Merge branch 'agent' into develop

master
wangning 7 years ago
commit 74eca570af

@ -0,0 +1,145 @@
package au.com.royalpay.payment.manage.citypartner.beans;
import au.com.royalpay.payment.tools.CommonConsts;
import com.alibaba.fastjson.JSONObject;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by yixian on 2017-03-08.
*/
public class AgentCommissionAnalysis {
private int orgId;
private int year;
private int month;
private BigDecimal rate;
private String channel;
private Map<Integer, List<JSONObject>> clientAnalysis = new HashMap<>();
private BigDecimal totalGrossAmount = BigDecimal.ZERO;
private BigDecimal totalAgentCharge = BigDecimal.ZERO;
private BigDecimal totalAgentNetCharge = BigDecimal.ZERO;
private BigDecimal totalOrgCharge = BigDecimal.ZERO;
private BigDecimal totalOrgNetCharge = BigDecimal.ZERO;
private JSONObject org;
private JSONObject parentOrg;
public AgentCommissionAnalysis(int orgId, int year, int month, BigDecimal rate,String channel,JSONObject org,JSONObject parentOrg) {
this.orgId = orgId;
this.year = year;
this.month = month;
this.rate = rate;
this.channel = channel;
this.org = org;
this.parentOrg = parentOrg;
}
public AgentCommissionAnalysis attachAnalysis(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 grossAmount = dayAnalysis.getBigDecimal("total");
BigDecimal dayRate = dayAnalysis.getBigDecimal(channel+"_rate_value");
BigDecimal agentCharge = grossAmount.multiply(dayRate.divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP));
BigDecimal orgCharge = BigDecimal.ZERO;
BigDecimal orgNetCharge = BigDecimal.ZERO;
switch (channel){
case "alipay":
orgCharge = grossAmount.multiply(org.getBigDecimal("alipay_rate_value").divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP));
orgNetCharge = orgCharge.subtract(grossAmount.multiply(parentOrg.getBigDecimal("alipay_rate_value").divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP)));
break;
case "wechat":
orgCharge = grossAmount.multiply(org.getBigDecimal("wechat_rate_value").divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP));
orgNetCharge = orgCharge.subtract(grossAmount.multiply(parentOrg.getBigDecimal("wechat_rate_value").divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP)));
break;
case "jd":
orgCharge = grossAmount.multiply(org.getBigDecimal("jd_rate_value").divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP));
orgNetCharge = orgCharge.subtract(grossAmount.multiply(parentOrg.getBigDecimal("jd_rate_value").divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP)));
break;
case "alipayonline":
orgCharge = grossAmount.multiply(org.getBigDecimal("alipayonline_rate_value").divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP));
orgNetCharge = orgCharge.subtract(grossAmount.multiply(parentOrg.getBigDecimal("alipayonline_rate_value").divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP)));
break;
default:
break;
}
totalGrossAmount = totalGrossAmount.add(grossAmount);
totalAgentCharge = totalAgentCharge.add(agentCharge);
totalAgentNetCharge = totalAgentNetCharge.add(orgNetCharge);
totalOrgCharge = totalOrgCharge.add(orgCharge);
totalOrgNetCharge = totalOrgNetCharge.add(orgNetCharge);
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(grossAmount);
item.put("gross_amount", gross);
BigDecimal totalCharge = item.getBigDecimal("total_charge").add(agentCharge);
item.put("total_charge", totalCharge);
BigDecimal totalOrgCharge = item.getBigDecimal("org_charge").add(orgCharge);
item.put("org_charge", totalOrgCharge);
BigDecimal totalRoyalpayClearingCharge = item.getBigDecimal("org_net_charge").add(orgNetCharge);
item.put("org_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", grossAmount);
item.put("total_charge", agentCharge);
item.put("org_charge", orgCharge);
item.put("channel",channel);
item.put("org_net_charge",orgNetCharge);
clientTrades.add(item);
return this;
}
public JSONObject totalCommission() {
JSONObject result = new JSONObject();
result.put("org_id", orgId);
result.put("year", year);
result.put("month", month);
result.put("create_time", new Date());
result.put("org_rate", rate);
result.put("gross_amount", totalGrossAmount);
result.put("total_charge", totalAgentCharge);
result.put("org_charge", totalOrgCharge);
result.put("org_net_charge",totalOrgNetCharge);
result.put("channel",channel);
return result;
}
public List<JSONObject> getCommissionDetails(String recordId) {
List<JSONObject> list = new ArrayList<>();
for (Map.Entry<Integer, List<JSONObject>> entry : clientAnalysis.entrySet()) {
int clientId = entry.getKey();
for (JSONObject item : entry.getValue()) {
item.put("client_id", clientId);
item.put("record_id", recordId);
list.add(item);
}
}
return list;
}
}

@ -29,5 +29,15 @@ public interface CityPartnerPrizeService {
List<JSONObject> getReferrerPrizeInfoList(String monthStr);
void generateAgent(String month,int orgId);
List<JSONObject> listAgentAvailableMonths(String year);
JSONObject getAgentPrizeInfo(String monthStr);
JSONObject getAgentPrizeDetail(String monthStr, String orgId);
List<JSONObject> getAgentPrizeInfoList(String monthStr);
}

