agent commission finish

master
wangning 7 years ago
parent 3bbdd7968a
commit cfb67ac4de

@ -265,8 +265,8 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
channelMap.put("Alipay", "Alipay");
channelMap.put("Wechat", "Wechat");
channelMap.put("Bestpay", "Bestpay");
channelMap.put("jd","jd");
channelMap.put("AlipayOnline","AlipayOnline");
channelMap.put("jd", "jd");
channelMap.put("AlipayOnline", "AlipayOnline");
List<JSONObject> transactionAnalysis = transactionMapper.listTransactionsForCityPartnerCommission(year, month);
Map<String, CityPartnerCommissionAnalysis> results = new HashMap<>();
for (JSONObject analysisDay : transactionAnalysis) {
@ -286,7 +286,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
CityPartnerCommissionAnalysis orgAnalysis = results.get(orgId + channel);
if (orgAnalysis == null) {
orgAnalysis = new CityPartnerCommissionAnalysis(orgId, year, month, org.getBigDecimal(channel + "_rate_value"), key, alipayChargeRate,
wechatChargeRate,jdChargeRate,alipayonlineChargeRate);
wechatChargeRate, jdChargeRate, alipayonlineChargeRate);
results.put(orgId + channel, orgAnalysis);
}
orgAnalysis.attachAnalysis(analysisDay, channel);
@ -340,7 +340,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
@Override
@Transactional
public void generateAgent(String monthStr,int orgId) {
public void generateAgent(String monthStr, int orgId) {
JSONObject org = orgMapper.findOne(orgId);
if (org == null) {
// shall never happen
@ -364,9 +364,9 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
channelMap.put("Alipay", "Alipay");
channelMap.put("Wechat", "Wechat");
channelMap.put("Bestpay", "Bestpay");
channelMap.put("jd","jd");
channelMap.put("AlipayOnline","AlipayOnline");
List<JSONObject> transactionAnalysis = transactionMapper.listTransactionsForAgentCommission(year, month,org.getIntValue("parent_org_id"));
channelMap.put("jd", "jd");
channelMap.put("AlipayOnline", "AlipayOnline");
List<JSONObject> transactionAnalysis = transactionMapper.listTransactionsForAgentCommission(year, month, org.getIntValue("parent_org_id"));
Map<String, AgentCommissionAnalysis> results = new HashMap<>();
for (JSONObject analysisDay : transactionAnalysis) {
String key = analysisDay.getString("channel");
@ -377,7 +377,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
channel = channel.toLowerCase();
AgentCommissionAnalysis agentCommissionAnalysis = results.get(orgId + channel);
if (agentCommissionAnalysis == null) {
agentCommissionAnalysis = new AgentCommissionAnalysis(orgId, year, month, org.getBigDecimal(channel + "_rate_value"), key,org,parnetOrg);
agentCommissionAnalysis = new AgentCommissionAnalysis(orgId, year, month, org.getBigDecimal(channel + "_rate_value"), key, org, parnetOrg);
results.put(orgId + channel, agentCommissionAnalysis);
}
agentCommissionAnalysis.attachAnalysis(analysisDay, channel);
@ -561,13 +561,12 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
if (CollectionUtils.isEmpty(total)) {
return null;
}
BigDecimal royalpay_charge = BigDecimal.ZERO;
List<JSONObject> partnerPrizeList = getCityPartnerPrizeInfoList(monthStr);
Map<Integer, JSONObject> countPartnerPrizeMap = new HashMap<>();
List<JSONObject> partnerPrizeList = financialPartnerCommissionDetailMapper.listDetailByMonth(year,month);
Map<String, JSONObject> countPartnerPrizeMap = new HashMap<>();
for (JSONObject p : partnerPrizeList) {
royalpay_charge = royalpay_charge.add(p.getBigDecimal("royalpay_charge"));
Integer key = p.getInteger("client_id");
String key = p.getString("client_id")+p.getString("channel").toLowerCase();
JSONObject partnerTmp = countPartnerPrizeMap.get(key);
if (partnerTmp == null) {
JSONObject partner = new JSONObject();
@ -578,11 +577,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
}
}
String tableColumn[] = { "gross_amount", "total_charge", "org_charge", "org_net_charge" };
List<String> recordIds = new ArrayList<>();
@ -607,6 +601,12 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
detail.put("date_from", format.format(detail.get("date_from")));
detail.put("date_to", format.format(detail.get("date_to")));
String key = detail.getString("client_id");
detail.put("royalpay_charge",BigDecimal.ZERO);
if(countPartnerPrizeMap.get(key+detail.getString("channel").toLowerCase())!=null){
detail.put("royalpay_charge",countPartnerPrizeMap.get(key+detail.getString("channel")).getBigDecimal("royalpay_charge"));
}else {
detail.put("royalpay_charge",BigDecimal.ZERO);
}
if (detailMap.containsKey(key)) {
detailMap.get(key).add(detail);
} else {
@ -633,7 +633,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
for (JSONObject jsonObject : entry.getValue()) {
grossAmount = grossAmount.add(jsonObject.getBigDecimal("gross_amount"));
totalCharge = totalCharge.add(jsonObject.getBigDecimal("total_charge"));
// royalpayCharge = royalpayCharge.add(jsonObject.getBigDecimal("royalpay_charge"));
royalpayCharge = royalpayCharge.add(jsonObject.getBigDecimal("royalpay_charge"));
orgCharge = orgCharge.add(jsonObject.getBigDecimal("org_charge"));
if (jsonObject.getBigDecimal("net_charge") != null) {
netCharge = netCharge.add(jsonObject.getBigDecimal("org_net_charge"));

@ -192,10 +192,29 @@ public class CityPartnerPrizeController {
@RequestMapping(value = "/agent/months/{monthStr}")
public JSONObject getAgentPrizeInfo(@PathVariable String monthStr) {
List<JSONObject> partnerPrizeList = cityPartnerPrizeService.getCityPartnerPrizeInfoList(monthStr);
Map<String, JSONObject> countPartnerPrizeMap = new HashMap<>();
for (JSONObject p : partnerPrizeList) {
String key = p.getString("org_id");
JSONObject partnerTmp = countPartnerPrizeMap.get(key);
if (partnerTmp == null) {
JSONObject partner = new JSONObject();
partner.put("royalpay_charge", p.getBigDecimal("royalpay_charge"));
countPartnerPrizeMap.put(key, partner);
} else {
partnerTmp.put("royalpay_charge", partnerTmp.getBigDecimal("royalpay_charge").add(p.getBigDecimal("royalpay_charge")));
}
}
List<JSONObject> partnerPrizeInfos = cityPartnerPrizeService.getAgentPrizeInfoList(monthStr);
Map<String, List<JSONObject>> partenerPrizeMap = new HashMap<>();
for (JSONObject partnerPrizeInfo : partnerPrizeInfos) {
String key = partnerPrizeInfo.getString("org_id");
if(countPartnerPrizeMap.containsKey(key)){
partnerPrizeInfo.put("royalpay_charge",countPartnerPrizeMap.get(key).getBigDecimal("royalpay_charge"));
}else {
partnerPrizeInfo.put("royalpay_charge",BigDecimal.ZERO);
}
if (partenerPrizeMap.containsKey(key)) {
partenerPrizeMap.get(key).add(partnerPrizeInfo);
} else {
@ -205,22 +224,8 @@ public class CityPartnerPrizeController {
}
}
BigDecimal royalpay_charge = BigDecimal.ZERO;
List<JSONObject> partnerPrizeList = cityPartnerPrizeService.getCityPartnerPrizeInfoList(monthStr);
Map<Integer, JSONObject> countPartnerPrizeMap = new HashMap<>();
for (JSONObject p : partnerPrizeList) {
royalpay_charge = royalpay_charge.add(p.getBigDecimal("royalpay_charge"));
Integer key = p.getInteger("org_id");
JSONObject partnerTmp = countPartnerPrizeMap.get(key);
if (partnerTmp == null) {
JSONObject partner = new JSONObject();
partner.put("royalpay_charge", p.getBigDecimal("royalpay_charge"));
countPartnerPrizeMap.put(key, partner);
} else {
partnerTmp.put("royalpay_charge", partnerTmp.getBigDecimal("royalpay_charge").add(p.getBigDecimal("royalpay_charge")));
}
}
JSONObject result = new JSONObject();
List<JSONObject> partnerInfos = new ArrayList<>(partenerPrizeMap.size());
@ -228,12 +233,15 @@ public class CityPartnerPrizeController {
BigDecimal resultOrgCharge = BigDecimal.ZERO;
BigDecimal resultAgentCharge = BigDecimal.ZERO;
BigDecimal resultOrgNetCharge = BigDecimal.ZERO;
BigDecimal resultRoyalpayCharge = BigDecimal.ZERO;
for (Map.Entry<String, List<JSONObject>> entry : partenerPrizeMap.entrySet()) {
JSONObject sumResult = new JSONObject();
BigDecimal grossAmount = BigDecimal.ZERO;
BigDecimal orgCharge = BigDecimal.ZERO;
BigDecimal agentCharge = BigDecimal.ZERO;
BigDecimal orgNetCharge = BigDecimal.ZERO;
BigDecimal royalpayCharge = BigDecimal.ZERO;
String cityPartnerName = "";
int org_id = 0;
for (JSONObject jsonObject : entry.getValue()) {
@ -241,6 +249,7 @@ public class CityPartnerPrizeController {
orgCharge = orgCharge.add(jsonObject.getBigDecimal("org_charge"));
agentCharge = agentCharge.add(jsonObject.getBigDecimal("total_charge"));
orgNetCharge = orgNetCharge.add(jsonObject.getBigDecimal("org_net_charge"));
royalpayCharge = royalpayCharge.add(jsonObject.getBigDecimal("royalpay_charge"));
org_id = jsonObject.getIntValue("org_id");
cityPartnerName = jsonObject.getString("name");
}
@ -250,8 +259,7 @@ public class CityPartnerPrizeController {
sumResult.put("org_name", cityPartnerName);
sumResult.put("org_id", org_id);
sumResult.put("channel_detail", entry.getValue());
sumResult.put("royalpay_charge",countPartnerPrizeMap.get(org_id)==null?0:countPartnerPrizeMap.get(org_id).getBigDecimal("royalpay_charge"));
sumResult.put("royalpay_charge",royalpayCharge);
resultGrossAmount = resultGrossAmount.add(grossAmount);
resultOrgCharge = resultOrgCharge.add(orgCharge);
resultAgentCharge = resultAgentCharge.add(agentCharge);
@ -259,14 +267,13 @@ public class CityPartnerPrizeController {
partnerInfos.add(sumResult);
}
result.put("royalpay_charge", royalpay_charge);
result.put("royalpay_charge", resultRoyalpayCharge);
result.put("monthstr", monthStr);
result.put("gross_amount", resultGrossAmount);
result.put("agent_total_charge", resultAgentCharge);
result.put("org_charge", resultOrgCharge);
result.put("org_net_charge", resultOrgNetCharge);
result.put("partner_info_list", partnerInfos);
return result;
}
}

@ -13,7 +13,7 @@
RoyalPay Charge:<span ng-bind="monthData.royalpay_charge|currency:'AUD'"></span>
</div>
<div class="col-xs-6 col-sm-3">
Net Charge:<span ng-bind="monthData.org_net_charge|currency:'AUD'"></span>
Org Net Charge:<span ng-bind="monthData.org_net_charge|currency:'AUD'"></span>
</div>
<div class="col-xs-6 col-sm-3">
Org Charge:<span ng-bind="monthData.org_charge|currency:'AUD'"></span>
@ -60,7 +60,7 @@
<th>Transaction Amount</th>
<th>Total Charge</th>
<th>RoyalPay Charge</th>
<th>Net Charge</th>
<th>Org Net Charge</th>
<th>City Partner Charge</th>
<th>channel</th>
</tr>
@ -71,7 +71,7 @@
<td ng-bind="detail.gross_amount"></td>
<td ng-bind="detail.total_charge"></td>
<td ng-bind="detail.royalpay_charge"></td>
<td ng-bind="detail.net_charge"></td>
<td ng-bind="detail.org_net_charge"></td>
<td ng-bind="detail.org_charge"></td>
<td ng-bind="detail.channel"></td>
</tr>

Loading…
Cancel
Save