|
|
<?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.yoho.order.dal.TradeBillsMapper">
|
|
|
<resultMap id="BaseResultMap" type="com.yoho.order.model.TradeBills">
|
|
|
<id column="id" jdbcType="INTEGER" property="id" />
|
|
|
<result column="uid" jdbcType="INTEGER" property="uid" />
|
|
|
<result column="order_code" jdbcType="BIGINT" property="orderCode" />
|
|
|
<result column="paid_order_code" jdbcType="BIGINT" property="paidOrderCode" />
|
|
|
<result column="user_type" jdbcType="TINYINT" property="userType" />
|
|
|
<result column="pay_type" jdbcType="TINYINT" property="payType" />
|
|
|
<result column="trade_type" jdbcType="INTEGER" property="tradeType" />
|
|
|
<result column="income_outcome" jdbcType="TINYINT" property="incomeOutcome" />
|
|
|
<result column="amount" jdbcType="DECIMAL" property="amount" />
|
|
|
<result column="system_amount" jdbcType="DECIMAL" property="systemAmount" />
|
|
|
<result column="trade_status" jdbcType="TINYINT" property="tradeStatus" />
|
|
|
<result column="create_time" jdbcType="INTEGER" property="createTime" />
|
|
|
<result column="deal_uid" jdbcType="INTEGER" property="dealUid" />
|
|
|
<result column="deal_status" jdbcType="TINYINT" property="dealStatus" />
|
|
|
<result column="deal_time" jdbcType="INTEGER" property="dealTime" />
|
|
|
<result column="deal_relate_id" jdbcType="INTEGER" property="dealRelateId" />
|
|
|
<result column="deal_user_name" jdbcType="VARCHAR" property="dealUserName" />
|
|
|
<result column="pay_error_code" jdbcType="VARCHAR" property="payErrorCode" />
|
|
|
</resultMap>
|
|
|
<sql id="Base_Column_List">
|
|
|
<resultMap id="BaseResultMap" type="com.yoho.order.model.TradeBills">
|
|
|
<id column="id" jdbcType="INTEGER" property="id"/>
|
|
|
<result column="uid" jdbcType="INTEGER" property="uid"/>
|
|
|
<result column="order_code" jdbcType="BIGINT" property="orderCode"/>
|
|
|
<result column="paid_order_code" jdbcType="BIGINT" property="paidOrderCode"/>
|
|
|
<result column="user_type" jdbcType="TINYINT" property="userType"/>
|
|
|
<result column="pay_type" jdbcType="TINYINT" property="payType"/>
|
|
|
<result column="trade_type" jdbcType="INTEGER" property="tradeType"/>
|
|
|
<result column="income_outcome" jdbcType="TINYINT" property="incomeOutcome"/>
|
|
|
<result column="amount" jdbcType="DECIMAL" property="amount"/>
|
|
|
<result column="system_amount" jdbcType="DECIMAL" property="systemAmount"/>
|
|
|
<result column="trade_status" jdbcType="TINYINT" property="tradeStatus"/>
|
|
|
<result column="create_time" jdbcType="INTEGER" property="createTime"/>
|
|
|
<result column="deal_uid" jdbcType="INTEGER" property="dealUid"/>
|
|
|
<result column="deal_status" jdbcType="TINYINT" property="dealStatus"/>
|
|
|
<result column="deal_time" jdbcType="INTEGER" property="dealTime"/>
|
|
|
<result column="deal_relate_id" jdbcType="INTEGER" property="dealRelateId"/>
|
|
|
<result column="deal_user_name" jdbcType="VARCHAR" property="dealUserName"/>
|
|
|
<result column="pay_error_code" jdbcType="VARCHAR" property="payErrorCode"/>
|
|
|
</resultMap>
|
|
|
<sql id="Base_Column_List">
|
|
|
id,uid, order_code, paid_order_code, user_type,pay_type,trade_type,
|
|
|
income_outcome,amount,system_amount,trade_status,create_time,
|
|
|
deal_uid,deal_status,deal_time,deal_relate_id,deal_user_name,pay_error_code
|
|
|
</sql>
|
|
|
|
|
|
<sql id="Query_Condition_Sql" >
|
|
|
income_outcome=1
|
|
|
and deal_status != 1
|
|
|
<if test="billsTradeReq.orderCode != null">
|
|
|
and (
|
|
|
order_code = #{billsTradeReq.orderCode}
|
|
|
or paid_order_code = #{billsTradeReq.orderCode}
|
|
|
<if test="billsTradeReq.orderCode2 != null">
|
|
|
or order_code = #{billsTradeReq.orderCode2}
|
|
|
or paid_order_code = #{billsTradeReq.orderCode2}
|
|
|
</if>
|
|
|
)
|
|
|
</if>
|
|
|
<if test="billsTradeReq.uid != null">
|
|
|
and uid = #{billsTradeReq.uid}
|
|
|
</if>
|
|
|
<if test="billsTradeReq.startTime != null">
|
|
|
and create_time > #{billsTradeReq.startTime}
|
|
|
</if>
|
|
|
<if test="billsTradeReq.endTime != null">
|
|
|
and create_time <= #{billsTradeReq.endTime}
|
|
|
</if>
|
|
|
<if test="billsTradeReq.userType != null">
|
|
|
and user_type = #{billsTradeReq.userType}
|
|
|
</if>
|
|
|
<if test="billsTradeReq.tradeType != null">
|
|
|
and trade_type = #{billsTradeReq.tradeType}
|
|
|
</if>
|
|
|
<if test="billsTradeReq.status != null ">
|
|
|
<choose>
|
|
|
<when test="billsTradeReq.status == 100 ">
|
|
|
and trade_status = 100
|
|
|
</when>
|
|
|
<otherwise>
|
|
|
and trade_status != 100
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
</if>
|
|
|
<if test="billsTradeReq.payErrorCode != null">
|
|
|
and pay_error_code = #{billsTradeReq.payErrorCode,jdbcType=VARCHAR}
|
|
|
</if>
|
|
|
</sql>
|
|
|
<sql id="Query_Condition_Sql">
|
|
|
income_outcome=1
|
|
|
and deal_status != 1
|
|
|
<if test="billsTradeReq.orderCode != null">
|
|
|
and (
|
|
|
order_code = #{billsTradeReq.orderCode}
|
|
|
or paid_order_code = #{billsTradeReq.orderCode}
|
|
|
<if test="billsTradeReq.orderCode2 != null">
|
|
|
or order_code = #{billsTradeReq.orderCode2}
|
|
|
or paid_order_code = #{billsTradeReq.orderCode2}
|
|
|
</if>
|
|
|
)
|
|
|
</if>
|
|
|
<if test="billsTradeReq.uid != null">
|
|
|
and uid = #{billsTradeReq.uid}
|
|
|
</if>
|
|
|
<if test="billsTradeReq.startTime != null">
|
|
|
and create_time > #{billsTradeReq.startTime}
|
|
|
</if>
|
|
|
<if test="billsTradeReq.endTime != null">
|
|
|
and create_time <= #{billsTradeReq.endTime}
|
|
|
</if>
|
|
|
<if test="billsTradeReq.userType != null">
|
|
|
and user_type = #{billsTradeReq.userType}
|
|
|
</if>
|
|
|
<if test="billsTradeReq.tradeType != null">
|
|
|
and trade_type = #{billsTradeReq.tradeType}
|
|
|
</if>
|
|
|
<if test="billsTradeReq.status != null ">
|
|
|
<choose>
|
|
|
<when test="billsTradeReq.status == 100 ">
|
|
|
and trade_status = 100
|
|
|
</when>
|
|
|
<otherwise>
|
|
|
and trade_status != 100
|
|
|
</otherwise>
|
|
|
</choose>
|
|
|
</if>
|
|
|
<if test="billsTradeReq.payErrorCode != null">
|
|
|
and pay_error_code = #{billsTradeReq.payErrorCode,jdbcType=VARCHAR}
|
|
|
</if>
|
|
|
</sql>
|
|
|
|
|
|
<select id="selectCountByCondition" resultType="java.lang.Integer" parameterType="com.yoho.order.model.TradeBillsReq">
|
|
|
select count(id)
|
|
|
from trade_bills where
|
|
|
<include refid="Query_Condition_Sql" />
|
|
|
</select>
|
|
|
<select id="selectCountByCondition" resultType="java.lang.Integer"
|
|
|
parameterType="com.yoho.order.model.TradeBillsReq">
|
|
|
select count(id)
|
|
|
from trade_bills where
|
|
|
<include refid="Query_Condition_Sql"/>
|
|
|
</select>
|
|
|
|
|
|
<select id="selectByConditionWithPage" resultMap="BaseResultMap" parameterType="com.yoho.order.model.TradeBillsReq">
|
|
|
select <include refid="Base_Column_List" />
|
|
|
from trade_bills where
|
|
|
<include refid="Query_Condition_Sql" />
|
|
|
order by create_time desc
|
|
|
limit #{billsTradeReq.start},#{billsTradeReq.size}
|
|
|
</select>
|
|
|
<select id="selectByConditionWithPage" resultMap="BaseResultMap" parameterType="com.yoho.order.model.TradeBillsReq">
|
|
|
select
|
|
|
<include refid="Base_Column_List"/>
|
|
|
from trade_bills where
|
|
|
<include refid="Query_Condition_Sql"/>
|
|
|
order by create_time desc
|
|
|
limit #{billsTradeReq.start},#{billsTradeReq.size}
|
|
|
</select>
|
|
|
|
|
|
<select id="selectTransferOutTradeNoByOrderCodes" resultType="com.yoho.order.model.TradeBillsTransferOutTradeNo">
|
|
|
select tb.id,
|
|
|
CASE t.interface_type
|
|
|
WHEN 2 THEN
|
|
|
concat(t.id, '_', tb.id)
|
|
|
WHEN 3 THEN
|
|
|
'钱包'
|
|
|
END
|
|
|
as outTradeNo,
|
|
|
order_code as orderCode
|
|
|
FROM
|
|
|
trade_bills tb
|
|
|
LEFT JOIN orders_pay_transfer t ON t.buyer_order_code = tb.order_code
|
|
|
where tb.order_code in
|
|
|
<foreach collection="orderCodes" item="orderCode" open="(" close=")" separator=",">
|
|
|
#{orderCode}
|
|
|
</foreach>
|
|
|
AND tb.trade_status != 100
|
|
|
and t.interface_type = 2
|
|
|
</select>
|
|
|
<select id="selectTransferOutTradeNoByOrderCodes" resultType="com.yoho.order.model.TradeBillsTransferOutTradeNo">
|
|
|
SELECT tb.id,
|
|
|
CASE t.interface_type
|
|
|
WHEN 2 THEN concat(t.id, '_', IF(tb.deal_relate_id != 0,tb.deal_relate_id,tb.id))
|
|
|
WHEN 3 THEN '钱包'
|
|
|
END AS outTradeNo,
|
|
|
tb.order_code AS orderCode
|
|
|
FROM ufo_order.trade_bills tb
|
|
|
LEFT JOIN ufo_order.orders_pay_transfer t ON t.buyer_order_code = tb.order_code
|
|
|
WHERE tb.income_outcome = 1 AND tb.deal_status != 1
|
|
|
<!-- 转账单 -->
|
|
|
AND (
|
|
|
tb.trade_type = 3 <!-- 补偿款 -->
|
|
|
OR (tb.user_type =2 AND tb.trade_type = 2) <!-- 卖家货款 -->
|
|
|
OR (tb.user_type =2 AND tb.trade_type = 4) <!-- 卖家返利 -->
|
|
|
)
|
|
|
AND tb.order_code IN
|
|
|
<foreach collection="orderCodes" item="orderCode" open="(" close=")" separator=",">
|
|
|
#{orderCode}
|
|
|
</foreach>
|
|
|
</select>
|
|
|
|
|
|
<select id="selectByFailTradeBills" resultMap="BaseResultMap">
|
|
|
select <include refid="Base_Column_List" />
|
|
|
from trade_bills where
|
|
|
<!-- 失败的 -->
|
|
|
income_outcome = 1 AND deal_status != 1
|
|
|
<!-- 没有人工干预的 -->
|
|
|
AND (deal_uid is NULL or deal_uid in (0,1))
|
|
|
<!-- 退款失败和转账失败 -->
|
|
|
AND trade_status in (200,299)
|
|
|
AND create_time > #{fromCreateTime}
|
|
|
AND id > #{fromTradeBillsId}
|
|
|
limit #{limit}
|
|
|
</select>
|
|
|
<select id="selectByFailTradeBills" resultMap="BaseResultMap">
|
|
|
select
|
|
|
<include refid="Base_Column_List"/>
|
|
|
from trade_bills where
|
|
|
<!-- 失败的 -->
|
|
|
income_outcome = 1 AND deal_status != 1
|
|
|
<!-- 没有人工干预的 -->
|
|
|
AND (deal_uid is NULL or deal_uid in (0,1))
|
|
|
<!-- 退款失败和转账失败 -->
|
|
|
AND trade_status in (200,299)
|
|
|
AND create_time > #{fromCreateTime}
|
|
|
AND id > #{fromTradeBillsId}
|
|
|
limit #{limit}
|
|
|
</select>
|
|
|
|
|
|
</mapper> |
|
|
\ No newline at end of file |
...
|
...
|
|