validate([ 'id' => ['required', 'integer', 'min:1'], ]); ActivityUserService::finish($params['id']); DB::commit(); } catch (ValidationException $e) { DB::rollBack(); return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first()); } catch (Exception $e) { DB::rollBack(); return $this->error($e->getCode(), $e->getMessage()); } return $this->success(); } //赠送金额(充值) public function gift() { DB::beginTransaction(); try { $params = request()->validate([ 'id' => ['required', 'integer', 'min:1'], 'amount' => ['required', 'numeric', 'min:0.01'], 'betting_amount' => ['required', 'integer', 'min:0', 'max:9999999'], ]); ActivityUserService::gift($params['id'], $params['amount'], $params['betting_amount']); DB::commit(); } catch (ValidationException $e) { DB::rollBack(); return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first()); } catch (Exception $e) { DB::rollBack(); return $this->error($e->getCode(), $e->getMessage()); } return $this->success(); } public function index(): JsonResponse { try { $params = request()->validate([ 'page' => ['required', 'integer', 'min:1'], 'limit' => ['required', 'integer', 'min:1'], 'title' => ['nullable', 'string'], 'member_id' => ['nullable', 'string'], ]); $page = request()->input('page', 1); $limit = request()->input('limit', 10); $where = ActivityUserService::getWhere($params); $query = ActivityUserModel::where($where); $count = $query->count(); $list = $query->orderBy('status') ->with(['member']) ->orderByDesc('id') ->forPage($page, $limit)->get()->toArray(); $result = ['total' => $count, 'data' => $list]; } catch (ValidationException $e) { return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first()); } catch (Exception $e) { return $this->error($e->getCode(), $e->getMessage()); } return $this->success($result); } }