Commit 31773288 authored by chenweijian's avatar chenweijian

group support

parent dbaf767b
...@@ -128,39 +128,39 @@ func (g *GiftOperate) GetConsumeByRange(beginTime, endTime time.Time) (uint32, u ...@@ -128,39 +128,39 @@ func (g *GiftOperate) GetConsumeByRange(beginTime, endTime time.Time) (uint32, u
return 0, 0, nil return 0, 0, nil
} }
if beginTime.Unix() >= 1691337600 && beginTime.Unix() < 1691942400 { // 因为这周水果机被部分人刷币,所以这里做了特殊的处理 //if beginTime.Unix() >= 1691337600 && beginTime.Unix() < 1691942400 { // 因为这周水果机被部分人刷币,所以这里做了特殊的处理
reduceMap := map[string]uint64{ // reduceMap := map[string]uint64{
"HTGS#a63226380": 20000000, // "HTGS#a63226380": 20000000,
//"HTGS#a42641278": 10000000, // //"HTGS#a42641278": 10000000,
"@TGS#3ZZ5GZLHA": 27141539, // "@TGS#3ZZ5GZLHA": 27141539,
"HTGS#a81630128": 8955410, // "HTGS#a81630128": 8955410,
"HTGS#a42300598": 50211301, // "HTGS#a42300598": 50211301,
"HTGS#a40088696": 10000000, // "HTGS#a40088696": 10000000,
"HTGS#a21700997": 14352310, // "HTGS#a21700997": 14352310,
"HTGS#a83608384": 49644203, // "HTGS#a83608384": 49644203,
"@TGS#33GDXTSIH": 50000000, // "@TGS#33GDXTSIH": 50000000,
"HTGS#a50538513": 15000000, // "HTGS#a50538513": 15000000,
"HTGS#a77282385": 15000000, // "HTGS#a77282385": 15000000,
"HTGS#a59437326": 10000000, // "HTGS#a59437326": 10000000,
"HTGS#a16909405": 10000000, // "HTGS#a16909405": 10000000,
"HTGS#a44104431": 16861206, // "HTGS#a44104431": 16861206,
"HTGS#a56794634": 59591313, // "HTGS#a56794634": 59591313,
"HTGS#a11286025": 31232311, // "HTGS#a11286025": 31232311,
"HTGS#a17238550": 52309338, // "HTGS#a17238550": 52309338,
"HTGS#a83592361": 79545067, // "HTGS#a83592361": 79545067,
"HTGS#a39882521": 10255093, // "HTGS#a39882521": 10255093,
} // }
if reduceNum, ok := reduceMap[g.SceneUid]; ok { // if reduceNum, ok := reduceMap[g.SceneUid]; ok {
if g.Log != nil { // if g.Log != nil {
g.Log.Infof("fruit diamond reduceMap,groupId:%v,reduceNum:%v", g.SceneUid, reduceNum) // g.Log.Infof("fruit diamond reduceMap,groupId:%v,reduceNum:%v", g.SceneUid, reduceNum)
} // }
if rows[0].Consume >= reduceNum { // if rows[0].Consume >= reduceNum {
rows[0].Consume -= reduceNum // rows[0].Consume -= reduceNum
} else { // } else {
rows[0].Consume = 0 // rows[0].Consume = 0
} // }
} // }
} //}
return rows[0].C, rows[0].Consume, nil return rows[0].C, rows[0].Consume, nil
} }
......
...@@ -206,22 +206,12 @@ func (s *GroupService) GetSupportLevelByRedis(groupId string) (*res_m.ResGroupSu ...@@ -206,22 +206,12 @@ func (s *GroupService) GetSupportLevelByRedis(groupId string) (*res_m.ResGroupSu
model := domain.CreateModel(s.svc.CtxAndDb) model := domain.CreateModel(s.svc.CtxAndDb)
_, _, period := group_m.GetLastSupportPeriod(time.Now()) _, _, period := group_m.GetLastSupportPeriod(time.Now())
// 流水 consume, count, err := GetGroupConsumeCount(model, groupId, period)
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()
if err != nil { if err != nil {
model.Log.Errorf("GetSupportLevelByRedis key:%v, groupId:%v, err:%v", keySupportNum, groupId, err)
return nil, 0, 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 { if err != nil {
return nil, 0, err return nil, 0, err
} }
...@@ -231,6 +221,24 @@ func (s *GroupService) GetSupportLevelByRedis(groupId string) (*res_m.ResGroupSu ...@@ -231,6 +221,24 @@ func (s *GroupService) GetSupportLevelByRedis(groupId string) (*res_m.ResGroupSu
return rec, 0, nil 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, func (s *GroupService) GroupSupportAward(groupId string, profitAllocator uint64, userIds []uint64, resSupport *res_m.ResGroupSupport,
period string, groupInfo *group_m.GroupInfo) error { period string, groupInfo *group_m.GroupInfo) error {
......
...@@ -6,13 +6,11 @@ import ( ...@@ -6,13 +6,11 @@ import (
"git.hilo.cn/hilo-common/mycontext" "git.hilo.cn/hilo-common/mycontext"
"git.hilo.cn/hilo-common/resource/mysql" "git.hilo.cn/hilo-common/resource/mysql"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"hilo-group/_const/enum/gift_e"
"hilo-group/_const/enum/group_e" "hilo-group/_const/enum/group_e"
"hilo-group/_const/enum/msg_e" "hilo-group/_const/enum/msg_e"
"hilo-group/cv/group_cv" "hilo-group/cv/group_cv"
"hilo-group/cv/user_cv" "hilo-group/cv/user_cv"
"hilo-group/domain/cache/group_c" "hilo-group/domain/cache/group_c"
"hilo-group/domain/model/gift_m"
"hilo-group/domain/model/group_m" "hilo-group/domain/model/group_m"
"hilo-group/domain/model/res_m" "hilo-group/domain/model/res_m"
"hilo-group/domain/model/user_m" "hilo-group/domain/model/user_m"
...@@ -111,18 +109,28 @@ func GetSupportDetail(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -111,18 +109,28 @@ func GetSupportDetail(c *gin.Context) (*mycontext.MyContext, error) {
result := group_cv.SupportPageDetail{GroupId: txGroupId} result := group_cv.SupportPageDetail{GroupId: txGroupId}
now := time.Now() now := time.Now()
beginTime, endTime, _ := group_m.GetSupportLevelTime(now) _, endTime, period := group_m.GetSupportLevelTime(now)
result.RemainSecond = endTime.Unix() - now.Unix() result.RemainSecond = endTime.Unix() - now.Unix()
g := gift_m.GiftOperate{SceneType: gift_e.GroupSceneType, SceneUid: groupId, Model: model} //g := gift_m.GiftOperate{SceneType: gift_e.GroupSceneType, SceneUid: groupId, Model: model}
result.CurrentCount, result.CurrentConsume, err = g.GetConsumeByRange(beginTime, endTime) //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 { if err != nil {
model.Log.Errorf("GetSupportDetail groupId:%s, err:%v", groupId, err)
return myContext, err return myContext, err
} }
beginTime, endTime, _ = group_m.GetSupportLevelTime(now.AddDate(0, 0, -group_e.SUPPORT_LEVEL_PERIOD_DAY)) _, _, periodLast := group_m.GetSupportLevelTime(now.AddDate(0, 0, -group_e.SUPPORT_LEVEL_PERIOD_DAY))
result.LastCount, result.LastConsume, err = g.GetConsumeByRange(beginTime, endTime) //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 { if err != nil {
model.Log.Errorf("GetSupportDetail groupId:%s, err:%v", groupId, err)
return myContext, err return myContext, err
} }
...@@ -152,7 +160,7 @@ func GetSupportDetail(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -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} gsaa := group_m.GroupSupportAwardAdmin{Period: period, GroupUid: groupId}
rows, err := gsaa.Get(model.Db) rows, err := gsaa.Get(model.Db)
if err != nil { if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment