sun-pc 2 months ago
parent
commit
10df0b2fb8
5 changed files with 8 additions and 10 deletions
  1. 2 2
      boxcost/api/bill-produce.go
  2. 1 2
      boxcost/api/bill-product.go
  3. 1 2
      boxcost/api/bill.go
  4. 2 2
      boxcost/api/plan.go
  5. 2 2
      boxcost/api/stages.go

+ 2 - 2
boxcost/api/bill-produce.go

@@ -288,8 +288,8 @@ func UpdateProduceBill(c *gin.Context, apictx *ApiSession) (interface{}, error)
 				DeliveryTime:   produce.DeliveryTime,
 			}
 		}
-		db := apictx.Svc.Mongo.GetCollection(repo.CollectionBillProduce)
-		_, err := updateBilltoStage(c, bill.PlanId, idStatges, apictx, db)
+
+		_, err := updateBilltoStage(c, bill.PlanId, idStatges, apictx)
 		if err != nil {
 			fmt.Println(err)
 			return nil, errors.New("该单据改动同步到产品失败")

+ 1 - 2
boxcost/api/bill-product.go

@@ -278,8 +278,7 @@ func UpdateProductBill(c *gin.Context, apictx *ApiSession) (interface{}, error)
 				DeliveryTime: product.DeliveryTime,
 			}
 		}
-		db := apictx.Svc.Mongo.GetCollection(repo.CollectionBillProduct)
-		_, err := updateBilltoStage(c, bill.PlanId, idStatges, apictx, db)
+		_, err := updateBilltoStage(c, bill.PlanId, idStatges, apictx)
 		if err != nil {
 			fmt.Println(err)
 			return nil, errors.New("该单据改动同步到产品失败")

+ 1 - 2
boxcost/api/bill.go

@@ -419,8 +419,7 @@ func UpdateBill(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 				IsChangePrice2: isInclude(paper.Price2Unit, units),
 			}
 		}
-		db := apictx.Svc.Mongo.GetCollection(repo.CollectionBillPurchase)
-		_, err := updateBilltoStage(c, bill.PlanId, idStatges, apictx, db)
+		_, err := updateBilltoStage(c, bill.PlanId, idStatges, apictx)
 		if err != nil {
 			fmt.Println(err)
 			return nil, errors.New("该单据改动同步到产品失败")

+ 2 - 2
boxcost/api/plan.go

@@ -20,7 +20,6 @@ import (
 	"github.com/xuri/excelize/v2"
 	"go.mongodb.org/mongo-driver/bson"
 	"go.mongodb.org/mongo-driver/bson/primitive"
-	"go.mongodb.org/mongo-driver/mongo"
 )
 
 // TODO 下载代码重复提取
@@ -184,7 +183,7 @@ type UpdateBilltoStageReq struct {
 }
 
 // 更新供应商确定数量与plan中stage项的同步
-func updateBilltoStage(c *gin.Context, planId primitive.ObjectID, idStatges map[string]*UpdateBilltoStageReq, apictx *ApiSession, db *mongo.Collection) (interface{}, error) {
+func updateBilltoStage(c *gin.Context, planId primitive.ObjectID, idStatges map[string]*UpdateBilltoStageReq, apictx *ApiSession) (interface{}, error) {
 	if len(idStatges) == 0 {
 		return true, nil
 	}
@@ -230,6 +229,7 @@ func updateBilltoStage(c *gin.Context, planId primitive.ObjectID, idStatges map[
 					StageId: stage.Id,
 					Stages:  []*model.ComponentStage{stage},
 				}
+				db := apictx.Svc.Mongo.GetCollection(repo.CollectionProductPlan)
 				_, err = updateStage(c, db, &req)
 				if err != nil {
 					return nil, err

+ 2 - 2
boxcost/api/stages.go

@@ -180,9 +180,9 @@ func DeleteStage(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	return result, nil
 }
 
-// 根据planId packId compentId stageId定位到到计划中的stage
+// 根据planId compentId stageId定位到到计划中的stage
 // 注意更新计划价格 组件价格
-// 根据planId packId compentId stageId定位到到计划中的stage
+// 根据planId compentId stageId定位到到计划中的stage
 // 注意更新计划价格 组件价格
 func updateStage(c *gin.Context, db *mongo.Collection, req *StageRequest) (interface{}, error) {
 	if len(req.PlanId) == 0 || len(req.CompId) == 0 || len(req.StageId) == 0 {