|
|
|
@ -1415,7 +1415,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|
|
|
|
} else if (sceneType.equals("tran")) {
|
|
|
|
|
updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiryV2(errorHeaderDetailsDtoDtoList);
|
|
|
|
|
} else {
|
|
|
|
|
Assert.state(false, "无法识别的场景类型:stock、tran");
|
|
|
|
|
Assert.state(false, "无法识别的场景类型:stock、tran请传递正确的字符串");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return sonDetailsDtoList;
|
|
|
|
@ -1681,48 +1681,96 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|
|
|
|
HeaderDto header = sonDetailsDto.getHeader();//销售出库单表头
|
|
|
|
|
BdInvmandocEntity bdInvmandocEntity = sonDetailsDto.getBdInvmandocEntity();//存货管理档案
|
|
|
|
|
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto = sonDetailsDto.getHeaderDetailsDto();//OFS销售订单
|
|
|
|
|
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = headerDetailsDto.getHeader();
|
|
|
|
|
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto> details = headerDetailsDto.getDetails();
|
|
|
|
|
|
|
|
|
|
//查找销售出库明细对应的销售订单明细行
|
|
|
|
|
com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto targetDetails = null;
|
|
|
|
|
for (int j = 0; j < details.size(); j++) {
|
|
|
|
|
com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto detailsDto = details.get(j);
|
|
|
|
|
if (detailsDto.getId() != null && sonDetailsDto.getRefOrderDetailId() != null) {
|
|
|
|
|
if (detailsDto.getId().equals(sonDetailsDto.getRefOrderDetailId())) {
|
|
|
|
|
targetDetails = detailsDto;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Assert.notNull(targetDetails, "根据销售出库单明细行(refOrderDetailId)无法匹配销售订单明细行", sonDetailsDto.getRefOrderDetailId());
|
|
|
|
|
|
|
|
|
|
//实付金额/实发数量
|
|
|
|
|
//OFS销售订单实付金额:totalPayAmount
|
|
|
|
|
//OFS销售出库单实付金额:totalPayAmount
|
|
|
|
|
//是一样的字段,目前暂时取销售出库单对应的totalPayAmount
|
|
|
|
|
String totalPayAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, sonDetailsDto, mapList);
|
|
|
|
|
StringBuffer calculationFormulaStr = new StringBuffer();
|
|
|
|
|
String totalPayAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, sonDetailsDto, mapList, calculationFormulaStr);
|
|
|
|
|
if (totalPayAmount == null) {
|
|
|
|
|
calculationFormulaStr.append("取O应收金额:");
|
|
|
|
|
//触发取实付金额的逻辑,因此需要累加:O实付金额+O达人优惠+O支付优惠+O平台优惠
|
|
|
|
|
//取O实付金额
|
|
|
|
|
// totalPayAmount = sonDetailsDto.getTotalPayAmount();
|
|
|
|
|
totalPayAmount = accumulatedDiscounts(sonDetailsDto, headerDetailsDto);
|
|
|
|
|
// totalPayAmount = accumulatedDiscounts(sonDetailsDto, headerDetailsDto, targetDetails);
|
|
|
|
|
//和万万确认,O销售出库单明细行应收金额=O销售订单明细行应收金额/O销售订单明细行请求数量*O销售出库单明细行实发数量
|
|
|
|
|
//这里做好必要的参数验证抛出异常
|
|
|
|
|
Assert.notNull(targetDetails.getPayableAmount(), "O应收金额不能为空 O销售订单编码:{} O明细行主键:{}", header1.getCode(), targetDetails.getId());
|
|
|
|
|
Assert.state(!"".equals(targetDetails.getPayableAmount()), "O应收金额不能为空 O销售订单编码:{} O明细行主键:{}", header1.getCode(), targetDetails.getId());
|
|
|
|
|
|
|
|
|
|
Assert.notNull(targetDetails.getRequestQty(), "O请求数量不能为空 O销售订单编码:{} O明细行主键:{}", header1.getCode(), targetDetails.getId());
|
|
|
|
|
Assert.state(!"".equals(targetDetails.getRequestQty()), "O请求数量不能为空 O销售订单编码:{} O明细行主键:{}", header1.getCode(), targetDetails.getId());
|
|
|
|
|
|
|
|
|
|
Assert.notNull(sonDetailsDto.getShipQty(), "O实发数量不能为空 O销售出库单编码:{} O明细行主键:{}", header.getCode(), sonDetailsDto.getId());
|
|
|
|
|
Assert.state(!"".equals(sonDetailsDto.getShipQty()), "O实发数量不能为空 O销售出库单编码:{} O明细行主键:{}", header.getCode(), sonDetailsDto.getId());
|
|
|
|
|
|
|
|
|
|
BigDecimal detailedLineUnitPrice = new BigDecimal(targetDetails.getPayableAmount()).divide(new BigDecimal(targetDetails.getRequestQty()), 20, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
BigDecimal totalPayAmountBigDecimal = detailedLineUnitPrice.multiply(new BigDecimal(sonDetailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
totalPayAmount = totalPayAmountBigDecimal.stripTrailingZeros().toPlainString();
|
|
|
|
|
|
|
|
|
|
String format = StrUtil.format("{}/{}*{}", targetDetails.getPayableAmount(), targetDetails.getRequestQty(), sonDetailsDto.getShipQty());
|
|
|
|
|
calculationFormulaStr.append(format);
|
|
|
|
|
} else {
|
|
|
|
|
//取结存单价、或者采购单价
|
|
|
|
|
//和李佳妮确认取采购价、结存价的情况下,不需要累加优惠金额
|
|
|
|
|
BigDecimal totalPayAmountBigDecimal = new BigDecimal(totalPayAmount);
|
|
|
|
|
totalPayAmount = totalPayAmountBigDecimal.multiply(new BigDecimal(sonDetailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString();
|
|
|
|
|
// totalPayAmount = totalPayAmountBigDecimal.multiply(new BigDecimal(sonDetailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString();
|
|
|
|
|
totalPayAmount = totalPayAmountBigDecimal.stripTrailingZeros().toPlainString();
|
|
|
|
|
}
|
|
|
|
|
Assert.notNull(totalPayAmount, "应收金额不能为空(应收金额=实付金额+达人优惠+支付优惠+平台优惠) 销售出库单编码:{} 出库单明细主键:{}", header.getCode(), sonDetailsDto.getId());
|
|
|
|
|
Assert.notNull(sonDetailsDto.getShipQty(), "实发数量不能为空 销售出库单编码:{} 出库单明细主键:{}", header.getCode(), sonDetailsDto.getId());
|
|
|
|
|
// Assert.notNull(sonDetailsDto.getShipQty(), "实发数量不能为空 销售出库单编码:{} 出库单明细主键:{}", header.getCode(), sonDetailsDto.getId());
|
|
|
|
|
|
|
|
|
|
// BigDecimal totalPayAmountBigDecimal = new BigDecimal("0");
|
|
|
|
|
//O出库单明细行实付金额=O销售订单明细行的实付金额/销售订单明细行的请求数量*O销售出库单明细行实发数量
|
|
|
|
|
//O应收金额=O实付金额+O达人优惠+O支付优惠+O平台优惠
|
|
|
|
|
//这里弄错了,这一步应该先算出来!O实付金额=O应收金额/O请求数量*O实发数量
|
|
|
|
|
// if (!"0".equals(new BigDecimal(totalPayAmount).stripTrailingZeros().toPlainString())) {
|
|
|
|
|
// //O应收金额/O请求数量
|
|
|
|
|
// Assert.notNull(sonDetailsDto.getRequestQty(), "请求数量不能为空!");
|
|
|
|
|
// if ("0".equals(new BigDecimal(sonDetailsDto.getRequestQty()).stripTrailingZeros().toPlainString())) {
|
|
|
|
|
// Assert.state(false, "请求数量不能为0!");
|
|
|
|
|
// }
|
|
|
|
|
// if ("0".equals(new BigDecimal(sonDetailsDto.getShipQty()).stripTrailingZeros().toPlainString())) {
|
|
|
|
|
// Assert.state(false, "实发数量不能为空!");
|
|
|
|
|
// }
|
|
|
|
|
// BigDecimal divide = new BigDecimal(totalPayAmount).divide(new BigDecimal(sonDetailsDto.getRequestQty()), 20, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
// totalPayAmountBigDecimal = divide.multiply(new BigDecimal(sonDetailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
BigDecimal totalPayAmountBigDecimal = new BigDecimal("0");
|
|
|
|
|
//O实付金额=O应收金额/O请求数量*O实发数量
|
|
|
|
|
if (!"0".equals(new BigDecimal(totalPayAmount).stripTrailingZeros().toPlainString())) {
|
|
|
|
|
//O应收金额/O请求数量
|
|
|
|
|
Assert.notNull(sonDetailsDto.getRequestQty(), "请求数量不能为空!");
|
|
|
|
|
if ("0".equals(new BigDecimal(sonDetailsDto.getRequestQty()).stripTrailingZeros().toPlainString())) {
|
|
|
|
|
Assert.state(false, "请求数量不能为0!");
|
|
|
|
|
}
|
|
|
|
|
if ("0".equals(new BigDecimal(sonDetailsDto.getShipQty()).stripTrailingZeros().toPlainString())) {
|
|
|
|
|
Assert.state(false, "实发数量不能为空!");
|
|
|
|
|
}
|
|
|
|
|
BigDecimal divide = new BigDecimal(totalPayAmount).divide(new BigDecimal(sonDetailsDto.getRequestQty()), 20, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
totalPayAmountBigDecimal = divide.multiply(new BigDecimal(sonDetailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
}
|
|
|
|
|
BigDecimal shipQtyBigDecimal = new BigDecimal(sonDetailsDto.getShipQty());
|
|
|
|
|
BigDecimal totalPayAmountBigDecimal = new BigDecimal(totalPayAmount);
|
|
|
|
|
|
|
|
|
|
groupTotalPayAmount = groupTotalPayAmount.add(totalPayAmountBigDecimal);
|
|
|
|
|
groupShipQty = groupShipQty.add(shipQtyBigDecimal);
|
|
|
|
|
|
|
|
|
|
//把销售订单明细行对应的优惠金额保存到销售出库单明细行一份,便于存储到中台的底表
|
|
|
|
|
sonDetailsDto.setCalculateAccountsReceivable(totalPayAmount);
|
|
|
|
|
sonDetailsDto.setCalculationFormula(calculationFormulaStr.toString());
|
|
|
|
|
sonDetailsDto.setPlatformDiscounts(targetDetails.getPlatformDiscounts());
|
|
|
|
|
sonDetailsDto.setPayDiscounts(targetDetails.getPayDiscounts());
|
|
|
|
|
sonDetailsDto.setExpertDiscounts(targetDetails.getExpertDiscounts());
|
|
|
|
|
sonDetailsDto.setMerchantDiscounts(targetDetails.getMerchantDiscounts());
|
|
|
|
|
}
|
|
|
|
|
SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(0);
|
|
|
|
|
sonDetailsDto.setGroupShipQty(groupShipQty);//汇总好的实发数量
|
|
|
|
|
sonDetailsDto.setGroupTotalPayAmount(groupTotalPayAmount);//汇总总金额
|
|
|
|
|
|
|
|
|
|
//累加4个优惠金额,放在第0号元素
|
|
|
|
|
//累加4个优惠金额,放在第0号对象,作为合并之后的对象
|
|
|
|
|
// accumulationDiscountAmount(sonDetailsDtoList);
|
|
|
|
|
accumulatedDiscountAmountDef(sonDetailsDtoList);
|
|
|
|
|
|
|
|
|
@ -2389,7 +2437,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|
|
|
|
|
|
|
|
|
//以50行为一个批次更新状态
|
|
|
|
|
if (tocofsSaleoutDetailedEntityList.size() > 0) {
|
|
|
|
|
List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50);
|
|
|
|
|
List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 100);
|
|
|
|
|
for (int i = 0; i < splitListByCount.size(); i++) {
|
|
|
|
|
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i);
|
|
|
|
|
iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock1(tocofsSaleoutDetailedEntityList1);
|
|
|
|
@ -2451,7 +2499,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|
|
|
|
|
|
|
|
|
//以50行为一个批次更新状态
|
|
|
|
|
if (tocofsSaleoutDetailedEntityList.size() > 0) {
|
|
|
|
|
List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50);
|
|
|
|
|
List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 100);
|
|
|
|
|
for (int i = 0; i < splitListByCount.size(); i++) {
|
|
|
|
|
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i);
|
|
|
|
|
iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock1V2(tocofsSaleoutDetailedEntityList1);
|
|
|
|
@ -2496,6 +2544,12 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|
|
|
|
tocofsSaleoutDetailedEntity.setNewpushdate(getNewDateStr());
|
|
|
|
|
tocofsSaleoutDetailedEntity.setNewtransmitinfo(finalNewTransmitInfo);
|
|
|
|
|
tocofsSaleoutDetailedEntity.setNewstate(newstate);
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef7(sonDetailsDto.getCalculateAccountsReceivable());//计算应收
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef8(sonDetailsDto.getCalculationFormula());//计算公式
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef9(sonDetailsDto.getPlatformDiscounts());//平台优惠
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef10(sonDetailsDto.getPayDiscounts());//支付优惠
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef11(sonDetailsDto.getExpertDiscounts());//达人优惠
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef12(sonDetailsDto.getMerchantDiscounts());//商家优惠
|
|
|
|
|
if (successY.equals(newstate)) {
|
|
|
|
|
tocofsSaleoutDetailedEntity.setNewsystemnumber(newsystemnumber);
|
|
|
|
|
tocofsSaleoutDetailedEntity.setNewsystemprimary(newsystemprimary);
|
|
|
|
@ -2505,7 +2559,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|
|
|
|
|
|
|
|
|
//以50行为一个批次,推送到Mysql
|
|
|
|
|
if (tocofsSaleoutDetailedEntityList.size() > 0) {
|
|
|
|
|
List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50);
|
|
|
|
|
List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 100);
|
|
|
|
|
for (int i = 0; i < splitListByCount.size(); i++) {
|
|
|
|
|
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i);
|
|
|
|
|
iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock2(tocofsSaleoutDetailedEntityList1);
|
|
|
|
@ -2550,6 +2604,12 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef1(getNewDateStr());
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef2(finalNewTransmitInfo);
|
|
|
|
|
tocofsSaleoutDetailedEntity.setNewstate2(newstate);
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef7(sonDetailsDto.getCalculateAccountsReceivable());//计算应收
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef8(sonDetailsDto.getCalculationFormula());//计算公式
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef9(sonDetailsDto.getPlatformDiscounts());//平台优惠
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef10(sonDetailsDto.getPayDiscounts());//支付优惠
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef11(sonDetailsDto.getExpertDiscounts());//达人优惠
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef12(sonDetailsDto.getMerchantDiscounts());//商家优惠
|
|
|
|
|
if (successY.equals(newstate)) {
|
|
|
|
|
tocofsSaleoutDetailedEntity.setNewsystemnumber2(newsystemnumber);
|
|
|
|
|
tocofsSaleoutDetailedEntity.setNewsystemprimary2(newsystemprimary);
|
|
|
|
@ -2604,6 +2664,12 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef3(getNewDateStr());
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef4(finalNewTransmitInfo);
|
|
|
|
|
tocofsSaleoutDetailedEntity.setNewstate3(newstate);
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef7(sonDetailsDto.getCalculateAccountsReceivable());//计算应收
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef8(sonDetailsDto.getCalculationFormula());//计算公式
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef9(sonDetailsDto.getPlatformDiscounts());//平台优惠
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef10(sonDetailsDto.getPayDiscounts());//支付优惠
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef11(sonDetailsDto.getExpertDiscounts());//达人优惠
|
|
|
|
|
tocofsSaleoutDetailedEntity.setDef12(sonDetailsDto.getMerchantDiscounts());//商家优惠
|
|
|
|
|
if (successY.equals(newstate)) {
|
|
|
|
|
tocofsSaleoutDetailedEntity.setNewsystemnumber3(newsystemnumber);
|
|
|
|
|
tocofsSaleoutDetailedEntity.setNewsystemprimary3(newsystemprimary);
|
|
|
|
@ -2613,7 +2679,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|
|
|
|
|
|
|
|
|
//以50行为一个批次,推送到Mysql
|
|
|
|
|
if (tocofsSaleoutDetailedEntityList.size() > 0) {
|
|
|
|
|
List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 200);
|
|
|
|
|
List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 100);
|
|
|
|
|
for (int i = 0; i < splitListByCount.size(); i++) {
|
|
|
|
|
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i);
|
|
|
|
|
iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock4(tocofsSaleoutDetailedEntityList1);
|
|
|
|
@ -3024,20 +3090,23 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|
|
|
|
/**
|
|
|
|
|
* 获取结存金额或者采购金额
|
|
|
|
|
*
|
|
|
|
|
* @param isCheckShopChoose true取OFS实付金额、false取结存金额或者采购价
|
|
|
|
|
* @param bdInvmandocEntity 存货基本档案
|
|
|
|
|
* @param header 对应的销售出库单表头
|
|
|
|
|
* @param sonDetailsDto 对应的销售出库单明细行对象
|
|
|
|
|
* @param mapList 0结存价1采购价
|
|
|
|
|
* @param isCheckShopChoose true取OFS实付金额、false取结存金额或者采购价
|
|
|
|
|
* @param bdInvmandocEntity 存货基本档案
|
|
|
|
|
* @param header 对应的销售出库单表头
|
|
|
|
|
* @param sonDetailsDto 对应的销售出库单明细行对象
|
|
|
|
|
* @param mapList 0结存价1采购价
|
|
|
|
|
* @param calculationFormulaStr 计算公式
|
|
|
|
|
* @author liuyang
|
|
|
|
|
*/
|
|
|
|
|
private String getFloorPrice(Boolean isCheckShopChoose, BdInvmandocEntity bdInvmandocEntity, HeaderDto header, SonDetailsDto sonDetailsDto, List<Map> mapList) throws Exception {
|
|
|
|
|
private String getFloorPrice(Boolean isCheckShopChoose, BdInvmandocEntity bdInvmandocEntity, HeaderDto header, SonDetailsDto sonDetailsDto, List<Map> mapList, StringBuffer calculationFormulaStr) throws Exception {
|
|
|
|
|
Assert.notNull(isCheckShopChoose, "isCheckShopChoose不能为空");
|
|
|
|
|
Assert.notNull(bdInvmandocEntity, "bdInvmandocEntity不能为空");
|
|
|
|
|
Assert.notNull(header, "header不能为空");
|
|
|
|
|
Assert.notNull(sonDetailsDto, "detailsDto不能为空");
|
|
|
|
|
Assert.notNull(mapList, "mapList不能为空");
|
|
|
|
|
Assert.notNull(calculationFormulaStr, "calculationFormulaStr不能为空");
|
|
|
|
|
|
|
|
|
|
//totalPayAmount只能为金额,或者为空
|
|
|
|
|
String totalPayAmount = null;
|
|
|
|
|
if (isCheckShopChoose) {
|
|
|
|
|
IaPeriodaccountEntity iaPeriodaccountEntity1 = null;
|
|
|
|
@ -3046,7 +3115,9 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|
|
|
|
iaPeriodaccountEntity1 = stringIaPeriodaccountEntityMap.get(bdInvmandocEntity.getPkInvmandoc());
|
|
|
|
|
}
|
|
|
|
|
if (iaPeriodaccountEntity1 != null) {
|
|
|
|
|
//结存金额=U结存金额/U结存数量*O明细行实出数量
|
|
|
|
|
logger.info("店铺:{} 取O结存价", header.getStoreCode());
|
|
|
|
|
calculationFormulaStr.append("取结存价:");
|
|
|
|
|
|
|
|
|
|
//结存金额
|
|
|
|
|
String nabmny = iaPeriodaccountEntity1.getNabmny();
|
|
|
|
@ -3063,16 +3134,21 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|
|
|
|
BigDecimal nabnumBigDecimal = new BigDecimal(nabnum);
|
|
|
|
|
|
|
|
|
|
if (!"0".equals(nabmnyBigDecimal.stripTrailingZeros().toPlainString()) && !"0".equals(nabnumBigDecimal.stripTrailingZeros().toPlainString())) {
|
|
|
|
|
//得到结存单价
|
|
|
|
|
BigDecimal bigDecimal = nabmnyBigDecimal.divide(nabnumBigDecimal, 20, BigDecimal.ROUND_HALF_UP).setScale(4, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
totalPayAmount = bigDecimal.stripTrailingZeros().toPlainString();
|
|
|
|
|
String format = StrUtil.format("{}/{}*{}", nabmnyBigDecimal.stripTrailingZeros().toPlainString(), nabnumBigDecimal.stripTrailingZeros().toPlainString(), sonDetailsDto.getShipQty());
|
|
|
|
|
calculationFormulaStr.append(format);
|
|
|
|
|
BigDecimal bigDecimal = nabmnyBigDecimal.divide(nabnumBigDecimal, 20, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
BigDecimal totalPayAmountBigDecimal = bigDecimal.multiply(new BigDecimal(sonDetailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
totalPayAmount = totalPayAmountBigDecimal.stripTrailingZeros().toPlainString();
|
|
|
|
|
} else {
|
|
|
|
|
//如果结存金额为或者数量为0,则设置为0
|
|
|
|
|
calculationFormulaStr.append("0");
|
|
|
|
|
totalPayAmount = "0";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//取采购价
|
|
|
|
|
//采购金额=O原币含税单价*O明细行实出数量
|
|
|
|
|
logger.info("店铺:{} 取O采购价", header.getStoreCode());
|
|
|
|
|
calculationFormulaStr.append("取采购价:");
|
|
|
|
|
PoOrderBEntity poOrderBEntity = null;
|
|
|
|
|
if (mapList != null && mapList.size() > 0) {
|
|
|
|
|
Map<String, PoOrderBEntity> poOrderBEntityList = (Map<String, PoOrderBEntity>) mapList.get(1);
|
|
|
|
@ -3082,11 +3158,16 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|
|
|
|
}
|
|
|
|
|
if (poOrderBEntity != null) {
|
|
|
|
|
String norgtaxprice = poOrderBEntity.getNorgtaxprice();
|
|
|
|
|
if ("0".equals(new BigDecimal(norgtaxprice).stripTrailingZeros().toPlainString())) {
|
|
|
|
|
Assert.notNull(norgtaxprice, "U8C采购订单明细行存在「原币含税单价」为空");
|
|
|
|
|
if (!"0".equals(new BigDecimal(norgtaxprice).stripTrailingZeros().toPlainString())) {
|
|
|
|
|
String format = StrUtil.format("{}*{}", norgtaxprice, sonDetailsDto.getShipQty());
|
|
|
|
|
calculationFormulaStr.append(format);
|
|
|
|
|
BigDecimal totalPayAmountBigDecimal = new BigDecimal(norgtaxprice).multiply(new BigDecimal(sonDetailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
totalPayAmount = totalPayAmountBigDecimal.stripTrailingZeros().toPlainString();
|
|
|
|
|
} else {
|
|
|
|
|
//如果采购单价都为0,那么金额也为0
|
|
|
|
|
totalPayAmount = "0";
|
|
|
|
|
} else {
|
|
|
|
|
totalPayAmount = norgtaxprice;
|
|
|
|
|
calculationFormulaStr.append("0");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Assert.state(false, "店铺:{} 存货管理档案主键:{} 既没有结存价、也没有采购价!", header.getStoreCode(), bdInvmandocEntity.getPkInvmandoc());
|
|
|
|
@ -3301,28 +3382,36 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|
|
|
|
*
|
|
|
|
|
* @param sonDetailsDto OFS销售出库单明细行
|
|
|
|
|
* @param headerDetailsDto OFS销售订单表头对象
|
|
|
|
|
* @param targetDetails 对应的销售出库单明细行
|
|
|
|
|
*/
|
|
|
|
|
private String accumulatedDiscounts(SonDetailsDto sonDetailsDto, com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto) throws Exception {
|
|
|
|
|
private String accumulatedDiscounts(SonDetailsDto sonDetailsDto, com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto, com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto targetDetails) throws Exception {
|
|
|
|
|
Assert.notNull(sonDetailsDto, "sonDetailsDto OFS销售出库单明细不能为空!");
|
|
|
|
|
Assert.notNull(headerDetailsDto, "headerDetailsDto OFS销售订单不能为空!");
|
|
|
|
|
Assert.notNull(targetDetails, "targetDetails 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());
|
|
|
|
|
// 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();
|
|
|
|
|
|
|
|
|
|
//O实付金额=O应收金额/O请求数量*O实发数量
|
|
|
|
|
BigDecimal divide = new BigDecimal(totalPayAmount).divide(new BigDecimal(sonDetailsDto.getRequestQty()), 20, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
// totalPayAmountBigDecimal = divide.multiply(new BigDecimal(sonDetailsDto.getShipQty())).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//商家优惠:不处理!!!仅保存
|
|
|
|
|
String merchantDiscounts = targetDetails.getMerchantDiscounts();
|
|
|
|
|
//达人优惠
|
|
|
|
@ -3332,10 +3421,10 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|
|
|
|
//平台优惠
|
|
|
|
|
String platformDiscounts = targetDetails.getPlatformDiscounts();
|
|
|
|
|
|
|
|
|
|
// sonDetailsDto.setVdef4(platformDiscounts);
|
|
|
|
|
// sonDetailsDto.setVdef5(payDiscounts);
|
|
|
|
|
// sonDetailsDto.setVdef6(expertDiscounts);
|
|
|
|
|
// sonDetailsDto.setVdef7(merchantDiscounts);
|
|
|
|
|
// sonDetailsDto.setPlatformDiscounts(platformDiscounts);
|
|
|
|
|
// sonDetailsDto.setPayDiscounts(payDiscounts);
|
|
|
|
|
// sonDetailsDto.setExpertDiscounts(expertDiscounts);
|
|
|
|
|
// sonDetailsDto.setMerchantDiscounts(merchantDiscounts);
|
|
|
|
|
|
|
|
|
|
BigDecimal totalBigDecimal = new BigDecimal("0");
|
|
|
|
|
BigDecimal totalPayAmountBigDecimal = new BigDecimal("0");
|
|
|
|
|