陶杰
2024-08-22 ee9032d9baf5f33e376d2d2699136e0a7b26bec7
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
<?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.customer.CustomerMapper">
    <update id="bindPartner">
        update t_customer_info set partner_id = #{partnerId} , partner_user_id = #{userId} where id = #{id}
    </update>
    <select id="queryCustomer" resultType="com.mzl.flower.dto.response.customer.CustomerDTO">
        SELECT
            c.*,
            p.name as partnerName,
            u.nick_name,
            u.tel
        FROM
            t_customer_info c
                LEFT JOIN t_user u ON c.user_id = u.id left join t_partner_info p on c.partner_id = p.id where c.deleted = 0
        <if test="dto.id != null">
            and c.id = #{dto.id}
        </if>
        <if test="dto.partnerId != null">
            and c.partner_id = #{dto.partnerId}
        </if>
        <if test="dto.name != null and dto.name != ''">
            and c.name like concat('%', #{dto.name}, '%')
        </if>
        <if test="dto.nickName != null and dto.nickName != ''">
            and u.nick_name like concat('%', #{dto.nickName}, '%')
        </if>
        <if test="dto.tel != null and dto.tel != ''">
            and u.tel like concat('%', #{dto.tel}, '%')
        </if>
        <if test="dto.province != null and dto.province != ''">
            and c.province = #{dto.province}
        </if>
        <if test="dto.city != null and dto.city != ''">
            and c.city = #{dto.city}
        </if>
        <if test="dto.region != null and dto.region != ''">
            and c.region = #{dto.region}
        </if>
        <if test="dto.partnerUserId != null and dto.partnerUserId != ''">
            and c.partner_user_id = #{dto.partnerUserId}
        </if>
        order by c.create_time desc
    </select>
    <select id="getCurrentCustomer" resultType="com.mzl.flower.dto.response.customer.CustomerDTO"
            parameterType="java.lang.String">
        select * from t_customer_info where user_id = #{userId} and deleted = 0
    </select>
</mapper>