From 4340d8bbe1aa92ddecf72b89ff3a1429006dca71 Mon Sep 17 00:00:00 2001 From: Xc Date: Tue, 11 Jun 2024 18:33:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86sysAccount/survey?= =?UTF-8?q?=E7=9A=84=E9=83=A8=E5=88=86=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/aspects/withdraw.js | 7 + es/checkers/abstractChecker.d.ts | 2 + es/checkers/abstractChecker.js | 10 +- es/checkers/index.js | 2 + es/checkers/withdrawAccount.d.ts | 5 + es/checkers/withdrawAccount.js | 71 ++++++ es/components/sysAccount/survey/index.d.ts | 6 + es/components/sysAccount/survey/index.js | 73 ++++++ es/components/sysAccount/survey/index.json | 1 + es/components/sysAccount/survey/web.pc.d.ts | 12 + es/components/sysAccount/survey/web.pc.js | 11 + .../sysAccount/survey/web.pc.module.less | 7 + es/components/withdraw/create/index.js | 39 +-- es/components/withdraw/create/index.less | 21 ++ es/components/withdraw/create/index.xml | 45 +++- es/components/withdraw/create/web.js | 2 +- es/components/withdraw/detail/index.js | 4 - es/components/withdraw/display/index.js | 8 +- es/components/withdraw/display/web.js | 4 +- es/components/withdraw/display/web.pc.js | 4 +- es/components/withdraw/list/index.js | 7 +- .../withdraw/list/locales/zh-CN.json | 7 +- es/components/withdraw/list/web.d.ts | 17 ++ es/components/withdraw/list/web.js | 21 +- es/components/withdraw/list/web.pc.d.ts | 4 +- es/components/withdraw/list/web.pc.js | 19 +- .../withdraw/list/web.pc.module.less | 6 +- es/components/withdrawAccount/list/index.js | 48 +++- .../withdrawAccount/list/locales/zh-CN.json | 3 +- es/components/withdrawAccount/list/web.d.ts | 29 +++ es/components/withdrawAccount/list/web.js | 88 ++++++- .../withdrawAccount/list/web.module.less | 37 +++ .../withdrawAccount/list/web.pc.d.ts | 1 + es/components/withdrawAccount/list/web.pc.js | 45 ++-- es/components/withdrawAccount/upsert/web.d.ts | 16 ++ es/components/withdrawAccount/upsert/web.js | 35 ++- es/configuration/relation.js | 2 + es/data/actionAuth.js | 35 +++ es/data/i18n.js | 10 +- es/data/path.js | 42 ++++ es/triggers/abstract.js | 5 +- es/triggers/pay.js | 5 + es/triggers/refund.js | 3 + es/triggers/withdrawAccount.js | 76 +----- es/utils/payClazz/index.d.ts | 6 +- es/utils/payClazz/index.js | 23 +- lib/aspects/withdraw.js | 7 + lib/checkers/abstractChecker.d.ts | 2 + lib/checkers/abstractChecker.js | 12 +- lib/checkers/index.js | 2 + lib/checkers/withdrawAccount.d.ts | 5 + lib/checkers/withdrawAccount.js | 74 ++++++ lib/configuration/relation.js | 2 + lib/data/actionAuth.js | 35 +++ lib/data/i18n.js | 10 +- lib/data/path.js | 42 ++++ lib/triggers/abstract.js | 5 +- lib/triggers/pay.js | 5 + lib/triggers/refund.js | 3 + lib/triggers/withdrawAccount.js | 77 +----- lib/utils/payClazz/index.d.ts | 6 +- lib/utils/payClazz/index.js | 26 +- src/checkers/abstractChecker.ts | 12 +- src/components/offlineAccount/config/index.ts | 15 ++ .../offlineAccount/config/web.pc.module.less | 2 +- .../offlineAccount/config/web.pc.tsx | 43 ++-- src/components/payConfig/system/index.ts | 2 + src/components/payConfig/system/web.pc.tsx | 23 +- src/components/sysAccount/survey/index.json | 1 + src/components/sysAccount/survey/index.ts | 95 +++++++ .../sysAccount/survey/locales/zh-CN.json | 7 + .../sysAccount/survey/web.pc.module.less | 67 +++++ src/components/sysAccount/survey/web.pc.tsx | 232 ++++++++++++++++++ src/components/wpAccount/config/index.ts | 22 +- src/components/wpAccount/config/web.pc.tsx | 148 +++++------ src/components/wpAccount/upsert/index.ts | 2 + .../wpAccount/upsert/locales/zh-CN.json | 2 +- src/data/i18n.ts | 15 +- src/triggers/abstract.ts | 7 +- src/utils/payClazz/index.ts | 9 +- 80 files changed, 1542 insertions(+), 399 deletions(-) create mode 100644 es/checkers/withdrawAccount.d.ts create mode 100644 es/checkers/withdrawAccount.js create mode 100644 es/components/sysAccount/survey/index.d.ts create mode 100644 es/components/sysAccount/survey/index.js create mode 100644 es/components/sysAccount/survey/index.json create mode 100644 es/components/sysAccount/survey/web.pc.d.ts create mode 100644 es/components/sysAccount/survey/web.pc.js create mode 100644 es/components/sysAccount/survey/web.pc.module.less create mode 100644 lib/checkers/withdrawAccount.d.ts create mode 100644 lib/checkers/withdrawAccount.js create mode 100644 src/components/sysAccount/survey/index.json create mode 100644 src/components/sysAccount/survey/index.ts create mode 100644 src/components/sysAccount/survey/locales/zh-CN.json create mode 100644 src/components/sysAccount/survey/web.pc.module.less create mode 100644 src/components/sysAccount/survey/web.pc.tsx diff --git a/es/aspects/withdraw.js b/es/aspects/withdraw.js index 9e2e4993..79170eab 100644 --- a/es/aspects/withdraw.js +++ b/es/aspects/withdraw.js @@ -143,6 +143,9 @@ export async function getWithdrawCreateData(params, context) { data: ele, }))); } + else { + data.refund$entity = []; + } if (totalPrice > price2) { // 如果还有要退的部分,就从withdrawAccount来进行转账 const rest = totalPrice - price2; @@ -196,6 +199,10 @@ export async function getWithdrawCreateData(params, context) { } ]; } + else { + // 保持结构完整,让上层可以和withdraw$detail同构渲染 + data.withdrawTransfer$withdraw = []; + } data.loss = totalLoss; return data; } diff --git a/es/checkers/abstractChecker.d.ts b/es/checkers/abstractChecker.d.ts index 9e45aa6a..ae3b7098 100644 --- a/es/checkers/abstractChecker.d.ts +++ b/es/checkers/abstractChecker.d.ts @@ -1,5 +1,7 @@ import { EntityDict } from '../oak-app-domain'; import { RuntimeCxt } from '../types/RuntimeCxt'; import { Checker } from 'oak-domain/lib/types/Auth'; +export declare function registerAccountEntity(entity: keyof ED): void; +export declare const accountEntities: string[]; declare const triggers: Checker[]; export default triggers; diff --git a/es/checkers/abstractChecker.js b/es/checkers/abstractChecker.js index 6e75b3bb..a944ddeb 100644 --- a/es/checkers/abstractChecker.js +++ b/es/checkers/abstractChecker.js @@ -1,9 +1,11 @@ import { generateNewId } from 'oak-domain/lib/utils/uuid'; -import { getPayClazzAccountEntities } from '../utils/payClazz'; -// 当注入一个新的pay entity时,将account的删除与之相关联 -const entities = getPayClazzAccountEntities(); +// 当注入一个新的account entity时,将withdrawChannel的删除与之相关联 +export function registerAccountEntity(entity) { + accountEntities.push(entity); +} +export const accountEntities = ['wpAccount', 'offlineAccount']; const triggers = [ - ...entities.filter(ele => !!ele).map((entity) => [ + ...accountEntities.filter(ele => !!ele).map((entity) => [ { entity, action: 'remove', diff --git a/es/checkers/index.js b/es/checkers/index.js index d1cf04e1..0fcd30f6 100644 --- a/es/checkers/index.js +++ b/es/checkers/index.js @@ -5,7 +5,9 @@ import applicationCheckers from './application'; import offlineAccountCheckers from './offlineAccount'; import wpProductCheckers from './wpProduct'; import abstractCheckers from './abstractChecker'; +import withdrawAccounts from './withdrawAccount'; const checkers = [ + ...withdrawAccounts, ...abstractCheckers, ...aoCheckers, ...payCheckers, diff --git a/es/checkers/withdrawAccount.d.ts b/es/checkers/withdrawAccount.d.ts new file mode 100644 index 00000000..a361a8d4 --- /dev/null +++ b/es/checkers/withdrawAccount.d.ts @@ -0,0 +1,5 @@ +import { Checker } from 'oak-domain/lib/types/Auth'; +import { EntityDict } from '../oak-app-domain'; +import { RuntimeCxt } from '../types/RuntimeCxt'; +declare const checkers: Checker[]; +export default checkers; diff --git a/es/checkers/withdrawAccount.js b/es/checkers/withdrawAccount.js new file mode 100644 index 00000000..8153365b --- /dev/null +++ b/es/checkers/withdrawAccount.js @@ -0,0 +1,71 @@ +import { generateNewId } from 'oak-domain/lib/utils/uuid'; +import { pipeline } from 'oak-domain/lib/utils/executor'; +import assert from 'assert'; +const checkers = [ + { + entity: 'withdrawAccount', + type: 'logical', + action: 'create', + checker(operation, context, option) { + const { data } = operation; + if (data) { + const { id, entity, entityId, isDefault } = data; + if (entity && entityId && isDefault) { + return context.operate('withdrawAccount', { + id: generateNewId(), + action: 'update', + data: { + isDefault: false, + }, + filter: { + entity, + entityId, + isDefault: true, + id: { + $ne: id, + }, + } + }, option); + } + } + } + }, + { + entity: 'withdrawAccount', + type: 'logical', + action: 'update', + checker(operation, context, option) { + const { data, filter } = operation; + if (data?.isDefault) { + return pipeline(() => context.select('withdrawAccount', { + data: { + id: 1, + entity: 1, + entityId: 1, + }, + filter, + }, {}), (accounts) => { + assert(accounts.length === 1); + const [account] = accounts; + const { entity, entityId, id } = account; + return context.operate('withdrawAccount', { + id: generateNewId(), + action: 'update', + data: { + isDefault: false, + }, + filter: { + entity, + entityId, + isDefault: true, + id: { + $ne: id, + }, + } + }, option); + }); + } + } + } +]; +export default checkers; diff --git a/es/components/sysAccount/survey/index.d.ts b/es/components/sysAccount/survey/index.d.ts new file mode 100644 index 00000000..46949f04 --- /dev/null +++ b/es/components/sysAccount/survey/index.d.ts @@ -0,0 +1,6 @@ +import { EntityDict } from "../../../oak-app-domain"; +declare const _default: (props: import("oak-frontend-base").ReactComponentProps) => React.ReactElement; +export default _default; diff --git a/es/components/sysAccount/survey/index.js b/es/components/sysAccount/survey/index.js new file mode 100644 index 00000000..a1b11885 --- /dev/null +++ b/es/components/sysAccount/survey/index.js @@ -0,0 +1,73 @@ +import assert from 'assert'; +import { uniq } from "oak-domain/lib/utils/lodash"; +export default OakComponent({ + properties: { + entities: [], + systemId: '', + }, + lifetimes: { + ready() { + this.refreshData(); + } + }, + methods: { + refreshData() { + const { entities, systemId } = this.props; + const schema = this.features.cache.getSchema(); + uniq(['wpAccount', 'offlineAccount'].concat(entities || [])).forEach((entity) => { + const projection = { + id: 1, + $$createAt$$: 1, + $$updateAt$$: 1, + }; + Object.keys(schema[entity].attributes).forEach(ele => { + if (!ele.startsWith('$$')) { + projection[ele] = 1; + } + }); + this.features.cache.refresh(entity, { + data: projection, + filter: { + systemId, + } + }); + }); + }, + }, + formData({ features }) { + const { entities, systemId } = this.props; + assert(systemId); + const schema = features.cache.getSchema(); + let total = 0; + const accounts = uniq(['wpAccount', 'offlineAccount'].concat(entities || [])).map((entity) => { + const projection = { + id: 1, + $$createAt$$: 1, + $$updateAt$$: 1, + }; + Object.keys(schema[entity].attributes).forEach(ele => { + if (!ele.startsWith('$$')) { + projection[ele] = 1; + } + }); + const [data] = this.features.cache.get(entity, { + data: projection, + filter: { + systemId, + } + }, true); + const { price, id } = data; + total += price; + return { + entity, + id, + price, + data, + }; + }); + return { + total, + accounts, + }; + } +}); diff --git a/es/components/sysAccount/survey/index.json b/es/components/sysAccount/survey/index.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/es/components/sysAccount/survey/index.json @@ -0,0 +1 @@ +{} diff --git a/es/components/sysAccount/survey/web.pc.d.ts b/es/components/sysAccount/survey/web.pc.d.ts new file mode 100644 index 00000000..4312f4d0 --- /dev/null +++ b/es/components/sysAccount/survey/web.pc.d.ts @@ -0,0 +1,12 @@ +import { EntityDict } from "../../../oak-app-domain"; +import { WebComponentProps } from "oak-frontend-base"; +import React from 'react'; +export default function render(props: WebComponentProps; +}>): React.JSX.Element | null; diff --git a/es/components/sysAccount/survey/web.pc.js b/es/components/sysAccount/survey/web.pc.js new file mode 100644 index 00000000..6b9e1827 --- /dev/null +++ b/es/components/sysAccount/survey/web.pc.js @@ -0,0 +1,11 @@ +import React from 'react'; +import Styles from './web.pc.module.less'; +export default function render(props) { + const { accounts, total } = props.data; + if (accounts) { + return (
+ {total} +
); + } + return null; +} diff --git a/es/components/sysAccount/survey/web.pc.module.less b/es/components/sysAccount/survey/web.pc.module.less new file mode 100644 index 00000000..0b9f3c36 --- /dev/null +++ b/es/components/sysAccount/survey/web.pc.module.less @@ -0,0 +1,7 @@ +.container { + width: 100%; + height: 100%; + display: flex; + flex-direction: column; + align-items: stretch; +} \ No newline at end of file diff --git a/es/components/withdraw/create/index.js b/es/components/withdraw/create/index.js index 98f9c82d..87ffab46 100644 --- a/es/components/withdraw/create/index.js +++ b/es/components/withdraw/create/index.js @@ -34,8 +34,8 @@ export default OakComponent({ return { withdrawCreate: withdrawData && { ...withdrawData, - refund$entity: withdrawData.refund$entity.map((ele) => ele.data), - withdrawTransfer$withdraw: withdrawData.withdrawTransfer$withdraw.map((ele) => ele.data), + refund$entity: withdrawData.refund$entity?.map((ele) => ele.data), + withdrawTransfer$withdraw: withdrawData.withdrawTransfer$withdraw?.map((ele) => ele.data), }, withdrawable, withdrawLossText, @@ -81,6 +81,9 @@ export default OakComponent({ chooseWa: false, withdrawAccountId: '', waFilter: undefined, + pickWithdrawChannelMp(id) { + this.pickWithdrawChannel(id); + } }, methods: { setValue(valueYuan) { @@ -108,19 +111,21 @@ export default OakComponent({ }, async createWithdrawData() { const { value, refundAmount, avail, withdrawAccountId } = this.state; - if (value > avail) { - this.setMessage({ - type: 'error', - content: this.t('error::withdraw.overflow'), - }); - } - else if (value <= refundAmount) { - this.resetCreateData(); - } - else if (!withdrawAccountId) { - this.setState({ - chooseWa: true, - }); + if (value) { + if (value > avail) { + this.setMessage({ + type: 'error', + content: this.t('error::withdraw.overflow'), + }); + } + else if (value <= refundAmount) { + this.resetCreateData(); + } + else if (!withdrawAccountId) { + this.setState({ + chooseWa: true, + }); + } } }, async resetCreateData() { @@ -208,6 +213,10 @@ export default OakComponent({ }, goBack() { this.navigateBack(); + }, + onGoToHistoryMp() { + const { onGoToHistory } = this.props; + onGoToHistory && onGoToHistory(); } }, }); diff --git a/es/components/withdraw/create/index.less b/es/components/withdraw/create/index.less index f3ad58ab..5371a413 100644 --- a/es/components/withdraw/create/index.less +++ b/es/components/withdraw/create/index.less @@ -1,6 +1,17 @@ @import '../../../config/styles/mp/mixins.less'; @import '../../../config/styles/mp/index.less'; + +.errorContainer { + padding: 48rpx; + background-color: #fff; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 40rpx; +} + .container { height: 100%; box-sizing: border-box; @@ -93,6 +104,16 @@ } } + .gotoHistory { + font-size: 32rpx; + color: @oak-color-primary; + margin-top: 56rpx; + text-decoration: underline; + display: flex; + justify-content: flex-end; + align-items: center; + } + .footer { position: fixed; width: 100%; diff --git a/es/components/withdraw/create/index.xml b/es/components/withdraw/create/index.xml index 362e870e..cfed13a1 100644 --- a/es/components/withdraw/create/index.xml +++ b/es/components/withdraw/create/index.xml @@ -1,4 +1,21 @@ - + + + + {{t('notSetYet')}} + {{t('common::back')}} + + + + + + {{t('common::action.cancel')}} @@ -25,12 +42,13 @@ - + {{t('label')}} {{t('common::pay.symbol')}} {{t('tips.1-1')}} - {{availYuan}} - {{t('tips.1-2')}} - - {{t('tips.fill')}} + + + {{availYuan}} + + + {{availYuan}} + + {{t('tips.1-2')}} {{t('tips.2-1')}} @@ -56,7 +79,7 @@ {{t('tips.3-1')}} - {{manualAmountYuan}} + {{manualAmountYuan}} {{t('tips.3-2')}} @@ -72,7 +95,11 @@ {{t('helps.label.loss')}} - {{t('helps.content.loss')}} + {{withdrawLossText}} + + + + {{t('gotoHistory')}}
{t('common::pay.symbol')} - setValue(value)} style={{ '--font-size': '28px' }}/> + setValue(value)} style={{ '--font-size': '28px' }} onEnterPress={() => createWithdrawData()}/>
diff --git a/es/components/withdraw/detail/index.js b/es/components/withdraw/detail/index.js index 50f360d8..249e8e3a 100644 --- a/es/components/withdraw/detail/index.js +++ b/es/components/withdraw/detail/index.js @@ -9,10 +9,6 @@ export default OakComponent({ dealLoss: 1, dealPrice: 1, iState: 1, - withdrawAccount: { - id: 1, - name: 1, - }, reason: 1, meta: 1, refund$entity: { diff --git a/es/components/withdraw/display/index.js b/es/components/withdraw/display/index.js index 00890fa0..321fbce2 100644 --- a/es/components/withdraw/display/index.js +++ b/es/components/withdraw/display/index.js @@ -8,7 +8,7 @@ export default OakComponent({ formData({ features }) { const { withdraw, create } = this.props; const { refund$entity: refundData, withdrawTransfer$withdraw: transferData } = withdraw; - const refundData2 = (refundData).map((refund) => { + const refundData2 = (refundData)?.map((refund) => { const { meta, price, loss, iState, $$updateAt$$, reason } = refund; const { lossExplanation, channel } = meta; return { @@ -24,8 +24,8 @@ export default OakComponent({ updateAt: !create && dayJs($$updateAt$$).format('YYYY-MM-DD HH:mm'), reason, }; - }); - const transferData2 = transferData.map((transfer) => { + }) || []; + const transferData2 = transferData?.map((transfer) => { const { price, loss, iState, meta, withdrawAccountId, withdrawAccount, $$updateAt$$, reason } = transfer; let withdrawChannel = withdrawAccount?.channel; if (!withdrawChannel && withdrawAccountId) { @@ -65,7 +65,7 @@ export default OakComponent({ updateAt: !create && dayJs($$updateAt$$).format('YYYY-MM-DD HH:mm'), reason, }; - }); + }) || []; const withdrawExactPrice = ['successful', 'partiallySuccessful', 'failed'].includes(withdraw.iState) ? withdraw.dealPrice - withdraw.dealLoss : withdraw.price - withdraw.loss; return { createAtStr: dayJs(withdraw.$$createAt$$).format('YYYY-MM-DD HH:mm'), diff --git a/es/components/withdraw/display/web.js b/es/components/withdraw/display/web.js index feeb8824..d78f68bc 100644 --- a/es/components/withdraw/display/web.js +++ b/es/components/withdraw/display/web.js @@ -24,7 +24,9 @@ export default function render(props) {
{itemData && itemData.map((data, idx) => (
- {data.type} + + {data.type} +
{data.iState &&
{t('refund:attr.iState')} diff --git a/es/components/withdraw/display/web.pc.js b/es/components/withdraw/display/web.pc.js index 827c12fc..b621320e 100644 --- a/es/components/withdraw/display/web.pc.js +++ b/es/components/withdraw/display/web.pc.js @@ -46,7 +46,9 @@ export default function render(props) { {itemData &&
{itemData.map((data, idx) => (
- {data.type} + + {data.type} +
{data.iState &&
{t('refund:attr.iState')} diff --git a/es/components/withdraw/list/index.js b/es/components/withdraw/list/index.js index 5017bb34..df30e2e4 100644 --- a/es/components/withdraw/list/index.js +++ b/es/components/withdraw/list/index.js @@ -34,7 +34,7 @@ export default OakComponent({ }, }, }, - withdrawTransfer$withdraw: { + withdrawTransfer$withdraw$$aggr: { $entity: 'withdrawTransfer', data: { '#count-1': { @@ -60,5 +60,10 @@ export default OakComponent({ }; }), }; + }, + methods: { + goBack() { + this.navigateBack(); + } } }); diff --git a/es/components/withdraw/list/locales/zh-CN.json b/es/components/withdraw/list/locales/zh-CN.json index 137cb02e..5d5acc63 100644 --- a/es/components/withdraw/list/locales/zh-CN.json +++ b/es/components/withdraw/list/locales/zh-CN.json @@ -1,5 +1,6 @@ { - "loss": "预计手续费%{value}%元", - "dealLoss": "手续费%{value}%元", - "count": "将分%{value}笔提现到您账户" + "loss": "预计手续费%{value}元", + "dealLoss": "手续费%{value}元", + "count": "将分%{value}笔提现到您账户", + "noData": "您尚无提现记录" } diff --git a/es/components/withdraw/list/web.d.ts b/es/components/withdraw/list/web.d.ts index e69de29b..1835222d 100644 --- a/es/components/withdraw/list/web.d.ts +++ b/es/components/withdraw/list/web.d.ts @@ -0,0 +1,17 @@ +import React from 'react'; +import { EntityDict } from "../../../oak-app-domain"; +import { WebComponentProps } from "oak-frontend-base"; +export default function render(props: WebComponentProps void; + withdraws?: ({ + id: string; + iState: string; + iStateColor: string; + price: string; + lossDescription: string; + countDescription: number; + createAt: string; + })[]; +}, { + goBack: () => void; +}>): React.JSX.Element; diff --git a/es/components/withdraw/list/web.js b/es/components/withdraw/list/web.js index 3918c74e..c502644c 100644 --- a/es/components/withdraw/list/web.js +++ b/es/components/withdraw/list/web.js @@ -1 +1,20 @@ -"use strict"; +import React from 'react'; +import { List, Tag, Result, Button } from 'antd-mobile'; +import { HandPayCircleOutline } from 'antd-mobile-icons'; +export default function render(props) { + const { withdraws, gotoDetail } = props.data; + const { t, goBack } = props.methods; + if (withdraws?.length) { + return ( + {withdraws.map((ele) => (} extra={{ele.iState}} title={ele.lossDescription} description={ele.createAt} onClick={() => gotoDetail(ele.id)}> + <> + {t('common::pay.symbol')} + {ele.price} + + ))} + ); + } + return ( + {t('common::back')} + }/>); +} diff --git a/es/components/withdraw/list/web.pc.d.ts b/es/components/withdraw/list/web.pc.d.ts index 04c1ebb2..1835222d 100644 --- a/es/components/withdraw/list/web.pc.d.ts +++ b/es/components/withdraw/list/web.pc.d.ts @@ -12,4 +12,6 @@ export default function render(props: WebComponentProps): React.JSX.Element | null; +}, { + goBack: () => void; +}>): React.JSX.Element; diff --git a/es/components/withdraw/list/web.pc.js b/es/components/withdraw/list/web.pc.js index bb78c8c7..a8fde147 100644 --- a/es/components/withdraw/list/web.pc.js +++ b/es/components/withdraw/list/web.pc.js @@ -1,14 +1,14 @@ import React from 'react'; -import { List, Avatar, Button } from 'antd'; -import { CalendarOutlined } from '@ant-design/icons'; +import { List, Avatar, Result, Button } from 'antd'; +import { CalendarOutlined, NodeExpandOutlined } from '@ant-design/icons'; import Styles from './web.pc.module.less'; export default function render(props) { const { withdraws, gotoDetail } = props.data; - const { t } = props.methods; + const { t, goBack } = props.methods; if (withdraws?.length) { return ( ( gotoDetail(item.id)}> - {t('common::detail')} + {t('common::action.detail')} ]}> {item.lossDescription}
} description={
-
{item.countDescription}
+
+ + {item.countDescription} +
- {item.createAt} + {item.createAt}
}/> )}/>); } - return null; + return ( + {t('common::back')} + }/>); } diff --git a/es/components/withdraw/list/web.pc.module.less b/es/components/withdraw/list/web.pc.module.less index d0298527..248d4bc6 100644 --- a/es/components/withdraw/list/web.pc.module.less +++ b/es/components/withdraw/list/web.pc.module.less @@ -22,9 +22,7 @@ .description { padding: auto; - .createAt { - .date { - margin-left: 4px; - } + .data { + margin-left: 4px; } } \ No newline at end of file diff --git a/es/components/withdrawAccount/list/index.js b/es/components/withdrawAccount/list/index.js index dec741fa..9dad81e4 100644 --- a/es/components/withdrawAccount/list/index.js +++ b/es/components/withdrawAccount/list/index.js @@ -63,6 +63,7 @@ export default OakComponent({ return { entity, entityId, + enabled: true, }; } } @@ -87,19 +88,37 @@ export default OakComponent({ }); }, async removeAccount(id) { - return this.execute(undefined, undefined, undefined, [ - { - entity: 'withdrawAccount', - operation: { - id: await generateNewIdAsync(), - action: 'remove', - data: {}, - filter: { - id, - }, + const row = this.state.withdrawAccounts.find(ele => ele.id === id); + if (row['#oakLegalActions']?.includes('remove')) { + return this.execute(undefined, undefined, undefined, [ + { + entity: 'withdrawAccount', + operation: { + id: await generateNewIdAsync(), + action: 'remove', + data: {}, + filter: { + id, + }, + } } - } - ]); + ]); + } + else { + return this.execute(undefined, undefined, undefined, [ + { + entity: 'withdrawAccount', + operation: { + id: await generateNewIdAsync(), + action: 'disable', + data: {}, + filter: { + id, + }, + } + } + ]); + } }, resetAll() { this.clean(); @@ -111,6 +130,11 @@ export default OakComponent({ await this.execute(); this.resetAll(); }, + switchDefault(id) { + const row = this.state.withdrawAccounts.find(ele => ele.id === id); + this.clean(); + this.updateItem({ isDefault: !row.isDefault }, row.id); + }, pickOne(id) { this.setState({ selectedId: id, diff --git a/es/components/withdrawAccount/list/locales/zh-CN.json b/es/components/withdrawAccount/list/locales/zh-CN.json index 9967b95d..0b19942f 100644 --- a/es/components/withdrawAccount/list/locales/zh-CN.json +++ b/es/components/withdrawAccount/list/locales/zh-CN.json @@ -1,5 +1,6 @@ { "noData": "您还没有配置过提现账号", "confirmDelete": "确定删除", - "areYouSure": "确认删除本账号吗?" + "areYouSure": "确认删除本账号吗?", + "default": "默认" } diff --git a/es/components/withdrawAccount/list/web.d.ts b/es/components/withdrawAccount/list/web.d.ts index e69de29b..023feac9 100644 --- a/es/components/withdrawAccount/list/web.d.ts +++ b/es/components/withdrawAccount/list/web.d.ts @@ -0,0 +1,29 @@ +import React from 'react'; +import { EntityDict } from "../../../oak-app-domain"; +import { RowWithActions, WebComponentProps } from "oak-frontend-base"; +export default function render(props: WebComponentProps & { + label: string; + symbol: string; + allowUpdate?: boolean; + allowRemove?: boolean; + })[]; + upsertId: string; + entity: string; + entityId: string; + isCreate?: boolean; + asPicker?: boolean; + allowCreate?: boolean; + selectedId?: string; + onCancel?: () => void; +}, { + setUpsertId: (id: string) => void; + doUpdate: () => Promise; + resetAll: () => void; + updateAccount: (id: string) => void; + newAccount: () => void; + removeAccount: (id: string) => Promise; + switchDefault: (id: string) => void; + pickOne: (id: string) => void; + confirmPick: () => void; +}>): React.JSX.Element; diff --git a/es/components/withdrawAccount/list/web.js b/es/components/withdrawAccount/list/web.js index 3918c74e..139c7eb4 100644 --- a/es/components/withdrawAccount/list/web.js +++ b/es/components/withdrawAccount/list/web.js @@ -1 +1,87 @@ -"use strict"; +import React from 'react'; +import { Popup, SwipeAction, List, Button, Result, Checkbox, Switch, Modal } from 'antd-mobile'; +import Styles from './web.module.less'; +import WdaUpsert from '../upsert'; +export default function render(props) { + const { isCreate, withdrawAccounts, upsertId, oakFullpath, entity, entityId, asPicker, allowCreate, selectedId, onCancel, oakExecutable } = props.data; + const { t, setUpsertId, doUpdate, resetAll, updateAccount, newAccount, pickOne, confirmPick, removeAccount, switchDefault } = props.methods; + const U = upsertId && ( resetAll()} onClose={() => resetAll()}> + +
+ + +
+
); + if (!withdrawAccounts?.length) { + return (
+ {U} + newAccount()}> + {t('common::action.create')} + }/> +
); + } + const getItem = (ele, index) => ( + {ele.symbol} +
} title={ele.name} description={ele.code} extra={asPicker ? { + if (checked) { + pickOne(ele.id); + } + else { + pickOne(''); + } + }}/> : switchDefault(ele.id)}/>}> + {ele.label} + ); + return (
+ {U} +
+ + {withdrawAccounts.map((ele, idx) => { + const Item = getItem(ele, idx); + if (asPicker) { + return Item; + } + return ( Modal.confirm({ + title: t('confirmDelete'), + content: t('areYouSure'), + onConfirm: () => removeAccount(ele.id), + }) + } + ]}> + {Item} + ); + })} + +
+
+ {asPicker ? (<> + + + ) : (oakExecutable === true ? + <> + + + : + allowCreate && )} +
+
); +} diff --git a/es/components/withdrawAccount/list/web.module.less b/es/components/withdrawAccount/list/web.module.less index a472b62f..128d4410 100644 --- a/es/components/withdrawAccount/list/web.module.less +++ b/es/components/withdrawAccount/list/web.module.less @@ -1,4 +1,41 @@ .container { width: 100%; height: 100%; +} + + +.container2 { + height: 100%; + width: 100%; + display: flex; + flex-direction: column; + align-items: stretch; + + .list { + flex: 1; + + + .avatar { + font-size: 24px; + font-weight: bold; + width: 48px; + height: 48px; + border-radius: 24px; + display: flex; + align-items: center; + justify-content: center; + color: var(--oak-color-primary); + background-color: silver; + } + + .switch { + width: 72px; + } + } +} + +.btns { + display: flex; + flex-direction: row; + justify-content: flex-end; } \ No newline at end of file diff --git a/es/components/withdrawAccount/list/web.pc.d.ts b/es/components/withdrawAccount/list/web.pc.d.ts index 65d91e63..023feac9 100644 --- a/es/components/withdrawAccount/list/web.pc.d.ts +++ b/es/components/withdrawAccount/list/web.pc.d.ts @@ -23,6 +23,7 @@ export default function render(props: WebComponentProps void; newAccount: () => void; removeAccount: (id: string) => Promise; + switchDefault: (id: string) => void; pickOne: (id: string) => void; confirmPick: () => void; }>): React.JSX.Element; diff --git a/es/components/withdrawAccount/list/web.pc.js b/es/components/withdrawAccount/list/web.pc.js index eb7d49b8..cab49cc5 100644 --- a/es/components/withdrawAccount/list/web.pc.js +++ b/es/components/withdrawAccount/list/web.pc.js @@ -1,10 +1,10 @@ import React from 'react'; -import { Modal, Avatar, List, Button, Result, Checkbox } from 'antd'; +import { Modal, Switch, Avatar, List, Button, Result, Checkbox } from 'antd'; import Styles from './web.pc.module.less'; import WdaUpsert from '../upsert'; export default function render(props) { - const { isCreate, withdrawAccounts, upsertId, oakFullpath, entity, entityId, asPicker, allowCreate, selectedId, onCancel } = props.data; - const { t, setUpsertId, doUpdate, resetAll, updateAccount, newAccount, pickOne, confirmPick, removeAccount } = props.methods; + const { isCreate, withdrawAccounts, upsertId, oakFullpath, entity, entityId, asPicker, allowCreate, selectedId, onCancel, oakExecutable } = props.data; + const { t, setUpsertId, doUpdate, resetAll, updateAccount, newAccount, pickOne, confirmPick, removeAccount, switchDefault } = props.methods; const U = upsertId && ( resetAll()} closeIcon={null} onOk={() => doUpdate()} okText={t('common::confirm')} cancelText={t('common::action.cancel')}> ); @@ -19,7 +19,7 @@ export default function render(props) { return (
{U}
- ( { + ( { const { checked } = target; if (checked) { pickOne(item.id); @@ -28,10 +28,9 @@ export default function render(props) { pickOne(''); } }}/>] : [ - item.allowUpdate && , - item.allowRemove &&
- {!asPicker && allowCreate && } - {asPicker && <> - - - } + {asPicker ? (<> + + + ) : (oakExecutable === true ? + <> + + + : + allowCreate && )}
); } diff --git a/es/components/withdrawAccount/upsert/web.d.ts b/es/components/withdrawAccount/upsert/web.d.ts index e69de29b..a69a822e 100644 --- a/es/components/withdrawAccount/upsert/web.d.ts +++ b/es/components/withdrawAccount/upsert/web.d.ts @@ -0,0 +1,16 @@ +import React from 'react'; +import { EntityDict } from "../../../oak-app-domain"; +import { RowWithActions, WebComponentProps } from "oak-frontend-base"; +export default function render(props: WebComponentProps; + channels?: { + label: string; + value: string; + }[]; + channel?: EntityDict['withdrawChannel']['Schema']; + isBank?: boolean; + isOffline?: boolean; +}, { + onSetChannelId: (id: string) => void; + onUpdate: (attr: T, value: EntityDict['withdrawAccount']['OpSchema'][T] | null) => void; +}>): React.JSX.Element | undefined; diff --git a/es/components/withdrawAccount/upsert/web.js b/es/components/withdrawAccount/upsert/web.js index 3918c74e..65f30124 100644 --- a/es/components/withdrawAccount/upsert/web.js +++ b/es/components/withdrawAccount/upsert/web.js @@ -1 +1,34 @@ -"use strict"; +import React from 'react'; +import { Form, Switch, Input, Selector } from 'antd-mobile'; +export default function render(props) { + const { withdrawAccount, channels, channel, isBank } = props.data; + const { t, onSetChannelId, onUpdate } = props.methods; + if (withdrawAccount) { + return (
+ {channels && + { + onSetChannelId(ids[0]); + }}/> + } + {isBank && + + { + onUpdate('org', value); + }}/> + } + + { + onUpdate('name', value); + }}/> + + + { + onUpdate('code', value); + }}/> + + + onUpdate('isDefault', value)}/> + +
); + } +} diff --git a/es/configuration/relation.js b/es/configuration/relation.js index ca749e04..0377c102 100644 --- a/es/configuration/relation.js +++ b/es/configuration/relation.js @@ -3,6 +3,8 @@ export const authDeduceRelationMap = {}; export const selectFreeEntities = [ 'offlineAccount', 'wpProduct', + 'withdrawChannel', + 'wpAccount', ]; export const updateFreeDict = {}; export default { diff --git a/es/data/actionAuth.js b/es/data/actionAuth.js index 54b1e7ec..61e7111c 100644 --- a/es/data/actionAuth.js +++ b/es/data/actionAuth.js @@ -38,6 +38,41 @@ const actionAuths = [ id: 'user-account-withdraw', pathId: 'user-account-withdraw', deActions: ['select'], + }, + //account + { + id: 'account-user', + pathId: 'user-acc', + deActions: ['select', 'deposit', 'withdraw', 'consume', 'loan'], + }, + //deposit + { + id: 'deposit-creator', + pathId: 'creator-deposit', + deActions: ['create'], + }, + { + id: 'deposit-account-user', + pathId: 'user-account-deposit', + deActions: ['fail'], + }, + // accountOper + { + id: 'user-acc-oper', + pathId: 'user-acc-oper', + deActions: ['select', 'create'], + }, + // withdrawAccount + { + id: 'user-withdrawAccount', + pathId: 'user-withdrawAccount', + deActions: ['select', 'create', 'remove', 'disable', 'update'], + }, + // withdrawTransfer + { + id: 'user-acc-wdtransfer', + pathId: 'user-acc-wdtransfer', + deActions: ['select', 'create'], } ]; export default actionAuths; diff --git a/es/data/i18n.js b/es/data/i18n.js index cbfe6c1f..1750ba4a 100644 --- a/es/data/i18n.js +++ b/es/data/i18n.js @@ -457,9 +457,10 @@ const i18ns = [ module: "oak-pay-business", position: "src/components/withdraw/list", data: { - "loss": "预计手续费%{value}%元", - "dealLoss": "手续费%{value}%元", - "count": "将分%{value}笔提现到您账户" + "loss": "预计手续费%{value}元", + "dealLoss": "手续费%{value}元", + "count": "将分%{value}笔提现到您账户", + "noData": "您尚无提现记录" } }, { @@ -471,7 +472,8 @@ const i18ns = [ data: { "noData": "您还没有配置过提现账号", "confirmDelete": "确定删除", - "areYouSure": "确认删除本账号吗?" + "areYouSure": "确认删除本账号吗?", + "default": "默认" } }, { diff --git a/es/data/path.js b/es/data/path.js index 54abd592..7b6fa981 100644 --- a/es/data/path.js +++ b/es/data/path.js @@ -68,6 +68,48 @@ const paths = [ destEntity: 'withdraw', value: 'account.user', recursive: false, + }, + { + id: 'user-acc', + sourceEntity: 'user', + destEntity: 'account', + value: 'user', + recursive: false, + }, + { + id: 'user-acc-oper', + sourceEntity: 'user', + destEntity: 'accountOper', + value: 'account.user', + recursive: false, + }, + { + id: 'creator-deposit', + sourceEntity: 'user', + destEntity: 'deposit', + value: 'creator', + recursive: false, + }, + { + id: 'user-account-deposit', + sourceEntity: 'user', + destEntity: 'deposit', + value: 'account.user', + recursive: false, + }, + { + id: 'user-withdrawAccount', + sourceEntity: 'user', + destEntity: 'withdrawAccount', + value: 'user', + recursive: false, + }, + { + id: 'user-acc-wdtransfer', + sourceEntity: 'user', + destEntity: 'withdrawTransfer', + value: 'withdraw.account.user', + recursive: false, } ]; export default paths; diff --git a/es/triggers/abstract.js b/es/triggers/abstract.js index e8521676..79ed6c41 100644 --- a/es/triggers/abstract.js +++ b/es/triggers/abstract.js @@ -1,10 +1,9 @@ import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid'; import assert from 'assert'; -import { getPayClazzAccountEntities } from '../utils/payClazz'; // 这里一定要注意两者的先后顺序,如果有注入更多的payEntity的话 -const entities = getPayClazzAccountEntities(); +import { accountEntities } from '../checkers/abstractChecker'; const triggers = [ - ...entities.filter(ele => !!ele).map((entity) => [ + ...accountEntities.filter(ele => !!ele).map((entity) => [ { name: `当${entity}的帐户生成时,则生成对应的withDrawAccount`, entity, diff --git a/es/triggers/pay.js b/es/triggers/pay.js index 8bec4fad..eee0fe48 100644 --- a/es/triggers/pay.js +++ b/es/triggers/pay.js @@ -150,6 +150,7 @@ const triggers = [ entity: 'pay', action: 'create', when: 'after', + asRoot: true, fn: async ({ operation }, context, option) => { const { data } = operation; assert(!(data instanceof Array)); @@ -171,6 +172,7 @@ const triggers = [ action: ['startPaying', 'succeedPaying', 'continuePaying', 'startClosing', 'succeedClosing', 'startRefunding', 'refundAll', 'refundPartially'], when: 'after', + asRoot: true, fn: async ({ operation }, context, option) => { const { data, filter, action, id } = operation; assert(typeof filter.id === 'string'); @@ -286,6 +288,7 @@ const triggers = [ action: 'close', when: 'before', priority: 99, + asRoot: true, fn: async ({ operation }, context, option) => { const { data, filter } = operation; const pays = await context.select('pay', { @@ -372,6 +375,7 @@ const triggers = [ entity: 'pay', action: 'succeedPaying', when: 'after', + asRoot: true, fn: async ({ operation }, context) => { const { data, filter } = operation; const projection = { @@ -441,6 +445,7 @@ const triggers = [ { name: '当account类型的pay的paid达到price,改为支付成功', entity: 'pay', + asRoot: true, action: ['startPaying', 'continuePaying'], check(operation) { return (!!operation.data.paid) && operation.data.paid > 0; diff --git a/es/triggers/refund.js b/es/triggers/refund.js index 487829d2..831d5c36 100644 --- a/es/triggers/refund.js +++ b/es/triggers/refund.js @@ -117,6 +117,7 @@ const triggers = [ entity: 'refund', action: 'succeedRefunding', when: 'after', + asRoot: true, name: '退款成功时,更新对应的pay状态以及对应的withdraw状态', fn: async ({ operation }, context) => { const { filter } = operation; @@ -210,6 +211,7 @@ const triggers = [ entity: 'refund', action: 'failRefunding', when: 'after', + asRoot: true, name: '退款失败时,更新对应的pay状态以及对应的withdraw状态', fn: async ({ operation }, context) => { const { filter } = operation; @@ -252,6 +254,7 @@ const triggers = [ entity: 'refund', name: '当发起退款时,将对应的pay置退款中状态', action: 'create', + asRoot: true, when: 'before', fn: async ({ operation }, context) => { const { data } = operation; diff --git a/es/triggers/withdrawAccount.js b/es/triggers/withdrawAccount.js index 977e9b6d..339c9d2d 100644 --- a/es/triggers/withdrawAccount.js +++ b/es/triggers/withdrawAccount.js @@ -1,76 +1,2 @@ -import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid'; -import assert from 'assert'; -const triggers = [ - { - name: '当withdrawAccount帐户被设置为default时,将其它的default设为false', - entity: 'withdrawAccount', - action: 'update', - check(operation) { - return operation.data.isDefault === true; - }, - when: 'after', - fn: async ({ operation }, context, option) => { - const { filter } = operation; - const accounts = await context.select('withdrawAccount', { - data: { - id: 1, - entity: 1, - entityId: 1, - }, - filter, - }, {}); - assert(accounts.length === 1); - for (const account of accounts) { - const { entity, entityId, id } = account; - await context.operate('withdrawAccount', { - id: await generateNewIdAsync(), - action: 'update', - data: { - isDefault: false, - }, - filter: { - entity, - entityId, - isDefault: true, - id: { - $ne: id, - }, - } - }, {}); - } - return 1; - }, - }, - { - name: '当withdrawAccount帐户创建为default时,将其它的default设为false', - entity: 'withdrawAccount', - action: 'create', - when: 'after', - fn: async ({ operation }, context, option) => { - const { data } = operation; - assert(!(data instanceof Array)); - const { id, entity, entityId, isDefault } = data; - assert(entity && entityId); - if (isDefault) { - await context.operate('withdrawAccount', { - id: await generateNewIdAsync(), - action: 'update', - data: { - isDefault: false, - }, - filter: { - entity, - entityId, - isDefault: true, - id: { - $ne: id, - }, - } - }, {}); - return 1; - } - return 0; - } - }, -]; +const triggers = []; export default triggers; diff --git a/es/utils/payClazz/index.d.ts b/es/utils/payClazz/index.d.ts index c5de8804..3380c957 100644 --- a/es/utils/payClazz/index.d.ts +++ b/es/utils/payClazz/index.d.ts @@ -2,11 +2,11 @@ import { EntityDict } from '../../oak-app-domain'; import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity'; import PayClazz from '../../types/PayClazz'; import { BRC } from '../../types/RuntimeCxt'; +import { StorageSchema } from 'oak-domain/lib/types/Storage'; type PayClazzConstructor = (applicationId: string, entityId: string, context: BRC) => Promise; -export declare function registerPayClazzEntity(entity: keyof ED, def: { +export declare function registerPayClazzEntity(entity: T, def: { clazzConstructor: PayClazzConstructor; accountEntity: keyof ED; -}): void; -export declare function getPayClazzAccountEntities(): (keyof ED)[]; +}, schema: StorageSchema): void; export declare function getPayClazz(applicationId: string, entity: EntityDict['pay']['OpSchema']['entity'], entityId: string, context: BRC): Promise; export {}; diff --git a/es/utils/payClazz/index.js b/es/utils/payClazz/index.js index 002d7571..3ced7901 100644 --- a/es/utils/payClazz/index.js +++ b/es/utils/payClazz/index.js @@ -2,6 +2,7 @@ import assert from 'assert'; import Offline from './Offline'; import Account from './Account'; import WechatPay from './WechatPay'; +import { registerAccountEntity } from '../../checkers/abstractChecker'; const PayChannelDict = {}; const PayClazzEntityDict = { 'account': { @@ -106,19 +107,27 @@ const PayClazzEntityDict = { // 这里用一个flag来表达先后顺序,如果有registerPayClazzEntity,框架应保证register在get之前 // 目前因为没有registerPayClazzEntity,所以没测,可能不对。by Xc 20240608 let MODULE_USED = false; -export function registerPayClazzEntity(entity, def) { - assert(!MODULE_USED); +export function registerPayClazzEntity(entity, def, schema) { + if (!MODULE_USED) { + assert(!MODULE_USED); + } PayClazzEntityDict[entity] = { accountEntity: def.accountEntity, clazzConstructor: def.clazzConstructor, }; -} -export function getPayClazzAccountEntities() { - MODULE_USED = true; - return Object.keys(PayClazzEntityDict).map(ele => PayClazzEntityDict[ele].accountEntity); + // 检查此entity是否符合注册要求 + const { attributes } = schema[entity]; + const { attributes: payAttr } = schema.pay; + const { attributes: accountAttr } = schema[def.accountEntity]; + assert(payAttr.entity.enumeration?.includes(entity)); + assert(accountAttr.price && accountAttr.price.type === 'decimal'); + assert(accountAttr.systemId && accountAttr.systemId.type === 'ref' && accountAttr.systemId.ref === 'system'); + registerAccountEntity(def.accountEntity); } export async function getPayClazz(applicationId, entity, entityId, context) { - MODULE_USED = true; + if (!MODULE_USED) { + assert(!MODULE_USED); + } const key = entity === 'account' ? entity : `${entity}.${entityId}`; if (PayChannelDict.hasOwnProperty(key)) { return PayChannelDict[key]; diff --git a/lib/aspects/withdraw.js b/lib/aspects/withdraw.js index 932e3d1d..a3a4df34 100644 --- a/lib/aspects/withdraw.js +++ b/lib/aspects/withdraw.js @@ -147,6 +147,9 @@ async function getWithdrawCreateData(params, context) { data: ele, }))); } + else { + data.refund$entity = []; + } if (totalPrice > price2) { // 如果还有要退的部分,就从withdrawAccount来进行转账 const rest = totalPrice - price2; @@ -200,6 +203,10 @@ async function getWithdrawCreateData(params, context) { } ]; } + else { + // 保持结构完整,让上层可以和withdraw$detail同构渲染 + data.withdrawTransfer$withdraw = []; + } data.loss = totalLoss; return data; } diff --git a/lib/checkers/abstractChecker.d.ts b/lib/checkers/abstractChecker.d.ts index 9e45aa6a..ae3b7098 100644 --- a/lib/checkers/abstractChecker.d.ts +++ b/lib/checkers/abstractChecker.d.ts @@ -1,5 +1,7 @@ import { EntityDict } from '../oak-app-domain'; import { RuntimeCxt } from '../types/RuntimeCxt'; import { Checker } from 'oak-domain/lib/types/Auth'; +export declare function registerAccountEntity(entity: keyof ED): void; +export declare const accountEntities: string[]; declare const triggers: Checker[]; export default triggers; diff --git a/lib/checkers/abstractChecker.js b/lib/checkers/abstractChecker.js index e0d86de7..ea488491 100644 --- a/lib/checkers/abstractChecker.js +++ b/lib/checkers/abstractChecker.js @@ -1,11 +1,15 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +exports.accountEntities = exports.registerAccountEntity = void 0; const uuid_1 = require("oak-domain/lib/utils/uuid"); -const payClazz_1 = require("../utils/payClazz"); -// 当注入一个新的pay entity时,将account的删除与之相关联 -const entities = (0, payClazz_1.getPayClazzAccountEntities)(); +// 当注入一个新的account entity时,将withdrawChannel的删除与之相关联 +function registerAccountEntity(entity) { + exports.accountEntities.push(entity); +} +exports.registerAccountEntity = registerAccountEntity; +exports.accountEntities = ['wpAccount', 'offlineAccount']; const triggers = [ - ...entities.filter(ele => !!ele).map((entity) => [ + ...exports.accountEntities.filter(ele => !!ele).map((entity) => [ { entity, action: 'remove', diff --git a/lib/checkers/index.js b/lib/checkers/index.js index bd4af033..19025f13 100644 --- a/lib/checkers/index.js +++ b/lib/checkers/index.js @@ -8,7 +8,9 @@ const application_1 = tslib_1.__importDefault(require("./application")); const offlineAccount_1 = tslib_1.__importDefault(require("./offlineAccount")); const wpProduct_1 = tslib_1.__importDefault(require("./wpProduct")); const abstractChecker_1 = tslib_1.__importDefault(require("./abstractChecker")); +const withdrawAccount_1 = tslib_1.__importDefault(require("./withdrawAccount")); const checkers = [ + ...withdrawAccount_1.default, ...abstractChecker_1.default, ...accountOper_1.default, ...pay_1.default, diff --git a/lib/checkers/withdrawAccount.d.ts b/lib/checkers/withdrawAccount.d.ts new file mode 100644 index 00000000..a361a8d4 --- /dev/null +++ b/lib/checkers/withdrawAccount.d.ts @@ -0,0 +1,5 @@ +import { Checker } from 'oak-domain/lib/types/Auth'; +import { EntityDict } from '../oak-app-domain'; +import { RuntimeCxt } from '../types/RuntimeCxt'; +declare const checkers: Checker[]; +export default checkers; diff --git a/lib/checkers/withdrawAccount.js b/lib/checkers/withdrawAccount.js new file mode 100644 index 00000000..b4486a38 --- /dev/null +++ b/lib/checkers/withdrawAccount.js @@ -0,0 +1,74 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +const uuid_1 = require("oak-domain/lib/utils/uuid"); +const executor_1 = require("oak-domain/lib/utils/executor"); +const assert_1 = tslib_1.__importDefault(require("assert")); +const checkers = [ + { + entity: 'withdrawAccount', + type: 'logical', + action: 'create', + checker(operation, context, option) { + const { data } = operation; + if (data) { + const { id, entity, entityId, isDefault } = data; + if (entity && entityId && isDefault) { + return context.operate('withdrawAccount', { + id: (0, uuid_1.generateNewId)(), + action: 'update', + data: { + isDefault: false, + }, + filter: { + entity, + entityId, + isDefault: true, + id: { + $ne: id, + }, + } + }, option); + } + } + } + }, + { + entity: 'withdrawAccount', + type: 'logical', + action: 'update', + checker(operation, context, option) { + const { data, filter } = operation; + if (data?.isDefault) { + return (0, executor_1.pipeline)(() => context.select('withdrawAccount', { + data: { + id: 1, + entity: 1, + entityId: 1, + }, + filter, + }, {}), (accounts) => { + (0, assert_1.default)(accounts.length === 1); + const [account] = accounts; + const { entity, entityId, id } = account; + return context.operate('withdrawAccount', { + id: (0, uuid_1.generateNewId)(), + action: 'update', + data: { + isDefault: false, + }, + filter: { + entity, + entityId, + isDefault: true, + id: { + $ne: id, + }, + } + }, option); + }); + } + } + } +]; +exports.default = checkers; diff --git a/lib/configuration/relation.js b/lib/configuration/relation.js index e311fea6..b67cf073 100644 --- a/lib/configuration/relation.js +++ b/lib/configuration/relation.js @@ -6,6 +6,8 @@ exports.authDeduceRelationMap = {}; exports.selectFreeEntities = [ 'offlineAccount', 'wpProduct', + 'withdrawChannel', + 'wpAccount', ]; exports.updateFreeDict = {}; exports.default = { diff --git a/lib/data/actionAuth.js b/lib/data/actionAuth.js index c4ffabfe..f9978206 100644 --- a/lib/data/actionAuth.js +++ b/lib/data/actionAuth.js @@ -40,6 +40,41 @@ const actionAuths = [ id: 'user-account-withdraw', pathId: 'user-account-withdraw', deActions: ['select'], + }, + //account + { + id: 'account-user', + pathId: 'user-acc', + deActions: ['select', 'deposit', 'withdraw', 'consume', 'loan'], + }, + //deposit + { + id: 'deposit-creator', + pathId: 'creator-deposit', + deActions: ['create'], + }, + { + id: 'deposit-account-user', + pathId: 'user-account-deposit', + deActions: ['fail'], + }, + // accountOper + { + id: 'user-acc-oper', + pathId: 'user-acc-oper', + deActions: ['select', 'create'], + }, + // withdrawAccount + { + id: 'user-withdrawAccount', + pathId: 'user-withdrawAccount', + deActions: ['select', 'create', 'remove', 'disable', 'update'], + }, + // withdrawTransfer + { + id: 'user-acc-wdtransfer', + pathId: 'user-acc-wdtransfer', + deActions: ['select', 'create'], } ]; exports.default = actionAuths; diff --git a/lib/data/i18n.js b/lib/data/i18n.js index 9d140189..26c0ad62 100644 --- a/lib/data/i18n.js +++ b/lib/data/i18n.js @@ -459,9 +459,10 @@ const i18ns = [ module: "oak-pay-business", position: "src/components/withdraw/list", data: { - "loss": "预计手续费%{value}%元", - "dealLoss": "手续费%{value}%元", - "count": "将分%{value}笔提现到您账户" + "loss": "预计手续费%{value}元", + "dealLoss": "手续费%{value}元", + "count": "将分%{value}笔提现到您账户", + "noData": "您尚无提现记录" } }, { @@ -473,7 +474,8 @@ const i18ns = [ data: { "noData": "您还没有配置过提现账号", "confirmDelete": "确定删除", - "areYouSure": "确认删除本账号吗?" + "areYouSure": "确认删除本账号吗?", + "default": "默认" } }, { diff --git a/lib/data/path.js b/lib/data/path.js index c4ac7252..c74bd964 100644 --- a/lib/data/path.js +++ b/lib/data/path.js @@ -70,6 +70,48 @@ const paths = [ destEntity: 'withdraw', value: 'account.user', recursive: false, + }, + { + id: 'user-acc', + sourceEntity: 'user', + destEntity: 'account', + value: 'user', + recursive: false, + }, + { + id: 'user-acc-oper', + sourceEntity: 'user', + destEntity: 'accountOper', + value: 'account.user', + recursive: false, + }, + { + id: 'creator-deposit', + sourceEntity: 'user', + destEntity: 'deposit', + value: 'creator', + recursive: false, + }, + { + id: 'user-account-deposit', + sourceEntity: 'user', + destEntity: 'deposit', + value: 'account.user', + recursive: false, + }, + { + id: 'user-withdrawAccount', + sourceEntity: 'user', + destEntity: 'withdrawAccount', + value: 'user', + recursive: false, + }, + { + id: 'user-acc-wdtransfer', + sourceEntity: 'user', + destEntity: 'withdrawTransfer', + value: 'withdraw.account.user', + recursive: false, } ]; exports.default = paths; diff --git a/lib/triggers/abstract.js b/lib/triggers/abstract.js index 8177b225..42046b32 100644 --- a/lib/triggers/abstract.js +++ b/lib/triggers/abstract.js @@ -3,11 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const uuid_1 = require("oak-domain/lib/utils/uuid"); const assert_1 = tslib_1.__importDefault(require("assert")); -const payClazz_1 = require("../utils/payClazz"); // 这里一定要注意两者的先后顺序,如果有注入更多的payEntity的话 -const entities = (0, payClazz_1.getPayClazzAccountEntities)(); +const abstractChecker_1 = require("../checkers/abstractChecker"); const triggers = [ - ...entities.filter(ele => !!ele).map((entity) => [ + ...abstractChecker_1.accountEntities.filter(ele => !!ele).map((entity) => [ { name: `当${entity}的帐户生成时,则生成对应的withDrawAccount`, entity, diff --git a/lib/triggers/pay.js b/lib/triggers/pay.js index 5e50b2b7..7a742f70 100644 --- a/lib/triggers/pay.js +++ b/lib/triggers/pay.js @@ -153,6 +153,7 @@ const triggers = [ entity: 'pay', action: 'create', when: 'after', + asRoot: true, fn: async ({ operation }, context, option) => { const { data } = operation; (0, assert_1.default)(!(data instanceof Array)); @@ -174,6 +175,7 @@ const triggers = [ action: ['startPaying', 'succeedPaying', 'continuePaying', 'startClosing', 'succeedClosing', 'startRefunding', 'refundAll', 'refundPartially'], when: 'after', + asRoot: true, fn: async ({ operation }, context, option) => { const { data, filter, action, id } = operation; (0, assert_1.default)(typeof filter.id === 'string'); @@ -289,6 +291,7 @@ const triggers = [ action: 'close', when: 'before', priority: 99, + asRoot: true, fn: async ({ operation }, context, option) => { const { data, filter } = operation; const pays = await context.select('pay', { @@ -375,6 +378,7 @@ const triggers = [ entity: 'pay', action: 'succeedPaying', when: 'after', + asRoot: true, fn: async ({ operation }, context) => { const { data, filter } = operation; const projection = { @@ -444,6 +448,7 @@ const triggers = [ { name: '当account类型的pay的paid达到price,改为支付成功', entity: 'pay', + asRoot: true, action: ['startPaying', 'continuePaying'], check(operation) { return (!!operation.data.paid) && operation.data.paid > 0; diff --git a/lib/triggers/refund.js b/lib/triggers/refund.js index 4f6e02a4..99fb65e8 100644 --- a/lib/triggers/refund.js +++ b/lib/triggers/refund.js @@ -120,6 +120,7 @@ const triggers = [ entity: 'refund', action: 'succeedRefunding', when: 'after', + asRoot: true, name: '退款成功时,更新对应的pay状态以及对应的withdraw状态', fn: async ({ operation }, context) => { const { filter } = operation; @@ -213,6 +214,7 @@ const triggers = [ entity: 'refund', action: 'failRefunding', when: 'after', + asRoot: true, name: '退款失败时,更新对应的pay状态以及对应的withdraw状态', fn: async ({ operation }, context) => { const { filter } = operation; @@ -255,6 +257,7 @@ const triggers = [ entity: 'refund', name: '当发起退款时,将对应的pay置退款中状态', action: 'create', + asRoot: true, when: 'before', fn: async ({ operation }, context) => { const { data } = operation; diff --git a/lib/triggers/withdrawAccount.js b/lib/triggers/withdrawAccount.js index e5cdfbc6..56a29395 100644 --- a/lib/triggers/withdrawAccount.js +++ b/lib/triggers/withdrawAccount.js @@ -1,79 +1,4 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const tslib_1 = require("tslib"); -const uuid_1 = require("oak-domain/lib/utils/uuid"); -const assert_1 = tslib_1.__importDefault(require("assert")); -const triggers = [ - { - name: '当withdrawAccount帐户被设置为default时,将其它的default设为false', - entity: 'withdrawAccount', - action: 'update', - check(operation) { - return operation.data.isDefault === true; - }, - when: 'after', - fn: async ({ operation }, context, option) => { - const { filter } = operation; - const accounts = await context.select('withdrawAccount', { - data: { - id: 1, - entity: 1, - entityId: 1, - }, - filter, - }, {}); - (0, assert_1.default)(accounts.length === 1); - for (const account of accounts) { - const { entity, entityId, id } = account; - await context.operate('withdrawAccount', { - id: await (0, uuid_1.generateNewIdAsync)(), - action: 'update', - data: { - isDefault: false, - }, - filter: { - entity, - entityId, - isDefault: true, - id: { - $ne: id, - }, - } - }, {}); - } - return 1; - }, - }, - { - name: '当withdrawAccount帐户创建为default时,将其它的default设为false', - entity: 'withdrawAccount', - action: 'create', - when: 'after', - fn: async ({ operation }, context, option) => { - const { data } = operation; - (0, assert_1.default)(!(data instanceof Array)); - const { id, entity, entityId, isDefault } = data; - (0, assert_1.default)(entity && entityId); - if (isDefault) { - await context.operate('withdrawAccount', { - id: await (0, uuid_1.generateNewIdAsync)(), - action: 'update', - data: { - isDefault: false, - }, - filter: { - entity, - entityId, - isDefault: true, - id: { - $ne: id, - }, - } - }, {}); - return 1; - } - return 0; - } - }, -]; +const triggers = []; exports.default = triggers; diff --git a/lib/utils/payClazz/index.d.ts b/lib/utils/payClazz/index.d.ts index c5de8804..3380c957 100644 --- a/lib/utils/payClazz/index.d.ts +++ b/lib/utils/payClazz/index.d.ts @@ -2,11 +2,11 @@ import { EntityDict } from '../../oak-app-domain'; import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity'; import PayClazz from '../../types/PayClazz'; import { BRC } from '../../types/RuntimeCxt'; +import { StorageSchema } from 'oak-domain/lib/types/Storage'; type PayClazzConstructor = (applicationId: string, entityId: string, context: BRC) => Promise; -export declare function registerPayClazzEntity(entity: keyof ED, def: { +export declare function registerPayClazzEntity(entity: T, def: { clazzConstructor: PayClazzConstructor; accountEntity: keyof ED; -}): void; -export declare function getPayClazzAccountEntities(): (keyof ED)[]; +}, schema: StorageSchema): void; export declare function getPayClazz(applicationId: string, entity: EntityDict['pay']['OpSchema']['entity'], entityId: string, context: BRC): Promise; export {}; diff --git a/lib/utils/payClazz/index.js b/lib/utils/payClazz/index.js index b67136f0..6297a03d 100644 --- a/lib/utils/payClazz/index.js +++ b/lib/utils/payClazz/index.js @@ -1,11 +1,12 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getPayClazz = exports.getPayClazzAccountEntities = exports.registerPayClazzEntity = void 0; +exports.getPayClazz = exports.registerPayClazzEntity = void 0; const tslib_1 = require("tslib"); const assert_1 = tslib_1.__importDefault(require("assert")); const Offline_1 = tslib_1.__importDefault(require("./Offline")); const Account_1 = tslib_1.__importDefault(require("./Account")); const WechatPay_1 = tslib_1.__importDefault(require("./WechatPay")); +const abstractChecker_1 = require("../../checkers/abstractChecker"); const PayChannelDict = {}; const PayClazzEntityDict = { 'account': { @@ -110,21 +111,28 @@ const PayClazzEntityDict = { // 这里用一个flag来表达先后顺序,如果有registerPayClazzEntity,框架应保证register在get之前 // 目前因为没有registerPayClazzEntity,所以没测,可能不对。by Xc 20240608 let MODULE_USED = false; -function registerPayClazzEntity(entity, def) { - (0, assert_1.default)(!MODULE_USED); +function registerPayClazzEntity(entity, def, schema) { + if (!MODULE_USED) { + (0, assert_1.default)(!MODULE_USED); + } PayClazzEntityDict[entity] = { accountEntity: def.accountEntity, clazzConstructor: def.clazzConstructor, }; + // 检查此entity是否符合注册要求 + const { attributes } = schema[entity]; + const { attributes: payAttr } = schema.pay; + const { attributes: accountAttr } = schema[def.accountEntity]; + (0, assert_1.default)(payAttr.entity.enumeration?.includes(entity)); + (0, assert_1.default)(accountAttr.price && accountAttr.price.type === 'decimal'); + (0, assert_1.default)(accountAttr.systemId && accountAttr.systemId.type === 'ref' && accountAttr.systemId.ref === 'system'); + (0, abstractChecker_1.registerAccountEntity)(def.accountEntity); } exports.registerPayClazzEntity = registerPayClazzEntity; -function getPayClazzAccountEntities() { - MODULE_USED = true; - return Object.keys(PayClazzEntityDict).map(ele => PayClazzEntityDict[ele].accountEntity); -} -exports.getPayClazzAccountEntities = getPayClazzAccountEntities; async function getPayClazz(applicationId, entity, entityId, context) { - MODULE_USED = true; + if (!MODULE_USED) { + (0, assert_1.default)(!MODULE_USED); + } const key = entity === 'account' ? entity : `${entity}.${entityId}`; if (PayChannelDict.hasOwnProperty(key)) { return PayChannelDict[key]; diff --git a/src/checkers/abstractChecker.ts b/src/checkers/abstractChecker.ts index 08b0fccc..93d76655 100644 --- a/src/checkers/abstractChecker.ts +++ b/src/checkers/abstractChecker.ts @@ -1,15 +1,17 @@ import { generateNewId } from 'oak-domain/lib/utils/uuid'; import { EntityDict } from '../oak-app-domain'; import { BRC, RuntimeCxt } from '../types/RuntimeCxt'; -import assert from 'assert'; -import { getPayClazzAccountEntities } from '../utils/payClazz'; import { Checker, LogicalChecker } from 'oak-domain/lib/types/Auth'; -// 当注入一个新的pay entity时,将account的删除与之相关联 -const entities = getPayClazzAccountEntities(); +// 当注入一个新的account entity时,将withdrawChannel的删除与之相关联 +export function registerAccountEntity(entity: keyof ED) { + accountEntities.push(entity as string); +} + +export const accountEntities = ['wpAccount', 'offlineAccount']; const triggers: Checker[] = [ - ...entities.filter(ele => !!ele).map( + ...accountEntities.filter(ele => !!ele).map( (entity) => [ { entity, diff --git a/src/components/offlineAccount/config/index.ts b/src/components/offlineAccount/config/index.ts index 04bdd721..389866e8 100644 --- a/src/components/offlineAccount/config/index.ts +++ b/src/components/offlineAccount/config/index.ts @@ -12,10 +12,25 @@ export default OakComponent({ systemId: 1, price: 1, enabled: 1, + taxLossRatio: 1, + refundCompensateRatio: 1, + refundGapDays: 1, + allowWithdrawTransfer: 1, + withdrawTransferLossRatio: 1, }, properties: { systemId: '', }, + filters: [ + { + filter() { + const { systemId } = this.props; + return { + systemId, + }; + } + } + ], formData({ data, legalActions }) { return { accounts: data.map( diff --git a/src/components/offlineAccount/config/web.pc.module.less b/src/components/offlineAccount/config/web.pc.module.less index cf7d1871..611726ad 100644 --- a/src/components/offlineAccount/config/web.pc.module.less +++ b/src/components/offlineAccount/config/web.pc.module.less @@ -12,7 +12,7 @@ display: flex; flex-direction: row; flex-wrap: wrap; - align-items: flex-start; + align-items: stretch; .item { border: 0.1px solid silver; diff --git a/src/components/offlineAccount/config/web.pc.tsx b/src/components/offlineAccount/config/web.pc.tsx index 06a43b01..cb63e6ca 100644 --- a/src/components/offlineAccount/config/web.pc.tsx +++ b/src/components/offlineAccount/config/web.pc.tsx @@ -8,31 +8,33 @@ import Styles from './web.pc.module.less'; import Upsert from '../upsert'; import { OakAttrNotNullException, OakException } from 'oak-domain/lib/types'; import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid'; +import { ToYuan } from 'oak-domain/lib/utils/money'; -function OfflineAccount(props: { - account: RowWithActions & { color: string }; +export function OfflineAccount(props: { + data: RowWithActions & { color: string }; t: (k: string, param?: any) => string; - onUpdate: () => void; - onRemove: () => void; - onQrCodeClick: () => void; + onUpdate?: () => void; + onRemove?: () => void; + onQrCodeClick?: () => void; }) { - const { account, t, onUpdate, onRemove, onQrCodeClick } = props; - const { type, channel, name, qrCode, allowDeposit, allowPay, color, enabled, price } = account; - const legalActions = account['#oakLegalActions']; + const { data: account, t, onUpdate, onRemove, onQrCodeClick } = props; + const { type, channel, name, qrCode, allowDeposit, allowPay, color, enabled, price, + taxLossRatio, refundCompensateRatio, refundGapDays, allowWithdrawTransfer, withdrawTransferLossRatio + } = account; return ( - {legalActions.includes('update') && } - {legalActions.includes('remove') && +
+
+ ); + } + ) + } +
+ + ); + } + + return null; +} \ No newline at end of file diff --git a/src/components/wpAccount/config/index.ts b/src/components/wpAccount/config/index.ts index 676949d3..7e0665df 100644 --- a/src/components/wpAccount/config/index.ts +++ b/src/components/wpAccount/config/index.ts @@ -5,14 +5,30 @@ export default OakComponent({ id: 1, price: 1, mchId: 1, - refundGapDays: 1, - taxLossRatio: 1, enabled: 1, + taxLossRatio: 1, + refundCompensateRatio: 1, + refundGapDays: 1, + allowWithdrawTransfer: 1, + withdrawTransferLossRatio: 1, }, + properties: { + systemId: '', + }, + filters: [ + { + filter() { + const { systemId } = this.props; + return { + systemId, + }; + } + } + ], formData({ data, legalActions }) { return { accounts: data, - canCreate: legalActions?.includes('create'), + canCreate: legalActions?.includes('create') && !data?.find(ele => ele.enabled), }; }, actions: ['create', 'update', 'remove'], diff --git a/src/components/wpAccount/config/web.pc.tsx b/src/components/wpAccount/config/web.pc.tsx index e029526b..5eb7fc40 100644 --- a/src/components/wpAccount/config/web.pc.tsx +++ b/src/components/wpAccount/config/web.pc.tsx @@ -9,77 +9,88 @@ import Upsert from '../upsert'; import WpProductConfig from '../../wpProduct/config'; import { OakAttrNotNullException, OakException } from 'oak-domain/lib/types'; import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid'; +import { ToYuan } from 'oak-domain/lib/utils/money'; -function WpAccount(props: { - account: RowWithActions, - oakFullpath: string; +export function WpAccount(props: { + data: RowWithActions, systemId: string; t: (k: string, param?: any) => string; - onUpdate: () => void; - onRemove: () => void; + onUpdate?: () => void; + onRemove?: () => void; }) { - const { account, t, onUpdate, onRemove, oakFullpath, systemId } = props; - const { refundGapDays, mchId, enabled, price, taxLossRatio } = account; - const legalActions = account['#oakLegalActions']; + const { data: account, t, onUpdate, onRemove, systemId } = props; + const { refundGapDays, mchId, enabled, price, taxLossRatio, + refundCompensateRatio, allowWithdrawTransfer, withdrawTransferLossRatio + } = account; const [activeKey, setActiveKey] = useState("1"); - return ( - { - setActiveKey(activeKey) - }} - tabBarExtraContent={ - activeKey === "1" && <> - {legalActions.includes('update') && } - {legalActions.includes('remove') && } - - } - style={{ width: 380, height: 520 }} - items={[ - { - key: '1', - label: t('common::action.detail'), - children: ( - - {mchId} - {price} - {refundGapDays} - {taxLossRatio}% - {t(`common::${enabled}`)} - - ) - }, - { - key: '2', - label: t('wpProduct:name'), - children: ( - - ) - } - ]} - /> + const D = ( + + {mchId} + {ToYuan(price!)}{t('common::pay.scale')} + {taxLossRatio}% + {refundCompensateRatio}% + {refundGapDays} + {taxLossRatio}% + {t(`common::${allowWithdrawTransfer}`)} + {withdrawTransferLossRatio}% + {t(`common::${enabled}`)} + ); + if (onUpdate) { + return ( + { + setActiveKey(activeKey) + }} + tabBarExtraContent={ + activeKey === "1" && <> + {onUpdate && } + {onRemove && } + + } + style={{ width: 380, height: 520 }} + items={[ + { + key: '1', + label: t('common::action.detail'), + children: D, + }, + { + key: '2', + label: t('wpProduct:name'), + children: ( + + ) + } + ]} + /> + ); + } + + return D; } export default function render(props: WebComponentProps ele.$$createAt$$ as number > 1).map( (ele, idx) =>
{ + onRemove={ele['#oakLegalActions']?.includes('remove') ? () => { Modal.confirm({ title: t('confirmDelete'), content: t('areYouSure'), @@ -165,8 +175,8 @@ export default function render(props: WebComponentProps setUpsertId(ele.id!)} + } : undefined} + onUpdate={ele['#oakLegalActions']?.includes('update') ? () => setUpsertId(ele.id!) : undefined} />
) diff --git a/src/components/wpAccount/upsert/index.ts b/src/components/wpAccount/upsert/index.ts index 59045c6b..51a7e166 100644 --- a/src/components/wpAccount/upsert/index.ts +++ b/src/components/wpAccount/upsert/index.ts @@ -48,6 +48,8 @@ export default OakComponent({ price: 0, enabled: true, taxLossRatio: 0.6, + refundCompensateRatio: 100, + allowWithdrawTransfer: false, }); const { systemId } = this.props; const { data: [ wechatPay ]} = await this.features.cache.refresh('wechatPay', { diff --git a/src/components/wpAccount/upsert/locales/zh-CN.json b/src/components/wpAccount/upsert/locales/zh-CN.json index f7ce7e78..4f452ddc 100644 --- a/src/components/wpAccount/upsert/locales/zh-CN.json +++ b/src/components/wpAccount/upsert/locales/zh-CN.json @@ -9,7 +9,7 @@ "refundNotifyUrl": "endpoint", "apiV3Key": "需要登录商户后台获取", "refundGapDays": "超过这个天数后无法退款", - "allowWithdrawTransfer": "开启转账允许后,提现时用户即可选择从此商户号提现到微信零钱,帐户需要开启此项能力", + "allowWithdrawTransfer": "开启转账允许后,提现时用户即可选择从此商户号提现到微信零钱,微信商户必须要开启此项能力(当前尚未实现)", "withdrawTransferLossRatio": "渠道转账(提现)时收取的手续费百分比,0.6代表千分之六" }, "wechatPayIsShared": "以上配置是全局的,请谨慎修改" diff --git a/src/data/i18n.ts b/src/data/i18n.ts index fb29a899..989a13ed 100644 --- a/src/data/i18n.ts +++ b/src/data/i18n.ts @@ -331,6 +331,19 @@ const i18ns: I18n[] = [ } } }, + { + id: "c014581e9b3508d49c8dc75b2c7f5730", + namespace: "oak-pay-business-c-sysAccount-survey", + language: "zh-CN", + module: "oak-pay-business", + position: "src/components/sysAccount/survey", + data: { + "sysAccount": "系统账户统计", + "total": "总余额", + "count": "账户个数", + "qrCode": "二维码收款" + } + }, { id: "79255be8c093dfef9765b3f367cab553", namespace: "oak-pay-business-c-wechatPay-upsert", @@ -527,7 +540,7 @@ const i18ns: I18n[] = [ "refundNotifyUrl": "endpoint", "apiV3Key": "需要登录商户后台获取", "refundGapDays": "超过这个天数后无法退款", - "allowWithdrawTransfer": "开启转账允许后,提现时用户即可选择从此商户号提现到微信零钱,帐户需要开启此项能力", + "allowWithdrawTransfer": "开启转账允许后,提现时用户即可选择从此商户号提现到微信零钱,微信商户必须要开启此项能力(当前尚未实现)", "withdrawTransferLossRatio": "渠道转账(提现)时收取的手续费百分比,0.6代表千分之六" }, "wechatPayIsShared": "以上配置是全局的,请谨慎修改" diff --git a/src/triggers/abstract.ts b/src/triggers/abstract.ts index 40015b6e..9ceed2a8 100644 --- a/src/triggers/abstract.ts +++ b/src/triggers/abstract.ts @@ -2,15 +2,12 @@ import { CreateTriggerInTxn, RemoveTriggerInTxn, Trigger, UpdateTriggerInTxn } f import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid'; import { EntityDict } from '../oak-app-domain'; import { BRC } from '../types/RuntimeCxt'; -import { DATA_SUBSCRIBER_KEYS } from '../config/constants'; import assert from 'assert'; -import { getPayClazzAccountEntities } from '../utils/payClazz'; - // 这里一定要注意两者的先后顺序,如果有注入更多的payEntity的话 -const entities = getPayClazzAccountEntities(); +import { accountEntities } from '../checkers/abstractChecker'; const triggers: Trigger[] = [ - ...entities.filter(ele => !!ele).map( + ...accountEntities.filter(ele => !!ele).map( (entity) => [ { name: `当${entity}的帐户生成时,则生成对应的withDrawAccount`, diff --git a/src/utils/payClazz/index.ts b/src/utils/payClazz/index.ts index d1e16576..c4fdb0af 100644 --- a/src/utils/payClazz/index.ts +++ b/src/utils/payClazz/index.ts @@ -9,6 +9,7 @@ import Account from './Account'; import { WebConfig, WechatMpConfig, WechatPublicConfig } from 'oak-general-business/lib/entities/Application'; import WechatPay from './WechatPay'; import { StorageSchema } from 'oak-domain/lib/types/Storage'; +import { registerAccountEntity } from '../../checkers/abstractChecker'; type PayClazzConstructor = (applicationId: string, entityId: string, context: BRC) => Promise; @@ -141,13 +142,9 @@ export function registerPayClazzEntity() { - MODULE_USED = true; - return Object.keys(PayClazzEntityDict).map( - ele => PayClazzEntityDict[ele].accountEntity as keyof ED - ); + registerAccountEntity(def.accountEntity); }