浏览代码

Merge branch 'feature/v1.0.4' of https://jygit.jydev.jianyu360.cn/CRM/application into feature/v1.0.4

wangchuanjin 1 年之前
父节点
当前提交
29fba22145

+ 4 - 4
api/application.api

@@ -53,8 +53,8 @@ type (
 		CustomId          int64   `json:"customId,optional"`          //客户id
 		CreateName        string  `json:"createName"`                 //创建人
 		ChanceSource      int64   `json:"chanceSource"`               //机会来源
-		OwnerId           int64   `json:"ownerId,optional"`           //潜客收录id(人脉)
-		BusinessId        int64   `json:"businessId,optional"`        //商机收录id(人脉)
+		OwnerId           string  `json:"ownerId,optional"`           //潜客收录id(人脉)
+		BusinessId        string  `json:"businessId,optional"`        //商机收录id(人脉)
 	}
 	EmployOperateReq {
 		AppId      string `header:"appId,default=10000"`
@@ -130,8 +130,8 @@ type (
 		Remarks              string  `json:"remarks,optional"`                 //备注
 		CreateName           string  `json:"createName"`                       //创建人
 		Source               string  `json:"source,optional"`                  //来源
-		OwnerId              int64   `json:"ownerId,optional"`                 //潜客收录id(人脉)
-		BusinessId           int64   `json:"businessId,optional"`              //商机收录id(人脉)
+		OwnerId              string  `json:"ownerId,optional"`                 //潜客收录id(人脉)
+		BusinessId           string  `json:"businessId,optional"`              //商机收录id(人脉)
 	}
 	FileUploadReq {
 		AppId      string `header:"appId,default=10000"`

+ 16 - 13
api/internal/service/CoopHistoryService.go

@@ -24,19 +24,22 @@ var (
 )
 
 type ResultData struct {
-	SourceType   string  `json:"SourceType"`
-	EntName      string  `json:"EntName"`
-	EntId        string  `json:"EntId"`
-	EntPerson    string  `json:"EntPerson"`
-	Middleman    string  `json:"Middleman"`
-	ProjectNum   int     `json:"ProjectNum"`
-	TotalAmount  float64 `json:"TotalAmount"`
-	RecentTime   int64   `json:"RecentTime"`
-	NearlyYears  bool    `json:"NearlyYears"`
-	SupEnt       string  `json:"SupEnt"`       // 上级
-	NextEnt      string  `json:"NextEnt"`      // 下级
-	Relationship string  `json:"Relationship"` // 关系
-	BuyerId      string  `json:"BuyerId"`
+	SourceType       string  `json:"SourceType"`
+	EntName          string  `json:"EntName"`
+	EntId            string  `json:"EntId"`
+	EntPerson        string  `json:"EntPerson"`
+	Middleman        string  `json:"Middleman"`
+	ProjectNum       int     `json:"ProjectNum"`
+	TotalAmount      float64 `json:"TotalAmount"`
+	RecentTime       int64   `json:"RecentTime"`
+	NearlyYears      bool    `json:"NearlyYears"`
+	SupEnt           string  `json:"SupEnt"`       // 上级
+	NextEnt          string  `json:"NextEnt"`      // 下级
+	Relationship     string  `json:"Relationship"` // 关系
+	BuyerId          string  `json:"BuyerId"`
+	IsCreateCustomer bool    `json:"isCreateCustomer"`
+	IsIgnore         bool    `json:"isIgnore"`
+	IsMonitor        bool    `json:"isMonitor"`
 }
 
 type ProjectTmp struct {

+ 28 - 6
api/internal/service/owner.go

@@ -1095,6 +1095,7 @@ func (t *OwnerService) CandidateChannel() []*ResultData {
 						TotalAmount: common.Float64All(m["coop_amount"]),
 						RecentTime:  zbtime,
 						NearlyYears: near,
+						BuyerId:     common.ObjToString(m["nameId"]),
 					}
 					returnData = append(returnData, &tmp)
 				}
@@ -1110,6 +1111,7 @@ func (t *OwnerService) CandidateChannel() []*ResultData {
 						EntName:      common.ObjToString(m["b_name"]),
 						EntPerson:    common.ObjToString(m["personName"]),
 						Relationship: "业主的关系人",
+						BuyerId:      common.ObjToString(m["b_id"]),
 					}
 					returnData = append(returnData, &tmp)
 				}
@@ -1124,6 +1126,7 @@ func (t *OwnerService) CandidateChannel() []*ResultData {
 						EntName:      common.ObjToString(m["b_name"]),
 						EntPerson:    common.ObjToString(m["personName"]),
 						Relationship: common.ObjToString(m["relationship"]),
+						BuyerId:      common.ObjToString(m["b_id"]),
 					}
 					returnData = append(returnData, &tmp)
 				}
