- 将skuName中的图片外移至dataResource
This commit is contained in:
@@ -45,8 +45,11 @@ func (p *PurchaseHandler) GetVendorID() int {
|
||||
}
|
||||
|
||||
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)
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
imgHint, err = api.EbaiAPI.PictureUpload(imgURL, imgData)
|
||||
} else {
|
||||
imgHint = imgURL + ".ebai"
|
||||
}
|
||||
return imgHint, err
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package mtwm
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -11,6 +12,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/putils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
@@ -21,6 +23,9 @@ var (
|
||||
type PurchaseHandler struct {
|
||||
partner.BasePurchasePlatform
|
||||
putils.DefSingleStorePlatform
|
||||
|
||||
poiCode4UploadImg string
|
||||
locker sync.RWMutex
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -162,5 +167,43 @@ func skuStatusJX2Mtwm(status int) int {
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) UploadImg(ctx *jxcontext.Context, imgURL string, imgData []byte, imgName string) (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)
|
||||
}
|
||||
} else {
|
||||
imgHint = utils.GetUpperUUID()
|
||||
}
|
||||
return imgHint, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) getUploadImgPoiCode() (poiCode string) {
|
||||
p.locker.RLock()
|
||||
poiCode = p.poiCode4UploadImg
|
||||
p.locker.RUnlock()
|
||||
if poiCode != "" {
|
||||
return poiCode
|
||||
}
|
||||
|
||||
p.locker.Lock()
|
||||
poiCode = p.poiCode4UploadImg
|
||||
if poiCode != "" {
|
||||
p.locker.Unlock()
|
||||
return poiCode
|
||||
}
|
||||
|
||||
defer p.locker.Unlock()
|
||||
storeIDs, err := api.MtwmAPI.PoiGetIDs()
|
||||
if err == nil && len(storeIDs) > 0 {
|
||||
poiCode = storeIDs[0]
|
||||
}
|
||||
p.poiCode4UploadImg = poiCode
|
||||
return poiCode
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user