WH01243 13 ore în urmă
părinte
comite
9554580d29
4 a modificat fișierele cu 85 adăugiri și 12 ștergeri
  1. 19 9
      clueSync/config.go
  2. 2 1
      clueSync/db.json
  3. 2 2
      clueSync/job.go
  4. 62 0
      clueSync/kc.go

+ 19 - 9
clueSync/config.go

@@ -9,6 +9,7 @@ import (
 	"github.com/gogf/gf/v2/util/gconv"
 	"github.com/gogf/gf/v2/util/gconv"
 	"gopkg.in/gomail.v2"
 	"gopkg.in/gomail.v2"
 	"log"
 	"log"
+	"strings"
 	"time"
 	"time"
 )
 )
 
 
@@ -110,10 +111,11 @@ type (
 			MessageReturnMoney string `json:"messageReturnMoney"`
 			MessageReturnMoney string `json:"messageReturnMoney"`
 			Admin              string `json:"admin"`
 			Admin              string `json:"admin"`
 		} `json:"keCheng"`
 		} `json:"keCheng"`
-		EntId      int          `json:"entId"`
-		Mail       GmailAuth    `json:"mail"` //邮箱配置
-		Clickhouse CHouseConfig `json:"clickhouse"`
-		Crm        MysqlConfig  `json:"crmTiDb"`
+		EntId             int          `json:"entId"`
+		Mail              GmailAuth    `json:"mail"` //邮箱配置
+		Clickhouse        CHouseConfig `json:"clickhouse"`
+		Crm               MysqlConfig  `json:"crmTiDb"`
+		EnterCustomsource string       `json:"enterCustomsource"`
 	}
 	}
 	LableJson struct {
 	LableJson struct {
 		ConditionConfig []ConditionEntity `json:"conditionConfig"`
 		ConditionConfig []ConditionEntity `json:"conditionConfig"`
@@ -163,11 +165,14 @@ type GmailAuth struct {
 	ReTry    int
 	ReTry    int
 }
 }
 
 
-var AreaCode = map[string]string{}
-var CodeArea = map[string]string{}
-var CodeTrail = map[string]string{}
-var DateMap = map[string]int{}
-var ProductMap = map[string]string{}
+var (
+	AreaCode   = map[string]string{}
+	CodeArea   = map[string]string{}
+	CodeTrail  = map[string]string{}
+	DateMap    = map[string]int{}
+	ProductMap = map[string]string{}
+	KcSource   = map[string]bool{}
+)
 
 
 func InitArea() {
 func InitArea() {
 	info := TiDb.Find("d_area_code", nil, "", "", -1, -1)
 	info := TiDb.Find("d_area_code", nil, "", "", -1, -1)
@@ -197,6 +202,11 @@ func InitProduct(product []string) {
 		ProductMap[v] = "dk"
 		ProductMap[v] = "dk"
 	}
 	}
 }
 }
+func IntEnterCustomsource(customsource string) {
+	for _, v := range strings.Split(customsource, ",") {
+		KcSource[v] = true
+	}
+}
 func InitUserChannel() {
 func InitUserChannel() {
 	data := TiDb.SelectBySql(`SELECT
 	data := TiDb.SelectBySql(`SELECT
 	a.code,
 	a.code,

+ 2 - 1
clueSync/db.json

@@ -226,5 +226,6 @@
     "poolsize": 20,
     "poolsize": 20,
     "maxidle": 40,
     "maxidle": 40,
     "maxleft": 40
     "maxleft": 40
-  }
+  },
+  "enterCustomsource": "1,2,614"
 }
 }

+ 2 - 2
clueSync/job.go

