Merge branch 'develop'

master
taylor.dang 6 years ago
commit 562b713a33

@ -1,11 +1,11 @@
package au.com.royalpay.payment.manage.mappers.system;
import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import org.joda.time.DateTime;
import java.util.Date;
import java.util.List;
@ -22,4 +22,6 @@ public interface ClearingDistributedSurchargeMapper {
List<JSONObject> getMonthDetailByClientId(@Param("datefrom") Date datefrom, @Param("dateto") Date dateto);
List<JSONObject> findTransactionsByDate(JSONObject params);
List<JSONObject> listUnClearedByMonth(@Param("dateto") DateTime dateTo);
}

@ -6,7 +6,6 @@ import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;

@ -11,7 +11,7 @@ import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.lock.Locker;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@ -19,13 +19,14 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class SurchargeAccountServiceImpl implements SurchargeAccountService{
public class SurchargeAccountServiceImpl implements SurchargeAccountService {
@Resource
private ClearingDistributedSurchargeMapper clearingDistributedSurchargeMapper;
@ -41,28 +42,45 @@ public class SurchargeAccountServiceImpl implements SurchargeAccountService{
@Override
@Transactional
public void generatorMonthDetail(){
Calendar monthCal = Calendar.getInstance();
monthCal.setTime(new Date());
monthCal.set(Calendar.DAY_OF_MONTH, 1);
monthCal.set(Calendar.HOUR_OF_DAY, 0);
monthCal.set(Calendar.MINUTE, 0);
monthCal.set(Calendar.SECOND, 0);
Date dateto = monthCal.getTime();
monthCal.set(Calendar.MONTH, (monthCal.get(Calendar.MONTH) - 1));
Date datefrom = monthCal.getTime();
logger.info("===============Start generator surcharge account month detail===============" + new Date());
List<JSONObject> thisMonthDetail = clearingDistributedSurchargeMapper.getMonthDetailByClientId(datefrom, dateto);
logger.info("this month details : " + thisMonthDetail.toString());
for (JSONObject detail : thisMonthDetail) {
public void generatorMonthDetail() {
DateTime dateTo = DateTime.now().withMillisOfDay(0).withDayOfMonth(1);
logger.info("===============Start generator surcharge account month detail==============={}", new Date());
List<JSONObject> surchargeTransactions = clearingDistributedSurchargeMapper.listUnClearedByMonth(dateTo);
Map<Integer, List<JSONObject>> clientsDistributed = surchargeTransactions.stream().collect(Collectors.groupingBy(trans -> trans.getInteger("client_id")));
for (Map.Entry<Integer, List<JSONObject>> clientEntry : clientsDistributed.entrySet()) {
int clientId = clientEntry.getKey();
List<JSONObject> surchargeTrans = clientEntry.getValue();
surchargeTrans.sort(Comparator.comparing(trans -> trans.getDate("create_time")));
JSONObject detail = new JSONObject();
detail.put("client_id", clientId);
detail.put("settle_month", dateTo.toString("yyyy-MM"));
BigDecimal creditAmount = surchargeTrans.stream()
.filter(trans -> "Credit".equals(trans.getString("type")))
.map(trans -> trans.getBigDecimal("amount"))
.reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
BigDecimal debitAmount = surchargeTrans.stream()
.filter(trans -> "Debit".equals(trans.getString("type")))
.map(trans -> trans.getBigDecimal("amount"))
.reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
detail.put("credit_amount", creditAmount);
detail.put("debit_amount", debitAmount);
JSONObject lastTrans = surchargeTrans.stream().max(Comparator.comparing(trans -> trans.getDate("create_time")))
.orElse(null);
BigDecimal postBalance;
if (lastTrans == null) {
JSONObject account = clientsSurchargeAccountsMapper.find(clientId);
postBalance = account == null ? BigDecimal.ZERO : account.getBigDecimal("balance");
} else {
postBalance = lastTrans.getBigDecimal("post_balance");
}
detail.put("post_balance", postBalance);
detail.put("send_mail", 0);
detail.put("wx_send", 0);
detail.put("settle_month", DateFormatUtils.format(datefrom, "yyyy-MM"));
detail.put("create_time", new Date());
detail.put("is_valid", 0);
financialSurchargeAccountDetailMapper.save(detail);
}
logger.info("===============generator OVER===============" + new Date());
logger.info("===============generator OVER==============={}", new Date());
}
@Override
@ -88,12 +106,12 @@ public class SurchargeAccountServiceImpl implements SurchargeAccountService{
transaction.put("client_id", detail.getIntValue("client_id"));
transaction.put("type", "Credit");
transaction.put("total_surcharge", BigDecimal.ZERO);
transaction.put("tax_amount", BigDecimal.ZERO);
transaction.put("amount", detail.getBigDecimal("debit_amount").negate());
transaction.put("post_balance", surcharge_account.getBigDecimal("balance").add(transaction.getBigDecimal("amount")));
transaction.put("operation", manager.getString("manager_id"));
transaction.put("create_time", new Date());
transaction.put("remark", detail.getString("settle_month")+"冲正");
transaction.put("tax_amount", BigDecimal.ZERO);
transaction.put("amount", detail.getBigDecimal("debit_amount").negate());
transaction.put("post_balance", surcharge_account.getBigDecimal("balance").add(transaction.getBigDecimal("amount")));
transaction.put("operation", manager.getString("manager_id"));
transaction.put("create_time", new Date());
transaction.put("remark", detail.getString("settle_month") + "冲正");
clearingDistributedSurchargeMapper.save(transaction);
surcharge_account.put("balance", surcharge_account.getBigDecimal("balance").add(transaction.getBigDecimal("amount")));

@ -75,17 +75,14 @@ public class RefundServiceImpl implements RefundService, ApplicationEventPublish
@Override
public JSONObject checkOrderRefundAmount(String orderId, JSONObject account) {
JSONObject order = orderMapper.getOrderDetail(orderId);
if (account != null) {
if (account != null && (account.getIntValue("client_id") != order.getIntValue("client_id"))) {
JSONObject client = clientMapper.findClient(account.getIntValue("client_id"));
////父商户全局管理子商户时候,跳过
if (account.getIntValue("client_id") != order.getIntValue("client_id")) {
JSONObject clientOrder = clientMapper.findClient(order.getIntValue("client_id"));
if(!(client.getBoolean("sub_manage") &&
clientOrder.containsKey("parent_client_id")?clientOrder.getIntValue("parent_client_id")==client.getIntValue("client_id"):false)){
throw new ForbiddenException("Order is not belong to your shop/merchant");
}
JSONObject orderTargetClient = clientMapper.findClient(order.getIntValue("client_id"));
if (orderTargetClient.getIntValue("parent_client_id") != account.getIntValue("client_id")) {
throw new ForbiddenException("Order is not belong to your shop/merchant");
} else if (!client.getBooleanValue("sub_manage")) {
throw new ForbiddenException("Order is not belong to your shop/merchant");
}
}
Assert.notNull(order, "Order Not Exists");

@ -130,6 +130,12 @@ settle.abafile.bank.ANZ.bsb=013006
settle.abafile.bank.ANZ.account-no=837022519
settle.abafile.bank.ANZ.account-name=Tunnel Show Pty Ltd
settle.abafile.bank.NAB.manual-sending=true
settle.abafile.bank.NAB.bank=NAB
settle.abafile.bank.NAB.apca=514624
settle.abafile.bank.NAB.bsb=013006
settle.abafile.bank.NAB.account-no=837022519
settle.abafile.bank.NAB.account-name=Tunnel Show Pty Ltd
# 瀚银Secure
app.hanyin-secure.pid=ROYALPAY

@ -3,31 +3,47 @@
<mapper namespace="au.com.royalpay.payment.manage.mappers.system.ClearingDistributedSurchargeMapper">
<select id="getMonthDetailByClientId" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT d.client_id,c.client_moniker,c.company_name,
SUM(IF(d.type='Debit',total_surcharge,-total_surcharge)) total_surcharge,
SUM(IF(d.type='Credit',amount,0)) credit_amount,
SUM(IF(d.type='Debit',amount,0)) debit_amount,
SUM(IF(d.type='Debit',total_surcharge,0)) total_surcharge
FROM log_clearing_distributed_surcharge d INNER JOIN sys_clients c ON c.client_id=d.client_id
WHERE d.create_time >=#{datefrom} AND d.create_time < #{dateto}
AND c.is_valid= 1
SELECT d.client_id,
c.client_moniker,
c.company_name,
SUM(IF(d.type = 'Debit', total_surcharge, -total_surcharge)) total_surcharge,
SUM(IF(d.type = 'Credit', amount, 0)) credit_amount,
SUM(IF(d.type = 'Debit', amount, 0)) debit_amount,
SUM(IF(d.type = 'Debit', total_surcharge, 0)) total_surcharge
FROM log_clearing_distributed_surcharge d
INNER JOIN sys_clients c ON c.client_id = d.client_id
WHERE d.create_time >= #{datefrom}
AND d.create_time < #{dateto}
AND c.is_valid = 1
GROUP BY d.client_id
]]>
</select>
<select id="findTransactions" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT * FROM log_clearing_distributed_surcharge WHERE client_id = #{client_id}
SELECT *
FROM log_clearing_distributed_surcharge
WHERE client_id = #{client_id}
ORDER BY create_time DESC
]]>
</select>
<select id="findTransactionsByDate" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT * FROM log_clearing_distributed_surcharge WHERE client_id = #{client_id}
AND year(create_time) = #{year}
AND month(create_time) = #{month}
SELECT *
FROM log_clearing_distributed_surcharge
WHERE client_id = #{client_id}
AND year(create_time) = #{year}
AND month(create_time) = #{month}
ORDER BY create_time DESC
]]>
</select>
<select id="listUnClearedByMonth" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
select d.*
from log_clearing_distributed_surcharge d
where d.bill_id is null
and d.create_time < #{dateto}
]]>
</select>
</mapper>

@ -778,7 +778,7 @@ margin-bottom: 10%;"/>
</li>
<li ui-sref-active="active" ng-if="('bdprize'|withModule)&&(currentUser.org_id==null||currentUser.org_id==1)">
<a ui-sref="analysis_bd.bd_data_analysis" ui-sref-opts="{reload:true}">
<i class="fa fa-usd"></i> <span>BD数据分析|BD Data Analysis</span>
<i class="fa fa-usd"></i> <span>BD团队分析|BD Team Analysis</span>
</a>
</li>
<li ui-sref-active="active" ng-if="'10000000001000'|withRole">

@ -59,7 +59,7 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
$scope.getBDTeamKpiEcharts = function(data){
var BDTeamKpi = {
tooltip : {
formatter: "{a} <br/>{c} {b}"
formatter: "{b} <br/> {a} {c}% "
},
toolbox: {
show : true,
@ -106,7 +106,7 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
fontWeight: 'bolder'
}
},
data:[{value: 0, name: '完成度'}]
data:[{value: 0, name: ''}]
},
{
name:'KPI',
@ -267,7 +267,7 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
},
series : [
{
name:'业务指标',
name:'KPI完成比例',
type:'gauge',
startAngle: 180,
endAngle: 0,
@ -327,17 +327,17 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
}
]
};
bdKpi.series[0].data[0] = {"value":(data.total_amount/data.kpi_amount*100).toFixed(2),"name":data.bd_name + "完成度"};
bdKpi.series[0].data[0] = {"value":(data.total_amount/data.kpi_amount*100).toFixed(2),"name":data.bd_name};
return bdKpi;
}
$scope.filterBdType = function (type) {
switch (type) {
case 1:
return 'Sydney';
return 'Sydney Team';
case 2:
return 'KA Manager';
case 6:
return 'Melbourne';
return 'Melbourne Team';
case 7:
return 'KA Manager';
}

@ -31,16 +31,21 @@
ng-class="{nodata:!BDTeamKpiData}"></div>
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<td>teamName</td>
<td>kpiAmount</td>
<td>totalAmount</td>
</tr>
<tr>
<th>团队名称<span class="text-green small">(点击可查看团队明细)</span></th>
<th>KPI</th>
<th>总金额</th>
<th>完成比例</th>
</tr>
</thead>
<tr ng-repeat="data in BDTeamKpiData">
<td ng-bind="data.team_name"></td>
<tr ng-repeat="data in BDTeamKpiData" ng-click="getBdProportion(data.bd_type)"
style="cursor:pointer;">
<td ng-bind="data.team_name" ></td>
<td ng-bind="data.kpi"></td>
<td ng-bind="data.total_amount"></td>
<td>{{data.total_amount/data.kpi | percentage:2}} <i ng-if="(data.total_amount/data.kpi)>=1"
class="fa fa-star text-yellow"
title="已完成"></i></td>
</tr>
</table>
</div>
@ -48,30 +53,36 @@
<div class="box box-info">
<div class="box-header">BD占比</div>
<div class="box-body">
<div class="chart" style="height: 400px" id="bdProportion" echarts="bdProportion"
chart-setter="bdProportionEcharts($chart)"
ng-class="{nodata:!bdProportionData}"></div>
<div class="col-xs-6 col-sm-6">
<div class="chart" style="height: 400px" id="bdProportion" echarts="bdProportion"
chart-setter="bdProportionEcharts($chart)"
ng-class="{nodata:!bdProportionData}"></div>
</div>
<div class=" col-xs-6 col-sm-6">
<div class="chart" style="height: 400px" id="bdKpi" echarts="bdKpi"
ng-class="{nodata:!bdKpiData}"></div>
</div>
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<td>bdName</td>
<td>kpiAmount</td>
<td>totalAmount</td>
<th>BD 名称</th>
<th>KPI</th>
<th>总交易金额</th>
<th>完成比例</th>
</tr>
</thead>
<tr ng-repeat="data in bdProportionData">
<td ng-bind="data.bd_name"></td>
<td ng-bind="data.kpi_amount"></td>
<td ng-bind="data.total_amount"></td>
<td>{{data.total_amount/data.kpi_amount | percentage:2}}
<i ng-if="(data.total_amount/data.kpi_amount)>=1" class="fa fa-star text-yellow"
title="已完成"></i>
</td>
</tr>
</table>
</div>
</div>
<div class="box box-info">
<div class="box-header">BD KPI完成度</div>
<div class="box-body">
<div class="chart" style="height: 400px" id="bdKpi" echarts="bdKpi"
ng-class="{nodata:!bdKpiData}"></div>
</div>
</div>
</section>

@ -489,6 +489,16 @@
</div>
</a>
</div>
<div ng-if="('bdprize'|withModule)&&(currentUser.org_id==null||currentUser.org_id==1)" class="col-sm-2 col-xs-6">
<a ui-sref="analysis_bd.bd_data_analysis" ui-sref-opts="{reload:true}">
<div class="description-block">
<img src="/static/images/main_menu/bd_sales_volume.png"/>
<div class="description-text">
<span class="description-text">BD团队分析</span>
</div>
</div>
</a>
</div>
<div ng-if="('bdprize'|withModule)&&(currentUser.org_id==null||currentUser.org_id==1)" class="col-sm-2 col-xs-6">
<a ui-sref="analysis_bd.bd_prizes" ui-sref-opts="{reload:true}">
<div class="description-block">

@ -2115,6 +2115,34 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
};
$scope.loadSubClients();
$scope.loadPartnerPaymentInfo = function () {
$http.get('/sys/partners/' + $scope.partner.client_moniker).then(function (resp) {
$scope.paymentInfo = resp.data;
})
};
$scope.loadPartnerPaymentInfo();
$scope.switchSubManage = function () {
if (!$scope.paymentInfo) {
return;
}
if (!$scope.init.sub_manage) {
$scope.init.sub_manage = true;
return;
}
$http.put('/sys/partners/' + $scope.partner.client_moniker + '/sub_manage', {allow: $scope.paymentInfo.sub_manage}).then(function () {
//$scope.loadPartnerPaymentInfo();
}, function (resp) {
commonDialog.alert({
title: 'Failed to change Sub Partners Manage status',
content: resp.data.message,
type: 'error'
})
})
};
}]);
app.controller('partnerRatesCtrl', ['$scope', '$rootScope', '$http', '$uibModal', 'commonDialog','$sce', function ($scope, $rootScope, $http, $uibModal, commonDialog,$sce) {
$scope.bankCtrl = {edit: true, rate_name: 'Wechat'};

@ -184,12 +184,12 @@
</div>
</div>
</div>
<div class="form-group" ng-if="('10'|withRole) && partner.parent_client_id==null">
<label class="col-sm-3 control-label">Sub Partners Manage</label>
<div class="col-xs-9">
<input type="checkbox" ng-model="paymentInfo.sub_manage" bs-switch switch-change="switchSubManage()">
</div>
</div>
<!--<div class="form-group" ng-if="('10'|withRole) && partner.parent_client_id==null">-->
<!--<label class="col-sm-3 control-label">Sub Partners Manage</label>-->
<!--<div class="col-xs-9" title="开启后,父商户具有帮子商户新建账户、退款等管理权限">-->
<!--<input type="checkbox" ng-model="paymentInfo.sub_manage" bs-switch switch-change="switchSubManage()">-->
<!--</div>-->
<!--</div>-->
</div>
</div>
</div>

@ -1,9 +1,17 @@
<div class="panel panel-default" ng-if="'111'|withRole">
<div class="panel-body" ng-if="('10'|withRole) && partner.parent_client_id==null">
<div class="panel-body" title="开启后,父商户具有帮子商户新建账户、退款等管理权限">
Sub Partners Manage <input type="checkbox" ng-model="paymentInfo.sub_manage" bs-switch switch-change="switchSubManage()">
</div>
</div>
<div class="panel-body">
<button class="btn btn-primary" type="button" ng-click="newSubClient()">
<i class="fa fa-plus"></i> New Sub Partner
</button>
</div>
</div>
<div class="row">
<div class="col-sm-12 table-responsive">

Loading…
Cancel
Save