@@ -1131,12 +1134,31 @@ func (t *OwnerService) CandidateChannel() []*ResultData {
 		}
 	}
 	//状态处理
-	/*if len(returnData) > 0 {
-		untreatedMap, ignoredMap, createdMap := FindStatus(t.PositionId)
-		for k, v := range returnData {
-
+	if len(returnData) > 0 {
+		monitorMap := map[string]bool{}
+		query := map[string]interface{}{
+			"userId": gconv.String(t.PositionId),
 		}
-	}*/
-
+		clist, ok := Mgo.Find("follow_customer", query, ``, `{"name":1}`, false, -1, -1)
+		if ok && clist != nil && len(*clist) > 0 {
+			for _, v := range *clist {
+				monitorMap[gconv.String(v["name"])] = true
+			}
+		}
+		_, ignoredMap, createdMap := FindStatus(t.PositionId)
+		for k, value := range returnData {
+			buyerId := value.BuyerId
+			if _, ok := ignoredMap[buyerId]; ok {
+				value.IsIgnore = true
+			}
+			if _, ok := createdMap[buyerId]; ok {
+				value.IsCreateCustomer = true
+			}
+			if _, ok := monitorMap[buyerId]; ok {
+				value.IsMonitor = true
+			}
+			returnData[k] = value
+		}
+	}
 	return returnData
 }

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

