|
|
/**
|
|
|
* Created by lvjian on 2018/10/9.
|
|
|
*/
|
|
|
define(['angular', 'jquery', 'uiRouter', './monitoring/analysis-monitoring'],
|
|
|
function (angular, $) {
|
|
|
'use strict';
|
|
|
|
|
|
const mailTemplate = {
|
|
|
"1": "代购、综合商城类",
|
|
|
"2": "飞机票、旅行社类",
|
|
|
"3": "教育类、中介类",
|
|
|
"4": "Chargeback"
|
|
|
};
|
|
|
|
|
|
const orderTypesProfiles = {
|
|
|
"1": {
|
|
|
label: "微信调单",
|
|
|
platform_trans_textarea: true,
|
|
|
company_name_required: true,
|
|
|
sub_mch_id_required: true,
|
|
|
partner_code_required: true,
|
|
|
date_label: 'Receive Date',
|
|
|
can_send_to_mch: true
|
|
|
},
|
|
|
"2": {
|
|
|
label: "支付宝调单",
|
|
|
platform_trans_textarea: true,
|
|
|
partner_code_required: true,
|
|
|
date_label: 'Receive Date',
|
|
|
require_material: true,
|
|
|
can_send_to_mch: true
|
|
|
},
|
|
|
"3": {
|
|
|
label: "RoyalPay调单",
|
|
|
platform_trans_textarea: true,
|
|
|
send_clean_days: true,
|
|
|
rp_order_type: true,
|
|
|
partner_code_required: true,
|
|
|
date_label: 'Create Date',
|
|
|
can_send_to_mch: true
|
|
|
},
|
|
|
"4": {
|
|
|
label: "警告",
|
|
|
warning_type_required: true,
|
|
|
partner_code_required: true,
|
|
|
date_label: 'Create Date',
|
|
|
can_send_to_mch: true
|
|
|
},
|
|
|
"5": {
|
|
|
label: "通用号调单",
|
|
|
platform_trans_textarea: true,
|
|
|
sub_mch_id_required: true,
|
|
|
date_label: 'Create Date'
|
|
|
},
|
|
|
"6": {
|
|
|
label: "卡支付ChargeBack",
|
|
|
single_channel_order: true,
|
|
|
date_label: 'Receive Date',
|
|
|
can_send_to_mch: true,
|
|
|
require_result: true
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const orderTypesMapForBD = {
|
|
|
"1": "微信调单",
|
|
|
"2": "支付宝调单",
|
|
|
"3": "RoyalPay调单"
|
|
|
};
|
|
|
|
|
|
const royalpayOrderTypesMap = {
|
|
|
"0": "正常调单",
|
|
|
"1": "单纯大金额频繁刷单"
|
|
|
};
|
|
|
|
|
|
const warningOrderTypesMap = {
|
|
|
"0": "单人多次大金额交易",
|
|
|
"1": "退款频繁"
|
|
|
};
|
|
|
|
|
|
const resultTypesMap = {
|
|
|
"0": "未处理",
|
|
|
"1": "已发送邮件",
|
|
|
"2": "已提交材料,等待审核",
|
|
|
"3": "风控初审完成,渠道方审核中",
|
|
|
"4": "材料审核不通过,已打回",
|
|
|
"5": "已处理"
|
|
|
};
|
|
|
|
|
|
const resultTypeSearchMap = {
|
|
|
"0": "未处理",
|
|
|
"1": "资料完善中",
|
|
|
"2": "等待风控",
|
|
|
"3": "风控初审完成,渠道方审核中",
|
|
|
"4": "材料打回",
|
|
|
"5": "已处理"
|
|
|
};
|
|
|
|
|
|
const resultTypeSearchMapForBD = {
|
|
|
"1": "材料待上传",
|
|
|
"2": "材料已提交",
|
|
|
"3": "风控初审完成,渠道方审核中",
|
|
|
"4": "材料打回",
|
|
|
"5": "已处理"
|
|
|
};
|
|
|
|
|
|
const emailStatusMap = {
|
|
|
"0": "未发送",
|
|
|
"1": "已发送",
|
|
|
"2": "打回并已发送",
|
|
|
"3": "已发送催促邮件"
|
|
|
};
|
|
|
|
|
|
const amountSectionMap = {
|
|
|
"0-500": "0-500",
|
|
|
"500-1000": "500-1000",
|
|
|
"1000-1500": "1000-1500",
|
|
|
"1500-2000": "1500-2000",
|
|
|
"2000-2500": "2000-2500",
|
|
|
"2500-3000": "2500-3000",
|
|
|
"3000-3500": "3000-3500",
|
|
|
"3500-4000": "3500-4000",
|
|
|
"4000-4500": "4000-4500"
|
|
|
};
|
|
|
|
|
|
const channelResultArray = [
|
|
|
"关闭支付",
|
|
|
"恢复支付",
|
|
|
"单日10",
|
|
|
"单日200",
|
|
|
"单日300",
|
|
|
"单日500",
|
|
|
"单日1000",
|
|
|
"单日3000",
|
|
|
"单日5000",
|
|
|
"单日10000",
|
|
|
"其他"
|
|
|
];
|
|
|
|
|
|
let app = angular.module('riskBusinessApp', ['ui.router']);
|
|
|
app.config(['$stateProvider', function ($stateProvider) {
|
|
|
$stateProvider.state('analysis_monitoring.risk_business', {
|
|
|
url: '/risk_business',
|
|
|
templateUrl: '/static/analysis/templates/risk_business.html',
|
|
|
cache: false,
|
|
|
controller: 'riskBusinessCtrl'
|
|
|
}).state('analysis_monitoring.risk_business_bd', {
|
|
|
url: '/risk_business_bd',
|
|
|
templateUrl: '/static/analysis/templates/risk_business_bd.html',
|
|
|
cache: false,
|
|
|
controller: 'riskBusinessCtrl'
|
|
|
}).state('analysis_monitoring.risk_business.riskEvent_detail', {
|
|
|
url: '/{risk_id}/detail',
|
|
|
templateUrl: '/static/analysis/templates/riskEvent_detail.html',
|
|
|
controller: 'riskEventDetailCtrl',
|
|
|
resolve: {
|
|
|
riskEvent: ['$http', '$stateParams', function ($http, $stateParams) {
|
|
|
return $http.get('/risk/business/events/' + $stateParams.risk_id);
|
|
|
}]
|
|
|
}
|
|
|
}).state('analysis_monitoring.risk_business.riskEvent_detail.audit_material', {
|
|
|
url: '/audit_material',
|
|
|
templateUrl: '/static/analysis/templates/audit_material.html',
|
|
|
controller: 'auditMaterialCtrl'
|
|
|
}).state('analysis_monitoring.riskEvent_detail_bd', {
|
|
|
url: '/{risk_id}/bd/detail',
|
|
|
templateUrl: '/static/analysis/templates/riskEvent_detail_bd.html',
|
|
|
controller: 'riskEventDetailCtrl',
|
|
|
resolve: {
|
|
|
riskEvent: ['$http', '$stateParams', function ($http, $stateParams) {
|
|
|
return $http.get('/risk/business/events/' + $stateParams.risk_id);
|
|
|
}]
|
|
|
}
|
|
|
}).state('analysis_monitoring.risk_business.new_riskEvent', {
|
|
|
url: '/new_riskEvent',
|
|
|
templateUrl: '/static/analysis/templates/new_riskEvent.html',
|
|
|
controller: 'newRiskEventCtrl'
|
|
|
});
|
|
|
|
|
|
}]);
|
|
|
|
|
|
app.controller('riskBusinessCtrl', ['$scope', '$state', '$http', '$uibModal', '$filter', 'commonDialog', 'industryMap', 'chartParser',
|
|
|
function ($scope, $state, $http, $uibModal, $filter, commonDialog, industryMap, chartParser) {
|
|
|
$scope.orderTypes = orderTypesProfiles;
|
|
|
$scope.orderTypesForBD = orderTypesMapForBD;
|
|
|
$scope.resultTypes = resultTypesMap;
|
|
|
$scope.resultSearchTypes = resultTypeSearchMap;
|
|
|
$scope.resultTypesForBD = resultTypeSearchMapForBD;
|
|
|
$scope.industries = industryMap.configs();
|
|
|
$scope.amountSection = amountSectionMap;
|
|
|
$scope.pagination = {};
|
|
|
$scope.params = {};
|
|
|
let industries = [];
|
|
|
angular.forEach($scope.industries, function (industry) {
|
|
|
industries.push(industry.label);
|
|
|
});
|
|
|
industries.push('未知行业');
|
|
|
$scope.$watch('params', function (newVal) {
|
|
|
console.log('params changed--->', newVal)
|
|
|
});
|
|
|
console.log('riskBusinessCtrl loaded')
|
|
|
// console.log(industries);
|
|
|
// 加载风险注册事件
|
|
|
$scope.loadRiskEvents = function (page) {
|
|
|
let params = angular.copy($scope.params);
|
|
|
params.page = page || $scope.pagination.page || 1;
|
|
|
params.replyEmailDateBegin = $filter('date')(params.replyEmailDateBegin, 'yyyy-MM-dd');
|
|
|
params.replyEmailDateEnd = $filter('date')(params.replyEmailDateEnd, 'yyyy-MM-dd');
|
|
|
params.receiveEmailDateBegin = $filter('date')(params.receiveEmailDateBegin, 'yyyy-MM-dd');
|
|
|
params.receiveEmailDateEnd = $filter('date')(params.receiveEmailDateEnd, 'yyyy-MM-dd');
|
|
|
if (params.section != null) {
|
|
|
let sectionArray = params.section.split('-');
|
|
|
params.startAmount = sectionArray[0];
|
|
|
params.endAmount = sectionArray[1];
|
|
|
}
|
|
|
$http.get('/risk/business/events', {params: params}).then(function (resp) {
|
|
|
$scope.riskEvents = resp.data.data;
|
|
|
$scope.pagination = resp.data.pagination;
|
|
|
});
|
|
|
$http.get('/risk/business/events/analysis/industry', {params: params}).then(function (resp) {
|
|
|
$scope.riskEventsByIndustry = resp.data;
|
|
|
$scope.risk_industry_chart = chartParser.parse(industryAmount(industries), $scope.riskEventsByIndustry);
|
|
|
});
|
|
|
$http.get('/risk/business/events/analysis/amount', {params: params}).then(function (resp) {
|
|
|
$scope.riskEventsByAmount = resp.data;
|
|
|
$scope.risk_amount_chart = chartParser.parse(intervalsAmount(), $scope.riskEventsByAmount);
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
let industryAmount = function (industries) {
|
|
|
return {
|
|
|
chart: {
|
|
|
tooltip: {
|
|
|
trigger: 'item',
|
|
|
formatter: "{a} <br/>{b} : {c}"
|
|
|
},
|
|
|
// color: colors,
|
|
|
legend: {
|
|
|
orient: 'vertical',
|
|
|
left: 'right',
|
|
|
data: industries
|
|
|
}
|
|
|
},
|
|
|
series: [{
|
|
|
basic: {
|
|
|
name: '风控事件单量', type: 'pie',
|
|
|
radius: '80%',
|
|
|
center: ['50%', '58%'],
|
|
|
label: { //饼图图形上的文本标签
|
|
|
normal: {
|
|
|
show: true,
|
|
|
position: 'outer', //标签的位置
|
|
|
textStyle: {
|
|
|
fontWeight: 300,
|
|
|
fontSize: 16 //文字的字体大小
|
|
|
},
|
|
|
formatter: '{d}%'
|
|
|
}
|
|
|
},
|
|
|
itemStyle: {
|
|
|
emphasis: {
|
|
|
shadowBlur: 10,
|
|
|
shadowOffsetX: 0,
|
|
|
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
column: {key: 'amount', name: 'industry'}
|
|
|
}]
|
|
|
}
|
|
|
};
|
|
|
|
|
|
let intervalsAmount = function () {
|
|
|
return {
|
|
|
chart: {
|
|
|
tooltip: {
|
|
|
trigger: 'item',
|
|
|
formatter: "{a} <br/>{b} : {c}"
|
|
|
},
|
|
|
// color: colors,
|
|
|
legend: {
|
|
|
orient: 'vertical',
|
|
|
left: 'right',
|
|
|
data: ['0-500', '500-1000', '1000-1500', '1500-2000', '2000-2500', '2500-3000', '3000-3500', '3500-4000', '4000-4500', '4500-5000', '5000-5500', '5500-6000',
|
|
|
'6000-6500', '6500-7000', '7000-7500', '7500-8000', '8000-8500', '8500-9000', '>9000']
|
|
|
}
|
|
|
},
|
|
|
series: [{
|
|
|
basic: {
|
|
|
name: '风控事件单量', type: 'pie',
|
|
|
radius: '80%',
|
|
|
center: ['50%', '58%'],
|
|
|
label: { //饼图图形上的文本标签
|
|
|
normal: {
|
|
|
show: true,
|
|
|
position: 'outer', //标签的位置
|
|
|
textStyle: {
|
|
|
fontWeight: 300,
|
|
|
fontSize: 16 //文字的字体大小
|
|
|
},
|
|
|
formatter: '{d}%'
|
|
|
}
|
|
|
},
|
|
|
itemStyle: {
|
|
|
emphasis: {
|
|
|
shadowBlur: 10,
|
|
|
shadowOffsetX: 0,
|
|
|
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
column: {key: 'amount', name: 'intervals'}
|
|
|
}]
|
|
|
}
|
|
|
};
|
|
|
|
|
|
$scope.loadRiskEvents(1);
|
|
|
}
|
|
|
]);
|
|
|
|
|
|
app.controller('riskEventDetailCtrl', ['$scope', '$state', '$http', '$uibModal', '$filter', 'Upload', 'commonDialog', 'riskEvent', 'orderService',
|
|
|
function ($scope, $state, $http, $uibModal, $filter, Upload, commonDialog, riskEvent, orderService) {
|
|
|
$scope.ctrl = {
|
|
|
editRemark: false
|
|
|
};
|
|
|
$scope.orderTypes = orderTypesProfiles;
|
|
|
$scope.mailTemplate = mailTemplate;
|
|
|
$scope.resultTypes = resultTypesMap;
|
|
|
$scope.channelResults = channelResultArray;
|
|
|
if (riskEvent.data.is_send_client === 1)
|
|
|
riskEvent.data.is_send_client = true;
|
|
|
$scope.riskEvent = riskEvent.data;
|
|
|
|
|
|
$scope.saveRemark = function () {
|
|
|
$http.put('/risk/business/' + $scope.riskEvent.risk_id + '/remark', {remark: $scope.riskEvent.remark}).then(function (resp) {
|
|
|
$scope.ctrl.editRemark = false;
|
|
|
}, function (resp) {
|
|
|
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
|
|
|
})
|
|
|
};
|
|
|
|
|
|
$scope.checkTemplate = function () {
|
|
|
let url = "";
|
|
|
switch ($scope.riskEvent.mail_template) {
|
|
|
case "1":
|
|
|
url = "https://file.royalpay.com.au/open/2019/03/27/1553658222567_BzfAtsEgsBdMQLl3jGOAlfcYmFUL1F.png";
|
|
|
break;
|
|
|
case "2":
|
|
|
url = "https://file.royalpay.com.au/open/2019/03/27/1553658193577_ddF4FAQYBaMx2oCEUlD2f2NtW3SxYD.png";
|
|
|
break;
|
|
|
case "3":
|
|
|
url = "https://file.royalpay.com.au/open/2019/03/27/1553658238130_VJPI3RNmyKtcOgsV8w8yswUsYMFvGs.png";
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
window.open(url, '_blank');
|
|
|
};
|
|
|
|
|
|
|
|
|
$http.get('/risk/business/process/logs/' + $scope.riskEvent.risk_id).then(function (resp) {
|
|
|
$scope.riskEvent.process_logs = resp.data;
|
|
|
});
|
|
|
|
|
|
// 编辑表格的数据保存对象,重新从源数据复制,从而取消保存操作时不会更新视图
|
|
|
$scope.riskEventEdit = angular.copy(riskEvent.data);
|
|
|
//let index = $scope.riskEvent.order_ids.lastIndexOf(",");
|
|
|
//$scope.riskEvent.order_ids = $scope.riskEvent.order_ids.substring(0, index) + "," + $scope.riskEvent.order_ids.substring(index + 1);
|
|
|
// 获取数据库中对应的渠道字段
|
|
|
let orderChannel = 'enable_';
|
|
|
if ($scope.riskEvent.order_type === 1) {
|
|
|
orderChannel += 'wechat';
|
|
|
} else if ($scope.riskEvent.order_type === 2) {
|
|
|
orderChannel += 'alipay';
|
|
|
} else {
|
|
|
orderChannel = null;
|
|
|
}
|
|
|
|
|
|
$scope.deleteRiskEvent = function () {
|
|
|
commonDialog.confirm({
|
|
|
title: 'Delete This Risk Event',
|
|
|
content: 'Are you sure to delete this risk event?'
|
|
|
}).then(function () {
|
|
|
$http.delete('/risk/business/ban/' + $scope.riskEvent.risk_id).then(function () {
|
|
|
$state.go('analysis_monitoring.risk_business');
|
|
|
commonDialog.alert({
|
|
|
title: 'Delete',
|
|
|
content: 'Risk Event Already Disabled',
|
|
|
type: 'error'
|
|
|
});
|
|
|
}, function (resp) {
|
|
|
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
|
|
|
})
|
|
|
})
|
|
|
};
|
|
|
|
|
|
$scope.commitWaitRiskStatus = function () {
|
|
|
let index = $scope.riskEvent.submit_url.lastIndexOf('=');
|
|
|
if (index < 0)
|
|
|
index = $scope.riskEvent.submit_url.lastIndexOf('/');
|
|
|
let codeKey = $scope.riskEvent.submit_url.substring(index + 1);
|
|
|
commonDialog.confirm({
|
|
|
title: '确认已提交资料',
|
|
|
content: '确认已收到商户资料,更新风控状态为等待风控审核?'
|
|
|
}).then(function () {
|
|
|
$http.put('/risk/business/commitWaitRiskStatus/' + $scope.riskEvent.risk_id + '/' + codeKey).then(function () {
|
|
|
$state.go('analysis_monitoring.risk_business');
|
|
|
commonDialog.alert({title: 'Success', content: '风控状态已修改为等待风控审核状态', type: 'success'});
|
|
|
}, function (resp) {
|
|
|
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
|
|
|
});
|
|
|
|
|
|
})
|
|
|
};
|
|
|
|
|
|
$scope.commitChargebackStatus = function (std) {
|
|
|
commonDialog.confirm({title: '确认操作', content: '当前操作不可逆,并会将风控项标记为办结状态,确认操作?'}).then(function () {
|
|
|
$http.put('/risk/business/chargebacks/' + $scope.riskEvent.risk_id + '/status', {status: std}).then(function () {
|
|
|
$state.reload();
|
|
|
commonDialog.alert({title: 'Success', content: '修改成功', type: success})
|
|
|
}, function (res) {
|
|
|
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
|
|
|
})
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* order_ids在指定位置换行
|
|
|
* @param str
|
|
|
* @param position
|
|
|
* @returns {*}
|
|
|
*/
|
|
|
$scope.splitStr = function (str, position) {
|
|
|
if (str == null || str === '')
|
|
|
return;
|
|
|
let strArr = str.split(",");
|
|
|
let resultStr = '';
|
|
|
for (let i = 0; i < strArr.length; i++) {
|
|
|
resultStr += strArr[i];
|
|
|
if (i === (strArr.length - 1))
|
|
|
break;
|
|
|
if ((i + 1) % position === 0)
|
|
|
resultStr += ", ";
|
|
|
else
|
|
|
resultStr += ",";
|
|
|
}
|
|
|
return resultStr;
|
|
|
};
|
|
|
$scope.riskEvent.order_ids = $scope.splitStr($scope.riskEvent.order_ids, 3);
|
|
|
|
|
|
// order_type转换为string类型是因为前端select控件这样才会显示初值
|
|
|
$scope.riskEventEdit.order_type += "";
|
|
|
|
|
|
// 调单信息
|
|
|
$scope.tradeLogs = $scope.riskEvent.tradeLogs;
|
|
|
|
|
|
// 商户信息
|
|
|
$scope.clientInfo = $scope.riskEvent.clientInfo;
|
|
|
if (orderChannel != null)
|
|
|
$scope.enableChannel = $scope.clientInfo[orderChannel];
|
|
|
|
|
|
// 控制编辑表格的显示
|
|
|
$scope.editFlag = false;
|
|
|
$scope.changeEditFlag = function (editFlag) {
|
|
|
$scope.editFlag = !editFlag;
|
|
|
// 如果是在编辑状态,需要将日期转换为date类型(前端控件需要)
|
|
|
// 如果是在非编辑状态,需要将日期转换为yyyy-MM-dd格式
|
|
|
if ($scope.editFlag) {
|
|
|
$scope.riskEventEdit.receive_email_date = new Date($scope.riskEventEdit.receive_email_date.replace(/-/g, "/"));
|
|
|
$scope.riskEventEdit.reply_email_date = new Date($scope.riskEventEdit.reply_email_date.replace(/-/g, "/"));
|
|
|
} else {
|
|
|
$scope.riskEvent.receive_email_date = $filter('date')($scope.riskEvent.receive_email_date, 'yyyy-MM-dd');
|
|
|
$scope.riskEvent.reply_email_date = $filter('date')($scope.riskEvent.reply_email_date, 'yyyy-MM-dd');
|
|
|
}
|
|
|
};
|
|
|
|
|
|
$scope.save = function (form) {
|
|
|
if (form.$invalid) {
|
|
|
angular.forEach(form, function (item, key) {
|
|
|
if (key.indexOf('$') < 0) {
|
|
|
item.$dirty = true;
|
|
|
}
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
// 保存时需要重新将日期转换为yyyy-MM-dd格式传入后端
|
|
|
$scope.riskEventEdit.reply_email_date = $filter('date')($scope.riskEventEdit.reply_email_date, 'yyyy-MM-dd');
|
|
|
$scope.riskEventEdit.receive_email_date = $filter('date')($scope.riskEventEdit.receive_email_date, 'yyyy-MM-dd');
|
|
|
$http.put('/risk/business/events', $scope.riskEventEdit).then(function (resp) {
|
|
|
commonDialog.alert({
|
|
|
title: 'Success',
|
|
|
content: 'Update riskEvent successfully',
|
|
|
type: 'success'
|
|
|
});
|
|
|
$state.reload('analysis_monitoring.risk_business.riskEvent_detail');
|
|
|
}, function (resp) {
|
|
|
commonDialog.alert({
|
|
|
title: 'Error',
|
|
|
content: resp.data.message,
|
|
|
type: 'error'
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 关停渠道
|
|
|
* @param orderType 调单类型
|
|
|
* @param channelFlag
|
|
|
* @param temporaryFlag 是否临时关停
|
|
|
*/
|
|
|
$scope.updateChannel = function (orderType, channelFlag, temporaryFlag) {
|
|
|
let channel;
|
|
|
if (orderType === "1")
|
|
|
channel = 'wechat';
|
|
|
else if (orderType === "2")
|
|
|
channel = 'alipay';
|
|
|
$scope.riskEvent.temporary_close_channel = temporaryFlag;
|
|
|
commonDialog.confirm({
|
|
|
title: 'Warning',
|
|
|
content: 'Are you sure?'
|
|
|
}).then(function () {
|
|
|
$http.put('/risk/business/channel/' + channel + '/permission/' + channelFlag, $scope.riskEvent).then(function () {
|
|
|
$state.reload('analysis_monitoring.risk_business.riskEvent_detail');
|
|
|
}, function (resp) {
|
|
|
commonDialog.alert({
|
|
|
title: 'Failed to change ' + channel + ' channel permission status',
|
|
|
content: resp.data.message,
|
|
|
type: 'error'
|
|
|
})
|
|
|
});
|
|
|
})
|
|
|
};
|
|
|
|
|
|
// 关停商户
|
|
|
$scope.updateClient = function (isValid, temporaryFlag) {
|
|
|
$scope.riskEvent.temporary_close_merchant = temporaryFlag;
|
|
|
commonDialog.confirm({
|
|
|
title: 'Warning',
|
|
|
content: 'Are you sure?'
|
|
|
}).then(function () {
|
|
|
$http.put('/risk/business/partner/' + isValid, $scope.riskEvent).then(function () {
|
|
|
$state.reload('analysis_monitoring.risk_business.riskEvent_detail');
|
|
|
}, function (resp) {
|
|
|
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
|
|
|
})
|
|
|
})
|
|
|
};
|
|
|
|
|
|
// 发送email
|
|
|
$scope.resendUploadEmail = function () {
|
|
|
commonDialog.confirm({
|
|
|
title: 'Warning',
|
|
|
content: 'Please confirm sending mail.'
|
|
|
}).then(function () {
|
|
|
let url = '/risk/business/' + $scope.riskEvent.risk_id + '/upload_mail';
|
|
|
if ($scope.riskEvent.result_type === 1)
|
|
|
url = '/risk/business/' + $scope.riskEvent.risk_id + '/urge';
|
|
|
$http.put(url).then(function () {
|
|
|
$state.reload();
|
|
|
}, function (resp) {
|
|
|
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
|
|
|
})
|
|
|
})
|
|
|
};
|
|
|
|
|
|
// 订单详情
|
|
|
$scope.showTradeDetail = function (order) {
|
|
|
orderService.managerOrderDetail(order)
|
|
|
};
|
|
|
|
|
|
// 以下为BD上传材料相关
|
|
|
$scope.material = {};
|
|
|
$scope.uploadFile = function (files, index) {
|
|
|
if (files && files.length) {
|
|
|
let urls = [];
|
|
|
let value = 0;
|
|
|
$scope.allMaterialInfo.material[index].fileProgressValue = 0;
|
|
|
for (let i = 0; i < files.length; i++) {
|
|
|
let file = files[i];
|
|
|
Upload.upload({
|
|
|
url: '/attachment/riskFiles',
|
|
|
data: {file: file}
|
|
|
}).then(function (resp) {
|
|
|
urls.push(resp.data.url);
|
|
|
}, function (resp) {
|
|
|
delete $scope.allMaterialInfo.material[index].fileProgressValue;
|
|
|
alert('Upload Failed');
|
|
|
}, function (evt) {
|
|
|
value += parseInt(100 * evt.loaded / evt.total);
|
|
|
$scope.allMaterialInfo.material[index].fileProgressValue = value / (files.length * 2);
|
|
|
})
|
|
|
}
|
|
|
$scope.allMaterialInfo.material[index].uploadFile = urls;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
$scope.submit = function (form) {
|
|
|
let codeKey = $scope.riskEvent.submit_url.substring($scope.riskEvent.submit_url.lastIndexOf('=') + 1) || $scope.riskEvent.submit_url.substring($scope.riskEvent.submit_url.lastIndexOf('/') + 1);
|
|
|
$scope.material.update_time = $filter('date')(new Date(), 'yyyy-MM-dd HH:mm:ss');
|
|
|
$scope.material.risk_id = $scope.riskEvent.risk_id;
|
|
|
for (let i = 0; i < $scope.allMaterialInfo.material.length; i++) {
|
|
|
let key = 'file' + (i + 1) + "_url";
|
|
|
$scope.material[key] = $scope.allMaterialInfo.material[i].uploadFile;
|
|
|
}
|
|
|
$scope.material.description = $scope.allMaterialInfo.description;
|
|
|
$http.post('/risk/upload/' + codeKey, $scope.material).then(function (resp) {
|
|
|
commonDialog.alert({
|
|
|
title: 'Success',
|
|
|
content: 'Submit successfully',
|
|
|
type: 'success'
|
|
|
});
|
|
|
$state.go('analysis_monitoring.risk_business_bd');
|
|
|
}, function (resp) {
|
|
|
commonDialog.alert({
|
|
|
title: 'Error',
|
|
|
content: resp.data.message,
|
|
|
type: 'error'
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 加载提交材料
|
|
|
$scope.loadRiskMaterial = function () {
|
|
|
// $http.get('/risk/business/' + $scope.riskEvent.risk_id + '/material').then(function(resp) {
|
|
|
// $scope.material = resp.data;
|
|
|
// });
|
|
|
|
|
|
$http.get('/risk/business/' + $scope.riskEvent.risk_id + '/all_material_info').then(function (resp) {
|
|
|
$scope.allMaterialInfo = resp.data;
|
|
|
if ($scope.uploadShowFlag) {
|
|
|
$scope.allMaterialInfo.description = '';
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// BD是否可上传
|
|
|
$scope.uploadShowFlag = ($scope.riskEvent.result_type === 1 || $scope.riskEvent.result_type === 3 || $scope.riskEvent.result_type === 4);
|
|
|
//if (!$scope.uploadShowFlag)
|
|
|
$scope.loadRiskMaterial();
|
|
|
}
|
|
|
]);
|
|
|
|
|
|
app.controller('auditMaterialCtrl', ['$scope', '$state', '$http', '$uibModal', '$filter', '$sce', 'commonDialog', 'Upload',
|
|
|
function ($scope, $state, $http, $uibModal, $filter, $sce, commonDialog, Upload) {
|
|
|
|
|
|
// 一键下载功能
|
|
|
$scope.downloadAsZip = function () {
|
|
|
return '/risk/business/' + $scope.riskEvent.risk_id + '/download/materialsAsZIP';
|
|
|
};
|
|
|
|
|
|
// 加载提交材料
|
|
|
// $scope.fileObject = {};
|
|
|
$scope.loadRiskMaterial = function () {
|
|
|
// $http.get('/risk/business/' + $scope.riskEvent.risk_id + '/material').then(function(resp) {
|
|
|
// $scope.riskMaterial = resp.data;
|
|
|
// $scope.file1 = resp.data.file1;
|
|
|
// $scope.file2 = resp.data.file2;
|
|
|
// $scope.file3 = resp.data.file3;
|
|
|
// $scope.file4 = resp.data.file4;
|
|
|
// $scope.file5 = resp.data.file5;
|
|
|
// $scope.file6 = resp.data.file6;
|
|
|
//
|
|
|
// // for (let i = 1; i <= 10; i++) {
|
|
|
// // let key = "file" + i;
|
|
|
// // if (riskMaterial[key + '_url'] != null)
|
|
|
// // $scope.fileObject[key] = riskMaterial[key + '_url'];
|
|
|
// // }
|
|
|
// // $scope.fileLength = Object.keys($scope.fileObject).length;
|
|
|
// })
|
|
|
|
|
|
$http.get('/risk/business/' + $scope.riskEvent.risk_id + '/all_material_info').then(function (resp) {
|
|
|
$scope.riskMaterial = resp.data;
|
|
|
});
|
|
|
};
|
|
|
$scope.loadRiskMaterial();
|
|
|
|
|
|
//审核通过也要可以传图片
|
|
|
$scope.uploadShowFlag = ($scope.riskEvent.result_type === 1 || $scope.riskEvent.result_type === 3 || $scope.riskEvent.result_type === 4);
|
|
|
|
|
|
// 材料上传
|
|
|
$scope.uploadFile = function (files, index) {
|
|
|
if (files && files.length) {
|
|
|
let urls = [];
|
|
|
let value = 0;
|
|
|
$scope.riskMaterial.material[index].fileProgressValue = 0;
|
|
|
for (let i = 0; i < files.length; i++) {
|
|
|
let file = files[i];
|
|
|
Upload.upload({
|
|
|
url: '/attachment/riskFiles',
|
|
|
data: {file: file}
|
|
|
}).then(function (resp) {
|
|
|
urls.push(resp.data.url);
|
|
|
delete $scope.riskMaterial.material[index].fileProgressValue;
|
|
|
}, function (resp) {
|
|
|
delete $scope.riskMaterial.material[index].fileProgressValue;
|
|
|
alert('Upload Failed');
|
|
|
}, function (evt) {
|
|
|
value += parseInt(100 * evt.loaded / evt.total);
|
|
|
$scope.riskMaterial.material[index].fileProgressValue = value / (files.length * 2);
|
|
|
})
|
|
|
}
|
|
|
$scope.riskMaterial.material[index].file = urls;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
$scope.submit = function (form) {
|
|
|
let index = $scope.riskEvent.submit_url.lastIndexOf('=');
|
|
|
if (index < 0)
|
|
|
index = $scope.riskEvent.submit_url.lastIndexOf('/');
|
|
|
let codeKey = $scope.riskEvent.submit_url.substring(index + 1);
|
|
|
$scope.material.update_time = $filter('date')(new Date(), 'yyyy-MM-dd HH:mm:ss');
|
|
|
$scope.material.risk_id = $scope.riskEvent.risk_id;
|
|
|
for (let i = 0; i < $scope.riskMaterial.material.length; i++) {
|
|
|
let key = 'file' + (i + 1) + "_url";
|
|
|
$scope.material[key] = $scope.riskMaterial.material[i].file;
|
|
|
}
|
|
|
$scope.material.description = $scope.riskMaterial.description;
|
|
|
$http.post('/risk/upload/' + codeKey, $scope.material).then(function (resp) {
|
|
|
commonDialog.alert({
|
|
|
title: 'Success',
|
|
|
content: 'Submit successfully',
|
|
|
type: 'success'
|
|
|
});
|
|
|
$state.go('analysis_monitoring.risk_business');
|
|
|
}, function (resp) {
|
|
|
commonDialog.alert({
|
|
|
title: 'Error',
|
|
|
content: resp.data.message,
|
|
|
type: 'error'
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 材料审核
|
|
|
$scope.auditMaterial = function (auditType) {
|
|
|
|
|
|
let url = '/risk/business/events/pass';
|
|
|
let warningMessageHTML = '是否确定<span style="color: green; font-weight: bolder; font-size: 20px;">通过</span>该材料?';
|
|
|
if (auditType === 3) {
|
|
|
commonDialog.confirm({
|
|
|
title: 'Warning',
|
|
|
contentHtml: $sce.trustAsHtml(warningMessageHTML)
|
|
|
}).then(function () {
|
|
|
// $scope.riskEvent.result_type = auditType;
|
|
|
$http.put(url, $scope.riskEvent).then(function (resp) {
|
|
|
commonDialog.alert({title: 'Success', content: "材料已通过!"});
|
|
|
$state.go('^', {}, {reload: true});
|
|
|
}, function (resp) {
|
|
|
commonDialog.alert({
|
|
|
title: 'Error',
|
|
|
content: resp.data.message,
|
|
|
type: 'error'
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
} else if (auditType === 4) {
|
|
|
url = '/risk/business/' + $scope.riskEvent.risk_id + '/refuse';
|
|
|
//warningMessageHTML = '是否确定<span style="color: red; font-weight: bolder; font-size: 20px;">拒绝</span>该材料?'
|
|
|
commonDialog.inputText({title: 'Input Refuse Description', size: 'lg'}).then(function (text) {
|
|
|
$scope.riskEvent.refuse_description = text;
|
|
|
$http.put(url, $scope.riskEvent).then(function () {
|
|
|
commonDialog.alert({title: 'Success', content: "材料已拒绝!"});
|
|
|
$state.go('^', {}, {reload: true});
|
|
|
}, function (resp) {
|
|
|
commonDialog.alert({
|
|
|
title: 'Error',
|
|
|
content: resp.data.message,
|
|
|
type: 'error'
|
|
|
});
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
|
|
|
};
|
|
|
}
|
|
|
]);
|
|
|
|
|
|
app.controller('newRiskEventCtrl', ['$scope', '$state', '$http', '$uibModal', '$filter', 'commonDialog',
|
|
|
function ($scope, $state, $http, $uibModal, $filter, commonDialog) {
|
|
|
$scope.receive_email_date = new Date();
|
|
|
$scope.today = new Date();
|
|
|
$scope.orderTypes = orderTypesProfiles;
|
|
|
$scope.mailTemplate = mailTemplate;
|
|
|
$scope.royapayOrderTypes = royalpayOrderTypesMap;
|
|
|
$scope.warningOrderTypes = warningOrderTypesMap;
|
|
|
$scope.materials = [{key: 0, value: ""}];
|
|
|
$scope.canMinus = false;
|
|
|
$scope.riskEvent = {};
|
|
|
$scope.searchForChargeback = function () {
|
|
|
$scope.riskEvent.order_ids = null;
|
|
|
let channelOrderId = $scope.riskEvent.channel_order_id;
|
|
|
$http.get('/risk/business/chargeback_orders', {params: {channel_order_id: channelOrderId}}).then(function (res) {
|
|
|
$scope.channel_orders = res.data;
|
|
|
}, function (res) {
|
|
|
commonDialog.alert({type: 'error', title: 'Error', content: res.data.message})
|
|
|
});
|
|
|
};
|
|
|
$scope.chooseOrderForChargeback = function (chargebackOrder) {
|
|
|
$scope.riskEvent.order_ids = chargebackOrder.channel_order_id;
|
|
|
$scope.riskEvent.client_moniker = chargebackOrder.client_moniker;
|
|
|
}
|
|
|
$scope.checkTemplate = function () {
|
|
|
let url = "";
|
|
|
switch ($scope.riskEvent.mail_template) {
|
|
|
case "1":
|
|
|
url = "https://file.royalpay.com.au/open/2019/03/27/1553658222567_BzfAtsEgsBdMQLl3jGOAlfcYmFUL1F.png";
|
|
|
break;
|
|
|
case "2":
|
|
|
url = "https://file.royalpay.com.au/open/2019/03/27/1553658193577_ddF4FAQYBaMx2oCEUlD2f2NtW3SxYD.png";
|
|
|
break;
|
|
|
case "3":
|
|
|
url = "https://file.royalpay.com.au/open/2019/03/27/1553658238130_VJPI3RNmyKtcOgsV8w8yswUsYMFvGs.png\n";
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
window.open(url, '_blank');
|
|
|
};
|
|
|
|
|
|
$scope.increase = function ($index) {
|
|
|
$scope.materials.splice($index + 1, 0,
|
|
|
{key: new Date().getTime(), value: ""}); // 用时间戳作为每个item的key
|
|
|
// 增加新的input后允许删除
|
|
|
$scope.canMinus = true;
|
|
|
};
|
|
|
|
|
|
$scope.decrease = function ($index) {
|
|
|
// 如果input大于1,删除
|
|
|
if ($scope.materials.length > 1) {
|
|
|
$scope.materials.splice($index, 1);
|
|
|
}
|
|
|
// 如果回复数为1,不允许删除
|
|
|
if ($scope.materials.length === 1) {
|
|
|
$scope.canMinus = false;
|
|
|
}
|
|
|
};
|
|
|
let array = [];
|
|
|
let validIndex = 0;
|
|
|
$scope.combineMaterials = function () {
|
|
|
for (let i = 0; i < $scope.materials.length; i++) {
|
|
|
let value = $scope.materials[i].value;
|
|
|
if (value === '')
|
|
|
continue;
|
|
|
let cr = {};
|
|
|
cr['question' + (validIndex + 1)] = $scope.materials[i].value;
|
|
|
array[validIndex] = cr;
|
|
|
validIndex++;
|
|
|
}
|
|
|
if (array.length === 0)
|
|
|
return null;
|
|
|
return JSON.stringify(array);
|
|
|
};
|
|
|
|
|
|
$scope.is_send_client = false;
|
|
|
$scope.changeIsSendClient = function (flag) {
|
|
|
$scope.is_send_client = flag
|
|
|
$scope.send_clean_days = flag
|
|
|
};
|
|
|
$scope.send_clean_days = false;
|
|
|
$scope.save = function (form) {
|
|
|
if (form.$invalid) {
|
|
|
angular.forEach(form, function (item, key) {
|
|
|
if (key.indexOf('$') < 0) {
|
|
|
item.$dirty = true;
|
|
|
}
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
$scope.riskEvent.receive_email_date = $scope.receive_email_date;
|
|
|
if ($scope.riskEvent.receive_email_date == null)
|
|
|
$scope.riskEvent.receive_email_date = new Date();
|
|
|
// 默认设置邮件回复截止日期为收到邮件的七天后,如果是内部调单,设置三天后
|
|
|
let replyDeadline = angular.copy($scope.riskEvent.receive_email_date);
|
|
|
if ($scope.riskEvent.order_type > 2)
|
|
|
replyDeadline.setDate(replyDeadline.getDate() + 3);
|
|
|
else
|
|
|
replyDeadline.setDate(replyDeadline.getDate() + 7);
|
|
|
$scope.riskEvent.reply_email_date = $filter('date')(replyDeadline, 'yyyy-MM-dd');
|
|
|
|
|
|
$scope.riskEvent.receive_email_date = $filter('date')($scope.riskEvent.receive_email_date, 'yyyy-MM-dd');
|
|
|
|
|
|
$scope.riskEvent.alipay_materials = $scope.combineMaterials();
|
|
|
|
|
|
$scope.riskEvent.is_send_client = $scope.is_send_client;
|
|
|
|
|
|
$scope.riskEvent.send_clean_days = $scope.send_clean_days;
|
|
|
|
|
|
let saveRiskBtn = document.getElementById('save-risk-btn');
|
|
|
let saveRiskBtnInnerHtmlBak = saveRiskBtn.innerHTML;
|
|
|
saveRiskBtn.disabled = true;
|
|
|
saveRiskBtn.innerHTML = "<i class='fa fa-spinner fa-spin '></i> Processing";
|
|
|
$http.post('/risk/business/events', $scope.riskEvent).then(function (resp) {
|
|
|
saveRiskBtn.innerHTML = saveRiskBtnInnerHtmlBak;
|
|
|
saveRiskBtn.disabled = false;
|
|
|
commonDialog.alert({
|
|
|
title: 'Success',
|
|
|
content: 'Register new riskEvent successfully',
|
|
|
type: 'success'
|
|
|
});
|
|
|
$state.go('^', {}, {reload: true});
|
|
|
}, function (resp) {
|
|
|
saveRiskBtn.innerHTML = saveRiskBtnInnerHtmlBak;
|
|
|
saveRiskBtn.disabled = false;
|
|
|
commonDialog.alert({
|
|
|
title: 'Error',
|
|
|
content: resp.data.message,
|
|
|
type: 'error'
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
$scope.partnerParam = {};
|
|
|
$scope.loadParnters = function () {
|
|
|
$scope.partnerParam.sub_merchant_id = $scope.riskEvent.sub_merchant_id;
|
|
|
$http.get('/risk/business/partners', {params: $scope.partnerParam}).then(function (resp) {
|
|
|
$scope.partners = resp.data;
|
|
|
if ($scope.partners != null && $scope.partners.length > 0) {
|
|
|
// 由于通用号调单可能无法提供商户client_moniker,所以后台无法查询到订单
|
|
|
if ($scope.partners.length === 1 || $scope.riskEvent.order_type !== 5)
|
|
|
$scope.riskEvent.client_moniker = $scope.partners[0].client_moniker;
|
|
|
} else {
|
|
|
commonDialog.confirm({
|
|
|
title: 'Warning',
|
|
|
content: '该微信子商户号下暂时没有商户或者商户被禁用,是否继续?'
|
|
|
}).then(function () {
|
|
|
// 点击确定
|
|
|
$scope.riskEvent.client_moniker = null;
|
|
|
}, function () {
|
|
|
// 点击取消
|
|
|
$scope.riskEvent.sub_merchant_id = '';
|
|
|
});
|
|
|
}
|
|
|
if ($scope.partners != null && $scope.partners.length > 1 && $scope.riskEvent.order_type !== 5)
|
|
|
commonDialog.confirm({
|
|
|
title: 'Warning',
|
|
|
content: '该微信子商户号下有多个商户,是否将调单类型改为通用号调单?'
|
|
|
}).then(function () {
|
|
|
$scope.riskEvent.order_type = 5 + "";
|
|
|
});
|
|
|
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
]);
|
|
|
|
|
|
// 调单类型过滤器
|
|
|
app.filter('orderType', function () {
|
|
|
return function (type) {
|
|
|
let profile = orderTypesProfiles[type];
|
|
|
return profile == null ? null : profile.label;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
app.filter('templateType', function () {
|
|
|
return function (type) {
|
|
|
return mailTemplate[type];
|
|
|
}
|
|
|
});
|
|
|
|
|
|
app.filter('royalPayOrderType', function () {
|
|
|
return function (type) {
|
|
|
return royalpayOrderTypesMap[type];
|
|
|
}
|
|
|
});
|
|
|
|
|
|
app.filter('warningOrderType', function () {
|
|
|
return function (type) {
|
|
|
return warningOrderTypesMap[type];
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 处理结果过滤器
|
|
|
app.filter('resultType', function () {
|
|
|
return function (type, resultTypesMap) {
|
|
|
return resultTypesMap[type];
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 邮件发送状态过滤器
|
|
|
app.filter('emailStatus', function () {
|
|
|
return function (status) {
|
|
|
return emailStatusMap[status];
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return app;
|
|
|
});
|