Browse Source

fix:bug

dev
Tooooommy 4 years ago
parent
commit
2fb19b497f
  1. 4
      models/customer_order_sub.go
  2. 34
      services/pay/handle.go

4
models/customer_order_sub.go

@ -77,7 +77,7 @@ func GetSubOrderGoodNum(goodIds interface{}) (res []*OrderGoodNum, err error) {
func GetSubOrderGoodNumBySession(s *xorm.Session, goodIds interface{}) (res []*OrderGoodNum, err error) {
err = s.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").
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)
Where("o.is_delete=0 and s.is_delete=0").In("s.goods_id", goodIds).
NotIn("o.status", "0", "6", "8", "9").GroupBy("s.goods_id").Find(&res)
return
}

34
services/pay/handle.go

@ -208,16 +208,16 @@ func HandleGoodOrder() error {
}
}
subs, err := models.GetSubOrdersByOrderId(v.Id)
if err != nil {
return err
}
for _, sub := range subs {
_, err = new(models.CustomerGoods).IncrStockById(sub.GoodsId, sub.GoodsNum)
if err != nil {
return err
}
}
//subs, err := models.GetSubOrdersByOrderId(v.Id)
//if err != nil {
// return err
//}
//for _, sub := range subs {
// _, err = new(models.CustomerGoods).IncrStockById(sub.GoodsId, sub.GoodsNum)
// if err != nil {
// return err
// }
//}
}
return nil
}
@ -267,13 +267,13 @@ func HandleCancelOrder(outTradeNo string) error {
if err != nil {
return err
}
for _, sub := range subs {
_, err = session.ID(sub.GoodsId).NoAutoCondition().Incr("stock", sub.GoodsNum).
Update(&models.CustomerGoods{})
if err != nil {
return err
}
}
//for _, sub := range subs {
// _, err = session.ID(sub.GoodsId).NoAutoCondition().Incr("stock", sub.GoodsNum).
// Update(&models.CustomerGoods{})
// if err != nil {
// return err
// }
//}
return nil
})
}
Loading…
Cancel
Save