refactor(sales): 重构销售订单插件初始化逻辑

-移除冗余代码和注释掉的方法
- 使用 QueryAdditionUtil 类替代重复的查询逻辑- 优化了平台运费、优惠等的处理逻辑
This commit is contained in:
liuy 2024-12-05 16:39:02 +08:00
parent 4a489719fd
commit b274609d9e
4 changed files with 475 additions and 167 deletions

View File

@ -208,6 +208,9 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
@Autowired @Autowired
private OfsStandardUtil ofsStandardUtil; private OfsStandardUtil ofsStandardUtil;
@Autowired
private QueryAdditionUtil queryAdditionUtil;
@Autowired @Autowired
private RdclUtil rdclUtil; private RdclUtil rdclUtil;
@ -859,15 +862,15 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//初始化所有存货管理档案对应的结存价+采购价 //初始化所有存货管理档案对应的结存价+采购价
// List<Map> mapList = initAllBalancePricePurchasePrice(); // List<Map> mapList = initAllBalancePricePurchasePrice();
//查询平台运费平台优惠支付优惠达人优惠存货基本档案注意没有商家优惠 //查询平台运费平台优惠支付优惠达人优惠存货基本档案注意没有商家优惠
List<BdInvbasdocEntity> bdInvbasdocEntities = queryStockBasicArchives(); List<BdInvbasdocEntity> bdInvbasdocEntities = queryAdditionUtil.queryStockBasicArchives();
Map<String, BdInvbasdocEntity> mapBdInvbasdocEntity = bdInvbasdocEntities.stream().collect(Collectors.toMap(BdInvbasdocEntity::getInvcode, entity -> entity)); Map<String, BdInvbasdocEntity> mapBdInvbasdocEntity = bdInvbasdocEntities.stream().collect(Collectors.toMap(BdInvbasdocEntity::getInvcode, entity -> entity));
String pkInvbasdocStr = bdInvbasdocEntities.stream().map(entity -> "'" + entity.getInvcode() + "'").collect(Collectors.joining(",")); String pkInvbasdocStr = bdInvbasdocEntities.stream().map(entity -> "'" + entity.getInvcode() + "'").collect(Collectors.joining(","));
//查询存货对应的税目 //查询存货对应的税目
Map<String, BdTaxitemsEntity> stringBdTaxitemsEntityMap = queryBatchBdTaxitems(pkInvbasdocStr); Map<String, BdTaxitemsEntity> stringBdTaxitemsEntityMap = queryAdditionUtil.queryBatchBdTaxitems(pkInvbasdocStr);
//查询平台运费对应的税率 //查询平台运费对应的税率
// BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode()); // BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode());
//查询平台运费平台优惠支付优惠达人优惠所有公司的存货管理档案 //查询平台运费平台优惠支付优惠达人优惠所有公司的存货管理档案
Map<String, BdInvmandocEntity> stringBdInvmandocEntityMap = queryInventoryMan(bdInvbasdocEntities); Map<String, BdInvmandocEntity> stringBdInvmandocEntityMap = queryAdditionUtil.queryInventoryMan(bdInvbasdocEntities);
if (bdBusitypeEntity != null && summaryDimensionMap != null) { if (bdBusitypeEntity != null && summaryDimensionMap != null) {
Iterator<Map.Entry<String, List<SonDetailsDto>>> iterator = summaryDimensionMap.entrySet().iterator(); Iterator<Map.Entry<String, List<SonDetailsDto>>> iterator = summaryDimensionMap.entrySet().iterator();
@ -1100,7 +1103,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//存货对应的税率 //存货对应的税率
BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY05"); 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())) { if (sonDetailsDto.getVdef4() != null && !"".equals(sonDetailsDto.getVdef4())) {
@ -1113,7 +1116,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//存货对应的税率 //存货对应的税率
BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY01"); 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"); 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"); BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY04");
//补充支付优惠-存货 //补充支付优惠-存货
additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, bigDecimalVdef5, "1", bdTaxitemsEntity); queryAdditionUtil.additional(saleorderRequestChildrenDtoList, bdInvmandocEntity1, bdInvbasdocEntity1, bigDecimalVdef5, "1", bdTaxitemsEntity);
} }
} }
@ -2032,15 +2035,15 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//初始化所有存货管理档案对应的结存价+采购价 //初始化所有存货管理档案对应的结存价+采购价
// List<Map> mapList = initAllBalancePricePurchasePrice(); // List<Map> mapList = initAllBalancePricePurchasePrice();
//查询平台运费存货基本档案 //查询平台运费存货基本档案
List<BdInvbasdocEntity> bdInvbasdocEntities = queryStockBasicArchives(); List<BdInvbasdocEntity> bdInvbasdocEntities = queryAdditionUtil.queryStockBasicArchives();
Map<String, BdInvbasdocEntity> mapBdInvbasdocEntity = bdInvbasdocEntities.stream().collect(Collectors.toMap(BdInvbasdocEntity::getInvcode, entity -> entity)); Map<String, BdInvbasdocEntity> mapBdInvbasdocEntity = bdInvbasdocEntities.stream().collect(Collectors.toMap(BdInvbasdocEntity::getInvcode, entity -> entity));
String pkInvbasdocStr = bdInvbasdocEntities.stream().map(entity -> "'" + entity.getInvcode() + "'").collect(Collectors.joining(",")); String pkInvbasdocStr = bdInvbasdocEntities.stream().map(entity -> "'" + entity.getInvcode() + "'").collect(Collectors.joining(","));
//查询存货对应的税目 //查询存货对应的税目
Map<String, BdTaxitemsEntity> stringBdTaxitemsEntityMap = queryBatchBdTaxitems(pkInvbasdocStr); Map<String, BdTaxitemsEntity> stringBdTaxitemsEntityMap = queryAdditionUtil.queryBatchBdTaxitems(pkInvbasdocStr);
//查询平台运费对应的税率 //查询平台运费对应的税率
// BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode()); // BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode());
//查询平台运费平台优惠支付优惠达人优惠所有公司的存货管理档案 //查询平台运费平台优惠支付优惠达人优惠所有公司的存货管理档案
Map<String, BdInvmandocEntity> stringBdInvmandocEntityMap = queryInventoryMan(bdInvbasdocEntities); Map<String, BdInvmandocEntity> stringBdInvmandocEntityMap = queryAdditionUtil.queryInventoryMan(bdInvbasdocEntities);
if (bdBusitypeEntity != null && summaryDimensionMap != null) { if (bdBusitypeEntity != null && summaryDimensionMap != null) {
Iterator<Map.Entry<String, List<SonDetailsDto>>> iterator = summaryDimensionMap.entrySet().iterator(); Iterator<Map.Entry<String, List<SonDetailsDto>>> iterator = summaryDimensionMap.entrySet().iterator();
@ -2265,7 +2268,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//accumulatedPostage应该是负数 //accumulatedPostage应该是负数
BigDecimal absAccumulatedPostage = accumulatedPostage.abs(); BigDecimal absAccumulatedPostage = accumulatedPostage.abs();
BigDecimal negativeValue = absAccumulatedPostage.negate(); 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())) { if (sonDetailsDto.getVdef4() != null && !"".equals(sonDetailsDto.getVdef4())) {
@ -2280,7 +2283,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//补充平台优惠-存货 //补充平台优惠-存货
BigDecimal absBigDecimalVdef4 = bigDecimalVdef4.abs(); BigDecimal absBigDecimalVdef4 = bigDecimalVdef4.abs();
BigDecimal negativeValue = absBigDecimalVdef4.negate(); 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 absBigDecimalVdef6 = bigDecimalVdef6.abs();
BigDecimal negativeValue = absBigDecimalVdef6.negate(); 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 absBigDecimalVdef5 = bigDecimalVdef5.abs();
BigDecimal negativeValue = absBigDecimalVdef5.negate(); 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"); 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())) { if (sonDetailsDto.getVdef4() != null && !"".equals(sonDetailsDto.getVdef4())) {
@ -2548,7 +2551,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//存货对应的税率 //存货对应的税率
BdTaxitemsEntity bdTaxitemsEntity = stringBdTaxitemsEntityMap.get("FY01"); 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"); 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"); 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 存货基本档案 * @param bdInvbasdocEntities 存货基本档案
* @author liuyang * @author liuyang
*/ */
private Map<String, BdInvmandocEntity> queryInventoryMan(List<BdInvbasdocEntity> bdInvbasdocEntities) throws Exception { // private Map<String, BdInvmandocEntity> queryInventoryMan(List<BdInvbasdocEntity> bdInvbasdocEntities) throws Exception {
Assert.notNull(bdInvbasdocEntities, "pk_invbasdoc不能为空"); // Assert.notNull(bdInvbasdocEntities, "pk_invbasdoc不能为空");
//
Map<String, BdInvmandocEntity> stringBdInvmandocEntityMap = new HashMap<>(); // Map<String, BdInvmandocEntity> stringBdInvmandocEntityMap = new HashMap<>();
for (int i = 0; i < bdInvbasdocEntities.size(); i++) { // for (int i = 0; i < bdInvbasdocEntities.size(); i++) {
BdInvbasdocEntity bdInvbasdocEntity = bdInvbasdocEntities.get(i); // BdInvbasdocEntity bdInvbasdocEntity = bdInvbasdocEntities.get(i);
//
BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity(); // BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity();
bdInvmandocEntity.setPkInvbasdoc(bdInvbasdocEntity.getPkInvbasdoc()); // bdInvmandocEntity.setPkInvbasdoc(bdInvbasdocEntity.getPkInvbasdoc());
bdInvmandocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); // bdInvmandocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
List<BdInvmandocEntity> bdInvmandocEntity2 = iBdInvmandocDao.query(bdInvmandocEntity); // List<BdInvmandocEntity> bdInvmandocEntity2 = iBdInvmandocDao.query(bdInvmandocEntity);
if (bdInvmandocEntity2 != null && bdInvmandocEntity2.size() > 0) { // if (bdInvmandocEntity2 != null && bdInvmandocEntity2.size() > 0) {
for (int j = 0; j < bdInvmandocEntity2.size(); j++) { // for (int j = 0; j < bdInvmandocEntity2.size(); j++) {
BdInvmandocEntity bdInvmandocEntity1 = bdInvmandocEntity2.get(j); // BdInvmandocEntity bdInvmandocEntity1 = bdInvmandocEntity2.get(j);
stringBdInvmandocEntityMap.put(bdInvbasdocEntity.getInvcode() + bdInvmandocEntity1.getPkCorp(), bdInvmandocEntity1); // stringBdInvmandocEntityMap.put(bdInvbasdocEntity.getInvcode() + bdInvmandocEntity1.getPkCorp(), bdInvmandocEntity1);
} // }
}
}
// BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity();
// bdInvmandocEntity.setPkInvbasdocs(pk_invbasdocs);
// bdInvmandocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
// List<BdInvmandocEntity> 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; //// BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity();
} //// bdInvmandocEntity.setPkInvbasdocs(pk_invbasdocs);
//// bdInvmandocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
//// List<BdInvmandocEntity> 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 * 2024年8月7日 10:25:29
@ -3592,22 +3595,22 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
* *
* @author liuyang * @author liuyang
*/ */
private List<BdInvbasdocEntity> queryStockBasicArchives() throws Exception { // private List<BdInvbasdocEntity> queryStockBasicArchives() throws Exception {
// String invcode = "FY05"; //// String invcode = "FY05";
String invcodes = "'FY05','FY02','FY04','FY01'"; // String invcodes = "'FY05','FY02','FY04','FY01'";
BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity(); // BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity();
// bdInvbasdocEntity.setInvcode(invcode); //// bdInvbasdocEntity.setInvcode(invcode);
bdInvbasdocEntity.setInvcodes(invcodes); // bdInvbasdocEntity.setInvcodes(invcodes);
bdInvbasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE); // bdInvbasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
List<BdInvbasdocEntity> bdInvbasdocEntities = iBdInvbasdocDao.query(bdInvbasdocEntity); // List<BdInvbasdocEntity> bdInvbasdocEntities = iBdInvbasdocDao.query(bdInvbasdocEntity);
if (bdInvbasdocEntities == null || bdInvbasdocEntities.size() == 0) { // if (bdInvbasdocEntities == null || bdInvbasdocEntities.size() == 0) {
Assert.state(false, "根据存货编码:{}无法匹配到U8C存货基本档案", invcodes); // Assert.state(false, "根据存货编码:{}无法匹配到U8C存货基本档案", invcodes);
} // }
if (bdInvbasdocEntities.size() != 4) { // if (bdInvbasdocEntities.size() != 4) {
Assert.state(false, "没有满足符合条数的存货数量,请检查《平台运费-FY05》、《平台优惠-FY01》、《达人优惠-FY02》、《支付优惠-FY04》是否在U8C全部都配置完毕"); // Assert.state(false, "没有满足符合条数的存货数量,请检查《平台运费-FY05》、《平台优惠-FY01》、《达人优惠-FY02》、《支付优惠-FY04》是否在U8C全部都配置完毕");
} // }
return bdInvbasdocEntities; // return bdInvbasdocEntities;
} // }
/** /**
* 2024年8月7日 14:58:34 * 2024年8月7日 14:58:34
@ -3635,20 +3638,20 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
* *
* @author liuyang * @author liuyang
*/ */
private Map<String, BdTaxitemsEntity> queryBatchBdTaxitems(String invcode) throws Exception { // private Map<String, BdTaxitemsEntity> queryBatchBdTaxitems(String invcode) throws Exception {
Assert.notNull(invcode, "存货编码不能为空"); // Assert.notNull(invcode, "存货编码不能为空");
//
BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity(); // BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity();
bdTaxitemsEntity.setInvcodes(invcode); // bdTaxitemsEntity.setInvcodes(invcode);
List<BdTaxitemsEntity> bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity); // List<BdTaxitemsEntity> bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity);
if (bdTaxitemsEntityList.size() == 0) { // if (bdTaxitemsEntityList.size() == 0) {
Assert.state(false, "根据存货编码{}没有查询到U8C税目档案", invcode); // Assert.state(false, "根据存货编码{}没有查询到U8C税目档案", invcode);
} // }
if (bdTaxitemsEntityList.size() != 4) { // if (bdTaxitemsEntityList.size() != 4) {
Assert.state(false, "根据存货编码{}没有查询到足够的U8C税目档案", invcode); // Assert.state(false, "根据存货编码{}没有查询到足够的U8C税目档案", invcode);
} // }
return bdTaxitemsEntityList.stream().collect(Collectors.toMap(BdTaxitemsEntity::getInvcode, entity -> entity)); // return bdTaxitemsEntityList.stream().collect(Collectors.toMap(BdTaxitemsEntity::getInvcode, entity -> entity));
} // }
/** /**
* 累加应收金额=实付金额+达人优惠+支付优惠+平台优惠 * 累加应收金额=实付金额+达人优惠+支付优惠+平台优惠
@ -3831,45 +3834,45 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
* @param nnumber 数量 * @param nnumber 数量
* @author liuyang * @author liuyang
*/ */
private void additional(List<SaleorderRequestChildrenDto> saleorderRequestChildrenDtoList, BdInvmandocEntity bdInvmandocEntity1, BdInvbasdocEntity bdInvbasdocEntity1, BigDecimal noriginalcursummny, String nnumber, BdTaxitemsEntity bdTaxitemsEntity) throws Exception { // private void additional(List<SaleorderRequestChildrenDto> saleorderRequestChildrenDtoList, BdInvmandocEntity bdInvmandocEntity1, BdInvbasdocEntity bdInvbasdocEntity1, BigDecimal noriginalcursummny, String nnumber, BdTaxitemsEntity bdTaxitemsEntity) throws Exception {
Assert.notNull(saleorderRequestChildrenDtoList, "saleorderRequestChildrenDtoList不能为空"); // Assert.notNull(saleorderRequestChildrenDtoList, "saleorderRequestChildrenDtoList不能为空");
Assert.notNull(bdInvmandocEntity1, "bdInvmandocEntity1不能为空"); // Assert.notNull(bdInvmandocEntity1, "bdInvmandocEntity1不能为空");
Assert.notNull(bdInvbasdocEntity1, "bdInvbasdocEntity1不能为空"); // Assert.notNull(bdInvbasdocEntity1, "bdInvbasdocEntity1不能为空");
Assert.notNull(noriginalcursummny, "noriginalcursummny不能为空"); // Assert.notNull(noriginalcursummny, "noriginalcursummny不能为空");
Assert.notNull(nnumber, "nnumber不能为空"); // Assert.notNull(nnumber, "nnumber不能为空");
//
//如果size=0则不正常 // //如果size=0则不正常
if (saleorderRequestChildrenDtoList.size() > 0) { // if (saleorderRequestChildrenDtoList.size() > 0) {
SaleorderRequestChildrenDto saleorderRequestChildrenDto = saleorderRequestChildrenDtoList.get(0); // SaleorderRequestChildrenDto saleorderRequestChildrenDto = saleorderRequestChildrenDtoList.get(0);
//
//拷贝SaleorderRequestChildrenDto对象 // //拷贝SaleorderRequestChildrenDto对象
SaleorderRequestChildrenDto saleorderRequestChildrenDto1 = new SaleorderRequestChildrenDto(); // SaleorderRequestChildrenDto saleorderRequestChildrenDto1 = new SaleorderRequestChildrenDto();
BeanUtil.copyPropertiesV2(saleorderRequestChildrenDto, saleorderRequestChildrenDto1); // BeanUtil.copyPropertiesV2(saleorderRequestChildrenDto, saleorderRequestChildrenDto1);
//
//修改存货数量税率价税合计优惠金额设置为0 // //修改存货数量税率价税合计优惠金额设置为0
//存货id存货编码 // //存货id存货编码
saleorderRequestChildrenDto1.setCinventoryid(bdInvmandocEntity1.getPkInvmandoc()); // saleorderRequestChildrenDto1.setCinventoryid(bdInvmandocEntity1.getPkInvmandoc());
saleorderRequestChildrenDto1.setCinventorycode(bdInvbasdocEntity1.getInvcode()); // saleorderRequestChildrenDto1.setCinventorycode(bdInvbasdocEntity1.getInvcode());
//
//价税合计 // //价税合计
saleorderRequestChildrenDto1.setNoriginalcursummny(noriginalcursummny.setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString()); // saleorderRequestChildrenDto1.setNoriginalcursummny(noriginalcursummny.setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString());
//
//数量 // //数量
saleorderRequestChildrenDto1.setNnumber(nnumber); // saleorderRequestChildrenDto1.setNnumber(nnumber);
//
//税率 // //税率
saleorderRequestChildrenDto1.setNtaxrate(new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString()); // saleorderRequestChildrenDto1.setNtaxrate(new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString());
//
//优惠字段 // //优惠字段
saleorderRequestChildrenDto1.setVdef4("0"); // saleorderRequestChildrenDto1.setVdef4("0");
saleorderRequestChildrenDto1.setVdef5("0"); // saleorderRequestChildrenDto1.setVdef5("0");
saleorderRequestChildrenDto1.setVdef6("0"); // saleorderRequestChildrenDto1.setVdef6("0");
saleorderRequestChildrenDto1.setVdef7("0"); // saleorderRequestChildrenDto1.setVdef7("0");
//
//是否赠品 // //是否赠品
saleorderRequestChildrenDto1.setBlargessflag(false); // saleorderRequestChildrenDto1.setBlargessflag(false);
//
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto1); // saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto1);
} // }
} // }
} }

