Merge branch 'develop'

master
yixian 4 years ago
commit f05b405a75

@ -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);
/**
*
*

@ -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
public List<JSONObject> 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<JSONObject> adminAccounts = clientAccountMapper.listAdminAccounts(clientId);
adminAccounts.forEach(o -> {
sendClientPostponeNotify(o, nextYearExipryDate);
});
// List<JSONObject> 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;
}
}

@ -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")

@ -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<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 * * ?")
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<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.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;

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

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