diff --git a/accounting/init.py b/accounting/init.py index 7d99d0d..67dd67c 100644 --- a/accounting/init.py +++ b/accounting/init.py @@ -10,6 +10,45 @@ from accounting.bizaccount import BizAccounting from accounting.recharge import RechargeBiz, recharge_accounting from comsume import ConsumeBiz +async def all_my_accounts(request): + env = request._run_ns + userid = await env.get_user() + userorgid = await env.get_userorgid() + async with get_sor_context(request._run_ns, 'accounting') as sor: + sql = """select b.id, a.name, b.balance_at, c.balance from + subject a, account b, + (select a.* from acc_balance a, (select accountid, max(acc_date) max_date from acc_balance group by accountid) b where a.accountid=b.accountid and a.acc_date=b.max_date) c + where c.accountid = b.id + and b.subjectid = a.id + and b.orgid = ${orgid}$ + """ + ns = {'orgid': userorgid} + recs = await sor.sqlExe(sql, ns) + return recs + +async def get_accdetail(request, accountid, page=1): + env = request._run_ns + userorgid = await env.get_userorgid() + async with get_sor_context(env, 'accounting') as sor: + sql = """select a.*, +c.name +from acc_detail a, account b, subject c +where b.subjectid = c.id + and a.accountid = b.id + and b.id = ${accountid}$ +""" + ns = { + 'accountid': accountid, + 'page': page, + 'sort': 'acc_date desc' + } + ret = await sor.sqlExe(sql, ns) + return ret + return { + 'total': 0, + 'rows': [] + } + def load_accounting(): g = ServerEnv() g.Accounting = Accounting @@ -26,3 +65,5 @@ def load_accounting(): g.get_account_total_amount = get_account_total_amount g.BizAccounting = BizAccounting g.recharge_accounting = recharge_accounting + g.get_accdetail = get_accdetail + g.all_my_accounts = all_my_accounts diff --git a/wwwroot/accdetail.dspy b/wwwroot/accdetail.dspy new file mode 100644 index 0000000..559aa08 --- /dev/null +++ b/wwwroot/accdetail.dspy @@ -0,0 +1 @@ +return await get_accdetail(request, params_kw.accountid) diff --git a/wwwroot/accdetail.ui b/wwwroot/accdetail.ui new file mode 100644 index 0000000..b8c0d00 --- /dev/null +++ b/wwwroot/accdetail.ui @@ -0,0 +1,53 @@ +{ + "widgettype":"Cols", + "options":{ + "data_url": "{{entire_url('accdetail.dspy')}}", + "data_params":{ + "accountid":"{{params_kw.accountid}}" + }, + "data_method": "GET" + {% if params_kw._is_mobile %} + "col_width": "{{params_kw.width / 2 - 5}}px", + {% else %} + "col_cwidth": 22, + {% endif %} + "record_view":{ + "widgettype":"VBox", + "options":{ + "width":"100%" + }, + "subwidgets":[ + { + "widgettype":"Text", + "options":{ + "text":"${acc_date}" + } + }, + { + "widgettype":"Text", + "options":{ + "text":"${acc_dir}" + } + }, + { + "widgettype":"Text", + "options":{ + "text":"${summary}" + } + }, + { + "widgettype":"Text", + "options":{ + "text":"${amount}" + } + }, + { + "widgettype":"Text", + "options":{ + "text":"${balance}" + } + } + ] + } + } +} diff --git a/wwwroot/myaccounts.dspy b/wwwroot/myaccounts.dspy new file mode 100644 index 0000000..03be758 --- /dev/null +++ b/wwwroot/myaccounts.dspy @@ -0,0 +1,13 @@ +userid = await get_user() +userorgid = await get_userorgid() +async with get_sor_context(request._run_ns, 'accounting') as sor: + sql = """select b.id, a.name, b.balance_at, c.balance from +subject a, account b, +(select a.* from acc_balance a, (select accountid, max(acc_date) max_date from acc_balance group by accountid) b where a.accountid=b.accountid and a.acc_date=b.max_date) c +where c.accountid = b.id + and b.subjectid = a.id + and b.orgid = ${orgid}$ +""" + ns = {'orgid': userorgid} + recs = await sor.sqlExe(sql, ns) + return recs diff --git a/wwwroot/myaccounts.ui b/wwwroot/myaccounts.ui new file mode 100644 index 0000000..6ae7263 --- /dev/null +++ b/wwwroot/myaccounts.ui @@ -0,0 +1,113 @@ +{ + "widgettype":"DynamicColumn", + "options":{ + "css":"filler", + "width":"100%" + }, + "subwidgets":[ +{% for acc in myaccounts(request) %} + { + "widgettype":"VBox", + "options":{ +{% if params_kw.is_mobile %} + "width":"{{params_kw.width/2-3}}px", + "cheight":4 +{% else %} + "cwidth":12, + "cheight":4 +{% endif %} + }, + "subwidgets":[ + { + "widgettype":"IconBar", + "options":{ + "rate": 1.5, + "tools":[ +{% if acc.name == '客户资金账户' %} + { + "name":"recharge", + "icon":"{{entire_url('/unipay/imgs/recharge.svg')}}", + "tip":"账户充值" + }, +{% endif %} + { + "name":"detail", + "icon":"{{entire_url('imgs/accdetail.svg')}}", + "tip":"查看账户明细" + } + ] + } + }, + { + "widgettype":"Title6", + "options":{ + "width":"100%", + "text":"{{acc.name}}" + } + },{ + "widgettype":"Text", + "options":{ + "width":"100%", + "i18n":true, + "otext":"{{'借' if acc.balance_at=='0' else '贷'}}" + } + },{ + "widgettype":"Text", + "options":{ + "width":"100%", + "text":"{{acc.balance}}" + } + } + ], + "binds":[ + { + "wid":"self", + "event":"recharge", + "actiontype":"urlwidget", + "target":"PopupWindow", + "popup_options":{ + "icon":"{{entire_url('/unipay/imgs/recharge.svg')}}", + "title":"充值", + {% if params_kw._is_mobile %} + "width":"100%", + "height":"95%" + {% else %} + "width":"360px", + "height":"240px" + {% endif %} + }, + "options":{ + "params_kw":{ + "accountid":"{{acc.id}}" + }, + "url":"entire_url('/uniapy/recharge.ui')" + } + },{ + "wid":"self", + "event":"recharge", + "actiontype":"urlwidget", + "target":"PopupWindow", + "popup_options":{ + "icon":"{{entire_url('imgs/accdetail.svg')}}", + "title":"充值", + {% if params_kw._is_mobile %} + "width":"100%", + "height":"95%" + {% else %} + "width":"360px", + "height":"240px" + {% endif %} + }, + "options":{ + "params_kw":{ + "accountid":"{{acc.id}}" + }, + "url":"entire_url('accdetail.ui')" + } + } + ] + } +{% if not loop.last %},{% endif %} +{% endfor %} + ] +}