View File

@ -75,6 +75,9 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
@Autowired @Autowired
private QueryU8CEntityUtil queryU8CEntityUtil; private QueryU8CEntityUtil queryU8CEntityUtil;
@Autowired
private QueryAdditionUtil queryAdditionUtil;
@Override @Override
public void initialize() { public void initialize() {
logger.info(getPluginLabel() + "執行初始化方法initialize()"); logger.info(getPluginLabel() + "執行初始化方法initialize()");
@ -618,6 +621,16 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
// BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("202"); // BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("202");
//初始化所有存货管理档案对应的结存价+采购价 //初始化所有存货管理档案对应的结存价+采购价
// List<Map> mapList = initAllBalancePricePurchasePrice(); // List<Map> mapList = initAllBalancePricePurchasePrice();
//查询平台运费平台优惠支付优惠达人优惠存货基本档案注意没有商家优惠
List<BdInvbasdocEntity> bdInvbasdocEntities = queryAdditionUtil.queryStockBasicArchives();
Map<String, BdInvbasdocEntity> mapBdInvbasdocEntity = bdInvbasdocEntities.stream().collect(Collectors.toMap(BdInvbasdocEntity::getInvcode, entity -> entity));
String pkInvbasdocStr = bdInvbasdocEntities.stream().map(entity -> "'" + entity.getInvcode() + "'").collect(Collectors.joining(","));
//查询存货对应的税目
Map<String, BdTaxitemsEntity> stringBdTaxitemsEntityMap = queryAdditionUtil.queryBatchBdTaxitems(pkInvbasdocStr);
//查询平台运费对应的税率
// BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode());
//查询平台运费平台优惠支付优惠达人优惠所有公司的存货管理档案
Map<String, BdInvmandocEntity> stringBdInvmandocEntityMap = queryAdditionUtil.queryInventoryMan(bdInvbasdocEntities);
if (bdBusitypeEntity != null && summaryDimensionMap != null) { if (bdBusitypeEntity != null && summaryDimensionMap != null) {
Iterator<Map.Entry<String, List<GoodsRertunSonDetailsDto>>> iterator = summaryDimensionMap.entrySet().iterator(); Iterator<Map.Entry<String, List<GoodsRertunSonDetailsDto>>> iterator = summaryDimensionMap.entrySet().iterator();
@ -753,28 +766,77 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
// saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目 // saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目
// saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj()); // saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj());
//如果优惠金额为0则传0 //如果优惠金额为0则传0
if (goodsRertunSonDetailsDto != null && !"0".equals(goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) { if (!"0".equals(goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) {
saleorderRequestChildrenDto.setVdef4("-" + goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString()); saleorderRequestChildrenDto.setVdef4("-" + goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString());
} else { } else {
saleorderRequestChildrenDto.setVdef4("0"); 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()); saleorderRequestChildrenDto.setVdef5("-" + goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString());
} else { } else {
saleorderRequestChildrenDto.setVdef5("0"); 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()); saleorderRequestChildrenDto.setVdef6("-" + goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString());
} else { } else {
saleorderRequestChildrenDto.setVdef6("0"); 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()); saleorderRequestChildrenDto.setVdef7("-" + goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString());
} else { } else {
saleorderRequestChildrenDto.setVdef7("0"); saleorderRequestChildrenDto.setVdef7("0");
} }
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); 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 //销售订单单据推送到u8c
List<SaleorderRequestDto> saleorderRequestDtoList = new ArrayList<>(); List<SaleorderRequestDto> saleorderRequestDtoList = new ArrayList<>();
saleorderRequestDtoList.add(saleorderRequestDto); saleorderRequestDtoList.add(saleorderRequestDto);
@ -833,6 +895,16 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
BdBusitypeEntity bdBusitypeEntity = u8cOperationFlowV2(); BdBusitypeEntity bdBusitypeEntity = u8cOperationFlowV2();
//初始化所有存货管理档案对应的结存价+采购价 //初始化所有存货管理档案对应的结存价+采购价
// List<Map> mapList = initAllBalancePricePurchasePrice(); // List<Map> mapList = initAllBalancePricePurchasePrice();
//查询平台运费平台优惠支付优惠达人优惠存货基本档案注意没有商家优惠
List<BdInvbasdocEntity> bdInvbasdocEntities = queryAdditionUtil.queryStockBasicArchives();
Map<String, BdInvbasdocEntity> mapBdInvbasdocEntity = bdInvbasdocEntities.stream().collect(Collectors.toMap(BdInvbasdocEntity::getInvcode, entity -> entity));
String pkInvbasdocStr = bdInvbasdocEntities.stream().map(entity -> "'" + entity.getInvcode() + "'").collect(Collectors.joining(","));
//查询存货对应的税目
Map<String, BdTaxitemsEntity> stringBdTaxitemsEntityMap = queryAdditionUtil.queryBatchBdTaxitems(pkInvbasdocStr);
//查询平台运费对应的税率
// BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode());
//查询平台运费平台优惠支付优惠达人优惠所有公司的存货管理档案
Map<String, BdInvmandocEntity> stringBdInvmandocEntityMap = queryAdditionUtil.queryInventoryMan(bdInvbasdocEntities);
if (bdBusitypeEntity != null && summaryDimensionMap != null) { if (bdBusitypeEntity != null && summaryDimensionMap != null) {
Iterator<Map.Entry<String, List<GoodsRertunSonDetailsDto>>> iterator = summaryDimensionMap.entrySet().iterator(); Iterator<Map.Entry<String, List<GoodsRertunSonDetailsDto>>> iterator = summaryDimensionMap.entrySet().iterator();
@ -968,28 +1040,78 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
// saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目 // saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目
// saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj()); // saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj());
//如果优惠金额为0则传0 //如果优惠金额为0则传0
if (goodsRertunSonDetailsDto != null && !"0".equals(goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) { if (!"0".equals(goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) {
saleorderRequestChildrenDto.setVdef4("-" + goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString()); saleorderRequestChildrenDto.setVdef4("-" + goodsRertunSonDetailsDto.getVdef4().stripTrailingZeros().toPlainString());
} else { } else {
saleorderRequestChildrenDto.setVdef4("0"); 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()); saleorderRequestChildrenDto.setVdef5("-" + goodsRertunSonDetailsDto.getVdef5().stripTrailingZeros().toPlainString());
} else { } else {
saleorderRequestChildrenDto.setVdef5("0"); 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()); saleorderRequestChildrenDto.setVdef6("-" + goodsRertunSonDetailsDto.getVdef6().stripTrailingZeros().toPlainString());
} else { } else {
saleorderRequestChildrenDto.setVdef6("0"); 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()); saleorderRequestChildrenDto.setVdef7("-" + goodsRertunSonDetailsDto.getVdef7().stripTrailingZeros().toPlainString());
} else { } else {
saleorderRequestChildrenDto.setVdef7("0"); saleorderRequestChildrenDto.setVdef7("0");
} }
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto); 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 //销售订单单据推送到u8c
List<SaleorderRequestDto> saleorderRequestDtoList = new ArrayList<>(); List<SaleorderRequestDto> saleorderRequestDtoList = new ArrayList<>();
saleorderRequestDtoList.add(saleorderRequestDto); saleorderRequestDtoList.add(saleorderRequestDto);
@ -1006,8 +1128,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
csaleid = soSaleResultRootDto.getParentvo().getCsaleid(); csaleid = soSaleResultRootDto.getParentvo().getCsaleid();
} }
logger.info("TOC销售订单编号{} 销售订单主键:{} 销售公司:{}", vreceiptcode, csaleid, pk_corp); logger.info("TOC销售订单编号{} 销售订单主键:{} 销售公司:{}", vreceiptcode, csaleid, pk_corp);
//记录成功 //记录成功updateSuccessOrFail2(oldValue, "Y", "success", vreceiptcode, csaleid);
updateSuccessOrFail2(oldValue, "Y", "success", vreceiptcode, csaleid);
} catch (Exception e) { } catch (Exception e) {
logger.error("TOC退货业务转换成U8C对象过程中、或者单据推送到U8C出现异常", e); logger.error("TOC退货业务转换成U8C对象过程中、或者单据推送到U8C出现异常", e);
//记录失败 //记录失败
@ -1036,6 +1157,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
* @author liuyang * @author liuyang
*/ */
private String createGenerateBusinessDate(StockinOrderSearchResponse.StockinOrder.StockinH header) { private String createGenerateBusinessDate(StockinOrderSearchResponse.StockinOrder.StockinH header) {
//测试
// header.setClosedAt("2024-11-29 10:00:12"); // header.setClosedAt("2024-11-29 10:00:12");
String code = null; String code = null;
if (header != null && header.getCode() != null) { if (header != null && header.getCode() != null) {
@ -1109,6 +1231,17 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
//查询OFS售后入库单对应的售后订单 //查询OFS售后入库单对应的售后订单
List<RerturnGoodsOrderSearchData> rerturnGoodsOrderSearchData = queryBatchAfterSalesOrder(returnGoodHeaderDetailsDataDtoList1); List<RerturnGoodsOrderSearchData> rerturnGoodsOrderSearchData = queryBatchAfterSalesOrder(returnGoodHeaderDetailsDataDtoList1);
findAfterSalesOrder(rerturnGoodsOrderSearchData, returnGoodHeaderDetailsDataDtoList1); findAfterSalesOrder(rerturnGoodsOrderSearchData, returnGoodHeaderDetailsDataDtoList1);
//测试
// RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData2 = rerturnGoodsOrderSearchData.get(0);
// List<RerturnGoodsOrderSearchDetails> 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销售订单 //查询OFS售后订单对应的OFS销售订单
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> headerDetailsDtos = queryBatchOfsOrder(returnGoodHeaderDetailsDataDtoList1); List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> headerDetailsDtos = queryBatchOfsOrder(returnGoodHeaderDetailsDataDtoList1);
findOfsOrder(headerDetailsDtos, returnGoodHeaderDetailsDataDtoList1); findOfsOrder(headerDetailsDtos, returnGoodHeaderDetailsDataDtoList1);
@ -1490,6 +1623,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
* 单价计算公式sum(实付金额/实发数量) 最后除以条数 * 单价计算公式sum(实付金额/实发数量) 最后除以条数
* *
* @param sonDetailsDtoList 汇总过后的售后入库单明细 * @param sonDetailsDtoList 汇总过后的售后入库单明细
* @param isCheckShopChoose true取建议零售价false取实付金额
* @author liuyang * @author liuyang
*/ */
private GoodsRertunSonDetailsDto groupMergeDetailedRows(List<GoodsRertunSonDetailsDto> sonDetailsDtoList, Boolean isCheckShopChoose) throws Exception { private GoodsRertunSonDetailsDto groupMergeDetailedRows(List<GoodsRertunSonDetailsDto> sonDetailsDtoList, Boolean isCheckShopChoose) throws Exception {
@ -1537,6 +1671,9 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
//// goodsRertunSonDetailsDto.setReceivedQty("1"); //// goodsRertunSonDetailsDto.setReceivedQty("1");
// totalAmount = accumulatedDiscounts(goodsRertunSonDetailsDto, rerturnGoodsOrderSearchData, calculationFormulaStr); // totalAmount = accumulatedDiscounts(goodsRertunSonDetailsDto, rerturnGoodsOrderSearchData, calculationFormulaStr);
// } // }
//测试
// goodsRertunSonDetailsDto.setReceivedQty("1");
Assert.notNull(totalAmount, "实退金额不能为空 明细行主键:{}", goodsRertunSonDetailsDto.getId()); Assert.notNull(totalAmount, "实退金额不能为空 明细行主键:{}", goodsRertunSonDetailsDto.getId());
Assert.notNull(goodsRertunSonDetailsDto.getReceivedQty(), "实收数量不能为空 明细行主键:{}", goodsRertunSonDetailsDto.getId()); Assert.notNull(goodsRertunSonDetailsDto.getReceivedQty(), "实收数量不能为空 明细行主键:{}", goodsRertunSonDetailsDto.getId());
@ -1548,6 +1685,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
goodsRertunSonDetailsDto.setCalculateAccountsReceivable(totalAmount); goodsRertunSonDetailsDto.setCalculateAccountsReceivable(totalAmount);
goodsRertunSonDetailsDto.setCalculationFormula(calculationFormulaStr.toString()); goodsRertunSonDetailsDto.setCalculationFormula(calculationFormulaStr.toString());
goodsRertunSonDetailsDto.setPlatformDiscounts(ofsOrderDetail.getPlatformDiscounts()); goodsRertunSonDetailsDto.setPlatformDiscounts(ofsOrderDetail.getPlatformDiscounts());
goodsRertunSonDetailsDto.setMerchantDiscounts(ofsOrderDetail.getMerchantDiscounts()); goodsRertunSonDetailsDto.setMerchantDiscounts(ofsOrderDetail.getMerchantDiscounts());
goodsRertunSonDetailsDto.setExpertDiscounts(ofsOrderDetail.getExpertDiscounts()); goodsRertunSonDetailsDto.setExpertDiscounts(ofsOrderDetail.getExpertDiscounts());
@ -2679,6 +2817,9 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
Assert.notNull(requestQty, "售后订单:{} 存货明细行:{} 请求数量不能为空!", header.getCode(), targetDetails.getSkuCode()); Assert.notNull(requestQty, "售后订单:{} 存货明细行:{} 请求数量不能为空!", header.getCode(), targetDetails.getSkuCode());
Assert.state(!"".equals(requestQty), "售后订单:{} 存货明细行:{} 请求数量不能为空!", header.getCode(), targetDetails.getSkuCode()); Assert.state(!"".equals(requestQty), "售后订单:{} 存货明细行:{} 请求数量不能为空!", header.getCode(), targetDetails.getSkuCode());
//测试
// goodsRertunSonDetailsDto.setReceivedQty("1");
String receivedQty = goodsRertunSonDetailsDto.getReceivedQty(); String receivedQty = goodsRertunSonDetailsDto.getReceivedQty();
Assert.notNull(receivedQty, "售后订单:{} 存货明细行:{} 请求数量不能为空!", header1.getCode(), goodsRertunSonDetailsDto.getId()); Assert.notNull(receivedQty, "售后订单:{} 存货明细行:{} 请求数量不能为空!", header1.getCode(), goodsRertunSonDetailsDto.getId());
Assert.state(!"".equals(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); String format = StrUtil.format("{}/{}*{}", totalAmount, requestQty, receivedQty);
calculationFormulaStr.append(format); calculationFormulaStr.append(format);
//商家优惠不处理仅保存 // //商家优惠不处理仅保存
String merchantDiscounts = targetDetails.getMerchantDiscounts(); // String merchantDiscounts = targetDetails.getMerchantDiscounts();
//达人优惠 // //达人优惠
String expertDiscounts = targetDetails.getExpertDiscounts(); // String expertDiscounts = targetDetails.getExpertDiscounts();
//支付优惠 // //支付优惠
String payDiscounts = targetDetails.getPayDiscounts(); // String payDiscounts = targetDetails.getPayDiscounts();
//平台优惠 // //平台优惠
String platformDiscounts = targetDetails.getPlatformDiscounts(); // String platformDiscounts = targetDetails.getPlatformDiscounts();
//
BigDecimal totalBigDecimal = new BigDecimal("0");//相加总和 // BigDecimal totalBigDecimal = new BigDecimal("0");//相加总和
BigDecimal totalPayAmountBigDecimal = new BigDecimal("0");//实退金额 // BigDecimal totalPayAmountBigDecimal = new BigDecimal("0");//实退金额
BigDecimal expertDiscountsBigDecimal = new BigDecimal("0");//达人优惠 // BigDecimal expertDiscountsBigDecimal = new BigDecimal("0");//达人优惠
BigDecimal payDiscountsBigDecimal = new BigDecimal("0");//支付优惠 // BigDecimal payDiscountsBigDecimal = new BigDecimal("0");//支付优惠
BigDecimal platformDiscountsBigDecimal = new BigDecimal("0");//平台优惠 // BigDecimal platformDiscountsBigDecimal = new BigDecimal("0");//平台优惠
//
if (actualRefundAmount != null) { // if (actualRefundAmount != null) {
totalPayAmountBigDecimal = actualRefundAmount; // totalPayAmountBigDecimal = actualRefundAmount;
} // }
if (expertDiscounts != null && !"".equals(expertDiscounts)) { // if (expertDiscounts != null && !"".equals(expertDiscounts)) {
expertDiscountsBigDecimal = new BigDecimal(expertDiscounts); // expertDiscountsBigDecimal = new BigDecimal(expertDiscounts);
} // }
if (payDiscounts != null && !"".equals(payDiscounts)) { // if (payDiscounts != null && !"".equals(payDiscounts)) {
payDiscountsBigDecimal = new BigDecimal(payDiscounts); // payDiscountsBigDecimal = new BigDecimal(payDiscounts);
} // }
if (platformDiscounts != null && !"".equals(platformDiscounts)) { // if (platformDiscounts != null && !"".equals(platformDiscounts)) {
platformDiscountsBigDecimal = new BigDecimal(platformDiscounts); // platformDiscountsBigDecimal = new BigDecimal(platformDiscounts);
} // }
//
//总和累加 // //总和累加
totalBigDecimal = totalBigDecimal.add(totalPayAmountBigDecimal); // totalBigDecimal = totalBigDecimal.add(totalPayAmountBigDecimal);
totalBigDecimal = totalBigDecimal.add(expertDiscountsBigDecimal); // totalBigDecimal = totalBigDecimal.add(expertDiscountsBigDecimal);
totalBigDecimal = totalBigDecimal.add(payDiscountsBigDecimal); // totalBigDecimal = totalBigDecimal.add(payDiscountsBigDecimal);
totalBigDecimal = totalBigDecimal.add(platformDiscountsBigDecimal); // totalBigDecimal = totalBigDecimal.add(platformDiscountsBigDecimal);
return totalBigDecimal.stripTrailingZeros().toPlainString(); // return totalBigDecimal.stripTrailingZeros().toPlainString();
return actualRefundAmount.stripTrailingZeros().toPlainString();
} }
/** /**
@ -2736,7 +2878,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
* @param sonDetailsDtoList OFS售后入库单明细行List集合(按纬度汇总好的) * @param sonDetailsDtoList OFS售后入库单明细行List集合(按纬度汇总好的)
* @author liuyang * @author liuyang
*/ */
private void accumulatedDiscountAmountDef(List<GoodsRertunSonDetailsDto> sonDetailsDtoList) { private void accumulatedDiscountAmountDef(List<GoodsRertunSonDetailsDto> sonDetailsDtoList) throws Exception {
Assert.notNull(sonDetailsDtoList, "sonDetailsDtoList不能为空"); Assert.notNull(sonDetailsDtoList, "sonDetailsDtoList不能为空");
if (sonDetailsDtoList.size() > 0) { if (sonDetailsDtoList.size() > 0) {

View File

@ -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;
/**
* @Authorliuyang
* @Packagecom.hzya.frame.plugin.lets.util
* @ProjectkangarooDataCenterV3
* @nameQueryAdditionUtil
* @Date2024/12/4 15:12
* @FilenameQueryAdditionUtil
*/
@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<BdInvbasdocEntity> queryStockBasicArchives() throws Exception {
String invcodes = "'FY05','FY02','FY04','FY01'";
BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity();
bdInvbasdocEntity.setInvcodes(invcodes);
bdInvbasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
List<BdInvbasdocEntity> 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<String, BdTaxitemsEntity> queryBatchBdTaxitems(String invcode) throws Exception {
Assert.notNull(invcode, "存货编码不能为空");
BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity();
bdTaxitemsEntity.setInvcodes(invcode);
List<BdTaxitemsEntity> 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为公司idvalue为存货管理档案对象
*
* @param bdInvbasdocEntities 存货基本档案
* @author liuyang
*/
public Map<String, BdInvmandocEntity> queryInventoryMan(List<BdInvbasdocEntity> bdInvbasdocEntities) throws Exception {
Assert.notNull(bdInvbasdocEntities, "pk_invbasdoc不能为空");
Map<String, BdInvmandocEntity> 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<BdInvmandocEntity> 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<SaleorderRequestChildrenDto> 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);
}
}
}

View File

@ -31,7 +31,7 @@ public class SoSaleReturnPluginInitializerToCTest {
// soSaleReturnPluginInitializerToC.startImplement(null, null); // soSaleReturnPluginInitializerToC.startImplement(null, null);
try { try {
String code = "LETS-RE2024112900000001"; String code = "LETS-RE2024112900000001";
soSaleReturnPluginInitializerToC.startImplementByCode(code, "stock"); soSaleReturnPluginInitializerToC.startImplementByCode(code, "tran");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }