oak-pay-business 1.0.5 → 1.0.7

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 (73) hide show
  1. package/es/components/AbstractComponents.d.ts +6 -4
  2. package/es/components/account/deposit/index.d.ts +1 -0
  3. package/es/components/account/deposit/index.js +39 -9
  4. package/es/components/account/deposit/index.json +1 -0
  5. package/es/components/account/deposit/index.xml +3 -0
  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 +20 -5
  14. package/es/components/account/detail/index.xml +2 -1
  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/info.js +6 -6
  21. package/es/components/pay/detail/index.d.ts +2 -1
  22. package/es/components/pay/detail/index.js +33 -4
  23. package/es/components/pay/detail/index.xml +9 -1
  24. package/es/components/pay/detail/locales/zh-CN.json +2 -1
  25. package/es/components/payConfig/system/index.js +14 -0
  26. package/es/components/payConfig/system/web.pc.d.ts +1 -0
  27. package/es/components/payConfig/system/web.pc.js +16 -16
  28. package/es/components/payConfig/upsert/account/index.js +21 -3
  29. package/es/components/payConfig/upsert/account/locales/zh-CN.json +9 -1
  30. package/es/components/payConfig/upsert/index.d.ts +2 -0
  31. package/es/components/payConfig/upsert/index.js +23 -23
  32. package/es/components/payConfig/upsert/wechatPay/index.d.ts +3 -0
  33. package/es/components/payConfig/upsert/wechatPay/index.js +36 -12
  34. package/es/components/payConfig/upsert/wechatPay/locales/zh-CN.json +10 -2
  35. package/es/context/BackendRuntimeContext.d.ts +1 -0
  36. package/es/context/BackendRuntimeContext.js +24 -0
  37. package/es/data/i18n.js +30 -5
  38. package/es/types/Exception.d.ts +12 -2
  39. package/es/types/Exception.js +24 -2
  40. package/es/types/PayClazz.d.ts +6 -6
  41. package/es/types/PayConfig.d.ts +6 -0
  42. package/es/utils/pay.d.ts +5 -0
  43. package/es/utils/pay.js +63 -0
  44. package/es/utils/payClazz/Account.d.ts +8 -9
  45. package/es/utils/payClazz/Account.js +3 -3
  46. package/es/utils/payClazz/Offline.d.ts +6 -7
  47. package/es/utils/payClazz/Offline.js +4 -4
  48. package/es/utils/payClazz/WechatPay/WechatPay.d.ts +12 -8
  49. package/es/utils/payClazz/WechatPay/WechatPay.debug.d.ts +8 -9
  50. package/es/utils/payClazz/WechatPay/WechatPay.debug.js +7 -7
  51. package/es/utils/payClazz/WechatPay/WechatPay.js +234 -9
  52. package/es/utils/payClazz/WechatPay/index.d.ts +2 -1
  53. package/es/watchers/pay.js +4 -5
  54. package/lib/context/BackendRuntimeContext.d.ts +1 -0
  55. package/lib/context/BackendRuntimeContext.js +24 -0
  56. package/lib/data/i18n.js +30 -5
  57. package/lib/types/Exception.d.ts +12 -2
  58. package/lib/types/Exception.js +26 -3
  59. package/lib/types/PayClazz.d.ts +6 -6
  60. package/lib/types/PayConfig.d.ts +6 -0
  61. package/lib/utils/pay.d.ts +5 -0
  62. package/lib/utils/pay.js +66 -1
  63. package/lib/utils/payClazz/Account.d.ts +8 -9
  64. package/lib/utils/payClazz/Account.js +3 -3
  65. package/lib/utils/payClazz/Offline.d.ts +6 -7
  66. package/lib/utils/payClazz/Offline.js +4 -4
  67. package/lib/utils/payClazz/WechatPay/WechatPay.d.ts +12 -8
  68. package/lib/utils/payClazz/WechatPay/WechatPay.debug.d.ts +8 -9
  69. package/lib/utils/payClazz/WechatPay/WechatPay.debug.js +7 -7
  70. package/lib/utils/payClazz/WechatPay/WechatPay.js +235 -9
  71. package/lib/utils/payClazz/WechatPay/index.d.ts +2 -1
  72. package/lib/watchers/pay.js +4 -5
  73. package/package.json +16 -15
