|
@@ -1598,6 +1598,7 @@ func OrderDeductNum(c *gin.Context) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
newNum := num |
|
|
newNum := num |
|
|
|
|
|
WaitMakeNum := 0 |
|
|
if all1.WaitMakeNum > 0 { |
|
|
if all1.WaitMakeNum > 0 { |
|
|
leave := all1.WaitMakeNum - num |
|
|
leave := all1.WaitMakeNum - num |
|
|
deNum := num |
|
|
deNum := num |
|
@@ -1606,19 +1607,8 @@ func OrderDeductNum(c *gin.Context) { |
|
|
} |
|
|
} |
|
|
all1.WaitMakeNum -= deNum |
|
|
all1.WaitMakeNum -= deNum |
|
|
newNum -= deNum |
|
|
newNum -= deNum |
|
|
all := all1 |
|
|
|
|
|
all.Id = 0 |
|
|
|
|
|
all.WaitBakingNum = 0 |
|
|
|
|
|
all.WaitMakeNum = deNum |
|
|
|
|
|
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 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
WaitMakeNum = deNum |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
if newNum > 0 && all1.WaitSortingNum > 0 { |
|
|
if newNum > 0 && all1.WaitSortingNum > 0 { |
|
|
leave := all1.WaitSortingNum - num |
|
|
leave := all1.WaitSortingNum - num |
|
@@ -1629,6 +1619,7 @@ func OrderDeductNum(c *gin.Context) { |
|
|
newNum -= deNum |
|
|
newNum -= deNum |
|
|
all1.WaitSortingNum -= deNum |
|
|
all1.WaitSortingNum -= deNum |
|
|
} |
|
|
} |
|
|
|
|
|
WaitBakingNum := 0 |
|
|
if newNum > 0 && all1.WaitBakingNum > 0 { |
|
|
if newNum > 0 && all1.WaitBakingNum > 0 { |
|
|
leave := all1.WaitBakingNum - num |
|
|
leave := all1.WaitBakingNum - num |
|
|
deNum := num |
|
|
deNum := num |
|
@@ -1637,6 +1628,7 @@ func OrderDeductNum(c *gin.Context) { |
|
|
} |
|
|
} |
|
|
newNum -= deNum |
|
|
newNum -= deNum |
|
|
all1.WaitBakingNum -= deNum |
|
|
all1.WaitBakingNum -= deNum |
|
|
|
|
|
WaitBakingNum = deNum |
|
|
} |
|
|
} |
|
|
if newNum > 0 { |
|
|
if newNum > 0 { |
|
|
sess.Rollback() |
|
|
sess.Rollback() |
|
@@ -1649,6 +1641,37 @@ func OrderDeductNum(c *gin.Context) { |
|
|
e.OutErr(c, 400, e.NewErr(400, "修改失败")) |
|
|
e.OutErr(c, 400, e.NewErr(400, "修改失败")) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
if WaitMakeNum > 0 { |
|
|
|
|
|
all := all1 |
|
|
|
|
|
all.Id = 0 |
|
|
|
|
|
all.WaitBakingNum = 0 |
|
|
|
|
|
all.WaitMakeNum = WaitMakeNum |
|
|
|
|
|
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 WaitBakingNum > 0 { |
|
|
|
|
|
all := all1 |
|
|
|
|
|
all.Id = 0 |
|
|
|
|
|
all.WaitBakingNum = WaitBakingNum |
|
|
|
|
|
all.WaitMakeNum = 0 |
|
|
|
|
|
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)) |
|
|
//销量减少 |
|
|
//销量减少 |
|
|
sqlSecond := `UPDATE goods SET sale=sale-%d WHERE id=%d` |
|
|
sqlSecond := `UPDATE goods SET sale=sale-%d WHERE id=%d` |
|
|