From 076e2eee01f59677018d7bc91dbf1939b0163af5 Mon Sep 17 00:00:00 2001 From: chenweijian <820961417@qq.com> Date: Thu, 4 May 2023 11:55:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _const/rediskey/key.go | 4 ++++ _const/rediskey/key_func.go | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/_const/rediskey/key.go b/_const/rediskey/key.go index 13fc9a0..2bd5757 100644 --- a/_const/rediskey/key.go +++ b/_const/rediskey/key.go @@ -38,4 +38,8 @@ const ( // 开斋节活动 OpenRamadanSendGiftLeftDiamond = "act:openRamadan:diamond:%d:%d" // 开斋节活动,剩余还没转换成积分的送礼钻石,活动id:用户id + ResCountry = "res:country" // 国家列表 + + // 定时任务的互斥锁 + cronLock = "cronLock:{subKey}" ) diff --git a/_const/rediskey/key_func.go b/_const/rediskey/key_func.go index c452f7c..b704c10 100644 --- a/_const/rediskey/key_func.go +++ b/_const/rediskey/key_func.go @@ -3,6 +3,7 @@ package rediskey import ( "fmt" "git.hilo.cn/hilo-common/utils" + "strings" "time" ) @@ -57,3 +58,27 @@ func GetActChargeDiamond(userId, actId uint64) string { } return fmt.Sprintf(ActChargeDiamond, time.Now().Format(utils.DATE_FORMAT), userId) } + +func GetActChargeGetPoint(userId, actId uint64, dollar int64) string { + if actId > 500 { + return fmt.Sprintf(ActIdChargeGetPoint, actId, time.Now().Format(utils.DATE_FORMAT), dollar, userId) + } + return fmt.Sprintf(ActChargeGetPoint, time.Now().Format(utils.DATE_FORMAT), dollar, userId) +} + +func GetMonthChargeTimes(userId uint64) string { + var cstZone = time.FixedZone("CST", 3*3600) // 东三区,沙特时间 + return fmt.Sprintf(MonthChargeTimes, time.Now().In(cstZone).Format(utils.MONTH_FORMAT), userId) +} + +func GetRamadanDailyTaskGet(actId, userId uint64, nowTime time.Time) string { + return fmt.Sprintf(RamadanDailyTaskGet, nowTime.Format(utils.DATE_FORMAT), actId, userId) +} + +func GetRamadanGetDailyLottery(actId, userId uint64) string { + return fmt.Sprintf(RamadanGetDailyLottery, time.Now().Format(utils.DATE_FORMAT), actId, userId) +} + +func GetCronLockKey(subKey string) string { + return strings.Replace(cronLock, "{subKey}", subKey, -1) +} -- 2.22.0