Files
exchange_go/pkg/udunhelper/udunmodel.go

154 lines
5.7 KiB
Go
Raw Permalink Normal View History

2025-02-06 11:14:33 +08:00
package udunhelper
type VerifyRequest struct {
MerchantId string `json:"merchantId"`
MainCoinType string `json:"mainCoinType"`
Address string `json:"address"`
}
type CallbackRequest struct {
MerchantId string `json:"merchantId"` //商户号
MainCoinType int `json:"mainCoinType"` //主幣種編號,使用獲取商戶幣種信息接口
CallUrl string `json:"callUrl"` //回調地址,通過該接口創建的地址,以後關於該地址的充幣信息會通過您指定的回調地址通知您
WalletId string `json:"walletId"` //錢包編號,默認根據主錢包生成地址,可不填写
Alias string `json:"alias"` //地址別名,可不填写
}
type WithdrawRequest struct {
/**
{
"address":"raadSxrUhG5EQVCY75CSGaVLWCeXd6yH6s",
"amount":"0.11",
"merchantId":"100109",
"mainCoinType":"144",
"coinType":"144",
"callUrl":"http://localhost:8080/mch/callBack",
"businessId":"15",
"memo":"10112"
}
*/
Address string `json:"address"` //提币地址
Amount string `json:"amount"` //提币数量
MerchantId string `json:"merchantId"` //商户号
MainCoinType string `json:"mainCoinType"` //主幣種編號,使用獲取商戶幣種信息接口
CoinType string `json:"coinType"` //子幣種編號,使用獲取商戶幣種信息接口
CallUrl string `json:"callUrl"` //回調地址通過該callUrl告知您該筆提幣交易的狀態
BusinessId string `json:"businessId"` //業務編號,必須保證該字段在系統內唯一,如果重復,則該筆提幣錢包將不會進行接收
WalletId string `json:"-"`
Memo string `json:"memo"` //備註,XRP和EOS這兩種幣的提幣申請該字段可選其他類型幣種不填
}
type BaseRequest struct {
Timestamp int64 `json:"timestamp"`
Nonce int `json:"nonce"`
}
type HttpRequest struct {
Timestamp int64 `json:"timestamp"` //时间戳
Nonce int `json:"nonce"` //随机数
Sign string `json:"sign"` //签名
Body string `json:"body"` //请求body
}
type BaseRes struct {
Code int `json:"code"` //200才是返回成功调用
Message string `json:"message"` //
}
type BaseCoinsMerchant struct {
Code int `json:"code"` //200才是返回成功调用
Message string `json:"message"` //
Data []CoinsMerchant `json:"data"` //
}
//CoinsMerchant 商家持仓的币种信息
type CoinsMerchant struct {
MainCoinType string `json:"mainCoinType"` //主幣種類型
CoinType string `json:"coinType"` // 幣種類型
Symbol string `json:"symbol"` //BTC
Name string `json:"name"` //幣種別名,BTC
Logo string `json:"logo"` //幣種log地址
CoinName string `json:"coinName"` //幣種全稱,Bitcoin
MainSymbol string `json:"mainSymbol"` //主幣種單位
Decimals string `json:"decimals"` //幣種精度,8
TokenStatus int `json:"tokenStatus"` //0 主幣 1代幣
Balance int64 `json:"balance"` //幣種余額
}
type BaseCoinAddress struct {
Code int `json:"code"` //200才是返回成功调用
Message string `json:"message"` //
Data CoinAddress `json:"data"` //
}
//CoinAddress 地址返回
type CoinAddress struct {
CoinType int `json:"coinType"` // 幣種類型
Address string `json:"address"` //地址
}
type CallBackBase struct {
TimeStamp int64 `json:"timestamp"`
Nonce int `json:"nonce"`
Sign string `json:"sign"`
Body CallBackRes `json:"body"` //
}
//CallBackRes 回调结构体
type CallBackRes struct {
Address string `json:"address"` //地址
Amount string `json:"amount"` //交易數量,根據幣種精度獲取實際金額,實際金額=amount/pow(10,decimals)即實際金額等於amount除以10的decimals次方
Fee string `json:"fee"` //礦工費,根據幣種精度獲取實際金額,實際金額獲取同上
Decimals string `json:"decimals"` //幣種精度
CoinType string `json:"coinType"` //子幣種編號,使用獲取商戶幣種信息接口
MainCoinType string `json:"mainCoinType"` //主幣種類型
BusinessId string `json:"businessId"` //業務編號,提幣回調時為提幣請求時傳入的,充幣回調無值
BlockHigh string `json:"blockHigh"` //區塊高度
TradeId string `json:"tradeId"` //業務流水號
TxId string `json:"txid"` //區塊鏈交易哈希
Memo string `json:"memo"` //備註XRP和EOS使用獲取商戶幣種信息接口這2種類型幣的充提幣可能有值
Status int `json:"status"` //狀態,0待審核,1審核成功,2審核駁回,3交易成功,4交易失敗
TradeType int `json:"tradeType"` //交易類型,1充幣回調,2提幣回調
}
func getWithDrawMsg(code int) string {
msg := ""
switch code {
case 200:
msg = "提币成功"
case 523:
msg = "参数为空"
case 581:
msg = "无效的提币金额"
case 4005:
msg = "非法参数"
case 4034:
msg = "未找到该币种信息"
case 4162:
msg = "签名异常"
case 4163:
msg = "签名错误"
case 4169:
msg = "商户已被禁用"
case 4183:
msg = "到账地址异常"
case 4193:
msg = "EOS金额小数点后超过4位长度"
case 4214:
msg = "暂无可用的币种"
case 4226:
msg = "商户普通账户被禁用"
case 4261:
msg = "商户管理员账户被禁用"
case 4284:
msg = "商户不存在"
case 4288:
msg = "业务编号重复,请勿重复申请"
case 4598:
msg = "传入body中的list对象中的所有merchantId必须保持一致"
case 4001:
msg = "商户不存在"
}
return msg
}