wangchuanjin před 1 rokem
rodič
revize
abb65a37ff

+ 10 - 7
api/internal/service/network.go

@@ -484,16 +484,15 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 	if in.Current_page <= 0 {
 		in.Current_page = 1
 	}
-	logx.Info(fmt.Sprintf("%+v", in))
-	args := []interface{}{in.PositionId, in.PositionId, in.PositionId}
+	sqlAppendArgs := []interface{}{}
 	sqlAppend1 := ""
 	if in.Type != "" {
 		sqlAppend1 += ` and a.itype=?`
-		args = append(args, n.TypeStrConvert(in.Type))
+		sqlAppendArgs = append(sqlAppendArgs, n.TypeStrConvert(in.Type))
 	}
 	if in.Starttime != "" {
 		sqlAppend1 += ` and a.create_time>=?`
-		args = append(args, in.Starttime+" 00:00:00")
+		sqlAppendArgs = append(sqlAppendArgs, in.Starttime+" 00:00:00")
 	}
 	if in.Endtime != "" {
 		sqlAppend1 += ` and a.create_time<=?`
@@ -502,19 +501,23 @@ func (n *network) List(in *types.NetWorkListReq) *types.Reply {
 		} else {
 			in.Endtime += " 00:00:00"
 		}
-		args = append(args, in.Endtime)
+		sqlAppendArgs = append(sqlAppendArgs, in.Endtime)
 	}
 	if in.Name != "" {
 		sqlAppend1 += ` and a.company_name like ?`
-		args = append(args, "%"+in.Name+"%")
+		sqlAppendArgs = append(sqlAppendArgs, "%"+in.Name+"%")
 	}
 	var count int64
 	start := (in.Current_page - 1) * in.Page_size
 	end := start + in.Page_size
 	dbPaging := in.Buyercount_start == 0 && in.Buyercount_end == 0 && in.Monitor == 0 && in.Monitorcount_start == 0 && in.Monitorcount_end == 0 && in.Project_matchme == 0 && in.Order_amount == 0
+	args := []interface{}{in.PositionId, in.PositionId, in.PositionId}
+	args = append(args, sqlAppendArgs...)
 	sqlAppend2 := ""
 	if dbPaging {
-		count = CrmMysql.CountBySql(`select count(1) as count from crm.connection a where a.position_id=?`+sqlAppend1, args...)
+		newArgs := []interface{}{in.PositionId}
+		newArgs = append(newArgs, sqlAppendArgs...)
+		count = CrmMysql.CountBySql(`select count(1) as count from crm.connection a where a.position_id=?`+sqlAppend1, newArgs...)
 		sqlAppend2 = ` limit ?,?`
 		args = append(args, start, end)
 	}

+ 2 - 2
api/internal/service/network_test.go

@@ -111,14 +111,14 @@ func TestNetWorkList(t *testing.T) {
 		Page_size:    10,
 		//PositionId: 935,
 		//PositionId: 1205591998,
-		Order_amount: -1,
+		//Order_amount: -1,
 		// Monitorcount_start: 1,
 		// Monitorcount_end:   1,
 		//Monitor:      0,
 		//Project_matchme: 1,
 		//Starttime: "2024-04-23",
 		//Endtime:   "2024-04-23",
-		Type: "middleman",
+		//Type: "middleman",
 		//Name: "三亚市",
 	})
 	for k, v := range res.Data.(map[string]interface{}) {