Browse Source

Merge branch 'dev_wx_msg' into dev_temp

master
sunyuchao 5 years ago
parent
commit
d728cf89f7
  1. 31
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/TemplateListFormDTO.java
  2. 11
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/WxSubscribeMessageFormDTO.java
  3. 6
      epmet-module/epmet-message/epmet-message-server/pom.xml
  4. 4
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/WxmpMessageConstant.java
  5. 19
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpMessageController.java
  6. 10
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpResiUserSubscribeDao.java
  7. 11
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpWorkUserSubscribeDao.java
  8. 13
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/exception/WxSubscribeException.java
  9. 9
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpMessageService.java
  10. 428
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java
  11. 13
      epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpResiUserSubscribeDao.xml
  12. 12
      epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpWorkUserSubscribeDao.xml
  13. 31
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/GetTemplateListFormDTO.java
  14. 25
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/GetTemplateListResultDTO.java
  15. 37
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PersonalTemplateController.java
  16. 9
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java
  17. 9
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java
  18. 13
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java
  19. 13
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml
  20. 5
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/UserMessageConstant.java
  21. 25
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/impl/ResiGroupMemberServiceImpl.java
  22. 12
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java
  23. 5
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/warmhearted/constant/ResiWarmUserMessageConstant.java
  24. 15
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/warmhearted/service/impl/ResiWarmheartedApplyServiceImpl.java

31
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/TemplateListFormDTO.java

@ -0,0 +1,31 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Description 获取客户小程序模板列表-接口入参
* @Author sun
*/
@Data
public class TemplateListFormDTO implements Serializable {
/**
* 客户Id
*/
@NotBlank(message="客户Id不能为空", groups = {TemplateListFormDTO.AddUserInternalGroup.class})
private String customerId;
/**
* 小程序Id
*/
@NotBlank(message="小程序appId不能为空", groups = {TemplateListFormDTO.AddUserInternalGroup.class})
private String appId;
/**
* 模板类型(站内信提醒)
*/
private String templateType;
public interface AddUserInternalGroup {}
}

11
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/WxSubscribeMessageFormDTO.java

@ -48,15 +48,4 @@ public class WxSubscribeMessageFormDTO implements Serializable {
@NotBlank(message = "消息内容不能为空")
private String messageContent;
/**
* 消息时间
*/
@NotBlank(message = "消息时间不能为空")
private String messageTime;
/**
* 所需下发的订阅模板id
*/
@NotBlank(message = "模板id不能为空")
private String templateId;
}

6
epmet-module/epmet-message/epmet-message-server/pom.xml

@ -101,6 +101,12 @@
<artifactId>epmet-user-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-third-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

4
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/WxmpMessageConstant.java

@ -34,8 +34,12 @@ public interface WxmpMessageConstant {
String TITLE = "title";
int TITLE_LIMIT = 20;
String MESSAGE_CONTENT = "message_content";
int MESSAGE_CONTENT_LIMIT = 20;
String MESSAGE_TIME = "message_time";
String DATA = "data";

19
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpMessageController.java

@ -20,11 +20,16 @@ package com.epmet.controller;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.GetTemplateListFormDTO;
import com.epmet.dto.form.WxMsgAuthInfoFormDTO;
import com.epmet.dto.form.WxSubscribeMessageFormDTO;
import com.epmet.dto.result.GetTemplateListResultDTO;
import com.epmet.service.WxmpMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@ -72,4 +77,16 @@ public class WxmpMessageController {
wxmpMessageService.sendWxSubscribeMessage(msgList);
return new Result();
}
/**
* @return
* @Description 居民端工作端-获取客户小程序模板列表
* @author sun
*/
@PostMapping("templatelist")
public Result<List<GetTemplateListResultDTO>> templateList(@RequestBody GetTemplateListFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, GetTemplateListFormDTO.AddUserInternalGroup.class);
return new Result<List<GetTemplateListResultDTO>>().ok(wxmpMessageService.templateList(formDTO));
}
}

10
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpResiUserSubscribeDao.java

@ -64,4 +64,14 @@ public interface WxmpResiUserSubscribeDao extends BaseDao<WxmpResiUserSubscribeE
* @Date 2020/10/22 13:23
*/
int clearResiSubscribeCount(@Param("openId") String openId, @Param("templateId") String templateId, @Param("customerId") String customerId);
/**
* @Description 获取模板id
* @param openId
* @param templateId
* @param customerId
* @return java.lang.Integer
* @Author liushaowen
* @Date 2020/10/23 10:53
*/
String getResiSubscribeTemplateId(@Param("openId") String openId, @Param("templateId") String templateId, @Param("customerId") String customerId);
}

11
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpWorkUserSubscribeDao.java

@ -64,4 +64,15 @@ public interface WxmpWorkUserSubscribeDao extends BaseDao<WxmpWorkUserSubscribeE
* @Date 2020/10/22 13:22
*/
int clearWorkSubscribeCount(@Param("openId") String openId, @Param("templateId") String templateId, @Param("customerId") String customerId);
/**
* @Description 获取模板id
* @param openId
* @param templateId
* @param customerId
* @return java.lang.String
* @Author liushaowen
* @Date 2020/10/23 10:54
*/
String getWorkSubscribeTemplateId(@Param("openId") String openId, @Param("templateId") String templateId, @Param("customerId") String customerId);
}

13
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/exception/WxSubscribeException.java

