Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujiebin
hilo-common
Commits
9a19e96d
Commit
9a19e96d
authored
Apr 17, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
开斋节活动
parent
41b58066
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
act_m.go
internal/model/act_m/act_m.go
+47
-0
No files found.
internal/model/act_m/act_m.go
0 → 100644
View file @
9a19e96d
package
act_m
import
(
"fmt"
"git.hilo.cn/hilo-common/domain"
)
type
ActPoint
struct
{
AcId
uint64
`json:"ac_id"`
UserId
uint64
`json:"user_id"`
Point
uint64
`json:"point"`
}
type
ActPointLog
struct
{
Id
uint64
`json:"id"`
AcId
uint64
`json:"ac_id"`
UserId
uint64
`json:"user_id"`
Point
uint64
`json:"point"`
AddReduce
uint8
`json:"add_reduce"`
// 1.增加2.减少
Remark
string
`json:"remark"`
}
func
(
this
*
ActPoint
)
Add
(
model
*
domain
.
Model
)
error
{
sql
:=
"insert into hilo.act_point (ac_id,user_id,point) "
+
"values(?,?,?) on duplicate key update point = point+values(point);"
return
model
.
DB
()
.
Exec
(
sql
,
this
.
AcId
,
this
.
UserId
,
this
.
Point
)
.
Error
}
func
(
this
*
ActPoint
)
Reduce
(
model
*
domain
.
Model
)
error
{
sql
:=
"update hilo.act_point set point = point - ? where ac_id=? and user_id=? and point >= ?;"
result
:=
model
.
DB
()
.
Exec
(
sql
,
this
.
Point
,
this
.
AcId
,
this
.
UserId
,
this
.
Point
)
if
result
.
Error
!=
nil
{
return
result
.
Error
}
if
result
.
RowsAffected
<=
0
{
return
fmt
.
Errorf
(
"bizerr.TransactionFailed"
)
}
return
nil
}
func
CreateActPointLog
(
model
*
domain
.
Model
,
info
*
ActPointLog
)
error
{
err
:=
model
.
DB
()
.
Create
(
&
info
)
.
Error
if
err
!=
nil
{
return
err
}
return
nil
}
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