Sfoglia il codice sorgente

完善自动分配

xuzhiheng 2 anni fa
parent
commit
06300e18eb
1 ha cambiato i file con 27 aggiunte e 6 eliminazioni
  1. 27 6
      clueSync/job.go

+ 27 - 6
clueSync/job.go

@@ -191,6 +191,9 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
 	//seatNumber position_id
 	//自动分配规则暂不确定
 	log.Println("data +++", top_cluetype, sub_cluetype, level, follow_project_area)
+	if top_cluetype == "" || sub_cluetype == "" || level == "" {
+		return true, true
+	}
 	position_id, seatNumber, saleName, saleData := autoDraw(level)
 	log.Println("data -------", position_id, seatNumber, saleName)
 	if position_id > 0 && seatNumber != "" && top_cluetype != "" && sub_cluetype != "" {
@@ -720,6 +723,11 @@ func autoDraw(mode string) (positionId int64, seatNumber, saleName string, saleD
 				isOk := false
 				for _, vv := range *countData {
 					if common.ObjToString(v["seatNumber"]) == common.ObjToString(vv["seatNumber"]) {
+						if common.IntAll(v["status"]) == 0 {
+							vv["status"] = 1
+						} else {
+							vv["status"] = 2
+						}
 						isOk = true
 					}
 				}
@@ -738,16 +746,29 @@ func autoDraw(mode string) (positionId int64, seatNumber, saleName string, saleD
 			}
 			if seatNumber == "" {
 				res := int64(0)
-				for k, v := range *countData {
-					if k == 0 {
-						res = common.Int64All(v["count"])
-						seatNumber = common.ObjToString(v["seatNumber"])
-					} else {
-						if common.Int64All(v["count"]) <= res {
+				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"])
+						} else {
+							if common.Int64All(v["count"]) <= res {
+								res = common.Int64All(v["count"])
+								seatNumber = common.ObjToString(v["seatNumber"])
+							}
 						}
+						countres++
 					}
+					// if k == 0 {
+					// 	res = common.Int64All(v["count"])
+					// 	seatNumber = common.ObjToString(v["seatNumber"])
+					// } else {
+					// 	if common.Int64All(v["count"]) <= res {
+					// 		res = common.Int64All(v["count"])
+					// 		seatNumber = common.ObjToString(v["seatNumber"])
+					// 	}
+					// }
 				}
 			}
 		} else {