orderOptionCateringLogModel ->where('cycle_id',$this->cycleId) ->where('status',CateringCode::CATERING_STATUS_UNDERWAY) ->whereIn('site_id', $this->siteIds) ->where('quantity','>',0) ->sum('quantity') ?? 0) > 0 ) throw new ErrException('自选配餐还未完成'); if ( ($this->orderMealCateringLogModel ->where('cycle_id',$this->cycleId) ->where('status',CateringCode::CATERING_STATUS_UNDERWAY) ->whereIn('site_id', $this->siteIds) ->where('quantity','>',0) ->sum('quantity') ?? 0) > 0 ) throw new ErrException('套餐配餐还未完成'); $orderIds = $this->orderModel ->where('cycle_id',$this->cycleId) ->where('status',OrderCode::PLAN) ->whereIn('site_id',$this->siteIds) ->pluck('id') ->toArray(); if (empty($orderIds)) throw new ErrException('数据不存在'); $list = $this->buildListData(); foreach ($list as &$one) { $one['meal_list'] = json_encode($one['meal_list']); } Db::transaction(function () use ($orderIds,$list) { // $this->orderModel->whereIn('id', $orderIds)->update([ // 'status' => OrderCode::DEPART, // 'set_out_time' => date('Y-m-d H:i:s'), // ]); $this->driverStatusModel->insert($list); $dateTime = date('Y-m-d H:i:s'); foreach (array_chunk($orderIds, 500) as $chunk) { $this->orderModel->whereIn('id', $chunk)->update([ 'status' => OrderCode::DEPART, 'set_out_time' => $dateTime, ]); } }); return $this->return->success(); } }