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
36d4bcd9
Commit
36d4bcd9
authored
Apr 03, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:多加几个脚本
parent
c65e3161
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
194 additions
and
1 deletion
+194
-1
diamond_account_detail_copy.go
script/diamond_account_detail_copy.go
+43
-0
diamond.go
script/model/diamond.go
+29
-0
slot_user_charge.go
script/slot_user_charge.go
+121
-0
utils_test.go
script/utils/utils_test.go
+1
-1
No files found.
script/diamond_account_detail_copy.go
0 → 100644
View file @
36d4bcd9
package
main
import
(
"bufio"
"fmt"
"git.hilo.cn/hilo-common/script/model"
"git.hilo.cn/hilo-common/script/mysql"
"os"
"time"
)
func
main
()
{
batchSize
:=
1000
errLog
:=
"diamond.error.log"
file
,
err
:=
os
.
OpenFile
(
errLog
,
os
.
O_WRONLY
|
os
.
O_CREATE
,
0666
)
if
err
!=
nil
{
fmt
.
Println
(
"文件打开失败"
,
err
)
}
defer
file
.
Close
()
n
:=
0
id
:=
uint64
(
4536403001
)
for
{
var
details
[]
*
model
.
DiamondAccountDetail
if
err
:=
mysql
.
ProdReadOnlyDB
.
Model
(
model
.
DiamondAccountDetail
{})
.
Where
(
"id < ? AND id >= 3275366391"
,
id
)
.
Order
(
"id DESC"
)
.
Limit
(
batchSize
)
.
Find
(
&
details
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
if
err
:=
mysql
.
ProdWriteDB
.
Table
(
model
.
DiamondAccountDetailCopy
{}
.
TableName
())
.
CreateInBatches
(
details
,
batchSize
)
.
Error
;
err
!=
nil
{
write
:=
bufio
.
NewWriter
(
file
)
write
.
WriteString
(
fmt
.
Sprintf
(
"%s
\n
"
,
err
.
Error
()))
write
.
Flush
()
}
if
len
(
details
)
<=
0
{
break
}
id
=
details
[
len
(
details
)
-
1
]
.
ID
fmt
.
Printf
(
"n:%v,lastest id:%v
\n
"
,
n
,
id
)
n
++
time
.
Sleep
(
time
.
Millisecond
*
300
)
if
n
>=
1
{
//break
}
}
}
script/model/diamond.go
0 → 100644
View file @
36d4bcd9
package
model
import
(
"time"
)
type
DiamondAccountDetail
struct
{
ID
uint64
CreatedTime
time
.
Time
UpdatedTime
time
.
Time
UserId
uint64
DiamondAccountId
uint64
OperateId
uint64
OperateType
int
OriginId
uint64
AddReduce
uint8
Num
uint32
Remark
string
BefNum
uint32
AftNum
uint32
OperateIds
string
}
type
DiamondAccountDetailCopy
struct
{
}
func
(
DiamondAccountDetailCopy
)
TableName
()
string
{
return
"diamond_account_detail_copy"
}
script/slot_user_charge.go
0 → 100644
View file @
36d4bcd9
package
main
import
(
"fmt"
"git.hilo.cn/hilo-common/script/model"
"git.hilo.cn/hilo-common/script/mysql"
"github.com/tealeg/xlsx"
)
type
SlotChargeData
struct
{
Period
string
UserId
uint64
Code
string
Stake
uint64
Award
uint64
Charge
int64
}
var
bt22
=
"2023-03-28 00:00:00"
var
et22
=
"2023-03-29 00:00:00"
func
ct
(
c
string
,
arr
[]
string
)
bool
{
for
_
,
v
:=
range
arr
{
if
c
==
v
{
return
true
}
}
return
false
}
func
ats22
(
a
interface
{})
string
{
return
fmt
.
Sprintf
(
"%v"
,
a
)
}
func
main
()
{
var
countries
[]
string
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"res_country"
)
.
Where
(
"area = 1"
)
.
Select
(
"name"
)
.
Find
(
&
countries
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
var
rows
[]
SlotChargeData
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"act_slot_day_rank_area"
)
.
Where
(
"`period` = '2023-03-28' AND `area` = 1"
)
.
Select
(
"period,user_id,stake,award"
)
.
Find
(
&
rows
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
var
data
[]
SlotChargeData
for
_
,
v
:=
range
rows
{
u
,
err
:=
GetUserById
(
v
.
UserId
)
if
err
!=
nil
{
panic
(
err
)
}
if
!
ct
(
u
.
Country
,
countries
)
{
continue
}
charge
,
_
,
err
:=
GetChargeMoneyDiamond22
(
v
.
UserId
)
if
err
!=
nil
{
panic
(
err
)
}
data
=
append
(
data
,
SlotChargeData
{
Period
:
v
.
Period
,
UserId
:
v
.
UserId
,
Code
:
u
.
Code
,
Stake
:
v
.
Stake
,
Award
:
v
.
Award
,
Charge
:
charge
,
})
}
excelFileName
:=
fmt
.
Sprintf
(
"./slot%s.xlsx"
,
"20230328"
)
xlFile
:=
xlsx
.
NewFile
()
sheet
,
err
:=
xlFile
.
AddSheet
(
"slot"
)
if
err
!=
nil
{
panic
(
err
)
}
row
:=
sheet
.
AddRow
()
c1
,
c2
,
c3
,
c4
,
c5
:=
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
()
c1
.
Value
,
c2
.
Value
,
c3
.
Value
,
c4
.
Value
,
c5
.
Value
=
"period"
,
"code"
,
"投注金额"
,
"中奖金额"
,
"当日充值金额(美分)"
for
_
,
d
:=
range
data
{
row
:=
sheet
.
AddRow
()
c1
,
c2
,
c3
,
c4
,
c5
:=
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
(),
row
.
AddCell
()
c1
.
Value
,
c2
.
Value
,
c3
.
Value
,
c4
.
Value
,
c5
.
Value
=
d
.
Period
,
d
.
Code
,
ats22
(
d
.
Stake
),
ats22
(
d
.
Award
),
ats22
(
d
.
Charge
)
}
_
=
xlFile
.
Save
(
excelFileName
)
}
func
GetUserById
(
id
uint64
)
(
model
.
User
,
error
)
{
var
u
model
.
User
if
err
:=
mysql
.
ProdReadOnlyDB
.
Model
(
model
.
User
{})
.
Where
(
"id = ?"
,
id
)
.
First
(
&
u
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
return
u
,
nil
}
func
GetChargeMoneyDiamond22
(
uid
uint64
)
(
int64
,
int64
,
error
)
{
type
R
struct
{
Money
int64
Diamond
int64
}
var
money
R
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"diamond_account_detail AS d"
)
.
Joins
(
"INNER JOIN pay_order AS p ON d.origin_id = p.id"
)
.
Where
(
"d.user_id in (?) AND operate_type in (?) AND add_reduce = 1"
,
uid
,
[]
int
{
int
(
4
),
int
(
42
),
int
(
55
),
int
(
68
)})
.
Where
(
"d.created_time >= ? AND d.created_time < ?"
,
bt22
,
et22
)
.
Order
(
"d.user_id"
)
.
Select
(
"SUM(p.price) as money,SUM(d.num) as diamond"
)
.
Scan
(
&
money
)
.
Error
;
err
!=
nil
{
return
0
,
0
,
err
}
type
R2
struct
{
Price
int64
Diamond
int64
}
var
money2
R2
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"diamond_account_detail AS d"
)
.
Joins
(
"INNER JOIN dealer_transfer_detail AS t ON d.origin_id = t.id"
)
.
Where
(
"d.user_id in (?) AND operate_type = ? AND add_reduce = 1"
,
uid
,
26
)
.
Select
(
"SUM(t.dollar) as price,SUM(d.num) as diamond"
)
.
Where
(
"d.created_time >= ? AND d.created_time < ?"
,
bt22
,
et22
)
.
Order
(
"d.user_id"
)
.
Scan
(
&
money2
)
.
Error
;
err
!=
nil
{
return
0
,
0
,
err
}
return
money
.
Money
+
money2
.
Price
,
money
.
Diamond
+
money2
.
Diamond
,
nil
}
script/utils/utils_test.go
View file @
36d4bcd9
...
@@ -10,6 +10,6 @@ func TestTestCommon(t *testing.T) {
...
@@ -10,6 +10,6 @@ func TestTestCommon(t *testing.T) {
}
}
func
TestJwt
(
t
*
testing
.
T
)
{
func
TestJwt
(
t
*
testing
.
T
)
{
token
,
_
:=
jwt
.
GenerateToken
(
7630
,
"4be85abee40f447a964a5bf2db7accba
"
,
"hiloApi"
)
token
,
_
:=
jwt
.
GenerateToken
(
2781
,
"6373ff5c318c4057886a669b5c9b5301
"
,
"hiloApi"
)
t
.
Logf
(
token
)
t
.
Logf
(
token
)
}
}
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