|
|
|
@ -8,6 +8,7 @@ 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.beans.TemplateMessage;
|
|
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
@ -44,16 +45,20 @@ public class PostponeClientTask {
|
|
|
|
|
private ClientAccountMapper clientAccountMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private ManagerMapper managerMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private SynchronizedScheduler synchronizedScheduler;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Scheduled(cron = "0 30 8 * * ?")
|
|
|
|
|
public void checkGreenChannel() {
|
|
|
|
|
synchronizedScheduler.executeProcess("manage_task:postPoneClient", 120_000, () -> {
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
Date tomorrow = DateUtils.addDays(now, 1);
|
|
|
|
|
Date yearTomorrow = DateUtils.addYears(tomorrow, 1);
|
|
|
|
|
String expireDate = DateFormatUtils.format(yearTomorrow, "yyyy-MM-dd");
|
|
|
|
|
List<JSONObject> expiryClient = clientRateMapper.getAllExpiry(now);
|
|
|
|
|
|
|
|
|
|
if(CollectionUtils.isEmpty(expiryClient)){
|
|
|
|
|
if (CollectionUtils.isEmpty(expiryClient)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Map<Integer, JSONObject> expiryClients = new HashMap<>();
|
|
|
|
@ -73,7 +78,7 @@ public class PostponeClientTask {
|
|
|
|
|
}
|
|
|
|
|
int finalCleanDays = cleanDays;
|
|
|
|
|
clientRates.forEach(o -> {
|
|
|
|
|
JSONObject record = clientRateMapper.latestExpiryConfig(client_id,o.getString("rate_name"));
|
|
|
|
|
JSONObject record = clientRateMapper.latestExpiryConfig(client_id, o.getString("rate_name"));
|
|
|
|
|
record.remove("client_rate_id");
|
|
|
|
|
record.put("active_time", now);
|
|
|
|
|
record.put("manager_id", 0);
|
|
|
|
@ -91,9 +96,10 @@ public class PostponeClientTask {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
sendComplianceNotify(expiryClients, expireDate);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void sendClientPostponeNotify(JSONObject account,String newExpireDate) {
|
|
|
|
|
private void sendClientPostponeNotify(JSONObject account, String newExpireDate) {
|
|
|
|
|
JSONObject client = clientManager.getClientInfo(account.getIntValue("client_id"));
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
@ -101,7 +107,7 @@ public class PostponeClientTask {
|
|
|
|
|
if (api != null) {
|
|
|
|
|
String templateId = api.getTemplateId("client-postpone");
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -129,7 +135,7 @@ public class PostponeClientTask {
|
|
|
|
|
private TemplateMessage initClientMessage(JSONObject client, String newExpiryDate, String wechatOpenid, String templateId) {
|
|
|
|
|
TemplateMessage notice = new TemplateMessage(wechatOpenid, templateId, null);
|
|
|
|
|
notice.put("first", "您好,您的合同费率已到期,根据合同协议系统已自动为您延期1年。", "#ff0000");
|
|
|
|
|
notice.put("keyword1", client.getString("short_name")+"("+client.getString("client_moniker")+")", "#ff0000");
|
|
|
|
|
notice.put("keyword1", client.getString("short_name") + "(" + client.getString("client_moniker") + ")", "#ff0000");
|
|
|
|
|
notice.put("keyword2", newExpiryDate, "#0000ff");
|
|
|
|
|
notice.put("remark", "如有疑问请联系RoyalPay", "#000000");
|
|
|
|
|
return notice;
|
|
|
|
|