@ -8,6 +8,7 @@ package com.epmet.exception;
public class WxSubscribeException extends Exception {
private String openId;
private String templateId;
/**
* Constructs a new exception with the specified detail message. The
@ -17,9 +18,18 @@ public class WxSubscribeException extends Exception {
* @param message the detail message. The detail message is saved for
* later retrieval by the {@link #getMessage()} method.
*/
public WxSubscribeException(String message, String openId) {
public WxSubscribeException(String message, String templateId, String openId) {
super(message);
this.openId = openId;
this.templateId = templateId;
}
public String getTemplateId() {
return templateId;
}
public void setTemplateId(String templateId) {
this.templateId = templateId;
}
public String getOpenId() {
@ -29,4 +39,5 @@ public class WxSubscribeException extends Exception {
public void setOpenId(String openId) {
this.openId = openId;
}
}

9
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpMessageService.java

@ -17,7 +17,9 @@
package com.epmet.service;
import com.epmet.dto.form.GetTemplateListFormDTO;
import com.epmet.dto.form.WxSubscribeMessageFormDTO;
import com.epmet.dto.result.GetTemplateListResultDTO;
import java.util.List;
@ -39,4 +41,11 @@ public interface WxmpMessageService {
* @Date 2020/10/21 15:34
*/
void sendWxSubscribeMessage(List<WxSubscribeMessageFormDTO> msgList);
/**
* @return
* @Description 居民端工作端-获取客户小程序模板列表
* @author sun
*/
List<GetTemplateListResultDTO> templateList(GetTemplateListFormDTO formDTO);
}

428
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java

@ -21,16 +21,21 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.enums.EnvEnum;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.exception.ValidateException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.constant.WxmpMessageConstant;
import com.epmet.dao.WxmpResiUserSubscribeDao;
import com.epmet.dao.WxmpTemplateMsgSubscribeStatusDao;
import com.epmet.dao.WxmpWorkUserSubscribeDao;
import com.epmet.dto.form.GetTemplateListFormDTO;
import com.epmet.dto.form.StaffBasicInfoFormDTO;
import com.epmet.dto.form.UserBasicInfoFormDTO;
import com.epmet.dto.form.WxSubscribeMessageFormDTO;
import com.epmet.dto.result.GetTemplateListResultDTO;
import com.epmet.entity.WxmpMsgSendRecordEntity;
import com.epmet.entity.WxmpTemplateMsgSubscribeStatusEntity;
import com.epmet.exception.WxSubscribeException;
@ -60,225 +65,258 @@ import java.util.Map;
*/
@Service
public class WxmpMessageServiceImpl implements WxmpMessageService {
private Logger logger = LoggerFactory.getLogger(getClass());
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private WxmpTemplateMsgSubscribeStatusDao msgSubscribeStatusDao;
@Autowired
private WxmpTemplateMsgSubscribeStatusDao msgSubscribeStatusDao;
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired
private WxmpMessageRedis wxmpMessageRedis;
@Autowired
private WxmpMessageRedis wxmpMessageRedis;
@Resource
private WxmpResiUserSubscribeDao wxmpResiUserSubscribeDao;
@Resource
private WxmpResiUserSubscribeDao wxmpResiUserSubscribeDao;
@Resource
private WxmpWorkUserSubscribeDao wxmpWorkUserSubscribeDao;
@Resource
private WxmpWorkUserSubscribeDao wxmpWorkUserSubscribeDao;
@Autowired
private WxmpMsgSendRecordService wxmpMsgSendRecordService;
@Autowired
private WxmpMsgSendRecordService wxmpMsgSendRecordService;
/**
* @Description 保存系统授权信息
* @return void
* @author wxz
* @date 2020.10.21 17:29
*/
@Override
public void saveSysAuthorizeInfo(String customerId, String clientType, String alwaysVisit, String subscribeStatus, String userId) {
WxmpTemplateMsgSubscribeStatusEntity userSubscribeStatusEntity = msgSubscribeStatusDao.getUserSubscribeStatusEntity(userId, customerId, clientType);
if (userSubscribeStatusEntity != null) {
userSubscribeStatusEntity.setAlwaysVisit(alwaysVisit);
userSubscribeStatusEntity.setSubscribeStatus(subscribeStatus);
msgSubscribeStatusDao.updateById(userSubscribeStatusEntity);
return;
}
/**
* @return void
* @Description 保存系统授权信息
* @author wxz
* @date 2020.10.21 17:29
*/
@Override
public void saveSysAuthorizeInfo(String customerId, String clientType, String alwaysVisit, String subscribeStatus, String userId) {
WxmpTemplateMsgSubscribeStatusEntity userSubscribeStatusEntity = msgSubscribeStatusDao.getUserSubscribeStatusEntity(userId, customerId, clientType);
if (userSubscribeStatusEntity != null) {
userSubscribeStatusEntity.setAlwaysVisit(alwaysVisit);
userSubscribeStatusEntity.setSubscribeStatus(subscribeStatus);
msgSubscribeStatusDao.updateById(userSubscribeStatusEntity);
return;
}
userSubscribeStatusEntity = new WxmpTemplateMsgSubscribeStatusEntity();
userSubscribeStatusEntity.setCustomerId(customerId);
userSubscribeStatusEntity.setClientType(clientType);
userSubscribeStatusEntity.setAlwaysVisit(alwaysVisit);
userSubscribeStatusEntity.setSubscribeStatus(subscribeStatus);
userSubscribeStatusEntity.setUserId(userId);
msgSubscribeStatusDao.insert(userSubscribeStatusEntity);
}
userSubscribeStatusEntity = new WxmpTemplateMsgSubscribeStatusEntity();
userSubscribeStatusEntity.setCustomerId(customerId);
userSubscribeStatusEntity.setClientType(clientType);
userSubscribeStatusEntity.setAlwaysVisit(alwaysVisit);
userSubscribeStatusEntity.setSubscribeStatus(subscribeStatus);
userSubscribeStatusEntity.setUserId(userId);
msgSubscribeStatusDao.insert(userSubscribeStatusEntity);
}
/**
* @param msgList
* @return void
* @Description 发送订阅消息
* @Author liushaowen
* @Date 2020/10/21 15:34
*/
@Override
public void sendWxSubscribeMessage(List<WxSubscribeMessageFormDTO> msgList) {
logger.info("待发送订阅消息数量:{}", msgList.size());
int succecssCount = 0;
for (WxSubscribeMessageFormDTO msg : msgList) {
try {
String userId = msg.getUserId();
String clientType = msg.getClientType();
String customerId = msg.getCustomerId();
String templateId = msg.getTemplateId();
String openId = null;
//通过userId获取openId
try {
if (WxmpMessageConstant.RESI.equals(clientType)) {
UserBasicInfoFormDTO userBasicInfoFormDTO = new UserBasicInfoFormDTO();
userBasicInfoFormDTO.setUserId(userId);
openId = epmetUserOpenFeignClient.getUserBasicInfo(userBasicInfoFormDTO).getData().getOpenId();
} else if (WxmpMessageConstant.WORK.equals(clientType)) {
StaffBasicInfoFormDTO staffBasicInfoFormDTO = new StaffBasicInfoFormDTO();
staffBasicInfoFormDTO.setStaffId(userId);
openId = epmetUserOpenFeignClient.getStaffBasicInfo(staffBasicInfoFormDTO).getData().getOpenId();
} else {
throw new WxSubscribeException("clientType有误",openId);
}
}catch (Exception e){
throw new WxSubscribeException("连接User服务失败","");
}
/**
* @param msgList
* @return void
* @Description 发送订阅消息
* @Author liushaowen
* @Date 2020/10/21 15:34
*/
@Override
public void sendWxSubscribeMessage(List<WxSubscribeMessageFormDTO> msgList) {
logger.info("待发送订阅消息数量:{}", msgList.size());
int succecssCount = 0;
for (WxSubscribeMessageFormDTO msg : msgList) {
try {
String userId = msg.getUserId();
String clientType = msg.getClientType();
String customerId = msg.getCustomerId();
String templateId = null;
String openId = null;
//通过userId获取openId
try {
if (WxmpMessageConstant.RESI.equals(clientType)) {
UserBasicInfoFormDTO userBasicInfoFormDTO = new UserBasicInfoFormDTO();
userBasicInfoFormDTO.setUserId(userId);
openId = epmetUserOpenFeignClient.getUserBasicInfo(userBasicInfoFormDTO).getData().getOpenId();
} else if (WxmpMessageConstant.WORK.equals(clientType)) {
StaffBasicInfoFormDTO staffBasicInfoFormDTO = new StaffBasicInfoFormDTO();
staffBasicInfoFormDTO.setStaffId(userId);
openId = epmetUserOpenFeignClient.getStaffBasicInfo(staffBasicInfoFormDTO).getData().getOpenId();
} else {
throw new WxSubscribeException("clientType有误", "", openId);
}
} catch (Exception e) {
throw new WxSubscribeException("连接User服务失败", "", "");
}
if (StringUtils.isBlank(openId)){
throw new WxSubscribeException("openId获取失败","");
if (StringUtils.isBlank(openId)) {
throw new WxSubscribeException("openId获取失败", "", "");
}
//获取accessToken
StringBuilder key = new StringBuilder(msg.getCustomerId()).append(":").append(msg.getClientType());
Map<String, Object> authorizerRefreshToken = new HashMap<>();
//获取accessToken
StringBuilder key = new StringBuilder(msg.getCustomerId()).append(":").append(msg.getClientType());
Map<String, Object> authorizerRefreshToken = new HashMap<>();
try {
authorizerRefreshToken = wxmpMessageRedis.getAuthorizerRefreshToken(key.toString());
}catch (Exception e){
throw new WxSubscribeException("连接缓存服务器失败",openId);
}
String accessToken = (String) authorizerRefreshToken.get(WxmpMessageConstant.AUTHORIZER_ACCESS_TOKEN);
if (StringUtils.isBlank(accessToken)) {
throw new WxSubscribeException("accessToken获取失败",openId);
}
authorizerRefreshToken = wxmpMessageRedis.getAuthorizerRefreshToken(key.toString());
} catch (Exception e) {
throw new WxSubscribeException("连接缓存服务器失败", "", openId);
}
String accessToken = (String) authorizerRefreshToken.get(WxmpMessageConstant.AUTHORIZER_ACCESS_TOKEN);
if (StringUtils.isBlank(accessToken)) {
throw new WxSubscribeException("accessToken获取失败", "", openId);
}
//判断用户是否有次数
Integer count = null;
if (WxmpMessageConstant.RESI.equals(clientType)) {
count = wxmpResiUserSubscribeDao.getResiSubscribeInfo(openId, templateId, customerId);
} else if (WxmpMessageConstant.WORK.equals(clientType)) {
count = wxmpWorkUserSubscribeDao.getWorkSubscribeInfo(openId, templateId, customerId);
}
if (count == null) {
//用户未订阅
throw new WxSubscribeException("用户未订阅",openId);
}
if (count == 0) {
throw new WxSubscribeException("用户可用额度不足",openId);
}
//获取模板id
if (WxmpMessageConstant.RESI.equals(clientType)) {
templateId = wxmpResiUserSubscribeDao.getResiSubscribeTemplateId(openId, templateId, customerId);
} else if (WxmpMessageConstant.WORK.equals(clientType)) {
templateId = wxmpWorkUserSubscribeDao.getWorkSubscribeTemplateId(openId, templateId, customerId);
}
if (StringUtils.isBlank(templateId)) {
throw new WxSubscribeException("获取模板id失败", "", openId);
}
//发送消息
JSONObject jsonObject = new JSONObject();
JSONObject data = new JSONObject();
//必填项
jsonObject.put(WxmpMessageConstant.ACCESS_TOKEN, accessToken);
jsonObject.put(WxmpMessageConstant.TOUSER, openId);
jsonObject.put(WxmpMessageConstant.TEMPLATE_ID, templateId);
data.put(WxmpMessageConstant.TITLE, new JSONObject().put("value", "您有一条" + msg.getBehaviorType()));
data.put(WxmpMessageConstant.MESSAGE_CONTENT, new JSONObject().put("value", msg.getMessageContent()));
data.put(WxmpMessageConstant.MESSAGE_TIME, new JSONObject().put("value", msg.getMessageTime()));
jsonObject.put(WxmpMessageConstant.DATA, data);
EnvEnum envEnum = EnvEnum.getCurrentEnv();
//选填项
if (WxmpMessageConstant.RESI.equals(clientType)) {
jsonObject.put(WxmpMessageConstant.PAGE, WxmpMessageConstant.PAGE_RESI);
} else if (WxmpMessageConstant.WORK.equals(clientType)) {
jsonObject.put(WxmpMessageConstant.PAGE, WxmpMessageConstant.PAGE_WORK);
}
//开发环境
if ("dev".equals(envEnum.getCode())){
jsonObject.put(WxmpMessageConstant.MINIPROGRAM_STATE, WxmpMessageConstant.STATE_DEV);
}
//测试环境
if ("test".equals(envEnum.getCode())){
jsonObject.put(WxmpMessageConstant.MINIPROGRAM_STATE, WxmpMessageConstant.STATE_TEST);
}
//判断用户是否有次数
Integer count = null;
if (WxmpMessageConstant.RESI.equals(clientType)) {
count = wxmpResiUserSubscribeDao.getResiSubscribeInfo(openId, templateId, customerId);
} else if (WxmpMessageConstant.WORK.equals(clientType)) {
count = wxmpWorkUserSubscribeDao.getWorkSubscribeInfo(openId, templateId, customerId);
}
if (count == null) {
//用户未订阅
throw new WxSubscribeException("用户未订阅", templateId, openId);
}
if (count == 0) {
throw new WxSubscribeException("用户可用额度不足", templateId, openId);
}
String resultStr = HttpClientManager.getInstance().sendPostByJSON(WxmpMessageConstant.SEND_MESSAGE + accessToken, JSON.toJSONString(jsonObject)).getData();
Map<String, Object> resultMap = JSON.parseObject(resultStr, Map.class);
Object errcode = resultMap.get(WxmpMessageConstant.ERR_CODE);
if (errcode.equals(NumConstant.ZERO)) {
//发送成功
//发送消息
JSONObject jsonObject = new JSONObject();
JSONObject data = new JSONObject();
//必填项
jsonObject.put(WxmpMessageConstant.ACCESS_TOKEN, accessToken);
jsonObject.put(WxmpMessageConstant.TOUSER, openId);
jsonObject.put(WxmpMessageConstant.TEMPLATE_ID, templateId);
data.put(WxmpMessageConstant.TITLE, new JSONObject().put("value", ("您有一条" + msg.getBehaviorType()).substring(0, WxmpMessageConstant.TITLE_LIMIT)));
data.put(WxmpMessageConstant.MESSAGE_CONTENT, new JSONObject().put("value", msg.getMessageContent().substring(0, WxmpMessageConstant.MESSAGE_CONTENT_LIMIT)));
data.put(WxmpMessageConstant.MESSAGE_TIME, new JSONObject().put("value", new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date())));
jsonObject.put(WxmpMessageConstant.DATA, data);
EnvEnum envEnum = EnvEnum.getCurrentEnv();
//选填项
if (WxmpMessageConstant.RESI.equals(clientType)) {
jsonObject.put(WxmpMessageConstant.PAGE, WxmpMessageConstant.PAGE_RESI);
} else if (WxmpMessageConstant.WORK.equals(clientType)) {
jsonObject.put(WxmpMessageConstant.PAGE, WxmpMessageConstant.PAGE_WORK);
}
//开发环境
if ("dev".equals(envEnum.getCode())) {
jsonObject.put(WxmpMessageConstant.MINIPROGRAM_STATE, WxmpMessageConstant.STATE_DEV);
}
//测试环境
if ("test".equals(envEnum.getCode())) {
jsonObject.put(WxmpMessageConstant.MINIPROGRAM_STATE, WxmpMessageConstant.STATE_TEST);
}
//订阅条数-1
int decrease = 0;
if (WxmpMessageConstant.RESI.equals(clientType)) {
decrease = wxmpResiUserSubscribeDao.decreaseResiSubscribeCount(openId, templateId, customerId, 1);
} else if (WxmpMessageConstant.WORK.equals(clientType)) {
decrease = wxmpWorkUserSubscribeDao.decreaseWorkSubscribeCount(openId, templateId, customerId, 1);
}
if (decrease == 0) {
logger.error("消息{}发送成功但订阅条数-1失败", JSON.toJSONString(msg));
}
//存表
int saveRes = wxmpMsgSendRecordService.saveRecord(initRecord(msg,openId,WxmpMessageConstant.SUCCESS));
if (saveRes == 0) {
logger.error("消息{}发送成功但存入记录表失败", JSON.toJSONString(msg));
}
} else {
//发送失败
//用户拒绝,需清空订阅表条数,修改订阅状态
if (errcode.equals(WxmpMessageConstant.USER_REFUSED)) {
int clear = 0;
if (WxmpMessageConstant.RESI.equals(clientType)) {
clear = wxmpResiUserSubscribeDao.clearResiSubscribeCount(openId, templateId, customerId);
} else if (WxmpMessageConstant.WORK.equals(clientType)) {
clear = wxmpWorkUserSubscribeDao.clearWorkSubscribeCount(openId, templateId, customerId);
}
if (clear == 0) {
logger.error("消息{}发送失败且清空订阅条数失败", JSON.toJSONString(msg));
}
}
String resultStr = HttpClientManager.getInstance().sendPostByJSON(WxmpMessageConstant.SEND_MESSAGE + accessToken, JSON.toJSONString(jsonObject)).getData();
Map<String, Object> resultMap = JSON.parseObject(resultStr, Map.class);
Object errcode = resultMap.get(WxmpMessageConstant.ERR_CODE);
if (errcode.equals(NumConstant.ZERO)) {
//发送成功
//抛出错误
throw new WxSubscribeException(String.valueOf(resultMap.get(WxmpMessageConstant.ERR_MSG)),openId);
}
//订阅条数-1
int decrease = 0;
if (WxmpMessageConstant.RESI.equals(clientType)) {
decrease = wxmpResiUserSubscribeDao.decreaseResiSubscribeCount(openId, templateId, customerId, 1);
} else if (WxmpMessageConstant.WORK.equals(clientType)) {
decrease = wxmpWorkUserSubscribeDao.decreaseWorkSubscribeCount(openId, templateId, customerId, 1);
}
if (decrease == 0) {
logger.error("消息{}发送成功但订阅条数-1失败", JSON.toJSONString(msg));
}
//存表
int saveRes = wxmpMsgSendRecordService.saveRecord(initRecord(msg, templateId, openId, WxmpMessageConstant.SUCCESS));
if (saveRes == 0) {
logger.error("消息{}发送成功但存入记录表失败", JSON.toJSONString(msg));
}
} else {
//发送失败
//用户拒绝,需清空订阅表条数,修改订阅状态
if (errcode.equals(WxmpMessageConstant.USER_REFUSED)) {
int clear = 0;
if (WxmpMessageConstant.RESI.equals(clientType)) {
clear = wxmpResiUserSubscribeDao.clearResiSubscribeCount(openId, templateId, customerId);
} else if (WxmpMessageConstant.WORK.equals(clientType)) {
clear = wxmpWorkUserSubscribeDao.clearWorkSubscribeCount(openId, templateId, customerId);
}
if (clear == 0) {
logger.error("消息{}发送失败且清空订阅条数失败", JSON.toJSONString(msg));
}
}
succecssCount++;
} catch (Exception e) {
String errMsg = e.getMessage();
//ValidateException错误信息为getMsg
//抛出错误
throw new WxSubscribeException(String.valueOf(resultMap.get(WxmpMessageConstant.ERR_MSG)),templateId, openId);
}
succecssCount++;
} catch (Exception e) {
String errMsg = e.getMessage();
//ValidateException错误信息为getMsg
// if (StringUtils.isBlank(errMsg) && e instanceof ValidateException) {
// errMsg = ((ValidateException) e).getMsg();
// }
if (e instanceof WxSubscribeException){
//存表
WxmpMsgSendRecordEntity wxmpMsgSendRecordEntity = initRecord(msg, ((WxSubscribeException) e).getOpenId(), WxmpMessageConstant.ERROR);
wxmpMsgSendRecordEntity.setReason(errMsg);
int saveRes = wxmpMsgSendRecordService.saveRecord(wxmpMsgSendRecordEntity);
if (saveRes == 0) {
logger.error("消息{}发送失败且存入记录表失败", JSON.toJSONString(msg));
}
}
if (e instanceof WxSubscribeException) {
//存表
WxmpMsgSendRecordEntity wxmpMsgSendRecordEntity = initRecord(msg, ((WxSubscribeException) e).getTemplateId(), ((WxSubscribeException) e).getOpenId(), WxmpMessageConstant.ERROR);
wxmpMsgSendRecordEntity.setReason(errMsg);
int saveRes = wxmpMsgSendRecordService.saveRecord(wxmpMsgSendRecordEntity);
if (saveRes == 0) {
logger.error("消息{}发送失败且存入记录表失败", JSON.toJSONString(msg));
}
}
logger.error("消息:{}发送失败,原因是:{}", JSON.toJSONString(msg), errMsg);
continue;
}
logger.error("消息:{}发送失败,原因是:{}", JSON.toJSONString(msg), errMsg);
continue;
}
}
logger.info("{}条消息中的{}条发送成功", msgList.size(), succecssCount);
}
//初始化记录对象
private WxmpMsgSendRecordEntity initRecord(WxSubscribeMessageFormDTO msg, String templateId, String openId, String status) {
WxmpMsgSendRecordEntity wxmpMsgSendRecordEntity = new WxmpMsgSendRecordEntity();
wxmpMsgSendRecordEntity.setCustomerId(msg.getCustomerId());
wxmpMsgSendRecordEntity.setClientType(msg.getClientType());
wxmpMsgSendRecordEntity.setTemplateId(templateId);
wxmpMsgSendRecordEntity.setUserId(msg.getUserId());
wxmpMsgSendRecordEntity.setWxOpenId(openId);
wxmpMsgSendRecordEntity.setBehaviorType(msg.getBehaviorType());
wxmpMsgSendRecordEntity.setTitle("您有一条" + msg.getBehaviorType());
wxmpMsgSendRecordEntity.setMessageContent(msg.getMessageContent());
wxmpMsgSendRecordEntity.setMessageTime(new Date());
wxmpMsgSendRecordEntity.setResult(status);
return wxmpMsgSendRecordEntity;
}
/**
* @return
* @Description 居民端工作端-获取客户小程序模板列表
* @author sun
*/
@Override
public List<GetTemplateListResultDTO> templateList(GetTemplateListFormDTO formDTO) {
GetTemplateListFormDTO dto = ConvertUtils.sourceToTarget(formDTO, GetTemplateListFormDTO.class);
String url = "https://epmet-cloud.elinkservice.cn/api/third/personaltemplate/templatelist";
//String url = "http://localhost:8080/api/third/personaltemplate/templatelist";
String data = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(dto)).getData();
logger.info("ThirdLoginServiceImpl.getUserWeChat:httpclient->url:"+url+",结果->"+data);
JSONObject toResult = JSON.parseObject(data);
Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class);
if (null != toResult.get("code")) {
mapToResult.setCode(((Integer) toResult.get("code")).intValue());
}
logger.info("{}条消息中的{}条发送成功", msgList.size(), succecssCount);
}
//初始化记录对象
private WxmpMsgSendRecordEntity initRecord(WxSubscribeMessageFormDTO msg, String openId, String status){
WxmpMsgSendRecordEntity wxmpMsgSendRecordEntity = new WxmpMsgSendRecordEntity();
wxmpMsgSendRecordEntity.setCustomerId(msg.getCustomerId());
wxmpMsgSendRecordEntity.setClientType(msg.getClientType());
wxmpMsgSendRecordEntity.setTemplateId(msg.getTemplateId());
wxmpMsgSendRecordEntity.setUserId(msg.getUserId());
wxmpMsgSendRecordEntity.setWxOpenId(openId);
wxmpMsgSendRecordEntity.setBehaviorType(msg.getBehaviorType());
wxmpMsgSendRecordEntity.setTitle("您有一条" + msg.getBehaviorType());
wxmpMsgSendRecordEntity.setMessageContent(msg.getMessageContent());
try {
wxmpMsgSendRecordEntity.setMessageTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(msg.getMessageTime()));
} catch (ParseException e) {
wxmpMsgSendRecordEntity.setMessageTime(new Date());
if (!mapToResult.success()) {
logger.error("调用epmet_third服务获取小程序消息订阅模板数据失败");
throw new RenException(mapToResult.getCode());
}
wxmpMsgSendRecordEntity.setResult(status);
return wxmpMsgSendRecordEntity;
List<GetTemplateListResultDTO> resultList = (List<GetTemplateListResultDTO>) mapToResult.getData();
return resultList;
}
}

13
epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpResiUserSubscribeDao.xml

@ -37,4 +37,17 @@
and wx_open_id = #{openId}
</update>
<select id="getResiSubscribeTemplateId" resultType="String">
select
template_id
from Wxmp_Resi_User_Subscribe
where
del_flag = 0
and customer_id = #{customerId}
and template_id = #{templateId}
and wx_open_id = #{openId}
and wx_subscribe_status = 'subscribe'
limit 1
</select>
</mapper>

12
epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/WxmpWorkUserSubscribeDao.xml

@ -34,4 +34,16 @@
and template_id = #{templateId}
and wx_open_id = #{openId}
</update>
<select id="getWorkSubscribeTemplateId" resultType="String">
select
template_id
from Wxmp_Work_User_Subscribe
where
del_flag = 0
and customer_id = #{customerId}
and template_id = #{templateId}
and wx_open_id = #{openId}
and wx_subscribe_status = 'subscribe'
limit 1
</select>
</mapper>

31
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/GetTemplateListFormDTO.java

@ -0,0 +1,31 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Description 获取客户小程序模板列表-接口入参
* @Author sun
*/
@Data
public class GetTemplateListFormDTO implements Serializable {
/**
* 客户Id
*/
@NotBlank(message="客户Id不能为空", groups = {AddUserInternalGroup.class})
private String customerId;
/**
* 小程序Id
*/
@NotBlank(message="小程序appId不能为空", groups = {AddUserInternalGroup.class})
private String appId;
/**
* 模板类型(站内信提醒)
*/
private String templateType;
public interface AddUserInternalGroup {}
}

25
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/GetTemplateListResultDTO.java

@ -0,0 +1,25 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Description 获取客户小程序模板列表-接口返参
* @Author sun
*/
@Data
public class GetTemplateListResultDTO implements Serializable {
private static final long serialVersionUID = 6856602932571839314L;
/**
* 模板Id
*/
private String templateId;
/**
* 模板类型站内信提醒
*/
private String templateType;
}

37
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PersonalTemplateController.java

@ -0,0 +1,37 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.GetTemplateListFormDTO;
import com.epmet.dto.result.GetTemplateListResultDTO;
import com.epmet.service.PersonalTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-09-09
*/
@RestController
@RequestMapping("personaltemplate")
public class PersonalTemplateController {
@Autowired
private PersonalTemplateService personalTemplateService;
/**
* @return
* @Description 居民端工作端-获取客户小程序模板列表
* @author sun
*/
@PostMapping("templatelist")
public Result<List<GetTemplateListResultDTO>> templateList(@RequestBody GetTemplateListFormDTO formDTO) {
return new Result<List<GetTemplateListResultDTO>>().ok(personalTemplateService.templateList(formDTO));
}
}

9
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java

@ -19,7 +19,9 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.PersonalTemplateDTO;
import com.epmet.dto.form.GetTemplateListFormDTO;
import com.epmet.dto.result.CustomerTempResultDTO;
import com.epmet.dto.result.GetTemplateListResultDTO;
import com.epmet.dto.result.TemplateDTO;
import com.epmet.entity.PersonalTemplateEntity;
import org.apache.ibatis.annotations.Mapper;
@ -76,4 +78,11 @@ public interface PersonalTemplateDao extends BaseDao<PersonalTemplateEntity> {
*/
List<TemplateDTO> selectListByCustomerId(@Param("appId") String appId, @Param("customerId") String customerId,
@Param("clientType") String clientType);
/**
* @return
* @Description 居民端工作端-获取客户小程序模板列表
* @author sun
*/
List<GetTemplateListResultDTO> selectTemplateList(GetTemplateListFormDTO formDTO);
}

9
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java

@ -20,6 +20,8 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.PersonalTemplateDTO;
import com.epmet.dto.form.GetTemplateListFormDTO;
import com.epmet.dto.result.GetTemplateListResultDTO;
import com.epmet.dto.result.TemplateDTO;
import com.epmet.entity.PersonalTemplateEntity;
@ -123,4 +125,11 @@ public interface PersonalTemplateService extends BaseService<PersonalTemplateEnt
* @date 2020/9/11 14:43
*/
List<TemplateDTO> getListByCustomer(String appId, String customerId, String clientType);
/**
* @return
* @Description 居民端工作端-获取客户小程序模板列表
* @author sun
*/
List<GetTemplateListResultDTO> templateList(GetTemplateListFormDTO formDTO);
}

13
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java

@ -25,6 +25,8 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.PersonalTemplateDao;
import com.epmet.dto.PersonalTemplateDTO;
import com.epmet.dto.form.GetTemplateListFormDTO;
import com.epmet.dto.result.GetTemplateListResultDTO;
import com.epmet.dto.result.TemplateDTO;
import com.epmet.entity.PersonalTemplateEntity;
import com.epmet.service.PersonalTemplateService;
@ -116,4 +118,15 @@ public class PersonalTemplateServiceImpl extends BaseServiceImpl<PersonalTemplat
return baseDao.selectListByCustomerId(appId, customerId, clientType);
}
/**
* @return
* @Description 居民端工作端-获取客户小程序模板列表
* @author sun
*/
@Override
public List<GetTemplateListResultDTO> templateList(GetTemplateListFormDTO formDTO) {
//根据客户Id、appId、模板类型查询小程序订阅消息模板列表
return baseDao.selectTemplateList(formDTO);
}
}

