@pisell/private-materials 3.0.205 → 3.0.206

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 (57) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +7 -7
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +9 -9
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +7 -7
  11. package/es/components/eftposPay/component/fail/failCustom.js +0 -1
  12. package/es/components/eftposPay/component/fail/index.js +0 -1
  13. package/es/components/eftposPay/component/manual/index.js +1 -4
  14. package/es/components/eftposPay/const.d.ts +1 -27
  15. package/es/components/eftposPay/const.js +0 -22
  16. package/es/components/eftposPay/device.d.ts +1 -1
  17. package/es/components/eftposPay/device.js +2 -2
  18. package/es/components/eftposPay/helper.d.ts +0 -5
  19. package/es/components/eftposPay/helper.js +4 -10
  20. package/es/components/eftposPay/hooks.d.ts +0 -1
  21. package/es/components/eftposPay/hooks.js +16 -22
  22. package/es/components/eftposPay/index.d.ts +1 -1
  23. package/es/components/eftposPay/index.js +179 -130
  24. package/es/components/eftposPay/locales.d.ts +0 -15
  25. package/es/components/eftposPay/locales.js +0 -15
  26. package/es/components/eftposPay/payo/config.js +8 -20
  27. package/es/components/eftposPay/tyro/index.js +2 -4
  28. package/es/components/eftposPay/windcave/windcave.js +6 -17
  29. package/lib/components/eftposPay/component/fail/failCustom.js +1 -1
  30. package/lib/components/eftposPay/component/fail/index.js +1 -1
  31. package/lib/components/eftposPay/component/manual/index.js +5 -19
  32. package/lib/components/eftposPay/const.d.ts +1 -27
  33. package/lib/components/eftposPay/const.js +0 -18
  34. package/lib/components/eftposPay/device.d.ts +1 -1
  35. package/lib/components/eftposPay/device.js +2 -2
  36. package/lib/components/eftposPay/helper.d.ts +0 -5
  37. package/lib/components/eftposPay/helper.js +4 -8
  38. package/lib/components/eftposPay/hooks.d.ts +0 -1
  39. package/lib/components/eftposPay/hooks.js +2 -8
  40. package/lib/components/eftposPay/index.d.ts +1 -1
  41. package/lib/components/eftposPay/index.js +144 -106
  42. package/lib/components/eftposPay/locales.d.ts +0 -15
  43. package/lib/components/eftposPay/locales.js +0 -15
  44. package/lib/components/eftposPay/payo/config.js +9 -33
  45. package/lib/components/eftposPay/tyro/index.js +2 -4
  46. package/lib/components/eftposPay/windcave/windcave.js +6 -29
  47. package/package.json +4 -4
  48. package/es/components/eftposPay/app.d.ts +0 -11
  49. package/es/components/eftposPay/app.js +0 -173
  50. package/es/components/eftposPay/tip.d.ts +0 -10
  51. package/es/components/eftposPay/tip.js +0 -177
  52. package/es/components/eftposPay/tip.less +0 -9
  53. package/lib/components/eftposPay/app.d.ts +0 -11
  54. package/lib/components/eftposPay/app.js +0 -166
  55. package/lib/components/eftposPay/tip.d.ts +0 -10
  56. package/lib/components/eftposPay/tip.js +0 -159
  57. package/lib/components/eftposPay/tip.less +0 -9
@@ -67,7 +67,6 @@ var manual_default = ({ onChange, className = "", formatAmount }) => {
67
67
  amount,
68
68
  total: amount,
69
69
  number,
70
- uniquePaymentNumber: number,
71
70
  device,
72
71
  order_id
73
72
  });
@@ -81,7 +80,7 @@ var manual_default = ({ onChange, className = "", formatAmount }) => {
81
80
  return;
82
81
  }
83
82
  setDisabled(true);
84
- onChange("fail", { number, uniquePaymentNumber: number, device, order_id });
83
+ onChange("fail", { number, device, order_id });
85
84
  };
