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
8a37431f
Commit
8a37431f
authored
Jun 09, 2021
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
ffb7667d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
237 additions
and
342 deletions
+237
-342
coin_red_packet.go
models/coin_red_packet.go
+0
-88
coin_red_packet_info.go
models/coin_red_packet_info.go
+0
-79
red_packet.go
models/red_packet.go
+98
-0
red_packet.go
routers/api/app/red_packet.go
+6
-21
router.go
routers/router.go
+0
-1
red_packet_info.go
service/red_packet_info_service/red_packet_info.go
+0
-96
red_packet.go
service/red_packet_service/red_packet.go
+133
-56
red_packet.go
validate_service/red_packet.go
+0
-1
No files found.
models/coin_red_packet.go
deleted
100644 → 0
View file @
ffb7667d
package
models
import
(
"bwallet/pkg/setting"
"github.com/jinzhu/gorm"
"time"
)
const
(
DRAW_NO
=
1
DRAW_YES
=
2
)
type
CoinRedPacket
struct
{
Model
PacketId
string
`json:"packet_id"`
LiveId
int32
`json:"live_id"`
UserId
int32
`json:"user_id"`
Avatar
string
`json:"avatar"`
Status
uint8
`json:"status"`
CreateAt
int64
`json:"create_at"`
UpdateAt
int64
`json:"update_at"`
RedPacketInfo
*
CoinRedPacketInfo
`gorm:"foreignkey:red_packet_id" json:"red_packet_info"`
}
func
(
c
CoinRedPacket
)
TableName
()
string
{
return
setting
.
DatabaseSetting
.
Name_Sources
+
".wallet_red_packet"
}
func
ExistCoinByPacketId
(
packet_id
string
)
(
bool
,
error
)
{
var
red_packet
CoinRedPacket
err
:=
db
.
Select
(
"id"
)
.
Where
(
"packet_id = ?"
,
packet_id
)
.
First
(
&
red_packet
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
false
,
err
}
if
red_packet
.
ID
>
0
{
return
true
,
nil
}
return
false
,
nil
}
func
GetRedPacketsTotal
(
maps
interface
{})
(
int
,
error
)
{
var
count
int
if
err
:=
db
.
Model
(
&
CoinRedPacket
{})
.
Where
(
maps
)
.
Count
(
&
count
)
.
Error
;
err
!=
nil
{
return
0
,
err
}
return
count
,
nil
}
func
GetRedPackets
(
pageNum
,
pageSize
int
,
maps
interface
{})
([]
*
CoinRedPacket
,
error
)
{
var
red_packets
[]
*
CoinRedPacket
err
:=
db
.
Preload
(
"RedPacketInfo"
)
.
Where
(
maps
)
.
Order
(
"create_at desc"
)
.
Offset
(
pageNum
)
.
Limit
(
pageSize
)
.
Find
(
&
red_packets
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
nil
,
err
}
return
red_packets
,
nil
}
func
AddCoinRedPacket
(
data
map
[
string
]
interface
{})
(
error
)
{
coinRedPacketInfo
:=
CoinRedPacket
{
PacketId
:
data
[
"packet_id"
]
.
(
string
),
LiveId
:
data
[
"live_id"
]
.
(
int32
),
UserId
:
data
[
"user_id"
]
.
(
int32
),
Avatar
:
data
[
"avatar"
]
.
(
string
),
Status
:
DRAW_NO
,
CreateAt
:
time
.
Now
()
.
UTC
()
.
Unix
(),
UpdateAt
:
time
.
Now
()
.
UTC
()
.
Unix
(),
}
if
err
:=
db
.
Create
(
&
coinRedPacketInfo
)
.
Error
;
err
!=
nil
{
return
err
}
return
nil
}
func
EditCoinRedPacket
(
maps
interface
{},
data
interface
{})
error
{
if
err
:=
db
.
Model
(
&
CoinRedPacket
{})
.
Where
(
maps
)
.
Updates
(
data
)
.
Error
;
err
!=
nil
{
return
err
}
return
nil
}
models/coin_red_packet_info.go
deleted
100644 → 0
View file @
ffb7667d
package
models
import
(
"bwallet/pkg/setting"
"github.com/jinzhu/gorm"
)
type
CoinRedPacketInfo
struct
{
Model
RedPacketId
int32
`json:"red_packet_id"`
UserId
int32
`json:"user_id"`
UserName
string
`json:"user_name"`
UserMobile
string
`json:"user_mobile"`
PlatformId
int32
`json:"platform_id"`
Type
uint8
`json:"type"`
CoinId
int32
`json:"coin_id"`
CoinName
string
`json:"coin_name"`
Amount
float32
`json:"amount"`
Size
uint8
`json:"size"`
To
string
`json:"to"`
Remain
uint8
`json:"remain"`
Status
uint8
`json:"status"`
Remark
string
`json:"remark"`
CreateAt
int32
`json:"create_at"`
UpdateAt
int32
`json:"update_at"`
ExpiresAt
int32
`json:"expires_at"`
RedPacket
*
CoinRedPacket
`gorm:"foreignkey:red_packet_id" json:"red_packet"`
}
func
(
c
CoinRedPacketInfo
)
TableName
()
string
{
return
setting
.
DatabaseSetting
.
Name_Sources
+
".wallet_red_packet_info"
}
func
GetRedPacketsInfo
(
maps
interface
{})
([]
*
CoinRedPacketInfo
,
error
)
{
var
redPacketsInfo
[]
*
CoinRedPacketInfo
err
:=
db
.
Debug
()
.
Preload
(
"RedPacket"
)
.
Where
(
maps
)
.
Find
(
&
redPacketsInfo
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
nil
,
err
}
return
redPacketsInfo
,
nil
}
func
AddCoinRedPacketInfo
(
data
map
[
string
]
interface
{})
(
error
)
{
coinRedPacketInfo
:=
CoinRedPacketInfo
{
RedPacketId
:
data
[
"red_packet_id"
]
.
(
int32
),
UserId
:
data
[
"user_id"
]
.
(
int32
),
UserName
:
data
[
"user_name"
]
.
(
string
),
UserMobile
:
data
[
"user_mobile"
]
.
(
string
),
PlatformId
:
data
[
"platform_id"
]
.
(
int32
),
Type
:
data
[
"type"
]
.
(
uint8
),
CoinId
:
data
[
"coin_id"
]
.
(
int32
),
CoinName
:
data
[
"coin_name"
]
.
(
string
),
Amount
:
data
[
"amount"
]
.
(
float32
),
Size
:
data
[
"size"
]
.
(
uint8
),
To
:
data
[
"to"
]
.
(
string
),
Remain
:
data
[
"remain"
]
.
(
uint8
),
Status
:
data
[
"status"
]
.
(
uint8
),
Remark
:
data
[
"remark"
]
.
(
string
),
CreateAt
:
data
[
"create_at"
]
.
(
int32
),
UpdateAt
:
data
[
"update_at"
]
.
(
int32
),
ExpiresAt
:
data
[
"expires_at"
]
.
(
int32
),
}
if
err
:=
db
.
Create
(
&
coinRedPacketInfo
)
.
Error
;
err
!=
nil
{
return
err
}
return
nil
}
func
EditCoinRedPacketInfo
(
maps
interface
{},
data
interface
{})
error
{
if
err
:=
db
.
Model
(
&
CoinRedPacketInfo
{})
.
Where
(
maps
)
.
Updates
(
data
)
.
Error
;
err
!=
nil
{
return
err
}
return
nil
}
models/red_packet.go
0 → 100644
View file @
8a37431f
package
models
import
(
"bwallet/pkg/setting"
"github.com/jinzhu/gorm"
)
type
RedPacket
struct
{
Model
PacketId
string
`json:"packet_id"`
LiveId
int32
`json:"live_id"`
Avatar
string
`json:"avatar"`
Receive
string
`json:"receive"`
UserId
string
`json:"user_id"`
UserName
string
`json:"user_name"`
UserMobile
string
`json:"user_mobile"`
PlatformId
string
`json:"platform_id"`
Type
uint8
`json:"type"`
CoinId
int32
`json:"coin_id"`
CoinName
string
`json:"coin_name"`
Amount
float32
`json:"amount"`
Size
uint8
`json:"size"`
To
string
`json:"to"`
Remain
uint8
`json:"remain"`
Status
uint8
`json:"status"`
Remark
string
`json:"remark"`
CreateAt
int32
`json:"create_at"`
UpdateAt
int32
`json:"update_at"`
ExpireAt
int32
`json:"expire_at"`
}
func
(
c
RedPacket
)
TableName
()
string
{
return
setting
.
DatabaseSetting
.
Name_Sources
+
".wallet_red_packet"
}
func
ExistByPacketInfoId
(
packet_id
string
)
(
bool
,
error
)
{
var
red_packet_info
RedPacket
err
:=
db
.
Select
(
"id"
)
.
Where
(
"packet_id = ?"
,
packet_id
)
.
First
(
&
red_packet_info
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
false
,
err
}
if
red_packet_info
.
ID
>
0
{
return
true
,
nil
}
return
false
,
nil
}
func
GetRedPackets
(
maps
interface
{})
([]
*
RedPacket
,
error
)
{
var
redPackets
[]
*
RedPacket
err
:=
db
.
Debug
()
.
Where
(
maps
)
.
Find
(
&
redPackets
)
.
Error
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
nil
,
err
}
return
redPackets
,
nil
}
func
AddRedPacket
(
data
map
[
string
]
interface
{})
(
error
)
{
redPacket
:=
RedPacket
{
PacketId
:
data
[
"packet_id"
]
.
(
string
),
LiveId
:
data
[
"live_id"
]
.
(
int32
),
Avatar
:
data
[
"avatar"
]
.
(
string
),
Receive
:
data
[
"receive"
]
.
(
string
),
UserId
:
data
[
"user_id"
]
.
(
string
),
UserName
:
data
[
"user_name"
]
.
(
string
),
UserMobile
:
data
[
"user_mobile"
]
.
(
string
),
PlatformId
:
data
[
"platform_id"
]
.
(
string
),
Type
:
data
[
"type"
]
.
(
uint8
),
CoinId
:
data
[
"coin_id"
]
.
(
int32
),
CoinName
:
data
[
"coin_name"
]
.
(
string
),
Amount
:
data
[
"amount"
]
.
(
float32
),
Size
:
data
[
"size"
]
.
(
uint8
),
To
:
data
[
"to"
]
.
(
string
),
Remain
:
data
[
"remain"
]
.
(
uint8
),
Status
:
data
[
"status"
]
.
(
uint8
),
Remark
:
data
[
"remark"
]
.
(
string
),
CreateAt
:
data
[
"create_at"
]
.
(
int32
),
UpdateAt
:
data
[
"update_at"
]
.
(
int32
),
ExpireAt
:
data
[
"expire_at"
]
.
(
int32
),
}
if
err
:=
db
.
Create
(
&
redPacket
)
.
Error
;
err
!=
nil
{
return
err
}
return
nil
}
func
EditRedPacket
(
maps
interface
{},
data
interface
{})
error
{
if
err
:=
db
.
Model
(
&
RedPacket
{})
.
Where
(
maps
)
.
Updates
(
data
)
.
Error
;
err
!=
nil
{
return
err
}
return
nil
}
routers/api/app/red_packet.go
View file @
8a37431f
package
app
import
(
"bwallet/models"
"bwallet/pkg/errno"
"bwallet/pkg/handler"
"bwallet/pkg/util"
"bwallet/service/red_packet_info_service"
"bwallet/service/red_packet_service"
"bwallet/validate_service"
"github.com/Unknwon/com"
...
...
@@ -25,13 +23,12 @@ func AddRedPacket(c *gin.Context) {
}
}
RedPacketService
:=
red_packet_service
.
Coin
RedPacket
{
RedPacketService
:=
red_packet_service
.
RedPacket
{
PacketId
:
red_packet
.
PacketId
,
LiveId
:
red_packet
.
LiveId
,
UserId
:
red_packet
.
UserId
,
Avatar
:
red_packet
.
Avatar
,
}
exist
,
err
:=
RedPacketService
.
Exist
CoinByPacket
Id
()
exist
,
err
:=
RedPacketService
.
Exist
ByPacketInfo
Id
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
ErrAddRedPacket
,
nil
)
return
...
...
@@ -54,14 +51,16 @@ func GetRedPackets(c *gin.Context) {
live_id
:=
com
.
StrTo
(
c
.
DefaultQuery
(
"live_id"
,
"0"
))
.
MustInt
()
valid
.
Required
(
live_id
,
"live_id"
)
.
Message
(
"直播间参数不能为空"
)
//user_id := com.StrTo(c.DefaultQuery("user_id", "0")).MustInt()
//valid.Required(user_id, "user_id").Message("用户参数不能为空")
if
valid
.
HasErrors
()
{
handler
.
SendResponse
(
c
,
valid
.
Errors
[
0
],
nil
)
return
}
RedPacketService
:=
red_packet_service
.
Coin
RedPacket
{
RedPacketService
:=
red_packet_service
.
RedPacket
{
LiveId
:
int32
(
live_id
),
Status
:
models
.
DRAW_NO
,
PageNum
:
util
.
GetPage
(
c
),
PageSize
:
util
.
GetLimit
(
c
),
}
...
...
@@ -78,17 +77,3 @@ func GetRedPackets(c *gin.Context) {
handler
.
SendResponse
(
c
,
nil
,
data
)
}
func
GetRedPacketsInfo
(
c
*
gin
.
Context
)
{
RedPacketInfoService
:=
red_packet_info_service
.
CoinRedPacketInfo
{
Status
:
1
,
}
info
,
err
:=
RedPacketInfoService
.
GetRedPacketsInfo
()
if
err
!=
nil
{
handler
.
SendResponse
(
c
,
errno
.
InternalServerError
,
nil
)
return
}
handler
.
SendResponse
(
c
,
nil
,
info
)
}
routers/router.go
View file @
8a37431f
...
...
@@ -53,7 +53,6 @@ func InitRouter() *gin.Engine {
client
.
GET
(
"/red-packets"
,
app
.
GetRedPackets
)
client
.
POST
(
"/red-packet"
,
app
.
AddRedPacket
)
client
.
GET
(
"/red-packets-info"
,
app
.
GetRedPacketsInfo
)
api
:=
r
.
Group
(
"/api"
)
...
...
service/red_packet_info_service/red_packet_info.go
deleted
100644 → 0
View file @
ffb7667d
package
red_packet_info_service
import
(
"bwallet/models"
)
type
CoinRedPacketInfo
struct
{
RedPacketId
int32
UserId
int32
UserName
string
UserMobile
string
PlatformId
int32
Type
uint8
CoinId
int32
CoinName
string
Amount
float32
Size
uint8
To
string
Remain
uint8
Status
uint8
Remark
string
CreateAt
int32
UpdateAt
int32
ExpiresAt
int32
}
func
(
r
*
CoinRedPacketInfo
)
GetRedPacketsInfo
()
([]
*
models
.
CoinRedPacketInfo
,
error
)
{
redPacketsInfo
,
err
:=
models
.
GetRedPacketsInfo
(
r
.
getMaps
())
if
err
!=
nil
{
return
nil
,
err
}
return
redPacketsInfo
,
nil
}
func
(
r
*
CoinRedPacketInfo
)
Add
()
error
{
redPacket
:=
map
[
string
]
interface
{}{
"red_packet_id"
:
r
.
RedPacketId
,
"user_id"
:
r
.
UserId
,
"user_name"
:
r
.
UserName
,
"user_mobile"
:
r
.
UserMobile
,
"platform_id"
:
r
.
PlatformId
,
"type"
:
r
.
Type
,
"coin_id"
:
r
.
CoinId
,
"coin_name"
:
r
.
CoinName
,
"amount"
:
r
.
Amount
,
"size"
:
r
.
Size
,
"to"
:
r
.
To
,
"remain"
:
r
.
Remain
,
"status"
:
r
.
Status
,
"remark"
:
r
.
Remark
,
"create_at"
:
r
.
CreateAt
,
"update_at"
:
r
.
UpdateAt
,
"expires_at"
:
r
.
ExpiresAt
,
}
if
err
:=
models
.
AddCoinRedPacketInfo
(
redPacket
);
err
!=
nil
{
return
err
}
return
nil
}
func
(
r
*
CoinRedPacketInfo
)
Edit
()
error
{
return
models
.
EditCoinRedPacketInfo
(
r
.
getMaps
(),
map
[
string
]
interface
{}{
"user_id"
:
r
.
UserId
,
"user_name"
:
r
.
UserName
,
"user_mobile"
:
r
.
UserMobile
,
"platform_id"
:
r
.
PlatformId
,
"type"
:
r
.
Type
,
"coin_id"
:
r
.
CoinId
,
"coin_name"
:
r
.
CoinName
,
"amount"
:
r
.
Amount
,
"size"
:
r
.
Size
,
"to"
:
r
.
To
,
"remain"
:
r
.
Remain
,
"status"
:
r
.
Status
,
"remark"
:
r
.
Remark
,
"create_at"
:
r
.
CreateAt
,
"update_at"
:
r
.
UpdateAt
,
"expires_at"
:
r
.
ExpiresAt
,
})
}
func
(
r
*
CoinRedPacketInfo
)
getMaps
()
(
map
[
string
]
interface
{})
{
maps
:=
make
(
map
[
string
]
interface
{})
if
r
.
UserId
!=
0
{
maps
[
"user_id"
]
=
r
.
UserId
}
if
r
.
Status
!=
0
{
maps
[
"status"
]
=
r
.
Status
}
return
maps
}
service/red_packet_service/red_packet.go
View file @
8a37431f
...
...
@@ -2,22 +2,56 @@ package red_packet_service
import
(
"bwallet/models"
"time"
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
type
CoinRedPacket
struct
{
PacketId
string
LiveId
int32
UserId
int32
Avatar
string
Status
uint8
type
RedPacketInfoResult
struct
{
UserId
string
`json:"user_id"`
UserName
string
`json:"user_name"`
UserMobile
string
`json:"user_mobile"`
PlatformId
string
`json:"platform_id"`
Type
uint8
`json:"type"`
CoinId
int32
`json:"coin_id"`
CoinName
string
`json:"coin_name"`
Amount
float32
`json:"amount"`
Size
uint8
`json:"size"`
To
string
`json:"to"`
Remain
uint8
`json:"remain"`
Status
uint8
`json:"status"`
Remark
string
`json:"remark"`
CreateAt
int32
`json:"create_at"`
UpdateAt
int32
`json:"update_at"`
ExpireAt
int32
`json:"expire_at"`
}
type
RedPacketInfoError
struct
{
Code
int32
`json:"code"`
Message
string
`json:"message"`
}
type
RedPacketInfoResp
struct
{
Id
int32
Result
RedPacketInfoResult
Error
RedPacketInfoError
}
type
RedPacket
struct
{
PacketId
string
`json:"packet_id"`
LiveId
int32
`json:"live_id"`
Avatar
string
`json:"avatar"`
Receive
string
`json:"receive"`
RedPacketInfo
RedPacketInfoResp
PageNum
int
PageSize
int
}
type
CoinRedPacketResp
struct
{
Status
uint8
`json:"status"`
type
RedPacketResp
struct
{
CoinName
string
`json:"coin_name"`
Amount
float32
`json:"amount"`
Size
uint8
`json:"size"`
...
...
@@ -27,79 +61,122 @@ type CoinRedPacketResp struct {
UserMobile
string
`json:"user_mobile"`
}
func
(
r
*
CoinRedPacket
)
ExistCoinByPacketId
()
(
bool
,
error
)
{
return
models
.
ExistCoinByPacketId
(
r
.
PacketId
)
}
func
(
r
*
CoinRedPacket
)
Count
()
(
int
,
error
)
{
return
models
.
GetRedPacketsTotal
(
r
.
getMaps
())
func
(
r
*
RedPacket
)
ExistByPacketInfoId
()
(
bool
,
error
)
{
return
models
.
ExistByPacketInfoId
(
r
.
PacketId
)
}
func
(
r
*
CoinRedPacket
)
GetRedPackets
()
([]
*
Coin
RedPacketResp
,
error
)
{
redPackets
,
err
:=
models
.
GetRedPackets
(
r
.
PageNum
,
r
.
PageSize
,
r
.
getMaps
())
func
(
r
*
RedPacket
)
GetRedPackets
()
([]
*
RedPacketResp
,
error
)
{
redPackets
Info
,
err
:=
models
.
GetRedPackets
(
r
.
getMaps
())
if
err
!=
nil
{
return
nil
,
err
}
var
redPacketsResp
=
[]
*
CoinRedPacketResp
{}
for
_
,
val
:=
range
redPackets
{
if
val
.
RedPacketInfo
!=
nil
&&
val
.
RedPacketInfo
.
Status
==
1
{
tmp
:=
&
CoinRedPacketResp
{}
tmp
.
Status
=
val
.
Status
tmp
.
Avatar
=
val
.
Avatar
tmp
.
Size
=
val
.
RedPacketInfo
.
Size
tmp
.
Remain
=
val
.
RedPacketInfo
.
Remain
tmp
.
Amount
=
val
.
RedPacketInfo
.
Amount
tmp
.
CoinName
=
val
.
RedPacketInfo
.
CoinName
tmp
.
UserName
=
val
.
RedPacketInfo
.
UserName
tmp
.
UserMobile
=
val
.
RedPacketInfo
.
UserMobile
redPacketsResp
=
append
(
redPacketsResp
,
tmp
)
}
var
redPacketResp
=
[]
*
RedPacketResp
{}
for
_
,
val
:=
range
redPacketsInfo
{
tmp
:=
&
RedPacketResp
{}
tmp
.
CoinName
=
val
.
CoinName
tmp
.
Amount
=
val
.
Amount
tmp
.
Size
=
val
.
Size
tmp
.
Remain
=
val
.
Remain
tmp
.
Avatar
=
val
.
Avatar
tmp
.
UserName
=
val
.
UserName
tmp
.
UserMobile
=
val
.
UserMobile
redPacketResp
=
append
(
redPacketResp
,
tmp
)
}
return
redPacket
s
Resp
,
nil
return
redPacketResp
,
nil
}
func
(
r
*
CoinRedPacket
)
Add
()
error
{
func
(
r
*
RedPacket
)
Add
()
error
{
url
:=
"https://redback.biqianbao.net/red-packet"
var
jsonStr
=
[]
byte
(
`{"method": "Info","params": {"packet_id": "fbbad00c-a91f-4eb3-88a1-cab02b1be26f"},"id":123}`
)
req
,
err
:=
http
.
NewRequest
(
"POST"
,
url
,
bytes
.
NewBuffer
(
jsonStr
))
req
.
Header
.
Set
(
"Content-Type"
,
"application/json"
)
client
:=
&
http
.
Client
{}
resp
,
err
:=
client
.
Do
(
req
)
if
err
!=
nil
{
return
err
}
defer
resp
.
Body
.
Close
()
body
,
_
:=
ioutil
.
ReadAll
(
resp
.
Body
)
var
redPacketResp
RedPacketInfoResp
err
=
json
.
Unmarshal
(
body
,
&
redPacketResp
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
err
}
if
redPacketResp
.
Error
.
Code
!=
0
{
fmt
.
Println
(
redPacketResp
.
Error
.
Message
)
}
redPacket
:=
map
[
string
]
interface
{}{
"packet_id"
:
r
.
PacketId
,
"live_id"
:
r
.
LiveId
,
"user_id"
:
r
.
UserId
,
"avatar"
:
r
.
Avatar
,
"packet_id"
:
r
.
PacketId
,
"live_id"
:
r
.
LiveId
,
"avatar"
:
r
.
Avatar
,
"receive"
:
"[]"
,
"user_id"
:
redPacketResp
.
Result
.
UserId
,
"user_name"
:
redPacketResp
.
Result
.
UserName
,
"user_mobile"
:
redPacketResp
.
Result
.
UserMobile
,
"platform_id"
:
redPacketResp
.
Result
.
PlatformId
,
"type"
:
redPacketResp
.
Result
.
Type
,
"coin_id"
:
redPacketResp
.
Result
.
CoinId
,
"coin_name"
:
redPacketResp
.
Result
.
CoinName
,
"amount"
:
redPacketResp
.
Result
.
Amount
,
"size"
:
redPacketResp
.
Result
.
Size
,
"to"
:
redPacketResp
.
Result
.
To
,
"remain"
:
redPacketResp
.
Result
.
Remain
,
"status"
:
redPacketResp
.
Result
.
Status
,
"remark"
:
redPacketResp
.
Result
.
Remark
,
"create_at"
:
redPacketResp
.
Result
.
CreateAt
,
"update_at"
:
redPacketResp
.
Result
.
UpdateAt
,
"expire_at"
:
redPacketResp
.
Result
.
ExpireAt
,
}
if
err
:=
models
.
AddCoinRedPacket
(
redPacket
);
err
!=
nil
{
if
err
:=
models
.
AddRedPacket
(
redPacket
);
err
!=
nil
{
return
err
}
return
nil
}
func
(
r
*
CoinRedPacket
)
Edit
()
error
{
return
models
.
EditCoinRedPacket
(
r
.
getMaps
(),
map
[
string
]
interface
{}{
"status"
:
models
.
DRAW_YES
,
"update_at"
:
time
.
Now
()
.
UTC
()
.
Unix
(),
func
(
r
*
RedPacket
)
Edit
()
error
{
return
models
.
EditRedPacket
(
r
.
getMaps
(),
map
[
string
]
interface
{}{
//"user_id": r.RedPacketInfo.UserId,
//"user_name": r.RedPacketInfo.UserName,
//"user_mobile": r.RedPacketInfo.UserMobile,
//"platform_id": r.RedPacketInfo.PlatformId,
//"type": r.RedPacketInfo.Type,
//"coin_id": r.RedPacketInfo.CoinId,
//"coin_name": r.RedPacketInfo.CoinName,
//"amount": r.RedPacketInfo.Amount,
//"size": r.RedPacketInfo.Size,
//"to": r.RedPacketInfo.To,
//"remain": r.RedPacketInfo.Remain,
//"status": r.RedPacketInfo.Status,
//"remark": r.RedPacketInfo.Remark,
//"create_at": r.RedPacketInfo.CreateAt,
//"update_at": r.RedPacketInfo.UpdateAt,
//"expires_at": r.RedPacketInfo.ExpiresAt,
})
}
func
(
r
*
Coin
RedPacket
)
getMaps
()
(
map
[
string
]
interface
{})
{
func
(
r
*
RedPacket
)
getMaps
()
(
map
[
string
]
interface
{})
{
maps
:=
make
(
map
[
string
]
interface
{})
if
r
.
PacketId
!=
""
{
maps
[
"packet_id"
]
=
r
.
PacketId
}
if
r
.
LiveId
!=
0
{
maps
[
"live_id"
]
=
r
.
LiveId
}
if
r
.
UserId
!=
0
{
maps
[
"user_id"
]
=
r
.
UserId
}
if
r
.
Status
!=
0
{
maps
[
"status"
]
=
r
.
Status
}
//if r.RedPacketInfo.UserId != 0 {
// maps["user_id"] = r.RedPacketInfo.UserId
//}
//
//if r.RedPacketInfo.Status != 0 {
// maps["status"] = r.RedPacketInfo.Status
//}
return
maps
}
validate_service/red_packet.go
View file @
8a37431f
...
...
@@ -3,6 +3,5 @@ package validate_service
type
RedPacket
struct
{
PacketId
string
`json:"packet_id" validate:"required"`
LiveId
int32
`json:"live_id" validate:"required"`
UserId
int32
`json:"user_id" validate:"required"`
Avatar
string
`json:"avatar" validate:"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