|
|
@@ -0,0 +1,201 @@
|
|
|
+<?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.TradeMapper">
|
|
|
+
|
|
|
+ <!-- 通用查询列 -->
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ t
|
|
|
+ .
|
|
|
+ trade_id
|
|
|
+ ,t.trade_no
|
|
|
+ ,t.cp_id
|
|
|
+ ,t.wx_user_id
|
|
|
+ ,t.trade_amount
|
|
|
+ ,t.trade_time
|
|
|
+ ,t.trade_type
|
|
|
+ ,t.buy_long
|
|
|
+ ,t.buy_begin_date
|
|
|
+ ,t.buy_end_date
|
|
|
+ ,t.buy_fun_id
|
|
|
+ ,t.buy_grade_code
|
|
|
+ ,t.wx_trade_no
|
|
|
+ ,t.extend_days
|
|
|
+ ,t.dk_user_id
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <resultMap type="com.dk.oauth.entity.Trade" id="ResultMap">
|
|
|
+ <id column="trade_id" property="tradeId"/>
|
|
|
+ <result column="cp_id" property="cpId"/>
|
|
|
+ <result column="trade_no" property="tradeCode"/>
|
|
|
+ <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="wxGradeCoNo"/>
|
|
|
+ <result column="extend_days" property="extendDays"/>
|
|
|
+ <result column="dk_user_id" property="dkUserId" typeHandler="UuidTypeHandler"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 通用查询映射结果 -->
|
|
|
+ <resultMap id="BaseResultMap" type="com.dk.oauth.entity.TradeResponse">
|
|
|
+ <id column="trade_id" property="tradeId"/>
|
|
|
+ <result column="cp_id" property="cpId"/>
|
|
|
+ <result column="trade_no" property="tradeCode"/>
|
|
|
+ <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="wxGradeCoNo"/>
|
|
|
+ <result column="extend_days" property="extendDays"/>
|
|
|
+ <result column="dk_user_id" property="dkUserId" typeHandler="UuidTypeHandler"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 通用条件列 -->
|
|
|
+ <sql id="Condition">
|
|
|
+ <where>
|
|
|
+ <if test="tradeId != null and tradeId != ''">
|
|
|
+ AND t.trade_id = #{tradeId}
|
|
|
+ </if>
|
|
|
+ <if test="tradeCode != null and tradeCode != ''">
|
|
|
+ AND t.trade_no = #{tradeCode}
|
|
|
+ </if>
|
|
|
+ <if test="cpId != null and cpId != ''">
|
|
|
+ AND t.cp_id = #{cpId}
|
|
|
+ </if>
|
|
|
+ <if test="wxUserId != null and wxUserId != ''">
|
|
|
+ AND t.wx_user_id = #{wxUserId}::uuid
|
|
|
+ </if>
|
|
|
+ <if test="tradeType != null and tradeType != ''">
|
|
|
+ AND t.trade_type = #{tradeType}
|
|
|
+ </if>
|
|
|
+ <if test="dkUserId != null and dkUserId != ''">
|
|
|
+ AND t.dk_user_id = #{dkUserId}::uuid
|
|
|
+ </if>
|
|
|
+
|
|
|
+ </where>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 根据主键查询表t_mst_staff的一行数据 -->
|
|
|
+ <select id="selectById" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ ,g.grade_name gradeName
|
|
|
+ FROM dkic_a.t_cp_trade t
|
|
|
+ left join sys.t_grade g on t.buy_grade_code = g.grade_code
|
|
|
+ WHERE t.trade_id = #{tradeId}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <insert id="insert">
|
|
|
+ insert into dkic_a.t_cp_trade
|
|
|
+ (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)
|
|
|
+ values (
|
|
|
+ #{tradeId},
|
|
|
+ #{tradeCode},
|
|
|
+ #{cpId},
|
|
|
+ #{wxUserId}::uuid,
|
|
|
+ #{tradeAmount},
|
|
|
+ #{tradeTime},
|
|
|
+ #{tradeType},
|
|
|
+ #{buyLong},
|
|
|
+ #{buyBeginDate},
|
|
|
+ #{buyEndDate},
|
|
|
+ #{buyFunId}::uuid[],
|
|
|
+ #{buyGradeCode},
|
|
|
+ #{wxGradeCoNo},
|
|
|
+ #{extendDays},
|
|
|
+ #{dkUserId}::uuid)
|
|
|
+
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <!-- 查询表t_cp_trade,(条件查询+分页)列表 -->
|
|
|
+ <select id="selectByCond" resultMap="BaseResultMap">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ ,g.grade_name gradeName
|
|
|
+ FROM dkic_a.t_cp_trade t
|
|
|
+ left join sys.t_grade g on t.buy_grade_code = g.grade_code
|
|
|
+ <include refid="Condition"/>
|
|
|
+ <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
+ limit #{end} offset #{start}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询表t_cp_trade,(条件查询)个数 -->
|
|
|
+ <select id="countByCond" resultType="Long">
|
|
|
+ SELECT
|
|
|
+ count(1)
|
|
|
+ FROM dkic_a.t_cp_trade t
|
|
|
+ <include refid="Condition"/>
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <insert id="insertBatch">
|
|
|
+ insert into dkic_a.t_cp_trade
|
|
|
+ (
|
|
|
+ <trim suffixOverrides=",">
|
|
|
+ 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
|
|
|
+ </trim>
|
|
|
+ )
|
|
|
+ values
|
|
|
+ <foreach collection="list" index="index" item="item" separator=",">
|
|
|
+ (
|
|
|
+ <trim suffixOverrides=",">
|
|
|
+ #{item.tradeId},
|
|
|
+ #{item.tradeCode},
|
|
|
+ #{item.cpId},
|
|
|
+ #{item.wxUserId}::uuid,
|
|
|
+ #{item.tradeAmount},
|
|
|
+ #{item.tradeTime},
|
|
|
+ #{item.tradeType},
|
|
|
+ #{item.buyLong},
|
|
|
+ #{item.buyBeginDate},
|
|
|
+ #{item.buyEndDate},
|
|
|
+ #{item.buyFunId}::uuid[],
|
|
|
+ #{item.buyGradeCode},
|
|
|
+ #{item.wxGradeCoNo},
|
|
|
+ #{item.extendDays},
|
|
|
+ #{item.dkUserId}::uuid,
|
|
|
+ </trim>
|
|
|
+ )
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+</mapper>
|
|
|
+
|