/var/www/vhosts/nabawater/backend/controllers
Edit: /var/www/vhosts/nabawater/backend/controllers/RefundRequestController.php (2964B)
render('index',
[
'searchModel' => $searchModel,
'dataProvider' => $searchModel->search(Yii::$app->request->queryParams)
]
);
}
/**
* @return Json
*
* @Title("Change Status")
*/
public function actionGetStatus()
{
$post = Yii::$app->getRequest()->post();
$params = ['status', 'id'];
$result = ['status' => STATUS_FAIL, 'msg' => '' ];
foreach ($params as $param) {
if (!array_key_exists($param, $post)){
$result['msg'] = 'Required Param Missing';
goto skip;
}
}
$model = ItemBottleRefundHistory::findOne(['item_bottle_refund_history_id' => $post['id']]);
if ($model === null) {
$result['msg'] = 'Unable to find the Order Details';
goto skip;
} else {
$model->refund_status = $post['status'];
$model->save(false);
if($model->refund_status == ItemBottleRefundHistory::REFUND_SUCCESS) {
$modelUser = User::findOne($model->user_id);
$modelWallet = new WalletTransaction();
$modelWallet->user_key = $modelUser->user_key;
$modelWallet->pay_type = WalletTransaction::TRANS_TYPE_EMPTY_BOTTLE_REFUND;
$modelWallet->amount = Configuration::get(Configuration::EMPTY_BOTTLE);
$modelWallet->transaction_status = WalletTransaction::TRANSACTION_SUCCESS;
$modelWallet->first_name = $modelUser->first_name;
$modelWallet->last_name = $modelUser->last_name;
$modelWallet->email = $modelUser->email;
$modelWallet->mobile_number = $modelUser->mobile_number;
$modelWallet->transaction_type = WalletTransaction::TRANS_TYPE_EMPTY_BOTTLE_REFUND;
$modelWallet->save(false);
$modelUser->wallet_point += $modelWallet->amount;
$modelUser->save(false);
}
}
$result['msg'] = 'Status Changed Successfully';
$result['status'] = STATUS_SUCCESS;
skip:
return $this->asJson($result);
}
}