商品详情描述图片加入DataResource管理,老数据还未迁移

This commit is contained in:
gazebo
2019-09-26 20:55:08 +08:00
parent 998c087d9f
commit 8a1d364e4e
15 changed files with 141 additions and 80 deletions

View File

@@ -1,6 +1,8 @@
package ebai
import (
"sync"
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
@@ -18,6 +20,9 @@ var (
type PurchaseHandler struct {
partner.BasePurchasePlatform
putils.DefSingleStorePlatform
shopList []*ebaiapi.ShopInfo
locker sync.RWMutex
}
func init() {
@@ -44,16 +49,60 @@ func (p *PurchaseHandler) GetVendorID() int {
return model.VendorIDEBAI
}
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string) (imgHint string, err error) {
globals.SugarLogger.Debugf("ebai UploadImg imgURL:%s, imgName:%s", imgURL, imgName)
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string, imgType int) (imgHint string, err error) {
globals.SugarLogger.Debugf("ebai UploadImg imgURL:%s, imgName:%s, imgType:%d", imgURL, imgName, imgType)
if globals.EnableEbaiStoreWrite {
imgHint, err = api.EbaiAPI.PictureUpload(imgURL, imgData)
if imgType == model.ImgTypeMain {
imgHint, err = api.EbaiAPI.PictureUpload(imgURL, imgData)
} else if imgType == model.ImgTypeMain {
imgHint, err = api.EbaiAPI.SkuUploadRTF(p.getShopID4UploadRTF(), ebaiapi.BuildRFTFromImgs(imgURL))
}
} else {
imgHint = imgURL + ".ebai"
}
return imgHint, err
}
func getShopIDFromList(shopList []*ebaiapi.ShopInfo) (shopID string) {
if len(shopList) > 0 {
shopID = shopList[0].ShopID
}
return shopID
}
func (p *PurchaseHandler) getShopID4UploadRTF() (shopID string) {
var shopList []*ebaiapi.ShopInfo
p.locker.RLock()
shopList = p.shopList
p.locker.RUnlock()
if len(shopList) > 0 {
return getShopIDFromList(shopList)
}
p.locker.Lock()
shopList = p.shopList
if len(shopList) > 0 {
p.locker.Unlock()
return getShopIDFromList(shopList)
}
defer p.locker.Unlock()
shopList, err := api.EbaiAPI.ShopList(ebaiapi.SysStatusAll)
if err == nil {
if len(shopList) > 0 {
p.shopList = shopList
shopID = getShopIDFromList(shopList)
} else {
// p.shopList = []*ebaiapi.ShopInfo{
// &ebaiapi.ShopInfo{
// ShopID: "",
// },
// }
}
}
return shopID
}
func (p *PurchaseHandler) getVendorCategories(level int, pid int64) (vendorCats []*model.SkuVendorCategory, err error) {
cats, err := api.EbaiAPI.SkuCategoryList("", level, pid)
if err != nil {