oak-pay-business 2.1.0 → 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 (41) 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/data/actionAuth.js +1 -1
  24. package/es/entities/AccountOper.d.ts +3 -0
  25. package/es/entities/AccountOper.js +4 -1
  26. package/es/oak-app-domain/AccountOper/Schema.d.ts +18 -0
  27. package/es/oak-app-domain/AccountOper/Storage.js +12 -0
  28. package/es/oak-app-domain/AccountOper/locales/zh_CN.json +1 -1
  29. package/es/triggers/accountOper.js +12 -9
  30. package/es/triggers/withdraw.d.ts +1 -1
  31. package/lib/checkers/order.js +5 -1
  32. package/lib/data/actionAuth.js +1 -1
  33. package/lib/entities/AccountOper.d.ts +3 -0
  34. package/lib/entities/AccountOper.js +4 -1
  35. package/lib/oak-app-domain/AccountOper/Schema.d.ts +18 -0
  36. package/lib/oak-app-domain/AccountOper/Storage.js +12 -0
  37. package/lib/oak-app-domain/AccountOper/locales/zh_CN.json +1 -1
  38. package/lib/triggers/accountOper.js +12 -9
  39. package/lib/triggers/withdraw.d.ts +1 -1
  40. package/package.json +3 -3
  41. package/src/entities/AccountOper.ts +7 -1
@@ -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')}>
@@ -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: '渠道费',
@@ -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": "退款失败" } } }
@@ -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
  },
@@ -6,6 +6,6 @@ import { BRC } from '../types/RuntimeCxt';
6
6
  * @param context
7
7
  * @param refunds
8
8
  */
9
- export declare function updateWithdrawState(context: BRC, id: string): Promise<0 | 1>;
9
+ export declare function updateWithdrawState(context: BRC, id: string): Promise<1 | 0>;
10
10
  declare const triggers: Trigger<EntityDict, 'withdraw', BRC>[];
11
11
  export default triggers;
@@ -16,7 +16,11 @@ const checkers = [
16
16
  data.paid = 0;
17
17
  data.refunded = 0;
18
18
  data.settled = false;
19
- data.systemId = context.getApplication()?.systemId;
19
+ if (!data.systemId) {
20
+ const contextSystemId = context.getApplication()?.systemId;
21
+ (0, assert_1.default)(contextSystemId);
22
+ data.systemId = contextSystemId;
23
+ }
20
24
  }
21
25
  },
