Commit b4ab5e9e authored by shajiaiming's avatar shajiaiming

设备托管手续费优化

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