zhujie
2025-04-11 52358cd76aee8d5f7edc54e177b6eab0d1f58533
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
<?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>
    <update id="checkVipExpireTime">
        update t_customer_info c
        set c.is_member = 0,c.member_overtime = NULL
        where c.member_overtime &lt; now() and c.is_member = 1
    </update>
    <select id="queryCustomer" resultType="com.mzl.flower.dto.response.customer.CustomerDTO">
        SELECT
            c.*,
            p.name as partnerName,
            u.nick_name,
            u.tel,
            (select count(o.id) from t_order o where o.create_by = c.user_id  and o.deleted=0 and o.status_backend not in ('PENDING','CANCEL','REFUND')) as orderNum
        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>
        <if test="dto.isEnabled!=null">
            AND c.is_enabled = #{dto.isEnabled}
        </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>