小程序消息中心接口

This commit is contained in:
xiezhijun 2021-08-04 15:48:50 +08:00
parent 4311cc4f2a
commit 1f5fe09639
12 changed files with 488 additions and 10 deletions

View File

@ -738,6 +738,10 @@ public class WechatAppletController extends BaseController {
sysPunchThumbsup.setPunchId(Long.parseLong(AesUtils.decrypt(sysPunchThumbsup.getEncPunchId())));
rows = sysPunchThumbsupService.insertSysPunchThumbsup(sysPunchThumbsup);
if (rows > 0) {
//发送点赞消息
SysWxUserLog sysWxUserLog = sysWxUserLogService.selectSysWxUserLogById(sysPunchThumbsup.getPunchId()+"");
sysMessageNoticeService.sendpunchDynamicThumbsUpMessage(sysWxUserLog, sysPunchThumbsup.getCusOpenid());
Map<String, Object> resultData = new HashMap<>();
resultData.put("id", AesUtils.encrypt(String.valueOf(sysPunchThumbsup.getId())));
resultData.put("openid", sysPunchThumbsup.getCusOpenid());
@ -888,6 +892,41 @@ public class WechatAppletController extends BaseController {
return AjaxResult.success(reply);
}
/**
* 查询消息列表
* @param cusId 客户ID
* @param messageType 0 查询全部 1 查询打卡点评消息 2 打卡动态点赞消息 3 服务消息食谱更新执行反馈消息
* @return
*/
@GetMapping("/getMessageNoticeData")
public AjaxResult getMessageNoticeList(@RequestParam("cusId")String cusId, @RequestParam(value = "messageType", required = false, defaultValue = "0")Integer messageType) {
cusId = StringUtils.isNotEmpty(cusId) ? AesUtils.decrypt(cusId) : "0";
Map<String, Object> result = new HashMap<>();
//查询打卡消息
if(messageType.intValue() == 0 || messageType.intValue() == 1){
startPage();
Map<String,Object> punchResult = sysMessageNoticeService.getPunchCommentMessageByCusId(Long.parseLong(cusId));
List<Map<String,Object>> list = (List<Map<String,Object>>)punchResult.get("data");
punchResult.put("data",getDataTable(list));
result.put("punchMessageData", punchResult);
}
if(messageType.intValue() == 0 || messageType.intValue() == 2){
startPage();
Map<String,Object> thumbsUpResult = sysMessageNoticeService.getPunchDynamicThumbsUpMessage(Long.parseLong(cusId));
List<Map<String,Object>> list = (List<Map<String,Object>>)thumbsUpResult.get("data");
thumbsUpResult.put("data",getDataTable(list));
result.put("thumbsUpMessageData", thumbsUpResult);
}
if(messageType.intValue() == 0 || messageType.intValue() == 3){
startPage();
Map<String,Object> serviceResult = sysMessageNoticeService.getServiceMessage(Long.parseLong(cusId));
List<Map<String,Object>> list = (List<Map<String,Object>>)serviceResult.get("data");
serviceResult.put("data",getDataTable(list));
result.put("serviceMessageData", serviceResult);
}
return AjaxResult.success(result);
}
}

View File

@ -3,8 +3,10 @@ package com.stdiet.custom.domain.entityEnum;
public enum MessageNoticeEnum{
systemMessage("系统通知", 0, 0, "系统通知"),
punchComment("打卡点评", 1, 1, "%s打卡点评"); //%s 为打卡时间
punchComment("打卡点评", 1, 1, "%s打卡点评"), //%s 为打卡时间
punchDynamicThumbsUp("打卡动态点赞", 1, 2, ""),
recipesPlanMessage("食谱更新通知", 1, 3, ""),
topicMessage("执行反馈通知", 1, 4, "");
//消息名称
private String name;

View File

@ -1,8 +1,11 @@
package com.stdiet.custom.mapper;
import java.util.List;
import java.util.Map;
import com.stdiet.custom.domain.SysMessageNotice;
import com.stdiet.custom.dto.response.MessageNoticeResponse;
import org.apache.ibatis.annotations.Param;
/**
* 客户消息通知Mapper接口
@ -73,4 +76,58 @@ public interface SysMessageNoticeMapper
* @return
*/
public int getCustomerMessageCount(SysMessageNotice sysMessageNotice);
/**
* 根据客户ID查询打卡点评消息包含点评营养师信息客户信息点评内容
* @param cusId 客户ID
* @return
*/
List<Map<String,Object>> getPunchCommentMessageByCusId(@Param("cusId")Long cusId);
/**
* 查询打卡点评未读消息数量
* @param cusId 客户ID
* @return
*/
int getUnReadPunchMessageNum(@Param("cusId")Long cusId);
/**
* 根据打卡ID和openid查询点赞消息
* @param punchId 打卡ID
* @param openid 点赞用户openid
* @return
*/
SysMessageNotice getMessageByPunchIdAndOpenId(@Param("punchId")Long punchId, @Param("openid")String openid);
/**
* 根据客户ID查询点赞消息列表
* @param cusId 客户ID
* @return
*/
List<Map<String,Object>> getPunchDynamicThumbsUpMessage(Long cusId);
/**
* 查询未读点赞数量
* @param cusId 客户ID
* @return
*/
int getUnReadThumbsUpMessageNum(Long cusId);
/**
* 根据消息类型客户ID消息关键词查询消息
*/
SysMessageNotice getMessageByCusIdAndTypeKey(SysMessageNotice sysMessageNotice);
/**
* 根据客户ID查询服务消息食谱发送消息执行反馈回复消息
* @return
*/
List<Map<String,Object>> getServiceMessage(Long cusId);
/**
* 根据客户ID查询未读服务消息数量
* @param cusId
* @return
*/
int getUnReadServiceMessageNum(Long cusId);
}

View File

@ -32,4 +32,25 @@ public interface SysServicesTopicMapper {
* @return
*/
int getServicesTopicNum(@Param("cusId")Long cusId);
/**
* 根据topicId查询内容
* @param topicId
* @return
*/
String getTopicContentByTopicId(String topicId);
/**
* 根据评论ID查询评论内容
* @param commentId
* @return
*/
String getCommentContentByCommentId(String commentId);
/**
* 查询回复内容
* @param replyId
* @return
*/
String getReplyContentByReplyId(String replyId);
}

View File

@ -1,10 +1,15 @@
package com.stdiet.custom.service;
import java.util.List;
import java.util.Map;
import com.stdiet.custom.domain.SysMessageNotice;
import com.stdiet.custom.domain.SysRecipesPlan;
import com.stdiet.custom.domain.SysServicesTopic;
import com.stdiet.custom.domain.SysWxUserLog;
import com.stdiet.custom.domain.entityEnum.MessageNoticeEnum;
import com.stdiet.custom.dto.response.MessageNoticeResponse;
import org.apache.ibatis.annotations.Param;
/**
* 客户消息通知Service接口
@ -89,4 +94,45 @@ public interface ISysMessageNoticeService
* @param sysWxUserLog
*/
public void sendPunchCommentMessage(SysWxUserLog sysWxUserLog);
/**
* 发送打卡动态点赞消息
* @param sysWxUserLog
* @param openId 点赞用户openid
*/
public void sendpunchDynamicThumbsUpMessage(SysWxUserLog sysWxUserLog, String openId);
/**
* 发送食谱消息
* @param sysRecipesPlan
*/
public void sendRecipesPlanMessage(SysRecipesPlan sysRecipesPlan);
/**
* 发送执行反馈话题消息
* @param topic 话题对象
* @param type 类型 1评论 2回复
* @param originalContent 话题内容或被回复的内容
*/
public void sendTopicMessage(SysServicesTopic topic, int type, String originalContent);
/**
* 根据客户ID查询打卡点评消息以及未读消息数量包含点评营养师信息客户信息点评内容
* @param cusId 客户ID
* @return
*/
Map<String,Object> getPunchCommentMessageByCusId(Long cusId);
/**
* 根据客户ID查询点赞消息列表
* @param cusId 客户ID
* @return
*/
Map<String,Object> getPunchDynamicThumbsUpMessage(Long cusId);
/**
* 根据客户ID查询服务消息食谱发送消息执行反馈回复消息
* @return
*/
Map<String,Object> getServiceMessage(Long cusId);
}

