xuzhiheng 1 year ago
parent
commit
3ca102dde1
3 changed files with 22 additions and 22 deletions
  1. 2 2
      clueSync/job.go
  2. 17 17
      clueSync/jobutil.go
  3. 3 3
      clueSync/kc.go

+ 2 - 2
clueSync/job.go

@@ -246,7 +246,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
 		} else { //不存在走新增
 			oks = SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, departments, industry, follow_project_area, role, seatNumber, position_id, source, sourceCode, remark, keyword, belong_to, isGroup, isCommerce)
 			if oks { //新增成功,销售分配次数+1
-				TiDb.UpdateOrDeleteBySql(`update dwd_f_crm_clue_autodraw_record set count = count + 1 where seatNumber = ? and clue_level = ?`, seatNumber, level)
+				TiDb.UpdateOrDeleteBySql(`update dwd_f_crm_clue_autodraw_record set count = count + 1 where position_id = ? and clue_level = ?`, position_id, level)
 			}
 		}
 		if !oks {
@@ -911,7 +911,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 			})
 		}
 		if old_position_id == 0 {
-			TiDb.UpdateOrDeleteBySql(`update dwd_f_crm_clue_autodraw_record set count = count + 1 where seatNumber = ? and clue_level = ?`, seatNumber, level)
+			TiDb.UpdateOrDeleteBySql(`update dwd_f_crm_clue_autodraw_record set count = count + 1 where position_id = ? and clue_level = ?`, positionId, level)
 		}
 		return true
 	} else {

+ 17 - 17
clueSync/jobutil.go

@@ -417,7 +417,7 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
 			for _, v := range *data {
 				isOk := false //判断是否有新员工
 				for _, vv := range *countData {
-					if common.ObjToString(v["seat_number"]) == common.ObjToString(vv["seatNumber"]) {
+					if common.Int64All(v["position_id"]) == common.Int64All(vv["position_id"]) {
 						if common.IntAll(v["resign"]) == 0 {
 							vv["status"] = 1
 						} else {
@@ -427,29 +427,29 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
 					}
 				}
 				if !isOk { //有新员工直接分给新员工
-					seatNumber = common.ObjToString(v["seat_number"])
+					positionId = common.Int64All(v["position_id"])
 					saleName = common.ObjToString(v["name"])
 					rData := TiDb.FindOne("dwd_f_crm_clue_autodraw_record", map[string]interface{}{"clue_level": mode}, "", "count desc")
 					TiDb.Insert("dwd_f_crm_clue_autodraw_record", map[string]interface{}{
-						"seatNumber": seatNumber,
-						"clue_level": mode,
-						"count":      common.Int64All((*rData)["count"]),
+						"position_id": positionId,
+						"clue_level":  mode,
+						"count":       common.Int64All((*rData)["count"]),
 					})
 					break
 				}
 			}
-			if seatNumber == "" {
+			if positionId > 0 {
 				res := int64(0)
 				countres := 0
 				for _, v := range *countData {
 					if common.IntAll(v["status"]) == 1 {
 						if countres == 0 {
 							res = common.Int64All(v["count"])
-							seatNumber = common.ObjToString(v["seatNumber"])
+							positionId = common.Int64All(v["position_id"])
 						} else {
 							if common.Int64All(v["count"]) <= res {
 								res = common.Int64All(v["count"])
-								seatNumber = common.ObjToString(v["seatNumber"])
+								positionId = common.Int64All(v["position_id"])
 							}
 						}
 						countres++
@@ -457,26 +457,26 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
 				}
 			}
 		} else {
-			seatNumber = common.ObjToString((*data)[0]["seat_number"])
+			positionId = common.Int64All((*data)[0]["position_id"])
 			saleName = common.ObjToString((*data)[0]["name"])
 			rData := TiDb.FindOne("dwd_f_crm_clue_autodraw_record", map[string]interface{}{"clue_level": mode}, "", "count desc")
 			if rData != nil && len(*rData) > 0 {
 				TiDb.Insert("dwd_f_crm_clue_autodraw_record", map[string]interface{}{
-					"seatNumber": seatNumber,
-					"clue_level": mode,
-					"count":      common.Int64All((*rData)["count"]),
+					"position_id": positionId,
+					"clue_level":  mode,
+					"count":       common.Int64All((*rData)["count"]),
 				})
 			} else {
 				TiDb.Insert("dwd_f_crm_clue_autodraw_record", map[string]interface{}{
-					"seatNumber": seatNumber,
-					"clue_level": mode,
-					"count":      0,
+					"position_id": positionId,
+					"clue_level":  mode,
+					"count":       0,
 				})
 			}
 		}
 		for _, v := range *data {
-			if seatNumber == common.ObjToString(v["seat_number"]) {
-				positionId = common.Int64All(v["position_id"])
+			if positionId == common.Int64All(v["position_id"]) {
+				seatNumber = common.ObjToString(v["seat_number"])
 				saleName = common.ObjToString(v["name"])
 			}
 		}

+ 3 - 3
clueSync/kc.go

@@ -613,8 +613,8 @@ func refundAuto() {
 				company_verification = common.IntAll((*clueData)["company_verification"])
 				uid = common.ObjToString((*clueData)["uid"])
 			}
-			query1 := fmt.Sprintf(`select id from dwd_f_userbase_order_info where (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime > "%s" and order_status = 1 and uid = "%s"`, nowTime, uid)
-			query2 := fmt.Sprintf(`select id from dwd_f_userbase_order_info where (product_type = "企业商机管理" or product_type = "大会员") and refund_status in (0,2) and order_status = 1 and uid = "%s"`, uid)
+			query1 := fmt.Sprintf(`select id from dwd_f_userbase_order_info where (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime > "%s" and order_status = 1 and pay_money > 0 and uid = "%s"`, nowTime, uid)
+			query2 := fmt.Sprintf(`select id from dwd_f_userbase_order_info where (product_type = "企业商机管理" or product_type = "大会员") and refund_status in (0,2) and order_status = 1 and pay_money > 0 and uid = "%s"`, uid)
 			log.Println("query1 ", query1)
 			log.Println("query2 ", query2)
 			order2 := TiDb.SelectBySql(query2)
@@ -666,7 +666,7 @@ func refundAuto() {
 				order1 := TiDb.SelectBySql(query1)
 				if order1 == nil || len(*order1) == 0 {
 					isOk := false
-					query3 := fmt.Sprintf(`select vip_endtime from dwd_f_userbase_order_info where (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime < "%s" and order_status = 1 and uid = "%s"`, nowTime, uid)
+					query3 := fmt.Sprintf(`select vip_endtime from dwd_f_userbase_order_info where (product_type = "企业商机管理" or product_type = "大会员") and vip_endtime < "%s" and order_status = 1 and pay_money > 0 and uid = "%s"`, nowTime, uid)
 					log.Println("query3 ", query3)
 					order3 := TiDb.SelectBySql(query3)
 					if order3 != nil && len(*order3) > 0 {