payment gateway for rpn cn
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

64 lines
1.5KB

  1. package main
  2. import (
  3. "errors"
  4. "time"
  5. )
  6. type LeanworkIn 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 time.Time
  18. Ip4 uint32
  19. Ip4Location string
  20. MD5Key string
  21. }
  22. //
  23. func lrIsIdMatchSign(id string, sign string) bool {
  24. _, err := getRequestRowByIdAndSign(id, sign)
  25. return err == nil
  26. }
  27. func getLeanworkInById(id int64) (row LeanworkIn, err error) {
  28. db.conn(Config)
  29. defer db.close()
  30. err = db.h.QueryRow("SELECT * FROM leanworkIn WHERE id=? ", id).Scan(
  31. &row.Id, &row.PickupUrl, &row.ReceiveUrl, &row.SignType,
  32. &row.OrderNo, &row.OrderAmount, &row.OrderCurrency, &row.CustomerId,
  33. &row.Sign, &row.Valid, &row.Ts, &row.Ip4, &row.Ip4Location, &row.MD5Key)
  34. return
  35. }
  36. func getRequestRowByIdAndSign(id string, sign string) (row LeanworkIn, err error) {
  37. //retrieve form DB
  38. db.conn(Config)
  39. defer db.close()
  40. selDB, err := db.h.Query("SELECT * FROM leanworkIn WHERE id=? and sign=?", id, sign)
  41. if err != nil {
  42. return
  43. }
  44. count := 0
  45. for selDB.Next() {
  46. err = selDB.Scan(&row.Id, &row.PickupUrl, &row.ReceiveUrl, &row.SignType,
  47. &row.OrderNo, &row.OrderAmount, &row.OrderCurrency, &row.CustomerId,
  48. &row.Sign, &row.Valid, &row.Ts, &row.Ip4, &row.Ip4Location, &row.MD5Key)
  49. if err != nil {
  50. return
  51. }
  52. count++
  53. }
  54. if count <= 0 {
  55. err = errors.New("no record found by the given id (" + id + ") and sign(" + sign + ")")
  56. }
  57. return
  58. }