From 224ab57805c3608a7a97c118d051b131685466bc Mon Sep 17 00:00:00 2001 From: liuy <37787198+LiuyCodes@users.noreply.github.com> Date: Thu, 31 Oct 2024 18:40:33 +0800 Subject: [PATCH] =?UTF-8?q?refactor(sales):=20=E9=87=8D=E6=9E=84=E9=94=80?= =?UTF-8?q?=E5=94=AE=E5=87=BA=E5=BA=93=E5=8D=95=E4=BC=98=E6=83=A0=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91-=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=86=E4=BC=98=E6=83=A0=E9=87=91=E9=A2=9D=E7=9A=84?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E6=96=B9=E5=BC=8F=EF=BC=8C=E5=B0=86=E5=AE=9E?= =?UTF-8?q?=E4=BB=98=E9=87=91=E9=A2=9D=E4=B8=8E=E5=90=84=E7=A7=8D=E4=BC=98?= =?UTF-8?q?=E6=83=A0=E9=87=91=E9=A2=9D=E5=88=86=E5=BC=80=E5=A4=84=E7=90=86?= =?UTF-8?q?=20-=20=E4=BC=98=E5=8C=96=E4=BA=86=E4=BB=A3=E7=A0=81=E7=BB=93?= =?UTF-8?q?=E6=9E=84=EF=BC=8C=E6=8F=90=E9=AB=98=E4=BA=86=E5=8F=AF=E8=AF=BB?= =?UTF-8?q?=E6=80=A7=E5=92=8C=E5=8F=AF=E7=BB=B4=E6=8A=A4=E6=80=A7=20-=20?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BA=86=E9=83=A8=E5=88=86=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=EF=BC=8C=E4=BB=A5=E9=80=82=E5=BA=94=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91=20-=20=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E4=BA=86=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E5=92=8C=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sales/SoSaleOutPluginInitializerToC.java | 298 +++++++++++++----- .../plugin/lets/u8cdto/SonDetailsDto.java | 12 +- .../SoSaleOutPluginInitializerToCTest.java | 8 +- .../lets/util/QueryU8CEntityUtilTest.java | 2 +- .../dto/ofssalesordersearch/DetailsDto.java | 12 + 5 files changed, 241 insertions(+), 91 deletions(-) diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java index eaeae1a8..0ab843c7 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java @@ -968,6 +968,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { BigDecimal noriginalcursummny = null;//价税合计 BigDecimal noriginalcurtaxmny = null;//税额 try { + //汇总好的金额/汇总好的实出数量 noriginalcurtaxprice = sonDetailsDto.getGroupTotalPayAmount().divide(sonDetailsDto.getGroupShipQty(), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); noriginalcurprice = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); noriginalcurmny = noriginalcurprice.multiply(sonDetailsDto.getGroupShipQty()).setScale(2, BigDecimal.ROUND_HALF_UP); @@ -1013,23 +1014,23 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { // saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目 // saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj()); //如果优惠金额为0,则传0 - if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef4(sonDetailsDto.getVdef4().stripTrailingZeros().toPlainString()); + if (sonDetailsDto != null && sonDetailsDto.getVdef4() != null) { + saleorderRequestChildrenDto.setVdef4(new BigDecimal(sonDetailsDto.getVdef4()).stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef4("0"); } - if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef5().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef5(sonDetailsDto.getVdef5().stripTrailingZeros().toPlainString()); + if (sonDetailsDto != null && sonDetailsDto.getVdef5() != null) { + saleorderRequestChildrenDto.setVdef5(new BigDecimal(sonDetailsDto.getVdef5()).stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef5("0"); } - if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef6().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef6(sonDetailsDto.getVdef6().stripTrailingZeros().toPlainString()); + if (sonDetailsDto != null && sonDetailsDto.getVdef6() != null) { + saleorderRequestChildrenDto.setVdef6(new BigDecimal(sonDetailsDto.getVdef6()).stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef6("0"); } - if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef7().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef7(sonDetailsDto.getVdef7().stripTrailingZeros().toPlainString()); + if (sonDetailsDto != null && sonDetailsDto.getVdef7() != null) { + saleorderRequestChildrenDto.setVdef7(new BigDecimal(sonDetailsDto.getVdef7()).stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef7("0"); } @@ -1037,8 +1038,6 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //判断是否增加邮费这个存货,accumulatedPostage BigDecimal accumulatedPostage = checkPostageFee(oldValue); - //测试:测试 - accumulatedPostage = new BigDecimal("6"); if (accumulatedPostage != null && accumulatedPostage.compareTo(BigDecimal.ZERO) > 0) { //获取「平台运维」对应的税率 String tax2 = new BigDecimal(bdTaxitemsEntity.getTaxratio()).divide(new BigDecimal(100), 20, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString(); @@ -1219,7 +1218,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { List headerDetailsDtos = queryOfsOrder(headerDetailsDtoList); findMatchingOfsOrder(headerDetailsDtos, headerDetailsDtoList); //计算OFS销售订单优惠金额分摊到明细行 - ofsOrderSaleAmountAllocationUtil.batchTocSalesAmountAllocation(headerDetailsDtos); +// ofsOrderSaleAmountAllocationUtil.batchTocSalesAmountAllocation(headerDetailsDtos); //计算OFS销售订单邮费分摊 ofsOrderSalePostageFeeAllocationUtil.batchTocSalesPostageFeeAllocation(headerDetailsDtos); //初始化公司档案对照关系 @@ -1684,23 +1683,26 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { for (int i = 0; i < sonDetailsDtoList.size(); i++) { SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(i); - HeaderDto header = sonDetailsDto.getHeader(); - BdInvmandocEntity bdInvmandocEntity = sonDetailsDto.getBdInvmandocEntity(); + HeaderDto header = sonDetailsDto.getHeader();//销售出库单表头 + BdInvmandocEntity bdInvmandocEntity = sonDetailsDto.getBdInvmandocEntity();//存货管理档案 + com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = sonDetailsDto.getHeaderDetailsDto();//OFS销售订单 //实付金额/实发数量 //OFS销售订单实付金额:totalPayAmount //OFS销售出库单实付金额:totalPayAmount //是一样的字段,目前暂时取销售出库单对应的totalPayAmount String totalPayAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, sonDetailsDto, mapList); if (totalPayAmount == null) { + //触发取实付金额的逻辑,因此需要累加:O实付金额+O达人优惠+O支付优惠+O平台优惠 //取O实付金额 - totalPayAmount = sonDetailsDto.getTotalPayAmount(); +// totalPayAmount = sonDetailsDto.getTotalPayAmount(); + totalPayAmount = accumulatedDiscounts(sonDetailsDto, headerDetailsDto); } else { //取结存单价、或者采购单价 BigDecimal totalPayAmountBigDecimal = new BigDecimal(totalPayAmount); totalPayAmount = totalPayAmountBigDecimal.multiply(new BigDecimal(sonDetailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString(); } - Assert.notNull(totalPayAmount, "实付金额不能为空 明细行对象:{}", JSON.toJSONString(sonDetailsDto)); - Assert.notNull(sonDetailsDto.getShipQty(), "实发数量不能为空 明细行对象:{}", JSON.toJSONString(sonDetailsDto)); + Assert.notNull(totalPayAmount, "实发数量不能为空 销售出库单编码:{} 出库单明细主键:{}", header.getCode(), sonDetailsDto.getId()); + Assert.notNull(sonDetailsDto.getShipQty(), "实发数量不能为空 销售出库单编码:{} 出库单明细主键:{}", header.getCode(), sonDetailsDto.getId()); BigDecimal totalPayAmountBigDecimal = new BigDecimal(sonDetailsDto.getTotalPayAmount()); BigDecimal shipQtyBigDecimal = new BigDecimal(sonDetailsDto.getShipQty()); @@ -1708,11 +1710,12 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { groupShipQty = groupShipQty.add(shipQtyBigDecimal); } SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(0); - sonDetailsDto.setGroupShipQty(groupShipQty); - sonDetailsDto.setGroupTotalPayAmount(groupTotalPayAmount); + sonDetailsDto.setGroupShipQty(groupShipQty);//汇总好的实发数量 + sonDetailsDto.setGroupTotalPayAmount(groupTotalPayAmount);//汇总总金额 //累加4个优惠金额,放在第0号元素 - accumulationDiscountAmount(sonDetailsDtoList); +// accumulationDiscountAmount(sonDetailsDtoList); + accumulatedDiscountAmountDef(sonDetailsDtoList); //累加各类优惠 logger.info("{}个明细行发生了合并!", sonDetailsDtoList.size()); @@ -2004,23 +2007,23 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { // saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目 // saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj()); //如果优惠金额为0,则传0 - if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef4("-" + sonDetailsDto.getVdef4().stripTrailingZeros().toPlainString()); + if (sonDetailsDto != null && sonDetailsDto.getVdef4() != null) { + saleorderRequestChildrenDto.setVdef4("-" + new BigDecimal(sonDetailsDto.getVdef4()).stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef4("0"); } - if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef5().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef5("-" + sonDetailsDto.getVdef5().stripTrailingZeros().toPlainString()); + if (sonDetailsDto != null && sonDetailsDto.getVdef5() != null) { + saleorderRequestChildrenDto.setVdef5("-" + new BigDecimal(sonDetailsDto.getVdef5()).stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef5("0"); } - if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef6().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef6("-" + sonDetailsDto.getVdef6().stripTrailingZeros().toPlainString()); + if (sonDetailsDto != null && sonDetailsDto.getVdef6() != null) { + saleorderRequestChildrenDto.setVdef6("-" + new BigDecimal(sonDetailsDto.getVdef6()).stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef6("0"); } - if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef7().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef7("-" + sonDetailsDto.getVdef7().stripTrailingZeros().toPlainString()); + if (sonDetailsDto != null && sonDetailsDto.getVdef7() != null) { + saleorderRequestChildrenDto.setVdef7("-" + new BigDecimal(sonDetailsDto.getVdef7()).stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef7("0"); } @@ -2028,8 +2031,6 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //判断是否增加邮费这个存货,accumulatedPostage BigDecimal accumulatedPostage = checkPostageFee(oldValue); - //测试 -// accumulatedPostage = new BigDecimal("6"); if (accumulatedPostage != null && accumulatedPostage.compareTo(BigDecimal.ZERO) > 0) { //获取「平台运维」对应的税率 String tax2 = "0." + new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString(); @@ -2209,23 +2210,23 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { // saleorderRequestChildrenDto.setCreccalbodyid(bdCalbodyEntity1.getPkCalbody());//收货库存组织:2024年8月7日 16:21:48 和佳妮、道品一起测试,收货库存组织、收货仓库 是不需要传递的 // saleorderRequestChildrenDto.setCrecwareid(bdStordocEntity1.getPkStordoc());//收货仓库 //如果优惠金额为0,则传0 - if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef4(sonDetailsDto.getVdef4().stripTrailingZeros().toPlainString()); + if (sonDetailsDto != null && sonDetailsDto.getVdef4() != null) { + saleorderRequestChildrenDto.setVdef4(new BigDecimal(sonDetailsDto.getVdef4()).stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef4("0"); } - if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef5().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef5(sonDetailsDto.getVdef5().stripTrailingZeros().toPlainString()); + if (sonDetailsDto != null && sonDetailsDto.getVdef5() != null) { + saleorderRequestChildrenDto.setVdef5(new BigDecimal(sonDetailsDto.getVdef5()).stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef5("0"); } - if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef6().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef6(sonDetailsDto.getVdef6().stripTrailingZeros().toPlainString()); + if (sonDetailsDto != null && sonDetailsDto.getVdef6() != null) { + saleorderRequestChildrenDto.setVdef6(new BigDecimal(sonDetailsDto.getVdef6()).stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef6("0"); } - if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef7().stripTrailingZeros().toPlainString())) { - saleorderRequestChildrenDto.setVdef7(sonDetailsDto.getVdef7().stripTrailingZeros().toPlainString()); + if (sonDetailsDto != null && sonDetailsDto.getVdef7() != null) { + saleorderRequestChildrenDto.setVdef7(new BigDecimal(sonDetailsDto.getVdef7()).stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef7("0"); } @@ -2233,8 +2234,6 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //判断是否增加邮费这个存货,accumulatedPostage BigDecimal accumulatedPostage = checkPostageFee(oldValue); - //测试 -// accumulatedPostage = new BigDecimal("6"); if (accumulatedPostage != null && accumulatedPostage.compareTo(BigDecimal.ZERO) > 0) { //获取「平台运维」对应的税率 String tax2 = "0." + new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString(); @@ -2932,52 +2931,52 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { * * @author liuyang */ - private void accumulationDiscountAmount(List sonDetailsDtoList) throws Exception { - Assert.notNull(sonDetailsDtoList, "sonDetailsDtoList不能为空"); - - if (sonDetailsDtoList.size() > 0) { - BigDecimal totalShareTargetPlatformDiscounts = new BigDecimal("0"); - BigDecimal totalShareTargetMerchantDiscounts = new BigDecimal("0"); - BigDecimal totalShareTargetExpertDiscounts = new BigDecimal("0"); - BigDecimal totalShareTargetPayDiscounts = new BigDecimal("0"); - - for (int i = 0; i < sonDetailsDtoList.size(); i++) { - SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(i); - com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = sonDetailsDto.getHeaderDetailsDto(); - Assert.notNull(headerDetailsDto, "无法关联到OFS销售订单 销售订单号:{}", sonDetailsDto.getRefOrderCode()); - com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header = headerDetailsDto.getHeader(); - List details = headerDetailsDto.getDetails(); - - //四舍五入保留2位 - com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto ofsOrderDetail = findOfsOrderDetail(details, sonDetailsDto); - if (ofsOrderDetail.getShareTargetPlatformDiscounts() != null) { - totalShareTargetPlatformDiscounts = totalShareTargetPlatformDiscounts.add(ofsOrderDetail.getShareTargetPlatformDiscounts()); - } - if (ofsOrderDetail.getShareTargetMerchantDiscounts() != null) { - totalShareTargetMerchantDiscounts = totalShareTargetMerchantDiscounts.add(ofsOrderDetail.getShareTargetMerchantDiscounts()); - } - if (ofsOrderDetail.getShareTargetExpertDiscounts() != null) { - totalShareTargetExpertDiscounts = totalShareTargetExpertDiscounts.add(ofsOrderDetail.getShareTargetExpertDiscounts()); - } - if (ofsOrderDetail.getShareTargetPayDiscounts() != null) { - totalShareTargetPayDiscounts = totalShareTargetPayDiscounts.add(ofsOrderDetail.getShareTargetPayDiscounts()); - } -// logger.info("对应的销售订单明细行主键:{}", ofsOrderDetail.getId()); - } - - SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(0); - HeaderDto header = sonDetailsDto.getHeader(); - - sonDetailsDto.setVdef4(totalShareTargetPlatformDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP)); - sonDetailsDto.setVdef5(totalShareTargetMerchantDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP)); - sonDetailsDto.setVdef6(totalShareTargetExpertDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP)); - sonDetailsDto.setVdef7(totalShareTargetPayDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP)); - - logger.info("出库单明细主键:{} 出库单号:{} 最终汇总好的平台优惠:{}、支付优惠:{}、达人优惠:{}、商家优惠:{}", sonDetailsDto.getId(), header.getCode(), sonDetailsDto.getVdef4(), sonDetailsDto.getVdef5(), sonDetailsDto.getVdef6(), sonDetailsDto.getVdef7()); - } else { - logger.info("accumulationDiscountAmount方法对应的sonDetailsDtoList.size为零!"); - } - } +// private void accumulationDiscountAmount(List sonDetailsDtoList) throws Exception { +// Assert.notNull(sonDetailsDtoList, "sonDetailsDtoList不能为空"); +// +// if (sonDetailsDtoList.size() > 0) { +// BigDecimal totalShareTargetPlatformDiscounts = new BigDecimal("0"); +// BigDecimal totalShareTargetMerchantDiscounts = new BigDecimal("0"); +// BigDecimal totalShareTargetExpertDiscounts = new BigDecimal("0"); +// BigDecimal totalShareTargetPayDiscounts = new BigDecimal("0"); +// +// for (int i = 0; i < sonDetailsDtoList.size(); i++) { +// SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(i); +// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = sonDetailsDto.getHeaderDetailsDto(); +// Assert.notNull(headerDetailsDto, "无法关联到OFS销售订单 销售订单号:{}", sonDetailsDto.getRefOrderCode()); +// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header = headerDetailsDto.getHeader(); +// List details = headerDetailsDto.getDetails(); +// +// //四舍五入保留2位 +// com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto ofsOrderDetail = findOfsOrderDetail(details, sonDetailsDto); +// if (ofsOrderDetail.getShareTargetPlatformDiscounts() != null) { +// totalShareTargetPlatformDiscounts = totalShareTargetPlatformDiscounts.add(ofsOrderDetail.getShareTargetPlatformDiscounts()); +// } +// if (ofsOrderDetail.getShareTargetMerchantDiscounts() != null) { +// totalShareTargetMerchantDiscounts = totalShareTargetMerchantDiscounts.add(ofsOrderDetail.getShareTargetMerchantDiscounts()); +// } +// if (ofsOrderDetail.getShareTargetExpertDiscounts() != null) { +// totalShareTargetExpertDiscounts = totalShareTargetExpertDiscounts.add(ofsOrderDetail.getShareTargetExpertDiscounts()); +// } +// if (ofsOrderDetail.getShareTargetPayDiscounts() != null) { +// totalShareTargetPayDiscounts = totalShareTargetPayDiscounts.add(ofsOrderDetail.getShareTargetPayDiscounts()); +// } +//// logger.info("对应的销售订单明细行主键:{}", ofsOrderDetail.getId()); +// } +// +// SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(0); +// HeaderDto header = sonDetailsDto.getHeader(); +// +// sonDetailsDto.setVdef4(totalShareTargetPlatformDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP)); +// sonDetailsDto.setVdef5(totalShareTargetMerchantDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP)); +// sonDetailsDto.setVdef6(totalShareTargetExpertDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP)); +// sonDetailsDto.setVdef7(totalShareTargetPayDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP)); +// +// logger.info("出库单明细主键:{} 出库单号:{} 最终汇总好的平台优惠:{}、支付优惠:{}、达人优惠:{}、商家优惠:{}", sonDetailsDto.getId(), header.getCode(), sonDetailsDto.getVdef4(), sonDetailsDto.getVdef5(), sonDetailsDto.getVdef6(), sonDetailsDto.getVdef7()); +// } else { +// logger.info("accumulationDiscountAmount方法对应的sonDetailsDtoList.size为零!"); +// } +// } /** * 根据OFS销售出库单明细行,查找OFS销售订单明细行 @@ -3283,4 +3282,133 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { } return bdTaxitemsEntityList.get(0); } + + /** + * 累加应收金额=实付金额+达人优惠+支付优惠+平台优惠 + * + * @param sonDetailsDto OFS销售出库单明细行 + * @param headerDetailsDto OFS销售订单表头对象 + */ + private String accumulatedDiscounts(SonDetailsDto sonDetailsDto, com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto) throws Exception { + Assert.notNull(sonDetailsDto, "sonDetailsDto OFS销售出库单明细不能为空!"); + Assert.notNull(headerDetailsDto, "headerDetailsDto OFS销售订单不能为空!"); + + com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header = headerDetailsDto.getHeader(); + List details = headerDetailsDto.getDetails(); + + //根据出库单明细匹配销售订单明细行 + com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto targetDetails = null; + for (int i = 0; i < details.size(); i++) { + com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto detailsDto = details.get(i); + if (detailsDto.getId() != null && sonDetailsDto.getRefOrderDetailId() != null) { + if (detailsDto.getId().equals(sonDetailsDto.getRefOrderDetailId())) { + targetDetails = detailsDto; + } + } + } + Assert.notNull(targetDetails, "根据销售出库单明细行(refOrderDetailId)无法匹配销售订单明细行", sonDetailsDto.getRefOrderDetailId()); + + //实付金额 + String totalPayAmount = sonDetailsDto.getTotalPayAmount(); + //商家优惠:不处理!!!仅保存 + String merchantDiscounts = targetDetails.getMerchantDiscounts(); + //达人优惠 + String expertDiscounts = targetDetails.getExpertDiscounts(); + //支付优惠 + String payDiscounts = targetDetails.getPayDiscounts(); + //平台优惠 + String platformDiscounts = targetDetails.getPlatformDiscounts(); + +// sonDetailsDto.setVdef4(platformDiscounts); +// sonDetailsDto.setVdef5(payDiscounts); +// sonDetailsDto.setVdef6(expertDiscounts); +// sonDetailsDto.setVdef7(merchantDiscounts); + + BigDecimal totalBigDecimal = new BigDecimal("0"); + BigDecimal totalPayAmountBigDecimal = new BigDecimal("0"); + BigDecimal expertDiscountsBigDecimal = new BigDecimal("0"); + BigDecimal payDiscountsBigDecimal = new BigDecimal("0"); + BigDecimal platformDiscountsBigDecimal = new BigDecimal("0"); + + if (totalPayAmount != null && !"".equals(totalPayAmount)) { + totalPayAmountBigDecimal = new BigDecimal(totalPayAmount); + } + if (expertDiscounts != null && !"".equals(expertDiscounts)) { + expertDiscountsBigDecimal = new BigDecimal(expertDiscounts); + } + if (payDiscounts != null && !"".equals(payDiscounts)) { + payDiscountsBigDecimal = new BigDecimal(payDiscounts); + } + if (platformDiscounts != null && !"".equals(platformDiscounts)) { + platformDiscountsBigDecimal = new BigDecimal(platformDiscounts); + } + + //总合 + totalBigDecimal = totalBigDecimal.add(totalPayAmountBigDecimal); + totalBigDecimal = totalBigDecimal.add(expertDiscountsBigDecimal); + totalBigDecimal = totalBigDecimal.add(payDiscountsBigDecimal); + totalBigDecimal = totalBigDecimal.add(platformDiscountsBigDecimal); + return totalBigDecimal.stripTrailingZeros().toPlainString(); + } + + /** + * 累加优惠金额,放在自定义项里 + * + * @param sonDetailsDtoList OFS销售出库单明细行(按纬度汇总好的) + * @author liuyang + */ + private void accumulatedDiscountAmountDef(List sonDetailsDtoList) { + Assert.notNull(sonDetailsDtoList, "sonDetailsDtoList不能为空"); + + if (sonDetailsDtoList.size() > 0) { + BigDecimal platformDiscountsBigDecimal = new BigDecimal("0");//平台 + BigDecimal merchantDiscountsBigDecimal = new BigDecimal("0");//商家 + BigDecimal expertDiscountsBigDecimal = new BigDecimal("0");//达人 + BigDecimal payDiscountsBigDecimal = new BigDecimal("0");//支付 + for (int i = 0; i < sonDetailsDtoList.size(); i++) { + SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(i); + HeaderDto header = sonDetailsDto.getHeader(); + com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = sonDetailsDto.getHeaderDetailsDto();//OFS销售订单号 + Assert.notNull(headerDetailsDto, "O出库单对应的销售订单不能为空 O出库单编码:{}", header.getCode()); + List details = headerDetailsDto.getDetails();//OFS销售订单明细行 + if (details != null && details.size() > 0) { + for (int j = 0; j < details.size(); j++) { + com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto detailsDto = details.get(j); + if (sonDetailsDto.getRefOrderDetailId() != null && detailsDto.getId() != null) { + if (sonDetailsDto.getRefOrderDetailId().equals(detailsDto.getId())) { + //累加优惠 + String platformDiscounts = detailsDto.getPlatformDiscounts(); + String merchantDiscounts = detailsDto.getMerchantDiscounts(); + String expertDiscounts = detailsDto.getExpertDiscounts(); + String payDiscounts = detailsDto.getPayDiscounts(); + + if (platformDiscounts == null || "".equals(platformDiscounts.trim())) { + platformDiscounts = "0"; + } + if (merchantDiscounts == null || "".equals(merchantDiscounts.trim())) { + merchantDiscounts = "0"; + } + if (expertDiscounts == null || "".equals(expertDiscounts.trim())) { + expertDiscounts = "0"; + } + if (payDiscounts == null || "".equals(payDiscounts.trim())) { + payDiscounts = "0"; + } + + platformDiscountsBigDecimal = platformDiscountsBigDecimal.add(new BigDecimal(platformDiscounts)); + merchantDiscountsBigDecimal = merchantDiscountsBigDecimal.add(new BigDecimal(merchantDiscounts)); + expertDiscountsBigDecimal = expertDiscountsBigDecimal.add(new BigDecimal(expertDiscounts)); + payDiscountsBigDecimal = payDiscountsBigDecimal.add(new BigDecimal(payDiscounts)); + } + } + } + } + } + + sonDetailsDtoList.get(0).setVdef4(platformDiscountsBigDecimal.stripTrailingZeros().toPlainString()); + sonDetailsDtoList.get(0).setVdef5(payDiscountsBigDecimal.stripTrailingZeros().toPlainString()); + sonDetailsDtoList.get(0).setVdef6(expertDiscountsBigDecimal.stripTrailingZeros().toPlainString()); + sonDetailsDtoList.get(0).setVdef7(merchantDiscountsBigDecimal.stripTrailingZeros().toPlainString()); + } + } } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/SonDetailsDto.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/SonDetailsDto.java index 834364d4..80233081 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/SonDetailsDto.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/SonDetailsDto.java @@ -81,14 +81,18 @@ public class SonDetailsDto extends DetailsDto { private com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto; //累加平台优惠 - private BigDecimal vdef4; + //改为原始平台优惠 + private String vdef4; //累加支付优惠 - private BigDecimal vdef5; + //改为原始支付优惠 + private String vdef5; //累加达人优惠 - private BigDecimal vdef6; + //改为原始达人优惠 + private String vdef6; //累加商家优惠 - private BigDecimal vdef7; + //改为原始商家优惠 + private String vdef7; } \ No newline at end of file diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java index 58b78411..3ceca42a 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java @@ -112,11 +112,17 @@ class SoSaleOutPluginInitializerToCTest { // String aaa = "LETS-SH2024102900016893"; // soSaleOutPluginInitializerToC.startImplementStockByCode(aaa, "tran"); - soSaleOutPluginInitializerToC.startImplementStockByTime("2024-10-30 00:00:00", "2024-10-30 23:59:59"); +// soSaleOutPluginInitializerToC.startImplementStockByTime("2024-10-30 00:00:00", "2024-10-30 23:59:59"); } catch (Exception e) { e.printStackTrace(); } // soSaleOutPluginInitializerToC.sendU8CTOCOrder("123446"); + + try { + soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024102600009446", "stock"); + } catch (Exception e) { + e.printStackTrace(); + } } } \ No newline at end of file diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/QueryU8CEntityUtilTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/QueryU8CEntityUtilTest.java index a5a2f588..a8d6076d 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/QueryU8CEntityUtilTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/QueryU8CEntityUtilTest.java @@ -69,7 +69,7 @@ public class QueryU8CEntityUtilTest { @Test public void testGetFuzzyQueryCustomers() { try { - String aaa = "188"; + String aaa = "9279"; queryU8CEntityUtil.getFuzzyQueryCustomers(aaa); } catch (Exception e) { e.printStackTrace(); diff --git a/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssalesordersearch/DetailsDto.java b/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssalesordersearch/DetailsDto.java index dbbdad78..2b49d041 100755 --- a/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssalesordersearch/DetailsDto.java +++ b/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssalesordersearch/DetailsDto.java @@ -91,4 +91,16 @@ public class DetailsDto { //实际运费分摊金额 private BigDecimal shareTargetFreightDiscounts; //邮费分摊end------------––------- + + + //销售订单明细行优惠金额start------------––----- + //平台优惠 + private String platformDiscounts; + //商家优惠 + private String merchantDiscounts; + //达人优惠 + private String expertDiscounts; + //支付优惠 + private String payDiscounts; + //销售订单明细行优惠金额end------------––------- } \ No newline at end of file