蛋蛋星球-客户端
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

hdl_user.go 17 KiB

1ヶ月前
1ヶ月前
3週間前
1ヶ月前
3週間前
3週間前
1週間前
1週間前
3週間前
3週間前
1ヶ月前
3週間前
3週間前
1ヶ月前
1ヶ月前
1ヶ月前
5日前
3週間前
3週間前
3週間前
1週間前
1週間前
1週間前
1週間前
3週間前
3週間前
1週間前
3週間前
6日前
3週間前
6日前
3週間前
1週間前
3週間前
1週間前
3週間前
1週間前
3週間前
1週間前
3週間前
1週間前
6日前
1週間前
6日前
1週間前
1週間前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. package hdl
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/es/hdl"
  6. md2 "applet/app/es/md"
  7. "applet/app/lib/auth"
  8. "applet/app/md"
  9. "applet/app/svc"
  10. "applet/app/utils"
  11. "applet/app/utils/cache"
  12. "applet/app/utils/qrcode"
  13. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  14. "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
  15. "code.fnuoos.com/EggPlanet/egg_system_rules.git/baidu"
  16. md3 "code.fnuoos.com/EggPlanet/egg_system_rules.git/md"
  17. md4 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md"
  18. es2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/es"
  19. "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es"
  20. "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
  21. "context"
  22. "encoding/json"
  23. "fmt"
  24. "github.com/gin-gonic/gin"
  25. "github.com/olivere/elastic/v7"
  26. "github.com/syyongx/php2go"
  27. "github.com/tidwall/gjson"
  28. "strings"
  29. "time"
  30. )
  31. // UserInfo
  32. // @Summary 用户信息
  33. // @Tags 用户信息
  34. // @Description 用户信息
  35. // @Accept json
  36. // @Produce json
  37. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  38. // @Success 200 {object} md.UserInfoResp "具体数据"
  39. // @Failure 400 {object} md.Response "具体错误"
  40. // @Router /api/v1/userInfo [get]
  41. func UserInfo(c *gin.Context) {
  42. user := svc.GetUser(c)
  43. res := md.UserInfoResp{
  44. Id: utils.Int64ToStr(user.Id),
  45. Phone: user.Phone,
  46. Nickname: user.Phone,
  47. InviteCode: user.SystemInviteCode,
  48. IsBindExtend: "0",
  49. }
  50. if user.Avatar == "" {
  51. user.Avatar = svc.GetSysCfgStr("default_avatar")
  52. }
  53. if user.Avatar != "" {
  54. res.HeadImg = svc.GetOssUrl(user.Avatar)
  55. }
  56. if user.CustomInviteCode != "" {
  57. res.InviteCode = user.CustomInviteCode
  58. }
  59. if user.ParentUid > 0 {
  60. res.IsBindExtend = "1"
  61. }
  62. e.OutSuc(c, res, nil)
  63. return
  64. }
  65. // InviteCodeUserInfo
  66. // @Summary 邀请码获取用户信息
  67. // @Tags 登录注册
  68. // @Description 邀请码获取用户信息
  69. // @Accept json
  70. // @Produce json
  71. // @Param req body md.InviteCodeUserInfoReq true "注册参数"
  72. // @Success 200 {object} md.InviteCodeUserInfoResp "具体数据"
  73. // @Failure 400 {object} md.Response "具体错误"
  74. // @Router /api/v1/inviteCode/userInfo [post]
  75. func InviteCodeUserInfo(c *gin.Context) {
  76. var req md.InviteCodeUserInfoReq
  77. err := c.ShouldBindJSON(&req)
  78. if err != nil {
  79. err = svc.HandleValidateErr(err)
  80. err1 := err.(e.E)
  81. e.OutErr(c, err1.Code, err1.Error())
  82. return
  83. }
  84. if req.InviteCode == "" {
  85. e.OutErr(c, 400, e.NewErr(400, "邀请码不能为空"))
  86. return
  87. }
  88. userDb := implement.NewUserDb(db.Db)
  89. user, err := userDb.UserGetOneByParams(map[string]interface{}{
  90. "key": "system_invite_code",
  91. "value": req.InviteCode,
  92. })
  93. if user == nil {
  94. user, _ = userDb.UserGetOneByParams(map[string]interface{}{
  95. "key": "custom_invite_code",
  96. "value": req.InviteCode,
  97. })
  98. if user == nil {
  99. e.OutErr(c, 400, e.NewErr(400, "邀请码失效,请联系上级重新获取分享"))
  100. return
  101. }
  102. }
  103. nickname := user.Nickname
  104. if nickname == "" {
  105. nickname = user.Phone
  106. }
  107. if php2go.IsNumeric(nickname) {
  108. nickname = utils.HideTrueName(user.Nickname)
  109. }
  110. user = svc.UserImg(user)
  111. res := md.InviteCodeUserInfoResp{
  112. Nickname: nickname,
  113. HeadImg: svc.GetOssUrl(user.Avatar),
  114. }
  115. e.OutSuc(c, res, nil)
  116. return
  117. }
  118. // UserBindParent
  119. // @Summary 绑定上级-要登陆的
  120. // @Tags 登录注册
  121. // @Description 绑定上级
  122. // @Accept json
  123. // @Produce json
  124. // @Param req body md.InviteCodeUserInfoReq true "注册参数"
  125. // @Success 200 {string} "具体数据"
  126. // @Failure 400 {object} md.Response "具体错误"
  127. // @Router /api/v1/memberCenter/bindParent [post]
  128. func UserBindParent(c *gin.Context) {
  129. var req md.InviteCodeUserInfoReq
  130. err := c.ShouldBindJSON(&req)
  131. if err != nil {
  132. err = svc.HandleValidateErr(err)
  133. err1 := err.(e.E)
  134. e.OutErr(c, err1.Code, err1.Error())
  135. return
  136. }
  137. if req.InviteCode == "" {
  138. e.OutErr(c, 400, e.NewErr(400, "邀请码不能为空"))
  139. return
  140. }
  141. userDb := implement.NewUserDb(db.Db)
  142. user, err := userDb.UserGetOneByParams(map[string]interface{}{
  143. "key": "system_invite_code",
  144. "value": req.InviteCode,
  145. })
  146. if user == nil {
  147. user, _ = userDb.UserGetOneByParams(map[string]interface{}{
  148. "key": "custom_invite_code",
  149. "value": req.InviteCode,
  150. })
  151. if user == nil {
  152. e.OutErr(c, 400, e.NewErr(400, "用户不存在"))
  153. return
  154. }
  155. }
  156. ownUser := svc.GetUser(c)
  157. if ownUser.ParentUid > 0 {
  158. e.OutErr(c, 400, e.NewErr(400, "已有导师"))
  159. return
  160. }
  161. if user.Id == ownUser.Id {
  162. e.OutErr(c, 400, e.NewErr(400, "不能绑定自己"))
  163. return
  164. }
  165. ownUser.ParentUid = user.Id
  166. _, err = db.Db.Where("id=?", ownUser.Id).Cols("parent_uid").Update(ownUser)
  167. if err != nil {
  168. e.OutErr(c, 400, e.NewErr(400, "绑定失败,请重试"))
  169. return
  170. }
  171. initLV := 1
  172. ur := new(model.UserRelate)
  173. ur.ParentUid = user.Id
  174. ur.Uid = ownUser.Id
  175. ur.Level = initLV
  176. ur.InviteTime = ownUser.CreateAt
  177. userRelateDb := implement.NewUserRelateDb(db.Db)
  178. _, err = userRelateDb.UserRelateInsert(ur)
  179. if err != nil {
  180. e.OutErr(c, e.ERR_DB_ORM, err)
  181. return
  182. }
  183. // 插入多级关联
  184. go svc.RoutineMultiRelate(ur.ParentUid, ur.Uid, initLV)
  185. //TODO 绑定成功后 加群之类的怎么处理
  186. if ownUser.ParentUid > 0 {
  187. //TODO::推入mq异步处理
  188. ch, err := rabbit.Cfg.Pool.GetChannel()
  189. if err != nil {
  190. e.OutErr(c, e.ERR_INIT_RABBITMQ, err.Error())
  191. return
  192. }
  193. defer ch.Release()
  194. ch.Publish(md4.EggAppExchange, md4.AddPublicPlatoonUserRelationCommissionReq{RecommendUid: utils.Int64ToStr(ownUser.ParentUid), Uid: utils.Int64ToStr(ownUser.Id)}, md4.EggRoutKeyForAddPublicPlatoonUserRelationCommission)
  195. }
  196. e.OutSuc(c, "success", nil)
  197. return
  198. }
  199. // BindUserInfo
  200. // @Summary 绑定用户信息
  201. // @Tags 会员中心
  202. // @Description 绑定用户信息
  203. // @Accept json
  204. // @Produce json
  205. // @Param req body md.WechatAccountUserInfoReq true "注册参数"
  206. // @Success 200 {string} "具体数据"
  207. // @Failure 400 {object} md.Response "具体错误"
  208. // @Router /api/v1/memberCenter/bindUserInfo [post]
  209. func BindUserInfo(c *gin.Context) {
  210. var req md.WechatAccountUserInfoReq
  211. err := c.ShouldBindJSON(&req)
  212. if err != nil {
  213. err = svc.HandleValidateErr(err)
  214. err1 := err.(e.E)
  215. e.OutErr(c, err1.Code, err1.Error())
  216. return
  217. }
  218. ownUser := svc.GetUser(c)
  219. cols := ""
  220. if req.Nickname != "" {
  221. ownUser.Nickname = req.Nickname
  222. cols += ",nickname"
  223. }
  224. if req.HeadImg != "" {
  225. ownUser.Avatar = req.HeadImg
  226. cols += ",avatar"
  227. }
  228. if req.WechatAccount != "" {
  229. ownUser.WechatAccount = req.WechatAccount
  230. cols += ",wechat_account"
  231. }
  232. if cols == "" {
  233. e.OutErr(c, 400, e.NewErr(400, "修改失败"))
  234. return
  235. }
  236. _, err = db.Db.Where("id=?", ownUser.Id).Cols(cols[1:]).Update(ownUser)
  237. if err != nil {
  238. e.OutErr(c, 400, e.NewErr(400, "修改失败"))
  239. return
  240. }
  241. e.OutSuc(c, "success", nil)
  242. return
  243. }
  244. // UpdatePassword
  245. // @Summary 修改密码-不要原密码 换成验证码
  246. // @Tags 账号与安全
  247. // @Description 修改密码
  248. // @Accept json
  249. // @Produce json
  250. // @Param req body md.UpdatePasswordReq true "注册参数"
  251. // @Success 200 string "登录成功返回"
  252. // @Failure 400 {object} md.Response "具体错误"
  253. // @Router /api/v1/memberCenter/updatePassword [post]
  254. func UpdatePassword(c *gin.Context) {
  255. var req md.UpdatePasswordReq
  256. err := c.ShouldBindJSON(&req)
  257. if err != nil {
  258. err = svc.HandleValidateErr(err)
  259. err1 := err.(e.E)
  260. e.OutErr(c, err1.Code, err1.Error())
  261. return
  262. }
  263. user := svc.GetUser(c)
  264. //校验短信
  265. err = svc.CommSmsCheck(c, user.Phone, req.Code)
  266. if err != nil {
  267. e.OutErr(c, 400, e.NewErr(400, "验证码错误,请重试"))
  268. return
  269. }
  270. user.Password = utils.Md5(req.Password)
  271. db.Db.Where("id=?", user.Id).Cols("password").Update(user)
  272. e.OutSuc(c, "success", nil)
  273. return
  274. }
  275. // UpdatePasscode
  276. // @Summary 修改支付宝密码
  277. // @Tags 账号与安全
  278. // @Description 修改支付宝密码
  279. // @Accept json
  280. // @Produce json
  281. // @Param req body md.UpdatePasscodeReq true "注册参数"
  282. // @Success 200 string "登录成功返回"
  283. // @Failure 400 {object} md.Response "具体错误"
  284. // @Router /api/v1/memberCenter/updatePasscode [post]
  285. func UpdatePasscode(c *gin.Context) {
  286. var req md.UpdatePasscodeReq
  287. err := c.ShouldBindJSON(&req)
  288. if err != nil {
  289. err = svc.HandleValidateErr(err)
  290. err1 := err.(e.E)
  291. e.OutErr(c, err1.Code, err1.Error())
  292. return
  293. }
  294. user := svc.GetUser(c)
  295. //校验短信
  296. err = svc.CommSmsCheck(c, user.Phone, req.Code)
  297. if err != nil {
  298. e.OutErr(c, 400, e.NewErr(400, "验证码错误,请重试"))
  299. return
  300. }
  301. user.Passcode = utils.Md5(req.PassCode)
  302. db.Db.Where("id=?", user.Id).Cols("passcode").Update(user)
  303. e.OutSuc(c, "success", nil)
  304. return
  305. }
  306. // InviteUrl
  307. // @Summary 邀请链接
  308. // @Tags 邀请海报
  309. // @Description 邀请链接
  310. // @Accept json
  311. // @Produce json
  312. // @Success 200 {object} md.InviteUrl "登录成功返回"
  313. // @Failure 400 {object} md.Response "具体错误"
  314. // @Router /api/v1/memberCenter/inviteUrl [get]
  315. func InviteUrl(c *gin.Context) {
  316. user := svc.GetUser(c)
  317. link := svc.GetSysCfgStr("kuaizhan_url")
  318. res := md.InviteUrl{
  319. Link: "",
  320. InviteCode: user.SystemInviteCode,
  321. }
  322. if user.CustomInviteCode != "" {
  323. res.InviteCode = user.CustomInviteCode
  324. }
  325. link += "?inviteCode=" + res.InviteCode
  326. EggUserShortLink := md2.EggUserShortLink
  327. boolQueryToItem := elastic.NewBoolQuery() // 创建bool查询
  328. aggsMatch := elastic.NewMatchQuery("link", link) //设置查询条件
  329. boolQueryToItem.Must(aggsMatch)
  330. result, _ := hdl.EsSelectOne(context.Background(), EggUserShortLink, boolQueryToItem, false)
  331. isHas := 0
  332. if result != nil && len(result.Hits.Hits) > 0 {
  333. for _, hit := range result.Hits.Hits {
  334. if hit == nil {
  335. continue
  336. }
  337. jsonByte, _ := hit.Source.MarshalJSON()
  338. if gjson.Get(string(jsonByte), "short_link").String() != "" && gjson.Get(string(jsonByte), "date").Int() > time.Now().Unix() {
  339. isHas = 1
  340. link = gjson.Get(string(jsonByte), "short_link").String()
  341. }
  342. }
  343. }
  344. if isHas == 0 {
  345. url, _ := baidu.BaiduShortenUrl(svc.GetSysCfgStr("baidu_token"), link)
  346. if url != "" {
  347. var uniqueId = php2go.Md5(link)
  348. oldLink := link
  349. link = url
  350. tmp := map[string]interface{}{
  351. "uid": user.Id,
  352. "link": oldLink,
  353. "short_link": link,
  354. "date": time.Now().Unix() + 365*86400,
  355. }
  356. doc, _ := es.FirstDoc(EggUserShortLink, uniqueId)
  357. if doc == nil {
  358. es.CreateDoc(EggUserShortLink, uniqueId, tmp)
  359. } else {
  360. es.UpdateDoc(EggUserShortLink, uniqueId, tmp)
  361. }
  362. }
  363. }
  364. res.Link = link
  365. QRcode := qrcode.GetPNGBase64(link)
  366. QRcode = strings.ReplaceAll(QRcode, "\u0000", "")
  367. res.Qrcode = QRcode
  368. e.OutSuc(c, res, nil)
  369. return
  370. }
  371. // ParentInfo
  372. // @Summary 导师信息
  373. // @Tags 会员中心
  374. // @Description 导师信息
  375. // @Accept json
  376. // @Produce json
  377. // @Success 200 {object} md.ParentInfo "登录成功返回"
  378. // @Failure 400 {object} md.Response "具体错误"
  379. // @Router /api/v1/memberCenter/parentInfo [get]
  380. func ParentInfo(c *gin.Context) {
  381. ownUser := svc.GetUser(c)
  382. publicPlatoonBasicDb := implement.NewPublicPlatoonBasicSettingDb(db.Db)
  383. publicPlatoonBasic, _ := publicPlatoonBasicDb.PublicPlatoonBasicSettingGetOne()
  384. if publicPlatoonBasic != nil && int(ownUser.Id) == publicPlatoonBasic.OriginatorUid {
  385. ownUser.ParentUid = ownUser.Id
  386. }
  387. if ownUser.ParentUid == 0 {
  388. e.OutSuc(c, md.ParentInfo{}, nil)
  389. return
  390. }
  391. NewUserDb := implement.NewUserDb(db.Db)
  392. user, _ := NewUserDb.GetUser(ownUser.ParentUid)
  393. // 1. 获取会员等级名称
  394. userLevelDb := implement.NewUserLevelDb(db.Db)
  395. level, err := userLevelDb.UserLevelByID(user.Level)
  396. if err != nil {
  397. e.OutErr(c, e.ERR_DB_ORM, nil)
  398. return
  399. }
  400. code := user.SystemInviteCode
  401. if user.CustomInviteCode != "" {
  402. code = user.CustomInviteCode
  403. }
  404. res := md.ParentInfo{
  405. Nickname: user.Nickname,
  406. LevelName: level.LevelName,
  407. InviteCode: code,
  408. HeadImg: svc.GetOssUrl(user.Avatar),
  409. Id: utils.Int64ToStr(user.Id),
  410. Phone: user.Phone,
  411. WechatAccount: user.WechatAccount,
  412. }
  413. e.OutSuc(c, res, nil)
  414. return
  415. }
  416. // Delete
  417. // @Summary 注销账号操作
  418. // @Tags 账号与安全
  419. // @Description 注销账号操作
  420. // @Accept json
  421. // @Produce json
  422. // @Param req body md.DeleteUserReq true "注册参数"
  423. // @Success 200 string "登录成功返回"
  424. // @Failure 400 {object} md.Response "具体错误"
  425. // @Router /api/v1/memberCenter/delete [post]
  426. func Delete(c *gin.Context) {
  427. var req md.DeleteUserReq
  428. err := c.ShouldBindJSON(&req)
  429. if err != nil {
  430. err = svc.HandleValidateErr(err)
  431. err1 := err.(e.E)
  432. e.OutErr(c, err1.Code, err1.Error())
  433. return
  434. }
  435. user := svc.GetUser(c)
  436. //校验短信
  437. err = svc.CommSmsCheck(c, user.Phone, req.Code)
  438. if err != nil {
  439. e.OutErr(c, 400, e.NewErr(400, "验证码错误,请重试"))
  440. return
  441. }
  442. user.State = 3
  443. db.Db.Where("id=?", user.Id).Cols("state").Update(user)
  444. tmp := model.UserDeleteInfo{
  445. Uid: int(user.Id),
  446. Phone: user.Phone,
  447. CreateAt: time.Now(),
  448. }
  449. db.Db.Insert(&tmp)
  450. ch, err := rabbit.Cfg.Pool.GetChannel()
  451. if err == nil {
  452. defer ch.Release()
  453. err = ch.PublishV2(md.EggUserExchange, md.CommUserId{
  454. Uid: utils.Int64ToStr(user.Id),
  455. ParentUid: utils.Int64ToStr(user.ParentUid),
  456. }, md.EggUserDelete)
  457. if err != nil {
  458. ch.PublishV2(md.EggUserExchange, md.CommUserId{
  459. Uid: utils.Int64ToStr(user.Id),
  460. ParentUid: utils.Int64ToStr(user.ParentUid),
  461. }, md.EggUserDelete)
  462. }
  463. }
  464. // 清掉token
  465. cacheKey := fmt.Sprintf(auth.TokenKey, user.Id)
  466. _, err = cache.SetEx(cacheKey, "", 1)
  467. e.OutSuc(c, "success", nil)
  468. return
  469. }
  470. // DeleteInfo
  471. // @Summary 注销账号信息
  472. // @Tags 账号与安全
  473. // @Description 注销账号信息
  474. // @Accept json
  475. // @Produce json
  476. // @Success 200 {object} md.UserDeleteInfo "登录成功返回"
  477. // @Failure 400 {object} md.Response "具体错误"
  478. // @Router /api/v1/memberCenter/delete/info [get]
  479. func DeleteInfo(c *gin.Context) {
  480. user := svc.GetUser(c)
  481. resp := md.UserDeleteInfo{
  482. Url: fmt.Sprintf("%s%s?id=%s&is_hide=1", svc.GetSysCfgStr("wap_host"), "/#/pages/course-detail-page/course-detail-page", "115"),
  483. }
  484. extendUserCount, _ := db.Db.Where("parent_uid=?", user.Id).Count(&model.User{})
  485. NewUserWalletDb := implement.NewUserWalletDb(db.Db)
  486. walletAmount := "0"
  487. wallet, _ := NewUserWalletDb.GetUserVirtualWallet(user.Id)
  488. if wallet != nil {
  489. walletAmount = wallet.Amount
  490. }
  491. NewUserVirtualAmountDb := implement.NewUserVirtualAmountDb(db.Db)
  492. virtualWallet, _ := NewUserVirtualAmountDb.GetUserVirtualAllWallets(user.Id)
  493. virtualAmount1 := "0"
  494. virtualAmount2 := "0"
  495. virtualAmount3 := "0"
  496. settingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
  497. setting, _ := settingDb.EggEnergyBasicSettingGetOne()
  498. if virtualWallet != nil {
  499. for _, v := range *virtualWallet {
  500. if v.CoinId == setting.PersonEggPointsCoinId {
  501. virtualAmount3 = utils.Float64ToStrPrec8(utils.StrToFloat64(v.Amount) + utils.StrToFloat64(virtualAmount3))
  502. }
  503. if v.CoinId == setting.TeamEggPointsCoinId {
  504. virtualAmount3 = utils.Float64ToStrPrec8(utils.StrToFloat64(v.Amount) + utils.StrToFloat64(virtualAmount3))
  505. }
  506. if v.CoinId == setting.PersonEggEnergyCoinId {
  507. virtualAmount2 = utils.Float64ToStrPrec8(utils.StrToFloat64(v.Amount) + utils.StrToFloat64(virtualAmount2))
  508. }
  509. if v.CoinId == setting.TeamEggEnergyCoinId {
  510. virtualAmount2 = utils.Float64ToStrPrec8(utils.StrToFloat64(v.Amount) + utils.StrToFloat64(virtualAmount2))
  511. }
  512. if v.CoinId == setting.ContributionCoinId {
  513. virtualAmount1 = utils.Float64ToStrPrec8(utils.StrToFloat64(v.Amount) + utils.StrToFloat64(virtualAmount1))
  514. }
  515. }
  516. }
  517. score := 60.00
  518. now := time.Now()
  519. esIndex := es2.GetLatestEffectiveIndexFromAlias(now)
  520. esIndexName := md3.EggEnergyUserEggScoreEsAlias + "_" + esIndex
  521. results, _ := es.FirstDoc(esIndexName, esIndex+"_"+utils.Int64ToStr(user.Id))
  522. if results != nil {
  523. var doc md.UserEggFlowReqRespList
  524. json.Unmarshal(results.Source, &doc)
  525. score = doc.ScoreValue
  526. }
  527. uid := user.Id
  528. sql := fmt.Sprintf("SELECT COUNT(*)AS total FROM `public_platoon_user_relation` WHERE father_uid1 = %d OR father_uid2= %d OR father_uid3= %d OR father_uid4= %d OR father_uid5= %d OR father_uid6= %d OR father_uid7= %d OR father_uid8= %d OR father_uid9= %d", uid, uid, uid, uid, uid, uid, uid, uid, uid)
  529. nativeString1, _ := db.QueryNativeString(db.Db, sql)
  530. hasUserCount := "0"
  531. if len(nativeString1) > 0 {
  532. hasUserCount = nativeString1[0]["total"]
  533. }
  534. info := []md.UserDeleteInfoList{
  535. {Title: "贡献值", Content: "贡献值 " + virtualAmount1},
  536. {Title: "能量值", Content: "能量值 " + virtualAmount2},
  537. {Title: "活跃值", Content: "活跃值 " + virtualAmount3},
  538. {Title: "蛋蛋分", Content: "蛋蛋分 " + utils.Float64ToStr(score)},
  539. {Title: "余额", Content: "余额 " + walletAmount},
  540. {Title: "直推好友", Content: "直推好友 " + utils.Int64ToStr(extendUserCount) + " 人"},
  541. {Title: "团队", Content: "团队 " + hasUserCount + " 人"},
  542. }
  543. resp.Info = info
  544. e.OutSuc(c, resp, nil)
  545. return
  546. }