From 796b8d3ef0ede307f321fbed3b2bc9d79b79a1d4 Mon Sep 17 00:00:00 2001 From: Yixian Date: Thu, 2 Dec 2021 13:58:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=90=88=E4=BC=99=E4=BA=BA?= =?UTF-8?q?=E6=8F=90=E6=88=90sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impls/CityPartnerPrizeServiceImpl.java | 43 ++++++++++--------- .../mappers/payment/TransactionMapper.java | 8 ++-- .../mappers/payment/TransactionMapper.xml | 12 +++--- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java index ebbd06d7c..e7bcf5b8c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/citypartner/core/impls/CityPartnerPrizeServiceImpl.java @@ -22,6 +22,7 @@ import org.apache.poi.hssf.usermodel.HSSFFont; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.usermodel.*; +import org.joda.time.DateTime; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -259,10 +260,10 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { @Transactional public void generateold(String monthStr) { Date mon = checkMonth(monthStr); - Calendar monthCal = Calendar.getInstance(); - monthCal.setTime(mon); - int year = monthCal.get(Calendar.YEAR); - int month = monthCal.get(Calendar.MONTH) + 1; + DateTime begin = new DateTime(mon); + DateTime end = begin.plusMonths(1); + int year = begin.getYear(); + int month = begin.getMonthOfYear(); JSONObject sysConfig = sysConfigManager.getSysConfig(); BigDecimal alipayChargeRate = new BigDecimal("0.6"); @@ -286,7 +287,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { channelMap.put("Wechat", "Wechat"); channelMap.put("AlipayOnline", "AlipayOnline"); Set orgIds = new HashSet<>(); - List transactionAnalysis = transactionMapper.listTransactionsForCityPartnerCommission(year, month); + List transactionAnalysis = transactionMapper.listTransactionsForCityPartnerCommission(begin.toDate(), end.toDate()); Map results = new HashMap<>(); for (JSONObject analysisDay : transactionAnalysis) { int orgId = analysisDay.getIntValue("org_id"); @@ -339,10 +340,10 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { @Transactional public void generate(String monthStr) { Date mon = checkMonth(monthStr); - Calendar monthCal = Calendar.getInstance(); - monthCal.setTime(mon); - int year = monthCal.get(Calendar.YEAR); - int month = monthCal.get(Calendar.MONTH) + 1; + DateTime begin = new DateTime(mon); + DateTime end = begin.plusMonths(1); + int year = begin.getYear(); + int month = begin.getMonthOfYear(); // List list = financialPartnerCommissionMapper.list(year, month); // if (list != null && !list.isEmpty()) { @@ -374,8 +375,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { channelCharge.put("wechatChargeRate", wechatChargeRate); channelCharge.put("jdChargeRate", jdChargeRate); channelCharge.put("alipayonlineChargeRate", alipayonlineChargeRate); - - List transactionDetail = transactionMapper.listTransactionForCityPartnerCommissionByDate(year, month); + List transactionDetail = transactionMapper.listTransactionForCityPartnerCommissionByDate(begin.toDate(), end.toDate()); transactionDetail.forEach(item -> { if (StringUtils.equalsIgnoreCase("AlipayPlus", item.getString("channel"))) { item.put("channel", item.getString("pay_type")); @@ -763,15 +763,15 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { @Transactional public void generateReferrer(String monthStr) { Date mon = checkMonth(monthStr); - Calendar monthCal = Calendar.getInstance(); - monthCal.setTime(mon); - int year = monthCal.get(Calendar.YEAR); - int month = monthCal.get(Calendar.MONTH) + 1; + DateTime begin = new DateTime(mon); + DateTime end = begin.plusMonths(1); + int year = begin.getYear(); + int month = begin.getMonthOfYear(); financialReferrerCommissionDetailMapper.clearData(year, month); financialReferrerCommissionMapper.clearData(year, month); - List transactionAnalysis = transactionMapper.listTransactionsForReferrerCommission(year, month); + List transactionAnalysis = transactionMapper.listTransactionsForReferrerCommission(begin.toDate(), end.toDate()); Map results = new HashMap<>(); for (JSONObject analysisDay : transactionAnalysis) { Integer orgId = analysisDay.getInteger("org_id"); @@ -850,14 +850,15 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService { public void generateAgent(String monthStr, JSONObject channelCharge) { Date mon = checkMonth(monthStr); - Calendar monthCal = Calendar.getInstance(); - monthCal.setTime(mon); - int year = monthCal.get(Calendar.YEAR); - int month = monthCal.get(Calendar.MONTH) + 1; + DateTime begin = new DateTime(mon); + DateTime end = begin.plusMonths(1); + int year = begin.getYear(); + int month = begin.getMonthOfYear(); financialAgentCommissionMapper.clearData(year, month); financialAgentCommissionDetailMapper.clearData(year, month); - List transactionDetail = transactionMapper.listTransactionForCityPartnerAgentCommissionByDate(year, month); + + List transactionDetail = transactionMapper.listTransactionForCityPartnerAgentCommissionByDate(begin.toDate(), end.toDate()); transactionDetail.forEach(item -> { if (StringUtils.equalsIgnoreCase("AlipayPlus", item.getString("channel"))) { item.put("channel", item.getString("pay_type")); 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 bf78fb493..a3e393e9a 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 @@ -95,13 +95,13 @@ public interface TransactionMapper { BigDecimal totalAmountForSydneyGMPrize(@Param("year") int year, @Param("month") int month); - List listTransactionForCityPartnerCommissionByDate(@Param("year") int year, @Param("month") int month); + List listTransactionForCityPartnerCommissionByDate(@Param("begin") Date begin, @Param("end") Date end); - List listTransactionForCityPartnerAgentCommissionByDate(@Param("year") int year, @Param("month") int month); + List listTransactionForCityPartnerAgentCommissionByDate(@Param("begin") Date begin, @Param("end") Date end); - List listTransactionsForCityPartnerCommission(@Param("year") int year, @Param("month") int month); + List listTransactionsForCityPartnerCommission(@Param("begin") Date begin, @Param("end") Date end); - List listTransactionsForReferrerCommission(@Param("year") int year, @Param("month") int month); + List listTransactionsForReferrerCommission(@Param("begin") Date begin, @Param("end") Date end); List listTransactionsForAgentCommission(@Param("year") int year, @Param("month") int month, @Param("parent_org_id") int parent_org_id); 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 02ac6e24a..478df93b9 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 @@ -1006,8 +1006,8 @@ INNER JOIN sys_org so ON m.org_id = so.org_id AND so.is_valid = 1 AND so.type = 0 AND so.citypartner = 1 AND so.commission = 1 - WHERE year(t.transaction_time) = #{year} - AND month(t.transaction_time) = #{month} + WHERE t.transaction_time >= #{begin} + AND t.transaction_time < #{end} AND t.channel != 'Settlement' GROUP BY t.client_id, trade_date, channel ORDER BY c.org_id ASC, t.client_id ASC, trade_date ASC @@ -1036,7 +1036,7 @@ INNER JOIN sys_org so ON t.org_id = so.org_id AND so.is_valid = 1 AND so.type = 0 AND so.citypartner = 1 AND so.commission = 1 - AND year(t.create_time) = #{year} AND month(t.create_time) = #{month} + AND t.create_time >= #{begin} AND t.create_time < #{end} AND t.channel != 'Settlement' AND t.channel != 'System' AND t.system_generate = 0 ORDER BY t.client_id asc ]]> @@ -1066,7 +1066,7 @@ AND so.type = 0 AND so.parent_org_id != '' AND so.citypartner = 1 AND so.commission = 1 - AND year(t.transaction_time) = #{year} AND month(t.transaction_time) = #{month} + AND t.transaction_time >= #{begin} AND t.transaction_time < #{end} AND t.channel != 'Settlement' AND t.channel != 'System' ORDER BY t.client_id asc ]]> @@ -1084,8 +1084,8 @@ inner join sys_client_config cc on cc.client_id = c.client_id INNER JOIN sys_org so ON c.referrer_id = so.org_id AND so.is_valid = 1 AND so.type = 1 AND so.commission = 1 - WHERE year(t.transaction_time) = #{year} - AND month(t.transaction_time) = #{month} + WHERE t.transaction_time >= #{begin} + AND t.transaction_time < #{end} AND t.channel != 'Settlement' GROUP BY so.org_id, trade_date, t.client_id ORDER BY c.org_id ASC, t.client_id ASC, trade_date ASC