| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <?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.dk.oauth.mapper.integral.CouponUseMapper">
- <!-- 通用设置 -->
- <!-- 通用查询列 -->
- <sql id="Base_Column_List">
- use_id, cp_id, send_id, coupon_id, use_valid_days, receive_date, use_date, coupon_status, receive_user, flg_valid
- </sql>
- <!-- 通用查询列Response -->
- <sql id="Base_Column_List_Response">
- tmcu.use_id, tmcu.cp_id, tmcu.send_id, tmcu.coupon_id, tmcu.use_valid_days, tmcu.receive_date, tmcu.use_date, tmcu.coupon_status, tmcu.receive_user, tmcu.flg_valid
- </sql>
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dk.oauth.model.pojo.integral.CouponUse">
- <id column="use_id" property="useId" typeHandler="UuidTypeHandler"/>
- <result column="cp_id" property="cpId"/>
- <result column="send_id" property="sendId" typeHandler="UuidTypeHandler"/>
- <result column="coupon_id" property="couponId" typeHandler="UuidTypeHandler"/>
- <result column="use_valid_days" property="useValidDays"/>
- <result column="receive_date" property="receiveDate" typeHandler="TimestampTypeHandler"/>
- <result column="use_date" property="useDate" typeHandler="TimestampTypeHandler"/>
- <result column="coupon_status" property="couponStatus"/>
- <result column="receive_user" property="receiveUser" typeHandler="UuidTypeHandler"/>
- <result column="flg_valid" property="flgValid"/>
- </resultMap>
- <!-- 通用查询映射结果Response -->
- <resultMap id="BaseResultMapResponse" type="com.dk.oauth.model.response.integral.CouponUseResponse">
- <id column="use_id" property="useId" typeHandler="UuidTypeHandler"/>
- <result column="cp_id" property="cpId"/>
- <result column="send_id" property="sendId" typeHandler="UuidTypeHandler"/>
- <result column="cp_name" property="cpName"/>
- <result column="coupon_id" property="couponId" typeHandler="UuidTypeHandler"/>
- <result column="coupon_name" property="couponName" />
- <result column="use_valid_days" property="useValidDays"/>
- <result column="receive_date" property="receiveDate" typeHandler="TimestampTypeHandler"/>
- <result column="use_date" property="useDate" typeHandler="TimestampTypeHandler"/>
- <result column="coupon_status" property="couponStatus"/>
- <result column="receive_user" property="receiveUser" typeHandler="UuidTypeHandler"/>
- <result column="flg_valid" property="flgValid"/>
- </resultMap>
- <!-- 通用条件列 -->
- <sql id="Condition">
- <where>
- <if test="cpId != null and cpId != ''">
- AND tmcu.cp_id = #{cpId}
- </if>
- <if test="sendId != null and sendId != ''">
- AND tmcu.send_id = #{sendId}::uuid
- </if>
- <if test="couponId != null and couponId != ''">
- AND tmcu.coupon_id = #{couponId}::uuid
- </if>
- <if test="useValidDays != null">
- AND tmcu.use_valid_days = #{useValidDays}
- </if>
- <if test="receiveDate != null">
- AND tmcu.receive_date = #{receiveDate}
- </if>
- <if test="useDate != null">
- AND tmcu.use_date = #{useDate}
- </if>
- <if test="couponStatus != null and couponStatus != ''">
- AND tmcu.coupon_status = #{couponStatus}
- </if>
- <if test="receiveUser != null and receiveUser != ''">
- AND tmcu.receive_user = #{receiveUser}
- </if>
- <if test="flgValid != null">
- AND tmcu.flg_valid = #{flgValid}
- </if>
- <if test="cpName != null and cpName != ''">
- AND tac.cp_name LIKE concat('%',my_ex.likequery(#{cpName}),'%')
- </if>
- <if test="couponName != null and couponName != ''">
- AND tmc.coupon_name LIKE concat('%',my_ex.likequery(#{couponName}),'%')
- </if>
- </where>
- </sql>
- <sql id="idsForeach">
- <!-- 根据主键cpId批量操作 -->
- WHERE use_id in
- <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </sql>
- <!-- 查询表t_mst_coupon_use,(条件查询+分页)列表 -->
- <select id="selectByCond" resultMap="BaseResultMapResponse">
- SELECT
- <include refid="Base_Column_List_Response"/>
- ,tmc.coupon_name
- ,tac.cp_name
- FROM dkic_a.t_mst_coupon_use tmcu
- left join dkic_a.t_mst_coupon tmc on tmc.coupon_id = tmcu.coupon_id
- left join dkic_a.t_a_company tac on tac.cp_id = tmcu.cp_id
- <include refid="Condition"/>
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询表t_mst_coupon_use,(条件查询)个数 -->
- <select id="countByCond" resultType="Long">
- SELECT
- count(1)
- FROM dkic_a.t_mst_coupon_use tmcu
- left join dkic_a.t_mst_coupon tmc on tmc.coupon_id = tmcu.coupon_id
- left join dkic_a.t_a_company tac on tac.cp_id = tmcu.cp_id
- <include refid="Condition"/>
- </select>
- <!-- 根据主键查询表t_mst_coupon_use的一行数据 -->
- <select id="selectById" resultMap="BaseResultMapResponse">
- SELECT
- <include refid="Base_Column_List_Response"/>
- ,tmc.coupon_name
- ,tac.cp_name
- FROM dkic_a.t_mst_coupon_use tmcu
- left join dkic_a.t_mst_coupon tmc on tmc.coupon_id = tmcu.coupon_id
- left join dkic_a.t_a_company tac on tac.cp_id = tmcu.cp_id
- WHERE use_id = #{id}
- </select>
- <!-- 根据主键锁定表t_mst_coupon_use的一行数据 -->
- <select id="selectByIdForUpdate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM dkic_a.t_mst_coupon_use
- WHERE use_id = #{useId}
- for update
- </select>
- <!-- 根据主键锁定表t_mst_coupon_use的多行数据 -->
- <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- FROM dkic_a.t_mst_coupon_use
- <include refid="idsForeach"/>
- for update
- </select>
- <insert id="insertBatch">
- insert into dkic_a.t_mst_coupon_use
- (
- <trim suffixOverrides=",">
- cp_id,
- coupon_id,
- send_id,
- use_valid_days,
- receive_date,
- use_date,
- coupon_status,
- receive_user,
- </trim>
- )
- values
- <foreach collection="list" index="index" item="item" separator=",">
- (
- <trim suffixOverrides=",">
- #{item.cpId},
- #{item.sendId}::uuid,
- #{item.couponId}::uuid,
- #{item.useValidDays},
- #{item.receiveDate},
- #{item.useDate},
- #{item.couponStatus},
- #{item.receiveUser}::uuid,
- </trim>
- )
- </foreach>
- </insert>
- </mapper>
|