feat(sales): 计算平台运费并添加到销售订单

- 新增平台运费计算逻辑,累加偏远地区邮费
- 查询平台运费对应的存货基本档案和管理档案
- 计算邮费的无税金额、含税金额和税额
- 创建并添加平台运费的销售订单明细行- 优化了销售订单推送流程,支持邮费分摊
This commit is contained in:
liuy 2024-10-24 16:53:47 +08:00
parent 18d64962b5
commit 68e1e47828
11 changed files with 755 additions and 17 deletions

View File

@ -263,7 +263,7 @@ public class ConsignmachiningIn extends PluginBaseEntity {
queryOfsSoSaleOutVo.setPageSize(50L);
queryOfsSoSaleOutVo.setCode(code);
queryOfsSoSaleOutVo.setInternalInstructionType("PURCHASE");
queryOfsSoSaleOutVo.setStatus(900L);
// queryOfsSoSaleOutVo.setStatus(900L);
ofsStandardUtil.queryOfsReturnGoods(queryOfsSoSaleOutVo, returnGoodHeaderDetailsDataDtoArrayList, 1L, "ofs.receipt.search");
logger.info("数据返回行数:{}", returnGoodHeaderDetailsDataDtoArrayList.size());
if (returnGoodHeaderDetailsDataDtoArrayList.size() > 0) {

View File

@ -1002,7 +1002,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
// memberId = "9387";
Assert.notNull(memberId, "TOB销售订单(OFS)表头会员id不能为空否则无法匹配U8C客商档案");
Assert.state(!"".equals(memberId.trim()), "TOB销售订单(OFS)表头会员id不能为空否则无法匹配U8C客商档案");
//如果没有O单据名称则默认为销售
if (header2.getSubOrderType() == null || "".equals(header2.getSubOrderType().trim())) {
header2.setSubOrderType("SALES");

View File

@ -11,6 +11,9 @@ import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.beanutil.BeanUtil;
import com.hzya.frame.plugin.lets.constant.OverallConstant;
import com.hzya.frame.plugin.lets.constant.ProfilesActiveConstant;
import com.hzya.frame.plugin.lets.dao.IBdInvbasdocDao;
import com.hzya.frame.plugin.lets.dao.IBdInvmandocDao;
import com.hzya.frame.plugin.lets.dao.IBdTaxitemsDao;
import com.hzya.frame.plugin.lets.entity.*;
import com.hzya.frame.plugin.lets.ofs.dao.ITocofsSaleoutDao;
import com.hzya.frame.plugin.lets.ofs.dao.ITocofsSaleoutDetailedDao;
@ -99,9 +102,21 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
private static final String TRAN = "tran";
@Autowired
private IBdInvmandocDao iBdInvmandocDao;
@Autowired
private OfsOrderSalePostageFeeAllocationUtil ofsOrderSalePostageFeeAllocationUtil;
@Autowired
private QueryU8CEntityUtil queryU8CEntityUtil;
@Autowired
private IBdInvbasdocDao iBdInvbasdocDao;
@Autowired
private IBdTaxitemsDao iBdTaxitemsDao;
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
try {
@ -753,6 +768,12 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
// BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("202");
//初始化所有存货管理档案对应的结存价+采购价
List<Map> mapList = initAllBalancePricePurchasePrice();
//查询平台运费存货基本档案
BdInvbasdocEntity bdInvbasdocEntity1 = queryStockBasicArchives();
//查询平台运费对应的税率
BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode());
//查询平台运费所有公司的存货管理档案
Map<String, BdInvmandocEntity> stringBdInvmandocEntityMap = queryInventoryMan(bdInvbasdocEntity1.getPkInvbasdoc());
if (bdBusitypeEntity != null && summaryDimensionMap != null) {
Iterator<Map.Entry<String, List<SonDetailsDto>>> iterator = summaryDimensionMap.entrySet().iterator();
@ -918,13 +939,63 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
} else {
saleorderRequestChildrenDto.setVdef7("0");
}
//判断是否增加邮费这个存货accumulatedPostage
BigDecimal accumulatedPostage = checkPostageFee(oldValue);
if (accumulatedPostage != null && accumulatedPostage.compareTo(BigDecimal.ZERO) > 0) {
//获取平台运维对应的税率
String tax2 = "0." + new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString();
BigDecimal noriginalcurprice2 = null;//无税单价
BigDecimal noriginalcurmny2 = null;//无税金额
BigDecimal noriginalcurtaxprice2 = null;//含税单价
BigDecimal noriginalcursummny2 = null;//价税合计
BigDecimal noriginalcurtaxmny2 = null;//税额
try {
//邮费的汇总金额但是数量永远为1
noriginalcurtaxprice2 = accumulatedPostage.setScale(2, BigDecimal.ROUND_HALF_UP);
noriginalcurprice2 = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax2)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
noriginalcurmny2 = noriginalcurprice.multiply(new BigDecimal("1")).setScale(2, BigDecimal.ROUND_HALF_UP);
noriginalcursummny2 = noriginalcurtaxprice.multiply(new BigDecimal("1")).setScale(2, BigDecimal.ROUND_HALF_UP);
noriginalcurtaxmny2 = noriginalcursummny.subtract(noriginalcurmny).setScale(2, BigDecimal.ROUND_HALF_UP);
} catch (Exception e) {
logger.error("邮费TOC金额计算错误", e);
Assert.state(false, "邮费TOC金额计算错误原因{}" + e.getMessage());
}
//存货管理档案
BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(deliverGoodsCorp.getPkCorp());
//增加平台运费这个存货
SaleorderRequestChildrenDto saleorderRequestChildrenDto2 = new SaleorderRequestChildrenDto();
saleorderRequestChildrenDto2.setBlargessflag(false);//是否赠品
saleorderRequestChildrenDto2.setCadvisecalbodyid(bdCalbodyEntity.getPkCalbody());//发货库存组织
saleorderRequestChildrenDto2.setCbodywarehouseid(bdStordocEntity.getPkStordoc());//发货仓库
saleorderRequestChildrenDto2.setCbodywarehousecode(bdStordocEntity.getStorcode());//发货仓库编码这个字段不需要给openapi接口而是提供给下游方法使用
saleorderRequestChildrenDto2.setCconsigncorpid(deliverGoodsCorp.getPkCorp());//发货公司
saleorderRequestChildrenDto2.setCcurrencytypeid("00010000000000000001");//币种
saleorderRequestChildrenDto2.setCinventoryid(bdInvmandocEntity1.getPkInvmandoc());//存货id
saleorderRequestChildrenDto2.setCinventorycode(bdInvbasdocEntity1.getInvcode());//存货编码
saleorderRequestChildrenDto2.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//收货单位
saleorderRequestChildrenDto2.setDconsigndate(generateBusinessDate);//计划发货日期
saleorderRequestChildrenDto2.setDdeliverdate(generateBusinessDate);//要求收货日期
saleorderRequestChildrenDto2.setNexchangeotobrate("1.00000000");//折本汇率
saleorderRequestChildrenDto2.setNitemdiscountrate("100.000000");//单品折扣
saleorderRequestChildrenDto2.setNnumber("1");//数量
saleorderRequestChildrenDto2.setNoriginalcurdiscountmny("0");//折扣额
saleorderRequestChildrenDto2.setNoriginalcurmny(noriginalcurmny2.stripTrailingZeros().toPlainString());//无税金额
saleorderRequestChildrenDto2.setNoriginalcursummny(noriginalcursummny2.stripTrailingZeros().toPlainString());//价税合计
saleorderRequestChildrenDto2.setNoriginalcurtaxmny(noriginalcurtaxmny2.stripTrailingZeros().toPlainString());//税额
saleorderRequestChildrenDto2.setNoriginalcurtaxnetprice(noriginalcurtaxprice2.stripTrailingZeros().toPlainString());//含税净价
saleorderRequestChildrenDto2.setNoriginalcurtaxprice(noriginalcurtaxprice2.stripTrailingZeros().toPlainString());//含税单价
saleorderRequestChildrenDto2.setNtaxrate(new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString());//税率对应运维存货的税率
saleorderRequestChildrenDto2.setVdef4("0");
saleorderRequestChildrenDto2.setVdef5("0");
saleorderRequestChildrenDto2.setVdef6("0");
saleorderRequestChildrenDto2.setVdef7("0");
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto2);
}
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto);
//销售订单单据推送到u8c
//测试
// if (true) {
// continue;
// }
List<SaleorderRequestDto> saleorderRequestDtoList = new ArrayList<>();
saleorderRequestDtoList.add(saleorderRequestDto);
@ -1048,6 +1119,8 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
findMatchingOfsOrder(headerDetailsDtos, headerDetailsDtoList);
//计算OFS销售订单优惠金额分摊到明细行
ofsOrderSaleAmountAllocationUtil.batchTocSalesAmountAllocation(headerDetailsDtos);
//计算OFS销售订单邮费分摊
ofsOrderSalePostageFeeAllocationUtil.batchTocSalesPostageFeeAllocation(headerDetailsDtos);
for (int i = 0; i < headerDetailsDtoList.size(); i++) {
HeaderDetailsDto headerDetailsDto = headerDetailsDtoList.get(i);
@ -1623,7 +1696,6 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
*/
private void implementTran(List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDetailsDto> headerDetailsDtos) throws Exception {
logger.info("TOC销售库存业务{}行需要进行数据转换", headerDetailsDtos.size());
if (headerDetailsDtos != null && headerDetailsDtos.size() > 0) {
try {
//查询基本档案
@ -1641,6 +1713,12 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
// BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("202");
//初始化所有存货管理档案对应的结存价+采购价
List<Map> mapList = initAllBalancePricePurchasePrice();
//查询平台运费存货基本档案
BdInvbasdocEntity bdInvbasdocEntity1 = queryStockBasicArchives();
//查询平台运费对应的税率
BdTaxitemsEntity bdTaxitemsEntity = queryBdTaxitems(bdInvbasdocEntity1.getInvcode());
//查询平台运费所有公司的存货管理档案
Map<String, BdInvmandocEntity> stringBdInvmandocEntityMap = queryInventoryMan(bdInvbasdocEntity1.getPkInvbasdoc());
if (bdBusitypeEntity != null && summaryDimensionMap != null) {
Iterator<Map.Entry<String, List<SonDetailsDto>>> iterator = summaryDimensionMap.entrySet().iterator();
@ -1801,6 +1879,60 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
}
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto);
//判断是否增加邮费这个存货accumulatedPostage
BigDecimal accumulatedPostage = checkPostageFee(oldValue);
if (accumulatedPostage != null && accumulatedPostage.compareTo(BigDecimal.ZERO) > 0) {
//获取平台运维对应的税率
String tax2 = "0." + new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString();
BigDecimal noriginalcurprice2 = null;//无税单价
BigDecimal noriginalcurmny2 = null;//无税金额
BigDecimal noriginalcurtaxprice2 = null;//含税单价
BigDecimal noriginalcursummny2 = null;//价税合计
BigDecimal noriginalcurtaxmny2 = null;//税额
try {
//邮费的汇总金额但是数量永远为1
noriginalcurtaxprice2 = accumulatedPostage.setScale(2, BigDecimal.ROUND_HALF_UP);
noriginalcurprice2 = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax2)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
noriginalcurmny2 = noriginalcurprice.multiply(new BigDecimal("1")).setScale(2, BigDecimal.ROUND_HALF_UP);
noriginalcursummny2 = noriginalcurtaxprice.multiply(new BigDecimal("1")).setScale(2, BigDecimal.ROUND_HALF_UP);
noriginalcurtaxmny2 = noriginalcursummny.subtract(noriginalcurmny).setScale(2, BigDecimal.ROUND_HALF_UP);
} catch (Exception e) {
logger.error("邮费TOC金额计算错误", e);
Assert.state(false, "邮费TOC金额计算错误原因{}" + e.getMessage());
}
//存货管理档案
BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(deliverGoodsCorp.getPkCorp());
//增加平台运费这个存货
SaleorderRequestChildrenDto saleorderRequestChildrenDto2 = new SaleorderRequestChildrenDto();
saleorderRequestChildrenDto2.setBlargessflag(false);//是否赠品
saleorderRequestChildrenDto2.setCadvisecalbodyid(bdCalbodyEntity.getPkCalbody());//发货库存组织
saleorderRequestChildrenDto2.setCbodywarehouseid(bdStordocEntity.getPkStordoc());//发货仓库
saleorderRequestChildrenDto2.setCbodywarehousecode(bdStordocEntity.getStorcode());//发货仓库编码这个字段不需要给openapi接口而是提供给下游方法使用
saleorderRequestChildrenDto2.setCconsigncorpid(deliverGoodsCorp.getPkCorp());//发货公司
saleorderRequestChildrenDto2.setCcurrencytypeid("00010000000000000001");//币种
saleorderRequestChildrenDto2.setCinventoryid(bdInvmandocEntity1.getPkInvmandoc());//存货id
saleorderRequestChildrenDto2.setCinventorycode(bdInvbasdocEntity1.getInvcode());//存货编码
saleorderRequestChildrenDto2.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//收货单位
saleorderRequestChildrenDto2.setDconsigndate(generateBusinessDate);//计划发货日期
saleorderRequestChildrenDto2.setDdeliverdate(generateBusinessDate);//要求收货日期
saleorderRequestChildrenDto2.setNexchangeotobrate("1.00000000");//折本汇率
saleorderRequestChildrenDto2.setNitemdiscountrate("100.000000");//单品折扣
saleorderRequestChildrenDto2.setNnumber("-1");//数量
saleorderRequestChildrenDto2.setNoriginalcurdiscountmny("0");//折扣额
saleorderRequestChildrenDto2.setNoriginalcurmny("-" + noriginalcurmny2.stripTrailingZeros().toPlainString());//无税金额
saleorderRequestChildrenDto2.setNoriginalcursummny("-" + noriginalcursummny2.stripTrailingZeros().toPlainString());//价税合计
saleorderRequestChildrenDto2.setNoriginalcurtaxmny("-" + noriginalcurtaxmny2.stripTrailingZeros().toPlainString());//税额
saleorderRequestChildrenDto2.setNoriginalcurtaxnetprice(noriginalcurtaxprice2.stripTrailingZeros().toPlainString());//含税净价
saleorderRequestChildrenDto2.setNoriginalcurtaxprice(noriginalcurtaxprice2.stripTrailingZeros().toPlainString());//含税单价
saleorderRequestChildrenDto2.setNtaxrate(new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString());//税率对应运维存货的税率
saleorderRequestChildrenDto2.setVdef4("0");
saleorderRequestChildrenDto2.setVdef5("0");
saleorderRequestChildrenDto2.setVdef6("0");
saleorderRequestChildrenDto2.setVdef7("0");
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto2);
}
//销售订单单据推送到u8c
List<SaleorderRequestDto> saleorderRequestDtoList = new ArrayList<>();
saleorderRequestDtoList.add(saleorderRequestDto);
@ -1948,6 +2080,61 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
saleorderRequestChildrenDto.setVdef7("0");
}
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto);
//判断是否增加邮费这个存货accumulatedPostage
BigDecimal accumulatedPostage = checkPostageFee(oldValue);
if (accumulatedPostage != null && accumulatedPostage.compareTo(BigDecimal.ZERO) > 0) {
//获取平台运维对应的税率
String tax2 = "0." + new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString();
BigDecimal noriginalcurprice2 = null;//无税单价
BigDecimal noriginalcurmny2 = null;//无税金额
BigDecimal noriginalcurtaxprice2 = null;//含税单价
BigDecimal noriginalcursummny2 = null;//价税合计
BigDecimal noriginalcurtaxmny2 = null;//税额
try {
//邮费的汇总金额但是数量永远为1
noriginalcurtaxprice2 = accumulatedPostage.setScale(2, BigDecimal.ROUND_HALF_UP);
noriginalcurprice2 = noriginalcurtaxprice.divide(new BigDecimal(1).add(new BigDecimal(tax2)), 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
noriginalcurmny2 = noriginalcurprice.multiply(new BigDecimal("1")).setScale(2, BigDecimal.ROUND_HALF_UP);
noriginalcursummny2 = noriginalcurtaxprice.multiply(new BigDecimal("1")).setScale(2, BigDecimal.ROUND_HALF_UP);
noriginalcurtaxmny2 = noriginalcursummny.subtract(noriginalcurmny).setScale(2, BigDecimal.ROUND_HALF_UP);
} catch (Exception e) {
logger.error("邮费TOC金额计算错误", e);
Assert.state(false, "邮费TOC金额计算错误原因{}" + e.getMessage());
}
//存货管理档案
BdInvmandocEntity bdInvmandocEntity1 = stringBdInvmandocEntityMap.get(deliverGoodsCorp.getPkCorp());
//增加平台运费这个存货
SaleorderRequestChildrenDto saleorderRequestChildrenDto2 = new SaleorderRequestChildrenDto();
saleorderRequestChildrenDto2.setBlargessflag(false);//是否赠品
saleorderRequestChildrenDto2.setCadvisecalbodyid(bdCalbodyEntity.getPkCalbody());//发货库存组织
saleorderRequestChildrenDto2.setCbodywarehouseid(bdStordocEntity.getPkStordoc());//发货仓库
saleorderRequestChildrenDto2.setCbodywarehousecode(bdStordocEntity.getStorcode());//发货仓库编码这个字段不需要给openapi接口而是提供给下游方法使用
saleorderRequestChildrenDto2.setCconsigncorpid(deliverGoodsCorp.getPkCorp());//发货公司
saleorderRequestChildrenDto2.setCcurrencytypeid("00010000000000000001");//币种
saleorderRequestChildrenDto2.setCinventoryid(bdInvmandocEntity1.getPkInvmandoc());//存货id
saleorderRequestChildrenDto2.setCinventorycode(bdInvbasdocEntity1.getInvcode());//存货编码
saleorderRequestChildrenDto2.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//收货单位
saleorderRequestChildrenDto2.setDconsigndate(generateBusinessDate);//计划发货日期
saleorderRequestChildrenDto2.setDdeliverdate(generateBusinessDate);//要求收货日期
saleorderRequestChildrenDto2.setNexchangeotobrate("1.00000000");//折本汇率
saleorderRequestChildrenDto2.setNitemdiscountrate("100.000000");//单品折扣
saleorderRequestChildrenDto2.setNnumber("1");//数量
saleorderRequestChildrenDto2.setNoriginalcurdiscountmny("0");//折扣额
saleorderRequestChildrenDto2.setNoriginalcurmny(noriginalcurmny2.stripTrailingZeros().toPlainString());//无税金额
saleorderRequestChildrenDto2.setNoriginalcursummny(noriginalcursummny2.stripTrailingZeros().toPlainString());//价税合计
saleorderRequestChildrenDto2.setNoriginalcurtaxmny(noriginalcurtaxmny2.stripTrailingZeros().toPlainString());//税额
saleorderRequestChildrenDto2.setNoriginalcurtaxnetprice(noriginalcurtaxprice2.stripTrailingZeros().toPlainString());//含税净价
saleorderRequestChildrenDto2.setNoriginalcurtaxprice(noriginalcurtaxprice2.stripTrailingZeros().toPlainString());//含税单价
saleorderRequestChildrenDto2.setNtaxrate(new BigDecimal(bdTaxitemsEntity.getTaxratio()).stripTrailingZeros().toPlainString());//税率对应运维存货的税率
saleorderRequestChildrenDto2.setVdef4("0");
saleorderRequestChildrenDto2.setVdef5("0");
saleorderRequestChildrenDto2.setVdef6("0");
saleorderRequestChildrenDto2.setVdef7("0");
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto2);
}
saleorderRequestChildrenDtoList.add(saleorderRequestChildrenDto);
//销售订单单据推送到u8c
List<SaleorderRequestDto> saleorderRequestDtoList = new ArrayList<>();
@ -2692,4 +2879,188 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
mapList.add(stringPoOrderBEntityMap);
return mapList;
}
/**
* 累加偏远地区的邮费如果累加后的邮费大于0则会追加一个存货用于记录平台邮费
*
* @author liuyang
*/
private BigDecimal checkPostageFee(List<SonDetailsDto> oldValue) throws Exception {
BigDecimal shareTargetFreightTotalDiscounts = new BigDecimal("0");
if (oldValue != null && oldValue.size() > 0) {
for (int i = 0; i < oldValue.size(); i++) {
SonDetailsDto sonDetailsDto = oldValue.get(i);
//查找O出库单某行明细对应的OFS销售订单明细行
com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto ofsOrderDetail = findOfsOrderDetail(sonDetailsDto);
if (ofsOrderDetail != null) {
BigDecimal shareTargetFreightDiscounts = ofsOrderDetail.getShareTargetFreightDiscounts();
shareTargetFreightTotalDiscounts = shareTargetFreightTotalDiscounts.add(shareTargetFreightDiscounts);
}
}
}
return shareTargetFreightTotalDiscounts;
}
/**
* 查找销售订单明细行
*
* @author liuyang
*/
private com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto findOfsOrderDetail(SonDetailsDto sonDetailsDto) {
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = sonDetailsDto.getHeaderDetailsDto();
if (headerDetailsDto != null) {
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header = headerDetailsDto.getHeader();
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto> details = headerDetailsDto.getDetails();
for (int j = 0; j < details.size(); j++) {
com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto detailsDto = details.get(j);//O销售出库单对应的O销售订单明细行
//detailsDto.getId()为销售订单明细行主键
if (detailsDto.getId() != null) {
if (detailsDto.getId().equals(sonDetailsDto.getRefOrderDetailId())) {
return detailsDto;
}
}
}
}
return null;
}
/**
* 收集OFS全部的销售订单
*
* @author liuyang
*/
// private Map<String, com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> collectOfsOrder(List<SonDetailsDto> oldValue) {
// Map<String, com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> stringHeaderDetailsDtoMap = new HashMap<>();
// List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> headerDetailsDtoList = new ArrayList<>();
// if (oldValue != null && oldValue.size() > 0) {
// for (int i = 0; i < oldValue.size(); i++) {
// SonDetailsDto sonDetailsDto = oldValue.get(i);
// headerDetailsDtoList.add(sonDetailsDto.getHeaderDetailsDto());
// }
// }
// if (headerDetailsDtoList.size() > 0) {
// //转换为Map
//
// }
// return stringHeaderDetailsDtoMap;
// }
/**
* 增加邮费存货
*/
// private void addPostageFeeStock() throws Exception {
// SaleorderRequestChildrenDto saleorderRequestChildrenDto = new SaleorderRequestChildrenDto();
// saleorderRequestChildrenDto.setBlargessflag(false);//是否赠品
// saleorderRequestChildrenDto.setCadvisecalbodyid(bdCalbodyEntity.getPkCalbody());//发货库存组织
// saleorderRequestChildrenDto.setCbodywarehouseid(bdStordocEntity.getPkStordoc());//发货仓库
// saleorderRequestChildrenDto.setCbodywarehousecode(bdStordocEntity.getStorcode());//发货仓库编码这个字段不需要给openapi接口而是提供给下游方法使用
// saleorderRequestChildrenDto.setCconsigncorpid(deliverGoodsCorp.getPkCorp());//发货公司
// saleorderRequestChildrenDto.setCcurrencytypeid("00010000000000000001");//币种
// saleorderRequestChildrenDto.setCinventoryid(bdInvmandocEntity.getPkInvmandoc());//存货id
// saleorderRequestChildrenDto.setCinventorycode(bdInvbasdocEntity.getInvcode());//存货编码
// saleorderRequestChildrenDto.setCreceiptcorpid(bdCumandocEntity.getPkCumandoc());//收货单位
// saleorderRequestChildrenDto.setDconsigndate(generateBusinessDate);//计划发货日期
// saleorderRequestChildrenDto.setDdeliverdate(generateBusinessDate);//要求收货日期
// saleorderRequestChildrenDto.setNexchangeotobrate("1.00000000");//折本汇率
// saleorderRequestChildrenDto.setNitemdiscountrate("100.000000");//单品折扣
// saleorderRequestChildrenDto.setNnumber(String.valueOf(sonDetailsDto.getGroupShipQty()));//数量
// saleorderRequestChildrenDto.setNoriginalcurdiscountmny("0");//折扣额
// saleorderRequestChildrenDto.setNoriginalcurmny(noriginalcurmny.stripTrailingZeros().toPlainString());//无税金额
// saleorderRequestChildrenDto.setNoriginalcursummny(noriginalcursummny.stripTrailingZeros().toPlainString());//价税合计
// saleorderRequestChildrenDto.setNoriginalcurtaxmny(noriginalcurtaxmny.stripTrailingZeros().toPlainString());//税额
// saleorderRequestChildrenDto.setNoriginalcurtaxnetprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税净价
// saleorderRequestChildrenDto.setNoriginalcurtaxprice(noriginalcurtaxprice.stripTrailingZeros().toPlainString());//含税单价
// saleorderRequestChildrenDto.setNtaxrate(new BigDecimal(bdTaxitemsEntity1.getTaxratio()).stripTrailingZeros().toPlainString());//税率
//
// //物流发货服务费
// saleorderRequestChildrenDto.setVdef4("0");
// saleorderRequestChildrenDto.setVdef5("0");
// saleorderRequestChildrenDto.setVdef6("0");
// saleorderRequestChildrenDto.setVdef7("0");
// }
/**
* 查询平台运费这个存货对应的基本档案和管理档案
*
* @author liuyang
*/
// private Map<String, Object> queryPlatformShippFeeStock(String pkCorp, String corpName) throws Exception {
// String freightPkInvmandoc = "FY05";
// Map<String, Object> stringObjectMap = new HashMap<>();
// //存货基本档案
// BdInvbasdocEntity bdInvbasdocEntity = queryStockBasicArchives(freightPkInvmandoc);
// //存货管理档案
// BdInvmandocEntity bdInvmandocEntity = queryInventoryMan(freightPkInvmandoc, pkCorp, corpName);
//
// stringObjectMap.put("bdInvbasdocEntity", bdInvbasdocEntity);
// stringObjectMap.put("bdInvmandocEntity", bdInvmandocEntity);
// return stringObjectMap;
// }
/**
* 查询存货管理档案key为公司idvalue为存货管理档案对象
*
* @param pk_invbasdoc 存货管理档案
* @author liuyang
*/
private Map<String, BdInvmandocEntity> queryInventoryMan(String pk_invbasdoc) throws Exception {
Assert.notNull(pk_invbasdoc, "pk_invbasdoc不能为空");
Assert.state(!"".equals(pk_invbasdoc.trim()), "pk_invbasdoc不能为空");
Map<String, BdInvmandocEntity> stringBdInvmandocEntityMap = new HashMap<>();
BdInvmandocEntity bdInvmandocEntity = new BdInvmandocEntity();
bdInvmandocEntity.setPkInvbasdoc(pk_invbasdoc);
bdInvmandocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
List<BdInvmandocEntity> bdInvmandocEntity2 = iBdInvmandocDao.queryBdInvmandocByInvcodeList(bdInvmandocEntity);
if (bdInvmandocEntity2 == null || bdInvmandocEntity2.size() == 0) {
Assert.state(false, "无法查询到所有公司对应的存货管理档案 存货管理档案主键:{}", pk_invbasdoc);
}
if (bdInvmandocEntity2 != null && bdInvmandocEntity2.size() > 0) {
for (int i = 0; i < bdInvmandocEntity2.size(); i++) {
BdInvmandocEntity bdInvmandocEntity1 = bdInvmandocEntity2.get(i);
stringBdInvmandocEntityMap.put(bdInvmandocEntity1.getPkCorp(), bdInvmandocEntity1);
}
}
return stringBdInvmandocEntityMap;
}
/**
* 2024年8月7日 10:25:29
* 查询存货基础档案档案
*
* @author liuyang
*/
private BdInvbasdocEntity queryStockBasicArchives() throws Exception {
String invcode = "FY05";
BdInvbasdocEntity bdInvbasdocEntity = new BdInvbasdocEntity();
bdInvbasdocEntity.setInvcode(invcode);
bdInvbasdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
List<BdInvbasdocEntity> bdInvbasdocEntity2 = iBdInvbasdocDao.query(bdInvbasdocEntity);
if (bdInvbasdocEntity2.size() == 0) {
Assert.state(false, "根据存货编码:{}无法匹配到U8C存货基本档案", invcode);
} else if (bdInvbasdocEntity2.size() >= 2) {
Assert.state(false, "根据存货编码:{}无法匹配到U8C存货基本档案", invcode);
}
return bdInvbasdocEntity2.get(0);
}
/**
* 2024年8月7日 14:58:34
* 查询税目档案
*
* @author liuyang
*/
private BdTaxitemsEntity queryBdTaxitems(String invcode) throws Exception {
Assert.notNull(invcode, "存货编码不能为空");
BdTaxitemsEntity bdTaxitemsEntity = new BdTaxitemsEntity();
bdTaxitemsEntity.setInvcode(invcode);
List<BdTaxitemsEntity> bdTaxitemsEntityList = iBdTaxitemsDao.queryBdInvbasdocByInvcodeV2(bdTaxitemsEntity);
if (bdTaxitemsEntityList.size() == 0) {
Assert.state(false, "根据存货编码{}没有查询到U8C税目档案", invcode);
} else if (bdTaxitemsEntityList.size() >= 2) {
Assert.state(false, "根据存货编码{}查询到{}个U8C税目档案", invcode, bdTaxitemsEntityList.size());
}
return bdTaxitemsEntityList.get(0);
}
}