@ -1,8 +1,11 @@
package au.com.royalpay.payment.manage.citypartner.core.impls;
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.ReferrerCommissionAnalysis;
import au.com.royalpay.payment.manage.citypartner.core.CityPartnerPrizeService;
import au.com.royalpay.payment.manage.mappers.financial.FinancialAgentCommissionDetailMapper;
import au.com.royalpay.payment.manage.mappers.financial.FinancialAgentCommissionMapper;
import au.com.royalpay.payment.manage.mappers.financial.FinancialPartnerCommissionDetailMapper;
import au.com.royalpay.payment.manage.mappers.financial.FinancialPartnerCommissionMapper;
import au.com.royalpay.payment.manage.mappers.financial.FinancialReferrerCommissionDetailMapper;
@ -12,18 +15,26 @@ import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
import au.com.royalpay.payment.tools.env.SysConfigManager;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
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 javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
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.
@ -41,6 +52,10 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
@Resource
private FinancialReferrerCommissionDetailMapper financialReferrerCommissionDetailMapper;
@Resource
private FinancialAgentCommissionDetailMapper financialAgentCommissionDetailMapper;
@Resource
private FinancialAgentCommissionMapper financialAgentCommissionMapper;
@Resource
private FinancialReferrerCommissionMapper financialReferrerCommissionMapper;
@Resource
private SysConfigManager sysConfigManager;
@ -250,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) {
@ -271,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);
@ -323,6 +338,62 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
}
}
@Override
@Transactional
public void generateAgent(String monthStr, int orgId) {
JSONObject org = orgMapper.findOne(orgId);
if (org == null) {
// shall never happen
throw new ServerErrorException("Organization Id not exists:" + orgId);
}
JSONObject parnetOrg = orgMapper.findOne(org.getIntValue("parent_org_id"));
if (parnetOrg == null) {
// shall never happen
throw new ServerErrorException("Organization Parent Id not exists:" + org.getIntValue("parent_org_id"));
}
Date mon = checkMonth(monthStr);
Calendar monthCal = Calendar.getInstance();
monthCal.setTime(mon);
int year = monthCal.get(Calendar.YEAR);
int month = monthCal.get(Calendar.MONTH) + 1;
financialAgentCommissionDetailMapper.clearData(year, month);
financialAgentCommissionMapper.clearData(year, month);
HashMap<String, String> channelMap = new HashMap<>();
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"));
Map<String, AgentCommissionAnalysis> results = new HashMap<>();
for (JSONObject analysisDay : transactionAnalysis) {
String key = analysisDay.getString("channel");
String channel = analysisDay.getString("channel");
if (!channelMap.containsKey(key)) {
continue;
}
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);
results.put(orgId + channel, agentCommissionAnalysis);
}
agentCommissionAnalysis.attachAnalysis(analysisDay, channel);
}
for (AgentCommissionAnalysis commission : results.values()) {
JSONObject commissionAnalysis = commission.totalCommission();
financialAgentCommissionMapper.save(commissionAnalysis);
String recordId = commissionAnalysis.getString("record_id");
List<JSONObject> details = commission.getCommissionDetails(recordId);
for (JSONObject detail : details) {
financialAgentCommissionDetailMapper.save(detail);
}
}
}
@Override
public List<JSONObject> listReferrerAvailableMonths(String year) {
int yearNum = checkValidYear(year);
@ -438,4 +509,173 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
}
}
@Override
public List<JSONObject> listAgentAvailableMonths(String year) {
int yearNum = checkValidYear(year);
List<Integer> months = financialAgentCommissionMapper.listAvailableMonths(yearNum);
List<JSONObject> monthObjs = new ArrayList<>();
for (Integer mon : months) {
JSONObject item = new JSONObject();
item.put("month", mon);
item.put("monthstr", year + "-" + StringUtils.substring("00" + mon, -2));
JSONObject chargeInfo = getAgentPrizeInfo(item.getString("monthstr"));
item.put("org_charge", chargeInfo.getString("org_charge"));
item.put("gross_amount", chargeInfo.getString("gross_amount"));
monthObjs.add(item);
}
return monthObjs;
}
@Override
public JSONObject getAgentPrizeInfo(String monthStr) {
Date monthDate = parseMonth(monthStr);
Calendar monthCal = Calendar.getInstance();
monthCal.setTime(monthDate);
int year = monthCal.get(Calendar.YEAR);
int month = monthCal.get(Calendar.MONTH) + 1;
JSONObject sum = new JSONObject();
sum.put("gross_amount", 0);
sum.put("org_charge", 0);
List<JSONObject> referrerPrizes = financialAgentCommissionMapper.list(year, month);
for (JSONObject prize : referrerPrizes) {
plusKey(sum, prize, "gross_amount");
plusKey(sum, prize, "org_charge");
prize.put("monthstr", monthStr);
}
sum.put("referrer", referrerPrizes);
sum.put("monthstr", monthStr);
return sum;
}
@Override
public JSONObject getAgentPrizeDetail(String monthStr, String orgId) {
Date monthDate = parseMonth(monthStr);
Calendar monthCal = Calendar.getInstance();
monthCal.setTime(monthDate);
int year = monthCal.get(Calendar.YEAR);
int month = monthCal.get(Calendar.MONTH) + 1;
JSONObject result = new JSONObject();
List<JSONObject> total = financialAgentCommissionMapper.find(year, month, orgId);
if (CollectionUtils.isEmpty(total)) {
return null;
}
BigDecimal royalpay_charge = BigDecimal.ZERO;
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"));
String key = p.getString("client_id")+p.getString("channel").toLowerCase();
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")));
}
}
String tableColumn[] = { "gross_amount", "total_charge", "org_charge", "org_net_charge" };
List<String> recordIds = new ArrayList<>();
Map<String, BigDecimal> chargeResultMap = new HashMap<>();
for (JSONObject jsonObject : total) {
result.put("name", jsonObject.getString("name"));
recordIds.add(jsonObject.getString("record_id"));
for (String s : tableColumn) {
String key = jsonObject.getString("channel") + "_" + s;
if (chargeResultMap.containsKey(key)) {
chargeResultMap.put(key, chargeResultMap.get(key).add(jsonObject.getBigDecimal(s)));
} else {
chargeResultMap.put(key, jsonObject.getBigDecimal(s));
}
}
}
List<JSONObject> details = financialAgentCommissionDetailMapper.listDetailsByRecordIds(recordIds);
Map<String, List<JSONObject>> detailMap = new HashMap<>();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
for (JSONObject detail : details) {
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 {
List<JSONObject> tmpList = new ArrayList<>();
tmpList.add(detail);
detailMap.put(key, tmpList);
}
}
List<JSONObject> partnerClientInfos = new ArrayList<>();
BigDecimal resultGrossAmount = BigDecimal.ZERO;
BigDecimal resultTotalCharge = BigDecimal.ZERO;
BigDecimal resultRoyalpayCharge = BigDecimal.ZERO;
BigDecimal resultOrgCharge = BigDecimal.ZERO;
BigDecimal resultNetCharge = BigDecimal.ZERO;
for (Map.Entry<String, List<JSONObject>> entry : detailMap.entrySet()) {
JSONObject sumResult = new JSONObject();
BigDecimal grossAmount = BigDecimal.ZERO;
BigDecimal totalCharge = BigDecimal.ZERO;
BigDecimal royalpayCharge = BigDecimal.ZERO;
BigDecimal netCharge = BigDecimal.ZERO;
BigDecimal orgCharge = BigDecimal.ZERO;
String clientMoniker = "";
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"));
orgCharge = orgCharge.add(jsonObject.getBigDecimal("org_charge"));
if (jsonObject.getBigDecimal("net_charge") != null) {
netCharge = netCharge.add(jsonObject.getBigDecimal("org_net_charge"));
}
clientMoniker = jsonObject.getString("client_moniker");
}
resultGrossAmount = resultGrossAmount.add(grossAmount);
resultTotalCharge = resultTotalCharge.add(totalCharge);
resultRoyalpayCharge = resultRoyalpayCharge.add(royalpayCharge);
resultOrgCharge = resultOrgCharge.add(orgCharge);
resultNetCharge = resultNetCharge.add(netCharge);
sumResult.put("gross_amount", grossAmount);
sumResult.put("total_charge", totalCharge);
sumResult.put("royalpay_charge", royalpayCharge);
sumResult.put("org_charge", orgCharge);
sumResult.put("org_net_charge", netCharge);
sumResult.put("client_moniker", clientMoniker);
sumResult.put("channel_detail", entry.getValue());
partnerClientInfos.add(sumResult);
}
result.put("partner_client_infos", partnerClientInfos);
for (Map.Entry<String, BigDecimal> entry : chargeResultMap.entrySet()) {
result.put(entry.getKey(), entry.getValue());
}
result.put("monthstr", monthStr);
result.put("total_transaction", resultGrossAmount);
result.put("total_charge", resultTotalCharge);
result.put("royalPay_charge", resultRoyalpayCharge);
result.put("org_net_charge", resultNetCharge);
result.put("city_partner_charge", resultOrgCharge);
return result;
}
@Override
public List<JSONObject> getAgentPrizeInfoList(String monthStr) {
Date monthDate = parseMonth(monthStr);
Calendar monthCal = Calendar.getInstance();
monthCal.setTime(monthDate);
int year = monthCal.get(Calendar.YEAR);
int month = monthCal.get(Calendar.MONTH) + 1;
return financialAgentCommissionMapper.list(year, month);
}
}

