Commit 1314ae68 by Aeolus

统一下单时返回要开的仓号

parent 3ed4e4f3
......@@ -60,6 +60,22 @@ def create_rent():
# 生成订单编号
rent_no = RentService.create_order_no()
open_hatchs = []
for id, count in productions.items():
count = int(count)
id = int(id)
# 根据给的仓号去获取商品信息
hatch_list = Hatch.query.filter(Hatch.machine_no == machine_no, Hatch.production_id == id,
Hatch.status == 1).order_by(func.random()).all()
if not hatch_list:
return jsonify(HATCH_NOT_EXIST_ERROR)
if len(hatch_list) < count:
return jsonify(HATCH_NOT_ALL_EXIST_ERROR)
hatch_no_list = [x.hatch_no for x in hatch_list[:count]]
open_hatchs.append(hatch_no_list)
# 配置微信订单数据
wechat_service = WeChatPayService(app_id=platform_appid_config_list[user.platform],
config_name=pay_config_list[machine.mch_platform])
......@@ -75,7 +91,8 @@ def create_rent():
"machine_no": machine_no,
"user_id": user.id,
"machine_id": machine.id,
"platform": machine.mch_platform
"platform": machine.mch_platform,
"open_hatchs": open_hatchs
}
}
......@@ -121,6 +138,7 @@ def wx_pay_callback():
machine_no = rent_data["machine_no"]
machine_id = rent_data["machine_id"]
productions = rent_data["productions"]
open_hatchs = rent_data["open_hatchs"]
user_id = rent_data["user_id"]
platform = pay_config_list[platform]
wechat_service = WeChatPayService(app_id=callback_data["appid"], config_name=platform)
......@@ -166,19 +184,10 @@ def wx_pay_callback():
rent.prepay_id = prepay_id
total_fee = 0
for id, count in productions.items():
count = int(count)
id = int(id)
# 根据给的仓号去获取商品信息
hatch_list = Hatch.query.filter(Hatch.machine_no == machine_no, Hatch.production_id == id,
Hatch.status == 1).order_by(func.random()).all()
if not hatch_list:
return jsonify(HATCH_NOT_EXIST_ERROR)
hatchs = Hatch.query.filter(Hatch.machine_no == machine_no, Hatch.hatch_no.in_(open_hatchs),
Hatch.status == 1).order_by(func.random()).all()
if len(hatch_list) < count:
return jsonify(HATCH_NOT_ALL_EXIST_ERROR)
hatchs = hatch_list[:count]
for i in hatchs:
if i.status == 1:
rent_detail = RentDetail()
......
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