From 20e77a74ca034ec05bd85e1220ca21e130fba818 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 13 Jun 2024 14:44:25 +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 | 30 ++++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/app/admin/svc/order/svc_order_list.go b/app/admin/svc/order/svc_order_list.go index 87f1a4b..489ed54 100644 --- a/app/admin/svc/order/svc_order_list.go +++ b/app/admin/svc/order/svc_order_list.go @@ -1600,16 +1600,26 @@ func OrderDeductNum(c *gin.Context) { if all1.WaitMakeNum < num { //不够的话就看分拣区有没有 扣掉分拣区的 if all1.WaitSortingNum < num { - sess.Rollback() - e.OutErr(c, 400, e.NewErr(400, "制作区或分拣区数量不足,减少数量失败")) - return - } - all1.WaitSortingNum -= num - _, err = sess.Where("id=?", all1.Id).Cols("wait_sorting_num").Update(all1) - if err != nil { - sess.Rollback() - e.OutErr(c, 400, e.NewErr(400, "修改失败")) - return + if all1.WaitBakingNum < num { + sess.Rollback() + e.OutErr(c, 400, e.NewErr(400, "数量不足,减少数量失败")) + return + } + all1.WaitBakingNum -= num + _, err = sess.Where("id=?", all1.Id).Cols("wait_baking_num").Update(all1) + if err != nil { + sess.Rollback() + e.OutErr(c, 400, e.NewErr(400, "修改失败")) + return + } + } else { + all1.WaitSortingNum -= num + _, err = sess.Where("id=?", all1.Id).Cols("wait_sorting_num").Update(all1) + if err != nil { + sess.Rollback() + e.OutErr(c, 400, e.NewErr(400, "修改失败")) + return + } } } else { all1.WaitMakeNum -= num