gomod引用

This commit is contained in:
2025-12-12 18:16:28 +08:00
parent a4ba4dd715
commit 465c138f21
11 changed files with 340 additions and 403 deletions

View File

@@ -7,11 +7,12 @@ import (
"math/rand"
"time"
"go.mongodb.org/mongo-driver/v2/bson"
"order/consts"
"order/dao"
"order/model/dto"
"order/model/entity"
"go.mongodb.org/mongo-driver/v2/bson"
)
type payment struct{}
@@ -27,7 +28,7 @@ func (s *payment) PayOrder(ctx context.Context, req *dto.PayOrderReq) (*dto.PayO
}
// 2. 查询订单
order, status, err := dao.Order.GetOrderByNo(ctx, req.TenantID, req.OrderNo)
order, status, err := dao.Order.GetOrderByNo(ctx, req.OrderNo)
if err != nil {
return nil, fmt.Errorf("获取订单失败: %w", err)
}
@@ -64,7 +65,6 @@ func (s *payment) PayOrder(ctx context.Context, req *dto.PayOrderReq) (*dto.PayO
// 6. 创建支付记录
paymentRecord := &entity.PaymentRecord{
TenantId: req.TenantID,
OrderID: pendingOrder.Id,
OrderNo: req.OrderNo,
PayMethod: req.PayMethod,
@@ -88,7 +88,7 @@ func (s *payment) PayOrder(ctx context.Context, req *dto.PayOrderReq) (*dto.PayO
APPParams: payResp.APPParams,
}
if err := dao.Order.UpdatePayInfo(ctx, req.TenantID, req.OrderNo, payInfo); err != nil {
if err := dao.Order.UpdatePayInfo(ctx, req.OrderNo, payInfo); err != nil {
return nil, fmt.Errorf("更新订单支付信息失败: %w", err)
}
@@ -197,7 +197,7 @@ func (s *payment) HandlePaymentNotify(ctx context.Context, req *dto.PaymentNotif
"payment_channel": req.PayMethod,
}
if err := dao.Order.MoveOrderToStatus(ctx, consts.OrderStatusPending, consts.OrderStatusPaid, req.TenantID, req.OrderNo, updateData); err != nil {
if err := dao.Order.MoveOrderToStatus(ctx, consts.OrderStatusPending, consts.OrderStatusPaid, req.OrderNo, updateData); err != nil {
return fmt.Errorf("更新订单状态失败: %w", err)
}
}
@@ -220,7 +220,7 @@ func (s *payment) RefundOrder(ctx context.Context, req *dto.RefundOrderReq) (*dt
}
// 2. 查询订单
order, status, err := dao.Order.GetOrderByNo(ctx, req.TenantID, req.OrderNo)
order, status, err := dao.Order.GetOrderByNo(ctx, req.OrderNo)
if err != nil {
return nil, fmt.Errorf("获取订单失败: %w", err)
}
@@ -252,7 +252,6 @@ func (s *payment) RefundOrder(ctx context.Context, req *dto.RefundOrderReq) (*dt
// 6. 创建退款记录
refundRecord := &entity.RefundRecord{
TenantId: req.TenantID,
OrderID: paidOrder.Id,
OrderNo: req.OrderNo,
RefundNo: refundResp.RefundNo,
@@ -271,7 +270,7 @@ func (s *payment) RefundOrder(ctx context.Context, req *dto.RefundOrderReq) (*dt
"refund_reason": req.Reason,
}
if err := dao.Order.MoveOrderToStatus(ctx, consts.OrderStatusPaid, consts.OrderStatusRefunded, req.TenantID, req.OrderNo, updateData); err != nil {
if err := dao.Order.MoveOrderToStatus(ctx, consts.OrderStatusPaid, consts.OrderStatusRefunded, req.OrderNo, updateData); err != nil {
return nil, fmt.Errorf("更新订单状态失败: %w", err)
}
}