浏览代码

Merge remote-tracking branch 'origin/feature/v1.5.39' into feature/v1.5.39

renjiaojiao 3 天之前
父节点
当前提交
147b6eeea3
共有 5 个文件被更改,包括 56 次插入10 次删除
  1. 6 0
      clueSync/job.go
  2. 6 0
      clueSync/jobutil.go
  3. 22 4
      clueSync/kc.go
  4. 19 3
      clueSync/shuaku.go
  5. 3 3
      clueSync/transferDx.go

+ 6 - 0
clueSync/job.go

@@ -327,6 +327,11 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
 		phone = gconv.String((*userInfo)["phone"])
 		sourceCode = gconv.String(data["sourceCode"])
 		log.Println(sourceCode)
+	} else if item == "powerdDele" {
+		uId = gconv.String(data["uid"])
+		source = gconv.String(data["source"])       //用户来源
+		belong_to = gconv.String(data["belong_to"]) //用户归属
+		phone = gconv.String(data["phone"])
 	}
 	log.Println(222, cluename)
 	if cluename == "" && item != "message" && item != "orders" && item != "readClue" &&
@@ -338,6 +343,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
 	cluename = strings.ReplaceAll(cluename, " ", "")
 	isGroup, isCommerce := GetCompanyType(cluename, uId) //判断是否集团公司、工商库
 	//获取用户渠道
+	//if (source == "0104" && !isSubAccount) || strings.HasPrefix(belong_to, "02") || source == "0102" || source == "0103" || phone == "" { //参照用户来源代码表
 	if strings.HasPrefix(belong_to, "02") || source == "0102" || source == "0103" || phone == "" { //参照用户来源代码表
 		//log.Println("线索分配失败,线索过滤!!", item, source, phone, userId)
 		//saveHlyj(belong_to, item, phone, name, sourceName, cluename, position, nowTime, isGroup, isCommerce)

+ 6 - 0
clueSync/jobutil.go

@@ -1128,6 +1128,12 @@ func getClueType(item string, data map[string]interface{}, sourceCode string, so
 				code = common.ObjToString((*codeData)["code"])
 			}
 		}
+	} else if item == "powerdDele" {
+		pcode = "532"
+		code = "949"
+		level = "C"
+		topname = "其他"
+		subname = "产品权限被企业删除"
 	} else {
 		if sourceCode != "" {
 			codeData := TiDb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"source": sourceCode}, "", "")

+ 22 - 4
clueSync/kc.go

@@ -41,6 +41,7 @@ FROM
 	AND ( a.refund_status != 1 OR a.refund_status IS NULL ) 
 	AND b.service_starttime < "2099-01-01" AND b.service_endtime > now() 
 	AND b.update_time > "%s"
+
 ORDER BY
     b.update_time asc ,
 	a.order_code ASC,
@@ -1983,7 +1984,7 @@ func addClueNameChangeRecord(clueType, clueId int64, oldName, newName string, kc
 		description = "订单公司信息变更"
 	}
 	//新增变更记录
