fence
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
warehouse_create_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/warehouse_create/request"
|
||||
warehouse_createBatch_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/warehouse_createBatch/request"
|
||||
warehouse_createFence_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/warehouse_createFence/request"
|
||||
warehouse_getWarehouseByStore_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/warehouse_getWarehouseByStore/response"
|
||||
warehouse_setFence_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/warehouse_setFence/request"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
@@ -16,7 +18,7 @@ import (
|
||||
|
||||
// /warehouse/create 创建单个区域仓
|
||||
func CreateWarehouse(appOrgCode, outWarehouseID string) (warehouseID int64, err error) {
|
||||
tempName := "门店编码:" + outWarehouseID + "的区域仓"
|
||||
tempName := "京西菜市(" + outWarehouseID + ")的区域仓"
|
||||
req := &warehouse_create_request.WarehouseCreateParam{
|
||||
OutWarehouseId: outWarehouseID,
|
||||
Name: tempName,
|
||||
@@ -57,9 +59,9 @@ func (P *PurchaseHandler) BatchCreateWarehouse(param warehouse_createBatch_reque
|
||||
}
|
||||
|
||||
// /warehouse/bindStore 仓库绑定门店
|
||||
func BindStoreWarehouse(VendorOrgCode, outWarehouseID string, storeIDs []int64) error {
|
||||
func BindStoreWarehouse(VendorOrgCode, outWarehouseID string, storeIDs int64) error {
|
||||
param := &warehouse_bindStore_request.WarehouseBindStoreParam{
|
||||
StoreIds: storeIDs,
|
||||
StoreIds: []int64{storeIDs},
|
||||
OutWarehouseId: outWarehouseID,
|
||||
}
|
||||
if _, err := getAPI(VendorOrgCode, 0, "").StoreBindWarehouse(param); err != nil {
|
||||
@@ -68,6 +70,15 @@ func BindStoreWarehouse(VendorOrgCode, outWarehouseID string, storeIDs []int64)
|
||||
return nil
|
||||
}
|
||||
|
||||
// /warehouse/getWarehouseByStore 门店id获取绑定仓库详情包括电子围栏
|
||||
func GetWarehouseByStore(appOrgCode string, storeID int64) (map[int64][]warehouse_getWarehouseByStore_response.WarehouseInfoMapItem, error) {
|
||||
info, err := getAPI(appOrgCode, 0, "").GetWarehouseByStore(storeID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return info, nil
|
||||
}
|
||||
|
||||
type LocalStore struct {
|
||||
Lng int `json:"-"` // 乘了10的6次方
|
||||
Lat int `json:"-"` // 乘了10的6次方
|
||||
@@ -77,7 +88,7 @@ type LocalStore struct {
|
||||
}
|
||||
|
||||
// /warehouse/createFence 以门店方式创建电子围栏
|
||||
func CreateFenceByStore(appOrgCode string, storeID int) (fenceID string, err error) {
|
||||
func CreateFenceByStore(appOrgCode string, storeID int64) (fenceID string, err error) {
|
||||
var (
|
||||
db *dao.DaoDB
|
||||
localStore *LocalStore
|
||||
@@ -98,7 +109,7 @@ func CreateFenceByStore(appOrgCode string, storeID int) (fenceID string, err err
|
||||
if err = dao.GetRow(db, &localStore, sqlStr, sqlParam...); err == nil {
|
||||
param := &warehouse_createFence_request.WarehouseCreateFenceParam{
|
||||
FenceInfo: &warehouse_createFence_request.FenceInfo{
|
||||
OutFenceId: utils.Int2Str(storeID), //绑定基于此id
|
||||
OutFenceId: utils.Int64ToStr(storeID), //绑定基于此id
|
||||
Shape: int32(localStore.DeliveryRangeType),
|
||||
},
|
||||
}
|
||||
@@ -151,7 +162,7 @@ func UpdateFenceByStore(appOrgCode string, storeID int) error {
|
||||
var (
|
||||
db *dao.DaoDB
|
||||
localStore *LocalStore
|
||||
verticeses []warehouse_createFence_request.VerticesItem
|
||||
verticeses []warehouse_setFence_request.VerticesItem
|
||||
)
|
||||
sqlParam := []interface{}{
|
||||
model.VendorIDDD,
|
||||
@@ -165,15 +176,15 @@ func UpdateFenceByStore(appOrgCode string, storeID int) error {
|
||||
return fmt.Errorf("storeID必填")
|
||||
}
|
||||
if err := dao.GetRow(db, &localStore, sqlStr, sqlParam...); err == nil {
|
||||
param := &warehouse_createFence_request.WarehouseCreateFenceParam{
|
||||
FenceInfo: &warehouse_createFence_request.FenceInfo{
|
||||
param := &warehouse_setFence_request.WarehouseSetFenceParam{
|
||||
FenceInfo: &warehouse_setFence_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{
|
||||
circular := &warehouse_setFence_request.Circular{
|
||||
Center: &warehouse_setFence_request.Center{
|
||||
Longitude: utils.Int2Float64(localStore.Lng),
|
||||
Latitude: utils.Int2Float64(localStore.Lat),
|
||||
},
|
||||
@@ -184,7 +195,7 @@ func UpdateFenceByStore(appOrgCode string, storeID int) error {
|
||||
tempStr := strings.Split(localStore.DeliveryRange, ";")
|
||||
for v := len(tempStr) - 1; v >= 0; v-- {
|
||||
s2 := strings.Split(tempStr[v], ",")
|
||||
vertices := warehouse_createFence_request.VerticesItem{
|
||||
vertices := warehouse_setFence_request.VerticesItem{
|
||||
Longitude: utils.Str2Float64(s2[0]),
|
||||
Latitude: utils.Str2Float64(s2[1]),
|
||||
}
|
||||
@@ -192,8 +203,7 @@ func UpdateFenceByStore(appOrgCode string, storeID int) error {
|
||||
}
|
||||
param.FenceInfo.Polygon.Vertices = verticeses
|
||||
}
|
||||
_, err := getAPI("", 0, "").CreateFence(param)
|
||||
if err != nil {
|
||||
if err := getAPI(appOrgCode, 0, "").SetFence(param); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
@@ -213,3 +223,8 @@ func BindFenceByStore(appOrgCode string, storeID int64, addOutFenceIDs []string)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//获取仓库绑定电子围栏(即门店) 同步三个映射关系
|
||||
//func GetStoreFence() {
|
||||
//
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user