1
This commit is contained in:
@@ -47,44 +47,41 @@ func (c *PurchaseHandler) GetVendorID() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PurchaseHandler) GetVendorCategories(ctx *jxcontext.Context) (vendorCats []*model.SkuVendorCategory, err error) {
|
func (p *PurchaseHandler) GetVendorCategories(ctx *jxcontext.Context) (vendorCats []*model.SkuVendorCategory, err error) {
|
||||||
cats, err := api.MtwmAPI.RetailGetSpTagIds()
|
cats, err := getAPI("53802960", 0, "").GetShopCategory(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
vendorCatMapList := make([]map[string]*model.SkuVendorCategory, 3)
|
|
||||||
manID := 10000
|
vendorCats = skuCategory(cats)
|
||||||
for i := 0; i < 3; i++ {
|
return vendorCats, nil
|
||||||
vendorCatMapList[i] = make(map[string]*model.SkuVendorCategory)
|
}
|
||||||
for _, v := range cats {
|
|
||||||
if v.Level == 3 {
|
func skuCategory(param1 []*tiktok_api.RetailCategoryInfo) (vendorCats []*model.SkuVendorCategory) {
|
||||||
namePathList := strings.Split(strings.Trim(v.NamePath, ","), ",")
|
size := make([]*model.SkuVendorCategory, 0)
|
||||||
if len(namePathList) != 3 {
|
for _, v := range param1 {
|
||||||
panic(fmt.Sprintf("%s没有三级结构", v.NamePath))
|
param := &model.SkuVendorCategory{
|
||||||
}
|
VendorCategoryID: utils.Int64ToStr(v.Id),
|
||||||
name := namePathList[i]
|
VendorID: model.VendorIDDD,
|
||||||
if _, ok := vendorCatMapList[i][name]; !ok {
|
Name: v.Name,
|
||||||
cat := &model.SkuVendorCategory{
|
Level: int(v.Level),
|
||||||
VendorID: model.VendorIDMTWM,
|
ParentID: utils.Int64ToStr(v.ParentId),
|
||||||
Name: name, //utils.Interface2String(v["name"]),
|
}
|
||||||
Level: i + 1, //int(utils.MustInterface2Int64(v["level"])),
|
if v.Enable == false {
|
||||||
}
|
param.IsLeaf = 0
|
||||||
vendorCats = append(vendorCats, cat)
|
} else {
|
||||||
vendorCatMapList[i][name] = cat
|
param.IsLeaf = 1
|
||||||
if i == 2 {
|
}
|
||||||
cat.IsLeaf = 1
|
if param.Name != "" {
|
||||||
cat.VendorCategoryID = utils.Int64ToStr(v.ID)
|
size = append(size, param)
|
||||||
} else {
|
}
|
||||||
cat.VendorCategoryID = utils.Int2Str(manID) // 非叶子结点编码没有实际使用
|
|
||||||
manID++
|
if len(v.Children) != 0 {
|
||||||
}
|
kk := skuCategory(v.Children)
|
||||||
if i > 0 {
|
vendorCats = append(vendorCats, kk...)
|
||||||
cat.ParentID = vendorCatMapList[i-1][namePathList[i-1]].VendorCategoryID
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return vendorCats, nil
|
vendorCats = append(vendorCats, size...)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func rangeMtwm2JX(areaStr string) string {
|
func rangeMtwm2JX(areaStr string) string {
|
||||||
|
|||||||
@@ -1,50 +1,51 @@
|
|||||||
package tiktok_store
|
package tiktok_store
|
||||||
|
|
||||||
//import (
|
import (
|
||||||
// "git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
// "git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
// "testing"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
// "time"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
//
|
"testing"
|
||||||
// "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"time"
|
||||||
//
|
)
|
||||||
// "git.rosy.net.cn/baseapi/utils"
|
|
||||||
// _ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
import (
|
||||||
// "git.rosy.net.cn/jx-callback/globals/testinit"
|
_ "git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||||
//)
|
"git.rosy.net.cn/jx-callback/globals/testinit"
|
||||||
//
|
)
|
||||||
//const (
|
|
||||||
// testShopVendorID = "2523687"
|
const (
|
||||||
// testShopID = 2
|
testShopVendorID = "2523687"
|
||||||
//)
|
testShopID = 2
|
||||||
//
|
)
|
||||||
//func init() {
|
|
||||||
// testinit.Init()
|
func init() {
|
||||||
//}
|
testinit.Init()
|
||||||
//
|
}
|
||||||
//// 获取平台分类属性(三级分类标签)
|
|
||||||
//func TestGetVendorCategories(t *testing.T) {
|
// 获取平台分类属性(三级分类标签)
|
||||||
// result, err := new(PurchaseHandler).GetVendorCategories(jxcontext.AdminCtx)
|
func TestGetVendorCategories(t *testing.T) {
|
||||||
// if err != nil {
|
result, err := new(PurchaseHandler).GetVendorCategories(jxcontext.AdminCtx)
|
||||||
// t.Fatal(err)
|
if err != nil {
|
||||||
// }
|
t.Fatal(err)
|
||||||
// for _, v := range result {
|
}
|
||||||
// data := model.SkuVendorCategory{
|
for _, v := range result {
|
||||||
// ModelIDCUL: model.ModelIDCUL{
|
data := model.SkuVendorCategory{
|
||||||
// CreatedAt: time.Now(),
|
ModelIDCUL: model.ModelIDCUL{
|
||||||
// UpdatedAt: time.Now(),
|
CreatedAt: time.Now(),
|
||||||
// LastOperator: "刘磊",
|
UpdatedAt: time.Now(),
|
||||||
// },
|
LastOperator: "刘磊",
|
||||||
// VendorCategoryID: v.VendorCategoryID,
|
},
|
||||||
// VendorID: v.VendorID,
|
VendorCategoryID: v.VendorCategoryID,
|
||||||
// Name: v.Name,
|
VendorID: v.VendorID,
|
||||||
// IsLeaf: v.IsLeaf,
|
Name: v.Name,
|
||||||
// Level: v.Level,
|
IsLeaf: v.IsLeaf,
|
||||||
// ParentID: v.ParentID,
|
Level: v.Level,
|
||||||
// }
|
ParentID: v.ParentID,
|
||||||
// if err := dao.CreateEntity(dao.GetDB(), &data); err != nil {
|
}
|
||||||
// t.Log(utils.Format4Output(err, false))
|
if err := dao.CreateEntity(dao.GetDB(), &data); err != nil {
|
||||||
// }
|
t.Log(utils.Format4Output(err, false))
|
||||||
// }
|
}
|
||||||
// t.Log(utils.Format4Output(result, false))
|
}
|
||||||
//}
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|||||||
@@ -74,7 +74,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: storeDetail.VendorStoreID,
|
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)),
|
||||||
Province: storeDetail.ProvinceName,
|
Province: storeDetail.ProvinceName,
|
||||||
|
|||||||
Reference in New Issue
Block a user