diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/RefundOnlyPluginInitializerToB.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/RefundOnlyPluginInitializerToB.java index 88b9af80..f0c4cf58 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/RefundOnlyPluginInitializerToB.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/RefundOnlyPluginInitializerToB.java @@ -12,9 +12,7 @@ import com.hzya.frame.plugin.lets.constant.OverallConstant; import com.hzya.frame.plugin.lets.constant.ProfilesActiveConstant; import com.hzya.frame.plugin.lets.dao.IOnlyAfterSalesBDao; import com.hzya.frame.plugin.lets.dao.IOnlyAfterSalesHDao; -import com.hzya.frame.plugin.lets.entity.BdCubasdocEntity; -import com.hzya.frame.plugin.lets.entity.OnlyAfterSalesBEntity; -import com.hzya.frame.plugin.lets.entity.OnlyAfterSalesHEntity; +import com.hzya.frame.plugin.lets.entity.*; import com.hzya.frame.plugin.lets.ofsvo.QueryOfsSoSaleOutVo; import com.hzya.frame.plugin.lets.ofsvo.QueryReturnOrderRequestVO; import com.hzya.frame.plugin.lets.u8cdto.ArapDjzb; @@ -65,6 +63,8 @@ import java.util.stream.Collectors; @Service("refundOnlyPluginInitializerToB") public class RefundOnlyPluginInitializerToB extends PluginBaseEntity { + private List referenceShopList = Arrays.asList("FANG-Q-L", "XZJJ", "dy-FQL", "pdd-yanxi", "DLTer"); + Logger logger = LoggerFactory.getLogger(RefundOnlyPluginInitializerToB.class); @Override @@ -305,7 +305,7 @@ public class RefundOnlyPluginInitializerToB extends PluginBaseEntity { List filterRefundOnly = new ArrayList<>(); for (RerturnGoodsOrderSearchData rerturnGoodsOrderSearchDatum : rerturnGoodsOrderSearchData) { RerturnGoodsOrderSearchHeader header = rerturnGoodsOrderSearchDatum.getHeader(); - if ("0".equals(header.getReturnType()) && "0".equals(header.getExchangeType()) && "1".equals(header.getRefundInd())&&("300".equals(header.getReturnNode())||"200".equals(header.getReturnNode()))) { + if ("0".equals(header.getReturnType()) && "0".equals(header.getExchangeType()) && "1".equals(header.getRefundInd()) && ("300".equals(header.getReturnNode()) || "200".equals(header.getReturnNode()))) { filterRefundOnly.add(rerturnGoodsOrderSearchDatum); } } @@ -322,7 +322,7 @@ public class RefundOnlyPluginInitializerToB extends PluginBaseEntity { RerturnGoodsOrderSearchHeader header = returnGoodsOrder.getHeader(); //过滤"NMNS"\"YNS"\"HJ" - if("NMNS".equals(header.getCompanyCode())||"YNS".equals(header.getCompanyCode())||"HJ".equals(header.getCompanyCode())){ + if ("NMNS".equals(header.getCompanyCode()) || "YNS".equals(header.getCompanyCode()) || "HJ".equals(header.getCompanyCode())) { continue; } @@ -364,6 +364,8 @@ public class RefundOnlyPluginInitializerToB extends PluginBaseEntity { * 因为优惠金额在表头,先按单据便利一变,具体分摊金额拆到每行,在去汇总 */ public void implement(List filterReturnGoodsOrders) throws Exception { + + boolean isReferenceShop = false; //分摊分摊后的子表 List allDetail = new ArrayList<>(); List allHeader = new ArrayList<>(); @@ -419,13 +421,13 @@ public class RefundOnlyPluginInitializerToB extends PluginBaseEntity { parentvo.setWldx("0"); //hbbm 客商==店铺,根据店铺区分tob、toc,,,编码需要转换,转换称自定义项。 BdCubasdocEntity entity = queryU8CEntityUtil.getFuzzyQueryCustomers(split[1]); - if(entity==null){ - Assert.state(false,"根据客商自定义项1:{},未查询到客商基本档案,请假查。",split[1]); + if (entity == null) { + Assert.state(false, "根据客商自定义项1:{},未查询到客商基本档案,请假查。", split[1]); } parentvo.setHbbm(entity.getCustcode()); //根据店铺区分tob、toc,区分业务流程 String s = checkFlow(parentvo, split[1]); - if("TOC".equals(s)){ + if ("TOC".equals(s)) { continue; } //deptid 部门 @@ -449,6 +451,10 @@ public class RefundOnlyPluginInitializerToB extends PluginBaseEntity { //zyx1店铺 parentvo.setZyx1(split[1]); + + if (referenceShopList.contains(split[1])) { + isReferenceShop = true; + } //zyx2来源平台 parentvo.setZyx2(entry.getValue().get(0).getSourcePlatformCode()); //zyx3 收发类别 销售出库,写死:SALES @@ -457,7 +463,6 @@ public class RefundOnlyPluginInitializerToB extends PluginBaseEntity { parentvo.setZyx16("1"); - //子表,需要通过多个主表的id找到多个子表,且退货金额==0的不要 List ofsDetails = new ArrayList<>(); for (RerturnGoodsOrderSearchHeader rerturnGoodsOrderSearchHeader : entry.getValue()) { @@ -474,7 +479,7 @@ public class RefundOnlyPluginInitializerToB extends PluginBaseEntity { //20241127:没有sku编码的过滤 r1.clear(); for (RerturnGoodsOrderSearchDetails logDetail : logDetails) { - if(logDetail.getSkuCode()==null||"".equals(logDetail.getSkuCode())) { + if (logDetail.getSkuCode() == null || "".equals(logDetail.getSkuCode())) { continue; // IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); // integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N); @@ -486,11 +491,11 @@ public class RefundOnlyPluginInitializerToB extends PluginBaseEntity { // integrationTaskLivingDetailsEntity.setRootAppBill(logDetail.getReturnOrderCode()); // integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); // saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); - }else { + } else { r1.add(logDetail); } } - if(r1.size()==0){ + if (r1.size() == 0) { continue; } @@ -524,15 +529,49 @@ public class RefundOnlyPluginInitializerToB extends PluginBaseEntity { //sum:zyx7 商家优惠 // BigDecimal sum_zyx7 = new BigDecimal(0); - //金额计算 - for (RerturnGoodsOrderSearchDetails detail : vv) { - sum_jfbbje = sum_jfbbje.add(new BigDecimal(detail.getTotalAmount())); + //查询是否需要参考售价 + if (isReferenceShop) { + //查询存货基本档案,管理档案,取参考售价 + BdInvbasdocEntity bdInvbasdocEntity = queryU8CEntityUtil.queryBdInvbasdocByCode(kk); + if (bdInvbasdocEntity == null) { + Assert.state(false, "根据存货编码:{},查询存货基本档案失败。", kk); + } + BdInvmandocEntity bdInvmandocEntity = queryU8CEntityUtil.queryBdInvmandocByPkInvbasdocAndPkCorp(bdInvbasdocEntity.getPkInvbasdoc(), split[0]); + if (bdInvmandocEntity == null) { + Assert.state(false, "根据公司编码:{},存货主键:{},查询存货管理档案失败。", bdInvbasdocEntity.getPkInvbasdoc(), split[0]); + } + //参考售价 + BigDecimal refsaleprice = new BigDecimal(bdInvmandocEntity.getRefsaleprice()); + for (RerturnGoodsOrderSearchDetails detail : vv) { + sum_jfbbje = sum_jfbbje.add(refsaleprice); - BigDecimal sj = new BigDecimal(detail.getTotalAmount()).multiply(new BigDecimal(0.13)).setScale(2, RoundingMode.FLOOR); - sum_jfbbsj = sum_jfbbsj.add(sj); + BigDecimal sj = refsaleprice.multiply(new BigDecimal(0.13)).setScale(2, RoundingMode.FLOOR); + sum_jfbbsj = sum_jfbbsj.add(sj); - BigDecimal ws = new BigDecimal(detail.getTotalAmount()).subtract(sj); - sum_wbfbbje = sum_wbfbbje.add(ws); + BigDecimal ws = refsaleprice.subtract(sj); + sum_wbfbbje = sum_wbfbbje.add(ws); + + if (detail.getPlatformDiscounts() != null) { + sum_zyx4 = sum_zyx4.add(new BigDecimal(detail.getPlatformDiscounts())); + } + if (detail.getPayDiscounts() != null) { + sum_zyx5 = sum_zyx5.add(new BigDecimal(detail.getPayDiscounts())); + } + if (detail.getExpertDiscounts() != null) { + sum_zyx6 = sum_zyx6.add(new BigDecimal(detail.getExpertDiscounts())); + } + } + + } else { + //金额计算 + for (RerturnGoodsOrderSearchDetails detail : vv) { + sum_jfbbje = sum_jfbbje.add(new BigDecimal(detail.getTotalAmount())); + + BigDecimal sj = new BigDecimal(detail.getTotalAmount()).multiply(new BigDecimal(0.13)).setScale(2, RoundingMode.FLOOR); + sum_jfbbsj = sum_jfbbsj.add(sj); + + BigDecimal ws = new BigDecimal(detail.getTotalAmount()).subtract(sj); + sum_wbfbbje = sum_wbfbbje.add(ws); // if (detail.getShareTargetPlatformDiscounts() != null) { // sum_zyx4 = sum_zyx4.add(detail.getShareTargetPlatformDiscounts()); @@ -547,16 +586,18 @@ public class RefundOnlyPluginInitializerToB extends PluginBaseEntity { // sum_zyx7 = sum_zyx7.add(detail.getShareTargetPayDiscounts()); // } - if (detail.getPlatformDiscounts() != null) { - sum_zyx4 = sum_zyx4.add(new BigDecimal(detail.getPlatformDiscounts())); - } - if (detail.getPayDiscounts() != null) { - sum_zyx5 = sum_zyx5.add(new BigDecimal(detail.getPayDiscounts())); - } - if (detail.getExpertDiscounts() != null) { - sum_zyx6 = sum_zyx6.add(new BigDecimal(detail.getExpertDiscounts())); + if (detail.getPlatformDiscounts() != null) { + sum_zyx4 = sum_zyx4.add(new BigDecimal(detail.getPlatformDiscounts())); + } + if (detail.getPayDiscounts() != null) { + sum_zyx5 = sum_zyx5.add(new BigDecimal(detail.getPayDiscounts())); + } + if (detail.getExpertDiscounts() != null) { + sum_zyx6 = sum_zyx6.add(new BigDecimal(detail.getExpertDiscounts())); + } } } + childrenn.setJfbbje("-" + sum_jfbbje); childrenn.setJfybje("-" + sum_jfbbje); childrenn.setJfbbsj("-" + sum_jfbbsj); @@ -569,7 +610,7 @@ public class RefundOnlyPluginInitializerToB extends PluginBaseEntity { children.add(childrenn); //新增三个优惠为存货 - if(sum_zyx4.compareTo(BigDecimal.ZERO)>0){//平台优惠 + if (sum_zyx4.compareTo(BigDecimal.ZERO) > 0) {//平台优惠 ArapDjzbVO.Childrenn childrennFY = new ArapDjzbVO.Childrenn(); //cinventoryid 存货 childrennFY.setCinventoryid("FY01"); @@ -595,7 +636,7 @@ public class RefundOnlyPluginInitializerToB extends PluginBaseEntity { childrennFY.setJfybwsje("-" + sum_wbfbbje_FY); children.add(childrennFY); } - if(sum_zyx5.compareTo(BigDecimal.ZERO)>0){//支付优惠 + if (sum_zyx5.compareTo(BigDecimal.ZERO) > 0) {//支付优惠 ArapDjzbVO.Childrenn childrennFY = new ArapDjzbVO.Childrenn(); //cinventoryid 存货 childrennFY.setCinventoryid("FY04"); @@ -621,7 +662,7 @@ public class RefundOnlyPluginInitializerToB extends PluginBaseEntity { childrennFY.setJfybwsje("-" + sum_wbfbbje_FY); children.add(childrennFY); } - if(sum_zyx6.compareTo(BigDecimal.ZERO)>0){//达人优惠 + if (sum_zyx6.compareTo(BigDecimal.ZERO) > 0) {//达人优惠 ArapDjzbVO.Childrenn childrennFY = new ArapDjzbVO.Childrenn(); //cinventoryid 存货 childrennFY.setCinventoryid("FY02"); @@ -690,7 +731,7 @@ public class RefundOnlyPluginInitializerToB extends PluginBaseEntity { integrationTaskLivingDetailsEntity.setBusinessDate(format); integrationTaskLivingDetailsEntity.setRootAppPk(ofsDetail.getReturnOrderCode() + "_" + ofsDetail.getSkuCode()); integrationTaskLivingDetailsEntity.setRootAppBill(ofsDetail.getReturnOrderCode());//仅退款单号 - integrationTaskLivingDetailsEntity.setNewSystemNumber(split[0]+"_"+djbh); + integrationTaskLivingDetailsEntity.setNewSystemNumber(split[0] + "_" + djbh); integrationTaskLivingDetailsEntity.setNewSystemPrimary(vouchid); integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); @@ -750,10 +791,11 @@ public class RefundOnlyPluginInitializerToB extends PluginBaseEntity { /** * 公司转换 + * * @param allHeader */ - public void transCorp(List allHeader){ - if(allHeader.size()==0){ + public void transCorp(List allHeader) { + if (allHeader.size() == 0) { return; } @@ -765,20 +807,22 @@ public class RefundOnlyPluginInitializerToB extends PluginBaseEntity { * TOC仅退款:JTK TOB仅退款:BJTK * parentvo.setXslxbm("JTK"); * 非b及c + * * @param parentvo * @param shop */ @Autowired private ShopTobOrToCUtil shopTobOrToCUtil; - public String checkFlow(ArapDjzbVO.Parentt parentvo,String shop){ + + public String checkFlow(ArapDjzbVO.Parentt parentvo, String shop) { String tobShop = shopTobOrToCUtil.getCommaShop("TOB"); String tocShop = shopTobOrToCUtil.getCommaShop("TOC"); System.out.println(tobShop); System.out.println(tocShop); - if(tobShop.contains(shop)){ + if (tobShop.contains(shop)) { // parentvo.setXslxbm("BJTK");//TOB return "TOB"; - }else { + } else { // parentvo.setXslxbm("JTK");//TOC return "TOC"; }