initInfo.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package service
  2. import (
  3. . "bp.jydev.jianyu360.cn/CRM/networkManage/api/common"
  4. "github.com/gogf/gf/v2/util/gconv"
  5. "log"
  6. )
  7. type InitInfoService struct {
  8. PositionType int64
  9. MgoUserId string
  10. EntId int64
  11. NewUserId int64
  12. AccountId int64
  13. PositionId int64
  14. EntUserId int64
  15. }
  16. func (t *InitInfoService) UpdateInitInfo(company, business string) bool {
  17. fool := false
  18. if t.PositionType == 1 {
  19. //企业
  20. userInfo := Middleground.PowerCheckCenter.Check("10000", t.MgoUserId, t.NewUserId, gconv.Int64(t.AccountId), t.EntId, t.PositionType, gconv.Int64(t.PositionId))
  21. fool = Mgo.Update("ent_user", map[string]interface{}{
  22. "i_entid": t.EntId,
  23. "i_userid": t.EntUserId,
  24. }, map[string]interface{}{
  25. "$set": map[string]interface{}{
  26. "is_init": true,
  27. },
  28. }, false, false)
  29. if userInfo.Ent.EntRoleId == 1 {
  30. //企业管理员
  31. fool = JianyuMysql.Update("entniche_info", map[string]interface{}{
  32. "id": t.EntId,
  33. }, map[string]interface{}{
  34. "identityInfo": map[string]interface{}{
  35. "company": company,
  36. "business": business,
  37. },
  38. })
  39. }
  40. } else {
  41. fool = Mgo.UpdateById("user", t.MgoUserId, map[string]interface{}{
  42. "$set": map[string]interface{}{
  43. "identity_info.is_init": true,
  44. "identity_info.ent_businessType": business,
  45. "s_company": company,
  46. },
  47. })
  48. }
  49. return fool
  50. }
  51. func (t *InitInfoService) FindInitInfo() map[string]interface{} {
  52. returnJson := map[string]interface{}{}
  53. if t.PositionType == 1 {
  54. isInit := false
  55. userInfo := Middleground.PowerCheckCenter.Check("10000", t.MgoUserId, t.NewUserId, gconv.Int64(t.AccountId), t.EntId, t.PositionType, gconv.Int64(t.PositionId))
  56. entUserInfo, _ := Mgo.FindOne("ent_user", map[string]interface{}{"i_entid": t.EntId, "i_userid": t.EntUserId})
  57. if userInfo != nil && len(*entUserInfo) > 0 {
  58. isInit = gconv.Bool((*entUserInfo)["is_init"])
  59. returnJson["isInit"] = isInit
  60. }
  61. if isInit {
  62. entInfo := JianyuMysql.FindOne("entniche_info", map[string]interface{}{
  63. "id": t.EntId,
  64. }, "", "")
  65. if (*entInfo)["identityInfo"] != nil {
  66. entMap := gconv.Map((*entInfo)["identityInfo"])
  67. returnJson["company"] = entMap["company"]
  68. returnJson["business"] = entMap["business"]
  69. }
  70. }
  71. if userInfo.Ent.EntRoleId == 1 {
  72. //企业管理员
  73. returnJson["isUpdate"] = true
  74. if !isInit {
  75. //查询订单信息
  76. dataOrder := JianyuMysql.SelectBySql(`select company_name from dataexport_order where user_id=? and order_status=1 and product_type LIKE "%大会员%" and vip_endtime>now()`, t.PositionId)
  77. if dataOrder != nil && len(*dataOrder) > 0 {
  78. if gconv.String((*dataOrder)[0]["company_name"]) != "" {
  79. returnJson["company"] = gconv.String((*dataOrder)[0]["company_name"])
  80. }
  81. }
  82. }
  83. } else {
  84. //个人
  85. returnJson["isUpdate"] = false
  86. }
  87. //企业
  88. } else {
  89. //个人
  90. user, ok := Mgo.FindById("user", t.MgoUserId, "")
  91. log.Println("用户信息", user)
  92. if ok && user != nil && len(*user) > 0 {
  93. if _, ok1 := (*user)["identity_info"]; !ok1 {
  94. returnJson["isInit"] = false
  95. return returnJson
  96. }
  97. identityInfo := gconv.Map((*user)["identity_info"])
  98. if _, ok1 := identityInfo["is_init"]; !ok1 {
  99. returnJson["isInit"] = false
  100. return returnJson
  101. }
  102. if _, ok1 := (*user)["s_company"]; ok1 {
  103. log.Println("公司名字", (*user)["s_company"])
  104. returnJson["company"] = gconv.String((*user)["s_company"])
  105. }
  106. if !gconv.Bool(identityInfo["is_init"]) {
  107. //设置过
  108. returnJson["business"] = gconv.String(identityInfo["ent_businessType"])
  109. dataOrder := JianyuMysql.SelectBySql(`select company_name from dataexport_order where user_id=? and order_status=1 and product_type LIKE "%大会员%" and vip_endtime>now()`, t.MgoUserId)
  110. if dataOrder != nil && len(*dataOrder) > 0 {
  111. returnJson["company"] = gconv.String((*dataOrder)[0]["company_name"])
  112. }
  113. }
  114. }
  115. returnJson["isInit"] = true
  116. returnJson["isUpdate"] = true
  117. }
  118. return returnJson
  119. }