订阅消息推送

This commit is contained in:
huangdeliang 2021-05-15 14:31:30 +08:00
parent 1df264e603
commit c8714a5354
20 changed files with 429 additions and 49 deletions

View File

@ -451,17 +451,24 @@ public class WechatAppletController extends BaseController {
if (StringUtils.isNotEmpty(sysWxUserInfo.getPhone())) {
SysCustomer sysCustomer = iSysCustomerService.getCustomerByPhone(sysWxUserInfo.getPhone());
if (StringUtils.isNull(sysCustomer)) {
return AjaxResult.error(5003, "未查到用户信息,请联系销售顾问");
// return AjaxResult.error(5003, "未查到用户信息,请联系销售顾问");
// 创建新客户
sysCustomer = new SysCustomer();
sysCustomer.setName(sysWxUserInfo.getNickName());
sysCustomer.setPhone(sysWxUserInfo.getPhone());
sysCustomer.setUpdateTime(DateUtils.getNowDate());
sysCustomer.setCreateTime(DateUtils.getNowDate());
iSysCustomerService.insertSysCustomer(sysCustomer);
}
sysWxUserInfo.setCusId(sysCustomer.getId());
sysWxUserInfo.setUpdateTime(DateUtils.getNowDate());
if (StringUtils.isNull(curWxUserInfo)) {
// 新增sys_wx_user_info
sysWxUserInfo.setCreateTime(DateUtils.getNowDate());
sysWxUserInfoService.insertSysWxUserInfo(sysWxUserInfo);
} else {
// 更新sys_wx_user_info数据
sysWxUserInfo.setUpdateTime(DateUtils.getNowDate());
sysWxUserInfoService.updateSysWxUserInfo(sysWxUserInfo);
}
// 更新对象
@ -486,6 +493,23 @@ public class WechatAppletController extends BaseController {
List<SysRecipesPlanListInfo> plans = sysRecipesPlanService.selectRecipesPlanListInfoByCusId(cusId);
SysRecipesPlanListInfo tmpPlan;
for (int i = 0; i < plans.size(); i++) {
tmpPlan = plans.get(i);
tmpPlan.setStatus(1);
if (StringUtils.isNull(tmpPlan.getSendFlag()) || tmpPlan.getSendFlag() == 0) {
tmpPlan.setSendFlag(0);
tmpPlan.setMenus(new ArrayList<>());
}
// 从excel转到线上的客户之前的食谱无效
if (i > 0 && plans.get(i - 1).getRecipesId() == null && i < plans.size() - 1 && plans.get(i + 1).getRecipesId() != null) {
for (int j = 0; j < i; j++) {
plans.get(j).setStatus(0);
}
}
}
SysOrderPause orderPause = new SysOrderPause();
orderPause.setCusId(cusId);
List<SysOrderPause> pauses = sysOrderPauseService.selectSysOrderPauseList(orderPause);
@ -534,10 +558,21 @@ public class WechatAppletController extends BaseController {
}
@GetMapping("/getToken")
public String getToken(@RequestParam String appId) throws Exception {
public String getToken(@RequestParam String appId) {
return iWechatAppletService.getAccessToken(appId);
}
@GetMapping("/subscribe")
public AjaxResult subscribe(@RequestParam String customerId, Long planId, Integer subscribed) {
// Long cusId = StringUtils.isNotEmpty(customerId) ? Long.parseLong(AesUtils.decrypt(customerId)) : 0L;
SysRecipesPlan info = new SysRecipesPlan();
info.setId(planId);
info.setSubscribed(subscribed);
return AjaxResult.success(sysRecipesPlanService.updateSysRecipesPlan(info));
}
}

View File

@ -148,4 +148,11 @@ public class SysRecipesPlan {
// 0-普通 1-模板
private Integer type;
/**
* 订阅推送
*/
private Integer subscribed;
private String remark;
}

View File

@ -25,4 +25,10 @@ public class SysRecipesPlanListInfo {
private List<SysRecipesPlan> menus;
private Integer sendFlag;
private Integer subscribed;
private Integer status;
}

View File

@ -0,0 +1,18 @@
package com.stdiet.custom.domain.wechat;
import com.google.gson.JsonObject;
import lombok.Data;
import java.util.Date;
@Data
public class WxSubscribePostLog {
Long id;
String appid;
String openid;
Long planId;
Date sendTime;
Integer errcode;
String errmsg;
JsonObject data;
}

View File

@ -0,0 +1,11 @@
package com.stdiet.custom.mapper;
import com.stdiet.custom.domain.wechat.WxSubscribePostLog;
import java.util.List;
public interface SysWxSubscribePostLogMapper {
public int insertWxSubscribePostLog(WxSubscribePostLog postLog);
public List<WxSubscribePostLog> selectWxSubscribePostLog(WxSubscribePostLog postLog);
}

View File

@ -19,6 +19,8 @@ public interface SysWxUserInfoMapper
*/
public SysWxUserInfo selectSysWxUserInfoById(String openid);
public SysWxUserInfo selectSysWxUserInfoByCusId(Long cusId);
/**
* 查询微信用户列表
*

View File

@ -19,6 +19,8 @@ public interface ISysWxUserInfoService
*/
public SysWxUserInfo selectSysWxUserInfoById(String openid);
public SysWxUserInfo selectSysWxUserInfoByCusId(Long cusId);
/**
* 查询微信用户列表
*

View File

@ -2,7 +2,7 @@ package com.stdiet.custom.service;
public interface IWechatAppletService {
public String getAccessToken(String appId) throws Exception;
public String getAccessToken(String appId);
public void postRecipesMessage(String appId, String openId, String name, String startDate, String endDate, String remark) throws Exception;
public String postRecipesMessage(Long cusId, Long planId, String name, String startDate, String endDate, String remark);
}

View File

@ -0,0 +1,11 @@
package com.stdiet.custom.service;
import com.stdiet.custom.domain.wechat.WxSubscribePostLog;
import java.util.List;
public interface IWxSubscribePostLogService {
public int insertWxSubscribePostLog(WxSubscribePostLog postLog);
public List<WxSubscribePostLog> selectWxSubscribePostLog(WxSubscribePostLog postLog);
}

View File

@ -12,6 +12,7 @@ import com.stdiet.custom.mapper.SysRecipesPlanMapper;
import com.stdiet.custom.service.ISysOrderPauseService;
import com.stdiet.custom.service.ISysOrderService;
import com.stdiet.custom.service.ISysRecipesPlanService;
import com.stdiet.custom.service.IWechatAppletService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -40,6 +41,8 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
private ISysOrderPauseService sysOrderPauseService;
@Autowired
private SynchrolockUtil synchrolockUtil;
@Autowired
private IWechatAppletService wechatAppletService;
/**
* 查询食谱计划
@ -83,10 +86,20 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
*/
@Override
public int updateSysRecipesPlan(SysRecipesPlan sysRecipesPlan) {
SysRecipesPlan recipesPlan = sysRecipesPlanMapper.selectSysRecipesPlanById(sysRecipesPlan.getId());
sysRecipesPlan.setUpdateTime(DateUtils.getNowDate());
//目前只能修改发送状态所以修改时加上发送时间
sysRecipesPlan.setSendTime(DateUtils.getNowDate());
return sysRecipesPlanMapper.updateSysRecipesPlan(sysRecipesPlan);
int row = sysRecipesPlanMapper.updateSysRecipesPlan(sysRecipesPlan);
if (row > 0 && sysRecipesPlan.getSendFlag() == 1 && StringUtils.isNull(recipesPlan.getSendTime())) {
// 未发送过
String name = "" + recipesPlan.getStartNumDay() + "" + recipesPlan.getEndNumDay() + "";
String startDate = recipesPlan.getStartDate().toString();
String endDate = recipesPlan.getEndDate().toString();
wechatAppletService.postRecipesMessage(sysRecipesPlan.getCusId(), sysRecipesPlan.getId(), name, startDate, endDate, recipesPlan.getRemark());
}
return row;
}
/**
@ -236,11 +249,11 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
if (beforeOrderLastPlan != null) {
long differDay = ChronoUnit.DAYS.between(DateUtils.dateToLocalDate(beforeOrderLastPlan.getEndDate()), serverStartDate);
//检查之前食谱的结束时间和目前该订单的开始时间是否连续
if(differDay <= 1){
if (differDay <= 1) {
//判断前一个订单食谱是否满七天不满则需要接上
int differNum = beforeOrderLastPlan.getEndNumDay() - beforeOrderLastPlan.getStartNumDay();
if(differNum < 6){
if (differNum < 6) {
//更新该食谱计划
beforeOrderLastPlan.setEndNumDay(beforeOrderLastPlan.getStartNumDay() + 6);
beforeOrderLastPlan.setEndDate(DateUtils.localDateToDate(DateUtils.dateToLocalDate(beforeOrderLastPlan.getEndDate()).plusDays(6 - differNum)));

View File

@ -1,12 +1,13 @@
package com.stdiet.custom.service.impl;
import java.util.List;
import com.stdiet.common.utils.DateUtils;
import com.stdiet.custom.domain.SysWxUserInfo;
import com.stdiet.custom.mapper.SysWxUserInfoMapper;
import com.stdiet.custom.service.ISysWxUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysWxUserInfoMapper;
import com.stdiet.custom.domain.SysWxUserInfo;
import com.stdiet.custom.service.ISysWxUserInfoService;
import java.util.List;
/**
* 微信用户Service业务层处理
@ -15,8 +16,7 @@ import com.stdiet.custom.service.ISysWxUserInfoService;
* @date 2020-11-28
*/
@Service
public class SysWxUserInfoServiceImpl implements ISysWxUserInfoService
{
public class SysWxUserInfoServiceImpl implements ISysWxUserInfoService {
@Autowired
private SysWxUserInfoMapper sysWxUserInfoMapper;
@ -27,11 +27,15 @@ public class SysWxUserInfoServiceImpl implements ISysWxUserInfoService
* @return 微信用户
*/
@Override
public SysWxUserInfo selectSysWxUserInfoById(String openid)
{
public SysWxUserInfo selectSysWxUserInfoById(String openid) {
return sysWxUserInfoMapper.selectSysWxUserInfoById(openid);
}
@Override
public SysWxUserInfo selectSysWxUserInfoByCusId(Long cusId) {
return sysWxUserInfoMapper.selectSysWxUserInfoByCusId(cusId);
}
/**
* 查询微信用户列表
*
@ -39,8 +43,7 @@ public class SysWxUserInfoServiceImpl implements ISysWxUserInfoService
* @return 微信用户
*/
@Override
public List<SysWxUserInfo> selectSysWxUserInfoList(SysWxUserInfo sysWxUserInfo)
{
public List<SysWxUserInfo> selectSysWxUserInfoList(SysWxUserInfo sysWxUserInfo) {
return sysWxUserInfoMapper.selectSysWxUserInfoList(sysWxUserInfo);
}
@ -56,8 +59,7 @@ public class SysWxUserInfoServiceImpl implements ISysWxUserInfoService
* @return 结果
*/
@Override
public int insertSysWxUserInfo(SysWxUserInfo sysWxUserInfo)
{
public int insertSysWxUserInfo(SysWxUserInfo sysWxUserInfo) {
sysWxUserInfo.setCreateTime(DateUtils.getNowDate());
return sysWxUserInfoMapper.insertSysWxUserInfo(sysWxUserInfo);
}
@ -69,8 +71,7 @@ public class SysWxUserInfoServiceImpl implements ISysWxUserInfoService
* @return 结果
*/
@Override
public int updateSysWxUserInfo(SysWxUserInfo sysWxUserInfo)
{
public int updateSysWxUserInfo(SysWxUserInfo sysWxUserInfo) {
sysWxUserInfo.setUpdateTime(DateUtils.getNowDate());
return sysWxUserInfoMapper.updateSysWxUserInfo(sysWxUserInfo);
}
@ -82,8 +83,7 @@ public class SysWxUserInfoServiceImpl implements ISysWxUserInfoService
* @return 结果
*/
@Override
public int deleteSysWxUserInfoByIds(String[] openids)
{
public int deleteSysWxUserInfoByIds(String[] openids) {
return sysWxUserInfoMapper.deleteSysWxUserInfoByIds(openids);
}
@ -94,8 +94,7 @@ public class SysWxUserInfoServiceImpl implements ISysWxUserInfoService
* @return 结果
*/
@Override
public int deleteSysWxUserInfoById(String openid)
{
public int deleteSysWxUserInfoById(String openid) {
return sysWxUserInfoMapper.deleteSysWxUserInfoById(openid);
}
}

View File

@ -3,8 +3,13 @@ package com.stdiet.custom.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.stdiet.common.core.redis.RedisCache;
import com.stdiet.common.utils.DateUtils;
import com.stdiet.common.utils.StringUtils;
import com.stdiet.custom.domain.SysWxUserInfo;
import com.stdiet.custom.domain.wechat.WxSubscribePostLog;
import com.stdiet.custom.service.ISysWxUserInfoService;
import com.stdiet.custom.service.IWechatAppletService;
import com.stdiet.custom.service.IWxSubscribePostLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@ -23,8 +28,14 @@ public class WeChartAppletServiceImp implements IWechatAppletService {
@Autowired
private RestTemplate restTemplate;
@Autowired
private ISysWxUserInfoService sysWxUserInfoService;
@Autowired
private IWxSubscribePostLogService wxSubscribePostLogService;
@Override
public String getAccessToken(String appId) throws Exception {
public String getAccessToken(String appId) {
String accessToken = redisCache.getCacheObject(appId);
if (StringUtils.isNull(accessToken)) {
String appSecret = "";
@ -49,26 +60,31 @@ public class WeChartAppletServiceImp implements IWechatAppletService {
}
@Override
public void postRecipesMessage(String appId, String openId, String name, String startDate, String endDate, String remark) throws Exception {
String accessToken = getAccessToken(appId);
if (StringUtils.isNull(accessToken)) {
return;
public String postRecipesMessage(Long cusId, Long planId, String name, String startDate, String endDate, String remark) {
SysWxUserInfo sysWxUserInfo = sysWxUserInfoService.selectSysWxUserInfoByCusId(cusId);
if (StringUtils.isNull(sysWxUserInfo)) {
return null;
}
String tmpId = "";
String accessToken = getAccessToken(sysWxUserInfo.getAppid());
if (StringUtils.isNull(accessToken)) {
return "";
}
String tmpId = "EWeha9m0ggpnhMANDLHtl2ezLfPWKY_9PsJubbG_6eA";
String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + accessToken;
JsonObject param = new JsonObject();
param.addProperty("access_token", accessToken);
param.addProperty("touser", openId);
param.addProperty("touser", sysWxUserInfo.getOpenid());
param.addProperty("template_id", tmpId);
param.addProperty("page", "pages/recipes/index");
JsonObject dataParam = new JsonObject();
dataParam.addProperty("key1", name);
dataParam.addProperty("key2", startDate);
dataParam.addProperty("key3", endDate);
dataParam.addProperty("key4", remark);
dataParam.addProperty("phrase1", name);
dataParam.addProperty("date3", startDate);
dataParam.addProperty("thing6", endDate);
// dataParam.addProperty("thing6", remark);
param.add("data", dataParam);
@ -76,7 +92,17 @@ public class WeChartAppletServiceImp implements IWechatAppletService {
JSONObject resultObj = JSONObject.parseObject(entity.getBody());
System.out.println(resultObj.toJSONString());
WxSubscribePostLog postLog = new WxSubscribePostLog();
postLog.setAppid(sysWxUserInfo.getAppid());
postLog.setOpenid(sysWxUserInfo.getOpenid());
postLog.setErrcode(resultObj.getInteger("errcode"));
postLog.setErrmsg(resultObj.getString("errmsg"));
postLog.setSendTime(DateUtils.getNowDate());
postLog.setPlanId(planId);
postLog.setData(dataParam);
wxSubscribePostLogService.insertWxSubscribePostLog(postLog);
return resultObj.toJSONString();
// Integer errcode = resultObj.getInteger("errcode");
}

View File

@ -0,0 +1,26 @@
package com.stdiet.custom.service.impl;
import com.stdiet.custom.domain.wechat.WxSubscribePostLog;
import com.stdiet.custom.mapper.SysWxSubscribePostLogMapper;
import com.stdiet.custom.service.IWxSubscribePostLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class WxSubscribePostLogServiceImp implements IWxSubscribePostLogService {
@Autowired
SysWxSubscribePostLogMapper sysWxSubscribePostLogMapper;
@Override
public int insertWxSubscribePostLog(WxSubscribePostLog postLog) {
return sysWxSubscribePostLogMapper.insertWxSubscribePostLog(postLog);
}
@Override
public List<WxSubscribePostLog> selectWxSubscribePostLog(WxSubscribePostLog postLog) {
return sysWxSubscribePostLogMapper.selectWxSubscribePostLog(postLog);
}
}

View File

@ -22,6 +22,7 @@
<result property="delFlag" column="del_flag"/>
<result property="cusId" column="cus_id"/>
<result property="outId" column="out_id"/>
<result property="subscribed" column="subscribed"/>
<!-- 非持久化字段 -->
<!-- <result property="customerId" column="cus_id"></result>&lt;!&ndash; 客户ID &ndash;&gt;-->
<result property="customer" column="customer"/><!-- 客户姓名 -->
@ -135,6 +136,7 @@
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="reviewStatus != null">review_status = #{reviewStatus},</if>
<if test="subscribed != null">subscribed = #{subscribed},</if>
</trim>
where id = #{id} and del_flag = 0
</update>
@ -153,10 +155,12 @@
<!-- 批量插入食谱计划 -->
<insert id="insertBatch">
INSERT INTO sys_recipes_plan
(order_id, cus_id, out_id, start_date, end_date, start_num_day, end_num_day, send_flag, send_time, pause_date, recipes_id)
(order_id, cus_id, out_id, start_date, end_date, start_num_day, end_num_day, send_flag, send_time, pause_date,
recipes_id)
VALUES
<foreach collection="list" item="plan" separator=",">
(#{plan.orderId}, #{plan.cusId}, #{plan.outId}, #{plan.startDate}, #{plan.endDate}, #{plan.startNumDay}, #{plan.endNumDay},
(#{plan.orderId}, #{plan.cusId}, #{plan.outId}, #{plan.startDate}, #{plan.endDate}, #{plan.startNumDay},
#{plan.endNumDay},
#{plan.sendFlag}, #{plan.sendTime}, #{plan.pauseDate}, #{plan.recipesId})
</foreach>
</insert>
@ -177,8 +181,10 @@
FROM sys_recipes_plan srp
LEFT JOIN sys_order sr ON sr.order_id = srp.order_id
LEFT JOIN sys_customer sc ON sc.id = srp.cus_id
LEFT JOIN sys_user su_nutritionist ON su_nutritionist.user_id = sr.nutritionist_id AND su_nutritionist.del_flag = 0
LEFT JOIN sys_user su_nutritionist_assis ON su_nutritionist_assis.user_id = sr.nutri_assis_id AND su_nutritionist_assis.del_flag = 0
LEFT JOIN sys_user su_nutritionist ON su_nutritionist.user_id = sr.nutritionist_id AND su_nutritionist.del_flag
= 0
LEFT JOIN sys_user su_nutritionist_assis ON su_nutritionist_assis.user_id = sr.nutri_assis_id AND
su_nutritionist_assis.del_flag = 0
WHERE srp.del_flag = 0 AND sr.del_flag = 0 AND srp.type = 0
<if test="orderId != null">AND srp.order_id = #{orderId}</if>
<if test="sendFlag != null">AND srp.send_flag = #{sendFlag}</if>
@ -238,16 +244,21 @@
<result property="startNumDay" column="start_num_day"/>
<result property="endNumDay" column="end_num_day"/>
<result property="recipesId" column="recipes_id"/>
<result property="sendFlag" column="send_flag"/>
<result property="subscribed" column="subscribed"/>
<association property="menus" column="recipes_id" select="selectMenuIds"/>
</resultMap>
<!-- 通过outId查询食谱计划简要-->
<!-- 通过outId查询食谱计划简要
and review_status = 2 and send_flag = 1
-->
<select id="selectRecipesPlanListInfo" resultMap="SysRecipesPlanListInfoResult">
select id, start_date, end_date, start_num_day, end_num_day, recipes_id from sys_recipes_plan where out_id=#{outId} and del_flag = 0 and review_status = 2 and send_flag = 1
select id, start_date, end_date, start_num_day, end_num_day, recipes_id, send_flag, subscribed from sys_recipes_plan where out_id=#{outId} and del_flag = 0
</select>
<!-- and review_status = 2 and send_flag = 1-->
<select id="selectRecipesPlanListInfoByCusId" resultMap="SysRecipesPlanListInfoResult">
select id, start_date, end_date, start_num_day, end_num_day, recipes_id from sys_recipes_plan where cus_id=#{cusId} and del_flag = 0 and review_status = 2 and send_flag = 1
select id, start_date, end_date, start_num_day, end_num_day, recipes_id, send_flag, subscribed from sys_recipes_plan where cus_id=#{cusId} and del_flag = 0
</select>
<resultMap type="SysRecipesDaily" id="SysRecipesResult">
@ -265,6 +276,7 @@
<!--<foreach collection="list" item="item" separator=";" open="" close="">
</foreach>-->
update sys_recipes_plan set start_date = #{startDate},end_date = #{endDate},pause_date=#{pauseDate} where id = #{id}
update sys_recipes_plan set start_date = #{startDate},end_date = #{endDate},pause_date=#{pauseDate} where id =
#{id}
</update>
</mapper>

View File

@ -0,0 +1,53 @@
<?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.SysWxSubscribePostLogMapper">
<resultMap type="WxSubscribePostLog" id="WxSubscribePostLogResult">
<result property="id" column="id"/>
<result property="appid" column="appid"/>
<result property="openid" column="openid"/>
<result property="sendTime" column="send_time"/>
<result property="planId" column="plan_id"/>
<result property="errcode" column="errcode"/>
<result property="errmsg" column="errmsg"/>
<result property="data" column="data" typeHandler="com.stdiet.custom.typehandler.ObjectJsonHandler"/>
</resultMap>
<insert id="insertWxSubscribePostLog" parameterType="WxSubscribePostLog" useGeneratedKeys="true" keyProperty="id">
insert into sys_wx_subscribe_post_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="appid != null">appid,</if>
<if test="openid != null">openid,</if>
<if test="planId != null">plan_id,</if>
<if test="sendTime != null">send_time,</if>
<if test="errcode != null">errcode,</if>
<if test="errmsg != null">errmsg,</if>
<if test="data != null">data,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="appid != null">#{appid},</if>
<if test="openid != null">#{openid},</if>
<if test="planId != null">#{planId},</if>
<if test="sendTime != null">#{sendTime},</if>
<if test="errcode != null">#{errcode},</if>
<if test="errmsg != null">#{errmsg},</if>
<if test="data != null">#{data, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ObjectJsonHandler},</if>
</trim>
</insert>
<select id="selectWxSubscribePostLog" parameterType="WxSubscribePostLog" resultMap="WxSubscribePostLogResult">
select * from sys_wx_subscribe_post_log
<where>
<if test="id != null">AND id = #{id}</if>
<if test="openid != null">AND openid = #{openid}</if>
<if test="appid != null">AND appid = #{appid}</if>
<if test="planId != null">AND plan_id = #{planId}</if>
<if test="planId != null">AND plan_id = #{planId}</if>
<if test="errcode != null">AND errcode = #{errcode}</if>
</where>
</select>
</mapper>

View File

@ -32,6 +32,7 @@
<where>
<if test="nickName != null and nickName != ''">and nick_name like concat('%', #{nickName}, '%')</if>
<if test="appid != null and appid != ''">and appid = #{appid}</if>
<if test="cusId != null and cusId != ''">and cus_id = #{cusId}</if>
<if test="phone != null and phone != ''">and phone = #{phone}</if>
<if test="sex != null and sex != ''">and sex = #{sex}</if>
</where>
@ -45,6 +46,11 @@
order by wxuser.update_time desc
</select>
<select id="selectSysWxUserInfoByCusId" parameterType="String" resultMap="SysWxUserInfoResult">
<include refid="selectSysWxUserInfoVo"/>
where cus_id = #{cusId}
</select>
<select id="selectSysWxUserInfoById" parameterType="String" resultMap="SysWxUserInfoResult">
<include refid="selectSysWxUserInfoVo"/>
where openid = #{openid}

Binary file not shown.

View File

@ -0,0 +1,146 @@
<template>
<div class="scrolling_num_wrapper">
<h3 class="orderTitle">订单总量</h3>
<div class="box-item">
<li
:class="{ 'number-item': !isNaN(item), 'mark-item': isNaN(item) }"
v-for="(item, index) in orderNum"
:key="index"
>
<span v-if="!isNaN(item)">
<i ref="numberItem">0123456789</i>
</span>
<span class="comma" v-else>{{ item }}</span>
</li>
</div>
</div>
</template>
<script>
// https://www.pianshen.com/article/80951378341/
export default {
data() {
return {
num: 0,
orderNum: ["0", "0", ",", "0", "0", "0", ",", "0", "0", "0"], //
};
},
mounted() {
this.$nextTick(() => {
// this.toOrderNum(0); //
// this.setNumberTransform();
this.increaseNumber();
});
},
methods: {
//
increaseNumber() {
this.timer = setInterval(() => {
this.num += this.getRandomNumber(1, 100);
this.toOrderNum(this.num);
this.setNumberTransform();
}, 3000);
},
getRandomNumber(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
},
//
setNumberTransform() {
const numberItems = this.$refs.numberItem; // ref
const numberArr = this.orderNum.filter((item) => !isNaN(item));
// CSS ,
for (let index = 0; index < numberItems.length; index++) {
const elem = numberItems[index];
elem.style.transform = `translate(-50%, -${numberArr[index] * 10}%)`;
}
},
//
toOrderNum(num) {
num = num.toString();
//
if (num.length < 8) {
num = "0" + num; // "0"
this.toOrderNum(num); // "0"
} else if (num.length === 8) {
//
num = num.slice(0, 2) + "," + num.slice(2, 5) + "," + num.slice(5, 8);
this.orderNum = num.split(""); // 便
} else {
//
this.$message.warning("订单总量数字过大,显示异常,请联系客服");
}
},
},
};
</script>
<style scoped lang='scss'>
.scrolling_num_wrapper {
/*订单总量滚动数字设置*/
.box-item {
position: relative;
height: 100px;
font-size: 54px;
line-height: 41px;
text-align: center;
list-style: none;
color: #2d7cff;
writing-mode: vertical-lr;
text-orientation: upright;
/*文字禁止编辑*/
-moz-user-select: none; /*火狐*/
-webkit-user-select: none; /*webkit浏览器*/
-ms-user-select: none; /*IE10*/
-khtml-user-select: none; /*早期浏览器*/
user-select: none;
/* overflow: hidden; */
}
/* 默认逗号设置 */
.mark-item {
width: 10px;
height: 75px;
margin-right: 5px;
line-height: 10px;
font-size: 48px;
position: relative;
& > span {
position: absolute;
width: 100%;
bottom: 0;
writing-mode: vertical-rl;
text-orientation: upright;
}
}
/*滚动数字设置*/
.number-item {
width: 41px;
height: 75px;
background: #ccc;
list-style: none;
margin-right: 5px;
background: rgba(250, 250, 250, 1);
border-radius: 4px;
border: 1px solid rgba(221, 221, 221, 1);
& > span {
position: relative;
display: inline-block;
margin-right: 10px;
width: 100%;
height: 100%;
writing-mode: vertical-rl;
text-orientation: upright;
overflow: hidden;
& > i {
font-style: normal;
position: absolute;
top: 11px;
left: 50%;
transform: translate(-50%, 0);
transition: transform 1s ease-in-out;
letter-spacing: 10px;
}
}
}
.number-item:last-child {
margin-right: 0;
}
}
</style>

View File

@ -13,7 +13,8 @@ const whiteList = [
"/bind",
"/register",
"/question",
"/subhealthyInvestigation"
"/subhealthyInvestigation",
"/live"
];
router.beforeEach((to, from, next) => {

View File

@ -160,6 +160,12 @@ export const constantRoutes = [
hidden: true,
meta: { title: "胜唐体控健康评估表" }
},
{
path: "/live",
component: resolve => require(["@/components/ScrollingNum"], resolve),
hidden: true,
meta: { title: "直播数据" }
},
{
path: "/foodHeatCalculator/:id",
component: resolve =>