12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace App\Handlers;
- use Illuminate\Support\Facades\Log;
- use Illuminate\Support\Facades\Redis;
- class DatabaseSyncRedisServer
- {
- const SHOP_LOCATION_KEY = 'shops_location';
- /**
- * 同步站点位置
- * @param $shop_id
- * @param $lat
- * @param $lng
- * @return mixed
- * Author: Mead
- */
- public static function syncShopLocation($shop_id, $lat, $lng)
- {
- Log::error([$shop_id, number_format($lat, 8), number_format($lng, 8)]);
- /** @var $redis \Predis\Client */
- $redis = Redis::connection();
- return $redis->geoadd(self::SHOP_LOCATION_KEY, '113.67462248', '34.72577707', $shop_id);
- // return $redis->geoadd(self::SHOP_LOCATION_KEY, number_format($lng, 8), number_format($lat, 8), $shop_id);
- }
- /**
- * 删除站点定位
- * @return mixed
- * Author: Mead
- */
- public static function delShopsLocation($id = 0)
- {
- /** @var $redis \Predis\Client */
- $redis = Redis::connection();
- if ($id) {
- return $redis->zrank(self::SHOP_LOCATION_KEY, $id);
- }
- return $redis->del(self::SHOP_LOCATION_KEY);
- }
- }
|