payment gateway for rpn cn
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

55 行
1.2KB

  1. package main
  2. import (
  3. "errors"
  4. "github.com/go-sql-driver/mysql"
  5. )
  6. type LeanworkRequest struct {
  7. Id int64
  8. PickupUrl string
  9. ReceiveUrl string
  10. SignType string
  11. OrderNo string
  12. OrderAmount string
  13. OrderCurrency string
  14. CustomerId string
  15. Sign string
  16. Valid bool
  17. Ts mysql.NullTime
  18. Ip4 uint32
  19. Ip4Location string
  20. }
  21. //
  22. func lrIsIdMatchSign(id string, sign string) bool {
  23. _, err := getRequestRowByIdAndSign(id, sign)
  24. return err == nil
  25. }
  26. func getRequestRowByIdAndSign(id string, sign string) (row LeanworkRequest, err error) {
  27. //retrieve form DB
  28. row = LeanworkRequest{}
  29. db.conn(Config)
  30. selDB, err := db.h.Query("SELECT * FROM request WHERE id=? and sign=?", id, sign)
  31. if err != nil {
  32. return
  33. }
  34. count := 0
  35. for selDB.Next() {
  36. err = selDB.Scan(&row.Id, &row.PickupUrl, &row.ReceiveUrl, &row.SignType,
  37. &row.OrderNo, &row.OrderAmount, &row.OrderCurrency, &row.CustomerId,
  38. &row.Sign, &row.Valid, &row.Ts, &row.Ip4, &row.Ip4Location)
  39. if err != nil {
  40. return
  41. }
  42. count++
  43. }
  44. if count <= 0 {
  45. err = errors.New("no record found by the given id (" + id + ") and sign(" + sign + ")")
  46. }
  47. return
  48. }