|
|
|
@ -1,13 +1,9 @@
|
|
|
|
|
package au.com.royalpay.payment.manage.task;
|
|
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.channels.rpay.runtime.RpayApi;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
|
|
|
|
|
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.ClientModifySupport;
|
|
|
|
|
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.beans.TemplateMessage;
|
|
|
|
|
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
|
|
|
|
@ -21,7 +17,6 @@ import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
@ -44,17 +39,9 @@ public class PostponeClientTask {
|
|
|
|
|
@Resource
|
|
|
|
|
private ClientManager clientManager;
|
|
|
|
|
@Resource
|
|
|
|
|
private ClientAccountMapper clientAccountMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private ManagerMapper managerMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private SynchronizedScheduler synchronizedScheduler;
|
|
|
|
|
@Resource
|
|
|
|
|
private ClientModifySupport clientModifySupport;
|
|
|
|
|
@Resource
|
|
|
|
|
private RpayApi rpayApi;
|
|
|
|
|
@Resource
|
|
|
|
|
private ClientMapper clientMapper;
|
|
|
|
|
|
|
|
|
|
@Scheduled(cron = "0 30 8 * * ?")
|
|
|
|
|
public void postponeClient() {
|
|
|
|
@ -70,9 +57,9 @@ public class PostponeClientTask {
|
|
|
|
|
}
|
|
|
|
|
for (JSONObject p : expiryClient) {
|
|
|
|
|
try {
|
|
|
|
|
modifyRate(now, yearTomorrow, expireDate, p, sb);
|
|
|
|
|
clientManager.postponeClientRate(now, yearTomorrow, expireDate, p, sb);
|
|
|
|
|
} catch (Exception ignore) {
|
|
|
|
|
continue;
|
|
|
|
|
logger.info("a",ignore);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sb.deleteCharAt(sb.length() - 1);
|
|
|
|
@ -80,82 +67,15 @@ public class PostponeClientTask {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
public void modifyRate(Date now, Date yearTomorrow, String expireDate, JSONObject p, StringBuilder sb) {
|
|
|
|
|
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);
|
|
|
|
|
if ("Rpay".equals(o.getString("rate_name"))) {
|
|
|
|
|
rpayApi.modifySurchargeConfig(clientMapper.findClient(client_id));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(null, p.getString("client_moniker"), "tax_in_surcharge", false));
|
|
|
|
|
adminAccounts.forEach(o -> {
|
|
|
|
|
sendClientPostponeNotify(o, expireDate);
|
|
|
|
|
});
|
|
|
|
|
sb.append(p.getString("client_moniker"));
|
|
|
|
|
sb.append("、");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void sendClientPostponeNotify(JSONObject account, String newExpireDate) {
|
|
|
|
|
// JSONObject client = clientManager.getClientInfo(account.getIntValue("client_id"));
|
|
|
|
|
//
|
|
|
|
|
// try {
|
|
|
|
|
// if (StringUtils.isEmpty(account.getString("wechat_openid"))) {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// MpWechatApi api = mpWechatApiProvider.getApiFromOpenId(account.getString("wechat_openid"));
|
|
|
|
|
// if (api != null) {
|
|
|
|
|
// String templateId = api.getTemplateId("client-postpone");
|
|
|
|
|
// if (templateId != null) {
|
|
|
|
|
// TemplateMessage notice = initClientMessage(client, newExpireDate, account.getString("wechat_openid"), templateId);
|
|
|
|
|
// api.sendTemplateMessage(notice);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// logger.error("Sending Notify failure", e);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void sendComplianceNotify(StringBuilder sb, String newExpireDate) {
|
|
|
|
|
// List<String> compliance = managerMapper.listOpenIdsOfCompliances();
|
|
|
|
|
// compliance.forEach(p -> {
|
|
|
|
|
// MpWechatApi api = mpWechatApiProvider.getApiFromOpenId(p);
|
|
|
|
|
// TemplateMessage notice = initComplianceMessage(sb.toString(), newExpireDate, p, api.getTemplateId("client-postpone"));
|
|
|
|
|
// api.sendTemplateMessage(notice);
|
|
|
|
|
// });
|
|
|
|
|
List<String> compliance = managerMapper.listOpenIdsOfCompliances();
|
|
|
|
|
compliance.forEach(p -> {
|
|
|
|
|
MpWechatApi api = mpWechatApiProvider.getApiFromOpenId(p);
|
|
|
|
|
TemplateMessage notice = initComplianceMessage(sb.toString(), newExpireDate, p, api.getTemplateId("client-postpone"));
|
|
|
|
|
api.sendTemplateMessage(notice);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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("keyword2", newExpiryDate, "#0000ff");
|
|
|
|
|
notice.put("remark", "如有疑问请联系RoyalPay", "#000000");
|
|
|
|
|
return notice;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private TemplateMessage initComplianceMessage(String clients, String newExpiryDate, String wechatOpenid, String templateId) {
|
|
|
|
|
TemplateMessage notice = new TemplateMessage(wechatOpenid, templateId, null);
|
|
|
|
|
notice.put("first", "以下商户据合同费率已经自动延期1年", "#ff0000");
|
|
|
|
@ -164,5 +84,4 @@ public class PostponeClientTask {
|
|
|
|
|
notice.put("remark", " ", "#000000");
|
|
|
|
|
return notice;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|