diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.java index 735c80aea..4d000d3ae 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.java @@ -28,4 +28,7 @@ public interface TaskManualSettleMapper { @AutoSql(type = SqlType.UPDATE) void update(JSONObject task); + + List getEveryLatestRecord(); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java index f6b91f73c..0f3269fff 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java @@ -55,6 +55,8 @@ public interface TransactionMapper { double getClientUnClearedAmount(@Param("client_id") int clientId); + List getClientsUnClearedAmount(@Param("client_ids") List client_ids); + JSONObject getClientAmountAnalysis(JSONObject params); PageList listPreRefundClients(PageBounds pagination); diff --git a/src/main/java/au/com/royalpay/payment/manage/settlement/core/ManualSettleSupport.java b/src/main/java/au/com/royalpay/payment/manage/settlement/core/ManualSettleSupport.java index 5033a4028..a9a94ef07 100644 --- a/src/main/java/au/com/royalpay/payment/manage/settlement/core/ManualSettleSupport.java +++ b/src/main/java/au/com/royalpay/payment/manage/settlement/core/ManualSettleSupport.java @@ -3,6 +3,7 @@ package au.com.royalpay.payment.manage.settlement.core; import com.alibaba.fastjson.JSONObject; import java.util.Date; +import java.util.List; /** * Create by yixian at 2018-03-20 17:42 @@ -13,4 +14,5 @@ public interface ManualSettleSupport { JSONObject findCurrentSettle(int clientId, boolean includingUnsettleData); + List listWithClearInfo(); } 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 3d34494e0..53d08a49b 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 @@ -11,16 +11,20 @@ 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 au.com.royalpay.payment.tools.utils.CurrencyAmountUtils; + 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.ArrayList; import java.util.Date; import java.util.List; +import javax.annotation.Resource; + /** * Create by yixian at 2018-03-20 17:44 */ @@ -96,4 +100,24 @@ public class ManualSettleSupportImpl implements ManualSettleSupport { } return todayTask; } + + @Override + public List listWithClearInfo() { + List manuals = taskManualSettleMapper.getEveryLatestRecord(); + List client_ids = new ArrayList<>(manuals.size()); + manuals.parallelStream().forEach(p->{ + client_ids.add(p.getInteger("client_id")); + }); + List clientUnsettle = transactionMapper.getClientsUnClearedAmount(client_ids); + for (JSONObject manual : manuals) { + for (JSONObject settle : clientUnsettle) { + if (manual.getIntValue("client_id") == settle.getIntValue("client_id")) { + manual.put("unsettle", settle.getBigDecimal("clearing_amount")); + break; + } + } + } + + return manuals; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/system/web/contractController.java b/src/main/java/au/com/royalpay/payment/manage/system/web/contractController.java index 2d688dfe8..14a7508e4 100644 --- a/src/main/java/au/com/royalpay/payment/manage/system/web/contractController.java +++ b/src/main/java/au/com/royalpay/payment/manage/system/web/contractController.java @@ -1,6 +1,7 @@ package au.com.royalpay.payment.manage.system.web; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; +import au.com.royalpay.payment.manage.settlement.core.ManualSettleSupport; import au.com.royalpay.payment.manage.system.core.ClientContractService; import com.alibaba.fastjson.JSONObject; @@ -14,13 +15,24 @@ import java.util.List; import javax.annotation.Resource; @RestController -@RequestMapping(value = "/manage/contract") +@RequestMapping(value = "/manage/common/analysis") public class contractController { @Resource private ClientContractService clientContractService; + @Resource + private ManualSettleSupport manualSettleSupport; - @ManagerMapping(value = "/list",method = RequestMethod.GET) - public List list(){ + @ManagerMapping(value = "/contract/list", method = RequestMethod.GET) + public List contractList() { return clientContractService.list(); } + + @RequestMapping(value = "/manualSettle/list", method = RequestMethod.GET) + public List manualList() { + List asd = manualSettleSupport.listWithClearInfo(); + System.out.println(asd); + System.out.println(asd); + System.out.println(asd); + return manualSettleSupport.listWithClearInfo(); + } } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.xml new file mode 100644 index 000000000..e7ce30abf --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml index 0ee0981d6..20ea3b938 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml @@ -173,6 +173,16 @@ WHERE clearing_status = 0 AND client_id = #{client_id} +