diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/ProfilesActiveConstant.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/ProfilesActiveConstant.java index 466801c7..3f1070ea 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/ProfilesActiveConstant.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/ProfilesActiveConstant.java @@ -7,7 +7,7 @@ public class ProfilesActiveConstant { public static final String LETS_DATE_SOURCE = "lets_u8c"; - public static final String LETS_PROFILES_ACTIVE = "prod"; + public static final String LETS_PROFILES_ACTIVE = "dev"; public static final String LOG_STATUS_Y = "Y"; diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsSaleoutDetailedEntity.xml b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsSaleoutDetailedEntity.xml index ec8734bf..075673e3 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsSaleoutDetailedEntity.xml +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsSaleoutDetailedEntity.xml @@ -874,7 +874,7 @@ - insert into tocofs_saleout_detailed(id,newPushDate,newTransmitInfo,newState,newSystemNumber,newSystemPrimary) + insert into tocofs_saleout_detailed(id,newPushDate,newTransmitInfo,newState,newSystemNumber,newSystemPrimary,def7,def8,def9,def10,def11,def12) values ( @@ -883,7 +883,13 @@ #{entity.newtransmitinfo}, #{entity.newstate}, #{entity.newsystemnumber}, - #{entity.newsystemprimary} + #{entity.newsystemprimary}, + #{entity.def7}, + #{entity.def8}, + #{entity.def9}, + #{entity.def10}, + #{entity.def11}, + #{entity.def12} ) on duplicate key update @@ -892,13 +898,19 @@ newTransmitInfo = values(newTransmitInfo), newState = values(newState), newSystemNumber = values(newSystemNumber), - newSystemPrimary = values(newSystemPrimary) + newSystemPrimary = values(newSystemPrimary), + def7 = values(def7), + def8 = values(def8), + def9 = values(def9), + def10 = values(def10), + def11 = values(def11), + def12 = values(def12) - insert into tocofs_saleout_detailed(id,def1,def2,newState2,newSystemNumber2,newSystemPrimary2) + insert into tocofs_saleout_detailed(id,def1,def2,newState2,newSystemNumber2,newSystemPrimary2,def7,def8,def9,def10,def11,def12) values ( @@ -907,7 +919,13 @@ #{entity.def2}, #{entity.newstate2}, #{entity.newsystemnumber2}, - #{entity.newsystemprimary2} + #{entity.newsystemprimary2}, + #{entity.def7}, + #{entity.def8}, + #{entity.def9}, + #{entity.def10}, + #{entity.def11}, + #{entity.def12} ) on duplicate key update @@ -916,22 +934,34 @@ def2 = values(def2), newState2 = values(newState2), newSystemNumber2 = values(newSystemNumber2), - newSystemPrimary2 = values(newSystemPrimary2) + newSystemPrimary2 = values(newSystemPrimary2), + def7 = values(def7), + def8 = values(def8), + def9 = values(def9), + def10 = values(def10), + def11 = values(def11), + def12 = values(def12) - insert into tocofs_saleout_detailed(id,def3,def4,newState3,newSystemNumber3,newSystemPrimary3) + insert into tocofs_saleout_detailed(id,def3,def4,newState3,newSystemNumber3,newSystemPrimary3,def7,def8,def9,def10,def11,def12) values ( - #{entity.id}, - #{entity.def3}, - #{entity.def4}, - #{entity.newstate3}, - #{entity.newsystemnumber3}, - #{entity.newsystemprimary3} + #{entity.id}, + #{entity.def3}, + #{entity.def4}, + #{entity.newstate3}, + #{entity.newsystemnumber3}, + #{entity.newsystemprimary3}, + #{entity.def7}, + #{entity.def8}, + #{entity.def9}, + #{entity.def10}, + #{entity.def11}, + #{entity.def12} ) on duplicate key update @@ -940,7 +970,13 @@ def4 = values(def4), newState3 = values(newState3), newSystemNumber3 = values(newSystemNumber3), - newSystemPrimary3 = values(newSystemPrimary3) + newSystemPrimary3 = values(newSystemPrimary3), + def7 = values(def7), + def8 = values(def8), + def9 = values(def9), + def10 = values(def10), + def11 = values(def11), + def12 = values(def12) diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java index e2207932..546eb4dc 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java @@ -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 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> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50); + List> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 100); for (int i = 0; i < splitListByCount.size(); i++) { List tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i); iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock1(tocofsSaleoutDetailedEntityList1); @@ -2451,7 +2499,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //以50行为一个批次更新状态 if (tocofsSaleoutDetailedEntityList.size() > 0) { - List> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50); + List> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 100); for (int i = 0; i < splitListByCount.size(); i++) { List 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> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50); + List> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 100); for (int i = 0; i < splitListByCount.size(); i++) { List 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> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 200); + List> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 100); for (int i = 0; i < splitListByCount.size(); i++) { List 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 mapList) throws Exception { + private String getFloorPrice(Boolean isCheckShopChoose, BdInvmandocEntity bdInvmandocEntity, HeaderDto header, SonDetailsDto sonDetailsDto, List 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 poOrderBEntityList = (Map) 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 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"); diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/SonDetailsDto.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/SonDetailsDto.java index 80233081..3860c39d 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/SonDetailsDto.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/u8cdto/SonDetailsDto.java @@ -95,4 +95,18 @@ public class SonDetailsDto extends DetailsDto { //累加商家优惠 //改为原始商家优惠 private String vdef7; + + //把销售订单明细行对应的优惠金额保存到销售出库单明细行一份,便于存储到中台的底表 + //计算应收 + private String calculateAccountsReceivable; + //计算公式 + private String calculationFormula; + //平台优惠 + private String platformDiscounts; + //商家优惠 + private String merchantDiscounts; + //达人优惠 + private String expertDiscounts; + //支付优惠 + private String payDiscounts; } \ No newline at end of file diff --git a/buildpackage/src/main/resources/application.yml b/buildpackage/src/main/resources/application.yml index bab6e286..cd510979 100644 --- a/buildpackage/src/main/resources/application.yml +++ b/buildpackage/src/main/resources/application.yml @@ -36,7 +36,7 @@ spring: # use-suffix-pattern: true profiles: # active: @profileActive@ - active: lets + active: letsprod # active: @profile.active@ # active: dev servlet: diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehousWarehouseTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehousWarehouseTest.java index f3fece1c..74241c20 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehousWarehouseTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/purchase/ProxyPurchaseWarehousWarehouseTest.java @@ -26,6 +26,6 @@ public class ProxyPurchaseWarehousWarehouseTest { @Test public void startImplementByCode() { - proxyPurchaseWarehousWarehouse.startImplementByCode("LETS-RE2024103000000089"); + proxyPurchaseWarehousWarehouse.startImplementByCode("LETS-RE2024110100000118"); } } \ No newline at end of file diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java index 6bf605a6..25a66c04 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java @@ -109,8 +109,8 @@ class SoSaleOutPluginInitializerToCTest { // String aaa = "LETS-SH2024101900022025"; // soSaleOutPluginInitializerToC.startImplementStockByCode(aaa, "tran"); -// String aaa = "LETS-SH2024102900016893"; -// soSaleOutPluginInitializerToC.startImplementStockByCode(aaa, "tran"); +// String aaa = "LETS-SH2024102800021196"; +// soSaleOutPluginInitializerToC.startImplementTranByTime("2024-11-05 10:28:06", "2024-11-05 10:28:06"); // soSaleOutPluginInitializerToC.startImplementTranByTime("2024-11-05 09:40:20", "2024-11-05 09:40:20"); } catch (Exception e) { @@ -120,8 +120,8 @@ class SoSaleOutPluginInitializerToCTest { // soSaleOutPluginInitializerToC.sendU8CTOCOrder("123446"); try { -// soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024091900002878", "stock"); - soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024110500013375", "tran"); + soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024110200012629", "tran"); +// soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024110500013375", "tran"); } catch (Exception e) { e.printStackTrace(); } diff --git a/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssalesordersearch/DetailsDto.java b/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssalesordersearch/DetailsDto.java index 2b49d041..bb3eefd7 100755 --- a/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssalesordersearch/DetailsDto.java +++ b/service/src/main/java/com/hzya/frame/ttxofs/dto/ofssalesordersearch/DetailsDto.java @@ -56,6 +56,7 @@ public class DetailsDto { private String inventoryId; private String shipAt; private String totalAmount; + private String payableAmount; //优惠分摊start------------––----- //优惠金额-分摊比例