Esempio n. 1
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);
     }
 }