make format
This commit is contained in:
parent
f429037d63
commit
418cc7bf86
5 changed files with 25 additions and 18 deletions
|
|
@ -274,12 +274,14 @@ async def get_diagonalley_order(order_id: str) -> Optional[Orders]:
|
|||
)
|
||||
return Orders(**row) if row else None
|
||||
|
||||
|
||||
async def get_diagonalley_order_invoiceid(invoice_id: str) -> Optional[Orders]:
|
||||
row = await db.fetchone(
|
||||
"SELECT * FROM diagonalley.orders WHERE invoiceid = ?", (invoice_id,)
|
||||
)
|
||||
return Orders(**row) if row else None
|
||||
|
||||
|
||||
async def set_diagonalley_order_paid(payment_hash: str) -> Orders:
|
||||
await db.execute(
|
||||
"""
|
||||
|
|
@ -290,9 +292,12 @@ async def set_diagonalley_order_paid(payment_hash: str) -> Orders:
|
|||
(payment_hash,),
|
||||
)
|
||||
|
||||
|
||||
async def update_diagonalley_product_stock(products):
|
||||
|
||||
q = "\n".join([f"""WHEN id='{p.product_id}' THEN quantity - {p.quantity}""" for p in products])
|
||||
q = "\n".join(
|
||||
[f"""WHEN id='{p.product_id}' THEN quantity - {p.quantity}""" for p in products]
|
||||
)
|
||||
v = ",".join(["?"] * len(products))
|
||||
|
||||
await db.execute(
|
||||
|
|
@ -303,9 +308,10 @@ async def update_diagonalley_product_stock(products):
|
|||
END)
|
||||
WHERE id IN ({v});
|
||||
""",
|
||||
(*[p.product_id for p in products],)
|
||||
(*[p.product_id for p in products],),
|
||||
)
|
||||
|
||||
|
||||
async def get_diagonalley_orders(wallet_ids: Union[str, List[str]]) -> List[Orders]:
|
||||
if isinstance(wallet_ids, str):
|
||||
wallet_ids = [wallet_ids]
|
||||
|
|
@ -344,6 +350,7 @@ async def get_diagonalley_market_stalls(market_id: str):
|
|||
|
||||
return [{**row} for row in rows]
|
||||
|
||||
|
||||
async def create_diagonalley_market(data: CreateMarket):
|
||||
market_id = urlsafe_short_hash()
|
||||
|
||||
|
|
|
|||
|
|
@ -104,5 +104,6 @@ class Market(BaseModel):
|
|||
usr: str
|
||||
name: Optional[str]
|
||||
|
||||
|
||||
class CreateMarketStalls(BaseModel):
|
||||
stallid: str
|
||||
|
|
|
|||
|
|
@ -37,5 +37,3 @@ async def on_invoice_paid(payment: Payment) -> None:
|
|||
# deduct items sold from stock
|
||||
details = await get_diagonalley_order_details(order.id)
|
||||
await update_diagonalley_product_stock(details)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -290,6 +290,7 @@ async def api_diagonalley_check_payment(payment_hash: str):
|
|||
return {"paid": False}
|
||||
return status
|
||||
|
||||
|
||||
@diagonalley_ext.delete("/api/v1/orders/{order_id}")
|
||||
async def api_diagonalley_order_delete(
|
||||
order_id: str, wallet: WalletTypeInfo = Depends(get_key_type)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue