Browse Source

Merge branch 'dev_v1.5.27.1_wh' of jianyu/datatools into hotfix/v1.5.27.1

王浩 6 months ago
parent
commit
298054009f
1 changed files with 32 additions and 2 deletions
  1. 32 2
      clueSync/kc.go

+ 32 - 2
clueSync/kc.go

@@ -948,7 +948,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, "销售") {
@@ -960,10 +973,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,