瀏覽代碼

冻结时间处理

WH01243 1 年之前
父節點
當前提交
a8106f29a9
共有 4 個文件被更改,包括 35 次插入17 次删除
  1. 18 2
      clueSync/autoTask.go
  2. 2 2
      clueSync/jobutil.go
  3. 4 2
      clueSync/kc.go
  4. 11 11
      clueSync/main.go

+ 18 - 2
clueSync/autoTask.go

@@ -386,10 +386,15 @@ func Thaw() {
 	k := 3
 	nowTime := time.Now()
 	for {
-		if k == 0 || IsBreak(nowTime) {
+		if k == 0 {
 			break
 		}
+
 		nowTime = nowTime.AddDate(0, 0, -1)
+
+		if !IsBreak(nowTime) {
+			continue
+		}
 		k--
 		fmt.Println(nowTime.Format("20060102"))
 	}
@@ -406,7 +411,7 @@ func Thaw() {
 		for _, v := range *l {
 			clueId := gconv.Int64(v["id"])
 			positionId := gconv.Int64(v["position_id"])
-			if FindUpperLimit(gconv.String(positionId), "positionId") {
+			if !FindUpperLimit(gconv.String(positionId), "positionId") {
 				//退公海处理
 				if TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{
 					"is_assign": 1,
@@ -423,6 +428,16 @@ func Thaw() {
 						"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":  "线索解冻",
+					"new_value":    "销售人员私海线索已释放",
+					"createtime":   nowTime,
+					"BCPCID":       common.GetRandom(32),
+					"operator_id":  -1,
+				})
 			} else {
 				//分配状态改改
 				if TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, map[string]interface{}{
@@ -442,6 +457,7 @@ func Thaw() {
 					})
 				}
 			}
+
 		}
 		return true
 	}, `select id,position_id from dwd_f_crm_clue_info where is_assign = -3 and FREEZE_TIME<=? `, nowTime.Format(date.Date_Full_Layout))

+ 2 - 2
clueSync/jobutil.go

@@ -146,6 +146,7 @@ func userbase() {
 	log.Println("userbase定时任务开始")
 	selectTimeEnd := time.Unix(time.Now().Unix()-1800, 0).Format("2006-01-02 15:04:05")
 	sql := fmt.Sprintf(`select * from dwd_f_userbase_baseinfo where updatetime > "%s" and source != "0105" and source != "0104" and source != "0103" and source != "0102"`, selectTimeEnd)
+	//sql := fmt.Sprintf(`select * from dwd_f_userbase_baseinfo where id='11927183'`)
 	data := TiDb.SelectBySql(sql)
 	if data != nil && *data != nil && len(*data) > 0 {
 		for _, v := range *data {
@@ -157,7 +158,7 @@ func userbase() {
 			nowTime := time.Now().Format(date.Date_Full_Layout)
 			source := common.ObjToString(v["source"])
 			if phone != "" {
-				contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where phone = ? and is_delete = 1", phone)
+				contactsData := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where D = ? and is_delete = 1", phone)
 				if contactsData == nil || len(*contactsData) == 0 {
 					contactsData2 := TiDb.SelectBySql("select * from dwd_f_userbase_contacts where baseinfo_id = ? and is_delete = 1", uId)
 					if contactsData2 != nil && len(*contactsData2) > 0 {
@@ -416,7 +417,6 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
 										}
 										isWait = true
 										return
-
 									}
 								} else {
 									saleName = common.ObjToString(v["name"])

+ 4 - 2
clueSync/kc.go

@@ -409,6 +409,8 @@ func ordersClue() {
 	lastOrderClueId := cfg.LastOrderClueId
 	nowTime := time.Now().Format(date.Date_Full_Layout)
 	sql := fmt.Sprintf(`select order_status,is_backstage_order,pay_money,saleDep,salesperson,user_phone,create_person,saleMoney,user_id,product_type,company_name,autoUpdate from dataexport_order where autoUpdate >= "%s" order by autoUpdate asc`, lastOrderClueId)
+	//sql := fmt.Sprintf(`select order_status,is_backstage_order,pay_money,saleDep,salesperson,user_phone,create_person,saleMoney,user_id,product_type,company_name,autoUpdate from dataexport_order where order_code= '134531275535' order by autoUpdate asc`)
+
 	data := Mysql.SelectBySql(sql)
 	if data != nil && *data != nil && len(*data) > 0 {
 		for _, v := range *data {
@@ -602,7 +604,7 @@ func ordersClue() {
 								"clue_id":     clueId,
 								"position_id": positionId,
 								"change_type": "线索冻结",
-								"new_value":   "线索冻结",
+								"new_value":   "销售人员私海线索已释放",
 								"createtime":  nowTime,
 								"BCPCID":      common.GetRandom(32),
 								"operator_id": -1,
@@ -817,7 +819,7 @@ func refundAuto() {
 								"clue_id":     clueId,
 								"position_id": saleId,
 								"change_type": "线索冻结",
-								"new_value":   "线索冻结",
+								"new_value":   "销售人员私海线索已释放",
 								"createtime":  nowTime,
 								"BCPCID":      common.GetRandom(32),
 								"operator_id": -1,

+ 11 - 11
clueSync/main.go

@@ -103,18 +103,18 @@ func main() {
 	MgoLog = mongodb.NewMgoWithUser(cfg.MgoLog.Address, cfg.MgoLog.DbName, cfg.MgoLog.User, cfg.MgoLog.Password, cfg.MgoLog.DbSize)
 	MgoQyxy = mongodb.NewMgoWithUser(cfg.MgoQyxy.Address, cfg.MgoQyxy.DbName, cfg.MgoQyxy.User, cfg.MgoQyxy.Password, cfg.MgoQyxy.DbSize)
 	InitArea()
-	/*
-		//自动释放处理1
-		//UpperLimitAutoExitSea(cfg.AllocationCap)
-		//订单成线索处理
-		//ordersClue() //后台订单进线索
-		//客成移交失败
-		//refundAuto()
-		//自动分配1
-		//saleLeads()
-		//解冻处理
-		Thaw()*/
 
+	/*//自动释放处理1
+	//UpperLimitAutoExitSea(cfg.AllocationCap)
+	//订单成线索处理
+	//ordersClue() //后台订单进线索
+	//客成移交失败
+	//refundAuto()
+	//自动分配1
+	//saleLeads()
+	//解冻处理
+	Thaw()
+	//userbase()*/
 	if *mode == 1 {
 		//30分钟一次
 		a := cron.New()