fix bd prize

master
eason 6 years ago
parent 2627482fba
commit 376687f25b

@ -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<JSONObject> report = calculator.getReport();
List<JSONObject> 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);

@ -11,5 +11,5 @@ public interface BDPrizeCalculator {
void calculate();
List<JSONObject> getReport();
List<JSONObject> getReport(int year,int month);
}

@ -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<String, JSONObject> bdMap = new HashMap<>();
private Map<Integer, Map<Integer, List<JSONObject>>> rateConfigMap = new HashMap<>();
private Map<String, BigDecimal> bdTotalMap = new HashMap<>();
private TransactionMapper transactionMapper;
public BDPrizeCalculatorDefaultImpl(List<JSONObject> tradeLogs, Date month) {
this.tradeLogs = tradeLogs;
@ -76,7 +78,7 @@ public class BDPrizeCalculatorDefaultImpl implements BDPrizeCalculator {
}
@Override
public List<JSONObject> getReport() {
public List<JSONObject> getReport(int year,int month1) {
List<JSONObject> report = new ArrayList<>();
for (Map.Entry<String, Map<String, JSONObject>> 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<JSONObject> details = new ArrayList<>();
for (Map.Entry<String, JSONObject> detail : resultItem.getValue().entrySet()) {
JSONObject detailItem = detail.getValue();

@ -93,6 +93,8 @@ public interface TransactionMapper {
List<JSONObject> 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);

@ -502,6 +502,21 @@
ORDER BY trade_date ASC, o.client_id ASC
</select>
<select id="TotalAmountForBDPrize" resultType="java.math.BigDecimal">
select sum(if(temp.transaction_type='Credit',temp.clearing_amount*d.proportion,-temp.clearing_amount*d.proportion))
total FROM
(SELECT l.client_id,l.clearing_amount,l.refund_id,l.transaction_type,o.create_time FROM pmt_transactions l
INNER JOIN pmt_orders o
ON o.order_id = l.order_id
and year(o.create_time) = #{year} AND month(o.create_time) = #{month}
where (l.transaction_type='Credit' or l.refund_id is not null)
) temp
INNER JOIN sys_client_bd d ON temp.client_id = d.client_id AND d.start_date <= temp.create_time and
d.is_valid = '1'
AND (d.end_date is null or d.end_date > temp.create_time)
and d.bd_id=#{bd_id}
</select>
<select id="TotalAmountForBDLeaderPrize" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(t.total),0)

Loading…
Cancel
Save