22
26
  {
@@ -51,7 +51,7 @@ const actionAuths = [
51
51
  {
52
52
  id: 'deposit-account-user',
53
53
  pathId: 'user-account-deposit',
54
- deActions: ['fail'],
54
+ deActions: ['fail', 'select', 'create'],
55
55
  },
56
56
  // accountOper
57
57
  {
@@ -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
  }
@@ -12,6 +12,9 @@ exports.entityDesc = {
12
12
  totalPlus: '余额变化',
13
13
  availPlus: '可用余额变化',
14
14
  refundablePlus: '可退款余额变化',
15
+ total: "操作后余额",
16
+ avail: '操作后可用余额',
17
+ refundable: '操作后可退款余额',
15
18
  entity: '关联对象',
16
19
  entityId: '关联对象Id',
17
20
  },
@@ -22,7 +25,7 @@ exports.entityDesc = {
22
25
  consume: '消费',
23
26
  loan: '抵押',
24
27
  repay: '偿还',
25
- withdrawBack: '提现失败',
28
+ withdrawBack: '提现未遂',
26
29
  earn: '赚取',
27
30
  encash: '兑现',
28
31
  tax: '渠道费',
@@ -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
  } | {
@@ -25,6 +25,18 @@ exports.desc = {
25
25
  refundablePlus: {
26
26
  type: "money"
27
27
  },
28
+ total: {
29
+ notNull: true,
30
+ type: "money"
31
+ },
32
+ avail: {
33
+ notNull: true,
34
+ type: "money"
35
+ },
36
+ refundable: {
37
+ notNull: true,
38
+ type: "money"
39
+ },
28
40
  entity: {
29
41
  notNull: true,
30
42
  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": "退款失败" } } }
@@ -10,7 +10,7 @@ const triggers = [
10
10
  name: '当生成accountOper时,修改account中的值,并向订阅者推送',
11
11
  entity: 'accountOper',
12
12
  action: 'create',
13
- when: 'after',
13
+ when: 'before',
14
14
  fn: async ({ operation }, context, option) => {
15
15
  const { id, data } = operation;
16
16
  (0, assert_1.default)(!(data instanceof Array));
@@ -36,18 +36,21 @@ const triggers = [
36
36
  throw new types_1.OakInputIllegalException('accountOper', ['availPlus'], 'withdraw::refundableOverflow');
37
37
  }
38
38
  }
39
- await context.operate('account', {
39
+ const total2 = total + totalPlus;
40
+ const avail2 = avail + availPlus;
41
+ const refundable2 = refundable + (refundablePlus || 0);
42
+ data.total = total2;
43
+ data.avail = avail2;
44
+ data.refundable = refundable2;
45
+ data.account = {
40
46
  id: await (0, uuid_1.generateNewIdAsync)(),
41
47
  action: type,
42
48
  data: {
43
- total: total + totalPlus,
44
- avail: avail + availPlus,
45
- refundable: refundable + (refundablePlus || 0),
49
+ total: total2,
50
+ avail: avail2,
51
+ refundable: refundable2,
46
52
  },
47
- filter: {
48
- id: accountId,
49
- }
50
- }, option);
53
+ };
51
54
  context.saveOperationToEvent(id, `${constants_1.DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${accountId}`);
52
55
  return 1;
53
56
  },
@@ -6,6 +6,6 @@ import { BRC } from '../types/RuntimeCxt';
6
6
  * @param context
7
7
  * @param refunds
8
8
  */
9
- export declare function updateWithdrawState(context: BRC, id: string): Promise<0 | 1>;
9
+ export declare function updateWithdrawState(context: BRC, id: string): Promise<1 | 0>;
10
10
  declare const triggers: Trigger<EntityDict, 'withdraw', BRC>[];
11
11
  export default triggers;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-pay-business",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "",
5
5
  "files": [
6
6
  "lib/**/*",
@@ -51,8 +51,8 @@
51
51
  "lodash": "^4.17.21",
52
52
  "nprogress": "^0.2.0",
53
53
  "oak-domain": "~5.0.11",
54
- "oak-frontend-base": "~5.2.0",
55
- "oak-general-business": "~5.2.0",
54
+ "oak-frontend-base": "~5.2.1",
55
+ "oak-general-business": "~5.2.3",
56
56
  "react": "~18.2.0",
57
57
  "react-dom": "~18.2.0",
58
58
  "react-image-gallery": "^1.2.11",
@@ -18,6 +18,9 @@ export interface Schema extends EntityShape {
18
18
  totalPlus: Price;
19
19
  availPlus: Price;
20
20
  refundablePlus?: Price;
21
+ total: Price;
22
+ avail: Price;
23
+ refundable: Price;
21
24
  entity: String<32>;
22
25
  entityId: String<64>;
23
26
  };
@@ -34,6 +37,9 @@ export const entityDesc: EntityDesc<Schema, '', '', {
34
37
  totalPlus: '余额变化',
35
38
  availPlus: '可用余额变化',
36
39
  refundablePlus: '可退款余额变化',
40
+ total: "操作后余额",
41
+ avail: '操作后可用余额',
42
+ refundable: '操作后可退款余额',
37
43
  entity: '关联对象',
38
44
  entityId: '关联对象Id',
39
45
  },
@@ -44,7 +50,7 @@ export const entityDesc: EntityDesc<Schema, '', '', {
44
50
  consume: '消费',
45
51
  loan: '抵押',
46
52
  repay: '偿还',
47
- withdrawBack: '提现失败',
53
+ withdrawBack: '提现未遂',
48
54
  earn: '赚取',
49
55
  encash: '兑现',
50
56
  tax: '渠道费',