@pisell/pisellos 2.2.326 → 2.2.328
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/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -1
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +60 -15
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/OpenData/index.d.ts +8 -1
- package/dist/modules/OpenData/index.js +276 -95
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +857 -598
- package/dist/server/modules/order/index.d.ts +1 -0
- package/dist/server/modules/order/index.js +51 -51
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/Sales/index.d.ts +2 -5
- package/dist/solution/Sales/index.js +117 -143
- package/dist/solution/Sales/types.d.ts +6 -0
- package/dist/solution/Sales/types.js +2 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -1
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +40 -6
- package/lib/modules/OpenData/index.d.ts +8 -1
- package/lib/modules/OpenData/index.js +123 -21
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/server/index.d.ts +3 -0
- package/lib/server/index.js +155 -18
- package/lib/server/modules/order/index.d.ts +1 -0
- package/lib/server/modules/order/index.js +4 -3
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/Sales/index.d.ts +2 -5
- package/lib/solution/Sales/index.js +32 -66
- package/lib/solution/Sales/types.d.ts +6 -0
- package/lib/solution/Sales/types.js +1 -0
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -783,7 +783,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
783
783
|
_defineProperty(this, "handleUpdateLocalOrder", /*#__PURE__*/function () {
|
|
784
784
|
var _ref33 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(_ref32) {
|
|
785
785
|
var _data$order_id, _ref34, _this$app;
|
|
786
|
-
var url, data, batchIds, rawOrderId, orderId, backendPath, _response$data, response,
|
|
786
|
+
var url, data, batchIds, rawOrderId, orderId, backendPath, _response$data, response, _fresh, exists, _yield$_this$order$ov, overwritten, errorMessage;
|
|
787
787
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
788
788
|
while (1) switch (_context13.prev = _context13.next) {
|
|
789
789
|
case 0:
|
|
@@ -857,8 +857,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
857
857
|
});
|
|
858
858
|
case 22:
|
|
859
859
|
response = _context13.sent;
|
|
860
|
-
|
|
861
|
-
if (!(!
|
|
860
|
+
_fresh = (_response$data = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data !== void 0 ? _response$data : response;
|
|
861
|
+
if (!(!_fresh || _typeof(_fresh) !== 'object' || _fresh.order_id == null)) {
|
|
862
862
|
_context13.next = 27;
|
|
863
863
|
break;
|
|
864
864
|
}
|
|
@@ -879,7 +879,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
879
879
|
break;
|
|
880
880
|
}
|
|
881
881
|
_context13.next = 31;
|
|
882
|
-
return _this.order.overwriteExistingOrder(
|
|
882
|
+
return _this.order.overwriteExistingOrder(_fresh);
|
|
883
883
|
case 31:
|
|
884
884
|
_yield$_this$order$ov = _context13.sent;
|
|
885
885
|
overwritten = _yield$_this$order$ov.overwritten;
|
|
@@ -899,7 +899,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
899
899
|
});
|
|
900
900
|
case 35:
|
|
901
901
|
_context13.next = 37;
|
|
902
|
-
return _this.order.upsertOrdersFromRemote([
|
|
902
|
+
return _this.order.upsertOrdersFromRemote([_fresh]);
|
|
903
903
|
case 37:
|
|
904
904
|
_this.logInfo('handleUpdateLocalOrder: 本地合并新订单完成', {
|
|
905
905
|
orderId: orderId
|
|
@@ -1405,7 +1405,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1405
1405
|
_defineProperty(this, "handleLocalOrderReceiptSnapshot", /*#__PURE__*/function () {
|
|
1406
1406
|
var _ref52 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(_ref51) {
|
|
1407
1407
|
var _this$order2;
|
|
1408
|
-
var data, input, lookup, _payment_info, sourceOrder, remoteResult,
|
|
1408
|
+
var data, input, lookup, _payment_info, sourceOrder, remoteResult, rebuiltOrder, smallTicketData, message;
|
|
1409
1409
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1410
1410
|
while (1) switch (_context22.prev = _context22.next) {
|
|
1411
1411
|
case 0:
|
|
@@ -1468,24 +1468,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
1468
1468
|
case 17:
|
|
1469
1469
|
sourceOrder = remoteResult.order;
|
|
1470
1470
|
case 18:
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
return _this.withLocalSmallTicketData(_objectSpread(_objectSpread({}, sourceOrder), {}, {
|
|
1475
|
-
small_ticket_data_flag: 1,
|
|
1476
|
-
payment_info: paymentInfo
|
|
1477
|
-
}), {
|
|
1478
|
-
locales: _this.normalizeRequestedReceiptLocales(input.locales),
|
|
1479
|
-
invoiceTemplateSettings: input.template_settings === undefined ? undefined : _this.normalizePrintInvoiceTemplateSettings(input.template_settings),
|
|
1480
|
-
applyTemplateVisibility: true,
|
|
1481
|
-
includeReceiptKeys: input.template_settings !== undefined,
|
|
1482
|
-
refreshResourceReference: true
|
|
1483
|
-
});
|
|
1484
|
-
case 22:
|
|
1471
|
+
_context22.next = 20;
|
|
1472
|
+
return _this.rebuildOrderReceipt(sourceOrder, input.template_settings === undefined ? undefined : _this.normalizePrintInvoiceTemplateSettings(input.template_settings), _this.normalizeRequestedReceiptLocales(input.locales));
|
|
1473
|
+
case 20:
|
|
1485
1474
|
rebuiltOrder = _context22.sent;
|
|
1486
1475
|
smallTicketData = (_payment_info = rebuiltOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data;
|
|
1487
1476
|
if (hasSmallTicketData(smallTicketData)) {
|
|
1488
|
-
_context22.next =
|
|
1477
|
+
_context22.next = 24;
|
|
1489
1478
|
break;
|
|
1490
1479
|
}
|
|
1491
1480
|
return _context22.abrupt("return", {
|
|
@@ -1496,7 +1485,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1496
1485
|
small_ticket_data: null
|
|
1497
1486
|
}
|
|
1498
1487
|
});
|
|
1499
|
-
case
|
|
1488
|
+
case 24:
|
|
1500
1489
|
return _context22.abrupt("return", {
|
|
1501
1490
|
code: 200,
|
|
1502
1491
|
status: true,
|
|
@@ -1513,8 +1502,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
1513
1502
|
})
|
|
1514
1503
|
}
|
|
1515
1504
|
});
|
|
1516
|
-
case
|
|
1517
|
-
_context22.prev =
|
|
1505
|
+
case 27:
|
|
1506
|
+
_context22.prev = 27;
|
|
1518
1507
|
_context22.t0 = _context22["catch"](7);
|
|
1519
1508
|
message = _context22.t0 instanceof Error ? _context22.t0.message : String(_context22.t0);
|
|
1520
1509
|
_this.logError('handleLocalOrderReceiptSnapshot: 生成失败', {
|
|
@@ -1529,11 +1518,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
1529
1518
|
small_ticket_data: null
|
|
1530
1519
|
}
|
|
1531
1520
|
});
|
|
1532
|
-
case
|
|
1521
|
+
case 32:
|
|
1533
1522
|
case "end":
|
|
1534
1523
|
return _context22.stop();
|
|
1535
1524
|
}
|
|
1536
|
-
}, _callee22, null, [[7,
|
|
1525
|
+
}, _callee22, null, [[7, 27]]);
|
|
1537
1526
|
}));
|
|
1538
1527
|
return function (_x21) {
|
|
1539
1528
|
return _ref52.apply(this, arguments);
|
|
@@ -3754,6 +3743,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
3754
3743
|
method: 'post',
|
|
3755
3744
|
path: '/shop/local/print-order',
|
|
3756
3745
|
handler: this.handleLocalPrintOrder.bind(this)
|
|
3746
|
+
}, {
|
|
3747
|
+
method: 'post',
|
|
3748
|
+
path: '/shop/local/cloud-order-invoice/lookup',
|
|
3749
|
+
handler: function handler(_ref65) {
|
|
3750
|
+
var data = _ref65.data;
|
|
3751
|
+
return _this9.handleCloudOrderInvoice(data, false);
|
|
3752
|
+
}
|
|
3753
|
+
}, {
|
|
3754
|
+
method: 'post',
|
|
3755
|
+
path: '/shop/local/cloud-order-invoice/submit',
|
|
3756
|
+
handler: function handler(_ref66) {
|
|
3757
|
+
var data = _ref66.data;
|
|
3758
|
+
return _this9.handleCloudOrderInvoice(data, true);
|
|
3759
|
+
}
|
|
3757
3760
|
}, {
|
|
3758
3761
|
method: 'post',
|
|
3759
3762
|
path: '/shop/local/order-receipt-snapshot',
|
|
@@ -3774,13 +3777,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
3774
3777
|
method: 'post',
|
|
3775
3778
|
path: '/shop/local/orderPaymentReadiness',
|
|
3776
3779
|
handler: function () {
|
|
3777
|
-
var _handler = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(
|
|
3780
|
+
var _handler = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(_ref67) {
|
|
3778
3781
|
var _this9$order;
|
|
3779
3782
|
var data;
|
|
3780
3783
|
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
3781
3784
|
while (1) switch (_context44.prev = _context44.next) {
|
|
3782
3785
|
case 0:
|
|
3783
|
-
data =
|
|
3786
|
+
data = _ref67.data;
|
|
3784
3787
|
_context44.next = 3;
|
|
3785
3788
|
return (_this9$order = _this9.order) === null || _this9$order === void 0 ? void 0 : _this9$order.getLocalOrderForPaymentReadiness(data === null || data === void 0 ? void 0 : data.sale_id);
|
|
3786
3789
|
case 3:
|
|
@@ -4186,11 +4189,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4186
4189
|
*/
|
|
4187
4190
|
}, {
|
|
4188
4191
|
key: "syncProductQueryScheduleTimers",
|
|
4189
|
-
value: function syncProductQueryScheduleTimers(
|
|
4192
|
+
value: function syncProductQueryScheduleTimers(_ref69) {
|
|
4190
4193
|
var _this$products$getLas3, _this$products2, _this$products2$getLa;
|
|
4191
|
-
var subscriberId =
|
|
4192
|
-
menu_list_ids =
|
|
4193
|
-
strategy_context =
|
|
4194
|
+
var subscriberId = _ref69.subscriberId,
|
|
4195
|
+
menu_list_ids = _ref69.menu_list_ids,
|
|
4196
|
+
strategy_context = _ref69.strategy_context;
|
|
4194
4197
|
this.clearSubscriberScheduleTimers(subscriberId);
|
|
4195
4198
|
if (!this.shouldScheduleProductQueryReload(strategy_context)) {
|
|
4196
4199
|
return;
|
|
@@ -4289,7 +4292,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4289
4292
|
*/
|
|
4290
4293
|
function () {
|
|
4291
4294
|
var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(kind, backendPath, data, config) {
|
|
4292
|
-
var queryPayload, result,
|
|
4295
|
+
var queryPayload, result, _ref70, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
|
|
4293
4296
|
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
4294
4297
|
while (1) switch (_context51.prev = _context51.next) {
|
|
4295
4298
|
case 0:
|
|
@@ -4298,7 +4301,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4298
4301
|
return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
|
|
4299
4302
|
case 3:
|
|
4300
4303
|
result = _context51.sent;
|
|
4301
|
-
|
|
4304
|
+
_ref70 = config || {}, callback = _ref70.callback, subscriberId = _ref70.subscriberId, resetVisibleOrderIds = _ref70.resetVisibleOrderIds;
|
|
4302
4305
|
if (subscriberId && typeof callback === 'function') {
|
|
4303
4306
|
contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
|
|
4304
4307
|
existing = this.salesSearchSubscribers.get(subscriberId);
|
|
@@ -6569,17 +6572,231 @@ var Server = /*#__PURE__*/function () {
|
|
|
6569
6572
|
}, {
|
|
6570
6573
|
key: "mergeLocalPrintOrderInput",
|
|
6571
6574
|
value: function mergeLocalPrintOrderInput(localOrder, inputOrder) {
|
|
6572
|
-
var
|
|
6573
|
-
var definedInput = Object.fromEntries(Object.entries(inputOrder || {}).filter(function (
|
|
6574
|
-
var
|
|
6575
|
-
value =
|
|
6575
|
+
var _ref75, _localOrder$order_id, _ref76, _external_sale_number4;
|
|
6576
|
+
var definedInput = Object.fromEntries(Object.entries(inputOrder || {}).filter(function (_ref73) {
|
|
6577
|
+
var _ref74 = _slicedToArray(_ref73, 2),
|
|
6578
|
+
value = _ref74[1];
|
|
6576
6579
|
return value !== undefined;
|
|
6577
6580
|
}));
|
|
6578
6581
|
return _objectSpread(_objectSpread(_objectSpread({}, localOrder), definedInput), {}, {
|
|
6579
|
-
order_id: (
|
|
6580
|
-
external_sale_number: (
|
|
6582
|
+
order_id: (_ref75 = (_localOrder$order_id = localOrder.order_id) !== null && _localOrder$order_id !== void 0 ? _localOrder$order_id : definedInput.order_id) !== null && _ref75 !== void 0 ? _ref75 : definedInput.orderId,
|
|
6583
|
+
external_sale_number: (_ref76 = (_external_sale_number4 = localOrder.external_sale_number) !== null && _external_sale_number4 !== void 0 ? _external_sale_number4 : definedInput.external_sale_number) !== null && _ref76 !== void 0 ? _ref76 : definedInput.externalSaleNumber
|
|
6581
6584
|
});
|
|
6582
6585
|
}
|
|
6586
|
+
}, {
|
|
6587
|
+
key: "loadCloudInvoiceOrder",
|
|
6588
|
+
value: function () {
|
|
6589
|
+
var _loadCloudInvoiceOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(orderId, shopId, assertCurrentShop) {
|
|
6590
|
+
var hasReceiptDetail, local, result, saved;
|
|
6591
|
+
return _regeneratorRuntime().wrap(function _callee67$(_context67) {
|
|
6592
|
+
while (1) switch (_context67.prev = _context67.next) {
|
|
6593
|
+
case 0:
|
|
6594
|
+
if (this.order) {
|
|
6595
|
+
_context67.next = 2;
|
|
6596
|
+
break;
|
|
6597
|
+
}
|
|
6598
|
+
throw new Error('Cloud invoice order service is unavailable');
|
|
6599
|
+
case 2:
|
|
6600
|
+
hasReceiptDetail = function hasReceiptDetail(order) {
|
|
6601
|
+
var _order$summary, _order$summary2;
|
|
6602
|
+
// Use the same amount fields as the receipt builder, including historical
|
|
6603
|
+
// top-level amounts. Zero is a valid total; a missing total in a list row is not.
|
|
6604
|
+
var total = [(_order$summary = order.summary) === null || _order$summary === void 0 ? void 0 : _order$summary.expect_amount, order.expect_amount, (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.total_amount, order.total_amount].find(function (value) {
|
|
6605
|
+
return value != null && value !== '';
|
|
6606
|
+
});
|
|
6607
|
+
return typeof order.business_code === 'string' && !!order.business_code.trim() && (typeof total === 'number' || typeof total === 'string' && !!total.trim()) && Number.isFinite(Number(total)) && (Array.isArray(order.products) || Array.isArray(order.bookings));
|
|
6608
|
+
};
|
|
6609
|
+
_context67.next = 5;
|
|
6610
|
+
return this.order.getLocalOrderByLookup(orderId, {
|
|
6611
|
+
exactOrderId: true
|
|
6612
|
+
});
|
|
6613
|
+
case 5:
|
|
6614
|
+
local = _context67.sent;
|
|
6615
|
+
assertCurrentShop();
|
|
6616
|
+
if (!(local && String(local.order_id) === orderId)) {
|
|
6617
|
+
_context67.next = 12;
|
|
6618
|
+
break;
|
|
6619
|
+
}
|
|
6620
|
+
if (!(local.shop_id != null && String(local.shop_id) !== shopId)) {
|
|
6621
|
+
_context67.next = 10;
|
|
6622
|
+
break;
|
|
6623
|
+
}
|
|
6624
|
+
throw new Error('Cloud invoice order belongs to another shop');
|
|
6625
|
+
case 10:
|
|
6626
|
+
if (!(String(local.shop_id) === shopId && hasReceiptDetail(local))) {
|
|
6627
|
+
_context67.next = 12;
|
|
6628
|
+
break;
|
|
6629
|
+
}
|
|
6630
|
+
return _context67.abrupt("return", local);
|
|
6631
|
+
case 12:
|
|
6632
|
+
_context67.next = 14;
|
|
6633
|
+
return this.fetchAndPersistSalesOrderByLookup(orderId, {
|
|
6634
|
+
with: ['all']
|
|
6635
|
+
}, 'cloudOrderInvoice', undefined, function (fresh) {
|
|
6636
|
+
assertCurrentShop();
|
|
6637
|
+
if (String(fresh.order_id) !== orderId || fresh.shop_id != null && String(fresh.shop_id) !== shopId || !hasReceiptDetail(fresh)) {
|
|
6638
|
+
throw new Error('Cloud invoice order identity or detail is invalid');
|
|
6639
|
+
}
|
|
6640
|
+
// Some older shop-authenticated detail responses omit shop_id.
|
|
6641
|
+
return fresh.shop_id == null ? _objectSpread(_objectSpread({}, fresh), {}, {
|
|
6642
|
+
shop_id: Number(shopId)
|
|
6643
|
+
}) : fresh;
|
|
6644
|
+
});
|
|
6645
|
+
case 14:
|
|
6646
|
+
result = _context67.sent;
|
|
6647
|
+
assertCurrentShop();
|
|
6648
|
+
saved = result.order;
|
|
6649
|
+
if (!(!saved || String(saved.order_id) !== orderId || String(saved.shop_id) !== shopId || !hasReceiptDetail(saved))) {
|
|
6650
|
+
_context67.next = 19;
|
|
6651
|
+
break;
|
|
6652
|
+
}
|
|
6653
|
+
throw new Error(result.message || 'Cloud invoice order detail is unavailable');
|
|
6654
|
+
case 19:
|
|
6655
|
+
return _context67.abrupt("return", saved);
|
|
6656
|
+
case 20:
|
|
6657
|
+
case "end":
|
|
6658
|
+
return _context67.stop();
|
|
6659
|
+
}
|
|
6660
|
+
}, _callee67, this);
|
|
6661
|
+
}));
|
|
6662
|
+
function loadCloudInvoiceOrder(_x71, _x72, _x73) {
|
|
6663
|
+
return _loadCloudInvoiceOrder.apply(this, arguments);
|
|
6664
|
+
}
|
|
6665
|
+
return loadCloudInvoiceOrder;
|
|
6666
|
+
}()
|
|
6667
|
+
}, {
|
|
6668
|
+
key: "handleCloudOrderInvoice",
|
|
6669
|
+
value: function () {
|
|
6670
|
+
var _handleCloudOrderInvoice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(input, submit) {
|
|
6671
|
+
var _this19 = this;
|
|
6672
|
+
var orderId, _this$getAppData2, _this$getAppData3, _input$template_setti, _receipt$payment_info, shopId, tenantId, assertCurrentShop, order, businessCode, settings, receipt, smallTicketData, deviceTask, deviceId, message;
|
|
6673
|
+
return _regeneratorRuntime().wrap(function _callee68$(_context68) {
|
|
6674
|
+
while (1) switch (_context68.prev = _context68.next) {
|
|
6675
|
+
case 0:
|
|
6676
|
+
orderId = typeof (input === null || input === void 0 ? void 0 : input.order_id) === 'string' ? input.order_id.trim() : Number.isSafeInteger(input === null || input === void 0 ? void 0 : input.order_id) ? String(input.order_id) : '';
|
|
6677
|
+
if (/^[1-9]\d*$/.test(orderId)) {
|
|
6678
|
+
_context68.next = 3;
|
|
6679
|
+
break;
|
|
6680
|
+
}
|
|
6681
|
+
return _context68.abrupt("return", {
|
|
6682
|
+
code: 400,
|
|
6683
|
+
status: false,
|
|
6684
|
+
message: 'Invalid cloud invoice order ID',
|
|
6685
|
+
data: null
|
|
6686
|
+
});
|
|
6687
|
+
case 3:
|
|
6688
|
+
_context68.prev = 3;
|
|
6689
|
+
shopId = String((_this$getAppData2 = this.getAppData('shop_id')) !== null && _this$getAppData2 !== void 0 ? _this$getAppData2 : '');
|
|
6690
|
+
tenantId = String((_this$getAppData3 = this.getAppData('tenant_id')) !== null && _this$getAppData3 !== void 0 ? _this$getAppData3 : '');
|
|
6691
|
+
if (!(!/^[1-9]\d*$/.test(shopId) || !Number.isSafeInteger(Number(shopId)))) {
|
|
6692
|
+
_context68.next = 8;
|
|
6693
|
+
break;
|
|
6694
|
+
}
|
|
6695
|
+
throw new Error('Cloud invoice shop is unavailable');
|
|
6696
|
+
case 8:
|
|
6697
|
+
assertCurrentShop = function assertCurrentShop() {
|
|
6698
|
+
var _this19$getAppData, _this19$getAppData2;
|
|
6699
|
+
if (String((_this19$getAppData = _this19.getAppData('shop_id')) !== null && _this19$getAppData !== void 0 ? _this19$getAppData : '') !== shopId || String((_this19$getAppData2 = _this19.getAppData('tenant_id')) !== null && _this19$getAppData2 !== void 0 ? _this19$getAppData2 : '') !== tenantId) {
|
|
6700
|
+
throw new Error('Cloud invoice shop context changed');
|
|
6701
|
+
}
|
|
6702
|
+
};
|
|
6703
|
+
_context68.next = 11;
|
|
6704
|
+
return this.loadCloudInvoiceOrder(orderId, shopId, assertCurrentShop);
|
|
6705
|
+
case 11:
|
|
6706
|
+
order = _context68.sent;
|
|
6707
|
+
businessCode = order.business_code.trim();
|
|
6708
|
+
if (submit) {
|
|
6709
|
+
_context68.next = 15;
|
|
6710
|
+
break;
|
|
6711
|
+
}
|
|
6712
|
+
return _context68.abrupt("return", {
|
|
6713
|
+
code: 200,
|
|
6714
|
+
status: true,
|
|
6715
|
+
message: '',
|
|
6716
|
+
data: {
|
|
6717
|
+
business_code: businessCode
|
|
6718
|
+
}
|
|
6719
|
+
});
|
|
6720
|
+
case 15:
|
|
6721
|
+
if (!(input.business_code !== businessCode || typeof ((_input$template_setti = input.template_settings) === null || _input$template_setti === void 0 ? void 0 : _input$template_setti.template) !== 'string' || !input.template_settings.template.trim() || !Array.isArray(input.template_settings.modules))) {
|
|
6722
|
+
_context68.next = 17;
|
|
6723
|
+
break;
|
|
6724
|
+
}
|
|
6725
|
+
throw new Error('Cloud invoice template is missing or belongs to another business');
|
|
6726
|
+
case 17:
|
|
6727
|
+
settings = this.normalizePrintInvoiceTemplateSettings(input.template_settings);
|
|
6728
|
+
_context68.next = 20;
|
|
6729
|
+
return this.rebuildOrderReceipt(order, settings);
|
|
6730
|
+
case 20:
|
|
6731
|
+
receipt = _context68.sent;
|
|
6732
|
+
smallTicketData = (_receipt$payment_info = receipt.payment_info) === null || _receipt$payment_info === void 0 ? void 0 : _receipt$payment_info.small_ticket_data;
|
|
6733
|
+
if (hasSmallTicketData(smallTicketData)) {
|
|
6734
|
+
_context68.next = 24;
|
|
6735
|
+
break;
|
|
6736
|
+
}
|
|
6737
|
+
throw new Error('Cloud invoice snapshot is unavailable');
|
|
6738
|
+
case 24:
|
|
6739
|
+
deviceTask = this.getDeviceTaskPlugin();
|
|
6740
|
+
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
6741
|
+
_context68.next = 27;
|
|
6742
|
+
break;
|
|
6743
|
+
}
|
|
6744
|
+
throw new Error('Print task service is unavailable');
|
|
6745
|
+
case 27:
|
|
6746
|
+
_context68.next = 29;
|
|
6747
|
+
return this.getShortNumberOrDeviceId();
|
|
6748
|
+
case 29:
|
|
6749
|
+
deviceId = _context68.sent;
|
|
6750
|
+
assertCurrentShop();
|
|
6751
|
+
_context68.next = 33;
|
|
6752
|
+
return deviceTask.dispatch({
|
|
6753
|
+
action: 'print_all',
|
|
6754
|
+
device_id: deviceId,
|
|
6755
|
+
name: 'PRINT_V1',
|
|
6756
|
+
source: 'server',
|
|
6757
|
+
source_type: 'order',
|
|
6758
|
+
source_id: order.order_id,
|
|
6759
|
+
payload: {
|
|
6760
|
+
type: '0',
|
|
6761
|
+
template_settings: settings,
|
|
6762
|
+
data: {
|
|
6763
|
+
order_id: order.order_id,
|
|
6764
|
+
small_ticket_data: smallTicketData
|
|
6765
|
+
}
|
|
6766
|
+
}
|
|
6767
|
+
});
|
|
6768
|
+
case 33:
|
|
6769
|
+
return _context68.abrupt("return", {
|
|
6770
|
+
code: 200,
|
|
6771
|
+
status: true,
|
|
6772
|
+
message: '',
|
|
6773
|
+
data: null
|
|
6774
|
+
});
|
|
6775
|
+
case 36:
|
|
6776
|
+
_context68.prev = 36;
|
|
6777
|
+
_context68.t0 = _context68["catch"](3);
|
|
6778
|
+
message = this.getUnknownErrorMessage(_context68.t0);
|
|
6779
|
+
this.logWarning('Cloud invoice request failed', {
|
|
6780
|
+
orderId: orderId,
|
|
6781
|
+
message: message
|
|
6782
|
+
});
|
|
6783
|
+
return _context68.abrupt("return", {
|
|
6784
|
+
code: 500,
|
|
6785
|
+
status: false,
|
|
6786
|
+
message: message,
|
|
6787
|
+
data: null
|
|
6788
|
+
});
|
|
6789
|
+
case 41:
|
|
6790
|
+
case "end":
|
|
6791
|
+
return _context68.stop();
|
|
6792
|
+
}
|
|
6793
|
+
}, _callee68, this, [[3, 36]]);
|
|
6794
|
+
}));
|
|
6795
|
+
function handleCloudOrderInvoice(_x74, _x75) {
|
|
6796
|
+
return _handleCloudOrderInvoice.apply(this, arguments);
|
|
6797
|
+
}
|
|
6798
|
+
return handleCloudOrderInvoice;
|
|
6799
|
+
}()
|
|
6583
6800
|
}, {
|
|
6584
6801
|
key: "normalizeRequestedReceiptLocales",
|
|
6585
6802
|
value: function normalizeRequestedReceiptLocales(value) {
|
|
@@ -6590,6 +6807,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
6590
6807
|
return locale.trim();
|
|
6591
6808
|
}).filter(Boolean)));
|
|
6592
6809
|
}
|
|
6810
|
+
}, {
|
|
6811
|
+
key: "rebuildOrderReceipt",
|
|
6812
|
+
value: function rebuildOrderReceipt(order, templateSettings, locales) {
|
|
6813
|
+
var paymentInfo = _objectSpread({}, order.payment_info);
|
|
6814
|
+
delete paymentInfo.small_ticket_data;
|
|
6815
|
+
return this.withLocalSmallTicketData(_objectSpread(_objectSpread({}, order), {}, {
|
|
6816
|
+
small_ticket_data_flag: 1,
|
|
6817
|
+
payment_info: paymentInfo
|
|
6818
|
+
}), {
|
|
6819
|
+
locales: locales,
|
|
6820
|
+
invoiceTemplateSettings: templateSettings,
|
|
6821
|
+
applyTemplateVisibility: true,
|
|
6822
|
+
includeReceiptKeys: templateSettings !== undefined,
|
|
6823
|
+
refreshResourceReference: true
|
|
6824
|
+
});
|
|
6825
|
+
}
|
|
6593
6826
|
}, {
|
|
6594
6827
|
key: "resolveMachinecodeBatchMetadataLookup",
|
|
6595
6828
|
value: function resolveMachinecodeBatchMetadataLookup(data) {
|
|
@@ -6601,57 +6834,57 @@ var Server = /*#__PURE__*/function () {
|
|
|
6601
6834
|
}, {
|
|
6602
6835
|
key: "syncMachinecodeRedeemStatusToLocalOrder",
|
|
6603
6836
|
value: function () {
|
|
6604
|
-
var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6837
|
+
var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(data, ids, status) {
|
|
6605
6838
|
var _this$order5, _data$order_id2;
|
|
6606
6839
|
var title, lookup, localOrder, orderId, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
|
|
6607
|
-
return _regeneratorRuntime().wrap(function
|
|
6608
|
-
while (1) switch (
|
|
6840
|
+
return _regeneratorRuntime().wrap(function _callee69$(_context69) {
|
|
6841
|
+
while (1) switch (_context69.prev = _context69.next) {
|
|
6609
6842
|
case 0:
|
|
6610
6843
|
title = 'handleMachinecodeBatchMetadata';
|
|
6611
6844
|
lookup = this.resolveMachinecodeBatchMetadataLookup(data);
|
|
6612
6845
|
if (!(lookup === undefined)) {
|
|
6613
|
-
|
|
6846
|
+
_context69.next = 5;
|
|
6614
6847
|
break;
|
|
6615
6848
|
}
|
|
6616
6849
|
this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
6617
6850
|
batchSize: ids.length,
|
|
6618
6851
|
status: status
|
|
6619
6852
|
});
|
|
6620
|
-
return
|
|
6853
|
+
return _context69.abrupt("return");
|
|
6621
6854
|
case 5:
|
|
6622
6855
|
if ((_this$order5 = this.order) !== null && _this$order5 !== void 0 && _this$order5.getLocalOrderByLookup) {
|
|
6623
|
-
|
|
6856
|
+
_context69.next = 8;
|
|
6624
6857
|
break;
|
|
6625
6858
|
}
|
|
6626
6859
|
this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
6627
6860
|
lookup: lookup,
|
|
6628
6861
|
status: status
|
|
6629
6862
|
});
|
|
6630
|
-
return
|
|
6863
|
+
return _context69.abrupt("return");
|
|
6631
6864
|
case 8:
|
|
6632
|
-
|
|
6865
|
+
_context69.next = 10;
|
|
6633
6866
|
return this.order.getLocalOrderByLookup(lookup);
|
|
6634
6867
|
case 10:
|
|
6635
|
-
localOrder =
|
|
6868
|
+
localOrder = _context69.sent;
|
|
6636
6869
|
orderId = (_data$order_id2 = data === null || data === void 0 ? void 0 : data.order_id) !== null && _data$order_id2 !== void 0 ? _data$order_id2 : data === null || data === void 0 ? void 0 : data.orderId;
|
|
6637
6870
|
if (!(!localOrder && orderId !== undefined && orderId !== null && orderId !== '' && String(orderId) !== String(lookup))) {
|
|
6638
|
-
|
|
6871
|
+
_context69.next = 16;
|
|
6639
6872
|
break;
|
|
6640
6873
|
}
|
|
6641
|
-
|
|
6874
|
+
_context69.next = 15;
|
|
6642
6875
|
return this.order.getLocalOrderByLookup(orderId);
|
|
6643
6876
|
case 15:
|
|
6644
|
-
localOrder =
|
|
6877
|
+
localOrder = _context69.sent;
|
|
6645
6878
|
case 16:
|
|
6646
6879
|
if (localOrder) {
|
|
6647
|
-
|
|
6880
|
+
_context69.next = 19;
|
|
6648
6881
|
break;
|
|
6649
6882
|
}
|
|
6650
6883
|
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
6651
6884
|
lookup: lookup,
|
|
6652
6885
|
status: status
|
|
6653
6886
|
});
|
|
6654
|
-
return
|
|
6887
|
+
return _context69.abrupt("return");
|
|
6655
6888
|
case 19:
|
|
6656
6889
|
voucherIdSet = new Set(ids.filter(function (id) {
|
|
6657
6890
|
return id !== undefined && id !== null && id !== '';
|
|
@@ -6659,14 +6892,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
6659
6892
|
return String(id);
|
|
6660
6893
|
}));
|
|
6661
6894
|
if (!(voucherIdSet.size === 0)) {
|
|
6662
|
-
|
|
6895
|
+
_context69.next = 23;
|
|
6663
6896
|
break;
|
|
6664
6897
|
}
|
|
6665
6898
|
this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
6666
6899
|
lookup: lookup,
|
|
6667
6900
|
status: status
|
|
6668
6901
|
});
|
|
6669
|
-
return
|
|
6902
|
+
return _context69.abrupt("return");
|
|
6670
6903
|
case 23:
|
|
6671
6904
|
vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
|
|
6672
6905
|
hasUpdatedVoucher = false;
|
|
@@ -6680,7 +6913,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6680
6913
|
});
|
|
6681
6914
|
});
|
|
6682
6915
|
if (hasUpdatedVoucher) {
|
|
6683
|
-
|
|
6916
|
+
_context69.next = 29;
|
|
6684
6917
|
break;
|
|
6685
6918
|
}
|
|
6686
6919
|
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
@@ -6688,13 +6921,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6688
6921
|
voucher_ids: Array.from(voucherIdSet),
|
|
6689
6922
|
status: status
|
|
6690
6923
|
});
|
|
6691
|
-
return
|
|
6924
|
+
return _context69.abrupt("return");
|
|
6692
6925
|
case 29:
|
|
6693
6926
|
if (!(typeof this.order.overwriteExistingOrder === 'function')) {
|
|
6694
|
-
|
|
6927
|
+
_context69.next = 34;
|
|
6695
6928
|
break;
|
|
6696
6929
|
}
|
|
6697
|
-
|
|
6930
|
+
_context69.next = 32;
|
|
6698
6931
|
return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
|
|
6699
6932
|
vouchers: nextVouchers
|
|
6700
6933
|
}));
|
|
@@ -6704,13 +6937,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6704
6937
|
updatedCount: voucherIdSet.size,
|
|
6705
6938
|
status: status
|
|
6706
6939
|
});
|
|
6707
|
-
return
|
|
6940
|
+
return _context69.abrupt("return");
|
|
6708
6941
|
case 34:
|
|
6709
6942
|
if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
|
|
6710
|
-
|
|
6943
|
+
_context69.next = 39;
|
|
6711
6944
|
break;
|
|
6712
6945
|
}
|
|
6713
|
-
|
|
6946
|
+
_context69.next = 37;
|
|
6714
6947
|
return this.order.markOrderSyncedByExternalSaleNumber({
|
|
6715
6948
|
externalSaleNumber: data.external_sale_number,
|
|
6716
6949
|
patch: {
|
|
@@ -6723,7 +6956,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6723
6956
|
updatedCount: voucherIdSet.size,
|
|
6724
6957
|
status: status
|
|
6725
6958
|
});
|
|
6726
|
-
return
|
|
6959
|
+
return _context69.abrupt("return");
|
|
6727
6960
|
case 39:
|
|
6728
6961
|
this.logWarning("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8BA2\u5355\u8986\u76D6\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
6729
6962
|
lookup: lookup,
|
|
@@ -6731,11 +6964,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6731
6964
|
});
|
|
6732
6965
|
case 40:
|
|
6733
6966
|
case "end":
|
|
6734
|
-
return
|
|
6967
|
+
return _context69.stop();
|
|
6735
6968
|
}
|
|
6736
|
-
},
|
|
6969
|
+
}, _callee69, this);
|
|
6737
6970
|
}));
|
|
6738
|
-
function syncMachinecodeRedeemStatusToLocalOrder(
|
|
6971
|
+
function syncMachinecodeRedeemStatusToLocalOrder(_x76, _x77, _x78) {
|
|
6739
6972
|
return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
|
|
6740
6973
|
}
|
|
6741
6974
|
return syncMachinecodeRedeemStatusToLocalOrder;
|
|
@@ -6743,30 +6976,30 @@ var Server = /*#__PURE__*/function () {
|
|
|
6743
6976
|
}, {
|
|
6744
6977
|
key: "handleOrderCheckoutSubmit",
|
|
6745
6978
|
value: function () {
|
|
6746
|
-
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6979
|
+
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
|
|
6747
6980
|
var _params$data5, _params$data6, _this$order6, _this$order6$getLocal;
|
|
6748
6981
|
var backendPath, title, lookup, localOrder, extractedInvoice, extractedTemplateSettings, data, invoiceLayoutConfig, invoiceTemplateSettings, receiptAutoPrintPaymentStatuses, normalizedData, numberedData, checkoutData, pendingResult, pendingOrder;
|
|
6749
|
-
return _regeneratorRuntime().wrap(function
|
|
6750
|
-
while (1) switch (
|
|
6982
|
+
return _regeneratorRuntime().wrap(function _callee70$(_context70) {
|
|
6983
|
+
while (1) switch (_context70.prev = _context70.next) {
|
|
6751
6984
|
case 0:
|
|
6752
6985
|
backendPath = params.backendPath, title = params.title;
|
|
6753
6986
|
lookup = ((_params$data5 = params.data) === null || _params$data5 === void 0 ? void 0 : _params$data5.order_id) || ((_params$data6 = params.data) === null || _params$data6 === void 0 ? void 0 : _params$data6.external_sale_number);
|
|
6754
|
-
|
|
6755
|
-
if (!
|
|
6756
|
-
|
|
6987
|
+
_context70.t0 = lookup;
|
|
6988
|
+
if (!_context70.t0) {
|
|
6989
|
+
_context70.next = 7;
|
|
6757
6990
|
break;
|
|
6758
6991
|
}
|
|
6759
|
-
|
|
6992
|
+
_context70.next = 6;
|
|
6760
6993
|
return (_this$order6 = this.order) === null || _this$order6 === void 0 || (_this$order6$getLocal = _this$order6.getLocalOrderByLookup) === null || _this$order6$getLocal === void 0 ? void 0 : _this$order6$getLocal.call(_this$order6, lookup);
|
|
6761
6994
|
case 6:
|
|
6762
|
-
|
|
6995
|
+
_context70.t0 = _context70.sent;
|
|
6763
6996
|
case 7:
|
|
6764
|
-
localOrder =
|
|
6997
|
+
localOrder = _context70.t0;
|
|
6765
6998
|
if (!(requiresLocalPaymentRefresh(params.data) || requiresLocalPaymentRefresh(localOrder))) {
|
|
6766
|
-
|
|
6999
|
+
_context70.next = 10;
|
|
6767
7000
|
break;
|
|
6768
7001
|
}
|
|
6769
|
-
return
|
|
7002
|
+
return _context70.abrupt("return", {
|
|
6770
7003
|
code: 409,
|
|
6771
7004
|
status: false,
|
|
6772
7005
|
message: PAYMENT_REFRESH_MESSAGE,
|
|
@@ -6790,10 +7023,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
6790
7023
|
order_number: data === null || data === void 0 ? void 0 : data.order_number
|
|
6791
7024
|
});
|
|
6792
7025
|
if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
|
|
6793
|
-
|
|
7026
|
+
_context70.next = 19;
|
|
6794
7027
|
break;
|
|
6795
7028
|
}
|
|
6796
|
-
return
|
|
7029
|
+
return _context70.abrupt("return", this.handleSyncCheckoutSubmit({
|
|
6797
7030
|
backendPath: backendPath,
|
|
6798
7031
|
data: data,
|
|
6799
7032
|
title: title,
|
|
@@ -6802,16 +7035,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
6802
7035
|
receiptAutoPrintPaymentStatuses: receiptAutoPrintPaymentStatuses
|
|
6803
7036
|
}));
|
|
6804
7037
|
case 19:
|
|
6805
|
-
|
|
7038
|
+
_context70.next = 21;
|
|
6806
7039
|
return this.normalizeCheckoutSubmitData(data, title);
|
|
6807
7040
|
case 21:
|
|
6808
|
-
normalizedData =
|
|
6809
|
-
|
|
7041
|
+
normalizedData = _context70.sent;
|
|
7042
|
+
_context70.next = 24;
|
|
6810
7043
|
return this.ensureCheckoutOrderNumbers(normalizedData, title);
|
|
6811
7044
|
case 24:
|
|
6812
|
-
numberedData =
|
|
7045
|
+
numberedData = _context70.sent;
|
|
6813
7046
|
checkoutData = this.normalizeCheckoutCollections(stripOsPrivatePayloadFields(this.applyCheckoutFulfillmentBuzzer(numberedData, title)));
|
|
6814
|
-
|
|
7047
|
+
_context70.next = 28;
|
|
6815
7048
|
return this.handlePendingSyncCheckoutOrder({
|
|
6816
7049
|
backendPath: backendPath,
|
|
6817
7050
|
data: checkoutData,
|
|
@@ -6820,18 +7053,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
6820
7053
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6821
7054
|
});
|
|
6822
7055
|
case 28:
|
|
6823
|
-
pendingResult =
|
|
7056
|
+
pendingResult = _context70.sent;
|
|
6824
7057
|
if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
|
|
6825
|
-
|
|
7058
|
+
_context70.next = 43;
|
|
6826
7059
|
break;
|
|
6827
7060
|
}
|
|
6828
7061
|
pendingOrder = pendingResult.data;
|
|
6829
7062
|
if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(pendingOrder, receiptAutoPrintPaymentStatuses) && this.shouldAutoPrintCheckoutReceipt())) {
|
|
6830
|
-
|
|
7063
|
+
_context70.next = 41;
|
|
6831
7064
|
break;
|
|
6832
7065
|
}
|
|
6833
|
-
|
|
6834
|
-
|
|
7066
|
+
_context70.prev = 32;
|
|
7067
|
+
_context70.next = 35;
|
|
6835
7068
|
return this.dispatchLocalReceiptPrint({
|
|
6836
7069
|
checkoutData: checkoutData,
|
|
6837
7070
|
order: pendingOrder,
|
|
@@ -6841,19 +7074,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
6841
7074
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6842
7075
|
});
|
|
6843
7076
|
case 35:
|
|
6844
|
-
|
|
7077
|
+
_context70.next = 41;
|
|
6845
7078
|
break;
|
|
6846
7079
|
case 37:
|
|
6847
|
-
|
|
6848
|
-
|
|
7080
|
+
_context70.prev = 37;
|
|
7081
|
+
_context70.t1 = _context70["catch"](32);
|
|
6849
7082
|
// The sale is already persisted. A failed receipt must not cancel its
|
|
6850
7083
|
// sync task or send an unfiltered fallback to the printer.
|
|
6851
|
-
pendingResult.receipt_print_error = this.getUnknownErrorMessage(
|
|
7084
|
+
pendingResult.receipt_print_error = this.getUnknownErrorMessage(_context70.t1);
|
|
6852
7085
|
this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u4ECD\u7EE7\u7EED\u540C\u6B65"), {
|
|
6853
7086
|
error: pendingResult.receipt_print_error
|
|
6854
7087
|
});
|
|
6855
7088
|
case 41:
|
|
6856
|
-
|
|
7089
|
+
_context70.next = 43;
|
|
6857
7090
|
return this.dispatchCheckoutSyncTask({
|
|
6858
7091
|
backendPath: backendPath,
|
|
6859
7092
|
data: checkoutData,
|
|
@@ -6863,23 +7096,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
6863
7096
|
});
|
|
6864
7097
|
case 43:
|
|
6865
7098
|
if (pendingResult.data.order_id) {
|
|
6866
|
-
|
|
7099
|
+
_context70.next = 45;
|
|
6867
7100
|
break;
|
|
6868
7101
|
}
|
|
6869
|
-
return
|
|
7102
|
+
return _context70.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
|
|
6870
7103
|
data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
|
|
6871
7104
|
order_id: pendingResult.data.external_sale_number
|
|
6872
7105
|
})
|
|
6873
7106
|
}));
|
|
6874
7107
|
case 45:
|
|
6875
|
-
return
|
|
7108
|
+
return _context70.abrupt("return", pendingResult);
|
|
6876
7109
|
case 46:
|
|
6877
7110
|
case "end":
|
|
6878
|
-
return
|
|
7111
|
+
return _context70.stop();
|
|
6879
7112
|
}
|
|
6880
|
-
},
|
|
7113
|
+
}, _callee70, this, [[32, 37]]);
|
|
6881
7114
|
}));
|
|
6882
|
-
function handleOrderCheckoutSubmit(
|
|
7115
|
+
function handleOrderCheckoutSubmit(_x79) {
|
|
6883
7116
|
return _handleOrderCheckoutSubmit.apply(this, arguments);
|
|
6884
7117
|
}
|
|
6885
7118
|
return handleOrderCheckoutSubmit;
|
|
@@ -6887,27 +7120,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
6887
7120
|
}, {
|
|
6888
7121
|
key: "handleSyncCheckoutSubmit",
|
|
6889
7122
|
value: function () {
|
|
6890
|
-
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7123
|
+
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(params) {
|
|
6891
7124
|
var _this$app18;
|
|
6892
7125
|
var backendPath, data, title, invoiceLayoutConfig, invoiceTemplateSettings, receiptAutoPrintPaymentStatuses, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
|
|
6893
|
-
return _regeneratorRuntime().wrap(function
|
|
6894
|
-
while (1) switch (
|
|
7126
|
+
return _regeneratorRuntime().wrap(function _callee71$(_context71) {
|
|
7127
|
+
while (1) switch (_context71.prev = _context71.next) {
|
|
6895
7128
|
case 0:
|
|
6896
7129
|
backendPath = params.backendPath, data = params.data, title = params.title, invoiceLayoutConfig = params.invoiceLayoutConfig, invoiceTemplateSettings = params.invoiceTemplateSettings, receiptAutoPrintPaymentStatuses = params.receiptAutoPrintPaymentStatuses;
|
|
6897
7130
|
if ((_this$app18 = this.app) !== null && _this$app18 !== void 0 && (_this$app18 = _this$app18.request) !== null && _this$app18 !== void 0 && _this$app18.post) {
|
|
6898
|
-
|
|
7131
|
+
_context71.next = 4;
|
|
6899
7132
|
break;
|
|
6900
7133
|
}
|
|
6901
7134
|
this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
|
|
6902
|
-
return
|
|
7135
|
+
return _context71.abrupt("return", {
|
|
6903
7136
|
code: 500,
|
|
6904
7137
|
status: false,
|
|
6905
7138
|
message: 'app.request 不可用',
|
|
6906
7139
|
data: null
|
|
6907
7140
|
});
|
|
6908
7141
|
case 4:
|
|
6909
|
-
|
|
6910
|
-
|
|
7142
|
+
_context71.prev = 4;
|
|
7143
|
+
_context71.next = 7;
|
|
6911
7144
|
return this.runCheckoutSync({
|
|
6912
7145
|
backendPath: backendPath,
|
|
6913
7146
|
data: data,
|
|
@@ -6917,13 +7150,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6917
7150
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6918
7151
|
});
|
|
6919
7152
|
case 7:
|
|
6920
|
-
syncResult =
|
|
7153
|
+
syncResult = _context71.sent;
|
|
6921
7154
|
if (!syncResult.rejected) {
|
|
6922
|
-
|
|
7155
|
+
_context71.next = 11;
|
|
6923
7156
|
break;
|
|
6924
7157
|
}
|
|
6925
7158
|
normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
|
|
6926
|
-
return
|
|
7159
|
+
return _context71.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
|
|
6927
7160
|
status: false,
|
|
6928
7161
|
message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
|
|
6929
7162
|
data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
|
|
@@ -6932,11 +7165,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6932
7165
|
response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
|
|
6933
7166
|
syncedOrder = syncResult.syncedOrder;
|
|
6934
7167
|
if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(syncedOrder, receiptAutoPrintPaymentStatuses) && (receiptAutoPrintPaymentStatuses === undefined || this.shouldAutoPrintCheckoutReceipt()))) {
|
|
6935
|
-
|
|
7168
|
+
_context71.next = 23;
|
|
6936
7169
|
break;
|
|
6937
7170
|
}
|
|
6938
|
-
|
|
6939
|
-
|
|
7171
|
+
_context71.prev = 14;
|
|
7172
|
+
_context71.next = 17;
|
|
6940
7173
|
return this.dispatchLocalReceiptPrint({
|
|
6941
7174
|
checkoutData: syncResult.checkoutData,
|
|
6942
7175
|
order: syncedOrder,
|
|
@@ -6946,41 +7179,41 @@ var Server = /*#__PURE__*/function () {
|
|
|
6946
7179
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6947
7180
|
});
|
|
6948
7181
|
case 17:
|
|
6949
|
-
|
|
7182
|
+
_context71.next = 23;
|
|
6950
7183
|
break;
|
|
6951
7184
|
case 19:
|
|
6952
|
-
|
|
6953
|
-
|
|
7185
|
+
_context71.prev = 19;
|
|
7186
|
+
_context71.t0 = _context71["catch"](14);
|
|
6954
7187
|
// Checkout already succeeded remotely; report the receipt failure
|
|
6955
7188
|
// separately instead of implying that payment/order creation failed.
|
|
6956
|
-
response.receipt_print_error = this.getUnknownErrorMessage(
|
|
7189
|
+
response.receipt_print_error = this.getUnknownErrorMessage(_context71.t0);
|
|
6957
7190
|
this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u5DF2\u540C\u6B65"), {
|
|
6958
7191
|
error: response.receipt_print_error
|
|
6959
7192
|
});
|
|
6960
7193
|
case 23:
|
|
6961
|
-
return
|
|
7194
|
+
return _context71.abrupt("return", response);
|
|
6962
7195
|
case 26:
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
backendError = this.extractBackendErrorResponse(
|
|
7196
|
+
_context71.prev = 26;
|
|
7197
|
+
_context71.t1 = _context71["catch"](4);
|
|
7198
|
+
backendError = this.extractBackendErrorResponse(_context71.t1);
|
|
6966
7199
|
if (!backendError) {
|
|
6967
|
-
|
|
7200
|
+
_context71.next = 32;
|
|
6968
7201
|
break;
|
|
6969
7202
|
}
|
|
6970
7203
|
_normalized = this.normalizeCheckoutResponse(backendError);
|
|
6971
|
-
return
|
|
7204
|
+
return _context71.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
|
|
6972
7205
|
status: false,
|
|
6973
7206
|
message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
|
|
6974
7207
|
data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
|
|
6975
7208
|
}));
|
|
6976
7209
|
case 32:
|
|
6977
|
-
message = this.getUnknownErrorMessage(
|
|
7210
|
+
message = this.getUnknownErrorMessage(_context71.t1);
|
|
6978
7211
|
this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
|
|
6979
7212
|
backendPath: backendPath,
|
|
6980
7213
|
error: message,
|
|
6981
|
-
error_detail: this.normalizeUnknownError(
|
|
7214
|
+
error_detail: this.normalizeUnknownError(_context71.t1)
|
|
6982
7215
|
});
|
|
6983
|
-
return
|
|
7216
|
+
return _context71.abrupt("return", {
|
|
6984
7217
|
code: 500,
|
|
6985
7218
|
status: false,
|
|
6986
7219
|
message: message,
|
|
@@ -6988,11 +7221,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6988
7221
|
});
|
|
6989
7222
|
case 35:
|
|
6990
7223
|
case "end":
|
|
6991
|
-
return
|
|
7224
|
+
return _context71.stop();
|
|
6992
7225
|
}
|
|
6993
|
-
},
|
|
7226
|
+
}, _callee71, this, [[4, 26], [14, 19]]);
|
|
6994
7227
|
}));
|
|
6995
|
-
function handleSyncCheckoutSubmit(
|
|
7228
|
+
function handleSyncCheckoutSubmit(_x80) {
|
|
6996
7229
|
return _handleSyncCheckoutSubmit.apply(this, arguments);
|
|
6997
7230
|
}
|
|
6998
7231
|
return handleSyncCheckoutSubmit;
|
|
@@ -7000,10 +7233,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
7000
7233
|
}, {
|
|
7001
7234
|
key: "handleOrderDraftSubmit",
|
|
7002
7235
|
value: function () {
|
|
7003
|
-
var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7236
|
+
var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(params) {
|
|
7004
7237
|
var title, extractedInvoice, _this$extractInvoiceT, data, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
|
|
7005
|
-
return _regeneratorRuntime().wrap(function
|
|
7006
|
-
while (1) switch (
|
|
7238
|
+
return _regeneratorRuntime().wrap(function _callee72$(_context72) {
|
|
7239
|
+
while (1) switch (_context72.prev = _context72.next) {
|
|
7007
7240
|
case 0:
|
|
7008
7241
|
title = params.title;
|
|
7009
7242
|
extractedInvoice = this.extractInvoiceLayoutConfig(params.data, {
|
|
@@ -7017,10 +7250,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
7017
7250
|
external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
|
|
7018
7251
|
order_number: data === null || data === void 0 ? void 0 : data.order_number
|
|
7019
7252
|
});
|
|
7020
|
-
|
|
7253
|
+
_context72.next = 6;
|
|
7021
7254
|
return this.normalizeCheckoutSubmitData(data, title);
|
|
7022
7255
|
case 6:
|
|
7023
|
-
normalizedData =
|
|
7256
|
+
normalizedData = _context72.sent;
|
|
7024
7257
|
createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
7025
7258
|
draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
|
|
7026
7259
|
external_sale_number: normalizedData.external_sale_number || "LOCAL_DRAFT_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 10)),
|
|
@@ -7030,26 +7263,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
7030
7263
|
is_draft_order: 1
|
|
7031
7264
|
});
|
|
7032
7265
|
if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
|
|
7033
|
-
|
|
7266
|
+
_context72.next = 12;
|
|
7034
7267
|
break;
|
|
7035
7268
|
}
|
|
7036
7269
|
this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
|
|
7037
|
-
return
|
|
7270
|
+
return _context72.abrupt("return", {
|
|
7038
7271
|
code: 500,
|
|
7039
7272
|
status: false,
|
|
7040
7273
|
message: 'Order 模块不支持本地草稿写入',
|
|
7041
7274
|
data: null
|
|
7042
7275
|
});
|
|
7043
7276
|
case 12:
|
|
7044
|
-
|
|
7045
|
-
|
|
7277
|
+
_context72.prev = 12;
|
|
7278
|
+
_context72.next = 15;
|
|
7046
7279
|
return this.order.upsertLocalDraftOrders([draftOrder]);
|
|
7047
7280
|
case 15:
|
|
7048
7281
|
this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
|
|
7049
7282
|
order_id: draftOrder.order_id,
|
|
7050
7283
|
external_sale_number: draftOrder.external_sale_number
|
|
7051
7284
|
});
|
|
7052
|
-
return
|
|
7285
|
+
return _context72.abrupt("return", {
|
|
7053
7286
|
code: 200,
|
|
7054
7287
|
status: true,
|
|
7055
7288
|
message: '',
|
|
@@ -7061,13 +7294,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
7061
7294
|
})
|
|
7062
7295
|
});
|
|
7063
7296
|
case 19:
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
errorMessage =
|
|
7297
|
+
_context72.prev = 19;
|
|
7298
|
+
_context72.t0 = _context72["catch"](12);
|
|
7299
|
+
errorMessage = _context72.t0 instanceof Error ? _context72.t0.message : String(_context72.t0);
|
|
7067
7300
|
this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
|
|
7068
7301
|
error: errorMessage
|
|
7069
7302
|
});
|
|
7070
|
-
return
|
|
7303
|
+
return _context72.abrupt("return", {
|
|
7071
7304
|
code: 500,
|
|
7072
7305
|
status: false,
|
|
7073
7306
|
message: errorMessage,
|
|
@@ -7075,11 +7308,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
7075
7308
|
});
|
|
7076
7309
|
case 24:
|
|
7077
7310
|
case "end":
|
|
7078
|
-
return
|
|
7311
|
+
return _context72.stop();
|
|
7079
7312
|
}
|
|
7080
|
-
},
|
|
7313
|
+
}, _callee72, this, [[12, 19]]);
|
|
7081
7314
|
}));
|
|
7082
|
-
function handleOrderDraftSubmit(
|
|
7315
|
+
function handleOrderDraftSubmit(_x81) {
|
|
7083
7316
|
return _handleOrderDraftSubmit.apply(this, arguments);
|
|
7084
7317
|
}
|
|
7085
7318
|
return handleOrderDraftSubmit;
|
|
@@ -7087,26 +7320,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
7087
7320
|
}, {
|
|
7088
7321
|
key: "handlePendingSyncCheckoutOrder",
|
|
7089
7322
|
value: function () {
|
|
7090
|
-
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7091
|
-
var
|
|
7323
|
+
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(params) {
|
|
7324
|
+
var _this20 = this;
|
|
7092
7325
|
var backendPath, data, title, reason, invoiceTemplateSettings, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
|
|
7093
|
-
return _regeneratorRuntime().wrap(function
|
|
7094
|
-
while (1) switch (
|
|
7326
|
+
return _regeneratorRuntime().wrap(function _callee73$(_context73) {
|
|
7327
|
+
while (1) switch (_context73.prev = _context73.next) {
|
|
7095
7328
|
case 0:
|
|
7096
7329
|
backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason, invoiceTemplateSettings = params.invoiceTemplateSettings;
|
|
7097
|
-
|
|
7330
|
+
_context73.next = 3;
|
|
7098
7331
|
return this.buildPendingSyncCheckoutOrder(data, invoiceTemplateSettings);
|
|
7099
7332
|
case 3:
|
|
7100
|
-
pendingOrder =
|
|
7333
|
+
pendingOrder = _context73.sent;
|
|
7101
7334
|
if (pendingOrder) {
|
|
7102
|
-
|
|
7335
|
+
_context73.next = 7;
|
|
7103
7336
|
break;
|
|
7104
7337
|
}
|
|
7105
7338
|
this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
|
|
7106
7339
|
backendPath: backendPath,
|
|
7107
7340
|
reason: reason
|
|
7108
7341
|
});
|
|
7109
|
-
return
|
|
7342
|
+
return _context73.abrupt("return", {
|
|
7110
7343
|
code: 500,
|
|
7111
7344
|
status: false,
|
|
7112
7345
|
message: '订单缺少本地存储标识,无法写入待同步队列',
|
|
@@ -7114,22 +7347,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
7114
7347
|
});
|
|
7115
7348
|
case 7:
|
|
7116
7349
|
if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
|
|
7117
|
-
|
|
7350
|
+
_context73.next = 10;
|
|
7118
7351
|
break;
|
|
7119
7352
|
}
|
|
7120
7353
|
this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
|
|
7121
7354
|
backendPath: backendPath,
|
|
7122
7355
|
reason: reason
|
|
7123
7356
|
});
|
|
7124
|
-
return
|
|
7357
|
+
return _context73.abrupt("return", {
|
|
7125
7358
|
code: 500,
|
|
7126
7359
|
status: false,
|
|
7127
7360
|
message: 'Order 模块不支持本地待同步写入',
|
|
7128
7361
|
data: null
|
|
7129
7362
|
});
|
|
7130
7363
|
case 10:
|
|
7131
|
-
|
|
7132
|
-
|
|
7364
|
+
_context73.prev = 10;
|
|
7365
|
+
_context73.next = 13;
|
|
7133
7366
|
return this.order.upsertPendingSyncOrders([pendingOrder]);
|
|
7134
7367
|
case 13:
|
|
7135
7368
|
this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
|
|
@@ -7141,9 +7374,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7141
7374
|
});
|
|
7142
7375
|
changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
|
|
7143
7376
|
var _payment$metadata;
|
|
7144
|
-
return sum +
|
|
7377
|
+
return sum + _this20.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
|
|
7145
7378
|
}, 0);
|
|
7146
|
-
return
|
|
7379
|
+
return _context73.abrupt("return", {
|
|
7147
7380
|
code: 200,
|
|
7148
7381
|
status: true,
|
|
7149
7382
|
message: '',
|
|
@@ -7158,15 +7391,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
7158
7391
|
})
|
|
7159
7392
|
});
|
|
7160
7393
|
case 18:
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
errorMessage =
|
|
7394
|
+
_context73.prev = 18;
|
|
7395
|
+
_context73.t0 = _context73["catch"](10);
|
|
7396
|
+
errorMessage = _context73.t0 instanceof Error ? _context73.t0.message : String(_context73.t0);
|
|
7164
7397
|
this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
|
|
7165
7398
|
backendPath: backendPath,
|
|
7166
7399
|
reason: reason,
|
|
7167
7400
|
error: errorMessage
|
|
7168
7401
|
});
|
|
7169
|
-
return
|
|
7402
|
+
return _context73.abrupt("return", {
|
|
7170
7403
|
code: 500,
|
|
7171
7404
|
status: false,
|
|
7172
7405
|
message: errorMessage,
|
|
@@ -7174,11 +7407,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
7174
7407
|
});
|
|
7175
7408
|
case 23:
|
|
7176
7409
|
case "end":
|
|
7177
|
-
return
|
|
7410
|
+
return _context73.stop();
|
|
7178
7411
|
}
|
|
7179
|
-
},
|
|
7412
|
+
}, _callee73, this, [[10, 18]]);
|
|
7180
7413
|
}));
|
|
7181
|
-
function handlePendingSyncCheckoutOrder(
|
|
7414
|
+
function handlePendingSyncCheckoutOrder(_x82) {
|
|
7182
7415
|
return _handlePendingSyncCheckoutOrder.apply(this, arguments);
|
|
7183
7416
|
}
|
|
7184
7417
|
return handlePendingSyncCheckoutOrder;
|
|
@@ -7186,45 +7419,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
7186
7419
|
}, {
|
|
7187
7420
|
key: "buildPendingSyncCheckoutOrder",
|
|
7188
7421
|
value: function () {
|
|
7189
|
-
var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7422
|
+
var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(data, invoiceTemplateSettings) {
|
|
7190
7423
|
var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
|
|
7191
|
-
return _regeneratorRuntime().wrap(function
|
|
7192
|
-
while (1) switch (
|
|
7424
|
+
return _regeneratorRuntime().wrap(function _callee74$(_context74) {
|
|
7425
|
+
while (1) switch (_context74.prev = _context74.next) {
|
|
7193
7426
|
case 0:
|
|
7194
7427
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
7195
|
-
|
|
7428
|
+
_context74.next = 2;
|
|
7196
7429
|
break;
|
|
7197
7430
|
}
|
|
7198
|
-
return
|
|
7431
|
+
return _context74.abrupt("return", null);
|
|
7199
7432
|
case 2:
|
|
7200
7433
|
hasStorageKey = data.external_sale_number !== undefined && data.external_sale_number !== null && data.external_sale_number !== '' ? true : data.order_id !== undefined && data.order_id !== null && data.order_id !== '';
|
|
7201
7434
|
if (hasStorageKey) {
|
|
7202
|
-
|
|
7435
|
+
_context74.next = 5;
|
|
7203
7436
|
break;
|
|
7204
7437
|
}
|
|
7205
|
-
return
|
|
7438
|
+
return _context74.abrupt("return", null);
|
|
7206
7439
|
case 5:
|
|
7207
7440
|
pendingOrder = this.normalizeCheckoutCollections(_objectSpread(_objectSpread({}, data), {}, {
|
|
7208
7441
|
need_sync: 1,
|
|
7209
7442
|
is_draft_order: 0
|
|
7210
7443
|
}));
|
|
7211
|
-
|
|
7444
|
+
_context74.next = 8;
|
|
7212
7445
|
return this.buildSmallTicketProductMap(pendingOrder);
|
|
7213
7446
|
case 8:
|
|
7214
|
-
productMap =
|
|
7447
|
+
productMap = _context74.sent;
|
|
7215
7448
|
orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
|
|
7216
|
-
return
|
|
7449
|
+
return _context74.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
|
|
7217
7450
|
requireFullyPaid: true,
|
|
7218
7451
|
productMap: productMap,
|
|
7219
7452
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
7220
7453
|
}));
|
|
7221
7454
|
case 11:
|
|
7222
7455
|
case "end":
|
|
7223
|
-
return
|
|
7456
|
+
return _context74.stop();
|
|
7224
7457
|
}
|
|
7225
|
-
},
|
|
7458
|
+
}, _callee74, this);
|
|
7226
7459
|
}));
|
|
7227
|
-
function buildPendingSyncCheckoutOrder(
|
|
7460
|
+
function buildPendingSyncCheckoutOrder(_x83, _x84) {
|
|
7228
7461
|
return _buildPendingSyncCheckoutOrder.apply(this, arguments);
|
|
7229
7462
|
}
|
|
7230
7463
|
return buildPendingSyncCheckoutOrder;
|
|
@@ -7261,11 +7494,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
7261
7494
|
}, {
|
|
7262
7495
|
key: "shouldAutoPrintReceiptForPaymentStatus",
|
|
7263
7496
|
value: function shouldAutoPrintReceiptForPaymentStatus(order, statuses) {
|
|
7264
|
-
var
|
|
7497
|
+
var _this21 = this;
|
|
7265
7498
|
if (statuses === undefined) return this.isSalesOrderFullyPaid(order);
|
|
7266
7499
|
var paymentStatus = String((order === null || order === void 0 ? void 0 : order.payment_status) || '').toLowerCase();
|
|
7267
7500
|
return statuses.some(function (status) {
|
|
7268
|
-
return status === 'paid' ?
|
|
7501
|
+
return status === 'paid' ? _this21.isSalesOrderFullyPaid(order) : paymentStatus === status;
|
|
7269
7502
|
});
|
|
7270
7503
|
}
|
|
7271
7504
|
}, {
|
|
@@ -7294,32 +7527,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
7294
7527
|
}, {
|
|
7295
7528
|
key: "isSalesOrderFullyPaid",
|
|
7296
7529
|
value: function isSalesOrderFullyPaid(order) {
|
|
7297
|
-
var _order$summary$amount, _order$
|
|
7530
|
+
var _order$summary$amount, _order$summary3, _ref77, _ref78, _order$summary$expect, _order$summary4, _order$summary5;
|
|
7298
7531
|
if (!order || _typeof(order) !== 'object') return false;
|
|
7299
7532
|
var paymentStatus = String(order.payment_status || '').toLowerCase();
|
|
7300
7533
|
if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
|
|
7301
7534
|
if (paymentStatus === 'partially_paid' || paymentStatus === 'payment_processing' || paymentStatus === 'pending' || paymentStatus === 'unpaid') {
|
|
7302
7535
|
return false;
|
|
7303
7536
|
}
|
|
7304
|
-
var amountGap = (_order$summary$amount = (_order$
|
|
7537
|
+
var amountGap = (_order$summary$amount = (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.amount_gap) !== null && _order$summary$amount !== void 0 ? _order$summary$amount : order.amount_gap;
|
|
7305
7538
|
if (amountGap !== undefined && amountGap !== null && amountGap !== '') {
|
|
7306
7539
|
return this.toAmountNumber(amountGap) <= 0;
|
|
7307
7540
|
}
|
|
7308
7541
|
var paidAmount = this.sumPaidOrderPayments(order.payments);
|
|
7309
|
-
var targetAmount = this.toAmountNumber((
|
|
7542
|
+
var targetAmount = this.toAmountNumber((_ref77 = (_ref78 = (_order$summary$expect = (_order$summary4 = order.summary) === null || _order$summary4 === void 0 ? void 0 : _order$summary4.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary5 = order.summary) === null || _order$summary5 === void 0 ? void 0 : _order$summary5.total_amount) !== null && _ref78 !== void 0 ? _ref78 : order.expect_amount) !== null && _ref77 !== void 0 ? _ref77 : order.total_amount);
|
|
7310
7543
|
if (targetAmount <= 0) return paidAmount > 0;
|
|
7311
7544
|
return paidAmount >= targetAmount;
|
|
7312
7545
|
}
|
|
7313
7546
|
}, {
|
|
7314
7547
|
key: "sumPaidOrderPayments",
|
|
7315
7548
|
value: function sumPaidOrderPayments(payments) {
|
|
7316
|
-
var
|
|
7549
|
+
var _this22 = this;
|
|
7317
7550
|
if (!Array.isArray(payments)) return 0;
|
|
7318
7551
|
return payments.reduce(function (sum, payment) {
|
|
7319
7552
|
var _payment$amount;
|
|
7320
7553
|
var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
|
|
7321
7554
|
if (status !== 'paid') return sum;
|
|
7322
|
-
return sum +
|
|
7555
|
+
return sum + _this22.toAmountNumber((_payment$amount = payment === null || payment === void 0 ? void 0 : payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment === null || payment === void 0 ? void 0 : payment.origin_amount);
|
|
7323
7556
|
}, 0);
|
|
7324
7557
|
}
|
|
7325
7558
|
}, {
|
|
@@ -7333,12 +7566,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
7333
7566
|
}, {
|
|
7334
7567
|
key: "buildSmallTicketProductMap",
|
|
7335
7568
|
value: function () {
|
|
7336
|
-
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7569
|
+
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(order) {
|
|
7337
7570
|
var _this$products3,
|
|
7338
|
-
|
|
7571
|
+
_this23 = this;
|
|
7339
7572
|
var products, productIdSet, productIds, entries;
|
|
7340
|
-
return _regeneratorRuntime().wrap(function
|
|
7341
|
-
while (1) switch (
|
|
7573
|
+
return _regeneratorRuntime().wrap(function _callee76$(_context76) {
|
|
7574
|
+
while (1) switch (_context76.prev = _context76.next) {
|
|
7342
7575
|
case 0:
|
|
7343
7576
|
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
|
|
7344
7577
|
productIdSet = new Set();
|
|
@@ -7350,8 +7583,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
7350
7583
|
}
|
|
7351
7584
|
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
7352
7585
|
product.product_bundle.forEach(function (bundle) {
|
|
7353
|
-
var
|
|
7354
|
-
var bundleProductId = (
|
|
7586
|
+
var _ref79, _bundle$bundle_produc;
|
|
7587
|
+
var bundleProductId = (_ref79 = (_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 && _ref79 !== void 0 ? _ref79 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
|
|
7355
7588
|
if (bundleProductId !== undefined && bundleProductId !== null && bundleProductId !== '') {
|
|
7356
7589
|
productIdSet.add(bundleProductId);
|
|
7357
7590
|
}
|
|
@@ -7360,45 +7593,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
7360
7593
|
});
|
|
7361
7594
|
productIds = Array.from(productIdSet);
|
|
7362
7595
|
if (!(!productIds.length || typeof ((_this$products3 = this.products) === null || _this$products3 === void 0 ? void 0 : _this$products3.getProductById) !== 'function')) {
|
|
7363
|
-
|
|
7596
|
+
_context76.next = 6;
|
|
7364
7597
|
break;
|
|
7365
7598
|
}
|
|
7366
|
-
return
|
|
7599
|
+
return _context76.abrupt("return", {});
|
|
7367
7600
|
case 6:
|
|
7368
|
-
|
|
7601
|
+
_context76.next = 8;
|
|
7369
7602
|
return Promise.all(productIds.map( /*#__PURE__*/function () {
|
|
7370
|
-
var
|
|
7371
|
-
var
|
|
7372
|
-
return _regeneratorRuntime().wrap(function
|
|
7373
|
-
while (1) switch (
|
|
7603
|
+
var _ref80 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(id) {
|
|
7604
|
+
var _this23$products, _this23$products$getP, product;
|
|
7605
|
+
return _regeneratorRuntime().wrap(function _callee75$(_context75) {
|
|
7606
|
+
while (1) switch (_context75.prev = _context75.next) {
|
|
7374
7607
|
case 0:
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
return (
|
|
7608
|
+
_context75.prev = 0;
|
|
7609
|
+
_context75.next = 3;
|
|
7610
|
+
return (_this23$products = _this23.products) === null || _this23$products === void 0 || (_this23$products$getP = _this23$products.getProductById) === null || _this23$products$getP === void 0 ? void 0 : _this23$products$getP.call(_this23$products, Number(id));
|
|
7378
7611
|
case 3:
|
|
7379
|
-
product =
|
|
7380
|
-
return
|
|
7612
|
+
product = _context75.sent;
|
|
7613
|
+
return _context75.abrupt("return", product ? [String(id), product] : null);
|
|
7381
7614
|
case 7:
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7615
|
+
_context75.prev = 7;
|
|
7616
|
+
_context75.t0 = _context75["catch"](0);
|
|
7617
|
+
_this23.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
|
|
7385
7618
|
product_id: id,
|
|
7386
|
-
error:
|
|
7619
|
+
error: _context75.t0 instanceof Error ? _context75.t0.message : String(_context75.t0)
|
|
7387
7620
|
});
|
|
7388
|
-
return
|
|
7621
|
+
return _context75.abrupt("return", null);
|
|
7389
7622
|
case 11:
|
|
7390
7623
|
case "end":
|
|
7391
|
-
return
|
|
7624
|
+
return _context75.stop();
|
|
7392
7625
|
}
|
|
7393
|
-
},
|
|
7626
|
+
}, _callee75, null, [[0, 7]]);
|
|
7394
7627
|
}));
|
|
7395
|
-
return function (
|
|
7396
|
-
return
|
|
7628
|
+
return function (_x86) {
|
|
7629
|
+
return _ref80.apply(this, arguments);
|
|
7397
7630
|
};
|
|
7398
7631
|
}()));
|
|
7399
7632
|
case 8:
|
|
7400
|
-
entries =
|
|
7401
|
-
return
|
|
7633
|
+
entries = _context76.sent;
|
|
7634
|
+
return _context76.abrupt("return", entries.reduce(function (map, entry) {
|
|
7402
7635
|
if (!entry) return map;
|
|
7403
7636
|
var _entry = _slicedToArray(entry, 2),
|
|
7404
7637
|
id = _entry[0],
|
|
@@ -7408,11 +7641,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
7408
7641
|
}, {}));
|
|
7409
7642
|
case 10:
|
|
7410
7643
|
case "end":
|
|
7411
|
-
return
|
|
7644
|
+
return _context76.stop();
|
|
7412
7645
|
}
|
|
7413
|
-
},
|
|
7646
|
+
}, _callee76, this);
|
|
7414
7647
|
}));
|
|
7415
|
-
function buildSmallTicketProductMap(
|
|
7648
|
+
function buildSmallTicketProductMap(_x85) {
|
|
7416
7649
|
return _buildSmallTicketProductMap.apply(this, arguments);
|
|
7417
7650
|
}
|
|
7418
7651
|
return buildSmallTicketProductMap;
|
|
@@ -7432,8 +7665,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
7432
7665
|
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);
|
|
7433
7666
|
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
7434
7667
|
product.product_bundle.forEach(function (bundle) {
|
|
7435
|
-
var
|
|
7436
|
-
addProductId((
|
|
7668
|
+
var _ref81, _bundle$bundle_produc2;
|
|
7669
|
+
addProductId((_ref81 = (_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 && _ref81 !== void 0 ? _ref81 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
|
|
7437
7670
|
});
|
|
7438
7671
|
}
|
|
7439
7672
|
});
|
|
@@ -7442,40 +7675,40 @@ var Server = /*#__PURE__*/function () {
|
|
|
7442
7675
|
}, {
|
|
7443
7676
|
key: "buildSalesDetailProductSnapshotMap",
|
|
7444
7677
|
value: function () {
|
|
7445
|
-
var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7678
|
+
var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(order) {
|
|
7446
7679
|
var _this$products4;
|
|
7447
7680
|
var productIds, getSnapshots;
|
|
7448
|
-
return _regeneratorRuntime().wrap(function
|
|
7449
|
-
while (1) switch (
|
|
7681
|
+
return _regeneratorRuntime().wrap(function _callee77$(_context77) {
|
|
7682
|
+
while (1) switch (_context77.prev = _context77.next) {
|
|
7450
7683
|
case 0:
|
|
7451
7684
|
productIds = this.collectSalesDetailProductIds(order);
|
|
7452
7685
|
getSnapshots = (_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductSnapshotsByIds;
|
|
7453
7686
|
if (!(!productIds.length || typeof getSnapshots !== 'function')) {
|
|
7454
|
-
|
|
7687
|
+
_context77.next = 4;
|
|
7455
7688
|
break;
|
|
7456
7689
|
}
|
|
7457
|
-
return
|
|
7690
|
+
return _context77.abrupt("return", {});
|
|
7458
7691
|
case 4:
|
|
7459
|
-
|
|
7460
|
-
|
|
7692
|
+
_context77.prev = 4;
|
|
7693
|
+
_context77.next = 7;
|
|
7461
7694
|
return getSnapshots.call(this.products, productIds);
|
|
7462
7695
|
case 7:
|
|
7463
|
-
return
|
|
7696
|
+
return _context77.abrupt("return", _context77.sent);
|
|
7464
7697
|
case 10:
|
|
7465
|
-
|
|
7466
|
-
|
|
7698
|
+
_context77.prev = 10;
|
|
7699
|
+
_context77.t0 = _context77["catch"](4);
|
|
7467
7700
|
this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
|
|
7468
7701
|
product_ids: productIds,
|
|
7469
|
-
error:
|
|
7702
|
+
error: _context77.t0 instanceof Error ? _context77.t0.message : String(_context77.t0)
|
|
7470
7703
|
});
|
|
7471
|
-
return
|
|
7704
|
+
return _context77.abrupt("return", {});
|
|
7472
7705
|
case 14:
|
|
7473
7706
|
case "end":
|
|
7474
|
-
return
|
|
7707
|
+
return _context77.stop();
|
|
7475
7708
|
}
|
|
7476
|
-
},
|
|
7709
|
+
}, _callee77, this, [[4, 10]]);
|
|
7477
7710
|
}));
|
|
7478
|
-
function buildSalesDetailProductSnapshotMap(
|
|
7711
|
+
function buildSalesDetailProductSnapshotMap(_x87) {
|
|
7479
7712
|
return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
|
|
7480
7713
|
}
|
|
7481
7714
|
return buildSalesDetailProductSnapshotMap;
|
|
@@ -7509,9 +7742,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7509
7742
|
if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
|
|
7510
7743
|
var hasChanged = false;
|
|
7511
7744
|
var productBundle = product.product_bundle.map(function (bundle) {
|
|
7512
|
-
var
|
|
7745
|
+
var _ref82, _bundle$bundle_produc3;
|
|
7513
7746
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
7514
|
-
var rawProductId = (
|
|
7747
|
+
var rawProductId = (_ref82 = (_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 && _ref82 !== void 0 ? _ref82 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
|
|
7515
7748
|
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
|
|
7516
7749
|
var productId = Number(rawProductId);
|
|
7517
7750
|
if (!Number.isFinite(productId)) return bundle;
|
|
@@ -7531,53 +7764,53 @@ var Server = /*#__PURE__*/function () {
|
|
|
7531
7764
|
}, {
|
|
7532
7765
|
key: "withSalesDetailProductSnapshots",
|
|
7533
7766
|
value: function () {
|
|
7534
|
-
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7535
|
-
var
|
|
7767
|
+
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78(order) {
|
|
7768
|
+
var _this24 = this;
|
|
7536
7769
|
var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
|
|
7537
|
-
return _regeneratorRuntime().wrap(function
|
|
7538
|
-
while (1) switch (
|
|
7770
|
+
return _regeneratorRuntime().wrap(function _callee78$(_context78) {
|
|
7771
|
+
while (1) switch (_context78.prev = _context78.next) {
|
|
7539
7772
|
case 0:
|
|
7540
7773
|
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
|
|
7541
7774
|
if (products !== null && products !== void 0 && products.length) {
|
|
7542
|
-
|
|
7775
|
+
_context78.next = 3;
|
|
7543
7776
|
break;
|
|
7544
7777
|
}
|
|
7545
|
-
return
|
|
7778
|
+
return _context78.abrupt("return", order);
|
|
7546
7779
|
case 3:
|
|
7547
|
-
|
|
7780
|
+
_context78.next = 5;
|
|
7548
7781
|
return this.buildSalesDetailProductSnapshotMap(order);
|
|
7549
7782
|
case 5:
|
|
7550
|
-
snapshotMap =
|
|
7783
|
+
snapshotMap = _context78.sent;
|
|
7551
7784
|
if (Object.keys(snapshotMap).length) {
|
|
7552
|
-
|
|
7785
|
+
_context78.next = 8;
|
|
7553
7786
|
break;
|
|
7554
7787
|
}
|
|
7555
|
-
return
|
|
7788
|
+
return _context78.abrupt("return", order);
|
|
7556
7789
|
case 8:
|
|
7557
7790
|
hasChanged = false;
|
|
7558
7791
|
enrichedProducts = products.map(function (product) {
|
|
7559
|
-
var productWithBundleSnapshots =
|
|
7560
|
-
var nextProduct =
|
|
7792
|
+
var productWithBundleSnapshots = _this24.withBundleCatalogSnapshots(product, snapshotMap);
|
|
7793
|
+
var nextProduct = _this24.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
|
|
7561
7794
|
if (nextProduct !== product) hasChanged = true;
|
|
7562
7795
|
return nextProduct;
|
|
7563
7796
|
});
|
|
7564
7797
|
if (hasChanged) {
|
|
7565
|
-
|
|
7798
|
+
_context78.next = 12;
|
|
7566
7799
|
break;
|
|
7567
7800
|
}
|
|
7568
|
-
return
|
|
7801
|
+
return _context78.abrupt("return", order);
|
|
7569
7802
|
case 12:
|
|
7570
7803
|
enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
|
|
7571
7804
|
products: enrichedProducts
|
|
7572
7805
|
});
|
|
7573
|
-
return
|
|
7806
|
+
return _context78.abrupt("return", enrichedOrder);
|
|
7574
7807
|
case 14:
|
|
7575
7808
|
case "end":
|
|
7576
|
-
return
|
|
7809
|
+
return _context78.stop();
|
|
7577
7810
|
}
|
|
7578
|
-
},
|
|
7811
|
+
}, _callee78, this);
|
|
7579
7812
|
}));
|
|
7580
|
-
function withSalesDetailProductSnapshots(
|
|
7813
|
+
function withSalesDetailProductSnapshots(_x88) {
|
|
7581
7814
|
return _withSalesDetailProductSnapshots.apply(this, arguments);
|
|
7582
7815
|
}
|
|
7583
7816
|
return withSalesDetailProductSnapshots;
|
|
@@ -7585,13 +7818,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
7585
7818
|
}, {
|
|
7586
7819
|
key: "withPendingSyncProductTitles",
|
|
7587
7820
|
value: function withPendingSyncProductTitles(order, productMap) {
|
|
7588
|
-
var
|
|
7821
|
+
var _this25 = this;
|
|
7589
7822
|
var products = Array.isArray(order.products) ? order.products : null;
|
|
7590
7823
|
if (!(products !== null && products !== void 0 && products.length)) return order;
|
|
7591
7824
|
return _objectSpread(_objectSpread({}, order), {}, {
|
|
7592
7825
|
products: products.map(function (product) {
|
|
7593
7826
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
7594
|
-
product_title:
|
|
7827
|
+
product_title: _this25.buildProductTitleSnapshot(product, productMap)
|
|
7595
7828
|
});
|
|
7596
7829
|
})
|
|
7597
7830
|
});
|
|
@@ -7602,7 +7835,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7602
7835
|
var _product$product_id4,
|
|
7603
7836
|
_product$product,
|
|
7604
7837
|
_fallbackProduct$prod,
|
|
7605
|
-
|
|
7838
|
+
_this26 = this;
|
|
7606
7839
|
var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
|
|
7607
7840
|
var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
|
|
7608
7841
|
var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
|
|
@@ -7610,7 +7843,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7610
7843
|
var currentLocale = this.getProductTitleSnapshotCurrentLocale();
|
|
7611
7844
|
var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
|
|
7612
7845
|
return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
|
|
7613
|
-
snapshot[key] =
|
|
7846
|
+
snapshot[key] = _this26.resolveProductTitleValue(ownTitle, key, currentLocale) || _this26.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
|
|
7614
7847
|
return snapshot;
|
|
7615
7848
|
}, {});
|
|
7616
7849
|
}
|
|
@@ -7635,7 +7868,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7635
7868
|
}, {
|
|
7636
7869
|
key: "resolveProductTitleValue",
|
|
7637
7870
|
value: function resolveProductTitleValue(value, key, currentLocale) {
|
|
7638
|
-
var
|
|
7871
|
+
var _ref83, _ref84, _value$key;
|
|
7639
7872
|
if (value === undefined || value === null || value === '') return null;
|
|
7640
7873
|
if (_typeof(value) !== 'object') {
|
|
7641
7874
|
var title = String(value);
|
|
@@ -7645,7 +7878,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7645
7878
|
}
|
|
7646
7879
|
var normalizedKey = key.replace('-', '_');
|
|
7647
7880
|
var dashedKey = key.replace('_', '-');
|
|
7648
|
-
var rawValue = (
|
|
7881
|
+
var rawValue = (_ref83 = (_ref84 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref84 !== void 0 ? _ref84 : value[dashedKey]) !== null && _ref83 !== void 0 ? _ref83 : key === 'auto' ? value.default : undefined;
|
|
7649
7882
|
if (rawValue === undefined || rawValue === null || rawValue === '') return null;
|
|
7650
7883
|
if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
|
|
7651
7884
|
return String(rawValue);
|
|
@@ -7708,31 +7941,31 @@ var Server = /*#__PURE__*/function () {
|
|
|
7708
7941
|
}, {
|
|
7709
7942
|
key: "enrichPaymentNamesByCode",
|
|
7710
7943
|
value: function () {
|
|
7711
|
-
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7712
|
-
var
|
|
7944
|
+
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79(order) {
|
|
7945
|
+
var _this27 = this;
|
|
7713
7946
|
var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
|
|
7714
|
-
return _regeneratorRuntime().wrap(function
|
|
7715
|
-
while (1) switch (
|
|
7947
|
+
return _regeneratorRuntime().wrap(function _callee79$(_context79) {
|
|
7948
|
+
while (1) switch (_context79.prev = _context79.next) {
|
|
7716
7949
|
case 0:
|
|
7717
7950
|
payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
|
|
7718
7951
|
hasMissingName = payments.some(function (payment) {
|
|
7719
|
-
return
|
|
7952
|
+
return _this27.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this27.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
|
|
7720
7953
|
});
|
|
7721
7954
|
if (hasMissingName) {
|
|
7722
|
-
|
|
7955
|
+
_context79.next = 4;
|
|
7723
7956
|
break;
|
|
7724
7957
|
}
|
|
7725
|
-
return
|
|
7958
|
+
return _context79.abrupt("return", order);
|
|
7726
7959
|
case 4:
|
|
7727
|
-
|
|
7728
|
-
|
|
7960
|
+
_context79.prev = 4;
|
|
7961
|
+
_context79.next = 7;
|
|
7729
7962
|
return this.getPaymentRouteModule();
|
|
7730
7963
|
case 7:
|
|
7731
|
-
paymentModule =
|
|
7732
|
-
|
|
7964
|
+
paymentModule = _context79.sent;
|
|
7965
|
+
_context79.next = 10;
|
|
7733
7966
|
return paymentModule.getPayMethodListAsync();
|
|
7734
7967
|
case 10:
|
|
7735
|
-
payMethods =
|
|
7968
|
+
payMethods = _context79.sent;
|
|
7736
7969
|
nameByCode = new Map();
|
|
7737
7970
|
_iterator12 = _createForOfIteratorHelper(payMethods || []);
|
|
7738
7971
|
try {
|
|
@@ -7749,9 +7982,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7749
7982
|
}
|
|
7750
7983
|
hasResolvedName = false;
|
|
7751
7984
|
enrichedPayments = payments.map(function (payment) {
|
|
7752
|
-
if (!
|
|
7753
|
-
if (!
|
|
7754
|
-
var name = nameByCode.get(
|
|
7985
|
+
if (!_this27.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
|
|
7986
|
+
if (!_this27.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
|
|
7987
|
+
var name = nameByCode.get(_this27.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
|
|
7755
7988
|
if (!name) return payment;
|
|
7756
7989
|
hasResolvedName = true;
|
|
7757
7990
|
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
@@ -7759,28 +7992,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
7759
7992
|
});
|
|
7760
7993
|
});
|
|
7761
7994
|
if (hasResolvedName) {
|
|
7762
|
-
|
|
7995
|
+
_context79.next = 18;
|
|
7763
7996
|
break;
|
|
7764
7997
|
}
|
|
7765
|
-
return
|
|
7998
|
+
return _context79.abrupt("return", order);
|
|
7766
7999
|
case 18:
|
|
7767
|
-
return
|
|
8000
|
+
return _context79.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
|
|
7768
8001
|
payments: enrichedPayments
|
|
7769
8002
|
}));
|
|
7770
8003
|
case 21:
|
|
7771
|
-
|
|
7772
|
-
|
|
8004
|
+
_context79.prev = 21;
|
|
8005
|
+
_context79.t0 = _context79["catch"](4);
|
|
7773
8006
|
this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
|
|
7774
|
-
error:
|
|
8007
|
+
error: _context79.t0 instanceof Error ? _context79.t0.message : String(_context79.t0)
|
|
7775
8008
|
});
|
|
7776
|
-
return
|
|
8009
|
+
return _context79.abrupt("return", order);
|
|
7777
8010
|
case 25:
|
|
7778
8011
|
case "end":
|
|
7779
|
-
return
|
|
8012
|
+
return _context79.stop();
|
|
7780
8013
|
}
|
|
7781
|
-
},
|
|
8014
|
+
}, _callee79, this, [[4, 21]]);
|
|
7782
8015
|
}));
|
|
7783
|
-
function enrichPaymentNamesByCode(
|
|
8016
|
+
function enrichPaymentNamesByCode(_x89) {
|
|
7784
8017
|
return _enrichPaymentNamesByCode.apply(this, arguments);
|
|
7785
8018
|
}
|
|
7786
8019
|
return enrichPaymentNamesByCode;
|
|
@@ -7788,25 +8021,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
7788
8021
|
}, {
|
|
7789
8022
|
key: "withLocalSmallTicketData",
|
|
7790
8023
|
value: function () {
|
|
7791
|
-
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7792
|
-
var mustApplyVisibility, _options$productMap, normalizedCollections, normalizedOrder, collapsedDuplicateCounts,
|
|
7793
|
-
return _regeneratorRuntime().wrap(function
|
|
7794
|
-
while (1) switch (
|
|
8024
|
+
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80(order, options) {
|
|
8025
|
+
var mustApplyVisibility, _options$productMap, normalizedCollections, normalizedOrder, collapsedDuplicateCounts, _ref85, _ref86, _order_id, receiptOrder, enrichedOrder, productMap, smallTicketData;
|
|
8026
|
+
return _regeneratorRuntime().wrap(function _callee80$(_context80) {
|
|
8027
|
+
while (1) switch (_context80.prev = _context80.next) {
|
|
7795
8028
|
case 0:
|
|
7796
8029
|
mustApplyVisibility = (options === null || options === void 0 ? void 0 : options.applyTemplateVisibility) === true && requiresInvoiceDataFiltering(options.invoiceTemplateSettings);
|
|
7797
8030
|
if (!(!this.shouldBuildSmallTicketData(order) && !mustApplyVisibility)) {
|
|
7798
|
-
|
|
8031
|
+
_context80.next = 3;
|
|
7799
8032
|
break;
|
|
7800
8033
|
}
|
|
7801
|
-
return
|
|
8034
|
+
return _context80.abrupt("return", order);
|
|
7802
8035
|
case 3:
|
|
7803
8036
|
if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
|
|
7804
|
-
|
|
8037
|
+
_context80.next = 5;
|
|
7805
8038
|
break;
|
|
7806
8039
|
}
|
|
7807
|
-
return
|
|
8040
|
+
return _context80.abrupt("return", order);
|
|
7808
8041
|
case 5:
|
|
7809
|
-
|
|
8042
|
+
_context80.prev = 5;
|
|
7810
8043
|
normalizedCollections = normalizeOrderCollections(order, {
|
|
7811
8044
|
ensureUid: false
|
|
7812
8045
|
});
|
|
@@ -7820,42 +8053,42 @@ var Server = /*#__PURE__*/function () {
|
|
|
7820
8053
|
return count > 0;
|
|
7821
8054
|
})) {
|
|
7822
8055
|
this.logWarning('withLocalSmallTicketData: 折叠重复订单子项', {
|
|
7823
|
-
order_identifier: (
|
|
8056
|
+
order_identifier: (_ref85 = (_ref86 = (_order_id = normalizedOrder.order_id) !== null && _order_id !== void 0 ? _order_id : normalizedOrder.external_sale_number) !== null && _ref86 !== void 0 ? _ref86 : normalizedOrder.shop_order_number) !== null && _ref85 !== void 0 ? _ref85 : null,
|
|
7824
8057
|
collapsed_duplicate_counts: collapsedDuplicateCounts
|
|
7825
8058
|
});
|
|
7826
8059
|
}
|
|
7827
8060
|
if (!(options !== null && options !== void 0 && options.refreshResourceReference)) {
|
|
7828
|
-
|
|
8061
|
+
_context80.next = 16;
|
|
7829
8062
|
break;
|
|
7830
8063
|
}
|
|
7831
|
-
|
|
8064
|
+
_context80.next = 13;
|
|
7832
8065
|
return this.withCurrentReceiptResourceReference(normalizedOrder);
|
|
7833
8066
|
case 13:
|
|
7834
|
-
|
|
7835
|
-
|
|
8067
|
+
_context80.t0 = _context80.sent;
|
|
8068
|
+
_context80.next = 17;
|
|
7836
8069
|
break;
|
|
7837
8070
|
case 16:
|
|
7838
|
-
|
|
8071
|
+
_context80.t0 = normalizedOrder;
|
|
7839
8072
|
case 17:
|
|
7840
|
-
receiptOrder =
|
|
7841
|
-
|
|
8073
|
+
receiptOrder = _context80.t0;
|
|
8074
|
+
_context80.next = 20;
|
|
7842
8075
|
return this.enrichPaymentNamesByCode(receiptOrder);
|
|
7843
8076
|
case 20:
|
|
7844
|
-
enrichedOrder =
|
|
8077
|
+
enrichedOrder = _context80.sent;
|
|
7845
8078
|
if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
|
|
7846
|
-
|
|
8079
|
+
_context80.next = 25;
|
|
7847
8080
|
break;
|
|
7848
8081
|
}
|
|
7849
|
-
|
|
7850
|
-
|
|
8082
|
+
_context80.t1 = _options$productMap;
|
|
8083
|
+
_context80.next = 28;
|
|
7851
8084
|
break;
|
|
7852
8085
|
case 25:
|
|
7853
|
-
|
|
8086
|
+
_context80.next = 27;
|
|
7854
8087
|
return this.buildSmallTicketProductMap(enrichedOrder);
|
|
7855
8088
|
case 27:
|
|
7856
|
-
|
|
8089
|
+
_context80.t1 = _context80.sent;
|
|
7857
8090
|
case 28:
|
|
7858
|
-
productMap =
|
|
8091
|
+
productMap = _context80.t1;
|
|
7859
8092
|
smallTicketData = buildSmallTicketData({
|
|
7860
8093
|
order: enrichedOrder,
|
|
7861
8094
|
shopInfo: this.getSmallTicketShopInfo(),
|
|
@@ -7864,31 +8097,31 @@ var Server = /*#__PURE__*/function () {
|
|
|
7864
8097
|
includeReceiptKeys: options === null || options === void 0 ? void 0 : options.includeReceiptKeys,
|
|
7865
8098
|
templateSettings: options !== null && options !== void 0 && options.applyTemplateVisibility ? options.invoiceTemplateSettings : undefined
|
|
7866
8099
|
});
|
|
7867
|
-
return
|
|
8100
|
+
return _context80.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
|
|
7868
8101
|
payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
|
|
7869
8102
|
small_ticket_data: smallTicketData
|
|
7870
8103
|
})
|
|
7871
8104
|
}));
|
|
7872
8105
|
case 33:
|
|
7873
|
-
|
|
7874
|
-
|
|
8106
|
+
_context80.prev = 33;
|
|
8107
|
+
_context80.t2 = _context80["catch"](5);
|
|
7875
8108
|
this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
|
|
7876
|
-
error:
|
|
8109
|
+
error: _context80.t2 instanceof Error ? _context80.t2.message : String(_context80.t2)
|
|
7877
8110
|
});
|
|
7878
8111
|
if (!mustApplyVisibility) {
|
|
7879
|
-
|
|
8112
|
+
_context80.next = 38;
|
|
7880
8113
|
break;
|
|
7881
8114
|
}
|
|
7882
|
-
throw
|
|
8115
|
+
throw _context80.t2;
|
|
7883
8116
|
case 38:
|
|
7884
|
-
return
|
|
8117
|
+
return _context80.abrupt("return", order);
|
|
7885
8118
|
case 39:
|
|
7886
8119
|
case "end":
|
|
7887
|
-
return
|
|
8120
|
+
return _context80.stop();
|
|
7888
8121
|
}
|
|
7889
|
-
},
|
|
8122
|
+
}, _callee80, this, [[5, 33]]);
|
|
7890
8123
|
}));
|
|
7891
|
-
function withLocalSmallTicketData(
|
|
8124
|
+
function withLocalSmallTicketData(_x90, _x91) {
|
|
7892
8125
|
return _withLocalSmallTicketData.apply(this, arguments);
|
|
7893
8126
|
}
|
|
7894
8127
|
return withLocalSmallTicketData;
|
|
@@ -7903,37 +8136,37 @@ var Server = /*#__PURE__*/function () {
|
|
|
7903
8136
|
}, {
|
|
7904
8137
|
key: "fetchAndPersistSalesOrderByLookup",
|
|
7905
8138
|
value: function () {
|
|
7906
|
-
var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8139
|
+
var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee81(lookup, data, title, paymentIdentityOrder, prepareExactOrderForPersist) {
|
|
7907
8140
|
var _this$order7, _this$order8, _this$app20;
|
|
7908
|
-
var backendPath, _this$order$
|
|
7909
|
-
return _regeneratorRuntime().wrap(function
|
|
7910
|
-
while (1) switch (
|
|
8141
|
+
var backendPath, _this$order$getOrderB, _this$order9, _this$order$getLocalO, _this$order10, response, _response$code3, responseStatusCode, code, message, _fresh2, localBeforeRefresh, orderToPersist, remotePayments, paidPayments, paymentIdsComplete, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode, _ref87, _backendError$code2, backendStatusCode, _code, _message2, _message3;
|
|
8142
|
+
return _regeneratorRuntime().wrap(function _callee81$(_context81) {
|
|
8143
|
+
while (1) switch (_context81.prev = _context81.next) {
|
|
7911
8144
|
case 0:
|
|
7912
8145
|
if (!(!((_this$order7 = this.order) !== null && _this$order7 !== void 0 && _this$order7.getLocalOrderByLookup) || !((_this$order8 = this.order) !== null && _this$order8 !== void 0 && _this$order8.upsertOrdersFromRemote))) {
|
|
7913
|
-
|
|
8146
|
+
_context81.next = 3;
|
|
7914
8147
|
break;
|
|
7915
8148
|
}
|
|
7916
8149
|
this.logError("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C"));
|
|
7917
|
-
return
|
|
8150
|
+
return _context81.abrupt("return", {
|
|
7918
8151
|
code: 500,
|
|
7919
8152
|
message: 'Order 模块未注册',
|
|
7920
8153
|
order: null
|
|
7921
8154
|
});
|
|
7922
8155
|
case 3:
|
|
7923
8156
|
if ((_this$app20 = this.app) !== null && _this$app20 !== void 0 && (_this$app20 = _this$app20.request) !== null && _this$app20 !== void 0 && _this$app20.get) {
|
|
7924
|
-
|
|
8157
|
+
_context81.next = 6;
|
|
7925
8158
|
break;
|
|
7926
8159
|
}
|
|
7927
8160
|
this.logError("".concat(title, ": app.request \u4E0D\u53EF\u7528"));
|
|
7928
|
-
return
|
|
8161
|
+
return _context81.abrupt("return", {
|
|
7929
8162
|
code: 500,
|
|
7930
8163
|
message: 'app.request 不可用',
|
|
7931
8164
|
order: null
|
|
7932
8165
|
});
|
|
7933
8166
|
case 6:
|
|
7934
8167
|
backendPath = this.buildOrderSalesDetailBackendPath(String(lookup), data);
|
|
7935
|
-
|
|
7936
|
-
|
|
8168
|
+
_context81.prev = 7;
|
|
8169
|
+
_context81.next = 10;
|
|
7937
8170
|
return this.app.request.get(backendPath, {
|
|
7938
8171
|
lookup_mode: 'multi'
|
|
7939
8172
|
}, {
|
|
@@ -7941,9 +8174,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7941
8174
|
customToast: function customToast() {}
|
|
7942
8175
|
});
|
|
7943
8176
|
case 10:
|
|
7944
|
-
response =
|
|
8177
|
+
response = _context81.sent;
|
|
7945
8178
|
if (!this.isCheckoutResponseRejected(response)) {
|
|
7946
|
-
|
|
8179
|
+
_context81.next = 17;
|
|
7947
8180
|
break;
|
|
7948
8181
|
}
|
|
7949
8182
|
responseStatusCode = typeof (response === null || response === void 0 ? void 0 : response.status) === 'number' ? response.status : undefined;
|
|
@@ -7955,70 +8188,80 @@ var Server = /*#__PURE__*/function () {
|
|
|
7955
8188
|
code: code,
|
|
7956
8189
|
message: message
|
|
7957
8190
|
});
|
|
7958
|
-
return
|
|
8191
|
+
return _context81.abrupt("return", {
|
|
7959
8192
|
code: code,
|
|
7960
8193
|
message: message,
|
|
7961
8194
|
order: null
|
|
7962
8195
|
});
|
|
7963
8196
|
case 17:
|
|
7964
|
-
|
|
7965
|
-
if (!(!
|
|
7966
|
-
|
|
8197
|
+
_fresh2 = this.extractOrderDataFromCheckoutResponse(response);
|
|
8198
|
+
if (!(!_fresh2 || _fresh2.order_id === undefined || _fresh2.order_id === null || String(_fresh2.order_id).trim() === '')) {
|
|
8199
|
+
_context81.next = 21;
|
|
7967
8200
|
break;
|
|
7968
8201
|
}
|
|
7969
8202
|
this.logInfo("".concat(title, ": \u540E\u7AEF\u8FD4\u56DE\u8BA2\u5355\u4E3A\u7A7A"), {
|
|
7970
8203
|
lookup: lookup,
|
|
7971
8204
|
backendPath: backendPath
|
|
7972
8205
|
});
|
|
7973
|
-
return
|
|
8206
|
+
return _context81.abrupt("return", {
|
|
7974
8207
|
code: 500,
|
|
7975
8208
|
message: '后端返回订单为空',
|
|
7976
8209
|
order: null
|
|
7977
8210
|
});
|
|
7978
8211
|
case 21:
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
8212
|
+
if (!prepareExactOrderForPersist) {
|
|
8213
|
+
_context81.next = 25;
|
|
8214
|
+
break;
|
|
8215
|
+
}
|
|
8216
|
+
_context81.t0 = (_this$order$getOrderB = (_this$order9 = this.order).getOrderByOrderId) === null || _this$order$getOrderB === void 0 ? void 0 : _this$order$getOrderB.call(_this$order9, lookup);
|
|
8217
|
+
_context81.next = 36;
|
|
8218
|
+
break;
|
|
8219
|
+
case 25:
|
|
8220
|
+
_context81.t1 = (_this$order$getLocalO = (_this$order10 = this.order).getLocalOrderFromMemoryByLookup) === null || _this$order$getLocalO === void 0 ? void 0 : _this$order$getLocalO.call(_this$order10, lookup);
|
|
8221
|
+
if (_context81.t1) {
|
|
8222
|
+
_context81.next = 35;
|
|
7982
8223
|
break;
|
|
7983
8224
|
}
|
|
7984
8225
|
if (!this.shouldForceRemoteSalesDetail(data)) {
|
|
7985
|
-
|
|
8226
|
+
_context81.next = 33;
|
|
7986
8227
|
break;
|
|
7987
8228
|
}
|
|
7988
|
-
|
|
8229
|
+
_context81.next = 30;
|
|
7989
8230
|
return this.order.getLocalOrderByLookup(lookup);
|
|
7990
|
-
case 26:
|
|
7991
|
-
_context79.t1 = _context79.sent;
|
|
7992
|
-
_context79.next = 30;
|
|
7993
|
-
break;
|
|
7994
|
-
case 29:
|
|
7995
|
-
_context79.t1 = null;
|
|
7996
8231
|
case 30:
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8232
|
+
_context81.t2 = _context81.sent;
|
|
8233
|
+
_context81.next = 34;
|
|
8234
|
+
break;
|
|
8235
|
+
case 33:
|
|
8236
|
+
_context81.t2 = null;
|
|
8237
|
+
case 34:
|
|
8238
|
+
_context81.t1 = _context81.t2;
|
|
8239
|
+
case 35:
|
|
8240
|
+
_context81.t0 = _context81.t1;
|
|
8241
|
+
case 36:
|
|
8242
|
+
localBeforeRefresh = _context81.t0;
|
|
8243
|
+
orderToPersist = _fresh2;
|
|
8001
8244
|
if (!paymentIdentityOrder) {
|
|
8002
|
-
|
|
8245
|
+
_context81.next = 49;
|
|
8003
8246
|
break;
|
|
8004
8247
|
}
|
|
8005
|
-
if (!(String(
|
|
8006
|
-
|
|
8248
|
+
if (!(String(_fresh2.order_id) !== String(paymentIdentityOrder.order_id) || _fresh2.external_sale_number && paymentIdentityOrder.external_sale_number && _fresh2.external_sale_number !== paymentIdentityOrder.external_sale_number || !Array.isArray(_fresh2.payments))) {
|
|
8249
|
+
_context81.next = 41;
|
|
8007
8250
|
break;
|
|
8008
8251
|
}
|
|
8009
8252
|
throw new Error('远端订单身份不匹配或缺少付款明细,暂不补齐付款 ID');
|
|
8010
|
-
case
|
|
8253
|
+
case 41:
|
|
8011
8254
|
if (!(!localBeforeRefresh || Number(localBeforeRefresh.need_sync || 0) === 1 || Number(localBeforeRefresh.is_draft_order || 0) === 1)) {
|
|
8012
|
-
|
|
8255
|
+
_context81.next = 43;
|
|
8013
8256
|
break;
|
|
8014
8257
|
}
|
|
8015
|
-
return
|
|
8258
|
+
return _context81.abrupt("return", {
|
|
8016
8259
|
code: 200,
|
|
8017
8260
|
message: '',
|
|
8018
8261
|
order: localBeforeRefresh || paymentIdentityOrder
|
|
8019
8262
|
});
|
|
8020
|
-
case
|
|
8021
|
-
remotePayments =
|
|
8263
|
+
case 43:
|
|
8264
|
+
remotePayments = _fresh2.payments;
|
|
8022
8265
|
paidPayments = (localBeforeRefresh.payments || []).filter(function (payment) {
|
|
8023
8266
|
return payment.status === 'paid';
|
|
8024
8267
|
});
|
|
@@ -8034,115 +8277,131 @@ var Server = /*#__PURE__*/function () {
|
|
|
8034
8277
|
return matches.length === 1 && paymentId !== undefined && paymentId !== null && String(paymentId).trim() !== '';
|
|
8035
8278
|
});
|
|
8036
8279
|
if (paymentIdsComplete) {
|
|
8037
|
-
|
|
8280
|
+
_context81.next = 48;
|
|
8038
8281
|
break;
|
|
8039
8282
|
}
|
|
8040
8283
|
throw new Error('远端付款 ID 尚未齐全或付款身份匹配不唯一,保留本地付款等待重试');
|
|
8041
|
-
case
|
|
8042
|
-
orderToPersist = _objectSpread(_objectSpread({},
|
|
8284
|
+
case 48:
|
|
8285
|
+
orderToPersist = _objectSpread(_objectSpread({}, _fresh2), {}, {
|
|
8043
8286
|
payments: mergeOrderPaymentListsByIdentity(localBeforeRefresh.payments, remotePayments, {
|
|
8044
8287
|
preserveUnmatchedExisting: true
|
|
8045
8288
|
})
|
|
8046
8289
|
});
|
|
8047
|
-
case
|
|
8290
|
+
case 49:
|
|
8291
|
+
if (prepareExactOrderForPersist) orderToPersist = prepareExactOrderForPersist(orderToPersist);
|
|
8048
8292
|
if (!requiresLocalPaymentRefresh(localBeforeRefresh)) {
|
|
8049
|
-
|
|
8293
|
+
_context81.next = 57;
|
|
8050
8294
|
break;
|
|
8051
8295
|
}
|
|
8052
|
-
if (!(String(
|
|
8053
|
-
|
|
8296
|
+
if (!(String(_fresh2.order_id) !== String(localBeforeRefresh.order_id))) {
|
|
8297
|
+
_context81.next = 53;
|
|
8054
8298
|
break;
|
|
8055
8299
|
}
|
|
8056
8300
|
throw new Error('远端订单身份不匹配,请重新刷新');
|
|
8057
|
-
case
|
|
8058
|
-
|
|
8301
|
+
case 53:
|
|
8302
|
+
_context81.next = 55;
|
|
8059
8303
|
return this.order.completeLocalPaymentRefresh(orderToPersist);
|
|
8060
|
-
case
|
|
8061
|
-
|
|
8304
|
+
case 55:
|
|
8305
|
+
_context81.next = 59;
|
|
8062
8306
|
break;
|
|
8063
|
-
case
|
|
8064
|
-
|
|
8307
|
+
case 57:
|
|
8308
|
+
_context81.next = 59;
|
|
8065
8309
|
return this.order.upsertOrdersFromRemote([orderToPersist]);
|
|
8066
|
-
case
|
|
8067
|
-
|
|
8310
|
+
case 59:
|
|
8311
|
+
if (!prepareExactOrderForPersist) {
|
|
8312
|
+
_context81.next = 65;
|
|
8313
|
+
break;
|
|
8314
|
+
}
|
|
8315
|
+
_context81.next = 62;
|
|
8316
|
+
return this.order.getLocalOrderByLookup(lookup, {
|
|
8317
|
+
exactOrderId: true
|
|
8318
|
+
});
|
|
8319
|
+
case 62:
|
|
8320
|
+
_context81.t3 = _context81.sent;
|
|
8321
|
+
_context81.next = 68;
|
|
8322
|
+
break;
|
|
8323
|
+
case 65:
|
|
8324
|
+
_context81.next = 67;
|
|
8068
8325
|
return this.order.getLocalOrderByLookup(lookup);
|
|
8069
|
-
case
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8326
|
+
case 67:
|
|
8327
|
+
_context81.t3 = _context81.sent;
|
|
8328
|
+
case 68:
|
|
8329
|
+
savedOrder = _context81.t3;
|
|
8330
|
+
if (!(!savedOrder && _fresh2.order_id !== undefined && _fresh2.order_id !== null && String(_fresh2.order_id) !== String(lookup))) {
|
|
8331
|
+
_context81.next = 73;
|
|
8073
8332
|
break;
|
|
8074
8333
|
}
|
|
8075
|
-
|
|
8076
|
-
return this.order.getLocalOrderByLookup(
|
|
8077
|
-
case
|
|
8078
|
-
savedOrder =
|
|
8079
|
-
case
|
|
8334
|
+
_context81.next = 72;
|
|
8335
|
+
return this.order.getLocalOrderByLookup(_fresh2.order_id);
|
|
8336
|
+
case 72:
|
|
8337
|
+
savedOrder = _context81.sent;
|
|
8338
|
+
case 73:
|
|
8080
8339
|
if (savedOrder) {
|
|
8081
|
-
|
|
8340
|
+
_context81.next = 76;
|
|
8082
8341
|
break;
|
|
8083
8342
|
}
|
|
8084
8343
|
this.logError("".concat(title, ": \u8BA2\u5355\u5199\u5165\u540E\u56DE\u8BFB\u5931\u8D25"), {
|
|
8085
8344
|
lookup: lookup,
|
|
8086
|
-
remote_order_id:
|
|
8345
|
+
remote_order_id: _fresh2.order_id
|
|
8087
8346
|
});
|
|
8088
|
-
return
|
|
8347
|
+
return _context81.abrupt("return", {
|
|
8089
8348
|
code: 500,
|
|
8090
8349
|
message: '订单写入后回读失败',
|
|
8091
8350
|
order: null
|
|
8092
8351
|
});
|
|
8093
|
-
case
|
|
8352
|
+
case 76:
|
|
8094
8353
|
this.logInfo("".concat(title, ": \u8FDC\u7AEF\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u672C\u5730"), {
|
|
8095
8354
|
lookup: lookup,
|
|
8096
|
-
remote_order_id:
|
|
8355
|
+
remote_order_id: _fresh2.order_id
|
|
8097
8356
|
});
|
|
8098
|
-
return
|
|
8357
|
+
return _context81.abrupt("return", {
|
|
8099
8358
|
code: 200,
|
|
8100
8359
|
message: '',
|
|
8101
8360
|
order: savedOrder
|
|
8102
8361
|
});
|
|
8103
|
-
case
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
backendError = this.extractBackendErrorResponse(
|
|
8107
|
-
errorRecord =
|
|
8362
|
+
case 80:
|
|
8363
|
+
_context81.prev = 80;
|
|
8364
|
+
_context81.t4 = _context81["catch"](7);
|
|
8365
|
+
backendError = this.extractBackendErrorResponse(_context81.t4);
|
|
8366
|
+
errorRecord = _context81.t4;
|
|
8108
8367
|
_responseStatusCode = typeof (errorRecord === null || errorRecord === void 0 || (_errorRecord$response = errorRecord.response) === null || _errorRecord$response === void 0 ? void 0 : _errorRecord$response.status) === 'number' ? errorRecord.response.status : undefined;
|
|
8109
8368
|
if (!(backendError || _responseStatusCode !== undefined)) {
|
|
8110
|
-
|
|
8369
|
+
_context81.next = 91;
|
|
8111
8370
|
break;
|
|
8112
8371
|
}
|
|
8113
8372
|
backendStatusCode = typeof (backendError === null || backendError === void 0 ? void 0 : backendError.status) === 'number' ? backendError.status : undefined;
|
|
8114
|
-
_code = this.normalizeRemoteSalesOrderErrorCode((
|
|
8115
|
-
_message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(
|
|
8373
|
+
_code = this.normalizeRemoteSalesOrderErrorCode((_ref87 = (_backendError$code2 = backendError === null || backendError === void 0 ? void 0 : backendError.code) !== null && _backendError$code2 !== void 0 ? _backendError$code2 : backendStatusCode) !== null && _ref87 !== void 0 ? _ref87 : _responseStatusCode);
|
|
8374
|
+
_message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context81.t4);
|
|
8116
8375
|
this.logInfo("".concat(title, ": \u540E\u7AEF\u8BA2\u5355\u67E5\u8BE2\u5931\u8D25"), {
|
|
8117
8376
|
lookup: lookup,
|
|
8118
8377
|
backendPath: backendPath,
|
|
8119
8378
|
code: _code,
|
|
8120
8379
|
message: _message2
|
|
8121
8380
|
});
|
|
8122
|
-
return
|
|
8381
|
+
return _context81.abrupt("return", {
|
|
8123
8382
|
code: _code,
|
|
8124
8383
|
message: _message2,
|
|
8125
8384
|
order: null
|
|
8126
8385
|
});
|
|
8127
|
-
case
|
|
8128
|
-
_message3 = this.getUnknownErrorMessage(
|
|
8386
|
+
case 91:
|
|
8387
|
+
_message3 = this.getUnknownErrorMessage(_context81.t4);
|
|
8129
8388
|
this.logInfo("".concat(title, ": \u8BF7\u6C42\u5931\u8D25"), {
|
|
8130
8389
|
lookup: lookup,
|
|
8131
8390
|
backendPath: backendPath,
|
|
8132
8391
|
error: _message3
|
|
8133
8392
|
});
|
|
8134
|
-
return
|
|
8393
|
+
return _context81.abrupt("return", {
|
|
8135
8394
|
code: 500,
|
|
8136
8395
|
message: _message3,
|
|
8137
8396
|
order: null
|
|
8138
8397
|
});
|
|
8139
|
-
case
|
|
8398
|
+
case 94:
|
|
8140
8399
|
case "end":
|
|
8141
|
-
return
|
|
8400
|
+
return _context81.stop();
|
|
8142
8401
|
}
|
|
8143
|
-
},
|
|
8402
|
+
}, _callee81, this, [[7, 80]]);
|
|
8144
8403
|
}));
|
|
8145
|
-
function fetchAndPersistSalesOrderByLookup(
|
|
8404
|
+
function fetchAndPersistSalesOrderByLookup(_x92, _x93, _x94, _x95, _x96) {
|
|
8146
8405
|
return _fetchAndPersistSalesOrderByLookup.apply(this, arguments);
|
|
8147
8406
|
}
|
|
8148
8407
|
return fetchAndPersistSalesOrderByLookup;
|
|
@@ -8204,22 +8463,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
8204
8463
|
}, {
|
|
8205
8464
|
key: "handleUpdateLocalOrdersBatch",
|
|
8206
8465
|
value: (function () {
|
|
8207
|
-
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8466
|
+
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82(orderIds) {
|
|
8208
8467
|
var _this$app21;
|
|
8209
|
-
var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id,
|
|
8210
|
-
return _regeneratorRuntime().wrap(function
|
|
8211
|
-
while (1) switch (
|
|
8468
|
+
var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, _fresh3, _message4, overwritten, inserted;
|
|
8469
|
+
return _regeneratorRuntime().wrap(function _callee82$(_context82) {
|
|
8470
|
+
while (1) switch (_context82.prev = _context82.next) {
|
|
8212
8471
|
case 0:
|
|
8213
8472
|
this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
|
|
8214
8473
|
count: orderIds.length,
|
|
8215
8474
|
orderIds: orderIds
|
|
8216
8475
|
});
|
|
8217
8476
|
if (this.order) {
|
|
8218
|
-
|
|
8477
|
+
_context82.next = 4;
|
|
8219
8478
|
break;
|
|
8220
8479
|
}
|
|
8221
8480
|
this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
|
|
8222
|
-
return
|
|
8481
|
+
return _context82.abrupt("return", {
|
|
8223
8482
|
code: 500,
|
|
8224
8483
|
status: false,
|
|
8225
8484
|
message: 'Order 模块未注册',
|
|
@@ -8227,11 +8486,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
8227
8486
|
});
|
|
8228
8487
|
case 4:
|
|
8229
8488
|
if ((_this$app21 = this.app) !== null && _this$app21 !== void 0 && _this$app21.request) {
|
|
8230
|
-
|
|
8489
|
+
_context82.next = 7;
|
|
8231
8490
|
break;
|
|
8232
8491
|
}
|
|
8233
8492
|
this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
|
|
8234
|
-
return
|
|
8493
|
+
return _context82.abrupt("return", {
|
|
8235
8494
|
code: 500,
|
|
8236
8495
|
status: false,
|
|
8237
8496
|
message: 'app.request 不可用',
|
|
@@ -8254,21 +8513,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
8254
8513
|
_iterator13.f();
|
|
8255
8514
|
}
|
|
8256
8515
|
fetched = [];
|
|
8257
|
-
|
|
8258
|
-
|
|
8516
|
+
_context82.prev = 11;
|
|
8517
|
+
_context82.next = 14;
|
|
8259
8518
|
return this.order.fetchOrdersByHttp(orderIds);
|
|
8260
8519
|
case 14:
|
|
8261
|
-
fetched =
|
|
8262
|
-
|
|
8520
|
+
fetched = _context82.sent;
|
|
8521
|
+
_context82.next = 22;
|
|
8263
8522
|
break;
|
|
8264
8523
|
case 17:
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
message =
|
|
8524
|
+
_context82.prev = 17;
|
|
8525
|
+
_context82.t0 = _context82["catch"](11);
|
|
8526
|
+
message = _context82.t0 instanceof Error ? _context82.t0.message : String(_context82.t0);
|
|
8268
8527
|
this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
|
|
8269
8528
|
message: message
|
|
8270
8529
|
});
|
|
8271
|
-
return
|
|
8530
|
+
return _context82.abrupt("return", {
|
|
8272
8531
|
code: 500,
|
|
8273
8532
|
status: false,
|
|
8274
8533
|
message: message,
|
|
@@ -8278,36 +8537,36 @@ var Server = /*#__PURE__*/function () {
|
|
|
8278
8537
|
// 按返回结果中的 order_id 建索引,未命中即视为单笔失败
|
|
8279
8538
|
fetchedMap = new Map();
|
|
8280
8539
|
_iterator14 = _createForOfIteratorHelper(fetched);
|
|
8281
|
-
|
|
8540
|
+
_context82.prev = 24;
|
|
8282
8541
|
_iterator14.s();
|
|
8283
8542
|
case 26:
|
|
8284
8543
|
if ((_step14 = _iterator14.n()).done) {
|
|
8285
|
-
|
|
8544
|
+
_context82.next = 34;
|
|
8286
8545
|
break;
|
|
8287
8546
|
}
|
|
8288
8547
|
order = _step14.value;
|
|
8289
8548
|
oid = order === null || order === void 0 ? void 0 : order.order_id;
|
|
8290
8549
|
if (!(oid === undefined || oid === null)) {
|
|
8291
|
-
|
|
8550
|
+
_context82.next = 31;
|
|
8292
8551
|
break;
|
|
8293
8552
|
}
|
|
8294
|
-
return
|
|
8553
|
+
return _context82.abrupt("continue", 32);
|
|
8295
8554
|
case 31:
|
|
8296
8555
|
fetchedMap.set(String(oid), order);
|
|
8297
8556
|
case 32:
|
|
8298
|
-
|
|
8557
|
+
_context82.next = 26;
|
|
8299
8558
|
break;
|
|
8300
8559
|
case 34:
|
|
8301
|
-
|
|
8560
|
+
_context82.next = 39;
|
|
8302
8561
|
break;
|
|
8303
8562
|
case 36:
|
|
8304
|
-
|
|
8305
|
-
|
|
8306
|
-
_iterator14.e(
|
|
8563
|
+
_context82.prev = 36;
|
|
8564
|
+
_context82.t1 = _context82["catch"](24);
|
|
8565
|
+
_iterator14.e(_context82.t1);
|
|
8307
8566
|
case 39:
|
|
8308
|
-
|
|
8567
|
+
_context82.prev = 39;
|
|
8309
8568
|
_iterator14.f();
|
|
8310
|
-
return
|
|
8569
|
+
return _context82.finish(39);
|
|
8311
8570
|
case 42:
|
|
8312
8571
|
freshOrders = [];
|
|
8313
8572
|
succeedIds = [];
|
|
@@ -8316,9 +8575,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
8316
8575
|
try {
|
|
8317
8576
|
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
8318
8577
|
_id = _step15.value;
|
|
8319
|
-
|
|
8320
|
-
if (
|
|
8321
|
-
freshOrders.push(
|
|
8578
|
+
_fresh3 = fetchedMap.get(_id);
|
|
8579
|
+
if (_fresh3) {
|
|
8580
|
+
freshOrders.push(_fresh3);
|
|
8322
8581
|
succeedIds.push(_id);
|
|
8323
8582
|
} else {
|
|
8324
8583
|
failed.push({
|
|
@@ -8333,23 +8592,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
8333
8592
|
_iterator15.f();
|
|
8334
8593
|
}
|
|
8335
8594
|
if (!(freshOrders.length > 0)) {
|
|
8336
|
-
|
|
8595
|
+
_context82.next = 58;
|
|
8337
8596
|
break;
|
|
8338
8597
|
}
|
|
8339
|
-
|
|
8340
|
-
|
|
8598
|
+
_context82.prev = 48;
|
|
8599
|
+
_context82.next = 51;
|
|
8341
8600
|
return this.order.upsertOrdersFromRemote(freshOrders);
|
|
8342
8601
|
case 51:
|
|
8343
|
-
|
|
8602
|
+
_context82.next = 58;
|
|
8344
8603
|
break;
|
|
8345
8604
|
case 53:
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
_message4 =
|
|
8605
|
+
_context82.prev = 53;
|
|
8606
|
+
_context82.t2 = _context82["catch"](48);
|
|
8607
|
+
_message4 = _context82.t2 instanceof Error ? _context82.t2.message : String(_context82.t2);
|
|
8349
8608
|
this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
|
|
8350
8609
|
message: _message4
|
|
8351
8610
|
});
|
|
8352
|
-
return
|
|
8611
|
+
return _context82.abrupt("return", {
|
|
8353
8612
|
code: 500,
|
|
8354
8613
|
status: false,
|
|
8355
8614
|
message: _message4,
|
|
@@ -8368,7 +8627,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8368
8627
|
insertedCount: inserted.length,
|
|
8369
8628
|
failedCount: failed.length
|
|
8370
8629
|
});
|
|
8371
|
-
return
|
|
8630
|
+
return _context82.abrupt("return", {
|
|
8372
8631
|
code: 200,
|
|
8373
8632
|
status: true,
|
|
8374
8633
|
message: '',
|
|
@@ -8380,11 +8639,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
8380
8639
|
});
|
|
8381
8640
|
case 62:
|
|
8382
8641
|
case "end":
|
|
8383
|
-
return
|
|
8642
|
+
return _context82.stop();
|
|
8384
8643
|
}
|
|
8385
|
-
},
|
|
8644
|
+
}, _callee82, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
|
|
8386
8645
|
}));
|
|
8387
|
-
function handleUpdateLocalOrdersBatch(
|
|
8646
|
+
function handleUpdateLocalOrdersBatch(_x97) {
|
|
8388
8647
|
return _handleUpdateLocalOrdersBatch.apply(this, arguments);
|
|
8389
8648
|
}
|
|
8390
8649
|
return handleUpdateLocalOrdersBatch;
|
|
@@ -8631,10 +8890,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
8631
8890
|
value: function extractBackendErrorResponse(error) {
|
|
8632
8891
|
var _error$response3,
|
|
8633
8892
|
_error$response4,
|
|
8634
|
-
|
|
8893
|
+
_this28 = this;
|
|
8635
8894
|
var candidates = [error === null || error === void 0 || (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.body, error === null || error === void 0 ? void 0 : error.body];
|
|
8636
8895
|
return candidates.find(function (candidate) {
|
|
8637
|
-
return
|
|
8896
|
+
return _this28.isExplicitBackendErrorResponse(candidate);
|
|
8638
8897
|
}) || null;
|
|
8639
8898
|
}
|
|
8640
8899
|
}, {
|
|
@@ -8753,16 +9012,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
8753
9012
|
}, {
|
|
8754
9013
|
key: "recomputeAndNotifyFloorPlanQuery",
|
|
8755
9014
|
value: (function () {
|
|
8756
|
-
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9015
|
+
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83() {
|
|
8757
9016
|
var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
|
|
8758
|
-
return _regeneratorRuntime().wrap(function
|
|
8759
|
-
while (1) switch (
|
|
9017
|
+
return _regeneratorRuntime().wrap(function _callee83$(_context83) {
|
|
9018
|
+
while (1) switch (_context83.prev = _context83.next) {
|
|
8760
9019
|
case 0:
|
|
8761
9020
|
if (!(this.floorPlanQuerySubscribers.size === 0)) {
|
|
8762
|
-
|
|
9021
|
+
_context83.next = 2;
|
|
8763
9022
|
break;
|
|
8764
9023
|
}
|
|
8765
|
-
return
|
|
9024
|
+
return _context83.abrupt("return");
|
|
8766
9025
|
case 2:
|
|
8767
9026
|
this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
|
|
8768
9027
|
subscriberCount: this.floorPlanQuerySubscribers.size
|
|
@@ -8792,9 +9051,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
8792
9051
|
}
|
|
8793
9052
|
case 5:
|
|
8794
9053
|
case "end":
|
|
8795
|
-
return
|
|
9054
|
+
return _context83.stop();
|
|
8796
9055
|
}
|
|
8797
|
-
},
|
|
9056
|
+
}, _callee83, this);
|
|
8798
9057
|
}));
|
|
8799
9058
|
function recomputeAndNotifyFloorPlanQuery() {
|
|
8800
9059
|
return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
|
|
@@ -8824,20 +9083,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
8824
9083
|
* filter 逻辑暂为 mock,仅记录参数
|
|
8825
9084
|
*/
|
|
8826
9085
|
function () {
|
|
8827
|
-
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9086
|
+
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee84(data) {
|
|
8828
9087
|
var rawList, result;
|
|
8829
|
-
return _regeneratorRuntime().wrap(function
|
|
8830
|
-
while (1) switch (
|
|
9088
|
+
return _regeneratorRuntime().wrap(function _callee84$(_context84) {
|
|
9089
|
+
while (1) switch (_context84.prev = _context84.next) {
|
|
8831
9090
|
case 0:
|
|
8832
9091
|
this.logInfo('computeOrderQueryResult: 开始过滤', {
|
|
8833
9092
|
data: data
|
|
8834
9093
|
});
|
|
8835
9094
|
if (this.order) {
|
|
8836
|
-
|
|
9095
|
+
_context84.next = 4;
|
|
8837
9096
|
break;
|
|
8838
9097
|
}
|
|
8839
9098
|
this.logError('computeOrderQueryResult: Order 模块未注册');
|
|
8840
|
-
return
|
|
9099
|
+
return _context84.abrupt("return", {
|
|
8841
9100
|
code: 500,
|
|
8842
9101
|
message: 'Order 模块未注册',
|
|
8843
9102
|
data: {
|
|
@@ -8869,7 +9128,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8869
9128
|
skip: result.skip,
|
|
8870
9129
|
rejected: result.rejected
|
|
8871
9130
|
});
|
|
8872
|
-
return
|
|
9131
|
+
return _context84.abrupt("return", {
|
|
8873
9132
|
code: 200,
|
|
8874
9133
|
data: result,
|
|
8875
9134
|
message: '',
|
|
@@ -8877,11 +9136,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
8877
9136
|
});
|
|
8878
9137
|
case 10:
|
|
8879
9138
|
case "end":
|
|
8880
|
-
return
|
|
9139
|
+
return _context84.stop();
|
|
8881
9140
|
}
|
|
8882
|
-
},
|
|
9141
|
+
}, _callee84, this);
|
|
8883
9142
|
}));
|
|
8884
|
-
function computeOrderQueryResult(
|
|
9143
|
+
function computeOrderQueryResult(_x98) {
|
|
8885
9144
|
return _computeOrderQueryResult.apply(this, arguments);
|
|
8886
9145
|
}
|
|
8887
9146
|
return computeOrderQueryResult;
|
|
@@ -8894,17 +9153,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
8894
9153
|
}, {
|
|
8895
9154
|
key: "computeBookingQueryResult",
|
|
8896
9155
|
value: (function () {
|
|
8897
|
-
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9156
|
+
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee85(data) {
|
|
8898
9157
|
var rawOrders, result;
|
|
8899
|
-
return _regeneratorRuntime().wrap(function
|
|
8900
|
-
while (1) switch (
|
|
9158
|
+
return _regeneratorRuntime().wrap(function _callee85$(_context85) {
|
|
9159
|
+
while (1) switch (_context85.prev = _context85.next) {
|
|
8901
9160
|
case 0:
|
|
8902
9161
|
if (this.order) {
|
|
8903
|
-
|
|
9162
|
+
_context85.next = 3;
|
|
8904
9163
|
break;
|
|
8905
9164
|
}
|
|
8906
9165
|
this.logError('computeBookingQueryResult: Order 模块未注册');
|
|
8907
|
-
return
|
|
9166
|
+
return _context85.abrupt("return", {
|
|
8908
9167
|
code: 500,
|
|
8909
9168
|
message: 'Order 模块未注册',
|
|
8910
9169
|
data: {
|
|
@@ -8923,7 +9182,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8923
9182
|
size: result.size,
|
|
8924
9183
|
skip: result.skip
|
|
8925
9184
|
});
|
|
8926
|
-
return
|
|
9185
|
+
return _context85.abrupt("return", {
|
|
8927
9186
|
code: 200,
|
|
8928
9187
|
data: result,
|
|
8929
9188
|
message: '',
|
|
@@ -8931,11 +9190,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
8931
9190
|
});
|
|
8932
9191
|
case 8:
|
|
8933
9192
|
case "end":
|
|
8934
|
-
return
|
|
9193
|
+
return _context85.stop();
|
|
8935
9194
|
}
|
|
8936
|
-
},
|
|
9195
|
+
}, _callee85, this);
|
|
8937
9196
|
}));
|
|
8938
|
-
function computeBookingQueryResult(
|
|
9197
|
+
function computeBookingQueryResult(_x99) {
|
|
8939
9198
|
return _computeBookingQueryResult.apply(this, arguments);
|
|
8940
9199
|
}
|
|
8941
9200
|
return computeBookingQueryResult;
|
|
@@ -8994,12 +9253,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
8994
9253
|
}, {
|
|
8995
9254
|
key: "computeProductQueryResult",
|
|
8996
9255
|
value: (function () {
|
|
8997
|
-
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9256
|
+
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee86(context, options) {
|
|
8998
9257
|
var _menu_list_ids$length3,
|
|
8999
|
-
|
|
9258
|
+
_this29 = this;
|
|
9000
9259
|
var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, application_code, strategy_context, isVisibleProduct, queryIds, startupPreloadTask, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, getActiveMenus, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
|
|
9001
|
-
return _regeneratorRuntime().wrap(function
|
|
9002
|
-
while (1) switch (
|
|
9260
|
+
return _regeneratorRuntime().wrap(function _callee86$(_context86) {
|
|
9261
|
+
while (1) switch (_context86.prev = _context86.next) {
|
|
9003
9262
|
case 0:
|
|
9004
9263
|
tTotal = performance.now();
|
|
9005
9264
|
menu_list_ids = context.menu_list_ids, ids = context.ids, schedule_date = context.schedule_date, schedule_datetime = context.schedule_datetime, customer_id = context.customer_id, extension_type = context.extension_type, product_id = context.product_id, application_code = context.application_code, strategy_context = context.strategy_context; // 仅 Kiosk 查询额外按商品销售渠道过滤。
|
|
@@ -9028,10 +9287,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
9028
9287
|
// SQLite/IndexDB,造成 preload 读到空数据并重复请求。正常运行期该字段为 null,不增加等待。
|
|
9029
9288
|
startupPreloadTask = this.startupModulePreloadInFlight;
|
|
9030
9289
|
if (!startupPreloadTask) {
|
|
9031
|
-
|
|
9290
|
+
_context86.next = 9;
|
|
9032
9291
|
break;
|
|
9033
9292
|
}
|
|
9034
|
-
|
|
9293
|
+
_context86.next = 9;
|
|
9035
9294
|
return startupPreloadTask;
|
|
9036
9295
|
case 9:
|
|
9037
9296
|
// Menu/Schedule preload 会替换 store 中的数组;必须在等待完成后再读取,
|
|
@@ -9043,28 +9302,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
9043
9302
|
strategy_context: strategy_context
|
|
9044
9303
|
});
|
|
9045
9304
|
if (this.products) {
|
|
9046
|
-
|
|
9305
|
+
_context86.next = 13;
|
|
9047
9306
|
break;
|
|
9048
9307
|
}
|
|
9049
9308
|
this.logError('computeProductQueryResult: Products 模块未注册');
|
|
9050
|
-
return
|
|
9309
|
+
return _context86.abrupt("return", {
|
|
9051
9310
|
message: 'Products 模块未注册',
|
|
9052
9311
|
data: this.buildProductQueryResultPayload([], 0)
|
|
9053
9312
|
});
|
|
9054
9313
|
case 13:
|
|
9055
9314
|
if (!(queryIds.length > 0)) {
|
|
9056
|
-
|
|
9315
|
+
_context86.next = 25;
|
|
9057
9316
|
break;
|
|
9058
9317
|
}
|
|
9059
9318
|
uniqueIds = Array.from(new Set(queryIds));
|
|
9060
9319
|
_tPrice = performance.now();
|
|
9061
|
-
|
|
9320
|
+
_context86.next = 18;
|
|
9062
9321
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
9063
9322
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
9064
9323
|
productIds: uniqueIds
|
|
9065
9324
|
});
|
|
9066
9325
|
case 18:
|
|
9067
|
-
productsWithPrice =
|
|
9326
|
+
productsWithPrice = _context86.sent;
|
|
9068
9327
|
perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
|
|
9069
9328
|
count: productsWithPrice.length,
|
|
9070
9329
|
ids: uniqueIds
|
|
@@ -9082,7 +9341,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
9082
9341
|
ids: uniqueIds,
|
|
9083
9342
|
count: extensionFilteredProducts.length
|
|
9084
9343
|
});
|
|
9085
|
-
return
|
|
9344
|
+
return _context86.abrupt("return", {
|
|
9086
9345
|
code: 200,
|
|
9087
9346
|
data: this.buildProductQueryResultPayload(extensionFilteredProducts),
|
|
9088
9347
|
message: '',
|
|
@@ -9090,17 +9349,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
9090
9349
|
});
|
|
9091
9350
|
case 25:
|
|
9092
9351
|
if (!(product_id != null && Number.isFinite(Number(product_id)))) {
|
|
9093
|
-
|
|
9352
|
+
_context86.next = 37;
|
|
9094
9353
|
break;
|
|
9095
9354
|
}
|
|
9096
9355
|
pid = Number(product_id);
|
|
9097
9356
|
_tPrice2 = performance.now();
|
|
9098
|
-
|
|
9357
|
+
_context86.next = 30;
|
|
9099
9358
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
9100
9359
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
9101
9360
|
});
|
|
9102
9361
|
case 30:
|
|
9103
|
-
allProductsWithPrice =
|
|
9362
|
+
allProductsWithPrice = _context86.sent;
|
|
9104
9363
|
perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
|
|
9105
9364
|
count: allProductsWithPrice.length,
|
|
9106
9365
|
productId: pid
|
|
@@ -9118,7 +9377,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
9118
9377
|
productId: pid,
|
|
9119
9378
|
found: !!item
|
|
9120
9379
|
});
|
|
9121
|
-
return
|
|
9380
|
+
return _context86.abrupt("return", {
|
|
9122
9381
|
code: 200,
|
|
9123
9382
|
data: item,
|
|
9124
9383
|
message: item ? '' : '商品不存在或未发布',
|
|
@@ -9126,16 +9385,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
9126
9385
|
});
|
|
9127
9386
|
case 37:
|
|
9128
9387
|
if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
|
|
9129
|
-
|
|
9388
|
+
_context86.next = 57;
|
|
9130
9389
|
break;
|
|
9131
9390
|
}
|
|
9132
9391
|
_tPrice3 = performance.now();
|
|
9133
|
-
|
|
9392
|
+
_context86.next = 41;
|
|
9134
9393
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
9135
9394
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
9136
9395
|
});
|
|
9137
9396
|
case 41:
|
|
9138
|
-
_filteredProducts2 =
|
|
9397
|
+
_filteredProducts2 = _context86.sent;
|
|
9139
9398
|
perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
|
|
9140
9399
|
count: _filteredProducts2.length,
|
|
9141
9400
|
extension_type: extension_type
|
|
@@ -9172,7 +9431,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
9172
9431
|
filteredCount: _filteredProducts2.length,
|
|
9173
9432
|
extension_type: extension_type
|
|
9174
9433
|
});
|
|
9175
|
-
return
|
|
9434
|
+
return _context86.abrupt("return", {
|
|
9176
9435
|
code: 200,
|
|
9177
9436
|
data: this.buildProductQueryResultPayload(_filteredProducts2),
|
|
9178
9437
|
message: '',
|
|
@@ -9180,50 +9439,50 @@ var Server = /*#__PURE__*/function () {
|
|
|
9180
9439
|
});
|
|
9181
9440
|
case 57:
|
|
9182
9441
|
if (this.menu) {
|
|
9183
|
-
|
|
9442
|
+
_context86.next = 60;
|
|
9184
9443
|
break;
|
|
9185
9444
|
}
|
|
9186
9445
|
this.logError('computeProductQueryResult: Menu 模块未注册');
|
|
9187
|
-
return
|
|
9446
|
+
return _context86.abrupt("return", {
|
|
9188
9447
|
message: 'Menu 模块未注册',
|
|
9189
9448
|
data: this.buildProductQueryResultPayload([], 0)
|
|
9190
9449
|
});
|
|
9191
9450
|
case 60:
|
|
9192
9451
|
if (this.schedule) {
|
|
9193
|
-
|
|
9452
|
+
_context86.next = 63;
|
|
9194
9453
|
break;
|
|
9195
9454
|
}
|
|
9196
9455
|
this.logError('computeProductQueryResult: Schedule 模块未注册');
|
|
9197
|
-
return
|
|
9456
|
+
return _context86.abrupt("return", {
|
|
9198
9457
|
message: 'Schedule 模块未注册',
|
|
9199
9458
|
data: this.buildProductQueryResultPayload([], 0)
|
|
9200
9459
|
});
|
|
9201
9460
|
case 63:
|
|
9202
9461
|
activeMenuList = [];
|
|
9203
9462
|
if (!(menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0)) {
|
|
9204
|
-
|
|
9463
|
+
_context86.next = 76;
|
|
9205
9464
|
break;
|
|
9206
9465
|
}
|
|
9207
9466
|
tMenu = performance.now();
|
|
9208
9467
|
getActiveMenus = function getActiveMenus() {
|
|
9209
|
-
return
|
|
9210
|
-
var
|
|
9211
|
-
return ((
|
|
9468
|
+
return _this29.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
|
|
9469
|
+
var _this29$schedule;
|
|
9470
|
+
return ((_this29$schedule = _this29.schedule) === null || _this29$schedule === void 0 ? void 0 : _this29$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
|
|
9212
9471
|
});
|
|
9213
9472
|
};
|
|
9214
9473
|
activeMenuList = getActiveMenus();
|
|
9215
|
-
|
|
9216
|
-
if (!
|
|
9217
|
-
|
|
9474
|
+
_context86.t0 = !activeMenuList.length;
|
|
9475
|
+
if (!_context86.t0) {
|
|
9476
|
+
_context86.next = 73;
|
|
9218
9477
|
break;
|
|
9219
9478
|
}
|
|
9220
|
-
|
|
9479
|
+
_context86.next = 72;
|
|
9221
9480
|
return this.refreshMenuScheduleCacheAfterEmptyResult();
|
|
9222
9481
|
case 72:
|
|
9223
|
-
|
|
9482
|
+
_context86.t0 = _context86.sent;
|
|
9224
9483
|
case 73:
|
|
9225
|
-
if (!
|
|
9226
|
-
|
|
9484
|
+
if (!_context86.t0) {
|
|
9485
|
+
_context86.next = 75;
|
|
9227
9486
|
break;
|
|
9228
9487
|
}
|
|
9229
9488
|
activeMenuList = getActiveMenus();
|
|
@@ -9243,22 +9502,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
9243
9502
|
});
|
|
9244
9503
|
tPrice = performance.now();
|
|
9245
9504
|
if (!(scopedProductIds.length > 0)) {
|
|
9246
|
-
|
|
9505
|
+
_context86.next = 87;
|
|
9247
9506
|
break;
|
|
9248
9507
|
}
|
|
9249
|
-
|
|
9508
|
+
_context86.next = 84;
|
|
9250
9509
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
9251
9510
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
9252
9511
|
productIds: productScope.isAllProducts ? undefined : scopedProductIds
|
|
9253
9512
|
});
|
|
9254
9513
|
case 84:
|
|
9255
|
-
|
|
9256
|
-
|
|
9514
|
+
_context86.t1 = _context86.sent;
|
|
9515
|
+
_context86.next = 88;
|
|
9257
9516
|
break;
|
|
9258
9517
|
case 87:
|
|
9259
|
-
|
|
9518
|
+
_context86.t1 = [];
|
|
9260
9519
|
case 88:
|
|
9261
|
-
filteredProducts =
|
|
9520
|
+
filteredProducts = _context86.t1;
|
|
9262
9521
|
perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
|
|
9263
9522
|
count: filteredProducts.length,
|
|
9264
9523
|
scopedProductCount: scopedProductIds.length
|
|
@@ -9297,7 +9556,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
9297
9556
|
filteredCount: filteredProducts.length,
|
|
9298
9557
|
activeMenuCount: activeMenuList.length
|
|
9299
9558
|
});
|
|
9300
|
-
return
|
|
9559
|
+
return _context86.abrupt("return", {
|
|
9301
9560
|
code: 200,
|
|
9302
9561
|
data: this.buildProductQueryResultPayload(filteredProducts),
|
|
9303
9562
|
message: '',
|
|
@@ -9305,11 +9564,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
9305
9564
|
});
|
|
9306
9565
|
case 104:
|
|
9307
9566
|
case "end":
|
|
9308
|
-
return
|
|
9567
|
+
return _context86.stop();
|
|
9309
9568
|
}
|
|
9310
|
-
},
|
|
9569
|
+
}, _callee86, this);
|
|
9311
9570
|
}));
|
|
9312
|
-
function computeProductQueryResult(
|
|
9571
|
+
function computeProductQueryResult(_x100, _x101) {
|
|
9313
9572
|
return _computeProductQueryResult.apply(this, arguments);
|
|
9314
9573
|
}
|
|
9315
9574
|
return computeProductQueryResult;
|
|
@@ -9347,74 +9606,74 @@ var Server = /*#__PURE__*/function () {
|
|
|
9347
9606
|
}, {
|
|
9348
9607
|
key: "recomputeAndNotifyProductQuery",
|
|
9349
9608
|
value: (function () {
|
|
9350
|
-
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9609
|
+
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee87(options) {
|
|
9351
9610
|
var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
|
|
9352
|
-
return _regeneratorRuntime().wrap(function
|
|
9353
|
-
while (1) switch (
|
|
9611
|
+
return _regeneratorRuntime().wrap(function _callee87$(_context87) {
|
|
9612
|
+
while (1) switch (_context87.prev = _context87.next) {
|
|
9354
9613
|
case 0:
|
|
9355
9614
|
if (!(this.productQuerySubscribers.size === 0)) {
|
|
9356
|
-
|
|
9615
|
+
_context87.next = 2;
|
|
9357
9616
|
break;
|
|
9358
9617
|
}
|
|
9359
|
-
return
|
|
9618
|
+
return _context87.abrupt("return");
|
|
9360
9619
|
case 2:
|
|
9361
9620
|
this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
|
|
9362
9621
|
subscriberCount: this.productQuerySubscribers.size,
|
|
9363
9622
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
9364
9623
|
});
|
|
9365
9624
|
_iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
|
|
9366
|
-
|
|
9625
|
+
_context87.prev = 4;
|
|
9367
9626
|
_iterator18.s();
|
|
9368
9627
|
case 6:
|
|
9369
9628
|
if ((_step18 = _iterator18.n()).done) {
|
|
9370
|
-
|
|
9629
|
+
_context87.next = 23;
|
|
9371
9630
|
break;
|
|
9372
9631
|
}
|
|
9373
9632
|
_step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
|
|
9374
|
-
|
|
9375
|
-
|
|
9633
|
+
_context87.prev = 8;
|
|
9634
|
+
_context87.next = 11;
|
|
9376
9635
|
return this.computeProductQueryResult(subscriber.context, {
|
|
9377
9636
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
9378
9637
|
});
|
|
9379
9638
|
case 11:
|
|
9380
|
-
result =
|
|
9381
|
-
|
|
9639
|
+
result = _context87.sent;
|
|
9640
|
+
_context87.next = 14;
|
|
9382
9641
|
return subscriber.callback(result);
|
|
9383
9642
|
case 14:
|
|
9384
9643
|
this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
|
|
9385
9644
|
subscriberId: subscriberId
|
|
9386
9645
|
});
|
|
9387
|
-
|
|
9646
|
+
_context87.next = 21;
|
|
9388
9647
|
break;
|
|
9389
9648
|
case 17:
|
|
9390
|
-
|
|
9391
|
-
|
|
9392
|
-
errorMessage =
|
|
9649
|
+
_context87.prev = 17;
|
|
9650
|
+
_context87.t0 = _context87["catch"](8);
|
|
9651
|
+
errorMessage = _context87.t0 instanceof Error ? _context87.t0.message : String(_context87.t0);
|
|
9393
9652
|
this.logError('recomputeAndNotifyProductQuery: 推送失败', {
|
|
9394
9653
|
subscriberId: subscriberId,
|
|
9395
9654
|
error: errorMessage
|
|
9396
9655
|
});
|
|
9397
9656
|
case 21:
|
|
9398
|
-
|
|
9657
|
+
_context87.next = 6;
|
|
9399
9658
|
break;
|
|
9400
9659
|
case 23:
|
|
9401
|
-
|
|
9660
|
+
_context87.next = 28;
|
|
9402
9661
|
break;
|
|
9403
9662
|
case 25:
|
|
9404
|
-
|
|
9405
|
-
|
|
9406
|
-
_iterator18.e(
|
|
9663
|
+
_context87.prev = 25;
|
|
9664
|
+
_context87.t1 = _context87["catch"](4);
|
|
9665
|
+
_iterator18.e(_context87.t1);
|
|
9407
9666
|
case 28:
|
|
9408
|
-
|
|
9667
|
+
_context87.prev = 28;
|
|
9409
9668
|
_iterator18.f();
|
|
9410
|
-
return
|
|
9669
|
+
return _context87.finish(28);
|
|
9411
9670
|
case 31:
|
|
9412
9671
|
case "end":
|
|
9413
|
-
return
|
|
9672
|
+
return _context87.stop();
|
|
9414
9673
|
}
|
|
9415
|
-
},
|
|
9674
|
+
}, _callee87, this, [[4, 25, 28, 31], [8, 17]]);
|
|
9416
9675
|
}));
|
|
9417
|
-
function recomputeAndNotifyProductQuery(
|
|
9676
|
+
function recomputeAndNotifyProductQuery(_x102) {
|
|
9418
9677
|
return _recomputeAndNotifyProductQuery.apply(this, arguments);
|
|
9419
9678
|
}
|
|
9420
9679
|
return recomputeAndNotifyProductQuery;
|
|
@@ -9426,16 +9685,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
9426
9685
|
}, {
|
|
9427
9686
|
key: "recomputeAndNotifyOrderQuery",
|
|
9428
9687
|
value: (function () {
|
|
9429
|
-
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9688
|
+
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee88() {
|
|
9430
9689
|
var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
|
|
9431
|
-
return _regeneratorRuntime().wrap(function
|
|
9432
|
-
while (1) switch (
|
|
9690
|
+
return _regeneratorRuntime().wrap(function _callee88$(_context88) {
|
|
9691
|
+
while (1) switch (_context88.prev = _context88.next) {
|
|
9433
9692
|
case 0:
|
|
9434
9693
|
if (!(this.orderQuerySubscribers.size === 0)) {
|
|
9435
|
-
|
|
9694
|
+
_context88.next = 2;
|
|
9436
9695
|
break;
|
|
9437
9696
|
}
|
|
9438
|
-
return
|
|
9697
|
+
return _context88.abrupt("return");
|
|
9439
9698
|
case 2:
|
|
9440
9699
|
notifyStartAt = Date.now();
|
|
9441
9700
|
this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
|
|
@@ -9443,20 +9702,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
9443
9702
|
notifyStartAt: new Date(notifyStartAt).toISOString()
|
|
9444
9703
|
});
|
|
9445
9704
|
_iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
|
|
9446
|
-
|
|
9705
|
+
_context88.prev = 5;
|
|
9447
9706
|
_iterator19.s();
|
|
9448
9707
|
case 7:
|
|
9449
9708
|
if ((_step19 = _iterator19.n()).done) {
|
|
9450
|
-
|
|
9709
|
+
_context88.next = 27;
|
|
9451
9710
|
break;
|
|
9452
9711
|
}
|
|
9453
9712
|
_step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
|
|
9454
|
-
|
|
9713
|
+
_context88.prev = 9;
|
|
9455
9714
|
computeStartAt = Date.now();
|
|
9456
|
-
|
|
9715
|
+
_context88.next = 13;
|
|
9457
9716
|
return this.computeOrderQueryResult(subscriber.context);
|
|
9458
9717
|
case 13:
|
|
9459
|
-
result =
|
|
9718
|
+
result = _context88.sent;
|
|
9460
9719
|
computeEndAt = Date.now();
|
|
9461
9720
|
callbackStartAt = Date.now();
|
|
9462
9721
|
subscriber.callback(result);
|
|
@@ -9467,30 +9726,30 @@ var Server = /*#__PURE__*/function () {
|
|
|
9467
9726
|
callbackDurationMs: callbackEndAt - callbackStartAt,
|
|
9468
9727
|
totalDurationMs: callbackEndAt - computeStartAt
|
|
9469
9728
|
});
|
|
9470
|
-
|
|
9729
|
+
_context88.next = 25;
|
|
9471
9730
|
break;
|
|
9472
9731
|
case 21:
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
errorMessage =
|
|
9732
|
+
_context88.prev = 21;
|
|
9733
|
+
_context88.t0 = _context88["catch"](9);
|
|
9734
|
+
errorMessage = _context88.t0 instanceof Error ? _context88.t0.message : String(_context88.t0);
|
|
9476
9735
|
this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
|
|
9477
9736
|
subscriberId: subscriberId,
|
|
9478
9737
|
error: errorMessage
|
|
9479
9738
|
});
|
|
9480
9739
|
case 25:
|
|
9481
|
-
|
|
9740
|
+
_context88.next = 7;
|
|
9482
9741
|
break;
|
|
9483
9742
|
case 27:
|
|
9484
|
-
|
|
9743
|
+
_context88.next = 32;
|
|
9485
9744
|
break;
|
|
9486
9745
|
case 29:
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
_iterator19.e(
|
|
9746
|
+
_context88.prev = 29;
|
|
9747
|
+
_context88.t1 = _context88["catch"](5);
|
|
9748
|
+
_iterator19.e(_context88.t1);
|
|
9490
9749
|
case 32:
|
|
9491
|
-
|
|
9750
|
+
_context88.prev = 32;
|
|
9492
9751
|
_iterator19.f();
|
|
9493
|
-
return
|
|
9752
|
+
return _context88.finish(32);
|
|
9494
9753
|
case 35:
|
|
9495
9754
|
notifyEndAt = Date.now();
|
|
9496
9755
|
this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
|
|
@@ -9499,9 +9758,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
9499
9758
|
});
|
|
9500
9759
|
case 37:
|
|
9501
9760
|
case "end":
|
|
9502
|
-
return
|
|
9761
|
+
return _context88.stop();
|
|
9503
9762
|
}
|
|
9504
|
-
},
|
|
9763
|
+
}, _callee88, this, [[5, 29, 32, 35], [9, 21]]);
|
|
9505
9764
|
}));
|
|
9506
9765
|
function recomputeAndNotifyOrderQuery() {
|
|
9507
9766
|
return _recomputeAndNotifyOrderQuery.apply(this, arguments);
|
|
@@ -9519,7 +9778,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
9519
9778
|
}, {
|
|
9520
9779
|
key: "notifySalesSearchSubscribers",
|
|
9521
9780
|
value: function notifySalesSearchSubscribers(payload) {
|
|
9522
|
-
var
|
|
9781
|
+
var _this30 = this;
|
|
9523
9782
|
if (this.salesSearchSubscribers.size === 0) return;
|
|
9524
9783
|
var changedOrders = this.extractChangedOrdersFromPayload(payload);
|
|
9525
9784
|
if (changedOrders.length === 0) {
|
|
@@ -9537,21 +9796,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
9537
9796
|
subscriber = _step20$value[1];
|
|
9538
9797
|
try {
|
|
9539
9798
|
var changedVisibleOrders = changedOrders.filter(function (order) {
|
|
9540
|
-
var orderId =
|
|
9799
|
+
var orderId = _this30.getSalesSearchOrderId(order);
|
|
9541
9800
|
return !!orderId && subscriber.visibleOrderIds.has(orderId);
|
|
9542
9801
|
});
|
|
9543
9802
|
if (changedVisibleOrders.length === 0) {
|
|
9544
9803
|
return 1; // continue
|
|
9545
9804
|
}
|
|
9546
|
-
subscriber.callback(
|
|
9547
|
-
|
|
9805
|
+
subscriber.callback(_this30.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
|
|
9806
|
+
_this30.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
|
|
9548
9807
|
subscriberId: subscriberId,
|
|
9549
9808
|
kind: subscriber.kind,
|
|
9550
9809
|
count: changedVisibleOrders.length
|
|
9551
9810
|
});
|
|
9552
9811
|
} catch (error) {
|
|
9553
9812
|
var errorMessage = error instanceof Error ? error.message : String(error);
|
|
9554
|
-
|
|
9813
|
+
_this30.logError('notifySalesSearchSubscribers: 推送失败', {
|
|
9555
9814
|
subscriberId: subscriberId,
|
|
9556
9815
|
error: errorMessage
|
|
9557
9816
|
});
|
|
@@ -9642,67 +9901,67 @@ var Server = /*#__PURE__*/function () {
|
|
|
9642
9901
|
}, {
|
|
9643
9902
|
key: "recomputeAndNotifyBookingQuery",
|
|
9644
9903
|
value: (function () {
|
|
9645
|
-
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9904
|
+
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee89() {
|
|
9646
9905
|
var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
|
|
9647
|
-
return _regeneratorRuntime().wrap(function
|
|
9648
|
-
while (1) switch (
|
|
9906
|
+
return _regeneratorRuntime().wrap(function _callee89$(_context89) {
|
|
9907
|
+
while (1) switch (_context89.prev = _context89.next) {
|
|
9649
9908
|
case 0:
|
|
9650
9909
|
if (!(this.bookingQuerySubscribers.size === 0)) {
|
|
9651
|
-
|
|
9910
|
+
_context89.next = 2;
|
|
9652
9911
|
break;
|
|
9653
9912
|
}
|
|
9654
|
-
return
|
|
9913
|
+
return _context89.abrupt("return");
|
|
9655
9914
|
case 2:
|
|
9656
9915
|
this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
|
|
9657
9916
|
subscriberCount: this.bookingQuerySubscribers.size
|
|
9658
9917
|
});
|
|
9659
9918
|
_iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
|
|
9660
|
-
|
|
9919
|
+
_context89.prev = 4;
|
|
9661
9920
|
_iterator21.s();
|
|
9662
9921
|
case 6:
|
|
9663
9922
|
if ((_step21 = _iterator21.n()).done) {
|
|
9664
|
-
|
|
9923
|
+
_context89.next = 22;
|
|
9665
9924
|
break;
|
|
9666
9925
|
}
|
|
9667
9926
|
_step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
|
|
9668
|
-
|
|
9669
|
-
|
|
9927
|
+
_context89.prev = 8;
|
|
9928
|
+
_context89.next = 11;
|
|
9670
9929
|
return this.computeBookingQueryResult(subscriber.context);
|
|
9671
9930
|
case 11:
|
|
9672
|
-
result =
|
|
9931
|
+
result = _context89.sent;
|
|
9673
9932
|
subscriber.callback(result);
|
|
9674
9933
|
this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
|
|
9675
9934
|
subscriberId: subscriberId
|
|
9676
9935
|
});
|
|
9677
|
-
|
|
9936
|
+
_context89.next = 20;
|
|
9678
9937
|
break;
|
|
9679
9938
|
case 16:
|
|
9680
|
-
|
|
9681
|
-
|
|
9682
|
-
errorMessage =
|
|
9939
|
+
_context89.prev = 16;
|
|
9940
|
+
_context89.t0 = _context89["catch"](8);
|
|
9941
|
+
errorMessage = _context89.t0 instanceof Error ? _context89.t0.message : String(_context89.t0);
|
|
9683
9942
|
this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
|
|
9684
9943
|
subscriberId: subscriberId,
|
|
9685
9944
|
error: errorMessage
|
|
9686
9945
|
});
|
|
9687
9946
|
case 20:
|
|
9688
|
-
|
|
9947
|
+
_context89.next = 6;
|
|
9689
9948
|
break;
|
|
9690
9949
|
case 22:
|
|
9691
|
-
|
|
9950
|
+
_context89.next = 27;
|
|
9692
9951
|
break;
|
|
9693
9952
|
case 24:
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
_iterator21.e(
|
|
9953
|
+
_context89.prev = 24;
|
|
9954
|
+
_context89.t1 = _context89["catch"](4);
|
|
9955
|
+
_iterator21.e(_context89.t1);
|
|
9697
9956
|
case 27:
|
|
9698
|
-
|
|
9957
|
+
_context89.prev = 27;
|
|
9699
9958
|
_iterator21.f();
|
|
9700
|
-
return
|
|
9959
|
+
return _context89.finish(27);
|
|
9701
9960
|
case 30:
|
|
9702
9961
|
case "end":
|
|
9703
|
-
return
|
|
9962
|
+
return _context89.stop();
|
|
9704
9963
|
}
|
|
9705
|
-
},
|
|
9964
|
+
}, _callee89, this, [[4, 24, 27, 30], [8, 16]]);
|
|
9706
9965
|
}));
|
|
9707
9966
|
function recomputeAndNotifyBookingQuery() {
|
|
9708
9967
|
return _recomputeAndNotifyBookingQuery.apply(this, arguments);
|