Exemplo n.º 1
0
 public function UnPackAddMoney($buff, $uType)
 {
     $oSocketType = @(include __APP_ROOT_DIR__ . "/etc/SocketType.php");
     $TypeInfo = $oSocketType[$uType];
     if ($TypeInfo['Type']) {
         $unpackArr = unpack($TypeInfo['UnPackFormat'], $buff);
         $oProduct = new Config_Product_Product();
         $remove = $oProduct->removeSentLog($unpackArr['Serial'], $unpackArr['uMoneyType'], $unpackArr['uResultID']);
         return $remove;
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 public function usePackCode($ProductPackCode, $ServerId, $UserId, $UsedTime)
 {
     $this->db->begin();
     $PackCode = $this->getProductPackCode($ProductPackCode);
     $Pack = $this->getRow($PackCode['ProductPackId']);
     $Comment = json_decode($Pack['Comment'], true);
     $bind = array('CodeStatus' => 1, 'ServerId' => $ServerId, 'UsedUser' => $UserId, 'UsedTime' => $UsedTime);
     $oProduct = new Config_Product_Product();
     foreach ($Comment as $Type => $TypeInfo) {
         foreach ($TypeInfo as $ProductId => $ProductCount) {
             $Sent = $oProduct->insertIntoProductSendList($ProductPackCode, 'ProductPack', $ProductId, $Type, $ProductCount, $UserId, $ServerId, time());
             if (!$Sent) {
                 $this->db->rollback();
                 return false;
             }
         }
     }
     $updatePackCode = $this->updatePackCode($ProductPackCode, $bind);
     if ($updatePackCode && $Sent) {
         $this->db->commit();
         return true;
     } else {
         $this->db->rollback();
         return false;
     }
 }
Exemplo n.º 3
0
 public function testExchange()
 {
     $ExchangeInfo['Comment'] = json_encode(array('ProductPackCode' => 'jChrsrjMs'));
     $ExchangeInfo['AppId'] = 101;
     $ExchangeInfo['ExchangeId'] = '1234567896134567489';
     $oProduct = new Config_Product_Product();
     $oProductPack = new Config_Product_Pack();
     $Comment = json_decode($ExchangeInfo['Comment'], true);
     //移除道具发送队列
     $remove = $oProduct->removeSentLog($Comment['ProductPackCode'], $ExchangeInfo['AppId'], 0);
     //获取礼包信息
     $PackCode = $oProductPack->getProductPackCode($Comment['ProductPackCode']);
     //解开备注字段
     $C = json_decode($PackCode['Comment']);
     //添加兑换ID
     $C['ExchangeId'] = $ExchangeInfo['ExchangeId'];
     //更新兑换ID
     $oProductPack->updatePackCode($Comment['ProductPackCode'], array('Comment' => json_encode($C)));
 }
Exemplo n.º 4
0
 /**
  *用户礼包码列表
  */
 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);
     }
 }