86
85
  const onSubmit = () => {
87
86
  if (disabled) {
@@ -111,13 +110,8 @@ var manual_default = ({ onChange, className = "", formatAmount }) => {
111
110
  surMoney: surMoneyDeci.toFixed(2, import_decimal.Decimal.ROUND_HALF_UP),
112
111
  surcharge: surchargeDeci.toFixed(2, import_decimal.Decimal.ROUND_HALF_UP),
113
112
  total: moneyDeci.toFixed(2, import_decimal.Decimal.ROUND_HALF_UP),
114
- totalUnit: formatAmount(
115
- moneyDeci.toFixed(2, import_decimal.Decimal.ROUND_HALF_UP),
116
- 2,
117
- symbol
118
- ),
113
+ totalUnit: formatAmount(moneyDeci.toFixed(2, import_decimal.Decimal.ROUND_HALF_UP), 2, symbol),
119
114
  number,
120
- uniquePaymentNumber: number,
121
115
  device,
122
116
  order_id
123
117
  });
@@ -126,15 +120,9 @@ var manual_default = ({ onChange, className = "", formatAmount }) => {
126
120
  const onCancel = () => {
127
121
  updateAmountStatus(false);
128
122
  setMoney(pay == null ? void 0 : pay.total);
129
- dispatch(
130
- (0, import_store.updateState)({
131
- manual: { ...manual, status: true, money: pay == null ? void 0 : pay.total }
132
- })
133
- );
123
+ dispatch((0, import_store.updateState)({ manual: { ...manual, status: true, money: pay == null ? void 0 : pay.total } }));
134
124
  };
135
- return /* @__PURE__ */ import_react.default.createElement("div", { className: `pisell-lowcode__eft-pay-manual ${className}` }, isUpdateAmount ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-manual-edit-title" }, import_utils.locales.getText("page.eftpos-pay.text.manual.title")), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-manual-edit-body" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-manual-edit-text" }, import_utils.locales.getText("page.eftpos-pay.text.manual.subtitle")(
136
- formatAmount(pay == null ? void 0 : pay.total, 2, symbol)
137
- ), " ", /* @__PURE__ */ import_react.default.createElement("br", null), import_utils.locales.getText("page.eftpos-pay.text.manual.confirm"), /* @__PURE__ */ import_react.default.createElement("br", null), import_utils.locales.getText("page.eftpos-pay.text.manual.diff")), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-manual-edit-act" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-manual-edit-text" }, import_utils.locales.getText("page.eftpos-pay.text.manual.tip")), /* @__PURE__ */ import_react.default.createElement(
125
+ return /* @__PURE__ */ import_react.default.createElement("div", { className: `pisell-lowcode__eft-pay-manual ${className}` }, isUpdateAmount ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-manual-edit-title" }, import_utils.locales.getText("page.eftpos-pay.text.manual.title")), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-manual-edit-body" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-manual-edit-text" }, import_utils.locales.getText("page.eftpos-pay.text.manual.subtitle")(formatAmount(pay == null ? void 0 : pay.total, 2, symbol)), " ", /* @__PURE__ */ import_react.default.createElement("br", null), import_utils.locales.getText("page.eftpos-pay.text.manual.confirm"), /* @__PURE__ */ import_react.default.createElement("br", null), import_utils.locales.getText("page.eftpos-pay.text.manual.diff")), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-manual-edit-act" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-manual-edit-text" }, import_utils.locales.getText("page.eftpos-pay.text.manual.tip")), /* @__PURE__ */ import_react.default.createElement(
138
126
  import_antd.InputNumber,
139
127
  {
140
128
  type: "number",
@@ -173,9 +161,7 @@ var manual_default = ({ onChange, className = "", formatAmount }) => {
173
161
  type: "primary",
174
162
  onClick: onSubmit
175
163
  },
176
- import_utils.locales.getText("page.eftpos-pay.text.manual.btn.confirm")(
177
- formatAmount(money, 2, symbol)
178
- )
164
+ import_utils.locales.getText("page.eftpos-pay.text.manual.btn.confirm")(formatAmount(money, 2, symbol))
179
165
  ))) : /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-manual-title" }, manual == null ? void 0 : manual.title), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-manual-txt" }, manual == null ? void 0 : manual.text), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-manual-card-box" }, /* @__PURE__ */ import_react.default.createElement(
180
166
  "div",
