@ -2,316 +2,327 @@
* Created by davep on 2016 - 09 - 01.
* Created by davep on 2016 - 09 - 01.
* /
* /
define ( [ 'angular' , 'uiRouter' ] , function ( ) {
define ( [ 'angular' , 'uiRouter' ] , function ( ) {
'use strict'
'use strict'
var app = angular . module ( 'orderValidApp' , [ 'ui.router' ] )
var app = angular . module ( 'orderValidApp' , [ 'ui.router' ] )
app . config ( [
app . config ( [
'$stateProvider' ,
'$stateProvider' ,
function ( $stateProvider ) {
function ( $stateProvider ) {
$stateProvider
$stateProvider
. state ( 'order_valid' , {
. state ( 'order_valid' , {
url : '/order_validation' ,
url : '/order_validation' ,
templateUrl : '/static/payment/validation/templates/valid-calendar.html' ,
templateUrl : '/static/payment/validation/templates/valid-calendar.html' ,
controller : 'orderValidCalendarCtrl' ,
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 ,
} )
} )
. then (
. state ( 'order_valid.report' , {
function ( ) {
url : '/{date}' ,
$state . reload ( )
templateUrl : '/static/payment/validation/templates/valid.html' ,
} ,
controller : 'orderValidationCtrl' ,
function ( resp ) {
} )
$state . reload ( )
. state ( 'order_valid.report_new' , {
}
url : '/new/{date}' ,
)
templateUrl : '/static/payment/validation/templates/valid_new.html' ,
} )
controller : 'orderValidationNewCtrl' ,
}
}
} ,
] )
// 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 ) {
app . controller ( 'orderValidCalendarCtrl' , [
if ( $scope . notExistsKeys . indexOf ( key ) < 0 ) {
'$scope' ,
$scope . notExistsKeys . push ( key )
'$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 . findReport = function ( dateStr ) {
}
if ( $scope . validatedDates == null ) {
$scope . startValid ( false )
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 ( ) {
$scope . fixReport = function ( ) {
var datePattern = $filter ( 'date' ) ( $scope . valid . date , 'yyyyMMdd' )
var datePattern = $filter ( 'date' ) ( $scope . valid . date , 'yyyyMMdd' )
$http
$http
. get ( '/sys/financial/order_validations' , {
. get ( '/sys/financial/order_validations' , {
params : {
params : {
date : datePattern ,
date : datePattern ,
fix : true ,
fix : true ,
} ,
} ,
} )
} )
. then (
. then (
function ( resp ) {
function ( resp ) {
commonDialog . alert ( { title : 'Success' , content : '修复完毕' , type : 'success' } )
commonDialog . alert ( { title : 'Success' , content : '修复完毕' , type : 'success' } )
} ,
} ,
function ( resp ) {
function ( resp ) {
commonDialog . alert ( { title : 'Error' , content : resp . data . message , type : 'error' } )
commonDialog . alert ( { title : 'Error' , content : resp . data . message , type : 'error' } )
}
)
}
}
)
} ,
}
] )
} ,
// new
] )
app . controller ( 'orderValidationNewCtrl' , [
// new
'$scope' ,
app . controller ( 'orderValidationNewCtrl' , [
'$http' ,
'$scope' ,
'$sce' ,
'$http' ,
'$stateParams' ,
'$stateParams' ,
'commonDialog' ,
'commonDialog' ,
'$uibModal' ,
'$uibModal' ,
function ( $scope , $http , $sce , $stateParams , commonDialog , $uibModal ) {
function ( $scope , $http , $stateParams , commonDialog , $uibModal ) {
// 清除sessionStorage
// 清除sessionStorage
$scope . $on ( '$destroy' , function ( ) {
$scope . $on ( '$destroy' , function ( ) {
sessionStorage . clear ( )
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 ( '<input type="checkbox" id="isSendMessage">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 . date = angular . copy ( $stateParams . date )
// 加载渠道信息
$scope . date = $scope . date . substr ( 0 , 4 ) + '-' + $scope . date . substr ( 4 , 2 ) + '-' + $scope . date . substr ( 6 )
$scope . startValid = function ( ) {
$scope . warningLevel = JSON . parse ( sessionStorage . getItem ( 'warningLevel' ) )
$http
$scope . validItAgain = function ( ) {
. get ( '/sys/financial/order_validation_new/' + $stateParams . date , {
commonDialog
timeout : 300000 ,
. confirm ( {
} )
title : 'Confirm reconciliations' ,
. then (
contentHtml : $sce . trustAsHtml ( '<input type="checkbox" id="isSendMessage">Agree to send push message' ) ,
function ( resp ) {
} )
$scope . channelList = [ ]
. then ( function ( ) {
for ( let key in resp . data ) {
var isSendMessage = document . getElementById ( 'isSendMessage' ) . checked
const obj = { }
$http
obj . key = key
. get ( '/sys/financial/order_validations/' + $stateParams . date , {
obj . channel = resp . data [ key ]
params : {
obj . selected = false
use _cache : false ,
$scope . channelList . push ( obj )
is _send _message : isSendMessage ,
}
} ,
$scope . channelList . map ( item => {
timeout : 300000 ,
const arr = item . channel . filter ( f => {
} )
return f . success === false
. then ( $scope . startValid ( ) )
} )
} )
item . status = arr . length ? 'FAILED' : 'SUCCESS'
}
item . success = arr . length ? false : true
// 加载渠道信息
} )
$scope . startValid = function ( ) {
if ( sessionStorage . getItem ( 'channel' ) ) {
$http
const channel = JSON . parse ( sessionStorage . getItem ( 'channel' ) )
. get ( '/sys/financial/order_validation_new/' + $stateParams . date , {
channel . map ( item => {
timeout : 300000 ,
$scope . channelList . filter ( f => f . key === item . key ) [ 0 ] . selected = item . selected
} )
} )
. then (
} else {
function ( resp ) {
$scope . channelList [ 0 ] . selected = true
$scope . channelList = [ ]
}
for ( let key in resp . data ) {
console . log ( $scope . channelList )
const obj = { }
} ,
obj . key = key
function ( resp ) {
obj . channel = resp . data [ key ]
commonDialog . alert ( { title : 'Error' , content : resp . data . message , type : 'error' } )
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 ( )
$scope . startValid ( )
} ,
// 受否折叠
function ( resp ) {
$scope . fold = function ( index ) {
commonDialog . alert ( { title : 'failed' , content : resp . data . message , type : 'error' } )
$scope . channelList [ index ] . selected = ! $scope . channelList [ index ] . selected
}
}
)
// 是否清除缓存
}
$scope . clear = function ( channelName , flag ) {
// 处理
$http . post ( '/sys/financial/redo_channel_validation/' + $stateParams . date , {
$scope . handle = function ( merchant ) {
channel : channelName ,
sessionStorage . setItem ( 'channel' , JSON . stringify ( $scope . channelList ) )
cache : flag
$uibModal
} ) . then (
. 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 ( ) {
function ( ) {
$scope . $close ( )
$scope . startValid ( )
} ,
} ,
function ( resp ) {
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
)
}
}
} ,
}
] ,
// 查看what
resolve : {
$scope . checkStatus = function ( transactionId ) {
merchantInfo : [
$http . get ( '/sys/financial/get/transaction/status/' + transactionId , { } ) . then (
'$stateParams' ,
function ( resp ) {
function ( ) {
commonDialog . alert ( { title : resp . data . statusInfo , content : '' , type : 'success' } )
return merchant
} ,
} ,
function ( resp ) {
] ,
commonDialog . alert ( { title : 'failed' , content : resp . data . message , type : 'error' } )
} ,
}
} )
)
. result . then ( function ( ) {
}
$scope . startValid ( )
} ,
} )
] )
}
return app
// 下载
$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
} )
} )