mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
add onetime plan
This commit is contained in:
parent
a7b47d8f77
commit
3b9e9cbe7f
@ -75,6 +75,25 @@ class OrderController extends Controller
|
||||
private function getSurplusValue(User $user)
|
||||
{
|
||||
$plan = Plan::find($user->plan_id);
|
||||
switch ($plan->type) {
|
||||
case 0: return $this->getSurplusValueByCycle($user, $plan);
|
||||
case 1: return $this->getSurplusValueByOneTime($user, $plan);
|
||||
}
|
||||
}
|
||||
|
||||
private function getSurplusValueByOneTime(User $user, Plan $plan)
|
||||
{
|
||||
$trafficUnitPrice = 0;
|
||||
$trafficUnitPrice = $plan->onetime_price / $plan->transfer_enable;
|
||||
if ($user->discount && $trafficUnitPrice) {
|
||||
$trafficUnitPrice = $trafficUnitPrice - ($trafficUnitPrice * $user->discount / 100);
|
||||
}
|
||||
$notUsedTrafficPrice = $plan->transfer_enable - (($user->u + $user->d) / 1073741824);
|
||||
return $trafficUnitPrice * $notUsedTrafficPrice;
|
||||
}
|
||||
|
||||
private function getSurplusValueByCycle(User $user, Plan $plan)
|
||||
{
|
||||
$dayPrice = 0;
|
||||
if ($plan->month_price) {
|
||||
$dayPrice = $plan->month_price / 2592000;
|
||||
|
Loading…
Reference in New Issue
Block a user