|
@@ -15,7 +15,7 @@ import ( |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
//短信数量 |
|
|
//短信数量 |
|
|
func SmsNumGetSmsNum(engine *xorm.Engine, smsType, uid string) int { |
|
|
|
|
|
|
|
|
func SmsNumGetSmsNum(engine *xorm.Engine, smsType, uid interface{}) int { |
|
|
numData := offical.GetSmsNum(engine, smsType, uid) |
|
|
numData := offical.GetSmsNum(engine, smsType, uid) |
|
|
num := 0 |
|
|
num := 0 |
|
|
if numData != nil { |
|
|
if numData != nil { |
|
@@ -28,14 +28,14 @@ func SmsNumGetSmsNum(engine *xorm.Engine, smsType, uid string) int { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//发送短信 |
|
|
//发送短信 |
|
|
func SmsSend(engine *xorm.Engine, args map[string]string) error { |
|
|
|
|
|
|
|
|
func SmsSend(engine *xorm.Engine, args map[string]interface{}) error { |
|
|
num := SmsNumGetSmsNum(engine, args["sms_type"], args["uid"]) |
|
|
num := SmsNumGetSmsNum(engine, args["sms_type"], args["uid"]) |
|
|
ex := strings.Split(args["mobile"], ",") |
|
|
|
|
|
|
|
|
ex := strings.Split(args["mobile"].(string), ",") |
|
|
if len(ex) == 0 { |
|
|
if len(ex) == 0 { |
|
|
return errors.New("请输入手机号") |
|
|
return errors.New("请输入手机号") |
|
|
} |
|
|
} |
|
|
count := len(ex) |
|
|
count := len(ex) |
|
|
contentLen := php2go.Ceil(float64(len(args["content"])) / 4 / 70) |
|
|
|
|
|
|
|
|
contentLen := php2go.Ceil(float64(len(args["content"].(string))) / 4 / 70) |
|
|
if args["type"] == "mob" { |
|
|
if args["type"] == "mob" { |
|
|
contentLen = 1 |
|
|
contentLen = 1 |
|
|
} |
|
|
} |
|
@@ -52,7 +52,7 @@ func SmsSend(engine *xorm.Engine, args map[string]string) error { |
|
|
return errors.New("平台短信不足") |
|
|
return errors.New("平台短信不足") |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
where := make(map[string]string) |
|
|
|
|
|
|
|
|
where := make(map[string]interface{}) |
|
|
param := []string{ |
|
|
param := []string{ |
|
|
"content", //短信内容 |
|
|
"content", //短信内容 |
|
|
"mobile", //号码多个以英文”,”号分割,最大 2000 个 |
|
|
"mobile", //号码多个以英文”,”号分割,最大 2000 个 |
|
@@ -61,13 +61,13 @@ func SmsSend(engine *xorm.Engine, args map[string]string) error { |
|
|
} |
|
|
} |
|
|
for _, v := range param { |
|
|
for _, v := range param { |
|
|
if args[v] != "" { |
|
|
if args[v] != "" { |
|
|
where[v] = args[v] |
|
|
|
|
|
|
|
|
where[v] = args[v].(string) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
send := "" |
|
|
send := "" |
|
|
var err error |
|
|
var err error |
|
|
if args["type"] == "mob" { //mob |
|
|
if args["type"] == "mob" { //mob |
|
|
where = map[string]string{ |
|
|
|
|
|
|
|
|
where = map[string]interface{}{ |
|
|
"appkey": args["smsmsg_key"], |
|
|
"appkey": args["smsmsg_key"], |
|
|
"zone": args["zone"], |
|
|
"zone": args["zone"], |
|
|
"phone": args["phone"], |
|
|
"phone": args["phone"], |
|
@@ -105,7 +105,7 @@ func SmsSend(engine *xorm.Engine, args map[string]string) error { |
|
|
} |
|
|
} |
|
|
var record = model.SmsRecord{ |
|
|
var record = model.SmsRecord{ |
|
|
OrdId: "", |
|
|
OrdId: "", |
|
|
Uid: zhios_third_party_utils.StrToInt(args["uid"]), |
|
|
|
|
|
|
|
|
Uid: int(zhios_third_party_utils.AnyToInt64(args["uid"])), |
|
|
Amount: zhios_third_party_utils.IntToStr(count * int(contentLen)), |
|
|
Amount: zhios_third_party_utils.IntToStr(count * int(contentLen)), |
|
|
CostPrice: "", |
|
|
CostPrice: "", |
|
|
Balance: zhios_third_party_utils.IntToStr(num - count*int(contentLen)), |
|
|
Balance: zhios_third_party_utils.IntToStr(num - count*int(contentLen)), |
|
@@ -117,10 +117,9 @@ func SmsSend(engine *xorm.Engine, args map[string]string) error { |
|
|
TradeNo: "", |
|
|
TradeNo: "", |
|
|
Type: 1, |
|
|
Type: 1, |
|
|
OrdType: "buy", |
|
|
OrdType: "buy", |
|
|
SubUid: zhios_third_party_utils.StrToInt(args["sub_uid"]), |
|
|
|
|
|
Fee: "", |
|
|
Fee: "", |
|
|
Ext: zhios_third_party_utils.SerializeStr(ext), |
|
|
Ext: zhios_third_party_utils.SerializeStr(ext), |
|
|
SmsType: args["sms_type"], |
|
|
|
|
|
|
|
|
SmsType: args["sms_type"].(string), |
|
|
} |
|
|
} |
|
|
engine.InsertOne(&record) |
|
|
engine.InsertOne(&record) |
|
|
sql := `UPDATE sms_num_list set num=num-%d WHERE uid=%s and type=%s;` |
|
|
sql := `UPDATE sms_num_list set num=num-%d WHERE uid=%s and type=%s;` |
|
@@ -153,7 +152,7 @@ func SmsApiSend(engine *xorm.Engine, method string, args map[string]string) (str |
|
|
fmt.Println(err) |
|
|
fmt.Println(err) |
|
|
return string(post), err |
|
|
return string(post), err |
|
|
} |
|
|
} |
|
|
func SmsMobApiSend(args map[string]string) (string, error) { |
|
|
|
|
|
|
|
|
func SmsMobApiSend(args map[string]interface{}) (string, error) { |
|
|
thisUrl := "https://webapi.sms.mob.com/sms/sendmsg" |
|
|
thisUrl := "https://webapi.sms.mob.com/sms/sendmsg" |
|
|
post, err := zhios_third_party_utils.CurlPost(thisUrl, zhios_third_party_utils.SerializeStr(args), nil) |
|
|
post, err := zhios_third_party_utils.CurlPost(thisUrl, zhios_third_party_utils.SerializeStr(args), nil) |
|
|
fmt.Println(string(post)) |
|
|
fmt.Println(string(post)) |
|
|