micro-account/pkg/common/verifica/mobile.go
2025-03-13 14:38:24 +08:00

143 lines
3.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package verifica
import (
"errors"
"fmt"
"github.com/fonchain_enterprise/micro-account/pkg/config"
"github.com/fonchain_enterprise/utils/mobile"
)
//const SIG_NO = 230001
const SIG_NO = 155123
const SIG_NO_SELLER = 159789
func SendMsg(telNum string, project string) (string, error) {
var sigNo uint
sigNo = SIG_NO
if project == "seller" {
sigNo = SIG_NO_SELLER
}
mobileTemplate := config.GetMobile()
if telNum == "" {
return "", errors.New("手机号不合法")
}
code := mobile.RandCode()
//content := "验证码模板:尊敬的用户,您的验证码为$$15分钟内有效请勿泄露。"
fmt.Println("发送短信请求参数:", telNum, mobile.TMP1, sigNo, code)
/**
TODO
*/
/*
if telNum == "15895559080" {
dingding.Send(fmt.Sprintf("尊敬的用户,您的验证码为%s15分钟内有效请勿泄露。", code))
return code, nil
}
*/
fmt.Println("发送短信请求参数:", telNum, mobile.TMP1, sigNo, code)
return code, mobileTemplate.Send(telNum, mobile.TMP1, sigNo, code)
}
func SendMsgV2(telNum string, project string, tempSignNo uint) (string, error) {
var sigNo uint
sigNo = SIG_NO
//if project == "seller" {
// sigNo = SIG_NO_SELLER
//}
mobileTemplate := config.GetMobile()
//mobileTemplate := config.GetAlMobile()
if telNum == "" {
return "", errors.New("手机号不合法")
}
code := mobile.RandCode()
//content := "验证码模板:尊敬的用户,您的验证码为$$15分钟内有效请勿泄露。"
/**
TODO
*/
/*
if telNum == "15895559080" {
dingding.Send(fmt.Sprintf("尊敬的用户,您的验证码为%s15分钟内有效请勿泄露。", code))
return code, nil
}
*/
fmt.Println("发送短信请求参数:", telNum, mobile.TMP1, sigNo, code)
return code, mobileTemplate.Send(telNum, mobile.TMP1, sigNo, code)
//fmt.Println("发送短信请求参数:", telNum, mobile.Sign, mobile.AlTMP1, code)
//return code, mobileTemplate.SendAlSms(telNum, mobile.Sign, mobile.AlTMP1, code)
}
func SendCustomMsg(telNum string, url string, m uint) error {
var sigNo uint
sigNo = SIG_NO
mobileTemplate := config.GetMobile()
if telNum == "" {
return errors.New("手机号不合法")
}
/**
TODO
if telNum == "15895559080" {
arr := strings.Split(url, "||")
if len(arr) <= 1 {
fmt.Println("解析失败")
return nil
}
if m == 134802 {
dingding.Send(fmt.Sprintf("尊敬的用户,您的帐号登陆地址(%s)异常,请点击下线该帐号%s", arr[0], arr[1]))
return nil
} else if m == 136784 {
dingding.Send(fmt.Sprintf("尊敬的用户,%s等待您的审批请点击查看%s", arr[0], arr[1]))
return nil
}
}
*/
fmt.Println(telNum, m, sigNo, url)
return mobileTemplate.Send(telNum, m, sigNo, url)
}
func SendCustomCode(telNum string, templateId uint, sigNo uint) (string, error) {
mobileTemplate := config.GetMobile()
//mobileTemplate := config.GetAlMobile()
if telNum == "" {
return "", errors.New("手机号不合法")
}
code := mobile.RandCode()
fmt.Println("发送短信请求参数:", telNum, mobile.TMP1, sigNo, code)
//fmt.Println("发送短信请求参数:", telNum, mobile.Sign, mobile.AlTMP1, code)
return code, mobileTemplate.Send(telNum, templateId, sigNo, code)
//return code, mobileTemplate.SendAlSms(telNum, mobile.Sign, mobile.AlTMP1, code)
}
func SendCustomSignNoMsg(telNum string, url string, m uint, sigNo uint) error {
mobileTemplate := config.GetMobile()
//mobileTemplate := config.GetAlMobile()
if telNum == "" {
return errors.New("手机号不合法")
}
return mobileTemplate.Send(telNum, m, sigNo, url)
//return mobileTemplate.SendAlSms(telNum, mobile.Sign, mobile.AlTMP1, url)
}