@ -2,17 +2,27 @@ package au.com.royalpay.payment.manage.citypartner.web;
import au.com.royalpay.payment.manage.citypartner.core.CityPartnerPrizeService;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
/**
* Created by yixian on 2017-03-08.
*/
@ -64,11 +74,11 @@ public class CityPartnerPrizeController {
String cityPartnerName = "";
int org_id = 0;
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"));
grossAmount = grossAmount.add(jsonObject.getBigDecimal("gross_amount"));
totalCharge = totalCharge.add(jsonObject.getBigDecimal("total_charge"));
royalpayCharge = royalpayCharge.add(jsonObject.getBigDecimal("royalpay_charge"));
orgCharge = orgCharge.add(jsonObject.getBigDecimal("org_charge"));
if(jsonObject.getBigDecimal("net_charge")!=null) {
if (jsonObject.getBigDecimal("net_charge") != null) {
netCharge = netCharge.add(jsonObject.getBigDecimal("net_charge"));
}
org_id = jsonObject.getIntValue("org_id");
@ -80,7 +90,7 @@ public class CityPartnerPrizeController {
sumResult.put("org_charge", orgCharge);
sumResult.put("org_name", cityPartnerName);
sumResult.put("org_id", org_id);
sumResult.put("net_charge",netCharge);
sumResult.put("net_charge", netCharge);
sumResult.put("channel_detail", entry.getValue());
resultTotalCharge = resultTotalCharge.add(totalCharge);
resultRoyalpayCharge = resultRoyalpayCharge.add(royalpayCharge);
@ -89,11 +99,11 @@ public class CityPartnerPrizeController {
partnerInfos.add(sumResult);
}
result.put("monthstr", monthStr);
result.put("total_charge",resultTotalCharge);
result.put("royalpay_charge",resultRoyalpayCharge);
result.put("net_charge",resultNetCharge);
result.put("org_charge",resultOrgCharge);
result.put("partner_info_list",partnerInfos);
result.put("total_charge", resultTotalCharge);
result.put("royalpay_charge", resultRoyalpayCharge);
result.put("net_charge", resultNetCharge);
result.put("org_charge", resultOrgCharge);
result.put("partner_info_list", partnerInfos);
return result;
}
@ -107,14 +117,17 @@ public class CityPartnerPrizeController {
String month = param.getString("month");
cityPartnerPrizeService.generateReferrer(month);
}
@ManagerMapping("/referrer/months/{monthStr}/orgs/{orgId}")
public JSONObject getreferrerPrizeDetail(@PathVariable String monthStr, @PathVariable String orgId) {
return cityPartnerPrizeService.getReferrerPrizeDetail(monthStr, orgId);
}
@RequestMapping("/referrer/months")
public List<JSONObject> listReferrerAvailableMonths(@RequestParam String year) {
return cityPartnerPrizeService.listReferrerAvailableMonths(year);
}
@RequestMapping(value = "/referrer/months/{monthStr}")
public JSONObject getReferrerPrizeInfo(@PathVariable String monthStr) {
List<JSONObject> partnerPrizeInfos = cityPartnerPrizeService.getReferrerPrizeInfoList(monthStr);
@ -140,7 +153,7 @@ public class CityPartnerPrizeController {
String cityPartnerName = "";
int org_id = 0;
for (JSONObject jsonObject : entry.getValue()) {
grossAmount = grossAmount.add(jsonObject.getBigDecimal("gross_amount"));
grossAmount = grossAmount.add(jsonObject.getBigDecimal("gross_amount"));
orgCharge = orgCharge.add(jsonObject.getBigDecimal("org_charge"));
org_id = jsonObject.getIntValue("org_id");
cityPartnerName = jsonObject.getString("name");
@ -155,9 +168,112 @@ public class CityPartnerPrizeController {
partnerInfos.add(sumResult);
}
result.put("monthstr", monthStr);
result.put("gross_amount",resultGrossAmount);
result.put("org_charge",resultOrgCharge);
result.put("partner_info_list",partnerInfos);
result.put("gross_amount", resultGrossAmount);
result.put("org_charge", resultOrgCharge);
result.put("partner_info_list", partnerInfos);
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}")
public JSONObject getAgentPrizeDetail(@PathVariable String monthStr, @PathVariable String orgId) {
return cityPartnerPrizeService.getAgentPrizeDetail(monthStr, orgId);
}
@RequestMapping("/agent/months")
public List<JSONObject> listAgentAvailableMonths(@RequestParam String year) {
return cityPartnerPrizeService.listAgentAvailableMonths(year);
}
@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 {
List<JSONObject> tmpList = new ArrayList<>();
tmpList.add(partnerPrizeInfo);
partenerPrizeMap.put(key, tmpList);
}
}
JSONObject result = new JSONObject();
List<JSONObject> partnerInfos = new ArrayList<>(partenerPrizeMap.size());
BigDecimal resultGrossAmount = BigDecimal.ZERO;
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()) {
grossAmount = grossAmount.add(jsonObject.getBigDecimal("gross_amount"));
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");
}
sumResult.put("gross_amount", grossAmount);
sumResult.put("org_charge", orgCharge);
sumResult.put("org_net_charge",orgNetCharge);
sumResult.put("org_name", cityPartnerName);
sumResult.put("org_id", org_id);
sumResult.put("channel_detail", entry.getValue());
sumResult.put("royalpay_charge",royalpayCharge);
resultGrossAmount = resultGrossAmount.add(grossAmount);
resultOrgCharge = resultOrgCharge.add(orgCharge);
resultAgentCharge = resultAgentCharge.add(agentCharge);
resultOrgNetCharge = resultOrgNetCharge.add(orgNetCharge);
partnerInfos.add(sumResult);
}
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;
}
}

