|
|
|
@ -1,15 +1,20 @@
|
|
|
|
|
package au.com.royalpay.payment.manage.management.clearing.core.impl;
|
|
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.core.PaymentApi;
|
|
|
|
|
import au.com.royalpay.payment.manage.management.clearing.core.SettleTasksService;
|
|
|
|
|
import au.com.royalpay.payment.manage.management.clearing.web.ManualSettleTask;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.SysSettlePlanMapper;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
|
|
|
|
import au.com.royalpay.payment.tools.livecheck.AppLiveCheck;
|
|
|
|
|
import au.com.royalpay.payment.tools.merchants.beans.BalanceGroup;
|
|
|
|
|
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONException;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.joda.time.DateTime;
|
|
|
|
|
import org.joda.time.DateTimeZone;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
@ -25,8 +30,10 @@ import org.springframework.web.util.UriComponentsBuilder;
|
|
|
|
|
|
|
|
|
|
import java.net.URI;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.TimeZone;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@ -34,6 +41,8 @@ public class SettleTaskServiceImpl implements SettleTasksService {
|
|
|
|
|
private final SysSettlePlanMapper planMapper;
|
|
|
|
|
private final StringRedisTemplate redisTemplate;
|
|
|
|
|
private final MerchantInfoProvider mchInfoProvider;
|
|
|
|
|
private final PaymentApi paymentApi;
|
|
|
|
|
private final TransactionMapper transactionMapper;
|
|
|
|
|
private final String prefix;
|
|
|
|
|
private final RestTemplate restTemplate;
|
|
|
|
|
private final String transactionHost;
|
|
|
|
@ -41,11 +50,13 @@ public class SettleTaskServiceImpl implements SettleTasksService {
|
|
|
|
|
private static final String SETTLE_TASK_URI = "/dev/manual/settle_tasks";
|
|
|
|
|
|
|
|
|
|
public SettleTaskServiceImpl(SysSettlePlanMapper planMapper, StringRedisTemplate redisTemplate,
|
|
|
|
|
MerchantInfoProvider mchInfoProvider, @Value("${app.redis.prefix}") String prefix,
|
|
|
|
|
MerchantInfoProvider mchInfoProvider, PaymentApi paymentApi, TransactionMapper transactionMapper, @Value("${app.redis.prefix}") String prefix,
|
|
|
|
|
@Value("${platform.services.transaction:http://127.0.0.1:6012}") String transactionHost, AppLiveCheck appLiveCheck) {
|
|
|
|
|
this.planMapper = planMapper;
|
|
|
|
|
this.redisTemplate = redisTemplate;
|
|
|
|
|
this.mchInfoProvider = mchInfoProvider;
|
|
|
|
|
this.paymentApi = paymentApi;
|
|
|
|
|
this.transactionMapper = transactionMapper;
|
|
|
|
|
this.prefix = prefix;
|
|
|
|
|
this.appLiveCheck = appLiveCheck;
|
|
|
|
|
this.restTemplate = new RestTemplateBuilder()
|
|
|
|
@ -108,5 +119,15 @@ public class SettleTaskServiceImpl implements SettleTasksService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<JSONObject> analysisYesterdayTransaction() {
|
|
|
|
|
Date from = DateTime.now().withMillisOfDay(0).withZoneRetainFields(DateTimeZone.forTimeZone(TimeZone.getTimeZone("Asia/Shanghai")))
|
|
|
|
|
.minusDays(1).toDate();
|
|
|
|
|
Date to = new DateTime(from).plusDays(1).toDate();
|
|
|
|
|
List<String> channels = paymentApi.channelsInGroup(BalanceGroup.NORMAL_CROSS_BORDER);
|
|
|
|
|
channels.remove("System");
|
|
|
|
|
return transactionMapper.analysisByChannels(from, to, channels);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|