|
|
|
@ -3,6 +3,7 @@ package upgrade
|
|
|
|
|
import (
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
|
"recook/internal/cache"
|
|
|
|
|
"recook/internal/define"
|
|
|
|
|
"recook/internal/service/baseCode"
|
|
|
|
|
"recook/internal/v2/model/recook/user"
|
|
|
|
@ -42,9 +43,13 @@ func (o logic) List(args ApplyList) (res []upgrade.ApplyEntry) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ApplyCreate struct {
|
|
|
|
|
Mobile string `json:"mobile" validate:"required"`
|
|
|
|
|
UserID uint `json:"-"`
|
|
|
|
|
Kind uint `json:"kind" validate:"required,oneof=1 2"`
|
|
|
|
|
Mobile string `json:"mobile" validate:"required"`
|
|
|
|
|
UserID uint `json:"-"`
|
|
|
|
|
Kind uint `json:"kind" validate:"required,oneof=1 2"`
|
|
|
|
|
Code string `json:"code"`
|
|
|
|
|
BusinessPhoto string `json:"business_photo"`
|
|
|
|
|
MainPhoto string `json:"main_photo"`
|
|
|
|
|
Address string `json:"address"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (o logic) Create(args ApplyCreate) error {
|
|
|
|
@ -75,14 +80,20 @@ func (o logic) Create(args ApplyCreate) error {
|
|
|
|
|
if args.Kind == 1 {
|
|
|
|
|
state = upgrade.Suc
|
|
|
|
|
}
|
|
|
|
|
if args.Code != cache.GetUpgradeSMSCode(u1.Id) {
|
|
|
|
|
return fmt.Errorf("验证码不正确")
|
|
|
|
|
}
|
|
|
|
|
if err := mysql.Db.Transaction(func(tx *gorm.DB) error {
|
|
|
|
|
obj := upgrade.ApplyEntry{
|
|
|
|
|
Mobile: args.Mobile,
|
|
|
|
|
ApplyUserID: args.UserID,
|
|
|
|
|
Kind: upgrade.Kind(args.Kind),
|
|
|
|
|
CreatedAt: formatime.NewSecondNow(),
|
|
|
|
|
State: state,
|
|
|
|
|
ParentID: parentID,
|
|
|
|
|
Mobile: args.Mobile,
|
|
|
|
|
ApplyUserID: args.UserID,
|
|
|
|
|
Kind: upgrade.Kind(args.Kind),
|
|
|
|
|
CreatedAt: formatime.NewSecondNow(),
|
|
|
|
|
State: state,
|
|
|
|
|
BusinessAddress: args.Address,
|
|
|
|
|
BusinessPhoto: args.BusinessPhoto,
|
|
|
|
|
MainPhoto: args.MainPhoto,
|
|
|
|
|
ParentID: parentID,
|
|
|
|
|
}
|
|
|
|
|
if err := tx.Create(&obj).Error; err != nil {
|
|
|
|
|
return err
|
|
|
|
|