Răsfoiți Sursa

新增初始化接口

WH01243 9 luni în urmă
părinte
comite
d703baceac

+ 6 - 0
api/common/initconfig.go

@@ -1,6 +1,7 @@
 package common
 
 import (
+	"app.yhyue.com/moapp/jypkg/middleground"
 	"context"
 	"flag"
 	"fmt"
@@ -35,6 +36,7 @@ var (
 	JianyuMysql    *mysql.Mysql
 	Mgo            mongodb.MongodbSim
 	ClickhouseConn driver.Conn
+	Middleground   *middleground.Middleground
 )
 
 func InitConf() {
@@ -120,6 +122,10 @@ func InitConf() {
 	redis.InitRedis(DB.Redis)
 
 	ConnectClickhouse(DB.Clickhouse)
+	Middleground = middleground.NewMiddleground(C.CodeServiceConf.Etcd.Hosts).
+		RegUserCenter(C.UserCenterKey).
+		RegPowerCheckCenter(C.PowerCheckCenterKey).
+		RegEntManageApplication(C.EntManageApplication)
 }
 func ConnectClickhouse(cHouseConfig *config.CHouseConfig) error {
 	var (

+ 11 - 1
api/etc/networkmanage.yaml

@@ -7,4 +7,14 @@ Gateway:
   Etcd:
     - 192.168.3.207:2379
     - 192.168.3.165:2379
-    - 192.168.3.204:2379
+    - 192.168.3.204:2379
+CodeServiceConf:
+  Etcd:
+    Hosts:
+      - 192.168.3.207:2379
+      - 192.168.3.165:2379
+      - 192.168.3.204:2379
+    Key: codeservice.rpc
+UserCenterKey: "usercenter.rpc" #用户中台rpc
+PowerCheckCenterKey: "powercheck.rpc" #权益校验中台
+EntManageApplication: "entmanageapplication.rpc" #企业管理中台    -

+ 5 - 0
api/internal/config/config.go

@@ -3,6 +3,7 @@ package config
 import (
 	"bp.jydev.jianyu360.cn/CRM/networkManage/entity"
 	"github.com/zeromicro/go-zero/rest"
+	"github.com/zeromicro/go-zero/zrpc"
 )
 
 type Config struct {
@@ -11,6 +12,10 @@ type Config struct {
 		ServerCode string
 		Etcd       []string
 	}
+	UserCenterKey        string
+	PowerCheckCenterKey  string
+	EntManageApplication string
+	CodeServiceConf      zrpc.RpcClientConf
 }
 
 type Db struct {

+ 28 - 0
api/internal/handler/findinitinfohandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/logic"
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func findInitInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.FindInitInfoReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewFindInitInfoLogic(r.Context(), svcCtx)
+		resp, err := l.FindInitInfo(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 10 - 0
api/internal/handler/routes.go

@@ -72,6 +72,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/networkManage/owner/cooperate",
 				Handler: ownerCooperateHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/networkManage/init/findInitInfo",
+				Handler: findInitInfoHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/networkManage/init/updateInitInfo",
+				Handler: updateInitInfoHandler(serverCtx),
+			},
 		},
 	)
 }

+ 28 - 0
api/internal/handler/updateinitinfohandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/logic"
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func updateInitInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.UpdateInitInfoReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := logic.NewUpdateInitInfoLogic(r.Context(), svcCtx)
+		resp, err := l.UpdateInitInfo(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 42 - 0
api/internal/logic/findinitinfologic.go

@@ -0,0 +1,42 @@
+package logic
+
+import (
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/service"
+	"context"
+
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type FindInitInfoLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewFindInitInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindInitInfoLogic {
+	return &FindInitInfoLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *FindInitInfoLogic) FindInitInfo(req *types.FindInitInfoReq) (resp *types.Reply, err error) {
+	// todo: add your logic here and delete this line
+	resp = &types.Reply{}
+	initInfoService := &service.InitInfoService{
+		PositionType: req.PositionType,
+		MgoUserId:    req.MgoUserId,
+		EntId:        req.EntId,
+		NewUserId:    req.NewUserId,
+		AccountId:    req.AccountId,
+		PositionId:   req.PositionId,
+		EntUserId:    req.EntUserId,
+	}
+	data := initInfoService.FindInitInfo()
+	resp.Data = data
+	return
+}

+ 2 - 0
api/internal/logic/ownerlistlogic.go

@@ -44,6 +44,8 @@ func (l *OwnerListLogic) OwnerList(req *types.OwnerListReq) (resp *types.Reply,
 		PageSize:      req.PageSize,
 		ProjectType:   req.ProjectType,
 		EntAccountId:  req.EntAccountId,
+		EntId:         req.EntId,
+		UserId:        req.MgoUserId,
 	}
 	data := ownerService.OwnerlList()
 	resp.Data = data

+ 51 - 0
api/internal/logic/updateinitinfologic.go

@@ -0,0 +1,51 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/service"
+	"context"
+	"github.com/gogf/gf/v2/util/gconv"
+
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type UpdateInitInfoLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewUpdateInitInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateInitInfoLogic {
+	return &UpdateInitInfoLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *UpdateInitInfoLogic) UpdateInitInfo(req *types.UpdateInitInfoReq) (resp *types.Reply, err error) {
+	// todo: add your logic here and delete this line
+	resp = &types.Reply{}
+	initInfoService := &service.InitInfoService{
+		PositionType: req.PositionType,
+		MgoUserId:    req.MgoUserId,
+		EntId:        req.EntId,
+		NewUserId:    req.NewUserId,
+		AccountId:    req.AccountId,
+		PositionId:   req.PositionId,
+		EntUserId:    req.EntUserId,
+	}
+	fool := initInfoService.UpdateInitInfo(req.Company, req.BusinessType)
+	resp.Data = map[string]interface{}{
+		"status": gconv.Int64(common.If(fool, 1, 0)),
+	}
+	if fool {
+		resp.Error_msg = "修改成功"
+	} else {
+		resp.Error_msg = "修改失败"
+	}
+	return
+}

+ 124 - 0
api/internal/service/initInfo.go

@@ -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
+}

+ 31 - 27
api/internal/service/owner.go

@@ -43,6 +43,8 @@ type OwnerService struct {
 	EntAccountId  int64
 	ProjectType   string
 	Type          string
+	EntId         int64
+	UserId        string
 }
 
 type BuyerProject struct {
@@ -80,7 +82,7 @@ func (t *OwnerService) OwnerlList() map[string]interface{} {
 	startTime := time.Now().Unix()
 	dataMap := &map[string]map[string]interface{}{}
 	projectMap := &map[string]map[string]interface{}{}
-	businessStr := FindBusiness(t.EntAccountId)
+	businessStr := FindBusiness(t.EntId, t.UserId)
 	returnData, connectionsNumber, highSuccessNumber, monitorNumber := []BuyerProject{}, int64(0), int64(0), int64(0)
 	if businessStr == "" {
 		return map[string]interface{}{
@@ -1061,31 +1063,33 @@ func (t *OwnerService) OwnerCooperate() []map[string]interface{} {
 }
 
 // 物业业务类型查询
-func FindBusiness(entUserId int64) string {
-	//先查询他的上级
-	entList := JianyuMysql.SelectBySql("select b.phone from   entniche_user   a    INNER JOIN   entniche_info  b  on   a.id=?   and   a.ent_id =b.id ", entUserId)
-	if entList == nil || len(*entList) == 0 {
-		return ""
-	}
-	//获取手机号
-	phone := gconv.String((*entList)[0]["phone"])
-	datas, _ := Mgo.Find("user", map[string]interface{}{
-		"i_appid": 2,
-		"$or": []map[string]interface{}{
-			{"s_phone": phone},
-			{"s_m_phone": phone},
-		},
-	}, `{"s_phone":-1}`, `{"s_phone":1,"s_m_phone":1}`, false, 0, 1)
-	if datas != nil || len(*datas) == 0 {
-		return ""
-	}
-	//
-	if _, ok := (*datas)[0]["identity_info"]; !ok {
-		return ""
-	}
-	identity_info := gconv.Map((*datas)[0]["identity_info"])
-	if _, ok := identity_info["ent_businessType"]; !ok {
-		return ""
+func FindBusiness(endId int64, userId string) string {
+	businessStr := ""
+	if endId != 0 {
+		//企业
+		entInfo := JianyuMysql.FindOne("entniche_info", map[string]interface{}{
+			"id": endId,
+		}, "", "")
+		if (*entInfo)["identityInfo"] != nil {
+			entMap := gconv.Map((*entInfo)["identityInfo"])
+			businessStr = gconv.String(entMap["business"])
+		}
+	} else {
+		//个人
+		user, ok := Mgo.FindById("user", userId, "")
+		if ok && user != nil && len(*user) > 0 {
+			if _, ok1 := (*user)["identity_info"]; !ok1 {
+				return ""
+			}
+			identityInfo := gconv.Map((*user)["identity_info"])
+			if _, ok1 := identityInfo["is_init"]; !ok1 {
+				return ""
+			}
+			if !gconv.Bool(identityInfo["is_init"]) {
+				//设置过
+				businessStr = gconv.String(identityInfo["ent_businessType"])
+			}
+		}
 	}
-	return gconv.String(identity_info["ent_businessType"])
+	return businessStr
 }

+ 24 - 0
api/internal/types/types.go

@@ -22,6 +22,8 @@ type OwnerListReq struct {
 	PageIndex        int64  `json:"pageIndex,optional"`
 	ProjectType      string `json:"projectType,optional"`
 	EntAccountId     int64  `header:"entAccountId"`
+	EntId            int64  `header:"entId,optional"`
+	MgoUserId        string `header:"mgoUserId,optional"` //原userId
 }
 
 type ProjectListReq struct {
@@ -141,3 +143,25 @@ type CooperateOwnerListReq struct {
 	CooperateType string `json:"cooperateType,optional"`
 	PositionId    int64  `header:"positionId,optional"`
 }
+
+type UpdateInitInfoReq struct {
+	BusinessType string `json:"businessType,optional"`
+	Company      string `json:"company,optional"`
+	EntId        int64  `header:"entId,optional"`
+	MgoUserId    string `header:"mgoUserId,optional"` //原userId
+	NewUserId    int64  `header:"newUserId"`
+	AccountId    int64  `header:"accountId,optional"`
+	PositionId   int64  `header:"positionId,optional"`
+	PositionType int64  `header:"positionType,optional"`
+	EntUserId    int64  `header:"entUserId,optional"`
+}
+
+type FindInitInfoReq struct {
+	EntId        int64  `header:"entId,optional"`
+	MgoUserId    string `header:"mgoUserId,optional"` //原userId
+	PositionType int64  `header:"positionType,optional"`
+	NewUserId    int64  `header:"newUserId"`
+	AccountId    int64  `header:"accountId,optional"`
+	PositionId   int64  `header:"positionId,optional"`
+	EntUserId    int64  `header:"entUserId,optional"`
+}

+ 41 - 11
api/networkmanage.api

@@ -21,6 +21,8 @@ type (
 		PageIndex        int64  `json:"pageIndex,optional"`
 		ProjectType      string `json:"projectType,optional"`
 		EntAccountId     int64  `header:"entAccountId"`
+		EntId            int64  `header:"entId,optional"`
+		MgoUserId        string `header:"mgoUserId,optional"` //原userId
 	}
 	ProjectListReq {
 		UserId       string `header:"userId,optional"`
@@ -129,54 +131,82 @@ type (
 		CooperateType string `json:"cooperateType,optional"`
 		PositionId    int64  `header:"positionId,optional"`
 	}
+	UpdateInitInfoReq {
+		BusinessType string `json:"businessType,optional"`
+		Company      string `json:"company,optional"`
+		EntId        int64  `header:"entId,optional"`
+		MgoUserId    string `header:"mgoUserId,optional"` //原userId
+		NewUserId    int64  `header:"newUserId"`
+		AccountId    int64  `header:"accountId,optional"`
+		PositionId   int64  `header:"positionId,optional"`
+		PositionType int64  `header:"positionType,optional"`
+		EntUserId    int64  `header:"entUserId,optional"`
+	}
+	FindInitInfoReq {
+		EntId        int64  `header:"entId,optional"`
+		MgoUserId    string `header:"mgoUserId,optional"` //原userId
+		PositionType int64  `header:"positionType,optional"`
+		NewUserId    int64  `header:"newUserId"`
+		AccountId    int64  `header:"accountId,optional"`
+		PositionId   int64  `header:"positionId,optional"`
+		EntUserId    int64  `header:"entUserId,optional"`
+	}
 )
 
 service networkManage {
 	@doc "人脉可达潜客业主列表"
 	@handler ownerList
 	post /networkManage/owner/list (OwnerListReq) returns (Reply)
-	
+
 	@doc "人脉可达商机列表"
 	@handler projectList
 	post /networkManage/network/project/list (ProjectListReq) returns (Reply)
-	
+
 	@doc "项目公关渠道分析-项目名称联想"
 	@handler PrPnameAss
 	post /networkManage/pr/pname/ass (PnameAssReq) returns (Reply)
-	
+
 	@doc "项目公关渠道分析-与业主合作历史"
 	@handler CoopHistoryList
 	post /networkManage/pr/project/analyse (CoopHistoryReq) returns (Reply)
-	
+
 	@doc "人脉库-添加/修改人脉"
 	@handler addOrUpdate
 	post /networkManage/network/addOrUpdate (AddOrUpdateReq) returns (Reply)
-	
+
 	@doc "人脉库-业主名称联想"
 	@handler associate
 	post /networkManage/network/associate (AssociateReq) returns (Reply)
-	
+
 	@doc "人脉库-全部人脉项目"
 	@handler allProject
 	post /networkManage/network/allProject (AllprojectReq) returns (Reply)
-	
+
 	@doc "人脉库-列表"
 	@handler networkList
 	post /networkManage/network/networkList (NetWorkListReq) returns (Reply)
-	
+
 	@doc "情报详情"
 	@handler infoDetail
 	post /networkManage/infomation/detail (InfoDetailReq) returns (Reply)
-	
+
 	@doc "人脉项目分析-业主合作历史"
 	@handler projectHistory
 	post /networkManage/pr/project/history (PrjectHistoryReq) returns (Reply)
-	
+
 	@doc "可介绍业主路径"
 	@handler ownerRoute
 	post /networkManage/owner/route (RouteOwnerListReq) returns (Reply)
-	
+
 	@doc "可介绍业主合作次数"
 	@handler ownerCooperate
 	post /networkManage/owner/cooperate (CooperateOwnerListReq) returns (Reply)
+
+	@doc "初始化设置查看"
+	@handler findInitInfo
+	post /networkManage/init/findInitInfo (FindInitInfoReq) returns (Reply)
+
+	@doc "初始化设置"
+	@handler updateInitInfo
+	post /networkManage/init/updateInitInfo (UpdateInitInfoReq) returns (Reply)
 }