You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package copartner
import (
"git.oa00.com/go/mysql"
"github.com/gin-gonic/gin"
"recook/internal/model/user"
service "recook/internal/service/app"
"recook/internal/v2/lib/back"
"recook/internal/v2/logic/wxapp/copartner"
"recook/tools"
)
type Personal struct {
}
type argsPersonalAdd struct {
Phone string `binding:"required,len=11,startswith=1" label:"手机号"`
Nickname string `binding:"required" label:"昵称"`
InviteNo string `binding:"required" label:"邀请码"`
}
// Add @Title 添加合伙人
func (*Personal) Add(c *gin.Context) {
args := argsPersonalAdd{}
err := tools.Params(&args, c)
if err != nil {
back.Fail(c, err.Error())
return
}
if err := copartner.CopartnerLogic.Very(args.InviteNo); err != nil {
back.Fail(c, err.Error())
return
}
information := user.Information{Mobile: args.Phone}
mysql.Db.Where(&information).First(&information)
if information.ID > 0 {
back.Fail(c, "手机号已存在")
return
}
// 从手机注册时用户邀请码默认为id时6的用户邀请码为NXR0L3
// p.InvitationNo = "NXR0L3"
// 根据 不同的码 去调用不同的 下级规则
// 获取用户角色等级
registerUser := service.NewRegisterUser()
// 开始添加用户
information.Nickname = args.Nickname
information.Level = 10
if err := registerUser.UserAdd(c, &user.Login{}, &information, args.Phone); err != nil {
back.Fail(c, "提交失败")
return
}
back.Suc(c, "操作成功", nil)
}