浏览代码

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

王浩 1 年之前
父节点
当前提交
f1e0194961
共有 4 个文件被更改,包括 39 次插入19 次删除
  1. 32 12
      clueSync/jobutil.go
  2. 0 2
      clueSync/kc.go
  3. 5 3
      clueSync/main.go
  4. 2 2
      clueSync/sendMail.go

+ 32 - 12
clueSync/jobutil.go

@@ -47,7 +47,9 @@ func rderAcceptance() {
 						product = gconv.String(v1["field_value"])
 					}
 				}
-				WorkDataHandle(company, phone, demand, name, product, v)
+				if !WorkDataHandle(company, phone, demand, name, product, v) {
+					log.Println("工单创建失败")
+				}
 			}
 		}
 	}
@@ -63,6 +65,7 @@ func WorkDataHandle(company, phone, demand, name, product string, acceptanceData
 		}
 	}
 	if uId == "" {
+		log.Println("用户信息不存在")
 		return false
 	}
 	cluename := company
@@ -83,17 +86,17 @@ func WorkDataHandle(company, phone, demand, name, product string, acceptanceData
 			}
 			UpdateClue(*uCount, saleData, "", "", uId, "", "", "", "", company, name, gconv.String(data["name"]), phone, "", "", "", "", "", "", gconv.String(data["seat_number"]), "", gconv.Int64(data["position_id"]), "", "", "", []string{}, "", isGroup, isCommerce, true, demand)
 		} else {
-			trailstatusl := gconv.String((*uCount)["trailstatusl"])
-			if trailstatusl == "01" || trailstatusl == "03" || trailstatusl == "04" {
+			trailstatus := gconv.String((*uCount)["trailstatus"])
+			if trailstatus == "01" || trailstatus == "03" || trailstatus == "04" {
 				//变更销售员
 				ok, data, saleData = FindPosition(positionId, "", false)
 				if !ok {
 					return false
 				}
 				UpdateClue(*uCount, saleData, "", "", uId, "", "", "", "", company, name, gconv.String(data["name"]), phone, "", "", "", "", "", "", gconv.String(data["seat_number"]), "", gconv.Int64(data["position_id"]), "", "", "", []string{}, "", isGroup, isCommerce, true, demand)
-			} else if trailstatusl == "08" {
+			} else if trailstatus == "08" {
 				//客成
-				//查找客成人员标识
+				//生成客成数据
 				customerMap := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{
 					"clue_id": clueId,
 				}, "position_id", "")
@@ -104,11 +107,23 @@ func WorkDataHandle(company, phone, demand, name, product string, acceptanceData
 						"position_id": (*customerMap)["position_id"],
 						"name":        (*customerMap)["name"],
 					}
+				} else {
+					log.Println("查询不到客成数据", clueId, uId)
+					return false
 				}
-
+				TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
+					"clue_id":       clueId,
+					"position_id":   (*customerMap)["position_id"],
+					"change_type":   "加入任务车",
+					"new_value":     "工单创建",
+					"new_value_BAK": "工单创建",
+					"createtime":    time.Now().Format(date.Date_Full_Layout),
+					"BCPCID":        common.GetRandom(32),
+					"operator_id":   -1,
+				})
 			} else {
 				//线索变更
-				ok, data, saleData = FindPosition(positionId, trailstatusl, false)
+				ok, data, saleData = FindPosition(positionId, trailstatus, false)
 				if !ok {
 					return false
 				}
@@ -139,11 +154,15 @@ func AddOrderWork(acceptanceData map[string]interface{}, userData map[string]int
 			productArr = append(productArr, v)
 		}
 	}
