소스 검색

fix:线索机会创建失败修复

zhangxinlei1996 1 년 전
부모
커밋
8f1a6a639f
1개의 변경된 파일18개의 추가작업 그리고 0개의 파일을 삭제
  1. 18 0
      service/util.go

+ 18 - 0
service/util.go

@@ -10,6 +10,9 @@ import (
 
 //CanAdd 是否允许多人针对一个创建
 func CanAdd(entId int64, key string, employInfoId, employCustomId, positionId int64) (status int64, error_msg string) {
+	if employInfoId <= 0 && employCustomId <= 0 {
+		return 1, ""
+	}
 	accountData := cm.BaseMysql.SelectBySql(`select * from base_service.base_account where ent_id =? and person_id =0 and type =1 limit 1`, entId)
 	if accountData == nil || len(*accountData) <= 0 {
 		return 1, ""
@@ -36,6 +39,9 @@ func CanAdd(entId int64, key string, employInfoId, employCustomId, positionId in
 		args = append(args, entId)
 		//判断是否已经创建
 		if strings.Contains(key, "clue") {
+			if hasZero(employInfoIdArr) {
+				return 1, ""
+			}
 			d := cm.BaseMysql.SelectBySql(`select create_person,position_id from crm.sale_clue where employ_info_id in( `+ws+`) and ent_id =? and is_close=0`, args...)
 			if d != nil && len(*d) > 0 {
 				for _, v := range *d {
@@ -48,6 +54,9 @@ func CanAdd(entId int64, key string, employInfoId, employCustomId, positionId in
 			}
 
 		} else if strings.Contains(key, "chance") {
+			if hasZero(employInfoIdArr) {
+				return 1, ""
+			}
 			d := cm.BaseMysql.SelectBySql(`select create_person,position_id from crm.sale_chance where   employ_info_id in ( `+ws+`) and ent_id =? `, args...)
 			if d != nil && len(*d) > 0 {
 				for _, v := range *d {
@@ -111,3 +120,12 @@ func GetInForCommaArr(ids []int64) ([]interface{}, string) {
 	}
 	return args, strings.Join(ws, ",")
 }
+
+func hasZero(arr []int64) bool {
+	for i := 0; i < len(arr); i++ {
+		if arr[i] == int64(0) {
+			return true
+		}
+	}
+	return false
+}