@pisell/pisellos 2.3.20 → 2.3.22
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 +17 -7
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Order/utils.js +16 -4
- package/dist/server/index.d.ts +5 -0
- package/dist/server/index.js +428 -255
- package/dist/server/modules/order/types.d.ts +4 -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.d.ts +10 -0
- package/dist/solution/BaseSales/index.js +503 -428
- package/dist/solution/BaseSales/types.d.ts +6 -1
- package/dist/solution/BaseSales/types.js +1 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -1
- package/dist/solution/BookingTicket/index.js +42 -24
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
- package/lib/modules/Order/index.js +22 -7
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Order/utils.js +17 -3
- package/lib/server/index.d.ts +5 -0
- package/lib/server/index.js +121 -2
- package/lib/server/modules/order/types.d.ts +4 -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.d.ts +10 -0
- package/lib/solution/BaseSales/index.js +66 -23
- package/lib/solution/BaseSales/types.d.ts +6 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -0
- package/lib/solution/BookingTicket/index.js +15 -7
- 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,181 @@ 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
|
+
var addProductId = function addProductId(rawProductId) {
|
|
5127
|
+
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return;
|
|
5128
|
+
var productId = Number(rawProductId);
|
|
5129
|
+
if (Number.isFinite(productId)) productIds.add(productId);
|
|
5130
|
+
};
|
|
5131
|
+
products.forEach(function (product) {
|
|
5132
|
+
var _product$product_id2;
|
|
5133
|
+
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);
|
|
5134
|
+
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
5135
|
+
product.product_bundle.forEach(function (bundle) {
|
|
5136
|
+
var _ref61, _bundle$bundle_produc2;
|
|
5137
|
+
addProductId((_ref61 = (_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 && _ref61 !== void 0 ? _ref61 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
|
|
5138
|
+
});
|
|
5139
|
+
}
|
|
5140
|
+
});
|
|
5141
|
+
return Array.from(productIds);
|
|
5142
|
+
}
|
|
5143
|
+
}, {
|
|
5144
|
+
key: "buildSalesDetailProductSnapshotMap",
|
|
5145
|
+
value: function () {
|
|
5146
|
+
var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(order) {
|
|
5147
|
+
var _this$products2;
|
|
5148
|
+
var productIds, getSnapshots;
|
|
5149
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5150
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
5151
|
+
case 0:
|
|
5152
|
+
productIds = this.collectSalesDetailProductIds(order);
|
|
5153
|
+
getSnapshots = (_this$products2 = this.products) === null || _this$products2 === void 0 ? void 0 : _this$products2.getProductSnapshotsByIds;
|
|
5154
|
+
if (!(!productIds.length || typeof getSnapshots !== 'function')) {
|
|
5155
|
+
_context55.next = 4;
|
|
5156
|
+
break;
|
|
5157
|
+
}
|
|
5158
|
+
return _context55.abrupt("return", {});
|
|
5159
|
+
case 4:
|
|
5160
|
+
_context55.prev = 4;
|
|
5161
|
+
_context55.next = 7;
|
|
5162
|
+
return getSnapshots.call(this.products, productIds);
|
|
5163
|
+
case 7:
|
|
5164
|
+
return _context55.abrupt("return", _context55.sent);
|
|
5165
|
+
case 10:
|
|
5166
|
+
_context55.prev = 10;
|
|
5167
|
+
_context55.t0 = _context55["catch"](4);
|
|
5168
|
+
this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
|
|
5169
|
+
product_ids: productIds,
|
|
5170
|
+
error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
|
|
5171
|
+
});
|
|
5172
|
+
return _context55.abrupt("return", {});
|
|
5173
|
+
case 14:
|
|
5174
|
+
case "end":
|
|
5175
|
+
return _context55.stop();
|
|
5176
|
+
}
|
|
5177
|
+
}, _callee55, this, [[4, 10]]);
|
|
5178
|
+
}));
|
|
5179
|
+
function buildSalesDetailProductSnapshotMap(_x61) {
|
|
5180
|
+
return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
|
|
5181
|
+
}
|
|
5182
|
+
return buildSalesDetailProductSnapshotMap;
|
|
5183
|
+
}()
|
|
5184
|
+
}, {
|
|
5185
|
+
key: "withProductCatalogSnapshots",
|
|
5186
|
+
value: function withProductCatalogSnapshots(product, snapshotMap) {
|
|
5187
|
+
var _product$product_id3;
|
|
5188
|
+
if (!product || _typeof(product) !== 'object') return product;
|
|
5189
|
+
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;
|
|
5190
|
+
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return product;
|
|
5191
|
+
var productId = Number(rawProductId);
|
|
5192
|
+
if (!Number.isFinite(productId)) return product;
|
|
5193
|
+
var snapshot = snapshotMap[String(productId)];
|
|
5194
|
+
if (!snapshot) return product;
|
|
5195
|
+
var shouldFillCover = (product.product_cover === undefined || product.product_cover === null || product.product_cover === '') && snapshot.cover !== undefined && snapshot.cover !== null && snapshot.cover !== '';
|
|
5196
|
+
var metadata = product.metadata && _typeof(product.metadata) === 'object' ? product.metadata : {};
|
|
5197
|
+
var shouldFillHolderConfig = (metadata.holder_config === undefined || metadata.holder_config === null) && snapshot.holder_config !== undefined && snapshot.holder_config !== null;
|
|
5198
|
+
if (!shouldFillCover && !shouldFillHolderConfig) return product;
|
|
5199
|
+
return _objectSpread(_objectSpread(_objectSpread({}, product), shouldFillCover ? {
|
|
5200
|
+
product_cover: snapshot.cover
|
|
5201
|
+
} : {}), shouldFillHolderConfig ? {
|
|
5202
|
+
metadata: _objectSpread(_objectSpread({}, metadata), {}, {
|
|
5203
|
+
holder_config: snapshot.holder_config
|
|
5204
|
+
})
|
|
5205
|
+
} : {});
|
|
5206
|
+
}
|
|
5207
|
+
}, {
|
|
5208
|
+
key: "withBundleCatalogSnapshots",
|
|
5209
|
+
value: function withBundleCatalogSnapshots(product, snapshotMap) {
|
|
5210
|
+
if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
|
|
5211
|
+
var hasChanged = false;
|
|
5212
|
+
var productBundle = product.product_bundle.map(function (bundle) {
|
|
5213
|
+
var _ref62, _bundle$bundle_produc3;
|
|
5214
|
+
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
5215
|
+
var rawProductId = (_ref62 = (_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 && _ref62 !== void 0 ? _ref62 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
|
|
5216
|
+
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
|
|
5217
|
+
var productId = Number(rawProductId);
|
|
5218
|
+
if (!Number.isFinite(productId)) return bundle;
|
|
5219
|
+
var snapshot = snapshotMap[String(productId)];
|
|
5220
|
+
var shouldFillCover = (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && (snapshot === null || snapshot === void 0 ? void 0 : snapshot.cover) !== undefined && snapshot.cover !== null && snapshot.cover !== '';
|
|
5221
|
+
if (!shouldFillCover) return bundle;
|
|
5222
|
+
hasChanged = true;
|
|
5223
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
5224
|
+
cover: snapshot.cover
|
|
5225
|
+
});
|
|
5226
|
+
});
|
|
5227
|
+
if (!hasChanged) return product;
|
|
5228
|
+
return _objectSpread(_objectSpread({}, product), {}, {
|
|
5229
|
+
product_bundle: productBundle
|
|
5230
|
+
});
|
|
5231
|
+
}
|
|
5232
|
+
}, {
|
|
5233
|
+
key: "withSalesDetailProductSnapshots",
|
|
5234
|
+
value: function () {
|
|
5235
|
+
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(order) {
|
|
5236
|
+
var _this13 = this;
|
|
5237
|
+
var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
|
|
5238
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
5239
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
5240
|
+
case 0:
|
|
5241
|
+
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
|
|
5242
|
+
if (products !== null && products !== void 0 && products.length) {
|
|
5243
|
+
_context56.next = 3;
|
|
5244
|
+
break;
|
|
5245
|
+
}
|
|
5246
|
+
return _context56.abrupt("return", order);
|
|
5247
|
+
case 3:
|
|
5248
|
+
_context56.next = 5;
|
|
5249
|
+
return this.buildSalesDetailProductSnapshotMap(order);
|
|
5250
|
+
case 5:
|
|
5251
|
+
snapshotMap = _context56.sent;
|
|
5252
|
+
if (Object.keys(snapshotMap).length) {
|
|
5253
|
+
_context56.next = 8;
|
|
5254
|
+
break;
|
|
5255
|
+
}
|
|
5256
|
+
return _context56.abrupt("return", order);
|
|
5257
|
+
case 8:
|
|
5258
|
+
hasChanged = false;
|
|
5259
|
+
enrichedProducts = products.map(function (product) {
|
|
5260
|
+
var productWithBundleSnapshots = _this13.withBundleCatalogSnapshots(product, snapshotMap);
|
|
5261
|
+
var nextProduct = _this13.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
|
|
5262
|
+
if (nextProduct !== product) hasChanged = true;
|
|
5263
|
+
return nextProduct;
|
|
5264
|
+
});
|
|
5265
|
+
if (hasChanged) {
|
|
5266
|
+
_context56.next = 12;
|
|
5267
|
+
break;
|
|
5268
|
+
}
|
|
5269
|
+
return _context56.abrupt("return", order);
|
|
5270
|
+
case 12:
|
|
5271
|
+
enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
|
|
5272
|
+
products: enrichedProducts
|
|
5273
|
+
});
|
|
5274
|
+
return _context56.abrupt("return", enrichedOrder);
|
|
5275
|
+
case 14:
|
|
5276
|
+
case "end":
|
|
5277
|
+
return _context56.stop();
|
|
5278
|
+
}
|
|
5279
|
+
}, _callee56, this);
|
|
5280
|
+
}));
|
|
5281
|
+
function withSalesDetailProductSnapshots(_x62) {
|
|
5282
|
+
return _withSalesDetailProductSnapshots.apply(this, arguments);
|
|
5283
|
+
}
|
|
5284
|
+
return withSalesDetailProductSnapshots;
|
|
5285
|
+
}()
|
|
5113
5286
|
}, {
|
|
5114
5287
|
key: "withPendingSyncProductTitles",
|
|
5115
5288
|
value: function withPendingSyncProductTitles(order, productMap) {
|
|
5116
|
-
var
|
|
5289
|
+
var _this14 = this;
|
|
5117
5290
|
var products = Array.isArray(order.products) ? order.products : null;
|
|
5118
5291
|
if (!(products !== null && products !== void 0 && products.length)) return order;
|
|
5119
5292
|
return _objectSpread(_objectSpread({}, order), {}, {
|
|
5120
5293
|
products: products.map(function (product) {
|
|
5121
5294
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
5122
|
-
product_title:
|
|
5295
|
+
product_title: _this14.buildProductTitleSnapshot(product, productMap)
|
|
5123
5296
|
});
|
|
5124
5297
|
})
|
|
5125
5298
|
});
|
|
@@ -5127,18 +5300,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
5127
5300
|
}, {
|
|
5128
5301
|
key: "buildProductTitleSnapshot",
|
|
5129
5302
|
value: function buildProductTitleSnapshot(product, productMap) {
|
|
5130
|
-
var _product$
|
|
5303
|
+
var _product$product_id4,
|
|
5131
5304
|
_product$product,
|
|
5132
5305
|
_fallbackProduct$prod,
|
|
5133
|
-
|
|
5134
|
-
var productId = (_product$
|
|
5306
|
+
_this15 = this;
|
|
5307
|
+
var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
|
|
5135
5308
|
var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
|
|
5136
5309
|
var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
|
|
5137
5310
|
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
5311
|
var currentLocale = this.getProductTitleSnapshotCurrentLocale();
|
|
5139
5312
|
var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
|
|
5140
5313
|
return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
|
|
5141
|
-
snapshot[key] =
|
|
5314
|
+
snapshot[key] = _this15.resolveProductTitleValue(ownTitle, key, currentLocale) || _this15.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
|
|
5142
5315
|
return snapshot;
|
|
5143
5316
|
}, {});
|
|
5144
5317
|
}
|
|
@@ -5163,7 +5336,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5163
5336
|
}, {
|
|
5164
5337
|
key: "resolveProductTitleValue",
|
|
5165
5338
|
value: function resolveProductTitleValue(value, key, currentLocale) {
|
|
5166
|
-
var
|
|
5339
|
+
var _ref63, _ref64, _value$key;
|
|
5167
5340
|
if (value === undefined || value === null || value === '') return null;
|
|
5168
5341
|
if (_typeof(value) !== 'object') {
|
|
5169
5342
|
var title = String(value);
|
|
@@ -5173,7 +5346,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5173
5346
|
}
|
|
5174
5347
|
var normalizedKey = key.replace('-', '_');
|
|
5175
5348
|
var dashedKey = key.replace('_', '-');
|
|
5176
|
-
var rawValue = (
|
|
5349
|
+
var rawValue = (_ref63 = (_ref64 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref64 !== void 0 ? _ref64 : value[dashedKey]) !== null && _ref63 !== void 0 ? _ref63 : key === 'auto' ? value.default : undefined;
|
|
5177
5350
|
if (rawValue === undefined || rawValue === null || rawValue === '') return null;
|
|
5178
5351
|
if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
|
|
5179
5352
|
return String(rawValue);
|
|
@@ -5236,31 +5409,31 @@ var Server = /*#__PURE__*/function () {
|
|
|
5236
5409
|
}, {
|
|
5237
5410
|
key: "enrichPaymentNamesByCode",
|
|
5238
5411
|
value: function () {
|
|
5239
|
-
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5240
|
-
var
|
|
5412
|
+
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(order) {
|
|
5413
|
+
var _this16 = this;
|
|
5241
5414
|
var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
|
|
5242
|
-
return _regeneratorRuntime().wrap(function
|
|
5243
|
-
while (1) switch (
|
|
5415
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5416
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
5244
5417
|
case 0:
|
|
5245
5418
|
payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
|
|
5246
5419
|
hasMissingName = payments.some(function (payment) {
|
|
5247
|
-
return
|
|
5420
|
+
return _this16.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this16.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
|
|
5248
5421
|
});
|
|
5249
5422
|
if (hasMissingName) {
|
|
5250
|
-
|
|
5423
|
+
_context57.next = 4;
|
|
5251
5424
|
break;
|
|
5252
5425
|
}
|
|
5253
|
-
return
|
|
5426
|
+
return _context57.abrupt("return", order);
|
|
5254
5427
|
case 4:
|
|
5255
|
-
|
|
5256
|
-
|
|
5428
|
+
_context57.prev = 4;
|
|
5429
|
+
_context57.next = 7;
|
|
5257
5430
|
return this.getPaymentRouteModule();
|
|
5258
5431
|
case 7:
|
|
5259
|
-
paymentModule =
|
|
5260
|
-
|
|
5432
|
+
paymentModule = _context57.sent;
|
|
5433
|
+
_context57.next = 10;
|
|
5261
5434
|
return paymentModule.getPayMethodListAsync();
|
|
5262
5435
|
case 10:
|
|
5263
|
-
payMethods =
|
|
5436
|
+
payMethods = _context57.sent;
|
|
5264
5437
|
nameByCode = new Map();
|
|
5265
5438
|
_iterator12 = _createForOfIteratorHelper(payMethods || []);
|
|
5266
5439
|
try {
|
|
@@ -5277,9 +5450,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5277
5450
|
}
|
|
5278
5451
|
hasResolvedName = false;
|
|
5279
5452
|
enrichedPayments = payments.map(function (payment) {
|
|
5280
|
-
if (!
|
|
5281
|
-
if (!
|
|
5282
|
-
var name = nameByCode.get(
|
|
5453
|
+
if (!_this16.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
|
|
5454
|
+
if (!_this16.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
|
|
5455
|
+
var name = nameByCode.get(_this16.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
|
|
5283
5456
|
if (!name) return payment;
|
|
5284
5457
|
hasResolvedName = true;
|
|
5285
5458
|
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
@@ -5287,28 +5460,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
5287
5460
|
});
|
|
5288
5461
|
});
|
|
5289
5462
|
if (hasResolvedName) {
|
|
5290
|
-
|
|
5463
|
+
_context57.next = 18;
|
|
5291
5464
|
break;
|
|
5292
5465
|
}
|
|
5293
|
-
return
|
|
5466
|
+
return _context57.abrupt("return", order);
|
|
5294
5467
|
case 18:
|
|
5295
|
-
return
|
|
5468
|
+
return _context57.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
|
|
5296
5469
|
payments: enrichedPayments
|
|
5297
5470
|
}));
|
|
5298
5471
|
case 21:
|
|
5299
|
-
|
|
5300
|
-
|
|
5472
|
+
_context57.prev = 21;
|
|
5473
|
+
_context57.t0 = _context57["catch"](4);
|
|
5301
5474
|
this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
|
|
5302
|
-
error:
|
|
5475
|
+
error: _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0)
|
|
5303
5476
|
});
|
|
5304
|
-
return
|
|
5477
|
+
return _context57.abrupt("return", order);
|
|
5305
5478
|
case 25:
|
|
5306
5479
|
case "end":
|
|
5307
|
-
return
|
|
5480
|
+
return _context57.stop();
|
|
5308
5481
|
}
|
|
5309
|
-
},
|
|
5482
|
+
}, _callee57, this, [[4, 21]]);
|
|
5310
5483
|
}));
|
|
5311
|
-
function enrichPaymentNamesByCode(
|
|
5484
|
+
function enrichPaymentNamesByCode(_x63) {
|
|
5312
5485
|
return _enrichPaymentNamesByCode.apply(this, arguments);
|
|
5313
5486
|
}
|
|
5314
5487
|
return enrichPaymentNamesByCode;
|
|
@@ -5316,66 +5489,66 @@ var Server = /*#__PURE__*/function () {
|
|
|
5316
5489
|
}, {
|
|
5317
5490
|
key: "withLocalSmallTicketData",
|
|
5318
5491
|
value: function () {
|
|
5319
|
-
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5492
|
+
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(order, options) {
|
|
5320
5493
|
var _options$productMap, enrichedOrder, productMap, smallTicketData;
|
|
5321
|
-
return _regeneratorRuntime().wrap(function
|
|
5322
|
-
while (1) switch (
|
|
5494
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
5495
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
5323
5496
|
case 0:
|
|
5324
5497
|
if (this.shouldBuildSmallTicketData(order)) {
|
|
5325
|
-
|
|
5498
|
+
_context58.next = 2;
|
|
5326
5499
|
break;
|
|
5327
5500
|
}
|
|
5328
|
-
return
|
|
5501
|
+
return _context58.abrupt("return", order);
|
|
5329
5502
|
case 2:
|
|
5330
5503
|
if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
|
|
5331
|
-
|
|
5504
|
+
_context58.next = 4;
|
|
5332
5505
|
break;
|
|
5333
5506
|
}
|
|
5334
|
-
return
|
|
5507
|
+
return _context58.abrupt("return", order);
|
|
5335
5508
|
case 4:
|
|
5336
|
-
|
|
5337
|
-
|
|
5509
|
+
_context58.prev = 4;
|
|
5510
|
+
_context58.next = 7;
|
|
5338
5511
|
return this.enrichPaymentNamesByCode(order);
|
|
5339
5512
|
case 7:
|
|
5340
|
-
enrichedOrder =
|
|
5513
|
+
enrichedOrder = _context58.sent;
|
|
5341
5514
|
if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
|
|
5342
|
-
|
|
5515
|
+
_context58.next = 12;
|
|
5343
5516
|
break;
|
|
5344
5517
|
}
|
|
5345
|
-
|
|
5346
|
-
|
|
5518
|
+
_context58.t0 = _options$productMap;
|
|
5519
|
+
_context58.next = 15;
|
|
5347
5520
|
break;
|
|
5348
5521
|
case 12:
|
|
5349
|
-
|
|
5522
|
+
_context58.next = 14;
|
|
5350
5523
|
return this.buildSmallTicketProductMap(enrichedOrder);
|
|
5351
5524
|
case 14:
|
|
5352
|
-
|
|
5525
|
+
_context58.t0 = _context58.sent;
|
|
5353
5526
|
case 15:
|
|
5354
|
-
productMap =
|
|
5527
|
+
productMap = _context58.t0;
|
|
5355
5528
|
smallTicketData = buildSmallTicketData({
|
|
5356
5529
|
order: enrichedOrder,
|
|
5357
5530
|
shopInfo: this.getSmallTicketShopInfo(),
|
|
5358
5531
|
productMap: productMap
|
|
5359
5532
|
});
|
|
5360
|
-
return
|
|
5533
|
+
return _context58.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
|
|
5361
5534
|
payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
|
|
5362
5535
|
small_ticket_data: smallTicketData
|
|
5363
5536
|
})
|
|
5364
5537
|
}));
|
|
5365
5538
|
case 20:
|
|
5366
|
-
|
|
5367
|
-
|
|
5539
|
+
_context58.prev = 20;
|
|
5540
|
+
_context58.t1 = _context58["catch"](4);
|
|
5368
5541
|
this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
|
|
5369
|
-
error:
|
|
5542
|
+
error: _context58.t1 instanceof Error ? _context58.t1.message : String(_context58.t1)
|
|
5370
5543
|
});
|
|
5371
|
-
return
|
|
5544
|
+
return _context58.abrupt("return", order);
|
|
5372
5545
|
case 24:
|
|
5373
5546
|
case "end":
|
|
5374
|
-
return
|
|
5547
|
+
return _context58.stop();
|
|
5375
5548
|
}
|
|
5376
|
-
},
|
|
5549
|
+
}, _callee58, this, [[4, 20]]);
|
|
5377
5550
|
}));
|
|
5378
|
-
function withLocalSmallTicketData(
|
|
5551
|
+
function withLocalSmallTicketData(_x64, _x65) {
|
|
5379
5552
|
return _withLocalSmallTicketData.apply(this, arguments);
|
|
5380
5553
|
}
|
|
5381
5554
|
return withLocalSmallTicketData;
|
|
@@ -5437,22 +5610,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
5437
5610
|
}, {
|
|
5438
5611
|
key: "handleUpdateLocalOrdersBatch",
|
|
5439
5612
|
value: (function () {
|
|
5440
|
-
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5613
|
+
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(orderIds) {
|
|
5441
5614
|
var _this$app17;
|
|
5442
5615
|
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 (
|
|
5616
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context59) {
|
|
5617
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
5445
5618
|
case 0:
|
|
5446
5619
|
this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
|
|
5447
5620
|
count: orderIds.length,
|
|
5448
5621
|
orderIds: orderIds
|
|
5449
5622
|
});
|
|
5450
5623
|
if (this.order) {
|
|
5451
|
-
|
|
5624
|
+
_context59.next = 4;
|
|
5452
5625
|
break;
|
|
5453
5626
|
}
|
|
5454
5627
|
this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
|
|
5455
|
-
return
|
|
5628
|
+
return _context59.abrupt("return", {
|
|
5456
5629
|
code: 500,
|
|
5457
5630
|
status: false,
|
|
5458
5631
|
message: 'Order 模块未注册',
|
|
@@ -5460,11 +5633,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5460
5633
|
});
|
|
5461
5634
|
case 4:
|
|
5462
5635
|
if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && _this$app17.request) {
|
|
5463
|
-
|
|
5636
|
+
_context59.next = 7;
|
|
5464
5637
|
break;
|
|
5465
5638
|
}
|
|
5466
5639
|
this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
|
|
5467
|
-
return
|
|
5640
|
+
return _context59.abrupt("return", {
|
|
5468
5641
|
code: 500,
|
|
5469
5642
|
status: false,
|
|
5470
5643
|
message: 'app.request 不可用',
|
|
@@ -5487,21 +5660,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
5487
5660
|
_iterator13.f();
|
|
5488
5661
|
}
|
|
5489
5662
|
fetched = [];
|
|
5490
|
-
|
|
5491
|
-
|
|
5663
|
+
_context59.prev = 11;
|
|
5664
|
+
_context59.next = 14;
|
|
5492
5665
|
return this.order.fetchOrdersByHttp(orderIds);
|
|
5493
5666
|
case 14:
|
|
5494
|
-
fetched =
|
|
5495
|
-
|
|
5667
|
+
fetched = _context59.sent;
|
|
5668
|
+
_context59.next = 22;
|
|
5496
5669
|
break;
|
|
5497
5670
|
case 17:
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
message =
|
|
5671
|
+
_context59.prev = 17;
|
|
5672
|
+
_context59.t0 = _context59["catch"](11);
|
|
5673
|
+
message = _context59.t0 instanceof Error ? _context59.t0.message : String(_context59.t0);
|
|
5501
5674
|
this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
|
|
5502
5675
|
message: message
|
|
5503
5676
|
});
|
|
5504
|
-
return
|
|
5677
|
+
return _context59.abrupt("return", {
|
|
5505
5678
|
code: 500,
|
|
5506
5679
|
status: false,
|
|
5507
5680
|
message: message,
|
|
@@ -5511,36 +5684,36 @@ var Server = /*#__PURE__*/function () {
|
|
|
5511
5684
|
// 按返回结果中的 order_id 建索引,未命中即视为单笔失败
|
|
5512
5685
|
fetchedMap = new Map();
|
|
5513
5686
|
_iterator14 = _createForOfIteratorHelper(fetched);
|
|
5514
|
-
|
|
5687
|
+
_context59.prev = 24;
|
|
5515
5688
|
_iterator14.s();
|
|
5516
5689
|
case 26:
|
|
5517
5690
|
if ((_step14 = _iterator14.n()).done) {
|
|
5518
|
-
|
|
5691
|
+
_context59.next = 34;
|
|
5519
5692
|
break;
|
|
5520
5693
|
}
|
|
5521
5694
|
order = _step14.value;
|
|
5522
5695
|
oid = order === null || order === void 0 ? void 0 : order.order_id;
|
|
5523
5696
|
if (!(oid === undefined || oid === null)) {
|
|
5524
|
-
|
|
5697
|
+
_context59.next = 31;
|
|
5525
5698
|
break;
|
|
5526
5699
|
}
|
|
5527
|
-
return
|
|
5700
|
+
return _context59.abrupt("continue", 32);
|
|
5528
5701
|
case 31:
|
|
5529
5702
|
fetchedMap.set(String(oid), order);
|
|
5530
5703
|
case 32:
|
|
5531
|
-
|
|
5704
|
+
_context59.next = 26;
|
|
5532
5705
|
break;
|
|
5533
5706
|
case 34:
|
|
5534
|
-
|
|
5707
|
+
_context59.next = 39;
|
|
5535
5708
|
break;
|
|
5536
5709
|
case 36:
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
_iterator14.e(
|
|
5710
|
+
_context59.prev = 36;
|
|
5711
|
+
_context59.t1 = _context59["catch"](24);
|
|
5712
|
+
_iterator14.e(_context59.t1);
|
|
5540
5713
|
case 39:
|
|
5541
|
-
|
|
5714
|
+
_context59.prev = 39;
|
|
5542
5715
|
_iterator14.f();
|
|
5543
|
-
return
|
|
5716
|
+
return _context59.finish(39);
|
|
5544
5717
|
case 42:
|
|
5545
5718
|
freshOrders = [];
|
|
5546
5719
|
succeedIds = [];
|
|
@@ -5566,23 +5739,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
5566
5739
|
_iterator15.f();
|
|
5567
5740
|
}
|
|
5568
5741
|
if (!(freshOrders.length > 0)) {
|
|
5569
|
-
|
|
5742
|
+
_context59.next = 58;
|
|
5570
5743
|
break;
|
|
5571
5744
|
}
|
|
5572
|
-
|
|
5573
|
-
|
|
5745
|
+
_context59.prev = 48;
|
|
5746
|
+
_context59.next = 51;
|
|
5574
5747
|
return this.order.upsertOrdersFromRemote(freshOrders);
|
|
5575
5748
|
case 51:
|
|
5576
|
-
|
|
5749
|
+
_context59.next = 58;
|
|
5577
5750
|
break;
|
|
5578
5751
|
case 53:
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
_message2 =
|
|
5752
|
+
_context59.prev = 53;
|
|
5753
|
+
_context59.t2 = _context59["catch"](48);
|
|
5754
|
+
_message2 = _context59.t2 instanceof Error ? _context59.t2.message : String(_context59.t2);
|
|
5582
5755
|
this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
|
|
5583
5756
|
message: _message2
|
|
5584
5757
|
});
|
|
5585
|
-
return
|
|
5758
|
+
return _context59.abrupt("return", {
|
|
5586
5759
|
code: 500,
|
|
5587
5760
|
status: false,
|
|
5588
5761
|
message: _message2,
|
|
@@ -5601,7 +5774,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5601
5774
|
insertedCount: inserted.length,
|
|
5602
5775
|
failedCount: failed.length
|
|
5603
5776
|
});
|
|
5604
|
-
return
|
|
5777
|
+
return _context59.abrupt("return", {
|
|
5605
5778
|
code: 200,
|
|
5606
5779
|
status: true,
|
|
5607
5780
|
message: '',
|
|
@@ -5613,11 +5786,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5613
5786
|
});
|
|
5614
5787
|
case 62:
|
|
5615
5788
|
case "end":
|
|
5616
|
-
return
|
|
5789
|
+
return _context59.stop();
|
|
5617
5790
|
}
|
|
5618
|
-
},
|
|
5791
|
+
}, _callee59, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
|
|
5619
5792
|
}));
|
|
5620
|
-
function handleUpdateLocalOrdersBatch(
|
|
5793
|
+
function handleUpdateLocalOrdersBatch(_x66) {
|
|
5621
5794
|
return _handleUpdateLocalOrdersBatch.apply(this, arguments);
|
|
5622
5795
|
}
|
|
5623
5796
|
return handleUpdateLocalOrdersBatch;
|
|
@@ -5859,10 +6032,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5859
6032
|
value: function extractBackendErrorResponse(error) {
|
|
5860
6033
|
var _error$response3,
|
|
5861
6034
|
_error$response4,
|
|
5862
|
-
|
|
6035
|
+
_this17 = this;
|
|
5863
6036
|
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
6037
|
return candidates.find(function (candidate) {
|
|
5865
|
-
return
|
|
6038
|
+
return _this17.isExplicitBackendErrorResponse(candidate);
|
|
5866
6039
|
}) || null;
|
|
5867
6040
|
}
|
|
5868
6041
|
}, {
|
|
@@ -5981,16 +6154,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
5981
6154
|
}, {
|
|
5982
6155
|
key: "recomputeAndNotifyFloorPlanQuery",
|
|
5983
6156
|
value: (function () {
|
|
5984
|
-
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6157
|
+
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60() {
|
|
5985
6158
|
var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
|
|
5986
|
-
return _regeneratorRuntime().wrap(function
|
|
5987
|
-
while (1) switch (
|
|
6159
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
6160
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
5988
6161
|
case 0:
|
|
5989
6162
|
if (!(this.floorPlanQuerySubscribers.size === 0)) {
|
|
5990
|
-
|
|
6163
|
+
_context60.next = 2;
|
|
5991
6164
|
break;
|
|
5992
6165
|
}
|
|
5993
|
-
return
|
|
6166
|
+
return _context60.abrupt("return");
|
|
5994
6167
|
case 2:
|
|
5995
6168
|
this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
|
|
5996
6169
|
subscriberCount: this.floorPlanQuerySubscribers.size
|
|
@@ -6020,9 +6193,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6020
6193
|
}
|
|
6021
6194
|
case 5:
|
|
6022
6195
|
case "end":
|
|
6023
|
-
return
|
|
6196
|
+
return _context60.stop();
|
|
6024
6197
|
}
|
|
6025
|
-
},
|
|
6198
|
+
}, _callee60, this);
|
|
6026
6199
|
}));
|
|
6027
6200
|
function recomputeAndNotifyFloorPlanQuery() {
|
|
6028
6201
|
return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
|
|
@@ -6052,21 +6225,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
6052
6225
|
* filter 逻辑暂为 mock,仅记录参数
|
|
6053
6226
|
*/
|
|
6054
6227
|
function () {
|
|
6055
|
-
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6228
|
+
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(data) {
|
|
6056
6229
|
var rawList, result;
|
|
6057
|
-
return _regeneratorRuntime().wrap(function
|
|
6058
|
-
while (1) switch (
|
|
6230
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
6231
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
6059
6232
|
case 0:
|
|
6060
6233
|
this.logInfo('computeOrderQueryResult: 开始过滤', {
|
|
6061
6234
|
data: data
|
|
6062
6235
|
});
|
|
6063
6236
|
console.log('[Server] computeOrderQueryResult', data);
|
|
6064
6237
|
if (this.order) {
|
|
6065
|
-
|
|
6238
|
+
_context61.next = 5;
|
|
6066
6239
|
break;
|
|
6067
6240
|
}
|
|
6068
6241
|
this.logError('computeOrderQueryResult: Order 模块未注册');
|
|
6069
|
-
return
|
|
6242
|
+
return _context61.abrupt("return", {
|
|
6070
6243
|
code: 500,
|
|
6071
6244
|
message: 'Order 模块未注册',
|
|
6072
6245
|
data: {
|
|
@@ -6090,7 +6263,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6090
6263
|
skip: result.skip,
|
|
6091
6264
|
rejected: result.rejected
|
|
6092
6265
|
});
|
|
6093
|
-
return
|
|
6266
|
+
return _context61.abrupt("return", {
|
|
6094
6267
|
code: 200,
|
|
6095
6268
|
data: result,
|
|
6096
6269
|
message: '',
|
|
@@ -6098,11 +6271,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6098
6271
|
});
|
|
6099
6272
|
case 10:
|
|
6100
6273
|
case "end":
|
|
6101
|
-
return
|
|
6274
|
+
return _context61.stop();
|
|
6102
6275
|
}
|
|
6103
|
-
},
|
|
6276
|
+
}, _callee61, this);
|
|
6104
6277
|
}));
|
|
6105
|
-
function computeOrderQueryResult(
|
|
6278
|
+
function computeOrderQueryResult(_x67) {
|
|
6106
6279
|
return _computeOrderQueryResult.apply(this, arguments);
|
|
6107
6280
|
}
|
|
6108
6281
|
return computeOrderQueryResult;
|
|
@@ -6115,17 +6288,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
6115
6288
|
}, {
|
|
6116
6289
|
key: "computeBookingQueryResult",
|
|
6117
6290
|
value: (function () {
|
|
6118
|
-
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6291
|
+
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(data) {
|
|
6119
6292
|
var rawOrders, result;
|
|
6120
|
-
return _regeneratorRuntime().wrap(function
|
|
6121
|
-
while (1) switch (
|
|
6293
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
6294
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
6122
6295
|
case 0:
|
|
6123
6296
|
if (this.order) {
|
|
6124
|
-
|
|
6297
|
+
_context62.next = 3;
|
|
6125
6298
|
break;
|
|
6126
6299
|
}
|
|
6127
6300
|
this.logError('computeBookingQueryResult: Order 模块未注册');
|
|
6128
|
-
return
|
|
6301
|
+
return _context62.abrupt("return", {
|
|
6129
6302
|
code: 500,
|
|
6130
6303
|
message: 'Order 模块未注册',
|
|
6131
6304
|
data: {
|
|
@@ -6144,7 +6317,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6144
6317
|
size: result.size,
|
|
6145
6318
|
skip: result.skip
|
|
6146
6319
|
});
|
|
6147
|
-
return
|
|
6320
|
+
return _context62.abrupt("return", {
|
|
6148
6321
|
code: 200,
|
|
6149
6322
|
data: result,
|
|
6150
6323
|
message: '',
|
|
@@ -6152,11 +6325,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6152
6325
|
});
|
|
6153
6326
|
case 8:
|
|
6154
6327
|
case "end":
|
|
6155
|
-
return
|
|
6328
|
+
return _context62.stop();
|
|
6156
6329
|
}
|
|
6157
|
-
},
|
|
6330
|
+
}, _callee62, this);
|
|
6158
6331
|
}));
|
|
6159
|
-
function computeBookingQueryResult(
|
|
6332
|
+
function computeBookingQueryResult(_x68) {
|
|
6160
6333
|
return _computeBookingQueryResult.apply(this, arguments);
|
|
6161
6334
|
}
|
|
6162
6335
|
return computeBookingQueryResult;
|
|
@@ -6215,12 +6388,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
6215
6388
|
}, {
|
|
6216
6389
|
key: "computeProductQueryResult",
|
|
6217
6390
|
value: (function () {
|
|
6218
|
-
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6391
|
+
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(context, options) {
|
|
6219
6392
|
var _menu_list_ids$length3,
|
|
6220
|
-
|
|
6393
|
+
_this18 = this;
|
|
6221
6394
|
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 (
|
|
6395
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
6396
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
6224
6397
|
case 0:
|
|
6225
6398
|
tTotal = performance.now();
|
|
6226
6399
|
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 +6413,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6240
6413
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6241
6414
|
});
|
|
6242
6415
|
if (this.products) {
|
|
6243
|
-
|
|
6416
|
+
_context63.next = 7;
|
|
6244
6417
|
break;
|
|
6245
6418
|
}
|
|
6246
6419
|
this.logError('computeProductQueryResult: Products 模块未注册');
|
|
6247
|
-
return
|
|
6420
|
+
return _context63.abrupt("return", {
|
|
6248
6421
|
message: 'Products 模块未注册',
|
|
6249
6422
|
data: {
|
|
6250
6423
|
list: [],
|
|
@@ -6253,12 +6426,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
6253
6426
|
});
|
|
6254
6427
|
case 7:
|
|
6255
6428
|
if (!(queryIds.length > 0)) {
|
|
6256
|
-
|
|
6429
|
+
_context63.next = 19;
|
|
6257
6430
|
break;
|
|
6258
6431
|
}
|
|
6259
6432
|
uniqueIds = Array.from(new Set(queryIds));
|
|
6260
6433
|
_tPrice = performance.now();
|
|
6261
|
-
|
|
6434
|
+
_context63.next = 12;
|
|
6262
6435
|
return this.products.getProductsWithPrice(schedule_date, {
|
|
6263
6436
|
scheduleModule: this.getSchedule(),
|
|
6264
6437
|
schedule_datetime: schedule_datetime,
|
|
@@ -6268,7 +6441,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6268
6441
|
productIds: uniqueIds
|
|
6269
6442
|
});
|
|
6270
6443
|
case 12:
|
|
6271
|
-
productsWithPrice =
|
|
6444
|
+
productsWithPrice = _context63.sent;
|
|
6272
6445
|
perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
|
|
6273
6446
|
count: productsWithPrice.length,
|
|
6274
6447
|
ids: uniqueIds
|
|
@@ -6288,7 +6461,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6288
6461
|
ids: uniqueIds,
|
|
6289
6462
|
count: extensionFilteredProducts.length
|
|
6290
6463
|
});
|
|
6291
|
-
return
|
|
6464
|
+
return _context63.abrupt("return", {
|
|
6292
6465
|
code: 200,
|
|
6293
6466
|
data: {
|
|
6294
6467
|
list: extensionFilteredProducts,
|
|
@@ -6299,19 +6472,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
6299
6472
|
});
|
|
6300
6473
|
case 19:
|
|
6301
6474
|
if (!(product_id != null && Number.isFinite(Number(product_id)))) {
|
|
6302
|
-
|
|
6475
|
+
_context63.next = 31;
|
|
6303
6476
|
break;
|
|
6304
6477
|
}
|
|
6305
6478
|
pid = Number(product_id);
|
|
6306
6479
|
_tPrice2 = performance.now();
|
|
6307
|
-
|
|
6480
|
+
_context63.next = 24;
|
|
6308
6481
|
return this.products.getProductsWithPrice(schedule_date, {
|
|
6309
6482
|
scheduleModule: this.getSchedule()
|
|
6310
6483
|
}, {
|
|
6311
6484
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6312
6485
|
});
|
|
6313
6486
|
case 24:
|
|
6314
|
-
allProductsWithPrice =
|
|
6487
|
+
allProductsWithPrice = _context63.sent;
|
|
6315
6488
|
perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
|
|
6316
6489
|
count: allProductsWithPrice.length,
|
|
6317
6490
|
productId: pid
|
|
@@ -6331,7 +6504,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6331
6504
|
productId: pid,
|
|
6332
6505
|
found: !!item
|
|
6333
6506
|
});
|
|
6334
|
-
return
|
|
6507
|
+
return _context63.abrupt("return", {
|
|
6335
6508
|
code: 200,
|
|
6336
6509
|
data: item,
|
|
6337
6510
|
message: item ? '' : '商品不存在或未发布',
|
|
@@ -6339,11 +6512,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6339
6512
|
});
|
|
6340
6513
|
case 31:
|
|
6341
6514
|
if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
|
|
6342
|
-
|
|
6515
|
+
_context63.next = 51;
|
|
6343
6516
|
break;
|
|
6344
6517
|
}
|
|
6345
6518
|
_tPrice3 = performance.now();
|
|
6346
|
-
|
|
6519
|
+
_context63.next = 35;
|
|
6347
6520
|
return this.products.getProductsWithPrice(schedule_date, {
|
|
6348
6521
|
scheduleModule: this.getSchedule(),
|
|
6349
6522
|
schedule_datetime: schedule_datetime,
|
|
@@ -6352,7 +6525,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6352
6525
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6353
6526
|
});
|
|
6354
6527
|
case 35:
|
|
6355
|
-
_filteredProducts2 =
|
|
6528
|
+
_filteredProducts2 = _context63.sent;
|
|
6356
6529
|
perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
|
|
6357
6530
|
count: _filteredProducts2.length,
|
|
6358
6531
|
extension_type: extension_type
|
|
@@ -6391,7 +6564,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6391
6564
|
filteredCount: _filteredProducts2.length,
|
|
6392
6565
|
extension_type: extension_type
|
|
6393
6566
|
});
|
|
6394
|
-
return
|
|
6567
|
+
return _context63.abrupt("return", {
|
|
6395
6568
|
code: 200,
|
|
6396
6569
|
data: {
|
|
6397
6570
|
list: _filteredProducts2,
|
|
@@ -6402,11 +6575,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6402
6575
|
});
|
|
6403
6576
|
case 51:
|
|
6404
6577
|
if (this.menu) {
|
|
6405
|
-
|
|
6578
|
+
_context63.next = 54;
|
|
6406
6579
|
break;
|
|
6407
6580
|
}
|
|
6408
6581
|
this.logError('computeProductQueryResult: Menu 模块未注册');
|
|
6409
|
-
return
|
|
6582
|
+
return _context63.abrupt("return", {
|
|
6410
6583
|
message: 'Menu 模块未注册',
|
|
6411
6584
|
data: {
|
|
6412
6585
|
list: [],
|
|
@@ -6415,11 +6588,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6415
6588
|
});
|
|
6416
6589
|
case 54:
|
|
6417
6590
|
if (this.schedule) {
|
|
6418
|
-
|
|
6591
|
+
_context63.next = 57;
|
|
6419
6592
|
break;
|
|
6420
6593
|
}
|
|
6421
6594
|
this.logError('computeProductQueryResult: Schedule 模块未注册');
|
|
6422
|
-
return
|
|
6595
|
+
return _context63.abrupt("return", {
|
|
6423
6596
|
message: 'Schedule 模块未注册',
|
|
6424
6597
|
data: {
|
|
6425
6598
|
list: [],
|
|
@@ -6432,8 +6605,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
6432
6605
|
tMenu = performance.now();
|
|
6433
6606
|
menuList = this.menu.getMenuByIds(menu_list_ids);
|
|
6434
6607
|
activeMenuList = menuList.filter(function (menu) {
|
|
6435
|
-
var
|
|
6436
|
-
return ((
|
|
6608
|
+
var _this18$schedule;
|
|
6609
|
+
return ((_this18$schedule = _this18.schedule) === null || _this18$schedule === void 0 ? void 0 : _this18$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
|
|
6437
6610
|
});
|
|
6438
6611
|
perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
|
|
6439
6612
|
totalMenu: menuList.length,
|
|
@@ -6450,10 +6623,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
6450
6623
|
});
|
|
6451
6624
|
tPrice = performance.now();
|
|
6452
6625
|
if (!(scopedProductIds.length > 0)) {
|
|
6453
|
-
|
|
6626
|
+
_context63.next = 70;
|
|
6454
6627
|
break;
|
|
6455
6628
|
}
|
|
6456
|
-
|
|
6629
|
+
_context63.next = 67;
|
|
6457
6630
|
return this.products.getProductsWithPrice(schedule_date, {
|
|
6458
6631
|
scheduleModule: this.getSchedule(),
|
|
6459
6632
|
schedule_datetime: schedule_datetime,
|
|
@@ -6463,13 +6636,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6463
6636
|
productIds: productScope.isAllProducts ? undefined : scopedProductIds
|
|
6464
6637
|
});
|
|
6465
6638
|
case 67:
|
|
6466
|
-
|
|
6467
|
-
|
|
6639
|
+
_context63.t0 = _context63.sent;
|
|
6640
|
+
_context63.next = 71;
|
|
6468
6641
|
break;
|
|
6469
6642
|
case 70:
|
|
6470
|
-
|
|
6643
|
+
_context63.t0 = [];
|
|
6471
6644
|
case 71:
|
|
6472
|
-
filteredProducts =
|
|
6645
|
+
filteredProducts = _context63.t0;
|
|
6473
6646
|
perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
|
|
6474
6647
|
count: filteredProducts.length,
|
|
6475
6648
|
scopedProductCount: scopedProductIds.length
|
|
@@ -6510,7 +6683,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6510
6683
|
filteredCount: filteredProducts.length,
|
|
6511
6684
|
activeMenuCount: activeMenuList.length
|
|
6512
6685
|
});
|
|
6513
|
-
return
|
|
6686
|
+
return _context63.abrupt("return", {
|
|
6514
6687
|
code: 200,
|
|
6515
6688
|
data: {
|
|
6516
6689
|
list: filteredProducts,
|
|
@@ -6521,11 +6694,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6521
6694
|
});
|
|
6522
6695
|
case 87:
|
|
6523
6696
|
case "end":
|
|
6524
|
-
return
|
|
6697
|
+
return _context63.stop();
|
|
6525
6698
|
}
|
|
6526
|
-
},
|
|
6699
|
+
}, _callee63, this);
|
|
6527
6700
|
}));
|
|
6528
|
-
function computeProductQueryResult(
|
|
6701
|
+
function computeProductQueryResult(_x69, _x70) {
|
|
6529
6702
|
return _computeProductQueryResult.apply(this, arguments);
|
|
6530
6703
|
}
|
|
6531
6704
|
return computeProductQueryResult;
|
|
@@ -6540,72 +6713,72 @@ var Server = /*#__PURE__*/function () {
|
|
|
6540
6713
|
}, {
|
|
6541
6714
|
key: "recomputeAndNotifyProductQuery",
|
|
6542
6715
|
value: (function () {
|
|
6543
|
-
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6716
|
+
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(options) {
|
|
6544
6717
|
var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
|
|
6545
|
-
return _regeneratorRuntime().wrap(function
|
|
6546
|
-
while (1) switch (
|
|
6718
|
+
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
6719
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
6547
6720
|
case 0:
|
|
6548
6721
|
if (!(this.productQuerySubscribers.size === 0)) {
|
|
6549
|
-
|
|
6722
|
+
_context64.next = 2;
|
|
6550
6723
|
break;
|
|
6551
6724
|
}
|
|
6552
|
-
return
|
|
6725
|
+
return _context64.abrupt("return");
|
|
6553
6726
|
case 2:
|
|
6554
6727
|
this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
|
|
6555
6728
|
subscriberCount: this.productQuerySubscribers.size,
|
|
6556
6729
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6557
6730
|
});
|
|
6558
6731
|
_iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
|
|
6559
|
-
|
|
6732
|
+
_context64.prev = 4;
|
|
6560
6733
|
_iterator18.s();
|
|
6561
6734
|
case 6:
|
|
6562
6735
|
if ((_step18 = _iterator18.n()).done) {
|
|
6563
|
-
|
|
6736
|
+
_context64.next = 22;
|
|
6564
6737
|
break;
|
|
6565
6738
|
}
|
|
6566
6739
|
_step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
|
|
6567
|
-
|
|
6568
|
-
|
|
6740
|
+
_context64.prev = 8;
|
|
6741
|
+
_context64.next = 11;
|
|
6569
6742
|
return this.computeProductQueryResult(subscriber.context, {
|
|
6570
6743
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6571
6744
|
});
|
|
6572
6745
|
case 11:
|
|
6573
|
-
result =
|
|
6746
|
+
result = _context64.sent;
|
|
6574
6747
|
subscriber.callback(result);
|
|
6575
6748
|
this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
|
|
6576
6749
|
subscriberId: subscriberId
|
|
6577
6750
|
});
|
|
6578
|
-
|
|
6751
|
+
_context64.next = 20;
|
|
6579
6752
|
break;
|
|
6580
6753
|
case 16:
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
errorMessage =
|
|
6754
|
+
_context64.prev = 16;
|
|
6755
|
+
_context64.t0 = _context64["catch"](8);
|
|
6756
|
+
errorMessage = _context64.t0 instanceof Error ? _context64.t0.message : String(_context64.t0);
|
|
6584
6757
|
this.logError('recomputeAndNotifyProductQuery: 推送失败', {
|
|
6585
6758
|
subscriberId: subscriberId,
|
|
6586
6759
|
error: errorMessage
|
|
6587
6760
|
});
|
|
6588
6761
|
case 20:
|
|
6589
|
-
|
|
6762
|
+
_context64.next = 6;
|
|
6590
6763
|
break;
|
|
6591
6764
|
case 22:
|
|
6592
|
-
|
|
6765
|
+
_context64.next = 27;
|
|
6593
6766
|
break;
|
|
6594
6767
|
case 24:
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
_iterator18.e(
|
|
6768
|
+
_context64.prev = 24;
|
|
6769
|
+
_context64.t1 = _context64["catch"](4);
|
|
6770
|
+
_iterator18.e(_context64.t1);
|
|
6598
6771
|
case 27:
|
|
6599
|
-
|
|
6772
|
+
_context64.prev = 27;
|
|
6600
6773
|
_iterator18.f();
|
|
6601
|
-
return
|
|
6774
|
+
return _context64.finish(27);
|
|
6602
6775
|
case 30:
|
|
6603
6776
|
case "end":
|
|
6604
|
-
return
|
|
6777
|
+
return _context64.stop();
|
|
6605
6778
|
}
|
|
6606
|
-
},
|
|
6779
|
+
}, _callee64, this, [[4, 24, 27, 30], [8, 16]]);
|
|
6607
6780
|
}));
|
|
6608
|
-
function recomputeAndNotifyProductQuery(
|
|
6781
|
+
function recomputeAndNotifyProductQuery(_x71) {
|
|
6609
6782
|
return _recomputeAndNotifyProductQuery.apply(this, arguments);
|
|
6610
6783
|
}
|
|
6611
6784
|
return recomputeAndNotifyProductQuery;
|
|
@@ -6617,16 +6790,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
6617
6790
|
}, {
|
|
6618
6791
|
key: "recomputeAndNotifyOrderQuery",
|
|
6619
6792
|
value: (function () {
|
|
6620
|
-
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6793
|
+
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65() {
|
|
6621
6794
|
var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
|
|
6622
|
-
return _regeneratorRuntime().wrap(function
|
|
6623
|
-
while (1) switch (
|
|
6795
|
+
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
6796
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
6624
6797
|
case 0:
|
|
6625
6798
|
if (!(this.orderQuerySubscribers.size === 0)) {
|
|
6626
|
-
|
|
6799
|
+
_context65.next = 2;
|
|
6627
6800
|
break;
|
|
6628
6801
|
}
|
|
6629
|
-
return
|
|
6802
|
+
return _context65.abrupt("return");
|
|
6630
6803
|
case 2:
|
|
6631
6804
|
notifyStartAt = Date.now();
|
|
6632
6805
|
this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
|
|
@@ -6634,20 +6807,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
6634
6807
|
notifyStartAt: new Date(notifyStartAt).toISOString()
|
|
6635
6808
|
});
|
|
6636
6809
|
_iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
|
|
6637
|
-
|
|
6810
|
+
_context65.prev = 5;
|
|
6638
6811
|
_iterator19.s();
|
|
6639
6812
|
case 7:
|
|
6640
6813
|
if ((_step19 = _iterator19.n()).done) {
|
|
6641
|
-
|
|
6814
|
+
_context65.next = 27;
|
|
6642
6815
|
break;
|
|
6643
6816
|
}
|
|
6644
6817
|
_step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
|
|
6645
|
-
|
|
6818
|
+
_context65.prev = 9;
|
|
6646
6819
|
computeStartAt = Date.now();
|
|
6647
|
-
|
|
6820
|
+
_context65.next = 13;
|
|
6648
6821
|
return this.computeOrderQueryResult(subscriber.context);
|
|
6649
6822
|
case 13:
|
|
6650
|
-
result =
|
|
6823
|
+
result = _context65.sent;
|
|
6651
6824
|
computeEndAt = Date.now();
|
|
6652
6825
|
callbackStartAt = Date.now();
|
|
6653
6826
|
subscriber.callback(result);
|
|
@@ -6658,30 +6831,30 @@ var Server = /*#__PURE__*/function () {
|
|
|
6658
6831
|
callbackDurationMs: callbackEndAt - callbackStartAt,
|
|
6659
6832
|
totalDurationMs: callbackEndAt - computeStartAt
|
|
6660
6833
|
});
|
|
6661
|
-
|
|
6834
|
+
_context65.next = 25;
|
|
6662
6835
|
break;
|
|
6663
6836
|
case 21:
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
errorMessage =
|
|
6837
|
+
_context65.prev = 21;
|
|
6838
|
+
_context65.t0 = _context65["catch"](9);
|
|
6839
|
+
errorMessage = _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0);
|
|
6667
6840
|
this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
|
|
6668
6841
|
subscriberId: subscriberId,
|
|
6669
6842
|
error: errorMessage
|
|
6670
6843
|
});
|
|
6671
6844
|
case 25:
|
|
6672
|
-
|
|
6845
|
+
_context65.next = 7;
|
|
6673
6846
|
break;
|
|
6674
6847
|
case 27:
|
|
6675
|
-
|
|
6848
|
+
_context65.next = 32;
|
|
6676
6849
|
break;
|
|
6677
6850
|
case 29:
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
_iterator19.e(
|
|
6851
|
+
_context65.prev = 29;
|
|
6852
|
+
_context65.t1 = _context65["catch"](5);
|
|
6853
|
+
_iterator19.e(_context65.t1);
|
|
6681
6854
|
case 32:
|
|
6682
|
-
|
|
6855
|
+
_context65.prev = 32;
|
|
6683
6856
|
_iterator19.f();
|
|
6684
|
-
return
|
|
6857
|
+
return _context65.finish(32);
|
|
6685
6858
|
case 35:
|
|
6686
6859
|
notifyEndAt = Date.now();
|
|
6687
6860
|
this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
|
|
@@ -6690,9 +6863,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6690
6863
|
});
|
|
6691
6864
|
case 37:
|
|
6692
6865
|
case "end":
|
|
6693
|
-
return
|
|
6866
|
+
return _context65.stop();
|
|
6694
6867
|
}
|
|
6695
|
-
},
|
|
6868
|
+
}, _callee65, this, [[5, 29, 32, 35], [9, 21]]);
|
|
6696
6869
|
}));
|
|
6697
6870
|
function recomputeAndNotifyOrderQuery() {
|
|
6698
6871
|
return _recomputeAndNotifyOrderQuery.apply(this, arguments);
|
|
@@ -6710,7 +6883,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6710
6883
|
}, {
|
|
6711
6884
|
key: "notifySalesSearchSubscribers",
|
|
6712
6885
|
value: function notifySalesSearchSubscribers(payload) {
|
|
6713
|
-
var
|
|
6886
|
+
var _this19 = this;
|
|
6714
6887
|
if (this.salesSearchSubscribers.size === 0) return;
|
|
6715
6888
|
var changedOrders = this.extractChangedOrdersFromPayload(payload);
|
|
6716
6889
|
if (changedOrders.length === 0) {
|
|
@@ -6728,21 +6901,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
6728
6901
|
subscriber = _step20$value[1];
|
|
6729
6902
|
try {
|
|
6730
6903
|
var changedVisibleOrders = changedOrders.filter(function (order) {
|
|
6731
|
-
var orderId =
|
|
6904
|
+
var orderId = _this19.getSalesSearchOrderId(order);
|
|
6732
6905
|
return !!orderId && subscriber.visibleOrderIds.has(orderId);
|
|
6733
6906
|
});
|
|
6734
6907
|
if (changedVisibleOrders.length === 0) {
|
|
6735
6908
|
return 1; // continue
|
|
6736
6909
|
}
|
|
6737
|
-
subscriber.callback(
|
|
6738
|
-
|
|
6910
|
+
subscriber.callback(_this19.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
|
|
6911
|
+
_this19.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
|
|
6739
6912
|
subscriberId: subscriberId,
|
|
6740
6913
|
kind: subscriber.kind,
|
|
6741
6914
|
count: changedVisibleOrders.length
|
|
6742
6915
|
});
|
|
6743
6916
|
} catch (error) {
|
|
6744
6917
|
var errorMessage = error instanceof Error ? error.message : String(error);
|
|
6745
|
-
|
|
6918
|
+
_this19.logError('notifySalesSearchSubscribers: 推送失败', {
|
|
6746
6919
|
subscriberId: subscriberId,
|
|
6747
6920
|
error: errorMessage
|
|
6748
6921
|
});
|
|
@@ -6833,67 +7006,67 @@ var Server = /*#__PURE__*/function () {
|
|
|
6833
7006
|
}, {
|
|
6834
7007
|
key: "recomputeAndNotifyBookingQuery",
|
|
6835
7008
|
value: (function () {
|
|
6836
|
-
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7009
|
+
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66() {
|
|
6837
7010
|
var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
|
|
6838
|
-
return _regeneratorRuntime().wrap(function
|
|
6839
|
-
while (1) switch (
|
|
7011
|
+
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
7012
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
6840
7013
|
case 0:
|
|
6841
7014
|
if (!(this.bookingQuerySubscribers.size === 0)) {
|
|
6842
|
-
|
|
7015
|
+
_context66.next = 2;
|
|
6843
7016
|
break;
|
|
6844
7017
|
}
|
|
6845
|
-
return
|
|
7018
|
+
return _context66.abrupt("return");
|
|
6846
7019
|
case 2:
|
|
6847
7020
|
this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
|
|
6848
7021
|
subscriberCount: this.bookingQuerySubscribers.size
|
|
6849
7022
|
});
|
|
6850
7023
|
_iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
|
|
6851
|
-
|
|
7024
|
+
_context66.prev = 4;
|
|
6852
7025
|
_iterator21.s();
|
|
6853
7026
|
case 6:
|
|
6854
7027
|
if ((_step21 = _iterator21.n()).done) {
|
|
6855
|
-
|
|
7028
|
+
_context66.next = 22;
|
|
6856
7029
|
break;
|
|
6857
7030
|
}
|
|
6858
7031
|
_step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
|
|
6859
|
-
|
|
6860
|
-
|
|
7032
|
+
_context66.prev = 8;
|
|
7033
|
+
_context66.next = 11;
|
|
6861
7034
|
return this.computeBookingQueryResult(subscriber.context);
|
|
6862
7035
|
case 11:
|
|
6863
|
-
result =
|
|
7036
|
+
result = _context66.sent;
|
|
6864
7037
|
subscriber.callback(result);
|
|
6865
7038
|
this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
|
|
6866
7039
|
subscriberId: subscriberId
|
|
6867
7040
|
});
|
|
6868
|
-
|
|
7041
|
+
_context66.next = 20;
|
|
6869
7042
|
break;
|
|
6870
7043
|
case 16:
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
errorMessage =
|
|
7044
|
+
_context66.prev = 16;
|
|
7045
|
+
_context66.t0 = _context66["catch"](8);
|
|
7046
|
+
errorMessage = _context66.t0 instanceof Error ? _context66.t0.message : String(_context66.t0);
|
|
6874
7047
|
this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
|
|
6875
7048
|
subscriberId: subscriberId,
|
|
6876
7049
|
error: errorMessage
|
|
6877
7050
|
});
|
|
6878
7051
|
case 20:
|
|
6879
|
-
|
|
7052
|
+
_context66.next = 6;
|
|
6880
7053
|
break;
|
|
6881
7054
|
case 22:
|
|
6882
|
-
|
|
7055
|
+
_context66.next = 27;
|
|
6883
7056
|
break;
|
|
6884
7057
|
case 24:
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
_iterator21.e(
|
|
7058
|
+
_context66.prev = 24;
|
|
7059
|
+
_context66.t1 = _context66["catch"](4);
|
|
7060
|
+
_iterator21.e(_context66.t1);
|
|
6888
7061
|
case 27:
|
|
6889
|
-
|
|
7062
|
+
_context66.prev = 27;
|
|
6890
7063
|
_iterator21.f();
|
|
6891
|
-
return
|
|
7064
|
+
return _context66.finish(27);
|
|
6892
7065
|
case 30:
|
|
6893
7066
|
case "end":
|
|
6894
|
-
return
|
|
7067
|
+
return _context66.stop();
|
|
6895
7068
|
}
|
|
6896
|
-
},
|
|
7069
|
+
}, _callee66, this, [[4, 24, 27, 30], [8, 16]]);
|
|
6897
7070
|
}));
|
|
6898
7071
|
function recomputeAndNotifyBookingQuery() {
|
|
6899
7072
|
return _recomputeAndNotifyBookingQuery.apply(this, arguments);
|