@ -0,0 +1,27 @@
package au.com.royalpay.payment.manage.mappers.financial;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.alibaba.fastjson.JSONObject;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
/**
* Created by yixian on 2017-03-08.
*/
@AutoMapper(tablename = "financial_agent_commission_detail", pkName = "detail_id")
public interface FinancialAgentCommissionDetailMapper {
@AutoSql(type = SqlType.DELETE)
void clearData(@Param("year") int year, @Param("month") int month);
@AutoSql(type = SqlType.INSERT)
void save(JSONObject detail);
List<JSONObject> listDetails(@Param("record_id") String recordId);
List<JSONObject> listDetailsByRecordIds(List<String> recordId);
}

@ -0,0 +1,31 @@
package au.com.royalpay.payment.manage.mappers.financial;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.alibaba.fastjson.JSONObject;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
/**
* Created by yixian on 2017-03-08.
*/
@AutoMapper(tablename = "financial_agent_commission", pkName = "record_id")
public interface FinancialAgentCommissionMapper {
@AutoSql(type = SqlType.INSERT)
void save(JSONObject commissionAnalysis);
@AutoSql(type = SqlType.DELETE)
void clearData(@Param("year") int year, @Param("month") int month);
List<Integer> listAvailableMonths(@Param("year") int year);
List<JSONObject> find(@Param("year") int year, @Param("month") int month, @Param("org_id") String orgId);
List<JSONObject> list(@Param("year") int year, @Param("month") int month);
}

