You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
272 lines
12 KiB
272 lines
12 KiB
define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
|
|
'use strict';
|
|
var app = angular.module('partnerIncrementalService', ['ui.bootstrap', 'ui.router']);
|
|
app.config(['$stateProvider', function ($stateProvider) {
|
|
$stateProvider.state('partnerIncrementalService', {
|
|
url: '/partner_incremental_service',
|
|
templateUrl: '/static/incrementalService/templates/partner_incremental_service.html',
|
|
controller: 'partnerIncrementalServiceCtrl',
|
|
resolve:{
|
|
partner:['$http',function($http){
|
|
return $http.get('/client/partner_info');
|
|
}]
|
|
}
|
|
}).state('partnerIncrementalServiceInfo', {
|
|
url: '/partner_incremental_service_info?:channel',
|
|
templateUrl: '/static/incrementalService/templates/partner_incremental_service_info.html',
|
|
controller: 'partnerIncrementalServiceInfoCtrl',
|
|
resolve:{
|
|
partner:['$http',function($http){
|
|
return $http.get('/client/partner_info');
|
|
}]
|
|
}
|
|
});
|
|
}]);
|
|
|
|
app.controller('partnerIncrementalServiceCtrl', ['$scope', '$http', '$state', 'partner', function ($scope, $http, $state, partner) {
|
|
$scope.serviceAll = [];
|
|
$scope.channelOptions = [];
|
|
$scope.windowHeight = document.body.clientWidth;
|
|
$scope.clientInfo = partner.data
|
|
$scope.initDate = function(){
|
|
$http.get("/client/partner_info/"+$scope.clientInfo.client_moniker+"/incremental_service").then(function (res) {
|
|
$scope.serviceAll = res.data.all_service;
|
|
$scope.serviceAll.forEach(function(service){
|
|
service.logo_url = '/static/images/'+service.channel+'.jpg'
|
|
})
|
|
res.data.incremental_channel.forEach(function(channel){
|
|
$scope.channelOptions.push({name:channel,logo_url:'/static/images/'+channel+'.jpg'})
|
|
})
|
|
})
|
|
|
|
}
|
|
$scope.initDate();
|
|
}]);
|
|
|
|
app.controller('partnerIncrementalServiceInfoCtrl',['$scope', '$http', '$state','$stateParams','$filter', '$timeout', 'partnerRefunder', 'orderService', 'commonDialog','partner',
|
|
function($scope,$http,$state,$stateParams,$filter, $timeout, partnerRefunder, orderService, commonDialog,partner){
|
|
$scope.serviceInfo = {}
|
|
$scope.initDate = function () {
|
|
$http.get("/client/partner_info/"+partner.data.client_moniker+"/incremental_service/"+$stateParams.channel+"/info").then(function(res){
|
|
$scope.serviceInfo =res.data
|
|
$scope.serviceInfo.logo_url = '/static/images/'+$scope.serviceInfo.channel+'.jpg'
|
|
|
|
})
|
|
}
|
|
$scope.initDate();
|
|
$scope.params = {source: $scope.serviceInfo.channel,status: 'PAID', channel :'ALL' ,textType: 'all', datefrom: new Date(), dateto: new Date()};
|
|
$scope.pagination = {};
|
|
$scope.today = new Date();
|
|
$scope.isAll = true;
|
|
$scope.isLevel3All = true;
|
|
$scope.device_isAll = true;
|
|
$scope.dev_params = {client_type:'sunmi',limit:100};
|
|
$scope.clients = [$scope.currentUser.client];
|
|
$scope.showLevel3Clients = false;
|
|
|
|
|
|
$scope.chooseToday = function () {
|
|
$scope.params.datefrom = $scope.params.dateto = new Date();
|
|
$scope.loadTradeLogs(1);
|
|
};
|
|
$scope.chooseYesterday = function () {
|
|
var yesterday = new Date();
|
|
yesterday.setDate(yesterday.getDate() - 1);
|
|
$scope.params.datefrom = $scope.params.dateto = yesterday;
|
|
$scope.loadTradeLogs(1);
|
|
};
|
|
$scope.chooseLast7Days = function () {
|
|
$scope.params.dateto = new Date();
|
|
var day = new Date();
|
|
day.setDate(day.getDate() - 7);
|
|
$scope.params.datefrom = day;
|
|
$scope.loadTradeLogs(1);
|
|
};
|
|
$scope.thisMonth = function () {
|
|
$scope.params.dateto = new Date();
|
|
var monthBegin = new Date();
|
|
monthBegin.setDate(1);
|
|
$scope.params.datefrom = monthBegin;
|
|
$scope.loadTradeLogs(1);
|
|
};
|
|
$scope.lastMonth = function () {
|
|
var monthFinish = new Date();
|
|
monthFinish.setDate(0);
|
|
$scope.params.dateto = monthFinish;
|
|
var monthBegin = new Date();
|
|
monthBegin.setDate(0);
|
|
monthBegin.setDate(1);
|
|
$scope.params.datefrom = monthBegin;
|
|
$scope.loadTradeLogs(1);
|
|
};
|
|
$scope.loadTradeLogs = function (page) {
|
|
$scope.params.source = $scope.serviceInfo.channel;
|
|
var params = angular.copy($scope.params);
|
|
if (params.datefrom) {
|
|
params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd');
|
|
}
|
|
if (params.dateto) {
|
|
params.dateto = $filter('date')(params.dateto, 'yyyyMMdd');
|
|
}
|
|
params.page = page || $scope.pagination.page || 1;
|
|
$http.get('/client/partner_info/incremental_trade_logs', {params: params}).then(function (resp) {
|
|
$scope.tradeLogs = resp.data.data;
|
|
$scope.pagination = resp.data.pagination;
|
|
$scope.analysis = resp.data.analysis;
|
|
$scope.analysis.refund_fee = angular.copy(Math.abs($scope.analysis.refund_fee));
|
|
});
|
|
};
|
|
|
|
$scope.gatewaySelected = function (arr) {
|
|
return $scope.params.gateway != null && $scope.params.gateway.filter(function (gateway) {
|
|
return arr.indexOf(gateway) >= 0
|
|
}).length > 0
|
|
};
|
|
$scope.showTradeDetail = function (order) {
|
|
orderService.clientOrderDetail(order)
|
|
};
|
|
$scope.showPRefundLog = function (orderId) {
|
|
partnerRefunder.prefunded(orderId);
|
|
};
|
|
$scope.newPRefund = function (orderId) {
|
|
partnerRefunder.prefund(orderId).then(function () {
|
|
$scope.loadTradeLogs();
|
|
});
|
|
};
|
|
$scope.releasePreAuth = function (orderId) {
|
|
commonDialog.confirm({
|
|
title: 'Pre Authorization Completion',
|
|
content: 'This bill will be taken into settlement, or you will be able to make a refund order. Are you sure?'
|
|
}).then(function () {
|
|
$http.put('/client/partner_info/trade_logs/' + orderId + '/release_preauth').then(function (resp) {
|
|
$scope.loadTradeLogs();
|
|
}, function (resp) {
|
|
commonDialog.alert({title: 'Error!', content: resp.data.message, type: 'error'})
|
|
})
|
|
})
|
|
};
|
|
$scope.alerts = [];
|
|
$scope.$on('pe_order_paid', function (evt, order) {
|
|
$scope.alerts.push(order);
|
|
$timeout(function () {
|
|
$scope.alerts.splice(0, 1);
|
|
}, 10000);
|
|
$scope.loadTradeLogs();
|
|
});
|
|
$scope.chooseClient = function (client) {
|
|
if (client == 'all') {
|
|
$scope.params.client_ids = angular.copy($scope.clientIds);
|
|
$scope.isAll = true;
|
|
$scope.chooseClientId = '';
|
|
$scope.dev_params.client_ids = angular.copy($scope.clientIds);
|
|
$scope.showLevel3Clients = false;
|
|
$scope.listDevices();
|
|
} else if (client.level3Clients) {
|
|
$scope.chooseClientId = client.client_id;
|
|
$scope.showLevel3Clients = true;
|
|
$scope.level3Clients = client.level3Clients;
|
|
$scope.isAll = false;
|
|
$scope.level3ClientIds = [];
|
|
$scope.level3ClientIds.push(client.client_id);
|
|
client.level3Clients.forEach(function (client) {
|
|
$scope.level3ClientIds.push(client.client_id);
|
|
});
|
|
$scope.chooseLevel3Client("all");
|
|
return;
|
|
} else {
|
|
$scope.chooseClientId = client.client_id;
|
|
$scope.params.client_ids = [client.client_id];
|
|
$scope.isAll = false;
|
|
$scope.dev_params.client_ids = [client.client_id];
|
|
$scope.showLevel3Clients = false;
|
|
$scope.listDevices();
|
|
}
|
|
$scope.loadTradeLogs();
|
|
};
|
|
|
|
$scope.chooseLevel3Client = function (client) {
|
|
if (client == 'all') {
|
|
$scope.params.client_ids = angular.copy($scope.level3ClientIds);
|
|
$scope.isLevel3All = true;
|
|
$scope.chooseLevel3ClientId = '';
|
|
$scope.dev_params.client_ids = angular.copy($scope.level3ClientIds);
|
|
$scope.listDevices();
|
|
} else {
|
|
$scope.chooseLevel3ClientId = client.client_id;
|
|
$scope.params.client_ids = [client.client_id];
|
|
$scope.isLevel3All = false;
|
|
$scope.dev_params.client_ids = [client.client_id];
|
|
$scope.listDevices();
|
|
}
|
|
$scope.loadTradeLogs();
|
|
};
|
|
|
|
$scope.listDevices = function () {
|
|
var params = angular.copy($scope.dev_params)
|
|
$http.get('/client/partner_info/devices', {params: params}).then(function (resp) {
|
|
$scope.devices = resp.data.data;
|
|
})
|
|
};
|
|
$scope.chooseDevices = function (dev_id) {
|
|
if(dev_id == 'all'){
|
|
$scope.chooseDevice_id = '';
|
|
$scope.params.dev_id = null;
|
|
$scope.device_isAll = true;
|
|
$scope.loadTradeLogs(1);
|
|
}else {
|
|
$scope.chooseDevice_id = dev_id;
|
|
$scope.params.dev_id = dev_id;
|
|
$scope.device_isAll = false;
|
|
$scope.loadTradeLogs(1);
|
|
}
|
|
};
|
|
$scope.listDevices();
|
|
|
|
if ($scope.currentUser.client.has_children) {
|
|
$http.get('/client/partner_info/sub_partners').then(function (resp) {
|
|
var clientList = resp.data;
|
|
clientList.forEach(function (client) {
|
|
$scope.clients.push(client);
|
|
});
|
|
$scope.clientIds = [];
|
|
$scope.clients.forEach(function (client) {
|
|
$scope.clientIds.push(client.client_id);
|
|
if (client.level3Clients) {
|
|
client.level3Clients.forEach(function (level3Client) {
|
|
$scope.clientIds.push(level3Client.client_id);
|
|
});
|
|
}
|
|
});
|
|
$scope.params.client_ids = angular.copy($scope.clientIds);
|
|
|
|
$scope.loadTradeLogs(1);
|
|
//console.log($rootScope.currentUser.client.clientList);
|
|
})
|
|
}else{
|
|
$scope.loadTradeLogs(1);
|
|
}
|
|
|
|
$scope.fullReleasePreAuth = function (){
|
|
var params = angular.copy($scope.params);
|
|
if (params.datefrom) {
|
|
params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd');
|
|
}
|
|
if (params.dateto) {
|
|
params.dateto = $filter('date')(params.dateto, 'yyyyMMdd');
|
|
}
|
|
commonDialog.confirm({
|
|
title: 'All Pre Authorization Completion',
|
|
content: 'These pre authorization orders will be taken into settlement, or you will be able to make a refund order. Are you sure?'
|
|
}).then(function(){
|
|
$http.put('/client/partner_info/trade_logs/full_release_preauth',params).then(function (resp){
|
|
$scope.loadTradeLogs(1);
|
|
alert("Success");
|
|
},function (resp) {
|
|
commonDialog.alert({title: 'Error!', content: resp.data.message, type: 'error'})
|
|
})
|
|
});
|
|
}
|
|
}]);
|
|
return app;
|
|
});
|