liyong
2026-04-24 c1bbff15e4f64767d471de763613a54c9cb8d4b4
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
<?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.basic.mapper.CustomerPrivatePoolMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.basic.pojo.CustomerPrivatePool">
        <id column="id" property="id" />
        <result column="customer_id" property="customerId" />
        <result column="bound_id" property="boundId" />
        <result column="create_user" property="createUser" />
        <result column="update_user" property="updateUser" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
    </resultMap>
    <select id="listPage" resultType="com.ruoyi.basic.dto.CustomerPrivatePoolDto">
        select cpp.id,
        cpp.bound_id,
        cpp.type,
        coalesce(c.id, cp.id) as customer_id,
        coalesce(c.customer_name, cp.customer_name) as customer_name,
        coalesce(c.customer_type, cp.customer_type) as customer_type,
        coalesce(c.taxpayer_identification_number, cp.taxpayer_identification_number) as taxpayer_identification_number,
        coalesce(c.company_address, cp.company_address) as company_address,
        coalesce(c.company_phone, cp.company_phone) as company_phone,
        coalesce(c.contact_person, cp.contact_person) as contact_person,
        coalesce(c.contact_phone, cp.contact_phone) as contact_phone,
        coalesce(c.maintainer, cp.maintainer) as maintainer,
        coalesce(c.maintenance_time, cp.maintenance_time) as maintenance_time,
        coalesce(c.tenant_id, cp.tenant_id) as tenant_id,
        coalesce(c.basic_bank_account, cp.basic_bank_account) as basic_bank_account,
        coalesce(c.bank_account, cp.bank_account) as bank_account,
        coalesce(c.bank_code, cp.bank_code) as bank_code,
        coalesce(c.corporation, cp.corporation) as corporation,
        coalesce(c.fax, cp.fax) as fax,
        coalesce(c.agent, cp.agent) as agent,
        coalesce(c.bank_name, cp.bank_name) as bank_name
        from customer_private_pool cpp
        left join customer c on c.id = cpp.customer_id and cpp.type = 1
        left join customer_private cp on cp.id = cpp.customer_id and cpp.type = 0
        <where>
            cpp.delete_flag = 0
            <if test="c.customerName != null and c.customerName != ''">
                and (c.customer_name like concat('%', #{c.customerName}, '%') or cp.customer_name like concat('%', #{c.customerName}, '%'))
            </if>
            <if test="c.customerType != null">
                and c.customer_type = #{c.customerType}
            </if>
            <if test="c.boundId != null">
                and cpp.bound_id = #{c.boundId}
            </if>
        </where>
        order by cpp.id desc
    </select>
    <select id="selectInfo" resultType="com.ruoyi.basic.dto.CustomerPrivatePoolDto">
        select cpp.id,
               cpp.bound_id,
               cpp.type,
               coalesce(c.id, cp.id) as customer_id,
               coalesce(c.customer_name, cp.customer_name) as customer_name,
               coalesce(c.customer_type, cp.customer_type) as customer_type,
               coalesce(c.taxpayer_identification_number, cp.taxpayer_identification_number) as taxpayer_identification_number,
               coalesce(c.company_address, cp.company_address) as company_address,
               coalesce(c.company_phone, cp.company_phone) as company_phone,
               coalesce(c.contact_person, cp.contact_person) as contact_person,
               coalesce(c.contact_phone, cp.contact_phone) as contact_phone,
               coalesce(c.maintainer, cp.maintainer) as maintainer,
               coalesce(c.maintenance_time, cp.maintenance_time) as maintenance_time,
               coalesce(c.tenant_id, cp.tenant_id) as tenant_id,
               coalesce(c.basic_bank_account, cp.basic_bank_account) as basic_bank_account,
               coalesce(c.bank_account, cp.bank_account) as bank_account,
               coalesce(c.bank_code, cp.bank_code) as bank_code,
               coalesce(c.corporation, cp.corporation) as corporation,
               coalesce(c.fax, cp.fax) as fax,
               coalesce(c.agent, cp.agent) as agent,
               coalesce(c.bank_name, cp.bank_name) as bank_name
        from customer_private_pool cpp
                 left join customer c on c.id = cpp.customer_id and cpp.type = 1
                 left join customer_private cp on cp.id = cpp.customer_id and cpp.type = 0
        <where>
            <if test="id != null">
                and cpp.id = #{id}
            </if>
        </where>
    </select>
    <select id="selectInfos" resultType="com.ruoyi.basic.dto.CustomerPrivatePoolDto">
        select cpp.id,
               cpp.bound_id,
               cpp.type,
               coalesce(c.id, cp.id) as customer_id,
               coalesce(c.customer_name, cp.customer_name) as customer_name,
               coalesce(c.customer_type, cp.customer_type) as customer_type,
               coalesce(c.taxpayer_identification_number, cp.taxpayer_identification_number) as taxpayer_identification_number,
               coalesce(c.company_address, cp.company_address) as company_address,
               coalesce(c.company_phone, cp.company_phone) as company_phone,
               coalesce(c.contact_person, cp.contact_person) as contact_person,
               coalesce(c.contact_phone, cp.contact_phone) as contact_phone,
               coalesce(c.maintainer, cp.maintainer) as maintainer,
               coalesce(c.maintenance_time, cp.maintenance_time) as maintenance_time,
               coalesce(c.tenant_id, cp.tenant_id) as tenant_id,
               coalesce(c.basic_bank_account, cp.basic_bank_account) as basic_bank_account,
               coalesce(c.bank_account, cp.bank_account) as bank_account,
               coalesce(c.bank_code, cp.bank_code) as bank_code,
            coalesce(c.corporation, cp.corporation) as corporation,
               coalesce(c.fax, cp.fax) as fax,
               coalesce(c.agent, cp.agent) as agent,
               coalesce(c.bank_name, cp.bank_name) as bank_name
        from customer_private_pool cpp
            left join customer c on c.id = cpp.customer_id and cpp.type = 1
            left join customer_private cp on cp.id = cpp.customer_id and cpp.type = 0
    </select>
    <select id="selectByCusterNames" resultType="com.ruoyi.basic.dto.CustomerPrivatePoolDto">
        select cpp.id,
        cpp.bound_id,
        cpp.type,
        coalesce(c.id, cp.id) as customer_id,
        coalesce(c.customer_name, cp.customer_name) as customer_name,
        coalesce(c.customer_type, cp.customer_type) as customer_type,
        coalesce(c.taxpayer_identification_number, cp.taxpayer_identification_number) as taxpayer_identification_number,
        coalesce(c.company_address, cp.company_address) as company_address,
        coalesce(c.company_phone, cp.company_phone) as company_phone,
        coalesce(c.contact_person, cp.contact_person) as contact_person,
        coalesce(c.contact_phone, cp.contact_phone) as contact_phone,
        coalesce(c.maintainer, cp.maintainer) as maintainer,
        coalesce(c.maintenance_time, cp.maintenance_time) as maintenance_time,
        coalesce(c.tenant_id, cp.tenant_id) as tenant_id,
        coalesce(c.basic_bank_account, cp.basic_bank_account) as basic_bank_account,
        coalesce(c.bank_account, cp.bank_account) as bank_account,
        coalesce(c.bank_code, cp.bank_code) as bank_code,
        coalesce(c.corporation, cp.corporation) as corporation,
        coalesce(c.fax, cp.fax) as fax,
        coalesce(c.agent, cp.agent) as agent,
        coalesce(c.bank_name, cp.bank_name) as bank_name
        from customer_private_pool cpp
        left join customer c on c.id = cpp.customer_id and cpp.type = 1
        left join customer_private cp on cp.id = cpp.customer_id and cpp.type = 0
        where c.customer_name in
        <foreach item="item" collection="collect" separator="," open="(" close=")">
            #{item}
        </foreach> or cp.customer_name in
        <foreach item="item" collection="collect" separator="," open="(" close=")">
            #{item}
        </foreach>
    </select>
 
</mapper>