From e941c4f9d9bc76787bde2df21158fffaabe77824 Mon Sep 17 00:00:00 2001
From: jyy <935090232@qq.com>
Date: Tue, 09 Mar 2021 17:09:53 +0800
Subject: [PATCH] 小程序优惠券跨公司bug

---
 zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponDao.xml                           |    4 +++-
 zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponDao.java                        |    2 +-
 zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopCouponServiceImpl.java |   16 +++++++---------
 zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopCouponAction.java                  |    3 ++-
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopCouponAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopCouponAction.java
index b08d002..d60a263 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopCouponAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopCouponAction.java
@@ -14,7 +14,6 @@
 import com.matrix.core.tools.WebUtil;
 import com.matrix.system.common.bean.SysUsers;
 import com.matrix.system.constance.Dictionary;
-import com.matrix.system.hive.action.util.QueryUtil;
 import com.matrix.system.shopXcx.bean.ShopCoupon;
 import com.matrix.system.shopXcx.bean.ShopProduct;
 import com.matrix.system.shopXcx.dao.ShopCouponDao;
@@ -269,6 +268,7 @@
      * @param shopCoupon
      */
     private void productLabeling(ShopCoupon shopCoupon) {
+        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
         Date now = new Date();
         Boolean needUpdate = false;
         //优惠券处于可用状态
@@ -279,6 +279,7 @@
             if (shopCoupon.getIsAll() == 1) {
                 ShopProduct productQuery = new ShopProduct();
                 productQuery.setDelFlag(2);
+                productQuery.setCompanyId(user.getCompanyId());
                 shopProductList = shopProductDao.selectByModel(productQuery);
             } else {
                 if (StringUtils.isNotBlank(shopCoupon.getProductIds())) {
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopCouponServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopCouponServiceImpl.java
index 3f4f488..bf87285 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopCouponServiceImpl.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopCouponServiceImpl.java
@@ -8,14 +8,8 @@
 import com.matrix.component.redis.RedisUserLoginUtils;
 import com.matrix.system.common.constance.AppConstance;
 
-import com.matrix.system.shopXcx.bean.ShopCoupon;
-import com.matrix.system.shopXcx.bean.ShopCouponRecord;
-import com.matrix.system.shopXcx.bean.ShopProductAttrRef;
-import com.matrix.system.shopXcx.bean.ShopShoppingCart;
-import com.matrix.system.shopXcx.dao.ShopCouponDao;
-import com.matrix.system.shopXcx.dao.ShopCouponRecordDao;
-import com.matrix.system.shopXcx.dao.ShopProductAttrRefDao;
-import com.matrix.system.shopXcx.dao.ShopReceiveAddressDao;
+import com.matrix.system.shopXcx.bean.*;
+import com.matrix.system.shopXcx.dao.*;
 import com.matrix.system.shopXcx.api.service.WxShopCouponService;
 import com.matrix.system.shopXcx.api.tools.WxShopCouponUtil;
 import com.matrix.system.shopXcx.api.tools.WxShopOrderUtil;
@@ -50,6 +44,9 @@
     private ShopReceiveAddressDao shopReceiveAddressDao;
     @Autowired
     private WxShopCouponUtil wxShopCouponUtil;
+
+    @Autowired
+    private ShopProductDao productDao;
 
 
     /**
@@ -290,7 +287,8 @@
                 attrIds.addAll(ids);
             }
         }
-        List<ShopCoupon> list = shopCouponDao.selectHdListByProductId(productId, attrIds);
+        ShopProduct shopProduct = productDao.selectById(productId);
+        List<ShopCoupon> list = shopCouponDao.selectHdListByProductId(productId, attrIds,shopProduct.getCompanyId());
         return list;
     }
 
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponDao.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponDao.java
index b5bb5d8..589f88f 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponDao.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponDao.java
@@ -55,7 +55,7 @@
 
 	ShopCoupon selectByIdAndUserId(@Param("id") Integer id, @Param("userId") String userId);
 
-	public List<ShopCoupon> selectHdListByProductId(@Param("productId") Integer productId, @Param("attrIds") List<String> attrIds);
+	public List<ShopCoupon> selectHdListByProductId(@Param("productId") Integer productId, @Param("attrIds") List<String> attrIds, @Param("companyId")Long companyId);
 
     ShopCoupon getCouponByTitle(@Param("title")String title, @Param("companyId")Long companyId);
 }
\ No newline at end of file
diff --git a/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponDao.xml b/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponDao.xml
index b1f72eb..4e833dc 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponDao.xml
@@ -526,6 +526,7 @@
         <result property="tag" column="tag"/>
         <result property="isUsing" column="is_using"/>
         <result property="kind" column="kind"/>
+        <result property="companyId" column="company_id"/>
     </resultMap>
 
     <select id="selectUsableCouponByProductInfo" resultMap="WxShopCouponMap">
@@ -561,7 +562,8 @@
         select *
         from shop_coupon
         where
-        kind=2 and now() >= begin_time and end_time >= now()
+        company_id=#{companyId}
+        and kind=2 and now() >= begin_time and end_time >= now()
         and is_open = 1
         and (is_all = 1 or
         (

--
Gitblit v1.9.1