39 lines
931 B
Go
39 lines
931 B
Go
package provider
|
|
|
|
import (
|
|
. "code.hoteas.com/golang/hotime"
|
|
"code.hoteas.com/golang/hotime/common"
|
|
"code.hoteas.com/golang/hotime/dri/ddsms"
|
|
)
|
|
|
|
var Sms = Ctr{
|
|
//只允许微信验证过的或者登录成功的发送短信
|
|
"send": func(that *Context) {
|
|
|
|
phone := that.Req.FormValue("phone")
|
|
if len(phone) < 11 {
|
|
that.Display(3, "手机号格式错误")
|
|
return
|
|
}
|
|
|
|
if that.Session("wechat_id").Data == nil && that.Session("salesman_id").Data == nil {
|
|
that.Display(2, "没有登录不可发送短信")
|
|
return
|
|
}
|
|
|
|
salesman := that.Db.Get("salesman", "id", common.Map{"phone": phone})
|
|
if salesman == nil {
|
|
that.Display(3, "你还不是企服人员,请联系管理员")
|
|
return
|
|
}
|
|
|
|
code := getCode()
|
|
that.Session("phone", phone)
|
|
that.Session("code", code)
|
|
|
|
ddsms.DDY.SendYZM(phone, that.Config.GetString("smsLogin"), map[string]string{"code": code})
|
|
|
|
that.Display(0, "发送成功")
|
|
},
|
|
}
|