Jelajahi Sumber

wip:文案修改

WH01243 3 tahun lalu
induk
melakukan
dee829cbcf

+ 21 - 22
entniche/src/entity/followProject.go

@@ -17,7 +17,6 @@ import (
 	"time"
 )
 
-
 type ProjectFollow struct {
 	UserId    string //用户id
 	MaxNum    int    //最大关注数量
@@ -108,7 +107,7 @@ func (this *ProjectFollow) GetDetailByFid(fid string) (returnData map[string]int
 	returnData["visit"] = (*data)["a_visited"]           //是否开启提醒
 	returnData["bidopentime"] = (*data)["l_bidopentime"] //开标时间
 	returnData["remindtime"] = (*data)["l_remindtime"]   //提醒时间
-	if qutil.ObjToString((*data)["s_id"]) == "" { //兼容旧版本手动添加的关注
+	if qutil.ObjToString((*data)["s_id"]) == "" {        //兼容旧版本手动添加的关注
 		projectInfo = map[string]interface{}{
 			"projectname": (*data)["s_projectname"],
 			"bidopentime": (*data)["l_bidopentime"],
@@ -188,7 +187,7 @@ func (this *ProjectFollow) SetFollowRead(sid, fid, flag string) bool {
 }
 
 //获取列表页
-func (this *ProjectFollow) GetFollowList(pNum, pSize,entUserId int) (followData []map[string]interface{}, hasNext bool, count int, err error) {
+func (this *ProjectFollow) GetFollowList(pNum, pSize, entUserId int) (followData []map[string]interface{}, hasNext bool, count int, err error) {
 	query := map[string]interface{}{
 		"s_userid": this.UserId,
 	}
@@ -207,7 +206,7 @@ func (this *ProjectFollow) GetFollowList(pNum, pSize,entUserId int) (followData
 		return
 	}
 	sidArr := []string{}
-	sidStr:=""
+	sidStr := ""
 	followSetting := map[string]map[string]interface{}{}
 	for _, followOne := range *followList {
 		sid := qutil.ObjToString(followOne["s_id"])
@@ -217,20 +216,20 @@ func (this *ProjectFollow) GetFollowList(pNum, pSize,entUserId int) (followData
 			followOne["l_lastpushtime"] = followOne["l_createtime"]
 		}
 		sidArr = append(sidArr, sid)
-		sidStr=sidStr+","+sid
+		sidStr = sidStr + "," + sid
 		followSetting[sid] = followOne
 	}
 	//查询所有项目对应采购单钩是否认领
 	value, str := GetInForComma(sidStr)
 	searchValues := []interface{}{}
-	searchValues=append(searchValues,value...)
-	searchValues=append(searchValues,entUserId)
-	infoMap:= map[interface{}]interface{}{}
-	searchSql:= fmt.Sprintf(` a.infoid in (%s) `, str)
-	selectsql:="	SELECT DISTINCT a.infoid FROM entniche_project a, entniche_customer b, entniche_user_customer c where "+searchSql+"  and  a.customer_id=b.id and  c.customer_id=b.id and  c.source_type=1 and  c.user_id=? and  a.infoid is  not  null"
+	searchValues = append(searchValues, value...)
+	searchValues = append(searchValues, entUserId)
+	infoMap := map[interface{}]interface{}{}
+	searchSql := fmt.Sprintf(` a.infoid in (%s) `, str)
+	selectsql := "	SELECT DISTINCT a.infoid FROM entniche_project a, entniche_customer b, entniche_user_customer c where " + searchSql + "  and  b.state=1 and  a.customer_id=b.id and  c.customer_id=b.id and  c.source_type=1 and  c.user_id=? and  a.infoid is  not  null"
 	if data := Mysql.SelectBySql(selectsql, searchValues...); len((*data)) > 0 {
 		for _, v := range *data {
-			infoMap[v["infoid"]]=1
+			infoMap[v["infoid"]] = 1
 		}
 	}
 	projectInfos := []map[string]interface{}{}
@@ -267,7 +266,7 @@ func (this *ProjectFollow) GetFollowList(pNum, pSize,entUserId int) (followData
 				info["title"] = projectinfo["projectname"]
 				info["status"] = projectinfo["bidstatus"]
 				info["projectcode"] = projectinfo["projectcode"]
-				info["buyer"]=projectinfo["buyer"]
+				info["buyer"] = projectinfo["buyer"]
 				break
 			}
 		}
@@ -291,11 +290,11 @@ func (this *ProjectFollow) GetFollowList(pNum, pSize,entUserId int) (followData
 		}else{
 			thisRow["isClaim"]=2
 		}*/
-		bdinfos := Mysql.SelectBySql(fmt.Sprintf("SELECT  ecn.id  FROM %s ecn,%s  euu WHERE ecn.id = euu.customer_id AND euu.user_id =? AND ecn.`name` = ? AND (euu.source_type =1 or  euu.source_type =4)", Entniche_customer, Entniche_user_customer), entUserId,thisRow["buyer"] )
+		bdinfos := Mysql.SelectBySql(fmt.Sprintf("SELECT  ecn.id  FROM %s ecn,%s  euu WHERE  ecn.state=1 and  ecn.id = euu.customer_id AND euu.user_id =? AND ecn.`name` = ? AND (euu.source_type =1 or  euu.source_type =4)", Entniche_customer, Entniche_user_customer), entUserId, thisRow["buyer"])
 		if len((*bdinfos)) > 0 {
-			thisRow["isClaim"]=1
-		}else{
-			thisRow["isClaim"]=2
+			thisRow["isClaim"] = 1
+		} else {
+			thisRow["isClaim"] = 2
 		}
 		followData = append(followData, thisRow)
 	}
@@ -417,7 +416,7 @@ func delRelRedis(userid interface{}, relationinfo interface{}) {
 
 //获取已关注项目的地区
 //项目提醒开关
-func (this *ProjectFollow) Area(list []map[string]interface{})  map[string][]string {
+func (this *ProjectFollow) Area(list []map[string]interface{}) map[string][]string {
 	areaM := map[string]int{}
 	area := map[string][]string{}
 	for _, v := range list {
@@ -425,11 +424,11 @@ func (this *ProjectFollow) Area(list []map[string]interface{})  map[string][]str
 	}
 	for k, _ := range areaM {
 		str, _ := pinyin.New(k).Split("").Mode(pinyin.InitialsInCapitals).Convert()
-		firstStr:=str[:1]
-		if  area[firstStr]==nil{
-			area[firstStr]=append(area[firstStr],k)
-		}else{
-			area[firstStr]=[]string{k}
+		firstStr := str[:1]
+		if area[firstStr] == nil {
+			area[firstStr] = append(area[firstStr], k)
+		} else {
+			area[firstStr] = []string{k}
 		}
 	}
 	return area

+ 15 - 15
entniche/src/service/customer/customer.go

@@ -843,21 +843,21 @@ func PCQuery(area map[string]interface{}, industry []string, buyerclass []string
 		musts = append(musts, entNameQuery)
 	}
 	/*sql := ""*/
-/*	if len(areaCity) > 0 {
-		if len(entName) > 0 {
-			sql = fmt.Sprintf(query_bool_should, strings.Join(areaCity, ","), 1)
-			musts = append(musts, sql)
-		} else {
-			sql = fmt.Sprintf(query_bool_should, strings.Join(areaCity, ","), 1)
-			musts = append(musts, sql)
-		}
+	/*	if len(areaCity) > 0 {
+			if len(entName) > 0 {
+				sql = fmt.Sprintf(query_bool_should, strings.Join(areaCity, ","), 1)
+				musts = append(musts, sql)
+			} else {
+				sql = fmt.Sprintf(query_bool_should, strings.Join(areaCity, ","), 1)
+				musts = append(musts, sql)
+			}
 
-	} else {
-		if len(entName) > 0 {
-			sql = fmt.Sprintf(query_bool_should, entNameQuery, 1)
-			musts = append(musts, sql)
-		}
-	}*/
+		} else {
+			if len(entName) > 0 {
+				sql = fmt.Sprintf(query_bool_should, entNameQuery, 1)
+				musts = append(musts, sql)
+			}
+		}*/
 	/*if len(areaCity) > 0 {
 		musts = append(musts, fmt.Sprintf(query_bool_should, strings.Join(areaCity, ",")))
 	}*/
@@ -1398,7 +1398,7 @@ func (this *CustomerAction) AddLabel() {
 			return Result{Data: nil, Error_msg: Error_msg_1005}
 		}
 		if this.GetString("name") == "" {
-			return Result{Data: nil, Error_msg: Error_msg_1003}
+			return Result{Data: nil, Error_msg: "请输入标签"}
 		}
 		rdata := AddLab(this.GetString("name"), userId)
 		return Result{Data: rdata["labid"], Error_msg: qutil.ObjToString(rdata["msg"])}

+ 2 - 2
entniche/src/service/customer/distribute.go

@@ -29,7 +29,7 @@ func (this *CustomerAction) DistributePersons() {
 		if curUser.Role_admin_department { //获取当前部门id
 			users = *VarDepartment.GetDisUsersDeptDetail(curUser.Ent.Id, curUser.Dept.Id)
 		} else if curUser.Role_admin_system { //查询客户所属的部门id
-			res := Mysql.FindOne(Entniche_customer, M{"id": customer_id, "ent_id": ent_id}, "dept_id", "")
+			res := Mysql.FindOne(Entniche_customer, M{"id": customer_id, "ent_id": ent_id, "state": 1}, "dept_id", "")
 			if res == nil || len(*res) == 0 {
 				return "未找到客户", nil
 			}
@@ -104,7 +104,7 @@ func (this *CustomerAction) DistributeSubmit() {
 			if curUser.Role_admin_department { //获取当前部门id
 				users = *VarDepartment.GetDisUsers(curUser.Ent.Id, curUser.Dept.Id)
 			} else if curUser.Role_admin_system { //查询客户所属的部门id
-				res := Mysql.FindOne(Entniche_customer, M{"id": customer_id, "ent_id": ent_id}, "dept_id", "")
+				res := Mysql.FindOne(Entniche_customer, M{"id": customer_id, "ent_id": ent_id, "state": 1}, "dept_id", "")
 				if res == nil || len(*res) == 0 {
 					return "未找到客户", nil
 				}

+ 38 - 62
entniche/src/service/customer/entiy.go

@@ -103,7 +103,7 @@ func (this *CustomerOperation) CList(searchCode string, isCliam int64, entUserId
 			"$regex": searchCode,
 		}
 	}
-	customerList := Mysql.SelectBySql("SELECT ec.name,euu.customer_id FROM entniche_user_customer euu LEFT JOIN entniche_customer ec ON ec.id = euu.customer_id  WHERE user_id = ? AND (source_type =1 or source_type =4) ", entUserId)
+	customerList := Mysql.SelectBySql("SELECT ec.name,euu.customer_id FROM entniche_user_customer euu LEFT JOIN entniche_customer ec ON ec.id = euu.customer_id  WHERE user_id = ?  AND  ec.state=1 and  (source_type =1 or source_type =4) ", entUserId)
 	customerMap := map[string]interface{}{}
 	for _, value := range *customerList {
 		customerMap[qu.ObjToString(value["name"])] = value["customer_id"]
@@ -192,12 +192,11 @@ func (this *CustomerOperation) CheckPower(mold int, entUserId int, name string,
 			msg = fmt.Sprintf("您的关注客户数量已经超过%d,请取消关注部分后再操作。", config.Config.FollowCustomer.CustomerNumb)
 		}
 	} else {
-
 		//查询
 		//判断该企业是否存在
 		res := Mysql.FindOne(Entniche_customer, M{"dept_id": dept_id, "ent_id": ent_id, "name": name}, "id,dept_id", "")
 		//查询企业客户数
-		data := Mysql.SelectBySql("SELECT count( a.count ) as  count FROM (SELECT COUNT( id ) as count FROM entniche_customer WHERE ent_id = ? GROUP BY name ) a", ent_id)
+		data := Mysql.SelectBySql("SELECT count( a.count ) as  count FROM (SELECT COUNT( id ) as count FROM entniche_customer WHERE  b.state=1 and  ent_id = ?  GROUP BY name ) a", ent_id)
 		if len((*data)) > 0 {
 			enterpriseNumb := qutil.Int64All((*data)[0]["count"])
 			//判断企业客户数
@@ -210,7 +209,7 @@ func (this *CustomerOperation) CheckPower(mold int, entUserId int, name string,
 			}
 		}
 		//判断自己是否有此客户
-		userData := Mysql.SelectBySql("select  count(ec.id) as count from  entniche_customer ec  INNER  join entniche_user_customer euc on ec.id=euc.customer_id where   ec.`name`=? and  euc.user_id=?", name, entUserId)
+		userData := Mysql.SelectBySql("select  count(ec.id) as count from  entniche_customer ec  INNER  join entniche_user_customer euc on ec.id=euc.customer_id where   ec.state=1 and  ec.`name`=? and  euc.user_id=?", name, entUserId)
 		if len((*userData)) > 0 {
 			prsonalNumb := qutil.Int64All((*userData)[0]["count"])
 			//判断企业客户数
@@ -292,7 +291,7 @@ func (this *CustomerOperation) Claimoperation(data *CurrentUser, ent_id, entUser
 	//认领处理
 	//true 取消认领;默认 false 认领
 	if this.D {
-		dataList := Mysql.SelectBySql("select  ec.*  from  entniche_customer  ec,entniche_user_customer euc where  ec.name =? and   ec.ent_id=?  and  ec.id =euc.customer_id 	and  euc.user_id=?", name, ent_id, entUserId)
+		dataList := Mysql.SelectBySql("select  ec.*  from  entniche_customer  ec,entniche_user_customer euc where  ec.name =? and   ec.ent_id=?  and  ec.id =euc.customer_id 	and  euc.user_id=? and  ec.state=1", name, ent_id, entUserId)
 		//true 取消认领
 		if len(*dataList) > 0 {
 			for _, value := range *dataList {
@@ -302,33 +301,18 @@ func (this *CustomerOperation) Claimoperation(data *CurrentUser, ent_id, entUser
 				//判断客户和别的数据数据是否还有关系
 				dataList = Mysql.SelectBySql("select  euc.*  from  entniche_user_customer euc where euc.customer_id=? 	", customer_id)
 				if len((*dataList)) == 0 {
-					userCustomerQueryMap := map[string]interface{}{
-						"id": customer_id,
+					updateOk := Mysql.Update(Entniche_customer, M{"id": customer_id}, map[string]interface{}{
+						"state": 0,
+					})
+					if !updateOk {
+						log.Printf("客户%s 更新出错\n", customer_id)
+						return false
 					}
-					B = Mysql.Delete(Entniche_customer, userCustomerQueryMap)
 				}
-				/*	//生命周期添加
-					cycleMap := map[string]interface{}{
-						"cancel_claim_time":   time_now,
-						"type":                4,
-						"cancel_claim_person": name,
-						"customer_id":         customer_id,
-						"reason":              this.Reason,
-					}
-					insertOk := entniceLifeCycleAdd(cycleMap, nil)
-					if !insertOk {
-						log.Printf("客户%s 更新生命周期出错\n", name)
-						return false
-					}*/
-				/*	deleteMap := map[string]interface{}{
-					"userid":      this.UserId,
-					"customer_id": customer_id,
-				}*/
-				//Mysql.Delete(Bdcollection_entniche, deleteMap)
 			}
 		}
 	} else {
-		dataList := Mysql.SelectBySql("select  ec.*  from  entniche_customer  ec,entniche_user_customer euc where  ec.name =? and   ec.ent_id=? and  ec.dept_id=? and  ec.id =euc.customer_id 	and  euc.user_id=?", name, ent_id, dept_id, entUserId)
+		dataList := Mysql.SelectBySql("select  ec.*  from  entniche_customer  ec,entniche_user_customer euc where  ec.name =? and   ec.ent_id=? and  ec.dept_id=? and  ec.id =euc.customer_id 	and  euc.user_id=? and  ec.state=1", name, ent_id, dept_id, entUserId)
 		// 认领
 		//查询是否存在用户
 		//添加完用户之后自动分配
@@ -385,48 +369,40 @@ func (this *CustomerOperation) Claimoperation(data *CurrentUser, ent_id, entUser
 					}
 				}
 			}
+			//查看客户是否存在
 			ok := Mysql.ExecTx("添加客户", func(tx *sql.Tx) bool {
 				time_now := time.Now().Format(qu.Date_Full_Layout)
-				customer_id := Mysql.InsertByTx(tx, Entniche_customer, map[string]interface{}{
-					"name":       name,
-					"ent_id":     ent_id,
-					"dept_id":    data.Dept.Id,
-					"editperson": data.User_name,
-					"createtime": time_now,
-					"timestamp":  time_now,
-					"area":       province,
-					"city":       city,
-				})
-				if customer_id <= 0 {
-					return false
+				customer_id := int64(0)
+				res := Mysql.FindOne(Entniche_customer, M{"dept_id": dept_id, "ent_id": ent_id, "name": name}, "id,dept_id,state", "")
+				if qutil.IntAll((*res)["state"]) == 0 {
+					customer_id = qutil.Int64All((*res)["id"])
+					updateOk := Mysql.UpdateByTx(tx, Entniche_customer, M{"id": customer_id}, map[string]interface{}{
+						"state": 1,
+					})
+					if !updateOk {
+						log.Printf("客户%s 更新出错\n", name)
+						return false
+					}
+				} else {
+					customer_id = Mysql.InsertByTx(tx, Entniche_customer, map[string]interface{}{
+						"name":       name,
+						"ent_id":     ent_id,
+						"dept_id":    data.Dept.Id,
+						"editperson": data.User_name,
+						"createtime": time_now,
+						"timestamp":  time_now,
+						"area":       province,
+						"city":       city,
+					})
+					if customer_id <= 0 {
+						return false
+					}
 				}
-				//生命周期添加
-				/*cycleMap := map[string]interface{}{
-					"add_time":    time_now,
-					"type":        0,
-					"add_person":  data.User_name,
-					"customer_id": customer_id,
-				}*/
-				//insertOk := entniceLifeCycleAdd(cycleMap, tx)
-				/*if !insertOk {
-					log.Printf("客户%s 更新生命周期出错\n", name)
-					return false
-				}*/
 				//添加完成默认分配给自己
 				if Mysql.InsertByTx(tx, Entniche_user_customer, map[string]interface{}{"customer_id": customer_id, "user_id": entUserId, "type": 1, "source": 1, "source_type": 1, "timestamp": time_now}) < 0 {
 					log.Printf("%s客户关联异常", name)
 					return false
 				}
-				/*cycleMap1 := map[string]interface{}{
-					"claim_time":   time_now,
-					"type":         1,
-					"claim_person": data.User_name,
-					"customer_id":  customer_id,
-				}
-				if !entniceLifeCycleAdd(cycleMap1, tx) {
-					log.Printf("%s客户关联异常", name)
-					return false
-				}*/
 				cycleMap := map[string]interface{}{
 					"claim_time":   time_now,
 					"type":         1,
@@ -489,7 +465,7 @@ func (this *CustomerOperation) IsCollclaim() map[string]interface{} {
 	res := map[string]interface{}{}
 	res["iscoll"] = false
 	for _, v := range strings.Split(this.Names, ",") {
-		bdinfos := Mysql.SelectBySql(fmt.Sprintf("SELECT  ecn.id  FROM %s ecn,%s  euu WHERE ecn.id = euu.customer_id AND euu.user_id =? AND ecn.`name` = ? AND (euu.source_type =1 or euu.source_type=4)", Entniche_customer, Entniche_user_customer), this.EntUserId, v)
+		bdinfos := Mysql.SelectBySql(fmt.Sprintf("SELECT  ecn.id  FROM %s ecn,%s  euu WHERE ecn.id = euu.customer_id AND euu.user_id =? AND ecn.`name` = ? AND  ecn.state=1 and  (euu.source_type =1 or euu.source_type=4)", Entniche_customer, Entniche_user_customer), this.EntUserId, v)
 		if len((*bdinfos)) > 0 {
 			nameArr = append(nameArr, v)
 			res["iscoll"] = true

+ 3 - 3
entniche/src/service/track/track.go

@@ -231,11 +231,11 @@ func (this *Action) ListInfo() {
 LEFT JOIN entniche_project b ON (a.project_id=b.id)
 INNER JOIN entniche_customer c ON (b.customer_id=c.id or c.id=a.customer_id)
 INNER JOIN entniche_department d ON (d.id = c.dept_id)
-WHERE a.customer_id = ` + customer_id
+WHERE  c.state=1 and a.customer_id = ` + customer_id
 				return_sql := `SELECT a.createtime,a.reason,c.name,a.user_name FROM entniche_customer_return a
 INNER JOIN entniche_customer b ON (a.customer_id=b.id)
 INNER JOIN entniche_department c ON (c.id = b.dept_id)
- WHERE a.customer_id = ` + customer_id
+ WHERE b.state=1 and  a.customer_id = ` + customer_id
 				if user_type == "staff" {
 					track_sql += ` AND a.user_id = ` + entUserId
 					return_sql += ` AND a.user_id = ` + entUserId
@@ -554,7 +554,7 @@ func getTrackNum(status int, i_entId int64, starttime, endtime string) int64 {
 	tracknum := util.Mysql.SelectBySql(`SELECT a.project_id,COUNT(a.project_id) AS pct,c.id AS customer_id 
 											FROM  entniche_project_track a 
 											INNER JOIN entniche_project b ON (b.id=a.project_id) 
-											INNER JOIN entniche_customer c ON (c.id=b.customer_id) 
+											INNER JOIN entniche_customer c ON (c.id=b.customer_id and  c.state=1) 
 											WHERE a.status = ? AND c.ent_id=? AND a.createtime >= ? AND a.createtime <= ?  
 											GROUP BY a.project_id`, status, i_entId, starttime, endtime)
 	var num int64 = 0

+ 5 - 5
entniche/src/timetask/timetask.go

@@ -40,11 +40,11 @@ func syncEntModel() {
 				//由统一订阅变成个人订阅
 				if model == 1 && newModel == 2 {
 					log.Println(entId, "同步订阅模式", "新的订阅模式", newModel, "旧的订阅模式", model)
-					del_ent_customer := Mysql.SelectBySql(`select * from entniche_customer where ent_id=?`, entId)
-					del_ent_customer_contact := Mysql.SelectBySql(`select a.* from entniche_customer_contact a inner join entniche_customer b on (b.ent_id=? and a.customer_id=b.id)`, entId)
-					del_ent_project := Mysql.SelectBySql(`select a.* from entniche_project a inner join entniche_customer b on (b.ent_id=? and a.customer_id=b.id)`, entId)
-					del_ent_project_track := Mysql.SelectBySql(`select a.* from entniche_project_track a inner join entniche_project b on (a.project_id=b.id) inner join entniche_customer c on (c.ent_id=? and b.customer_id=c.id)`, entId)
-					if Mysql.UpdateOrDeleteBySql(`delete from entniche_customer where ent_id=?`, entId) > 0 {
+					del_ent_customer := Mysql.SelectBySql(`select * from entniche_customer where ent_id=? and  state=1`, entId)
+					del_ent_customer_contact := Mysql.SelectBySql(`select a.* from entniche_customer_contact a inner join entniche_customer b on (b.ent_id=? and a.customer_id=b.id and  b.state=1)`, entId)
+					del_ent_project := Mysql.SelectBySql(`select a.* from entniche_project a inner join entniche_customer b on (b.ent_id=? and  b.state=1 and a.customer_id=b.id)`, entId)
+					del_ent_project_track := Mysql.SelectBySql(`select a.* from entniche_project_track a inner join entniche_project b on (a.project_id=b.id) inner join entniche_customer c on (c.ent_id=?  and  c.state=1 and b.customer_id=c.id)`, entId)
+					if Mysql.UpdateOrDeleteBySql(`delete from entniche_customer where ent_id=? and   state=1`, entId) > 0 {
 						VarBackup.Save(Entniche_customer, del_ent_customer)
 						VarBackup.Save(Entniche_customer_contact, del_ent_customer_contact)
 						VarBackup.Save(Entniche_project, del_ent_project)

+ 4 - 4
public/src/ent/entity/customer.go

@@ -134,7 +134,7 @@ pageSize 每页数据量
 */
 func (this *Customer) GetEntCustomerList(ent_id int, name, alloc, staff_names string, area map[string]interface{}, startTme, endTime int64, pageIndex, pageSize, sourceType int, industry string) (count int64, customerList *[]map[string]interface{}) {
 	customerList = &[]map[string]interface{}{}
-	searchSql := ` a.ent_id =?  `
+	searchSql := ` a.ent_id =?  and a.state=1 `
 	searchValues := []interface{}{}
 	searchValues = append(searchValues, ent_id)
 	if name != "" { //名字模糊查询
@@ -237,7 +237,7 @@ func (this *Customer) GetEntCustomerList(ent_id int, name, alloc, staff_names st
 				WHERE `+searchSql+` order by updatetime desc limit ?,?) as a
 				LEFT JOIN entniche_user_customer b on (a.id=b.customer_id)
 				LEFT JOIN entniche_user c on (b.user_id=c.id) 
-				GROUP BY a.id `+allocSql +` order by updatetime desc,	a.createtime  desc`, searchValues...)
+				GROUP BY a.id `+allocSql+` order by updatetime desc,	a.createtime  desc`, searchValues...)
 	}
 	return
 }
@@ -254,7 +254,7 @@ pageSize 每页数据量
 */
 func (this *Customer) GetDeptCustomerList(dept_id, ent_id int, name, alloc, staff_names string, area map[string]interface{}, startTme, endTime int64, pageIndex, pageSize, sourceType int, industry string) (count int64, customerList *[]map[string]interface{}) {
 	customerList = &[]map[string]interface{}{}
-	searchSql := ` a.ent_id=? and (a.dept_id=? or b.pid=? ) `
+	searchSql := ` a.ent_id=? and (a.dept_id=? or b.pid=? )  and a.state=1 `
 	searchValues := []interface{}{}
 	searchValues = append(searchValues, ent_id, dept_id, dept_id)
 	if name != "" { //名字模糊查询
@@ -372,7 +372,7 @@ pageSize 每页数据量
 func (this *Customer) GetStaffCustomerList(user_id, ent_id int, name string, area map[string]interface{}, startTme, endTime int64, pageIndex, pageSize, sourceType int, followStatus int, industry, label, userId string) (count int64, customerList *[]map[string]interface{}) {
 	customerList = &[]map[string]interface{}{}
 	searchValues := []interface{}{}
-	searchSql := ` and  a.ent_id=? and b.user_id=? `
+	searchSql := ` and  a.ent_id=? and b.user_id=?  and a.state=1 `
 	searchValues = append(searchValues, ent_id, user_id)
 	if len(area) > 0 {
 		areaStr := ""

+ 3 - 3
public/src/ent/entity/department.go

@@ -172,10 +172,10 @@ func (d *Department) Del(entId int, deptId string) bool {
 	del_dept_users := Mysql.SelectBySql(`select b.* from entniche_user a 
 		INNER JOIN entniche_department_user b on (a.ent_id=? and b.dept_id in (`+ids_ws+`) and a.id=b.user_id)`, args_3...)
 	del_dept := Mysql.SelectBySql(`select * from entniche_department where ent_id=? and id in(`+ids_ws+`)`, args_3...)
-	del_ent_customer := Mysql.SelectBySql(`select * from entniche_customer where ent_id=? and dept_id in (`+ids_ws+`)`, args_3...)
+	del_ent_customer := Mysql.SelectBySql(`select * from entniche_customer where ent_id=? and state=1 and dept_id in (`+ids_ws+`)`, args_3...)
 	del_ent_customer_contact := Mysql.SelectBySql(`select a.* from entniche_customer_contact a inner join entniche_customer b on (b.ent_id=? and b.dept_id in (`+ids_ws+`) and a.customer_id=b.id)`, args_3...)
-	del_ent_project := Mysql.SelectBySql(`select a.* from entniche_project a inner join entniche_customer b on (b.ent_id=? and b.dept_id in (`+ids_ws+`) and a.customer_id=b.id)`, args_3...)
-	del_ent_project_track := Mysql.SelectBySql(`select a.* from entniche_project_track a inner join entniche_project b on (a.project_id=b.id) inner join entniche_customer c on (c.ent_id=? and c.dept_id in (`+ids_ws+`) and b.customer_id=c.id)`, args_3...)
+	del_ent_project := Mysql.SelectBySql(`select a.* from entniche_project a inner join entniche_customer b on (b.ent_id=? and b.state=1 and   b.dept_id in (`+ids_ws+`) and a.customer_id=b.id)`, args_3...)
+	del_ent_project_track := Mysql.SelectBySql(`select a.* from entniche_project_track a inner join entniche_project b on (a.project_id=b.id) inner join entniche_customer c on (c.ent_id=? and  c.state=1  and c.dept_id in (`+ids_ws+`) and b.customer_id=c.id)`, args_3...)
 	if Mysql.ExecTx("删除部门", func(tx *sql.Tx) bool {
 		//args_1
 		ok_1 := Mysql.UpdateOrDeleteBySqlByTx(tx, `DELETE a from entniche_user a 

+ 1 - 1
trackreport/src/job/statisticjob.go

@@ -57,7 +57,7 @@ func (s *StatisticJob) Execute(now time.Time) {
 					}()
 					//客户总量查询
 					customerTotal := Mysql.SelectBySql(`SELECT  COUNT(DISTINCT a.id ) as ccount FROM entniche_customer a 
-WHERE a.ent_id = ? AND a.createtime <= ?`, v["ent_id"].(int64), util.FormatDateByInt64(&s.today_end_ymdhms, util.Date_Full_Layout))
+WHERE a.ent_id = ?  AND a.createtime <= ?`, v["ent_id"].(int64), util.FormatDateByInt64(&s.today_end_ymdhms, util.Date_Full_Layout))
 					//项目总量查询
 					projectTotal := Mysql.SelectBySql(`SELECT COUNT(b.id) AS pcount FROM entniche_project a INNER JOIN entniche_customer b  ON (a.customer_id = b.id) WHERE b.ent_id = ? AND a.createtime <= ?`, v["ent_id"].(int64), util.FormatDateByInt64(&s.today_end_ymdhms, util.Date_Full_Layout))
 					var customercount int64 = 0