<?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,
|
(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>
|