Commit 5a4f9857 by Aeolus

Merge remote-tracking branch 'origin/master'

parents 8065bc35 9aa1cb99
[uWSGI] getting INI configuration from /data/www/automat/automat_app_uwsgi.ini
*** Starting uWSGI 2.0.20 (64bit) on [Thu Jan 20 12:05:17 2022] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-44) on 20 January 2022 04:01:54
os: Linux-3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018
nodename: iZ2ze4tbzlpw7nv35r9zudZ
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /data/www/automat
detected binary path: /root/.pyenv/versions/3.7.5/envs/env4automat/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /data/www/automat
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 30125
your memory page size is 4096 bytes
detected max file descriptor number: 65535
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:8893 fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.7.5 (default, Jan 20 2022, 11:57:50) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
Python main interpreter initialized at 0xc137f0
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 584448 bytes (570 KB) for 32 cores
*** Operational MODE: preforking+threaded ***
2022-01-20 12:05:17 - automat_app.py - <module> -[line:13] - INFO - request_id=None: run server
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0xc137f0 pid: 1182 (default app)
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (pid: 1182, cores: 8)
spawned uWSGI worker 2 (pid: 1185, cores: 8)
spawned uWSGI worker 3 (pid: 1189, cores: 8)
spawned uWSGI worker 4 (pid: 1193, cores: 8)
......@@ -22,9 +22,9 @@ XX_PAY_CONFIG = {
"pay_key": os.getenv("XX_PAY_KEY"),
"cert_path": os.getenv("XX_PAY_SSL_CERT_PATH"),
"key_path": os.getenv("XX_PAY_SSL_KEY_PATH"),
'callback_url': '/rent/wx_pay_callback',
'refund_callback_url': '/rent/refund_callback',
'domain': 'https://automat.ssw-htzn.com/sukang'
'callback_url': '/automat/rent/wx_pay_callback',
'refund_callback_url': '/automat/rent/refund_callback',
'domain': os.getenv("DOMAIN")
}
pay_config_list = ["", "xx"]
......
......@@ -116,6 +116,7 @@ def run_create_machine_no():
machine_model.machine_no = machine_no
machine_model.mac = mac
machine_model.hatch_number = hatch_number
machine_model.status = 1
db.session.add(machine_model)
db.session.commit()
return BaseResponse(data={"machine_no": machine_no})
......@@ -130,7 +131,7 @@ def run_bind_serial_num():
machine = Machine.query.filter_by(machine_no=machine_no).first()
if not machine:
return jsonify(MACHINE_NOT_EXIST_ERROR)
machine.device_id = serial_num
machine.qrcode_no = serial_num
db.session.add(machine)
db.session.commit()
return BaseResponse(data={"machine_no": machine_no, "serial_num": serial_num})
......@@ -42,7 +42,8 @@ def get_discount_info():
return jsonify(MACHINE_NOT_EXIST_ERROR)
is_used = 1
if machine.discounts_id == 1:
rent = Rent.query.filter(db.cast(Rent.created_at, db.DATE) == db.cast(datetime.datetime.now(), db.DATE)).first()
rent = Rent.query.filter(db.cast(Rent.created_at, db.DATE) == db.cast(datetime.datetime.now(), db.DATE),
Rent.user_id == g.user.id).first()
if rent:
is_used = 1
else:
......@@ -67,7 +68,8 @@ def create_rent():
return jsonify(MACHINE_NOT_EXIST_ERROR)
if machine.discounts_id == 1:
rent = Rent.query.filter(db.cast(Rent.created_at, db.DATE) == db.cast(datetime.datetime.now(), db.DATE)).first()
rent = Rent.query.filter(db.cast(Rent.created_at, db.DATE) == db.cast(datetime.datetime.now(), db.DATE),
Rent.user_id == g.user.id).first()
if not rent:
if len(productions) != 1:
return jsonify(HATCH_COUNT_ERROR)
......@@ -243,11 +245,12 @@ def wx_pay_callback():
rent.user_id = user_id
rent.place_id = machine.place_id
rent.total = int(callback_data["total_fee"])
rent.real_total = int(callback_data["total_fee"])
rent.add_time = datetime.datetime.now()
rent.is_pay = 1
rent.pay_time = datetime.datetime.strptime(callback_data["time_end"], "%Y%m%d%H%M%S")
rent.rent_type = type
rent.mch_platform = platform
rent.mch_platform = rent_data["platform"]
prepay_id = redis_client.get(USER_RENT_PREPAY_ID + str(user_id) + rent_no)
if prepay_id:
rent.prepay_id = prepay_id
......@@ -271,6 +274,7 @@ def wx_pay_callback():
rent_detail.production_type_id = i.production_type_id
rent_detail.production_type_name = i.production_type_name
rent_detail.price = i.price
rent_detail.original_price = i.original_price
rent_detail.total = i.price * open_hatchs[str(i.hatch_no)]
rent_detail.rent_count = open_hatchs[str(i.hatch_no)]
rent_detail.img = i.img
......@@ -278,7 +282,7 @@ def wx_pay_callback():
rent_detail.content = i.content
rent_detail.summary = i.summary
db.session.add(rent_detail)
total_fee += rent_detail.price
total_fee += rent_detail.total
if total_fee != int(callback_data['total_fee']):
return xmltodict.unparse({'xml': error_data}, pretty=True), header
......@@ -287,6 +291,7 @@ def wx_pay_callback():
db.session.commit()
except Exception as e:
logger.info(e)
return xmltodict.unparse({'xml': error_data}, pretty=True), header
return xmltodict.unparse({'xml': response_data}, pretty=True), header
......@@ -363,7 +368,7 @@ def get_user_detail_record():
tmp_data["hatch_no"] = i.hatch_no
tmp_data["production_id"] = i.production_id
tmp_data["is_take"] = i.is_take
tmp_data["name"] = i.name
tmp_data["name"] = i.production_name
tmp_data["title"] = i.title
tmp_data["brand_id"] = i.brand_id
tmp_data["brand_name"] = i.brand_name
......@@ -402,7 +407,7 @@ def get_user_rent_detail():
tmp_data["hatch_no"] = i.hatch_no
tmp_data["production_id"] = i.production_id
tmp_data["is_take"] = i.is_take
tmp_data["name"] = i.name
tmp_data["name"] = i.production_name
tmp_data["title"] = i.title
tmp_data["price"] = i.price
tmp_data["img"] = i.img
......
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import datetime
import logging
import time
......@@ -238,7 +238,7 @@ def get_tallyman_hatch_list():
"machine_no": i.machine_no,
"hatch_no": i.hatch_no,
"production_id": i.production_id,
"name": i.name,
"name": i.production_name,
"status": i.status,
"left_count": i.left_count,
"total_count": i.total_count
......@@ -281,7 +281,7 @@ def run_tally_start():
tally_record.machine_no = i.machine_no
tally_record.hatch_no = i.hatch_no
tally_record.production_id = i.production_id
tally_record.production_name = i.name
tally_record.production_name = i.production_name
tally_record.tally_count = i.total_count - i.left_count if i.left_count > 0 else i.total_count
tally_record.status = 1
db.session.add(tally_record)
......@@ -340,13 +340,12 @@ def get_tally_report():
machine_info = TallymanService.get_machine_info(g.user, machine_no)
if not machine_info:
return jsonify(MACHINE_NOT_EXIST_ERROR)
empty_number = int(machine_info["empty_number"])
empty_number = machine_info["empty_number"]
over_number = db.session.query(func.sum(TallyRecord.tally_count)).filter(TallyRecord.user_no == g.user.user_no,
TallyRecord.machine_no == machine_no,
TallyRecord.status == 2).scalar()
return BaseResponse(data={"empty_number": empty_number, "over_number": over_number})
return BaseResponse(data={"empty_number": empty_number, "over_number": over_number if over_number else 0})
@tallyman_route.route('machine_activate', methods=["post"])
......
......@@ -134,7 +134,7 @@ def add_user():
account.comment = comment
account.created_at = datetime.datetime.now()
account.updated_at = datetime.datetime.now()
if password:
if password is not None:
account.password = password
db.session.add(account)
db.session.commit()
......@@ -196,13 +196,13 @@ def get_account_detail():
@admin_route.route('/edit_account', methods=['GET', 'POST'])
def edit_user():
json_data = request.get_json()
old_phone = json_data['old_phone'] if 'old_phone' in json_data else ''
new_phone = json_data['new_phone'] if 'new_phone' in json_data else ''
user_name = json_data['user_name'] if 'user_name' in json_data else 'XX'
password = json_data['password'] if 'password' in json_data else ''
comment = json_data['comment'] if 'comment' in json_data else ''
level = json_data['level'] if 'level' in json_data else ''
status = json_data['status'] if 'status' in json_data else ''
old_phone = json_data['old_phone'] if 'old_phone' in json_data else None
new_phone = json_data['new_phone'] if 'new_phone' in json_data else None
user_name = json_data['user_name'] if 'user_name' in json_data else None
password = json_data['password'] if 'password' in json_data else None
comment = json_data['comment'] if 'comment' in json_data else None
level = json_data['level'] if 'level' in json_data else None
status = json_data['status'] if 'status' in json_data else None
if not old_phone:
return BaseResponse(error_code=-1, error_message='old phone is null')
......@@ -224,16 +224,16 @@ def edit_user():
return BaseResponse(**ACCOUNT_NOT_EXISTS_ERROR)
if level and level > g.user.level:
admin_info.level = level
if status:
if status is not None:
admin_info.status = status
if comment:
if comment is not None:
admin_info.comment = comment
if user_name:
if user_name is not None:
admin_info.user_name = user_name
if new_phone:
if new_phone is not None:
admin_info.phone = new_phone
if password:
if password is not None:
admin_info.password = password
db.session.add(admin_info)
......@@ -248,7 +248,7 @@ def edit_user():
@admin_route.route('/delete_account', methods=['GET', 'POST'])
def delete_user():
json_data = request.get_json()
phone = json_data['phone'] if 'phone' in json_data else ''
phone = json_data['phone'] if 'phone' in json_data else None
if not phone:
return BaseResponse(**PHONE_NOT_NULL_ERROR)
......
......@@ -102,9 +102,9 @@ def run_edit_business():
status = json_data.get("status", None)
business_model = Business.query.filter_by(id=business_id).first()
if business_name:
if business_name is not None:
business_model.business_name = business_name
if status:
if status is not None:
business_model.status = status
db.session.add(business_model)
db.session.commit()
......
......@@ -45,11 +45,14 @@ def run_hatch_list():
"""
count_sql = "select count(hatch.id) as total_count"
from_sql = """ from hatch
where hatch.machine_no in ( select machine_no from admin_machine where
admin_machine.user_id = {user_id} and admin_machine.status = 1)
""".format(user_id=admin.id)
where_sql = " "
"""
if g.user.level == 1:
where_sql = " where 0=0"
else:
where_sql = """ where hatch.machine_no in ( select machine_no from admin_machine where
admin_machine.user_id = '{user_id}' and admin_machine.status = 1)
""".format(user_id=admin.id)
if keyword:
where_sql += """
and CONCAT(hatch.machine_no,ifnull(hatch.brand_name,''), ifnull(hatch.production_type_name,''),
......@@ -99,9 +102,10 @@ def run_add_machine():
"""
json_data = request.get_json()
machine_no = json_data["machine_no"]
admin_machine = AdminMachine.query.filter_by(machine_no=machine_no, user_id=g.user.id, status=1).first()
if not admin_machine:
return jsonify(MACHINE_NOT_EXIST_ERROR)
if g.user.level != 1:
admin_machine = AdminMachine.query.filter_by(machine_no=machine_no, user_id=g.user.id, status=1).first()
if not admin_machine:
return jsonify(MACHINE_NOT_EXIST_ERROR)
machine = Machine.query.filter(Machine.machine_no == machine_no, Machine.status != -1).first()
if not machine:
return jsonify(MACHINE_NOT_EXIST_ERROR)
......@@ -178,10 +182,10 @@ def run_edit_hatch():
hatch = Hatch.query.filter_by(id=hatch_id).first()
if not hatch:
return jsonify(HATCH_NOT_EXIST_ERROR)
admin_machine = AdminMachine.query.filter_by(machine_no=hatch.machine_no, user_id=g.user.id, status=1).first()
if not admin_machine:
return jsonify(MACHINE_NOT_EXIST_ERROR)
if g.user.level != 1:
admin_machine = AdminMachine.query.filter_by(machine_no=hatch.machine_no, user_id=g.user.id, status=1).first()
if not admin_machine:
return jsonify(MACHINE_NOT_EXIST_ERROR)
machine = Machine.query.filter(Machine.machine_no == hatch.machine_no, Machine.status != -1).first()
if not machine:
return jsonify(MACHINE_NOT_EXIST_ERROR)
......@@ -208,44 +212,44 @@ def run_edit_hatch():
left_count = json_data.get("left_count", None)
total_count = json_data.get("total_count", None)
if production_id:
if production_id is not None:
hatch.production_id = production_id
hatch.production_name = production_name
if title:
if title is not None:
hatch.title = title
if brand_id:
if brand_id is not None:
hatch.brand_id = brand_id
hatch.brand_name = brand_name
if production_type_id:
if production_type_id is not None:
hatch.production_type_id = production_type_id
hatch.production_type_name = production_type_name
if price:
if price is not None:
hatch.price = price
if original_price:
if original_price is not None:
hatch.original_price = original_price
if weight:
if weight is not None:
hatch.weight = weight
if weight_unit:
if weight_unit is not None:
hatch.weight_unit = weight_unit
if weight_error:
if weight_error is not None:
hatch.weight_error = weight_error
if expiration_date:
if expiration_date is not None:
hatch.expiration_date = expiration_date
if expiration_date_unit:
if expiration_date_unit is not None:
hatch.expiration_date_unit = expiration_date_unit
if is_expiration_date:
if is_expiration_date is not None:
hatch.is_expiration_date = is_expiration_date
if img:
if img is not None:
hatch.img = img
if tags:
if tags is not None:
hatch.tags = tags
if content:
if content is not None:
hatch.content = content
if summary:
if summary is not None:
hatch.summary = summary
if left_count:
if left_count is not None:
hatch.left_count = left_count
if total_count:
if total_count is not None:
hatch.total_count = total_count
db.session.add(hatch)
db.session.commit()
......
......@@ -45,12 +45,14 @@ def run_machine_list():
from_sql = """ from machine
left join place on machine.place_id = place.id
left join business on machine.business_id = business.id
where machine.machine_no in ( select machine_no from admin_machine where
admin_machine.user_id = {user_id} and admin_machine.status = 1)
""".format(user_id=admin.id)
where_sql = " "
if keyword:
"""
if g.user.level == 1:
where_sql = " where 0=0 "
else:
where_sql = """ where machine.machine_no in ( select machine_no from admin_machine where
admin_machine.user_id = '{user_id}' and admin_machine.status = 1)""".format(user_id=admin.id)
if keyword is not None:
where_sql += """
and CONCAT(machine.machine_no,ifnull(machine.qrcode_no,'')) LIKE '%{keyword}%'
......@@ -87,16 +89,17 @@ def run_add_machine():
:return:
"""
json_data = request.get_json()
machine_no = json_data["machine_no"]
machine_no = json_data.get("machine_no", None)
address = json_data.get("address", None)
device_id = json_data.get("device_id", None)
qrcode_no = json_data.get("qrcode_no", None)
mac = json_data.get("mac", None)
mac = json_data["mac"]
power = json_data.get("power", None)
hatch_number = json_data.get("hatch_number", None)
place_id = json_data.get("place_id", None)
type = json_data.get("type", 1)
discounts_id = json_data.get("type", 0)
discounts_id = json_data.get("discounts_id", 0)
status = int(json_data.get("status", 1))
machine_model = Machine()
machine_model.machine_no = machine_no
......@@ -110,6 +113,7 @@ def run_add_machine():
machine_model.hatch_number = hatch_number
machine_model.type = type
machine_model.discounts_id = discounts_id
machine_model.status = status
db.session.add(machine_model)
admin_machine = AdminMachine()
......@@ -145,25 +149,25 @@ def run_edit_machine():
if not machine_model:
return jsonify(MACHINE_NOT_EXIST_ERROR)
if device_id:
if device_id is not None:
machine_model.device_id = device_id
if qrcode_no:
if qrcode_no is not None:
machine_model.qrcode_no = qrcode_no
if mac:
if mac is not None:
machine_model.mac = mac
if power:
if power is not None:
machine_model.power = power
if place_id:
if place_id is not None:
machine_model.place_id = place_id
if address:
if address is not None:
machine_model.address = address
if hatch_number:
if hatch_number is not None:
machine_model.hatch_number = hatch_number
if type:
if type is not None:
machine_model.type = type
if status:
if status is not None:
machine_model.status = status
if discounts_id:
if discounts_id is not None:
machine_model.discounts_id = discounts_id
db.session.add(machine_model)
......@@ -188,11 +192,15 @@ def get_machine_detail():
from_sql = """ from machine
left join place on machine.place_id = place.id
left join business on machine.business_id = business.id
where machine.machine_no in ( select machine_no from admin_machine where
admin_machine.user_id = {user_id} and admin_machine.status = 1)
""".format(user_id=admin.id)
"""
where_sql = " and machine.machine_no = {}".format(machine_no)
if g.user.level == 1:
where_sql = " where 0=0 "
else:
where_sql = """ where machine.machine_no in ( select machine_no from admin_machine where
admin_machine.user_id = '{user_id}' and admin_machine.status = 1) """.format(user_id=admin.id)
where_sql += " and machine.machine_no = '{}'".format(machine_no)
result = db.session.execute(select_sql + from_sql + where_sql).fetchall()
if not result or len(result) != 1:
......@@ -230,9 +238,10 @@ def run_distribute_machine():
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
if g.user.level != 1:
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
......@@ -267,9 +276,10 @@ def run_distribute_tallyman_machine():
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
if g.user.level != 1:
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
......
......@@ -36,10 +36,14 @@ def run_place_list():
admin = g.user
select_sql = "select place.place_name, place.address, place.parent_id,place.status, place.id "
count_sql = "select count(place.id) as total_count"
from_sql = " from place where place.id in ( select place_id from admin_place where admin_place.user_id = {} and admin_place.status = 1) ".format(
admin.id)
from_sql = " from place"
if g.user.level == 1:
where_sql = " where 0=0 "
else:
where_sql = """ where place.id in ( select place_id from admin_place where
admin_place.user_id = '{}' and admin_place.status = 1) """.format(admin.id)
where_sql = " "
if keyword:
where_sql += """
and CONCAT(place.place_name, place.address) LIKE '%{keyword}%'
......@@ -107,10 +111,14 @@ def run_edit_place():
status = json_data.get("status", None)
place_model = Place.query.filter_by(id=id).first()
place_model.place_name = place_name
place_model.address = address
place_model.parent_id = parent_id
place_model.status = status
if place_name is not None:
place_model.place_name = place_name
if address is not None:
place_model.address = address
if parent_id is not None:
place_model.parent_id = parent_id
if status is not None:
place_model.status = status
db.session.add(place_model)
db.session.commit()
return BaseResponse()
......@@ -126,7 +134,7 @@ def get_place_detail():
id = json_data["id"]
place_model = Place.query.filter_by(id=id).first()
if place_model:
if place_model is not None:
return BaseResponse(data={"place_name": place_model.place_name,
"address": place_model.address,
"parent_id": place_model.parent_id,
......
......@@ -43,14 +43,15 @@ def run_production_list():
count_sql = "select count(p.id) as total_count"
from_sql = """ from production p
left join brand on p.brand_id = brand.id
left join production_type on p.production_type_id = production_type.id
where p.id in ( select production_id from admin_production where
admin_production.user_id = {} and admin_production.status = 1
)
""".format(admin.id)
where_sql = " "
left join production_type on p.production_type_id = production_type.id
"""
if g.user.level == 1:
where_sql = " where 0=0"
else:
where_sql = """ where p.id in ( select production_id from admin_production where
admin_production.user_id = '{}' and admin_production.status = 1
)""".format(admin.id)
if keyword:
where_sql += """
and CONCAT(p.production_name, brand_name,production_type_name, p.production_no) LIKE '%{keyword}%'
......@@ -68,12 +69,6 @@ def run_production_list():
result = db.session.execute(select_sql + from_sql + where_sql + order_sql + limit_sql).fetchall()
"""
select p.id, p.production_no, p.name, p.title, p.brand_id,p.production_type_id, p.price,p.original_price,
p.weight, p.weight_unit, p.expiration_date, p.expiration_date_unit, p.is_expiration_date,
p.weight_error, p.img, p.tags, p.content,p.summary, p.status,
brand.name as brand_name, production_type.name as production_type_name
"""
return_data = []
for info in result:
return_data.append(
......@@ -177,37 +172,37 @@ def run_edit_production():
production_model = Production.query.filter_by(id=production_id).first()
if not production_model:
return jsonify(NO_PRODUCTION_ERROR)
if production_name:
if production_name is not None:
production_model.production_name = production_name
if title:
if title is not None:
production_model.title = title
if brand_id:
if brand_id is not None:
production_model.brand_id = brand_id
if production_type_id:
if production_type_id is not None:
production_model.production_type_id = production_type_id
if price:
if price is not None:
production_model.price = price
if original_price:
if original_price is not None:
production_model.original_price = original_price
if weight:
if weight is not None:
production_model.weight = weight
if weight_unit:
if weight_unit is not None:
production_model.weight_unit = weight_unit
if weight_error:
if weight_error is not None:
production_model.weight_error = weight_error
if expiration_date:
if expiration_date is not None:
production_model.expiration_date = expiration_date
if expiration_date_unit:
if expiration_date_unit is not None:
production_model.expiration_date_unit = expiration_date_unit
if is_expiration_date:
if is_expiration_date is not None:
production_model.is_expiration_date = is_expiration_date
if img:
if img is not None:
production_model.img = img
if tags:
if tags is not None:
production_model.tags = tags
if content:
if content is not None:
production_model.content = content
if summary:
if summary is not None:
production_model.summary = summary
db.session.add(production_model)
db.session.commit()
......@@ -231,15 +226,17 @@ def get_production_detail():
"""
from_sql = """ from production p
left join brand on p.brand_id = brand.id
left join production_type on p.production_type_id = production_type.id
where p.id in (
select production_id from admin_production where
admin_production.user_id = {} and admin_production.status = 1
)
""".format(admin.id)
left join production_type on p.production_type_id = production_type.id
"""
where_sql = " and p.id={}".format(production_id)
if g.user.level == 1:
where_sql = " where 0=0"
else:
where_sql = """ where p.id in (
select production_id from admin_production where
admin_production.user_id = '{}' and admin_production.status = 1
)""".format(admin.id)
where_sql += " and p.id='{}'".format(production_id)
result = db.session.execute(select_sql + from_sql + where_sql).fetchall()
if not result or len(result) != 1:
......@@ -276,13 +273,15 @@ def run_brand_list():
select_sql = """select b.id, b.brand_name,b.status, b.img
"""
count_sql = "select count(b.id) as total_count"
from_sql = """ from brand b where b.id in (
select brand_id from admin_brand where
admin_brand.user_id = {} and admin_brand.status = 1
)
""".format(admin.id)
where_sql = ""
from_sql = """ from brand b
"""
if g.user.level == 1:
where_sql = " where 0=0"
else:
where_sql = """ where b.id in (
select brand_id from admin_brand where
admin_brand.user_id = '{}' and admin_brand.status = 1
)""".format(admin.id)
if keyword:
where_sql += """
and CONCAT( b.brand_name) LIKE '%{keyword}%'
......@@ -349,11 +348,11 @@ def run_edit_brand():
brand_model = Brand.query.filter_by(id=brand_id).first()
if not brand_model:
return jsonify(NO_PRODUCTION_ERROR)
if brand_name:
if brand_name is not None:
brand_model.brand_name = brand_name
if img:
if img is not None:
brand_model.img = img
if status:
if status is not None:
brand_model.status = status
db.session.add(brand_model)
db.session.commit()
......@@ -373,8 +372,14 @@ def get_brand_detail():
select_sql = """select b.id,b.brand_name,b.status, b.img
"""
from_sql = """ from brand b """
where_sql = " where b.id ={}".format(brand_id)
if g.user.level == 1:
where_sql = " where 0=0"
else:
where_sql = """ where b.id in (
select brand_id from admin_brand where
admin_brand.user_id = '{}' and admin_brand.status = 1
)""".format(admin.id)
where_sql += " and b.id ='{}'".format(brand_id)
result = db.session.execute(select_sql + from_sql + where_sql).fetchall()
if not result or len(result) != 1:
......@@ -403,13 +408,15 @@ def run_production_type_list():
select_sql = """select p.id, p.production_type_name,p.status
"""
count_sql = "select count(p.id) as total_count"
from_sql = """ from production_type p where p.id in (
select production_type_id from admin_production_type where
admin_production_type.user_id = {} and admin_production_type.status = 1
from_sql = """ from production_type p
"""
if g.user.level == 1:
where_sql = " where 0=0"
else:
where_sql = """ where p.id in ( select production_type_id from admin_production_type where
admin_production_type.user_id = '{}' and admin_production_type.status = 1
)
""".format(admin.id)
where_sql = " "
""".format(admin.id)
if keyword:
where_sql += """
and CONCAT( p.production_type_name) LIKE '%{keyword}%'
......@@ -475,9 +482,9 @@ def run_edit_production_type():
production_type_model = ProductionType.query.filter_by(id=production_type_id).first()
if not production_type_model:
return jsonify(NO_PRODUCTION_ERROR)
if production_type_name:
if production_type_name is not None:
production_type_model.production_type_name = production_type_name
if status:
if status is not None:
production_type_model.status = status
db.session.add(production_type_model)
db.session.commit()
......@@ -497,8 +504,14 @@ def get_production_type_detail():
select_sql = """select b.id,b.production_type_name,b.status
"""
from_sql = """ from production_type b """
where_sql = " where b.id ={}".format(production_type_id)
if g.user.level == 1:
where_sql = " where 0=0"
else:
where_sql = """ where p.id in ( select production_type_id from admin_production_type where
admin_production_type.user_id = '{}' and admin_production_type.status = 1
)
""".format(admin.id)
where_sql += " and b.id ='{}'".format(production_type_id)
result = db.session.execute(select_sql + from_sql + where_sql).fetchall()
if not result or len(result) != 1:
......
......@@ -66,21 +66,21 @@ def run_rent_list():
"""
where_sql = " WHERE 0=0 "
if keyword:
if keyword is not None:
where_sql += """
and CONCAT(rent.rent_no,
wx_user.phone) LIKE '%{keyword}%'
""".format(keyword=keyword)
if start_date:
if start_date is not None:
where_sql += " and rent.created_at > '{}'".format(start_date)
if end_date:
if end_date is not None:
where_sql += " and rent.created_at <= '{}'".format(end_date)
if is_pay:
if is_pay is not None:
where_sql += " and rent.is_pay = '{}'".format(is_pay)
if business_id:
if business_id is not None:
where_sql += " and rent.business_id = '{}'".format(business_id)
if g.user.level != 1:
......@@ -154,7 +154,7 @@ def get_rent_detail():
"""
where_sql = " where rent.rent_no = '{}'".format(rent_no)
if rent_detail_id:
if rent_detail_id is not None:
where_sql += " and rent_detail.id = '{}'".format(rent_detail_id)
if g.user.level != 1:
where_sql += """ and rent.business_id in (
......
......@@ -159,6 +159,7 @@ def get_tallyman_account_detail():
"phone": admin_info.phone,
"level": admin_info.level,
"business_id": admin_info.business_id,
"business_name": admin_info.business_name,
"status": admin_info.status,
"comment": admin_info.comment
}
......
......@@ -349,6 +349,28 @@ url = "http://mirrors.cloud.aliyuncs.com/pypi/simple"
reference = "aliyun"
[[package]]
name = "pymongo"
version = "4.0.1"
description = "Python driver for MongoDB <http://www.mongodb.org>"
category = "main"
optional = false
python-versions = ">=3.6"
[package.extras]
aws = ["pymongo-auth-aws (<2.0.0)"]
encryption = ["pymongocrypt (>=1.2.0,<2.0.0)"]
gssapi = ["pykerberos"]
ocsp = ["pyopenssl (>=17.2.0)", "requests (<3.0.0)", "service_identity (>=18.1.0)", "certifi"]
snappy = ["python-snappy"]
srv = ["dnspython (>=1.16.0,<3.0.0)"]
zstd = ["zstandard"]
[package.source]
type = "legacy"
url = "http://mirrors.cloud.aliyuncs.com/pypi/simple"
reference = "aliyun"
[[package]]
name = "pymysql"
version = "1.0.2"
description = "Pure Python MySQL Driver"
......@@ -398,6 +420,19 @@ url = "http://mirrors.cloud.aliyuncs.com/pypi/simple"
reference = "aliyun"
[[package]]
name = "qcloudsms-py"
version = "0.1.4"
description = "qcloudsms python sdk"
category = "main"
optional = false
python-versions = "*"
[package.source]
type = "legacy"
url = "http://mirrors.cloud.aliyuncs.com/pypi/simple"
reference = "aliyun"
[[package]]
name = "redis"
version = "3.5.3"
description = "Python client for Redis key-value store"
......@@ -519,6 +554,19 @@ url = "http://mirrors.cloud.aliyuncs.com/pypi/simple"
reference = "aliyun"
[[package]]
name = "uwsgi"
version = "2.0.20"
description = "The uWSGI server"
category = "main"
optional = false
python-versions = "*"
[package.source]
type = "legacy"
url = "http://mirrors.cloud.aliyuncs.com/pypi/simple"
reference = "aliyun"
[[package]]
name = "wechatpy"
version = "1.8.15"
description = "WeChat SDK for Python"
......@@ -591,7 +639,7 @@ reference = "aliyun"
[metadata]
lock-version = "1.1"
python-versions = "^3.7"
content-hash = "8dbf51a1e0bed878fdc65b564a712aa2e37e276d08f2ea189bc8b85156ece750"
content-hash = "c3e2d9bacfc7ea6430883704ddfa3e6a53d1ba1b240f96a4e6c3f14c08c16f62"
[metadata.files]
certifi = [
......@@ -892,6 +940,91 @@ pyjwt = [
{file = "PyJWT-2.2.0-py3-none-any.whl", hash = "sha256:b0ed5824c8ecc5362e540c65dc6247567db130c4226670bf7699aec92fb4dae1"},
{file = "PyJWT-2.2.0.tar.gz", hash = "sha256:a0b9a3b4e5ca5517cac9f1a6e9cd30bf1aa80be74fcdf4e28eded582ecfcfbae"},
]
pymongo = [
{file = "pymongo-4.0.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:62459b91a513a7b441cfd70ea7fd15c50b858877ca823915d32bab08fe173edb"},
{file = "pymongo-4.0.1-cp310-cp310-manylinux1_i686.whl", hash = "sha256:633ca2001f80900142068bab907feca99554b557ac105c74a9ed157ed38ca5d6"},
{file = "pymongo-4.0.1-cp310-cp310-manylinux2014_aarch64.whl", hash = "sha256:774b9f48bdc385af6654def31e7a7617e01b99cc8aaca1ab3ef6ea0492205e57"},
{file = "pymongo-4.0.1-cp310-cp310-manylinux2014_i686.whl", hash = "sha256:1c153274699424e8f89f2097d5113f8cbe7898a8d62afaad0270a0f0bd0af53b"},
{file = "pymongo-4.0.1-cp310-cp310-manylinux2014_ppc64le.whl", hash = "sha256:c878286b1464f462616a47f315d14f02f03512c6b81cb568e996c3f1f79bff8a"},
{file = "pymongo-4.0.1-cp310-cp310-manylinux2014_s390x.whl", hash = "sha256:e4e36810c541bd1976cd05452e797860b775886cf32c3e8136b9fe48c2c8ba95"},
{file = "pymongo-4.0.1-cp310-cp310-manylinux2014_x86_64.whl", hash = "sha256:75e449ab068af63b7729195343315bc63d242166d88467314be182cc54ce235d"},
{file = "pymongo-4.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b0606d14892ae2a2b1450e37c8924381e9b64683386a9853e4467f02fd5b44b6"},
{file = "pymongo-4.0.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5cbfa85a12cfe3dca21951cd432051c505ac461bd9f4a635207d982dd9df2373"},
{file = "pymongo-4.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:71810eade75ae1c466adc158d1fa8141040f75427b76240316d97f3c89edd72f"},
{file = "pymongo-4.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:716499113650aacfe1b94d37e0a863f1e84b8d47737c74a2f44f8dfccad46952"},
{file = "pymongo-4.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:349c8e522e0b785f442fc9d7fc01c59f7f13f1abe9395310d0d817cff03ec034"},
{file = "pymongo-4.0.1-cp310-cp310-win32.whl", hash = "sha256:0271bbba36bb130202e011171c1883c4c193036ad0b1e02ecfbea6837790b7de"},
{file = "pymongo-4.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:d419e2dbc4943ad6df7ee05e707d7b2c2b512b92407bb6ff643bccbdea399c3a"},
{file = "pymongo-4.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:1ba8eb426d56556fffec53d600a8f2572589c19d50b30f61daa8f4d72ab92fbe"},
{file = "pymongo-4.0.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:47a58f15fc70198cf95982f9699e17fec12287b90f30e90c5e2b7c1c1bc07914"},
{file = "pymongo-4.0.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:3a4eb0a4db8a2d960bdd5354f05e2e57530e83d333cb644fb2b7120a7a954a69"},
{file = "pymongo-4.0.1-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:b73ff8582964f52ab1bf1a9fdddc1454143172a0b8a9d7d6e3972dd1134f7982"},
{file = "pymongo-4.0.1-cp36-cp36m-manylinux2014_i686.whl", hash = "sha256:8baf23d6a0a08b697854e5bcdf82afb91da732cf575fd47ee93945c3654132d8"},
{file = "pymongo-4.0.1-cp36-cp36m-manylinux2014_ppc64le.whl", hash = "sha256:6cd7a4321e718cb98a7c7c475b0757e77fdaf1cdb013d7d2e781ba45219e1144"},
{file = "pymongo-4.0.1-cp36-cp36m-manylinux2014_s390x.whl", hash = "sha256:e5441f4c8142a250695e249e432637c14f79d856a2b60e0974da082e006c53e2"},
{file = "pymongo-4.0.1-cp36-cp36m-manylinux2014_x86_64.whl", hash = "sha256:069d49b193f94bb1d748cfd8faf697060a2299f40d86bf5b6d41dd3cedf0fd48"},
{file = "pymongo-4.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f3e20eb096deea92350f7198a4287d45883a62fe4459d027ce789e72ceba12ee"},
{file = "pymongo-4.0.1-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8da525765dbcc1b7abf1bba623f9f701d8759a8fb19594cd71a13b7b0c2c56bd"},
{file = "pymongo-4.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9ff0dbec451a2c6226bbd6f2bbbde438bc263e002f3f97d151c8708732ba5197"},
{file = "pymongo-4.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:06af6e6374ee2bb70f724e09ddf9402907a3d6714828b908737948cd83e5685c"},
{file = "pymongo-4.0.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0e9a2628bcd896368ede456bcfe189d9ca65b18fb0dd91974cb734baf2e24af9"},
{file = "pymongo-4.0.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:c0efc5ab7d9b9e64726496bf650dbc7f1754124a48d076e5292cc5306e61a530"},
{file = "pymongo-4.0.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:ceb9a4986f56595e73fffeef3ec037280eda938ed5fe6e4e0961656669d89b32"},
{file = "pymongo-4.0.1-cp36-cp36m-win32.whl", hash = "sha256:c86a0614eda95db036fae01a89f3917d7abdc657c806bac2a32eec74724d9330"},
{file = "pymongo-4.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:59a4a5fe5379e4fa93380fd0b55bccbdbeb8d04fcfbbad8b42bd31610d5ed3ad"},
{file = "pymongo-4.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:686c40344f7f82c4deaa4e17aa46ad97df51263be1434aeedd2d6b6f38c7f44a"},
{file = "pymongo-4.0.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:12d336bdbe60982de55651be397b5e49d7eadd2aa144f11da353002cd52502ed"},
{file = "pymongo-4.0.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:bf6047dea1bc8ae19fc14e01b5cb70b3810f91b100d9a535751dd3eadcd3016c"},
{file = "pymongo-4.0.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:a47f4b24b1360da172cae07ce90e9bd425b6db0052d76142c7fef47173a27283"},
{file = "pymongo-4.0.1-cp37-cp37m-manylinux2014_i686.whl", hash = "sha256:9043bfb816ed50d831acc8d06469dcc41597b4f50c30e62227a93f9f9e37d6c7"},
{file = "pymongo-4.0.1-cp37-cp37m-manylinux2014_ppc64le.whl", hash = "sha256:512059a902ea2cbcd0afac370af580e67ccd4c7e41ecaff0f0fbd03653b25ca2"},
{file = "pymongo-4.0.1-cp37-cp37m-manylinux2014_s390x.whl", hash = "sha256:1498f388181ae5592c7b60549faaefaffc62d6e3754097576611cb642d21d37b"},
{file = "pymongo-4.0.1-cp37-cp37m-manylinux2014_x86_64.whl", hash = "sha256:186b2ff4518c1c169fcef5047deb0e6c13a2354d143859587e745fd9f2cf68e9"},
{file = "pymongo-4.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7450b25a803b0f57dae4c3fbd0df742f7f3344c3c9cabb86e4180083c3ebd893"},
{file = "pymongo-4.0.1-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0c77cd3dbe0dd9e7cdf8c93dc24e5a4fcb56e115ffb259d4f399e4aaf3f3c62d"},
{file = "pymongo-4.0.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:51664dac8d9b138259876f324adca5ab31d991acf88d1d0ffcc94f423ff2e31b"},
{file = "pymongo-4.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:91c049104b51321e4e18d41edc6850d9f0890ac609b3cb3b8db86dc51666de17"},
{file = "pymongo-4.0.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d9f61b08b60909d936c1f3a4e12c163ca71fd1a4665fc6e078afc6f54f886977"},
{file = "pymongo-4.0.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:953129b6b952a9d22042ac23050053444624f630e1928f5f590788660905fa9c"},
{file = "pymongo-4.0.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:e2b6a323ca545bcb4286d14c0bd75d9a1f5bce2fa1d7fa3621e5f71fd9b8d196"},
{file = "pymongo-4.0.1-cp37-cp37m-win32.whl", hash = "sha256:e7aedefc87cb46544a3865a19c1d5ca7ddf5ec5ed7dfe162d9538d7543aef499"},
{file = "pymongo-4.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:177ed1b14aa4f84f00ebef1b0f785680fbaa610361942b23eb54f562fe4c6b34"},
{file = "pymongo-4.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:ddaf391ba74eef47eb5afbc40d0b6ddcdbdb417ec8edc8ae95352d25485076db"},
{file = "pymongo-4.0.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:35a5843546bcbe0422f30b4b2bd5e0b630b04cc4006492c70e8168a921d94b9e"},
{file = "pymongo-4.0.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:86d0e28dd5867153d9d9963a4eb17764854a925758fc2db0a814260f82fd4319"},
{file = "pymongo-4.0.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:28afb00423e521f4b04fb8f75da7c0215e46631e821e27abf5a7176f9b671f47"},
{file = "pymongo-4.0.1-cp38-cp38-manylinux2014_i686.whl", hash = "sha256:5fea4207fec8909e155a7948c987eac61949dbbe97fd0c388e587d06ba9bc78d"},
{file = "pymongo-4.0.1-cp38-cp38-manylinux2014_ppc64le.whl", hash = "sha256:1fd71b4d7070b01c7f66edc44c1ec2f8bcace2761c3a6ecc10449a40e474d2fa"},
{file = "pymongo-4.0.1-cp38-cp38-manylinux2014_s390x.whl", hash = "sha256:8869feff59f08cd63979df26aa12343a85bdc7fbd1b79fda8ae39f31a310fa62"},
{file = "pymongo-4.0.1-cp38-cp38-manylinux2014_x86_64.whl", hash = "sha256:132cc67b909835d7c230888387b4cc9596d4559a3ce90d947e03bc0b0ffe420b"},
{file = "pymongo-4.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7629abba158610cb5db6c22041b287f9398555d72bf9468d44d2efc03d837b81"},
{file = "pymongo-4.0.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f785375ca2b4e2192786f1e0d2a94c66900d12e780ebae1eccbbab85eb9a7054"},
{file = "pymongo-4.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d66462f740dcea496bd779775688a0f805860f0b01998bb59ca22566b098ee26"},
{file = "pymongo-4.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:426584e99af31ad2398e617c3eb0f1ebcda37f0ffb2d3e56087cdaf23a2f1689"},
{file = "pymongo-4.0.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f2b6e12f98cce588525f3db802c88f9795d294549ebfe7c2c9bb81333f533ecd"},
{file = "pymongo-4.0.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f333c0d71dd892683e608f8d1731785a0aa67b1ec012b0d9fc863e8d7224f64e"},
{file = "pymongo-4.0.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:72a0c06b76b254bdec18af9add3b8d35796dda51e64a5e0e48d40bff7b41ab13"},
{file = "pymongo-4.0.1-cp38-cp38-win32.whl", hash = "sha256:84eec41ed982f21ceb58689e16a630a70301eb14499c929388a5bf6464518d9d"},
{file = "pymongo-4.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:da576e59f5f8a642ee26d027479325a45be45defe075b6fa7c84506dabc76883"},
{file = "pymongo-4.0.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:cd4cde3dfdd347d638171eca53ee6e787d4b1247c6e182f8616039b1df6278d5"},
{file = "pymongo-4.0.1-cp39-cp39-manylinux1_i686.whl", hash = "sha256:87dce7c85387ca033cf76cce773ace7675550dcffc456db32a34403439e53e45"},
{file = "pymongo-4.0.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:d7514231a03e95072b32d9b335b96253799802ab94647ce83585d5010749380a"},
{file = "pymongo-4.0.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:93c25fbb5dbc436edbb74101f4da49a42bd3af534513fdf8e75fc72ef035d5e0"},
{file = "pymongo-4.0.1-cp39-cp39-manylinux2014_i686.whl", hash = "sha256:7a091050bb8d54a5200193b4998e0cf763d083f93d97c7780963c09996f85a38"},
{file = "pymongo-4.0.1-cp39-cp39-manylinux2014_ppc64le.whl", hash = "sha256:38b21eddd021a943b1978b0a3d42e974956a338e3dbb88d56aeb8b8799abd6e8"},
{file = "pymongo-4.0.1-cp39-cp39-manylinux2014_s390x.whl", hash = "sha256:40269fe6bb79fe00c8ba7c2f2d542a82711eb234c3dedb90b7e489386120e9d1"},
{file = "pymongo-4.0.1-cp39-cp39-manylinux2014_x86_64.whl", hash = "sha256:0238e53b452ab699b5e2e3f8af2557844c80ab0d0c7a0e066226882838e72756"},
{file = "pymongo-4.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e3f6faea65a73ed54111f209b4a411fe012c68f04e8bde96dd7af89b13cac92b"},
{file = "pymongo-4.0.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ee2c1fd5bd57fd0092dfa31c1f9f166cf2850f191311603ce343cadcc8608d60"},
{file = "pymongo-4.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6f0605b1146bc24c720aac0e806492144aea9d5a4dc956589e0544301862756a"},
{file = "pymongo-4.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a57e271a0647002b5683dd0c7c2fd7f5fb939357c44396d85298e51a3561b9e3"},
{file = "pymongo-4.0.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6183476860511cb553a7e4c40936221b6985af7852029c84df898370ec8a028c"},
{file = "pymongo-4.0.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:1617fd52da7b208fe5ea176d251dd7cf1b5309e5a4272754b9599edfdf7e64e5"},
{file = "pymongo-4.0.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:812650a2e8a08b812d6a3c937f482bd2c9355e90574964fa283b4d8ef4ae665e"},
{file = "pymongo-4.0.1-cp39-cp39-win32.whl", hash = "sha256:7bdb66340e246b5dcddfcfe79a63ac2ec3808dc394853476f49fc785425040f4"},
{file = "pymongo-4.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:65f8a93816dcb2202710839907759aca9eece94d9f13215686f224fcc8966f9e"},
{file = "pymongo-4.0.1.tar.gz", hash = "sha256:13d0624c13a91da71fa0d960205d93b3d98344481be865ee7cc238c972d41d73"},
]
pymysql = [
{file = "PyMySQL-1.0.2-py3-none-any.whl", hash = "sha256:41fc3a0c5013d5f039639442321185532e3e2c8924687abe6537de157d403641"},
{file = "PyMySQL-1.0.2.tar.gz", hash = "sha256:816927a350f38d56072aeca5dfb10221fe1dc653745853d30a216637f5d7ad36"},
......@@ -904,6 +1037,9 @@ python-dotenv = [
{file = "python-dotenv-0.19.0.tar.gz", hash = "sha256:f521bc2ac9a8e03c736f62911605c5d83970021e3fa95b37d769e2bbbe9b6172"},
{file = "python_dotenv-0.19.0-py2.py3-none-any.whl", hash = "sha256:aae25dc1ebe97c420f50b81fb0e5c949659af713f31fdb63c749ca68748f34b1"},
]
qcloudsms-py = [
{file = "qcloudsms_py-0.1.4.tar.gz", hash = "sha256:4dfcb8b1eba2be47a264e33183ba30d8a782346992e344b5a179bf548e130e1f"},
]
redis = [
{file = "redis-3.5.3-py2.py3-none-any.whl", hash = "sha256:432b788c4530cfe16d8d943a09d40ca6c16149727e4afe8c2c9d5580c59d9f24"},
{file = "redis-3.5.3.tar.gz", hash = "sha256:0e7e0cfca8660dea8b7d5cd8c4f6c5e29e11f31158c0b0ae91a397f00e5a05a2"},
......@@ -957,6 +1093,9 @@ urllib3 = [
{file = "urllib3-1.26.7-py2.py3-none-any.whl", hash = "sha256:c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844"},
{file = "urllib3-1.26.7.tar.gz", hash = "sha256:4987c65554f7a2dbf30c18fd48778ef124af6fab771a377103da0585e2336ece"},
]
uwsgi = [
{file = "uwsgi-2.0.20.tar.gz", hash = "sha256:88ab9867d8973d8ae84719cf233b7dafc54326fcaec89683c3f9f77c002cdff9"},
]
wechatpy = [
{file = "wechatpy-1.8.15-py2.py3-none-any.whl", hash = "sha256:0ac7bd23725cc6cbcfcc45cc4864c2afb9e9b630a2fa6763b0fbed9fe714d5f6"},
{file = "wechatpy-1.8.15.tar.gz", hash = "sha256:0724347ea9ede4f14b59acefd6e41c9baae25e822df204ece3eeba3d9e1dfd03"},
......
......@@ -18,6 +18,9 @@ flask-redis = "^0.4.0"
PyJWT = "^2.2.0"
pycryptodome = "^3.11.0"
cryptography = "^36.0.1"
uwsgi = "^2.0.20"
pymongo = "^4.0.1"
qcloudsms-py = "^0.1.4"
[tool.poetry.dev-dependencies]
......
......@@ -127,11 +127,11 @@ class AdminService(object):
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
tallyman_account.business_id, business.business_name
"""
count_sql = "select count(tallyman_account.id) as total_count"
from_sql = " from tallyman_account "
from_sql = " from tallyman_account left join business on tallyman_account.business_id = business.id"
if g.user.level == 1:
where_sql = " where 0=0 "
else:
......@@ -171,8 +171,9 @@ class AdminService(object):
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,
"comment": info.comment, "id": info.id, "user_no": info.user_no,
"create_time": info.created_at.strftime("%Y-%m-%d %H:%M:%S"),
"update_time": info.updated_at.strftime("%Y-%m-%d %H:%M:%S"),
"business_id": info.business_id, "business_name": info.business_name,
})
return {"list": return_data, "page": page, "pageSize": page_size, "total_count": total_count}
......@@ -48,7 +48,8 @@ class TallymanService(object):
cur_machine['short_address'] = machine_info.short_address
cur_machine['address'] = machine_info.address
cur_machine['place_id'] = machine_info.place_id
cur_machine['empty_number'] = db.session.query(func.sum(Hatch.total_count - Hatch.left_count)).filter(
empty_number = db.session.query(func.sum(Hatch.total_count - Hatch.left_count)).filter(
Hatch.machine_no == machine_info.machine_no,
Hatch.status == 2).scalar()
Hatch.status.in_([1, 2])).scalar()
cur_machine['empty_number'] = empty_number if empty_number else 0
return cur_machine
#!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
#!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": 'XXTM000015'}, 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment