From 3e23e15896628e9d8774d83bef048eb4ba9c02f0 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 13 Jun 2024 15:36:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/svc/order/svc_order_list.go | 49 ++++++++++++++++++++------- app/bigData/svc/svc_making_data.go | 4 +++ 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/app/admin/svc/order/svc_order_list.go b/app/admin/svc/order/svc_order_list.go index dab631c..6009324 100644 --- a/app/admin/svc/order/svc_order_list.go +++ b/app/admin/svc/order/svc_order_list.go @@ -1598,6 +1598,7 @@ func OrderDeductNum(c *gin.Context) { return } newNum := num + WaitMakeNum := 0 if all1.WaitMakeNum > 0 { leave := all1.WaitMakeNum - num deNum := num @@ -1606,19 +1607,8 @@ func OrderDeductNum(c *gin.Context) { } all1.WaitMakeNum -= deNum newNum -= deNum - all := all1 - all.Id = 0 - all.WaitBakingNum = 0 - all.WaitMakeNum = deNum - all.WaitSortingNum = 0 - all.GoodsTitle = orderGoods1.GoodsTitle - all.GoodsType = 2 - _, err = sess.InsertOne(all) - if err != nil { - sess.Rollback() - e.OutErr(c, 400, e.NewErr(400, "修改失败")) - return - } + WaitMakeNum = deNum + } if newNum > 0 && all1.WaitSortingNum > 0 { leave := all1.WaitSortingNum - num @@ -1629,6 +1619,7 @@ func OrderDeductNum(c *gin.Context) { newNum -= deNum all1.WaitSortingNum -= deNum } + WaitBakingNum := 0 if newNum > 0 && all1.WaitBakingNum > 0 { leave := all1.WaitBakingNum - num deNum := num @@ -1637,6 +1628,7 @@ func OrderDeductNum(c *gin.Context) { } newNum -= deNum all1.WaitBakingNum -= deNum + WaitBakingNum = deNum } if newNum > 0 { sess.Rollback() @@ -1649,6 +1641,37 @@ func OrderDeductNum(c *gin.Context) { e.OutErr(c, 400, e.NewErr(400, "修改失败")) return } + if WaitMakeNum > 0 { + all := all1 + all.Id = 0 + all.WaitBakingNum = 0 + all.WaitMakeNum = WaitMakeNum + all.WaitSortingNum = 0 + all.GoodsTitle = orderGoods1.GoodsTitle + all.GoodsType = 2 + _, err = sess.InsertOne(all) + if err != nil { + sess.Rollback() + e.OutErr(c, 400, e.NewErr(400, "修改失败")) + return + } + } + if WaitBakingNum > 0 { + all := all1 + all.Id = 0 + all.WaitBakingNum = WaitBakingNum + all.WaitMakeNum = 0 + all.WaitSortingNum = 0 + all.GoodsTitle = orderGoods1.GoodsTitle + all.GoodsType = 2 + _, err = sess.InsertOne(all) + if err != nil { + sess.Rollback() + e.OutErr(c, 400, e.NewErr(400, "修改失败")) + return + } + } + order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) - float64(num)*utils.StrToFloat64(orderGoods1.Price)) //销量减少 sqlSecond := `UPDATE goods SET sale=sale-%d WHERE id=%d` diff --git a/app/bigData/svc/svc_making_data.go b/app/bigData/svc/svc_making_data.go index 93917ed..54879fd 100644 --- a/app/bigData/svc/svc_making_data.go +++ b/app/bigData/svc/svc_making_data.go @@ -52,6 +52,10 @@ func CommMakingData(c *gin.Context, args map[string]string) { tmp["state"] = "4" tmp["state_str"] = "烘焙完成" } + if v.GoodsType == 2 { + tmp["state"] = "4" + tmp["state_str"] = "无需烘焙" + } } if args["state"] == "3" { tmp["num"] = utils.IntToStr(v.WaitSortingNum)