cycleModel->max('dates') ?? 0; $nextMax = date('Ymd',strtotime('+3 day',time())); if ($maxDate != 0 && $nextMax <= $maxDate) { return; } $nextCycleRange = DateUtil::getDateFromRange(date('Ymd'),$nextMax); $this->cycleCache->setAllCycleCache(); $key = CommonRedisKey::getCycleList(); $noDataInsertArr = []; $noDataArr = []; foreach ($nextCycleRange as $date) { $one = $this->redis->zScore($key,$date,'system'); if ($one) continue; $noDataInsertArr[] = [ 'dates' => $date, 'create_time' => date('Y-m-d H:i:s'), ]; $noDataArr[] = $date; } $insertSql = (new Cycle)->insert($noDataInsertArr); if (!$insertSql) $this->log->error('添加周期失败!!!'); $res = $this->cycleModel->whereIn('dates',$noDataArr)->get(); if (empty($res)) return; $res = $res->toArray(); foreach ($res as $one) { $this->redis->zAdd($key,$one['id'],$one['dates'],'system'); } $this->log->notice('添加周期成功,添加的周期为'.json_encode($noDataArr,JSON_UNESCAPED_UNICODE)); } }