From 8a0580a5a68831e83eb657b2358a226d77973f76 Mon Sep 17 00:00:00 2001 From: Xc Date: Thu, 13 Jun 2024 20:34:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E7=9A=84=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=92=8C=E5=90=84=E7=A7=8D=E7=BB=86=E8=8A=82=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/checkers/index.ts | 2 + src/checkers/withdrawTransfer.ts | 22 ++- src/components/sysAccount/survey/index.ts | 2 +- .../withdrawAccount/upsert/web.pc.tsx | 4 +- src/components/withdrawTransfer/list/index.ts | 48 +++++- .../withdrawTransfer/list/locales/zh-CN.json | 11 +- .../withdrawTransfer/list/web.pc.module.less | 34 +++++ .../withdrawTransfer/list/web.pc.tsx | 142 ++++++++++++++++-- src/data/i18n.ts | 20 ++- src/entities/Refund.ts | 2 +- src/entities/WithdrawTransfer.ts | 6 +- src/locales/withdraw/zh-CN.json | 9 ++ src/triggers/withdraw.ts | 3 +- src/triggers/withdrawTransfer.ts | 58 ++++--- 14 files changed, 310 insertions(+), 53 deletions(-) create mode 100644 src/components/withdrawTransfer/list/web.pc.module.less diff --git a/src/checkers/index.ts b/src/checkers/index.ts index ce8a0486..bf5aff0b 100644 --- a/src/checkers/index.ts +++ b/src/checkers/index.ts @@ -10,6 +10,7 @@ import wpProductCheckers from './wpProduct'; import abstractCheckers from './abstractChecker'; import withdrawAccounts from './withdrawAccount'; import refundCheckers from './refund'; +import withdrawTransferCheckers from './withdrawTransfer'; const checkers = [ ...refundCheckers, @@ -21,6 +22,7 @@ const checkers = [ ...applicationCheckers, ...offlineAccountCheckers, ...wpProductCheckers, + ...withdrawTransferCheckers, ] as Checker[]; export default checkers; diff --git a/src/checkers/withdrawTransfer.ts b/src/checkers/withdrawTransfer.ts index 35e45db4..a4d5a87e 100644 --- a/src/checkers/withdrawTransfer.ts +++ b/src/checkers/withdrawTransfer.ts @@ -10,9 +10,25 @@ const checkers: Checker[] = [ action: 'succeed', checker(operation, context) { const { data } = operation as EntityDict['pay']['Update']; - const { externalId } = data; - if (!externalId) { - throw new OakAttrNotNullException('pay', ['externalId']); + if (data) { + const { externalId } = data; + if (!externalId) { + throw new OakAttrNotNullException('pay', ['externalId']); + } + } + } + }, + { + entity: 'withdrawTransfer', + type: 'data', + action: 'fail', + checker(operation, context) { + const { data } = operation as EntityDict['pay']['Update']; + if (data) { + const { reason } = data; + if (!reason) { + throw new OakAttrNotNullException('pay', ['reason']); + } } } } diff --git a/src/components/sysAccount/survey/index.ts b/src/components/sysAccount/survey/index.ts index 731493bf..dabd04a2 100644 --- a/src/components/sysAccount/survey/index.ts +++ b/src/components/sysAccount/survey/index.ts @@ -130,7 +130,7 @@ export default OakComponent({ }, }, filter: { - iState: 'refunding', + iState: 'transferring', withdraw: { account: { ofSystemId: systemId, diff --git a/src/components/withdrawAccount/upsert/web.pc.tsx b/src/components/withdrawAccount/upsert/web.pc.tsx index d70f64e1..ce7a701d 100644 --- a/src/components/withdrawAccount/upsert/web.pc.tsx +++ b/src/components/withdrawAccount/upsert/web.pc.tsx @@ -39,7 +39,7 @@ export default function render(props: WebComponentProps } { - const { creator, price, loss, operator, withdrawAccount, ...rest } = ele; + const { creator, operator, withdrawAccount, ...rest } = ele; const { entity, offlineAccount } = withdrawAccount!.channel!; const channel = entity === 'offlineAccount' ? this.t(`withdraw::channel.offlineAccount.${offlineAccount?.type}`) : this.t(`withdraw::channel.${entity}`); return { ...rest, - price: ThousandCont(ToYuan(price!), 2), - loss: ThousandCont(ToYuan(loss!), 2), creatorName: creator?.name || creator?.nickname || '-', creatorMobile: creator?.mobile$user?.[0]?.mobile || '-', operatorName: operator?.name || operator?.nickname || '-', operatorMobile: operator?.mobile$user?.[0]?.mobile || '-', + withdrawAccount, channel, }; } ), }; }, + data: { + updateId: '', + sysAccountAmount: 0, + }, filters: [ { filter() { @@ -81,4 +90,35 @@ export default OakComponent({ } } ], + methods: { + async setUpdateId(id: string, action: string) { + this.clean(); + this.setState({ + updateId: id, + }); + if (id) { + this.updateItem({}, id, action); + + const row = (this.state.transfers as EntityDict['withdrawTransfer']['Schema'][]).find( + ele => ele.id === id + ); + + // 每次都刷新这个系统账户当前余额吧 + const { entity, entityId } = row!.withdrawAccount!.channel; + const { data: [sysAccount] } = await this.features.cache.refresh(entity as 'offlineAccount', { + data: { + id: 1, + price: 1, + }, + filter: { + id: entityId, + } + }); + assert(sysAccount); + this.setState({ + sysAccountAmount: sysAccount.price!, + }); + } + } + } }) \ No newline at end of file diff --git a/src/components/withdrawTransfer/list/locales/zh-CN.json b/src/components/withdrawTransfer/list/locales/zh-CN.json index f92588ed..84ff04c8 100644 --- a/src/components/withdrawTransfer/list/locales/zh-CN.json +++ b/src/components/withdrawTransfer/list/locales/zh-CN.json @@ -1,7 +1,10 @@ { "label": { - "cn": "创建人", - "on": "操作者", - "channel": "提现渠道" - } + "channel": "提现渠道", + "transferActualPrice": "实际转账金额", + "sysAccountAmount": "系统账户余额", + "cn": "创建者", + "on": "操作者" + }, + "saNotEnough": "系统中此账户的余额不足,请及时同步数据和实际账户一致" } \ No newline at end of file diff --git a/src/components/withdrawTransfer/list/web.pc.module.less b/src/components/withdrawTransfer/list/web.pc.module.less new file mode 100644 index 00000000..80394527 --- /dev/null +++ b/src/components/withdrawTransfer/list/web.pc.module.less @@ -0,0 +1,34 @@ +.spCon { + display: flex; + flex-direction: column; + align-items: center; + padding: 18px; + + .btn { + margin-top: 13px; + align-self: flex-end; + } +} + +.entityDetail { + font-size: small; + color: var(--oak-color-primary); +} + +.title { + font-size: large; + font-weight: bold; + color: var(--oak-color-primary); + padding: 4px; +} + +.warning { + font-weight: bold; + color: red; +} + +.actualPrice { + font-weight: bold; + color: var(--oak-color-primary); + text-decoration: underline; +} \ No newline at end of file diff --git a/src/components/withdrawTransfer/list/web.pc.tsx b/src/components/withdrawTransfer/list/web.pc.tsx index e16e0282..b0fa4889 100644 --- a/src/components/withdrawTransfer/list/web.pc.tsx +++ b/src/components/withdrawTransfer/list/web.pc.tsx @@ -6,22 +6,29 @@ import Styles from './web.pc.module.less'; import classNames from 'classnames'; import ListPro from 'oak-frontend-base/es/components/listPro'; import { FilterPanel } from '../../../components/AbstractComponents'; -import { ToYuan } from 'oak-domain/lib/utils/money'; +import { ThousandCont, ToYuan } from 'oak-domain/lib/utils/money'; import dayJs from 'dayjs'; +import assert from 'assert'; export default function Render(props: WebComponentProps & { + transfers?: (RowWithActions & { creatorName: string; creatorMobile: string; operatorName: string; operatorMobile: string; channel: string; })[]; + updateId: string; + sysAccountAmount: number; +}, { + setUpdateId: (id: string, action: string) => void; }>) { - const { refunds, oakFullpath } = props.data; - const { t } = props.methods; + const { transfers, oakFullpath, oakExecutable, updateId, sysAccountAmount } = props.data; + const { t, updateItem, execute, clean, setMessage, setUpdateId } = props.methods; - if (refunds) { + const [updateAction, setUpdateAction] = useState(''); + if (transfers) { + const updateRow = updateId && transfers.find(ele => ele.id === updateId); return (
{ + return `${t('common::pay.symbol')} ${ThousandCont(ToYuan(row!.price), 2)}` + } }, { path: 'loss', - label: t('order:attr.loss'), + label: t('withdrawTransfer:attr.loss'), width: 100, + render: (row) => { + return `${t('common::pay.symbol')} ${ThousandCont(ToYuan(row!.loss), 2)}` + } }, { path: 'iState', width: 80, - label: t('order:attr.iState'), + label: t('withdrawTransfer:attr.iState'), }, { path: '$$createAt$$', @@ -97,16 +110,123 @@ export default function Render(props: WebComponentProps { + setUpdateId(row.id, action); + setUpdateAction(action); + }} /> + {updateRow && { + setUpdateId('', ''); + setUpdateAction(''); + }} + onOk={async () => { + await execute(); + setUpdateId('', ''); + setUpdateAction(''); + }} + destroyOnClose + closeIcon={null} + okText={t('common::confirm')} + cancelText={t('common::action.cancel')} + okButtonProps={{ + disabled: oakExecutable !== true, + }} + > +
+ + {updateRow!.channel} + + {updateRow.withdrawAccount?.org && + {updateRow!.withdrawAccount?.org} + } + {updateRow.withdrawAccount?.name && + {updateRow!.withdrawAccount?.name} + } + {updateRow.withdrawAccount?.code && + {updateRow!.withdrawAccount?.code} + } + {t('saNotEnough')} : + undefined + } + > + + {`${t('common::pay.symbol')} ${ThousandCont(ToYuan(sysAccountAmount), 2)}`} + + + + + {`${t('common::pay.symbol')} ${ThousandCont(ToYuan(updateRow!.price! - updateRow.loss!), 2)}`} + + + { + updateAction === 'succeed' && ( + + { + const { value } = currentTarget; + updateItem({ + externalId: value, + }, updateId); + }} + /> + + ) + } + { + updateAction === 'fail' && ( + + { + const { value } = currentTarget; + updateItem({ + reason: value, + }, updateId); + }} + /> + + ) + } +
+
}
); } diff --git a/src/data/i18n.ts b/src/data/i18n.ts index 2283efb4..3351be1f 100644 --- a/src/data/i18n.ts +++ b/src/data/i18n.ts @@ -572,10 +572,13 @@ const i18ns: I18n[] = [ position: "src/components/withdrawTransfer/list", data: { "label": { - "cn": "创建人", - "on": "操作者", - "channel": "提现渠道" - } + "channel": "提现渠道", + "transferActualPrice": "实际转账金额", + "sysAccountAmount": "系统账户余额", + "cn": "创建者", + "on": "操作者" + }, + "saNotEnough": "系统中此账户的余额不足,请及时同步数据和实际账户一致" } }, { @@ -813,6 +816,15 @@ const i18ns: I18n[] = [ "others": "其它渠道" }, "wpAccount": "微信支付(到零钱)" + }, + "account": { + "bank": { + "org": "银行及所属支行", + "name": "户主姓名" + }, + "others": { + "name": "收款人真实姓名" + } } } } diff --git a/src/entities/Refund.ts b/src/entities/Refund.ts index 9509fffc..e88b2077 100644 --- a/src/entities/Refund.ts +++ b/src/entities/Refund.ts @@ -49,7 +49,7 @@ export const entityDesc: EntityDesc[] = [ ] return 1; }, - } as CreateTriggerInTxn, - + } as CreateTriggerInTxn, { name: '当withdraw失败时,将total和avail还回到帐户', entity: 'withdraw', diff --git a/src/triggers/withdrawTransfer.ts b/src/triggers/withdrawTransfer.ts index 600c5442..c7dc7c99 100644 --- a/src/triggers/withdrawTransfer.ts +++ b/src/triggers/withdrawTransfer.ts @@ -60,9 +60,7 @@ const triggers: Trigger[] = [ }, {}); cnt ++; - if (tax) { - // 如果转账有手续费,由system的account来承受 - assert(tax > 0); + if (tax || loss) { const systemId = withdrawAccount!.ofSystemId!; const [account] = await context.select('account', { data: { @@ -73,22 +71,46 @@ const triggers: Trigger[] = [ entityId: systemId, } }, { dontCollect: true }); - - await context.operate('accountOper', { - id: await generateNewIdAsync(), - action: 'create', - data: { + + if (loss) { + // loss也进system account的账户 + await context.operate('accountOper', { id: await generateNewIdAsync(), - accountId: account!.id, - type: 'tax', - totalPlus: -tax, - availPlus: -tax, - entity: 'withdrawTransfer', - entityId: transfer.id!, - }, - }, {}); - - cnt++; + action: 'create', + data: { + id: await generateNewIdAsync(), + accountId: account!.id, + type: 'earn', + totalPlus: loss, + availPlus: loss, + entity: 'withdrawTransfer', + entityId: transfer.id!, + }, + }, {}); + + cnt++; + } + + if (tax) { + // 如果转账有手续费,由system的account来承受 + assert(tax > 0); + + await context.operate('accountOper', { + id: await generateNewIdAsync(), + action: 'create', + data: { + id: await generateNewIdAsync(), + accountId: account!.id, + type: 'tax', + totalPlus: -tax, + availPlus: -tax, + entity: 'withdrawTransfer', + entityId: transfer.id!, + }, + }, {}); + + cnt++; + } } }