[Y] 优化通用商户号查询

master
taylor.dang 6 years ago
parent 29500e60a7
commit 7af0564814

@ -62,8 +62,8 @@ public class MerchantIdManageServiceImpl implements MerchantIdManageService {
@Override @Override
public Map<String, List<JSONObject>> listSubMerchantId(JSONObject manager) { public Map<String, List<JSONObject>> listSubMerchantId(JSONObject manager) {
List<JSONObject> clients = clientMapper.listSubMerchantId(); List<JSONObject> clients = clientMapper.listSubMerchantId();
return getClientMap(clients); return getClientMap(clients);
} }
@Override @Override
public JSONObject listNotTradeSubMerchantId(JSONObject manager) { public JSONObject listNotTradeSubMerchantId(JSONObject manager) {
@ -139,7 +139,10 @@ public class MerchantIdManageServiceImpl implements MerchantIdManageService {
client.put("temp_sub_merchant", true); client.put("temp_sub_merchant", true);
} }
} }
Map<String, List<JSONObject>> clientsMap = clients.stream().filter(t->t.containsKey("merchant_id")).filter(t->t.containsKey("sub_merchant_id")).collect(Collectors.groupingBy(t->t.getString("merchant_id"))); Map<String, List<JSONObject>> clientsMap = clients.stream()
.filter(t->t.containsKey("merchant_id"))
.filter(t->t.containsKey("sub_merchant_id"))
.collect(Collectors.groupingBy(t->t.getString("merchant_id")));
return clientsMap; return clientsMap;
} }

