trade.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package http
  2. import (
  3. "net/http"
  4. api "go-common/app/service/main/ugcpay/api/http"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. func tradePayRefund(ctx *bm.Context) {
  9. var (
  10. err error
  11. arg = &api.ArgTradeRefund{}
  12. )
  13. if err = ctx.Bind(arg); err != nil {
  14. return
  15. }
  16. ctx.JSON(nil, srv.TradeRefund(ctx, arg.OrderID))
  17. }
  18. func tradePayRefunds(ctx *bm.Context) {
  19. var (
  20. err error
  21. arg = &api.ArgTradeRefunds{}
  22. )
  23. if err = ctx.Bind(arg); err != nil {
  24. return
  25. }
  26. if len(arg.OrderIDs) > 20 {
  27. err = ecode.RequestErr
  28. return
  29. }
  30. ctx.JSON(nil, srv.TradeRefunds(ctx, arg.OrderIDs))
  31. }
  32. func tradePayCallback(ctx *bm.Context) {
  33. var (
  34. err error
  35. arg = &api.ArgTradeCallback{}
  36. retMSG string
  37. )
  38. if err = ctx.Bind(arg); err != nil {
  39. return
  40. }
  41. if retMSG, err = srv.TradePayCallback(ctx, arg.MSGID, arg.MSGContent); err != nil {
  42. ctx.JSON(nil, err)
  43. return
  44. }
  45. ctx.String(http.StatusOK, retMSG)
  46. }
  47. func tradePayRefundCallback(ctx *bm.Context) {
  48. var (
  49. err error
  50. arg = &api.ArgTradeCallback{}
  51. retMSG string
  52. )
  53. if err = ctx.Bind(arg); err != nil {
  54. return
  55. }
  56. if retMSG, err = srv.TradeRefundCallback(ctx, arg.MSGID, arg.MSGContent); err != nil {
  57. ctx.JSON(nil, err)
  58. return
  59. }
  60. ctx.String(http.StatusOK, retMSG)
  61. }
  62. func tradePayRechargeCallback(ctx *bm.Context) {
  63. var (
  64. err error
  65. arg = &api.ArgTradeCallback{}
  66. retMSG string
  67. )
  68. if err = ctx.Bind(arg); err != nil {
  69. return
  70. }
  71. if retMSG, err = srv.TradeRefundCallback(ctx, arg.MSGID, arg.MSGContent); err != nil {
  72. ctx.JSON(nil, err)
  73. return
  74. }
  75. ctx.String(http.StatusOK, retMSG)
  76. }