|
|
@ -90,8 +90,8 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { |
|
|
|
private WxmpUserSubscribeRecordDao subscribeRecordDao; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 保存系统授权信息 |
|
|
|
* @return void |
|
|
|
* @Description 保存系统授权信息 |
|
|
|
* @author wxz |
|
|
|
* @date 2020.10.21 17:29 |
|
|
|
*/ |
|
|
@ -139,7 +139,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { |
|
|
|
UserBasicInfoFormDTO userBasicInfoFormDTO = new UserBasicInfoFormDTO(); |
|
|
|
userBasicInfoFormDTO.setUserId(userId); |
|
|
|
openId = epmetUserOpenFeignClient.getUserBasicInfo(userBasicInfoFormDTO).getData().getOpenId(); |
|
|
|
} else if (WxmpMessageConstant.WORK.equals(clientType)) { |
|
|
|
} else if (WxmpMessageConstant.GOV_DB.equals(clientType)) { |
|
|
|
StaffBasicInfoFormDTO staffBasicInfoFormDTO = new StaffBasicInfoFormDTO(); |
|
|
|
staffBasicInfoFormDTO.setStaffId(userId); |
|
|
|
openId = epmetUserOpenFeignClient.getStaffBasicInfo(staffBasicInfoFormDTO).getData().getOpenId(); |
|
|
@ -155,7 +155,14 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { |
|
|
|
} |
|
|
|
|
|
|
|
//获取accessToken
|
|
|
|
StringBuilder key = new StringBuilder(msg.getCustomerId()).append(":").append(msg.getClientType()); |
|
|
|
String clientTypeRedis = null; |
|
|
|
if (WxmpMessageConstant.RESI.equals(msg.getClientType())){ |
|
|
|
clientTypeRedis = WxmpMessageConstant.RESI; |
|
|
|
} |
|
|
|
if (WxmpMessageConstant.GOV_DB.equals(msg.getClientType())){ |
|
|
|
clientTypeRedis = WxmpMessageConstant.GOV_REDIS; |
|
|
|
} |
|
|
|
StringBuilder key = new StringBuilder(msg.getCustomerId()).append(":").append(clientTypeRedis); |
|
|
|
Map<String, Object> authorizerRefreshToken = new HashMap<>(); |
|
|
|
try { |
|
|
|
authorizerRefreshToken = wxmpMessageRedis.getAuthorizerRefreshToken(key.toString()); |
|
|
@ -170,7 +177,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { |
|
|
|
//获取模板id
|
|
|
|
if (WxmpMessageConstant.RESI.equals(clientType)) { |
|
|
|
templateId = wxmpResiUserSubscribeDao.getResiSubscribeTemplateId(openId, customerId); |
|
|
|
} else if (WxmpMessageConstant.WORK.equals(clientType)) { |
|
|
|
} else if (WxmpMessageConstant.GOV_DB.equals(clientType)) { |
|
|
|
templateId = wxmpWorkUserSubscribeDao.getWorkSubscribeTemplateId(openId, customerId); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(templateId)) { |
|
|
@ -181,7 +188,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { |
|
|
|
Integer count = null; |
|
|
|
if (WxmpMessageConstant.RESI.equals(clientType)) { |
|
|
|
count = wxmpResiUserSubscribeDao.getResiSubscribeInfo(openId, templateId, customerId); |
|
|
|
} else if (WxmpMessageConstant.WORK.equals(clientType)) { |
|
|
|
} else if (WxmpMessageConstant.GOV_DB.equals(clientType)) { |
|
|
|
count = wxmpWorkUserSubscribeDao.getWorkSubscribeInfo(openId, templateId, customerId); |
|
|
|
} |
|
|
|
if (count == null) { |
|
|
@ -199,15 +206,22 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { |
|
|
|
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(msg.getMessageTime()))); |
|
|
|
String title = "您有一条" + msg.getBehaviorType(); |
|
|
|
JSONObject titleJson = new JSONObject(); |
|
|
|
titleJson.put("value", title.length() > WxmpMessageConstant.TITLE_LIMIT ? title.substring(0, WxmpMessageConstant.TITLE_LIMIT) : title); |
|
|
|
data.put(WxmpMessageConstant.TITLE, titleJson); |
|
|
|
JSONObject contentJson = new JSONObject(); |
|
|
|
contentJson.put("value", msg.getMessageContent().length() > WxmpMessageConstant.MESSAGE_CONTENT_LIMIT ? msg.getMessageContent().substring(0, WxmpMessageConstant.MESSAGE_CONTENT_LIMIT) : msg.getMessageContent()); |
|
|
|
data.put(WxmpMessageConstant.MESSAGE_CONTENT, contentJson); |
|
|
|
JSONObject timeJson = new JSONObject(); |
|
|
|
timeJson.put("value", new SimpleDateFormat("yyyy-MM-dd HH:mm").format(msg.getMessageTime())); |
|
|
|
data.put(WxmpMessageConstant.MESSAGE_TIME,timeJson); |
|
|
|
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)) { |
|
|
|
} else if (WxmpMessageConstant.GOV_DB.equals(clientType)) { |
|
|
|
jsonObject.put(WxmpMessageConstant.PAGE, WxmpMessageConstant.PAGE_WORK); |
|
|
|
} |
|
|
|
//开发环境
|
|
|
@ -229,7 +243,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { |
|
|
|
int decrease = 0; |
|
|
|
if (WxmpMessageConstant.RESI.equals(clientType)) { |
|
|
|
decrease = wxmpResiUserSubscribeDao.decreaseResiSubscribeCount(openId, templateId, customerId, 1); |
|
|
|
} else if (WxmpMessageConstant.WORK.equals(clientType)) { |
|
|
|
} else if (WxmpMessageConstant.GOV_DB.equals(clientType)) { |
|
|
|
decrease = wxmpWorkUserSubscribeDao.decreaseWorkSubscribeCount(openId, templateId, customerId, 1); |
|
|
|
} |
|
|
|
if (decrease == 0) { |
|
|
@ -247,7 +261,7 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { |
|
|
|
int clear = 0; |
|
|
|
if (WxmpMessageConstant.RESI.equals(clientType)) { |
|
|
|
clear = wxmpResiUserSubscribeDao.clearResiSubscribeCount(openId, templateId, customerId); |
|
|
|
} else if (WxmpMessageConstant.WORK.equals(clientType)) { |
|
|
|
} else if (WxmpMessageConstant.GOV_DB.equals(clientType)) { |
|
|
|
clear = wxmpWorkUserSubscribeDao.clearWorkSubscribeCount(openId, templateId, customerId); |
|
|
|
} |
|
|
|
if (clear == 0) { |
|
|
@ -377,8 +391,8 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 保存居民端微信订阅信息 |
|
|
|
* @return void |
|
|
|
* @Description 保存居民端微信订阅信息 |
|
|
|
* @author wxz |
|
|
|
* @date 2020.10.22 09:56 |
|
|
|
*/ |
|
|
@ -404,8 +418,8 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 保存工作端订阅信息 |
|
|
|
* @return void |
|
|
|
* @Description 保存工作端订阅信息 |
|
|
|
* @author wxz |
|
|
|
* @date 2020.10.22 14:21 |
|
|
|
*/ |
|
|
@ -432,8 +446,8 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 根据UserId查询居民OpenId |
|
|
|
* @return string |
|
|
|
* @Description 根据UserId查询居民OpenId |
|
|
|
* @author wxz |
|
|
|
* @date 2020.10.22 13:35 |
|
|
|
*/ |
|
|
@ -452,8 +466,8 @@ public class WxmpMessageServiceImpl implements WxmpMessageService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 查询工作人员openId |
|
|
|
* @return java.lang.String |
|
|
|
* @Description 查询工作人员openId |
|
|
|
* @author wxz |
|
|
|
* @date 2020.10.22 14:46 |
|
|
|
*/ |
|
|
|