Selaa lähdekoodia

Merge branch 'master' into feature/v1.5.18

yuelujie 5 kuukautta sitten
vanhempi
commit
00d6c1290a

+ 1 - 1
clueSync/jobutil.go

@@ -374,7 +374,7 @@ func FindPosition(positionId int64, trailstatus, creatorTime string) (bool, map[
 FROM
 	dwd_d_crm_department_level_succbi a
 	INNER JOIN dwd_f_crm_personnel_management b ON a.resign = 0 and b.resign = 0
-	AND a.dept_name LIKE "%电销部%"
+	AND a.dept_name LIKE "销售一部%"
 	AND a.position_id = b.position_id`)
 	userData3 := TiDb.SelectBySql(`SELECT
 	a.position_id,

+ 39 - 6
clueSync/kc.go

@@ -29,7 +29,7 @@ var (
 func kcSync() {
 	log.Println("客户成功系统移交定时任务开始")
 	sql := `select * from dwd_f_userbase_order_info where (payable_money > 0 or  (payable_money=0 and  ( filter  like "%分期付款补充权益%"  or   filter  like "%原订单不支持开通多项权益%"  or    filter  like "%权益码兑换%")))
-	  and  data_spec!="dhy4" and  order_status=1  and (refund_status!=1  or  refund_status is null  ) and  vip_starttime<"2099-01-01"
+	  and  data_spec!="dhy4" and phone not   like "9%" and  order_status=1  and (refund_status!=1  or  refund_status is null  ) and  vip_starttime<"2099-01-01"
 	  and vip_endtime > "` + time.Now().Format(date.Date_Full_Layout) + `" and autoUpdate > "` + cfg.LastkcTime + `" order by autoUpdate asc`
 	//sql := `select * from dwd_f_userbase_order_info where order_code="173943424276"  `
 	data := TiDb.SelectBySql(sql)
@@ -55,6 +55,7 @@ func kcSync() {
 					continue
 				}
 				status := kcJob(v)
+				log.Println("订单进客成打印", orderCode, status)
 				if status == 0 {
 					break
 				}
@@ -78,7 +79,8 @@ func kcJob(data map[string]interface{}) int {
 	log.Println(data["order_code"], saleDep, orderPositionId, salesperson)
 	if clueData == nil || len(*clueData) == 0 {
 		if saleDep == "销售部" || saleDep == "市场部" {
-			return 1
+			log.Println("移交客成缺少基本信息", uId)
+			return 0
 		}
 		//创建线索
 		//原始订单获取
@@ -137,7 +139,7 @@ func kcJob(data map[string]interface{}) int {
 				return 0
 			}
 		} else {
-			return 1
+			return 0
 		}
 	}
 	clueId = common.Int64All((*clueData)["id"])
@@ -627,7 +629,7 @@ func refundAuto() {
 			isRenewalProtection := common.IntAll(v["is_renewal_protection"])
 			clueData := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, "name,phone,company_nature,company_verification,cluename,userid,position_id,uid", "")
 			if clueData != nil && len(*clueData) > 0 {
-				saleId = common.Int64All((*clueData)["position_id"])
+				saleId, _ = FindPositionIdClueId(clueId)
 				cluename = common.ObjToString((*clueData)["cluename"])
 				userName = gconv.String((*clueData)["name"])
 				company_nature = common.IntAll((*clueData)["company_nature"])
@@ -891,7 +893,7 @@ FROM
 				FROM dwd_f_crm_personnel_management u2
 				WHERE u1.position_id = u2.position_id		
 			)
-			ORDER BY id desc) b ON  a.dept_name LIKE "%销部%"
+			ORDER BY id desc) b ON  a.dept_name LIKE "%销售一部%"
 	AND a.position_id = b.position_id`)
 	userData3 := TiDb.SelectBySql(`SELECT
 	a.position_id,
@@ -1085,6 +1087,7 @@ func CustomerChange() {
 		}
 		return true
 	}, `select operator_id, clue_id,position_id,old_value,new_value,createtime from   dwd_f_crm_clue_change_record  where    createtime>?  and change_type="客户成功经理"   order by  createtime`, startTime)
+	//}, `select operator_id, clue_id,position_id,old_value,new_value,createtime from   dwd_f_crm_clue_change_record  where   id=?   order by  createtime`, 21921661)
 	if len(customMap1) > 0 {
 		ChangeSendKc(customMap1, 1)
 	}
