|
|
@@ -0,0 +1,276 @@
|
|
|
+<?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.mdm.mapper.mst.CpTradeMapper">
|
|
|
+
|
|
|
+ <!-- 通用设置 -->
|
|
|
+ <!-- 通用查询列 -->
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ trade_id, trade_no, cp_id, wx_user_id, trade_amount, trade_time, trade_type, buy_long, buy_begin_date, buy_end_date, buy_fun_id, buy_grade_code, wx_trade_no, extend_days, dk_user_id, trade_status
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 通用查询列 -->
|
|
|
+ <sql id="Base_Column_List_list">
|
|
|
+ tct.trade_id,
|
|
|
+ tct.trade_no,
|
|
|
+ tct.cp_id,
|
|
|
+ tct.wx_user_id,
|
|
|
+ tct.trade_amount,
|
|
|
+ tct.trade_time,
|
|
|
+ tct.trade_type,
|
|
|
+ tct.buy_long,
|
|
|
+ tct.buy_begin_date,
|
|
|
+ tct.buy_end_date,
|
|
|
+ tct.buy_fun_id,
|
|
|
+ tct.wx_trade_no,
|
|
|
+ tct.extend_days,
|
|
|
+ tct.dk_user_id,
|
|
|
+ tct.trade_status
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 通用查询映射结果 -->
|
|
|
+ <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.CpTrade">
|
|
|
+ <id column="trade_id" property="tradeId"/>
|
|
|
+ <result column="trade_no" property="tradeNo"/>
|
|
|
+ <result column="cp_id" property="cpId"/>
|
|
|
+ <result column="wx_user_id" property="wxUserId" typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="trade_amount" property="tradeAmount"/>
|
|
|
+ <result column="trade_time" property="tradeTime" typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="trade_type" property="tradeType"/>
|
|
|
+ <result column="buy_long" property="buyLong"/>
|
|
|
+ <result column="buy_begin_date" property="buyBeginDate" typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="buy_end_date" property="buyEndDate" typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="buy_fun_id" property="buyFunId" typeHandler="UuidListTypeHandler"/>
|
|
|
+ <result column="buy_grade_code" property="buyGradeCode"/>
|
|
|
+ <result column="wx_trade_no" property="wxTradeNo"/>
|
|
|
+ <result column="extend_days" property="extendDays"/>
|
|
|
+ <result column="dk_user_id" property="dkUserId" typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="trade_status" property="tradeStatus"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 通用查询映射结果 -->
|
|
|
+ <resultMap id="BaseResultMap_list" type="com.dk.mdm.model.response.mst.CpTradeResponse">
|
|
|
+ <id column="trade_id" property="tradeId"/>
|
|
|
+ <result column="trade_no" property="tradeNo"/>
|
|
|
+ <result column="cp_id" property="cpId"/>
|
|
|
+ <result column="wx_user_id" property="wxUserId" typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="trade_amount" property="tradeAmount"/>
|
|
|
+ <result column="trade_time" property="tradeTime" typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="trade_type" property="tradeType"/>
|
|
|
+ <result column="buy_long" property="buyLong"/>
|
|
|
+ <result column="buy_begin_date" property="buyBeginDate" typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="buy_end_date" property="buyEndDate" typeHandler="TimestampTypeHandler"/>
|
|
|
+ <result column="buy_fun_id" property="buyFunId" typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="buy_grade_code" property="buyGradeCode"/>
|
|
|
+ <result column="wx_trade_no" property="wxTradeNo"/>
|
|
|
+ <result column="extend_days" property="extendDays"/>
|
|
|
+ <result column="dk_user_id" property="dkUserId" typeHandler="UuidTypeHandler"/>
|
|
|
+ <result column="trade_status" property="tradeStatus"/>
|
|
|
+ <result column="cp_name" property="cpName"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 通用条件列 -->
|
|
|
+ <sql id="Condition">
|
|
|
+ <where>
|
|
|
+ <if test="tradeNo != null and tradeNo != ''">
|
|
|
+ AND trade_no = #{tradeNo}
|
|
|
+ </if>
|
|
|
+ <if test="cpId != null">
|
|
|
+ AND cp_id = #{cpId}
|
|
|
+ </if>
|
|
|
+ <if test="wxUserId != null and wxUserId != ''">
|
|
|
+ AND wx_user_id = #{wxUserId}
|
|
|
+ </if>
|
|
|
+ <if test="tradeAmount != null">
|
|
|
+ AND trade_amount = #{tradeAmount}
|
|
|
+ </if>
|
|
|
+ <if test="tradeTime != null">
|
|
|
+ AND trade_time = #{tradeTime}
|
|
|
+ </if>
|
|
|
+ <if test="tradeType != null and tradeType != ''">
|
|
|
+ AND trade_type = #{tradeType}
|
|
|
+ </if>
|
|
|
+ <if test="buyLong != null and buyLong != ''">
|
|
|
+ AND buy_long = #{buyLong}
|
|
|
+ </if>
|
|
|
+ <if test="buyBeginDate != null">
|
|
|
+ AND buy_begin_date = #{buyBeginDate}
|
|
|
+ </if>
|
|
|
+ <if test="buyEndDate != null">
|
|
|
+ AND buy_end_date = #{buyEndDate}
|
|
|
+ </if>
|
|
|
+ <if test="buyFunId != null and buyFunId != ''">
|
|
|
+ AND buy_fun_id = #{buyFunId}
|
|
|
+ </if>
|
|
|
+ <if test="buyGradeCode != null and buyGradeCode != ''">
|
|
|
+ AND buy_grade_code = #{buyGradeCode}
|
|
|
+ </if>
|
|
|
+ <if test="wxTradeNo != null and wxTradeNo != ''">
|
|
|
+ AND wx_trade_no = #{wxTradeNo}
|
|
|
+ </if>
|
|
|
+ <if test="extendDays != null">
|
|
|
+ AND extend_days = #{extendDays}
|
|
|
+ </if>
|
|
|
+ <if test="dkUserId != null and dkUserId != ''">
|
|
|
+ AND dk_user_id = #{dkUserId}
|
|
|
+ </if>
|
|
|
+ <if test="tradeStatus != null and tradeStatus != ''">
|
|
|
+ AND trade_status = #{tradeStatus}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 通用条件列 -->
|
|
|
+ <sql id="Condition_list">
|
|
|
+ <where>
|
|
|
+ <if test="tradeNo != null and tradeNo != ''">
|
|
|
+ AND tct.trade_no LIKE concat('%',my_ex.likequery(#{tradeNo}),'%')
|
|
|
+ </if>
|
|
|
+ <if test="cpId != null">
|
|
|
+ AND tct.cp_id = #{cpId}
|
|
|
+ </if>
|
|
|
+ <if test="wxUserId != null and wxUserId != ''">
|
|
|
+ AND tct.wx_user_id = #{wxUserId}
|
|
|
+ </if>
|
|
|
+ <if test="tradeAmount != null">
|
|
|
+ AND tct.trade_amount = #{tradeAmount}
|
|
|
+ </if>
|
|
|
+ <if test="tradeTime != null">
|
|
|
+ AND tct.trade_time = #{tradeTime}
|
|
|
+ </if>
|
|
|
+ <if test="tradeType != null and tradeType != ''">
|
|
|
+ AND tct.trade_type = #{tradeType}
|
|
|
+ </if>
|
|
|
+ <if test="buyLong != null and buyLong != ''">
|
|
|
+ AND tct.buy_long = #{buyLong}
|
|
|
+ </if>
|
|
|
+ <if test="buyBeginDate != null">
|
|
|
+ AND tct.buy_begin_date = #{buyBeginDate}
|
|
|
+ </if>
|
|
|
+ <if test="buyEndDate != null">
|
|
|
+ AND tct.buy_end_date = #{buyEndDate}
|
|
|
+ </if>
|
|
|
+ <if test="buyFunId != null and buyFunId != ''">
|
|
|
+ AND tct.buy_fun_id = #{buyFunId}
|
|
|
+ </if>
|
|
|
+ <if test="buyGradeCode != null and buyGradeCode != ''">
|
|
|
+ AND tct.buy_grade_code = #{buyGradeCode}
|
|
|
+ </if>
|
|
|
+ <if test="wxTradeNo != null and wxTradeNo != ''">
|
|
|
+ AND tct.wx_trade_no = #{wxTradeNo}
|
|
|
+ </if>
|
|
|
+ <if test="extendDays != null">
|
|
|
+ AND tct.extend_days = #{extendDays}
|
|
|
+ </if>
|
|
|
+ <if test="dkUserId != null and dkUserId != ''">
|
|
|
+ AND tct.dk_user_id = #{dkUserId}
|
|
|
+ </if>
|
|
|
+ <if test="tradeStatus != null and tradeStatus != ''">
|
|
|
+ AND tct.trade_status = #{tradeStatus}
|
|
|
+ </if>
|
|
|
+ <if test="cpIds != null and cpIds.size()>0">
|
|
|
+ AND tct.cp_id = any(#{cpIds, typeHandler=IntListTypeHandler})
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <sql id="idsForeach">
|
|
|
+ <!-- 根据主键tradeId批量操作 -->
|
|
|
+ WHERE trade_id in
|
|
|
+ <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 查询表dkic_a.t_cp_trade,(条件查询+分页)列表 -->
|
|
|
+ <select id="selectByCond" resultMap="BaseResultMap_list">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List_list"/>
|
|
|
+ ,case when tct.buy_grade_code = 'STD'
|
|
|
+ then '标准版' else '专业版'
|
|
|
+ end as buy_grade_code
|
|
|
+ ,cp.cp_name
|
|
|
+ , sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "tradeTypeName"
|
|
|
+ , sys.f_get_name_i18n(tdk2.kind_name_i18n, #{i18n}) as "tradeStatusName"
|
|
|
+ FROM dkic_a.t_cp_trade tct
|
|
|
+ left JOIN dkic_a.t_a_company cp
|
|
|
+ on tct.cp_id = cp.cp_id
|
|
|
+ left JOIN sys.t_data_kind as tdk1 on tct.trade_type = tdk1.kind_code
|
|
|
+ left JOIN sys.t_data_kind as tdk2 on tct.trade_status = tdk2.kind_code
|
|
|
+ <include refid="Condition_list"/>
|
|
|
+ <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
+ limit #{end} offset #{start}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询表dkic_a.t_cp_trade,(条件查询)个数 -->
|
|
|
+ <select id="countByCond" resultType="Long">
|
|
|
+ SELECT
|
|
|
+ count(1)
|
|
|
+ FROM dkic_a.t_cp_trade tct
|
|
|
+ <include refid="Condition_list"/>
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <!-- 根据主键锁定表dkic_a.t_cp_trade的一行数据 -->
|
|
|
+ <select id="selectByIdForUpdate" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM dkic_a.t_cp_trade
|
|
|
+ WHERE trade_id = #{tradeId}
|
|
|
+ for update
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据主键锁定表dkic_a.t_cp_trade的多行数据 -->
|
|
|
+ <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM dkic_a.t_cp_trade
|
|
|
+ <include refid="idsForeach"/>
|
|
|
+ for update
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <insert id="insertBatch">
|
|
|
+ insert into dkic_a.t_cp_trade
|
|
|
+ (
|
|
|
+ <trim suffixOverrides=",">
|
|
|
+ trade_no,
|
|
|
+ cp_id,
|
|
|
+ wx_user_id,
|
|
|
+ trade_amount,
|
|
|
+ trade_time,
|
|
|
+ trade_type,
|
|
|
+ buy_long,
|
|
|
+ buy_begin_date,
|
|
|
+ buy_end_date,
|
|
|
+ buy_fun_id,
|
|
|
+ buy_grade_code,
|
|
|
+ wx_trade_no,
|
|
|
+ extend_days,
|
|
|
+ dk_user_id,
|
|
|
+ trade_status,
|
|
|
+ </trim>
|
|
|
+ )
|
|
|
+ values
|
|
|
+ <foreach collection="list" index="index" item="item" separator=",">
|
|
|
+ (
|
|
|
+ <trim suffixOverrides=",">
|
|
|
+ #{item.tradeNo},
|
|
|
+ #{item.cpId},
|
|
|
+ #{item.wxUserId}::uuid,
|
|
|
+ #{item.tradeAmount},
|
|
|
+ #{item.tradeTime},
|
|
|
+ #{item.tradeType},
|
|
|
+ #{item.buyLong},
|
|
|
+ #{item.buyBeginDate},
|
|
|
+ #{item.buyEndDate},
|
|
|
+ #{item.buyFunId},
|
|
|
+ #{item.buyGradeCode},
|
|
|
+ #{item.wxTradeNo},
|
|
|
+ #{item.extendDays},
|
|
|
+ #{item.dkUserId}::uuid,
|
|
|
+ #{item.tradeStatus},
|
|
|
+ </trim>
|
|
|
+ )
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+</mapper>
|