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.

1712 lines
74 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
* partner info in partner client
* Created by yixian on 2016-07-03.
*/
define(['angular', 'decimal', 'uiRouter', 'ngBootSwitch', 'ngFileUpload','uiBootstrap'], function (angular, Decimal) {
'use strict';
var app = angular.module('partnerInfoApp', ['ui.router', 'frapontillo.bootstrap-switch', 'ngFileUpload','ui.bootstrap']);
app.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('basic', {
url: '/basic',
templateUrl: '/static/payment/partner/templates/client_partner_detail.html',
controller: 'clientPartnerDetailCtrl',
resolve: {
partner: ['$http', function ($http) {
return $http.get('/client/partner_info');
}]
}
}).state('edit', {
url: '/edit',
templateUrl: '/static/payment/partner/templates/client_partner_edit.html',
controller: 'clientPartnerEditCtrl',
resolve: {
partner: ['$http', function ($http) {
return $http.get('/client/partner_info');
}]
}
}).state('basic.payment_info', {
url: '/payment',
templateUrl: '/static/payment/partner/templates/client_payment_info.html',
controller: 'clientPaymentInfoCtrl'
}).state('basic.compliance_files', {
url: '/{client_moniker}/compliance_files',
templateUrl: '/static/payment/partner/templates/client_compliance_files.html',
controller: 'clientComplianceFilesCtrl',
resolve: {
file: ['$http', function ($http) {
return $http.get('/client/partner_info/compliance/files');
}]
}
}).state('basic.compliance_to_perfect', {
url: '/compliance_to_perfect',
templateUrl: '/static/payment/partner/templates/client_compliance_to_perfect.html',
controller: 'clientCommitToComplianceFilesCtrl',
resolve: {
file: ['$http', function ($http) {
return $http.get('/client/partner_info/compliance/clientViewFiles');
}]
}
}).state('compliance_contract', {
url: '/compliance/contract',
templateUrl: '/static/payment/partner/templates/contract_for_compliance.html',
controller: 'clientCommitToComplianceFilesCtrl',
resolve: {
file: ['$http', function ($http) {
return $http.get('/client/partner_info/compliance/clientViewFiles');
}]
}
}).state('basic.clearing_config', {
url: '/clearing_config',
templateUrl: '/static/payment/partner/templates/client_bankaccounts.html',
controller: 'clientClearingConfigCtrl'
}).state('parameter', {
url: '/parameters',
templateUrl: '/static/payment/partner/templates/client_parameter.html',
controller: 'clientParameterCtrl'
}).state('sub_partners', {
url: '/sub_partners',
templateUrl: '/static/payment/partner/templates/client_sub_partners.html',
controller: 'clientSubPartnersCtrl',
resolve: {
partner: ['$http', function ($http) {
return $http.get('/client/partner_info');
}]
}
}).state('devices', {
url: '/devices',
templateUrl: '/static/payment/partner/templates/client_devices.html',
controller: 'clientDeviceCtrl'
})
}]);
app.controller('clientPartnerDetailCtrl', ['$scope', '$http', 'partner','industryMap','businessStructuresMap','commonDialog','Upload','$state', function ($scope, $http, partner,industryMap,businessStructuresMap,commonDialog,Upload,$state) {
$scope.business_structures = businessStructuresMap.configs();
$scope.industries = industryMap.configs();
$scope.partner = partner.data;
$scope.partner.partner_type = $scope.partner.company_website ? 'website' : 'photo';
$scope.getMerchantLocation = function () {
$http.get('/sys/partners/' + $scope.partner.client_moniker + '/location').then(function (resp) {
$scope.merchant_location = resp.data;
});
};
$scope.getMerchantLocation();
$scope.uploadLogo = function (file) {
if (file != null) {
if (file.size > 1 * 1024 * 1024) {
commonDialog.alert({title: 'Error', content: '文件大小不能超过1MB请压缩后重试', type: 'error'})
} else {
$scope.logoProgress = {value: 0};
Upload.upload({
url: '/attachment/files',
data: {file: file}
}).then(function (resp) {
delete $scope.logoProgress;
$scope.partner.logo_id = resp.data.fileid;
$scope.partner.logo_url = resp.data.url;
}, function (resp) {
delete $scope.logoProgress;
commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})
}, function (evt) {
$scope.logoProgress.value = parseInt(100 * evt.loaded / evt.total);
})
}
}
};
$scope.uploadShopPhoto = function (file) {
if (file != null) {
if (file.size > 2 * 1024 * 1024) {
commonDialog.alert({title: 'Error', content: '文件大小不能超过2MB请压缩后重试', type: 'error'})
} else {
$scope.shopPhotoProgress = {value: 0};
Upload.upload({
url: '/attachment/files',
data: {file: file}
}).then(function (resp) {
delete $scope.shopPhotoProgress;
$scope.partner.company_photo = resp.data.url;
}, function (resp) {
delete $scope.shopPhotoProgress;
commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})
}, function (evt) {
$scope.shopPhotoProgress.value = parseInt(100 * evt.loaded / evt.total);
})
}
}
};
var resetClientPayDescByTpey = function (type) {
type = parseInt(type);
if (type == 1) {
removeClientPayDesc($scope.partner.client_pay_desc, '10');
}
if (type == 2) {
removeClientPayDesc($scope.partner.client_pay_desc, '20');
}
};
$scope.toggleClientPayType = function (type) {
if (!$scope.partner.client_pay_type) {
$scope.partner.client_pay_type = [];
}
var $idx = $scope.partner.client_pay_type.indexOf(type);
if ($idx >= 0) {
$scope.partner.client_pay_type.splice($idx, 1);
resetClientPayDescByTpey(type);
} else {
$scope.partner.client_pay_type.push(type);
$scope.partner.client_pay_type.sort(compare);
}
};
var removeClientPayDesc = function (items, key) {
for (var i = 0; i < items.length; i++) {
var item = items[i];
if (item.indexOf(key)>=0) {
items.splice(items.indexOf(item), 1);
i = i - 1;
}
}
};
$scope.toggleClientPayDesc = function (type) {
if (!$scope.partner.client_pay_desc) {
$scope.partner.client_pay_desc = [];
}
var $idx = $scope.partner.client_pay_desc.indexOf(type);
if ($idx >= 0) {
if (type == '203') {
removeClientPayDesc($scope.partner.client_pay_desc,'2030')
}
$scope.partner.client_pay_desc.splice($idx, 1);
} else {
$scope.partner.client_pay_desc.push(type);
$scope.partner.client_pay_desc.sort(compare);
}
};
$scope.uploadStorePhoto = function (file) {
if (file != null) {
if (file.size > 2 * 1024 * 1024) {
commonDialog.alert({title: 'Error', content: '文件大小不能超过2MB请压缩后重试', type: 'error'})
} else {
$scope.storePhotoProgress = {value: 0};
Upload.upload({
url: '/attachment/files',
data: {file: file}
}).then(function (resp) {
delete $scope.storePhotoProgress;
$scope.partner.store_photo = resp.data.url;
}, function (resp) {
delete $scope.storePhotoProgress;
commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})
}, function (evt) {
$scope.storePhotoProgress.value = parseInt(100 * evt.loaded / evt.total);
})
}
}
};
$scope.updatePartner = function (form) {
if (form.$invalid) {
angular.forEach(form, function (item, key) {
if (key.indexOf('$') < 0) {
item.$dirty = true;
}
});
return;
}
if (!$scope.partner.logo_url) {
alert("Logo is necessary!");
return;
}
if($scope.partner.partner_type == 'photo'){
if (!$scope.partner.company_photo) {
alert('Shop Photo1 is necessary');
return;
}
if (!$scope.partner.store_photo) {
alert('Shop Photo2 is necessary');
return;
}
}
var content = '';
if ($scope.partner.client_pay_type.length==0) {
alert('请选择商户支付场景')
return;
}
if ($scope.partner.client_pay_desc.length==0) {
alert('请选择商户支付方式')
return;
}
if ($scope.partner.client_pay_type.indexOf('1') >= 0) {
if ($scope.partner.client_pay_desc.join(',').indexOf('10') < 0) {
alert("请检查线上支付场景是否已选择支付方式");
return;
}
}
if ( $scope.partner.client_pay_type.indexOf('2') >= 0) {
if ($scope.partner.client_pay_desc.join(',').indexOf('20') < 0) {
alert("请检查线下支付场景是否已选择支付方式");
return;
}
}
if ($scope.partner.client_pay_desc.join(',').indexOf('203') >= 0) {
if ($scope.partner.client_pay_desc.join(',').indexOf('2030') < 0) {
alert("请检查线下支付是否已选择收银系统类型");
return;
}
}
$scope.partner.client_pay_type = $scope.partner.client_pay_type.join(',');
$scope.partner.client_pay_desc = $scope.partner.client_pay_desc.join(',');
$http.put('/client/partner_info/update/partnerInfo', $scope.partner).then(function () {
if (content != '') {
commonDialog.alert({
title: 'Warning',
content: content,
type: 'error'
});
} else {
commonDialog.alert({
title: 'Success',
content: 'Update partner information successfully',
type: 'success'
});
}
$state.go('basic', {clientMoniker: $scope.partner.client_moniker}, {reload: true});
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
});
};
//修改邮箱
$scope.updateEmail = function () {
$http.put('/client/partner_info/complianceAudit').then(
);
};
$scope.commitToCompliance = function () {
$http.get('/client/partner_info/compliance/files').then(function (resp) {
$scope.complianceFiles = resp.data;
if($scope.complianceFiles.client_id_file == null||$scope.complianceFiles.client_bank_file == null || $scope.complianceFiles.client_company_file == null){
commonDialog.alert({title: 'Message', content: '请前去完善合规资料,再进行提交!', type: 'info'});
return;
}
if($scope.partner.business_structure == null ||$scope.partner.logo_url == null || $scope.partner.description == null ||($scope.partner.partner_type == 'website' && $scope.partner.company_website == null) || ($scope.partner.partner_type == 'photo'&&($scope.partner.store_photo == null || $scope.partner.company_photo == null))){
commonDialog.alert({title: 'Message', content: '请前去完善商户资料,再进行提交!', type: 'info'});
return;
}
if(($scope.partner.business_structure == "Company" && $scope.partner.acn == null) || ($scope.partner.business_structure != "Company" && $scope.partner.abn == null)){
commonDialog.alert({title: 'Message', content: '请前去完善商户资料,再进行提交!', type: 'info'});
return;
}
if(!$scope.partner.mail_confirm){
commonDialog.alert({title: 'Message', content: '请验证邮箱后,再进行提交!', type: 'info'});
return;
}
commonDialog.confirm({
title: 'Commit to Compliance',
content: 'Are you sure to commit ' + $scope.partner.company_name + ' to compliance',
choises: [
{label: 'Submit', className: 'btn-success', key: 1},
{label: 'Cancel', className: 'btn-warning', key: 0, dismiss: true}
]
}).then(function (choice) {
$scope.submitted = true;
if (choice == 1) {
$http.post('/client/partner_info/complianceAudit').then(function (){
commonDialog.alert({title: 'Success', content: '已提交至合规,请耐心等待审核!', type: 'info'});
$state.reload();
}, function () {
$state.reload();
});
}
})
});
}
}]);
app.controller('clientPartnerEditCtrl', ['$scope', '$http', 'commonDialog','stateMap','countryMap','partner','$state','Upload',function ($scope, $http, commonDialog,stateMap,countryMap,partner,$state,Upload) {
$scope.partner = partner.data;
$scope.states = stateMap.configs();
$scope.countries = countryMap.configs();
$scope.uploadLogo = function (file) {
if (file != null) {
if (file.size > 1 * 1024 * 1024) {
commonDialog.alert({title: 'Error', content: '文件大小不能超过1MB请压缩后重试', type: 'error'})
} else {
$scope.logoProgress = {value: 0};
Upload.upload({
url: '/attachment/files',
data: {file: file}
}).then(function (resp) {
delete $scope.logoProgress;
$scope.partner.logo_id = resp.data.fileid;
$scope.partner.logo_url = resp.data.url;
}, function (resp) {
delete $scope.logoProgress;
commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})
}, function (evt) {
$scope.logoProgress.value = parseInt(100 * evt.loaded / evt.total);
})
}
}
};
$scope.uploadShopPhoto = function (file) {
if (file != null) {
if (file.size > 2 * 1024 * 1024) {
commonDialog.alert({title: 'Error', content: '文件大小不能超过2MB请压缩后重试', type: 'error'})
} else {
$scope.shopPhotoProgress = {value: 0};
Upload.upload({
url: '/attachment/files',
data: {file: file}
}).then(function (resp) {
delete $scope.shopPhotoProgress;
$scope.partner.company_photo = resp.data.url;
}, function (resp) {
delete $scope.shopPhotoProgress;
commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})
}, function (evt) {
$scope.shopPhotoProgress.value = parseInt(100 * evt.loaded / evt.total);
})
}
}
};
$scope.uploadStorePhoto = function (file) {
if (file != null) {
if (file.size > 2 * 1024 * 1024) {
commonDialog.alert({title: 'Error', content: '文件大小不能超过2MB请压缩后重试', type: 'error'})
} else {
$scope.storePhotoProgress = {value: 0};
Upload.upload({
url: '/attachment/files',
data: {file: file}
}).then(function (resp) {
delete $scope.storePhotoProgress;
$scope.partner.store_photo = resp.data.url;
}, function (resp) {
delete $scope.storePhotoProgress;
commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})
}, function (evt) {
$scope.storePhotoProgress.value = parseInt(100 * evt.loaded / evt.total);
})
}
}
};
var resetClientPayDescByTpey = function (type) {
type = parseInt(type);
if (type == 1) {
removeClientPayDesc($scope.partner.client_pay_desc, '10');
}
if (type == 2) {
removeClientPayDesc($scope.partner.client_pay_desc, '20');
}
};
$scope.toggleClientPayType = function (type) {
if (!$scope.partner.client_pay_type) {
$scope.partner.client_pay_type = [];
}
var $idx = $scope.partner.client_pay_type.indexOf(type);
if ($idx >= 0) {
$scope.partner.client_pay_type.splice($idx, 1);
resetClientPayDescByTpey(type);
} else {
$scope.partner.client_pay_type.push(type);
$scope.partner.client_pay_type.sort(compare);
}
};
var removeClientPayDesc = function (items, key) {
for (var i = 0; i < items.length; i++) {
var item = items[i];
if (item.indexOf(key)>=0) {
items.splice(items.indexOf(item), 1);
i = i - 1;
}
}
};
$scope.toggleClientPayDesc = function (type) {
if (!$scope.partner.client_pay_desc) {
$scope.partner.client_pay_desc = [];
}
var $idx = $scope.partner.client_pay_desc.indexOf(type);
if ($idx >= 0) {
if (type == '203') {
removeClientPayDesc($scope.partner.client_pay_desc,'2030')
}
$scope.partner.client_pay_desc.splice($idx, 1);
} else {
$scope.partner.client_pay_desc.push(type);
$scope.partner.client_pay_desc.sort(compare);
}
};
$scope.updatePartner = function (form) {
if (form.$invalid) {
angular.forEach(form, function (item, key) {
if (key.indexOf('$') < 0) {
item.$dirty = true;
}
});
return;
}
if (!$scope.partner.logo_url) {
alert("Logo is necessary!");
return;
}
if($scope.partner.partner_type == 'photo'){
if (!$scope.partner.company_photo) {
alert('Shop Photo1 is necessary');
return;
}
if (!$scope.partner.store_photo) {
alert('Shop Photo2 is necessary');
return;
}
}
var content = '';
if ($scope.partner.client_pay_type.length==0) {
alert('请选择商户支付场景')
return;
}
if ($scope.partner.client_pay_desc.length==0) {
alert('请选择商户支付方式')
return;
}
if ($scope.partner.client_pay_type.indexOf('1') >= 0) {
if ($scope.partner.client_pay_desc.join(',').indexOf('10') < 0) {
alert("请检查线上支付场景是否已选择支付方式");
return;
}
}
if ( $scope.partner.client_pay_type.indexOf('2') >= 0) {
if ($scope.partner.client_pay_desc.join(',').indexOf('20') < 0) {
alert("请检查线下支付场景是否已选择支付方式");
return;
}
}
if ($scope.partner.client_pay_desc.join(',').indexOf('203') >= 0) {
if ($scope.partner.client_pay_desc.join(',').indexOf('2030') < 0) {
alert("请检查线下支付是否已选择收银系统类型");
return;
}
}
$scope.partner.client_pay_type = $scope.partner.client_pay_type.join(',');
$scope.partner.client_pay_desc = $scope.partner.client_pay_desc.join(',');
$http.put('/client/partner_info/update/partnerInfo', $scope.partner).then(function () {
if (content != '') {
commonDialog.alert({
title: 'Warning',
content: content,
type: 'error'
});
} else {
commonDialog.alert({
title: 'Success',
content: 'Update partner information successfully',
type: 'success'
});
}
$state.go('basic', {reload: true});
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
});
};
}]);
app.controller('clientResetPartnerPublicKeyDialogCtrl', ['$scope', '$http', 'gateway_sign', function ($scope, $http,gateway_sign) {
$scope.gateway_sign = angular.copy(gateway_sign);
$scope.uploadPublicKey = function (mch_public_key) {
$scope.errmsg = null;
$http.put('/client/partner_info/partner_public_key', {partner_public_key:mch_public_key}).then(function () {
$scope.$close();
}, function (resp) {
$scope.errmsg = resp.data.message;
})
}
}]);
app.controller('clientRefreshPlatformPublicKeyDialogCtrl', ['$scope', '$http', 'gateway_sign','commonDialog', function ($scope, $http,gateway_sign,commonDialog) {
$scope.gateway_sign = angular.copy(gateway_sign);
$scope.copyPublicKey = function() {
var e=document.getElementById("c-cpKey");
e.select();
var successful = document.execCommand("Copy");
if (successful) {
commonDialog.alert({title: 'Success', content: '已复制到剪切板!', type: 'success'});
}else {
commonDialog.alert({title: 'Error', content: '您的浏览器不支持!请手动复制', type: 'error'});
}
};
$scope.refreshPublicKey = function () {
$scope.errmsg = null;
$http.put('/client/partner_info/refresh_platform_public_key').then(function () {
$scope.$close();
}, function (resp) {
$scope.errmsg = resp.data.message;
})
}
}]);
app.controller('clientResetRefundPwdDialogCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.updateRefundPwd = function (refundPwd) {
$scope.errmsg = null;
$http.put('/client/partner_info/refund_pwd_new', refundPwd).then(function () {
$scope.$close();
}, function (resp) {
$scope.errmsg = resp.data.message;
})
}
}]);
app.controller('clientComplianceFilesCtrl', ['$scope', '$http', '$rootScope', 'commonDialog', '$state', 'Upload', 'file', function ($scope, $http, $rootScope, commonDialog, $state, Upload, file) {
$scope.file = file.data || {};
//audit files
$scope.uploadBankFile = function (file) {
if (file != null) {
if (file.size > 3 * 1024 * 1024) {
commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB请压缩后重试', type: 'error'})
} else {
$scope.bankFileProgress = {value: 0};
Upload.upload({
url: '/attachment/files',
data: {file: file}
}).then(function (resp) {
delete $scope.bankFileProgress;
$scope.file.file_bank_info = resp.data.url;
$scope.updateFile();
if ($scope.file.file_bank_info.endsWith('pdf')) {
$scope.bankIsImage = false;
} else {
$scope.bankIsImage = true;
}
}, function (resp) {
delete $scope.bankFileProgress;
commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})
}, function (evt) {
$scope.bankFileProgress.value = parseInt(100 * evt.loaded / evt.total);
})
}
}
};
$scope.agreeIsImage = true;
if ($scope.file.file_agreement_info && $scope.file.file_agreement_info.endsWith('pdf')) {
$scope.agreeIsImage = false;
}
$scope.bankIsImage = true;
if ($scope.file.file_bank_info && $scope.file.file_bank_info.endsWith('pdf')) {
$scope.bankIsImage = false;
}
$scope.companyIsImage = true;
if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) {
$scope.companyIsImage = false;
}
$scope.applyIsImage = true;
if ($scope.file.file_apply_info && $scope.file.file_apply_info.endsWith('pdf')) {
$scope.applyIsImage = false;
}
$scope.idIsImage = true;
if ($scope.file.file_id_info && $scope.file.file_id_info.endsWith('pdf')) {
$scope.idIsImage = false;
}
$scope.uploadCompanyFile = function (file) {
if (file != null) {
if (file.size > 3 * 1024 * 1024) {
commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB请压缩后重试', type: 'error'})
} else {
$scope.companyFileProgress = {value: 0};
Upload.upload({
url: '/attachment/files',
data: {file: file}
}).then(function (resp) {
delete $scope.companyFileProgress;
$scope.file.file_company_info = resp.data.url;
$scope.updateFile();
if ($scope.file.file_company_info.endsWith('pdf')) {
$scope.companyIsImage = false;
} else {
$scope.companyIsImage = true;
}
}, function (resp) {
delete $scope.companyFileProgress;
commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})
}, function (evt) {
$scope.companyFileProgress.value = parseInt(100 * evt.loaded / evt.total);
})
}
}
};
//上传ID信息
$scope.uploadIDFile = function (file) {
if (file != null) {
if (file.size > 3 * 1024 * 1024) {
commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB请压缩后重试', type: 'error'})
} else {
$scope.idFileProgress = {value: 0};
Upload.upload({
url: '/attachment/files',
data: {file: file}
}).then(function (resp) {
delete $scope.idFileProgress;
$scope.file.file_id_info = resp.data.url;
$scope.updateFile();
if ($scope.file.file_id_info.endsWith('pdf')) {
$scope.idIsImage = false;
} else {
$scope.idIsImage = true;
}
}, function (resp) {
delete $scope.idFileProgress;
commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})
}, function (evt) {
$scope.idFileProgress.value = parseInt(100 * evt.loaded / evt.total);
})
}
}
};
//上传协议文件
$scope.uploadAgreementFile = function (file) {
if (file != null) {
if (file.size > 10 * 1024 * 1024) {
commonDialog.alert({title: 'Error', content: '文件大小不能超过5MB请压缩后重试', type: 'error'})
} else {
$scope.agreementFileProgress = {value: 0};
Upload.upload({
url: '/attachment/files',
data: {file: file}
}).then(function (resp) {
delete $scope.agreementFileProgress;
$scope.file.file_agreement_info = resp.data.url;
$scope.updateFile();
if ($scope.file.file_agreement_info.endsWith('pdf')) {
$scope.agreeIsImage = false;
} else {
$scope.agreeIsImage = true;
}
}, function (resp) {
delete $scope.agreementFileProgress;
commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})
}, function (evt) {
$scope.agreementFileProgress.value = parseInt(100 * evt.loaded / evt.total);
})
}
}
};
//上传申请表
$scope.uploadApplyFile = function (file) {
if (file != null) {
if (file.size > 3 * 1024 * 1024) {
commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB请压缩后重试', type: 'error'})
} else {
$scope.applyFileProgress = {value: 0};
Upload.upload({
url: '/attachment/files',
data: {file: file}
}).then(function (resp) {
delete $scope.applyFileProgress;
$scope.file.file_apply_info = resp.data.url;
$scope.updateFile();
if ($scope.file.file_apply_info.endsWith('pdf')) {
$scope.applyIsImage = false;
} else {
$scope.applyIsImage = true;
}
}, function (resp) {
delete $scope.applyFileProgress;
commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})
}, function (evt) {
$scope.applyFileProgress.value = parseInt(100 * evt.loaded / evt.total);
})
}
}
};
/* $scope.downloadAsZip = function () {
var url = '/sys/partners/' + $scope.partner.client_moniker + '/download/complianceAsZIP';
return url;
};
*/
$scope.updateFile = function () {
$http.put('/client/partner_info/update/file', $scope.file).then(function () {
commonDialog.alert({
title: 'Success',
content: 'Upload Successful',
type: 'success'
});
$state.reload();
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
})
};
function commitError() {
commonDialog.alert({
title: 'Error',
content: 'Missing file',
type: 'error'
});
};
$scope.commitPartner = function () {
if ($scope.file) {
if ($scope.file.file_bank_info != null && $scope.file.file_company_info != null && $scope.file.file_id_info != null && $scope.file_apply_info != null) {
$http.put('/client/partner_info/complianceAudit').then(function (resp) {
});
} else {
commitError();
}
} else {
commitError();
}
};
}]);
app.controller('clientCommitToComplianceFilesCtrl', ['$scope', '$http', '$rootScope', 'commonDialog', '$state', 'Upload', 'file', function ($scope, $http, $rootScope, commonDialog, $state, Upload, file) {
$scope.file = file.data || {};
//audit files
$scope.uploadBankFile = function (file) {
if (file != null) {
if (file.size > 3 * 1024 * 1024) {
commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB请压缩后重试', type: 'error'})
} else {
$scope.bankFileProgress = {value: 0};
Upload.upload({
url: '/attachment/files',
data: {file: file}
}).then(function (resp) {
delete $scope.bankFileProgress;
$scope.file.file_bank_info = resp.data.url;
$scope.updateFile();
if ($scope.file.file_bank_info.endsWith('pdf')) {
$scope.bankIsImage = false;
} else {
$scope.bankIsImage = true;
}
}, function (resp) {
delete $scope.bankFileProgress;
commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})
}, function (evt) {
$scope.bankFileProgress.value = parseInt(100 * evt.loaded / evt.total);
})
}
}
};
$scope.agreeIsImage = true;
if ($scope.file.file_agreement_info && $scope.file.file_agreement_info.endsWith('pdf')) {
$scope.agreeIsImage = false;
}
$scope.bankIsImage = true;
if ($scope.file.file_bank_info && $scope.file.file_bank_info.endsWith('pdf')) {
$scope.bankIsImage = false;
}
$scope.companyIsImage = true;
if ($scope.file.file_company_info && $scope.file.file_company_info.endsWith('pdf')) {
$scope.companyIsImage = false;
}
$scope.applyIsImage = true;
if ($scope.file.file_apply_info && $scope.file.file_apply_info.endsWith('pdf')) {
$scope.applyIsImage = false;
}
$scope.idIsImage = true;
if ($scope.file.file_id_info && $scope.file.file_id_info.endsWith('pdf')) {
$scope.idIsImage = false;
}
$scope.uploadCompanyFile = function (file) {
if (file != null) {
if (file.size > 3 * 1024 * 1024) {
commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB请压缩后重试', type: 'error'})
} else {
$scope.companyFileProgress = {value: 0};
Upload.upload({
url: '/attachment/files',
data: {file: file}
}).then(function (resp) {
delete $scope.companyFileProgress;
$scope.file.file_company_info = resp.data.url;
$scope.updateFile();
if ($scope.file.file_company_info.endsWith('pdf')) {
$scope.companyIsImage = false;
} else {
$scope.companyIsImage = true;
}
}, function (resp) {
delete $scope.companyFileProgress;
commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})
}, function (evt) {
$scope.companyFileProgress.value = parseInt(100 * evt.loaded / evt.total);
})
}
}
};
//上传ID信息
$scope.uploadIDFile = function (file) {
if (file != null) {
if (file.size > 3 * 1024 * 1024) {
commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB请压缩后重试', type: 'error'})
} else {
$scope.idFileProgress = {value: 0};
Upload.upload({
url: '/attachment/files',
data: {file: file}
}).then(function (resp) {
delete $scope.idFileProgress;
$scope.file.file_id_info = resp.data.url;
$scope.updateFile();
if ($scope.file.file_id_info.endsWith('pdf')) {
$scope.idIsImage = false;
} else {
$scope.idIsImage = true;
}
}, function (resp) {
delete $scope.idFileProgress;
commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})
}, function (evt) {
$scope.idFileProgress.value = parseInt(100 * evt.loaded / evt.total);
})
}
}
};
//上传协议文件
$scope.uploadAgreementFile = function (file) {
if (file != null) {
if (file.size > 10 * 1024 * 1024) {
commonDialog.alert({title: 'Error', content: '文件大小不能超过5MB请压缩后重试', type: 'error'})
} else {
$scope.agreementFileProgress = {value: 0};
Upload.upload({
url: '/attachment/files',
data: {file: file}
}).then(function (resp) {
delete $scope.agreementFileProgress;
$scope.file.file_agreement_info = resp.data.url;
$scope.updateFile();
if ($scope.file.file_agreement_info.endsWith('pdf')) {
$scope.agreeIsImage = false;
} else {
$scope.agreeIsImage = true;
}
}, function (resp) {
delete $scope.agreementFileProgress;
commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})
}, function (evt) {
$scope.agreementFileProgress.value = parseInt(100 * evt.loaded / evt.total);
})
}
}
};
//上传申请表
$scope.uploadApplyFile = function (file) {
if (file != null) {
if (file.size > 3 * 1024 * 1024) {
commonDialog.alert({title: 'Error', content: '文件大小不能超过3MB请压缩后重试', type: 'error'})
} else {
$scope.applyFileProgress = {value: 0};
Upload.upload({
url: '/attachment/files',
data: {file: file}
}).then(function (resp) {
delete $scope.applyFileProgress;
$scope.file.file_apply_info = resp.data.url;
$scope.updateFile();
if ($scope.file.file_apply_info.endsWith('pdf')) {
$scope.applyIsImage = false;
} else {
$scope.applyIsImage = true;
}
}, function (resp) {
delete $scope.applyFileProgress;
commonDialog.alert({title: 'Upload Failed', content: resp.data.message, type: 'error'})
}, function (evt) {
$scope.applyFileProgress.value = parseInt(100 * evt.loaded / evt.total);
})
}
}
};
/* $scope.downloadAsZip = function () {
var url = '/sys/partners/' + $scope.partner.client_moniker + '/download/complianceAsZIP';
return url;
};
*/
$scope.updateFile = function () {
$http.put('/client/partner_info/update/wait_compliance_file', $scope.file).then(function () {
commonDialog.alert({
title: 'Success',
content: 'Upload Successful',
type: 'success'
});
$state.reload();
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
})
};
function commitError() {
commonDialog.alert({
title: 'Error',
content: 'Missing file',
type: 'error'
});
};
$scope.clientComplianceViewCommit= function () {
if(!$scope.file.client_agree_file)
{
commonDialog.alert({title: 'Error', content: '请提交* Agreement', type: 'error'});
return;
}else if(!$scope.file.client_id_file)
{
commonDialog.alert({title: 'Error', content:'请提交* ID', type: 'error'});
return;
}else if(!$scope.file.client_bank_file)
{
commonDialog.alert({title: 'Error', content: '请提交* bank statement', type: 'error'});
return;
}
else if(!$scope.file.client_company_file)
{
commonDialog.alert({title: 'Error', content: '请提交* Certificate of Registration', type: 'error'});
return;
};
commonDialog.confirm({
title: 'Warning',
content: 'Are you sure commit for compliance audit?'
}).then(function () {
$http.post('/client/partner_info/clientCompliance/' + $scope.partner.client_moniker + '/viewCommit', $scope.file).then(function () {
commonDialog.alert({
title: 'Success',
content: 'Commit Successful',
type: 'success'
});
$state.reload();
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
})
})
};
$scope.deleteComplianceFiles = function (file_id) {
$scope.file_id = file_id;
commonDialog.confirm({
title: 'Warning',
content: 'This operation will delete the file, Are you sure?'
}).then(function () {
$http.put('/client/partner_info/auth_file/' + $scope.file_id + '/delete').then(function (resp) {
commonDialog.alert({
title: 'Success',
content: 'Delete Successful',
type: 'success'
});
$state.reload();
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
})
})
};
$scope.commitPartner = function () {
if ($scope.file) {
if ($scope.file.file_bank_info != null && $scope.file.file_company_info != null && $scope.file.file_id_info != null && $scope.file_apply_info != null) {
$http.put('/client/partner_info/complianceAudit').then(function (resp) {
});
} else {
commitError();
}
} else {
commitError();
}
};
$scope.signContract =function(){
var url = $state.href('compliance_contract',{basicType:8});
window.open(url,'_blank');
}
$scope.goBottom =function() {
window.scrollTo(0, document.documentElement.scrollHeight-document.documentElement.clientHeight);
};
$scope.submitContract =function(){
$scope.goBottom();
$scope.confirmforsubmit();
};
$scope.confirmforsubmit =function(){
var Confirm = confirm("确认提交合同吗?")
if(Confirm)
{
}
};
}]);
app.controller('clientPaymentInfoCtrl', ['$scope', '$http', '$state', 'commonDialog','$uibModal', function ($scope, $http, $state, commonDialog, $uibModal) {
$scope.paymentInfo = $scope.partner;
$scope.old_customer_surcharge_rate = angular.copy($scope.partner.customer_surcharge_rate);
$scope.qrConfig = {currency: 'AUD'};
$scope.ctrl = {
switch_gateway_v2: false,
switch_verify_ip: false
};
$scope.clientCopyHfLink = function() {
var e=document.getElementById("c-cpbt");
e.select();
var successful = document.execCommand("Copy");
if (successful) {
commonDialog.alert({title: 'Success', content: '已复制到剪切板!', type: 'success'});
}else {
commonDialog.alert({title: 'Error', content: '您的浏览器不支持!', type: 'error'});
}
};
$scope.loadPartnerPaymentInfo = function () {
$http.get('/client/partner_info').then(function (resp) {
$scope.paymentInfo = resp.data;
})
};
$scope.switchGatewayV2 = function () {
if (!$scope.paymentInfo) {
return;
}
if (!$scope.ctrl.switch_gateway_v2) {
$scope.ctrl.switch_gateway_v2 = true;
return;
}
$http.put('/client/partner_info/switch_gateway_v2', {enable_gateway_version2: $scope.paymentInfo.enable_gateway_version2}).then(function () {
$scope.loadPartnerPaymentInfo();
}, function (resp) {
commonDialog.alert({
title: 'failed to change Gateway Version',
content: resp.data.message,
type: 'error'
})
})
};
$scope.switchVerifyIp = function () {
if (!$scope.paymentInfo.gateway_sign) {
return;
}
if (!$scope.ctrl.switch_verify_ip) {
$scope.ctrl.switch_verify_ip = true;
return;
}
$http.put('/client/partner_info/verify_ip', {verify_ip: $scope.paymentInfo.gateway_sign.verify_ip}).then(function () {
$scope.loadPartnerPaymentInfo();
}, function (resp) {
commonDialog.alert({
title: 'failed to change Verify IP',
content: resp.data.message,
type: 'error'
})
})
};
$scope.clientSaveIpWhitelistConfig = function (config) {
$http.put('/client/partner_info/ip_whitelist', {ip_whitelist: config}).then(function () {
$scope.ctrl.editIpWhitelistConfig = false;
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
})
};
$scope.resetPartnerPubliKey = function () {
$uibModal.open({
templateUrl: '/static/payment/partner/templates/partner_reset_public_key_dialog.html',
controller: 'clientResetPartnerPublicKeyDialogCtrl',
backdrop: false,
size: 'lg',
resolve: {
gateway_sign: function () {
return $scope.paymentInfo.gateway_sign;
}
}
}).result.then(function () {
commonDialog.alert({title: 'Success!', content: 'Partner Public Key Upload Successfully', type: 'success'})
$scope.loadPartnerPaymentInfo();
})
};
$scope.refreshPlatformPubliKey = function () {
$uibModal.open({
templateUrl: '/static/payment/partner/templates/partner_refresh_platform_public_key_dialog.html',
controller: 'clientRefreshPlatformPublicKeyDialogCtrl',
backdrop: false,
size: 'lg',
resolve: {
gateway_sign: function () {
return $scope.paymentInfo.gateway_sign;
}
}
}).result.then(function () {
commonDialog.alert({title: 'Success!', content: 'RoyalPay Public Key Refresh Successfully', type: 'success'})
$scope.loadPartnerPaymentInfo();
})
};
$scope.resetRefundPwd = function (account) {
$uibModal.open({
templateUrl: '/static/payment/partner/templates/partner_reset_refund_pwd_dialog.html',
controller: 'clientResetRefundPwdDialogCtrl',
backdrop: false,
size: 'sm',
resolve: {
account: function () {
return account;
}
}
}).result.then(function () {
commonDialog.alert({title: 'Success!', content: 'Refund Password Changed Successfully', type: 'success'})
})
};
$scope.clientCopyCBBannkPayLink = function() {
var e=document.getElementById("c-cpcbbankpay");
e.select();
var successful = document.execCommand("Copy");
if (successful) {
commonDialog.alert({title: 'Success', content: '已复制到剪切板!', type: 'success'});
}else {
commonDialog.alert({title: 'Error', content: '您的浏览器不支持!', type: 'error'});
}
};
$scope.reloadQRCode = function () {
$http.get('/client/partner_info/qrcode', {params: $scope.qrConfig}).then(function (resp) {
$scope.qrcode = resp.data;
});
};
$scope.ctrl = {};
$scope.reloadQRCode();
$scope.clientSaveOrderExpiryConfig = function (config) {
$http.put('/client/partner_info/' + $scope.partner.client_moniker + '/order_expiry_config', {order_expiry_config: config}).then(function () {
$scope.ctrl.editOrderExpiryConfig = false;
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
})
};
$scope.changePaymentPage = function () {
if (!$scope.paymentInfo) {
return;
}
$http.put('/client/partner_info/payment_page_version', {paypad_version: $scope.paymentInfo.paypad_version}).then(function () {
// $scope.loadPartnerPaymentInfo();
}, function (resp) {
commonDialog.alert({
title: 'failed to change Payment Page Version',
content: resp.data.message,
type: 'error'
})
})
};
$scope.changeCBBankPaymentPage = function () {
if (!$scope.paymentInfo) {
return;
}
$http.put('/client/partner_info/cbbank_payment_page_version', {cbbank_paypad_version: $scope.paymentInfo.cbbank_paypad_version}).then(function () {
// $scope.loadPartnerPaymentInfo();
}, function (resp) {
commonDialog.alert({
title: 'failed to change Payment Page Version',
content: resp.data.message,
type: 'error'
})
})
};
$scope.saveCustomerSurchargeRate = function (cofig) {
if (cofig != null && isNaN(cofig)) {
commonDialog.alert({title: 'Error', content: 'Your input is not a number!', type: 'error'});
return;
}
if (cofig > 2 || cofig < parseFloat(Decimal.add($scope.paymentInfo.rate_value, 0.1).toFixed(2))) {
commonDialog.alert({title: 'Error', content: 'Not in the valid range', type: 'error'});
return;
}
$http.put('/client/partner_info/customer_surcharge_rate', {customer_surcharge_rate: cofig}).then(function (resp) {
// $scope.loadPartnerPaymentInfo();
$scope.ctrl.editCustomerSurchargeRate = false;
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
})
};
$scope.updateClientQRCodePaySurCharge = function () {
if (!$scope.paymentInfo) {
return;
}
if (!$scope.ctrl.init_qr_surcharge) {
$scope.ctrl.init_qr_surcharge = true;
return;
}
$http.put('/client/partner_info/qrcode_surcharge', {qrcode_surcharge: $scope.paymentInfo.qrcode_surcharge}).then(function () {
// $scope.loadPartnerPaymentInfo();
}, function (resp) {
commonDialog.alert({
title: 'failed to change Customer Pay for Surcharge for QR Code',
content: resp.data.message,
type: 'error'
})
})
};
$scope.updateClientApiPaySurCharge = function () {
if (!$scope.paymentInfo) {
return;
}
if (!$scope.ctrl.init_api_surcharge) {
$scope.ctrl.init_api_surcharge = true;
return;
}
$http.put('/client/partner_info/api_surcharge', {api_surcharge: $scope.paymentInfo.api_surcharge}).then(function () {
// $scope.loadPartnerPaymentInfo();
}, function (resp) {
commonDialog.alert({
title: 'failed to change Customer Pay for Surcharge for Gateway',
content: resp.data.message,
type: 'error'
})
})
};
$scope.updateClientRetailPaySurCharge = function () {
if (!$scope.paymentInfo) {
return;
}
if (!$scope.ctrl.init_retail_surcharge) {
$scope.ctrl.init_retail_surcharge = true;
return;
}
$http.put('/client/partner_info/retail_surcharge', {retail_surcharge: $scope.paymentInfo.retail_surcharge}).then(function () {
// $scope.loadPartnerPaymentInfo();
}, function (resp) {
commonDialog.alert({
title: 'failed to change Customer Pay for Surcharge for Retail',
content: resp.data.message,
type: 'error'
})
})
}
$scope.updateClientCBBankPaySurCharge = function () {
if (!$scope.paymentInfo) {
return;
}
$http.put('/client/partner_info/cbbank_surcharge', {cbbank_surcharge: $scope.paymentInfo.cbbank_surcharge}).then(function () {
// $scope.loadPartnerPaymentInfo();
}, function (resp) {
commonDialog.alert({
title: 'failed to change Customer Pay for Surcharge for Retail',
content: resp.data.message,
type: 'error'
})
})
}
$scope.toggleRequireCustInfo = function () {
if (!$scope.paymentInfo) {
return;
}
if (!$scope.ctrl.require_custinfo) {
$scope.ctrl.require_custinfo = true;
return;
}
$http.put('/client/partner_info/require_custinfo', {require_custinfo: $scope.paymentInfo.require_custinfo}).then(function () {
}, function (resp) {
commonDialog.alert({
title: 'failed to change require customer Info permission status',
content: resp.data.message,
type: 'error'
})
})
};
$scope.toggleRequireRemark = function () {
if (!$scope.paymentInfo) {
return;
}
if (!$scope.ctrl.require_remark) {
$scope.ctrl.require_remark = true;
return;
}
$http.put('/client/partner_info/require_remark', {require_remark: $scope.paymentInfo.require_remark}).then(function () {
}, function (resp) {
commonDialog.alert({
title: 'failed to change require remark permission status',
content: resp.data.message,
type: 'error'
})
})
};
$scope.myInterval = 2000;
$scope.pcfirst = true;
$scope.bankfirst = true;
$scope.appfirst = true;
$scope.active = 0;
$scope.pcshow = false;
$scope.appshow = false;
$scope.bankshow = false;
var slidesPc = $scope.slidesPc = [];
var slidesPcBank = $scope.slidesBank = [];
var slidesApp = $scope.slidesApp = [];
var addSlidePc = function () {
slidesPc.push({
image: '/static/images/hfpaylink_intro/pc_hf_pay_step1.png',
text: '第一次打开支付链接进行下单,第一步用微信扫码页面弹出的二维码,确认您的身份',
id:0
});
slidesPc.push({
image: '/static/images/hfpaylink_intro/pc_hf_pay_step2.png',
text: '下一步填写订单信息。注意订单金额货币单位是澳元AUD。请认真填写商品名称否则可能导致交易不成功。填写完成最后提交订单。',
id:1
});
slidesPc.push({
image: '/static/images/hfpaylink_intro/pc_hf_pay_step3.png',
text: '页面显示支付二维码使用相应的支付app进行扫码支付。如订单有误请点击"返回上一步"修改订单。',
id:2
});
slidesPc.push({
image: '/static/images/hfpaylink_intro/hf_pay_end.png',
text: '完成支付,跳转到支付成功页面。',
id:3
});
};
var addSlidePcBank = function () {
slidesPcBank.push({
image: '/static/images/hfpaylink_intro/pc_bank_hf_pay_step1.png',
text: '第一次打开支付链接进行下单,第一步用微信扫码页面弹出的二维码,确认您的身份',
id:0
});
slidesPcBank.push({
image: '/static/images/hfpaylink_intro/pc_bank_hf_pay_step2.png',
text: '下一步填写订单信息。注意订单金额货币单位是澳元AUD。请认真填写商品名称否则可能导致交易不成功。填写完成最后提交订单。',
id:1
});
slidesPcBank.push({
image: '/static/images/hfpaylink_intro/pc_bank_hf_pay_step3.png',
text: '提交订单后,页面跳转到对应银行,请填写相关信息完成支付。',
id:2
});
slidesPcBank.push({
image: '/static/images/hfpaylink_intro/hf_pay_end.png',
text: '完成支付,跳转到支付成功页面。',
id:3
});
};
var addSlideApp = function () {
slidesApp.push({
image: '/static/images/hfpaylink_intro/app_bank_hf_pay_step1.png',
text: '使用微信客户端填写订单信息。注意订单金额货币单位是澳元AUD。请认真填写商品名称否则可能导致交易不成功。填写完成最后提交订单。',
id:0
});
slidesApp.push({
image: '/static/images/hfpaylink_intro/app_bank_hf_pay_step2.png',
text: '提交订单后,页面跳转到汇付天下支付页面,请填写相关信息完成支付。',
id:1
});
};
$scope.toPcFirst = function () {
$scope.reset();
if(!$scope.pcfirst) {
return;
}
addSlidePc();
$scope.pcfirst = false;
};
$scope.toBankFirst = function () {
$scope.reset();
if(!$scope.bankfirst) {
return;
}
addSlidePcBank();
$scope.bankfirst = false;
};
$scope.toAppFirst = function () {
$scope.reset();
if(!$scope.appfirst) {
return;
}
addSlideApp();
$scope.appfirst = false;
};
$scope.toPcShow = function () {
$scope.pcshow = true;
};
$scope.toAppShow = function () {
$scope.appshow = true;
};
$scope.toBankShow = function () {
$scope.bankshow = true;
};
$scope.toHide = function () {
$scope.pcshow = false;
$scope.bankshow = false;
$scope.appshow = false;
};
$scope.reset = function () {
slidesPc = $scope.slidesPc = [];
slidesPcBank = $scope.slidesBank = [];
slidesApp = $scope.slidesApp = [];
$scope.myInterval = 2000;
$scope.pcfirst = true;
$scope.bankfirst = true;
$scope.appfirst = true;
$scope.active = 0;
$scope.pcshow = false;
$scope.appshow = false;
$scope.bankshow = false;
};
// 新增需求,商户端刷新支付秘钥
$scope.refreshCredential = function () {
commonDialog.confirm({
title: 'Warning',
content: 'Refresh Credential will expire the current one, ' +
'which will cause the current payment service disabled. ' +
'Are you sure going on?'
}).then(function () {
$http.put('/sys/partners/' + $scope.partner.client_moniker + '/credential_code').then(function () {
$state.reload();
}, function (resp) {
commonDialog.alert({
title: 'Error',
content: resp.data.message,
type: 'error'
})
})
})
};
}]);
app.controller('clientParameterCtrl', ['$scope', '$http', 'commonDialog', 'timezone', function ($scope, $http, commonDialog, timezone) {
$scope.getClientConfig = function () {
$http.get('/client/partner_info').then(function (resp) {
$scope.config = resp.data;
});
};
$scope.timezones = timezone.configs();
$scope.getClientConfig();
$scope.switchNotice = function () {
if (!$scope.config) {
return;
}
$http.put('/client/partner_info/pay_notice', {enable: $scope.config.enable_pay_notice}).then(function () {
$scope.getClientConfig();
}, function (resp) {
commonDialog.alert({title: 'Failed', message: resp.data.message, type: 'error'})
});
};
$scope.switchAuditRefund = function () {
if (!$scope.config) {
return;
}
$http.put('/client/partner_info/audit_refund', {enable: $scope.config.enable_refund_auth}).then(function () {
$scope.getClientConfig();
}, function (resp) {
commonDialog.alert({title: 'Failed', message: resp.data.message, type: 'error'})
});
};
$scope.updateTimeZone = function () {
if (!$scope.config) {
return;
}
$http.put('/client/partner_info/timezone', {timezone: $scope.config.timezone}).then(function () {
$scope.getClientConfig();
}, function (resp) {
commonDialog.alert({title: 'Failed', message: resp.data.message, type: 'error'})
})
}
}]);
app.controller('clientClearingConfigCtrl', ['$scope', '$http','$state','commonDialog', function ($scope, $http,$state,commonDialog) {
$scope.bankCtrl = {rate_name:'Wechat'};
$scope.init = {manual:false};
$scope.getBankAccount = function () {
$http.get('/client/partner_info/bank_account').then(function (resp) {
$scope.bankaccount = resp.data;
});
};
$scope.getBankAccount();
$scope.getRates = function () {
$http.get('/client/partner_info/rates').then(function (resp) {
$scope.rates = resp.data;
angular.forEach($scope.rates, function (rate) {
rate.active_time = new Date(rate.active_time);
rate.expiry_time = new Date(rate.expiry_time);
})
});
};
$scope.manualSettle = function (manualSettle) {
if(!$scope.init.manual){
$scope.init.manual = true;
return;
}
var waring_messsage;
if(manualSettle){
waring_messsage = "Open"
}else {
waring_messsage = "Close"
}
commonDialog.confirm({
title: 'Confirmation',
content: 'Are you sure to '+waring_messsage+'?',
}).then(function(){
$http.put('/client/partner_info/manual_settle?'+'manual_settle='+manualSettle).then(function (resp) {
},function (resp) {
commonDialog.alert({title: 'Error!', content: resp.data.message, type: 'error'})
})
},function () {
$state.reload();
});
};
$scope.getRates();
}]);
app.controller('clientSubPartnersCtrl', ['$scope', '$http','partner', function ($scope, $http,partner) {
$scope.partner = partner.data;
$scope.loadSubPartners = function () {
$http.get('/client/partner_info/sub_partners').then(function (resp) {
$scope.subPartners = resp.data;
$scope.subPartners.forEach(function (client) {
if (client.level3Clients) {
client.level3Clients.forEach(function (level3Client) {
$scope.subPartners.push(level3Client);
});
}
})
})
};
$scope.loadSubPartners();
}]);
app.controller('clientDeviceCtrl','newDive','newDeviceDialogCtrl', ['$scope', '$http', 'orderService', 'commonDialog', 'refunder','$filter', '$uibModal', function ($scope, $http, orderService, commonDialog, refunder,$filter,$uibModal) {
$scope.pagination = {};
$scope.params = {};
/**
* 查询设备
* @param page
*/
$scope.listDevices = function (page) {
var params = angular.copy($scope.devsearch) || {};
params.page = page || $scope.pagination.page || 1;
$http.get('/client/partner_info/devices', {params: params}).then(function (resp) {
$scope.pagination = resp.data.pagination;
$scope.devices = resp.data.data;
})
};
$scope.listDevices(1);
$scope.showDeviceOrders = function (dev) {
$scope.params.dev_id = dev.dev_id;
$scope.listOrders(1);
};
$scope.modifyRemark = function (dev) {
commonDialog.inputText({title: 'Input New Remark of device'}).then(function (text) {
$http.put('/client/partner_info/devices/' + dev.dev_id, {remark: text}).then(function () {
$scope.listDevices();
}, function (resp) {
commonDialog.alert({title: 'Update remark failed', content: resp.data.message, type: 'error'});
})
})
};
$scope.disableDevice = function (dev) {
$http.put('/client/partner_info/devices/' + dev.dev_id + '/enable', {enable: false}).then(function () {
$scope.listDevices()
}, function (resp) {
commonDialog.alert({title: 'Failed to disable device', content: resp.data.message, type: 'error'});
});
};
$scope.enableDevice = function (dev) {
$http.put('/client/partner_info/devices/' + dev.dev_id + '/enable', {enable: true}).then(function () {
$scope.listDevices()
}, function (resp) {
commonDialog.alert({title: 'Failed to enable device', content: resp.data.message, type: 'error'});
});
};
$scope.orderPagination = {};
$scope.today = new Date();
$scope.chooseToday = function () {
$scope.params.datefrom = $scope.params.dateto = new Date();
$scope.listOrders(1);
};
$scope.chooseYesterday = function () {
var yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);
$scope.params.datefrom = $scope.params.dateto = yesterday;
$scope.listOrders(1);
};
$scope.chooseLast7Days = function () {
$scope.params.dateto = new Date();
var day = new Date();
day.setDate(day.getDate() - 7);
$scope.params.datefrom = day;
$scope.listOrders(1);
};
$scope.thisMonth = function () {
$scope.params.dateto = new Date();
var monthBegin = new Date();
monthBegin.setDate(1);
$scope.params.datefrom = monthBegin;
$scope.listOrders(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.listOrders(1);
};
$scope.listOrders = function (page) {
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.gateway = [0, 1];
params.page = page || $scope.orderPagination.page || 1;
$http.get('/client/partner_info/trade_logs', {params: params}).then(function (resp) {
$scope.orders = resp.data.data;
$scope.orderPagination = resp.data.pagination;
$scope.analysis = resp.data.analysis;
});
};
$scope.listOrders(1);
$scope.orderDetail = function (order) {
orderService.clientOrderDetail(order)
};
$scope.refundOrder = function (order) {
refunder.refunded(order.order_id)
};
}]);
return app;
});