Browse Source

修复计划价格为0时,更改数据不生效

suncloud 1 year ago
parent
commit
cea8f70ead
3 changed files with 6 additions and 3 deletions
  1. 4 1
      boxcost/api/plan.go
  2. 1 1
      boxcost/api/summary.go
  3. 1 1
      boxcost/db/model/plan.go

+ 4 - 1
boxcost/api/plan.go

@@ -1228,7 +1228,10 @@ func CreateProductPlan(c *gin.Context, apictx *ApiSession) (interface{}, error)
 	if plan.Total == 0 {
 		return nil, errors.New("生产计划数应不为0")
 	}
-
+	if plan.TotalPrice == nil {
+		var zero float64 = 0
+		plan.TotalPrice = &zero
+	}
 	plan.Status = "process" // 进行中
 	plan.CreateTime = time.Now()
 	plan.UpdateTime = time.Now()

+ 1 - 1
boxcost/api/summary.go

@@ -98,7 +98,7 @@ func SummarySupplierPlan(c *gin.Context, apictx *ApiSession) (interface{}, error
 			CreateUser: plan.CreateUser,
 			Total:      plan.Total,
 			Status:     plan.Status,
-			TotalPrice: plan.TotalPrice,
+			TotalPrice: *plan.TotalPrice,
 			CreateTime: plan.CreateTime,
 		}
 		// 选供应商

+ 1 - 1
boxcost/db/model/plan.go

@@ -22,7 +22,7 @@ type ProductPlan struct {
 	Status string `bson:"status,omitempty" json:"status"`
 
 	//总价
-	TotalPrice float64 `bson:"totalPrice,omitempty" json:"totalPrice"`
+	TotalPrice *float64 `bson:"totalPrice,omitempty" json:"totalPrice"`
 
 	UpdateTime time.Time `bson:"updteTime,omitempty" json:"updateTime"`