@@ -1124,6 +1127,7 @@ func ChangeSendKc(data map[string][]map[string]interface{}, personType int64) {
 }
 
 func ChangeSendSale(data map[int64][]map[string]interface{}, personType int64) {
+	log.Println("客成人员变更", personType, data)
 	if personType == 1 {
 		//客户成功经理从空变成有人
 		for _, v := range data {
@@ -1186,7 +1190,8 @@ func CustomerChangeHandle(data map[string]interface{}) map[string]interface{} {
 	}
 	phone = common.ObjToString((*clueData)["phone"])
 	userName = gconv.String((*clueData)["name"])
-	positionId := gconv.Int64((*clueData)["position_id"])
+	//positionId := gconv.Int64((*clueData)["position_id"])
+	positionId, _ := FindPositionIdClueId(clueId)
 	clueName = gconv.String((*clueData)["cluename"])
 	customData := TiDb.FindOne("dwd_f_csm_customer_info", map[string]interface{}{
 		"clue_id": clueId,
@@ -1205,6 +1210,34 @@ func CustomerChangeHandle(data map[string]interface{}) map[string]interface{} {
 		"companyName": companyName,
 	}
 }
+func FindPositionIdClueId(clueId int64) (int64, string) {
+	querySql := `
+	SELECT
+		b.salesperson,c.position_id
+	FROM
+		dwd_f_crm_clue_info a
+		INNER JOIN dwd_f_userbase_order_info b ON a.id = ?
+		AND a.uid = b.uid 
+		AND (
+			b.payable_money > 0 
+			OR (
+				b.payable_money = 0 
+			AND ( b.filter LIKE "%分期付款补充权益%" OR b.filter LIKE "%原订单不支持开通多项权益%" OR b.filter LIKE "%权益码兑换%" ))) 
+		AND b.data_spec != "dhy4" 
+		AND b.order_status = 1 and b.phone not   like "9%"
+		AND ( b.refund_status != 1 OR b.refund_status IS NULL ) 
+		AND b.vip_starttime < "2099-01-01" 
+		AND b.product_type IN ( "大会员", "企业商机管理" ) 
+		AND ( b.order_change = 0 OR ( b.order_change = 0 AND DATEDIFF( b.vip_endtime, b.vip_starttime )> 90 ) ) 
+		INNER JOIN   dwd_f_crm_personnel_management c   on c.ent_id =?  and    b.salesperson=c.name 
+	ORDER BY
+		b.create_time,b.payable_money DESC limit  1`
+	clueData := TiDb.SelectBySql(querySql, clueId, db.EntId)
+	if clueData == nil || len(*clueData) == 0 {
+		return 0, ""
+	}
+	return gconv.Int64((*clueData)[0]["position_id"]), gconv.String((*clueData)[0]["salesperson"])
+}
 func refundAutoHistory() {
 	data := TiDb.Find("dwd_f_crm_clue_autodraw_record", nil, "", "", -1, -1)
 	if data != nil {

+ 1 - 1
telemarketingEtl/entity/Voiced.go

@@ -135,7 +135,7 @@ func getRecord() {
 	)
 	if firstLoad {
 		// 当日首次执行	1、全部归0 outbound_count
-		config.JianyuSubjectdb.ExecBySql("UPDATE dwd_f_crm_attribute_label SET outbound_count = 0")
+		config.JianyuSubjectdb.ExecBySql("UPDATE dwd_f_crm_attribute_label SET outbound_count = 0 WHERE DATE(createTime) BETWEEN DATE(NOW() - INTERVAL 7 DAY) AND DATE(NOW())")
 		sql = "SELECT createTime, CallNo, CalledNo FROM voice_record WHERE DATE(createTime) BETWEEN DATE(NOW() - INTERVAL 7 DAY) AND DATE(NOW()) ORDER BY createTime ASC"
 		countSql = "SELECT COUNT(id) FROM voice_record WHERE DATE(createTime) BETWEEN DATE(NOW() - INTERVAL 7 DAY) AND DATE(NOW())"
 	} else {

+ 4 - 0
telemarketingEtl/entity/dwd_f_userbase_event_info.go

@@ -179,6 +179,7 @@ func EventInfoAdd(start, end int64) {
 						if len(uarr) > 0 {
 							biddingId := uarr[0]
 							//获取标讯标题
+							log.Println("biddingId:", biddingId)
 							bdata, ok := config.MgoBid.FindById("bidding", biddingId, `{"title":1}`)
 							if ok && bdata != nil && len(*bdata) > 0 {
 								name = gconv.String((*bdata)["title"])
@@ -420,6 +421,9 @@ func AppClient(urls string) string {
 // return title href
 func GetInfoByBid(bid string) (string, string) {
 	title, href := "", ""
+	if bid == "" {
+		return "", ""
+	}
 	res, _ := config.MgoBid.FindById("bidding", bid, `{"title":1,"href":1}`)
 
 	if res == nil || len(*res) == 0 {

+ 2 - 2
telemarketingEtl/main.go

@@ -15,8 +15,8 @@ func main() {
 	//t3.Run()
 	//t4 := &timetask.TaskVipExpire{}
 	//t4.Run()
-	t5 := &timetask.TaskJyDetail{}
-	t5.Run()
+	//t5 := &timetask.TaskJyDetail{}
+	//t5.Run()
 
 	//t := &timetask.TaskVisitInfo{}
 	//t.Run()