Changeset 499 for pro-violet-viettel/sourcecode
- Timestamp:
- Nov 14, 2014 6:01:48 AM (11 years ago)
- Location:
- pro-violet-viettel/sourcecode
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-violet-viettel/sourcecode/application/config/config.php
r487 r499 388 388 $config['mo_password'] = 'sbg571285'; 389 389 390 $config['mt_username'] = 'sbg'; 391 $config['mt_password'] = 'sbg56ab77cdsgb'; 392 390 393 $config['charging_username'] = 'sbg'; 391 394 $config['charging_password'] = 'sbg123#@!'; 395 392 396 /* 393 397 |-------------------------------------------------------------------------- -
pro-violet-viettel/sourcecode/application/config/database.php
r490 r499 51 51 $db['default']['hostname'] = 'mysql:host=127.0.0.1'; 52 52 $db['default']['username'] = 'root';//sbg 53 $db['default']['password'] = ' Quyenhue@123';//sbg~~!!@@12353 $db['default']['password'] = '123456';//sbg~~!!@@123 54 54 $db['default']['database'] = 'violet-viettel'; 55 55 $db['default']['dbdriver'] = 'pdo'; -
pro-violet-viettel/sourcecode/application/config/routes.php
r483 r499 43 43 44 44 $route['violetservice/soanbai/mo'] = 'services/viettel/mo'; 45 $route['violetservice/soanbai/mo/'] = 'services/viettel/mo'; 45 46 $route['violetservice/soanbai/mo/wsdl'] = 'services/viettel/index/wsdl'; 47 $route['violetservice/soanbai/index'] = 'services/viettel/index/wsdl'; 48 $route['violetservice/soanbai'] = 'services/viettel/index/wsdl'; 49 $route['violetservice/soanbai/'] = 'services/viettel/index/wsdl'; 46 50 47 51 $route['admin'] = 'admin/home'; -
pro-violet-viettel/sourcecode/application/modules/frontend/models/servicepackage_model.php
r490 r499 8 8 const TOKENPW = 'violet'; 9 9 10 function __construct(){ 10 function __construct() 11 { 11 12 parent::__construct(); 12 13 $this->vservices->setApiUrl($this->config->item('api_url')); … … 19 20 return $this->db->query($sql)->result_array(); 20 21 } 22 21 23 function getPackage($p_id) 22 24 { … … 24 26 return $this->db->query($sql)->row_array(); 25 27 } 28 29 function getPackagePriceByCode ($p_code) 30 { 31 $sql='SELECT p_price FROM '. $this->table_name .' WHERE p_code = ?'; 32 $query = $this->db->query($sql , array($p_code)); 33 $row = $query->row_array(); 34 return $row['p_price']; 35 } 36 37 function getPackageByCode ($p_code) 38 { 39 $sql='SELECT * FROM '. $this->table_name .' WHERE p_code = ?'; 40 $query = $this->db->query($sql , array($p_code)); 41 $row = $query->row_array(); 42 return $row; 43 } 26 44 27 45 } -
pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php
r498 r499 6 6 const TOKENPW = 'violet'; 7 7 8 function __construct(){8 public function __construct(){ 9 9 parent::__construct(); 10 10 $this->vservices->setApiUrl($this->config->item('api_url')); … … 12 12 } 13 13 14 function checkLogin ($src, $token, $username, $password)14 public function checkLogin ($src, $token, $username, $password) 15 15 { 16 16 $data = $this->vservices->actionExecute('login', array('src' => $src, 'token' => $token, 'username' => $username, 'password' => $password), 'user'); 17 17 18 18 $arr_users = explode("&", $data); 19 19 $str_status = ''; … … 22 22 $usid = ''; 23 23 $fullname = ''; 24 24 25 for ($i=0; $i < count($arr_users); $i++) 25 26 { … … 68 69 } 69 70 70 function register ($username, $collaborator, &$status)71 public function register ($username, $collaborator, &$status='') 71 72 { 72 73 $user = array(); … … 76 77 $id = 0; 77 78 $errMsg = ''; 78 $username = '0'.substr($username, 2, strlen($username));79 79 $token = md5($username.self::TOKENPW); 80 80 $phone = $username; 81 81 82 if (!is_null($collaborator) || $collaborator != ''){ 82 if($this->isExistcollaborator($collaborator)){ 83 $data = $this->vservices->actionExecute('update', array('src'=>$src, 'username'=>$username, 'password'=>$password, 'fullname'=>null, 'phone'=>$username, 'token'=>$token), 'user'); 84 parse_str($data); 85 switch((int)$status) 86 { 87 case 0: 88 $us_id = $id; 89 $user['created_time'] = date('Y-m-d H:i:s'); 90 $user['us_id'] = $us_id; 91 $user['cellphone'] = $username; 92 $user['collaborator'] = $collaborator; 93 $this->db->insert('tbluser', $user); 94 $sms = "Chuc mung Qui vi da dang ky thanh cong tai khoan Soan Bai giang Online. Hay dang nhap vao soanbaigiang.smas.vn voi ten truy nhap ".$username.", mat khau ".$password." de su dung."; 95 $status = 1; 96 break; 97 case 2: 98 case 4: 99 $sms = "So dien thoai cua Qui vi da duoc dang ky !"; 100 $status = 0; 101 break; 102 default: 103 $status = 0; 104 $sms = $errMsg; 105 break; 106 } 107 } 108 else 109 { 83 if(!$this->isExistcollaborator($collaborator)){ 110 84 $sms = "Khong tim thay cong tac vien nao co so dien thoai [".$collaborator."] tren soanbaigiang.smas.vn!"; 111 85 $status = 0; 112 } 113 }else 114 { 115 $data = $this->vservices->actionExecute('update', array('src'=>$src, 'username'=>$username, 'password'=>$password, 'fullname'=>null, 'phone'=>$username, 'token'=>$token), 'user'); 116 parse_str($data); 117 switch((int)$status) 118 { 119 case 0: 120 $us_id = $id; 121 $user['created_time'] = date('Y-m-d H:i:s'); 122 $user['us_id'] = $us_id; 123 $user['cellphone'] = $username; 124 $this->db->insert('tbluser', $user); 125 $sms = "Chuc mung Qui vi da dang ky thanh cong tai khoan Soan Bai giang Online. Hay dang nhap vao soanbaigiang.smas.vn voi ten truy nhap ".$username.", mat khau ".$password." de su dung."; 126 $status = 1; 127 break; 128 case 2: 129 case 4: 130 $sms = "So dien thoai cua Qui vi da duoc dang ky !"; 131 $status = 0; 132 break; 133 default: 134 $status = 0; 135 $sms = $errMsg; 136 break; 137 } 86 return $status.'|'.$sms; 87 } 88 } 89 90 $data = $this->vservices->actionExecute('update', array('src'=>$src, 'username'=>$username, 'password'=>$password, 'fullname'=>null, 'phone'=>$username, 'token'=>$token), 'user'); 91 parse_str($data); 92 switch((int)$status) 93 { 94 case 0: 95 $us_id = $id; 96 $user['created_time'] = date('Y-m-d H:i:s'); 97 $user['us_id'] = $us_id; 98 $user['cellphone'] = $username; 99 if (!is_null($collaborator) || $collaborator != ''){ 100 $user['collaborator'] = $collaborator; 101 } 102 $this->db->query('UNLOCK TABLES'); 103 $this->db->insert('tbluser', $user); 104 $sms = "Chuc mung Qui vi da dang ky thanh cong tai khoan Soan Bai giang Online. Hay dang nhap vao soanbaigiang.smas.vn voi ten truy nhap ".$username.", mat khau ".$password." de su dung."; 105 $status = 1; 106 break; 107 case 2: 108 case 4: 109 $sms = "So dien thoai cua Qui vi da duoc dang ky!"; 110 $status = 0; 111 break; 112 default: 113 $status = 0; 114 $sms = $errMsg; 115 break; 138 116 } 139 117 … … 141 119 } 142 120 143 function create_random_password() 144 { 145 $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789"; 121 public function create_random_password() 122 { 123 //$alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789"; 124 $alphabet = "0123456789"; 146 125 $pass = array(); 147 126 $alphaLength = strlen($alphabet) - 1; … … 153 132 } 154 133 155 function get_user_by_id($us_id) 156 { 134 public function get_user_by_id($us_id) 135 { 136 $this->db->query('UNLOCK TABLES'); 157 137 $this->db->select('*')->from('tbluser')->where('us_id', $us_id); 158 138 $query = $this->db->get(); … … 164 144 } 165 145 166 function get_user_info($src, $token, $us_id)146 public function get_user_info($src, $token, $us_id) 167 147 { 168 148 $data = $this->vservices->actionExecute('getinfo', array('src' => $src, 'us_id' => $us_id, 'token'=>$token), 'user'); … … 170 150 } 171 151 172 function update_user($src, $token, $user, $us_id)152 public function update_user($src, $token, $user, $us_id) 173 153 { 174 154 $data = $this->vservices->actionExecute('update', array('src'=>$src, 'token'=>$token, 'us_id'=>$us_id, … … 180 160 } 181 161 182 function changeProfile($sentNumber, $username, $password, &$status)162 public function changeProfile($sentNumber, $username, $password, &$status='') 183 163 { 184 164 $user = array(); … … 205 185 break; 206 186 case 5: 207 $sms = "So dien thoai cá»§a Qui vi chua duoc dang ky 187 $sms = "So dien thoai cá»§a Qui vi chua duoc dang ky!"; 208 188 $status = 0; 209 189 break; … … 219 199 }else 220 200 { 221 $sms = "So dien thoai cá»§a Qui vi chua duoc dang ky 201 $sms = "So dien thoai cá»§a Qui vi chua duoc dang ky!"; 222 202 $status = 0; 223 203 } … … 225 205 } 226 206 227 function changePassword($username, $password, &$status)207 public function changePassword($username, $password, &$status = '') 228 208 { 229 209 $user = array(); … … 255 235 $sms = "Mat khau moi cua quy vi tren soanbaigiang.smas.vn la [".$pass."]"; 256 236 }else{ 257 $sms = "Qui vi da doi thanh cong mat khau tren soanbaigiang.smas.vn. 237 $sms = "Qui vi da doi thanh cong mat khau tren soanbaigiang.smas.vn."; 258 238 } 259 239 $status = 1; 260 240 break; 261 241 case 5: 262 $sms = "So dien thoai cá»§a Qui vi chua duoc dang ky 242 $sms = "So dien thoai cá»§a Qui vi chua duoc dang ky!"; 263 243 $status = 0; 264 244 break; … … 271 251 else 272 252 { 273 $sms = "So dien thoai cá»§a Qui vi da duoc dang ky 253 $sms = "So dien thoai cá»§a Qui vi da duoc dang ky!"; 274 254 $status = 0; 275 255 } … … 278 258 279 259 280 function checkLicense ($userId)260 public function checkLicense ($userId) 281 261 { 282 262 $isNotExpired = false; 283 $userInfo = $this->get_user_by_id($userId); 263 $userInfo = array(); 264 $userInfo = $this->get_user_by_id($userId); 265 284 266 $expireDate = $userInfo['expire_date']; 285 267 … … 292 274 } 293 275 294 function registerVip($username, $p_name, &$status) 295 { 296 $user = array(); 297 $sms = ''; 276 public function registerVip($username, $p_code) 277 { 278 $user = array(); 279 $sms = ''; 280 298 281 $result = $this->get_user_by_cellphone($username); 282 $package = $this->get_package((int)$p_code); 299 283 if($result){ 300 $package = $this->get_package($p_name);301 if ($result['acc_balanced'] >=$package['p_price'])284 285 if ($result['acc_balanced'] >= $package['p_price']) 302 286 { 303 287 $us_id = $result['us_id']; 304 $user['acc_balanced'] = $result['acc_balanced'] - $p _price;288 $user['acc_balanced'] = $result['acc_balanced'] - $package['p_price']; 305 289 if ($this->checkLicense($us_id)){ 306 290 $user['expire_date'] = date('Y-m-d', strtotime($result['expire_date'].' + '.$package['p_period'].' month')); … … 309 293 $user['expire_date'] = date('Y-m-d', strtotime('now + '.$package['p_period'].' month')); 310 294 } 311 $user['user_package'] = $p_id; 295 296 $user['p_id'] = $package['p_id']; 312 297 $user['updated_time'] = date('Y-m-d H:i:s'); 298 313 299 $this->updateUser($us_id, $user); 314 300 $sms = "Chuc mung Qui vi da dang ky su dung Soan Bai giang truc tuyen tren soanbaigiang.smas.vn. Qui vi co the su dung dich vu den 24h00 ngay ".date('d/m/Y', strtotime($user['expire_date'])); … … 327 313 } 328 314 329 function rechargeAccount($username, $amount, &$status)315 public function rechargeAccount($username, $amount) 330 316 { 331 317 $user = array(); … … 338 324 $user['updated_time'] = date('Y-m-d H:i:s'); 339 325 $this->updateUser($us_id, $user); 340 $sms = "Qui vi da nap thanh cong [".$amount."]vao tai khoan ".$username." tren soanbaigiang.smas.vn";326 $sms = "Qui vi da nap thanh cong ".$amount."VND vao tai khoan ".$username." tren soanbaigiang.smas.vn"; 341 327 $status = 1; 342 328 }else 343 329 { 344 $sms = "Tai khoan [".$username."]chua dang ki tai khoan tren he thong SBG Online soanbaigiang.smas.vn.";330 $sms = "Tai khoan ".$username." chua dang ki tai khoan tren he thong SBG Online soanbaigiang.smas.vn."; 345 331 $status = 0; 346 332 } … … 348 334 } 349 335 350 function get_user_by_cellphone($cellphone) 351 { 352 $this->db->select('*')->from('tbluser')->where('cellphone', $cellphone)->limit(1); 353 $result = $this->db->get()->row_array(); 354 return $result; 355 } 356 357 function isExistcollaborator($collaborator) 358 { 336 public function get_user_by_cellphone($cellphone) 337 { 338 $this->db->query('UNLOCK TABLES'); 339 $sql = 'SELECT * FROM tbluser where cellphone = ? LIMIT 0,1'; 340 $query = $this->db->query($sql, array($cellphone)); 341 $row = $query->row_array(); 342 return $row; 343 } 344 345 public function isExistcollaborator($collaborator) 346 { 347 $this->db->query('UNLOCK TABLES'); 359 348 $this->db->select('*')->from('tblcollaborator')->where('login_name', $collaborator)->limit(1); 360 349 $result = $this->db->get()->row_array(); … … 362 351 } 363 352 364 function updateUser($us_id, $data) 365 { 353 public function updateUser($us_id, $data) 354 { 355 $this->db->query('UNLOCK TABLES'); 366 356 $this->db->where('us_id', $us_id); 367 357 $this->db->update('tbluser', $data); 368 358 } 369 359 370 function get_package($p_name) 371 { 372 $this->db->select('*')->from('tblservicepackage')->where('p_name', $p_name); 373 $query = $this->db->get(); 374 if($query->num_rows() > 0) 375 { 376 $row = $query->row_array(); 377 return $row; 378 } 379 } 380 381 function insertSmslog($sentNumber, $userID, $serviceID, $commandcode, $info, $receiveTime) 382 { 360 public function get_package($p_code) 361 { 362 $this->db->query('UNLOCK TABLES'); 363 $sql = 'SELECT * FROM tblservicepackage where p_code = ? LIMIT 0,1'; 364 $query = $this->db->query($sql, array($p_code)); 365 $row = $query->row_array(); 366 return $row; 367 } 368 369 public function insertSmslog($sentNumber, $serviceID, $commandcode, $info, $receiveTime) 370 { 371 if (preg_match('/^(84)([0-9]{9,10})$/', $sentNumber, $aryMatch) == 1) { 372 $sentNumber = '0'. $aryMatch[2]; 373 } 374 375 try { 376 $user = $this->get_user_by_cellphone($sentNumber); 377 } 378 catch(Exception $e) { 379 380 } 381 383 382 $smslog = array(); 384 383 $smslog['sender'] = $sentNumber; 385 $smslog['us_id'] = $userID;384 $smslog['us_id'] = isset($user['us_id']) ? $user['us_id']:NULL; 386 385 $smslog['service_id'] = $serviceID; 387 386 $smslog['commandcode'] = $commandcode; 388 387 $smslog['info'] = $info; 389 388 $smslog['created_time'] = $receiveTime; 390 $this->db->insert('tblsmslog', $smslog); 389 $this->db->query('UNLOCK TABLES'); 390 $sql = 'INSERT INTO tblsmslog(sender, us_id, service_id, commandcode, info, created_time) VALUES(?,?,?,?,?,?)'; 391 $query = $this->db->query($sql, $smslog); 392 //$this->db->insert('tblsmslog', $smslog); 391 393 } 392 394 } -
pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php
r470 r499 16 16 } 17 17 18 public function index () 19 { 20 error_reporting(E_ALL); 21 $this->load->model('Services_model'); 22 //$this->Services_model->cardPaidProcess($aryParams); 23 echo $this->Services_model->processMORequest('01662860000', strtoupper('Sbg vip 1')); 24 25 } 26 18 27 public function testmo() { 19 28 $url = 'http://10.58.38.162/violetservice/soanbai/mo?wsdl'; … … 59 68 } 60 69 61 public function send($msg )70 public function send($msg, $receiverID) 62 71 { 63 72 $url = $this->config->item('mt_service_url'); … … 66 75 $operator = 'InsertMT'; 67 76 $operation = 'http://tempuri.org/InsertMT'; 68 77 78 $aryMatch = array(); 79 if (preg_match('/^(0)([0-9]{9,10})$/', $receiverID, $aryMatch) == 1) { 80 $receiverID = '84'. $aryMatch[2]; 81 } 82 69 83 $aryParams = array( 70 84 'User' => $username, … … 73 87 'UserID' => '841662860000', 74 88 'RequestID' => '4', 75 'ReceiverID' => '84988568786',89 'ReceiverID' => $receiverID, 76 90 'ServiceID' => '8062', 77 91 'CommandCode' => 'SBG', … … 93 107 } 94 108 109 var_dump($result); 110 95 111 echo "<br/>"; 96 112 echo "<h2>Request</h2>"; … … 104 120 { 105 121 $url = $this->config->item('topup_service_url'); 106 $operator = 'TopupService'; 107 $operation = 'http://soanbaigiang.smas.vn/ITopupService/TopUp'; 122 $operation = 'http://tempuri.org/ITopupService/TopUp';; 108 123 109 124 $username = 'sbg'; … … 162 177 'user' => $username, 163 178 'pass' => $password, 164 'MSISDN' => ' 1689925260',179 'MSISDN' => '01662860000', 165 180 'Charging' => '100', 166 181 'Contents' => 'Namta-Active' … … 180 195 } 181 196 197 var_dump($result); 198 182 199 echo "<br/>"; 183 200 echo "<h2>Request</h2>"; -
pro-violet-viettel/sourcecode/application/modules/services/controllers/viettel.php
r483 r499 35 35 function messageReceiver(){ 36 36 $aryArgs = func_get_args(); 37 list($username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $ contentType ,$info, $receiveTime) = $aryArgs;37 list($username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $info, $receiveTime) = $aryArgs; 38 38 39 39 $msgType = '0'; //text message … … 48 48 if ($username != $mo_username) return '0|0|Username is not corrected!'; 49 49 if ($password != $mo_password) return '0|0|Password is not corrected!'; 50 if (!$requestID) return '0|0|requestID is required!'; 51 if ((int)$requestID != 4) return '0|0|requestID is not corrected!'; 50 if (!$requestID) return '0|0|requestID is required!'; 52 51 if (!$userID) return '0|0|UserID is required!'; 53 52 if (!$serviceID) return '0|0|serviceID is required!'; 54 53 if ($serviceID != '8062') return '0|0|serviceID is not corrected!'; 55 56 $status = 0; 57 $sentNumber = $userID; 58 $username = !$receiverID ? $sentNumber : $receiverID; 59 60 $CI->load->model('frontend/user_model', 'userModel'); 61 $password = $CI->userModel->create_random_password(); 62 63 $result = $CI->userModel->register ($sentNumber, $receiverID, $serviceID, $commandCode, $info, $receiveTime, $status); 54 55 $CI->load->model('Services_model'); 56 $CI->load->model('frontend/User_model', 'objUserModel'); 57 $result = $CI->Services_model->processMORequest($userID, strtoupper($info)); 58 $CI->objUserModel->insertSmslog($receiverID, $serviceID, $commandCode, $info, $receiveTime); 64 59 65 60 $aryResult = explode ('|', $result); 66 67 61 return $aryResult[0].'|'.$msgType.'|'.$aryResult[1]; 68 62 } 69 63 70 64 $this->_server->addFunction('messageReceiver'); 65 71 66 try { 72 67 ob_start(); -
pro-violet-viettel/sourcecode/application/modules/services/views/mowsdl.php
r483 r499 6 6 <s:complexType> 7 7 <s:sequence> 8 <s:element minOccurs="0" maxOccurs="1" name="username" type="s:string"/> 9 <s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/> 10 <s:element minOccurs="0" maxOccurs="1" name="requestID" type="s:string"/> 11 <s:element minOccurs="0" maxOccurs="1" name="userID" type="s:string"/> 12 <s:element minOccurs="0" maxOccurs="1" name="receiverID" type="s:string"/> 13 <s:element minOccurs="0" maxOccurs="1" name="serviceID" type="s:string"/> 14 <s:element minOccurs="0" maxOccurs="1" name="commandCode" type="s:string"/> 15 <s:element minOccurs="0" maxOccurs="1" name="contentType" type="s:string"/> 16 <s:element minOccurs="0" maxOccurs="1" name="info" type="s:string"/> 17 <s:element minOccurs="0" maxOccurs="1" name="receiveTime" type="s:string"/> 8 <s:element minOccurs="0" maxOccurs="1" name="Username" type="s:string"/> 9 <s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string"/> 10 <s:element minOccurs="0" maxOccurs="1" name="RequestID" type="s:string"/> 11 <s:element minOccurs="0" maxOccurs="1" name="UserID" type="s:string"/> 12 <s:element minOccurs="0" maxOccurs="1" name="ReceiverID" type="s:string"/> 13 <s:element minOccurs="0" maxOccurs="1" name="ServiceID" type="s:string"/> 14 <s:element minOccurs="0" maxOccurs="1" name="CommandCode" type="s:string"/> 15 <s:element minOccurs="0" maxOccurs="1" name="Info" type="s:string"/> 16 <s:element minOccurs="0" maxOccurs="1" name="ReceiveTime" type="s:string"/> 18 17 </s:sequence> 19 18 </s:complexType>
Note: See TracChangeset
for help on using the changeset viewer.