Pu Zhibing
3 天以前 3244b550596e0330031b3f4547356927df83b0ad
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
<?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.order.mapper.TOrderInvoiceMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.order.api.model.TOrderInvoice">
        <id column="id" property="id" />
        <result column="code" property="code" />
        <result column="app_user_id" property="appUserId" />
        <result column="order_type" property="orderType" />
        <result column="invoicing_company" property="invoicingCompany" />
        <result column="invoice_type_id" property="invoiceTypeId"/>
        <result column="invoice_type" property="invoiceType" />
        <result column="invoice_material" property="invoiceMaterial" />
        <result column="invoicing_method" property="invoicingMethod" />
        <result column="invoicing_object_type" property="invoicingObjectType" />
        <result column="name" property="name" />
        <result column="tax_identification_number" property="taxIdentificationNumber" />
        <result column="company_address" property="companyAddress" />
        <result column="company_phone" property="companyPhone" />
        <result column="deposit_bank" property="depositBank" />
        <result column="bank_account" property="bankAccount" />
        <result column="total_amount" property="totalAmount" />
        <result column="invoice_url" property="invoiceUrl" />
        <result column="mailbox" property="mailbox" />
        <result column="status" property="status" />
        <result column="create_time" property="createTime" />
        <result column="billing_time" property="billingTime" />
        <result column="billing_user_id" property="billingUserId" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, code, app_user_id, order_type, invoicing_company, invoice_type_id, invoice_type, invoice_material, invoicing_method, invoicing_object_type, name, tax_identification_number, company_address, company_phone, deposit_bank, bank_account, total_amount, invoice_url, mailbox, status, create_time, billing_time, billing_user_id
    </sql>
    <select id="pageList" resultType="com.ruoyi.order.api.vo.TOrderInvoiceVO">
        select toi.id, toi.code, toi.app_user_id, toi.order_type, toi.invoicing_company, toi.invoice_type_id, toi.invoice_type, toi.invoice_material,
               toi.invoicing_method, toi.invoicing_object_type, toi.name, toi.tax_identification_number, toi.company_address, toi.company_phone,
               toi.deposit_bank, toi.bank_account, toi.total_amount, toi.invoice_url, toi.mailbox, toi.status, toi.create_time, toi.billing_time,
               toi.billing_user_id
        from t_order_invoice toi
        <where>
            <if test="query.invoicingCompany != null and query.invoicingCompany != ''">
                AND toi.invoicing_company LIKE concat('%',#{query.invoicingCompany},'%')
            </if>
            <if test="query.invoiceType != null and query.invoiceType != ''">
                AND toi.invoice_type LIKE concat('%',#{query.invoiceType},'%')
            </if>
            <if test="query.invoicingObjectType != null">
                AND toi.invoicing_object_type = #{query.invoicingObjectType}
            </if>
            <if test="query.status != null">
                AND toi.status = #{query.status}
            </if>
            <if test="query.invoiceMaterial != null">
                AND toi.invoice_material = #{query.invoiceMaterial}
            </if>
            <if test="query.invoicingMethod != null">
                AND toi.invoicing_method = #{query.invoicingMethod}
            </if>
            <if test="query.name != null and query.name != ''">
                AND toi.name LIKE concat('%',#{query.name},'%')
            </if>
            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
                AND toi.create_time BETWEEN #{query.startTime} AND #{query.endTime}
            </if>
            <if test="query.userIds != null and query.userIds.size()>0">
                AND toi.app_user_id IN
                <foreach collection="query.userIds" close=")" open="(" item="userId" separator=",">
                    #{userId}
                </foreach>
            </if>
        </where>
        ORDER BY toi.create_time DESC
    </select>
    <select id="statusCount" resultType="java.util.Map">
        select
            COUNT(CASE WHEN status = 1 THEN 1 END) AS `notAccepted`,
            COUNT(CASE WHEN status = 2 THEN 1 END) AS `processing`,
            COUNT(CASE WHEN status = 3 THEN 1 END) AS `finished`
        from t_order_invoice toi
        <where>
            <if test="query.invoicingCompany != null and query.invoicingCompany != ''">
                AND toi.invoicing_company LIKE concat('%',#{query.invoicingCompany},'%')
            </if>
            <if test="query.invoiceType != null and query.invoiceType != ''">
                AND toi.invoice_type LIKE concat('%',#{query.invoiceType},'%')
            </if>
            <if test="query.invoicingObjectType != null">
                AND toi.invoicing_object_type = #{query.invoicingObjectType}
            </if>
            <if test="query.invoiceMaterial != null">
                AND toi.invoice_material = #{query.invoiceMaterial}
            </if>
            <if test="query.invoicingMethod != null">
                AND toi.invoicing_method = #{query.invoicingMethod}
            </if>
            <if test="query.name != null and query.name != ''">
                AND toi.name LIKE concat('%',#{query.name},'%')
            </if>
            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
                AND toi.billing_time BETWEEN #{query.startTime} AND #{query.endTime}
            </if>
            <if test="query.userIds != null and query.userIds.size()>0">
                AND toi.app_user_id IN
                <foreach collection="query.userIds" close=")" open="(" item="userId" separator=",">
                    #{userId}
                </foreach>
            </if>
        </where>
    </select>
    <select id="export" resultType="com.ruoyi.order.api.vo.TOrderInvoiceVO">
        select toi.id, toi.code, toi.app_user_id, toi.order_type, toi.invoicing_company, toi.invoice_type_id, toi.invoice_type, toi.invoice_material,
        toi.invoicing_method, toi.invoicing_object_type, toi.name, toi.tax_identification_number, toi.company_address, toi.company_phone,
        toi.deposit_bank, toi.bank_account, toi.total_amount, toi.invoice_url, toi.mailbox, toi.status, toi.create_time, toi.billing_time,
        toi.billing_user_id
        from t_order_invoice toi
        <where>
            <if test="query.invoicingCompany != null and query.invoicingCompany != ''">
                AND toi.invoicing_company LIKE concat('%',#{query.invoicingCompany},'%')
            </if>
            <if test="query.invoiceType != null and query.invoiceType != ''">
                AND toi.invoice_type LIKE concat('%',#{query.invoiceType},'%')
            </if>
            <if test="query.invoicingObjectType != null">
                AND toi.invoicing_object_type = #{query.invoicingObjectType}
            </if>
            <if test="query.invoiceMaterial != null">
                AND toi.invoice_material = #{query.invoiceMaterial}
            </if>
            <if test="query.invoicingMethod != null">
                AND toi.invoicing_method = #{query.invoicingMethod}
            </if>
            <if test="query.name != null and query.name != ''">
                AND toi.name LIKE concat('%',#{query.name},'%')
            </if>
            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
                AND toi.billing_time BETWEEN #{query.startTime} AND #{query.endTime}
            </if>
            <if test="query.userIds != null and query.userIds.size()>0">
                AND toi.app_user_id IN
                <foreach collection="query.userIds" close=")" open="(" item="userId" separator=",">
                    #{userId}
                </foreach>
            </if>
        </where>
        ORDER BY toi.billing_time DESC
    </select>
 
</mapper>