mirror of
https://github.com/v2board/v2board.git
synced 2025-01-10 16:19:10 +08:00
update: order process event
This commit is contained in:
parent
b174403a2a
commit
9db5de09f2
@ -72,8 +72,10 @@ class ConfigController extends Controller
|
|||||||
'subscribe' => [
|
'subscribe' => [
|
||||||
'plan_change_enable' => (int)config('v2board.plan_change_enable', 1),
|
'plan_change_enable' => (int)config('v2board.plan_change_enable', 1),
|
||||||
'reset_traffic_method' => (int)config('v2board.reset_traffic_method', 0),
|
'reset_traffic_method' => (int)config('v2board.reset_traffic_method', 0),
|
||||||
'renew_reset_traffic_enable' => (int)config('v2board.renew_reset_traffic_enable', 0),
|
'surplus_enable' => (int)config('v2board.surplus_enable', 1),
|
||||||
'surplus_enable' => (int)config('v2board.surplus_enable', 1)
|
'new_order_event_id' => (int)config('v2board.new_order_event_id', 0),
|
||||||
|
'renew_order_event_id' => (int)config('v2board.renew_order_event_id', 0),
|
||||||
|
'change_order_event_id' => (int)config('v2board.change_order_event_id', 0),
|
||||||
],
|
],
|
||||||
'pay' => [
|
'pay' => [
|
||||||
// alipay
|
// alipay
|
||||||
|
@ -45,8 +45,10 @@ class ConfigSave extends FormRequest
|
|||||||
// subscribe
|
// subscribe
|
||||||
'plan_change_enable' => 'in:0,1',
|
'plan_change_enable' => 'in:0,1',
|
||||||
'reset_traffic_method' => 'in:0,1',
|
'reset_traffic_method' => 'in:0,1',
|
||||||
'renew_reset_traffic_enable' => 'in:0,1',
|
|
||||||
'surplus_enable' => 'in:0,1',
|
'surplus_enable' => 'in:0,1',
|
||||||
|
'new_order_event_id' => 'in:0,1',
|
||||||
|
'renew_order_event_id' => 'in:0,1',
|
||||||
|
'change_order_event_id' => 'in:0,1',
|
||||||
// server
|
// server
|
||||||
'server_token' => 'nullable|min:16',
|
'server_token' => 'nullable|min:16',
|
||||||
'server_license' => 'nullable',
|
'server_license' => 'nullable',
|
||||||
|
@ -14,7 +14,7 @@ class UserFetch extends FormRequest
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'filter.*.key' => 'required|in:id,email,transfer_enable,d,expired_at,uuid,token,invite_by_email,invite_user_id,plan_id,banned',
|
'filter.*.key' => 'required|in:id,email,transfer_enable,d,expired_at,uuid,token,invite_by_email,invite_user_id,plan_id,banned,remarks',
|
||||||
'filter.*.condition' => 'required|in:>,<,=,>=,<=,模糊,!=',
|
'filter.*.condition' => 'required|in:>,<,=,>=,<=,模糊,!=',
|
||||||
'filter.*.value' => 'required'
|
'filter.*.value' => 'required'
|
||||||
];
|
];
|
||||||
|
@ -18,6 +18,7 @@ class OrderService
|
|||||||
'three_year_price' => 36
|
'three_year_price' => 36
|
||||||
];
|
];
|
||||||
public $order;
|
public $order;
|
||||||
|
public $user;
|
||||||
|
|
||||||
public function __construct(Order $order)
|
public function __construct(Order $order)
|
||||||
{
|
{
|
||||||
@ -27,11 +28,11 @@ class OrderService
|
|||||||
public function open()
|
public function open()
|
||||||
{
|
{
|
||||||
$order = $this->order;
|
$order = $this->order;
|
||||||
$user = User::find($order->user_id);
|
$this->user = User::find($order->user_id);
|
||||||
$plan = Plan::find($order->plan_id);
|
$plan = Plan::find($order->plan_id);
|
||||||
|
|
||||||
if ($order->refund_amount) {
|
if ($order->refund_amount) {
|
||||||
$user->balance = $user->balance + $order->refund_amount;
|
$this->user->balance = $this->user->balance + $order->refund_amount;
|
||||||
}
|
}
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if ($order->surplus_order_ids) {
|
if ($order->surplus_order_ids) {
|
||||||
@ -46,18 +47,28 @@ class OrderService
|
|||||||
}
|
}
|
||||||
switch ((string)$order->cycle) {
|
switch ((string)$order->cycle) {
|
||||||
case 'onetime_price':
|
case 'onetime_price':
|
||||||
$this->buyByOneTime($user, $plan);
|
$this->buyByOneTime($plan);
|
||||||
break;
|
break;
|
||||||
case 'reset_price':
|
case 'reset_price':
|
||||||
$this->buyByResetTraffic($user);
|
$this->buyByResetTraffic();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->buyByCycle($order, $user, $plan);
|
$this->buyByCycle($order, $plan);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((int)config('v2board.renew_reset_traffic_enable', 0)) $this->buyByResetTraffic($user);
|
switch ((int)$order->type) {
|
||||||
|
case 1:
|
||||||
|
$this->openEvent(config('v2board.new_order_event_id', 0));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$this->openEvent(config('v2board.renew_order_event_id', 0));
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
$this->openEvent(config('v2board.change_order_event_id', 0));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$user->save()) {
|
if (!$this->user->save()) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
abort(500, '开通失败');
|
abort(500, '开通失败');
|
||||||
}
|
}
|
||||||
@ -220,35 +231,35 @@ class OrderService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function buyByResetTraffic(User $user)
|
private function buyByResetTraffic()
|
||||||
{
|
{
|
||||||
$user->u = 0;
|
$this->user->u = 0;
|
||||||
$user->d = 0;
|
$this->user->d = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buyByCycle(Order $order, User $user, Plan $plan)
|
private function buyByCycle(Order $order, Plan $plan)
|
||||||
{
|
{
|
||||||
// change plan process
|
// change plan process
|
||||||
if ((int)$order->type === 3) {
|
if ((int)$order->type === 3) {
|
||||||
$user->expired_at = time();
|
$this->user->expired_at = time();
|
||||||
}
|
}
|
||||||
$user->transfer_enable = $plan->transfer_enable * 1073741824;
|
$this->user->transfer_enable = $plan->transfer_enable * 1073741824;
|
||||||
// 从一次性转换到循环
|
// 从一次性转换到循环
|
||||||
if ($user->expired_at === NULL) $this->buyByResetTraffic($user);
|
if ($this->user->expired_at === NULL) $this->buyByResetTraffic();
|
||||||
// 新购
|
// 新购
|
||||||
if ($order->type === 1) $this->buyByResetTraffic($user);
|
if ($order->type === 1) $this->buyByResetTraffic();
|
||||||
$user->plan_id = $plan->id;
|
$this->user->plan_id = $plan->id;
|
||||||
$user->group_id = $plan->group_id;
|
$this->user->group_id = $plan->group_id;
|
||||||
$user->expired_at = $this->getTime($order->cycle, $user->expired_at);
|
$this->user->expired_at = $this->getTime($order->cycle, $this->user->expired_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buyByOneTime(User $user, Plan $plan)
|
private function buyByOneTime(Plan $plan)
|
||||||
{
|
{
|
||||||
$this->buyByResetTraffic($user);
|
$this->buyByResetTraffic();
|
||||||
$user->transfer_enable = $plan->transfer_enable * 1073741824;
|
$this->user->transfer_enable = $plan->transfer_enable * 1073741824;
|
||||||
$user->plan_id = $plan->id;
|
$this->user->plan_id = $plan->id;
|
||||||
$user->group_id = $plan->group_id;
|
$this->user->group_id = $plan->group_id;
|
||||||
$user->expired_at = NULL;
|
$this->user->expired_at = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getTime($str, $timestamp)
|
private function getTime($str, $timestamp)
|
||||||
@ -271,4 +282,15 @@ class OrderService
|
|||||||
return strtotime('+36 month', $timestamp);
|
return strtotime('+36 month', $timestamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function openEvent($eventId)
|
||||||
|
{
|
||||||
|
switch ((int) $eventId) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
$this->buyByResetTraffic();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
2
public/assets/admin/umi.js
vendored
2
public/assets/admin/umi.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user