bugfix
This commit is contained in:
parent
b2f2aadb2e
commit
b0f6c01cc2
39
platformbiz/businessdate.py
Normal file
39
platformbiz/businessdate.py
Normal file
@ -0,0 +1,39 @@
|
||||
from sqlor.dbpools import DBPools
|
||||
from appPublic.timeUtils import strdate_add
|
||||
from .excep import BusinessDateParamsError
|
||||
from .const import *
|
||||
async def get_business_date(sor=None):
|
||||
async def _f(sor):
|
||||
sql = "select * from params where params_name = 'business_date'"
|
||||
recs = await sor.sqlExe(sql, {})
|
||||
if len(recs) > 0:
|
||||
return recs[0]['params_value']
|
||||
raise BusinessDateParamsError
|
||||
|
||||
if sor:
|
||||
return await _f(sor)
|
||||
db = DBPools()
|
||||
async with db.sqlorContext(DBNAME()) as sor:
|
||||
return await _f(sor)
|
||||
|
||||
async def new_business_date(sor=None):
|
||||
async def _f(sor):
|
||||
dat = await get_business_date(sor)
|
||||
new_dat = strdate_add(dat, days=1)
|
||||
sql = "update params set params_value=${new_dat}$ where params_name='business_date'"
|
||||
await sor.sqlExe(sql, {'new_dat':new_dat})
|
||||
|
||||
if sor:
|
||||
return await _f(sor)
|
||||
db = DBPools()
|
||||
async with db.sqlorContext(DBNAME()) as sor:
|
||||
return await _f(sor)
|
||||
|
||||
async def previous_business_date(sor=None):
|
||||
dat = await get_business_date(sor=sor)
|
||||
return strdate_add(dat, days=-1)
|
||||
|
||||
async def next_business_date(sor=None):
|
||||
dat = await get_business_date(sor=sor)
|
||||
return strdate_add(dat, days=1)
|
||||
|
Loading…
Reference in New Issue
Block a user