|
@@ -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>
|