diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java index f4c6c4834..ca5f444da 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java @@ -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)); + } + } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlan.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlan.java index 48da9b9b8..db37a2bab 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlan.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlan.java @@ -148,4 +148,11 @@ public class SysRecipesPlan { // 0-普通 1-模板 private Integer type; + + /** + * 订阅推送 + */ + private Integer subscribed; + + private String remark; } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlanListInfo.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlanListInfo.java index 926e9925c..e333258da 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlanListInfo.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlanListInfo.java @@ -25,4 +25,10 @@ public class SysRecipesPlanListInfo { private List<SysRecipesPlan> menus; + private Integer sendFlag; + + private Integer subscribed; + + private Integer status; + } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/wechat/WxSubscribePostLog.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/wechat/WxSubscribePostLog.java new file mode 100644 index 000000000..5a4fdf2fc --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/wechat/WxSubscribePostLog.java @@ -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; +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxSubscribePostLogMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxSubscribePostLogMapper.java new file mode 100644 index 000000000..e875e5c87 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxSubscribePostLogMapper.java @@ -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); +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxUserInfoMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxUserInfoMapper.java index 5173878a0..7081917fb 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxUserInfoMapper.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxUserInfoMapper.java @@ -19,6 +19,8 @@ public interface SysWxUserInfoMapper */ public SysWxUserInfo selectSysWxUserInfoById(String openid); + public SysWxUserInfo selectSysWxUserInfoByCusId(Long cusId); + /** * 查询微信用户列表 * diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxUserInfoService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxUserInfoService.java index 45dd721fe..3dc8acb61 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxUserInfoService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysWxUserInfoService.java @@ -19,6 +19,8 @@ public interface ISysWxUserInfoService */ public SysWxUserInfo selectSysWxUserInfoById(String openid); + public SysWxUserInfo selectSysWxUserInfoByCusId(Long cusId); + /** * 查询微信用户列表 * diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/IWechatAppletService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/IWechatAppletService.java index 61b66e351..1273a7b99 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/IWechatAppletService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/IWechatAppletService.java @@ -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); } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/IWxSubscribePostLogService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/IWxSubscribePostLogService.java new file mode 100644 index 000000000..d033d59b9 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/IWxSubscribePostLogService.java @@ -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); +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanServiceImpl.java index d949019dc..fa62f7f03 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysRecipesPlanServiceImpl.java @@ -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))); diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxUserInfoServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxUserInfoServiceImpl.java index a1ccb0e84..94f1ffb95 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxUserInfoServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysWxUserInfoServiceImpl.java @@ -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); } } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/WeChartAppletServiceImp.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/WeChartAppletServiceImp.java index 21199866f..4a89be9b8 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/WeChartAppletServiceImp.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/WeChartAppletServiceImp.java @@ -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"); } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/WxSubscribePostLogServiceImp.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/WxSubscribePostLogServiceImp.java new file mode 100644 index 000000000..4137d7e47 --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/WxSubscribePostLogServiceImp.java @@ -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); + } +} diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml index aa0c9a6f0..ca90aa620 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml @@ -14,7 +14,7 @@ <result property="recipesId" column="recipes_id"/> <result property="sendFlag" column="send_flag"/> <result property="sendTime" column="send_time"/> - <result property="pauseDate" column="pause_date"/> + <result property="pauseDate" column="pause_date"/> <result property="createTime" column="create_time"/> <result property="createBy" column="create_by"/> <result property="updateTime" column="update_time"/> @@ -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><!– 客户ID –>--> <result property="customer" column="customer"/><!-- 客户姓名 --> @@ -63,7 +64,7 @@ </select> <!-- 根据用户ID查询是否存在该用户该订单之前的最后一条食谱 --> - <select id="getLastDayRecipesPlan" resultMap="SysRecipesPlanResult"> + <select id="getLastDayRecipesPlan" resultMap="SysRecipesPlanResult"> select srp.* from sys_recipes_plan srp left join sys_order so on so.order_id = srp.order_id and so.del_flag = 0 @@ -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> \ No newline at end of file diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysWxSubscribePostLogMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysWxSubscribePostLogMapper.xml new file mode 100644 index 000000000..46ff6b20f --- /dev/null +++ b/stdiet-custom/src/main/resources/mapper/custom/SysWxSubscribePostLogMapper.xml @@ -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> diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysWxUserInfoMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysWxUserInfoMapper.xml index 213c2a3a7..946ed2c3c 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysWxUserInfoMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysWxUserInfoMapper.xml @@ -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} diff --git a/stdiet-framework/src/main/java/com/stdiet/framework/.DS_Store b/stdiet-framework/src/main/java/com/stdiet/framework/.DS_Store new file mode 100644 index 000000000..46970c204 Binary files /dev/null and b/stdiet-framework/src/main/java/com/stdiet/framework/.DS_Store differ diff --git a/stdiet-ui/src/components/ScrollingNum/index.vue b/stdiet-ui/src/components/ScrollingNum/index.vue new file mode 100644 index 000000000..f85078083 --- /dev/null +++ b/stdiet-ui/src/components/ScrollingNum/index.vue @@ -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> diff --git a/stdiet-ui/src/permission.js b/stdiet-ui/src/permission.js index 41a8e5ba6..110ddb218 100644 --- a/stdiet-ui/src/permission.js +++ b/stdiet-ui/src/permission.js @@ -13,7 +13,8 @@ const whiteList = [ "/bind", "/register", "/question", - "/subhealthyInvestigation" + "/subhealthyInvestigation", + "/live" ]; router.beforeEach((to, from, next) => { diff --git a/stdiet-ui/src/router/index.js b/stdiet-ui/src/router/index.js index c406b278d..303bbf182 100644 --- a/stdiet-ui/src/router/index.js +++ b/stdiet-ui/src/router/index.js @@ -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 =>