From 9aba03a6dc288aa340cdd9b40ee84f8ee3021845 Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 4 Feb 2020 10:46:16 +0800 Subject: [PATCH] SetStoresMapSyncStatus --- business/jxstore/cms/store.go | 2 +- business/jxstore/misc/misc.go | 1 + business/model/dao/store.go | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 80c8d4c16..299c5f439 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -1167,7 +1167,7 @@ func UpdateStoreVendorMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendor } } // 暂时不开放isSync - if payload["isSync"] != nil { + if isSync, ok := payload["isSync"].(int); ok && isSync == 0 { delete(payload, "isSync") } if db == nil { diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 9236e3463..c3890bf17 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -232,6 +232,7 @@ func doDailyWork() { cms.SyncStoresCourierInfo(jxcontext.AdminCtx, nil, false, true) netprinter.RebindAllPrinters(jxcontext.AdminCtx, false, true) + dao.SetStoresMapSyncStatus(dao.GetDB(), nil, nil, model.SyncFlagStoreStatus) cms.CurVendorSync.SyncStore2(jxcontext.AdminCtx, dao.GetDB(), nil, nil, true, true) syncStoreSku() diff --git a/business/model/dao/store.go b/business/model/dao/store.go index 3d6e42a8b..f028fd855 100644 --- a/business/model/dao/store.go +++ b/business/model/dao/store.go @@ -256,6 +256,30 @@ func GetStoresMapList2(db *DaoDB, vendorIDs, storeIDs, storeStatuss []int, statu return nil, err } +func SetStoresMapSyncStatus(db *DaoDB, vendorIDs, storeIDs []int, syncStatus int8) (err error) { + sql := ` + UPDATE store_map t1 + JOIN store t2 ON t2.id = t1.store_id AND t2.deleted_at = ? + SET t1.sync_status = t1.sync_status | ? + WHERE t1.deleted_at = ? + ` + sqlParams := []interface{}{ + syncStatus, + utils.DefaultTimeValue, + utils.DefaultTimeValue, + } + if len(vendorIDs) > 0 { + sql += " AND t1.vendor_id IN (" + GenQuestionMarks(len(vendorIDs)) + ")" + sqlParams = append(sqlParams, vendorIDs) + } + if len(storeIDs) > 0 { + sql += " AND t1.store_id IN (" + GenQuestionMarks(len(storeIDs)) + ")" + sqlParams = append(sqlParams, storeIDs) + } + _, err = ExecuteSQL(db, sql, sqlParams...) + return err +} + func GetStoresMapList(db *DaoDB, vendorIDs, storeIDs, storeStatuss []int, status, isSync int, pricePack string) (storeMapList []*model.StoreMap, err error) { return GetStoresMapList2(db, vendorIDs, storeIDs, storeStatuss, status, isSync, pricePack, false) }