oak-pay-business 1.0.4 → 1.0.6

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 (66) hide show
  1. package/es/components/AbstractComponents.d.ts +1 -0
  2. package/es/components/account/deposit/index.d.ts +2 -2
  3. package/es/components/account/deposit/index.js +44 -8
  4. package/es/components/account/deposit/index.json +1 -0
  5. package/es/components/account/deposit/index.xml +5 -2
  6. package/es/components/account/deposit/locales/zh-CN.json +4 -0
  7. package/es/components/account/deposit/web.d.ts +4 -1
  8. package/es/components/account/deposit/web.js +7 -7
  9. package/es/components/account/deposit/web.pc.d.ts +4 -2
  10. package/es/components/account/deposit/web.pc.js +9 -7
  11. package/es/components/account/deposit/web.pc.module.less +3 -0
  12. package/es/components/account/detail/index.d.ts +2 -1
  13. package/es/components/account/detail/index.js +32 -3
  14. package/es/components/account/detail/index.xml +40 -36
  15. package/es/components/account/detail/locales/zh-CN.json +5 -1
  16. package/es/components/account/detail/web.d.ts +2 -1
  17. package/es/components/account/detail/web.js +2 -2
  18. package/es/components/account/detail/web.pc.d.ts +2 -1
  19. package/es/components/account/detail/web.pc.js +2 -2
  20. package/es/components/order/pay/index.d.ts +1 -1
  21. package/es/components/order/pay/index.js +65 -30
  22. package/es/components/order/pay/index.json +17 -1
  23. package/es/components/order/pay/index.less +94 -0
  24. package/es/components/order/pay/index.xml +71 -0
  25. package/es/components/order/pay/info.js +6 -6
  26. package/es/components/order/pay/info.module.less +24 -24
  27. package/es/components/order/pay/locales/zh-CN.json +1 -0
  28. package/es/components/order/pay/web.d.ts +1 -1
  29. package/es/components/order/pay/web.js +4 -9
  30. package/es/components/order/pay/web.mobile.module.less +35 -35
  31. package/es/components/order/pay/web.pc.d.ts +1 -1
  32. package/es/components/order/pay/web.pc.js +4 -9
  33. package/es/components/order/pay/web.pc.module.less +35 -35
  34. package/es/components/pay/channelPicker/web.mobile.module.less +7 -7
  35. package/es/components/pay/detail/index.js +2 -1
  36. package/es/components/pay/detail/index.less +0 -1
  37. package/es/components/payConfig/upsert/account/index.js +21 -3
  38. package/es/components/payConfig/upsert/account/locales/zh-CN.json +9 -1
  39. package/es/components/payConfig/upsert/wechatPay/index.js +17 -11
  40. package/es/components/payConfig/upsert/wechatPay/locales/zh-CN.json +4 -2
  41. package/es/config/constants.d.ts +1 -0
  42. package/es/config/constants.js +1 -0
  43. package/es/context/BackendRuntimeContext.d.ts +1 -0
  44. package/es/context/BackendRuntimeContext.js +24 -0
  45. package/es/data/i18n.js +23 -4
  46. package/es/triggers/accountOper.js +4 -2
  47. package/es/triggers/acount.d.ts +5 -0
  48. package/es/triggers/acount.js +20 -0
  49. package/es/triggers/index.js +2 -0
  50. package/es/types/Exception.d.ts +1 -1
  51. package/es/types/Exception.js +2 -3
  52. package/es/types/PayConfig.d.ts +3 -0
  53. package/lib/config/constants.d.ts +1 -0
  54. package/lib/config/constants.js +1 -0
  55. package/lib/context/BackendRuntimeContext.d.ts +1 -0
  56. package/lib/context/BackendRuntimeContext.js +24 -0
  57. package/lib/data/i18n.js +23 -4
  58. package/lib/triggers/accountOper.js +4 -2
  59. package/lib/triggers/acount.d.ts +5 -0
  60. package/lib/triggers/acount.js +23 -0
  61. package/lib/triggers/index.js +2 -0
  62. package/lib/types/Exception.d.ts +1 -1
  63. package/lib/types/Exception.js +3 -4
  64. package/lib/types/PayConfig.d.ts +3 -0
  65. package/lib/utils/payClazz/WechatPay/index.js +0 -1
  66. package/package.json +4 -4
