Browse Source

分发操作修改

WH01243 1 year ago
parent
commit
534f21ff15
1 changed files with 37 additions and 50 deletions
  1. 37 50
      api/internal/service/employService.go

+ 37 - 50
api/internal/service/employService.go

@@ -167,7 +167,7 @@ func (e *EmPloyService) EmployOperate(in *types.EmployOperateReq) bool {
 // CustomFind 企业信息查询
 func CustomFind(id string, employType int64) map[string]interface{} {
 	data := map[string]interface{}{}
-	//company_id 企业id name户名称 address 地址
+	//company_id 企业id name户名称 address 地址 industry 行业
 	if employType == 2 {
 		//企业详情
 		entinfo, _ := MC.MgoEnt.FindOneByField("qyxy_std", map[string]interface{}{"_id": id}, map[string]interface{}{
@@ -435,70 +435,57 @@ func (e *EmPloyService) DistributePerson(in *types.EmployDistributeReq) bool {
 		for _, person := range in.Person {
 			personMap[person.PositionId] = PersonSmmary{
 				EntUserId: person.EntUserId,
-				//Summary:   SummaryFormat(person.PositionId),
 			}
 		}
 		//分发数据处理
 		infoMap := map[string]map[string]interface{}{}
-		for positionId, personSmmary := range personMap {
-			for _, v := range strings.Split(in.EmployIdArr, ",") {
-				VMap := map[string]interface{}{}
-				if infoMap[v] == nil {
-					//新增记录
-					infoData := MC.CrmMysql.FindOne(entity.EMPLOY_INFO, map[string]interface{}{
-						"id": v,
-					}, "", "")
-					if infoData != nil && len(*infoData) > 0 {
-						(*infoData)["dis_id"] = v
-						(*infoData)["is_handle"] = 0
-						(*infoData)["is_ignore"] = 0
-						(*infoData)["is_dis"] = 0
-						(*infoData)["is_create_clue"] = 0
-						(*infoData)["is_create_chance"] = 0
-						(*infoData)["is_create_custom"] = 0
-						(*infoData)["create_time"] = time.Now().Format(date.Date_Full_Layout)
-						delete(*infoData, "id")
+		onlyMap := map[string]interface{}{}
+		for _, v := range strings.Split(in.EmployIdArr, ",") {
+			if onlyMap[v] == nil {
+				//查询信息
+				infoDataList := MC.CrmMysql.SelectBySqlByTx(tx, "SELECT * FROM employ_info WHERE  id=?", v)
+				if infoDataList != nil && len(*infoDataList) > 0 {
+					source_id := common.InterfaceToStr((*infoDataList)[0]["source_id"])
+					if onlyMap[source_id] == nil {
+						(*infoDataList)[0]["dis_id"] = v
+						(*infoDataList)[0]["is_handle"] = 0
+						(*infoDataList)[0]["is_ignore"] = 0
+						(*infoDataList)[0]["is_dis"] = 0
+						(*infoDataList)[0]["is_create_clue"] = 0
+						(*infoDataList)[0]["is_create_chance"] = 0
+						(*infoDataList)[0]["is_create_custom"] = 0
+						(*infoDataList)[0]["create_time"] = time.Now().Format(date.Date_Full_Layout)
+						delete((*infoDataList)[0], "id")
+						if common.IntAll((*infoDataList)[0]["is_dis"]) != 1 {
+							MC.CrmMysql.UpdateByTx(tx, entity.EMPLOY_INFO, map[string]interface{}{
+								"id": v,
+							}, map[string]interface{}{
+								"is_dis": 1,
+							})
+						}
+						infoMap[source_id] = (*infoDataList)[0]
+						onlyMap[source_id] = v
 					} else {
 						log.Println(v, "查询不到改收录信息")
-						break
-					}
-					//更改已分发状态
-					if common.IntAll((*infoData)["is_dis"]) != 1 {
-						MC.CrmMysql.UpdateByTx(tx, entity.EMPLOY_INFO, map[string]interface{}{
-							"id": v,
-						}, map[string]interface{}{
-							"is_dis": 1,
-						})
+						continue
 					}
-					infoMap[v] = *infoData
-					VMap = *infoData
-				} else {
-					VMap = infoMap[v]
 				}
+			}
+		}
+		for positionId, personSmmary := range personMap {
+			for _, v := range infoMap {
 				//查询时候收录过
 				findMap := map[string]interface{}{
 					"position_id": positionId,
-					"source_id":   VMap["source_id"],
+					"source_id":   v["source_id"],
 				}
 				if MC.CrmMysql.Count(entity.EMPLOY_INFO, findMap) == 0 {
 					//新增
-					//
-					VMap["ent_user_id"] = personSmmary.EntUserId
-					VMap["position_id"] = positionId
-					ok := MC.CrmMysql.InsertByTx(tx, entity.EMPLOY_INFO, VMap)
-					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
-					}*/
+					v["ent_user_id"] = personSmmary.EntUserId
+					v["position_id"] = positionId
+					MC.CrmMysql.InsertByTx(tx, entity.EMPLOY_INFO, v)
 				}
-				return true
-				/*if fool {
-					if !SummarySave(tx, positionId, personSmmary.Summary) {
-						return false
-					}
-				}*/
+
 			}
 		}
 		return true