This commit is contained in:
2025-03-28 09:16:08 +08:00
parent ee148ed144
commit 31164fb5f4
3 changed files with 39 additions and 17 deletions

View File

@ -26,6 +26,7 @@ import (
"go-admin/app/admin/models" "go-admin/app/admin/models"
"go-admin/app/admin/service/dto" "go-admin/app/admin/service/dto"
"go-admin/app/admin/service/messages"
"go-admin/common/actions" "go-admin/common/actions"
cDto "go-admin/common/dto" cDto "go-admin/common/dto"
) )
@ -1378,23 +1379,37 @@ func (e *LinePreOrder) SetBinanceMarginType(req *dto.MarginTypeReq, users []mode
"marginType": req.MarginType, "marginType": req.MarginType,
"symbol": s, "symbol": s,
} }
resp, _, err := client.SendFuturesRequestAuth("/fapi/v1/marginType", "POST", params) _, _, err := client.SendFuturesRequestAuth("/fapi/v1/marginType", "POST", params)
if err != nil { if err != nil {
*errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, err.Error())) var dataMap map[string]interface{}
continue 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()))
var dataMap map[string]interface{} continue
if err := sonic.Unmarshal(resp, &dataMap); err != nil { }
*errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, err.Error())) code, ok := dataMap["code"]
continue if !ok {
} *errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, dataMap["message"]))
code, ok := dataMap["code"] continue
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
if code.(float64) != 200 { codeInt := utility.ToInt(code)
*errs = append(*errs, fmt.Errorf("api_id:%d 交易对:%s 设置仓位失败:%+v", user.Id, s, dataMap["message"]))
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 continue
} }
} }

View File

@ -0,0 +1,7 @@
package messages
var BinanceFutureMessage = map[int]string{
-4168: "多资产模式下无法使用逐仓",
-4167: "因有交易对在逐仓模式,无法切换多资产模式",
-4046: "不需要切换仓位模式。",
}

View File

@ -45,7 +45,7 @@ func GetSpotSymbols() (map[string]models.TradeSet, []string, error) {
tradeSet.MaxQty = utility.StringAsFloat(filter.MaxQty) tradeSet.MaxQty = utility.StringAsFloat(filter.MaxQty)
case "MARKET_LOT_SIZE": case "MARKET_LOT_SIZE":
tradeSet.MarketMinQty = utility.StringAsFloat(filter.MinQty) tradeSet.MarketMinQty = utility.StringAsFloat(filter.MinQty)
tradeSet.MarketMinQty = utility.StringAsFloat(filter.MaxQty) tradeSet.MarketMaxQty = utility.StringAsFloat(filter.MaxQty)
} }
} }