@ -17,19 +17,61 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS
}) })
}]); }]);
app.controller('merchantIdManageCtrl', ['$scope', '$state', '$http', function ($scope, $state, $http) { app.controller('merchantIdManageCtrl', ['$scope', '$state', '$http', function ($scope, $state, $http) {
$scope.isCollapsed = true; $scope.isCollapsed = true;
$scope.toShow = false; $scope.toShow = false;
$scope.client_loading = true; $scope.client_loading = true;
$scope.loadClient = function () { // 前端渲染的end索引
$scope.endIndexMap = {};
// 初始化索引是60
const initEndIndex = 60;
$scope.loadClient = function () {
$http.get('/sys/merchant_id').then(function (resp) { $http.get('/sys/merchant_id').then(function (resp) {
$scope.clientsMap = resp.data; $scope.clientsMap = resp.data;
$scope.client_loading = false; $scope.client_loading = false;
// 加入对应项的end索引值
// 如果数据小于60索引值为数据长度
// 否则设置为60
for (var key in $scope.clientsMap) {
$scope.endIndexMap[key] = initEndIndex;
var length = $scope.clientsMap[key].length;
if (length <= initEndIndex)
$scope.endIndexMap[key] = length;
}
}); });
}; };
$scope.loadClient(); $scope.loadClient();
/**
* 点击更多加载
* 判断加60后的索引是否超出数组长度
* @param key
*/
$scope.more = function(key) {
var endIndex = $scope.endIndexMap[key] + initEndIndex;
$scope.endIndexMap[key] = endIndex;
if (endIndex > $scope.clientsMap[key].length) {
$scope.endIndexMap[key] = $scope.clientsMap[key].length;
}
$scope.showClient = function (sub_merchant_id) { };
/**
* 收起
* @param key
*/
$scope.packup = function(key) {
$scope.endIndexMap[key] = initEndIndex;
var length = $scope.clientsMap[key].length;
if (length <= initEndIndex)
$scope.endIndexMap[key] = length;
};
$scope.showClient = function (sub_merchant_id) {
if($scope.sub_merchant_id == sub_merchant_id){ if($scope.sub_merchant_id == sub_merchant_id){
return; return;
} }
@ -38,6 +80,7 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS
$scope.sub_merchant_id = sub_merchant_id; $scope.sub_merchant_id = sub_merchant_id;
}); });
}; };
}]); }]);
app.controller('noTradeSubMerchantIdCtrl', ['$scope', '$state', '$http','$uibModal', function ($scope, $state, $http,$uibModal) { app.controller('noTradeSubMerchantIdCtrl', ['$scope', '$state', '$http','$uibModal', function ($scope, $state, $http,$uibModal) {
$scope.pagination = {}; $scope.pagination = {};

@ -78,44 +78,53 @@
<loadingbar ng-if="client_loading"></loadingbar> <loadingbar ng-if="client_loading"></loadingbar>
<div class="col-sm-12 col-xs-12"> <div class="col-sm-12 col-xs-12">
<div style="margin-top: 5px"> <div style="margin-top: 5px">
<div class="list-group col-sm-12 col-xs-12" ng-repeat="(key,clients) in clientsMap"> <div class="list-group col-sm-12 col-xs-12"
ng-repeat="(key, clients) in clientsMap">
<a class="list-group-item active col-sm-12 col-xs-12"> <a class="list-group-item active col-sm-12 col-xs-12">
{{key|choose_merchant_id}} {{key|choose_merchant_id}}
<!--为了页面的优化,注释此段代码,其下亦是如此
<span ng-show="clients.length>59" class="small-box-footer cursor pull-right" <span ng-show="clients.length>59" class="small-box-footer cursor pull-right"
ng-click="isCollapsed = !isCollapsed"><span ng-click="isCollapsed = !isCollapsed"><span
ng-if="clients.length>59">更多 <i class="fa fa-arrow-circle-right" ng-if="clients.length>59">更多 <i class="fa fa-arrow-circle-right"
ng-class="{'i-rotate_90':!isCollapsed}"></i></span></span> ng-class="{'i-rotate_90':!isCollapsed}"></i></span></span>
-->
</a> </a>
<a class="list-group-item col-sm-2 col-xs-6 cursor" <a class="list-group-item col-sm-2 col-xs-6 cursor"
ng-repeat="client in clients | orderBy:'client_count':true" ng-repeat="client in clients.slice(0, endIndexMap[key]) | orderBy:'client_count':true"
ng-click="showClient(client.sub_merchant_id);toShow=!toShow" ng-if="$index<60"> ng-click="showClient(client.sub_merchant_id); toShow = !toShow">
<span> <span>
{{client.sub_merchant_id}}&nbsp;<i class="fa fa-clock-o text-danger" {{client.sub_merchant_id}}&nbsp;
title="Using temp Sub Merchant ID" <i class="fa fa-clock-o text-danger"
ng-if="client.temp_sub_merchant"></i></span> title="Using temp Sub Merchant ID"
ng-if="client.temp_sub_merchant">
</i>
</span>
<span class="badge pull-right position_re"> <span class="badge pull-right position_re">
{{client.client_count}} {{client.client_count}}
<div ng-if="sub_merchant_id==client.sub_merchant_id&&toShow" class="popover fade in position_ab" <div ng-if="sub_merchant_id==client.sub_merchant_id&&toShow"
class="popover fade in position_ab"
role="tooltip" style="display: block;"> role="tooltip" style="display: block;">
<div class="arrow"></div> <div class="arrow"></div>
<h3 class="popover-title popover-color">Clients</h3> <h3 class="popover-title popover-color">Clients</h3>
<div class="popover-content" style="width: 250px"> <div class="popover-content" style="width: 250px">
<button type="button" class="btn btn-link" <button type="button" class="btn btn-link"
ng-repeat="client_moniker in client_monikers" ng-repeat="client_moniker in client_monikers"
ng-show="$index<client_monikers.length-1" ng-show="$index<client_monikers.length-1"
ui-sref="partners.detail({clientMoniker:client_moniker.client_moniker})"> ui-sref="partners.detail({clientMoniker:client_moniker.client_moniker})">
{{client_moniker.client_moniker}}<span class="text-black">,</span>&nbsp; {{client_moniker.client_moniker}}
</button> <span class="text-black">,</span>&nbsp;
<button type="button" class="btn btn-link" </button>
ng-repeat="client_moniker in client_monikers" ng-if="$last" <button type="button" class="btn btn-link"
ui-sref="partners.detail({clientMoniker:client_moniker.client_moniker})"> ng-repeat="client_moniker in client_monikers" ng-if="$last"
{{client_moniker.client_moniker}} ui-sref="partners.detail({clientMoniker:client_moniker.client_moniker})">
</button> {{client_moniker.client_moniker}}
</button>
</div>
</div> </div>
</div>
</span> </span>
</a> </a>
<!--
<a class="list-group-item col-sm-2 col-xs-6 cursor" ng-hide="isCollapsed" <a class="list-group-item col-sm-2 col-xs-6 cursor" ng-hide="isCollapsed"
ng-repeat="client in clients | orderBy:'client_count':true" ng-repeat="client in clients | orderBy:'client_count':true"
ng-click="showClient(client.sub_merchant_id);toShow=!toShow" ng-if="$index>59"> ng-click="showClient(client.sub_merchant_id);toShow=!toShow" ng-if="$index>59">
@ -124,7 +133,7 @@
title="Using temp Sub Merchant ID" title="Using temp Sub Merchant ID"
ng-if="client.temp_sub_merchant"></i></span> ng-if="client.temp_sub_merchant"></i></span>
<span class="badge pull-right position_re" aria-hidden="true" title="show detail"> <span class="badge pull-right position_re" aria-hidden="true" title="show detail">
{{client.client_count}} {{client.client_count}}</span>
<div ng-if="sub_merchant_id==client.sub_merchant_id&&toShow" class="popover fade in position_ab" <div ng-if="sub_merchant_id==client.sub_merchant_id&&toShow" class="popover fade in position_ab"
role="tooltip" style="display: block;"> role="tooltip" style="display: block;">
<div class="arrow"></div> <div class="arrow"></div>
@ -145,6 +154,21 @@
</div> </div>
</span> </span>
</a> </a>
-->
<a ng-if="clients.length > 60"
class="list-group-item col-sm-12 col-xs-12 text-center" >
<span class="small-box-footer cursor"
ng-click="more(key)"
ng-if="endIndexMap[key] < clients.length">
更多 <i class="fa fa-arrow-circle-down"></i>
</span>
<span class="small-box-footer cursor pull-right"
ng-click="packup(key)"
ng-if="endIndexMap[key] > 60">
收起 <i class="fa fa-arrow-circle-up"></i>
</span>
</a>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save