services = $services; } /** * 抽奖活动信息 * @param Request $request */ public function LotteryInfo(Request $request) { $id = $request->get('id','1'); if (intval($id) <= 0) return $this->error('请上传抽奖ID'); $lottery = $this->services->getLottery($id, '*', ['prize'], true); if (!$lottery) { $this->error('未获取到抽奖活动'); } $lottery = $lottery->toArray(); $lotteryData = ['lottery' => $lottery]; $lotteryData['lottery_num'] = $this->auth->lottery_num ?? 0; $this->success('获取成功', $lotteryData); } /** * 参与抽奖 * @param Request $request * @return mixed */ public function luckLottery(Request $request) { $id = $request->get('id','1'); if (!$id) { $this->error('请上传抽奖ID'); } if ($this->auth->lottery_num <=0){ $this->error('抽奖次数不足'); } $uid =$this->auth->id; $key = 'lucklotter_limit_' . $uid; if (Cache::get($key)) { $this->error('您求的频率太过频繁,请稍后请求!'); } Cache::set('lucklotter_limit_' . $uid, $uid, 1); $arrUserinfo = $this->auth->getUser()->toArray(); list($nError,$arrData) = $this->services->luckLottery($arrUserinfo, $id); if ($nError === 1 ) { $this->error($arrData); } $this->success('', $arrData); } /** * 获取抽奖记录 * @param Request $request * @return mixed */ public function lotteryRecord(Request $request) { $uid = $this->auth->id; $pageSize = (int)$this->request->param('pageSize', 10); $page = (int)$this->request->param('page', 1); $lotteryRecordServices = new LuckLotteryRecordServices(); $arrData = $lotteryRecordServices->getRecord($uid,$page,$pageSize); $this->success('', $arrData); } }