@ -22,4 +22,7 @@ public interface FinancialPartnerCommissionDetailMapper {
List<JSONObject> listDetails(@Param("record_id") String recordId);
List<JSONObject> listDetailsByRecordIds(List<String> recordId);
@AutoSql(type = SqlType.SELECT)
List<JSONObject> listDetailByMonth(@Param("year") int year, @Param("month") int month);
}

@ -96,6 +96,8 @@ public interface TransactionMapper {
List<JSONObject> listTransactionsForReferrerCommission(@Param("year") int year, @Param("month") int month);
List<JSONObject> listTransactionsForAgentCommission(@Param("year") int year, @Param("month") int month,@Param("parent_org_id") int parent_org_id);
BigDecimal checkBalance(@Param("end") Date endDate);
@AutoSql(type = SqlType.COUNT)

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.financial.FinancialAgentCommissionDetailMapper">
<select id="listDetailsByRecordIds" resultType="com.alibaba.fastjson.JSONObject">
SELECT
d.*,
c.client_moniker
FROM financial_agent_commission_detail d
INNER JOIN sys_clients c ON c.client_id = d.client_id
WHERE d.record_id in
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
ORDER BY c.client_moniker ASC
</select>
</mapper>

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.financial.FinancialAgentCommissionMapper">
<select id="listAvailableMonths" resultType="java.lang.Integer">
SELECT DISTINCT `month`
FROM financial_agent_commission
WHERE `year` = #{year}
ORDER BY `month` ASC
</select>
<select id="find" resultType="com.alibaba.fastjson.JSONObject">
SELECT
c.*,
o.name `name`
FROM financial_agent_commission c
INNER JOIN sys_org o ON o.org_id = c.org_id and o.parent_org_id is null
WHERE c.year = #{year} AND c.month = #{month} and c.org_id=#{org_id}
</select>
<select id="list" resultType="com.alibaba.fastjson.JSONObject">
SELECT
c.*,
o.name
FROM financial_agent_commission c
INNER JOIN sys_org o ON o.org_id = c.org_id and o.parent_org_id is null
WHERE c.year = #{year} AND c.month = #{month}
</select>
</mapper>

@ -23,4 +23,5 @@
</foreach>
ORDER BY c.client_moniker ASC, d.date_from ASC
</select>
</mapper>

@ -515,6 +515,52 @@
ORDER BY c.org_id ASC, t.client_id ASC, trade_date ASC
</select>
<select id="listTransactionsForAgentCommission" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT
sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount))
total,
t.client_id client_id,
c.approve_time client_create_time,
c.source client_source,
date(t.transaction_time) trade_date,
t.channel channel,
ifnull(so.rate_value, 1) rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'Wechat'), 1) wechat_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'Alipay'), 1) alipay_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'Bestpay'), 1) bestpay_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'jd'), 1) jd_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'AlipayOnline'), 2.0) AlipayOnline_rate_value
FROM pmt_transactions t
INNER JOIN sys_clients c ON c.client_id = t.client_id
INNER JOIN sys_org so
ON c.org_id = so.org_id AND so.is_valid = 1 AND so.type = 0 AND so.parent_org_id = #{parent_org_id}
WHERE year(t.transaction_time) = #{year} AND month(t.transaction_time) = #{month} 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
]]>
</select>
<select id="checkBalance" resultType="java.math.BigDecimal">
<![CDATA[

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

@ -0,0 +1,108 @@
/**
* Created by yixian on 2017-03-08.
*/
define(['angular','../../agent/commission/commission'], function (angular) {
'use strict';
var app = angular.module('agentCommission', ['ui.router']);
app.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('analysis_agent', {
url: '/analysis_agent',
templateUrl: '/static/agent/commission/templates/agent_commission_root.html',
controller: 'agentCommissionRootCtrl'
}).state('analysis_agent.agentcommission', {
url:'/agentcommission',
template:'<div ui-view></div>',
controller:['$scope',function ($scope) {
}]
}).state('analysis_agent.agentcommission.month', {
url: '/months/{monthStr}',
templateUrl: '/static/agent/commission/templates/agent_commission_month.html',
controller: 'agentCommissionMonthViewCtrl',
resolve: {
monthData: ['$http', '$stateParams', function ($http, $stateParams) {
return $http.get('/sys/citypartner_prizes/agent/months/' + $stateParams.monthStr);
}]
}
}).state('analysis_agent.agentcommission.month.agentdetail', {
url: '/orgs/{orgId}',
templateUrl: '/static/agent/commission/templates/agent_commission_detail.html',
controller: 'agentCommissionagentDetailCtrl',
resolve: {
detail: ['$http', '$stateParams', function ($http, $stateParams) {
return $http.get('/sys/citypartner_prizes/agent/months/' + $stateParams.monthStr + '/orgs/' + $stateParams.orgId);
}]
}
})
}]);
app.controller('agentCommissionRootCtrl', ['$scope', '$http', '$filter', '$state', 'commonDialog',
function ($scope, $http, $filter, $state, commonDialog) {
$scope.generate = {};
$scope.generateAgentCommission = function () {
$scope.generate.status = {};
if (!$scope.generate.month) {
commonDialog.alert({
type: 'error', title: 'Error', content: 'Select a month first!'
});
return;
}
commonDialog.confirm({
title: 'Confirm',
content: 'This operation will clear the data generated before, Are you sure?'
}).then(function () {
var params = {month: $filter('date')($scope.generate.month, 'yyyy-MM')};
$http.post('/sys/citypartner_prizes/agent/generate', params).then(function () {
$state.go('analysis_agent.agentcommission.month', {monthStr: params.month})
$scope.generate.status = null;
}, function (resp) {
commonDialog.alert({type: 'error', title: 'Error', content: resp.data.message});
})
})
};
$scope.params = {year: new Date()};
$scope.months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
$scope.loadAvailableMonths = function () {
$http.get('/sys/citypartner_prizes/agent/months', {params: {year: $scope.params.year.getFullYear()}}).then(function (resp) {
$scope.availableMonths = resp.data;
});
};
$scope.loadAvailableMonths();
$scope.hasReport = function (mon) {
var has = false;
angular.forEach($scope.availableMonths, function (m) {
if (mon == m.month) {
has = true;
}
});
return has;
};
$scope.gotoMonth = function (mon) {
var monthStr = $scope.params.year.getFullYear() + '-' + (('0' + mon).substr(-2));
$state.go('analysis_agent.agentcommission.month', {monthStr: monthStr})
};
}]);
app.controller('agentCommissionMonthViewCtrl', ['$scope', 'monthData', function ($scope, monthData) {
$scope.monthData = monthData.data;
$scope.ctrl = {};
$scope.active = function (log) {
if($scope.ctrl.activeLog && $scope.ctrl.activeLog.org_id==log.org_id){
$scope.ctrl.activeLog=null;
return;
}
$scope.ctrl.activeLog=log;
}
}]);
app.controller('agentCommissionagentDetailCtrl', ['$scope', 'detail', function ($scope, detail) {
$scope.detail = detail.data;
$scope.ctrl = {};
$scope.active = function (log) {
if($scope.ctrl.activeLog && $scope.ctrl.activeLog.client_moniker==log.client_moniker){
$scope.ctrl.activeLog=null;
return;
}
$scope.ctrl.activeLog=log;
}
}]);
return app;
});