View File

@ -30,4 +30,11 @@ public interface ISysServicesTopicService {
* @return
*/
int getServicesTopicNum(Long cusId);
/**
* 根据topicId查询内容
* @param topicId
* @return
*/
String getTopicContentByTopicId(String topicId);
}

View File

@ -1,11 +1,13 @@
package com.stdiet.custom.service.impl;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONArray;
import com.stdiet.common.utils.DateUtils;
import com.stdiet.common.utils.StringUtils;
import com.stdiet.custom.domain.SysCustomer;
import com.stdiet.custom.domain.SysWxUserLog;
import com.stdiet.custom.domain.*;
import com.stdiet.custom.domain.entityEnum.MessageNoticeEnum;
import com.stdiet.custom.dto.response.MessageNoticeResponse;
import com.stdiet.custom.service.ISysCustomerService;
@ -13,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.stdiet.custom.mapper.SysMessageNoticeMapper;
import com.stdiet.custom.domain.SysMessageNotice;
import com.stdiet.custom.service.ISysMessageNoticeService;
/**
@ -151,7 +152,7 @@ public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
@Override
@Async
public void sendPunchCommentMessage(SysWxUserLog sysWxUserLog){
if(sysWxUserLog == null || StringUtils.isEmpty(sysWxUserLog.getOpenid())){
if(sysWxUserLog == null || StringUtils.isEmpty(sysWxUserLog.getOpenid()) || sysWxUserLog.getId() == null){
return;
}
SysCustomer sysCustomer = sysCustomerService.getCustomerByOpenId(sysWxUserLog.getOpenid());
@ -161,9 +162,157 @@ public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
sysMessageNotice.setMessageType(MessageNoticeEnum.punchComment.getType());
sysMessageNotice.setReadType(0);
sysMessageNotice.setMessageCustomer(sysCustomer.getId());
sysMessageNotice.setMessageTitle(String.format(MessageNoticeEnum.punchComment.getTitleTemplate(), DateUtils.dateTime(sysWxUserLog.getLogTime())));
sysMessageNotice.setMessageTitle("");
sysMessageNotice.setMessageContent(sysWxUserLog.getComment());
sysMessageNotice.setMessageKey(sysWxUserLog.getId()+"");
sendMessageNoticeToCustomer(MessageNoticeEnum.punchComment, sysMessageNotice);
}
}
/**
* 发送打卡动态点赞消息
* @param sysWxUserLog
* @param openId 点赞用户openid
*/
@Override
@Async
public void sendpunchDynamicThumbsUpMessage(SysWxUserLog sysWxUserLog, String openId){
if(sysWxUserLog == null || StringUtils.isEmpty(sysWxUserLog.getOpenid()) || sysWxUserLog.getId() == null){
return;
}
//自己给自己点赞不发送消息
if(sysWxUserLog.getOpenid().equals(openId)){
return;
}
SysCustomer sysCustomer = sysCustomerService.getCustomerByOpenId(sysWxUserLog.getOpenid());
if(sysCustomer != null){
//根据openid打卡ID查询是否已经存在点赞消息
SysMessageNotice existSysMessageNotice = sysMessageNoticeMapper.getMessageByPunchIdAndOpenId(sysWxUserLog.getId(), openId);
if(existSysMessageNotice != null){
return;
}
SysMessageNotice sysMessageNotice = new SysMessageNotice();
sysMessageNotice.setMessageProperty(1);
sysMessageNotice.setMessageType(MessageNoticeEnum.punchDynamicThumbsUp.getType());
sysMessageNotice.setReadType(0);
sysMessageNotice.setMessageCustomer(sysCustomer.getId());
sysMessageNotice.setMessageTitle("");
sysMessageNotice.setMessageContent(openId);
sysMessageNotice.setMessageKey(sysWxUserLog.getId()+"");
sendMessageNoticeToCustomer(MessageNoticeEnum.punchDynamicThumbsUp, sysMessageNotice);
}
}
/**
* 发送执行反馈消息
*/
@Override
@Async
public void sendTopicMessage(SysServicesTopic topic, int type, String originalContent){
if(topic == null){
return;
}
Map<String,Object> content = new HashMap<>();
//回复内容
content.put("replyContent", topic.getContent());
//类型1 评论 2回复
content.put("type", type);
//topic的内容
content.put("originalContent", originalContent);
SysMessageNotice sysMessageNotice = new SysMessageNotice();
sysMessageNotice.setMessageProperty(1);
sysMessageNotice.setMessageType(MessageNoticeEnum.topicMessage.getType());
sysMessageNotice.setReadType(0);
sysMessageNotice.setMessageCustomer(Long.parseLong(topic.getToUid()));
sysMessageNotice.setMessageTitle("");
sysMessageNotice.setMessageContent(JSONArray.toJSONString(content));
sysMessageNotice.setMessageKey(topic.getTopicId());
sendMessageNoticeToCustomer(MessageNoticeEnum.topicMessage, sysMessageNotice);
}
/**
* 发送食谱更新消息
*/
@Override
@Async
public void sendRecipesPlanMessage(SysRecipesPlan sysRecipesPlan){
if(sysRecipesPlan == null || sysRecipesPlan.getCusId() == null || sysRecipesPlan.getRecipesId() == null){
return;
}
SysMessageNotice sysMessageNotice = new SysMessageNotice();
sysMessageNotice.setMessageType(MessageNoticeEnum.recipesPlanMessage.getType());
sysMessageNotice.setMessageKey(sysRecipesPlan.getRecipesId()+"");
sysMessageNotice.setMessageCustomer(sysRecipesPlan.getCusId());
//根据食谱ID查询是否已经发送过
SysMessageNotice existMessageNotice = sysMessageNoticeMapper.getMessageByCusIdAndTypeKey(sysMessageNotice);
if(existMessageNotice != null){
return;
}
sysMessageNotice.setMessageProperty(1);
sysMessageNotice.setReadType(0);
sysMessageNotice.setMessageTitle("");
Map<String,Object> content = new HashMap<>();
content.put("startNumDay", sysRecipesPlan.getStartNumDay());
content.put("endNumDay", sysRecipesPlan.getEndNumDay());
sysMessageNotice.setMessageContent(JSONArray.toJSONString(content));
sendMessageNoticeToCustomer(MessageNoticeEnum.recipesPlanMessage, sysMessageNotice);
}
/**
* 根据客户ID查询打卡点评消息以及未读消息数量包含点评营养师信息客户信息点评内容
* @param cusId 客户ID
* @return
*/
@Override
public Map<String,Object> getPunchCommentMessageByCusId(Long cusId){
List<Map<String,Object>> punchMessageList = sysMessageNoticeMapper.getPunchCommentMessageByCusId(cusId);
int unReadPunchMessageNum = 0;
if(punchMessageList != null && punchMessageList.size() > 0){
//查询未读消息
unReadPunchMessageNum = sysMessageNoticeMapper.getUnReadPunchMessageNum(cusId);
}
Map<String, Object> result = new HashMap<>();
result.put("data", punchMessageList);
result.put("unReadNum", unReadPunchMessageNum);
return result;
}
/**
* 根据客户ID查询点赞消息列表
* @param cusId 客户ID
* @return
*/
@Override
public Map<String,Object> getPunchDynamicThumbsUpMessage(Long cusId){
List<Map<String,Object>> thumbsUpMessageList = sysMessageNoticeMapper.getPunchDynamicThumbsUpMessage(cusId);
int unReadThumbsUpMessageNum = 0;
if(thumbsUpMessageList != null && thumbsUpMessageList.size() > 0){
//查询未读消息
unReadThumbsUpMessageNum = sysMessageNoticeMapper.getUnReadThumbsUpMessageNum(cusId);
}
Map<String, Object> result = new HashMap<>();
result.put("data", thumbsUpMessageList);
result.put("unReadNum", unReadThumbsUpMessageNum);
return result;
}
/**
* 根据客户ID查询服务消息食谱发送消息执行反馈回复消息
* @return
*/
@Override
public Map<String,Object> getServiceMessage(Long cusId){
List<Map<String,Object>> serviceMessageList = sysMessageNoticeMapper.getServiceMessage(cusId);
int unReadServiceMessageNum = 0;
if(serviceMessageList != null && serviceMessageList.size() > 0){
//查询未读消息
unReadServiceMessageNum = sysMessageNoticeMapper.getUnReadServiceMessageNum(cusId);
}
Map<String, Object> result = new HashMap<>();
result.put("data", serviceMessageList);
result.put("unReadNum", unReadServiceMessageNum);
return result;
}
}

