mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
update: fix commission first
This commit is contained in:
parent
3aabeff5de
commit
be19a93efb
@ -127,7 +127,7 @@ class OrderService
|
||||
if ($user->invite_user_id && $order->total_amount > 0) {
|
||||
$order->invite_user_id = $user->invite_user_id;
|
||||
$commissionFirstTime = (int)config('v2board.commission_first_time_enable', 1);
|
||||
if (!$commissionFirstTime || ($commissionFirstTime && !Order::where('user_id', $user->id)->where('status', 3)->first())) {
|
||||
if (!$commissionFirstTime || ($commissionFirstTime && !$this->haveValidOrder($user))) {
|
||||
$inviter = User::find($user->invite_user_id);
|
||||
if ($inviter && $inviter->commission_rate) {
|
||||
$order->commission_balance = $order->total_amount * ($inviter->commission_rate / 100);
|
||||
@ -138,6 +138,13 @@ class OrderService
|
||||
}
|
||||
}
|
||||
|
||||
private function haveValidOrder(User $user)
|
||||
{
|
||||
return Order::where('user_id', $user->id)
|
||||
->whereIn('status', [3, 4])
|
||||
->first();
|
||||
}
|
||||
|
||||
private function getSurplusValue(User $user, Order $order)
|
||||
{
|
||||
if ($user->expired_at === NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user