1
This commit is contained in:
@@ -26,8 +26,6 @@ func (P *PurchaseHandler) CreateWarehouse(outWarehouseID, appOrgCode string) (wa
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
//todo 存入数据库
|
||||
|
||||
return resp.Data, err
|
||||
}
|
||||
|
||||
@@ -149,6 +147,64 @@ func (P *PurchaseHandler) CreateFenceDirectly(param warehouse_createFence_reques
|
||||
return resp.FenceId, err
|
||||
}
|
||||
|
||||
// 通过门店更新电子围栏
|
||||
func UpdateFenceByStore(storeID int) error {
|
||||
var (
|
||||
db *dao.DaoDB
|
||||
localStore *LocalStore
|
||||
verticeses []warehouse_createFence_request.VerticesItem
|
||||
)
|
||||
sqlParam := []interface{}{
|
||||
model.VendorIDDD,
|
||||
}
|
||||
sqlStr := ` SELECT t.lng,t.lat,t.delivery_range_type,t.delivery_range,s.vendor_store_id FROM store t
|
||||
LEFT JOIN store_map s ON t.id = s.store_id
|
||||
WHERE s.vendor_id= ? `
|
||||
if storeID != 0 {
|
||||
sqlStr += " AND t.id = ? "
|
||||
sqlParam = append(sqlParam, storeID)
|
||||
} else {
|
||||
return fmt.Errorf("storeID必填")
|
||||
}
|
||||
if err := dao.GetRow(db, &localStore, sqlStr, sqlParam...); err == nil {
|
||||
param := &warehouse_createFence_request.WarehouseCreateFenceParam{
|
||||
FenceInfo: &warehouse_createFence_request.FenceInfo{
|
||||
//OutFenceId: "京西门店:" + utils.Int2Str(storeID) + " 的电子围栏",
|
||||
Shape: int32(localStore.DeliveryRangeType),
|
||||
},
|
||||
}
|
||||
if localStore.DeliveryRangeType == 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),
|
||||
}
|
||||
param.FenceInfo.Circular = circular
|
||||
} else if localStore.DeliveryRangeType == tiktok_api.ShapePolygon {
|
||||
tempStr := strings.Split(localStore.DeliveryRange, ";")
|
||||
for v := len(tempStr) - 1; v >= 0; v-- {
|
||||
s2 := strings.Split(tempStr[v], ",")
|
||||
vertices := warehouse_createFence_request.VerticesItem{
|
||||
Longitude: utils.Str2Float64(s2[0]),
|
||||
Latitude: utils.Str2Float64(s2[1]),
|
||||
}
|
||||
verticeses = append(verticeses, vertices)
|
||||
}
|
||||
param.FenceInfo.Polygon.Vertices = verticeses
|
||||
}
|
||||
_, err := getAPI("", 0, "").CreateFence(param)
|
||||
if err != nil {
|
||||
return err
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
//门店直接绑定围栏
|
||||
func BindFenceByStore(storeID int64, addOutFenceIDs []string) error {
|
||||
param := &warehouse_bindFencesByStore_request.WarehouseBindFencesByStoreParam{
|
||||
|
||||
Reference in New Issue
Block a user