wechatRefundOrderCtrl.js 5.24 KB
(function(angular) {
	function wechatRefundOrderCtrl($scope, DTOptionsBuilder, DTColumnBuilder, wechatauthService, $uibModal, $filter, $state,Utils) {		
		
		$scope.filter={
	        createTime:{},
	        refundSuccessTime:{},
	    };

		$scope.createOptions = {
			opens : 'right',
			eventHandlers : {
				'apply.daterangepicker' : function(ev, picker) {
					$scope.filter.createTime.startDate = picker.startDate;
					$scope.filter.createTime.endDate = picker.endDate;
				},
				'cancel.daterangepicker' : function(ev, picker) {
					$scope.filter.createTime.startDate = null;
					$scope.filter.createTime.endDate = null;
					$('#createTime').val('');
				}
			}
		};
		
		$scope.refundOptions = {
			opens : 'right',
			eventHandlers : {
				'apply.daterangepicker' : function(ev, picker) {
					$scope.filter.refundSuccessTime.startDate = picker.startDate;
					$scope.filter.refundSuccessTime.endDate = picker.endDate;
				},
				'cancel.daterangepicker' : function(ev, picker) {
					$scope.filter.refundSuccessTime.startDate = null;
					$scope.filter.refundSuccessTime.endDate = null;
					$('#refundSuccessTime').val('');
				}
			}
		};
		
		$scope.dtColumns = [	
			DTColumnBuilder.newColumn('createdDate').withOption('width',160).withTitle('退款申请时间').renderWith(function(e, dt, node, config){
				return $filter('date')(new Date(node.createdDate), 'yyyy-MM-dd HH:mm:ss');
			}),
		    DTColumnBuilder.newColumn('refundSuccessTime').withOption('width',160).withTitle('退款成功时间').renderWith(function(e, dt, node, config){
            	return $filter('date')(new Date(node.refundSuccessTime), 'yyyy-MM-dd HH:mm:ss');
            }),
		    DTColumnBuilder.newColumn('outTradeNo').withOption('width',160).withTitle('交易单号'),
		    DTColumnBuilder.newColumn('outRefundNo').withOption('width',220).withTitle('商户退款单号'),
		    DTColumnBuilder.newColumn('transactionId').withOption('width',220).withTitle('微信交易号'),
		    DTColumnBuilder.newColumn('refundId').withOption('width',220).withTitle('微信退款单号'),
		    DTColumnBuilder.newColumn('totalFee').withOption('width',80).withTitle('订单总金额(单位:分)'),
		    DTColumnBuilder.newColumn('refundFee').withOption('width',80).withTitle('申请退款金额(单位:分)'),
		    DTColumnBuilder.newColumn('settlementTotalFee').withOption('width',80).withTitle('应结订单金额(单位:分)'),
		    DTColumnBuilder.newColumn('settlementRefundFee').withOption('width',80).withTitle('退款金额(单位:分)'),
		    DTColumnBuilder.newColumn('refundStatus').withOption('width',80).withTitle('退款状态'),
		    DTColumnBuilder.newColumn('refundDesc').withOption('width',80).withTitle('退款原因'),
		    DTColumnBuilder.newColumn('refundRecvAccount').withOption('width',160).withTitle('退款入账账户'),
		    DTColumnBuilder.newColumn('refundChannel').withOption('width',100).withTitle('退款渠道'),
		    DTColumnBuilder.newColumn('refundAccount').withOption('width',200).withTitle('退款资金来源'),
		    DTColumnBuilder.newColumn('refundRequestSource').withOption('width',120).withTitle('退款发起来源'),
		    DTColumnBuilder.newColumn('appId').withOption('width',160).withTitle('微信应用ID'),
		    DTColumnBuilder.newColumn('merchantId').withOption('width',100).withTitle('微信支付商户号'),
		    DTColumnBuilder.newColumn('subAppId').withOption('width',160).withTitle('微信子应用ID'),
		    DTColumnBuilder.newColumn('subMerchantId').withOption('width',120).withTitle('微信支付子商户号')
        ];
		$scope.dtOptions = DTOptionsBuilder.newOptions()
		.withOption('id','id')
		.withFixedColumns({
			leftColumns: 4
		});

		$scope.dtInstance = {
			serverData : wechatauthService.searchRefundOrder
		};

		function getParams(){
			var obj = {};
			if($scope.fieldName){
                if($scope.fieldValue){
                    obj[$scope.fieldName] = $scope.fieldValue;
                }else {
                    obj[$scope.fieldName] = '';
                }
            }
			if ($scope.filter.createTime.startDate) {
				obj['createdDateStart'] = $scope.filter.createTime.startDate.format('YYYY-MM-DD 00:00:00');
            }
			if ($scope.filter.createTime.endDate) {
				obj['createdDateEnd'] = $scope.filter.createTime.endDate.format('YYYY-MM-DD 23:59:59');
            }
			if ($scope.filter.refundSuccessTime.startDate) {
				obj['refundSuccessTimeStart'] = $scope.filter.refundSuccessTime.startDate.format('YYYY-MM-DD 00:00:00');
            }
			if ($scope.filter.refundSuccessTime.endDate) {
				obj['refundSuccessTimeEnd'] = $scope.filter.refundSuccessTime.endDate.format('YYYY-MM-DD 23:59:59');
            }
			if($scope.refundStatus){
				obj['refundSuccessStatus'] = $scope.refundStatus;
			}
			if($scope.refundChannel){
				obj['refundChannel'] = $scope.refundChannel;
			}
			return obj;
		}


		//查询
		$scope.submitForm = function(){
			$scope.dtInstance.query({condition:getParams()});
		}
		
		// 导出
	    $scope.handleExport = function() {
	      var pragam = getParams();
	      var options = {
	    	url : 'wechat/payment/refund/order/export',
	    	name : '退款订单列表.xlsx'
	      };
	      Utils.exportExcel(options, pragam);
	    }
		
	}

	angular.module('wechatauth').controller('wechatRefundOrderCtrl', wechatRefundOrderCtrl)
})(angular);