From 9e102f8e75d757320aba50555795ac8c0b0be010 Mon Sep 17 00:00:00 2001 From: chenweijian <820961417@qq.com> Date: Fri, 30 Jun 2023 15:02:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BE=E5=AF=B9=E9=82=80=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cv/invite_cv/invite_apply.go | 20 +++++++++++++------- domain/model/invite_m/invite_apply.go | 18 ++++++++++++++++++ route/invite_r/party_invite.go | 15 ++++++++++++++- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/cv/invite_cv/invite_apply.go b/cv/invite_cv/invite_apply.go index baf3f65..25e3289 100644 --- a/cv/invite_cv/invite_apply.go +++ b/cv/invite_cv/invite_apply.go @@ -11,11 +11,17 @@ type CvUserLevel struct { } type InviteApplyRes struct { - NewUserCode string `json:"newUserCode"` - Platform string `json:"platform"` - Recharge string `json:"recharge"` - UserCode string `json:"userCode"` - CreateUnix int64 `json:"createUnix"` - Level string `json:"level"` - Status uint8 `json:"status"` // 状态0.未审核1.已通过2.已拒绝 + NewUserCode string `json:"newUserCode"` + Platform string `json:"platform"` + Recharge string `json:"recharge"` + UserCode string `json:"userCode"` + CreateUnix int64 `json:"createUnix"` + Level string `json:"level"` + Status uint8 `json:"status"` // 状态0.未审核1.已通过2.已拒绝 + NumList []*InviteApplyNumRes `json:"numList"` +} + +type InviteApplyNumRes struct { + Type int `json:"type"` // 1.已申请2.待审核3.已通过4.已拒绝" + Num int `json:"num"` } diff --git a/domain/model/invite_m/invite_apply.go b/domain/model/invite_m/invite_apply.go index c68500e..44671a8 100644 --- a/domain/model/invite_m/invite_apply.go +++ b/domain/model/invite_m/invite_apply.go @@ -63,3 +63,21 @@ func IsInInviteApply(model *domain.Model, userId mysql.ID) (bool, error) { // err == nil, record exists return true, nil } + +// 检查被邀请人是否存在 +func GetInviteApplyNumByType(model *domain.Model, gType int, beginTime, endTime time.Time) (int, error) { + var count int64 + db := model.Db.Model(InviteApply{}).Where("created_time >= ? and created_time <= ?", beginTime, endTime) + switch gType { // 1.已申请2.待审核3.已通过4.已拒绝 + case 2: + db = db.Where("`status` = ?", 0) + case 3: + db = db.Where("`status` = ?", 1) + case 4: + db = db.Where("`status` = ?", 2) + } + if err := db.Count(&count).Error; err != nil { + return 0, err + } + return int(count), nil +} diff --git a/route/invite_r/party_invite.go b/route/invite_r/party_invite.go index e99cf6c..139eddb 100644 --- a/route/invite_r/party_invite.go +++ b/route/invite_r/party_invite.go @@ -139,7 +139,7 @@ func InviteApplyList(c *gin.Context) (*mycontext.MyContext, error) { if err := c.ShouldBindQuery(¶m); err != nil { return myCtx, err } - if param.Type < 1 || param.Type > 4 { + if param.Type < 0 || param.Type > 4 { return myCtx, bizerr.InvalidParameter } @@ -159,6 +159,19 @@ func InviteApplyList(c *gin.Context) (*mycontext.MyContext, error) { var model = domain.CreateModelContext(myCtx) + if param.Type == 0 { // 返回所有Type类型有多少条数 + res := &invite_cv.InviteApplyRes{NumList: make([]*invite_cv.InviteApplyNumRes, 0, 4)} + for _, gType := range []int{1, 2, 3, 4} { // 1.已申请2.待审核3.已通过4.已拒绝 + num, err := invite_m.GetInviteApplyNumByType(model, gType, param.BeginTime, param.EndTime) + if err != nil { + return myCtx, err + } + res.NumList = append(res.NumList, &invite_cv.InviteApplyNumRes{Type: gType, Num: num}) + } + resp.ResponsePageOk(c, []*invite_cv.InviteApplyRes{res}, 0, 0, 0) + return myCtx, nil + } + agentIds := []uint64{userId} if promotion_m.IsPromotionManager(model, userId) { agentIds, err = promotion_m.GetPromotionManagerAgentList(model, userId) -- 2.22.0