WH01243 1 год назад
Родитель
Сommit
3177ed4da7

+ 6 - 0
api/application.api

@@ -137,6 +137,9 @@ type (
 		PositionId int64 `json:"positionId"`
 		EntUserId  int64 `json:"entUserId"`
 	}
+	EntInfoReq {
+		EntName string `json:"entName"`
+	}
 )
 
 service crmApplication {
@@ -167,4 +170,7 @@ service crmApplication {
 	@doc "分发"
 	@handler  employDistribute
 	post /crmApplication/employ/distribute(EmployDistributeReq) returns (Reply)
+	@doc "企业详情"
+	@handler   entinfo
+	post /crmApplication/ent/info(EntInfoReq) returns (Reply)
 }

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

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

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

@@ -57,6 +57,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/crmApplication/employ/distribute",
 				Handler: employDistributeHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/crmApplication/ent/info",
+				Handler: entinfoHandler(serverCtx),
+			},
 		},
 	)
 }

+ 1 - 1
api/internal/logic/employdistributelogic.go

@@ -1,7 +1,7 @@
 package logic
 
 import (
-	"bp.jydev.jianyu360.cn/CRM/application/api/service"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/service"
 	"context"
 
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"

+ 1 - 1
api/internal/logic/employinfologic.go

@@ -1,7 +1,7 @@
 package logic
 
 import (
-	"bp.jydev.jianyu360.cn/CRM/application/api/service"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/service"
 	"context"
 
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"

+ 1 - 1
api/internal/logic/employoperatelogic.go

@@ -1,7 +1,7 @@
 package logic
 
 import (
-	"bp.jydev.jianyu360.cn/CRM/application/api/service"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/service"
 	"context"
 
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"

+ 37 - 0
api/internal/logic/entinfologic.go

@@ -0,0 +1,37 @@
+package logic
+
+import (
+	"bp.jydev.jianyu360.cn/CRM/application/service"
+	"context"
+
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type EntinfoLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewEntinfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EntinfoLogic {
+	return &EntinfoLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *EntinfoLogic) Entinfo(req *types.EntInfoReq) (resp *types.Reply, err error) {
+	// todo: add your logic here and delete this line
+	resp = &types.Reply{}
+	entService := &service.EntService{}
+	data, err := entService.EntInfo(req.EntName)
+	/*if err != nil {
+		resp.Error_msg = "未查询到企业信息"
+	}*/
+	resp.Data = data
+	return
+}

+ 1 - 1
api/internal/logic/ignoreoperatelogic.go

@@ -1,7 +1,7 @@
 package logic
 
 import (
-	"bp.jydev.jianyu360.cn/CRM/application/api/service"
+	"bp.jydev.jianyu360.cn/CRM/application/api/internal/service"
 	"context"
 
 	"bp.jydev.jianyu360.cn/CRM/application/api/internal/svc"

+ 60 - 55
api/service/EmployService.go → api/internal/service/employService.go

@@ -4,7 +4,6 @@ import (
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/date"
 	elastic "app.yhyue.com/moapp/jybase/es"
-	"app.yhyue.com/moapp/jybase/mongodb"
 	"app.yhyue.com/moapp/jypkg/ent/util"
 	"app.yhyue.com/moapp/jypkg/public"
 	MC "bp.jydev.jianyu360.cn/CRM/application/api/common"
@@ -32,7 +31,6 @@ type EmPloyService struct{}
 func (e *EmPloyService) InfoEmployinfo(in *types.InfoEmployinfoReq) []map[string]interface{} {
 	data := []map[string]interface{}{}
 	for _, v := range strings.Split(in.IdArr, ",") {
-		vint := int64(0)
 		table, findKey, employKey, source := EmployKeyFormat(in.EmployType)
 		id := ""
 		id = IdFormat(v, in.EmployType)
@@ -44,46 +42,51 @@ func (e *EmPloyService) InfoEmployinfo(in *types.InfoEmployinfoReq) []map[string
 			"id": v,
 		}
 		//有收录情况
-		summaryMap := SummaryFormat(in.PositionId)
+		//summaryMap := SummaryFormat(in.PositionId)
 		//vint = mongodb.StringTOBsonId(id).Timestamp().Unix()
-		vint = extractNumbers(id)
-		valueMap["isEmploy"] = summaryMap[in.EmployType].Contains(uint32(vint))
+		//vint = extractNumbers(id)
+		//valueMap["isEmploy"] = summaryMap[in.EmployType].Contains(uint32(vint))
+		employData := MC.CrmMysql.FindOne(table, map[string]interface{}{
+			employKey:     id,
+			"position_id": in.PositionId,
+			"source":      source,
+		}, "", "")
+		if employData != nil && len(*employData) > 0 {
+			valueMap["isIgnore"] = common.If(common.Int64All((*employData)["is_ignore"]) == 1, true, false)
+			valueMap["isEmploy"] = common.If(common.Int64All((*employData)["status"]) == 1, true, false)
+		} else {
+			valueMap["isIgnore"] = false
+			valueMap["isEmploy"] = false
+		}
+
 		if len(strings.Split(in.IdArr, ",")) == 1 {
 			//列表查询
 			//是否忽略处理
-			employData := MC.CrmMysql.FindOne(table, map[string]interface{}{
-				employKey:     id,
+			//客户数量
+			customCount := MC.CrmMysql.Count(entity.CUSTOM, map[string]interface{}{
+				findKey:       id,
 				"position_id": in.PositionId,
-				"source":      source,
-			}, "", "")
-			if employData != nil && len(*employData) > 0 {
-				valueMap["isIgnore"] = common.If(common.Int64All((*employData)["is_ignore"]) == 1, true, false)
-				//客户数量
-				customCount := MC.CrmMysql.Count(entity.CUSTOM, map[string]interface{}{
-					findKey:       id,
-					"position_id": in.PositionId,
+			})
+			valueMap["customCount"] = customCount
+			if in.EmployType == 1 || in.EmployType == 4 {
+				//销售线索数量
+				clueCount := MC.CrmMysql.Count(entity.SALE_CLUE, map[string]interface{}{
+					"employ_info_id": id,
+					"position_id":    in.PositionId,
 				})
-				valueMap["customCount"] = customCount
-				if in.EmployType == 1 || in.EmployType == 4 {
-					//销售线索数量
-					clueCount := MC.CrmMysql.Count(entity.SALE_CLUE, map[string]interface{}{
-						"employ_info_id": id,
-						"position_id":    in.PositionId,
-					})
-					valueMap["clueCount"] = clueCount
-					//销售机会数量
-					chanceCount := MC.CrmMysql.Count(entity.SALE_CHANCE, map[string]interface{}{
-						"employ_info_id": id,
-						"position_id":    in.PositionId,
-					})
-					valueMap["chanceCount"] = chanceCount
-				}
-			} else {
-				valueMap["chanceCount"] = 0
-				valueMap["clueCount"] = 0
-				valueMap["isIgnore"] = false
-				valueMap["customCount"] = 0
+				valueMap["clueCount"] = clueCount
+				//销售机会数量
+				chanceCount := MC.CrmMysql.Count(entity.SALE_CHANCE, map[string]interface{}{
+					"employ_info_id": id,
+					"position_id":    in.PositionId,
+				})
+				valueMap["chanceCount"] = chanceCount
 			}
+		} else {
+			valueMap["chanceCount"] = 0
+			valueMap["clueCount"] = 0
+			valueMap["isIgnore"] = false
+			valueMap["customCount"] = 0
 		}
 		data = append(data, valueMap)
 	}
@@ -94,9 +97,8 @@ func (e *EmPloyService) InfoEmployinfo(in *types.InfoEmployinfoReq) []map[string
 func (e *EmPloyService) EmployOperate(in *types.EmployOperateReq) bool {
 	//收录汇总表
 	table, _, employKey, source := EmployKeyFormat(in.EmployType)
-	summaryMap := SummaryFormat(in.PositionId)
+	//summaryMap := SummaryFormat(in.PositionId)
 	return MC.CrmMysql.ExecTx("收录操作", func(tx *sql.Tx) bool {
-		fool := false
 		for _, v1 := range strings.Split(in.IdArr, ",") {
 			//id转中文
 			id := ""
@@ -141,21 +143,21 @@ func (e *EmPloyService) EmployOperate(in *types.EmployOperateReq) bool {
 					log.Println(v1, id, in.EmployType, "取消收录失败")
 				}
 			}
-			//收录汇总表处理
+			/*//收录汇总表处理
 			vint := extractNumbers(id)
 			if in.IsEmploy {
 				summaryMap[in.EmployType].Add(uint32(vint))
 			} else {
 				summaryMap[in.EmployType].Remove(uint32(vint))
-			}
-			fool = true
+			}*/
+			//fool = true
 		}
-		if fool {
+		/*if fool {
 			return SummarySave(tx, in.PositionId, summaryMap)
 		} else {
 			return false
-		}
-
+		}*/
+		return true
 	})
 }
 
@@ -208,12 +210,7 @@ func InfoFind(id string, employType int64) map[string]interface{} {
 			obj = *aobj
 		}
 		if ok && obj != nil && len(obj) > 0 {
-			titleTmp := common.ObjToString(obj["title"])
-			if len([]rune(titleTmp)) > 100 {
-				titleTmp = string([]rune(titleTmp)[:100]) + "..."
-			}
-			titleTmp = public.ClearHtml.ReplaceAllString(titleTmp, "")
-			data["title"] = titleTmp
+			data["title"] = common.ObjToString(obj["title"])
 			data["city"] = obj["city"]
 			data["area"] = obj["area"]
 			data["subtype"] = obj["subtype"]
@@ -257,6 +254,8 @@ func InfoFind(id string, employType int64) map[string]interface{} {
 	data["create_time"] = time.Now().Format(date.Date_Full_Layout)
 	return data
 }
+
+// 通过采购单位名称获取id
 func getBuyerIdByName(buyeName string) (buyerId string) {
 	r := elastic.Get(BuyerIndex, BuyerType, fmt.Sprintf(`{"query":{"bool":{"must":[{"term":{"buyer_name":"%s"}}]}},"size":1,"_source":["city","id"]}`, buyeName))
 	if r == nil || len(*r) == 0 {
@@ -265,6 +264,8 @@ func getBuyerIdByName(buyeName string) (buyerId string) {
 	buyerId, _ = (*r)[0]["_id"].(string)
 	return
 }
+
+// id解密
 func IdFormat(encryptionId string, employType int64) string {
 	decryptId := ""
 	switch employType {
@@ -282,6 +283,8 @@ func IdFormat(encryptionId string, employType int64) string {
 	}
 	return decryptId
 }
+
+// 汇总表处理
 func SummaryFormat(positionId int64) map[int64]*roaring.Bitmap {
 	byte1 := []byte{}
 	byte2 := []byte{}
@@ -311,6 +314,8 @@ func SummaryFormat(positionId int64) map[int64]*roaring.Bitmap {
 	data[4] = rb4
 	return data
 }
+
+// 汇总表保存
 func SummarySave(tx *sql.Tx, positionId int64, data map[int64]*roaring.Bitmap) bool {
 	employSummaryData := MC.CrmMysql.FindOne(entity.EMPLOY_SUMMARY, map[string]interface{}{
 		"position_id": positionId,
@@ -420,13 +425,12 @@ func (e *EmPloyService) DistributePerson(in *types.EmployDistributeReq) bool {
 		for _, person := range in.Person {
 			personMap[person.PositionId] = PersonSmmary{
 				EntUserId: person.EntUserId,
-				Summary:   SummaryFormat(person.PositionId),
+				//Summary:   SummaryFormat(person.PositionId),
 			}
 		}
 		//分发数据处理
 		infoMap := map[string]map[string]interface{}{}
 		for positionId, personSmmary := range personMap {
-			fool := false
 			for _, v := range strings.Split(in.EmployIdArr, ",") {
 				VMap := map[string]interface{}{}
 				if infoMap[v] == nil {
@@ -472,17 +476,18 @@ func (e *EmPloyService) DistributePerson(in *types.EmployDistributeReq) bool {
 					VMap["ent_user_id"] = personSmmary.EntUserId
 					VMap["position_id"] = positionId
 					ok := MC.CrmMysql.InsertByTx(tx, entity.EMPLOY_INFO, VMap)
-					if ok > 0 {
+					return ok > 0
+					/*if ok > 0 {
 						employType := common.If(common.Int64All(VMap["source"]) == 1, 1, 4)
 						personSmmary.Summary[common.Int64All(employType)].Add(uint32(mongodb.StringTOBsonId(common.InterfaceToStr(VMap["source_id"])).Timestamp().Unix()))
 						fool = true
-					}
+					}*/
 				}
-				if fool {
+				/*if fool {
 					if !SummarySave(tx, positionId, personSmmary.Summary) {
 						return false
 					}
-				}
+				}*/
 			}
 		}
 		return true

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

@@ -139,3 +139,7 @@ type DistributePerson struct {
 	PositionId int64 `json:"positionId"`
 	EntUserId  int64 `json:"entUserId"`
 }
+
+type EntInfoReq struct {
+	EntName string `json:"entName"`
+}

+ 80 - 0
service/ent.go

@@ -0,0 +1,80 @@
+package service
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	MC "bp.jydev.jianyu360.cn/CRM/application/api/common"
+	"errors"
+	"log"
+	"strings"
+	"time"
+)
+
+type EntService struct {
+}
+
+const (
+	Date_Full_Layout  = "2006-01-02 15:04:05"
+	Date_Short_Layout = "2006-01-02"
+)
+
+func (in *EntService) EntInfo(entName string) (map[string]interface{}, error) {
+	entinfo, _ := MC.MgoEnt.FindOneByField("qyxy_std", map[string]interface{}{"company_name": entName}, map[string]interface{}{
+		"company_type": 1, //公司类型
+		//"issue_date":          1, //核准日期
+		"operation_startdate": 1, //营业期限开始
+		"operation_enddate":   1, //营业期限结束
+		//"authority":           1, //登记机关
+		"credit_no":       1, //统一社会信用代码
+		"tax_code":        1, //纳税人识别码
+		"capital":         1, //注册资本
+		"establish_date":  1, //成立日期
+		"company_status":  1, //经营状态
+		"employee_no":     1, //员工规模
+		"company_address": 1, //注册地
+		"business_scope":  1, //经营范围
+		"company_code":    1, //工商注册号
+		"org_code":        1, //组织机构代码
+		//"stock_realcapital":   1, //实缴资本
+		"legal_person":  1, //法人姓名
+		"company_phone": 1, //公司电话
+	})
+	if entinfo == nil || len(*entinfo) == 0 {
+		log.Println()
+		return nil, errors.New("未查询到企业相关信息")
+	}
+	rData := map[string]interface{}{
+		"type":         (*entinfo)["company_type"],
+		"status":       (*entinfo)["company_status"],
+		"creditNo":     (*entinfo)["credit_no"],
+		"taxCode":      (*entinfo)["tax_code"],
+		"capital":      (*entinfo)["capital"],
+		"employeeNo":   (*entinfo)["employee_no"],
+		"address":      (*entinfo)["company_address"],
+		"scope":        (*entinfo)["business_scope"],
+		"company_code": (*entinfo)["company_code"],
+		"org_code":     (*entinfo)["org_code"],
+		"operStart":    paseDateToint64(common.ObjToString((*entinfo)["operation_startdate"])),
+		"operEnd":      paseDateToint64(common.ObjToString((*entinfo)["operation_enddate"])),
+		"establish":    paseDateToint64(common.ObjToString((*entinfo)["establish_date"])),
+		"legal":        (*entinfo)["legal_person"],
+		"phone":        (*entinfo)["company_phone"],
+		"entName":      (*entinfo)["company_name"],
+	}
+	return rData, nil
+}
+func paseDateToint64(dateStr string) (timeStamp int64) {
+	timeStamp = -1
+	if dateStr == "" {
+		return
+	}
+	if thisTime, err := time.Parse(Date_Short_Layout, dateStr); err == nil {
+		timeStamp = thisTime.Unix()
+	}
+	//企业变更部分信息时间格式2017-04-18 00:00:00.0
+	if len(strings.Split(dateStr, " ")) == 2 {
+		if thisTime, err := time.Parse(Date_Full_Layout, dateStr); err == nil {
+			timeStamp = thisTime.Unix()
+		}
+	}
+	return
+}