Merge branch 'jdshop' of e.coding.net:rosydev/jx-callback into jdshop
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/common"
|
"git.rosy.net.cn/jx-callback/business/jxstore/common"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/event"
|
"git.rosy.net.cn/jx-callback/business/jxstore/event"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner/purchase/tiktok_store"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
@@ -1543,7 +1544,10 @@ func AddStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, vendorID int, vend
|
|||||||
err = ErrCanNotFindVendor
|
err = ErrCanNotFindVendor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if vendorID == model.VendorIDDD { //抖店绑定店铺时 检查并补充创建
|
||||||
|
err = tiktok_store.CreateOrUpdateAll(vendorOrgCode, int64(storeMap.StoreID), utils.Str2Int64(storeMap.VendorStoreID))
|
||||||
}
|
}
|
||||||
|
|
||||||
storeMapList, err := dao.GetStoresMapList2(db, []int{vendorID}, []int{storeID}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "", "", true)
|
storeMapList, err := dao.GetStoresMapList2(db, []int{vendorID}, []int{storeID}, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "", "", true)
|
||||||
if len(storeMapList) > 0 {
|
if len(storeMapList) > 0 {
|
||||||
_, err = CurVendorSync.SyncStore(ctx, db, storeMap.VendorID, storeID, false, userName)
|
_, err = CurVendorSync.SyncStore(ctx, db, storeMap.VendorID, storeID, false, userName)
|
||||||
|
|||||||
19
business/partner/delivery/tiktok_store/store.go
Normal file
19
business/partner/delivery/tiktok_store/store.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package tiktok_store
|
||||||
|
|
||||||
|
//
|
||||||
|
//func (c *DeliveryHandler) UpdateStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (err error) {
|
||||||
|
// if globals.EnableStoreWrite {
|
||||||
|
// //info:=&
|
||||||
|
//
|
||||||
|
// shopInfo := &mtpsapi.ShopInfo{
|
||||||
|
// ShopID: utils.Int2Str(storeDetail.ID),
|
||||||
|
// ContactName: storeDetail.PayeeName,
|
||||||
|
// ContactPhone: storeDetail.Tel1,
|
||||||
|
// ShopAddress: storeDetail.Address,
|
||||||
|
// ShopLat: storeDetail.Lat,
|
||||||
|
// ShopLng: storeDetail.Lng,
|
||||||
|
// }
|
||||||
|
// _, err = api.MtpsAPI.ShopUpdate(shopInfo)
|
||||||
|
// }
|
||||||
|
// return err
|
||||||
|
//}
|
||||||
75
business/partner/delivery/tiktok_store/waybill.go
Normal file
75
business/partner/delivery/tiktok_store/waybill.go
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
package tiktok_store
|
||||||
|
|
||||||
|
//
|
||||||
|
//import (
|
||||||
|
// "git.rosy.net.cn/baseapi/platformapi/mtpsapi"
|
||||||
|
// "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
|
// "git.rosy.net.cn/jx-callback/business/model"
|
||||||
|
// "git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
|
// "git.rosy.net.cn/jx-callback/business/partner"
|
||||||
|
// "git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//var (
|
||||||
|
// curDeliveryHandler *DeliveryHandler
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//type DeliveryHandler struct {
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func init() {
|
||||||
|
// if api.TiktokStore != nil {
|
||||||
|
// curDeliveryHandler = new(DeliveryHandler)
|
||||||
|
// partner.RegisterDeliveryPlatform(curDeliveryHandler, true)
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func (c *DeliveryHandler) GetVendorID() int {
|
||||||
|
// //TODO implement me
|
||||||
|
// panic("implement me")
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func (c *DeliveryHandler) CreateStore(ctx *jxcontext.Context, storeDetail *dao.StoreDetail2) (vendorStoreID string, status int, err error) {
|
||||||
|
// //TODO implement me
|
||||||
|
// panic("implement me")
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func (c *DeliveryHandler) GetStore(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeDetail *dao.StoreDetail2, err error) {
|
||||||
|
// //TODO implement me
|
||||||
|
// panic("implement me")
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func (c *DeliveryHandler) IsErrStoreNotExist(err error) bool {
|
||||||
|
// //TODO implement me
|
||||||
|
// panic("implement me")
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func (c *DeliveryHandler) IsErrStoreExist(err error) bool {
|
||||||
|
// //TODO implement me
|
||||||
|
// panic("implement me")
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func (c *DeliveryHandler) CreateWaybill(order *model.GoodsOrder, maxDeliveryFee int64) (bill *model.Waybill, err error) {
|
||||||
|
// //TODO implement me
|
||||||
|
// panic("implement me")
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func (c *DeliveryHandler) CancelWaybill(bill *model.Waybill, cancelReasonID int, cancelReason string) (err error) {
|
||||||
|
// //TODO implement me
|
||||||
|
// panic("implement me")
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func (c *DeliveryHandler) GetWaybillFee(order *model.GoodsOrder) (deliveryFeeInfo *partner.WaybillFeeInfo, err error) {
|
||||||
|
// //TODO implement me
|
||||||
|
// panic("implement me")
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func (c *DeliveryHandler) ComplaintRider(bill *model.Waybill, resonID int, resonContent string) (err error) {
|
||||||
|
// //TODO implement me
|
||||||
|
// panic("implement me")
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//func (c *DeliveryHandler) GetRiderInfo(orderId string, deliveryId int64, mtPeisongId string) (rider *mtpsapi.RiderInfo, err error) {
|
||||||
|
// //TODO implement me
|
||||||
|
// panic("implement me")
|
||||||
|
//}
|
||||||
@@ -83,17 +83,14 @@ func SplicingTimeToDoudian(openTime1, closeTime1, openTime2, closeTime2 int16, f
|
|||||||
// shop/batchCreateStore 批量创建门店
|
// shop/batchCreateStore 批量创建门店
|
||||||
func (P *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName string, params map[string]interface{}, storeDetail *dao.StoreDetail) (vendorStoreID string, err error) {
|
func (P *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName string, params map[string]interface{}, storeDetail *dao.StoreDetail) (vendorStoreID string, err error) {
|
||||||
var (
|
var (
|
||||||
storeIDs string
|
vendorStoreIDs string
|
||||||
tempStoreID []int64
|
|
||||||
lists []shop_batchCreateStore_request.StoreListItem
|
lists []shop_batchCreateStore_request.StoreListItem
|
||||||
ShopBatchCreateStoreParam *shop_batchCreateStore_request.ShopBatchCreateStoreParam
|
ShopBatchCreateStoreParam *shop_batchCreateStore_request.ShopBatchCreateStoreParam
|
||||||
FreightTemplate = &model.FreightTemplate{}
|
|
||||||
errList = errlist.New()
|
errList = errlist.New()
|
||||||
timeStr = ""
|
timeStr = ""
|
||||||
m = make(map[int64]string)
|
m = make(map[int64]string)
|
||||||
)
|
)
|
||||||
//增加绑定门店操作
|
//增加绑定门店操作
|
||||||
|
|
||||||
a := getAPI(storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID)
|
a := getAPI(storeDetail.VendorOrgCode, storeID, storeDetail.VendorStoreID)
|
||||||
if storeDetail.OpenTime1 == 0 || storeDetail.CloseTime1 == 0 {
|
if storeDetail.OpenTime1 == 0 || storeDetail.CloseTime1 == 0 {
|
||||||
return "", fmt.Errorf("营业时间必填")
|
return "", fmt.Errorf("营业时间必填")
|
||||||
@@ -110,7 +107,7 @@ func (P *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName stri
|
|||||||
}
|
}
|
||||||
list := shop_batchCreateStore_request.StoreListItem{
|
list := shop_batchCreateStore_request.StoreListItem{
|
||||||
RowId: 1,
|
RowId: 1,
|
||||||
Name: storeDetail.Name,
|
Name: "京西菜市(" + storeDetail.Name + ")",
|
||||||
StoreCode: utils.Int2Str(storeDetail.Store.ID),
|
StoreCode: utils.Int2Str(storeDetail.Store.ID),
|
||||||
Longitude: utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lng)),
|
Longitude: utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lng)),
|
||||||
Latitude: utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lat)),
|
Latitude: utils.Float64ToStr(jxutils.IntCoordinate2Standard(storeDetail.Lat)),
|
||||||
@@ -130,78 +127,117 @@ func (P *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName stri
|
|||||||
if resp, err := a.BatchCreateStore(ShopBatchCreateStoreParam); err != nil {
|
if resp, err := a.BatchCreateStore(ShopBatchCreateStoreParam); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
} else {
|
} else {
|
||||||
storeIDs = utils.Int64ToStr(resp.ResultList[0].Store.StoreId)
|
vendorStoreIDs = utils.Int64ToStr(resp.ResultList[0].Store.StoreId)
|
||||||
if utils.Str2Int(storeIDs) == 0 || len(resp.ResultList) == 0 {
|
if err := CreateOrUpdateAll(storeDetail.VendorOrgCode, int64(storeDetail.Store.ID), resp.ResultList[0].Store.StoreId); err != nil {
|
||||||
return "", errors.New(fmt.Sprintf("创建店铺失败,storeIDs = 0:%v,%v", err, resp.ResultList[0].Msg))
|
errList.AddErr(err)
|
||||||
}
|
}
|
||||||
//创建并绑定运费模板
|
}
|
||||||
//先获取是否已绑定
|
return vendorStoreIDs, errors.New(fmt.Sprintf("%s", utils.Format4Output(errList, true)))
|
||||||
//if bindFenceIDs,err:=GetStoreFreight(storeDetail.VendorOrgCode,storeDetail.Store.ID)
|
}
|
||||||
if freightTemplateID, err := CreateFreightTemplate(storeDetail.Store.ID); err != nil {
|
|
||||||
|
//电子围栏 仓库 运费模板 限售模板 更新与绑定
|
||||||
|
func CreateOrUpdateAll(vendorOrgCode string, storeID, vendorStoreID int64) error {
|
||||||
|
var (
|
||||||
|
errList = errlist.New()
|
||||||
|
FreightTemplate = &model.FreightTemplate{}
|
||||||
|
db *dao.DaoDB
|
||||||
|
)
|
||||||
|
//1.平台获取门店运费模板
|
||||||
|
bindFreightIDs, err := GetStoreFreight(vendorOrgCode, vendorStoreID)
|
||||||
|
if err != nil {
|
||||||
|
errList.AddErr(fmt.Errorf("获取门店(%d) 绑定运费模板出错:%v", vendorStoreID, err))
|
||||||
|
}
|
||||||
|
if bindFreightIDs == 0 { //(1)未查询到绑定信息,不算错误
|
||||||
|
//创建
|
||||||
|
if freightTemplateID, err := CreateFreightTemplate(int(storeID)); err != nil || freightTemplateID == 0 || utils.IsNil(freightTemplateID) {
|
||||||
errList.AddErr(fmt.Errorf("创建运费模板失败:%v", err))
|
errList.AddErr(fmt.Errorf("创建运费模板失败:%v", err))
|
||||||
} else {
|
} else { //绑定
|
||||||
if freightTemplateID == 0 {
|
if err = ShopBindStoreFreight(vendorOrgCode, vendorStoreID, freightTemplateID); err != nil {
|
||||||
errList.AddErr(fmt.Errorf("创建运费模板失败:%v", err))
|
errList.AddErr(fmt.Errorf("京西菜市门店:%d 平台门店:%d 绑定运费模板:%d 失败:%v", storeID, vendorStoreID, freightTemplateID, err))
|
||||||
} else {
|
} else {
|
||||||
if err = ShopBindStoreFreight(storeDetail.VendorOrgCode, int64(storeDetail.Store.ID), freightTemplateID); err != nil {
|
FreightTemplate.TemplateID = freightTemplateID
|
||||||
errList.AddErr(fmt.Errorf("本地门店:%d 绑定运费模板:%d 失败:%v", int64(storeDetail.Store.ID), freightTemplateID, err))
|
if err = dao.CreateEntity(db, FreightTemplate); err != nil {
|
||||||
|
errList.AddErr(fmt.Errorf("运费模板:%d 同步数据库失败:%v", freightTemplateID, err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else { //同步信息到本地
|
||||||
|
if _, err = dao.UpdateEntity(db, FreightTemplate, "TemplateID"); err != nil {
|
||||||
|
errList.AddErr(fmt.Errorf("平台运费模板 同步到本地出错:%v", err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//2.平台获取仓库信息以及电子围栏id
|
||||||
|
bindWarehouseAndFence, err := GetWarehouseByStore(vendorOrgCode, vendorStoreID)
|
||||||
|
if err != nil {
|
||||||
|
errList.AddErr(fmt.Errorf("获取门店(%d) 绑定仓库信息以及电子围栏出错:%v", vendorStoreID, err))
|
||||||
|
}
|
||||||
|
if len(bindWarehouseAndFence) == 0 || utils.IsNil(bindWarehouseAndFence) { //未绑定仓库
|
||||||
|
if warehouseID, err := CreateWarehouse(vendorOrgCode, utils.Int64ToStr(storeID)); err != nil || warehouseID == 0 || utils.IsNil(warehouseID) {
|
||||||
|
errList.AddErr(fmt.Errorf("门店(%d) 创建仓库失败:%v", storeID, err))
|
||||||
|
} else { //绑定
|
||||||
|
if err = BindStoreWarehouse(vendorOrgCode, utils.Int64ToStr(storeID), vendorStoreID); err != nil { //仓库绑定通过自定义外部ID
|
||||||
|
errList.AddErr(fmt.Errorf("门店(%d) 绑定仓库:%d 失败:%v", storeID, warehouseID, err))
|
||||||
|
} else {
|
||||||
|
FreightTemplate.WarehouseID = warehouseID
|
||||||
|
if err = dao.CreateEntity(db, FreightTemplate); err != nil {
|
||||||
|
errList.AddErr(fmt.Errorf("仓库ID(%d) 同步到数据库失败:%v", warehouseID, err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(bindWarehouseAndFence[0][vendorStoreID].OutFenceIds) == 0 || utils.IsNil(bindWarehouseAndFence[0][vendorStoreID].OutFenceIds) { //未绑定电子围栏
|
||||||
|
if fenceID, err := CreateFenceByStore(vendorOrgCode, storeID); err != nil || utils.Str2Int(fenceID) == 0 || utils.IsNil(fenceID) { //创建
|
||||||
|
errList.AddErr(fmt.Errorf("门店(%d) 创建电子围栏失败:%v", storeID, err))
|
||||||
|
} else { //绑定
|
||||||
|
if err := BindFenceByStore(vendorOrgCode, vendorStoreID, []string{utils.Int64ToStr(storeID)}); err != nil {
|
||||||
|
errList.AddErr(fmt.Errorf("门店(%d) 绑定电子围栏:%s失败:%v", storeID, fenceID, err))
|
||||||
} else {
|
} else {
|
||||||
FreightTemplate.TemplateID = freightTemplateID
|
FreightTemplate.FenceID = utils.Int64ToStr(storeID)
|
||||||
if err = dao.CreateEntity(db, FreightTemplate); err != nil {
|
if err := dao.CreateEntity(db, FreightTemplate); err != nil {
|
||||||
errList.AddErr(fmt.Errorf("运费模板ID存入数据库失败:%v", err))
|
errList.AddErr(fmt.Errorf("电子围栏ID(%s) 同步到数据库失败:%v", fenceID, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//创建并绑定仓库
|
} else { //同步信息到本地
|
||||||
if warehouse, err := CreateWarehouse(storeDetail.VendorOrgCode, utils.Int2Str(storeDetail.Store.ID)); err != nil {
|
if _, err = dao.UpdateEntity(db, FreightTemplate, "FenceID"); err != nil {
|
||||||
errList.AddErr(fmt.Errorf("创建仓库失败:%v", err))
|
errList.AddErr(fmt.Errorf("电子围栏 同步到本地出错:%v", err))
|
||||||
} else {
|
|
||||||
tempStoreID = append(tempStoreID, int64(storeDetail.Store.ID))
|
|
||||||
if err = BindStoreWarehouse(storeDetail.VendorOrgCode, utils.Int64ToStr(warehouse), tempStoreID); err != nil {
|
|
||||||
errList.AddErr(fmt.Errorf("门店:%d 绑定仓库:%d 失败:%v", int64(storeDetail.Store.ID), warehouse, err))
|
|
||||||
} else {
|
|
||||||
FreightTemplate.WarehouseID = warehouse
|
|
||||||
if err = dao.CreateEntity(db, FreightTemplate); err != nil {
|
|
||||||
errList.AddErr(fmt.Errorf("仓库ID存入数据库失败:%v", err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//创建并绑定电子围栏
|
if _, err = dao.UpdateEntity(db, FreightTemplate, "WarehouseID"); err != nil {
|
||||||
if fenceID, err := CreateFenceByStore(storeDetail.VendorOrgCode, int(resp.ResultList[0].Store.StoreId)); err != nil {
|
errList.AddErr(fmt.Errorf("仓库 同步到本地出错:%v", err))
|
||||||
errList.AddErr(fmt.Errorf("创建电子围栏失败:%v", err))
|
|
||||||
} else {
|
|
||||||
fences := []string{utils.Int2Str(storeDetail.Store.ID)}
|
|
||||||
if err := BindFenceByStore(storeDetail.VendorOrgCode, resp.ResultList[0].Store.StoreId, fences); err != nil {
|
|
||||||
errList.AddErr(fmt.Errorf("门店:%d 绑定电子围栏:%s 失败:%v", resp.ResultList[0].Store.StoreId, fenceID, err))
|
|
||||||
} else {
|
|
||||||
FreightTemplate.FenceID = fenceID
|
|
||||||
if err := dao.CreateEntity(db, FreightTemplate); err != nil {
|
|
||||||
errList.AddErr(fmt.Errorf("电子围栏ID存入数据库失败:%v", err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//创建限售模板
|
}
|
||||||
if tradeLimitID, err := CreateTradeLimitTemplate(storeDetail.VendorOrgCode, int64(storeDetail.Store.ID)); err != nil {
|
|
||||||
errList.AddErr(fmt.Errorf("创建限售模板失败:%v", err))
|
//3.平台获取限售模板
|
||||||
|
SaleLimitID, err := GetStoreSaleLimit(vendorOrgCode, vendorStoreID)
|
||||||
|
if err != nil {
|
||||||
|
errList.AddErr(fmt.Errorf("获取门店(%d) 限售模板出错:%v", vendorStoreID, err))
|
||||||
|
}
|
||||||
|
if SaleLimitID == 0 || utils.IsNil(SaleLimitID) { //未绑定限售模板
|
||||||
|
if tradeLimitID, err := CreateTradeLimitTemplate(vendorOrgCode, storeID); err != nil || tradeLimitID == 0 || utils.IsNil(tradeLimitID) {
|
||||||
|
errList.AddErr(fmt.Errorf("门店(%d) 创建限售模板失败:%v", storeID, err))
|
||||||
} else {
|
} else {
|
||||||
if err := BindStoreSaleLimit(storeDetail.VendorOrgCode, resp.ResultList[0].Store.StoreId, tradeLimitID); err != nil {
|
if err := BindStoreSaleLimit(vendorOrgCode, vendorStoreID, tradeLimitID); err != nil {
|
||||||
errList.AddErr(fmt.Errorf("绑定限售模板失败:%v", err))
|
errList.AddErr(fmt.Errorf("门店(%d) 绑定限售模板失败:%v", storeID, err))
|
||||||
} else {
|
} else {
|
||||||
FreightTemplate.TradeLimitID = tradeLimitID
|
FreightTemplate.TradeLimitID = tradeLimitID
|
||||||
if err := dao.CreateEntity(db, FreightTemplate); err != nil {
|
if err := dao.CreateEntity(db, FreightTemplate); err != nil {
|
||||||
errList.AddErr(fmt.Errorf("限售模板ID存入数据库失败:%v", err))
|
errList.AddErr(fmt.Errorf("限售模板(%d) 存入数据库失败:%v", tradeLimitID, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FreightTemplate.StoreID = storeDetail.Store.ID
|
} else { //同步到本地
|
||||||
FreightTemplate.VendorStoreID = storeIDs
|
if _, err = dao.UpdateEntity(db, FreightTemplate, "TradeLimitID"); err != nil {
|
||||||
FreightTemplate.DeletedAt = utils.DefaultTimeValue
|
errList.AddErr(fmt.Errorf("限售模板 同步到本地出错:%v", err))
|
||||||
if err = dao.CreateEntity(db, FreightTemplate); err != nil {
|
|
||||||
errList.AddErr(fmt.Errorf("db update storeID,vendorStoreID defeat on :%v", err))
|
|
||||||
}
|
}
|
||||||
return storeIDs, errors.New(fmt.Sprintf("%s", utils.Format4Output(errList, true)))
|
|
||||||
}
|
}
|
||||||
|
FreightTemplate.StoreID = int(storeID)
|
||||||
|
FreightTemplate.VendorStoreID = utils.Int64ToStr(vendorStoreID)
|
||||||
|
FreightTemplate.DeletedAt = utils.DefaultTimeValue
|
||||||
|
if err = dao.CreateEntity(db, FreightTemplate); err != nil {
|
||||||
|
errList.AddErr(fmt.Errorf("db update storeID,vendorStoreID defeat on :%v", err))
|
||||||
|
}
|
||||||
|
return errors.New(fmt.Sprintf("%s", utils.Format4Output(errList, true)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// shop/editStore 编辑门店信息 正向推送平台
|
// shop/editStore 编辑门店信息 正向推送平台
|
||||||
@@ -267,7 +303,7 @@ func (P *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
}
|
}
|
||||||
//修改店铺状态
|
//修改店铺状态
|
||||||
if storeInfo.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreStatus) != 0 {
|
if storeInfo.SyncStatus&(model.SyncFlagNewMask|model.SyncFlagStoreStatus) != 0 {
|
||||||
errList.AddErr(P.UpdateStoreStatus(jxcontext.AdminCtx, storeInfo.VendorOrgCode, storeID, storeInfo.VendorStoreID, mergedStoreStatus))
|
errList.AddErr(UpdateStoreStatus(jxcontext.AdminCtx, storeInfo.VendorOrgCode, storeID, storeInfo.VendorStoreID, mergedStoreStatus))
|
||||||
}
|
}
|
||||||
err3 := api.EditStore(params)
|
err3 := api.EditStore(params)
|
||||||
if err3 != nil {
|
if err3 != nil {
|
||||||
@@ -289,33 +325,33 @@ func (P *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateStoreStatus shop/unsuspendStore 门店恢复营业
|
// UpdateStoreStatus shop/unsuspendStore 门店恢复营业
|
||||||
func (p *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, status int) (err error) {
|
func UpdateStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, status int) (err error) {
|
||||||
isOnline := bizStatusJX2DouDian(status)
|
isOnline := bizStatusJX2DouDian(status)
|
||||||
api := getAPI(vendorOrgCode, storeID, vendorStoreID)
|
a := getAPI(vendorOrgCode, storeID, vendorStoreID)
|
||||||
if globals.EnableDdStoreWrite {
|
if globals.EnableDdStoreWrite {
|
||||||
if isOnline != tiktok_api.StoreStatusOnline { //暂停营业状态
|
if isOnline != tiktok_api.StoreStatusOnline { //暂停营业状态
|
||||||
unsuspendStoreID := &shop_unsuspendStore_request.ShopUnsuspendStoreParam{
|
suspendStoreID := &shop_storeSuspend_request.ShopStoreSuspendParam{
|
||||||
StoreId: utils.Str2Int64(vendorStoreID),
|
StoreId: utils.Str2Int64(vendorStoreID),
|
||||||
}
|
}
|
||||||
if _, err = api.UnsuspendStore(unsuspendStoreID); err != nil {
|
if _, err = a.StoreSuspend(suspendStoreID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else { //恢复营业
|
} else { //恢复营业
|
||||||
suspendStoreID := &shop_storeSuspend_request.ShopStoreSuspendParam{
|
unsuspendStoreID := &shop_unsuspendStore_request.ShopUnsuspendStoreParam{
|
||||||
StoreId: utils.Str2Int64(vendorStoreID),
|
StoreId: utils.Str2Int64(vendorStoreID),
|
||||||
}
|
}
|
||||||
getStoreID := &shop_getStoreDetail_request.ShopGetStoreDetailParam{
|
getStoreID := &shop_getStoreDetail_request.ShopGetStoreDetailParam{
|
||||||
StoreId: utils.Str2Int64(vendorStoreID),
|
StoreId: utils.Str2Int64(vendorStoreID),
|
||||||
}
|
}
|
||||||
//平台上店铺状态
|
//平台上店铺状态
|
||||||
remoteStoreInfo, err2 := api.GetStoreDetail(getStoreID)
|
remoteStoreInfo, err2 := a.GetStoreDetail(getStoreID)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
return err2
|
return err2
|
||||||
}
|
}
|
||||||
if remoteStoreInfo.StoreDetail.Store.SuspendType == tiktok_api.SuspendTypePlatformPenalty {
|
if remoteStoreInfo.StoreDetail.Store.SuspendType == tiktok_api.SuspendTypePlatformPenalty {
|
||||||
err = errors.New("门店因平台处罚暂停营业,不可主动修改营业状态")
|
err = errors.New("门店因平台处罚暂停营业,不可主动修改营业状态")
|
||||||
} else {
|
} else {
|
||||||
if _, err = api.StoreSuspend(suspendStoreID); err != nil {
|
if _, err = a.UnsuspendStore(unsuspendStoreID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -502,32 +538,6 @@ func (P *PurchaseHandler) CreateAddress(addressInfo address_create_request.Addre
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
//添加进数据库page_shop
|
|
||||||
//获取门店信息
|
|
||||||
//storeID := &shop_getStoreDetail_request.ShopGetStoreDetailParam{
|
|
||||||
// StoreId: addressInfo.StoreId,
|
|
||||||
//}
|
|
||||||
//storeInfo, err1 := api.DouDianApi.GetStoreDetail(storeID)
|
|
||||||
//if err1 != nil {
|
|
||||||
// return 0, err1
|
|
||||||
//}
|
|
||||||
//createAddress := &model.PageShop{ //此表暂存门店售后地址库
|
|
||||||
// Name: storeInfo.StoreDetail.Store.Name,
|
|
||||||
// VendorID: model.VendorIDDouDian,
|
|
||||||
// VendorStoreID: utils.Int64ToStr(storeInfo.StoreDetail.Store.StoreId), //抖店平台ID
|
|
||||||
// OrgCode: storeInfo.StoreDetail.Store.StoreCode, //暂时用来存放京西平台门店ID
|
|
||||||
// VendorStatus: utils.Int64ToStr(storeInfo.StoreDetail.Store.State),
|
|
||||||
// Status: 0,
|
|
||||||
// CityCode: utils.Str2Int(storeInfo.StoreDetail.Store.CityCode),
|
|
||||||
// DistrictCode: utils.Str2Int(storeInfo.StoreDetail.Store.DistrictCode),
|
|
||||||
// Address: storeInfo.StoreDetail.Store.Address,
|
|
||||||
// Lng: utils.Str2Float64(storeInfo.StoreDetail.Store.Longitude),
|
|
||||||
// Lat: utils.Str2Float64(storeInfo.StoreDetail.Store.Latitude),
|
|
||||||
// Tel1: storeInfo.StoreDetail.Store.Contact,
|
|
||||||
//}
|
|
||||||
//if err = dao.CreateEntity(dao.GetDB(), createAddress); err != nil {
|
|
||||||
// return 0, err
|
|
||||||
//}
|
|
||||||
return resp.AddressId, nil
|
return resp.AddressId, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -590,6 +600,15 @@ func BindStoreSaleLimit(appOrgCode string, storeID, saleLimitTemplateID int64) e
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取门店绑定限售模板
|
||||||
|
func GetStoreSaleLimit(appOrgCode string, storeID int64) (int64, error) {
|
||||||
|
saleLimitTemplateID, err := getAPI(appOrgCode, 0, "").StoreQuerySaleLimitTemp(storeID)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return saleLimitTemplateID, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (P *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, opTimeList []int16) (err error) {
|
func (P *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, opTimeList []int16) (err error) {
|
||||||
t1 := opTimeList[0]
|
t1 := opTimeList[0]
|
||||||
t2 := opTimeList[1]
|
t2 := opTimeList[1]
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import (
|
|||||||
warehouse_create_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/warehouse_create/request"
|
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_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_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/platformapi/tiktok_shop/tiktok_api"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
@@ -16,7 +18,7 @@ import (
|
|||||||
|
|
||||||
// /warehouse/create 创建单个区域仓
|
// /warehouse/create 创建单个区域仓
|
||||||
func CreateWarehouse(appOrgCode, outWarehouseID string) (warehouseID int64, err error) {
|
func CreateWarehouse(appOrgCode, outWarehouseID string) (warehouseID int64, err error) {
|
||||||
tempName := "门店编码:" + outWarehouseID + "的区域仓"
|
tempName := "京西菜市(" + outWarehouseID + ")的区域仓"
|
||||||
req := &warehouse_create_request.WarehouseCreateParam{
|
req := &warehouse_create_request.WarehouseCreateParam{
|
||||||
OutWarehouseId: outWarehouseID,
|
OutWarehouseId: outWarehouseID,
|
||||||
Name: tempName,
|
Name: tempName,
|
||||||
@@ -57,9 +59,9 @@ func (P *PurchaseHandler) BatchCreateWarehouse(param warehouse_createBatch_reque
|
|||||||
}
|
}
|
||||||
|
|
||||||
// /warehouse/bindStore 仓库绑定门店
|
// /warehouse/bindStore 仓库绑定门店
|
||||||
func BindStoreWarehouse(VendorOrgCode, outWarehouseID string, storeIDs []int64) error {
|
func BindStoreWarehouse(VendorOrgCode, outWarehouseID string, storeIDs int64) error {
|
||||||
param := &warehouse_bindStore_request.WarehouseBindStoreParam{
|
param := &warehouse_bindStore_request.WarehouseBindStoreParam{
|
||||||
StoreIds: storeIDs,
|
StoreIds: []int64{storeIDs},
|
||||||
OutWarehouseId: outWarehouseID,
|
OutWarehouseId: outWarehouseID,
|
||||||
}
|
}
|
||||||
if _, err := getAPI(VendorOrgCode, 0, "").StoreBindWarehouse(param); err != nil {
|
if _, err := getAPI(VendorOrgCode, 0, "").StoreBindWarehouse(param); err != nil {
|
||||||
@@ -68,6 +70,15 @@ func BindStoreWarehouse(VendorOrgCode, outWarehouseID string, storeIDs []int64)
|
|||||||
return nil
|
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 {
|
type LocalStore struct {
|
||||||
Lng int `json:"-"` // 乘了10的6次方
|
Lng int `json:"-"` // 乘了10的6次方
|
||||||
Lat int `json:"-"` // 乘了10的6次方
|
Lat int `json:"-"` // 乘了10的6次方
|
||||||
@@ -77,7 +88,7 @@ type LocalStore struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// /warehouse/createFence 以门店方式创建电子围栏
|
// /warehouse/createFence 以门店方式创建电子围栏
|
||||||
func CreateFenceByStore(appOrgCode string, storeID int) (fenceID string, err error) {
|
func CreateFenceByStore(appOrgCode string, storeID int64) (fenceID string, err error) {
|
||||||
var (
|
var (
|
||||||
db *dao.DaoDB
|
db *dao.DaoDB
|
||||||
localStore *LocalStore
|
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 {
|
if err = dao.GetRow(db, &localStore, sqlStr, sqlParam...); err == nil {
|
||||||
param := &warehouse_createFence_request.WarehouseCreateFenceParam{
|
param := &warehouse_createFence_request.WarehouseCreateFenceParam{
|
||||||
FenceInfo: &warehouse_createFence_request.FenceInfo{
|
FenceInfo: &warehouse_createFence_request.FenceInfo{
|
||||||
OutFenceId: utils.Int2Str(storeID), //绑定基于此id
|
OutFenceId: utils.Int64ToStr(storeID), //绑定基于此id
|
||||||
Shape: int32(localStore.DeliveryRangeType),
|
Shape: int32(localStore.DeliveryRangeType),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -151,7 +162,7 @@ func UpdateFenceByStore(appOrgCode string, storeID int) error {
|
|||||||
var (
|
var (
|
||||||
db *dao.DaoDB
|
db *dao.DaoDB
|
||||||
localStore *LocalStore
|
localStore *LocalStore
|
||||||
verticeses []warehouse_createFence_request.VerticesItem
|
verticeses []warehouse_setFence_request.VerticesItem
|
||||||
)
|
)
|
||||||
sqlParam := []interface{}{
|
sqlParam := []interface{}{
|
||||||
model.VendorIDDD,
|
model.VendorIDDD,
|
||||||
@@ -165,15 +176,15 @@ func UpdateFenceByStore(appOrgCode string, storeID int) error {
|
|||||||
return fmt.Errorf("storeID必填")
|
return fmt.Errorf("storeID必填")
|
||||||
}
|
}
|
||||||
if err := dao.GetRow(db, &localStore, sqlStr, sqlParam...); err == nil {
|
if err := dao.GetRow(db, &localStore, sqlStr, sqlParam...); err == nil {
|
||||||
param := &warehouse_createFence_request.WarehouseCreateFenceParam{
|
param := &warehouse_setFence_request.WarehouseSetFenceParam{
|
||||||
FenceInfo: &warehouse_createFence_request.FenceInfo{
|
FenceInfo: &warehouse_setFence_request.FenceInfo{
|
||||||
OutFenceId: utils.Int2Str(storeID),
|
OutFenceId: utils.Int2Str(storeID),
|
||||||
Shape: int32(localStore.DeliveryRangeType),
|
Shape: int32(localStore.DeliveryRangeType),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if localStore.DeliveryRangeType == tiktok_api.ShapeCircular {
|
if localStore.DeliveryRangeType == tiktok_api.ShapeCircular {
|
||||||
circular := &warehouse_createFence_request.Circular{
|
circular := &warehouse_setFence_request.Circular{
|
||||||
Center: &warehouse_createFence_request.Center{
|
Center: &warehouse_setFence_request.Center{
|
||||||
Longitude: utils.Int2Float64(localStore.Lng),
|
Longitude: utils.Int2Float64(localStore.Lng),
|
||||||
Latitude: utils.Int2Float64(localStore.Lat),
|
Latitude: utils.Int2Float64(localStore.Lat),
|
||||||
},
|
},
|
||||||
@@ -184,7 +195,7 @@ func UpdateFenceByStore(appOrgCode string, storeID int) error {
|
|||||||
tempStr := strings.Split(localStore.DeliveryRange, ";")
|
tempStr := strings.Split(localStore.DeliveryRange, ";")
|
||||||
for v := len(tempStr) - 1; v >= 0; v-- {
|
for v := len(tempStr) - 1; v >= 0; v-- {
|
||||||
s2 := strings.Split(tempStr[v], ",")
|
s2 := strings.Split(tempStr[v], ",")
|
||||||
vertices := warehouse_createFence_request.VerticesItem{
|
vertices := warehouse_setFence_request.VerticesItem{
|
||||||
Longitude: utils.Str2Float64(s2[0]),
|
Longitude: utils.Str2Float64(s2[0]),
|
||||||
Latitude: utils.Str2Float64(s2[1]),
|
Latitude: utils.Str2Float64(s2[1]),
|
||||||
}
|
}
|
||||||
@@ -192,8 +203,7 @@ func UpdateFenceByStore(appOrgCode string, storeID int) error {
|
|||||||
}
|
}
|
||||||
param.FenceInfo.Polygon.Vertices = verticeses
|
param.FenceInfo.Polygon.Vertices = verticeses
|
||||||
}
|
}
|
||||||
_, err := getAPI("", 0, "").CreateFence(param)
|
if err := getAPI(appOrgCode, 0, "").SetFence(param); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -213,3 +223,8 @@ func BindFenceByStore(appOrgCode string, storeID int64, addOutFenceIDs []string)
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取仓库绑定电子围栏(即门店) 同步三个映射关系
|
||||||
|
//func GetStoreFence() {
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|||||||
Reference in New Issue
Block a user