diff --git a/db/offical/db_sms_num_list.go b/db/offical/db_sms_num_list.go index 4d7ecb6..4532690 100644 --- a/db/offical/db_sms_num_list.go +++ b/db/offical/db_sms_num_list.go @@ -5,7 +5,7 @@ import ( "xorm.io/xorm" ) -func GetSmsNum(engine *xorm.Engine, smsType string, uid string) *model.SmsNumList { +func GetSmsNum(engine *xorm.Engine, smsType, uid interface{}) *model.SmsNumList { var data model.SmsNumList get, err := engine.Where("uid=? and type=?", uid, smsType).Get(&data) if get == false || err != nil { diff --git a/sms/api.go b/sms/api.go index 930388a..b718d77 100644 --- a/sms/api.go +++ b/sms/api.go @@ -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) num := 0 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"]) - ex := strings.Split(args["mobile"], ",") + ex := strings.Split(args["mobile"].(string), ",") if len(ex) == 0 { return errors.New("请输入手机号") } 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" { contentLen = 1 } @@ -52,7 +52,7 @@ func SmsSend(engine *xorm.Engine, args map[string]string) error { return errors.New("平台短信不足") } } - where := make(map[string]string) + where := make(map[string]interface{}) param := []string{ "content", //短信内容 "mobile", //号码多个以英文”,”号分割,最大 2000 个 @@ -61,13 +61,13 @@ func SmsSend(engine *xorm.Engine, args map[string]string) error { } for _, v := range param { if args[v] != "" { - where[v] = args[v] + where[v] = args[v].(string) } } send := "" var err error if args["type"] == "mob" { //mob - where = map[string]string{ + where = map[string]interface{}{ "appkey": args["smsmsg_key"], "zone": args["zone"], "phone": args["phone"], @@ -105,7 +105,7 @@ func SmsSend(engine *xorm.Engine, args map[string]string) error { } var record = model.SmsRecord{ 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)), CostPrice: "", 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: "", Type: 1, OrdType: "buy", - SubUid: zhios_third_party_utils.StrToInt(args["sub_uid"]), Fee: "", Ext: zhios_third_party_utils.SerializeStr(ext), - SmsType: args["sms_type"], + SmsType: args["sms_type"].(string), } engine.InsertOne(&record) 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) 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" post, err := zhios_third_party_utils.CurlPost(thisUrl, zhios_third_party_utils.SerializeStr(args), nil) fmt.Println(string(post))