@pisell/pisellos 0.10.16 → 0.10.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/OpenData/index.d.ts +5 -2
- package/dist/modules/OpenData/index.js +27 -12
- package/dist/modules/OpenData/types.d.ts +42 -0
- package/dist/modules/OpenData/types.js +7 -1
- package/dist/modules/OpenData/utils.d.ts +15 -1
- package/dist/modules/OpenData/utils.js +85 -0
- package/dist/modules/Order/index.d.ts +3 -1
- package/dist/modules/Order/index.js +68 -44
- package/dist/modules/Order/types.d.ts +3 -0
- package/dist/modules/Order/types.js +1 -0
- package/dist/modules/ProductList/index.js +96 -74
- package/dist/modules/Rules/index.js +11 -8
- package/dist/modules/SalesSummary/index.js +6 -4
- package/dist/server/index.d.ts +11 -0
- package/dist/server/index.js +852 -484
- package/dist/server/modules/order/index.d.ts +8 -0
- package/dist/server/modules/order/index.js +251 -215
- package/dist/server/utils/small-ticket.d.ts +9 -1
- package/dist/server/utils/small-ticket.js +117 -43
- package/dist/solution/BaseSales/index.d.ts +7 -0
- package/dist/solution/BaseSales/index.js +251 -144
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.d.ts +14 -19
- package/dist/solution/BookingTicket/index.js +545 -429
- package/dist/solution/Sales/index.d.ts +20 -4
- package/dist/solution/Sales/index.js +348 -75
- package/dist/solution/Sales/types.d.ts +10 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/dist/solution/UnifiedBookingSales/index.js +495 -422
- package/dist/solution/UnifiedBookingSales/types.d.ts +7 -1
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/OpenData/index.d.ts +5 -2
- package/lib/modules/OpenData/index.js +50 -3
- package/lib/modules/OpenData/types.d.ts +42 -0
- package/lib/modules/OpenData/types.js +9 -1
- package/lib/modules/OpenData/utils.d.ts +15 -1
- package/lib/modules/OpenData/utils.js +85 -0
- package/lib/modules/Order/index.d.ts +3 -1
- package/lib/modules/Order/index.js +41 -21
- package/lib/modules/Order/types.d.ts +3 -0
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/ProductList/index.js +9 -6
- package/lib/modules/Rules/index.js +8 -6
- package/lib/modules/SalesSummary/index.js +3 -1
- package/lib/server/index.d.ts +11 -0
- package/lib/server/index.js +399 -96
- package/lib/server/modules/order/index.d.ts +8 -0
- package/lib/server/modules/order/index.js +23 -0
- package/lib/server/utils/small-ticket.d.ts +9 -1
- package/lib/server/utils/small-ticket.js +107 -35
- package/lib/solution/BaseSales/index.d.ts +7 -0
- package/lib/solution/BaseSales/index.js +125 -28
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.d.ts +14 -19
- package/lib/solution/BookingTicket/index.js +70 -17
- package/lib/solution/Sales/index.d.ts +20 -4
- package/lib/solution/Sales/index.js +183 -15
- package/lib/solution/Sales/types.d.ts +10 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/lib/solution/UnifiedBookingSales/index.js +41 -15
- package/lib/solution/UnifiedBookingSales/types.d.ts +7 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -43,6 +43,10 @@ import { filterBookingsFromOrders, sortBookings } from "./modules/order/utils/fi
|
|
|
43
43
|
import { buildSmallTicketData, hasSmallTicketData } from "./utils/small-ticket";
|
|
44
44
|
import { BaseSalesImpl } from "../solution/BaseSales";
|
|
45
45
|
import { getOrderPaymentIdentityKeys, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity } from "../modules/Order/payment-utils";
|
|
46
|
+
import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings } from "../modules/OpenData";
|
|
47
|
+
var OS_FULFILLMENT_REF_MODE_FIELD = '_os_fulfillment_ref_mode';
|
|
48
|
+
var OS_INVOICE_LAYOUT_CONFIG_FIELD = '_os_invoice_layout_config';
|
|
49
|
+
var OS_INVOICE_TEMPLATE_SETTINGS_FIELD = '_os_invoice_template_settings';
|
|
46
50
|
|
|
47
51
|
// 重新导出类型供外部使用
|
|
48
52
|
|
|
@@ -68,7 +72,7 @@ var AUTO_PRINT_STORAGE_KEY = 'auto_print';
|
|
|
68
72
|
var Server = /*#__PURE__*/function () {
|
|
69
73
|
function Server(core) {
|
|
70
74
|
var _this = this,
|
|
71
|
-
_this$
|
|
75
|
+
_this$app3;
|
|
72
76
|
_classCallCheck(this, Server);
|
|
73
77
|
_defineProperty(this, "core", void 0);
|
|
74
78
|
_defineProperty(this, "app", void 0);
|
|
@@ -1136,15 +1140,30 @@ var Server = /*#__PURE__*/function () {
|
|
|
1136
1140
|
}());
|
|
1137
1141
|
_defineProperty(this, "handleLocalPrintOrder", /*#__PURE__*/function () {
|
|
1138
1142
|
var _ref45 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(_ref44) {
|
|
1139
|
-
var data, _this$getLocalPrintOr, _need_sync, inputOrder, shouldLookup, lookup, sourceOrder, _this$order,
|
|
1143
|
+
var data, _extractedRequestTemp, _nestedOrderTemplateS, _extractedRequest$inv, _extractedRequestTemp2, _this$getLocalPrintOr, _need_sync, extractedRequest, extractedRequestTemplateSettings, requestOrder, nestedOrder, nestedOrderTemplateSettings, inputOrder, invoiceLayoutConfig, invoiceTemplateSettings, shouldLookup, lookup, sourceOrder, _this$order, localOrder, remoteResult, checkoutData, printableOrder, printResult, message;
|
|
1140
1144
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1141
1145
|
while (1) switch (_context19.prev = _context19.next) {
|
|
1142
1146
|
case 0:
|
|
1143
1147
|
data = _ref44.data;
|
|
1144
1148
|
_context19.prev = 1;
|
|
1145
|
-
|
|
1149
|
+
extractedRequest = _this.extractInvoiceLayoutConfig(data, {
|
|
1150
|
+
includePublicInvoice: true
|
|
1151
|
+
});
|
|
1152
|
+
extractedRequestTemplateSettings = _this.extractInvoiceTemplateSettings(extractedRequest.data, {
|
|
1153
|
+
includePublicTemplateSettings: true
|
|
1154
|
+
});
|
|
1155
|
+
requestOrder = (_extractedRequestTemp = extractedRequestTemplateSettings.data) === null || _extractedRequestTemp === void 0 ? void 0 : _extractedRequestTemp.order;
|
|
1156
|
+
nestedOrder = requestOrder && _typeof(requestOrder) === 'object' ? _this.extractInvoiceLayoutConfig(requestOrder, {
|
|
1157
|
+
includePublicInvoice: true
|
|
1158
|
+
}) : null;
|
|
1159
|
+
nestedOrderTemplateSettings = nestedOrder ? _this.extractInvoiceTemplateSettings(nestedOrder.data, {
|
|
1160
|
+
includePublicTemplateSettings: true
|
|
1161
|
+
}) : null;
|
|
1162
|
+
inputOrder = (_nestedOrderTemplateS = nestedOrderTemplateSettings === null || nestedOrderTemplateSettings === void 0 ? void 0 : nestedOrderTemplateSettings.data) !== null && _nestedOrderTemplateS !== void 0 ? _nestedOrderTemplateS : extractedRequestTemplateSettings.data;
|
|
1163
|
+
invoiceLayoutConfig = (_extractedRequest$inv = extractedRequest.invoiceLayoutConfig) !== null && _extractedRequest$inv !== void 0 ? _extractedRequest$inv : nestedOrder === null || nestedOrder === void 0 ? void 0 : nestedOrder.invoiceLayoutConfig;
|
|
1164
|
+
invoiceTemplateSettings = _this.normalizePrintInvoiceTemplateSettings((_extractedRequestTemp2 = extractedRequestTemplateSettings.invoiceTemplateSettings) !== null && _extractedRequestTemp2 !== void 0 ? _extractedRequestTemp2 : nestedOrderTemplateSettings === null || nestedOrderTemplateSettings === void 0 ? void 0 : nestedOrderTemplateSettings.invoiceTemplateSettings);
|
|
1146
1165
|
if (!(!inputOrder || _typeof(inputOrder) !== 'object')) {
|
|
1147
|
-
_context19.next =
|
|
1166
|
+
_context19.next = 12;
|
|
1148
1167
|
break;
|
|
1149
1168
|
}
|
|
1150
1169
|
return _context19.abrupt("return", {
|
|
@@ -1156,21 +1175,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
1156
1175
|
order: null
|
|
1157
1176
|
}
|
|
1158
1177
|
});
|
|
1159
|
-
case
|
|
1160
|
-
shouldLookup = _this.shouldLookupLocalPrintOrder(inputOrder) || _this.shouldLookupLocalPrintOrder(data);
|
|
1178
|
+
case 12:
|
|
1179
|
+
shouldLookup = _this.shouldLookupLocalPrintOrder(inputOrder) || _this.shouldLookupLocalPrintOrder(extractedRequest.data);
|
|
1161
1180
|
_this.logInfo('handleLocalPrintOrder: 是否需要查找本地订单', {
|
|
1162
1181
|
shouldLookup: shouldLookup,
|
|
1163
1182
|
inputOrder: inputOrder,
|
|
1164
1183
|
data: data
|
|
1165
1184
|
});
|
|
1166
|
-
lookup = shouldLookup ? (_this$getLocalPrintOr = _this.getLocalPrintOrderLookup(inputOrder)) !== null && _this$getLocalPrintOr !== void 0 ? _this$getLocalPrintOr : _this.getLocalPrintOrderLookup(data) : undefined;
|
|
1185
|
+
lookup = shouldLookup ? (_this$getLocalPrintOr = _this.getLocalPrintOrderLookup(inputOrder)) !== null && _this$getLocalPrintOr !== void 0 ? _this$getLocalPrintOr : _this.getLocalPrintOrderLookup(extractedRequest.data) : undefined;
|
|
1167
1186
|
sourceOrder = inputOrder;
|
|
1168
1187
|
if (!shouldLookup) {
|
|
1169
|
-
_context19.next =
|
|
1188
|
+
_context19.next = 32;
|
|
1170
1189
|
break;
|
|
1171
1190
|
}
|
|
1172
1191
|
if (!(lookup === undefined)) {
|
|
1173
|
-
_context19.next =
|
|
1192
|
+
_context19.next = 19;
|
|
1174
1193
|
break;
|
|
1175
1194
|
}
|
|
1176
1195
|
return _context19.abrupt("return", {
|
|
@@ -1182,9 +1201,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
1182
1201
|
order: null
|
|
1183
1202
|
}
|
|
1184
1203
|
});
|
|
1185
|
-
case
|
|
1204
|
+
case 19:
|
|
1186
1205
|
if ((_this$order = _this.order) !== null && _this$order !== void 0 && _this$order.getLocalOrderByLookup) {
|
|
1187
|
-
_context19.next =
|
|
1206
|
+
_context19.next = 21;
|
|
1188
1207
|
break;
|
|
1189
1208
|
}
|
|
1190
1209
|
return _context19.abrupt("return", {
|
|
@@ -1196,35 +1215,44 @@ var Server = /*#__PURE__*/function () {
|
|
|
1196
1215
|
order: null
|
|
1197
1216
|
}
|
|
1198
1217
|
});
|
|
1199
|
-
case
|
|
1200
|
-
_context19.next =
|
|
1218
|
+
case 21:
|
|
1219
|
+
_context19.next = 23;
|
|
1201
1220
|
return _this.order.getLocalOrderByLookup(lookup);
|
|
1202
|
-
case
|
|
1221
|
+
case 23:
|
|
1203
1222
|
localOrder = _context19.sent;
|
|
1204
1223
|
if (localOrder) {
|
|
1205
|
-
_context19.next =
|
|
1224
|
+
_context19.next = 31;
|
|
1225
|
+
break;
|
|
1226
|
+
}
|
|
1227
|
+
_context19.next = 27;
|
|
1228
|
+
return _this.fetchAndPersistSalesOrderByLookup(lookup, {
|
|
1229
|
+
with: ['all']
|
|
1230
|
+
}, 'handleLocalPrintOrder');
|
|
1231
|
+
case 27:
|
|
1232
|
+
remoteResult = _context19.sent;
|
|
1233
|
+
if (remoteResult.order) {
|
|
1234
|
+
_context19.next = 30;
|
|
1206
1235
|
break;
|
|
1207
1236
|
}
|
|
1208
1237
|
return _context19.abrupt("return", {
|
|
1209
|
-
code:
|
|
1238
|
+
code: remoteResult.code,
|
|
1210
1239
|
status: false,
|
|
1211
|
-
message:
|
|
1240
|
+
message: remoteResult.message,
|
|
1212
1241
|
data: {
|
|
1213
1242
|
printed: false,
|
|
1214
1243
|
order: null
|
|
1215
1244
|
}
|
|
1216
1245
|
});
|
|
1217
|
-
case
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
_context19.next = 22;
|
|
1246
|
+
case 30:
|
|
1247
|
+
localOrder = remoteResult.order;
|
|
1248
|
+
case 31:
|
|
1249
|
+
sourceOrder = _this.mergeLocalPrintOrderInput(localOrder, inputOrder);
|
|
1250
|
+
case 32:
|
|
1251
|
+
_context19.next = 34;
|
|
1224
1252
|
return _this.ensureCheckoutOrderNumbers(_objectSpread(_objectSpread({}, sourceOrder), {}, {
|
|
1225
1253
|
small_ticket_data_flag: 1
|
|
1226
1254
|
}), 'handleLocalPrintOrder');
|
|
1227
|
-
case
|
|
1255
|
+
case 34:
|
|
1228
1256
|
checkoutData = _context19.sent;
|
|
1229
1257
|
printableOrder = _objectSpread(_objectSpread({}, checkoutData), {}, {
|
|
1230
1258
|
need_sync: (_need_sync = checkoutData.need_sync) !== null && _need_sync !== void 0 ? _need_sync : 1
|
|
@@ -1233,15 +1261,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
1233
1261
|
checkoutData: checkoutData,
|
|
1234
1262
|
printableOrder: printableOrder
|
|
1235
1263
|
});
|
|
1236
|
-
_context19.next =
|
|
1264
|
+
_context19.next = 39;
|
|
1237
1265
|
return _this.dispatchLocalReceiptPrint({
|
|
1238
1266
|
checkoutData: checkoutData,
|
|
1239
1267
|
order: printableOrder,
|
|
1240
1268
|
response: null,
|
|
1241
1269
|
requireFullyPaid: false,
|
|
1242
|
-
isManualPrint: true
|
|
1270
|
+
isManualPrint: true,
|
|
1271
|
+
invoiceLayoutConfig: invoiceLayoutConfig,
|
|
1272
|
+
invoiceTemplateSettings: invoiceTemplateSettings
|
|
1243
1273
|
});
|
|
1244
|
-
case
|
|
1274
|
+
case 39:
|
|
1245
1275
|
printResult = _context19.sent;
|
|
1246
1276
|
return _context19.abrupt("return", {
|
|
1247
1277
|
code: 200,
|
|
@@ -1252,8 +1282,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
1252
1282
|
order: printResult.order
|
|
1253
1283
|
}
|
|
1254
1284
|
});
|
|
1255
|
-
case
|
|
1256
|
-
_context19.prev =
|
|
1285
|
+
case 43:
|
|
1286
|
+
_context19.prev = 43;
|
|
1257
1287
|
_context19.t0 = _context19["catch"](1);
|
|
1258
1288
|
message = _context19.t0 instanceof Error ? _context19.t0.message : String(_context19.t0);
|
|
1259
1289
|
_this.logError('handleLocalPrintOrder: 本地打印小票失败', {
|
|
@@ -1268,24 +1298,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
1268
1298
|
order: null
|
|
1269
1299
|
}
|
|
1270
1300
|
});
|
|
1271
|
-
case
|
|
1301
|
+
case 48:
|
|
1272
1302
|
case "end":
|
|
1273
1303
|
return _context19.stop();
|
|
1274
1304
|
}
|
|
1275
|
-
}, _callee19, null, [[1,
|
|
1305
|
+
}, _callee19, null, [[1, 43]]);
|
|
1276
1306
|
}));
|
|
1277
1307
|
return function (_x19) {
|
|
1278
1308
|
return _ref45.apply(this, arguments);
|
|
1279
1309
|
};
|
|
1280
1310
|
}());
|
|
1281
1311
|
_defineProperty(this, "handleMachinecodeBatchMeta", /*#__PURE__*/function () {
|
|
1282
|
-
var
|
|
1312
|
+
var _ref47 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(_ref46) {
|
|
1283
1313
|
var _this$resolveMachinec, _this$app2;
|
|
1284
1314
|
var data, title, backendPath, ids, status, message, _response$code, _response$status, _response$message, _response$data2, response, backendError, _backendError$code, _backendError$status, _backendError$message, _backendError$data, _message;
|
|
1285
1315
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1286
1316
|
while (1) switch (_context20.prev = _context20.next) {
|
|
1287
1317
|
case 0:
|
|
1288
|
-
data =
|
|
1318
|
+
data = _ref46.data;
|
|
1289
1319
|
title = 'handleMachinecodeBatchMeta';
|
|
1290
1320
|
backendPath = '/shop/machinecode/batch';
|
|
1291
1321
|
ids = Array.isArray(data === null || data === void 0 ? void 0 : data.ids) ? data.ids : [];
|
|
@@ -1404,17 +1434,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
1404
1434
|
}, _callee20, null, [[10, 15], [23, 30]]);
|
|
1405
1435
|
}));
|
|
1406
1436
|
return function (_x20) {
|
|
1407
|
-
return
|
|
1437
|
+
return _ref47.apply(this, arguments);
|
|
1408
1438
|
};
|
|
1409
1439
|
}());
|
|
1410
1440
|
_defineProperty(this, "handleOrderSalesDetail", /*#__PURE__*/function () {
|
|
1411
|
-
var
|
|
1412
|
-
var
|
|
1413
|
-
var url, data, path, requestPath, lookup, localOrder, enrichedOrder, backendPath, _response$data3, response, fresh, savedOrder, _enrichedOrder, errorMessage;
|
|
1441
|
+
var _ref49 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(_ref48) {
|
|
1442
|
+
var url, data, path, requestPath, lookup, localOrder, _enrichedOrder, remoteResult, enrichedOrder;
|
|
1414
1443
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1415
1444
|
while (1) switch (_context21.prev = _context21.next) {
|
|
1416
1445
|
case 0:
|
|
1417
|
-
url =
|
|
1446
|
+
url = _ref48.url, data = _ref48.data, path = _ref48.path;
|
|
1418
1447
|
requestPath = _this.parseRequestPath(url, path);
|
|
1419
1448
|
lookup = _this.extractOrderSalesDetailLookup(requestPath);
|
|
1420
1449
|
_this.logInfo('handleOrderSalesDetail: 开始处理', {
|
|
@@ -1464,7 +1493,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1464
1493
|
_context21.next = 17;
|
|
1465
1494
|
return _this.withSalesDetailProductSnapshots(localOrder);
|
|
1466
1495
|
case 17:
|
|
1467
|
-
|
|
1496
|
+
_enrichedOrder = _context21.sent;
|
|
1468
1497
|
_this.logInfo('handleOrderSalesDetail: 命中本地订单', {
|
|
1469
1498
|
lookup: lookup
|
|
1470
1499
|
});
|
|
@@ -1472,117 +1501,54 @@ var Server = /*#__PURE__*/function () {
|
|
|
1472
1501
|
code: 200,
|
|
1473
1502
|
status: true,
|
|
1474
1503
|
message: '',
|
|
1475
|
-
data:
|
|
1504
|
+
data: _enrichedOrder
|
|
1476
1505
|
});
|
|
1477
1506
|
case 20:
|
|
1478
|
-
|
|
1479
|
-
|
|
1507
|
+
_context21.next = 22;
|
|
1508
|
+
return _this.fetchAndPersistSalesOrderByLookup(lookup, data, 'handleOrderSalesDetail');
|
|
1509
|
+
case 22:
|
|
1510
|
+
remoteResult = _context21.sent;
|
|
1511
|
+
if (remoteResult.order) {
|
|
1512
|
+
_context21.next = 25;
|
|
1480
1513
|
break;
|
|
1481
1514
|
}
|
|
1482
|
-
_this.logError('handleOrderSalesDetail: app.request 不可用');
|
|
1483
1515
|
return _context21.abrupt("return", {
|
|
1484
|
-
code:
|
|
1516
|
+
code: remoteResult.code,
|
|
1485
1517
|
status: false,
|
|
1486
|
-
message:
|
|
1518
|
+
message: remoteResult.message,
|
|
1487
1519
|
data: null
|
|
1488
1520
|
});
|
|
1489
|
-
case
|
|
1490
|
-
backendPath = _this.buildOrderSalesDetailBackendPath(lookup, data);
|
|
1491
|
-
_context21.prev = 24;
|
|
1521
|
+
case 25:
|
|
1492
1522
|
_context21.next = 27;
|
|
1493
|
-
return _this.
|
|
1494
|
-
lookup_mode: 'multi'
|
|
1495
|
-
}, {
|
|
1496
|
-
isShopApi: true,
|
|
1497
|
-
customToast: function customToast() {}
|
|
1498
|
-
});
|
|
1523
|
+
return _this.withSalesDetailProductSnapshots(remoteResult.order);
|
|
1499
1524
|
case 27:
|
|
1500
|
-
|
|
1501
|
-
fresh = (_response$data3 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data3 !== void 0 ? _response$data3 : response;
|
|
1502
|
-
if (!(!fresh || _typeof(fresh) !== 'object' || fresh.order_id == null)) {
|
|
1503
|
-
_context21.next = 32;
|
|
1504
|
-
break;
|
|
1505
|
-
}
|
|
1506
|
-
_this.logInfo('handleOrderSalesDetail: 后端返回订单为空', {
|
|
1507
|
-
lookup: lookup,
|
|
1508
|
-
backendPath: backendPath
|
|
1509
|
-
});
|
|
1510
|
-
return _context21.abrupt("return", {
|
|
1511
|
-
code: 500,
|
|
1512
|
-
status: false,
|
|
1513
|
-
message: '后端返回订单为空',
|
|
1514
|
-
data: null
|
|
1515
|
-
});
|
|
1516
|
-
case 32:
|
|
1517
|
-
_context21.next = 34;
|
|
1518
|
-
return _this.order.upsertOrdersFromRemote([fresh]);
|
|
1519
|
-
case 34:
|
|
1520
|
-
_context21.next = 36;
|
|
1521
|
-
return _this.order.getLocalOrderByLookup(lookup);
|
|
1522
|
-
case 36:
|
|
1523
|
-
savedOrder = _context21.sent;
|
|
1524
|
-
if (savedOrder) {
|
|
1525
|
-
_context21.next = 40;
|
|
1526
|
-
break;
|
|
1527
|
-
}
|
|
1528
|
-
_this.logError('handleOrderSalesDetail: 订单写入后回读失败', {
|
|
1529
|
-
lookup: lookup
|
|
1530
|
-
});
|
|
1531
|
-
return _context21.abrupt("return", {
|
|
1532
|
-
code: 500,
|
|
1533
|
-
status: false,
|
|
1534
|
-
message: '订单写入后回读失败',
|
|
1535
|
-
data: null
|
|
1536
|
-
});
|
|
1537
|
-
case 40:
|
|
1538
|
-
_this.logInfo('handleOrderSalesDetail: 远端订单已同步到本地', {
|
|
1539
|
-
lookup: lookup
|
|
1540
|
-
});
|
|
1541
|
-
_context21.next = 43;
|
|
1542
|
-
return _this.withSalesDetailProductSnapshots(savedOrder);
|
|
1543
|
-
case 43:
|
|
1544
|
-
_enrichedOrder = _context21.sent;
|
|
1525
|
+
enrichedOrder = _context21.sent;
|
|
1545
1526
|
return _context21.abrupt("return", {
|
|
1546
1527
|
code: 200,
|
|
1547
1528
|
status: true,
|
|
1548
1529
|
message: '',
|
|
1549
|
-
data:
|
|
1550
|
-
});
|
|
1551
|
-
case 47:
|
|
1552
|
-
_context21.prev = 47;
|
|
1553
|
-
_context21.t0 = _context21["catch"](24);
|
|
1554
|
-
errorMessage = _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0);
|
|
1555
|
-
_this.logInfo('handleOrderSalesDetail: 请求失败', {
|
|
1556
|
-
lookup: lookup,
|
|
1557
|
-
backendPath: backendPath,
|
|
1558
|
-
error: errorMessage
|
|
1559
|
-
});
|
|
1560
|
-
return _context21.abrupt("return", {
|
|
1561
|
-
code: 500,
|
|
1562
|
-
status: false,
|
|
1563
|
-
message: errorMessage,
|
|
1564
|
-
data: null
|
|
1530
|
+
data: enrichedOrder
|
|
1565
1531
|
});
|
|
1566
|
-
case
|
|
1532
|
+
case 29:
|
|
1567
1533
|
case "end":
|
|
1568
1534
|
return _context21.stop();
|
|
1569
1535
|
}
|
|
1570
|
-
}, _callee21
|
|
1536
|
+
}, _callee21);
|
|
1571
1537
|
}));
|
|
1572
1538
|
return function (_x21) {
|
|
1573
|
-
return
|
|
1539
|
+
return _ref49.apply(this, arguments);
|
|
1574
1540
|
};
|
|
1575
1541
|
}());
|
|
1576
1542
|
/**
|
|
1577
1543
|
* GET /shop/schedule/floor-plan* 前缀路由:读本地 store;支持 subscriberId + callback 订阅更新
|
|
1578
1544
|
*/
|
|
1579
1545
|
_defineProperty(this, "handleFloorPlanGet", /*#__PURE__*/function () {
|
|
1580
|
-
var
|
|
1581
|
-
var url, data, config, routePath, base, path, _subscriberId,
|
|
1546
|
+
var _ref51 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(_ref50) {
|
|
1547
|
+
var url, data, config, routePath, base, path, _subscriberId, _ref52, callback, subscriberId, ctx;
|
|
1582
1548
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1583
1549
|
while (1) switch (_context22.prev = _context22.next) {
|
|
1584
1550
|
case 0:
|
|
1585
|
-
url =
|
|
1551
|
+
url = _ref50.url, data = _ref50.data, config = _ref50.config, routePath = _ref50.path;
|
|
1586
1552
|
base = '/shop/schedule/floor-plan';
|
|
1587
1553
|
path = _this.parseRequestPath(url, routePath);
|
|
1588
1554
|
if (!(path === "".concat(base, "/unsubscribe") || path === "".concat(base, "/code/unsubscribe"))) {
|
|
@@ -1603,7 +1569,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1603
1569
|
status: true
|
|
1604
1570
|
});
|
|
1605
1571
|
case 7:
|
|
1606
|
-
|
|
1572
|
+
_ref52 = config || {}, callback = _ref52.callback, subscriberId = _ref52.subscriberId;
|
|
1607
1573
|
ctx = _this.resolveFloorPlanQueryContext(path, base);
|
|
1608
1574
|
if (ctx) {
|
|
1609
1575
|
_context22.next = 11;
|
|
@@ -1635,20 +1601,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
1635
1601
|
}, _callee22);
|
|
1636
1602
|
}));
|
|
1637
1603
|
return function (_x22) {
|
|
1638
|
-
return
|
|
1604
|
+
return _ref51.apply(this, arguments);
|
|
1639
1605
|
};
|
|
1640
1606
|
}());
|
|
1641
1607
|
/**
|
|
1642
1608
|
* 取消预约列表查询订阅(HTTP 路由入口)
|
|
1643
1609
|
*/
|
|
1644
1610
|
_defineProperty(this, "handleUnsubscribeBookingQuery", /*#__PURE__*/function () {
|
|
1645
|
-
var
|
|
1646
|
-
var data,
|
|
1611
|
+
var _ref54 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(_ref53) {
|
|
1612
|
+
var data, _ref55, subscriberId;
|
|
1647
1613
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1648
1614
|
while (1) switch (_context23.prev = _context23.next) {
|
|
1649
1615
|
case 0:
|
|
1650
|
-
data =
|
|
1651
|
-
|
|
1616
|
+
data = _ref53.data;
|
|
1617
|
+
_ref55 = data || {}, subscriberId = _ref55.subscriberId;
|
|
1652
1618
|
if (subscriberId) {
|
|
1653
1619
|
_this.bookingQuerySubscribers.delete(subscriberId);
|
|
1654
1620
|
_this.bookingRemoteQuerySubscribers.delete(subscriberId);
|
|
@@ -1670,7 +1636,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1670
1636
|
}, _callee23);
|
|
1671
1637
|
}));
|
|
1672
1638
|
return function (_x23) {
|
|
1673
|
-
return
|
|
1639
|
+
return _ref54.apply(this, arguments);
|
|
1674
1640
|
};
|
|
1675
1641
|
}());
|
|
1676
1642
|
/**
|
|
@@ -1678,13 +1644,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
1678
1644
|
* 通过餐牌ID列表获取所有相关日程的时间段点
|
|
1679
1645
|
*/
|
|
1680
1646
|
_defineProperty(this, "handleGetScheduleTimePoints", /*#__PURE__*/function () {
|
|
1681
|
-
var
|
|
1647
|
+
var _ref57 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(_ref56) {
|
|
1682
1648
|
var _menu_list_ids$length;
|
|
1683
1649
|
var url, method, data, config, menu_list_ids, _menu_list_ids$length2, _this$getMenuSchedule, menuList, scheduleIds, scheduleList, timePoints, errorMessage;
|
|
1684
1650
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1685
1651
|
while (1) switch (_context24.prev = _context24.next) {
|
|
1686
1652
|
case 0:
|
|
1687
|
-
url =
|
|
1653
|
+
url = _ref56.url, method = _ref56.method, data = _ref56.data, config = _ref56.config;
|
|
1688
1654
|
menu_list_ids = data.menu_list_ids;
|
|
1689
1655
|
_this.logInfo('handleGetScheduleTimePoints 开始处理', {
|
|
1690
1656
|
menuListIdsCount: (_menu_list_ids$length = menu_list_ids === null || menu_list_ids === void 0 ? void 0 : menu_list_ids.length) !== null && _menu_list_ids$length !== void 0 ? _menu_list_ids$length : 0,
|
|
@@ -1797,13 +1763,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
1797
1763
|
}, _callee24, null, [[15, 27]]);
|
|
1798
1764
|
}));
|
|
1799
1765
|
return function (_x24) {
|
|
1800
|
-
return
|
|
1766
|
+
return _ref57.apply(this, arguments);
|
|
1801
1767
|
};
|
|
1802
1768
|
}());
|
|
1803
1769
|
this.core = core;
|
|
1804
1770
|
var appPlugin = core.getPlugin('app');
|
|
1805
1771
|
this.app = (appPlugin === null || appPlugin === void 0 ? void 0 : appPlugin.getApp()) || null;
|
|
1806
|
-
this.logger = ((_this$
|
|
1772
|
+
this.logger = ((_this$app3 = this.app) === null || _this$app3 === void 0 ? void 0 : _this$app3.logger) || null;
|
|
1807
1773
|
this.logInfo('Server 初始化', {
|
|
1808
1774
|
hasApp: !!this.app,
|
|
1809
1775
|
hasLogger: !!this.logger
|
|
@@ -2359,42 +2325,53 @@ var Server = /*#__PURE__*/function () {
|
|
|
2359
2325
|
key: "handleSyncSalesTask",
|
|
2360
2326
|
value: function () {
|
|
2361
2327
|
var _handleSyncSalesTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(ctx) {
|
|
2362
|
-
var _ctx$task, _this$
|
|
2363
|
-
var payload, backendPath, data, title, _ctx$task2, _syncResult$syncedOrd, syncResult, backendError, message, errorMessage;
|
|
2328
|
+
var _ctx$task, _payload$invoice, _payload$template_set, _this$app4;
|
|
2329
|
+
var payload, backendPath, extractedInvoice, extractedTemplateSettings, data, rawInvoiceLayoutConfig, invoiceLayoutConfig, invoiceTemplateSettings, title, _ctx$task2, _syncResult$syncedOrd, syncResult, backendError, message, errorMessage;
|
|
2364
2330
|
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2365
2331
|
while (1) switch (_context30.prev = _context30.next) {
|
|
2366
2332
|
case 0:
|
|
2367
2333
|
payload = ((_ctx$task = ctx.task) === null || _ctx$task === void 0 ? void 0 : _ctx$task.payload) || {};
|
|
2368
2334
|
backendPath = payload.backendPath;
|
|
2369
|
-
|
|
2335
|
+
extractedInvoice = this.extractInvoiceLayoutConfig(payload.data, {
|
|
2336
|
+
includePublicInvoice: true
|
|
2337
|
+
});
|
|
2338
|
+
extractedTemplateSettings = this.extractInvoiceTemplateSettings(extractedInvoice.data, {
|
|
2339
|
+
includePublicTemplateSettings: true
|
|
2340
|
+
});
|
|
2341
|
+
data = extractedTemplateSettings.data;
|
|
2342
|
+
rawInvoiceLayoutConfig = (_payload$invoice = payload.invoice) !== null && _payload$invoice !== void 0 ? _payload$invoice : extractedInvoice.invoiceLayoutConfig;
|
|
2343
|
+
invoiceLayoutConfig = rawInvoiceLayoutConfig === undefined || rawInvoiceLayoutConfig === null ? undefined : this.normalizePrintInvoiceLayoutConfig(rawInvoiceLayoutConfig);
|
|
2344
|
+
invoiceTemplateSettings = this.normalizePrintInvoiceTemplateSettings((_payload$template_set = payload.template_settings) !== null && _payload$template_set !== void 0 ? _payload$template_set : extractedTemplateSettings.invoiceTemplateSettings);
|
|
2370
2345
|
title = payload.title || 'sync_sales';
|
|
2371
2346
|
if (!(!backendPath || !data)) {
|
|
2372
|
-
_context30.next =
|
|
2347
|
+
_context30.next = 11;
|
|
2373
2348
|
break;
|
|
2374
2349
|
}
|
|
2375
2350
|
return _context30.abrupt("return", this.taskFail('INVALID_PAYLOAD', '缺少 backendPath 或 data'));
|
|
2376
|
-
case
|
|
2377
|
-
if ((_this$
|
|
2378
|
-
_context30.next =
|
|
2351
|
+
case 11:
|
|
2352
|
+
if ((_this$app4 = this.app) !== null && _this$app4 !== void 0 && _this$app4.request) {
|
|
2353
|
+
_context30.next = 14;
|
|
2379
2354
|
break;
|
|
2380
2355
|
}
|
|
2381
2356
|
this.logError("".concat(title, ": sync_sales app.request \u4E0D\u53EF\u7528"));
|
|
2382
2357
|
return _context30.abrupt("return", this.taskTimeout('app.request 不可用'));
|
|
2383
|
-
case
|
|
2384
|
-
_context30.prev =
|
|
2385
|
-
_context30.next =
|
|
2358
|
+
case 14:
|
|
2359
|
+
_context30.prev = 14;
|
|
2360
|
+
_context30.next = 17;
|
|
2386
2361
|
return this.runCheckoutSync({
|
|
2387
2362
|
backendPath: backendPath,
|
|
2388
2363
|
data: data,
|
|
2389
2364
|
title: title,
|
|
2390
2365
|
externalSaleNumber: payload.external_sale_number,
|
|
2391
2366
|
deviceId: (_ctx$task2 = ctx.task) === null || _ctx$task2 === void 0 ? void 0 : _ctx$task2.device_id,
|
|
2392
|
-
persistCheckoutDataWithResponse: false
|
|
2367
|
+
persistCheckoutDataWithResponse: false,
|
|
2368
|
+
invoiceLayoutConfig: invoiceLayoutConfig,
|
|
2369
|
+
invoiceTemplateSettings: invoiceTemplateSettings
|
|
2393
2370
|
});
|
|
2394
|
-
case
|
|
2371
|
+
case 17:
|
|
2395
2372
|
syncResult = _context30.sent;
|
|
2396
2373
|
if (!syncResult.rejected) {
|
|
2397
|
-
_context30.next =
|
|
2374
|
+
_context30.next = 21;
|
|
2398
2375
|
break;
|
|
2399
2376
|
}
|
|
2400
2377
|
this.logError("".concat(title, ": sync_sales \u540E\u7AEF\u660E\u786E\u5931\u8D25"), {
|
|
@@ -2402,17 +2379,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
2402
2379
|
response: syncResult.errorResponse
|
|
2403
2380
|
});
|
|
2404
2381
|
return _context30.abrupt("return", this.taskFail('BACKEND_REJECTED', syncResult.message || '后端明确拒绝 checkout', syncResult.errorResponse));
|
|
2405
|
-
case
|
|
2382
|
+
case 21:
|
|
2406
2383
|
return _context30.abrupt("return", this.taskOk({
|
|
2407
2384
|
order: (_syncResult$syncedOrd = syncResult.syncedOrder) !== null && _syncResult$syncedOrd !== void 0 ? _syncResult$syncedOrd : null,
|
|
2408
2385
|
response: syncResult.normalizedResponse
|
|
2409
2386
|
}));
|
|
2410
|
-
case
|
|
2411
|
-
_context30.prev =
|
|
2412
|
-
_context30.t0 = _context30["catch"](
|
|
2387
|
+
case 24:
|
|
2388
|
+
_context30.prev = 24;
|
|
2389
|
+
_context30.t0 = _context30["catch"](14);
|
|
2413
2390
|
backendError = this.extractBackendErrorResponse(_context30.t0);
|
|
2414
2391
|
if (!backendError) {
|
|
2415
|
-
_context30.next =
|
|
2392
|
+
_context30.next = 31;
|
|
2416
2393
|
break;
|
|
2417
2394
|
}
|
|
2418
2395
|
message = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || '后端明确拒绝 checkout';
|
|
@@ -2421,7 +2398,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2421
2398
|
backendError: backendError
|
|
2422
2399
|
});
|
|
2423
2400
|
return _context30.abrupt("return", this.taskFail('BACKEND_REJECTED', message, backendError));
|
|
2424
|
-
case
|
|
2401
|
+
case 31:
|
|
2425
2402
|
errorMessage = this.getUnknownErrorMessage(_context30.t0);
|
|
2426
2403
|
this.logError("".concat(title, ": sync_sales \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
|
|
2427
2404
|
backendPath: backendPath,
|
|
@@ -2429,11 +2406,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
2429
2406
|
error_detail: this.normalizeUnknownError(_context30.t0)
|
|
2430
2407
|
});
|
|
2431
2408
|
return _context30.abrupt("return", this.taskTimeout(errorMessage));
|
|
2432
|
-
case
|
|
2409
|
+
case 34:
|
|
2433
2410
|
case "end":
|
|
2434
2411
|
return _context30.stop();
|
|
2435
2412
|
}
|
|
2436
|
-
}, _callee30, this, [[
|
|
2413
|
+
}, _callee30, this, [[14, 24]]);
|
|
2437
2414
|
}));
|
|
2438
2415
|
function handleSyncSalesTask(_x33) {
|
|
2439
2416
|
return _handleSyncSalesTask.apply(this, arguments);
|
|
@@ -2444,8 +2421,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
2444
2421
|
key: "runCheckoutSync",
|
|
2445
2422
|
value: function () {
|
|
2446
2423
|
var _runCheckoutSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
2447
|
-
var _this$
|
|
2448
|
-
var backendPath, title, normalizedData, checkoutData, remoteCheckoutData, response, fresh, externalSaleNumber, syncedOrder, printableSyncedOrder;
|
|
2424
|
+
var _this$app5;
|
|
2425
|
+
var backendPath, title, normalizedData, numberedData, checkoutData, remoteCheckoutData, response, fresh, externalSaleNumber, syncedOrder, printableSyncedOrder;
|
|
2449
2426
|
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2450
2427
|
while (1) switch (_context31.prev = _context31.next) {
|
|
2451
2428
|
case 0:
|
|
@@ -2457,23 +2434,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
2457
2434
|
_context31.next = 6;
|
|
2458
2435
|
return this.ensureCheckoutOrderNumbers(normalizedData, title);
|
|
2459
2436
|
case 6:
|
|
2460
|
-
|
|
2437
|
+
numberedData = _context31.sent;
|
|
2438
|
+
checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
|
|
2461
2439
|
remoteCheckoutData = this.buildRemoteCheckoutData(checkoutData, title);
|
|
2462
|
-
if ((_this$
|
|
2463
|
-
_context31.next =
|
|
2440
|
+
if ((_this$app5 = this.app) !== null && _this$app5 !== void 0 && (_this$app5 = _this$app5.request) !== null && _this$app5 !== void 0 && _this$app5.post) {
|
|
2441
|
+
_context31.next = 11;
|
|
2464
2442
|
break;
|
|
2465
2443
|
}
|
|
2466
2444
|
throw new Error('app.request 不可用');
|
|
2467
|
-
case
|
|
2468
|
-
_context31.next =
|
|
2445
|
+
case 11:
|
|
2446
|
+
_context31.next = 13;
|
|
2469
2447
|
return this.app.request.post(backendPath, remoteCheckoutData, {
|
|
2470
2448
|
isShopApi: true,
|
|
2471
2449
|
customToast: function customToast() {}
|
|
2472
2450
|
});
|
|
2473
|
-
case
|
|
2451
|
+
case 13:
|
|
2474
2452
|
response = _context31.sent;
|
|
2475
2453
|
if (!this.isCheckoutResponseRejected(response)) {
|
|
2476
|
-
_context31.next =
|
|
2454
|
+
_context31.next = 16;
|
|
2477
2455
|
break;
|
|
2478
2456
|
}
|
|
2479
2457
|
return _context31.abrupt("return", {
|
|
@@ -2484,13 +2462,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
2484
2462
|
normalizedResponse: this.normalizeCheckoutResponse(response),
|
|
2485
2463
|
checkoutData: checkoutData
|
|
2486
2464
|
});
|
|
2487
|
-
case
|
|
2465
|
+
case 16:
|
|
2488
2466
|
fresh = this.extractOrderDataFromCheckoutResponse(response);
|
|
2489
2467
|
externalSaleNumber = this.getCheckoutExternalSaleNumber(checkoutData, {
|
|
2490
2468
|
external_sale_number: params.externalSaleNumber,
|
|
2491
2469
|
data: checkoutData
|
|
2492
2470
|
});
|
|
2493
|
-
_context31.next =
|
|
2471
|
+
_context31.next = 20;
|
|
2494
2472
|
return this.persistSyncedCheckoutOrder({
|
|
2495
2473
|
backendPath: backendPath,
|
|
2496
2474
|
checkoutData: checkoutData,
|
|
@@ -2499,7 +2477,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2499
2477
|
title: title,
|
|
2500
2478
|
persistCheckoutDataWithResponse: params.persistCheckoutDataWithResponse === true
|
|
2501
2479
|
});
|
|
2502
|
-
case
|
|
2480
|
+
case 20:
|
|
2503
2481
|
syncedOrder = _context31.sent;
|
|
2504
2482
|
printableSyncedOrder = syncedOrder ? this.buildSyncedOrderForPrint({
|
|
2505
2483
|
syncedOrder: syncedOrder,
|
|
@@ -2509,17 +2487,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
2509
2487
|
checkoutData: checkoutData,
|
|
2510
2488
|
syncedOrder: printableSyncedOrder
|
|
2511
2489
|
}))) {
|
|
2512
|
-
_context31.next =
|
|
2490
|
+
_context31.next = 25;
|
|
2513
2491
|
break;
|
|
2514
2492
|
}
|
|
2515
|
-
_context31.next =
|
|
2493
|
+
_context31.next = 25;
|
|
2516
2494
|
return this.dispatchPrintOtherReceiptTask({
|
|
2517
2495
|
checkoutData: checkoutData,
|
|
2518
2496
|
syncedOrder: printableSyncedOrder,
|
|
2519
2497
|
response: response,
|
|
2520
|
-
deviceId: params.deviceId
|
|
2498
|
+
deviceId: params.deviceId,
|
|
2499
|
+
invoiceLayoutConfig: params.invoiceLayoutConfig,
|
|
2500
|
+
invoiceTemplateSettings: params.invoiceTemplateSettings
|
|
2521
2501
|
});
|
|
2522
|
-
case
|
|
2502
|
+
case 25:
|
|
2523
2503
|
return _context31.abrupt("return", {
|
|
2524
2504
|
rejected: false,
|
|
2525
2505
|
response: response,
|
|
@@ -2528,7 +2508,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2528
2508
|
syncedOrder: syncedOrder,
|
|
2529
2509
|
fresh: fresh
|
|
2530
2510
|
});
|
|
2531
|
-
case
|
|
2511
|
+
case 26:
|
|
2532
2512
|
case "end":
|
|
2533
2513
|
return _context31.stop();
|
|
2534
2514
|
}
|
|
@@ -2554,6 +2534,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
2554
2534
|
var next = cloneDeep(this.omitCheckoutSyncMode(data));
|
|
2555
2535
|
if (!next || _typeof(next) !== 'object') return next;
|
|
2556
2536
|
var record = next;
|
|
2537
|
+
delete record[OS_FULFILLMENT_REF_MODE_FIELD];
|
|
2538
|
+
delete record[OS_INVOICE_LAYOUT_CONFIG_FIELD];
|
|
2557
2539
|
if (!Array.isArray(record.payments)) return next;
|
|
2558
2540
|
var originalPayments = record.payments;
|
|
2559
2541
|
var filteredPayments = originalPayments.filter(function (payment) {
|
|
@@ -2613,7 +2595,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2613
2595
|
key: "persistSyncedCheckoutOrder",
|
|
2614
2596
|
value: function () {
|
|
2615
2597
|
var _persistSyncedCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
2616
|
-
var backendPath, checkoutData, externalSaleNumber, fresh, title, persistCheckoutDataWithResponse, shouldMergeRemoteOrder, syncedOrder,
|
|
2598
|
+
var backendPath, checkoutData, externalSaleNumber, fresh, title, persistCheckoutDataWithResponse, shouldMergeRemoteOrder, syncedOrder, _external_sale_number, _external_sale_number2, _syncedOrder$order_id, _syncedOrder, patch, result;
|
|
2617
2599
|
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2618
2600
|
while (1) switch (_context32.prev = _context32.next) {
|
|
2619
2601
|
case 0:
|
|
@@ -2624,11 +2606,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
2624
2606
|
break;
|
|
2625
2607
|
}
|
|
2626
2608
|
syncedOrder = persistCheckoutDataWithResponse ? _objectSpread(_objectSpread(_objectSpread({}, checkoutData), this.mergeCheckoutSyncPayments(checkoutData, fresh, title)), {}, {
|
|
2627
|
-
external_sale_number: (
|
|
2609
|
+
external_sale_number: (_external_sale_number = fresh.external_sale_number) !== null && _external_sale_number !== void 0 ? _external_sale_number : externalSaleNumber,
|
|
2628
2610
|
need_sync: 0,
|
|
2629
2611
|
is_draft_order: 0
|
|
2630
2612
|
}) : _objectSpread(_objectSpread({}, this.mergeCheckoutSyncPayments(checkoutData, fresh, title)), {}, {
|
|
2631
|
-
external_sale_number: (
|
|
2613
|
+
external_sale_number: (_external_sale_number2 = fresh.external_sale_number) !== null && _external_sale_number2 !== void 0 ? _external_sale_number2 : externalSaleNumber,
|
|
2632
2614
|
need_sync: 0,
|
|
2633
2615
|
is_draft_order: 0
|
|
2634
2616
|
});
|
|
@@ -3405,12 +3387,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
3405
3387
|
key: "fetchQuotationAvailableFromAPI",
|
|
3406
3388
|
value: function () {
|
|
3407
3389
|
var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(data) {
|
|
3408
|
-
var _this$
|
|
3390
|
+
var _this$app6;
|
|
3409
3391
|
var requester;
|
|
3410
3392
|
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3411
3393
|
while (1) switch (_context41.prev = _context41.next) {
|
|
3412
3394
|
case 0:
|
|
3413
|
-
requester = ((_this$
|
|
3395
|
+
requester = ((_this$app6 = this.app) === null || _this$app6 === void 0 ? void 0 : _this$app6.request) || this.core.getPlugin('request');
|
|
3414
3396
|
if (requester !== null && requester !== void 0 && requester.get) {
|
|
3415
3397
|
_context41.next = 4;
|
|
3416
3398
|
break;
|
|
@@ -3707,11 +3689,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3707
3689
|
*/
|
|
3708
3690
|
}, {
|
|
3709
3691
|
key: "syncProductQueryScheduleTimers",
|
|
3710
|
-
value: function syncProductQueryScheduleTimers(
|
|
3692
|
+
value: function syncProductQueryScheduleTimers(_ref59) {
|
|
3711
3693
|
var _this$products$getLas3, _this$products2, _this$products2$getLa;
|
|
3712
|
-
var subscriberId =
|
|
3713
|
-
menu_list_ids =
|
|
3714
|
-
strategy_context =
|
|
3694
|
+
var subscriberId = _ref59.subscriberId,
|
|
3695
|
+
menu_list_ids = _ref59.menu_list_ids,
|
|
3696
|
+
strategy_context = _ref59.strategy_context;
|
|
3715
3697
|
this.clearSubscriberScheduleTimers(subscriberId);
|
|
3716
3698
|
if (!this.shouldScheduleProductQueryReload(strategy_context)) {
|
|
3717
3699
|
return;
|
|
@@ -3810,7 +3792,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3810
3792
|
*/
|
|
3811
3793
|
function () {
|
|
3812
3794
|
var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(kind, backendPath, data, config) {
|
|
3813
|
-
var queryPayload, result,
|
|
3795
|
+
var queryPayload, result, _ref60, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
|
|
3814
3796
|
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
3815
3797
|
while (1) switch (_context45.prev = _context45.next) {
|
|
3816
3798
|
case 0:
|
|
@@ -3819,7 +3801,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3819
3801
|
return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
|
|
3820
3802
|
case 3:
|
|
3821
3803
|
result = _context45.sent;
|
|
3822
|
-
|
|
3804
|
+
_ref60 = config || {}, callback = _ref60.callback, subscriberId = _ref60.subscriberId, resetVisibleOrderIds = _ref60.resetVisibleOrderIds;
|
|
3823
3805
|
if (subscriberId && typeof callback === 'function') {
|
|
3824
3806
|
contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
|
|
3825
3807
|
existing = this.salesSearchSubscribers.get(subscriberId);
|
|
@@ -3873,12 +3855,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
3873
3855
|
key: "fetchSalesSearchFromAPI",
|
|
3874
3856
|
value: (function () {
|
|
3875
3857
|
var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(backendPath, data) {
|
|
3876
|
-
var _this$
|
|
3877
|
-
var _response$
|
|
3858
|
+
var _this$app7;
|
|
3859
|
+
var _response$data3, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
|
|
3878
3860
|
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
3879
3861
|
while (1) switch (_context46.prev = _context46.next) {
|
|
3880
3862
|
case 0:
|
|
3881
|
-
if ((_this$
|
|
3863
|
+
if ((_this$app7 = this.app) !== null && _this$app7 !== void 0 && _this$app7.request) {
|
|
3882
3864
|
_context46.next = 3;
|
|
3883
3865
|
break;
|
|
3884
3866
|
}
|
|
@@ -3904,7 +3886,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3904
3886
|
});
|
|
3905
3887
|
case 6:
|
|
3906
3888
|
response = _context46.sent;
|
|
3907
|
-
_payload = (_response$
|
|
3889
|
+
_payload = (_response$data3 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data3 !== void 0 ? _response$data3 : response;
|
|
3908
3890
|
return _context46.abrupt("return", {
|
|
3909
3891
|
code: (_response$code2 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code2 !== void 0 ? _response$code2 : 200,
|
|
3910
3892
|
status: (_response$status2 = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status2 !== void 0 ? _response$status2 : true,
|
|
@@ -4458,12 +4440,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
4458
4440
|
key: "fetchOrderListFromAPI",
|
|
4459
4441
|
value: (function () {
|
|
4460
4442
|
var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(data) {
|
|
4461
|
-
var _this$
|
|
4462
|
-
var _response$
|
|
4443
|
+
var _this$app8;
|
|
4444
|
+
var _response$data4, response, _payload2, list, count, errorMessage;
|
|
4463
4445
|
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
4464
4446
|
while (1) switch (_context47.prev = _context47.next) {
|
|
4465
4447
|
case 0:
|
|
4466
|
-
if ((_this$
|
|
4448
|
+
if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
|
|
4467
4449
|
_context47.next = 3;
|
|
4468
4450
|
break;
|
|
4469
4451
|
}
|
|
@@ -4485,7 +4467,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4485
4467
|
});
|
|
4486
4468
|
case 6:
|
|
4487
4469
|
response = _context47.sent;
|
|
4488
|
-
_payload2 = (_response$
|
|
4470
|
+
_payload2 = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
|
|
4489
4471
|
list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
|
|
4490
4472
|
count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
|
|
4491
4473
|
return _context47.abrupt("return", {
|
|
@@ -4660,11 +4642,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4660
4642
|
}, {
|
|
4661
4643
|
key: "buildLocalPaymentOrderLogContext",
|
|
4662
4644
|
value: function buildLocalPaymentOrderLogContext(order) {
|
|
4663
|
-
var _order$order_id2,
|
|
4645
|
+
var _order$order_id2, _external_sale_number3, _order_number, _shop_order_number, _shop_full_order_numb, _status, _payment_status, _platform, _business_code, _order_sales_channel, _sales_channel, _type;
|
|
4664
4646
|
if (!order) return {};
|
|
4665
4647
|
return {
|
|
4666
4648
|
order_id: (_order$order_id2 = order.order_id) !== null && _order$order_id2 !== void 0 ? _order$order_id2 : null,
|
|
4667
|
-
external_sale_number: (
|
|
4649
|
+
external_sale_number: (_external_sale_number3 = order.external_sale_number) !== null && _external_sale_number3 !== void 0 ? _external_sale_number3 : null,
|
|
4668
4650
|
order_number: (_order_number = order.order_number) !== null && _order_number !== void 0 ? _order_number : null,
|
|
4669
4651
|
shop_order_number: (_shop_order_number = order.shop_order_number) !== null && _shop_order_number !== void 0 ? _shop_order_number : null,
|
|
4670
4652
|
shop_full_order_number: (_shop_full_order_numb = order.shop_full_order_number) !== null && _shop_full_order_numb !== void 0 ? _shop_full_order_numb : null,
|
|
@@ -5198,24 +5180,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
5198
5180
|
}, {
|
|
5199
5181
|
key: "getDeviceTaskPlugin",
|
|
5200
5182
|
value: function getDeviceTaskPlugin() {
|
|
5201
|
-
var _this$
|
|
5202
|
-
return ((_this$
|
|
5183
|
+
var _this$app9, _this$app9$getPlugin;
|
|
5184
|
+
return ((_this$app9 = this.app) === null || _this$app9 === void 0 || (_this$app9$getPlugin = _this$app9.getPlugin) === null || _this$app9$getPlugin === void 0 ? void 0 : _this$app9$getPlugin.call(_this$app9, 'deviceTask')) || null;
|
|
5203
5185
|
}
|
|
5204
5186
|
}, {
|
|
5205
5187
|
key: "getIdGeneratorPlugin",
|
|
5206
5188
|
value: function getIdGeneratorPlugin() {
|
|
5207
|
-
var _this$
|
|
5208
|
-
return ((_this$
|
|
5189
|
+
var _this$app10, _this$app10$getPlugin;
|
|
5190
|
+
return ((_this$app10 = this.app) === null || _this$app10 === void 0 || (_this$app10$getPlugin = _this$app10.getPlugin) === null || _this$app10$getPlugin === void 0 ? void 0 : _this$app10$getPlugin.call(_this$app10, 'idGenerator')) || null;
|
|
5209
5191
|
}
|
|
5210
5192
|
}, {
|
|
5211
5193
|
key: "getAppData",
|
|
5212
5194
|
value: function getAppData(key) {
|
|
5213
|
-
var _this$core$getPlugin, _this$core$getPlugin$, _this$
|
|
5195
|
+
var _this$core$getPlugin, _this$core$getPlugin$, _this$app11, _this$app11$getData, _this$app12, _this$app12$getStore, _this$app12$getStore$, _this$app12$getStore$2, _this$app13, _this$app13$getStore, _this$app13$getStore$, _this$app13$getStore$2, _this$app14, _this$app14$getStore, _this$app14$getStore$, _this$app14$getStore$2;
|
|
5214
5196
|
var getData = (_this$core$getPlugin = this.core.getPlugin('app')) === null || _this$core$getPlugin === void 0 || (_this$core$getPlugin$ = _this$core$getPlugin.getData) === null || _this$core$getPlugin$ === void 0 ? void 0 : _this$core$getPlugin$.call(_this$core$getPlugin);
|
|
5215
5197
|
if (typeof getData === 'function') return getData(key);
|
|
5216
|
-
var directValue = (_this$
|
|
5198
|
+
var directValue = (_this$app11 = this.app) === null || _this$app11 === void 0 || (_this$app11$getData = _this$app11.getData) === null || _this$app11$getData === void 0 ? void 0 : _this$app11$getData.call(_this$app11, key);
|
|
5217
5199
|
if (directValue !== undefined) return directValue;
|
|
5218
|
-
var coreData = ((_this$
|
|
5200
|
+
var coreData = ((_this$app12 = this.app) === null || _this$app12 === void 0 || (_this$app12 = _this$app12.models) === null || _this$app12 === void 0 || (_this$app12$getStore = _this$app12.getStore) === null || _this$app12$getStore === void 0 || (_this$app12$getStore$ = (_this$app12$getStore$2 = _this$app12$getStore.call(_this$app12)).getDataByModel) === null || _this$app12$getStore$ === void 0 ? void 0 : _this$app12$getStore$.call(_this$app12$getStore$2, 'core', 'core')) || ((_this$app13 = this.app) === null || _this$app13 === void 0 || (_this$app13 = _this$app13.data) === null || _this$app13 === void 0 || (_this$app13 = _this$app13.store) === null || _this$app13 === void 0 || (_this$app13$getStore = _this$app13.getStore) === null || _this$app13$getStore === void 0 || (_this$app13$getStore$ = (_this$app13$getStore$2 = _this$app13$getStore.call(_this$app13)).getDataByModel) === null || _this$app13$getStore$ === void 0 ? void 0 : _this$app13$getStore$.call(_this$app13$getStore$2, 'core', 'core')) || ((_this$app14 = this.app) === null || _this$app14 === void 0 || (_this$app14 = _this$app14.data) === null || _this$app14 === void 0 || (_this$app14 = _this$app14.store) === null || _this$app14 === void 0 || (_this$app14$getStore = _this$app14.getStore) === null || _this$app14$getStore === void 0 || (_this$app14$getStore$ = (_this$app14$getStore$2 = _this$app14$getStore.call(_this$app14)).getDataByModel) === null || _this$app14$getStore$ === void 0 || (_this$app14$getStore$ = _this$app14$getStore$.call(_this$app14$getStore$2, 'core')) === null || _this$app14$getStore$ === void 0 ? void 0 : _this$app14$getStore$.core);
|
|
5219
5201
|
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
5220
5202
|
}
|
|
5221
5203
|
}, {
|
|
@@ -5315,6 +5297,173 @@ var Server = /*#__PURE__*/function () {
|
|
|
5315
5297
|
value: function isLocalCheckoutOrderId(orderId) {
|
|
5316
5298
|
return typeof orderId === 'string' && orderId.startsWith('LOCAL_');
|
|
5317
5299
|
}
|
|
5300
|
+
}, {
|
|
5301
|
+
key: "normalizePrintInvoiceLayoutConfig",
|
|
5302
|
+
value: function normalizePrintInvoiceLayoutConfig(value) {
|
|
5303
|
+
if (value === undefined || value === null) {
|
|
5304
|
+
return getDefaultInvoiceLayoutConfig();
|
|
5305
|
+
}
|
|
5306
|
+
var parsed = value;
|
|
5307
|
+
if (typeof parsed === 'string') {
|
|
5308
|
+
try {
|
|
5309
|
+
parsed = JSON.parse(parsed);
|
|
5310
|
+
} catch (_unused2) {
|
|
5311
|
+
return getDefaultInvoiceLayoutConfig();
|
|
5312
|
+
}
|
|
5313
|
+
}
|
|
5314
|
+
if (!parsed || _typeof(parsed) !== 'object' || Array.isArray(parsed)) {
|
|
5315
|
+
return getDefaultInvoiceLayoutConfig();
|
|
5316
|
+
}
|
|
5317
|
+
var record = parsed;
|
|
5318
|
+
if (!Array.isArray(record.module)) {
|
|
5319
|
+
return getDefaultInvoiceLayoutConfig();
|
|
5320
|
+
}
|
|
5321
|
+
return _objectSpread(_objectSpread({}, typeof record.locale === 'string' ? {
|
|
5322
|
+
locale: record.locale
|
|
5323
|
+
} : {}), {}, {
|
|
5324
|
+
module: record.module.map(function (moduleConfig) {
|
|
5325
|
+
return moduleConfig && _typeof(moduleConfig) === 'object' && !Array.isArray(moduleConfig) ? _objectSpread({}, moduleConfig) : moduleConfig;
|
|
5326
|
+
})
|
|
5327
|
+
});
|
|
5328
|
+
}
|
|
5329
|
+
}, {
|
|
5330
|
+
key: "extractInvoiceLayoutConfig",
|
|
5331
|
+
value: function extractInvoiceLayoutConfig(data, options) {
|
|
5332
|
+
var _record$invoice;
|
|
5333
|
+
if (!data || _typeof(data) !== 'object' || Array.isArray(data)) {
|
|
5334
|
+
return {
|
|
5335
|
+
data: data
|
|
5336
|
+
};
|
|
5337
|
+
}
|
|
5338
|
+
var record = data;
|
|
5339
|
+
var rawInvoiceLayoutConfig = options !== null && options !== void 0 && options.includePublicInvoice ? (_record$invoice = record.invoice) !== null && _record$invoice !== void 0 ? _record$invoice : record[OS_INVOICE_LAYOUT_CONFIG_FIELD] : record[OS_INVOICE_LAYOUT_CONFIG_FIELD];
|
|
5340
|
+
var next = _objectSpread({}, record);
|
|
5341
|
+
delete next[OS_INVOICE_LAYOUT_CONFIG_FIELD];
|
|
5342
|
+
if (options !== null && options !== void 0 && options.includePublicInvoice) delete next.invoice;
|
|
5343
|
+
return _objectSpread({
|
|
5344
|
+
data: next
|
|
5345
|
+
}, rawInvoiceLayoutConfig !== undefined && rawInvoiceLayoutConfig !== null ? {
|
|
5346
|
+
invoiceLayoutConfig: this.normalizePrintInvoiceLayoutConfig(rawInvoiceLayoutConfig)
|
|
5347
|
+
} : {});
|
|
5348
|
+
}
|
|
5349
|
+
}, {
|
|
5350
|
+
key: "normalizePrintInvoiceTemplateSettings",
|
|
5351
|
+
value: function normalizePrintInvoiceTemplateSettings(value) {
|
|
5352
|
+
if (value === undefined || value === null) {
|
|
5353
|
+
return getDefaultInvoiceTemplateSettings();
|
|
5354
|
+
}
|
|
5355
|
+
return normalizeRawInvoiceTemplateSettings(value);
|
|
5356
|
+
}
|
|
5357
|
+
}, {
|
|
5358
|
+
key: "extractInvoiceTemplateSettings",
|
|
5359
|
+
value: function extractInvoiceTemplateSettings(data, options) {
|
|
5360
|
+
var _record$template_sett;
|
|
5361
|
+
if (!data || _typeof(data) !== 'object' || Array.isArray(data)) {
|
|
5362
|
+
return {
|
|
5363
|
+
data: data
|
|
5364
|
+
};
|
|
5365
|
+
}
|
|
5366
|
+
var record = data;
|
|
5367
|
+
var rawInvoiceTemplateSettings = options !== null && options !== void 0 && options.includePublicTemplateSettings ? (_record$template_sett = record.template_settings) !== null && _record$template_sett !== void 0 ? _record$template_sett : record[OS_INVOICE_TEMPLATE_SETTINGS_FIELD] : record[OS_INVOICE_TEMPLATE_SETTINGS_FIELD];
|
|
5368
|
+
var next = _objectSpread({}, record);
|
|
5369
|
+
delete next[OS_INVOICE_TEMPLATE_SETTINGS_FIELD];
|
|
5370
|
+
if (options !== null && options !== void 0 && options.includePublicTemplateSettings) delete next.template_settings;
|
|
5371
|
+
return _objectSpread({
|
|
5372
|
+
data: next
|
|
5373
|
+
}, rawInvoiceTemplateSettings !== undefined && rawInvoiceTemplateSettings !== null ? {
|
|
5374
|
+
invoiceTemplateSettings: this.normalizePrintInvoiceTemplateSettings(rawInvoiceTemplateSettings)
|
|
5375
|
+
} : {});
|
|
5376
|
+
}
|
|
5377
|
+
}, {
|
|
5378
|
+
key: "applyCheckoutFulfillmentBuzzer",
|
|
5379
|
+
value: function applyCheckoutFulfillmentBuzzer(data, title) {
|
|
5380
|
+
if (!data || _typeof(data) !== 'object') return data;
|
|
5381
|
+
var next = _objectSpread({}, data);
|
|
5382
|
+
var refMode = String(next[OS_FULFILLMENT_REF_MODE_FIELD] || '').trim();
|
|
5383
|
+
delete next[OS_FULFILLMENT_REF_MODE_FIELD];
|
|
5384
|
+
if (!refMode) return next;
|
|
5385
|
+
if (refMode === 'manual_input') {
|
|
5386
|
+
this.logInfo("".concat(title, ": fulfillment ref mode \u4FDD\u7559\u624B\u52A8 buzzer"), {
|
|
5387
|
+
fulfillment_ref_mode: refMode,
|
|
5388
|
+
has_buzzer: !this.isBlankCheckoutValue(next.buzzer)
|
|
5389
|
+
});
|
|
5390
|
+
return next;
|
|
5391
|
+
}
|
|
5392
|
+
if (refMode === 'resource_identifier') {
|
|
5393
|
+
next.buzzer = this.buildCheckoutResourceIdentifierBuzzer(next.bookings);
|
|
5394
|
+
} else if (refMode === 'sale_number') {
|
|
5395
|
+
next.buzzer = this.isBlankCheckoutValue(next.shop_order_number) ? '' : String(next.shop_order_number);
|
|
5396
|
+
} else if (refMode === 'short_number') {
|
|
5397
|
+
next.buzzer = this.isBlankCheckoutValue(next.shop_full_order_number) ? '' : String(next.shop_full_order_number);
|
|
5398
|
+
} else {
|
|
5399
|
+
this.logWarning("".concat(title, ": \u672A\u8BC6\u522B\u7684 fulfillment ref mode\uFF0C\u8DF3\u8FC7 buzzer \u81EA\u52A8\u586B\u5145"), {
|
|
5400
|
+
fulfillment_ref_mode: refMode
|
|
5401
|
+
});
|
|
5402
|
+
return next;
|
|
5403
|
+
}
|
|
5404
|
+
this.logInfo("".concat(title, ": fulfillment ref mode \u5DF2\u586B\u5145 buzzer"), {
|
|
5405
|
+
fulfillment_ref_mode: refMode,
|
|
5406
|
+
buzzer: next.buzzer
|
|
5407
|
+
});
|
|
5408
|
+
return next;
|
|
5409
|
+
}
|
|
5410
|
+
}, {
|
|
5411
|
+
key: "buildCheckoutResourceIdentifierBuzzer",
|
|
5412
|
+
value: function buildCheckoutResourceIdentifierBuzzer(bookings) {
|
|
5413
|
+
var _this13 = this;
|
|
5414
|
+
if (!Array.isArray(bookings)) return '';
|
|
5415
|
+
var values = [];
|
|
5416
|
+
var seen = new Set();
|
|
5417
|
+
var visitResource = function visitResource(resource, fallbackName) {
|
|
5418
|
+
var identifier = _this13.getCheckoutResourceIdentifier(resource, fallbackName);
|
|
5419
|
+
if (identifier && !seen.has(identifier)) {
|
|
5420
|
+
seen.add(identifier);
|
|
5421
|
+
values.push(identifier);
|
|
5422
|
+
}
|
|
5423
|
+
if (Array.isArray(resource === null || resource === void 0 ? void 0 : resource.children)) {
|
|
5424
|
+
resource.children.forEach(function (child) {
|
|
5425
|
+
return visitResource(child);
|
|
5426
|
+
});
|
|
5427
|
+
}
|
|
5428
|
+
};
|
|
5429
|
+
bookings.forEach(function (booking) {
|
|
5430
|
+
if (Array.isArray(booking === null || booking === void 0 ? void 0 : booking.resources)) {
|
|
5431
|
+
booking.resources.forEach(function (resource, index) {
|
|
5432
|
+
visitResource(resource, index === 0 ? booking === null || booking === void 0 ? void 0 : booking.relation_form_name : undefined);
|
|
5433
|
+
});
|
|
5434
|
+
}
|
|
5435
|
+
});
|
|
5436
|
+
return values.join(',');
|
|
5437
|
+
}
|
|
5438
|
+
}, {
|
|
5439
|
+
key: "getCheckoutResourceIdentifier",
|
|
5440
|
+
value: function getCheckoutResourceIdentifier(resource, fallbackName) {
|
|
5441
|
+
var _resource$metadata, _resource$metadata2;
|
|
5442
|
+
if (!resource || _typeof(resource) !== 'object') return '';
|
|
5443
|
+
var candidates = [resource.main_field, resource.name, resource.title, (_resource$metadata = resource.metadata) === null || _resource$metadata === void 0 ? void 0 : _resource$metadata.resource_name, (_resource$metadata2 = resource.metadata) === null || _resource$metadata2 === void 0 ? void 0 : _resource$metadata2.name, fallbackName, resource.relation_id, resource.id];
|
|
5444
|
+
for (var _i2 = 0, _candidates = candidates; _i2 < _candidates.length; _i2++) {
|
|
5445
|
+
var candidate = _candidates[_i2];
|
|
5446
|
+
var value = this.stringifyCheckoutResourceIdentifier(candidate);
|
|
5447
|
+
if (value) return value;
|
|
5448
|
+
}
|
|
5449
|
+
return '';
|
|
5450
|
+
}
|
|
5451
|
+
}, {
|
|
5452
|
+
key: "stringifyCheckoutResourceIdentifier",
|
|
5453
|
+
value: function stringifyCheckoutResourceIdentifier(value) {
|
|
5454
|
+
if (value === undefined || value === null) return '';
|
|
5455
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
5456
|
+
return String(value).trim();
|
|
5457
|
+
}
|
|
5458
|
+
if (_typeof(value) !== 'object' || Array.isArray(value)) return '';
|
|
5459
|
+
var localeCandidates = [value.original, value.auto, value.en, value['zh-CN'], value.zh_CN, value['zh-HK'], value.zh_HK];
|
|
5460
|
+
for (var _i3 = 0, _localeCandidates = localeCandidates; _i3 < _localeCandidates.length; _i3++) {
|
|
5461
|
+
var candidate = _localeCandidates[_i3];
|
|
5462
|
+
var normalized = this.stringifyCheckoutResourceIdentifier(candidate);
|
|
5463
|
+
if (normalized) return normalized;
|
|
5464
|
+
}
|
|
5465
|
+
return '';
|
|
5466
|
+
}
|
|
5318
5467
|
}, {
|
|
5319
5468
|
key: "normalizeCheckoutSubmitData",
|
|
5320
5469
|
value: function () {
|
|
@@ -5536,6 +5685,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
5536
5685
|
payload: {
|
|
5537
5686
|
backendPath: params.backendPath,
|
|
5538
5687
|
data: params.data,
|
|
5688
|
+
invoice: this.normalizePrintInvoiceLayoutConfig(params.invoiceLayoutConfig),
|
|
5689
|
+
template_settings: this.normalizePrintInvoiceTemplateSettings(params.invoiceTemplateSettings),
|
|
5539
5690
|
external_sale_number: (_params$data = params.data) === null || _params$data === void 0 ? void 0 : _params$data.external_sale_number,
|
|
5540
5691
|
title: params.title
|
|
5541
5692
|
},
|
|
@@ -5603,14 +5754,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
5603
5754
|
data: params.receiptOnly ? {
|
|
5604
5755
|
order_id: printIdentity,
|
|
5605
5756
|
small_ticket_data: (_params$syncedOrder = params.syncedOrder) === null || _params$syncedOrder === void 0 || (_params$syncedOrder = _params$syncedOrder.payment_info) === null || _params$syncedOrder === void 0 ? void 0 : _params$syncedOrder.small_ticket_data,
|
|
5757
|
+
invoice: this.normalizePrintInvoiceLayoutConfig(params.invoiceLayoutConfig),
|
|
5758
|
+
template_settings: this.normalizePrintInvoiceTemplateSettings(params.invoiceTemplateSettings),
|
|
5606
5759
|
skip_wristband: true,
|
|
5607
5760
|
skip_voucher: true
|
|
5608
|
-
} : {
|
|
5761
|
+
} : _objectSpread(_objectSpread({
|
|
5609
5762
|
order_id: printIdentity,
|
|
5610
5763
|
machine_code_print_info: (_params$syncedOrder2 = params.syncedOrder) === null || _params$syncedOrder2 === void 0 || (_params$syncedOrder2 = _params$syncedOrder2.payment_info) === null || _params$syncedOrder2 === void 0 ? void 0 : _params$syncedOrder2.machine_code_print_info,
|
|
5611
|
-
machine_code_print_info_v2: (_params$syncedOrder3 = params.syncedOrder) === null || _params$syncedOrder3 === void 0 ? void 0 : _params$syncedOrder3.machine_code_print_info_v2
|
|
5764
|
+
machine_code_print_info_v2: (_params$syncedOrder3 = params.syncedOrder) === null || _params$syncedOrder3 === void 0 ? void 0 : _params$syncedOrder3.machine_code_print_info_v2
|
|
5765
|
+
}, params.invoiceLayoutConfig ? {
|
|
5766
|
+
invoice: this.normalizePrintInvoiceLayoutConfig(params.invoiceLayoutConfig)
|
|
5767
|
+
} : {}), {}, {
|
|
5768
|
+
template_settings: this.normalizePrintInvoiceTemplateSettings(params.invoiceTemplateSettings),
|
|
5612
5769
|
skip_receipt: true
|
|
5613
|
-
}
|
|
5770
|
+
})
|
|
5614
5771
|
},
|
|
5615
5772
|
idempotency_key: this.buildPrintOtherReceiptIdempotencyKey(params.syncedOrder, {
|
|
5616
5773
|
receiptOnly: params.receiptOnly
|
|
@@ -5696,7 +5853,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5696
5853
|
syncedOrder: printableOrder,
|
|
5697
5854
|
response: params.response,
|
|
5698
5855
|
receiptOnly: true,
|
|
5699
|
-
isManualPrint: params.isManualPrint
|
|
5856
|
+
isManualPrint: params.isManualPrint,
|
|
5857
|
+
invoiceLayoutConfig: params.invoiceLayoutConfig,
|
|
5858
|
+
invoiceTemplateSettings: params.invoiceTemplateSettings
|
|
5700
5859
|
});
|
|
5701
5860
|
case 10:
|
|
5702
5861
|
return _context58.abrupt("return", {
|
|
@@ -5733,6 +5892,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
5733
5892
|
}
|
|
5734
5893
|
return undefined;
|
|
5735
5894
|
}
|
|
5895
|
+
}, {
|
|
5896
|
+
key: "mergeLocalPrintOrderInput",
|
|
5897
|
+
value: function mergeLocalPrintOrderInput(localOrder, inputOrder) {
|
|
5898
|
+
var _ref64, _localOrder$order_id, _ref65, _external_sale_number4;
|
|
5899
|
+
var definedInput = Object.fromEntries(Object.entries(inputOrder || {}).filter(function (_ref62) {
|
|
5900
|
+
var _ref63 = _slicedToArray(_ref62, 2),
|
|
5901
|
+
value = _ref63[1];
|
|
5902
|
+
return value !== undefined;
|
|
5903
|
+
}));
|
|
5904
|
+
return _objectSpread(_objectSpread(_objectSpread({}, localOrder), definedInput), {}, {
|
|
5905
|
+
order_id: (_ref64 = (_localOrder$order_id = localOrder.order_id) !== null && _localOrder$order_id !== void 0 ? _localOrder$order_id : definedInput.order_id) !== null && _ref64 !== void 0 ? _ref64 : definedInput.orderId,
|
|
5906
|
+
external_sale_number: (_ref65 = (_external_sale_number4 = localOrder.external_sale_number) !== null && _external_sale_number4 !== void 0 ? _external_sale_number4 : definedInput.external_sale_number) !== null && _ref65 !== void 0 ? _ref65 : definedInput.externalSaleNumber
|
|
5907
|
+
});
|
|
5908
|
+
}
|
|
5736
5909
|
}, {
|
|
5737
5910
|
key: "resolveMachinecodeBatchMetadataLookup",
|
|
5738
5911
|
value: function resolveMachinecodeBatchMetadataLookup(data) {
|
|
@@ -5877,11 +6050,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
5877
6050
|
key: "handleOrderCheckoutSubmit",
|
|
5878
6051
|
value: function () {
|
|
5879
6052
|
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
|
|
5880
|
-
var backendPath, data,
|
|
6053
|
+
var backendPath, title, extractedInvoice, extractedTemplateSettings, data, invoiceLayoutConfig, invoiceTemplateSettings, normalizedData, numberedData, checkoutData, pendingResult, pendingOrder;
|
|
5881
6054
|
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
5882
6055
|
while (1) switch (_context60.prev = _context60.next) {
|
|
5883
6056
|
case 0:
|
|
5884
|
-
backendPath = params.backendPath,
|
|
6057
|
+
backendPath = params.backendPath, title = params.title;
|
|
6058
|
+
extractedInvoice = this.extractInvoiceLayoutConfig(params.data, {
|
|
6059
|
+
includePublicInvoice: true
|
|
6060
|
+
});
|
|
6061
|
+
extractedTemplateSettings = this.extractInvoiceTemplateSettings(extractedInvoice.data, {
|
|
6062
|
+
includePublicTemplateSettings: true
|
|
6063
|
+
});
|
|
6064
|
+
data = extractedTemplateSettings.data;
|
|
6065
|
+
invoiceLayoutConfig = extractedInvoice.invoiceLayoutConfig;
|
|
6066
|
+
invoiceTemplateSettings = this.normalizePrintInvoiceTemplateSettings(extractedTemplateSettings.invoiceTemplateSettings);
|
|
5885
6067
|
this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
|
|
5886
6068
|
backendPath: backendPath,
|
|
5887
6069
|
order_id: data === null || data === void 0 ? void 0 : data.order_id,
|
|
@@ -5889,58 +6071,65 @@ var Server = /*#__PURE__*/function () {
|
|
|
5889
6071
|
order_number: data === null || data === void 0 ? void 0 : data.order_number
|
|
5890
6072
|
});
|
|
5891
6073
|
if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
|
|
5892
|
-
_context60.next =
|
|
6074
|
+
_context60.next = 9;
|
|
5893
6075
|
break;
|
|
5894
6076
|
}
|
|
5895
6077
|
return _context60.abrupt("return", this.handleSyncCheckoutSubmit({
|
|
5896
6078
|
backendPath: backendPath,
|
|
5897
6079
|
data: data,
|
|
5898
|
-
title: title
|
|
6080
|
+
title: title,
|
|
6081
|
+
invoiceLayoutConfig: invoiceLayoutConfig,
|
|
6082
|
+
invoiceTemplateSettings: invoiceTemplateSettings
|
|
5899
6083
|
}));
|
|
5900
|
-
case
|
|
5901
|
-
_context60.next =
|
|
6084
|
+
case 9:
|
|
6085
|
+
_context60.next = 11;
|
|
5902
6086
|
return this.normalizeCheckoutSubmitData(data, title);
|
|
5903
|
-
case
|
|
6087
|
+
case 11:
|
|
5904
6088
|
normalizedData = _context60.sent;
|
|
5905
|
-
_context60.next =
|
|
6089
|
+
_context60.next = 14;
|
|
5906
6090
|
return this.ensureCheckoutOrderNumbers(normalizedData, title);
|
|
5907
|
-
case
|
|
5908
|
-
|
|
5909
|
-
|
|
6091
|
+
case 14:
|
|
6092
|
+
numberedData = _context60.sent;
|
|
6093
|
+
checkoutData = this.applyCheckoutFulfillmentBuzzer(numberedData, title);
|
|
6094
|
+
_context60.next = 18;
|
|
5910
6095
|
return this.handlePendingSyncCheckoutOrder({
|
|
5911
6096
|
backendPath: backendPath,
|
|
5912
6097
|
data: checkoutData,
|
|
5913
6098
|
title: title,
|
|
5914
6099
|
reason: 'checkout 已转入设备任务同步'
|
|
5915
6100
|
});
|
|
5916
|
-
case
|
|
6101
|
+
case 18:
|
|
5917
6102
|
pendingResult = _context60.sent;
|
|
5918
6103
|
if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
|
|
5919
|
-
_context60.next =
|
|
6104
|
+
_context60.next = 26;
|
|
5920
6105
|
break;
|
|
5921
6106
|
}
|
|
5922
6107
|
pendingOrder = pendingResult.data;
|
|
5923
6108
|
if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && this.shouldAutoPrintCheckoutReceipt())) {
|
|
5924
|
-
_context60.next =
|
|
6109
|
+
_context60.next = 24;
|
|
5925
6110
|
break;
|
|
5926
6111
|
}
|
|
5927
|
-
_context60.next =
|
|
6112
|
+
_context60.next = 24;
|
|
5928
6113
|
return this.dispatchLocalReceiptPrint({
|
|
5929
6114
|
checkoutData: checkoutData,
|
|
5930
6115
|
order: pendingOrder,
|
|
5931
6116
|
response: pendingResult,
|
|
5932
|
-
requireFullyPaid: true
|
|
6117
|
+
requireFullyPaid: true,
|
|
6118
|
+
invoiceLayoutConfig: invoiceLayoutConfig,
|
|
6119
|
+
invoiceTemplateSettings: invoiceTemplateSettings
|
|
5933
6120
|
});
|
|
5934
|
-
case
|
|
5935
|
-
_context60.next =
|
|
6121
|
+
case 24:
|
|
6122
|
+
_context60.next = 26;
|
|
5936
6123
|
return this.dispatchCheckoutSyncTask({
|
|
5937
6124
|
backendPath: backendPath,
|
|
5938
6125
|
data: checkoutData,
|
|
5939
|
-
title: title
|
|
6126
|
+
title: title,
|
|
6127
|
+
invoiceLayoutConfig: invoiceLayoutConfig,
|
|
6128
|
+
invoiceTemplateSettings: invoiceTemplateSettings
|
|
5940
6129
|
});
|
|
5941
|
-
case
|
|
6130
|
+
case 26:
|
|
5942
6131
|
if (pendingResult.data.order_id) {
|
|
5943
|
-
_context60.next =
|
|
6132
|
+
_context60.next = 28;
|
|
5944
6133
|
break;
|
|
5945
6134
|
}
|
|
5946
6135
|
return _context60.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
|
|
@@ -5948,9 +6137,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5948
6137
|
order_id: pendingResult.data.external_sale_number
|
|
5949
6138
|
})
|
|
5950
6139
|
}));
|
|
5951
|
-
case
|
|
6140
|
+
case 28:
|
|
5952
6141
|
return _context60.abrupt("return", pendingResult);
|
|
5953
|
-
case
|
|
6142
|
+
case 29:
|
|
5954
6143
|
case "end":
|
|
5955
6144
|
return _context60.stop();
|
|
5956
6145
|
}
|
|
@@ -5965,13 +6154,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
5965
6154
|
key: "handleSyncCheckoutSubmit",
|
|
5966
6155
|
value: function () {
|
|
5967
6156
|
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
|
|
5968
|
-
var _this$
|
|
5969
|
-
var backendPath, data, title, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
|
|
6157
|
+
var _this$app15;
|
|
6158
|
+
var backendPath, data, title, invoiceLayoutConfig, invoiceTemplateSettings, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
|
|
5970
6159
|
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
5971
6160
|
while (1) switch (_context61.prev = _context61.next) {
|
|
5972
6161
|
case 0:
|
|
5973
|
-
backendPath = params.backendPath, data = params.data, title = params.title;
|
|
5974
|
-
if ((_this$
|
|
6162
|
+
backendPath = params.backendPath, data = params.data, title = params.title, invoiceLayoutConfig = params.invoiceLayoutConfig, invoiceTemplateSettings = params.invoiceTemplateSettings;
|
|
6163
|
+
if ((_this$app15 = this.app) !== null && _this$app15 !== void 0 && (_this$app15 = _this$app15.request) !== null && _this$app15 !== void 0 && _this$app15.post) {
|
|
5975
6164
|
_context61.next = 4;
|
|
5976
6165
|
break;
|
|
5977
6166
|
}
|
|
@@ -5989,7 +6178,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5989
6178
|
backendPath: backendPath,
|
|
5990
6179
|
data: data,
|
|
5991
6180
|
title: title,
|
|
5992
|
-
persistCheckoutDataWithResponse: true
|
|
6181
|
+
persistCheckoutDataWithResponse: true,
|
|
6182
|
+
invoiceLayoutConfig: invoiceLayoutConfig,
|
|
6183
|
+
invoiceTemplateSettings: invoiceTemplateSettings
|
|
5993
6184
|
});
|
|
5994
6185
|
case 7:
|
|
5995
6186
|
syncResult = _context61.sent;
|
|
@@ -6015,7 +6206,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6015
6206
|
checkoutData: syncResult.checkoutData,
|
|
6016
6207
|
order: syncedOrder,
|
|
6017
6208
|
response: syncResult.normalizedResponse,
|
|
6018
|
-
requireFullyPaid: true
|
|
6209
|
+
requireFullyPaid: true,
|
|
6210
|
+
invoiceLayoutConfig: invoiceLayoutConfig,
|
|
6211
|
+
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6019
6212
|
// print_all 的 type=0 是收据打印;不要沿用同步成功后的券/手环打印 type=99。
|
|
6020
6213
|
});
|
|
6021
6214
|
case 16:
|
|
@@ -6062,19 +6255,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
6062
6255
|
key: "handleOrderDraftSubmit",
|
|
6063
6256
|
value: function () {
|
|
6064
6257
|
var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
|
|
6065
|
-
var
|
|
6258
|
+
var title, extractedInvoice, _this$extractInvoiceT, data, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
|
|
6066
6259
|
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
6067
6260
|
while (1) switch (_context62.prev = _context62.next) {
|
|
6068
6261
|
case 0:
|
|
6069
|
-
|
|
6262
|
+
title = params.title;
|
|
6263
|
+
extractedInvoice = this.extractInvoiceLayoutConfig(params.data, {
|
|
6264
|
+
includePublicInvoice: true
|
|
6265
|
+
});
|
|
6266
|
+
_this$extractInvoiceT = this.extractInvoiceTemplateSettings(extractedInvoice.data, {
|
|
6267
|
+
includePublicTemplateSettings: true
|
|
6268
|
+
}), data = _this$extractInvoiceT.data;
|
|
6070
6269
|
this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
|
|
6071
6270
|
order_id: data === null || data === void 0 ? void 0 : data.order_id,
|
|
6072
6271
|
external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
|
|
6073
6272
|
order_number: data === null || data === void 0 ? void 0 : data.order_number
|
|
6074
6273
|
});
|
|
6075
|
-
_context62.next =
|
|
6274
|
+
_context62.next = 6;
|
|
6076
6275
|
return this.normalizeCheckoutSubmitData(data, title);
|
|
6077
|
-
case
|
|
6276
|
+
case 6:
|
|
6078
6277
|
normalizedData = _context62.sent;
|
|
6079
6278
|
createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
6080
6279
|
draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
|
|
@@ -6085,7 +6284,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6085
6284
|
is_draft_order: 1
|
|
6086
6285
|
});
|
|
6087
6286
|
if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
|
|
6088
|
-
_context62.next =
|
|
6287
|
+
_context62.next = 12;
|
|
6089
6288
|
break;
|
|
6090
6289
|
}
|
|
6091
6290
|
this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
|
|
@@ -6095,11 +6294,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6095
6294
|
message: 'Order 模块不支持本地草稿写入',
|
|
6096
6295
|
data: null
|
|
6097
6296
|
});
|
|
6098
|
-
case
|
|
6099
|
-
_context62.prev =
|
|
6100
|
-
_context62.next =
|
|
6297
|
+
case 12:
|
|
6298
|
+
_context62.prev = 12;
|
|
6299
|
+
_context62.next = 15;
|
|
6101
6300
|
return this.order.upsertLocalDraftOrders([draftOrder]);
|
|
6102
|
-
case
|
|
6301
|
+
case 15:
|
|
6103
6302
|
this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
|
|
6104
6303
|
order_id: draftOrder.order_id,
|
|
6105
6304
|
external_sale_number: draftOrder.external_sale_number
|
|
@@ -6115,9 +6314,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6115
6314
|
payment_status: draftOrder === null || draftOrder === void 0 ? void 0 : draftOrder.payment_status
|
|
6116
6315
|
})
|
|
6117
6316
|
});
|
|
6118
|
-
case
|
|
6119
|
-
_context62.prev =
|
|
6120
|
-
_context62.t0 = _context62["catch"](
|
|
6317
|
+
case 19:
|
|
6318
|
+
_context62.prev = 19;
|
|
6319
|
+
_context62.t0 = _context62["catch"](12);
|
|
6121
6320
|
errorMessage = _context62.t0 instanceof Error ? _context62.t0.message : String(_context62.t0);
|
|
6122
6321
|
this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
|
|
6123
6322
|
error: errorMessage
|
|
@@ -6128,11 +6327,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6128
6327
|
message: errorMessage,
|
|
6129
6328
|
data: null
|
|
6130
6329
|
});
|
|
6131
|
-
case
|
|
6330
|
+
case 24:
|
|
6132
6331
|
case "end":
|
|
6133
6332
|
return _context62.stop();
|
|
6134
6333
|
}
|
|
6135
|
-
}, _callee62, this, [[
|
|
6334
|
+
}, _callee62, this, [[12, 19]]);
|
|
6136
6335
|
}));
|
|
6137
6336
|
function handleOrderDraftSubmit(_x69) {
|
|
6138
6337
|
return _handleOrderDraftSubmit.apply(this, arguments);
|
|
@@ -6143,7 +6342,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6143
6342
|
key: "handlePendingSyncCheckoutOrder",
|
|
6144
6343
|
value: function () {
|
|
6145
6344
|
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
|
|
6146
|
-
var
|
|
6345
|
+
var _this14 = this;
|
|
6147
6346
|
var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
|
|
6148
6347
|
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
6149
6348
|
while (1) switch (_context63.prev = _context63.next) {
|
|
@@ -6196,7 +6395,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6196
6395
|
});
|
|
6197
6396
|
changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
|
|
6198
6397
|
var _payment$metadata;
|
|
6199
|
-
return sum +
|
|
6398
|
+
return sum + _this14.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
|
|
6200
6399
|
}, 0);
|
|
6201
6400
|
return _context63.abrupt("return", {
|
|
6202
6401
|
code: 200,
|
|
@@ -6289,17 +6488,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
6289
6488
|
}, {
|
|
6290
6489
|
key: "shouldAutoPrintCheckoutReceipt",
|
|
6291
6490
|
value: function shouldAutoPrintCheckoutReceipt() {
|
|
6292
|
-
var _this$core$context2, _this$core$context2$g, _this$
|
|
6491
|
+
var _this$core$context2, _this$core$context2$g, _this$app16, _this$app16$getStorag;
|
|
6293
6492
|
if (((_this$core$context2 = this.core.context) === null || _this$core$context2 === void 0 || (_this$core$context2$g = _this$core$context2.getPlatform) === null || _this$core$context2$g === void 0 ? void 0 : _this$core$context2$g.call(_this$core$context2)) !== 'android') return true;
|
|
6294
|
-
return ((_this$
|
|
6493
|
+
return ((_this$app16 = this.app) === null || _this$app16 === void 0 || (_this$app16 = _this$app16.storage) === null || _this$app16 === void 0 || (_this$app16$getStorag = _this$app16.getStorage) === null || _this$app16$getStorag === void 0 ? void 0 : _this$app16$getStorag.call(_this$app16, AUTO_PRINT_STORAGE_KEY)) !== 'false';
|
|
6295
6494
|
}
|
|
6296
6495
|
}, {
|
|
6297
6496
|
key: "shouldBuildSmallTicketData",
|
|
6298
6497
|
value: function shouldBuildSmallTicketData(order) {
|
|
6299
|
-
var
|
|
6498
|
+
var _ref66, _order$small_ticket_d;
|
|
6300
6499
|
if (!order || _typeof(order) !== 'object') return false;
|
|
6301
6500
|
// if (hasSmallTicketData(order.payment_info?.small_ticket_data)) return false;
|
|
6302
|
-
return Number((
|
|
6501
|
+
return Number((_ref66 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref66 !== void 0 ? _ref66 : 0) === 1;
|
|
6303
6502
|
}
|
|
6304
6503
|
}, {
|
|
6305
6504
|
key: "shouldPrintSyncedOrder",
|
|
@@ -6317,7 +6516,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6317
6516
|
}, {
|
|
6318
6517
|
key: "isSalesOrderFullyPaid",
|
|
6319
6518
|
value: function isSalesOrderFullyPaid(order) {
|
|
6320
|
-
var _order$summary$amount, _order$summary,
|
|
6519
|
+
var _order$summary$amount, _order$summary, _ref67, _ref68, _order$summary$expect, _order$summary2, _order$summary3;
|
|
6321
6520
|
if (!order || _typeof(order) !== 'object') return false;
|
|
6322
6521
|
var paymentStatus = String(order.payment_status || '').toLowerCase();
|
|
6323
6522
|
if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
|
|
@@ -6329,20 +6528,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
6329
6528
|
return this.toAmountNumber(amountGap) <= 0;
|
|
6330
6529
|
}
|
|
6331
6530
|
var paidAmount = this.sumPaidOrderPayments(order.payments);
|
|
6332
|
-
var targetAmount = this.toAmountNumber((
|
|
6531
|
+
var targetAmount = this.toAmountNumber((_ref67 = (_ref68 = (_order$summary$expect = (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.total_amount) !== null && _ref68 !== void 0 ? _ref68 : order.expect_amount) !== null && _ref67 !== void 0 ? _ref67 : order.total_amount);
|
|
6333
6532
|
if (targetAmount <= 0) return paidAmount > 0;
|
|
6334
6533
|
return paidAmount >= targetAmount;
|
|
6335
6534
|
}
|
|
6336
6535
|
}, {
|
|
6337
6536
|
key: "sumPaidOrderPayments",
|
|
6338
6537
|
value: function sumPaidOrderPayments(payments) {
|
|
6339
|
-
var
|
|
6538
|
+
var _this15 = this;
|
|
6340
6539
|
if (!Array.isArray(payments)) return 0;
|
|
6341
6540
|
return payments.reduce(function (sum, payment) {
|
|
6342
6541
|
var _payment$amount;
|
|
6343
6542
|
var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
|
|
6344
6543
|
if (status !== 'paid') return sum;
|
|
6345
|
-
return sum +
|
|
6544
|
+
return sum + _this15.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);
|
|
6346
6545
|
}, 0);
|
|
6347
6546
|
}
|
|
6348
6547
|
}, {
|
|
@@ -6358,7 +6557,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6358
6557
|
value: function () {
|
|
6359
6558
|
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(order) {
|
|
6360
6559
|
var _this$products3,
|
|
6361
|
-
|
|
6560
|
+
_this16 = this;
|
|
6362
6561
|
var products, productIdSet, productIds, entries;
|
|
6363
6562
|
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
6364
6563
|
while (1) switch (_context66.prev = _context66.next) {
|
|
@@ -6373,8 +6572,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
6373
6572
|
}
|
|
6374
6573
|
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
6375
6574
|
product.product_bundle.forEach(function (bundle) {
|
|
6376
|
-
var
|
|
6377
|
-
var bundleProductId = (
|
|
6575
|
+
var _ref69, _bundle$bundle_produc;
|
|
6576
|
+
var bundleProductId = (_ref69 = (_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 && _ref69 !== void 0 ? _ref69 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
|
|
6378
6577
|
if (bundleProductId !== undefined && bundleProductId !== null && bundleProductId !== '') {
|
|
6379
6578
|
productIdSet.add(bundleProductId);
|
|
6380
6579
|
}
|
|
@@ -6390,21 +6589,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
6390
6589
|
case 6:
|
|
6391
6590
|
_context66.next = 8;
|
|
6392
6591
|
return Promise.all(productIds.map( /*#__PURE__*/function () {
|
|
6393
|
-
var
|
|
6394
|
-
var
|
|
6592
|
+
var _ref70 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(id) {
|
|
6593
|
+
var _this16$products, _this16$products$getP, product;
|
|
6395
6594
|
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
6396
6595
|
while (1) switch (_context65.prev = _context65.next) {
|
|
6397
6596
|
case 0:
|
|
6398
6597
|
_context65.prev = 0;
|
|
6399
6598
|
_context65.next = 3;
|
|
6400
|
-
return (
|
|
6599
|
+
return (_this16$products = _this16.products) === null || _this16$products === void 0 || (_this16$products$getP = _this16$products.getProductById) === null || _this16$products$getP === void 0 ? void 0 : _this16$products$getP.call(_this16$products, Number(id));
|
|
6401
6600
|
case 3:
|
|
6402
6601
|
product = _context65.sent;
|
|
6403
6602
|
return _context65.abrupt("return", product ? [String(id), product] : null);
|
|
6404
6603
|
case 7:
|
|
6405
6604
|
_context65.prev = 7;
|
|
6406
6605
|
_context65.t0 = _context65["catch"](0);
|
|
6407
|
-
|
|
6606
|
+
_this16.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
|
|
6408
6607
|
product_id: id,
|
|
6409
6608
|
error: _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0)
|
|
6410
6609
|
});
|
|
@@ -6416,7 +6615,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6416
6615
|
}, _callee65, null, [[0, 7]]);
|
|
6417
6616
|
}));
|
|
6418
6617
|
return function (_x73) {
|
|
6419
|
-
return
|
|
6618
|
+
return _ref70.apply(this, arguments);
|
|
6420
6619
|
};
|
|
6421
6620
|
}()));
|
|
6422
6621
|
case 8:
|
|
@@ -6455,8 +6654,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
6455
6654
|
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);
|
|
6456
6655
|
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
6457
6656
|
product.product_bundle.forEach(function (bundle) {
|
|
6458
|
-
var
|
|
6459
|
-
addProductId((
|
|
6657
|
+
var _ref71, _bundle$bundle_produc2;
|
|
6658
|
+
addProductId((_ref71 = (_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 && _ref71 !== void 0 ? _ref71 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
|
|
6460
6659
|
});
|
|
6461
6660
|
}
|
|
6462
6661
|
});
|
|
@@ -6532,9 +6731,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6532
6731
|
if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
|
|
6533
6732
|
var hasChanged = false;
|
|
6534
6733
|
var productBundle = product.product_bundle.map(function (bundle) {
|
|
6535
|
-
var
|
|
6734
|
+
var _ref72, _bundle$bundle_produc3;
|
|
6536
6735
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
6537
|
-
var rawProductId = (
|
|
6736
|
+
var rawProductId = (_ref72 = (_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 && _ref72 !== void 0 ? _ref72 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
|
|
6538
6737
|
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
|
|
6539
6738
|
var productId = Number(rawProductId);
|
|
6540
6739
|
if (!Number.isFinite(productId)) return bundle;
|
|
@@ -6555,7 +6754,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6555
6754
|
key: "withSalesDetailProductSnapshots",
|
|
6556
6755
|
value: function () {
|
|
6557
6756
|
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(order) {
|
|
6558
|
-
var
|
|
6757
|
+
var _this17 = this;
|
|
6559
6758
|
var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
|
|
6560
6759
|
return _regeneratorRuntime().wrap(function _callee68$(_context68) {
|
|
6561
6760
|
while (1) switch (_context68.prev = _context68.next) {
|
|
@@ -6579,8 +6778,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
6579
6778
|
case 8:
|
|
6580
6779
|
hasChanged = false;
|
|
6581
6780
|
enrichedProducts = products.map(function (product) {
|
|
6582
|
-
var productWithBundleSnapshots =
|
|
6583
|
-
var nextProduct =
|
|
6781
|
+
var productWithBundleSnapshots = _this17.withBundleCatalogSnapshots(product, snapshotMap);
|
|
6782
|
+
var nextProduct = _this17.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
|
|
6584
6783
|
if (nextProduct !== product) hasChanged = true;
|
|
6585
6784
|
return nextProduct;
|
|
6586
6785
|
});
|
|
@@ -6608,13 +6807,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6608
6807
|
}, {
|
|
6609
6808
|
key: "withPendingSyncProductTitles",
|
|
6610
6809
|
value: function withPendingSyncProductTitles(order, productMap) {
|
|
6611
|
-
var
|
|
6810
|
+
var _this18 = this;
|
|
6612
6811
|
var products = Array.isArray(order.products) ? order.products : null;
|
|
6613
6812
|
if (!(products !== null && products !== void 0 && products.length)) return order;
|
|
6614
6813
|
return _objectSpread(_objectSpread({}, order), {}, {
|
|
6615
6814
|
products: products.map(function (product) {
|
|
6616
6815
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
6617
|
-
product_title:
|
|
6816
|
+
product_title: _this18.buildProductTitleSnapshot(product, productMap)
|
|
6618
6817
|
});
|
|
6619
6818
|
})
|
|
6620
6819
|
});
|
|
@@ -6625,7 +6824,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6625
6824
|
var _product$product_id4,
|
|
6626
6825
|
_product$product,
|
|
6627
6826
|
_fallbackProduct$prod,
|
|
6628
|
-
|
|
6827
|
+
_this19 = this;
|
|
6629
6828
|
var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
|
|
6630
6829
|
var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
|
|
6631
6830
|
var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
|
|
@@ -6633,7 +6832,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6633
6832
|
var currentLocale = this.getProductTitleSnapshotCurrentLocale();
|
|
6634
6833
|
var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
|
|
6635
6834
|
return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
|
|
6636
|
-
snapshot[key] =
|
|
6835
|
+
snapshot[key] = _this19.resolveProductTitleValue(ownTitle, key, currentLocale) || _this19.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
|
|
6637
6836
|
return snapshot;
|
|
6638
6837
|
}, {});
|
|
6639
6838
|
}
|
|
@@ -6658,7 +6857,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6658
6857
|
}, {
|
|
6659
6858
|
key: "resolveProductTitleValue",
|
|
6660
6859
|
value: function resolveProductTitleValue(value, key, currentLocale) {
|
|
6661
|
-
var
|
|
6860
|
+
var _ref73, _ref74, _value$key;
|
|
6662
6861
|
if (value === undefined || value === null || value === '') return null;
|
|
6663
6862
|
if (_typeof(value) !== 'object') {
|
|
6664
6863
|
var title = String(value);
|
|
@@ -6668,7 +6867,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6668
6867
|
}
|
|
6669
6868
|
var normalizedKey = key.replace('-', '_');
|
|
6670
6869
|
var dashedKey = key.replace('_', '-');
|
|
6671
|
-
var rawValue = (
|
|
6870
|
+
var rawValue = (_ref73 = (_ref74 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref74 !== void 0 ? _ref74 : value[dashedKey]) !== null && _ref73 !== void 0 ? _ref73 : key === 'auto' ? value.default : undefined;
|
|
6672
6871
|
if (rawValue === undefined || rawValue === null || rawValue === '') return null;
|
|
6673
6872
|
if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
|
|
6674
6873
|
return String(rawValue);
|
|
@@ -6695,8 +6894,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
6695
6894
|
if (value === undefined || value === null || value === '') return null;
|
|
6696
6895
|
if (_typeof(value) !== 'object') return String(value);
|
|
6697
6896
|
var preferredKeys = ['auto', 'en', 'original', 'zh-CN', 'zh_CN', 'zh-HK', 'zh_HK', 'kitchen', 'ja', 'pt', 'default'];
|
|
6698
|
-
for (var
|
|
6699
|
-
var _key6 = _preferredKeys[
|
|
6897
|
+
for (var _i4 = 0, _preferredKeys = preferredKeys; _i4 < _preferredKeys.length; _i4++) {
|
|
6898
|
+
var _key6 = _preferredKeys[_i4];
|
|
6700
6899
|
var rawValue = value[_key6];
|
|
6701
6900
|
if (rawValue !== undefined && rawValue !== null && rawValue !== '') return String(rawValue);
|
|
6702
6901
|
}
|
|
@@ -6732,14 +6931,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
6732
6931
|
key: "enrichPaymentNamesByCode",
|
|
6733
6932
|
value: function () {
|
|
6734
6933
|
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(order) {
|
|
6735
|
-
var
|
|
6934
|
+
var _this20 = this;
|
|
6736
6935
|
var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
|
|
6737
6936
|
return _regeneratorRuntime().wrap(function _callee69$(_context69) {
|
|
6738
6937
|
while (1) switch (_context69.prev = _context69.next) {
|
|
6739
6938
|
case 0:
|
|
6740
6939
|
payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
|
|
6741
6940
|
hasMissingName = payments.some(function (payment) {
|
|
6742
|
-
return
|
|
6941
|
+
return _this20.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this20.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
|
|
6743
6942
|
});
|
|
6744
6943
|
if (hasMissingName) {
|
|
6745
6944
|
_context69.next = 4;
|
|
@@ -6772,9 +6971,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6772
6971
|
}
|
|
6773
6972
|
hasResolvedName = false;
|
|
6774
6973
|
enrichedPayments = payments.map(function (payment) {
|
|
6775
|
-
if (!
|
|
6776
|
-
if (!
|
|
6777
|
-
var name = nameByCode.get(
|
|
6974
|
+
if (!_this20.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
|
|
6975
|
+
if (!_this20.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
|
|
6976
|
+
var name = nameByCode.get(_this20.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
|
|
6778
6977
|
if (!name) return payment;
|
|
6779
6978
|
hasResolvedName = true;
|
|
6780
6979
|
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
@@ -6875,6 +7074,175 @@ var Server = /*#__PURE__*/function () {
|
|
|
6875
7074
|
}
|
|
6876
7075
|
return withLocalSmallTicketData;
|
|
6877
7076
|
}()
|
|
7077
|
+
}, {
|
|
7078
|
+
key: "normalizeRemoteSalesOrderErrorCode",
|
|
7079
|
+
value: function normalizeRemoteSalesOrderErrorCode(value) {
|
|
7080
|
+
if (value === undefined || value === null || value === '') return 500;
|
|
7081
|
+
var code = typeof value === 'number' ? value : Number(value);
|
|
7082
|
+
return Number.isFinite(code) ? code : 500;
|
|
7083
|
+
}
|
|
7084
|
+
}, {
|
|
7085
|
+
key: "fetchAndPersistSalesOrderByLookup",
|
|
7086
|
+
value: function () {
|
|
7087
|
+
var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(lookup, data, title) {
|
|
7088
|
+
var _this$order4, _this$order5, _this$app17;
|
|
7089
|
+
var backendPath, response, _response$code3, responseStatusCode, code, message, fresh, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode, _ref75, _backendError$code2, backendStatusCode, _code, _message2, _message3;
|
|
7090
|
+
return _regeneratorRuntime().wrap(function _callee71$(_context71) {
|
|
7091
|
+
while (1) switch (_context71.prev = _context71.next) {
|
|
7092
|
+
case 0:
|
|
7093
|
+
if (!(!((_this$order4 = this.order) !== null && _this$order4 !== void 0 && _this$order4.getLocalOrderByLookup) || !((_this$order5 = this.order) !== null && _this$order5 !== void 0 && _this$order5.upsertOrdersFromRemote))) {
|
|
7094
|
+
_context71.next = 3;
|
|
7095
|
+
break;
|
|
7096
|
+
}
|
|
7097
|
+
this.logError("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C"));
|
|
7098
|
+
return _context71.abrupt("return", {
|
|
7099
|
+
code: 500,
|
|
7100
|
+
message: 'Order 模块未注册',
|
|
7101
|
+
order: null
|
|
7102
|
+
});
|
|
7103
|
+
case 3:
|
|
7104
|
+
if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && (_this$app17 = _this$app17.request) !== null && _this$app17 !== void 0 && _this$app17.get) {
|
|
7105
|
+
_context71.next = 6;
|
|
7106
|
+
break;
|
|
7107
|
+
}
|
|
7108
|
+
this.logError("".concat(title, ": app.request \u4E0D\u53EF\u7528"));
|
|
7109
|
+
return _context71.abrupt("return", {
|
|
7110
|
+
code: 500,
|
|
7111
|
+
message: 'app.request 不可用',
|
|
7112
|
+
order: null
|
|
7113
|
+
});
|
|
7114
|
+
case 6:
|
|
7115
|
+
backendPath = this.buildOrderSalesDetailBackendPath(String(lookup), data);
|
|
7116
|
+
_context71.prev = 7;
|
|
7117
|
+
_context71.next = 10;
|
|
7118
|
+
return this.app.request.get(backendPath, {
|
|
7119
|
+
lookup_mode: 'multi'
|
|
7120
|
+
}, {
|
|
7121
|
+
isShopApi: true,
|
|
7122
|
+
customToast: function customToast() {}
|
|
7123
|
+
});
|
|
7124
|
+
case 10:
|
|
7125
|
+
response = _context71.sent;
|
|
7126
|
+
if (!this.isCheckoutResponseRejected(response)) {
|
|
7127
|
+
_context71.next = 17;
|
|
7128
|
+
break;
|
|
7129
|
+
}
|
|
7130
|
+
responseStatusCode = typeof (response === null || response === void 0 ? void 0 : response.status) === 'number' ? response.status : undefined;
|
|
7131
|
+
code = this.normalizeRemoteSalesOrderErrorCode((_response$code3 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code3 !== void 0 ? _response$code3 : responseStatusCode);
|
|
7132
|
+
message = (response === null || response === void 0 ? void 0 : response.message) || '后端拒绝订单查询';
|
|
7133
|
+
this.logInfo("".concat(title, ": \u540E\u7AEF\u62D2\u7EDD\u8BA2\u5355\u67E5\u8BE2"), {
|
|
7134
|
+
lookup: lookup,
|
|
7135
|
+
backendPath: backendPath,
|
|
7136
|
+
code: code,
|
|
7137
|
+
message: message
|
|
7138
|
+
});
|
|
7139
|
+
return _context71.abrupt("return", {
|
|
7140
|
+
code: code,
|
|
7141
|
+
message: message,
|
|
7142
|
+
order: null
|
|
7143
|
+
});
|
|
7144
|
+
case 17:
|
|
7145
|
+
fresh = this.extractOrderDataFromCheckoutResponse(response);
|
|
7146
|
+
if (!(!fresh || fresh.order_id === undefined || fresh.order_id === null || String(fresh.order_id).trim() === '')) {
|
|
7147
|
+
_context71.next = 21;
|
|
7148
|
+
break;
|
|
7149
|
+
}
|
|
7150
|
+
this.logInfo("".concat(title, ": \u540E\u7AEF\u8FD4\u56DE\u8BA2\u5355\u4E3A\u7A7A"), {
|
|
7151
|
+
lookup: lookup,
|
|
7152
|
+
backendPath: backendPath
|
|
7153
|
+
});
|
|
7154
|
+
return _context71.abrupt("return", {
|
|
7155
|
+
code: 500,
|
|
7156
|
+
message: '后端返回订单为空',
|
|
7157
|
+
order: null
|
|
7158
|
+
});
|
|
7159
|
+
case 21:
|
|
7160
|
+
_context71.next = 23;
|
|
7161
|
+
return this.order.upsertOrdersFromRemote([fresh]);
|
|
7162
|
+
case 23:
|
|
7163
|
+
_context71.next = 25;
|
|
7164
|
+
return this.order.getLocalOrderByLookup(lookup);
|
|
7165
|
+
case 25:
|
|
7166
|
+
savedOrder = _context71.sent;
|
|
7167
|
+
if (!(!savedOrder && fresh.order_id !== undefined && fresh.order_id !== null && String(fresh.order_id) !== String(lookup))) {
|
|
7168
|
+
_context71.next = 30;
|
|
7169
|
+
break;
|
|
7170
|
+
}
|
|
7171
|
+
_context71.next = 29;
|
|
7172
|
+
return this.order.getLocalOrderByLookup(fresh.order_id);
|
|
7173
|
+
case 29:
|
|
7174
|
+
savedOrder = _context71.sent;
|
|
7175
|
+
case 30:
|
|
7176
|
+
if (savedOrder) {
|
|
7177
|
+
_context71.next = 33;
|
|
7178
|
+
break;
|
|
7179
|
+
}
|
|
7180
|
+
this.logError("".concat(title, ": \u8BA2\u5355\u5199\u5165\u540E\u56DE\u8BFB\u5931\u8D25"), {
|
|
7181
|
+
lookup: lookup,
|
|
7182
|
+
remote_order_id: fresh.order_id
|
|
7183
|
+
});
|
|
7184
|
+
return _context71.abrupt("return", {
|
|
7185
|
+
code: 500,
|
|
7186
|
+
message: '订单写入后回读失败',
|
|
7187
|
+
order: null
|
|
7188
|
+
});
|
|
7189
|
+
case 33:
|
|
7190
|
+
this.logInfo("".concat(title, ": \u8FDC\u7AEF\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u672C\u5730"), {
|
|
7191
|
+
lookup: lookup,
|
|
7192
|
+
remote_order_id: fresh.order_id
|
|
7193
|
+
});
|
|
7194
|
+
return _context71.abrupt("return", {
|
|
7195
|
+
code: 200,
|
|
7196
|
+
message: '',
|
|
7197
|
+
order: savedOrder
|
|
7198
|
+
});
|
|
7199
|
+
case 37:
|
|
7200
|
+
_context71.prev = 37;
|
|
7201
|
+
_context71.t0 = _context71["catch"](7);
|
|
7202
|
+
backendError = this.extractBackendErrorResponse(_context71.t0);
|
|
7203
|
+
errorRecord = _context71.t0;
|
|
7204
|
+
_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;
|
|
7205
|
+
if (!(backendError || _responseStatusCode !== undefined)) {
|
|
7206
|
+
_context71.next = 48;
|
|
7207
|
+
break;
|
|
7208
|
+
}
|
|
7209
|
+
backendStatusCode = typeof (backendError === null || backendError === void 0 ? void 0 : backendError.status) === 'number' ? backendError.status : undefined;
|
|
7210
|
+
_code = this.normalizeRemoteSalesOrderErrorCode((_ref75 = (_backendError$code2 = backendError === null || backendError === void 0 ? void 0 : backendError.code) !== null && _backendError$code2 !== void 0 ? _backendError$code2 : backendStatusCode) !== null && _ref75 !== void 0 ? _ref75 : _responseStatusCode);
|
|
7211
|
+
_message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context71.t0);
|
|
7212
|
+
this.logInfo("".concat(title, ": \u540E\u7AEF\u8BA2\u5355\u67E5\u8BE2\u5931\u8D25"), {
|
|
7213
|
+
lookup: lookup,
|
|
7214
|
+
backendPath: backendPath,
|
|
7215
|
+
code: _code,
|
|
7216
|
+
message: _message2
|
|
7217
|
+
});
|
|
7218
|
+
return _context71.abrupt("return", {
|
|
7219
|
+
code: _code,
|
|
7220
|
+
message: _message2,
|
|
7221
|
+
order: null
|
|
7222
|
+
});
|
|
7223
|
+
case 48:
|
|
7224
|
+
_message3 = this.getUnknownErrorMessage(_context71.t0);
|
|
7225
|
+
this.logInfo("".concat(title, ": \u8BF7\u6C42\u5931\u8D25"), {
|
|
7226
|
+
lookup: lookup,
|
|
7227
|
+
backendPath: backendPath,
|
|
7228
|
+
error: _message3
|
|
7229
|
+
});
|
|
7230
|
+
return _context71.abrupt("return", {
|
|
7231
|
+
code: 500,
|
|
7232
|
+
message: _message3,
|
|
7233
|
+
order: null
|
|
7234
|
+
});
|
|
7235
|
+
case 51:
|
|
7236
|
+
case "end":
|
|
7237
|
+
return _context71.stop();
|
|
7238
|
+
}
|
|
7239
|
+
}, _callee71, this, [[7, 37]]);
|
|
7240
|
+
}));
|
|
7241
|
+
function fetchAndPersistSalesOrderByLookup(_x79, _x80, _x81) {
|
|
7242
|
+
return _fetchAndPersistSalesOrderByLookup.apply(this, arguments);
|
|
7243
|
+
}
|
|
7244
|
+
return fetchAndPersistSalesOrderByLookup;
|
|
7245
|
+
}()
|
|
6878
7246
|
}, {
|
|
6879
7247
|
key: "parseOrderIdsParam",
|
|
6880
7248
|
value:
|
|
@@ -6912,8 +7280,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
6912
7280
|
pushRaw(this.extractQueryParam(url, 'order_ids'));
|
|
6913
7281
|
var seen = new Set();
|
|
6914
7282
|
var result = [];
|
|
6915
|
-
for (var
|
|
6916
|
-
var id = _collected[
|
|
7283
|
+
for (var _i5 = 0, _collected = collected; _i5 < _collected.length; _i5++) {
|
|
7284
|
+
var id = _collected[_i5];
|
|
6917
7285
|
if (seen.has(id)) continue;
|
|
6918
7286
|
seen.add(id);
|
|
6919
7287
|
result.push(id);
|
|
@@ -6932,22 +7300,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
6932
7300
|
}, {
|
|
6933
7301
|
key: "handleUpdateLocalOrdersBatch",
|
|
6934
7302
|
value: (function () {
|
|
6935
|
-
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7303
|
+
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(orderIds) {
|
|
6936
7304
|
var _this$app18;
|
|
6937
|
-
var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh,
|
|
6938
|
-
return _regeneratorRuntime().wrap(function
|
|
6939
|
-
while (1) switch (
|
|
7305
|
+
var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message4, overwritten, inserted;
|
|
7306
|
+
return _regeneratorRuntime().wrap(function _callee72$(_context72) {
|
|
7307
|
+
while (1) switch (_context72.prev = _context72.next) {
|
|
6940
7308
|
case 0:
|
|
6941
7309
|
this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
|
|
6942
7310
|
count: orderIds.length,
|
|
6943
7311
|
orderIds: orderIds
|
|
6944
7312
|
});
|
|
6945
7313
|
if (this.order) {
|
|
6946
|
-
|
|
7314
|
+
_context72.next = 4;
|
|
6947
7315
|
break;
|
|
6948
7316
|
}
|
|
6949
7317
|
this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
|
|
6950
|
-
return
|
|
7318
|
+
return _context72.abrupt("return", {
|
|
6951
7319
|
code: 500,
|
|
6952
7320
|
status: false,
|
|
6953
7321
|
message: 'Order 模块未注册',
|
|
@@ -6955,11 +7323,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6955
7323
|
});
|
|
6956
7324
|
case 4:
|
|
6957
7325
|
if ((_this$app18 = this.app) !== null && _this$app18 !== void 0 && _this$app18.request) {
|
|
6958
|
-
|
|
7326
|
+
_context72.next = 7;
|
|
6959
7327
|
break;
|
|
6960
7328
|
}
|
|
6961
7329
|
this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
|
|
6962
|
-
return
|
|
7330
|
+
return _context72.abrupt("return", {
|
|
6963
7331
|
code: 500,
|
|
6964
7332
|
status: false,
|
|
6965
7333
|
message: 'app.request 不可用',
|
|
@@ -6982,21 +7350,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
6982
7350
|
_iterator13.f();
|
|
6983
7351
|
}
|
|
6984
7352
|
fetched = [];
|
|
6985
|
-
|
|
6986
|
-
|
|
7353
|
+
_context72.prev = 11;
|
|
7354
|
+
_context72.next = 14;
|
|
6987
7355
|
return this.order.fetchOrdersByHttp(orderIds);
|
|
6988
7356
|
case 14:
|
|
6989
|
-
fetched =
|
|
6990
|
-
|
|
7357
|
+
fetched = _context72.sent;
|
|
7358
|
+
_context72.next = 22;
|
|
6991
7359
|
break;
|
|
6992
7360
|
case 17:
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
message =
|
|
7361
|
+
_context72.prev = 17;
|
|
7362
|
+
_context72.t0 = _context72["catch"](11);
|
|
7363
|
+
message = _context72.t0 instanceof Error ? _context72.t0.message : String(_context72.t0);
|
|
6996
7364
|
this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
|
|
6997
7365
|
message: message
|
|
6998
7366
|
});
|
|
6999
|
-
return
|
|
7367
|
+
return _context72.abrupt("return", {
|
|
7000
7368
|
code: 500,
|
|
7001
7369
|
status: false,
|
|
7002
7370
|
message: message,
|
|
@@ -7006,36 +7374,36 @@ var Server = /*#__PURE__*/function () {
|
|
|
7006
7374
|
// 按返回结果中的 order_id 建索引,未命中即视为单笔失败
|
|
7007
7375
|
fetchedMap = new Map();
|
|
7008
7376
|
_iterator14 = _createForOfIteratorHelper(fetched);
|
|
7009
|
-
|
|
7377
|
+
_context72.prev = 24;
|
|
7010
7378
|
_iterator14.s();
|
|
7011
7379
|
case 26:
|
|
7012
7380
|
if ((_step14 = _iterator14.n()).done) {
|
|
7013
|
-
|
|
7381
|
+
_context72.next = 34;
|
|
7014
7382
|
break;
|
|
7015
7383
|
}
|
|
7016
7384
|
order = _step14.value;
|
|
7017
7385
|
oid = order === null || order === void 0 ? void 0 : order.order_id;
|
|
7018
7386
|
if (!(oid === undefined || oid === null)) {
|
|
7019
|
-
|
|
7387
|
+
_context72.next = 31;
|
|
7020
7388
|
break;
|
|
7021
7389
|
}
|
|
7022
|
-
return
|
|
7390
|
+
return _context72.abrupt("continue", 32);
|
|
7023
7391
|
case 31:
|
|
7024
7392
|
fetchedMap.set(String(oid), order);
|
|
7025
7393
|
case 32:
|
|
7026
|
-
|
|
7394
|
+
_context72.next = 26;
|
|
7027
7395
|
break;
|
|
7028
7396
|
case 34:
|
|
7029
|
-
|
|
7397
|
+
_context72.next = 39;
|
|
7030
7398
|
break;
|
|
7031
7399
|
case 36:
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
_iterator14.e(
|
|
7400
|
+
_context72.prev = 36;
|
|
7401
|
+
_context72.t1 = _context72["catch"](24);
|
|
7402
|
+
_iterator14.e(_context72.t1);
|
|
7035
7403
|
case 39:
|
|
7036
|
-
|
|
7404
|
+
_context72.prev = 39;
|
|
7037
7405
|
_iterator14.f();
|
|
7038
|
-
return
|
|
7406
|
+
return _context72.finish(39);
|
|
7039
7407
|
case 42:
|
|
7040
7408
|
freshOrders = [];
|
|
7041
7409
|
succeedIds = [];
|
|
@@ -7061,26 +7429,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
7061
7429
|
_iterator15.f();
|
|
7062
7430
|
}
|
|
7063
7431
|
if (!(freshOrders.length > 0)) {
|
|
7064
|
-
|
|
7432
|
+
_context72.next = 58;
|
|
7065
7433
|
break;
|
|
7066
7434
|
}
|
|
7067
|
-
|
|
7068
|
-
|
|
7435
|
+
_context72.prev = 48;
|
|
7436
|
+
_context72.next = 51;
|
|
7069
7437
|
return this.order.upsertOrdersFromRemote(freshOrders);
|
|
7070
7438
|
case 51:
|
|
7071
|
-
|
|
7439
|
+
_context72.next = 58;
|
|
7072
7440
|
break;
|
|
7073
7441
|
case 53:
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7442
|
+
_context72.prev = 53;
|
|
7443
|
+
_context72.t2 = _context72["catch"](48);
|
|
7444
|
+
_message4 = _context72.t2 instanceof Error ? _context72.t2.message : String(_context72.t2);
|
|
7077
7445
|
this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
|
|
7078
|
-
message:
|
|
7446
|
+
message: _message4
|
|
7079
7447
|
});
|
|
7080
|
-
return
|
|
7448
|
+
return _context72.abrupt("return", {
|
|
7081
7449
|
code: 500,
|
|
7082
7450
|
status: false,
|
|
7083
|
-
message:
|
|
7451
|
+
message: _message4,
|
|
7084
7452
|
data: null
|
|
7085
7453
|
});
|
|
7086
7454
|
case 58:
|
|
@@ -7096,7 +7464,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7096
7464
|
insertedCount: inserted.length,
|
|
7097
7465
|
failedCount: failed.length
|
|
7098
7466
|
});
|
|
7099
|
-
return
|
|
7467
|
+
return _context72.abrupt("return", {
|
|
7100
7468
|
code: 200,
|
|
7101
7469
|
status: true,
|
|
7102
7470
|
message: '',
|
|
@@ -7108,11 +7476,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
7108
7476
|
});
|
|
7109
7477
|
case 62:
|
|
7110
7478
|
case "end":
|
|
7111
|
-
return
|
|
7479
|
+
return _context72.stop();
|
|
7112
7480
|
}
|
|
7113
|
-
},
|
|
7481
|
+
}, _callee72, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
|
|
7114
7482
|
}));
|
|
7115
|
-
function handleUpdateLocalOrdersBatch(
|
|
7483
|
+
function handleUpdateLocalOrdersBatch(_x82) {
|
|
7116
7484
|
return _handleUpdateLocalOrdersBatch.apply(this, arguments);
|
|
7117
7485
|
}
|
|
7118
7486
|
return handleUpdateLocalOrdersBatch;
|
|
@@ -7129,7 +7497,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7129
7497
|
var target = url.startsWith('http') ? new URL(url) : new URL(url, 'http://placeholder.local');
|
|
7130
7498
|
var value = target.searchParams.get(key);
|
|
7131
7499
|
return value !== null && value !== void 0 ? value : null;
|
|
7132
|
-
} catch (
|
|
7500
|
+
} catch (_unused3) {
|
|
7133
7501
|
var queryIndex = url.indexOf('?');
|
|
7134
7502
|
if (queryIndex < 0) return null;
|
|
7135
7503
|
var query = url.slice(queryIndex + 1);
|
|
@@ -7148,7 +7516,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7148
7516
|
if (decodeURIComponent(rawKey) === key) {
|
|
7149
7517
|
return decodeURIComponent(rawValue);
|
|
7150
7518
|
}
|
|
7151
|
-
} catch (
|
|
7519
|
+
} catch (_unused4) {
|
|
7152
7520
|
if (rawKey === key) return rawValue;
|
|
7153
7521
|
}
|
|
7154
7522
|
}
|
|
@@ -7189,10 +7557,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
7189
7557
|
}, {
|
|
7190
7558
|
key: "extractOrderDataFromCheckoutResponse",
|
|
7191
7559
|
value: function extractOrderDataFromCheckoutResponse(response) {
|
|
7192
|
-
var _response$
|
|
7193
|
-
var candidates = [response === null || response === void 0 || (_response$
|
|
7194
|
-
for (var
|
|
7195
|
-
var candidate =
|
|
7560
|
+
var _response$data5, _response$data6;
|
|
7561
|
+
var candidates = [response === null || response === void 0 || (_response$data5 = response.data) === null || _response$data5 === void 0 ? void 0 : _response$data5.order, response === null || response === void 0 || (_response$data6 = response.data) === null || _response$data6 === void 0 ? void 0 : _response$data6.sales, response === null || response === void 0 ? void 0 : response.data, response === null || response === void 0 ? void 0 : response.order, response === null || response === void 0 ? void 0 : response.sales, response];
|
|
7562
|
+
for (var _i6 = 0, _candidates2 = candidates; _i6 < _candidates2.length; _i6++) {
|
|
7563
|
+
var candidate = _candidates2[_i6];
|
|
7196
7564
|
if (!candidate || _typeof(candidate) !== 'object') continue;
|
|
7197
7565
|
if (candidate.order_id !== undefined && candidate.order_id !== null) {
|
|
7198
7566
|
return candidate;
|
|
@@ -7312,7 +7680,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7312
7680
|
if (typeof normalized === 'string') return normalized;
|
|
7313
7681
|
try {
|
|
7314
7682
|
return JSON.stringify(normalized);
|
|
7315
|
-
} catch (
|
|
7683
|
+
} catch (_unused5) {
|
|
7316
7684
|
return String(error);
|
|
7317
7685
|
}
|
|
7318
7686
|
}
|
|
@@ -7347,7 +7715,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7347
7715
|
seen.add(current);
|
|
7348
7716
|
return current;
|
|
7349
7717
|
}));
|
|
7350
|
-
} catch (
|
|
7718
|
+
} catch (_unused6) {
|
|
7351
7719
|
return String(value);
|
|
7352
7720
|
}
|
|
7353
7721
|
}
|
|
@@ -7356,10 +7724,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
7356
7724
|
value: function extractBackendErrorResponse(error) {
|
|
7357
7725
|
var _error$response3,
|
|
7358
7726
|
_error$response4,
|
|
7359
|
-
|
|
7727
|
+
_this21 = this;
|
|
7360
7728
|
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];
|
|
7361
7729
|
return candidates.find(function (candidate) {
|
|
7362
|
-
return
|
|
7730
|
+
return _this21.isExplicitBackendErrorResponse(candidate);
|
|
7363
7731
|
}) || null;
|
|
7364
7732
|
}
|
|
7365
7733
|
}, {
|
|
@@ -7380,7 +7748,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7380
7748
|
try {
|
|
7381
7749
|
var pathname = url.startsWith('http') ? new URL(url).pathname : noQuery;
|
|
7382
7750
|
return pathname.replace(/\/$/, '') || pathname;
|
|
7383
|
-
} catch (
|
|
7751
|
+
} catch (_unused7) {
|
|
7384
7752
|
return noQuery.replace(/\/$/, '');
|
|
7385
7753
|
}
|
|
7386
7754
|
}
|
|
@@ -7478,16 +7846,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
7478
7846
|
}, {
|
|
7479
7847
|
key: "recomputeAndNotifyFloorPlanQuery",
|
|
7480
7848
|
value: (function () {
|
|
7481
|
-
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7849
|
+
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73() {
|
|
7482
7850
|
var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
|
|
7483
|
-
return _regeneratorRuntime().wrap(function
|
|
7484
|
-
while (1) switch (
|
|
7851
|
+
return _regeneratorRuntime().wrap(function _callee73$(_context73) {
|
|
7852
|
+
while (1) switch (_context73.prev = _context73.next) {
|
|
7485
7853
|
case 0:
|
|
7486
7854
|
if (!(this.floorPlanQuerySubscribers.size === 0)) {
|
|
7487
|
-
|
|
7855
|
+
_context73.next = 2;
|
|
7488
7856
|
break;
|
|
7489
7857
|
}
|
|
7490
|
-
return
|
|
7858
|
+
return _context73.abrupt("return");
|
|
7491
7859
|
case 2:
|
|
7492
7860
|
this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
|
|
7493
7861
|
subscriberCount: this.floorPlanQuerySubscribers.size
|
|
@@ -7517,9 +7885,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7517
7885
|
}
|
|
7518
7886
|
case 5:
|
|
7519
7887
|
case "end":
|
|
7520
|
-
return
|
|
7888
|
+
return _context73.stop();
|
|
7521
7889
|
}
|
|
7522
|
-
},
|
|
7890
|
+
}, _callee73, this);
|
|
7523
7891
|
}));
|
|
7524
7892
|
function recomputeAndNotifyFloorPlanQuery() {
|
|
7525
7893
|
return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
|
|
@@ -7549,20 +7917,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
7549
7917
|
* filter 逻辑暂为 mock,仅记录参数
|
|
7550
7918
|
*/
|
|
7551
7919
|
function () {
|
|
7552
|
-
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7920
|
+
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(data) {
|
|
7553
7921
|
var rawList, result;
|
|
7554
|
-
return _regeneratorRuntime().wrap(function
|
|
7555
|
-
while (1) switch (
|
|
7922
|
+
return _regeneratorRuntime().wrap(function _callee74$(_context74) {
|
|
7923
|
+
while (1) switch (_context74.prev = _context74.next) {
|
|
7556
7924
|
case 0:
|
|
7557
7925
|
this.logInfo('computeOrderQueryResult: 开始过滤', {
|
|
7558
7926
|
data: data
|
|
7559
7927
|
});
|
|
7560
7928
|
if (this.order) {
|
|
7561
|
-
|
|
7929
|
+
_context74.next = 4;
|
|
7562
7930
|
break;
|
|
7563
7931
|
}
|
|
7564
7932
|
this.logError('computeOrderQueryResult: Order 模块未注册');
|
|
7565
|
-
return
|
|
7933
|
+
return _context74.abrupt("return", {
|
|
7566
7934
|
code: 500,
|
|
7567
7935
|
message: 'Order 模块未注册',
|
|
7568
7936
|
data: {
|
|
@@ -7592,7 +7960,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7592
7960
|
skip: result.skip,
|
|
7593
7961
|
rejected: result.rejected
|
|
7594
7962
|
});
|
|
7595
|
-
return
|
|
7963
|
+
return _context74.abrupt("return", {
|
|
7596
7964
|
code: 200,
|
|
7597
7965
|
data: result,
|
|
7598
7966
|
message: '',
|
|
@@ -7600,11 +7968,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
7600
7968
|
});
|
|
7601
7969
|
case 10:
|
|
7602
7970
|
case "end":
|
|
7603
|
-
return
|
|
7971
|
+
return _context74.stop();
|
|
7604
7972
|
}
|
|
7605
|
-
},
|
|
7973
|
+
}, _callee74, this);
|
|
7606
7974
|
}));
|
|
7607
|
-
function computeOrderQueryResult(
|
|
7975
|
+
function computeOrderQueryResult(_x83) {
|
|
7608
7976
|
return _computeOrderQueryResult.apply(this, arguments);
|
|
7609
7977
|
}
|
|
7610
7978
|
return computeOrderQueryResult;
|
|
@@ -7617,17 +7985,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
7617
7985
|
}, {
|
|
7618
7986
|
key: "computeBookingQueryResult",
|
|
7619
7987
|
value: (function () {
|
|
7620
|
-
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7988
|
+
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(data) {
|
|
7621
7989
|
var rawOrders, result;
|
|
7622
|
-
return _regeneratorRuntime().wrap(function
|
|
7623
|
-
while (1) switch (
|
|
7990
|
+
return _regeneratorRuntime().wrap(function _callee75$(_context75) {
|
|
7991
|
+
while (1) switch (_context75.prev = _context75.next) {
|
|
7624
7992
|
case 0:
|
|
7625
7993
|
if (this.order) {
|
|
7626
|
-
|
|
7994
|
+
_context75.next = 3;
|
|
7627
7995
|
break;
|
|
7628
7996
|
}
|
|
7629
7997
|
this.logError('computeBookingQueryResult: Order 模块未注册');
|
|
7630
|
-
return
|
|
7998
|
+
return _context75.abrupt("return", {
|
|
7631
7999
|
code: 500,
|
|
7632
8000
|
message: 'Order 模块未注册',
|
|
7633
8001
|
data: {
|
|
@@ -7646,7 +8014,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7646
8014
|
size: result.size,
|
|
7647
8015
|
skip: result.skip
|
|
7648
8016
|
});
|
|
7649
|
-
return
|
|
8017
|
+
return _context75.abrupt("return", {
|
|
7650
8018
|
code: 200,
|
|
7651
8019
|
data: result,
|
|
7652
8020
|
message: '',
|
|
@@ -7654,11 +8022,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
7654
8022
|
});
|
|
7655
8023
|
case 8:
|
|
7656
8024
|
case "end":
|
|
7657
|
-
return
|
|
8025
|
+
return _context75.stop();
|
|
7658
8026
|
}
|
|
7659
|
-
},
|
|
8027
|
+
}, _callee75, this);
|
|
7660
8028
|
}));
|
|
7661
|
-
function computeBookingQueryResult(
|
|
8029
|
+
function computeBookingQueryResult(_x84) {
|
|
7662
8030
|
return _computeBookingQueryResult.apply(this, arguments);
|
|
7663
8031
|
}
|
|
7664
8032
|
return computeBookingQueryResult;
|
|
@@ -7717,12 +8085,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
7717
8085
|
}, {
|
|
7718
8086
|
key: "computeProductQueryResult",
|
|
7719
8087
|
value: (function () {
|
|
7720
|
-
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8088
|
+
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(context, options) {
|
|
7721
8089
|
var _menu_list_ids$length3,
|
|
7722
|
-
|
|
8090
|
+
_this22 = this;
|
|
7723
8091
|
var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, 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;
|
|
7724
|
-
return _regeneratorRuntime().wrap(function
|
|
7725
|
-
while (1) switch (
|
|
8092
|
+
return _regeneratorRuntime().wrap(function _callee76$(_context76) {
|
|
8093
|
+
while (1) switch (_context76.prev = _context76.next) {
|
|
7726
8094
|
case 0:
|
|
7727
8095
|
tTotal = performance.now();
|
|
7728
8096
|
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, strategy_context = context.strategy_context;
|
|
@@ -7749,28 +8117,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
7749
8117
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
7750
8118
|
});
|
|
7751
8119
|
if (this.products) {
|
|
7752
|
-
|
|
8120
|
+
_context76.next = 8;
|
|
7753
8121
|
break;
|
|
7754
8122
|
}
|
|
7755
8123
|
this.logError('computeProductQueryResult: Products 模块未注册');
|
|
7756
|
-
return
|
|
8124
|
+
return _context76.abrupt("return", {
|
|
7757
8125
|
message: 'Products 模块未注册',
|
|
7758
8126
|
data: this.buildProductQueryResultPayload([], 0)
|
|
7759
8127
|
});
|
|
7760
8128
|
case 8:
|
|
7761
8129
|
if (!(queryIds.length > 0)) {
|
|
7762
|
-
|
|
8130
|
+
_context76.next = 20;
|
|
7763
8131
|
break;
|
|
7764
8132
|
}
|
|
7765
8133
|
uniqueIds = Array.from(new Set(queryIds));
|
|
7766
8134
|
_tPrice = performance.now();
|
|
7767
|
-
|
|
8135
|
+
_context76.next = 13;
|
|
7768
8136
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
7769
8137
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
7770
8138
|
productIds: uniqueIds
|
|
7771
8139
|
});
|
|
7772
8140
|
case 13:
|
|
7773
|
-
productsWithPrice =
|
|
8141
|
+
productsWithPrice = _context76.sent;
|
|
7774
8142
|
perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
|
|
7775
8143
|
count: productsWithPrice.length,
|
|
7776
8144
|
ids: uniqueIds
|
|
@@ -7790,7 +8158,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7790
8158
|
ids: uniqueIds,
|
|
7791
8159
|
count: extensionFilteredProducts.length
|
|
7792
8160
|
});
|
|
7793
|
-
return
|
|
8161
|
+
return _context76.abrupt("return", {
|
|
7794
8162
|
code: 200,
|
|
7795
8163
|
data: this.buildProductQueryResultPayload(extensionFilteredProducts),
|
|
7796
8164
|
message: '',
|
|
@@ -7798,17 +8166,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
7798
8166
|
});
|
|
7799
8167
|
case 20:
|
|
7800
8168
|
if (!(product_id != null && Number.isFinite(Number(product_id)))) {
|
|
7801
|
-
|
|
8169
|
+
_context76.next = 32;
|
|
7802
8170
|
break;
|
|
7803
8171
|
}
|
|
7804
8172
|
pid = Number(product_id);
|
|
7805
8173
|
_tPrice2 = performance.now();
|
|
7806
|
-
|
|
8174
|
+
_context76.next = 25;
|
|
7807
8175
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
7808
8176
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
7809
8177
|
});
|
|
7810
8178
|
case 25:
|
|
7811
|
-
allProductsWithPrice =
|
|
8179
|
+
allProductsWithPrice = _context76.sent;
|
|
7812
8180
|
perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
|
|
7813
8181
|
count: allProductsWithPrice.length,
|
|
7814
8182
|
productId: pid
|
|
@@ -7828,7 +8196,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7828
8196
|
productId: pid,
|
|
7829
8197
|
found: !!item
|
|
7830
8198
|
});
|
|
7831
|
-
return
|
|
8199
|
+
return _context76.abrupt("return", {
|
|
7832
8200
|
code: 200,
|
|
7833
8201
|
data: item,
|
|
7834
8202
|
message: item ? '' : '商品不存在或未发布',
|
|
@@ -7836,16 +8204,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
7836
8204
|
});
|
|
7837
8205
|
case 32:
|
|
7838
8206
|
if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
|
|
7839
|
-
|
|
8207
|
+
_context76.next = 52;
|
|
7840
8208
|
break;
|
|
7841
8209
|
}
|
|
7842
8210
|
_tPrice3 = performance.now();
|
|
7843
|
-
|
|
8211
|
+
_context76.next = 36;
|
|
7844
8212
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
7845
8213
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
7846
8214
|
});
|
|
7847
8215
|
case 36:
|
|
7848
|
-
_filteredProducts2 =
|
|
8216
|
+
_filteredProducts2 = _context76.sent;
|
|
7849
8217
|
perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
|
|
7850
8218
|
count: _filteredProducts2.length,
|
|
7851
8219
|
extension_type: extension_type
|
|
@@ -7884,7 +8252,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7884
8252
|
filteredCount: _filteredProducts2.length,
|
|
7885
8253
|
extension_type: extension_type
|
|
7886
8254
|
});
|
|
7887
|
-
return
|
|
8255
|
+
return _context76.abrupt("return", {
|
|
7888
8256
|
code: 200,
|
|
7889
8257
|
data: this.buildProductQueryResultPayload(_filteredProducts2),
|
|
7890
8258
|
message: '',
|
|
@@ -7892,50 +8260,50 @@ var Server = /*#__PURE__*/function () {
|
|
|
7892
8260
|
});
|
|
7893
8261
|
case 52:
|
|
7894
8262
|
if (this.menu) {
|
|
7895
|
-
|
|
8263
|
+
_context76.next = 55;
|
|
7896
8264
|
break;
|
|
7897
8265
|
}
|
|
7898
8266
|
this.logError('computeProductQueryResult: Menu 模块未注册');
|
|
7899
|
-
return
|
|
8267
|
+
return _context76.abrupt("return", {
|
|
7900
8268
|
message: 'Menu 模块未注册',
|
|
7901
8269
|
data: this.buildProductQueryResultPayload([], 0)
|
|
7902
8270
|
});
|
|
7903
8271
|
case 55:
|
|
7904
8272
|
if (this.schedule) {
|
|
7905
|
-
|
|
8273
|
+
_context76.next = 58;
|
|
7906
8274
|
break;
|
|
7907
8275
|
}
|
|
7908
8276
|
this.logError('computeProductQueryResult: Schedule 模块未注册');
|
|
7909
|
-
return
|
|
8277
|
+
return _context76.abrupt("return", {
|
|
7910
8278
|
message: 'Schedule 模块未注册',
|
|
7911
8279
|
data: this.buildProductQueryResultPayload([], 0)
|
|
7912
8280
|
});
|
|
7913
8281
|
case 58:
|
|
7914
8282
|
activeMenuList = [];
|
|
7915
8283
|
if (!(menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0)) {
|
|
7916
|
-
|
|
8284
|
+
_context76.next = 71;
|
|
7917
8285
|
break;
|
|
7918
8286
|
}
|
|
7919
8287
|
tMenu = performance.now();
|
|
7920
8288
|
getActiveMenus = function getActiveMenus() {
|
|
7921
|
-
return
|
|
7922
|
-
var
|
|
7923
|
-
return ((
|
|
8289
|
+
return _this22.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
|
|
8290
|
+
var _this22$schedule;
|
|
8291
|
+
return ((_this22$schedule = _this22.schedule) === null || _this22$schedule === void 0 ? void 0 : _this22$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
|
|
7924
8292
|
});
|
|
7925
8293
|
};
|
|
7926
8294
|
activeMenuList = getActiveMenus();
|
|
7927
|
-
|
|
7928
|
-
if (!
|
|
7929
|
-
|
|
8295
|
+
_context76.t0 = !activeMenuList.length;
|
|
8296
|
+
if (!_context76.t0) {
|
|
8297
|
+
_context76.next = 68;
|
|
7930
8298
|
break;
|
|
7931
8299
|
}
|
|
7932
|
-
|
|
8300
|
+
_context76.next = 67;
|
|
7933
8301
|
return this.refreshMenuScheduleCacheAfterEmptyResult();
|
|
7934
8302
|
case 67:
|
|
7935
|
-
|
|
8303
|
+
_context76.t0 = _context76.sent;
|
|
7936
8304
|
case 68:
|
|
7937
|
-
if (!
|
|
7938
|
-
|
|
8305
|
+
if (!_context76.t0) {
|
|
8306
|
+
_context76.next = 70;
|
|
7939
8307
|
break;
|
|
7940
8308
|
}
|
|
7941
8309
|
activeMenuList = getActiveMenus();
|
|
@@ -7955,22 +8323,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
7955
8323
|
});
|
|
7956
8324
|
tPrice = performance.now();
|
|
7957
8325
|
if (!(scopedProductIds.length > 0)) {
|
|
7958
|
-
|
|
8326
|
+
_context76.next = 82;
|
|
7959
8327
|
break;
|
|
7960
8328
|
}
|
|
7961
|
-
|
|
8329
|
+
_context76.next = 79;
|
|
7962
8330
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
7963
8331
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
7964
8332
|
productIds: productScope.isAllProducts ? undefined : scopedProductIds
|
|
7965
8333
|
});
|
|
7966
8334
|
case 79:
|
|
7967
|
-
|
|
7968
|
-
|
|
8335
|
+
_context76.t1 = _context76.sent;
|
|
8336
|
+
_context76.next = 83;
|
|
7969
8337
|
break;
|
|
7970
8338
|
case 82:
|
|
7971
|
-
|
|
8339
|
+
_context76.t1 = [];
|
|
7972
8340
|
case 83:
|
|
7973
|
-
filteredProducts =
|
|
8341
|
+
filteredProducts = _context76.t1;
|
|
7974
8342
|
perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
|
|
7975
8343
|
count: filteredProducts.length,
|
|
7976
8344
|
scopedProductCount: scopedProductIds.length
|
|
@@ -8011,7 +8379,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8011
8379
|
filteredCount: filteredProducts.length,
|
|
8012
8380
|
activeMenuCount: activeMenuList.length
|
|
8013
8381
|
});
|
|
8014
|
-
return
|
|
8382
|
+
return _context76.abrupt("return", {
|
|
8015
8383
|
code: 200,
|
|
8016
8384
|
data: this.buildProductQueryResultPayload(filteredProducts),
|
|
8017
8385
|
message: '',
|
|
@@ -8019,11 +8387,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
8019
8387
|
});
|
|
8020
8388
|
case 99:
|
|
8021
8389
|
case "end":
|
|
8022
|
-
return
|
|
8390
|
+
return _context76.stop();
|
|
8023
8391
|
}
|
|
8024
|
-
},
|
|
8392
|
+
}, _callee76, this);
|
|
8025
8393
|
}));
|
|
8026
|
-
function computeProductQueryResult(
|
|
8394
|
+
function computeProductQueryResult(_x85, _x86) {
|
|
8027
8395
|
return _computeProductQueryResult.apply(this, arguments);
|
|
8028
8396
|
}
|
|
8029
8397
|
return computeProductQueryResult;
|
|
@@ -8059,72 +8427,72 @@ var Server = /*#__PURE__*/function () {
|
|
|
8059
8427
|
}, {
|
|
8060
8428
|
key: "recomputeAndNotifyProductQuery",
|
|
8061
8429
|
value: (function () {
|
|
8062
|
-
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8430
|
+
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(options) {
|
|
8063
8431
|
var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
|
|
8064
|
-
return _regeneratorRuntime().wrap(function
|
|
8065
|
-
while (1) switch (
|
|
8432
|
+
return _regeneratorRuntime().wrap(function _callee77$(_context77) {
|
|
8433
|
+
while (1) switch (_context77.prev = _context77.next) {
|
|
8066
8434
|
case 0:
|
|
8067
8435
|
if (!(this.productQuerySubscribers.size === 0)) {
|
|
8068
|
-
|
|
8436
|
+
_context77.next = 2;
|
|
8069
8437
|
break;
|
|
8070
8438
|
}
|
|
8071
|
-
return
|
|
8439
|
+
return _context77.abrupt("return");
|
|
8072
8440
|
case 2:
|
|
8073
8441
|
this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
|
|
8074
8442
|
subscriberCount: this.productQuerySubscribers.size,
|
|
8075
8443
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
8076
8444
|
});
|
|
8077
8445
|
_iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
|
|
8078
|
-
|
|
8446
|
+
_context77.prev = 4;
|
|
8079
8447
|
_iterator18.s();
|
|
8080
8448
|
case 6:
|
|
8081
8449
|
if ((_step18 = _iterator18.n()).done) {
|
|
8082
|
-
|
|
8450
|
+
_context77.next = 22;
|
|
8083
8451
|
break;
|
|
8084
8452
|
}
|
|
8085
8453
|
_step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
|
|
8086
|
-
|
|
8087
|
-
|
|
8454
|
+
_context77.prev = 8;
|
|
8455
|
+
_context77.next = 11;
|
|
8088
8456
|
return this.computeProductQueryResult(subscriber.context, {
|
|
8089
8457
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
8090
8458
|
});
|
|
8091
8459
|
case 11:
|
|
8092
|
-
result =
|
|
8460
|
+
result = _context77.sent;
|
|
8093
8461
|
subscriber.callback(result);
|
|
8094
8462
|
this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
|
|
8095
8463
|
subscriberId: subscriberId
|
|
8096
8464
|
});
|
|
8097
|
-
|
|
8465
|
+
_context77.next = 20;
|
|
8098
8466
|
break;
|
|
8099
8467
|
case 16:
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
errorMessage =
|
|
8468
|
+
_context77.prev = 16;
|
|
8469
|
+
_context77.t0 = _context77["catch"](8);
|
|
8470
|
+
errorMessage = _context77.t0 instanceof Error ? _context77.t0.message : String(_context77.t0);
|
|
8103
8471
|
this.logError('recomputeAndNotifyProductQuery: 推送失败', {
|
|
8104
8472
|
subscriberId: subscriberId,
|
|
8105
8473
|
error: errorMessage
|
|
8106
8474
|
});
|
|
8107
8475
|
case 20:
|
|
8108
|
-
|
|
8476
|
+
_context77.next = 6;
|
|
8109
8477
|
break;
|
|
8110
8478
|
case 22:
|
|
8111
|
-
|
|
8479
|
+
_context77.next = 27;
|
|
8112
8480
|
break;
|
|
8113
8481
|
case 24:
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
_iterator18.e(
|
|
8482
|
+
_context77.prev = 24;
|
|
8483
|
+
_context77.t1 = _context77["catch"](4);
|
|
8484
|
+
_iterator18.e(_context77.t1);
|
|
8117
8485
|
case 27:
|
|
8118
|
-
|
|
8486
|
+
_context77.prev = 27;
|
|
8119
8487
|
_iterator18.f();
|
|
8120
|
-
return
|
|
8488
|
+
return _context77.finish(27);
|
|
8121
8489
|
case 30:
|
|
8122
8490
|
case "end":
|
|
8123
|
-
return
|
|
8491
|
+
return _context77.stop();
|
|
8124
8492
|
}
|
|
8125
|
-
},
|
|
8493
|
+
}, _callee77, this, [[4, 24, 27, 30], [8, 16]]);
|
|
8126
8494
|
}));
|
|
8127
|
-
function recomputeAndNotifyProductQuery(
|
|
8495
|
+
function recomputeAndNotifyProductQuery(_x87) {
|
|
8128
8496
|
return _recomputeAndNotifyProductQuery.apply(this, arguments);
|
|
8129
8497
|
}
|
|
8130
8498
|
return recomputeAndNotifyProductQuery;
|
|
@@ -8136,16 +8504,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
8136
8504
|
}, {
|
|
8137
8505
|
key: "recomputeAndNotifyOrderQuery",
|
|
8138
8506
|
value: (function () {
|
|
8139
|
-
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8507
|
+
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78() {
|
|
8140
8508
|
var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
|
|
8141
|
-
return _regeneratorRuntime().wrap(function
|
|
8142
|
-
while (1) switch (
|
|
8509
|
+
return _regeneratorRuntime().wrap(function _callee78$(_context78) {
|
|
8510
|
+
while (1) switch (_context78.prev = _context78.next) {
|
|
8143
8511
|
case 0:
|
|
8144
8512
|
if (!(this.orderQuerySubscribers.size === 0)) {
|
|
8145
|
-
|
|
8513
|
+
_context78.next = 2;
|
|
8146
8514
|
break;
|
|
8147
8515
|
}
|
|
8148
|
-
return
|
|
8516
|
+
return _context78.abrupt("return");
|
|
8149
8517
|
case 2:
|
|
8150
8518
|
notifyStartAt = Date.now();
|
|
8151
8519
|
this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
|
|
@@ -8153,20 +8521,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
8153
8521
|
notifyStartAt: new Date(notifyStartAt).toISOString()
|
|
8154
8522
|
});
|
|
8155
8523
|
_iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
|
|
8156
|
-
|
|
8524
|
+
_context78.prev = 5;
|
|
8157
8525
|
_iterator19.s();
|
|
8158
8526
|
case 7:
|
|
8159
8527
|
if ((_step19 = _iterator19.n()).done) {
|
|
8160
|
-
|
|
8528
|
+
_context78.next = 27;
|
|
8161
8529
|
break;
|
|
8162
8530
|
}
|
|
8163
8531
|
_step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
|
|
8164
|
-
|
|
8532
|
+
_context78.prev = 9;
|
|
8165
8533
|
computeStartAt = Date.now();
|
|
8166
|
-
|
|
8534
|
+
_context78.next = 13;
|
|
8167
8535
|
return this.computeOrderQueryResult(subscriber.context);
|
|
8168
8536
|
case 13:
|
|
8169
|
-
result =
|
|
8537
|
+
result = _context78.sent;
|
|
8170
8538
|
computeEndAt = Date.now();
|
|
8171
8539
|
callbackStartAt = Date.now();
|
|
8172
8540
|
subscriber.callback(result);
|
|
@@ -8177,30 +8545,30 @@ var Server = /*#__PURE__*/function () {
|
|
|
8177
8545
|
callbackDurationMs: callbackEndAt - callbackStartAt,
|
|
8178
8546
|
totalDurationMs: callbackEndAt - computeStartAt
|
|
8179
8547
|
});
|
|
8180
|
-
|
|
8548
|
+
_context78.next = 25;
|
|
8181
8549
|
break;
|
|
8182
8550
|
case 21:
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
errorMessage =
|
|
8551
|
+
_context78.prev = 21;
|
|
8552
|
+
_context78.t0 = _context78["catch"](9);
|
|
8553
|
+
errorMessage = _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0);
|
|
8186
8554
|
this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
|
|
8187
8555
|
subscriberId: subscriberId,
|
|
8188
8556
|
error: errorMessage
|
|
8189
8557
|
});
|
|
8190
8558
|
case 25:
|
|
8191
|
-
|
|
8559
|
+
_context78.next = 7;
|
|
8192
8560
|
break;
|
|
8193
8561
|
case 27:
|
|
8194
|
-
|
|
8562
|
+
_context78.next = 32;
|
|
8195
8563
|
break;
|
|
8196
8564
|
case 29:
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
_iterator19.e(
|
|
8565
|
+
_context78.prev = 29;
|
|
8566
|
+
_context78.t1 = _context78["catch"](5);
|
|
8567
|
+
_iterator19.e(_context78.t1);
|
|
8200
8568
|
case 32:
|
|
8201
|
-
|
|
8569
|
+
_context78.prev = 32;
|
|
8202
8570
|
_iterator19.f();
|
|
8203
|
-
return
|
|
8571
|
+
return _context78.finish(32);
|
|
8204
8572
|
case 35:
|
|
8205
8573
|
notifyEndAt = Date.now();
|
|
8206
8574
|
this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
|
|
@@ -8209,9 +8577,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
8209
8577
|
});
|
|
8210
8578
|
case 37:
|
|
8211
8579
|
case "end":
|
|
8212
|
-
return
|
|
8580
|
+
return _context78.stop();
|
|
8213
8581
|
}
|
|
8214
|
-
},
|
|
8582
|
+
}, _callee78, this, [[5, 29, 32, 35], [9, 21]]);
|
|
8215
8583
|
}));
|
|
8216
8584
|
function recomputeAndNotifyOrderQuery() {
|
|
8217
8585
|
return _recomputeAndNotifyOrderQuery.apply(this, arguments);
|
|
@@ -8229,7 +8597,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8229
8597
|
}, {
|
|
8230
8598
|
key: "notifySalesSearchSubscribers",
|
|
8231
8599
|
value: function notifySalesSearchSubscribers(payload) {
|
|
8232
|
-
var
|
|
8600
|
+
var _this23 = this;
|
|
8233
8601
|
if (this.salesSearchSubscribers.size === 0) return;
|
|
8234
8602
|
var changedOrders = this.extractChangedOrdersFromPayload(payload);
|
|
8235
8603
|
if (changedOrders.length === 0) {
|
|
@@ -8247,21 +8615,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
8247
8615
|
subscriber = _step20$value[1];
|
|
8248
8616
|
try {
|
|
8249
8617
|
var changedVisibleOrders = changedOrders.filter(function (order) {
|
|
8250
|
-
var orderId =
|
|
8618
|
+
var orderId = _this23.getSalesSearchOrderId(order);
|
|
8251
8619
|
return !!orderId && subscriber.visibleOrderIds.has(orderId);
|
|
8252
8620
|
});
|
|
8253
8621
|
if (changedVisibleOrders.length === 0) {
|
|
8254
8622
|
return 1; // continue
|
|
8255
8623
|
}
|
|
8256
|
-
subscriber.callback(
|
|
8257
|
-
|
|
8624
|
+
subscriber.callback(_this23.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
|
|
8625
|
+
_this23.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
|
|
8258
8626
|
subscriberId: subscriberId,
|
|
8259
8627
|
kind: subscriber.kind,
|
|
8260
8628
|
count: changedVisibleOrders.length
|
|
8261
8629
|
});
|
|
8262
8630
|
} catch (error) {
|
|
8263
8631
|
var errorMessage = error instanceof Error ? error.message : String(error);
|
|
8264
|
-
|
|
8632
|
+
_this23.logError('notifySalesSearchSubscribers: 推送失败', {
|
|
8265
8633
|
subscriberId: subscriberId,
|
|
8266
8634
|
error: errorMessage
|
|
8267
8635
|
});
|
|
@@ -8352,67 +8720,67 @@ var Server = /*#__PURE__*/function () {
|
|
|
8352
8720
|
}, {
|
|
8353
8721
|
key: "recomputeAndNotifyBookingQuery",
|
|
8354
8722
|
value: (function () {
|
|
8355
|
-
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8723
|
+
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79() {
|
|
8356
8724
|
var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
|
|
8357
|
-
return _regeneratorRuntime().wrap(function
|
|
8358
|
-
while (1) switch (
|
|
8725
|
+
return _regeneratorRuntime().wrap(function _callee79$(_context79) {
|
|
8726
|
+
while (1) switch (_context79.prev = _context79.next) {
|
|
8359
8727
|
case 0:
|
|
8360
8728
|
if (!(this.bookingQuerySubscribers.size === 0)) {
|
|
8361
|
-
|
|
8729
|
+
_context79.next = 2;
|
|
8362
8730
|
break;
|
|
8363
8731
|
}
|
|
8364
|
-
return
|
|
8732
|
+
return _context79.abrupt("return");
|
|
8365
8733
|
case 2:
|
|
8366
8734
|
this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
|
|
8367
8735
|
subscriberCount: this.bookingQuerySubscribers.size
|
|
8368
8736
|
});
|
|
8369
8737
|
_iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
|
|
8370
|
-
|
|
8738
|
+
_context79.prev = 4;
|
|
8371
8739
|
_iterator21.s();
|
|
8372
8740
|
case 6:
|
|
8373
8741
|
if ((_step21 = _iterator21.n()).done) {
|
|
8374
|
-
|
|
8742
|
+
_context79.next = 22;
|
|
8375
8743
|
break;
|
|
8376
8744
|
}
|
|
8377
8745
|
_step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
|
|
8378
|
-
|
|
8379
|
-
|
|
8746
|
+
_context79.prev = 8;
|
|
8747
|
+
_context79.next = 11;
|
|
8380
8748
|
return this.computeBookingQueryResult(subscriber.context);
|
|
8381
8749
|
case 11:
|
|
8382
|
-
result =
|
|
8750
|
+
result = _context79.sent;
|
|
8383
8751
|
subscriber.callback(result);
|
|
8384
8752
|
this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
|
|
8385
8753
|
subscriberId: subscriberId
|
|
8386
8754
|
});
|
|
8387
|
-
|
|
8755
|
+
_context79.next = 20;
|
|
8388
8756
|
break;
|
|
8389
8757
|
case 16:
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
errorMessage =
|
|
8758
|
+
_context79.prev = 16;
|
|
8759
|
+
_context79.t0 = _context79["catch"](8);
|
|
8760
|
+
errorMessage = _context79.t0 instanceof Error ? _context79.t0.message : String(_context79.t0);
|
|
8393
8761
|
this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
|
|
8394
8762
|
subscriberId: subscriberId,
|
|
8395
8763
|
error: errorMessage
|
|
8396
8764
|
});
|
|
8397
8765
|
case 20:
|
|
8398
|
-
|
|
8766
|
+
_context79.next = 6;
|
|
8399
8767
|
break;
|
|
8400
8768
|
case 22:
|
|
8401
|
-
|
|
8769
|
+
_context79.next = 27;
|
|
8402
8770
|
break;
|
|
8403
8771
|
case 24:
|
|
8404
|
-
|
|
8405
|
-
|
|
8406
|
-
_iterator21.e(
|
|
8772
|
+
_context79.prev = 24;
|
|
8773
|
+
_context79.t1 = _context79["catch"](4);
|
|
8774
|
+
_iterator21.e(_context79.t1);
|
|
8407
8775
|
case 27:
|
|
8408
|
-
|
|
8776
|
+
_context79.prev = 27;
|
|
8409
8777
|
_iterator21.f();
|
|
8410
|
-
return
|
|
8778
|
+
return _context79.finish(27);
|
|
8411
8779
|
case 30:
|
|
8412
8780
|
case "end":
|
|
8413
|
-
return
|
|
8781
|
+
return _context79.stop();
|
|
8414
8782
|
}
|
|
8415
|
-
},
|
|
8783
|
+
}, _callee79, this, [[4, 24, 27, 30], [8, 16]]);
|
|
8416
8784
|
}));
|
|
8417
8785
|
function recomputeAndNotifyBookingQuery() {
|
|
8418
8786
|
return _recomputeAndNotifyBookingQuery.apply(this, arguments);
|
|
@@ -8551,7 +8919,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8551
8919
|
metadata: metadata || {}
|
|
8552
8920
|
});
|
|
8553
8921
|
}
|
|
8554
|
-
} catch (
|
|
8922
|
+
} catch (_unused8) {
|
|
8555
8923
|
// 日志记录失败不影响主流程
|
|
8556
8924
|
}
|
|
8557
8925
|
}
|
|
@@ -8572,7 +8940,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8572
8940
|
metadata: metadata || {}
|
|
8573
8941
|
});
|
|
8574
8942
|
}
|
|
8575
|
-
} catch (
|
|
8943
|
+
} catch (_unused9) {
|
|
8576
8944
|
// 日志记录失败不影响主流程
|
|
8577
8945
|
}
|
|
8578
8946
|
}
|
|
@@ -8593,7 +8961,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8593
8961
|
metadata: metadata || {}
|
|
8594
8962
|
});
|
|
8595
8963
|
}
|
|
8596
|
-
} catch (
|
|
8964
|
+
} catch (_unused10) {
|
|
8597
8965
|
// 日志记录失败不影响主流程
|
|
8598
8966
|
}
|
|
8599
8967
|
}
|