|
@@ -11,6 +11,7 @@ import (
|
|
|
"rocommon/util"
|
|
"rocommon/util"
|
|
|
"roserver/baseserver/model"
|
|
"roserver/baseserver/model"
|
|
|
"roserver/serverproto"
|
|
"roserver/serverproto"
|
|
|
|
|
+ "strconv"
|
|
|
"strings"
|
|
"strings"
|
|
|
"time"
|
|
"time"
|
|
|
"unicode/utf8"
|
|
"unicode/utf8"
|
|
@@ -305,6 +306,7 @@ type RoleLogicOuter interface {
|
|
|
DaoChang100SetTips(tipDesc string)
|
|
DaoChang100SetTips(tipDesc string)
|
|
|
|
|
|
|
|
OnAntiCheatReq(cheatType int32)
|
|
OnAntiCheatReq(cheatType int32)
|
|
|
|
|
+ CodeRewardReq(code string)
|
|
|
GiftReward(ackMsg *serverproto.SCGiftRewardAck)
|
|
GiftReward(ackMsg *serverproto.SCGiftRewardAck)
|
|
|
|
|
|
|
|
//问卷奖励获取
|
|
//问卷奖励获取
|
|
@@ -4001,6 +4003,57 @@ func (this *Role) OnAntiCheatReq(cheatType int32) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const RoleCdkInfo = "cdk_info_"
|
|
|
|
|
+
|
|
|
|
|
+func (this *Role) CodeRewardReq(code string) {
|
|
|
|
|
+ res := &serverproto.SCGiftRewardAck{
|
|
|
|
|
+ Uuid: this.GetUUid(),
|
|
|
|
|
+ }
|
|
|
|
|
+ if _, ok := model.ConvertCdkRewardMap[code]; !ok {
|
|
|
|
|
+ res.Error = int32(serverproto.ErrorCode_ERROR_GIFT_CODE_NOT_FOUND)
|
|
|
|
|
+ this.ReplayGate(res, true)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ v := model.ConvertCdkRewardMap[code]
|
|
|
|
|
+ if v == nil {
|
|
|
|
|
+ util.ErrorF("uid:%v cdk get config is nil", this.GetUUid())
|
|
|
|
|
+ res.Error = int32(serverproto.ErrorCode_ERROR_FAIL)
|
|
|
|
|
+ this.ReplayGate(res, true)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ now := time.Now()
|
|
|
|
|
+ if now.Before(v.Start) || now.After(v.End) {
|
|
|
|
|
+ res.Error = int32(serverproto.ErrorCode_ERROR_GIFT_CODE_OUTDATE)
|
|
|
|
|
+ this.ReplayGate(res, true)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ key := RoleCdkInfo + strconv.FormatUint(this.GetUUid(), 10)
|
|
|
|
|
+ field := strconv.FormatInt(int64(v.Id), 10)
|
|
|
|
|
+ b, err := service.GetRedis().HExists(key, field).Result()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ util.ErrorF("uid:%v cdk get redis err:%v", this.GetUUid(), err)
|
|
|
|
|
+ res.Error = int32(serverproto.ErrorCode_ERROR_FAIL)
|
|
|
|
|
+ this.ReplayGate(res, true)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if b {
|
|
|
|
|
+ res.Error = int32(serverproto.ErrorCode_ERROR_GIFT_CODE_USED)
|
|
|
|
|
+ this.ReplayGate(res, true)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ res.RewardList = v.RewardList
|
|
|
|
|
+ _, er := service.GetRedis().HSet(key, field, "11").Result()
|
|
|
|
|
+ if er != nil {
|
|
|
|
|
+ util.ErrorF("uid:%v cdk set redis err:%v", this.GetUUid(), err)
|
|
|
|
|
+ res.Error = int32(serverproto.ErrorCode_ERROR_FAIL)
|
|
|
|
|
+ this.ReplayGate(res, true)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ this.GiftReward(res)
|
|
|
|
|
+ util.InfoF("uid:%v cdk get reward:%v", this.GetUUid(), res.RewardList)
|
|
|
|
|
+ this.ReplayGate(res, true)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func (this *Role) GiftReward(ackMsg *serverproto.SCGiftRewardAck) {
|
|
func (this *Role) GiftReward(ackMsg *serverproto.SCGiftRewardAck) {
|
|
|
if ackMsg == nil {
|
|
if ackMsg == nil {
|
|
|
return
|
|
return
|