|
@@ -725,21 +725,21 @@ func OrderEditNum(c *gin.Context) { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
num = orderGoods.Num - utils.StrToInt(args["num"]) |
|
|
num = orderGoods.Num - utils.StrToInt(args["num"]) |
|
|
all.WaitBakingNum -= orderGoods.Num |
|
|
|
|
|
|
|
|
all.WaitMakeNum -= orderGoods.Num |
|
|
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) - float64(num)*utils.StrToFloat64(orderGoods.Price)) |
|
|
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) - float64(num)*utils.StrToFloat64(orderGoods.Price)) |
|
|
//销量扣除 |
|
|
//销量扣除 |
|
|
sqlSecond := `UPDATE goods SET sale=sale-%d WHERE id=%d` |
|
|
sqlSecond := `UPDATE goods SET sale=sale-%d WHERE id=%d` |
|
|
sqlSecond = fmt.Sprintf(sqlSecond, num, orderGoods.GoodsId) |
|
|
sqlSecond = fmt.Sprintf(sqlSecond, num, orderGoods.GoodsId) |
|
|
db.QueryNativeStringSess(sess, sqlSecond) |
|
|
db.QueryNativeStringSess(sess, sqlSecond) |
|
|
} else { |
|
|
} else { |
|
|
all.WaitBakingNum += orderGoods.Num |
|
|
|
|
|
|
|
|
all.WaitMakeNum += orderGoods.Num |
|
|
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) + float64(num)*utils.StrToFloat64(orderGoods.Price)) |
|
|
order.Amount = utils.Float64ToStr(utils.StrToFloat64(order.Amount) + float64(num)*utils.StrToFloat64(orderGoods.Price)) |
|
|
//销量增加 |
|
|
//销量增加 |
|
|
sqlSecond := `UPDATE goods SET sale=sale+%d WHERE id=%d` |
|
|
sqlSecond := `UPDATE goods SET sale=sale+%d WHERE id=%d` |
|
|
sqlSecond = fmt.Sprintf(sqlSecond, num, orderGoods.GoodsId) |
|
|
sqlSecond = fmt.Sprintf(sqlSecond, num, orderGoods.GoodsId) |
|
|
db.QueryNativeStringSess(sess, sqlSecond) |
|
|
db.QueryNativeStringSess(sess, sqlSecond) |
|
|
} |
|
|
} |
|
|
_, err := sess.Where("id=?", all.Id).Cols("wait_baking_num").Update(all) |
|
|
|
|
|
|
|
|
_, err := sess.Where("id=?", all.Id).Cols("wait_make_num").Update(all) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
sess.Rollback() |
|
|
sess.Rollback() |
|
|
e.OutErr(c, 400, e.NewErr(400, "修改失败")) |
|
|
e.OutErr(c, 400, e.NewErr(400, "修改失败")) |
|
|