2024-10-25 10:17:27 +00:00
|
|
|
package orderservicelogic
|
|
|
|
|
|
|
|
import (
|
2024-10-27 16:01:55 +00:00
|
|
|
"app-cloudep-trade-service/internal/domain/usecase"
|
|
|
|
ers "code.30cm.net/digimon/library-go/errs"
|
2024-10-25 10:17:27 +00:00
|
|
|
"context"
|
|
|
|
|
|
|
|
"app-cloudep-trade-service/gen_result/pb/trade"
|
|
|
|
"app-cloudep-trade-service/internal/svc"
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
)
|
|
|
|
|
|
|
|
type GetOrderLogic struct {
|
|
|
|
ctx context.Context
|
|
|
|
svcCtx *svc.ServiceContext
|
|
|
|
logx.Logger
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewGetOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetOrderLogic {
|
|
|
|
return &GetOrderLogic{
|
|
|
|
ctx: ctx,
|
|
|
|
svcCtx: svcCtx,
|
|
|
|
Logger: logx.WithContext(ctx),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-27 16:01:55 +00:00
|
|
|
type GetOrderQuery struct {
|
|
|
|
BusinessID string `json:"business_id" validate:"required"`
|
|
|
|
}
|
|
|
|
|
2024-10-25 10:17:27 +00:00
|
|
|
// GetOrder 取得訂單詳情
|
|
|
|
func (l *GetOrderLogic) GetOrder(in *trade.GetOrderReq) (*trade.GetOrderResp, error) {
|
2024-10-27 16:01:55 +00:00
|
|
|
// 驗證資料
|
|
|
|
if err := l.svcCtx.Validate.ValidateAll(&GetOrderQuery{
|
|
|
|
BusinessID: in.GetBusinessId(),
|
|
|
|
}); err != nil {
|
|
|
|
// 錯誤代碼 06-011-00
|
|
|
|
return nil, ers.InvalidFormat(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
o, err := l.svcCtx.OrderUseCase.GetOrder(l.ctx, usecase.GetOrderQuery{
|
|
|
|
BusinessID: in.GetBusinessId(),
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2024-10-25 10:17:27 +00:00
|
|
|
|
2024-10-27 16:01:55 +00:00
|
|
|
return &trade.GetOrderResp{
|
|
|
|
UpdateTime: o.UpdateTime,
|
|
|
|
CreateTime: o.CreateTime,
|
|
|
|
BusinessId: o.BusinessId,
|
|
|
|
OrderType: int32(o.OrderType),
|
|
|
|
OrderStatus: int32(o.OrderStatus),
|
|
|
|
Brand: o.Brand,
|
|
|
|
OrderUid: o.OrderUid,
|
|
|
|
ReferenceId: o.ReferenceId,
|
|
|
|
Count: o.Count,
|
|
|
|
OrderFee: o.OrderFee,
|
|
|
|
Amount: o.Amount,
|
|
|
|
// 下面的為未來擴充用的欄位
|
|
|
|
ReferenceBrand: o.ReferenceBrand,
|
|
|
|
ReferenceUid: o.ReferenceUid,
|
|
|
|
WalletStatus: o.WalletStatus,
|
|
|
|
ThreePartyStatus: o.ThreePartyStatus,
|
|
|
|
DirectionType: o.DirectionType,
|
|
|
|
CryptoType: o.CryptoType,
|
|
|
|
ThirdPartyFee: o.ThirdPartyFee,
|
|
|
|
CryptoToUsdtRate: o.CryptoToUsdtRate,
|
|
|
|
FiatToUsdRate: o.FiatToUsdRate,
|
|
|
|
FeeCryptoToUsdtRate: o.FeeCryptoToUsdtRate,
|
|
|
|
UsdtToCryptoTypeRate: o.UsdtToCryptoTypeRate,
|
|
|
|
PaymentFiat: o.PaymentFiat,
|
|
|
|
PaymentUnitPrice: o.PaymentUnitPrice,
|
|
|
|
PaymentTemplateId: o.PaymentTemplateId,
|
|
|
|
OrderArrivalTime: o.OrderArrivalTime,
|
|
|
|
OrderPaymentTime: o.OrderPaymentTime,
|
|
|
|
UnpaidTimeoutSecond: o.UnpaidTimeoutSecond,
|
|
|
|
ChainType: o.ChainType,
|
|
|
|
TxHash: o.TxHash,
|
|
|
|
FromAddress: o.FromAddress,
|
|
|
|
ToAddress: o.ToAddress,
|
|
|
|
ChainFee: o.ChainFee,
|
|
|
|
ChainFeeCrypto: o.ChainFeeCrypto,
|
|
|
|
Memo: o.Memo,
|
|
|
|
OrderNote: o.OrderNote,
|
|
|
|
}, nil
|
2024-10-25 10:17:27 +00:00
|
|
|
}
|