@@ -20,7 +20,7 @@ declare const List: <T extends keyof EntityDict>(props: ReactComponentProps<Enti
20
20
  rowSelection?: any;
21
21
  hideHeader?: boolean | undefined;
22
22
  disableSerialNumber?: boolean | undefined;
23
- size?: "small" | "large" | "middle" | undefined;
23
+ size?: "small" | "middle" | "large" | undefined;
24
24
  scroll?: ({
25
25
  x?: string | number | true | undefined;
26
26
  y?: string | number | undefined;
@@ -28,6 +28,7 @@ declare const List: <T extends keyof EntityDict>(props: ReactComponentProps<Enti
28
28
  scrollToFirstRowOnChange?: boolean | undefined;
29
29
  }) | undefined;
30
30
  locale?: any;
31
+ opWidth?: number | undefined;
31
32
  }>) => React.ReactElement;
32
33
  declare const ListPro: <T extends keyof EntityDict>(props: {
33
34
  title?: any;
@@ -45,9 +46,10 @@ declare const ListPro: <T extends keyof EntityDict>(props: {
45
46
  tablePagination?: any;
46
47
  rowSelection?: any;
47
48
  disableSerialNumber?: boolean | undefined;
48
- size?: "small" | "large" | "middle" | undefined;
49
+ size?: "small" | "middle" | "large" | undefined;
49
50
  scroll?: any;
50
51
  locale?: any;
52
+ opWidth?: number | undefined;
51
53
  }) => React.ReactElement;
52
54
  declare const Detail: <T extends keyof EntityDict>(props: ReactComponentProps<EntityDict, T, false, {
53
55
  column?: number | Record<Breakpoint, number> | undefined;
@@ -56,14 +58,14 @@ declare const Detail: <T extends keyof EntityDict>(props: ReactComponentProps<En
56
58
  data: Partial<EntityDict[T]["Schema"]>;
57
59
  title?: string | undefined;
58
60
  bordered?: boolean | undefined;
59
- layout?: "horizontal" | "vertical" | undefined;
61
+ layout?: "vertical" | "horizontal" | undefined;
60
62
  }>) => React.ReactElement;
61
63
  declare const Upsert: <T extends keyof EntityDict>(props: ReactComponentProps<EntityDict, T, false, {
62
64
  helps: Record<string, string>;
63
65
  entity: T;
64
66
  attributes: OakAbsAttrUpsertDef<EntityDict, T, string | number>[];
65
67
  data: EntityDict[T]["Schema"];
66
- layout: "horizontal" | "vertical";
68
+ layout: "vertical" | "horizontal";
67
69
  mode: "default" | "card";
68
70
  }>) => React.ReactElement;
69
71
  export { FilterPanel, List, ListPro, Detail, Upsert, ReactComponentProps, ColumnProps, RowWithActions, OakExtraActionProps, OakAbsAttrDef, onActionFnDef, };
@@ -1,4 +1,5 @@
1
1
  declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, keyof import("../../../oak-app-domain").EntityDict, boolean, {
2
+ depositMinCent: number;
2
3
  depositMaxCent: number;
3
4
  onSetPrice: (price: null | number) => void;
4
5
  onSetChannel: (channel: string) => void;
@@ -2,6 +2,7 @@ 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
+ depositMinCent: 0,
5
6
  depositMaxCent: 1000000,
6
7
  onSetPrice: (price) => undefined,
7
8
  onSetChannel: (channel) => undefined,
@@ -21,12 +22,16 @@ export default OakComponent({
21
22
  payConfig.push(config);
22
23
  }
23
24
  }
24
- const { depositMaxCent } = this.props;
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') : '';
25
29
  return {
26
30
  depositMax: ToYuan(depositMaxCent),
31
+ depositMin: ToYuan(depositMinCent),
27
32
  account: data,
28
33
  payConfig,
29
- // accountConfig,
34
+ tips,
30
35
  };
31
36
  },
32
37
  features: ['application'],
@@ -36,23 +41,48 @@ export default OakComponent({
36
41
  }
37
42
  },
38
43
  methods: {
39
- onDepPriceChangeMp(event) {
40
- const { value } = event.detail;
41
- const { depositMaxCent } = this.props;
42
- const price2 = parseInt(value);
43
- if (!isNaN(price2)) {
44
- const price = Math.min(depositMaxCent, ToCent(price2));
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);
45
54
  this.props.onSetPrice(price);
46
55
  this.setState({
47
56
  price,
48
- priceStr: price ? `${ToYuan(price)}` : undefined
57
+ priceStr: ToYuan(price),
49
58
  });
50
59
  }
51
60
  },
61
+ onDepPriceChangeMp(event) {
62
+ const { value } = event.detail;
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
+ }
71
+ }
72
+ },
52
73
  },
