123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357 |
- <?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.ygj.yuemum.dao.customer.CustomerCouponDao" >
- <resultMap id="BaseResultMap" type="com.ygj.yuemum.domain.customer.CustomerCoupon" >
- <id column="id" property="id" jdbcType="INTEGER" />
- <result column="cm_code" property="cm_code" jdbcType="VARCHAR" />
- <result column="cm_phone" property="cm_phone" jdbcType="VARCHAR" />
- <result column="cb_code" property="cb_code" jdbcType="VARCHAR" />
- <result column="cc_code" property="cc_code" jdbcType="VARCHAR" />
- <result column="cp_status" property="cp_status" jdbcType="INTEGER" />
- <result column="cc_getdate" property="cc_getdate" jdbcType="DATE" />
- <result column="cc_getchannel" property="cc_getchannel" jdbcType="INTEGER" />
- <result column="cc_usedate" property="cc_usedate" jdbcType="DATE" />
- <result column="cc_usebillno" property="cc_usebillno" jdbcType="VARCHAR" />
- <result column="cb_name" property="cb_name" jdbcType="VARCHAR" />
- <result column="cb_rule" property="cb_rule" jdbcType="VARCHAR" />
- <result column="cb_packages" property="cb_packages" jdbcType="VARCHAR" />
- <result column="cb_citys" property="cb_citys" jdbcType="VARCHAR" />
- <result column="cp_enddate" property="cp_enddate" jdbcType="DATE" />
- <result column="cp_amount" property="cp_amount" jdbcType="INTEGER" />
- <result column="cc_quantity" property="cc_quantity" jdbcType="INTEGER" />
- </resultMap>
- <sql id="Base_Column_List" >
- id, cm_code,cm_phone,cb_code,cc_code,cp_status,cc_getdate,cc_getchannel,cc_usedate,cc_usebillno
- </sql>
- <!--获取所有数据-->
- <select id="getCount" resultType="java.lang.Integer" >
- select
- count(1)
- from customer_coupon
- </select>
- <select id="getAll" resultMap="BaseResultMap" >
- select
- id, cm_code,cm_phone,cb_code,cc_code,cp_status,cc_getdate,cc_getchannel,cc_usedate,cc_usebillno
- from customer_coupon
- order by id desc
- </select>
- <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
- select
- <include refid="Base_Column_List" />
- from customer_coupon
- where id = #{id,jdbcType=INTEGER}
- </select>
- <select id="getCouponSum" resultMap="BaseResultMap" parameterType="com.ygj.yuemum.domain.customer.CustomerCouponQuery" >
- SELECT
- cm_phone,
- count(1) cc_quantity,
- sum(cp_amount) cp_amount
- FROM
- (
- SELECT
- ta.cm_phone,
- ta.cc_code,
- tb.cb_packages,
- tb.cb_citys
- FROM
- customer_coupon ta
- LEFT JOIN coupon_batch tb ON ta.cb_code = tb.cb_code
- where ta.cp_status = 2
- <if test="cm_phone != null and cm_phone != ''" >
- and ta.cm_phone = #{cm_phone,jdbcType=VARCHAR}
- </if>
- <if test="cb_packages != null and cb_packages != ''">
- and tb.cb_packages like concat ('%',#{cb_packages,jdbcType=VARCHAR},'%')
- </if>
- <if test="cb_citys != null and cb_citys != ''">
- and tb.cb_citys like concat ('%',#{cb_citys,jdbcType=VARCHAR},'%')
- </if>
- ) tta,
- coupon ttb
- WHERE
- tta.cc_code = ttb.cp_code
- group by tta.cm_phone
- </select>
- <select id="getCustomerCoupons" resultMap="BaseResultMap" parameterType="com.ygj.yuemum.domain.customer.CustomerCouponQuery" >
- SELECT
- ta.cc_code,
- tb.cb_name,
- tb.cb_rule,
- fgetpackages(tb.id) cb_packages,
- fgetmoretcityname(tb.id) cb_citys,
- tc.cp_startdate,
- tc.cp_enddate,
- tc.cp_amount,
- cc_getdate,
- ta.cp_status
- FROM
- customer_coupon ta
- LEFT JOIN coupon_batch tb ON ta.cb_code = tb.cb_code
- left JOIN coupon tc on ta.cc_code = tc.cp_code
- where
- 1=1
- <if test="cm_phone != null and cm_phone != ''" >
- and ta.cm_phone = #{cm_phone,jdbcType=VARCHAR}
- </if>
- <if test="cb_packages != null and cb_packages != ''">
- and tb.cb_packages like concat ('%',#{cb_packages,jdbcType=VARCHAR},'%')
- </if>
- <if test="cb_citys != null and cb_citys != ''">
- and tb.cb_citys like concat ('%',#{cb_citys,jdbcType=VARCHAR},'%')
- </if>
- and ta.cp_status = 2
- order by ta.cb_code ,tc.cp_amount desc
- </select>
- <select id="getWXCustomerCoupons" resultMap="BaseResultMap" parameterType="java.lang.String" >
- SELECT
- ta.cc_code,
- ta.cb_code,
- tb.cb_name,
- tb.cb_rule,
- fgetpackages(tb.id) cb_packages,
- fgetmoretcityname(tb.id) cb_citys,
- DATE_FORMAT(tc.cp_startdate,'%Y-%m-%d') cp_startdate,
- DATE_FORMAT(tc.cp_enddate,'%Y-%m-%d') cp_enddate,
- tc.cp_amount,
- cc_getdate,
- ta.cp_status,
- IFNULL(td.no_amount,0) no_amount
- FROM
- customer_coupon ta
- LEFT JOIN coupon_batch tb ON ta.cb_code = tb.cb_code
- left JOIN coupon tc on ta.cc_code = tc.cp_code
- left join coupon_create td on ta.cb_code = td.cb_code
- where
- ta.cm_phone = #{cm_phone,jdbcType=VARCHAR}
- and ta.cp_status = 2
- order by ta.cb_code ,tc.cp_amount desc
- </select>
- <select id="getCustomerCouponsCount" resultType="java.lang.Integer" parameterType="com.ygj.yuemum.domain.customer.CustomerCouponQuery" >
- SELECT
- count(1)
- FROM
- customer_coupon ta
- LEFT JOIN coupon_batch tb ON ta.cb_code = tb.cb_code
- left JOIN coupon tc on ta.cc_code = tc.cp_code
- where
- 1=1
- <if test="cm_phone != null and cm_phone != ''" >
- and ta.cm_phone = #{cm_phone,jdbcType=VARCHAR}
- </if>
- <if test="cb_packages != null and cb_packages != ''">
- and tb.cb_packages like concat ('%',#{cb_packages,jdbcType=VARCHAR},'%')
- </if>
- <if test="cb_citys != null and cb_citys != ''">
- and tb.cb_citys like concat ('%',#{cb_citys,jdbcType=VARCHAR},'%')
- </if>
- and ta.cp_status = 2
- order by ta.cb_code ,tc.cp_amount desc
- </select>
- <select id="checkCustomerCoupon" resultType="java.lang.Integer" parameterType="com.ygj.yuemum.domain.customer.CustomerCoupon" >
- SELECT
- count(1)
- FROM
- customer_coupon
- WHERE
- 1=1
- <if test="_parameter != null" >
- and cm_phone = #{cm_phone,jdbcType=VARCHAR}
- </if>
- <if test="cb_code != null" >
- and cb_code = #{cb_code,jdbcType=VARCHAR}
- </if>
- </select>
- <select id="checkSumCustomerCoupon" resultType="java.lang.Integer" parameterType="java.lang.String" >
- SELECT
- ifnull(sum(tb.cp_amount), 0)
- FROM
- customer_coupon ta,
- coupon tb
- WHERE
- ta.cc_code = tb.cp_code
- <if test="_parameter != null" >
- and cm_phone = #{cm_phone,jdbcType=VARCHAR}
- </if>
- AND ta.cp_status = 1
- AND tb.cc_code IN (
- 'PVP2018051297451',
- 'PVP2018051273883',
- 'PVP2018051211608',
- 'PVP2018051263016'
- )
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
- delete from customer_coupon
- where cb_code = #{cb_code,jdbcType=VARCHAR}
- </delete>
- <!-- 插入一条培训信息 -->
- <insert id="insertSelective" parameterType="com.ygj.yuemum.domain.customer.CustomerCoupon" >
- insert into customer_coupon
- <trim prefix="(" suffix=")" suffixOverrides="," >
- <if test="cm_code != null" >
- cm_code,
- </if>
- <if test="cm_phone != null" >
- cm_phone,
- </if>
- <if test="cb_code != null" >
- cb_code,
- </if>
- <if test="cc_code != null" >
- cc_code,
- </if>
- <if test="cp_status != null" >
- cp_status,
- </if>
- <if test="cc_getdate != null" >
- cc_getdate,
- </if>
- <if test="cc_getchannel != null" >
- cc_getchannel,
- </if>
- <if test="cc_usedate != null" >
- cc_usedate,
- </if>
- <if test="cc_usebillno != null" >
- cc_usebillno
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides="," >
- <if test="cm_code != null" >
- #{cm_code,jdbcType=VARCHAR},
- </if>
- <if test="cm_phone != null" >
- #{cm_phone,jdbcType=VARCHAR},
- </if>
- <if test="cb_code != null" >
- #{cb_code,jdbcType=VARCHAR},
- </if>
- <if test="cc_code != null" >
- #{cc_code,jdbcType=VARCHAR},
- </if>
- <if test="cp_status != null" >
- #{cp_status,jdbcType=INTEGER},
- </if>
- <if test="cc_getdate != null" >
- #{cc_getdate,jdbcType=DATE},
- </if>
- <if test="cc_getchannel != null" >
- #{cc_getchannel,jdbcType=INTEGER},
- </if>
- <if test="cc_usedate != null" >
- #{cc_usedate,jdbcType=DATE},
- </if>
- <if test="cc_usebillno != null" >
- #{cc_usebillno,jdbcType=VARCHAR}
- </if>
- </trim>
- </insert>
- <!-- 根据id更新一条培训信息 -->
- <update id="updateByPrimaryKeySelective" parameterType="com.ygj.yuemum.domain.customer.CustomerCoupon" >
- update customer_coupon
- <set >
- <if test="cm_code != null" >
- cm_code = #{cm_code,jdbcType=VARCHAR},
- </if>
- <if test="cm_phone != null" >
- cm_phone = #{cm_phone,jdbcType=VARCHAR},
- </if>
- <if test="cb_rule != null" >
- cb_rule = #{cb_rule,jdbcType=VARCHAR},
- </if>
- <if test="cb_packages != null" >
- cb_packages = #{cb_packages,jdbcType=VARCHAR},
- </if>
- <if test="cb_citys != null" >
- cb_citys = #{cb_citys,jdbcType=VARCHAR}
- </if>
- </set>
- where id = #{id,jdbcType=INTEGER}
- </update>
- <select id="getQCouponBatchconut" resultType="java.lang.Integer" parameterType="com.ygj.yuemum.domain.customer.CustomerCoupon">
- select
- count(1)
- from customer_coupon
- where 1=1
- <if test="id != null and id != ''">
- and id = #{id,jdbcType=INTEGER}
- </if>
- <if test="cb_code != null and cb_code != ''">
- and cb_code = #{cb_code,jdbcType=INTEGER}
- </if>
- <if test="cb_name != null and cb_name != ''">
- and cb_name like concat ('%',#{cb_name,jdbcType=VARCHAR},'%')
- </if>
- <if test="cb_rule != null and cb_rule != ''">
- and cb_rule like concat ('%',#{cb_rule,jdbcType=VARCHAR},'%')
- </if>
- <if test="cb_packages != null and cb_packages != ''">
- and cb_packages like concat ('%',#{cb_packages,jdbcType=VARCHAR},'%')
- </if>
- <if test="cb_citys != null and cb_citys != ''">
- and cb_citys like concat ('%',#{cb_citys,jdbcType=VARCHAR},'%')
- </if>
- </select>
- <select id="getQCouponBatch" resultMap="BaseResultMap" parameterType="com.ygj.yuemum.domain.customer.CustomerCoupon">
- select
- id, cb_code,cb_name,cb_rule,fgetpackages(id) cb_packages,fgetmoretcityname(id) cb_citys
- from customer_coupon
- where 1=1
- <if test="id != null and id != ''">
- and id = #{id,jdbcType=INTEGER}
- </if>
- <if test="cb_code != null and cb_code != ''">
- and cb_code = #{cb_code,jdbcType=INTEGER}
- </if>
- <if test="cb_name != null and cb_name != ''">
- and cb_name like concat ('%',#{cb_name,jdbcType=VARCHAR},'%')
- </if>
- <if test="cb_rule != null and cb_rule != ''">
- and cb_rule like concat ('%',#{cb_rule,jdbcType=VARCHAR},'%')
- </if>
- <if test="cb_packages != null and cb_packages != ''">
- and cb_packages like concat ('%',#{cb_packages,jdbcType=VARCHAR},'%')
- </if>
- <if test="cb_citys != null and cb_citys != ''">
- and cb_citys like concat ('%',#{cb_citys,jdbcType=VARCHAR},'%')
- </if>
- </select>
- <update id="updateCustomerUseCoupon" parameterType="com.ygj.yuemum.domain.customer.CustomerCoupon" >
- update customer_coupon
- <set >
- <if test="cp_status != null" >
- cp_status = #{cp_status,jdbcType=VARCHAR},
- </if>
- </set>
- where cc_code = #{cc_code,jdbcType=INTEGER}
- </update>
- </mapper>
|