错误映射
This commit is contained in:
parent
bbfc91da57
commit
81c53823af
|
|
@ -10,11 +10,11 @@ import (
|
|||
"voucher/internal/biz/vo"
|
||||
)
|
||||
|
||||
func (this *VoucherBiz) CmbOrder(ctx context.Context, req *bo.OrderCreateReqBo) (*bo.OrderBo, error) {
|
||||
func (this *VoucherBiz) CmbOrder(ctx context.Context, req *bo.OrderCreateReqBo) (*bo.OrderBo, *bo.ProductBo, error) {
|
||||
|
||||
order, err3 := this.GetByOutBizNo(ctx, req)
|
||||
if err3 != nil {
|
||||
return nil, err3
|
||||
return nil, nil, err3
|
||||
}
|
||||
|
||||
if order != nil {
|
||||
|
|
@ -22,32 +22,32 @@ func (this *VoucherBiz) CmbOrder(ctx context.Context, req *bo.OrderCreateReqBo)
|
|||
if order.Status.IsFail() || order.Status.IsIng() {
|
||||
|
||||
if err4 := this.orderRetry(ctx, order); err4 != nil {
|
||||
return nil, err4
|
||||
return order, nil, err4
|
||||
}
|
||||
}
|
||||
|
||||
return order, nil
|
||||
return order, nil, nil
|
||||
}
|
||||
|
||||
product, err3 := this.ProductRepo.GetByProductNo(ctx, req.ProductNo)
|
||||
if err3 != nil {
|
||||
return nil, err3
|
||||
return nil, product, err3
|
||||
}
|
||||
|
||||
nowTime := time.Now()
|
||||
if nowTime.Before(*product.StartTime) {
|
||||
return nil, businesserr.BatchNotStartedError
|
||||
return nil, product, businesserr.BatchNotStartedError
|
||||
}
|
||||
if nowTime.After(*product.EndTime) {
|
||||
return nil, businesserr.BatchEndedError
|
||||
return nil, product, businesserr.BatchEndedError
|
||||
}
|
||||
|
||||
order, err3 = this.order(ctx, req, product)
|
||||
if err3 != nil {
|
||||
return nil, err3
|
||||
return nil, product, err3
|
||||
}
|
||||
|
||||
return order, nil
|
||||
return order, product, nil
|
||||
}
|
||||
|
||||
func (this *VoucherBiz) order(ctx context.Context, req *bo.OrderCreateReqBo, product *bo.ProductBo) (*bo.OrderBo, error) {
|
||||
|
|
|
|||
|
|
@ -11,20 +11,20 @@ import (
|
|||
|
||||
func (c *CmbService) Order(ctx context.Context, request *v1.CmbRequest) (*v1.CmbReply, error) {
|
||||
|
||||
order, err := c.order(ctx, request)
|
||||
order, product, err := c.order(ctx, request)
|
||||
|
||||
if err != nil {
|
||||
return c.OrderFail(ctx, order, err)
|
||||
return c.OrderFail(ctx, order, product, err)
|
||||
}
|
||||
|
||||
return c.OrderSuccess(ctx, order.OrderNo)
|
||||
}
|
||||
|
||||
func (c *CmbService) order(ctx context.Context, request *v1.CmbRequest) (*bo.OrderBo, error) {
|
||||
func (c *CmbService) order(ctx context.Context, request *v1.CmbRequest) (*bo.OrderBo, *bo.ProductBo, error) {
|
||||
|
||||
bizContent, err := c.CmbMixRepo.OrderVerify(ctx, request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
boReq := &bo.OrderCreateReqBo{
|
||||
|
|
@ -38,12 +38,12 @@ func (c *CmbService) order(ctx context.Context, request *v1.CmbRequest) (*bo.Ord
|
|||
NotifyUrl: c.bc.Cmb.NotifyUrl,
|
||||
}
|
||||
|
||||
order, err := c.VoucherBiz.CmbOrder(ctx, boReq)
|
||||
order, product, err := c.VoucherBiz.CmbOrder(ctx, boReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return order, nil
|
||||
return order, product, nil
|
||||
}
|
||||
|
||||
func (c *CmbService) OrderSuccess(ctx context.Context, orderNo string) (*v1.CmbReply, error) {
|
||||
|
|
@ -59,13 +59,21 @@ func (c *CmbService) OrderSuccess(ctx context.Context, orderNo string) (*v1.CmbR
|
|||
return c.GetResponse(ctx, replyBizContent)
|
||||
}
|
||||
|
||||
func (c *CmbService) OrderFail(ctx context.Context, order *bo.OrderBo, err error) (*v1.CmbReply, error) {
|
||||
func (c *CmbService) OrderFail(ctx context.Context, order *bo.OrderBo, product *bo.ProductBo, err error) (*v1.CmbReply, error) {
|
||||
|
||||
bizReply := &v1.CmbOrderReply{}
|
||||
|
||||
if e, ok := err.(*businesserr.BusinessErr); ok {
|
||||
|
||||
if order.ActivityId != "" {
|
||||
isMultiErr := false
|
||||
|
||||
if product != nil && product.ActivityId != "" {
|
||||
isMultiErr = true
|
||||
} else if order != nil && order.ActivityId != "" {
|
||||
isMultiErr = true
|
||||
}
|
||||
|
||||
if isMultiErr {
|
||||
cmbAPIError := e.HandleMULTIThirdErrCode()
|
||||
bizReply = &v1.CmbOrderReply{
|
||||
RespCode: vo.CmbResponseStatusFail.GetValue(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue