Commit b4ab5e9e authored by shajiaiming's avatar shajiaiming

设备托管手续费优化

parent 646dc158
......@@ -15,6 +15,7 @@ type Fee struct {
Fees float32 `json:"fees"`
TransactionFees float32 `json:"transaction_fees"`
CoinName string `json:"coin_name"`
TransferType uint8 `json:"transfer_type"`
CoinInfo *Coin `gorm:"foreignkey:Cid" json:"coin,omitempty"`
}
......@@ -79,6 +80,7 @@ func AddFee(data map[string]interface{}) (error) {
Cid: data["cid"].(int),
PlatformId: data["platform_id"].(int),
CoinName: data["coin_name"].(string),
TransferType: data["transfer_type"].(uint8),
}
if err := db.Create(&fee).Error; err != nil {
return err
......
......@@ -18,6 +18,8 @@ func GetTransactionFee(c *gin.Context) {
name := c.DefaultQuery("name", "")
valid.Required(name, "name").Message("币种不能为空")
transfer_type := com.StrTo(c.DefaultQuery("transfer_type", "1")).MustUint8()
if valid.HasErrors() {
handler.SendResponse(c, valid.Errors[0], nil)
return
......@@ -26,16 +28,22 @@ func GetTransactionFee(c *gin.Context) {
feeService := fee_service.Fee{
PlatformId: platform_id,
CoinName: name,
TransferType: transfer_type,
PageNum: util.GetPage(c),
PageSize: util.GetLimit(c),
}
total_fee, err_fee := feeService.Count()
if err_fee != nil || 0 == total_fee {
if err_fee != nil {
handler.SendResponse(c, errno.ErrCountCoin, nil)
return
}
if 0 == total_fee {
handler.SendResponse(c, errno.ErrCoinNotFound, nil)
return
}
fee, err := feeService.Search()
if err != nil {
handler.SendResponse(c, errno.ErrCountCoin, nil)
......
......@@ -37,7 +37,7 @@ func GetTransactionCoins(c *gin.Context) {
}
vals := []string{}
for _,value := range fees {
for _, value := range fees {
if "" == value.CoinName {
continue
}
......@@ -61,8 +61,11 @@ func GetTransactionFees(c *gin.Context) {
}
}
transfer_type := com.StrTo(c.DefaultQuery("transfer_type", "1")).MustUint8()
feeService := fee_service.Fee{
PlatformId: platform_id,
TransferType: transfer_type,
PageNum: util.GetPage(c),
PageSize: util.GetLimit(c),
}
......
......@@ -121,9 +121,11 @@ func AddRecommendCoin(c *gin.Context) {
recommendCoinService.Add()
if 2 == recommend_coin.Type {
for i := 1; i < 3; i++ {
feeValidate := fee_service.Fee{
PlatformId: platform_id,
Cid: coin_id,
TransferType: uint8(i),
}
total_fee, err := feeValidate.Count()
if err != nil || total_fee > 0 {
......@@ -136,11 +138,13 @@ func AddRecommendCoin(c *gin.Context) {
Cid: coin_id,
PlatformId: platform_id,
CoinName: coin.Name,
TransferType: uint8(i),
}
feeService.Add()
}
}
}
handler.SendResponse(c, nil, nil)
......
......@@ -12,6 +12,7 @@ type Fee struct {
Fees float32
TransactionFees float32
CoinName string
TransferType uint8
PageNum int
PageSize int
......@@ -43,6 +44,7 @@ func (c *Fee) Add() error {
"cid": c.Cid,
"platform_id": c.PlatformId,
"coin_name": c.CoinName,
"transfer_type": c.TransferType,
}
if err := models.AddFee(fee); err != nil {
......@@ -117,5 +119,9 @@ func (c *Fee) getMaps() (map[string]interface{}) {
maps["coin_name"] = c.CoinName
}
if c.TransferType != 0 {
maps["transfer_type"] = c.TransferType
}
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