@@ -1146,7 +1146,7 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
 			if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
 			if trailstatus == "00" && trailstatusTime != "" && time.Now().Unix()-trailstatusTimes.Unix() < 86400 {
 			} else {
 			} else {
 				if is_transfer == 1 {
 				if is_transfer == 1 {
-					if old_sub_cluetype != sub_cluetype && !is_ok {
+					if old_sub_cluetype != sub_cluetype && !is_ok && KcSource[top_cluetype] {
 						cdata := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}, "", "")
 						cdata := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}, "", "")
 						if cdata != nil && len(*cdata) > 0 {
 						if cdata != nil && len(*cdata) > 0 {
 							kcpositionId := common.Int64All((*cdata)["position_id"])
 							kcpositionId := common.Int64All((*cdata)["position_id"])
@@ -1773,7 +1773,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 				seatNumber = ""
 				seatNumber = ""
 			} else {
 			} else {
 				if is_transfer == 1 {
 				if is_transfer == 1 {
-					if old_sub_cluetype != sub_cluetype && !is_ok {
+					if old_sub_cluetype != sub_cluetype && !is_ok && KcSource[top_cluetype] {
 						cdata := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}, "", "")
 						cdata := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{"clue_id": clueId}, "", "")
 						if cdata != nil && len(*cdata) > 0 {
 						if cdata != nil && len(*cdata) > 0 {
 							kcpositionId := common.Int64All((*cdata)["position_id"])
 							kcpositionId := common.Int64All((*cdata)["position_id"])

+ 62 - 0
clueSync/kc.go

@@ -356,6 +356,32 @@ func kcJob(data map[string]interface{}) int {
 	return status
 	return status
 }
 }
 
 
+// 新增客成变更记录
+func addKChangeRecord(clueId, positionId int64, oldName, newName string) {
+	nowTime := time.Now().Format(date.Date_Full_Layout)
+	//进客成记录
+	TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
+		"clue_id":     clueId,
+		"position_id": positionId,
+		"change_type": "成交客户移交",
+		"new_value":   "移交至客户成功组",
+		"createtime":  nowTime,
+		"BCPCID":      common.GetRandom(32),
+		"operator_id": -1,
+	})
+	TiDb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
+		"clue_id":      clueId,
+		"position_id":  positionId,
+		"change_field": "position_id",
+		"change_type":  "客户成功经理",
+		"old_value":    common.If(oldName != newName, oldName, common.If(oldName == "", "/", oldName)),
+		"new_value":    newName,
+		"createtime":   nowTime,
+		"BCPCID":       common.GetRandom(32),
+		"operator_id":  -1,
+	})
+}
+
 // 客成人员查询
 // 客成人员查询
 func cAutoDraw(entId int, orderPositionId int64, salesperson, saleDep string, customData *map[string]interface{}, company_name string) (positionId int64, name string) {
 func cAutoDraw(entId int, orderPositionId int64, salesperson, saleDep string, customData *map[string]interface{}, company_name string) (positionId int64, name string) {
 	if customData != nil {
 	if customData != nil {
@@ -2043,3 +2069,39 @@ func getOrderData(sql string) (map[string]map[string]interface{}, string) {
 
 
 	return orderMap, lastEndTime
 	return orderMap, lastEndTime
 }
 }
+
+// 客成移交     其他相对应的数据也移交
+func OtherKcTransfer(uid, kcName, companyName, productName string, kcPositionId, entId int64) {
+	//查找子账号
+	if entId == 0 {
+		//个人账号
+		userData := TiDb.FindOne("data_service.user_system", map[string]interface{}{
+			"status": 1,
+			"uid":    uid,
+		}, "", "createtime DESC  ")
+		if userData == nil || len(*userData) == 0 {
+			log.Println(fmt.Sprintf("查询不到 %s 用户信息", uid))
+			return
+		}
+		mongoId := gconv.String((*userData)["userid"])
+		//子账号
+		query := map[string]interface{}{"s_member_mainid": mongoId}
+		childAccount, _ := Mgo.Find("user", query, "", `"_id":1`, false, -1, -1)
+		if childAccount == nil || len(*childAccount) == 0 {
+			log.Println(fmt.Sprintf("子账号查询不到 %s , %s 用户信息", uid, mongoId))
+		}
+		childIds := []string{}
+		log.Println(fmt.Sprintf("子账号 %s , %s , 数量 %v ", uid, mongoId, len(*childAccount)))
+		for _, v := range *childAccount {
+			childIds = append(childIds, mongodb.BsonIdToSId(v["_id"]))
+		}
+	}
+	//企业订单
+	//企业下人员查询
+	switch productName {
+	case "商机管理":
+	case "大会员":
+
+	}
+
+}