oak-pay-business 2.0.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/es/checkers/order.js +5 -1
  2. package/es/components/account/detail/index.d.ts +1 -0
  3. package/es/components/account/detail/index.js +4 -0
  4. package/es/components/account/detail/index.xml +6 -1
  5. package/es/components/account/detail/web.d.ts +1 -0
  6. package/es/components/account/detail/web.js +4 -2
  7. package/es/components/account/detail/web.pc.d.ts +1 -0
  8. package/es/components/account/detail/web.pc.js +1 -1
  9. package/es/components/accountOper/list/index.d.ts +3 -2
  10. package/es/components/accountOper/list/index.js +41 -1
  11. package/es/components/accountOper/list/mobile.module.less +7 -0
  12. package/es/components/accountOper/list/web.d.ts +11 -3
  13. package/es/components/accountOper/list/web.js +27 -3
  14. package/es/components/accountOper/list/web.pc.d.ts +10 -3
  15. package/es/components/accountOper/list/web.pc.js +7 -1
  16. package/es/components/accountOper/pure/List.pc.js +1 -1
  17. package/es/components/pay/detail/web.d.ts +2 -2
  18. package/es/components/pay/detail/web.js +7 -4
  19. package/es/components/pay/detail/web.pc.d.ts +2 -2
  20. package/es/components/pay/detail/web.pc.js +7 -4
  21. package/es/components/pay/list/web.pc.d.ts +1 -1
  22. package/es/components/pay/list/web.pc.js +4 -4
  23. package/es/context/BackendRuntimeContext.d.ts +1 -1
  24. package/es/context/BackendRuntimeContext.js +1 -1
  25. package/es/context/FrontendRuntimeContext.d.ts +1 -1
  26. package/es/context/FrontendRuntimeContext.js +1 -1
  27. package/es/data/actionAuth.js +1 -1
  28. package/es/entities/AccountOper.d.ts +3 -0
  29. package/es/entities/AccountOper.js +4 -1
  30. package/es/features/Pay.js +19 -1
  31. package/es/features/index.d.ts +1 -1
  32. package/es/index.d.ts +0 -3
  33. package/es/index.js +0 -2
  34. package/es/oak-app-domain/AccountOper/Schema.d.ts +18 -0
  35. package/es/oak-app-domain/AccountOper/Storage.js +12 -0
  36. package/es/oak-app-domain/AccountOper/locales/zh_CN.json +1 -1
  37. package/es/oak-app-domain/Refund/locales/zh_CN.json +1 -1
  38. package/es/oak-app-domain/WithdrawTransfer/locales/zh_CN.json +1 -1
  39. package/es/triggers/accountOper.js +12 -9
  40. package/es/utils/pay.d.ts +0 -10
  41. package/es/utils/pay.js +0 -26
  42. package/lib/checkers/order.js +5 -1
  43. package/lib/context/BackendRuntimeContext.d.ts +1 -1
  44. package/lib/context/BackendRuntimeContext.js +2 -2
  45. package/lib/context/FrontendRuntimeContext.d.ts +1 -1
  46. package/lib/context/FrontendRuntimeContext.js +2 -2
  47. package/lib/data/actionAuth.js +1 -1
  48. package/lib/entities/AccountOper.d.ts +3 -0
  49. package/lib/entities/AccountOper.js +4 -1
  50. package/lib/features/Pay.js +20 -2
  51. package/lib/features/index.d.ts +1 -1
  52. package/lib/index.d.ts +0 -3
  53. package/lib/index.js +0 -5
  54. package/lib/oak-app-domain/AccountOper/Schema.d.ts +18 -0
  55. package/lib/oak-app-domain/AccountOper/Storage.js +12 -0
  56. package/lib/oak-app-domain/AccountOper/locales/zh_CN.json +1 -1
  57. package/lib/oak-app-domain/Refund/locales/zh_CN.json +1 -1
  58. package/lib/oak-app-domain/WithdrawTransfer/locales/zh_CN.json +1 -1
  59. package/lib/triggers/accountOper.js +12 -9
  60. package/lib/utils/pay.d.ts +0 -10
  61. package/lib/utils/pay.js +1 -28
  62. package/package.json +4 -4
  63. package/src/entities/AccountOper.ts +7 -1
  64. package/es/aspects/account.d.ts +0 -5
  65. package/es/aspects/account.js +0 -4
  66. package/es/aspects/sample.d.ts +0 -2
  67. package/es/aspects/sample.js +0 -3
  68. package/es/components/offlineAccount/index.d.ts +0 -3
  69. package/es/components/offlineAccount/index.js +0 -17
  70. package/es/components/offlineAccount/index.json +0 -1
  71. package/es/components/offlineAccount/locales/zh-CN.json +0 -3
  72. package/es/components/offlineAccount/web.pc.d.ts +0 -6
  73. package/es/components/offlineAccount/web.pc.js +0 -27
  74. package/es/components/pay/channelPicker/index.d.ts +0 -23
  75. package/es/components/pay/channelPicker/index.js +0 -47
  76. package/es/components/pay/channelPicker/index.json +0 -8
  77. package/es/components/pay/channelPicker/index.less +0 -31
  78. package/es/components/pay/channelPicker/index.xml +0 -36
  79. package/es/components/pay/channelPicker/locales/zh-CN.json +0 -6
  80. package/es/components/pay/channelPicker/web.d.ts +0 -14
  81. package/es/components/pay/channelPicker/web.js +0 -49
  82. package/es/components/pay/channelPicker/web.mobile.module.less +0 -8
  83. package/es/components/pay/channelPicker/web.pc.d.ts +0 -12
  84. package/es/components/pay/channelPicker/web.pc.js +0 -54
  85. package/es/components/pay/channelPicker/web.pc.module.less +0 -7
  86. package/es/config/connector.d.ts +0 -5
  87. package/es/config/connector.js +0 -5
  88. package/es/context/DependentContext.d.ts +0 -1
  89. package/es/context/DependentContext.js +0 -1
  90. package/es/entities/Application.d.ts +0 -5
  91. package/es/entities/Application.js +0 -38
  92. package/es/exceptionHandler.d.ts +0 -8
  93. package/es/exceptionHandler.js +0 -47
  94. package/es/features/Console.d.ts +0 -12
  95. package/es/features/Console.js +0 -15
  96. package/es/features/Menu.d.ts +0 -20
  97. package/es/features/Menu.js +0 -62
  98. package/es/features/Sample.d.ts +0 -15
  99. package/es/features/Sample.js +0 -14
  100. package/es/triggers/acount.d.ts +0 -5
  101. package/es/triggers/acount.js +0 -20
  102. package/lib/aspects/account.d.ts +0 -5
  103. package/lib/aspects/account.js +0 -8
  104. package/lib/context/DependentContext.d.ts +0 -1
  105. package/lib/context/DependentContext.js +0 -6
