Merge branch 'develop'

master
eason.qian 7 years ago
commit a425a03f91

@ -139,10 +139,49 @@ ALTER TABLE sys_clients_customers ADD COLUMN channel varchar(15) not NULL ;
ALTER TABLE sys_clients_customers ADD COLUMN last_payment_time datetime DEFAULT NULL COMMENT '最后一次付款时间';
ALTER TABLE sys_org ADD COLUMN parent_org_id int(11) DEFAULT NULL;
ALTER TABLE sys_org ADD COLUMN min_wechat_rate DECIMAL(3,2) DEFAULT 'NULL' COMMENT '旗下商户最低微信费率';
ALTER TABLE sys_org ADD COLUMN min_alipay_rate DECIMAL(3,2) DEFAULT 'NULL' COMMENT '旗下商户最低支付宝费率';
ALTER TABLE sys_org ADD COLUMN min_alipayonline_rate DECIMAL(3,2) DEFAULT 'NULL' COMMENT '旗下商户最低支付宝线上费率';
ALTER TABLE sys_org ADD COLUMN min_bestpay_rate DECIMAL(3,2) DEFAULT 'NULL' COMMENT '旗下商户最低翼支付费率';
ALTER TABLE sys_org ADD COLUMN min_jd_rate DECIMAL(3,2) DEFAULT 'NULL' COMMENT '旗下商户最低京东费率';
ALTER TABLE sys_org ADD COLUMN min_wechat_rate DECIMAL(3,2) DEFAULT NULL COMMENT '旗下商户最低微信费率';
ALTER TABLE sys_org ADD COLUMN min_alipay_rate DECIMAL(3,2) DEFAULT NULL COMMENT '旗下商户最低支付宝费率';
ALTER TABLE sys_org ADD COLUMN min_alipayonline_rate DECIMAL(3,2) DEFAULT NULL COMMENT '旗下商户最低支付宝线上费率';
ALTER TABLE sys_org ADD COLUMN min_bestpay_rate DECIMAL(3,2) DEFAULT NULL COMMENT '旗下商户最低翼支付费率';
ALTER TABLE sys_org ADD COLUMN min_jd_rate DECIMAL(3,2) DEFAULT NULL COMMENT '旗下商户最低京东费率';
ALTER TABLE sys_org ADD COLUMN commission_type SMALLINT(1) DEFAULT '1' COMMENT '提成类型 1:渠道计算法 2:总交易额比例 3:收益比例';
--agent_commission
CREATE TABLE `financial_agent_commission` (
`record_id` varchar(50) NOT NULL,
`org_id` int(11) NOT NULL,
`year` smallint(6) NOT NULL,
`month` smallint(6) NOT NULL,
`create_time` datetime NOT NULL,
`org_rate` decimal(5,2) DEFAULT NULL COMMENT '保底费率RoyalPay抽取',
`gross_amount` decimal(12,2) NOT NULL COMMENT '支付-退款',
`total_charge` decimal(12,2) NOT NULL COMMENT '总手续费',
`org_charge` decimal(12,2) NOT NULL COMMENT '合伙人手续',
`channel` varchar(12) NOT NULL,
`org_net_charge` decimal(12,2) DEFAULT NULL COMMENT '净值',
PRIMARY KEY (`record_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='二级代理商提成';
CREATE TABLE `financial_agent_commission_detail` (
`detail_id` varchar(50) NOT NULL,
`year` smallint(6) NOT NULL,
`month` smallint(6) NOT NULL,
`record_id` varchar(50) NOT NULL,
`client_id` int(11) NOT NULL,
`client_rate` decimal(5,2) NOT NULL,
`date_from` date NOT NULL,
`date_to` date NOT NULL,
`gross_amount` decimal(12,2) NOT NULL COMMENT '总支付-总退款',
`total_charge` decimal(12,2) NOT NULL COMMENT '总手续费',
`org_charge` decimal(12,2) NOT NULL COMMENT '合伙人所得手续费',
`channel` varchar(15) NOT NULL,
`org_net_charge` decimal(12,2) DEFAULT NULL COMMENT '净值',
PRIMARY KEY (`detail_id`)
) 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:收益比例';

@ -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;
}
}

@ -1,6 +1,8 @@
package au.com.royalpay.payment.manage.citypartner.beans;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import com.alibaba.fastjson.JSONObject;
import java.math.BigDecimal;
@ -18,7 +20,9 @@ public class CityPartnerCommissionAnalysis {
private BigDecimal jdChargeRate;
private BigDecimal alipayonlineChargeRate;
private BigDecimal rate;
private BigDecimal orgRate;
private String channel;
private int commissionType;
private Map<Integer, List<JSONObject>> clientAnalysis = new HashMap<>();
private BigDecimal totalGrossAmount = BigDecimal.ZERO;
private BigDecimal totalChargeSum = BigDecimal.ZERO;
@ -26,19 +30,34 @@ public class CityPartnerCommissionAnalysis {
private BigDecimal totalOrgChargeSum = 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.year = year;
this.month = month;
this.rate = rate;
this.channel = channel;
this.commissionType = commissionType;
this.alipayChargeRate = alipayChargeRate;
this.wechatChargeRate = wechatChargeRate;
this.jdChargeRate = jdChargeRate;
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) {
int clientId = dayAnalysis.getIntValue("client_id");
List<JSONObject> clientTrades = clientAnalysis.get(clientId);
if (clientTrades == null) {
@ -47,32 +66,14 @@ public class CityPartnerCommissionAnalysis {
}
Date tradeDate = dayAnalysis.getDate("trade_date");
BigDecimal total = dayAnalysis.getBigDecimal("total");
BigDecimal dayRate = dayAnalysis.getBigDecimal(channel+"_rate_value");
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 = 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;
}
BigDecimal thirdPartyPaymentCharge = getThirdPartyCharge(channel, total);
BigDecimal netCharge = royalpayCharge.subtract(thirdPartyPaymentCharge);
BigDecimal orgCharge = dayCharge.subtract(royalpayCharge);
totalGrossAmount = totalGrossAmount.add(total);
@ -113,8 +114,9 @@ public class CityPartnerCommissionAnalysis {
item.put("total_charge", dayCharge);
item.put("royalpay_charge", royalpayCharge);
item.put("org_charge", orgCharge);
item.put("channel",channel);
item.put("net_charge",netCharge);
item.put("channel", channel);
item.put("net_charge", netCharge);
item.put("commission_type",commissionType);
clientTrades.add(item);
return this;
}
@ -130,8 +132,9 @@ public class CityPartnerCommissionAnalysis {
result.put("total_charge", totalChargeSum);
result.put("royalpay_charge", totalRoyalPayCharge);
result.put("org_charge", totalOrgChargeSum);
result.put("net_charge",totalnetCharge);
result.put("channel",channel);
result.put("net_charge", totalnetCharge);
result.put("channel", channel);
result.put("commission_type",commissionType);
return result;
}
@ -147,4 +150,87 @@ public class CityPartnerCommissionAnalysis {
}
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 orgCharge = total.multiply(referrerRate).divide(CommonConsts.HUNDRED, 2, BigDecimal.ROUND_HALF_UP);
Date tradeDate = dayAnalysis.getDate("trade_date");
BigDecimal dayRate = dayAnalysis.getBigDecimal("rate_value");
totalGrossAmount = totalGrossAmount.add(total);
totalOrgChargeSum = totalOrgChargeSum.add(orgCharge);

@ -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,33 @@
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.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 +37,6 @@ 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.*;
/**
* Created by yixian on 2017-03-08.
@ -41,6 +54,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;
@ -180,6 +197,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
BigDecimal netCharge = BigDecimal.ZERO;
BigDecimal orgCharge = BigDecimal.ZERO;
String clientMoniker = "";
int type = 1;
for (JSONObject jsonObject : entry.getValue()) {
grossAmount = grossAmount.add(jsonObject.getBigDecimal("gross_amount"));
totalCharge = totalCharge.add(jsonObject.getBigDecimal("total_charge"));
@ -189,6 +207,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
netCharge = netCharge.add(jsonObject.getBigDecimal("net_charge"));
}
clientMoniker = jsonObject.getString("client_moniker");
type = jsonObject.getIntValue("type");
}
resultGrossAmount = resultGrossAmount.add(grossAmount);
resultTotalCharge = resultTotalCharge.add(totalCharge);
@ -202,6 +221,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
sumResult.put("net_charge", netCharge);
sumResult.put("client_moniker", clientMoniker);
sumResult.put("channel_detail", entry.getValue());
sumResult.put("type",type);
partnerClientInfos.add(sumResult);
}
result.put("partner_client_infos", partnerClientInfos);
@ -227,8 +247,7 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
int year = monthCal.get(Calendar.YEAR);
int month = monthCal.get(Calendar.MONTH) + 1;
financialPartnerCommissionDetailMapper.clearData(year, month);
financialPartnerCommissionMapper.clearData(year, month);
JSONObject sysConfig = sysConfigManager.getSysConfig();
BigDecimal alipayChargeRate = new BigDecimal("0.6");
BigDecimal wechatChargeRate = new BigDecimal("0.6");
@ -250,31 +269,38 @@ 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");
Set<Integer> orgIds = new HashSet<>();
List<JSONObject> transactionAnalysis = transactionMapper.listTransactionsForCityPartnerCommission(year, month);
Map<String, CityPartnerCommissionAnalysis> results = new HashMap<>();
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");
JSONObject org = orgMapper.findOne(orgId);
if(org.getIntValue("parent_org_id")>0){
orgIds.add(orgId);
}
if (org == null) {
// shall never happen
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();
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,org.getBigDecimal("rate_value"),org.getIntValue("commission_type"));
results.put(orgId + channel, orgAnalysis);
}
orgAnalysis.attachAnalysis(analysisDay, channel);
orgAnalysis.calculator(analysisDay, channel,org.getIntValue("commission_type"));
}
for (CityPartnerCommissionAnalysis commission : results.values()) {
@ -286,7 +312,12 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
financialPartnerCommissionDetailMapper.save(detail);
}
}
Runnable task = ()->{
orgIds.forEach((p)->{
generateAgent(monthStr,p);
});
};
new Thread(task).start();
}
@Override
@ -323,6 +354,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 +525,176 @@ 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"));
item.put("total_charge", chargeInfo.getString("total_charge"));
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);
sum.put("total_charge",0);
List<JSONObject> referrerPrizes = financialAgentCommissionMapper.list(year, month);
for (JSONObject prize : referrerPrizes) {
plusKey(sum, prize, "gross_amount");
plusKey(sum, prize, "org_charge");
plusKey(sum, prize, "total_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.
*/
@ -63,16 +73,18 @@ public class CityPartnerPrizeController {
BigDecimal netCharge = BigDecimal.ZERO;
String cityPartnerName = "";
int org_id = 0;
int type = 1;
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) {
if (jsonObject.getBigDecimal("net_charge") != null) {
netCharge = netCharge.add(jsonObject.getBigDecimal("net_charge"));
}
org_id = jsonObject.getIntValue("org_id");
cityPartnerName = jsonObject.getString("name");
type = jsonObject.getIntValue("commission_type");
}
sumResult.put("gross_amount", grossAmount);
sumResult.put("total_charge", totalCharge);
@ -80,7 +92,8 @@ 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("type",type);
sumResult.put("channel_detail", entry.getValue());
resultTotalCharge = resultTotalCharge.add(totalCharge);
resultRoyalpayCharge = resultRoyalpayCharge.add(royalpayCharge);
@ -89,11 +102,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 +120,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);
@ -155,9 +171,106 @@ 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;
}
@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);
}

@ -14,7 +14,7 @@ import java.util.List;
@AutoMapper(tablename = "financial_partner_commission_detail", pkName = "detail_id")
public interface FinancialPartnerCommissionDetailMapper {
@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)
void save(JSONObject detail);
@ -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);
}

@ -14,7 +14,7 @@ import java.util.List;
@AutoMapper(tablename = "financial_partner_commission", pkName = "record_id")
public interface FinancialPartnerCommissionMapper {
@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)
void save(JSONObject commissionAnalysis);

@ -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)

@ -1164,6 +1164,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
checkOrgPermission(manager, client);
int clientId = client.getIntValue("client_id");
JSONObject org = orgMapper.findOne(client.getIntValue("org_id"));
if (config == null) {
throw new ForbiddenException(clientId + "费率参数配置不完整,请重新输入===>");
}
@ -1174,15 +1175,22 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
config.put("update_time", new Date());
config.put("active_time", DateFormatUtils.format(config.getDate("active_time"), "yyyy-MM-dd"));
config.put("expiry_time", DateFormatUtils.format(config.getDate("expiry_time"), "yyyy-MM-dd"));
configNewClientRate(config, clientId, "Alipay", "alipay_rate_value");
configNewClientRate(config, clientId, "AlipayOnline", "alipayonline_rate_value");
configNewClientRate(config, clientId, "Wechat", "wechat_rate_value");
configNewClientRate(config, clientId, "jd", "jd_rate_value");
configNewClientRate(config, clientId, "Bestpay", "bestpay_rate_value");
checkAddRate(config,"Wechat", "wechat_rate_value",org,"min_wechat_rate");
checkAddRate(config,"Alipay", "alipay_rate_value",org,"min_alipay_rate");
checkAddRate(config,"AlipayOnline", "alipayonline_rate_value",org,"min_alipayonline_rate");
checkAddRate(config,"Bestpay", "bestpay_rate_value",org,"min_bestpay_rate");
checkAddRate(config,"jd", "jd_rate_value",org,"min_jd_rate");
configNewClientRate(config, clientId, "Wechat", "wechat_rate_value",org,"min_wechat_rate");
configNewClientRate(config, clientId, "Alipay", "alipay_rate_value",org,"min_alipay_rate");
configNewClientRate(config, clientId, "AlipayOnline", "alipayonline_rate_value",org,"min_alipayonline_rate");
configNewClientRate(config, clientId, "Bestpay", "bestpay_rate_value",org,"min_bestpay_rate");
configNewClientRate(config, clientId, "jd", "jd_rate_value",org,"min_jd_rate");
}
private void configNewClientRate(JSONObject config, int clientId, String channel, String rateKey) {
private void configNewClientRate(JSONObject config, int clientId, String channel, String rateKey,JSONObject org,String rateValueKey) {
if (config.containsKey(rateKey)) {
JSONObject newConfig = new JSONObject();
newConfig.putAll(config);
@ -1210,6 +1218,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
checkOrgPermission(manager, client);
JSONObject configJson = config.toJSON();
JSONObject org = orgMapper.findOne(client.getIntValue("org_id"));
checkModifyRate(org,configJson,"Wechat","min_wechat_rate");
checkModifyRate(org,configJson,"Alipay","min_alipay_rate");
checkModifyRate(org,configJson,"AlipayOnline","min_alipayonline_rate");
checkModifyRate(org,configJson,"jd","min_jd_rate");
checkModifyRate(org,configJson,"Bestpay","min_bestpay_rate");
configJson.put("client_rate_id", rateId);
configJson.put("manager_id", manager.getString("manager_id"));
configJson.put("manager_name", manager.getString("username"));
@ -1223,6 +1237,24 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
// clientMapper.updateCleanDays(clientId, config.getCleanDays());
}
private void checkModifyRate(JSONObject org,JSONObject configJson,String rateName,String rateValueKey){
if(configJson.getString("rate_name").equals(rateName)){
if(org.containsKey(rateValueKey)){
if(configJson.getDouble("rate_value").compareTo(org.getDouble(rateValueKey)) > 0){
throw new ForbiddenException("费率参数大于旗下商户最低"+rateName+"费率,请重新输入===>");
};
}
}
}
private void checkAddRate(JSONObject config,String channel, String rateKey,JSONObject org,String rateValueKey){
if(config.containsKey(rateKey)){
if(org.containsKey(rateValueKey)){
if(config.getBigDecimal(rateKey).compareTo(org.getBigDecimal(rateValueKey)) > 0){
throw new ForbiddenException("费率参数大于旗下商户最低"+channel+"费率,请重新输入===>");
};
}
}
}
@Override
public List<JSONObject> listSubClients(JSONObject manager, String clientMoniker) {

@ -34,6 +34,12 @@ public class OrgInfo {
private int limit = 10;
private String parent_org_id;
private String org_id;
private String commission_type;
private Double min_wechat_rate;
private Double min_alipay_rate;
private Double min_bestpay_rate;
private Double min_jd_rate;
private Double min_alipayonline_rate;
public JSONObject toJsonParam() {
JSONObject param = new JSONObject();
@ -229,4 +235,52 @@ public class OrgInfo {
public void setOrg_id(String org_id) {
this.org_id = org_id;
}
public String getCommission_type() {
return commission_type;
}
public void setCommission_type(String commission_type) {
this.commission_type = commission_type;
}
public Double getMin_wechat_rate() {
return min_wechat_rate;
}
public void setMin_wechat_rate(Double min_wechat_rate) {
this.min_wechat_rate = min_wechat_rate;
}
public Double getMin_alipay_rate() {
return min_alipay_rate;
}
public void setMin_alipay_rate(Double min_alipay_rate) {
this.min_alipay_rate = min_alipay_rate;
}
public Double getMin_bestpay_rate() {
return min_bestpay_rate;
}
public void setMin_bestpay_rate(Double min_bestpay_rate) {
this.min_bestpay_rate = min_bestpay_rate;
}
public Double getMin_jd_rate() {
return min_jd_rate;
}
public void setMin_jd_rate(Double min_jd_rate) {
this.min_jd_rate = min_jd_rate;
}
public Double getMin_alipayonline_rate() {
return min_alipayonline_rate;
}
public void setMin_alipayonline_rate(Double min_alipayonline_rate) {
this.min_alipayonline_rate = min_alipayonline_rate;
}
}

@ -96,6 +96,3 @@ app.foreign-currency=AUD
app.ofei.md5-key=Khjx6wejblaJzmG0JBWFlPFKAUxhFIXQ
app.ofei.pwd=aomi@8888
app.ofei.sp-code=A1407200
android.message.secret=2b96d9bc6169c9554218aab1
android.message.appkey=3f33a10d0a7d4ac94d8f2431

@ -52,8 +52,9 @@
<select id="listPaymentManagerByCus" resultType="java.lang.String">
<![CDATA[
SELECT DISTINCT c.kanga_openid
from cus_membership c, sys_managers s where c.payment_openid = s.wx_openid AND (s.role & 1 >0 or s.role & 10000000 >0)
SELECT DISTINCT scr.kanga_openid FROM sys_customer_relation scr, sys_managers sm
WHERE scr.wechat_openid = sm.wx_openid AND scr.kanga_openid IS NOT NULL
AND sm.role & 10000001 > 0
]]>
</select>
</mapper>

@ -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[

@ -191,6 +191,8 @@ margin-bottom: 10%;"/>
ng-class="{'text-orange':!('10000000000'|withRole),'text-gray':('10000000000'|withRole)}"></i>
<i class="fa fa-tripadvisor" title="GUEST"
ng-class="{'text-orange':!('100000000000'|withRole),'text-gray':('100000000000'|withRole)}"></i>
<i class="fa fa-user-plus" title="Org Manager"
ng-class="{'text-orange':!('1000000000000'|withRole),'text-gray':('1000000000000'|withRole)}"></i>
</small>
</p>
</li>
@ -326,6 +328,13 @@ margin-bottom: 10%;"/>
<i class="fa fa-users"></i> <span>周末费率减半活动</span>
</a>
</li>
<li class="header nav-header" ng-if="('1000000000000'|withRole)">机构|Agent</li>
<li ui-sref-active="active" ng-if="('1000000000000'|withRole)">
<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,89 @@
<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">
Gross Amount:<span ng-bind="monthData.gross_amount|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,33 @@
<section class="content">
<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.total_charge|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>

@ -11,6 +11,13 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
"label": "推荐人",
"value": 1
}];
var commission_types = [{
"label": "渠道计算法",
"value": 1
}, {
"label": "收益比例",
"value": 3
}];
var app = angular.module('organizations', ['ui.router', 'ui.bootstrap']);
app.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('organizations', {
@ -43,7 +50,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
}]);
app.controller('orgsCtrl', ['$scope', '$http','commonDialog', function ($scope, $http,commonDialog ) {
$scope.params = {};
if($scope.currentUser.org_id !=null && !angular.equals({}, $scope.currentUser.org_id)) {
if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id) {
$scope.params.org_id = $scope.currentUser.org_id;
}
$scope.pagination = {};
@ -80,8 +87,9 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
}]);
app.controller('orgDetailCtrl', ['$scope', '$http', '$state', 'Upload', '$uibModal','commonDialog', 'org', function ($scope, $http, $state, Upload,$uibModal,commonDialog, org) {
$scope.types = angular.copy(types);
$scope.commission_types = angular.copy(commission_types);
$scope.org = angular.copy(org.data);
if ($scope.currentUser.org_id != null) {
if (($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id) {
$scope.org.type = 0;
}
$scope.uploadLogo = function (file) {
@ -111,6 +119,9 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
});
return;
}
if($scope.org.type == 1){
$scope.org.commission_type = 2;
}
$http.put('/sys/orgs/' + $scope.org.org_id, $scope.org).then(function () {
commonDialog.alert({title: 'Succeed', content: 'Organization update succeeded', type: 'success'});
$state.reload();
@ -177,8 +188,9 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
}]);
app.controller('orgDetailParentCtrl', ['$scope', '$http', '$state', 'Upload', '$uibModal','commonDialog', 'org', function ($scope, $http, $state, Upload,$uibModal,commonDialog, org) {
$scope.types = angular.copy(types);
$scope.commission_types = angular.copy(commission_types);
$scope.org = angular.copy(org.data);
if ($scope.currentUser.org_id != null) {
if (($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id) {
$scope.org.type = 0;
}
$scope.uploadLogo = function (file) {
@ -274,6 +286,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
}]);
app.controller('newOrgCtrl', ['$scope', '$http', '$state', 'Upload', 'commonDialog', function ($scope, $http, $state, Upload, commonDialog) {
$scope.types = angular.copy(types);
$scope.commission_types = angular.copy(commission_types);
$scope.uploadLogo = function (file) {
if (file == null) {
return;
@ -301,7 +314,10 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
});
return;
}
if($scope.currentUser.org_id !=null && !angular.equals({}, $scope.currentUser.org_id)) {
if($scope.org.type == 1){
$scope.org.commission_type = 2;
}
if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id) {
$scope.org.parent_org_id = angular.copy($scope.currentUser.org.org_id);
$scope.org.type = '0';
}

@ -65,7 +65,7 @@
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.type.$invalid && org_form.type.$dirty}"
ng-show="!currentUser.org_id">
ng-show="!('1000000000000'|withRole)">
<label class="control-label col-sm-2" for="org_type_input">Type *</label>
<div class="col-sm-8">
<!--<select class="form-control" ng-model="org.type" ng-init="org.type=0" id="org_type_input">-->
@ -79,6 +79,17 @@
</select>
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.commission_type_0.$invalid && org_form.commission_type_0.$dirty}"
ng-show="org.type == 0 || ('1000000000000'|withRole)">
<label class="control-label col-sm-2" for="commission_type_0">Commission Type *</label>
<div class="col-sm-8">
<select class="form-control" name="commission_type_0" required ng-model="org.commission_type" id="commission_type_0"
ng-options="commission_type.value as commission_type.label for commission_type in commission_types"
ng-if="org.type == 0 || ('1000000000000'|withRole)">
<option value="">Please Choose</option>
</select>
</div>
</div>
<div ng-if="org.type == 1">
<div class="form-group"
ng-class="{'has-error':org_form.rate_value.$invalid && org_form.rate_value.$dirty}">
@ -89,7 +100,18 @@
</div>
</div>
</div>
<div ng-if="org.type == 0 || currentUser.org_id !=null">
<div ng-if="org.type == 0 || ('1000000000000'|withRole) ">
<div ng-if="org.commission_type == 3">
<div class="form-group"
ng-class="{'has-error':org_form.rate_value.$invalid && org_form.rate_value.$dirty}">
<label class="control-label col-sm-2" for="rate_value_input_t">Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.rate_value"
id="rate_value_input_t" name="rate_value" max="100">
</div>
</div>
</div>
<div ng-if="org.commission_type == 1">
<div class="form-group"
ng-class="{'has-error':org_form.alipay_rate_value.$invalid && org_form.alipay_rate_value.$dirty}">
<label class="control-label col-sm-2" for="alipay_rate_value_input">Alipay rate *</label>
@ -128,13 +150,60 @@
<div class="form-group"
ng-class="{'has-error':org_form.alipayonline_rate_value.$invalid && org_form.alipayonline_rate_value.$dirty}">
<label class="control-label col-sm-2" for="alipayonline_rate_value_input">alipayonline rate *</label>
<label class="control-label col-sm-2" for="alipayonline_rate_value_input">Alipayonline Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.alipayonline_rate_value"
id="alipayonline_rate_value_input" name="alipayonline_rate_value" max="100">
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_wechat_rate.$invalid && org_form.min_wechat_rate.$dirty}">
<label class="control-label col-sm-2" for="min_wechat_rate_input">Min Wechat Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_wechat_rate"
id="min_wechat_rate_input" name="min_wechat_rate" max="100">
</div>
</div>
</div>
<div>
<div class="form-group"
ng-class="{'has-error':org_form.min_alipay_rate.$invalid && org_form.min_alipay_rate.$dirty}">
<label class="control-label col-sm-2" for="min_alipay_rate_input">Min Alipay Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_alipay_rate"
id="min_alipay_rate_input" name="min_alipay_rate" max="100" required>
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_bestpay_rate.$invalid && org_form.min_bestpay_rate.$dirty}">
<label class="control-label col-sm-2" for="min_bestpay_rate_input">Min Bestpay Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_bestpay_rate"
id="min_bestpay_rate_input" name="min_bestpay_rate" max="100" required>
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_jd_rate.$invalid && org_form.min_jd_rate.$dirty}">
<label class="control-label col-sm-2" for="min_jd_rate_input">Min Jd Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_jd_rate"
id="min_jd_rate_input" name="min_jd_rate" max="100" required>
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_alipayonline_rate.$invalid && org_form.min_alipayonline_rate.$dirty}">
<label class="control-label col-sm-2" for="min_alipayonline_rate_input">Min Alipayonline Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_alipayonline_rate"
id="min_alipayonline_rate_input" name="min_alipayonline_rate" max="100" required>
</div>
</div>
</div>
</div>

@ -51,7 +51,7 @@
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.type.$invalid && org_form.type.$dirty}"
ng-if="!currentUser.org_id">
ng-if="!('1000000000000'|withRole)">
<label class="control-label col-sm-2" for="org_type_input">Type *</label>
<div class="col-sm-8">
<!--<select class="form-control" ng-model="org.type" ng-init="org.type=0" id="org_type_input">-->
@ -65,6 +65,16 @@
</select>
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.commission_type_0.$invalid && org_form.commission_type_0.$dirty}"
ng-show="(org.type == 0) || ('1000000000000'|withRole)">
<label class="control-label col-sm-2" for="commission_type_0">Commission Type *</label>
<div class="col-sm-8">
<select class="form-control" name="commission_type_0" required ng-model="org.commission_type" id="commission_type_0"
ng-options="commission_type.value as commission_type.label for commission_type in commission_types">
<option value="">Please Choose</option>
</select>
</div>
</div>
<div ng-if="org.type == 1">
<div class="form-group" ng-class="{'has-error':org_form.rate_value.$invalid && org_form.rate_value.$dirty}">
<label class="control-label col-sm-2" for="rate_value_input">Rate *</label>
@ -75,6 +85,16 @@
</div>
</div>
<div ng-if="org.type == 0">
<div ng-if="org.commission_type == 3">
<div class="form-group" ng-class="{'has-error':org_form.rate_value.$invalid && org_form.rate_value.$dirty}">
<label class="control-label col-sm-2" for="rate_value_input_3">Rate *</label>
<div class="col-sm-8">
<input class="form-control form-control-float" type="number" ng-model="org.rate_value" id="rate_value_input_3" name="rate_value" max="100">
<span class="input-group-addon form-control-span">%</span>
</div>
</div>
</div>
<div ng-if="org.commission_type == 1">
<div class="form-group" ng-class="{'has-error':org_form.alipay_rate_value.$invalid && org_form.alipay_rate_value.$dirty}">
<label class="control-label col-sm-2" for="alipay_rate_value_input">Alipay Rate *</label>
<div class="col-sm-8">
@ -116,6 +136,93 @@
</div>
</div>
<div>
<div class="form-group"
ng-class="{'has-error':org_form.min_wechat_rate.$invalid && org_form.min_wechat_rate.$dirty}">
<label class="control-label col-sm-2" for="min_wechat_rate_input">Min Wechat Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_wechat_rate"
id="min_wechat_rate_input" name="min_wechat_rate" max="100">
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_alipay_rate.$invalid && org_form.min_alipay_rate.$dirty}">
<label class="control-label col-sm-2" for="min_alipay_rate_input">Min Alipay Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_alipay_rate"
id="min_alipay_rate_input" name="min_alipay_rate" max="100">
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_bestpay_rate.$invalid && org_form.min_bestpay_rate.$dirty}">
<label class="control-label col-sm-2" for="min_bestpay_rate_input">Min Bestpay Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_bestpay_rate"
id="min_bestpay_rate_input" name="min_bestpay_rate" max="100">
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_jd_rate.$invalid && org_form.min_jd_rate.$dirty}">
<label class="control-label col-sm-2" for="min_jd_rate_input">Min Jd Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_jd_rate"
id="min_jd_rate_input" name="min_jd_rate" max="100">
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_alipayonline_rate.$invalid && org_form.min_alipayonline_rate.$dirty}">
<label class="control-label col-sm-2" for="min_alipayonline_rate_input">Min Alipayonline Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_alipayonline_rate"
id="min_alipayonline_rate_input" name="min_alipayonline_rate" max="100">
</div>
</div>
</div>
</div>
<!-- <div ng-if="(org.type == 0 || currentUser.org_id !=null)">
<div class="form-group"
ng-class="{'has-error':org_form.min_alipay_rate.$invalid && org_form.min_alipay_rate.$dirty}">
<label class="control-label col-sm-2" for="min_alipay_rate_input">Min Alipay Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_alipay_rate"
id="min_alipay_rate_input" name="min_alipay_rate" max="100">
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_bestpay_rate.$invalid && org_form.min_bestpay_rate.$dirty}">
<label class="control-label col-sm-2" for="min_bestpay_rate_input">Min Bestpay Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_bestpay_rate"
id="min_bestpay_rate_input" name="min_bestpay_rate" max="100">
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_jd_rate.$invalid && org_form.min_jd_rate.$dirty}">
<label class="control-label col-sm-2" for="min_jd_rate_input">Min Jd Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_jd_rate"
id="min_jd_rate_input" name="min_jd_rate" max="100">
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_alipayonline_rate.$invalid && org_form.min_alipayonline_rate.$dirty}">
<label class="control-label col-sm-2" for="min_alipayonline_rate_input">Min Alipayonline Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_alipayonline_rate"
id="min_alipayonline_rate_input" name="min_alipayonline_rate" max="100">
</div>
</div>
</div>-->
<div class="form-group" ng-class="{'has-error':org_form.contact_person.$invalid && org_form.contact_person.$dirty}">
<label class="control-label col-sm-2" for="org_contact_person_input">Contact Person *</label>
<div class="col-sm-8">

@ -22,7 +22,7 @@
<div class="box box-warning">
<div class="box-body">
<uib-tabset>
<uib-tab heading="Basic Info">
<!-- <uib-tab heading="Basic Info">
<form class="form-horizontal margin-top" name="org_form" novalidate>
<div class="panel">
<div class="form-group" ng-class="{'has-error':org_form.name.$invalid && org_form.name.$dirty}">
@ -53,6 +53,143 @@
<div class="form-group" ng-class="{'has-error':org_form.type.$invalid && org_form.type.$dirty}"
ng-if="!currentUser.org_id">
<label class="control-label col-sm-2" for="org_type_input">Type *</label>
<div class="col-sm-8">
&lt;!&ndash;<select class="form-control" ng-model="org.type" ng-init="org.type=0" id="org_type_input">&ndash;&gt;
&lt;!&ndash;<option value="0">代理人</option>&ndash;&gt;
&lt;!&ndash;<option value="1">推荐人</option>&ndash;&gt;
&lt;!&ndash;</select>&ndash;&gt;
<select class="form-control" name="type" required ng-model="org.type"
id="org_type_input"
ng-options="type.value as type.label for type in types">
&lt;!&ndash;<option value="">Please Choose</option>&ndash;&gt;
</select>
</div>
</div>
<div ng-if="org.type == 1">
<div class="form-group" ng-class="{'has-error':org_form.rate_value.$invalid && org_form.rate_value.$dirty}">
<label class="control-label col-sm-2" for="rate_value_input">Rate *</label>
<div class="col-sm-8">
<input class="form-control form-control-float" type="number" ng-model="org.rate_value" id="rate_value_input" name="rate_value" max="100">
<span class="input-group-addon form-control-span">%</span>
</div>
</div>
</div>
<div ng-if="org.type == 0">
<div class="form-group" ng-class="{'has-error':org_form.alipay_rate_value.$invalid && org_form.alipay_rate_value.$dirty}">
<label class="control-label col-sm-2" for="alipay_rate_value_input">Alipay Rate *</label>
<div class="col-sm-8">
<input class="form-control form-control-float" type="number" ng-model="org.alipay_rate_value" id="alipay_rate_value_input" name="alipay_rate_value" max="100" readonly>
<span class="input-group-addon form-control-span">%</span>
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.wechat_rate_value.$invalid && org_form.wechat_rate_value.$dirty}">
<label class="control-label col-sm-2" for="wechat_rate_value_input">Wechat Rate *</label>
<div class="col-sm-8">
<input class="form-control form-control-float" type="number" ng-model="org.wechat_rate_value" id="wechat_rate_value_input" name="wechat_rate_value" max="100" readonly>
<span class="input-group-addon form-control-span">%</span>
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.bestpay_rate_value.$invalid && org_form.bestpay_rate_value.$dirty}">
<label class="control-label col-sm-2" for="bestpay_rate_value_input">Bestpay Rate *</label>
<div class="col-sm-8">
<input class="form-control form-control-float" type="number" ng-model="org.bestpay_rate_value" id="bestpay_rate_value_input" name="bestpay_rate_value" max="100" readonly>
<span class="input-group-addon form-control-span">%</span>
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.jd_rate_value.$invalid && org_form.jd_rate_value.$dirty}">
<label class="control-label col-sm-2" for="jd_rate_value_input">JD Pay Rate *</label>
<div class="col-sm-8">
<input class="form-control form-control-float" type="number" ng-model="org.jd_rate_value" id="jd_rate_value_input" name="jd_rate_value" max="100" readonly>
<span class="input-group-addon form-control-span">%</span>
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.alipayonline_rate_value.$invalid && org_form.alipayonline_rate_value.$dirty}">
<label class="control-label col-sm-2" for="alipayonline_rate_value_input">AlipayOnline Rate *</label>
<div class="col-sm-8">
<input class="form-control form-control-float" type="number" ng-model="org.alipayonline_rate_value" id="alipayonline_rate_value_input" name="alipayonline_rate_value" max="100" readonly>
<span class="input-group-addon form-control-span">%</span>
</div>
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.contact_person.$invalid && org_form.contact_person.$dirty}">
<label class="control-label col-sm-2" for="org_contact_person_input">Contact Person *</label>
<div class="col-sm-8">
<input class="form-control" ng-model="org.contact_person" id="org_contact_person_input" name="contact_person" required>
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.contact_phone.$invalid && org_form.contact_phone.$dirty}">
<label class="control-label col-sm-2" for="org_contact_phone_input">Phone *</label>
<div class="col-sm-8">
<input class="form-control" ng-model="org.contact_phone" id="org_contact_phone_input" name="contact_phone" required>
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.contact_mail.$invalid && org_form.contact_mail.$dirty}">
<label class="control-label col-sm-2" for="org_contact_mail_input">Mail *</label>
<div class="col-sm-8">
<input class="form-control" ng-model="org.contact_mail" id="org_contact_mail_input" name="contact_mail" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="commission_checkbox">Enable Commission</label>
<div class="col-sm-8">
<input id="commission_checkbox" type="checkbox" class="checkbox-inline checkbox" ng-model="org.commission" readonly
onclick="return false">
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.remark.$invalid && org_form.remark.$dirty}">
<label class="control-label col-sm-2" for="remark-input">Remark</label>
<div class="col-sm-8">
<textarea class="form-control" ng-model="org.remark" name="remark"
id="remark-input" maxlength="500"></textarea>
</div>
</div>
</div>
<div class="btn-group margin-bottom margin-top">
<button class="btn btn-success" type="button" ng-click="update(org_form)">Save
</button>
<a class="btn btn-danger" role="button" ui-sref="^" ui-sref-opts="{reload:true}">Back</a>
</div>
&lt;!&ndash;<button class="btn btn-success col-sm-offset-2" ng-click="update()"><i class="fa fa-save"></i> Update</button>&ndash;&gt;
</form>
</uib-tab>-->
<uib-tab heading="Basic Info">
<form class="form-horizontal margin-top" name="org_form" novalidate>
<div class="panel">
<div class="form-group" ng-class="{'has-error':org_form.name.$invalid && org_form.name.$dirty}">
<label class="control-label col-sm-2" for="org_name_input">Name *</label>
<div class="col-sm-8">
<input class="form-control" ng-model="org.name" id="org_name_input" name="name" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Logo</label>
<div class="col-sm-8">
<p class="form-control-static">
<button class="btn btn-primary" type="button" ngf-select="uploadLogo($file)"
accept="image/*" ngf-max-size="1MB">
<i class="fa fa-upload"></i> Upload
</button>
<uib-progressbar value="logoProgress.value" ng-if="logoProgress"></uib-progressbar>
<img ng-src="{{org.logo}}" class="col-sm-3" ng-if="org.logo">
</p>
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.location.$invalid && org_form.location.$dirty}">
<label class="control-label col-sm-2" for="org_location_input">Location *</label>
<div class="col-sm-8">
<input class="form-control" ng-model="org.location" id="org_location_input" name="location" required>
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.type.$invalid && org_form.type.$dirty}"
ng-if="!('1000000000000'|withRole)">
<label class="control-label col-sm-2" for="org_type_input">Type *</label>
<div class="col-sm-8">
<!--<select class="form-control" ng-model="org.type" ng-init="org.type=0" id="org_type_input">-->
<!--<option value="0">代理人</option>-->
@ -65,6 +202,16 @@
</select>
</div>
</div>
<div class="form-group" ng-class="{'has-error':org_form.commission_type_0.$invalid && org_form.commission_type_0.$dirty}"
ng-show="(org.type == 0) || ('1000000000000'|withRole)">
<label class="control-label col-sm-2" for="commission_type_0">Commission Type *</label>
<div class="col-sm-8">
<select class="form-control" name="commission_type_0" required ng-model="org.commission_type" id="commission_type_0"
ng-options="commission_type.value as commission_type.label for commission_type in commission_types">
<option value="">Please Choose</option>
</select>
</div>
</div>
<div ng-if="org.type == 1">
<div class="form-group" ng-class="{'has-error':org_form.rate_value.$invalid && org_form.rate_value.$dirty}">
<label class="control-label col-sm-2" for="rate_value_input">Rate *</label>
@ -75,6 +222,16 @@
</div>
</div>
<div ng-if="org.type == 0">
<div ng-if="org.commission_type == 3">
<div class="form-group" ng-class="{'has-error':org_form.rate_value.$invalid && org_form.rate_value.$dirty}">
<label class="control-label col-sm-2" for="rate_value_input_3">Rate *</label>
<div class="col-sm-8">
<input class="form-control form-control-float" type="number" ng-model="org.rate_value" id="rate_value_input_3" name="rate_value" max="100" readonly>
<span class="input-group-addon form-control-span">%</span>
</div>
</div>
</div>
<div ng-if="org.commission_type == 1">
<div class="form-group" ng-class="{'has-error':org_form.alipay_rate_value.$invalid && org_form.alipay_rate_value.$dirty}">
<label class="control-label col-sm-2" for="alipay_rate_value_input">Alipay Rate *</label>
<div class="col-sm-8">
@ -116,6 +273,92 @@
</div>
</div>
<div>
<div class="form-group"
ng-class="{'has-error':org_form.min_wechat_rate.$invalid && org_form.min_wechat_rate.$dirty}">
<label class="control-label col-sm-2" for="min_wechat_rate_input">Min Wechat Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_wechat_rate"
id="min_wechat_rate_input" name="min_wechat_rate" max="10" readonly>
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_alipay_rate.$invalid && org_form.min_alipay_rate.$dirty}">
<label class="control-label col-sm-2" for="min_alipay_rate_input">Min Alipay Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_alipay_rate"
id="min_alipay_rate_input" name="min_alipay_rate" max="10" readonly>
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_bestpay_rate.$invalid && org_form.min_bestpay_rate.$dirty}">
<label class="control-label col-sm-2" for="min_bestpay_rate_input">Min Bestpay Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_bestpay_rate"
id="min_bestpay_rate_input" name="min_bestpay_rate" max="10" readonly>
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_jd_rate.$invalid && org_form.min_jd_rate.$dirty}">
<label class="control-label col-sm-2" for="min_jd_rate_input">Min Jd Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_jd_rate"
id="min_jd_rate_input" name="min_jd_rate" max="10" readonly>
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_alipayonline_rate.$invalid && org_form.min_alipayonline_rate.$dirty}">
<label class="control-label col-sm-2" for="min_alipayonline_rate_input">Min Alipayonline Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_alipayonline_rate"
id="min_alipayonline_rate_input" name="min_alipayonline_rate" max="10" readonly>
</div>
</div>
</div>
</div>
<!-- <div ng-if="(org.type == 0 || currentUser.org_id !=null)">
<div class="form-group"
ng-class="{'has-error':org_form.min_alipay_rate.$invalid && org_form.min_alipay_rate.$dirty}">
<label class="control-label col-sm-2" for="min_alipay_rate_input">Min Alipay Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_alipay_rate"
id="min_alipay_rate_input" name="min_alipay_rate" max="100">
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_bestpay_rate.$invalid && org_form.min_bestpay_rate.$dirty}">
<label class="control-label col-sm-2" for="min_bestpay_rate_input">Min Bestpay Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_bestpay_rate"
id="min_bestpay_rate_input" name="min_bestpay_rate" max="100">
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_jd_rate.$invalid && org_form.min_jd_rate.$dirty}">
<label class="control-label col-sm-2" for="min_jd_rate_input">Min Jd Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_jd_rate"
id="min_jd_rate_input" name="min_jd_rate" max="100">
</div>
</div>
<div class="form-group"
ng-class="{'has-error':org_form.min_alipayonline_rate.$invalid && org_form.min_alipayonline_rate.$dirty}">
<label class="control-label col-sm-2" for="min_alipayonline_rate_input">Min Alipayonline Rate *</label>
<div class="col-sm-8">
<input class="form-control" type="number" ng-model="org.min_alipayonline_rate"
id="min_alipayonline_rate_input" name="min_alipayonline_rate" max="100">
</div>
</div>
</div>-->
<div class="form-group" ng-class="{'has-error':org_form.contact_person.$invalid && org_form.contact_person.$dirty}">
<label class="control-label col-sm-2" for="org_contact_person_input">Contact Person *</label>
<div class="col-sm-8">
@ -137,8 +380,7 @@
<div class="form-group">
<label class="control-label col-sm-2" for="commission_checkbox">Enable Commission</label>
<div class="col-sm-8">
<input id="commission_checkbox" type="checkbox" class="checkbox-inline checkbox" ng-model="org.commission" readonly
onclick="return false">
<input id="commission_checkbox" type="checkbox" class="checkbox-inline checkbox" ng-model="org.commission">
</div>
</div>
<div class="form-group"
@ -158,16 +400,6 @@
<!--<button class="btn btn-success col-sm-offset-2" ng-click="update()"><i class="fa fa-save"></i> Update</button>-->
</form>
</uib-tab>
<!-- <uib-tab heading="Permission" ng-if="org.type == 0">
<form class="form-horizontal margin-top" name="org_permission_form">
<div class="form-group">
<label class="col-xs-4 col-sm-2 control-label">Client Rate Editable</label>
<div class="col-xs-8 col-sm-8">
<input type="checkbox" ng-model="org.rate_editable" bs-switch switch-change="toggleRateEditable()">
</div>
</div>
</form>
</uib-tab>-->
</uib-tabset>
</div>
</div>

@ -1,6 +1,21 @@
/**
* 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) {
'use strict';
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})
};
}]);
app.controller('orgCommissionMonthViewCtrl', ['$scope', 'monthData', function ($scope, monthData) {
app.controller('orgCommissionMonthViewCtrl', ['$scope', 'monthData','$filter', function ($scope, monthData) {
$scope.monthData = monthData.data;
$scope.ctrl = {};
$scope.commissionTypeMap = commissionTypeMap;
$scope.active = function (log) {
if($scope.ctrl.activeLog && $scope.ctrl.activeLog.org_id==log.org_id){
$scope.ctrl.activeLog=null;
@ -100,5 +117,23 @@ define(['angular','../../analysis/org/analysis-org'], function (angular) {
$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;
});

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

@ -0,0 +1,33 @@
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);
}
@Test
public void generate() throws Exception {
cityPartnerPrizeService.generate("2017-06");
}
}
Loading…
Cancel
Save