From 470af7313f05d5be58fb643981c27c486ba88f2f Mon Sep 17 00:00:00 2001
From: jyy <935090232@qq.com>
Date: Tue, 09 Mar 2021 16:06:47 +0800
Subject: [PATCH] 优化邮费计算

---
 zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java |   52 ++++++++++------------------------------------------
 1 files changed, 10 insertions(+), 42 deletions(-)

diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java
index 3e9fd80..dce9db6 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java
@@ -98,52 +98,20 @@
     private BusParameterSettingsDao busParameterSettingsDao;
 
     @Override
-    public BigDecimal calculationPostage(Integer addressId, BigDecimal payPrice) {
+    public BigDecimal calculationPostage(BigDecimal payPrice,Long companyId) {
         BigDecimal postage = BigDecimal.ZERO;
-        if (addressId != null) {
-            ShopReceiveAddress shopReceiveAddress = shopReceiveAddressDao.selectById(addressId);
-
-
-            BusParameterSettings sn= busParameterSettingsDao.selectCompanyParamByCode(AppConstance.IN_PROVINCE_PACKAGE_LIST,17L);
-
-
-            BusParameterSettings pydq= busParameterSettingsDao.selectCompanyParamByCode(AppConstance.SECOND_PROVINCE_PACKAGE_LIST,17L);
-
-
-
-            if (sn.getParamValue().indexOf(shopReceiveAddress.getAddrProvince()) > -1) {
-                //省内邮费计算
-                postage = getPostageByDataBictionary(AppConstance.IN_PROVINCE_PACKAGE_PRICE, payPrice);
-            } else if (pydq.getParamValue().indexOf(shopReceiveAddress.getAddrProvince()) > -1) {
-                //偏远地区
-                postage = getPostageByDataBictionary(AppConstance.SECOND_OUT_PROVINCE_PACKAGE_PRICE, payPrice);
-            } else {
-                //其他地区
-                postage = getPostageByDataBictionary(AppConstance.FIRST_OUT_PROVINCE_PACKAGE_PRICE, payPrice);
+        BusParameterSettings yf = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.PACKAGE_PRICE, companyId);
+        BusParameterSettings myje = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.FREE_PACKAGE_PRICE, companyId);
+        if(yf!=null&&myje!=null){
+            if (Double.parseDouble(myje.getParamValue()) > payPrice.doubleValue()) {
+                postage = new BigDecimal(yf.getParamValue());
             }
-
         }
+
         return postage;
     }
 
-    //todo 根据数据字典计算运费  运费设置为0 后面再改配置在改计算规则
-    private BigDecimal getPostageByDataBictionary(String code, BigDecimal payPrice) {
 
-        /*CustomerDataDictionary dd = dataDictionaryDao.selectByTypeCode(code);
-
-
-        BigDecimal postage = BigDecimal.ZERO;
-        if (StringUtils.isNotBlank(dd.getValue())) {
-            if (StringUtils.isNotBlank(dd.getExtValue())
-                    && payPrice.compareTo(new BigDecimal(dd.getExtValue())) >= 0) {
-                //达到条件免邮
-                postage = BigDecimal.ZERO;
-            } else {
-                postage = new BigDecimal(dd.getValue());
-            }
-        }*/
-        return BigDecimal.ZERO;
-    }
 
 
     /**
@@ -189,7 +157,7 @@
         }
 
         //计算订单优惠信息
-        DiscountExplain discountExplain = buildDiscountExplain(cartList, addShopOrderPOJO.getCouponReceiveId(), shopReceiveAddress.getAddrId());
+        DiscountExplain discountExplain = buildDiscountExplain(cartList, addShopOrderPOJO.getCouponReceiveId(), bizUser.getCompanyId());
 
 
         ShopOrder shopOrder = new ShopOrder();
@@ -308,7 +276,7 @@
     }
 
     @Override
-    public DiscountExplain buildDiscountExplain(List<ShopCartVo> cartList, Integer receiveId, Integer receiveAddrId) {
+    public DiscountExplain buildDiscountExplain(List<ShopCartVo> cartList, Integer receiveId, Long companyId) {
         ShopCartBillVo shopCartBill = shoppingCartService.buildShopCartBillVo(cartList);
         DiscountExplain discountExplain = new DiscountExplain();
         discountExplain.setActivity(shopCartBill.getBillCouponTotal());
@@ -325,7 +293,7 @@
             }
         }
 
-        discountExplain.setPostage(calculationPostage(receiveAddrId, discountExplain.getPayPrice()));
+        discountExplain.setPostage(calculationPostage(discountExplain.getPayPrice(),companyId));
 
         //计算实际支付
         discountExplain.setPayPrice(discountExplain.getPayPrice().add(discountExplain.getPostage()));

--
Gitblit v1.9.1