@pisell/pisellos 2.3.20 → 2.3.21
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/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -10
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/dist/modules/Order/index.js +14 -6
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Order/utils.js +10 -2
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.js +392 -253
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/server/modules/products/index.d.ts +5 -1
- package/dist/server/modules/products/index.js +383 -315
- package/dist/server/modules/products/types.d.ts +4 -0
- package/dist/solution/BaseSales/index.js +144 -127
- package/dist/solution/BaseSales/types.d.ts +2 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -1
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
- package/lib/modules/Order/index.js +21 -7
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Order/utils.js +10 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/server/index.d.ts +4 -0
- package/lib/server/index.js +83 -2
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/server/modules/products/index.d.ts +5 -1
- package/lib/server/modules/products/index.js +20 -0
- package/lib/server/modules/products/types.d.ts +4 -0
- package/lib/solution/BaseSales/index.js +40 -22
- package/lib/solution/BaseSales/types.d.ts +2 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -1201,7 +1201,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1201
1201
|
_defineProperty(this, "handleOrderSalesDetail", /*#__PURE__*/function () {
|
|
1202
1202
|
var _ref45 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref44) {
|
|
1203
1203
|
var _this$app3;
|
|
1204
|
-
var url, data, path, requestPath, lookup, localOrder, backendPath, _response$data3, response, fresh, savedOrder, errorMessage;
|
|
1204
|
+
var url, data, path, requestPath, lookup, localOrder, enrichedOrder, backendPath, _response$data3, response, fresh, savedOrder, _enrichedOrder, errorMessage;
|
|
1205
1205
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1206
1206
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1207
1207
|
case 0:
|
|
@@ -1241,7 +1241,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1241
1241
|
});
|
|
1242
1242
|
case 10:
|
|
1243
1243
|
if (_this.shouldForceRemoteSalesDetail(data)) {
|
|
1244
|
-
_context18.next =
|
|
1244
|
+
_context18.next = 20;
|
|
1245
1245
|
break;
|
|
1246
1246
|
}
|
|
1247
1247
|
_context18.next = 13;
|
|
@@ -1249,9 +1249,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
1249
1249
|
case 13:
|
|
1250
1250
|
localOrder = _context18.sent;
|
|
1251
1251
|
if (!localOrder) {
|
|
1252
|
-
_context18.next =
|
|
1252
|
+
_context18.next = 20;
|
|
1253
1253
|
break;
|
|
1254
1254
|
}
|
|
1255
|
+
_context18.next = 17;
|
|
1256
|
+
return _this.withSalesDetailProductSnapshots(localOrder);
|
|
1257
|
+
case 17:
|
|
1258
|
+
enrichedOrder = _context18.sent;
|
|
1255
1259
|
_this.logInfo('handleOrderSalesDetail: 命中本地订单', {
|
|
1256
1260
|
lookup: lookup
|
|
1257
1261
|
});
|
|
@@ -1259,11 +1263,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
1259
1263
|
code: 200,
|
|
1260
1264
|
status: true,
|
|
1261
1265
|
message: '',
|
|
1262
|
-
data:
|
|
1266
|
+
data: enrichedOrder
|
|
1263
1267
|
});
|
|
1264
|
-
case
|
|
1268
|
+
case 20:
|
|
1265
1269
|
if ((_this$app3 = _this.app) !== null && _this$app3 !== void 0 && _this$app3.request) {
|
|
1266
|
-
_context18.next =
|
|
1270
|
+
_context18.next = 23;
|
|
1267
1271
|
break;
|
|
1268
1272
|
}
|
|
1269
1273
|
_this.logError('handleOrderSalesDetail: app.request 不可用');
|
|
@@ -1273,21 +1277,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
1273
1277
|
message: 'app.request 不可用',
|
|
1274
1278
|
data: null
|
|
1275
1279
|
});
|
|
1276
|
-
case
|
|
1280
|
+
case 23:
|
|
1277
1281
|
backendPath = _this.buildOrderSalesDetailBackendPath(lookup, data);
|
|
1278
|
-
_context18.prev =
|
|
1279
|
-
_context18.next =
|
|
1282
|
+
_context18.prev = 24;
|
|
1283
|
+
_context18.next = 27;
|
|
1280
1284
|
return _this.app.request.get(backendPath, {
|
|
1281
1285
|
lookup_mode: 'multi'
|
|
1282
1286
|
}, {
|
|
1283
1287
|
isShopApi: true,
|
|
1284
1288
|
customToast: function customToast() {}
|
|
1285
1289
|
});
|
|
1286
|
-
case
|
|
1290
|
+
case 27:
|
|
1287
1291
|
response = _context18.sent;
|
|
1288
1292
|
fresh = (_response$data3 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data3 !== void 0 ? _response$data3 : response;
|
|
1289
1293
|
if (!(!fresh || _typeof(fresh) !== 'object' || fresh.order_id == null)) {
|
|
1290
|
-
_context18.next =
|
|
1294
|
+
_context18.next = 32;
|
|
1291
1295
|
break;
|
|
1292
1296
|
}
|
|
1293
1297
|
_this.logInfo('handleOrderSalesDetail: 后端返回订单为空', {
|
|
@@ -1300,16 +1304,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
1300
1304
|
message: '后端返回订单为空',
|
|
1301
1305
|
data: null
|
|
1302
1306
|
});
|
|
1303
|
-
case
|
|
1304
|
-
_context18.next =
|
|
1307
|
+
case 32:
|
|
1308
|
+
_context18.next = 34;
|
|
1305
1309
|
return _this.order.upsertOrdersFromRemote([fresh]);
|
|
1306
|
-
case
|
|
1307
|
-
_context18.next =
|
|
1310
|
+
case 34:
|
|
1311
|
+
_context18.next = 36;
|
|
1308
1312
|
return _this.order.getLocalOrderByLookup(lookup);
|
|
1309
|
-
case
|
|
1313
|
+
case 36:
|
|
1310
1314
|
savedOrder = _context18.sent;
|
|
1311
1315
|
if (savedOrder) {
|
|
1312
|
-
_context18.next =
|
|
1316
|
+
_context18.next = 40;
|
|
1313
1317
|
break;
|
|
1314
1318
|
}
|
|
1315
1319
|
_this.logError('handleOrderSalesDetail: 订单写入后回读失败', {
|
|
@@ -1321,19 +1325,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
1321
1325
|
message: '订单写入后回读失败',
|
|
1322
1326
|
data: null
|
|
1323
1327
|
});
|
|
1324
|
-
case
|
|
1328
|
+
case 40:
|
|
1325
1329
|
_this.logInfo('handleOrderSalesDetail: 远端订单已同步到本地', {
|
|
1326
1330
|
lookup: lookup
|
|
1327
1331
|
});
|
|
1332
|
+
_context18.next = 43;
|
|
1333
|
+
return _this.withSalesDetailProductSnapshots(savedOrder);
|
|
1334
|
+
case 43:
|
|
1335
|
+
_enrichedOrder = _context18.sent;
|
|
1328
1336
|
return _context18.abrupt("return", {
|
|
1329
1337
|
code: 200,
|
|
1330
1338
|
status: true,
|
|
1331
1339
|
message: '',
|
|
1332
|
-
data:
|
|
1340
|
+
data: _enrichedOrder
|
|
1333
1341
|
});
|
|
1334
|
-
case
|
|
1335
|
-
_context18.prev =
|
|
1336
|
-
_context18.t0 = _context18["catch"](
|
|
1342
|
+
case 47:
|
|
1343
|
+
_context18.prev = 47;
|
|
1344
|
+
_context18.t0 = _context18["catch"](24);
|
|
1337
1345
|
errorMessage = _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0);
|
|
1338
1346
|
_this.logInfo('handleOrderSalesDetail: 请求失败', {
|
|
1339
1347
|
lookup: lookup,
|
|
@@ -1346,11 +1354,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
1346
1354
|
message: errorMessage,
|
|
1347
1355
|
data: null
|
|
1348
1356
|
});
|
|
1349
|
-
case
|
|
1357
|
+
case 52:
|
|
1350
1358
|
case "end":
|
|
1351
1359
|
return _context18.stop();
|
|
1352
1360
|
}
|
|
1353
|
-
}, _callee18, null, [[
|
|
1361
|
+
}, _callee18, null, [[24, 47]]);
|
|
1354
1362
|
}));
|
|
1355
1363
|
return function (_x18) {
|
|
1356
1364
|
return _ref45.apply(this, arguments);
|
|
@@ -5110,16 +5118,147 @@ var Server = /*#__PURE__*/function () {
|
|
|
5110
5118
|
}
|
|
5111
5119
|
return buildSmallTicketProductMap;
|
|
5112
5120
|
}()
|
|
5121
|
+
}, {
|
|
5122
|
+
key: "collectSalesDetailProductIds",
|
|
5123
|
+
value: function collectSalesDetailProductIds(order) {
|
|
5124
|
+
var products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
|
|
5125
|
+
var productIds = new Set();
|
|
5126
|
+
products.forEach(function (product) {
|
|
5127
|
+
var _product$product_id2;
|
|
5128
|
+
var rawProductId = (_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;
|
|
5129
|
+
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return;
|
|
5130
|
+
var productId = Number(rawProductId);
|
|
5131
|
+
if (Number.isFinite(productId)) productIds.add(productId);
|
|
5132
|
+
});
|
|
5133
|
+
return Array.from(productIds);
|
|
5134
|
+
}
|
|
5135
|
+
}, {
|
|
5136
|
+
key: "buildSalesDetailProductSnapshotMap",
|
|
5137
|
+
value: function () {
|
|
5138
|
+
var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(order) {
|
|
5139
|
+
var _this$products2;
|
|
5140
|
+
var productIds, getSnapshots;
|
|
5141
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5142
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
5143
|
+
case 0:
|
|
5144
|
+
productIds = this.collectSalesDetailProductIds(order);
|
|
5145
|
+
getSnapshots = (_this$products2 = this.products) === null || _this$products2 === void 0 ? void 0 : _this$products2.getProductSnapshotsByIds;
|
|
5146
|
+
if (!(!productIds.length || typeof getSnapshots !== 'function')) {
|
|
5147
|
+
_context55.next = 4;
|
|
5148
|
+
break;
|
|
5149
|
+
}
|
|
5150
|
+
return _context55.abrupt("return", {});
|
|
5151
|
+
case 4:
|
|
5152
|
+
_context55.prev = 4;
|
|
5153
|
+
_context55.next = 7;
|
|
5154
|
+
return getSnapshots.call(this.products, productIds);
|
|
5155
|
+
case 7:
|
|
5156
|
+
return _context55.abrupt("return", _context55.sent);
|
|
5157
|
+
case 10:
|
|
5158
|
+
_context55.prev = 10;
|
|
5159
|
+
_context55.t0 = _context55["catch"](4);
|
|
5160
|
+
this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
|
|
5161
|
+
product_ids: productIds,
|
|
5162
|
+
error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
|
|
5163
|
+
});
|
|
5164
|
+
return _context55.abrupt("return", {});
|
|
5165
|
+
case 14:
|
|
5166
|
+
case "end":
|
|
5167
|
+
return _context55.stop();
|
|
5168
|
+
}
|
|
5169
|
+
}, _callee55, this, [[4, 10]]);
|
|
5170
|
+
}));
|
|
5171
|
+
function buildSalesDetailProductSnapshotMap(_x61) {
|
|
5172
|
+
return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
|
|
5173
|
+
}
|
|
5174
|
+
return buildSalesDetailProductSnapshotMap;
|
|
5175
|
+
}()
|
|
5176
|
+
}, {
|
|
5177
|
+
key: "withProductCatalogSnapshots",
|
|
5178
|
+
value: function withProductCatalogSnapshots(product, snapshotMap) {
|
|
5179
|
+
var _product$product_id3;
|
|
5180
|
+
if (!product || _typeof(product) !== 'object') return product;
|
|
5181
|
+
var rawProductId = (_product$product_id3 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id3 !== void 0 ? _product$product_id3 : product === null || product === void 0 ? void 0 : product.id;
|
|
5182
|
+
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return product;
|
|
5183
|
+
var productId = Number(rawProductId);
|
|
5184
|
+
if (!Number.isFinite(productId)) return product;
|
|
5185
|
+
var snapshot = snapshotMap[String(productId)];
|
|
5186
|
+
if (!snapshot) return product;
|
|
5187
|
+
var shouldFillCover = (product.product_cover === undefined || product.product_cover === null || product.product_cover === '') && snapshot.cover !== undefined && snapshot.cover !== null && snapshot.cover !== '';
|
|
5188
|
+
var metadata = product.metadata && _typeof(product.metadata) === 'object' ? product.metadata : {};
|
|
5189
|
+
var shouldFillHolderConfig = (metadata.holder_config === undefined || metadata.holder_config === null) && snapshot.holder_config !== undefined && snapshot.holder_config !== null;
|
|
5190
|
+
if (!shouldFillCover && !shouldFillHolderConfig) return product;
|
|
5191
|
+
return _objectSpread(_objectSpread(_objectSpread({}, product), shouldFillCover ? {
|
|
5192
|
+
product_cover: snapshot.cover
|
|
5193
|
+
} : {}), shouldFillHolderConfig ? {
|
|
5194
|
+
metadata: _objectSpread(_objectSpread({}, metadata), {}, {
|
|
5195
|
+
holder_config: snapshot.holder_config
|
|
5196
|
+
})
|
|
5197
|
+
} : {});
|
|
5198
|
+
}
|
|
5199
|
+
}, {
|
|
5200
|
+
key: "withSalesDetailProductSnapshots",
|
|
5201
|
+
value: function () {
|
|
5202
|
+
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(order) {
|
|
5203
|
+
var _this13 = this;
|
|
5204
|
+
var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
|
|
5205
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
5206
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
5207
|
+
case 0:
|
|
5208
|
+
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
|
|
5209
|
+
if (products !== null && products !== void 0 && products.length) {
|
|
5210
|
+
_context56.next = 3;
|
|
5211
|
+
break;
|
|
5212
|
+
}
|
|
5213
|
+
return _context56.abrupt("return", order);
|
|
5214
|
+
case 3:
|
|
5215
|
+
_context56.next = 5;
|
|
5216
|
+
return this.buildSalesDetailProductSnapshotMap(order);
|
|
5217
|
+
case 5:
|
|
5218
|
+
snapshotMap = _context56.sent;
|
|
5219
|
+
if (Object.keys(snapshotMap).length) {
|
|
5220
|
+
_context56.next = 8;
|
|
5221
|
+
break;
|
|
5222
|
+
}
|
|
5223
|
+
return _context56.abrupt("return", order);
|
|
5224
|
+
case 8:
|
|
5225
|
+
hasChanged = false;
|
|
5226
|
+
enrichedProducts = products.map(function (product) {
|
|
5227
|
+
var nextProduct = _this13.withProductCatalogSnapshots(product, snapshotMap);
|
|
5228
|
+
if (nextProduct !== product) hasChanged = true;
|
|
5229
|
+
return nextProduct;
|
|
5230
|
+
});
|
|
5231
|
+
if (hasChanged) {
|
|
5232
|
+
_context56.next = 12;
|
|
5233
|
+
break;
|
|
5234
|
+
}
|
|
5235
|
+
return _context56.abrupt("return", order);
|
|
5236
|
+
case 12:
|
|
5237
|
+
enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
|
|
5238
|
+
products: enrichedProducts
|
|
5239
|
+
});
|
|
5240
|
+
return _context56.abrupt("return", enrichedOrder);
|
|
5241
|
+
case 14:
|
|
5242
|
+
case "end":
|
|
5243
|
+
return _context56.stop();
|
|
5244
|
+
}
|
|
5245
|
+
}, _callee56, this);
|
|
5246
|
+
}));
|
|
5247
|
+
function withSalesDetailProductSnapshots(_x62) {
|
|
5248
|
+
return _withSalesDetailProductSnapshots.apply(this, arguments);
|
|
5249
|
+
}
|
|
5250
|
+
return withSalesDetailProductSnapshots;
|
|
5251
|
+
}()
|
|
5113
5252
|
}, {
|
|
5114
5253
|
key: "withPendingSyncProductTitles",
|
|
5115
5254
|
value: function withPendingSyncProductTitles(order, productMap) {
|
|
5116
|
-
var
|
|
5255
|
+
var _this14 = this;
|
|
5117
5256
|
var products = Array.isArray(order.products) ? order.products : null;
|
|
5118
5257
|
if (!(products !== null && products !== void 0 && products.length)) return order;
|
|
5119
5258
|
return _objectSpread(_objectSpread({}, order), {}, {
|
|
5120
5259
|
products: products.map(function (product) {
|
|
5121
5260
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
5122
|
-
product_title:
|
|
5261
|
+
product_title: _this14.buildProductTitleSnapshot(product, productMap)
|
|
5123
5262
|
});
|
|
5124
5263
|
})
|
|
5125
5264
|
});
|
|
@@ -5127,18 +5266,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
5127
5266
|
}, {
|
|
5128
5267
|
key: "buildProductTitleSnapshot",
|
|
5129
5268
|
value: function buildProductTitleSnapshot(product, productMap) {
|
|
5130
|
-
var _product$
|
|
5269
|
+
var _product$product_id4,
|
|
5131
5270
|
_product$product,
|
|
5132
5271
|
_fallbackProduct$prod,
|
|
5133
|
-
|
|
5134
|
-
var productId = (_product$
|
|
5272
|
+
_this15 = this;
|
|
5273
|
+
var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
|
|
5135
5274
|
var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
|
|
5136
5275
|
var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
|
|
5137
5276
|
var fallbackTitle = (fallbackProduct === null || fallbackProduct === void 0 ? void 0 : fallbackProduct.product_title) || (fallbackProduct === null || fallbackProduct === void 0 ? void 0 : fallbackProduct.title) || (fallbackProduct === null || fallbackProduct === void 0 ? void 0 : fallbackProduct.name) || (fallbackProduct === null || fallbackProduct === void 0 ? void 0 : fallbackProduct.format_title) || (fallbackProduct === null || fallbackProduct === void 0 || (_fallbackProduct$prod = fallbackProduct.product) === null || _fallbackProduct$prod === void 0 ? void 0 : _fallbackProduct$prod.title);
|
|
5138
5277
|
var currentLocale = this.getProductTitleSnapshotCurrentLocale();
|
|
5139
5278
|
var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
|
|
5140
5279
|
return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
|
|
5141
|
-
snapshot[key] =
|
|
5280
|
+
snapshot[key] = _this15.resolveProductTitleValue(ownTitle, key, currentLocale) || _this15.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
|
|
5142
5281
|
return snapshot;
|
|
5143
5282
|
}, {});
|
|
5144
5283
|
}
|
|
@@ -5236,31 +5375,31 @@ var Server = /*#__PURE__*/function () {
|
|
|
5236
5375
|
}, {
|
|
5237
5376
|
key: "enrichPaymentNamesByCode",
|
|
5238
5377
|
value: function () {
|
|
5239
|
-
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5240
|
-
var
|
|
5378
|
+
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(order) {
|
|
5379
|
+
var _this16 = this;
|
|
5241
5380
|
var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
|
|
5242
|
-
return _regeneratorRuntime().wrap(function
|
|
5243
|
-
while (1) switch (
|
|
5381
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5382
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
5244
5383
|
case 0:
|
|
5245
5384
|
payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
|
|
5246
5385
|
hasMissingName = payments.some(function (payment) {
|
|
5247
|
-
return
|
|
5386
|
+
return _this16.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this16.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
|
|
5248
5387
|
});
|
|
5249
5388
|
if (hasMissingName) {
|
|
5250
|
-
|
|
5389
|
+
_context57.next = 4;
|
|
5251
5390
|
break;
|
|
5252
5391
|
}
|
|
5253
|
-
return
|
|
5392
|
+
return _context57.abrupt("return", order);
|
|
5254
5393
|
case 4:
|
|
5255
|
-
|
|
5256
|
-
|
|
5394
|
+
_context57.prev = 4;
|
|
5395
|
+
_context57.next = 7;
|
|
5257
5396
|
return this.getPaymentRouteModule();
|
|
5258
5397
|
case 7:
|
|
5259
|
-
paymentModule =
|
|
5260
|
-
|
|
5398
|
+
paymentModule = _context57.sent;
|
|
5399
|
+
_context57.next = 10;
|
|
5261
5400
|
return paymentModule.getPayMethodListAsync();
|
|
5262
5401
|
case 10:
|
|
5263
|
-
payMethods =
|
|
5402
|
+
payMethods = _context57.sent;
|
|
5264
5403
|
nameByCode = new Map();
|
|
5265
5404
|
_iterator12 = _createForOfIteratorHelper(payMethods || []);
|
|
5266
5405
|
try {
|
|
@@ -5277,9 +5416,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5277
5416
|
}
|
|
5278
5417
|
hasResolvedName = false;
|
|
5279
5418
|
enrichedPayments = payments.map(function (payment) {
|
|
5280
|
-
if (!
|
|
5281
|
-
if (!
|
|
5282
|
-
var name = nameByCode.get(
|
|
5419
|
+
if (!_this16.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
|
|
5420
|
+
if (!_this16.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
|
|
5421
|
+
var name = nameByCode.get(_this16.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
|
|
5283
5422
|
if (!name) return payment;
|
|
5284
5423
|
hasResolvedName = true;
|
|
5285
5424
|
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
@@ -5287,28 +5426,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
5287
5426
|
});
|
|
5288
5427
|
});
|
|
5289
5428
|
if (hasResolvedName) {
|
|
5290
|
-
|
|
5429
|
+
_context57.next = 18;
|
|
5291
5430
|
break;
|
|
5292
5431
|
}
|
|
5293
|
-
return
|
|
5432
|
+
return _context57.abrupt("return", order);
|
|
5294
5433
|
case 18:
|
|
5295
|
-
return
|
|
5434
|
+
return _context57.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
|
|
5296
5435
|
payments: enrichedPayments
|
|
5297
5436
|
}));
|
|
5298
5437
|
case 21:
|
|
5299
|
-
|
|
5300
|
-
|
|
5438
|
+
_context57.prev = 21;
|
|
5439
|
+
_context57.t0 = _context57["catch"](4);
|
|
5301
5440
|
this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
|
|
5302
|
-
error:
|
|
5441
|
+
error: _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0)
|
|
5303
5442
|
});
|
|
5304
|
-
return
|
|
5443
|
+
return _context57.abrupt("return", order);
|
|
5305
5444
|
case 25:
|
|
5306
5445
|
case "end":
|
|
5307
|
-
return
|
|
5446
|
+
return _context57.stop();
|
|
5308
5447
|
}
|
|
5309
|
-
},
|
|
5448
|
+
}, _callee57, this, [[4, 21]]);
|
|
5310
5449
|
}));
|
|
5311
|
-
function enrichPaymentNamesByCode(
|
|
5450
|
+
function enrichPaymentNamesByCode(_x63) {
|
|
5312
5451
|
return _enrichPaymentNamesByCode.apply(this, arguments);
|
|
5313
5452
|
}
|
|
5314
5453
|
return enrichPaymentNamesByCode;
|
|
@@ -5316,66 +5455,66 @@ var Server = /*#__PURE__*/function () {
|
|
|
5316
5455
|
}, {
|
|
5317
5456
|
key: "withLocalSmallTicketData",
|
|
5318
5457
|
value: function () {
|
|
5319
|
-
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5458
|
+
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(order, options) {
|
|
5320
5459
|
var _options$productMap, enrichedOrder, productMap, smallTicketData;
|
|
5321
|
-
return _regeneratorRuntime().wrap(function
|
|
5322
|
-
while (1) switch (
|
|
5460
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
5461
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
5323
5462
|
case 0:
|
|
5324
5463
|
if (this.shouldBuildSmallTicketData(order)) {
|
|
5325
|
-
|
|
5464
|
+
_context58.next = 2;
|
|
5326
5465
|
break;
|
|
5327
5466
|
}
|
|
5328
|
-
return
|
|
5467
|
+
return _context58.abrupt("return", order);
|
|
5329
5468
|
case 2:
|
|
5330
5469
|
if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
|
|
5331
|
-
|
|
5470
|
+
_context58.next = 4;
|
|
5332
5471
|
break;
|
|
5333
5472
|
}
|
|
5334
|
-
return
|
|
5473
|
+
return _context58.abrupt("return", order);
|
|
5335
5474
|
case 4:
|
|
5336
|
-
|
|
5337
|
-
|
|
5475
|
+
_context58.prev = 4;
|
|
5476
|
+
_context58.next = 7;
|
|
5338
5477
|
return this.enrichPaymentNamesByCode(order);
|
|
5339
5478
|
case 7:
|
|
5340
|
-
enrichedOrder =
|
|
5479
|
+
enrichedOrder = _context58.sent;
|
|
5341
5480
|
if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
|
|
5342
|
-
|
|
5481
|
+
_context58.next = 12;
|
|
5343
5482
|
break;
|
|
5344
5483
|
}
|
|
5345
|
-
|
|
5346
|
-
|
|
5484
|
+
_context58.t0 = _options$productMap;
|
|
5485
|
+
_context58.next = 15;
|
|
5347
5486
|
break;
|
|
5348
5487
|
case 12:
|
|
5349
|
-
|
|
5488
|
+
_context58.next = 14;
|
|
5350
5489
|
return this.buildSmallTicketProductMap(enrichedOrder);
|
|
5351
5490
|
case 14:
|
|
5352
|
-
|
|
5491
|
+
_context58.t0 = _context58.sent;
|
|
5353
5492
|
case 15:
|
|
5354
|
-
productMap =
|
|
5493
|
+
productMap = _context58.t0;
|
|
5355
5494
|
smallTicketData = buildSmallTicketData({
|
|
5356
5495
|
order: enrichedOrder,
|
|
5357
5496
|
shopInfo: this.getSmallTicketShopInfo(),
|
|
5358
5497
|
productMap: productMap
|
|
5359
5498
|
});
|
|
5360
|
-
return
|
|
5499
|
+
return _context58.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
|
|
5361
5500
|
payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
|
|
5362
5501
|
small_ticket_data: smallTicketData
|
|
5363
5502
|
})
|
|
5364
5503
|
}));
|
|
5365
5504
|
case 20:
|
|
5366
|
-
|
|
5367
|
-
|
|
5505
|
+
_context58.prev = 20;
|
|
5506
|
+
_context58.t1 = _context58["catch"](4);
|
|
5368
5507
|
this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
|
|
5369
|
-
error:
|
|
5508
|
+
error: _context58.t1 instanceof Error ? _context58.t1.message : String(_context58.t1)
|
|
5370
5509
|
});
|
|
5371
|
-
return
|
|
5510
|
+
return _context58.abrupt("return", order);
|
|
5372
5511
|
case 24:
|
|
5373
5512
|
case "end":
|
|
5374
|
-
return
|
|
5513
|
+
return _context58.stop();
|
|
5375
5514
|
}
|
|
5376
|
-
},
|
|
5515
|
+
}, _callee58, this, [[4, 20]]);
|
|
5377
5516
|
}));
|
|
5378
|
-
function withLocalSmallTicketData(
|
|
5517
|
+
function withLocalSmallTicketData(_x64, _x65) {
|
|
5379
5518
|
return _withLocalSmallTicketData.apply(this, arguments);
|
|
5380
5519
|
}
|
|
5381
5520
|
return withLocalSmallTicketData;
|
|
@@ -5437,22 +5576,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
5437
5576
|
}, {
|
|
5438
5577
|
key: "handleUpdateLocalOrdersBatch",
|
|
5439
5578
|
value: (function () {
|
|
5440
|
-
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5579
|
+
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(orderIds) {
|
|
5441
5580
|
var _this$app17;
|
|
5442
5581
|
var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message2, overwritten, inserted;
|
|
5443
|
-
return _regeneratorRuntime().wrap(function
|
|
5444
|
-
while (1) switch (
|
|
5582
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context59) {
|
|
5583
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
5445
5584
|
case 0:
|
|
5446
5585
|
this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
|
|
5447
5586
|
count: orderIds.length,
|
|
5448
5587
|
orderIds: orderIds
|
|
5449
5588
|
});
|
|
5450
5589
|
if (this.order) {
|
|
5451
|
-
|
|
5590
|
+
_context59.next = 4;
|
|
5452
5591
|
break;
|
|
5453
5592
|
}
|
|
5454
5593
|
this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
|
|
5455
|
-
return
|
|
5594
|
+
return _context59.abrupt("return", {
|
|
5456
5595
|
code: 500,
|
|
5457
5596
|
status: false,
|
|
5458
5597
|
message: 'Order 模块未注册',
|
|
@@ -5460,11 +5599,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5460
5599
|
});
|
|
5461
5600
|
case 4:
|
|
5462
5601
|
if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && _this$app17.request) {
|
|
5463
|
-
|
|
5602
|
+
_context59.next = 7;
|
|
5464
5603
|
break;
|
|
5465
5604
|
}
|
|
5466
5605
|
this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
|
|
5467
|
-
return
|
|
5606
|
+
return _context59.abrupt("return", {
|
|
5468
5607
|
code: 500,
|
|
5469
5608
|
status: false,
|
|
5470
5609
|
message: 'app.request 不可用',
|
|
@@ -5487,21 +5626,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
5487
5626
|
_iterator13.f();
|
|
5488
5627
|
}
|
|
5489
5628
|
fetched = [];
|
|
5490
|
-
|
|
5491
|
-
|
|
5629
|
+
_context59.prev = 11;
|
|
5630
|
+
_context59.next = 14;
|
|
5492
5631
|
return this.order.fetchOrdersByHttp(orderIds);
|
|
5493
5632
|
case 14:
|
|
5494
|
-
fetched =
|
|
5495
|
-
|
|
5633
|
+
fetched = _context59.sent;
|
|
5634
|
+
_context59.next = 22;
|
|
5496
5635
|
break;
|
|
5497
5636
|
case 17:
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
message =
|
|
5637
|
+
_context59.prev = 17;
|
|
5638
|
+
_context59.t0 = _context59["catch"](11);
|
|
5639
|
+
message = _context59.t0 instanceof Error ? _context59.t0.message : String(_context59.t0);
|
|
5501
5640
|
this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
|
|
5502
5641
|
message: message
|
|
5503
5642
|
});
|
|
5504
|
-
return
|
|
5643
|
+
return _context59.abrupt("return", {
|
|
5505
5644
|
code: 500,
|
|
5506
5645
|
status: false,
|
|
5507
5646
|
message: message,
|
|
@@ -5511,36 +5650,36 @@ var Server = /*#__PURE__*/function () {
|
|
|
5511
5650
|
// 按返回结果中的 order_id 建索引,未命中即视为单笔失败
|
|
5512
5651
|
fetchedMap = new Map();
|
|
5513
5652
|
_iterator14 = _createForOfIteratorHelper(fetched);
|
|
5514
|
-
|
|
5653
|
+
_context59.prev = 24;
|
|
5515
5654
|
_iterator14.s();
|
|
5516
5655
|
case 26:
|
|
5517
5656
|
if ((_step14 = _iterator14.n()).done) {
|
|
5518
|
-
|
|
5657
|
+
_context59.next = 34;
|
|
5519
5658
|
break;
|
|
5520
5659
|
}
|
|
5521
5660
|
order = _step14.value;
|
|
5522
5661
|
oid = order === null || order === void 0 ? void 0 : order.order_id;
|
|
5523
5662
|
if (!(oid === undefined || oid === null)) {
|
|
5524
|
-
|
|
5663
|
+
_context59.next = 31;
|
|
5525
5664
|
break;
|
|
5526
5665
|
}
|
|
5527
|
-
return
|
|
5666
|
+
return _context59.abrupt("continue", 32);
|
|
5528
5667
|
case 31:
|
|
5529
5668
|
fetchedMap.set(String(oid), order);
|
|
5530
5669
|
case 32:
|
|
5531
|
-
|
|
5670
|
+
_context59.next = 26;
|
|
5532
5671
|
break;
|
|
5533
5672
|
case 34:
|
|
5534
|
-
|
|
5673
|
+
_context59.next = 39;
|
|
5535
5674
|
break;
|
|
5536
5675
|
case 36:
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
_iterator14.e(
|
|
5676
|
+
_context59.prev = 36;
|
|
5677
|
+
_context59.t1 = _context59["catch"](24);
|
|
5678
|
+
_iterator14.e(_context59.t1);
|
|
5540
5679
|
case 39:
|
|
5541
|
-
|
|
5680
|
+
_context59.prev = 39;
|
|
5542
5681
|
_iterator14.f();
|
|
5543
|
-
return
|
|
5682
|
+
return _context59.finish(39);
|
|
5544
5683
|
case 42:
|
|
5545
5684
|
freshOrders = [];
|
|
5546
5685
|
succeedIds = [];
|
|
@@ -5566,23 +5705,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
5566
5705
|
_iterator15.f();
|
|
5567
5706
|
}
|
|
5568
5707
|
if (!(freshOrders.length > 0)) {
|
|
5569
|
-
|
|
5708
|
+
_context59.next = 58;
|
|
5570
5709
|
break;
|
|
5571
5710
|
}
|
|
5572
|
-
|
|
5573
|
-
|
|
5711
|
+
_context59.prev = 48;
|
|
5712
|
+
_context59.next = 51;
|
|
5574
5713
|
return this.order.upsertOrdersFromRemote(freshOrders);
|
|
5575
5714
|
case 51:
|
|
5576
|
-
|
|
5715
|
+
_context59.next = 58;
|
|
5577
5716
|
break;
|
|
5578
5717
|
case 53:
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
_message2 =
|
|
5718
|
+
_context59.prev = 53;
|
|
5719
|
+
_context59.t2 = _context59["catch"](48);
|
|
5720
|
+
_message2 = _context59.t2 instanceof Error ? _context59.t2.message : String(_context59.t2);
|
|
5582
5721
|
this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
|
|
5583
5722
|
message: _message2
|
|
5584
5723
|
});
|
|
5585
|
-
return
|
|
5724
|
+
return _context59.abrupt("return", {
|
|
5586
5725
|
code: 500,
|
|
5587
5726
|
status: false,
|
|
5588
5727
|
message: _message2,
|
|
@@ -5601,7 +5740,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5601
5740
|
insertedCount: inserted.length,
|
|
5602
5741
|
failedCount: failed.length
|
|
5603
5742
|
});
|
|
5604
|
-
return
|
|
5743
|
+
return _context59.abrupt("return", {
|
|
5605
5744
|
code: 200,
|
|
5606
5745
|
status: true,
|
|
5607
5746
|
message: '',
|
|
@@ -5613,11 +5752,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5613
5752
|
});
|
|
5614
5753
|
case 62:
|
|
5615
5754
|
case "end":
|
|
5616
|
-
return
|
|
5755
|
+
return _context59.stop();
|
|
5617
5756
|
}
|
|
5618
|
-
},
|
|
5757
|
+
}, _callee59, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
|
|
5619
5758
|
}));
|
|
5620
|
-
function handleUpdateLocalOrdersBatch(
|
|
5759
|
+
function handleUpdateLocalOrdersBatch(_x66) {
|
|
5621
5760
|
return _handleUpdateLocalOrdersBatch.apply(this, arguments);
|
|
5622
5761
|
}
|
|
5623
5762
|
return handleUpdateLocalOrdersBatch;
|
|
@@ -5859,10 +5998,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5859
5998
|
value: function extractBackendErrorResponse(error) {
|
|
5860
5999
|
var _error$response3,
|
|
5861
6000
|
_error$response4,
|
|
5862
|
-
|
|
6001
|
+
_this17 = this;
|
|
5863
6002
|
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];
|
|
5864
6003
|
return candidates.find(function (candidate) {
|
|
5865
|
-
return
|
|
6004
|
+
return _this17.isExplicitBackendErrorResponse(candidate);
|
|
5866
6005
|
}) || null;
|
|
5867
6006
|
}
|
|
5868
6007
|
}, {
|
|
@@ -5981,16 +6120,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
5981
6120
|
}, {
|
|
5982
6121
|
key: "recomputeAndNotifyFloorPlanQuery",
|
|
5983
6122
|
value: (function () {
|
|
5984
|
-
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6123
|
+
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60() {
|
|
5985
6124
|
var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
|
|
5986
|
-
return _regeneratorRuntime().wrap(function
|
|
5987
|
-
while (1) switch (
|
|
6125
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
6126
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
5988
6127
|
case 0:
|
|
5989
6128
|
if (!(this.floorPlanQuerySubscribers.size === 0)) {
|
|
5990
|
-
|
|
6129
|
+
_context60.next = 2;
|
|
5991
6130
|
break;
|
|
5992
6131
|
}
|
|
5993
|
-
return
|
|
6132
|
+
return _context60.abrupt("return");
|
|
5994
6133
|
case 2:
|
|
5995
6134
|
this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
|
|
5996
6135
|
subscriberCount: this.floorPlanQuerySubscribers.size
|
|
@@ -6020,9 +6159,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6020
6159
|
}
|
|
6021
6160
|
case 5:
|
|
6022
6161
|
case "end":
|
|
6023
|
-
return
|
|
6162
|
+
return _context60.stop();
|
|
6024
6163
|
}
|
|
6025
|
-
},
|
|
6164
|
+
}, _callee60, this);
|
|
6026
6165
|
}));
|
|
6027
6166
|
function recomputeAndNotifyFloorPlanQuery() {
|
|
6028
6167
|
return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
|
|
@@ -6052,21 +6191,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
6052
6191
|
* filter 逻辑暂为 mock,仅记录参数
|
|
6053
6192
|
*/
|
|
6054
6193
|
function () {
|
|
6055
|
-
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6194
|
+
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(data) {
|
|
6056
6195
|
var rawList, result;
|
|
6057
|
-
return _regeneratorRuntime().wrap(function
|
|
6058
|
-
while (1) switch (
|
|
6196
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
6197
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
6059
6198
|
case 0:
|
|
6060
6199
|
this.logInfo('computeOrderQueryResult: 开始过滤', {
|
|
6061
6200
|
data: data
|
|
6062
6201
|
});
|
|
6063
6202
|
console.log('[Server] computeOrderQueryResult', data);
|
|
6064
6203
|
if (this.order) {
|
|
6065
|
-
|
|
6204
|
+
_context61.next = 5;
|
|
6066
6205
|
break;
|
|
6067
6206
|
}
|
|
6068
6207
|
this.logError('computeOrderQueryResult: Order 模块未注册');
|
|
6069
|
-
return
|
|
6208
|
+
return _context61.abrupt("return", {
|
|
6070
6209
|
code: 500,
|
|
6071
6210
|
message: 'Order 模块未注册',
|
|
6072
6211
|
data: {
|
|
@@ -6090,7 +6229,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6090
6229
|
skip: result.skip,
|
|
6091
6230
|
rejected: result.rejected
|
|
6092
6231
|
});
|
|
6093
|
-
return
|
|
6232
|
+
return _context61.abrupt("return", {
|
|
6094
6233
|
code: 200,
|
|
6095
6234
|
data: result,
|
|
6096
6235
|
message: '',
|
|
@@ -6098,11 +6237,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6098
6237
|
});
|
|
6099
6238
|
case 10:
|
|
6100
6239
|
case "end":
|
|
6101
|
-
return
|
|
6240
|
+
return _context61.stop();
|
|
6102
6241
|
}
|
|
6103
|
-
},
|
|
6242
|
+
}, _callee61, this);
|
|
6104
6243
|
}));
|
|
6105
|
-
function computeOrderQueryResult(
|
|
6244
|
+
function computeOrderQueryResult(_x67) {
|
|
6106
6245
|
return _computeOrderQueryResult.apply(this, arguments);
|
|
6107
6246
|
}
|
|
6108
6247
|
return computeOrderQueryResult;
|
|
@@ -6115,17 +6254,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
6115
6254
|
}, {
|
|
6116
6255
|
key: "computeBookingQueryResult",
|
|
6117
6256
|
value: (function () {
|
|
6118
|
-
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6257
|
+
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(data) {
|
|
6119
6258
|
var rawOrders, result;
|
|
6120
|
-
return _regeneratorRuntime().wrap(function
|
|
6121
|
-
while (1) switch (
|
|
6259
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
6260
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
6122
6261
|
case 0:
|
|
6123
6262
|
if (this.order) {
|
|
6124
|
-
|
|
6263
|
+
_context62.next = 3;
|
|
6125
6264
|
break;
|
|
6126
6265
|
}
|
|
6127
6266
|
this.logError('computeBookingQueryResult: Order 模块未注册');
|
|
6128
|
-
return
|
|
6267
|
+
return _context62.abrupt("return", {
|
|
6129
6268
|
code: 500,
|
|
6130
6269
|
message: 'Order 模块未注册',
|
|
6131
6270
|
data: {
|
|
@@ -6144,7 +6283,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6144
6283
|
size: result.size,
|
|
6145
6284
|
skip: result.skip
|
|
6146
6285
|
});
|
|
6147
|
-
return
|
|
6286
|
+
return _context62.abrupt("return", {
|
|
6148
6287
|
code: 200,
|
|
6149
6288
|
data: result,
|
|
6150
6289
|
message: '',
|
|
@@ -6152,11 +6291,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6152
6291
|
});
|
|
6153
6292
|
case 8:
|
|
6154
6293
|
case "end":
|
|
6155
|
-
return
|
|
6294
|
+
return _context62.stop();
|
|
6156
6295
|
}
|
|
6157
|
-
},
|
|
6296
|
+
}, _callee62, this);
|
|
6158
6297
|
}));
|
|
6159
|
-
function computeBookingQueryResult(
|
|
6298
|
+
function computeBookingQueryResult(_x68) {
|
|
6160
6299
|
return _computeBookingQueryResult.apply(this, arguments);
|
|
6161
6300
|
}
|
|
6162
6301
|
return computeBookingQueryResult;
|
|
@@ -6215,12 +6354,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
6215
6354
|
}, {
|
|
6216
6355
|
key: "computeProductQueryResult",
|
|
6217
6356
|
value: (function () {
|
|
6218
|
-
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6357
|
+
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(context, options) {
|
|
6219
6358
|
var _menu_list_ids$length3,
|
|
6220
|
-
|
|
6359
|
+
_this18 = this;
|
|
6221
6360
|
var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, queryIds, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
|
|
6222
|
-
return _regeneratorRuntime().wrap(function
|
|
6223
|
-
while (1) switch (
|
|
6361
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
6362
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
6224
6363
|
case 0:
|
|
6225
6364
|
tTotal = performance.now();
|
|
6226
6365
|
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;
|
|
@@ -6240,11 +6379,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6240
6379
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6241
6380
|
});
|
|
6242
6381
|
if (this.products) {
|
|
6243
|
-
|
|
6382
|
+
_context63.next = 7;
|
|
6244
6383
|
break;
|
|
6245
6384
|
}
|
|
6246
6385
|
this.logError('computeProductQueryResult: Products 模块未注册');
|
|
6247
|
-
return
|
|
6386
|
+
return _context63.abrupt("return", {
|
|
6248
6387
|
message: 'Products 模块未注册',
|
|
6249
6388
|
data: {
|
|
6250
6389
|
list: [],
|
|
@@ -6253,12 +6392,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
6253
6392
|
});
|
|
6254
6393
|
case 7:
|
|
6255
6394
|
if (!(queryIds.length > 0)) {
|
|
6256
|
-
|
|
6395
|
+
_context63.next = 19;
|
|
6257
6396
|
break;
|
|
6258
6397
|
}
|
|
6259
6398
|
uniqueIds = Array.from(new Set(queryIds));
|
|
6260
6399
|
_tPrice = performance.now();
|
|
6261
|
-
|
|
6400
|
+
_context63.next = 12;
|
|
6262
6401
|
return this.products.getProductsWithPrice(schedule_date, {
|
|
6263
6402
|
scheduleModule: this.getSchedule(),
|
|
6264
6403
|
schedule_datetime: schedule_datetime,
|
|
@@ -6268,7 +6407,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6268
6407
|
productIds: uniqueIds
|
|
6269
6408
|
});
|
|
6270
6409
|
case 12:
|
|
6271
|
-
productsWithPrice =
|
|
6410
|
+
productsWithPrice = _context63.sent;
|
|
6272
6411
|
perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
|
|
6273
6412
|
count: productsWithPrice.length,
|
|
6274
6413
|
ids: uniqueIds
|
|
@@ -6288,7 +6427,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6288
6427
|
ids: uniqueIds,
|
|
6289
6428
|
count: extensionFilteredProducts.length
|
|
6290
6429
|
});
|
|
6291
|
-
return
|
|
6430
|
+
return _context63.abrupt("return", {
|
|
6292
6431
|
code: 200,
|
|
6293
6432
|
data: {
|
|
6294
6433
|
list: extensionFilteredProducts,
|
|
@@ -6299,19 +6438,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
6299
6438
|
});
|
|
6300
6439
|
case 19:
|
|
6301
6440
|
if (!(product_id != null && Number.isFinite(Number(product_id)))) {
|
|
6302
|
-
|
|
6441
|
+
_context63.next = 31;
|
|
6303
6442
|
break;
|
|
6304
6443
|
}
|
|
6305
6444
|
pid = Number(product_id);
|
|
6306
6445
|
_tPrice2 = performance.now();
|
|
6307
|
-
|
|
6446
|
+
_context63.next = 24;
|
|
6308
6447
|
return this.products.getProductsWithPrice(schedule_date, {
|
|
6309
6448
|
scheduleModule: this.getSchedule()
|
|
6310
6449
|
}, {
|
|
6311
6450
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6312
6451
|
});
|
|
6313
6452
|
case 24:
|
|
6314
|
-
allProductsWithPrice =
|
|
6453
|
+
allProductsWithPrice = _context63.sent;
|
|
6315
6454
|
perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
|
|
6316
6455
|
count: allProductsWithPrice.length,
|
|
6317
6456
|
productId: pid
|
|
@@ -6331,7 +6470,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6331
6470
|
productId: pid,
|
|
6332
6471
|
found: !!item
|
|
6333
6472
|
});
|
|
6334
|
-
return
|
|
6473
|
+
return _context63.abrupt("return", {
|
|
6335
6474
|
code: 200,
|
|
6336
6475
|
data: item,
|
|
6337
6476
|
message: item ? '' : '商品不存在或未发布',
|
|
@@ -6339,11 +6478,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6339
6478
|
});
|
|
6340
6479
|
case 31:
|
|
6341
6480
|
if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
|
|
6342
|
-
|
|
6481
|
+
_context63.next = 51;
|
|
6343
6482
|
break;
|
|
6344
6483
|
}
|
|
6345
6484
|
_tPrice3 = performance.now();
|
|
6346
|
-
|
|
6485
|
+
_context63.next = 35;
|
|
6347
6486
|
return this.products.getProductsWithPrice(schedule_date, {
|
|
6348
6487
|
scheduleModule: this.getSchedule(),
|
|
6349
6488
|
schedule_datetime: schedule_datetime,
|
|
@@ -6352,7 +6491,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6352
6491
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6353
6492
|
});
|
|
6354
6493
|
case 35:
|
|
6355
|
-
_filteredProducts2 =
|
|
6494
|
+
_filteredProducts2 = _context63.sent;
|
|
6356
6495
|
perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
|
|
6357
6496
|
count: _filteredProducts2.length,
|
|
6358
6497
|
extension_type: extension_type
|
|
@@ -6391,7 +6530,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6391
6530
|
filteredCount: _filteredProducts2.length,
|
|
6392
6531
|
extension_type: extension_type
|
|
6393
6532
|
});
|
|
6394
|
-
return
|
|
6533
|
+
return _context63.abrupt("return", {
|
|
6395
6534
|
code: 200,
|
|
6396
6535
|
data: {
|
|
6397
6536
|
list: _filteredProducts2,
|
|
@@ -6402,11 +6541,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6402
6541
|
});
|
|
6403
6542
|
case 51:
|
|
6404
6543
|
if (this.menu) {
|
|
6405
|
-
|
|
6544
|
+
_context63.next = 54;
|
|
6406
6545
|
break;
|
|
6407
6546
|
}
|
|
6408
6547
|
this.logError('computeProductQueryResult: Menu 模块未注册');
|
|
6409
|
-
return
|
|
6548
|
+
return _context63.abrupt("return", {
|
|
6410
6549
|
message: 'Menu 模块未注册',
|
|
6411
6550
|
data: {
|
|
6412
6551
|
list: [],
|
|
@@ -6415,11 +6554,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6415
6554
|
});
|
|
6416
6555
|
case 54:
|
|
6417
6556
|
if (this.schedule) {
|
|
6418
|
-
|
|
6557
|
+
_context63.next = 57;
|
|
6419
6558
|
break;
|
|
6420
6559
|
}
|
|
6421
6560
|
this.logError('computeProductQueryResult: Schedule 模块未注册');
|
|
6422
|
-
return
|
|
6561
|
+
return _context63.abrupt("return", {
|
|
6423
6562
|
message: 'Schedule 模块未注册',
|
|
6424
6563
|
data: {
|
|
6425
6564
|
list: [],
|
|
@@ -6432,8 +6571,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
6432
6571
|
tMenu = performance.now();
|
|
6433
6572
|
menuList = this.menu.getMenuByIds(menu_list_ids);
|
|
6434
6573
|
activeMenuList = menuList.filter(function (menu) {
|
|
6435
|
-
var
|
|
6436
|
-
return ((
|
|
6574
|
+
var _this18$schedule;
|
|
6575
|
+
return ((_this18$schedule = _this18.schedule) === null || _this18$schedule === void 0 ? void 0 : _this18$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
|
|
6437
6576
|
});
|
|
6438
6577
|
perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
|
|
6439
6578
|
totalMenu: menuList.length,
|
|
@@ -6450,10 +6589,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
6450
6589
|
});
|
|
6451
6590
|
tPrice = performance.now();
|
|
6452
6591
|
if (!(scopedProductIds.length > 0)) {
|
|
6453
|
-
|
|
6592
|
+
_context63.next = 70;
|
|
6454
6593
|
break;
|
|
6455
6594
|
}
|
|
6456
|
-
|
|
6595
|
+
_context63.next = 67;
|
|
6457
6596
|
return this.products.getProductsWithPrice(schedule_date, {
|
|
6458
6597
|
scheduleModule: this.getSchedule(),
|
|
6459
6598
|
schedule_datetime: schedule_datetime,
|
|
@@ -6463,13 +6602,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6463
6602
|
productIds: productScope.isAllProducts ? undefined : scopedProductIds
|
|
6464
6603
|
});
|
|
6465
6604
|
case 67:
|
|
6466
|
-
|
|
6467
|
-
|
|
6605
|
+
_context63.t0 = _context63.sent;
|
|
6606
|
+
_context63.next = 71;
|
|
6468
6607
|
break;
|
|
6469
6608
|
case 70:
|
|
6470
|
-
|
|
6609
|
+
_context63.t0 = [];
|
|
6471
6610
|
case 71:
|
|
6472
|
-
filteredProducts =
|
|
6611
|
+
filteredProducts = _context63.t0;
|
|
6473
6612
|
perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
|
|
6474
6613
|
count: filteredProducts.length,
|
|
6475
6614
|
scopedProductCount: scopedProductIds.length
|
|
@@ -6510,7 +6649,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6510
6649
|
filteredCount: filteredProducts.length,
|
|
6511
6650
|
activeMenuCount: activeMenuList.length
|
|
6512
6651
|
});
|
|
6513
|
-
return
|
|
6652
|
+
return _context63.abrupt("return", {
|
|
6514
6653
|
code: 200,
|
|
6515
6654
|
data: {
|
|
6516
6655
|
list: filteredProducts,
|
|
@@ -6521,11 +6660,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6521
6660
|
});
|
|
6522
6661
|
case 87:
|
|
6523
6662
|
case "end":
|
|
6524
|
-
return
|
|
6663
|
+
return _context63.stop();
|
|
6525
6664
|
}
|
|
6526
|
-
},
|
|
6665
|
+
}, _callee63, this);
|
|
6527
6666
|
}));
|
|
6528
|
-
function computeProductQueryResult(
|
|
6667
|
+
function computeProductQueryResult(_x69, _x70) {
|
|
6529
6668
|
return _computeProductQueryResult.apply(this, arguments);
|
|
6530
6669
|
}
|
|
6531
6670
|
return computeProductQueryResult;
|
|
@@ -6540,72 +6679,72 @@ var Server = /*#__PURE__*/function () {
|
|
|
6540
6679
|
}, {
|
|
6541
6680
|
key: "recomputeAndNotifyProductQuery",
|
|
6542
6681
|
value: (function () {
|
|
6543
|
-
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6682
|
+
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(options) {
|
|
6544
6683
|
var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
|
|
6545
|
-
return _regeneratorRuntime().wrap(function
|
|
6546
|
-
while (1) switch (
|
|
6684
|
+
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
6685
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
6547
6686
|
case 0:
|
|
6548
6687
|
if (!(this.productQuerySubscribers.size === 0)) {
|
|
6549
|
-
|
|
6688
|
+
_context64.next = 2;
|
|
6550
6689
|
break;
|
|
6551
6690
|
}
|
|
6552
|
-
return
|
|
6691
|
+
return _context64.abrupt("return");
|
|
6553
6692
|
case 2:
|
|
6554
6693
|
this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
|
|
6555
6694
|
subscriberCount: this.productQuerySubscribers.size,
|
|
6556
6695
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6557
6696
|
});
|
|
6558
6697
|
_iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
|
|
6559
|
-
|
|
6698
|
+
_context64.prev = 4;
|
|
6560
6699
|
_iterator18.s();
|
|
6561
6700
|
case 6:
|
|
6562
6701
|
if ((_step18 = _iterator18.n()).done) {
|
|
6563
|
-
|
|
6702
|
+
_context64.next = 22;
|
|
6564
6703
|
break;
|
|
6565
6704
|
}
|
|
6566
6705
|
_step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
|
|
6567
|
-
|
|
6568
|
-
|
|
6706
|
+
_context64.prev = 8;
|
|
6707
|
+
_context64.next = 11;
|
|
6569
6708
|
return this.computeProductQueryResult(subscriber.context, {
|
|
6570
6709
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6571
6710
|
});
|
|
6572
6711
|
case 11:
|
|
6573
|
-
result =
|
|
6712
|
+
result = _context64.sent;
|
|
6574
6713
|
subscriber.callback(result);
|
|
6575
6714
|
this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
|
|
6576
6715
|
subscriberId: subscriberId
|
|
6577
6716
|
});
|
|
6578
|
-
|
|
6717
|
+
_context64.next = 20;
|
|
6579
6718
|
break;
|
|
6580
6719
|
case 16:
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
errorMessage =
|
|
6720
|
+
_context64.prev = 16;
|
|
6721
|
+
_context64.t0 = _context64["catch"](8);
|
|
6722
|
+
errorMessage = _context64.t0 instanceof Error ? _context64.t0.message : String(_context64.t0);
|
|
6584
6723
|
this.logError('recomputeAndNotifyProductQuery: 推送失败', {
|
|
6585
6724
|
subscriberId: subscriberId,
|
|
6586
6725
|
error: errorMessage
|
|
6587
6726
|
});
|
|
6588
6727
|
case 20:
|
|
6589
|
-
|
|
6728
|
+
_context64.next = 6;
|
|
6590
6729
|
break;
|
|
6591
6730
|
case 22:
|
|
6592
|
-
|
|
6731
|
+
_context64.next = 27;
|
|
6593
6732
|
break;
|
|
6594
6733
|
case 24:
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
_iterator18.e(
|
|
6734
|
+
_context64.prev = 24;
|
|
6735
|
+
_context64.t1 = _context64["catch"](4);
|
|
6736
|
+
_iterator18.e(_context64.t1);
|
|
6598
6737
|
case 27:
|
|
6599
|
-
|
|
6738
|
+
_context64.prev = 27;
|
|
6600
6739
|
_iterator18.f();
|
|
6601
|
-
return
|
|
6740
|
+
return _context64.finish(27);
|
|
6602
6741
|
case 30:
|
|
6603
6742
|
case "end":
|
|
6604
|
-
return
|
|
6743
|
+
return _context64.stop();
|
|
6605
6744
|
}
|
|
6606
|
-
},
|
|
6745
|
+
}, _callee64, this, [[4, 24, 27, 30], [8, 16]]);
|
|
6607
6746
|
}));
|
|
6608
|
-
function recomputeAndNotifyProductQuery(
|
|
6747
|
+
function recomputeAndNotifyProductQuery(_x71) {
|
|
6609
6748
|
return _recomputeAndNotifyProductQuery.apply(this, arguments);
|
|
6610
6749
|
}
|
|
6611
6750
|
return recomputeAndNotifyProductQuery;
|
|
@@ -6617,16 +6756,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
6617
6756
|
}, {
|
|
6618
6757
|
key: "recomputeAndNotifyOrderQuery",
|
|
6619
6758
|
value: (function () {
|
|
6620
|
-
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6759
|
+
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65() {
|
|
6621
6760
|
var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
|
|
6622
|
-
return _regeneratorRuntime().wrap(function
|
|
6623
|
-
while (1) switch (
|
|
6761
|
+
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
6762
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
6624
6763
|
case 0:
|
|
6625
6764
|
if (!(this.orderQuerySubscribers.size === 0)) {
|
|
6626
|
-
|
|
6765
|
+
_context65.next = 2;
|
|
6627
6766
|
break;
|
|
6628
6767
|
}
|
|
6629
|
-
return
|
|
6768
|
+
return _context65.abrupt("return");
|
|
6630
6769
|
case 2:
|
|
6631
6770
|
notifyStartAt = Date.now();
|
|
6632
6771
|
this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
|
|
@@ -6634,20 +6773,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
6634
6773
|
notifyStartAt: new Date(notifyStartAt).toISOString()
|
|
6635
6774
|
});
|
|
6636
6775
|
_iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
|
|
6637
|
-
|
|
6776
|
+
_context65.prev = 5;
|
|
6638
6777
|
_iterator19.s();
|
|
6639
6778
|
case 7:
|
|
6640
6779
|
if ((_step19 = _iterator19.n()).done) {
|
|
6641
|
-
|
|
6780
|
+
_context65.next = 27;
|
|
6642
6781
|
break;
|
|
6643
6782
|
}
|
|
6644
6783
|
_step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
|
|
6645
|
-
|
|
6784
|
+
_context65.prev = 9;
|
|
6646
6785
|
computeStartAt = Date.now();
|
|
6647
|
-
|
|
6786
|
+
_context65.next = 13;
|
|
6648
6787
|
return this.computeOrderQueryResult(subscriber.context);
|
|
6649
6788
|
case 13:
|
|
6650
|
-
result =
|
|
6789
|
+
result = _context65.sent;
|
|
6651
6790
|
computeEndAt = Date.now();
|
|
6652
6791
|
callbackStartAt = Date.now();
|
|
6653
6792
|
subscriber.callback(result);
|
|
@@ -6658,30 +6797,30 @@ var Server = /*#__PURE__*/function () {
|
|
|
6658
6797
|
callbackDurationMs: callbackEndAt - callbackStartAt,
|
|
6659
6798
|
totalDurationMs: callbackEndAt - computeStartAt
|
|
6660
6799
|
});
|
|
6661
|
-
|
|
6800
|
+
_context65.next = 25;
|
|
6662
6801
|
break;
|
|
6663
6802
|
case 21:
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
errorMessage =
|
|
6803
|
+
_context65.prev = 21;
|
|
6804
|
+
_context65.t0 = _context65["catch"](9);
|
|
6805
|
+
errorMessage = _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0);
|
|
6667
6806
|
this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
|
|
6668
6807
|
subscriberId: subscriberId,
|
|
6669
6808
|
error: errorMessage
|
|
6670
6809
|
});
|
|
6671
6810
|
case 25:
|
|
6672
|
-
|
|
6811
|
+
_context65.next = 7;
|
|
6673
6812
|
break;
|
|
6674
6813
|
case 27:
|
|
6675
|
-
|
|
6814
|
+
_context65.next = 32;
|
|
6676
6815
|
break;
|
|
6677
6816
|
case 29:
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
_iterator19.e(
|
|
6817
|
+
_context65.prev = 29;
|
|
6818
|
+
_context65.t1 = _context65["catch"](5);
|
|
6819
|
+
_iterator19.e(_context65.t1);
|
|
6681
6820
|
case 32:
|
|
6682
|
-
|
|
6821
|
+
_context65.prev = 32;
|
|
6683
6822
|
_iterator19.f();
|
|
6684
|
-
return
|
|
6823
|
+
return _context65.finish(32);
|
|
6685
6824
|
case 35:
|
|
6686
6825
|
notifyEndAt = Date.now();
|
|
6687
6826
|
this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
|
|
@@ -6690,9 +6829,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6690
6829
|
});
|
|
6691
6830
|
case 37:
|
|
6692
6831
|
case "end":
|
|
6693
|
-
return
|
|
6832
|
+
return _context65.stop();
|
|
6694
6833
|
}
|
|
6695
|
-
},
|
|
6834
|
+
}, _callee65, this, [[5, 29, 32, 35], [9, 21]]);
|
|
6696
6835
|
}));
|
|
6697
6836
|
function recomputeAndNotifyOrderQuery() {
|
|
6698
6837
|
return _recomputeAndNotifyOrderQuery.apply(this, arguments);
|
|
@@ -6710,7 +6849,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6710
6849
|
}, {
|
|
6711
6850
|
key: "notifySalesSearchSubscribers",
|
|
6712
6851
|
value: function notifySalesSearchSubscribers(payload) {
|
|
6713
|
-
var
|
|
6852
|
+
var _this19 = this;
|
|
6714
6853
|
if (this.salesSearchSubscribers.size === 0) return;
|
|
6715
6854
|
var changedOrders = this.extractChangedOrdersFromPayload(payload);
|
|
6716
6855
|
if (changedOrders.length === 0) {
|
|
@@ -6728,21 +6867,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
6728
6867
|
subscriber = _step20$value[1];
|
|
6729
6868
|
try {
|
|
6730
6869
|
var changedVisibleOrders = changedOrders.filter(function (order) {
|
|
6731
|
-
var orderId =
|
|
6870
|
+
var orderId = _this19.getSalesSearchOrderId(order);
|
|
6732
6871
|
return !!orderId && subscriber.visibleOrderIds.has(orderId);
|
|
6733
6872
|
});
|
|
6734
6873
|
if (changedVisibleOrders.length === 0) {
|
|
6735
6874
|
return 1; // continue
|
|
6736
6875
|
}
|
|
6737
|
-
subscriber.callback(
|
|
6738
|
-
|
|
6876
|
+
subscriber.callback(_this19.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
|
|
6877
|
+
_this19.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
|
|
6739
6878
|
subscriberId: subscriberId,
|
|
6740
6879
|
kind: subscriber.kind,
|
|
6741
6880
|
count: changedVisibleOrders.length
|
|
6742
6881
|
});
|
|
6743
6882
|
} catch (error) {
|
|
6744
6883
|
var errorMessage = error instanceof Error ? error.message : String(error);
|
|
6745
|
-
|
|
6884
|
+
_this19.logError('notifySalesSearchSubscribers: 推送失败', {
|
|
6746
6885
|
subscriberId: subscriberId,
|
|
6747
6886
|
error: errorMessage
|
|
6748
6887
|
});
|
|
@@ -6833,67 +6972,67 @@ var Server = /*#__PURE__*/function () {
|
|
|
6833
6972
|
}, {
|
|
6834
6973
|
key: "recomputeAndNotifyBookingQuery",
|
|
6835
6974
|
value: (function () {
|
|
6836
|
-
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6975
|
+
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66() {
|
|
6837
6976
|
var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
|
|
6838
|
-
return _regeneratorRuntime().wrap(function
|
|
6839
|
-
while (1) switch (
|
|
6977
|
+
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
6978
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
6840
6979
|
case 0:
|
|
6841
6980
|
if (!(this.bookingQuerySubscribers.size === 0)) {
|
|
6842
|
-
|
|
6981
|
+
_context66.next = 2;
|
|
6843
6982
|
break;
|
|
6844
6983
|
}
|
|
6845
|
-
return
|
|
6984
|
+
return _context66.abrupt("return");
|
|
6846
6985
|
case 2:
|
|
6847
6986
|
this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
|
|
6848
6987
|
subscriberCount: this.bookingQuerySubscribers.size
|
|
6849
6988
|
});
|
|
6850
6989
|
_iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
|
|
6851
|
-
|
|
6990
|
+
_context66.prev = 4;
|
|
6852
6991
|
_iterator21.s();
|
|
6853
6992
|
case 6:
|
|
6854
6993
|
if ((_step21 = _iterator21.n()).done) {
|
|
6855
|
-
|
|
6994
|
+
_context66.next = 22;
|
|
6856
6995
|
break;
|
|
6857
6996
|
}
|
|
6858
6997
|
_step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
|
|
6859
|
-
|
|
6860
|
-
|
|
6998
|
+
_context66.prev = 8;
|
|
6999
|
+
_context66.next = 11;
|
|
6861
7000
|
return this.computeBookingQueryResult(subscriber.context);
|
|
6862
7001
|
case 11:
|
|
6863
|
-
result =
|
|
7002
|
+
result = _context66.sent;
|
|
6864
7003
|
subscriber.callback(result);
|
|
6865
7004
|
this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
|
|
6866
7005
|
subscriberId: subscriberId
|
|
6867
7006
|
});
|
|
6868
|
-
|
|
7007
|
+
_context66.next = 20;
|
|
6869
7008
|
break;
|
|
6870
7009
|
case 16:
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
errorMessage =
|
|
7010
|
+
_context66.prev = 16;
|
|
7011
|
+
_context66.t0 = _context66["catch"](8);
|
|
7012
|
+
errorMessage = _context66.t0 instanceof Error ? _context66.t0.message : String(_context66.t0);
|
|
6874
7013
|
this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
|
|
6875
7014
|
subscriberId: subscriberId,
|
|
6876
7015
|
error: errorMessage
|
|
6877
7016
|
});
|
|
6878
7017
|
case 20:
|
|
6879
|
-
|
|
7018
|
+
_context66.next = 6;
|
|
6880
7019
|
break;
|
|
6881
7020
|
case 22:
|
|
6882
|
-
|
|
7021
|
+
_context66.next = 27;
|
|
6883
7022
|
break;
|
|
6884
7023
|
case 24:
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
_iterator21.e(
|
|
7024
|
+
_context66.prev = 24;
|
|
7025
|
+
_context66.t1 = _context66["catch"](4);
|
|
7026
|
+
_iterator21.e(_context66.t1);
|
|
6888
7027
|
case 27:
|
|
6889
|
-
|
|
7028
|
+
_context66.prev = 27;
|
|
6890
7029
|
_iterator21.f();
|
|
6891
|
-
return
|
|
7030
|
+
return _context66.finish(27);
|
|
6892
7031
|
case 30:
|
|
6893
7032
|
case "end":
|
|
6894
|
-
return
|
|
7033
|
+
return _context66.stop();
|
|
6895
7034
|
}
|
|
6896
|
-
},
|
|
7035
|
+
}, _callee66, this, [[4, 24, 27, 30], [8, 16]]);
|
|
6897
7036
|
}));
|
|
6898
7037
|
function recomputeAndNotifyBookingQuery() {
|
|
6899
7038
|
return _recomputeAndNotifyBookingQuery.apply(this, arguments);
|