allowance.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package http
  2. import (
  3. "go-common/app/service/main/coupon/model"
  4. "go-common/library/log"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func useAllowance(c *bm.Context) {
  8. var err error
  9. arg := new(model.ArgUseAllowance)
  10. if err = c.Bind(arg); err != nil {
  11. return
  12. }
  13. c.JSON(nil, svc.UseAllowanceCoupon(c, arg))
  14. }
  15. func allowanceCount(c *bm.Context) {
  16. var (
  17. err error
  18. res []*model.CouponAllowanceInfo
  19. )
  20. arg := new(model.ArgCount)
  21. if err = c.Bind(arg); err != nil {
  22. return
  23. }
  24. res, err = svc.AllowanceCoupon(c, &model.ArgAllowanceCoupons{
  25. Mid: arg.Mid,
  26. State: model.NotUsed,
  27. })
  28. c.JSON(len(res), err)
  29. }
  30. func receiveAllowance(c *bm.Context) {
  31. var err error
  32. arg := new(model.ArgReceiveAllowance)
  33. if err = c.Bind(arg); err != nil {
  34. log.Error("receive allowance bind %+v", err)
  35. return
  36. }
  37. c.JSON(svc.ReceiveAllowance(c, arg))
  38. }
  39. func useNotify(c *bm.Context) {
  40. var err error
  41. arg := new(model.ArgAllowanceCheck)
  42. if err = c.Bind(arg); err != nil {
  43. return
  44. }
  45. c.JSON(svc.UseNotify(c, arg))
  46. }
  47. func prizeCards(c *bm.Context) {
  48. var err error
  49. arg := new(model.ArgCount)
  50. if err = c.Bind(arg); err != nil {
  51. return
  52. }
  53. c.JSON(svc.PrizeCards(c, arg.Mid))
  54. }
  55. func prizeDraw(c *bm.Context) {
  56. var err error
  57. arg := new(model.ArgPrizeDraw)
  58. if err = c.Bind(arg); err != nil {
  59. return
  60. }
  61. c.JSON(svc.PrizeDraw(c, arg.Mid, arg.CardType))
  62. }