Commit c114da63 authored by chenweijian's avatar chenweijian

家族送礼排行

parent 25f747e1
...@@ -1624,3 +1624,66 @@ func GroupPowerSetInfo(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -1624,3 +1624,66 @@ func GroupPowerSetInfo(c *gin.Context) (*mycontext.MyContext, error) {
resp.ResponseOk(c, info) resp.ResponseOk(c, info)
return myContext, nil return myContext, nil
} }
// @Tags 国家势力
// @Summary 搜索家族
// @Success 200 {object} group_power_cv.CvGroupPowerRankMontAct
// @Router /v1/h5/groupPower/rank/month [get]
func GroupPowerMonthRankAct(c *gin.Context) (*mycontext.MyContext, error) {
myContext := mycontext.CreateMyContext(c.Keys)
userId, err := req.GetUserId(c)
if err != nil {
return myContext, err
}
var model = domain.CreateModelContext(myContext)
// 国家区域
var area int
// 我的家族
myGroupPower, err := groupPower_m.GetGroupPowerUserOrNil(model, userId)
if err != nil {
return myContext, err
}
if myGroupPower != nil && myGroupPower.GroupPowerId > 0 {
//获取势力主
mgrUserId, err := groupPower_m.GetGroupPowerMgr(model, myGroupPower.GroupPowerId)
if err != nil {
return myContext, err
}
_, area, err = user_m.GetUserCountryArea(model, mgrUserId)
if err != nil {
model.Log.Errorf("GroupPowerMonthRankAct 获取国家资源错误 userId:%d, err:%v", userId, err)
return myContext, err
}
}
if area == 0 {
_, area, err = user_m.GetUserCountryArea(model, userId)
if err != nil {
model.Log.Errorf("GroupPowerMonthRankAct 获取国家资源错误 userId:%d, err:%v", userId, err)
return myContext, err
}
}
// 这个月
beginDate, endDate := now.BeginningOfMonth().Format(utils.DATE_FORMAT), now.EndOfMonth().Format(utils.DATE_FORMAT)
response, err := GroupPowerMonthRankActByMonth(model, userId, beginDate, endDate, time.Now().Format(utils.COMPACT_MONTH_FORMAT), area)
if err != nil {
return myContext, err
}
// 上月
lastMonthStart := utils.GetLastMonthStart(time.Now())
lastTime := now.New(lastMonthStart)
beginDateLast, endDateLast := lastTime.BeginningOfMonth().Format(utils.DATE_FORMAT), lastTime.EndOfMonth().Format(utils.DATE_FORMAT)
responseLast, err := GroupPowerMonthRankActByMonth(model, userId, beginDateLast, endDateLast, lastMonthStart.Format(utils.COMPACT_MONTH_FORMAT), area)
if err != nil {
return myContext, err
}
res := &group_power_cv.CvGroupPowerRankMontAct{
MyGroupPower: response.MyGroupPower,
Items: response.Items,
MyGroupPowerLast: responseLast.MyGroupPower,
ItemsLast: responseLast.Items,
LeftSecond: now.EndOfMonth().Unix() - time.Now().Unix(),
}
resp.ResponseOk(c, res)
return myContext, nil
}
...@@ -56,65 +56,30 @@ func GroupPowerRank(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -56,65 +56,30 @@ func GroupPowerRank(c *gin.Context) (*mycontext.MyContext, error) {
} }
// @Tags 国家势力 // @Tags 国家势力
// @Summary 家族榜单-活动 // @Summary 搜索家族
// @Success 200 {object} group_power_cv.CvGroupPowerRankMontAct // @Param id query int true "家族id"
// @Router /v1/h5/groupPower/rank/month [get] // @Success 200
func GroupPowerMonthRankAct(c *gin.Context) (*mycontext.MyContext, error) { // @Router /v1/h5/groupPower/info [get]
func H5GetGroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) {
myContext := mycontext.CreateMyContext(c.Keys) myContext := mycontext.CreateMyContext(c.Keys)
userId, err := req.GetUserId(c) familyId, err := strconv.ParseUint(c.Query("id"), 10, 64)
if err != nil { if err != nil || familyId <= 0 {
return myContext, err return myContext, bizerr.InvalidParameter
}
var model = domain.CreateModelContext(myContext)
// 国家区域
var area int
// 我的家族
myGroupPower, err := groupPower_m.GetGroupPowerUserOrNil(model, userId)
if err != nil {
return myContext, err
}
if myGroupPower != nil && myGroupPower.GroupPowerId > 0 {
//获取势力主
mgrUserId, err := groupPower_m.GetGroupPowerMgr(model, myGroupPower.GroupPowerId)
if err != nil {
return myContext, err
}
_, area, err = user_m.GetUserCountryArea(model, mgrUserId)
if err != nil {
model.Log.Errorf("GroupPowerMonthRankAct 获取国家资源错误 userId:%d, err:%v", userId, err)
return myContext, err
}
}
if area == 0 {
_, area, err = user_m.GetUserCountryArea(model, userId)
if err != nil {
model.Log.Errorf("GroupPowerMonthRankAct 获取国家资源错误 userId:%d, err:%v", userId, err)
return myContext, err
}
} }
// 这个月
beginDate, endDate := now.BeginningOfMonth().Format(utils.DATE_FORMAT), now.EndOfMonth().Format(utils.DATE_FORMAT) model := domain.CreateModelContext(myContext)
response, err := GroupPowerMonthRankActByMonth(model, userId, beginDate, endDate, time.Now().Format(utils.COMPACT_MONTH_FORMAT), area) info, err := groupPower_m.GetGroupPower(model, familyId)
if err != nil { if err != nil {
return myContext, err return myContext, err
} }
// 上月
lastMonthStart := utils.GetLastMonthStart(time.Now()) type Family struct {
lastTime := now.New(lastMonthStart) Id uint64 `json:"id,omitempty"`
beginDateLast, endDateLast := lastTime.BeginningOfMonth().Format(utils.DATE_FORMAT), lastTime.EndOfMonth().Format(utils.DATE_FORMAT) Avatar string `json:"avatar"`
responseLast, err := GroupPowerMonthRankActByMonth(model, userId, beginDateLast, endDateLast, lastMonthStart.Format(utils.COMPACT_MONTH_FORMAT), area) Nick string `json:"nick"`
if err != nil {
return myContext, err
} }
res := &group_power_cv.CvGroupPowerRankMontAct{ resp.ResponseOk(c, Family{Id: info.ID, Avatar: info.Icon, Nick: info.Name})
MyGroupPower: response.MyGroupPower,
Items: response.Items,
MyGroupPowerLast: responseLast.MyGroupPower,
ItemsLast: responseLast.Items,
LeftSecond: now.EndOfMonth().Unix() - time.Now().Unix(),
}
resp.ResponseOk(c, res)
return myContext, nil return myContext, nil
} }
......
...@@ -147,6 +147,7 @@ func InitRouter() *gin.Engine { ...@@ -147,6 +147,7 @@ func InitRouter() *gin.Engine {
{ {
h5GroupPower.GET("/grade/detail", wrapper(group_power_r.GroupPowerGradeDetail)) h5GroupPower.GET("/grade/detail", wrapper(group_power_r.GroupPowerGradeDetail))
h5GroupPower.GET("/rank/month", wrapper(group_power_r.GroupPowerMonthRankAct)) h5GroupPower.GET("/rank/month", wrapper(group_power_r.GroupPowerMonthRankAct))
h5GroupPower.GET("/info", wrapper(group_power_r.H5GetGroupPowerInfo))
} }
charge := v1.Group("/charge") charge := v1.Group("/charge")
......
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