|
@@ -137,43 +137,49 @@ public class PushTemplateServiceImpl extends BaseServiceImpl<PushTemplate, Stri
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
- TbWxTemplate tbWxTemplate= WxTemplateCacheUtils.getTbWxTemplate(pushTemplate.getWxTplSid(),null,null);
|
|
|
- if(tbWxTemplate==null || StringUtils.isEmpty(tbWxTemplate.getTemplateId())){
|
|
|
- pushTemplate.setRemark("模板池无法得到微信模板ID...");
|
|
|
- pushTemplate.setTryTime(pushTemplate.getTryTime()+1);
|
|
|
+ if(StringUtils.isEmpty(pushTemplate.getWxTplSid())){
|
|
|
+ pushTemplate.setRemark("WxTplSid为空,请注意检查来源代码逻辑...");
|
|
|
+ pushTemplate.setTryTime(7);
|
|
|
errorNum=errorNum+1;
|
|
|
}else if(StringUtils.isEmpty(pushTemplate.getOpenid())){
|
|
|
pushTemplate.setRemark("OPENID为空,请注意检查来源代码逻辑...");
|
|
|
- pushTemplate.setTryTime(pushTemplate.getTryTime()+1);
|
|
|
+ pushTemplate.setTryTime(7);
|
|
|
errorNum=errorNum+1;
|
|
|
- }else{
|
|
|
- String msg= NewsUtil.WX_TPL_BODY
|
|
|
- .replace(NewsUtil.TPL_CODE_OPENID, pushTemplate.getOpenid())
|
|
|
- .replace(NewsUtil.TPL_CODE_TPLID, tbWxTemplate.getTemplateId())
|
|
|
- .replace(NewsUtil.TPL_CODE_URL, StringUtils.isNotEmpty(pushTemplate.getClickUrl())?pushTemplate.getClickUrl():"")
|
|
|
- .replace(NewsUtil.TPL_CODE_DATA, pushTemplate.getContent())
|
|
|
- .replace(NewsUtil.TPL_CODE_TOPCOLOR, StringUtils.isNotEmpty(pushTemplate.getTopColor())?pushTemplate.getTopColor():"");
|
|
|
- if(StringUtils.isNotEmpty(pushTemplate.getMiniprogram())){
|
|
|
- msg=msg.replace(NewsUtil.TPL_CODE_MINIPROQRAM_TEXT, NewsUtil.TPL_SUB_MINIPROQRAM_DATA);
|
|
|
- msg=msg.replace(NewsUtil.MINIPROQRAM_DATA, pushTemplate.getMiniprogram());
|
|
|
+ }else {
|
|
|
+ TbWxTemplate tbWxTemplate= WxTemplateCacheUtils.getTbWxTemplate(pushTemplate.getWxTplSid(),null,null);
|
|
|
+ if(tbWxTemplate==null || StringUtils.isEmpty(tbWxTemplate.getTemplateId())){
|
|
|
+ pushTemplate.setRemark("模板池无法得到微信模板ID...");
|
|
|
+ pushTemplate.setTryTime(pushTemplate.getTryTime()+1);
|
|
|
+ errorNum=errorNum+1;
|
|
|
}else{
|
|
|
- msg=msg.replace(NewsUtil.TPL_CODE_MINIPROQRAM_TEXT, "");
|
|
|
- }
|
|
|
- //再去查询,防止重复推送,定时推送数据锁定一分钟
|
|
|
- if(StringUtils.isNotEmpty(pushTemplate.getId())){
|
|
|
- pushTemplate=this.getById(pushTemplate.getId());
|
|
|
- }
|
|
|
- if(pushTemplate.getIsSuccess()==0){
|
|
|
- JSONObject result = NewsUtil.sendTemplate(tokenManager.getSSJAccessToken(), msg);
|
|
|
- if(result != null && "0".equals(result.getString("errcode"))){
|
|
|
- pushTemplate.setIsSuccess(1);
|
|
|
- pushTemplate.setSuccessTime(new Date());
|
|
|
- pushTemplate.setCurTotal(pushTemplate.getCurTotal()+1);
|
|
|
- pushTemplate.setRemark("");
|
|
|
+ String msg= NewsUtil.WX_TPL_BODY
|
|
|
+ .replace(NewsUtil.TPL_CODE_OPENID, pushTemplate.getOpenid())
|
|
|
+ .replace(NewsUtil.TPL_CODE_TPLID, tbWxTemplate.getTemplateId())
|
|
|
+ .replace(NewsUtil.TPL_CODE_URL, StringUtils.isNotEmpty(pushTemplate.getClickUrl())?pushTemplate.getClickUrl():"")
|
|
|
+ .replace(NewsUtil.TPL_CODE_DATA, pushTemplate.getContent())
|
|
|
+ .replace(NewsUtil.TPL_CODE_TOPCOLOR, StringUtils.isNotEmpty(pushTemplate.getTopColor())?pushTemplate.getTopColor():"");
|
|
|
+ if(StringUtils.isNotEmpty(pushTemplate.getMiniprogram())){
|
|
|
+ msg=msg.replace(NewsUtil.TPL_CODE_MINIPROQRAM_TEXT, NewsUtil.TPL_SUB_MINIPROQRAM_DATA);
|
|
|
+ msg=msg.replace(NewsUtil.MINIPROQRAM_DATA, pushTemplate.getMiniprogram());
|
|
|
}else{
|
|
|
- pushTemplate.setTryTime(pushTemplate.getTryTime()+1);
|
|
|
- pushTemplate.setRemark("errcode:"+result.getString("errcode"));
|
|
|
- errorNum=errorNum+1;
|
|
|
+ msg=msg.replace(NewsUtil.TPL_CODE_MINIPROQRAM_TEXT, "");
|
|
|
+ }
|
|
|
+ //再去查询,防止重复推送,定时推送数据锁定一分钟
|
|
|
+ if(StringUtils.isNotEmpty(pushTemplate.getId())){
|
|
|
+ pushTemplate=this.getById(pushTemplate.getId());
|
|
|
+ }
|
|
|
+ if(pushTemplate.getIsSuccess()==0){
|
|
|
+ JSONObject result = NewsUtil.sendTemplate(tokenManager.getSSJAccessToken(), msg);
|
|
|
+ if(result != null && "0".equals(result.getString("errcode"))){
|
|
|
+ pushTemplate.setIsSuccess(1);
|
|
|
+ pushTemplate.setSuccessTime(new Date());
|
|
|
+ pushTemplate.setCurTotal(pushTemplate.getCurTotal()+1);
|
|
|
+ pushTemplate.setRemark("");
|
|
|
+ }else{
|
|
|
+ pushTemplate.setTryTime(pushTemplate.getTryTime()+1);
|
|
|
+ pushTemplate.setRemark("errcode:"+result.getString("errcode"));
|
|
|
+ errorNum=errorNum+1;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|