- first edition of weimob wsc.
This commit is contained in:
@@ -167,13 +167,12 @@ func InitSkuName(ctx *jxcontext.Context, isForce, isAsync, isContinueWhenError b
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func InitVendorCategory(ctx *jxcontext.Context) (num int64, err error) {
|
||||
if handler, ok := partner.PurchasePlatformHandlers[model.VendorIDMTWM].(*mtwm.PurchaseHandler); ok {
|
||||
func InitVendorCategory(ctx *jxcontext.Context, vendorID int) (num int64, err error) {
|
||||
if handler, ok := partner.PurchasePlatformHandlers[vendorID].(*mtwm.PurchaseHandler); ok {
|
||||
cats, err2 := handler.GetVendorCategories()
|
||||
if err2 != nil {
|
||||
return num, err2
|
||||
}
|
||||
|
||||
db := dao.GetDB()
|
||||
dao.Begin(db)
|
||||
defer dao.Rollback(db)
|
||||
@@ -182,7 +181,7 @@ func InitVendorCategory(ctx *jxcontext.Context) (num int64, err error) {
|
||||
FROM sku_vendor_category
|
||||
WHERE vendor_id = ?
|
||||
`
|
||||
if _, err = dao.ExecuteSQL(db, sql, model.VendorIDMTWM); err != nil {
|
||||
if _, err = dao.ExecuteSQL(db, sql, vendorID); err != nil {
|
||||
return num, err
|
||||
}
|
||||
for _, cat := range cats {
|
||||
@@ -445,3 +444,28 @@ func Change2JDSPU4Store(ctx *jxcontext.Context, storeIDs []int, step int, isAsyn
|
||||
hint, err = cms.CurVendorSync.SyncStoresSkus(ctx, db, []int{model.VendorIDJD}, storeIDs, skuIDs, isAsync, isContinueWhenError)
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func UploadWeimobImg4SkuName(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
db := dao.GetDB()
|
||||
skuNameList, err := dao.GetSkuNames(db)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
rootTask := tasksch.NewParallelTask("UploadWeimobImg4SkuName", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError).SetParallelCount(5), ctx.GetUserName(), func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
skuName := batchItemList[0].(*model.SkuName)
|
||||
if skuName.Img != "" && skuName.ImgWeimob == "" {
|
||||
if skuName.ImgWeimob, err = api.WeimobAPI.UploadImgByURL(skuName.Img, ""); err == nil {
|
||||
_, err = dao.UpdateEntity(db, skuName)
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}, skuNameList)
|
||||
tasksch.ManageTask(rootTask).Run()
|
||||
|
||||
if !isAsync {
|
||||
_, err = rootTask.GetResult(0)
|
||||
} else {
|
||||
hint = rootTask.ID
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user