@pisell/private-materials 6.6.61 → 6.6.63

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 (203) 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 +9 -9
  11. package/es/components/booking/components/footer/amount.js +4 -3
  12. package/es/components/booking/components/footer/utils.js +10 -3
  13. package/es/components/booking/components/voucher/index.js +1 -1
  14. package/es/components/booking/info2/service/editService/index.js +76 -8
  15. package/es/components/booking/info2/service/editService/utils.d.ts +1 -0
  16. package/es/components/booking/info2/service/editService/utils.js +16 -0
  17. package/es/components/booking/payments/index.js +1 -1
  18. package/es/components/eftpos/PairModal/hooks.d.ts +27 -0
  19. package/es/components/eftpos/PairModal/hooks.js +67 -0
  20. package/es/components/eftpos/PairModal/index.d.ts +11 -0
  21. package/es/components/eftpos/PairModal/index.js +246 -0
  22. package/es/components/eftpos/PairModal/index.less +70 -0
  23. package/es/components/eftpos/SettlementModal/Action.d.ts +7 -0
  24. package/es/components/eftpos/SettlementModal/Action.js +141 -0
  25. package/es/components/eftpos/SettlementModal/index.d.ts +7 -0
  26. package/es/components/eftpos/SettlementModal/index.js +135 -0
  27. package/es/components/eftpos/SettlementModal/index.less +33 -0
  28. package/es/components/eftpos/SettlementModal/serve.d.ts +8 -0
  29. package/es/components/eftpos/SettlementModal/serve.js +171 -0
  30. package/es/components/eftpos/SettlementModal/types.d.ts +138 -0
  31. package/es/components/eftpos/SettlementModal/types.js +35 -0
  32. package/es/components/eftpos/SettlementModal/utils.d.ts +18 -0
  33. package/es/components/eftpos/SettlementModal/utils.js +351 -0
  34. package/es/components/eftpos/assets/mx51SCI.svg +15 -0
  35. package/es/components/eftpos/const.d.ts +3 -1
  36. package/es/components/eftpos/const.js +2 -0
  37. package/es/components/eftpos/device.d.ts +3 -1
  38. package/es/components/eftpos/device.js +14 -3
  39. package/es/components/eftpos/hooks.d.ts +13 -0
  40. package/es/components/eftpos/hooks.js +35 -0
  41. package/es/components/eftpos/index.js +198 -24
  42. package/es/components/eftpos/index.less +32 -1
  43. package/es/components/eftpos/locales.d.ts +80 -0
  44. package/es/components/eftpos/locales.js +205 -25
  45. package/es/components/eftpos/table.js +47 -3
  46. package/es/components/eftposPay/aggregatePayment/hooks/useMicropay.d.ts +2 -2
  47. package/es/components/eftposPay/aggregatePayment/hooks/usePayment.d.ts +8 -0
  48. package/es/components/eftposPay/aggregatePayment/hooks/usePayment.js +145 -0
  49. package/es/components/eftposPay/aggregatePayment/index.d.ts +2 -1
  50. package/es/components/eftposPay/aggregatePayment/index.js +2 -1
  51. package/es/components/eftposPay/aggregatePayment/mock.d.ts +495 -0
  52. package/es/components/eftposPay/aggregatePayment/mock.js +567 -0
  53. package/es/components/eftposPay/aggregatePayment/service.js +1 -0
  54. package/es/components/eftposPay/aggregatePayment/types.d.ts +12 -12
  55. package/es/components/eftposPay/aggregatePayment/types.js +4 -8
  56. package/es/components/eftposPay/aggregatePayment/utils/payment.d.ts +13 -13
  57. package/es/components/eftposPay/aggregatePayment/utils/payment.js +231 -168
  58. package/es/components/eftposPay/amount.js +15 -1
  59. package/es/components/eftposPay/app.js +2 -3
  60. package/es/components/eftposPay/component/fail/failCustom.js +13 -4
  61. package/es/components/eftposPay/component/fail/index.js +12 -5
  62. package/es/components/eftposPay/component/fail/network.js +3 -0
  63. package/es/components/eftposPay/component/fail/unknow.js +8 -0
  64. package/es/components/eftposPay/component/manual/index.js +17 -3
  65. package/es/components/eftposPay/component/signature/index.js +3 -0
  66. package/es/components/eftposPay/const.d.ts +8 -3
  67. package/es/components/eftposPay/const.js +2 -0
  68. package/es/components/eftposPay/device.js +225 -38
  69. package/es/components/eftposPay/helper.d.ts +3 -0
  70. package/es/components/eftposPay/helper.js +2 -1
  71. package/es/components/eftposPay/hooks.d.ts +1 -1
  72. package/es/components/eftposPay/index.js +50 -13
  73. package/es/components/eftposPay/linkly/const.js +1 -1
  74. package/es/components/eftposPay/linkly/hooks/normal.js +21 -68
  75. package/es/components/eftposPay/linkly/hooks/useTimeQuery.js +20 -81
  76. package/es/components/eftposPay/linkly/index.js +11 -23
  77. package/es/components/eftposPay/locales.d.ts +15 -0
  78. package/es/components/eftposPay/locales.js +30 -15
  79. package/es/components/eftposPay/manufacturer.d.ts +1 -0
  80. package/es/components/eftposPay/manufacturer.js +4 -0
  81. package/es/components/eftposPay/mx51/Action.d.ts +6 -0
  82. package/es/components/eftposPay/mx51/Action.js +144 -0
  83. package/es/components/eftposPay/mx51/const.d.ts +5 -0
  84. package/es/components/eftposPay/mx51/const.js +69 -0
  85. package/es/components/eftposPay/mx51/index.d.ts +6 -0
  86. package/es/components/eftposPay/mx51/index.js +498 -0
  87. package/es/components/eftposPay/mx51/types.d.ts +142 -0
  88. package/es/components/eftposPay/mx51/types.js +35 -0
  89. package/es/components/eftposPay/mx51/utils.d.ts +10 -0
  90. package/es/components/eftposPay/mx51/utils.js +121 -0
  91. package/es/components/eftposPay/pay.js +21 -9
  92. package/es/components/eftposPay/payo/config.js +39 -5
  93. package/es/components/eftposPay/payo/const.js +1 -1
  94. package/es/components/eftposPay/payo/hooks.js +3 -12
  95. package/es/components/eftposPay/payo/payment.js +69 -136
  96. package/es/components/eftposPay/store/index.d.ts +5 -9
  97. package/es/components/eftposPay/tip.js +5 -0
  98. package/es/components/eftposPay/tyro/const.js +1 -1
  99. package/es/components/eftposPay/tyro/index.js +44 -11
  100. package/es/components/eftposPay/utils/payLog.d.ts +81 -0
  101. package/es/components/eftposPay/utils/payLog.js +458 -0
  102. package/es/components/eftposPay/windcave/const.js +1 -1
  103. package/es/components/eftposPay/windcave/receiptAction.js +5 -0
  104. package/es/components/eftposPay/windcave/windcave.js +37 -38
  105. package/es/components/ticketBooking/utils/formatProductMessage.js +47 -2
  106. package/lib/components/booking/components/footer/amount.js +3 -3
  107. package/lib/components/booking/components/footer/utils.js +12 -5
  108. package/lib/components/booking/components/voucher/index.js +1 -1
  109. package/lib/components/booking/info2/service/editService/index.js +56 -5
  110. package/lib/components/booking/info2/service/editService/utils.d.ts +1 -0
  111. package/lib/components/booking/info2/service/editService/utils.js +16 -0
  112. package/lib/components/booking/payments/index.js +1 -1
  113. package/lib/components/eftpos/PairModal/hooks.d.ts +27 -0
  114. package/lib/components/eftpos/PairModal/hooks.js +70 -0
  115. package/lib/components/eftpos/PairModal/index.d.ts +11 -0
  116. package/lib/components/eftpos/PairModal/index.js +197 -0
  117. package/lib/components/eftpos/PairModal/index.less +70 -0
  118. package/lib/components/eftpos/SettlementModal/Action.d.ts +7 -0
  119. package/lib/components/eftpos/SettlementModal/Action.js +153 -0
  120. package/lib/components/eftpos/SettlementModal/index.d.ts +7 -0
  121. package/lib/components/eftpos/SettlementModal/index.js +170 -0
  122. package/lib/components/eftpos/SettlementModal/index.less +33 -0
  123. package/lib/components/eftpos/SettlementModal/serve.d.ts +8 -0
  124. package/lib/components/eftpos/SettlementModal/serve.js +45 -0
  125. package/lib/components/eftpos/SettlementModal/types.d.ts +138 -0
  126. package/lib/components/eftpos/SettlementModal/types.js +43 -0
  127. package/lib/components/eftpos/SettlementModal/utils.d.ts +18 -0
  128. package/lib/components/eftpos/SettlementModal/utils.js +248 -0
  129. package/lib/components/eftpos/assets/mx51SCI.svg +15 -0
  130. package/lib/components/eftpos/const.d.ts +3 -1
  131. package/lib/components/eftpos/const.js +2 -0
  132. package/lib/components/eftpos/device.d.ts +3 -1
  133. package/lib/components/eftpos/device.js +13 -3
  134. package/lib/components/eftpos/hooks.d.ts +13 -0
  135. package/lib/components/eftpos/hooks.js +30 -0
  136. package/lib/components/eftpos/index.js +121 -8
  137. package/lib/components/eftpos/index.less +32 -1
  138. package/lib/components/eftpos/locales.d.ts +80 -0
  139. package/lib/components/eftpos/locales.js +231 -21
  140. package/lib/components/eftpos/table.js +30 -2
  141. package/lib/components/eftposPay/aggregatePayment/hooks/useMicropay.d.ts +2 -2
  142. package/lib/components/eftposPay/aggregatePayment/hooks/usePayment.d.ts +8 -0
  143. package/lib/components/eftposPay/aggregatePayment/hooks/usePayment.js +171 -0
  144. package/lib/components/eftposPay/aggregatePayment/index.d.ts +2 -1
  145. package/lib/components/eftposPay/aggregatePayment/index.js +5 -2
  146. package/lib/components/eftposPay/aggregatePayment/mock.d.ts +495 -0
  147. package/lib/components/eftposPay/aggregatePayment/mock.js +679 -0
  148. package/lib/components/eftposPay/aggregatePayment/types.d.ts +12 -12
  149. package/lib/components/eftposPay/aggregatePayment/utils/payment.d.ts +13 -13
  150. package/lib/components/eftposPay/aggregatePayment/utils/payment.js +173 -123
  151. package/lib/components/eftposPay/amount.js +13 -1
  152. package/lib/components/eftposPay/app.js +4 -5
  153. package/lib/components/eftposPay/component/fail/failCustom.js +10 -2
  154. package/lib/components/eftposPay/component/fail/index.js +10 -2
  155. package/lib/components/eftposPay/component/fail/network.js +3 -0
  156. package/lib/components/eftposPay/component/fail/unknow.js +8 -0
  157. package/lib/components/eftposPay/component/manual/index.js +16 -2
  158. package/lib/components/eftposPay/component/signature/index.js +3 -0
  159. package/lib/components/eftposPay/const.d.ts +8 -3
  160. package/lib/components/eftposPay/const.js +2 -0
  161. package/lib/components/eftposPay/device.js +114 -25
  162. package/lib/components/eftposPay/helper.d.ts +3 -0
  163. package/lib/components/eftposPay/helper.js +2 -1
  164. package/lib/components/eftposPay/hooks.d.ts +1 -1
  165. package/lib/components/eftposPay/index.js +38 -13
  166. package/lib/components/eftposPay/linkly/const.js +1 -1
  167. package/lib/components/eftposPay/linkly/hooks/normal.js +22 -43
  168. package/lib/components/eftposPay/linkly/hooks/useTimeQuery.js +13 -65
  169. package/lib/components/eftposPay/linkly/index.js +8 -10
  170. package/lib/components/eftposPay/locales.d.ts +15 -0
  171. package/lib/components/eftposPay/locales.js +30 -15
  172. package/lib/components/eftposPay/manufacturer.d.ts +1 -0
  173. package/lib/components/eftposPay/manufacturer.js +6 -0
  174. package/lib/components/eftposPay/mx51/Action.d.ts +6 -0
  175. package/lib/components/eftposPay/mx51/Action.js +154 -0
  176. package/lib/components/eftposPay/mx51/const.d.ts +5 -0
  177. package/lib/components/eftposPay/mx51/const.js +85 -0
  178. package/lib/components/eftposPay/mx51/index.d.ts +6 -0
  179. package/lib/components/eftposPay/mx51/index.js +433 -0
  180. package/lib/components/eftposPay/mx51/types.d.ts +142 -0
  181. package/lib/components/eftposPay/mx51/types.js +43 -0
  182. package/lib/components/eftposPay/mx51/utils.d.ts +10 -0
  183. package/lib/components/eftposPay/mx51/utils.js +115 -0
  184. package/lib/components/eftposPay/pay.js +13 -3
  185. package/lib/components/eftposPay/payo/config.js +16 -8
  186. package/lib/components/eftposPay/payo/const.js +1 -1
  187. package/lib/components/eftposPay/payo/hooks.js +12 -10
  188. package/lib/components/eftposPay/payo/payment.js +31 -65
  189. package/lib/components/eftposPay/store/index.d.ts +5 -9
  190. package/lib/components/eftposPay/tip.js +5 -0
  191. package/lib/components/eftposPay/tyro/const.js +1 -1
  192. package/lib/components/eftposPay/tyro/index.js +21 -17
  193. package/lib/components/eftposPay/utils/payLog.d.ts +81 -0
  194. package/lib/components/eftposPay/utils/payLog.js +321 -0
  195. package/lib/components/eftposPay/windcave/const.js +1 -1
  196. package/lib/components/eftposPay/windcave/receiptAction.js +5 -0
  197. package/lib/components/eftposPay/windcave/windcave.js +27 -29
  198. package/lib/components/ticketBooking/utils/formatProductMessage.js +44 -2
  199. package/package.json +4 -4
  200. package/es/components/eftposPay/utils/log/index.d.ts +0 -110
  201. package/es/components/eftposPay/utils/log/index.js +0 -371
  202. package/lib/components/eftposPay/utils/log/index.d.ts +0 -110
  203. package/lib/components/eftposPay/utils/log/index.js +0 -294