-	AddClueChange(clueId, kcPositionId, "cluename", "基本信息变更", oldName, newName, nowTime, common.GetRandom(32), description, "")
+	AddClueChange(clueId, kcPositionId, "cluename", "基本信息变更", oldName, newName, nowTime, common.GetRandom(32), "", description)
 }
 
 func updateClueTransfer(clueId int64, nowTime string) {
@@ -2108,6 +2109,7 @@ func EntOperateHandle() {
 			if number == 80 {
 				Mysql.Update("ent_operate_record", map[string]interface{}{
 					"entUserId": entUserId,
+					"isUse":     0,
 				}, map[string]interface{}{
 					"isUse": 1,
 				})
@@ -2130,6 +2132,7 @@ func EntOperateHandle() {
 				//没有归集需要等一等
 				Mysql.Update("ent_operate_record", map[string]interface{}{
 					"entUserId": entUserId,
+					"isUse":     0,
 				}, map[string]interface{}{
 					"number": number,
 				})
@@ -2144,6 +2147,7 @@ func EntOperateHandle() {
 				log.Println("企业操作线索不存在:", uid)
 				Mysql.Update("ent_operate_record", map[string]interface{}{
 					"entUserId": entUserId,
+					"isUse":     0,
 				}, map[string]interface{}{
 					"number": number,
 				})
@@ -2156,7 +2160,8 @@ func EntOperateHandle() {
 			isCreate := false
 			isTransfer := false
 			oldClueType := int64(0)
-			minEntry, _ := GetPersonIdentityPower(uid, 5, entId, gconv.String((*clueData)["cluename"]))
+			minEntry, _ := GetPersonIdentityPower(uid, gconv.Int(common.If(operate > 0, 51, 52)), entId, gconv.String((*clueData)["cluename"]))
+			//minEntry, _ := GetPersonIdentityPower(uid, gconv.Int(common.If(operate > 0, 51, 52)), entId, "2222")
 			newClueType := int64(0)
 			if minEntry != nil {
 				newClueType = gconv.Int64(minEntry["newAccountType"])
@@ -2172,6 +2177,7 @@ func EntOperateHandle() {
 				//之前不在客成  没有权限    不需要处理
 				Mysql.Update("ent_operate_record", map[string]interface{}{
 					"entUserId": entUserId,
+					"isUse":     0,
 				}, map[string]interface{}{
 					"isUse": 1,
 				})
@@ -2210,12 +2216,13 @@ func EntOperateHandle() {
 				if minEntry == nil {
 					Mysql.Update("ent_operate_record", map[string]interface{}{
 						"entUserId": entUserId,
+						"isUse":     0,
 					}, map[string]interface{}{
 						"isUse": 1,
 					})
 					continue
 				}
-				//新增
+				//查看是否创建
 				if isCreate {
 					if isTransfer {
 						//在客成
@@ -2252,8 +2259,8 @@ func EntOperateHandle() {
 				if isCreate && isTransfer {
 					if newClueType == 0 {
 						//查询不到其他权限
-						productName := GetProductName(gconv.Int64((*customData)["product_access"]))
 						//走退出
+						productName := GetProductName(gconv.Int64((*customData)["product_access"]))
 						changeReason := ""
 						switch operate {
 						case -1:
@@ -2270,6 +2277,15 @@ func EntOperateHandle() {
 							changeReason = fmt.Sprintf("%s权限被企业删除", productName)
 						}
 						kcToOpenSeaUpdate(clueId, gconv.Int64((*customData)["position_id"]), oldClueType, changeReason)
+						if isPower {
+							//需要重新进课程
+							FormatData(map[string]interface{}{
+								"belong_to": "0100",
+								"source":    "0101",
+								"uid":       uid,
+								"phone":     "phone",
+							}, "powerdDele")
+						}
 					} else {
 						//已创建   在客成可继续处理   其他不需要操作
 						if newClueType >= oldClueType {
@@ -2283,6 +2299,7 @@ func EntOperateHandle() {
 				} else {
 					Mysql.Update("ent_operate_record", map[string]interface{}{
 						"entUserId": entUserId,
+						"isUse":     0,
 					}, map[string]interface{}{
 						"isUse": 1,
 					})
@@ -2290,6 +2307,7 @@ func EntOperateHandle() {
 			}
 			Mysql.Update("ent_operate_record", map[string]interface{}{
 				"entUserId": entUserId,
+				"isUse":     0,
 			}, map[string]interface{}{
 				"isUse": 1,
 			})

+ 19 - 3
clueSync/shuaku.go

@@ -21,7 +21,8 @@ func customInit() {
 				a.name,
 				a.is_renewal_protection,
 				a.company_name,
-				a.account_type 
+				a.account_type,
+				b.cluename
 			FROM
 				dwd_f_csm_customer_info  a INNER JOIN    dwd_f_crm_clue_info  b   on    a.is_transfer   =0 and  a.clue_id=b.id`
 	aaa = `SELECT
@@ -36,15 +37,30 @@ func customInit() {
 		a.name,
 		a.is_renewal_protection,
 		a.company_name,
-		a.account_type
+		a.account_type,
+		b.cluename
 	FROM
 		dwd_f_csm_customer_info  a INNER JOIN    dwd_f_crm_clue_info  b   on    a.id =600006   and  a.clue_id=b.id`
 	nowTime := time.Now().Format(date.Date_Full_Layout)
 	TiDb.SelectByBath(100, func(l *[]map[string]interface{}) bool {
 		for _, v := range *l {
 			//先保证线索名称和订单公司名字一致
-			log.Println(gconv.String(v["id"]), ":客成数据开始处理")
+			companyName := gconv.String(v["company_name"])
+			clueName := gconv.String(v["cluename"])
 			uId := gconv.String(v["uid"])
+			clueId := gconv.Int64(v["clue_id"])
+			positionId := gconv.Int64(v["position_id"])
+			if companyName != clueName && clueName != "" && companyName != "" {
+				if !isGroupCompany(companyName) {
+					//非集团
+					//做名称变更
+					//线索名称修改
+					updateClueName(clueId, companyName, nowTime, uId)
+					addClueNameChangeRecord(5, clueId, clueName, companyName, positionId, nowTime)
+				}
+			}
+			log.Println(gconv.String(v["id"]), ":客成数据开始处理")
+
 			productName := GetProductName(gconv.Int64(v["product_access"]))
 			productname := ""
 			if strings.Contains(productName, "大会员") {

+ 3 - 3
clueSync/transferDx.go

@@ -70,11 +70,11 @@ func GetPersonIdentityPower(uid string, accountType int, currentEntId int64, clu
 		log.Println("大会员子账号")
 	}
 	switch accountType {
-	case 1, 2, 5:
+	case 1, 2, 51, 52:
 		for _, v := range *userEntData {
 			newType := 0
 			entId := common.Int64All(v["ent_id"])
-			if entId == currentEntId {
+			if entId == currentEntId && accountType != 51 {
 				continue
 			}
 			userPhone := common.InterfaceToStr(v["phone"])
@@ -151,7 +151,7 @@ func GetPersonIdentityPower(uid string, accountType int, currentEntId int64, clu
 				allMemberType = append(allMemberType, data)
 			}
 			//被踢出企业   以后   归集表还没有处理
-			if newType == 0 && accountType == 5 && !isGroupCompany(cluename) {
+			if newType == 0 && (accountType == 51 || accountType == 52) && !isGroupCompany(cluename) {
 				//是否是集团
 				if cluename != "" {
 					entCusData := TiDb.FindOne("dwd_f_csm_customer_info", bson.M{"company_name": cluename, "is_transfer": 0, "account_type": 1}, "", "")