Changeset 620 for pro-violet-viettel/sourcecode/application/modules/services/controllers/recharge.php
- Timestamp:
- Nov 24, 2014 4:27:40 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-violet-viettel/sourcecode/application/modules/services/controllers/recharge.php
r611 r620 6 6 { 7 7 parent::__construct(); 8 $this->load->model('frontend/user_model', 'objUserModel'); 9 $this->load->helper('lockfile'); 10 $this->load->model('services_model'); 8 11 } 9 12 … … 14 17 $cardSerial = $input['card_serial']; 15 18 $pinCard = $input['pin_card']; 16 $aryParams = array( 17 'EWalletID' => $this->config->item('EWalletID'), 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'); 19 $isLocked = 0; 29 20 30 21 $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); 22 $lockFilePreFix = $user['cellphone']; 23 $lockFilePath = $this->config->item('topup_lock_path'); 24 $maxReach = $this->config->item('topup_lock_max_reach'); 25 $timeToUnlock = $this->config->item('topup_unlock_minute'); 26 27 $isLocked = createLockFile($lockFilePreFix, $maxReach, $timeToUnlock, $lockFilePath, 1); 28 $chargCard = _SBG_CARD_PAY_SUCCESS; 29 $result = array(); 30 $result['maxReach'] = $maxReach; 31 $result['timeToUnlock'] = $timeToUnlock; 32 $result['isLocked'] = $isLocked; 33 $result['tmp'] = $maxReach; 34 35 $lockedMsg = 'QuÜ vá» Äã nháºp sai thÃŽng tin thẻ cà o '. $maxReach .' lần liên tiếp.<br />Xin chá» '. $timeToUnlock .' phút sau Äá» thao tác lại!'; 36 $chargErrMsg = 'Mã thẻ hoặc Serial khÃŽng Äúng hoặc Äã ÄÆ°á»£c sá» dụng. Quà vá» vui lòng kiá»m tra lại!'; 37 $errMsg = ''; 38 39 if ($isLocked == 0) { 40 $aryParams = array( 41 'EWalletID' => $this->config->item('EWalletID'), 42 'CardSerial' => $cardSerial, 43 'PinCard' => $pinCard, 44 ); 45 46 $aryResult = array(); 47 $chargCard = $this->services_model->cardPaidProcess($aryParams, $aryResult); 48 49 $paidType = 2; 50 $amount = $aryResult['TransactionAmount']; 51 $paidTime = date('Y-m-d H:i:s'); 52 $user['acc_balanced'] = $user['acc_balanced'] + $amount; 53 $user['updated_time'] = date('Y-m-d H:i:s'); 54 if ($amount>0){ 55 $this->objUserModel->updateUser($userID, $user); 56 } 57 58 $result['success'] = $chargCard; 59 60 if ($chargCard == _SBG_CARD_PAY_SUCCESS){ 61 $result['username'] = $user['cellphone']; 62 $result['acc_balanced'] = $user['acc_balanced']; 63 $result['amount'] = $amount; 64 $this->objUserModel->insertPaidlog($user['cellphone'], $user['cellphone'], $paidType, $amount, $paidTime); 65 releaseLockFile($lockFilePreFix, $lockFilePath); 66 } 67 else { 68 $isLocked = createLockFile($lockFilePreFix, $maxReach, $timeToUnlock, $lockFilePath); 69 $errMsg = $isLocked == 1 ? $chargErrMsg .'<br />'.$lockedMsg : $chargErrMsg; 70 } 71 }else if ($isLocked == 1) { 72 $errMsg = $lockedMsg; 73 $result['success'] = _SBG_CARD_PAY_FAIL; 35 74 } 36 75 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 $this->objUserModel->insertPaidlog($user['cellphone'], $user['cellphone'], $paidType, $amount, $paidTime); 44 }else 45 { 46 $result['success'] = 0; 47 } 76 $result['errMsg'] = $errMsg; 48 77 echo json_encode($result); 49 78 }
Note: See TracChangeset
for help on using the changeset viewer.