瀏覽代碼

Merge remote-tracking branch 'origin/developerA' into developerA

Aslee 3 年之前
父節點
當前提交
0088b0b3b9

+ 10 - 0
src/main/java/com/caimei365/commodity/mapper/CouponMapper.java

@@ -100,4 +100,14 @@ public interface CouponMapper {
      * @return
      */
     Date findUserRegisterTime(Integer userId);
+
+    Integer findVip(Integer userId);
+
+    /**
+     * 查所有超级会员优惠券
+     * @return
+     */
+    List<Integer> findVipCoupon();
+
+
 }

+ 35 - 0
src/main/java/com/caimei365/commodity/service/impl/CouponServiceImpl.java

@@ -112,6 +112,16 @@ public class CouponServiceImpl implements CouponService {
     public ResponseJson<PageInfo<CouponVo>> collarCouponsList(Integer userId, int pageNum, int pageSize) {
         PageHelper.startPage(pageNum, pageSize);
         List<CouponVo> couponList = couponMapper.findCouponList(userId);
+        //剔除超级会员优惠券
+        List<Integer> vipCoupon = couponMapper.findVipCoupon();
+        if (couponList.size() > 0 && couponList != null) {
+            for (CouponVo couponVo : couponList) {
+                if (vipCoupon.contains(couponVo.getCouponId())) {
+                    couponList.remove(couponVo);
+                }
+            }
+        }
+
         couponList.forEach(this::setShopName);
         PageInfo<CouponVo> pageInfo = new PageInfo<>(couponList);
         return ResponseJson.success(pageInfo);
@@ -123,6 +133,14 @@ public class CouponServiceImpl implements CouponService {
         if (id != null && id > 0) {
             return ResponseJson.error("已经领取过了", null);
         }
+        //超级会员券领取限制
+        List<Integer> couponIds = couponMapper.findVipCoupon();
+        if (couponIds.contains(couponsDto.getCouponId())) {
+            Integer vip = couponMapper.findVip(couponsDto.getUserId());
+            if (vip == null || vip <= 0) {
+                return ResponseJson.error("未成为超级会员无法领取超级会员券!");
+            }
+        }
         CouponClubPo couponClub = new CouponClubPo();
         BeanUtils.copyProperties(couponsDto, couponClub);
         couponClub.setStatus("1");
@@ -191,12 +209,29 @@ public class CouponServiceImpl implements CouponService {
         if (product == null) {
             return ResponseJson.error("商品数据异常", null);
         }
+        List<Integer> vipCoupon = couponMapper.findVipCoupon();
         //未领取
         List<CouponVo> notCouponList = couponMapper.findCouponList(userId);
         filterCoupon(source, product, notCouponList);
+        //超级会员优惠券移除
+        if (notCouponList.size() > 0 && notCouponList != null) {
+            for (CouponVo couponVo : notCouponList) {
+                if (vipCoupon.contains(couponVo.getCouponId())) {
+                    notCouponList.remove(couponVo);
+                }
+            }
+        }
         map.put("notCouponNum", notCouponList == null ? 0 : notCouponList.size());
         //已领取
         List<CouponVo> couponList = couponMapper.findCouponClub(userId, 1);
+        //超级会员优惠券移除
+        if (couponList.size() > 0 && couponList != null) {
+            for (CouponVo couponVo : couponList) {
+                if (vipCoupon.contains(couponVo.getCouponId())) {
+                    notCouponList.remove(couponVo);
+                }
+            }
+        }
         filterCoupon(source, product, couponList);
         map.put("couponNum", couponList == null ? 0 : couponList.size());
         if (status == 1) {

+ 165 - 168
src/main/resources/mapper/CouponMapper.xml

@@ -5,223 +5,220 @@
 <mapper namespace="com.caimei365.commodity.mapper.CouponMapper">
     <select id="findCouponClub" resultType="com.caimei365.commodity.model.vo.CouponVo">
         SELECT
-          cc.`id` AS "couponId",
-          cc.`couponAmount`,
-          cc.`touchPrice`,
-          cc.`startDate`,
-          cc.`endDate`,
-          cc.`couponType`,
-          cc.`userId`,
-          cc.`shopId`,
-          cc.`productType`,
-          cc.`categoryType`
+        cc.`id` AS "couponId",
+        cc.`couponAmount`,
+        cc.`touchPrice`,
+        cc.`startDate`,
+        cc.`endDate`,
+        cc.`couponType`,
+        cc.`userId`,
+        cc.`shopId`,
+        cc.`productType`,
+        cc.`categoryType`
         FROM
-          cm_coupon_club a
-          LEFT JOIN cm_coupon cc ON a.couponId = cc.id
+        cm_coupon_club a
+        LEFT JOIN cm_coupon cc ON a.couponId = cc.id
         WHERE
-          cc.delFlag = 0
-          AND a.delFlag = 0
-          AND a.userId = #{userId}
-          <if test="status == 1">
-              AND a.status = 1
-              AND NOW() BETWEEN cc.startDate
-              AND cc.endDate
-          </if>
-          <if test="status == 2">
+        cc.delFlag = 0
+        AND a.delFlag = 0
+        AND a.userId = #{userId}
+        <if test="status == 1">
+            AND a.status = 1
+            AND NOW() BETWEEN cc.startDate
+            AND cc.endDate
+        </if>
+        <if test="status == 2">
             AND a.status = 2
             AND NOW() BETWEEN cc.startDate
             AND cc.endDate
-          </if>
-          <if test="status == 3">
-              AND NOW() NOT BETWEEN cc.startDate
-              AND cc.endDate
-          </if>
-          AND cc.status != 2
+        </if>
+        <if test="status == 3">
+            AND NOW() NOT BETWEEN cc.startDate
+            AND cc.endDate
+        </if>
+        AND cc.status != 2
         ORDER BY
-          a.createDate DESC
+        a.createDate DESC
     </select>
 
     <select id="findCouponById" resultType="com.caimei365.commodity.model.vo.ActivityCouponVo">
-        SELECT
-          id AS "couponId",
-          NAME,
-          pcBanner,
-          appletsBanner
-        FROM
-          cm_coupon
-        WHERE
-          productType = 2
+        SELECT id AS "couponId",
+               NAME,
+               pcBanner,
+               appletsBanner
+        FROM cm_coupon
+        WHERE productType = 2
           AND delFlag = 0
           AND couponType = 0
           AND NOW() BETWEEN startDate
-          AND endDate
+            AND endDate
           AND status != 2
           AND id = #{couponId}
     </select>
 
     <select id="findCouponProduct" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
         SELECT
-          p.productID AS productId,
-          p.actStatus,
-          p.name,
-          p.aliasName,
-          p.mainImage AS image,
-          p.unit,
-          p.productCode AS CODE,
-          p.price1TextFlag AS priceFlag,
-          p.price1 AS price,
-          p.costPrice,
-          p.costCheckFlag,
-          p.shopID AS shopId,
-          p.searchKey AS keyword,
-          p.price8Text AS beautyActFlag,
-          p.minBuyNumber AS minBuyNumber,
-          p.maxBuyNumber AS maxBuyNumber,
-          p.ladderPriceFlag,
-          p.normalPrice,
-          p.step,
-          p.shopID AS shopId,
-          p.taxPoint AS taxRate,
-          p.includedTax,
-          p.invoiceType,
-          p.productCategory AS productCategory,
-          p.validFlag,
-          p.featuredFlag,
-          p.commodityType,
-          p.bigTypeID AS bigTypeId,
-          p.smallTypeID AS smallTypeId,
-          p.tinyTypeID AS tinyTypeId
+        p.productID AS productId,
+        p.actStatus,
+        p.name,
+        p.aliasName,
+        p.mainImage AS image,
+        p.unit,
+        p.productCode AS CODE,
+        p.price1TextFlag AS priceFlag,
+        p.price1 AS price,
+        p.costPrice,
+        p.costCheckFlag,
+        p.shopID AS shopId,
+        p.searchKey AS keyword,
+        p.price8Text AS beautyActFlag,
+        p.minBuyNumber AS minBuyNumber,
+        p.maxBuyNumber AS maxBuyNumber,
+        p.ladderPriceFlag,
+        p.normalPrice,
+        p.step,
+        p.shopID AS shopId,
+        p.taxPoint AS taxRate,
+        p.includedTax,
+        p.invoiceType,
+        p.productCategory AS productCategory,
+        p.validFlag,
+        p.featuredFlag,
+        p.commodityType,
+        p.bigTypeID AS bigTypeId,
+        p.smallTypeID AS smallTypeId,
+        p.tinyTypeID AS tinyTypeId
         FROM
-          cm_coupon_product a
-          LEFT JOIN product p ON a.productId = p.productID
+        cm_coupon_product a
+        LEFT JOIN product p ON a.productId = p.productID
         WHERE
-          a.delFlag = 0
-          AND a.couponId = #{couponId}
-          <if test="source == 1">
-              AND a.pcStatus = 1
-          </if>
-          <if test="source == 2">
-              AND a.appletsStatus = 1
-          </if>
+        a.delFlag = 0
+        AND a.couponId = #{couponId}
+        <if test="source == 1">
+            AND a.pcStatus = 1
+        </if>
+        <if test="source == 2">
+            AND a.appletsStatus = 1
+        </if>
         ORDER BY
-            -a.sort DESC
+        -a.sort DESC
     </select>
 
     <select id="findCouponList" resultType="com.caimei365.commodity.model.vo.CouponVo">
         SELECT
-          `id` AS "couponId",
-          `couponAmount`,
-          `touchPrice`,
-          `startDate`,
-          `endDate`,
-          `couponType`,
-          `userId`,
-          `shopId`,
-          `productType`,
-          `categoryType`
+        `id` AS "couponId",
+        `couponAmount`,
+        `touchPrice`,
+        `startDate`,
+        `endDate`,
+        `couponType`,
+        `userId`,
+        `shopId`,
+        `productType`,
+        `categoryType`
         FROM
-          cm_coupon
+        cm_coupon
         WHERE
-          delFlag = 0
-          AND NOW() BETWEEN startDate
-          AND endDate
-          AND status != 2
-          AND couponsMode = 0
-          <if test="userId == null or userId == 0">
-              AND couponType != 2
-          </if>
-          <if test="userId > 0">
-              AND id NOT IN(SELECT couponId FROM cm_coupon_club WHERE userId = #{userId})
-              AND (couponType IN (0,1,3)
-              OR couponType = 2 AND userId = #{userId}
-              OR ((SELECT registerTime FROM USER WHERE userID = #{userId}) <![CDATA[ >= ]]> startDate
-                    AND couponType = 4))
-          </if>
+        delFlag = 0
+        AND NOW() BETWEEN startDate
+        AND endDate
+        AND status != 2
+        AND couponsMode = 0
+        <if test="userId == null or userId == 0">
+            AND couponType != 2
+        </if>
+        <if test="userId > 0">
+            AND id NOT IN(SELECT couponId FROM cm_coupon_club WHERE userId = #{userId})
+            AND (couponType IN (0,1,3)
+            OR couponType = 2 AND userId = #{userId}
+            OR ((SELECT registerTime FROM USER WHERE userID = #{userId}) <![CDATA[ >= ]]> startDate
+            AND couponType = 4))
+        </if>
         ORDER BY
-          createDate DESC
+        createDate DESC
     </select>
 
     <select id="getCoupons" resultType="com.caimei365.commodity.model.vo.CouponVo">
-        SELECT
-          `id` AS "couponId",
-          `couponAmount`,
-          `touchPrice`,
-          `startDate`,
-          `endDate`,
-          `couponType`,
-          `userId`,
-          `shopId`,
-          `productType`,
-          `categoryType`
-        FROM
-          cm_coupon
-        WHERE
-          delFlag = 0
+        SELECT `id` AS "couponId",
+               `couponAmount`,
+               `touchPrice`,
+               `startDate`,
+               `endDate`,
+               `couponType`,
+               `userId`,
+               `shopId`,
+               `productType`,
+               `categoryType`
+        FROM cm_coupon
+        WHERE delFlag = 0
           AND status != 2
           AND id = #{couponId}
     </select>
 
     <select id="findCouponRedemptionCode" resultType="com.caimei365.commodity.model.po.CouponRedemptionCodePo">
-        SELECT
-          `id`,
-          `couponId`,
-          `clubCouponId`,
-          `redemptionCode`,
-          `status`,
-          `redemptionTime`,
-          `addTime`
-        FROM
-          `cm_coupon_redemption_code`
-        WHERE
-          redemptionCode = #{redemptionCode}
+        SELECT `id`,
+               `couponId`,
+               `clubCouponId`,
+               `redemptionCode`,
+               `status`,
+               `redemptionTime`,
+               `addTime`
+        FROM `cm_coupon_redemption_code`
+        WHERE redemptionCode = #{redemptionCode}
     </select>
 
     <select id="findCouponClubByUserId" resultType="integer">
-        SELECT
-          `id`
-        FROM
-          `cm_coupon_club`
-        WHERE
-          userId = #{userId}
+        SELECT `id`
+        FROM `cm_coupon_club`
+        WHERE userId = #{userId}
           AND couponId = #{couponId}
     </select>
 
     <insert id="insertCouponClub" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-        INSERT INTO `cm_coupon_club` (
-          `userId`,
-          `couponId`,
-          `orderId`,
-          `source`,
-          `status`,
-          `createDate`,
-          `useDate`,
-          `delFlag`
-        )
-        VALUES
-          (
-            #{userId},
-            #{couponId},
-            #{orderId},
-            #{source},
-            #{status},
-            #{createDate},
-            #{useDate},
-            #{delFlag}
-          )
+        INSERT INTO `cm_coupon_club` (`userId`,
+                                      `couponId`,
+                                      `orderId`,
+                                      `source`,
+                                      `status`,
+                                      `createDate`,
+                                      `useDate`,
+                                      `delFlag`)
+        VALUES (#{userId},
+                #{couponId},
+                #{orderId},
+                #{source},
+                #{status},
+                #{createDate},
+                #{useDate},
+                #{delFlag})
     </insert>
 
     <update id="updateRedemptionCode">
         UPDATE
-          cm_coupon_redemption_code
-        SET
-          STATUS = 2,
-          redemptionTime = NOW(),
-          clubCouponId = #{clubCouponId}
-        WHERE
-          id = #{id}
+            cm_coupon_redemption_code
+        SET STATUS         = 2,
+            redemptionTime = NOW(),
+            clubCouponId   = #{clubCouponId}
+        WHERE id = #{id}
     </update>
 
     <select id="findUserRegisterTime" resultType="date">
-        SELECT registerTime FROM user WHERE userID = #{userId}
+        SELECT registerTime
+        FROM user
+        WHERE userID = #{userId}
     </select>
+
+    <select id="findVip" resultType="java.lang.Integer">
+        select userId
+        from cm_svip_user
+        where userId = #{userId}
+          AND delFlag = 0
+          AND endtime > now()
+    </select>
+
+    <select id="findVipCoupon" resultType="java.lang.Integer">
+        select couponId
+        from cm_svip_coupon
+    </select>
+
 </mapper>