chenrui
5 天以前 ab01a0f611c0adb97662bc8f548ca4a911ec8045
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?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.ruoyi.purchase.mapper.PaymentRegistrationMapper">
 
    <resultMap type="PaymentRegistration" id="PaymentRegistrationResult">
        <result property="id" column="id"/>
        <result property="saleLedgerId" column="sale_ledger_id"/>
        <result property="purchaseLedgerId" column="purchase_ledger_id"/>
        <result property="supplierId" column="supplier_id"/>
        <result property="ticketRegistrationId" column="ticket_registration_id"/>
        <result property="currentPaymentAmount" column="current_payment_amount"/>
        <result property="paymentMethod" column="payment_method"/>
        <result property="registrantId" column="registrant_id"/>
        <result property="paymentDate" column="payment_date"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="tenantId" column="tenant_id"/>
        <result property="registrationtDate" column="registrationt_date"/>
    </resultMap>
 
    <resultMap type="com.ruoyi.purchase.dto.PaymentRegistrationDto" id="PaymentRegistrationDtoResult">
        <result property="id" column="id"/>
        <result property="saleLedgerId" column="sale_ledger_id"/>
        <result property="purchaseLedgerId" column="purchase_ledger_id"/>
        <result property="supplierId" column="supplier_id"/>
        <result property="ticketRegistrationId" column="ticket_registration_id"/>
        <result property="currentPaymentAmount" column="current_payment_amount"/>
        <result property="paymentMethod" column="payment_method"/>
        <result property="registrantId" column="registrant_id"/>
        <result property="paymentDate" column="payment_date"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="salesContractNo" column="sales_contract_no"/>
        <result property="purchaseContractNumber" column="purchase_contract_number"/>
        <result property="supplierName" column="supplier_name"/>
        <result property="invoiceNumber" column="invoice_number"/>
        <result property="taxRate" column="tax_rate"/>
        <result property="invoiceAmount" column="invoice_amount"/>
        <result property="tenantId" column="tenant_id"/>
        <result property="registrationtDate" column="registrationt_date"/>
    </resultMap>
 
    <sql id="selectPaymentRegistrationVo">
        select pr.id,
               pr.sale_ledger_id,
               pr.purchase_ledger_id,
               pr.supplier_id,
               pr.ticket_registration_id,
               pr.current_payment_amount,
               pr.payment_method,
               pr.registrant_id,
               pr.payment_date,
               pr.create_time,
               pr.update_time,
               pr.tenant_id,
               sl.sales_contract_no as sales_contract_no,
               pl.purchase_contract_number as purchase_contract_number,
               sm.supplier_name as supplier_name,
               ip.invoice_number as invoice_number,
               ip.invoice_amount as invoice_amount,
               pr.tax_rate,
               pr.registrationt_date,
               su.nick_name as registrant
        from payment_registration pr
                 left join sales_ledger sl on pr.sale_ledger_id = sl.id
                 left join purchase_ledger pl on pr.purchase_ledger_id = pl.id
                 left join supplier_manage sm on pr.supplier_id = sm.id
                 left join ticket_registration ip on pr.ticket_registration_id = ip.id
                 left join sys_user su on pr.registrant_id = su.user_id
    </sql>
 
    <select id="selectPaymentRegistrationList" parameterType="com.ruoyi.purchase.dto.PaymentRegistrationDto"
            resultMap="PaymentRegistrationDtoResult">
        <include refid="selectPaymentRegistrationVo"/>
        <where>
            <if test="supplierNameOrContractNo != null  and supplierNameOrContractNo != ''">
                and sm.supplier_name LIKE CONCAT('%', #{supplierNameOrContractNo}, '%') or sl.sales_contract_no LIKE
                CONCAT('%', #{supplierNameOrContractNo}, '%')
                or pl.purchase_contract_number LIKE CONCAT('%', #{supplierNameOrContractNo}, '%')
            </if>
        </where>
    </select>
 
    <select id="selectPaymentRegistrationById" parameterType="Long" resultMap="PaymentRegistrationDtoResult">
        <include refid="selectPaymentRegistrationVo"/>
        where pr.id = #{id}
    </select>
 
    <select id="paymentHistoryList" resultType="com.ruoyi.purchase.dto.PaymentRegistrationDto">
        SELECT
            T1.payment_date,
            T2.supplier_name,
            T1.current_payment_amount,
            T1.payment_method,
            T3.nick_name AS registrant,
            T1.registrationt_date
        FROM
            payment_registration T1
                LEFT JOIN
            supplier_manage T2 ON T1.supplier_id = T2.id
                LEFT JOIN
            sys_user T3 ON T3.user_id = T1.registrant_id
        <where>
            <if test="params.searchText != null and params.searchText != '' ">
                AND T2.supplier_name LIKE CONCAT('%',#{params.searchText},'%')
            </if>
        </where>
        ORDER BY T1.payment_date,T1.create_time DESC
    </select>
 
    <select id="countPaymentTotalByTicketRegId" resultType="com.ruoyi.purchase.dto.PaymentRegistrationDto">
        SELECT
            IFNULL(SUM(current_payment_amount),0) AS paymentAmountTotal,
            ticket_registration_id
        FROM
            payment_registration
        <where>
            ticket_registration_id IN
            <foreach collection="ticketRegistrationIds" separator="," open="(" close=")" item="item">
                #{item}
            </foreach>
        </where>
        GROUP BY ticket_registration_id
    </select>
 
    <select id="getPaymentRecordList" resultType="com.ruoyi.purchase.dto.PaymentHistoryRecordVo">
        SELECT * FROM(
             SELECT
                 T1.issue_date AS happenTime,
                 IFNULL(T1.invoice_amount,0) AS invoiceAmount,
                 '1' AS type,
                 0 AS currentPaymentAmount
             FROM
                 ticket_registration T1
                     LEFT JOIN purchase_ledger T2 ON T1.purchase_ledger_id = T2.id
             WHERE T2.supplier_id = #{supplierId}
             UNION
             SELECT
                 payment_date AS happenTime,
                 0 AS invoiceAmount,
                 '0' AS type,
                 current_payment_amount AS currentPaymentAmount
             FROM payment_registration
             WHERE supplier_id = #{supplierId}
        ) T1
        ORDER BY T1.happenTime ASC
 
    </select>
 
    <select id="paymentHistoryListPage" resultType="com.ruoyi.purchase.dto.PaymentRegistrationDto">
        SELECT
        T1.payment_date,
        T2.supplier_name,
        T1.current_payment_amount,
        T1.payment_method,
        T3.nick_name AS registrant,
        T1.registrationt_date
        FROM
        payment_registration T1
        LEFT JOIN
        supplier_manage T2 ON T1.supplier_id = T2.id
        LEFT JOIN
        sys_user T3 ON T3.user_id = T1.registrant_id
        <where>
            <if test="params.searchText != null and params.searchText != '' ">
                AND T2.supplier_name LIKE CONCAT('%',#{params.searchText},'%')
            </if>
        </where>
        ORDER BY T1.payment_date,T1.create_time DESC
    </select>
 
</mapper>