update 增加alipay plus的代理商提成计算

master
Todking 4 years ago
parent 7f574c45df
commit 5c8d50fd3a

@ -376,6 +376,11 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
channelCharge.put("alipayonlineChargeRate", alipayonlineChargeRate); channelCharge.put("alipayonlineChargeRate", alipayonlineChargeRate);
List<JSONObject> transactionDetail = transactionMapper.listTransactionForCityPartnerCommissionByDate(year, month); List<JSONObject> transactionDetail = transactionMapper.listTransactionForCityPartnerCommissionByDate(year, month);
transactionDetail.forEach(item -> {
if (StringUtils.equalsIgnoreCase("AlipayPlus", item.getString("channel"))) {
item.put("channel", item.getString("pay_type"));
}
});
Map<Integer, List<JSONObject>> groupByOrgMap = transactionDetail.stream().collect(Collectors.groupingBy(e -> e.getInteger("org_id"))); Map<Integer, List<JSONObject>> groupByOrgMap = transactionDetail.stream().collect(Collectors.groupingBy(e -> e.getInteger("org_id")));
for (Map.Entry<Integer, List<JSONObject>> oneOrg : groupByOrgMap.entrySet()) { for (Map.Entry<Integer, List<JSONObject>> oneOrg : groupByOrgMap.entrySet()) {
int orgId = oneOrg.getKey(); int orgId = oneOrg.getKey();
@ -436,6 +441,16 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
if (orgInfo.get("rpaypmt_overseas_card_rate_value") == null) { if (orgInfo.get("rpaypmt_overseas_card_rate_value") == null) {
throw new ServerErrorException(orgInfo.getString("name") + "组织下overseas_card成本手续费未设置"); throw new ServerErrorException(orgInfo.getString("name") + "组织下overseas_card成本手续费未设置");
} }
} else if (StringUtils.equalsAny(channel, "alipay_ac_sg", "alipay_ac_mo", "alipay_ac_hk", "alipay_ac_lu", "alipay_ac_gb", "alipay_ac_us", "paytm", "kakaopay", "truemoney", "ezlink", "gcash", "tng", "dana", "easy_paisa", "bkash", "lazada_wallet_my")) {
channel = "alipayother";
if (orgInfo.get("alipayother_rate_value") == null) {
throw new ServerErrorException(orgInfo.getString("name") + "组织下" + oneChannel.getKey() + "成本手续费未设置");
}
} else if (StringUtils.equals(channel, "alipay_cn")) {
channel = "alipayonlinecn";
if (orgInfo.get("alipayonlinecn_rate_value") == null) {
throw new ServerErrorException(orgInfo.getString("name") + "组织下" + oneChannel.getKey() + "成本手续费未设置");
}
} else { } else {
throw new ServerErrorException(orgInfo.getString("name") + "组织下" + oneChannel.getKey() + "成本手续费未设置"); throw new ServerErrorException(orgInfo.getString("name") + "组织下" + oneChannel.getKey() + "成本手续费未设置");
@ -583,6 +598,12 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
Date dateto = new Date(); Date dateto = new Date();
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
String channel = oneChannel.getKey(); String channel = oneChannel.getKey();
if (StringUtils.equals(oneChannel.getKey(), "alipay_cn")) {
channel = "alipayonlinecn";
}
if (StringUtils.equalsAny(oneChannel.getKey(), "alipay_ac_sg", "alipay_ac_mo", "alipay_ac_hk", "alipay_ac_lu", "alipay_ac_gb", "alipay_ac_us", "paytm", "kakaopay", "truemoney", "ezlink", "gcash", "tng", "dana", "easy_paisa", "bkash", "lazada_wallet_my")) {
channel = "alipayother";
}
String rateChannel = oneChannel.getKey(); String rateChannel = oneChannel.getKey();
JSONObject clientRate = null; JSONObject clientRate = null;
try { try {
@ -665,7 +686,8 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP)); royalpay_surage = royalpay_surage.add(tmpClearingAmount.multiply(channelRate).setScale(i, RoundingMode.HALF_UP));
//net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge)); //net_surage = net_surage.add(getThirdPartyCharge(params.getString("channel"), params.getBigDecimal("clearing_amount"), channelCharge));
net_surage = net_surage.add(params.getBigDecimal("channel_surcharge")); net_surage = net_surage.add(params.getBigDecimal("channel_surcharge"));
transaction_fee = transaction_fee.add(params.getBigDecimal("transaction_fee")); } transaction_fee = transaction_fee.add(params.getBigDecimal("transaction_fee"));
}
} }
BigDecimal org_charge = total_surage.subtract(royalpay_surage); BigDecimal org_charge = total_surage.subtract(royalpay_surage);
@ -836,6 +858,11 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
financialAgentCommissionMapper.clearData(year, month); financialAgentCommissionMapper.clearData(year, month);
financialAgentCommissionDetailMapper.clearData(year, month); financialAgentCommissionDetailMapper.clearData(year, month);
List<JSONObject> transactionDetail = transactionMapper.listTransactionForCityPartnerAgentCommissionByDate(year, month); List<JSONObject> transactionDetail = transactionMapper.listTransactionForCityPartnerAgentCommissionByDate(year, month);
transactionDetail.forEach(item -> {
if (StringUtils.equalsIgnoreCase("AlipayPlus", item.getString("channel"))) {
item.put("channel", item.getString("pay_type"));
}
});
Map<Integer, List<JSONObject>> groupByOrgMap = transactionDetail.stream().collect(Collectors.groupingBy(e -> e.getInteger("org_id"))); Map<Integer, List<JSONObject>> groupByOrgMap = transactionDetail.stream().collect(Collectors.groupingBy(e -> e.getInteger("org_id")));
for (Map.Entry<Integer, List<JSONObject>> oneOrg : groupByOrgMap.entrySet()) { for (Map.Entry<Integer, List<JSONObject>> oneOrg : groupByOrgMap.entrySet()) {
@ -1203,8 +1230,10 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
if (CollectionUtils.isEmpty(seniorSubOrgs)) { if (CollectionUtils.isEmpty(seniorSubOrgs)) {
return; return;
} }
JSONObject seniorOrgAnalysis = financialPartnerCommissionMapper.analysisSeniorForGenerate(year, month, seniorSubOrgs); JSONObject seniorOrgAnalysis = financialPartnerCommissionMapper.analysisSeniorForGenerate(year, month, seniorSubOrgs);
if (seniorOrgAnalysis == null) {
return;
}
JSONObject record = new JSONObject(); JSONObject record = new JSONObject();
record.put("org_id", p); record.put("org_id", p);
record.put("year", year); record.put("year", year);

@ -2,8 +2,10 @@ package au.com.royalpay.payment.manage.citypartner.web;
import au.com.royalpay.payment.manage.citypartner.core.CityPartnerPrizeService; import au.com.royalpay.payment.manage.citypartner.core.CityPartnerPrizeService;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.manage.tradelog.beans.enums.AlipayPlusChannelEnum;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -24,6 +26,10 @@ public class CityPartnerPrizeController {
@Resource @Resource
private CityPartnerPrizeService cityPartnerPrizeService; private CityPartnerPrizeService cityPartnerPrizeService;
/**
*
* @param param
*/
@PostMapping("/generate") @PostMapping("/generate")
public void generate(@RequestBody JSONObject param) { public void generate(@RequestBody JSONObject param) {
String month = param.getString("month"); String month = param.getString("month");
@ -71,6 +77,8 @@ public class CityPartnerPrizeController {
String cityPartnerName = ""; String cityPartnerName = "";
int org_id = 0; int org_id = 0;
int type = 1; int type = 1;
ArrayList<JSONObject> objectAlipayPlus = new ArrayList<>();
ArrayList<Object> unGmos = new ArrayList<>();
for (JSONObject jsonObject : entry.getValue()) { for (JSONObject jsonObject : entry.getValue()) {
grossAmount = grossAmount.add(jsonObject.getBigDecimal("gross_amount")); grossAmount = grossAmount.add(jsonObject.getBigDecimal("gross_amount"));
totalCharge = totalCharge.add(jsonObject.getBigDecimal("total_charge")); totalCharge = totalCharge.add(jsonObject.getBigDecimal("total_charge"));
@ -83,6 +91,12 @@ public class CityPartnerPrizeController {
org_id = jsonObject.getIntValue("org_id"); org_id = jsonObject.getIntValue("org_id");
cityPartnerName = jsonObject.getString("name"); cityPartnerName = jsonObject.getString("name");
type = jsonObject.getIntValue("commission_type"); type = jsonObject.getIntValue("commission_type");
if (StringUtils.equalsAny(jsonObject.getString("channel"), "alipay_cn", "alipay_ac_sg", "alipay_ac_mo", "alipay_ac_hk", "alipay_ac_lu", "alipay_ac_gb", "alipay_ac_us", "paytm", "kakaopay", "truemoney", "ezlink", "gcash", "tng", "dana", "easy_paisa", "bkash", "lazada_wallet_my")) {
jsonObject.put("channel", AlipayPlusChannelEnum.statusOf(jsonObject.getString("channel")).description());
objectAlipayPlus.add(jsonObject);
} else {
unGmos.add(jsonObject);
}
} }
if (entry.getValue().get(0).get("parent_org_id") != null) { if (entry.getValue().get(0).get("parent_org_id") != null) {
sumResult.put("org_type", "agent"); sumResult.put("org_type", "agent");
@ -96,7 +110,25 @@ public class CityPartnerPrizeController {
sumResult.put("org_id", org_id); sumResult.put("org_id", org_id);
sumResult.put("net_charge", netCharge); sumResult.put("net_charge", netCharge);
sumResult.put("type",type); sumResult.put("type",type);
sumResult.put("channel_detail", entry.getValue()); if (objectAlipayPlus.size() != 0) {
JSONObject totalAlipayPlus = new JSONObject();
for (JSONObject alipayPlus : objectAlipayPlus) {
totalAlipayPlus.put("org_rate", 0);
totalAlipayPlus.put("org_id", alipayPlus.getString("org_id"));
totalAlipayPlus.put("year", alipayPlus.getString("year"));
totalAlipayPlus.put("month", alipayPlus.getString("month"));
totalAlipayPlus.put("channel", "alipayPlus");
totalAlipayPlus.put("gross_amount", alipayPlus.getBigDecimal("gross_amount").add(totalAlipayPlus.getBigDecimal("gross_amount") != null ? totalAlipayPlus.getBigDecimal("gross_amount") : BigDecimal.valueOf(0)));
totalAlipayPlus.put("net_charge", alipayPlus.getBigDecimal("net_charge").add(totalAlipayPlus.getBigDecimal("net_charge") != null ? totalAlipayPlus.getBigDecimal("net_charge") : BigDecimal.valueOf(0)));
totalAlipayPlus.put("total_charge", alipayPlus.getBigDecimal("total_charge").add(totalAlipayPlus.getBigDecimal("total_charge") != null ? totalAlipayPlus.getBigDecimal("total_charge") : BigDecimal.valueOf(0)));
totalAlipayPlus.put("royalpay_charge", alipayPlus.getBigDecimal("royalpay_charge").add(totalAlipayPlus.getBigDecimal("royalpay_charge") != null ? totalAlipayPlus.getBigDecimal("royalpay_charge") : BigDecimal.valueOf(0)));
totalAlipayPlus.put("share_charge", alipayPlus.getBigDecimal("share_charge").add(totalAlipayPlus.getBigDecimal("share_charge") != null ? totalAlipayPlus.getBigDecimal("share_charge") : BigDecimal.valueOf(0)));
totalAlipayPlus.put("org_charge", alipayPlus.getBigDecimal("org_charge").add(totalAlipayPlus.getBigDecimal("org_charge") != null ? totalAlipayPlus.getBigDecimal("org_charge") : BigDecimal.valueOf(0)));
}
totalAlipayPlus.put("AlipayPlus", objectAlipayPlus);
unGmos.add(totalAlipayPlus);
}
sumResult.put("channel_detail", unGmos);
resultTotalCharge = resultTotalCharge.add(totalCharge); resultTotalCharge = resultTotalCharge.add(totalCharge);
resultRoyalpayCharge = resultRoyalpayCharge.add(royalpayCharge); resultRoyalpayCharge = resultRoyalpayCharge.add(royalpayCharge);
if ("agent".equals(sumResult.getString("org_type"))) { if ("agent".equals(sumResult.getString("org_type"))) {

@ -0,0 +1,322 @@
package au.com.royalpay.payment.manage.tradelog.beans.enums;
public enum AlipayPlusChannelEnum {
ALIPAY_CN {
@Override
public int code() {
return 0;
}
@Override
public String value() {
return "alipay_cn";
}
@Override
public String description() {
return "ALIPAY_CN";
}
},
ALIPAY_SG {
@Override
public int code() {
return 1;
}
@Override
public String value() {
return "alipay_ac_sg";
}
@Override
public String description() {
return "ALIPAY_SG";
}
},
ALIPAY_MO {
@Override
public int code() {
return 2;
}
@Override
public String value() {
return "alipay_ac_mo";
}
@Override
public String description() {
return "ALIPAY_MO";
}
},
ALIPAY_HK {
@Override
public int code() {
return 3;
}
@Override
public String value() {
return "alipay_ac_hk";
}
@Override
public String description() {
return "ALIPAY_HK";
}
},
ALIPAY_LU {
@Override
public int code() {
return 4;
}
@Override
public String value() {
return "alipay_ac_lu";
}
@Override
public String description() {
return "ALIPAY_LU";
}
},
ALIPAY_GB {
@Override
public int code() {
return 5;
}
@Override
public String value() {
return "alipay_ac_gb";
}
@Override
public String description() {
return "ALIPAY_GB";
}
},
ALIPAY_US {
@Override
public int code() {
return 6;
}
@Override
public String value() {
return "alipay_ac_us";
}
@Override
public String description() {
return "ALIPAY_US";
}
},
PAYTM {
@Override
public int code() {
return 7;
}
@Override
public String value() {
return "paytm";
}
@Override
public String description() {
return "PAYTM";
}
},
KAKAOPAY {
@Override
public int code() {
return 8;
}
@Override
public String value() {
return "kakaopay";
}
@Override
public String description() {
return "KAKAOPAY";
}
},
TRUEMONEY {
@Override
public int code() {
return 9;
}
@Override
public String value() {
return "truemoney";
}
@Override
public String description() {
return "TRUEMONEY";
}
},
EZLINK {
@Override
public int code() {
return 10;
}
@Override
public String value() {
return "ezlink";
}
@Override
public String description() {
return "EZLINK";
}
},
GCASH {
@Override
public int code() {
return 11;
}
@Override
public String value() {
return "gcash";
}
@Override
public String description() {
return "GCASH";
}
},
TNG {
@Override
public int code() {
return 12;
}
@Override
public String value() {
return "tng";
}
@Override
public String description() {
return "TNG";
}
},
DANA {
@Override
public int code() {
return 13;
}
@Override
public String value() {
return "dana";
}
@Override
public String description() {
return "DANA";
}
},
EASYPAISA {
@Override
public int code() {
return 14;
}
@Override
public String value() {
return "easy_paisa";
}
@Override
public String description() {
return "EASYPAISA";
}
},
BKASH {
@Override
public int code() {
return 15;
}
@Override
public String value() {
return "bkash";
}
@Override
public String description() {
return "BKASH";
}
},
LAZADAWALLET {
@Override
public int code() {
return 16;
}
@Override
public String value() {
return "lazada_wallet_my";
}
@Override
public String description() {
return "LAZADAWALLET";
}
},
UNKNOWN {
@Override
public int code() {
return -1;
}
@Override
public String value() {
return "unknown";
}
@Override
public String description() {
return "AlipayPlus";
}
};
/**
*
*
* @return
*/
public abstract int code();
/**
*
*
* @return
*/
public abstract String value();
/**
*
*
* @return
*/
public abstract String description();
public static AlipayPlusChannelEnum statusOf(String value) {
for (AlipayPlusChannelEnum item : AlipayPlusChannelEnum.values()) {
if (item.value().equalsIgnoreCase(value)) {
return item;
}
}
return AlipayPlusChannelEnum.UNKNOWN;
}
}

@ -945,6 +945,7 @@
IF( t.transaction_type = 'Credit', t.settle_amount, - (if(t.settle_amount>=0,t.settle_amount, - t.settle_amount)) ) settle_amount, IF( t.transaction_type = 'Credit', t.settle_amount, - (if(t.settle_amount>=0,t.settle_amount, - t.settle_amount)) ) settle_amount,
t.order_id, t.order_id,
t.org_rate, t.org_rate,
o.pay_type,
t.surcharge_cashback, t.surcharge_cashback,
o.customer_surcharge o.customer_surcharge
from pmt_transactions t from pmt_transactions t
@ -975,6 +976,7 @@
t.org_rate, t.org_rate,
t.surcharge_cashback, t.surcharge_cashback,
o.customer_surcharge, o.customer_surcharge,
o.pay_type
from pmt_transactions t from pmt_transactions t
LEFT JOIN pmt_orders o on o.order_id = t.order_id LEFT JOIN pmt_orders o on o.order_id = t.order_id
INNER JOIN sys_org so ON t.org_id = so.org_id AND so.is_valid = 1 INNER JOIN sys_org so ON t.org_id = so.org_id AND so.is_valid = 1

@ -177,6 +177,7 @@ define(['angular', '../../analysis/org/analysis-org'], function (angular) {
$scope.ctrl = {} $scope.ctrl = {}
$scope.commissionTypeMap = commissionTypeMap $scope.commissionTypeMap = commissionTypeMap
$scope.seniors = {} $scope.seniors = {}
$scope.isAlipayPlus = false
$scope.active = function (log) { $scope.active = function (log) {
$http.get('/sys/citypartner_prizes/senior/' + log.org_id + '/details?monthStr=' + $scope.monthData.monthstr).then(function (resp) { $http.get('/sys/citypartner_prizes/senior/' + log.org_id + '/details?monthStr=' + $scope.monthData.monthstr).then(function (resp) {
$scope.seniors = resp.data $scope.seniors = resp.data
@ -186,6 +187,15 @@ define(['angular', '../../analysis/org/analysis-org'], function (angular) {
} }
$scope.ctrl.activeLog = log $scope.ctrl.activeLog = log
}) })
$scope.isAlipayPlus = false
}
$scope.activeAlipayPlus= function (detail){
$scope.isAlipayPlus = !$scope.isAlipayPlus
if($scope.isAlipayPlus){
$scope.ctrl.activeDetail = detail;
}else {
$scope.ctrl.activeDetail = null;
}
} }
}, },
]) ])

@ -24,7 +24,8 @@
<div class="box box-default"> <div class="box box-default">
<div class="box-header">Details</div> <div class="box-header">Details</div>
<div class="box-body table-responsive"> <div class="box-body table-responsive">
<div style="float:right"><a role="button" class="btn-group btn btn-warning" type="button" ng-href="/sys/citypartner_prizes/export/{{monthData.monthstr}}"> <div style="float:right"><a role="button" class="btn-group btn btn-warning" type="button"
ng-href="/sys/citypartner_prizes/export/{{monthData.monthstr}}">
<i class="fa fa-download"></i>提成明细文件</a> <i class="fa fa-download"></i>提成明细文件</a>
</div> </div>
<table class="table table-bordered table-hover table-striped"> <table class="table table-bordered table-hover table-striped">
@ -120,7 +121,13 @@
<td ng-bind="detail.net_charge"></td> <td ng-bind="detail.net_charge"></td>
<td ng-bind="detail.org_charge"></td> <td ng-bind="detail.org_charge"></td>
<td ng-bind="detail.share_charge"></td> <td ng-bind="detail.share_charge"></td>
<td ng-bind="detail.channel"></td> <td>
{{detail.channel}}
<a role="button" ng-if="detail.channel == 'alipayPlus'"
ng-click="activeAlipayPlus(detail)">
<i class="fa fa-list-ul"></i>
</a>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -143,6 +150,54 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<table ng-if="isAlipayPlus"
class="table table-bordered table-hover table-striped">
<thead>
<tr>
<!-- <th>{{'partner_commission_month.keep_rate' | translate}}</th>-->
<!-- <th>{{'partner_card.transaction_amount' | translate}}</th>-->
<!-- <th>{{'partner_commission_month.total_charge' | translate}}</th>-->
<!-- <th>{{sysconfig.company_name}}{{'partner_commission_month.charge' | translate}}</th>-->
<!-- <th>{{'partner_commission_month.net_charge' | translate}}</th>-->
<!-- <th>{{'partner_commission_month.city_partner_charge' | translate}}</th>-->
<!-- <th>{{'partner_commission_month.city_partner_share' | translate}}</th>-->
<!-- <th>{{'select.channel.channel' | translate}}</th>-->
<th>Keep Rate</th>
<th>Transaction Amount</th>
<th>Total Charge</th>
<th>RoyalPay Charge</th>
<th>Net Charge</th>
<th>City Partner Charge</th>
<th>Share Charge</th>
<th>channel</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="alipayplus in ctrl.activeDetail.AlipayPlus">
<td ng-bind="alipayplus.org_rate"></td>
<td ng-bind="alipayplus.gross_amount"></td>
<td ng-bind="alipayplus.total_charge"></td>
<td ng-bind="alipayplus.royalpay_charge"></td>
<td ng-bind="alipayplus.net_charge"></td>
<td ng-bind="alipayplus.org_charge"></td>
<td ng-bind="alipayplus.share_charge"></td>
<td>
{{alipayplus.channel}}
<a ng-if="!alipayplus.parent_org_id" role="button"
ng-href="/sys/citypartners/client/extract/{{alipayplus.org_id}}/excel?year={{alipayplus.year}}&month={{alipayplus.month}}&channel={{alipayplus.channel}}"
target="_blank" title="Download Transactions">
<i class="fa fa-download"></i>
</a>
<a ng-if="alipayplus.parent_org_id" role="button"
ng-href="/sys/citypartners/client/extract/{{alipayplus.org_id}}/agent/excel?year={{alipayplus.year}}&month={{alipayplus.month}}&channel={{alipayplus.channel}}"
target="_blank" title="Download Transactions">
<i class="fa fa-download"></i>
</a>
</td>
</tr>
</tbody>
</table>
</td> </td>
</tr> </tr>
</tbody> </tbody>

Loading…
Cancel
Save