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