Merge remote-tracking branch 'origin/mark' into yonghui

This commit is contained in:
苏尹岚
2019-12-11 13:46:41 +08:00
6 changed files with 35 additions and 18 deletions

View File

@@ -345,10 +345,17 @@ func GetSkuNames(ctx *jxcontext.Context, keyword string, isBySku bool, params ma
keywordLike := "%" + keyword + "%"
sql += " AND (t1.name LIKE ? OR t1.prefix LIKE ? OR t2.comment LIKE ? OR t1.upc LIKE ?"
sqlParams = append(sqlParams, keywordLike, keywordLike, keywordLike, keywordLike)
if globals.IsUseThingMap {
sql += " OR (SELECT COUNT(*) FROM thing_map tm WHERE tm.vendor_thing_id LIKE ? AND tm.thing_type = ? AND tm.thing_id = t2.id AND tm.deleted_at = ?) > 0"
sqlParams = append(sqlParams, keywordLike, model.ThingTypeSku, utils.DefaultTimeValue)
}
if keywordInt64, err2 := strconv.ParseInt(keyword, 10, 64); err2 == nil {
sql += " OR t1.id = ? OR t2.id = ? OR t2.jd_id = ? OR t1.category_id = ?"
sqlParams = append(sqlParams, keywordInt64, keywordInt64, keywordInt64, keywordInt64)
sql += " OR t1.id = ? OR t2.id = ? OR t1.category_id = ?"
sqlParams = append(sqlParams, keywordInt64, keywordInt64, keywordInt64)
if !globals.IsUseThingMap {
sql += " OR t2.jd_id = ?"
sqlParams = append(sqlParams, keywordInt64)
}
}
sql += ")"
}

View File

@@ -266,10 +266,6 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool
}
sql += ")"
}
// if params["jdID"] != nil {
// sql += " AND t1.jd_id = ?"
// sqlParams = append(sqlParams, params["jdID"].(int))
// }
if params["name"] != nil {
sql += " AND t1.name LIKE ?"
sqlParams = append(sqlParams, "%"+params["name"].(string)+"%")
@@ -314,7 +310,11 @@ func getGetStoresSkusBaseSQL(db *dao.DaoDB, storeIDs, skuIDs []int, isFocus bool
}
sql += " AND ( 1 = 0"
if params["jdSyncStatus"] != nil && realVendorMap[model.VendorIDJD] == 1 {
sql += " OR (t4.jd_sync_status & ? <> 0 AND t2.jd_id <> 0 AND t1.status = ? AND t2.status = ?)"
if globals.IsUseThingMap {
sql += " OR (t4.jd_sync_status & ? <> 0 AND t1.status = ? AND t2.status = ?)"
} else {
sql += " OR (t4.jd_sync_status & ? <> 0 AND t2.jd_id <> 0 AND t1.status = ? AND t2.status = ?)"
}
sqlParams = append(sqlParams, params["jdSyncStatus"], model.SkuStatusNormal, model.SkuStatusNormal)
}
if params["ebaiSyncStatus"] != nil && realVendorMap[model.VendorIDEBAI] == 1 {

View File

@@ -657,6 +657,13 @@ func isSyncError(err error) bool {
}
func (v *VendorSync) SyncSkuNames(ctx *jxcontext.Context, nameIDs []int, isForce, isAsync, isContinueWhenError bool) (hint string, err error) {
if !globals.IsUseThingMap {
return v.oldSyncSkuNames(ctx, nameIDs, isForce, isAsync, isContinueWhenError)
}
return SyncSkus(ctx, nil, nil, nil, nameIDs, nil, isAsync)
}
func (v *VendorSync) oldSyncSkuNames(ctx *jxcontext.Context, nameIDs []int, isForce, isAsync, isContinueWhenError bool) (hint string, err error) {
db := dao.GetDB()
if isForce {
sql := `