Merge branch 'partnerCommission' into develop

master
wangning 7 years ago
commit f14b7c10b9

@ -181,3 +181,7 @@ CREATE TABLE `financial_agent_commission_detail` (
`org_net_charge` decimal(12,2) DEFAULT NULL COMMENT '净值', `org_net_charge` decimal(12,2) DEFAULT NULL COMMENT '净值',
PRIMARY KEY (`detail_id`) PRIMARY KEY (`detail_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
alter table financial_partner_commission add column commission_type smallint(1) DEFAULT 1 COMMENT '提成类型 1:渠道计算法 2:总交易额比例 3:收益比例';
alter table financial_partner_commission_detail add column commission_type smallint(1) DEFAULT 1 COMMENT '提成类型 1:渠道计算法 2:总交易额比例 3:收益比例';

@ -1,6 +1,8 @@
package au.com.royalpay.payment.manage.citypartner.beans; package au.com.royalpay.payment.manage.citypartner.beans;
import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -18,7 +20,9 @@ public class CityPartnerCommissionAnalysis {
private BigDecimal jdChargeRate; private BigDecimal jdChargeRate;
private BigDecimal alipayonlineChargeRate; private BigDecimal alipayonlineChargeRate;
private BigDecimal rate; private BigDecimal rate;
private BigDecimal orgRate;
private String channel; private String channel;
private int commissionType;
private Map<Integer, List<JSONObject>> clientAnalysis = new HashMap<>(); private Map<Integer, List<JSONObject>> clientAnalysis = new HashMap<>();
private BigDecimal totalGrossAmount = BigDecimal.ZERO; private BigDecimal totalGrossAmount = BigDecimal.ZERO;
private BigDecimal totalChargeSum = BigDecimal.ZERO; private BigDecimal totalChargeSum = BigDecimal.ZERO;
@ -26,16 +30,31 @@ public class CityPartnerCommissionAnalysis {
private BigDecimal totalOrgChargeSum = BigDecimal.ZERO; private BigDecimal totalOrgChargeSum = BigDecimal.ZERO;
private BigDecimal totalnetCharge = BigDecimal.ZERO; private BigDecimal totalnetCharge = BigDecimal.ZERO;
public CityPartnerCommissionAnalysis(int orgId, int year, int month, BigDecimal rate,String channel,BigDecimal alipayChargeRate,BigDecimal wechatChargeRate,BigDecimal jdChargeRate,BigDecimal alipayonlineChargeRate) { public CityPartnerCommissionAnalysis(int orgId, int year, int month, BigDecimal rate, String channel, BigDecimal alipayChargeRate,
BigDecimal wechatChargeRate, BigDecimal jdChargeRate, BigDecimal alipayonlineChargeRate, BigDecimal orgRate,int commissionType) {
this.orgId = orgId; this.orgId = orgId;
this.year = year; this.year = year;
this.month = month; this.month = month;
this.rate = rate; this.rate = rate;
this.channel = channel; this.channel = channel;
this.commissionType = commissionType;
this.alipayChargeRate = alipayChargeRate; this.alipayChargeRate = alipayChargeRate;
this.wechatChargeRate = wechatChargeRate; this.wechatChargeRate = wechatChargeRate;
this.jdChargeRate = jdChargeRate; this.jdChargeRate = jdChargeRate;
this.alipayonlineChargeRate = alipayonlineChargeRate; this.alipayonlineChargeRate = alipayonlineChargeRate;
this.orgRate = orgRate;
}
public CityPartnerCommissionAnalysis calculator(JSONObject dayAnalysis, String channel, int type) {
switch (type) {
case 1:
return attachAnalysis(dayAnalysis, channel);
case 3:
return attachNetCommissionAnalysis(dayAnalysis, channel);
default:
throw new ServerErrorException("unkonw calculate type");
}
} }
public CityPartnerCommissionAnalysis attachAnalysis(JSONObject dayAnalysis, String channel) { public CityPartnerCommissionAnalysis attachAnalysis(JSONObject dayAnalysis, String channel) {
@ -52,27 +71,9 @@ public class CityPartnerCommissionAnalysis {
BigDecimal royalpayCharge = total.multiply(rate).divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP); BigDecimal royalpayCharge = total.multiply(rate).divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP);
BigDecimal thirdPartyPaymentCharge = BigDecimal.ZERO; BigDecimal thirdPartyPaymentCharge = getThirdPartyCharge(channel, total);
switch (channel){
case "alipay":
thirdPartyPaymentCharge = total.multiply(alipayChargeRate).divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP);
break;
case "wechat":
thirdPartyPaymentCharge = total.multiply(wechatChargeRate).divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP);
break;
case "jd":
thirdPartyPaymentCharge = total.multiply(jdChargeRate).divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP);
break;
case "alipayonline":
thirdPartyPaymentCharge = total.multiply(alipayonlineChargeRate).divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP);
break;
default:
break;
}
BigDecimal netCharge = royalpayCharge.subtract(thirdPartyPaymentCharge); BigDecimal netCharge = royalpayCharge.subtract(thirdPartyPaymentCharge);
BigDecimal orgCharge = dayCharge.subtract(royalpayCharge); BigDecimal orgCharge = dayCharge.subtract(royalpayCharge);
totalGrossAmount = totalGrossAmount.add(total); totalGrossAmount = totalGrossAmount.add(total);
@ -115,6 +116,7 @@ public class CityPartnerCommissionAnalysis {
item.put("org_charge", orgCharge); item.put("org_charge", orgCharge);
item.put("channel", channel); item.put("channel", channel);
item.put("net_charge", netCharge); item.put("net_charge", netCharge);
item.put("commission_type",commissionType);
clientTrades.add(item); clientTrades.add(item);
return this; return this;
} }
@ -132,6 +134,7 @@ public class CityPartnerCommissionAnalysis {
result.put("org_charge", totalOrgChargeSum); result.put("org_charge", totalOrgChargeSum);
result.put("net_charge", totalnetCharge); result.put("net_charge", totalnetCharge);
result.put("channel", channel); result.put("channel", channel);
result.put("commission_type",commissionType);
return result; return result;
} }
@ -147,4 +150,87 @@ public class CityPartnerCommissionAnalysis {
} }
return list; return list;
} }
public CityPartnerCommissionAnalysis attachNetCommissionAnalysis(JSONObject dayAnalysis, String channel) {
int clientId = dayAnalysis.getIntValue("client_id");
List<JSONObject> clientTrades = clientAnalysis.get(clientId);
if (clientTrades == null) {
clientTrades = new ArrayList<>();
clientAnalysis.put(clientId, clientTrades);
}
Date tradeDate = dayAnalysis.getDate("trade_date");
BigDecimal total = dayAnalysis.getBigDecimal("total");
BigDecimal dayRate = dayAnalysis.getBigDecimal(channel + "_rate_value");
BigDecimal dayCharge = total.multiply(dayRate).divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP);
BigDecimal royalpayCharge = total.multiply(rate).divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP);
BigDecimal thirdPartyPaymentCharge = getThirdPartyCharge(channel, total);
BigDecimal netCharge = royalpayCharge.subtract(thirdPartyPaymentCharge);
BigDecimal orgCharge = netCharge.multiply(orgRate).divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP);
totalGrossAmount = totalGrossAmount.add(total);
totalChargeSum = totalChargeSum.add(dayCharge);
totalRoyalPayCharge = totalRoyalPayCharge.add(royalpayCharge);
totalOrgChargeSum = totalOrgChargeSum.add(orgCharge);
totalnetCharge = totalnetCharge.add(netCharge);
if (!clientTrades.isEmpty()) {
JSONObject item = clientTrades.get(clientTrades.size() - 1);
BigDecimal rate = item.getBigDecimal("client_rate");
if (rate.compareTo(dayRate) == 0) {
BigDecimal gross = item.getBigDecimal("gross_amount").add(total);
item.put("gross_amount", gross);
BigDecimal totalCharge = item.getBigDecimal("total_charge").add(dayCharge);
item.put("total_charge", totalCharge);
BigDecimal totalRoyalCharge = item.getBigDecimal("royalpay_charge").add(royalpayCharge);
item.put("royalpay_charge", totalRoyalCharge);
BigDecimal totalOrgCharge = item.getBigDecimal("org_charge").add(orgCharge);
item.put("org_charge", totalOrgCharge);
BigDecimal totalRoyalpayClearingCharge = item.getBigDecimal("net_charge").add(netCharge);
item.put("net_charge", totalRoyalpayClearingCharge);
Date from = item.getDate("date_from");
Date to = item.getDate("date_to");
from = from.before(tradeDate) ? from : tradeDate;
to = to.after(tradeDate) ? to : tradeDate;
item.put("date_from", from);
item.put("date_to", to);
return this;
}
}
JSONObject item = new JSONObject();
item.put("year", year);
item.put("month", month);
item.put("date_from", tradeDate);
item.put("date_to", tradeDate);
item.put("client_rate", dayRate);
item.put("gross_amount", total);
item.put("total_charge", dayCharge);
item.put("royalpay_charge", royalpayCharge);
item.put("org_charge", orgCharge);
item.put("channel", channel);
item.put("net_charge", netCharge);
clientTrades.add(item);
return this;
}
private BigDecimal getThirdPartyCharge(String channel, BigDecimal total) {
BigDecimal thirdPartyPaymentCharge = BigDecimal.ZERO;
switch (channel) {
case "alipay":
thirdPartyPaymentCharge = total.multiply(alipayChargeRate).divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP);
break;
case "wechat":
thirdPartyPaymentCharge = total.multiply(wechatChargeRate).divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP);
break;
case "jd":
thirdPartyPaymentCharge = total.multiply(jdChargeRate).divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP);
break;
case "alipayonline":
thirdPartyPaymentCharge = total.multiply(alipayonlineChargeRate).divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP);
break;
default:
break;
}
return thirdPartyPaymentCharge;
}
} }

@ -36,7 +36,6 @@ public class ReferrerCommissionAnalysis {
BigDecimal total = dayAnalysis.getBigDecimal("total"); BigDecimal total = dayAnalysis.getBigDecimal("total");
BigDecimal orgCharge = total.multiply(referrerRate).divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP); BigDecimal orgCharge = total.multiply(referrerRate).divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP);
Date tradeDate = dayAnalysis.getDate("trade_date"); Date tradeDate = dayAnalysis.getDate("trade_date");
BigDecimal dayRate = dayAnalysis.getBigDecimal("rate_value");
totalGrossAmount = totalGrossAmount.add(total); totalGrossAmount = totalGrossAmount.add(total);
totalOrgChargeSum = totalOrgChargeSum.add(orgCharge); totalOrgChargeSum = totalOrgChargeSum.add(orgCharge);

@ -1,5 +1,27 @@
package au.com.royalpay.payment.manage.citypartner.core.impls; package au.com.royalpay.payment.manage.citypartner.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.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject;
import au.com.royalpay.payment.manage.citypartner.beans.AgentCommissionAnalysis; import au.com.royalpay.payment.manage.citypartner.beans.AgentCommissionAnalysis;
import au.com.royalpay.payment.manage.citypartner.beans.CityPartnerCommissionAnalysis; import au.com.royalpay.payment.manage.citypartner.beans.CityPartnerCommissionAnalysis;
import au.com.royalpay.payment.manage.citypartner.beans.ReferrerCommissionAnalysis; import au.com.royalpay.payment.manage.citypartner.beans.ReferrerCommissionAnalysis;
@ -16,26 +38,6 @@ import au.com.royalpay.payment.tools.env.SysConfigManager;
import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
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.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
/** /**
* Created by yixian on 2017-03-08. * Created by yixian on 2017-03-08.
*/ */
@ -195,6 +197,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
BigDecimal netCharge = BigDecimal.ZERO; BigDecimal netCharge = BigDecimal.ZERO;
BigDecimal orgCharge = BigDecimal.ZERO; BigDecimal orgCharge = BigDecimal.ZERO;
String clientMoniker = ""; String clientMoniker = "";
int type = 1;
for (JSONObject jsonObject : entry.getValue()) { for (JSONObject jsonObject : entry.getValue()) {
grossAmount = grossAmount.add(jsonObject.getBigDecimal("gross_amount")); grossAmount = grossAmount.add(jsonObject.getBigDecimal("gross_amount"));
totalCharge = totalCharge.add(jsonObject.getBigDecimal("total_charge")); totalCharge = totalCharge.add(jsonObject.getBigDecimal("total_charge"));
@ -204,6 +207,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
netCharge = netCharge.add(jsonObject.getBigDecimal("net_charge")); netCharge = netCharge.add(jsonObject.getBigDecimal("net_charge"));
} }
clientMoniker = jsonObject.getString("client_moniker"); clientMoniker = jsonObject.getString("client_moniker");
type = jsonObject.getIntValue("type");
} }
resultGrossAmount = resultGrossAmount.add(grossAmount); resultGrossAmount = resultGrossAmount.add(grossAmount);
resultTotalCharge = resultTotalCharge.add(totalCharge); resultTotalCharge = resultTotalCharge.add(totalCharge);
@ -217,6 +221,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
sumResult.put("net_charge", netCharge); sumResult.put("net_charge", netCharge);
sumResult.put("client_moniker", clientMoniker); sumResult.put("client_moniker", clientMoniker);
sumResult.put("channel_detail", entry.getValue()); sumResult.put("channel_detail", entry.getValue());
sumResult.put("type",type);
partnerClientInfos.add(sumResult); partnerClientInfos.add(sumResult);
} }
result.put("partner_client_infos", partnerClientInfos); result.put("partner_client_infos", partnerClientInfos);
@ -242,8 +247,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
int year = monthCal.get(Calendar.YEAR); int year = monthCal.get(Calendar.YEAR);
int month = monthCal.get(Calendar.MONTH) + 1; int month = monthCal.get(Calendar.MONTH) + 1;
financialPartnerCommissionDetailMapper.clearData(year, month);
financialPartnerCommissionMapper.clearData(year, month);
JSONObject sysConfig = sysConfigManager.getSysConfig(); JSONObject sysConfig = sysConfigManager.getSysConfig();
BigDecimal alipayChargeRate = new BigDecimal("0.6"); BigDecimal alipayChargeRate = new BigDecimal("0.6");
BigDecimal wechatChargeRate = new BigDecimal("0.6"); BigDecimal wechatChargeRate = new BigDecimal("0.6");
@ -267,29 +271,36 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
channelMap.put("Bestpay", "Bestpay"); channelMap.put("Bestpay", "Bestpay");
channelMap.put("jd", "jd"); channelMap.put("jd", "jd");
channelMap.put("AlipayOnline", "AlipayOnline"); channelMap.put("AlipayOnline", "AlipayOnline");
Set<Integer> orgIds = new HashSet<>();
List<JSONObject> transactionAnalysis = transactionMapper.listTransactionsForCityPartnerCommission(year, month); List<JSONObject> transactionAnalysis = transactionMapper.listTransactionsForCityPartnerCommission(year, month);
Map<String, CityPartnerCommissionAnalysis> results = new HashMap<>(); Map<String, CityPartnerCommissionAnalysis> results = new HashMap<>();
for (JSONObject analysisDay : transactionAnalysis) { for (JSONObject analysisDay : transactionAnalysis) {
String key = analysisDay.getString("channel");
String channel = analysisDay.getString("channel");
if (!channelMap.containsKey(key)) {
continue;
}
int orgId = analysisDay.getIntValue("org_id"); int orgId = analysisDay.getIntValue("org_id");
JSONObject org = orgMapper.findOne(orgId); JSONObject org = orgMapper.findOne(orgId);
if(org.getIntValue("parent_org_id")>0){
orgIds.add(orgId);
}
if (org == null) { if (org == null) {
// shall never happen // shall never happen
throw new ServerErrorException("Organization Id not exists:" + orgId); throw new ServerErrorException("Organization Id not exists:" + orgId);
} }
financialPartnerCommissionDetailMapper.clearData(year, month,org.getIntValue("commission_type"));
financialPartnerCommissionMapper.clearData(year, month,org.getIntValue("commission_type"));
String key = analysisDay.getString("channel");
String channel = analysisDay.getString("channel");
if (!channelMap.containsKey(key)) {
continue;
}
channel = channel.toLowerCase(); channel = channel.toLowerCase();
CityPartnerCommissionAnalysis orgAnalysis = results.get(orgId + channel); CityPartnerCommissionAnalysis orgAnalysis = results.get(orgId + channel);
if (orgAnalysis == null) { if (orgAnalysis == null) {
orgAnalysis = new CityPartnerCommissionAnalysis(orgId, year, month, org.getBigDecimal(channel + "_rate_value"), key, alipayChargeRate, orgAnalysis = new CityPartnerCommissionAnalysis(orgId, year, month, org.getBigDecimal(channel + "_rate_value"), key, alipayChargeRate,
wechatChargeRate, jdChargeRate, alipayonlineChargeRate); wechatChargeRate, jdChargeRate, alipayonlineChargeRate,org.getBigDecimal("rate_value"),org.getIntValue("commission_type"));
results.put(orgId + channel, orgAnalysis); results.put(orgId + channel, orgAnalysis);
} }
orgAnalysis.attachAnalysis(analysisDay, channel); orgAnalysis.calculator(analysisDay, channel,org.getIntValue("commission_type"));
} }
for (CityPartnerCommissionAnalysis commission : results.values()) { for (CityPartnerCommissionAnalysis commission : results.values()) {
@ -301,7 +312,12 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
financialPartnerCommissionDetailMapper.save(detail); financialPartnerCommissionDetailMapper.save(detail);
} }
} }
Runnable task = ()->{
orgIds.forEach((p)->{
generateAgent(monthStr,p);
});
};
new Thread(task).start();
} }
@Override @Override
@ -521,6 +537,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
JSONObject chargeInfo = getAgentPrizeInfo(item.getString("monthstr")); JSONObject chargeInfo = getAgentPrizeInfo(item.getString("monthstr"));
item.put("org_charge", chargeInfo.getString("org_charge")); item.put("org_charge", chargeInfo.getString("org_charge"));
item.put("gross_amount", chargeInfo.getString("gross_amount")); item.put("gross_amount", chargeInfo.getString("gross_amount"));
item.put("total_charge", chargeInfo.getString("total_charge"));
monthObjs.add(item); monthObjs.add(item);
} }
return monthObjs; return monthObjs;
@ -536,10 +553,12 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
JSONObject sum = new JSONObject(); JSONObject sum = new JSONObject();
sum.put("gross_amount", 0); sum.put("gross_amount", 0);
sum.put("org_charge", 0); sum.put("org_charge", 0);
sum.put("total_charge",0);
List<JSONObject> referrerPrizes = financialAgentCommissionMapper.list(year, month); List<JSONObject> referrerPrizes = financialAgentCommissionMapper.list(year, month);
for (JSONObject prize : referrerPrizes) { for (JSONObject prize : referrerPrizes) {
plusKey(sum, prize, "gross_amount"); plusKey(sum, prize, "gross_amount");
plusKey(sum, prize, "org_charge"); plusKey(sum, prize, "org_charge");
plusKey(sum, prize, "total_charge");
prize.put("monthstr", monthStr); prize.put("monthstr", monthStr);
} }
sum.put("referrer", referrerPrizes); sum.put("referrer", referrerPrizes);

@ -73,6 +73,7 @@ public class CityPartnerPrizeController {
BigDecimal netCharge = BigDecimal.ZERO; BigDecimal netCharge = BigDecimal.ZERO;
String cityPartnerName = ""; String cityPartnerName = "";
int org_id = 0; int org_id = 0;
int type = 1;
for (JSONObject jsonObject : entry.getValue()) { for (JSONObject jsonObject : entry.getValue()) {
grossAmount = grossAmount.add(jsonObject.getBigDecimal("gross_amount")); grossAmount = grossAmount.add(jsonObject.getBigDecimal("gross_amount"));
totalCharge = totalCharge.add(jsonObject.getBigDecimal("total_charge")); totalCharge = totalCharge.add(jsonObject.getBigDecimal("total_charge"));
@ -83,6 +84,7 @@ public class CityPartnerPrizeController {
} }
org_id = jsonObject.getIntValue("org_id"); org_id = jsonObject.getIntValue("org_id");
cityPartnerName = jsonObject.getString("name"); cityPartnerName = jsonObject.getString("name");
type = jsonObject.getIntValue("commission_type");
} }
sumResult.put("gross_amount", grossAmount); sumResult.put("gross_amount", grossAmount);
sumResult.put("total_charge", totalCharge); sumResult.put("total_charge", totalCharge);
@ -91,6 +93,7 @@ public class CityPartnerPrizeController {
sumResult.put("org_name", cityPartnerName); sumResult.put("org_name", cityPartnerName);
sumResult.put("org_id", org_id); sumResult.put("org_id", org_id);
sumResult.put("net_charge", netCharge); sumResult.put("net_charge", netCharge);
sumResult.put("type",type);
sumResult.put("channel_detail", entry.getValue()); sumResult.put("channel_detail", entry.getValue());
resultTotalCharge = resultTotalCharge.add(totalCharge); resultTotalCharge = resultTotalCharge.add(totalCharge);
resultRoyalpayCharge = resultRoyalpayCharge.add(royalpayCharge); resultRoyalpayCharge = resultRoyalpayCharge.add(royalpayCharge);
@ -174,12 +177,6 @@ public class CityPartnerPrizeController {
return result; return result;
} }
@RequestMapping(value = "/agent/generate", method = RequestMethod.POST)
public void generateAgent(@RequestBody JSONObject param, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject managerInfo) {
String month = param.getString("month");
cityPartnerPrizeService.generateAgent(month, managerInfo.getIntValue("org_id"));
}
@ManagerMapping("/agent/months/{monthStr}/orgs/{orgId}") @ManagerMapping("/agent/months/{monthStr}/orgs/{orgId}")
public JSONObject getAgentPrizeDetail(@PathVariable String monthStr, @PathVariable String orgId) { public JSONObject getAgentPrizeDetail(@PathVariable String monthStr, @PathVariable String orgId) {
return cityPartnerPrizeService.getAgentPrizeDetail(monthStr, orgId); return cityPartnerPrizeService.getAgentPrizeDetail(monthStr, orgId);

@ -14,7 +14,7 @@ import java.util.List;
@AutoMapper(tablename = "financial_partner_commission_detail", pkName = "detail_id") @AutoMapper(tablename = "financial_partner_commission_detail", pkName = "detail_id")
public interface FinancialPartnerCommissionDetailMapper { public interface FinancialPartnerCommissionDetailMapper {
@AutoSql(type = SqlType.DELETE) @AutoSql(type = SqlType.DELETE)
void clearData(@Param("year") int year, @Param("month") int month); void clearData(@Param("year") int year, @Param("month") int month,@Param("commission_type") int commission_type);
@AutoSql(type = SqlType.INSERT) @AutoSql(type = SqlType.INSERT)
void save(JSONObject detail); void save(JSONObject detail);

@ -14,7 +14,7 @@ import java.util.List;
@AutoMapper(tablename = "financial_partner_commission", pkName = "record_id") @AutoMapper(tablename = "financial_partner_commission", pkName = "record_id")
public interface FinancialPartnerCommissionMapper { public interface FinancialPartnerCommissionMapper {
@AutoSql(type = SqlType.DELETE) @AutoSql(type = SqlType.DELETE)
void clearData(@Param("year") int year, @Param("month") int month); void clearData(@Param("year") int year, @Param("month") int month,@Param("commission_type") int commission_type);
@AutoSql(type = SqlType.INSERT) @AutoSql(type = SqlType.INSERT)
void save(JSONObject commissionAnalysis); void save(JSONObject commissionAnalysis);

@ -326,8 +326,8 @@ margin-bottom: 10%;"/>
<i class="fa fa-users"></i> <span>周末费率减半活动</span> <i class="fa fa-users"></i> <span>周末费率减半活动</span>
</a> </a>
</li> </li>
<li class="header nav-header" ng-if="('1000000000000'|withRole)|| currentUser.org_id==null">机构|Agent</li> <li class="header nav-header" ng-if="('1000000000000'|withRole)">机构|Agent</li>
<li ui-sref-active="active" ng-if="('1000000000000'|withRole)|| currentUser.org_id==null"> <li ui-sref-active="active" ng-if="('1000000000000'|withRole)">
<a ui-sref="analysis_agent" ui-sref-opts="{reload:true}"> <a ui-sref="analysis_agent" ui-sref-opts="{reload:true}">
<i class="fa fa-hand-peace-o"></i> <span>机构数据分析|Agent Analysis</span> <i class="fa fa-hand-peace-o"></i> <span>机构数据分析|Agent Analysis</span>
</a> </a>

@ -9,6 +9,9 @@
<div class="col-xs-6 col-sm-3"> <div class="col-xs-6 col-sm-3">
Total Charge:<span ng-bind="monthData.agent_total_charge|currency:'AUD'"></span> Total Charge:<span ng-bind="monthData.agent_total_charge|currency:'AUD'"></span>
</div> </div>
<div class="col-xs-6 col-sm-3">
Gross Amount:<span ng-bind="monthData.gross_amount|currency:'AUD'"></span>
</div>
<div class="col-xs-6 col-sm-3"> <div class="col-xs-6 col-sm-3">
RoyalPay Charge:<span ng-bind="monthData.royalpay_charge|currency:'AUD'"></span> RoyalPay Charge:<span ng-bind="monthData.royalpay_charge|currency:'AUD'"></span>
</div> </div>

@ -1,27 +1,4 @@
<!--<section class="content-header">-->
<!--<h1>City Partner Commissions</h1>-->
<!--<ol class="breadcrumb">-->
<!--<li><i class="fa fa-users"></i> Analysis</li>-->
<!--<li class="active">City Partner Commissions</li>-->
<!--</ol>-->
<!--</section>-->
<section class="content"> <section class="content">
<div class="box box-default">
<div class="box-body">
<div class="form-inline">
<div class="form-group">
<input type="text" class="form-control" uib-datepicker-popup="yyyy-MM" ng-model="generate.month"
is-open="ctrl.genmonth" datepicker-options="{minMode: 'month'}"
ng-click="ctrl.genmonth=true" placeholder="Select Month"/>
</div>
<button class="btn btn-primary" ng-click="generateAgentCommission()" ng-disabled="!generate.month">
Generate
</button>
<loadingbar ng-if="generate.status"></loadingbar>
</div>
</div>
</div>
<div class="box box-warning"> <div class="box box-warning">
<div class="box-header"> <div class="box-header">
<input type="text" class="hidden" uib-datepicker-popup="yyyy" ng-model="params.year" is-open="ctrl.viewyear" <input type="text" class="hidden" uib-datepicker-popup="yyyy" ng-model="params.year" is-open="ctrl.viewyear"
@ -39,7 +16,7 @@
<div> <div>
<div class="info-box-number-right"> <div class="info-box-number-right">
<span class="text-bold">Total Charge:</span> <span class="text-bold">Total Charge:</span>
<span class="text-green" ng-bind="mon.gross_amount|currency:'AUD'"></span> <span class="text-green" ng-bind="mon.total_charge|currency:'AUD'"></span>
</div> </div>
<div class="info-box-number-right"> <div class="info-box-number-right">
<span class="text-bold">Org Charge:</span> <span class="text-bold">Org Charge:</span>

@ -1,6 +1,21 @@
/** /**
* Created by yixian on 2017-03-08. * Created by yixian on 2017-03-08.
*/ */
var commissionTypeMap = [{
"label": 1,
"value": "渠道计算法"
},
{
"label": 2,
"value": "总交易额比例"
},
{
"label": 3,
"value": "收益比例"
}
];
define(['angular','../../analysis/org/analysis-org'], function (angular) { define(['angular','../../analysis/org/analysis-org'], function (angular) {
'use strict'; 'use strict';
var app = angular.module('orgcommission', ['ui.router']); var app = angular.module('orgcommission', ['ui.router']);
@ -78,9 +93,11 @@ define(['angular','../../analysis/org/analysis-org'], function (angular) {
$state.go('analysis_org.orgcommission.month', {monthStr: monthStr}) $state.go('analysis_org.orgcommission.month', {monthStr: monthStr})
}; };
}]); }]);
app.controller('orgCommissionMonthViewCtrl', ['$scope', 'monthData', function ($scope, monthData) { app.controller('orgCommissionMonthViewCtrl', ['$scope', 'monthData','$filter', function ($scope, monthData) {
$scope.monthData = monthData.data; $scope.monthData = monthData.data;
$scope.ctrl = {}; $scope.ctrl = {};
$scope.commissionTypeMap = commissionTypeMap;
$scope.active = function (log) { $scope.active = function (log) {
if($scope.ctrl.activeLog && $scope.ctrl.activeLog.org_id==log.org_id){ if($scope.ctrl.activeLog && $scope.ctrl.activeLog.org_id==log.org_id){
$scope.ctrl.activeLog=null; $scope.ctrl.activeLog=null;
@ -100,5 +117,23 @@ define(['angular','../../analysis/org/analysis-org'], function (angular) {
$scope.ctrl.activeLog=log; $scope.ctrl.activeLog=log;
} }
}]); }]);
app.filter('commission_type_filter', function () {
return function (sectorValue) {
var sectorLabel = '';
angular.forEach(commissionTypeMap, function (sector) {
if (sector.label == sectorValue) {
sectorLabel = sector.value;
}
});
return sectorLabel;
}
});
return app; return app;
}); });

@ -33,6 +33,7 @@
<th>RoyalPay Charge</th> <th>RoyalPay Charge</th>
<th>Net Charge</th> <th>Net Charge</th>
<th>City Partner Charge</th> <th>City Partner Charge</th>
<th>Type</th>
<th>Details</th> <th>Details</th>
</tr> </tr>
</thead> </thead>
@ -44,6 +45,7 @@
<td ng-bind="log.royalpay_charge|currency:'AUD'"></td> <td ng-bind="log.royalpay_charge|currency:'AUD'"></td>
<td ng-bind="log.net_charge|currency:'AUD'"></td> <td ng-bind="log.net_charge|currency:'AUD'"></td>
<td ng-bind="log.org_charge|currency:'AUD'"></td> <td ng-bind="log.org_charge|currency:'AUD'"></td>
<td ng-bind="log.type|commission_type_filter"></td>
<td> <td>
<a ui-sref=".orgdetail({orgId:log.org_id})"> <a ui-sref=".orgdetail({orgId:log.org_id})">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>

@ -17,6 +17,7 @@ import javax.annotation.Resource;
@ActiveProfiles({"local","alipay","wechat","jd","bestpay"}) @ActiveProfiles({"local","alipay","wechat","jd","bestpay"})
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
public class CityPartnerPrizeServiceImplTest { public class CityPartnerPrizeServiceImplTest {
@Resource @Resource
private CityPartnerPrizeService cityPartnerPrizeService; private CityPartnerPrizeService cityPartnerPrizeService;
@Test @Test
@ -24,4 +25,9 @@ public class CityPartnerPrizeServiceImplTest {
cityPartnerPrizeService.generateAgent("2017-06",9); cityPartnerPrizeService.generateAgent("2017-06",9);
} }
@Test
public void generate() throws Exception {
cityPartnerPrizeService.generate("2017-06");
}
} }
Loading…
Cancel
Save