Commit 42230d55 by 于方蒙

修复每个仓道只能取出一个的问题

parent 87e4efb6
...@@ -403,6 +403,7 @@ class RentDetail(Base): ...@@ -403,6 +403,7 @@ class RentDetail(Base):
hatch_no = Column(TINYINT(3), nullable=False, comment='机柜仓口号') hatch_no = Column(TINYINT(3), nullable=False, comment='机柜仓口号')
total = Column(INTEGER(10), server_default=text("'0'"), comment='实收金额') total = Column(INTEGER(10), server_default=text("'0'"), comment='实收金额')
rent_count = Column(TINYINT(3), nullable=False, server_default=text("'0'")) rent_count = Column(TINYINT(3), nullable=False, server_default=text("'0'"))
takeout_count = Column(TINYINT(8), nullable=False, server_default=text("'0'"), comment='已取出的数量')
refund_total = Column(INTEGER(10), server_default=text("'0'")) refund_total = Column(INTEGER(10), server_default=text("'0'"))
refund_count = Column(INTEGER(10), server_default=text("'0'")) refund_count = Column(INTEGER(10), server_default=text("'0'"))
is_take = Column(TINYINT(3), nullable=False, server_default=text("'0'"), comment='是否取货') is_take = Column(TINYINT(3), nullable=False, server_default=text("'0'"), comment='是否取货')
......
...@@ -104,20 +104,27 @@ def run_hatch_open(): ...@@ -104,20 +104,27 @@ def run_hatch_open():
machine_no = json_data['machine_no'] machine_no = json_data['machine_no']
hatch_no = json_data['hatch_no'] hatch_no = json_data['hatch_no']
user_id = g.user.id user_id = g.user.id
rent_detail = RentDetail.query.filter(RentDetail.user_id == user_id, RentDetail.machine_no == machine_no, rent_detail = RentDetail.query.filter(RentDetail.user_id == user_id, RentDetail.machine_no == machine_no,
RentDetail.hatch_no == hatch_no, RentDetail.hatch_no == hatch_no,
RentDetail.status != -1, RentDetail.status != -1,
RentDetail.is_take == 0).order_by(RentDetail.id.desc()).first() RentDetail.is_take == 0).order_by(RentDetail.id.desc()).first()
if rent_detail: if rent_detail:
# 改变rentDatail中的is_take
rent_detail.is_take = 1
db.session.add(rent_detail)
# 查询到柜子中的物品 数量减一 # 查询到柜子中的物品 数量减一
sql = "update hatch set left_count = left_count - 1 where machine_no = '{}' and hatch_no='{}'".format( sql = "update hatch set left_count = left_count - 1 where machine_no = '{}' and hatch_no='{}'".format(
machine_no, hatch_no) machine_no, hatch_no)
# 对订单中已经取出过的数量 + 1
sql_updata = "update rent_detail set takeout_count = takeout_count + 1 where id = '{}'".format(rent_detail.id)
db.session.execute(sql) db.session.execute(sql)
db.session.commit() db.session.commit()
db.session.execute(sql_updata)
db.session.commit()
# 改变rentDatail中的is_take
# 22-06-08 Author famon
# 已取出的数量 和 订单数量一致才算取出
if rent_detail.takeout_count == rent_detail.rent_count:
rent_detail.is_take = 1
db.session.add(rent_detail)
# 当数量小于等于1时,将柜子物品状态改为已售空 # 当数量小于等于1时,将柜子物品状态改为已售空
left_res = Hatch.query.filter(Hatch.hatch_no == hatch_no, left_res = Hatch.query.filter(Hatch.hatch_no == hatch_no,
......
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