Changeset 884 for pro-violet-viettel/sourcecode/application/modules
- Timestamp:
- Apr 7, 2015 2:17:28 PM (10 years ago)
- Location:
- pro-violet-viettel/sourcecode/application/modules
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php
r883 r884 5 5 /** 6 6 * Home Class 7 * @todo Control main actions 8 * @see index() 9 * @see singin() 10 * @see signout() 7 11 * 8 12 * @author dzungnv02 … … 18 22 } 19 23 24 /** 25 * function index 26 * @todo checked is sign-in then redirect to lecture page else redirect to sign-in page 27 */ 20 28 public function index() { 21 29 $user_info = $this->session->userdata ( 'userInfo' ); … … 41 49 } 42 50 51 /** 52 * function signin 53 * @todo Execute sign-in action 54 */ 43 55 public function signin() { 44 56 $username = $this->input->post ( 'username', TRUE ); … … 83 95 } 84 96 97 /** 98 * funtion signout 99 * @todo Execute signout action 100 */ 85 101 public function signout() { 86 102 //$this->session->sess_destroy (); … … 92 108 } 93 109 94 public function register() { 95 $this->load->model ( 'user_model' ); 96 $collaborator = '0979947802'; 97 $serviceID = 1; 98 $username = '0978618113'; 99 $commandcode = 'commandcode1'; 100 $info = 'ABCD'; 101 // $receiveTime = time(); 102 $receiveTime = date ( "Y-m-d H:i:s" ); 103 $data = $this->user_model->register ( $username, $collaborator ); 104 echo $data; 105 } 106 107 public function change_profile() { 108 $this->load->model ( 'user_model' ); 109 $sentNumber = '0979947802'; 110 $serviceID = 1; 111 $password = '2933369'; 112 $commandcode = "SBG"; 113 $receiveID = '0977274183'; 114 $info = "SBG TD"; 115 $receiveTime = date ( "Y-m-d H:i:s" ); 116 $status = 0; 117 $data = $this->user_model->changeProfile ( $sentNumber, $receiveID, $password, $status ); 118 echo $data; 119 } 120 121 public function change_password() { 122 $this->load->model ( 'user_model' ); 123 $sentNumber = '0979947802'; 124 $password = '935322'; 125 $data = $this->user_model->changePassword ( $sentNumber, $password ); 126 echo $data; 127 } 128 129 public function register_vip() { 130 $this->load->model ( 'user_model' ); 131 $sentNumber = '0979947802'; 132 $p_code = 1; 133 $serviceID = 1; 134 $commandcode = "SBG"; 135 $vipNum = 1; 136 $mainAccBalanced = 15000; 137 $info = "SBG DK VIP1"; 138 $receiveTime = date ( "Y-m-d H:i:s" ); 139 $status = 0; 140 $data = $this->user_model->registerVip ( $sentNumber, $p_code ); 141 echo $data; 142 } 143 144 public function recharge_account() { 145 $this->load->model ( 'user_model' ); 146 $sentNumber = '0979947802'; 147 $receiveID = '01662860000'; 148 $serviceID = 1; 149 $commandcode = "SBG"; 150 $vipNum = 1; 151 $mainAccBalanced = 15000; 152 $amount = 1000; 153 $info = "SBG NAP 10000"; 154 $status = 0; 155 $receiveTime = date ( "Y-m-d H:i:s" ); 156 $data = $this->user_model->rechargeAccount ( $sentNumber, $amount ); 157 //$data = $this->user_model->insertPaidlog($sentNumber, $sentNumber, 2, $amount, $receiveTime); 158 echo $data; 159 } 160 161 public function is_viettel($number) { 110 /** 111 * function is_viettel 112 * @param string $number 113 * @return 1:true;0:false 114 * @todo checked the phone number is viettel subscriber 115 */ 116 private function is_viettel($number) { 162 117 $viettel = array ( 163 118 '096', -
pro-violet-viettel/sourcecode/application/modules/frontend/controllers/lecture.php
r821 r884 6 6 /** 7 7 * Lecture Class 8 * 8 * @todo Show lecture editor software 9 9 * @author dzungnv02 10 10 * … … 12 12 class Lecture extends MX_Controller { 13 13 14 /** 15 * function __construct 16 * @todo constructor of class 17 */ 14 18 public function __construct() { 15 19 parent::__construct(); … … 18 22 } 19 23 24 /** 25 * function index 26 * @todo Show lecture editor 27 */ 20 28 public function index() { 21 29 $this->load->model('User_model'); -
pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php
r883 r884 1 1 <?php 2 3 2 if (!defined('BASEPATH')) 4 3 exit('No direct script access allowed'); 5 4 5 /** 6 * Class User 7 * @todo Execute actions of user 8 * 9 * @see function profile 10 * @see function packageRegister 11 * @see function finishRegisterPackage 12 * @see function regpackage 13 * @see function update_info 14 * @see function update_user 15 * @see function change_password 16 * @see function trade_history 17 * @see function getUserInfor 18 * @see function adminUpdateUser 19 * @see function regis_history 20 * 21 * @author dungnv02 22 * 23 */ 6 24 class User extends MX_Controller { 7 25 -
pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php
r714 r884 212 212 } 213 213 214 public function getCollaborators () { 215 $client = new SoapClient($this->config->item('bccs_service_url'), array( 'trace' => true, 216 'exceptions' => true, 217 )); 218 $username = $this->config->item('bccs_username'); 219 $password = $this->config->item('bccs_password'); 220 $wscode = 'getListShopAndStaftInfo'; 221 222 $input = new Input($username, $password, $wscode/* , 2, 1,5000 */); 223 $param = new Param(); 224 225 $params = array( 226 "Input" => $input, 227 "rawData" => "rawData", 228 "Param" => $param, 229 ); 230 231 var_dump($params); 232 233 $response = $client->__soapCall("gwOperation", array($params)); 234 var_dump($response); 235 } 236 214 237 215 238 } 216 239 240 241 class Input { 242 function Input ($user, $pass, $wscode/*, $type, $page, $displaypage */) { 243 $this->user = $user; 244 $this->pass = $pass; 245 $this->wscode = $wscode; 246 $this->param = null; 247 $this->rawData = ''; 248 /* $this->type = $type; 249 $this->page = $page; 250 $this->displaypage = $displaypage; */ 251 } 252 } 253 254 class Param { 255 function Param () { 256 $this->name = ''; 257 $this->value = ''; 258 } 259 } 217 260 function fix_latin1_mangled_with_utf8_maybe_hopefully_most_of_the_time($str) 218 261 { -
pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php
r883 r884 26 26 if ( ! defined('_SBG_CHARGING_NUMBER_NOT_REGISTED')) define('_SBG_CHARGING_NUMBER_NOT_REGISTED', 501); 27 27 if ( ! defined('_SBG_CHARGING_MAX_VALUE')) define('_SBG_CHARGING_MAX_VALUE', 50000); 28 if ( ! defined('_SBG_CHARGING_MIN_VALUE')) define('_SBG_CHARGING_MIN_VALUE', 5000); 28 29 29 30 … … 40 41 if ( ! defined('_SBG_GET_COLLABORATOR_FAIL')) define('_SBG_GET_COLLABORATOR_FAIL', -1); 41 42 42 Class Services_model extends CI_Model 43 Class Services_model extends CI_Model 43 44 { 44 45 private $_arySmsMO = array( … … 52 53 _SBG_MO_SUPPOR_SERVICE => array('pattern' => '/^(SBG)([[:blank:]])(HD)$/'), 53 54 _SBG_MO_UNSUBSCRIBE_SERVICE => array('pattern' => '/^(SBG)([[:blank:]])(HUY)$/') 54 ); 55 55 ); 56 56 57 public function __construct(){ 57 58 parent::__construct(); … … 59 60 $this->lang->load('messages', 'message'); 60 61 } 61 62 62 63 /** 63 64 * messageAnalys 64 * 65 * 65 66 * @todo Analysis content of incoming message 66 * 67 * 67 68 * @param String $message - coming SMS 68 69 * @return multitype:Ambigous <string, multitype> multitype:multitype … … 70 71 public function messageAnalys ($message) 71 72 { 72 $aryMatched = array(); 73 $aryMatched = array(); 73 74 $aryContent = array(); 74 75 $result = FALSE; 75 76 76 77 foreach ($this->_arySmsMO as $case => $pattern) 77 78 { … … 82 83 } 83 84 } 84 85 85 86 $case = (bool)$result ? $case:_SBG_MO_SYNTAX_ERR; 86 87 87 88 foreach($aryMatched as $k => $val) { 88 if ($k > 1) $aryContent[] = $val; 89 } 90 89 if ($k > 1) $aryContent[] = $val; 90 } 91 91 92 return array('case' => $case, 'content' => $aryContent); 92 93 } 93 94 94 95 /** 95 96 * processMORequest 96 * 97 * 97 98 * @todo process action analysed from messageAnalys 98 * 99 * 99 100 * @param unknown $sentNumber 100 101 * @param unknown $message 101 102 * @return string 102 103 */ 103 public function processMORequest ($sentNumber, $message, &$mtBody = null) 104 public function processMORequest ($sentNumber, $message, &$mtBody = null) 104 105 { 105 106 $debugMsg = $message."\n"; 106 107 107 108 $sentNumber = $this->formatPhoneNumber($sentNumber); 108 109 109 110 $smsReturn = ''; 110 $aryMOAnalys = $this->messageAnalys($message); 111 $aryMOAnalys = $this->messageAnalys($message); 111 112 $case = $aryMOAnalys['case']; 112 113 $aryContents = isset($aryMOAnalys['content']) ? $aryMOAnalys['content']: null; 113 114 $this->load->model('frontend/user_model', 'objUserModel'); 114 115 $debugMsg .= $case; 115 116 116 117 switch ($case) { 117 118 case _SBG_MO_REGISTER: … … 123 124 } 124 125 } 125 126 $userName = isset($aryContents[0]) ? $this->formatPhoneNumber($aryContents[0]) : $sentNumber; 126 127 $userName = isset($aryContents[0]) ? $this->formatPhoneNumber($aryContents[0]) : $sentNumber; 127 128 $collaborator = isset($aryContents[0]) ? $sentNumber:null; 128 129 $collaboratorMsg = ''; 129 130 130 131 $sms = $this->objUserModel->register($userName, $collaborator, $collaboratorMsg); 131 132 132 133 if ($case == _SBG_MO_REGISTER_FOR) { 133 134 $smsReturn = $collaboratorMsg; … … 137 138 $sendMT = $this->sendMT($this->formatPhoneNumber($userName, -1), $mtBody); 138 139 } 139 140 140 141 } 141 142 else { … … 149 150 break; 150 151 } 151 152 152 153 $oldPhoneNumber = $this->formatPhoneNumber($aryContents[0]); 153 154 $password = $aryContents[1]; 154 155 $smsReturn = $this->objUserModel->changeProfile($sentNumber, $oldPhoneNumber, $password); 155 156 156 157 $arySMS = explode('|', $smsReturn); 157 158 $changeResult = (int)$arySMS[0]; 158 159 159 160 $aryPatterns = array('/:sentNumber:/'); 160 161 $sms = preg_replace($aryPatterns, array($sentNumber), lang('_SBG_MO_USER_OLD_PHONENUM_CHANGE_SUCCESS_MSG')); … … 168 169 $p_code = $aryContents[0]; 169 170 $smsReturn = $this->objUserModel->registerVip($sentNumber, $p_code, $packageData); 170 171 171 172 $arySmsReturn = explode('|', $smsReturn); 172 173 $result = $arySmsReturn[0]; … … 179 180 for ($i = 1; $i <= $count; $i++) { 180 181 $value = $amount > _SBG_CHARGING_MAX_VALUE ? _SBG_CHARGING_MAX_VALUE : $amount; 181 $amount -= $value; 182 $amount -= $value; 182 183 $result = $this->chargeRootAccountProcess($sentNumber, $value, $sentNumber.' paid for SBG'); 183 } 184 } 184 185 185 186 if ($result == _SBG_CHARGING_SUCCESS) { … … 199 200 case _SBG_MO_PAY_TO_ACCOUNT_FOR: 200 201 error_log(date('Y-m-d H:i:s').' -- DATA: '. var_export($aryContents, TRUE).' -- CASE: '. $case . "\n", 3, '/srv/www/sbg/log/pay.log'); 202 201 203 $userName = isset($aryContents[1]) ? $this->formatPhoneNumber($aryContents[1]) : $sentNumber; 202 204 if ($case == _SBG_MO_PAY_TO_ACCOUNT_FOR && !preg_match('/^(09\d{8}|01\d{9})$/', $userName)) { … … 204 206 break; 205 207 } 206 208 207 209 $amount = $aryContents[0]; 208 210 if (!preg_match('/^[0-9]{3,}$/', $amount)) { … … 210 212 break; 211 213 } 212 214 215 if ((int)$amount < _SBG_CHARGING_MIN_VALUE) { 216 $smsReturn = _SBG_MO_PROCCESS_ERR.'|'.lang('_SBG_MO_AMOUNT_LESS_THAN_MIN_VALUE_MSG'); 217 break; 218 } 219 213 220 $result =$this->chargeRootAccountProcess($sentNumber, $amount, $sentNumber.' paid for SBG'); 214 221 215 222 if ($result == _SBG_CHARGING_SUCCESS) { 216 223 $smsReturn = $this->objUserModel->rechargeAccount($userName, $amount); … … 228 235 } 229 236 else if ($result == _SBG_CHARGING_FAIL_NOT_ENOUGH) { 230 //$aryPatterns = array ('/:amount:/');231 237 $aryPatterns = array ('/:sentNumber:/'); 232 238 $smsReturn = preg_replace($aryPatterns, array($sentNumber), lang('_SBG_MO_CHARGING_FAIL_NOT_ENOUGH_MSG')); 233 /*234 if ($case == _SBG_MO_PAY_TO_ACCOUNT_FOR) {235 $aryPatterns = array ('/:amount:/', '/:username:/');236 $smsReturn = preg_replace($aryPatterns, array($amount, $userName), lang('_SBG_MO_CHARGING_FAIL_NOT_ENOUGH_FOR_MSG'));237 }*/238 239 $smsReturn = _SBG_MO_PROCCESS_ERR.'|'.$smsReturn; 239 240 } 240 241 else if ($result == _SBG_CHARGING_FAIL_MORETHAN_LIMIT) { 241 $aryPatterns = array ('/:sendid:/');242 /* $aryPatterns = array ('/:sendid:/'); 242 243 $smsReturn = preg_replace($aryPatterns, array($sentNumber), lang('_SBG_MO_CHARGING_FAIL_MORETHAN_LIMIT_MSG')); 243 $smsReturn = _SBG_MO_PROCCESS_ERR.'|'.$smsReturn; 244 $smsReturn = _SBG_MO_PROCCESS_ERR.'|'.$smsReturn; */ 245 246 247 248 244 249 }else if ($result == _SBG_CHARGING_FAIL_NOT_VIETTEL || $result == _SBG_CHARGING_NUMBER_NOT_EXISTED || $result == _SBG_CHARGING_NUMBER_NOT_AVAILABLE) { 245 250 $smsReturn = _SBG_MO_PROCCESS_ERR.'|'.lang('_SBG_MO_CHARGING_FAIL_NOT_VIETTEL_MSG'); 246 } 251 } 247 252 else { 248 253 $smsReturn = _SBG_MO_PROCCESS_ERR.'|'.lang('_SBG_MO_CHARGING_FAIL_MSG'); 249 254 } 250 255 break; 256 251 257 case _SBG_MO_SUPPOR_SERVICE: 252 //$smsReturn = '1|'.lang('_SBG_MO_SUPPORT_MSG');253 258 if ($this->isViettel($sentNumber)){ 254 259 $smsReturn = '1|'.lang('_SBG_MO_SUPPORT_VIETTEL_MSG'); … … 257 262 } 258 263 break; 264 259 265 case _SBG_MO_UNSUBSCRIBE_SERVICE: 260 266 case _SBG_MO_SYNTAX_ERR: … … 263 269 break; 264 270 } 265 271 266 272 $aryTmp = explode('|', $smsReturn); 267 273 $mtBody = $aryTmp[1] . "\n" . $mtBody; 268 274 269 275 return $smsReturn.'|'.$case; 270 276 } 271 272 277 278 273 279 /** 274 280 * cardPaidProcess 275 * 281 * 276 282 * @todo Call Topup webservice to check and lock prepaid-card 277 283 * @param Array $aryCardInfo … … 279 285 * @return string 280 286 */ 281 public function cardPaidProcess ($aryCardInfo, &$aryTopupResult = array()) 287 public function cardPaidProcess ($aryCardInfo, &$aryTopupResult = array()) 282 288 { 283 289 $url = $this->config->item('topup_service_url'); 284 290 $action = 'http://tempuri.org/ITopupService/TopUp'; 285 291 $xml = $this->load->view('topup', $aryCardInfo, true); 286 292 287 293 $client = new nusoap_client($url); 288 294 $client->useHTTPPersistentConnection(); 289 295 $client->soap_defencoding = 'UTF-8'; 290 296 $client->operation = $action; 291 297 292 298 $result = $client->send($xml, $action); 293 299 294 300 if ($client->fault) { 295 301 return _SBG_CARD_PAY_FAIL; 296 302 } 297 303 298 304 $keys = array_keys($result); 299 305 300 306 $aryTopupResult = $result[$keys[0]]; 301 307 … … 308 314 return _SBG_CARD_PAY_FAIL; 309 315 } 310 316 311 317 return _SBG_CARD_PAY_SUCCESS; 312 318 } 313 319 314 320 /** 315 321 * chargeRootAccountProcess 316 * 322 * 317 323 * @todo Call charging webservice to charged fee from phone root account 318 324 * @param String $sentID … … 321 327 * @return string|number 322 328 */ 323 public function chargeRootAccountProcess ($sentID, $amount = 0, $contents = '') 329 public function chargeRootAccountProcess ($sentID, $amount = 0, $contents = '') 324 330 { 325 331 $url = $this->config->item('charging_service_url'); 326 332 $username = $this->config->item('charging_username'); 327 333 $password = $this->config->item('charging_password'); 328 $action = 'http://tempuri.org/processCharging'; 329 334 $action = 'http://tempuri.org/processCharging'; 335 330 336 $aryParams = array( 331 337 'user' => $username, … … 345 351 return _SBG_CHARGING_FAIL; 346 352 } 347 348 $aryErrs = array ( _SBG_CHARGING_FAIL_NOT_ENOUGH, 349 _SBG_CHARGING_FAIL_NOT_VIETTEL, 353 354 $aryErrs = array ( _SBG_CHARGING_FAIL_NOT_ENOUGH, 355 _SBG_CHARGING_FAIL_NOT_VIETTEL, 350 356 _SBG_CHARGING_FAIL_MORETHAN_LIMIT, 351 357 _SBG_CHARGING_NUMBER_NOT_EXISTED, … … 354 360 _SBG_CHARGING_GENERAL_ERROR, 355 361 _SBG_CHARGING_NUMBER_NOT_REGISTED); 356 357 if (in_array((int)$result['processChargingResult'], $aryErrs)) 358 return (int)$result['processChargingResult']; 359 362 363 if (in_array((int)$result['processChargingResult'], $aryErrs)) 364 return (int)$result['processChargingResult']; 365 360 366 return _SBG_CHARGING_SUCCESS; 361 367 } 362 368 363 369 /** 364 370 * sendMT 365 * 371 * 366 372 * @todo Calling MT webservice to send a SMS to a phone number 367 373 * @param String $receiverID … … 372 378 { 373 379 $aryMatch = array(); 374 380 375 381 if (preg_match('/^(0)([0-9]{9,10})$/', $receiverID, $aryMatch) == 1) { 376 382 $receiverID = '84'. $aryMatch[2]; 377 383 } 378 384 379 385 $username = $this->config->item('mt_username'); 380 386 $password = $this->config->item('mt_password'); 381 387 $action = 'http://tempuri.org/InsertMT'; 382 388 383 389 $aryParams = array( 384 390 'User' => $username, … … 393 399 'Info' => $message 394 400 ); 395 401 396 402 $xml = $this->load->view('services/mt', $aryParams, true); 397 403 $url = $this->config->item('mt_service_url'); … … 401 407 $client->operation = $action; 402 408 $result = $client->send($xml, $action); 403 409 404 410 if ($client->fault || (int)$result['InsertMTResult'] != 1) { 405 411 return _SBG_SEND_MT_FAIL; 406 412 } 407 413 408 414 return _SBG_SEND_MT_SUCCESS; 409 415 } 410 416 411 417 public function getCollaborator ($type = 2, $page = 10, $displaypage = 1) { 412 418 $action = 'http://tempuri.org/InsertMT'; … … 423 429 'displaypage' => $displaypage 424 430 ); 431 425 432 $xml = $this->load->view('bscc', $aryParams, true); 426 433 427 434 $client = new nusoap_client($url); 428 435 $client->useHTTPPersistentConnection(); 429 436 $client->soap_defencoding = 'UTF-8'; 430 437 $client->decode_utf8 = false; 431 438 432 439 $client->operation = $action; 433 440 $result = $client->send($xml, $action); … … 435 442 return _SBG_GET_COLLABORATOR_FAIL; 436 443 } 437 444 438 445 return $result['Result']['original']; 439 446 } 440 447 441 448 /** 442 449 * formatPhoneNumber 443 * 450 * 444 451 * @todo format phone number to prefix 0 or 84 445 452 * @param String $phoneNumber … … 465 472 $result = '0'. $phoneNumber; 466 473 } 467 474 468 475 return $result; 469 476 } 470 471 477 478 472 479 public function syncCollaborator($data){ 473 480 if ($data){ 474 $sql = $this->db->insert_string('tblcollaborator', $data) . ' ON DUPLICATE KEY UPDATE address = "'.$data['address'].'", 475 code = "'.$data['code'].'", 476 district = "'.$data['district'].'", 477 email = "'.$data['email'].'", 481 $sql = $this->db->insert_string('tblcollaborator', $data) . ' ON DUPLICATE KEY UPDATE address = "'.$data['address'].'", 482 code = "'.$data['code'].'", 483 district = "'.$data['district'].'", 484 email = "'.$data['email'].'", 478 485 full_name = "'.$data['full_name'].'", 479 486 passwd = "'.$data['passwd'].'", 480 cellphone = "'.$data['cellphone'].'", 481 precinct = "'.$data['precinct'].'", 487 cellphone = "'.$data['cellphone'].'", 488 precinct = "'.$data['precinct'].'", 482 489 province = "'.$data['province'].'", 483 490 created_time = "'.$data['created_time'].'", … … 499 506 } 500 507 } 501 508 502 509 public function deleteCollaborator($id){ 503 510 $sql = "DELETE FROM tblcollaborator WHERE id = ". $id; … … 511 518 } 512 519 } 513 520 514 521 public function getAllCollaboratorID(){ 515 522 $sql = "Select id from tblcollaborator"; … … 522 529 } 523 530 } 524 531 525 532 public function isViettel($number) { 526 533 $prefixViettel = array (
Note: See TracChangeset
for help on using the changeset viewer.