animeic 1 年之前
父節點
當前提交
89762ea44d
共有 1 個文件被更改,包括 27 次插入6 次删除
  1. 27 6
      boxcost/api/summary.go

+ 27 - 6
boxcost/api/summary.go

@@ -44,6 +44,19 @@ type PlanSummary struct {
 	SendTo       map[string]string
 }
 
+type PlanSimple struct {
+	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
+	Name       string             `bson:"name,omitempty" json:"name"`
+	CreateUser string             `bson:"createUser,omitempty" json:"createUser"`
+	//生产数量
+	Total int `bson:"total,omitempty" json:"total"`
+	//状态
+	Status string `bson:"status,omitempty" json:"status"`
+	//总价
+	TotalPrice float64   `bson:"totalPrice,omitempty" json:"totalPrice"`
+	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
+}
+
 func SummarySupplierPlan(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	_, _, query := UtilQueryPageSize(c)
 	supplierId := primitive.NilObjectID
@@ -65,21 +78,29 @@ func SummarySupplierPlan(c *gin.Context, apictx *ApiSession) (interface{}, error
 	err := repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
 		CollectName: repo.CollectionProductPlan,
 		Query:       query,
-		Project:     []string{"_id", "pack"},
 		Sort:        bson.M{"createTime": -1},
 	}, &plans)
 	if err != nil {
 		log.Error(err)
 		return nil, errors.New("查询数据错误!")
 	}
-	planIds := []primitive.ObjectID{}
+	planSimples := []*PlanSimple{}
 	if len(plans) < 1 {
-		return planIds, nil
+		return planSimples, nil
 	}
 	// 遍历
 
 	flag := false
 	for _, plan := range plans {
+		ps := &PlanSimple{
+			Id:         plan.Id,
+			Name:       plan.Name,
+			CreateUser: plan.CreateUser,
+			Total:      plan.Total,
+			Status:     plan.Status,
+			TotalPrice: plan.TotalPrice,
+			CreateTime: plan.CreateTime,
+		}
 		// 选供应商
 		if !supplierId.IsZero() {
 			for _, comp := range plan.Pack.Components {
@@ -92,7 +113,7 @@ func SummarySupplierPlan(c *gin.Context, apictx *ApiSession) (interface{}, error
 						continue
 					}
 					if stage.SupplierInfo.Id == supplierId {
-						planIds = append(planIds, plan.Id)
+						planSimples = append(planSimples, ps)
 						flag = true
 						break
 					}
@@ -103,14 +124,14 @@ func SummarySupplierPlan(c *gin.Context, apictx *ApiSession) (interface{}, error
 			}
 
 		} else {
-			planIds = append(planIds, plan.Id)
+			planSimples = append(planSimples, ps)
 		}
 		if flag {
 			continue
 		}
 	}
 
-	return planIds, nil
+	return planSimples, nil
 }
 
 // /summary/download?planIds=id1,id2&supplierId=xxx