Commit 9e102f8e authored by chenweijian's avatar chenweijian

派对邀请

parent 4875e396
...@@ -11,11 +11,17 @@ type CvUserLevel struct { ...@@ -11,11 +11,17 @@ type CvUserLevel struct {
} }
type InviteApplyRes struct { type InviteApplyRes struct {
NewUserCode string `json:"newUserCode"` NewUserCode string `json:"newUserCode"`
Platform string `json:"platform"` Platform string `json:"platform"`
Recharge string `json:"recharge"` Recharge string `json:"recharge"`
UserCode string `json:"userCode"` UserCode string `json:"userCode"`
CreateUnix int64 `json:"createUnix"` CreateUnix int64 `json:"createUnix"`
Level string `json:"level"` Level string `json:"level"`
Status uint8 `json:"status"` // 状态0.未审核1.已通过2.已拒绝 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"`
} }
...@@ -63,3 +63,21 @@ func IsInInviteApply(model *domain.Model, userId mysql.ID) (bool, error) { ...@@ -63,3 +63,21 @@ func IsInInviteApply(model *domain.Model, userId mysql.ID) (bool, error) {
// err == nil, record exists // err == nil, record exists
return true, nil 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
}
...@@ -139,7 +139,7 @@ func InviteApplyList(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -139,7 +139,7 @@ func InviteApplyList(c *gin.Context) (*mycontext.MyContext, error) {
if err := c.ShouldBindQuery(&param); err != nil { if err := c.ShouldBindQuery(&param); err != nil {
return myCtx, err return myCtx, err
} }
if param.Type < 1 || param.Type > 4 { if param.Type < 0 || param.Type > 4 {
return myCtx, bizerr.InvalidParameter return myCtx, bizerr.InvalidParameter
} }
...@@ -159,6 +159,19 @@ func InviteApplyList(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -159,6 +159,19 @@ func InviteApplyList(c *gin.Context) (*mycontext.MyContext, error) {
var model = domain.CreateModelContext(myCtx) 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} agentIds := []uint64{userId}
if promotion_m.IsPromotionManager(model, userId) { if promotion_m.IsPromotionManager(model, userId) {
agentIds, err = promotion_m.GetPromotionManagerAgentList(model, userId) agentIds, err = promotion_m.GetPromotionManagerAgentList(model, userId)
......
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