This commit is contained in:
richboo111
2022-11-04 18:46:39 +08:00
parent 9360328153
commit aa1b322ec9

View File

@@ -118,19 +118,20 @@ func CreateFenceByStore(appOrgCode string, storeID int64) (fenceID string, err e
if err = dao.GetRow(db, &localStore, sqlStr, sqlParam...); err == nil {
globals.SugarLogger.Debug("localStore.DeliveryRangeType==============", localStore.DeliveryRangeType)
if localStore.DeliveryRangeType == LocalShapeCircular {
circular = warehouse_createFence_request.Circular{
Center: &warehouse_createFence_request.Center{
Longitude: utils.Int2Float64(localStore.Lng),
Latitude: utils.Int2Float64(localStore.Lat),
param = &warehouse_createFence_request.WarehouseCreateFenceParam{
FenceInfo: &warehouse_createFence_request.FenceInfo{
OutFenceId: utils.Int64ToStr(storeID),
Shape: tiktok_api.ShapeCircular,
Circular: &warehouse_createFence_request.Circular{
Center: &warehouse_createFence_request.Center{
Longitude: utils.Int2Float64(localStore.Lng),
Latitude: utils.Int2Float64(localStore.Lat),
},
Radius: utils.Str2Float64(localStore.DeliveryRange),
},
},
Radius: utils.Str2Float64(localStore.DeliveryRange),
}
globals.SugarLogger.Debugf("Latitude============%f,%f,%f", circular.Center.Latitude, circular.Center.Longitude, circular.Radius)
globals.SugarLogger.Debugf("circular=====%v", circular)
param.FenceInfo.Circular = &circular
param.FenceInfo.Shape = tiktok_api.ShapeCircular
globals.SugarLogger.Debug("圆lat,lng", circular.Center.Latitude, circular.Center.Longitude)
} else if localStore.DeliveryRangeType == LocalShapePolygon {
tempStr := strings.Split(localStore.DeliveryRange, ";")
for v := len(tempStr) - 1; v >= 0; v-- {
@@ -141,11 +142,17 @@ func CreateFenceByStore(appOrgCode string, storeID int64) (fenceID string, err e
}
vertex = append(vertex, vertices)
}
param.FenceInfo.Polygon.Vertices = vertex
param.FenceInfo.Shape = tiktok_api.ShapePolygon
param = &warehouse_createFence_request.WarehouseCreateFenceParam{
FenceInfo: &warehouse_createFence_request.FenceInfo{
OutFenceId: utils.Int64ToStr(storeID),
Shape: tiktok_api.ShapePolygon,
Polygon: &warehouse_createFence_request.Polygon{
Vertices: vertex,
},
},
}
globals.SugarLogger.Debug("多边形vertex", param.FenceInfo.Polygon.Vertices)
}
param.FenceInfo.OutFenceId = utils.Int64ToStr(storeID) //绑定基于此id
resp, err := getAPI(appOrgCode, 0, "").CreateFence(param)
if err != nil {
return "", err