Merge branch 'xzj' of gitee.com:darlk/ShengTangManage into develop
This commit is contained in:
@ -202,9 +202,37 @@
|
||||
where phone = #{phone} and del_flag = 0
|
||||
</select>
|
||||
|
||||
<resultMap type="SysCustomer" id="SysCustomerResultExtended">
|
||||
<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"/>
|
||||
<result property="onSaleId" column="on_sale_id" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 根据openId查询客户 -->
|
||||
<select id="getCustomerByOpenId" parameterType="String" resultMap="SysCustomerResult">
|
||||
select sc.id from sys_customer sc
|
||||
<select id="getCustomerByOpenId" parameterType="String" resultMap="SysCustomerResultExtended">
|
||||
select sc.id, sc.name, sc.phone, sc.main_dietitian, sc.assistant_dietitian, sc.after_dietitian, sc.salesman, sc.on_sale_id
|
||||
from sys_customer sc
|
||||
left join sys_wx_user_info wu on wu.phone = sc.phone
|
||||
where wu.openid = #{openid} and sc.del_flag = 0 order by sc.id desc limit 1
|
||||
</select>
|
||||
|
@ -141,4 +141,77 @@
|
||||
and smn.message_type = #{messageType}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据客户ID查询打卡点评消息(包含点评营养师信息、客户信息、点评内容) -->
|
||||
<select id="getPunchCommentMessageByCusId" parameterType="Long" resultType="Map">
|
||||
select
|
||||
message.id,message.message_type as messageType, message.message_content as content, message.read_type as readType,
|
||||
DATE_FORMAT(message.create_time,'%Y-%m-%d %H:%i') as createTime, log.id as punchId, log.health_manifesto as healthManifesto,info.nick_name cusNickName,info.avatar_url as cusAvatar,diet.nick_name as dietNickName,diet.avatar as dietAvatar
|
||||
from (
|
||||
select id,message_customer,message_type,message_title,message_content,message_key,read_type,create_time from sys_message_notice
|
||||
where del_flag = 0 and message_property = 1 and message_customer = #{cusId}
|
||||
and message_type = 1
|
||||
) message
|
||||
left join sys_wx_user_log log on log.id = message.message_key and log.del_flag = 0
|
||||
left join sys_wx_user_info info on info.openid = log.openid
|
||||
left join sys_customer cus on cus.del_flag = 0 and cus.id = message.message_customer
|
||||
left join sys_user diet on diet.user_id = cus.main_dietitian and diet.del_flag = 0 and diet.status = 0
|
||||
order by message.id desc
|
||||
</select>
|
||||
|
||||
<!-- 根据用户查询打卡点评的未读消息 -->
|
||||
<select id="getUnReadPunchMessageNum" parameterType="Long" resultType="int">
|
||||
select count(id) from sys_message_notice
|
||||
where del_flag = 0 and message_property = 1
|
||||
and message_type = 1 and read_type = 0 and message_customer = #{cusId}
|
||||
</select>
|
||||
|
||||
<!-- 根据打卡ID、点赞openid查询点赞消息 -->
|
||||
<select id="getMessageByPunchIdAndOpenId" resultMap="SysMessageNoticeResult">
|
||||
select * from sys_message_notice where message_property = 1 and del_flag = 0 and message_type = 2
|
||||
and message_key = #{punchId} and message_content = #{openid} order by id desc limit 1
|
||||
</select>
|
||||
|
||||
<!-- 根据客户ID查询点赞消息 -->
|
||||
<select id="getPunchDynamicThumbsUpMessage" parameterType="Long" resultType="Map">
|
||||
select message.id,message.read_type as readType, message.message_type as messageType,DATE_FORMAT(message.create_time,'%Y-%m-%d %H:%i') as createTime, log.id as punchId, log.health_manifesto as healthManifesto,
|
||||
thumbsUpUser.nick_name as thumbsUpUserNickName,thumbsUpUser.avatar_url as thumbsUpUserAvatar, punchUser.nick_name as cusNickName, punchUser.avatar_url as cusAvatarUrl
|
||||
from
|
||||
(
|
||||
select id,message_customer,message_type,message_title,message_content,message_key,read_type,create_time from sys_message_notice
|
||||
where del_flag = 0 and message_property = 1 and message_customer = #{cusId}
|
||||
and message_type = 2
|
||||
) message
|
||||
left join sys_wx_user_info as thumbsUpUser on thumbsUpUser.openid = message.message_content
|
||||
left join sys_wx_user_log as log on log.id = message.message_key and log.del_flag = 0
|
||||
left join sys_wx_user_info as punchUser on punchUser.openid = log.openid
|
||||
order by message.id desc
|
||||
</select>
|
||||
|
||||
<!-- 查询点赞未读消息数量 -->
|
||||
<select id="getUnReadThumbsUpMessageNum" parameterType="Long" resultType="int">
|
||||
select count(id) from sys_message_notice
|
||||
where del_flag = 0 and message_property = 1 and read_type = 0 and message_type = 2 and message_customer = #{cusId}
|
||||
</select>
|
||||
|
||||
<!-- 查询消息是否存在 -->
|
||||
<select id="getMessageByCusIdAndTypeKey" parameterType="SysMessageNotice" resultMap="SysMessageNoticeResult">
|
||||
select * from sys_message_notice where del_flag = 0 and message_customer = #{messageCustomer}
|
||||
and message_type = #{messageType} and message_key= #{messageKey} order by id desc limit 1
|
||||
</select>
|
||||
|
||||
<!-- 查询服务消息(包含食谱更新消息、意见反馈回复消息) -->
|
||||
<select id="getServiceMessage" parameterType="Long" resultType="Map">
|
||||
select id, message_content as content, message_key as messageKey,
|
||||
read_type as readType, message_type as messageType, DATE_FORMAT(create_time,'%Y-%m-%d %H:%i') as createTime from sys_message_notice
|
||||
where del_flag = 0 and message_property = 1 and message_customer = #{cusId}
|
||||
and (message_type = 3 or message_type = 4)
|
||||
order by id desc
|
||||
</select>
|
||||
|
||||
<!-- 查询未读服务消息数量 -->
|
||||
<select id="getUnReadServiceMessageNum" parameterType="Long" resultType="int">
|
||||
select count(id) from sys_message_notice
|
||||
where del_flag = 0 and message_property = 1 and read_type = 0 and (message_type = 3 || message_type = 4) and message_customer = #{cusId}
|
||||
</select>
|
||||
</mapper>
|
@ -10,6 +10,7 @@
|
||||
<result property="planId" column="plan_id"/>
|
||||
<result property="nutritionistId" column="nutritionist_id"/>
|
||||
<result property="nutriAssisId" column="nutri_assis_id"/>
|
||||
<result property="keyWord" column="key_word" />
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
@ -23,7 +24,7 @@
|
||||
</resultMap>
|
||||
|
||||
<select id="selectRecipesTemplateListByCondition" parameterType="SysRecipesTemplate" resultMap="SysRecipesTemplateResult">
|
||||
select srt.id, srt.name, srt.nutritionist_id, srt.nutri_assis_id, srt.remark, srt.update_time,
|
||||
select srt.id, srt.name, srt.nutritionist_id, srt.nutri_assis_id, srt.key_word, srt.remark, srt.update_time,
|
||||
srt.create_time, srt.update_by, srt.create_by, srt.plan_id, srp.recipes_id, srp.review_status,
|
||||
su_nutritionist.nick_name as nutritionist, su_nutritionist_assis.nick_name as nutritionist_assis
|
||||
from sys_recipes_template srt
|
||||
@ -31,19 +32,31 @@
|
||||
left join sys_user su_nutritionist on su_nutritionist.user_id = srt.nutritionist_id and su_nutritionist.del_flag = 0
|
||||
left join sys_user su_nutritionist_assis on su_nutritionist_assis.user_id = srt.nutri_assis_id and su_nutritionist_assis.del_flag = 0
|
||||
where srt.del_flag = 0
|
||||
<if test="keys != null">and
|
||||
<if test="keys != null and keys.length > 0">and
|
||||
<foreach collection="keys" item="key" separator="and" open="(" close=")">
|
||||
srt.name like concat('%', #{key}, '%') or srt.remark like concat('%', #{key}, '%')
|
||||
(
|
||||
srt.name like concat('%', #{key}, '%') or srt.remark like concat('%', #{key}, '%')
|
||||
or FIND_IN_SET(#{key}, srt.key_word)
|
||||
)
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="nutriAssisId != null ">and srt.nutri_assis_id = #{nutriAssisId}</if>
|
||||
<if test="nutritionistId != null ">and srt.nutritionist_id = #{nutritionistId}</if>
|
||||
<if test="reviewStatus != null ">and srp.review_status = #{reviewStatus}</if>
|
||||
order by srt.id desc
|
||||
order by
|
||||
<if test="keys != null and keys.length > 0">
|
||||
FIND_IN_SET(srt.id, (
|
||||
SELECT group_concat(t.id Separator ',') from sys_recipes_template t WHERE
|
||||
<foreach collection="keys" item="key" separator="and" open="(" close=")">
|
||||
FIND_IN_SET(#{key}, srt.key_word)
|
||||
</foreach>
|
||||
)) desc,
|
||||
</if>
|
||||
srt.id desc
|
||||
</select>
|
||||
|
||||
<select id="getRecipesTemplateById" parameterType="Long" resultType="SysRecipesTemplate">
|
||||
select srt.id, srt.name, srt.nutritionist_id as nutritionistId, srt.nutri_assis_id as nutriAssisId, srt.remark, srt.update_time as updateTime,
|
||||
select srt.id, srt.name, srt.nutritionist_id as nutritionistId, srt.nutri_assis_id as nutriAssisId, srt.key_word, srt.remark, srt.update_time as updateTime,
|
||||
srt.create_time as createTime, srt.update_by as updateBy, srt.create_by as createBy, srt.plan_id as planId,
|
||||
su_nutritionist.nick_name as nutritionist, su_nutritionist_assis.nick_name as nutriAssis
|
||||
from sys_recipes_template srt
|
||||
@ -59,6 +72,7 @@
|
||||
<if test="planId != null">plan_id,</if>
|
||||
<if test="nutriAssisId != null">nutri_assis_id,</if>
|
||||
<if test="nutritionistId != null">nutritionist_id,</if>
|
||||
<if test="keyWord != null">key_word,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
@ -70,6 +84,7 @@
|
||||
<if test="planId != null">#{planId},</if>
|
||||
<if test="nutriAssisId != null">#{nutriAssisId},</if>
|
||||
<if test="nutritionistId != null">#{nutritionistId},</if>
|
||||
<if test="keyWord != null">#{keyWord},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
@ -84,6 +99,7 @@
|
||||
<if test="name != null">name = #{name},</if>
|
||||
<if test="nutriAssisId != null">nutri_assis_id = #{nutriAssisId},</if>
|
||||
<if test="nutritionistId != null">nutritionist_id = #{nutritionistId},</if>
|
||||
<if test="keyWord != null">key_word = #{keyWord},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
|
@ -325,4 +325,19 @@
|
||||
<select id="getServicesTopicNum" parameterType="Long" resultType="int">
|
||||
select count(1) from sys_services_topic where del_flag = 0 and uid = #{cusId}
|
||||
</select>
|
||||
|
||||
<!-- 根据topicId查询内容 -->
|
||||
<select id="getTopicContentByTopicId" resultType="String" parameterType="String">
|
||||
select content from sys_services_topic where topic_id = #{topicId} limit 1
|
||||
</select>
|
||||
|
||||
<!-- 根据CommentId查询评论内容 -->
|
||||
<select id="getCommentContentByCommentId" resultType="String" parameterType="String">
|
||||
select content from sys_services_topic_comment where id = #{commentId} limit 1
|
||||
</select>
|
||||
|
||||
<!-- 根据replyId查询回复内容 -->
|
||||
<select id="getReplyContentByReplyId" resultType="String" parameterType="String">
|
||||
select content from sys_services_topic_reply where id = #{replyId} limit 1
|
||||
</select>
|
||||
</mapper>
|
@ -465,5 +465,35 @@
|
||||
select count(wxlog.openid) from sys_wx_user_log wxlog where wxlog.del_flag = 0 and to_days(log_time) = to_days(now())
|
||||
</select>
|
||||
|
||||
<!-- 根据日期查询该日期中未打卡客户(根据食谱计划判断今日是否需要打卡) -->
|
||||
<select id="selectNotPunchCustomerByDate" parameterType="SysCustomer" resultType="SysCustomer">
|
||||
select plan.cus_id as id, cus.name, cus.main_dietitian as mainDietitian, cus.assistant_dietitian as assistantDietitian,cus.after_dietitian as afterDietitian from
|
||||
|
||||
(
|
||||
select DISTINCT cus_id from sys_recipes_plan where end_date >= DATE_FORMAT(#{startDate},'%Y-%m-%d') and DATE_FORMAT(#{startDate},'%Y-%m-%d') >= start_date and del_flag = 0 and instr(pause_date, DATE_FORMAT(#{startDate},'%Y%m%d')) = 0
|
||||
) as plan
|
||||
|
||||
left join sys_customer cus on cus.id = plan.cus_id and cus.del_flag = 0
|
||||
|
||||
where plan.cus_id not in
|
||||
|
||||
(
|
||||
select info.cus_id from sys_wx_user_log log left join sys_wx_user_info info on info.openid = log.openid
|
||||
where log.del_flag = 0 and DATE_FORMAT(log.log_time,'%Y-%m-%d') = DATE_FORMAT(#{startDate},'%Y-%m-%d')
|
||||
)
|
||||
|
||||
<if test="mainDietitian != null">
|
||||
and cus.main_dietitian = #{mainDietitian}
|
||||
</if>
|
||||
<if test="assistantDietitian != null">
|
||||
and cus.assistant_dietitian = #{assistantDietitian}
|
||||
</if>
|
||||
<if test="afterDietitian != null">
|
||||
and cus.after_dietitian = #{afterDietitian}
|
||||
</if>
|
||||
|
||||
order by plan.cus_id desc
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user