From f8e66e6208f128792c5e5dec58c38672499db9a2 Mon Sep 17 00:00:00 2001 From: Gauthier LO Date: Wed, 27 Nov 2024 16:19:26 +0100 Subject: [PATCH] feat : extra fees, fixes --- .../config/mybatis/MybatisInterceptor.java | 29 ++++++++- .../base/event/SkuWeightModifiedEvent.java | 17 +++++ .../controller/admin/ExtraFeeController.java | 36 ++++++----- .../controller/admin/SkuWeightController.java | 6 ++ .../shippingInvoice/InvoiceController.java | 51 +++++++++++---- .../admin/shippingInvoice/InvoiceDatas.java | 13 +++- .../client/TransactionController.java | 3 + .../business/domain/excel/SheetManager.java | 21 +++++-- .../job/ConfirmedClientsInvoicingJob.java | 6 +- .../business/domain/job/MabangSkuSyncJob.java | 9 ++- .../domain/job/SkuAssociationToClientJob.java | 3 +- .../business/domain/job/VipInvoicingJob.java | 8 ++- .../shippingInvoice/CompleteInvoice.java | 6 +- .../shippingInvoice/ShippingInvoice.java | 34 +++++++--- .../ShippingInvoiceFactory.java | 62 ++++++++++++------- .../business/mapper/ExtraFeeMapper.java | 8 +++ .../business/mapper/xml/ExtraFeeMapper.xml | 50 +++++++++++++++ .../mongoService/SkuMongoService.java | 11 ++-- .../mongoService/SkuMongoSyncService.java | 34 +++++++--- .../impl/SkuMongoServiceImpl.java | 54 ++++++++++------ .../business/service/IExtraFeeService.java | 8 +++ .../PlatformOrderShippingInvoiceService.java | 48 +++++++++++++- .../service/impl/ExtraFeeServiceImpl.java | 20 ++++++ .../service/impl/InvoiceServiceImpl.java | 3 + .../impl/SkuListMabangServiceImpl.java | 7 ++- 25 files changed, 436 insertions(+), 111 deletions(-) create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/event/SkuWeightModifiedEvent.java diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/config/mybatis/MybatisInterceptor.java b/jeecg-boot-base-core/src/main/java/org/jeecg/config/mybatis/MybatisInterceptor.java index 0f2f8e7af..424c49b17 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/config/mybatis/MybatisInterceptor.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/config/mybatis/MybatisInterceptor.java @@ -12,7 +12,9 @@ import org.jeecg.common.config.TenantContext; import org.jeecg.common.constant.TenantConstant; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.base.event.SkuDeclaredValueModifiedEvent; import org.jeecg.modules.base.event.SkuModifiedEvent; +import org.jeecg.modules.base.event.SkuPriceModifiedEvent; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Component; @@ -37,6 +39,9 @@ public class MybatisInterceptor implements Interceptor { @Autowired private ApplicationEventPublisher eventPublisher; + private static final String INSERT_SUCCESS_MSG = "添加成功!"; + private static final String UPDATE_SUCCESS_MSG = "修改成功!"; + @Override public Object intercept(Invocation invocation) throws Throwable { MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0]; @@ -181,15 +186,35 @@ public class MybatisInterceptor implements Interceptor { String operationStatus = dto.getLogContent().split(",")[2]; String requestParam = dto.getRequestParam(); if(table.equals("sku")) { - if(operationStatus.equals("添加成功!")) { + if(operationStatus.equals(INSERT_SUCCESS_MSG)) { String id = extractIdFromRequestParam(requestParam); eventPublisher.publishEvent(new SkuModifiedEvent(this, id, "INSERT")); } - if(operationStatus.equals("修改成功!")) { + if(operationStatus.equals(UPDATE_SUCCESS_MSG)) { String id = extractIdFromRequestParam(requestParam); eventPublisher.publishEvent(new SkuModifiedEvent(this, id, "UPDATE")); } } + if(table.equals("sku_price")) { + if(operationStatus.equals(INSERT_SUCCESS_MSG)) { + String id = extractIdFromRequestParam(requestParam); + eventPublisher.publishEvent(new SkuPriceModifiedEvent(this, id, "INSERT")); + } + if(operationStatus.equals(UPDATE_SUCCESS_MSG)) { + String id = extractIdFromRequestParam(requestParam); + eventPublisher.publishEvent(new SkuPriceModifiedEvent(this, id, "UPDATE")); + } + } + if(table.equals("sku_declared_value")) { + if(operationStatus.equals(INSERT_SUCCESS_MSG)) { + String id = extractIdFromRequestParam(requestParam); + eventPublisher.publishEvent(new SkuDeclaredValueModifiedEvent(this, id, "INSERT")); + } + if(operationStatus.equals(UPDATE_SUCCESS_MSG)) { + String id = extractIdFromRequestParam(requestParam); + eventPublisher.publishEvent(new SkuDeclaredValueModifiedEvent(this, id, "UPDATE")); + } + } } } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/event/SkuWeightModifiedEvent.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/event/SkuWeightModifiedEvent.java new file mode 100644 index 000000000..530f84fb6 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/event/SkuWeightModifiedEvent.java @@ -0,0 +1,17 @@ +package org.jeecg.modules.base.event; + +import lombok.Getter; +import org.springframework.context.ApplicationEvent; + +@Getter +public class SkuWeightModifiedEvent extends ApplicationEvent { + private final String id; + private final String operation; // "INSERT", "UPDATE", "DELETE" + + public SkuWeightModifiedEvent(Object source, String id, String operation) { + super(source); + this.id = id; + this.operation = operation; + } + +} \ No newline at end of file diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/ExtraFeeController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/ExtraFeeController.java index 6eadbafbf..d4a032ad7 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/ExtraFeeController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/ExtraFeeController.java @@ -102,30 +102,30 @@ public class ExtraFeeController extends JeecgController add(@RequestBody ExtraFee extraFees) { - extraFeeService.save(extraFees); + public Result add(@RequestBody ExtraFee extraFee) { + extraFeeService.save(extraFee); return Result.OK("添加成功!"); } /** * 编辑 * - * @param extraFees + * @param extraFee * @return */ @AutoLog(value = "extra fee content-编辑") @ApiOperation(value="extra fee content-编辑", notes="extra fee content-编辑") @RequiresPermissions("business:extra_fee:edit") @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) - public Result edit(@RequestBody ExtraFee extraFees) { - extraFeeService.updateById(extraFees); + public Result edit(@RequestBody ExtraFee extraFee) { + extraFeeService.updateById(extraFee); return Result.OK("编辑成功!"); } @@ -137,11 +137,17 @@ public class ExtraFeeController extends JeecgController delete(@RequestParam(name="id",required=true) String id) { + public Result delete(@RequestParam(name="id") String id) { + ExtraFee extraFee = extraFeeService.getById(id); + if(extraFee == null) { + return Result.error(404,"Fee not found"); + } + if(extraFee.getInvoiceNumber() != null) { + return Result.error(403, "Cannot delete invoiced fee"); + } extraFeeService.removeById(id); - return Result.OK("删除成功!"); + return Result.OK(); } /** @@ -169,23 +175,23 @@ public class ExtraFeeController extends JeecgController queryById(@RequestParam(name="id",required=true) String id) { - ExtraFee extraFees = extraFeeService.getById(id); - if(extraFees==null) { + ExtraFee extraFee = extraFeeService.getById(id); + if(extraFee==null) { return Result.error("未找到对应数据"); } - return Result.OK(extraFees); + return Result.OK(extraFee); } /** * 导出excel * * @param request - * @param extraFees + * @param extraFee */ @RequiresPermissions("business:extra_fee:exportXls") @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, ExtraFee extraFees) { - return super.exportXls(request, extraFees, ExtraFee.class, "extra fee content"); + public ModelAndView exportXls(HttpServletRequest request, ExtraFee extraFee) { + return super.exportXls(request, extraFee, ExtraFee.class, "extra fee content"); } /** diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/SkuWeightController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/SkuWeightController.java index cb0a3fcc0..606fcc9bc 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/SkuWeightController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/SkuWeightController.java @@ -13,6 +13,7 @@ import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.business.entity.Sku; import org.jeecg.modules.business.entity.SkuWeight; +import org.jeecg.modules.business.mongoService.SkuMongoService; import org.jeecg.modules.business.service.ISecurityService; import org.jeecg.modules.business.service.ISkuService; import org.jeecg.modules.business.service.ISkuWeightService; @@ -25,6 +26,7 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.modules.business.vo.SkuWeightParam; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import io.swagger.annotations.Api; @@ -49,6 +51,8 @@ public class SkuWeightController extends JeecgController updateBatch(@RequestBody SkuWeightParam param) { boolean isEmployee = securityService.checkIsEmployee(); @@ -204,6 +209,7 @@ public class SkuWeightController extends JeecgController factureDetails = shippingInvoiceService.getInvoiceDetail(invoiceNumber); List refunds = savRefundWithDetailService.getRefundsByInvoiceNumber(invoiceNumber); - return shippingInvoiceService.exportToExcel(factureDetails, refunds, invoiceNumber, invoiceEntity, internalCode); + List extraFees = extraFeeService.findByInvoiceNumber(invoiceNumber); + return shippingInvoiceService.exportToExcel(factureDetails, refunds, extraFees, invoiceNumber, invoiceEntity, internalCode); } @GetMapping(value = "/downloadInvoiceInventory") public byte[] downloadInvoiceInventory(@RequestParam("invoiceCode") String invoiceCode, @RequestParam("internalCode") String internalCode, @RequestParam("invoiceEntity") String invoiceEntity) throws IOException { @@ -881,7 +884,8 @@ public class InvoiceController { filenameList.add(INVOICE_DIR + "//" + metaData.getFilename()); List factureDetails = shippingInvoiceService.getInvoiceDetail(metaData.getInvoiceCode()); List refunds = savRefundWithDetailService.getRefundsByInvoiceNumber(metaData.getInvoiceCode()); - shippingInvoiceService.exportToExcel(factureDetails, refunds, metaData.getInvoiceCode(), metaData.getInvoiceEntity(), metaData.getInternalCode()); + List extraFees = extraFeeService.findByInvoiceNumber(metaData.getInvoiceCode()); + shippingInvoiceService.exportToExcel(factureDetails, refunds, extraFees, metaData.getInvoiceCode(), metaData.getInvoiceEntity(), metaData.getInternalCode()); filenameList.add(INVOICE_DETAIL_DIR + "//" + metaData.getInternalCode() + "_(" + metaData.getInvoiceEntity() + ")_" + metaData.getInvoiceCode() + "_Détail_calcul_de_facture.xlsx"); } log.info("Generating detail files ...{}/{}", cpt++, invoiceList.size()); @@ -1088,12 +1092,29 @@ public class InvoiceController { List platformOrderList = iShippingInvoiceService.getPlatformOrder(invoiceNumber); List refundList = iSavRefundService.getRefundAmount(invoiceNumber); - Map> feeAndQtyPerCountry = new HashMap<>(); // it maps number of order and shipping fee per country : >, > + List extraFees = extraFeeService.findByInvoiceNumber(invoiceNumber); + Map feeAndQtyPerCountry = new HashMap<>(); // it maps number of order and shipping fee per country : >, > BigDecimal serviceFee = BigDecimal.ZERO; // po.order_service_fee + poc.service_fee BigDecimal pickingFee = BigDecimal.ZERO; BigDecimal packagingMatFee = BigDecimal.ZERO; BigDecimal vat = BigDecimal.ZERO; BigDecimal refund = BigDecimal.ZERO; + Map extraFeesMap = new HashMap<>(); // <"extra fee name", >, <"extra fee name", >, ... + + if(extraFees != null) { + for(ExtraFeeResult extraFee : extraFees) { + if(!extraFeesMap.containsKey(extraFee.getEnName())) { + Fee fee = new Fee(extraFee.getQuantity(), extraFee.getUnitPrice()); + extraFeesMap.put(extraFee.getEnName(), fee); + } + else { + Integer existingQuantity = extraFeesMap.get(extraFee.getEnName()).getQuantity(); + Fee fee = new Fee(existingQuantity + extraFee.getQuantity(), extraFee.getUnitPrice()); + extraFeesMap.remove(extraFee.getEnName()); + extraFeesMap.put(extraFee.getEnName(), fee); + } + } + } // on parcours toutes les commandes pour récupérer : country, order_service_fee, fret_fee, picking_fee for(PlatformOrder p : platformOrderList) { @@ -1115,15 +1136,18 @@ public class InvoiceController { // si oui on additionne la "qty" et "shipping fee" // sinon on ajoute juste à la map if(!feeAndQtyPerCountry.containsKey(country)) { - feeAndQtyPerCountry.put(country, new AbstractMap.SimpleEntry<>(1, shippingFee)); + Fee fee = new Fee(1, shippingFee); + feeAndQtyPerCountry.put(country, fee); } else { - BigDecimal existingGlobalFee = feeAndQtyPerCountry.get(country).getValue(); - Integer existingOrderQuantity = feeAndQtyPerCountry.get(country).getKey(); + BigDecimal existingGlobalFee = feeAndQtyPerCountry.get(country).getUnitPrice(); + Integer existingOrderQuantity = feeAndQtyPerCountry.get(country).getQuantity(); existingOrderQuantity ++; existingGlobalFee = existingGlobalFee.add(shippingFee); + + Fee fee = new Fee(existingOrderQuantity, existingGlobalFee); feeAndQtyPerCountry.remove(country); - feeAndQtyPerCountry.put(country, new AbstractMap.SimpleEntry<>(existingOrderQuantity, existingGlobalFee)); + feeAndQtyPerCountry.put(country, fee); } } // on fait la somme des remboursements @@ -1149,6 +1173,7 @@ public class InvoiceController { invoiceDatas.setPickingFee(pickingFee); invoiceDatas.setPackagingMaterialFee(packagingMatFee); invoiceDatas.setFeeAndQtyPerCountry(feeAndQtyPerCountry); + invoiceDatas.setExtraFees(extraFeesMap); return Result.OK(invoiceDatas); } @@ -1168,7 +1193,7 @@ public class InvoiceController { invoiceData.addAll(purchaseOrderContentMapper.selectInvoiceDataByID(order.getId())); } List refundList = iSavRefundService.getRefundAmount(invoiceNumber); - Map> feeAndQtyPerSku = new HashMap<>(); // it maps number of order and purchase fee per item : >, > + Map feeAndQtyPerSku = new HashMap<>(); // it maps number of order and purchase fee per item : >, > BigDecimal refund = BigDecimal.ZERO; // on parcours toutes les commandes pour récupérer : country, purchaseFee @@ -1180,15 +1205,17 @@ public class InvoiceController { // si oui on additionne la "qty" et "purchase fee" // sinon on ajoute juste à la map if(!feeAndQtyPerSku.containsKey(sku)) { - feeAndQtyPerSku.put(sku, new AbstractMap.SimpleEntry<>(qty, purchaseFeePerSku)); + Fee fee = new Fee(qty, purchaseFeePerSku); + feeAndQtyPerSku.put(sku, fee); } else { - BigDecimal existingGlobalFee = feeAndQtyPerSku.get(sku).getValue(); - Integer existingOrderQuantity = feeAndQtyPerSku.get(sku).getKey(); + BigDecimal existingGlobalFee = feeAndQtyPerSku.get(sku).getUnitPrice(); + Integer existingOrderQuantity = feeAndQtyPerSku.get(sku).getQuantity(); existingOrderQuantity += qty; existingGlobalFee = existingGlobalFee.add(purchaseFeePerSku); + Fee fee = new Fee(existingOrderQuantity, existingGlobalFee); feeAndQtyPerSku.remove(sku); - feeAndQtyPerSku.put(sku, new AbstractMap.SimpleEntry<>(existingOrderQuantity, existingGlobalFee)); + feeAndQtyPerSku.put(sku, fee); } } // on fait la somme des remboursements diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/shippingInvoice/InvoiceDatas.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/shippingInvoice/InvoiceDatas.java index 8984d4380..660d24205 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/shippingInvoice/InvoiceDatas.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/admin/shippingInvoice/InvoiceDatas.java @@ -1,6 +1,7 @@ package org.jeecg.modules.business.controller.admin.shippingInvoice; import com.alibaba.fastjson.annotation.JSONField; +import lombok.Builder; import lombok.Data; import java.math.BigDecimal; @@ -11,9 +12,9 @@ public class InvoiceDatas { @JSONField(name = "invoiceNumber") private String invoiceNumber; @JSONField(name = "feeAndQtyPerSku") - private Map> feeAndQtyPerSku; + private Map feeAndQtyPerSku; @JSONField(name = "feeAndQtyPerCountry") - private Map> feeAndQtyPerCountry; + private Map feeAndQtyPerCountry; @JSONField(name = "vat") private BigDecimal vat; @JSONField(name = "serviceFee") @@ -30,5 +31,13 @@ public class InvoiceDatas { private BigDecimal finalAmountEur; @JSONField(name = "finalAmount") private BigDecimal finalAmount; + @JSONField(name = "extraFees") + private Map extraFees; } +@Data +@Builder +class Fee { + private Integer quantity; + private BigDecimal unitPrice; +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/client/TransactionController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/client/TransactionController.java index 89c933f36..d4b937285 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/client/TransactionController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/client/TransactionController.java @@ -31,6 +31,8 @@ import java.util.stream.Collectors; @RequestMapping("/transaction") @Slf4j public class TransactionController { + @Autowired + private IExtraFeeService extraFeeService; @Autowired private EmailService emailService; @Autowired @@ -107,6 +109,7 @@ public class TransactionController { List shippingOrderIds = shippingOrders.stream().map(PlatformOrder::getId).collect(Collectors.toList()); log.info("Estimating shipping fees for {}", shippingOrderIds.size()); ShippingInvoiceFactory factory = new ShippingInvoiceFactory( + extraFeeService, platformOrderService, clientMapper, shopMapper, logisticChannelMapper, logisticChannelPriceMapper, platformOrderContentService, skuDeclaredValueService, countryService, exchangeRatesMapper, purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService, emailService, env); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/excel/SheetManager.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/excel/SheetManager.java index 8cd38daca..7f0b694d8 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/excel/SheetManager.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/excel/SheetManager.java @@ -24,6 +24,8 @@ public class SheetManager { private final Sheet savSheet; + private final Sheet extraFeeSheet; + private Sheet currentSheet; private int currentRow; @@ -32,10 +34,11 @@ public class SheetManager { private int max_col; - private SheetManager(Workbook workbook, Sheet detailSheet, Sheet savSheet) { + private SheetManager(Workbook workbook, Sheet detailSheet, Sheet savSheet, Sheet extraFeeSheet) { this.workbook = workbook; this.detailSheet = detailSheet; this.savSheet = savSheet; + this.extraFeeSheet = extraFeeSheet; this.currentRow = 0; this.currentCol = 0; max_col = 10; @@ -48,7 +51,7 @@ public class SheetManager { * @return the sheetManager instance. */ public static SheetManager createXLSX() { - return createXLSX("Détails", "SAV"); + return createXLSX("Détails", "SAV", "Frais supplémentaires"); } /** @@ -58,11 +61,12 @@ public class SheetManager { * @param savSheetName SAV sheet name * @return the sheetManager object. */ - public static SheetManager createXLSX(String detailSheetName, String savSheetName) { + public static SheetManager createXLSX(String detailSheetName, String savSheetName, String extraFeeSheetName) { Workbook workbook = new XSSFWorkbook(); Sheet detailSheet = workbook.createSheet(detailSheetName); Sheet savSheet = workbook.createSheet(savSheetName); - return new SheetManager(workbook, detailSheet, savSheet); + Sheet extraFeeSheet = workbook.createSheet(extraFeeSheetName); + return new SheetManager(workbook, detailSheet, savSheet, extraFeeSheet); } public void startDetailsSheet() { @@ -75,6 +79,12 @@ public class SheetManager { this.currentCol = 0; } + public void startExtraFeeSheet() { + this.currentSheet = extraFeeSheet; + this.currentRow = 0; + this.currentCol = 0; + } + /** * Same as {@code readXLS} but for ".xlsx" Excel workbook. * @@ -85,7 +95,7 @@ public class SheetManager { public static SheetManager readXLSX(Path path) throws IOException { FileInputStream fis = new FileInputStream(path.toFile()); Workbook workbook = new XSSFWorkbook(fis); - return new SheetManager(workbook, workbook.getSheetAt(0), workbook.getSheetAt(1)); + return new SheetManager(workbook, workbook.getSheetAt(0), workbook.getSheetAt(1), workbook.getSheetAt(2)); } /** @@ -204,6 +214,7 @@ public class SheetManager { for (int i = 0; i < max_col; i++) { detailSheet.autoSizeColumn(i); savSheet.autoSizeColumn(i); + extraFeeSheet.autoSizeColumn(i); } FileOutputStream fos = new FileOutputStream(target.toFile()); workbook.write(fos); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/job/ConfirmedClientsInvoicingJob.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/job/ConfirmedClientsInvoicingJob.java index 7920ca82d..9b5226905 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/job/ConfirmedClientsInvoicingJob.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/job/ConfirmedClientsInvoicingJob.java @@ -6,6 +6,7 @@ import org.jeecg.modules.business.entity.Client; import org.jeecg.modules.business.entity.SavRefundWithDetail; import org.jeecg.modules.business.service.*; import org.jeecg.modules.business.vo.BalanceData; +import org.jeecg.modules.business.vo.ExtraFeeResult; import org.jeecg.modules.business.vo.FactureDetail; import org.jeecg.modules.business.vo.InvoiceMetaData; import org.quartz.Job; @@ -36,6 +37,8 @@ public class ConfirmedClientsInvoicingJob implements Job { @Autowired private EmailService emailService; @Autowired + private IExtraFeeService extraFeeService; + @Autowired private PlatformOrderShippingInvoiceService platformOrderShippingInvoiceService; @Autowired private ISavRefundWithDetailService savRefundWithDetailService; @@ -100,8 +103,9 @@ public class ConfirmedClientsInvoicingJob implements Job { invoicedMetaDataList.add(metaData); List factureDetails = platformOrderShippingInvoiceService.getInvoiceDetail(metaData.getInvoiceCode()); List refunds = savRefundWithDetailService.getRefundsByInvoiceNumber(metaData.getInvoiceCode()); + List extraFess = extraFeeService.findByInvoiceNumber(metaData.getInvoiceCode()); try { - platformOrderShippingInvoiceService.exportToExcel(factureDetails, refunds, metaData.getInvoiceCode(), metaData.getInvoiceEntity(), metaData.getInternalCode()); + platformOrderShippingInvoiceService.exportToExcel(factureDetails, refunds, extraFess, metaData.getInvoiceCode(), metaData.getInvoiceEntity(), metaData.getInternalCode()); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/job/MabangSkuSyncJob.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/job/MabangSkuSyncJob.java index 9ec443482..295e5bd0f 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/job/MabangSkuSyncJob.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/job/MabangSkuSyncJob.java @@ -9,6 +9,7 @@ import org.codehaus.jettison.json.JSONObject; import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.*; import org.jeecg.modules.business.entity.Sku; import org.jeecg.modules.business.entity.SkuWeight; +import org.jeecg.modules.business.model.SkuDocument; import org.jeecg.modules.business.mongoService.SkuMongoService; import org.jeecg.modules.business.service.EmailService; import org.jeecg.modules.business.service.ISkuListMabangService; @@ -137,8 +138,12 @@ public class MabangSkuSyncJob implements Job { // Mongo sync after update transaction for(Sku sku : updatedSkuRemarkMap.keySet()) { skuMongoService.updateSkuFromMabangSync(sku); - SkuWeight skuWeight = skuWeightService.getBySkuId(sku.getId()); - skuMongoService.updateSkuWeight(sku.getErpCode(), skuWeight.getWeight()); + // TODO : pb if we update weight locally and the effective date is not now, then we cannot update it on Mabang and thus creating a conflict. +// SkuWeight skuWeight = skuWeightService.getBySkuId(sku.getId()); +// SkuDocument skuDocument = skuMongoService.findBySkuId(sku.getId()); +// if(skuDocument.getLatestSkuWeight().getWeight() != skuWeight.getWeight()) { +// skuMongoService.upsertSkuWeight(skuWeight); +// } } Map skusNeedTreatmentMap = new HashMap<>(updatedSkuRemarkMap); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/job/SkuAssociationToClientJob.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/job/SkuAssociationToClientJob.java index 2ea9b28af..f27c316f7 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/job/SkuAssociationToClientJob.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/job/SkuAssociationToClientJob.java @@ -21,8 +21,7 @@ import java.util.*; import java.util.stream.Collectors; /** - * A Job that retrieves all Sku from Mabang - * if the sku is of status 3 (normal) and not in DB, then we insert it in DB + * A Job that pairs sku with client based on sku suffix */ @Slf4j @Component diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/job/VipInvoicingJob.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/job/VipInvoicingJob.java index 6c6bf7b57..be4927921 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/job/VipInvoicingJob.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/job/VipInvoicingJob.java @@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.modules.business.entity.*; import org.jeecg.modules.business.service.*; import org.jeecg.modules.business.vo.BalanceData; +import org.jeecg.modules.business.vo.ExtraFeeResult; import org.jeecg.modules.business.vo.FactureDetail; import org.jeecg.modules.business.vo.InvoiceMetaData; import org.quartz.Job; @@ -12,6 +13,7 @@ import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; import org.springframework.ui.freemarker.FreeMarkerTemplateUtils; import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; @@ -25,6 +27,7 @@ import java.util.*; import java.util.stream.Collectors; @Slf4j +@Component public class VipInvoicingJob implements Job { @Autowired private IBalanceService balanceService; @@ -33,6 +36,8 @@ public class VipInvoicingJob implements Job { @Autowired private EmailService emailService; @Autowired + private IExtraFeeService extraFeeService; + @Autowired private PlatformOrderShippingInvoiceService platformOrderShippingInvoiceService; @Autowired private ISavRefundWithDetailService savRefundWithDetailService; @@ -76,8 +81,9 @@ public class VipInvoicingJob implements Job { invoicedMetaDataList.add(metaData); List factureDetails = platformOrderShippingInvoiceService.getInvoiceDetail(metaData.getInvoiceCode()); List refunds = savRefundWithDetailService.getRefundsByInvoiceNumber(metaData.getInvoiceCode()); + List extraFees = extraFeeService.findByInvoiceNumber(metaData.getInvoiceCode()); try { - platformOrderShippingInvoiceService.exportToExcel(factureDetails, refunds, metaData.getInvoiceCode(), metaData.getInvoiceEntity(), metaData.getInternalCode()); + platformOrderShippingInvoiceService.exportToExcel(factureDetails, refunds, extraFees, metaData.getInvoiceCode(), metaData.getInvoiceEntity(), metaData.getInternalCode()); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/shippingInvoice/CompleteInvoice.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/shippingInvoice/CompleteInvoice.java index b7d50b9be..d8807acf3 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/shippingInvoice/CompleteInvoice.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/shippingInvoice/CompleteInvoice.java @@ -6,6 +6,7 @@ import org.jeecg.modules.business.entity.Client; import org.jeecg.modules.business.entity.PlatformOrder; import org.jeecg.modules.business.entity.PlatformOrderContent; import org.jeecg.modules.business.entity.SavRefundWithDetail; +import org.jeecg.modules.business.vo.ExtraFeeResult; import org.jeecg.modules.business.vo.PromotionDetail; import java.math.BigDecimal; @@ -24,9 +25,10 @@ public class CompleteInvoice extends ShippingInvoice { public CompleteInvoice(Client targetClient, String code, String subject, Map> ordersToContent, - List savRefunds, List purchaseInvoiceEntries, + List savRefunds, List extraFees, + List purchaseInvoiceEntries, List promotions, BigDecimal exchangeRate) { - super(targetClient, code, subject, ordersToContent, savRefunds, exchangeRate); + super(targetClient, code, subject, ordersToContent, savRefunds, extraFees,exchangeRate); this.purchaseInvoiceEntries = purchaseInvoiceEntries; this.promotions = promotions; } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/shippingInvoice/ShippingInvoice.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/shippingInvoice/ShippingInvoice.java index 9ae0e5fba..595a284f5 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/shippingInvoice/ShippingInvoice.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/shippingInvoice/ShippingInvoice.java @@ -1,10 +1,13 @@ package org.jeecg.modules.business.domain.shippingInvoice; +import lombok.Getter; +import lombok.Setter; import org.apache.poi.ss.usermodel.*; import org.jeecg.modules.business.domain.invoice.AbstractInvoice; import org.jeecg.modules.business.domain.invoice.InvoiceStyleFactory; import org.jeecg.modules.business.domain.invoice.Row; import org.jeecg.modules.business.entity.*; +import org.jeecg.modules.business.vo.ExtraFeeResult; import java.math.BigDecimal; import java.util.ArrayList; @@ -20,16 +23,21 @@ public class ShippingInvoice extends AbstractInvoice> ordersToContent; private final List savRefunds; - + private final List extraFees; + @Getter + @Setter private BigDecimal totalAmount; public ShippingInvoice(Client targetClient, String code, String subject, Map> ordersToContent, - List savRefunds, BigDecimal exchangeRate) { + List savRefunds, + List extraFees, + BigDecimal exchangeRate) { super(targetClient, code, subject, exchangeRate); this.ordersToContent = ordersToContent; this.savRefunds = savRefunds; + this.extraFees = extraFees; totalAmount = BigDecimal.ZERO; } @@ -144,19 +152,25 @@ public class ShippingInvoice extends AbstractInvoice extraFeeRow = new Row<>( + extraFee.getDescription() == null ? extraFee.getEnName() : extraFee.getDescription(), + extraFee.getUnitPrice(), + extraFee.getQuantity(), + null, + extraFeeAmount + ); + rows.add(extraFeeRow); + totalAmount = totalAmount.add(extraFeeAmount); + } + } totalAmount = totalAmount.add(vatForEU); return rows; } - public BigDecimal getTotalAmount() { - return totalAmount; - } - - public void setTotalAmount(BigDecimal totalAmount) { - this.totalAmount = totalAmount; - } - public BigDecimal reducedAmount() { return BigDecimal.ZERO; } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/shippingInvoice/ShippingInvoiceFactory.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/shippingInvoice/ShippingInvoiceFactory.java index 01504aff0..44601db9f 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/shippingInvoice/ShippingInvoiceFactory.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/domain/shippingInvoice/ShippingInvoiceFactory.java @@ -14,10 +14,7 @@ import org.jeecg.modules.business.domain.purchase.invoice.PurchaseInvoiceEntry; import org.jeecg.modules.business.entity.*; import org.jeecg.modules.business.mapper.*; import org.jeecg.modules.business.service.*; -import org.jeecg.modules.business.vo.PromotionDetail; -import org.jeecg.modules.business.vo.ShippingFeesEstimation; -import org.jeecg.modules.business.vo.SkuQuantity; -import org.jeecg.modules.business.vo.SkuWeightDiscountServiceFees; +import org.jeecg.modules.business.vo.*; import org.jeecg.modules.business.vo.clientPlatformOrder.section.OrdersStatisticData; import org.jetbrains.annotations.NotNull; import org.simpleframework.xml.core.Complete; @@ -45,6 +42,7 @@ import static java.util.stream.Collectors.*; @Component public class ShippingInvoiceFactory { + private final IExtraFeeService extraFeeService; private final IPlatformOrderService platformOrderService; private final ClientMapper clientMapper; private final ShopMapper shopMapper; @@ -80,7 +78,7 @@ public class ShippingInvoiceFactory { } }); - public ShippingInvoiceFactory(IPlatformOrderService platformOrderService, ClientMapper clientMapper, + public ShippingInvoiceFactory(IExtraFeeService extraFeeService, IPlatformOrderService platformOrderService, ClientMapper clientMapper, ShopMapper shopMapper, LogisticChannelMapper logisticChannelMapper, LogisticChannelPriceMapper logisticChannelPriceMapper, IPlatformOrderContentService platformOrderContentService, @@ -89,6 +87,7 @@ public class ShippingInvoiceFactory { PurchaseOrderContentMapper purchaseOrderContentMapper, SkuPromotionHistoryMapper skuPromotionHistoryMapper, ISavRefundService savRefundService, ISavRefundWithDetailService savRefundWithDetailService, EmailService emailService, Environment env) { + this.extraFeeService = extraFeeService; this.platformOrderService = platformOrderService; this.clientMapper = clientMapper; this.shopMapper = shopMapper; @@ -137,6 +136,7 @@ public class ShippingInvoiceFactory { .map(PlatformOrder::getShopId) .distinct() .collect(Collectors.toList()); + List extraFees = extraFeeService.findNotInvoicedByShops(shopIds); log.info("Orders to be invoiced: {}", uninvoicedOrderToContent); String subject; if(type.equals("shipping")) @@ -147,7 +147,7 @@ public class ShippingInvoiceFactory { subject = String.format("Shipping fees, order time from %s to %s", start, end); else throw new UserException("Couldn't create shipping invoice of unknown type."); - return createInvoice(customerId, shopIds, uninvoicedOrderToContent, savRefunds, subject, true); + return createInvoice(customerId, shopIds, uninvoicedOrderToContent, savRefunds, extraFees, subject, true); } /** @@ -182,6 +182,7 @@ public class ShippingInvoiceFactory { .map(PlatformOrder::getShopId) .distinct() .collect(Collectors.toList()); + List extraFees = extraFeeService.findNotInvoicedByShops(shopIds); log.info("Orders to be invoiced: {}", uninvoicedOrderToContent); String subject; if(shippingMethod.equals("shipping")) @@ -194,8 +195,8 @@ public class ShippingInvoiceFactory { subject = String.format("Purchase and Shipping fees, order time from %s to %s", start, end); else throw new UserException("Couldn't create complete invoice for unknown shipping method"); if(balance != null) - return createCompleteInvoiceWithBalance(username, customerId, balance, shopIds, uninvoicedOrderToContent, savRefunds, subject); - return createInvoice(username, customerId, null, shopIds, uninvoicedOrderToContent, savRefunds, subject); + return createCompleteInvoiceWithBalance(username, customerId, balance, shopIds, uninvoicedOrderToContent, savRefunds, extraFees, subject); + return createInvoice(username, customerId, null, shopIds, uninvoicedOrderToContent, savRefunds, extraFees, subject); } @@ -224,7 +225,7 @@ public class ShippingInvoiceFactory { @Transactional public CompleteInvoice createInvoice(String username, String customerId, BigDecimal balance, List shopIds, Map> orderAndContent, - List savRefunds, String subject) throws UserException { + List savRefunds, List extraFees, String subject) throws UserException { Client client = clientMapper.selectById(customerId); log.info("User {} is creating a complete invoice for customer {}", username, client.getInternalCode()); @@ -261,10 +262,13 @@ public class ShippingInvoiceFactory { if (savRefunds != null) { updateSavRefundsInDb(savRefunds, invoiceCode); } - + if(extraFees != null) { + List extraFeesIds = extraFees.stream().map(ExtraFeeResult::getId).collect(toList()); + extraFeeService.updateInvoiceNumberByIds(extraFeesIds, invoiceCode); + } updateOrdersAndContentsInDb(orderAndContent); - return new CompleteInvoice(client, invoiceCode, subject, orderAndContent, savRefunds, + return new CompleteInvoice(client, invoiceCode, subject, orderAndContent, savRefunds, extraFees, purchaseOrderSkuList, promotionDetails, eurToUsd); } @@ -294,7 +298,7 @@ public class ShippingInvoiceFactory { @Transactional public CompleteInvoice createCompleteInvoiceWithBalance(String username, String customerId, BigDecimal balance, List shopIds, Map> orderAndContent, - List savRefunds, String subject) throws UserException, MessagingException { + List savRefunds, List extraFees, String subject) throws UserException, MessagingException { // sorting by order time orderAndContent = orderAndContent.entrySet().stream().sorted( Map.Entry.comparingByKey(Comparator.comparing(PlatformOrder::getOrderTime)) @@ -394,10 +398,13 @@ public class ShippingInvoiceFactory { if (savRefunds != null) { updateSavRefundsInDb(savRefunds, invoiceCode); } - + if(extraFees != null) { + List extraFeesIds = extraFees.stream().map(ExtraFeeResult::getId).collect(toList()); + extraFeeService.updateInvoiceNumberByIds(extraFeesIds, invoiceCode); + } updateOrdersAndContentsInDb(orderAndContent); - return new CompleteInvoice(client, invoiceCode, subject, orderAndContent, savRefunds, + return new CompleteInvoice(client, invoiceCode, subject, orderAndContent, savRefunds, extraFees, purchaseOrderSkuList, promotionDetails, eurToUsd); } @@ -480,6 +487,7 @@ public class ShippingInvoiceFactory { ); // find orders and their contents of the invoice Map> uninvoicedOrderToContent; + List extraFees = extraFeeService.findNotInvoicedByShops(shopIds); List savRefunds = savRefundWithDetailService.findUnprocessedRefundsByClient(customerId); String subject; if(erpStatuses.toString().equals("[3]")) { @@ -509,9 +517,9 @@ public class ShippingInvoiceFactory { uninvoicedOrderToContent = platformOrderService.findUninvoicedOrderContentsForShopsAndStatus(shopIds, begin, end, erpStatuses, warehouses); } if(balance != null) { - return createInvoiceWithBalance(customerId, balance, shopIds, uninvoicedOrderToContent, savRefunds, subject, false); + return createInvoiceWithBalance(customerId, balance, shopIds, uninvoicedOrderToContent, savRefunds, extraFees, subject, false); } - return createInvoice(customerId, shopIds, uninvoicedOrderToContent, savRefunds, subject, false); + return createInvoice(customerId, shopIds, uninvoicedOrderToContent, savRefunds, extraFees, subject, false); } /** @@ -541,6 +549,7 @@ public class ShippingInvoiceFactory { public ShippingInvoice createInvoice(String customerId, List shopIds, Map> orderAndContent, List savRefunds, + List extraFees, String subject, boolean skipShippingTimeComparing) throws UserException { log.info("Orders to be invoiced: {}", orderAndContent); if (orderAndContent == null || orderAndContent.size() == 0) { @@ -578,7 +587,11 @@ public class ShippingInvoiceFactory { if (savRefunds != null) { updateSavRefundsInDb(savRefunds, invoiceCode); } - ShippingInvoice invoice = new ShippingInvoice(client, invoiceCode, subject, orderAndContent, savRefunds, eurToUsd); + if(extraFees != null) { + List extraFeesIds = extraFees.stream().map(ExtraFeeResult::getId).collect(toList()); + extraFeeService.updateInvoiceNumberByIds(extraFeesIds, invoiceCode); + } + ShippingInvoice invoice = new ShippingInvoice(client, invoiceCode, subject, orderAndContent, savRefunds, extraFees, eurToUsd); updateOrdersAndContentsInDb(orderAndContent); return invoice; } @@ -610,6 +623,7 @@ public class ShippingInvoiceFactory { public ShippingInvoice createInvoiceWithBalance(String customerId, BigDecimal balance, List shopIds, Map> orderAndContent, List savRefunds, + List extraFees, String subject, boolean skipShippingTimeComparing) throws UserException { log.info("Orders to be invoiced: {}", orderAndContent); if (orderAndContent == null || orderAndContent.isEmpty()) { @@ -650,7 +664,7 @@ public class ShippingInvoiceFactory { if (savRefunds != null) { updateSavRefundsInDb(savRefunds, invoiceCode); } - ShippingInvoice invoice = new ShippingInvoice(client, invoiceCode, subject, orderAndContent, savRefunds, eurToUsd); + ShippingInvoice invoice = new ShippingInvoice(client, invoiceCode, subject, orderAndContent, savRefunds, extraFees, eurToUsd); updateOrdersAndContentsInDb(orderAndContent); return invoice; } @@ -1217,6 +1231,7 @@ public class ShippingInvoiceFactory { shopPackageMatFeeMap.put(shop.getId(), shop.getPackagingMaterialFee()); Map> orders = uninvoicedOrdersByShopId.get(shop.getId()); try { + List extraFees = extraFeeService.findNotInvoicedByShops(Collections.singletonList(shop.getId())); Map> orderIdErrorMap = calculateFees(null, logisticChannelMap, orders, channelPriceMap, countryList, skuRealWeights, skuServiceFees, latestDeclaredValues, client, shopServiceFeeMap,shopPackageMatFeeMap, null); if(!orderIdErrorMap.isEmpty()) { @@ -1224,7 +1239,7 @@ public class ShippingInvoiceFactory { throw new UserException(errorEntry.getValue().toString()); } BigDecimal eurToUsd = exchangeRatesMapper.getLatestExchangeRate("EUR", "USD"); - ShippingInvoice invoice = new ShippingInvoice(client, "", "", orders, null, eurToUsd); + ShippingInvoice invoice = new ShippingInvoice(client, "", "", orders, null, extraFees, eurToUsd); // Calculate total amounts invoice.tableData(); estimations.add(new ShippingFeesEstimation( @@ -1281,13 +1296,14 @@ public class ShippingInvoiceFactory { shopPackageMatFeeMap.put(shop.getId(), shop.getPackagingMaterialFee()); Map> orders = uninvoicedOrdersByShopId.get(shop.getId()); try { + List extraFees = extraFeeService.findNotInvoicedByShops(Collections.singletonList(shop.getId())); Map> platformOrderIdErrorMap = calculateFees(null, logisticChannelMap, orders, channelPriceMap, countryList, skuRealWeights, skuServiceFees, latestDeclaredValues, client, shopServiceFeeMap, shopPackageMatFeeMap, null); platformOrderIdErrorMap.forEach((key, value) -> errorMessages.addAll(value)); orders.entrySet().removeIf(entries -> platformOrderIdErrorMap.containsKey(entries.getKey().getId())); List estimationsOrderIds = orders.keySet().stream().map(PlatformOrder::getId).collect(Collectors.toList()); BigDecimal eurToUsd = exchangeRatesMapper.getLatestExchangeRate("EUR", "USD"); - ShippingInvoice invoice = new ShippingInvoice(client, "", "", orders, null, eurToUsd); + ShippingInvoice invoice = new ShippingInvoice(client, "", "", orders, null, extraFees, eurToUsd); // Calculate total amounts invoice.tableData(); estimations.add(new ShippingFeesEstimation( @@ -1304,6 +1320,7 @@ public class ShippingInvoiceFactory { log.info("Building existing shipping invoice : {} - Client ID : {}, ", invoiceCode, clientId); Map> ordersMapContent = platformOrderService.fetchOrderDataByInvoiceCode(invoiceCode); List savRefunds = savRefundWithDetailService.getRefundsByInvoiceNumber(invoiceCode); + List extraFees = extraFeeService.findByInvoiceNumber(invoiceCode); String subject; if(shippingMethod.equals("post-shipping")) { subject = String.format("Shipping fees from %s to %s", start, end); @@ -1316,7 +1333,7 @@ public class ShippingInvoiceFactory { Client client = clientMapper.selectById(clientId); BigDecimal eurToUsd = exchangeRatesMapper.getExchangeRateFromDate("EUR", "USD", start); - return new ShippingInvoice(client, invoiceCode, subject, ordersMapContent, savRefunds, eurToUsd); + return new ShippingInvoice(client, invoiceCode, subject, ordersMapContent, savRefunds, extraFees, eurToUsd); } public PurchaseInvoice buildExistingPurchaseInvoice (String invoiceCode) { PurchaseOrder order = purchaseOrderService.getPurchaseByInvoiceNumber(invoiceCode); @@ -1331,6 +1348,7 @@ public class ShippingInvoiceFactory { log.info("Building existing complete invoice : {} - Client ID : {}, ", invoiceCode, clientId); Map> ordersMapContent = platformOrderService.fetchOrderDataByInvoiceCode(invoiceCode); List savRefunds = savRefundWithDetailService.getRefundsByInvoiceNumber(invoiceCode); + List extraFees = extraFeeService.findByInvoiceNumber(invoiceCode); String subject; if(shippingMethod.equals("post-shipping")) subject = String.format("Purchase and Shipping fees from %s to %s", start, end); @@ -1343,7 +1361,7 @@ public class ShippingInvoiceFactory { List purchaseOrderSkuList = purchaseOrderContentMapper.selectInvoiceDataByID(purchaseID); List promotionDetails = skuPromotionHistoryMapper.selectPromotionByPurchase(purchaseID); - return new CompleteInvoice(client, invoiceCode, subject, ordersMapContent, savRefunds, + return new CompleteInvoice(client, invoiceCode, subject, ordersMapContent, savRefunds, extraFees, purchaseOrderSkuList, promotionDetails, eurToUsd); } } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/ExtraFeeMapper.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/ExtraFeeMapper.java index cdb7e804a..367d70fd6 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/ExtraFeeMapper.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/ExtraFeeMapper.java @@ -28,5 +28,13 @@ public interface ExtraFeeMapper extends BaseMapper { @Param("status") String status); void updateFee(@Param("id") String id, @Param("description") String description, @Param("qty") Integer quantity, @Param("price") BigDecimal unitPrice); + + List findNotInvoicedByShops(@Param("shopIds") List shopIds); + + void updateInvoiceNumberByIds(@Param("ids") List feeIds, @Param("invoiceNumber") String invoiceCode); + + List findByInvoiceNumber(@Param("invoiceNumber") String invoiceCode); + + void cancelInvoice(@Param("invoiceNumber") String invoiceNumber, @Param("clientId") String clientId); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/ExtraFeeMapper.xml b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/ExtraFeeMapper.xml index 8ecd8625f..d265c8374 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/ExtraFeeMapper.xml +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/ExtraFeeMapper.xml @@ -57,4 +57,54 @@ IF(option_id = (SELECT id FROM extra_fee_option WHERE en_name = 'Autres') AND invoice_number IS NULL, #{description}, description) WHERE id = #{id}; + + + UPDATE extra_fee + SET invoice_number = #{invoiceNumber} + WHERE id IN + + #{id} + + + + + UPDATE extra_fee + JOIN shop s ON extra_fee.shop_id = s.id + JOIN client c ON s.owner_id = c.id + SET invoice_number = NULL + WHERE invoice_number = #{invoiceNumber} + AND c.id = #{clientId}; + \ No newline at end of file diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mongoService/SkuMongoService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mongoService/SkuMongoService.java index 885a16b35..6d9b8de00 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mongoService/SkuMongoService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mongoService/SkuMongoService.java @@ -3,28 +3,31 @@ package org.jeecg.modules.business.mongoService; import org.jeecg.modules.business.entity.Sku; import org.jeecg.modules.business.entity.SkuDeclaredValue; import org.jeecg.modules.business.entity.SkuPrice; +import org.jeecg.modules.business.entity.SkuWeight; import org.jeecg.modules.business.model.SkuDocument; import org.jeecg.modules.business.vo.SkuOrderPage; -import java.math.BigDecimal; import java.util.List; public interface SkuMongoService { - void updateSkuWeight(String erpCode, Integer weight); SkuDocument findByErpCode(String erpCode); SkuDocument findBySkuId(String skuId); void findAndReplace(String field, String value, SkuDocument skuDocument); + void deleteBySkuId(String skuId); + void upsertSkuPrice(SkuPrice price); - void deleteBySkuId(String skuId); + void deleteSkuPriceBySkuId(String skuId); void upsertSkuDeclaredValue(SkuDeclaredValue skuDeclaredValue); void deleteSkuDeclaredValueBySkuId(String skuId); - void deleteSkuPriceBySkuId(String skuId); + void upsertSkuWeight(SkuWeight skuWeight); + + void deleteSkuWeightBySkuId(String skuId); void updateStock(Sku sku); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mongoService/SkuMongoSyncService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mongoService/SkuMongoSyncService.java index 20ff96b2e..10862fd92 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mongoService/SkuMongoSyncService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mongoService/SkuMongoSyncService.java @@ -4,15 +4,10 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.modules.base.event.SkuDeclaredValueModifiedEvent; import org.jeecg.modules.base.event.SkuModifiedEvent; import org.jeecg.modules.base.event.SkuPriceModifiedEvent; -import org.jeecg.modules.business.entity.SensitiveAttribute; -import org.jeecg.modules.business.entity.Sku; -import org.jeecg.modules.business.entity.SkuDeclaredValue; -import org.jeecg.modules.business.entity.SkuPrice; +import org.jeecg.modules.base.event.SkuWeightModifiedEvent; +import org.jeecg.modules.business.entity.*; import org.jeecg.modules.business.model.SkuDocument; -import org.jeecg.modules.business.service.ISensitiveAttributeService; -import org.jeecg.modules.business.service.ISkuDeclaredValueService; -import org.jeecg.modules.business.service.ISkuPriceService; -import org.jeecg.modules.business.service.ISkuService; +import org.jeecg.modules.business.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Service; @@ -29,6 +24,8 @@ public class SkuMongoSyncService { @Autowired private ISkuPriceService skuPriceService; @Autowired + private ISkuWeightService skuWeightService; + @Autowired private ISensitiveAttributeService sensitiveAttributeService; /** @@ -125,4 +122,25 @@ public class SkuMongoSyncService { break; } } + + @EventListener + public void handeSkuWeightModifiedEvent(SkuWeightModifiedEvent event) { + log.info("Received a SkuWeightModifiedEvent: {}", event); + String id = event.getId(); + String operation = event.getOperation(); + + SkuWeight skuWeight = skuWeightService.getById(id); + + switch (operation) { + case "INSERT": + case "UPDATE": + skuMongoService.upsertSkuWeight(skuWeight); + break; + case "DELETE": + skuMongoService.deleteSkuWeightBySkuId(skuWeight.getSkuId()); + break; + default: + break; + } + } } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mongoService/impl/SkuMongoServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mongoService/impl/SkuMongoServiceImpl.java index 86063974d..ad950e76c 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mongoService/impl/SkuMongoServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mongoService/impl/SkuMongoServiceImpl.java @@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j; import org.jeecg.modules.business.entity.Sku; import org.jeecg.modules.business.entity.SkuDeclaredValue; import org.jeecg.modules.business.entity.SkuPrice; +import org.jeecg.modules.business.entity.SkuWeight; import org.jeecg.modules.business.model.SkuDocument; import org.jeecg.modules.business.mongoRepository.SkuRepository; import org.jeecg.modules.business.mongoService.SkuMongoService; @@ -28,20 +29,6 @@ public class SkuMongoServiceImpl implements SkuMongoService { @Autowired private SkuRepository skuRepository; - @Override - public void updateSkuWeight(String erpCode, Integer weight) { - log.info("updateSkuWeight erpCode: {}, weight: {}", erpCode, weight); - Query query = new Query(Criteria.where("erpCode").is(erpCode)); - Update update = new Update().set("weight", weight); - - UpdateResult result = mongoTemplate.updateFirst(query, update, SkuDocument.class); - - if(result == null) - log.error("updateSkuWeight failed"); - else - log.info("{} document(s) updated ..", result.getModifiedCount()); - } - @Override public SkuDocument findByErpCode(String erpCode) { return skuRepository.findByErpCode(erpCode); @@ -63,6 +50,12 @@ public class SkuMongoServiceImpl implements SkuMongoService { .findAndReplace(); } + @Override + public void deleteBySkuId(String skuId) { + Query query = new Query(Criteria.where("skuId").is(skuId)); + mongoTemplate.findAndRemove(query, SkuDocument.class); + } + @Override public void upsertSkuPrice(SkuPrice price) { Query query = new Query(Criteria.where("skuId").is(price.getSkuId())); @@ -91,9 +84,14 @@ public class SkuMongoServiceImpl implements SkuMongoService { } @Override - public void deleteBySkuId(String skuId) { + public void deleteSkuPriceBySkuId(String skuId) { Query query = new Query(Criteria.where("skuId").is(skuId)); - mongoTemplate.findAndRemove(query, SkuDocument.class); + mongoTemplate.update(SkuDocument.class) + .matching(query) + .apply(new Update() + .unset("latestSkuPrice") + ) + .findAndModifyValue(); } @Override @@ -126,16 +124,33 @@ public class SkuMongoServiceImpl implements SkuMongoService { } @Override - public void deleteSkuPriceBySkuId(String skuId) { + public void upsertSkuWeight(SkuWeight skuWeight) { + Query query = new Query(Criteria.where("skuId").is(skuWeight.getSkuId())); + SkuDocument.LatestSkuWeight latestSkuWeight = SkuDocument.LatestSkuWeight.builder() + .weight(skuWeight.getWeight()) + .effectiveDate(skuWeight.getEffectiveDate()) + .build(); + mongoTemplate.update(SkuDocument.class) + .matching(query) + .apply(new Update() + .set("latestSkuWeight", latestSkuWeight) + .set("updateTime", skuWeight.getCreateTime()) + .set("updateBy", skuWeight.getCreateBy()) + ) + .withOptions(FindAndModifyOptions.options().upsert(true)) + .findAndModifyValue(); + } + + @Override + public void deleteSkuWeightBySkuId(String skuId) { Query query = new Query(Criteria.where("skuId").is(skuId)); mongoTemplate.update(SkuDocument.class) .matching(query) .apply(new Update() - .unset("latestSkuPrice") + .unset("latestSkuWeight") ) .findAndModifyValue(); } - @Override public void updateStock(Sku sku) { Query query = new Query(Criteria.where("skuId").is(sku.getId())); @@ -187,6 +202,7 @@ public class SkuMongoServiceImpl implements SkuMongoService { return skuOrderPages.stream() .map(this::convertSkuDocumentToSkuOrderPage).collect(Collectors.toList()); } + public SkuOrderPage convertSkuDocumentToSkuOrderPage(SkuDocument skuDocument) { SkuOrderPage skuOrderPage = new SkuOrderPage(); skuOrderPage.setId(skuDocument.getSkuId()); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IExtraFeeService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IExtraFeeService.java index 19be9498b..06d4d0578 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IExtraFeeService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IExtraFeeService.java @@ -20,4 +20,12 @@ public interface IExtraFeeService extends IService { Integer countAllFees(String shop, String status); void updateFee(ExtraFeeParam feeParam) throws Exception; + + List findNotInvoicedByShops(List shopIds); + + void updateInvoiceNumberByIds(List feeIds, String invoiceCode); + + List findByInvoiceNumber(String invoiceCode); + + void cancelInvoice(String invoiceNumber, String clientId); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/PlatformOrderShippingInvoiceService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/PlatformOrderShippingInvoiceService.java index baa40113d..c5a26cefb 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/PlatformOrderShippingInvoiceService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/PlatformOrderShippingInvoiceService.java @@ -27,6 +27,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.math.BigDecimal; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -54,6 +55,8 @@ public class PlatformOrderShippingInvoiceService { @Autowired ICurrencyService currencyService; @Autowired + IExtraFeeService extraFeeService; + @Autowired ShippingInvoiceMapper shippingInvoiceMapper; @Autowired PlatformOrderMapper platformOrderMapper; @@ -160,6 +163,14 @@ public class PlatformOrderShippingInvoiceService { "Montant total du remboursement", "N° de facture" }; + private final static String[] EXTRA_FEE_TITLES = { + "Boutique", + "Type", + "Description", + "Quantité", + "Prix unitaire", + "N° de facture" + }; private final static String[] PURCHASE_INVENTORY_TITLES = { "SKU", "Nom Anglais", @@ -211,6 +222,7 @@ public class PlatformOrderShippingInvoiceService { public InvoiceMetaData makeInvoice(ShippingInvoiceParam param, String ... user) throws UserException, ParseException, IOException { // Creates factory ShippingInvoiceFactory factory = new ShippingInvoiceFactory( + extraFeeService, platformOrderService, clientMapper, shopMapper, logisticChannelMapper, logisticChannelPriceMapper, platformOrderContentService, skuDeclaredValueService, countryService, exchangeRatesMapper, purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService, emailService, env); @@ -242,6 +254,7 @@ public class PlatformOrderShippingInvoiceService { public InvoiceMetaData makeInvoice(ShippingInvoiceOrderParam param) throws UserException, ParseException, IOException { // Creates factory ShippingInvoiceFactory factory = new ShippingInvoiceFactory( + extraFeeService, platformOrderService, clientMapper, shopMapper, logisticChannelMapper, logisticChannelPriceMapper, platformOrderContentService, skuDeclaredValueService, countryService, exchangeRatesMapper, purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService, emailService, env); @@ -265,6 +278,7 @@ public class PlatformOrderShippingInvoiceService { public InvoiceMetaData makeCompleteInvoice(ShippingInvoiceOrderParam param) throws UserException, ParseException, IOException, MessagingException { // Creates factory ShippingInvoiceFactory factory = new ShippingInvoiceFactory( + extraFeeService, platformOrderService, clientMapper, shopMapper, logisticChannelMapper, logisticChannelPriceMapper, platformOrderContentService, skuDeclaredValueService, countryService, exchangeRatesMapper, purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService, emailService, env); @@ -287,6 +301,7 @@ public class PlatformOrderShippingInvoiceService { public InvoiceMetaData makeCompleteInvoicePostShipping(ShippingInvoiceParam param, String method, String ... user) throws UserException, ParseException, IOException, MessagingException { // Creates factory ShippingInvoiceFactory factory = new ShippingInvoiceFactory( + extraFeeService, platformOrderService, clientMapper, shopMapper, logisticChannelMapper, logisticChannelPriceMapper, platformOrderContentService, skuDeclaredValueService, countryService, exchangeRatesMapper, purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService, emailService, env); @@ -371,6 +386,7 @@ public class PlatformOrderShippingInvoiceService { public List getShippingFeesEstimation(List errorMessages) { // Creates factory ShippingInvoiceFactory factory = new ShippingInvoiceFactory( + extraFeeService, platformOrderService, clientMapper, shopMapper, logisticChannelMapper, logisticChannelPriceMapper, platformOrderContentService, skuDeclaredValueService, countryService, exchangeRatesMapper, purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService, emailService, env); @@ -386,6 +402,7 @@ public class PlatformOrderShippingInvoiceService { public List getShippingFeesEstimation(String clientId, List orderIds,List errorMessages) { // Creates factory ShippingInvoiceFactory factory = new ShippingInvoiceFactory( + extraFeeService, platformOrderService, clientMapper, shopMapper, logisticChannelMapper, logisticChannelPriceMapper, platformOrderContentService, skuDeclaredValueService, countryService, exchangeRatesMapper, purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService, emailService, env); @@ -413,7 +430,7 @@ public class PlatformOrderShippingInvoiceService { return factureDetailMapper.selectList(queryWrapper); } - public byte[] exportToExcel(List details, List refunds, String invoiceNumber, String invoiceEntity, String internalCode) throws IOException { + public byte[] exportToExcel(List details, List refunds, List extraFees, String invoiceNumber, String invoiceEntity, String internalCode) throws IOException { SheetManager sheetManager = SheetManager.createXLSX(); sheetManager.startDetailsSheet(); for (String title : DETAILS_TITLES) { @@ -498,6 +515,31 @@ public class PlatformOrderShippingInvoiceService { sheetManager.nextRow(); } + sheetManager.startExtraFeeSheet(); + for (String title: EXTRA_FEE_TITLES) { + sheetManager.write(title); + sheetManager.nextCol(); + } + + sheetManager.moveCol(0); + sheetManager.nextRow(); + + for (ExtraFeeResult extraFee: extraFees) { + sheetManager.write(extraFee.getShop()); + sheetManager.nextCol(); + sheetManager.write(extraFee.getEnName()); + sheetManager.nextCol(); + sheetManager.write(extraFee.getDescription()); + sheetManager.nextCol(); + sheetManager.write(extraFee.getQuantity()); + sheetManager.nextCol(); + sheetManager.write(extraFee.getUnitPrice()); + sheetManager.nextCol(); + sheetManager.write(extraFee.getInvoiceNumber()); + sheetManager.moveCol(0); + sheetManager.nextRow(); + } + Path target = Paths.get(INVOICE_DETAIL_DIR, internalCode + "_(" + invoiceEntity + ")_" + invoiceNumber + "_Détail_calcul_de_facture.xlsx"); int i = 2; while (Files.exists(target)) { @@ -750,7 +792,8 @@ public class PlatformOrderShippingInvoiceService { Client client = clientService.getClientFromInvoice(invoiceNumber); List details = getInvoiceDetail(invoiceNumber); List refunds = savRefundWithDetailService.getRefundsByInvoiceNumber(invoiceNumber); - exportToExcel(details, refunds, invoiceNumber, client.getInvoiceEntity(), client.getInternalCode()); + List extraFees = extraFeeService.findByInvoiceNumber(invoiceNumber); + exportToExcel(details, refunds, extraFees, invoiceNumber, client.getInvoiceEntity(), client.getInternalCode()); pathList = getPath(INVOICE_DETAIL_DIR, invoiceNumber); } else { @@ -834,6 +877,7 @@ public class PlatformOrderShippingInvoiceService { public List generateInvoiceExcel(String invoiceNumber, String filetype) throws UserException, IOException { ShippingInvoiceFactory factory = new ShippingInvoiceFactory( + extraFeeService, platformOrderService, clientMapper, shopMapper, logisticChannelMapper, logisticChannelPriceMapper, platformOrderContentService, skuDeclaredValueService, countryService, exchangeRatesMapper, purchaseOrderService, purchaseOrderContentMapper, skuPromotionHistoryMapper, savRefundService, savRefundWithDetailService, emailService, env); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/ExtraFeeServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/ExtraFeeServiceImpl.java index 290c12e95..bdd9c236b 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/ExtraFeeServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/ExtraFeeServiceImpl.java @@ -41,4 +41,24 @@ public class ExtraFeeServiceImpl extends ServiceImpl i } extraFeeMapper.updateFee(feeParam.getId(), feeParam.getDescription(), feeParam.getQuantity(), feeParam.getUnitPrice()); } + + @Override + public List findNotInvoicedByShops(List shopIds) { + return extraFeeMapper.findNotInvoicedByShops(shopIds); + } + + @Override + public void updateInvoiceNumberByIds(List feeIds, String invoiceCode) { + extraFeeMapper.updateInvoiceNumberByIds(feeIds, invoiceCode); + } + + @Override + public List findByInvoiceNumber(String invoiceCode) { + return extraFeeMapper.findByInvoiceNumber(invoiceCode); + } + + @Override + public void cancelInvoice(String invoiceNumber, String clientId) { + extraFeeMapper.cancelInvoice(invoiceNumber, clientId); + } } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/InvoiceServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/InvoiceServiceImpl.java index 055e6a9a0..2d371e8f4 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/InvoiceServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/InvoiceServiceImpl.java @@ -27,6 +27,8 @@ public class InvoiceServiceImpl extends ServiceImpl impl @Autowired private IClientService clientService; @Autowired + private IExtraFeeService extraFeeService; + @Autowired private IPlatformOrderContentService platformOrderContentService; @Autowired private IPlatformOrderService platformOrderService; @@ -57,6 +59,7 @@ public class InvoiceServiceImpl extends ServiceImpl impl public boolean cancelInvoice(String id, String invoiceNumber, String clientId) { String invoiceEntity = clientService.getById(clientId).getInvoiceEntity(); + extraFeeService.cancelInvoice(invoiceNumber, clientId); savRefundService.cancelInvoice(invoiceNumber, clientId); if(Invoice.getType(invoiceNumber).equalsIgnoreCase(PURCHASE.name())) { PurchaseOrder po = purchaseOrderService.getById(id); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/SkuListMabangServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/SkuListMabangServiceImpl.java index e8e6fc5a4..7658ab7ee 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/SkuListMabangServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/SkuListMabangServiceImpl.java @@ -444,8 +444,11 @@ public class SkuListMabangServiceImpl extends ServiceImpl