- prevent modify promotion sku

This commit is contained in:
gazebo
2018-11-06 16:10:23 +08:00
parent ae267dcdbe
commit e0cf85ebb6
4 changed files with 74 additions and 20 deletions

View File

@@ -11,22 +11,22 @@ const (
cacheKeyPrefix = "jdpromotion"
)
func LockJdStoreSku(storeID, skuID int, expire time.Time) {
func LockJdStoreSku(jdStoreID string, jdSkuID int64, 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)
globals.Cacher.Set(genCacheKey(jdStoreID, jdSkuID), 1, duration)
}
}
func UnlockJdStoreSku(storeID, skuID int) {
globals.Cacher.Del(genCacheKey(storeID, skuID))
func UnlockJdStoreSku(jdStoreID string, jdSkuID int64) {
globals.Cacher.Del(genCacheKey(jdStoreID, jdSkuID))
}
func IsJdStoreSkuLocked(storeID, skuID int) bool {
return globals.Cacher.Get(genCacheKey(storeID, skuID)) != nil
func IsJdStoreSkuLocked(jdStoreID string, jdSkuID int64) bool {
return globals.Cacher.Get(genCacheKey(jdStoreID, jdSkuID)) != nil
}
func genCacheKey(storeID, skuID int) string {
return fmt.Sprintf("%s.%d.%d", cacheKeyPrefix, storeID, skuID)
func genCacheKey(jdStoreID string, jdSkuID int64) string {
return fmt.Sprintf("%s.%s.%d", cacheKeyPrefix, jdStoreID, jdSkuID)
}