printKey = AdminRedisKey::optionCateringIsPrint($this->cycleId); $this->stopOrderKey = AdminRedisKey::optionCateringStopOrder($this->cycleId); $this->pickupCodeKey = AdminRedisKey::optionCateringBuildPickupCode($this->cycleId); $this->isCateringKey = AdminRedisKey::optionIsCatering($this->cycleId); $script = <<redis->eval($script, [$this->printKey, $this->stopOrderKey, $this->pickupCodeKey, $this->isCateringKey, CateringCode::REDIS_FINISH_VALUE, DateUtil::DAY], 4); } /** * @return void * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ protected function closePrint(): void { if (CateringCode::REDIS_FINISH_VALUE == $this->redis->hGet($this->printKey, $this->logInfo->id)) return; $this->redis->hSet($this->printKey, $this->logInfo->id, CateringCode::REDIS_FINISH_VALUE); } /** * @return void * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ protected function closeSite(): void { if (CateringCode::REDIS_FINISH_VALUE == $this->redis->hGet($this->stopOrderKey, $this->logInfo->site_id)) return; $this->redis->hSet($this->stopOrderKey, $this->logInfo->site_id, CateringCode::REDIS_FINISH_VALUE); } /** * @return void * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ protected function closeWholeLine(): void { $siteArr = $this->siteModel->where('delivered_id',$this->siteInfo->delivered_id)->pluck('id'); //没有日志数据 跳出 $logArr = $this ->orderOptionCateringLogModel ->where('cycle_id',$this->cycleId) ->whereIn('site_id',$siteArr) ->pluck('site_id') ->toArray(); if (empty($logArr)) return; //没有缓存数据 跳出 $cacheData = $this->redis->hGetAll($this->stopOrderKey); if (empty($cacheData)) return; $cacheData = array_diff(array_keys($cacheData),[0]); //需要排除默认写的值 //数量不对等 跳出 if (count($logArr) !== count($cacheData)) return; //如果相反交集有一个不为空就是不对的 跳出 if (!empty(array_diff($logArr,$cacheData)) || !empty(array_diff($cacheData,$logArr))) return; //批量写入 hashmap $insertCacheData = []; foreach ($siteArr as $one) { $insertCacheData[$one] = CateringCode::REDIS_FINISH_VALUE; } $this->redis->hMset($this->stopOrderKey, $insertCacheData); } /** * @return bool * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ protected function isBuildPickupCode(): bool { if (CateringCode::REDIS_FINISH_VALUE == $this->redis->hGet($this->pickupCodeKey, $this->logInfo->id)) return true; return false; } }