作者 yangfu

增加 短信验证码验证手机号

分红合约分页修改
@@ -8,15 +8,22 @@ import ( @@ -8,15 +8,22 @@ import (
8 8
9 type SendSmsCodeCommand struct { 9 type SendSmsCodeCommand struct {
10 Phone string `json:"phone" valid:"Required"` 10 Phone string `json:"phone" valid:"Required"`
  11 + // 0:无 1:需要账号存在于账号系统内,才能发送验证码
  12 + Flag int `json:"flag"`
  13 + // [1:登录][2:修改密码][3:找回密码][4:注册][5:修改手机号]
  14 + Action int `json:"action"`
11 } 15 }
12 16
13 -func (orgAddCommand *SendSmsCodeCommand) Valid(validation *validation.Validation) { 17 +func (cmd *SendSmsCodeCommand) Valid(validation *validation.Validation) {
14 18
15 } 19 }
16 20
17 -func (orgAddCommand *SendSmsCodeCommand) ValidateCommand() error { 21 +func (cmd *SendSmsCodeCommand) ValidateCommand() error {
18 valid := validation.Validation{} 22 valid := validation.Validation{}
19 - b, err := valid.Valid(orgAddCommand) 23 + b, err := valid.Valid(cmd)
  24 + if cmd.Action == 1 || cmd.Action == 2 || cmd.Action == 3 {
  25 + cmd.Flag = 1
  26 + }
20 if err != nil { 27 if err != nil {
21 return err 28 return err
22 } 29 }
@@ -171,6 +171,18 @@ func (svr AuthService) AuthLoginQrcodeBinding(bindingCmd *command.QrcodeBindingC @@ -171,6 +171,18 @@ func (svr AuthService) AuthLoginQrcodeBinding(bindingCmd *command.QrcodeBindingC
171 171
172 //SendSmsCaptcha 发送验证码短信 172 //SendSmsCaptcha 发送验证码短信
173 func (svr AuthService) SendSmsCaptcha(smsCodeCommand *command.SendSmsCodeCommand) error { 173 func (svr AuthService) SendSmsCaptcha(smsCodeCommand *command.SendSmsCodeCommand) error {
  174 + if err := smsCodeCommand.ValidateCommand(); err != nil {
  175 + return application.ThrowError(application.ARG_ERROR, err.Error())
  176 + }
  177 + if smsCodeCommand.Flag == 1 {
  178 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
  179 + userBase, err := creationUserGateway.AuthUserBaseInfo(allied_creation_user.ReqAuthUserBase{
  180 + Account: smsCodeCommand.Phone,
  181 + })
  182 + if err != nil || userBase.UserInfo.Phone != smsCodeCommand.Phone {
  183 + return application.ThrowError(application.TRANSACTION_ERROR, "输入的手机号不是平台用户,请重新输入")
  184 + }
  185 + }
174 smsServeGateway := sms_serve.NewHttplibHttplibSmsServe() 186 smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
175 err := smsServeGateway.SendSms(smsCodeCommand.Phone) 187 err := smsServeGateway.SendSms(smsCodeCommand.Phone)
176 if err != nil { 188 if err != nil {
@@ -11,7 +11,7 @@ type SearchDividendContractsCommand struct { @@ -11,7 +11,7 @@ type SearchDividendContractsCommand struct {
11 //操作人 11 //操作人
12 Operator domain.Operator `json:"-"` 12 Operator domain.Operator `json:"-"`
13 // 查询偏离量 13 // 查询偏离量
14 - PageNumber int `json:"pageIndex" valid:"Required"` 14 + PageNumber int `json:"pageNumber" valid:"Required"`
15 // 查询限制 15 // 查询限制
16 PageSize int `json:"pageSize" valid:"Required"` 16 PageSize int `json:"pageSize" valid:"Required"`
17 //审核状态 17 //审核状态
@@ -8,6 +8,8 @@ import ( @@ -8,6 +8,8 @@ import (
8 8
9 type SendSmsCodeCommand struct { 9 type SendSmsCodeCommand struct {
10 Phone string `json:"phone" valid:"Required"` 10 Phone string `json:"phone" valid:"Required"`
  11 + // 0:无 1:需要账号存在于账号系统内,才能发送验证码
  12 + Flag int `json:"flag"`
11 } 13 }
12 14
13 func (orgAddCommand *SendSmsCodeCommand) Valid(validation *validation.Validation) { 15 func (orgAddCommand *SendSmsCodeCommand) Valid(validation *validation.Validation) {
@@ -19,6 +19,15 @@ type UserService struct { @@ -19,6 +19,15 @@ type UserService struct {
19 19
20 //SendSmsCaptcha 发送验证码短信 20 //SendSmsCaptcha 发送验证码短信
21 func (srv UserService) SendSmsCaptcha(smsCodeCommand *command.SendSmsCodeCommand) error { 21 func (srv UserService) SendSmsCaptcha(smsCodeCommand *command.SendSmsCodeCommand) error {
  22 + if smsCodeCommand.Flag == 1 {
  23 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
  24 + userBase, err := creationUserGateway.AuthUserBaseInfo(allied_creation_user.ReqAuthUserBase{
  25 + Account: smsCodeCommand.Phone,
  26 + })
  27 + if err != nil || userBase.UserInfo.Phone != smsCodeCommand.Phone {
  28 + return application.ThrowError(application.TRANSACTION_ERROR, "输入的手机号不是平台用户,请重新输入")
  29 + }
  30 + }
22 smsServeGateway := sms_serve.NewHttplibHttplibSmsServe() 31 smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
23 err := smsServeGateway.SendSms(smsCodeCommand.Phone) 32 err := smsServeGateway.SendSms(smsCodeCommand.Phone)
24 if err != nil { 33 if err != nil {