diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningIn.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningIn.java index 3cd3b73e..13755c0d 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningIn.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningIn.java @@ -263,7 +263,7 @@ public class ConsignmachiningIn extends PluginBaseEntity { queryOfsSoSaleOutVo.setPageSize(50L); queryOfsSoSaleOutVo.setCode(code); queryOfsSoSaleOutVo.setInternalInstructionType("PURCHASE"); - queryOfsSoSaleOutVo.setStatus(900L); +// queryOfsSoSaleOutVo.setStatus(900L); ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.receipt.search"); logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size()); if (returnGoodHeaderDetailsDataDtoArrayList.size() > 0) { diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToB.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToB.java index 8635a8ae..7a9e060c 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToB.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToB.java @@ -1002,7 +1002,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity { // memberId = "9387"; Assert.notNull(memberId, "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); Assert.state(!"".equals(memberId.trim()), "TOB销售订单(OFS)表头会员id不能为空,否则无法匹配U8C客商档案!"); - + //如果没有O单据名称,则默认为「销售」 if (header2.getSubOrderType() == null || "".equals(header2.getSubOrderType().trim())) { header2.setSubOrderType("SALES"); 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 43849c4b..55570452 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 @@ -11,6 +11,9 @@ import com.hzya.frame.base.PluginBaseEntity; import com.hzya.frame.beanutil.BeanUtil; import com.hzya.frame.plugin.lets.constant.OverallConstant; import com.hzya.frame.plugin.lets.constant.ProfilesActiveConstant; +import com.hzya.frame.plugin.lets.dao.IBdInvbasdocDao; +import com.hzya.frame.plugin.lets.dao.IBdInvmandocDao; +import com.hzya.frame.plugin.lets.dao.IBdTaxitemsDao; import com.hzya.frame.plugin.lets.entity.*; import com.hzya.frame.plugin.lets.ofs.dao.ITocofsSaleoutDao; import com.hzya.frame.plugin.lets.ofs.dao.ITocofsSaleoutDetailedDao; @@ -99,9 +102,21 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { private static final String TRAN = "tran"; + @Autowired + private IBdInvmandocDao iBdInvmandocDao; + + @Autowired + private OfsOrderSalePostageFeeAllocationUtil ofsOrderSalePostageFeeAllocationUtil; + @Autowired private QueryU8CEntityUtil queryU8CEntityUtil; + @Autowired + private IBdInvbasdocDao iBdInvbasdocDao; + + @Autowired + private IBdTaxitemsDao iBdTaxitemsDao; + @Override public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { try { @@ -753,6 +768,12 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { // BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("202"); //初始化所有存货管理档案对应的结存价+采购价 List mapList = initAllBalancePricePurchasePrice(); + //查询「平台运费」存货基本档案 + BdInvbasdocEntity bdInvbasdocEntity1 = queryStockBasicArchives(); + //查询「平台运费」对应的税率 + BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode()); + //查询「平台运费」所有公司的存货管理档案 + Map stringBdInvmandocEntityMap = queryInventoryMan(bdInvbasdocEntity1.getPkInvbasdoc()); if (bdBusitypeEntity != null && summaryDimensionMap != null) { Iterator>> iterator = summaryDimensionMap.entrySet().iterator(); @@ -918,13 +939,63 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { } else { saleorderRequestChildrenDto.setVdef7("0"); } + + //判断是否增加邮费这个存货,accumulatedPostage + BigDecimal accumulatedPostage = checkPostageFee(oldValue); + if (accumulatedPostage != null && accumulatedPostage.compareTo(BigDecimal.ZERO) > 0) { + //获取「平台运维」对应的税率 + String tax2 = "0." + new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString(); + BigDecimal noriginalcurprice2 = null;//无税单价 + BigDecimal noriginalcurmny2 = null;//无税金额 + BigDecimal noriginalcurtaxprice2 = null;//含税单价 + BigDecimal noriginalcursummny2 = null;//价税合计 + BigDecimal noriginalcurtaxmny2 = null;//税额 + try { + //邮费的汇总金额,但是数量永远为1 + noriginalcurtaxprice2 = accumulatedPostage.setScale(2, BigDecimal.ROUND_HALF_UP); + noriginalcurprice2 = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax2)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); + noriginalcurmny2 = noriginalcurprice.multiply(new BigDecimal("1")).setScale(2, BigDecimal.ROUND_HALF_UP); + noriginalcursummny2 = noriginalcurtaxprice.multiply(new BigDecimal("1")).setScale(2, BigDecimal.ROUND_HALF_UP); + noriginalcurtaxmny2 = noriginalcursummny.subtract(noriginalcurmny).setScale(2, BigDecimal.ROUND_HALF_UP); + } catch (Exception e) { + logger.error("邮费TOC金额计算错误", e); + Assert.state(false, "邮费TOC金额计算错误,原因:{}" + e.getMessage()); + } + + //存货管理档案 + BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(deliverGoodsCorp.getPkCorp()); + //增加「平台运费」这个存货 + SaleorderRequestChildrenDto saleorderRequestChildrenDto2 = new SaleorderRequestChildrenDto(); + saleorderRequestChildrenDto2.setBlargessflag(false);//是否赠品 + saleorderRequestChildrenDto2.setCadvisecalbodyid(bdCalbodyEntity.getPkCalbody());//发货库存组织 + saleorderRequestChildrenDto2.setCbodywarehouseid(bdStordocEntity.getPkStordoc());//发货仓库 + saleorderRequestChildrenDto2.setCbodywarehousecode(bdStordocEntity.getStorcode());//发货仓库编码:这个字段不需要给openapi接口,而是提供给下游方法使用 + saleorderRequestChildrenDto2.setCconsigncorpid(deliverGoodsCorp.getPkCorp());//发货公司 + saleorderRequestChildrenDto2.setCcurrencytypeid("00010000000000000001");//币种 + saleorderRequestChildrenDto2.setCinventoryid(bdInvmandocEntity1.getPkInvmandoc());//存货id + saleorderRequestChildrenDto2.setCinventorycode(bdInvbasdocEntity1.getInvcode());//存货编码 + saleorderRequestChildrenDto2.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//收货单位 + saleorderRequestChildrenDto2.setDconsigndate(generateBusinessDate);//计划发货日期 + saleorderRequestChildrenDto2.setDdeliverdate(generateBusinessDate);//要求收货日期 + saleorderRequestChildrenDto2.setNexchangeotobrate("1.00000000");//折本汇率 + saleorderRequestChildrenDto2.setNitemdiscountrate("100.000000");//单品折扣 + saleorderRequestChildrenDto2.setNnumber("1");//数量 + saleorderRequestChildrenDto2.setNoriginalcurdiscountmny("0");//折扣额 + saleorderRequestChildrenDto2.setNoriginalcurmny(noriginalcurmny2.stripTrailingZeros().toPlainString());//无税金额 + saleorderRequestChildrenDto2.setNoriginalcursummny(noriginalcursummny2.stripTrailingZeros().toPlainString());//价税合计 + saleorderRequestChildrenDto2.setNoriginalcurtaxmny(noriginalcurtaxmny2.stripTrailingZeros().toPlainString());//税额 + saleorderRequestChildrenDto2.setNoriginalcurtaxnetprice(noriginalcurtaxprice2.stripTrailingZeros().toPlainString());//含税净价 + saleorderRequestChildrenDto2.setNoriginalcurtaxprice(noriginalcurtaxprice2.stripTrailingZeros().toPlainString());//含税单价 + saleorderRequestChildrenDto2.setNtaxrate(new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString());//税率,对应运维存货的税率 + saleorderRequestChildrenDto2.setVdef4("0"); + saleorderRequestChildrenDto2.setVdef5("0"); + saleorderRequestChildrenDto2.setVdef6("0"); + saleorderRequestChildrenDto2.setVdef7("0"); + saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto2); + } saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); //销售订单单据推送到u8c - //测试 -// if (true) { -// continue; -// } List saleorderRequestDtoList = new ArrayList<>(); saleorderRequestDtoList.add(saleorderRequestDto); @@ -1048,6 +1119,8 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { findMatchingOfsOrder(headerDetailsDtos, headerDetailsDtoList); //计算OFS销售订单优惠金额分摊到明细行 ofsOrderSaleAmountAllocationUtil.batchTocSalesAmountAllocation(headerDetailsDtos); + //计算OFS销售订单邮费分摊 + ofsOrderSalePostageFeeAllocationUtil.batchTocSalesPostageFeeAllocation(headerDetailsDtos); for (int i = 0; i < headerDetailsDtoList.size(); i++) { HeaderDetailsDto headerDetailsDto = headerDetailsDtoList.get(i); @@ -1623,7 +1696,6 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { */ private void implementTran(List headerDetailsDtos) throws Exception { logger.info("TOC销售库存业务:{}行需要进行数据转换", headerDetailsDtos.size()); - if (headerDetailsDtos != null && headerDetailsDtos.size() > 0) { try { //查询基本档案 @@ -1641,6 +1713,12 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { // BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("202"); //初始化所有存货管理档案对应的结存价+采购价 List mapList = initAllBalancePricePurchasePrice(); + //查询「平台运费」存货基本档案 + BdInvbasdocEntity bdInvbasdocEntity1 = queryStockBasicArchives(); + //查询「平台运费」对应的税率 + BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode()); + //查询「平台运费」所有公司的存货管理档案 + Map stringBdInvmandocEntityMap = queryInventoryMan(bdInvbasdocEntity1.getPkInvbasdoc()); if (bdBusitypeEntity != null && summaryDimensionMap != null) { Iterator>> iterator = summaryDimensionMap.entrySet().iterator(); @@ -1801,6 +1879,60 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { } saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); + //判断是否增加邮费这个存货,accumulatedPostage + BigDecimal accumulatedPostage = checkPostageFee(oldValue); + if (accumulatedPostage != null && accumulatedPostage.compareTo(BigDecimal.ZERO) > 0) { + //获取「平台运维」对应的税率 + String tax2 = "0." + new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString(); + BigDecimal noriginalcurprice2 = null;//无税单价 + BigDecimal noriginalcurmny2 = null;//无税金额 + BigDecimal noriginalcurtaxprice2 = null;//含税单价 + BigDecimal noriginalcursummny2 = null;//价税合计 + BigDecimal noriginalcurtaxmny2 = null;//税额 + try { + //邮费的汇总金额,但是数量永远为1 + noriginalcurtaxprice2 = accumulatedPostage.setScale(2, BigDecimal.ROUND_HALF_UP); + noriginalcurprice2 = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax2)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); + noriginalcurmny2 = noriginalcurprice.multiply(new BigDecimal("1")).setScale(2, BigDecimal.ROUND_HALF_UP); + noriginalcursummny2 = noriginalcurtaxprice.multiply(new BigDecimal("1")).setScale(2, BigDecimal.ROUND_HALF_UP); + noriginalcurtaxmny2 = noriginalcursummny.subtract(noriginalcurmny).setScale(2, BigDecimal.ROUND_HALF_UP); + } catch (Exception e) { + logger.error("邮费TOC金额计算错误", e); + Assert.state(false, "邮费TOC金额计算错误,原因:{}" + e.getMessage()); + } + + //存货管理档案 + BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(deliverGoodsCorp.getPkCorp()); + //增加「平台运费」这个存货 + SaleorderRequestChildrenDto saleorderRequestChildrenDto2 = new SaleorderRequestChildrenDto(); + saleorderRequestChildrenDto2.setBlargessflag(false);//是否赠品 + saleorderRequestChildrenDto2.setCadvisecalbodyid(bdCalbodyEntity.getPkCalbody());//发货库存组织 + saleorderRequestChildrenDto2.setCbodywarehouseid(bdStordocEntity.getPkStordoc());//发货仓库 + saleorderRequestChildrenDto2.setCbodywarehousecode(bdStordocEntity.getStorcode());//发货仓库编码:这个字段不需要给openapi接口,而是提供给下游方法使用 + saleorderRequestChildrenDto2.setCconsigncorpid(deliverGoodsCorp.getPkCorp());//发货公司 + saleorderRequestChildrenDto2.setCcurrencytypeid("00010000000000000001");//币种 + saleorderRequestChildrenDto2.setCinventoryid(bdInvmandocEntity1.getPkInvmandoc());//存货id + saleorderRequestChildrenDto2.setCinventorycode(bdInvbasdocEntity1.getInvcode());//存货编码 + saleorderRequestChildrenDto2.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//收货单位 + saleorderRequestChildrenDto2.setDconsigndate(generateBusinessDate);//计划发货日期 + saleorderRequestChildrenDto2.setDdeliverdate(generateBusinessDate);//要求收货日期 + saleorderRequestChildrenDto2.setNexchangeotobrate("1.00000000");//折本汇率 + saleorderRequestChildrenDto2.setNitemdiscountrate("100.000000");//单品折扣 + saleorderRequestChildrenDto2.setNnumber("-1");//数量 + saleorderRequestChildrenDto2.setNoriginalcurdiscountmny("0");//折扣额 + saleorderRequestChildrenDto2.setNoriginalcurmny("-" + noriginalcurmny2.stripTrailingZeros().toPlainString());//无税金额 + saleorderRequestChildrenDto2.setNoriginalcursummny("-" + noriginalcursummny2.stripTrailingZeros().toPlainString());//价税合计 + saleorderRequestChildrenDto2.setNoriginalcurtaxmny("-" + noriginalcurtaxmny2.stripTrailingZeros().toPlainString());//税额 + saleorderRequestChildrenDto2.setNoriginalcurtaxnetprice(noriginalcurtaxprice2.stripTrailingZeros().toPlainString());//含税净价 + saleorderRequestChildrenDto2.setNoriginalcurtaxprice(noriginalcurtaxprice2.stripTrailingZeros().toPlainString());//含税单价 + saleorderRequestChildrenDto2.setNtaxrate(new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString());//税率,对应运维存货的税率 + saleorderRequestChildrenDto2.setVdef4("0"); + saleorderRequestChildrenDto2.setVdef5("0"); + saleorderRequestChildrenDto2.setVdef6("0"); + saleorderRequestChildrenDto2.setVdef7("0"); + saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto2); + } + //销售订单单据推送到u8c List saleorderRequestDtoList = new ArrayList<>(); saleorderRequestDtoList.add(saleorderRequestDto); @@ -1948,6 +2080,61 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { saleorderRequestChildrenDto.setVdef7("0"); } saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); + + //判断是否增加邮费这个存货,accumulatedPostage + BigDecimal accumulatedPostage = checkPostageFee(oldValue); + if (accumulatedPostage != null && accumulatedPostage.compareTo(BigDecimal.ZERO) > 0) { + //获取「平台运维」对应的税率 + String tax2 = "0." + new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString(); + BigDecimal noriginalcurprice2 = null;//无税单价 + BigDecimal noriginalcurmny2 = null;//无税金额 + BigDecimal noriginalcurtaxprice2 = null;//含税单价 + BigDecimal noriginalcursummny2 = null;//价税合计 + BigDecimal noriginalcurtaxmny2 = null;//税额 + try { + //邮费的汇总金额,但是数量永远为1 + noriginalcurtaxprice2 = accumulatedPostage.setScale(2, BigDecimal.ROUND_HALF_UP); + noriginalcurprice2 = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax2)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP); + noriginalcurmny2 = noriginalcurprice.multiply(new BigDecimal("1")).setScale(2, BigDecimal.ROUND_HALF_UP); + noriginalcursummny2 = noriginalcurtaxprice.multiply(new BigDecimal("1")).setScale(2, BigDecimal.ROUND_HALF_UP); + noriginalcurtaxmny2 = noriginalcursummny.subtract(noriginalcurmny).setScale(2, BigDecimal.ROUND_HALF_UP); + } catch (Exception e) { + logger.error("邮费TOC金额计算错误", e); + Assert.state(false, "邮费TOC金额计算错误,原因:{}" + e.getMessage()); + } + + //存货管理档案 + BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(deliverGoodsCorp.getPkCorp()); + //增加「平台运费」这个存货 + SaleorderRequestChildrenDto saleorderRequestChildrenDto2 = new SaleorderRequestChildrenDto(); + saleorderRequestChildrenDto2.setBlargessflag(false);//是否赠品 + saleorderRequestChildrenDto2.setCadvisecalbodyid(bdCalbodyEntity.getPkCalbody());//发货库存组织 + saleorderRequestChildrenDto2.setCbodywarehouseid(bdStordocEntity.getPkStordoc());//发货仓库 + saleorderRequestChildrenDto2.setCbodywarehousecode(bdStordocEntity.getStorcode());//发货仓库编码:这个字段不需要给openapi接口,而是提供给下游方法使用 + saleorderRequestChildrenDto2.setCconsigncorpid(deliverGoodsCorp.getPkCorp());//发货公司 + saleorderRequestChildrenDto2.setCcurrencytypeid("00010000000000000001");//币种 + saleorderRequestChildrenDto2.setCinventoryid(bdInvmandocEntity1.getPkInvmandoc());//存货id + saleorderRequestChildrenDto2.setCinventorycode(bdInvbasdocEntity1.getInvcode());//存货编码 + saleorderRequestChildrenDto2.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//收货单位 + saleorderRequestChildrenDto2.setDconsigndate(generateBusinessDate);//计划发货日期 + saleorderRequestChildrenDto2.setDdeliverdate(generateBusinessDate);//要求收货日期 + saleorderRequestChildrenDto2.setNexchangeotobrate("1.00000000");//折本汇率 + saleorderRequestChildrenDto2.setNitemdiscountrate("100.000000");//单品折扣 + saleorderRequestChildrenDto2.setNnumber("1");//数量 + saleorderRequestChildrenDto2.setNoriginalcurdiscountmny("0");//折扣额 + saleorderRequestChildrenDto2.setNoriginalcurmny(noriginalcurmny2.stripTrailingZeros().toPlainString());//无税金额 + saleorderRequestChildrenDto2.setNoriginalcursummny(noriginalcursummny2.stripTrailingZeros().toPlainString());//价税合计 + saleorderRequestChildrenDto2.setNoriginalcurtaxmny(noriginalcurtaxmny2.stripTrailingZeros().toPlainString());//税额 + saleorderRequestChildrenDto2.setNoriginalcurtaxnetprice(noriginalcurtaxprice2.stripTrailingZeros().toPlainString());//含税净价 + saleorderRequestChildrenDto2.setNoriginalcurtaxprice(noriginalcurtaxprice2.stripTrailingZeros().toPlainString());//含税单价 + saleorderRequestChildrenDto2.setNtaxrate(new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString());//税率,对应运维存货的税率 + saleorderRequestChildrenDto2.setVdef4("0"); + saleorderRequestChildrenDto2.setVdef5("0"); + saleorderRequestChildrenDto2.setVdef6("0"); + saleorderRequestChildrenDto2.setVdef7("0"); + saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto2); + } + saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); //销售订单单据推送到u8c List saleorderRequestDtoList = new ArrayList<>(); @@ -2692,4 +2879,188 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { mapList.add(stringPoOrderBEntityMap); return mapList; } + + /** + * 累加偏远地区的邮费,如果累加后的邮费大于0,则会追加一个存货用于记录平台邮费 + * + * @author liuyang + */ + private BigDecimal checkPostageFee(List oldValue) throws Exception { + BigDecimal shareTargetFreightTotalDiscounts = new BigDecimal("0"); + if (oldValue != null && oldValue.size() > 0) { + for (int i = 0; i < oldValue.size(); i++) { + SonDetailsDto sonDetailsDto = oldValue.get(i); + //查找O出库单某行明细对应的OFS销售订单明细行 + com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto ofsOrderDetail = findOfsOrderDetail(sonDetailsDto); + if (ofsOrderDetail != null) { + BigDecimal shareTargetFreightDiscounts = ofsOrderDetail.getShareTargetFreightDiscounts(); + shareTargetFreightTotalDiscounts = shareTargetFreightTotalDiscounts.add(shareTargetFreightDiscounts); + } + } + } + return shareTargetFreightTotalDiscounts; + } + + /** + * 查找销售订单明细行 + * + * @author liuyang + */ + private com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto findOfsOrderDetail(SonDetailsDto sonDetailsDto) { + com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = sonDetailsDto.getHeaderDetailsDto(); + if (headerDetailsDto != null) { + com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header = headerDetailsDto.getHeader(); + List details = headerDetailsDto.getDetails(); + for (int j = 0; j < details.size(); j++) { + com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto detailsDto = details.get(j);//O销售出库单对应的O销售订单明细行 + //detailsDto.getId()为销售订单明细行主键 + if (detailsDto.getId() != null) { + if (detailsDto.getId().equals(sonDetailsDto.getRefOrderDetailId())) { + return detailsDto; + } + } + } + } + return null; + } + + /** + * 收集OFS全部的销售订单 + * + * @author liuyang + */ +// private Map collectOfsOrder(List oldValue) { +// Map stringHeaderDetailsDtoMap = new HashMap<>(); +// List headerDetailsDtoList = new ArrayList<>(); +// if (oldValue != null && oldValue.size() > 0) { +// for (int i = 0; i < oldValue.size(); i++) { +// SonDetailsDto sonDetailsDto = oldValue.get(i); +// headerDetailsDtoList.add(sonDetailsDto.getHeaderDetailsDto()); +// } +// } +// if (headerDetailsDtoList.size() > 0) { +// //转换为Map +// +// } +// return stringHeaderDetailsDtoMap; +// } + + /** + * 增加邮费存货 + */ +// private void addPostageFeeStock() throws Exception { +// SaleorderRequestChildrenDto saleorderRequestChildrenDto = new SaleorderRequestChildrenDto(); +// saleorderRequestChildrenDto.setBlargessflag(false);//是否赠品 +// saleorderRequestChildrenDto.setCadvisecalbodyid(bdCalbodyEntity.getPkCalbody());//发货库存组织 +// saleorderRequestChildrenDto.setCbodywarehouseid(bdStordocEntity.getPkStordoc());//发货仓库 +// saleorderRequestChildrenDto.setCbodywarehousecode(bdStordocEntity.getStorcode());//发货仓库编码:这个字段不需要给openapi接口,而是提供给下游方法使用 +// saleorderRequestChildrenDto.setCconsigncorpid(deliverGoodsCorp.getPkCorp());//发货公司 +// saleorderRequestChildrenDto.setCcurrencytypeid("00010000000000000001");//币种 +// saleorderRequestChildrenDto.setCinventoryid(bdInvmandocEntity.getPkInvmandoc());//存货id +// saleorderRequestChildrenDto.setCinventorycode(bdInvbasdocEntity.getInvcode());//存货编码 +// saleorderRequestChildrenDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//收货单位 +// saleorderRequestChildrenDto.setDconsigndate(generateBusinessDate);//计划发货日期 +// saleorderRequestChildrenDto.setDdeliverdate(generateBusinessDate);//要求收货日期 +// saleorderRequestChildrenDto.setNexchangeotobrate("1.00000000");//折本汇率 +// saleorderRequestChildrenDto.setNitemdiscountrate("100.000000");//单品折扣 +// saleorderRequestChildrenDto.setNnumber(String.valueOf(sonDetailsDto.getGroupShipQty()));//数量 +// saleorderRequestChildrenDto.setNoriginalcurdiscountmny("0");//折扣额 +// saleorderRequestChildrenDto.setNoriginalcurmny(noriginalcurmny.stripTrailingZeros().toPlainString());//无税金额 +// saleorderRequestChildrenDto.setNoriginalcursummny(noriginalcursummny.stripTrailingZeros().toPlainString());//价税合计 +// saleorderRequestChildrenDto.setNoriginalcurtaxmny(noriginalcurtaxmny.stripTrailingZeros().toPlainString());//税额 +// saleorderRequestChildrenDto.setNoriginalcurtaxnetprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税净价 +// saleorderRequestChildrenDto.setNoriginalcurtaxprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税单价 +// saleorderRequestChildrenDto.setNtaxrate(new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString());//税率 +// +// //物流发货服务费 +// saleorderRequestChildrenDto.setVdef4("0"); +// saleorderRequestChildrenDto.setVdef5("0"); +// saleorderRequestChildrenDto.setVdef6("0"); +// saleorderRequestChildrenDto.setVdef7("0"); +// } + + /** + * 查询「平台运费」这个存货对应的基本档案和管理档案 + * + * @author liuyang + */ +// private Map queryPlatformShippFeeStock(String pkCorp, String corpName) throws Exception { +// String freightPkInvmandoc = "FY05"; +// Map stringObjectMap = new HashMap<>(); +// //存货基本档案 +// BdInvbasdocEntity bdInvbasdocEntity = queryStockBasicArchives(freightPkInvmandoc); +// //存货管理档案 +// BdInvmandocEntity bdInvmandocEntity = queryInventoryMan(freightPkInvmandoc, pkCorp, corpName); +// +// stringObjectMap.put("bdInvbasdocEntity", bdInvbasdocEntity); +// stringObjectMap.put("bdInvmandocEntity", bdInvmandocEntity); +// return stringObjectMap; +// } + + /** + * 查询存货管理档案,key为公司id、value为存货管理档案对象 + * + * @param pk_invbasdoc 存货管理档案 + * @author liuyang + */ + private Map queryInventoryMan(String pk_invbasdoc) throws Exception { + Assert.notNull(pk_invbasdoc, "pk_invbasdoc不能为空!"); + Assert.state(!"".equals(pk_invbasdoc.trim()), "pk_invbasdoc不能为空!"); + + Map stringBdInvmandocEntityMap = new HashMap<>(); + BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity(); + bdInvmandocEntity.setPkInvbasdoc(pk_invbasdoc); + bdInvmandocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); + List bdInvmandocEntity2 = iBdInvmandocDao.queryBdInvmandocByInvcodeList(bdInvmandocEntity); + if (bdInvmandocEntity2 == null || bdInvmandocEntity2.size() == 0) { + Assert.state(false, "无法查询到所有公司对应的存货管理档案 存货管理档案主键:{}", pk_invbasdoc); + } + if (bdInvmandocEntity2 != null && bdInvmandocEntity2.size() > 0) { + for (int i = 0; i < bdInvmandocEntity2.size(); i++) { + BdInvmandocEntity bdInvmandocEntity1 = bdInvmandocEntity2.get(i); + stringBdInvmandocEntityMap.put(bdInvmandocEntity1.getPkCorp(), bdInvmandocEntity1); + } + } + return stringBdInvmandocEntityMap; + } + + /** + * 2024年8月7日 10:25:29 + * 查询存货基础档案档案 + * + * @author liuyang + */ + private BdInvbasdocEntity queryStockBasicArchives() throws Exception { + String invcode = "FY05"; + BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity(); + bdInvbasdocEntity.setInvcode(invcode); + bdInvbasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); + List bdInvbasdocEntity2 = iBdInvbasdocDao.query(bdInvbasdocEntity); + if (bdInvbasdocEntity2.size() == 0) { + Assert.state(false, "根据存货编码:{},无法匹配到U8C存货基本档案", invcode); + } else if (bdInvbasdocEntity2.size() >= 2) { + Assert.state(false, "根据存货编码:{},无法匹配到U8C存货基本档案", invcode); + } + return bdInvbasdocEntity2.get(0); + } + + /** + * 2024年8月7日 14:58:34 + * 查询税目档案 + * + * @author liuyang + */ + private BdTaxitemsEntity queryBdTaxitems(String invcode) throws Exception { + Assert.notNull(invcode, "存货编码不能为空"); + + BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity(); + bdTaxitemsEntity.setInvcode(invcode); + List bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity); + if (bdTaxitemsEntityList.size() == 0) { + Assert.state(false, "根据存货编码{}没有查询到U8C税目档案", invcode); + } else if (bdTaxitemsEntityList.size() >= 2) { + Assert.state(false, "根据存货编码{}查询到{}个U8C税目档案", invcode, bdTaxitemsEntityList.size()); + } + return bdTaxitemsEntityList.get(0); + } } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsOrderSalePostageFeeAllocationUtil.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsOrderSalePostageFeeAllocationUtil.java new file mode 100644 index 00000000..b8ca37cf --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/OfsOrderSalePostageFeeAllocationUtil.java @@ -0,0 +1,286 @@ +package com.hzya.frame.plugin.lets.util; + +import cn.hutool.core.lang.Assert; +import com.hzya.frame.beanutil.BeanUtil; +import com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto; +import com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto; +import com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +/** + * 处理OFS销售订单,邮费金额分摊的逻辑 + * + * @Author:liuyang + * @Package:com.hzya.frame.plugin.lets.util + * @Project:kangarooDataCenterV3 + * @name:AmountAllocationUtil + * @Date:2024/9/21 18:19 + * @Filename:AmountAllocationUtil + */ +@Component +public class OfsOrderSalePostageFeeAllocationUtil { + + Logger logger = LoggerFactory.getLogger(OfsOrderSalePostageFeeAllocationUtil.class); + + /** + * TOC销售订单邮费分摊逻辑 + * + * @author liuyang + */ + public void batchTocSalesPostageFeeAllocation(List headerDetailsDtoList) { + Assert.notNull(headerDetailsDtoList, "headerDetailsDtoList不能为空!"); + + logger.info("==TOC销售邮费金额分摊开始=="); + headerDetailsDtoList.forEach(headerDetailsDto -> { + try { + tocSalesPostageFeeAllocation(headerDetailsDto); + } catch (Exception e) { + logger.error("tocSalesPostageFeeAllocation方法抛出异常,批量处理TOC销售邮费分摊异常", e); + } + }); + logger.info("==TOC销售邮费金额分摊结束=="); +// logger.info("=记录优惠金额分摊结果开始="); +// printAmountOfMoneyNum(headerDetailsDtoList); +// logger.info("=记录优惠金额分摊结果完成="); + } + + /** + * TOC邮费金额分摊 + * + * @param headerDetailsDto OFS销售订单对象 + * @author liuyang + */ + public void tocSalesPostageFeeAllocation(HeaderDetailsDto headerDetailsDto) throws Exception { + Assert.notNull(headerDetailsDto, "OFS销售订单对象不能为空"); + + HeaderDto header = headerDetailsDto.getHeader(); + List detailsOld = headerDetailsDto.getDetails(); + + //拷贝一份List集合,并移除没有「实付金额」的OFS销售订单明细行,不参与分摊 + //运费:postageAmount + List details = copyDetailsDto(detailsOld); + details.removeIf(dto -> dto.getTotalPayAmount() == null || "0".equals(new BigDecimal(dto.getTotalPayAmount()).stripTrailingZeros().toPlainString())); + + //计算分摊百分比 + calculatePercentage(headerDetailsDto, details, header.getCode()); + + //销售订单运费 + String postageAmount = header.getPostageAmount(); + + //运费可能没有,也有可能为0! + BigDecimal postageAmountDiscounts = null; + if (postageAmount != null && !"".equals(postageAmount) && !"0".equals(new BigDecimal(postageAmount).stripTrailingZeros().toPlainString())) { + postageAmountDiscounts = new BigDecimal(postageAmount); + } + + BigDecimal totalShareTargetPlatformDiscounts = new BigDecimal("0"); + //分摊金额=分摊比例*优惠金额 + for (int i = 0; i < details.size(); i++) { + DetailsDto detailsDto = details.get(i); + //分摊比例 + BigDecimal postageFeeSharingRatio = detailsDto.getPostageFeeSharingRatio(); + + //这里应该先8为小数,实际汇总到出库单时,再四舍五入两位小数 + BigDecimal shareTargetPlatformDiscounts = null; + if (postageFeeSharingRatio != null && postageAmountDiscounts != null) { + shareTargetPlatformDiscounts = postageAmountDiscounts.multiply(postageFeeSharingRatio).setScale(2, BigDecimal.ROUND_HALF_UP); + detailsDto.setOriginalFreightDiscounts(postageAmountDiscounts); + detailsDto.setShareTargetFreightDiscounts(shareTargetPlatformDiscounts); + + totalShareTargetPlatformDiscounts = totalShareTargetPlatformDiscounts.add(shareTargetPlatformDiscounts); + } + + //如果是最后一行,则把尾差进行追加 + if (i == details.size() - 1) { + if (!"0".equals(totalShareTargetPlatformDiscounts.stripTrailingZeros().toPlainString()) && detailsDto.getShareTargetFreightDiscounts() != null) { + //原始运费金额-sum(分摊金额) + BigDecimal subtract = postageAmountDiscounts.subtract(totalShareTargetPlatformDiscounts); + if (subtract.compareTo(BigDecimal.ZERO) > 0) { + BigDecimal shareTargetFreightDiscounts = detailsDto.getShareTargetFreightDiscounts(); + detailsDto.setShareTargetFreightDiscounts(shareTargetFreightDiscounts.add(subtract)); + } + } + } + + //拷贝回到原始的集合 + copyDetailsDtoOld(details, detailsOld); + } + } + + /** + * 计算百分比 + * 分摊比例=实付金额/sum(实付金额) + * + * @param headerDetailsDto2 OFS销售订单 + * @param details 克隆后的销售订单明细行 + * @param ofsCode OFS销售订单编码 + * @author liuyang + */ + private void calculatePercentage(HeaderDetailsDto headerDetailsDto2, List details, String ofsCode) throws Exception { + Assert.notNull(headerDetailsDto2, "headerDetailsDto2不能为空"); + Assert.notNull(details, "details不能为空"); + Assert.notNull(ofsCode, "ofsCode不能为空"); + + HeaderDto header1 = headerDetailsDto2.getHeader(); + List details1 = headerDetailsDto2.getDetails(); + + BigDecimal sumTotalPayAmountBigDecimal = sumTotalPayAmountAmount(details1, header1.getCode()); + for (int i = 0; i < details1.size(); i++) { + DetailsDto detailsDto = details1.get(i); + + String totalPayAmount = detailsDto.getTotalPayAmount(); + //如果实付金额为0则不进行分摊! + if (totalPayAmount != null && !"0".equals(new BigDecimal(totalPayAmount).stripTrailingZeros().toPlainString())) { + BigDecimal totalPayAmountBigDecimal = new BigDecimal(totalPayAmount); + //得到分摊比例 + BigDecimal percentageBigDecimal = totalPayAmountBigDecimal.divide(sumTotalPayAmountBigDecimal, 20, BigDecimal.ROUND_HALF_UP).setScale(8, BigDecimal.ROUND_HALF_UP); + if (details != null && details.size() > 0) { + for (int j = 0; j < details.size(); j++) { + DetailsDto detailsDto1 = details.get(j); + if (detailsDto1.getId() != null && detailsDto.getId() != null) { + if (detailsDto1.getId().equals(detailsDto.getId())) { + details.get(j).setPostageFeeSharingRatio(percentageBigDecimal); + } + } + } + } + } + //logger.info打太多太慢了 +// else { +// logger.info(totalPayAmount, "totalPayAmount(商品金额)为空!OFS销售订单号:{} 存货编码:{}", ofsCode, detailsDto.getSkuCode()); +// } + } + } + + /** + * 累计这一单对应的实付金额 + * + * @param details1 OFS销售订单明细行 + * @param code OFS销售订单号 + * @author liuyang + */ + private BigDecimal sumTotalPayAmountAmount(List details1, String code) throws Exception { + Assert.notNull(details1, "details1不能为空"); + Assert.notNull(code, "code不能为空"); + + BigDecimal totalPayAmountTotalBigDecimal = new BigDecimal("0"); + for (int i = 0; i < details1.size(); i++) { + DetailsDto detailsDto = details1.get(i); + //实付金额 + String totalPayAmount = detailsDto.getTotalPayAmount(); + if (totalPayAmount != null && !"0".equals(new BigDecimal(totalPayAmount).stripTrailingZeros().toPlainString())) { + BigDecimal totalPayAmountBigDecimal = new BigDecimal(totalPayAmount); + totalPayAmountTotalBigDecimal = totalPayAmountTotalBigDecimal.add(totalPayAmountBigDecimal); + } + } + if ("0".equals(totalPayAmountTotalBigDecimal.stripTrailingZeros().toPlainString())) { + logger.info("OFS销售订单号:{} 整单明细行全部的「实付金额」都为0,邮费都不参与分摊!", code); + } + return totalPayAmountTotalBigDecimal; + } + + /** + * 集合复制 + * + * @param details 旧OFS销售订单明细行 + * @author liuyang + */ + private List copyDetailsDto(List details) throws Exception { + List newDetails = new ArrayList<>(); + for (int i = 0; i < details.size(); i++) { + DetailsDto detailsDto = details.get(i); + + DetailsDto newDetailsDto1 = new DetailsDto(); + BeanUtil.copyPropertiesV2(detailsDto, newDetailsDto1); + newDetails.add(newDetailsDto1); + } + return newDetails; + } + + /** + * 拷贝到原集合中 + * + * @param newDetails 新OFS销售订单明细行 + * @param detailsOld 旧OFS销售订单明细行 + * @author liuyang + */ + private void copyDetailsDtoOld(List newDetails, List detailsOld) throws Exception { + if (newDetails != null && detailsOld != null) { + for (int i = 0; i < detailsOld.size(); i++) { + DetailsDto detailsDto = detailsOld.get(i); + for (int j = 0; j < newDetails.size(); j++) { + DetailsDto detailsDto1 = newDetails.get(j); + if (detailsDto.getId().equals(detailsDto1.getId())) { + //把分摊后的金额拷贝到旧的OFS销售订单集合中 + BeanUtil.copyPropertiesV2(detailsDto1, detailsDto); + } + } + } + } else { + logger.error("copyDetailsDtoOld方法newDetails或者detailsOld为空!"); + } + } + + /** + * 打印金额参数 + * + * @param headerDetailsDtoList OFS销售订单号 + */ +// public void printAmountOfMoneyNum(List headerDetailsDtoList) { +// try { +// if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) { +// for (int i = 0; i < headerDetailsDtoList.size(); i++) { +// HeaderDetailsDto headerDetailsDto = headerDetailsDtoList.get(i); +// HeaderDto header = headerDetailsDto.getHeader(); +// List details = headerDetailsDto.getDetails(); +// +// logger.info("OFS销售订单号:{} 平台优惠:{} 商家优惠:{} 达人优惠:{} 支付优惠:{}", header.getCode(), header.getPlatformDiscounts(), header.getMerchantDiscounts(), header.getExpertDiscounts(), header.getPayDiscounts()); +// if (details != null && details.size() > 0) { +// for (int j = 0; j < details.size(); j++) { +// DetailsDto detailsDto = details.get(j); +// +// logger.info("start================================"); +// logger.info("OFS销售订单明细主键:{}", detailsDto.getId()); +// if (detailsDto.getSharingRatio() != null) { +// logger.info("分摊比例:{}", detailsDto.getSharingRatio().stripTrailingZeros().toPlainString()); +// } else { +// logger.info("分摊比例:无"); +// } +// logger.info("商品金额:{}", detailsDto.getItemTotalAmount()); +// if (detailsDto.getShareTargetPlatformDiscounts() != null) { +// logger.info("分摊平台优惠:{}", detailsDto.getShareTargetPlatformDiscounts().stripTrailingZeros().toPlainString()); +// } else { +// logger.info("分摊平台优惠:无"); +// } +// if (detailsDto.getShareTargetMerchantDiscounts() != null) { +// logger.info("分摊商家优惠:{}", detailsDto.getShareTargetMerchantDiscounts().stripTrailingZeros().toPlainString()); +// } else { +// logger.info("分摊商家优惠:无"); +// } +// if (detailsDto.getShareTargetExpertDiscounts() != null) { +// logger.info("分摊达人优惠:{}", detailsDto.getShareTargetExpertDiscounts().stripTrailingZeros().toPlainString()); +// } else { +// logger.info("分摊达人优惠:无"); +// } +// if (detailsDto.getShareTargetPayDiscounts() != null) { +// logger.info("分摊支付优惠:{}", detailsDto.getShareTargetPayDiscounts().stripTrailingZeros().toPlainString()); +// } else { +// logger.info("分摊支付优惠:无"); +// } +// logger.info("end================================"); +// } +// } +// } +// } +// } catch (Exception e) { +//// e.printStackTrace(); +// logger.error("printAmountOfMoneyNum方法抛出异常", e); +// } +// } +} \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/TocOrderBasicArchivesCacheUtil.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/TocOrderBasicArchivesCacheUtil.java index 119a3670..fab96d40 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/TocOrderBasicArchivesCacheUtil.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/TocOrderBasicArchivesCacheUtil.java @@ -587,7 +587,9 @@ public class TocOrderBasicArchivesCacheUtil { if (bdDefdocEntityList != null && bdDefdocEntityList.size() > 0) { for (int i = 0; i < bdDefdocEntityList.size(); i++) { BdDefdocEntity bdDefdocEntity1 = bdDefdocEntityList.get(i); - shopDefdocEntityHashMap.put(bdDefdocEntity1.getDoccode(), bdDefdocEntity1); + if (bdDefdocEntity1 != null) { + shopDefdocEntityHashMap.put(bdDefdocEntity1.getDoccode().trim(), bdDefdocEntity1); + } } } return shopDefdocEntityHashMap; diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningInTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningInTest.java index 1b598899..6df6ef5e 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningInTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/outsourc/ConsignmachiningInTest.java @@ -27,9 +27,9 @@ public class ConsignmachiningInTest { @Test public void startImplement() { // String code = "LETS-RE2024082300000007"; -// String code = "LETS-RE2024090300000001"; -// consignmachiningIn.startImplement(code); + String code = "LETS-RE2024102200000018"; + consignmachiningIn.startImplement(code); - consignmachiningIn.startImplement("2024-09-24 13:49:15", "2024-09-24 13:49:17"); +// consignmachiningIn.startImplement("2024-09-24 13:49:15", "2024-09-24 13:49:17"); } } \ No newline at end of file diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToBTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToBTest.java index 17403035..8e99ae0f 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToBTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToBTest.java @@ -80,9 +80,10 @@ public class SoSaleOutPluginInitializerToBTest { try { // soSaleOutPluginInitializerToB.startImplementByCode("LETS-SH2024101800025544", "stock"); - soSaleOutPluginInitializerToB.startImplementByStockTime("2024-10-18 00:00:00", "2024-10-18 23:59:59"); -// String aaa = "LETS-SH2024101800024795"; -// soSaleOutPluginInitializerToB.startImplementByCode(aaa, "stock"); +// soSaleOutPluginInitializerToB.startImplementByStockTime("2024-10-18 00:00:00", "2024-10-18 23:59:59"); + + String aaa = "LETS-RE2024102200000018"; + soSaleOutPluginInitializerToB.startImplementByCode(aaa, "stock"); } catch (Exception e) { e.printStackTrace(); } 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 334a1762..f0eec125 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 @@ -97,7 +97,7 @@ class SoSaleOutPluginInitializerToCTest { try { // soSaleOutPluginInitializerToC.startImplementStockByTime("2024-10-18 00:00:00", "2024-10-18 23:59:59"); - String code = "LETS-SH2024101700027117"; + String code = "LETS-SH2024102100026682"; soSaleOutPluginInitializerToC.startImplementStockByCode(code, "stock"); } catch (Exception e) { e.printStackTrace(); diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/OfsOrderSaleAmountAllocationUtilTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/OfsOrderSaleAmountAllocationUtilTest.java index b696e467..7aaa5909 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/OfsOrderSaleAmountAllocationUtilTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/OfsOrderSaleAmountAllocationUtilTest.java @@ -40,7 +40,7 @@ public class OfsOrderSaleAmountAllocationUtilTest { @Test public void tocSalesAmountAllocation() { try { - SaleOrderMessageDto ofsOrder = afterSalesOrderUtil.getOfsOrder("LETS-SO2024092500000020"); + SaleOrderMessageDto ofsOrder = afterSalesOrderUtil.getOfsOrder("LETS-SO2022110600035448"); List data = ofsOrder.getData(); if (data.size() > 0) { //测试一:所有优惠金额都为0 diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/OfsOrderSalePostageFeeAllocationUtilTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/OfsOrderSalePostageFeeAllocationUtilTest.java new file mode 100644 index 00000000..319b3d20 --- /dev/null +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/util/OfsOrderSalePostageFeeAllocationUtilTest.java @@ -0,0 +1,64 @@ +package com.hzya.frame.plugin.lets.util; + +import com.hzya.frame.WebappApplication; +import com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto; +import com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto; +import com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto; +import com.hzya.frame.ttxofs.dto.ofssalesordersearch.SaleOrderMessageDto; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.*; + +/** + * @Author:liuyang + * @Package:com.hzya.frame.plugin.lets.util + * @Project:kangarooDataCenterV3 + * @name:OfsOrderSalePostageFeeAllocationUtilTest + * @Date:2024/10/23 14:51 + * @Filename:OfsOrderSalePostageFeeAllocationUtilTest + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = WebappApplication.class) +public class OfsOrderSalePostageFeeAllocationUtilTest { + + @Autowired + private OfsOrderSalePostageFeeAllocationUtil ofsOrderSalePostageFeeAllocationUtil; + + @Autowired + private AfterSalesOrderUtil afterSalesOrderUtil; + + @Test + public void batchTocSalesPostageFeeAllocation() { + try { + SaleOrderMessageDto ofsOrder = afterSalesOrderUtil.getOfsOrder("LETS-SO2024100100026431"); + List data = ofsOrder.getData(); + +// List headerDetailsDtoList = new ArrayList<>(); +// headerDetailsDtoList.add(HeaderDetailsDto.builder().build()); + ofsOrderSalePostageFeeAllocationUtil.batchTocSalesPostageFeeAllocation(data); + + HeaderDetailsDto headerDetailsDto = data.get(0); + HeaderDto header = headerDetailsDto.getHeader(); + List details = headerDetailsDto.getDetails(); + for (int i = 0; i < details.size(); i++) { + DetailsDto detailsDto = details.get(i); + System.out.println("邮费分摊比例:" + detailsDto.getPostageFeeSharingRatio()); + System.out.println("原始运费分摊金额:" + detailsDto.getOriginalFreightDiscounts()); + System.out.println("实际运费分摊金额:" + detailsDto.getShareTargetFreightDiscounts()); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Test + public void tocSalesPostageFeeAllocation() { + } +} \ No newline at end of file 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 48787ebf..dbbdad78 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 @@ -57,7 +57,8 @@ public class DetailsDto { private String shipAt; private String totalAmount; - //分摊比例 + //优惠分摊start------------––----- + //优惠金额-分摊比例 private BigDecimal sharingRatio; //原始平台优惠 @@ -77,4 +78,17 @@ public class DetailsDto { private BigDecimal shareTargetExpertDiscounts; //分摊支付优惠 private BigDecimal shareTargetPayDiscounts; + //优惠分摊end------------––----- + + + //邮费分摊start------------––----- + //邮费分摊比例 + private BigDecimal postageFeeSharingRatio; + + //原始运费分摊金额 + private BigDecimal originalFreightDiscounts; + + //实际运费分摊金额 + private BigDecimal shareTargetFreightDiscounts; + //邮费分摊end------------––------- } \ No newline at end of file