master
yixian 7 years ago
parent 4c6fbed61c
commit f11ccbc7cd

@ -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.tools.exceptions.BadRequestException;
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.permission.enums.PartnerRole;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@ -37,6 +40,9 @@ public class ManualSettleSupportImpl implements ManualSettleSupport {
@Override
public JSONObject requestManualSettle(Date settleTo, String accountId) {
JSONObject account = clientAccountMapper.findById(accountId);
if (PartnerRole.getRole(account.getIntValue("role")) != PartnerRole.ADMIN) {
throw new ForbiddenException();
}
int clientId = account.getIntValue("client_id");
if (DateUtils.isSameDay(new Date(), settleTo)) {
throw new BadRequestException("Cannot settle today's transactions");
@ -75,6 +81,11 @@ public class ManualSettleSupportImpl implements ManualSettleSupport {
List<JSONObject> unsettleReports = transactionMapper.listClientUnsettleDataByDate(clientId);
unsettleReports.parallelStream().forEach(report -> report.put("date_str", DateFormatUtils.format(report.getDate("trans_date"), "yyyy-MM-dd")));
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;
}

@ -0,0 +1 @@
manual_settle.notice=Settlement will be made on second work day after submitted this application. Your balance will not update during this time.

@ -0,0 +1 @@
manual_settle.notice=提现申请提交后会在第二个工作日到账,在此期间您的余额不会更新

@ -0,0 +1,23 @@
package au.com.royalpay.payment.manage.valid;
/**
* Create by yixian at 2018-03-21 10:36
*/
import au.com.royalpay.payment.tools.locale.LocaleSupport;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest
@ActiveProfiles({ "local", "alipay", "wechat", "jd", "bestpay" })
@RunWith(SpringRunner.class)
public class TestI18N {
@Test
public void test(){
System.out.println("------------------------"+ LocaleSupport.localeMessage("manual_settle.notice"));
}
}
Loading…
Cancel
Save