add trade wallet proto

This commit is contained in:
daniel.w 2024-10-25 14:18:16 +08:00
commit d0a6f9e0ec
5 changed files with 301 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
.idea/
go.sum
account/
gen_result/
etc/order.yaml
client/
.DS_Store

View File

@ -0,0 +1,13 @@
use digimon_order;
db.order.createIndex({ "business_id": 1, "order_status": 1, "create_time": -1 })
db.orders.createIndex({ "reference_id": 1, "reference_uid": 1, "business_id": 1, "uid": 1 })
db.orders.createIndex({ "order_type": 1, "direction_type": 1, "order_status": 1 })
db.orders.createIndex({ "create_time": -1, "update_time": -1, "order_arrival_time": -1, "order_payment_time": -1 })
db.order.createIndex({
"uid": 1,
"order_type": 1,
"order_status": 1,
"create_time": -1,
})

View File

@ -0,0 +1 @@
如果有需要可以把 mongo 放這邊

View File

@ -0,0 +1,39 @@
# migrate
數據庫遷移工具
[golang-migrate](https://github.com/golang-migrate/migrate)
## 安裝 make
```shell
brew install Makefile
```
## 安裝 golang-migrate
```shell
brew install golang-migrate
```
## 執行刪除 mysql schema
```shell
migrate -source file://database/migrations/mysql -database 'mysql://account:password@tcp(127.0.0.1:3306)/esc_c2c' down
```
## 執行安裝 mysql schema
```shell
migrate -source file://database/migrations/mysql -database 'mysql://account:password@tcp(127.0.0.1:3306)/esc_c2c' up
```
## 執行刪除 mongo schema
```shell
migrate -source file://database/migrations/mongodb -database 'mongodb://127.0.0.1:27017/esc_c2c' down
```
## 執行安裝 mongo schema
```shell
migrate -source file://database/migrations/mongodb -database 'mongodb://127.0.0.1:27017/esc_c2c' up
```

View File

@ -0,0 +1,241 @@
syntax = "proto3";
package trade;
option go_package = "./trade";
// ========== ===========
message OKResp {}
//
message NoneReq {}
//
message Pager {
int64 total = 1; //
int64 size = 2; //
int64 index = 3; //
}
// ========== ===========
message CreateOrderReq {
string business_id = 1; //
int32 order_type = 2; //
int32 order_status = 3; //
string brand = 4; //
string order_uid = 5; // UID
string reference_id = 6; //
string count = 7; // (decimal to string)
string order_fee = 8; // (decimal to string)
string amount = 9; // (decimal to string)
//
optional string reference_brand = 10; //
optional string reference_uid = 11; // UID
optional int64 wallet_status = 12; //
optional int64 three_party_status = 13; //
optional int64 direction_type = 14; //
optional string crypto_type = 15; //
optional string third_party_fee = 16; // (decimal to string)
optional string crypto_to_usdt_rate = 17; // USDT (decimal to string)
optional string fiat_to_usd_rate = 18; // USD (decimal to string)
optional string fee_crypto_to_usdt_rate = 19; // USDT (decimal to string)
optional string usdt_to_crypto_type_rate = 20; // USDT (decimal to string)
optional string payment_fiat = 21; //
optional string payment_unit_price = 22; // crypto (decimal to string)
optional string payment_template_id = 23; // ID
optional int64 order_arrival_time = 24; //
optional int64 order_payment_time = 25; //
optional int64 unpaid_timeout_second = 26; //
optional string chain_type = 27; //
optional string tx_hash = 28; //
optional string from_address = 29; //
optional string to_address = 30; //
optional string chain_fee = 31; // (decimal to string)
optional string chain_fee_crypto = 32; // 使
optional string memo = 33; //
optional string order_note = 34; //
}
message CancelOrderReq {
string business_id = 1;
int64 status = 2;
}
message ModifyOrderStatusReq {
string business_id = 1;
int64 status = 2;
}
message DeleteOrderReq {
string business_id = 1;
}
message OrderStatusTimeoutReq {}
message GetOrderReq {
string business_id = 1; //
}
message GetOrderResp {
string business_id = 1; //
int32 order_type = 2; //
int32 order_status = 3; //
string brand = 4; //
string order_uid = 5; // UID
string reference_id = 6; //
string count = 7; // (decimal to string)
string order_fee = 8; // (decimal to string)
string amount = 9; // (decimal to string)
//
optional string reference_brand = 10; //
optional string reference_uid = 11; // UID
optional int64 wallet_status = 12; //
optional int64 three_party_status = 13; //
optional int64 direction_type = 14; //
optional string crypto_type = 15; //
optional string third_party_fee = 16; // (decimal to string)
optional string crypto_to_usdt_rate = 17; // USDT (decimal to string)
optional string fiat_to_usd_rate = 18; // USD (decimal to string)
optional string fee_crypto_to_usdt_rate = 19; // USDT (decimal to string)
optional string usdt_to_crypto_type_rate = 20; // USDT (decimal to string)
optional string payment_fiat = 21; //
optional string payment_unit_price = 22; // crypto (decimal to string)
optional string payment_template_id = 23; // ID
optional int64 order_arrival_time = 24; //
optional int64 order_payment_time = 25; //
optional int64 unpaid_timeout_second = 26; //
optional string chain_type = 27; //
optional string tx_hash = 28; //
optional string from_address = 29; //
optional string to_address = 30; //
optional string chain_fee = 31; // (decimal to string)
optional string chain_fee_crypto = 32; // 使
optional string memo = 33; //
optional string order_note = 34; //
int64 create_time = 35; //
int64 update_time = 36; //
}
message ListOrderReq {
int64 page_index = 1; // required
int64 page_size = 2; // required
string reference_id = 3;
string reference_uid = 4;
string business_id = 5;
string uid = 6;
int32 order_type = 7;
repeated int32 direction_type = 8;
repeated int32 order_status = 9;
int64 start_create_time = 10;
int64 end_create_time = 11;
int64 start_update_time = 12;
int64 end_update_time = 13;
int64 start_order_arrival_time = 14;
int64 end_order_arrival_time = 15;
int64 start_order_payment_time = 16;
int64 end_order_payment_time = 17;
string crypto_type = 18;
string tx_hash = 19;
}
message ListOrderResp {
repeated GetOrderResp data = 1; //
Pager page = 2;
}
// OrderService
service OrderService {
// CreateOrder
rpc CreateOrder(CreateOrderReq) returns (OKResp);
// CancelOrder
rpc CancelOrder(CancelOrderReq) returns (OKResp);
// ModifyOrderStatus
rpc ModifyOrderStatus(ModifyOrderStatusReq) returns (OKResp);
// DeleteOrder
rpc DeleteOrder(DeleteOrderReq) returns (OKResp);
// GetOrder
rpc GetOrder(GetOrderReq) returns (GetOrderResp);
// ListOrder
rpc ListOrder(ListOrderReq) returns (ListOrderResp);
// OrderStatusTimeout /cron/order-status/timeout
rpc OrderStatusTimeout(OrderStatusTimeoutReq) returns (OKResp);
}
// ========== ===========
message CreateWalletReq{
repeated WalletItem item =1;
}
message WalletItem {
string source = 1; //
string uid = 2; // UID
string currency_type = 3; //
string current_balance = 4; //
int64 wallet_type = 5; // 1. 2. 3.
}
message WalletTransactionReq{
string uid =1; // UID
optional string order_id =2; //
optional string business_type =3; //
optional string currency_type = 4; //
optional string amount = 5; //
optional int64 wallet_type = 6;//
}
message QueryBalanceByDateReq{
string uid =1; // UID
string currency_type = 2; //
}
message QueryBalanceByDateResp {
string currency_type = 1; //
string available = 2; //
UnavailableBalance unavailable = 3; //
int64 update_time=4;
}
message UnavailableBalance{
string freeze = 1; //
string unconfirmed = 2; //
}
service WalletService {
// CreateWallet
rpc CreateWallet(CreateWalletReq) returns (OKResp);
// DepositFunds - [] []
rpc DepositFunds(WalletTransactionReq) returns (OKResp);
// WithdrawFunds - []
rpc WithdrawFunds(WalletTransactionReq) returns (OKResp);
// FreezeFunds - [] []
rpc FreezeFunds(WalletTransactionReq) returns (OKResp);
// UnfreezeFunds - []
rpc UnfreezeFunds(WalletTransactionReq) returns (OKResp);
// AppendToFreeze - [] (order_id)
rpc AppendToFreeze(WalletTransactionReq) returns (OKResp);
// RollbackFreeze - [] [] []
rpc RollbackFreeze(WalletTransactionReq) returns (OKResp);
// CancelFreeze - [] []
rpc CancelFreeze(WalletTransactionReq) returns (OKResp);
// TransferToRestrictedFunds - []使 []
rpc TransferToRestrictedFunds(WalletTransactionReq) returns (OKResp);
// SettleRestrictedFunds - T+N
rpc SettleRestrictedFunds(NoneReq) returns (OKResp);
// QueryBalance ->
rpc QueryBalance(QueryBalanceByDateReq) returns (QueryBalanceByDateResp);
}
// ->
//
//
// ========== ===========
service InventoryService {}
// ========== ===========
service ProductService {}
// ========== ===========
service SubscriptionService {}