Changeset 909


Ignore:
Timestamp:
Apr 24, 2015 11:17:57 AM (10 years ago)
Author:
dungnv
Message:
 
Location:
pro-violet-viettel/sourcecode/application/modules/services
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php

    r884 r909  
    22/**
    33 * Viettel Class
    4  * 
     4 *
    55 * @author dzungnv02
    66 *
    77 */
    88
    9 class Sendmessage extends MX_Controller 
     9class Sendmessage extends MX_Controller
    1010{
    1111        private $_xmlHeader = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
    12                
    13         public function __construct() 
     12
     13        public function __construct()
    1414        {
    1515                parent::__construct();
    1616        }
    17        
    18         public function index () 
     17
     18        public function index ()
    1919        {
    2020                error_reporting(E_ALL);
     
    2929                echo $this->Services_model->cardPaidProcess($aryParams);
    3030        }
    31        
     31
    3232        public function testmo() {
    3333                $url = 'http://10.58.38.162/violetservice/soanbai/mo?wsdl';
     
    4545                                'receiveTime' => date('Ymd H:i:s')
    4646                );
    47                
     47
    4848                $client = new nusoap_client($url, false);
    4949                $client->useHTTPPersistentConnection();
    5050                $xml = $this->load->view('mo', null, true);
    51                
     51
    5252                $operator = 'MOReceiver';
    5353                $operation = 'http://tempuri.org/MOReceiver';
     
    5555                $client->soap_defencoding = 'UTF-8';
    5656                $client->operation = $operation;
    57                 $result = $client->send($this->_xmlHeader.$xml, $operation);           
     57                $result = $client->send($this->_xmlHeader.$xml, $operation);
    5858                //$result = $client->call('MOReceiver', $aryParams ,$operator ,$operation);
    59                
     59
    6060                echo $client->responseData;
    61                
     61
    6262                /* $err = $client->getError();
    63                        
     63
    6464                if ($err) {
    6565                        echo '<p><b>Error: ' . $err . '</b></p>';
    6666                }
    67                
    68                 echo "<br/>";
    69                 echo "<h2>Request</h2>";
    70                 echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
    71                 echo "<h2>Response</h2>";
    72                 echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>"; */           
    73         }
    74        
     67
     68                echo "<br/>";
     69                echo "<h2>Request</h2>";
     70                echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
     71                echo "<h2>Response</h2>";
     72                echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>"; */
     73        }
     74
    7575        public function send($msg, $receiverID)
    7676        {
     
    8080                $operator = 'InsertMT';
    8181                $operation = 'http://tempuri.org/InsertMT';
    82                
     82
    8383                $aryMatch = array();
    8484                if (preg_match('/^(0)([0-9]{9,10})$/', $receiverID, $aryMatch) == 1) {
    8585                        $receiverID = '84'. $aryMatch[2];
    8686                }
    87                
     87
    8888                $aryParams = array(
    8989                                'User' => $username,
     
    9898                                'Info' => urldecode($msg).' - Host: '.$_SERVER['HTTP_HOST'].' - '. date('Y-m-d H:i:s')//'Test MT '. date('Y-m-d H:i:s'),
    9999                );
    100        
     100
    101101                $xml = $this->load->view('mt', $aryParams, true);
    102102                $client = new nusoap_client($url);
     
    104104                $client->soap_defencoding = 'UTF-8';
    105105                $client->operation = $operation;
    106        
     106
    107107                $result = $client->send($this->_xmlHeader.$xml, $operation);
    108108                $err = $client->getError();
    109                        
     109
    110110                if ($err) {
    111111                        echo '<p><b>Error: ' . $err . '</b></p>';
    112112                }
    113                
     113
    114114                var_dump($result);
    115                
     115
    116116                echo "<br/>";
    117117                echo "<h2>Request</h2>";
     
    119119                echo "<h2>Response</h2>";
    120120                echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
    121        
    122         }
    123        
    124         public function topup () 
     121
     122        }
     123
     124        public function topup ()
    125125        {
    126126                $url = $this->config->item('topup_service_url');
    127                
     127
    128128                //echo file_get_contents($url);
    129129                //exit();
    130                
     130
    131131                $operation = 'http://tempuri.org/ITopupService/TopUp';
    132                
     132
    133133                $username = 'sbg';
    134134                $password = 'sbg56ab77cdsgb';
    135                
     135
    136136                $aryParams = array(
    137137                        'EWalletID' => 0,
     
    144144                $client->soap_defencoding = 'UTF-8';
    145145                $client->operation = $operation;
    146                
     146
    147147                $result = $client->send($this->_xmlHeader.$xml, $operation);
    148148                $err = $client->getError();
    149                
     149
    150150                if ($client->fault) {
    151151                    echo "<h2>Fault loi:</h2><pre>";
     
    169169                echo "<h2>Response</h2>";
    170170                echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
    171                
    172         }
    173        
    174         public function charging ()
    175         {
     171
     172        }
     173
     174        public function chargingws ()
     175        {
     176                //$op = $this->input->get('op', TRUE);
     177                //$op = trim($op) == '' ? 'Balance' : 'processCharging';
    176178                $url = $this->config->item('charging_service_url');
    177                
     179                $content = file_get_contents ($url.'?op=Charge');
     180                header('Content-Type: text/html; charset=utf-8');
     181                echo $content;
     182        }
     183
     184        public function getBalance()
     185        {
     186                //GetAmountBalance
     187                $url = $this->config->item('charging_service_url');
     188
    178189                $username = $this->config->item('charging_username');
    179190                $password = $this->config->item('charging_password');
    180                
     191                $operator = 'GetAmountBalance';
     192                $operation = 'http://tempuri.org/Balance';
     193
     194                $aryParams = array(
     195                                'user' => $username,
     196                                'pass' => $password,
     197                                'MSISDN' => '01662860000',
     198                );
     199
     200                $xml = $this->load->view('chargingBalance', $aryParams, true);
     201                $client = new nusoap_client($url.'?op=Balance');
     202                $client->useHTTPPersistentConnection();
     203                $client->soap_defencoding = 'UTF-8';
     204                $client->operation = $operation;
     205
     206                $result = $client->send($this->_xmlHeader.$xml, $operation);
     207                $err = $client->getError();
     208
     209                if ($err) {
     210                        echo '<p><b>Error: ' . $err . '</b></p>';
     211                }
     212
     213                var_dump($result);
     214
     215                echo "<br/>";
     216                echo "<h2>Request</h2>";
     217                echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
     218                echo "<h2>Response</h2>";
     219                echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
     220        }
     221
     222        public function charging ()
     223        {
     224                $url = $this->config->item('charging_service_url');
     225
     226                $username = $this->config->item('charging_username');
     227                $password = $this->config->item('charging_password');
     228
    181229                $operator = 'processCharging';
    182                 $operation = 'http://tempuri.org/processCharging';
    183                
     230                $operation = 'http://tempuri.org/Charge';
     231
    184232                $aryParams = array(
    185233                                'user' => $username,
     
    189237                                'Contents' => 'Namta-Active'
    190238                );
    191                
     239
    192240                $xml = $this->load->view('charging', $aryParams, true);
    193241                $client = new nusoap_client($url);
     
    195243                $client->soap_defencoding = 'UTF-8';
    196244                $client->operation = $operation;
    197                
     245
    198246                $result = $client->send($this->_xmlHeader.$xml, $operation);
    199247                $err = $client->getError();
    200                        
     248
    201249                if ($err) {
    202250                        echo '<p><b>Error: ' . $err . '</b></p>';
    203251                }
    204                
     252
    205253                var_dump($result);
    206                
    207                 echo "<br/>";
    208                 echo "<h2>Request</h2>";
    209                 echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
    210                 echo "<h2>Response</h2>";
    211                 echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";             
    212         }
    213        
     254
     255                echo "<br/>";
     256                echo "<h2>Request</h2>";
     257                echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
     258                echo "<h2>Response</h2>";
     259                echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
     260        }
     261
    214262        public function getCollaborators () {
    215263                $client = new SoapClient($this->config->item('bccs_service_url'), array(  'trace'      => true,
     
    219267                $password = $this->config->item('bccs_password');
    220268                $wscode = 'getListShopAndStaftInfo';
    221                
     269
    222270                $input = new Input($username, $password, $wscode/* , 2, 1,5000 */);
    223271                $param = new Param();
    224                
     272
    225273                $params = array(
    226274                                "Input" => $input,
     
    228276                                "Param" => $param,
    229277                );
    230                
     278
    231279                var_dump($params);
    232280
     
    234282                var_dump($response);
    235283        }
    236        
    237        
     284
     285
    238286}
    239287
  • pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php

    r906 r909  
    177177
    178178                                if (trim($arySmsReturn[1]) == trim(lang('_SBG_MO_USER_REGISTER_VIP_FAIL_NOT_ENOUGH_MSG'))) {
    179                                         $maxCharging = 50000;
    180179                                        $amount = $packageData ['p_price'];
    181                                         $count = $amount > $maxCharging ? ceil($amount/ _SBG_CHARGING_MAX_VALUE) : 1;
    182                                         $value = 0;
    183                                         for ($i = 1; $i <= $count; $i++) {
    184                                                 $value = $amount > _SBG_CHARGING_MAX_VALUE ? _SBG_CHARGING_MAX_VALUE : $amount;
    185                                                 $amount -= $value;
    186                                                 $result = $this->chargeRootAccountProcess($sentNumber, $value, $sentNumber.' paid for SBG');
    187                                         }
     180                                        $result = $this->chargeRootAccountProcess($sentNumber, $amount, $sentNumber.' paid for SBG');
    188181
    189182                                        if ($result == _SBG_CHARGING_SUCCESS) {
     
    243236                                }
    244237                                else if ($result == _SBG_CHARGING_FAIL_MORETHAN_LIMIT) {
    245                                         /* $aryPatterns = array ('/:sendid:/');
     238                                        $aryPatterns = array ('/:sendid:/');
    246239                                        $smsReturn = preg_replace($aryPatterns, array($sentNumber), lang('_SBG_MO_CHARGING_FAIL_MORETHAN_LIMIT_MSG'));
    247                                         $smsReturn = _SBG_MO_PROCCESS_ERR.'|'.$smsReturn; */
    248 
    249 
    250 
    251 
     240                                        $smsReturn = _SBG_MO_PROCCESS_ERR.'|'.$smsReturn;
    252241                                }else if ($result == _SBG_CHARGING_FAIL_NOT_VIETTEL || $result == _SBG_CHARGING_NUMBER_NOT_EXISTED || $result == _SBG_CHARGING_NUMBER_NOT_AVAILABLE) {
    253242                                        $smsReturn = _SBG_MO_PROCCESS_ERR.'|'.lang('_SBG_MO_CHARGING_FAIL_NOT_VIETTEL_MSG');
     
    265254                                }
    266255                                break;
    267                                
     256
    268257                        case _SBG_MO_PASSWORD_COLLABORATOR_SERVICE:
    269258                                $smsReturn = $this->objCollaboratorModel->getPassword($sentNumber);
    270259                                break;
    271                        
     260
    272261                        case _SBG_MO_UNSUBSCRIBE_SERVICE:
    273262                        case _SBG_MO_SYNTAX_ERR:
     
    339328                $username = $this->config->item('charging_username');
    340329                $password = $this->config->item('charging_password');
    341                 $action = 'http://tempuri.org/processCharging';
     330                $action = 'http://tempuri.org/Charge';
    342331
    343332                $aryParams = array(
     
    355344                $client->operation = $action;
    356345                $result = $client->send($xml, $action);
     346
     347                error_log(date('Y-m-d H:i:s').' -- DATA: '. var_export($xml, TRUE).' -- CASE: '. $case . "\n", 3, '/srv/www/sbg/log/chargeresult.log');
     348                error_log(date('Y-m-d H:i:s').' -- DATA: '. var_export($result, TRUE).' -- CASE: '. $case . "\n", 3, '/srv/www/sbg/log/chargeresult.log');
     349
    357350                if ($client->fault) {
    358351                        return _SBG_CHARGING_FAIL;
  • pro-violet-viettel/sourcecode/application/modules/services/views/charging.php

    r457 r909  
    11<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    22  <soap:Body>
    3     <processCharging xmlns="http://tempuri.org/">
     3    <Charge xmlns="http://tempuri.org/">
    44      <user><?php echo $user?></user>
    55      <pass><?php echo $pass?></pass>
     
    77      <Charging><?php echo $Charging?></Charging>
    88      <Contents><?php echo $Contents?></Contents>
    9     </processCharging>
     9    </Charge>
    1010  </soap:Body>
    1111</soap:Envelope>
Note: See TracChangeset for help on using the changeset viewer.