money::class]; public function scopeUid(Builder $query): Builder { return $query->whereUserId(Auth::id()); } public function user(): BelongsTo { return $this->belongsTo(User::class); } public function failed(): bool { // 关闭支付单 return $this->close() && $this->order()->close(); } public function close(): bool { // 关闭支付单 return $this->update(['status' => -1]); } public function order(): BelongsTo { return $this->belongsTo(Order::class); } public function complete(): bool { // 完成支付单 return $this->update(['status' => 1]); } protected function amountTag(): Attribute { return Attribute::make( get: fn () => Helpers::getPriceTag($this->amount), ); } protected function statusLabel(): Attribute { // 订单状态 return Attribute::make( get: fn () => match ($this->status) { -1 => trans('common.failed_item', ['attribute' => trans('user.pay')]), 1 => trans('common.success_item', ['attribute' => trans('user.pay')]), default => trans('common.payment.status.wait'), }, ); } }