699 lines
27 KiB
XML
699 lines
27 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.bonus.account.mapper.CuMemberAccountMapper">
|
|
|
|
<!-- 通用查询映射结果 -->
|
|
<resultMap id="AccountExResultMap" type="com.hzs.common.domain.member.ext.CuMemberAccountExt">
|
|
<id column="PK_ID" property="pkId"/>
|
|
<result column="PK_MEMBER" property="pkMember"/>
|
|
<result column="ACCOUNT1" property="account1"/>
|
|
<result column="LOCK_ACCOUNT1" property="lockAccount1"/>
|
|
<result column="LOCK_TRANSFER_ACCOUNT1" property="lockTransferAccount1"/>
|
|
<result column="ACCOUNT1_REMARKS" property="account1Remarks"/>
|
|
<result column="ACCOUNT2" property="account2"/>
|
|
<result column="LOCK_ACCOUNT2" property="lockAccount2"/>
|
|
<result column="LOCK_TRANSFER_ACCOUNT2" property="lockTransferAccount2"/>
|
|
<result column="ACCOUNT2_REMARKS" property="account2Remarks"/>
|
|
<result column="ACCOUNT3" property="account3"/>
|
|
<result column="LOCK_ACCOUNT3" property="lockAccount3"/>
|
|
<result column="LOCK_TRANSFER_ACCOUNT3" property="lockTransferAccount3"/>
|
|
<result column="ACCOUNT3_REMARKS" property="account3Remarks"/>
|
|
<result column="ACCOUNT4" property="account4"/>
|
|
<result column="LOCK_ACCOUNT4" property="lockAccount4"/>
|
|
<result column="LOCK_TRANSFER_ACCOUNT4" property="lockTransferAccount4"/>
|
|
<result column="LOCK_WITHDRAW_ACCOUNT4" property="lockWithdrawAccount4"/>
|
|
<result column="WITHDRAW_ACCOUNT4" property="withdrawAccount4"/>
|
|
<result column="CONSUME_ACCOUNT4" property="consumeAccount4"/>
|
|
<result column="ACCOUNT4_REMARKS" property="account4Remarks"/>
|
|
<result column="ACCOUNT5" property="account5"/>
|
|
<result column="LOCK_ACCOUNT5" property="lockAccount5"/>
|
|
<result column="LOCK_TRANSFER_ACCOUNT5" property="lockTransferAccount5"/>
|
|
<result column="ACCOUNT5_REMARKS" property="account5Remarks"/>
|
|
<result column="ACCOUNT6" property="account6"/>
|
|
<result column="LOCK_ACCOUNT6" property="lockAccount6"/>
|
|
<result column="LOCK_TRANSFER_ACCOUNT6" property="lockTransferAccount6"/>
|
|
<result column="ACCOUNT6_REMARKS" property="account6Remarks"/>
|
|
<result column="ACCOUNT7" property="account7"/>
|
|
<result column="LOCK_ACCOUNT7" property="lockAccount7"/>
|
|
<result column="LOCK_TRANSFER_ACCOUNT7" property="lockTransferAccount7"/>
|
|
<result column="ACCOUNT7_REMARKS" property="account7Remarks"/>
|
|
<result column="ACCOUNT8" property="account8"/>
|
|
<result column="LOCK_ACCOUNT8" property="lockAccount8"/>
|
|
<result column="LOCK_TRANSFER_ACCOUNT8" property="lockTransferAccount8"/>
|
|
<result column="ACCOUNT8_REMARKS" property="account8Remarks"/>
|
|
<result column="ACCOUNT9" property="account9"/>
|
|
<result column="LOCK_ACCOUNT9" property="lockAccount9"/>
|
|
<result column="LOCK_TRANSFER_ACCOUNT9" property="lockTransferAccount9"/>
|
|
<result column="ACCOUNT9_REMARKS" property="account9Remarks"/>
|
|
<result column="ACCOUNT10" property="account10"/>
|
|
<result column="LOCK_ACCOUNT10" property="lockAccount10"/>
|
|
<result column="LOCK_TRANSFER_ACCOUNT10" property="lockTransferAccount10"/>
|
|
<result column="ACCOUNT10_REMARKS" property="account10Remarks"/>
|
|
<result column="ACCOUNT11" property="account11"/>
|
|
<result column="ACCOUNT12" property="account12"/>
|
|
<result column="ACCOUNT13" property="account13"/>
|
|
<result column="LOCK_ACCOUNT13" property="lockAccount13"/>
|
|
<result column="ACCOUNT14" property="account14"/>
|
|
<result column="ACCOUNT15" property="account15"/>
|
|
<result column="ACCOUNT16" property="account16"/>
|
|
<result column="ACCOUNT17" property="account17"/>
|
|
<result column="ACCOUNT18" property="account18"/>
|
|
<result column="ACCOUNT19" property="account19"/>
|
|
<result column="ACCOUNT20" property="account20"/>
|
|
<result column="TRANSFER_STATUS" property="transferStatus"/>
|
|
<result column="IS_TRANSFER" property="isTransfer"/>
|
|
<result column="IS_WITHDRAW" property="isWithdraw"/>
|
|
<result column="IS_CONSUME" property="isConsume"/>
|
|
<result column="PAY_PWD" property="payPwd"/>
|
|
<result column="ACCOUNT_STATUS" property="accountStatus"/>
|
|
<result column="PK_COUNTRY" property="pkCountry"/>
|
|
</resultMap>
|
|
|
|
<select id="queryMemberAccountByCondition" resultMap="AccountExResultMap">
|
|
select cm.pay_pwd,
|
|
cm.account_status,
|
|
ca.pk_member,
|
|
ca.account1,
|
|
ca.lock_account1,
|
|
ca.account2,
|
|
ca.lock_account2,
|
|
ca.lock_account3,
|
|
ca.account3,
|
|
ca.lock_account4,
|
|
ca.account4,
|
|
ca.consume_account4,
|
|
ca.withdraw_account4,
|
|
ca.lock_account4,
|
|
ca.account5,
|
|
ca.lock_account5,
|
|
ca.account6,
|
|
ca.lock_account6,
|
|
ca.account7,
|
|
ca.lock_account7,
|
|
ca.account8,
|
|
ca.lock_account8,
|
|
ca.account9,
|
|
ca.account10,
|
|
ca.account11,
|
|
ca.account12,
|
|
ca.account13,
|
|
ca.lock_account13,
|
|
ca.is_transfer,
|
|
ca.is_withdraw,
|
|
ca.is_consume,
|
|
cm.pk_settle_country pk_country
|
|
from cu_member cm
|
|
inner join cu_member_account ca
|
|
on cm.pk_id = ca.pk_member
|
|
where cm.del_flag=0 and ca.del_flag=0
|
|
and cm.category =0
|
|
and cm.pk_settle_country=#{pkCountry}
|
|
<if test="pkMember != null and pkMember != ''">
|
|
and ca.pk_member = #{pkMember}
|
|
</if>
|
|
</select>
|
|
|
|
|
|
<!-- 根据会员编码获取会员账户余额 -->
|
|
<select id="selectBalanceByMemberCode" resultType="decimal">
|
|
SELECT CASE
|
|
WHEN 1 = #{accountType} then account1
|
|
WHEN 2 = #{accountType} then account2
|
|
WHEN 3 = #{accountType} then account3
|
|
WHEN 4 = #{accountType} then account4
|
|
WHEN 5 = #{accountType} then account5
|
|
WHEN 6 = #{accountType} then account6
|
|
WHEN 7 = #{accountType} then account7
|
|
WHEN 8 = #{accountType} then account8
|
|
WHEN 9 = #{accountType} then account9
|
|
WHEN 10 = #{accountType} then account10
|
|
WHEN 11 = #{accountType} then account11
|
|
WHEN 12 = #{accountType} then account12
|
|
WHEN 13 = #{accountType} then account13
|
|
WHEN 14 = #{accountType} then account14
|
|
WHEN 15 = #{accountType} then account15
|
|
WHEN 16 = #{accountType} then account16
|
|
WHEN 17 = #{accountType} then account17
|
|
WHEN 18 = #{accountType} then account18
|
|
WHEN 19 = #{accountType} then account19
|
|
WHEN 20 = #{accountType} then account20
|
|
END balance
|
|
FROM CU_MEMBER_ACCOUNT
|
|
WHERE pk_member = #{pkMember}
|
|
</select>
|
|
|
|
|
|
<update id="updateMemberAccount">
|
|
UPDATE CU_MEMBER_ACCOUNT
|
|
SET
|
|
<if test="account1 != null">
|
|
account1 = account1 + #{account1},
|
|
</if>
|
|
<if test="account2 != null">
|
|
account2 = account2 + #{account2},
|
|
</if>
|
|
<if test="account3 != null">
|
|
account3 = account3 + #{account3},
|
|
</if>
|
|
<if test="account4 != null">
|
|
account4 = account4 + #{account4},
|
|
</if>
|
|
<if test="account5 != null">
|
|
account5 = account5 + #{account5},
|
|
</if>
|
|
<if test="account6 != null">
|
|
account6 = account6 + #{account6},
|
|
</if>
|
|
<if test="account7 != null">
|
|
account7 = account7 + #{account7},
|
|
</if>
|
|
<if test="account8 != null">
|
|
account8 = account8 + #{account8},
|
|
</if>
|
|
<if test="account9 != null">
|
|
account9 = account9 + #{account9},
|
|
</if>
|
|
<if test="account10 != null">
|
|
account10 = account10 + #{account10},
|
|
</if>
|
|
<if test="account11 != null">
|
|
account11 = account11 + #{account11},
|
|
</if>
|
|
<if test="account12 != null">
|
|
account12 = account12 + #{account12},
|
|
</if>
|
|
<if test="account13 != null">
|
|
account13 = account13 + #{account13},
|
|
</if>
|
|
<if test="account14 != null">
|
|
account14 = account14 + #{account14},
|
|
</if>
|
|
<if test="account15 != null">
|
|
account15 = account15 + #{account15},
|
|
</if>
|
|
<if test="account16 != null">
|
|
account16 = account16 + #{account16},
|
|
</if>
|
|
<if test="account17 != null">
|
|
account17 = account17 + #{account17},
|
|
</if>
|
|
<if test="account18 != null">
|
|
account18 = account18 + #{account18},
|
|
</if>
|
|
<if test="account19 != null">
|
|
account19 = account19 + #{account19},
|
|
</if>
|
|
<if test="account20 != null">
|
|
account20 = account20 + #{account20},
|
|
</if>
|
|
<if test="lockAccount1 != null">
|
|
lock_account1 = #{lockAccount1},
|
|
</if>
|
|
<if test="lockAccount2 != null">
|
|
lock_account2 = #{lockAccount2},
|
|
</if>
|
|
<if test="lockAccount4 != null">
|
|
lock_account4 = #{lockAccount4},
|
|
</if>
|
|
<if test="withdrawAccount4 != null">
|
|
withdraw_account4 = withdraw_account4 + #{withdrawAccount4},
|
|
</if>
|
|
<if test="consumeAccount4 != null">
|
|
consume_account4 = consume_account4 + #{consumeAccount4},
|
|
</if>
|
|
<if test="lockAccount13 != null">
|
|
lock_account13 = #{lockAccount13},
|
|
</if>
|
|
pk_modified = #{pkModified},
|
|
modified_time = sysdate
|
|
WHERE pk_member = #{pkMember} and pk_country = #{pkCountry} and del_flag=0
|
|
</update>
|
|
|
|
<select id="queryMemberAccountByPkCountry" resultType="com.hzs.common.domain.member.ext.CuMemberAccountExt">
|
|
select a.*, b.pk_id pkBank
|
|
from cu_member_account a,
|
|
cu_member_bank b
|
|
where a.pk_member = b.pk_member
|
|
and a.del_flag = 0
|
|
and b.del_flag = 0
|
|
and b.default_card = 1
|
|
and a.is_withdraw = 0
|
|
and a.pk_country = #{pkCountry}
|
|
</select>
|
|
|
|
<update id="updateBatchMemberAccountByPkmember">
|
|
MERGE INTO cu_member_account m
|
|
USING (select *
|
|
from (select a.field_value,
|
|
r.recharge_amount,
|
|
pk_member,
|
|
r.recharge_method
|
|
from cu_member_recharge r
|
|
left join bd_account a
|
|
on r.pk_account = a.pk_id
|
|
where r.del_flag = 0
|
|
and r.batch = #{batch}) tt pivot(sum(recharge_amount)
|
|
for field_value in('1' as account1,
|
|
'2' as account2,
|
|
'3' as account3,
|
|
'4' as account4,
|
|
'5' as account5,
|
|
'6' as account6,
|
|
'7' as account7,
|
|
'8' as account8,
|
|
'9' as account9,
|
|
'10' as account10,
|
|
'12' as account12,
|
|
'13' as account13))) t
|
|
ON (m.pk_member = t.pk_member)
|
|
WHEN MATCHED THEN
|
|
update
|
|
set m.account1 = NVL(t.account1, 0) + m.account1,
|
|
m.account2 = NVL(t.account2, 0) + m.account2,
|
|
m.account3 = NVL(t.account3, 0) + m.account3,
|
|
m.account4 = NVL(t.account4, 0) + m.account4,
|
|
m.WITHDRAW_ACCOUNT4 = case
|
|
when NVL(t.account4, 0) < 0 and
|
|
m.WITHDRAW_ACCOUNT4 + NVL(t.account4, 0) >= 0 then
|
|
NVL(t.account4, 0) + m.WITHDRAW_ACCOUNT4
|
|
when NVL(t.account4, 0) < 0 and
|
|
m.WITHDRAW_ACCOUNT4 + NVL(t.account4, 0) < 0 then
|
|
0
|
|
else
|
|
m.WITHDRAW_ACCOUNT4
|
|
end,
|
|
m.CONSUME_ACCOUNT4 = case
|
|
when NVL(t.account4, 0) < 0 and
|
|
m.WITHDRAW_ACCOUNT4 + NVL(t.account4, 0) < 0 then
|
|
m.WITHDRAW_ACCOUNT4 + t.account4 + m.CONSUME_ACCOUNT4
|
|
else
|
|
NVL(t.account4, 0) + m.CONSUME_ACCOUNT4
|
|
end,
|
|
m.account5 = NVL(t.account5, 0) + m.account5,
|
|
m.account6 = NVL(t.account6, 0) + m.account6,
|
|
m.account7 = NVL(t.account7, 0) + m.account7,
|
|
m.account8 = NVL(t.account8, 0) + m.account8,
|
|
m.account9 = NVL(t.account9, 0) + m.account9,
|
|
m.account10 = NVL(t.account10, 0) + m.account10,
|
|
m.account12 = NVL(t.account12, 0) + m.account12,
|
|
m.account13 = NVL(t.account13, 0) + m.account13,
|
|
m.MODIFIED_TIME = sysdate,
|
|
m.PK_MODIFIED = #{pkModified}
|
|
</update>
|
|
|
|
|
|
<select id="queryMemberAccountAllByMemberCodes" resultType="com.hzs.common.domain.member.ext.CuMemberAccountExt">
|
|
select m.member_code memberCode,
|
|
m.member_name memberName,
|
|
a.*
|
|
from cu_member_account a, cu_member m
|
|
where a.pk_member = m.pk_id
|
|
and a.del_flag = 0
|
|
and m.del_flag = 0
|
|
<if test="memberCodes != null and memberCodes.size >0">
|
|
and m.member_code in
|
|
<foreach collection="memberCodes" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
|
|
<sql id="select_base">
|
|
with t1 as
|
|
(select u.member_code,
|
|
u.member_name,
|
|
u.pk_id,
|
|
u.pk_vertex vertex_id,
|
|
u.pk_team_code team_id,
|
|
v.vertex_name,
|
|
v.pk_member,
|
|
u.pk_place_parent,
|
|
u.pk_parent,
|
|
t.team_name
|
|
from cu_member u
|
|
left join bd_vertex v
|
|
on u.pk_vertex = v.pk_id
|
|
and v.del_flag = 0
|
|
left join cu_member_team t
|
|
on u.pk_team_code = t.pk_id
|
|
and t.del_flag = 0
|
|
where u.del_flag = 0
|
|
and u.pk_settle_country = #{pkCountry})
|
|
select ss.memberCode,
|
|
ss.memberName,
|
|
ss.pk_id pkId,
|
|
ss.vertexId,
|
|
ss.teamId,
|
|
ss.vertexName,
|
|
ss.pk_member,
|
|
ss.pk_place_parent,
|
|
ss.pk_parent,
|
|
ss.teamName,
|
|
ss.slevel,
|
|
pp.plevel,
|
|
account1,
|
|
lock_account1,
|
|
lock_transfer_account1,
|
|
account2,
|
|
lock_account2,
|
|
lock_transfer_account2,
|
|
account3,
|
|
lock_account3,
|
|
lock_transfer_account3,
|
|
account4,
|
|
lock_account4,
|
|
lock_transfer_account4,
|
|
lock_withdraw_account4,
|
|
withdraw_account4,
|
|
consume_account4,
|
|
account5,
|
|
lock_account5,
|
|
lock_transfer_account5,
|
|
account6,
|
|
lock_account6,
|
|
lock_transfer_account6,
|
|
account7,
|
|
lock_account7,
|
|
lock_transfer_account7,
|
|
account8,
|
|
lock_account8,
|
|
lock_transfer_account8,
|
|
account9,
|
|
lock_account9,
|
|
lock_transfer_account9,
|
|
account10,
|
|
lock_account10,
|
|
account11,
|
|
lock_transfer_account10,
|
|
account12,
|
|
account13,
|
|
lock_account13
|
|
from (select member_code memberCode,
|
|
member_name memberName,
|
|
pk_id,
|
|
vertex_id vertexId,
|
|
team_id teamId,
|
|
vertex_name vertexName,
|
|
pk_member,
|
|
pk_place_parent,
|
|
pk_parent,
|
|
team_name teamName,
|
|
level slevel
|
|
from t1
|
|
<include refid="list_place_where"></include>
|
|
start with pk_id =
|
|
<if test="memberCode != null and memberCode != ''">
|
|
(select cm.pk_id
|
|
from cu_member cm
|
|
where cm.member_code = #{memberCode})
|
|
</if>
|
|
<if test="memberCode == null or memberCode == ''">
|
|
pk_member
|
|
</if>
|
|
connect by prior pk_id = pk_place_parent) ss,
|
|
(select pk_id, level plevel
|
|
from t1
|
|
<include refid="list_rem_where"></include>
|
|
start with pk_id =
|
|
<if test="memberCode != null and memberCode != ''">
|
|
(select cm.pk_id
|
|
from cu_member cm
|
|
where cm.member_code = #{memberCode})
|
|
</if>
|
|
<if test="memberCode == null or memberCode == ''">
|
|
pk_member
|
|
</if>
|
|
connect by prior pk_id = pk_parent) pp,
|
|
cu_member_account a
|
|
</sql>
|
|
|
|
<!-- 安置条件 -->
|
|
<sql id="list_place_where">
|
|
<where>
|
|
1=1
|
|
<if test="memberName != null and memberName != ''">
|
|
and member_name like #{memberName} || '%'
|
|
</if>
|
|
<if test="vertexName != null and vertexName != ''">
|
|
and vertex_name like #{memberName} || '%'
|
|
</if>
|
|
<if test="teamName != null and teamName != ''">
|
|
and team_name like #{teamName} || '%'
|
|
</if>
|
|
<if test="teamId != null">
|
|
and team_id = #{teamId}
|
|
</if>
|
|
<if test="vertexId != null">
|
|
and vertex_id = #{vertexId}
|
|
</if>
|
|
<if test="slevel != null">
|
|
and level <= #{slevel}
|
|
</if>
|
|
</where>
|
|
</sql>
|
|
|
|
<!-- 推荐条件 -->
|
|
<sql id="list_rem_where">
|
|
<where>
|
|
1=1
|
|
<if test="memberName != null and memberName != ''">
|
|
and member_name like #{memberName} || '%'
|
|
</if>
|
|
<if test="vertexName != null and vertexName != ''">
|
|
and vertex_name like #{memberName} || '%'
|
|
</if>
|
|
<if test="teamName != null and teamName != ''">
|
|
and team_name like #{teamName} || '%'
|
|
</if>
|
|
<if test="teamId != null">
|
|
and team_id = #{teamId}
|
|
</if>
|
|
<if test="vertexId != null">
|
|
and vertex_id = #{vertexId}
|
|
</if>
|
|
|
|
<if test="plevel != null">
|
|
and level <= #{plevel}
|
|
</if>
|
|
</where>
|
|
</sql>
|
|
|
|
<sql id="list_where">
|
|
<where>
|
|
ss.pk_id = pp.pk_id
|
|
and ss.pk_id = a.pk_member
|
|
and a.del_flag = 0
|
|
and a.pk_country = #{pkCountry}
|
|
</where>
|
|
</sql>
|
|
|
|
|
|
<sql id="ids_where">
|
|
<where>
|
|
ss.pk_id = pp.pk_id
|
|
and ss.pk_id = a.pk_member
|
|
and a.del_flag = 0
|
|
and a.pk_country = #{pkCountry}
|
|
and ss.pk_id in
|
|
<foreach collection="pkIds" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</where>
|
|
</sql>
|
|
|
|
|
|
<select id="selectPkMembersByMemberCode" resultType="java.lang.Long">
|
|
select a.pk_member
|
|
from cu_member_account a, cu_member c
|
|
where a.pk_member = c.pk_id
|
|
and c.del_flag = 0
|
|
and c.account_status = 0
|
|
and a.del_flag = 0
|
|
and c.pk_settle_country= #{pkCountry}
|
|
and c.member_code in
|
|
<foreach collection="memberCodes" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</select>
|
|
|
|
|
|
<update id="updateFrozenAmountInfo">
|
|
update cu_member_account a
|
|
set
|
|
<if test="lockAccount1 != null">
|
|
a.lock_account1 = #{lockAccount1},
|
|
</if>
|
|
<if test="lockTransferAccount1 != null">
|
|
a.lock_transfer_account1 = #{lockTransferAccount1},
|
|
</if>
|
|
<if test="account1Remarks != null and account1Remarks != ''">
|
|
a.account1_remarks = #{account1Remarks},
|
|
</if>
|
|
|
|
<if test="lockAccount2 != null">
|
|
a.lock_account2 = #{lockAccount2},
|
|
</if>
|
|
<if test="lockTransferAccount2 != null">
|
|
a.lock_transfer_account2 = #{lockTransferAccount2},
|
|
</if>
|
|
<if test="account2Remarks != null and account2Remarks != ''">
|
|
a.account2_remarks = #{account2Remarks},
|
|
</if>
|
|
|
|
<if test="lockAccount3 != null">
|
|
a.lock_account3 = #{lockAccount3},
|
|
</if>
|
|
<if test="lockTransferAccount3 != null">
|
|
a.lock_transfer_account3 = #{lockTransferAccount3},
|
|
</if>
|
|
<if test="account3Remarks != null and account3Remarks != ''">
|
|
a.account3_remarks = #{account3Remarks},
|
|
</if>
|
|
|
|
<if test="lockAccount4 != null">
|
|
a.lock_account4 = #{lockAccount4},
|
|
</if>
|
|
<if test="lockTransferAccount4 != null">
|
|
a.lock_transfer_account4 = #{lockTransferAccount4},
|
|
</if>
|
|
<if test="lockWithdrawAccount4 != null">
|
|
a.lock_withdraw_account4 = #{lockWithdrawAccount4},
|
|
</if>
|
|
<if test="account4Remarks != null and account4Remarks != ''">
|
|
a.account4_remarks = #{account4Remarks},
|
|
</if>
|
|
|
|
<if test="lockAccount5 != null">
|
|
a.lock_account5 = #{lockAccount5},
|
|
</if>
|
|
<if test="lockTransferAccount5 != null">
|
|
a.lock_transfer_account5 = #{lockTransferAccount5},
|
|
</if>
|
|
<if test="account5Remarks != null and account5Remarks != ''">
|
|
a.account5_remarks = #{account5Remarks},
|
|
</if>
|
|
|
|
<if test="lockAccount6 != null">
|
|
a.lock_account6 = #{lockAccount6},
|
|
</if>
|
|
<if test="lockTransferAccount6 != null">
|
|
a.lock_transfer_account6 = #{lockTransferAccount6},
|
|
</if>
|
|
<if test="account6Remarks != null and account6Remarks != ''">
|
|
a.account6_remarks = #{account6Remarks},
|
|
</if>
|
|
|
|
<if test="lockAccount7 != null">
|
|
a.lock_account7 = #{lockAccount7},
|
|
</if>
|
|
<if test="lockTransferAccount7 != null">
|
|
a.lock_transfer_account7 = #{lockTransferAccount7},
|
|
</if>
|
|
<if test="account7Remarks != null and account7Remarks != ''">
|
|
a.account7_remarks = #{account7Remarks},
|
|
</if>
|
|
|
|
<if test="lockAccount8 != null">
|
|
a.lock_account8 = #{lockAccount8},
|
|
</if>
|
|
<if test="lockTransferAccount8 != null">
|
|
a.lock_transfer_account8 = #{lockTransferAccount8},
|
|
</if>
|
|
<if test="account8Remarks != null and account8Remarks != ''">
|
|
a.account8_remarks = #{account8Remarks},
|
|
</if>
|
|
|
|
<if test="lockAccount9 != null">
|
|
a.lock_account9 = #{lockAccount9},
|
|
</if>
|
|
<if test="lockTransferAccount9 != null">
|
|
a.lock_transfer_account9 = #{lockTransferAccount9},
|
|
</if>
|
|
<if test="account9Remarks != null and account9Remarks != ''">
|
|
a.account9_remarks = #{account9Remarks},
|
|
</if>
|
|
|
|
<if test="lockAccount10 != null">
|
|
a.lock_account10 = #{lockAccount10},
|
|
</if>
|
|
<if test="lockTransferAccount10 != null">
|
|
a.lock_transfer_account10 = #{lockTransferAccount10},
|
|
</if>
|
|
<if test="account10Remarks != null and account10Remarks != ''">
|
|
a.account10_remarks = #{account10Remarks},
|
|
</if>
|
|
a.pk_modified = #{pkModified},
|
|
a.modified_time = sysdate
|
|
WHERE a.pk_member in
|
|
<foreach collection="pkMembers" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</update>
|
|
|
|
<update id="updateMemberAccountGrantByPeriod">
|
|
merge into cu_member_account a
|
|
using (select pk_member,
|
|
sum(real_income_total * bc.out_exchange_rate) account4,
|
|
sum(back_points * bc.out_exchange_rate) account5,
|
|
sum(repur_coupon_subtotal * bc.out_exchange_rate) account8,
|
|
sum(global_points * bc.out_exchange_rate) account9,
|
|
sum(car_award_points * bc.out_exchange_rate) account10
|
|
from cu_member_bonus cb
|
|
inner join bd_currency bc
|
|
on cb.pk_country = bc.pk_country
|
|
where cb.del_flag = 0
|
|
and cb.pk_country = #{pkCountry}
|
|
and period between #{startPeriod} and #{endPeriod}
|
|
and cb.grant_status = 2
|
|
group by pk_member
|
|
) b
|
|
on (a.pk_member = b.pk_member)
|
|
when matched then
|
|
update set a.account4 = a.account4 + b.account4,
|
|
a.consume_account4 = a.consume_account4 + b.account4,
|
|
a.account5 = a.account5 + b.account5,
|
|
a.account8 = a.account8 + b.account8
|
|
</update>
|
|
<update id="updateMemberAccountWithdrawalByPeriod">
|
|
merge into cu_member_account a
|
|
using (
|
|
select a.pk_member,
|
|
(case
|
|
when CONSUME_ACCOUNT4 >= a.consume_money then a.consume_money
|
|
else CONSUME_ACCOUNT4 end) consume_money
|
|
from (select ct.pk_member, sum(cd.consume_money) consume_money
|
|
from cu_member_trade ct
|
|
inner join cu_member_trade_detail cd
|
|
on cd.pk_member_trade = ct.pk_id
|
|
where cd.del_flag = 0
|
|
and ct.del_flag = 0
|
|
and cd.trade_statue = 1
|
|
and cd.period between #{startPeriod} and #{endPeriod}
|
|
and ct.pk_country = #{pkCountry}
|
|
group by ct.pk_member) a
|
|
inner join cu_member_account ca
|
|
on a.pk_member = ca.pk_member
|
|
where ca.CONSUME_ACCOUNT4 > 0
|
|
) b
|
|
on (a.pk_member = b.pk_member)
|
|
when matched then
|
|
update set a.withdraw_account4 = a.withdraw_account4 + b.consume_money,
|
|
a.consume_account4 = a.consume_account4 - b.consume_money
|
|
</update>
|
|
|
|
<select id="selectMemberBonusAccountBySourceCode" resultMap="AccountExResultMap">
|
|
select r.pk_member, ma.account4, ma.withdraw_account4, ma.consume_account4, ma.pk_modified, ma.pk_country
|
|
from cu_member_recharge r
|
|
left join cu_member_account ma
|
|
on r.pk_member = ma.pk_member
|
|
and ma.del_flag = 0
|
|
left join bd_account a
|
|
on r.pk_account = a.pk_id
|
|
and a.del_flag = 0
|
|
where r.del_flag = 0
|
|
and a.field_value = 4
|
|
and r.batch = #{sourceCode}
|
|
</select>
|
|
|
|
</mapper>
|