Subversion Repositories SmartDukaan

Rev

Rev 13944 | Rev 13994 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13944 Rev 13993
Line 15... Line 15...
15
 */
15
 */
16
	public $components = array('Paginator');
16
	public $components = array('Paginator');
17
 
17
 
18
	public function beforeFilter() {		
18
	public function beforeFilter() {		
19
		parent::beforeFilter();
19
		parent::beforeFilter();
20
		$this->Auth->allow('add','mine');
20
		$this->Auth->allow('add','mine','pendingcashbacks');
21
		$this->apihost = Configure::read('pythonapihost');
21
		$this->apihost = Configure::read('pythonapihost');
22
	}
22
	}
23
	
23
	
24
	public function mine() {
24
	public function mine() {
25
		$page = $this->request->query('page');
25
		$page = $this->request->query('page');
Line 49... Line 49...
49
			$this->loadModel('User');
49
			$this->loadModel('User');
50
			$dbuser = $this->User->findById($userId);
50
			$dbuser = $this->User->findById($userId);
51
			$this->Auth->login($dbuser['User']);	
51
			$this->Auth->login($dbuser['User']);	
52
		}
52
		}
53
		$this->layout = "innerpages";
53
		$this->layout = "innerpages";
54
		$url = $this->apihost."storeorder/user/".$this->Auth->User('id')."?page=1&window=10";
54
		$url = $this->apihost."storeorder/user/".$this->Auth->User('id')."?page=1&window=50";
55
		$response = $this->make_request($url,null);
55
		$response = $this->make_request($url,null);
-
 
56
		// debug($response);
-
 
57
		$creditedOrders = $pendingOrders = $approvedOrders = array();
-
 
58
		$creditedAmount = $pendingAmount = $approvedAmount = 0;
56
		if(!empty($response['data'])){
59
		if(!empty($response['data'])){
-
 
60
			foreach ($response['data'] as $key => $order) {
-
 
61
				foreach ($order['subOrders'] as $key => $suborder) {
-
 
62
					$suborder['storeId'] = $order['storeId'];
-
 
63
					switch($suborder['cashBackStatus']){
-
 
64
						case 'Credited to wallet'://Credited
-
 
65
						$creditedOrders[] = $suborder;
-
 
66
						break;
-
 
67
						case 'Approved':
-
 
68
						$approvedOrders[] = $suborder;
-
 
69
						$approvedAmount += $suborder['cashBackAmount'];
-
 
70
						break;
-
 
71
						case 'Pending':
-
 
72
						$pendingOrders[] = $suborder;
-
 
73
						$pendingAmount += $suborder['cashBackAmount'];
-
 
74
					}
-
 
75
				}
-
 
76
			}
-
 
77
		}
-
 
78
		//Get pending cashbacks
-
 
79
		$url = $this->apihost.'pending-refunds/user/'.$userId;
-
 
80
		$pendingCashbacks = $this->make_request($url,null);
-
 
81
		//Get credited cashbacks
-
 
82
		$url = $this->apihost.'refund/user/'.$userId;
-
 
83
		$creditedCashbacks = $this->make_request($url,null);
-
 
84
		if(!empty($response)){
-
 
85
			foreach ($creditedCashbacks['data'] as $key => $value) {
-
 
86
				$creditedAmount += $value['userAmount'];
-
 
87
			}
-
 
88
		}
-
 
89
		// debug($response);
57
			$this->set('orders',$response['data']);
90
		if(!empty($response['data'])){
-
 
91
			$this->set(compact('pendingOrders','approvedOrders','creditedOrders','pendingCashbacks','creditedCashbacks','pendingAmount','approvedAmount','creditedAmount'));
58
		}
92
		}
59
	}
93
	}
60
 
94
 
61
/**
95
/**
62
 * index method
96
 * index method