Exemple #1
0
 public function convertProductToSocket($ProductInfo)
 {
     //订单状态为尚未通知服务器
     if ($ProductInfo['SendStatus'] == 0) {
         $oSocketType = @(include __APP_ROOT_DIR__ . "/etc/SocketType.php");
         $oSocketQueue = new Config_SocketQueue();
         //发放英雄
         if ($ProductInfo['ProductType'] == "hero") {
             $uType = 60227;
             $TypeInfo = $oSocketType[$uType];
             if ($TypeInfo['Type']) {
                 $DataArr = array('PackFormat' => $TypeInfo['PackFormat'], 'Length' => $TypeInfo['Length'], 'Length2' => 0, 'uType' => $uType, 'MsgLevel' => 0, 'Line' => 0, 'UserID' => $ProductInfo['UserId'], 'HeroID' => $ProductInfo['ProductId'], 'Serial' => $ProductInfo['SendId']);
             }
             $DataArr = array('ServerId' => $ProductInfo['ServerId'], 'uType' => $uType, 'UserId' => $DataArr['UserID'], 'MessegeContent' => serialize($DataArr), 'QueueTime' => time(), 'SendTime' => 0);
             $this->db->begin();
             $addQueue = $oSocketQueue->insert($DataArr);
             $updateStatus = $this->updateProductQueue($ProductInfo['SendId'], $ProductInfo['ProductId'], array('SendStatus' => 1));
             if ($addQueue && updateStatus) {
                 $this->db->commit();
                 return true;
             } else {
                 $this->db->rollback();
                 return false;
             }
         }
         //发放时装
         if ($ProductInfo['ProductType'] == "skin") {
             $uType = 60229;
             $TypeInfo = $oSocketType[$uType];
             if ($TypeInfo['Type']) {
                 $ServerList = @(include __APP_ROOT_DIR__ . "/etc/Server.php");
                 $ServerInfo = $ServerList[$ProductInfo['ServerId']];
                 $oSkin = new Config_Skin();
                 $SkinInfo = $oSkin->getRow($ProductInfo['ProductId'], $ServerInfo['AppId']);
                 $DataArr = array('PackFormat' => $TypeInfo['PackFormat'], 'Length' => $TypeInfo['Length'], 'Length2' => 0, 'uType' => $uType, 'MsgLevel' => 0, 'Line' => 0, 'UserID' => $ProductInfo['UserId'], 'HeroID' => $SkinInfo['HeroId'], 'HeroEquip' => $ProductInfo['ProductId'], 'Serial' => $ProductInfo['SendId']);
             }
             $DataArr = array('ServerId' => $ProductInfo['ServerId'], 'uType' => $uType, 'UserId' => $DataArr['UserID'], 'MessegeContent' => serialize($DataArr), 'QueueTime' => time(), 'SendTime' => 0);
             $this->db->begin();
             $addQueue = $oSocketQueue->insert($DataArr);
             $updateStatus = $this->updateProductQueue($ProductInfo['SendId'], $ProductInfo['ProductId'], array('SendStatus' => 1));
             if ($addQueue && updateStatus) {
                 $this->db->commit();
                 return true;
             } else {
                 $this->db->rollback();
                 return false;
             }
         }
         //发放金钱
         if ($ProductInfo['ProductType'] == "money") {
             $uType = 60223;
             $TypeInfo = $oSocketType[$uType];
             if ($TypeInfo['Type']) {
                 $ServerList = @(include __APP_ROOT_DIR__ . "/etc/Server.php");
                 $ServerInfo = $ServerList[$ProductInfo['ServerId']];
                 $oSkin = new Config_Skin();
                 $SkinInfo = $oSkin->getRow($ProductInfo['ProductId'], $ServerInfo['AppId']);
                 $DataArr = array('PackFormat' => $TypeInfo['PackFormat'], 'Length' => $TypeInfo['Length'], 'Length2' => 0, 'uType' => $uType, 'MsgLevel' => 0, 'Line' => 0, 'UserID' => $ProductInfo['UserId'], 'MoneyChanged' => $ProductInfo['ProductCount'], 'MoneyType' => $ProductInfo['ProductId'], 'Serial' => $ProductInfo['SendId']);
             }
             $DataArr = array('ServerId' => $ProductInfo['ServerId'], 'uType' => $uType, 'UserId' => $DataArr['UserID'], 'MessegeContent' => serialize($DataArr), 'QueueTime' => time(), 'SendTime' => 0);
             $this->db->begin();
             $addQueue = $oSocketQueue->insert($DataArr);
             $updateStatus = $this->updateProductQueue($ProductInfo['SendId'], $ProductInfo['ProductId'], array('SendStatus' => 1));
             if ($addQueue && updateStatus) {
                 $this->db->commit();
                 return true;
             } else {
                 $this->db->rollback();
                 return false;
             }
         }
         //发放游戏币
         if ($ProductInfo['ProductType'] == "appcoin") {
             $oProductPack = new Config_Product_Pack();
             $CodeInfo = $oProductPack->getUserProductPackCode($ProductInfo['SendId'], $ProductInfo['UserId']);
             $Comment = json_decode($CodeInfo['Comment'], true);
             if (!isset($Comment['ExchangeId'])) {
                 $oExchange = new Lm_Exchange();
                 $createExchange = $oExchange->createExchangeQueueByCode($ProductInfo['UserId'], $ProductInfo['ServerId'], $ProductInfo['ProductCount'], $ProductInfo['SendId']);
                 $this->db->begin();
                 if ($createExchange) {
                     $updateStatus = $this->updateProductQueue($ProductInfo['SendId'], $ProductInfo['ProductId'], array('SendStatus' => 1));
                     $Comment['ExchangeId'] = $createExchange;
                     $updateCode = $oProductPack->updatePackCode($ProductInfo['SendId'], array('Comment' => json_encode($Comment)));
                     if ($updateStatus && $updateCode) {
                         $this->db->commit();
                         return true;
                     } else {
                         $this->db->rollback();
                         return false;
                     }
                 } else {
                     $this->db->rollback();
                     return false;
                 }
             } else {
                 return false;
             }
         }
     }
 }
