@pisell/pisellos 0.10.56 → 0.10.57
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.
- package/dist/modules/OpenData/index.js +2 -1
- package/dist/modules/Order/index.d.ts +2 -1
- package/dist/modules/Order/index.js +118 -59
- package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/dist/modules/Order/utils/weighedProduct.js +94 -0
- package/dist/modules/Order/utils.d.ts +1 -1
- package/dist/modules/Order/utils.js +9 -6
- package/dist/modules/Payment/index.d.ts +0 -5
- package/dist/modules/Payment/index.js +35 -85
- package/dist/modules/ProductList/index.js +18 -5
- package/dist/modules/ResourcePlanner/planner.js +10 -8
- package/dist/modules/Rules/index.js +16 -14
- package/dist/modules/Rules/types.d.ts +2 -0
- package/dist/server/index.js +122 -69
- package/dist/server/modules/floor-plan/index.js +34 -3
- package/dist/server/modules/payment/index.d.ts +25 -6
- package/dist/server/modules/payment/index.js +660 -133
- package/dist/server/test.json +1 -1
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
- package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +5 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.js +46 -4
- package/dist/shared/receipt/small-ticket.d.ts +11 -0
- package/dist/shared/receipt/small-ticket.js +430 -255
- package/dist/shared/receipt/templateVisibility.d.ts +23 -0
- package/dist/shared/receipt/templateVisibility.js +64 -0
- package/dist/solution/BaseSales/index.d.ts +4 -2
- package/dist/solution/BaseSales/index.js +1328 -1214
- package/dist/solution/BaseSales/types.d.ts +5 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
- package/dist/solution/BaseSales/utils.js +3 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +4 -1
- package/dist/solution/BookingTicket/index.js +120 -80
- package/dist/solution/OrderInvoicePreview/index.d.ts +10 -0
- package/dist/solution/OrderInvoicePreview/index.js +85 -14
- package/dist/solution/RegisterAndLogin/config.js +54 -11
- package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
- package/dist/solution/RegisterAndLogin/index.js +1 -1
- package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
- package/dist/solution/RegisterAndLogin/utils.js +36 -16
- package/dist/solution/Sales/index.d.ts +2 -0
- package/dist/solution/Sales/index.js +15 -1
- package/dist/solution/ScanOrder/utils.js +3 -2
- package/dist/solution/UnifiedBookingSales/index.js +12 -13
- package/dist/solution/VenueBooking/index.d.ts +15 -2
- package/dist/solution/VenueBooking/index.js +1062 -785
- package/dist/solution/VenueBooking/types.d.ts +2 -1
- package/dist/solution/VenueBooking/types.js +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
- package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
- package/lib/modules/OpenData/index.js +2 -1
- package/lib/modules/Order/index.d.ts +2 -1
- package/lib/modules/Order/index.js +71 -11
- package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/lib/modules/Order/utils/weighedProduct.js +89 -0
- package/lib/modules/Order/utils.d.ts +1 -1
- package/lib/modules/Order/utils.js +5 -3
- package/lib/modules/Payment/index.d.ts +0 -5
- package/lib/modules/Payment/index.js +3 -28
- package/lib/modules/ProductList/index.js +14 -1
- package/lib/modules/ResourcePlanner/planner.js +10 -8
- package/lib/modules/Rules/index.js +16 -14
- package/lib/modules/Rules/types.d.ts +2 -0
- package/lib/server/index.js +72 -28
- package/lib/server/modules/floor-plan/index.js +29 -1
- package/lib/server/modules/payment/index.d.ts +25 -6
- package/lib/server/modules/payment/index.js +350 -78
- package/lib/server/test.json +1 -1
- package/lib/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
- package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +5 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.js +42 -4
- package/lib/shared/receipt/small-ticket.d.ts +11 -0
- package/lib/shared/receipt/small-ticket.js +234 -30
- package/lib/shared/receipt/templateVisibility.d.ts +23 -0
- package/lib/shared/receipt/templateVisibility.js +63 -0
- package/lib/solution/BaseSales/index.d.ts +4 -2
- package/lib/solution/BaseSales/index.js +79 -18
- package/lib/solution/BaseSales/types.d.ts +5 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
- package/lib/solution/BaseSales/utils.js +2 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +4 -1
- package/lib/solution/BookingTicket/index.js +14 -2
- package/lib/solution/OrderInvoicePreview/index.d.ts +10 -0
- package/lib/solution/OrderInvoicePreview/index.js +61 -7
- package/lib/solution/RegisterAndLogin/config.js +57 -11
- package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
- package/lib/solution/RegisterAndLogin/index.js +9 -1
- package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
- package/lib/solution/RegisterAndLogin/utils.js +24 -17
- package/lib/solution/Sales/index.d.ts +2 -0
- package/lib/solution/Sales/index.js +10 -1
- package/lib/solution/ScanOrder/utils.js +2 -1
- package/lib/solution/UnifiedBookingSales/index.js +5 -6
- package/lib/solution/VenueBooking/index.d.ts +15 -2
- package/lib/solution/VenueBooking/index.js +243 -96
- package/lib/solution/VenueBooking/types.d.ts +2 -1
- package/lib/solution/VenueBooking/types.js +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
- package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -41,6 +41,7 @@ import { OrderHooks } from "./modules/order/types";
|
|
|
41
41
|
import { filterOrders } from "./modules/order/utils/filterOrders";
|
|
42
42
|
import { filterBookingsFromOrders, sortBookings } from "./modules/order/utils/filterBookings";
|
|
43
43
|
import { buildSmallTicketData, hasSmallTicketData } from "./utils/small-ticket";
|
|
44
|
+
import { requiresInvoiceDataFiltering } from "../shared/receipt/templateVisibility";
|
|
44
45
|
import { BaseSalesImpl } from "../solution/BaseSales";
|
|
45
46
|
import { getOrderPaymentIdentityKeys, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity } from "../modules/Order/payment-utils";
|
|
46
47
|
import { finalizeSalesNotesForCheckout } from "../modules/Order/salesNotes";
|
|
@@ -1386,7 +1387,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
1386
1387
|
small_ticket_data_flag: 1,
|
|
1387
1388
|
payment_info: paymentInfo
|
|
1388
1389
|
}), {
|
|
1389
|
-
locales: _this.normalizeRequestedReceiptLocales(input.locales)
|
|
1390
|
+
locales: _this.normalizeRequestedReceiptLocales(input.locales),
|
|
1391
|
+
invoiceTemplateSettings: input.template_settings === undefined ? undefined : _this.normalizePrintInvoiceTemplateSettings(input.template_settings),
|
|
1392
|
+
applyTemplateVisibility: true,
|
|
1393
|
+
includeReceiptKeys: input.template_settings !== undefined
|
|
1390
1394
|
});
|
|
1391
1395
|
case 22:
|
|
1392
1396
|
rebuiltOrder = _context20.sent;
|
|
@@ -1409,7 +1413,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
1409
1413
|
status: true,
|
|
1410
1414
|
message: '',
|
|
1411
1415
|
data: {
|
|
1412
|
-
small_ticket_data: smallTicketData
|
|
1416
|
+
small_ticket_data: smallTicketData,
|
|
1417
|
+
template_visibility_applied: true,
|
|
1418
|
+
// These products and currency settings are the exact source used for
|
|
1419
|
+
// this receipt, not the potentially newer active tempOrder.
|
|
1420
|
+
source: _objectSpread(_objectSpread({}, rebuiltOrder), {}, {
|
|
1421
|
+
payment_info: _objectSpread(_objectSpread({}, rebuiltOrder.payment_info || {}), {}, {
|
|
1422
|
+
small_ticket_data: undefined
|
|
1423
|
+
})
|
|
1424
|
+
})
|
|
1413
1425
|
}
|
|
1414
1426
|
});
|
|
1415
1427
|
case 29:
|
|
@@ -3542,6 +3554,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
3542
3554
|
method: 'get',
|
|
3543
3555
|
path: '/shop/pay/custom-payment/all',
|
|
3544
3556
|
handler: this.handlePaymentMethods.bind(this)
|
|
3557
|
+
}, {
|
|
3558
|
+
method: 'get',
|
|
3559
|
+
path: '/pay/custom-payment/all',
|
|
3560
|
+
handler: this.handlePaymentMethods.bind(this)
|
|
3545
3561
|
}, {
|
|
3546
3562
|
method: 'get',
|
|
3547
3563
|
path: '/shop/quotation/available',
|
|
@@ -6142,7 +6158,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
6142
6158
|
_context60.next = 4;
|
|
6143
6159
|
return this.withLocalSmallTicketData(params.order, {
|
|
6144
6160
|
requireFullyPaid: params.requireFullyPaid,
|
|
6145
|
-
invoiceTemplateSettings: params.invoiceTemplateSettings
|
|
6161
|
+
invoiceTemplateSettings: params.invoiceTemplateSettings,
|
|
6162
|
+
applyTemplateVisibility: true
|
|
6146
6163
|
});
|
|
6147
6164
|
case 4:
|
|
6148
6165
|
printableOrder = _context60.sent;
|
|
@@ -6173,7 +6190,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6173
6190
|
case 10:
|
|
6174
6191
|
return _context60.abrupt("return", {
|
|
6175
6192
|
printed: true,
|
|
6176
|
-
order: printableOrder
|
|
6193
|
+
order: requiresInvoiceDataFiltering(params.invoiceTemplateSettings) ? params.order : printableOrder
|
|
6177
6194
|
});
|
|
6178
6195
|
case 11:
|
|
6179
6196
|
case "end":
|
|
@@ -6425,15 +6442,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
6425
6442
|
case 18:
|
|
6426
6443
|
pendingResult = _context62.sent;
|
|
6427
6444
|
if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
|
|
6428
|
-
_context62.next =
|
|
6445
|
+
_context62.next = 33;
|
|
6429
6446
|
break;
|
|
6430
6447
|
}
|
|
6431
6448
|
pendingOrder = pendingResult.data;
|
|
6432
|
-
if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && this.shouldAutoPrintCheckoutReceipt())) {
|
|
6433
|
-
_context62.next =
|
|
6449
|
+
if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData, invoiceTemplateSettings) && this.isSalesOrderFullyPaid(pendingOrder) && this.shouldAutoPrintCheckoutReceipt())) {
|
|
6450
|
+
_context62.next = 31;
|
|
6434
6451
|
break;
|
|
6435
6452
|
}
|
|
6436
|
-
_context62.
|
|
6453
|
+
_context62.prev = 22;
|
|
6454
|
+
_context62.next = 25;
|
|
6437
6455
|
return this.dispatchLocalReceiptPrint({
|
|
6438
6456
|
checkoutData: checkoutData,
|
|
6439
6457
|
order: pendingOrder,
|
|
@@ -6442,8 +6460,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
6442
6460
|
invoiceLayoutConfig: invoiceLayoutConfig,
|
|
6443
6461
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6444
6462
|
});
|
|
6445
|
-
case
|
|
6446
|
-
_context62.next =
|
|
6463
|
+
case 25:
|
|
6464
|
+
_context62.next = 31;
|
|
6465
|
+
break;
|
|
6466
|
+
case 27:
|
|
6467
|
+
_context62.prev = 27;
|
|
6468
|
+
_context62.t0 = _context62["catch"](22);
|
|
6469
|
+
// The sale is already persisted. A failed receipt must not cancel its
|
|
6470
|
+
// sync task or send an unfiltered fallback to the printer.
|
|
6471
|
+
pendingResult.receipt_print_error = this.getUnknownErrorMessage(_context62.t0);
|
|
6472
|
+
this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u4ECD\u7EE7\u7EED\u540C\u6B65"), {
|
|
6473
|
+
error: pendingResult.receipt_print_error
|
|
6474
|
+
});
|
|
6475
|
+
case 31:
|
|
6476
|
+
_context62.next = 33;
|
|
6447
6477
|
return this.dispatchCheckoutSyncTask({
|
|
6448
6478
|
backendPath: backendPath,
|
|
6449
6479
|
data: checkoutData,
|
|
@@ -6451,9 +6481,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6451
6481
|
invoiceLayoutConfig: invoiceLayoutConfig,
|
|
6452
6482
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6453
6483
|
});
|
|
6454
|
-
case
|
|
6484
|
+
case 33:
|
|
6455
6485
|
if (pendingResult.data.order_id) {
|
|
6456
|
-
_context62.next =
|
|
6486
|
+
_context62.next = 35;
|
|
6457
6487
|
break;
|
|
6458
6488
|
}
|
|
6459
6489
|
return _context62.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
|
|
@@ -6461,13 +6491,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6461
6491
|
order_id: pendingResult.data.external_sale_number
|
|
6462
6492
|
})
|
|
6463
6493
|
}));
|
|
6464
|
-
case
|
|
6494
|
+
case 35:
|
|
6465
6495
|
return _context62.abrupt("return", pendingResult);
|
|
6466
|
-
case
|
|
6496
|
+
case 36:
|
|
6467
6497
|
case "end":
|
|
6468
6498
|
return _context62.stop();
|
|
6469
6499
|
}
|
|
6470
|
-
}, _callee62, this);
|
|
6500
|
+
}, _callee62, this, [[22, 27]]);
|
|
6471
6501
|
}));
|
|
6472
6502
|
function handleOrderCheckoutSubmit(_x69) {
|
|
6473
6503
|
return _handleOrderCheckoutSubmit.apply(this, arguments);
|
|
@@ -6521,11 +6551,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
6521
6551
|
case 11:
|
|
6522
6552
|
response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
|
|
6523
6553
|
syncedOrder = syncResult.syncedOrder;
|
|
6524
|
-
if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData) && this.isSalesOrderFullyPaid(syncedOrder))) {
|
|
6525
|
-
_context63.next =
|
|
6554
|
+
if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData, invoiceTemplateSettings) && this.isSalesOrderFullyPaid(syncedOrder))) {
|
|
6555
|
+
_context63.next = 23;
|
|
6526
6556
|
break;
|
|
6527
6557
|
}
|
|
6528
|
-
_context63.
|
|
6558
|
+
_context63.prev = 14;
|
|
6559
|
+
_context63.next = 17;
|
|
6529
6560
|
return this.dispatchLocalReceiptPrint({
|
|
6530
6561
|
checkoutData: syncResult.checkoutData,
|
|
6531
6562
|
order: syncedOrder,
|
|
@@ -6533,16 +6564,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
6533
6564
|
requireFullyPaid: true,
|
|
6534
6565
|
invoiceLayoutConfig: invoiceLayoutConfig,
|
|
6535
6566
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6536
|
-
// print_all 的 type=0 是收据打印;不要沿用同步成功后的券/手环打印 type=99。
|
|
6537
6567
|
});
|
|
6538
|
-
case
|
|
6539
|
-
|
|
6568
|
+
case 17:
|
|
6569
|
+
_context63.next = 23;
|
|
6570
|
+
break;
|
|
6540
6571
|
case 19:
|
|
6541
6572
|
_context63.prev = 19;
|
|
6542
|
-
_context63.t0 = _context63["catch"](
|
|
6543
|
-
|
|
6573
|
+
_context63.t0 = _context63["catch"](14);
|
|
6574
|
+
// Checkout already succeeded remotely; report the receipt failure
|
|
6575
|
+
// separately instead of implying that payment/order creation failed.
|
|
6576
|
+
response.receipt_print_error = this.getUnknownErrorMessage(_context63.t0);
|
|
6577
|
+
this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u5DF2\u540C\u6B65"), {
|
|
6578
|
+
error: response.receipt_print_error
|
|
6579
|
+
});
|
|
6580
|
+
case 23:
|
|
6581
|
+
return _context63.abrupt("return", response);
|
|
6582
|
+
case 26:
|
|
6583
|
+
_context63.prev = 26;
|
|
6584
|
+
_context63.t1 = _context63["catch"](4);
|
|
6585
|
+
backendError = this.extractBackendErrorResponse(_context63.t1);
|
|
6544
6586
|
if (!backendError) {
|
|
6545
|
-
_context63.next =
|
|
6587
|
+
_context63.next = 32;
|
|
6546
6588
|
break;
|
|
6547
6589
|
}
|
|
6548
6590
|
_normalized = this.normalizeCheckoutResponse(backendError);
|
|
@@ -6551,12 +6593,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
6551
6593
|
message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
|
|
6552
6594
|
data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
|
|
6553
6595
|
}));
|
|
6554
|
-
case
|
|
6555
|
-
message = this.getUnknownErrorMessage(_context63.
|
|
6596
|
+
case 32:
|
|
6597
|
+
message = this.getUnknownErrorMessage(_context63.t1);
|
|
6556
6598
|
this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
|
|
6557
6599
|
backendPath: backendPath,
|
|
6558
6600
|
error: message,
|
|
6559
|
-
error_detail: this.normalizeUnknownError(_context63.
|
|
6601
|
+
error_detail: this.normalizeUnknownError(_context63.t1)
|
|
6560
6602
|
});
|
|
6561
6603
|
return _context63.abrupt("return", {
|
|
6562
6604
|
code: 500,
|
|
@@ -6564,11 +6606,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6564
6606
|
message: message,
|
|
6565
6607
|
data: null
|
|
6566
6608
|
});
|
|
6567
|
-
case
|
|
6609
|
+
case 35:
|
|
6568
6610
|
case "end":
|
|
6569
6611
|
return _context63.stop();
|
|
6570
6612
|
}
|
|
6571
|
-
}, _callee63, this, [[4, 19]]);
|
|
6613
|
+
}, _callee63, this, [[4, 26], [14, 19]]);
|
|
6572
6614
|
}));
|
|
6573
6615
|
function handleSyncCheckoutSubmit(_x70) {
|
|
6574
6616
|
return _handleSyncCheckoutSubmit.apply(this, arguments);
|
|
@@ -6836,11 +6878,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6836
6878
|
}
|
|
6837
6879
|
}, {
|
|
6838
6880
|
key: "shouldBuildSmallTicketData",
|
|
6839
|
-
value: function shouldBuildSmallTicketData(order) {
|
|
6840
|
-
var
|
|
6881
|
+
value: function shouldBuildSmallTicketData(order, invoiceTemplateSettings) {
|
|
6882
|
+
var _order$small_ticket_d;
|
|
6841
6883
|
if (!order || _typeof(order) !== 'object') return false;
|
|
6842
|
-
|
|
6843
|
-
|
|
6884
|
+
var flag = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag;
|
|
6885
|
+
// A synced order can omit the generation flag; required display filtering
|
|
6886
|
+
// still rebuilds its output. An explicit 0 retains the no-auto-print intent.
|
|
6887
|
+
return Number(flag !== null && flag !== void 0 ? flag : 0) === 1 || flag == null && requiresInvoiceDataFiltering(invoiceTemplateSettings);
|
|
6844
6888
|
}
|
|
6845
6889
|
}, {
|
|
6846
6890
|
key: "shouldPrintSyncedOrder",
|
|
@@ -6858,7 +6902,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6858
6902
|
}, {
|
|
6859
6903
|
key: "isSalesOrderFullyPaid",
|
|
6860
6904
|
value: function isSalesOrderFullyPaid(order) {
|
|
6861
|
-
var _order$summary$amount, _order$summary,
|
|
6905
|
+
var _order$summary$amount, _order$summary, _ref68, _ref69, _order$summary$expect, _order$summary2, _order$summary3;
|
|
6862
6906
|
if (!order || _typeof(order) !== 'object') return false;
|
|
6863
6907
|
var paymentStatus = String(order.payment_status || '').toLowerCase();
|
|
6864
6908
|
if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
|
|
@@ -6870,7 +6914,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6870
6914
|
return this.toAmountNumber(amountGap) <= 0;
|
|
6871
6915
|
}
|
|
6872
6916
|
var paidAmount = this.sumPaidOrderPayments(order.payments);
|
|
6873
|
-
var targetAmount = this.toAmountNumber((
|
|
6917
|
+
var targetAmount = this.toAmountNumber((_ref68 = (_ref69 = (_order$summary$expect = (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.total_amount) !== null && _ref69 !== void 0 ? _ref69 : order.expect_amount) !== null && _ref68 !== void 0 ? _ref68 : order.total_amount);
|
|
6874
6918
|
if (targetAmount <= 0) return paidAmount > 0;
|
|
6875
6919
|
return paidAmount >= targetAmount;
|
|
6876
6920
|
}
|
|
@@ -6914,8 +6958,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
6914
6958
|
}
|
|
6915
6959
|
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
6916
6960
|
product.product_bundle.forEach(function (bundle) {
|
|
6917
|
-
var
|
|
6918
|
-
var bundleProductId = (
|
|
6961
|
+
var _ref70, _bundle$bundle_produc;
|
|
6962
|
+
var bundleProductId = (_ref70 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref70 !== void 0 ? _ref70 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
|
|
6919
6963
|
if (bundleProductId !== undefined && bundleProductId !== null && bundleProductId !== '') {
|
|
6920
6964
|
productIdSet.add(bundleProductId);
|
|
6921
6965
|
}
|
|
@@ -6931,7 +6975,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6931
6975
|
case 6:
|
|
6932
6976
|
_context68.next = 8;
|
|
6933
6977
|
return Promise.all(productIds.map( /*#__PURE__*/function () {
|
|
6934
|
-
var
|
|
6978
|
+
var _ref71 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(id) {
|
|
6935
6979
|
var _this18$products, _this18$products$getP, product;
|
|
6936
6980
|
return _regeneratorRuntime().wrap(function _callee67$(_context67) {
|
|
6937
6981
|
while (1) switch (_context67.prev = _context67.next) {
|
|
@@ -6957,7 +7001,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6957
7001
|
}, _callee67, null, [[0, 7]]);
|
|
6958
7002
|
}));
|
|
6959
7003
|
return function (_x76) {
|
|
6960
|
-
return
|
|
7004
|
+
return _ref71.apply(this, arguments);
|
|
6961
7005
|
};
|
|
6962
7006
|
}()));
|
|
6963
7007
|
case 8:
|
|
@@ -6996,8 +7040,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
6996
7040
|
addProductId((_product$product_id2 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product === null || product === void 0 ? void 0 : product.id);
|
|
6997
7041
|
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
6998
7042
|
product.product_bundle.forEach(function (bundle) {
|
|
6999
|
-
var
|
|
7000
|
-
addProductId((
|
|
7043
|
+
var _ref72, _bundle$bundle_produc2;
|
|
7044
|
+
addProductId((_ref72 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref72 !== void 0 ? _ref72 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
|
|
7001
7045
|
});
|
|
7002
7046
|
}
|
|
7003
7047
|
});
|
|
@@ -7073,9 +7117,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7073
7117
|
if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
|
|
7074
7118
|
var hasChanged = false;
|
|
7075
7119
|
var productBundle = product.product_bundle.map(function (bundle) {
|
|
7076
|
-
var
|
|
7120
|
+
var _ref73, _bundle$bundle_produc3;
|
|
7077
7121
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
7078
|
-
var rawProductId = (
|
|
7122
|
+
var rawProductId = (_ref73 = (_bundle$bundle_produc3 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref73 !== void 0 ? _ref73 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
|
|
7079
7123
|
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
|
|
7080
7124
|
var productId = Number(rawProductId);
|
|
7081
7125
|
if (!Number.isFinite(productId)) return bundle;
|
|
@@ -7199,7 +7243,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7199
7243
|
}, {
|
|
7200
7244
|
key: "resolveProductTitleValue",
|
|
7201
7245
|
value: function resolveProductTitleValue(value, key, currentLocale) {
|
|
7202
|
-
var
|
|
7246
|
+
var _ref74, _ref75, _value$key;
|
|
7203
7247
|
if (value === undefined || value === null || value === '') return null;
|
|
7204
7248
|
if (_typeof(value) !== 'object') {
|
|
7205
7249
|
var title = String(value);
|
|
@@ -7209,7 +7253,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7209
7253
|
}
|
|
7210
7254
|
var normalizedKey = key.replace('-', '_');
|
|
7211
7255
|
var dashedKey = key.replace('_', '-');
|
|
7212
|
-
var rawValue = (
|
|
7256
|
+
var rawValue = (_ref74 = (_ref75 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref75 !== void 0 ? _ref75 : value[dashedKey]) !== null && _ref74 !== void 0 ? _ref74 : key === 'auto' ? value.default : undefined;
|
|
7213
7257
|
if (rawValue === undefined || rawValue === null || rawValue === '') return null;
|
|
7214
7258
|
if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
|
|
7215
7259
|
return String(rawValue);
|
|
@@ -7353,23 +7397,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
7353
7397
|
key: "withLocalSmallTicketData",
|
|
7354
7398
|
value: function () {
|
|
7355
7399
|
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(order, options) {
|
|
7356
|
-
var _options$productMap, normalizedCollections, normalizedOrder, collapsedDuplicateCounts,
|
|
7400
|
+
var mustApplyVisibility, _options$productMap, normalizedCollections, normalizedOrder, collapsedDuplicateCounts, _ref76, _ref77, _order_id, enrichedOrder, productMap, smallTicketData;
|
|
7357
7401
|
return _regeneratorRuntime().wrap(function _callee72$(_context72) {
|
|
7358
7402
|
while (1) switch (_context72.prev = _context72.next) {
|
|
7359
7403
|
case 0:
|
|
7360
|
-
|
|
7361
|
-
|
|
7404
|
+
mustApplyVisibility = (options === null || options === void 0 ? void 0 : options.applyTemplateVisibility) === true && requiresInvoiceDataFiltering(options.invoiceTemplateSettings);
|
|
7405
|
+
if (!(!this.shouldBuildSmallTicketData(order) && !mustApplyVisibility)) {
|
|
7406
|
+
_context72.next = 3;
|
|
7362
7407
|
break;
|
|
7363
7408
|
}
|
|
7364
7409
|
return _context72.abrupt("return", order);
|
|
7365
|
-
case
|
|
7410
|
+
case 3:
|
|
7366
7411
|
if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
|
|
7367
|
-
_context72.next =
|
|
7412
|
+
_context72.next = 5;
|
|
7368
7413
|
break;
|
|
7369
7414
|
}
|
|
7370
7415
|
return _context72.abrupt("return", order);
|
|
7371
|
-
case
|
|
7372
|
-
_context72.prev =
|
|
7416
|
+
case 5:
|
|
7417
|
+
_context72.prev = 5;
|
|
7373
7418
|
normalizedCollections = normalizeOrderCollections(order, {
|
|
7374
7419
|
ensureUid: false
|
|
7375
7420
|
});
|
|
@@ -7383,51 +7428,59 @@ var Server = /*#__PURE__*/function () {
|
|
|
7383
7428
|
return count > 0;
|
|
7384
7429
|
})) {
|
|
7385
7430
|
this.logWarning('withLocalSmallTicketData: 折叠重复订单子项', {
|
|
7386
|
-
order_identifier: (
|
|
7431
|
+
order_identifier: (_ref76 = (_ref77 = (_order_id = normalizedOrder.order_id) !== null && _order_id !== void 0 ? _order_id : normalizedOrder.external_sale_number) !== null && _ref77 !== void 0 ? _ref77 : normalizedOrder.shop_order_number) !== null && _ref76 !== void 0 ? _ref76 : null,
|
|
7387
7432
|
collapsed_duplicate_counts: collapsedDuplicateCounts
|
|
7388
7433
|
});
|
|
7389
7434
|
}
|
|
7390
|
-
_context72.next =
|
|
7435
|
+
_context72.next = 12;
|
|
7391
7436
|
return this.enrichPaymentNamesByCode(normalizedOrder);
|
|
7392
|
-
case
|
|
7437
|
+
case 12:
|
|
7393
7438
|
enrichedOrder = _context72.sent;
|
|
7394
7439
|
if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
|
|
7395
|
-
_context72.next =
|
|
7440
|
+
_context72.next = 17;
|
|
7396
7441
|
break;
|
|
7397
7442
|
}
|
|
7398
7443
|
_context72.t0 = _options$productMap;
|
|
7399
|
-
_context72.next =
|
|
7444
|
+
_context72.next = 20;
|
|
7400
7445
|
break;
|
|
7401
|
-
case
|
|
7402
|
-
_context72.next =
|
|
7446
|
+
case 17:
|
|
7447
|
+
_context72.next = 19;
|
|
7403
7448
|
return this.buildSmallTicketProductMap(enrichedOrder);
|
|
7404
|
-
case 18:
|
|
7405
|
-
_context72.t0 = _context72.sent;
|
|
7406
7449
|
case 19:
|
|
7450
|
+
_context72.t0 = _context72.sent;
|
|
7451
|
+
case 20:
|
|
7407
7452
|
productMap = _context72.t0;
|
|
7408
7453
|
smallTicketData = buildSmallTicketData({
|
|
7409
7454
|
order: enrichedOrder,
|
|
7410
7455
|
shopInfo: this.getSmallTicketShopInfo(),
|
|
7411
7456
|
locales: [].concat(_toConsumableArray(resolveInvoiceReceiptLocales(options === null || options === void 0 ? void 0 : options.invoiceTemplateSettings)), _toConsumableArray((options === null || options === void 0 ? void 0 : options.locales) || [])),
|
|
7412
|
-
productMap: productMap
|
|
7457
|
+
productMap: productMap,
|
|
7458
|
+
includeReceiptKeys: options === null || options === void 0 ? void 0 : options.includeReceiptKeys,
|
|
7459
|
+
templateSettings: options !== null && options !== void 0 && options.applyTemplateVisibility ? options.invoiceTemplateSettings : undefined
|
|
7413
7460
|
});
|
|
7414
7461
|
return _context72.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
|
|
7415
7462
|
payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
|
|
7416
7463
|
small_ticket_data: smallTicketData
|
|
7417
7464
|
})
|
|
7418
7465
|
}));
|
|
7419
|
-
case
|
|
7420
|
-
_context72.prev =
|
|
7421
|
-
_context72.t1 = _context72["catch"](
|
|
7466
|
+
case 25:
|
|
7467
|
+
_context72.prev = 25;
|
|
7468
|
+
_context72.t1 = _context72["catch"](5);
|
|
7422
7469
|
this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
|
|
7423
7470
|
error: _context72.t1 instanceof Error ? _context72.t1.message : String(_context72.t1)
|
|
7424
7471
|
});
|
|
7472
|
+
if (!mustApplyVisibility) {
|
|
7473
|
+
_context72.next = 30;
|
|
7474
|
+
break;
|
|
7475
|
+
}
|
|
7476
|
+
throw _context72.t1;
|
|
7477
|
+
case 30:
|
|
7425
7478
|
return _context72.abrupt("return", order);
|
|
7426
|
-
case
|
|
7479
|
+
case 31:
|
|
7427
7480
|
case "end":
|
|
7428
7481
|
return _context72.stop();
|
|
7429
7482
|
}
|
|
7430
|
-
}, _callee72, this, [[
|
|
7483
|
+
}, _callee72, this, [[5, 25]]);
|
|
7431
7484
|
}));
|
|
7432
7485
|
function withLocalSmallTicketData(_x80, _x81) {
|
|
7433
7486
|
return _withLocalSmallTicketData.apply(this, arguments);
|
|
@@ -7446,7 +7499,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7446
7499
|
value: function () {
|
|
7447
7500
|
var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(lookup, data, title) {
|
|
7448
7501
|
var _this$order5, _this$order6, _this$app17;
|
|
7449
|
-
var backendPath, response, _response$code3, responseStatusCode, code, message, fresh, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode,
|
|
7502
|
+
var backendPath, response, _response$code3, responseStatusCode, code, message, fresh, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode, _ref78, _backendError$code2, backendStatusCode, _code, _message2, _message3;
|
|
7450
7503
|
return _regeneratorRuntime().wrap(function _callee73$(_context73) {
|
|
7451
7504
|
while (1) switch (_context73.prev = _context73.next) {
|
|
7452
7505
|
case 0:
|
|
@@ -7567,7 +7620,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7567
7620
|
break;
|
|
7568
7621
|
}
|
|
7569
7622
|
backendStatusCode = typeof (backendError === null || backendError === void 0 ? void 0 : backendError.status) === 'number' ? backendError.status : undefined;
|
|
7570
|
-
_code = this.normalizeRemoteSalesOrderErrorCode((
|
|
7623
|
+
_code = this.normalizeRemoteSalesOrderErrorCode((_ref78 = (_backendError$code2 = backendError === null || backendError === void 0 ? void 0 : backendError.code) !== null && _backendError$code2 !== void 0 ? _backendError$code2 : backendStatusCode) !== null && _ref78 !== void 0 ? _ref78 : _responseStatusCode);
|
|
7571
7624
|
_message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context73.t0);
|
|
7572
7625
|
this.logInfo("".concat(title, ": \u540E\u7AEF\u8BA2\u5355\u67E5\u8BE2\u5931\u8D25"), {
|
|
7573
7626
|
lookup: lookup,
|
|
@@ -31,6 +31,33 @@ import { FloorPlanHooks } from "./types";
|
|
|
31
31
|
var FLOOR_PLAN_SYNC_DEBOUNCE_MS = 3000;
|
|
32
32
|
var FLOOR_PLAN_STORE_NAME = 'floor_plans';
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Request failures can be plain response objects (rather than Error instances).
|
|
36
|
+
* Keep diagnostics useful without allowing the UI bridge to stringify them as
|
|
37
|
+
* "[object Object]".
|
|
38
|
+
*/
|
|
39
|
+
function getRequestErrorInfo(error) {
|
|
40
|
+
var _ref, _ref2, _value$resData$res, _value$resData, _value$response, _response$code, _response$status, _value$response2;
|
|
41
|
+
if (error instanceof Error && error.message) return {
|
|
42
|
+
message: error.message
|
|
43
|
+
};
|
|
44
|
+
if (typeof error === 'string' && error) return {
|
|
45
|
+
message: error
|
|
46
|
+
};
|
|
47
|
+
var value = error;
|
|
48
|
+
var response = (_ref = (_ref2 = (_value$resData$res = value === null || value === void 0 || (_value$resData = value.resData) === null || _value$resData === void 0 ? void 0 : _value$resData.res) !== null && _value$resData$res !== void 0 ? _value$resData$res : value === null || value === void 0 || (_value$response = value.response) === null || _value$response === void 0 ? void 0 : _value$response.data) !== null && _ref2 !== void 0 ? _ref2 : value === null || value === void 0 ? void 0 : value.data) !== null && _ref !== void 0 ? _ref : value;
|
|
49
|
+
var candidates = [value === null || value === void 0 ? void 0 : value.message, value === null || value === void 0 ? void 0 : value.error, response === null || response === void 0 ? void 0 : response.message, response === null || response === void 0 ? void 0 : response.error];
|
|
50
|
+
var message = candidates.find(function (candidate) {
|
|
51
|
+
return typeof candidate === 'string' && candidate.trim() !== '';
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
message: message || '平面图加载失败(未提供错误详情)',
|
|
55
|
+
code: (_response$code = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code !== void 0 ? _response$code : value === null || value === void 0 ? void 0 : value.code,
|
|
56
|
+
status: (_response$status = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status !== void 0 ? _response$status : value === null || value === void 0 ? void 0 : value.status,
|
|
57
|
+
httpStatus: value === null || value === void 0 || (_value$response2 = value.response) === null || _value$response2 === void 0 ? void 0 : _value$response2.status
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
34
61
|
/**
|
|
35
62
|
* 平面图模块:预加载列表、pubsub 同步、供 OS Server 路由读本地 store
|
|
36
63
|
*/
|
|
@@ -230,7 +257,7 @@ export var FloorPlanModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
230
257
|
key: "loadListFromServer",
|
|
231
258
|
value: function () {
|
|
232
259
|
var _loadListFromServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
233
|
-
var res, body, raw, list;
|
|
260
|
+
var res, body, raw, list, errorInfo;
|
|
234
261
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
235
262
|
while (1) switch (_context2.prev = _context2.next) {
|
|
236
263
|
case 0:
|
|
@@ -248,11 +275,15 @@ export var FloorPlanModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
248
275
|
case 10:
|
|
249
276
|
_context2.prev = 10;
|
|
250
277
|
_context2.t0 = _context2["catch"](0);
|
|
278
|
+
errorInfo = getRequestErrorInfo(_context2.t0);
|
|
251
279
|
this.logWarning('loadListFromServer 失败', {
|
|
252
|
-
error:
|
|
280
|
+
error: errorInfo.message,
|
|
281
|
+
code: errorInfo.code,
|
|
282
|
+
status: errorInfo.status,
|
|
283
|
+
httpStatus: errorInfo.httpStatus
|
|
253
284
|
});
|
|
254
285
|
return _context2.abrupt("return", []);
|
|
255
|
-
case
|
|
286
|
+
case 15:
|
|
256
287
|
case "end":
|
|
257
288
|
return _context2.stop();
|
|
258
289
|
}
|
|
@@ -7,22 +7,41 @@ export declare class PaymentServerModule extends BaseModule implements Module {
|
|
|
7
7
|
private request;
|
|
8
8
|
private app;
|
|
9
9
|
private logger;
|
|
10
|
+
private dbManager;
|
|
10
11
|
private store;
|
|
11
|
-
private
|
|
12
|
-
private
|
|
12
|
+
private paymentDataSource;
|
|
13
|
+
private initialLoadInFlight;
|
|
14
|
+
private refreshInFlight;
|
|
15
|
+
private hasLoadedPayMethods;
|
|
16
|
+
private hasEmittedLoaded;
|
|
17
|
+
private syncTimer;
|
|
18
|
+
private pendingMessageUuids;
|
|
19
|
+
private queuedTrailingRefresh;
|
|
20
|
+
private trailingMessageUuids;
|
|
13
21
|
constructor(name?: string, version?: string);
|
|
14
22
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
23
|
+
preload(): Promise<void>;
|
|
15
24
|
getPayMethodListAsync(options?: {
|
|
16
25
|
shouldFilter?: boolean;
|
|
17
26
|
}): Promise<PaymentMethod[]>;
|
|
18
|
-
|
|
19
|
-
private
|
|
27
|
+
private ensureInitialPayMethods;
|
|
28
|
+
private initPaymentDataSource;
|
|
29
|
+
private setupPaymentMethodSync;
|
|
30
|
+
private schedulePaymentMethodRefresh;
|
|
31
|
+
private refreshPayMethodsSingleFlight;
|
|
32
|
+
private performRemoteRefresh;
|
|
20
33
|
private fetchRemotePayMethods;
|
|
21
|
-
private
|
|
34
|
+
private loadPayMethodsFromSQLite;
|
|
35
|
+
private replacePayMethodsInSQLite;
|
|
36
|
+
private resolveCurrentShopScope;
|
|
37
|
+
private stripSnapshotFields;
|
|
38
|
+
private arePayMethodsEqual;
|
|
22
39
|
private resolvePayMethods;
|
|
23
40
|
private filterPayMethods;
|
|
24
|
-
private
|
|
41
|
+
private setPayMethodMirror;
|
|
42
|
+
private getErrorMessage;
|
|
25
43
|
private logInfo;
|
|
26
44
|
private logWarning;
|
|
27
45
|
private logError;
|
|
46
|
+
destroy(): void;
|
|
28
47
|
}
|