蛋蛋星球-客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

svc_sms.go 1.5 KiB

6 päivää sitten
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package svc
  2. import (
  3. "applet/app/e"
  4. "code.fnuoos.com/EggPlanet/egg_system_rules.git/aliyun"
  5. "code.fnuoos.com/EggPlanet/egg_system_rules.git/mob"
  6. "errors"
  7. "fmt"
  8. "github.com/gin-gonic/gin"
  9. )
  10. func CommSmsSend(c *gin.Context, mobile, types string) error {
  11. smsPlatform := GetSysCfgStr("sms_platform")
  12. var err error
  13. if smsPlatform == "mob" {
  14. err = mob.MobSms(GetSysCfgStr("mob_key"), mobile, GetSysCfgStr("mob_temple_code"))
  15. if err != nil {
  16. fmt.Println("短信错误:" + err.Error())
  17. return err
  18. }
  19. } else {
  20. data := AliyunSmsBase(c, types)
  21. //发送短信
  22. err = aliyun.AliyunSendSms(data["aliyun_sms_id"], data["aliyun_sms_secret"], mobile, data["aliyun_sms_sign_name"], data["aliyun_sms_code"], "")
  23. if err != nil {
  24. fmt.Println("短信错误:" + err.Error())
  25. return errors.New("发送失败")
  26. }
  27. }
  28. return nil
  29. }
  30. func CommSmsCheck(c *gin.Context, mobile, code string) error {
  31. //校验短信
  32. smsPlatform := GetSysCfgStr("sms_platform")
  33. var err error
  34. var bools bool
  35. if smsPlatform == "mob" {
  36. bools, err = mob.MobSMSCheck(GetSysCfgStr("mob_key"), mobile, code)
  37. if err != nil {
  38. fmt.Println("短信错误:" + err.Error())
  39. return err
  40. }
  41. if bools == false {
  42. return e.NewErr(400, "验证码错误,请重试")
  43. }
  44. } else {
  45. data := AliyunSmsBase(c, "")
  46. err = aliyun.AliyunCheckSms(data["aliyun_sms_id"], data["aliyun_sms_secret"], mobile, code)
  47. if err != nil {
  48. return e.NewErr(400, "验证码错误,请重试")
  49. }
  50. }
  51. return nil
  52. }