From c7ae9d0c419ca9e5950ee65081bdac2416a100a3 Mon Sep 17 00:00:00 2001 From: yixian Date: Wed, 26 Aug 2020 21:28:08 +1000 Subject: [PATCH] postpone --- .../manage/merchants/core/ClientManager.java | 3 -- .../core/impls/ClientManagerImpl.java | 43 ++----------------- .../manage/task/OrgCommissionTask.java | 2 - .../manage/task/PostponeClientTask.java | 32 +------------- .../manage/task/initClientLocationTask.java | 2 - .../mappers/system/ClientRateMapper.xml | 24 +++++------ .../manage/task/PostponeClientTaskTest.java | 8 +--- 7 files changed, 18 insertions(+), 96 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java index 024fa5f4c..d8b43d483 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -19,7 +19,6 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.OutputStream; import java.math.BigDecimal; -import java.util.Date; import java.util.List; /** @@ -489,8 +488,6 @@ public interface ClientManager { void updateAllPartnerPassword(String clientMoniker); - void postponeClientRate(Date now, Date yearTomorrow, String expireDate, JSONObject client); - /** * 根据商户之前的费率自动延期一年 * diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 5ac5dc392..cc72b70c9 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -6329,41 +6329,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } } - @Override - @Transactional - public void postponeClientRate(Date now, Date yearTomorrow, String expireDate, JSONObject client) { - int client_id = client.getIntValue("client_id"); - List adminAccounts = clientAccountMapper.listAdminAccounts(client_id); - List clientRates = clientRateMapper.maxChannelExpiryTime(client_id, null); - JSONObject wechatRate = clientRateMapper.latestChannelCleanDays("Wechat", client.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; - for (JSONObject o : clientRates) { - 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)); -// } - } - adminAccounts.forEach(o -> { - sendClientPostponeNotify(o, expireDate); - }); - } - @Override public List getClientBySimpleQuery(JSONObject param) { String subMerchantId = param.getString("sub_merchant_id"); @@ -6380,14 +6345,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid for (String channel : channels) { clientRateMapper.postponeMerchantRateByClientId(clientId, channel); } - List adminAccounts = clientAccountMapper.listAdminAccounts(clientId); - adminAccounts.forEach(o -> { - sendClientPostponeNotify(o, nextYearExipryDate); - }); +// List adminAccounts = clientAccountMapper.listAdminAccounts(clientId); +// adminAccounts.forEach(o -> sendClientPostponeNotify(o, nextYearExipryDate)); logger.error("[{}]费率自动延期成功", clientMoniker); return true; } catch (Exception e) { - logger.error("[{}]费率自动延期失败", clientMoniker); + logger.error("[{}]费率自动延期失败", clientMoniker, e); return false; } } diff --git a/src/main/java/au/com/royalpay/payment/manage/task/OrgCommissionTask.java b/src/main/java/au/com/royalpay/payment/manage/task/OrgCommissionTask.java index 1a7a42647..dce6c199a 100644 --- a/src/main/java/au/com/royalpay/payment/manage/task/OrgCommissionTask.java +++ b/src/main/java/au/com/royalpay/payment/manage/task/OrgCommissionTask.java @@ -5,12 +5,10 @@ import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.util.Calendar; import java.util.Date; -import java.util.List; @Component @ConditionalOnProperty(value = "app.run-tasks", havingValue = "true") diff --git a/src/main/java/au/com/royalpay/payment/manage/task/PostponeClientTask.java b/src/main/java/au/com/royalpay/payment/manage/task/PostponeClientTask.java index 660d8ef75..83f1f664d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/task/PostponeClientTask.java +++ b/src/main/java/au/com/royalpay/payment/manage/task/PostponeClientTask.java @@ -13,10 +13,8 @@ import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateUtils; import org.slf4j.Logger; 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.util.CollectionUtils; import javax.annotation.Resource; import java.util.*; @@ -26,7 +24,7 @@ import java.util.stream.Collectors; * Created by wangning on 2018/1/2. */ @Component -@ConditionalOnProperty(value = "app.run-tasks", havingValue = "true") +//@ConditionalOnProperty(value = "app.run-tasks", havingValue = "true") public class PostponeClientTask { Logger logger = LoggerFactory.getLogger(PostponeClientTask.class); @@ -43,34 +41,8 @@ public class PostponeClientTask { @Resource private PaymentApi paymentApi; - @Scheduled(cron = "0 30 8 * * ?") - public void postponeClient() { - 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 expiryClient = clientRateMapper.getAllExpiry(now); - StringBuilder sb = new StringBuilder(); - if (CollectionUtils.isEmpty(expiryClient)) { - return; - } - for (JSONObject client : expiryClient) { - try { - clientManager.postponeClientRate(now, yearTomorrow, expireDate, client); - sb.append(client.getString("client_moniker")); - sb.append("、"); - } catch (Exception ignore) { - continue; - } - } - sb.deleteCharAt(sb.length() - 1); - sendComplianceNotify(sb.toString(), expireDate); - }); - } - @Scheduled(cron = "0 30 6 * * ?") - private void postponeMerchantRate() { + public void postponeMerchantRate() { synchronizedScheduler.executeProcess("manage_task:postponeMerchantRate", 120_000, () -> { String nextYearExipryDate = DateFormatUtils.format(DateUtils.addYears(new Date(), 1), "yyyy-MM-dd"); List expiryRateMerchantsChannels = clientRateMapper.getAllClientRateExpiryMerchants(); diff --git a/src/main/java/au/com/royalpay/payment/manage/task/initClientLocationTask.java b/src/main/java/au/com/royalpay/payment/manage/task/initClientLocationTask.java index f7b23547c..43e2e3df3 100644 --- a/src/main/java/au/com/royalpay/payment/manage/task/initClientLocationTask.java +++ b/src/main/java/au/com/royalpay/payment/manage/task/initClientLocationTask.java @@ -2,8 +2,6 @@ package au.com.royalpay.payment.manage.task; import au.com.royalpay.payment.manage.dev.core.MerchantLocationService; import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml index 1e2309ba1..866468147 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientRateMapper.xml @@ -134,23 +134,21 @@ HAVING max_expire<=curdate() ]]> - + - +