update order change process

This commit is contained in:
Tokumeikoi 2020-02-17 01:27:07 +08:00
parent 15cd13c26c
commit 874648a4c0
2 changed files with 15 additions and 7 deletions

View File

@ -70,6 +70,9 @@ class CheckOrder extends Command
{ {
$plan = Plan::find($order->plan_id); $plan = Plan::find($order->plan_id);
// change plan process // change plan process
if ($order->type === 3) {
$user->expired_at = time();
}
$user->transfer_enable = $plan->transfer_enable * 1073741824; $user->transfer_enable = $plan->transfer_enable * 1073741824;
$user->enable = 1; $user->enable = 1;
$user->u = 0; $user->u = 0;

View File

@ -142,7 +142,11 @@ class OrderController extends Controller
if (!(int)config('v2board.plan_change_enable', 1)) abort(500, '目前不允许更改订阅,请联系管理员'); if (!(int)config('v2board.plan_change_enable', 1)) abort(500, '目前不允许更改订阅,请联系管理员');
$order->type = 3; $order->type = 3;
$order->surplus_amount = $this->getSurplusValue($user); $order->surplus_amount = $this->getSurplusValue($user);
$order->total_amount = $order->total_amount - $order->surplus_amount; if ($order->surplus_amount >= $order->total_amount) {
$order->total_amount = 0;
} else {
$order->total_amount = $order->total_amount - $order->surplus_amount;
}
} else if ($user->expired_at > time() && $order->plan_id == $user->plan_id) { } else if ($user->expired_at > time() && $order->plan_id == $user->plan_id) {
$order->type = 2; $order->type = 2;
} else { } else {
@ -174,12 +178,6 @@ class OrderController extends Controller
// discount complete // discount complete
$order->total_amount = $order->total_amount - $order->discount_amount; $order->total_amount = $order->total_amount - $order->discount_amount;
// discount end // discount end
// free process
if ($order->total_amount <= 0) {
$order->total_amount = 0;
$order->status = 1;
}
// invite process // invite process
if ($user->invite_user_id && $order->total_amount > 0) { if ($user->invite_user_id && $order->total_amount > 0) {
$order->invite_user_id = $user->invite_user_id; $order->invite_user_id = $user->invite_user_id;
@ -213,6 +211,13 @@ class OrderController extends Controller
if (!$order) { if (!$order) {
abort(500, '订单不存在或已支付'); abort(500, '订单不存在或已支付');
} }
// free process
if ($order->total_amount <= 0) {
$order->total_amount = 0;
$order->status = 1;
$order->save();
exit();
}
switch ($method) { switch ($method) {
// return type => 0: QRCode / 1: URL // return type => 0: QRCode / 1: URL
case 0: case 0: