diff --git a/src/main/ui/static/payment/validation/order-validation.js b/src/main/ui/static/payment/validation/order-validation.js index 683d30057..3df8e518f 100644 --- a/src/main/ui/static/payment/validation/order-validation.js +++ b/src/main/ui/static/payment/validation/order-validation.js @@ -2,316 +2,327 @@ * Created by davep on 2016-09-01. */ define(['angular', 'uiRouter'], function () { - 'use strict' - var app = angular.module('orderValidApp', ['ui.router']) - app.config([ - '$stateProvider', - function ($stateProvider) { - $stateProvider - .state('order_valid', { - url: '/order_validation', - templateUrl: '/static/payment/validation/templates/valid-calendar.html', - controller: 'orderValidCalendarCtrl', - }) - .state('order_valid.report', { - url: '/{date}', - templateUrl: '/static/payment/validation/templates/valid.html', - controller: 'orderValidationCtrl', - }) - .state('order_valid.report_new', { - url: '/new/{date}', - templateUrl: '/static/payment/validation/templates/valid_new.html', - controller: 'orderValidationNewCtrl', - }) - }, - ]) - app.controller('orderValidCalendarCtrl', [ - '$scope', - '$http', - '$filter', - '$state', - 'commonDialog', - function ($scope, $http, $filter, $state, commonDialog) { - $scope.today = new Date() - $scope.loadValidatedDates = function (month) { - let monthStr = $filter('date')(month, 'yyyyMM') - $http.get('/sys/financial/validated_dates/' + monthStr).then(function (resp) { - $scope.validatedDates = resp.data - }) - } - $scope.findReport = function (dateStr) { - if ($scope.validatedDates == null) { - return null - } - let filtered = $scope.validatedDates.filter(rp => rp.date === dateStr) - return filtered.length ? filtered[0] : null - } - $scope.checkDetail = function (date) { - const filterItem = $scope.validatedDates.filter(rp => rp.date === date) - const dateStr = date.replace(/\//g, '') - if (filterItem.length) { - if (filterItem[0].isOld) { - $state.go('order_valid.report', { date: dateStr }) - } else { - sessionStorage.setItem('warningLevel', filterItem[0].warning_level) - $state.go('order_valid.report_new', { date: dateStr }) - } - } else { - commonDialog - .confirm({ - title: 'Confirm', - content: '是否确认重新执行对账?', - }) - .then(function () { - $http - .get('/sys/financial/order_validations/' + dateStr, { - params: { - use_cache: false, - }, - timeout: 300000, + 'use strict' + var app = angular.module('orderValidApp', ['ui.router']) + app.config([ + '$stateProvider', + function ($stateProvider) { + $stateProvider + .state('order_valid', { + url: '/order_validation', + templateUrl: '/static/payment/validation/templates/valid-calendar.html', + controller: 'orderValidCalendarCtrl', }) - .then( - function () { - $state.reload() - }, - function (resp) { - $state.reload() - } - ) - }) - } - } - }, - ]) - // old - app.controller('orderValidationCtrl', [ - '$scope', - '$http', - '$filter', - '$stateParams', - 'commonDialog', - function ($scope, $http, $filter, $stateParams, commonDialog) { - $scope.date = $stateParams.date - $scope.startValid = function (forceRebuild) { - $scope.report = { loading: true } - $http - .get('/sys/financial/order_validations/' + $scope.date, { - params: { - use_cache: !forceRebuild, - }, - timeout: 300000, - }) - .then( - function (resp) { - $scope.report = resp.data - $scope.notExistsKeys = [] - $scope.notEqualsKeys = [] - angular.forEach($scope.report.not_exists, function (item) { - angular.forEach(item, function (val, key) { - if ($scope.notExistsKeys.indexOf(key) < 0) { - $scope.notExistsKeys.push(key) - } + .state('order_valid.report', { + url: '/{date}', + templateUrl: '/static/payment/validation/templates/valid.html', + controller: 'orderValidationCtrl', + }) + .state('order_valid.report_new', { + url: '/new/{date}', + templateUrl: '/static/payment/validation/templates/valid_new.html', + controller: 'orderValidationNewCtrl', }) - }) - angular.forEach($scope.report.not_equals, function (item) { - angular.forEach(item, function (val, key) { - if ($scope.notExistsKeys.indexOf(key) < 0) { - $scope.notExistsKeys.push(key) - } + }, + ]) + app.controller('orderValidCalendarCtrl', [ + '$scope', + '$http', + '$filter', + '$state', + 'commonDialog', + function ($scope, $http, $filter, $state, commonDialog) { + $scope.today = new Date() + $scope.loadValidatedDates = function (month) { + let monthStr = $filter('date')(month, 'yyyyMM') + $http.get('/sys/financial/validated_dates/' + monthStr).then(function (resp) { + $scope.validatedDates = resp.data }) - }) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) - $scope.report = null } - ) - } - $scope.startValid(false) + $scope.findReport = function (dateStr) { + if ($scope.validatedDates == null) { + return null + } + let filtered = $scope.validatedDates.filter(rp => rp.date === dateStr) + return filtered.length ? filtered[0] : null + } + $scope.checkDetail = function (date) { + const filterItem = $scope.validatedDates.filter(rp => rp.date === date) + const dateStr = date.replace(/\//g, '') + if (filterItem.length) { + if (filterItem[0].isOld) { + $state.go('order_valid.report', {date: dateStr}) + } else { + sessionStorage.setItem('warningLevel', filterItem[0].warning_level) + $state.go('order_valid.report_new', {date: dateStr}) + } + } else { + commonDialog + .confirm({ + title: 'Confirm', + content: '是否确认重新执行对账?', + }) + .then(function () { + $http + .get('/sys/financial/order_validations/' + dateStr, { + params: { + use_cache: false, + }, + timeout: 300000, + }) + .then( + function () { + $state.reload() + }, + function (resp) { + $state.reload() + } + ) + }) + } + } + }, + ]) + // old + app.controller('orderValidationCtrl', [ + '$scope', + '$http', + '$filter', + '$stateParams', + 'commonDialog', + function ($scope, $http, $filter, $stateParams, commonDialog) { + $scope.date = $stateParams.date + $scope.startValid = function (forceRebuild) { + $scope.report = {loading: true} + $http + .get('/sys/financial/order_validations/' + $scope.date, { + params: { + use_cache: !forceRebuild, + }, + timeout: 300000, + }) + .then( + function (resp) { + $scope.report = resp.data + $scope.notExistsKeys = [] + $scope.notEqualsKeys = [] + angular.forEach($scope.report.not_exists, function (item) { + angular.forEach(item, function (val, key) { + if ($scope.notExistsKeys.indexOf(key) < 0) { + $scope.notExistsKeys.push(key) + } + }) + }) + angular.forEach($scope.report.not_equals, function (item) { + angular.forEach(item, function (val, key) { + if ($scope.notExistsKeys.indexOf(key) < 0) { + $scope.notExistsKeys.push(key) + } + }) + }) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + $scope.report = null + } + ) + } + $scope.startValid(false) - $scope.fixReport = function () { - var datePattern = $filter('date')($scope.valid.date, 'yyyyMMdd') - $http - .get('/sys/financial/order_validations', { - params: { - date: datePattern, - fix: true, - }, - }) - .then( - function (resp) { - commonDialog.alert({ title: 'Success', content: '修复完毕', type: 'success' }) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) + $scope.fixReport = function () { + var datePattern = $filter('date')($scope.valid.date, 'yyyyMMdd') + $http + .get('/sys/financial/order_validations', { + params: { + date: datePattern, + fix: true, + }, + }) + .then( + function (resp) { + commonDialog.alert({title: 'Success', content: '修复完毕', type: 'success'}) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) } - ) - } - }, - ]) - // new - app.controller('orderValidationNewCtrl', [ - '$scope', - '$http', - '$stateParams', - 'commonDialog', - '$uibModal', - function ($scope, $http, $stateParams, commonDialog, $uibModal) { - // 清除sessionStorage - $scope.$on('$destroy', function () { - sessionStorage.clear() - }) - $scope.date = angular.copy($stateParams.date) - $scope.date = $scope.date.substr(0, 4) + '-' + $scope.date.substr(4, 2) + '-' + $scope.date.substr(6) - $scope.warningLevel = JSON.parse(sessionStorage.getItem('warningLevel')) - $scope.validItAgain = function () { - commonDialog - .confirm({ - title: 'Confirm reconciliations', - contentHtml: $sce.trustAsHtml('Agree to send push message'), - }) - .then(function () { - var isSendMessage = document.getElementById('isSendMessage').checked - $http - .get('/sys/financial/order_validations/' + $stateParams.date, { - params: { - use_cache: false, - is_send_message: isSendMessage, - }, - timeout: 300000, - }) - .then($scope.startValid()) + }, + ]) + // new + app.controller('orderValidationNewCtrl', [ + '$scope', + '$http', + '$sce', + '$stateParams', + 'commonDialog', + '$uibModal', + function ($scope, $http, $sce, $stateParams, commonDialog, $uibModal) { + // 清除sessionStorage + $scope.$on('$destroy', function () { + sessionStorage.clear() }) - } - // 加载渠道信息 - $scope.startValid = function () { - $http - .get('/sys/financial/order_validation_new/' + $stateParams.date, { - timeout: 300000, - }) - .then( - function (resp) { - $scope.channelList = [] - for (let key in resp.data) { - const obj = {} - obj.key = key - obj.channel = resp.data[key] - obj.selected = false - $scope.channelList.push(obj) - } - $scope.channelList.map(item => { - const arr = item.channel.filter(f => { - return f.success === false - }) - item.status = arr.length ? 'FAILED' : 'SUCCESS' - item.success = arr.length ? false : true - }) - if (sessionStorage.getItem('channel')) { - const channel = JSON.parse(sessionStorage.getItem('channel')) - channel.map(item => { - $scope.channelList.filter(f => f.key === item.key)[0].selected = item.selected - }) - } else { - $scope.channelList[0].selected = true - } - console.log($scope.channelList) - }, - function (resp) { - commonDialog.alert({ title: 'Error', content: resp.data.message, type: 'error' }) + $scope.date = angular.copy($stateParams.date) + $scope.date = $scope.date.substr(0, 4) + '-' + $scope.date.substr(4, 2) + '-' + $scope.date.substr(6) + $scope.warningLevel = JSON.parse(sessionStorage.getItem('warningLevel')) + $scope.validItAgain = function () { + commonDialog + .confirm({ + title: 'Confirm reconciliations', + contentHtml: $sce.trustAsHtml('Agree to send push message'), + }) + .then(function () { + var isSendMessage = document.getElementById('isSendMessage').checked + $http + .get('/sys/financial/order_validations/' + $stateParams.date, { + params: { + use_cache: false, + is_send_message: isSendMessage, + }, + timeout: 300000, + }) + .then($scope.startValid()) + }) + } + // 加载渠道信息 + $scope.startValid = function () { + $http + .get('/sys/financial/order_validation_new/' + $stateParams.date, { + timeout: 300000, + }) + .then( + function (resp) { + $scope.channelList = [] + for (let key in resp.data) { + const obj = {} + obj.key = key + obj.channel = resp.data[key] + obj.selected = false + $scope.channelList.push(obj) + } + $scope.channelList.map(item => { + const arr = item.channel.filter(f => { + return f.success === false + }) + item.status = arr.length ? 'FAILED' : 'SUCCESS' + item.success = arr.length ? false : true + }) + if (sessionStorage.getItem('channel')) { + const channel = JSON.parse(sessionStorage.getItem('channel')) + channel.map(item => { + $scope.channelList.filter(f => f.key === item.key)[0].selected = item.selected + }) + } else { + $scope.channelList[0].selected = true + } + console.log($scope.channelList) + }, + function (resp) { + commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'}) + } + ) } - ) - } - $scope.startValid() - // 受否折叠 - $scope.fold = function (index) { - $scope.channelList[index].selected = !$scope.channelList[index].selected - } - // 是否清除缓存 - $scope.clear = function (channelName, flag) { - $http.post('/sys/financial/redo_channel_validation/' + $stateParams.date, { channel: channelName, cache: flag }).then( - function () { $scope.startValid() - }, - function (resp) { - commonDialog.alert({ title: 'failed', content: resp.data.message, type: 'error' }) - } - ) - } - // 处理 - $scope.handle = function (merchant) { - sessionStorage.setItem('channel', JSON.stringify($scope.channelList)) - $uibModal - .open({ - templateUrl: '/static/payment/validation/templates/handle_desc.html', - controller: [ - '$scope', - '$http', - 'commonDialog', - 'merchantInfo', - function ($scope, $http, commonDialog, merchantInfo) { - if (merchantInfo.resolve_msg) { - $scope.message = merchantInfo.resolve_msg - } - $scope.confirm = function () { - $http.post('/sys/financial/mark/resolve/message', { log_id: merchantInfo.log_id, message: $scope.message }).then( + // 受否折叠 + $scope.fold = function (index) { + $scope.channelList[index].selected = !$scope.channelList[index].selected + } + // 是否清除缓存 + $scope.clear = function (channelName, flag) { + $http.post('/sys/financial/redo_channel_validation/' + $stateParams.date, { + channel: channelName, + cache: flag + }).then( function () { - $scope.$close() + $scope.startValid() }, function (resp) { - commonDialog.alert({ title: 'failed', content: resp.data.message, type: 'error' }) + commonDialog.alert({title: 'failed', content: resp.data.message, type: 'error'}) } - ) + ) + } + // 处理 + $scope.handle = function (merchant) { + sessionStorage.setItem('channel', JSON.stringify($scope.channelList)) + $uibModal + .open({ + templateUrl: '/static/payment/validation/templates/handle_desc.html', + controller: [ + '$scope', + '$http', + 'commonDialog', + 'merchantInfo', + function ($scope, $http, commonDialog, merchantInfo) { + if (merchantInfo.resolve_msg) { + $scope.message = merchantInfo.resolve_msg + } + $scope.confirm = function () { + $http.post('/sys/financial/mark/resolve/message', { + log_id: merchantInfo.log_id, + message: $scope.message + }).then( + function () { + $scope.$close() + }, + function (resp) { + commonDialog.alert({ + title: 'failed', + content: resp.data.message, + type: 'error' + }) + } + ) + } + }, + ], + resolve: { + merchantInfo: [ + '$stateParams', + function () { + return merchant + }, + ], + }, + }) + .result.then(function () { + $scope.startValid() + }) + } + // 下载 + $scope.download = function (merchant, keyName) { + if (merchant != null) { + const params = {} + params.channel = keyName + params.pid = merchant.pid + params.billDate = merchant.bill_date + params.noCache = false + params.billType = '' + window.open( + '/sys/financial/downloadChannelReconciliationFile?billDate=' + + params.billDate + + '&channel=' + + params.channel + + '&noCache=' + + params.noCache + + '&pid=' + + params.pid + + '&billType=' + + params.billType + ) } - }, - ], - resolve: { - merchantInfo: [ - '$stateParams', - function () { - return merchant - }, - ], - }, - }) - .result.then(function () { - $scope.startValid() - }) - } - // 下载 - $scope.download = function (merchant, keyName) { - if (merchant != null) { - const params = {} - params.channel = keyName - params.pid = merchant.pid - params.billDate = merchant.bill_date - params.noCache = false - params.billType = '' - window.open( - '/sys/financial/downloadChannelReconciliationFile?billDate=' + - params.billDate + - '&channel=' + - params.channel + - '&noCache=' + - params.noCache + - '&pid=' + - params.pid + - '&billType=' + - params.billType - ) - } - } - // 查看what - $scope.checkStatus = function (transactionId) { - $http.get('/sys/financial/get/transaction/status/' + transactionId, {}).then( - function (resp) { - commonDialog.alert({ title: resp.data.statusInfo, content: '', type: 'success' }) - }, - function (resp) { - commonDialog.alert({ title: 'failed', content: resp.data.message, type: 'error' }) - } - ) - } - }, - ]) - return app + } + // 查看what + $scope.checkStatus = function (transactionId) { + $http.get('/sys/financial/get/transaction/status/' + transactionId, {}).then( + function (resp) { + commonDialog.alert({title: resp.data.statusInfo, content: '', type: 'success'}) + }, + function (resp) { + commonDialog.alert({title: 'failed', content: resp.data.message, type: 'error'}) + } + ) + } + }, + ]) + return app })