Commit da952b28 by Aeolus

Merge remote-tracking branch 'origin/yanglei'

parents e8df6945 3db5cabd
......@@ -40,6 +40,8 @@ class Hatch(Base):
left_count = Column(TINYINT(3), nullable=False, comment='剩余数量')
total_count = Column(TINYINT(3), nullable=False, comment='总数')
brand_id = Column(INTEGER(10), nullable=False, comment='品牌ID')
left_count = Column(INTEGER(10), nullable=False, comment='余额')
total_count = Column(INTEGER(10), nullable=False, comment='总数')
brand_name = Column(String(100, 'utf8mb4_unicode_ci'), nullable=False, comment='商品名称')
cate_id = Column(INTEGER(10), nullable=False, comment='分类ID')
cate_name = Column(String(200, 'utf8mb4_unicode_ci'), nullable=False, comment='商品标题')
......
......@@ -103,13 +103,24 @@ def run_hatch_open():
machine_no = json_data['machine_no']
hatch_no = json_data['hatch_no']
user_id = g.user.id
rent_detail = RentDetail.query.filter(RentDetail.user_id == user_id, RentDetail.machine_no == machine_no,
RentDetail.hatch_no == hatch_no,
RentDetail.status != -1,
RentDetail.is_take == 0).order_by(RentDetail.id.desc()).first()
if rent_detail:
# 改变rentDatail中的is_take
rent_detail.is_take = 1
db.session.add(rent_detail)
# 查询到柜子中的物品 数量减一
left_res = Hatch.query.filter(Hatch.hatch_no == hatch_no,
Hatch.machine_no == machine_no).first()
left_res.left_count = left_res.left_count - 1
# 当数量等于1时,将柜子物品状态改为已售空
if left_res.left_count == 0:
left_res.status = 2
# 执行语句
db.session.add(left_res)
db.session.commit()
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