/**
  * 获取指定用户组允许的AppId
  * @param integer $data_groups
  * @return array
  */
 public function getApp($data_groups, $fields = '*')
 {
     $returnArr = array();
     //声明需要调取的app类
     $oAppData = new Config_App();
     $data_groups = trim($data_groups);
     $table_to_process = $this->getDbTable($this->table);
     //查找指定data_groups的数据
     $sql = "SELECT distinct(AppId) FROM {$table_to_process} where group_id in (" . $data_groups . ")";
     $level_app = $this->db->getAll($sql);
     if ($level_app) {
         foreach ($level_app as $key => $value) {
             //默认所有游戏
             if ($value['AppId'] == 0) {
                 $app_data = $oAppData->getAll($fields);
                 if (isset($app_data)) {
                     foreach ($app_data as $k => $v) {
                         if (!isset($returnArr[$v['AppId']])) {
                             $returnArr[$v['AppId']] = $v;
                         }
                     }
                 }
             } else {
                 $app_data = $oAppData->getRow($value['AppId'], $fields);
                 if (isset($app_data)) {
                     if (!isset($returnArr[$app_data['AppId']])) {
                         $returnArr[$app_data['AppId']] = $app_data;
                     }
                 }
             }
         }
     }
     return $returnArr;
 }
Beispiel #2
0
 public function createExchangeQueueByUser($UserId, $ServerId, $Coin)
 {
     $oServer = new Config_Server();
     $oApp = new Config_App();
     $ServerInfo = $oServer->getRow($ServerId);
     //服务器存在
     if ($ServerInfo['ServerId']) {
         $AppInfo = $oApp->getRow($ServerInfo['AppId']);
         if ($AppInfo['AppId']) {
             $oUser = new Lm_User();
             $UserInfo = $oUser->GetUserById($UserId);
             //用户存在
             if ($UserInfo['UserId']) {
                 $time = time();
                 //初始化兑换信息
                 $ExchangeInfo = array('OrderId' => 0, 'AppId' => $ServerInfo['AppId'], 'PartnerId' => $ServerInfo['PartnerId'], 'Coin' => $Coin, 'ServerId' => $ServerInfo['ServerId'], 'UserId' => $UserInfo['UserId'], 'AppCoin' => $Coin * $AppInfo['exchange_rate'], 'UserSourceId' => $UserInfo['UserSourceId'], 'UserSourceDetail' => $UserInfo['UserSourceDetail'], 'UserSourceProjectId' => $UserInfo['UserSourceProjectId'], 'UserSourceActionId' => $UserInfo['UserSourceActionId'], 'UserRegTime' => $UserInfo['UserRegTime'], 'ExchangeStatus' => 0, 'ReTryCount' => 0, 'ExchangeType' => 3, 'CreateExchangeTime' => $time, 'ExchangeId' => date("YmdHis", $time) . sprintf("%04d", rand(1, 9999)), 'ToSendTime' => $time);
                 $this->db->begin();
                 $queueTable = Base_Widget::getDbTable($this->table_exchange_queue);
                 //添加兑换队列
                 $addQueue = $this->db->insert($queueTable, $ExchangeInfo);
                 $coinUpdate = $oUser->updateUserCoin($UserInfo['UserId'], $Coin * -1);
                 //扣款
                 if ($addQueue && $coinUpdate) {
                     //执行
                     $this->db->commit();
                     return $ExchangeInfo['ExchangeId'];
                 } else {
                     $this->db->rollBack();
                     return false;
                 }
             } else {
                 return false;
             }
         } else {
             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);
     }
 }