cloudroam
3 天以前 3a819e4f668c15e8b77b188b322470da12bb7a43
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?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.wallet.WalletBillRecordMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.mzl.flower.entity.wallet.WalletBillRecordDO">
        <id column="id" property="id" />
        <result column="create_by" property="createBy" />
        <result column="create_time" property="createTime" />
        <result column="update_by" property="updateBy" />
        <result column="update_time" property="updateTime" />
        <result column="deleted" property="deleted" />
        <result column="supplier_id" property="supplierId" />
        <result column="wallet_id" property="walletId" />
        <result column="type" property="type" />
 
        <result column="withdraw_type" property="withdrawType" />
 
        <result column="type_detail" property="typeDetail" />
        <result column="transfer_id" property="transferId" />
        <result column="method" property="method" />
        <result column="original_amount" property="originalAmount" />
        <result column="change_amount" property="changeAmount" />
        <result column="balance" property="balance" />
        <result column="transfer_detail_id" property="transferDetailId" />
        <result column="open_id" property="openId" />
    </resultMap>
    <select id="getPage" resultType="com.mzl.flower.dto.response.wallet.WalletBillRecordVO">
        select wbr.*, u.nick_name AS approveName
        from t_wallet_bill_record wbr
        LEFT JOIN t_user u ON wbr.approve_by = u.id
        where wbr.DELETED=0
        <if test="dto.supplierId != null and dto.supplierId != ''">
            and wbr.supplier_id= #{dto.supplierId}
        </if>
        <if test="dto.startDate != null">
            and DATE_FORMAT(wbr.create_time, '%Y-%m-%d') &gt;= #{dto.startDate}
        </if>
        <if test="dto.endDate != null">
            and DATE_FORMAT(wbr.create_time, '%Y-%m-%d') &lt;= #{dto.endDate}
        </if>
        order by wbr.create_time asc
    </select>
 
    <select id="getPageByDesc" resultType="com.mzl.flower.dto.response.wallet.WalletBillRecordVO">
        select wbr.*, u.nick_name AS approveName
        from t_wallet_bill_record wbr
        LEFT JOIN t_user u ON wbr.approve_by = u.id
        where wbr.DELETED=0
        <if test="dto.supplierId != null and dto.supplierId != ''">
            and wbr.supplier_id= #{dto.supplierId}
        </if>
        <if test="dto.startDate != null">
            and DATE_FORMAT(wbr.create_time, '%Y-%m-%d') &gt;= #{dto.startDate}
        </if>
        <if test="dto.endDate != null">
            and DATE_FORMAT(wbr.create_time, '%Y-%m-%d') &lt;= #{dto.endDate}
        </if>
        order by wbr.create_time desc
    </select>
    <select id="queryPage" resultType="com.mzl.flower.dto.response.wallet.WalletBillRecordVO">
--         select t.* ,s.name supplierName ,w.approve_time as approveTime ,u.nick_name AS approveName from t_wallet_bill_record t
--         left join t_supplier_info s on t.supplier_id = s.id
--         left join t_wallet_withdraw_record w on t.withdraw_record_id = w.id
--         LEFT JOIN t_user u ON t.approve_by = u.id
--         where t.deleted= 0
        SELECT
        t.*,
        (SELECT s.name FROM t_supplier_info s WHERE s.id = t.supplier_id) AS supplierName,
        (SELECT w.approve_time FROM t_wallet_withdraw_record w WHERE w.id = t.withdraw_record_id) AS approveTime,
        (SELECT u.nick_name FROM t_user u WHERE u.id = t.approve_by) AS approveName
        FROM
        t_wallet_bill_record t
        WHERE
        t.deleted = 0
        <if test="dto.supplierName != null and dto.supplierName != ''">
            AND (SELECT s.name FROM t_supplier_info s WHERE s.id = t.supplier_id) LIKE CONCAT('%', #{dto.supplierName}, '%')
        </if>
        <if test="dto.supplierId != null and dto.supplierId != ''">
            and t.supplier_id = #{dto.supplierId}
        </if>
        <if test="dto.type != null and dto.type != ''">
            and t.type = #{dto.type}
        </if>
        <if test="dto.orderNo != null and dto.orderNo != ''">
            and t.order_no  like concat('%', #{dto.orderNo}, '%')
        </if>
        <if test="dto.createStartDate!=null ">
            AND DATE_FORMAT(t.create_time, '%Y-%m-%d') &gt;= #{dto.createStartDate}
        </if>
        <if test="dto.endEndDate!=null ">
            AND DATE_FORMAT(t.create_time, '%Y-%m-%d') &lt;= #{dto.endEndDate}
        </if>
        <if test="dto.approveStartDate!=null ">
            AND DATE_FORMAT((SELECT w.approve_time FROM t_wallet_withdraw_record w WHERE w.id = t.withdraw_record_id), '%Y-%m-%d') &gt;= #{dto.approveStartDate}
        </if>
        <if test="dto.approveEndDate!=null ">
            AND DATE_FORMAT((SELECT w.approve_time FROM t_wallet_withdraw_record w WHERE w.id = t.withdraw_record_id), '%Y-%m-%d')  &lt;= #{dto.approveEndDate}
        </if>
        order by t.create_time desc
    </select>
 
    <select id="queryWalletBillRecordList" resultType="com.mzl.flower.dto.response.wallet.WalletBillRecordVO">
        select t.* , s.name supplierName, w.approve_time as approveTime, u.nick_name AS approveName from t_wallet_bill_record t
        left join t_supplier_info s on t.supplier_id = s.id
        left join t_wallet_withdraw_record w on t.withdraw_record_id = w.id
        LEFT JOIN t_user u ON t.approve_by = u.id
        where t.deleted= 0
        <if test="dto.supplierName != null and dto.supplierName != ''">
            and s.name like concat('%', #{dto.supplierName}, '%')
        </if>
        <if test="dto.supplierId != null and dto.supplierId != ''">
            and t.supplier_id = #{dto.supplierId}
        </if>
        <if test="dto.type != null and dto.type != ''">
            and t.type = #{dto.type}
        </if>
        <if test="dto.orderNo != null and dto.orderNo != ''">
            and t.order_no  like concat('%', #{dto.orderNo}, '%')
        </if>
        <if test="dto.createStartDate!=null ">
            AND DATE_FORMAT(t.create_time, '%Y-%m-%d') &gt;= #{dto.createStartDate}
        </if>
        <if test="dto.endEndDate!=null ">
            AND DATE_FORMAT(t.create_time, '%Y-%m-%d') &lt;= #{dto.endEndDate}
        </if>
        <if test="dto.approveStartDate!=null ">
            AND DATE_FORMAT(w.approve_time, '%Y-%m-%d') &gt;= #{dto.approveStartDate}
        </if>
        <if test="dto.approveEndDate!=null ">
            AND DATE_FORMAT(w.approve_time, '%Y-%m-%d') &lt;= #{dto.approveEndDate}
        </if>
        order by t.create_time
    </select>
</mapper>