aa
This commit is contained in:
@@ -2935,21 +2935,28 @@ func LoadStoreVendorCategories(ctx *jxcontext.Context, vendorOrgCode string, ven
|
||||
return err
|
||||
}
|
||||
|
||||
func RefreshNoImgSku(ctx *jxcontext.Context) (err error) {
|
||||
func RefreshNoImgSku(ctx *jxcontext.Context, skuNameID int) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
skuNames []*model.SkuName
|
||||
)
|
||||
sql := `
|
||||
SELECT * FROM sku_name WHERE deleted_at = ? AND upc <> '' AND img2 = ''
|
||||
SELECT * FROM sku_name WHERE deleted_at = ? AND upc <> '' AND img <> ''
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
utils.DefaultTimeValue,
|
||||
}
|
||||
if skuNameID > 0 {
|
||||
sql += " AND id = ?"
|
||||
sqlParams = append(sqlParams, skuNameID)
|
||||
}
|
||||
|
||||
dao.GetRows(db, &skuNames, sql, sqlParams)
|
||||
task := tasksch.NewParallelTask("uuuuu", tasksch.NewParallelConfig().SetParallelCount(20).SetIsContinueWhenError(true), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
v := batchItemList[0].(*model.SkuName)
|
||||
data, _, _ := jxutils.DownloadFileByURL(v.Img)
|
||||
if string(data) == "" {
|
||||
if v.Upc != nil {
|
||||
productInfos, _ := api.JdAPI.GetJdUpcCodeByName("", *v.Upc, 1, 30)
|
||||
if len(productInfos) > 0 {
|
||||
@@ -2990,6 +2997,7 @@ func RefreshNoImgSku(ctx *jxcontext.Context) (err error) {
|
||||
}
|
||||
dao.UpdateEntity(db, v, "Img", "Img2", "Img3", "Img4", "Img5")
|
||||
}
|
||||
}
|
||||
return retVal, err
|
||||
}, skuNames)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
|
||||
@@ -687,11 +687,13 @@ func (c *SkuController) LoadStoreVendorCategories() {
|
||||
// @Title 刷新没图的商品
|
||||
// @Description 刷新没图的商品
|
||||
// @Param token header string true "认证token"
|
||||
// @Param skuNameID formData int false "门店ID"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /RefreshNoImgSku [post]
|
||||
func (c *SkuController) RefreshNoImgSku() {
|
||||
c.callRefreshNoImgSku(func(params *tSkuRefreshNoImgSkuParams) (retVal interface{}, errCode string, err error) {
|
||||
err = cms.RefreshNoImgSku(params.Ctx, params.SkuNameID)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user