|
@@ -6,10 +6,17 @@ import ( |
|
|
"applet/app/lib/validate" |
|
|
"applet/app/lib/validate" |
|
|
"applet/app/md" |
|
|
"applet/app/md" |
|
|
"applet/app/svc" |
|
|
"applet/app/svc" |
|
|
|
|
|
"applet/app/utils" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/sms" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/sms" |
|
|
|
|
|
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" |
|
|
|
|
|
db "code.fnuoos.com/zhimeng/model.git/src" |
|
|
"code.fnuoos.com/zhimeng/model.git/src/implement" |
|
|
"code.fnuoos.com/zhimeng/model.git/src/implement" |
|
|
|
|
|
implement3 "code.fnuoos.com/zhimeng/model.git/src/super/implement" |
|
|
|
|
|
"code.fnuoos.com/zhimeng/model.git/src/super/model" |
|
|
|
|
|
"fmt" |
|
|
"github.com/gin-gonic/gin" |
|
|
"github.com/gin-gonic/gin" |
|
|
"github.com/tidwall/gjson" |
|
|
"github.com/tidwall/gjson" |
|
|
|
|
|
"time" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
// Sms |
|
|
// Sms |
|
@@ -33,8 +40,8 @@ func Sms(c *gin.Context) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
if args.Type == "fast_login" { |
|
|
if args.Type == "fast_login" { |
|
|
NewAdminDb := implement.NewAdminDb(svc.MasterDb(c)) |
|
|
|
|
|
admin, _ := NewAdminDb.GetAdminByUserName(args.Phone) |
|
|
|
|
|
|
|
|
NewAdminDb := implement.NewMediumDb(svc.MasterDb(c)) |
|
|
|
|
|
admin, _ := NewAdminDb.GetMediumByUsername(args.Phone) |
|
|
if admin == nil { |
|
|
if admin == nil { |
|
|
e.OutErr(c, 400, e.NewErr(400, "账号未注册")) |
|
|
e.OutErr(c, 400, e.NewErr(400, "账号未注册")) |
|
|
return |
|
|
return |
|
@@ -54,6 +61,11 @@ func Sms(c *gin.Context) { |
|
|
e.OutErr(c, 400, e.NewErr(400, "appkey不存在")) |
|
|
e.OutErr(c, 400, e.NewErr(400, "appkey不存在")) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
count := SmsNumGetSmsNum(c.GetString("mid")) |
|
|
|
|
|
if count-1 < 0 { |
|
|
|
|
|
e.OutErr(c, 400, e.NewErr(400, "短信数量不足")) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
where := map[string]interface{}{ |
|
|
where := map[string]interface{}{ |
|
|
"appkey": key, |
|
|
"appkey": key, |
|
|
"zone": "86", |
|
|
"zone": "86", |
|
@@ -78,6 +90,48 @@ func Sms(c *gin.Context) { |
|
|
e.OutErr(c, 400, e.NewErr(400, msg)) |
|
|
e.OutErr(c, 400, e.NewErr(400, msg)) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
//存入记录 |
|
|
|
|
|
ext := map[string]interface{}{ |
|
|
|
|
|
"send": send, |
|
|
|
|
|
"post": where, |
|
|
|
|
|
} |
|
|
|
|
|
var record = model.SmsRecord{ |
|
|
|
|
|
OrdId: "", |
|
|
|
|
|
Uid: utils.StrToInt(c.GetString("mid")), |
|
|
|
|
|
Amount: "1", |
|
|
|
|
|
CostPrice: "", |
|
|
|
|
|
Balance: zhios_third_party_utils.IntToStr(count - 1), |
|
|
|
|
|
PayWay: 0, |
|
|
|
|
|
State: 1, |
|
|
|
|
|
Memo: "发送短信", |
|
|
|
|
|
CreateAt: time.Now(), |
|
|
|
|
|
UpdateAt: time.Now(), |
|
|
|
|
|
TradeNo: "", |
|
|
|
|
|
Type: 1, |
|
|
|
|
|
OrdType: "buy", |
|
|
|
|
|
Fee: "", |
|
|
|
|
|
Ext: zhios_third_party_utils.SerializeStr(ext), |
|
|
|
|
|
Phone: args.Phone, |
|
|
|
|
|
} |
|
|
|
|
|
db.Db.InsertOne(&record) |
|
|
|
|
|
sql := `UPDATE sms_num_list set num=num-%d WHERE uid=%s ;` |
|
|
|
|
|
sql = fmt.Sprintf(sql, 1, c.GetString("mid")) |
|
|
|
|
|
fmt.Println(sql) |
|
|
|
|
|
nativeString, err := db.QueryNativeString(db.Db, sql) |
|
|
|
|
|
fmt.Println(nativeString) |
|
|
|
|
|
fmt.Println(err) |
|
|
e.OutSuc(c, "success", nil) |
|
|
e.OutSuc(c, "success", nil) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
func SmsNumGetSmsNum(uid interface{}) int { |
|
|
|
|
|
NewSmsNumListDb := implement3.NewSmsNumListDb(db.Db) |
|
|
|
|
|
numData := NewSmsNumListDb.GetSmsNum(uid) |
|
|
|
|
|
num := 0 |
|
|
|
|
|
if numData != nil { |
|
|
|
|
|
num = numData.Num |
|
|
|
|
|
} |
|
|
|
|
|
if num < 0 { |
|
|
|
|
|
num = 0 |
|
|
|
|
|
} |
|
|
|
|
|
return num |
|
|
|
|
|
} |