Exemple #2
0
 public function InsertCharacterKickOff($KickOffArr)
 {
     $this->db->begin();
     $position = Base_Common::getUserDataPositionById($KickOffArr['UserId']);
     $table_user = Base_Common::getUserTable($this->character_kick_off, $position);
     $user = $this->db->insert($table_user, $KickOffArr);
     $Date = date("Ym", $KickOffArr['KickOffTime']);
     $table_date = $this->CreateCharacterKickOffLog($Date);
     $oSocketType = @(include __APP_ROOT_DIR__ . "/etc/SocketType.php");
     $oSocketQueue = new Config_SocketQueue();
     $uType = 60221;
     $TypeInfo = $oSocketType[$uType];
     if ($TypeInfo['Type']) {
         $DataArr = array('PackFormat' => $TypeInfo['PackFormat'], 'Length' => $TypeInfo['Length'], 'Length2' => 0, 'uType' => $uType, 'MsgLevel' => 0, 'Line' => 0, 'UserID' => $KickOffArr['UserId'], 'KickOffReason' => $KickOffArr['KickOffReason'], 'Serial' => $KickOffArr['KickOffId']);
     }
     $DataArr = array('ServerId' => $KickOffArr['ServerId'], 'uType' => $uType, 'UserId' => $DataArr['UserID'], 'MessegeContent' => serialize($DataArr), 'QueueTime' => time(), 'SendTime' => 0);
     $addQueue = $oSocketQueue->insert($DataArr);
     $log = $this->db->insert($table_date, $KickOffArr);
     if ($user && $log && $addQueue) {
         $this->db->commit();
         return true;
     } else {
         $this->db->rollBack();
         return false;
     }
 }
