123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.caimei.modules.coupon.dao.CmCouponVipDao">
- <sql id="cmCouponColumns">
- a.id AS "id",
- a.name AS "name",
- a.couponAmount AS "couponAmount",
- a.touchPrice AS "touchPrice",
- a.startDate AS "startDate",
- a.endDate AS "endDate",
- a.status AS "status",
- a.couponType AS "couponType",
- a.userId AS "userId",
- a.shopId AS "shopId",
- a.productType AS "productType",
- a.pcBanner AS "pcBanner",
- a.appletsBanner AS "appletsBanner",
- a.categoryType AS "categoryType",
- a.couponsMode AS "couponsMode",
- a.createDate AS "createDate",
- a.delFlag AS "delFlag"
- </sql>
- <insert id="insertVipCouponMonth" parameterType="CmVipCoupon" keyProperty="id" useGeneratedKeys="true">
- INSERT INTO cm_svip_coupon_month (useTime, updateTime, status,delFlag)
- VALUES (#{useTime}, #{updateTime}, #{status}, #{delFlag})
- </insert>
- <update id="updateVipCouponMonth" parameterType="CmVipCoupon">
- UPDATE cm_svip_coupon_month SET useTime=#{useTime}, updateTime=#{updateTime}, status=#{status}, delFlag=#{delFlag}
- WHERE id=#{id}
- </update>
- <insert id="insertVipCouponRelation">
- INSERT INTO cm_svip_coupon (couponId, montId, updateTime, delFlag)
- VALUES (#{couponId}, #{montId}, #{updateTime}, #{delFlag})
- </insert>
- <update id="updateVipCouponRelation">
- UPDATE cm_svip_coupon SET couponId=#{couponId}, montId=#{montId}, updateTime=#{updateTime}, delFlag=#{delFlag}
- WHERE id=#{id}
- </update>
- <select id="get" resultType="CmVipCoupon">
- SELECT DISTINCT id, useTime, status, updateTime, delFlag
- FROM cm_svip_coupon_month
- WHERE id = #{id}
- LIMIT 1
- </select>
- <select id="getBindCoupons" resultType="java.lang.String">
- SELECT couponId from cm_svip_coupon WHERE montId = #{montId} AND delFlag=0
- </select>
- <select id="findList" resultType="CmVipCoupon">
- SELECT cs.id, cs.useTime, cs.status, cs.updateTime, cs.delFlag
- FROM cm_svip_coupon_month cs
- <where>
- AND cs.delFlag = 0
- <if test="startDate!=null and startDate!=''">
- AND cs.useTime <![CDATA[ >= ]]> #{startDate}
- </if>
- <if test="endDate!=null and endDate!=''">
- AND cs.useTime <![CDATA[ <= ]]> #{endDate}
- </if>
- </where>
- ORDER BY cs.useTime DESC
- </select>
- <select id="getCouponListByIds" resultType="com.caimei.modules.coupon.entity.CmCoupon">
- SELECT
- <include refid="cmCouponColumns"/>,
- u.name AS "clubName",
- s.name AS "shopName"
- FROM cm_coupon a
- LEFT JOIN cm_coupon_club ccc ON ccc.couponId = a.id
- LEFT JOIN USER u ON u.userID = a.userId
- LEFT JOIN shop s ON s.shopID = a.shopId
- <where>
- AND a.delFlag = 0
- <if test="couponType != null">
- AND a.couponType = #{couponType}
- </if>
- <if test='status == "0"'>
- AND a.startDate <![CDATA[ > ]]> NOW()
- </if>
- <if test='status == "1"'>
- AND a.startDate <![CDATA[ <= ]]> NOW()
- AND a.endDate <![CDATA[ >= ]]> NOW()
- AND a.status != '2'
- </if>
- <if test='status == "2"'>
- AND a.status = '2'
- </if>
- <if test='status == "3"'>
- AND a.endDate <![CDATA[ < ]]> NOW()
- </if>
- <if test="bindCoupons != null">
- AND a.id IN
- <foreach collection="bindCoupons" open="(" separator="," close=")" item="couponId">
- #{couponId}
- </foreach>
- </if>
- </where>
- GROUP BY a.id
- ORDER BY createDate DESC
- </select>
- <delete id="deleteByMonthId">
- UPDATE cm_svip_coupon SET delFlag=1 WHERE montId = #{montId}
- </delete>
- <select id="findShopName" resultType="com.caimei.modules.user.entity.NewCmShop">
- select name,sname,linkMan,contractMobile
- from shop
- where shopID = #{shopId}
- </select>
- <!-- <select id="findGroup" resultType="com.caimei.modules.coupon.entity.CmVipCouponRelation">-->
- <!-- select *-->
- <!-- from cm_svip_coupon cs-->
- <!-- where useTime = #{useTime}-->
- <!-- AND cs.delFlag=0-->
- <!-- <if test="status!=null and status != ''">-->
- <!-- AND cs.status=#{status}-->
- <!-- </if>-->
- <!-- </select>-->
- <!-- <select id="findUseTime" resultType="String">-->
- <!-- SELECT DISTINCT usetime-->
- <!-- FROM cm_svip_coupon-->
- <!-- </select>-->
- <!-- <select id="findBind" resultType="java.lang.String">-->
- <!-- SELECT DISTINCT bindCoupon-->
- <!-- FROM cm_svip_coupon-->
- <!-- </select>-->
- <!-- <select id="findByCoupon" resultType="com.caimei.modules.coupon.entity.CmVipCouponRelation">-->
- <!-- select useTime, status, couponId, bindCoupon-->
- <!-- from cm_svip_coupon-->
- <!-- where delFlag = 0-->
- <!-- and couponId=#{couponId}-->
- <!-- <if test="status != null and status != ''">-->
- <!-- and status=#{status}-->
- <!-- </if>-->
- <!-- </select>-->
- </mapper>
|