diff --git a/models/customer_order_sub.go b/models/customer_order_sub.go index 1f239c5..c41257c 100644 --- a/models/customer_order_sub.go +++ b/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 } diff --git a/services/pay/handle.go b/services/pay/handle.go index 8505728..ca2536a 100644 --- a/services/pay/handle.go +++ b/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 }) }