validate([ 'issue_no' => ['nullable', 'string'], 'id' => ['nullable', 'string'], 'status' => ['nullable', 'string'], ]); $search = request()->all(); $result = IssueService::paginate($search); } catch (ValidationException $e) { return $this->error(HttpStatus::VALIDATION_FAILED, $e->validator->errors()->first()); } catch (Exception $e) { return $this->error(intval($e->getCode())); } return $this->success($result); } /** * @description: 修改|新增 * @return {*} */ public function store() { // try { $params = request()->all(); $validator = [ 'issue_no' => 'required|string|max:50|alpha_dash|unique:issues,issue_no', 'winning_numbers' => 'nullable|string|max:100', 'status' => 'nullable|string', ]; request()->validate($validator); $ret = IssueService::submit($params); if ($ret['code'] == IssueService::NOT) { return $this->error($ret['code'], $ret['msg']); } // } catch (ValidationException $e) { // return $this->error(HttpStatus::VALIDATION_FAILED, '', $e->errors()); // } catch (Exception $e) { // return $this->error(intval($e->getCode())); // } return $this->success([], $ret['msg']); } /** * @description: 开始 * @return {*} */ public function betting() { $id = request()->input('id'); if (!$id) { return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误'); } $ret = IssueService::betting($id); if ($ret['code'] == IssueService::NOT) { return $this->error($ret['code'], $ret['msg']); } return $this->success([], $ret['msg']); } /** * @description: 关闭 * @return {*} */ public function close() { $id = request()->input('id'); if (!$id) { return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误'); } $ret = IssueService::closeBetting($id); if ($ret['code'] == IssueService::NOT) { return $this->error($ret['code'], $ret['msg']); } return $this->success([], $ret['msg']); } /** * @description: 开奖 * @return {*} */ public function lotteryDraw() { $id = request()->input('id'); $winning_numbers = request()->input('winning_numbers'); if (!$id) { return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误'); } if (!$winning_numbers) { return $this->error(HttpStatus::VALIDATION_FAILED, '参数错误'); } if(explode(',', $winning_numbers) < 3){ return $this->error(HttpStatus::VALIDATION_FAILED, '开奖号码格式错误'); } $ret = IssueService::lotteryDraw($id,$winning_numbers); if ($ret['code'] == IssueService::NOT) { return $this->error($ret['code'], $ret['msg']); } return $this->success([], $ret['msg']); } }