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
4f235dd2
Commit
4f235dd2
authored
Feb 16, 2022
by
Aeolus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
66ab33b3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
156 additions
and
20 deletions
+156
-20
models/models.py
+1
-2
myapps/pc_management/api/admin_portal.py
+2
-8
myapps/pc_management/api/business_portal.py
+146
-3
myapps/pc_management/api/rent_portal.py
+3
-3
myapps/pc_management/api/tallyman_portal.py
+4
-4
utils/error_code.py
+0
-0
No files found.
models/models.py
View file @
4f235dd2
...
@@ -16,7 +16,6 @@ class AdminAccount(Base):
...
@@ -16,7 +16,6 @@ class AdminAccount(Base):
level
=
Column
(
INTEGER
(
2
),
nullable
=
False
)
level
=
Column
(
INTEGER
(
2
),
nullable
=
False
)
parent_id
=
Column
(
INTEGER
(
10
),
nullable
=
False
)
parent_id
=
Column
(
INTEGER
(
10
),
nullable
=
False
)
draw
=
Column
(
INTEGER
(
1
),
nullable
=
False
)
draw
=
Column
(
INTEGER
(
1
),
nullable
=
False
)
rate
=
Column
(
INTEGER
(
1
),
nullable
=
False
)
status
=
Column
(
INTEGER
(
1
),
nullable
=
False
)
status
=
Column
(
INTEGER
(
1
),
nullable
=
False
)
_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'
))
...
@@ -56,6 +55,7 @@ class AdminBusiness(Base):
...
@@ -56,6 +55,7 @@ class AdminBusiness(Base):
user_id
=
Column
(
INTEGER
(
11
),
nullable
=
False
)
user_id
=
Column
(
INTEGER
(
11
),
nullable
=
False
)
user_no
=
Column
(
String
(
25
,
'utf8mb4_unicode_ci'
),
nullable
=
False
)
user_no
=
Column
(
String
(
25
,
'utf8mb4_unicode_ci'
),
nullable
=
False
)
business_id
=
Column
(
INTEGER
(
11
),
nullable
=
False
)
business_id
=
Column
(
INTEGER
(
11
),
nullable
=
False
)
rate
=
Column
(
INTEGER
(
1
),
nullable
=
False
)
status
=
Column
(
INTEGER
(
1
),
nullable
=
False
,
server_default
=
text
(
"'1'"
))
status
=
Column
(
INTEGER
(
1
),
nullable
=
False
,
server_default
=
text
(
"'1'"
))
created_at
=
Column
(
DateTime
,
nullable
=
False
,
server_default
=
text
(
"CURRENT_TIMESTAMP"
))
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"
))
updated_at
=
Column
(
DateTime
,
nullable
=
False
,
server_default
=
text
(
"CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
))
...
@@ -429,7 +429,6 @@ class SalePlanProduction(Base):
...
@@ -429,7 +429,6 @@ 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'
...
...
myapps/pc_management/api/admin_portal.py
View file @
4f235dd2
...
@@ -113,7 +113,7 @@ def add_user():
...
@@ -113,7 +113,7 @@ def add_user():
comment
=
json_data
.
get
(
'comment'
,
""
)
comment
=
json_data
.
get
(
'comment'
,
""
)
parent_id
=
json_data
.
get
(
"parent_id"
,
admin
.
id
)
parent_id
=
json_data
.
get
(
"parent_id"
,
admin
.
id
)
draw
=
json_data
.
get
(
"draw"
,
0
)
draw
=
json_data
.
get
(
"draw"
,
0
)
rate
=
json_data
.
get
(
"rate"
,
0
)
business_id
=
json_data
[
"business_id"
]
account
=
AdminAccount
.
query
.
filter_by
(
phone
=
phone
)
.
first
()
account
=
AdminAccount
.
query
.
filter_by
(
phone
=
phone
)
.
first
()
if
account
:
if
account
:
...
@@ -128,7 +128,6 @@ def add_user():
...
@@ -128,7 +128,6 @@ def add_user():
account
.
phone
=
phone
account
.
phone
=
phone
account
.
level
=
level
account
.
level
=
level
account
.
draw
=
draw
account
.
draw
=
draw
account
.
rate
=
rate
account
.
parent_id
=
parent_id
account
.
parent_id
=
parent_id
account
.
status
=
1
account
.
status
=
1
account
.
comment
=
comment
account
.
comment
=
comment
...
@@ -142,9 +141,7 @@ def add_user():
...
@@ -142,9 +141,7 @@ def add_user():
db
.
session
.
add
(
account
)
db
.
session
.
add
(
account
)
db
.
session
.
commit
()
db
.
session
.
commit
()
business_ids
=
json_data
.
get
(
"business_ids"
,
[])
AdminService
.
add_or_edit_admin_business
(
account
,
[
business_id
,
])
if
business_ids
:
AdminService
.
add_or_edit_admin_business
(
account
,
business_ids
)
return
BaseResponse
()
return
BaseResponse
()
...
@@ -239,9 +236,6 @@ def edit_user():
...
@@ -239,9 +236,6 @@ def edit_user():
db
.
session
.
add
(
admin_info
)
db
.
session
.
add
(
admin_info
)
db
.
session
.
commit
()
db
.
session
.
commit
()
business_ids
=
json_data
.
get
(
"business_ids"
,
[])
if
business_ids
:
AdminService
.
add_or_edit_admin_business
(
admin_info
,
business_ids
)
return
BaseResponse
()
return
BaseResponse
()
...
...
myapps/pc_management/api/business_portal.py
View file @
4f235dd2
...
@@ -13,9 +13,12 @@ import logging
...
@@ -13,9 +13,12 @@ import logging
from
flask
import
Blueprint
,
g
,
request
,
jsonify
from
flask
import
Blueprint
,
g
,
request
,
jsonify
from
models.base_model
import
db
from
models.base_model
import
db
from
models.models
import
AdminPlace
,
Place
,
Business
,
AdminBusiness
from
models.models
import
AdminPlace
,
Place
,
Business
,
AdminBusiness
,
AdminAccount
from
utils.error_code
import
NO_PLACE_ERROR
,
NO_BUSINESS_ERROR
from
service.admin_service
import
AdminService
from
utils.error_code
import
NO_PLACE_ERROR
,
NO_BUSINESS_ERROR
,
ADMIN_BUSINESS_NOT_EXIST
,
OPERATE_LEVEL_ERROR
,
\
ACCOUNT_NOT_EXISTS_ERROR
,
RATE_INVALID_ERROR
from
utils.my_response
import
BaseResponse
from
utils.my_response
import
BaseResponse
from
utils.mytools
import
json2obj
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -68,7 +71,7 @@ def run_business_list():
...
@@ -68,7 +71,7 @@ def run_business_list():
@business_route.route
(
"add_business"
,
methods
=
[
"POST"
])
@business_route.route
(
"add_business"
,
methods
=
[
"POST"
])
def
run_add_
place
():
def
run_add_
business
():
"""
"""
:return:
:return:
...
@@ -126,3 +129,143 @@ def get_business_detail():
...
@@ -126,3 +129,143 @@ def get_business_detail():
"status"
:
business_model
.
status
,
"business_id"
:
business_id
})
"status"
:
business_model
.
status
,
"business_id"
:
business_id
})
else
:
else
:
return
jsonify
(
NO_BUSINESS_ERROR
)
return
jsonify
(
NO_BUSINESS_ERROR
)
@business_route.route
(
"business_account_list"
,
methods
=
[
"POST"
])
def
get_business_account_list
():
"""
:return:
"""
json_data
=
request
.
get_json
()
page
=
json_data
.
get
(
"page"
,
1
)
page_size
=
json_data
.
get
(
"pageSize"
,
10
)
keyword
=
json_data
.
get
(
"keyword"
,
None
)
business_id
=
json_data
.
get
(
"business_id"
,
None
)
admin
=
g
.
user
if
g
.
user
.
level
!=
1
:
result
=
AdminBusiness
.
query
.
filter_by
(
business_id
=
business_id
,
user_id
=
admin
.
id
,
status
=
1
)
.
first
()
if
not
result
:
return
jsonify
(
ADMIN_BUSINESS_NOT_EXIST
)
select_sql
=
"""select admin_account.id, admin_account.user_no,admin_account.user_name, admin_account.phone,
admin_account.level, admin_business.rate """
count_sql
=
"select count(admin_account.id) as total_count"
from_sql
=
""" from admin_account left join admin_business on admin_account.id = admin_business.user_id """
where_sql
=
""" where admin_business.business_id = {} and admin_business.status = 1
and admin_account.status = 1
"""
.
format
(
business_id
)
if
keyword
:
where_sql
+=
""" and CONCAT(admin_account.user_name, admin_account.phone) LIKE '
%
{keyword}
%
'
"""
.
format
(
keyword
=
keyword
)
order_sql
=
" ORDER BY admin_account.id ASC"
limit_sql
=
" LIMIT {offset} , {page_size} "
.
format
(
offset
=
(
page
-
1
)
*
page_size
,
page_size
=
page_size
)
count_result
=
db
.
session
.
execute
(
count_sql
+
from_sql
+
where_sql
)
.
fetchone
()
if
not
count_result
:
return
BaseResponse
(
data
=
{
"list"
:
[],
"page"
:
page
,
"pageSize"
:
page_size
,
"total_count"
:
0
})
else
:
total_count
=
count_result
.
total_count
result
=
db
.
session
.
execute
(
select_sql
+
from_sql
+
where_sql
+
order_sql
+
limit_sql
)
.
fetchall
()
return_data
=
[]
# super_admin = {"user_name": "咻咻公司", "user_id": 0, "user_no": "0",
# "phone": "0", "level": 1, "rate": 0}
for
info
in
result
:
# if info.level == 1 or info.level == 4:
# super_admin["rate"] += info.rate
# else:
return_data
.
append
({
"user_name"
:
info
.
user_name
,
"user_id"
:
info
.
id
,
"user_no"
:
info
.
user_no
,
"phone"
:
info
.
phone
,
"level"
:
info
.
level
,
"rate"
:
info
.
rate
})
# return_data.append(super_admin)
return
BaseResponse
({
"list"
:
return_data
,
"page"
:
page
,
"pageSize"
:
page_size
,
"total_count"
:
total_count
})
@business_route.route
(
"add_admin_account"
,
methods
=
[
"POST"
])
def
run_add_admin_account
():
"""
:return:
"""
json_data
=
request
.
get_json
()
business_id
=
json_data
[
"business_id"
]
phone
=
json_data
[
"phone"
]
rate
=
int
(
json_data
[
"rate"
])
admin
=
g
.
user
if
admin
.
level
not
in
(
1
,
2
,
4
,
5
):
return
jsonify
(
OPERATE_LEVEL_ERROR
)
if
admin
.
level
!=
1
:
result
=
AdminBusiness
.
query
.
filter_by
(
business_id
=
business_id
,
user_id
=
admin
.
id
,
status
=
1
)
.
first
()
if
not
result
:
return
jsonify
(
ADMIN_BUSINESS_NOT_EXIST
)
result
=
AdminService
.
get_admin_account_list
(
phone
=
phone
)
if
result
[
"total_count"
]
!=
1
:
return
BaseResponse
(
**
ACCOUNT_NOT_EXISTS_ERROR
)
user_info
=
json2obj
(
result
[
"list"
][
0
])
result
=
AdminBusiness
.
query
.
filter_by
(
business_id
=
business_id
,
status
=
1
)
.
all
()
total_rate
=
0
for
i
in
result
:
total_rate
+=
i
.
rate
if
(
total_rate
+
rate
)
>
100
:
return
jsonify
(
RATE_INVALID_ERROR
)
admin_business
=
AdminBusiness
()
admin_business
.
user_id
=
user_info
.
id
admin_business
.
user_no
=
user_info
.
user_no
admin_business
.
business_id
=
business_id
admin_business
.
rate
=
rate
db
.
session
.
add
(
admin_business
)
db
.
session
.
commit
()
return
BaseResponse
()
@business_route.route
(
"edit_admin_account"
,
methods
=
[
"POST"
])
def
run_edit_admin_account
():
"""
:return:
"""
json_data
=
request
.
get_json
()
business_id
=
json_data
[
"business_id"
]
user_id
=
json_data
[
"user_id"
]
rate
=
json_data
.
get
(
"rate"
,
None
)
status
=
json_data
.
get
(
"status"
,
None
)
admin
=
g
.
user
if
admin
.
level
not
in
(
1
,
2
,
4
,
5
):
return
jsonify
(
OPERATE_LEVEL_ERROR
)
if
admin
.
level
!=
1
:
result
=
AdminBusiness
.
query
.
filter_by
(
business_id
=
business_id
,
user_id
=
admin
.
id
,
status
=
1
)
.
first
()
if
not
result
:
return
jsonify
(
OPERATE_LEVEL_ERROR
)
admin_business
=
AdminBusiness
.
query
.
filter_by
(
business_id
=
business_id
,
user_id
=
user_id
)
.
first
()
if
not
admin_business
:
return
jsonify
(
ADMIN_BUSINESS_NOT_EXIST
)
if
rate
:
result
=
AdminBusiness
.
query
.
filter_by
(
business_id
=
business_id
,
status
=
1
)
.
all
()
total_rate
=
0
for
i
in
result
:
if
i
.
user_id
!=
user_id
:
total_rate
+=
i
.
rate
if
(
total_rate
+
int
(
rate
))
>
100
:
return
jsonify
(
RATE_INVALID_ERROR
)
admin_business
.
rate
=
rate
if
status
:
admin_business
.
status
=
int
(
status
)
db
.
session
.
add
(
admin_business
)
db
.
session
.
commit
()
return
BaseResponse
()
myapps/pc_management/api/rent_portal.py
View file @
4f235dd2
...
@@ -42,7 +42,7 @@ def run_rent_list():
...
@@ -42,7 +42,7 @@ def run_rent_list():
business_id
=
json_data
.
get
(
"business_id"
,
None
)
business_id
=
json_data
.
get
(
"business_id"
,
None
)
is_pay
=
json_data
.
get
(
"is_pay"
,
None
)
is_pay
=
json_data
.
get
(
"is_pay"
,
None
)
if
g
.
user
.
level
not
in
(
1
,
2
,
4
):
if
g
.
user
.
level
not
in
(
1
,
2
,
4
,
5
):
return
jsonify
(
OPERATE_LEVEL_ERROR
)
return
jsonify
(
OPERATE_LEVEL_ERROR
)
select_sql
=
"""
select_sql
=
"""
SELECT rent.rent_no, rent.machine_no, rent.user_id,rent.place_id,rent.is_pay,
SELECT rent.rent_no, rent.machine_no, rent.user_id,rent.place_id,rent.is_pay,
...
@@ -126,7 +126,7 @@ def get_rent_detail():
...
@@ -126,7 +126,7 @@ def get_rent_detail():
json_data
=
request
.
get_json
()
json_data
=
request
.
get_json
()
rent_no
=
json_data
.
get
(
"rent_no"
,
None
)
rent_no
=
json_data
.
get
(
"rent_no"
,
None
)
rent_detail_id
=
json_data
.
get
(
"rent_detail_id"
,
None
)
rent_detail_id
=
json_data
.
get
(
"rent_detail_id"
,
None
)
if
g
.
user
.
level
not
in
(
1
,
2
,
4
):
if
g
.
user
.
level
not
in
(
1
,
2
,
4
,
5
):
return
jsonify
(
OPERATE_LEVEL_ERROR
)
return
jsonify
(
OPERATE_LEVEL_ERROR
)
select_sql
=
"""
select_sql
=
"""
...
@@ -192,7 +192,7 @@ def get_rent_detail():
...
@@ -192,7 +192,7 @@ def get_rent_detail():
@rent_route.route
(
'/rent_money_refund'
,
methods
=
[
'GET'
,
'POST'
])
@rent_route.route
(
'/rent_money_refund'
,
methods
=
[
'GET'
,
'POST'
])
def
rent_money_refund_new
():
def
rent_money_refund_new
():
if
g
.
user
.
level
not
in
(
1
,
2
,
4
):
if
g
.
user
.
level
not
in
(
1
,
2
,
4
,
5
):
return
jsonify
(
OPERATE_LEVEL_ERROR
)
return
jsonify
(
OPERATE_LEVEL_ERROR
)
json_data
=
request
.
get_json
()
json_data
=
request
.
get_json
()
...
...
myapps/pc_management/api/tallyman_portal.py
View file @
4f235dd2
...
@@ -41,7 +41,7 @@ def get_account_list():
...
@@ -41,7 +41,7 @@ def get_account_list():
@tallyman_route.route
(
'/edit_tallyman_account'
,
methods
=
[
'GET'
,
'POST'
])
@tallyman_route.route
(
'/edit_tallyman_account'
,
methods
=
[
'GET'
,
'POST'
])
def
run_tallyman_edit_account
():
def
run_tallyman_edit_account
():
admin
=
g
.
user
admin
=
g
.
user
if
g
.
user
.
level
not
in
(
1
,
2
,
4
):
if
g
.
user
.
level
not
in
(
1
,
2
,
4
,
5
):
return
jsonify
(
OPERATE_LEVEL_ERROR
)
return
jsonify
(
OPERATE_LEVEL_ERROR
)
json_data
=
request
.
get_json
()
json_data
=
request
.
get_json
()
old_phone
=
json_data
[
'old_phone'
]
old_phone
=
json_data
[
'old_phone'
]
...
@@ -79,7 +79,7 @@ def run_tallyman_edit_account():
...
@@ -79,7 +79,7 @@ def run_tallyman_edit_account():
@tallyman_route.route
(
'/add_tallyman_account'
,
methods
=
[
'GET'
,
'POST'
])
@tallyman_route.route
(
'/add_tallyman_account'
,
methods
=
[
'GET'
,
'POST'
])
def
run_add_tallyman_account
():
def
run_add_tallyman_account
():
admin
=
g
.
user
admin
=
g
.
user
if
g
.
user
.
level
not
in
(
1
,
2
,
4
):
if
g
.
user
.
level
not
in
(
1
,
2
,
4
,
5
):
return
jsonify
(
OPERATE_LEVEL_ERROR
)
return
jsonify
(
OPERATE_LEVEL_ERROR
)
json_data
=
request
.
get_json
()
json_data
=
request
.
get_json
()
user_name
=
json_data
[
'user_name'
]
if
'user_name'
in
json_data
else
'SSW'
user_name
=
json_data
[
'user_name'
]
if
'user_name'
in
json_data
else
'SSW'
...
@@ -118,7 +118,7 @@ def run_add_tallyman_account():
...
@@ -118,7 +118,7 @@ def run_add_tallyman_account():
@tallyman_route.route
(
'/delete_tallyman_account'
,
methods
=
[
'GET'
,
'POST'
])
@tallyman_route.route
(
'/delete_tallyman_account'
,
methods
=
[
'GET'
,
'POST'
])
def
run_delete_tallyman_account
():
def
run_delete_tallyman_account
():
json_data
=
request
.
get_json
()
json_data
=
request
.
get_json
()
if
g
.
user
.
level
not
in
(
1
,
2
,
4
):
if
g
.
user
.
level
not
in
(
1
,
2
,
4
,
5
):
return
jsonify
(
OPERATE_LEVEL_ERROR
)
return
jsonify
(
OPERATE_LEVEL_ERROR
)
phone
=
json_data
[
'phone'
]
phone
=
json_data
[
'phone'
]
...
@@ -141,7 +141,7 @@ def run_delete_tallyman_account():
...
@@ -141,7 +141,7 @@ def run_delete_tallyman_account():
@tallyman_route.route
(
'/tallyman_account_detail'
,
methods
=
[
"POST"
])
@tallyman_route.route
(
'/tallyman_account_detail'
,
methods
=
[
"POST"
])
def
get_tallyman_account_detail
():
def
get_tallyman_account_detail
():
json_data
=
request
.
get_json
()
json_data
=
request
.
get_json
()
if
g
.
user
.
level
not
in
(
1
,
2
,
4
):
if
g
.
user
.
level
not
in
(
1
,
2
,
4
,
5
):
return
jsonify
(
OPERATE_LEVEL_ERROR
)
return
jsonify
(
OPERATE_LEVEL_ERROR
)
phone
=
json_data
[
"phone"
]
phone
=
json_data
[
"phone"
]
if
phone
==
g
.
user
.
phone
:
if
phone
==
g
.
user
.
phone
:
...
...
utils/error_code.py
View file @
4f235dd2
This diff is collapsed.
Click to expand it.
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