商品详情描述图片加入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

@@ -151,7 +151,7 @@ type IPurchasePlatformHandler interface {
RefreshAllStoresID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error)
UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string) (imgHint string, err error)
UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string, imgType int) (imgHint string, err error)
}
// db *dao.DaoDB,

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 {

View File

@@ -92,7 +92,7 @@ func (c *PurchaseHandler) OnCallbackMsg(msg *elmapi.CallbackMsg) (retVal *elmapi
return retVal
}
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string) (imgHint string, err error) {
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string, imgType int) (imgHint string, err error) {
return imgHint, err
}

View File

@@ -59,6 +59,6 @@ func JxStoreStatus2JdStatus(status int) (yn, closeStatus int) {
}
}
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string) (imgHint string, err error) {
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string, imgType int) (imgHint string, err error) {
return imgHint, err
}

View File

@@ -29,6 +29,6 @@ func (c *PurchaseHandler) GetVendorID() int {
return model.VendorIDJX
}
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string) (imgHint string, err error) {
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string, imgType int) (imgHint string, err error) {
return imgHint, err
}

View File

@@ -166,17 +166,19 @@ func skuStatusJX2Mtwm(status int) int {
return mtwmapi.SellStatusOffline
}
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string) (imgHint string, err error) {
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string, imgType int) (imgHint string, err error) {
globals.SugarLogger.Debugf("mtwm UploadImg imgURL:%s, imgName:%s", imgURL, imgName)
poiCode4UploadImg := p.getUploadImgPoiCode()
if poiCode4UploadImg == "" {
return "", fmt.Errorf("找不到一个美团门店来上传图片")
}
if globals.EnableMtwmStoreWrite {
if imgData != nil {
imgHint, err = api.MtwmAPI.ImageUpload(poiCode4UploadImg, imgName, imgData)
} else {
imgHint, err = api.MtwmAPI.ImageUploadByURL(poiCode4UploadImg, imgName, imgURL)
if imgType > 0 {
if imgData != nil {
imgHint, err = api.MtwmAPI.ImageUpload(poiCode4UploadImg, imgName, imgData)
} else {
imgHint, err = api.MtwmAPI.ImageUploadByURL(poiCode4UploadImg, imgName, imgURL)
}
}
} else {
imgHint = utils.GetUpperUUID()

View File

@@ -68,7 +68,7 @@ func vendorCategoryID2String(catID int64) string {
return ""
}
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string) (imgHint string, err error) {
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string, imgType int) (imgHint string, err error) {
if globals.EnableWscStoreWrite {
imgHint, err = api.WeimobAPI.UploadImg(imgData, imgName)
}