Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Automat
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
冯佳佳
Automat
Commits
8065bc35
Commit
8065bc35
authored
Feb 10, 2022
by
Aeolus
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'aeolus'
parents
0247696d
8b3f4d93
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
279 additions
and
11 deletions
+279
-11
config/commen_config.py
+1
-2
models/models.py
+2
-0
models_tmp.py
+2
-1
myapps/automat/api/rent_portal.py
+10
-0
myapps/pc_management/api/__init__.py
+2
-0
myapps/pc_management/api/machine_portal.py
+35
-1
myapps/pc_management/api/tallyman_portal.py
+166
-0
service/admin_service.py
+59
-5
utils/jwt_util.py
+2
-2
No files found.
config/commen_config.py
View file @
8065bc35
...
@@ -49,8 +49,7 @@ AGENT_STATUS = {
...
@@ -49,8 +49,7 @@ AGENT_STATUS = {
'5'
:
'商户管理员'
,
'5'
:
'商户管理员'
,
'6'
:
'财务'
,
'6'
:
'财务'
,
'7'
:
'运维管理员'
,
'7'
:
'运维管理员'
,
'8'
:
'补货员'
,
'8'
:
'客服'
,
'9'
:
'客服'
,
}
}
ACCOUNT_STATUS
=
{
ACCOUNT_STATUS
=
{
...
...
models/models.py
View file @
8065bc35
...
@@ -429,6 +429,7 @@ class SalePlanProduction(Base):
...
@@ -429,6 +429,7 @@ class SalePlanProduction(Base):
updated_at
=
Column
(
TIMESTAMP
,
server_default
=
text
(
"CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
))
updated_at
=
Column
(
TIMESTAMP
,
server_default
=
text
(
"CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
))
class
TallymanAccount
(
Base
):
class
TallymanAccount
(
Base
):
__tablename__
=
'tallyman_account'
__tablename__
=
'tallyman_account'
...
@@ -437,6 +438,7 @@ class TallymanAccount(Base):
...
@@ -437,6 +438,7 @@ class TallymanAccount(Base):
user_name
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
),
nullable
=
False
)
user_name
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
),
nullable
=
False
)
phone
=
Column
(
String
(
191
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
unique
=
True
)
phone
=
Column
(
String
(
191
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
unique
=
True
)
level
=
Column
(
INTEGER
(
1
),
nullable
=
False
,
comment
=
'1:补货员'
)
level
=
Column
(
INTEGER
(
1
),
nullable
=
False
,
comment
=
'1:补货员'
)
business_id
=
Column
(
INTEGER
(
11
),
server_default
=
text
(
"'0'"
))
status
=
Column
(
INTEGER
(
1
),
nullable
=
False
,
comment
=
'1:正常 2:删除'
)
status
=
Column
(
INTEGER
(
1
),
nullable
=
False
,
comment
=
'1:正常 2:删除'
)
_password_hash_
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
))
_password_hash_
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
))
comment
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
))
comment
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
))
...
...
models_tmp.py
View file @
8065bc35
...
@@ -14,7 +14,7 @@ class AdminAccount(Base):
...
@@ -14,7 +14,7 @@ class AdminAccount(Base):
user_no
=
Column
(
String
(
25
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
unique
=
True
)
user_no
=
Column
(
String
(
25
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
unique
=
True
)
user_name
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
),
nullable
=
False
)
user_name
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
),
nullable
=
False
)
phone
=
Column
(
String
(
191
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
unique
=
True
)
phone
=
Column
(
String
(
191
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
unique
=
True
)
level
=
Column
(
TINYINT
(
2
),
nullable
=
False
,
comment
=
'1:超级管理员,2:代理商,3:业务员,4:财务,5:运维管理员,6:补货员,7:客服 '
)
level
=
Column
(
TINYINT
(
2
),
nullable
=
False
,
comment
=
"'1': '超级管理员','2': '管理员','3': '业务员','4': '商户管理员','5': '商户管理员','6': '财务','7': '运维管理员','8': '补货员','9': '客服',"
)
parent_id
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'上级ID'
)
parent_id
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'上级ID'
)
draw
=
Column
(
TINYINT
(
1
),
nullable
=
False
,
server_default
=
text
(
"'0'"
),
comment
=
'提现权限0不可以1可以'
)
draw
=
Column
(
TINYINT
(
1
),
nullable
=
False
,
server_default
=
text
(
"'0'"
),
comment
=
'提现权限0不可以1可以'
)
rate
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'分成比例'
)
rate
=
Column
(
INTEGER
(
10
),
nullable
=
False
,
comment
=
'分成比例'
)
...
@@ -500,6 +500,7 @@ class TallymanAccount(Base):
...
@@ -500,6 +500,7 @@ class TallymanAccount(Base):
user_name
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
),
nullable
=
False
)
user_name
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
),
nullable
=
False
)
phone
=
Column
(
String
(
191
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
unique
=
True
)
phone
=
Column
(
String
(
191
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
unique
=
True
)
level
=
Column
(
INTEGER
(
1
),
nullable
=
False
,
comment
=
'1:补货员'
)
level
=
Column
(
INTEGER
(
1
),
nullable
=
False
,
comment
=
'1:补货员'
)
business_id
=
Column
(
INTEGER
(
11
),
server_default
=
text
(
"'0'"
))
status
=
Column
(
INTEGER
(
1
),
nullable
=
False
,
comment
=
'1:正常 2:删除'
)
status
=
Column
(
INTEGER
(
1
),
nullable
=
False
,
comment
=
'1:正常 2:删除'
)
_password_hash_
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
))
_password_hash_
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
))
comment
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
))
comment
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
))
...
...
myapps/automat/api/rent_portal.py
View file @
8065bc35
...
@@ -99,6 +99,7 @@ def create_rent():
...
@@ -99,6 +99,7 @@ def create_rent():
rent
.
pay_time
=
datetime
.
datetime
.
now
()
rent
.
pay_time
=
datetime
.
datetime
.
now
()
rent
.
rent_type
=
type
rent
.
rent_type
=
type
rent
.
mch_platform
=
machine
.
mch_platform
rent
.
mch_platform
=
machine
.
mch_platform
rent
.
place_id
=
machine
.
place_id
rent_detail
=
RentDetail
()
rent_detail
=
RentDetail
()
rent_detail
.
rent_no
=
rent_no
rent_detail
.
rent_no
=
rent_no
...
@@ -113,6 +114,7 @@ def create_rent():
...
@@ -113,6 +114,7 @@ def create_rent():
rent_detail
.
production_type_id
=
open_hatch
.
production_type_id
rent_detail
.
production_type_id
=
open_hatch
.
production_type_id
rent_detail
.
production_type_name
=
open_hatch
.
production_type_name
rent_detail
.
production_type_name
=
open_hatch
.
production_type_name
rent_detail
.
price
=
0
rent_detail
.
price
=
0
rent_detail
.
original_price
=
open_hatch
.
original_price
rent_detail
.
total
=
0
rent_detail
.
total
=
0
rent_detail
.
rent_count
=
1
rent_detail
.
rent_count
=
1
rent_detail
.
img
=
open_hatch
.
img
rent_detail
.
img
=
open_hatch
.
img
...
@@ -326,6 +328,10 @@ def get_rent_detail():
...
@@ -326,6 +328,10 @@ def get_rent_detail():
tmp_data
[
"production_type_id"
]
=
i
.
production_type_id
tmp_data
[
"production_type_id"
]
=
i
.
production_type_id
tmp_data
[
"production_type_name"
]
=
i
.
production_type_name
tmp_data
[
"production_type_name"
]
=
i
.
production_type_name
tmp_data
[
"price"
]
=
i
.
price
tmp_data
[
"price"
]
=
i
.
price
tmp_data
[
"total"
]
=
i
.
total
tmp_data
[
"rent_count"
]
=
i
.
rent_count
tmp_data
[
"refund_total"
]
=
i
.
refund_total
tmp_data
[
"refund_count"
]
=
i
.
refund_count
tmp_data
[
"img"
]
=
i
.
img
tmp_data
[
"img"
]
=
i
.
img
tmp_data
[
"tags"
]
=
i
.
tags
tmp_data
[
"tags"
]
=
i
.
tags
tmp_data
[
"content"
]
=
i
.
content
tmp_data
[
"content"
]
=
i
.
content
...
@@ -364,6 +370,10 @@ def get_user_detail_record():
...
@@ -364,6 +370,10 @@ def get_user_detail_record():
tmp_data
[
"production_type_id"
]
=
i
.
production_type_id
tmp_data
[
"production_type_id"
]
=
i
.
production_type_id
tmp_data
[
"production_type_name"
]
=
i
.
production_type_name
tmp_data
[
"production_type_name"
]
=
i
.
production_type_name
tmp_data
[
"price"
]
=
i
.
price
tmp_data
[
"price"
]
=
i
.
price
tmp_data
[
"total"
]
=
i
.
total
tmp_data
[
"rent_count"
]
=
i
.
rent_count
tmp_data
[
"refund_total"
]
=
i
.
refund_total
tmp_data
[
"refund_count"
]
=
i
.
refund_count
tmp_data
[
"img"
]
=
i
.
img
tmp_data
[
"img"
]
=
i
.
img
tmp_data
[
"tags"
]
=
i
.
tags
tmp_data
[
"tags"
]
=
i
.
tags
tmp_data
[
"content"
]
=
i
.
content
tmp_data
[
"content"
]
=
i
.
content
...
...
myapps/pc_management/api/__init__.py
View file @
8065bc35
...
@@ -19,6 +19,7 @@ from myapps.pc_management.api.production_portal import production_route
...
@@ -19,6 +19,7 @@ from myapps.pc_management.api.production_portal import production_route
from
myapps.pc_management.api.hatch_portal
import
hatch_route
from
myapps.pc_management.api.hatch_portal
import
hatch_route
from
myapps.pc_management.api.business_portal
import
business_route
from
myapps.pc_management.api.business_portal
import
business_route
from
myapps.pc_management.api.rent_portal
import
rent_route
from
myapps.pc_management.api.rent_portal
import
rent_route
from
myapps.pc_management.api.tallyman_portal
import
tallyman_route
def
register_sukang_blueprint
(
app
:
Flask
):
def
register_sukang_blueprint
(
app
:
Flask
):
...
@@ -31,3 +32,4 @@ def register_sukang_blueprint(app: Flask):
...
@@ -31,3 +32,4 @@ def register_sukang_blueprint(app: Flask):
app
.
register_blueprint
(
hatch_route
,
url_prefix
=
prefix
+
"/hatch"
)
app
.
register_blueprint
(
hatch_route
,
url_prefix
=
prefix
+
"/hatch"
)
app
.
register_blueprint
(
business_route
,
url_prefix
=
prefix
+
"/business"
)
app
.
register_blueprint
(
business_route
,
url_prefix
=
prefix
+
"/business"
)
app
.
register_blueprint
(
rent_route
,
url_prefix
=
prefix
+
"/rent"
)
app
.
register_blueprint
(
rent_route
,
url_prefix
=
prefix
+
"/rent"
)
app
.
register_blueprint
(
tallyman_route
,
url_prefix
=
prefix
+
"/tallyman"
)
myapps/pc_management/api/machine_portal.py
View file @
8065bc35
...
@@ -14,7 +14,7 @@ from flask import Blueprint, g, request, jsonify
...
@@ -14,7 +14,7 @@ from flask import Blueprint, g, request, jsonify
from
config.commen_config
import
DISCOUNTS_TYPES
from
config.commen_config
import
DISCOUNTS_TYPES
from
models.base_model
import
db
from
models.base_model
import
db
from
models.models
import
AdminMachine
,
Machine
,
AdminAccount
,
AdminBusiness
from
models.models
import
AdminMachine
,
Machine
,
AdminAccount
,
AdminBusiness
,
TallymanMachine
from
service.admin_service
import
AdminService
from
service.admin_service
import
AdminService
from
utils.error_code
import
MACHINE_NOT_EXIST_ERROR
,
ACCOUNT_NOT_EXISTS_ERROR
,
ADMIN_BUSINESS_NOT_EXIST
from
utils.error_code
import
MACHINE_NOT_EXIST_ERROR
,
ACCOUNT_NOT_EXISTS_ERROR
,
ADMIN_BUSINESS_NOT_EXIST
from
utils.my_response
import
BaseResponse
from
utils.my_response
import
BaseResponse
...
@@ -248,3 +248,37 @@ def run_distribute_machine():
...
@@ -248,3 +248,37 @@ def run_distribute_machine():
return_machine_no
.
append
(
i
)
return_machine_no
.
append
(
i
)
return
BaseResponse
(
data
=
{
"add_machine_nos"
:
return_machine_no
})
return
BaseResponse
(
data
=
{
"add_machine_nos"
:
return_machine_no
})
@machine_route.route
(
"distribute_tallyman_machine"
,
methods
=
[
"POST"
])
def
run_distribute_tallyman_machine
():
"""
:return:
"""
json_data
=
request
.
get_json
()
machine_nos
=
json_data
[
"machine_nos"
]
user_id
=
json_data
[
"user_id"
]
result
=
AdminService
.
get_tallyman_account_list
(
user_id
=
user_id
)
if
result
[
"total_count"
]
!=
1
:
return
jsonify
(
ACCOUNT_NOT_EXISTS_ERROR
)
admin_info
=
json2obj
(
result
[
"list"
][
0
])
return_machine_no
=
[]
for
i
in
machine_nos
:
admin_machines
=
AdminMachine
.
query
.
filter_by
(
user_id
=
g
.
user
.
id
,
machine_no
=
i
,
status
=
1
)
.
first
()
if
not
admin_machines
:
continue
machine
=
Machine
.
query
.
filter_by
(
machine_no
=
i
)
.
first
()
if
not
machine
:
continue
insert_sql
=
" insert into tallyman_machine (user_id, machine_no) values "
insert_sql
+=
"('{}','{}'),"
.
format
(
admin_info
.
id
,
i
)
insert_sql
=
insert_sql
[:
-
1
]
insert_sql
+=
" ON DUPLICATE KEY UPDATE status = 1"
db
.
session
.
execute
(
insert_sql
)
db
.
session
.
commit
()
return_machine_no
.
append
(
i
)
return
BaseResponse
(
data
=
{
"add_machine_nos"
:
return_machine_no
})
myapps/pc_management/api/tallyman_portal.py
0 → 100644
View file @
8065bc35
#!usr/bin/env python
# -*- coding:utf-8 _*-
"""
@version:
author:Aeolus
@time: 2022/01/12
@file: place_portal.py
@function:
@modify:
"""
import
datetime
import
logging
from
flask
import
Blueprint
,
g
,
request
,
jsonify
from
models.base_model
import
db
from
models.models
import
AdminPlace
,
Place
,
TallymanMachine
,
Machine
,
TallymanAccount
from
service.admin_service
import
AdminService
from
utils.error_code
import
NO_PLACE_ERROR
,
TALLYMAN_ACCOUNT_NOT_EXIST
,
TALLYMAN_ACCOUNT_EXIST
,
OPERATE_LEVEL_ERROR
,
\
ACCOUNT_NOT_EXISTS_ERROR
from
utils.my_response
import
BaseResponse
from
utils.mytools
import
json2obj
logger
=
logging
.
getLogger
(
__name__
)
tallyman_route
=
Blueprint
(
'tallyman'
,
__name__
)
@tallyman_route.route
(
'/tallyman_list'
,
methods
=
[
"POST"
])
def
get_account_list
():
json_data
=
request
.
get_json
()
page
=
json_data
.
get
(
"page"
,
1
)
page_size
=
json_data
.
get
(
"pageSize"
,
10
)
keyword
=
json_data
.
get
(
"keyword"
,
None
)
return_data
=
AdminService
.
get_tallyman_account_list
(
keyword
=
keyword
,
page
=
page
,
page_size
=
page_size
)
return
BaseResponse
(
return_data
)
@tallyman_route.route
(
'/edit_tallyman_account'
,
methods
=
[
'GET'
,
'POST'
])
def
run_tallyman_edit_account
():
admin
=
g
.
user
if
g
.
user
.
level
not
in
(
1
,
2
,
4
):
return
jsonify
(
OPERATE_LEVEL_ERROR
)
json_data
=
request
.
get_json
()
old_phone
=
json_data
[
'old_phone'
]
new_phone
=
json_data
.
get
(
'new_phone'
,
None
)
user_name
=
json_data
.
get
(
'user_name'
,
None
)
password
=
json_data
.
get
(
'password'
,
None
)
business_id
=
json_data
.
get
(
'business_id'
,
None
)
status
=
json_data
.
get
(
'status'
,
None
)
tallyman_info
=
TallymanAccount
.
query
.
filter_by
(
phone
=
old_phone
)
.
first
()
if
not
tallyman_info
:
return
jsonify
(
TALLYMAN_ACCOUNT_NOT_EXIST
)
if
new_phone
:
tallyman_info
.
phone
=
new_phone
if
user_name
:
tallyman_info
.
user_name
=
user_name
if
password
:
tallyman_info
.
password
=
password
if
status
:
tallyman_info
.
status
=
status
if
business_id
:
tallyman_info
.
business_id
=
business_id
db
.
session
.
add
(
tallyman_info
)
db
.
session
.
commit
()
return
BaseResponse
()
@tallyman_route.route
(
'/add_tallyman_account'
,
methods
=
[
'GET'
,
'POST'
])
def
run_add_tallyman_account
():
admin
=
g
.
user
if
g
.
user
.
level
not
in
(
1
,
2
,
4
):
return
jsonify
(
OPERATE_LEVEL_ERROR
)
json_data
=
request
.
get_json
()
user_name
=
json_data
[
'user_name'
]
if
'user_name'
in
json_data
else
'SSW'
phone
=
json_data
[
'phone'
]
if
'phone'
in
json_data
else
None
level
=
int
(
json_data
[
'level'
])
if
'level'
in
json_data
else
2
password
=
json_data
[
'password'
]
if
'password'
in
json_data
else
None
comment
=
json_data
[
'comment'
]
if
'comment'
in
json_data
else
''
business_id
=
json_data
[
"business_id"
]
tallyman
=
TallymanAccount
.
query
.
filter_by
(
phone
=
phone
)
.
first
()
if
tallyman
:
if
tallyman
.
status
!=
-
1
:
return
jsonify
(
TALLYMAN_ACCOUNT_EXIST
)
else
:
tallyman
=
TallymanAccount
()
tallyman
.
user_no
=
"todo"
tallyman
.
user_name
=
user_name
tallyman
.
phone
=
phone
tallyman
.
level
=
level
tallyman
.
business_id
=
business_id
tallyman
.
status
=
1
tallyman
.
comment
=
comment
tallyman
.
created_at
=
datetime
.
datetime
.
now
()
tallyman
.
updated_at
=
datetime
.
datetime
.
now
()
if
password
:
tallyman
.
password
=
password
db
.
session
.
add
(
tallyman
)
db
.
session
.
commit
()
tallyman
.
user_no
=
"XXTM"
+
str
(
tallyman
.
id
)
.
zfill
(
6
)
db
.
session
.
add
(
tallyman
)
db
.
session
.
commit
()
return
BaseResponse
()
@tallyman_route.route
(
'/delete_tallyman_account'
,
methods
=
[
'GET'
,
'POST'
])
def
run_delete_tallyman_account
():
json_data
=
request
.
get_json
()
if
g
.
user
.
level
not
in
(
1
,
2
,
4
):
return
jsonify
(
OPERATE_LEVEL_ERROR
)
phone
=
json_data
[
'phone'
]
tallyman
=
TallymanAccount
.
query
.
filter_by
(
phone
=
phone
)
.
first
()
if
not
tallyman
:
return
BaseResponse
()
tallyman
.
status
=
-
1
db
.
session
.
add
(
tallyman
)
tallyman_machine_info
=
TallymanMachine
.
query
.
filter_by
(
user_id
=
tallyman
.
id
)
.
all
()
for
info
in
tallyman_machine_info
:
info
.
status
=
-
1
db
.
session
.
add
(
info
)
db
.
session
.
commit
()
return
BaseResponse
()
@tallyman_route.route
(
'/tallyman_account_detail'
,
methods
=
[
"POST"
])
def
get_tallyman_account_detail
():
json_data
=
request
.
get_json
()
if
g
.
user
.
level
not
in
(
1
,
2
,
4
):
return
jsonify
(
OPERATE_LEVEL_ERROR
)
phone
=
json_data
[
"phone"
]
if
phone
==
g
.
user
.
phone
:
admin_info
=
g
.
user
else
:
result
=
AdminService
.
get_tallyman_account_list
(
phone
=
phone
)
if
result
[
"total_count"
]
!=
1
:
return
BaseResponse
(
ACCOUNT_NOT_EXISTS_ERROR
)
admin_info
=
json2obj
(
result
[
"list"
][
0
])
user_info
=
{
"id"
:
admin_info
.
id
,
"user_no"
:
admin_info
.
user_no
,
"user_name"
:
admin_info
.
user_name
,
"phone"
:
admin_info
.
phone
,
"level"
:
admin_info
.
level
,
"business_id"
:
admin_info
.
business_id
,
"status"
:
admin_info
.
status
,
"comment"
:
admin_info
.
comment
}
return
BaseResponse
(
data
=
user_info
)
service/admin_service.py
View file @
8065bc35
...
@@ -10,11 +10,6 @@ from flask import g
...
@@ -10,11 +10,6 @@ from flask import g
from
config.commen_config
import
ACCOUNT_STATUS
from
config.commen_config
import
ACCOUNT_STATUS
from
models.models
import
AdminAccount
,
Business
,
AdminBusiness
from
models.models
import
AdminAccount
,
Business
,
AdminBusiness
from
models.base_model
import
db
from
models.base_model
import
db
from
models.models
import
Place
# from models.user_models import AgentAccount
# from service.spot_service import SpotService
class
AdminService
(
object
):
class
AdminService
(
object
):
...
@@ -122,3 +117,62 @@ class AdminService(object):
...
@@ -122,3 +117,62 @@ class AdminService(object):
"update_time"
:
info
.
updated_at
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
"update_time"
:
info
.
updated_at
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
})
})
return
{
"list"
:
return_data
,
"page"
:
page
,
"pageSize"
:
page_size
,
"total_count"
:
total_count
}
return
{
"list"
:
return_data
,
"page"
:
page
,
"pageSize"
:
page_size
,
"total_count"
:
total_count
}
@staticmethod
def
get_tallyman_account_list
(
user_id
=
None
,
phone
=
None
,
keyword
=
None
,
page
=
None
,
page_size
=
None
):
"""
:return:
"""
select_sql
=
"""select tallyman_account.user_name, tallyman_account.phone, tallyman_account.level,
tallyman_account.status,tallyman_account.created_at, tallyman_account.updated_at,
tallyman_account.id, tallyman_account.user_no, tallyman_account.comment,
tallyman_account.business_id
"""
count_sql
=
"select count(tallyman_account.id) as total_count"
from_sql
=
" from tallyman_account "
if
g
.
user
.
level
==
1
:
where_sql
=
" where 0=0 "
else
:
where_sql
=
"""
where
tallyman_account.business_id in (
select business_id from admin_business where user_id = {user_id} and status = 1
)
"""
.
format
(
user_id
=
g
.
user
.
id
)
if
user_id
:
where_sql
+=
" and tallyman_account.id = '{id}'"
.
format
(
id
=
user_id
)
if
phone
:
where_sql
+=
" and phone = '{phone}'"
.
format
(
phone
=
phone
)
if
keyword
:
where_sql
+=
"""
and CONCAT( tallyman_account.user_name,
tallyman_account.phone) LIKE '
%
{keyword}
%
'
"""
.
format
(
keyword
=
keyword
)
order_sql
=
" ORDER BY tallyman_account.id ASC, tallyman_account.status ASC"
if
page
and
page_size
:
limit_sql
=
" LIMIT {offset} , {page_size} "
.
format
(
offset
=
(
page
-
1
)
*
page_size
,
page_size
=
page_size
)
else
:
limit_sql
=
" "
count_result
=
db
.
session
.
execute
(
count_sql
+
from_sql
+
where_sql
)
.
fetchone
()
if
not
count_result
:
return
{
"list"
:
[],
"page"
:
page
,
"pageSize"
:
page_size
,
"total_count"
:
0
}
else
:
total_count
=
count_result
.
total_count
print
(
select_sql
+
from_sql
+
where_sql
+
order_sql
+
limit_sql
)
result
=
db
.
session
.
execute
(
select_sql
+
from_sql
+
where_sql
+
order_sql
+
limit_sql
)
.
fetchall
()
return_data
=
[]
for
info
in
result
:
return_data
.
append
(
{
"user_name"
:
info
.
user_name
,
"phone"
:
info
.
phone
,
"level"
:
info
.
level
,
"status"
:
info
.
status
,
"comment"
:
info
.
comment
,
"id"
:
info
.
id
,
"user_no"
:
info
.
user_no
,
"business_id"
:
info
.
business_id
,
"create_time"
:
info
.
created_at
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
"update_time"
:
info
.
updated_at
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
})
return
{
"list"
:
return_data
,
"page"
:
page
,
"pageSize"
:
page_size
,
"total_count"
:
total_count
}
utils/jwt_util.py
View file @
8065bc35
#!usr/bin/.env python # -*- coding:utf-8 _*- """ @version: author:Aeolus @time: 2021/03/30 @file: jwt_util.py @function: @modify: """ import jwt from flask import current_app def generate_jwt(payload, expiry, secret=None): """ 生成jwt :param payload: dict 载荷 :param expiry: datetime 有效期 :param secret: 密钥 :return: jwt """ _payload = {'exp': expiry} _payload.update(payload) if not secret: secret = current_app.config['SECRET_KEY'] token = jwt.encode(_payload, secret, algorithm='HS256') return token def verify_jwt(token, secret=None): """ 检验jwt :param token: jwt :param secret: 密钥 :return: dict: payload """ if not secret: secret = current_app.config['SECRET_KEY'] try: payload = jwt.decode(token, secret, algorithms=['HS256']) except jwt.PyJWTError: payload = None return payload if __name__ == '__main__': import time from config.env_path_config import env_path from dotenv import load_dotenv load_dotenv(dotenv_path=env_path, verbose=True, override=True) import os SECRET_KEY = os.getenv('SECRET_KEY') token = generate_jwt({"user_id": 1}, time.time() + 6000, SECRET_KEY) # token = generate_jwt({"user_no": 'SK000007'}, time.time() + 6000, SECRET_KEY) print(token) # for i in range(10): # result = verify_jwt(token, 'secret') # print(result) # print(time.time()) # time.sleep(1)
#!usr/bin/.env python # -*- coding:utf-8 _*- """ @version: author:Aeolus @time: 2021/03/30 @file: jwt_util.py @function: @modify: """ import jwt from flask import current_app def generate_jwt(payload, expiry, secret=None): """ 生成jwt :param payload: dict 载荷 :param expiry: datetime 有效期 :param secret: 密钥 :return: jwt """ _payload = {'exp': expiry} _payload.update(payload) if not secret: secret = current_app.config['SECRET_KEY'] token = jwt.encode(_payload, secret, algorithm='HS256') return token def verify_jwt(token, secret=None): """ 检验jwt :param token: jwt :param secret: 密钥 :return: dict: payload """ if not secret: secret = current_app.config['SECRET_KEY'] try: payload = jwt.decode(token, secret, algorithms=['HS256']) except jwt.PyJWTError: payload = None return payload if __name__ == '__main__': import time from config.env_path_config import env_path from dotenv import load_dotenv load_dotenv(dotenv_path=env_path, verbose=True, override=True) import os SECRET_KEY = os.getenv('SECRET_KEY') token = generate_jwt({"user_id": 10}, time.time() + 6000, SECRET_KEY) # token = generate_jwt({"user_no": 'SK000007'}, time.time() + 6000, SECRET_KEY) print(token) # for i in range(10): # result = verify_jwt(token, 'secret') # print(result) # print(time.time()) # time.sleep(1)
\ No newline at end of file
\ 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