sun-pc-linux 8 months ago
parent
commit
f134da6591
3 changed files with 54 additions and 36 deletions
  1. 14 11
      boxcost/api/bill-produce.go
  2. 22 11
      boxcost/api/bill.go
  3. 18 14
      boxcost/api/plan.go

+ 14 - 11
boxcost/api/bill-produce.go

@@ -249,6 +249,7 @@ func UpdateProduceBill(c *gin.Context, apictx *ApiSession) (interface{}, error)
 				Query:       repo.Map{"_id": bill.SupplierId},
 			}, supplierInfo)
 		}
+
 		idStatges := make(map[string]*UpdateBilltoStageReq)
 		for _, produce := range bill.Produces {
 			if len(produce.Id) == 0 {
@@ -261,18 +262,20 @@ func UpdateProduceBill(c *gin.Context, apictx *ApiSession) (interface{}, error)
 				height, _ = strconv.Atoi(ps[0])
 				width, _ = strconv.Atoi(ps[1])
 			}
+
 			idStatges[produce.Id] = &UpdateBilltoStageReq{
-				BillType:     "produce",
-				SupplierInfo: supplierInfo,
-				Norm:         produce.Norm,
-				Price2:       produce.Price2,
-				OrderCount:   produce.OrderCount,
-				OrderPrice:   produce.OrderPrice,
-				ConfirmCount: produce.ConfirmCount,
-				Remark:       produce.Remark,
-				Width:        width,
-				Height:       height,
-				DeliveryTime: produce.DeliveryTime,
+				BillType:       "produce",
+				IsChangePrice2: bill.IsLam,
+				SupplierInfo:   supplierInfo,
+				Norm:           produce.Norm,
+				Price2:         produce.Price2,
+				OrderCount:     produce.OrderCount,
+				OrderPrice:     produce.OrderPrice,
+				ConfirmCount:   produce.ConfirmCount,
+				Remark:         produce.Remark,
+				Width:          width,
+				Height:         height,
+				DeliveryTime:   produce.DeliveryTime,
 			}
 		}
 		_, err := updateBilltoStage(c, bill.PlanId, idStatges, apictx)

+ 22 - 11
boxcost/api/bill.go

@@ -385,6 +385,7 @@ func UpdateBill(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 				Query:       repo.Map{"_id": bill.SupplierId},
 			}, supplierInfo)
 		}
+		units := []string{"元/吨", "元/平方米"}
 		idStatges := make(map[string]*UpdateBilltoStageReq)
 		for _, paper := range bill.Paper {
 			if len(paper.Id) == 0 {
@@ -393,17 +394,18 @@ func UpdateBill(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 			width, _ := strconv.Atoi(paper.Width)
 			Height, _ := strconv.Atoi(paper.Height)
 			idStatges[paper.Id] = &UpdateBilltoStageReq{
-				BillType:     "purchase",
-				SupplierInfo: supplierInfo,
-				Norm:         paper.Norm,
-				Width:        width,
-				Height:       Height,
-				Price2:       paper.Price2,
-				OrderCount:   paper.OrderCount,
-				OrderPrice:   paper.OrderPrice,
-				Remark:       paper.Remark,
-				ConfirmCount: paper.ConfirmCount,
-				DeliveryTime: paper.DeliveryTime,
+				BillType:       "purchase",
+				SupplierInfo:   supplierInfo,
+				Norm:           paper.Norm,
+				Width:          width,
+				Height:         Height,
+				Price2:         paper.Price2,
+				OrderCount:     paper.OrderCount,
+				OrderPrice:     paper.OrderPrice,
+				Remark:         paper.Remark,
+				ConfirmCount:   paper.ConfirmCount,
+				DeliveryTime:   paper.DeliveryTime,
+				IsChangePrice2: isInclude(paper.Price2Unit, units),
 			}
 		}
 		_, err := updateBilltoStage(c, bill.PlanId, idStatges, apictx)
@@ -423,6 +425,15 @@ func UpdateBill(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	})
 }
 
+func isInclude(str1 string, arr []string) bool {
+	for _, a := range arr {
+		if str1 == a {
+			return true
+		}
+	}
+	return false
+}
+
 // 删除单据
 func DelBill(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	billId := c.Param("id")

+ 18 - 14
boxcost/api/plan.go

@@ -165,19 +165,20 @@ func PlanAllocBatch(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 }
 
 type UpdateBilltoStageReq struct {
-	BillType     string
-	SupplierInfo *model.Supplier
-	Norm         string
-	Width        int
-	Height       int
-	Price2       float64
-	OrderCount   int
-	OrderPrice   float64
-	Remark       string
-	ConfirmCount int
-	DeliveryTime time.Time
-	PrintSize    string
-	Size         string
+	BillType       string
+	SupplierInfo   *model.Supplier
+	Norm           string
+	Width          int
+	Height         int
+	Price2         float64
+	OrderCount     int
+	OrderPrice     float64
+	Remark         string
+	ConfirmCount   int
+	DeliveryTime   time.Time
+	PrintSize      string
+	Size           string
+	IsChangePrice2 bool
 }
 
 // 更新供应商确定数量与plan中stage项的同步
@@ -204,10 +205,13 @@ func updateBilltoStage(c *gin.Context, planId primitive.ObjectID, idStatges map[
 				if idStatge.SupplierInfo != nil {
 					stage.SupplierInfo = idStatge.SupplierInfo
 				}
+				if idStatge.IsChangePrice2 {
+					stage.Price = idStatge.Price2
+				}
+
 				stage.Norm = idStatge.Norm
 				stage.BatchSizeWidth = idStatge.Width
 				stage.BatchSizeHeight = idStatge.Height
-				stage.Price = idStatge.Price2
 				stage.OrderCount = idStatge.OrderCount
 				stage.OrderPrice = idStatge.OrderPrice
 				stage.Remark = idStatge.Remark