13
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml

@ -75,5 +75,18 @@
ON t1.PRI_TMPL_ID = t2.PID
</select>
<select id="selectTemplateList" resultType="com.epmet.dto.result.GetTemplateListResultDTO">
SELECT
title AS "templateType",
pri_tmpl_id AS "templateId"
FROM
personal_template
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND app_id = #{appId}
AND title = #{templateType}
ORDER BY CREATED_TIME DESC
</select>
</mapper>

5
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/UserMessageConstant.java

@ -59,4 +59,9 @@ public interface UserMessageConstant {
*/
String CREATION_OF_GROUP_MESSAGE_TEMPLATE = "%s%s申请创建小组【%s】,请审核。";
/**
* 组长审核入组申请时的微信订阅behavior
*/
String WX_APPLY_GROUP_BEHAVIOR = "小组消息";
}

25
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/impl/ResiGroupMemberServiceImpl.java

@ -34,6 +34,7 @@ import com.epmet.constant.ReadFlagConstant;
import com.epmet.dto.form.UserMessageFormDTO;
import com.epmet.dto.form.UserResiInfoFormDTO;
import com.epmet.dto.form.UserResiInfoListFormDTO;
import com.epmet.dto.form.WxSubscribeMessageFormDTO;
import com.epmet.dto.result.UserResiInfoResultDTO;
import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.modules.constant.GroupMemberConstant;
@ -435,7 +436,7 @@ public class ResiGroupMemberServiceImpl extends BaseServiceImpl<ResiGroupMemberD
* @return void
* @param resiGroupMemberDTO
* @Author yinzuomei
* @Description 用户会收到您有一条小组消息 您加入的组名已通过审核请查看
* @Description 用户会收到您有一条小组消息 您加入的组名已通过审核请查看发送微信订阅通知
* @Date 2020/4/7 15:39
**/
private void sendUserApprovedMessage(ResiGroupMemberDTO resiGroupMemberDTO) {
@ -452,6 +453,16 @@ public class ResiGroupMemberServiceImpl extends BaseServiceImpl<ResiGroupMemberD
//通知群主
userMessage.setUserId(resiGroupMemberDTO.getCustomerUserId());
epmetMessageOpenFeignClient.saveUserMessage(userMessage);
//2 给用户发送微信订阅
WxSubscribeMessageFormDTO wxSubscribeMessageFormDTO = new WxSubscribeMessageFormDTO();
wxSubscribeMessageFormDTO.setCustomerId(resiGroupMemberDTO.getCustomerId());
wxSubscribeMessageFormDTO.setUserId(resiGroupMemberDTO.getCustomerUserId());
wxSubscribeMessageFormDTO.setClientType(AppClientConstant.APP_RESI);
wxSubscribeMessageFormDTO.setBehaviorType(UserMessageConstant.WX_APPLY_GROUP_BEHAVIOR);
wxSubscribeMessageFormDTO.setMessageContent(messageContent);
List<WxSubscribeMessageFormDTO> msgList = new ArrayList<>();
msgList.add(wxSubscribeMessageFormDTO);
epmetMessageOpenFeignClient.sendWxSubscribeMessage(msgList);
}
/**
@ -500,7 +511,7 @@ public class ResiGroupMemberServiceImpl extends BaseServiceImpl<ResiGroupMemberD
* @param groupMemeberOperationDTO
* @param disagreeApplyFormDTO
* @Author yinzuomei
* @Description 您在组名的入组申请被拒绝原因组长拒绝审核时输入的备注
* @Description 您在组名的入组申请被拒绝原因组长拒绝审核时输入的备注 发送微信订阅
* @Date 2020/4/7 15:39
**/
private void sendUserRejectedMessage(GroupMemeberOperationDTO groupMemeberOperationDTO,DisagreeApplyFormDTO disagreeApplyFormDTO) {
@ -517,6 +528,16 @@ public class ResiGroupMemberServiceImpl extends BaseServiceImpl<ResiGroupMemberD
//通知群主
userMessage.setUserId(groupMemeberOperationDTO.getCustomerUserId());
epmetMessageOpenFeignClient.saveUserMessage(userMessage);
//2 给用户发送微信订阅
WxSubscribeMessageFormDTO wxSubscribeMessageFormDTO = new WxSubscribeMessageFormDTO();
wxSubscribeMessageFormDTO.setCustomerId(resiGroupDTO.getCustomerId());
wxSubscribeMessageFormDTO.setUserId(groupMemeberOperationDTO.getCustomerUserId());
wxSubscribeMessageFormDTO.setClientType(AppClientConstant.APP_RESI);
wxSubscribeMessageFormDTO.setBehaviorType(UserMessageConstant.WX_APPLY_GROUP_BEHAVIOR);
wxSubscribeMessageFormDTO.setMessageContent(messageContent);
List<WxSubscribeMessageFormDTO> msgList = new ArrayList<>();
msgList.add(wxSubscribeMessageFormDTO);
epmetMessageOpenFeignClient.sendWxSubscribeMessage(msgList);
}
/**

12
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java

@ -23,6 +23,7 @@ import com.epmet.modules.feign.ResiGroupFeignClient;
import com.epmet.modules.partymember.entity.*;
import com.epmet.modules.partymember.redis.PartymemberInfoRedis;
import com.epmet.modules.partymember.service.*;
import com.epmet.modules.warmhearted.constant.ResiWarmUserMessageConstant;
import com.epmet.modules.warmhearted.constant.ResiWarmheartedConstant;
import com.epmet.modules.warmhearted.constant.ResiWarmheartedVisitConstant;
import com.epmet.redis.ResiPartyMemberRedis;
@ -644,6 +645,17 @@ public class PartyMemberConfirmServiceImpl implements PartyMemberConfirmService
String messageContent = String.format(userMsg, gridName);
userMessageFormDTO.setMessageContent(messageContent);
userMessageFormDTO.setReadFlag(ReadFlagConstant.UN_READ);
//发送微信订阅消息
WxSubscribeMessageFormDTO wxSubscribeMessageFormDTO = new WxSubscribeMessageFormDTO();
wxSubscribeMessageFormDTO.setCustomerId(formDTO.getCustomerId());
wxSubscribeMessageFormDTO.setUserId(formDTO.getUserId());
wxSubscribeMessageFormDTO.setClientType(AppClientConstant.APP_RESI);
wxSubscribeMessageFormDTO.setBehaviorType(ResiWarmUserMessageConstant.WX_WARMHEARTED_BEHAVIOR);
wxSubscribeMessageFormDTO.setMessageContent(messageContent);
List<WxSubscribeMessageFormDTO> msgList = new ArrayList<>();
msgList.add(wxSubscribeMessageFormDTO);
epmetMessageOpenFeignClient.sendWxSubscribeMessage(msgList);
//保存消息
return epmetMessageOpenFeignClient.saveUserMessage(userMessageFormDTO);
}

5
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/warmhearted/constant/ResiWarmUserMessageConstant.java

@ -26,4 +26,9 @@ public interface ResiWarmUserMessageConstant {
*/
String AUDIT_REJECT_MSG = "您好,您申请的%s热心居民,已被驳回,原因:%s";
/**
* 热心居民申请-微信订阅behavior
*/
String WX_WARMHEARTED_BEHAVIOR = "热心居民申请消息";
}

