animeic 2 years ago
parent
commit
616dd92bc5
3 changed files with 12 additions and 14 deletions
  1. 4 5
      boxcost/api/bill-produce.go
  2. 4 5
      boxcost/api/bill-product.go
  3. 4 4
      boxcost/api/bill.go

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

@@ -200,13 +200,12 @@ func UpdateProduceBill(c *gin.Context, apictx *ApiSession) (interface{}, error)
 		return nil, errors.New("id的为空")
 	}
 
-	billType, err := searchBillTypeById(apictx, repo.CollectionBillProduce, bill.Id)
-	if err != nil {
-		return nil, err
-	}
-
 	// 如果更改类型
 	if len(bill.Type) > 0 {
+		billType, err := searchBillTypeById(apictx, repo.CollectionBillPurchase, bill.Id)
+		if err != nil {
+			return nil, err
+		}
 		if billType != bill.Type {
 			bill.SerialNumber, err = generateSerial(apictx, bill.Type)
 			if err != nil {

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

@@ -200,13 +200,12 @@ func UpdateProductBill(c *gin.Context, apictx *ApiSession) (interface{}, error)
 		return nil, errors.New("id的为空")
 	}
 
-	billType, err := searchBillTypeById(apictx, repo.CollectionBillProduct, bill.Id)
-	if err != nil {
-		return nil, err
-	}
-
 	// 如果更改类型
 	if len(bill.Type) > 0 {
+		billType, err := searchBillTypeById(apictx, repo.CollectionBillPurchase, bill.Id)
+		if err != nil {
+			return nil, err
+		}
 		if billType != bill.Type {
 			bill.SerialNumber, err = generateSerial(apictx, bill.Type)
 			if err != nil {

+ 4 - 4
boxcost/api/bill.go

@@ -294,13 +294,13 @@ func UpdateBill(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	if bill.Id.Hex() == "" {
 		return nil, errors.New("id的为空")
 	}
-	billType, err := searchBillTypeById(apictx, repo.CollectionBillPurchase, bill.Id)
-	if err != nil {
-		return nil, err
-	}
 
 	// 如果更改类型
 	if len(bill.Type) > 0 {
+		billType, err := searchBillTypeById(apictx, repo.CollectionBillPurchase, bill.Id)
+		if err != nil {
+			return nil, err
+		}
 		if billType != bill.Type {
 			bill.SerialNumber, err = generateSerial(apictx, bill.Type)
 			if err != nil {