@@ -48,6 +48,7 @@ declare const ListPro: <T extends keyof EntityDict>(props: {
48
48
  size?: "small" | "large" | "middle" | undefined;
49
49
  scroll?: any;
50
50
  locale?: any;
51
+ opWidth?: number | undefined;
51
52
  }) => React.ReactElement;
52
53
  declare const Detail: <T extends keyof EntityDict>(props: ReactComponentProps<EntityDict, T, false, {
53
54
  column?: number | Record<Breakpoint, number> | undefined;
@@ -1,9 +1,9 @@
1
1
  declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, keyof import("../../../oak-app-domain").EntityDict, boolean, {
2
- depositMax: number;
2
+ depositMinCent: number;
3
+ depositMaxCent: number;
3
4
  onSetPrice: (price: null | number) => void;
4
5
  onSetChannel: (channel: string) => void;
5
6
  onSetMeta: (meta: any) => void;
6
- price: number | null;
7
7
  channel: string;
8
8
  meta: any;
9
9
  }>) => React.ReactElement;
@@ -2,11 +2,11 @@ import { ToCent, ToYuan } from 'oak-domain/lib/utils/money';
2
2
  import { PAY_CHANNEL_ACCOUNT_NAME, PAY_CHANNEL_OFFLINE_NAME } from '../../../types/PayConfig';
3
3
  export default OakComponent({
4
4
  properties: {
5
- depositMax: 10000,
5
+ depositMinCent: 0,
6
+ depositMaxCent: 1000000,
6
7
  onSetPrice: (price) => undefined,
7
8
  onSetChannel: (channel) => undefined,
8
9
  onSetMeta: (meta) => undefined,
9
- price: 0,
10
10
  channel: '',
11
11
  meta: {},
12
12
  },
@@ -22,12 +22,16 @@ export default OakComponent({
22
22
  payConfig.push(config);
23
23
  }
24
24
  }
25
- const price = this.props.price;
25
+ const { depositMaxCent, depositMinCent } = this.props;
26
+ const depositLoss = accountConfig?.depositLoss;
27
+ const depositLossRatio = accountConfig?.depositLossRatio;
28
+ const tips = depositLoss ? depositLossRatio ? this.t('tips.depositLossRatio', { ratio: depositLossRatio }) : this.t('tips.depositLoss') : '';
26
29
  return {
30
+ depositMax: ToYuan(depositMaxCent),
31
+ depositMin: ToYuan(depositMinCent),
27
32
  account: data,
28
33
  payConfig,
29
- priceStr: typeof price == 'number' ? `${ToYuan(price)}` : undefined
30
- // accountConfig,
34
+ tips,
31
35
  };
32
36
  },
33
37
  features: ['application'],
@@ -37,16 +41,48 @@ export default OakComponent({
37
41
  }
38
42
  },
39
43
  methods: {
44
+ onPriceChange(price2) {
45
+ if (price2 === null) {
46
+ this.props.onSetPrice(price2);
47
+ this.setState({
48
+ price: price2,
49
+ priceStr: '',
50
+ });
51
+ }
52
+ else {
53
+ let price = ToCent(price2);
54
+ this.props.onSetPrice(price);
55
+ this.setState({
56
+ price,
57
+ priceStr: ToYuan(price),
58
+ });
59
+ }
60
+ },
40
61
  onDepPriceChangeMp(event) {
41
62
  const { value } = event.detail;
42
- const price = parseInt(value);
43
- if (!isNaN(price)) {
44
- this.props.onSetPrice(ToCent(price));
63
+ if (value === null) {
64
+ this.onPriceChange(value);
65
+ }
66
+ else {
67
+ const price2 = parseInt(value);
68
+ if (!isNaN(price2)) {
69
+ this.onPriceChange(price2);
70
+ }
45
71
  }
46
72
  },
47
73
  },
48
74
  data: {
49
75
  onChannelPickMp(channel) { this.props.onSetChannel(channel); },
50
76
  onMetaSetMp(meta) { this.props.onSetMeta(meta); },
77
+ price: 0,
78
+ priceStr: '',
79
+ },
80
+ lifetimes: {
81
+ ready() {
82
+ const { depositMinCent } = this.props;
83
+ if (depositMinCent) {
84
+ this.onPriceChange(ToYuan(depositMinCent));
85
+ }
86
+ }
51
87
  }
52
88
  });
@@ -4,6 +4,7 @@
4
4
  "l-form-item": "@oak-frontend-base/miniprogram_npm/lin-ui/form-item/index",
5
5
  "l-input": "@oak-frontend-base/miniprogram_npm/lin-ui/input/index",
6
6
  "l-button": "@oak-frontend-base/miniprogram_npm/lin-ui/button/index",
7
+ "l-notice-bar": "@oak-frontend-base/miniprogram_npm/lin-ui/notice-bar/index",
7
8
  "pay-channel-picker": "../../pay/channelPicker/index"
8
9
  }
