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

Merge branch 'master' into feature/v1.5.27

lianbingjie 6 сар өмнө
parent
commit
e4ca23be9e
1 өөрчлөгдсөн 33 нэмэгдсэн , 3 устгасан
  1. 33 3
      clueSync/kc.go

+ 33 - 3
clueSync/kc.go

@@ -80,7 +80,7 @@ func kcJob(data map[string]interface{}) int {
 			seatNumber = "0000"
 		}
 		cluename = common.ObjToString(data["company_name"])
-		phone = common.ObjToString(data["user_phone"])
+		phone = common.ObjToString(data["phone"])
 		if cluename == "" {
 			cluename = phone
 		}
@@ -1457,7 +1457,20 @@ func IsFreeze(source string, pay_money int, positionId, trailstatus string) bool
 	return false
 }
 func FindSaleRecord(orderCode string) (dept string, positionId int64, position string) {
-	recordList := Mysql.SelectBySql("select   * from   order_sale_record  where  ordercode=?  ORDER BY   state ,money ", orderCode)
+	recordList := Mysql.SelectBySql(`
+			SELECT
+			a.saler_dept,
+			a.saler_name,
+			b.phone 
+		FROM
+			order_sale_record a
+			INNER JOIN cadmin.admin_user b 
+		on 
+			a.ordercode = ? and  a.saler_Id = b.id 
+		ORDER BY
+			a.state,
+			a.money
+	`, orderCode)
 	if recordList != nil && len(*recordList) > 0 {
 		saler_dept := gconv.String((*recordList)[0]["saler_dept"])
 		if strings.Contains(saler_dept, "销售") {
@@ -1469,10 +1482,27 @@ func FindSaleRecord(orderCode string) (dept string, positionId int64, position s
 		} else {
 			saler_dept = ""
 		}
-		return saler_dept, gconv.Int64((*recordList)[0]["saler_Id"]), gconv.String((*recordList)[0]["saler_name"])
+		positionid := PhoneToPositionId(gconv.String((*recordList)[0]["phone"]))
+		if positionid > 0 {
+			return saler_dept, positionid, gconv.String((*recordList)[0]["saler_name"])
+		}
 	}
 	return "", int64(0), ""
 }
+func PhoneToPositionId(phone string) int64 {
+	positionId := int64(0)
+	data := Base.SelectBySql(`SELECT
+						 b.id
+					FROM
+						base_user a
+						INNER JOIN base_position b ON a.phone = ?
+						AND a.id = b.user_id 
+						AND b.ent_id = 25917`, phone)
+	if data != nil && len(*data) > 0 {
+		positionId = gconv.Int64((*data)[0]["id"])
+	}
+	return positionId
+}
 func kcClue(userId, uId, seatNumber, cluename, top_cluetype, sub_cluetype,
 	name, phone, position, sourceCode, industry, follow_project_area,
 	role, item, subname, topname, remark, demand, department, departments, saleName, source string,