[520] | 1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
---|
| 2 |
|
---|
| 3 | class Recharge extends MX_Controller
|
---|
| 4 | {
|
---|
| 5 | public function __construct()
|
---|
| 6 | {
|
---|
| 7 | parent::__construct();
|
---|
| 8 | }
|
---|
| 9 |
|
---|
| 10 | public function recharge_card()
|
---|
| 11 | {
|
---|
| 12 | $userID = $this->uri->segment(4);
|
---|
| 13 | $input = $this->input->post();
|
---|
| 14 | $cardSerial = $input['card_serial'];
|
---|
| 15 | $pinCard = $input['pin_card'];
|
---|
| 16 | $aryParams = array(
|
---|
[601] | 17 | 'EWalletID' => 1,
|
---|
[520] | 18 | 'CardSerial' => $cardSerial,
|
---|
| 19 | 'PinCard' => $pinCard,
|
---|
| 20 | );
|
---|
| 21 |
|
---|
| 22 | $this->load->model('services_model');
|
---|
| 23 | $aryResult = array();
|
---|
| 24 | $data = $this->services_model->cardPaidProcess($aryParams, $aryResult);
|
---|
| 25 | $this->load->model('frontend/user_model', 'objUserModel');
|
---|
| 26 | $paidType = 2;
|
---|
| 27 | $amount = $aryResult['TransactionAmount'];
|
---|
| 28 | $paidTime = date('Y-m-d H:i:s');
|
---|
| 29 |
|
---|
| 30 | $user = $this->objUserModel->get_user_by_id($userID);
|
---|
| 31 | $user['acc_balanced'] = $user['acc_balanced'] + $amount;
|
---|
| 32 | $user['updated_time'] = date('Y-m-d H:i:s');
|
---|
| 33 | if ($amount>0){
|
---|
| 34 | $this->objUserModel->updateUser($userID, $user);
|
---|
| 35 | }
|
---|
| 36 | $this->objUserModel->insertPaidlog($user['cellphone'], $user['cellphone'], $paidType, $amount, $paidTime);
|
---|
| 37 | $result = array();
|
---|
| 38 | if ($data == 1){
|
---|
| 39 | $result['success'] = 1;
|
---|
| 40 | $result['username'] = $user['cellphone'];
|
---|
| 41 | $result['acc_balanced'] = $user['acc_balanced'];
|
---|
| 42 | $result['amount'] = $amount;
|
---|
| 43 | }else
|
---|
| 44 | {
|
---|
[536] | 45 | $result['success'] = 0;
|
---|
[520] | 46 | }
|
---|
| 47 | echo json_encode($result);
|
---|
| 48 | }
|
---|
| 49 | } |
---|