|
@@ -39,6 +39,15 @@ func (BP *JyActivity) Questionnaire(userId, phone, answers string) error {
|
|
|
if inActivity, _, _ := BP.InActivity(); !inActivity {
|
|
|
return fmt.Errorf("不在活动时间内")
|
|
|
}
|
|
|
+ cacheKey := fmt.Sprintf(PowerCacheKey, userId)
|
|
|
+ if bytes, err := redis.GetBytes(PowerCacheDb, cacheKey); err == nil && bytes != nil {
|
|
|
+ userPower := &BigVipBaseMsg{}
|
|
|
+ if err := json.Unmarshal(*bytes, &userPower); err == nil {
|
|
|
+ if userPower.EntIsNew || userPower.Status > 0 && userPower.VipStatus > 0 {
|
|
|
+ return fmt.Errorf("当前用户不符合领取条件")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//保存问卷
|
|
|
if ok := award.SaveQuestionnaire(userId, phone, answers); ok {
|
|
|
if redis.Put(BidderPlanRedis, fmt.Sprintf(QuestionnaireSubmit, userId), "qs", BP.cacheLong()) != true {
|
|
@@ -78,12 +87,14 @@ func (BP *JyActivity) GetDailyBoonDetail(userId string) (has bool, todayBalance
|
|
|
//查询是否领取
|
|
|
hasKey := fmt.Sprintf(BidderPlanHasDailyBoonKey, userId)
|
|
|
has = redis.GetInt(BidderPlanRedis, hasKey) >= 1
|
|
|
+ ActivityLock.Lock()
|
|
|
//查询剩余
|
|
|
todaySumKey := fmt.Sprintf(BidderPlanDailyBoonKey, time.Now().Format(dataUtil.Date_yyyyMMdd))
|
|
|
todayBalance = gcfg.Instance().MustGet(gctx.New(), "jyactivity.dailyBoon.reward.limit", 500).Int() - redis.GetInt(BidderPlanRedis, todaySumKey)
|
|
|
if todayBalance < 0 {
|
|
|
todayBalance = 0
|
|
|
}
|
|
|
+ ActivityLock.Unlock()
|
|
|
// 注册时间也在活动允许范围内
|
|
|
registerBool = true
|
|
|
//是否有权限领取
|
|
@@ -133,11 +144,13 @@ func (BP *JyActivity) GetDailyBoonSVip(userId string) (err error) {
|
|
|
err = func() error {
|
|
|
hasKey := fmt.Sprintf(BidderPlanHasDailyBoonKey, userId)
|
|
|
if redis.Incr(BidderPlanRedis, hasKey) == 1 {
|
|
|
+ ActivityLock.Lock()
|
|
|
todaySumKey := fmt.Sprintf(BidderPlanDailyBoonKey, time.Now().Format(dataUtil.Date_yyyyMMdd))
|
|
|
balance := redis.Incr(BidderPlanRedis, todaySumKey)
|
|
|
if balance > gcfg.Instance().MustGet(gctx.New(), "jyactivity.dailyBoon.reward.limit", 500).Int64() {
|
|
|
return fmt.Errorf("剩余为零")
|
|
|
}
|
|
|
+ ActivityLock.Unlock()
|
|
|
if err := award.GivenSubVip(userId, award.SubVip{
|
|
|
Num: gcfg.Instance().MustGet(gctx.New(), "jyactivity.dailyBoon.reward.svip", nil).Int64(),
|
|
|
ActivityCode: BP.ActivityCode,
|