feature: Cross-Package and below 80% of traffic usage cannot be purchased as a reset package.

This commit is contained in:
coldice945 2023-06-29 00:07:49 +08:00
parent 0ca47622a5
commit 21e137a146
3 changed files with 14 additions and 0 deletions

View File

@ -97,6 +97,16 @@ class OrderController extends Controller
if (!$userService->isAvailable($user) || $plan->id !== $user->plan_id) {
abort(500, __('Subscription has expired or no active subscription, unable to purchase Data Reset Package'));
}
if ($plan->id !== $user->plan_id) {
abort(500, __('Current subscription and Data Reset package do not match, unable to purchase Data Reset Package'));
}
$upload = round($user['u'] / (1024*1024*1024), 2);
$download = round($user['d'] / (1024*1024*1024), 2);
$useTraffic = $upload + $download;
$totalTraffic = round($user['transfer_enable'] / (1024*1024*1024), 2);
if ($useTraffic < $totalTraffic * 0.8) {
abort(500, __('The traffic usage of the current subscription has not reached 80%, unable to purchase Data Reset Package'));
}
}
if ((!$plan->show && !$plan->renew) || (!$plan->show && $user->plan_id !== $plan->id)) {

View File

@ -35,6 +35,8 @@
"Reset failed": "Reset failed",
"Save failed": "Save failed",
"Subscription has expired or no active subscription, unable to purchase Data Reset Package": "Subscription has expired or no active subscription, unable to purchase Data Reset Package",
"Current subscription and Data Reset package do not match, unable to purchase Data Reset Package": "Current subscription and Data Reset package do not match, unable to purchase Data Reset Package",
"The traffic usage of the current subscription has not reached 80%, unable to purchase Data Reset Package": "The traffic usage of the current subscription has not reached 80%, unable to purchase Data Reset Package",
"Subscription plan does not exist": "Subscription plan does not exist",
"The coupon code cannot be used for this subscription": "The coupon code cannot be used for this subscription",
"The current required minimum withdrawal commission is :limit": "The current required minimum withdrawal commission is :limit",

View File

@ -27,6 +27,8 @@
"This subscription cannot be renewed, please change to another subscription": "该订阅无法续费,请更换其它订阅",
"This payment period cannot be purchased, please choose another period": "该订阅周期无法进行购买,请选择其它周期",
"Subscription has expired or no active subscription, unable to purchase Data Reset Package": "订阅已过期或无有效订阅,无法购买重置包",
"Current subscription and Data Reset package do not match, unable to purchase Data Reset Package": "当前套餐和重置包套餐不符,无法购买重置包",
"The traffic usage of the current subscription has not reached 80%, unable to purchase Data Reset Package": "当前订阅的流量使用并未达到80%,无法购买重置包",
"This subscription has expired, please change to another subscription": "订阅已过期,请更换其它订阅",
"Coupon failed": "优惠券使用失败",
"Insufficient balance": "余额不足",