| Line 111... |
Line 111... |
| 111 |
if(!empty($response['data'])){
|
111 |
if(!empty($response['data'])){
|
| 112 |
$this->set(compact('storemapping','activestores','pendingOrders','approvedOrders','creditedOrders','pendingCashbacks','creditedCashbacks','pendingAmount','approvedAmount','creditedAmount'));
|
112 |
$this->set(compact('storemapping','activestores','pendingOrders','approvedOrders','creditedOrders','pendingCashbacks','creditedCashbacks','pendingAmount','approvedAmount','creditedAmount'));
|
| 113 |
}
|
113 |
}
|
| 114 |
}
|
114 |
}
|
| 115 |
|
115 |
|
| - |
|
116 |
|
| - |
|
117 |
public function usercashbacks($userId) {
|
| - |
|
118 |
$this->set('byUser',$userId);
|
| - |
|
119 |
$this->layout = "innerpages";
|
| - |
|
120 |
$url = $this->apihost."storeorder/user/".$userId."?page=1&window=50";
|
| - |
|
121 |
$response = $this->make_request($url,null);
|
| - |
|
122 |
// debug($response);
|
| - |
|
123 |
$creditedOrders = $pendingOrders = $approvedOrders = array();
|
| - |
|
124 |
$creditedAmount = $pendingAmount = $approvedAmount = 0;
|
| - |
|
125 |
if(!empty($response['data'])){
|
| - |
|
126 |
foreach ($response['data'] as $key => $order) {
|
| - |
|
127 |
if(!empty($order['subOrders'])){
|
| - |
|
128 |
foreach ($order['subOrders'] as $key => $suborder) {
|
| - |
|
129 |
$suborder['storeId'] = $order['storeId'];
|
| - |
|
130 |
if($order['storeId']!=4){
|
| - |
|
131 |
$suborder['merchantOrderId'] = $order['merchantOrderId'];
|
| - |
|
132 |
} else {
|
| - |
|
133 |
$suborder['merchantOrderId'] = $suborder['merchantSubOrderId'];
|
| - |
|
134 |
}
|
| - |
|
135 |
if(!empty($order['orderTrackingUrl'])){
|
| - |
|
136 |
$suborder['orderSuccessUrl'] = $order['orderTrackingUrl'];
|
| - |
|
137 |
}
|
| - |
|
138 |
switch($suborder['cashBackStatus']){
|
| - |
|
139 |
// case 'Credited to wallet'://Credited
|
| - |
|
140 |
// $creditedOrders[] = $suborder;
|
| - |
|
141 |
// break;
|
| - |
|
142 |
case 'Approved':
|
| - |
|
143 |
$approvedOrders[] = $suborder;
|
| - |
|
144 |
$approvedAmount += $suborder['cashBackAmount'];
|
| - |
|
145 |
break;
|
| - |
|
146 |
case 'Pending':
|
| - |
|
147 |
$pendingOrders[] = $suborder;
|
| - |
|
148 |
// $pendingAmount += $suborder['cashBackAmount'];
|
| - |
|
149 |
}
|
| - |
|
150 |
}
|
| - |
|
151 |
}
|
| - |
|
152 |
}
|
| - |
|
153 |
}
|
| - |
|
154 |
$url = $this->apihost.'pending-cashbacks/user/'.$userId;
|
| - |
|
155 |
$result = $this->make_request($url,null);
|
| - |
|
156 |
$pendingAmount = $result['amount'];
|
| - |
|
157 |
//Get pending cashbacks
|
| - |
|
158 |
$url = $this->apihost.'pending-refunds/user/'.$userId;
|
| - |
|
159 |
$pendingCashbacks = $this->make_request($url,null);
|
| - |
|
160 |
//Get credited cashbacks
|
| - |
|
161 |
$url = $this->apihost.'refund/user/'.$userId;
|
| - |
|
162 |
$creditedCashbacks = $this->make_request($url,null);
|
| - |
|
163 |
|
| - |
|
164 |
$creditKeyArray = array();
|
| - |
|
165 |
$creditValueArray = array();
|
| - |
|
166 |
$total_credited_amount = 0;
|
| - |
|
167 |
if(!empty($creditedCashbacks)){
|
| - |
|
168 |
foreach ($creditedCashbacks['data'] as $key => $value) {
|
| - |
|
169 |
$creditedAmount += $value['userAmount'];
|
| - |
|
170 |
$data = array('subOrders.batchId'=>$value['batch']);
|
| - |
|
171 |
$jsonVar = json_encode($data);
|
| - |
|
172 |
|
| - |
|
173 |
$url = $this->apihost."storeorder/user/".$userId."?page=1&window=50&searchMap=$jsonVar";
|
| - |
|
174 |
$creditedOrders[$value['batch']] = $this->make_request($url,null);
|
| - |
|
175 |
$total_credited_amount =$total_credited_amount + $value['userAmount'];
|
| - |
|
176 |
if($value['type']== 'Order')
|
| - |
|
177 |
{
|
| - |
|
178 |
$creditValueArray['amount'] = $value['userAmount'];
|
| - |
|
179 |
$creditValueArray['type'] = $value['type'];
|
| - |
|
180 |
$creditValueArray['fortbatchid'] = $value['batch'];
|
| - |
|
181 |
$creditValueArray['creditedDate'] = date('Y-m-d',strtotime($value['timestamp']));
|
| - |
|
182 |
// $creditKeyArray[date('Y-m-d',strtotime($value['timestamp']))] = $creditValueArray;
|
| - |
|
183 |
$creditKeyArray[date('Y-m-d',strtotime($value['timestamp'])).$value['type']] = $creditValueArray;
|
| - |
|
184 |
}
|
| - |
|
185 |
|
| - |
|
186 |
}
|
| - |
|
187 |
}
|
| - |
|
188 |
|
| - |
|
189 |
$storemapping = Configure::read('storemapping');
|
| - |
|
190 |
$activestores = Configure::read('activestores');
|
| - |
|
191 |
|
| - |
|
192 |
// App Credit Start
|
| - |
|
193 |
$creditedFortnight = array();
|
| - |
|
194 |
$url = $this->apihost.'appUserCashBack/'.$userId.'/Credited';
|
| - |
|
195 |
$getcredited = $this->make_request($url,null);
|
| - |
|
196 |
// debug($getcredited);
|
| - |
|
197 |
foreach ($getcredited['UserAppCashBack'] as $key => $value) {
|
| - |
|
198 |
|
| - |
|
199 |
|
| - |
|
200 |
|
| - |
|
201 |
$url = $this->apihost.'appUserBatchDrillDown/'.$userId.'/'.$value['fortnightOfYear'].'/'.$value['yearVal'];
|
| - |
|
202 |
$creditedFortnight[$value['fortnightOfYear']] = $this->make_request($url,null);
|
| - |
|
203 |
|
| - |
|
204 |
$creditValueArray['amount'] = $value['amount'];
|
| - |
|
205 |
// $total_credited_amount = $total_credited_amount + $value['amount'];
|
| - |
|
206 |
$creditValueArray['type'] = 'App';
|
| - |
|
207 |
$creditValueArray['fortbatchid'] = $value['fortnightOfYear'];
|
| - |
|
208 |
$creditValueArray['creditedDate'] = $value['creditedDate'];
|
| - |
|
209 |
$creditKeyArray[$value['creditedDate'].'App'] = $creditValueArray;
|
| - |
|
210 |
// echo "total credit",$total_credited_amount;
|
| - |
|
211 |
// echo $url;
|
| - |
|
212 |
}
|
| - |
|
213 |
|
| - |
|
214 |
ksort($creditKeyArray);
|
| - |
|
215 |
// debug($creditKeyArray);
|
| - |
|
216 |
$this->set(compact('getcredited','creditedFortnight','creditKeyArray','total_credited_amount'));
|
| - |
|
217 |
// debug($creditedFortnight);
|
| - |
|
218 |
// App Credit End
|
| - |
|
219 |
|
| - |
|
220 |
// Approved Start
|
| - |
|
221 |
|
| - |
|
222 |
$url = $this->apihost.'appUserCashBack/'.$userId.'/Approved';
|
| - |
|
223 |
$getapproved = $this->make_request($url,null);
|
| - |
|
224 |
$fortnight = array();
|
| - |
|
225 |
$fortnight_amount = array();
|
| - |
|
226 |
$counter = 0;
|
| - |
|
227 |
$total_approved_amount = 0;
|
| - |
|
228 |
$current_date = date("Y");
|
| - |
|
229 |
foreach ($getapproved["UserAppCashBack"] as $key => $value) {
|
| - |
|
230 |
$fortnight[$counter] = $value["fortnightOfYear"];
|
| - |
|
231 |
$fortnight_amount[$counter] = $value["amount"];
|
| - |
|
232 |
$total_approved_amount += $value["amount"];
|
| - |
|
233 |
$counter++;
|
| - |
|
234 |
}
|
| - |
|
235 |
$approvedFortnight = array();
|
| - |
|
236 |
for($i=0; $i<count($fortnight); $i++){
|
| - |
|
237 |
$url = $this->apihost.'appUserBatchDrillDown/'.$userId.'/'.$fortnight[$i].'/'.$current_date;
|
| - |
|
238 |
$approvedFortnight[$i] = $this->make_request($url,null);
|
| - |
|
239 |
|
| - |
|
240 |
}
|
| - |
|
241 |
// debug($approvedFortnight);
|
| - |
|
242 |
$this->set(compact('fortnight','total_approved_amount','fortnight_amount','approvedFortnight'));
|
| - |
|
243 |
// Approved End
|
| - |
|
244 |
|
| - |
|
245 |
if(!empty($response['data'])){
|
| - |
|
246 |
$this->set(compact('storemapping','activestores','pendingOrders','approvedOrders','creditedOrders','pendingCashbacks','creditedCashbacks','pendingAmount','approvedAmount','creditedAmount'));
|
| - |
|
247 |
}
|
| - |
|
248 |
}
|
| - |
|
249 |
|
| - |
|
250 |
|
| - |
|
251 |
public function by($userId) {
|
| - |
|
252 |
$page = $this->request->query('page');
|
| - |
|
253 |
$page = isset($page)?$page:1;
|
| - |
|
254 |
$this->layout = "innerpages";
|
| - |
|
255 |
$url = $this->apihost."storeorder/user/".$userId."?page=$page&window=10";
|
| - |
|
256 |
$response = $this->make_request($url,null);
|
| - |
|
257 |
$totalPages = $response['totalPages'];
|
| - |
|
258 |
if(!empty($response['data'])){
|
| - |
|
259 |
$this->set('orders',$response['data']);
|
| - |
|
260 |
}
|
| - |
|
261 |
$ignoredFields = array('imgUrl','status','productTitle','estimatedDeliveryDate','productCode','merchantSubOrderId','productUrl','closed','tracingkUrl','detailedStatus');
|
| - |
|
262 |
$storemapping = Configure::read('storemapping');
|
| - |
|
263 |
$activestores = Configure::read('activestores');
|
| - |
|
264 |
$amazonorderurl = Configure::read('amazonorderurl');
|
| - |
|
265 |
$this->set(compact('ignoredFields','page','totalPages','userId','activestores','storemapping','amazonorderurl'));
|
| - |
|
266 |
}
|
| - |
|
267 |
|
| 116 |
/**
|
268 |
/**
|
| 117 |
* index method
|
269 |
* index method
|
| 118 |
*
|
270 |
*
|
| 119 |
* @return void
|
271 |
* @return void
|
| 120 |
*/
|
272 |
*/
|