Pārlūkot izejas kodu

分配新增上限

WH01243 1 mēnesi atpakaļ
vecāks
revīzija
cb890b9f8f
5 mainītis faili ar 26 papildinājumiem un 10 dzēšanām
  1. 1 0
      clueSync/config.go
  2. 2 2
      clueSync/job.go
  3. 15 2
      clueSync/jobutil.go
  4. 7 5
      clueSync/lable.json
  5. 1 1
      clueSync/tag.go

+ 1 - 0
clueSync/config.go

@@ -225,6 +225,7 @@ type (
 	ConditionEntity struct {
 		TopName      string      `json:"topName"`
 		SubName      string      `json:"subName"`
+		Limitation   int64       `json:"limitation"`
 		ConditionArr []Condition `json:"conditionArr"`
 	}
 	Condition struct {

+ 2 - 2
clueSync/job.go

@@ -18,7 +18,7 @@ import (
 )
 
 func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
-	userId, uId, positionId, source, cluename, phone, sourceCode, keyword, _ := gconv.String(data["user_id"]), "", "", "", "", "", "", []string{}, ""
+	userId, uId, positionId, source, cluename, phone, sourceCode, keyword, limitation := gconv.String(data["user_id"]), "", "", "", "", "", "", []string{}, gconv.Int64(data["limitation"])
 	role, industry, department, departments, position, name, top_cluetype, sub_cluetype, follow_project_area, level := "", "", "", "", "", "", "", "", "", ""
 	query, topname, subname, belong_to, sourceName, remark, sourceId := map[string]interface{}{}, "", "", "01", "", "", int64(0)
 	nowTime := time.Now().Format("2006-01-02 15:04:05")
@@ -343,7 +343,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
 		return true, true, true
 	}
 	log.Println("人员选择", level, cluename, phone, isGroup, isCommerce)
-	position_id, seatNumber, saleName, saleData, pIsOk, isFreeze, noticePositionId := autoDraw(level, cluename, phone, isGroup, isCommerce) //查询当前分配次数最少的,如果当前线索有销售,此次找出的不会+1
+	position_id, seatNumber, saleName, saleData, pIsOk, isFreeze, noticePositionId := autoDraw(level, cluename, phone, isGroup, isCommerce, item, limitation) //查询当前分配次数最少的,如果当前线索有销售,此次找出的不会+1
 	log.Println("data -------", position_id, seatNumber, saleName, pIsOk, isFreeze, noticePositionId)
 	if position_id > 0 && seatNumber != "" {
 		uCount, oks := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", ""), true //查当前线索是否已存在

+ 15 - 2
clueSync/jobutil.go

@@ -1039,7 +1039,7 @@ func getClueType(item string, data map[string]interface{}, sourceCode string, so
 }
 
 // 获取自动分配的人
-func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId int64, seatNumber, saleName string, saleData []map[string]interface{}, isOk, isFreeze bool, noticePositionId int64) {
+func autoDraw(mode, cluename, phone string, isGroup, isCommerce int, item string, limitation int64) (positionId int64, seatNumber, saleName string, saleData []map[string]interface{}, isOk, isFreeze bool, noticePositionId int64) {
 	isOk = false
 	isFreeze = false
 	if TiDb.Count("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone, "is_assign": 1}) == 0 { //线索没销售进入,有销售走分配次数最少的逻辑
@@ -1077,6 +1077,7 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
 										m["saleName"] = common.ObjToString(v["name"])
 										cdataNew = append(cdataNew, m)
 									} else {
+										//达上限了
 										upperLimitCount++
 										upperLimitPersonMap[positionid1] = true
 										m["saleName"] = common.ObjToString(v["name"])
@@ -1268,7 +1269,7 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
 						if FindUpperLimit(gconv.String(v["position_id"]), mode, false) {
 							continue
 						}
-						if countres == 0 {
+						if countres == 0 && (item=="tag"&&  ){
 							res = common.Int64All(v["count"])
 							positionId = common.Int64All(v["position_id"])
 						} else {
@@ -1367,6 +1368,18 @@ func FindUpperLimit(positionId string, level string, isAdd bool) bool {
 	}
 	return isFull
 }
+//735线索是否达总量
+func Find735UpperLimit(positionId string, subName string, isAdd bool,limitation int64 ) bool {
+	timeStr:=time.Now().Format(time.time.DateOnly)
+	if positionId == "" {
+		return false
+	}
+	isFull := TiDb.CountBySql(`select count from dwd_f_crm_clue_autodraw_record where position_id=? and subName=?   and date = ?  `, positionId,subName,timeStr) >= limitation
+	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)
+	}
+	return isFull
+}
 func getSeatNumberPositionId(seatNumber string) (positionId int64) {
 	saleData := TiDb.FindOne("dwd_f_crm_personnel_management", map[string]interface{}{"seat_number": seatNumber}, "", "")
 	if saleData != nil && len(*saleData) > 0 {

+ 7 - 5
clueSync/lable.json

@@ -66,9 +66,10 @@
     },{
       "topName": "公海中电销历史标记用户",
       "subName": "点击留资弹框的历史接通用户",
+      "limitation": 120,
       "conditionArr": [
         {
-          "code": "click_saleLeads_gte_1_7day",
+          "code": "click_saleLeads_gte_3_1day",
           "fool": true
         },
         {
@@ -76,28 +77,29 @@
           "fool": true
         },
         {
-          "code": "telemarketing_follow_7_day",
+          "code": "telemarketing_follow_30_day",
           "fool": false
         },
         {
-          "code": "telemarketing_listen_7_day",
+          "code": "telemarketing_listen_30_day",
           "fool": false
         }
       ]
     },{
       "topName": "公海中电销历史标记用户",
       "subName": "访问标讯的近期未建联用户",
+      "limitation": 120,
       "conditionArr": [
         {
           "code": "1day_article_gte_10",
           "fool": true
         },
         {
-          "code": "telemarketing_follow_7_day",
+          "code": "telemarketing_follow_30_day",
           "fool": false
         },
         {
-          "code": "telemarketing_listen_7_day",
+          "code": "telemarketing_listen_30_day",
           "fool": false
         }
       ]

+ 1 - 1
clueSync/tag.go

@@ -399,7 +399,6 @@ func LabelToClue() {
 		if len(dataArr) == 0 {
 			continue
 		}
-
 		for _, baseUserId := range dataArr {
 			log.Println("735标签用户:", baseUserId)
 			if baseUserId == 0 {
@@ -409,6 +408,7 @@ func LabelToClue() {
 				"baseUserId": baseUserId,
 				"topName":    v.TopName,
 				"subName":    v.SubName,
+				"limitation": v.Limitation,
 			}, "tag")
 
 		}