Prechádzať zdrojové kódy

修改拼团定时任务

jun 5 mesiacov pred
rodič
commit
15ff71c8ea
1 zmenil súbory, kde vykonal 14 pridanie a 4 odobranie
  1. 14 4
      app/Console/Commands/Regiment.php

+ 14 - 4
app/Console/Commands/Regiment.php

@@ -4,6 +4,7 @@ namespace App\Console\Commands;
 
 use App\Facades\Servers\Logs\Log;
 use App\Models\Orders;
+use App\Models\OrdersProduct;
 use Illuminate\Console\Command;
 use App\Facades\Servers\Redis\RedisLock;
 use App\Facades\Servers\WechatWork\ExternalContact;
@@ -59,9 +60,8 @@ class Regiment extends Command
         $Model          = New Model();
         $time           = time();
         // 活动结束
-        $activeList     =  $Model->query()->where([['end_time','<=',time()],['status','=',1]])->get();
+        $activeList     =  $Model->query()->where([['end_time','<=',time()],['status','=',1]])->get()->toArray();
         if ($activeList){
-            $activeList =  $activeList->toArray();
             $activeList =  array_column($activeList,null,'id');
             $activeIds  =   array_column($activeList,'id');
             $regiment   =   RegimentModel::query()->where('status','=',0)->whereIn('active_id',$activeIds)->get()->toArray();
@@ -76,6 +76,8 @@ class Regiment extends Command
                                //修改订单
                                $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>1,'update_time'=>$time]);
                                if (!$res)   Log::error('run_regiment','修改订单失败');
+                               $res         =   OrdersProduct::query()->whereIn('order_id',$regimentRecordListIds)->update(['status'=>1]);
+                               if (!$res)   Log::error('run_regiment','修改订单产品失败');
                            }
                            //修改状态
                            $res         =   RegimentModel::query()->where('id','=',$v['id'])->update(['status'=>2]);
@@ -91,13 +93,15 @@ class Regiment extends Command
                                $regimentRecordListIds = array_column($regimentRecordList,'order_id');
                                //修改订单
                                $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>11]);
-                               if (!$res)   Log::error('run_regiment','修改团记录失败');
+                               if (!$res)   Log::error('run_regiment','修改订单失败');
+                               $res         =   OrdersProduct::query()->whereIn('order_id',$regimentRecordListIds)->update(['status'=>11]);
+                               if (!$res)   Log::error('run_regiment','修改订单产品失败');
                            }
                        }
                 }
             }
             $res    =   $Model->query()->whereIn('id',$activeIds)->update(['status'=>2,'update_time'=>$time]);
-            if (!$res)   Log::error('run_regiment','修改团活动失败');
+            if (!$res)   Log::error('run_regiment','修改团活动失败:'.json_encode($activeIds));
         }
 
         //团过期
@@ -116,6 +120,9 @@ class Regiment extends Command
                         $regimentRecordListIds = array_column($regimentRecordList,'order_id');
                         //修改订单
                         $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>1]);
+                        if (!$res)   Log::error('run_regiment','修改订单失败');
+                        $res         =   OrdersProduct::query()->whereIn('order_id',$regimentRecordListIds)->update(['status'=>1]);
+                        if (!$res)   Log::error('run_regiment','修改订单产品失败');
                     }
                 }else{
                     $r = RegimentModel::query()->where('id','=',$v['id'])->update(['status'=>3]);
@@ -125,6 +132,9 @@ class Regiment extends Command
                     $regimentRecordListIds = array_column($regimentRecordList,'order_id');
                     //修改订单
                     $res         =   Orders::query()->whereIn('id',$regimentRecordListIds)->update(['status'=>11]);
+                    if (!$res)   Log::error('run_regiment','修改订单失败');
+                    $res         =   OrdersProduct::query()->whereIn('order_id',$regimentRecordListIds)->update(['status'=>11]);
+                    if (!$res)   Log::error('run_regiment','修改订单产品失败');
                 }
             }
         }