View File

@ -0,0 +1,286 @@
package com.hzya.frame.plugin.lets.util;
import cn.hutool.core.lang.Assert;
import com.hzya.frame.beanutil.BeanUtil;
import com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto;
import com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto;
import com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* 处理OFS销售订单邮费金额分摊的逻辑
*
* @Authorliuyang
* @Packagecom.hzya.frame.plugin.lets.util
* @ProjectkangarooDataCenterV3
* @nameAmountAllocationUtil
* @Date2024/9/21 18:19
* @FilenameAmountAllocationUtil
*/
@Component
public class OfsOrderSalePostageFeeAllocationUtil {
Logger logger = LoggerFactory.getLogger(OfsOrderSalePostageFeeAllocationUtil.class);
/**
* TOC销售订单邮费分摊逻辑
*
* @author liuyang
*/
public void batchTocSalesPostageFeeAllocation(List<HeaderDetailsDto> headerDetailsDtoList) {
Assert.notNull(headerDetailsDtoList, "headerDetailsDtoList不能为空");
logger.info("==TOC销售邮费金额分摊开始==");
headerDetailsDtoList.forEach(headerDetailsDto -> {
try {
tocSalesPostageFeeAllocation(headerDetailsDto);
} catch (Exception e) {
logger.error("tocSalesPostageFeeAllocation方法抛出异常批量处理TOC销售邮费分摊异常", e);
}
});
logger.info("==TOC销售邮费金额分摊结束==");
// logger.info("=记录优惠金额分摊结果开始=");
// printAmountOfMoneyNum(headerDetailsDtoList);
// logger.info("=记录优惠金额分摊结果完成=");
}
/**
* TOC邮费金额分摊
*
* @param headerDetailsDto OFS销售订单对象
* @author liuyang
*/
public void tocSalesPostageFeeAllocation(HeaderDetailsDto headerDetailsDto) throws Exception {
Assert.notNull(headerDetailsDto, "OFS销售订单对象不能为空");
HeaderDto header = headerDetailsDto.getHeader();
List<DetailsDto> detailsOld = headerDetailsDto.getDetails();
//拷贝一份List集合并移除没有实付金额的OFS销售订单明细行不参与分摊
//运费postageAmount
List<DetailsDto> details = copyDetailsDto(detailsOld);
details.removeIf(dto -> dto.getTotalPayAmount() == null || "0".equals(new BigDecimal(dto.getTotalPayAmount()).stripTrailingZeros().toPlainString()));
//计算分摊百分比
calculatePercentage(headerDetailsDto, details, header.getCode());
//销售订单运费
String postageAmount = header.getPostageAmount();
//运费可能没有也有可能为0
BigDecimal postageAmountDiscounts = null;
if (postageAmount != null && !"".equals(postageAmount) && !"0".equals(new BigDecimal(postageAmount).stripTrailingZeros().toPlainString())) {
postageAmountDiscounts = new BigDecimal(postageAmount);
}
BigDecimal totalShareTargetPlatformDiscounts = new BigDecimal("0");
//分摊金额=分摊比例*优惠金额
for (int i = 0; i < details.size(); i++) {
DetailsDto detailsDto = details.get(i);
//分摊比例
BigDecimal postageFeeSharingRatio = detailsDto.getPostageFeeSharingRatio();
//这里应该先8为小数实际汇总到出库单时再四舍五入两位小数
BigDecimal shareTargetPlatformDiscounts = null;
if (postageFeeSharingRatio != null && postageAmountDiscounts != null) {
shareTargetPlatformDiscounts = postageAmountDiscounts.multiply(postageFeeSharingRatio).setScale(2, BigDecimal.ROUND_HALF_UP);
detailsDto.setOriginalFreightDiscounts(postageAmountDiscounts);
detailsDto.setShareTargetFreightDiscounts(shareTargetPlatformDiscounts);
totalShareTargetPlatformDiscounts = totalShareTargetPlatformDiscounts.add(shareTargetPlatformDiscounts);
}
//如果是最后一行则把尾差进行追加
if (i == details.size() - 1) {
if (!"0".equals(totalShareTargetPlatformDiscounts.stripTrailingZeros().toPlainString()) && detailsDto.getShareTargetFreightDiscounts() != null) {
//原始运费金额-sum分摊金额
BigDecimal subtract = postageAmountDiscounts.subtract(totalShareTargetPlatformDiscounts);
if (subtract.compareTo(BigDecimal.ZERO) > 0) {
BigDecimal shareTargetFreightDiscounts = detailsDto.getShareTargetFreightDiscounts();
detailsDto.setShareTargetFreightDiscounts(shareTargetFreightDiscounts.add(subtract));
}
}
}
//拷贝回到原始的集合
copyDetailsDtoOld(details, detailsOld);
}
}
/**
* 计算百分比
* 分摊比例=实付金额/sum(实付金额)
*
* @param headerDetailsDto2 OFS销售订单
* @param details 克隆后的销售订单明细行
* @param ofsCode OFS销售订单编码
* @author liuyang
*/
private void calculatePercentage(HeaderDetailsDto headerDetailsDto2, List<DetailsDto> details, String ofsCode) throws Exception {
Assert.notNull(headerDetailsDto2, "headerDetailsDto2不能为空");
Assert.notNull(details, "details不能为空");
Assert.notNull(ofsCode, "ofsCode不能为空");
HeaderDto header1 = headerDetailsDto2.getHeader();
List<DetailsDto> details1 = headerDetailsDto2.getDetails();
BigDecimal sumTotalPayAmountBigDecimal = sumTotalPayAmountAmount(details1, header1.getCode());
for (int i = 0; i < details1.size(); i++) {
DetailsDto detailsDto = details1.get(i);
String totalPayAmount = detailsDto.getTotalPayAmount();
//如果实付金额为0则不进行分摊
if (totalPayAmount != null && !"0".equals(new BigDecimal(totalPayAmount).stripTrailingZeros().toPlainString())) {
BigDecimal totalPayAmountBigDecimal = new BigDecimal(totalPayAmount);
//得到分摊比例
BigDecimal percentageBigDecimal = totalPayAmountBigDecimal.divide(sumTotalPayAmountBigDecimal, 20, BigDecimal.ROUND_HALF_UP).setScale(8, BigDecimal.ROUND_HALF_UP);
if (details != null && details.size() > 0) {
for (int j = 0; j < details.size(); j++) {
DetailsDto detailsDto1 = details.get(j);
if (detailsDto1.getId() != null && detailsDto.getId() != null) {
if (detailsDto1.getId().equals(detailsDto.getId())) {
details.get(j).setPostageFeeSharingRatio(percentageBigDecimal);
}
}
}
}
}
//logger.info打太多太慢了
// else {
// logger.info(totalPayAmount, "totalPayAmount(商品金额)为空OFS销售订单号{} 存货编码:{}", ofsCode, detailsDto.getSkuCode());
// }
}
}
/**
* 累计这一单对应的实付金额
*
* @param details1 OFS销售订单明细行
* @param code OFS销售订单号
* @author liuyang
*/
private BigDecimal sumTotalPayAmountAmount(List<DetailsDto> details1, String code) throws Exception {
Assert.notNull(details1, "details1不能为空");
Assert.notNull(code, "code不能为空");
BigDecimal totalPayAmountTotalBigDecimal = new BigDecimal("0");
for (int i = 0; i < details1.size(); i++) {
DetailsDto detailsDto = details1.get(i);
//实付金额
String totalPayAmount = detailsDto.getTotalPayAmount();
if (totalPayAmount != null && !"0".equals(new BigDecimal(totalPayAmount).stripTrailingZeros().toPlainString())) {
BigDecimal totalPayAmountBigDecimal = new BigDecimal(totalPayAmount);
totalPayAmountTotalBigDecimal = totalPayAmountTotalBigDecimal.add(totalPayAmountBigDecimal);
}
}
if ("0".equals(totalPayAmountTotalBigDecimal.stripTrailingZeros().toPlainString())) {
logger.info("OFS销售订单号{} 整单明细行全部的「实付金额」都为0邮费都不参与分摊", code);
}
return totalPayAmountTotalBigDecimal;
}
/**
* 集合复制
*
* @param details 旧OFS销售订单明细行
* @author liuyang
*/
private List<DetailsDto> copyDetailsDto(List<DetailsDto> details) throws Exception {
List<DetailsDto> newDetails = new ArrayList<>();
for (int i = 0; i < details.size(); i++) {
DetailsDto detailsDto = details.get(i);
DetailsDto newDetailsDto1 = new DetailsDto();
BeanUtil.copyPropertiesV2(detailsDto, newDetailsDto1);
newDetails.add(newDetailsDto1);
}
return newDetails;
}
/**
* 拷贝到原集合中
*
* @param newDetails 新OFS销售订单明细行
* @param detailsOld 旧OFS销售订单明细行
* @author liuyang
*/
private void copyDetailsDtoOld(List<DetailsDto> newDetails, List<DetailsDto> detailsOld) throws Exception {
if (newDetails != null && detailsOld != null) {
for (int i = 0; i < detailsOld.size(); i++) {
DetailsDto detailsDto = detailsOld.get(i);
for (int j = 0; j < newDetails.size(); j++) {
DetailsDto detailsDto1 = newDetails.get(j);
if (detailsDto.getId().equals(detailsDto1.getId())) {
//把分摊后的金额拷贝到旧的OFS销售订单集合中
BeanUtil.copyPropertiesV2(detailsDto1, detailsDto);
}
}
}
} else {
logger.error("copyDetailsDtoOld方法newDetails或者detailsOld为空");
}
}
/**
* 打印金额参数
*
* @param headerDetailsDtoList OFS销售订单号
*/
// public void printAmountOfMoneyNum(List<HeaderDetailsDto> headerDetailsDtoList) {
// try {
// if (headerDetailsDtoList != null && headerDetailsDtoList.size() > 0) {
// for (int i = 0; i < headerDetailsDtoList.size(); i++) {
// HeaderDetailsDto headerDetailsDto = headerDetailsDtoList.get(i);
// HeaderDto header = headerDetailsDto.getHeader();
// List<DetailsDto> details = headerDetailsDto.getDetails();
//
// logger.info("OFS销售订单号{} 平台优惠:{} 商家优惠:{} 达人优惠:{} 支付优惠:{}", header.getCode(), header.getPlatformDiscounts(), header.getMerchantDiscounts(), header.getExpertDiscounts(), header.getPayDiscounts());
// if (details != null && details.size() > 0) {
// for (int j = 0; j < details.size(); j++) {
// DetailsDto detailsDto = details.get(j);
//
// logger.info("start================================");
// logger.info("OFS销售订单明细主键{}", detailsDto.getId());
// if (detailsDto.getSharingRatio() != null) {
// logger.info("分摊比例:{}", detailsDto.getSharingRatio().stripTrailingZeros().toPlainString());
// } else {
// logger.info("分摊比例:无");
// }
// logger.info("商品金额:{}", detailsDto.getItemTotalAmount());
// if (detailsDto.getShareTargetPlatformDiscounts() != null) {
// logger.info("分摊平台优惠:{}", detailsDto.getShareTargetPlatformDiscounts().stripTrailingZeros().toPlainString());
// } else {
// logger.info("分摊平台优惠:无");
// }
// if (detailsDto.getShareTargetMerchantDiscounts() != null) {
// logger.info("分摊商家优惠:{}", detailsDto.getShareTargetMerchantDiscounts().stripTrailingZeros().toPlainString());
// } else {
// logger.info("分摊商家优惠:无");
// }
// if (detailsDto.getShareTargetExpertDiscounts() != null) {
// logger.info("分摊达人优惠:{}", detailsDto.getShareTargetExpertDiscounts().stripTrailingZeros().toPlainString());
// } else {
// logger.info("分摊达人优惠:无");
// }
// if (detailsDto.getShareTargetPayDiscounts() != null) {
// logger.info("分摊支付优惠:{}", detailsDto.getShareTargetPayDiscounts().stripTrailingZeros().toPlainString());
// } else {
// logger.info("分摊支付优惠:无");
// }
// logger.info("end================================");
// }
// }
// }
// }
// } catch (Exception e) {
//// e.printStackTrace();
// logger.error("printAmountOfMoneyNum方法抛出异常", e);
// }
// }
}

