- prevent modify promotion store sku. lack callback handler
This commit is contained in:
32
business/jxutils/storeskulock/storeskulock.go
Normal file
32
business/jxutils/storeskulock/storeskulock.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package storeskulock
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
const (
|
||||
cacheKeyPrefix = "jdpromotion"
|
||||
)
|
||||
|
||||
func LockJdStoreSku(storeID, skuID int, expire time.Time) {
|
||||
globals.SugarLogger.Debug(expire, " ", time.Now())
|
||||
duration := expire.Sub(time.Now())
|
||||
if duration > 0 {
|
||||
globals.Cacher.Set(genCacheKey(storeID, skuID), 1, duration)
|
||||
}
|
||||
}
|
||||
|
||||
func UnlockJdStoreSku(storeID, skuID int) {
|
||||
globals.Cacher.Del(genCacheKey(storeID, skuID))
|
||||
}
|
||||
|
||||
func IsJdStoreSkuLocked(storeID, skuID int) bool {
|
||||
return globals.Cacher.Get(genCacheKey(storeID, skuID)) != nil
|
||||
}
|
||||
|
||||
func genCacheKey(storeID, skuID int) string {
|
||||
return fmt.Sprintf("%s.%d.%d", cacheKeyPrefix, storeID, skuID)
|
||||
}
|
||||
Reference in New Issue
Block a user