53
74
  data: {
54
75
  onChannelPickMp(channel) { this.props.onSetChannel(channel); },
55
76
  onMetaSetMp(meta) { this.props.onSetMeta(meta); },
56
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
+ }
57
87
  }
58
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,5 +1,8 @@
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
@@ -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,4 +1,4 @@
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
3
  import assert from 'assert';
4
4
  import { DATA_SUBSCRIBER_KEYS } from "../../../config/constants";
@@ -49,7 +49,8 @@ export default OakComponent({
49
49
  }
50
50
  },
51
51
  properties: {
52
- depositMax: 10000,
52
+ depositMinCent: 0,
53
+ depositMaxCent: 1000000,
53
54
  onDepositPayId: (payId) => undefined,
54
55
  },
55
56
  formData({ data }) {
@@ -66,7 +67,21 @@ export default OakComponent({
66
67
  async createDepositPay() {
67
68
  const { depPrice, depositChannel, depositMeta } = this.state;
68
69
  const payId = await generateNewIdAsync();
69
- 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
+ }
70
85
  this.setDepositing(true);
71
86
  try {
72
87
  await this.execute(undefined, undefined, undefined, [
@@ -160,12 +175,12 @@ export default OakComponent({
160
175
  ready() {
161
176
  const { oakId } = this.props;
162
177
  assert(typeof oakId === 'string');
163
- this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${oakId}`]);
178
+ this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${oakId}`], 'opb-c-account-detail');
164
179
  },
165
180
  detached() {
166
181
  const { oakId } = this.props;
167
182
  assert(typeof oakId === 'string');
168
- this.unsubDataEvents([`${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${oakId}`]);
183
+ this.unsubDataEvents([`${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${oakId}`], 'opb-c-account-detail');
169
184
  }
170
185
  }
171
186
  });
@@ -37,7 +37,8 @@
37
37
  >
38
38
  <view class="ad-container">
39
39
  <account-deposit
40
- depositMax='{{depositMax}}'
40
+ depositMinCent="{{depositMinCent}}"
41
+ depositMaxCent='{{depositMaxCent}}'
41
42
  channel='{{depositChannel}}'
42
43
  meta='{{depositMeta}}'
43
44
  onSetPrice="{{setDepPriceMp}}"
@@ -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} 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} 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={() => {
@@ -1,11 +1,11 @@
1
1
  import Styles from './info.module.less';
2
2
  export default function Info(props) {
3
3
  const { price, t } = props;
4
- return (<div className={Styles.info}>
5
- <div className={Styles.should}>{t('price')}</div>
6
- <div className={Styles.price}>
7
- <div>{t('common::pay.symbol')}</div>
8
- <div>{price}</div>
9
- </div>
4
+ return (<div className={Styles.info}>
5
+ <div className={Styles.should}>{t('price')}</div>
6
+ <div className={Styles.price}>
7
+ <div>{t('common::pay.symbol')}</div>
8
+ <div>{price}</div>
9
+ </div>
10
10
  </div>);
11
11
  }
@@ -1,4 +1,5 @@
1
- declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../oak-app-domain").EntityDict, "pay", false, {
1
+ import { EntityDict } from "../../../oak-app-domain";
2
+ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "pay", false, {
2
3
  onClose: () => void;
3
4
  }>) => React.ReactElement;
4
5
  export default _default;
@@ -27,7 +27,8 @@ export default OakComponent({
27
27
  order: {
28
28
  id: 1,
29
29
  creatorId: 1,
30
- }
30
+ },
31
+ creatorId: 1,
31
32
  },
32
33
  properties: {
33
34
  onClose: () => undefined,
@@ -47,6 +48,12 @@ export default OakComponent({
47
48
  const iState = data?.iState;
48
49
  const iStateColor = iState && this.features.style.getColor('pay', 'iState', iState);
49
50
  const payConfig = this.features.pay.getPayConfigs();
51
+ const startPayable = data?.iState === 'paying' && data?.meta && data?.channel && [
52
+ PAY_CHANNEL_WECHAT_APP_NAME,
53
+ PAY_CHANNEL_WECHAT_MP_NAME,
54
+ PAY_CHANNEL_WECHAT_H5_NAME,
55
+ PAY_CHANNEL_WECHAT_JS_NAME
56
+ ].includes(data.channel);
50
57
  return {
51
58
  type: data?.orderId ? 'order' : 'account',
52
59
  pay: data,
@@ -54,7 +61,7 @@ export default OakComponent({
54
61
  iStateColor,
55
62
  payConfig,
56
63
  closable: !!(data?.["#oakLegalActions"]?.includes('close')),
57
- startPayable: false,
64
+ startPayable,
58
65
  metaUpdatable: !!(data?.["#oakLegalActions"]?.find(ele => typeof ele === 'object'
59
66
  && ele.action === 'update'
60
67
  && ele.attrs?.includes('meta'))),
@@ -111,18 +118,40 @@ export default OakComponent({
111
118
  },
112
119
  goBack() {
113
120
  this.navigateBack();
121
+ },
122
+ async startPay() {
123
+ const { pay } = this.state;
124
+ const { iState, channel, meta } = pay;
125
+ switch (channel) {
126
+ case PAY_CHANNEL_WECHAT_MP_NAME: {
127
+ const { prepayMeta } = meta;
128
+ const result = await wx.requestPayment(prepayMeta);
129
+ console.log(result);
130
+ break;
131
+ }
132
+ default: {
133
+ assert('尚未实现');
134
+ }
135
+ }
114
136
  }
115
137
  },
116
138
  lifetimes: {
117
139
  ready() {
118
140
  const { oakId } = this.props;
119
141
  assert(typeof oakId === 'string');
120
- this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`]);
142
+ this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`], 'opb-c-pay-detail');
121
143
  },
122
144
  detached() {
123
145
  const { oakId } = this.props;
124
146
  assert(typeof oakId === 'string');
125
- this.unsubDataEvents([`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`]);
147
+ this.unsubDataEvents([`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`], 'opb-c-pay-detail');
148
+ }
149
+ },
150
+ listeners: {
151
+ startPayable(prev, next) {
152
+ if (next.startPayable) {
153
+ this.startPay();
154
+ }
126
155
  }
127
156
  }
128
157
  });
@@ -126,7 +126,15 @@
126
126
  />
127
127
  </block>
128
128
  <block wx:elif="{{startPayable}}">
129
-
129
+ <view class="btn">
130
+ <l-button
131
+ type="default"
132
+ size="long"
133
+ bind:lintap="startPay"
134
+ >
135
+ {{t('pay')}}
136
+ </l-button>
137
+ </view>
130
138
  </block>
131
139
  <block wx:else>
132
140
  <view class="btn">
@@ -28,5 +28,6 @@
28
28
  "order": "订单支付",
29
29
  "account": "帐户充值"
30
30
  },
31
- "success": "支付成功"
31
+ "success": "支付成功",
32
+ "pay": "支付"
32
33
  }
@@ -1,3 +1,4 @@
1
+ import { composeServerUrl } from 'oak-general-business/es/utils/domain';
1
2
  export default OakComponent({
2
3
  entity: 'system',
3
4
  isList: false,
@@ -13,12 +14,25 @@ export default OakComponent({
13
14
  type: 1,
14
15
  },
15
16
  },
17
+ domain$system: {
18
+ $entity: 'domain',
19
+ data: {
20
+ id: 1,
21
+ protocol: 1,
22
+ url: 1,
23
+ apiPath: 1,
24
+ port: 1,
25
+ },
26
+ },
16
27
  },
17
28
  formData({ data, features }) {
18
29
  const operation = this.state.oakFullpath && this.features.runningTree.getOperations(this.state.oakFullpath);
30
+ const domain = data && data.domain$system[0];
31
+ const serverUrl = domain && composeServerUrl(domain);
19
32
  return {
20
33
  operation: operation && operation[0].operation,
21
34
  system: data,
35
+ serverUrl,
22
36
  };
23
37
  },
24
38
  });
@@ -15,4 +15,5 @@ export declare function registerApplicationPayChannel(type: EntityDict['applicat
15
15
  export default function render(props: WebComponentProps<EntityDict, 'system', false, {
16
16
  system: RowWithActions<EntityDict, 'system'>;
17
17
  operation?: EntityDict['system']['Update'];
18
+ serverUrl?: string;
18
19
  }>): React.JSX.Element | null;
@@ -27,7 +27,7 @@ export function registerApplicationPayChannel(type, channel) {
27
27
  }
28
28
  }
29
29
  export default function render(props) {
30
- const { system, oakFullpath, operation, oakDirty } = props.data;
30
+ const { system, oakFullpath, operation, oakDirty, serverUrl } = props.data;
31
31
  const { t, update, setMessage, execute } = props.methods;
32
32
  const defaultApplicationPayChannelDict = {
33
33
  web: AppTypeToPayChannelDict.web.map(ele => [t(`payChannel::internal.${ele}`), ele]),
@@ -37,23 +37,23 @@ export default function render(props) {
37
37
  const [key, setKey] = useState('');
38
38
  if (system && oakFullpath) {
39
39
  const { payConfig, application$system: applications } = system;
40
- return (<div className={Styles.container}>
41
- <Row justify="end" style={{ marginBottom: 12 }}>
42
- <Button type="primary" disabled={!oakDirty} onClick={() => execute()}>
43
- {t('common::action.save')}
44
- </Button>
45
- </Row>
40
+ return (<div className={Styles.container}>
41
+ <Row justify="end" style={{ marginBottom: 12 }}>
42
+ <Button type="primary" disabled={!oakDirty} onClick={() => execute()}>
43
+ {t('common::action.save')}
44
+ </Button>
45
+ </Row>
46
46
  <Tabs tabPosition="left" items={[
47
47
  {
48
- label: (<div className={Styles.systemLabel}>
49
- {t('system')}
48
+ label: (<div className={Styles.systemLabel}>
49
+ {t('system')}
50
50
  </div>),
51
51
  key: 'system',
52
- children: (<PayConfigUpsert key="system" config={payConfig} update={(config) => update({ payConfig: config })} channels={SystemPayChannels.concat([[t('payChannel::internal.ACCOUNT'), 'ACCOUNT'], [t('payChannel::internal.OFFLINE'), 'OFFLINE']])} t={t}/>),
52
+ children: (<PayConfigUpsert key="system" serverUrl={serverUrl} config={payConfig} update={(config) => update({ payConfig: config })} channels={SystemPayChannels.concat([[t('payChannel::internal.ACCOUNT'), 'ACCOUNT'], [t('payChannel::internal.OFFLINE'), 'OFFLINE']])} t={t}/>),
53
53
  },
54
54
  {
55
- label: (<div className={Styles.padding}>
56
- {t('appsBelow')}
55
+ label: (<div className={Styles.padding}>
56
+ {t('appsBelow')}
57
57
  </div>),
58
58
  disabled: true,
59
59
  key: 'padding',
@@ -62,10 +62,10 @@ export default function render(props) {
62
62
  const { type, id, payConfig: appPayConfig } = app;
63
63
  return {
64
64
  key: id,
65
- label: (<div>
66
- {app.name}
65
+ label: (<div>
66
+ {app.name}
67
67
  </div>),
68
- children: (<PayConfigUpsert key={id} config={appPayConfig} update={(config) => update({
68
+ children: (<PayConfigUpsert key={id} serverUrl={serverUrl} config={appPayConfig} update={(config) => update({
69
69
  application$system: {
70
70
  id: generateNewId(),
71
71
  action: 'update',
@@ -95,7 +95,7 @@ export default function render(props) {
95
95
  }
96
96
  }
97
97
  setKey(activeKey);
98
- }}/>
98
+ }}/>
99
99
  </div>);
100
100
  }
101
101
  return null;