mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-13 07:59:20 +00:00
优化重置价格提取逻辑+套餐过期逻辑
This commit is contained in:
@@ -76,7 +76,7 @@ trait Callback
|
||||
$order->status = 2;
|
||||
$order->save();
|
||||
Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, $user->transfer_enable+$goods->traffic*1048576, '[在线支付]加上用户购买的套餐流量');
|
||||
$user->increment('transfer_enable', $goods->traffic*1048576);
|
||||
User::query()->where('id', $order->user_id)->increment('transfer_enable', $goods->traffic*1048576);
|
||||
break;
|
||||
case 2:
|
||||
$activePlan = Order::query()
|
||||
@@ -153,7 +153,7 @@ trait Callback
|
||||
case 3:
|
||||
$order->status = 2;
|
||||
$order->save();
|
||||
$user->increment('balance', $goods->price*100);
|
||||
User::query()->where('id', $order->user_id)->increment('balance', $goods->price*100);
|
||||
|
||||
// 余额变动记录日志
|
||||
$this->addUserBalanceLog($order->user_id, $order->oid, $order->user->balance, $order->user->balance+$goods->price, $goods->price, '用户在线充值');
|
||||
|
||||
@@ -71,7 +71,7 @@ class AutoJob extends Command
|
||||
private function closeOrders()
|
||||
{
|
||||
// 关闭超时未支付的在线支付订单(在线支付收款二维码超过30分钟自动关闭,关闭后无法再支付,所以我们限制15分钟内必须付款)
|
||||
$paymentList = Payment::query()->with(['order', 'order.coupon'])->where('status', 0)->where('created_at', '<=', date("Y-m-d H:i:s", strtotime("-15 minutes")))->get();
|
||||
$paymentList = Payment::query()->where('status', 0)->where('created_at', '<=', date("Y-m-d H:i:s", strtotime("-15 minutes")))->get();
|
||||
if($paymentList->isNotEmpty()){
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
|
||||
@@ -41,7 +41,8 @@ class ServiceTimer extends Command
|
||||
// 扣减用户到期商品的流量
|
||||
private function decGoodsTraffic()
|
||||
{
|
||||
$orderList = Order::query()->with(['user', 'goods'])->where('status', 2)->where('is_expire', 0)->where('expire_at', '<=', date('Y-m-d H:i:s'))->get();
|
||||
//获取失效的套餐
|
||||
$orderList = Order::query()->with(['goods'])->where('status', 2)->where('is_expire', 0)->whereHas('goods', function($q){ $q->where('type', 2); })->where('expire_at', '<=', date('Y-m-d H:i:s'))->get();
|
||||
if($orderList->isNotEmpty()){
|
||||
DB::beginTransaction();
|
||||
try{
|
||||
|
||||
@@ -315,9 +315,9 @@ class UserController extends Controller
|
||||
// 余额充值商品,只取10个
|
||||
$view['chargeGoodsList'] = Goods::type(3)->where('status', 1)->orderBy('price', 'asc')->orderBy('price', 'asc')->limit(10)->get();
|
||||
$view['goodsList'] = Goods::query()->where('status', 1)->where('type', '<=', '2')->orderBy('type', 'desc')->orderBy('sort', 'desc')->paginate(10)->appends($request->except('page'));
|
||||
$renewOrder = Order:: query()->with(['goods'])->where('user_id', Auth::user()->id)->where('status', 2)->where('is_expire', 0)->whereHas('goods', function($q){ $q->where('type', 2); })->first();
|
||||
$renewPrice = Goods::query()->where('id', $renewOrder->goods_id)->first();
|
||||
$view['renewTraffic'] = $renewPrice->renew? : 0;
|
||||
$renewOrder = Order::query()->with(['goods'])->where('user_id', Auth::user()->id)->where('status', 2)->where('is_expire', 0)->whereHas('goods', function($q){ $q->where('type', 2); })->first();
|
||||
$renewPrice = $renewOrder? Goods::query()->where('id', $renewOrder->goods_id)->first() : 0;
|
||||
$view['renewTraffic'] = $renewPrice? $renewPrice->renew : 0;
|
||||
// 有重置日时按照重置日为标准,否者就以过期日为标准
|
||||
$dataPlusDays = Auth::user()->reset_time? Auth::user()->reset_time : Auth::user()->expire_time;
|
||||
$view['dataPlusDays'] = $dataPlusDays > date('Y-m-d')? round((strtotime($dataPlusDays)-strtotime(date('Y-m-d')))/86400) : 0;
|
||||
|
||||
Reference in New Issue
Block a user