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; } } } }
/** *用户礼包码列表 */ public function getUserProductPackCodeAction() { //基础元素,必须参与验证 $User['UserId'] = abs(intval($this->request->UserId)); $User['Used'] = abs(intval($this->request->Used)); $User['ProductPackId'] = abs(intval($this->request->ProductPackId)); $User['GenId'] = abs(intval($this->request->GenId)); $User['PageSize'] = abs(intval($this->request->PageSize)); $User['Page'] = abs(intval($this->request->Page)); $User['Time'] = abs(intval($this->request->Time)); $User['ReturnType'] = $this->request->ReturnType ? $this->request->ReturnType : 2; //URL验证码 $sign = $this->request->sign; //私钥,以后要移开到数据库存储 $p_sign = 'lm'; $sign_to_check = base_common::check_sign($User, $p_sign); //不参与验证的元素 //验证URL是否来自可信的发信方 if ($sign_to_check == $sign) { if ($User['UserId']) { //验证时间戳,时差超过600秒即认为非法 if (abs($User['Time'] - time()) <= 600) { //查询用户 $UserInfo = $this->oUser->GetUserById($User['UserId']); if ($UserInfo['UserId']) { unset($User['ReturnType']); $oProductPack = new Config_Product_Pack(); $ProductPackCodeList = $oProductPack->getUserProductPackCodeList($User['UserId'], $User['Used'], $User['ProductPackId'], $User['GenId'], ($User['Page'] - 1) * $User['PageSize'], $User['PageSize']); if (is_array($ProductPackCodeList['UserProductPackCodeList'])) { foreach ($ProductPackCodeList['UserProductPackCodeList'] as $Code => $CodeData) { if (!isset($ProductPackList[$CodeData['ProductPackId']])) { $ProductPackList[$CodeData['ProductPackId']] = $oProductPack->getRow($CodeData['ProductPackId']); } if (!isset($GenLogList[$CodeData['GenId']])) { $GenLogList[$CodeData['GenId']] = $oProductPack->GetGenPackCodeLogById($CodeData['GenId']); } } } if (is_array($ProductPackList)) { $oSkin = new Config_Skin(); $oHero = new Config_Hero(); $oMoney = new Config_Money(); $oProduct = new Config_Product_Product(); $oApp = new Config_App(); foreach ($ProductPackList as $ProductPack => $ProductPackInfo) { unset($Comment); $Comment = json_decode($ProductPackInfo['Comment'], true); if (!isset($ProductInfo[$Type][$ProductPackInfo['AppId']][$ProductId])) { if (is_array($Comment)) { foreach ($Comment as $Type => $TypeInfo) { foreach ($TypeInfo as $ProductId => $Count) { if (!isset($ProductInfo[$Type][$ProductPackInfo['AppId']][$ProductId])) { if ($Type == "hero") { $ProductInfo[$Type][$ProductPackInfo['AppId']][$ProductId] = $oHero->getRow($ProductId, $ProductPackInfo['AppId'], '*'); } elseif ($Type == "skin") { $ProductInfo[$Type][$ProductPackInfo['AppId']][$ProductId] = $oSkin->getRow($ProductId, $ProductPackInfo['AppId'], '*'); } elseif ($Type == "product") { $ProductInfo[$Type][$ProductPackInfo['AppId']][$ProductId] = $oProduct->getRow($ProductId, $ProductPackInfo['AppId'], '*'); } elseif ($Type == "money") { $ProductInfo[$Type][$ProductPackInfo['AppId']][$ProductId] = $oMoney->getRow($ProductId, $ProductPackInfo['AppId'], '*'); } elseif ($Type == "appcoin") { $AppInfo = $oApp->getRow($ProductPackInfo['AppId']); $comment = json_decode($AppInfo['comment'], true); $ProductInfo[$Type][$ProductPackInfo['AppId']][$ProductId]['name'] = $comment['coin_name']; } } $ProductList[$Type]['detail'][$ProductId] = $ProductInfo[$Type][$ProductPackInfo['AppId']][$ProductId]['name'] . "*" . $Count . "个"; } $TypeList[$Type] = implode(",", $ProductList[$Type]['detail']); } $ProductPackList[$ProductPack]['ProductListText'] = implode(",", $TypeList); } else { $ProductPackList[$ProductPack]['ProductListText'] = "无道具"; } } } } $result = array('return' => 1, 'ProductPackCodeList' => $ProductPackCodeList, 'ProductPackList' => $ProductPackList, 'GenLogList' => $GenLogList); } else { $result = array('return' => 2, 'comment' => "无此用户"); } } else { $result = array('return' => 2, 'comment' => "时间有误"); } } else { $result = array('return' => 0, 'comment' => "请选择用户"); } } else { $result = array('return' => 2, 'comment' => "验证失败,请检查URL"); } $User['ReturnType'] = $this->request->ReturnType ? $this->request->ReturnType : 2; if ($User['ReturnType'] == 1) { echo json_encode($result); } }