|
|
@ -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.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 com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
@ -44,56 +45,61 @@ public class PostponeClientTask {
|
|
|
|
private ClientAccountMapper clientAccountMapper;
|
|
|
|
private ClientAccountMapper clientAccountMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private ManagerMapper managerMapper;
|
|
|
|
private ManagerMapper managerMapper;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private SynchronizedScheduler synchronizedScheduler;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Scheduled(cron = "0 30 8 * * ?")
|
|
|
|
@Scheduled(cron = "0 30 8 * * ?")
|
|
|
|
public void checkGreenChannel() {
|
|
|
|
public void checkGreenChannel() {
|
|
|
|
Date now = new Date();
|
|
|
|
synchronizedScheduler.executeProcess("manage_task:postPoneClient", 120_000, () -> {
|
|
|
|
Date tomorrow = DateUtils.addDays(now, 1);
|
|
|
|
Date now = new Date();
|
|
|
|
Date yearTomorrow = DateUtils.addYears(tomorrow, 1);
|
|
|
|
Date tomorrow = DateUtils.addDays(now, 1);
|
|
|
|
String expireDate = DateFormatUtils.format(yearTomorrow, "yyyy-MM-dd");
|
|
|
|
Date yearTomorrow = DateUtils.addYears(tomorrow, 1);
|
|
|
|
List<JSONObject> expiryClient = clientRateMapper.getAllExpiry(now);
|
|
|
|
String expireDate = DateFormatUtils.format(yearTomorrow, "yyyy-MM-dd");
|
|
|
|
|
|
|
|
List<JSONObject> expiryClient = clientRateMapper.getAllExpiry(now);
|
|
|
|
if(CollectionUtils.isEmpty(expiryClient)){
|
|
|
|
|
|
|
|
return;
|
|
|
|
if (CollectionUtils.isEmpty(expiryClient)) {
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
Map<Integer, JSONObject> expiryClients = new HashMap<>();
|
|
|
|
|
|
|
|
expiryClient.forEach(p -> {
|
|
|
|
|
|
|
|
expiryClients.put(p.getInteger("client_id"), p);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
expiryClients.values().forEach(p -> {
|
|
|
|
|
|
|
|
int client_id = p.getIntValue("client_id");
|
|
|
|
|
|
|
|
List<JSONObject> adminAccounts = clientAccountMapper.listAdminAccounts(client_id);
|
|
|
|
|
|
|
|
List<JSONObject> clientRates = clientRateMapper.maxChannelExpiryTime(client_id, null);
|
|
|
|
|
|
|
|
JSONObject wechatRate = clientRateMapper.latestChannelCleanDays("Wechat", p.getIntValue("client_id"));
|
|
|
|
|
|
|
|
int cleanDays = 1;
|
|
|
|
|
|
|
|
if (wechatRate.getInteger("clean_days") != null) {
|
|
|
|
|
|
|
|
cleanDays = wechatRate.getIntValue("clean_days");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
cleanDays = wechatRate.getIntValue("c_clean_days");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int finalCleanDays = cleanDays;
|
|
|
|
Map<Integer, JSONObject> expiryClients = new HashMap<>();
|
|
|
|
clientRates.forEach(o -> {
|
|
|
|
expiryClient.forEach(p -> {
|
|
|
|
JSONObject record = clientRateMapper.latestExpiryConfig(client_id,o.getString("rate_name"));
|
|
|
|
expiryClients.put(p.getInteger("client_id"), p);
|
|
|
|
record.remove("client_rate_id");
|
|
|
|
|
|
|
|
record.put("active_time", now);
|
|
|
|
|
|
|
|
record.put("manager_id", 0);
|
|
|
|
|
|
|
|
record.put("expiry_time", yearTomorrow);
|
|
|
|
|
|
|
|
record.put("create_time", now);
|
|
|
|
|
|
|
|
record.put("update_time", now);
|
|
|
|
|
|
|
|
record.put("clean_days", finalCleanDays);
|
|
|
|
|
|
|
|
record.put("manager_name", "System");
|
|
|
|
|
|
|
|
record.put("remark", "费率到期系统自动延期1年");
|
|
|
|
|
|
|
|
clientRateMapper.saveRate(record);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
adminAccounts.forEach(o -> {
|
|
|
|
expiryClients.values().forEach(p -> {
|
|
|
|
sendClientPostponeNotify(o, expireDate);
|
|
|
|
int client_id = p.getIntValue("client_id");
|
|
|
|
|
|
|
|
List<JSONObject> adminAccounts = clientAccountMapper.listAdminAccounts(client_id);
|
|
|
|
|
|
|
|
List<JSONObject> clientRates = clientRateMapper.maxChannelExpiryTime(client_id, null);
|
|
|
|
|
|
|
|
JSONObject wechatRate = clientRateMapper.latestChannelCleanDays("Wechat", p.getIntValue("client_id"));
|
|
|
|
|
|
|
|
int cleanDays = 1;
|
|
|
|
|
|
|
|
if (wechatRate.getInteger("clean_days") != null) {
|
|
|
|
|
|
|
|
cleanDays = wechatRate.getIntValue("clean_days");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
cleanDays = wechatRate.getIntValue("c_clean_days");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int finalCleanDays = cleanDays;
|
|
|
|
|
|
|
|
clientRates.forEach(o -> {
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
record.put("expiry_time", yearTomorrow);
|
|
|
|
|
|
|
|
record.put("create_time", now);
|
|
|
|
|
|
|
|
record.put("update_time", now);
|
|
|
|
|
|
|
|
record.put("clean_days", finalCleanDays);
|
|
|
|
|
|
|
|
record.put("manager_name", "System");
|
|
|
|
|
|
|
|
record.put("remark", "费率到期系统自动延期1年");
|
|
|
|
|
|
|
|
clientRateMapper.saveRate(record);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
adminAccounts.forEach(o -> {
|
|
|
|
|
|
|
|
sendClientPostponeNotify(o, expireDate);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
sendComplianceNotify(expiryClients, expireDate);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
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"));
|
|
|
|
JSONObject client = clientManager.getClientInfo(account.getIntValue("client_id"));
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -101,8 +107,8 @@ public class PostponeClientTask {
|
|
|
|
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) {
|
|
|
@ -129,7 +135,7 @@ public class PostponeClientTask {
|
|
|
|
private TemplateMessage initClientMessage(JSONObject client, String newExpiryDate, String wechatOpenid, String templateId) {
|
|
|
|
private TemplateMessage initClientMessage(JSONObject client, String newExpiryDate, String wechatOpenid, String templateId) {
|
|
|
|
TemplateMessage notice = new TemplateMessage(wechatOpenid, templateId, null);
|
|
|
|
TemplateMessage notice = new TemplateMessage(wechatOpenid, templateId, null);
|
|
|
|
notice.put("first", "您好,您的合同费率已到期,根据合同协议系统已自动为您延期1年。", "#ff0000");
|
|
|
|
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("keyword2", newExpiryDate, "#0000ff");
|
|
|
|
notice.put("remark", "如有疑问请联系RoyalPay", "#000000");
|
|
|
|
notice.put("remark", "如有疑问请联系RoyalPay", "#000000");
|
|
|
|
return notice;
|
|
|
|
return notice;
|
|
|
|