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
|
||||
|
||||
async def set_program(request, program_type, quota):
|
||||
async def set_program(request, program_type, quota, term=1):
|
||||
db = DBPools()
|
||||
dbname = get_serverenv('get_module_dbname')('rag')
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
u = await get_session_userinfo(request)
|
||||
sql="select * from ragquote where orgid = ${orgid}$ order by enabled_date"
|
||||
qs = await sor.sqlExe(sql, {'orgid': u.userorgid})
|
||||
today = curDateString()
|
||||
if len(qs) == 0:
|
||||
if params_kw.program_type == 'free':
|
||||
expired_date = dateadd(today, months=1)
|
||||
else:
|
||||
expired_date = '9999-12-31'
|
||||
today = curDateString()
|
||||
expired_date = dateadd(today, months=term)
|
||||
ns = {
|
||||
"id": uuid(),
|
||||
"orgid": u.userorgid,
|
||||
@ -24,12 +21,11 @@ async def set_program(request, program_type, quota):
|
||||
await sor.C('ragquota', ns)
|
||||
else:
|
||||
lastq = qs[-1]
|
||||
lastq.expired_date = today
|
||||
await sor.U('ragquote', lastq.copy())
|
||||
expired_date = dateadd(lastq.expired_date, months=term)
|
||||
ns = {
|
||||
"id": uuid(),
|
||||
"orgid": u.userorgid,
|
||||
"enabled_date": today,
|
||||
"enabled_date": lastq.expired_date,
|
||||
"expired_date": expired_date,
|
||||
'quota': params_kw.quota
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user