第三方api接口
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.

60 lines
1.5 KiB

  1. package fast_login
  2. import (
  3. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db"
  4. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/offical"
  5. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/offical/model"
  6. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  7. "fmt"
  8. "time"
  9. "xorm.io/xorm"
  10. )
  11. //数量
  12. func FastLoginNumGetSmsNum(engine *xorm.Engine, uid interface{}) int {
  13. numData := offical.GetFastLoginNum(engine, uid)
  14. num := 0
  15. if numData != nil {
  16. num = numData.Num
  17. }
  18. if num < 0 {
  19. num = 0
  20. }
  21. return num
  22. }
  23. //发送
  24. func FastLoginSend(engine *xorm.Engine, args map[string]interface{}) error {
  25. num := FastLoginNumGetSmsNum(engine, args["uid"])
  26. //存入记录
  27. ext := map[string]interface{}{
  28. "post": args,
  29. }
  30. var record = model.FastLoginRecord{
  31. OrdId: "",
  32. Uid: int(zhios_third_party_utils.AnyToInt64(args["uid"])),
  33. Amount: "1",
  34. CostPrice: "",
  35. Balance: zhios_third_party_utils.IntToStr(num - 1),
  36. PayWay: 0,
  37. State: 1,
  38. Memo: "一键登录",
  39. CreateAt: time.Now(),
  40. UpdateAt: time.Now(),
  41. TradeNo: "",
  42. Type: 1,
  43. OrdType: "buy",
  44. Fee: "",
  45. Ext: zhios_third_party_utils.SerializeStr(ext),
  46. Phone: args["mobile"].(string),
  47. }
  48. engine.InsertOne(&record)
  49. sql := `UPDATE fast_login_num_list set num=num-%d WHERE uid=%s ;`
  50. sql = fmt.Sprintf(sql, 1, args["uid"])
  51. fmt.Println(sql)
  52. nativeString, err := db.QueryNativeString(engine, sql)
  53. fmt.Println(nativeString)
  54. fmt.Println(err)
  55. return nil
  56. }