unicom.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. package http
  2. import (
  3. "encoding/base64"
  4. "encoding/json"
  5. "io/ioutil"
  6. "net/http"
  7. "net/url"
  8. "strconv"
  9. "time"
  10. "go-common/app/interface/main/app-wall/model"
  11. "go-common/app/interface/main/app-wall/model/unicom"
  12. "go-common/library/ecode"
  13. log "go-common/library/log"
  14. bm "go-common/library/net/http/blademaster"
  15. "go-common/library/net/metadata"
  16. )
  17. // ordersSync
  18. func ordersSync(c *bm.Context) {
  19. res := map[string]interface{}{}
  20. unicom, err := requestJSONToMap(c.Request)
  21. if err != nil {
  22. res["result"] = "1"
  23. res["errorcode"] = "100"
  24. log.Error("unicom_ioutil.ReadAll error (%v)", err)
  25. returnDataJSON(c, res, ecode.RequestErr)
  26. return
  27. }
  28. usermob, err := url.QueryUnescape(unicom.Usermob)
  29. if err != nil {
  30. log.Error("unicom_url.QueryUnescape (%v) error (%v)", unicom.Usermob, err)
  31. res["result"] = "1"
  32. res["errorcode"] = "100"
  33. returnDataJSON(c, res, ecode.RequestErr)
  34. return
  35. }
  36. var (
  37. _aesKey = []byte("9ed226d9")
  38. )
  39. bs, err := base64.StdEncoding.DecodeString(usermob)
  40. if err != nil {
  41. log.Error("base64.StdEncoding.DecodeString(%s) error(%v)", usermob, err)
  42. c.JSON(nil, ecode.RequestErr)
  43. return
  44. }
  45. bs, err = unicomSvc.DesDecrypt(bs, _aesKey)
  46. if err != nil {
  47. log.Error("unicomSvc.DesDecrypt error(%v)", err)
  48. c.JSON(nil, ecode.RequestErr)
  49. return
  50. }
  51. var usermobStr string
  52. if len(bs) > 32 {
  53. usermobStr = string(bs[:32])
  54. } else {
  55. usermobStr = string(bs)
  56. }
  57. log.Info("unicomSvc.OrdersSync_usermob (%v) unicom (%v)", usermobStr, unicom)
  58. if err := unicomSvc.InOrdersSync(c, usermobStr, metadata.String(c, metadata.RemoteIP), unicom, time.Now()); err != nil {
  59. log.Error("unicomSvc.OrdersSync usermob (%v) unicom (%v) error (%v)", usermobStr, unicom, err)
  60. res["result"] = "1"
  61. res["errorcode"] = "100"
  62. returnDataJSON(c, res, err)
  63. return
  64. }
  65. res["result"] = "0"
  66. res["message"] = ""
  67. res["errorcode"] = ""
  68. returnDataJSON(c, res, nil)
  69. }
  70. // advanceSync
  71. func advanceSync(c *bm.Context) {
  72. res := map[string]interface{}{}
  73. unicom, err := requestJSONToMap(c.Request)
  74. if err != nil {
  75. res["result"] = "1"
  76. res["errorcode"] = "100"
  77. log.Error("unicom_ioutil.ReadAll error (%v)", err)
  78. returnDataJSON(c, res, ecode.RequestErr)
  79. return
  80. }
  81. usermob, err := url.QueryUnescape(unicom.Usermob)
  82. if err != nil {
  83. log.Error("unicom_url.QueryUnescape (%v) error (%v)", unicom.Usermob, err)
  84. res["result"] = "1"
  85. res["errorcode"] = "100"
  86. returnDataJSON(c, res, ecode.RequestErr)
  87. return
  88. }
  89. var (
  90. _aesKey = []byte("9ed226d9")
  91. )
  92. bs, err := base64.StdEncoding.DecodeString(usermob)
  93. if err != nil {
  94. log.Error("base64.StdEncoding.DecodeString(%s) error(%v)", usermob, err)
  95. c.JSON(nil, ecode.RequestErr)
  96. return
  97. }
  98. bs, err = unicomSvc.DesDecrypt(bs, _aesKey)
  99. if err != nil {
  100. log.Error("unicomSvc.DesDecrypt error(%v)", err)
  101. c.JSON(nil, ecode.RequestErr)
  102. return
  103. }
  104. var usermobStr string
  105. if len(bs) > 32 {
  106. usermobStr = string(bs[:32])
  107. } else {
  108. usermobStr = string(bs)
  109. }
  110. log.Info("unicomSvc.AdvanceSync_usermob (%v) unicom (%v)", usermobStr, unicom)
  111. if err := unicomSvc.InAdvanceSync(c, usermobStr, metadata.String(c, metadata.RemoteIP), unicom, time.Now()); err != nil {
  112. log.Error("unicomSvc.InAdvanceSync usermob (%v) unicom (%v) error (%v)", usermobStr, unicom, err)
  113. res["result"] = "1"
  114. res["errorcode"] = "100"
  115. returnDataJSON(c, res, err)
  116. return
  117. }
  118. res["result"] = "0"
  119. res["message"] = ""
  120. res["errorcode"] = ""
  121. returnDataJSON(c, res, nil)
  122. }
  123. // flowSync
  124. func flowSync(c *bm.Context) {
  125. res := map[string]interface{}{}
  126. unicom, err := requestJSONToMap(c.Request)
  127. if err != nil {
  128. res["result"] = "1"
  129. res["errorcode"] = "100"
  130. log.Error("unicom_ioutil.ReadAll error (%v)", err)
  131. returnDataJSON(c, res, ecode.RequestErr)
  132. return
  133. }
  134. var flowbyte float64
  135. if flowbyte, err = strconv.ParseFloat(unicom.FlowbyteStr, 64); err != nil {
  136. log.Error("unicom_flowbyte strconv.ParseFloat(%s) error(%v)", unicom.FlowbyteStr, err)
  137. res["result"] = "1"
  138. res["errorcode"] = "100"
  139. returnDataJSON(c, res, ecode.RequestErr)
  140. return
  141. }
  142. usermob, err := url.QueryUnescape(unicom.Usermob)
  143. if err != nil {
  144. log.Error("unicom_url.QueryUnescape (%v) error (%v)", unicom.Usermob, err)
  145. res["result"] = "1"
  146. res["errorcode"] = "100"
  147. returnDataJSON(c, res, ecode.RequestErr)
  148. return
  149. }
  150. var (
  151. _aesKey = []byte("9ed226d9")
  152. )
  153. bs, err := base64.StdEncoding.DecodeString(usermob)
  154. if err != nil {
  155. log.Error("unicom_base64.StdEncoding.DecodeString(%s) error(%v)", usermob, err)
  156. c.JSON(nil, ecode.RequestErr)
  157. return
  158. }
  159. bs, err = unicomSvc.DesDecrypt(bs, _aesKey)
  160. if err != nil {
  161. log.Error("unicomSvc.DesDecrypt error(%v)", err)
  162. c.JSON(nil, ecode.RequestErr)
  163. return
  164. }
  165. var usermobStr string
  166. if len(bs) > 32 {
  167. usermobStr = string(bs[:32])
  168. } else {
  169. usermobStr = string(bs)
  170. }
  171. if err := unicomSvc.FlowSync(c, int(flowbyte*1024), usermobStr, unicom.Time, metadata.String(c, metadata.RemoteIP), time.Now()); err != nil {
  172. log.Error("unicomSvc.FlowSync error (%v)", err)
  173. res["result"] = "1"
  174. res["errorcode"] = "100"
  175. returnDataJSON(c, res, err)
  176. return
  177. }
  178. res["result"] = "0"
  179. res["message"] = ""
  180. res["errorcode"] = ""
  181. returnDataJSON(c, res, nil)
  182. }
  183. // inIPSync
  184. func inIPSync(c *bm.Context) {
  185. res := map[string]interface{}{}
  186. unicom, err := requestIPJSONToMap(c.Request)
  187. if err != nil {
  188. res["result"] = "1"
  189. res["errorcode"] = "100"
  190. log.Error("unicom_ioutil.ReadAll error (%v)", err)
  191. returnDataJSON(c, res, ecode.RequestErr)
  192. return
  193. }
  194. log.Info("unicomSvc.InIpSync_unicom (%v)", unicom)
  195. if err := unicomSvc.InIPSync(c, metadata.String(c, metadata.RemoteIP), unicom, time.Now()); err != nil {
  196. log.Error("unicomSvc.InIpSync unicom (%v) error (%v)", unicom, err)
  197. res["result"] = "1"
  198. res["errorcode"] = "100"
  199. returnDataJSON(c, res, err)
  200. return
  201. }
  202. res["result"] = "0"
  203. res["message"] = ""
  204. res["errorcode"] = ""
  205. returnDataJSON(c, res, nil)
  206. }
  207. // userFlow
  208. func userFlow(c *bm.Context) {
  209. res := map[string]interface{}{}
  210. params := c.Request.Form
  211. usermob := params.Get("usermob")
  212. mobiApp := params.Get("mobi_app")
  213. buildStr := params.Get("build")
  214. build, _ := strconv.Atoi(buildStr)
  215. ipStr := metadata.String(c, metadata.RemoteIP)
  216. data, msg, err := unicomSvc.UserFlow(c, usermob, mobiApp, ipStr, build, time.Now())
  217. if err != nil {
  218. res["message"] = msg
  219. returnDataJSON(c, res, err)
  220. return
  221. }
  222. res["data"] = data
  223. returnDataJSON(c, res, nil)
  224. }
  225. // userFlowState
  226. func userFlowState(c *bm.Context) {
  227. params := c.Request.Form
  228. usermob := params.Get("usermob")
  229. data, err := unicomSvc.UserFlowState(c, usermob, time.Now())
  230. if err != nil {
  231. c.JSON(nil, err)
  232. return
  233. }
  234. res := map[string]interface{}{
  235. "data": data,
  236. }
  237. returnDataJSON(c, res, nil)
  238. }
  239. // userState
  240. func userState(c *bm.Context) {
  241. res := map[string]interface{}{}
  242. params := c.Request.Form
  243. usermob := params.Get("usermob")
  244. mobiApp := params.Get("mobi_app")
  245. buildStr := params.Get("build")
  246. build, _ := strconv.Atoi(buildStr)
  247. ipStr := metadata.String(c, metadata.RemoteIP)
  248. data, msg, err := unicomSvc.UserState(c, usermob, mobiApp, ipStr, build, time.Now())
  249. if err != nil {
  250. res["message"] = msg
  251. returnDataJSON(c, res, err)
  252. return
  253. }
  254. res["data"] = data
  255. returnDataJSON(c, res, nil)
  256. }
  257. // unicomState
  258. func unicomState(c *bm.Context) {
  259. params := c.Request.Form
  260. usermob := params.Get("usermob")
  261. mobiApp := params.Get("mobi_app")
  262. buildStr := params.Get("build")
  263. build, _ := strconv.Atoi(buildStr)
  264. ipStr := metadata.String(c, metadata.RemoteIP)
  265. data, err := unicomSvc.UnicomState(c, usermob, mobiApp, ipStr, build, time.Now())
  266. if err != nil {
  267. c.JSON(nil, err)
  268. return
  269. }
  270. res := map[string]interface{}{
  271. "data": data,
  272. }
  273. returnDataJSON(c, res, nil)
  274. }
  275. // unicomStateM
  276. func unicomStateM(c *bm.Context) {
  277. params := c.Request.Form
  278. usermob := params.Get("usermob")
  279. mobiApp := params.Get("mobi_app")
  280. buildStr := params.Get("build")
  281. build, _ := strconv.Atoi(buildStr)
  282. ipStr := metadata.String(c, metadata.RemoteIP)
  283. var (
  284. _aesKey = []byte("9ed226d9")
  285. )
  286. bs, err := base64.StdEncoding.DecodeString(usermob)
  287. if err != nil {
  288. log.Error("base64.StdEncoding.DecodeString(%s) error(%v)", usermob, err)
  289. c.JSON(nil, ecode.RequestErr)
  290. return
  291. }
  292. bs, err = unicomSvc.DesDecrypt(bs, _aesKey)
  293. if err != nil {
  294. log.Error("unicomSvc.DesDecrypt error(%v)", err)
  295. c.JSON(nil, ecode.RequestErr)
  296. return
  297. }
  298. var usermobStr string
  299. if len(bs) > 32 {
  300. usermobStr = string(bs[:32])
  301. } else {
  302. usermobStr = string(bs)
  303. }
  304. data, err := unicomSvc.UnicomState(c, usermobStr, mobiApp, ipStr, build, time.Now())
  305. if err != nil {
  306. c.JSON(nil, err)
  307. return
  308. }
  309. res := map[string]interface{}{
  310. "data": data,
  311. }
  312. returnDataJSON(c, res, nil)
  313. }
  314. // RequestJsonToMap
  315. func requestJSONToMap(request *http.Request) (unicom *unicom.UnicomJson, err error) {
  316. body, err := ioutil.ReadAll(request.Body)
  317. if err != nil {
  318. log.Error("unicom_ioutil.ReadAll error (%v)", err)
  319. return
  320. }
  321. defer request.Body.Close()
  322. if len(body) == 0 {
  323. err = ecode.RequestErr
  324. return
  325. }
  326. log.Info("unicom orders json body(%s)", body)
  327. if err = json.Unmarshal(body, &unicom); err != nil {
  328. log.Error("json.Unmarshal UnicomJson(%v) error (%v)", unicom, err)
  329. return
  330. }
  331. if err = unicom.UnicomJSONChange(); err != nil {
  332. log.Error("unicom.UnicomJSONChange unicom (%v) error (%v)", unicom, err)
  333. }
  334. return
  335. }
  336. // RequestIpJsonToMap
  337. func requestIPJSONToMap(request *http.Request) (unicom *unicom.UnicomIpJson, err error) {
  338. body, err := ioutil.ReadAll(request.Body)
  339. if err != nil {
  340. log.Error("unicom_ioutil.ReadAll error (%v)", err)
  341. return
  342. }
  343. defer request.Body.Close()
  344. if len(body) == 0 {
  345. err = ecode.RequestErr
  346. return
  347. }
  348. log.Info("unicom ip json body(%s)", body)
  349. json.Unmarshal(body, &unicom)
  350. return
  351. }
  352. func pack(c *bm.Context) {
  353. var mid int64
  354. res := map[string]interface{}{}
  355. params := c.Request.Form
  356. usermob := params.Get("usermob")
  357. midInter, _ := c.Get("mid")
  358. mid = midInter.(int64)
  359. msg, err := unicomSvc.Pack(c, usermob, mid, time.Now())
  360. if err != nil {
  361. res["message"] = msg
  362. returnDataJSON(c, res, err)
  363. return
  364. }
  365. res["message"] = msg
  366. returnDataJSON(c, res, nil)
  367. }
  368. func isUnciomIP(c *bm.Context) {
  369. params := c.Request.Form
  370. mobiApp := params.Get("mobi_app")
  371. buildStr := params.Get("build")
  372. build, _ := strconv.Atoi(buildStr)
  373. ipStr := metadata.String(c, metadata.RemoteIP)
  374. ip := model.InetAtoN(ipStr)
  375. if err := unicomSvc.IsUnciomIP(ip, ipStr, mobiApp, build, time.Now()); err != nil {
  376. log.Error("unicom_user_ip:%v", ipStr)
  377. c.JSON(nil, err)
  378. }
  379. res := map[string]interface{}{
  380. "code": ecode.OK,
  381. }
  382. returnDataJSON(c, res, nil)
  383. }
  384. func userUnciomIP(c *bm.Context) {
  385. params := c.Request.Form
  386. usermob := params.Get("usermob")
  387. mobiApp := params.Get("mobi_app")
  388. buildStr := params.Get("build")
  389. build, _ := strconv.Atoi(buildStr)
  390. ipStr := metadata.String(c, metadata.RemoteIP)
  391. ip := model.InetAtoN(ipStr)
  392. res := map[string]interface{}{}
  393. res["data"] = unicomSvc.UserUnciomIP(ip, ipStr, usermob, mobiApp, build, time.Now())
  394. returnDataJSON(c, res, nil)
  395. }
  396. func orderPay(c *bm.Context) {
  397. res := map[string]interface{}{}
  398. params := c.Request.Form
  399. usermob := params.Get("usermob")
  400. channel := params.Get("channel")
  401. ordertypeStr := params.Get("ordertype")
  402. ordertype, _ := strconv.Atoi(ordertypeStr)
  403. data, msg, err := unicomSvc.Order(c, usermob, channel, ordertype, time.Now())
  404. if err != nil {
  405. res["message"] = msg
  406. returnDataJSON(c, res, err)
  407. return
  408. }
  409. res["data"] = data
  410. returnDataJSON(c, res, nil)
  411. }
  412. func orderCancel(c *bm.Context) {
  413. res := map[string]interface{}{}
  414. params := c.Request.Form
  415. usermob := params.Get("usermob")
  416. data, msg, err := unicomSvc.CancelOrder(c, usermob)
  417. if err != nil {
  418. res["message"] = msg
  419. returnDataJSON(c, res, err)
  420. return
  421. }
  422. res["data"] = data
  423. returnDataJSON(c, res, nil)
  424. }
  425. func smsCode(c *bm.Context) {
  426. res := map[string]interface{}{}
  427. params := c.Request.Form
  428. phone := params.Get("phone")
  429. msg, err := unicomSvc.UnicomSMSCode(c, phone, time.Now())
  430. if err != nil {
  431. res["message"] = msg
  432. returnDataJSON(c, res, err)
  433. return
  434. }
  435. res["message"] = msg
  436. returnDataJSON(c, res, nil)
  437. }
  438. func addUnicomBind(c *bm.Context) {
  439. res := map[string]interface{}{}
  440. params := c.Request.Form
  441. phone := params.Get("phone")
  442. codeStr := params.Get("code")
  443. code, err := strconv.Atoi(codeStr)
  444. if err != nil {
  445. log.Error("code(%v) strconv.Atoi error(%v)", codeStr, err)
  446. res["message"] = "参数错误"
  447. returnDataJSON(c, res, ecode.RequestErr)
  448. return
  449. }
  450. var mid int64
  451. midInter, ok := c.Get("mid")
  452. if ok {
  453. mid = midInter.(int64)
  454. } else {
  455. res["message"] = "账号未登录"
  456. returnDataJSON(c, res, ecode.RequestErr)
  457. return
  458. }
  459. msg, err := unicomSvc.AddUnicomBind(c, phone, code, mid, time.Now())
  460. if err != nil {
  461. res["code"] = err
  462. res["message"] = msg
  463. returnDataJSON(c, res, err)
  464. return
  465. }
  466. res["message"] = msg
  467. returnDataJSON(c, res, nil)
  468. }
  469. func releaseUnicomBind(c *bm.Context) {
  470. res := map[string]interface{}{}
  471. params := c.Request.Form
  472. phoneStr := params.Get("phone")
  473. phone, err := strconv.Atoi(phoneStr)
  474. if err != nil {
  475. log.Error("phone(%v) strconv.Atoi error(%v)", phoneStr, err)
  476. res["message"] = "参数错误"
  477. returnDataJSON(c, res, ecode.RequestErr)
  478. return
  479. }
  480. var mid int64
  481. midInter, ok := c.Get("mid")
  482. if ok {
  483. mid = midInter.(int64)
  484. } else {
  485. res["message"] = "账号未登录"
  486. returnDataJSON(c, res, ecode.RequestErr)
  487. return
  488. }
  489. msg, err := unicomSvc.ReleaseUnicomBind(c, mid, phone)
  490. if err != nil {
  491. res["message"] = msg
  492. returnDataJSON(c, res, err)
  493. return
  494. }
  495. res["message"] = msg
  496. returnDataJSON(c, res, nil)
  497. }
  498. func userBind(c *bm.Context) {
  499. res := map[string]interface{}{}
  500. var mid int64
  501. midInter, ok := c.Get("mid")
  502. if ok {
  503. mid = midInter.(int64)
  504. } else {
  505. res["message"] = "账号未登录"
  506. returnDataJSON(c, res, ecode.RequestErr)
  507. return
  508. }
  509. data, msg, err := unicomSvc.UserBind(c, mid)
  510. if err != nil {
  511. res["message"] = msg
  512. returnDataJSON(c, res, err)
  513. return
  514. }
  515. res["data"] = data
  516. res["message"] = ""
  517. returnDataJSON(c, res, nil)
  518. }
  519. func packList(c *bm.Context) {
  520. res := map[string]interface{}{
  521. "data": unicomSvc.UnicomPackList(),
  522. }
  523. returnDataJSON(c, res, nil)
  524. }
  525. func packReceive(c *bm.Context) {
  526. res := map[string]interface{}{}
  527. params := c.Request.Form
  528. idStr := params.Get("id")
  529. id, err := strconv.ParseInt(idStr, 10, 64)
  530. if err != nil {
  531. log.Error("id(%v) strconv.ParseInt error(%v)", idStr, err)
  532. c.JSON(nil, err)
  533. return
  534. }
  535. var mid int64
  536. midInter, ok := c.Get("mid")
  537. if ok {
  538. mid = midInter.(int64)
  539. } else {
  540. res["message"] = "账号未登录"
  541. returnDataJSON(c, res, ecode.RequestErr)
  542. return
  543. }
  544. msg, err := unicomSvc.UnicomPackReceive(c, mid, id, time.Now())
  545. if err != nil {
  546. res["message"] = msg
  547. returnDataJSON(c, res, err)
  548. return
  549. }
  550. res["message"] = msg
  551. returnDataJSON(c, res, nil)
  552. }
  553. func flowPack(c *bm.Context) {
  554. res := map[string]interface{}{}
  555. params := c.Request.Form
  556. var mid int64
  557. midInter, ok := c.Get("mid")
  558. if ok {
  559. mid = midInter.(int64)
  560. } else {
  561. res["message"] = "账号未登录"
  562. returnDataJSON(c, res, ecode.RequestErr)
  563. return
  564. }
  565. flowID := params.Get("flow_id")
  566. msg, err := unicomSvc.UnicomFlowPack(c, mid, flowID, time.Now())
  567. if err != nil {
  568. res["message"] = msg
  569. returnDataJSON(c, res, err)
  570. return
  571. }
  572. res["message"] = msg
  573. returnDataJSON(c, res, nil)
  574. }
  575. func userPacksLog(c *bm.Context) {
  576. params := c.Request.Form
  577. starttimeStr := params.Get("starttime")
  578. pnStr := params.Get("pn")
  579. pn, err := strconv.Atoi(pnStr)
  580. if err != nil {
  581. c.JSON(nil, ecode.RequestErr)
  582. return
  583. }
  584. if pn < 1 {
  585. pn = 1
  586. }
  587. timeLayout := "2006-01"
  588. loc, _ := time.LoadLocation("Local")
  589. startTime, err := time.ParseInLocation(timeLayout, starttimeStr, loc)
  590. if err != nil {
  591. c.JSON(nil, ecode.RequestErr)
  592. return
  593. }
  594. c.JSON(unicomSvc.UserPacksLog(c, startTime, time.Now(), pn, metadata.String(c, metadata.RemoteIP)))
  595. }
  596. func userBindLog(c *bm.Context) {
  597. res := map[string]interface{}{}
  598. var mid int64
  599. midInter, ok := c.Get("mid")
  600. if ok {
  601. mid = midInter.(int64)
  602. } else {
  603. res["message"] = "账号未登录"
  604. returnDataJSON(c, res, ecode.RequestErr)
  605. return
  606. }
  607. data, err := unicomSvc.UserBindLog(c, mid, time.Now())
  608. if err != nil {
  609. c.JSON(nil, err)
  610. return
  611. }
  612. res["data"] = data
  613. returnDataJSON(c, res, nil)
  614. }
  615. func welfareBindState(c *bm.Context) {
  616. params := c.Request.Form
  617. midStr := params.Get("mid")
  618. mid, err := strconv.ParseInt(midStr, 10, 64)
  619. if err != nil || mid < 1 {
  620. c.JSON(nil, ecode.RequestErr)
  621. return
  622. }
  623. data := unicomSvc.WelfareBindState(c, mid)
  624. res := map[string]interface{}{
  625. "state": data,
  626. }
  627. c.JSON(res, nil)
  628. }