bugfix
This commit is contained in:
parent
fa105e9aad
commit
0b33b1418b
@ -1,19 +1,16 @@
|
|||||||
from appPublic.timeUtils import curDateString, dateadd
|
from appPublic.timeUtils import curDateString, dateAdd
|
||||||
from ahserver.serverenv import get_serverenv
|
from ahserver.serverenv import get_serverenv
|
||||||
|
|
||||||
async def set_program(request, program_type, quota):
|
async def set_program(request, program_type, quota, term=1):
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
dbname = get_serverenv('get_module_dbname')('rag')
|
dbname = get_serverenv('get_module_dbname')('rag')
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
u = await get_session_userinfo(request)
|
u = await get_session_userinfo(request)
|
||||||
sql="select * from ragquote where orgid = ${orgid}$ order by enabled_date"
|
sql="select * from ragquote where orgid = ${orgid}$ order by enabled_date"
|
||||||
qs = await sor.sqlExe(sql, {'orgid': u.userorgid})
|
qs = await sor.sqlExe(sql, {'orgid': u.userorgid})
|
||||||
today = curDateString()
|
|
||||||
if len(qs) == 0:
|
if len(qs) == 0:
|
||||||
if params_kw.program_type == 'free':
|
today = curDateString()
|
||||||
expired_date = dateadd(today, months=1)
|
expired_date = dateadd(today, months=term)
|
||||||
else:
|
|
||||||
expired_date = '9999-12-31'
|
|
||||||
ns = {
|
ns = {
|
||||||
"id": uuid(),
|
"id": uuid(),
|
||||||
"orgid": u.userorgid,
|
"orgid": u.userorgid,
|
||||||
@ -24,12 +21,11 @@ async def set_program(request, program_type, quota):
|
|||||||
await sor.C('ragquota', ns)
|
await sor.C('ragquota', ns)
|
||||||
else:
|
else:
|
||||||
lastq = qs[-1]
|
lastq = qs[-1]
|
||||||
lastq.expired_date = today
|
expired_date = dateadd(lastq.expired_date, months=term)
|
||||||
await sor.U('ragquote', lastq.copy())
|
|
||||||
ns = {
|
ns = {
|
||||||
"id": uuid(),
|
"id": uuid(),
|
||||||
"orgid": u.userorgid,
|
"orgid": u.userorgid,
|
||||||
"enabled_date": today,
|
"enabled_date": lastq.expired_date,
|
||||||
"expired_date": expired_date,
|
"expired_date": expired_date,
|
||||||
'quota': params_kw.quota
|
'quota': params_kw.quota
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user