小程序打卡功能优化

This commit is contained in:
xiezhijun 2021-04-14 17:25:40 +08:00
parent de5ca49409
commit 8d8dc77642
7 changed files with 221 additions and 33 deletions

View File

@ -200,4 +200,13 @@ public class SysWxUserLogController extends BaseController {
List<SysWxUserLog> list = sysWxUserLogService.getWxUserLogListByCustomerId(sysWxUserLog); List<SysWxUserLog> list = sysWxUserLogService.getWxUserLogListByCustomerId(sysWxUserLog);
return AjaxResult.success(list); return AjaxResult.success(list);
} }
/**
* 点评客户打卡内容
*/
@PreAuthorize("@ss.hasPermi('custom:wxUserLog:query')")
@PostMapping("/commentPunchContent")
public AjaxResult commentPunchContent(@RequestBody SysWxUserLog sysWxUserLog) {
return toAjax(sysWxUserLogService.updateSysWxUserLog(sysWxUserLog));
}
} }

View File

@ -131,6 +131,35 @@ public class WechatAppletController extends BaseController {
isPunch = true; isPunch = true;
} }
} }
for (WxLogInfo wxLogInfo : list) {
Map<String, List<String>> imageUrlMap = new HashMap<>();
List<String> breakfastImagesUrlList = StringUtils.isNotEmpty(wxLogInfo.getBreakfastImages()) ? Arrays.asList(wxLogInfo.getBreakfastImages().split("\\|")) : new ArrayList<>();
imageUrlMap.put("breakfastImages", breakfastImagesUrlList);
List<String> lunchImagesUrlList = StringUtils.isNotEmpty(sysWxUserLog.getLunchImages()) ? Arrays.asList(sysWxUserLog.getLunchImages().split("\\|")) : new ArrayList<>();
imageUrlMap.put("lunchImages", lunchImagesUrlList);
List<String> dinnerImagesUrlList = StringUtils.isNotEmpty(sysWxUserLog.getDinnerImages()) ? Arrays.asList(sysWxUserLog.getDinnerImages().split("\\|")) : new ArrayList<>();
imageUrlMap.put("dinnerImages", dinnerImagesUrlList);
List<String> extraMealImagesUrlList = StringUtils.isNotEmpty(sysWxUserLog.getExtraMealImages()) ? Arrays.asList(sysWxUserLog.getExtraMealImages().split("\\|")) : new ArrayList<>();
imageUrlMap.put("extraMealImages", extraMealImagesUrlList);
List<String> bodyImagesUrlList = StringUtils.isNotEmpty(sysWxUserLog.getBodyImages()) ? Arrays.asList(sysWxUserLog.getBodyImages().split("\\|")) : new ArrayList<>();
imageUrlMap.put("bodyImages", bodyImagesUrlList );
//生成预览链接
Map<String,List<String>> downUrlList = AliyunOSSUtils.generatePresignedUrl(imageUrlMap);
wxLogInfo.setBreakfastImagesUrl(downUrlList.get("breakfastImages"));
wxLogInfo.setLunchImagesUrl(downUrlList.get("lunchImages"));
wxLogInfo.setDinnerImagesUrl(downUrlList.get("dinnerImages"));
wxLogInfo.setExtraMealImagesUrl(downUrlList.get("extraMealImages"));
wxLogInfo.setBodyImagesUrl(downUrlList.get("bodyImages"));
}
Collections.reverse(list); Collections.reverse(list);
TableDataInfo tableDataInfo = getDataTable(list); TableDataInfo tableDataInfo = getDataTable(list);
result.put("isPunch", isPunch); result.put("isPunch", isPunch);

View File

