Browse Source

fix:bug

dev
Tooooommy 4 years ago
parent
commit
4b05f91f6c
  1. 2
      controllers/client/good.go
  2. 2
      models/customer_order_sub.go

2
controllers/client/good.go

@ -196,7 +196,7 @@ func (t *GoodCtl) Order() {
// 检测库存 // 检测库存
for _, good := range goods { for _, good := range goods {
for _, g := range param.Goods { for _, g := range param.Goods {
if good.Id == int(g["id"]) {
if good.Id == g["id"] {
if good.Stock-g["num"] < 0 { if good.Stock-g["num"] < 0 {
session.Rollback() session.Rollback()
t.ERROR("商品库存不足", code.MSG_DATA_NOT_EXIST) t.ERROR("商品库存不足", code.MSG_DATA_NOT_EXIST)

2
models/customer_order_sub.go

@ -72,7 +72,7 @@ type OrderGoodNum struct {
func GetSubOrderGoodNumByGoodIds(goodIds interface{}) (res []*OrderGoodNum, err error) { func GetSubOrderGoodNumByGoodIds(goodIds interface{}) (res []*OrderGoodNum, err error) {
err = core.GetXormAuto().Table(&CustomerOrderSub{}).Alias("s").Select("s.goods_id, SUM(s.goods_num) as goods_num"). err = core.GetXormAuto().Table(&CustomerOrderSub{}).Alias("s").Select("s.goods_id, SUM(s.goods_num) as goods_num").
Join("left", (&CustomerOrder{}).TableName()+" as o", "o.id=s.order_id"). Join("left", (&CustomerOrder{}).TableName()+" as o", "o.id=s.order_id").
Where("o.is_delete=0 and s.is_delete=0").In("s.goods_id", goodIds).
Where("o.is_delete=0 and s.is_delete=0 and o.type=0").In("s.goods_id", goodIds).
NotIn("o.status", "0", "8", "9").Find(&res) NotIn("o.status", "0", "8", "9").Find(&res)
return return
} }
Loading…
Cancel
Save