@ -0,0 +1,186 @@
<style type="text/css">
.nowrap > div {
white-space: nowrap;
}
</style>
<div ui-view>
<div class="box box-warning" ng-if="detail">
<div class="box-header">Analysis</div>
<div class="box-body nowrap">
<div class="row">
<div class="col-xs-3 col-sm-3">
City Partner:<span ng-bind="detail.name"></span>
</div>
<div class="col-xs-3 col-sm-3">
Month:<span ng-bind="detail.monthstr"></span>
</div>
<div class="col-xs-3 col-sm-3 nowrap">
Total Transaction:{{detail.total_transaction}}
</div>
<div class="col-xs-3 col-sm-3 nowrap">
Total Charge:{{detail.total_charge}}
</div>
<div class="col-xs-3 col-sm-3 nowrap">
RoyalPay Charge:{{detail.royalPay_charge}}
</div>
<div class="col-xs-3 col-sm-3 nowrap">
Org Net Charge:{{detail.org_net_charge}}
</div>
<div class="col-xs-6 col-sm-6 nowrap">
City Partner Charge:{{detail.city_partner_charge}}
</div>
<div class="col-xs-3 ng-scope"
ng-if="detail.Alipay_gross_amount|| detail.Alipay_total_charge || detail.Alipay_royalpay_charge|| detail.Alipay_org_charge">
<div class="info-box" style="background: lightcyan">
<div class="info-box-icon" style=" background: bottom;">
<img uib-tooltip="Alipay" src="/static/images/alipay_sign_lg.png">
</div>
<div class="info-box-content">
<h5 class="ng-binding">Total Transaction:<span
ng-bind="detail.Alipay_gross_amount|currency:'AUD'"></span></h5>
<h5 class="ng-binding">Total Charge:<span
ng-bind="detail.Alipay_total_charge|currency:'AUD'"></span></h5>
<h5 class="ng-binding">RoyalPay Charge:<span
ng-bind="detail.Alipay_royalpay_charge|currency:'AUD'"></span></h5>
<h5 class="ng-binding">Org Net Charge:<span
ng-bind="detail.Alipay_org_net_charge|currency:'AUD'"></span></h5>
<h5 class="ng-binding">City Partner Charge:<span
ng-bind="detail.Alipay_org_charge|currency:'AUD'"></span></h5>
</div>
</div>
</div>
<div class="col-xs-3 ng-scope"
ng-if="detail.Bestpay_gross_amount|| detail.Bestpay_total_charge || detail.Bestpay_royalpay_charge|| detail.Bestpay_org_charge">
<div class="info-box" style="background: lightcyan">
<div class="info-box-icon" style=" background: bottom;">
<img uib-tooltip="Bestpay" src="/static/images/bestpay_sign_lg.png">
</div>
<div class="info-box-content">
<h5 class="ng-binding">Total Transaction:<span
ng-bind="detail.Bestpay_gross_amount|currency:'AUD'"></span></h5>
<h5 class="ng-binding">Total Charge:<span
ng-bind="detail.Bestpay_total_charge|currency:'AUD'"></span></h5>
<h5 class="ng-binding">RoyalPay Charge:<span
ng-bind="detail.Bestpay_royalpay_charge|currency:'AUD'"></span></h5>
<h5 class="ng-binding">Org Net Charge:<span
ng-bind="detail.Bestpay_org_net_charge|currency:'AUD'"></span></h5>
<h5 class="ng-binding">City Partner Charge:<span
ng-bind="detail.Bestpay_org_charge|currency:'AUD'"></span></h5>
</div>
</div>
</div>
<div class="col-xs-3 ng-scope"
ng-if="detail.Wechat_gross_amount|| detail.Wechat_total_charge || detail.Wechat_royalpay_charge|| detail.Wechat_org_charge">
<div class="info-box" style="background: lightcyan">
<div class="info-box-icon" style=" background: bottom;">
<img uib-tooltip="Wechat" src="/static/images/wechatpay_sign_lg.png">
</div>
<div class="info-box-content">
<h5 class="ng-binding"> Total Transaction:<span
ng-bind="detail.Wechat_gross_amount|currency:'AUD'"></span></h5>
<h5 class="ng-binding"> Total Charge:<span
ng-bind="detail.Wechat_total_charge|currency:'AUD'"></span></h5>
<h5 class="ng-binding"> RoyalPay Charge:<span
ng-bind="detail.Wechat_royalpay_charge|currency:'AUD'"></span></h5>
<h5 class="ng-binding">Org Net Charge:<span
ng-bind="detail.Wechat_org_net_charge|currency:'AUD'"></span></h5>
<h5 class="ng-binding">City Partner Charge:<span
ng-bind="detail.Wechat_org_charge|currency:'AUD'"></span></h5>
</div>
</div>
</div>
<div class="col-xs-3 ng-scope"
ng-if="detail.jd_gross_amount|| detail.jd_total_charge || detail.jd_royalpay_charge|| detail.jd_org_charge">
<div class="info-box" style="background: lightcyan">
<div class="info-box-icon" style=" background: bottom;">
<img uib-tooltip="jd" src="/static/images/jd_sign_lg.png">
</div>
<div class="info-box-content">
<h5 class="ng-binding"> Total Transaction:<span
ng-bind="detail.jd_gross_amount|currency:'AUD'"></span></h5>
<h5 class="ng-binding"> Total Charge:<span
ng-bind="detail.jd_total_charge|currency:'AUD'"></span></h5>
<h5 class="ng-binding"> RoyalPay Charge:<span
ng-bind="detail.jd_royalpay_charge|currency:'AUD'"></span></h5>
<h5 class="ng-binding">Org Net Charge:<span
ng-bind="detail.jd_org_net_charge|currency:'AUD'"></span></h5>
<h5 class="ng-binding">City Partner Charge:<span
ng-bind="detail.jd_org_charge|currency:'AUD'"></span></h5>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="box box-default" ng-if="detail">
<div class="box-body table-responsive">
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Client Moniker</th>
<th>Transaction</th>
<th>Total Charge</th>
<th>RoyalPay Charge</th>
<th>Org Net Charge</th>
<th>City Partner Charge</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr ng-repeat-start="log in detail.partner_client_infos">
<td ng-bind="log.client_moniker"></td>
<td ng-bind="log.gross_amount|currency:'AUD'"></td>
<td ng-bind="log.total_charge|currency:'AUD'"></td>
<td ng-bind="log.royalpay_charge|currency:'AUD'"></td>
<td ng-bind="log.org_net_charge|currency:'AUD'"></td>
<td ng-bind="log.org_charge|currency:'AUD'"></td>
<td>
<a role="button" ng-click="active(log)">
<i class="fa fa-list-ul"></i>
</a>
</td>
</tr>
<tr ng-repeat-end ng-if="log.client_moniker==ctrl.activeLog.client_moniker">
<td colspan="6">
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Order Date Range</th>
<th>Client Rate</th>
<th>Transaction Amount</th>
<th>Total Charge</th>
<th>RoyalPay Charge</th>
<th>Org Net Charge</th>
<th>City Partner Charge</th>
<th>channel</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="detail in log.channel_detail">
<td>
{{detail.date_from|date:'dd/MMM/yyyy'}}~{{detail.date_to|date:'dd/MMM/yyyy'}}
</td>
<td ng-bind="detail.client_rate"></td>
<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.org_net_charge"></td>
<td ng-bind="detail.org_charge"></td>
<td ng-bind="detail.channel"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

