Modify BD Leader prize

master
wangning 7 years ago
parent 0a41d58e77
commit caa60f6287

@ -1,27 +1,5 @@
package au.com.royalpay.payment.manage.bdprize.core.impls;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import javax.annotation.Resource;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
import au.com.royalpay.payment.manage.bdprize.core.BDPrizeService;
import au.com.royalpay.payment.manage.bdprize.support.BDPrizeCalculator;
@ -43,6 +21,28 @@ import au.com.royalpay.payment.tools.lock.Locker;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import javax.annotation.Resource;
/**
* Created by yixian on 2017-02-07.
*/
@ -110,6 +110,7 @@ public class BDPrizeServiceImpl implements BDPrizeService {
record.put("create_time", new Date());
record.put("month", month);
financialBDPrizeRecordMapper.save(record);
for (String channel : channels) {
List<JSONObject> trades = transactionMapper.listTransactionsForBDPrize(now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1, channel);
List<Integer> clientsWithBDAway = clientBDMapper.clientsWithBDAway();
@ -134,7 +135,7 @@ public class BDPrizeServiceImpl implements BDPrizeService {
//BD Leader Prize
List<JSONObject> bdLeaders = managerMapper.listByRole(1, ManagerRole.BD_LEADER.getMask());
for (JSONObject leader : bdLeaders) {
BigDecimal groupAmount = financialBDConfigMapper.getTotalAmount(leader.getString("manager_id"), record.getString("record_id"));
BigDecimal groupAmount = transactionMapper.TotalAmountForBDLeaderPrize(now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1,leader.getString("manager_id"));
JSONObject rateJson = financialBDCommissionConfigMapper.findCurrentCommissionRate(month, groupAmount.toString(), 1);
BigDecimal groupPrize = new BigDecimal(0);
if (rateJson != null) {

@ -93,6 +93,7 @@ public interface TransactionMapper {
List<JSONObject> listTransactionsForBDPrize(@Param("year") int year, @Param("month") int month, @Param("channel") String channel);
BigDecimal TotalAmountForBDLeaderPrize(@Param("year") int year, @Param("month") int month, @Param("bd_group") String bd_group);
List<JSONObject> listTransactionsForCityPartnerCommission(@Param("year") int year, @Param("month") int month);

@ -486,6 +486,29 @@
ORDER BY trade_date ASC, o.client_id ASC
</select>
<select id="TotalAmountForBDLeaderPrize" resultType="java.math.BigDecimal">
SELECT
sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount))
total
FROM pmt_transactions t
INNER JOIN pmt_orders o ON o.order_id = t.order_id
INNER JOIN sys_clients c ON c.client_id = o.client_id AND c.org_id = 1
WHERE year(o.create_time) = #{year} AND month(o.create_time) = #{month} AND
AND(
t.transaction_type = 'Credit'
OR t.refund_id IS NOT NULL
)
AND(
o. STATUS =5
OR o. STATUS =6
OR o. STATUS =7
)
and t.client_id in
(SELECT b.client_id FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id
where b.is_valid=1 and b.start_date&lt;=now() and (b.end_date is null or b.end_date &gt;= now())
AND c.bd_group=#{bd_group} or c.manager_id=#{bd_group})
</select>
<select id="listTransactionsForCityPartnerCommission" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT

Loading…
Cancel
Save