From fe7dd68d7f2e90d386d7bd0de093d52b91ccb6b1 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 26 Dec 2024 17:56:37 +0800 Subject: [PATCH] bugfix --- accounting/getaccount.py | 11 +++++++---- accounting/init.py | 17 ++++++++++++++++ accounting/recharge.py | 23 ++++++++++++++++++++++ www/alipay_recharge.ui | 6 ++++++ www/api/callback/alipay/index.dspy | 5 +++++ www/api/callback/wechat/index.dspy | 5 +++++ www/recharge.ui | 31 ++++++++++++++++++++++++++++++ www/wechat_recharge.ui | 6 ++++++ 8 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 accounting/init.py create mode 100644 www/alipay_recharge.ui create mode 100644 www/api/callback/alipay/index.dspy create mode 100644 www/api/callback/wechat/index.dspy create mode 100644 www/recharge.ui create mode 100644 www/wechat_recharge.ui diff --git a/accounting/getaccount.py b/accounting/getaccount.py index c657e14..b6357f6 100644 --- a/accounting/getaccount.py +++ b/accounting/getaccount.py @@ -2,7 +2,7 @@ from sqlor.dbpools import DBPools from .const import * from accounting.accountingnode import get_parent_orgid -async def getAccountByName(sor, accounting_orgid, orgid, name): +async def getAccountByName(sor, accounting_orgid, orgid, name, org1id): sql = """select a.* from account a, subject b where a.subjectid = b.id and a.accounting_orgid = ${accounting_orgid}$ and @@ -15,7 +15,10 @@ where a.subjectid = b.id and }); if len(recs) == 0: return None - return recs[0]['id'] + for rec in recs: + if a.org1id == org1id: + return rec['id'] + return None async def getTransPayMode(): pass @@ -43,10 +46,10 @@ async def getCustomerBalance(sor, customerid): return None return balance -async def getAccountBalance(sor, accounting_orgid, orgid, subjectname): +async def getAccountBalance(sor, accounting_orgid, orgid, subjectname, org1id): accid = await getAccountByName(sor, accounting_orgid, orgid, - subjectname) + subjectname,org1id) if accid is None: print(f'accid is None, {accounting_orgid=}, {orgid=}, {subjectname=}') return None diff --git a/accounting/init.py b/accounting/init.py new file mode 100644 index 0000000..f564ffd --- /dev/null +++ b/accounting/init.py @@ -0,0 +1,17 @@ +from ahserver.serverenv import ServerEnv +from accounting.openaccount import openAllResellerAccounts +from accounting.openaccount import openAllCustomerAccounts +from accounting.openaccount import openAllProviderAccounts +from accounting.openaccount import openRetailRelationshipAccounts +from accounting.openaccount import openOwnerAccounts +from accounting.recharge import recharge_accounting +from accounting.getaccount import getAccountBalance, getCustomerBalance + +def load_accounting(): + g = ServerEnv() + g.openAllResellerAccounts = openAllResellerAccounts + g.openAllCustomerAccounts = openAllCustomerAccounts + g.openAllProviderAccounts = openAllProviderAccounts + g.openRetailRelationshipAccounts = openRetailRelationshipAccounts + g.openOwnerAccounts = openOwnerAccounts + g.recharge_accounting = recharge_accounting diff --git a/accounting/recharge.py b/accounting/recharge.py index 6244f13..88f6e66 100644 --- a/accounting/recharge.py +++ b/accounting/recharge.py @@ -16,6 +16,7 @@ class RechargeAccounting: self.db = DBPools() self.recharge_log = recharge_log self.customerid = recharge_log['customerid'] + self.summary = recharge_log['summary'] self.orderid = None self.curdate = recharge_log['recharge_date'] self.transamount = recharge_log['recharge_amt'] @@ -62,3 +63,25 @@ class RechargeAccounting: await sor.C('bill', self.bill.copy()) # await sor.C('recharge_log', self.recharge_log.copy()) +async def recharge_accounting(sor, customerid, action, logid, trnasdate, recharge_amt): + """ + summary:recharge channe(handly, wechat, alipay) + """ + recharge_log = { + "customerid":customerid, + "recharge_date":transdate, + "recharge_logid":logid, + "recharge_amt":recharge_amt, + "action":action, + } + ra = RechargeAccounting(recharge_log) + if sor: + r = await ra.accounting(sor) + return True + + db = DBPools() + dbname = await rfrun('get_module_dbname', 'accounting') + async with db.sqlorContext(dbname) as sor: + r = await ra.accounting(sor) + return True + diff --git a/www/alipay_recharge.ui b/www/alipay_recharge.ui new file mode 100644 index 0000000..d17765d --- /dev/null +++ b/www/alipay_recharge.ui @@ -0,0 +1,6 @@ +{ + "widgettype":"VBox", + "options":{ + "height":"100%" + } +} diff --git a/www/api/callback/alipay/index.dspy b/www/api/callback/alipay/index.dspy new file mode 100644 index 0000000..7c7b235 --- /dev/null +++ b/www/api/callback/alipay/index.dspy @@ -0,0 +1,5 @@ +debug(f'{params_kw=}') +return { + 'status':'ok', + 'message':'is ok' +} diff --git a/www/api/callback/wechat/index.dspy b/www/api/callback/wechat/index.dspy new file mode 100644 index 0000000..7c7b235 --- /dev/null +++ b/www/api/callback/wechat/index.dspy @@ -0,0 +1,5 @@ +debug(f'{params_kw=}') +return { + 'status':'ok', + 'message':'is ok' +} diff --git a/www/recharge.ui b/www/recharge.ui new file mode 100644 index 0000000..b5b1b4d --- /dev/null +++ b/www/recharge.ui @@ -0,0 +1,31 @@ +{ + "widgettype":"Form", + "options":{ + "fields":[ + { + "name":"recharge_amt", + "uitype":"float", + "required":true, + "label":"充值金额" + }, + { + "name":"channel", + "label":"选择充值方式", + "uitype":"checkbox", + "multicheck":false, + "required":true, + "value":"alipay", + "data":[ + { + "value":"alipay", + "text":"支付宝" + }, + { + "value":"wechatpay", + "text":"微信支付" + } + ] + } + ] + } +} diff --git a/www/wechat_recharge.ui b/www/wechat_recharge.ui new file mode 100644 index 0000000..d17765d --- /dev/null +++ b/www/wechat_recharge.ui @@ -0,0 +1,6 @@ +{ + "widgettype":"VBox", + "options":{ + "height":"100%" + } +}