add org_detail 商户/交易数据/提成 && 重构合伙人提成

master
luoyang 6 years ago
parent 9b2b7a6619
commit b7ce1b8924

@ -29,8 +29,6 @@ public interface CityPartnerPrizeService {
List<JSONObject> getReferrerPrizeInfoList(String monthStr);
void generateAgent(String month,int orgId);
List<JSONObject> listAgentAvailableMonths(String year);
JSONObject getAgentPrizeInfo(String monthStr);

@ -69,6 +69,7 @@ public class CityPartnerPrizeController {
BigDecimal royalpayCharge = BigDecimal.ZERO;
BigDecimal orgCharge = BigDecimal.ZERO;
BigDecimal netCharge = BigDecimal.ZERO;
BigDecimal shareCharge = BigDecimal.ZERO;
String cityPartnerName = "";
int org_id = 0;
int type = 1;
@ -76,6 +77,7 @@ public class CityPartnerPrizeController {
grossAmount = grossAmount.add(jsonObject.getBigDecimal("gross_amount"));
totalCharge = totalCharge.add(jsonObject.getBigDecimal("total_charge"));
royalpayCharge = royalpayCharge.add(jsonObject.getBigDecimal("royalpay_charge"));
shareCharge = shareCharge.add(jsonObject.getBigDecimal("share_charge"));
orgCharge = orgCharge.add(jsonObject.getBigDecimal("org_charge"));
if (jsonObject.getBigDecimal("net_charge") != null) {
netCharge = netCharge.add(jsonObject.getBigDecimal("net_charge"));
@ -84,10 +86,14 @@ public class CityPartnerPrizeController {
cityPartnerName = jsonObject.getString("name");
type = jsonObject.getIntValue("commission_type");
}
if (entry.getValue().get(0).get("parent_org_id") != null) {
sumResult.put("org_type", "agent");
}
sumResult.put("gross_amount", grossAmount);
sumResult.put("total_charge", totalCharge);
sumResult.put("royalpay_charge", royalpayCharge);
sumResult.put("org_charge", orgCharge);
sumResult.put("share_charge", shareCharge);
sumResult.put("org_name", cityPartnerName);
sumResult.put("org_id", org_id);
sumResult.put("net_charge", netCharge);
@ -95,7 +101,13 @@ public class CityPartnerPrizeController {
sumResult.put("channel_detail", entry.getValue());
resultTotalCharge = resultTotalCharge.add(totalCharge);
resultRoyalpayCharge = resultRoyalpayCharge.add(royalpayCharge);
if ("agent".equals(sumResult.getString("org_type"))) {
resultRoyalpayCharge = resultRoyalpayCharge.add(shareCharge);
}
resultOrgCharge = resultOrgCharge.add(orgCharge);
if (!"agent".equals(sumResult.getString("org_type"))) {
resultOrgCharge = resultOrgCharge.add(shareCharge);
}
resultNetCharge = resultNetCharge.add(netCharge);
partnerInfos.add(sumResult);
}

@ -27,5 +27,6 @@ public interface FinancialAgentCommissionMapper {
List<JSONObject> list(@Param("year") int year, @Param("month") int month);
String getRecordId(@Param("org_id") int orgId, @Param("year") int year, @Param("month") int month, @Param("channel") String channel);
}

@ -104,6 +104,9 @@ public interface TransactionMapper {
BigDecimal TotalAmountForBDLeaderPrize(@Param("year") int year, @Param("month") int month, @Param("bd_group") String bd_group);
BigDecimal TotalAmountForSydneyGMPrize(@Param("year") int year, @Param("month") int month);
List<JSONObject> listTransactionForCityPartnerCommissionByDate(@Param("year") int year, @Param("month") int month);
List<JSONObject> listTransactionForCityPartnerAgentCommissionByDate(@Param("year") int year, @Param("month") int month);
List<JSONObject> listTransactionsForCityPartnerCommission(@Param("year") int year, @Param("month") int month);

@ -23,4 +23,10 @@
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>
<select id="getRecordId" resultType="java.lang.String">
SELECT
c.record_id
FROM financial_agent_commission c
WHERE c.org_id = #{org_id} AND c.year = #{year} AND c.month = #{month} AND c.channel = #{channel}
</select>
</mapper>

@ -58,7 +58,19 @@
</foreach>)
</select>
<select id="getRecordId" resultType="java.lang.String">
SELECT
c.record_id
FROM financial_partner_commission c
WHERE c.org_id = #{org_id} AND c.year = #{year} AND c.month = #{month} AND c.channel = #{channel}
</select>
<select id="findByChanel" resultType="com.alibaba.fastjson.JSONObject">
SELECT
*
FROM financial_partner_commission
WHERE year = #{year} AND month = #{month} and org_id=#{org_id} and channel=#{channel}
</select>
<select id="getClientExtractRecord" resultType="com.alibaba.fastjson.JSONObject">
SELECT

@ -662,7 +662,36 @@ select sum(if(temp.transaction_type='Credit',temp.clearing_amount*d.proportion,
]]>
</select>
<select id="listTransactionForCityPartnerCommissionByDate" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
select t.org_id,t.clearing_currency,t.client_id,t.channel,t.surcharge_rate,t.transaction_time,if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount) clearing_amount,
if(t.transaction_type = 'Credit', t.total_surcharge, -t.total_surcharge) total_surcharge,
if(t.transaction_type = 'Credit', t.channel_surcharge, -t.channel_surcharge) channel_surcharge,
t.order_id
from pmt_transactions t INNER JOIN sys_org so ON t.org_id = so.org_id AND so.is_valid = 1
AND so.type=0
AND so.citypartner = 1 AND so.commission = 1
AND year(t.transaction_time) = #{year} AND month(t.transaction_time) = #{month}
AND t.channel != 'Settlement' AND t.channel!='System'
ORDER BY t.client_id asc
]]>
</select>
<select id="listTransactionForCityPartnerAgentCommissionByDate" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
select t.org_id,t.client_id,t.channel,t.surcharge_rate,t.transaction_time,if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount) clearing_amount,
if(t.transaction_type = 'Credit', t.total_surcharge, -t.total_surcharge) total_surcharge,
if(t.transaction_type = 'Credit', t.channel_surcharge, -t.channel_surcharge) channel_surcharge,
t.order_id
from pmt_transactions t INNER JOIN sys_org so ON t.org_id = so.org_id AND so.is_valid = 1
AND so.type=0
AND so.parent_org_id !=''
AND so.citypartner = 1 AND so.commission = 1
AND year(t.transaction_time) = #{year} AND month(t.transaction_time) = #{month}
AND t.channel != 'Settlement' AND t.channel!='System'
ORDER BY t.client_id asc
]]>
</select>
<select id="listTransactionsForReferrerCommission" resultType="com.alibaba.fastjson.JSONObject">
SELECT
sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount))

