diff --git a/domain/model/groupPower_m/group_grade.go b/domain/model/groupPower_m/group_grade.go index b1d02417ae903f35a5764f5f2504a02b65b17212..14b8a37fcb9c4709dfbacb1be15f4ac9ee49722c 100644 --- a/domain/model/groupPower_m/group_grade.go +++ b/domain/model/groupPower_m/group_grade.go @@ -255,7 +255,9 @@ func IncrGroupPowerStarOnMic(model *domain.Model, groupPowerId, userId mysql.ID, curTs = month0Ts } score := nowTs - curTs - return IncrGroupPowerMonthStarScore(model, groupPowerId, userId, groupPower_e.GroupPowerStarTypeActive, mysql.Num(score), nowTs) + err = IncrGroupPowerMonthStarScore(model, groupPowerId, userId, groupPower_e.GroupPowerStarTypeActive, mysql.Num(score), nowTs) + err = IncrGroupPowerDayStarScore(model, groupPowerId, userId, groupPower_e.GroupPowerStarTypeActive, mysql.Num(score), nowTs) + return err }) } diff --git a/domain/model/groupPower_m/group_star.go b/domain/model/groupPower_m/group_star.go index 930a318d2ab97676512681f219076c30b176c2fd..08b97a0b609f4b37746ab0bda18f99bdb8ac69f4 100644 --- a/domain/model/groupPower_m/group_star.go +++ b/domain/model/groupPower_m/group_star.go @@ -9,7 +9,7 @@ import ( "time" ) -// 家族之星 +// 家族之星-月 type GroupPowerMonthStar struct { Month string GroupPowerId mysql.ID @@ -21,6 +21,18 @@ type GroupPowerMonthStar struct { UpdatedTime time.Time `gorm:"->"` } +// 家族之星-日 +type GroupPowerDayStar struct { + Date time.Time + GroupPowerId mysql.ID + UserId mysql.ID + Type groupPower_e.GroupPowerStarType + Score mysql.Num + LastCalTs int64 + CreatedTime time.Time `gorm:"->"` + UpdatedTime time.Time `gorm:"->"` +} + // 增加家族之星分数 func IncrGroupPowerMonthStarScore(model *domain.Model, groupPowerId, userId mysql.ID, _type groupPower_e.GroupPowerStarType, score mysql.Num, lastCalTs int64) error { month := time.Now().Format("200601") @@ -45,6 +57,29 @@ func IncrGroupPowerMonthStarScore(model *domain.Model, groupPowerId, userId mysq return nil } +// 增加家族之星分数 +func IncrGroupPowerDayStarScore(model *domain.Model, groupPowerId, userId mysql.ID, _type groupPower_e.GroupPowerStarType, score mysql.Num, lastCalTs int64) error { + star := &GroupPowerDayStar{ + Date: time.Now(), + GroupPowerId: groupPowerId, + UserId: userId, + Type: _type, + Score: score, + LastCalTs: lastCalTs, + } + if err := model.DB().Model(GroupPowerDayStar{}).Clauses(clause.OnConflict{ + Columns: []clause.Column{{Name: "date"}, {Name: "group_power_id"}, {Name: "user_id"}, {Name: "type"}}, + DoUpdates: clause.Assignments(map[string]interface{}{ + "score": gorm.Expr("score + ?", star.Score), + "last_cal_ts": lastCalTs, + }), + }).Create(star).Error; err != nil { + model.Log.Errorf("IncrGroupPowerDayStarScore fail:%v", err) + return err + } + return nil +} + // 获取家族之星分数 // 允许返回gorm.ErrRecordNotFound func GetGroupPowerMonthStar(model *domain.Model, groupPowerId, userId mysql.ID, _type groupPower_e.GroupPowerStarType) (*GroupPowerMonthStar, error) { diff --git a/domain/service/event_s/event_init.go b/domain/service/event_s/event_init.go index c5b10091733217a9411a3a50c4d7fba3b9cb8c78..e9ddc8f16d100f35e21485f1de037ad5fde62dd7 100644 --- a/domain/service/event_s/event_init.go +++ b/domain/service/event_s/event_init.go @@ -493,6 +493,9 @@ func SendGift() { if err := groupPower_m.IncrGroupPowerMonthStarScore(model, data.GroupPowerId, data.UserId, groupPower_e.GroupPowerStarTypeFamous, diamonds, 0); err != nil { model.Log.Errorf("IncrGroupPowerMonthStarScore famous fail:%v", err) } + if err := groupPower_m.IncrGroupPowerDayStarScore(model, data.GroupPowerId, data.UserId, groupPower_e.GroupPowerStarTypeFamous, diamonds, 0); err != nil { + model.Log.Errorf("IncrGroupPowerDayStarScore famous fail:%v", err) + } } // 收礼加分 for _, userId := range sendGiftEvent.ReceiveUserIds { @@ -501,6 +504,9 @@ func SendGift() { if err := groupPower_m.IncrGroupPowerMonthStarScore(model, data.GroupPowerId, data.UserId, groupPower_e.GroupPowerStarTypeCharm, diamonds, 0); err != nil { model.Log.Errorf("IncrGroupPowerMonthStarScore charm fail:%v", err) } + if err := groupPower_m.IncrGroupPowerDayStarScore(model, data.GroupPowerId, data.UserId, groupPower_e.GroupPowerStarTypeCharm, diamonds, 0); err != nil { + model.Log.Errorf("IncrGroupPowerDayStarScore charm fail:%v", err) + } } } return nil diff --git a/route/router.go b/route/router.go index 9c2884b0b043c43acb81a7fc5a874410e000b43c..cb8663de2c6291645513a00e344fd81b809dd61f 100644 --- a/route/router.go +++ b/route/router.go @@ -139,6 +139,7 @@ func InitRouter() *gin.Engine { groupPower.GET("/rank/:period", wrapper(group_power_r.GroupPowerRank)) groupPower.GET("/rankTop", wrapper(group_power_r.GroupPowerRankTop)) groupPower.GET("/star", wrapper(group_power_r.GroupPowerStar)) + groupPower.GET("/star/:period", wrapper(group_power_r.GroupPowerStar)) groupPower.POST("/info/set", wrapper(group_power_r.GroupPowerSetInfo)) } h5GroupPower := v1.Group("/h5/groupPower")