浏览代码

更新

master
huangjiajun 5 个月前
父节点
当前提交
7229d99f6d
共有 1 个文件被更改,包括 38 次插入32 次删除
  1. +38
    -32
      app/admin/svc/order/svc_order_list.go

+ 38
- 32
app/admin/svc/order/svc_order_list.go 查看文件

@@ -1597,42 +1597,19 @@ func OrderDeductNum(c *gin.Context) {
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
return
}
if all1.WaitMakeNum < num {
//不够的话就看分拣区有没有 扣掉分拣区的
if all1.WaitSortingNum < num {
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
_, 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
newNum := num
if all1.WaitMakeNum > 0 {
leave := all1.WaitMakeNum - num
deNum := num
if leave < 0 {
deNum = all1.WaitMakeNum
}
all1.WaitMakeNum -= deNum
newNum -= deNum
all := all1
all.Id = 0
all.WaitBakingNum = 0
all.WaitMakeNum = num
all.WaitMakeNum = deNum
all.WaitSortingNum = 0
all.GoodsTitle = orderGoods1.GoodsTitle
all.GoodsType = 2
@@ -1643,6 +1620,35 @@ func OrderDeductNum(c *gin.Context) {
return
}
}
if newNum > 0 && all1.WaitSortingNum > 0 {
leave := all1.WaitSortingNum - num
deNum := num
if leave < 0 {
deNum = all1.WaitSortingNum
}
newNum -= deNum
all1.WaitSortingNum -= deNum
}
if newNum > 0 && all1.WaitBakingNum > 0 {
leave := all1.WaitBakingNum - num
deNum := num
if leave < 0 {
deNum = all1.WaitBakingNum
}
newNum -= deNum
all1.WaitBakingNum -= deNum
}
if newNum > 0 {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "数量不足,减少数量失败"))
return
}
_, err = sess.Where("id=?", all1.Id).Cols("wait_make_num,wait_sorting_num,wait_baking_num").Update(all1)
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`


正在加载...
取消
保存