@ -0,0 +1,86 @@
<div ui-view>
<div class="box box-warning">
<div class="box-header">Analysis</div>
<div class="box-body">
<div class="row">
<div class="col-xs-6 col-sm-3">
Month:<span ng-bind="monthData.monthstr"></span>
</div>
<div class="col-xs-6 col-sm-3">
Total Charge:<span ng-bind="monthData.agent_total_charge|currency:'AUD'"></span>
</div>
<div class="col-xs-6 col-sm-3">
RoyalPay Charge:<span ng-bind="monthData.royalpay_charge|currency:'AUD'"></span>
</div>
<div class="col-xs-6 col-sm-3">
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>
</div>
</div>
</div>
</div>
<div class="box box-default">
<div class="box-header">Details</div>
<div class="box-body table-responsive">
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>City Partner Name</th>
<th>Transaction Amount</th>
<th>Total Charge</th>
<th>RoyalPay Charge</th>
<th>Net Charge</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr ng-repeat-start="log in monthData.partner_info_list">
<td ng-bind="log.org_name"></td>
<td ng-bind="log.gross_amount|currency:'AUD'"></td>
<td ng-bind="log.org_charge|currency:'AUD'"></td>
<td ng-bind="log.royalpay_charge|currency:'AUD'"></td>
<td ng-bind="log.org_net_charge|currency:'AUD'"></td>
<td>
<a ui-sref=".agentdetail({orgId:log.org_id})">
<i class="fa fa-search"></i>
</a>
<a role="button" ng-click="active(log)">
<i class="fa fa-list-ul"></i>
</a>
</td>
</tr>
<tr ng-repeat-end ng-if="log.org_id==ctrl.activeLog.org_id">
<td colspan="6">
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Keep Rate</th>
<th>Transaction Amount</th>
<th>Total Charge</th>
<th>RoyalPay Charge</th>
<th>Org Net Charge</th>
<th>City Partner Charge</th>
<th>channel</th>
</tr>
</thead>
<tbody>
<tr ng-repeat = "detail in log.channel_detail" >
<td ng-bind="detail.org_rate"></td>
<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.org_net_charge"></td>
<td ng-bind="detail.org_charge"></td>
<td ng-bind="detail.channel"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

