|
@@ -0,0 +1,124 @@
|
|
|
+package service
|
|
|
+
|
|
|
+import (
|
|
|
+ . "bp.jydev.jianyu360.cn/CRM/networkManage/api/common"
|
|
|
+ "github.com/gogf/gf/v2/util/gconv"
|
|
|
+ "log"
|
|
|
+)
|
|
|
+
|
|
|
+type InitInfoService struct {
|
|
|
+ PositionType int64
|
|
|
+ MgoUserId string
|
|
|
+ EntId int64
|
|
|
+ NewUserId int64
|
|
|
+ AccountId int64
|
|
|
+ PositionId int64
|
|
|
+ EntUserId int64
|
|
|
+}
|
|
|
+
|
|
|
+func (t *InitInfoService) UpdateInitInfo(company, business string) bool {
|
|
|
+ fool := false
|
|
|
+ if t.PositionType == 1 {
|
|
|
+ //企业
|
|
|
+ userInfo := Middleground.PowerCheckCenter.Check("10000", t.MgoUserId, t.NewUserId, gconv.Int64(t.AccountId), t.EntId, t.PositionType, gconv.Int64(t.PositionId))
|
|
|
+ fool = Mgo.Update("ent_user", map[string]interface{}{
|
|
|
+ "i_entid": t.EntId,
|
|
|
+ "i_userid": t.EntUserId,
|
|
|
+ }, map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "is_init": true,
|
|
|
+ },
|
|
|
+ }, false, false)
|
|
|
+ if userInfo.Ent.EntRoleId == 1 {
|
|
|
+ //企业管理员
|
|
|
+ fool = JianyuMysql.Update("entniche_info", map[string]interface{}{
|
|
|
+ "id": t.EntId,
|
|
|
+ }, map[string]interface{}{
|
|
|
+ "identityInfo": map[string]interface{}{
|
|
|
+ "company": company,
|
|
|
+ "business": business,
|
|
|
+ },
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ fool = Mgo.UpdateById("user", t.MgoUserId, map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "identity_info.is_init": true,
|
|
|
+ "identity_info.ent_businessType": business,
|
|
|
+ "s_company": company,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return fool
|
|
|
+}
|
|
|
+func (t *InitInfoService) FindInitInfo() map[string]interface{} {
|
|
|
+ returnJson := map[string]interface{}{}
|
|
|
+ if t.PositionType == 1 {
|
|
|
+ isInit := false
|
|
|
+ userInfo := Middleground.PowerCheckCenter.Check("10000", t.MgoUserId, t.NewUserId, gconv.Int64(t.AccountId), t.EntId, t.PositionType, gconv.Int64(t.PositionId))
|
|
|
+ entUserInfo, _ := Mgo.FindOne("ent_user", map[string]interface{}{"i_entid": t.EntId, "i_userid": t.EntUserId})
|
|
|
+ if userInfo != nil && len(*entUserInfo) > 0 {
|
|
|
+ isInit = gconv.Bool((*entUserInfo)["is_init"])
|
|
|
+ returnJson["isInit"] = isInit
|
|
|
+ }
|
|
|
+ if isInit {
|
|
|
+ entInfo := JianyuMysql.FindOne("entniche_info", map[string]interface{}{
|
|
|
+ "id": t.EntId,
|
|
|
+ }, "", "")
|
|
|
+ if (*entInfo)["identityInfo"] != nil {
|
|
|
+ entMap := gconv.Map((*entInfo)["identityInfo"])
|
|
|
+ returnJson["company"] = entMap["company"]
|
|
|
+ returnJson["business"] = entMap["business"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if userInfo.Ent.EntRoleId == 1 {
|
|
|
+ //企业管理员
|
|
|
+ returnJson["isUpdate"] = true
|
|
|
+ if !isInit {
|
|
|
+ //查询订单信息
|
|
|
+ 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)
|
|
|
+ if dataOrder != nil && len(*dataOrder) > 0 {
|
|
|
+ if gconv.String((*dataOrder)[0]["company_name"]) != "" {
|
|
|
+ returnJson["company"] = gconv.String((*dataOrder)[0]["company_name"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //个人
|
|
|
+ returnJson["isUpdate"] = false
|
|
|
+ }
|
|
|
+ //企业
|
|
|
+ } else {
|
|
|
+ //个人
|
|
|
+ user, ok := Mgo.FindById("user", t.MgoUserId, "")
|
|
|
+ log.Println("用户信息", user)
|
|
|
+ if ok && user != nil && len(*user) > 0 {
|
|
|
+ if _, ok1 := (*user)["identity_info"]; !ok1 {
|
|
|
+ returnJson["isInit"] = false
|
|
|
+ return returnJson
|
|
|
+ }
|
|
|
+ identityInfo := gconv.Map((*user)["identity_info"])
|
|
|
+ if _, ok1 := identityInfo["is_init"]; !ok1 {
|
|
|
+ returnJson["isInit"] = false
|
|
|
+ return returnJson
|
|
|
+ }
|
|
|
+ if _, ok1 := (*user)["s_company"]; ok1 {
|
|
|
+ log.Println("公司名字", (*user)["s_company"])
|
|
|
+ returnJson["company"] = gconv.String((*user)["s_company"])
|
|
|
+ }
|
|
|
+ if !gconv.Bool(identityInfo["is_init"]) {
|
|
|
+ //设置过
|
|
|
+ returnJson["business"] = gconv.String(identityInfo["ent_businessType"])
|
|
|
+ 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)
|
|
|
+ if dataOrder != nil && len(*dataOrder) > 0 {
|
|
|
+ returnJson["company"] = gconv.String((*dataOrder)[0]["company_name"])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ returnJson["isInit"] = true
|
|
|
+ returnJson["isUpdate"] = true
|
|
|
+
|
|
|
+ }
|
|
|
+ return returnJson
|
|
|
+}
|