소스 검색

二维码获取处理

WH01243 1 주 전
부모
커밋
82bf8d8129
3개의 변경된 파일21개의 추가작업 그리고 10개의 파일을 삭제
  1. 1 0
      clueSync/config.go
  2. 6 0
      clueSync/main.go
  3. 14 10
      clueSync/manualOperation.go

+ 1 - 0
clueSync/config.go

@@ -114,6 +114,7 @@ type (
 		Mail       GmailAuth    `json:"mail"` //邮箱配置
 		Clickhouse CHouseConfig `json:"clickhouse"`
 		Crm        MysqlConfig  `json:"crmTiDb"`
+		ApiPort    string       `json:"apiPort"`
 	}
 	LableJson struct {
 		ConditionConfig []ConditionEntity `json:"conditionConfig"`

+ 6 - 0
clueSync/main.go

@@ -102,6 +102,12 @@ func main() {
 	InitArea()
 	InitProduct(db.ProductArr)
 	InitUserChannel()
+	r := setupRouter()
+	go func() {
+		if err := r.Run(fmt.Sprintf(":%s", db.ApiPort)); err != nil {
+			log.Fatalf("HTTP服务启动失败: %v", err)
+		}
+	}()
 	if *mode == 1 {
 		go ordersClue() //后台订单进线索
 		//一秒钟一次

+ 14 - 10
clueSync/manualOperation.go

@@ -277,7 +277,8 @@ func GetPersonSubsidiary(positionId int64) (string, string, string) {
 		name = gconv.String((*personnel)["name"])
 	}
 	//二维码获取
-	qrData := Mysql.SelectBySql(`SELECT
+	if name != "" {
+		qrData := Mysql.SelectBySql(`SELECT
 			b.qr_code 
 		FROM
 			wx_qy_user a
@@ -286,8 +287,9 @@ func GetPersonSubsidiary(positionId int64) (string, string, string) {
 			AND b.is_del = 0 
 		ORDER BY
 			b.create_date DESC`, fmt.Sprintf("%%%s%%", name))
-	if qrData != nil && len(*qrData) > 0 {
-		qrCode = gconv.String((*qrData)[0]["qr_code"])
+		if qrData != nil && len(*qrData) > 0 {
+			qrCode = gconv.String((*qrData)[0]["qr_code"])
+		}
 	}
 	return phone, qrCode, name
 }
@@ -336,7 +338,7 @@ func processClueInfo(uId, cluename string) (isGroup, isCommerce int, kcPositionI
 	}, "", "")
 	if clueData != nil && len(*clueData) > 0 {
 		clueId := gconv.Int64((*clueData)["id"])
-		is_transfer := gconv.Int64((*clueData)["is_transfer"])
+		is_transfer = gconv.Int64((*clueData)["is_transfer"])
 		if is_transfer == 1 {
 			//在客成
 			customData := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{
@@ -354,24 +356,26 @@ func processClueInfo(uId, cluename string) (isGroup, isCommerce int, kcPositionI
 func getClueState(c *gin.Context) {
 	// 1. 参数绑定和验证
 	var req FetchDeptAdminRequest
+	response := FetchDeptAdminResponse{}
 	if err := c.ShouldBindJSON(&req); err != nil {
 		c.JSON(http.StatusBadRequest, gin.H{"error": "无效的请求参数"})
 		return
 	}
 	// 2. 处理用户信息
-	uId, _, _, _, _, _ := processUserInfo(req)
-
+	uId, _, source, belong_to, _, _ := processUserInfo(req)
+	if source == "0104" || strings.HasPrefix(belong_to, "02") || source == "0102" || source == "0103" || strings.HasPrefix(belong_to, "03") {
+		c.JSON(http.StatusOK, response)
+		return
+	}
 	// 3. 处理线索信息
 	_, _, kcPositionId, isTransfer, clueData := processClueInfo(uId, "")
-	// 4. 准备响应数据
-	response := FetchDeptAdminResponse{}
-	// 5. 根据是否转移获取不同数据
+	// 4. 根据是否转移获取不同数据
 	positionId := gconv.Int64((*clueData)["position_id"])
 	if isTransfer == 1 {
 		response.Phone, response.Wxer, response.Name = GetPersonSubsidiary(kcPositionId)
 	} else {
 		response.Phone, response.Wxer, response.Name = GetPersonSubsidiary(positionId)
 	}
-	// 6. 返回响应
+	// 5. 返回响应
 	c.JSON(http.StatusOK, response)
 }