f
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package admin_order
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"qnc-server/app/main/api/internal/logic/pay"
|
||||
"qnc-server/app/main/api/internal/svc"
|
||||
"qnc-server/app/main/api/internal/types"
|
||||
"qnc-server/app/main/model"
|
||||
"qnc-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AdminXpayDeliverLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAdminXpayDeliverLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminXpayDeliverLogic {
|
||||
return &AdminXpayDeliverLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AdminXpayDeliverLogic) AdminXpayDeliver(req *types.AdminXpayDeliverReq) (resp *types.AdminXpayDeliverResp, err error) {
|
||||
order, findErr := l.svcCtx.OrderModel.FindOne(l.ctx, req.Id)
|
||||
if findErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("订单不存在"), "%v", findErr)
|
||||
}
|
||||
|
||||
if !model.IsXpayOrder(order) {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("仅支持小程序虚拟支付订单"), "")
|
||||
}
|
||||
|
||||
if l.svcCtx.XpayService == nil || !l.svcCtx.XpayService.Enabled() {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("虚拟支付未启用"), "")
|
||||
}
|
||||
|
||||
result, deliverErr := pay.DeliverXpayQueryOrder(l.ctx, l.svcCtx, order.OrderNo)
|
||||
if deliverErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "补发货失败: %v", deliverErr)
|
||||
}
|
||||
|
||||
return &types.AdminXpayDeliverResp{
|
||||
Credited: result.Credited,
|
||||
Notified: result.Notified,
|
||||
WechatDetail: result.WechatDetail,
|
||||
Errors: result.Errors,
|
||||
Message: result.Message,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user