瀏覽代碼

bugfix-添加商品互斥

Aslee 3 年之前
父節點
當前提交
265adf1ab9

+ 0 - 8
src/main/java/com/caimei/modules/hehe/dao/CmHeheActivityProductDao.java

@@ -17,12 +17,6 @@ import java.util.List;
  */
 @MyBatisDao
 public interface CmHeheActivityProductDao extends CrudDao<CmHeheActivityProduct> {
-    /**
-     * 查询活动商品id
-     *
-     * @return
-     */
-    List<Integer> findActivityProductId();
 
     /**
      * 查询呵呵商城所有上架商品
@@ -70,6 +64,4 @@ public interface CmHeheActivityProductDao extends CrudDao<CmHeheActivityProduct>
      * @param productId
      */
     void deleteUserActivity(Integer productId);
-
-    List<Integer> findCollageProductId();
 }

+ 0 - 4
src/main/java/com/caimei/modules/hehe/dao/CmHeheCollageProductDao.java

@@ -17,9 +17,5 @@ public interface CmHeheCollageProductDao extends CrudDao<CmHeheCollageProduct> {
 
     void updateStatus(@Param("id") Integer id,@Param("status") Integer status);
 
-    List<Integer> findExistProductIds();
-
-    List<Integer> findActivityProductIds();
-
     Integer getProductId(Integer heheProductId);
 }

+ 20 - 0
src/main/java/com/caimei/modules/hehe/dao/CmHeheProductDao.java

@@ -56,4 +56,24 @@ public interface CmHeheProductDao extends CrudDao<CmHeheProduct> {
     List<Integer> findHeHeFloorProductIds();
 
     List<Product> findAllHeheProduct(Product product);
+
+
+    /**
+     * 查询活动商品id
+     *
+     * @return
+     */
+    List<Integer> findActivityProductIds();
+
+    /**
+     * 查询拼团商品id
+     * @return
+     */
+    List<Integer> findCollageProductIds();
+
+    /**
+     * 查询限时特价商品id
+     * @return
+     */
+    List<Integer> findDiscountProductIds();
 }

+ 9 - 2
src/main/java/com/caimei/modules/hehe/service/CmHeheActivityProductService.java

@@ -1,6 +1,7 @@
 package com.caimei.modules.hehe.service;
 
 import com.caimei.modules.hehe.dao.CmHeheActivityProductDao;
+import com.caimei.modules.hehe.dao.CmHeheProductDao;
 import com.caimei.modules.hehe.entity.CmHeHeActivityLadder;
 import com.caimei.modules.hehe.entity.CmHeheActivityProduct;
 import com.caimei.modules.hehe.entity.CmHeheProduct;
@@ -28,6 +29,9 @@ public class CmHeheActivityProductService extends CrudService<CmHeheActivityProd
     @Autowired
     private CmHeheActivityProductDao activityProductDao;
 
