kboss/b/lease/update_stock.dspy
2025-07-16 14:27:17 +08:00

23 lines
963 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

async def update_stock(ns={}):
"""
定时更新库存,0:00:00开始
:param ns:
:return:
"""
db = DBPools()
async with db.sqlorContext('kboss') as sor:
# `status` int(1) DEFAULT 0 COMMENT '租赁状态: 0:可租1:下单锁定2:租赁中3:租赁到期4:产品到期',
now_date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
# 租赁到期需要回收
sql = "UPDATE lease_server_data SET `status` = 0,update_at=${update_at}$,update_time=${update_at}$ WHERE lease_end_time < ${now_date}$"
await sor.sqlExe(sql, {"now_date": now_date, "update_at": now_date})
# 产品过期
sql = "UPDATE lease_server_data SET `status` = 4,update_at=${update_at}$,update_time=${update_at}$ WHERE end_date < ${now_date}$;"
await sor.sqlExe(sql, {"now_date": now_date, "update_at": now_date})
return {"status": True}
ret = await update_stock(params_kw)
return ret