Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bwallet
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Go
bwallet
Commits
9f66803a
Commit
9f66803a
authored
Dec 29, 2021
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into develop
parents
a674b6bb
fbb06b8c
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
409 additions
and
66 deletions
+409
-66
coin_gas.go
models/coin_gas.go
+88
-0
cron.go
pkg/cron/cron.go
+3
-4
errno.go
pkg/errno/errno.go
+7
-0
coin_gas.go
routers/api/backend/coin_gas.go
+154
-0
supported_chain.go
routers/api/backend/supported_chain.go
+28
-38
router.go
routers/router.go
+5
-0
coin_gas.go
service/coin_gas_service/coin_gas.go
+92
-9
red_packet.go
service/red_packet_service/red_packet.go
+12
-10
supported_chain.go
service/supported_chain_service/supported_chain.go
+9
-3
coin_gas.go
validate_service/coin_gas.go
+9
-0
supported_chain.go
validate_service/supported_chain.go
+1
-1
wallet.go
validate_service/wallet.go
+1
-1
No files found.
models/coin_gas.go
0 → 100644
View file @
9f66803a
package
models
import
(
"bwallet/pkg/setting"
"github.com/jinzhu/gorm"
)
type
CoinGas
struct
{
CoinName
string
`json:"coin_name"`
Low
string
`json:"low"`
Average
string
`json:"average"`
High
string
`json:"high"`
Switch
int8
`json:"switch"`
}
func
(
c
CoinGas
)
TableName
()
string
{
return
setting
.
DatabaseSetting
.
Name_Sources
+
".wallet_coin_gas"
}
func
GetCoinsGas
(
maps
interface
{})
([]
*
CoinGas
,
error
)
{
var
ct
[]
*
CoinGas
err
:=
db
.
Where
(
maps
)
.
Find
(
&
ct
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
nil
,
err
}
return
ct
,
nil
}
func
AddCoinGas
(
data
map
[
string
]
interface
{})
(
error
)
{
CoinGas
:=
CoinGas
{
CoinName
:
data
[
"coin_name"
]
.
(
string
),
Low
:
data
[
"low"
]
.
(
string
),
Average
:
data
[
"average"
]
.
(
string
),
High
:
data
[
"high"
]
.
(
string
),
Switch
:
data
[
"switch"
]
.
(
int8
),
}
if
err
:=
db
.
Debug
()
.
Create
(
&
CoinGas
)
.
Error
;
err
!=
nil
{
return
err
}
return
nil
}
func
EditCoinGas
(
maps
interface
{},
data
interface
{})
error
{
if
err
:=
db
.
Model
(
&
CoinGas
{})
.
Where
(
maps
)
.
Updates
(
data
)
.
Error
;
err
!=
nil
{
return
err
}
return
nil
}
func
DeleteCoinGas
(
id
int
)
error
{
if
err
:=
db
.
Where
(
"id = ?"
,
id
)
.
Delete
(
CoinGas
{})
.
Error
;
err
!=
nil
{
return
err
}
return
nil
}
func
GetCoinGas
(
coin_name
string
)
(
*
CoinGas
,
error
)
{
var
gas
CoinGas
err
:=
db
.
Where
(
"coin_name = ? and switch = ?"
,
coin_name
,
1
)
.
First
(
&
gas
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
nil
,
err
}
err
=
db
.
Model
(
&
gas
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
nil
,
err
}
return
&
gas
,
nil
}
func
Exist
(
coin_name
string
)
(
bool
,
error
)
{
var
coinGas
CoinGas
err
:=
db
.
Where
(
"coin_name = ?"
,
coin_name
)
.
First
(
&
coinGas
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
false
,
err
}
if
coinGas
.
CoinName
!=
""
{
return
true
,
nil
}
return
false
,
nil
}
pkg/cron/cron.go
View file @
9f66803a
package
cron
import
(
"bwallet/service/coin_gas_service"
"bwallet/service/red_packet_service"
"github.com/robfig/cron"
)
...
...
@@ -11,9 +10,9 @@ var c *cron.Cron
func
Setup
()
{
c
=
cron
.
New
()
c
.
AddFunc
(
"* * * * * *"
,
func
()
{
coin_gas_service
.
TokenView
()
})
//
c.AddFunc("* * * * * *", func() {
//
coin_gas_service.TokenView()
//
})
c
.
AddFunc
(
"* * * * * *"
,
func
()
{
red_packet_service
.
UpdateReceive
()
...
...
pkg/errno/errno.go
View file @
9f66803a
...
...
@@ -214,6 +214,13 @@ var (
ErrDeleteCoinTicker
=
&
Errno
{
Code
:
20104
,
Message
:
"The coin ticker delete error."
}
ErrExistCoinTicker
=
&
Errno
{
Code
:
20105
,
Message
:
"The coin ticker already exists."
}
// coin gas errors
ErrCoinGasNotFound
=
&
Errno
{
Code
:
20101
,
Message
:
"The coin gas was not found."
}
ErrAddCoinGas
=
&
Errno
{
Code
:
20102
,
Message
:
"The coin gas add error."
}
ErrUpdateCoinGas
=
&
Errno
{
Code
:
20103
,
Message
:
"The coin gas update error."
}
ErrDeleteCoinGas
=
&
Errno
{
Code
:
20104
,
Message
:
"The coin gas delete error."
}
ErrExistCoinGas
=
&
Errno
{
Code
:
20105
,
Message
:
"The coin gas already exists."
}
// red packet errors
ErrRedPacketNotFound
=
&
Errno
{
Code
:
20101
,
Message
:
"The red packet was not found."
}
ErrCountRedPacket
=
&
Errno
{
Code
:
20102
,
Message
:
"The red packet statistic error."
}
...
...
routers/api/backend/coin_gas.go
0 → 100644
View file @
9f66803a
package
backend
import
(
"bwallet/pkg/errno"
"bwallet/pkg/handler"
"bwallet/pkg/util"
"bwallet/service/coin_gas_service"
"bwallet/validate_service"
"github.com/Unknwon/com"
"github.com/astaxie/beego/validation"
"github.com/gin-gonic/gin"
"strings"
)
func
CoinsGas
(
c
*
gin
.
Context
)
{
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
user
,
_
:=
util
.
ParseToken
(
token
)
group
:=
user
.
UserInfo
.
Group
if
(
"administrator"
!=
group
)
{
handler
.
SendResponse
(
c
,
errno
.
ErrUserAuthIncorrect
,
nil
)
return
}
CoinGasService
:=
coin_gas_service
.
CoinGas
{}
coins_gas
,
err
:=
CoinGasService
.
GetAll
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
InternalServerError
,
nil
)
return
}
handler
.
SendResponse
(
c
,
nil
,
coins_gas
)
}
func
AddCoinGas
(
c
*
gin
.
Context
)
{
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
user
,
_
:=
util
.
ParseToken
(
token
)
group
:=
user
.
UserInfo
.
Group
if
(
"administrator"
!=
group
)
{
handler
.
SendResponse
(
c
,
errno
.
ErrUserAuthIncorrect
,
nil
)
return
}
coin_gas
:=
validate_service
.
CoinGas
{}
c
.
ShouldBindJSON
(
&
coin_gas
)
if
ok
,
errors
:=
validate_service
.
ValidateInputs
(
coin_gas
);
!
ok
{
for
_
,
err
:=
range
errors
{
handler
.
SendResponse
(
c
,
errno
.
ErrBind
,
strings
.
Join
(
err
,
" "
))
return
}
}
CoinGasService
:=
coin_gas_service
.
CoinGas
{
CoinName
:
coin_gas
.
CoinName
,
Low
:
coin_gas
.
Low
,
Average
:
coin_gas
.
Average
,
High
:
coin_gas
.
High
,
Switch
:
coin_gas
.
Switch
,
}
if
err
:=
CoinGasService
.
Add
();
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrAddCoinTicker
,
nil
)
return
}
handler
.
SendResponse
(
c
,
nil
,
nil
)
}
func
UpdateCoinGas
(
c
*
gin
.
Context
)
{
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
user
,
_
:=
util
.
ParseToken
(
token
)
group
:=
user
.
UserInfo
.
Group
if
(
"administrator"
!=
group
)
{
handler
.
SendResponse
(
c
,
errno
.
ErrUserAuthIncorrect
,
nil
)
return
}
coin_gas
:=
validate_service
.
CoinGas
{}
c
.
ShouldBindJSON
(
&
coin_gas
)
if
ok
,
errors
:=
validate_service
.
ValidateInputs
(
coin_gas
);
!
ok
{
for
_
,
err
:=
range
errors
{
handler
.
SendResponse
(
c
,
errno
.
ErrBind
,
strings
.
Join
(
err
,
" "
))
return
}
}
CoinGasValidateService
:=
coin_gas_service
.
CoinGas
{
CoinName
:
coin_gas
.
CoinName
,
}
exist
,
_
:=
CoinGasValidateService
.
Exist
()
if
!
exist
{
handler
.
SendResponse
(
c
,
errno
.
ErrCoinGasNotFound
,
nil
)
return
}
CoinGasService
:=
coin_gas_service
.
CoinGas
{
Low
:
coin_gas
.
Low
,
Average
:
coin_gas
.
Average
,
High
:
coin_gas
.
High
,
Switch
:
coin_gas
.
Switch
,
}
if
err
:=
CoinGasService
.
Edit
();
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrAddCoinGas
,
nil
)
return
}
handler
.
SendResponse
(
c
,
nil
,
nil
)
}
func
DeleteCoinGas
(
c
*
gin
.
Context
)
{
token
:=
c
.
Request
.
Header
.
Get
(
"Token"
)
user
,
_
:=
util
.
ParseToken
(
token
)
group
:=
user
.
UserInfo
.
Group
if
(
"administrator"
!=
group
)
{
handler
.
SendResponse
(
c
,
errno
.
ErrUserAuthIncorrect
,
nil
)
return
}
id
:=
com
.
StrTo
(
c
.
DefaultQuery
(
"id"
,
"0"
))
.
MustInt
()
valid
:=
validation
.
Validation
{}
valid
.
Min
(
id
,
1
,
"id"
)
.
Message
(
"ID必须大于0"
)
if
valid
.
HasErrors
()
{
handler
.
SendResponse
(
c
,
errno
.
ErrValidation
,
nil
)
return
}
CoinGasService
:=
coin_gas_service
.
CoinGas
{
Id
:
id
,
}
exists
,
err
:=
CoinGasService
.
Exist
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrValidation
,
nil
)
return
}
if
!
exists
{
handler
.
SendResponse
(
c
,
errno
.
ErrCoinGasNotFound
,
nil
)
return
}
err
=
CoinGasService
.
Delete
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrDeleteCoinTicker
,
nil
)
return
}
handler
.
SendResponse
(
c
,
nil
,
nil
)
}
routers/api/backend/supported_chain.go
View file @
9f66803a
...
...
@@ -10,6 +10,7 @@ import (
"github.com/Unknwon/com"
"github.com/astaxie/beego/validation"
"github.com/gin-gonic/gin"
"strconv"
"strings"
)
...
...
@@ -77,51 +78,40 @@ func AddSupportedChain(c *gin.Context) {
}
}
coinService
:=
coin_service
.
Coin
{
Name
:
chain
.
CoinName
,
Chain
:
strings
.
ToUpper
(
chain
.
CoinName
),
var
platform_id
int
platform_id
=
user
.
UserInfo
.
PlatformId
if
(
"administrator"
==
group
)
{
if
chain
.
PlatformId
!=
0
{
platform_id
=
chain
.
PlatformId
}
}
coin
,
err
:=
coinService
.
Find
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrCoinNotFound
,
nil
)
return
}
if
""
==
coin
.
Name
{
for
_
,
id
:=
range
strings
.
Split
(
chain
.
CoinIds
,
","
)
{
if
id
==
""
{
continue
}
coin_id
,
err
:=
strconv
.
Atoi
(
id
)
if
(
nil
!=
err
)
{
continue
}
coinService
:=
coin_service
.
Coin
{
Name
:
chain
.
CoinName
,
Chain
:
"BTY"
,
Id
:
coin_id
,
}
coin
,
err
=
coinService
.
Find
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrCoinNotFound
,
nil
)
return
exists
,
err
:=
coinService
.
ExistById
()
if
err
!=
nil
||
!
exists
{
continue
}
}
if
""
==
coin
.
Name
{
handler
.
SendResponse
(
c
,
errno
.
ErrCoinNotFound
,
nil
)
return
}
chainService
:=
supported_chain_service
.
SupportedChain
{
PlatformId
:
chain
.
PlatformId
,
CoinId
:
coin
.
ID
,
}
total
,
err
:=
chainService
.
Count
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrCountCoin
,
nil
)
return
}
if
0
!=
total
{
handler
.
SendResponse
(
c
,
errno
.
ErrExistCoin
,
nil
)
return
}
supportedChainValidate
:=
supported_chain_service
.
SupportedChain
{
CoinId
:
coin_id
,
PlatformId
:
platform_id
,
}
total
,
err
:=
supportedChainValidate
.
Count
()
if
err
!=
nil
||
total
>
0
{
continue
}
if
err
:=
chainService
.
Add
();
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrAddSupportedChain
,
nil
)
return
supportedChainValidate
.
Add
()
}
handler
.
SendResponse
(
c
,
nil
,
nil
)
...
...
routers/router.go
View file @
9f66803a
...
...
@@ -161,6 +161,11 @@ func InitRouter() *gin.Engine {
api
.
POST
(
"/manager"
,
backend
.
AddManager
)
api
.
PUT
(
"/manager"
,
backend
.
EditManager
)
api
.
DELETE
(
"/manager"
,
backend
.
DeleteManager
)
api
.
GET
(
"/coins-gas"
,
backend
.
CoinsGas
)
api
.
POST
(
"/coin-gas"
,
backend
.
AddCoinGas
)
api
.
PUT
(
"/coin-gas"
,
backend
.
UpdateCoinGas
)
api
.
DELETE
(
"/coin-gas"
,
backend
.
DeleteCoinGas
)
}
return
r
...
...
service/coin_gas_service/coin_gas.go
View file @
9f66803a
package
coin_gas_service
import
(
"bwallet/models"
"bwallet/pkg/errno"
"bwallet/pkg/gredis"
"bwallet/pkg/util"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
...
...
@@ -26,7 +28,7 @@ type Data struct {
func
GetTransactionGas
(
name
string
)
(
map
[
string
]
interface
{},
error
)
{
data
:=
make
(
map
[
string
]
interface
{})
items_fee
:=
[]
string
{
"BTC"
,
"BCH"
,
"LTC"
,
"ZEC"
,
"ZCASH"
,
"DCR"
,
"NEO"
,
"TRX"
,
"ATOM"
,
"BTY"
,
"ETC"
,
"ETH"
,
"HT"
,
"ETHTOKEN"
,
"BNB"
}
items_fee
:=
[]
string
{
"BTC"
,
"BCH"
,
"LTC"
,
"ZEC"
,
"ZCASH"
,
"DCR"
,
"NEO"
,
"TRX"
,
"ATOM"
,
"BTY"
,
"ETC"
,
"ETH"
,
"HT"
,
"ETHTOKEN"
,
"BNB"
,
"DOGE"
,
"YCC"
}
_
,
found_fee
:=
util
.
Contains
(
items_fee
,
strings
.
ToUpper
(
name
))
...
...
@@ -34,11 +36,27 @@ func GetTransactionGas(name string) (map[string]interface{}, error) {
return
nil
,
errno
.
ErrCoinNotFound
}
var
coin_gas
*
models
.
CoinGas
coin_gas
,
err
:=
models
.
GetCoinGas
(
name
)
if
err
!=
nil
{
return
nil
,
err
}
if
coin_gas
.
CoinName
!=
""
{
data
[
"name"
]
=
strings
.
ToUpper
(
coin_gas
.
CoinName
)
data
[
"low"
]
=
coin_gas
.
Low
data
[
"average"
]
=
coin_gas
.
Average
data
[
"high"
]
=
coin_gas
.
High
return
data
,
nil
}
if
"ETC"
==
strings
.
ToUpper
(
name
)
||
"HT"
==
strings
.
ToUpper
(
name
)
{
fee
,
_
:=
gredis
.
HashGet
(
"ETC_GAS"
,
"gasPrice"
,
3
)
low
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
/
1000000000
*
30000
*
0.000000001
*
30
*
1.1
,
8
)
average
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
/
1000000000
*
30000
*
0.000000001
*
30
*
1.2
,
8
)
high
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
/
1000000000
*
30000
*
0.000000001
*
30
*
1.3
,
8
)
high
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
/
1000000000
*
30000
*
0.000000001
*
30
*
6
,
8
)
data
[
"name"
]
=
strings
.
ToUpper
(
name
)
data
[
"low"
]
=
low
...
...
@@ -49,9 +67,9 @@ func GetTransactionGas(name string) (map[string]interface{}, error) {
}
}
else
if
"ETH"
==
strings
.
ToUpper
(
name
)
{
fee
,
_
:=
gredis
.
HashGet
(
strings
.
ToUpper
(
name
)
+
"_GAS"
,
"gasPrice"
,
3
)
low
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
/
1000000000
*
21
000
*
0.000000001
,
8
)
average
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
/
1000000000
*
21
000
*
0.000000001
*
1.1
,
8
)
high
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
/
1000000000
*
21000
*
0.000000001
*
1.2
,
8
)
low
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
/
1000000000
*
33
000
*
0.000000001
,
8
)
average
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
/
1000000000
*
33
000
*
0.000000001
*
1.1
,
8
)
high
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
/
1000000000
*
33000
*
0.000000001
*
6
,
8
)
data
[
"name"
]
=
strings
.
ToUpper
(
name
)
data
[
"low"
]
=
low
...
...
@@ -67,9 +85,9 @@ func GetTransactionGas(name string) (map[string]interface{}, error) {
data
[
"high"
]
=
"0.002"
}
else
if
"ETHTOKEN"
==
strings
.
ToUpper
(
name
)
{
fee
,
_
:=
gredis
.
HashGet
(
"ETH_GAS"
,
"gasPrice"
,
3
)
low
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
/
1000000000
*
8
0000
*
0.000000001
,
8
)
average
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
/
1000000000
*
8
0000
*
0.000000001
*
1.1
,
8
)
high
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
/
1000000000
*
80000
*
0.000000001
*
1.2
,
8
)
low
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
/
1000000000
*
13
0000
*
0.000000001
,
8
)
average
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
/
1000000000
*
13
0000
*
0.000000001
*
1.1
,
8
)
high
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
/
1000000000
*
130000
*
0.000000001
*
6
,
8
)
data
[
"name"
]
=
strings
.
ToUpper
(
name
)
data
[
"low"
]
=
low
...
...
@@ -82,7 +100,7 @@ func GetTransactionGas(name string) (map[string]interface{}, error) {
fee
,
_
:=
gredis
.
HashGet
(
strings
.
ToUpper
(
name
)
+
"_GAS"
,
"txFee"
,
3
)
low
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
*
1.1
,
8
)
average
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
*
1.2
,
8
)
high
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
*
1.3
,
8
)
high
:=
util
.
FormatFloat
(
util
.
ToFloat64
(
string
(
fee
))
*
6
,
8
)
data
[
"name"
]
=
strings
.
ToUpper
(
name
)
data
[
"low"
]
=
low
...
...
@@ -216,6 +234,10 @@ func TokenView() error {
gredis
.
HashSet
(
"DCR_GAS"
,
"txFee"
,
val
.
TxFee
,
3
)
gredis
.
HashSet
(
"DCR_GAS"
,
"time"
,
val
.
Time
,
3
)
}
if
"DOGE"
==
strings
.
ToUpper
(
val
.
Network
)
{
gredis
.
HashSet
(
"DOGE_GAS"
,
"txFee"
,
val
.
TxFee
,
3
)
gredis
.
HashSet
(
"DOGE_GAS"
,
"time"
,
val
.
Time
,
3
)
}
if
"ETC"
==
strings
.
ToUpper
(
val
.
Network
)
{
gredis
.
HashSet
(
"ETC_GAS"
,
"gasPrice"
,
val
.
GasPrice
,
3
)
gredis
.
HashSet
(
"ETC_GAS"
,
"time"
,
val
.
Time
,
3
)
...
...
@@ -229,3 +251,64 @@ func TokenView() error {
}
return
nil
}
type
CoinGas
struct
{
Id
int
CoinName
string
Low
string
Average
string
High
string
Switch
int8
}
func
(
g
*
CoinGas
)
GetAll
()
([]
*
models
.
CoinGas
,
error
)
{
coins_gas
,
err
:=
models
.
GetCoinsGas
(
g
.
getMaps
())
if
err
!=
nil
{
return
nil
,
err
}
return
coins_gas
,
nil
}
func
(
g
*
CoinGas
)
Add
()
error
{
CoinGas
:=
map
[
string
]
interface
{}{
"coin_name"
:
g
.
CoinName
,
"low"
:
g
.
Low
,
"average"
:
g
.
Average
,
"high"
:
g
.
High
,
"switch"
:
g
.
Switch
,
}
fmt
.
Println
(
CoinGas
)
if
err
:=
models
.
AddCoinGas
(
CoinGas
);
err
!=
nil
{
return
err
}
return
nil
}
func
(
g
*
CoinGas
)
Edit
()
error
{
return
models
.
EditCoinGas
(
g
.
getMaps
(),
map
[
string
]
interface
{}{
"low"
:
g
.
Low
,
"average"
:
g
.
Average
,
"high"
:
g
.
High
,
"switch"
:
g
.
Switch
,
})
}
func
(
g
*
CoinGas
)
Delete
()
error
{
return
models
.
DeleteCoinGas
(
g
.
Id
)
}
func
(
g
*
CoinGas
)
Exist
()
(
bool
,
error
)
{
return
models
.
Exist
(
g
.
CoinName
)
}
func
(
c
*
CoinGas
)
getMaps
()
(
map
[
string
]
interface
{})
{
maps
:=
make
(
map
[
string
]
interface
{})
if
c
.
CoinName
!=
""
{
maps
[
"coin_name"
]
=
c
.
CoinName
}
return
maps
}
service/red_packet_service/red_packet.go
View file @
9f66803a
...
...
@@ -85,6 +85,7 @@ type RedPacket struct {
type
RedPacketResp
struct
{
PacketId
string
`json:"packet_id"`
UserId
string
`json:"user_id"`
CoinName
string
`json:"coin_name"`
Amount
float32
`json:"amount"`
Size
uint8
`json:"size"`
...
...
@@ -112,6 +113,7 @@ func (r *RedPacket) GetRedPackets() ([]*RedPacketResp, error) {
}
tmp
:=
&
RedPacketResp
{}
tmp
.
PacketId
=
val
.
PacketId
tmp
.
UserId
=
val
.
UserId
tmp
.
CoinName
=
val
.
CoinName
tmp
.
Amount
=
val
.
Amount
tmp
.
Size
=
val
.
Size
...
...
@@ -230,7 +232,7 @@ func UpdateReceive() error {
if
redPacketReceiveDetailResp
.
Error
.
Code
!=
0
{
continue
}
var
receive
=
[]
int
{
20063
}
var
receive
=
[]
int
{}
for
_
,
item
:=
range
redPacketReceiveDetailResp
.
Result
.
Rows
{
receive
=
append
(
receive
,
util
.
ToInt
(
item
.
UserId
))
}
...
...
@@ -292,16 +294,16 @@ func UpdateInfo() error {
if
redPacketResp
.
Error
.
Code
!=
0
{
fmt
.
Println
(
redPacketResp
.
Error
.
Message
)
}
if
val
.
UpdateAt
!=
redPacketResp
.
Result
.
UpdateAt
{
redPacket
:=
map
[
string
]
interface
{}{
"remain"
:
redPacketResp
.
Result
.
Remain
,
"status"
:
redPacketResp
.
Result
.
Status
,
"update_at"
:
redPacketResp
.
Result
.
UpdateAt
,
}
condition
:=
make
(
map
[
string
]
interface
{})
condition
[
"id"
]
=
val
.
ID
models
.
EditRedPacket
(
condition
,
redPacket
)
//if val.UpdateAt != redPacketResp.Result.UpdateAt {
redPacket
:=
map
[
string
]
interface
{}{
"remain"
:
redPacketResp
.
Result
.
Remain
,
"status"
:
redPacketResp
.
Result
.
Status
,
"update_at"
:
redPacketResp
.
Result
.
UpdateAt
,
}
condition
:=
make
(
map
[
string
]
interface
{})
condition
[
"id"
]
=
val
.
ID
models
.
EditRedPacket
(
condition
,
redPacket
)
//}
}
return
nil
...
...
service/supported_chain_service/supported_chain.go
View file @
9f66803a
...
...
@@ -14,9 +14,12 @@ type SupportedChain struct {
}
type
SupportedChainResp
struct
{
ID
int
`json:"id"`
Name
string
`json:"name"`
CoinId
int
`json:"coin_id"`
ID
int
`json:"id"`
Name
string
`json:"name"`
CoinId
int
`json:"coin_id"`
Icon
string
`json:"icon"`
Platform
string
`json:"platform"`
Chain
string
`json:"chain"`
}
func
(
c
*
SupportedChain
)
Get
()
(
*
models
.
SupportedChain
,
error
)
{
...
...
@@ -40,6 +43,9 @@ func (c *SupportedChain) GetAll() ([]*SupportedChainResp, error) {
tmp
.
ID
=
val
.
ID
tmp
.
Name
=
val
.
CoinInfo
.
Name
tmp
.
CoinId
=
val
.
CoinId
tmp
.
Icon
=
val
.
CoinInfo
.
Icon
tmp
.
Platform
=
val
.
CoinInfo
.
Platform
tmp
.
Chain
=
val
.
CoinInfo
.
Chain
coinsResp
=
append
(
coinsResp
,
tmp
)
}
...
...
validate_service/coin_gas.go
0 → 100644
View file @
9f66803a
package
validate_service
type
CoinGas
struct
{
CoinName
string
`json:"coin_name" validate:"required"`
Low
string
`json:"low" validate:"required"`
Average
string
`json:"average" validate:"required"`
High
string
`json:"high" validate:"required"`
Switch
int8
`json:"switch" validate:"required"`
}
validate_service/supported_chain.go
View file @
9f66803a
...
...
@@ -2,5 +2,5 @@ package validate_service
type
SupportedChain
struct
{
PlatformId
int
`json:"platform_id" validate:"required"`
Coin
Name
string
`json:"coin_name
" validate:"required"`
Coin
Ids
string
`json:"coin_ids
" validate:"required"`
}
validate_service/wallet.go
View file @
9f66803a
...
...
@@ -5,7 +5,7 @@ type Wallet struct {
DownloadUrl
string
`json:"download_url" validate:"required,url"`
Introduce
string
`json:"introduce" validate:"required"`
Summary
string
`json:"summary, omitempty"`
ChainId
int
`json:"chain_id
" validate:"required"
`
ChainId
int
`json:"chain_id
, omitempty
`
IssueCharge
float32
`json:"issue_charge, omitempty"`
ChargeUnit
string
`json:"charge_unit, omitempty"`
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment