@pisell/private-materials 6.3.181 → 6.3.182

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.
@@ -31,6 +31,25 @@ import { useDispatch, updateStatus, updateCustom, updateState } from "../store";
31
31
  import { useFail } from "../hooks";
32
32
  import { getInitState } from "../manufacturer";
33
33
  import { getPayParams } from "../helper";
34
+ /**
35
+ * @title 是否需要使用 POS 打印收据
36
+ * @param setting 设置
37
+ */
38
+ var shouldPrintReceiptOnPos = function shouldPrintReceiptOnPos(setting) {
39
+ // 兼容老数据,明确为false才表示使用POS打印
40
+ if (typeof setting === 'boolean') {
41
+ return setting === false;
42
+ }
43
+ // 数字0表示使用POS打印
44
+ if (typeof setting === 'number') {
45
+ return setting === 0;
46
+ }
47
+ // 兼容:字符串0表示使用POS打印
48
+ if (typeof setting === 'string') {
49
+ return setting === '0';
50
+ }
51
+ return false;
52
+ };
34
53
  var AggregatePayment = function AggregatePayment(_ref) {
35
54
  var onChange = _ref.onChange;
36
55
  // 设置request
@@ -244,14 +263,14 @@ var AggregatePayment = function AggregatePayment(_ref) {
244
263
  // 刷卡机的手续费
245
264
  var card_reader_surcharge = external_service_fee || 0;
246
265
  var deviceSetting = (_deviceRef$current = deviceRef.current) === null || _deviceRef$current === void 0 ? void 0 : _deviceRef$current.setting;
247
- // 设备是否打印商家小票
248
- var isEftposPrintMerchantReceipt = deviceSetting === null || deviceSetting === void 0 ? void 0 : deviceSetting.print_merchant_receipt;
249
- // 设备是否打印客户小票
250
- var isEftposPrintCustomerReceipt = deviceSetting === null || deviceSetting === void 0 ? void 0 : deviceSetting.prompt_customer_receipt;
251
- if (!isEftposPrintMerchantReceipt && merchant_receipt) {
266
+ // 商家小票是否需要使用 POS 打印
267
+ var shouldPrintMerchantReceiptOnPos = shouldPrintReceiptOnPos(deviceSetting === null || deviceSetting === void 0 ? void 0 : deviceSetting.print_merchant_receipt);
268
+ // 客户小票是否需要使用 POS 打印
269
+ var shouldPrintCustomerReceiptOnPos = shouldPrintReceiptOnPos(deviceSetting === null || deviceSetting === void 0 ? void 0 : deviceSetting.prompt_customer_receipt);
270
+ if (shouldPrintMerchantReceiptOnPos && merchant_receipt) {
252
271
  receipt.push(merchant_receipt);
253
272
  }
254
- if (!isEftposPrintCustomerReceipt && customer_receipt) {
273
+ if (shouldPrintCustomerReceiptOnPos && customer_receipt) {
255
274
  receipt.push(customer_receipt);
256
275
  }
257
276
  dispatch(updateNextStep());
@@ -362,14 +381,14 @@ var AggregatePayment = function AggregatePayment(_ref) {
362
381
  // 刷卡机的手续费
363
382
  var card_reader_surcharge = (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.external_unified_response) === null || _response$data === void 0 ? void 0 : _response$data.external_service_fee) || 0;
364
383
  var deviceSetting = (_deviceRef$current2 = deviceRef.current) === null || _deviceRef$current2 === void 0 ? void 0 : _deviceRef$current2.setting;
365
- // 设备是否打印商家小票
366
- var isEftposPrintMerchantReceipt = deviceSetting === null || deviceSetting === void 0 ? void 0 : deviceSetting.print_merchant_receipt;
367
- // 设备是否打印客户小票
368
- var isEftposPrintCustomerReceipt = deviceSetting === null || deviceSetting === void 0 ? void 0 : deviceSetting.prompt_customer_receipt;
369
- if (!isEftposPrintMerchantReceipt && merchantReceipt) {
384
+ // 商家小票是否需要使用 POS 打印
385
+ var shouldPrintMerchantReceiptOnPos = shouldPrintReceiptOnPos(deviceSetting === null || deviceSetting === void 0 ? void 0 : deviceSetting.print_merchant_receipt);
386
+ // 客户小票是否需要使用 POS 打印
387
+ var shouldPrintCustomerReceiptOnPos = shouldPrintReceiptOnPos(deviceSetting === null || deviceSetting === void 0 ? void 0 : deviceSetting.prompt_customer_receipt);
388
+ if (shouldPrintMerchantReceiptOnPos && merchantReceipt) {
370
389
  receipt.push(merchantReceipt);
371
390
  }
372
- if (!isEftposPrintCustomerReceipt && customerReceipt) {
391
+ if (shouldPrintCustomerReceiptOnPos && customerReceipt) {
373
392
  receipt.push(customerReceipt);
374
393
  }
375
394
  var _params2 = getPayParams({
@@ -50,6 +50,18 @@ var import_store2 = require("../store");
50
50
  var import_hooks2 = require("../hooks");
51
51
  var import_manufacturer = require("../manufacturer");
52
52
  var import_helper = require("../helper");
53
+ var shouldPrintReceiptOnPos = (setting) => {
54
+ if (typeof setting === "boolean") {
55
+ return setting === false;
56
+ }
57
+ if (typeof setting === "number") {
58
+ return setting === 0;
59
+ }
60
+ if (typeof setting === "string") {
61
+ return setting === "0";
62
+ }
63
+ return false;
64
+ };
53
65
  var AggregatePayment = ({ onChange }) => {
54
66
  const context = (0, import_useEngineContext.default)();
55
67
  const utils = context.appHelper.utils || {};
@@ -200,12 +212,16 @@ var AggregatePayment = ({ onChange }) => {
200
212
  const { merchant_receipt, customer_receipt } = transaction || {};
201
213
  const card_reader_surcharge = external_service_fee || 0;
202
214
  const deviceSetting = (_b = deviceRef.current) == null ? void 0 : _b.setting;
203
- const isEftposPrintMerchantReceipt = deviceSetting == null ? void 0 : deviceSetting.print_merchant_receipt;
204
- const isEftposPrintCustomerReceipt = deviceSetting == null ? void 0 : deviceSetting.prompt_customer_receipt;
205
- if (!isEftposPrintMerchantReceipt && merchant_receipt) {
215
+ const shouldPrintMerchantReceiptOnPos = shouldPrintReceiptOnPos(
216
+ deviceSetting == null ? void 0 : deviceSetting.print_merchant_receipt
217
+ );
218
+ const shouldPrintCustomerReceiptOnPos = shouldPrintReceiptOnPos(
219
+ deviceSetting == null ? void 0 : deviceSetting.prompt_customer_receipt
220
+ );
221
+ if (shouldPrintMerchantReceiptOnPos && merchant_receipt) {
206
222
  receipt.push(merchant_receipt);
207
223
  }
208
- if (!isEftposPrintCustomerReceipt && customer_receipt) {
224
+ if (shouldPrintCustomerReceiptOnPos && customer_receipt) {
209
225
  receipt.push(customer_receipt);
210
226
  }
211
227
  dispatch((0, import_store.updateNextStep)());
@@ -291,12 +307,16 @@ var AggregatePayment = ({ onChange }) => {
291
307
  const receipt = [];
292
308
  const card_reader_surcharge = ((_b = (_a = response == null ? void 0 : response.data) == null ? void 0 : _a.external_unified_response) == null ? void 0 : _b.external_service_fee) || 0;
293
309
  const deviceSetting = (_c = deviceRef.current) == null ? void 0 : _c.setting;
294
- const isEftposPrintMerchantReceipt = deviceSetting == null ? void 0 : deviceSetting.print_merchant_receipt;
295
- const isEftposPrintCustomerReceipt = deviceSetting == null ? void 0 : deviceSetting.prompt_customer_receipt;
296
- if (!isEftposPrintMerchantReceipt && merchantReceipt) {
310
+ const shouldPrintMerchantReceiptOnPos = shouldPrintReceiptOnPos(
311
+ deviceSetting == null ? void 0 : deviceSetting.print_merchant_receipt
312
+ );
313
+ const shouldPrintCustomerReceiptOnPos = shouldPrintReceiptOnPos(
314
+ deviceSetting == null ? void 0 : deviceSetting.prompt_customer_receipt
315
+ );
316
+ if (shouldPrintMerchantReceiptOnPos && merchantReceipt) {
297
317
  receipt.push(merchantReceipt);
298
318
  }
299
- if (!isEftposPrintCustomerReceipt && customerReceipt) {
319
+ if (shouldPrintCustomerReceiptOnPos && customerReceipt) {
300
320
  receipt.push(customerReceipt);
301
321
  }
302
322
  const params = (0, import_helper.getPayParams)(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "6.3.181",
3
+ "version": "6.3.182",
4
4
  "scripts": {
5
5
  "dev": "father dev",
6
6
  "build": "father build",