蛋蛋星球 后台端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hdl_user_management.go 17 KiB

2 weeks ago
1 week ago
2 weeks ago
2 weeks ago
1 week ago
2 weeks ago
2 weeks ago
1 week ago
2 weeks ago
6 days ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
6 days ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
2 weeks ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. package member_center
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/md/member_center"
  6. svc "applet/app/svc/member_center"
  7. "applet/app/utils"
  8. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  9. "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
  10. "errors"
  11. "fmt"
  12. "github.com/gin-gonic/gin"
  13. "strings"
  14. )
  15. // UserManagementGetUserList
  16. // @Summary 制度中心-会员中心-用户管理-用户信息管理(获取)
  17. // @Tags 会员中心
  18. // @Description 用户信息管理(获取)
  19. // @Accept json
  20. // @Produce json
  21. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  22. // @Param req body md.UserManagementGetUserListReq true "分页信息必填"
  23. // @Success 200 {object} md.UserManagementGetUserListResp "具体数据"
  24. // @Failure 400 {object} md.Response "具体错误"
  25. // @Router /api/memberCenter/userManagement/getUserList [post]
  26. func UserManagementGetUserList(c *gin.Context) {
  27. var req *md.UserManagementGetUserListReq
  28. if err := c.ShouldBindJSON(&req); err != nil {
  29. e.OutErr(c, e.ERR_INVALID_ARGS, err.Error())
  30. return
  31. }
  32. levelDb := implement.NewUserLevelDb(db.Db)
  33. levels, err1 := levelDb.UserLevelAllByAsc()
  34. if err1 != nil {
  35. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  36. return
  37. }
  38. levelsList := make([]map[string]interface{}, 0)
  39. levelsMap := make(map[int]string)
  40. for _, level := range levels {
  41. levelsList = append(levelsList, map[string]interface{}{
  42. "id": level.Id,
  43. "name": level.LevelName,
  44. })
  45. levelsMap[level.Id] = level.LevelName
  46. }
  47. tagDb := implement.NewUserTagDb(db.Db)
  48. tags, err2 := tagDb.UserTagAllByAsc()
  49. if err2 != nil {
  50. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  51. return
  52. }
  53. tagsList := make([]map[string]interface{}, 0)
  54. tagsMap := make(map[int]string)
  55. for _, tag := range tags {
  56. tagsList = append(tagsList, map[string]interface{}{
  57. "id": tag.Id,
  58. "name": tag.TagName,
  59. })
  60. tagsMap[tag.Id] = tag.TagName
  61. }
  62. stateList := []map[string]interface{}{
  63. {
  64. "name": "正常",
  65. "value": "1",
  66. },
  67. {
  68. "name": "冻结",
  69. "value": "2",
  70. },
  71. }
  72. users, total, err3 := svc.UserManagementGetUsers(db.Db, req)
  73. if err3 != nil {
  74. e.OutErr(c, e.ERR_DB_ORM, err3.Error())
  75. return
  76. }
  77. var levelCounts []md.LevelCount
  78. err4 := db.Db.Table("user").Select("level, Count(*) AS count").GroupBy("level").Find(&levelCounts)
  79. if err4 != nil {
  80. e.OutErr(c, e.ERR_DB_ORM, err4.Error())
  81. return
  82. }
  83. list := make([]md.UserManagementGetUserListNode, len(*users))
  84. for i, user := range *users {
  85. list[i] = md.UserManagementGetUserListNode{
  86. ID: user.Id,
  87. Sex: user.Sex,
  88. Avatar: user.Avatar,
  89. Nickname: user.Nickname,
  90. Phone: user.Phone,
  91. IsRealName: user.IsRealName,
  92. InviteCode: user.SystemInviteCode,
  93. ParentID: user.ParentUid,
  94. ParentInviteCode: user.ParentSystemInviteCode,
  95. ParentPhone: user.Phone,
  96. RegisterTime: user.CreateAt,
  97. Memo: user.Memo,
  98. Wechat: user.UnionId,
  99. RegisterType: user.RegisterType,
  100. State: user.State,
  101. LastLoginAt: user.UpdateAt,
  102. }
  103. tag, ok := tagsMap[user.TagID]
  104. if ok {
  105. list[i].Tag = tag
  106. }
  107. level, ok := levelsMap[user.Level]
  108. if ok {
  109. list[i].LevelName = level
  110. }
  111. }
  112. resp := md.UserManagementGetUserListResp{
  113. LevelsList: levelsList,
  114. TagsList: tagsList,
  115. StateList: stateList,
  116. List: list,
  117. Paginate: md.Paginate{
  118. Limit: req.Limit,
  119. Page: req.Page,
  120. Total: total,
  121. },
  122. }
  123. e.OutSuc(c, resp, nil)
  124. }
  125. // UserManagementUpdateUserInfo
  126. // @Summary 制度中心-会员中心-用户管理-用户信息管理(更新)
  127. // @Tags 会员中心
  128. // @Description 用户信息管理(更新)
  129. // @Accept json
  130. // @Produce json
  131. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  132. // @Param req body md.UserManagementUpdateUserInfoReq true "用户ID 必传"
  133. // @Success 200 {int} "修改数据行数"
  134. // @Failure 400 {object} md.Response "具体错误"
  135. // @Router /api/memberCenter/userManagement/updateUserInfo [post]
  136. func UserManagementUpdateUserInfo(c *gin.Context) {
  137. var req *md.UserManagementUpdateUserInfoReq
  138. if err := c.ShouldBindJSON(&req); err != nil {
  139. e.OutErr(c, e.ERR_INVALID_ARGS, err.Error())
  140. return
  141. }
  142. session := db.Db.NewSession()
  143. defer session.Close()
  144. session.Begin()
  145. userDb := implement.NewUserDb(db.Db)
  146. var affected int64
  147. var err1 error
  148. forceColumns := make([]string, 0)
  149. user := model.User{
  150. Id: req.UID,
  151. Phone: req.Phone,
  152. UnionId: req.UnionId,
  153. Nickname: req.Nickname,
  154. Avatar: req.Avatar,
  155. LastLoginIp: req.LastLoginIp,
  156. Memo: req.Memo,
  157. }
  158. if req.Level != "" {
  159. user.Level = utils.StrToInt(req.Level)
  160. }
  161. if req.State != "" {
  162. user.State = utils.StrToInt(req.State)
  163. }
  164. if req.Sex != "" {
  165. user.Sex = utils.StrToInt(req.Sex)
  166. }
  167. if req.ParentUid != "" {
  168. user.ParentUid = utils.StrToInt64(req.ParentUid)
  169. } else {
  170. user.ParentUid = 0
  171. }
  172. forceColumns = []string{"sex", "parent_uid"}
  173. affected, err1 = userDb.UserUpdateBySession(session, req.UID, &user, forceColumns...)
  174. if err1 != nil {
  175. session.Rollback()
  176. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  177. return
  178. }
  179. relateDb := implement.NewUserRelateDb(db.Db)
  180. relateForceColumns := []string{"sex", "parent_uid"}
  181. relate := &model.UserRelate{
  182. ParentUid: user.ParentUid,
  183. }
  184. affected, err1 = relateDb.UpdateUserRelateBySession(session, req.UID, relate, relateForceColumns...)
  185. if err1 != nil {
  186. session.Rollback()
  187. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  188. return
  189. }
  190. var err2 error
  191. if req.Tag != "" {
  192. record := model.UserTagRecords{
  193. TagId: utils.StrToInt(req.Tag),
  194. }
  195. recordsDb := implement.NewUserTagRecordsDb(db.Db)
  196. affected, err2 = recordsDb.UserTagRecordsUpdateBySession(session, req.UID, &record, "tag_id")
  197. if err2 != nil {
  198. session.Rollback()
  199. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  200. return
  201. }
  202. }
  203. err3 := session.Commit()
  204. if err3 != nil {
  205. session.Rollback()
  206. e.OutErr(c, e.ERR_DB_ORM, err3.Error())
  207. return
  208. }
  209. e.OutSuc(c, affected, nil)
  210. }
  211. // UserManagementGetOneBasic
  212. // @Summary 制度中心-会员中心-用户管理-会员明细概况(获取)
  213. // @Tags 会员中心
  214. // @Description 会员明细概况(获取)
  215. // @Accept json
  216. // @Produce json
  217. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  218. // @Param uid query string true "用户 ID"
  219. // @Success 200 {object} md.UserManagementGetOneBasicResp "会员明细概况具体数据"
  220. // @Failure 400 {object} md.Response "具体错误"
  221. // @Router /api/memberCenter/userManagement/userData [get]
  222. func UserManagementGetOneBasic(c *gin.Context) {
  223. uid := c.Query("uid")
  224. userDb := implement.NewUserDb(db.Db)
  225. user, err := userDb.UserGetOneByParams(map[string]interface{}{
  226. "key": "id",
  227. "value": uid,
  228. })
  229. if err != nil {
  230. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  231. return
  232. }
  233. // 1. 查询等级列表
  234. levelDb := implement.NewUserLevelDb(db.Db)
  235. levels, err1 := levelDb.UserLevelAllByAsc()
  236. if err1 != nil {
  237. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  238. return
  239. }
  240. levelsList := make([]map[string]interface{}, 0)
  241. levelsMap := make(map[int]string)
  242. for _, level := range levels {
  243. levelsList = append(levelsList, map[string]interface{}{
  244. "id": level.Id,
  245. "name": level.LevelName,
  246. })
  247. levelsMap[level.Id] = level.LevelName
  248. }
  249. //2. 查询标签列表
  250. tagDb := implement.NewUserTagDb(db.Db)
  251. tags, err2 := tagDb.UserTagAllByAsc()
  252. if err2 != nil {
  253. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  254. return
  255. }
  256. tagsList := make([]map[string]interface{}, 0)
  257. tagsMap := make(map[int]string)
  258. for _, tag := range tags {
  259. tagsList = append(tagsList, map[string]interface{}{
  260. "id": tag.Id,
  261. "name": tag.TagName,
  262. })
  263. tagsMap[tag.Id] = tag.TagName
  264. }
  265. //3. 查询父用户信息
  266. parent, err := userDb.UserGetOneByParams(map[string]interface{}{
  267. "key": "id",
  268. "value": user.ParentUid,
  269. })
  270. if err != nil {
  271. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  272. return
  273. }
  274. //4. 查询用户标签
  275. recordsDb := implement.NewUserTagRecordsDb(db.Db)
  276. userTagRecord, err := recordsDb.UserTagRecordsGetOneByParams(map[string]interface{}{
  277. "key": "uid",
  278. "value": uid,
  279. })
  280. if err != nil {
  281. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  282. return
  283. }
  284. resp := md.UserManagementGetOneBasicResp{
  285. TagsList: tagsList,
  286. LevelsList: levelsList,
  287. BasicInfo: md.BasicInfoNode{
  288. Avatar: user.Avatar,
  289. Sex: user.Sex,
  290. Nickname: user.Nickname,
  291. Phone: user.Phone,
  292. UnionId: user.UnionId,
  293. Password: user.Password,
  294. State: user.State,
  295. Memo: user.Memo,
  296. },
  297. OtherInfo: md.OtherNode{
  298. LastLoginIp: user.LastLoginIp,
  299. LastLoginAt: user.UpdateAt,
  300. CreateAt: user.CreateAt,
  301. },
  302. }
  303. if userTagRecord != nil {
  304. resp.BasicInfo.TagName = tagsMap[userTagRecord.TagId]
  305. }
  306. if parent != nil {
  307. resp.BasicInfo.ParentUid = parent.Id
  308. resp.BasicInfo.ParentName = parent.Nickname
  309. resp.BasicInfo.ParentPhone = parent.Phone
  310. }
  311. level, ok := levelsMap[user.Level]
  312. if ok {
  313. resp.BasicInfo.LevelName = level
  314. }
  315. e.OutSuc(c, resp, nil)
  316. }
  317. // UserManagementGetFans
  318. // @Summary 制度中心-会员中心-用户管理-会员明细粉丝情况(获取)
  319. // @Tags 会员中心
  320. // @Description 会员明细粉丝情况(获取)
  321. // @Accept json
  322. // @Produce json
  323. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  324. // @Param uid query string true "用户 ID"
  325. // @Param type query string true "粉丝类型(1.全部 2.直推 3.二代 4.二代以后)"
  326. // @Param limit query string true "每页大小"
  327. // @Param page query string true "页数"
  328. // @Success 200 {object} md.UserManagementGetFansResp "具体数据"
  329. // @Failure 400 {object} md.Response "具体错误"
  330. // @Router /api/memberCenter/userManagement/getFans [get]
  331. func UserManagementGetFans(c *gin.Context) {
  332. uid := c.Query("uid")
  333. fansType := c.Query("type")
  334. limit := c.Query("limit")
  335. page := c.Query("page")
  336. //1. 查询符合情况用户 ID
  337. relateDb := implement.NewUserRelateDb(db.Db)
  338. var level int
  339. switch fansType {
  340. case "0":
  341. level = 0
  342. case "1":
  343. level = 1
  344. case "2":
  345. level = 2
  346. default:
  347. level = 3
  348. }
  349. relates, total, err := relateDb.PageFindUserRelateByParentUidAndLevel(utils.StrToInt64(uid), utils.StrToInt(page), utils.StrToInt(limit), level)
  350. if err != nil {
  351. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  352. return
  353. }
  354. userIDs := make([]int64, len(*relates))
  355. for i, relate := range *relates {
  356. userIDs[i] = relate.Uid
  357. }
  358. //2. 查询所属代数
  359. platoonUserRelationDb := implement.NewPublicPlatoonUserRelationDb(db.Db)
  360. levelTotals, err := platoonUserRelationDb.PublicPlatoonUserRelationFindByParamsByPage(map[string]interface{}{
  361. "key": "uid",
  362. "value": userIDs,
  363. }, utils.StrToInt(page), utils.StrToInt(limit))
  364. if err != nil {
  365. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  366. return
  367. }
  368. levelTotalMap := make(map[int64]int)
  369. for _, levelTotal := range *levelTotals {
  370. levelTotalMap[levelTotal.Uid] = levelTotal.LevelTotal
  371. }
  372. //3. 查询可提现余额
  373. walletDb := implement.NewUserWalletDb(db.Db)
  374. wallets, err := walletDb.FindUserWalletByParams(map[string]interface{}{
  375. "key": uid,
  376. "value": userIDs,
  377. })
  378. if err != nil {
  379. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  380. return
  381. }
  382. walletMap := make(map[int64]string)
  383. for _, wallet := range *wallets {
  384. walletMap[wallet.Uid] = wallet.Amount
  385. }
  386. //4. 查询累计收益
  387. var incomeMap = map[int64]string{}
  388. if len(*relates) > 0 {
  389. userIDStrs := make([]string, len(*relates))
  390. for i, id := range userIDs {
  391. userIDStrs[i] = utils.Int64ToStr(id)
  392. }
  393. sql := "SELECT SUM(amount) as total, uid FROM `user_wallet_flow` WHERE uid in (%s) AND direction = 1 Group BY uid"
  394. results, err := db.QueryNativeString(db.Db, fmt.Sprintf(sql, strings.Join(userIDStrs, ",")))
  395. if err != nil {
  396. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  397. return
  398. }
  399. for _, res := range results {
  400. incomeMap[utils.StrToInt64(res["uid"])] = res["total"]
  401. }
  402. }
  403. //5. 查询用户信息
  404. userDb := implement.NewUserDb(db.Db)
  405. users, err := userDb.UserFindByParams(map[string]interface{}{
  406. "key": "uid",
  407. "value": userIDs,
  408. })
  409. if err != nil {
  410. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  411. return
  412. }
  413. list := make([]md.FansNode, len(users))
  414. for i, user := range users {
  415. list[i] = md.FansNode{
  416. ID: user.Id,
  417. Nickname: user.Nickname,
  418. Phone: user.Phone,
  419. RegisterAt: user.CreateAt,
  420. }
  421. val, ok := incomeMap[user.Id]
  422. if ok {
  423. list[i].TotalIncome = val
  424. }
  425. levelTotal, ok := levelTotalMap[user.Id]
  426. if ok {
  427. list[i].LevelTotal = levelTotal
  428. }
  429. amount, ok := walletMap[user.Id]
  430. if ok {
  431. list[i].Amount = amount
  432. }
  433. }
  434. resp := md.UserManagementGetFansResp{
  435. List: list,
  436. Paginate: md.Paginate{
  437. Limit: utils.StrToInt(limit),
  438. Page: utils.StrToInt(page),
  439. Total: total,
  440. },
  441. }
  442. e.OutSuc(c, resp, nil)
  443. }
  444. // UserManagementGetBalanceDetail
  445. // @Summary 制度中心-会员中心-用户管理-会员明细(余额获取)
  446. // @Tags 会员中心
  447. // @Description 会员明细(余额获取)
  448. // @Accept json
  449. // @Produce json
  450. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  451. // @Param uid query string true "用户 ID"
  452. // @Param limit query string true "每页大小"
  453. // @Param page query string true "页数"
  454. // @Success 200 {object} md.UserManagementGetBalanceDetailResp "具体数据"
  455. // @Failure 400 {object} md.Response "具体错误"
  456. // @Router /api/memberCenter/userManagement/balanceDetail [get]
  457. func UserManagementGetBalanceDetail(c *gin.Context) {
  458. uid := c.Query("uid")
  459. page := c.DefaultQuery("page", "1")
  460. limit := c.DefaultQuery("limit", "10")
  461. walletFlowDb := implement.NewUserWalletFlowDb(db.Db)
  462. walletFlows, total, err := walletFlowDb.UserWalletFlowFindByParams(map[string]interface{}{
  463. "key": "uid",
  464. "value": uid,
  465. }, utils.StrToInt(page), utils.StrToInt(limit))
  466. if err != nil {
  467. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  468. return
  469. }
  470. kindMap := map[int]string{
  471. 1: "管理员操作增加余额",
  472. 2: "管理员操作扣除余额",
  473. 3: "蛋蛋能量兑换余额",
  474. 4: "余额兑换蛋蛋能量",
  475. }
  476. list := make([]md.BalanceDetailNode, len(*walletFlows))
  477. for i, flow := range *walletFlows {
  478. list[i] = md.BalanceDetailNode{
  479. ID: flow.Id,
  480. Amount: flow.Amount,
  481. AfterAmount: flow.AfterAmount,
  482. Kind: kindMap[flow.Kind],
  483. CreateAt: flow.CreateAt,
  484. }
  485. }
  486. resp := md.UserManagementGetBalanceDetailResp{
  487. List: list,
  488. Paginate: md.Paginate{
  489. Limit: utils.StrToInt(limit),
  490. Page: utils.StrToInt(page),
  491. Total: total,
  492. },
  493. }
  494. e.OutSuc(c, resp, nil)
  495. }
  496. // UserManagementGetVirtualCoinDetail
  497. // @Summary 制度中心-会员中心-用户管理-会员明细(积分明细获取)
  498. // @Tags 会员中心
  499. // @Description 会员明细(积分明细获取)
  500. // @Accept json
  501. // @Produce json
  502. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  503. // @Param uid query string true "用户 ID"
  504. // @Param coinId query string true "货币 ID"
  505. // @Param limit query string true "每页大小"
  506. // @Param page query string true "页数"
  507. // @Success 200 {object} md.UserManagementGetVirtualCoinDetailResp "具体数据"
  508. // @Failure 400 {object} md.Response "具体错误"
  509. // @Router /api/memberCenter/userManagement/getVirtualCoinDetail [get]
  510. func UserManagementGetVirtualCoinDetail(c *gin.Context) {
  511. page := c.DefaultQuery("page", "1")
  512. limit := c.DefaultQuery("limit", "10")
  513. uid := c.Query("uid")
  514. coinID := c.Query("coinId")
  515. coinDb := implement.NewVirtualCoinDb(db.Db)
  516. coins, err := coinDb.VirtualCoinFindAll()
  517. if err != nil {
  518. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  519. return
  520. }
  521. if coins == nil {
  522. e.OutErr(c, e.ERR_NO_DATA, errors.New("未初始化货币"))
  523. return
  524. }
  525. coinsList := make([]map[string]interface{}, len(coins))
  526. coinsMap := map[int]string{}
  527. for i, coin := range coins {
  528. coinsList[i] = map[string]interface{}{
  529. "coinID": coin.Id,
  530. "name": coin.Name,
  531. }
  532. coinsMap[coin.Id] = coin.Name
  533. }
  534. // 传入不存在的货币类型时 默认为第一种货币类型
  535. var reqCoinID int
  536. _, ok := coinsMap[utils.StrToInt(coinID)]
  537. if !ok {
  538. reqCoinID = coinsList[0]["coinID"].(int)
  539. } else {
  540. reqCoinID = utils.StrToInt(coinID)
  541. }
  542. flowDb := implement.NewUserVirtualCoinFlowDb(db.Db)
  543. flows, total, err := flowDb.UserVirtualCoinFlowFindByCoinAndUser(utils.StrToInt(page), utils.StrToInt(limit), reqCoinID, utils.StrToInt64(uid), "", "", 0, false, 0)
  544. if err != nil {
  545. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  546. return
  547. }
  548. list := make([]md.VirtualCoinDetailNode, len(flows))
  549. for i, flow := range flows {
  550. list[i] = md.VirtualCoinDetailNode{
  551. Uid: flow.Uid,
  552. Amount: flow.Amount,
  553. AfterAmount: flow.AfterAmount,
  554. Direction: flow.Direction,
  555. CreateAt: flow.CreateAt,
  556. }
  557. }
  558. resp := md.UserManagementGetVirtualCoinDetailResp{
  559. CoinList: coinsList,
  560. List: list,
  561. Paginate: md.Paginate{
  562. Limit: utils.StrToInt(limit),
  563. Page: utils.StrToInt(page),
  564. Total: total,
  565. },
  566. }
  567. e.OutSuc(c, resp, nil)
  568. }