@@ -32,11 +32,30 @@ __export(payment_exports, {
32
32
  default: () => payment_default
33
33
  });
34
34
  module.exports = __toCommonJS(payment_exports);
35
+ var import_utils = require("@pisell/utils");
35
36
  var import_const = require("../../const");
36
- var import_logs = __toESM(require("./logs"));
37
+ var import_payLog = __toESM(require("../../utils/payLog"));
37
38
  var import_service = require("../service");
38
39
  var import_helper = require("../../helper");
39
40
  var import_types = require("../types");
41
+ var sanitizePaymentLogContent = (content) => {
42
+ var _a, _b;
43
+ if (!content || typeof content !== "object") {
44
+ return content;
45
+ }
46
+ if (!((_b = (_a = content.params) == null ? void 0 : _a.eftpos) == null ? void 0 : _b.pay_param_base64)) {
47
+ return content;
48
+ }
49
+ const clonedContent = (0, import_helper.cloneDeep)(content);
50
+ delete clonedContent.params.eftpos.pay_param_base64;
51
+ return clonedContent;
52
+ };
53
+ var addPaymentLog = ({ title, content }) => {
54
+ import_payLog.default.log(title, sanitizePaymentLogContent(content));
55
+ };
56
+ var paymentLog = {
57
+ addLog: addPaymentLog
58
+ };
40
59
  var PaymentMethod = class {
41
60
  /** 初始化参数 */
42
61
  initOptions;
@@ -44,8 +63,6 @@ var PaymentMethod = class {
44
63
  paymentNum;
45
64
  // 订单ID
46
65
  orderId;
47
- // 设备ID
48
- deviceId;
49
66
  // 统一回调函数
50
67
  callback;
51
68
  // 检查是否应该继续处理结果
@@ -80,14 +97,19 @@ var PaymentMethod = class {
80
97
  this.initOptions = options;
81
98
  this.paymentNum = options.paymentNum;
82
99
  this.orderId = options.orderId;
83
- this.deviceId = options.deviceId;
84
100
  this.callback = options.callback;
85
101
  this.shouldContinue = options.shouldContinue || (() => true);
86
102
  this.config = options.config || {};
87
- import_logs.default.init(this.paymentNum, {
88
- orderId: this.orderId,
89
- deviceId: this.deviceId,
90
- paymentCode: (options == null ? void 0 : options.paymentCode) || ""
103
+ import_payLog.default.setContext({
104
+ transactionNumber: this.paymentNum,
105
+ extra: { paymentCode: (options == null ? void 0 : options.paymentCode) || "" }
106
+ });
107
+ addPaymentLog({
108
+ title: "聚合支付初始化",
109
+ content: {
110
+ paymentNum: this.paymentNum,
111
+ paymentCode: (options == null ? void 0 : options.paymentCode) || ""
112
+ }
91
113
  });
92
114
  }
93
115
  /**
@@ -95,8 +117,24 @@ var PaymentMethod = class {
95
117
  * 1. 有明确错误code且不是超时和支付超时,则直接失败
96
118
  * @param code 错误码
97
119
  */
98
- isRequestFailed(code) {
99
- return code && `${code}` !== import_const.PayStatus.Timeout && `${code}` !== import_const.PayStatus.PayTimeout;
120
+ isBusinessFailed(res) {
121
+ var _a;
122
+ const { external_unified_status, response_code } = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.external_unified_response) || {};
123
+ return `${res == null ? void 0 : res.code}` === "200" && external_unified_status === import_types.EPaymentStatus.Failed && response_code !== import_const.PayStatus.Timeout && response_code !== import_const.PayStatus.PayTimeout;
124
+ }
125
+ /**
126
+ * 判断业务是否成功
127
+ */
128
+ isBusinessSuccess(res) {
129
+ var _a;
130
+ const { external_unified_status } = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.external_unified_response) || {};
131
+ return `${res == null ? void 0 : res.code}` === "200" && external_unified_status === import_types.EPaymentStatus.Success;
132
+ }
133
+ /**
134
+ * 判断最外层code是否是超时错误
135
+ */
136
+ isOuterCodeTimeout(code) {
137
+ return code && (`${code}` === import_const.PayStatus.Timeout || `${code}` === import_const.PayStatus.PayTimeout);
100
138
  }
101
139
  /**
102
140
  * 清理定时器和请求控制器
@@ -147,7 +185,7 @@ var PaymentMethod = class {
147
185
  startNewOperation(actionType) {
148
186
  const runId = (0, import_helper.getUuid)();
149
187
  this.currentRunId = runId;
150
- import_logs.default.addLog({
188
+ paymentLog.addLog({
151
189
  title: `触发新的操作:${actionType}`,
152
190
  content: { actionType, runId }
153
191
  });
@@ -171,7 +209,7 @@ var PaymentMethod = class {
171
209
  });
172
210
  } catch (error) {
173
211
  console.error("⚠️ 回调执行出错:", error);
174
- import_logs.default.addLog({ title: "回调执行出错", content: error });
212
+ paymentLog.addLog({ title: "回调执行出错", content: error });
175
213
  }
176
214
  }
177
215
  /**
@@ -179,14 +217,14 @@ var PaymentMethod = class {
179
217
  */
180
218
  handleOperationSuccess(res) {
181
219
  if (this.isFinished || !this.shouldContinue() || !this.currentActionType) {
182
- import_logs.default.addLog({
220
+ paymentLog.addLog({
183
221
  title: "操作结果:已完成或不应继续处理,忽略操作成功结果",
184
222
  content: { actionType: this.currentActionType, res }
185
223
  });
186
224
  return;
187
225
  }
188
226
  const actionType = this.currentActionType;
189
- import_logs.default.addLog({
227
+ paymentLog.addLog({
190
228
  title: "操作结果:成功",
191
229
  content: { actionType, res }
192
230
  });
@@ -199,7 +237,7 @@ var PaymentMethod = class {
199
237
  });
200
238
  } catch (error) {
201
239
  console.error("⚠️ 回调执行出错:", error);
202
- import_logs.default.addLog({ title: "回调执行出错", content: error });
240
+ paymentLog.addLog({ title: "回调执行出错", content: error });
203
241
  }
204
242
  }
205
243
  /**
@@ -212,7 +250,7 @@ var PaymentMethod = class {
212
250
  return;
213
251
  }
214
252
  const actionType = this.currentActionType;
215
- import_logs.default.addLog({
253
+ paymentLog.addLog({
216
254
  title: "操作结果:失败",
217
255
  content: { actionType, error }
218
256
  });
@@ -225,7 +263,7 @@ var PaymentMethod = class {
225
263
  });
226
264
  } catch (err) {
227
265
  console.error("⚠️ 回调执行出错:", err);
228
- import_logs.default.addLog({ title: "回调执行出错", content: err });
266
+ paymentLog.addLog({ title: "回调执行出错", content: err });
229
267
  }
230
268
  }
231
269
  /**
@@ -275,13 +313,13 @@ var PaymentMethod = class {
275
313
  async performQuery(actionType) {
276
314
  var _a, _b;
277
315
  if (this.isFinished || !this.shouldContinue()) {
278
- import_logs.default.addLog({
316
+ paymentLog.addLog({
279
317
  title: "查询前置校验:已完成或不应继续处理,取消查询"
280
318
  });
281
319
  return;
282
320
  }
283
321
  if (!this.currentQueryApi) {
284
- import_logs.default.addLog({ title: "查询API未设置,取消查询" });
322
+ paymentLog.addLog({ title: "查询API未设置,取消查询" });
285
323
  return;
286
324
  }
287
325
  if (this.queryController) {
@@ -296,7 +334,7 @@ var PaymentMethod = class {
296
334
  this.currentQueryId = queryId;
297
335
  this.queryController = new AbortController();
298
336
  const { signal } = this.queryController;
299
- import_logs.default.addLog({ title: "查询轮询:开始单次查询" });
337
+ paymentLog.addLog({ title: "查询轮询:开始单次查询" });
300
338
  try {
301
339
  const res = await Promise.race([
302
340
  this.currentQueryApi(
@@ -305,13 +343,14 @@ var PaymentMethod = class {
305
343
  unique_payment_number: this.paymentNum,
306
344
  payment_code: (_a = this.initOptions) == null ? void 0 : _a.paymentCode,
307
345
  request_version: queryId,
308
- is_outer_response_info: 1
346
+ // TODO: MX51审核需要,后续需要删除
347
+ is_force_request_api: 1
309
348
  },
310
349
  { signal }
311
350
  ),
312
351
  this.createTimeoutPromise(import_types.REQUEST_TIMEOUT)
313
352
  ]);
314
- import_logs.default.addLog({
353
+ paymentLog.addLog({
315
354
  title: "查询轮询:单次查询返回",
316
355
  content: { actionType, res }
317
356
  });
@@ -320,32 +359,38 @@ var PaymentMethod = class {
320
359
  this.requestTimeoutTimer = null;
321
360
  }
322
361
  if (((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.request_version) !== this.currentQueryId) {
323
- import_logs.default.addLog({ title: "查询轮询结果:过期的查询响应,忽略" });
362
+ paymentLog.addLog({ title: "查询轮询结果:过期的查询响应,忽略" });
324
363
  return;
325
364
  }
326
365
  if (this.isFinished || !this.shouldContinue()) {
327
- import_logs.default.addLog({ title: "查询轮询结果:已完成或不应继续处理" });
366
+ paymentLog.addLog({ title: "查询轮询结果:已完成或不应继续处理" });
328
367
  return;
329
368
  }
330
- if (res && `${res.code}` === "200") {
331
- import_logs.default.addLog({ title: "查询轮询结果:查询成功" });
369
+ if (`${res == null ? void 0 : res.code}` !== "200") {
370
+ paymentLog.addLog({ title: "查询轮询结果:查询返回失败,code非200" });
371
+ this.handleOperationError(res);
372
+ return;
373
+ }
374
+ if (this.isBusinessSuccess(res)) {
375
+ paymentLog.addLog({ title: "查询轮询结果:查询成功" });
332
376
  const needContinue = this.handleResponse(res);
333
377
  if (needContinue) {
334
378
  this.scheduleNextQuery(actionType);
335
379
  }
336
380
  return;
337
381
  }
338
- if (this.isRequestFailed(res == null ? void 0 : res.code)) {
339
- import_logs.default.addLog({
382
+ if (this.isBusinessFailed(res)) {
383
+ paymentLog.addLog({
340
384
  title: "查询轮询结果:有明确错误code,停止轮询",
341
385
  content: res
342
386
  });
343
387
  this.handleOperationError(res);
344
388
  } else {
345
- import_logs.default.addLog({
346
- title: "查询轮询结果:查询返回失败但没有明确code或超时code,继续轮询",
389
+ paymentLog.addLog({
390
+ title: "查询轮询结果:交易进行中,继续轮询",
347
391
  content: res
348
392
  });
393
+ this.handleOperationProcess(res);
349
394
  this.scheduleNextQuery(actionType);
350
395
  }
351
396
  } catch (error) {
@@ -354,7 +399,7 @@ var PaymentMethod = class {
354
399
  this.requestTimeoutTimer = null;
355
400
  }
356
401
  if (queryId !== this.currentQueryId) {
357
- import_logs.default.addLog({
402
+ paymentLog.addLog({
358
403
  title: "查询轮询结果:error-过期的查询异常,忽略"
359
404
  });
360
405
  return;
@@ -363,24 +408,25 @@ var PaymentMethod = class {
363
408
  return;
364
409
  }
365
410
  if ((error == null ? void 0 : error.name) === "AbortError" || (error == null ? void 0 : error.message) === "REQUEST_TIMEOUT") {
366
- import_logs.default.addLog({
411
+ paymentLog.addLog({
367
412
  title: "查询轮询结果:error-请求被取消或超时,继续轮询"
368
413
  });
369
414
  this.scheduleNextQuery(actionType);
370
415
  return;
371
416
  }
372
- if (this.isRequestFailed(error == null ? void 0 : error.code)) {
373
- import_logs.default.addLog({
374
- title: "查询轮询结果:error-有明确错误code,停止轮询",
417
+ if (this.isOuterCodeTimeout(error == null ? void 0 : error.code)) {
418
+ paymentLog.addLog({
419
+ title: "查询轮询结果:error-code是超时错误,继续轮询",
375
420
  content: error
376
421
  });
377
- this.handleOperationError(error);
422
+ this.scheduleNextQuery(actionType);
423
+ return;
378
424
  } else {
379
- import_logs.default.addLog({
380
- title: "查询轮询结果:error-无明确code或者code不是超时,继续轮询",
425
+ paymentLog.addLog({
426
+ title: "查询轮询结果:error-有明确错误code,停止轮询",
381
427
  content: error
382
428
  });
383
- this.scheduleNextQuery(actionType);
429
+ this.handleOperationError(error);
384
430
  }
385
431
  }
386
432
  }
@@ -396,14 +442,14 @@ var PaymentMethod = class {
396
442
  clearTimeout(this.queryIntervalTimer);
397
443
  }
398
444
  if (((_a = this.config) == null ? void 0 : _a.hasQueryInterval) === false) {
399
- import_logs.default.addLog({
445
+ paymentLog.addLog({
400
446
  title: "查询轮询:立即安排下一次查询",
401
447
  content: { actionType }
402
448
  });
403
449
  this.performQuery(actionType);
404
450
  } else {
405
451
  this.queryIntervalTimer = setTimeout(() => {
406
- import_logs.default.addLog({
452
+ paymentLog.addLog({
407
453
  title: "查询轮询:安排下一次查询",
408
454
  content: { actionType }
409
455
  });
@@ -415,24 +461,33 @@ var PaymentMethod = class {
415
461
  * 开始轮询
416
462
  */
417
463
  startQuery(actionType) {
464
+ var _a;
418
465
  if (this.isFinished || !this.shouldContinue() || this.isQuerying) {
419
466
  return;
420
467
  }
421
468
  this.isQuerying = true;
422
- import_logs.default.addLog({ title: "开始轮询", content: { actionType } });
469
+ paymentLog.addLog({ title: "开始轮询", content: { actionType } });
470
+ const _globalQueryTimeout = ((_a = this.config) == null ? void 0 : _a.globalQueryTimeout) || import_types.GLOBAL_TIMEOUT;
423
471
  this.globalTimeoutTimer = setTimeout(() => {
472
+ var _a2;
424
473
  if (this.isFinished) {
425
474
  return;
426
475
  }
427
- import_logs.default.addLog({
428
- title: "轮询全局超时(2分钟),终止所有请求",
476
+ paymentLog.addLog({
477
+ title: `轮询全局超时(${_globalQueryTimeout / 1e3}秒),终止所有请求`,
429
478
  content: { actionType }
430
479
  });
431
480
  this.handleOperationError({
432
- code: import_const.PayStatus.Timeout,
433
- message: "交易超时"
481
+ code: "200",
482
+ data: {
483
+ external_unified_response: {
484
+ external_unified_status: import_types.EPaymentStatus.Failed,
485
+ response_code: import_const.PayStatus.Timeout,
486
+ message: ((_a2 = import_utils.locales) == null ? void 0 : _a2.getText("page.eftpos-pay.text.transaction.fail.timeout")) || "Transaction timeout."
487
+ }
488
+ }
434
489
  });
435
- }, import_types.GLOBAL_TIMEOUT);
490
+ }, _globalQueryTimeout);
436
491
  this.performQuery(actionType);
437
492
  }
438
493
  /**
@@ -480,7 +535,7 @@ var PaymentMethod = class {
480
535
  return;
481
536
  }
482
537
  this.currentQueryApi = queryApi;
483
- import_logs.default.addLog({ title: `开始${actionType}查询轮询` });
538
+ paymentLog.addLog({ title: `开始${actionType}查询轮询` });
484
539
  this.startQuery(actionType);
485
540
  }
486
541
  /**
@@ -488,15 +543,12 @@ var PaymentMethod = class {
488
543
  */
489
544
  async run(runOptions) {
490
545
  var _a;
491
- const { actionType, params } = runOptions;
546
+ const { actionType, params, config } = runOptions;
492
547
  const runId = this.startNewOperation(actionType);
493
- const { pay_param_base64, ...otherParams } = params || {};
494
- if (Object.keys(otherParams).length > 0) {
495
- import_logs.default.addLog({
496
- title: "请求参数",
497
- content: { params: otherParams }
498
- });
499
- }
548
+ paymentLog.addLog({
549
+ title: "请求参数",
550
+ content: { params }
551
+ });
500
552
  const { actionApi, queryApi } = this.getActionApi(actionType);
501
553
  if (!actionApi) {
502
554
  const error = new Error(`${actionType}接口不存在`);
@@ -506,7 +558,7 @@ var PaymentMethod = class {
506
558
  this.currentQueryApi = queryApi;
507
559
  if (queryApi !== null) {
508
560
  this.queryStartTimer = setTimeout(() => {
509
- import_logs.default.addLog({
561
+ paymentLog.addLog({
510
562
  title: "操作后10秒开始轮询",
511
563
  content: { actionType }
512
564
  });
@@ -515,89 +567,83 @@ var PaymentMethod = class {
515
567
  }
516
568
  this.controller = new AbortController();
517
569
  const { signal } = this.controller;
570
+ const _query = (_status, _title, _content) => {
571
+ paymentLog.addLog({ title: _title, content: _content });
572
+ if (this.queryStartTimer) {
573
+ clearTimeout(this.queryStartTimer);
574
+ this.queryStartTimer = null;
575
+ }
576
+ this.startQuery(actionType);
577
+ };
518
578
  try {
519
- import_logs.default.addLog({
579
+ paymentLog.addLog({
520
580
  title: `发起${actionType}请求`,
521
581
  content: { actionType, params }
522
582
  });
523
583
  const res = await actionApi(
524
- { ...params, request_version: runId, is_outer_response_info: 1 },
584
+ { ...params, request_version: runId },
525
585
  { signal }
526
586
  );
527
- import_logs.default.addLog({
587
+ paymentLog.addLog({
528
588
  title: "请求返回",
529
589
  content: { params, actionType, res }
530
590
  });
531
591
  if (runId != ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.request_version)) {
532
- import_logs.default.addLog({ title: "响应过期,忽略", content: { actionType } });
592
+ paymentLog.addLog({ title: "响应过期,忽略", content: { actionType } });
533
593
  return;
534
594
  }
535
595
  if (this.isFinished || !this.shouldContinue()) {
536
- import_logs.default.addLog({
596
+ paymentLog.addLog({
537
597
  title: "返回时已完成或不应继续处理",
538
598
  content: { actionType }
539
599
  });
540
600
  return;
541
601
  }
542
- if (res && `${res.code}` === "200") {
543
- import_logs.default.addLog({
602
+ if (`${res == null ? void 0 : res.code}` !== "200") {
603
+ paymentLog.addLog({ title: `${actionType}接口返回失败,code非200` });
604
+ this.handleOperationError(res);
605
+ return;
606
+ }
607
+ if (this.isBusinessSuccess(res)) {
608
+ paymentLog.addLog({
544
609
  title: `${actionType}接口成功`,
545
610
  content: { actionType, res }
546
611
  });
547
612
  const needContinue = this.handleResponse(res);
548
613
  if (needContinue) {
549
- import_logs.default.addLog({
550
- title: `${actionType}接口返回processing,开始轮询`
551
- });
552
- if (this.queryStartTimer) {
553
- clearTimeout(this.queryStartTimer);
554
- this.queryStartTimer = null;
555
- }
556
- this.startQuery(actionType);
614
+ _query("success", `${actionType}接口返回processing,开始轮询`);
557
615
  }
558
616
  return;
559
617
  }
560
- if (this.isRequestFailed(res == null ? void 0 : res.code)) {
561
- import_logs.default.addLog({
618
+ if (this.isBusinessFailed(res)) {
619
+ paymentLog.addLog({
562
620
  title: `${actionType}接口返回失败`,
563
621
  content: { actionType, res }
564
622
  });
565
623
  this.handleOperationError(res);
566
624
  } else {
567
- import_logs.default.addLog({
568
- title: `${actionType}超时或无明确错误,等待轮询结果`,
569
- content: { actionType, res }
625
+ this.handleOperationProcess(res);
626
+ _query("failed", `${actionType}超时或无明确错误,开始轮询`, {
627
+ actionType,
628
+ res
570
629
  });
571
- if (this.queryStartTimer) {
572
- clearTimeout(this.queryStartTimer);
573
- this.queryStartTimer = null;
574
- }
575
- this.startQuery(actionType);
576
630
  }
577
631
  } catch (error) {
578
632
  if (runId !== this.currentRunId) {
579
- import_logs.default.addLog({ title: "响应过期,忽略", content: { actionType } });
633
+ paymentLog.addLog({ title: "响应过期,忽略", content: { actionType } });
580
634
  return;
581
635
  }
582
636
  if (this.isFinished || !this.shouldContinue()) {
583
- import_logs.default.addLog({
637
+ paymentLog.addLog({
584
638
  title: "异常时已完成或不应继续处理",
585
639
  content: { actionType }
586
640
  });
587
641
  return;
588
642
  }
589
- if (this.isRequestFailed(error == null ? void 0 : error.code)) {
590
- import_logs.default.addLog({
591
- title: `${actionType}接口异常`,
592
- content: { actionType, error }
593
- });
594
- this.handleOperationError(error);
595
- } else {
596
- import_logs.default.addLog({
597
- title: `${actionType}超时或无明确错误,等待轮询结果`,
598
- content: { actionType, error }
599
- });
600
- }
643
+ _query("failed", `${actionType}接口异常,开始轮询`, {
644
+ actionType,
645
+ error
646
+ });
601
647
  }
602
648
  }
603
649
  /**
@@ -605,15 +651,13 @@ var PaymentMethod = class {
605
651
  */
606
652
  async runAction(actionOptions) {
607
653
  var _a;
608
- const { actionType, params } = actionOptions;
654
+ const { actionType, params, config } = actionOptions;
655
+ console.log("runAction_actionOptions", actionOptions);
609
656
  const runActionId = this.startNewOperation(actionType);
610
- const { pay_param_base64, ...otherParams } = params || {};
611
- if (Object.keys(otherParams).length > 0) {
612
- import_logs.default.addLog({
613
- title: "请求参数",
614
- content: { params: otherParams }
615
- });
616
- }
657
+ paymentLog.addLog({
658
+ title: `${actionType}操作请求参数`,
659
+ content: { actionType, params }
660
+ });
617
661
  const { actionApi, queryApi } = this.getActionApi(actionType);
618
662
  if (!actionApi) {
619
663
  const error = new Error(`${actionType}操作接口不存在`);
@@ -627,46 +671,49 @@ var PaymentMethod = class {
627
671
  const res = await actionApi(
628
672
  {
629
673
  ...params || {},
630
- request_version: runActionId,
631
- is_outer_response_info: 1
674
+ request_version: runActionId
632
675
  },
633
676
  { signal }
634
677
  );
635
678
  if (this.isFinished || !this.shouldContinue()) {
636
- import_logs.default.addLog({
679
+ paymentLog.addLog({
637
680
  title: "Action返回时已完成或不应继续处理,忽略",
638
681
  content: { actionType }
639
682
  });
640
683
  return;
641
684
  }
642
685
  if (runActionId !== ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.request_version)) {
643
- import_logs.default.addLog({
686
+ paymentLog.addLog({
644
687
  title: "Action响应过期,忽略",
645
688
  content: { actionType }
646
689
  });
647
690
  return;
648
691
  }
649
- import_logs.default.addLog({
692
+ if (config == null ? void 0 : config.needResponse) {
693
+ this.handleResponse(res);
694
+ return;
695
+ }
696
+ paymentLog.addLog({
650
697
  title: "Action请求返回,开始轮询",
651
698
  content: { actionType }
652
699
  });
653
700
  this.startQuery(actionType);
654
701
  } catch (error) {
655
702
  if (this.isFinished || !this.shouldContinue()) {
656
- import_logs.default.addLog({
703
+ paymentLog.addLog({
657
704
  title: "Action异常时已完成或不应继续处理,忽略",
658
705
  content: { actionType }
659
706
  });
660
707
  return;
661
708
  }
662
709
  if (runActionId !== this.currentRunId) {
663
- import_logs.default.addLog({
710
+ paymentLog.addLog({
664
711
  title: "Action响应过期,忽略",
665
712
  content: { actionType }
666
713
  });
667
714
  return;
668
715
  }
669
- import_logs.default.addLog({
716
+ paymentLog.addLog({
670
717
  title: "Action请求异常,开始轮询",
671
718
  content: { actionType, error }
672
719
  });
@@ -677,40 +724,44 @@ var PaymentMethod = class {
677
724
  * 支付
678
725
  * @param params 支付参数
679
726
  */
680
- pay(params) {
727
+ pay(params, config) {
681
728
  this.run({
682
729
  actionType: import_types.ActionType.Pay,
683
- params
730
+ params,
731
+ config
684
732
  });
685
733
  }
686
734
  /**
687
735
  * 支付取消
688
736
  * @param params 取消参数
689
737
  */
690
- payAction(params) {
738
+ payAction(params, config) {
691
739
  this.runAction({
692
740
  actionType: import_types.ActionType.PayAction,
693
- params
741
+ params,
742
+ config
694
743
  });
695
744
  }
696
745
  /**
697
746
  * 退款
698
747
  * @param params 退款参数
699
748
  */
700
- refund(params) {
749
+ refund(params, config) {
701
750
  this.run({
702
751
  actionType: import_types.ActionType.Refund,
703
- params
752
+ params,
753
+ config
704
754
  });
705
755
  }
706
756
  /**
707
757
  * 退款取消
708
758
  * @param params 取消参数
709
759
  */
710
- refundAction(params) {
760
+ refundAction(params, config) {
711
761
  this.runAction({
712
762
  actionType: import_types.ActionType.RefundAction,
713
- params
763
+ params,
764
+ config
714
765
  });
715
766
  }
716
767
  /**
@@ -733,7 +784,7 @@ var PaymentMethod = class {
733
784
  * 停止操作,后续依然可以重新发起操作
734
785
  */
735
786
  stop() {
736
- import_logs.default.addLog({
787
+ paymentLog.addLog({
737
788
  title: "停止操作",
738
789
  content: { actionType: this.currentActionType }
739
790
  });
@@ -744,9 +795,8 @@ var PaymentMethod = class {
744
795
  * 注意:销毁后实例不可再使用
745
796
  */
746
797
  destroy() {
747
- import_logs.default.addLog({ title: "销毁实例,完成所有流程" });
798
+ paymentLog.addLog({ title: "支付步骤结束,销毁实例" });
748
799
  this.clean(true);
749
- import_logs.default.clearLogs();
750
800
  }
751
801
  };
752
802
  var payment_default = PaymentMethod;