瀏覽代碼

推送的异常

wuwen 5 年之前
父節點
當前提交
843a54bc11

+ 37 - 31
src/main/java/com/ssj/service/weixin/push/service/impl/PushTemplateServiceImpl.java

@@ -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;
+							}
 						}
 					}
 				}

+ 2 - 2
src/main/java/com/ssj/service/weixin/sales/service/impl/LibVipServiceServiceImpl.java

@@ -1703,7 +1703,7 @@ public class LibVipServiceServiceImpl extends BaseServiceImpl<LibVipService, Str
             this.insertLibService(vipId, libId, endDate);
         } else {
             //老套餐,只需要给指定的校区服务
-            this.insertLibService(vipId, libId, endDate);
+            this.insertLibService(vipId, libId, DateUtil.parse_yyyyMMdd("9999-01-01"));
         }
     }
 
@@ -1731,7 +1731,7 @@ public class LibVipServiceServiceImpl extends BaseServiceImpl<LibVipService, Str
      */
     Date getEndDate(String vipId, String libId) {
         Merchant merchant=merchantService.getMerchantByLibId(libId);
-        return merchant.getNextSummaryTime();
+        return DateHelper.getMonthDate(merchant.getCurSummaryTime(),merchant.getLibServiceMonth());
     }
 
 

+ 2 - 2
src/main/java/com/ssj/util/WxTemplateCacheUtils.java

@@ -80,14 +80,14 @@ public class WxTemplateCacheUtils {
     	List<String> longList = redisUtil.lrange(TaskConstant.LONG_KEY,0,-1);
     	for (String str : longList) {
     		JSONObject json=JSONObject.parseObject(str);
-    		if(templateIdShort.equals(json.getString("templateIdShort"))){
+    		if(json.containsKey("templateIdShort") && templateIdShort.equals(json.getString("templateIdShort"))){
     			return JSONObject.toJavaObject(json,TbWxTemplate.class);
     		}
 		}
     	List<String> tempList = redisUtil.lrange(TaskConstant.TEMP_KEY,0,-1);
     	for (String str : tempList) {
     		JSONObject json=JSONObject.parseObject(str);
-    		if(templateIdShort.equals(json.getString("templateIdShort"))){
+    		if(json.containsKey("templateIdShort") && templateIdShort.equals(json.getString("templateIdShort"))){
     			return JSONObject.toJavaObject(json,TbWxTemplate.class);
     		}
 		}