调整接口

This commit is contained in:
huangdeliang 2021-08-06 11:38:04 +08:00
parent af814fb1e1
commit 34bc27681d
2 changed files with 61 additions and 53 deletions

View File

@ -1,21 +1,21 @@
package com.stdiet.custom.service.impl;
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.*;
import com.stdiet.custom.domain.entityEnum.MessageNoticeEnum;
import com.stdiet.custom.dto.response.MessageNoticeResponse;
import com.stdiet.custom.mapper.SysMessageNoticeMapper;
import com.stdiet.custom.service.ISysCustomerService;
import com.stdiet.custom.service.ISysMessageNoticeService;
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.service.ISysMessageNoticeService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 客户消息通知Service业务层处理
@ -24,8 +24,7 @@ import com.stdiet.custom.service.ISysMessageNoticeService;
* @date 2021-04-26
*/
@Service
public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
{
public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService {
@Autowired
private SysMessageNoticeMapper sysMessageNoticeMapper;
@ -39,8 +38,7 @@ public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
* @return 客户消息通知
*/
@Override
public SysMessageNotice selectSysMessageNoticeById(Long id)
{
public SysMessageNotice selectSysMessageNoticeById(Long id) {
return sysMessageNoticeMapper.selectSysMessageNoticeById(id);
}
@ -51,8 +49,7 @@ public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
* @return 客户消息通知
*/
@Override
public List<SysMessageNotice> selectSysMessageNoticeList(SysMessageNotice sysMessageNotice)
{
public List<SysMessageNotice> selectSysMessageNoticeList(SysMessageNotice sysMessageNotice) {
return sysMessageNoticeMapper.selectSysMessageNoticeList(sysMessageNotice);
}
@ -63,8 +60,7 @@ public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
* @return 结果
*/
@Override
public int insertSysMessageNotice(SysMessageNotice sysMessageNotice)
{
public int insertSysMessageNotice(SysMessageNotice sysMessageNotice) {
sysMessageNotice.setCreateTime(DateUtils.getNowDate());
return sysMessageNoticeMapper.insertSysMessageNotice(sysMessageNotice);
}
@ -76,8 +72,7 @@ public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
* @return 结果
*/
@Override
public int updateSysMessageNotice(SysMessageNotice sysMessageNotice)
{
public int updateSysMessageNotice(SysMessageNotice sysMessageNotice) {
sysMessageNotice.setUpdateTime(DateUtils.getNowDate());
return sysMessageNoticeMapper.updateSysMessageNotice(sysMessageNotice);
}
@ -89,8 +84,7 @@ public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
* @return 结果
*/
@Override
public int deleteSysMessageNoticeByIds(Long[] ids)
{
public int deleteSysMessageNoticeByIds(Long[] ids) {
return sysMessageNoticeMapper.deleteSysMessageNoticeByIds(ids);
}
@ -101,20 +95,20 @@ public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
* @return 结果
*/
@Override
public int deleteSysMessageNoticeById(Long id)
{
public int deleteSysMessageNoticeById(Long id) {
return sysMessageNoticeMapper.deleteSysMessageNoticeById(id);
}
/**
* 根据客户ID查询客户信息包含私有信息以及公共消息
*
* @param sysMessageNotice
* @return
*/
@Override
public List<MessageNoticeResponse> getCustomerMessage(SysMessageNotice sysMessageNotice){
public List<MessageNoticeResponse> getCustomerMessage(SysMessageNotice sysMessageNotice) {
List<MessageNoticeResponse> responsesList = sysMessageNoticeMapper.getCustomerMessage(sysMessageNotice);
if(responsesList != null && responsesList.size() > 0){
if (responsesList != null && responsesList.size() > 0) {
for (MessageNoticeResponse messageNoticeResponse : responsesList) {
messageNoticeResponse.setMessageTypeName(MessageNoticeEnum.getNoticeEnumByType(messageNoticeResponse.getMessageType()).getName());
}
@ -124,12 +118,13 @@ public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
/**
* 消息发送
*
* @param messageNoticeEnum
* @param sysMessageNotice
* @return
*/
@Override
public int sendMessageNoticeToCustomer(MessageNoticeEnum messageNoticeEnum, SysMessageNotice sysMessageNotice){
public int sendMessageNoticeToCustomer(MessageNoticeEnum messageNoticeEnum, SysMessageNotice sysMessageNotice) {
sysMessageNotice.setMessageProperty(messageNoticeEnum.getProperty());
sysMessageNotice.setMessageType(messageNoticeEnum.getType());
return sysMessageNoticeMapper.insertSysMessageNotice(sysMessageNotice);
@ -137,26 +132,28 @@ public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
/**
* 根据客户ID查询客户消息数量
*
* @param sysMessageNotice
* @return
*/
@Override
public int getCustomerMessageCount(SysMessageNotice sysMessageNotice){
public int getCustomerMessageCount(SysMessageNotice sysMessageNotice) {
return sysMessageNoticeMapper.getCustomerMessageCount(sysMessageNotice);
}
/**
* 发送打卡点评消息
*
* @param sysWxUserLog
*/
@Override
@Async
public void sendPunchCommentMessage(SysWxUserLog sysWxUserLog){
if(sysWxUserLog == null || StringUtils.isEmpty(sysWxUserLog.getOpenid()) || sysWxUserLog.getId() == null){
public void sendPunchCommentMessage(SysWxUserLog sysWxUserLog) {
if (sysWxUserLog == null || StringUtils.isEmpty(sysWxUserLog.getOpenid()) || sysWxUserLog.getId() == null) {
return;
}
SysCustomer sysCustomer = sysCustomerService.getCustomerByOpenId(sysWxUserLog.getOpenid());
if(sysCustomer != null){
if (sysCustomer != null) {
SysMessageNotice sysMessageNotice = new SysMessageNotice();
sysMessageNotice.setMessageProperty(1);
sysMessageNotice.setMessageType(MessageNoticeEnum.punchComment.getType());
@ -164,31 +161,32 @@ public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
sysMessageNotice.setMessageCustomer(sysCustomer.getId());
sysMessageNotice.setMessageTitle("");
sysMessageNotice.setMessageContent(sysWxUserLog.getComment());
sysMessageNotice.setMessageKey(sysWxUserLog.getId()+"");
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){
public void sendpunchDynamicThumbsUpMessage(SysWxUserLog sysWxUserLog, String openId) {
if (sysWxUserLog == null || StringUtils.isEmpty(sysWxUserLog.getOpenid()) || sysWxUserLog.getId() == null) {
return;
}
//自己给自己点赞不发送消息
if(sysWxUserLog.getOpenid().equals(openId)){
if (sysWxUserLog.getOpenid().equals(openId)) {
return;
}
SysCustomer sysCustomer = sysCustomerService.getCustomerByOpenId(sysWxUserLog.getOpenid());
if(sysCustomer != null){
if (sysCustomer != null) {
//根据openid打卡ID查询是否已经存在点赞消息
SysMessageNotice existSysMessageNotice = sysMessageNoticeMapper.getMessageByPunchIdAndOpenId(sysWxUserLog.getId(), openId);
if(existSysMessageNotice != null){
if (existSysMessageNotice != null) {
return;
}
SysMessageNotice sysMessageNotice = new SysMessageNotice();
@ -198,7 +196,7 @@ public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
sysMessageNotice.setMessageCustomer(sysCustomer.getId());
sysMessageNotice.setMessageTitle("");
sysMessageNotice.setMessageContent(openId);
sysMessageNotice.setMessageKey(sysWxUserLog.getId()+"");
sysMessageNotice.setMessageKey(sysWxUserLog.getId() + "");
sendMessageNoticeToCustomer(MessageNoticeEnum.punchDynamicThumbsUp, sysMessageNotice);
}
}
@ -208,11 +206,11 @@ public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
*/
@Override
@Async
public void sendTopicMessage(SysServicesTopic topic, int type, String originalContent){
if(topic == null){
public void sendTopicMessage(SysServicesTopic topic, int type, String originalContent) {
if (topic == null) {
return;
}
Map<String,Object> content = new HashMap<>();
Map<String, Object> content = new HashMap<>();
//回复内容
content.put("replyContent", topic.getContent());
//类型1 评论 2回复
@ -236,23 +234,23 @@ public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
*/
@Override
@Async
public void sendRecipesPlanMessage(SysRecipesPlan sysRecipesPlan){
if(sysRecipesPlan == null || sysRecipesPlan.getCusId() == null || sysRecipesPlan.getRecipesId() == null){
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.setMessageKey(sysRecipesPlan.getRecipesId() + "");
sysMessageNotice.setMessageCustomer(sysRecipesPlan.getCusId());
//根据食谱ID查询是否已经发送过
SysMessageNotice existMessageNotice = sysMessageNoticeMapper.getMessageByCusIdAndTypeKey(sysMessageNotice);
if(existMessageNotice != null){
if (existMessageNotice != null) {
return;
}
sysMessageNotice.setMessageProperty(1);
sysMessageNotice.setReadType(0);
sysMessageNotice.setMessageTitle("");
Map<String,Object> content = new HashMap<>();
Map<String, Object> content = new HashMap<>();
content.put("startNumDay", sysRecipesPlan.getStartNumDay());
content.put("endNumDay", sysRecipesPlan.getEndNumDay());
sysMessageNotice.setMessageContent(JSONArray.toJSONString(content));
@ -261,18 +259,26 @@ public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
/**
* 根据客户ID查询打卡点评消息以及未读消息数量包含点评营养师信息客户信息点评内容
*
* @param cusId 客户ID
* @return
*/
@Override
public Map<String,Object> getPunchCommentMessageByCusId(Long cusId){
List<Map<String,Object>> punchMessageList = sysMessageNoticeMapper.getPunchCommentMessageByCusId(cusId);
public Map<String, Object> getPunchCommentMessageByCusId(Long cusId) {
List<Map<String, Object>> punchMessageList = sysMessageNoticeMapper.getPunchCommentMessageByCusId(cusId);
int unReadPunchMessageNum = 0;
if(punchMessageList != null && punchMessageList.size() > 0){
if (punchMessageList != null && punchMessageList.size() > 0) {
//查询未读消息
unReadPunchMessageNum = sysMessageNoticeMapper.getUnReadPunchMessageNum(cusId);
}
for (Map<String, Object> obj : punchMessageList) {
String dietAvatar = ((String) obj.get("dietAvatar"));
if (!dietAvatar.startsWith("http")) {
obj.put("dietAvatar", "https://manage.stdiet.cn/prod-api" + dietAvatar);
}
}
Map<String, Object> result = new HashMap<>();
result.put("data", punchMessageList);
result.put("unReadNum", unReadPunchMessageNum);
@ -281,14 +287,15 @@ public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
/**
* 根据客户ID查询点赞消息列表
*
* @param cusId 客户ID
* @return
*/
@Override
public Map<String,Object> getPunchDynamicThumbsUpMessage(Long cusId){
List<Map<String,Object>> thumbsUpMessageList = sysMessageNoticeMapper.getPunchDynamicThumbsUpMessage(cusId);
public Map<String, Object> getPunchDynamicThumbsUpMessage(Long cusId) {
List<Map<String, Object>> thumbsUpMessageList = sysMessageNoticeMapper.getPunchDynamicThumbsUpMessage(cusId);
int unReadThumbsUpMessageNum = 0;
if(thumbsUpMessageList != null && thumbsUpMessageList.size() > 0){
if (thumbsUpMessageList != null && thumbsUpMessageList.size() > 0) {
//查询未读消息
unReadThumbsUpMessageNum = sysMessageNoticeMapper.getUnReadThumbsUpMessageNum(cusId);
}
@ -300,13 +307,14 @@ public class SysMessageNoticeServiceImpl implements ISysMessageNoticeService
/**
* 根据客户ID查询服务消息食谱发送消息执行反馈回复消息
*
* @return
*/
@Override
public Map<String,Object> getServiceMessage(Long cusId){
List<Map<String,Object>> serviceMessageList = sysMessageNoticeMapper.getServiceMessage(cusId);
public Map<String, Object> getServiceMessage(Long cusId) {
List<Map<String, Object>> serviceMessageList = sysMessageNoticeMapper.getServiceMessage(cusId);
int unReadServiceMessageNum = 0;
if(serviceMessageList != null && serviceMessageList.size() > 0){
if (serviceMessageList != null && serviceMessageList.size() > 0) {
//查询未读消息
unReadServiceMessageNum = sysMessageNoticeMapper.getUnReadServiceMessageNum(cusId);
}

View File

@ -175,7 +175,7 @@
<!-- 根据客户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
thumbsUpUser.nick_name as thumbsUpUserNickName,thumbsUpUser.avatar_url as thumbsUpUserAvatar, punchUser.nick_name as cusNickName, punchUser.avatar_url as cusAvatar
from
(
select id,message_customer,message_type,message_title,message_content,message_key,read_type,create_time from sys_message_notice