This commit is contained in:
parent
609fe56f75
commit
90d03a07bc
|
|
@ -10,7 +10,7 @@ type OrderRepo interface {
|
||||||
FindInBatches(ctx context.Context, w *bo.FindInBatchesUseBo, fun func(ctx context.Context, rows []*bo.OrderBo) error) error
|
FindInBatches(ctx context.Context, w *bo.FindInBatchesUseBo, fun func(ctx context.Context, rows []*bo.OrderBo) error) error
|
||||||
GetByOutBizNo(ctx context.Context, t vo.OrderType, outBizNo string) (*bo.OrderBo, error)
|
GetByOutBizNo(ctx context.Context, t vo.OrderType, outBizNo string) (*bo.OrderBo, error)
|
||||||
GetByOrderNo(ctx context.Context, orderNo string) (*bo.OrderBo, error)
|
GetByOrderNo(ctx context.Context, orderNo string) (*bo.OrderBo, error)
|
||||||
GetByMBV(ctx context.Context, merchantNo, batchNo, voucherNo string) (*bo.OrderBo, error)
|
GetByVoucherNo(ctx context.Context, merchantNo, batchNo, voucherNo string) (*bo.OrderBo, error)
|
||||||
Create(ctx context.Context, req *bo.OrderBo) (*bo.OrderBo, error)
|
Create(ctx context.Context, req *bo.OrderBo) (*bo.OrderBo, error)
|
||||||
GetByID(ctx context.Context, id uint64) (*bo.OrderBo, error)
|
GetByID(ctx context.Context, id uint64) (*bo.OrderBo, error)
|
||||||
Ing(ctx context.Context, id uint64) error
|
Ing(ctx context.Context, id uint64) error
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ func (v *VoucherBiz) WechatNotifyConsumer(ctx context.Context, tag string, req *
|
||||||
|
|
||||||
return lock.NewMutex(v.rdb.Rdb, c.TTL).Lock(ctx, c.Key, func(ctx context.Context) error {
|
return lock.NewMutex(v.rdb.Rdb, c.TTL).Lock(ctx, c.Key, func(ctx context.Context) error {
|
||||||
|
|
||||||
order, err := v.OrderRepo.GetByMBV(ctx, req.PlainText.StockCreatorMchid, req.PlainText.StockID, req.PlainText.CouponID)
|
order, err := v.OrderRepo.GetByVoucherNo(ctx, req.PlainText.StockCreatorMchid, req.PlainText.StockID, req.PlainText.CouponID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,10 @@ func (p *OrderRepoImpl) GetByOutBizNo(ctx context.Context, t vo.OrderType, outBi
|
||||||
log.Warnf("order当前打开连接数:%d,空闲连接数:%d", sqlDB.Stats().OpenConnections, sqlDB.Stats().Idle)
|
log.Warnf("order当前打开连接数:%d,空闲连接数:%d", sqlDB.Stats().OpenConnections, sqlDB.Stats().Idle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if errors.Is(tx.Error, gorm.ErrRecordNotFound) {
|
||||||
|
return nil, err2.ErrorDbNotFound("订单数据不存在")
|
||||||
|
}
|
||||||
|
|
||||||
return nil, fmt.Errorf("order db fail %w", tx.Error)
|
return nil, fmt.Errorf("order db fail %w", tx.Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,6 +116,9 @@ func (p *OrderRepoImpl) GetByID(ctx context.Context, id uint64) (*bo.OrderBo, er
|
||||||
tx := p.DB(ctx).Where(model.Order{ID: id}).First(&info)
|
tx := p.DB(ctx).Where(model.Order{ID: id}).First(&info)
|
||||||
|
|
||||||
if tx.Error != nil {
|
if tx.Error != nil {
|
||||||
|
if errors.Is(tx.Error, gorm.ErrRecordNotFound) {
|
||||||
|
return nil, err2.ErrorDbNotFound("订单数据不存在")
|
||||||
|
}
|
||||||
return nil, fmt.Errorf("order db fail %w", tx.Error)
|
return nil, fmt.Errorf("order db fail %w", tx.Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,6 +135,9 @@ func (p *OrderRepoImpl) GetByOrderNo(ctx context.Context, orderNo string) (*bo.O
|
||||||
tx := p.DB(ctx).Where(model.Order{OrderNo: orderNo}).First(&info)
|
tx := p.DB(ctx).Where(model.Order{OrderNo: orderNo}).First(&info)
|
||||||
|
|
||||||
if tx.Error != nil {
|
if tx.Error != nil {
|
||||||
|
if errors.Is(tx.Error, gorm.ErrRecordNotFound) {
|
||||||
|
return nil, err2.ErrorDbNotFound("订单数据不存在")
|
||||||
|
}
|
||||||
return nil, fmt.Errorf("order db fail %w", tx.Error)
|
return nil, fmt.Errorf("order db fail %w", tx.Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,12 +148,15 @@ func (p *OrderRepoImpl) GetByOrderNo(ctx context.Context, orderNo string) (*bo.O
|
||||||
return p.ToBo(info), nil
|
return p.ToBo(info), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *OrderRepoImpl) GetByMBV(ctx context.Context, merchantNo, batchNo, voucherNo string) (*bo.OrderBo, error) {
|
func (p *OrderRepoImpl) GetByVoucherNo(ctx context.Context, merchantNo, batchNo, voucherNo string) (*bo.OrderBo, error) {
|
||||||
info := &model.Order{}
|
info := &model.Order{}
|
||||||
|
|
||||||
tx := p.DB(ctx).Where(model.Order{MerchantNo: merchantNo, BatchNo: batchNo, VoucherNo: voucherNo}).First(&info)
|
tx := p.DB(ctx).Where(model.Order{MerchantNo: merchantNo, BatchNo: batchNo, VoucherNo: voucherNo}).First(&info)
|
||||||
|
|
||||||
if tx.Error != nil {
|
if tx.Error != nil {
|
||||||
|
if errors.Is(tx.Error, gorm.ErrRecordNotFound) {
|
||||||
|
return nil, err2.ErrorDbNotFound("订单数据不存在")
|
||||||
|
}
|
||||||
return nil, fmt.Errorf("db fail %w", tx.Error)
|
return nil, fmt.Errorf("db fail %w", tx.Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package repoimpl
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-kratos/kratos/v2/log"
|
"github.com/go-kratos/kratos/v2/log"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
|
|
@ -88,6 +89,10 @@ func (r *ProductRepoImpl) getByProductNo(ctx context.Context, item *model.Produc
|
||||||
tx := db.Where(model.Product{ProductNo: productNo}).First(&item)
|
tx := db.Where(model.Product{ProductNo: productNo}).First(&item)
|
||||||
|
|
||||||
if tx.Error != nil {
|
if tx.Error != nil {
|
||||||
|
if errors.Is(tx.Error, gorm.ErrRecordNotFound) {
|
||||||
|
return nil, err2.ErrorDbNotFound("商品数据不存在")
|
||||||
|
}
|
||||||
|
|
||||||
sqlDB, _ := db.DB()
|
sqlDB, _ := db.DB()
|
||||||
log.Warnf("product当前打开连接数:%d,空闲连接数:%d", sqlDB.Stats().OpenConnections, sqlDB.Stats().Idle)
|
log.Warnf("product当前打开连接数:%d,空闲连接数:%d", sqlDB.Stats().OpenConnections, sqlDB.Stats().Idle)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue