- 饿百图片库管理
This commit is contained in:
@@ -463,6 +463,12 @@ func AddSkuName(ctx *jxcontext.Context, skuNameExt *model.SkuNameExt, userName s
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
if skuNameExt.ImgEbai, err = api.EbaiAPI.PictureUpload(skuNameExt.Img, nil); err != nil {
|
||||
dao.Rollback(db)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if skuNameExt.ImgHashCode == "" {
|
||||
skuNameExt.ImgHashCode = imgMD5
|
||||
} else if skuNameExt.ImgHashCode != imgMD5 {
|
||||
@@ -536,6 +542,11 @@ func UpdateSkuName(ctx *jxcontext.Context, nameID int, payload map[string]interf
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
if valid["ImgEbai"], err = api.EbaiAPI.PictureUpload(valid["img"].(string), nil); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
}
|
||||
if num, err = dao.UpdateEntityLogicallyAndUpdateSyncStatus(db, skuName, valid, userName, nil, model.FieldJdSyncStatus, model.SyncFlagModifiedMask); err == nil && num == 1 {
|
||||
if utils.Interface2Int64WithDefault(payload["isGlobal"], 0) == 0 && payload["places"] != nil {
|
||||
|
||||
@@ -230,6 +230,33 @@ func UploadWeimobImg4SkuName(ctx *jxcontext.Context, nameIDs []int, isAsync, isC
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func UploadEbaiImg4SkuName(ctx *jxcontext.Context, nameIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
db := dao.GetDB()
|
||||
skuNameList, err := dao.GetSkuNames(db, nameIDs)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
rootTask := tasksch.NewParallelTask("UploadEbaiImg4SkuName", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError).SetParallelCount(5), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
skuName := batchItemList[0].(*model.SkuName)
|
||||
if skuName.Img != "" && skuName.ImgEbai == "" {
|
||||
if globals.EnableEbaiStoreWrite {
|
||||
if skuName.ImgEbai, err = api.EbaiAPI.PictureUpload(skuName.Img, nil); err == nil {
|
||||
_, err = dao.UpdateEntity(db, skuName, "ImgEbai")
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}, skuNameList)
|
||||
tasksch.ManageTask(rootTask).Run()
|
||||
if !isAsync {
|
||||
_, err = rootTask.GetResult(0)
|
||||
} else {
|
||||
hint = rootTask.ID
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func getSkuNameKey(prefix, name, comment, specUnit, unit string, specQuality float32) string {
|
||||
return fmt.Sprintf("%s-%s-%f-%s-%s", prefix, name, specQuality, specUnit, unit)
|
||||
}
|
||||
|
||||
@@ -169,6 +169,7 @@ type SkuName struct {
|
||||
Price int `json:"price"` // 单位为分,标准价,不为份的就为实际标准价,为份的为每市斤价,实际还要乘质量。todo 为份的确定必须有质量
|
||||
Img string `orm:"size(255)" json:"img"`
|
||||
ImgWeimob string `orm:"size(255)" json:"imgWeimob"` // 微盟图片地址
|
||||
ImgEbai string `orm:"size(255)" json:"imgEbai"` // 饿百图片地址
|
||||
ImgHashCode string `orm:"size(255);index" json:"img_hash_code"`
|
||||
ElmImgHashCode string `orm:"size(255)" json:"-"` // 长度255的原因是从京东初始化数据时临时需要
|
||||
Upc string `orm:"size(20)"`
|
||||
|
||||
@@ -78,7 +78,7 @@ var (
|
||||
func (p *PurchaseHandler) getDirtyStoreSkus(db *dao.DaoDB, storeID int, skuIDs []int) (storeSkuInfoList []*tStoreSkuFullInfo, err error) {
|
||||
sql := `
|
||||
SELECT t8.price_percentage, t1.*, t2.spec_quality, t2.spec_unit, t2.weight, t2.status sku_status,
|
||||
t3.prefix, t3.name, t2.comment, t3.is_global, t3.unit, t3.img, t3.upc,
|
||||
t3.prefix, t3.name, t2.comment, t3.is_global, t3.unit, IF(t3.img_ebai <> '', t3.img_ebai, t3.img) img, t3.upc,
|
||||
t4.name cat_name,
|
||||
t4.id cat_id, t4.level cat_level, t5.ebai_id cat_ebai_id,
|
||||
t4p.id parent_cat_id, t5p.ebai_id parent_cat_ebai_id, t5p.ebai_sync_status parent_cat_ebai_sync_status,
|
||||
|
||||
Reference in New Issue
Block a user