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
129b3e6a
Commit
129b3e6a
authored
Jan 09, 2022
by
Aeolus
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/yanglei'
parents
e4bbefdb
7b2fe02d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
283 additions
and
35 deletions
+283
-35
models/models.py
+9
-1
myapps/management/api/__init__.py
+6
-2
myapps/management/api/login.py
+21
-11
myapps/management/api/machine_portal.py
+99
-16
myapps/management/api/rent_portal.py
+3
-3
myapps/management/api/tallyman_portal.py
+132
-0
service/machine_service.py
+11
-0
utils/error_code.py
+2
-2
No files found.
models/models.py
View file @
129b3e6a
...
@@ -363,7 +363,6 @@ class Management(Base):
...
@@ -363,7 +363,6 @@ class Management(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
(
255
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
unique
=
True
)
phone
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
unique
=
True
)
key
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
),
nullable
=
False
,
unique
=
True
)
level
=
Column
(
INTEGER
(
1
),
nullable
=
False
,
comment
=
'1:补货员'
)
level
=
Column
(
INTEGER
(
1
),
nullable
=
False
,
comment
=
'1:补货员'
)
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'
))
...
@@ -384,3 +383,12 @@ class Management(Base):
...
@@ -384,3 +383,12 @@ class Management(Base):
# 使用check_password,进行密码校验,返回True False。
# 使用check_password,进行密码校验,返回True False。
def
check_password
(
self
,
pasword
):
def
check_password
(
self
,
pasword
):
return
check_password_hash
(
self
.
_password_hash_
,
pasword
)
return
check_password_hash
(
self
.
_password_hash_
,
pasword
)
class
TallymanPlace
(
Base
):
__tablename__
=
'tallyman_place'
id
=
Column
(
INTEGER
(
11
),
primary_key
=
True
,
unique
=
True
)
user_id
=
Column
(
String
(
25
,
'utf8mb4_unicode_ci'
))
place_id
=
Column
(
String
(
255
,
'utf8mb4_unicode_ci'
))
status
=
Column
(
TINYINT
(
3
),
nullable
=
False
,
comment
=
'状态1绑定 -1未绑定'
)
created_at
=
Column
(
DateTime
,
nullable
=
False
,
server_default
=
text
(
"CURRENT_TIMESTAMP"
))
updated_at
=
Column
(
DateTime
,
nullable
=
False
,
server_default
=
text
(
"CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
))
myapps/management/api/__init__.py
View file @
129b3e6a
...
@@ -7,9 +7,10 @@ author:Aeolus
...
@@ -7,9 +7,10 @@ author:Aeolus
"""
"""
from
flask
import
Flask
from
flask
import
Flask
from
myapps.management.api.rent_
query
import
rent_query_route
from
myapps.management.api.rent_
portal
import
rent_query_route
from
myapps.management.api.machine_
management
import
machine_query_route
from
myapps.management.api.machine_
portal
import
machine_query_route
from
myapps.management.api.login
import
login_route
from
myapps.management.api.login
import
login_route
from
myapps.management.api.tallyman_portal
import
tallyman_route
...
@@ -18,3 +19,6 @@ def register_management_blueprint(app: Flask):
...
@@ -18,3 +19,6 @@ def register_management_blueprint(app: Flask):
app
.
register_blueprint
(
rent_query_route
,
url_prefix
=
prefix
+
"/rent"
)
app
.
register_blueprint
(
rent_query_route
,
url_prefix
=
prefix
+
"/rent"
)
app
.
register_blueprint
(
machine_query_route
,
url_prefix
=
prefix
+
"/machine"
)
app
.
register_blueprint
(
machine_query_route
,
url_prefix
=
prefix
+
"/machine"
)
app
.
register_blueprint
(
login_route
,
url_prefix
=
prefix
+
"/login"
)
app
.
register_blueprint
(
login_route
,
url_prefix
=
prefix
+
"/login"
)
app
.
register_blueprint
(
tallyman_route
,
url_prefix
=
prefix
+
"/tallyman"
)
myapps/management/api/login.py
View file @
129b3e6a
...
@@ -3,9 +3,12 @@
...
@@ -3,9 +3,12 @@
import
json
import
json
import
logging
import
logging
import
re
import
time
import
time
import
os
from
utils.jwt_util
import
generate_jwt
from
config.env_path_config
import
env_path
from
dotenv
import
load_dotenv
from
flask
import
Blueprint
,
request
,
jsonify
,
g
from
flask
import
Blueprint
,
request
,
jsonify
,
g
from
models.base_model
import
db
from
models.base_model
import
db
from
utils.my_response
import
BaseResponse
from
utils.my_response
import
BaseResponse
...
@@ -22,28 +25,35 @@ def login():
...
@@ -22,28 +25,35 @@ def login():
json_date
=
request
.
get_json
()
json_date
=
request
.
get_json
()
number
=
json_date
[
"number"
]
number
=
json_date
[
"number"
]
password
=
json_date
[
'password'
]
password
=
json_date
[
'password'
]
key
=
json_date
[
"key"
]
#手机号登录
#手机号登录
phone_result
=
Management
.
query
.
filter_by
(
phone
=
number
,
status
=
1
)
.
first
()
phone_result
=
Management
.
query
.
filter_by
(
phone
=
number
,
status
=
1
)
.
first
()
if
phone_result
:
if
phone_result
:
# 进行密码验证
# 进行密码验证
if
phone_result
.
check_password
(
password
)
==
True
:
if
phone_result
.
check_password
(
password
)
==
True
:
token_making
=
generate_token
(
key
,
360
)
load_dotenv
(
dotenv_path
=
env_path
,
verbose
=
True
,
override
=
True
)
# 从获取库里获取key
SECRET_KEY
=
os
.
getenv
(
'SECRET_KEY'
)
ky
=
phone_result
.
key
token
=
generate_jwt
({
"user_id"
:
phone_result
.
id
},
time
.
time
()
+
6000
,
SECRET_KEY
)
return
BaseResponse
(
data
=
certify_token
(
ky
,
token_making
))
date
=
{
"token"
:
token
,
"success"
:
True
}
return
BaseResponse
(
data
=
date
)
else
:
else
:
return
BaseResponse
(
**
PASSWORD_ERROR
)
return
BaseResponse
(
**
PASSWORD_ERROR
)
#用户id登录
#
用户id登录
user_result
=
Management
.
query
.
filter_by
(
user_no
=
number
,
status
=
1
)
.
first
()
user_result
=
Management
.
query
.
filter_by
(
user_no
=
number
,
status
=
1
)
.
first
()
if
user_result
:
if
user_result
:
# 进行密码验证
# 进行密码验证
if
user_result
.
check_password
(
password
)
==
True
:
if
user_result
.
check_password
(
password
)
==
True
:
token_making
=
generate_token
(
key
,
360
)
load_dotenv
(
dotenv_path
=
env_path
,
verbose
=
True
,
override
=
True
)
# 从获取库里获取key
SECRET_KEY
=
os
.
getenv
(
'SECRET_KEY'
)
ky
=
user_result
.
key
token
=
generate_jwt
({
"user_id"
:
user_result
.
id
},
time
.
time
()
+
6000
,
SECRET_KEY
)
return
BaseResponse
(
data
=
certify_token
(
ky
,
token_making
))
date
=
{
"token"
:
token
,
"success"
:
True
}
return
BaseResponse
(
data
=
date
)
else
:
else
:
return
BaseResponse
(
**
PASSWORD_ERROR
)
return
BaseResponse
(
**
PASSWORD_ERROR
)
...
...
myapps/management/api/machine_
management
.py
→
myapps/management/api/machine_
portal
.py
View file @
129b3e6a
#!usr/bin/env python
#!usr/bin/env python
# -*- coding:utf-8 _*-
# -*- coding:utf-8 _*-
import
os
import
json
import
json
import
logging
import
logging
import
re
import
time
import
time
from
flask
import
Blueprint
,
request
,
jsonify
,
g
from
flask
import
Blueprint
,
request
,
jsonify
,
g
from
models.base_model
import
db
from
models.base_model
import
db
from
utils.my_response
import
BaseResponse
from
utils.my_response
import
BaseResponse
from
models.models
import
Machine
,
Hatch
from
models.models
import
Machine
,
Hatch
,
Place
,
Management
from
utils.error_code
import
MACHINE_NOT_EXIST_ERROR
from
utils.error_code
import
MACHINE_NOT_EXIST_ERROR
,
NO_PLACE_ERROR
,
TOKEN_NOT_VALID_ERROR
from
utils.jwt_util
import
verify_jwt
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
# 创建蓝图
# 创建蓝图
machine_query_route
=
Blueprint
(
'machine'
,
__name__
)
machine_query_route
=
Blueprint
(
'machine'
,
__name__
)
# 模糊查询到机器信息
@machine_query_route.route
(
"query_machine"
,
methods
=
[
"post"
])
def
query_machine
():
json_date
=
request
.
get_json
()
number
=
json_date
[
"number"
]
page
=
json_date
[
"page"
]
page_size
=
json_date
[
"page_size"
]
pass
# 修改机器信息
# 修改机器信息
@machine_query_route.route
(
"query_edit"
,
methods
=
[
"post"
])
@machine_query_route.route
(
"query_edit"
,
methods
=
[
"post"
])
def
query_edit
():
def
query_edit
():
...
@@ -37,7 +28,8 @@ def query_edit():
...
@@ -37,7 +28,8 @@ def query_edit():
{
"address"
:
address
,
"short_address"
:
short_address
,
"status"
:
status
}
{
"address"
:
address
,
"short_address"
:
short_address
,
"status"
:
status
}
)
)
db
.
session
.
commit
()
db
.
session
.
commit
()
return
BaseResponse
()
return
BaseResponse
(
data
=
True
)
# 显出机柜数量
# 显出机柜数量
@machine_query_route.route
(
"hatch_query"
,
methods
=
[
"post"
])
@machine_query_route.route
(
"hatch_query"
,
methods
=
[
"post"
])
def
hatch_query
():
def
hatch_query
():
...
@@ -78,7 +70,7 @@ def query():
...
@@ -78,7 +70,7 @@ def query():
else
:
# 有返回add信息
else
:
# 有返回add信息
add_result
=
Machine
.
query
.
filter
(
Machine
.
address
.
like
(
"
%
"
+
get_number
+
"
%
"
))
.
offset
((
page
-
1
)
*
page_size
)
.
limit
(
add_result
=
Machine
.
query
.
filter
(
Machine
.
address
.
like
(
"
%
"
+
get_number
+
"
%
"
))
.
offset
((
page
-
1
)
*
page_size
)
.
limit
(
page_size
page_size
)
.
all
()
)
result_date
=
[]
result_date
=
[]
for
add
in
add_result
:
for
add
in
add_result
:
date
=
{
date
=
{
...
@@ -92,7 +84,7 @@ def query():
...
@@ -92,7 +84,7 @@ def query():
return
BaseResponse
(
data
=
result_date
,
page
=
page
,
page_size
=
page_size
)
return
BaseResponse
(
data
=
result_date
,
page
=
page
,
page_size
=
page_size
)
else
:
else
:
machine_result
=
Machine
.
query
.
filter
(
Machine
.
machine_no
.
like
(
"
%
"
+
get_number
+
"
%
"
))
.
offset
((
page
-
1
)
*
page_size
)
.
\
machine_result
=
Machine
.
query
.
filter
(
Machine
.
machine_no
.
like
(
"
%
"
+
get_number
+
"
%
"
))
.
offset
((
page
-
1
)
*
page_size
)
.
\
limit
(
page_size
)
.
all
()
limit
(
page_size
)
result_date
=
[]
result_date
=
[]
for
machine
in
machine_result
:
for
machine
in
machine_result
:
date
=
{
date
=
{
...
@@ -104,3 +96,94 @@ def query():
...
@@ -104,3 +96,94 @@ def query():
}
}
result_date
.
append
(
date
)
result_date
.
append
(
date
)
return
BaseResponse
(
data
=
result_date
,
page
=
page
,
page_size
=
page_size
)
return
BaseResponse
(
data
=
result_date
,
page
=
page
,
page_size
=
page_size
)
# 机器查询machine_query
@machine_query_route.route
(
"machine_query"
,
methods
=
[
"post"
])
def
machine_query
():
token
=
request
.
headers
.
get
(
'Authorization'
)
json_date
=
request
.
get_json
()
page
=
json_date
[
"page"
]
page_size
=
json_date
[
"page_size"
]
if
token
:
SECRET_KEY
=
os
.
getenv
(
'SECRET_KEY'
)
payload
=
verify_jwt
(
token
,
SECRET_KEY
)
# return str(payload.get("user_id"))
# 这边是拿到了user_id,接下来链表查询即可
if
not
payload
:
return
TOKEN_NOT_VALID_ERROR
else
:
user_id
=
payload
.
get
(
"user_id"
)
if
not
user_id
:
return
TOKEN_NOT_VALID_ERROR
user_info
=
Management
.
query
.
filter_by
()
.
first
()
if
not
user_info
:
return
TOKEN_NOT_VALID_ERROR
if
"machine_no"
in
json_date
:
machine_no
=
json_date
[
"machine_no"
]
query1
=
"select a.* ,b.management_id FROM machine as a JOIN management_machine as b ON "
\
"a.machine_no = b.machine_no WHERE management_id='{}' and a.machine_no like '{}' limit {},{}"
.
\
format
(
user_id
,
"
%
"
+
machine_no
+
"
%
"
,
(
page
-
1
)
*
page_size
,
page
*
page_size
)
elif
"machine_mac"
in
json_date
:
machine_mac
=
json_date
[
"machine_mac"
]
# machine_result = Machine.query.filter(Machine.mac.like("%"+machine_mac+"%")).offset((page-1)*page_size).limit(page_size)
query1
=
"select a.* ,b.management_id FROM machine as a JOIN management_machine as b ON "
\
"a.machine_no = b.machine_no WHERE management_id='{}' and mac like '{}' limit {},{}"
.
\
format
(
user_id
,
"
%
"
+
machine_mac
+
"
%
"
,
(
page
-
1
)
*
page_size
,
page
*
page_size
)
else
:
query1
=
"select a.* ,b.management_id FROM machine as a JOIN management_machine as b ON "
\
"a.machine_no = b.machine_no WHERE management_id={} limit {},{}"
.
\
format
(
user_id
,
(
page
-
1
)
*
page_size
,
page
*
page_size
)
machine_result
=
db
.
session
.
execute
(
query1
)
.
fetchall
()
result_date
=
[]
# # 将数据遍历和筛选
for
i
in
machine_result
:
date
=
{
"machine_no"
:
i
.
machine_no
,
"machine_mac"
:
i
.
mac
,
"status"
:
i
.
status
,
"short_address"
:
i
.
short_address
,
"address"
:
i
.
address
,
"address_id"
:
i
.
place_id
}
result_date
.
append
(
date
)
return
BaseResponse
(
date
=
result_date
)
else
:
return
"no_token"
# 编辑机柜edit_machine
@machine_query_route.route
(
"edit_machine"
,
methods
=
[
"post"
])
def
update_machine
():
json_data
=
request
.
get_json
()
machine_no
=
json_data
[
"machine_no"
]
machine_mac
=
json_data
[
"machine_mac"
]
short_address
=
json_data
[
"short_address"
]
if
"short_address"
in
json_data
else
None
address_id
=
json_data
[
"address_id"
]
address_result
=
Place
.
query
.
filter_by
(
id
=
address_id
)
.
first
()
if
not
address_result
:
return
NO_PLACE_ERROR
machine_result
=
Machine
.
query
.
filter_by
(
mac
=
machine_mac
)
.
first
()
if
not
machine_result
:
return
MACHINE_NOT_EXIST_ERROR
machine_result
.
no
=
machine_no
machine_result
.
place_id
=
address_id
machine_result
.
short_address
=
address_result
.
place_name
machine_result
.
short_address
=
short_address
db
.
session
.
add
(
machine_result
)
db
.
session
.
commit
()
return
BaseResponse
(
date
=
{
"success"
:
True
})
# 更换机器状态change_machine_status
@machine_query_route.route
(
"change_machine_status"
,
methods
=
[
"post"
])
def
update_status
():
json_data
=
request
.
get_json
()
machine_mac
=
json_data
[
"machine_mac"
]
status
=
json_data
[
"status"
]
machine_result
=
Machine
.
query
.
filter_by
(
mac
=
machine_mac
)
.
first
()
if
not
machine_result
:
return
MACHINE_NOT_EXIST_ERROR
machine_result
.
status
=
status
db
.
session
.
add
(
machine_result
)
db
.
session
.
commit
()
return
BaseResponse
(
date
=
{
"success"
:
True
})
myapps/management/api/rent_
query
.py
→
myapps/management/api/rent_
portal
.py
View file @
129b3e6a
...
@@ -90,8 +90,8 @@ def details():
...
@@ -90,8 +90,8 @@ def details():
"back_money"
:
result
.
back_money
,
"back_money"
:
result
.
back_money
,
"is_pay"
:
result
.
is_pay
,
"is_pay"
:
result
.
is_pay
,
"rent_type"
:
result
.
rent_type
,
"rent_type"
:
result
.
rent_type
,
"add_time"
:
result
.
add_time
,
"add_time"
:
result
.
add_time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
,
"pay_time"
:
result
.
pay_time
,
"pay_time"
:
result
.
pay_time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
,
"over_time"
:
result
.
over_time
"over_time"
:
result
.
over_time
}
}
result_date
.
append
(
data
)
result_date
.
append
(
data
)
...
@@ -125,4 +125,4 @@ def edit_s():
...
@@ -125,4 +125,4 @@ def edit_s():
db
.
session
.
add
(
rent_refund
)
db
.
session
.
add
(
rent_refund
)
db
.
session
.
commit
()
db
.
session
.
commit
()
return
BaseResponse
()
return
BaseResponse
(
data
=
True
)
myapps/management/api/tallyman_portal.py
0 → 100644
View file @
129b3e6a
# -*- coding: utf-8 -*-
import
datetime
import
logging
import
time
import
os
from
flask
import
Blueprint
,
jsonify
,
request
,
g
from
sqlalchemy
import
func
from
config.base_config
import
MONGO_DATABASE_URI
from
config.commen_config
import
LOGIN_TYPE
from
models.base_model
import
db
from
models.models
import
TallymanAccount
,
TallymanMachine
,
TallymanLoginRecord
,
Machine
,
Hatch
,
TallyRecord
,
\
TallymanPlace
,
Management
from
service.tallyman_service
import
TallymanService
from
utils.error_code
import
TALLYMAN_ACCOUNT_EXIST
,
PHONE_NOT_VALID_ERROR
,
TOKEN_NOT_VALID_ERROR
,
PASSWORD_ERROR
,
\
TALLYMAN_ACCOUNT_NOT_EXIST
,
MACHINE_NOT_EXIST_ERROR
,
HATCH_NOT_EXIST_ERROR
,
MACHINE_ACTIVATED_ERROR
,
\
USER_ALREADY_REGISTER_ERROR
from
utils.jwt_util
import
verify_jwt
,
generate_jwt
from
utils.my_response
import
BaseResponse
logger
=
logging
.
getLogger
(
__name__
)
tallyman_route
=
Blueprint
(
'tallyman'
,
__name__
)
@tallyman_route.route
(
'/add_man'
,
methods
=
[
'GET'
,
'POST'
])
def
add_man
():
# 添加补货员账号
json_data
=
request
.
get_json
()
user_name
=
json_data
[
'name'
]
phone
=
json_data
[
'phone'
]
password
=
json_data
[
'password'
]
comment
=
json_data
[
'comment'
]
if
'comment'
in
json_data
else
None
# 是否存在手机号码
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
.
level
=
1
tallyman
.
user_name
=
user_name
tallyman
.
phone
=
phone
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
=
"SK"
+
str
(
tallyman
.
id
)
.
zfill
(
6
)
db
.
session
.
add
(
tallyman
)
db
.
session
.
commit
()
return
BaseResponse
(
date
=
{
"success"
:
True
})
# 删除补货员
@tallyman_route.route
(
'/del_man'
,
methods
=
[
'GET'
,
'POST'
])
def
del_man
():
json_date
=
request
.
get_json
()
tallyman_id
=
json_date
[
"tallyman_id"
]
tall_result
=
TallymanAccount
.
query
.
filter_by
(
id
=
tallyman_id
)
.
first
()
if
not
tall_result
:
return
TALLYMAN_ACCOUNT_NOT_EXIST
tall_result
.
status
=
-
1
db
.
session
.
add
(
tall_result
)
db
.
session
.
commit
()
return
BaseResponse
(
date
=
{
"success"
:
True
})
# 查询补货员list
@tallyman_route.route
(
"/query_man"
,
methods
=
[
'POST'
])
def
tallyman
():
token
=
request
.
headers
.
get
(
'Authorization'
)
json_date
=
request
.
get_json
()
tallyman
=
json_date
[
'tallyman'
]
if
"tallyman"
in
json_date
else
""
place_name
=
json_date
[
"place_name"
]
if
"place_name"
in
json_date
else
""
page
=
json_date
[
"page"
]
page_size
=
json_date
[
"page_size"
]
if
not
token
:
return
TOKEN_NOT_VALID_ERROR
SECRET_KEY
=
os
.
getenv
(
'SECRET_KEY'
)
payload
=
verify_jwt
(
token
,
SECRET_KEY
)
if
not
payload
:
return
TOKEN_NOT_VALID_ERROR
user_id
=
payload
.
get
(
"user_id"
)
user_res
=
Management
.
query
.
filter_by
(
id
=
user_id
)
if
not
user_res
:
return
TOKEN_NOT_VALID_ERROR
# 多表查询
query1
=
"SELECT a.*,b.management_id,c.place_id , d.place_name FROM ((tallyman_account as a JOIN "
\
"management_tallyman as b on a.id = b.tallyman_id) JOIN tallyman_place as c on c.user_id = a.id) "
\
"JOIN place as d ON d.id = c.place_id WHERE b.management_id = {} and a.user_name like '{}' and"
\
" d.place_name like '{}' limit {},{}"
\
.
format
(
user_id
,
"
%
"
+
tallyman
+
"
%
"
,
"
%
"
+
place_name
+
"
%
"
,
(
page
-
1
)
*
page_size
,
page
*
page_size
)
tallyman_result
=
db
.
session
.
execute
(
query1
)
.
fetchall
()
result_date
=
[]
for
i
in
tallyman_result
:
date
=
{
"tallyman_id"
:
i
.
id
,
"user_no"
:
i
.
user_no
,
"user_name"
:
i
.
user_name
,
"level"
:
i
.
level
,
"phone"
:
i
.
phone
,
"status"
:
i
.
status
,
"last_login"
:
i
.
last_login
,
"address_name"
:
i
.
place_name
,
"address_id"
:
i
.
place_id
}
result_date
.
append
(
date
)
return
BaseResponse
(
date
=
result_date
)
# 编辑补货员信息
@tallyman_route.route
(
"/edit_man"
,
methods
=
[
"POST"
])
def
edit_man
():
json_date
=
request
.
get_json
()
tallyman_id
=
json_date
[
"tallyman_id"
]
phone
=
json_date
[
"phone"
]
t_name
=
json_date
[
"t_name"
]
level
=
json_date
[
"level"
]
man_result
=
TallymanAccount
.
query
.
filter_by
(
id
=
tallyman_id
)
.
first
()
if
not
man_result
:
return
TALLYMAN_ACCOUNT_NOT_EXIST
phone_not
=
TallymanAccount
.
query
.
filter_by
(
phone
=
phone
,
status
=
1
)
.
first
()
if
phone_not
:
return
USER_ALREADY_REGISTER_ERROR
man_result
.
phone
=
phone
man_result
.
user_name
=
t_name
man_result
.
level
=
level
db
.
session
.
add
(
man_result
)
return
BaseResponse
(
date
=
{
"success"
:
True
})
# 为补货员添加机器
\ No newline at end of file
service/machine_service.py
0 → 100644
View file @
129b3e6a
# -*- coding: utf-8 -*-
import
logging
from
flask
import
Blueprint
,
request
,
jsonify
,
g
from
utils.my_response
import
BaseResponse
from
models.base_model
import
db
from
models.models
import
Machine
,
Production
,
Hatch
,
RentDetail
from
utils.error_code
import
MACHINE_NOT_EXIST_ERROR
,
HATCH_NOT_EXIST_ERROR
logger
=
logging
.
getLogger
(
__name__
)
# 查询数据
utils/error_code.py
View file @
129b3e6a
#!usr/bin/env python # -*- coding:utf-8 _*- """ @version: author:Aeolus @file: error_code.py """ ### 通用错误相关 Param_Invalid_Error = { "error_code": "500", "error_message": "params is invalid, 参数无效" } TOKEN_NOT_VALID_ERROR = { "error_code": "1001", "error_message": "无效的token" } TOKEN_NOT_PROVIDED_ERROR = { "error_code": "1002", "error_message": "token未提供" } TOKEN_EXPIRE_ERROR = { "error_code": "1003", "error_message": "token超时" } PHONE_NOT_BINDING_ERROR = { "error_code": "1004", "error_message": "未绑定手机号" } PHONE_NOT_NULL_ERROR = { "error_code": "1005", "error_message": "手机号为空" } PHONE_NOT_VALID_ERROR = { "error_code": "1006", "error_message": "无效的手机号" } USER_ALREADY_REGISTER_ERROR = { "error_code": "1007", "error_message": "用户已注册" } VERIFICATION_CODE_NULL_ERROR = { "error_code": "1008", "error_message": "验证码为空" } VERIFICATION_CODE_INVALID_ERROR = { "error_code": "1009", "error_message": "验证码已失效" } VERIFICATION_CODE_ERROR = { "error_code": "1010", "error_message": "验证码错误" } PASSWORD_ERROR = { "error_code": "1011", "error_message": "账号或密码错误" } ## 微信登陆相关 WX_LOGIN_DATA_ERROR = { "error_code": "3001", "error_message": "微信登录数据错误" } WX_LOGIN_CODE_ERROR = { "error_code": "3002", "error_message": "微信登录code值错误" } WX_OPENID_NOT_GET_ERROR = { "error_code": "3003", "error_message": "微信OpenId获取失败,请刷新重试" } WX_SESSION_KEY_ERROR = { "error_code": "3004", "error_message": "session key error" } ### 微信支付相关 WE_MINIAPP_PAY_FAIL = { "error_code": "3101", "error_message": "小程序下单失败" } ### 消息推送相关 WXBizMsgCrypt_OK = { "error_code": "0", "error_message": "WXBizMsgCrypt_OK" } WXBizMsgCrypt_ValidateSignature_Error = { "error_code": "4001", "error_message": "验证签名错误" } WXBizMsgCrypt_ParseXml_Error = { "error_code": "4002", "error_message": "解析xml错误" } WXBizMsgCrypt_ComputeSignature_Error = { "error_code": "4003", "error_message": "计算签名错误" } WXBizMsgCrypt_IllegalAesKey = { "error_code": "4004", "error_message": "Aes key非法错误" } WXBizMsgCrypt_ValidateAppid_Error = { "error_code": "4005", "error_message": "appid错误" } WXBizMsgCrypt_EncryptAES_Error = { "error_code": "4006", "error_message": "aes加密错误" } WXBizMsgCrypt_DecryptAES_Error = { "error_code": "4007", "error_message": "aes解密错误" } WXBizMsgCrypt_IllegalBuffer = { "error_code": "4008", "error_message": "illegal buffer" } WXBizMsgCrypt_EncodeBase64_Error = { "error_code": "4009", "error_message": "base64加密错误" } WXBizMsgCrypt_DecodeBase64_Error = { "error_code": "4010", "error_message": "base64解密错误" } WXBizMsgCrypt_GenReturnXml_Error = { "error_code": "4011", "error_message": "gen return xml error" } MACHINE_NOT_EXIST_ERROR = { "error_code": '5001', "error_message": "机柜不存在" } MACHINE_IS_USE_ERROR = { "error_code": '5002', "error_message": "已有他人正在租借中,请稍后" } MACHINE_IS_NOT_ONLINE_ERROR = { "error_code": '5003', "error_message": "机柜不在线" } MACHINE_ADD_ERROR = { "error_code": '5004', "error_message": "机柜添加失败" } MACHINE_NO_DUPLICATE_ERROR = { "error_code": '5005', "error_message": "machine_no duplicate,机柜编号重复" } MACHINE_EDIT_ERROR = { "error_code": '5006', "error_message": "machine edit error, 机柜修改错误" } HATCH_NOT_EXIST_ERROR = { "error_code": "5007", "error_message": "no hatch, 没有商品信息" } HATCH_NOT_ALL_EXIST_ERROR = { "error_code": "5008", "error_message": "no all hatch, 存在已售出商品" } HATCH_COUNT_ERROR = { "error_code": "5009", "error_message": "hatch count error, 商品数量错误,检查数量" } MACHINE_ACTIVATED_ERROR = { "error_code": '5010', "error_message": "machine activated, 机柜已激活" } ### 订单相关 RENT_ORDER_NOT_BACK_ERROR = { "error_code": '6101', "error_message": "有未归还的订单" } RENT_ORDER_NOT_TAKE_ERROR = { "error_code": '6102', "error_message": "有未取货的订单" } RENT_ORDER_NUMBER_MAX = { "error_code": '6103', "error_message": "订单数量达到上限" } TAKE_CODE_NOT_VALID = { "error_code": '6104', "error_message": "取货码错误请确认手机号及取货码是否匹配" } CODE_CANCEL_ERROR = { "error_code": '6105', "error_message": "取货码已取消" } CODE_USED_ERROR = { "error_code": '6108', "error_message": "取货码已使用" } NO_POWER_ERROR = { "error_code": '6106', "error_message": "没有可租借设备" } NO_RENT_RECORD = { "error_code": '6107', "error_message": "订单不存在" } CODE_USED_ERROR = { "error_code": '6108', "error_message": "取货码已使用" } RENT_ORDER_NUMBER_LIMIT = { "error_code": '6109', "error_message": "机柜只允许租借一台" } REFUND_NOT_RENT_INFO = { "error_code": "6301", "error_message": "没有该订单信息" } REFUND_BACK_TIME_ERROR = { "error_code": "6302", "error_message": "归还时间异常" } REFUND_NOT_PRODUCTION_INFO = { "error_code": "6303", "error_message": "没有该讲解器信息" } REFUND_MONEY_IS_ZERO = { "error_code": "6304", "error_message": "退款金额为零" } REFUND_NO_DUPLICATE = { "error_code": "6305", "error_message": "退款单号重复" } TALLYMAN_ACCOUNT_EXIST = { "error_code": "7001", "error_message": "tallyman account exist, 补货员账号已存在" } TALLYMAN_ACCOUNT_NOT_EXIST = { "error_code": "7002", "error_message": "tallyman account not exist, 补货员账号不存在" } NFC_CARD_NOT_EXIST = { "error_code": "8001", "error_message": "nfc card not exist, 卡号错误" } NFC_CARD_ACTIVATED_ERROR = { "error_code": "8002", "error_message": "nfc card activated, 卡片已激活" } NO_NFC_CARD_ERROR = { "error_code": "8003", "error_message": "no nfc card , 不存在卡片" } RE_NFC_CARD_ERROR = { "error_code": "8004", "error_message": "re nfc card , 卡片已存在" } NFC_PAY_LOAD_SECRET_ERROR = { "error_code": "8005", "error_message": "secret error , 身份验证失败" }
#!usr/bin/env python # -*- coding:utf-8 _*- """ @version: author:Aeolus @file: error_code.py """ ### 通用错误相关 Param_Invalid_Error = { "error_code": "500", "error_message": "params is invalid, 参数无效" } TOKEN_NOT_VALID_ERROR = { "error_code": "1001", "error_message": "无效的token" } TOKEN_NOT_PROVIDED_ERROR = { "error_code": "1002", "error_message": "token未提供" } TOKEN_EXPIRE_ERROR = { "error_code": "1003", "error_message": "token超时" } PHONE_NOT_BINDING_ERROR = { "error_code": "1004", "error_message": "未绑定手机号" } PHONE_NOT_NULL_ERROR = { "error_code": "1005", "error_message": "手机号为空" } PHONE_NOT_VALID_ERROR = { "error_code": "1006", "error_message": "无效的手机号" } USER_ALREADY_REGISTER_ERROR = { "error_code": "1007", "error_message": "用户已注册" } VERIFICATION_CODE_NULL_ERROR = { "error_code": "1008", "error_message": "验证码为空" } VERIFICATION_CODE_INVALID_ERROR = { "error_code": "1009", "error_message": "验证码已失效" } VERIFICATION_CODE_ERROR = { "error_code": "1010", "error_message": "验证码错误" } PASSWORD_ERROR = { "error_code": "1011", "error_message": "账号或密码错误" } ## 微信登陆相关 WX_LOGIN_DATA_ERROR = { "error_code": "3001", "error_message": "微信登录数据错误" } WX_LOGIN_CODE_ERROR = { "error_code": "3002", "error_message": "微信登录code值错误" } WX_OPENID_NOT_GET_ERROR = { "error_code": "3003", "error_message": "微信OpenId获取失败,请刷新重试" } WX_SESSION_KEY_ERROR = { "error_code": "3004", "error_message": "session key error" } ### 微信支付相关 WE_MINIAPP_PAY_FAIL = { "error_code": "3101", "error_message": "小程序下单失败" } ### 消息推送相关 WXBizMsgCrypt_OK = { "error_code": "0", "error_message": "WXBizMsgCrypt_OK" } WXBizMsgCrypt_ValidateSignature_Error = { "error_code": "4001", "error_message": "验证签名错误" } WXBizMsgCrypt_ParseXml_Error = { "error_code": "4002", "error_message": "解析xml错误" } WXBizMsgCrypt_ComputeSignature_Error = { "error_code": "4003", "error_message": "计算签名错误" } WXBizMsgCrypt_IllegalAesKey = { "error_code": "4004", "error_message": "Aes key非法错误" } WXBizMsgCrypt_ValidateAppid_Error = { "error_code": "4005", "error_message": "appid错误" } WXBizMsgCrypt_EncryptAES_Error = { "error_code": "4006", "error_message": "aes加密错误" } WXBizMsgCrypt_DecryptAES_Error = { "error_code": "4007", "error_message": "aes解密错误" } WXBizMsgCrypt_IllegalBuffer = { "error_code": "4008", "error_message": "illegal buffer" } WXBizMsgCrypt_EncodeBase64_Error = { "error_code": "4009", "error_message": "base64加密错误" } WXBizMsgCrypt_DecodeBase64_Error = { "error_code": "4010", "error_message": "base64解密错误" } WXBizMsgCrypt_GenReturnXml_Error = { "error_code": "4011", "error_message": "gen return xml error" } MACHINE_NOT_EXIST_ERROR = { "error_code": '5001', "error_message": "机柜不存在" } MACHINE_IS_USE_ERROR = { "error_code": '5002', "error_message": "已有他人正在租借中,请稍后" } MACHINE_IS_NOT_ONLINE_ERROR = { "error_code": '5003', "error_message": "机柜不在线" } MACHINE_ADD_ERROR = { "error_code": '5004', "error_message": "机柜添加失败" } MACHINE_NO_DUPLICATE_ERROR = { "error_code": '5005', "error_message": "machine_no duplicate,机柜编号重复" } MACHINE_EDIT_ERROR = { "error_code": '5006', "error_message": "machine edit error, 机柜修改错误" } HATCH_NOT_EXIST_ERROR = { "error_code": "5007", "error_message": "no hatch, 没有商品信息" } HATCH_NOT_ALL_EXIST_ERROR = { "error_code": "5008", "error_message": "no all hatch, 存在已售出商品" } HATCH_COUNT_ERROR = { "error_code": "5009", "error_message": "hatch count error, 商品数量错误,检查数量" } MACHINE_ACTIVATED_ERROR = { "error_code": '5010', "error_message": "machine activated, 机柜已激活" } ### 订单相关 RENT_ORDER_NOT_BACK_ERROR = { "error_code": '6101', "error_message": "有未归还的订单" } RENT_ORDER_NOT_TAKE_ERROR = { "error_code": '6102', "error_message": "有未取货的订单" } RENT_ORDER_NUMBER_MAX = { "error_code": '6103', "error_message": "订单数量达到上限" } TAKE_CODE_NOT_VALID = { "error_code": '6104', "error_message": "取货码错误请确认手机号及取货码是否匹配" } CODE_CANCEL_ERROR = { "error_code": '6105', "error_message": "取货码已取消" } CODE_USED_ERROR = { "error_code": '6108', "error_message": "取货码已使用" } NO_POWER_ERROR = { "error_code": '6106', "error_message": "没有可租借设备" } NO_RENT_RECORD = { "error_code": '6107', "error_message": "订单不存在" } CODE_USED_ERROR = { "error_code": '6108', "error_message": "取货码已使用" } RENT_ORDER_NUMBER_LIMIT = { "error_code": '6109', "error_message": "机柜只允许租借一台" } REFUND_NOT_RENT_INFO = { "error_code": "6301", "error_message": "没有该订单信息" } REFUND_BACK_TIME_ERROR = { "error_code": "6302", "error_message": "归还时间异常" } REFUND_NOT_PRODUCTION_INFO = { "error_code": "6303", "error_message": "没有该讲解器信息" } REFUND_MONEY_IS_ZERO = { "error_code": "6304", "error_message": "退款金额为零" } REFUND_NO_DUPLICATE = { "error_code": "6305", "error_message": "退款单号重复" } TALLYMAN_ACCOUNT_EXIST = { "error_code": "7001", "error_message": "tallyman account exist, 补货员账号已存在" } TALLYMAN_ACCOUNT_NOT_EXIST = { "error_code": "7002", "error_message": "tallyman account not exist, 补货员账号不存在" } NFC_CARD_NOT_EXIST = { "error_code": "8001", "error_message": "nfc card not exist, 卡号错误" } NFC_CARD_ACTIVATED_ERROR = { "error_code": "8002", "error_message": "nfc card activated, 卡片已激活" } NO_NFC_CARD_ERROR = { "error_code": "8003", "error_message": "no nfc card , 不存在卡片" } RE_NFC_CARD_ERROR = { "error_code": "8004", "error_message": "re nfc card , 卡片已存在" } NFC_PAY_LOAD_SECRET_ERROR = { "error_code": "8005", "error_message": "secret error , 身份验证失败" } NO_PLACE_ERROR = { "error_code": "9001", "error_message": "no place error,不存在场景" }
\ 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