|
|
@@ -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) |
|
|
|