浏览代码

Merge branch 'dev_v1.5.11_wh' of jianyu/datatools into feature/v1.5.11

王浩 1 年之前
父节点
当前提交
aae164f339
共有 4 个文件被更改,包括 19 次插入17 次删除
  1. 1 1
      clueSync/autoTask.go
  2. 1 2
      clueSync/jobutil.go
  3. 7 4
      clueSync/kc.go
  4. 10 10
      clueSync/sendMail.go

+ 1 - 1
clueSync/autoTask.go

@@ -164,7 +164,7 @@ FROM
 	dwd_f_crm_clue_info b 
 right JOIN
  ( 	select  position_id from  dwd_f_crm_personnel_management where  assign_type = 1 
-	AND resign = 0 ) a on  a.position_id=b.position_id    and  b.trailstatus!="08"
+	AND resign = 0 ) a on  a.position_id=b.position_id    and  b.is_transfer != 1
 GROUP BY
 	a.position_id HAVING count<?`, upperLimit)
 	if countData == nil || len(*countData) > 0 {

+ 1 - 2
clueSync/jobutil.go

@@ -1225,8 +1225,7 @@ func FindUpperLimit(positionId string, level string, isAdd bool) bool {
 	if positionId == "" {
 		return false
 	}
-	isFull := false
-	isFull = TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where position_id=? and is_assign=1   and trailstatus != '08'  `, positionId) >= db.AllocationCap
+	isFull := TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where position_id=? and is_assign=1   and is_transfer != 1  `, positionId) >= db.AllocationCap
 	if isFull && isAdd && level != "" {
 		TiDb.UpdateOrDeleteBySql(`update dwd_f_crm_clue_autodraw_record set count = count + 1 where position_id = ? and clue_level = ?`, positionId, level)
 	}

+ 7 - 4
clueSync/kc.go

@@ -543,7 +543,7 @@ func ordersClue() {
 							seatNumber = common.ObjToString((*saleData)["seat_number"])
 							positionId = common.Int64All((*saleData)["position_id"])
 						}
-						if IsFreeze(source, pay_money, gconv.String(positionId)) {
+						if IsFreeze(source, pay_money, gconv.String(positionId), trailstatus) {
 							//线索需要冻结
 							is_assign = -3
 						}
@@ -612,7 +612,7 @@ func ordersClue() {
 								"operator_id": -1,
 							})
 							//移交失败发送消息
-							if IsFreeze(source, pay_money, gconv.String(positionId)) {
+							if IsFreeze(source, pay_money, gconv.String(positionId), trailstatus) {
 								//发送邮件信息
 								OrderCreateFail(positionId, mailContent)
 							}
@@ -880,12 +880,15 @@ func refundAutoHistory() {
 		}
 	}
 }
-func IsFreeze(source string, pay_money int, positionId string) bool {
+func IsFreeze(source string, pay_money int, positionId, trailstatus string) bool {
 	log.Println(source, pay_money == 0, FindUpperLimit(gconv.String(
-		positionId), "", false))
+		positionId), "", false), trailstatus)
 	if source == "0104" && pay_money == 0 && FindUpperLimit(gconv.String(
 		positionId), "", false) {
 		return true
+	} else if source == "0104" && pay_money > 0 && trailstatus == "08" && FindUpperLimit(gconv.String(
+		positionId), "", false) {
+		return true
 	}
 	return false
 }

+ 10 - 10
clueSync/sendMail.go

@@ -18,7 +18,7 @@ var (
                     WHERE a.dept_name = '销售三部' AND a.resign = 0 AND c.role_id = 8`
 	dmInfo = `SELECT b.dept_name FROM dwd_d_crm_department_level_succbi b WHERE b.position_id IN (SELECT a.position_id FROM dwd_f_crm_personnel_management a
 		WHERE assign_type = 1) GROUP BY b.dept_name`