+	two_type := "dx"
+	if gconv.String(userData["type"]) == "kc" {
+		two_type = "kc"
+	}
 	orderWorkMap := map[string]interface{}{
 		"work_order_no":         work_order_no,
 		"acceptance_no":         gconv.String(acceptanceData["acceptance_no"]),
 		"type":                  strings.Join(productArr, ","),
-		"status":                common.If(gconv.Int64(userData["orderStatus"]) == 0, 1, 2),
+		"status":                common.If(gconv.Int64(userData["orderStatus"]) == 0, 2, 1),
 		"initiator_name":        gconv.String(acceptanceData["creator_name"]),
 		"initiator_position_id": gconv.String(acceptanceData["initiator_position_id"]),
 		"current_name":          userData["name"],
@@ -152,7 +171,7 @@ func AddOrderWork(acceptanceData map[string]interface{}, userData map[string]int
 		"creator_name":          gconv.String(acceptanceData["creator_name"]),
 		"creator_position_id":   gconv.String(acceptanceData["creator_position_id"]),
 		"creator_time":          nowTime,
-		"two_type":              "dx",
+		"two_type":              two_type,
 		"department_no":         gconv.String(acceptanceData["department_no"]),
 		"department_name":       gconv.String(acceptanceData["department_name"]),
 	}
@@ -258,7 +277,7 @@ func FindNumber(moudle string) string {
 }
 
 // 人员查询
-func FindPosition(positionId int64, trailstatusl string, full bool) (bool, map[string]interface{}, []map[string]interface{}) {
+func FindPosition(positionId int64, trailstatus string, full bool) (bool, map[string]interface{}, []map[string]interface{}) {
 	allData := []map[string]interface{}{}
 	//查询是否满了
 	if positionId != 0 {
@@ -353,7 +372,7 @@ FROM
 		if full {
 			switch positiontype {
 			case 1:
-				if trailstatusl == "01" || trailstatusl == "03" || trailstatusl == "04" {
+				if trailstatus == "01" || trailstatus == "03" || trailstatus == "04" {
 					//找他上级
 					positionId1 := gconv.String(administrators1["position_id"])
 					administrators = administrators1
@@ -362,7 +381,7 @@ FROM
 					}
 				}
 			case 3:
-				if trailstatusl == "01" || trailstatusl == "03" || trailstatusl == "04" {
+				if trailstatus == "01" || trailstatus == "03" || trailstatus == "04" {
 					//找他上级
 					positionId1 := gconv.String(administrators3["position_id"])
 					administrators = administrators3
@@ -391,6 +410,7 @@ FROM
 	} else {
 		return true, administrators1, allData
 	}
+	log.Println("电销信息获取失败", positionId)
 	return false, map[string]interface{}{}, allData
 }
 func CalculateProportion(positionIsStr string) float64 {

+ 0 - 2
clueSync/kc.go

@@ -410,8 +410,6 @@ func ordersClue() {
 	lastOrderClueId := cfg.LastOrderClueId
 	nowTime := time.Now().Format(date.Date_Full_Layout)
 	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)
-	//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 order_code= '134531275535' order by autoUpdate asc`)
-
 	data := Mysql.SelectBySql(sql)
 	if data != nil && *data != nil && len(*data) > 0 {
 		for _, v := range *data {

+ 5 - 3
clueSync/main.go

@@ -3,6 +3,7 @@ package main
 import (
 	"flag"
 	"fmt"
+	"github.com/robfig/cron"
 	"log"
 
 	"app.yhyue.com/moapp/jybase/common"
@@ -113,9 +114,9 @@ func main() {
 	MgoQyxy = mongodb.NewMgoWithUser(cfg.MgoQyxy.Address, cfg.MgoQyxy.DbName, cfg.MgoQyxy.User, cfg.MgoQyxy.Password, cfg.MgoQyxy.DbSize)
 	InitArea()
 	InitProduct(cfg.ProductArr)
-	rderAcceptance()
 	//kcSync() //移交客成
-	/*if *mode == 1 {
+	rderAcceptance()
+	if *mode == 1 {
 		//30分钟一次
 		a := cron.New()
 		a.AddFunc(cfg.CornExp1, func() {
@@ -158,6 +159,7 @@ func main() {
 			go tagAddSync()     //用户标签增量
 			go autoExitSea()    //自动退海
 			go Thaw()           //自动解冻处理
+			go rderAcceptance() //工单生成
 		})
 		e.Start()
 		//5分钟一次
@@ -197,5 +199,5 @@ func main() {
 		//refundAutoHistory()
 		users()
 		saleLeads()
-	}*/
+	}
 }

+ 2 - 2
clueSync/sendMail.go

@@ -181,8 +181,8 @@ func WorkMail(personMap map[string]interface{}, productStr string, orderStatus i
 	toMail := gconv.String(personMap["mail"])
 	toCc := fmt.Sprintf("%s%s", gconv.String(common.If(gconv.String(personMap["deptPersonMail"]) == "", "", gconv.String(personMap["deptPersonMail"]))), gconv.String(common.If(gconv.String(personMap["superiorDepthPersonMail"]) == "", "", gconv.String(personMap["superiorDepthPersonMail"]))))
 	log.Println(toMail, toCc, title, content)
-	toMail = "wanghao@topnet.net.cn"
-	toCc = "wanghao@topnet.net.cn"
+	/*toMail = "wanghao@topnet.net.cn"
+	toCc = "wanghao@topnet.net.cn"*/
 	sendInfo(toMail, toCc, title, content)
 }