OrderService.js 3.9 KB
"use strict";
var OrderService = angular.module('OrderService',[]);

OrderService.service("OrderService", [
	'$rootScope',
	'BaseService',
	function ($rootScope,BaseService) {
		var _service = {
				orders:[],
				orderDetailBean:[],
				orderPagerList:function(queryParam){
					BaseService.request({
						url:BaseService.url.orderPager_url,
						method:'post',
						mark:true,
						data:queryParam,
						fn:function(response) {
							if(response.code == 0) {
								_service.orders = response.data;
								$rootScope.$broadcast('orders.list');
							}
						}
					});
				},
				orderErrorPagerList:function(queryParam){
					BaseService.request({
						url:BaseService.url.orderErroePager_url,
						method:'post',
						mark:true,
						data:queryParam,
						fn:function(response) {
							if(response.code == 0) {
								_service.orders = response.data;
								$rootScope.$broadcast('orders.error');
							}
						}
					});
				},
				orderDetail:function(orderCode){
					BaseService.request({
						url:BaseService.url.orderDetail_url+orderCode,
						method:'POST',
						mark:true,
						fn:function(response) {
							if(response.code == 0) {
								_service.orderDetailBean = response.data;
								$rootScope.$broadcast('orders.detail');
							}
						}
					});
				},
				getOrderDetailById:function(memberId, orderId){
					BaseService.request({
						url:BaseService.url.getOrderDetail_url+"?memberId="+memberId+"&orderId="+orderId,
						method:'GET',
						mark:true,
						fn:function(response) {
							if(response.code == 0) {
								_service.orderDetailBean = response.data;
								$rootScope.$broadcast('order.detail');
							}
						}
					});
				},
				verifyOrder:function(ids,callback){
					BaseService.request({
						url:BaseService.url.verify_order_url,
						method:'POST',
						data:{"ids":ids},
						fn:function(response){
							if(response.code == 0){
								callback();
							}else{
								BaseService.updateAlert(response.message,response.code);
							}
						}
					});
				},
				
				statusList:function(orderType){
					BaseService.request({
						url:BaseService.url.order_status_url+"/"+orderType,
						method:'post',
						mark:true,
						fn:function(response) {
							if(response.code == 0) {
								_service.orderStatusList = response.data;
								$rootScope.$broadcast('orders.orderStatusList');
							}
						}
					});
				},
				modifyExpress:function(code,code2,expressName,orderCode,orderStatus){
					BaseService.request({
						url:BaseService.url.order_modify_url,
						method:'post',
						mark:true,
						data:{"expressCode":code,"expressCode2":code2,"orderCode":orderCode,'orderStatus':orderStatus,'expressName':expressName},
						fn:function(response) {
							if(response.code==0){
								window.location.reload();
							}
							BaseService.updateAlert(response.message,response.code)
						}
					});
				},
				refundOrderHandle:function(orderCode, orderStatus) {
					BaseService.request({
						url:BaseService.url.refund_order_handle_url,
						method:'post',
						mark:true,
						data:{"orderCode":orderCode,"orderStatus":orderStatus},
						fn:function(response) {
							BaseService.updateAlert(response.message,response.code)
						}
					});
				},
			updateOrderGoods:function(editOrder1Info,orderCode) {
				BaseService.request({
					url:BaseService.url.update_order_goods_url+orderCode,
					method:'post',
					mark:true,
					data:editOrder1Info,
					fn:function(response) {
						BaseService.updateAlert(response.message,response.code)
					}
				});
			},
			addOrderGoods:function(editOrder1Info,orderCode,callback){
				BaseService.request({
					url:BaseService.url.add_order_goods_url+orderCode,
					method:'post',
					mark:true,
					data:editOrder1Info,
					fn:function(data) {
						BaseService.updateAlert(data.message,data.code);
						if(callback) {
							callback.call(this, data);
						}
					}
				});
			}
		};
		return _service;
	}]);