From 5db4a09b92f7723894ff0f4018335983367e761f Mon Sep 17 00:00:00 2001 From: yixian Date: Tue, 27 Mar 2018 14:34:15 +0800 Subject: [PATCH] manual settle --- .../manage/mappers/bill/BillOrderMapper.java | 13 ++++---- .../core/impls/ManualSettleSupportImpl.java | 9 +++--- .../impls/ManualSettleSupportImplTest.java | 30 +++++++++++++++++++ 3 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 src/test/java/au/com/royalpay/payment/manage/settlement/core/impls/ManualSettleSupportImplTest.java diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillOrderMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillOrderMapper.java index 12e740c6c..e23b783d9 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillOrderMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/bill/BillOrderMapper.java @@ -1,17 +1,14 @@ package au.com.royalpay.payment.manage.mappers.bill; -import java.util.List; - -import org.apache.ibatis.annotations.Param; - +import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; +import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; +import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; -import com.sun.tracing.dtrace.ProviderAttributes; +import org.apache.ibatis.annotations.Param; -import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; -import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; -import cn.yixblog.support.mybatis.autosql.annotations.SqlType; +import java.util.List; /** * Create by yixian at 2017-12-19 19:09 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 9f89c83db..8e4285ea0 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 @@ -79,16 +79,17 @@ public class ManualSettleSupportImpl implements ManualSettleSupport { if (client.getBooleanValue("skip_clearing")) { throw new ForbiddenException("Manual Settlement Not Enabled"); } - JSONObject todayTask = taskManualSettleMapper.findTodayTask(clientId); - if (todayTask != null) { + List unsettleRequests = taskManualSettleMapper.listActiveTasks(clientId); + JSONObject todayTask = unsettleRequests.isEmpty() ? null : unsettleRequests.get(0); + if (!unsettleRequests.isEmpty()) { todayTask.put("settle_to", DateFormatUtils.format(todayTask.getDate("settle_to"), "yyyy-MM-dd")); } else { todayTask = new JSONObject(); } List settleLogs = clearingLogMapper.findByDate(new Date()); - List unsettleRequests = taskManualSettleMapper.listActiveTasks(clientId); + //今天未清算则锁定 - todayTask.put("locked", settleLogs.isEmpty() || !unsettleRequests.isEmpty()); + todayTask.put("locked", settleLogs.isEmpty()); if (includingUnsettleData) { Date end = findSettleTo(clientId); List unsettleReports = transactionMapper.listClientUnsettleDataByDate(clientId, end); diff --git a/src/test/java/au/com/royalpay/payment/manage/settlement/core/impls/ManualSettleSupportImplTest.java b/src/test/java/au/com/royalpay/payment/manage/settlement/core/impls/ManualSettleSupportImplTest.java new file mode 100644 index 000000000..fcdd590d4 --- /dev/null +++ b/src/test/java/au/com/royalpay/payment/manage/settlement/core/impls/ManualSettleSupportImplTest.java @@ -0,0 +1,30 @@ +package au.com.royalpay.payment.manage.settlement.core.impls; + +import au.com.royalpay.payment.manage.settlement.core.ManualSettleSupport; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.serializer.SerializerFeature; +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; + +import javax.annotation.Resource; + +import static org.junit.Assert.*; + +/** + * Create by yixian at 2018-03-27 14:04 + */ +@SpringBootTest +@ActiveProfiles({"proxy", "alipay", "wechat", "jd", "bestpay"}) +@RunWith(SpringRunner.class) +public class ManualSettleSupportImplTest { + @Resource + private ManualSettleSupport manualSettleSupport; + + @Test + public void findCurrentSettle() { + System.out.println(JSON.toJSONString(manualSettleSupport.findCurrentSettle(9, true), SerializerFeature.PrettyFormat)); + } +} \ No newline at end of file