Exemple #3
0
 public function convertExchangeToSocket($ExchangeId)
 {
     $ExchangeInfo = $this->getQueuedExchange($ExchangeId);
     //订单存在
     echo "convert-------->\n";
     print_R($ExchangeInfo);
     if ($ExchangeInfo['ExchangeId']) {
         if ($ExchangeInfo['ToSendTime'] <= time()) {
             $oSocketType = @(include __APP_ROOT_DIR__ . "/etc/SocketType.php");
             $oSocketQueue = new Config_SocketQueue();
             //订单状态为尚未通知服务器
             if ($ExchangeInfo['ReTryCount'] < 3) {
                 if ($ExchangeInfo['ExchangeStatus'] == 0) {
                     $uType = 60215;
                     $TypeInfo = $oSocketType[$uType];
                     if ($TypeInfo['Type']) {
                         $DataArr = array('PackFormat' => $TypeInfo['PackFormat'], 'Length' => $TypeInfo['Length'], 'Length2' => 0, 'uType' => $uType, 'MsgLevel' => 0, 'Line' => 0, 'UserID' => $ExchangeInfo['UserId'], 'ZoneID' => $ExchangeInfo['ServerId'], 'iCash' => $ExchangeInfo['AppCoin'], 'ExchangeId' => $ExchangeInfo['ExchangeId']);
                     }
                     $DataArr = array('ServerId' => $ExchangeInfo['ServerId'], 'uType' => $uType, 'UserId' => $DataArr['UserID'], 'MessegeContent' => serialize($DataArr), 'QueueTime' => time(), 'SendTime' => 0);
                     $this->db->begin();
                     $addQueue = $oSocketQueue->insert($DataArr);
                     $updateReTry = $this->updateExchangeQueue($ExchangeInfo['ExchangeId'], array('RetryCount' => $ExchangeInfo['ReTryCount'] + 1, 'ToSendTime' => time() + 60 * pow(2, $ExchangeInfo['ReTryCount'] + 1)));
                     echo "60215\n";
                     echo "addQueue:" . $addQueue . "\n";
                     echo "updateReTry:" . $updateReTry . "\n";
                     echo "=============>end\n";
                     if ($addQueue && $updateReTry) {
                         $this->db->commit();
                         return true;
                     } else {
                         $this->db->rollback();
                         return false;
                     }
                 } elseif ($ExchangeInfo['ExchangeStatus'] == 1) {
                     $uType = 60217;
                     $TypeInfo = $oSocketType[$uType];
                     if ($TypeInfo['Type']) {
                         $DataArr = array('PackFormat' => $TypeInfo['PackFormat'], 'Length' => $TypeInfo['Length'], 'Length2' => 0, 'uType' => $uType, 'MsgLevel' => 0, 'Line' => 0, 'UserID' => $ExchangeInfo['UserId'], 'ZoneID' => $ExchangeInfo['ServerId'], 'SN' => $ExchangeInfo['ExchangeSn'], 'iCash' => $ExchangeInfo['AppCoin'], 'ExchangeId' => $ExchangeInfo['ExchangeId']);
                     }
                     $DataArr = array('ServerId' => $ExchangeInfo['ServerId'], 'uType' => $uType, 'UserId' => $DataArr['UserID'], 'MessegeContent' => serialize($DataArr), 'QueueTime' => time(), 'SendTime' => 0);
                     $this->db->begin();
                     $addQueue = $oSocketQueue->insert($DataArr);
                     $updateReTry = $this->updateExchangeQueue($ExchangeInfo['ExchangeId'], array('RetryCount' => $ExchangeInfo['ReTryCount'] + 1, 'ToSendTime' => time() + 60 * pow(2, $ExchangeInfo['ReTryCount'] + 1)));
                     echo "60217\n";
                     echo "addQueue:" . $addQueue . "\n";
                     echo "updateReTry:" . $updateReTry . "\n";
                     if ($addQueue && $updateReTry) {
                         $this->db->commit();
                         return true;
                     } else {
                         $this->db->rollback();
                         return false;
                     }
                 }
             } else {
                 $this->ExchangeFail($ExchangeInfo['ExchangeId']);
             }
         }
     }
 }