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

31 lines
1.0 KiB
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 save_order_id(ns={}):
"""
设置订单id
:param ns:
:return:
"""
data = {}
msg = "sql error"
try:
data["count"] = int(ns['count'])
data['order_id'] = ns['order_id']
data['productid'] = ns['productid']
data['update_time'] = datetime.datetime.now()
except Exception as e:
return {"status": False, "msg": f"get key error, please check key:{str(e)}"}
db = DBPools()
async with db.sqlorContext('kboss') as sor:
sql = "UPDATE lease_server_status SET update_time = ${update_time}$, order_id=${order_id}$ WHERE `status`=1 AND del_flg=0 and order_id is null and productid=${productid}$ limit ${count}$"
d = await sor.sqlExe(sql, data)
if d == data['count']:
return {"status": True, "msg": f"success update number:{d}"}
else:
msg = "锁定设备不足无法更新订单id"
raise Exception(msg)
return {"status": False, "msg": msg}
ret = await save_order_id(params_kw)
return ret