Commit aa31e5ee authored by shajiaiming's avatar shajiaiming

托管币种添加时加入币种名称

parent 30865711
...@@ -14,6 +14,7 @@ type Fee struct { ...@@ -14,6 +14,7 @@ type Fee struct {
FeesType uint8 `json:"fees_type"` FeesType uint8 `json:"fees_type"`
Fees float32 `json:"fees"` Fees float32 `json:"fees"`
TransactionFees float32 `json:"transaction_fees"` TransactionFees float32 `json:"transaction_fees"`
CoinName string `json:"coin_name"`
CoinInfo *Coin `gorm:"foreignkey:Cid" json:"coin,omitempty"` CoinInfo *Coin `gorm:"foreignkey:Cid" json:"coin,omitempty"`
} }
...@@ -73,6 +74,7 @@ func AddFee(data map[string]interface{}) (error) { ...@@ -73,6 +74,7 @@ func AddFee(data map[string]interface{}) (error) {
fee := Fee{ fee := Fee{
Cid: data["cid"].(int), Cid: data["cid"].(int),
PlatformId: data["platform_id"].(int), PlatformId: data["platform_id"].(int),
CoinName: data["coin_name"].(string),
} }
if err := db.Create(&fee).Error; err != nil { if err := db.Create(&fee).Error; err != nil {
return err return err
......
...@@ -4,7 +4,6 @@ import ( ...@@ -4,7 +4,6 @@ import (
"bwallet/pkg/errno" "bwallet/pkg/errno"
"bwallet/pkg/handler" "bwallet/pkg/handler"
"bwallet/pkg/util" "bwallet/pkg/util"
"bwallet/service/coin_service"
"bwallet/service/fee_service" "bwallet/service/fee_service"
"github.com/Unknwon/com" "github.com/Unknwon/com"
"github.com/astaxie/beego/validation" "github.com/astaxie/beego/validation"
...@@ -24,42 +23,13 @@ func GetTransactionFee(c *gin.Context) { ...@@ -24,42 +23,13 @@ func GetTransactionFee(c *gin.Context) {
return return
} }
coinService := coin_service.Coin{ feeService := fee_service.Fee{
Name: name, PlatformId: platform_id,
PageNum: util.GetPage(c), CoinName: name,
PageSize: util.GetLimit(c), PageNum: util.GetPage(c),
PageSize: util.GetLimit(c),
} }
total, err := coinService.Count()
if err != nil || 0 == total {
handler.SendResponse(c, errno.ErrCountCoin, nil)
return
}
coins, err := coinService.GetAll()
if err != nil {
handler.SendResponse(c, errno.InternalServerError, nil)
return
}
feeService := fee_service.Fee{}
if name == "BBB" {
feeService = fee_service.Fee{
PlatformId: platform_id,
Cid: coins[1].ID,
PageNum: util.GetPage(c),
PageSize: util.GetLimit(c),
}
} else {
feeService = fee_service.Fee{
PlatformId: platform_id,
Cid: coins[0].ID,
PageNum: util.GetPage(c),
PageSize: util.GetLimit(c),
}
}
total_fee, err_fee := feeService.Count() total_fee, err_fee := feeService.Count()
if err_fee != nil || 0 == total_fee { if err_fee != nil || 0 == total_fee {
handler.SendResponse(c, errno.ErrCountCoin, nil) handler.SendResponse(c, errno.ErrCountCoin, nil)
......
...@@ -130,9 +130,12 @@ func AddRecommendCoin(c *gin.Context) { ...@@ -130,9 +130,12 @@ func AddRecommendCoin(c *gin.Context) {
continue continue
} }
coin, _ := coinService.Get()
feeService := fee_service.Fee{ feeService := fee_service.Fee{
Cid: coin_id, Cid: coin_id,
PlatformId: platform_id, PlatformId: platform_id,
CoinName: coin.Name,
} }
feeService.Add() feeService.Add()
......
...@@ -11,6 +11,7 @@ type Fee struct { ...@@ -11,6 +11,7 @@ type Fee struct {
FeesType uint8 FeesType uint8
Fees float32 Fees float32
TransactionFees float32 TransactionFees float32
CoinName string
PageNum int PageNum int
PageSize int PageSize int
...@@ -41,6 +42,7 @@ func (c *Fee) Add() error { ...@@ -41,6 +42,7 @@ func (c *Fee) Add() error {
fee := map[string]interface{}{ fee := map[string]interface{}{
"cid": c.Cid, "cid": c.Cid,
"platform_id": c.PlatformId, "platform_id": c.PlatformId,
"coin_name": c.CoinName,
} }
if err := models.AddFee(fee); err != nil { if err := models.AddFee(fee); err != nil {
...@@ -92,5 +94,9 @@ func (c *Fee) getMaps() (map[string]interface{}) { ...@@ -92,5 +94,9 @@ func (c *Fee) getMaps() (map[string]interface{}) {
maps["cid"] = c.Cid maps["cid"] = c.Cid
} }
if c.CoinName != "" {
maps["coin_name"] = c.CoinName
}
return maps return maps
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment