Commit c114da63 authored by chenweijian's avatar chenweijian

家族送礼排行

parent 25f747e1
......@@ -1624,3 +1624,66 @@ func GroupPowerSetInfo(c *gin.Context) (*mycontext.MyContext, error) {
resp.ResponseOk(c, info)
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) {
}
// @Tags 国家势力
// @Summary 家族榜单-活动
// @Success 200 {object} group_power_cv.CvGroupPowerRankMontAct
// @Router /v1/h5/groupPower/rank/month [get]
func GroupPowerMonthRankAct(c *gin.Context) (*mycontext.MyContext, error) {
// @Summary 搜索家族
// @Param id query int true "家族id"
// @Success 200
// @Router /v1/h5/groupPower/info [get]
func H5GetGroupPowerInfo(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
}
familyId, err := strconv.ParseUint(c.Query("id"), 10, 64)
if err != nil || familyId <= 0 {
return myContext, bizerr.InvalidParameter
}
// 这个月
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)
model := domain.CreateModelContext(myContext)
info, err := groupPower_m.GetGroupPower(model, familyId)
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
type Family struct {
Id uint64 `json:"id,omitempty"`
Avatar string `json:"avatar"`
Nick string `json:"nick"`
}
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)
resp.ResponseOk(c, Family{Id: info.ID, Avatar: info.Icon, Nick: info.Name})
return myContext, nil
}
......
......@@ -147,6 +147,7 @@ func InitRouter() *gin.Engine {
{
h5GroupPower.GET("/grade/detail", wrapper(group_power_r.GroupPowerGradeDetail))
h5GroupPower.GET("/rank/month", wrapper(group_power_r.GroupPowerMonthRankAct))
h5GroupPower.GET("/info", wrapper(group_power_r.H5GetGroupPowerInfo))
}
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