<?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.ruoyi.account.mapper.BalanceChangeRecordMapper">
|
|
<select id="pageList" resultType="com.ruoyi.account.api.model.BalanceChangeRecord">
|
select t1.*,t2.name as userName,t2.phone as userPhone
|
from t_balance_change_record t1
|
left join t_app_user t2 on t1.app_user_id = t2.id
|
<where>
|
<if test="agentQuery.userName != null and agentQuery.userName != ''">
|
and t2.name like concat('%',#{agentQuery.userName},'%')
|
</if>
|
<if test="agentQuery.userPhone != null and agentQuery.userPhone != ''">
|
and t2.phone like concat('%',#{agentQuery.userPhone},'%')
|
</if>
|
<if test="agentQuery.changeType != null">
|
and t1.change_type = #{agentQuery.changeType}
|
</if>
|
<if test="agentQuery.localDate1 != null">
|
and DATE(t1.create_time) between #{agentQuery.localDate1} and #{agentQuery.localDate2}
|
</if>
|
</where>
|
order by t1.create_time desc
|
</select>
|
|
<sql id="balanceChangeRecordList">
|
SELECT
|
tau.`name` userName,
|
tau.phone userPhone,
|
tbcr.change_type,
|
tbcr.create_time,
|
tbcr.change_amount,
|
tbcr.before_amount,
|
tbcr.after_amount,
|
tbcr.change_direction
|
FROM
|
(select * from t_balance_change_record union all select * from t_balance_change_record_copy) tbcr
|
LEFT JOIN t_app_user tau ON tbcr.app_user_id = tau.id
|
<where>
|
<if test="changeRecord.changeType == null">
|
and tbcr.change_type = #{changeRecord.changeType}
|
</if>
|
<if test="changeRecord.userName != null and changeRecord.userName != ''">
|
and tau.name like concat('%',#{changeRecord.userName},'%')
|
</if>
|
<if test="changeRecord.userPhone != null and changeRecord.userPhone != ''">
|
and tau.phone like concat('%',#{changeRecord.userPhone},'%')
|
</if>
|
<if test="changeRecord.startTime != null and changeRecord.endTime != null">
|
and (tbcr.create_time between #{changeRecord.startTime} and #{changeRecord.endTime})
|
</if>
|
<if test="changeRecord.changeType != null">
|
and tbcr.change_type = #{changeRecord.changeType}
|
</if>
|
</where>
|
order by tbcr.create_time desc
|
</sql>
|
|
<select id="selectBalanceChangeRecordList" resultType="com.ruoyi.account.api.model.BalanceChangeRecord">
|
<include refid="balanceChangeRecordList"/>
|
</select>
|
|
<select id="selectBalanceChangeRecordList1" resultType="com.ruoyi.account.api.model.BalanceChangeRecord">
|
SELECT
|
tau.`name` userName,
|
tau.phone userPhone,
|
tbcr.change_type,
|
tbcr.create_time,
|
tbcr.change_amount,
|
tbcr.before_amount,
|
tbcr.after_amount,
|
tbcr.change_direction
|
FROM
|
t_balance_change_record tbcr
|
LEFT JOIN t_app_user tau ON tbcr.app_user_id = tau.id and tau.del_flag = 0
|
<where>
|
<if test="changeRecord.userName != null and changeRecord.userName != ''">
|
and tau.name like concat('%',#{changeRecord.userName},'%')
|
</if>
|
<if test="changeRecord.userPhone != null and changeRecord.userPhone != ''">
|
and tau.phone like concat('%',#{changeRecord.userPhone},'%')
|
</if>
|
<if test="changeRecord.startTime != null and changeRecord.endTime != null">
|
and (tbcr.create_time between #{changeRecord.startTime} and #{changeRecord.endTime})
|
</if>
|
<if test="changeRecord.changeType != null">
|
and tbcr.change_type = #{changeRecord.changeType}
|
</if>
|
</where>
|
</select>
|
|
<select id="queryCommissionStatistics" resultType="com.ruoyi.account.api.model.BalanceChangeRecord">
|
<include refid="balanceChangeRecordList"/>
|
</select>
|
|
|
<select id="change" resultType="com.ruoyi.account.api.model.BalanceChangeRecordCopy">
|
select * from (
|
select * from t_balance_change_record where app_user_id = #{userId}
|
<if test="null != changeType">
|
and change_type = #{changeType}
|
</if>
|
<if test="null != startTime and null != endTime">
|
and create_time between #{startTime} and #{endTime}
|
</if>
|
union all
|
select * from t_balance_change_record_copy where app_user_id = #{userId}
|
<if test="null != changeType">
|
and change_type = #{changeType}
|
</if>
|
<if test="null != startTime and null != endTime">
|
and create_time between #{startTime} and #{endTime}
|
</if>
|
) as a order by a.create_time desc
|
</select>
|
</mapper>
|