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 147fe3ca..3b887ea0 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 @@ -3573,11 +3573,12 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity { //U参考售价 String refsaleprice = bdInvmandocEntity.getRefsaleprice(); Assert.notNull(refsaleprice, "存货:{} 公司:{} 不存在参考售价,请维护!", bdInvbasdocEntity.getInvname(), bdInvmandocEntity.getPkCorp()); + Assert.state(!"".equals(refsaleprice.trim()), "存货:{} 公司:{} 不存在参考售价,请维护!", bdInvbasdocEntity.getInvname(), bdInvmandocEntity.getPkCorp()); //O实发数量 String shipQty = sonDetailsDto.getShipQty(); Assert.notNull(shipQty, "O实发数量不能为空 O销售出库单编码:{} O明细行主键:{}", header.getCode(), sonDetailsDto.getId()); - Assert.state(!"".equals(shipQty), "O实发数量不能为空 O销售出库单编码:{} O明细行主键:{}", header.getCode(), sonDetailsDto.getId()); + Assert.state(!"".equals(shipQty.trim()), "O实发数量不能为空 O销售出库单编码:{} O明细行主键:{}", header.getCode(), sonDetailsDto.getId()); BigDecimal amountOfMoney = new BigDecimal(refsaleprice).multiply(new BigDecimal(shipQty)); diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java index c8d79ca5..f217b62a 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleReturnPluginInitializerToC.java @@ -617,7 +617,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { // 查询销售收发类别 // BdRdclEntity bdRdclEntity = rdclUtil.queryRdClObject("202"); //初始化所有存货管理档案对应的结存价+采购价 - List mapList = initAllBalancePricePurchasePrice(); +// List mapList = initAllBalancePricePurchasePrice(); if (bdBusitypeEntity != null && summaryDimensionMap != null) { Iterator>> iterator = summaryDimensionMap.entrySet().iterator(); @@ -692,7 +692,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { Boolean isCheckShopChoose = balanceUnitPriceUtil.checkOfsShop(header.getStoreCode()); //把汇总好的出库单明细行合并成一行 - GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = groupMergeDetailedRows(oldValue, isCheckShopChoose, mapList); + GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = groupMergeDetailedRows(oldValue, isCheckShopChoose); //存货管理档案:取发货公司的存货管理档案 BdInvmandocEntity bdInvmandocEntity = oldValue.get(0).getBdInvmandocEntity(); //存货基础档案 @@ -830,7 +830,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { // 查询U8C业务流程 BdBusitypeEntity bdBusitypeEntity = u8cOperationFlowV2(); //初始化所有存货管理档案对应的结存价+采购价 - List mapList = initAllBalancePricePurchasePrice(); +// List mapList = initAllBalancePricePurchasePrice(); if (bdBusitypeEntity != null && summaryDimensionMap != null) { Iterator>> iterator = summaryDimensionMap.entrySet().iterator(); @@ -904,7 +904,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { //验证是否为指定的店铺,如果为true,则取结存价 Boolean isCheckShopChoose = balanceUnitPriceUtil.checkOfsShop(header.getStoreCode()); //把汇总好的出库单明细行合并成一行 - GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = groupMergeDetailedRows(oldValue, isCheckShopChoose, mapList); + GoodsRertunSonDetailsDto goodsRertunSonDetailsDto = groupMergeDetailedRows(oldValue, isCheckShopChoose); //存货管理档案:取发货公司的存货管理档案 BdInvmandocEntity bdInvmandocEntity = oldValue.get(0).getBdInvmandocEntity(); @@ -1489,10 +1489,10 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { * @param sonDetailsDtoList 汇总过后的售后入库单明细 * @author liuyang */ - private GoodsRertunSonDetailsDto groupMergeDetailedRows(List sonDetailsDtoList, Boolean isCheckShopChoose, List mapList) throws Exception { + private GoodsRertunSonDetailsDto groupMergeDetailedRows(List sonDetailsDtoList, Boolean isCheckShopChoose) throws Exception { Assert.notNull(sonDetailsDtoList, "sonDetailsDtoList不能为空"); Assert.notNull(isCheckShopChoose, "isCheckShopChoose不能为空"); - Assert.notNull(mapList, "mapLists不能为空"); +// Assert.notNull(mapList, "mapLists不能为空"); if (sonDetailsDtoList != null && sonDetailsDtoList.size() > 0) { BigDecimal groupTotalPayAmount = new BigDecimal("0"); @@ -1506,23 +1506,34 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { RerturnGoodsOrderSearchHeader header1 = rerturnGoodsOrderSearchData.getHeader();//OFS售后订单表头对象 List details = rerturnGoodsOrderSearchData.getDetails();//OFS售后订单表体对象 - //存货管理档案 - BdInvmandocEntity bdInvmandocEntity = goodsRertunSonDetailsDto.getBdInvmandocEntity(); +// BdInvmandocEntity bdInvmandocEntity1 = goodsRertunSonDetailsDto.getBdInvmandocEntity();//存货管理档案 + BdInvbasdocEntity bdInvbasdocEntity = goodsRertunSonDetailsDto.getBdInvbasdocEntity();//存货基本档案 + BdInvmandocEntity bdInvmandocEntity = goodsRertunSonDetailsDto.getBdInvmandocEntity();//存货管理档案 + //根据OFS售后入库单明细行,查找匹配OFS售后订单明细行 RerturnGoodsOrderSearchDetails ofsOrderDetail = findOfsOrderDetail(details, goodsRertunSonDetailsDto); - //取对应的售后订单明细,主要是取这个价格 + String totalAmount = null; StringBuffer calculationFormulaStr = new StringBuffer(); - String totalAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, goodsRertunSonDetailsDto, mapList, calculationFormulaStr); - if (totalAmount == null) { - calculationFormulaStr.append("取O实退金额:"); - //取O实退金额 -// RerturnGoodsOrderSearchDetails afterSalesOrder = findAfterSalesOrderV2(goodsRertunSonDetailsDto, rerturnGoodsOrderSearchData); -// totalAmount = afterSalesOrder.getTotalAmount(); - //测试 -// goodsRertunSonDetailsDto.setReceivedQty("1"); + if (isCheckShopChoose) { + //取《U8C存货基本档案-参考售价》 + totalAmount = getRefsaleprice(bdInvmandocEntity, bdInvbasdocEntity, calculationFormulaStr, goodsRertunSonDetailsDto, header); + } else { + //取《O实退》 totalAmount = accumulatedDiscounts(goodsRertunSonDetailsDto, rerturnGoodsOrderSearchData, calculationFormulaStr); } + + //取对应的售后订单明细,主要是取这个价格 +// String totalAmount = getFloorPrice(isCheckShopChoose, bdInvmandocEntity, header, goodsRertunSonDetailsDto, mapList, calculationFormulaStr); +// if (totalAmount == null) { +// calculationFormulaStr.append("取O实退金额:"); +// //取O实退金额 +//// RerturnGoodsOrderSearchDetails afterSalesOrder = findAfterSalesOrderV2(goodsRertunSonDetailsDto, rerturnGoodsOrderSearchData); +//// totalAmount = afterSalesOrder.getTotalAmount(); +// //测试 +//// goodsRertunSonDetailsDto.setReceivedQty("1"); +// totalAmount = accumulatedDiscounts(goodsRertunSonDetailsDto, rerturnGoodsOrderSearchData, calculationFormulaStr); +// } Assert.notNull(totalAmount, "实退金额不能为空 明细行主键:{}", goodsRertunSonDetailsDto.getId()); Assert.notNull(goodsRertunSonDetailsDto.getReceivedQty(), "实收数量不能为空 明细行主键:{}", goodsRertunSonDetailsDto.getId()); @@ -2770,11 +2781,42 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity { } } } - sonDetailsDtoList.get(0).setVdef4(platformDiscountsBigDecimal);//平台 sonDetailsDtoList.get(0).setVdef5(payDiscountsBigDecimal);//支付 sonDetailsDtoList.get(0).setVdef6(expertDiscountsBigDecimal);//达人 sonDetailsDtoList.get(0).setVdef7(merchantDiscountsBigDecimal);//商家 } } + + /** + * 获取参考售价 + * + * @param bdInvmandocEntity 存货管理档案 + * @param bdInvbasdocEntity 存货基本档案 + * @param calculationFormulaStr 计算公式 + * @param goodsRertunSonDetailsDto O售后入库单明细行 + * @param header O售后入库单表头 + * @author liuyang + */ + private String getRefsaleprice(BdInvmandocEntity bdInvmandocEntity, BdInvbasdocEntity bdInvbasdocEntity, StringBuffer calculationFormulaStr, GoodsRertunSonDetailsDto goodsRertunSonDetailsDto, StockinOrderSearchResponse.StockinOrder.StockinH header) throws Exception { + Assert.notNull(bdInvmandocEntity, "bdInvmandocEntity不能为空!"); + Assert.notNull(bdInvbasdocEntity, "bdInvbasdocEntity不能为空!"); + Assert.notNull(calculationFormulaStr, "calculationFormulaStr不能为空!"); + Assert.notNull(goodsRertunSonDetailsDto, "goodsRertunSonDetailsDto不能为空!"); + Assert.notNull(header, "header不能为空"); + + //U参考售价 + String refsaleprice = bdInvmandocEntity.getRefsaleprice(); + Assert.notNull(refsaleprice, "存货:{} 公司:{} 不存在参考售价,请维护!", bdInvbasdocEntity.getInvname(), bdInvmandocEntity.getPkCorp()); + + //O实收数量 + String receivedQty = goodsRertunSonDetailsDto.getReceivedQty(); + Assert.notNull(receivedQty, "O实收数量不能为空 O售后入库单编码:{} O明细行主键:{}", header.getCode(), goodsRertunSonDetailsDto.getId()); + Assert.state(!"".equals(receivedQty), "O实收数量不能为空 O售后入库单编码:{} O明细行主键:{}", header.getCode(), goodsRertunSonDetailsDto.getId()); + + BigDecimal amountOfMoney = new BigDecimal(refsaleprice).multiply(new BigDecimal(receivedQty)); + String format = StrUtil.format("取U参考售价:{}*{}", refsaleprice, receivedQty); + calculationFormulaStr.append(format); + return amountOfMoney.stripTrailingZeros().toPlainString(); + } } \ 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 3bc24cd9..382c5424 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 @@ -110,7 +110,7 @@ class SoSaleOutPluginInitializerToCTest { // soSaleOutPluginInitializerToC.startImplementStockByCode(aaa, "tran"); // String aaa = "LETS-SH2024102800021196"; - soSaleOutPluginInitializerToC.startImplementTranByTime("2024-11-23 11:24:33", "2024-11-23 11:24:33"); +// soSaleOutPluginInitializerToC.startImplementTranByTime("2024-11-23 11:24:33", "2024-11-23 11:24:33"); // soSaleOutPluginInitializerToC.startImplementStockByTime("2024-11-15 00:00:00", "2024-11-15 23:59:59"); } catch (Exception e) { @@ -120,7 +120,7 @@ class SoSaleOutPluginInitializerToCTest { // soSaleOutPluginInitializerToC.sendU8CTOCOrder("123446"); try { -// soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024103100030329", "stock"); + soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024110100000024", "stock"); // soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024110500013375", "tran"); // soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024111700013756", "tran");