-	dmInfoCount = `SELECT b.position_id, COUNT(IF(a.trailstatus <> '08', 1, NULL)) as num FROM dwd_f_crm_clue_info a RIGHT JOIN dwd_d_crm_department_level_succbi b ON a.position_id = b.position_id LEFT JOIN dwd_f_crm_personnel_management c ON b.position_id = c.position_id WHERE b.dept_name = ? AND c.resign = 0 AND c.assign_type = 1 GROUP BY a.position_id HAVING num < ?`
+	dmInfoCount = `SELECT b.position_id, COUNT(IF( a.is_transfer != 1, 1, NULL)) as num FROM dwd_f_crm_clue_info a RIGHT JOIN dwd_d_crm_department_level_succbi b ON a.position_id = b.position_id LEFT JOIN dwd_f_crm_personnel_management c ON b.position_id = c.position_id WHERE b.dept_name = ? AND c.resign = 0 AND c.assign_type = 1 GROUP BY a.position_id HAVING num < ?`
 	dmInfoMail  = `SELECT a.name, a.position_id, (b.send_mail >> 2) & 1 AS flag_1, (b.send_mail >> 3) & 1 AS flag_2, c.mail FROM dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b ON a.position_id = b.position_id LEFT JOIN jianyu.entniche_user c ON a.ent_user_id = c.id WHERE a.dept_name = ? AND a.resign = 0 AND b.role_id = ?`
 	xgFlag      = `SELECT a.name, (b.send_mail >> 4) & 1 AS flag FROM dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b ON a.position_id = b.position_id WHERE b.role_id = 5 AND b.resign = 0`
 	xgMail      = `SELECT a.name, c.mail FROM dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b ON a.position_id = b.position_id LEFT JOIN jianyu.entniche_user c ON a.ent_user_id = c.id WHERE b.role_id = 5 AND b.resign = 0`
