|
|
@ -7,13 +7,16 @@ import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
|
|
|
|
import au.com.royalpay.payment.manage.settlement.core.ManualSettleSupport;
|
|
|
|
import au.com.royalpay.payment.manage.settlement.core.ManualSettleSupport;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.locale.LocaleSupport;
|
|
|
|
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
|
|
|
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
@ -37,6 +40,9 @@ public class ManualSettleSupportImpl implements ManualSettleSupport {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public JSONObject requestManualSettle(Date settleTo, String accountId) {
|
|
|
|
public JSONObject requestManualSettle(Date settleTo, String accountId) {
|
|
|
|
JSONObject account = clientAccountMapper.findById(accountId);
|
|
|
|
JSONObject account = clientAccountMapper.findById(accountId);
|
|
|
|
|
|
|
|
if (PartnerRole.getRole(account.getIntValue("role")) != PartnerRole.ADMIN) {
|
|
|
|
|
|
|
|
throw new ForbiddenException();
|
|
|
|
|
|
|
|
}
|
|
|
|
int clientId = account.getIntValue("client_id");
|
|
|
|
int clientId = account.getIntValue("client_id");
|
|
|
|
if (DateUtils.isSameDay(new Date(), settleTo)) {
|
|
|
|
if (DateUtils.isSameDay(new Date(), settleTo)) {
|
|
|
|
throw new BadRequestException("Cannot settle today's transactions");
|
|
|
|
throw new BadRequestException("Cannot settle today's transactions");
|
|
|
@ -75,6 +81,11 @@ public class ManualSettleSupportImpl implements ManualSettleSupport {
|
|
|
|
List<JSONObject> unsettleReports = transactionMapper.listClientUnsettleDataByDate(clientId);
|
|
|
|
List<JSONObject> unsettleReports = transactionMapper.listClientUnsettleDataByDate(clientId);
|
|
|
|
unsettleReports.parallelStream().forEach(report -> report.put("date_str", DateFormatUtils.format(report.getDate("trans_date"), "yyyy-MM-dd")));
|
|
|
|
unsettleReports.parallelStream().forEach(report -> report.put("date_str", DateFormatUtils.format(report.getDate("trans_date"), "yyyy-MM-dd")));
|
|
|
|
todayTask.put("unsettle", unsettleReports);
|
|
|
|
todayTask.put("unsettle", unsettleReports);
|
|
|
|
|
|
|
|
BigDecimal totalClearing = unsettleReports.stream().map(report -> report.getBigDecimal("clearing_amount")).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
|
|
|
|
|
|
|
|
todayTask.put("total_clearing_amount", totalClearing);
|
|
|
|
|
|
|
|
BigDecimal totalSettle = unsettleReports.stream().map(report -> report.getBigDecimal("settle_amount")).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
|
|
|
|
|
|
|
|
todayTask.put("total_settle_amount", totalSettle);
|
|
|
|
|
|
|
|
todayTask.put("desc", LocaleSupport.localeMessage("manual_settle.notice"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return todayTask;
|
|
|
|
return todayTask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|