[ 'only' => ['zoneList'] ] ]; /** * 首页专区列表 * @return array */ public function zoneList() { return $this->renderSuccess('数据返回成功',ZoneModel::getList()); } /** * 刮奖专区列表 * @return array */ public function zoneGoodsList() { $param = Request::param(); return $this->renderSuccess('数据返回成功',ZoneGoods::getList($param,true)); } /** * 刮奖初始化数据 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function beginInitInfo() { $param = Request::param(); $zoneGoodsId = $param['zone_goods_id']; $info = ZoneGoods::where(['status' => 1,'id' => $zoneGoodsId]) ->field('max_awards_amount,content,price,bg_image') ->find(); if (empty($info)) $this->renderError('数据不存在'); $info['important'] = '最高中奖金额'.format_money($info['max_awards_amount']); if ($info['bg_image']) $info['bg_image'] = get_image_url($info['bg_image']); unset($info['max_awards_amount']); return $this->renderSuccess('数据返回成功',['data' => $info]); } /** * 立即刮奖 * @param $zoneGoodsId * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function beginLottery() { $param = Request::param(); $zoneGoodsId = $param['zone_goods_id']; $userData = $this->request->userInfo; # 判断余额够不够 $judgeRes = ZoneLogic::judgeBalance($userData['id'],$zoneGoodsId); if (!$judgeRes) return $this->renderError('余额不足'); # 获取刮奖图片 $data = ZoneLogic::createOrder($userData['id'],$zoneGoodsId); if (!$data['status']) $this->renderError($data['msg']); return $this->renderSuccess('开始刮奖',['list' => $data['data'], 'c_r_id' => $data['c_r_id']]); } /** * 结束刮奖 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function endLottery() { $param = Request::param(); $c_r_id = $param['c_r_id']; $userData = $this->request->userInfo; $res = ZoneLogic::endOrder($userData['id'],$c_r_id); if (!$res['status']) return $this->renderError($res['msg']); return $this->renderSuccess( $res['awards_amount'] > 0 ? '恭喜你中奖了' : '未中奖', ['awards_amount' => $res['awards_amount'],'list' => $res['data']] ); } /** * 查看中奖结果 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function queryAwardsResult() { $param = Request::param(); $c_r_id = $param['c_r_id']; $userData = $this->request->userInfo; $queryWhere = ['status' => 1, 'user_id' => $userData['id'], 'id' => $c_r_id]; $ConsumptionRecords = new ConsumptionRecords(); $query = $ConsumptionRecords->where($queryWhere)->field('text_data,zone_goods_id')->find(); if (!$query['text_data']) return $this->renderError('中奖结果数据不存在'); $returnData = ZoneLogic::handleTextData(unserialize($query['text_data'])); return $this->renderSuccess('数据返回成功', ['list' => $returnData]); } }