|
@@ -1598,29 +1598,40 @@ func OrderDeductNum(c *gin.Context) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
if all1.WaitMakeNum < num { |
|
|
if all1.WaitMakeNum < num { |
|
|
sess.Rollback() |
|
|
|
|
|
e.OutErr(c, 400, e.NewErr(400, "订单已经在制作,减少数量失败")) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
all1.WaitMakeNum -= num |
|
|
|
|
|
_, err = sess.Where("id=?", all1.Id).Cols("wait_make_num").Update(all1) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
sess.Rollback() |
|
|
|
|
|
e.OutErr(c, 400, e.NewErr(400, "修改失败")) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
all := all1 |
|
|
|
|
|
all.Id = 0 |
|
|
|
|
|
all.WaitBakingNum = 0 |
|
|
|
|
|
all.WaitMakeNum = num |
|
|
|
|
|
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 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 |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
all1.WaitMakeNum -= num |
|
|
|
|
|
_, err = sess.Where("id=?", all1.Id).Cols("wait_make_num").Update(all1) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
sess.Rollback() |
|
|
|
|
|
e.OutErr(c, 400, e.NewErr(400, "修改失败")) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
all := all1 |
|
|
|
|
|
all.Id = 0 |
|
|
|
|
|
all.WaitBakingNum = 0 |
|
|
|
|
|
all.WaitMakeNum = num |
|
|
|
|
|
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)) |
|
|
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) - float64(num)*utils.StrToFloat64(orderGoods1.Price)) |
|
|
//销量减少 |
|
|
//销量减少 |
|
|