+    @Autowired
+    private CmHeheProductDao heheProductDao;
+
     public CmHeheActivityProduct get(String id) {
         CmHeheActivityProduct activityProduct = super.get(id);
         List<CmHeHeActivityLadder> activityLadderList = activityProductDao.findActivityLadder(activityProduct.getActivityId(), activityProduct.getProductId());
@@ -61,10 +65,13 @@ public class CmHeheActivityProductService extends CrudService<CmHeheActivityProd
     }
 
     public Page<CmHeheProduct> findProductPage(Page<CmHeheProduct> productPage, CmHeheProduct product) {
-        List<Integer> productIds = activityProductDao.findActivityProductId();
+        List<Integer> productIds = heheProductDao.findActivityProductIds();
         // 已参与拼团商品id
-        List<Integer> collageProductIds = activityProductDao.findCollageProductId();
+        List<Integer> collageProductIds = heheProductDao.findCollageProductIds();
+        // 已参与限时特价的商品id
+        List<Integer> discountProductIds = heheProductDao.findDiscountProductIds();
         productIds.addAll(collageProductIds);
+        productIds.addAll(discountProductIds);
         product.setIds(productIds);
         product.setPage(productPage);
         List<CmHeheProduct> productList = activityProductDao.findAllHeHeProduct(product);

+ 8 - 2
src/main/java/com/caimei/modules/hehe/service/CmHeheCollageProductService.java

@@ -5,6 +5,7 @@ import java.util.Arrays;
 import java.util.List;
 
 import com.caimei.modules.hehe.dao.CmHeheFloorProductDao;
+import com.caimei.modules.hehe.dao.CmHeheProductDao;
 import com.caimei.modules.product.entity.Product;
 import com.caimei.utils.AppUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -33,6 +34,9 @@ public class CmHeheCollageProductService extends CrudService<CmHeheCollageProduc
 	@Resource
 	private CmHeheCollageProductDao cmHeheCollageProductDao;
 
+	@Resource
+	private CmHeheProductDao heheProductDao;
+
 	public CmHeheCollageProduct get(String id) {
 		return super.get(id);
 	}
@@ -68,9 +72,11 @@ public class CmHeheCollageProductService extends CrudService<CmHeheCollageProduc
 		product.setPage(productPage);
 		product.setSearchType(2);
 		// 已参与拼团商品id
-		List<Integer> productIds = cmHeheCollageProductDao.findExistProductIds();
+		List<Integer> productIds = heheProductDao.findCollageProductIds();
 		// 已参与商品活动商品id
-		List<Integer> actProductIds = cmHeheCollageProductDao.findActivityProductIds();
+		List<Integer> actProductIds = heheProductDao.findActivityProductIds();
+		// 已参与限时特价活动商品id
+		List<Integer> discountProductIds = heheProductDao.findDiscountProductIds();
 		productIds.addAll(actProductIds);
 		product.setIds(productIds);
 		List<Product> productList = cmHeheFloorProductDao.findAllProduct(product);

+ 11 - 1
src/main/java/com/caimei/modules/hehe/service/HeheDiscountActivityProductService.java

@@ -3,6 +3,7 @@ package com.caimei.modules.hehe.service;
 import java.util.List;
 
 import com.caimei.modules.hehe.dao.CmHeheActivityProductDao;
+import com.caimei.modules.hehe.dao.CmHeheProductDao;
 import com.caimei.modules.hehe.entity.CmHeheProduct;
 import com.caimei.modules.hehe.entity.HeheHomeTypeProduct;
 import com.caimei.utils.AppUtils;
@@ -29,6 +30,8 @@ public class HeheDiscountActivityProductService extends CrudService<HeheDiscount
 	private HeheDiscountActivityProductDao heheDiscountActivityProductDao;
 	@Autowired
 	private CmHeheActivityProductDao activityProductDao;
+	@Autowired
+	private CmHeheProductDao heheProductDao;
 
 	public HeheDiscountActivityProduct get(String id) {
 		return super.get(id);
@@ -58,7 +61,14 @@ public class HeheDiscountActivityProductService extends CrudService<HeheDiscount
 	}
 
     public Page<CmHeheProduct> findProductPage(Page<CmHeheProduct> productPage, CmHeheProduct product) {
-        List<Integer> productIds = heheDiscountActivityProductDao.findDiscountProductIds();
+		// 已参与拼团商品id
+		List<Integer> productIds = heheProductDao.findCollageProductIds();
+		// 已参与商品活动商品id
+		List<Integer> actProductIds = heheProductDao.findActivityProductIds();
+		// 已参与限时特价活动商品id
+		List<Integer> discountProductIds = heheProductDao.findDiscountProductIds();
+		productIds.addAll(actProductIds);
+		productIds.addAll(discountProductIds);
         product.setIds(productIds);
         product.setPage(productPage);
         List<CmHeheProduct> productList = activityProductDao.findAllHeHeProduct(product);

+ 1 - 15
src/main/resources/mappings/modules/hehe/CmHeheActivityProductMapper.xml

@@ -97,17 +97,6 @@
 		UPDATE cm_hehe_activity_product SET delFlag = 1 WHERE id = #{id}
 	</update>
 
-	<select id="findActivityProductId" resultType="integer">
-		SELECT
-		  productId
-		FROM
-		  cm_hehe_activity_product a
-		  LEFT JOIN cm_hehe_activity cha ON a.activityId = cha.id
-		WHERE
-		  a.delFlag = 0
-		  AND cha.delFlag = 0
-	</select>
-
 	<select id="findAllHeHeProduct" resultType="com.caimei.modules.hehe.entity.CmHeheProduct">
 		SELECT
 		a.id AS "id",
@@ -179,11 +168,8 @@
 	<select id="findActivityByProductId" resultType="integer">
 		SELECT activityId FROM cm_hehe_activity_product WHERE productId = #{productId} AND delFlag = 0
 	</select>
-    <select id="findCollageProductId" resultType="java.lang.Integer">
-		select chcp.productId from cm_hehe_collage_product chcp
-	</select>
 
-    <delete id="deleteUserActivity">
+	<delete id="deleteUserActivity">
 		DELETE FROM cm_hehe_user_activity WHERE productId = #{productId}
 	</delete>
 

+ 0 - 10
src/main/resources/mappings/modules/hehe/CmHeheCollageProductMapper.xml

@@ -75,16 +75,6 @@
 			</otherwise>
 		</choose>
 	</select>
-	<select id="findExistProductIds" resultType="java.lang.Integer">
-		select chp.id from cm_hehe_collage_product chcp left join cm_hehe_product chp on chcp.productId = chp.productId
-		where chp.id is not null;
-	</select>
-	<select id="findActivityProductIds" resultType="java.lang.Integer">
-		select chp.id
-		from cm_hehe_activity_product chap
-				 left join cm_hehe_product chp on chap.productId = chp.productId
-		where chp.id is not null and delFlag = 0;
-	</select>
 	<select id="findReductionProductIds" resultType="java.lang.Integer">
 		select chp.id
 		from cm_hehe_reduction chap

+ 17 - 1
src/main/resources/mappings/modules/hehe/CmHeheProductMapper.xml

@@ -257,7 +257,23 @@
 			</otherwise>
 		</choose>
 	</select>
-
+	<select id="findActivityProductIds" resultType="java.lang.Integer">
+		SELECT
+			a.productId
+		FROM
+			cm_hehe_activity_product a
+			LEFT JOIN cm_hehe_activity cha ON a.activityId = cha.id
+		WHERE
+			a.delFlag = 0
+		  AND cha.delFlag = 0
+  	</select>
+	<select id="findCollageProductIds" resultType="java.lang.Integer">
+		select productId from cm_hehe_collage_product
+	</select>
+	<select id="findDiscountProductIds" resultType="java.lang.Integer">
+		select productId from hehe_discount_activity_product hdap left join cm_hehe_discount_activity chda on hdap.activityId = chda.id
+		where chda.id is not null
+	</select>
 
 	<update id="deleteActivityProduct">
 		UPDATE cm_hehe_activity_product SET delFlag = 1 WHERE productId = #{productId}