@ -123,6 +123,25 @@ public class SysWxUserLog extends BaseEntity
@Excel(name = "体型对比照") @Excel(name = "体型对比照")
private String bodyImages; private String bodyImages;
/** 服务建议 */
@Excel(name = "服务建议")
private String suggest;
/** 目标体重 */
@Excel(name = "目标体重")
private BigDecimal targetWeight;
/** 执行评分,五分制 */
@Excel(name = "执行评分,五分制")
private BigDecimal executionScore;
/** 点评 */
@Excel(name = "点评")
private String comment;
/** 删除标识 0未删除 1已删除 */
private Long delFlag;
//售后营养师ID //售后营养师ID
private Long afterNutritionistId; private Long afterNutritionistId;

View File

@ -1,10 +1,12 @@
package com.stdiet.custom.page; package com.stdiet.custom.page;
import com.stdiet.common.annotation.Excel;
import com.stdiet.common.utils.DateUtils; import com.stdiet.common.utils.DateUtils;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List;
public class WxLogInfo implements Serializable { public class WxLogInfo implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -51,6 +53,28 @@ public class WxLogInfo implements Serializable {
/** 体型对比照 */ /** 体型对比照 */
private String bodyImages; private String bodyImages;
/** 服务建议 */
private String suggest;
/** 目标体重 */
private BigDecimal targetWeight;
/** 执行评分,五分制 */
private BigDecimal executionScore;
/** 点评 */
private String comment;
private List<String> breakfastImagesUrl;
private List<String> lunchImagesUrl;
private List<String> dinnerImagesUrl;
private List<String> extraMealImagesUrl;
private List<String> bodyImagesUrl;
public String getDate() { public String getDate() {
return date; return date;
} }
@ -187,6 +211,78 @@ public class WxLogInfo implements Serializable {
this.bodyImages = bodyImages; this.bodyImages = bodyImages;
} }
public String getSuggest() {
return suggest;
}
public void setSuggest(String suggest) {
this.suggest = suggest;
}
public BigDecimal getTargetWeight() {
return targetWeight;
}
public void setTargetWeight(BigDecimal targetWeight) {
this.targetWeight = targetWeight;
}
public BigDecimal getExecutionScore() {
return executionScore;
}
public void setExecutionScore(BigDecimal executionScore) {
this.executionScore = executionScore;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public List<String> getBreakfastImagesUrl() {
return breakfastImagesUrl;
}
public void setBreakfastImagesUrl(List<String> breakfastImagesUrl) {
this.breakfastImagesUrl = breakfastImagesUrl;
}
public List<String> getLunchImagesUrl() {
return lunchImagesUrl;
}
public void setLunchImagesUrl(List<String> lunchImagesUrl) {
this.lunchImagesUrl = lunchImagesUrl;
}
public List<String> getDinnerImagesUrl() {
return dinnerImagesUrl;
}
public void setDinnerImagesUrl(List<String> dinnerImagesUrl) {
this.dinnerImagesUrl = dinnerImagesUrl;
}
public List<String> getExtraMealImagesUrl() {
return extraMealImagesUrl;
}
public void setExtraMealImagesUrl(List<String> extraMealImagesUrl) {
this.extraMealImagesUrl = extraMealImagesUrl;
}
public List<String> getBodyImagesUrl() {
return bodyImagesUrl;
}
public void setBodyImagesUrl(List<String> bodyImagesUrl) {
this.bodyImagesUrl = bodyImagesUrl;
}
@Override @Override
public String toString() { public String toString() {
return "WxLogInfo{" + return "WxLogInfo{" +

View File

@ -33,6 +33,11 @@
<result property="dinnerImages" column="dinner_images" /> <result property="dinnerImages" column="dinner_images" />
<result property="extraMealImages" column="extra_meal_images" /> <result property="extraMealImages" column="extra_meal_images" />
<result property="bodyImages" column="body_images" /> <result property="bodyImages" column="body_images" />
<result property="suggest" column="suggest" />
<result property="targetWeight" column="target_weight" />
<result property="executionScore" column="execution_score" />
<result property="comment" column="comment" />
<result property="delFlag" column="del_flag" />
<!-- 非持久字段 --> <!-- 非持久字段 -->
<result property="customerName" column="customer_name"></result> <result property="customerName" column="customer_name"></result>
<!-- 营养师 --> <!-- 营养师 -->
@ -58,29 +63,33 @@
<result property="dinnerImages" column="dinner_images" /> <result property="dinnerImages" column="dinner_images" />
<result property="extraMealImages" column="extra_meal_images" /> <result property="extraMealImages" column="extra_meal_images" />
<result property="bodyImages" column="body_images" /> <result property="bodyImages" column="body_images" />
<result property="suggest" column="suggest" />
<result property="targetWeight" column="target_weight" />
<result property="executionScore" column="execution_score" />
<result property="comment" column="comment" />
</resultMap> </resultMap>
<sql id="selectSysWxUserLogVo"> <sql id="selectSysWxUserLogVo">
select id,openid, weight, appid, phone, log_time, sleep_time, wakeup_time, sport, avatar_url, diet, insomnia, defecation, water, create_by, create_time, update_by, update_time, remark, select id,openid, weight, appid, phone, log_time, sleep_time, wakeup_time, sport, avatar_url, diet, insomnia, defecation, water, create_by, create_time, update_by, update_time, remark,
emotion,sly_eat_food,constipation,breakfast_images,lunch_images,dinner_images,extra_meal_images,body_images emotion,sly_eat_food,constipation,breakfast_images,lunch_images,dinner_images,extra_meal_images,body_images,suggest,execution_score,comment
from sys_wx_user_log from sys_wx_user_log
</sql> </sql>
<select id="checkWxLogInfoCount" parameterType="String" resultType="Integer"> <select id="checkWxLogInfoCount" parameterType="String" resultType="Integer">
select count(*) from sys_wx_user_log where to_days(log_time) = to_days(now()) and openid = #{openid} select count(*) from sys_wx_user_log where to_days(log_time) = to_days(now()) and openid = #{openid} and del_flag = 0
</select> </select>
<!-- 后台查询 --> <!-- 后台查询 -->
<select id="selectSysWxUserLogList" parameterType="SysWxUserLog" resultMap="SysWxUserLogResult"> <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.water, wxlog.insomnia,wxlog.sport,wxlog.diet,wxlog.remark, 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.water, wxlog.insomnia,wxlog.sport,wxlog.diet,wxlog.remark,
wxlog.emotion,wxlog.sly_eat_food,wxlog.constipation,wxlog.breakfast_images,wxlog.lunch_images,wxlog.dinner_images,wxlog.extra_meal_images,wxlog.body_images, wxlog.emotion,wxlog.sly_eat_food,wxlog.constipation,wxlog.breakfast_images,wxlog.lunch_images,wxlog.dinner_images,wxlog.extra_meal_images,wxlog.body_images,
sc.name as customer_name, su.nick_name as nutritionist, su_atferSale.nick_name as after_nutritionist wxlog.suggest,wxlog.execution_score,wxlog.comment,sc.name as customer_name, su.nick_name as nutritionist, su_atferSale.nick_name as after_nutritionist
FROM sys_wx_user_log wxlog FROM sys_wx_user_log wxlog
left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid 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_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 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' left join sys_user su_atferSale on su_atferSale.user_id = sc.after_dietitian and su_atferSale.del_flag = '0'
where wxinfo.phone is not null where wxlog.del_flag = 0 and wxinfo.phone is not null
<if test="id != null"> <if test="id != null">
and wxlog.id = #{id} and wxlog.id = #{id}
</if> </if>
@ -103,24 +112,22 @@
</select> </select>
<select id="selectWxLogInfoList" parameterType="SysWxUserLog" resultMap="WxLogInfo"> <select id="selectWxLogInfoList" parameterType="SysWxUserLog" resultMap="WxLogInfo">
SELECT * FROM sys_wx_user_log log SELECT * FROM sys_wx_user_log log where log.del_flag = 0
<where> <choose>
<choose> <when test="phone == null or phone == ''">
<when test="phone == null or phone == ''"> (SELECT phone FROM sys_wx_user_info WHERE openid = #{openid}) = log.phone
(SELECT phone FROM sys_wx_user_info WHERE openid = #{openid}) = log.phone </when>
</when> <otherwise>
<otherwise> <if test="openid != null and openid != ''">and openid = #{openid}</if>
<if test="openid != null and openid != ''">and openid = #{openid}</if> <if test="phone != null and phone != ''">or phone = #{phone}</if>
<if test="phone != null and phone != ''">or phone = #{phone}</if> </otherwise>
</otherwise> </choose>
</choose>
</where>
order by log_time asc order by log_time asc
</select> </select>
<select id="selectSysWxUserLogById" parameterType="String" resultMap="SysWxUserLogResult"> <select id="selectSysWxUserLogById" parameterType="String" resultMap="SysWxUserLogResult">
<include refid="selectSysWxUserLogVo"/> <include refid="selectSysWxUserLogVo"/>
where id = #{id} where id = #{id} and del_flag = 0
</select> </select>
<insert id="insertSysWxUserLog" parameterType="SysWxUserLog"> <insert id="insertSysWxUserLog" parameterType="SysWxUserLog">
@ -152,6 +159,11 @@
<if test="dinnerImages != null">dinner_images,</if> <if test="dinnerImages != null">dinner_images,</if>
<if test="extraMealImages != null">extra_meal_images,</if> <if test="extraMealImages != null">extra_meal_images,</if>
<if test="bodyImages != null">body_images,</if> <if test="bodyImages != null">body_images,</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="delFlag != null">del_flag,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="openid != null">#{openid},</if> <if test="openid != null">#{openid},</if>
@ -180,6 +192,11 @@
<if test="dinnerImages != null">#{dinnerImages},</if> <if test="dinnerImages != null">#{dinnerImages},</if>
<if test="extraMealImages != null">#{extraMealImages},</if> <if test="extraMealImages != null">#{extraMealImages},</if>
<if test="bodyImages != null">#{bodyImages},</if> <if test="bodyImages != null">#{bodyImages},</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="delFlag != null">del_flag = #{delFlag},</if>
</trim> </trim>
</insert> </insert>
@ -212,32 +229,38 @@
<if test="dinnerImages != null">dinner_images = #{dinnerImages},</if> <if test="dinnerImages != null">dinner_images = #{dinnerImages},</if>
<if test="extraMealImages != null">extra_meal_images = #{extraMealImages},</if> <if test="extraMealImages != null">extra_meal_images = #{extraMealImages},</if>
<if test="bodyImages != null">body_images = #{bodyImages},</if> <if test="bodyImages != null">body_images = #{bodyImages},</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="delFlag != null">del_flag = #{delFlag},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
<delete id="deleteSysWxUserLogById" parameterType="Long"> <update id="deleteSysWxUserLogById" parameterType="Long">
delete from sys_wx_user_log where id = #{id} update sys_wx_user_log set del_flag = 1 where id = #{id}
</delete> </update>
<delete id="deleteSysWxUserLogByIds" parameterType="String"> <update id="deleteSysWxUserLogByIds" parameterType="String">
delete from sys_wx_user_log where id in update sys_wx_user_log set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
</delete> </update>
<!-- 根据openid和手机号查询对应打卡记录 --> <!-- 根据openid和手机号查询对应打卡记录 -->
<select id="getWxLogInfoList" parameterType="SysWxUserLog" resultMap="WxLogInfo"> <select id="getWxLogInfoList" parameterType="SysWxUserLog" resultMap="WxLogInfo">
SELECT wxlog.weight,wxlog.log_time,wxlog.sleep_time, wxlog.wakeup_time,wxlog.defecation, wxlog.water, wxlog.insomnia,wxlog.sport,wxlog.diet, SELECT wxlog.weight,wxlog.log_time,wxlog.sleep_time, wxlog.wakeup_time,wxlog.defecation, wxlog.water, wxlog.insomnia,wxlog.sport,wxlog.diet,
wxlog.emotion,wxlog.sly_eat_food,wxlog.constipation,wxlog.breakfast_images,wxlog.lunch_images,wxlog.dinner_images,wxlog.extra_meal_images,wxlog.body_images wxlog.emotion,wxlog.sly_eat_food,wxlog.constipation,wxlog.breakfast_images,wxlog.lunch_images,wxlog.dinner_images,wxlog.extra_meal_images,wxlog.body_images
,wxlog.suggest,wxlog.execution_score,wxlog.comment
FROM sys_wx_user_log wxlog left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid FROM sys_wx_user_log wxlog left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
where wxinfo.openid = #{openid} or wxinfo.phone = #{phone} where wxlog.del_flag = 0 and (wxinfo.openid = #{openid} or wxinfo.phone = #{phone})
order by wxlog.log_time desc order by wxlog.log_time desc
</select> </select>
<select id="selectSysWxUserLogByDateAndOpenId" parameterType="SysWxUserLog" resultMap="SysWxUserLogResult"> <select id="selectSysWxUserLogByDateAndOpenId" parameterType="SysWxUserLog" resultMap="SysWxUserLogResult">
select id from sys_wx_user_log where to_days(log_time) = to_days(#{logTime}) and openid = #{openid} limit 1 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> </select>
<!-- 根据手机号和openid查询打卡连续天数只查询前两条 --> <!-- 根据手机号和openid查询打卡连续天数只查询前两条 -->
@ -250,7 +273,7 @@
( (
SELECT log_time,CONCAT(YEAR(log_time),'-',MONTH(log_time)) AS yearMonth,DAY(log_time) AS days 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 FROM sys_wx_user_log wxlog left join sys_wx_user_info wxinfo on wxinfo.openid = wxlog.openid
where wxinfo.openid = #{openid} or wxinfo.phone = #{phone} where wxlog.del_flag = 0 and wxinfo.openid = #{openid} or wxinfo.phone = #{phone}
) AS s ORDER BY s.log_time DESC ) AS s ORDER BY s.log_time DESC
) ss ) ss
) sss GROUP BY yearMonth,day_cha LIMIT 2 ) sss GROUP BY yearMonth,day_cha LIMIT 2
@ -261,7 +284,7 @@
SELECT wxlog.id,wxlog.log_time,wxlog.weight FROM sys_wx_user_log wxlog 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_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_customer sc on sc.phone = wxinfo.phone and sc.del_flag = 0
where wxinfo.phone is not null and sc.id = #{customerId} 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') &gt;= date_format(#{beginTime},'%y%m%d')</if> <if test="beginTime != null and beginTime != ''">and date_format(wxlog.log_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')</if>
<if test="endTime != null and endTime != ''">and date_format(wxlog.log_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')</if> <if test="endTime != null and endTime != ''">and date_format(wxlog.log_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')</if>
order by wxlog.log_time asc order by wxlog.log_time asc

View File

@ -70,4 +70,16 @@ export function getAllPunchLogByCustomerId(query) {
}) })
} }
// 点评打卡
export function commentPunchContent(data) {
return request({
url: '/custom/wxUserLog/commentPunchContent',
method: 'post',
data: data
})
}

View File

@ -8,15 +8,15 @@
> >
<div style="margin-top: -20px;"> <div style="margin-top: -20px;">
<div <div
style="float: right; " style="float: right; margin-bottom:10px"
> >
<!--<el-button <el-button
v-hasPermi="['custom:wxUserLog:query']"
type="primary" type="primary"
plain plain
></el-button >打卡点</el-button
>--> >
</div> </div>
@ -84,7 +84,7 @@
</template> </template>
<script> <script>
import { import {
getPunchLogDetail getPunchLogDetail,commentPunchContent
} from "@/api/custom/wxUserLog"; } from "@/api/custom/wxUserLog";
import TableDetailMessage from "@/components/TableDetailMessage"; import TableDetailMessage from "@/components/TableDetailMessage";