From c5bf5190e4ae6c8d6a3398b37e7483b9fd94c898 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 5 Jul 2024 10:55:34 +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 | 37 ++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/app/admin/svc/order/svc_order_list.go b/app/admin/svc/order/svc_order_list.go index 94cc125..8ec42fc 100644 --- a/app/admin/svc/order/svc_order_list.go +++ b/app/admin/svc/order/svc_order_list.go @@ -768,7 +768,8 @@ func OrderUpdateState(c *gin.Context) { e.OutErr(c, 400, e.NewErr(400, "订单不存在")) return } - sess1 := sess.Where("state!=5") + sess1 := sess + sess1.Where("state!=5") if args["ids"] != "" { sess1.In("oid", strings.Split(args["ids"], ",")) } @@ -778,15 +779,37 @@ func OrderUpdateState(c *gin.Context) { e.OutErr(c, 400, e.NewErr(400, "操作失败")) return } - sess2 := sess.Where("state!=5") + sess2 := sess + sess2.Where("state!=5") if args["ids"] != "" { sess2.In("oid", strings.Split(args["ids"], ",")) } - _, err = sess2.Cols("state").Update(&model.OrderGoods{State: 4}) - if err != nil { - sess.Rollback() - e.OutErr(c, 400, e.NewErr(400, "操作失败")) - return + goods := make([]model.OrderGoods, 0) + sess2.Find(&goods) + for _, v := range goods { + v.State = 4 + sess3 := sess + _, err = sess3.Where("id=?", v.Id).Cols("state").Update(&v) + if err != nil { + sess.Rollback() + e.OutErr(c, 400, e.NewErr(400, "操作失败")) + return + } + flow := make([]model.OrderGoodsMakeStock, 0) + sess4 := sess + + sess4.Where("sku_id=? and goods_id=? and make_date=?", v.SkuId, v.GoodsId, v.MakeDate).Find(&flow) + for _, v1 := range flow { + v1.SuccessNum = v1.WaitSortingNum + v1.WaitSortingNum = 0 + sess5 := sess + _, err = sess5.Where("id=?", v1.Id).Cols("success_num,wait_sorting_num").Update(&v1) + if err != nil { + sess.Rollback() + e.OutErr(c, 400, e.NewErr(400, "操作失败")) + return + } + } } sess.Commit() e.OutSuc(c, "success", nil)