Tokumeikoi 5 years ago
parent
commit
e8b6f1b481
2 changed files with 10 additions and 6 deletions
  1. 6 6
      app/Http/Controllers/User/OrderController.php
  2. 4 0
      database/update.sql

+ 6 - 6
app/Http/Controllers/User/OrderController.php

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

+ 4 - 0
database/update.sql

@@ -200,3 +200,7 @@ ADD `tlsSettings` text COLLATE 'utf8_general_ci' NULL AFTER `tls`;
 
 ALTER TABLE `v2_order`
 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`;