优化 代码
This commit is contained in:
parent
34892e0511
commit
cd2a77de85
@ -33,6 +33,20 @@ public function index(Request $request): View|RedirectResponse
|
||||
return view('affiliates.index', compact('affiliateUsers', 'affiliate'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
if (auth()->user()->affiliate) {
|
||||
return redirect()->route('affiliates.index')->with('error', '您已经激活了推介计划。');
|
||||
}
|
||||
|
||||
$request->user('web')->affiliate()->create();
|
||||
|
||||
return redirect()->route('affiliates.index')->with('success', '欢迎您,并感谢您。');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
@ -48,20 +62,6 @@ public function create(Request $request): View|RedirectResponse
|
||||
return view('affiliates.create', compact('user'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
if (auth()->user()->affiliate) {
|
||||
return redirect()->route('affiliates.index')->with('error', '您已经激活了推介计划。');
|
||||
}
|
||||
|
||||
$request->user('web')->affiliate()->create();
|
||||
|
||||
return redirect()->route('affiliates.index')->with('success', '欢迎您,并感谢您。');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
|
@ -200,6 +200,9 @@ public function reduce(string|null $amount = '0', string $description = '消费'
|
||||
return $this->balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws BalanceNotEnoughException
|
||||
*/
|
||||
return Cache::lock('user_balance_'.$this->id, 10)->block(10, function () use ($amount, $fail, $description, $options) {
|
||||
$this->refresh();
|
||||
|
||||
@ -281,6 +284,11 @@ public function getCostPrice(string $price): string
|
||||
return $this->user_group->getCostPrice($price);
|
||||
}
|
||||
|
||||
public function subscriptions(): HasMany
|
||||
{
|
||||
return $this->hasMany(Subscription::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户的身份证号
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user