Commit 0023e52a by Aeolus

update

parent 09261a14
......@@ -61,5 +61,5 @@ ACCOUNT_STATUS = {
DISCOUNTS_TYPES = {
0: "暂无折扣",
1: "每日单免费",
1: "每日单免费",
}
......@@ -65,6 +65,67 @@ def create_rent():
if not machine:
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()
if not rent:
if len(productions) != 1:
return jsonify(HATCH_COUNT_ERROR)
total_fee = 0
for id, count in productions.items():
count = int(count)
if count != 1:
return jsonify(HATCH_COUNT_ERROR)
id = int(id)
# 根据给的仓号去获取商品信息
open_hatch = Hatch.query.filter(Hatch.machine_no == machine_no, Hatch.production_id == id,
Hatch.left_count >= 1).order_by(func.random()).first()
if not open_hatch:
print("....")
return jsonify(HATCH_NOT_EXIST_ERROR)
break
rent_no = RentService.create_order_no()
rent = Rent()
rent.rent_no = rent_no
rent.machine_no = machine.machine_no
rent.user_id = g.user.id
rent.place_id = machine.place_id
rent.total = total_fee
rent.add_time = datetime.datetime.now()
rent.is_pay = 1
rent.pay_time = datetime.datetime.now()
rent.rent_type = type
rent.mch_platform = machine.mch_platform
rent_detail = RentDetail()
rent_detail.rent_no = rent_no
rent_detail.user_id = rent.user_id
rent_detail.machine_no = rent.machine_no
rent_detail.hatch_no = open_hatch.hatch_no
rent_detail.production_id = open_hatch.production_id
rent_detail.name = open_hatch.name
rent_detail.title = open_hatch.title
rent_detail.brand_id = open_hatch.brand_id
rent_detail.brand_name = open_hatch.brand_name
rent_detail.cate_id = open_hatch.cate_id
rent_detail.cate_name = open_hatch.cate_name
rent_detail.price = 0
rent_detail.rent_count = 1
rent_detail.img = open_hatch.img
rent_detail.tags = open_hatch.tags
rent_detail.content = open_hatch.content
rent_detail.summary = open_hatch.summary
open_hatch.left_count -= 1
if open_hatch.left_count <= 0:
open_hatch.status = 2
db.session.add(rent)
db.session.add(rent_detail)
db.session.commit()
return BaseResponse()
total_fee = 0
open_hatchs = {}
for id, count in productions.items():
......
......@@ -70,7 +70,7 @@ def run_machine_list():
"mac": info.mac, "power": info.power, "hatch_number": info.hatch_number, "type": info.type,
"status": info.status, "place_id": info.place_id,
"discounts_id": info.discounts_id,
"discounts_name": DISCOUNTS_TYPES[int(info.discounts_id)],
"discounts_name": DISCOUNTS_TYPES.get(int(info.discounts_id), "无此优惠"),
})
return BaseResponse({"list": return_data, "page": page, "pageSize": page_size, "total_count": total_count})
......@@ -197,6 +197,6 @@ def get_machine_detail():
"mac": info.mac, "power": info.power, "hatch_number": info.hatch_number,
"type": info.type, "status": info.status, "place_id": info.place_id,
"discounts_id": info.discounts_id,
"discounts_name": DISCOUNTS_TYPES[int(info.discounts_id)],
"discounts_name": DISCOUNTS_TYPES.get(int(info.discounts_id), "无此优惠"),
})
......@@ -13,4 +13,4 @@ app = create_app('prod')
logger.info("run server")
if __name__ == '__main__':
app.run('127.0.0.1', 8893, debug=False)
app.run('127.0.0.1', 8893, debug=True)
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