@ -0,0 +1,56 @@
<!--<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">
<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-header">
<input type="text" class="hidden" uib-datepicker-popup="yyyy" ng-model="params.year" is-open="ctrl.viewyear"
datepicker-options="{minMode: 'year'}" ng-change="loadAvailableMonths()"
placeholder="Select Year">
<span ng-bind="params.year.getFullYear()" ng-click="ctrl.viewyear=true"></span>
</div>
<div class="row">
<div class="col-md-3 col-sm-6 col-xs-12" ng-repeat="mon in availableMonths">
<div class="info-box">
<div class="info-box-icon bg-aqua" ng-bind="mon.month" ng-click="gotoMonth(mon.monthstr)" role="button">
</div>
<div class="info-box-content">
<!--<div class="info-box-text text-bold text-red" ng-bind="r.charge_date"></div>-->
<div>
<div class="info-box-number-right">
<span class="text-bold">Total Charge:</span>
<span class="text-green" ng-bind="mon.gross_amount|currency:'AUD'"></span>
</div>
<div class="info-box-number-right">
<span class="text-bold">Org Charge:</span>
<span class="text-green" ng-bind="mon.org_charge|currency:'AUD'"></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div ui-view></div>
</section>

@ -0,0 +1,27 @@
package au.com.royalpay.payment.manage.citypartner.core.impls;
import au.com.royalpay.payment.manage.citypartner.core.CityPartnerPrizeService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
/**
* Created by wangning on 09/01/2018.
*/
@SpringBootTest
@ActiveProfiles({"local","alipay","wechat","jd","bestpay"})
@RunWith(SpringRunner.class)
public class CityPartnerPrizeServiceImplTest {
@Resource
private CityPartnerPrizeService cityPartnerPrizeService;
@Test
public void generateAgent() throws Exception {
cityPartnerPrizeService.generateAgent("2017-06",9);
}
}
Loading…
Cancel
Save