Browse Source

Merge remote-tracking branch 'origin/feature/v1.5.3' into dev_v1.5.3_wh

# Conflicts:
#	clueSync/kc.go
WH01243 1 year ago
parent
commit
e99da80775
2 changed files with 35 additions and 15 deletions
  1. 33 13
      clueSync/kc.go
  2. 2 2
      clueSync/sendMail.go

+ 33 - 13
clueSync/kc.go

@@ -19,7 +19,26 @@ import (
 
 func kcSync() {
 	log.Println("客户成功系统移交定时任务开始")
-	sql := `select * from dwd_f_userbase_order_info where pay_money > 0 and vip_endtime > "` + time.Now().Format(date.Date_Full_Layout) + `" and autoUpdate > "` + cfg.LastkcTime + `" order by autoUpdate asc`
+<<<<<<< HEAD
+	//sql := `select * from dwd_f_userbase_order_info where pay_money > 0 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
+	uid in ("4b534cf8e67811ed972200163e3214c2","1928dfe0e69611ed972200163e3214c2","9949f6384e5511eebd3a00163e3214c2","9912accee69411ed972200163e3214c2","98de316406b011efbb0e00163e3214c2","d35a5734e69811ed972200163e3214c2","274e8eaae67b11ed972200163e3214c2","937f16bce69411ed972200163e3214c2","8cd465fac48e11eeb38300163e3214c2","a83cb826e68411ed972200163e3214c2","ed9f9ebce69111ed972200163e3214c2","b27abc84e69311ed972200163e3214c2","7e40357ce67d11ed972200163e3214c2","14e1a9d6e68b11ed972200163e3214c2","7ce2192ee69211ed972200163e3214c2","741f3ff2e68711ed972200163e3214c2","b54b3148e69111ed972200163e3214c2","6bd34a0e098811eeb04a00163e3214c2","62c887f0e69a11ed972200163e3214c2","47f24806e67911ed972200163e3214c2","b9929da2e69311ed972200163e3214c2","421a0dace69611ed972200163e3214c2","c9300b46e67011ed972200163e3214c2","0b01efc8e69711ed972200163e3214c2","c796378e05d111efaee600163e3214c2","47fe4f58e69611ed972200163e3214c2","5867d45a3d9811ee829800163e3214c2","c484486ce69a11ed972200163e3214c2","018261e2e67611ed972200163e3214c2","bace9eb8e69911ed972200163e3214c2","c292fc6ce67511ed972200163e3214c2","092c4d12e69011ed972200163e3214c2","49f7912ee67411ed972200163e3214c2","cbe2589ce68111ed972200163e3214c2")
+	AND pay_money > 0 
+	AND vip_endtime > now() 
+	AND product_type IN ( "大会员", "企业商机管理" ) 
+	AND order_status = 1 
+	AND data_spec != "dhy4" 
+	AND refund_status != 1 
+	AND vip_starttime != "2099-01-01 00:00:00"
+
+`
+=======
+	sql := `select * from dwd_f_userbase_order_info where payable_money > 0 and vip_endtime > "` + time.Now().Format(date.Date_Full_Layout) + `" and autoUpdate > "` + cfg.LastkcTime + `" order by autoUpdate asc`
+>>>>>>> master
 	data := TiDb.SelectBySql(sql)
 	if data != nil && *data != nil && len(*data) > 0 {
 		for _, v := range *data {
@@ -29,15 +48,16 @@ func kcSync() {
 			order_status := common.IntAll(v["order_status"])
 			refund_status := common.IntAll(v["refund_status"])
 			if (product_type == "大会员" || product_type == "企业商机管理") && order_status == 1 && data_spec != "dhy4" && !strings.HasPrefix(starttime, "2099") && refund_status != 1 {
-				status := kcJob(v)
-				if status == 0 {
+				kcJob(v)
+				//status := kcJob(v)
+				/*if status == 0 {
 					break
-				}
+				}*/
 			}
-			cfg.LastkcTime = common.ObjToString(v["autoUpdate"])
+			//cfg.LastkcTime = common.ObjToString(v["autoUpdate"])
 		}
 	}
-	common.WriteSysConfig(&cfg)
+	//common.WriteSysConfig(&cfg)
 	log.Println("客户成功系统移交定时任务结束")
 }
 
@@ -54,7 +74,7 @@ func kcJob(data map[string]interface{}) int {
 		product_type := common.ObjToString(data["product_type"])
 		data_spec := common.ObjToString(data["data_spec"])
 		userName := common.ObjToString((*clueData)["name"])
-		phone := common.ObjToString((*clueData)["phone"])
+		//phone := common.ObjToString((*clueData)["phone"])
 		product, company_name := 0, common.ObjToString(data["company_name"])
 		productMap := map[string]int{
 			"dhy6":   1,
@@ -75,7 +95,7 @@ func kcJob(data map[string]interface{}) int {
 				starttime = common.ObjToString((*powerData)["starttime"])
 				endtime = common.ObjToString((*powerData)["endtime"])
 			} else {
-				log.Println("客成移交权限未查到--", phone)
+				log.Println("客成移交权限未查到--", uId)
 				return 0
 			}
 		} else {
@@ -96,7 +116,7 @@ func kcJob(data map[string]interface{}) int {
 		}
 		//同一公司名称(以客户详情-组织机构-公司名称)下的线索需分配给同1人
 		//合力亿捷线索同步
-		customerData := TiDbData.FindOne("customer", map[string]interface{}{"phone": phone}, "", "")
+		/*customerData := TiDbData.FindOne("customer", map[string]interface{}{"phone": phone}, "", "")
 		if customerData != nil {
 			log.Println("移交客成查询到合力亿捷")
 			status999 := common.ObjToString((*customerData)["status999"])               //线索状态
@@ -165,7 +185,7 @@ func kcJob(data map[string]interface{}) int {
 				"industry":            belongToIndustry,
 				"follow_project_area": areaCode,
 			})
-		}
+		}*/
 		//
 		entIds := common.IntAll(data["ent_id"])
 		positionId, name = cAutoDraw(entIds)
@@ -650,7 +670,7 @@ func refundAuto() {
 			}
 			isFull := FindUpperLimit(gconv.String(saleId), "", false)
 			isAllRefund := false
-			myOrders := TiDb.SelectBySql(`select refund_status from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and order_status = 1 and pay_money > 0 and vip_endtime < ?`, uid, nowTime)
+			myOrders := TiDb.SelectBySql(`select refund_status from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and order_status = 1  and vip_endtime < ?`, uid, nowTime)
 			if myOrders != nil {
 				refundCount := 0
 				for _, v := range *myOrders {
@@ -707,10 +727,10 @@ func refundAuto() {
 				})
 				TiDb.UpdateOrDeleteBySql(`UPDATE dwd_f_csm_customer_info SET is_transfer=1 WHERE clue_id = ?`, clueId)
 			} else {
-				order1 := TiDb.SelectBySql(`select id from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime > ? and order_status = 1 and pay_money > 0`, uid, nowTime)
+				order1 := TiDb.SelectBySql(`select id from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime > ? and order_status = 1 `, uid, nowTime)
 				if order1 == nil || len(*order1) == 0 {
 					isOk := false
-					order3 := TiDb.SelectBySql(`select vip_endtime from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime < ? and order_status = 1 and pay_money > 0`, uid, nowTime)
+					order3 := TiDb.SelectBySql(`select vip_endtime from dwd_f_userbase_order_info where uid=? and (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime < ? and order_status = 1 `, uid, nowTime)
 					if order3 != nil && len(*order3) > 0 {
 						for _, vv := range *order3 {
 							if isRenewalProtection == 1 {

+ 2 - 2
clueSync/sendMail.go

@@ -17,9 +17,9 @@ var (
                     WHERE a.dept_name = '销售三部' AND a.resign = 0 AND c.role_id = 3`
 	dmInfo = `SELECT b.dept_name FROM dwd_d_crm_department_level_succbi b WHERE b.position_id IN (SELECT a.position_id FROM dwd_f_crm_personnel_management a
 		WHERE assign_type = 1) GROUP BY b.dept_name`
-	dmInfoCount = `SELECT b.position_id, COUNT(IF(a.trailstatus <> '08', 1, NULL)) as num FROM Jianyu_subjectdb_test.dwd_f_crm_clue_info a RIGHT JOIN Jianyu_subjectdb_test.dwd_d_crm_department_level_succbi b ON a.position_id = b.position_id LEFT JOIN Jianyu_subjectdb_test.dwd_f_crm_personnel_management c ON b.position_id = c.position_id WHERE b.dept_name = ? AND c.resign = 0 AND c.assign_type = 1 GROUP BY a.position_id HAVING num < ?`
+	dmInfoCount = `SELECT b.position_id, COUNT(IF(a.trailstatus <> '08', 1, NULL)) as num FROM dwd_f_crm_clue_info a RIGHT JOIN dwd_d_crm_department_level_succbi b ON a.position_id = b.position_id LEFT JOIN dwd_f_crm_personnel_management c ON b.position_id = c.position_id WHERE b.dept_name = ? AND c.resign = 0 AND c.assign_type = 1 GROUP BY a.position_id HAVING num < ?`
 	dmInfoMail  = `SELECT a.name, a.position_id, (b.send_mail >> 2) & 1 AS flag_1, (b.send_mail >> 3) & 1 AS flag_2, c.mail FROM dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b ON a.position_id = b.position_id LEFT JOIN jianyu.entniche_user c ON a.ent_user_id = c.id WHERE a.dept_name = ? AND a.resign = 0 AND b.role_id = 3`
-	xgFlag      = `SELECT a.name, (b.send_mail >> 4) & 1 AS flag FROM dwd_d_crm_department_level_succbi a INNER JOIN jianyu_subjectdb_test.dwd_f_crm_personnel_management b ON a.position_id = b.position_id WHERE b.role_id = 5 AND b.resign = 0`
+	xgFlag      = `SELECT a.name, (b.send_mail >> 4) & 1 AS flag FROM dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b ON a.position_id = b.position_id WHERE b.role_id = 5 AND b.resign = 0`
 	xgMail      = `SELECT a.name, c.mail FROM dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b ON a.position_id = b.position_id LEFT JOIN jianyu.entniche_user c ON a.ent_user_id = c.id WHERE b.role_id = 5 AND b.resign = 0`
 	// 所有参与线索分配人员的邮箱
 	allMail = `SELECT a.name, c.mail FROM dwd_f_crm_personnel_management a INNER JOIN dwd_d_crm_department_level_succbi b ON a.position_id  = b.position_id LEFT JOIN jianyu.entniche_user c ON b.ent_user_id  = c.id  WHERE a.assign_type = 1 AND a.resign = 0`