9
10
  }
@@ -1,12 +1,15 @@
1
1
  <view class="container">
2
2
  <l-form>
3
+ <block wx:if="{{tips}}">
4
+ <l-notice-bar type="roll" show="{{true}}">{{tips}}</l-notice-bar>
5
+ </block>
3
6
  <l-form-item label="{{t('label.depPrice')}}">
4
7
  <l-input
5
8
  hide-label
6
- value="{{priceStr}}"
9
+ value="{{priceStr || ''}}"
7
10
  type="number"
8
11
  bind:lininput="onDepPriceChangeMp"
9
- placeholder="{{t('placeholder', { max: depositMax })}}"
12
+ placeholder="一次最大充值{{depositMax}}元"
10
13
  />
11
14
  </l-form-item>
12
15
  <view wx:if="{{price > 0}}">
@@ -3,5 +3,9 @@
3
3
  "label": {
4
4
  "depPrice": "充值金额",
5
5
  "channel": "充值渠道"
6
+ },
7
+ "tips": {
8
+ "depositLoss": "线上充值将按照充值渠道的扣款比例扣除相应费用(一般是0.6%),敬请知晓",
9
+ "depositLossRatio": "线上充值将按照%{ratio}%的比例扣除相应费用,敬请知晓"
6
10
  }
7
11
  }
@@ -6,11 +6,14 @@ export default function Render(props: WebComponentProps<EntityDict, 'account', f
6
6
  depositMax: number;
7
7
  payConfig: PayConfig;
8
8
  accountConfig?: AccountPayConfig;
9
- onSetPrice: (price: null | number) => void;
10
9
  onSetChannel: (channel: string) => void;
11
10
  onSetMeta: (meta: any) => void;
12
11
  price: number;
13
12
  priceStr: string | undefined;
14
13
  channel: string;
15
14
  meta: any;
15
+ depositMin: number;
16
+ tips: string;
17
+ }, {
18
+ onPriceChange: (price: null | number) => void;
16
19
  }>): React.JSX.Element | null;
@@ -1,21 +1,21 @@
1
1
  import React from 'react';
2
2
  import ChannelPicker from '../../pay/channelPicker';
