300 lines
12 KiB
XML
300 lines
12 KiB
XML
|
|
<?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.hzs.member.account.mapper.CuMemberTradeMapper">
|
||
|
|
|
||
|
|
<!-- 通用查询映射结果 -->
|
||
|
|
<resultMap id="CuMemberTrade" type="com.hzs.common.domain.member.account.CuMemberTrade">
|
||
|
|
<id column="PK_ID" property="pkId"/>
|
||
|
|
<result column="DEL_FLAG" property="delFlag"/>
|
||
|
|
<result column="PK_COUNTRY" property="pkCountry"/>
|
||
|
|
<result column="PK_CREATOR" property="pkCreator"/>
|
||
|
|
<result column="CREATION_TIME" property="creationTime"/>
|
||
|
|
<result column="PK_MODIFIED" property="pkModified"/>
|
||
|
|
<result column="MODIFIED_TIME" property="modifiedTime"/>
|
||
|
|
<result column="PK_MEMBER" property="pkMember"/>
|
||
|
|
<result column="TRADE_CODE" property="tradeCode"/>
|
||
|
|
<result column="PK_ACCOUNT" property="pkAccount"/>
|
||
|
|
<result column="TRADE_TYPE" property="tradeType"/>
|
||
|
|
<result column="TRADE_CLASSIFY" property="tradeClassify"/>
|
||
|
|
<result column="PK_RATE" property="pkRate"/>
|
||
|
|
<result column="TRADE_AMOUNT" property="tradeAmount"/>
|
||
|
|
<result column="TRADE_BALANCE" property="tradeBalance"/>
|
||
|
|
<result column="TRADE_BEFORE_BALANCE" property="tradeBeforeBalance"/>
|
||
|
|
<result column="SOURCE_CODE" property="sourceCode"/>
|
||
|
|
<result column="TRADE_STATUE" property="tradeStatue"/>
|
||
|
|
<result column="REMARKS" property="remarks"/>
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<sql id="select_base">
|
||
|
|
select t.*,
|
||
|
|
m.member_code as memberCode,
|
||
|
|
m.member_name as memberName,
|
||
|
|
v.VERTEX_NAME as vertexName,
|
||
|
|
c.TEAM_NAME as teamName
|
||
|
|
from cu_member_trade t
|
||
|
|
left join cu_member m
|
||
|
|
on t.pk_member = m.pk_id
|
||
|
|
left join cu_member_team c
|
||
|
|
ON c.pk_id = m.pk_team_code
|
||
|
|
and c.del_flag = 0
|
||
|
|
left join bd_vertex v
|
||
|
|
on v.pk_id = m.PK_VERTEX
|
||
|
|
and v.del_flag = 0
|
||
|
|
</sql>
|
||
|
|
|
||
|
|
<sql id="ids_where">
|
||
|
|
<where>
|
||
|
|
t.del_flag='0'
|
||
|
|
and t.pk_id in
|
||
|
|
<foreach collection="pkIds" item="item" open="(" close=")" separator=",">
|
||
|
|
#{item}
|
||
|
|
</foreach>
|
||
|
|
</where>
|
||
|
|
</sql>
|
||
|
|
|
||
|
|
<sql id="list_where">
|
||
|
|
<where>
|
||
|
|
t.del_flag = 0
|
||
|
|
<if test="memberName != null and memberName != ''">
|
||
|
|
and m.member_name like #{memberName} || '%'
|
||
|
|
</if>
|
||
|
|
<if test="memberCode != null and memberCode != ''">
|
||
|
|
and m.member_code like #{memberCode} || '%'
|
||
|
|
</if>
|
||
|
|
<if test="tradeAmount != null">
|
||
|
|
and t.TRADE_AMOUNT = #{tradeAmount}
|
||
|
|
</if>
|
||
|
|
<if test="remarks != null and remarks != ''">
|
||
|
|
and m.REMARKS like #{remarks} || '%'
|
||
|
|
</if>
|
||
|
|
<if test="pkAccount != null">
|
||
|
|
and t.PK_ACCOUNT = #{pkAccount}
|
||
|
|
</if>
|
||
|
|
<if test="tradeType != null">
|
||
|
|
and t.TRADE_TYPE = #{tradeType}
|
||
|
|
</if>
|
||
|
|
<if test="sourceCode != null and sourceCode != ''">
|
||
|
|
and t.SOURCE_CODE = #{sourceCode}
|
||
|
|
</if>
|
||
|
|
<if test="pkCountry != null">
|
||
|
|
and t.pk_country = #{pkCountry}
|
||
|
|
</if>
|
||
|
|
<if test="tradeClassify != null">
|
||
|
|
and t.TRADE_CLASSIFY = #{tradeClassify}
|
||
|
|
</if>
|
||
|
|
<if test="startDate != null and startDate != ''">
|
||
|
|
and t.CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
|
||
|
|
</if>
|
||
|
|
<if test="endDate != null and endDate != ''">
|
||
|
|
and t.CREATION_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
|
||
|
|
</if>
|
||
|
|
<if test="vertexId != null">
|
||
|
|
and m.PK_VERTEX=#{vertexId}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="teamId != null">
|
||
|
|
and m.pk_team_code=#{teamId}
|
||
|
|
</if>
|
||
|
|
</where>
|
||
|
|
</sql>
|
||
|
|
|
||
|
|
<select id="selectMemberTradeList" resultType="com.hzs.common.domain.member.account.CuMemberTradeExt">
|
||
|
|
<include refid="select_base"/>
|
||
|
|
<choose>
|
||
|
|
<when test="pkIds != null and pkIds.size >0">
|
||
|
|
<include refid="ids_where"></include>
|
||
|
|
</when>
|
||
|
|
<otherwise>
|
||
|
|
<include refid="list_where"></include>
|
||
|
|
</otherwise>
|
||
|
|
</choose>
|
||
|
|
order by t.creation_time Desc,t.PK_ID Desc
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="selectMemberTradeListCount" resultType="com.hzs.common.domain.member.account.CuMemberTradeExt">
|
||
|
|
select NVL(sum(t.trade_amount), 0) as tradeAmount,
|
||
|
|
NVL(sum(t.trade_balance), 0) as tradeBalance
|
||
|
|
from cu_member_trade t
|
||
|
|
left join cu_member m
|
||
|
|
on t.pk_member = m.pk_id
|
||
|
|
<include refid="list_where"></include>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="queryCuMemberTrade" resultMap="CuMemberTrade">
|
||
|
|
select min(pk_id) pk_id, pk_account,sum(trade_amount) trade_amount, max(pk_country) pk_country
|
||
|
|
from cu_member_trade
|
||
|
|
where pk_member = #{pkMember} and trade_classify !=4
|
||
|
|
and source_code = #{sourceCode}
|
||
|
|
and del_flag = 0
|
||
|
|
<!-- 2024.05.20 临时解决,订单业务手续费不退款 -->
|
||
|
|
and trade_type not in (830, 831, 832, 833, 834)
|
||
|
|
group by pk_account
|
||
|
|
order by pk_id
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<insert id="batchSaveTradeByMemberCode" parameterType="com.hzs.common.domain.member.account.CuMemberTrade">
|
||
|
|
insert into CU_MEMBER_TRADE (PK_ID, PK_MEMBER, TRADE_CODE, PK_ACCOUNT, TRADE_TYPE,
|
||
|
|
TRADE_CLASSIFY, PK_RATE, TRADE_AMOUNT, TRADE_BALANCE,TRADE_BEFORE_BALANCE,
|
||
|
|
SOURCE_CODE, TRADE_STATUE, REMARKS, PK_COUNTRY, CREATION_TIME, PK_CREATOR)
|
||
|
|
SELECT cu_member_trade_seq.nextval,t.* FROM
|
||
|
|
(
|
||
|
|
<foreach collection="cuMemberTrades" item="item" separator="UNION ALL">
|
||
|
|
SELECT #{item.pkMember},#{item.tradeCode},#{item.pkAccount},#{item.tradeType}
|
||
|
|
,#{item.tradeClassify},#{item.pkRate},#{item.tradeAmount},#{item.tradeBalance},#{item.tradeBeforeBalance}
|
||
|
|
,#{item.sourceCode, jdbcType=VARCHAR},#{item.tradeStatue},
|
||
|
|
<choose>
|
||
|
|
<when test="item.remarks != null">
|
||
|
|
#{item.remarks},
|
||
|
|
</when>
|
||
|
|
<otherwise>
|
||
|
|
null,
|
||
|
|
</otherwise>
|
||
|
|
</choose>
|
||
|
|
#{item.pkCountry},sysdate,#{item.pkCreator}
|
||
|
|
FROM dual
|
||
|
|
</foreach>
|
||
|
|
) t
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<select id="selectWattleDetail" resultType="com.hzs.common.domain.member.account.CuMemberTradeExt">
|
||
|
|
select t.trade_code tradeCode,
|
||
|
|
t.source_code sourceCode,
|
||
|
|
t.pk_account pkAccount,
|
||
|
|
t.trade_type tradeType,
|
||
|
|
t.trade_amount tradeAmount,
|
||
|
|
t.trade_balance tradeBalance,
|
||
|
|
t.creation_time creationTime,
|
||
|
|
t.remarks remarks,
|
||
|
|
r.member_remarks memberRemarks
|
||
|
|
from cu_member_trade t
|
||
|
|
left join cu_member_recharge r
|
||
|
|
on t.trade_code = r.recharge_code
|
||
|
|
and r.del_flag = 0
|
||
|
|
and r.approve_state = 2
|
||
|
|
where t.del_flag=0
|
||
|
|
and t.pk_country = #{pkCountry}
|
||
|
|
and t.pk_member = #{pkMember}
|
||
|
|
<if test="pkAccount != null">
|
||
|
|
and t.PK_ACCOUNT = #{pkAccount}
|
||
|
|
</if>
|
||
|
|
<if test="tradeType != null">
|
||
|
|
and t.TRADE_TYPE = #{tradeType}
|
||
|
|
</if>
|
||
|
|
<if test="startDate != null and startDate != ''">
|
||
|
|
and t.CREATION_TIME >= to_date(#{startDate}, 'yyyy-mm-dd')
|
||
|
|
</if>
|
||
|
|
<if test="endDate != null and endDate != ''">
|
||
|
|
and t.CREATION_TIME <= to_date(#{endDate} || ' 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
|
||
|
|
</if>
|
||
|
|
order by t.creation_time desc,t.PK_ID desc
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="selectTradeType" resultType="Integer">
|
||
|
|
select distinct t.trade_type
|
||
|
|
from cu_member_trade t
|
||
|
|
where t.del_flag = 0
|
||
|
|
and t.pk_country =#{pkCountry}
|
||
|
|
and t.pk_member= #{pkMember}
|
||
|
|
order by t.trade_type
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="selectMemberTradeByTradeCodeAndTradeType" resultMap="CuMemberTrade">
|
||
|
|
select t.pk_member,
|
||
|
|
t.trade_code,
|
||
|
|
t.pk_account,
|
||
|
|
t.trade_type,
|
||
|
|
t.trade_classify,
|
||
|
|
t.pk_rate,
|
||
|
|
t.trade_amount,
|
||
|
|
t.trade_balance,
|
||
|
|
t.trade_before_balance,
|
||
|
|
t.source_code,
|
||
|
|
t.trade_statue,
|
||
|
|
t.remarks,
|
||
|
|
t.pk_country
|
||
|
|
from cu_member_trade t
|
||
|
|
where t.del_flag = 0
|
||
|
|
and t.source_code = #{tradeCode}
|
||
|
|
and t.trade_type = #{tradeType}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<update id="updateSourceCodeByTradeCode">
|
||
|
|
update cu_member_trade t set t.source_code = #{sourceCode},
|
||
|
|
t.pk_modified = #{pkModified},
|
||
|
|
t.modified_time = sysdate
|
||
|
|
where t.trade_code in
|
||
|
|
<foreach collection="tradeCodes" item="item" open="(" close=")" separator=",">
|
||
|
|
#{item}
|
||
|
|
</foreach>
|
||
|
|
</update>
|
||
|
|
<update id="batchInsertCuMemberTrade">
|
||
|
|
merge into cu_member_trade a
|
||
|
|
using (
|
||
|
|
select m.pk_id, m.pk_member, m.trade_code, m.pk_account, m.trade_type,m.trade_classify, m.pk_rate, m.trade_amount,
|
||
|
|
(case when ba.field_value=4 then ca.account4 + m.trade_amount when ba.field_value=5 then ca.account5 + m.trade_amount
|
||
|
|
when ba.field_value=8 then ca.account8 + m.trade_amount when ba.field_value=9 then ca.account9 + m.trade_amount
|
||
|
|
else ca.account10 + m.trade_amount end) trade_balance,
|
||
|
|
(case when ba.field_value=4 then ca.account4 when ba.field_value=5 then ca.account5 when ba.field_value=8 then ca.account8
|
||
|
|
when ba.field_value=9 then ca.account9 else ca.account10 end) trade_before_balance,
|
||
|
|
m.source_code, m.trade_statue, m.remarks, m.pk_country, m.creation_time, m.pk_creator from(
|
||
|
|
<foreach collection="cuMemberTradeList" item="item" open=" " separator=" union all " close=" ">
|
||
|
|
select #{item.pkId} pk_id,#{item.tradeCode} trade_code, #{item.tradeClassify} trade_classify,
|
||
|
|
#{item.pkMember} pk_member,#{item.pkAccount} pk_account,#{item.pkRate} pk_rate,#{item.tradeAmount} trade_amount,
|
||
|
|
#{item.sourceCode} source_code,#{item.tradeStatue} trade_statue,#{item.remarks} remarks,
|
||
|
|
#{item.tradeType} trade_type,#{item.pkCountry} pk_country,#{item.pkCreator} pk_creator,
|
||
|
|
#{item.creationTime} creation_time from dual
|
||
|
|
</foreach>) m
|
||
|
|
inner join cu_member_account ca
|
||
|
|
on m.pk_member = ca.pk_member
|
||
|
|
inner join bd_account ba
|
||
|
|
on ba.pk_id = m.pk_account
|
||
|
|
) b
|
||
|
|
on (a.pk_id = b.pk_id)
|
||
|
|
when not matched then
|
||
|
|
insert (pk_id, pk_member, trade_code, pk_account, trade_type,
|
||
|
|
trade_classify, pk_rate, trade_amount, trade_balance,trade_before_balance,
|
||
|
|
source_code, trade_statue, remarks, pk_country, creation_time, pk_creator)
|
||
|
|
values(b.pk_id,b.pk_member,b.trade_code,b.pk_account,b.trade_type,
|
||
|
|
b.trade_classify,b.pk_rate,b.trade_amount,b.trade_balance,b.trade_before_balance,
|
||
|
|
b.source_code,b.trade_statue,b.remarks,b.pk_country,b.creation_time,b.pk_creator)
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<!-- 查询会员订单产生的最新交易明细 -->
|
||
|
|
<select id="querySourceCodeLastTrade" resultMap="CuMemberTrade">
|
||
|
|
select *
|
||
|
|
from cu_member_trade cmt
|
||
|
|
where cmt.pk_id in
|
||
|
|
(select max(pk_id)
|
||
|
|
from cu_member_trade cmt
|
||
|
|
where cmt.del_flag = 0
|
||
|
|
and cmt.pk_member = #{pkMember}
|
||
|
|
and cmt.source_code = #{sourceCode}
|
||
|
|
<if test="tradeClassify != null">
|
||
|
|
and cmt.trade_classify = #{tradeClassify}
|
||
|
|
</if>
|
||
|
|
group by cmt.trade_classify, cmt.pk_account)
|
||
|
|
</select>
|
||
|
|
<select id="batchQueryCuMemberTradeSeq" resultType="java.lang.Long">
|
||
|
|
select cu_member_trade_seq.nextval from dual connect by rownum <= #{rowNum}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="selectMemberTradeBySourceCode" resultMap="CuMemberTrade" >
|
||
|
|
select *
|
||
|
|
from cu_member_trade t
|
||
|
|
left join bd_account a
|
||
|
|
on t.pk_account = a.pk_id
|
||
|
|
and a.del_flag = 0
|
||
|
|
where t.del_flag = 0
|
||
|
|
and a.field_value = 4
|
||
|
|
and t.source_code = #{sourceCode}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
</mapper>
|