cloudroam
2024-11-12 4537f8e46508fbe3627fe916ada90ebc7d281a7e
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
<?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.mzl.flower.mapper.payment.OrderSettlementMapper">
 
    <select id="selectSettlementList" resultType="com.mzl.flower.dto.response.payment.OrderSettlementListDTO">
        SELECT s.*, ifnull(si.name, pi.name) userName
        FROM t_order_settlement s
        left join t_supplier_info si on s.user_id = si.user_id
        left join t_partner_info pi on s.user_id = pi.user_id
        WHERE s.deleted = 0
        <if test="condition.userId != null and condition.userId != ''">
            AND s.user_id = #{condition.userId}
        </if>
        <if test="condition.type != null and condition.type != ''">
            AND s.type = #{condition.type}
        </if>
        <if test="condition.status != null and condition.status != ''">
            AND s.status = #{condition.status}
        </if>
        <if test="condition.startDate != null">
            AND s.create_time &gt;= #{condition.startDate}
        </if>
        <if test="condition.endDate != null">
            AND s.create_time &lt;= #{condition.endDate}
        </if>
        <if test="condition.userName != null and condition.userName != ''">
            AND (si.name LIKE CONCAT('%', #{condition.userName}, '%') OR pi.name LIKE CONCAT('%', #{condition.userName}, '%'))
        </if>
        ORDER BY s.create_time desc, userName
    </select>
 
 
    <select id="selectSettlementListInfo" resultType="com.mzl.flower.dto.response.payment.OrderSettlementListDTO">
        SELECT s.*, ifnull(si.name, pi.name) userName,
        code.label as statusStr,
        code2.label as typeStr
        FROM t_order_settlement s
        left join t_supplier_info si on s.user_id = si.user_id
        left join t_partner_info pi on s.user_id = pi.user_id
        LEFT JOIN (SELECT ct.label, ct.value from t_code_value ct where type_code = 'SETTLEMENT_STATUS') code ON s.status = code.value
        LEFT JOIN (SELECT ct.label, ct.value from t_code_value ct where type_code = 'SETTLEMENT_TYPE') code2 ON s.type = code2.value
        WHERE s.deleted = 0
        <if test="condition.userId != null and condition.userId != ''">
            AND s.user_id = #{condition.userId}
        </if>
        <if test="condition.type != null and condition.type != ''">
            AND s.type = #{condition.type}
        </if>
        <if test="condition.status != null and condition.status != ''">
            AND s.status = #{condition.status}
        </if>
        <if test="condition.startDate != null">
            AND s.create_time &gt;= #{condition.startDate}
        </if>
        <if test="condition.endDate != null">
            AND s.create_time &lt;= #{condition.endDate}
        </if>
        <if test="condition.userName != null and condition.userName != ''">
            AND (si.name LIKE CONCAT('%', #{condition.userName}, '%') OR pi.name LIKE CONCAT('%', #{condition.userName}, '%'))
        </if>
        ORDER BY s.create_time desc, userName
    </select>
 
    <select id="getUserIncome" resultType="java.math.BigDecimal">
        select sum(settlement_amount)
        from t_order_settlement
        where user_id = #{userId}
        and deleted = 0
    </select>
</mapper>