View File

@ -44,6 +44,8 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
private ISysCustomerService sysCustomerService;
@Autowired
private SysRecipesMapper sysRecipesMapper;
@Autowired
private ISysMessageNoticeService sysMessageNoticeService;
//2021-06-11之后大于等于成交的订单只生成定金单食谱计划不生成尾款食谱计划之前成交的订单还是保持之前逻辑
public static final LocalDate newVersionPlanStartDate = DateUtils.stringToLocalDate("2021-06-01", "yyyy-MM-dd");
@ -117,6 +119,10 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
sysRecipesPlan.setSmsSend(1);
}
}
//发送食谱消息
if(StringUtils.isNotNull(recipesPlan)) {
sysMessageNoticeService.sendRecipesPlanMessage(recipesPlan);
}
}
}

View File

@ -10,6 +10,7 @@ import com.stdiet.custom.domain.SysWxUserInfo;
import com.stdiet.custom.mapper.SysCustomerMapper;
import com.stdiet.custom.mapper.SysServicesTopicMapper;
import com.stdiet.custom.server.WebSocketServer;
import com.stdiet.custom.service.ISysMessageNoticeService;
import com.stdiet.custom.service.ISysServicesTopicService;
import com.stdiet.custom.service.ISysWxUserInfoService;
import com.stdiet.custom.utils.WsUtils;
@ -31,6 +32,9 @@ public class SysServicesTopicServiceImp implements ISysServicesTopicService {
@Autowired
ISysWxUserInfoService iSysWxUserInfoService;
@Autowired
ISysMessageNoticeService sysMessageNoticeService;
@Override
public List<SysServicesTopic> selectSysServicesTopicByUserIdAndRole(SysServicesTopic topic) {
return servicesTopicMapper.selectSysServicesTopicByUserIdAndRole(topic);
@ -145,6 +149,19 @@ public class SysServicesTopicServiceImp implements ISysServicesTopicService {
status.setRole(topic.getRole());
servicesTopicMapper.updateSysServicesTopicStatus(status);
//发送消息
if("customer".equals(topic.getToRole()) && StringUtils.isNotEmpty(topic.getToUid())){
String content = "";
if(StringUtils.isNotEmpty(topic.getReplyId()) ){
content = servicesTopicMapper.getReplyContentByReplyId(topic.getReplyId());
}else if(StringUtils.isNotEmpty(topic.getCommentId())){
content = servicesTopicMapper.getCommentContentByCommentId(topic.getReplyId());
}
if(StringUtils.isNotEmpty(content)){
sysMessageNoticeService.sendTopicMessage(topic, 2, content);
}
}
afterReply(topic);
}
return topic;
@ -164,6 +181,15 @@ public class SysServicesTopicServiceImp implements ISysServicesTopicService {
status.setRole(topic.getRole());
servicesTopicMapper.updateSysServicesTopicStatus(status);
//发送消息
if("customer".equals(topic.getToRole()) && StringUtils.isNotEmpty(topic.getToUid())){
//查询topic内容
String content = servicesTopicMapper.getTopicContentByTopicId(topic.getTopicId());
if(StringUtils.isNotEmpty(content)){
sysMessageNoticeService.sendTopicMessage(topic, 1, content);
}
}
afterReply(topic);
}
return topic;
@ -229,4 +255,13 @@ public class SysServicesTopicServiceImp implements ISysServicesTopicService {
public int getServicesTopicNum(Long cusId){
return servicesTopicMapper.getServicesTopicNum(cusId);
}
/**
* 根据topicId查询内容
* @param topicId
* @return
*/
public String getTopicContentByTopicId(String topicId){
return servicesTopicMapper.getTopicContentByTopicId(topicId);
}
}

View File

@ -202,9 +202,37 @@
where phone = #{phone} and del_flag = 0
</select>
<resultMap type="SysCustomer" id="SysCustomerResultExtended">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="phone" column="phone"/>
<result property="email" column="email"/>
<result property="address" column="address"/>
<result property="payDate" column="pay_date"/>
<result property="startDate" column="start_date"/>
<result property="fansTime" column="fans_time"/>
<result property="fansChannel" column="fans_channel"/>
<result property="purchaseNum" column="purchase_num"/>
<result property="payTotal" column="pay_total"/>
<result property="chargePerson" column="charge_person"/>
<result property="followStatus" column="follow_status"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateTime" column="update_time"/>
<result property="updateBy" column="update_by"/>
<result property="channelId" column="channel_id"/>
<result property="mainDietitian" column="main_dietitian"/>
<result property="assistantDietitian" column="assistant_dietitian"/>
<result property="afterDietitian" column="after_dietitian"/>
<result property="salesman" column="salesman"/>
<result property="onSaleId" column="on_sale_id" />
</resultMap>
<!-- 根据openId查询客户 -->
<select id="getCustomerByOpenId" parameterType="String" resultMap="SysCustomerResult">
select sc.id from sys_customer sc
<select id="getCustomerByOpenId" parameterType="String" resultMap="SysCustomerResultExtended">
select sc.id, sc.name, sc.phone, sc.main_dietitian, sc.assistant_dietitian, sc.after_dietitian, sc.salesman, sc.on_sale_id
from sys_customer sc
left join sys_wx_user_info wu on wu.phone = sc.phone
where wu.openid = #{openid} and sc.del_flag = 0 order by sc.id desc limit 1
</select>

View File

@ -141,4 +141,77 @@
and smn.message_type = #{messageType}
</if>
</select>
<!-- 根据客户ID查询打卡点评消息包含点评营养师信息、客户信息、点评内容 -->
<select id="getPunchCommentMessageByCusId" parameterType="Long" resultType="Map">
select
message.id,message.message_type as messageType, message.message_content as content, message.read_type as readType,
DATE_FORMAT(message.create_time,'%Y-%m-%d %H:%i') as createTime, log.id as punchId, log.health_manifesto as healthManifesto,info.nick_name cusNickName,info.avatar_url as cusAvatar,diet.nick_name as dietNickName,diet.avatar as dietAvatar
from (
select id,message_customer,message_type,message_title,message_content,message_key,read_type,create_time from sys_message_notice
where del_flag = 0 and message_property = 1 and message_customer = #{cusId}
and message_type = 1
) message
left join sys_wx_user_log log on log.id = message.message_key and log.del_flag = 0
left join sys_wx_user_info info on info.openid = log.openid
left join sys_customer cus on cus.del_flag = 0 and cus.id = message.message_customer
left join sys_user diet on diet.user_id = cus.main_dietitian and diet.del_flag = 0 and diet.status = 0
order by message.id desc
</select>
<!-- 根据用户查询打卡点评的未读消息 -->
<select id="getUnReadPunchMessageNum" parameterType="Long" resultType="int">
select count(id) from sys_message_notice
where del_flag = 0 and message_property = 1
and message_type = 1 and read_type = 0 and message_customer = #{cusId}
</select>
<!-- 根据打卡ID、点赞openid查询点赞消息 -->
<select id="getMessageByPunchIdAndOpenId" resultMap="SysMessageNoticeResult">
select * from sys_message_notice where message_property = 1 and del_flag = 0 and message_type = 2
and message_key = #{punchId} and message_content = #{openid} order by id desc limit 1
</select>
<!-- 根据客户ID查询点赞消息 -->
<select id="getPunchDynamicThumbsUpMessage" parameterType="Long" resultType="Map">
select message.id,message.read_type as readType, message.message_type as messageType,DATE_FORMAT(message.create_time,'%Y-%m-%d %H:%i') as createTime, log.id as punchId, log.health_manifesto as healthManifesto,
thumbsUpUser.nick_name as thumbsUpUserNickName,thumbsUpUser.avatar_url as thumbsUpUserAvatar, punchUser.nick_name as cusNickName, punchUser.avatar_url as cusAvatarUrl
from
(
select id,message_customer,message_type,message_title,message_content,message_key,read_type,create_time from sys_message_notice
where del_flag = 0 and message_property = 1 and message_customer = #{cusId}
and message_type = 2
) message
left join sys_wx_user_info as thumbsUpUser on thumbsUpUser.openid = message.message_content
left join sys_wx_user_log as log on log.id = message.message_key and log.del_flag = 0
left join sys_wx_user_info as punchUser on punchUser.openid = log.openid
order by message.id desc
</select>
<!-- 查询点赞未读消息数量 -->
<select id="getUnReadThumbsUpMessageNum" parameterType="Long" resultType="int">
select count(id) from sys_message_notice
where del_flag = 0 and message_property = 1 and read_type = 0 and message_type = 2 and message_customer = #{cusId}
</select>
<!-- 查询消息是否存在 -->
<select id="getMessageByCusIdAndTypeKey" parameterType="SysMessageNotice" resultMap="SysMessageNoticeResult">
select * from sys_message_notice where del_flag = 0 and message_customer = #{messageCustomer}
and message_type = #{messageType} and message_key= #{messageKey} order by id desc limit 1
</select>
<!-- 查询服务消息(包含食谱更新消息、意见反馈回复消息) -->
<select id="getServiceMessage" parameterType="Long" resultType="Map">
select id, message_content as content, message_key as messageKey,
read_type as readType, message_type as messageType, DATE_FORMAT(create_time,'%Y-%m-%d %H:%i') as createTime from sys_message_notice
where del_flag = 0 and message_property = 1 and message_customer = #{cusId}
and (message_type = 3 or message_type = 4)
order by id desc
</select>
<!-- 查询未读服务消息数量 -->
<select id="getUnReadServiceMessageNum" parameterType="Long" resultType="int">
select count(id) from sys_message_notice
where del_flag = 0 and message_property = 1 and read_type = 0 and (message_type = 3 || message_type = 4) and message_customer = #{cusId}
</select>
</mapper>

View File

@ -325,4 +325,19 @@
<select id="getServicesTopicNum" parameterType="Long" resultType="int">
select count(1) from sys_services_topic where del_flag = 0 and uid = #{cusId}
</select>
<!-- 根据topicId查询内容 -->
<select id="getTopicContentByTopicId" resultType="String" parameterType="String">
select content from sys_services_topic where topic_id = #{topicId} limit 1
</select>
<!-- 根据CommentId查询评论内容 -->
<select id="getCommentContentByCommentId" resultType="String" parameterType="String">
select content from sys_services_topic_comment where id = #{commentId} limit 1
</select>
<!-- 根据replyId查询回复内容 -->
<select id="getReplyContentByReplyId" resultType="String" parameterType="String">
select content from sys_services_topic_reply where id = #{replyId} limit 1
</select>
</mapper>