request->post(); var_dump($data);exit; $data['user_id'] = $this->uid; $service = new RedpacketService(); $reslut = $service->create($data); return V($reslut['code'], $reslut['msg'], $reslut['data']); } /** * 抢红包 */ public function grab() { $redpacketId = $this->request->post('redpacket_id'); if (empty($redpacketId)) { return V(0, '红包ID不能为空'); } $service = new RedpacketService(); $reslut = $service->grabWithResult($redpacketId, $this->uid); return V($reslut['code'], $reslut['msg'], $reslut['data']); } /** * 获取抢红包结果 */ public function grabResult() { $redpacketId = $this->request->get('redpacket_id'); if (empty($redpacketId)) { return V(0, '红包ID不能为空'); } $service = new RedpacketService(); $result = $service->getGrabResult($redpacketId, $this->uid); if (!$result) { return V(0, '红包不存在'); } return V(1, '获取成功', $result); } /** * 红包详情 */ public function detail() { $redpacketId = $this->request->get('redpacket_id'); if (empty($redpacketId)) { return V(0, '红包ID不能为空'); } $service = new RedpacketService(); $detail = $service->getDetail($redpacketId, $this->uid); if (!$detail) { return V(0, '红包不存在'); } return V(1, '获取成功', $detail); } /** * 获取倒计时选项 */ public function countdownOptions() { $options = \app\common\model\Redpacket::$countdownOptions; $this->success('获取成功', $options); } // 获取房间内红包列表 public function roomRedPackets() { $roomId = $this->request->get('room_id'); $result = Db::name('redpacket')->where(['room_id' => $roomId, 'status' => [1, 0]])->select(); return V(1, '获取成功', $result); } }