distrib.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package http
  2. import (
  3. "github.com/pkg/errors"
  4. "go-common/app/service/openplatform/ticket-sales/model"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. func syncOrder(c *bm.Context) {
  9. orderStatusMap := make(map[int64]string)
  10. orderStatusMap[model.OrderPaid] = "已付款"
  11. orderStatusMap[model.OrderRefunded] = "已退款"
  12. arg := new(model.DistOrderArg)
  13. if err := c.Bind(arg); err != nil {
  14. errors.Wrap(err, "参数验证失败")
  15. return
  16. }
  17. _, ok := orderStatusMap[arg.Stat]
  18. if !ok {
  19. c.JSON("stat", ecode.TicketParamInvalid)
  20. return
  21. }
  22. if arg.Serial == "" {
  23. c.JSON("serial_num is empty", ecode.TicketParamInvalid)
  24. return
  25. }
  26. switch arg.Stat {
  27. case model.OrderPaid:
  28. arg.Stat = model.DistOrderNormal
  29. if arg.RefStat == model.OrderRefundPartly {
  30. arg.Stat = model.DistOrderRefunded
  31. }
  32. case model.OrderRefunded:
  33. arg.Stat = model.DistOrderRefunded
  34. }
  35. c.JSON(svc.SyncOrder(c, arg))
  36. }
  37. func getOrder(c *bm.Context) {
  38. arg := new(model.DistOrderGetArg)
  39. if err := c.Bind(arg); err != nil {
  40. errors.Wrap(err, "参数验证失败")
  41. return
  42. }
  43. c.JSON(svc.GetOrder(c, arg.Oid))
  44. }