From 376687f25b4168c90bddb35f74b80a0d6a012b86 Mon Sep 17 00:00:00 2001 From: eason Date: Thu, 2 Aug 2018 22:58:28 +0800 Subject: [PATCH] fix bd prize --- .../bdprize/core/impls/BDPrizeServiceImpl.java | 2 +- .../manage/bdprize/support/BDPrizeCalculator.java | 2 +- .../impls/BDPrizeCalculatorDefaultImpl.java | 6 ++++-- .../manage/mappers/payment/TransactionMapper.java | 2 ++ .../manage/mappers/payment/TransactionMapper.xml | 15 +++++++++++++++ 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/bdprize/core/impls/BDPrizeServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/bdprize/core/impls/BDPrizeServiceImpl.java index c52dac881..8670ec2f6 100644 --- a/src/main/java/au/com/royalpay/payment/manage/bdprize/core/impls/BDPrizeServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/bdprize/core/impls/BDPrizeServiceImpl.java @@ -124,7 +124,7 @@ public class BDPrizeServiceImpl implements BDPrizeService { BDPrizeCalculator calculator = new BDPrizeCalculatorDefaultImpl(trades, now.getTime()).clientBDMapper(clientBDMapper) .clientsWithBDAwayDeterminor(new DefaultClientWithBDAwayDeterminor(clientsWithBDAway)).rateConfig(rateConfig); calculator.calculate(); - List report = calculator.getReport(); + List report = calculator.getReport(now.get(Calendar.YEAR),now.get(Calendar.MONTH) + 1); for (JSONObject log : report) { log.put("record_id", record.getString("record_id")); log.put("channel", channel); diff --git a/src/main/java/au/com/royalpay/payment/manage/bdprize/support/BDPrizeCalculator.java b/src/main/java/au/com/royalpay/payment/manage/bdprize/support/BDPrizeCalculator.java index 49e4365b6..049a5bedb 100644 --- a/src/main/java/au/com/royalpay/payment/manage/bdprize/support/BDPrizeCalculator.java +++ b/src/main/java/au/com/royalpay/payment/manage/bdprize/support/BDPrizeCalculator.java @@ -11,5 +11,5 @@ public interface BDPrizeCalculator { void calculate(); - List getReport(); + List getReport(int year,int month); } diff --git a/src/main/java/au/com/royalpay/payment/manage/bdprize/support/impls/BDPrizeCalculatorDefaultImpl.java b/src/main/java/au/com/royalpay/payment/manage/bdprize/support/impls/BDPrizeCalculatorDefaultImpl.java index 1564f33be..be9df684f 100644 --- a/src/main/java/au/com/royalpay/payment/manage/bdprize/support/impls/BDPrizeCalculatorDefaultImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/bdprize/support/impls/BDPrizeCalculatorDefaultImpl.java @@ -9,6 +9,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import com.alibaba.fastjson.JSONObject; import au.com.royalpay.payment.manage.bdprize.support.BDPrizeCalculator; @@ -30,6 +31,7 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator { private Map bdMap = new HashMap<>(); private Map>> rateConfigMap = new HashMap<>(); private Map bdTotalMap = new HashMap<>(); + private TransactionMapper transactionMapper; public BDPrizeCalculatorDefaultImpl(List tradeLogs, Date month) { this.tradeLogs = tradeLogs; @@ -76,7 +78,7 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator { } @Override - public List getReport() { + public List getReport(int year,int month1) { List report = new ArrayList<>(); for (Map.Entry> resultItem : results.entrySet()) { JSONObject log = new JSONObject(); @@ -89,7 +91,7 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator { log.put("total_amount", 0); log.put("total_prize", 0); log.put("total_donation", 0); - BigDecimal totalAmount = bdTotalMap.get(bd.getString("bd_id")); + BigDecimal totalAmount = transactionMapper.TotalAmountForBDPrize(year,month1,bd.getString("bd_id")); List details = new ArrayList<>(); for (Map.Entry detail : resultItem.getValue().entrySet()) { JSONObject detailItem = detail.getValue(); 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 be48b0efc..38eb75087 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 @@ -93,6 +93,8 @@ public interface TransactionMapper { List listTransactionsForBDPrize(@Param("year") int year, @Param("month") int month, @Param("channel") String channel); + BigDecimal TotalAmountForBDPrize(@Param("year") int year, @Param("month") int month, @Param("bd_id") String bd_id); + BigDecimal TotalAmountForBDLeaderPrize(@Param("year") int year, @Param("month") int month, @Param("bd_group") String bd_group); BigDecimal TotalAmountForSydneyGMPrize(@Param("year") int year, @Param("month") int month); 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 3cb0cd8e4..6c6c00715 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 @@ -502,6 +502,21 @@ ORDER BY trade_date ASC, o.client_id ASC + +