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++ {