appeal.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package http
  2. import (
  3. "go-common/library/ecode"
  4. "go-common/library/log"
  5. bm "go-common/library/net/http/blademaster"
  6. "strconv"
  7. )
  8. func addAppeal(c *bm.Context) {
  9. var (
  10. err error
  11. params = c.Request.Form
  12. btid int64
  13. bid int64
  14. midI, _ = c.Get("mid")
  15. btidStr = params.Get("business_typeid")
  16. bidStr = params.Get("bid")
  17. reason = params.Get("reason")
  18. )
  19. if btid, err = strconv.ParseInt(btidStr, 10, 64); err != nil {
  20. log.Error("strconv.ParseInt err(err) %v", err)
  21. c.JSON(nil, ecode.RequestErr)
  22. return
  23. }
  24. if bid, err = strconv.ParseInt(bidStr, 10, 64); err != nil {
  25. log.Error("strconv.ParseInt err(err) %v", err)
  26. c.JSON(nil, ecode.RequestErr)
  27. return
  28. }
  29. if err = creditSvc.AddAppeal(c, btid, bid, midI.(int64), reason); err != nil {
  30. log.Error("creditSvc.AddAppeal error(%v)", err)
  31. c.JSON(nil, err)
  32. return
  33. }
  34. c.JSON(nil, nil)
  35. }
  36. func appealStatus(c *bm.Context) {
  37. var (
  38. err error
  39. params = c.Request.Form
  40. mid int64
  41. bid int64
  42. bidStr = params.Get("bid")
  43. )
  44. if bid, err = strconv.ParseInt(bidStr, 10, 64); err != nil {
  45. log.Error("strconv.ParseInt err(err) %v", err)
  46. c.JSON(nil, ecode.RequestErr)
  47. return
  48. }
  49. midI, ok := c.Get("mid")
  50. if ok {
  51. mid, _ = midI.(int64)
  52. }
  53. state, err := creditSvc.AppealState(c, mid, bid)
  54. if err != nil {
  55. log.Error("creditSvc.AppealState error(%v)", err)
  56. c.JSON(nil, err)
  57. return
  58. }
  59. // 未申述过 true, 已申诉过flase
  60. c.JSON(!state, nil)
  61. }