Commit e3f27fa2 by Aeolus

update

parent a77e82d0
...@@ -137,8 +137,8 @@ class Hatch(Base): ...@@ -137,8 +137,8 @@ class Hatch(Base):
total_count = Column(TINYINT(3), nullable=False, comment='总数') total_count = Column(TINYINT(3), nullable=False, comment='总数')
brand_id = Column(INTEGER(10), nullable=False, comment='品牌ID') brand_id = Column(INTEGER(10), nullable=False, comment='品牌ID')
brand_name = Column(String(100, 'utf8mb4_unicode_ci'), nullable=False, comment='商品名称') brand_name = Column(String(100, 'utf8mb4_unicode_ci'), nullable=False, comment='商品名称')
cate_id = Column(INTEGER(10), nullable=False, comment='分类ID') production_type_id = Column(INTEGER(10), nullable=False, comment='分类ID')
cate_name = Column(String(200, 'utf8mb4_unicode_ci'), nullable=False, comment='商品标题') production_type_name = Column(String(200, 'utf8mb4_unicode_ci'), nullable=False, comment='商品标题')
price = Column(INTEGER(10), nullable=False, comment='价格') price = Column(INTEGER(10), nullable=False, comment='价格')
original_price = Column(INTEGER(10), nullable=False, comment='商品原价') original_price = Column(INTEGER(10), nullable=False, comment='商品原价')
weight = Column(INTEGER(10), server_default=text("'0'")) weight = Column(INTEGER(10), server_default=text("'0'"))
......
...@@ -43,8 +43,8 @@ def get_production_list(): ...@@ -43,8 +43,8 @@ def get_production_list():
"title": i.title, "title": i.title,
"brand_id": i.brand_id, "brand_id": i.brand_id,
"brand_name": i.brand_name, "brand_name": i.brand_name,
"cate_id": i.cate_id, "production_type_id": i.production_type_id,
"cate_name": i.cate_name, "production_type_name": i.production_type_name,
"price": i.price, "price": i.price,
"original_price": i.original_price, "original_price": i.original_price,
"img": i.img, "img": i.img,
...@@ -83,8 +83,8 @@ def get_production_info(): ...@@ -83,8 +83,8 @@ def get_production_info():
"title": hatch_info.title, "title": hatch_info.title,
"brand_id": hatch_info.brand_id, "brand_id": hatch_info.brand_id,
"brand_name": hatch_info.brand_name, "brand_name": hatch_info.brand_name,
"cate_id": hatch_info.cate_id, "production_type_id": hatch_info.production_type_id,
"cate_name": hatch_info.cate_name, "production_type_name": hatch_info.production_type_name,
"price": hatch_info.price, "price": hatch_info.price,
"original_price": hatch_info.original_price, "original_price": hatch_info.original_price,
"img": hatch_info.img, "img": hatch_info.img,
......
...@@ -110,8 +110,8 @@ def create_rent(): ...@@ -110,8 +110,8 @@ def create_rent():
rent_detail.title = open_hatch.title rent_detail.title = open_hatch.title
rent_detail.brand_id = open_hatch.brand_id rent_detail.brand_id = open_hatch.brand_id
rent_detail.brand_name = open_hatch.brand_name rent_detail.brand_name = open_hatch.brand_name
rent_detail.cate_id = open_hatch.cate_id rent_detail.production_type_id = open_hatch.production_type_id
rent_detail.cate_name = open_hatch.cate_name rent_detail.production_type_name = open_hatch.production_type_name
rent_detail.price = 0 rent_detail.price = 0
rent_detail.rent_count = 1 rent_detail.rent_count = 1
rent_detail.img = open_hatch.img rent_detail.img = open_hatch.img
...@@ -266,8 +266,8 @@ def wx_pay_callback(): ...@@ -266,8 +266,8 @@ def wx_pay_callback():
rent_detail.title = i.title rent_detail.title = i.title
rent_detail.brand_id = i.brand_id rent_detail.brand_id = i.brand_id
rent_detail.brand_name = i.brand_name rent_detail.brand_name = i.brand_name
rent_detail.cate_id = i.cate_id rent_detail.production_type_id = i.production_type_id
rent_detail.cate_name = i.cate_name rent_detail.production_type_name = i.production_type_name
rent_detail.price = i.price * open_hatchs[str(i.hatch_no)] rent_detail.price = i.price * open_hatchs[str(i.hatch_no)]
rent_detail.rent_count = open_hatchs[str(i.hatch_no)] rent_detail.rent_count = open_hatchs[str(i.hatch_no)]
rent_detail.img = i.img rent_detail.img = i.img
...@@ -322,8 +322,8 @@ def get_rent_detail(): ...@@ -322,8 +322,8 @@ def get_rent_detail():
tmp_data["title"] = i.title tmp_data["title"] = i.title
tmp_data["brand_id"] = i.brand_id tmp_data["brand_id"] = i.brand_id
tmp_data["brand_name"] = i.brand_name tmp_data["brand_name"] = i.brand_name
tmp_data["cate_id"] = i.cate_id tmp_data["production_type_id"] = i.production_type_id
tmp_data["cate_name"] = i.cate_name tmp_data["production_type_name"] = i.production_type_name
tmp_data["price"] = i.price tmp_data["price"] = i.price
tmp_data["img"] = i.img tmp_data["img"] = i.img
tmp_data["tags"] = i.tags tmp_data["tags"] = i.tags
...@@ -360,8 +360,8 @@ def get_user_detail_record(): ...@@ -360,8 +360,8 @@ def get_user_detail_record():
tmp_data["title"] = i.title tmp_data["title"] = i.title
tmp_data["brand_id"] = i.brand_id tmp_data["brand_id"] = i.brand_id
tmp_data["brand_name"] = i.brand_name tmp_data["brand_name"] = i.brand_name
tmp_data["cate_id"] = i.cate_id tmp_data["production_type_id"] = i.production_type_id
tmp_data["cate_name"] = i.cate_name tmp_data["production_type_name"] = i.production_type_name
tmp_data["price"] = i.price tmp_data["price"] = i.price
tmp_data["img"] = i.img tmp_data["img"] = i.img
tmp_data["tags"] = i.tags tmp_data["tags"] = i.tags
......
...@@ -108,7 +108,7 @@ def run_add_machine(): ...@@ -108,7 +108,7 @@ def run_add_machine():
if len(hatchs) >= hatch_num: if len(hatchs) >= hatch_num:
return jsonify(HATCH_COUNT_MAX_ERROR) return jsonify(HATCH_COUNT_MAX_ERROR)
hatch_no = json_data["hatch_no"] hatch_no = int(json_data["hatch_no"])
for i in hatchs: for i in hatchs:
if i.hatch_no == hatch_no: if i.hatch_no == hatch_no:
return jsonify(HATCH_NO_DUPLICATE_ERROR) return jsonify(HATCH_NO_DUPLICATE_ERROR)
...@@ -117,7 +117,9 @@ def run_add_machine(): ...@@ -117,7 +117,9 @@ def run_add_machine():
production_name = json_data["production_name"] production_name = json_data["production_name"]
title = json_data.get("title", "") title = json_data.get("title", "")
brand_id = json_data.get("brand_id", 0) brand_id = json_data.get("brand_id", 0)
brand_name = json_data.get("brand_name", 0)
production_type_id = json_data.get("production_type_id", 0) production_type_id = json_data.get("production_type_id", 0)
production_type_name = json_data.get("production_type_name", 0)
price = json_data.get("price", 0) price = json_data.get("price", 0)
original_price = json_data.get("original_price", 0) original_price = json_data.get("original_price", 0)
weight = json_data.get("weight", 0) weight = json_data.get("weight", 0)
...@@ -130,13 +132,21 @@ def run_add_machine(): ...@@ -130,13 +132,21 @@ def run_add_machine():
tags = json_data.get("tags", None) tags = json_data.get("tags", None)
content = json_data.get("content", None) content = json_data.get("content", None)
summary = json_data.get("summary", None) summary = json_data.get("summary", None)
left_count = json_data.get("left_count", 0)
total_count = json_data.get["total_count"]
hatch_model = Hatch() hatch_model = Hatch()
hatch_model.machine_no = machine_no
hatch_model.hatch_no = hatch_no
hatch_model.production_id = production_id hatch_model.production_id = production_id
hatch_model.production_name = production_name hatch_model.production_name = production_name
hatch_model.title = title hatch_model.title = title
hatch_model.left_count = left_count
hatch_model.total_count = total_count
hatch_model.brand_id = brand_id hatch_model.brand_id = brand_id
hatch_model.brand_name = brand_name
hatch_model.production_type_id = production_type_id hatch_model.production_type_id = production_type_id
hatch_model.production_type_name = production_type_name
hatch_model.price = price hatch_model.price = price
hatch_model.original_price = original_price hatch_model.original_price = original_price
hatch_model.weight = weight hatch_model.weight = weight
...@@ -154,51 +164,83 @@ def run_add_machine(): ...@@ -154,51 +164,83 @@ def run_add_machine():
return BaseResponse() return BaseResponse()
@hatch_route.route("edit_machine", methods=["POST"]) @hatch_route.route("edit_hatch", methods=["POST"])
def run_edit_machine(): def run_edit_hatch():
""" """
:return: :return:
""" """
json_data = request.get_json() json_data = request.get_json()
hatch_id = json_data["hatch_id"]
hatch = Hatch.query.filter_by(id=hatch_id).first()
if not hatch:
return jsonify()
machine_no = json_data["machine_no"] machine_no = json_data["machine_no"]
address = json_data.get("address", None) admin_machine = AdminMachine.query.filter_by(machine_no=machine_no, user_id=g.user.id, status=1).first()
device_id = json_data.get("device_id", None) if not admin_machine:
qrcode_no = json_data.get("qrcode_no", None) return jsonify(MACHINE_NOT_EXIST_ERROR)
mac = json_data.get("mac", None) machine = Machine.query.filter_by(machine_no=machine_no, status=1).first()
power = json_data.get("power", None) if not machine:
hatch_number = json_data.get("hatch_number", None)
place_id = json_data.get("place_id", None)
type = json_data.get("type", None)
status = json_data.get("status", None)
discounts_id = json_data.get("discounts_id", None)
machine_model = Machine.query.filter_by(machine_no=machine_no).first()
if not machine_model:
return jsonify(MACHINE_NOT_EXIST_ERROR) return jsonify(MACHINE_NOT_EXIST_ERROR)
if device_id: hatch_num = machine.hatch_number
machine_model.device_id = device_id hatchs = Hatch.query.filter_by(machine_no=machine_no).all()
if qrcode_no: if len(hatchs) >= hatch_num:
machine_model.qrcode_no = qrcode_no return jsonify(HATCH_COUNT_MAX_ERROR)
if mac:
machine_model.mac = mac hatch_no = int(json_data["hatch_no"])
if power: for i in hatchs:
machine_model.power = power if i.hatch_no == hatch_no:
if place_id: return jsonify(HATCH_NO_DUPLICATE_ERROR)
machine_model.place_id = place_id
if address:
machine_model.address = address
if hatch_number:
machine_model.hatch_number = hatch_number
if type:
machine_model.type = type
if status:
machine_model.status = status
if discounts_id:
machine_model.discounts_id = discounts_id
db.session.add(machine_model)
production_id = json_data["production_id"]
production_name = json_data["production_name"]
title = json_data.get("title", "")
brand_id = json_data.get("brand_id", 0)
brand_name = json_data.get("brand_name", 0)
production_type_id = json_data.get("production_type_id", 0)
production_type_name = json_data.get("production_type_name", 0)
price = json_data.get("price", 0)
original_price = json_data.get("original_price", 0)
weight = json_data.get("weight", 0)
weight_unit = json_data.get("weight_unit", "g")
weight_error = json_data.get("weight_error", 0)
expiration_date = json_data.get("expiration_date", 0)
expiration_date_unit = json_data.get("expiration_date_unit", "月")
is_expiration_date = json_data.get("is_expiration_date", 0)
img = json_data.get("img", None)
tags = json_data.get("tags", None)
content = json_data.get("content", None)
summary = json_data.get("summary", None)
left_count = json_data.get("left_count", 0)
total_count = json_data.get["total_count"]
hatch_model = Hatch()
hatch_model.machine_no = machine_no
hatch_model.hatch_no = hatch_no
hatch_model.production_id = production_id
hatch_model.production_name = production_name
hatch_model.title = title
hatch_model.left_count = left_count
hatch_model.total_count = total_count
hatch_model.brand_id = brand_id
hatch_model.brand_name = brand_name
hatch_model.production_type_id = production_type_id
hatch_model.production_type_name = production_type_name
hatch_model.price = price
hatch_model.original_price = original_price
hatch_model.weight = weight
hatch_model.weight_unit = weight_unit
hatch_model.weight_error = weight_error
hatch_model.expiration_date = expiration_date
hatch_model.expiration_date_unit = expiration_date_unit
hatch_model.is_expiration_date = is_expiration_date
hatch_model.img = img
hatch_model.tags = tags
hatch_model.content = content
hatch_model.summary = summary
db.session.add(hatch_model)
db.session.commit() db.session.commit()
return BaseResponse() return BaseResponse()
......
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