diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysMessageNoticeServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysMessageNoticeServiceImpl.java index 44cc4baa6..70ef187a3 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysMessageNoticeServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysMessageNoticeServiceImpl.java @@ -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 selectSysMessageNoticeList(SysMessageNotice sysMessageNotice) - { + public List 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 getCustomerMessage(SysMessageNotice sysMessageNotice){ + public List getCustomerMessage(SysMessageNotice sysMessageNotice) { List 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 + * @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 content = new HashMap<>(); + Map 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 content = new HashMap<>(); + Map 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 getPunchCommentMessageByCusId(Long cusId){ - List> punchMessageList = sysMessageNoticeMapper.getPunchCommentMessageByCusId(cusId); + public Map getPunchCommentMessageByCusId(Long cusId) { + List> 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 obj : punchMessageList) { + String dietAvatar = ((String) obj.get("dietAvatar")); + if (!dietAvatar.startsWith("http")) { + obj.put("dietAvatar", "https://manage.stdiet.cn/prod-api" + dietAvatar); + } + } + Map 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 getPunchDynamicThumbsUpMessage(Long cusId){ - List> thumbsUpMessageList = sysMessageNoticeMapper.getPunchDynamicThumbsUpMessage(cusId); + public Map getPunchDynamicThumbsUpMessage(Long cusId) { + List> 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 getServiceMessage(Long cusId){ - List> serviceMessageList = sysMessageNoticeMapper.getServiceMessage(cusId); + public Map getServiceMessage(Long cusId) { + List> serviceMessageList = sysMessageNoticeMapper.getServiceMessage(cusId); int unReadServiceMessageNum = 0; - if(serviceMessageList != null && serviceMessageList.size() > 0){ + if (serviceMessageList != null && serviceMessageList.size() > 0) { //查询未读消息 unReadServiceMessageNum = sysMessageNoticeMapper.getUnReadServiceMessageNum(cusId); } diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysMessageNoticeMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysMessageNoticeMapper.xml index 0a8684878..ed6f94544 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysMessageNoticeMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysMessageNoticeMapper.xml @@ -175,7 +175,7 @@