123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <?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.coupon.CouponDao" >
- <resultMap id="BaseResultMap" type="com.ygj.yuemum.domain.coupon.Coupon" >
- <id column="id" property="id" jdbcType="INTEGER" />
- <result column="cp_code" property="cp_code" jdbcType="VARCHAR" />
- <result column="cb_code" property="cb_code" jdbcType="VARCHAR" />
- <result column="cc_code" property="cc_code" jdbcType="INTEGER" />
- <result column="cp_startdate" property="cp_startdate" jdbcType="DATE" />
- <result column="cp_enddate" property="cp_enddate" jdbcType="DATE" />
- <result column="cp_amount" property="cp_amount" jdbcType="INTEGER" />
- <result column="cp_status" property="cp_status" jdbcType="INTEGER" />
- </resultMap>
- <sql id="Base_Column_List" >
- id, cp_code,cc_code,cb_code,cp_startdate,cp_enddate,cp_amount,cp_status
- </sql>
- <!--获取所有数据-->
- <select id="getCount" resultType="java.lang.Integer" >
- select
- count(1)
- from coupon
- </select>
- <select id="getAll" resultMap="BaseResultMap" >
- select
- <include refid="Base_Column_List" />
- from coupon
- order by id desc
- </select>
- <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
- select
- <include refid="Base_Column_List" />
- from coupon
- where id = #{id,jdbcType=INTEGER}
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
- delete from coupon
- where id = #{id,jdbcType=INTEGER}
- </delete>
- <update id="disableCoupon" parameterType="java.lang.Integer" >
- update coupon
- set cp_status = 4
- where cc_code = #{id,jdbcType=INTEGER}
- </update>
- <update id="enableCoupon" parameterType="java.lang.Integer" >
- update coupon
- set cp_status = 1
- where cc_code = #{id,jdbcType=INTEGER}
- </update>
- <insert id="insertSelective" parameterType="com.ygj.yuemum.domain.coupon.Coupon" >
- insert into coupon
- <trim prefix="(" suffix=")" suffixOverrides="," >
- <if test="cp_code != null" >
- cp_code,
- </if>
- <if test="cb_code != null" >
- cb_code,
- </if>
- <if test="cc_code != null" >
- cc_code,
- </if>
- <if test="cp_startdate != null" >
- cp_startdate,
- </if>
- <if test="cp_enddate != null" >
- cp_enddate,
- </if>
- <if test="cp_amount != null" >
- cp_amount,
- </if>
- <if test="cp_status != null" >
- cp_status
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides="," >
- <if test="cp_code != null" >
- #{cp_code,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_startdate != null" >
- #{cp_startdate,jdbcType=DATE},
- </if>
- <if test="cp_enddate != null" >
- #{cp_enddate,jdbcType=DATE},
- </if>
- <if test="cp_amount != null" >
- #{cp_amount,jdbcType=INTEGER},
- </if>
- <if test="cp_status != null" >
- #{cp_status,jdbcType=INTEGER}
- </if>
- </trim>
- </insert>
- <!--Modoo API-->
- <select id="getCoupon" resultType="java.lang.String" parameterType="java.lang.String" >
- select
- cp_code
- from coupon
- where cb_code = #{cb_code,jdbcType=INTEGER}
- and cp_status = 1
- and cp_enddate > now()
- order by id asc limit 1
- </select>
- <select id="getCouponAmount" resultType="java.lang.String" parameterType="com.ygj.yuemum.domain.coupon.Coupon" >
- select
- cp_code
- from coupon
- where
- 1=1
- <if test="cb_code != null and cb_code != ''">
- and cb_code = #{cb_code,jdbcType=VARCHAR}
- </if>
- <if test="cp_amount != null and cp_amount != ''">
- and cp_amount = #{cp_amount,jdbcType=INTEGER}
- </if>
- and cp_status = 1
- and cp_enddate > now()
- order by id asc limit 1
- </select>
- <update id="updateGetCoupon" parameterType="java.lang.String" >
- update coupon
- set cp_status = 2
- where cp_code = #{cp_code,jdbcType=INTEGER}
- </update>
- <update id="updateUseCoupon" parameterType="com.ygj.yuemum.domain.customer.CustomerCoupon" >
- update coupon
- <set >
- <if test="cp_status != null" >
- cp_status = #{cp_status,jdbcType=VARCHAR},
- </if>
- </set>
- where cp_code = #{cp_code,jdbcType=INTEGER}
- </update>
- </mapper>
|