499 lines
28 KiB
XML
499 lines
28 KiB
XML
<?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.stdiet.custom.mapper.SysWxUserLogMapper">
|
||
|
||
<resultMap type="SysWxUserLog" id="SysWxUserLogResult">
|
||
<result property="id" column="id"/>
|
||
<result property="openid" column="openid"/>
|
||
<result property="weight" column="weight"/>
|
||
<result property="appid" column="appid"/>
|
||
<result property="phone" column="phone"/>
|
||
<result property="phone" column="phone"/>
|
||
<result property="logTime" column="log_time"/>
|
||
<result property="wakeupTime" column="wakeup_time"/>
|
||
<result property="sleepTime" column="sleep_time"/>
|
||
<result property="sport" column="sport"/>
|
||
<result property="sportDesc" column="sport_desc"/>
|
||
<result property="avatarUrl" column="avatar_url"/>
|
||
<result property="diet" column="diet"/>
|
||
<result property="dietDesc" column="diet_desc"/>
|
||
<result property="insomnia" column="insomnia"/>
|
||
<result property="defecation" column="defecation"/>
|
||
<result property="defecationDesc" column="defecation_desc"/>
|
||
<result property="water" column="water"/>
|
||
<result property="createBy" column="create_by"/>
|
||
<result property="createTime" column="create_time"/>
|
||
<result property="updateBy" column="update_by"/>
|
||
<result property="updateTime" column="update_time"/>
|
||
<result property="remark" column="remark"/>
|
||
<result property="emotion" column="emotion"/>
|
||
<result property="emotionDesc" column="emotion_desc"/>
|
||
<result property="slyEatFood" column="sly_eat_food"/>
|
||
<result property="constipation" column="constipation"/>
|
||
<result property="ingredientDesc" column="ingredient_desc"/>
|
||
<result property="breakfastImages" column="breakfast_images"/>
|
||
<result property="lunchImages" column="lunch_images"/>
|
||
<result property="dinnerImages" column="dinner_images"/>
|
||
<result property="extraMealImages" column="extra_meal_images"/>
|
||
<result property="bodyImages" column="body_images"/>
|
||
<result property="bodyDesc" column="body_desc"/>
|
||
<result property="suggest" column="suggest"/>
|
||
<result property="targetWeight" column="target_weight"/>
|
||
<result property="executionScore" column="execution_score"/>
|
||
<result property="comment" column="comment"/>
|
||
<result property="thumbsupNum" column="thumbsup_num"/>
|
||
<result property="healthManifesto" column="health_manifesto"/>
|
||
<result property="delFlag" column="del_flag"/>
|
||
<result property="menstrualPeriod" column="menstrual_period"/>
|
||
<!-- 非持久字段 -->
|
||
<result property="customerName" column="customer_name"/>
|
||
<!-- 营养师 -->
|
||
<result property="nutritionist" column="nutritionist"/>
|
||
<result property="afterNutritionist" column="after_nutritionist"/>
|
||
</resultMap>
|
||
|
||
<resultMap type="com.stdiet.custom.page.WxLogInfo" id="WxLogInfo">
|
||
<result property="id" column="id"/>
|
||
<result property="weight" column="weight"/>
|
||
<result property="sleepTime" column="sleep_time"/>
|
||
<result property="wakeupTime" column="wakeup_time"/>
|
||
<result property="sport" column="sport"/>
|
||
<result property="sportDesc" column="sport_desc"/>
|
||
<result property="diet" column="diet"/>
|
||
<result property="dietDesc" column="diet_desc"/>
|
||
<result property="insomnia" column="insomnia"/>
|
||
<result property="defecation" column="defecation"/>
|
||
<result property="defecationDesc" column="defecation_desc"/>
|
||
<result property="water" column="water"/>
|
||
<result property="date" column="log_time"/>
|
||
<result property="emotion" column="emotion"/>
|
||
<result property="emotionDesc" column="emotion_desc"/>
|
||
<result property="slyEatFood" column="sly_eat_food"/>
|
||
<result property="constipation" column="constipation"/>
|
||
<result property="remark" column="remark"/>
|
||
<result property="ingredientDesc" column="ingredient_desc"/>
|
||
<!-- <result property="breakfastImages" column="breakfast_images"/>-->
|
||
<result property="breakfastImagesUrl" column="breakfast_images"
|
||
typeHandler="com.stdiet.custom.typehandler.ImagesHandler"/>
|
||
<!-- <result property="lunchImages" column="lunch_images"/>-->
|
||
<result property="lunchImagesUrl" column="lunch_images"
|
||
typeHandler="com.stdiet.custom.typehandler.ImagesHandler"/>
|
||
<!-- <result property="dinnerImages" column="dinner_images"/>-->
|
||
<result property="dinnerImagesUrl" column="dinner_images"
|
||
typeHandler="com.stdiet.custom.typehandler.ImagesHandler"/>
|
||
<!-- <result property="extraMealImages" column="extra_meal_images"/>-->
|
||
<result property="extraMealImagesUrl" column="extra_meal_images"
|
||
typeHandler="com.stdiet.custom.typehandler.ImagesHandler"/>
|
||
<!-- <result property="bodyImages" column="body_images"/>-->
|
||
<result property="bodyImagesUrl" column="body_images"
|
||
typeHandler="com.stdiet.custom.typehandler.ImagesHandler"/>
|
||
<result property="bodyDesc" column="body_desc"/>
|
||
<result property="suggest" column="suggest"/>
|
||
<result property="targetWeight" column="target_weight"/>
|
||
<result property="executionScore" column="execution_score"/>
|
||
<result property="comment" column="comment"/>
|
||
<result property="thumbsupNum" column="thumbsup_num"/>
|
||
<result property="healthManifesto" column="health_manifesto"/>
|
||
<result property="menstrualPeriod" column="menstrual_period"/>
|
||
</resultMap>
|
||
|
||
<sql id="selectSysWxUserLogVo">
|
||
select id,openid, weight, appid, phone, log_time, sleep_time, wakeup_time, sport, sport_desc, avatar_url, diet, diet_desc, insomnia, defecation, defecation_desc, water, create_by, create_time, update_by, update_time, remark,
|
||
emotion, emotion_desc,sly_eat_food,constipation,ingredient_desc,breakfast_images,lunch_images,dinner_images,extra_meal_images,body_images,body_desc,suggest,execution_score,comment,health_manifesto,menstrual_period
|
||
from sys_wx_user_log
|
||
</sql>
|
||
|
||
<select id="checkWxLogInfoCount" parameterType="SysWxUserLog" resultType="Integer">
|
||
select count(*) from sys_wx_user_log where to_days(log_time) = to_days(#{logTime}) and openid = #{openid} and del_flag = 0
|
||
</select>
|
||
|
||
<!-- 后台查询 -->
|
||
<select id="selectSysWxUserLogList" parameterType="SysWxUserLog" resultMap="SysWxUserLogResult">
|
||
SELECT
|
||
wxlog.id,wxinfo.appid,wxinfo.openid,wxinfo.avatar_url,wxinfo.phone,wxlog.weight,wxlog.log_time,wxlog.sleep_time,
|
||
wxlog.wakeup_time,wxlog.defecation, wxlog.defecation_desc, wxlog.water, wxlog.insomnia,wxlog.sport,
|
||
wxlog.sport_desc,wxlog.diet, wxlog.diet_desc,wxlog.remark,
|
||
wxlog.emotion, wxlog.menstrual_period,
|
||
wxlog.emotion_desc,wxlog.sly_eat_food,wxlog.constipation,wxlog.ingredient_desc,wxlog.breakfast_images,
|
||
wxlog.lunch_images,wxlog.dinner_images,wxlog.extra_meal_images,wxlog.body_images,wxlog.body_desc,
|
||
wxlog.suggest,wxlog.execution_score,wxlog.comment,sc.name as customer_name, su.nick_name as nutritionist,
|
||
su_atferSale.nick_name as after_nutritionist, wxlog.health_manifesto, wxlog.log_time
|
||
FROM sys_wx_user_log wxlog
|
||
left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
|
||
left join sys_customer sc on sc.phone = wxinfo.phone and sc.del_flag = 0
|
||
left join sys_user su on su.user_id = sc.main_dietitian and su.del_flag = '0'
|
||
left join sys_user su_atferSale on su_atferSale.user_id = sc.after_dietitian and su_atferSale.del_flag = '0'
|
||
where wxlog.del_flag = 0 and wxinfo.phone is not null
|
||
<if test="id != null">
|
||
and wxlog.id = #{id}
|
||
</if>
|
||
<if test="customerId != null">
|
||
and sc.id = #{customerId}
|
||
</if>
|
||
<if test="phone != null and phone != ''">and (sc.name like concat('%',#{phone},'%') or wxinfo.phone like
|
||
concat('%',#{phone},'%') )
|
||
</if>
|
||
<if test="appid != null">
|
||
and wxinfo.appid = #{appid}
|
||
</if>
|
||
<if test="nutritionistId != null">
|
||
and su.user_id = #{nutritionistId}
|
||
</if>
|
||
<if test="afterNutritionistId != null">
|
||
and su_atferSale.user_id = #{afterNutritionistId}
|
||
</if>
|
||
<if test="beginTime != null and beginTime != ''">and date_format(wxlog.log_time,'%y%m%d') >=
|
||
date_format(#{beginTime},'%y%m%d')
|
||
</if>
|
||
<if test="endTime != null and endTime != ''">and date_format(wxlog.log_time,'%y%m%d') <=
|
||
date_format(#{endTime},'%y%m%d')
|
||
</if>
|
||
order by wxlog.log_time desc
|
||
</select>
|
||
|
||
<select id="selectWxLogInfoList" parameterType="SysWxUserLog" resultMap="WxLogInfo">
|
||
SELECT * FROM sys_wx_user_log log where log.del_flag = 0
|
||
<choose>
|
||
<when test="phone == null or phone == ''">
|
||
(SELECT phone FROM sys_wx_user_info WHERE openid = #{openid}) = log.phone
|
||
</when>
|
||
<otherwise>
|
||
<if test="openid != null and openid != ''">and openid = #{openid}</if>
|
||
<if test="phone != null and phone != ''">or phone = #{phone}</if>
|
||
</otherwise>
|
||
</choose>
|
||
order by log_time asc
|
||
</select>
|
||
|
||
<select id="selectSysWxUserLogById" parameterType="String" resultMap="SysWxUserLogResult">
|
||
<include refid="selectSysWxUserLogVo"/>
|
||
where id = #{id} and del_flag = 0
|
||
</select>
|
||
|
||
<insert id="insertSysWxUserLog" parameterType="SysWxUserLog">
|
||
insert into sys_wx_user_log
|
||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||
<if test="openid != null">openid,</if>
|
||
<if test="weight != null">weight,</if>
|
||
<if test="appid != null">appid,</if>
|
||
<if test="phone != null">phone,</if>
|
||
<if test="true">log_time,</if>
|
||
<if test="sleepTime != null">sleep_time,</if>
|
||
<if test="wakeupTime != null">wakeup_time,</if>
|
||
<if test="sport != null">sport,</if>
|
||
<if test="sportDesc != null">sport_desc,</if>
|
||
<if test="avatarUrl != null">avatar_url,</if>
|
||
<if test="diet != null">diet,</if>
|
||
<if test="dietDesc != null">diet_desc,</if>
|
||
<if test="insomnia != null">insomnia,</if>
|
||
<if test="defecation != null">defecation,</if>
|
||
<if test="defecationDesc != null">defecation_desc,</if>
|
||
<if test="water != null">water,</if>
|
||
<if test="createBy != null">create_by,</if>
|
||
<if test="true">create_time,</if>
|
||
<if test="updateBy != null">update_by,</if>
|
||
<if test="true">update_time,</if>
|
||
<if test="remark != null">remark,</if>
|
||
<if test="emotion != null">emotion,</if>
|
||
<if test="emotionDesc != null">emotion_desc,</if>
|
||
<if test="slyEatFood != null">sly_eat_food,</if>
|
||
<if test="constipation != null">constipation,</if>
|
||
<if test="ingredientDesc != null">ingredient_desc,</if>
|
||
<if test="breakfastImages != null">breakfast_images,</if>
|
||
<if test="lunchImages != null">lunch_images,</if>
|
||
<if test="dinnerImages != null">dinner_images,</if>
|
||
<if test="extraMealImages != null">extra_meal_images,</if>
|
||
<if test="bodyImages != null">body_images,</if>
|
||
<if test="bodyDesc != null">body_desc,</if>
|
||
<if test="suggest != null">suggest,</if>
|
||
<if test="targetWeight != null">target_weight,</if>
|
||
<if test="executionScore != null">execution_score,</if>
|
||
<if test="comment != null">comment,</if>
|
||
<if test="thumbsupNum != null">thumbsup_num,</if>
|
||
<if test="healthManifesto != null">health_manifesto,</if>
|
||
<if test="delFlag != null">del_flag,</if>
|
||
<if test="menstrualPeriod != null">menstrual_period,</if>
|
||
</trim>
|
||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||
<if test="openid != null">#{openid},</if>
|
||
<if test="weight != null">#{weight},</if>
|
||
<if test="appid != null">#{appid},</if>
|
||
<if test="phone != null">#{phone},</if>
|
||
<if test="true">now(),</if>
|
||
<if test="sleepTime != null">#{sleepTime},</if>
|
||
<if test="wakeupTime != null">#{wakeupTime},</if>
|
||
<if test="sport != null">#{sport},</if>
|
||
<if test="sportDesc != null">#{sportDesc},</if>
|
||
<if test="avatarUrl != null">#{avatarUrl},</if>
|
||
<if test="diet != null">#{diet},</if>
|
||
<if test="dietDesc != null">#{dietDesc},</if>
|
||
<if test="insomnia != null">#{insomnia},</if>
|
||
<if test="defecation != null">#{defecation},</if>
|
||
<if test="defecationDesc != null">#{defecationDesc},</if>
|
||
<if test="water != null">#{water},</if>
|
||
<if test="createBy != null">#{createBy},</if>
|
||
<if test="true">now(),</if>
|
||
<if test="updateBy != null">#{updateBy},</if>
|
||
<if test="true">now(),</if>
|
||
<if test="remark != null">#{remark},</if>
|
||
<if test="emotion != null">#{emotion},</if>
|
||
<if test="emotionDesc != null">#{emotionDesc},</if>
|
||
<if test="slyEatFood != null">#{slyEatFood},</if>
|
||
<if test="constipation != null">#{constipation},</if>
|
||
<if test="ingredientDesc != null">#{ingredientDesc},</if>
|
||
<if test="breakfastImages != null">#{breakfastImages},</if>
|
||
<if test="lunchImages != null">#{lunchImages},</if>
|
||
<if test="dinnerImages != null">#{dinnerImages},</if>
|
||
<if test="extraMealImages != null">#{extraMealImages},</if>
|
||
<if test="bodyImages != null">#{bodyImages},</if>
|
||
<if test="bodyDesc != null">#{bodyDesc},</if>
|
||
<if test="suggest != null">suggest = #{suggest},</if>
|
||
<if test="targetWeight != null">target_weight = #{targetWeight},</if>
|
||
<if test="executionScore != null">execution_score = #{executionScore},</if>
|
||
<if test="comment != null">comment = #{comment},</if>
|
||
<if test="thumbsupNum != null">#{thumbsupNum},</if>
|
||
<if test="healthManifesto != null">#{healthManifesto},</if>
|
||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||
<if test="menstrualPeriod != null">menstrual_period = #{menstrualPeriod},</if>
|
||
</trim>
|
||
</insert>
|
||
|
||
<update id="updateSysWxUserLog" parameterType="SysWxUserLog">
|
||
update sys_wx_user_log
|
||
<trim prefix="SET" suffixOverrides=",">
|
||
<if test="openid != null">openid = #{openid},</if>
|
||
<if test="weight != null">weight = #{weight},</if>
|
||
<if test="appid != null">appid = #{appid},</if>
|
||
<if test="phone != null">phone = #{phone},</if>
|
||
<if test="sleepTime != null">sleep_time = #{sleepTime},</if>
|
||
<if test="wakeupTime != null">wakeup_time = #{wakeupTime},</if>
|
||
<if test="sport != null">sport = #{sport},</if>
|
||
<if test="sportDesc != null">sport_desc = #{sportDesc},</if>
|
||
<if test="avatarUrl != null">avatar_url = #{avatarUrl},</if>
|
||
<if test="diet != null">diet = #{diet},</if>
|
||
<if test="dietDesc != null">diet_desc = #{dietDesc},</if>
|
||
<if test="insomnia != null">insomnia = #{insomnia},</if>
|
||
<if test="defecation != null">defecation = #{defecation},</if>
|
||
<if test="defecationDesc != null">defecation_desc = #{defecationDesc},</if>
|
||
<if test="water != null">water = #{water},</if>
|
||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||
<if test="updateTime != null">update_time = now(),</if>
|
||
<if test="remark != null">remark = #{remark},</if>
|
||
<if test="emotion != null">emotion = #{emotion},</if>
|
||
<if test="emotionDesc != null">emotion_desc = #{emotionDesc},</if>
|
||
<if test="slyEatFood != null">sly_eat_food = #{slyEatFood},</if>
|
||
<if test="constipation != null">constipation = #{constipation},</if>
|
||
<if test="ingredientDesc != null">ingredient_desc = #{ingredientDesc},</if>
|
||
<if test="breakfastImages != null">breakfast_images = #{breakfastImages},</if>
|
||
<if test="lunchImages != null">lunch_images = #{lunchImages},</if>
|
||
<if test="dinnerImages != null">dinner_images = #{dinnerImages},</if>
|
||
<if test="extraMealImages != null">extra_meal_images = #{extraMealImages},</if>
|
||
<if test="bodyImages != null">body_images = #{bodyImages},</if>
|
||
<if test="bodyDesc != null">body_desc = #{bodyDesc},</if>
|
||
<if test="suggest != null">suggest = #{suggest},</if>
|
||
<if test="targetWeight != null">target_weight = #{targetWeight},</if>
|
||
<if test="executionScore != null">execution_score = #{executionScore},</if>
|
||
<if test="comment != null">comment = #{comment},</if>
|
||
<if test="thumbsupNum != null">thumbsup_num = #{thumbsupNum},</if>
|
||
<if test="healthManifesto != null">health_manifesto = #{healthManifesto},</if>
|
||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||
<if test="menstrualPeriod != null">menstrual_period = #{menstrualPeriod},</if>
|
||
</trim>
|
||
where id = #{id}
|
||
</update>
|
||
|
||
<update id="deleteSysWxUserLogById" parameterType="Long">
|
||
update sys_wx_user_log set del_flag = 1 where id = #{id}
|
||
</update>
|
||
|
||
<update id="deleteSysWxUserLogByIds" parameterType="String">
|
||
update sys_wx_user_log set del_flag = 1 where id in
|
||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||
#{id}
|
||
</foreach>
|
||
</update>
|
||
|
||
<!-- 根据openid和手机号查询对应打卡记录 -->
|
||
<select id="getWxLogInfoList" parameterType="SysWxUserLog" resultMap="WxLogInfo">
|
||
SELECT wxlog.id,wxlog.weight,wxlog.log_time,wxlog.sleep_time, wxlog.wakeup_time,wxlog.defecation, wxlog.defecation_desc,
|
||
wxlog.water, wxlog.insomnia,wxlog.sport, wxlog.sport_desc,wxlog.diet, wxlog.diet_desc,
|
||
wxlog.emotion, wxlog.emotion_desc,wxlog.sly_eat_food,wxlog.constipation,wxlog.ingredient_desc,wxlog.breakfast_images,
|
||
wxlog.lunch_images,wxlog.dinner_images,wxlog.extra_meal_images,wxlog.body_images, wxlog.body_desc,
|
||
wxlog.remark,wxlog.execution_score,wxlog.comment, wxlog.health_manifesto, wxlog.menstrual_period
|
||
FROM sys_wx_user_log wxlog
|
||
where wxlog.del_flag = 0 and wxlog.openid = #{openid}
|
||
order by wxlog.log_time asc
|
||
</select>
|
||
|
||
<select id="selectSysWxUserLogByDateAndOpenId" parameterType="SysWxUserLog" resultMap="SysWxUserLogResult">
|
||
select id from sys_wx_user_log where del_flag = 0 and to_days(log_time) = to_days(#{logTime}) and openid = #{openid} limit 1
|
||
</select>
|
||
|
||
<!-- 根据手机号和openid查询打卡连续天数,只查询前两条 -->
|
||
<select id="getContinuity" parameterType="SysWxUserLog" resultType="Map">
|
||
SELECT yearMonth,MIN(log_time) AS minLogTime,MAX(log_time) AS maxLogTime,COUNT(*) AS continuityDayCount FROM
|
||
(
|
||
SELECT log_time,yearMonth,(days-date_rank) AS day_cha FROM
|
||
(
|
||
SELECT *,row_number() over(PARTITION BY yearMonth ORDER BY log_time) date_rank FROM
|
||
(
|
||
SELECT log_time,CONCAT(YEAR(log_time),'-',MONTH(log_time)) AS yearMonth,DAY(log_time) AS days
|
||
FROM sys_wx_user_log wxlog left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
|
||
where wxlog.del_flag = 0 and wxinfo.openid = #{openid} or wxinfo.phone = #{phone}
|
||
) AS s ORDER BY s.log_time DESC
|
||
) ss
|
||
) sss GROUP BY yearMonth,day_cha LIMIT 2
|
||
</select>
|
||
|
||
<!-- 后台根据用户ID查询该用户的打卡体重 -->
|
||
<select id="getWxUserLogListByCustomerId" parameterType="SysWxUserLog" resultMap="SysWxUserLogResult">
|
||
SELECT wxlog.id,wxlog.log_time,wxlog.weight FROM sys_wx_user_log wxlog
|
||
left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
|
||
left join sys_customer sc on sc.phone = wxinfo.phone and sc.del_flag = 0
|
||
where wxlog.del_flag = 0 and wxinfo.phone is not null and sc.id = #{customerId}
|
||
<if test="beginTime != null and beginTime != ''">and date_format(wxlog.log_time,'%y%m%d') >=
|
||
date_format(#{beginTime},'%y%m%d')
|
||
</if>
|
||
<if test="endTime != null and endTime != ''">and date_format(wxlog.log_time,'%y%m%d') <=
|
||
date_format(#{endTime},'%y%m%d')
|
||
</if>
|
||
order by wxlog.log_time asc
|
||
</select>
|
||
|
||
<!-- 根据openid和手机号查询对应打卡记录 -->
|
||
<select id="getWxLogInfoDetailById" parameterType="SysWxUserLog" resultMap="WxLogInfo">
|
||
SELECT wxlog.id,wxlog.weight,wxlog.log_time,wxlog.sleep_time, wxlog.wakeup_time,wxlog.defecation, wxlog.defecation_desc,
|
||
wxlog.water, wxlog.insomnia,wxlog.sport, wxlog.sport_desc,wxlog.diet, wxlog.diet_desc,
|
||
wxlog.emotion, wxlog.emotion_desc,wxlog.sly_eat_food,wxlog.constipation,wxlog.ingredient_desc,wxlog.breakfast_images,
|
||
wxlog.lunch_images,wxlog.dinner_images,wxlog.extra_meal_images,wxlog.body_images, wxlog.body_desc,
|
||
wxlog.remark,wxlog.execution_score,wxlog.comment,wxlog.menstrual_period
|
||
FROM sys_wx_user_log wxlog left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
|
||
where wxlog.del_flag = 0 and wxlog.id = #{id}
|
||
order by wxlog.log_time desc
|
||
</select>
|
||
|
||
|
||
<resultMap id="punchReponseMap" type="com.stdiet.custom.dto.response.CommunityPunchReponse">
|
||
<result property="id" column="id" typeHandler="com.stdiet.custom.typehandler.EncryptedIdHandler"/>
|
||
<result property="openid" column="openid"/>
|
||
<result property="nickName" column="nick_name"/>
|
||
<result property="avatarUrl" column="avatar_url"/>
|
||
<result property="logTime" column="log_time"/>
|
||
<result property="comment" column="comment"/>
|
||
<result property="healthManifesto" column="health_manifesto"/>
|
||
<association property="thumbsupNum" column="id" select="getPunchThumbsupCount"/>
|
||
<!-- 查询体重 -->
|
||
<association property="weightData" column="{id=openid}" select="getRecentWeight"/>
|
||
<!-- 查询点赞的openid -->
|
||
<association property="thumbsupUser" column="id" select="getPunchThumbsupList"/>
|
||
</resultMap>
|
||
|
||
<!-- 查询打卡社区内容 -->
|
||
<select id="getCommunityPunch" resultMap="punchReponseMap" parameterType="SysWxUserLog">
|
||
SELECT * FROM
|
||
(SELECT id, openid, `comment`, health_manifesto, log_time FROM sys_wx_user_log
|
||
WHERE TO_DAYS(log_time) = TO_DAYS(NOW()) AND del_flag = 0) AS wxlog
|
||
LEFT JOIN (SELECT openid, nick_name, avatar_url FROM sys_wx_user_info) AS wxinfo
|
||
USING(openid)
|
||
ORDER BY log_time DESC
|
||
</select>
|
||
|
||
<resultMap id="punchReponseMap2" type="com.stdiet.custom.dto.response.CommunityPunchReponse">
|
||
<result property="id" column="id" typeHandler="com.stdiet.custom.typehandler.EncryptedIdHandler"/>
|
||
<result property="openid" column="openid"/>
|
||
<result property="nickName" column="nick_name"/>
|
||
<result property="avatarUrl" column="avatar_url"/>
|
||
<result property="logTime" column="log_time"/>
|
||
<result property="comment" column="comment"/>
|
||
<result property="healthManifesto" column="health_manifesto"/>
|
||
<association property="thumbsupNum" column="id" select="getPunchThumbsupCount"/>
|
||
<!-- 查询体重 -->
|
||
<!-- <association property="weightData" column="{id=openid}" select="getRecentWeight"/>-->
|
||
<!-- 查询点赞的openid -->
|
||
<association property="thumbsupUser" column="id" select="getPunchThumbsupList"/>
|
||
</resultMap>
|
||
|
||
<!-- 客户活动-->
|
||
<select id="getCommunityPunchByOpenid" resultMap="punchReponseMap2" parameterType="String">
|
||
SELECT * FROM
|
||
(SELECT id, openid, `comment`, health_manifesto, log_time FROM sys_wx_user_log
|
||
WHERE openid = #{openid} AND del_flag = 0) AS wxlog
|
||
LEFT JOIN (SELECT openid, nick_name, avatar_url FROM sys_wx_user_info) AS wxinfo
|
||
USING(openid)
|
||
ORDER BY log_time DESC
|
||
</select>
|
||
|
||
<!-- 查询打卡社区中点赞的openid -->
|
||
<!-- <select id="getPunchThumbsupList" parameterType="Long" resultType="Map">-->
|
||
<!-- select * from-->
|
||
<!-- (select id, cus_openid as openid, DATE_FORMAT(create_time,'%Y-%m-%d %H:%i') as `time` from sys_punch_thumbsup where punch_id = #{id} and del_flag = 0 order by create_time asc) as tu-->
|
||
<!-- left join (SELECT openid, nick_name as nickName, avatar_url as avatarUrl FROM sys_wx_user_info) AS wxinfo-->
|
||
<!-- using(openid)-->
|
||
<!-- </select>-->
|
||
|
||
<resultMap id="thumbupUserResultMap" type="Map">
|
||
<result property="id" column="id" typeHandler="com.stdiet.custom.typehandler.EncryptedIdHandler"/>
|
||
<result property="openid" column="cus_openid"/>
|
||
</resultMap>
|
||
|
||
<select id="getPunchThumbsupList" parameterType="Long" resultMap="thumbupUserResultMap">
|
||
select id, cus_openid from sys_punch_thumbsup where punch_id = #{id} and del_flag = 0
|
||
</select>
|
||
|
||
<select id="getPunchThumbsupCount" parameterType="Long" resultType="Integer">
|
||
select count(*) from sys_punch_thumbsup where punch_id = #{id} and del_flag = 0
|
||
</select>
|
||
|
||
<!-- 查询所有打卡体重 -->
|
||
<select id="getRecentWeight" resultType="Map">
|
||
select DATE_FORMAT(log_time,'%Y-%m-%d') as name, weight as `value` from sys_wx_user_log
|
||
where del_flag = 0 and openid = #{id}
|
||
order by log_time desc
|
||
</select>
|
||
|
||
<!-- 根据客户ID查询总共打卡次数 -->
|
||
<select id="getPunchTotalNum" parameterType="SysWxUserLog" resultType="int">
|
||
select count(1) from sys_wx_user_log wxlog
|
||
left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
|
||
where wxlog.del_flag = 0 and wxinfo.cus_id = #{customerId}
|
||
</select>
|
||
|
||
<!-- 查询当天打卡社区总共几个人在打卡 -->
|
||
<select id="getPunchCustomerTotalNum" resultType="int">
|
||
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> |