Browse Source

防撞单优化

xuzhiheng 1 năm trước cách đây
mục cha
commit
0b7e84f15c
5 tập tin đã thay đổi với 31 bổ sung29 xóa
  1. 1 1
      clueSync/everything.go
  2. 1 1
      clueSync/job.go
  3. 26 24
      clueSync/jobutil.go
  4. 1 1
      clueSync/kc.go
  5. 2 2
      clueSync/trailContent.go

+ 1 - 1
clueSync/everything.go

@@ -510,7 +510,7 @@ func bigCustomer() {
 	} else {
 		detailName = time.Now().Format(date.Date_Short_Layout) + "无线索"
 	}
-	email := "xuzhiheng@topnet.net.cn,wenyue@topnet.net.cn,zoushanshan@topnet.net.cn,fanzongdong@topnet.net.cn,sunzhenjie@topnet.net.cn"
+	email := "xuzhiheng@topnet.net.cn,wenyue@topnet.net.cn,zhangwenfu@topnet.net.cn,zhufengchao@topnet.net.cn,zoushanshan@topnet.net.cn,fanzongdong@topnet.net.cn,sunzhenjie@topnet.net.cn"
 	// email = "xuzhiheng@jianyu360.com"
 	dir := "./xlsx/" + fileName + ".xlsx"
 	err := xf.Save(dir)

+ 1 - 1
clueSync/job.go

@@ -233,7 +233,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
 		log.Println("线索分配失败,线索过滤top_cluetype!!", item, uId, phone, userId)
 		return true, true
 	}
-	position_id, seatNumber, saleName, saleData, pIsOk := autoDraw(level, cluename, isGroup, isCommerce)
+	position_id, seatNumber, saleName, saleData, pIsOk := autoDraw(level, cluename, phone, isGroup, isCommerce)
 	log.Println("data -------", position_id, seatNumber, saleName)
 	if position_id > 0 && seatNumber != "" {
 		uCount, oks := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", ""), true

+ 26 - 24
clueSync/jobutil.go

@@ -365,36 +365,38 @@ func getClueType(item string, data map[string]interface{}, sourceCode string, so
 }
 
 // 获取自动分配的人
-func autoDraw(mode, cluename string, isGroup, isCommerce int) (positionId int64, seatNumber, saleName string, saleData []map[string]interface{}, isOk bool) {
+func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId int64, seatNumber, saleName string, saleData []map[string]interface{}, isOk bool) {
 	isOk = false
-	if isGroup == 0 && isCommerce == 1 && cluename != "" {
-		cdata := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"cluename": cluename, "is_assign": 1}, "", "")
-		if cdata != nil && len(*cdata) > 0 {
-			isOk = true
-			positionId = common.Int64All((*cdata)["position_id"])
-			seatNumber = common.ObjToString((*cdata)["seatNumber"])
-			log.Println("positionId seatNumber ", positionId, seatNumber)
-			if positionId > 0 {
-				pdata := TiDb.SelectBySql(`select * from dwd_f_crm_personnel_management where seat_number is not null and seat_number != ""`)
-				if pdata != nil {
-					saleData = *pdata
-					for _, v := range *pdata {
-						resign := common.IntAll(v["resign"])
-						if seatNumber == common.ObjToString(v["seat_number"]) {
-							if resign == 1 { //离职分配
-								sdata := TiDb.SelectBySql(`SELECT b.name,b.position_id,b.seat_number from dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b on a.position_id = b.position_id where a.bi_pcode = (SELECT bi_pcode from dwd_d_crm_department_level_succbi where position_id = ?) and b.role_id = 3`, positionId)
-								if sdata != nil && len(*sdata) > 0 {
-									positionId = common.Int64All((*sdata)[0]["position_id"])
-									seatNumber = common.ObjToString((*sdata)[0]["seat_number"])
-									saleName = common.ObjToString((*sdata)[0]["name"])
+	if TiDb.Count("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone, "is_assign": 1}) == 0 {
+		if isGroup == 0 && isCommerce == 1 && cluename != "" {
+			cdata := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"cluename": cluename, "is_assign": 1}, "", "")
+			if cdata != nil && len(*cdata) > 0 {
+				isOk = true
+				positionId = common.Int64All((*cdata)["position_id"])
+				seatNumber = common.ObjToString((*cdata)["seatNumber"])
+				log.Println("positionId seatNumber ", positionId, seatNumber)
+				if positionId > 0 {
+					pdata := TiDb.SelectBySql(`select * from dwd_f_crm_personnel_management where seat_number is not null and seat_number != ""`)
+					if pdata != nil {
+						saleData = *pdata
+						for _, v := range *pdata {
+							resign := common.IntAll(v["resign"])
+							if seatNumber == common.ObjToString(v["seat_number"]) {
+								if resign == 1 { //离职分配
+									sdata := TiDb.SelectBySql(`SELECT b.name,b.position_id,b.seat_number from dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b on a.position_id = b.position_id where a.bi_pcode = (SELECT bi_pcode from dwd_d_crm_department_level_succbi where position_id = ?) and b.role_id = 3`, positionId)
+									if sdata != nil && len(*sdata) > 0 {
+										positionId = common.Int64All((*sdata)[0]["position_id"])
+										seatNumber = common.ObjToString((*sdata)[0]["seat_number"])
+										saleName = common.ObjToString((*sdata)[0]["name"])
+									}
+								} else {
+									saleName = common.ObjToString(v["name"])
 								}
-							} else {
-								saleName = common.ObjToString(v["name"])
 							}
 						}
 					}
+					return
 				}
-				return
 			}
 		}
 	}

+ 1 - 1
clueSync/kc.go

@@ -369,7 +369,7 @@ func ordersClue() {
 	log.Println("后台订单线索定时任务开始")
 	lastOrderClueId := cfg.LastOrderClueId
 	nowTime := time.Now().Format(date.Date_Full_Layout)
-	sql := fmt.Sprintf(`select * from dataexport_order where autoUpdate >= "%s" order by autoUpdate asc`, lastOrderClueId)
+	sql := fmt.Sprintf(`select order_status,is_backstage_order,pay_money,saleDep,salesperson,user_phone,create_person,saleMoney,user_id,product_type,company_name,autoUpdate from dataexport_order where autoUpdate >= "%s" order by autoUpdate asc`, lastOrderClueId)
 	data := Mysql.SelectBySql(sql)
 	if data != nil && *data != nil && len(*data) > 0 {
 		for _, v := range *data {

+ 2 - 2
clueSync/trailContent.go

@@ -137,7 +137,7 @@ func getXlsx() {
 						})
 					} else {
 						//在公海
-						positionId, seatNumber, _, _, _ := autoDraw("C", "", 0, 0)
+						positionId, seatNumber, _, _, _ := autoDraw("C", "", "", 0, 0)
 						TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{
 							"seatNumber":   seatNumber,
 							"position_id":  positionId,
@@ -168,7 +168,7 @@ func getXlsx() {
 					if base != nil && len(*base) > 0 {
 						uId := common.ObjToString((*base)["uid"])
 						userId := common.ObjToString((*base)["userid"])
-						positionId, seatNumber, _, _, _ := autoDraw("C", "", 0, 0)
+						positionId, seatNumber, _, _, _ := autoDraw("C", "", "", 0, 0)
 						clueId := TiDb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
 							"userid":       userId,
 							"uid":          uId,