2025-10-27 15:50:44 +08:00

55 lines
1.5 KiB
Python

async def get_customer_price(obj):
sor = obj.sor
sql1 = """select * from floorprice
where offer_orgid = ${id}$
and bid_orgid = ${customerid}$
and productid = ${productid}$
and begin_date <= ${curdate}$
and ${curdate}$ < ${end_date}$
and del_flg = '0'
"""
sql2 = """select * from floorprice
where offer_orgid = ${id}$
and (bid_orgid = '' or bid_orgid is null)
and productid = ${productid}$
and begin_date <= ${curdate}$
and ${curdate}$ < ${end_date}$
and del_flg = '0'
"""
recs = await sor.sqlExe(sql1, {
'id':obj.accounting_orgid,
'customerid':obj.customerid,
'productid':obj.productid,
'curdate':obj.curdate
})
print(f'{recs=}, {sql1=},{obj.curdate=}')
if len(recs) > 0:
p = recs[0]['proce']
return p
recs = await sor.sqlExe(sql2, {
'id':obj.accounting_orgid,
'customerid':obj.customerid,
'productid':obj.productid,
'curdate':obj.curdate
})
print(f'{recs=}, {sql1=},{obj.curdate=}')
if len(recs) > 0:
p = recs[0]['proce']
return p
print('=========error============')
raise GetCustomerPriceError(obj.accounting_orgid,
obj.customerid,
obj.productid)
db = DBPools()
async with db.sqlorContext('kboss') as sor:
obj = object()
obj.sor = sor
obj.accounting_orgid = '6woiJ-_5tDmZUHFnLLty_'
obj.customerid = 'Uf0e9kZ4MXcHQvaHsbnVr'
obj.productid='XGcWsUEgFc6kmXgr_ZFNy'
x = obj.get_customer_price()
return x