新零售订单智能拆分:订单拆分到仓库

1、就近发货

2、注册高德地图开发者

1)创建地图应用程序。

2)创建访问秘钥。

3)使用地理编码获取地址服务。根据api获取经纬度,

4)引入hutool依赖包,发送请求查询地理坐标。

5)利用mysql st_distance函数计算两个坐标之间的度数。

SELECT st_distance(
    point(116.414042,39.92556),
    point(121.486864,31.232965)
)*111195/1000
SELECT ip,address st_distance(
    point(116.414042,39.92556),
    point(lng,lat)
)*111195/1000 as distance 
from t_warehouse order by distance limit 1

(SELECT id,st_distance(
point(116.414042,39.92556),
point(lng,lat)
)*111195/1000 as distance
from t_warehouse order by distance limit 1) t
JOIN t_warehouse_sku ws on ws.warehouse_id = t.id
and ws.sku_id =1 and ws.num >1;

6)mysql全文索引,mysql8才支持,全文索引,切词语更多,占用存储空间更大,更新内容字段,全文索引不会更新,必须定期更新,数据库集群中维护索引难度更大。

SELECT id,title,images,price from t_sku
where MATCH(title) AGAINST("小米9")

猜你喜欢

转载自www.cnblogs.com/xiaofeiyang/p/12513990.html