@@ -13,7 +13,11 @@ const checkers = [
13
13
  data.paid = 0;
14
14
  data.refunded = 0;
15
15
  data.settled = false;
16
- data.systemId = context.getApplication()?.systemId;
16
+ if (!data.systemId) {
17
+ const contextSystemId = context.getApplication()?.systemId;
18
+ assert(contextSystemId);
19
+ data.systemId = contextSystemId;
20
+ }
17
21
  }
18
22
  },
19
23
  {
@@ -7,5 +7,6 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
7
7
  priceColor: string;
8
8
  bgColor: string;
9
9
  preWithdraw: () => boolean;
10
+ onGoToHistory: () => void;
10
11
  }>) => React.ReactElement;
11
12
  export default _default;
@@ -59,6 +59,7 @@ export default OakComponent({
59
59
  priceColor: '#8A6321',
60
60
  bgColor: '#EAD8BC',
61
61
  preWithdraw: () => true,
62
+ onGoToHistory: () => undefined,
62
63
  },
63
64
  formData({ data }) {
64
65
  const unfinishedDepositId = data?.deposit$account?.[0]?.id;
@@ -203,6 +204,9 @@ export default OakComponent({
203
204
  },
204
205
  onWithdrawClick() {
205
206
  this.props.onWithdraw();
207
+ },
208
+ gotoHistoryMp() {
209
+ this.props.onGoToHistory();
206
210
  }
207
211
  },
208
212
  data: {
@@ -1,6 +1,11 @@
1
1
  <view class="container">
2
2
  <view class="info" style="background-color:{{bgColor}};color:{{textColor}};">
3
- <view class="top label">{{t('history')}}</view>
3
+ <view
4
+ class="top label"
5
+ bind:tap="gotoHistoryMp"
6
+ >
7
+ {{t('history')}}
8
+ </view>
4
9
  <view class="middle">
5
10
  <view class="box fortify">
6
11
  <view class="label">{{t('avail')}}{{t('yuan')}}</view>
@@ -29,4 +29,5 @@ export default function Render(props: WebComponentProps<EntityDict, 'account', f
29
29
  onDepositClick: () => void;
30
30
  onDepositModalClose: () => void;
31
31
  onUnfinishedDepositClick: () => void;
32
+ onGoToHistory: () => void;
32
33
  }>): React.JSX.Element | null;
@@ -6,12 +6,14 @@ import { CentToString } from 'oak-domain/lib/utils/money';
6
6
  import NewDeposit from '../../deposit/new';
7
7
  export default function Render(props) {
8
8
  const { account, depositMaxCent, newDepositPath, depositOpen, depositMinCent, ufOpen, depPrice, depositChannel, depositLoss, depositing, onWithdraw, textColor, priceColor, bgColor, } = props.data;
9
- const { t, newDeposit, setMessage, setDepositOpen, setUfOpen, setDepPrice, setDepositChannel, onUnfinishedDepositClick, setDepositing, onDepositClick, onDepositModalClose, } = props.methods;
9
+ const { t, newDeposit, setMessage, setDepositOpen, setUfOpen, setDepPrice, setDepositChannel, onUnfinishedDepositClick, setDepositing, onDepositClick, onDepositModalClose, onGoToHistory, } = props.methods;
10
10
  if (account) {
11
11
  const { total, avail, '#oakLegalActions': legalActions, accountOper$account: opers } = account;
12
12
  return (<div className={Styles.container}>
13
13
  <div className={Styles.info} style={{ backgroundColor: bgColor, color: textColor }}>
14
- <div className={classNames(Styles.top, Styles.label)}>{t('history')}</div>
14
+ <div className={classNames(Styles.top, Styles.label)} onClick={onGoToHistory}>
15
+ {t('history')}
16
+ </div>
15
17
  <div className={Styles.middle}>
16
18
  <div className={classNames(Styles.box, Styles.fortify)}>
17
19
  <div className={Styles.label}>{t('avail')}{t('yuan')}</div>
@@ -26,4 +26,5 @@ export default function Render(props: WebComponentProps<EntityDict, 'account', f
26
26
  onDepositClick: () => void;
27
27
  onDepositModalClose: () => void;
28
28
  onUnfinishedDepositClick: () => void;
29
+ onGoToHistory: () => void;
29
30
  }>): React.JSX.Element | null;
@@ -8,7 +8,7 @@ import AccountOperList from '../../accountOper/pure/List.pc';
8
8
  import { AccountBookOutlined, ScheduleOutlined } from '@ant-design/icons';
9
9
  export default function Render(props) {
10
10
  const { account, depositMaxCent, newDepositPath, depositOpen, depositMinCent, ufOpen, depPrice, depositChannel, depositLoss, depositing, onWithdraw, } = props.data;
11
- const { t, newDeposit, setMessage, setDepositOpen, setUfOpen, setDepPrice, setDepositChannel, onUnfinishedDepositClick, setDepositing, onDepositClick, onDepositModalClose, } = props.methods;
11
+ const { t, newDeposit, setMessage, setDepositOpen, setUfOpen, setDepPrice, setDepositChannel, onUnfinishedDepositClick, setDepositing, onDepositClick, onDepositModalClose, onGoToHistory, } = props.methods;
12
12
  if (account) {
13
13
  const { total, avail, '#oakLegalActions': legalActions, accountOper$account: opers } = account;
14
14
  return (<>
@@ -1,3 +1,4 @@
1
- /// <reference types="wechat-miniprogram" />
2
- declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "accountOper", true, WechatMiniprogram.Component.DataOption>) => React.ReactElement;
1
+ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "accountOper", true, {
2
+ accountId: string;
3
+ }>) => React.ReactElement;
3
4
  export default _default;
@@ -1,3 +1,5 @@
1
+ import dayjs from 'dayjs';
2
+ import { ToYuan, ThousandCont } from "oak-domain/lib/utils/money";
1
3
  export default OakComponent({
2
4
  entity: 'accountOper',
3
5
  isList: true,
@@ -8,9 +10,47 @@ export default OakComponent({
8
10
  availPlus: 1,
9
11
  $$createAt$$: 1,
10
12
  },
13
+ properties: {
14
+ accountId: '',
15
+ },
16
+ filters: [
17
+ {
18
+ filter() {
19
+ const { accountId } = this.props;
20
+ return {
21
+ accountId,
22
+ avail: {
23
+ $ne: 0,
24
+ },
25
+ };
26
+ }
27
+ }
28
+ ],
11
29
  formData({ data }) {
30
+ const pagi = this.getPagination();
31
+ const hasMore = !!pagi?.more;
12
32
  return {
13
- accountOpers: data,
33
+ hasMore,
34
+ accountOpers: data.map((oper) => {
35
+ const { $$createAt$$, type, availPlus, avail } = oper;
36
+ const num = Math.abs(availPlus);
37
+ const plus = ThousandCont(ToYuan(num), 2);
38
+ const sign = availPlus > 0 ? '+' : '-';
39
+ const time = dayjs($$createAt$$).format('YYYY-MM-DD HH:mm');
40
+ const symbol = this.t(`accountOper:v.type.${type}`)[0];
41
+ return {
42
+ value: `${sign}${plus}`,
43
+ time,
44
+ type,
45
+ symbol,
46
+ avail: ThousandCont(ToYuan(avail), 2)
47
+ };
48
+ }),
14
49
  };
50
+ },
51
+ methods: {
52
+ loadMoreMp() {
53
+ return this.loadMore();
54
+ }
15
55
  }
16
56
  });
@@ -0,0 +1,7 @@
1
+ .container {
2
+ display: flex;
3
+ width: 100%;
4
+ min-height: 100%;
5
+ flex-direction: column;
6
+ align-items: stretch;
7
+ }
@@ -1,5 +1,13 @@
1
- import { RowWithActions, WebComponentProps } from 'oak-frontend-base';
1
+ import React from 'react';
2
+ import { WebComponentProps } from 'oak-frontend-base';
2
3
  import { EntityDict } from '../../../oak-app-domain';
3
4
  export default function Render(props: WebComponentProps<EntityDict, 'accountOper', false, {
4
- accountOpers: RowWithActions<EntityDict, 'accountOper'>[];
5
- }>): string;
5
+ accountOpers?: Array<{
6
+ value: string;
7
+ time: string;
8
+ type: string;
9
+ symbol: string;
10
+ avail: string;
11
+ }>;
12
+ hasMore: boolean;
13
+ }>): React.JSX.Element | null;
@@ -1,5 +1,29 @@
1
+ import React from 'react';
2
+ import { List, InfiniteScroll, Space } from 'antd-mobile';
3
+ import Styles from './mobile.module.less';
1
4
  export default function Render(props) {
2
- const { accountOpers } = props.data;
3
- const { t } = props.methods;
4
- return '还没有实现,todo';
5
+ const { accountOpers, hasMore } = props.data;
6
+ const { t, loadMore } = props.methods;
7
+ if (accountOpers?.length) {
8
+ return (<div className={Styles.container}>
9
+ <List>
10
+ {accountOpers.map((oper, idx) => {
11
+ const { value, time, type, symbol, avail } = oper;
12
+ return (<List.Item key={idx} prefix={<div className={Styles.symbol}>
13
+ {symbol}
14
+ </div>} description={<Space direction="horizontal" justify="between">
15
+ <span>{time}</span>
16
+ <span>{t('accountOper:attr.avail')}:{avail}</span>
17
+ </Space>}>
18
+ <Space direction="horizontal" justify="between">
19
+ <span>{type}</span>
20
+ <span>{value}</span>
21
+ </Space>
22
+ </List.Item>);
23
+ })}
24
+ </List>
25
+ <InfiniteScroll hasMore={hasMore} loadMore={loadMore}/>
26
+ </div>);
27
+ }
28
+ return null;
5
29
  }
@@ -1,5 +1,12 @@
1
- import { RowWithActions, WebComponentProps } from 'oak-frontend-base';
1
+ import React from 'react';
2
+ import { WebComponentProps } from 'oak-frontend-base';
2
3
  import { EntityDict } from '../../../oak-app-domain';
3
4
  export default function Render(props: WebComponentProps<EntityDict, 'accountOper', false, {
4
- accountOpers: RowWithActions<EntityDict, 'accountOper'>[];
5
- }>): string;
5
+ accountOpers?: Array<{
6
+ value: string;
7
+ time: string;
8
+ type: string;
9
+ symbol: string;
10
+ avail: string;
11
+ }>;
12
+ }>): React.JSX.Element | undefined;
@@ -1,5 +1,11 @@
1
+ import React from 'react';
2
+ import { List, Flex } from 'antd';
1
3
  export default function Render(props) {
2
4
  const { accountOpers } = props.data;
3
5
  const { t } = props.methods;
4
- return '还没有实现,利用pure/List渲染,要支持滚动加载 todo';
6
+ if (accountOpers?.length) {
7
+ return (<Flex vertical>
8
+ <List dataSource={accountOpers}/>
9
+ </Flex>);
10
+ }
5
11
  }
@@ -6,7 +6,7 @@ export default function Render(props) {
6
6
  return (<List itemLayout="horizontal" dataSource={accountOpers} renderItem={(item, index) => {
7
7
  const { $$createAt$$, type, totalPlus, availPlus } = item;
8
8
  const plus = ToYuan(totalPlus || availPlus);
9
- const sign = plus > 0 ? '+' : '-';
9
+ const sign = plus >= 0 ? '+' : '-';
10
10
  const num = Math.abs(plus);
11
11
  const d = dayjs($$createAt$$);
12
12
  return (<List.Item key={index}>
@@ -19,8 +19,8 @@ export default function Render(props: WebComponentProps<EntityDict, 'pay', false
19
19
  startPayable: boolean;
20
20
  notSameApp?: boolean;
21
21
  type: string;
22
- offlines: ColoredOffline[];
23
- offline: ColoredOffline;
22
+ offlines?: ColoredOffline[];
23
+ offline?: ColoredOffline;
24
24
  }, {
25
25
  goBack: () => void;
26
26
  startPay: () => Promise<void>;
@@ -128,10 +128,13 @@ function RenderPayMeta(props) {
128
128
  }
129
129
  switch (entity) {
130
130
  case 'offlineAccount': {
131
- return (<>
132
- {iState === 'paying' && <Alert type='info' message={t('code.help')} style={{ marginBottom: 10 }}/>}
133
- <RenderOffline t={t} pay={pay} offline={offline} offlines={offlines} updateOfflineId={updateOfflineId}/>
134
- </>);
131
+ if (offline && offlines) {
132
+ return (<>
133
+ {iState === 'paying' && <Alert type='info' message={t('code.help')} style={{ marginBottom: 10 }}/>}
134
+ <RenderOffline t={t} pay={pay} offline={offline} offlines={offlines} updateOfflineId={updateOfflineId}/>
135
+ </>);
136
+ }
137
+ return null;
135
138
  }
136
139
  case 'wpProduct': {
137
140
  return <RenderWechatPay pay={pay} t={t}/>;
@@ -19,8 +19,8 @@ export default function Render(props: WebComponentProps<EntityDict, 'pay', false
19
19
  startPayable: boolean;
20
20
  notSameApp?: boolean;
21
21
  type: string;
22
- offlines: ColoredOffline[];
23
- offline: ColoredOffline;
22
+ offlines?: ColoredOffline[];
23
+ offline?: ColoredOffline;
24
24
  }, {
25
25
  goBack: () => void;
26
26
  startPay: () => Promise<void>;
@@ -130,10 +130,13 @@ function RenderPayMeta(props) {
130
130
  }
131
131
  switch (entity) {
132
132
  case 'offlineAccount': {
133
- return (<>
134
- {iState === 'paying' && <Alert type='info' message={t('code.help')} style={{ marginBottom: 10 }}/>}
135
- <RenderOffline t={t} pay={pay} offline={offline} offlines={offlines} updateOfflineId={updateOfflineId}/>
136
- </>);
133
+ if (offline && offlines) {
134
+ return (<>
135
+ {iState === 'paying' && <Alert type='info' message={t('code.help')} style={{ marginBottom: 10 }}/>}
136
+ <RenderOffline t={t} pay={pay} offline={offline} offlines={offlines} updateOfflineId={updateOfflineId}/>
137
+ </>);
138
+ }
139
+ return null;
137
140
  }
138
141
  case 'wpProduct': {
139
142
  return <RenderWechatPay pay={pay} t={t}/>;
@@ -9,6 +9,6 @@ export default function Render(props: WebComponentProps<EntityDict, 'pay', false
9
9
  creatorName: string;
10
10
  creatorMobile?: string;
11
11
  })[];
12
- offlines: ColoredOffline[];
12
+ offlines?: ColoredOffline[];
13
13
  }>): React.JSX.Element | null;
14
14
  export {};
@@ -143,10 +143,10 @@ export default function Render(props) {
143
143
  <div className={Styles.spCon}>
144
144
  <Alert type="warning" message={t('csp.tips')}/>
145
145
  <Divider style={{ width: '80%', alignSelf: 'flex-end' }}/>
146
- <RenderOffline pay={spRow} t={t} offlines={offlines} offline={offlines.find(ele => ele.id === spRow.entityId)} updateOfflineId={(entityId) => updateItem({
147
- entity: 'offlineAccount',
148
- entityId
149
- }, spId)}/>
146
+ {offlines && <RenderOffline pay={spRow} t={t} offlines={offlines} offline={offlines.find(ele => ele.id === spRow.entityId)} updateOfflineId={(entityId) => updateItem({
147
+ entity: 'offlineAccount',
148
+ entityId
149
+ }, spId)}/>}
150
150
  <Divider style={{ width: '80%', alignSelf: 'flex-end' }}/>
151
151
  <Form labelCol={{ span: 8 }} wrapperCol={{ span: 12 }} layout="horizontal" style={{ width: '100%', marginTop: 12 }}>
152
152
  <Form.Item label={t('pay:attr.price')}>
@@ -1,7 +1,7 @@
1
1
  import { EntityDict } from '../oak-app-domain';
2
2
  import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
3
3
  import { RuntimeContext } from './RuntimeContext';
4
- import { BackendRuntimeContext as DependentBackendRuntimeContext } from './DependentContext';
4
+ import { BackendRuntimeContext as DependentBackendRuntimeContext } from 'oak-general-business/lib/context/BackendRuntimeContext';
5
5
  export declare class BackendRuntimeContext<ED extends EntityDict & BaseEntityDict> extends DependentBackendRuntimeContext<ED> implements RuntimeContext {
6
6
  protected applicationProjection: {
7
7
  [k: string]: any;
@@ -1,4 +1,4 @@
1
- import { BackendRuntimeContext as DependentBackendRuntimeContext } from './DependentContext';
1
+ import { BackendRuntimeContext as DependentBackendRuntimeContext } from 'oak-general-business/lib/context/BackendRuntimeContext';
2
2
  import { mergedProjection } from '../utils/application';
3
3
  export class BackendRuntimeContext extends DependentBackendRuntimeContext {
4
4
  applicationProjection = mergedProjection;
@@ -1,6 +1,6 @@
1
1
  import { EntityDict } from '../oak-app-domain';
2
2
  import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
3
- import { FrontendRuntimeContext as DependentFrontendRuntimeContext, SerializedData } from './DependentContext';
3
+ import { FrontendRuntimeContext as DependentFrontendRuntimeContext, SerializedData } from 'oak-general-business/es/context/FrontendRuntimeContext';
4
4
  import { RuntimeContext } from './RuntimeContext';
5
5
  export { SerializedData, };
6
6
  export declare class FrontendRuntimeContext<ED extends EntityDict & BaseEntityDict> extends DependentFrontendRuntimeContext<ED> implements RuntimeContext {
@@ -1,4 +1,4 @@
1
- import { FrontendRuntimeContext as DependentFrontendRuntimeContext } from './DependentContext';
1
+ import { FrontendRuntimeContext as DependentFrontendRuntimeContext } from 'oak-general-business/es/context/FrontendRuntimeContext';
2
2
  export class FrontendRuntimeContext extends DependentFrontendRuntimeContext {
3
3
  async toString() {
4
4
  const data = await this.getSerializedData();
@@ -49,7 +49,7 @@ const actionAuths = [
49
49
  {
50
50
  id: 'deposit-account-user',
51
51
  pathId: 'user-account-deposit',
52
- deActions: ['fail'],
52
+ deActions: ['fail', 'select', 'create'],
53
53
  },
54
54
  // accountOper
55
55
  {
@@ -9,6 +9,9 @@ export interface Schema extends EntityShape {
9
9
  totalPlus: Price;
10
10
  availPlus: Price;
11
11
  refundablePlus?: Price;
12
+ total: Price;
13
+ avail: Price;
14
+ refundable: Price;
12
15
  entity: String<32>;
13
16
  entityId: String<64>;
14
17
  }
@@ -9,6 +9,9 @@ export const entityDesc = {
9
9
  totalPlus: '余额变化',
10
10
  availPlus: '可用余额变化',
11
11
  refundablePlus: '可退款余额变化',
12
+ total: "操作后余额",
13
+ avail: '操作后可用余额',
14
+ refundable: '操作后可退款余额',
12
15
  entity: '关联对象',
13
16
  entityId: '关联对象Id',
14
17
  },
@@ -19,7 +22,7 @@ export const entityDesc = {
19
22
  consume: '消费',
20
23
  loan: '抵押',
21
24
  repay: '偿还',
22
- withdrawBack: '提现失败',
25
+ withdrawBack: '提现未遂',
23
26
  earn: '赚取',
24
27
  encash: '兑现',
25
28
  tax: '渠道费',
@@ -1,6 +1,24 @@
1
1
  import { Feature } from "oak-frontend-base";
2
- import { getDepositLoss } from '../utils/pay';
3
2
  import { getWpProductTypeFromEnv } from "../utils/wpProductFrontend";
3
+ function getDepositLoss(price, application) {
4
+ const { system } = application;
5
+ const { payConfig } = system;
6
+ const depositLoss = payConfig?.depositLoss;
7
+ if (depositLoss) {
8
+ const { ratio, highest, lowest } = depositLoss;
9
+ let loss = ratio && Math.round(price * ratio / 100) || 0;
10
+ if (highest && loss > highest) {
11
+ return [highest, 'common::deposit.lossReason.highest', { value: (highest / 100).toFixed(2) }];
12
+ }
13
+ if (lowest && loss < lowest) {
14
+ return [lowest, 'common::deposit.lossReason.lowest', { value: (lowest / 100).toFixed(2) }];
15
+ }
16
+ if (loss > 0) {
17
+ return [loss, 'common::deposit.lossReason.ratio', { value: ratio }];
18
+ }
19
+ }
20
+ return [0, '', undefined];
21
+ }
4
22
  export default class Pay extends Feature {
5
23
  application;
6
24
  locales;
@@ -2,7 +2,7 @@ import { EntityDict } from '../oak-app-domain';
2
2
  import { AccessConfiguration } from 'oak-domain/lib/types/Configuration';
3
3
  import { BasicFeatures } from 'oak-frontend-base';
4
4
  import { FeatureDict as Ogb0FeatureDict } from "oak-general-business";
5
- import Cos from 'oak-general-business/es/types/Cos';
5
+ import { Cos } from 'oak-general-business/es/types/Cos';
6
6
  import Pay from './Pay';
7
7
  export declare function create<ED extends EntityDict>(features: BasicFeatures<ED> & Ogb0FeatureDict<ED>): {
8
8
  pay: Pay;
package/es/index.d.ts CHANGED
@@ -2,6 +2,3 @@ export type { FeatureDict } from './features';
2
2
  export type { AspectDict } from './aspects/AspectDict';
3
3
  export * from './types/Exception';
4
4
  export * from './types/RuntimeCxt';
5
- export { BackendRuntimeContext } from './context/BackendRuntimeContext';
6
- export { FrontendRuntimeContext, SerializedData, } from './context/FrontendRuntimeContext';
7
- export { RuntimeContext } from './context/RuntimeContext';
package/es/index.js CHANGED
@@ -1,4 +1,2 @@
1
1
  export * from './types/Exception';
2
2
  export * from './types/RuntimeCxt';
3
- export { BackendRuntimeContext } from './context/BackendRuntimeContext';
4
- export { FrontendRuntimeContext, } from './context/FrontendRuntimeContext';
@@ -18,6 +18,9 @@ export type OpSchema = EntityShape & {
18
18
  totalPlus: Price;
19
19
  availPlus: Price;
20
20
  refundablePlus?: Price | null;
21
+ total: Price;
22
+ avail: Price;
23
+ refundable: Price;
21
24
  entity: "deposit" | "order" | "pay" | "refund" | "withdraw" | "withdrawTransfer" | string;
22
25
  entityId: String<64>;
23
26
  };
@@ -28,6 +31,9 @@ export type Schema = EntityShape & {
28
31
  totalPlus: Price;
29
32
  availPlus: Price;
30
33
  refundablePlus?: Price | null;
34
+ total: Price;
35
+ avail: Price;
36
+ refundable: Price;
31
37
  entity: "deposit" | "order" | "pay" | "refund" | "withdraw" | "withdrawTransfer" | string;
32
38
  entityId: String<64>;
33
39
  account: Account.Schema;
@@ -51,6 +57,9 @@ type AttrFilter = {
51
57
  totalPlus: Q_NumberValue;
52
58
  availPlus: Q_NumberValue;
53
59
  refundablePlus: Q_NumberValue;
60
+ total: Q_NumberValue;
61
+ avail: Q_NumberValue;
62
+ refundable: Q_NumberValue;
54
63
  entity: Q_EnumValue<"deposit" | "order" | "pay" | "refund" | "withdraw" | "withdrawTransfer" | string>;
55
64
  entityId: Q_StringValue;
56
65
  deposit: Deposit.Filter;
@@ -74,6 +83,9 @@ export type Projection = {
74
83
  totalPlus?: number;
75
84
  availPlus?: number;
76
85
  refundablePlus?: number;
86
+ total?: number;
87
+ avail?: number;
88
+ refundable?: number;
77
89
  entity?: number;
78
90
  entityId?: number;
79
91
  deposit?: Deposit.Projection;
@@ -127,6 +139,12 @@ export type SortAttr = {
127
139
  availPlus: number;
128
140
  } | {
129
141
  refundablePlus: number;
142
+ } | {
143
+ total: number;
144
+ } | {
145
+ avail: number;
146
+ } | {
147
+ refundable: number;
130
148
  } | {
131
149
  entity: number;
132
150
  } | {
@@ -22,6 +22,18 @@ export const desc = {
22
22
  refundablePlus: {
23
23
  type: "money"
24
24
  },
25
+ total: {
26
+ notNull: true,
27
+ type: "money"
28
+ },
29
+ avail: {
30
+ notNull: true,
31
+ type: "money"
32
+ },
33
+ refundable: {
34
+ notNull: true,
35
+ type: "money"
36
+ },
25
37
  entity: {
26
38
  notNull: true,
27
39
  type: "varchar",
@@ -1 +1 @@
1
- { "name": "帐号操作", "attr": { "account": "帐号", "type": "类型", "totalPlus": "余额变化", "availPlus": "可用余额变化", "refundablePlus": "可退款余额变化", "entity": "关联对象", "entityId": "关联对象Id" }, "v": { "type": { "deposit": "充值", "withdraw": "提现", "consume": "消费", "loan": "抵押", "repay": "偿还", "withdrawBack": "提现失败", "earn": "赚取", "encash": "兑现", "tax": "渠道费", "taxRefund": "渠道费用退还", "cutoffRefundable": "削减可自由退额度", "refund": "退款", "refundFailure": "退款失败" } } }
1
+ { "name": "帐号操作", "attr": { "account": "帐号", "type": "类型", "totalPlus": "余额变化", "availPlus": "可用余额变化", "refundablePlus": "可退款余额变化", "total": "操作后余额", "avail": "操作后可用余额", "refundable": "操作后可退款余额", "entity": "关联对象", "entityId": "关联对象Id" }, "v": { "type": { "deposit": "充值", "withdraw": "提现", "consume": "消费", "loan": "抵押", "repay": "偿还", "withdrawBack": "提现失败", "earn": "赚取", "encash": "兑现", "tax": "渠道费", "taxRefund": "渠道费用退还", "cutoffRefundable": "削减可自由退额度", "refund": "退款", "refundFailure": "退款失败" } } }
@@ -1 +1 @@
1
- { "name": "帐户", "attr": { "pay": "关联支付", "price": "价格", "loss": "损耗", "withdraw": "关联提现", "meta": "metadata", "externalId": "外部ID", "iState": "状态", "creator": "创建者", "reason": "原因", "opers": "相关账户操作" }, "action": { "succeed": "退款成功", "fail": "退款失败" }, "v": { "iState": { "refunding": "退款中", "successful": "退款成功", "failed": "退款失败" } } }
1
+ { "name": "帐户", "attr": { "pay": "关联支付", "price": "价格", "loss": "损耗", "withdraw": "关联提现", "meta": "metadata", "externalId": "外部退款流水号", "iState": "状态", "creator": "创建者", "reason": "原因", "opers": "相关账户操作" }, "action": { "succeed": "退款成功", "fail": "退款失败" }, "v": { "iState": { "refunding": "退款中", "successful": "退款成功", "failed": "退款失败" } } }
@@ -1 +1 @@
1
- { "name": "提现转账", "attr": { "withdraw": "提现申请", "withdrawAccount": "提现账户", "price": "金额", "loss": "手续费", "operator": "操作者", "creator": "创建者", "iState": "状态", "externalId": "外部Id", "meta": "metadata", "reason": "原因", "sysOpers": "账户操作" }, "v": { "iState": { "transferring": "待转账", "failed": "已失败", "successful": "已成功" } }, "action": { "succeed": "提现成功", "fail": "提现失败" } }
1
+ { "name": "提现转账", "attr": { "withdraw": "提现申请", "withdrawAccount": "提现账户", "price": "金额", "loss": "手续费", "operator": "操作者", "creator": "创建者", "iState": "状态", "externalId": "外部转账流水号", "meta": "metadata", "reason": "原因", "sysOpers": "账户操作" }, "v": { "iState": { "transferring": "待转账", "failed": "已失败", "successful": "已成功" } }, "action": { "succeed": "转账成功", "fail": "转账失败" } }
@@ -7,7 +7,7 @@ const triggers = [
7
7
  name: '当生成accountOper时,修改account中的值,并向订阅者推送',
8
8
  entity: 'accountOper',
9
9
  action: 'create',
10
- when: 'after',
10
+ when: 'before',
11
11
  fn: async ({ operation }, context, option) => {
12
12
  const { id, data } = operation;
13
13
  assert(!(data instanceof Array));
@@ -33,18 +33,21 @@ const triggers = [
33
33
  throw new OakInputIllegalException('accountOper', ['availPlus'], 'withdraw::refundableOverflow');
34
34
  }
35
35
  }
36
- await context.operate('account', {
36
+ const total2 = total + totalPlus;
37
+ const avail2 = avail + availPlus;
38
+ const refundable2 = refundable + (refundablePlus || 0);
39
+ data.total = total2;
40
+ data.avail = avail2;
41
+ data.refundable = refundable2;
42
+ data.account = {
37
43
  id: await generateNewIdAsync(),
38
44
  action: type,
39
45
  data: {
40
- total: total + totalPlus,
41
- avail: avail + availPlus,
42
- refundable: refundable + (refundablePlus || 0),
46
+ total: total2,
47
+ avail: avail2,
48
+ refundable: refundable2,
43
49
  },
44
- filter: {
45
- id: accountId,
46
- }
47
- }, option);
50
+ };
48
51
  context.saveOperationToEvent(id, `${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${accountId}`);
49
52
  return 1;
50
53
  },
package/es/utils/pay.d.ts CHANGED
@@ -5,13 +5,3 @@ import BackendRuntimeContext from '../context/BackendRuntimeContext';
5
5
  import { IncomingHttpHeaders } from 'http';
6
6
  export declare const fullPayProjection: EntityDict['pay']['Selection']['data'];
7
7
  export declare function payNotify<ED extends EntityDict & BaseEntityDict>(context: BackendRuntimeContext<ED>, body: any, payId: string, headers: IncomingHttpHeaders): Promise<void>;
8
- type CalcLoss = <ED extends EntityDict & BaseEntityDict>(entityId: string, application: ED['application']['Schema'], price: number) => [number, string, any];
9
- /**
10
- * 计算充值的损耗比例
11
- * attention: 这个函数目前是在前端调用的
12
- * @param context
13
- * @param channel
14
- * @param application
15
- */
16
- export declare function getDepositLoss<ED extends EntityDict & BaseEntityDict>(price: number, application: ED['application']['Schema']): ReturnType<CalcLoss>;
17
- export {};