@ -5,38 +5,50 @@
|
||||
<mapper namespace="com.stdiet.custom.mapper.SysCustomerMapper">
|
||||
|
||||
<resultMap type="SysCustomer" id="SysCustomerResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="phone" column="phone" />
|
||||
<result property="email" column="email" />
|
||||
<result property="address" column="address" />
|
||||
<result property="payDate" column="pay_date" />
|
||||
<result property="startDate" column="start_date" />
|
||||
<result property="fansTime" column="fans_time" />
|
||||
<result property="fansChannel" column="fans_channel" />
|
||||
<result property="purchaseNum" column="purchase_num" />
|
||||
<result property="payTotal" column="pay_total" />
|
||||
<result property="mainDietitian" column="main_dietitian" />
|
||||
<result property="assistantDietitian" column="assistant_dietitian" />
|
||||
<result property="afterDietitian" column="after_dietitian" />
|
||||
<result property="salesman" column="salesman" />
|
||||
<result property="chargePerson" column="charge_person" />
|
||||
<result property="followStatus" column="follow_status" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="channelId" column="channel_id" />
|
||||
<result property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="phone" column="phone"/>
|
||||
<result property="email" column="email"/>
|
||||
<result property="address" column="address"/>
|
||||
<result property="payDate" column="pay_date"/>
|
||||
<result property="startDate" column="start_date"/>
|
||||
<result property="fansTime" column="fans_time"/>
|
||||
<result property="fansChannel" column="fans_channel"/>
|
||||
<result property="purchaseNum" column="purchase_num"/>
|
||||
<result property="payTotal" column="pay_total"/>
|
||||
<result property="chargePerson" column="charge_person"/>
|
||||
<result property="followStatus" column="follow_status"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="channelId" column="channel_id"/>
|
||||
|
||||
<result property="mainDietitian" column="main_dietitian"/>
|
||||
<result property="assistantDietitian" column="assistant_dietitian"/>
|
||||
<result property="afterDietitian" column="after_dietitian"/>
|
||||
<result property="salesman" column="salesman"/>
|
||||
|
||||
<association property="dietitianName" column="{id=main_dietitian}" select="selectUserName"/>
|
||||
<association property="assDietitianName" column="{id=assistant_dietitian}" select="selectUserName"/>
|
||||
<association property="afterDietitianName" column="{id=after_dietitian}" select="selectUserName"/>
|
||||
<association property="salesName" column="{id=salesman}" select="selectUserName"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectUserName" parameterType="java.util.Map" resultType="String">
|
||||
select nick_name from sys_user where user_id = #{id}
|
||||
</select>
|
||||
|
||||
<sql id="selectSysCustomerVo">
|
||||
select id, name, phone, email, fans_time, fans_channel, address, pay_date, start_date, purchase_num, pay_total, main_dietitian, assistant_dietitian, after_dietitian, salesman, charge_person, follow_status, create_time, create_by, update_time, update_by, channel_id from sys_customer
|
||||
</sql>
|
||||
|
||||
<select id="selectSysCustomerList" parameterType="SysCustomer" resultMap="SysCustomerResult">
|
||||
select
|
||||
sc.id, sc.name, sc.phone, sc.email, sc.fans_time, sc.fans_channel, sc.address, sc.pay_date, sc.start_date, sc.purchase_num, sc.pay_total, sc.main_dietitian,
|
||||
sc.assistant_dietitian, sc.after_dietitian, sc.salesman, sc.charge_person, sc.follow_status, sc.create_time,sc.channel_id
|
||||
sc.id, sc.name, sc.phone, sc.email, sc.fans_time, sc.fans_channel, sc.address, sc.pay_date, sc.start_date,
|
||||
sc.purchase_num, sc.pay_total, sc.main_dietitian,
|
||||
sc.assistant_dietitian, sc.after_dietitian, sc.salesman, sc.charge_person, sc.follow_status,
|
||||
sc.create_time,sc.channel_id
|
||||
from sys_customer sc
|
||||
left join sys_customer_healthy as sch
|
||||
on sch.customer_id = sc.id and sch.del_flag = 0
|
||||
@ -44,16 +56,18 @@
|
||||
<if test="name != null and name != ''">
|
||||
and (sc.name like concat('%', #{name}, '%') or sc.phone like concat('%', #{name}, '%'))
|
||||
</if>
|
||||
<if test="mainDietitian != null and mainDietitian != ''"> and sc.main_dietitian = #{mainDietitian}</if>
|
||||
<if test="mainDietitian == 0"> and (isnull(sc.main_dietitian) or sc.main_dietitian=0)</if>
|
||||
<if test="salesman != null and salesman != ''"> and sc.salesman = #{salesman}</if>
|
||||
<if test="salesman == 0"> and (isnull(sc.salesman) or sc.salesman=0)</if>
|
||||
<if test="afterDietitian != null and afterDietitian != ''"> and sc.after_dietitian = #{afterDietitian}</if>
|
||||
<if test="afterDietitian == 0"> and (isnull(sc.after_dietitian) or sc.after_dietitian=0)</if>
|
||||
<if test="assistantDietitian != null and assistantDietitian != ''"> and sc.assistant_dietitian = #{assistantDietitian}</if>
|
||||
<if test="assistantDietitian == 0"> and (isnull(sc.assistant_dietitian) or sc.assistant_dietitian=0)</if>
|
||||
<if test="fansChannel != null "> and sc.fans_channel = #{fansChannel}</if>
|
||||
<if test="channelId != null "> and sc.channel_id = #{channelId}</if>
|
||||
<if test="mainDietitian != null and mainDietitian != ''">and sc.main_dietitian = #{mainDietitian}</if>
|
||||
<if test="mainDietitian == 0">and (isnull(sc.main_dietitian) or sc.main_dietitian=0)</if>
|
||||
<if test="salesman != null and salesman != ''">and sc.salesman = #{salesman}</if>
|
||||
<if test="salesman == 0">and (isnull(sc.salesman) or sc.salesman=0)</if>
|
||||
<if test="afterDietitian != null and afterDietitian != ''">and sc.after_dietitian = #{afterDietitian}</if>
|
||||
<if test="afterDietitian == 0">and (isnull(sc.after_dietitian) or sc.after_dietitian=0)</if>
|
||||
<if test="assistantDietitian != null and assistantDietitian != ''">and sc.assistant_dietitian =
|
||||
#{assistantDietitian}
|
||||
</if>
|
||||
<if test="assistantDietitian == 0">and (isnull(sc.assistant_dietitian) or sc.assistant_dietitian=0)</if>
|
||||
<if test="fansChannel != null ">and sc.fans_channel = #{fansChannel}</if>
|
||||
<if test="channelId != null ">and sc.channel_id = #{channelId}</if>
|
||||
<if test="channels != null">
|
||||
and sc.channel_id in
|
||||
<foreach collection="channels" item="cn" separator="," open="(" close=")">
|
||||
|
@ -16,8 +16,57 @@
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<association column="{uid=uid,role=role}" property="name" select="selectUserInfo"/>
|
||||
<association property="avatar" column="{uid=uid,role=role}" select="selectUserAvatar"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectCustomerListByUserIdAndRole" parameterType="SysServicesTopic" resultMap="SysServicesTopicResult">
|
||||
SELECT DISTINCT(uid)AS uid, MAX(update_time) AS update_time, MIN(create_time) AS create_time, MIN(`read`) AS
|
||||
`read`, role FROM (
|
||||
SELECT * FROM (
|
||||
SELECT topic_id, `read`, create_time, update_time, 'customer' AS role FROM sys_services_topic_status
|
||||
<choose>
|
||||
<when test="role == 'admin' or role == 'manager' or role == 'admin-dev'">
|
||||
WHERE role = 'dietician'
|
||||
</when>
|
||||
<otherwise>
|
||||
WHERE role = #{role} AND uid = #{uid}
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
) AS status
|
||||
LEFT JOIN (SELECT topic_id, uid, del_flag FROM sys_services_topic ) AS topic USING(topic_id)
|
||||
WHERE del_flag = 0
|
||||
ORDER BY `read` ASC, update_time DESC
|
||||
) AS userList GROUP BY uid
|
||||
</select>
|
||||
|
||||
<select id="selectTopicListByUid" parameterType="SysServicesTopic" resultMap="SysServicesTopicResult">
|
||||
SELECT * FROM(
|
||||
SELECT topic_id, topic_type, content, uid, img, 'customer' AS role FROM sys_services_topic
|
||||
WHERE uid = #{fromUid} AND del_flag = 0
|
||||
) AS topic
|
||||
LEFT JOIN (SELECT topic_id, create_time, update_time, `read`,
|
||||
<choose>
|
||||
<when test="role == 'admin' or role == 'manager' or role == 'admin-dev'">
|
||||
'0' AS id
|
||||
</when>
|
||||
<otherwise>
|
||||
id
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM sys_services_topic_status
|
||||
<choose>
|
||||
<when test="role == 'admin' or role == 'manager' or role == 'admin-dev'">
|
||||
WHERE role = 'dietician'
|
||||
</when>
|
||||
<otherwise>
|
||||
WHERE role = #{role} AND uid = #{uid}
|
||||
</otherwise>
|
||||
</choose>
|
||||
) AS state
|
||||
USING(topic_id)
|
||||
ORDER BY `read` ASC, update_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据userId和角色查询问题列表-->
|
||||
<select id="selectSysServicesTopicByUserIdAndRole" parameterType="SysServicesTopic"
|
||||
@ -36,8 +85,6 @@
|
||||
ORDER BY `read` ASC, update_time DESC
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 查询主题-->
|
||||
|
Reference in New Issue
Block a user