View File

@ -587,7 +587,9 @@ public class TocOrderBasicArchivesCacheUtil {
if (bdDefdocEntityList != null && bdDefdocEntityList.size() > 0) {
for (int i = 0; i < bdDefdocEntityList.size(); i++) {
BdDefdocEntity bdDefdocEntity1 = bdDefdocEntityList.get(i);
shopDefdocEntityHashMap.put(bdDefdocEntity1.getDoccode(), bdDefdocEntity1);
if (bdDefdocEntity1 != null) {
shopDefdocEntityHashMap.put(bdDefdocEntity1.getDoccode().trim(), bdDefdocEntity1);
}
}
}
return shopDefdocEntityHashMap;

View File

@ -27,9 +27,9 @@ public class ConsignmachiningInTest {
@Test
public void startImplement() {
// String code = "LETS-RE2024082300000007";
// String code = "LETS-RE2024090300000001";
// consignmachiningIn.startImplement(code);
String code = "LETS-RE2024102200000018";
consignmachiningIn.startImplement(code);
consignmachiningIn.startImplement("2024-09-24 13:49:15", "2024-09-24 13:49:17");
// consignmachiningIn.startImplement("2024-09-24 13:49:15", "2024-09-24 13:49:17");
}
}

View File

@ -80,9 +80,10 @@ public class SoSaleOutPluginInitializerToBTest {
try {
// soSaleOutPluginInitializerToB.startImplementByCode("LETS-SH2024101800025544", "stock");
soSaleOutPluginInitializerToB.startImplementByStockTime("2024-10-18 00:00:00", "2024-10-18 23:59:59");
// String aaa = "LETS-SH2024101800024795";
// soSaleOutPluginInitializerToB.startImplementByCode(aaa, "stock");
// soSaleOutPluginInitializerToB.startImplementByStockTime("2024-10-18 00:00:00", "2024-10-18 23:59:59");
String aaa = "LETS-RE2024102200000018";
soSaleOutPluginInitializerToB.startImplementByCode(aaa, "stock");
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -97,7 +97,7 @@ class SoSaleOutPluginInitializerToCTest {
try {
// soSaleOutPluginInitializerToC.startImplementStockByTime("2024-10-18 00:00:00", "2024-10-18 23:59:59");
String code = "LETS-SH2024101700027117";
String code = "LETS-SH2024102100026682";
soSaleOutPluginInitializerToC.startImplementStockByCode(code, "stock");
} catch (Exception e) {
e.printStackTrace();

View File

@ -40,7 +40,7 @@ public class OfsOrderSaleAmountAllocationUtilTest {
@Test
public void tocSalesAmountAllocation() {
try {
SaleOrderMessageDto ofsOrder = afterSalesOrderUtil.getOfsOrder("LETS-SO2024092500000020");
SaleOrderMessageDto ofsOrder = afterSalesOrderUtil.getOfsOrder("LETS-SO2022110600035448");
List<HeaderDetailsDto> data = ofsOrder.getData();
if (data.size() > 0) {
//测试一所有优惠金额都为0

View File

@ -0,0 +1,64 @@
package com.hzya.frame.plugin.lets.util;
import com.hzya.frame.WebappApplication;
import com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto;
import com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto;
import com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto;
import com.hzya.frame.ttxofs.dto.ofssalesordersearch.SaleOrderMessageDto;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.*;
/**
* @Authorliuyang
* @Packagecom.hzya.frame.plugin.lets.util
* @ProjectkangarooDataCenterV3
* @nameOfsOrderSalePostageFeeAllocationUtilTest
* @Date2024/10/23 14:51
* @FilenameOfsOrderSalePostageFeeAllocationUtilTest
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = WebappApplication.class)
public class OfsOrderSalePostageFeeAllocationUtilTest {
@Autowired
private OfsOrderSalePostageFeeAllocationUtil ofsOrderSalePostageFeeAllocationUtil;
@Autowired
private AfterSalesOrderUtil afterSalesOrderUtil;
@Test
public void batchTocSalesPostageFeeAllocation() {
try {
SaleOrderMessageDto ofsOrder = afterSalesOrderUtil.getOfsOrder("LETS-SO2024100100026431");
List<HeaderDetailsDto> data = ofsOrder.getData();
// List<HeaderDetailsDto> headerDetailsDtoList = new ArrayList<>();
// headerDetailsDtoList.add(HeaderDetailsDto.builder().build());
ofsOrderSalePostageFeeAllocationUtil.batchTocSalesPostageFeeAllocation(data);
HeaderDetailsDto headerDetailsDto = data.get(0);
HeaderDto header = headerDetailsDto.getHeader();
List<DetailsDto> details = headerDetailsDto.getDetails();
for (int i = 0; i < details.size(); i++) {
DetailsDto detailsDto = details.get(i);
System.out.println("邮费分摊比例:" + detailsDto.getPostageFeeSharingRatio());
System.out.println("原始运费分摊金额:" + detailsDto.getOriginalFreightDiscounts());
System.out.println("实际运费分摊金额:" + detailsDto.getShareTargetFreightDiscounts());
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void tocSalesPostageFeeAllocation() {
}
}

View File

@ -57,7 +57,8 @@ public class DetailsDto {
private String shipAt;
private String totalAmount;
//分摊比例
//优惠分摊start-----------------
//优惠金额-分摊比例
private BigDecimal sharingRatio;
//原始平台优惠
@ -77,4 +78,17 @@ public class DetailsDto {
private BigDecimal shareTargetExpertDiscounts;
//分摊支付优惠
private BigDecimal shareTargetPayDiscounts;
//优惠分摊end-----------------
//邮费分摊start-----------------
//邮费分摊比例
private BigDecimal postageFeeSharingRatio;
//原始运费分摊金额
private BigDecimal originalFreightDiscounts;
//实际运费分摊金额
private BigDecimal shareTargetFreightDiscounts;
//邮费分摊end-------------------
}