diff --git a/src/main/java/au/com/royalpay/payment/manage/settlement/core/impls/ManualSettleSupportImpl.java b/src/main/java/au/com/royalpay/payment/manage/settlement/core/impls/ManualSettleSupportImpl.java index dc9a51fe5..f35f02be3 100644 --- a/src/main/java/au/com/royalpay/payment/manage/settlement/core/impls/ManualSettleSupportImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/settlement/core/impls/ManualSettleSupportImpl.java @@ -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 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; } diff --git a/src/main/resources/i18n/addon_en.properties b/src/main/resources/i18n/addon_en.properties new file mode 100644 index 000000000..5fe45b118 --- /dev/null +++ b/src/main/resources/i18n/addon_en.properties @@ -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. \ No newline at end of file diff --git a/src/main/resources/i18n/addon_zh.properties b/src/main/resources/i18n/addon_zh.properties new file mode 100644 index 000000000..9cf1789bf --- /dev/null +++ b/src/main/resources/i18n/addon_zh.properties @@ -0,0 +1 @@ +manual_settle.notice=提现申请提交后会在第二个工作日到账,在此期间您的余额不会更新 \ No newline at end of file diff --git a/src/test/java/au/com/royalpay/payment/manage/valid/TestI18N.java b/src/test/java/au/com/royalpay/payment/manage/valid/TestI18N.java new file mode 100644 index 000000000..23acc14a3 --- /dev/null +++ b/src/test/java/au/com/royalpay/payment/manage/valid/TestI18N.java @@ -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")); + } +}