mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
update
This commit is contained in:
parent
2076dded41
commit
467f33c71d
@ -78,13 +78,13 @@ class OrderController extends Controller
|
||||
private function getSurplusValue(User $user, Order $order)
|
||||
{
|
||||
if ($user->expired_at === NULL) {
|
||||
$this->getSurplusValueByOneTime($user);
|
||||
$this->getSurplusValueByOneTime($user, $order);
|
||||
} else {
|
||||
$this->getSurplusValueByCycle($user, $order);
|
||||
}
|
||||
}
|
||||
|
||||
private function getSurplusValueByOneTime(User $user)
|
||||
private function getSurplusValueByOneTime(User $user, Order $order)
|
||||
{
|
||||
$plan = Plan::find($user->plan_id);
|
||||
$trafficUnitPrice = $plan->onetime_price / $plan->transfer_enable;
|
||||
@ -93,7 +93,9 @@ class OrderController extends Controller
|
||||
}
|
||||
$notUsedTrafficPrice = $plan->transfer_enable - (($user->u + $user->d) / 1073741824);
|
||||
$result = $trafficUnitPrice * $notUsedTrafficPrice;
|
||||
return $result > 0 ? $result : 0;
|
||||
$orderModel = Order::where('user_id', $user->id)->where('status', 3);
|
||||
$order->surplus_amount = $result > 0 ? $result : 0;
|
||||
$order->surplus_order_ids = json_encode(array_map(function ($v) { return $v['id'];}, $orderModel->get()->toArray()));
|
||||
}
|
||||
|
||||
private function getSurplusValueByCycle(User $user, Order $order)
|
||||
|
Loading…
Reference in New Issue
Block a user