siteId = (int)$this->request->input('site_id'); $info = $this->driverStatusModel ->where('cycle_id',$this->cycleId) ->where('site_id',$this->siteId) ->where('driver_id',$this->adminInfo->id) ->first(); if (empty($info)) throw new ErrException('今日无该点位的送餐数据'); if ($info->status == DriverCode::DESTINATION) throw new ErrException('该点位已送达'); $orderIds = $this->orderModel ->where('cycle_id',$this->cycleId) ->where('status',OrderCode::DEPART) ->where('site_id',$this->siteId) ->pluck('id') ->toArray(); Db::transaction(function () use ($info,$orderIds) { // $this->orderModel->whereIn('id', $orderIds)->update([ // 'status' => OrderCode::DEPART, // 'set_out_time' => date('Y-m-d H:i:s'), // ]); $info->status = DriverCode::DESTINATION; if (!$info->save()) throw new ErrException('送达失败-01'); $dateTime = date('Y-m-d H:i:s'); foreach (array_chunk($orderIds, 500) as $chunk) { $this->orderModel->whereIn('id', $chunk)->update([ 'status' => OrderCode::ARRIVE, 'delivery_time' => $dateTime, ]); } }); return $this->return->success(); } }