From c8714a5354155186bbb16297c4fc2960c686db6e Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Sat, 15 May 2021 14:31:30 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=AE=A2=E9=98=85=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/WechatAppletController.java | 41 ++++- .../stdiet/custom/domain/SysRecipesPlan.java | 7 + .../custom/domain/SysRecipesPlanListInfo.java | 6 + .../domain/wechat/WxSubscribePostLog.java | 18 +++ .../mapper/SysWxSubscribePostLogMapper.java | 11 ++ .../custom/mapper/SysWxUserInfoMapper.java | 2 + .../custom/service/ISysWxUserInfoService.java | 2 + .../custom/service/IWechatAppletService.java | 4 +- .../service/IWxSubscribePostLogService.java | 11 ++ .../impl/SysRecipesPlanServiceImpl.java | 19 ++- .../impl/SysWxUserInfoServiceImpl.java | 35 ++--- .../service/impl/WeChartAppletServiceImp.java | 50 ++++-- .../impl/WxSubscribePostLogServiceImp.java | 26 ++++ .../mapper/custom/SysRecipesPlanMapper.xml | 32 ++-- .../custom/SysWxSubscribePostLogMapper.xml | 53 +++++++ .../mapper/custom/SysWxUserInfoMapper.xml | 6 + .../main/java/com/stdiet/framework/.DS_Store | Bin 0 -> 6148 bytes .../src/components/ScrollingNum/index.vue | 146 ++++++++++++++++++ stdiet-ui/src/permission.js | 3 +- stdiet-ui/src/router/index.js | 6 + 20 files changed, 429 insertions(+), 49 deletions(-) create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/domain/wechat/WxSubscribePostLog.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysWxSubscribePostLogMapper.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/service/IWxSubscribePostLogService.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/service/impl/WxSubscribePostLogServiceImp.java create mode 100644 stdiet-custom/src/main/resources/mapper/custom/SysWxSubscribePostLogMapper.xml create mode 100644 stdiet-framework/src/main/java/com/stdiet/framework/.DS_Store create mode 100644 stdiet-ui/src/components/ScrollingNum/index.vue 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 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 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 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 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 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 selectSysWxUserInfoList(SysWxUserInfo sysWxUserInfo) - { + public List 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 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 @@ - + @@ -22,6 +22,7 @@ + @@ -63,7 +64,7 @@ - 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 @@ update_by = #{updateBy}, del_flag = #{delFlag}, review_status = #{reviewStatus}, + subscribed = #{subscribed}, where id = #{id} and del_flag = 0 @@ -153,10 +155,12 @@ 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 - (#{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}) @@ -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 AND srp.order_id = #{orderId} AND srp.send_flag = #{sendFlag} @@ -238,16 +244,21 @@ + + - + + @@ -265,6 +276,7 @@ - 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} \ 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 @@ + + + + + + + + + + + + + + + + + insert into sys_wx_subscribe_post_log + + appid, + openid, + plan_id, + send_time, + errcode, + errmsg, + data, + + + #{appid}, + #{openid}, + #{planId}, + #{sendTime}, + #{errcode}, + #{errmsg}, + #{data, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ObjectJsonHandler}, + + + + + + + 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 @@ and nick_name like concat('%', #{nickName}, '%') and appid = #{appid} + and cus_id = #{cusId} and phone = #{phone} and sex = #{sex} @@ -45,6 +46,11 @@ order by wxuser.update_time desc + + @@ -137,6 +139,8 @@ del_flag = #{delFlag}, review_status = #{reviewStatus}, subscribed = #{subscribed}, + sub_send = #{subSend}, + sms_send = #{smsSend}, where id = #{id} and del_flag = 0 diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysWxSubscribePostLogMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysWxSubscribePostLogMapper.xml index 46ff6b20f..e83d9a82f 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysWxSubscribePostLogMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysWxSubscribePostLogMapper.xml @@ -10,8 +10,8 @@ - - + + @@ -22,18 +22,20 @@ openid, plan_id, send_time, - errcode, - errmsg, + result, + phone, data, + type, #{appid}, #{openid}, #{planId}, #{sendTime}, - #{errcode}, - #{errmsg}, + #{result, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ObjectJsonHandler}, + #{phone}, #{data, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ObjectJsonHandler}, + #{type}, @@ -45,8 +47,8 @@ AND openid = #{openid} AND appid = #{appid} AND plan_id = #{planId} - AND plan_id = #{planId} - AND errcode = #{errcode} + AND phone = #{phone} + AND type = #{type} diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysWxUserInfoMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysWxUserInfoMapper.xml index 946ed2c3c..f5d31376b 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysWxUserInfoMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysWxUserInfoMapper.xml @@ -46,7 +46,7 @@ order by wxuser.update_time desc - where cus_id = #{cusId}