bugfix
This commit is contained in:
parent
4882b1f8a1
commit
cc8cb54a8a
@ -199,6 +199,13 @@ class Accounting:
|
|||||||
async def leg_accounting(self, sor, leg):
|
async def leg_accounting(self, sor, leg):
|
||||||
# print(f'leg_accounting(), {leg=}')
|
# print(f'leg_accounting(), {leg=}')
|
||||||
accid = leg['accid']
|
accid = leg['accid']
|
||||||
|
sql = "select * from account where id=${accid}$ for update"
|
||||||
|
accounts = await sor.sqlExe(sql, {'accid': accid})
|
||||||
|
if len(accounts) == 0:
|
||||||
|
e = Exception(f'{accid} account not exist')
|
||||||
|
exception(f'{e}')
|
||||||
|
raise e
|
||||||
|
account = accounts[0]
|
||||||
if leg['amount'] < 0.00001:
|
if leg['amount'] < 0.00001:
|
||||||
return
|
return
|
||||||
subjects = await sor.R('subject', {'id': leg['subjectid']})
|
subjects = await sor.R('subject', {'id': leg['subjectid']})
|
||||||
@ -255,6 +262,7 @@ where accountid=${accid}$
|
|||||||
ns = {
|
ns = {
|
||||||
'id':getID(),
|
'id':getID(),
|
||||||
'accountid':accid,
|
'accountid':accid,
|
||||||
|
'acc_no': account.max_detailno + 1,
|
||||||
'acc_date':self.curdate,
|
'acc_date':self.curdate,
|
||||||
'acc_timestamp':self.timestamp,
|
'acc_timestamp':self.timestamp,
|
||||||
'acc_dir':leg['acc_dir'],
|
'acc_dir':leg['acc_dir'],
|
||||||
@ -264,5 +272,9 @@ where accountid=${accid}$
|
|||||||
'acclogid':logid
|
'acclogid':logid
|
||||||
}
|
}
|
||||||
await sor.C('acc_detail', ns.copy())
|
await sor.C('acc_detail', ns.copy())
|
||||||
await sor.U('account', {'id': accid, 'balance': new_balance})
|
await sor.U('account', {
|
||||||
|
'id': accid,
|
||||||
|
'max_detailno': account.max_detailno + 1,
|
||||||
|
'balance': new_balance
|
||||||
|
})
|
||||||
|
|
||||||
|
|||||||
@ -21,11 +21,13 @@ async def get_orgid_by_username(sor, username):
|
|||||||
|
|
||||||
async def accounting(username):
|
async def accounting(username):
|
||||||
env = ServerEnv()
|
env = ServerEnv()
|
||||||
async with get_sor_context(env, 'accounting') as sor:
|
customerid = None
|
||||||
customerid = await get_orgid_by_username(sor, username)
|
for i in range(10):
|
||||||
resellerid = '0'
|
resellerid = '0'
|
||||||
ais = []
|
async with get_sor_context(env, 'accounting') as sor:
|
||||||
for i in range(10):
|
ais = []
|
||||||
|
if customerid is None:
|
||||||
|
customerid = await get_orgid_by_username(sor, username)
|
||||||
d = DictObject()
|
d = DictObject()
|
||||||
d.customerid = customerid
|
d.customerid = customerid
|
||||||
d.resellerid = '0'
|
d.resellerid = '0'
|
||||||
@ -40,8 +42,8 @@ async def accounting(username):
|
|||||||
"交易手续费": 0
|
"交易手续费": 0
|
||||||
}
|
}
|
||||||
ais.append(d)
|
ais.append(d)
|
||||||
orderid = 'test_orderid'
|
orderid = 'test_orderid'
|
||||||
await consume_accounting(sor, orderid, ais)
|
await consume_accounting(sor, orderid, ais)
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user