Эх сурвалжийг харах

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

王浩 6 сар өмнө
parent
commit
837cea422d
1 өөрчлөгдсөн 15 нэмэгдсэн , 11 устгасан
  1. 15 11
      clueSync/kc.go

+ 15 - 11
clueSync/kc.go

@@ -22,7 +22,7 @@ func kcSync() {
 	  and  data_spec!="dhy4" and  order_status=1  and refund_status!=1  and  vip_starttime<"2099-01-01"
 	  and vip_endtime > "` + time.Now().Format(date.Date_Full_Layout) + `" and autoUpdate > "` + cfg.LastkcTime + `" order by autoUpdate asc`
 
-	//sql := `select * from dwd_f_userbase_order_info where order_code="160431577234"  `
+	//sql := `select * from dwd_f_userbase_order_info where order_code="152504013602"  `
 	data := TiDb.SelectBySql(sql)
 	if data != nil && *data != nil && len(*data) > 0 {
 		arr := []string{}
@@ -200,6 +200,8 @@ func kcJob(data map[string]interface{}) int {
 		if csmdata != nil && len(*csmdata) > 0 {
 			id := gconv.Int64((*csmdata)["id"])
 			log.Println(1111111, id, orderCode)
+			//'已移交销售,0移交客成 1移交销售',
+			is_transfer := gconv.Int64((*csmdata)["is_transfer"])
 			customerPositionId, customerName := cAutoDraw(0, orderPositionId, salesperson, saleDep, true, csmdata)
 			log.Println("移交客成positionId", customerPositionId, customerName, saleDep, orderPositionId, salesperson, true)
 			oldName := gconv.String((*csmdata)["name"])
@@ -226,7 +228,7 @@ func kcJob(data map[string]interface{}) int {
 				"BCPCID":      common.GetRandom(32),
 				"operator_id": -1,
 			})
-			if customerPositionId > 0 {
+			if customerPositionId > 0 && is_transfer == 1 {
 				TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
 					"clue_id":      clueId,
 					"position_id":  customerPositionId,
@@ -247,8 +249,8 @@ func kcJob(data map[string]interface{}) int {
 					"BCPCID":      common.GetRandom(32),
 					"operator_id": -1,
 				})
-				KcSend(orderCode, customerName)
 			}
+			KcSend(orderCode, customerName)
 			TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{"is_transfer": 1, "updatetime": nowTime, "name": userName})
 		}
 	} else {
@@ -282,8 +284,8 @@ func kcJob(data map[string]interface{}) int {
 					"BCPCID":       common.GetRandom(32),
 					"operator_id":  -1,
 				})
-				KcSend(orderCode, customerName)
 			}
+			KcSend(orderCode, customerName)
 			updateId2 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 				"clue_id":     clueId,
 				"position_id": customerPositionId,
@@ -1104,15 +1106,16 @@ func KcSend(orderCode, personName string) {
 		table += fmt.Sprintf(db.KeCheng.Mail.Table, orderInfo.ProductType, orderInfo.CompanyName, orderInfo.UserPhone, orderInfo.UserName, orderInfo.OrderCode, orderInfo.PayMoney, orderInfo.StartEnd, orderInfo.DisKcName, orderInfo.SaleName, tableAppend)
 		//发送邮件
 		if deptData != nil && len(*deptData) > 0 && table != "" {
-			mailArr := []string{}
+			mailMap := map[string]bool{}
 			for _, m := range *deptData {
-				mail := gconv.String(m["mail"])
-				if mail != "" {
-					mailArr = append(mailArr, gconv.String(m["mail"]))
+				mailStr := gconv.String(m["mail"])
+				if mailStr == "" {
+					continue
 				}
-			}
-			if len(mailArr) > 0 {
-				mailStr := strings.Join(mailArr, "|")
+				if _, exists := mailMap[mailStr]; exists {
+					continue
+				}
+				mailMap[mailStr] = true
 				gmail := &mail.GmailAuth{
 					SmtpHost: db.Mail.SmtpHost,
 					SmtpPort: db.Mail.SmtpPort,
@@ -1124,6 +1127,7 @@ func KcSend(orderCode, personName string) {
 					log.Println("客成发邮件 send mail success", table, mailStr)
 				}
 			}
+
 		}
 	}
 }