auth($token); } $data = D("Giftbag")->getGiftLists($game_id,USER_ACCOUNT,$p); if(empty($data)){ $this->set_message(1015,"暂无礼包"); } $this->set_message(200,"成功",$data); } /* * 根据游戏名称查询礼包 * @param string $game_name 游戏名称 * @param string $token * @author 鹿文学 */ public function search_gift_lists($game_name,$token="",$p=1,$version=""){ if(!empty($token)){ $this->auth($token); } $data = D("Giftbag")->searchGiftLists($game_name,USER_ACCOUNT,$p,$version); if(empty($data)){ $this->set_message(1015,"暂无礼包"); } $this->set_message(200,"成功",$data); } /** * 礼包列表 礼包数量 * @param int $p * author: xmy 280564871@qq.com */ public function gift_lists_num($p=1,$version,$game_name="",$token=""){ if(!empty($game_name)){ $game = D("Game")->where(['game_name'=>['like',"%".$game_name."%"]])->select(); if(!empty($game)){ $map['game_id'] = ['in',array_column($game,"id")]; }else{ $map['game_id'] =0; } } if(!empty($token)){ $this->auth($token); } $map['giftbag_version'] = $version; $data = D("Giftbag")->giftListsNum($map,$p,USER_ACCOUNT); if(empty($data)){ $this->set_message(1015,"暂无礼包"); } $this->set_message(200,"成功",$data); } /** * 领取激活码 * @param $token * @param $gift_id * author: xmy 280564871@qq.com */ public function get_novice($token,$gift_id){ $this->auth($token); $model = D("Giftbag"); $exist = $model->checkAccountGiftExist(USER_ACCOUNT,$gift_id); if($exist){ $this->set_message(1014,"已领取过该游戏"); } $novice = $model->getNovice(USER_ACCOUNT,$gift_id); if(empty($novice)){ $this->set_message(1015,"暂无激活码"); } $this->set_message(200,"领取成功",$novice); } /** * 礼包记录 * @param $token * @param int $p * author: xmy 280564871@qq.com */ public function get_my_gift_record($token,$p=1){ $this->auth($token); $data = D("Giftbag")->getMyGiftRecord(USER_ACCOUNT,$p); if(empty($data)){ $this->set_message(1047,"暂无礼包记录"); } $this->set_message(200,"成功",$data); } /** * 删除记录 * @param $token * @param $gift_id * author: xmy 280564871@qq.com */ public function delete_gift_record($token,$gift_id){ $this->auth($token); $result = D("Giftbag")->changeRecordStatus($gift_id,USER_ACCOUNT,1); if($result !== false){ $this->set_message(200,"删除成功"); }else{ $this->set_message(1054,"删除失败"); } } /** * 礼包详情 * @param $gift_id * author: xmy 280564871@qq.com */ public function get_detail($gift_id,$token=""){ if(!empty($token)){ $this->auth($token); } $model = new GiftbagModel(); $data = $model->getDetail($gift_id,USER_ACCOUNT); if(empty($data)){ $this->set_message(1015,"礼包不存在"); }else{ $this->set_message(200,"成功",$data); } } /** * 豪华礼包 * @param version 1 安卓 2苹果 * lcj */ public function index_gift($token="",$version){ if(!empty($token)){ $this->auth($token); } $map['game_status']=1; $map['end_time']=array(array('gt',time()),array('eq',0),'or'); $map['giftbag_type']=2; $map['status'] = 1; $map['giftbag_version'] = $version; $map['novice'] = array('neq',''); $gift = M('Giftbag','tab_') ->field('tab_giftbag.id as gift_id,relation_game_name,game_id,tab_giftbag.game_name,giftbag_name,giftbag_type,tab_game.icon,tab_giftbag.create_time') ->join('tab_game on tab_giftbag.game_id = tab_game.id') ->where($map) ->order('create_time desc') ->limit(4) ->select(); foreach ($gift as $key => $value) { $gift[$key]['gift_num']=gift_recorded($value['game_id'],$value['gift_id'])['wei']; $gift[$key]['icon'] = get_img_url($value['icon'],'path'); } //礼包广告图 if($version==1){ $adv = get_adv_data('and_wap_index_gift')[0]; }else{ $adv = get_adv_data('ios_wap_index_gift')[0]; } if($adv['game_id'] != 0){ $map['game_id'] = $adv['game_id']; $gdata = M('giftbag','tab_')->where($map)->find(); if(empty($gdata)){ $adv['game_id'] = 0; $adv['title'] = '礼包列表'; }else{ $adv['title'] = get_game_name($adv['game_id']); } } if(empty($gift)){ $data['gift'] = []; }else{ $data['gift'] = $gift; } $data['adv_img'] = get_cover($adv['data'],'path'); if(strpos($data['adv_img'],'http')===false){ $data['adv_img'] = 'http://'.$_SERVER['HTTP_HOST'].$data['adv_img']; } $data['adv_url'] = empty($adv['url'])?'':$adv['url']; $data['title'] = empty($adv['title'])?'':$adv['title']; $data['belong_game'] = empty($adv['belong_game'])?0:$adv['belong_game']; if(empty($data)){ $this->set_message(1015,"暂无礼包"); }else{ echo json_encode(array('code'=>200,'msg'=>'成功','data'=>$data)); } } }