KK 3 years ago
parent 845180ed29
commit 6abe165f9a

@ -13,6 +13,8 @@ type sms struct {
client *sdk.Client
}
const ()
/*
*/
@ -20,6 +22,8 @@ const (
regionId = "cn-hangzhou"
accessKey = "LTAI4Fe9j26vbarEGVZ7Nany"
accessKeySecret = "ysEYgqgpKtPbEJmHwdZ5psKsT15nel"
SUCCESS = "SMS_243631426"
FAIL = "SMS_243616481"
)
func init() {

@ -44,9 +44,6 @@ func (*Personal) Add(c *gin.Context) {
// 开始添加用户
information.Nickname = args.Nickname
information.Level = 10
if err := registerUser.UserAdd(c, &user.Login{}, &information, args.Phone); err != nil {
back.Fail(c, "提交失败")
return
}
registerUser.UserAdd(c, &user.Login{}, &information, args.Phone)
back.Suc(c, "操作成功", nil)
}

@ -8,7 +8,6 @@ import (
"recook/internal/libs/aliyun"
"recook/internal/libs/bean"
"recook/internal/service/baseCode"
"recook/internal/v2/logic/wxapp/message"
"recook/internal/v2/model/company"
"recook/internal/v2/model/recook/manage"
"recook/internal/v2/model/recook/user"
@ -228,61 +227,57 @@ func (o logic) Sure(args CompanySureApply) error {
}
if u1.Id > 0 {
return errors.New("手机号已使用")
} else {
mobile := obj.Mobile
rd := fmt.Sprintf("%06v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(1000000))
sql := `select max(id)+floor(1+rand()*5) from recook_user_info`
var lastId int64
if err := tx.Raw(sql).Count(&lastId).Error; err != nil {
return err
}
info := user.RecookUserInfoModel{
Id: uint(lastId),
Nickname: obj.ShopName,
Mobile: mobile,
Birthday: formatime.NewSecondFrom(define.DefaultBirthday),
HeadImgUrl: "",
Phone: mobile,
Identifier: time.Now().Format("060102") + rd,
Level: 10,
ParentID: 0,
RootID: 0,
InvitationNo: baseCode.Encode(uint64(lastId)),
IsEnterprise: true,
}
}
if err := tx.Create(&info).Error; err != nil {
tx.Rollback()
err = fmt.Errorf("创建用户错误101:" + err.Error())
return err
}
mobile := obj.Mobile
rd := fmt.Sprintf("%06v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(1000000))
sql := `select max(id)+floor(1+rand()*5) from recook_user_info`
var lastId int64
if err := tx.Raw(sql).Count(&lastId).Error; err != nil {
return err
}
info := user.RecookUserInfoModel{
Id: uint(lastId),
Nickname: obj.ShopName,
Mobile: mobile,
Birthday: formatime.NewSecondFrom(define.DefaultBirthday),
HeadImgUrl: "",
Phone: mobile,
Identifier: time.Now().Format("060102") + rd,
Level: 10,
ParentID: 0,
RootID: 0,
InvitationNo: baseCode.Encode(uint64(lastId)),
IsEnterprise: true,
}
// 生成邀请码和推荐码
info.InvitationNo = baseCode.Encode(uint64(info.Id))
if err := tx.Save(&info).Error; err != nil {
err = fmt.Errorf("创建用户错误102:" + err.Error())
return err
}
// 建立钱包
wallet := user.RecookUserWalletModel{
UserId: info.Id,
}
if err := tx.Create(&wallet).Error; err != nil {
tx.Rollback()
err = fmt.Errorf("创建用户错误103:" + err.Error())
return err
}
err := aliyun.Sms.SendMessage(info.Mobile, message.SUCCESS, map[string]string{}) // 发送短信
if err != nil {
return err
}
if err := tx.Model(&obj).Updates(company.Info{
UserID: uint(lastId),
}).Error; err != nil {
return err
}
if err := tx.Create(&info).Error; err != nil {
tx.Rollback()
err = fmt.Errorf("创建用户错误101:" + err.Error())
return err
}
// 生成邀请码和推荐码
info.InvitationNo = baseCode.Encode(uint64(info.Id))
if err := tx.Save(&info).Error; err != nil {
err = fmt.Errorf("创建用户错误102:" + err.Error())
return err
}
// 建立钱包
wallet := user.RecookUserWalletModel{
UserId: info.Id,
}
if err := tx.Create(&wallet).Error; err != nil {
tx.Rollback()
err = fmt.Errorf("创建用户错误103:" + err.Error())
return err
}
if err := tx.Model(&obj).Updates(company.Info{
UserID: uint(lastId),
}).Error; err != nil {
return err
}
aliyun.Sms.SendMessage(info.Mobile, aliyun.SUCCESS, map[string]string{})
return nil
}); err != nil {
return err
@ -319,12 +314,9 @@ func (o logic) Reject(args CompanyRejectApply) error {
}).Error; err != nil {
return err
}
err := aliyun.Sms.SendMessage(obj.Mobile, message.FAIL, map[string]string{
aliyun.Sms.SendMessage(obj.Mobile, aliyun.FAIL, map[string]string{
"remark": args.Reason,
})
if err != nil {
return err
}
return nil
}); err != nil {
return err

Loading…
Cancel
Save