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.

409 lines
18 KiB

/**
* Created by yixian on 2016-07-06.
*/
define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
'use strict';
var app = angular.module('devtoolsApp', ['ui.router', 'ui.bootstrap']);
app.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('devtools', {
url: '/dev_tools',
templateUrl: '/static/config/devtools/templates/root.html',
controller: ['$scope', function ($scope) {
}]
}).state('devtools.fix_transaction', {
url: '/fix_transaction',
templateUrl: '/static/config/devtools/templates/fix_transaction.html',
controller: 'devFixTransactionCtrl'
}).state('devtools.order_check', {
url: '/order_check',
templateUrl: '/static/config/devtools/templates/order_check.html',
controller: 'devOrderCheckCtrl'
}).state('devtools.generate_austrac', {
url: '/austrac_generate',
templateUrl: '/static/config/devtools/templates/generate_austrac_data.html',
controller: 'devAustracDataCtrl'
}).state('devtools.mail', {
url: '/mail',
templateUrl: '/static/config/devtools/templates/mail.html',
controller: 'devMailCtrl'
}).state('devtools.weekreport', {
url: '/weekreport',
templateUrl: '/static/config/devtools/templates/weekreport.html',
controller: 'devWeekReportCtrl'
}).state('devtools.dailyreport', {
url: '/dailyreport',
templateUrl: '/static/config/devtools/templates/dailyreport.html',
controller: 'dailyReportCtrl'
}).state('devtools.auth_message', {
url: '/auth_message',
templateUrl: '/static/config/devtools/templates/auth_message.html',
controller: 'devAuthMessageCtrl'
}).state('devtools.send_message', {
url: '/send_message',
templateUrl: '/static/config/devtools/templates/send_message.html',
controller: 'devSendMessageCtrl'
}).state('devtools.wechat_message', {
url: '/wechat_message',
templateUrl: '/static/config/devtools/templates/wechat_message.html',
controller: 'wechatMessageCtrl'
}).state('devtools.phone_top_up', {
url: '/phone_top_up',
templateUrl: '/static/config/devtools/templates/phone_top_up.html',
controller: 'phonetopupCtrl'
}).state('devtools.aliforexcel', {
url: '/aliforexcel',
templateUrl: '/static/config/devtools/templates/aliforexcel.html',
controller: 'aliforexcelCtrl'
}).state('devtools.hfClearAmount', {
url: '/hfClearAmount',
templateUrl: '/static/config/devtools/templates/hfClearAmount.html',
controller: 'hfClearAmountCtrl'
}).state('devtools.hfupdate', {
url: '/hfupdate',
templateUrl: '/static/config/devtools/templates/hfupdate.html',
controller: 'hfupdateCtrl'
}).state('devtools.rpayupdate', {
url: '/rpayupdate',
templateUrl: '/static/config/devtools/templates/rpayupdate.html',
controller: 'rpayupdateCtrl'
})
}]);
app.controller('devManualRefundCtrl', ['$scope', '$http', 'commonDialog', function ($scope, $http, commonDialog) {
$scope.sendRefund = function () {
var refund = angular.copy($scope.refund);
refund.amount = Math.floor(refund.amount * 100);
$http.get('/dev/manual_refund', {params: refund}).then(function (resp) {
$scope.refund = {};
commonDialog.alert({title: 'SUCCESS', content: resp.data.xml, type: 'success'})
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
})
}
}]);
// app.controller('devWxSettlementsCtrl', ['$scope', '$http', '$filter', 'commonDialog', function ($scope, $http, $filter, commonDialog) {
// $scope.params = {from: new Date(), to: new Date()};
// $scope.loadSettlements = function () {
// var params = {};
// params.from = $filter('date')($scope.params.from, 'yyyyMMdd');
// params.to = $filter('date')($scope.params.to, 'yyyyMMdd');
// $http.get('/dev/wx_settlements', {params: params}).then(function (resp) {
// $scope.settleLogs = resp.data;
// }, function (resp) {
// commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
// })
// }
// }]);
app.controller('devFixTransactionCtrl', ['$scope', '$http', '$uibModal', 'commonDialog', function ($scope, $http, $uibModal, commonDialog) {
$scope.fixTransactions = function () {
$http.put('/dev/fix_transaction').then(function () {
commonDialog.alert({title: 'Success', content: 'fixed', type: 'success'})
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
})
};
$scope.resend = {};
$scope.resendNotify = function () {
if (!$scope.resend.date) {
return;
}
$http.put('/dev/notify_resend', $scope.resend).then(function () {
commonDialog.alert({title: 'Success', content: 'fixed', type: 'success'})
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
})
};
$scope.resendLuckyMoney = function () {
$http.put('/dev/activities/luckymoney/resend').then(function (resp) {
$uibModal.open({
templateUrl: '/static/config/devtools/templates/luckymoney_result.html',
controller: ['$scope', 'redpacks', function ($scope, redpacks) {
$scope.redpacks = redpacks;
}],
size: 'lg',
resolve: {
redpacks: function () {
return resp.data;
}
}
})
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
});
};
}]);
app.controller('devOrderCheckCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.search = {};
$scope.check = function () {
$scope.errmsg = null;
$scope.xmlStr = null;
if (!$scope.search.order_id) {
return;
}
$http.get('/dev/orders/' + $scope.search.order_id + '/detail').then(function (resp) {
$scope.xmlStr = resp.data.xml;
}, function (resp) {
$scope.errmsg = resp.data.message;
})
};
$scope.checkRefund = function () {
$scope.errmsg = null;
$scope.xmlStr = null;
if (!$scope.search.order_id) {
return;
}
$http.get('/dev/order_refunds/' + $scope.search.order_id + '/detail').then(function (resp) {
$scope.xmlStr = resp.data.xml;
}, function (resp) {
$scope.errmsg = resp.data.message;
})
}
}]);
app.controller('devAustracDataCtrl', ['$scope', '$filter', '$http', 'commonDialog', function ($scope, $filter, $http, commonDialog) {
$scope.params = {};
$scope.generate = function () {
var params = angular.copy($scope.params);
if (params.datefrom) {
params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd');
} else {
commonDialog.alert({title: 'Error', content: "开始时间不能为空", type: 'error'});
return;
}
if (params.dateto) {
params.dateto = $filter('date')(params.dateto, 'yyyyMMdd');
} else {
commonDialog.alert({title: 'Error', content: "结束时间不能为空", type: 'error'});
return;
}
$http.get('/dev/austrac/generate', {params: params}).then(function () {
commonDialog.alert({title: 'Success', content: 'Generate OK', type: 'success'})
}, function (resp) {
commonDialog.alert({title: 'Success', content: resp.data.message, type: 'error'})
});
};
}]);
app.controller('devSettlementCtrl', ['$scope', '$http', '$filter', function ($scope, $http, $filter) {
$scope.loadMonthLog = function (month) {
var monthStr = $filter('date')(month, 'yyyyMM');
$http.get('/dev/settlement/month/' + monthStr + '/settled_dates').then(function (resp) {
$scope.settledDates = resp.data;
});
}
}]);
app.controller('devMailCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.sendTestMail = function () {
$http.post('/dev/mail')
}
}]);
app.controller('devWeekReportCtrl', ['$scope', '$http', '$filter', function ($scope, $http, $filter) {
$scope.reportconfig = {send_msg: false};
$scope.generateWeekReport = function () {
var data = angular.copy($scope.reportconfig);
data.date = $filter('date')(data.date, 'yyyy-MM-dd');
$http.post('/analysis/week_reports/generate', data).then(function () {
alert('ok')
}, function (resp) {
alert(resp.data.message);
})
}
}]);
app.controller('dailyReportCtrl', ['$scope', '$http', '$filter', function ($scope, $http, $filter) {
$scope.dailyreportconfig = {send_msg: false};
$scope.generateDailyReport = function () {
var data = angular.copy($scope.dailyreportconfig);
data.date = $filter('date')(data.date, 'yyyy-MM-dd');
$http.post('/analysis/daily_reports/generate', data).then(function () {
alert('ok')
}, function (resp) {
alert(resp.data.message);
})
}
}]);
app.controller('devAuthMessageCtrl', ['$scope', '$http', '$filter', function ($scope, $http, $filter) {
$scope.sendAuthMessage = function () {
$http.get('/simpleclient/auth_message').then(function (resp) {
alert('ok')
}, function (resp) {
alert(resp.data.message);
})
}
}]);
app.controller('devSendMessageCtrl', ['$scope', '$http', '$filter', function ($scope, $http, $filter) {
$scope.params = {type:'Merchant'};
$scope.sendMessage = function () {
var params = angular.copy($scope.params);
$http.put('/dev/send_message',params).then(function (resp) {
alert('ok');
}, function (resp) {
alert(resp.data.message);
})
}
}]);
app.controller('phonetopupCtrl', ['$scope', '$http', '$filter', function ($scope, $http, $filter) {
$scope.topUp = function () {
var params = angular.copy($scope.params);
$http.get('/top_up/recharge',{params: params}).then(function (resp) {
alert('ok');
}, function (resp) {
alert(resp.data.message);
})
}
}]);
app.controller('wechatMessageCtrl', ['$scope', '$http', '$filter', function ($scope, $http, $filter) {
$scope.params = {};
$scope.send_merchant_message = function () {
$scope.params.title = $scope.params.m_title;
$scope.params.content = $scope.params.m_content;
if (null == $scope.params.partner_code || angular.equals({}, $scope.params.partner_code)){
alert("请输入partnerCode");
return;
}
if (null == $scope.params.title || angular.equals({}, $scope.params.title)){
alert("请输入标题");
return;
}
if (null == $scope.params.content || angular.equals({}, $scope.params.content)){
alert("请输入内容")
return;
}
var params = angular.copy($scope.params);
$http.put('/dev/send_merchant_message',params).then(function (resp) {
alert('ok');
}, function (resp) {
alert(resp.data.message);
})
};
$scope.send_roles_message = function () {
$scope.params.title = $scope.params.r_title;
$scope.params.content = $scope.params.r_content;
if (null == $scope.params.title || angular.equals({}, $scope.params.title)){
alert("请输入标题");
return;
}
if (null == $scope.params.content || angular.equals({}, $scope.params.content)){
alert("请输入内容")
return;
}
var params = angular.copy($scope.params);
$http.put('/dev/send_roles_message',params).then(function (resp) {
alert('ok');
}, function (resp) {
alert(resp.data.message);
})
};
$scope.send_personal_message = function () {
$scope.params.title = $scope.params.p_title;
$scope.params.content = $scope.params.p_content;
if (null == $scope.params.open_id || angular.equals({}, $scope.params.open_id)){
alert("请输入openId");
return;
}
if (null == $scope.params.title || angular.equals({}, $scope.params.title)){
alert("请输入标题");
return;
}
if (null == $scope.params.content || angular.equals({}, $scope.params.content)){
alert("请输入内容")
return;
}
var params = angular.copy($scope.params);
$http.put('/dev/send_personal_message',params).then(function (resp) {
alert('ok');
}, function (resp) {
alert(resp.data.message);
})
}
}]);
/* app.controller('orgusertestCtrl', ['$scope', '$http', '$filter','commonDialog', function ($scope, $http, $filter,commonDialog) {
$scope.regist = function () {
$http.post('/dev/orgusertest',{client_moniker: $scope.company}).then(function (resp) {
commonDialog.alert({title: 'SUCCESS', content:"注册成功", type: 'success'})
}, function (resp) {
commonDialog.alert({title: 'Error', content: "商品编号已存在", type: 'Error'})
})
}
}]);*/
app.controller('aliforexcelCtrl', ['$scope', '$filter', function ($scope, $filter) {
$scope.params = {};
var str = $filter('date')(new Date(), 'yyyyMMdd');
var oDate = new Date(str.slice(0, 4), str.slice(4, 6) - 1, str.slice(-2));
var oDay = oDate.getDay();
var oNum = oDate.getDate();
var bWeek1 =new Date(str.slice(0, 4), str.slice(4, 6) - 1, oNum-oDay-6);
var bWeek2 =new Date(str.slice(0, 4), str.slice(4, 6) - 1, oNum-oDay);
$scope.params.datefrom = bWeek1;
$scope.params.dateto = bWeek2;
$scope.Export = function () {
var params = angular.copy($scope.params);
params.datefrom = $filter('date')(params.datefrom, 'yyyy-MM-dd');
params.dateto = $filter('date')(params.dateto, 'yyyy-MM-dd');
var url = '/dev/aliforexcel';
var connectSymbol = '?';
url += connectSymbol + 'datefrom=' + params.datefrom + '&' + 'dateto=' + params.dateto;
return url;
}
}]);
app.controller('hfClearAmountCtrl', ['$scope', '$http','$filter', function ($scope, $http,$filter) {
$scope.params = {};
$scope.totalhide = true;
$scope.selecttotal = true;
$scope.select = function () {
$scope.totalhide = true;
$scope.selecttotal = false;
var params = angular.copy($scope.params);
params.datefrom = $filter('date')(params.datefrom, 'yyyy-MM-dd');
params.dateto = $filter('date')(params.dateto, 'yyyy-MM-dd');
$http.get('/dev/hfClearAmount',{params:params}).then(function (resp) {
$scope.hfClearResult =resp.data;
$scope.totalhide = false;
$scope.selecttotal = true;
}, function (resp) {
alert(resp.data.message);
})
}
}]);
app.controller('hfupdateCtrl', ['$scope', '$http','$filter', function ($scope, $http,$filter) {
$scope.selecttotal = true;
$scope.select = function () {
$scope.totalhide = true;
$scope.selecttotal = false;
$http.get('/dev/hfUpdate').then(function (resp) {
alert(resp.data);
$scope.totalhide = false;
$scope.selecttotal = true;
}, function (resp) {
alert(resp.data.message);
})
}
}]);
app.controller('rpayupdateCtrl', ['$scope', '$http','$filter', function ($scope, $http,$filter) {
$scope.selecttotal = true;
$scope.update = function () {
$scope.totalhide = true;
$scope.selecttotal = false;
$http.put('/dev/rpayUpdate').then(function (resp) {
$scope.totalhide = false;
$scope.selecttotal = true;
}, function (resp) {
alert(resp.data.message);
})
}
}]);
return app;
});