- first edition of weimob wsc.
This commit is contained in:
59
business/partner/purchase/weimob/wsc/wsc.go
Normal file
59
business/partner/purchase/weimob/wsc/wsc.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package wsc
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
var (
|
||||
curPurchaseHandler *PurchaseHandler
|
||||
)
|
||||
|
||||
type PurchaseHandler struct {
|
||||
partner.BasePurchasePlatform
|
||||
}
|
||||
|
||||
func init() {
|
||||
curPurchaseHandler = new(PurchaseHandler)
|
||||
partner.RegisterPurchasePlatform(curPurchaseHandler)
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetVendorID() int {
|
||||
return model.VendorIDWSC
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetVendorCategories() (vendorCats []*model.SkuVendorCategory, err error) {
|
||||
rootCats, err := api.WeimobAPI.QueryCategoryTree()
|
||||
catList := rootCats
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, v := range rootCats {
|
||||
cats, err := api.WeimobAPI.QueryChildrenCategory(v.CategoryID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
catList = append(catList, cats...)
|
||||
}
|
||||
vendorCats = make([]*model.SkuVendorCategory, len(catList))
|
||||
for k, v := range catList {
|
||||
vendorCats[k] = &model.SkuVendorCategory{
|
||||
VendorCategoryID: vendorCategoryID2String(v.CategoryID),
|
||||
VendorID: model.VendorIDWSC,
|
||||
Name: v.Title,
|
||||
IsLeaf: int8(v.Level - 1),
|
||||
Level: v.Level,
|
||||
ParentID: vendorCategoryID2String(v.ParentID),
|
||||
}
|
||||
}
|
||||
return vendorCats, nil
|
||||
}
|
||||
|
||||
func vendorCategoryID2String(catID int64) string {
|
||||
if catID > 0 {
|
||||
return utils.Int64ToStr(catID)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
Reference in New Issue
Block a user