diff --git a/domain/model/gift_m/gift.go b/domain/model/gift_m/gift.go index 6c7140314be89e11ad0c08ecbcf9c51f97b7b973..f3e5192545e4aeff23205922992388fc30a8d85d 100644 --- a/domain/model/gift_m/gift.go +++ b/domain/model/gift_m/gift.go @@ -128,39 +128,39 @@ func (g *GiftOperate) GetConsumeByRange(beginTime, endTime time.Time) (uint32, u return 0, 0, nil } - if beginTime.Unix() >= 1691337600 && beginTime.Unix() < 1691942400 { // 因为这周水果机被部分人刷币,所以这里做了特殊的处理 - reduceMap := map[string]uint64{ - "HTGS#a63226380": 20000000, - //"HTGS#a42641278": 10000000, - "@TGS#3ZZ5GZLHA": 27141539, - "HTGS#a81630128": 8955410, - "HTGS#a42300598": 50211301, - "HTGS#a40088696": 10000000, - "HTGS#a21700997": 14352310, - "HTGS#a83608384": 49644203, - "@TGS#33GDXTSIH": 50000000, - "HTGS#a50538513": 15000000, - "HTGS#a77282385": 15000000, - "HTGS#a59437326": 10000000, - "HTGS#a16909405": 10000000, - "HTGS#a44104431": 16861206, - "HTGS#a56794634": 59591313, - "HTGS#a11286025": 31232311, - "HTGS#a17238550": 52309338, - "HTGS#a83592361": 79545067, - "HTGS#a39882521": 10255093, - } - if reduceNum, ok := reduceMap[g.SceneUid]; ok { - if g.Log != nil { - g.Log.Infof("fruit diamond reduceMap,groupId:%v,reduceNum:%v", g.SceneUid, reduceNum) - } - if rows[0].Consume >= reduceNum { - rows[0].Consume -= reduceNum - } else { - rows[0].Consume = 0 - } - } - } + //if beginTime.Unix() >= 1691337600 && beginTime.Unix() < 1691942400 { // 因为这周水果机被部分人刷币,所以这里做了特殊的处理 + // reduceMap := map[string]uint64{ + // "HTGS#a63226380": 20000000, + // //"HTGS#a42641278": 10000000, + // "@TGS#3ZZ5GZLHA": 27141539, + // "HTGS#a81630128": 8955410, + // "HTGS#a42300598": 50211301, + // "HTGS#a40088696": 10000000, + // "HTGS#a21700997": 14352310, + // "HTGS#a83608384": 49644203, + // "@TGS#33GDXTSIH": 50000000, + // "HTGS#a50538513": 15000000, + // "HTGS#a77282385": 15000000, + // "HTGS#a59437326": 10000000, + // "HTGS#a16909405": 10000000, + // "HTGS#a44104431": 16861206, + // "HTGS#a56794634": 59591313, + // "HTGS#a11286025": 31232311, + // "HTGS#a17238550": 52309338, + // "HTGS#a83592361": 79545067, + // "HTGS#a39882521": 10255093, + // } + // if reduceNum, ok := reduceMap[g.SceneUid]; ok { + // if g.Log != nil { + // g.Log.Infof("fruit diamond reduceMap,groupId:%v,reduceNum:%v", g.SceneUid, reduceNum) + // } + // if rows[0].Consume >= reduceNum { + // rows[0].Consume -= reduceNum + // } else { + // rows[0].Consume = 0 + // } + // } + //} return rows[0].C, rows[0].Consume, nil } diff --git a/domain/service/group_s/group_support.go b/domain/service/group_s/group_support.go index 650b4fba0a34d0b221c810850059074fbd3641ba..5a5f37555bc1f02a75d50edde952db99b03d03b0 100644 --- a/domain/service/group_s/group_support.go +++ b/domain/service/group_s/group_support.go @@ -206,22 +206,12 @@ func (s *GroupService) GetSupportLevelByRedis(groupId string) (*res_m.ResGroupSu model := domain.CreateModel(s.svc.CtxAndDb) _, _, period := group_m.GetLastSupportPeriod(time.Now()) - // 流水 - keyDiamond := rediskey.GetGroupSupportConsumeSummary(period) - consume, err := model.RedisCluster.ZScore(context.Background(), keyDiamond, groupId).Result() - if err != nil { - model.Log.Errorf("GetSupportLevelByRedis key:%v, groupId:%v, err:%v", keyDiamond, groupId, err) - return nil, 0, err - } - // 支持者数量 - keySupportNum := rediskey.GetGroupSupportCountSupporter(period, groupId) - count, err := model.RedisCluster.SCard(context.Background(), keySupportNum).Result() + consume, count, err := GetGroupConsumeCount(model, groupId, period) if err != nil { - model.Log.Errorf("GetSupportLevelByRedis key:%v, groupId:%v, err:%v", keySupportNum, groupId, err) return nil, 0, err } - rec, err := res_m.GetResGroupSupportBy(model, uint32(count), uint64(consume)) + rec, err := res_m.GetResGroupSupportBy(model, count, consume) if err != nil { return nil, 0, err } @@ -231,6 +221,24 @@ func (s *GroupService) GetSupportLevelByRedis(groupId string) (*res_m.ResGroupSu return rec, 0, nil } +func GetGroupConsumeCount(model *domain.Model, imGroupId, period string) (uint64, uint32, error) { + // 流水 + keyDiamond := rediskey.GetGroupSupportConsumeSummary(period) + consume, err := model.RedisCluster.ZScore(context.Background(), keyDiamond, imGroupId).Result() + if err != nil { + model.Log.Errorf("GetSupportLevelByRedis key:%v, groupId:%v, err:%v", keyDiamond, imGroupId, err) + return 0, 0, err + } + // 支持者数量 + keySupportNum := rediskey.GetGroupSupportCountSupporter(period, imGroupId) + count, err := model.RedisCluster.SCard(context.Background(), keySupportNum).Result() + if err != nil { + model.Log.Errorf("GetSupportLevelByRedis key:%v, groupId:%v, err:%v", keySupportNum, imGroupId, err) + return 0, 0, err + } + return uint64(consume), uint32(count), nil +} + //群组支持奖励 func (s *GroupService) GroupSupportAward(groupId string, profitAllocator uint64, userIds []uint64, resSupport *res_m.ResGroupSupport, period string, groupInfo *group_m.GroupInfo) error { diff --git a/route/group_r/group_support.go b/route/group_r/group_support.go index 97c98bffa0b36c4889fa1e998574f170ccc6b9de..69fe8a6de9142620f6165ff00897e839ed590e18 100644 --- a/route/group_r/group_support.go +++ b/route/group_r/group_support.go @@ -6,13 +6,11 @@ import ( "git.hilo.cn/hilo-common/mycontext" "git.hilo.cn/hilo-common/resource/mysql" "github.com/gin-gonic/gin" - "hilo-group/_const/enum/gift_e" "hilo-group/_const/enum/group_e" "hilo-group/_const/enum/msg_e" "hilo-group/cv/group_cv" "hilo-group/cv/user_cv" "hilo-group/domain/cache/group_c" - "hilo-group/domain/model/gift_m" "hilo-group/domain/model/group_m" "hilo-group/domain/model/res_m" "hilo-group/domain/model/user_m" @@ -111,18 +109,28 @@ func GetSupportDetail(c *gin.Context) (*mycontext.MyContext, error) { result := group_cv.SupportPageDetail{GroupId: txGroupId} now := time.Now() - beginTime, endTime, _ := group_m.GetSupportLevelTime(now) + _, endTime, period := group_m.GetSupportLevelTime(now) result.RemainSecond = endTime.Unix() - now.Unix() - g := gift_m.GiftOperate{SceneType: gift_e.GroupSceneType, SceneUid: groupId, Model: model} - result.CurrentCount, result.CurrentConsume, err = g.GetConsumeByRange(beginTime, endTime) + //g := gift_m.GiftOperate{SceneType: gift_e.GroupSceneType, SceneUid: groupId, Model: model} + //result.CurrentCount, result.CurrentConsume, err = g.GetConsumeByRange(beginTime, endTime) + //if err != nil { + // return myContext, err + //} + result.CurrentConsume, result.CurrentCount, err = group_s.GetGroupConsumeCount(model, groupId, period) if err != nil { + model.Log.Errorf("GetSupportDetail groupId:%s, err:%v", groupId, err) return myContext, err } - beginTime, endTime, _ = group_m.GetSupportLevelTime(now.AddDate(0, 0, -group_e.SUPPORT_LEVEL_PERIOD_DAY)) - result.LastCount, result.LastConsume, err = g.GetConsumeByRange(beginTime, endTime) + _, _, periodLast := group_m.GetSupportLevelTime(now.AddDate(0, 0, -group_e.SUPPORT_LEVEL_PERIOD_DAY)) + //result.LastCount, result.LastConsume, err = g.GetConsumeByRange(beginTimeLast, endTimeLast) + //if err != nil { + // return myContext, err + //} + result.LastConsume, result.LastCount, err = group_s.GetGroupConsumeCount(model, groupId, periodLast) if err != nil { + model.Log.Errorf("GetSupportDetail groupId:%s, err:%v", groupId, err) return myContext, err } @@ -152,7 +160,7 @@ func GetSupportDetail(c *gin.Context) (*mycontext.MyContext, error) { } // 判断这个周期这个群的奖金是否已经发过 - _, _, period := group_m.GetLastSupportPeriod(now) + _, _, period = group_m.GetLastSupportPeriod(now) gsaa := group_m.GroupSupportAwardAdmin{Period: period, GroupUid: groupId} rows, err := gsaa.Get(model.Db) if err != nil {