@@ -32,7 +32,7 @@ var (
 // @Description 个人预警/上限
 // @Date 2024/4/11
 func WarningPerl() {
-	sql := `SELECT count(*) FROM dwd_f_crm_clue_info where position_id = ? and trailstatus <> '08'`
+	sql := `SELECT count(*) FROM dwd_f_crm_clue_info where position_id = ?  and is_transfer != 1`
 	sql1 := `UPDATE dwd_f_crm_personnel_management SET send_mail = (%s) where position_id = ?`
 	pp := TiDb.SelectBySql(`SELECT name, position_id, send_mail & 1 AS flag_1, (send_mail >> 1) & 1 AS flag_2 FROM dwd_f_crm_personnel_management WHERE resign = 0`)
 	if pp != nil && len(*pp) > 0 {
@@ -60,7 +60,7 @@ func WarningPerl() {
 // @Description 部门预警/上限 所有人
 // @Date 2024/5/9
 func WarningDm() {
-	sql1 := `UPDATE dwd_f_crm_personnel_management SET send_mail = (%s) where position_id = ?`
+	sql1 := `UPDATE dwd_f_crm_personnel_management SET send_mail = (%s) where position_id = ? `
 	dm := TiDb.SelectBySql(dmInfo)
 	send := true // 所有人
 	for _, m := range *dm {
@@ -151,7 +151,7 @@ func WarningDm() {
 // @Date 2024/4/10
 func WillWarningByPp(posid int64) {
 	title := "您的私海线索即将达到上限通知"
-	content := "您的私海线索已超过%d条(不包含成交客户),即将达到私海线索上限%d条(不包含成交客户),请及时将无需跟进的线索退回公海,以避免无法接收新线索。"
+	content := "您的私海线索已超过%d条(含成交客户),即将达到私海线索上限%d条(含成交客户),请及时将无需跟进的线索退回公海,以避免无法接收新线索。"
 	toMail := ""
 	toCc := ""
 
@@ -205,7 +205,7 @@ func WorkMail(personMap map[string]interface{}, productStr string, orderStatus i
 // @Date 2024/4/10
 func WillWarningByDm(dname, to string, toCc []string) {
 	title := "“%s”私海线索即将达到上限通知"
-	content := "“%s”的所有参与线索分配的电销人员,私海线索都已达到%d条(不包含成交客户),即将达到私海线索上限%d条(不包含成交客户),请及时通知电销人员将无需跟进的线索退回公海,以避免无法接收新线索。"
+	content := "“%s”的所有参与线索分配的电销人员,私海线索都已达到%d条(含成交客户),即将达到私海线索上限%d条(含成交客户),请及时通知电销人员将无需跟进的线索退回公海,以避免无法接收新线索。"
 	title = fmt.Sprintf(title, dname)
 	content = fmt.Sprintf(content, dname, db.WarningValue, db.AllocationCap)
 	sendInfo(to, strings.Join(toCc, ","), title, content)
@@ -232,7 +232,7 @@ func WillWarningByAll() {
 // @Date 2024/4/10
 func ExceedLimitByPp(posid int64) {
 	title := "您的私海线索已达上限通知"
-	content := "您的私海线索已达到私海线索上限%d条(不包含成交客户),当前无法接收新线索,请及时将无需跟进的线索退回公海"
+	content := "您的私海线索已达到私海线索上限%d条(含成交客户),当前无法接收新线索,请及时将无需跟进的线索退回公海"
 
 	toMail := ""
 	toCc := ""
@@ -254,7 +254,7 @@ func ExceedLimitByPp(posid int64) {
 // @Date 2024/4/10
 func ExceedLimitByDm(dname, to string, toCc []string) {
 	title := "“%s”私海线索已达到上限通知"
-	content := "“%s”的所有参与线索分配的电销人员,私海线索都已达到私海线索上限%d条(不包含成交客户),当前无法接收新线索,请及时通知电销人员将无需跟进的线索退回公海"
+	content := "“%s”的所有参与线索分配的电销人员,私海线索都已达到私海线索上限%d条(含成交客户),当前无法接收新线索,请及时通知电销人员将无需跟进的线索退回公海"
 	title = fmt.Sprintf(title, dname)
 	content = fmt.Sprintf(content, dname, db.AllocationCap)
 	sendInfo(to, strings.Join(toCc, ","), title, content)
@@ -321,7 +321,7 @@ func CantBeAssignedNots() {
 // @Date 2024/4/10
 func HandOverFail(posid int64, ent string) {
 	title := "客成线索移交失败通知"
-	content := "您的私海线索已超过%d条(不包含成交客户),已达到私海线索上限%d条(不包含成交客户),导致“%s”无法从客成到期自动移交至私海,请及时将无需跟进的线索退回公海,超过%d个工作日不处理,该线索将自动退回至公海"
+	content := "您的私海线索已超过%d条(含成交客户),已达到私海线索上限%d条(含成交客户),导致“%s”无法从客成到期自动移交至私海,请及时将无需跟进的线索退回公海,超过%d个工作日不处理,该线索将自动退回至公海"
 
 	toMail := ""
 	toCc := ""
@@ -343,7 +343,7 @@ func HandOverFail(posid int64, ent string) {
 // @Date 2024/4/10
 func OrderCreateFail(posid int64, bname string) {
 	title := "订单用户创建线索失败通知"
-	content := "您的私海线索已超过%d条(不包含成交客户),已达到私海线索上限%d条(不包含成交客户),导致订单系统的用户“%s”无法进入您的私海,请及时将无需跟进的线索退回公海,超过%d个工作日不处理,该线索将自动进入至公海。"
+	content := "您的私海线索已超过%d条(含成交客户),已达到私海线索上限%d条(含成交客户),导致订单系统的用户“%s”无法进入您的私海,请及时将无需跟进的线索退回公海,超过%d个工作日不处理,该线索将自动进入至公海。"
 
 	toMail := ""
 	toCc := ""
@@ -365,7 +365,7 @@ func OrderCreateFail(posid int64, bname string) {
 // @Date 2024/5/11
 func AssFail(posid int64, ent, iname string) {
 	title := "您跟进的非集团公司线上线索分配失败"
-	content := "您的私海线索已达到私海线索上限%d条(不包含成交客户),导致您正在跟进的非集团公司“%s”产生的新线索“%s”无法进入您的私海,请及时将无需跟进的线索退回公海,退回后联系您的电销经理将此线索再划转至您的私海。"
+	content := "您的私海线索已达到私海线索上限%d条(含成交客户),导致您正在跟进的非集团公司“%s”产生的新线索“%s”无法进入您的私海,请及时将无需跟进的线索退回公海,退回后联系您的电销经理将此线索再划转至您的私海。"
 
 	toMail := ""
 	toCc := ""