15
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/warmhearted/service/impl/ResiWarmheartedApplyServiceImpl.java

@ -39,6 +39,7 @@ import com.epmet.dto.form.*;
import com.epmet.dto.result.AgencyAndStaffsResultDTO;
import com.epmet.dto.result.GovStaffRoleResultDTO;
import com.epmet.dto.result.UserResiInfoResultDTO;
import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.modules.feign.EpmetMessageFeignClient;
import com.epmet.modules.feign.EpmetUserFeignClient;
import com.epmet.modules.feign.GovOrgFeignClient;
@ -90,6 +91,8 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmhea
@Autowired
private EpmetMessageFeignClient epmetMessageFeignClient;
@Autowired
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
@Autowired
private GovOrgFeignClient govOrgFeignClient;
@Autowired
private ResiPartyMemberRedis resiPartyMemberRedis;
@ -438,6 +441,18 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmhea
String messageContent = String.format(userMsg, gridName,formDTO.getRefuseReason());
userMessageFormDTO.setMessageContent(messageContent);
userMessageFormDTO.setReadFlag(ReadFlagConstant.UN_READ);
//发送微信订阅
WxSubscribeMessageFormDTO wxSubscribeMessageFormDTO = new WxSubscribeMessageFormDTO();
wxSubscribeMessageFormDTO.setCustomerId(formDTO.getCustomerId());
wxSubscribeMessageFormDTO.setUserId(formDTO.getUserId());
wxSubscribeMessageFormDTO.setClientType(AppClientConstant.APP_RESI);
wxSubscribeMessageFormDTO.setBehaviorType(ResiWarmUserMessageConstant.WX_WARMHEARTED_BEHAVIOR);
wxSubscribeMessageFormDTO.setMessageContent(messageContent);
List<WxSubscribeMessageFormDTO> msgList = new ArrayList<>();
msgList.add(wxSubscribeMessageFormDTO);
epmetMessageOpenFeignClient.sendWxSubscribeMessage(msgList);
//保存消息
return epmetMessageFeignClient.saveUserMessage(userMessageFormDTO);
}

Loading…
Cancel
Save