Browse Source

add search

animeic 1 year ago
parent
commit
65d9d5be83
4 changed files with 15 additions and 0 deletions
  1. 4 0
      boxcost/api/bill-produce.go
  2. 4 0
      boxcost/api/bill-product.go
  3. 5 0
      boxcost/api/bill.go
  4. 2 0
      boxcost/api/plan.go

+ 4 - 0
boxcost/api/bill-produce.go

@@ -179,6 +179,10 @@ func GetProduceBills(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 		start, end := getTimeRange(startTime, endTime)
 		query["createTime"] = bson.M{"$gte": start, "$lte": end}
 	}
+	if productName, ok := query["productName"]; ok {
+		delete(query, "productName")
+		query["productName"] = bson.M{"$regex": productName.(string)}
+	}
 
 	option := &repo.PageSearchOptions{
 		CollectName: repo.CollectionBillProduce,

+ 4 - 0
boxcost/api/bill-product.go

@@ -179,6 +179,10 @@ func GetProductBills(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 		start, end := getTimeRange(startTime, endTime)
 		query["createTime"] = bson.M{"$gte": start, "$lte": end}
 	}
+	if productName, ok := query["productName"]; ok {
+		delete(query, "productName")
+		query["productName"] = bson.M{"$regex": productName.(string)}
+	}
 
 	option := &repo.PageSearchOptions{
 		CollectName: repo.CollectionBillProduct,

+ 5 - 0
boxcost/api/bill.go

@@ -188,6 +188,11 @@ func GetBills(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 		query["createTime"] = bson.M{"$gte": start, "$lte": end}
 	}
 
+	if productName, ok := query["productName"]; ok {
+		delete(query, "productName")
+		query["productName"] = bson.M{"$regex": productName.(string)}
+	}
+
 	option := &repo.PageSearchOptions{
 		CollectName: repo.CollectionBillPurchase,
 		Query:       query,

+ 2 - 0
boxcost/api/plan.go

@@ -1090,6 +1090,8 @@ func GetProductPlan(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 						})
 						if ok {
 							billData[stage.BillId] = state
+
+							// TODO 订单数据合并到billData中,修改上线时删除下面的代码。
 							billStates[stage.BillId] = state["status"].(string)
 							billSerialNumber[stage.BillId] = state["serialNumber"].(string)
 							if v, ok := state["sendTo"]; ok {