@ -583,6 +583,11 @@ margin-bottom: 10%;"/>
<i class="fa fa-users"></i> <span>合伙人提成</span>
</a>
</li>
<li ui-sref-active="active" ng-if="('orgcommission'|withModule)">
<a ui-sref="analysis_org.info" ui-sref-opts="{reload:true}">
<i class="fa fa-hand-peace-o"></i> <span>合伙人提成计算说明</span>
</a>
</li>
<li ui-sref-active="active" ng-if="('cashbackAnalysis'|withModule)">
<a ui-sref="cashbackAnalysis">
<i class="fa fa-gift"></i> <span>商户营销账户</span>
@ -813,6 +818,11 @@ margin-bottom: 10%;"/>
<i class="fa fa-hand-peace-o"></i> <span>合伙人提成</span>
</a>
</li>
<li ui-sref-active="active" ng-if="('orgcommission'|withModule)">
<a ui-sref="analysis_org.info" ui-sref-opts="{reload:true}">
<i class="fa fa-hand-peace-o"></i> <span>合伙人提成计算说明</span>
</a>
</li>
</ul>
</li>

@ -26,6 +26,10 @@ define(['angular','../../analysis/org/analysis-org'], function (angular) {
url: '/commissionorg/months/{monthStr}',
templateUrl: '/static/config/orgcommission/templates/org_commission_month_root.html',
controller: 'commissionMonthRootCtrl'
}).state('analysis_org.info', {
url: '/commissionorg/info',
templateUrl: '/static/config/orgcommission/templates/org_commission_info.html',
controller: 'commissionMonthRootCtrl'
}).state('analysis_org.commission.month.org', {
url: '/org',
templateUrl: '/static/config/orgcommission/templates/org_commission_month.html',

@ -0,0 +1,33 @@
<div ui-view>
<section class="content">
<div class="box box-info">
<div class="box-body">
<h4>合伙人提成计算说明</h4>
<ul>
<li>2018-11-30更新</li>
<li>合伙人提成算法:按照合伙人签约的商户下每笔订单计算合伙人提成,提成规则明细如下: &nbsp&nbsp
<span style="color:red">(取整规则为四舍五入保留2位小数)</span>
</li>
<li>单笔订单 :&nbsp&nbsp(单笔订单交易金额 * 商家签约费率)<span style="font-size: 1px;color:red">取整</span> &nbsp&nbsp&nbsp - &nbsp&nbsp单笔订单交易金额 * 组织成本费率)<span style="font-size: 1px;color:red">取整</span> &nbsp&nbsp&nbsp
= &nbsp&nbsp&nbsp单笔订单合伙人提成</li>
<li>总交易额 : &nbsp合伙人签约的商户累计交易额</li>
<li>平台手续费:合伙人签约的商户(单笔订单交易金额 * 组织成本费率)<span style="font-size: 1px;color:red">取整</span> 累加</li>
<li>合伙人提成: 每笔订单合伙人提成累加</li>
<li>·······························································································································································</li>
<li>如合伙人存在二级代理,可从二级代理的交易额中得到分润,分润规则如下:</li>
<li>二级代理合伙人提成计算规则如同一级代理,分润从平台手续费中扣除。</li>
<li>如A合伙人与平台签约组织成本费率为1.5%A合伙人的二级代理B的签约组织成本费率为1.8%B的商户签约费率为3%</li>
<li>假设B当月只有一笔交易且交易额为1000总手续费为30平台手续费为18B合伙人提成为12。</li>
<li>计算A的分润时会将B的交易额1000 * A的组织成本费率 1.5% = 15A的分润就是 18-15=3而B合伙人平台手续费为15其中扣除3是A的分润</li>
</ul>
<h4>补充说明</h4>
<ul style="color:red">
<li >退款成功的订单不计入合伙人提成内</li>
<li>当本月有合伙人手续费存在欠款时,无法下载汇款文件</li>
</ul>
</div>
</div>
</section>
</div>

@ -33,18 +33,51 @@
<th>RoyalPay Charge</th>
<th>Net Charge</th>
<th>City Partner Charge</th>
<th>Share Charge</th>
<th>Type</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.total_charge|currency:'AUD'"></td>
<td ng-bind="log.royalpay_charge|currency:'AUD'"></td>
<td ng-bind="log.net_charge|currency:'AUD'"></td>
<td ng-bind="log.org_charge|currency:'AUD'"></td>
<td>
{{log.org_name}}
<span ng-if="log.org_type=='agent'">(二级代理)</span>
<span ng-if="log.org_type==null">(一级代理)</span>
</td>
<td ng-bind="log.gross_amount"></td>
<td ng-bind="log.total_charge"></td>
<td ng-if="log.org_type == 'agent' && log.share_charge!=0">
<span >
{{(log.royalpay_charge+log.share_charge)}}
</span>
<span style="color: red;font-size: 6px" >
({{log.royalpay_charge}}
</span>
<span style="color: red;font-size: 6px" ng-if="log.share_charge > 0 "> + </span>
<span style="color: red;font-size: 6px">
{{log.share_charge}})
</span>
</td>
<td ng-if="log.org_type != 'agent' || log.share_charge==0" ng-bind="log.royalpay_charge" ></td>
<td ng-bind="log.net_charge"></td>
<td ng-if="log.org_type==null && log.share_charge !=0">
<span>
{{(log.org_charge+log.share_charge)}}
</span>
<span style="color: red;font-size: 6px">
({{log.org_charge}}
</span>
<span style="color: red;font-size: 6px" ng-if="log.share_charge >= 0"> + </span>
<span style="color: red;font-size: 6px">
{{log.share_charge}})
</span>
</td>
<td ng-if="log.org_type=='agent' || log.share_charge ==0">
{{log.org_charge}}
</td>
<td ng-bind="log.share_charge"></td>
<td ng-bind="log.type|commission_type_filter"></td>
<td>
<a ui-sref=".orgdetail({orgId:log.org_id})">
@ -66,6 +99,7 @@
<th>RoyalPay Charge</th>
<th>Net Charge</th>
<th>City Partner Charge</th>
<th>Share Charge</th>
<th>channel</th>
</tr>
</thead>
@ -77,6 +111,7 @@
<td ng-bind="detail.royalpay_charge"></td>
<td ng-bind="detail.net_charge"></td>
<td ng-bind="detail.org_charge"></td>
<td ng-bind="detail.share_charge"></td>
<td ng-bind="detail.channel"></td>
</tr>
</tbody>

@ -435,6 +435,16 @@
</div>
</a>
</div>
<div ng-if="('orgcommission'|withModule)" class="col-sm-2 col-xs-6">
<a ui-sref="analysis_org.info" ui-sref-opts="{reload:true}">
<div class="description-block">
<img src="/static/images/main_menu/partner_commission.png"/>
<div class="description-text">
<span class="description-text">合伙人提成计算说明</span>
</div>
</div>
</a>
</div>
<!--
<div ng-if="('citypartner'|withModule)" class="col-sm-2 col-xs-6">
<a ui-sref="citypartner_reg" ui-sref-opts="{reload:true}">
@ -762,6 +772,15 @@
</div>
</div>
</a></div>
<div class="col-sm-2 col-xs-6">
<a ui-sref="analysis_org.info" ui-sref-opts="{reload:true}">
<div class="description-block">
<img src="/static/images/main_menu/finance_partner_contribution.png"/>
<div class="description-text">
<span class="description-text">合伙人提成计算说明</span>
</div>
</div>
</a></div>
<div ng-if="'cashbackAnalysis'|withModule" class="col-sm-2 col-xs-6">
<a ui-sref="cashbackAnalysis" ui-sref-opts="{reload:true}">
<div class="description-block">

@ -22,7 +22,6 @@ public class CityPartnerPrizeServiceImplTest {
private CityPartnerPrizeService cityPartnerPrizeService;
@Test
public void generateAgent() throws Exception {
cityPartnerPrizeService.generateAgent("2017-06",9);
}
@Test

Loading…
Cancel
Save