realname.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. package http
  2. import (
  3. "strconv"
  4. "strings"
  5. "go-common/app/service/main/member/api"
  6. "go-common/app/service/main/member/model"
  7. "go-common/library/ecode"
  8. "go-common/library/log"
  9. bm "go-common/library/net/http/blademaster"
  10. )
  11. func realnameStatus(ctx *bm.Context) {
  12. var (
  13. err error
  14. mid int64
  15. status model.RealnameStatus
  16. params = ctx.Request.Form
  17. midStr = params.Get("mid")
  18. )
  19. if mid, err = strconv.ParseInt(midStr, 10, 64); err != nil {
  20. ctx.JSON(nil, ecode.RequestErr)
  21. return
  22. }
  23. if status, err = memberSvc.RealnameStatus(ctx, mid); err != nil {
  24. log.Error("%+v", err)
  25. ctx.JSON(nil, err)
  26. return
  27. }
  28. var resData struct {
  29. Status model.RealnameStatus `json:"status"`
  30. }
  31. resData.Status = status
  32. ctx.JSON(resData, nil)
  33. }
  34. func realnameInfo(ctx *bm.Context) {
  35. var (
  36. err error
  37. mid int64
  38. params = ctx.Request.Form
  39. midStr = params.Get("mid")
  40. )
  41. if mid, err = strconv.ParseInt(midStr, 10, 64); err != nil {
  42. ctx.JSON(nil, ecode.RequestErr)
  43. return
  44. }
  45. ctx.JSON(memberSvc.RealnameBrief(ctx, mid))
  46. }
  47. func realnameTelCapture(ctx *bm.Context) {
  48. var (
  49. err error
  50. mid int64
  51. params = ctx.Request.Form
  52. midStr = params.Get("mid")
  53. )
  54. if mid, err = strconv.ParseInt(midStr, 10, 64); err != nil {
  55. ctx.JSON(nil, ecode.RequestErr)
  56. return
  57. }
  58. _, err = memberSvc.RealnameTelCapture(ctx, mid)
  59. ctx.JSON(nil, err)
  60. }
  61. func realnameCheckTelCapture(ctx *bm.Context) {
  62. var (
  63. err error
  64. param = &model.ParamRealnameTelCaptureCheck{}
  65. )
  66. if err = ctx.Bind(param); err != nil {
  67. return
  68. }
  69. ctx.JSON(nil, memberSvc.RealnameTelCaptureCheck(ctx, param.MID, param.Capture))
  70. }
  71. func realnameApplyStatus(ctx *bm.Context) {
  72. var (
  73. err error
  74. mid int64
  75. params = ctx.Request.Form
  76. midStr = params.Get("mid")
  77. )
  78. if mid, err = strconv.ParseInt(midStr, 10, 64); err != nil {
  79. ctx.JSON(nil, ecode.RequestErr)
  80. return
  81. }
  82. ctx.JSON(memberSvc.RealnameApplyStatus(ctx, mid))
  83. }
  84. func realnameApply(ctx *bm.Context) {
  85. var (
  86. err error
  87. params = ctx.Request.Form
  88. // res = c.Result()
  89. midStr = params.Get("mid")
  90. mid int64
  91. realname = params.Get("real_name")
  92. cardTypeStr = params.Get("card_type")
  93. cardType int64
  94. cardNum = params.Get("card_num")
  95. countryStr = params.Get("country")
  96. country int64
  97. captureStr = params.Get("capture")
  98. capture int64
  99. handIMGToken = params.Get("img1_token")
  100. frontIMGToken = params.Get("img2_token")
  101. backIMGToken = params.Get("img3_token")
  102. )
  103. if mid, err = strconv.ParseInt(midStr, 10, 64); err != nil {
  104. ctx.JSON(nil, ecode.RequestErr)
  105. return
  106. }
  107. if cardType, err = strconv.ParseInt(cardTypeStr, 10, 64); err != nil {
  108. ctx.JSON(nil, ecode.RequestErr)
  109. return
  110. }
  111. if country, err = strconv.ParseInt(countryStr, 10, 64); err != nil {
  112. ctx.JSON(nil, ecode.RequestErr)
  113. return
  114. }
  115. if capture, err = strconv.ParseInt(captureStr, 10, 64); err != nil {
  116. ctx.JSON(nil, ecode.RequestErr)
  117. return
  118. }
  119. ctx.JSON(nil, memberSvc.RealnameApply(ctx, mid, int(capture), realname, int8(cardType), cardNum, int16(country), handIMGToken, frontIMGToken, backIMGToken))
  120. }
  121. func realnameAdult(ctx *bm.Context) {
  122. var (
  123. err error
  124. params = ctx.Request.Form
  125. midStr = params.Get("mid")
  126. mid int64
  127. )
  128. if mid, err = strconv.ParseInt(midStr, 10, 64); err != nil {
  129. ctx.JSON(nil, ecode.RequestErr)
  130. return
  131. }
  132. var resp struct {
  133. Type model.RealnameAdultType `json:"type"`
  134. }
  135. resp.Type, err = memberSvc.RealnameAdult(ctx, mid)
  136. ctx.JSON(resp, err)
  137. }
  138. func realnameCheck(ctx *bm.Context) {
  139. var (
  140. err error
  141. param = &model.ParamRealnameCheck{}
  142. resp bool
  143. )
  144. if err = ctx.Bind(param); err != nil {
  145. return
  146. }
  147. resp, err = memberSvc.RealnameCheck(ctx, param.MID, param.CardType, strings.TrimSpace(param.CardCode))
  148. ctx.JSON(resp, err)
  149. }
  150. func realnameStrippedInfo(ctx *bm.Context) {
  151. arg := &model.ArgMid2{}
  152. if err := ctx.Bind(arg); err != nil {
  153. return
  154. }
  155. ctx.JSON(memberSvc.RealnameStrippedInfo(ctx, arg.Mid))
  156. }
  157. func realnameMidByCard(ctx *bm.Context) {
  158. arg := &api.MidByRealnameCardsReq{}
  159. if err := ctx.Bind(arg); err != nil {
  160. return
  161. }
  162. reply, err := memberSvc.MidByRealnameCard(ctx, arg)
  163. if err != nil {
  164. ctx.JSON(nil, err)
  165. return
  166. }
  167. ctx.JSON(reply.CodeToMid, nil)
  168. }