优化OFS售后订单金额分摊逻辑
- 新增批量分摊方法batchTocSalesAmountAllocation- 优化分摊比例计算逻辑,支持商品零售价为0时不参与分摊 - 增加分摊结果记录和打印方法printAmountOfMoneyNum -重构calculatePercentage方法,支持售后订单明细分摊比例计算 - 新增测试类OfsOrderAfterSalesAmountAllocationUtilTest,增加多种测试场景
This commit is contained in:
parent
4b3f3c8437
commit
215f1b0fa1
|
@ -34,7 +34,7 @@ import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* O采购入库->U8C委外加工入库
|
* O采购入库(委外加工类型)->U8C委外订单
|
||||||
*
|
*
|
||||||
* @Author:liuyang
|
* @Author:liuyang
|
||||||
* @Package:com.hzya.frame.plugin.lets.plugin.outsourc
|
* @Package:com.hzya.frame.plugin.lets.plugin.outsourc
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.hzya.frame.plugin.lets.util;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import com.hzya.frame.beanutil.BeanUtil;
|
import com.hzya.frame.beanutil.BeanUtil;
|
||||||
import com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto;
|
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.HeaderDto;
|
||||||
import com.hzya.frame.ttxofs.dto.returngoodordersearch.RerturnGoodsOrderSearchData;
|
import com.hzya.frame.ttxofs.dto.returngoodordersearch.RerturnGoodsOrderSearchData;
|
||||||
import com.hzya.frame.ttxofs.dto.returngoodordersearch.RerturnGoodsOrderSearchDetails;
|
import com.hzya.frame.ttxofs.dto.returngoodordersearch.RerturnGoodsOrderSearchDetails;
|
||||||
|
@ -30,6 +31,26 @@ public class OfsOrderAfterSalesAmountAllocationUtil {
|
||||||
|
|
||||||
Logger logger = LoggerFactory.getLogger(OfsOrderAfterSalesAmountAllocationUtil.class);
|
Logger logger = LoggerFactory.getLogger(OfsOrderAfterSalesAmountAllocationUtil.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TOC售后订单金额批量分摊
|
||||||
|
*
|
||||||
|
* @author liuyang
|
||||||
|
*/
|
||||||
|
public void batchTocSalesAmountAllocation(List<RerturnGoodsOrderSearchData> rerturnGoodsOrderSearchDataList) {
|
||||||
|
Assert.notNull(rerturnGoodsOrderSearchDataList, "rerturnGoodsOrderSearchDataList不能为空!");
|
||||||
|
|
||||||
|
rerturnGoodsOrderSearchDataList.forEach(rerturnGoodsOrderSearchData -> {
|
||||||
|
try {
|
||||||
|
tocSalesAmountAllocation(rerturnGoodsOrderSearchData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("batchTocSalesAmountAllocation方法抛出异常,批量处理TOC售后订单分摊异常", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
logger.info("=记录优惠金额分摊结果开始=");
|
||||||
|
printAmountOfMoneyNum(rerturnGoodsOrderSearchDataList);
|
||||||
|
logger.info("=记录优惠金额分摊结果完成=");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TOC销售金额分摊
|
* TOC销售金额分摊
|
||||||
*
|
*
|
||||||
|
@ -47,10 +68,10 @@ public class OfsOrderAfterSalesAmountAllocationUtil {
|
||||||
//暂时取零售价作为分类的标准,需要和万万确认一下
|
//暂时取零售价作为分类的标准,需要和万万确认一下
|
||||||
//已经和万万确认
|
//已经和万万确认
|
||||||
List<RerturnGoodsOrderSearchDetails> rerturnGoodsOrderSearchDetails = copyDetailsDto(detailsOld);
|
List<RerturnGoodsOrderSearchDetails> rerturnGoodsOrderSearchDetails = copyDetailsDto(detailsOld);
|
||||||
rerturnGoodsOrderSearchDetails.removeIf(dto -> dto.getMsrPrice() == null || !"0".equals(new BigDecimal(dto.getMsrPrice()).stripTrailingZeros().toPlainString()));
|
rerturnGoodsOrderSearchDetails.removeIf(dto -> dto.getMsrPrice() == null || "0".equals(new BigDecimal(dto.getMsrPrice()).stripTrailingZeros().toPlainString()));
|
||||||
|
|
||||||
//计算分摊百分比
|
//计算分摊百分比
|
||||||
calculatePercentage(rerturnGoodsOrderSearchData);
|
calculatePercentage(rerturnGoodsOrderSearchData, rerturnGoodsOrderSearchDetails, header.getCode());
|
||||||
|
|
||||||
String platformDiscounts = header.getPlatformDiscounts();
|
String platformDiscounts = header.getPlatformDiscounts();
|
||||||
String merchantDiscounts = header.getMerchantDiscounts();
|
String merchantDiscounts = header.getMerchantDiscounts();
|
||||||
|
@ -98,32 +119,32 @@ public class OfsOrderAfterSalesAmountAllocationUtil {
|
||||||
BigDecimal shareTargetExpertDiscounts = null;
|
BigDecimal shareTargetExpertDiscounts = null;
|
||||||
BigDecimal shareTargetPayDiscounts = null;
|
BigDecimal shareTargetPayDiscounts = null;
|
||||||
if (sharingRatio != null && targetPlatformDiscounts != null) {
|
if (sharingRatio != null && targetPlatformDiscounts != null) {
|
||||||
shareTargetPlatformDiscounts = targetPlatformDiscounts.multiply(sharingRatio).setScale(8, BigDecimal.ROUND_HALF_UP);
|
shareTargetPlatformDiscounts = targetPlatformDiscounts.multiply(sharingRatio).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
rerturnGoodsOrderSearchDetails1.setOriginalTargetPlatformDiscounts(targetPlatformDiscounts);
|
rerturnGoodsOrderSearchDetails1.setOriginalTargetPlatformDiscounts(targetPlatformDiscounts);
|
||||||
rerturnGoodsOrderSearchDetails1.setShareTargetPlatformDiscounts(shareTargetPlatformDiscounts);
|
rerturnGoodsOrderSearchDetails1.setShareTargetPlatformDiscounts(shareTargetPlatformDiscounts);
|
||||||
|
|
||||||
totalShareTargetPlatformDiscounts = totalShareTargetPlatformDiscounts.add(shareTargetPlatformDiscounts);
|
totalShareTargetPlatformDiscounts = totalShareTargetPlatformDiscounts.add(shareTargetPlatformDiscounts);
|
||||||
}
|
}
|
||||||
if (sharingRatio != null && targetMerchantDiscounts != null) {
|
if (sharingRatio != null && targetMerchantDiscounts != null) {
|
||||||
shareTargetMerchantDiscounts = targetMerchantDiscounts.multiply(sharingRatio).setScale(8, BigDecimal.ROUND_HALF_UP);
|
shareTargetMerchantDiscounts = targetMerchantDiscounts.multiply(sharingRatio).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
rerturnGoodsOrderSearchDetails1.setOriginalTargetMerchantDiscounts(targetMerchantDiscounts);
|
rerturnGoodsOrderSearchDetails1.setOriginalTargetMerchantDiscounts(targetMerchantDiscounts);
|
||||||
rerturnGoodsOrderSearchDetails1.setShareTargetMerchantDiscounts(shareTargetMerchantDiscounts);
|
rerturnGoodsOrderSearchDetails1.setShareTargetMerchantDiscounts(shareTargetMerchantDiscounts);
|
||||||
|
|
||||||
totalShareTargetMerchantDiscounts = totalShareTargetPlatformDiscounts.add(shareTargetMerchantDiscounts);
|
totalShareTargetMerchantDiscounts = totalShareTargetMerchantDiscounts.add(shareTargetMerchantDiscounts);
|
||||||
}
|
}
|
||||||
if (sharingRatio != null && targetExpertDiscounts != null) {
|
if (sharingRatio != null && targetExpertDiscounts != null) {
|
||||||
shareTargetExpertDiscounts = targetExpertDiscounts.multiply(sharingRatio).setScale(8, BigDecimal.ROUND_HALF_UP);
|
shareTargetExpertDiscounts = targetExpertDiscounts.multiply(sharingRatio).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
rerturnGoodsOrderSearchDetails1.setOriginalTargetExpertDiscounts(targetExpertDiscounts);
|
rerturnGoodsOrderSearchDetails1.setOriginalTargetExpertDiscounts(targetExpertDiscounts);
|
||||||
rerturnGoodsOrderSearchDetails1.setShareTargetExpertDiscounts(shareTargetExpertDiscounts);
|
rerturnGoodsOrderSearchDetails1.setShareTargetExpertDiscounts(shareTargetExpertDiscounts);
|
||||||
|
|
||||||
totalShareTargetExpertDiscounts = totalShareTargetPlatformDiscounts.add(shareTargetExpertDiscounts);
|
totalShareTargetExpertDiscounts = totalShareTargetExpertDiscounts.add(shareTargetExpertDiscounts);
|
||||||
}
|
}
|
||||||
if (sharingRatio != null && targetPayDiscounts != null) {
|
if (sharingRatio != null && targetPayDiscounts != null) {
|
||||||
shareTargetPayDiscounts = targetPayDiscounts.multiply(sharingRatio).setScale(8, BigDecimal.ROUND_HALF_UP);
|
shareTargetPayDiscounts = targetPayDiscounts.multiply(sharingRatio).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
rerturnGoodsOrderSearchDetails1.setOriginalTargetPayDiscounts(targetPayDiscounts);
|
rerturnGoodsOrderSearchDetails1.setOriginalTargetPayDiscounts(targetPayDiscounts);
|
||||||
rerturnGoodsOrderSearchDetails1.setShareTargetPayDiscounts(shareTargetPayDiscounts);
|
rerturnGoodsOrderSearchDetails1.setShareTargetPayDiscounts(shareTargetPayDiscounts);
|
||||||
|
|
||||||
totalShareTargetPayDiscounts = totalShareTargetPlatformDiscounts.add(shareTargetPayDiscounts);
|
totalShareTargetPayDiscounts = totalShareTargetPayDiscounts.add(shareTargetPayDiscounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
//如果是最后一行,则把尾差进行追加
|
//如果是最后一行,则把尾差进行追加
|
||||||
|
@ -162,10 +183,12 @@ public class OfsOrderAfterSalesAmountAllocationUtil {
|
||||||
* 计算百分比
|
* 计算百分比
|
||||||
* 分摊比例=零售价/sum(零售价)
|
* 分摊比例=零售价/sum(零售价)
|
||||||
*
|
*
|
||||||
* @param rerturnGoodsOrderSearchData OFS售后订单
|
* @param rerturnGoodsOrderSearchData OFS售后订单
|
||||||
|
* @param rerturnGoodsOrderSearchDetailsOld 过滤前的售后订单
|
||||||
|
* @param ofsCode OFS售后订单号
|
||||||
* @author liuyang
|
* @author liuyang
|
||||||
*/
|
*/
|
||||||
private void calculatePercentage(RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData) throws Exception {
|
private void calculatePercentage(RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData, List<RerturnGoodsOrderSearchDetails> rerturnGoodsOrderSearchDetailsOld, String ofsCode) throws Exception {
|
||||||
Assert.notNull(rerturnGoodsOrderSearchData, "headerDetailsDto2不能为空");
|
Assert.notNull(rerturnGoodsOrderSearchData, "headerDetailsDto2不能为空");
|
||||||
RerturnGoodsOrderSearchHeader header = rerturnGoodsOrderSearchData.getHeader();
|
RerturnGoodsOrderSearchHeader header = rerturnGoodsOrderSearchData.getHeader();
|
||||||
List<RerturnGoodsOrderSearchDetails> details = rerturnGoodsOrderSearchData.getDetails();
|
List<RerturnGoodsOrderSearchDetails> details = rerturnGoodsOrderSearchData.getDetails();
|
||||||
|
@ -173,14 +196,24 @@ public class OfsOrderAfterSalesAmountAllocationUtil {
|
||||||
BigDecimal sumActualPaymentAmountBigDecimal = sumActualPaymentAmount(details, header.getCode());
|
BigDecimal sumActualPaymentAmountBigDecimal = sumActualPaymentAmount(details, header.getCode());
|
||||||
for (int i = 0; i < details.size(); i++) {
|
for (int i = 0; i < details.size(); i++) {
|
||||||
RerturnGoodsOrderSearchDetails rerturnGoodsOrderSearchDetails = details.get(i);
|
RerturnGoodsOrderSearchDetails rerturnGoodsOrderSearchDetails = details.get(i);
|
||||||
|
|
||||||
String msrPrice = rerturnGoodsOrderSearchDetails.getMsrPrice();
|
|
||||||
BigDecimal msrPriceBigDecimal = new BigDecimal(msrPrice);
|
|
||||||
//如果实付金额为0则不进行分摊!
|
//如果实付金额为0则不进行分摊!
|
||||||
if (!"0".equals(msrPriceBigDecimal.stripTrailingZeros().toPlainString())) {
|
String msrPrice = rerturnGoodsOrderSearchDetails.getMsrPrice();
|
||||||
|
if (msrPrice != null && !"0".equals(new BigDecimal(msrPrice).stripTrailingZeros().toPlainString())) {
|
||||||
|
BigDecimal msrPriceBigDecimal = new BigDecimal(msrPrice);
|
||||||
//得到分摊比例
|
//得到分摊比例
|
||||||
BigDecimal percentageBigDecimal = msrPriceBigDecimal.divide(sumActualPaymentAmountBigDecimal, 20, BigDecimal.ROUND_HALF_UP).setScale(8, BigDecimal.ROUND_HALF_UP);
|
BigDecimal percentageBigDecimal = msrPriceBigDecimal.divide(sumActualPaymentAmountBigDecimal, 20, BigDecimal.ROUND_HALF_UP).setScale(8, BigDecimal.ROUND_HALF_UP);
|
||||||
rerturnGoodsOrderSearchDetails.setSharingRatio(percentageBigDecimal);
|
if (rerturnGoodsOrderSearchDetailsOld != null && rerturnGoodsOrderSearchDetailsOld.size() > 0) {
|
||||||
|
for (int j = 0; j < rerturnGoodsOrderSearchDetailsOld.size(); j++) {
|
||||||
|
RerturnGoodsOrderSearchDetails rerturnGoodsOrderSearchDetails1 = rerturnGoodsOrderSearchDetailsOld.get(j);
|
||||||
|
if (rerturnGoodsOrderSearchDetails1.getId() != null && rerturnGoodsOrderSearchDetails.getId() != null) {
|
||||||
|
if (rerturnGoodsOrderSearchDetails1.getId().equals(rerturnGoodsOrderSearchDetails.getId())) {
|
||||||
|
rerturnGoodsOrderSearchDetails1.setSharingRatio(percentageBigDecimal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.info("msrPrice(商品零售价)为空!OFS售后订单号:{} 存货编码:{}", ofsCode, rerturnGoodsOrderSearchDetails.getSkuCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,14 +234,20 @@ public class OfsOrderAfterSalesAmountAllocationUtil {
|
||||||
RerturnGoodsOrderSearchDetails rerturnGoodsOrderSearchDetails = details.get(i);
|
RerturnGoodsOrderSearchDetails rerturnGoodsOrderSearchDetails = details.get(i);
|
||||||
|
|
||||||
String msrPrice = rerturnGoodsOrderSearchDetails.getMsrPrice();
|
String msrPrice = rerturnGoodsOrderSearchDetails.getMsrPrice();
|
||||||
if (msrPrice == null || "".equals(msrPrice.trim())) {
|
// if (msrPrice == null || "".equals(msrPrice.trim())) {
|
||||||
Assert.state(false, "售后订单零售价不能为空 OFS售后订单号:{}", code);
|
// Assert.state(false, "售后订单零售价不能为空 OFS售后订单号:{}", code);
|
||||||
|
// }
|
||||||
|
if (msrPrice != null && !"0".equals(new BigDecimal(msrPrice).stripTrailingZeros().toPlainString())) {
|
||||||
|
BigDecimal msrPriceBigDecimal = new BigDecimal(msrPrice);
|
||||||
|
actualPaymentAmountBigDecimal = actualPaymentAmountBigDecimal.add(msrPriceBigDecimal);
|
||||||
|
logger.info("商品零售价:{}", msrPrice);
|
||||||
}
|
}
|
||||||
BigDecimal msrPriceBigDecimal = new BigDecimal(msrPrice);
|
|
||||||
actualPaymentAmountBigDecimal = actualPaymentAmountBigDecimal.add(msrPriceBigDecimal);
|
|
||||||
}
|
}
|
||||||
|
// if ("0".equals(actualPaymentAmountBigDecimal.stripTrailingZeros().toPlainString())) {
|
||||||
|
// Assert.state(false, "售后订单零售价(合并后)不能为0 OFS售后订单号:{}", code);
|
||||||
|
// }
|
||||||
if ("0".equals(actualPaymentAmountBigDecimal.stripTrailingZeros().toPlainString())) {
|
if ("0".equals(actualPaymentAmountBigDecimal.stripTrailingZeros().toPlainString())) {
|
||||||
Assert.state(false, "售后订单零售价(合并后)不能为0 OFS售后订单号:{}", code);
|
logger.info("售后订单零售价(合并后)全部为0,所有的明细行不参与分摊! OFS售后订单号:{}", code);
|
||||||
}
|
}
|
||||||
return actualPaymentAmountBigDecimal;
|
return actualPaymentAmountBigDecimal;
|
||||||
}
|
}
|
||||||
|
@ -254,4 +293,60 @@ public class OfsOrderAfterSalesAmountAllocationUtil {
|
||||||
logger.error("copyDetailsDtoOld方法newDetails或者detailsOld为空!");
|
logger.error("copyDetailsDtoOld方法newDetails或者detailsOld为空!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印金额参数
|
||||||
|
*
|
||||||
|
* @param rerturnGoodsOrderSearchDataList OFS售后订单集合
|
||||||
|
*/
|
||||||
|
public void printAmountOfMoneyNum(List<RerturnGoodsOrderSearchData> rerturnGoodsOrderSearchDataList) {
|
||||||
|
try {
|
||||||
|
if (rerturnGoodsOrderSearchDataList != null && rerturnGoodsOrderSearchDataList.size() > 0) {
|
||||||
|
for (int i = 0; i < rerturnGoodsOrderSearchDataList.size(); i++) {
|
||||||
|
RerturnGoodsOrderSearchData rerturnGoodsOrderSearchData = rerturnGoodsOrderSearchDataList.get(i);
|
||||||
|
RerturnGoodsOrderSearchHeader header = rerturnGoodsOrderSearchData.getHeader();
|
||||||
|
List<RerturnGoodsOrderSearchDetails> details = rerturnGoodsOrderSearchData.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++) {
|
||||||
|
RerturnGoodsOrderSearchDetails rerturnGoodsOrderSearchDetails = details.get(j);
|
||||||
|
|
||||||
|
logger.info("start================================");
|
||||||
|
logger.info("OFS售后订单明细主键:{}", rerturnGoodsOrderSearchDetails.getId());
|
||||||
|
if (rerturnGoodsOrderSearchDetails.getSharingRatio() != null) {
|
||||||
|
logger.info("分摊比例:{}", rerturnGoodsOrderSearchDetails.getSharingRatio().stripTrailingZeros().toPlainString());
|
||||||
|
} else {
|
||||||
|
logger.info("分摊比例:无");
|
||||||
|
}
|
||||||
|
logger.info("商品零售价:{}", rerturnGoodsOrderSearchDetails.getMsrPrice());
|
||||||
|
if (rerturnGoodsOrderSearchDetails.getShareTargetPlatformDiscounts() != null) {
|
||||||
|
logger.info("分摊平台优惠:{}", rerturnGoodsOrderSearchDetails.getShareTargetPlatformDiscounts().stripTrailingZeros().toPlainString());
|
||||||
|
} else {
|
||||||
|
logger.info("分摊平台优惠:无");
|
||||||
|
}
|
||||||
|
if (rerturnGoodsOrderSearchDetails.getShareTargetMerchantDiscounts() != null) {
|
||||||
|
logger.info("分摊商家优惠:{}", rerturnGoodsOrderSearchDetails.getShareTargetMerchantDiscounts().stripTrailingZeros().toPlainString());
|
||||||
|
} else {
|
||||||
|
logger.info("分摊商家优惠:无");
|
||||||
|
}
|
||||||
|
if (rerturnGoodsOrderSearchDetails.getShareTargetExpertDiscounts() != null) {
|
||||||
|
logger.info("分摊达人优惠:{}", rerturnGoodsOrderSearchDetails.getShareTargetExpertDiscounts().stripTrailingZeros().toPlainString());
|
||||||
|
} else {
|
||||||
|
logger.info("分摊达人优惠:无");
|
||||||
|
}
|
||||||
|
if (rerturnGoodsOrderSearchDetails.getShareTargetPayDiscounts() != null) {
|
||||||
|
logger.info("分摊支付优惠:{}", rerturnGoodsOrderSearchDetails.getShareTargetPayDiscounts().stripTrailingZeros().toPlainString());
|
||||||
|
} else {
|
||||||
|
logger.info("分摊支付优惠:无");
|
||||||
|
}
|
||||||
|
logger.info("end================================");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("printAmountOfMoneyNum方法抛出异常", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -203,11 +203,13 @@ public class OfsOrderSaleAmountAllocationUtil {
|
||||||
BigDecimal totalPayAmountBigDecimal = new BigDecimal(totalPayAmount);
|
BigDecimal totalPayAmountBigDecimal = new BigDecimal(totalPayAmount);
|
||||||
//得到分摊比例
|
//得到分摊比例
|
||||||
BigDecimal percentageBigDecimal = totalPayAmountBigDecimal.divide(sumActualPaymentAmountBigDecimal, 20, BigDecimal.ROUND_HALF_UP).setScale(8, BigDecimal.ROUND_HALF_UP);
|
BigDecimal percentageBigDecimal = totalPayAmountBigDecimal.divide(sumActualPaymentAmountBigDecimal, 20, BigDecimal.ROUND_HALF_UP).setScale(8, BigDecimal.ROUND_HALF_UP);
|
||||||
for (int j = 0; j < details.size(); j++) {
|
if (details != null && details.size() > 0) {
|
||||||
DetailsDto detailsDto1 = details.get(j);
|
for (int j = 0; j < details.size(); j++) {
|
||||||
if (detailsDto1.getId() != null && detailsDto.getId() != null) {
|
DetailsDto detailsDto1 = details.get(j);
|
||||||
if (detailsDto1.getId().equals(detailsDto.getId())) {
|
if (detailsDto1.getId() != null && detailsDto.getId() != null) {
|
||||||
details.get(j).setSharingRatio(percentageBigDecimal);
|
if (detailsDto1.getId().equals(detailsDto.getId())) {
|
||||||
|
details.get(j).setSharingRatio(percentageBigDecimal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -346,8 +348,8 @@ public class OfsOrderSaleAmountAllocationUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
logger.error("printNum方法抛出异常", e);
|
logger.error("printAmountOfMoneyNum方法抛出异常", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
package com.hzya.frame.plugin.lets.util;
|
||||||
|
|
||||||
|
import com.hzya.frame.WebappApplication;
|
||||||
|
import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSoSaleOutVo;
|
||||||
|
import com.hzya.frame.ttxofs.dto.returngoodordersearch.RerturnGoodsOrderSearchData;
|
||||||
|
import com.hzya.frame.ttxofs.dto.returngoodordersearch.RerturnGoodsOrderSearchDetails;
|
||||||
|
import com.hzya.frame.ttxofs.dto.returngoodordersearch.RerturnGoodsOrderSearchHeader;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:liuyang
|
||||||
|
* @Package:com.hzya.frame.plugin.lets.util
|
||||||
|
* @Project:kangarooDataCenterV3
|
||||||
|
* @name:OfsOrderAfterSalesAmountAllocationUtilTest
|
||||||
|
* @Date:2024/10/10 14:22
|
||||||
|
* @Filename:OfsOrderAfterSalesAmountAllocationUtilTest
|
||||||
|
*/
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest(classes = WebappApplication.class)
|
||||||
|
public class OfsOrderAfterSalesAmountAllocationUtilTest {
|
||||||
|
|
||||||
|
Logger logger = LoggerFactory.getLogger(OfsOrderAfterSalesAmountAllocationUtilTest.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OfsOrderAfterSalesAmountAllocationUtil ofsOrderAfterSalesAmountAllocationUtil;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AfterSalesOrderUtil afterSalesOrderUtil;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void tocSalesAmountAllocation() {
|
||||||
|
try {
|
||||||
|
List<RerturnGoodsOrderSearchData> rerturnGoodsOrderSearchDataList = new ArrayList<>();
|
||||||
|
|
||||||
|
QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
|
||||||
|
// queryOfsSoSaleOutVo.setCode("LETS-RO2024091900000001");
|
||||||
|
queryOfsSoSaleOutVo.setCode("LETS-RO2023082300000025");
|
||||||
|
afterSalesOrderUtil.getBatchOfsRertunOrder(queryOfsSoSaleOutVo, rerturnGoodsOrderSearchDataList, 1L);
|
||||||
|
|
||||||
|
//测试一:所有的优惠金额都为零
|
||||||
|
// RerturnGoodsOrderSearchHeader header = rerturnGoodsOrderSearchDataList.get(0).getHeader();
|
||||||
|
// header.setPlatformDiscounts("0");
|
||||||
|
// header.setMerchantDiscounts("0");
|
||||||
|
// header.setExpertDiscounts("0");
|
||||||
|
// header.setPayDiscounts("0");
|
||||||
|
|
||||||
|
//测试二:所有优惠的金额都为null
|
||||||
|
// RerturnGoodsOrderSearchHeader header = rerturnGoodsOrderSearchDataList.get(0).getHeader();
|
||||||
|
// header.setPlatformDiscounts(null);
|
||||||
|
// header.setMerchantDiscounts(null);
|
||||||
|
// header.setExpertDiscounts(null);
|
||||||
|
// header.setPayDiscounts(null);
|
||||||
|
|
||||||
|
//测试三:全部存在优惠金额数值
|
||||||
|
// RerturnGoodsOrderSearchHeader header = rerturnGoodsOrderSearchDataList.get(0).getHeader();
|
||||||
|
// header.setPlatformDiscounts("3.75");
|
||||||
|
// header.setMerchantDiscounts("7.88");
|
||||||
|
// header.setExpertDiscounts("4.22");
|
||||||
|
// header.setPayDiscounts("1.96");
|
||||||
|
|
||||||
|
//测试四:没有商品零售价过滤
|
||||||
|
// List<RerturnGoodsOrderSearchDetails> details = rerturnGoodsOrderSearchDataList.get(0).getDetails();
|
||||||
|
// details.get(1).setMsrPrice(null);
|
||||||
|
// RerturnGoodsOrderSearchHeader header = rerturnGoodsOrderSearchDataList.get(0).getHeader();
|
||||||
|
// header.setPlatformDiscounts("3.75");
|
||||||
|
// header.setMerchantDiscounts("7.88");
|
||||||
|
// header.setExpertDiscounts("4.22");
|
||||||
|
// header.setPayDiscounts("1.96");
|
||||||
|
|
||||||
|
//测试五:部分金额不存在
|
||||||
|
// RerturnGoodsOrderSearchHeader header = rerturnGoodsOrderSearchDataList.get(0).getHeader();
|
||||||
|
// header.setPlatformDiscounts("3.75");
|
||||||
|
// header.setMerchantDiscounts("7.88");
|
||||||
|
// header.setExpertDiscounts(null);
|
||||||
|
// header.setPayDiscounts(null);
|
||||||
|
|
||||||
|
//测试六:商品零售价为0
|
||||||
|
// List<RerturnGoodsOrderSearchDetails> details = rerturnGoodsOrderSearchDataList.get(0).getDetails();
|
||||||
|
// details.get(0).setMsrPrice("0");
|
||||||
|
// details.get(1).setMsrPrice("0");
|
||||||
|
// RerturnGoodsOrderSearchHeader header = rerturnGoodsOrderSearchDataList.get(0).getHeader();
|
||||||
|
// header.setPlatformDiscounts("3.75");
|
||||||
|
// header.setMerchantDiscounts("7.88");
|
||||||
|
// header.setExpertDiscounts("4.22");
|
||||||
|
// header.setPayDiscounts("1.96");
|
||||||
|
|
||||||
|
ofsOrderAfterSalesAmountAllocationUtil.tocSalesAmountAllocation(rerturnGoodsOrderSearchDataList.get(0));
|
||||||
|
//打印结果
|
||||||
|
ofsOrderAfterSalesAmountAllocationUtil.printAmountOfMoneyNum(rerturnGoodsOrderSearchDataList);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue