master
yixian 4 years ago
parent 604baa63e0
commit c7ae9d0c41

@ -19,7 +19,6 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -489,8 +488,6 @@ public interface ClientManager {
void updateAllPartnerPassword(String clientMoniker); void updateAllPartnerPassword(String clientMoniker);
void postponeClientRate(Date now, Date yearTomorrow, String expireDate, JSONObject client);
/** /**
* *
* *

@ -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<JSONObject> adminAccounts = clientAccountMapper.listAdminAccounts(client_id);
List<JSONObject> 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 @Override
public List<JSONObject> getClientBySimpleQuery(JSONObject param) { public List<JSONObject> getClientBySimpleQuery(JSONObject param) {
String subMerchantId = param.getString("sub_merchant_id"); String subMerchantId = param.getString("sub_merchant_id");
@ -6380,14 +6345,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
for (String channel : channels) { for (String channel : channels) {
clientRateMapper.postponeMerchantRateByClientId(clientId, channel); clientRateMapper.postponeMerchantRateByClientId(clientId, channel);
} }
List<JSONObject> adminAccounts = clientAccountMapper.listAdminAccounts(clientId); // List<JSONObject> adminAccounts = clientAccountMapper.listAdminAccounts(clientId);
adminAccounts.forEach(o -> { // adminAccounts.forEach(o -> sendClientPostponeNotify(o, nextYearExipryDate));
sendClientPostponeNotify(o, nextYearExipryDate);
});
logger.error("[{}]费率自动延期成功", clientMoniker); logger.error("[{}]费率自动延期成功", clientMoniker);
return true; return true;
} catch (Exception e) { } catch (Exception e) {
logger.error("[{}]费率自动延期失败", clientMoniker); logger.error("[{}]费率自动延期失败", clientMoniker, e);
return false; return false;
} }
} }

@ -5,12 +5,10 @@ import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List;
@Component @Component
@ConditionalOnProperty(value = "app.run-tasks", havingValue = "true") @ConditionalOnProperty(value = "app.run-tasks", havingValue = "true")

@ -13,10 +13,8 @@ import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*; import java.util.*;
@ -26,7 +24,7 @@ import java.util.stream.Collectors;
* Created by wangning on 2018/1/2. * Created by wangning on 2018/1/2.
*/ */
@Component @Component
@ConditionalOnProperty(value = "app.run-tasks", havingValue = "true") //@ConditionalOnProperty(value = "app.run-tasks", havingValue = "true")
public class PostponeClientTask { public class PostponeClientTask {
Logger logger = LoggerFactory.getLogger(PostponeClientTask.class); Logger logger = LoggerFactory.getLogger(PostponeClientTask.class);
@ -43,34 +41,8 @@ public class PostponeClientTask {
@Resource @Resource
private PaymentApi paymentApi; 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<JSONObject> 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 * * ?") @Scheduled(cron = "0 30 6 * * ?")
private void postponeMerchantRate() { public void postponeMerchantRate() {
synchronizedScheduler.executeProcess("manage_task:postponeMerchantRate", 120_000, () -> { synchronizedScheduler.executeProcess("manage_task:postponeMerchantRate", 120_000, () -> {
String nextYearExipryDate = DateFormatUtils.format(DateUtils.addYears(new Date(), 1), "yyyy-MM-dd"); String nextYearExipryDate = DateFormatUtils.format(DateUtils.addYears(new Date(), 1), "yyyy-MM-dd");
List<JSONObject> expiryRateMerchantsChannels = clientRateMapper.getAllClientRateExpiryMerchants(); List<JSONObject> expiryRateMerchantsChannels = clientRateMapper.getAllClientRateExpiryMerchants();

@ -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.manage.dev.core.MerchantLocationService;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler; 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.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;

@ -134,23 +134,21 @@
HAVING max_expire<=curdate() HAVING max_expire<=curdate()
]]> ]]>
</select> </select>
<insert id="postponeMerchantRateByClientId" parameterType="int"> <update id="postponeMerchantRateByClientId">
<![CDATA[ <![CDATA[
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)
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),
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), IF(DATE_ADD( r.expiry_time, INTERVAL 1 YEAR )<=NOW(),DATE_ADD( r.expiry_time, INTERVAL 2 YEAR ),DATE_ADD( r.expiry_time, INTERVAL 1 YEAR )) expiry_time,NOW(), NOW(),
IF(DATE_ADD( r.expiry_time, INTERVAL 1 YEAR )<=NOW(),DATE_ADD( r.expiry_time, INTERVAL 2 YEAR ),DATE_ADD( r.expiry_time, INTERVAL 1 YEAR )) expiry_time,NOW(), NOW(), CONCAT('System-', CURRENT_DATE()),r.clean_days,'费率自动延期一年'
CONCAT('System-', CURRENT_DATE()),r.clean_days,'费率自动延期一年' FROM (select rr.* from sys_client_rates rr
FROM (select rr.* from sys_client_rates rr WHERE rr.client_id = #{client_id}
WHERE rr.client_id = #{clientId} and rr.rate_name = #{channel}
and rr.rate_name = #{channel} order by rr.expiry_time desc limit 1) r
order by rr.expiry_time desc limit 1) r where r.expiry_time< current_date()
where r.expiry_time< current_date()
]]> ]]>
</insert> </update>
<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

@ -1,7 +1,5 @@
package au.com.royalpay.payment.manage.task; package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
@ -11,15 +9,13 @@ import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource; import javax.annotation.Resource;
@SpringBootTest @SpringBootTest
@ActiveProfiles({ "local","rpay", "alipay", "wechat", "jd", "bestpay" }) @ActiveProfiles({"proxy", "rpay", "alipay", "wechat", "rppaysvc", "common"})
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
public class PostponeClientTaskTest { public class PostponeClientTaskTest {
@Resource
private ClientRateMapper clientRateMapper;
@Resource @Resource
private PostponeClientTask postponeClientTask; private PostponeClientTask postponeClientTask;
@Test @Test
public void checkGreenChannel() { public void checkGreenChannel() {
postponeClientTask.postponeClient(); postponeClientTask.postponeMerchantRate();
} }
} }
Loading…
Cancel
Save