merchant_id; $location_key = Area::REDIS_AREAS_LOCATION_TAG . ":{$merchant_id}"; // $area_key = Area::REDIS_AREAS_TAG . ":{$merchant_id}:"; $area_key = Area::REDIS_AREAS_TAG; if ((int)$area->status === Area::STATUS_OK) { $centre = json_decode($area->area_centre, true); $redis->geoadd($location_key, $centre[0], $centre[1], $area->id); $db_area = DB::table('areas')->where('id', $area->id)->first(); $redis->hset($area_key, $area->id, serialize(object_array($db_area))); } else { $redis->hdel($area_key, [$area->id]); $redis->zrem($location_key, [$area->id]); } } public function updated(Area $area) { if (!$area->isDirty('status')) return true; $redis = Redis::connection(); $merchant_id = $area->merchant_id; $location_key = Area::REDIS_AREAS_LOCATION_TAG . ":{$merchant_id}"; $area_key = Area::REDIS_AREAS_TAG; if ((int)$area->status === Area::STATUS_OK) { $db_area = DB::table('areas')->where('id', $area->id)->first(); $centre = json_decode($db_area->area_centre, true); $redis->geoadd($location_key, $centre['longitude'], $centre['latitude'], $area->id); $redis->hset(Area::REDIS_AREAS_TAG, $area->id, serialize(object_array($db_area))); //调整停车区 Artisan::call('load:stop_bike_sites'); } else { $redis->hdel($area_key, [$area->id]); $redis->zrem($location_key, [$area->id]); Artisan::call('load:stop_bike_sites'); } } public function deleted(Area $area) { $merchant_id = $area->merchant_id; $location_key = Area::REDIS_AREAS_LOCATION_TAG . ":{$merchant_id}"; $area_key = Area::REDIS_AREAS_TAG; $redis = Redis::connection(); $redis->zrem($location_key, $area->id); $redis->hdel($area_key, [$area->id]); } }