validate([ 'page' => ['nullable', 'integer', 'min:1'], 'limit' => ['nullable', 'integer', 'min:1'], 'member_id' => ['nullable', 'integer', 'min:1'], 'date' => ['nullable', 'date_format:Y-m-d'], 'username' => ['nullable', 'string'], 'first_name' => ['nullable', 'string'], ]); $result = RebateService::paginate($search); } catch (ValidationException $e) { return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first()); } catch (Exception $e) { return $this->error(intval($e->getCode())); } return $this->success($result); } public function store() { DB::beginTransaction(); try { $params = request()->validate([ 'id' => ['required', 'integer', 'min:1'], ]); $params['status'] = RebateModel::STATUS_WEI_FAN_YONG; $rebate = RebateService::findOne($params); if (!$rebate) throw new Exception('数据不存在', HttpStatus::CUSTOM_ERROR); $date = Carbon::now('America/New_York')->format('Y-m-d'); if (strtotime($rebate->date) >= strtotime($date)) { throw new Exception('未到发放时间', HttpStatus::CUSTOM_ERROR); } RebateService::BibiReturn($rebate, $rebate->effective_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(intval($e->getCode()), $e->getMessage()); } return $this->success(); } }