This commit is contained in:
yumoqing 2025-12-15 17:12:44 +08:00
parent 1a712da0d9
commit bfa388b95e

View File

@ -1,5 +1,6 @@
from sqlor.dbpools import DBPools from sqlor.dbpools import DBPools
from appPublic.timeUtils import timestampstr from appPublic.timeUtils import timestampstr
from appPublic.dictObject import DictObject
class PaymentLog: class PaymentLog:
def __init__(self, env): def __init__(self, env):
@ -8,26 +9,34 @@ class PaymentLog:
async def new_log(self, async def new_log(self,
userid, customerid, channel, userid, customerid, channel,
payment_name, amount, fee, payment_name, amount, feerate,
client_ip, currency='CNY'): client_ip, currency='CNY'):
dbname = self.env.get_module_dbname('unipay') dbname = self.env.get_module_dbname('unipay')
async with self.db.sqlorContext(dbname) as sor: async with self.db.sqlorContext(dbname) as sor:
ns = { return await self.sor_new_log(sor, userid, customerid, channel,
"id": self.env.uuid(), payment_name, amount, feerate,
"customerid": customerid, client_ip, currency=currency)
"channelid": channel,
"payment_name": payment_name,
"payer_client_ip": client_ip,
"amount_total": amount,
"pay_fee": fee,
"currency": currency,
"payment_status": '0',
"init_timestamp": timestampstr(),
"userid": userid
}
await sor.C('payment_log', ns.copy())
return ns
return None return None
async def sor_new_log(self, sor,
userid, customerid, channel,
payment_name, amount, feerate,
client_ip, currency='CNY'):
ns = {
"id": self.env.uuid(),
"customerid": customerid,
"channelid": channel,
"payment_name": payment_name,
"payer_client_ip": client_ip,
"amount_total": amount,
"pay_feerate": feerate,
"pay_fee": feerate * amount,
"currency": currency,
"payment_status": '0',
"init_timestamp": timestampstr(),
"userid": userid
}
await sor.C('payment_log', ns.copy())
return DictObject(**ns)
async def cancel_log(self, logid): async def cancel_log(self, logid):
dbname = self.env.get_module_dbname('unipay') dbname = self.env.get_module_dbname('unipay')