181
167
  {
@@ -27,32 +27,6 @@ export declare enum ModeEnum {
27
27
  /** 查询 */
28
28
  Query = "query"
29
29
  }
30
- /**
31
- * 崩溃恢复
32
- */
33
- export declare enum RestoreEumn {
34
- /** 常规 */
35
- Normal = "normal",
36
- /** 恢复 */
37
- Restore = "restore"
38
- }
39
- /**
40
- * 订单状态
41
- */
42
- export declare enum OrderEumn {
43
- /** 恢复 */
44
- Restore = "restore",
45
- /** 常规 */
46
- Normal = "normal",
47
- /** 成功 */
48
- Succeed = "succeed",
49
- /** 失败 */
50
- Failed = "failed",
51
- /** 等待 */
52
- Pending = "pending",
53
- /** 没有订单状态 */
54
- Null = "null"
55
- }
56
30
  export declare enum ClientEnum {
57
31
  /** 用户端 */
58
32
  User = "user",
@@ -86,7 +60,7 @@ export interface PosProps {
86
60
  [key: string]: unknown;
87
61
  };
88
62
  /** 回调 */
89
- onChangeStatus: (status: `${StatusEnum.Success}` | `${StatusEnum.Fail}` | 'page' | 'print' | 'mark_tx_processed', params?: {
63
+ onChangeStatus: (status: `${StatusEnum.Success}` | `${StatusEnum.Fail}` | 'page', params?: {
90
64
  [keys: string]: unknown;
91
65
  } | string, other?: any) => void;
92
66
  onChangeParams(...agrn: unknown[]): void;
@@ -22,10 +22,8 @@ __export(const_exports, {
22
22
  ClientEnum: () => ClientEnum,
23
23
  EftposEnum: () => EftposEnum,
24
24
  ModeEnum: () => ModeEnum,
25
- OrderEumn: () => OrderEumn,
26
25
  PayRouteEnum: () => PayRouteEnum,
27
26
  PayStatus: () => PayStatus,
28
- RestoreEumn: () => RestoreEumn,
29
27
  RouteEnum: () => RouteEnum,
30
28
  StatusEnum: () => StatusEnum
31
29
  });
@@ -55,20 +53,6 @@ var ModeEnum = /* @__PURE__ */ ((ModeEnum2) => {
55
53
  ModeEnum2["Query"] = "query";
56
54
  return ModeEnum2;
57
55
  })(ModeEnum || {});
58
- var RestoreEumn = /* @__PURE__ */ ((RestoreEumn2) => {
59
- RestoreEumn2["Normal"] = "normal";
60
- RestoreEumn2["Restore"] = "restore";
61
- return RestoreEumn2;
62
- })(RestoreEumn || {});
63
- var OrderEumn = /* @__PURE__ */ ((OrderEumn2) => {
64
- OrderEumn2["Restore"] = "restore";
65
- OrderEumn2["Normal"] = "normal";
66
- OrderEumn2["Succeed"] = "succeed";
67
- OrderEumn2["Failed"] = "failed";
68
- OrderEumn2["Pending"] = "pending";
69
- OrderEumn2["Null"] = "null";
70
- return OrderEumn2;
71
- })(OrderEumn || {});
72
56
  var ClientEnum = /* @__PURE__ */ ((ClientEnum2) => {
73
57
  ClientEnum2["User"] = "user";
74
58
  ClientEnum2["Merchant"] = "merchant";
@@ -105,10 +89,8 @@ var PayStatus = /* @__PURE__ */ ((PayStatus2) => {
105
89
  ClientEnum,
106
90
  EftposEnum,
107
91
  ModeEnum,
108
- OrderEumn,
109
92
  PayRouteEnum,
110
93
  PayStatus,
111
- RestoreEumn,
112
94
  RouteEnum,
113
95
  StatusEnum
114
96
  });
@@ -11,7 +11,7 @@ import './device.less';
11
11
  declare const _default: ({ api, onChange, onClose, className, device_number, isMobile, net, client, formatAmount, }: {
12
12
  api: PayProps['api'];
13
13
  className?: string | undefined;
14
- onChange?: ((status: "page" | "success" | "fail" | "print" | "mark_tx_processed", params?: string | {
14
+ onChange?: ((status: "page" | "success" | "fail", params?: string | {
15
15
  [keys: string]: unknown;
16
16
  } | undefined, other?: any) => void) | undefined;
17
17
  onClose: () => void;
@@ -167,11 +167,11 @@ var device_default = ({
167
167
  role: "button",
168
168
  tabIndex: index
169
169
  },
170
- /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-device-content" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-device-name" }, name), mode === import_const.ModeEnum.Refund ? null : /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-device-money" }, pay.totalUnit), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-device-sucharge" }, import_utils.locales.getText(
170
+ /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-device-content" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-device-name" }, name), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-device-money" }, pay.totalUnit), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__eft-pay-device-sucharge" }, import_utils.locales.getText(
171
171
  "page.eftpos-pay.text.surcharge.edit.inc.surcharge"
172
172
  ), ": ", formatAmount(`${pay.surcharge}`, 2, symbol), " (", import_utils.locales.getText(
173
173
  "page.eftpos-pay.text.surcharge.edit.rate"
174
- ), ":", pay.surRate, "% +", " ", formatAmount(`${pay.surMoney}`, 2, symbol), ")"))),
174
+ ), ":", pay.surRate, "% +", " ", formatAmount(`${pay.surMoney}`, 2, symbol), ")")),
175
175
  /* @__PURE__ */ import_react.default.createElement("div", { style: { flexShrink: 0 } }, /* @__PURE__ */ import_react.default.createElement(
176
176
  import_ChevronRight.default,
177
177
  {
@@ -28,19 +28,16 @@ export declare const getPayParams: (data: Partial<Omit<State, key>> & Pick<State
28
28
  order_id: string | number;
29
29
  amount?: undefined;
30
30
  total?: undefined;
31
- receipt?: undefined;
32
31
  } | {
33
32
  cardReaderSurcharge: {};
34
33
  surMoney: string;
35
34
  surcharge: string;
36
35
  total: string;
37
36
  number: string | number | undefined;
38
- uniquePaymentNumber: string | number | undefined;
39
37
  device: {
40
38
  [key: string]: unknown;
41
39
  } | undefined;
42
40
  order_id: string | number;
43
- receipt: {};
44
41
  amount?: undefined;
45
42
  } | {
46
43
  amount: string | number;
@@ -50,14 +47,12 @@ export declare const getPayParams: (data: Partial<Omit<State, key>> & Pick<State
50
47
  [key: string]: unknown;
51
48
  } | undefined;
52
49
  order_id: string | number;
53
- receipt: {};
54
50
  } | {
55
51
  amount: string | number;
56
52
  total: string | number;
57
53
  number: string | number | undefined;
58
54
  order_id: string | number;
59
55
  device?: undefined;
60
- receipt?: undefined;
61
56
  };
62
57
  export declare const limitDecimals: (value: any) => any;
63
58
  /**
@@ -62,7 +62,7 @@ function cloneDeep(source, hash = /* @__PURE__ */ new WeakMap()) {
62
62
  return target;
63
63
  }
64
64
  var getPayParams = (data, statue) => {
65
- var _a, _b, _c, _d, _e, _f;
65
+ var _a;
66
66
  if (statue === "fail") {
67
67
  return {
68
68
  number: data.number,
@@ -70,10 +70,9 @@ var getPayParams = (data, statue) => {
70
70
  order_id: data.order_id
71
71
  };
72
72
  }
73
- const receipt = ((_a = data == null ? void 0 : data.custom) == null ? void 0 : _a.receipt) || [];
74
73
  if (data.mode === import_const.ModeEnum.Pay || data.mode === import_const.ModeEnum.FullPay) {
75
74
  const pay = data.pay;
76
- const card_reader_surcharge = ((_b = data.custom) == null ? void 0 : _b.card_reader_surcharge) || 0;
75
+ const card_reader_surcharge = ((_a = data.custom) == null ? void 0 : _a.card_reader_surcharge) || 0;
77
76
  const obj = pay || {};
78
77
  const cardReaderSurcharge = card_reader_surcharge;
79
78
  const surCardDeci = new import_decimal.Decimal(Number(cardReaderSurcharge));
@@ -90,10 +89,8 @@ var getPayParams = (data, statue) => {
90
89
  surcharge: surchargeDeci.toFixed(2, import_decimal.Decimal.ROUND_HALF_UP),
91
90
  total: total.toFixed(2, import_decimal.Decimal.ROUND_HALF_UP),
92
91
  number: data.number,
93
- uniquePaymentNumber: data.number,
94
92
  device: data.device,
95
- order_id: data.order_id,
96
- receipt: ((_d = (_c = data.device) == null ? void 0 : _c.setting) == null ? void 0 : _d.receipts) ? [] : receipt
93
+ order_id: data.order_id
97
94
  };
98
95
  }
99
96
  if (data.mode === import_const.ModeEnum.Refund) {
@@ -102,8 +99,7 @@ var getPayParams = (data, statue) => {
102
99
  total: data.amount,
103
100
  number: data.number,
104
101
  device: data.device,
105
- order_id: data.order_id,
106
- receipt: ((_f = (_e = data.device) == null ? void 0 : _e.setting) == null ? void 0 : _f.receipts) ? [] : receipt
102
+ order_id: data.order_id
107
103
  };
108
104
  }
109
105
  return {
@@ -21,7 +21,6 @@ export declare const useStoreRef: <T extends {
21
21
  readonly amountRef: React.MutableRefObject<string | number>;
22
22
  readonly eftposRef: React.MutableRefObject<"windcave" | "tyro" | "payo" | "stripe">;
23
23
  readonly clientRef: React.MutableRefObject<ClientEnum>;
24
- readonly dataRef: React.MutableRefObject<import("./store").State>;
25
24
  };
26
25
  /**
27
26
  * @title: 通用失败处理
@@ -30,7 +30,6 @@ var import_store = require("./store");
30
30
  var import_const2 = require("./const");
31
31
  var Max4004 = 1;
32
32
  var useStoreRef = () => {
33
- const data = (0, import_store.useContextData)();
34
33
  const {
35
34
  order_id,
36
35
  device,
@@ -43,8 +42,7 @@ var useStoreRef = () => {
43
42
  amount,
44
43
  eftpos,
45
44
  client
46
- } = data;
47
- const dataRef = (0, import_react.useRef)(data);
45
+ } = (0, import_store.useContextData)();
48
46
  const deviceRef = (0, import_react.useRef)(device);
49
47
  const payRef = (0, import_react.useRef)(pay);
50
48
  const numRef = (0, import_react.useRef)(number);
@@ -56,9 +54,6 @@ var useStoreRef = () => {
56
54
  const amountRef = (0, import_react.useRef)(amount);
57
55
  const eftposRef = (0, import_react.useRef)(eftpos);
58
56
  const clientRef = (0, import_react.useRef)(client);
59
- (0, import_react.useEffect)(() => {
60
- dataRef.current = data;
61
- }, [data]);
62
57
  (0, import_react.useEffect)(() => {
63
58
  deviceRef.current = device;
64
59
  }, [device]);
@@ -103,8 +98,7 @@ var useStoreRef = () => {
103
98
  symbolRef,
104
99
  amountRef,
105
100
  eftposRef,
106
- clientRef,
107
- dataRef
101
+ clientRef
108
102
  };
109
103
  };
110
104
  var useFail = (index) => {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { PosProps } from './const';
3
3
  import './index.less';
4
- declare const _default: (props: PosProps) => React.JSX.Element | null;
4
+ declare const _default: (props: PosProps) => React.JSX.Element;
5
5
  export default _default;
@@ -34,33 +34,67 @@ __export(eftposPay_exports, {
34
34
  module.exports = __toCommonJS(eftposPay_exports);
35
35
  var import_utils = require("@pisell/utils");
36
36
  var import_react = __toESM(require("react"));
37
+ var import_ahooks = require("ahooks");
37
38
  var import_useEngineContext = __toESM(require("../../hooks/useEngineContext"));
38
- var import_app = __toESM(require("./app"));
39
- var import_tip = __toESM(require("./tip"));
39
+ var import_amount = __toESM(require("./amount"));
40
40
  var import_const = require("./const");
41
+ var import_device = __toESM(require("./device"));
41
42
  var import_locales = __toESM(require("./locales"));
42
43
  var import_manufacturer = require("./manufacturer");
44
+ var import_pay = __toESM(require("./pay"));
43
45
  var import_store = require("./store");
44
46
  var import_index = require("./index.less");
45
47
  import_utils.locales.init(import_locales.default, localStorage.getItem("umi_locale") || "en");
46
- var eftposPay_default = (props) => {
47
- var _a, _b, _c, _d, _e, _f;
48
- const [check, setCheckStatus] = (0, import_react.useState)(
49
- props.type === import_const.EftposEnum.Tyro ? import_const.OrderEumn.Null : props.source === import_const.RestoreEumn.Restore ? import_const.OrderEumn.Restore : import_const.OrderEumn.Normal
50
- );
48
+ var App = ({
49
+ action,
50
+ getApi,
51
+ device_number,
52
+ terminal,
53
+ tyroUrl,
54
+ tyroVersion,
55
+ onChangeParams,
56
+ ...props
57
+ }) => {
58
+ var _a;
59
+ const data = (0, import_store.useContextData)();
60
+ const dispatch = (0, import_store.useDispatch)();
61
+ const [current, setCurrent] = (0, import_react.useState)(action);
62
+ const statusRef = (0, import_react.useRef)(data.status);
51
63
  const context = (0, import_useEngineContext.default)();
52
- const [cardSurcharge, setCardSurcharge] = (0, import_react.useState)(0);
53
- const [receipt, setReceipt] = (0, import_react.useState)([]);
54
- const [updateTime, setTime] = (0, import_react.useState)("");
55
64
  console.log("context = ", context);
56
- const [historyData, setHistory] = (0, import_react.useState)();
57
- const { formatAmount, storage, store } = ((_a = context.appHelper) == null ? void 0 : _a.utils) || {
58
- store: {},
59
- formatAmount: (number, precision, symbol2) => `${symbol2}${number}`,
65
+ const {
66
+ formatAmount,
67
+ storage
68
+ } = ((_a = context.appHelper) == null ? void 0 : _a.utils) || {
69
+ formatAmount: (number, precision, symbol) => `${symbol}${number}`,
60
70
  storage: () => ({
61
71
  get: () => ""
62
72
  })
63
73
  };
74
+ const network = (0, import_react.useMemo)(
75
+ () => typeof terminal.network === "boolean" ? terminal.network : true,
76
+ [terminal == null ? void 0 : terminal.network]
77
+ );
78
+ const { online } = (0, import_ahooks.useNetwork)();
79
+ const netRef = (0, import_react.useRef)([network, online]);
80
+ const net = (0, import_react.useMemo)(() => {
81
+ let networkChange = false, onlineChange = false;
82
+ if (netRef.current[0] !== network) {
83
+ netRef.current[0] = network;
84
+ networkChange = true;
85
+ }
86
+ if (netRef.current[1] !== online) {
87
+ netRef.current[1] = online;
88
+ onlineChange = true;
89
+ }
90
+ if (networkChange) {
91
+ return network;
92
+ }
93
+ return online;
94
+ }, [network, online]);
95
+ (0, import_react.useEffect)(() => {
96
+ statusRef.current = data.status;
97
+ }, [data.status]);
64
98
  const channel = (0, import_react.useMemo)(() => {
65
99
  var _a2;
66
100
  const channel2 = ((_a2 = storage == null ? void 0 : storage.get) == null ? void 0 : _a2.call(storage, "channel")) || "";
@@ -72,10 +106,99 @@ var eftposPay_default = (props) => {
72
106
  }
73
107
  return "";
74
108
  }, []);
109
+ const client = (0, import_react.useMemo)(() => {
110
+ if (channel === "kiosk") {
111
+ return import_const.ClientEnum.User;
112
+ }
113
+ return import_const.ClientEnum.Merchant;
114
+ }, [channel]);
115
+ (0, import_react.useEffect)(() => {
116
+ dispatch((0, import_store.updateClient)(client));
117
+ }, [client]);
75
118
  const isMobile = (0, import_react.useMemo)(() => Boolean(channel), [channel]);
119
+ const api = (0, import_react.useMemo)(() => {
120
+ if (typeof getApi === "function") {
121
+ return getApi();
122
+ }
123
+ return {};
124
+ }, [getApi]);
125
+ (0, import_react.useEffect)(() => {
126
+ onChangeParams && onChangeParams({
127
+ ...data,
128
+ ...data.eftpos === "tyro" ? { custom: { ...data.custom, btnList: [], list: [] } } : {},
129
+ form: "restore"
130
+ });
131
+ }, [data, onChangeParams]);
132
+ const onChange = (0, import_react.useCallback)((status, params, other) => {
133
+ if (status === "page" && typeof params === "string") {
134
+ if (["amount", "deviceList", "pay"].includes(params)) {
135
+ setCurrent(params);
136
+ dispatch((0, import_store.updateState)({ action: params }));
137
+ }
138
+ }
139
+ console.log("状态切换 = ", status, params, other);
140
+ props.onChangeStatus(status, params, other);
141
+ }, []);
142
+ const onClose = () => {
143
+ onChange("fail", {
144
+ number: data.number,
145
+ device: data.device,
146
+ order_id: data.order_id
147
+ });
148
+ };
149
+ if (current === import_const.RouteEnum.DeviceList) {
150
+ return /* @__PURE__ */ import_react.default.createElement(
151
+ import_device.default,
152
+ {
153
+ api,
154
+ onChange,
155
+ onClose,
156
+ isMobile,
157
+ className: isMobile ? "pisell-lowcode__eft-pay-terminal" : "",
158
+ net,
159
+ device_number,
160
+ formatAmount,
161
+ client
162
+ }
163
+ );
164
+ }
165
+ if (current === import_const.RouteEnum.Amount) {
166
+ return /* @__PURE__ */ import_react.default.createElement(
167
+ import_amount.default,
168
+ {
169
+ onChange,
170
+ onClose,
171
+ formatAmount,
172
+ isMobile,
173
+ className: isMobile ? "pisell-lowcode__eft-pay-terminal" : "",
174
+ net,
175
+ client
176
+ }
177
+ );
178
+ }
179
+ return /* @__PURE__ */ import_react.default.createElement(
180
+ import_pay.default,
181
+ {
182
+ api,
183
+ tyroUrl,
184
+ tyroVersion,
185
+ onChange,
186
+ className: isMobile ? "pisell-lowcode__eft-pay-terminal" : "",
187
+ terminal,
188
+ isMobile,
189
+ net,
190
+ formatAmount,
191
+ client
192
+ }
193
+ );
194
+ };
195
+ var eftposPay_default = (props) => {
196
+ var _a, _b, _c, _d, _e, _f;
197
+ const context = (0, import_useEngineContext.default)();
198
+ const { store } = ((_a = context.appHelper) == null ? void 0 : _a.utils) || { store: {} };
76
199
  const symbol = ((_d = (_c = (_b = store == null ? void 0 : store.getState) == null ? void 0 : _b.call(store)) == null ? void 0 : _c.global) == null ? void 0 : _d.symbol) || "$";
77
200
  const mode = (0, import_react.useMemo)(() => {
78
- if (props.source === import_const.RestoreEumn.Restore) {
201
+ if (props.source === "restore") {
79
202
  if (props.params) {
80
203
  if (props.params.mode) {
81
204
  return props.params.mode;
@@ -90,7 +213,7 @@ var eftposPay_default = (props) => {
90
213
  }, [props.mode, props.source, props.params]);
91
214
  const state = (0, import_react.useMemo)(() => {
92
215
  const current = props.params && props.params.symbol ? props.params.symbol : symbol;
93
- if (props.source === import_const.RestoreEumn.Restore) {
216
+ if (props.source === "restore") {
94
217
  return props.params;
95
218
  }
96
219
  return (0, import_manufacturer.getInitState)(
@@ -98,10 +221,6 @@ var eftposPay_default = (props) => {
98
221
  props.params ? { mode, ...props.params, symbol: current } : { mode, symbol: current }
99
222
  );
100
223
  }, [mode, props.params, props.type, symbol]);
101
- const stateRef = (0, import_react.useRef)(state);
102
- (0, import_react.useEffect)(() => {
103
- stateRef.current = state;
104
- }, [state]);
105
224
  const onChangeStatus = (0, import_react.useCallback)(
106
225
  (status, params, other) => {
107
226
  props.onChangeStatus(status, params, other);
@@ -137,103 +256,22 @@ var eftposPay_default = (props) => {
137
256
  return act;
138
257
  }, [mode, state]);
139
258
  (0, import_react.useEffect)(() => {
140
- document.body.id = "body";
141
259
  console.log("初始化 ........11221801");
142
260
  }, []);
143
261
  console.log("props?.params?.device_number = ", (_e = props == null ? void 0 : props.params) == null ? void 0 : _e.device_number);
144
- const api = (0, import_react.useMemo)(() => {
145
- if (typeof props.getApi === "function") {
146
- return props.getApi();
147
- }
148
- return {};
149
- }, [props.getApi]);
150
- (0, import_react.useEffect)(() => {
151
- if (props.source === import_const.RestoreEumn.Restore || props.type === import_const.EftposEnum.Tyro) {
152
- return;
153
- }
154
- api.getTransaction({
155
- order_id: stateRef.current.order_id,
156
- card_reader_type: stateRef.current.eftpos,
157
- receive_status: "unprocessed"
158
- }).then((res) => {
159
- if (!Array.isArray(res.data) || res.data.length === 0) {
160
- setCheckStatus(import_const.OrderEumn.Null);
161
- return;
162
- }
163
- const currentMode = stateRef.current.mode === import_const.ModeEnum.FullPay ? import_const.ModeEnum.Pay : stateRef.current.mode;
164
- const list = res.data.filter(
165
- (item) => item.action === currentMode
166
- );
167
- if (list.length === 0) {
168
- setCheckStatus(import_const.OrderEumn.Null);
169
- return;
170
- }
171
- const latest = list.pop();
172
- const numberList = list.map((item) => item.number);
173
- if (latest.status === import_const.OrderEumn.Failed) {
174
- setCheckStatus(latest.status);
175
- onChangeStatus("mark_tx_processed", [
176
- ...numberList,
177
- latest.number
178
- ]);
179
- return;
180
- }
181
- if (list.length > 0) {
182
- onChangeStatus("mark_tx_processed", numberList);
183
- }
184
- const { pay_param_base64, card_reader_surcharge, receipt: receipt2 } = (latest == null ? void 0 : latest.metadata) || {};
185
- setTime(latest.updated_at);
186
- setCardSurcharge(card_reader_surcharge || 0);
187
- setReceipt(receipt2 || []);
188
- if (!pay_param_base64) {
189
- setCheckStatus(import_const.OrderEumn.Failed);
190
- return;
191
- }
192
- try {
193
- const data = JSON.parse(
194
- decodeURIComponent(atob(decodeURIComponent(pay_param_base64)))
195
- );
196
- setHistory(data);
197
- setCheckStatus(latest.status);
198
- } catch (e) {
199
- setCheckStatus(import_const.OrderEumn.Failed);
200
- return;
201
- }
202
- });
203
- }, []);
204
- if (check === import_const.OrderEumn.Normal) {
205
- return null;
206
- }
207
- if (check === import_const.OrderEumn.Succeed) {
208
- return /* @__PURE__ */ import_react.default.createElement(import_store.Provider, { state: historyData }, /* @__PURE__ */ import_react.default.createElement(
209
- import_tip.default,
210
- {
211
- cardSurcharge,
212
- receipts: receipt,
213
- onChangeStatus,
214
- onChangeParams: props.onChangeParams,
215
- formatAmount,
216
- successTime: updateTime,
217
- className: isMobile ? "pisell-lowcode__eft-pay-terminal" : ""
218
- }
219
- ));
220
- }
221
- return /* @__PURE__ */ import_react.default.createElement(import_store.Provider, { state: check === import_const.OrderEumn.Pending ? historyData : state }, /* @__PURE__ */ import_react.default.createElement(
222
- import_app.default,
262
+ return /* @__PURE__ */ import_react.default.createElement(import_store.Provider, { state }, /* @__PURE__ */ import_react.default.createElement(
263
+ App,
223
264
  {
224
- api,
225
- channel,
265
+ getApi: props.getApi,
226
266
  params: props.params,
227
267
  onChangeStatus,
228
268
  terminal: props.terminal,
229
269
  onChangeParams: props.onChangeParams,
230
- action: check === import_const.OrderEumn.Pending ? import_const.ModeEnum.Pay : action,
270
+ action,
231
271
  source: props.source,
232
272
  tyroUrl: props.tyroUrl,
233
273
  tyroVersion: props.tyroVersion,
234
- device_number: (_f = props == null ? void 0 : props.params) == null ? void 0 : _f.device_number,
235
- isMobile,
236
- formatAmount
274
+ device_number: (_f = props == null ? void 0 : props.params) == null ? void 0 : _f.device_number
237
275
  }
238
276
  ));
239
277
  };
@@ -54,11 +54,6 @@ declare const _default: {
54
54
  'page.eftpos-pay.text.sure': string;
55
55
  'page.eftpos-pay.text.device': string;
56
56
  'page.eftpos-pay.text.leave': string;
57
- 'page.eftpos-pay.text.latest.success': string;
58
- 'page.eftpos-pay.text.latest.amount': string;
59
- 'page.eftpos-pay.text.latest.surcharge': string;
60
- 'page.eftpos-pay.text.latest.time': string;
61
- 'page.eftpos-pay.text.latest.confirm': string;
62
57
  'page.eftpos-pay.text.amount.to.pay': string;
63
58
  'page.eftpos-pay.text.surcharge.percentage': string;
64
59
  'page.eftpos-pay.text.surcharge.fixed': string;
@@ -163,11 +158,6 @@ declare const _default: {
163
158
  'page.eftpos-pay.text.sure': string;
164
159
  'page.eftpos-pay.text.device': string;
165
160
  'page.eftpos-pay.text.leave': string;
166
- 'page.eftpos-pay.text.latest.success': string;
167
- 'page.eftpos-pay.text.latest.amount': string;
168
- 'page.eftpos-pay.text.latest.surcharge': string;
169
- 'page.eftpos-pay.text.latest.time': string;
170
- 'page.eftpos-pay.text.latest.confirm': string;
171
161
  'page.eftpos-pay.text.amount.to.pay': string;
172
162
  'page.eftpos-pay.text.surcharge.percentage': string;
173
163
  'page.eftpos-pay.text.surcharge.fixed': string;
@@ -272,11 +262,6 @@ declare const _default: {
272
262
  'page.eftpos-pay.text.sure': string;
273
263
  'page.eftpos-pay.text.device': string;
274
264
  'page.eftpos-pay.text.leave': string;
275
- 'page.eftpos-pay.text.latest.success': string;
276
- 'page.eftpos-pay.text.latest.amount': string;
277
- 'page.eftpos-pay.text.latest.surcharge': string;
278
- 'page.eftpos-pay.text.latest.time': string;
279
- 'page.eftpos-pay.text.latest.confirm': string;
280
265
  'page.eftpos-pay.text.amount.to.pay': string;
281
266
  'page.eftpos-pay.text.surcharge.percentage': string;
282
267
  'page.eftpos-pay.text.surcharge.fixed': string;