From 2f9df63b1002759056d8188a4937ddfd396a89c4 Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 18 Dec 2019 12:25:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=85=E8=A6=81=E6=97=B6=E6=B8=85=E9=99=A4?= =?UTF-8?q?=E9=97=A8=E5=BA=97=E5=95=86=E5=93=81=E4=BB=B7=E6=A0=BC=E9=94=81?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/sync_store_sku.go | 9 ++++++++- business/model/dao/dao_utils.go | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/business/jxstore/cms/sync_store_sku.go b/business/jxstore/cms/sync_store_sku.go index 8d18508e9..a0619c139 100644 --- a/business/jxstore/cms/sync_store_sku.go +++ b/business/jxstore/cms/sync_store_sku.go @@ -235,6 +235,9 @@ func formalizeStoreSkuList(inSkuList []*dao.StoreSkuSyncInfo) []*dao.StoreSkuSyn func sku2Update(vendorID int, sku *dao.StoreSkuSyncInfo, syncStatus int8) (item *dao.KVUpdateItem) { kvs := map[string]interface{}{} + if !isSkuLockTimeValid(sku) { + kvs[dao.GetVendorLockTimeStructField(model.VendorNames[vendorID])] = nil + } if syncStatus&(model.SyncFlagDeletedMask|model.SyncFlagNewMask|model.SyncFlagModifiedMask) != 0 { if model.IsSyncStatusNew(syncStatus) { sku.SkuSyncStatus = 0 @@ -289,6 +292,10 @@ func updateStoreSku(db *dao.DaoDB, vendorID int, storeSkuList []*dao.StoreSkuSyn return num, err } +func isSkuLockTimeValid(sku *dao.StoreSkuSyncInfo) bool { + return sku.LockTime != nil && time.Now().Sub(*sku.LockTime) < 0 +} + func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bool, vendorID, storeID int, nameIDs, skuIDs, excludeSkuIDs []int, useVendorPriceDirectly, isContinueWhenError bool) (err error) { db := dao.GetDB() storeDetail, err := dao.GetStoreDetail(db, storeID, vendorID) @@ -336,7 +343,7 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bo now := jxutils.OperationTime2HourMinuteFormat(time.Now()) for _, sku := range skus { if !useVendorPriceDirectly && - (sku.LockTime == nil || time.Now().Sub(*sku.LockTime) > 0) { + !isSkuLockTimeValid(sku) { sku.VendorPrice = 0 } sku.MergedStatus = MergeSkuSaleStatusWithStoreOpTime(sku, storeDetail, now) diff --git a/business/model/dao/dao_utils.go b/business/model/dao/dao_utils.go index 8a36c2adc..eaca61326 100644 --- a/business/model/dao/dao_utils.go +++ b/business/model/dao/dao_utils.go @@ -160,6 +160,10 @@ func GetCategoryIDDBField(prefix string) string { return ConvertDBFieldPrefix(prefix) + "_category_id" } +func GetVendorLockTimeStructField(prefix string) string { + return ConvertStructFieldPrefix(prefix) + "LockTime" +} + func value2Value(srcValue, dstValue reflect.Value, copyType int) { srcType := srcValue.Type() for i := 0; i < srcType.NumField(); i++ {