diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/EncourageUseProcessor.java b/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/EncourageUseProcessor.java index 13de70add..d4bead124 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/EncourageUseProcessor.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/EncourageUseProcessor.java @@ -85,6 +85,7 @@ public class EncourageUseProcessor implements Ordered, EncourageService { @Override public JSONObject takeEncourageMoney(String orderId, String visitorOpenId) { + logger.info("=====takeEncourageMoney+" + orderId); JSONObject config = currentEncourageConfig(); if (config != null) { if (customerEncourageMoneyAccessLogMapper.findByOrderId(orderId) != null) { @@ -239,16 +240,22 @@ public class EncourageUseProcessor implements Ordered, EncourageService { Date toDate = config.getDate("to_date"); status.put("to", DateFormatUtils.format(toDate, "MM-dd")); JSONObject member = customerMembershipMapper.findByPaymentOpenId(openid); + JSONObject use = customerEncourageMoneyAccessLogMapper.sumMoney(member.getString("memeber_id"),config.getString("event_id")); + BigDecimal balance = BigDecimal.ZERO; + if(use!=null){ + balance = use.getBigDecimal("use_amount"); + } + member.put("used_amount",balance.setScale(2, BigDecimal.ROUND_DOWN).toPlainString()); if (member != null) { status.put("member_info", member); List balanceLogs = customerMembershipMapper.listEncourageBalanceHistory(fromDate, toDate, member.getString("member_id")); status.put("logs", balanceLogs); - BigDecimal usedAmount = customerEncourageMoneyUseLogMapper.sumUsed(member.getString("member_id"), fromDate, toDate); - member.put("used_amount", usedAmount); +// BigDecimal usedAmount = customerEncourageMoneyUseLogMapper.sumUsed(member.getString("member_id"), fromDate, toDate); +// member.put("used_amount", usedAmount); } else { member = new JSONObject(); member.put("encourage_balance", 0); - member.put("used_amount", 0); +// member.put("used_amount", 0); } status.put("member", member); return status; diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/customers/CustomerEncourageMoneyAccessLogMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/customers/CustomerEncourageMoneyAccessLogMapper.java index 04ab8b807..469a62172 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/customers/CustomerEncourageMoneyAccessLogMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/customers/CustomerEncourageMoneyAccessLogMapper.java @@ -31,4 +31,7 @@ public interface CustomerEncourageMoneyAccessLogMapper { PageList list(JSONObject params, PageBounds pageBounds); List analysisByDate(@Param("event_id") String eventId); + + JSONObject sumMoney(@Param("memberId") String memberId,@Param("eventId")String eventId); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/customers/CustomerEncourageMoneyUseLogMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/customers/CustomerEncourageMoneyUseLogMapper.java index f9ca6116e..a82dc96c7 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/customers/CustomerEncourageMoneyUseLogMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/customers/CustomerEncourageMoneyUseLogMapper.java @@ -34,4 +34,7 @@ public interface CustomerEncourageMoneyUseLogMapper { List analysisByDate(@Param("event_id") String eventId); List listUnsettled(); + + JSONObject sumMoney(@Param("memberId") String memberId,@Param("eventId")String eventId); + } diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/customers/CustomerEncourageMoneyAccessLogMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/customers/CustomerEncourageMoneyAccessLogMapper.xml index 83a1ab531..4f115c7d3 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/customers/CustomerEncourageMoneyAccessLogMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/customers/CustomerEncourageMoneyAccessLogMapper.xml @@ -42,4 +42,7 @@ GROUP BY access_date ORDER BY access_date DESC + \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/customers/CustomerEncourageMoneyUseLogMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/customers/CustomerEncourageMoneyUseLogMapper.xml index 4610889fc..4d025397b 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/customers/CustomerEncourageMoneyUseLogMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/customers/CustomerEncourageMoneyUseLogMapper.xml @@ -43,4 +43,7 @@ INNER JOIN pmt_orders o ON o.order_id=u.order_id AND o.status>4 WHERE u.transaction_id is null + \ No newline at end of file