master
kira 6 years ago
parent 58fb928ef2
commit 701e1ceb80

@ -8,7 +8,6 @@ import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport; import au.com.royalpay.payment.manage.merchants.core.ClientModifySupport;
import au.com.royalpay.payment.manage.merchants.entity.impls.SwitchPermissionModify; import au.com.royalpay.payment.manage.merchants.entity.impls.SwitchPermissionModify;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider; import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage; import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler; import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
@ -24,10 +23,8 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.Date; import java.util.Date;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -68,7 +65,6 @@ public class PostponeClientTask {
String expireDate = DateFormatUtils.format(yearTomorrow, "yyyy-MM-dd"); String expireDate = DateFormatUtils.format(yearTomorrow, "yyyy-MM-dd");
List<JSONObject> expiryClient = clientRateMapper.getAllExpiry(now); List<JSONObject> expiryClient = clientRateMapper.getAllExpiry(now);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
List<JSONObject> successClients = new LinkedList<>();
if (CollectionUtils.isEmpty(expiryClient)) { if (CollectionUtils.isEmpty(expiryClient)) {
return; return;
} }
@ -122,32 +118,32 @@ public class PostponeClientTask {
} }
private void sendClientPostponeNotify(JSONObject account, String newExpireDate) { private void sendClientPostponeNotify(JSONObject account, String newExpireDate) {
JSONObject client = clientManager.getClientInfo(account.getIntValue("client_id")); // JSONObject client = clientManager.getClientInfo(account.getIntValue("client_id"));
//
try { // try {
if (StringUtils.isEmpty(account.getString("wechat_openid"))) { // if (StringUtils.isEmpty(account.getString("wechat_openid"))) {
return; // return;
} // }
MpWechatApi api = mpWechatApiProvider.getApiFromOpenId(account.getString("wechat_openid")); // MpWechatApi api = mpWechatApiProvider.getApiFromOpenId(account.getString("wechat_openid"));
if (api != null) { // if (api != null) {
String templateId = api.getTemplateId("client-postpone"); // String templateId = api.getTemplateId("client-postpone");
if (templateId != null) { // if (templateId != null) {
TemplateMessage notice = initClientMessage(client, newExpireDate, account.getString("wechat_openid"), templateId); // TemplateMessage notice = initClientMessage(client, newExpireDate, account.getString("wechat_openid"), templateId);
api.sendTemplateMessage(notice); // api.sendTemplateMessage(notice);
} // }
} // }
} catch (Exception e) { // } catch (Exception e) {
logger.error("Sending Notify failure", e); // logger.error("Sending Notify failure", e);
} // }
} }
private void sendComplianceNotify(StringBuilder sb, String newExpireDate) { private void sendComplianceNotify(StringBuilder sb, String newExpireDate) {
List<String> compliance = managerMapper.listOpenIdsOfCompliances(); // List<String> compliance = managerMapper.listOpenIdsOfCompliances();
compliance.forEach(p -> { // compliance.forEach(p -> {
MpWechatApi api = mpWechatApiProvider.getApiFromOpenId(p); // MpWechatApi api = mpWechatApiProvider.getApiFromOpenId(p);
TemplateMessage notice = initComplianceMessage(sb.toString(), newExpireDate, p, api.getTemplateId("client-postpone")); // TemplateMessage notice = initComplianceMessage(sb.toString(), newExpireDate, p, api.getTemplateId("client-postpone"));
api.sendTemplateMessage(notice); // api.sendTemplateMessage(notice);
}); // });
} }

Loading…
Cancel
Save