feat: init project
This commit is contained in:
parent
0c1009dddb
commit
a1f3a439ab
11
go.mod
11
go.mod
|
@ -3,7 +3,10 @@ module code.30cm.net/digimon/app-cloudep-order-service
|
|||
go 1.24.1
|
||||
|
||||
require (
|
||||
code.30cm.net/digimon/library-go/errs v1.2.14
|
||||
github.com/shopspring/decimal v1.4.0
|
||||
github.com/zeromicro/go-zero v1.8.1
|
||||
go.mongodb.org/mongo-driver v1.17.3
|
||||
google.golang.org/grpc v1.71.0
|
||||
google.golang.org/protobuf v1.36.6
|
||||
)
|
||||
|
@ -26,6 +29,7 @@ require (
|
|||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/gnostic-models v0.6.8 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/google/gofuzz v1.2.0 // indirect
|
||||
|
@ -39,6 +43,7 @@ require (
|
|||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/montanaflynn/stats v0.7.1 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/openzipkin/zipkin-go v0.4.3 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||
|
@ -48,6 +53,10 @@ require (
|
|||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
github.com/redis/go-redis/v9 v9.7.1 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||
github.com/xdg-go/scram v1.1.2 // indirect
|
||||
github.com/xdg-go/stringprep v1.0.4 // indirect
|
||||
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.15 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.15 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.5.15 // indirect
|
||||
|
@ -67,8 +76,10 @@ require (
|
|||
go.uber.org/automaxprocs v1.6.0 // indirect
|
||||
go.uber.org/multierr v1.9.0 // indirect
|
||||
go.uber.org/zap v1.24.0 // indirect
|
||||
golang.org/x/crypto v0.33.0 // indirect
|
||||
golang.org/x/net v0.35.0 // indirect
|
||||
golang.org/x/oauth2 v0.25.0 // indirect
|
||||
golang.org/x/sync v0.11.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/term v0.29.0 // indirect
|
||||
golang.org/x/text v0.22.0 // indirect
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
package entity
|
||||
|
||||
import (
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/pkg/domain/order"
|
||||
"github.com/shopspring/decimal"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type Order struct {
|
||||
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
|
||||
UpdateTime int64 `bson:"update_time"`
|
||||
CreateTime int64 `bson:"create_time"`
|
||||
BusinessID string `bson:"business_id"` // 訂單業務流水號
|
||||
OrderType order.Type `bson:"order_type"` // 訂單類型
|
||||
OrderStatus order.Status `bson:"order_status"` // 訂單狀態
|
||||
Brand string `bson:"brand"` // 下單平台
|
||||
OrderUID string `bson:"order_uid"` // 下單用戶 UID
|
||||
ReferenceID string `bson:"reference_id"` // 訂單來源
|
||||
Count decimal.Decimal `bson:"count"` // 訂單數量
|
||||
OrderFee decimal.Decimal `bson:"order_fee"` // 訂單手續費
|
||||
Amount decimal.Decimal `bson:"amount"` // 單價
|
||||
WalletStatus int64 `bson:"wallet_status,omitempty"` // 交易金額狀態
|
||||
DirectionType int64 `bson:"direction_type,omitempty"` // 交易方向
|
||||
BookingInfo *BookingInfo `bson:"booking_info,omitempty"` // 寄送資訊
|
||||
InvoiceInfo *InvoiceInfo `bson:"invoice_info,omitempty"` // 寄送資訊
|
||||
OrderItem []OrderItem `bson:"order_item,omitempty"` // 這筆訂單所訂購的 ProductItem List
|
||||
// 以上為必要欄位,下面是區塊鏈時才需要
|
||||
ReferenceBrand *string `bson:"reference_brand,omitempty"` // 訂單來源平台
|
||||
ReferenceUID *string `bson:"reference_uid,omitempty"` // 訂單來源用戶 UID
|
||||
ThreePartyStatus *int64 `bson:"three_party_status,omitempty"` // 三方請求狀態
|
||||
CryptoType *string `bson:"crypto_type,omitempty"` // 交易幣種
|
||||
ThirdPartyFee *decimal.Decimal `bson:"third_party_fee,omitempty"` // 第三方手續費
|
||||
CryptoToUSDTRate *decimal.Decimal `bson:"crypto_to_usdt_rate,omitempty"` // 加密貨幣對 USDT 匯率
|
||||
FiatToUSDRate *decimal.Decimal `bson:"fiat_to_usd_rate,omitempty"` // 法幣對 USD 匯率
|
||||
FeeCryptoToUSDTRate *decimal.Decimal `bson:"fee_crypto_to_usdt_rate,omitempty"` // 手續費加密貨幣對 USDT 匯率
|
||||
USDTToCryptoTypeRate *decimal.Decimal `bson:"usdt_to_crypto_type_rate,omitempty"` // USDT 對加密貨幣匯率
|
||||
PaymentFiat *string `bson:"payment_fiat,omitempty"` // 支付法幣
|
||||
PaymentUnitPrice *decimal.Decimal `bson:"payment_unit_price,omitempty"` // 加密貨幣單價
|
||||
PaymentTemplateID *string `bson:"payment_template_id,omitempty"` // 支付方式配置 ID
|
||||
OrderArrivalTime *int64 `bson:"order_arrival_time,omitempty"` // 訂單到帳時間
|
||||
OrderPaymentTime *int64 `bson:"order_payment_time,omitempty"` // 訂單付款時間
|
||||
UnpaidTimeoutSecond *int64 `bson:"unpaid_timeout_second,omitempty"` // 支付期限秒數
|
||||
ChainType *string `bson:"chain_type,omitempty"` // 主網類型
|
||||
TxHash *string `bson:"tx_hash,omitempty"` // 交易哈希
|
||||
FromAddress *string `bson:"from_address,omitempty"` // 來源地址
|
||||
ToAddress *string `bson:"to_address,omitempty"` // 目標地址
|
||||
ChainFee *decimal.Decimal `bson:"chain_fee,omitempty"` // 鏈上交易手續費
|
||||
ChainFeeCrypto *string `bson:"chain_fee_crypto,omitempty"` // 鏈上手續費使用幣別
|
||||
Memo *string `bson:"memo,omitempty"` // 鏈上備註
|
||||
OrderNote *string `bson:"order_note,omitempty"` // 訂單交易備註
|
||||
|
||||
}
|
||||
|
||||
type BookingInfo struct {
|
||||
SenderName string `bson:"sender_name"` // 寄件者姓名
|
||||
SenderPhone string `bson:"sender_phone"` // 寄件者手機
|
||||
SenderEmail string `bson:"sender_email"` // 寄件者信箱
|
||||
SenderNational string `bson:"sender_national"` // 寄件者國家
|
||||
SenderAddress string `bson:"sender_address"` // 寄件者地址
|
||||
SenderCode string `bson:"sender_code"` // 寄件者郵遞區號
|
||||
ReceiverName string `bson:"receiver_name"` // 收件者姓名
|
||||
ReceiverPhone string `bson:"receiver_phone"` // 收件者手機
|
||||
ReceiverEmail string `bson:"receiver_email"` // 收件者信箱
|
||||
ReceiverAddress string `bson:"receiver_address"` // 收件者地址
|
||||
ReceiverNational string `bson:"receiver_national"` // 收件者國家
|
||||
ReceiverCode string `bson:"receiver_code"` // 收件者郵遞區號
|
||||
Memo string `bson:"memo"` // 備註
|
||||
}
|
||||
type InvoiceInfo struct {
|
||||
Type string `bson:"type"` // 發票類型
|
||||
Code string `bson:"code"` // 載具條碼
|
||||
Name string `bson:"name"` // 捐款人姓名 / 公司抬頭
|
||||
ID string `bson:"id"` // 身分證字號,通依編號
|
||||
National string `bson:"national"` // 國家
|
||||
City string `bson:"city" ` // 縣市
|
||||
Area string `bson:"area"` // 地區
|
||||
Address string `bson:"address"` // 收件者地址
|
||||
Memo string `bson:"memo"` // 備註
|
||||
}
|
||||
|
||||
type OrderItem struct {
|
||||
ItemID string
|
||||
Count int64
|
||||
Additional uint64
|
||||
}
|
||||
|
||||
func (p *Order) CollectionName() string {
|
||||
return "order"
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package entity
|
||||
|
||||
import "go.mongodb.org/mongo-driver/bson/primitive"
|
||||
|
||||
type RememberMe struct {
|
||||
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
|
||||
UID string `bson:"uid"`
|
||||
BookingInfo *BookingInfo `bson:"booking_info,omitempty"` // 寄送資訊
|
||||
InvoiceInfo *InvoiceInfo `bson:"invoice_info,omitempty"` // 寄送資訊
|
||||
UpdateTime int64 `bson:"update_time"`
|
||||
CreateTime int64 `bson:"create_time"`
|
||||
}
|
||||
|
||||
func (p *RememberMe) CollectionName() string {
|
||||
return "remember_me"
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package domain
|
||||
|
||||
import "code.30cm.net/digimon/library-go/errs"
|
||||
|
||||
// Error Code 統一這邊改
|
||||
const (
|
||||
_ = iota
|
||||
CreateOrderErrorCode errs.ErrorCode = iota
|
||||
CancelOrderErrorCode
|
||||
DeleteOrderErrorCode
|
||||
DataNotFoundErrorCode
|
||||
ListOrderErrorCode
|
||||
ModifyOrderErrorCode
|
||||
TimeoutOrderErrorCode
|
||||
ModifyBookingInfoErrorCode
|
||||
GetReadmeErrorCode
|
||||
)
|
|
@ -0,0 +1,20 @@
|
|||
package order
|
||||
|
||||
// DirectType 表示訂單方向
|
||||
type DirectType int64
|
||||
|
||||
// ToInt 將訂單類型轉為 int
|
||||
func (t DirectType) ToInt() int {
|
||||
return int(t)
|
||||
}
|
||||
|
||||
// ToInt64 將訂單類型轉為 int64
|
||||
func (t DirectType) ToInt64() int64 {
|
||||
return int64(t)
|
||||
}
|
||||
|
||||
// 訂單類型常量
|
||||
const (
|
||||
Buy DirectType = iota + 1 // 測試訂單
|
||||
Sell
|
||||
)
|
|
@ -0,0 +1,84 @@
|
|||
package order
|
||||
|
||||
// Status 表示訂單狀態
|
||||
type Status int64
|
||||
|
||||
// ToInt64 將訂單狀態轉為 int64
|
||||
func (s Status) ToInt64() int64 {
|
||||
return int64(s)
|
||||
}
|
||||
|
||||
var statusMap = map[Status]string{
|
||||
Created: CreatedString,
|
||||
Failed: FailedString,
|
||||
UnderReview: UnderReviewString,
|
||||
Processing: ProcessingString,
|
||||
Paid: PaidString,
|
||||
AwaitingTransfer: AwaitingTransferString,
|
||||
InDispute: InDisputeString,
|
||||
Completed: CompletedString,
|
||||
FailedTrade: FailedTradeString,
|
||||
Cancelled: CancelledString,
|
||||
Abnormal: AbnormalString,
|
||||
TimedOut: TimedOutString,
|
||||
}
|
||||
|
||||
// ToString 將訂單類型轉為 String
|
||||
func (s Status) ToString() string {
|
||||
r := statusMap[s]
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// 訂單狀態常量
|
||||
const (
|
||||
Created Status = iota // 訂單已建立
|
||||
Failed // 建單失敗
|
||||
UnderReview // 審核中
|
||||
Processing // 付款中
|
||||
Paid // 已付款
|
||||
AwaitingTransfer // 待轉帳
|
||||
InDispute // 申訴中
|
||||
Completed // 交易完成
|
||||
FailedTrade // 交易失敗
|
||||
Cancelled // 交易取消
|
||||
Abnormal // 交易異常
|
||||
TimedOut // 交易超時
|
||||
)
|
||||
|
||||
const (
|
||||
CreatedString = "create" // 訂單已建立
|
||||
FailedString = "failed" // 建單失敗
|
||||
UnderReviewString = "under_review" // 審核中
|
||||
ProcessingString = "processing" // 付款中
|
||||
PaidString = "paid" // 已付款
|
||||
AwaitingTransferString = "awaiting_transfer" // 待轉帳
|
||||
InDisputeString = "in_dispute" // 申訴中
|
||||
CompletedString = "completed" // 交易完成
|
||||
FailedTradeString = "failed_trade" // 交易失敗
|
||||
CancelledString = "cancelled" // 交易取消
|
||||
AbnormalString = "abnormal" // 交易異常
|
||||
TimedOutString = "timed_out" // 交易超時
|
||||
)
|
||||
|
||||
var statusStringMap = map[string]Status{
|
||||
CreatedString: Created,
|
||||
FailedString: Failed,
|
||||
UnderReviewString: UnderReview,
|
||||
ProcessingString: Processing,
|
||||
PaidString: Paid,
|
||||
AwaitingTransferString: AwaitingTransfer,
|
||||
InDisputeString: InDispute,
|
||||
CompletedString: Completed,
|
||||
FailedTradeString: FailedTrade,
|
||||
CancelledString: Cancelled,
|
||||
AbnormalString: Abnormal,
|
||||
TimedOutString: TimedOut,
|
||||
}
|
||||
|
||||
// ConvertStringToStatus 將訂單類型轉為 Status
|
||||
func ConvertStringToStatus(t string) Status {
|
||||
s := statusStringMap[t]
|
||||
|
||||
return s
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package order
|
||||
|
||||
// Type 表示訂單類型
|
||||
type Type int64
|
||||
|
||||
const (
|
||||
UnDefine Type = iota
|
||||
ProductType // 商品訂單
|
||||
)
|
||||
|
||||
// typeToStr 是 Type 對應的文字敘述
|
||||
var typeToStr = map[Type]string{
|
||||
UnDefine: "un_define",
|
||||
ProductType: "product",
|
||||
}
|
||||
|
||||
// strToType 是文字轉回 Type 的對應
|
||||
var strToType = map[string]Type{
|
||||
"un_define": UnDefine,
|
||||
"product": ProductType,
|
||||
}
|
||||
|
||||
// ToInt 將 Type 轉為 int
|
||||
func (t Type) ToInt() int {
|
||||
return int(t)
|
||||
}
|
||||
|
||||
// ToString 將 Type 轉為 string
|
||||
func (t Type) ToString() string {
|
||||
if s, ok := typeToStr[t]; ok {
|
||||
return s
|
||||
}
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
// ParseType 從字串解析 Type,預設回傳 UnDefine
|
||||
func ParseType(s string) Type {
|
||||
if t, ok := strToType[s]; ok {
|
||||
return t
|
||||
}
|
||||
return UnDefine
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package domain
|
||||
|
||||
import "strings"
|
||||
|
||||
type RedisKey string
|
||||
|
||||
const (
|
||||
OrderRedisKey RedisKey = "id"
|
||||
RememberME RedisKey = "remember_me"
|
||||
)
|
||||
|
||||
func (key RedisKey) ToString() string {
|
||||
return "order:" + string(key)
|
||||
}
|
||||
|
||||
func (key RedisKey) With(s ...string) RedisKey {
|
||||
parts := append([]string{string(key)}, s...)
|
||||
|
||||
return RedisKey(strings.Join(parts, ":"))
|
||||
}
|
||||
|
||||
func GetOrderRedisKey(id string) string {
|
||||
return OrderRedisKey.With(id).ToString()
|
||||
}
|
||||
|
||||
func GetRememberMeRedisKey(uid string) string {
|
||||
return RememberME.With(uid).ToString()
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package repository
|
||||
|
||||
import (
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/pkg/domain/entity"
|
||||
"context"
|
||||
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
type OrderRepository interface {
|
||||
Insert(ctx context.Context, data *entity.Order) error
|
||||
FindOne(ctx context.Context, id string) (*entity.Order, error)
|
||||
Update(ctx context.Context, data *entity.Order) (*mongo.UpdateResult, error)
|
||||
Delete(ctx context.Context, id string) (int64, error)
|
||||
UpdateStatus(ctx context.Context, data UpdateStatusReq) (*mongo.UpdateResult, error)
|
||||
UpdateTimeoutOrder(ctx context.Context, req UpdateTimeoutReq) ([]string, error)
|
||||
DeleteByBusinessID(ctx context.Context, id string) (*mongo.UpdateResult, error)
|
||||
FindOneBusinessID(ctx context.Context, id string) (*entity.Order, error)
|
||||
ListOrder(ctx context.Context, req GetOrderListReq) ([]entity.Order, int64, error)
|
||||
ModifyBookingInfoByBusinessID(ctx context.Context, orderID string, param *BookingInfo) error
|
||||
}
|
||||
|
||||
type (
|
||||
UpdateStatusReq struct {
|
||||
BusinessID string
|
||||
Status int64
|
||||
}
|
||||
|
||||
UpdateTimeoutReq struct {
|
||||
CreateTimeBefore int64
|
||||
}
|
||||
|
||||
GetOrderListReq struct {
|
||||
PageIndex int64 `json:"page_index" validate:"required"`
|
||||
PageSize int64 `json:"page_size" validate:"required"`
|
||||
|
||||
ReferenceID string `json:"reference_id"`
|
||||
ReferenceUID string `json:"reference_uid"`
|
||||
BusinessID string `json:"business_id"`
|
||||
UID string `json:"uid"`
|
||||
OrderType int `json:"order_type"`
|
||||
DirectionType []int64 `json:"direction_type"`
|
||||
OrderStatus []int64 `json:"order_status"`
|
||||
|
||||
StartCreateTime int64 `json:"start_create_time"`
|
||||
EndCreateTime int64 `json:"end_create_time"`
|
||||
StartUpdateTime int64 `json:"start_update_time"`
|
||||
EndUpdateTime int64 `json:"end_update_time"`
|
||||
StartOrderArrivalTime int64 `json:"start_order_arrival_time"`
|
||||
EndOrderArrivalTime int64 `json:"end_order_arrival_time"`
|
||||
StartOrderPaymentTime int64 `json:"start_order_payment_time"`
|
||||
EndOrderPaymentTime int64 `json:"end_order_payment_time"`
|
||||
|
||||
CryptoType string `json:"crypto_type"`
|
||||
TxHash string `json:"tx_hash"`
|
||||
}
|
||||
|
||||
BookingInfo struct {
|
||||
SenderName string // 寄件者姓名
|
||||
SenderPhone string // 寄件者手機
|
||||
SenderEmail string // 寄件者信箱
|
||||
SenderNational string // 寄件者國家
|
||||
SenderAddress string // 寄件者地址
|
||||
SenderCode string // 寄件者郵遞區號
|
||||
ReceiverName string // 收件者姓名
|
||||
ReceiverPhone string // 收件者手機
|
||||
ReceiverEmail string // 收件者信箱
|
||||
ReceiverAddress string // 收件者地址
|
||||
ReceiverNational string // 收件者國家
|
||||
ReceiverCode string // 收件者郵遞區號
|
||||
Memo string // 備註
|
||||
}
|
||||
)
|
||||
|
||||
type OrderItem struct {
|
||||
ItemID string
|
||||
Count int64
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package repository
|
||||
|
||||
import (
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/pkg/domain/entity"
|
||||
"context"
|
||||
)
|
||||
|
||||
type RememberMeRepository interface {
|
||||
Insert(ctx context.Context, data *entity.RememberMe) error
|
||||
FindOne(ctx context.Context, uid string) (*entity.RememberMe, error)
|
||||
Delete(ctx context.Context, uid string) error
|
||||
}
|
|
@ -0,0 +1,220 @@
|
|||
package usecase
|
||||
|
||||
import (
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/pkg/domain/entity"
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/pkg/domain/order"
|
||||
"context"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
type OrderUseCase interface {
|
||||
// CreateOrder 建立訂單,不另外做 struct 直接用 model.Order
|
||||
// 考量底層已經寫完,如有額外需求需要在這邊用轉的
|
||||
CreateOrder(ctx context.Context, param CreateOrderReq) error
|
||||
// CancelOrder 取消訂單
|
||||
CancelOrder(ctx context.Context, param CancelOrderQuery) error
|
||||
// DeleteOrder 刪除訂單(軟刪除)
|
||||
DeleteOrder(ctx context.Context, param DeleteOrderQuery) error
|
||||
// GetOrder 取得訂單資料
|
||||
GetOrder(ctx context.Context, param GetOrderQuery) (*GetOrderResp, error)
|
||||
// ListOrder 取得資料列表
|
||||
ListOrder(ctx context.Context, param GetOrderListReq) (*ListOrderResp, error)
|
||||
// ModifyOrderStatus 更新資料
|
||||
ModifyOrderStatus(ctx context.Context, param *ModifyOrderQuery) error
|
||||
// OrderStatusTimeout 訂單超時任務/cron/order-status/timeout
|
||||
OrderStatusTimeout(ctx context.Context) ([]string, error)
|
||||
// ModifyBookingInfo 編輯訂單送達的資訊
|
||||
ModifyBookingInfo(ctx context.Context, orderID string, param *BookingInfo) error
|
||||
// GenerateProductBusinessID 產生 product business id
|
||||
GenerateProductBusinessID() string
|
||||
// UpdateRememberMe 記住我的常用資訊
|
||||
UpdateRememberMe(ctx context.Context, data *entity.RememberMe) error
|
||||
// GetRememberMe 取得我的常用資訊
|
||||
GetRememberMe(ctx context.Context, uid string) (RememberMe, error)
|
||||
}
|
||||
|
||||
// ModifyOrderQuery
|
||||
// 0.建立訂單 1.建單失敗 2.審核中 3.付款中 4.已付款
|
||||
// 5.已付款待轉帳 6.申訴中 7.交易完成
|
||||
// 8.交易失敗 9.交易取消 10.交易異常 11.交易超時
|
||||
|
||||
type ModifyOrderQuery struct {
|
||||
BusinessID string `json:"business_id" validate:"required"`
|
||||
Status int64 `json:"status" validate:"required,oneof=2 3 4 5 6 7 8 11"`
|
||||
}
|
||||
|
||||
// CancelOrderQuery 1.建單失敗 9.交易取消 10.交易異常
|
||||
type CancelOrderQuery struct {
|
||||
BusinessID string
|
||||
Status order.Status
|
||||
}
|
||||
|
||||
// DeleteOrderQuery 刪除訂單(軟刪除)
|
||||
type DeleteOrderQuery struct {
|
||||
BusinessID string
|
||||
}
|
||||
|
||||
// GetOrderQuery 取得訂單
|
||||
type GetOrderQuery struct {
|
||||
BusinessID string
|
||||
}
|
||||
|
||||
type GetOrderResp struct {
|
||||
ID string `json:"id"`
|
||||
BusinessID string // 訂單業務流水號
|
||||
OrderType order.Type `json:"order_type"` // 訂單類型
|
||||
OrderStatus order.Status `json:"order_status"` // 訂單狀態
|
||||
Brand string `json:"brand"` // 下單平台
|
||||
OrderUID string `json:"order_uid"` // 下單用戶 UID
|
||||
ReferenceID string `json:"reference_id"` // 訂單來源
|
||||
Count string `json:"count"` // 訂單數量 (decimal to string)
|
||||
OrderFee string `json:"order_fee"` // 訂單手續費 (decimal to string)
|
||||
Amount string `json:"amount"` // 單價 (decimal to string)
|
||||
ReferenceBrand *string `json:"reference_brand,omitempty"` // 訂單來源平台
|
||||
ReferenceUID *string `json:"reference_uid,omitempty"` // 訂單來源用戶 UID
|
||||
WalletStatus *int64 `json:"wallet_status,omitempty"` // 交易金額狀態
|
||||
ThreePartyStatus *int64 `json:"three_party_status,omitempty"` // 三方請求狀態
|
||||
DirectionType *int64 `json:"direction_type,omitempty"` // 交易方向
|
||||
CryptoType *string `json:"crypto_type,omitempty"` // 交易幣種
|
||||
ThirdPartyFee *string `json:"third_party_fee,omitempty"` // 第三方手續費 (decimal to string)
|
||||
CryptoToUsdtRate *string `json:"crypto_to_usdt_rate,omitempty"` // 交易幣種對 USDT 匯率 (decimal to string)
|
||||
FiatToUsdRate *string `json:"fiat_to_usd_rate,omitempty"` // 法幣對 USD 匯率 (decimal to string)
|
||||
FeeCryptoToUsdtRate *string `json:"fee_crypto_to_usdt_rate,omitempty"` // 手續費幣種對 USDT 匯率 (decimal to string)
|
||||
UsdtToCryptoTypeRate *string `json:"usdt_to_crypto_type_rate,omitempty"` // USDT 對交易幣種匯率 (decimal to string)
|
||||
PaymentFiat *string `json:"payment_fiat,omitempty"` // 支付法幣
|
||||
PaymentUnitPrice *string `json:"payment_unit_price,omitempty"` // crypto 單價 (decimal to string)
|
||||
PaymentTemplateID *string `json:"payment_template_id,omitempty"` // 支付方式配置 ID
|
||||
OrderArrivalTime *int64 `json:"order_arrival_time,omitempty"` // 訂單到帳時間
|
||||
OrderPaymentTime *int64 `json:"order_payment_time,omitempty"` // 訂單付款時間
|
||||
UnpaidTimeoutSecond *int64 `json:"unpaid_timeout_second,omitempty"` // 支付期限秒數
|
||||
ChainType *string `json:"chain_type,omitempty"` // 主網類型
|
||||
TxHash *string `json:"tx_hash,omitempty,omitempty"` // 交易哈希
|
||||
FromAddress *string `json:"from_address,omitempty,omitempty"` // 來源地址
|
||||
ToAddress *string `json:"to_address,omitempty,omitempty"` // 目標地址
|
||||
ChainFee *string `json:"chain_fee,omitempty"` // 鏈上交易手續費 (decimal to string)
|
||||
ChainFeeCrypto *string `json:"chain_fee_crypto,omitempty"` // 鏈上手續費使用幣別
|
||||
Memo *string `json:"memo,omitempty"` // 鏈上備註
|
||||
OrderNote *string `json:"order_note,omitempty"` // 訂單交易備註
|
||||
CreateTime int64 `json:"create_time,omitempty"` // 建立時間
|
||||
UpdateTime int64 `json:"update_time,omitempty"` // 更新時間
|
||||
BookingInfo *BookingInfo `json:"booking_info,omitempty"` // 實體訂單資訊
|
||||
OrderItemInfo []OrderItem `json:"order_item_info,omitempty"` // 這張單的品項資訊
|
||||
InvoiceInfo *InvoiceInfo `json:"invoice_info,omitempty"` // 這張單的品項資訊
|
||||
}
|
||||
|
||||
type GetOrderListReq struct {
|
||||
PageIndex int64
|
||||
PageSize int64
|
||||
|
||||
ReferenceID string
|
||||
ReferenceUID string
|
||||
BusinessID string
|
||||
UID string
|
||||
OrderType order.Type
|
||||
DirectionType []int64
|
||||
OrderStatus []int64
|
||||
|
||||
StartCreateTime int64
|
||||
EndCreateTime int64
|
||||
StartUpdateTime int64
|
||||
EndUpdateTime int64
|
||||
StartOrderArrivalTime int64
|
||||
EndOrderArrivalTime int64
|
||||
StartOrderPaymentTime int64
|
||||
EndOrderPaymentTime int64
|
||||
|
||||
CryptoType string
|
||||
TxHash string
|
||||
}
|
||||
|
||||
type Pager struct {
|
||||
Index int64
|
||||
Size int64
|
||||
Total int64
|
||||
}
|
||||
|
||||
type ListOrderResp struct {
|
||||
Data []*GetOrderResp `json:"data"` // 訂單列表
|
||||
Page *Pager `json:"page"`
|
||||
}
|
||||
|
||||
type CreateOrderReq struct {
|
||||
BusinessID string
|
||||
OrderType order.Type // 訂單類型
|
||||
OrderStatus order.Status // 訂單狀態
|
||||
Brand string // 下單平台
|
||||
OrderUID string // 下單用戶 UID
|
||||
ReferenceID string // 訂單來源
|
||||
Count decimal.Decimal // 訂單數量
|
||||
OrderFee decimal.Decimal // 訂單手續費
|
||||
Amount decimal.Decimal // 單價
|
||||
WalletStatus int64 // 交易金額狀態
|
||||
DirectionType int64 // 交易方向
|
||||
// 以上為必要欄位,下面是區塊鏈時才需要
|
||||
ReferenceBrand *string // 訂單來源平台
|
||||
ReferenceUID *string // 訂單來源用戶 UID
|
||||
ThreePartyStatus *int64 // 三方請求狀態
|
||||
CryptoType *string // 交易幣種
|
||||
ThirdPartyFee *decimal.Decimal // 第三方手續費
|
||||
CryptoToUSDTRate *decimal.Decimal // 加密貨幣對 USDT 匯率
|
||||
FiatToUSDRate *decimal.Decimal // 法幣對 USD 匯率
|
||||
FeeCryptoToUSDTRate *decimal.Decimal // 手續費加密貨幣對 USDT 匯率
|
||||
USDTToCryptoTypeRate *decimal.Decimal // USDT 對加密貨幣匯率
|
||||
PaymentFiat *string // 支付法幣
|
||||
PaymentUnitPrice *decimal.Decimal // 加密貨幣單價
|
||||
PaymentTemplateID *string // 支付方式配置 ID
|
||||
OrderArrivalTime *int64 // 訂單到帳時間
|
||||
OrderPaymentTime *int64 // 訂單付款時間
|
||||
UnpaidTimeoutSecond *int64 // 支付期限秒數
|
||||
ChainType *string // 主網類型
|
||||
TxHash *string // 交易哈希
|
||||
FromAddress *string // 來源地址
|
||||
ToAddress *string // 目標地址
|
||||
ChainFee *decimal.Decimal // 鏈上交易手續費
|
||||
ChainFeeCrypto *string // 鏈上手續費使用幣別
|
||||
Memo *string // 鏈上備註
|
||||
OrderNote *string // 訂單交易備註
|
||||
BookingInfo *BookingInfo // 實體訂單資訊
|
||||
OrderItemInfo []OrderItem // 這張單的品項資訊
|
||||
InvoiceInfo *InvoiceInfo
|
||||
}
|
||||
|
||||
type BookingInfo struct {
|
||||
SenderName string // 寄件者姓名
|
||||
SenderPhone string // 寄件者手機
|
||||
SenderEmail string // 寄件者信箱
|
||||
SenderNational string // 寄件者國家
|
||||
SenderAddress string // 寄件者地址
|
||||
SenderCode string // 寄件者郵遞區號
|
||||
ReceiverName string // 收件者姓名
|
||||
ReceiverPhone string // 收件者手機
|
||||
ReceiverEmail string // 收件者信箱
|
||||
ReceiverNational string // 收件者國家
|
||||
ReceiverAddress string // 收件者地址
|
||||
ReceiverCode string // 收件者郵遞區號
|
||||
Memo string // 備註
|
||||
}
|
||||
|
||||
type InvoiceInfo struct {
|
||||
Type string `json:"type" validate:"required"` // 發票類型
|
||||
Code string `json:"code" validate:"required"` // 載具條碼
|
||||
Name string `json:"name" validate:"required"` // 捐款人姓名 / 公司抬頭
|
||||
ID string `json:"id" validate:"required"` // 身分證字號,通依編號
|
||||
City string `json:"city" validate:"required"` // 縣市
|
||||
Area string `json:"area" validate:"required"` // 地區
|
||||
National string `json:"national" validate:"required"` // 國家
|
||||
Address string `json:"address" validate:"required"` // 收件者地址
|
||||
Memo string `json:"memo,optional"` // 備註
|
||||
}
|
||||
|
||||
type OrderItem struct {
|
||||
ItemID string
|
||||
Count int64
|
||||
Additional uint64
|
||||
}
|
||||
|
||||
type RememberMe struct {
|
||||
BookingInfo BookingInfo `json:"booking_info"` // 寄送資訊
|
||||
InvoiceInfo InvoiceInfo `json:"invoice_info"` // 寄送資訊
|
||||
}
|
Loading…
Reference in New Issue