@@ -56,8 +56,8 @@ type SaleChanceReq struct {
 	CustomId          int64   `json:"customId,optional"`          //客户id
 	CreateName        string  `json:"createName"`                 //创建人
 	ChanceSource      int64   `json:"chanceSource"`               //机会来源
-	OwnerId           int64   `json:"ownerId,optional"`           //潜客收录id(人脉)
-	BusinessId        int64   `json:"businessId,optional"`        //商机收录id(人脉)
+	OwnerId           string  `json:"ownerId,optional"`           //潜客收录id(人脉)
+	BusinessId        string  `json:"businessId,optional"`        //商机收录id(人脉)
 }
 
 type EmployOperateReq struct {
@@ -138,8 +138,8 @@ type CustomAddReq struct {
 	Remarks              string  `json:"remarks,optional"`                 //备注
 	CreateName           string  `json:"createName"`                       //创建人
 	Source               string  `json:"source,optional"`                  //来源
-	OwnerId              int64   `json:"ownerId,optional"`                 //潜客收录id(人脉)
-	BusinessId           int64   `json:"businessId,optional"`              //商机收录id(人脉)
+	OwnerId              string  `json:"ownerId,optional"`                 //潜客收录id(人脉)
+	BusinessId           string  `json:"businessId,optional"`              //商机收录id(人脉)
 }
 
 type FileUploadReq struct {

+ 7 - 7
service/custom.go

@@ -46,8 +46,8 @@ type CustomService struct {
 	Remarks              string  //备注
 	CreateName           string  //创建人
 	Source               string
-	OwnerId              int64 //潜客收录id(人脉)
-	BusinessId           int64 //商机收录id(人脉)
+	OwnerId              string //潜客收录id(人脉)
+	BusinessId           string //商机收录id(人脉)
 }
 
 // Add 创建客户
@@ -229,7 +229,7 @@ func EmployUpdate(tx *sql.Tx, employ_info_id, employ_custom_id, positionId int64
 	return employ_info_id, employ_custom_id
 }
 
-func SaveCustom(ctx context.Context, argsCustom, argsTask, argsTaskTeam []interface{}, employ_info_id, employ_custom_id, ownerId, connectionBusinessId, positionId int64, createPerson string, transferArr []int64, entId, entUserId, entDeptId int64) (int64, int64) {
+func SaveCustom(ctx context.Context, argsCustom, argsTask, argsTaskTeam []interface{}, employ_info_id, employ_custom_id int64, ownerId, connectionBusinessId string, positionId int64, createPerson string, transferArr []int64, entId, entUserId, entDeptId int64) (int64, int64) {
 	customId := int64(-1)
 	taskId := int64(-1)
 	//存库
@@ -250,7 +250,7 @@ func SaveCustom(ctx context.Context, argsCustom, argsTask, argsTaskTeam []interf
 		//插入台账
 		ok2 := SaveLedger(ctx, positionId, customId, taskId, "创建客户", fmt.Sprintf("%s创建了客户", createPerson), createPerson)
 		//人脉信息添加
-		if ownerId != 0 || connectionBusinessId != 0 {
+		if ownerId != "" || connectionBusinessId != "" {
 			SaveConnection(tx, positionId, connectionBusinessId, ownerId, entId, entDeptId, entUserId)
 		}
 		if customId > 0 && taskId > 0 && ok2 {
@@ -329,11 +329,11 @@ func GetOtherKey(key string) []string {
 	}
 	return parameters[key]
 }
-func SaveConnection(tx *sql.Tx, positionId, businessId, ownerId, entId, entDeptId, entUserId int64) bool {
-	if businessId != 0 || ownerId != 0 {
+func SaveConnection(tx *sql.Tx, positionId int64, businessId, ownerId string, entId, entDeptId, entUserId int64) bool {
+	if businessId != "" || ownerId != "" {
 		table := entity.CONNECTION_STATUS
 		sourceType := 2
-		if businessId == 0 {
+		if businessId == "" {
 			businessId = ownerId
 			sourceType = 1
 		}

+ 4 - 4
service/sale_chance.go

@@ -42,8 +42,8 @@ type SaleChanceService struct {
 	CustomId          int64   //客户id
 	CreateName        string
 	ChanceSource      int64
-	OwnerId           int64 //潜客收录id(人脉)
-	BusinessId        int64 //商机收录id(人脉)
+	OwnerId           string //潜客收录id(人脉)
+	BusinessId        string //商机收录id(人脉)
 }
 
 // Add 创建机会
@@ -171,7 +171,7 @@ func SaleChangeAdd(tx *sql.Tx, args []interface{}) int64 {
 }
 
 // Save 存库
-func (this *SaleChanceService) SaveChange(ctx context.Context, argsChange, argsTask, argsTaskTeam []interface{}, transferArr []int64, ownerId, connectionBusinessId int64) (int64, int64) {
+func (this *SaleChanceService) SaveChange(ctx context.Context, argsChange, argsTask, argsTaskTeam []interface{}, transferArr []int64, ownerId, connectionBusinessId string) (int64, int64) {
 	//存库
 	changeId, taskId := int64(-1), int64(-1)
 	cm.CrmMysql.ExecTx("创建机会", func(tx *sql.Tx) bool {
@@ -205,7 +205,7 @@ func (this *SaleChanceService) SaveChange(ctx context.Context, argsChange, argsT
 		}
 		SalesFunnel := saveSalesFunnel(tx, argsSalesFunnel, this.BusinessType)
 		//人脉保存
-		if ownerId != 0 || connectionBusinessId != 0 {
+		if ownerId != "" || connectionBusinessId != "" {
 			SaveConnection(tx, this.PositionId, connectionBusinessId, ownerId, this.EntId, this.EntDeptId, this.EntUserId)
 		}
 		if changeId > 0 && taskId > 0 && ok1 && planId > 0 && SalesFunnel > 0 {