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
<?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="cn.iocoder.yudao.module.wealth.dal.mysql.commissionPayment.CommissionPaymentMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="getCommissionPaymentPage" resultType="cn.iocoder.yudao.module.wealth.vo.commissionPayment.CommissionPaymentBackVO">
select cp.*
from ecw_commission_payment cp
left join ecw_customer c
on c.id = cp.customer_id
where cp.deleted = 0
<if test="query.state != null">
AND cp.state = #{query.state}
</if>
<if test="query.invoiceStatus != null">
AND cp.invoice_status = #{query.invoiceStatus}
</if>
<if test="query.invoiceNumber != null and query.invoiceNumber != ''">
AND cp.invoice_number LIKE concat('%',#{query.invoiceNumber},'%')
</if>
<if test="query.accountNumber != null and query.accountNumber != ''">
AND cp.account_number LIKE concat('%',#{query.accountNumber},'%')
</if>
<if test="query.customerId != null">
AND cp.customer_id = #{query.customerId}
</if>
<if test="query.customerName != null and query.customerName != ''">
AND cp.customer_name LIKE concat('%',#{query.customerName},'%')
</if>
<if test="query.salesmanId != null">
AND (cp.`salesman_id` = #{query.salesmanId} or cp.`customer_id` in(select cus.id from ecw_customer cus where cus.is_customer_service_confirmed = 1 and cus.customer_service = #{query.salesmanId} ))
</if>
<if test="query.salesmanName != null and query.salesmanName != ''">
AND cp.salesman_name LIKE concat('%',#{query.salesmanName},'%')
</if>
<if test="query.departmentId != null">
AND cp.department_id = #{query.departmentId}
</if>
<if test="query.departmentName != null and query.departmentName != ''">
AND cp.department_name LIKE concat('%',#{query.departmentName},'%')
</if>
<if test="query.paymentNo != null and query.paymentNo !=''">
AND cp.payment_no LIKE concat('%',#{query.paymentNo},'%')
</if>
<if test = "query.beginCreateTime != null and query.endCreateTime != null ">
AND cp.`create_time` between #{query.beginCreateTime} and #{query.endCreateTime}
</if>
<if test="query.ids != null ">
AND cp.id in
<foreach item="id" index="1" collection="query.ids" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="query.searchKey != null and query.searchKey !=''">
AND (
c.name LIKE concat('%',#{query.searchKey},'%')
or c.number LIKE concat('%',#{query.searchKey},'%')
or c.new_phone LIKE concat('%',#{query.searchKey},'%')
)
</if>
</select>
<select id="getCommissionPaymentList" resultType="cn.iocoder.yudao.module.wealth.vo.commissionPayment.CommissionPaymentBackVO">
select cp.*
from ecw_commission_payment cp
left join ecw_customer c
on c.id = cp.customer_id
where cp.deleted = 0
<if test="query.state != null">
AND cp.state = #{query.state}
</if>
<if test="query.invoiceStatus != null">
AND cp.invoice_status = #{query.invoiceStatus}
</if>
<if test="query.invoiceNumber != null and query.invoiceNumber != ''">
AND cp.invoice_number LIKE concat('%',#{query.invoiceNumber},'%')
</if>
<if test="query.accountNumber != null and query.accountNumber != ''">
AND cp.account_number LIKE concat('%',#{query.accountNumber},'%')
</if>
<if test="query.customerId != null">
AND cp.customer_id = #{query.customerId}
</if>
<if test="query.customerName != null and query.customerName != ''">
AND cp.customer_name LIKE concat('%',#{query.customerName},'%')
</if>
<if test="query.salesmanId != null">
AND (cp.`salesman_id` = #{query.salesmanId} or cp.`customer_id` in(select cus.id from ecw_customer cus where cus.is_customer_service_confirmed = 1 and cus.customer_service = #{query.salesmanId} ))
</if>
<if test="query.salesmanName != null and query.salesmanName != ''">
AND cp.salesman_name LIKE concat('%',#{query.salesmanName},'%')
</if>
<if test="query.departmentId != null">
AND cp.department_id = #{query.departmentId}
</if>
<if test="query.departmentName != null and query.departmentName != ''">
AND cp.department_name LIKE concat('%',#{query.departmentName},'%')
</if>
<if test="query.paymentNo != null and query.paymentNo !=''">
AND cp.payment_no LIKE concat('%',#{query.paymentNo},'%')
</if>
<if test="query.ids != null ">
AND cp.id in
<foreach item="id" index="1" collection="query.ids" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="query.searchKey != null and query.searchKey !=''">
AND (
c.name LIKE concat('%',#{query.searchKey},'%')
or c.number LIKE concat('%',#{query.searchKey},'%')
or c.new_phone LIKE concat('%',#{query.searchKey},'%')
)
</if>
</select>
<select id="info" resultType="cn.iocoder.yudao.module.wealth.vo.commissionPayment.CommissionPaymentBackVO">
select
cp.*
from ecw_commission_payment cp
where
cp.id = #{id}
</select>
</mapper>