1
This commit is contained in:
@ -26,6 +26,7 @@ import (
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/app/admin/service/dto"
|
||||
"go-admin/app/admin/service/messages"
|
||||
"go-admin/common/actions"
|
||||
cDto "go-admin/common/dto"
|
||||
)
|
||||
@ -1378,23 +1379,37 @@ func (e *LinePreOrder) SetBinanceMarginType(req *dto.MarginTypeReq, users []mode
|
||||
"marginType": req.MarginType,
|
||||
"symbol": s,
|
||||
}
|
||||
resp, _, err := client.SendFuturesRequestAuth("/fapi/v1/marginType", "POST", params)
|
||||
_, _, err := client.SendFuturesRequestAuth("/fapi/v1/marginType", "POST", params)
|
||||
if err != nil {
|
||||
*errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, err.Error()))
|
||||
continue
|
||||
}
|
||||
var dataMap map[string]interface{}
|
||||
if err := sonic.Unmarshal(resp, &dataMap); err != nil {
|
||||
*errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, err.Error()))
|
||||
continue
|
||||
}
|
||||
code, ok := dataMap["code"]
|
||||
if !ok {
|
||||
*errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, dataMap["message"]))
|
||||
continue
|
||||
}
|
||||
if code.(float64) != 200 {
|
||||
*errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, dataMap["message"]))
|
||||
var dataMap map[string]interface{}
|
||||
if err := sonic.Unmarshal([]byte(err.Error()), &dataMap); err != nil {
|
||||
*errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, err.Error()))
|
||||
continue
|
||||
}
|
||||
code, ok := dataMap["code"]
|
||||
if !ok {
|
||||
*errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, dataMap["message"]))
|
||||
continue
|
||||
}
|
||||
|
||||
if code.(float64) != 200 {
|
||||
var msg string
|
||||
codeInt := utility.ToInt(code)
|
||||
|
||||
if codeInt == -4046 {
|
||||
continue
|
||||
}
|
||||
|
||||
if val, ok := messages.BinanceFutureMessage[codeInt]; ok {
|
||||
msg = val
|
||||
} else {
|
||||
msg = dataMap["message"].(string)
|
||||
}
|
||||
|
||||
*errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, msg))
|
||||
continue
|
||||
}
|
||||
// *errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, err.Error()))
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
7
app/admin/service/messages/binance_message.go
Normal file
7
app/admin/service/messages/binance_message.go
Normal file
@ -0,0 +1,7 @@
|
||||
package messages
|
||||
|
||||
var BinanceFutureMessage = map[int]string{
|
||||
-4168: "多资产模式下无法使用逐仓",
|
||||
-4167: "因有交易对在逐仓模式,无法切换多资产模式",
|
||||
-4046: "不需要切换仓位模式。",
|
||||
}
|
||||
Reference in New Issue
Block a user