This commit is contained in:
Tokumeikoi 2020-03-29 23:49:06 +08:00
parent 40e5ee62b1
commit e8b6f1b481
2 changed files with 10 additions and 6 deletions

View File

@ -98,21 +98,21 @@ class OrderController extends Controller
private function getSurplusValueByCycle(User $user, Plan $plan) private function getSurplusValueByCycle(User $user, Plan $plan)
{ {
$dayPrice = 0; $dayPrice = 0;
$day = ($user->expired_at - time()) / 86400;
if ($plan->month_price) { if ($plan->month_price) {
$dayPrice = $plan->month_price / 2592000; $dayPrice = $plan->month_price / $day;
} else if ($plan->quarter_price) { } else if ($plan->quarter_price) {
$dayPrice = $plan->quarter_price / 7862400; $dayPrice = $plan->quarter_price / $day;
} else if ($plan->half_year_price) { } else if ($plan->half_year_price) {
$dayPrice = $plan->half_year_price / 15811200; $dayPrice = $plan->half_year_price / $day;
} else if ($plan->year_price) { } else if ($plan->year_price) {
$dayPrice = $plan->year_price / 31536000; $dayPrice = $plan->year_price / $day;
} }
// exclude discount // exclude discount
if ($user->discount && $dayPrice) { if ($user->discount && $dayPrice) {
$dayPrice = $dayPrice - ($dayPrice * $user->discount / 100); $dayPrice = $dayPrice - ($dayPrice * $user->discount / 100);
} }
$remainingDay = $user->expired_at - time(); $result = $day * $dayPrice;
$result = $remainingDay * $dayPrice;
return $result > 0 ? $result : 0; return $result > 0 ? $result : 0;
} }

View File

@ -200,3 +200,7 @@ ADD `tlsSettings` text COLLATE 'utf8_general_ci' NULL AFTER `tls`;
ALTER TABLE `v2_order` ALTER TABLE `v2_order`
ADD `balance_amount` int(11) NULL COMMENT '使用余额' AFTER `refund_amount`; ADD `balance_amount` int(11) NULL COMMENT '使用余额' AFTER `refund_amount`;
ALTER TABLE `v2_server`
CHANGE `network` `network` text COLLATE 'utf8_general_ci' NOT NULL AFTER `rate`,
ADD `dnsSettings` text COLLATE 'utf8_general_ci' NULL AFTER `ruleSettings`;