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 c9db9a6b..c0b9d782 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 @@ -208,6 +208,9 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { @Autowired private OfsStandardUtil ofsStandardUtil; + @Autowired + private QueryAdditionUtil queryAdditionUtil; + @Autowired private RdclUtil rdclUtil; @@ -859,15 +862,15 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //初始化所有存货管理档案对应的结存价+采购价 // List mapList = initAllBalancePricePurchasePrice(); //查询「平台运费」、「平台优惠」、「支付优惠」、「达人优惠」存货基本档案(注意没有商家优惠) - List bdInvbasdocEntities = queryStockBasicArchives(); + List bdInvbasdocEntities = queryAdditionUtil.queryStockBasicArchives(); Map mapBdInvbasdocEntity = bdInvbasdocEntities.stream().collect(Collectors.toMap(BdInvbasdocEntity::getInvcode, entity -> entity)); String pkInvbasdocStr = bdInvbasdocEntities.stream().map(entity -> "'" + entity.getInvcode() + "'").collect(Collectors.joining(",")); //查询存货对应的税目 - Map stringBdTaxitemsEntityMap = queryBatchBdTaxitems(pkInvbasdocStr); + Map stringBdTaxitemsEntityMap = queryAdditionUtil.queryBatchBdTaxitems(pkInvbasdocStr); //查询「平台运费」对应的税率 // BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode()); //查询「平台运费」、「平台优惠」、「支付优惠」、「达人优惠」所有公司的存货管理档案 - Map stringBdInvmandocEntityMap = queryInventoryMan(bdInvbasdocEntities); + Map stringBdInvmandocEntityMap = queryAdditionUtil.queryInventoryMan(bdInvbasdocEntities); if (bdBusitypeEntity != null && summaryDimensionMap != null) { Iterator>> iterator = summaryDimensionMap.entrySet().iterator(); @@ -1100,7 +1103,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //存货对应的税率 BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY05"); //补充:平台运费-存货 - additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, accumulatedPostage, "1", bdTaxitemsEntity); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, accumulatedPostage, "1", bdTaxitemsEntity); } //平台优惠 if (sonDetailsDto.getVdef4() != null && !"".equals(sonDetailsDto.getVdef4())) { @@ -1113,7 +1116,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //存货对应的税率 BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY01"); //补充:平台优惠-存货 - additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, bigDecimalVdef4, "1", bdTaxitemsEntity); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, bigDecimalVdef4, "1", bdTaxitemsEntity); } } //达人优惠 @@ -1127,7 +1130,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //存货对应的税率 BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY02"); //补充:达人优惠-存货 - additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, bigDecimalVdef6, "1", bdTaxitemsEntity); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, bigDecimalVdef6, "1", bdTaxitemsEntity); } } //支付优惠 @@ -1141,7 +1144,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //存货对应的税率 BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY04"); //补充:支付优惠-存货 - additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, bigDecimalVdef5, "1", bdTaxitemsEntity); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, bigDecimalVdef5, "1", bdTaxitemsEntity); } } @@ -1272,7 +1275,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //查询对应的OFS销售订单 List headerDetailsDtos = queryOfsOrder(headerDetailsDtoList); findMatchingOfsOrder(headerDetailsDtos, headerDetailsDtoList); - + //测试 // for (int i = 0; i < headerDetailsDtos.size(); i++) { // com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = headerDetailsDtos.get(i); @@ -2032,15 +2035,15 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //初始化所有存货管理档案对应的结存价+采购价 // List mapList = initAllBalancePricePurchasePrice(); //查询「平台运费」存货基本档案 - List bdInvbasdocEntities = queryStockBasicArchives(); + List bdInvbasdocEntities = queryAdditionUtil.queryStockBasicArchives(); Map mapBdInvbasdocEntity = bdInvbasdocEntities.stream().collect(Collectors.toMap(BdInvbasdocEntity::getInvcode, entity -> entity)); String pkInvbasdocStr = bdInvbasdocEntities.stream().map(entity -> "'" + entity.getInvcode() + "'").collect(Collectors.joining(",")); //查询存货对应的税目 - Map stringBdTaxitemsEntityMap = queryBatchBdTaxitems(pkInvbasdocStr); + Map stringBdTaxitemsEntityMap = queryAdditionUtil.queryBatchBdTaxitems(pkInvbasdocStr); //查询「平台运费」对应的税率 // BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode()); //查询「平台运费」、「平台优惠」、「支付优惠」、「达人优惠」所有公司的存货管理档案 - Map stringBdInvmandocEntityMap = queryInventoryMan(bdInvbasdocEntities); + Map stringBdInvmandocEntityMap = queryAdditionUtil.queryInventoryMan(bdInvbasdocEntities); if (bdBusitypeEntity != null && summaryDimensionMap != null) { Iterator>> iterator = summaryDimensionMap.entrySet().iterator(); @@ -2265,7 +2268,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //accumulatedPostage应该是负数 BigDecimal absAccumulatedPostage = accumulatedPostage.abs(); BigDecimal negativeValue = absAccumulatedPostage.negate(); - additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); } //平台优惠 if (sonDetailsDto.getVdef4() != null && !"".equals(sonDetailsDto.getVdef4())) { @@ -2280,7 +2283,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //补充:平台优惠-存货 BigDecimal absBigDecimalVdef4 = bigDecimalVdef4.abs(); BigDecimal negativeValue = absBigDecimalVdef4.negate(); - additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); } } //达人优惠 @@ -2296,7 +2299,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //补充:达人优惠-存货 BigDecimal absBigDecimalVdef6 = bigDecimalVdef6.abs(); BigDecimal negativeValue = absBigDecimalVdef6.negate(); - additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); } } //支付优惠 @@ -2312,7 +2315,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //补充:支付优惠-存货 BigDecimal absBigDecimalVdef5 = bigDecimalVdef5.abs(); BigDecimal negativeValue = absBigDecimalVdef5.negate(); - additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); } } @@ -2535,7 +2538,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //存货对应的税率 BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY05"); //补充:平台运费-存货 - additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, accumulatedPostage, "1", bdTaxitemsEntity); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, accumulatedPostage, "1", bdTaxitemsEntity); } //平台优惠 if (sonDetailsDto.getVdef4() != null && !"".equals(sonDetailsDto.getVdef4())) { @@ -2548,7 +2551,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //存货对应的税率 BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY01"); //补充:平台优惠-存货 - additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, bigDecimalVdef4, "1", bdTaxitemsEntity); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, bigDecimalVdef4, "1", bdTaxitemsEntity); } } //达人优惠 @@ -2562,7 +2565,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //存货对应的税率 BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY02"); //补充:达人优惠-存货 - additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, bigDecimalVdef6, "1", bdTaxitemsEntity); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, bigDecimalVdef6, "1", bdTaxitemsEntity); } } //支付优惠 @@ -2576,7 +2579,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //存货对应的税率 BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY04"); //补充:支付优惠-存货 - additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, bigDecimalVdef5, "1", bdTaxitemsEntity); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, bigDecimalVdef5, "1", bdTaxitemsEntity); } } @@ -3552,39 +3555,39 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { * @param bdInvbasdocEntities 存货基本档案 * @author liuyang */ - private Map queryInventoryMan(List bdInvbasdocEntities) throws Exception { - Assert.notNull(bdInvbasdocEntities, "pk_invbasdoc不能为空!"); - - Map stringBdInvmandocEntityMap = new HashMap<>(); - for (int i = 0; i < bdInvbasdocEntities.size(); i++) { - BdInvbasdocEntity bdInvbasdocEntity = bdInvbasdocEntities.get(i); - - BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity(); - bdInvmandocEntity.setPkInvbasdoc(bdInvbasdocEntity.getPkInvbasdoc()); - bdInvmandocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); - List bdInvmandocEntity2 = iBdInvmandocDao.query(bdInvmandocEntity); - if (bdInvmandocEntity2 != null && bdInvmandocEntity2.size() > 0) { - for (int j = 0; j < bdInvmandocEntity2.size(); j++) { - BdInvmandocEntity bdInvmandocEntity1 = bdInvmandocEntity2.get(j); - stringBdInvmandocEntityMap.put(bdInvbasdocEntity.getInvcode() + bdInvmandocEntity1.getPkCorp(), bdInvmandocEntity1); - } - } - } -// BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity(); -// bdInvmandocEntity.setPkInvbasdocs(pk_invbasdocs); -// bdInvmandocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); -// List bdInvmandocEntity2 = iBdInvmandocDao.query(bdInvmandocEntity); -// if (bdInvmandocEntity2 == null || bdInvmandocEntity2.size() == 0) { -// Assert.state(false, "无法查询到所有公司对应的存货管理档案 存货基本档案主键:{}", pk_invbasdocs); -// } -// if (bdInvmandocEntity2 != null && bdInvmandocEntity2.size() > 0) { -// for (int i = 0; i < bdInvmandocEntity2.size(); i++) { -// BdInvmandocEntity bdInvmandocEntity1 = bdInvmandocEntity2.get(i); -// stringBdInvmandocEntityMap.put(bdInvmandocEntity1.getPkCorp(), bdInvmandocEntity1); +// private Map queryInventoryMan(List bdInvbasdocEntities) throws Exception { +// Assert.notNull(bdInvbasdocEntities, "pk_invbasdoc不能为空!"); +// +// Map stringBdInvmandocEntityMap = new HashMap<>(); +// for (int i = 0; i < bdInvbasdocEntities.size(); i++) { +// BdInvbasdocEntity bdInvbasdocEntity = bdInvbasdocEntities.get(i); +// +// BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity(); +// bdInvmandocEntity.setPkInvbasdoc(bdInvbasdocEntity.getPkInvbasdoc()); +// bdInvmandocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); +// List bdInvmandocEntity2 = iBdInvmandocDao.query(bdInvmandocEntity); +// if (bdInvmandocEntity2 != null && bdInvmandocEntity2.size() > 0) { +// for (int j = 0; j < bdInvmandocEntity2.size(); j++) { +// BdInvmandocEntity bdInvmandocEntity1 = bdInvmandocEntity2.get(j); +// stringBdInvmandocEntityMap.put(bdInvbasdocEntity.getInvcode() + bdInvmandocEntity1.getPkCorp(), bdInvmandocEntity1); +// } // } // } - return stringBdInvmandocEntityMap; - } +//// BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity(); +//// bdInvmandocEntity.setPkInvbasdocs(pk_invbasdocs); +//// bdInvmandocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); +//// List bdInvmandocEntity2 = iBdInvmandocDao.query(bdInvmandocEntity); +//// if (bdInvmandocEntity2 == null || bdInvmandocEntity2.size() == 0) { +//// Assert.state(false, "无法查询到所有公司对应的存货管理档案 存货基本档案主键:{}", pk_invbasdocs); +//// } +//// 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 @@ -3592,22 +3595,22 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { * * @author liuyang */ - private List queryStockBasicArchives() throws Exception { -// String invcode = "FY05"; - String invcodes = "'FY05','FY02','FY04','FY01'"; - BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity(); -// bdInvbasdocEntity.setInvcode(invcode); - bdInvbasdocEntity.setInvcodes(invcodes); - bdInvbasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); - List bdInvbasdocEntities = iBdInvbasdocDao.query(bdInvbasdocEntity); - if (bdInvbasdocEntities == null || bdInvbasdocEntities.size() == 0) { - Assert.state(false, "根据存货编码:{},无法匹配到U8C存货基本档案", invcodes); - } - if (bdInvbasdocEntities.size() != 4) { - Assert.state(false, "没有满足符合条数的存货数量,请检查《平台运费-FY05》、《平台优惠-FY01》、《达人优惠-FY02》、《支付优惠-FY04》是否在U8C全部都配置完毕!"); - } - return bdInvbasdocEntities; - } +// private List queryStockBasicArchives() throws Exception { +//// String invcode = "FY05"; +// String invcodes = "'FY05','FY02','FY04','FY01'"; +// BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity(); +//// bdInvbasdocEntity.setInvcode(invcode); +// bdInvbasdocEntity.setInvcodes(invcodes); +// bdInvbasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); +// List bdInvbasdocEntities = iBdInvbasdocDao.query(bdInvbasdocEntity); +// if (bdInvbasdocEntities == null || bdInvbasdocEntities.size() == 0) { +// Assert.state(false, "根据存货编码:{},无法匹配到U8C存货基本档案", invcodes); +// } +// if (bdInvbasdocEntities.size() != 4) { +// Assert.state(false, "没有满足符合条数的存货数量,请检查《平台运费-FY05》、《平台优惠-FY01》、《达人优惠-FY02》、《支付优惠-FY04》是否在U8C全部都配置完毕!"); +// } +// return bdInvbasdocEntities; +// } /** * 2024年8月7日 14:58:34 @@ -3635,20 +3638,20 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { * * @author liuyang */ - private Map queryBatchBdTaxitems(String invcode) throws Exception { - Assert.notNull(invcode, "存货编码不能为空"); - - BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity(); - bdTaxitemsEntity.setInvcodes(invcode); - List bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity); - if (bdTaxitemsEntityList.size() == 0) { - Assert.state(false, "根据存货编码{}没有查询到U8C税目档案", invcode); - } - if (bdTaxitemsEntityList.size() != 4) { - Assert.state(false, "根据存货编码{}没有查询到足够的U8C税目档案", invcode); - } - return bdTaxitemsEntityList.stream().collect(Collectors.toMap(BdTaxitemsEntity::getInvcode, entity -> entity)); - } +// private Map queryBatchBdTaxitems(String invcode) throws Exception { +// Assert.notNull(invcode, "存货编码不能为空"); +// +// BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity(); +// bdTaxitemsEntity.setInvcodes(invcode); +// List bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity); +// if (bdTaxitemsEntityList.size() == 0) { +// Assert.state(false, "根据存货编码{}没有查询到U8C税目档案", invcode); +// } +// if (bdTaxitemsEntityList.size() != 4) { +// Assert.state(false, "根据存货编码{}没有查询到足够的U8C税目档案", invcode); +// } +// return bdTaxitemsEntityList.stream().collect(Collectors.toMap(BdTaxitemsEntity::getInvcode, entity -> entity)); +// } /** * 累加应收金额=实付金额+达人优惠+支付优惠+平台优惠 @@ -3831,45 +3834,45 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { * @param nnumber 数量 * @author liuyang */ - private void additional(List saleorderRequestChildrenDtoList, BdInvmandocEntity bdInvmandocEntity1, BdInvbasdocEntity bdInvbasdocEntity1, BigDecimal noriginalcursummny, String nnumber, BdTaxitemsEntity bdTaxitemsEntity) throws Exception { - Assert.notNull(saleorderRequestChildrenDtoList, "saleorderRequestChildrenDtoList不能为空!"); - Assert.notNull(bdInvmandocEntity1, "bdInvmandocEntity1不能为空"); - Assert.notNull(bdInvbasdocEntity1, "bdInvbasdocEntity1不能为空"); - Assert.notNull(noriginalcursummny, "noriginalcursummny不能为空"); - Assert.notNull(nnumber, "nnumber不能为空!"); - - //如果size=0则不正常 - if (saleorderRequestChildrenDtoList.size() > 0) { - SaleorderRequestChildrenDto saleorderRequestChildrenDto = saleorderRequestChildrenDtoList.get(0); - - //拷贝SaleorderRequestChildrenDto对象 - SaleorderRequestChildrenDto saleorderRequestChildrenDto1 = new SaleorderRequestChildrenDto(); - BeanUtil.copyPropertiesV2(saleorderRequestChildrenDto, saleorderRequestChildrenDto1); - - //修改存货、数量、税率、价税合计、优惠金额设置为0 - //存货id、存货编码 - saleorderRequestChildrenDto1.setCinventoryid(bdInvmandocEntity1.getPkInvmandoc()); - saleorderRequestChildrenDto1.setCinventorycode(bdInvbasdocEntity1.getInvcode()); - - //价税合计 - saleorderRequestChildrenDto1.setNoriginalcursummny(noriginalcursummny.setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString()); - - //数量 - saleorderRequestChildrenDto1.setNnumber(nnumber); - - //税率 - saleorderRequestChildrenDto1.setNtaxrate(new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString()); - - //优惠字段 - saleorderRequestChildrenDto1.setVdef4("0"); - saleorderRequestChildrenDto1.setVdef5("0"); - saleorderRequestChildrenDto1.setVdef6("0"); - saleorderRequestChildrenDto1.setVdef7("0"); - - //是否赠品 - saleorderRequestChildrenDto1.setBlargessflag(false); - - saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto1); - } - } +// private void additional(List saleorderRequestChildrenDtoList, BdInvmandocEntity bdInvmandocEntity1, BdInvbasdocEntity bdInvbasdocEntity1, BigDecimal noriginalcursummny, String nnumber, BdTaxitemsEntity bdTaxitemsEntity) throws Exception { +// Assert.notNull(saleorderRequestChildrenDtoList, "saleorderRequestChildrenDtoList不能为空!"); +// Assert.notNull(bdInvmandocEntity1, "bdInvmandocEntity1不能为空"); +// Assert.notNull(bdInvbasdocEntity1, "bdInvbasdocEntity1不能为空"); +// Assert.notNull(noriginalcursummny, "noriginalcursummny不能为空"); +// Assert.notNull(nnumber, "nnumber不能为空!"); +// +// //如果size=0则不正常 +// if (saleorderRequestChildrenDtoList.size() > 0) { +// SaleorderRequestChildrenDto saleorderRequestChildrenDto = saleorderRequestChildrenDtoList.get(0); +// +// //拷贝SaleorderRequestChildrenDto对象 +// SaleorderRequestChildrenDto saleorderRequestChildrenDto1 = new SaleorderRequestChildrenDto(); +// BeanUtil.copyPropertiesV2(saleorderRequestChildrenDto, saleorderRequestChildrenDto1); +// +// //修改存货、数量、税率、价税合计、优惠金额设置为0 +// //存货id、存货编码 +// saleorderRequestChildrenDto1.setCinventoryid(bdInvmandocEntity1.getPkInvmandoc()); +// saleorderRequestChildrenDto1.setCinventorycode(bdInvbasdocEntity1.getInvcode()); +// +// //价税合计 +// saleorderRequestChildrenDto1.setNoriginalcursummny(noriginalcursummny.setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString()); +// +// //数量 +// saleorderRequestChildrenDto1.setNnumber(nnumber); +// +// //税率 +// saleorderRequestChildrenDto1.setNtaxrate(new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString()); +// +// //优惠字段 +// saleorderRequestChildrenDto1.setVdef4("0"); +// saleorderRequestChildrenDto1.setVdef5("0"); +// saleorderRequestChildrenDto1.setVdef6("0"); +// saleorderRequestChildrenDto1.setVdef7("0"); +// +// //是否赠品 +// saleorderRequestChildrenDto1.setBlargessflag(false); +// +// saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto1); +// } +// } } \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java index a02f704b..dc834ce9 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java @@ -75,6 +75,9 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { @Autowired private QueryU8CEntityUtil queryU8CEntityUtil; + @Autowired + private QueryAdditionUtil queryAdditionUtil; + @Override public void initialize() { logger.info(getPluginLabel() + "執行初始化方法initialize()"); @@ -618,6 +621,16 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { // BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("202"); //初始化所有存货管理档案对应的结存价+采购价 // List mapList = initAllBalancePricePurchasePrice(); + //查询「平台运费」、「平台优惠」、「支付优惠」、「达人优惠」存货基本档案(注意没有商家优惠) + List bdInvbasdocEntities = queryAdditionUtil.queryStockBasicArchives(); + Map mapBdInvbasdocEntity = bdInvbasdocEntities.stream().collect(Collectors.toMap(BdInvbasdocEntity::getInvcode, entity -> entity)); + String pkInvbasdocStr = bdInvbasdocEntities.stream().map(entity -> "'" + entity.getInvcode() + "'").collect(Collectors.joining(",")); + //查询存货对应的税目 + Map stringBdTaxitemsEntityMap = queryAdditionUtil.queryBatchBdTaxitems(pkInvbasdocStr); + //查询「平台运费」对应的税率 +// BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode()); + //查询「平台运费」、「平台优惠」、「支付优惠」、「达人优惠」所有公司的存货管理档案 + Map stringBdInvmandocEntityMap = queryAdditionUtil.queryInventoryMan(bdInvbasdocEntities); if (bdBusitypeEntity != null && summaryDimensionMap != null) { Iterator>> iterator = summaryDimensionMap.entrySet().iterator(); @@ -753,28 +766,77 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { // saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目 // saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj()); //如果优惠金额为0,则传0 - if (goodsRertunSonDetailsDto != null && !"0".equals(goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) { + if (!"0".equals(goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) { saleorderRequestChildrenDto.setVdef4("-" + goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef4("0"); } - if (goodsRertunSonDetailsDto != null && !"0".equals(goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString())) { + if (!"0".equals(goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString())) { saleorderRequestChildrenDto.setVdef5("-" + goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef5("0"); } - if (goodsRertunSonDetailsDto != null && !"0".equals(goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString())) { + if (!"0".equals(goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString())) { saleorderRequestChildrenDto.setVdef6("-" + goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef6("0"); } - if (goodsRertunSonDetailsDto != null && !"0".equals(goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString())) { + if (!"0".equals(goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString())) { saleorderRequestChildrenDto.setVdef7("-" + goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef7("0"); } saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); + //平台优惠 + if (goodsRertunSonDetailsDto.getVdef4() != null) { + BigDecimal vdef4 = goodsRertunSonDetailsDto.getVdef4(); + if (vdef4.compareTo(BigDecimal.ZERO) > 0) { + //发货运费-存货基本档案 + BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY01"); + //存货管理档案 + BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); + //存货对应的税率 + BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY01"); + //补充:平台优惠-存货 + BigDecimal absAccumulatedPostage = vdef4.abs(); + BigDecimal negativeValue = absAccumulatedPostage.negate(); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); + } + } + //达人优惠 + if (goodsRertunSonDetailsDto.getVdef6() != null) { + BigDecimal vdef6 = goodsRertunSonDetailsDto.getVdef6(); + if (vdef6.compareTo(BigDecimal.ZERO) > 0) { + //发货运费-存货基本档案 + BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY02"); + //存货管理档案 + BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); + //存货对应的税率 + BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY02"); + //补充:达人优惠-存货 + BigDecimal absAccumulatedPostage = vdef6.abs(); + BigDecimal negativeValue = absAccumulatedPostage.negate(); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); + } + } + //支付优惠 + if (goodsRertunSonDetailsDto.getVdef5() != null) { + BigDecimal vdef5 = goodsRertunSonDetailsDto.getVdef5(); + if (vdef5.compareTo(BigDecimal.ZERO) > 0) { + //发货运费-存货基本档案 + BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY04"); + //存货管理档案 + BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); + //存货对应的税率 + BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY04"); + //补充:支付优惠-存货 + BigDecimal absAccumulatedPostage = vdef5.abs(); + BigDecimal negativeValue = absAccumulatedPostage.negate(); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); + } + } + //销售订单单据推送到u8c List saleorderRequestDtoList = new ArrayList<>(); saleorderRequestDtoList.add(saleorderRequestDto); @@ -833,6 +895,16 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { BdBusitypeEntity bdBusitypeEntity = u8cOperationFlowV2(); //初始化所有存货管理档案对应的结存价+采购价 // List mapList = initAllBalancePricePurchasePrice(); + //查询「平台运费」、「平台优惠」、「支付优惠」、「达人优惠」存货基本档案(注意没有商家优惠) + List bdInvbasdocEntities = queryAdditionUtil.queryStockBasicArchives(); + Map mapBdInvbasdocEntity = bdInvbasdocEntities.stream().collect(Collectors.toMap(BdInvbasdocEntity::getInvcode, entity -> entity)); + String pkInvbasdocStr = bdInvbasdocEntities.stream().map(entity -> "'" + entity.getInvcode() + "'").collect(Collectors.joining(",")); + //查询存货对应的税目 + Map stringBdTaxitemsEntityMap = queryAdditionUtil.queryBatchBdTaxitems(pkInvbasdocStr); + //查询「平台运费」对应的税率 +// BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode()); + //查询「平台运费」、「平台优惠」、「支付优惠」、「达人优惠」所有公司的存货管理档案 + Map stringBdInvmandocEntityMap = queryAdditionUtil.queryInventoryMan(bdInvbasdocEntities); if (bdBusitypeEntity != null && summaryDimensionMap != null) { Iterator>> iterator = summaryDimensionMap.entrySet().iterator(); @@ -968,28 +1040,78 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { // saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目 // saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj()); //如果优惠金额为0,则传0 - if (goodsRertunSonDetailsDto != null && !"0".equals(goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) { + if (!"0".equals(goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) { saleorderRequestChildrenDto.setVdef4("-" + goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef4("0"); } - if (goodsRertunSonDetailsDto != null && !"0".equals(goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString())) { + if (!"0".equals(goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString())) { saleorderRequestChildrenDto.setVdef5("-" + goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef5("0"); } - if (goodsRertunSonDetailsDto != null && !"0".equals(goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString())) { + if (!"0".equals(goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString())) { saleorderRequestChildrenDto.setVdef6("-" + goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef6("0"); } - if (goodsRertunSonDetailsDto != null && !"0".equals(goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString())) { + if (!"0".equals(goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString())) { saleorderRequestChildrenDto.setVdef7("-" + goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString()); } else { saleorderRequestChildrenDto.setVdef7("0"); } saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); + //退货没有邮费金额,已经向万万确认 + //平台优惠 + if (goodsRertunSonDetailsDto.getVdef4() != null) { + BigDecimal vdef4 = goodsRertunSonDetailsDto.getVdef4(); + if (vdef4.compareTo(BigDecimal.ZERO) > 0) { + //发货运费-存货基本档案 + BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY01"); + //存货管理档案 + BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); + //存货对应的税率 + BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY01"); + //补充:平台优惠-存货 + BigDecimal absAccumulatedPostage = vdef4.abs(); + BigDecimal negativeValue = absAccumulatedPostage.negate(); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); + } + } + //达人优惠 + if (goodsRertunSonDetailsDto.getVdef6() != null) { + BigDecimal vdef6 = goodsRertunSonDetailsDto.getVdef6(); + if (vdef6.compareTo(BigDecimal.ZERO) > 0) { + //发货运费-存货基本档案 + BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY02"); + //存货管理档案 + BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); + //存货对应的税率 + BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY02"); + //补充:达人优惠-存货 + BigDecimal absAccumulatedPostage = vdef6.abs(); + BigDecimal negativeValue = absAccumulatedPostage.negate(); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); + } + } + //支付优惠 + if (goodsRertunSonDetailsDto.getVdef5() != null) { + BigDecimal vdef5 = goodsRertunSonDetailsDto.getVdef5(); + if (vdef5.compareTo(BigDecimal.ZERO) > 0) { + //发货运费-存货基本档案 + BdInvbasdocEntity bdInvbasdocEntity1 = mapBdInvbasdocEntity.get("FY04"); + //存货管理档案 + BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(bdInvbasdocEntity1.getInvcode() + deliverGoodsCorp.getPkCorp()); + //存货对应的税率 + BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY04"); + //补充:支付优惠-存货 + BigDecimal absAccumulatedPostage = vdef5.abs(); + BigDecimal negativeValue = absAccumulatedPostage.negate(); + queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, negativeValue, "-1", bdTaxitemsEntity); + } + } + //销售订单单据推送到u8c List saleorderRequestDtoList = new ArrayList<>(); saleorderRequestDtoList.add(saleorderRequestDto); @@ -1006,8 +1128,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { csaleid = soSaleResultRootDto.getParentvo().getCsaleid(); } logger.info("TOC销售订单编号:{} 销售订单主键:{} 销售公司:{}", vreceiptcode, csaleid, pk_corp); - //记录成功 - updateSuccessOrFail2(oldValue, "Y", "success", vreceiptcode, csaleid); + //记录成功updateSuccessOrFail2(oldValue, "Y", "success", vreceiptcode, csaleid); } catch (Exception e) { logger.error("TOC退货业务转换成U8C对象过程中、或者单据推送到U8C出现异常!", e); //记录失败 @@ -1036,6 +1157,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { * @author liuyang */ private String createGenerateBusinessDate(StockinOrderSearchResponse.StockinOrder.StockinH header) { + //测试 // header.setClosedAt("2024-11-29 10:00:12"); String code = null; if (header != null && header.getCode() != null) { @@ -1109,6 +1231,17 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { //查询OFS售后入库单对应的售后订单 List rerturnGoodsOrderSearchData = queryBatchAfterSalesOrder(returnGoodHeaderDetailsDataDtoList1); findAfterSalesOrder(rerturnGoodsOrderSearchData, returnGoodHeaderDetailsDataDtoList1); + //测试 +// RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData2 = rerturnGoodsOrderSearchData.get(0); +// List details2 = rerturnGoodsOrderSearchData2.getDetails(); +// for (int i = 0; i < details2.size(); i++) { +// RerturnGoodsOrderSearchDetails rerturnGoodsOrderSearchDetails = details2.get(i); +// +// rerturnGoodsOrderSearchDetails.setPlatformDiscounts("1"); +// rerturnGoodsOrderSearchDetails.setMerchantDiscounts("1"); +// rerturnGoodsOrderSearchDetails.setExpertDiscounts("1"); +// rerturnGoodsOrderSearchDetails.setPayDiscounts("1"); +// } //查询OFS售后订单对应的OFS销售订单 List headerDetailsDtos = queryBatchOfsOrder(returnGoodHeaderDetailsDataDtoList1); findOfsOrder(headerDetailsDtos, returnGoodHeaderDetailsDataDtoList1); @@ -1490,6 +1623,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { * 单价计算公式:sum(实付金额/实发数量) 最后除以条数 * * @param sonDetailsDtoList 汇总过后的售后入库单明细 + * @param isCheckShopChoose true取建议零售价、false取实付金额 * @author liuyang */ private GoodsRertunSonDetailsDto groupMergeDetailedRows(List sonDetailsDtoList, Boolean isCheckShopChoose) throws Exception { @@ -1537,6 +1671,9 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { //// goodsRertunSonDetailsDto.setReceivedQty("1"); // totalAmount = accumulatedDiscounts(goodsRertunSonDetailsDto, rerturnGoodsOrderSearchData, calculationFormulaStr); // } + //测试 +// goodsRertunSonDetailsDto.setReceivedQty("1"); + Assert.notNull(totalAmount, "实退金额不能为空 明细行主键:{}", goodsRertunSonDetailsDto.getId()); Assert.notNull(goodsRertunSonDetailsDto.getReceivedQty(), "实收数量不能为空 明细行主键:{}", goodsRertunSonDetailsDto.getId()); @@ -1548,6 +1685,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { goodsRertunSonDetailsDto.setCalculateAccountsReceivable(totalAmount); goodsRertunSonDetailsDto.setCalculationFormula(calculationFormulaStr.toString()); + goodsRertunSonDetailsDto.setPlatformDiscounts(ofsOrderDetail.getPlatformDiscounts()); goodsRertunSonDetailsDto.setMerchantDiscounts(ofsOrderDetail.getMerchantDiscounts()); goodsRertunSonDetailsDto.setExpertDiscounts(ofsOrderDetail.getExpertDiscounts()); @@ -2679,6 +2817,9 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { Assert.notNull(requestQty, "售后订单:{} 存货明细行:{} 请求数量不能为空!", header.getCode(), targetDetails.getSkuCode()); Assert.state(!"".equals(requestQty), "售后订单:{} 存货明细行:{} 请求数量不能为空!", header.getCode(), targetDetails.getSkuCode()); + //测试 +// goodsRertunSonDetailsDto.setReceivedQty("1"); + String receivedQty = goodsRertunSonDetailsDto.getReceivedQty(); Assert.notNull(receivedQty, "售后订单:{} 存货明细行:{} 请求数量不能为空!", header1.getCode(), goodsRertunSonDetailsDto.getId()); Assert.state(!"".equals(receivedQty), header1.getCode(), goodsRertunSonDetailsDto.getId()); @@ -2694,40 +2835,41 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { String format = StrUtil.format("{}/{}*{}", totalAmount, requestQty, receivedQty); calculationFormulaStr.append(format); - //商家优惠:不处理!!!仅保存 - String merchantDiscounts = targetDetails.getMerchantDiscounts(); - //达人优惠 - String expertDiscounts = targetDetails.getExpertDiscounts(); - //支付优惠 - String payDiscounts = targetDetails.getPayDiscounts(); - //平台优惠 - String platformDiscounts = targetDetails.getPlatformDiscounts(); - - 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 (actualRefundAmount != null) { - totalPayAmountBigDecimal = actualRefundAmount; - } - 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(); +// //商家优惠:不处理!!!仅保存 +// String merchantDiscounts = targetDetails.getMerchantDiscounts(); +// //达人优惠 +// String expertDiscounts = targetDetails.getExpertDiscounts(); +// //支付优惠 +// String payDiscounts = targetDetails.getPayDiscounts(); +// //平台优惠 +// String platformDiscounts = targetDetails.getPlatformDiscounts(); +// +// 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 (actualRefundAmount != null) { +// totalPayAmountBigDecimal = actualRefundAmount; +// } +// 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(); + return actualRefundAmount.stripTrailingZeros().toPlainString(); } /** @@ -2736,7 +2878,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { * @param sonDetailsDtoList OFS售后入库单明细行List集合(按纬度汇总好的) * @author liuyang */ - private void accumulatedDiscountAmountDef(List sonDetailsDtoList) { + private void accumulatedDiscountAmountDef(List sonDetailsDtoList) throws Exception { Assert.notNull(sonDetailsDtoList, "sonDetailsDtoList不能为空"); if (sonDetailsDtoList.size() > 0) { diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/QueryAdditionUtil.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/QueryAdditionUtil.java new file mode 100644 index 00000000..42ee0911 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/QueryAdditionUtil.java @@ -0,0 +1,163 @@ +package com.hzya.frame.plugin.lets.util; + +import cn.hutool.core.lang.Assert; +import com.hzya.frame.beanutil.BeanUtil; +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.BdInvbasdocEntity; +import com.hzya.frame.plugin.lets.entity.BdInvmandocEntity; +import com.hzya.frame.plugin.lets.entity.BdTaxitemsEntity; +import com.hzya.frame.plugin.lets.u8cdto.SaleorderRequestChildrenDto; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Author:liuyang + * @Package:com.hzya.frame.plugin.lets.util + * @Project:kangarooDataCenterV3 + * @name:QueryAdditionUtil + * @Date:2024/12/4 15:12 + * @Filename:QueryAdditionUtil + */ +@Component +public class QueryAdditionUtil { + + @Autowired + private IBdInvbasdocDao iBdInvbasdocDao; + + @Autowired + private IBdTaxitemsDao iBdTaxitemsDao; + + @Autowired + private IBdInvmandocDao iBdInvmandocDao; + + /** + * 2024年8月7日 10:25:29 + * 查询存货基础档案档案 + * + * @author liuyang + */ + public List queryStockBasicArchives() throws Exception { + String invcodes = "'FY05','FY02','FY04','FY01'"; + BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity(); + bdInvbasdocEntity.setInvcodes(invcodes); + bdInvbasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); + List bdInvbasdocEntities = iBdInvbasdocDao.query(bdInvbasdocEntity); + if (bdInvbasdocEntities == null || bdInvbasdocEntities.size() == 0) { + Assert.state(false, "根据存货编码:{},无法匹配到U8C存货基本档案", invcodes); + } + if (bdInvbasdocEntities.size() != 4) { + Assert.state(false, "没有满足符合条数的存货数量,请检查《平台运费-FY05》、《平台优惠-FY01》、《达人优惠-FY02》、《支付优惠-FY04》是否在U8C全部都配置完毕!"); + } + return bdInvbasdocEntities; + } + + /** + * 2024年8月7日 14:58:34 + * 查询存货对应的税目档案 + * + * @author liuyang + */ + public Map queryBatchBdTaxitems(String invcode) throws Exception { + Assert.notNull(invcode, "存货编码不能为空"); + + BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity(); + bdTaxitemsEntity.setInvcodes(invcode); + List bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity); + if (bdTaxitemsEntityList.size() == 0) { + Assert.state(false, "根据存货编码{}没有查询到U8C税目档案", invcode); + } + if (bdTaxitemsEntityList.size() != 4) { + Assert.state(false, "根据存货编码{}没有查询到足够的U8C税目档案", invcode); + } + return bdTaxitemsEntityList.stream().collect(Collectors.toMap(BdTaxitemsEntity::getInvcode, entity -> entity)); + } + + + /** + * 查询存货管理档案,key为公司id、value为存货管理档案对象 + * + * @param bdInvbasdocEntities 存货基本档案 + * @author liuyang + */ + public Map queryInventoryMan(List bdInvbasdocEntities) throws Exception { + Assert.notNull(bdInvbasdocEntities, "pk_invbasdoc不能为空!"); + + Map stringBdInvmandocEntityMap = new HashMap<>(); + for (int i = 0; i < bdInvbasdocEntities.size(); i++) { + BdInvbasdocEntity bdInvbasdocEntity = bdInvbasdocEntities.get(i); + + BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity(); + bdInvmandocEntity.setPkInvbasdoc(bdInvbasdocEntity.getPkInvbasdoc()); + bdInvmandocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); + List bdInvmandocEntity2 = iBdInvmandocDao.query(bdInvmandocEntity); + if (bdInvmandocEntity2 != null && bdInvmandocEntity2.size() > 0) { + for (int j = 0; j < bdInvmandocEntity2.size(); j++) { + BdInvmandocEntity bdInvmandocEntity1 = bdInvmandocEntity2.get(j); + stringBdInvmandocEntityMap.put(bdInvbasdocEntity.getInvcode() + bdInvmandocEntity1.getPkCorp(), bdInvmandocEntity1); + } + } + } + return stringBdInvmandocEntityMap; + } + + /** + * 增加平台运费,优惠金额这些存货一起保存进U8C销售订单 + * + * @param bdInvmandocEntity1 存货管理档案 + * @param bdInvbasdocEntity1 存货基本档案 + * @param saleorderRequestChildrenDtoList 需要推送给U8C销售订单明细行表体 + * @param noriginalcursummny 价税合计,只能传金额 + * @param nnumber 数量 + * @author liuyang + */ + public void additional(List saleorderRequestChildrenDtoList, BdInvmandocEntity bdInvmandocEntity1, BdInvbasdocEntity bdInvbasdocEntity1, BigDecimal noriginalcursummny, String nnumber, BdTaxitemsEntity bdTaxitemsEntity) throws Exception { + Assert.notNull(saleorderRequestChildrenDtoList, "saleorderRequestChildrenDtoList不能为空!"); + Assert.notNull(bdInvmandocEntity1, "bdInvmandocEntity1不能为空"); + Assert.notNull(bdInvbasdocEntity1, "bdInvbasdocEntity1不能为空"); + Assert.notNull(noriginalcursummny, "noriginalcursummny不能为空"); + Assert.notNull(nnumber, "nnumber不能为空!"); + + //如果size=0则不正常 + if (saleorderRequestChildrenDtoList.size() > 0) { + SaleorderRequestChildrenDto saleorderRequestChildrenDto = saleorderRequestChildrenDtoList.get(0); + + //拷贝SaleorderRequestChildrenDto对象 + SaleorderRequestChildrenDto saleorderRequestChildrenDto1 = new SaleorderRequestChildrenDto(); + BeanUtil.copyPropertiesV2(saleorderRequestChildrenDto, saleorderRequestChildrenDto1); + + //修改存货、数量、税率、价税合计、优惠金额设置为0 + //存货id、存货编码 + saleorderRequestChildrenDto1.setCinventoryid(bdInvmandocEntity1.getPkInvmandoc()); + saleorderRequestChildrenDto1.setCinventorycode(bdInvbasdocEntity1.getInvcode()); + + //价税合计 + saleorderRequestChildrenDto1.setNoriginalcursummny(noriginalcursummny.setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString()); + + //数量 + saleorderRequestChildrenDto1.setNnumber(nnumber); + + //税率 + saleorderRequestChildrenDto1.setNtaxrate(new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString()); + + //优惠字段 + saleorderRequestChildrenDto1.setVdef4("0"); + saleorderRequestChildrenDto1.setVdef5("0"); + saleorderRequestChildrenDto1.setVdef6("0"); + saleorderRequestChildrenDto1.setVdef7("0"); + + //是否赠品 + saleorderRequestChildrenDto1.setBlargessflag(false); + + saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto1); + } + } +} diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToCTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToCTest.java index 5459741d..fb1e6e67 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToCTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToCTest.java @@ -31,7 +31,7 @@ public class SoSaleReturnPluginInitializerToCTest { // soSaleReturnPluginInitializerToC.startImplement(null, null); try { String code = "LETS-RE2024112900000001"; - soSaleReturnPluginInitializerToC.startImplementByCode(code, "stock"); + soSaleReturnPluginInitializerToC.startImplementByCode(code, "tran"); } catch (Exception e) { e.printStackTrace(); }