accountType
This commit is contained in:
parent
9b0801fd34
commit
796650d161
|
@ -49,12 +49,10 @@ func (c *Config) orderReq(in *proto.OrderRequest) *api.OrderCreateReq {
|
|||
accountType := int64(0)
|
||||
if in.Order.Account == "" {
|
||||
accountType = 0
|
||||
} else {
|
||||
if helper.IsPhoneNumber(in.Order.Account) {
|
||||
accountType = 1
|
||||
} else {
|
||||
accountType = 2
|
||||
}
|
||||
} else if helper.IsPhoneNumber(in.Order.Account) {
|
||||
accountType = 1
|
||||
} else if helper.IsValidQQ(in.Order.Account) {
|
||||
accountType = 2
|
||||
}
|
||||
return &api.OrderCreateReq{
|
||||
OutTradeNo: in.Order.OrderNo, // 商户侧订单号长度只能是1-64位
|
||||
|
|
|
@ -19,12 +19,21 @@ func ToChinese(s string) string {
|
|||
return encodedName
|
||||
}
|
||||
|
||||
// IsPhoneNumber 检查给定的字符串是否为有效的手机号码
|
||||
func IsPhoneNumber(phoneNumber string) bool {
|
||||
phoneRegex := `^1[34578]\d{9}$`
|
||||
return regexp.MustCompile(phoneRegex).MatchString(phoneNumber)
|
||||
}
|
||||
|
||||
// IsEmail 检查给定的字符串是否为有效的电子邮箱地址
|
||||
func IsEmail(email string) bool {
|
||||
var emailRegex = regexp.MustCompile(`[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`)
|
||||
return emailRegex.MatchString(email)
|
||||
}
|
||||
|
||||
// IsValidQQ 检查给定的字符串是否为有效的 QQ 号
|
||||
func IsValidQQ(qq string) bool {
|
||||
// QQ号正则表达式:5到11位数字,且开头不为0的情况
|
||||
re := regexp.MustCompile(`^(?!0)[0-9]{5,11}$`)
|
||||
return re.MatchString(qq)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue