Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
financial-system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
xianyang
financial-system
Commits
9b25bbfa
Commit
9b25bbfa
authored
Dec 15, 2023
by
xianyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
12-15:公会查询优化
parent
2f954c9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
90 deletions
+7
-90
crud.py
app/api/account/crud.py
+7
-1
img_code.py
libs/img_code.py
+0
-89
No files found.
app/api/account/crud.py
View file @
9b25bbfa
...
...
@@ -420,7 +420,11 @@ class AccountStatistics(object):
if
not
old
.
get
(
'guild_id'
):
Logger
()
.
logger
.
info
(
"错误的公会数据:"
,
old
)
continue
df
=
bk
[(
bk
[
"guild_id"
]
==
old
[
'guild_id'
])
&
(
bk
[
"create_time"
]
==
old
[
'create_time'
])
&
(
bk
[
"amount_type"
]
==
2
)]
# 可消费
try
:
df
=
bk
[(
bk
[
"guild_id"
]
==
old
[
'guild_id'
])
&
(
bk
[
"create_time"
]
==
old
[
'create_time'
])
&
(
bk
[
"amount_type"
]
==
2
)]
# 可消费
except
Exception
as
e
:
Logger
()
.
logger
.
info
(
f
"处理可消费可提现报错:{e}"
)
continue
serializer_info
=
df
.
to_dict
(
orient
=
'records'
)
if
serializer_info
:
old
[
'con_income'
]
=
serializer_info
[
0
][
'income'
]
...
...
@@ -572,6 +576,8 @@ class AccountStatistics(object):
future2
=
pool
.
submit
(
LinkMysql
(
env
.
DB_3YV2
)
.
query_mysql
,
sql
)
other_data
=
future1
.
result
()
mysql_data
=
future2
.
result
()
Logger
(
20
)
.
logger
.
info
(
f
"other_sql:::{other_sql}"
)
Logger
(
20
)
.
logger
.
info
(
f
"sql:::{sql}"
)
for
info
in
mysql_data
:
info
[
'guild_name'
]
=
self
.
guild_dict
.
get
(
info
[
'guild_id'
])
mysql_data
=
self
.
special_handle
(
mysql_data
,
other_data
)
...
...
libs/img_code.py
deleted
100644 → 0
View file @
2f954c9e
import
base64
import
os.path
import
random
import
string
import
requests
import
socket
from
PIL
import
Image
,
ImageFont
,
ImageDraw
from
six
import
BytesIO
from
core.config.env
import
client
,
Bucket
,
secret_key
,
region
,
secret_id
,
COS_PATH
,
COS_RERURN_PATH
,
red
session
=
requests
.
session
()
class
imageCode
():
'''
验证码处理
'''
def
rndColor
(
self
):
'''随机颜色'''
return
(
random
.
randint
(
32
,
127
),
random
.
randint
(
32
,
127
),
random
.
randint
(
32
,
127
))
def
geneText
(
self
):
'''生成4位验证码'''
return
''
.
join
(
random
.
sample
(
string
.
ascii_letters
+
string
.
digits
,
4
))
# ascii_letters是生成所有字母 digits是生成所有数字0-9
def
drawLines
(
self
,
draw
,
num
,
width
,
height
):
'''划线'''
for
num
in
range
(
num
):
x1
=
random
.
randint
(
0
,
width
/
2
)
y1
=
random
.
randint
(
0
,
height
/
2
)
x2
=
random
.
randint
(
0
,
width
)
y2
=
random
.
randint
(
height
/
2
,
height
)
draw
.
line
(((
x1
,
y1
),
(
x2
,
y2
)),
fill
=
'black'
,
width
=
1
)
def
getVerifyCode
(
self
):
'''生成验证码图形'''
code
=
self
.
geneText
()
# 图片大小120×50
width
,
height
=
120
,
50
# 新图片对象
im
=
Image
.
new
(
'RGB'
,
(
width
,
height
),
'white'
)
# 字体
font_file
=
os
.
path
.
join
(
os
.
getcwd
(),
"static"
,
"DejaVuSans-BoldOblique.ttf"
)
font
=
ImageFont
.
truetype
(
font_file
,
40
)
# draw对象
draw
=
ImageDraw
.
Draw
(
im
)
# 绘制字符串
for
item
in
range
(
4
):
draw
.
text
((
5
+
random
.
randint
(
-
3
,
3
)
+
23
*
item
,
5
+
random
.
randint
(
-
3
,
3
)),
text
=
code
[
item
],
fill
=
self
.
rndColor
(),
font
=
font
)
# 划线
self
.
drawLines
(
draw
,
2
,
width
,
height
)
return
im
,
code
def
getImgCode
(
self
):
image
,
code
=
self
.
getVerifyCode
()
# 图片以二进制形式写入
buf
=
BytesIO
()
image
.
save
(
buf
,
'jpeg'
)
buf_str
=
buf
.
getvalue
()
img
=
b
"data:image/png;base64,"
+
base64
.
b64encode
(
buf_str
)
session
.
headers
[
'verify'
]
=
code
res
=
socket
.
gethostbyname
(
socket
.
gethostname
())
red
.
set
(
res
+
'-VerifyCode'
,
code
,
100
)
return
img
.
decode
(
'utf-8'
)
def
new_upload_file
(
file_object
,
filename
):
'''图片上传cos'''
filename
=
COS_RERURN_PATH
+
filename
+
'.png'
try
:
response
=
client
.
put_object
(
Bucket
=
Bucket
,
Body
=
file_object
,
Key
=
filename
,
)
except
Exception
as
e
:
print
(
"上传失败"
)
return
""
if
response
is
None
:
print
(
"上传成功"
)
return
filename
def
random_number
():
randomId
=
''
.
join
([
str
(
random
.
randint
(
1
,
999999
))
.
zfill
(
3
)
for
_
in
range
(
2
)])
return
randomId
\ No newline at end of file
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