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
3f189448
Commit
3f189448
authored
Feb 08, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:脚本
parent
21335d2f
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
46 additions
and
36 deletions
+46
-36
group_power_india.go
script/group_power_india.go
+2
-2
group.go
script/model/group.go
+0
-0
robot.go
script/model/robot.go
+0
-0
user.go
script/model/user.go
+0
-0
mysql.go
script/mysql/mysql.go
+0
-0
prod_game_robot.go
script/prod_game_robot.go
+5
-5
sync_group_code.go
script/sync_group_code.go
+6
-6
test_20_in_mic.go
script/test_20_in_mic.go
+2
-2
test_fruit_machine.go
script/test_fruit_machine.go
+2
-2
test_game_robot.go
script/test_game_robot.go
+2
-2
user_charge.go
script/user_charge.go
+27
-17
No files found.
script/group_power_india.go
View file @
3f189448
...
@@ -2,8 +2,8 @@ package main
...
@@ -2,8 +2,8 @@ package main
import
(
import
(
"fmt"
"fmt"
"git.hilo.cn/hilo-common/model"
"git.hilo.cn/hilo-common/
script/
model"
"git.hilo.cn/hilo-common/mysql"
"git.hilo.cn/hilo-common/
script/
mysql"
"github.com/spf13/cast"
"github.com/spf13/cast"
"github.com/tealeg/xlsx"
"github.com/tealeg/xlsx"
"time"
"time"
...
...
model/group.go
→
script/
model/group.go
View file @
3f189448
File moved
model/robot.go
→
script/
model/robot.go
View file @
3f189448
File moved
model/user.go
→
script/
model/user.go
View file @
3f189448
File moved
mysql/mysql.go
→
script/
mysql/mysql.go
View file @
3f189448
File moved
script/prod_game_robot.go
View file @
3f189448
...
@@ -2,8 +2,8 @@ package main
...
@@ -2,8 +2,8 @@ package main
import
(
import
(
"fmt"
"fmt"
"git.hilo.cn/hilo-common
/model"
model2
"git.hilo.cn/hilo-common/script
/model"
"git.hilo.cn/hilo-common/mysql"
"git.hilo.cn/hilo-common/
script/
mysql"
uuid
"github.com/satori/go.uuid"
uuid
"github.com/satori/go.uuid"
"strings"
"strings"
)
)
...
@@ -19,7 +19,7 @@ var codes = []string{"1384891", "1387474", "1379229", "1382208", "1385588", "138
...
@@ -19,7 +19,7 @@ var codes = []string{"1384891", "1387474", "1379229", "1382208", "1385588", "138
func
main
()
{
func
main
()
{
println
(
len
(
codes
))
// 1078个key的
println
(
len
(
codes
))
// 1078个key的
var
testRobots
[]
model
.
UserNoId
var
testRobots
[]
model
2
.
UserNoId
sql
:=
"SELECT * FROM `user` where id BETWEEN 4564 and 7615 limit 1078"
sql
:=
"SELECT * FROM `user` where id BETWEEN 4564 and 7615 limit 1078"
if
err
:=
mysql
.
TestDB
.
Raw
(
sql
)
.
Find
(
&
testRobots
)
.
Error
;
err
!=
nil
{
if
err
:=
mysql
.
TestDB
.
Raw
(
sql
)
.
Find
(
&
testRobots
)
.
Error
;
err
!=
nil
{
panic
(
err
)
panic
(
err
)
...
@@ -39,11 +39,11 @@ func main() {
...
@@ -39,11 +39,11 @@ func main() {
//break
//break
}
}
var
userIds
[]
uint64
var
userIds
[]
uint64
if
err
:=
mysql
.
ProdReadOnlyDB
.
Model
(
model
.
User
{})
.
Select
(
"id"
)
.
Where
(
"code in ?"
,
codes
)
.
Find
(
&
userIds
)
.
Error
;
err
!=
nil
{
if
err
:=
mysql
.
ProdReadOnlyDB
.
Model
(
model
2
.
User
{})
.
Select
(
"id"
)
.
Where
(
"code in ?"
,
codes
)
.
Find
(
&
userIds
)
.
Error
;
err
!=
nil
{
panic
(
"get user id fail"
)
panic
(
"get user id fail"
)
}
}
for
_
,
userId
:=
range
userIds
{
for
_
,
userId
:=
range
userIds
{
gameRobot
:=
&
model
.
GameRobot
{
UserId
:
userId
}
gameRobot
:=
&
model
2
.
GameRobot
{
UserId
:
userId
}
if
err
:=
mysql
.
ProdWriteDB
.
Create
(
gameRobot
)
.
Error
;
err
!=
nil
{
if
err
:=
mysql
.
ProdWriteDB
.
Create
(
gameRobot
)
.
Error
;
err
!=
nil
{
fmt
.
Printf
(
"create robot fail:%v-%v"
,
gameRobot
,
err
)
fmt
.
Printf
(
"create robot fail:%v-%v"
,
gameRobot
,
err
)
}
}
...
...
script/sync_group_code.go
View file @
3f189448
...
@@ -2,8 +2,8 @@ package main
...
@@ -2,8 +2,8 @@ package main
import
(
import
(
"fmt"
"fmt"
"git.hilo.cn/hilo-common
/model"
model2
"git.hilo.cn/hilo-common/script
/model"
"git.hilo.cn/hilo-common/mysql"
"git.hilo.cn/hilo-common/
script/
mysql"
"time"
"time"
)
)
...
@@ -24,12 +24,12 @@ func main() {
...
@@ -24,12 +24,12 @@ func main() {
panic
(
err
)
panic
(
err
)
}
}
for
_
,
row
:=
range
rows
{
for
_
,
row
:=
range
rows
{
groupInfo
:=
new
(
model
.
GroupInfo
)
groupInfo
:=
new
(
model
2
.
GroupInfo
)
if
err
:=
mysql
.
ProdReadOnlyDB
.
Model
(
model
.
GroupInfo
{})
.
Where
(
"im_group_id = ?"
,
row
.
GroupId
)
.
First
(
groupInfo
)
.
Error
;
err
!=
nil
{
if
err
:=
mysql
.
ProdReadOnlyDB
.
Model
(
model
2
.
GroupInfo
{})
.
Where
(
"im_group_id = ?"
,
row
.
GroupId
)
.
First
(
groupInfo
)
.
Error
;
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
owner
:=
new
(
model
.
User
)
owner
:=
new
(
model
2
.
User
)
if
err
:=
mysql
.
ProdReadOnlyDB
.
Model
(
model
.
User
{})
.
Where
(
"id = ?"
,
groupInfo
.
Owner
)
.
First
(
owner
)
.
Error
;
err
!=
nil
{
if
err
:=
mysql
.
ProdReadOnlyDB
.
Model
(
model
2
.
User
{})
.
Where
(
"id = ?"
,
groupInfo
.
Owner
)
.
First
(
owner
)
.
Error
;
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
if
owner
.
Code
!=
owner
.
OriginCode
&&
owner
.
Code
!=
groupInfo
.
Code
{
if
owner
.
Code
!=
owner
.
OriginCode
&&
owner
.
Code
!=
groupInfo
.
Code
{
...
...
script/test_20_in_mic.go
View file @
3f189448
...
@@ -2,8 +2,8 @@ package main
...
@@ -2,8 +2,8 @@ package main
import
(
import
(
"fmt"
"fmt"
"git.hilo.cn/hilo-common/model"
"git.hilo.cn/hilo-common/
script/
model"
"git.hilo.cn/hilo-common/mysql"
"git.hilo.cn/hilo-common/
script/
mysql"
"git.hilo.cn/hilo-common/utils/jwt"
"git.hilo.cn/hilo-common/utils/jwt"
"net/http"
"net/http"
"strings"
"strings"
...
...
script/test_fruit_machine.go
View file @
3f189448
...
@@ -2,8 +2,8 @@ package main
...
@@ -2,8 +2,8 @@ package main
import
(
import
(
"fmt"
"fmt"
"git.hilo.cn/hilo-common/model"
"git.hilo.cn/hilo-common/
script/
model"
"git.hilo.cn/hilo-common/mysql"
"git.hilo.cn/hilo-common/
script/
mysql"
"git.hilo.cn/hilo-common/utils/jwt"
"git.hilo.cn/hilo-common/utils/jwt"
"io/ioutil"
"io/ioutil"
"math/rand"
"math/rand"
...
...
script/test_game_robot.go
View file @
3f189448
package
main
package
main
import
(
import
(
"git.hilo.cn/hilo-common/model"
"git.hilo.cn/hilo-common/
script/
model"
"git.hilo.cn/hilo-common/mysql"
"git.hilo.cn/hilo-common/
script/
mysql"
)
)
func
main
()
{
func
main
()
{
...
...
script/user_charge.go
View file @
3f189448
...
@@ -2,29 +2,39 @@ package main
...
@@ -2,29 +2,39 @@ package main
import
(
import
(
"fmt"
"fmt"
"git.hilo.cn/hilo-common/
mysq
l"
"git.hilo.cn/hilo-common/
script/mode
l"
"
time
"
"
git.hilo.cn/hilo-common/script/mysql
"
)
)
func
main
()
{
func
main
()
{
uids
:=
[]
uint64
{
889621
,
904971
,
1072931
,
1083981
,
1108951
,
1147471
,
1187511
,
1365041
,
1496521
,
1540091
,
1888121
,
2037771
,
2236221
,
2396461
,
2603721
,
2613321
,
2648851
,
2778081
,
3142631
,
3219391
,
3401561
,
3533911
,
3602511
,
3791481
,
3840571
,
3845671
,
3865481
,
3873381
,
3892321
,
4009941
}
//uids := []uint64{889621, 904971, 1072931, 1083981, 1108951, 1147471, 1187511, 1365041, 1496521, 1540091, 1888121, 2037771, 2236221, 2396461, 2603721, 2613321, 2648851, 2778081, 3142631, 3219391, 3401561, 3533911, 3602511, 3791481, 3840571, 3845671, 3865481, 3873381, 3892321, 4009941}
since
,
_
:=
time
.
Parse
(
"2006-01-02"
,
"2023-02-05"
)
var
uids
[]
uint64
since
=
since
.
AddDate
(
0
,
0
,
-
7
)
if
err
:=
mysql
.
ProdReadOnlyDB
.
Raw
(
"select id from user where origin_code <> `code`"
)
.
Find
(
&
uids
)
.
Error
;
err
!=
nil
{
var
data
[][
2
]
uint64
panic
(
err
)
}
var
users
[]
model
.
User
if
err
:=
mysql
.
ProdReadOnlyDB
.
Model
(
model
.
User
{})
.
Where
(
"id in ?"
,
uids
)
.
Find
(
&
users
)
.
Error
;
err
!=
nil
{
panic
(
err
)
}
uM
:=
make
(
map
[
uint64
]
model
.
User
)
for
k
,
u
:=
range
users
{
uM
[
u
.
Id
]
=
users
[
k
]
}
var
data
=
make
(
map
[
uint64
]
int64
)
for
_
,
uid
:=
range
uids
{
for
_
,
uid
:=
range
uids
{
m1
,
_
:=
GetUsersChargeMoneySum
([]
uint64
{
uid
}
,
since
)
m1
,
_
:=
GetUsersChargeMoneySum
([]
uint64
{
uid
})
m2
,
_
:=
GetUserDealerTransferMoneySum
([]
uint64
{
uid
}
,
since
)
m2
,
_
:=
GetUserDealerTransferMoneySum
([]
uint64
{
uid
})
data
=
append
(
data
,
[
2
]
uint64
{
uid
,
uint64
(
m1
+
m2
)})
data
[
uid
]
=
m1
+
m2
}
}
for
_
,
r
:=
range
data
{
for
uid
,
num
:=
range
data
{
fmt
.
Print
ln
(
r
)
fmt
.
Print
f
(
"%d,%s,%d
\n
"
,
uid
,
uM
[
uid
]
.
Country
,
num
)
}
}
}
}
// 获取用户范围内充值金额
// 获取用户范围内充值金额
// param sinceTime: 过去n时间内
// param sinceTime: 过去n时间内
// 返回美分
// 返回美分
func
GetUsersChargeMoneySum
(
uids
[]
uint64
,
sinceTime
time
.
Time
)
(
int64
,
error
)
{
func
GetUsersChargeMoneySum
(
uids
[]
uint64
)
(
int64
,
error
)
{
if
len
(
uids
)
<=
0
{
if
len
(
uids
)
<=
0
{
return
0
,
nil
return
0
,
nil
}
}
...
@@ -34,8 +44,8 @@ func GetUsersChargeMoneySum(uids []uint64, sinceTime time.Time) (int64, error) {
...
@@ -34,8 +44,8 @@ func GetUsersChargeMoneySum(uids []uint64, sinceTime time.Time) (int64, error) {
var
money
R
var
money
R
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"diamond_account_detail AS d"
)
.
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"diamond_account_detail AS d"
)
.
Joins
(
"INNER JOIN pay_order AS p ON d.origin_id = p.id"
)
.
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
AND d.created_time >= ?
"
,
Where
(
"d.user_id in (?) AND operate_type in (?) AND add_reduce = 1"
,
uids
,
[]
int
{
int
(
4
),
int
(
42
),
int
(
55
),
int
(
68
)}
,
sinceTime
)
.
uids
,
[]
int
{
int
(
4
),
int
(
42
),
int
(
55
),
int
(
68
)})
.
Select
(
"SUM(p.price) as money"
)
.
Scan
(
&
money
)
.
Error
;
err
!=
nil
{
Select
(
"SUM(p.price) as money"
)
.
Scan
(
&
money
)
.
Error
;
err
!=
nil
{
return
0
,
err
return
0
,
err
}
}
...
@@ -45,7 +55,7 @@ func GetUsersChargeMoneySum(uids []uint64, sinceTime time.Time) (int64, error) {
...
@@ -45,7 +55,7 @@ func GetUsersChargeMoneySum(uids []uint64, sinceTime time.Time) (int64, error) {
// 获取代理范围内总充值金额
// 获取代理范围内总充值金额
// param sinceTime: 过去n时间内
// param sinceTime: 过去n时间内
// 返回美分
// 返回美分
func
GetUserDealerTransferMoneySum
(
uids
[]
uint64
,
sinceTime
time
.
Time
)
(
int64
,
error
)
{
func
GetUserDealerTransferMoneySum
(
uids
[]
uint64
)
(
int64
,
error
)
{
if
len
(
uids
)
<=
0
{
if
len
(
uids
)
<=
0
{
return
0
,
nil
return
0
,
nil
}
}
...
@@ -55,8 +65,8 @@ func GetUserDealerTransferMoneySum(uids []uint64, sinceTime time.Time) (int64, e
...
@@ -55,8 +65,8 @@ func GetUserDealerTransferMoneySum(uids []uint64, sinceTime time.Time) (int64, e
var
money
R
var
money
R
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"diamond_account_detail AS d"
)
.
if
err
:=
mysql
.
ProdReadOnlyDB
.
Table
(
"diamond_account_detail AS d"
)
.
Joins
(
"INNER JOIN dealer_transfer_detail AS t ON d.origin_id = t.id"
)
.
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
AND d.created_time >= ?
"
,
Where
(
"d.user_id in (?) AND operate_type = ? AND add_reduce = 1"
,
uids
,
26
,
sinceTime
)
.
Select
(
"SUM(t.dollar) as price"
)
.
uids
,
26
)
.
Select
(
"SUM(t.dollar) as price"
)
.
Scan
(
&
money
)
.
Error
;
err
!=
nil
{
Scan
(
&
money
)
.
Error
;
err
!=
nil
{
return
0
,
err
return
0
,
err
}
}
...
...
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