3
- import { Form, Input } from 'antd-mobile';
4
- import { ToCent } from 'oak-domain/lib/utils/money';
3
+ import { Form, Input, NoticeBar } from 'antd-mobile';
5
4
  export default function Render(props) {
6
- const { depositMax, payConfig, price, channel, meta, priceStr, onSetChannel, onSetMeta, onSetPrice } = props.data;
7
- const { t } = props.methods;
5
+ const { depositMax, payConfig, tips, price, channel, meta, priceStr, onSetChannel, onSetMeta } = props.data;
6
+ const { t, onPriceChange } = props.methods;
8
7
  if (payConfig) {
9
8
  return (<Form layout="horizontal">
9
+ {tips && <NoticeBar content={tips} color='info'/>}
10
10
  <Form.Item label={<span>{t("label.depPrice")}:</span>} extra={t('common::pay.symbol')}>
11
- <Input type='number' placeholder={t('placeholder', { max: depositMax })} max={depositMax} min={1} value={priceStr} onChange={(value) => {
11
+ <Input autoFocus type='number' placeholder={t('placeholder', { max: depositMax })} value={priceStr} onChange={(value) => {
12
12
  if (value === '' || value === null) {
13
- onSetPrice(null);
13
+ onPriceChange(null);
14
14
  return;
15
15
  }
16
16
  const v = parseInt(value);
17
17
  if (!isNaN(v)) {
18
- onSetPrice(ToCent(v));
18
+ onPriceChange(v);
19
19
  }
20
20
  }}/>
21
21
  </Form.Item>
@@ -6,11 +6,13 @@ export default function Render(props: WebComponentProps<EntityDict, 'account', f
6
6
  depositMax: number;
7
7
  payConfig: PayConfig;
8
8
  accountConfig?: AccountPayConfig;
9
- onSetPrice: (price: null | number) => void;
10
9
  onSetChannel: (channel: string) => void;
11
10
  onSetMeta: (meta: any) => void;
12
11
  price: number;
13
- priceStr: string | undefined;
14
12
  channel: string;
15
13
  meta: any;
14
+ depositMin: number;
15
+ tips: string;
16
+ }, {
17
+ onPriceChange: (price: null | number) => void;
16
18
  }>): React.JSX.Element | null;
@@ -1,15 +1,17 @@
1
1
  import React from 'react';
2
- import { Form, InputNumber } from 'antd';
2
+ import { Form, InputNumber, Alert } from 'antd';
3
3
  import ChannelPicker from '../../pay/channelPicker';
4
- import { ToYuan, ToCent } from 'oak-domain/lib/utils/money';
4
+ import { ToYuan } from 'oak-domain/lib/utils/money';
5
+ import Styles from './web.pc.module.less';
5
6
  export default function Render(props) {
6
- const { depositMax, payConfig, price, channel, meta, priceStr, onSetChannel, onSetMeta, onSetPrice } = props.data;
7
- const { t } = props.methods;
7
+ const { depositMax, payConfig, price, channel, meta, tips, onSetChannel, onSetMeta } = props.data;
8
+ const { t, onPriceChange } = props.methods;
8
9
  if (payConfig) {
9
- return (<Form labelCol={{ span: 4 }} wrapperCol={{ span: 14 }} layout="horizontal" style={{ minWidth: 600 }} colon={false}>
10
+ return (<Form labelCol={{ span: 4 }} wrapperCol={{ span: 14 }} layout="horizontal" style={{ width: '100%' }} colon={false}>
11
+ {tips && <Alert className={Styles.tips} type="info" message={tips}/>}
10
12
  <Form.Item label={<span>{t("label.depPrice")}:</span>}>
11
- <InputNumber placeholder={t('placeholder', { max: depositMax })} max={depositMax} min={1} value={typeof price == 'number' ? ToYuan(price) : null} addonAfter={t('common::pay.symbol')} onChange={(value) => {
12
- onSetPrice(ToCent(value || 0));
13
+ <InputNumber autoFocus placeholder={t('placeholder', { max: depositMax })} value={typeof price == 'number' ? ToYuan(price) : null} addonAfter={t('common::pay.symbol')} onChange={(value) => {
14
+ onPriceChange(value);
13
15
  }}/>
14
16
  </Form.Item>
15
17
  {price > 0 ? <Form.Item label={<span style={{ marginTop: 10 }}>
@@ -0,0 +1,3 @@
1
+ .tips {
2
+ margin-bottom: 4px;
3
+ }
@@ -1,5 +1,6 @@
1
1
  declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "account", false, {
2
- depositMax: number;
2
+ depositMinCent: number;
3
+ depositMaxCent: number;
3
4
  onDepositPayId: (payId: string) => void;
4
5
  }>) => React.ReactElement;
5
6
  export default _default;
@@ -1,5 +1,7 @@
1
- import { CentToString } from "oak-domain/lib/utils/money";
1
+ import { CentToString, ToYuan } from "oak-domain/lib/utils/money";
2
2
  import { generateNewIdAsync } from "oak-domain/lib/utils/uuid";
3
+ import assert from 'assert';
4
+ import { DATA_SUBSCRIBER_KEYS } from "../../../config/constants";
3
5
  export default OakComponent({
4
6
  entity: 'account',
5
7
  isList: false,
@@ -47,7 +49,8 @@ export default OakComponent({
47
49
  }
48
50
  },
49
51
  properties: {
50
- depositMax: 10000,
52
+ depositMinCent: 0,
53
+ depositMaxCent: 1000000,
51
54
  onDepositPayId: (payId) => undefined,
52
55
  },
53
56
  formData({ data }) {
@@ -64,7 +67,21 @@ export default OakComponent({
64
67
  async createDepositPay() {
65
68
  const { depPrice, depositChannel, depositMeta } = this.state;
66
69
  const payId = await generateNewIdAsync();
67
- const { oakId } = this.props;
70
+ const { oakId, depositMaxCent, depositMinCent } = this.props;
71
+ if (depPrice > depositMaxCent) {
72
+ this.setMessage({
73
+ type: 'error',
74
+ content: this.t('error.maxOverflow', { value: ToYuan(depositMaxCent) }),
75
+ });
76
+ return;
77
+ }
78
+ else if (depPrice < depositMinCent) {
79
+ this.setMessage({
80
+ type: 'error',
81
+ content: this.t('error.minOverflow', { value: ToYuan(depositMinCent) }),
82
+ });
83
+ return;
84
+ }
68
85
  this.setDepositing(true);
69
86
  try {
70
87
  await this.execute(undefined, undefined, undefined, [
@@ -153,5 +170,17 @@ export default OakComponent({
153
170
  setDepPriceMp(price) { this.setDepPrice(price); },
154
171
  setDepositChannelMp(depositChannel) { this.setDepositChannel(depositChannel); },
155
172
  setDepositMetaMp(depositMeta) { this.setDepositMeta(depositMeta); }
173
+ },
174
+ lifetimes: {
175
+ ready() {
176
+ const { oakId } = this.props;
177
+ assert(typeof oakId === 'string');
178
+ this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${oakId}`]);
179
+ },
180
+ detached() {
181
+ const { oakId } = this.props;
182
+ assert(typeof oakId === 'string');
183
+ this.unsubDataEvents([`${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${oakId}`]);
184
+ }
156
185
  }
157
186
  });
@@ -29,41 +29,45 @@
29
29
  </l-button>
30
30
  </view>
31
31
  </view>
32
- <l-popup
33
- show="{{depositOpen}}"
34
- content-align="bottom"
35
- bind:lintap="onDepositModalClose"
36
- >
37
- <view class="ad-container">
38
- <account-deposit
39
- depositMax='{{depositMax}}'
40
- price='{{depPrice}}'
41
- channel='{{depositChannel}}'
42
- meta='{{depositMeta}}'
43
- onSetPrice="{{setDepPriceMp}}"
44
- onSetChannel="{{setDepositChannelMp}}"
45
- onSetMeta="{{setDepositMetaMp}}"
46
- />
47
- <view style="margin-top: 12rpx">
48
- <l-button
49
- type="default"
50
- size="long"
51
- disabled="{{!depPrice || !depositChannel || depositing}}"
52
- loading="{{depositing}}"
53
- bind:lintap="createDepositPay"
54
- >
55
- {{depositing ? t('depositing') : t('common::confirm')}}
56
- </l-button>
32
+ <block wx:if="{{depositOpen}}">
33
+ <l-popup
34
+ show="{{depositOpen}}"
35
+ content-align="bottom"
36
+ bind:lintap="onDepositModalClose"
37
+ >
38
+ <view class="ad-container">
39
+ <account-deposit
40
+ depositMinCent="{{depositMinCent}}"
41
+ depositMaxCent='{{depositMaxCent}}'
42
+ channel='{{depositChannel}}'
43
+ meta='{{depositMeta}}'
44
+ onSetPrice="{{setDepPriceMp}}"
45
+ onSetChannel="{{setDepositChannelMp}}"
46
+ onSetMeta="{{setDepositMetaMp}}"
47
+ />
48
+ <view style="margin-top: 12rpx">
49
+ <l-button
50
+ type="default"
51
+ size="long"
52
+ disabled="{{!depPrice || !depositChannel || depositing}}"
53
+ loading="{{depositing}}"
54
+ bind:lintap="createDepositPay"
55
+ >
56
+ {{depositing ? t('depositing') : t('common::confirm')}}
57
+ </l-button>
58
+ </view>
57
59
  </view>
58
- </view>
59
- </l-popup>
60
- <l-dialog
61
- show="{{ufOpen}}"
62
- type="alert"
63
- show-title="{{false}}"
64
- content="{{t('uf.content')}}"
65
- confirm-text="{{t('uf.go')}}"
66
- bind:linconfirm="onUnfinishedPayClickedMp"
67
- bind:lintap="onUfModalClose"
68
- />
60
+ </l-popup>
61
+ </block>
62
+ <block wx:if="{{ufOpen}}">
63
+ <l-dialog
64
+ show="{{ufOpen}}"
65
+ type="alert"
66
+ show-title="{{false}}"
67
+ content="{{t('uf.content')}}"
68
+ confirm-text="{{t('uf.go')}}"
69
+ bind:linconfirm="onUnfinishedPayClickedMp"
70
+ bind:lintap="onUfModalClose"
71
+ />
72
+ </block>
69
73
  </view>
@@ -12,5 +12,9 @@
12
12
  "content": "您有未支付的充值,请先完成支付",
13
13
  "go": "前往支付"
14
14
  },
15
- "history": "账单:"
15
+ "history": "账单:",
16
+ "error": {
17
+ "maxOverflow": "充值金额不得高于%{value}元",
18
+ "minOverflow": "充值金额不得低于%{value}元"
19
+ }
16
20
  }
@@ -3,7 +3,8 @@ import { RowWithActions, WebComponentProps } from 'oak-frontend-base';
3
3
  import { EntityDict } from '../../../oak-app-domain';
4
4
  export default function Render(props: WebComponentProps<EntityDict, 'account', false, {
5
5
  account: RowWithActions<EntityDict, 'account'>;
6
- depositMax: number;
6
+ depositMaxCent: number;
7
+ depositMinCent: number;
7
8
  unfinishedPayId?: string;
8
9
  onDepositPayId: (payId: string) => void;
9
10
  depositOpen: boolean;
@@ -5,7 +5,7 @@ import classNames from 'classnames';
5
5
  import { CentToString } from 'oak-domain/lib/utils/money';
6
6
  import AccountDeposit from '../deposit';
7
7
  export default function Render(props) {
8
- const { account, depositMax, unfinishedPayId, onDepositPayId, depositOpen, ufOpen, depPrice, depositChannel, depositMeta, depositing } = props.data;
8
+ const { account, depositMaxCent, unfinishedPayId, onDepositPayId, depositOpen, depositMinCent, ufOpen, depPrice, depositChannel, depositMeta, depositing } = props.data;
9
9
  const { t, createDepositPay, setMessage, setDepositOpen, setUfOpen, setDepPrice, setDepositChannel, setDepositMeta, setDepositing, onDepositClick, onDepositModalClose, onUfModalClose } = props.methods;
10
10
  if (account) {
11
11
  const { total, avail, '#oakLegalActions': legalActions, accountOper$account: opers } = account;
@@ -50,7 +50,7 @@ export default function Render(props) {
50
50
  </div>
51
51
  <Popup visible={depositOpen} onMaskClick={() => onDepositModalClose()} onClose={() => onDepositModalClose()}>
52
52
  <div style={{ padding: 12, marginBottom: 6 }}>
53
- <AccountDeposit depositMax={depositMax} price={depPrice} channel={depositChannel} meta={depositMeta} onSetPrice={(price) => setDepPrice(price)} onSetChannel={(channel) => setDepositChannel(channel)} onSetMeta={(meta) => setDepositMeta(meta)}/>
53
+ <AccountDeposit depositMinCent={depositMinCent} depositMaxCent={depositMaxCent} channel={depositChannel} meta={depositMeta} onSetPrice={(price) => setDepPrice(price)} onSetChannel={(channel) => setDepositChannel(channel)} onSetMeta={(meta) => setDepositMeta(meta)}/>
54
54
  <Button block loading={depositing} color="primary" disabled={!depPrice || !depositChannel || depositing} onClick={() => createDepositPay()}>
55
55
  {depositing ? t('depositing') : t('common::confirm')}
56
56
  </Button>
@@ -3,7 +3,8 @@ import { RowWithActions, WebComponentProps } from 'oak-frontend-base';
3
3
  import { EntityDict } from '../../../oak-app-domain';
4
4
  export default function Render(props: WebComponentProps<EntityDict, 'account', false, {
5
5
  account: RowWithActions<EntityDict, 'account'>;
6
- depositMax: number;
6
+ depositMaxCent: number;
7
+ depositMinCent: number;
7
8
  unfinishedPayId?: string;
8
9
  onDepositPayId: (payId: string) => void;
9
10
  depositOpen: boolean;
@@ -7,7 +7,7 @@ import AccountDeposit from '../deposit';
7
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
- const { account, depositMax, unfinishedPayId, onDepositPayId, depositOpen, ufOpen, depPrice, depositChannel, depositMeta, depositing } = props.data;
10
+ const { account, depositMaxCent, unfinishedPayId, onDepositPayId, depositOpen, depositMinCent, ufOpen, depPrice, depositChannel, depositMeta, depositing } = props.data;
11
11
  const { t, createDepositPay, setMessage, setDepositOpen, setUfOpen, setDepPrice, setDepositChannel, setDepositMeta, setDepositing, onDepositClick, onDepositModalClose, } = props.methods;
12
12
  if (account) {
13
13
  const { total, avail, '#oakLegalActions': legalActions, accountOper$account: opers } = account;
@@ -51,7 +51,7 @@ export default function Render(props) {
51
51
  {depositing ? t('depositing') : t('common::confirm')}
52
52
  </Button>}>
53
53
  <div style={{ padding: 12 }}>
54
- <AccountDeposit depositMax={depositMax} price={depPrice} channel={depositChannel} meta={depositMeta} onSetPrice={(price) => setDepPrice(price)} onSetChannel={(channel) => setDepositChannel(channel)} onSetMeta={(meta) => setDepositMeta(meta)}/>
54
+ <AccountDeposit depositMinCent={depositMinCent} depositMaxCent={depositMaxCent} channel={depositChannel} meta={depositMeta} onSetPrice={(price) => setDepPrice(price)} onSetChannel={(channel) => setDepositChannel(channel)} onSetMeta={(meta) => setDepositMeta(meta)}/>
55
55
  </div>
56
56
  </Modal>
57
57
  <Modal title={t('uf.title')} open={ufOpen} onCancel={() => {
@@ -2,6 +2,6 @@ import { EntityDict } from "../../../oak-app-domain";
2
2
  declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "order", false, {
3
3
  accountId: string;
4
4
  accountAvailMax: number;
5
- onPayReady: (operation: EntityDict['order']['Update'], payId: string) => void;
5
+ onSetPays: (pays: Partial<EntityDict['pay']['CreateSingle']['data']>[]) => void;
6
6
  }>) => React.ReactElement;
7
7
  export default _default;
@@ -1,5 +1,6 @@
1
1
  import { PAY_CHANNEL_ACCOUNT_NAME } from "../../../types/PayConfig";
2
2
  import { generateNewId } from "oak-domain/lib/utils/uuid";
3
+ import { ToCent, ToYuan } from "oak-domain/lib/utils/money";
3
4
  export default OakComponent({
4
5
  entity: 'order',
5
6
  projection: {
@@ -24,7 +25,7 @@ export default OakComponent({
24
25
  properties: {
25
26
  accountId: '', // 是否可以使用帐户中的余额抵扣
26
27
  accountAvailMax: 0, // 本次交易可以使用的帐户中的Avail max值,调用者自己保证此数值的一致性,不要扣成负数
27
- onPayReady: (operation, payId) => undefined,
28
+ onSetPays: (pays) => undefined,
28
29
  },
29
30
  formData({ data }) {
30
31
  const payConfig = this.features.pay.getPayConfigs();
@@ -32,49 +33,93 @@ export default OakComponent({
32
33
  const payConfig2 = payConfig?.filter(ele => ele !== accountConfig);
33
34
  const activePay = data && data.pay$order?.[0];
34
35
  const { accountPrice } = this.state;
36
+ const { accountAvailMax } = this.props;
37
+ const rest = data ? data.price - data.paid - accountPrice : 0;
35
38
  return {
39
+ priceStr: data && ToYuan(data.price),
40
+ accountAvailMaxStr: accountAvailMax && ToYuan(accountAvailMax),
36
41
  order: data,
37
42
  activePay,
38
43
  accountConfig,
39
44
  payConfig: payConfig2,
40
- rest: data ? data.price - data.paid - accountPrice : 0,
41
- legal: !!(data?.['#oakLegalActions']?.includes('startPaying'))
45
+ rest,
46
+ restYuan: ToYuan(rest),
47
+ legal: !!(data?.['#oakLegalActions']?.includes('startPaying')),
42
48
  };
43
49
  },
44
50
  features: ['application'],
45
51
  data: {
46
52
  useAccount: false,
47
53
  accountPrice: 0,
54
+ accountPriceYuan: 0,
48
55
  channel: '',
56
+ restYuan: 0,
49
57
  meta: undefined,
58
+ onPickMp(channel) {
59
+ this.onPickChannel(channel);
60
+ },
61
+ onSetMetaMp(meta) {
62
+ this.onSetChannelMeta(meta);
63
+ }
50
64
  },
51
65
  methods: {
52
- setUseAccount(v) {
66
+ switchUseAccount() {
53
67
  const { accountAvailMax } = this.props;
54
- const { order } = this.state;
68
+ const { useAccount, order } = this.state;
55
69
  const accountMaxPrice = Math.min(accountAvailMax, order.price);
56
- this.setState({
57
- useAccount: v,
58
- accountPrice: accountMaxPrice,
59
- rest: order.price - accountMaxPrice,
60
- }, () => this.tryCreatePay());
70
+ if (!useAccount) {
71
+ const rest = order.price - accountMaxPrice;
72
+ this.setState({
73
+ useAccount: true,
74
+ accountPrice: accountMaxPrice,
75
+ accountPriceYuan: ToYuan(accountMaxPrice),
76
+ rest,
77
+ restYuan: ToYuan(rest),
78
+ }, () => this.tryCreatePays());
79
+ }
80
+ else {
81
+ const rest = order.price;
82
+ this.setState({
83
+ useAccount: false,
84
+ accountPrice: undefined,
85
+ accountPriceYuan: undefined,
86
+ rest,
87
+ restYuan: ToYuan(rest),
88
+ });
89
+ }
61
90
  },
62
91
  setAccountPrice(price) {
63
92
  const { order } = this.state;
64
- this.setState({ accountPrice: price, rest: order.price - order.paid - price }, () => this.tryCreatePay());
93
+ const rest = order.price - order.paid - price;
94
+ this.setState({
95
+ accountPrice: price,
96
+ rest,
97
+ restYuan: ToYuan(rest),
98
+ accountPriceYuan: ToYuan(price),
99
+ }, () => this.tryCreatePays());
100
+ },
101
+ setAccountPriceMp(e) {
102
+ const { value } = e.detail;
103
+ const v = parseInt(value);
104
+ if (!isNaN(v)) {
105
+ const { accountAvailMax } = this.props;
106
+ const { order } = this.state;
107
+ const accountMaxPrice = Math.min(accountAvailMax, order.price);
108
+ this.setAccountPrice(Math.min(accountMaxPrice, ToCent(v)));
109
+ }
65
110
  },
66
111
  onPickChannel(channel) {
67
112
  this.setState({
68
113
  channel,
69
- }, () => this.tryCreatePay());
114
+ }, () => this.tryCreatePays());
70
115
  },
71
116
  onSetChannelMeta(meta) {
72
117
  this.setState({
73
118
  meta,
74
- }, () => this.tryCreatePay());
119
+ }, () => this.tryCreatePays());
75
120
  },
76
- tryCreatePay() {
77
- const { oakId, accountId } = this.props;
121
+ tryCreatePays() {
122
+ const { accountId } = this.props;
78
123
  const { useAccount, accountPrice, channel, meta, order } = this.state;
79
124
  const pays = [];
80
125
  let rest = order.price - order.paid;
@@ -98,22 +143,12 @@ export default OakComponent({
98
143
  });
99
144
  rest = 0;
100
145
  }
101
- const { onPayReady } = this.props;
146
+ const { onSetPays } = this.props;
102
147
  if (rest === 0) {
103
- onPayReady({
104
- id: generateNewId(),
105
- action: 'startPaying',
106
- data: {
107
- pay$order: pays.map(ele => ({
108
- id: generateNewId(),
109
- action: 'create',
110
- data: ele,
111
- })),
112
- },
113
- filter: {
114
- id: oakId,
115
- },
116
- }, payId);
148
+ onSetPays(pays);
149
+ }
150
+ else {
151
+ onSetPays([]);
117
152
  }
118
153
  }
119
154
  },
@@ -1 +1,17 @@
1
- {}
1
+ {
2
+ "usingComponents": {
3
+ "l-input": "@oak-frontend-base/miniprogram_npm/lin-ui/input/index",
4
+ "l-search-bar": "@oak-frontend-base/miniprogram_npm/lin-ui/search-bar/index",
5
+ "l-tabs": "@oak-frontend-base/miniprogram_npm/lin-ui/tabs/index",
6
+ "l-tabpanel": "@oak-frontend-base/miniprogram_npm/lin-ui/tabpanel/index",
7
+ "l-segment": "@oak-frontend-base/miniprogram_npm/lin-ui/segment/index",
8
+ "l-segment-item": "@oak-frontend-base/miniprogram_npm/lin-ui/segment-item/index",
9
+ "l-status-show": "@oak-frontend-base/miniprogram_npm/lin-ui/status-show/index",
10
+ "l-card": "@oak-frontend-base/miniprogram_npm/lin-ui/card/index",
11
+ "l-tag": "@oak-frontend-base/miniprogram_npm/lin-ui/tag/index",
12
+ "l-icon": "@oak-frontend-base/miniprogram_npm/lin-ui/icon/index",
13
+ "l-button": "@oak-frontend-base/miniprogram_npm/lin-ui/button/index",
14
+ "l-switch": "@oak-frontend-base/miniprogram_npm/lin-ui/switch/index",
15
+ "channel-picker": "../../pay/channelPicker"
16
+ }
17
+ }