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

hdl_user.go 17 KiB

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