订阅消息推送
This commit is contained in:
		| @@ -148,4 +148,11 @@ public class SysRecipesPlan { | ||||
|  | ||||
|     //    0-普通 1-模板 | ||||
|     private Integer type; | ||||
|  | ||||
|     /** | ||||
|      * 订阅推送 | ||||
|      */ | ||||
|     private Integer subscribed; | ||||
|  | ||||
|     private String remark; | ||||
| } | ||||
| @@ -25,4 +25,10 @@ public class SysRecipesPlanListInfo { | ||||
|  | ||||
|     private List<SysRecipesPlan> menus; | ||||
|  | ||||
|     private Integer sendFlag; | ||||
|  | ||||
|     private Integer subscribed; | ||||
|  | ||||
|     private Integer status; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -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; | ||||
| } | ||||
| @@ -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); | ||||
| } | ||||
| @@ -19,6 +19,8 @@ public interface SysWxUserInfoMapper | ||||
|      */ | ||||
|     public SysWxUserInfo selectSysWxUserInfoById(String openid); | ||||
|  | ||||
|     public SysWxUserInfo selectSysWxUserInfoByCusId(Long cusId); | ||||
|  | ||||
|     /** | ||||
|      * 查询微信用户列表 | ||||
|      * | ||||
|   | ||||
| @@ -19,6 +19,8 @@ public interface ISysWxUserInfoService | ||||
|      */ | ||||
|     public SysWxUserInfo selectSysWxUserInfoById(String openid); | ||||
|  | ||||
|     public SysWxUserInfo selectSysWxUserInfoByCusId(Long cusId); | ||||
|  | ||||
|     /** | ||||
|      * 查询微信用户列表 | ||||
|      * | ||||
|   | ||||
| @@ -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); | ||||
| } | ||||
|   | ||||
| @@ -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); | ||||
| } | ||||
| @@ -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))); | ||||
|   | ||||
| @@ -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); | ||||
|     } | ||||
| } | ||||
| @@ -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"); | ||||
|  | ||||
|     } | ||||
|   | ||||
| @@ -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); | ||||
|     } | ||||
| } | ||||
| @@ -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> | ||||
| @@ -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> | ||||
| @@ -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} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user