费率自动延期

master
taylor.dang 6 years ago
parent dd34208113
commit 8b813a0e51

@ -46,6 +46,10 @@ public interface ClientRateMapper {
List<JSONObject> getAllExpiry(@Param("expiry_date")Date expiry_date); List<JSONObject> getAllExpiry(@Param("expiry_date")Date expiry_date);
List<JSONObject> getAllClientRateExpiryMerchants();
void postponeMerchantRateByClientId(int clientId);
JSONObject latestChannelCleanDays(@Param("rate_name")String rate_name, @Param("client_id")int client_id); JSONObject latestChannelCleanDays(@Param("rate_name")String rate_name, @Param("client_id")int client_id);
JSONObject latestExpiryConfig(@Param("client_id")int client_id,@Param("rate_name") String rate_name); JSONObject latestExpiryConfig(@Param("client_id")int client_id,@Param("rate_name") String rate_name);

@ -342,4 +342,11 @@ public interface ClientManager {
void updateAllPartnerPassword(String clientMoniker, List<String> emails); void updateAllPartnerPassword(String clientMoniker, List<String> emails);
void postponeClientRate(Date now, Date yearTomorrow, String expireDate, JSONObject client); void postponeClientRate(Date now, Date yearTomorrow, String expireDate, JSONObject client);
/**
*
*
* @param clientId
*/
boolean postponeClientRate(int clientId, String clientMoniker,String nextYearExipryDate);
} }

@ -4029,6 +4029,23 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}); });
} }
@Override
@Transactional
public boolean postponeClientRate(int clientId, String clientMoniker, String nextYearExipryDate) {
try {
clientRateMapper.postponeMerchantRateByClientId(clientId);
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(null, clientMoniker, "tax_in_surcharge", false));
List<JSONObject> adminAccounts = clientAccountMapper.listAdminAccounts(clientId);
adminAccounts.forEach(o -> {
sendClientPostponeNotify(o, nextYearExipryDate);
});
logger.error("[{}]费率自动延期成功", clientMoniker);
return true;
} catch (Exception e) {
logger.error("[{}]费率自动延期失败", clientMoniker);
return false;
}
}
private TemplateMessage initClientMessage(JSONObject client, String newExpiryDate, String wechatOpenid, String templateId) { private TemplateMessage initClientMessage(JSONObject client, String newExpiryDate, String wechatOpenid, String templateId) {

@ -69,6 +69,23 @@ public class PostponeClientTask {
}); });
} }
@Scheduled(cron = "0 30 6 * * ?")
private void postponeMerchantRate() {
synchronizedScheduler.executeProcess("manage_task:postponeMerchantRate", 120_000, () -> {
String nextYearExipryDate = DateFormatUtils.format(DateUtils.addYears(new Date(), 1), "yyyy-MM-dd");
List<JSONObject> expiryRateMerchants = clientRateMapper.getAllClientRateExpiryMerchants();
StringBuilder merchantStrBuilder = new StringBuilder();
expiryRateMerchants.forEach(merchant -> {
if (clientManager.postponeClientRate(merchant.getIntValue("client_id"), merchant.getString("client_moniker"),nextYearExipryDate)) {
merchantStrBuilder.append(merchant.getString("client_moniker")).append("、");
}
});
merchantStrBuilder.deleteCharAt(merchantStrBuilder.length() - 1);
sendComplianceNotify(merchantStrBuilder, nextYearExipryDate);
});
}
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 -> {
@ -76,8 +93,8 @@ public class PostponeClientTask {
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);
}); });
} }
private TemplateMessage initComplianceMessage(String clients, String newExpiryDate, String wechatOpenid, String templateId) { private TemplateMessage initComplianceMessage(String clients, 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");

@ -119,6 +119,43 @@
a.expiry_time < #{expiry_date} a.expiry_time < #{expiry_date}
]]> ]]>
</select> </select>
<select id="getAllClientRateExpiryMerchants" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT
c.client_moniker,
c.client_id
FROM sys_clients c
LEFT JOIN sys_client_rates r
ON r.client_id = c.client_id
WHERE c.skip_clearing = 0
AND (c.approve_result = 1
OR (c.approve_result = 2
AND (c.source = 1
OR c.source = 2)))
AND c.is_valid = 1
AND (r.expiry_time = (SELECT
MAX(expiry_time)
FROM sys_client_rates r3
WHERE r3.client_id = c.client_id
AND r3.rate_name = r.rate_name)
AND r.expiry_time <= CURRENT_DATE()
OR r.client_rate_id IS NULL
)
]]>
</select>
<insert id="postponeMerchantRateByClientId" parameterType="int">
INSERT sys_client_rates (manager_id, client_id, rate_name, rate_value, transaction_fee, active_time, expiry_time, create_time, update_time, manager_name, clean_days, remark)
SELECT CONCAT('System-', CURRENT_DATE()),r.client_id,r.rate_name,r.rate_value,r.transaction_fee,DATE_ADD(r.expiry_time, INTERVAL 1 day),DATE_ADD(r.expiry_time, INTERVAL 1 year),NOW(), NOW(),
CONCAT('System-', CURRENT_DATE()),r.clean_days,'费率自动延期一年'
FROM sys_clients c
LEFT JOIN sys_client_rates r ON r.client_id = c.client_id
WHERE c.client_id = #{clientId} AND c.skip_clearing = 0 AND (c.approve_result = 1 OR (c.approve_result = 2 AND (c.source = 1 OR c.source = 2)))
AND c.is_valid = 1 AND (r.expiry_time = (SELECT MAX(expiry_time)FROM sys_client_rates r3
WHERE r3.client_id = c.client_id
AND r3.rate_name = r.rate_name)
AND CURRENT_DATE() >= r.expiry_time
OR r.client_rate_id IS NULL)
</insert>
<select id="latestConfig" resultType="com.alibaba.fastjson.JSONObject"> <select id="latestConfig" resultType="com.alibaba.fastjson.JSONObject">
SELECT * FROM SELECT * FROM
sys_client_rates sys_client_rates

Loading…
Cancel
Save