TdBSettlementSMapper.xml
5.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?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.zteits.order.mapper.smapper.TdBSettlementSMapper">
<resultMap id="BaseResultMap" type="com.zteits.order.domain.TdBSettlement">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="settlement_no" jdbcType="VARCHAR" property="settlementNo" />
<result column="from_org_id" jdbcType="BIGINT" property="fromOrgId" />
<result column="to_org_id" jdbcType="BIGINT" property="toOrgId" />
<result column="from_org_name" jdbcType="VARCHAR" property="fromOrgName" />
<result column="to_org_name" jdbcType="VARCHAR" property="toOrgName" />
<result column="settlement_total_fee" jdbcType="BIGINT" property="settlementTotalFee" />
<result column="settlement_act_fee" jdbcType="BIGINT" property="settlementActFee" />
<result column="start_date" jdbcType="DATE" property="startDate" />
<result column="end_date" jdbcType="DATE" property="endDate" />
<result column="settlement_state" jdbcType="INTEGER" property="settlementState" />
<result column="cancel_reason" jdbcType="VARCHAR" property="cancelReason" />
<result column="ali_fee" jdbcType="BIGINT" property="aliFee" />
<result column="ali_refund_fee" jdbcType="BIGINT" property="aliRefundFee" />
<result column="ali_srv_fee" jdbcType="BIGINT" property="aliSrvFee" />
<result column="ali_charge_num" jdbcType="INTEGER" property="aliChargeNum" />
<result column="wx_fee" jdbcType="BIGINT" property="wxFee" />
<result column="wx_refund_fee" jdbcType="BIGINT" property="wxRefundFee" />
<result column="wx_srv_fee" jdbcType="BIGINT" property="wxSrvFee" />
<result column="wx_charge_num" jdbcType="INTEGER" property="wxChargeNum" />
<result column="balance_fee" jdbcType="BIGINT" property="balanceFee" />
<result column="balance_refund_fee" jdbcType="BIGINT" property="balanceRefundFee" />
<result column="balance_srv_fee" jdbcType="BIGINT" property="balanceSrvFee" />
<result column="balance_charge_num" jdbcType="INTEGER" property="balanceChargeNum" />
<result column="platform_srv_fee" jdbcType="BIGINT" property="platformSrvFee" />
<result column="create_emp_id" jdbcType="VARCHAR" property="createEmpId" />
<result column="from_bank_acct_no" jdbcType="VARCHAR" property="fromBankAcctNo" />
<result column="to_bank_acct_no" jdbcType="VARCHAR" property="toBankAcctNo" />
<result column="bank_seri_no" jdbcType="VARCHAR" property="bankSeriNo" />
<result column="back_seri_no_pic" jdbcType="VARCHAR" property="backSeriNoPic" />
<result column="create_emp_name" jdbcType="VARCHAR" property="createEmpName" />
<result column="from_modfiy_empid" jdbcType="VARCHAR" property="fromModfiyEmpid" />
<result column="from_modfiy_date" jdbcType="TIMESTAMP" property="fromModfiyDate" />
<result column="to_modfiy_empid" jdbcType="VARCHAR" property="toModfiyEmpid" />
<result column="to_modfiy_date" jdbcType="TIMESTAMP" property="toModfiyDate" />
<result column="data_state" jdbcType="INTEGER" property="dataState" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
</resultMap>
<!-- 根据结算单状态查询结算单汇总 -->
<select id="querySettlementFeeSummary" resultType="com.zteits.clouds.api.dto.order.settlement.dto.SettlementFeeDTO"
parameterType="com.zteits.clouds.api.dto.order.settlement.param.SettlementQueryRequest">
SELECT
SUM(IFNULL(settlement_total_fee,0)) settlementTotalFee,
SUM(IFNULL(settlement_act_fee,0)) settlementActFee,
SUM(IFNULL(ali_srv_fee,0)+IFNULL(wx_srv_fee,0)+IFNULL(balance_srv_fee,0)+IFNULL(platform_srv_fee,0)) srvFee
FROM
`td_b_settlement`
WHERE
1 = 1
<if test="settlementStates != null and settlementStates.size >0">
AND settlement_state IN
<foreach collection="settlementStates" open="(" close=")" item="settlementState" separator=",">
#{settlementState}
</foreach>
</if>
<if test="fromOrgId != null">
AND from_org_id = #{fromOrgId}
</if>
<if test="toOrgIds != null and toOrgIds.size >0">
AND to_org_id IN
<foreach collection="toOrgIds" open="(" close=")" item="toOrgId" separator=",">
#{toOrgId}
</foreach>
</if>
<if test="startDate != null">
AND date(start_date) >= date(#{startDate}) AND date(end_date) >= date(#{startDate})
</if>
<if test="startDate != null">
AND date(start_date) <= date(#{endDate}) AND date(end_date) <= date(#{endDate})
</if>
AND data_state = 1
</select>
<select id="querySettlementCustInfo" resultType="com.zteits.clouds.api.dto.order.settlement.dto.SettlementCustInfoDTO">
SELECT t.org_id toOrgId,
max(t.org_name ) custName,
sum(IFNULL(t.settlement_total_fee,0)) settlementTotalFee,
sum(CASE WHEN t.check_status <=300
THEN t.settlement_act_fee
ELSE 0 END) noSettleFee,
sum(CASE WHEN t.check_status = 400
THEN t.settlement_act_fee
ELSE 0 END) hasSettleFee,
sum(CASE WHEN t.check_status =500
THEN t.settlement_act_fee
ELSE 0 END) ingSettleFee
FROM td_b_settlement_record t
WHERE data_state = 1 AND check_date >= #{startDate} AND check_date <= #{endDate}
GROUP BY org_id
</select>
</mapper>