bugfix
This commit is contained in:
parent
856a8d89dc
commit
f1e00e02c3
@ -56,9 +56,9 @@ async def create_payment(request, params_kw=None):
|
||||
payment_name = data.payment_name or "充值",
|
||||
amount = data.amount
|
||||
currency = data.currency
|
||||
id = await pl.new_log(userid, orgid, payment_name, amount, fee, client_ip, currency=currency)
|
||||
if id:
|
||||
data.out_trade_no = id
|
||||
plog = await pl.new_log(userid, orgid, payment_name, amount, fee, client_ip, currency=currency)
|
||||
if plog:
|
||||
data.out_trade_no = plog.id
|
||||
res = await PROVIDERS[provider].create_payment(data)
|
||||
return res
|
||||
raise Exception('write payment_log error')
|
||||
@ -120,7 +120,7 @@ async def payment_notify(request, callback, params_kw=None):
|
||||
# 返回厂商要求的固定成功响应
|
||||
logid = data['out_trade_no']
|
||||
pl = PaymentLog(request._run_ns)
|
||||
await pl.payed_log(logid)
|
||||
plog = await pl.payed_log(logid)
|
||||
await callback(request, data)
|
||||
if provider == "wechat":
|
||||
return {"code":"SUCCESS", "message":"OK"}
|
||||
@ -143,5 +143,6 @@ def load_unipay():
|
||||
env.refund_payment = refund_payment
|
||||
env.get_pay_fee = get_pay_fee
|
||||
env.sor_get_pay_fee = sor_get_pay_fee
|
||||
env.PaymentLog = PaymentLog
|
||||
|
||||
|
||||
|
||||
@ -24,9 +24,9 @@ class PaymentLog:
|
||||
"init_timestamp": timestampstr(),
|
||||
"userid": userid
|
||||
}
|
||||
await sor.C('payment_log', ns)
|
||||
return True
|
||||
return False
|
||||
await sor.C('payment_log', ns.copy())
|
||||
return ns
|
||||
return None
|
||||
|
||||
async def cancel_log(self, logid):
|
||||
dbname = await self.env.get_module_dbname('unipay')
|
||||
@ -36,8 +36,11 @@ class PaymentLog:
|
||||
"cancel_timestamp": timestampstr()
|
||||
}
|
||||
await sor.U('payment_log', ns)
|
||||
return True
|
||||
return False
|
||||
recs = await sor.R('payment_log', {"id": logid})
|
||||
if len(recs) > 0:
|
||||
return recs[0]
|
||||
return None
|
||||
return None
|
||||
|
||||
async def payed_log(self, logid):
|
||||
dbname = await self.env.get_module_dbname('unipay')
|
||||
@ -47,7 +50,10 @@ class PaymentLog:
|
||||
"payed_timestamp": timestampstr()
|
||||
}
|
||||
await sor.U('payment_log', ns)
|
||||
return True
|
||||
return False
|
||||
recs = await sor.R('payment_log', {"id": logid})
|
||||
if len(recs) > 0:
|
||||
return recs[0]
|
||||
return None
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@ -18,18 +18,18 @@ async with db.sqlorContext(dbname) as sor:
|
||||
message=f"客户机构不存在{params_kw.customerid}")
|
||||
|
||||
pl = PaymentLog(request._run_ns)
|
||||
plid = await pl.new_log(serid, params_kw.customerid, 'manual',
|
||||
plog = await pl.new_log(serid, params_kw.customerid, 'manual',
|
||||
'手工充值', params_kw.amount, 0.0,
|
||||
request['client_ip'], currency='CNY')
|
||||
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
biz_date = await get_business_date(sor)
|
||||
await recharge_accounting(sor, params_kw.customerid, 'RECHARGE',
|
||||
plid,
|
||||
plog.id,
|
||||
biz_date,
|
||||
params_kw.amount,
|
||||
0.00)
|
||||
pl.payed_log(plid)
|
||||
pl.payed_log(plog.id)
|
||||
return UiMessage(title="手工充值",message=f"充值{params_kw.amount} 成功")
|
||||
exception(f'Exception:{db.e_except}')
|
||||
return UiError(title="手工充值",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user