refactor(sales): 重构销售出库单优惠金额计算逻辑- 修改了优惠金额的计算方式,将实付金额与各种优惠金额分开处理
- 优化了代码结构,提高了可读性和可维护性 - 调整了部分变量类型,以适应新的计算逻辑 - 移除了不必要的注释和测试代码
This commit is contained in:
parent
3c1b94091a
commit
224ab57805
|
@ -968,6 +968,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
BigDecimal noriginalcursummny = null;//价税合计
|
||||
BigDecimal noriginalcurtaxmny = null;//税额
|
||||
try {
|
||||
//汇总好的金额/汇总好的实出数量
|
||||
noriginalcurtaxprice = sonDetailsDto.getGroupTotalPayAmount().divide(sonDetailsDto.getGroupShipQty(), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
|
||||
noriginalcurprice = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
|
||||
noriginalcurmny = noriginalcurprice.multiply(sonDetailsDto.getGroupShipQty()).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
|
@ -1013,23 +1014,23 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
// saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目
|
||||
// saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj());
|
||||
//如果优惠金额为0,则传0
|
||||
if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef4(sonDetailsDto.getVdef4().stripTrailingZeros().toPlainString());
|
||||
if (sonDetailsDto != null && sonDetailsDto.getVdef4() != null) {
|
||||
saleorderRequestChildrenDto.setVdef4(new BigDecimal(sonDetailsDto.getVdef4()).stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef4("0");
|
||||
}
|
||||
if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef5().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef5(sonDetailsDto.getVdef5().stripTrailingZeros().toPlainString());
|
||||
if (sonDetailsDto != null && sonDetailsDto.getVdef5() != null) {
|
||||
saleorderRequestChildrenDto.setVdef5(new BigDecimal(sonDetailsDto.getVdef5()).stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef5("0");
|
||||
}
|
||||
if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef6().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef6(sonDetailsDto.getVdef6().stripTrailingZeros().toPlainString());
|
||||
if (sonDetailsDto != null && sonDetailsDto.getVdef6() != null) {
|
||||
saleorderRequestChildrenDto.setVdef6(new BigDecimal(sonDetailsDto.getVdef6()).stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef6("0");
|
||||
}
|
||||
if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef7().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef7(sonDetailsDto.getVdef7().stripTrailingZeros().toPlainString());
|
||||
if (sonDetailsDto != null && sonDetailsDto.getVdef7() != null) {
|
||||
saleorderRequestChildrenDto.setVdef7(new BigDecimal(sonDetailsDto.getVdef7()).stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef7("0");
|
||||
}
|
||||
|
@ -1037,8 +1038,6 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
|
||||
//判断是否增加邮费这个存货,accumulatedPostage
|
||||
BigDecimal accumulatedPostage = checkPostageFee(oldValue);
|
||||
//测试:测试
|
||||
accumulatedPostage = new BigDecimal("6");
|
||||
if (accumulatedPostage != null && accumulatedPostage.compareTo(BigDecimal.ZERO) > 0) {
|
||||
//获取「平台运维」对应的税率
|
||||
String tax2 = new BigDecimal(bdTaxitemsEntity.getTaxratio()).divide(new BigDecimal(100), 20, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString();
|
||||
|
@ -1219,7 +1218,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> headerDetailsDtos = queryOfsOrder(headerDetailsDtoList);
|
||||
findMatchingOfsOrder(headerDetailsDtos, headerDetailsDtoList);
|
||||
//计算OFS销售订单优惠金额分摊到明细行
|
||||
ofsOrderSaleAmountAllocationUtil.batchTocSalesAmountAllocation(headerDetailsDtos);
|
||||
// ofsOrderSaleAmountAllocationUtil.batchTocSalesAmountAllocation(headerDetailsDtos);
|
||||
//计算OFS销售订单邮费分摊
|
||||
ofsOrderSalePostageFeeAllocationUtil.batchTocSalesPostageFeeAllocation(headerDetailsDtos);
|
||||
//初始化公司档案对照关系
|
||||
|
@ -1684,23 +1683,26 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
|
||||
for (int i = 0; i < sonDetailsDtoList.size(); i++) {
|
||||
SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(i);
|
||||
HeaderDto header = sonDetailsDto.getHeader();
|
||||
BdInvmandocEntity bdInvmandocEntity = sonDetailsDto.getBdInvmandocEntity();
|
||||
HeaderDto header = sonDetailsDto.getHeader();//销售出库单表头
|
||||
BdInvmandocEntity bdInvmandocEntity = sonDetailsDto.getBdInvmandocEntity();//存货管理档案
|
||||
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = sonDetailsDto.getHeaderDetailsDto();//OFS销售订单
|
||||
//实付金额/实发数量
|
||||
//OFS销售订单实付金额:totalPayAmount
|
||||
//OFS销售出库单实付金额:totalPayAmount
|
||||
//是一样的字段,目前暂时取销售出库单对应的totalPayAmount
|
||||
String totalPayAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, sonDetailsDto, mapList);
|
||||
if (totalPayAmount == null) {
|
||||
//触发取实付金额的逻辑,因此需要累加:O实付金额+O达人优惠+O支付优惠+O平台优惠
|
||||
//取O实付金额
|
||||
totalPayAmount = sonDetailsDto.getTotalPayAmount();
|
||||
// totalPayAmount = sonDetailsDto.getTotalPayAmount();
|
||||
totalPayAmount = accumulatedDiscounts(sonDetailsDto, headerDetailsDto);
|
||||
} else {
|
||||
//取结存单价、或者采购单价
|
||||
BigDecimal totalPayAmountBigDecimal = new BigDecimal(totalPayAmount);
|
||||
totalPayAmount = totalPayAmountBigDecimal.multiply(new BigDecimal(sonDetailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString();
|
||||
}
|
||||
Assert.notNull(totalPayAmount, "实付金额不能为空 明细行对象:{}", JSON.toJSONString(sonDetailsDto));
|
||||
Assert.notNull(sonDetailsDto.getShipQty(), "实发数量不能为空 明细行对象:{}", JSON.toJSONString(sonDetailsDto));
|
||||
Assert.notNull(totalPayAmount, "实发数量不能为空 销售出库单编码:{} 出库单明细主键:{}", header.getCode(), sonDetailsDto.getId());
|
||||
Assert.notNull(sonDetailsDto.getShipQty(), "实发数量不能为空 销售出库单编码:{} 出库单明细主键:{}", header.getCode(), sonDetailsDto.getId());
|
||||
BigDecimal totalPayAmountBigDecimal = new BigDecimal(sonDetailsDto.getTotalPayAmount());
|
||||
BigDecimal shipQtyBigDecimal = new BigDecimal(sonDetailsDto.getShipQty());
|
||||
|
||||
|
@ -1708,11 +1710,12 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
groupShipQty = groupShipQty.add(shipQtyBigDecimal);
|
||||
}
|
||||
SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(0);
|
||||
sonDetailsDto.setGroupShipQty(groupShipQty);
|
||||
sonDetailsDto.setGroupTotalPayAmount(groupTotalPayAmount);
|
||||
sonDetailsDto.setGroupShipQty(groupShipQty);//汇总好的实发数量
|
||||
sonDetailsDto.setGroupTotalPayAmount(groupTotalPayAmount);//汇总总金额
|
||||
|
||||
//累加4个优惠金额,放在第0号元素
|
||||
accumulationDiscountAmount(sonDetailsDtoList);
|
||||
// accumulationDiscountAmount(sonDetailsDtoList);
|
||||
accumulatedDiscountAmountDef(sonDetailsDtoList);
|
||||
|
||||
//累加各类优惠
|
||||
logger.info("{}个明细行发生了合并!", sonDetailsDtoList.size());
|
||||
|
@ -2004,23 +2007,23 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
// saleorderRequestChildrenDto.setVdef2(bdCostsubjEntity.getCostname());//收支项目
|
||||
// saleorderRequestChildrenDto.setPk_defdoc2(bdCostsubjEntity.getPkCostsubj());
|
||||
//如果优惠金额为0,则传0
|
||||
if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef4("-" + sonDetailsDto.getVdef4().stripTrailingZeros().toPlainString());
|
||||
if (sonDetailsDto != null && sonDetailsDto.getVdef4() != null) {
|
||||
saleorderRequestChildrenDto.setVdef4("-" + new BigDecimal(sonDetailsDto.getVdef4()).stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef4("0");
|
||||
}
|
||||
if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef5().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef5("-" + sonDetailsDto.getVdef5().stripTrailingZeros().toPlainString());
|
||||
if (sonDetailsDto != null && sonDetailsDto.getVdef5() != null) {
|
||||
saleorderRequestChildrenDto.setVdef5("-" + new BigDecimal(sonDetailsDto.getVdef5()).stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef5("0");
|
||||
}
|
||||
if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef6().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef6("-" + sonDetailsDto.getVdef6().stripTrailingZeros().toPlainString());
|
||||
if (sonDetailsDto != null && sonDetailsDto.getVdef6() != null) {
|
||||
saleorderRequestChildrenDto.setVdef6("-" + new BigDecimal(sonDetailsDto.getVdef6()).stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef6("0");
|
||||
}
|
||||
if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef7().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef7("-" + sonDetailsDto.getVdef7().stripTrailingZeros().toPlainString());
|
||||
if (sonDetailsDto != null && sonDetailsDto.getVdef7() != null) {
|
||||
saleorderRequestChildrenDto.setVdef7("-" + new BigDecimal(sonDetailsDto.getVdef7()).stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef7("0");
|
||||
}
|
||||
|
@ -2028,8 +2031,6 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
|
||||
//判断是否增加邮费这个存货,accumulatedPostage
|
||||
BigDecimal accumulatedPostage = checkPostageFee(oldValue);
|
||||
//测试
|
||||
// accumulatedPostage = new BigDecimal("6");
|
||||
if (accumulatedPostage != null && accumulatedPostage.compareTo(BigDecimal.ZERO) > 0) {
|
||||
//获取「平台运维」对应的税率
|
||||
String tax2 = "0." + new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString();
|
||||
|
@ -2209,23 +2210,23 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
// saleorderRequestChildrenDto.setCreccalbodyid(bdCalbodyEntity1.getPkCalbody());//收货库存组织:2024年8月7日 16:21:48 和佳妮、道品一起测试,收货库存组织、收货仓库 是不需要传递的
|
||||
// saleorderRequestChildrenDto.setCrecwareid(bdStordocEntity1.getPkStordoc());//收货仓库
|
||||
//如果优惠金额为0,则传0
|
||||
if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef4().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef4(sonDetailsDto.getVdef4().stripTrailingZeros().toPlainString());
|
||||
if (sonDetailsDto != null && sonDetailsDto.getVdef4() != null) {
|
||||
saleorderRequestChildrenDto.setVdef4(new BigDecimal(sonDetailsDto.getVdef4()).stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef4("0");
|
||||
}
|
||||
if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef5().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef5(sonDetailsDto.getVdef5().stripTrailingZeros().toPlainString());
|
||||
if (sonDetailsDto != null && sonDetailsDto.getVdef5() != null) {
|
||||
saleorderRequestChildrenDto.setVdef5(new BigDecimal(sonDetailsDto.getVdef5()).stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef5("0");
|
||||
}
|
||||
if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef6().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef6(sonDetailsDto.getVdef6().stripTrailingZeros().toPlainString());
|
||||
if (sonDetailsDto != null && sonDetailsDto.getVdef6() != null) {
|
||||
saleorderRequestChildrenDto.setVdef6(new BigDecimal(sonDetailsDto.getVdef6()).stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef6("0");
|
||||
}
|
||||
if (sonDetailsDto != null && !"0".equals(sonDetailsDto.getVdef7().stripTrailingZeros().toPlainString())) {
|
||||
saleorderRequestChildrenDto.setVdef7(sonDetailsDto.getVdef7().stripTrailingZeros().toPlainString());
|
||||
if (sonDetailsDto != null && sonDetailsDto.getVdef7() != null) {
|
||||
saleorderRequestChildrenDto.setVdef7(new BigDecimal(sonDetailsDto.getVdef7()).stripTrailingZeros().toPlainString());
|
||||
} else {
|
||||
saleorderRequestChildrenDto.setVdef7("0");
|
||||
}
|
||||
|
@ -2233,8 +2234,6 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
|
||||
//判断是否增加邮费这个存货,accumulatedPostage
|
||||
BigDecimal accumulatedPostage = checkPostageFee(oldValue);
|
||||
//测试
|
||||
// accumulatedPostage = new BigDecimal("6");
|
||||
if (accumulatedPostage != null && accumulatedPostage.compareTo(BigDecimal.ZERO) > 0) {
|
||||
//获取「平台运维」对应的税率
|
||||
String tax2 = "0." + new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString();
|
||||
|
@ -2932,52 +2931,52 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private void accumulationDiscountAmount(List<SonDetailsDto> sonDetailsDtoList) throws Exception {
|
||||
Assert.notNull(sonDetailsDtoList, "sonDetailsDtoList不能为空");
|
||||
|
||||
if (sonDetailsDtoList.size() > 0) {
|
||||
BigDecimal totalShareTargetPlatformDiscounts = new BigDecimal("0");
|
||||
BigDecimal totalShareTargetMerchantDiscounts = new BigDecimal("0");
|
||||
BigDecimal totalShareTargetExpertDiscounts = new BigDecimal("0");
|
||||
BigDecimal totalShareTargetPayDiscounts = new BigDecimal("0");
|
||||
|
||||
for (int i = 0; i < sonDetailsDtoList.size(); i++) {
|
||||
SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(i);
|
||||
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = sonDetailsDto.getHeaderDetailsDto();
|
||||
Assert.notNull(headerDetailsDto, "无法关联到OFS销售订单 销售订单号:{}", sonDetailsDto.getRefOrderCode());
|
||||
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header = headerDetailsDto.getHeader();
|
||||
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto> details = headerDetailsDto.getDetails();
|
||||
|
||||
//四舍五入保留2位
|
||||
com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto ofsOrderDetail = findOfsOrderDetail(details, sonDetailsDto);
|
||||
if (ofsOrderDetail.getShareTargetPlatformDiscounts() != null) {
|
||||
totalShareTargetPlatformDiscounts = totalShareTargetPlatformDiscounts.add(ofsOrderDetail.getShareTargetPlatformDiscounts());
|
||||
}
|
||||
if (ofsOrderDetail.getShareTargetMerchantDiscounts() != null) {
|
||||
totalShareTargetMerchantDiscounts = totalShareTargetMerchantDiscounts.add(ofsOrderDetail.getShareTargetMerchantDiscounts());
|
||||
}
|
||||
if (ofsOrderDetail.getShareTargetExpertDiscounts() != null) {
|
||||
totalShareTargetExpertDiscounts = totalShareTargetExpertDiscounts.add(ofsOrderDetail.getShareTargetExpertDiscounts());
|
||||
}
|
||||
if (ofsOrderDetail.getShareTargetPayDiscounts() != null) {
|
||||
totalShareTargetPayDiscounts = totalShareTargetPayDiscounts.add(ofsOrderDetail.getShareTargetPayDiscounts());
|
||||
}
|
||||
// logger.info("对应的销售订单明细行主键:{}", ofsOrderDetail.getId());
|
||||
}
|
||||
|
||||
SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(0);
|
||||
HeaderDto header = sonDetailsDto.getHeader();
|
||||
|
||||
sonDetailsDto.setVdef4(totalShareTargetPlatformDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
sonDetailsDto.setVdef5(totalShareTargetMerchantDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
sonDetailsDto.setVdef6(totalShareTargetExpertDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
sonDetailsDto.setVdef7(totalShareTargetPayDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
|
||||
logger.info("出库单明细主键:{} 出库单号:{} 最终汇总好的平台优惠:{}、支付优惠:{}、达人优惠:{}、商家优惠:{}", sonDetailsDto.getId(), header.getCode(), sonDetailsDto.getVdef4(), sonDetailsDto.getVdef5(), sonDetailsDto.getVdef6(), sonDetailsDto.getVdef7());
|
||||
} else {
|
||||
logger.info("accumulationDiscountAmount方法对应的sonDetailsDtoList.size为零!");
|
||||
}
|
||||
}
|
||||
// private void accumulationDiscountAmount(List<SonDetailsDto> sonDetailsDtoList) throws Exception {
|
||||
// Assert.notNull(sonDetailsDtoList, "sonDetailsDtoList不能为空");
|
||||
//
|
||||
// if (sonDetailsDtoList.size() > 0) {
|
||||
// BigDecimal totalShareTargetPlatformDiscounts = new BigDecimal("0");
|
||||
// BigDecimal totalShareTargetMerchantDiscounts = new BigDecimal("0");
|
||||
// BigDecimal totalShareTargetExpertDiscounts = new BigDecimal("0");
|
||||
// BigDecimal totalShareTargetPayDiscounts = new BigDecimal("0");
|
||||
//
|
||||
// for (int i = 0; i < sonDetailsDtoList.size(); i++) {
|
||||
// SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(i);
|
||||
// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = sonDetailsDto.getHeaderDetailsDto();
|
||||
// Assert.notNull(headerDetailsDto, "无法关联到OFS销售订单 销售订单号:{}", sonDetailsDto.getRefOrderCode());
|
||||
// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header = headerDetailsDto.getHeader();
|
||||
// List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto> details = headerDetailsDto.getDetails();
|
||||
//
|
||||
// //四舍五入保留2位
|
||||
// com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto ofsOrderDetail = findOfsOrderDetail(details, sonDetailsDto);
|
||||
// if (ofsOrderDetail.getShareTargetPlatformDiscounts() != null) {
|
||||
// totalShareTargetPlatformDiscounts = totalShareTargetPlatformDiscounts.add(ofsOrderDetail.getShareTargetPlatformDiscounts());
|
||||
// }
|
||||
// if (ofsOrderDetail.getShareTargetMerchantDiscounts() != null) {
|
||||
// totalShareTargetMerchantDiscounts = totalShareTargetMerchantDiscounts.add(ofsOrderDetail.getShareTargetMerchantDiscounts());
|
||||
// }
|
||||
// if (ofsOrderDetail.getShareTargetExpertDiscounts() != null) {
|
||||
// totalShareTargetExpertDiscounts = totalShareTargetExpertDiscounts.add(ofsOrderDetail.getShareTargetExpertDiscounts());
|
||||
// }
|
||||
// if (ofsOrderDetail.getShareTargetPayDiscounts() != null) {
|
||||
// totalShareTargetPayDiscounts = totalShareTargetPayDiscounts.add(ofsOrderDetail.getShareTargetPayDiscounts());
|
||||
// }
|
||||
//// logger.info("对应的销售订单明细行主键:{}", ofsOrderDetail.getId());
|
||||
// }
|
||||
//
|
||||
// SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(0);
|
||||
// HeaderDto header = sonDetailsDto.getHeader();
|
||||
//
|
||||
// sonDetailsDto.setVdef4(totalShareTargetPlatformDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
// sonDetailsDto.setVdef5(totalShareTargetMerchantDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
// sonDetailsDto.setVdef6(totalShareTargetExpertDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
// sonDetailsDto.setVdef7(totalShareTargetPayDiscounts.setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
//
|
||||
// logger.info("出库单明细主键:{} 出库单号:{} 最终汇总好的平台优惠:{}、支付优惠:{}、达人优惠:{}、商家优惠:{}", sonDetailsDto.getId(), header.getCode(), sonDetailsDto.getVdef4(), sonDetailsDto.getVdef5(), sonDetailsDto.getVdef6(), sonDetailsDto.getVdef7());
|
||||
// } else {
|
||||
// logger.info("accumulationDiscountAmount方法对应的sonDetailsDtoList.size为零!");
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 根据OFS销售出库单明细行,查找OFS销售订单明细行
|
||||
|
@ -3283,4 +3282,133 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
}
|
||||
return bdTaxitemsEntityList.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 累加应收金额=实付金额+达人优惠+支付优惠+平台优惠
|
||||
*
|
||||
* @param sonDetailsDto OFS销售出库单明细行
|
||||
* @param headerDetailsDto OFS销售订单表头对象
|
||||
*/
|
||||
private String accumulatedDiscounts(SonDetailsDto sonDetailsDto, com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto) throws Exception {
|
||||
Assert.notNull(sonDetailsDto, "sonDetailsDto OFS销售出库单明细不能为空!");
|
||||
Assert.notNull(headerDetailsDto, "headerDetailsDto OFS销售订单不能为空!");
|
||||
|
||||
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header = headerDetailsDto.getHeader();
|
||||
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto> details = headerDetailsDto.getDetails();
|
||||
|
||||
//根据出库单明细匹配销售订单明细行
|
||||
com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto targetDetails = null;
|
||||
for (int i = 0; i < details.size(); i++) {
|
||||
com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto detailsDto = details.get(i);
|
||||
if (detailsDto.getId() != null && sonDetailsDto.getRefOrderDetailId() != null) {
|
||||
if (detailsDto.getId().equals(sonDetailsDto.getRefOrderDetailId())) {
|
||||
targetDetails = detailsDto;
|
||||
}
|
||||
}
|
||||
}
|
||||
Assert.notNull(targetDetails, "根据销售出库单明细行(refOrderDetailId)无法匹配销售订单明细行", sonDetailsDto.getRefOrderDetailId());
|
||||
|
||||
//实付金额
|
||||
String totalPayAmount = sonDetailsDto.getTotalPayAmount();
|
||||
//商家优惠:不处理!!!仅保存
|
||||
String merchantDiscounts = targetDetails.getMerchantDiscounts();
|
||||
//达人优惠
|
||||
String expertDiscounts = targetDetails.getExpertDiscounts();
|
||||
//支付优惠
|
||||
String payDiscounts = targetDetails.getPayDiscounts();
|
||||
//平台优惠
|
||||
String platformDiscounts = targetDetails.getPlatformDiscounts();
|
||||
|
||||
// sonDetailsDto.setVdef4(platformDiscounts);
|
||||
// sonDetailsDto.setVdef5(payDiscounts);
|
||||
// sonDetailsDto.setVdef6(expertDiscounts);
|
||||
// sonDetailsDto.setVdef7(merchantDiscounts);
|
||||
|
||||
BigDecimal totalBigDecimal = new BigDecimal("0");
|
||||
BigDecimal totalPayAmountBigDecimal = new BigDecimal("0");
|
||||
BigDecimal expertDiscountsBigDecimal = new BigDecimal("0");
|
||||
BigDecimal payDiscountsBigDecimal = new BigDecimal("0");
|
||||
BigDecimal platformDiscountsBigDecimal = new BigDecimal("0");
|
||||
|
||||
if (totalPayAmount != null && !"".equals(totalPayAmount)) {
|
||||
totalPayAmountBigDecimal = new BigDecimal(totalPayAmount);
|
||||
}
|
||||
if (expertDiscounts != null && !"".equals(expertDiscounts)) {
|
||||
expertDiscountsBigDecimal = new BigDecimal(expertDiscounts);
|
||||
}
|
||||
if (payDiscounts != null && !"".equals(payDiscounts)) {
|
||||
payDiscountsBigDecimal = new BigDecimal(payDiscounts);
|
||||
}
|
||||
if (platformDiscounts != null && !"".equals(platformDiscounts)) {
|
||||
platformDiscountsBigDecimal = new BigDecimal(platformDiscounts);
|
||||
}
|
||||
|
||||
//总合
|
||||
totalBigDecimal = totalBigDecimal.add(totalPayAmountBigDecimal);
|
||||
totalBigDecimal = totalBigDecimal.add(expertDiscountsBigDecimal);
|
||||
totalBigDecimal = totalBigDecimal.add(payDiscountsBigDecimal);
|
||||
totalBigDecimal = totalBigDecimal.add(platformDiscountsBigDecimal);
|
||||
return totalBigDecimal.stripTrailingZeros().toPlainString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 累加优惠金额,放在自定义项里
|
||||
*
|
||||
* @param sonDetailsDtoList OFS销售出库单明细行(按纬度汇总好的)
|
||||
* @author liuyang
|
||||
*/
|
||||
private void accumulatedDiscountAmountDef(List<SonDetailsDto> sonDetailsDtoList) {
|
||||
Assert.notNull(sonDetailsDtoList, "sonDetailsDtoList不能为空");
|
||||
|
||||
if (sonDetailsDtoList.size() > 0) {
|
||||
BigDecimal platformDiscountsBigDecimal = new BigDecimal("0");//平台
|
||||
BigDecimal merchantDiscountsBigDecimal = new BigDecimal("0");//商家
|
||||
BigDecimal expertDiscountsBigDecimal = new BigDecimal("0");//达人
|
||||
BigDecimal payDiscountsBigDecimal = new BigDecimal("0");//支付
|
||||
for (int i = 0; i < sonDetailsDtoList.size(); i++) {
|
||||
SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(i);
|
||||
HeaderDto header = sonDetailsDto.getHeader();
|
||||
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = sonDetailsDto.getHeaderDetailsDto();//OFS销售订单号
|
||||
Assert.notNull(headerDetailsDto, "O出库单对应的销售订单不能为空 O出库单编码:{}", header.getCode());
|
||||
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto> details = headerDetailsDto.getDetails();//OFS销售订单明细行
|
||||
if (details != null && details.size() > 0) {
|
||||
for (int j = 0; j < details.size(); j++) {
|
||||
com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto detailsDto = details.get(j);
|
||||
if (sonDetailsDto.getRefOrderDetailId() != null && detailsDto.getId() != null) {
|
||||
if (sonDetailsDto.getRefOrderDetailId().equals(detailsDto.getId())) {
|
||||
//累加优惠
|
||||
String platformDiscounts = detailsDto.getPlatformDiscounts();
|
||||
String merchantDiscounts = detailsDto.getMerchantDiscounts();
|
||||
String expertDiscounts = detailsDto.getExpertDiscounts();
|
||||
String payDiscounts = detailsDto.getPayDiscounts();
|
||||
|
||||
if (platformDiscounts == null || "".equals(platformDiscounts.trim())) {
|
||||
platformDiscounts = "0";
|
||||
}
|
||||
if (merchantDiscounts == null || "".equals(merchantDiscounts.trim())) {
|
||||
merchantDiscounts = "0";
|
||||
}
|
||||
if (expertDiscounts == null || "".equals(expertDiscounts.trim())) {
|
||||
expertDiscounts = "0";
|
||||
}
|
||||
if (payDiscounts == null || "".equals(payDiscounts.trim())) {
|
||||
payDiscounts = "0";
|
||||
}
|
||||
|
||||
platformDiscountsBigDecimal = platformDiscountsBigDecimal.add(new BigDecimal(platformDiscounts));
|
||||
merchantDiscountsBigDecimal = merchantDiscountsBigDecimal.add(new BigDecimal(merchantDiscounts));
|
||||
expertDiscountsBigDecimal = expertDiscountsBigDecimal.add(new BigDecimal(expertDiscounts));
|
||||
payDiscountsBigDecimal = payDiscountsBigDecimal.add(new BigDecimal(payDiscounts));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sonDetailsDtoList.get(0).setVdef4(platformDiscountsBigDecimal.stripTrailingZeros().toPlainString());
|
||||
sonDetailsDtoList.get(0).setVdef5(payDiscountsBigDecimal.stripTrailingZeros().toPlainString());
|
||||
sonDetailsDtoList.get(0).setVdef6(expertDiscountsBigDecimal.stripTrailingZeros().toPlainString());
|
||||
sonDetailsDtoList.get(0).setVdef7(merchantDiscountsBigDecimal.stripTrailingZeros().toPlainString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -81,14 +81,18 @@ public class SonDetailsDto extends DetailsDto {
|
|||
private com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto;
|
||||
|
||||
//累加平台优惠
|
||||
private BigDecimal vdef4;
|
||||
//改为原始平台优惠
|
||||
private String vdef4;
|
||||
|
||||
//累加支付优惠
|
||||
private BigDecimal vdef5;
|
||||
//改为原始支付优惠
|
||||
private String vdef5;
|
||||
|
||||
//累加达人优惠
|
||||
private BigDecimal vdef6;
|
||||
//改为原始达人优惠
|
||||
private String vdef6;
|
||||
|
||||
//累加商家优惠
|
||||
private BigDecimal vdef7;
|
||||
//改为原始商家优惠
|
||||
private String vdef7;
|
||||
}
|
|
@ -112,11 +112,17 @@ class SoSaleOutPluginInitializerToCTest {
|
|||
// String aaa = "LETS-SH2024102900016893";
|
||||
// soSaleOutPluginInitializerToC.startImplementStockByCode(aaa, "tran");
|
||||
|
||||
soSaleOutPluginInitializerToC.startImplementStockByTime("2024-10-30 00:00:00", "2024-10-30 23:59:59");
|
||||
// soSaleOutPluginInitializerToC.startImplementStockByTime("2024-10-30 00:00:00", "2024-10-30 23:59:59");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// soSaleOutPluginInitializerToC.sendU8CTOCOrder("123446");
|
||||
|
||||
try {
|
||||
soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024102600009446", "stock");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -69,7 +69,7 @@ public class QueryU8CEntityUtilTest {
|
|||
@Test
|
||||
public void testGetFuzzyQueryCustomers() {
|
||||
try {
|
||||
String aaa = "188";
|
||||
String aaa = "9279";
|
||||
queryU8CEntityUtil.getFuzzyQueryCustomers(aaa);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -91,4 +91,16 @@ public class DetailsDto {
|
|||
//实际运费分摊金额
|
||||
private BigDecimal shareTargetFreightDiscounts;
|
||||
//邮费分摊end------------––-------
|
||||
|
||||
|
||||
//销售订单明细行优惠金额start------------––-----
|
||||
//平台优惠
|
||||
private String platformDiscounts;
|
||||
//商家优惠
|
||||
private String merchantDiscounts;
|
||||
//达人优惠
|
||||
private String expertDiscounts;
|
||||
//支付优惠
|
||||
private String payDiscounts;
|
||||
//销售订单明细行优惠金额end------------––-------
|
||||
}
|
Loading…
Reference in New Issue