优化合伙人提成sql

master
Yixian 3 years ago
parent 80d6ea5076
commit 796b8d3ef0

@ -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<Integer> orgIds = new HashSet<>();
List<JSONObject> transactionAnalysis = transactionMapper.listTransactionsForCityPartnerCommission(year, month);
List<JSONObject> transactionAnalysis = transactionMapper.listTransactionsForCityPartnerCommission(begin.toDate(), end.toDate());
Map<String, CityPartnerCommissionAnalysis> 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<JSONObject> 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<JSONObject> transactionDetail = transactionMapper.listTransactionForCityPartnerCommissionByDate(year, month);
List<JSONObject> 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<JSONObject> transactionAnalysis = transactionMapper.listTransactionsForReferrerCommission(year, month);
List<JSONObject> transactionAnalysis = transactionMapper.listTransactionsForReferrerCommission(begin.toDate(), end.toDate());
Map<Integer, ReferrerCommissionAnalysis> 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<JSONObject> transactionDetail = transactionMapper.listTransactionForCityPartnerAgentCommissionByDate(year, month);
List<JSONObject> transactionDetail = transactionMapper.listTransactionForCityPartnerAgentCommissionByDate(begin.toDate(), end.toDate());
transactionDetail.forEach(item -> {
if (StringUtils.equalsIgnoreCase("AlipayPlus", item.getString("channel"))) {
item.put("channel", item.getString("pay_type"));

@ -95,13 +95,13 @@ public interface TransactionMapper {
BigDecimal totalAmountForSydneyGMPrize(@Param("year") int year, @Param("month") int month);
List<JSONObject> listTransactionForCityPartnerCommissionByDate(@Param("year") int year, @Param("month") int month);
List<JSONObject> listTransactionForCityPartnerCommissionByDate(@Param("begin") Date begin, @Param("end") Date end);
List<JSONObject> listTransactionForCityPartnerAgentCommissionByDate(@Param("year") int year, @Param("month") int month);
List<JSONObject> listTransactionForCityPartnerAgentCommissionByDate(@Param("begin") Date begin, @Param("end") Date end);
List<JSONObject> listTransactionsForCityPartnerCommission(@Param("year") int year, @Param("month") int month);
List<JSONObject> listTransactionsForCityPartnerCommission(@Param("begin") Date begin, @Param("end") Date end);
List<JSONObject> listTransactionsForReferrerCommission(@Param("year") int year, @Param("month") int month);
List<JSONObject> listTransactionsForReferrerCommission(@Param("begin") Date begin, @Param("end") Date end);
List<JSONObject> listTransactionsForAgentCommission(@Param("year") int year, @Param("month") int month, @Param("parent_org_id") int parent_org_id);

@ -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 &lt; #{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

Loading…
Cancel
Save