@pisell/pisellos 2.2.261 → 2.2.262
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
- package/dist/model/strategy/adapter/index.d.ts +4 -0
- package/dist/model/strategy/adapter/index.js +5 -1
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
- package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/dist/model/strategy/adapter/promotion/examples.js +0 -99
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/dist/model/strategy/adapter/promotion/type.js +0 -45
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -10
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
- package/dist/modules/Discount/index.d.ts +5 -2
- package/dist/modules/Discount/index.js +30 -7
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +14 -2
- package/dist/modules/Order/index.js +1035 -736
- package/dist/modules/Order/types.d.ts +16 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
- package/dist/modules/Order/utils.d.ts +4 -3
- package/dist/modules/Order/utils.js +54 -61
- package/dist/modules/Product/types.d.ts +22 -0
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -2
- package/dist/modules/ProductList/types.d.ts +2 -0
- package/dist/modules/Rules/index.d.ts +2 -9
- package/dist/modules/Rules/index.js +69 -43
- package/dist/modules/Rules/types.d.ts +10 -1
- package/dist/server/index.d.ts +55 -0
- package/dist/server/index.js +1161 -742
- package/dist/server/modules/order/index.d.ts +10 -4
- package/dist/server/modules/order/index.js +404 -399
- package/dist/server/modules/order/types.d.ts +4 -0
- package/dist/server/modules/products/index.d.ts +31 -8
- package/dist/server/modules/products/index.js +549 -390
- package/dist/server/modules/products/types.d.ts +18 -0
- package/dist/solution/BaseSales/index.d.ts +21 -1
- package/dist/solution/BaseSales/index.js +1136 -789
- package/dist/solution/BaseSales/types.d.ts +6 -1
- package/dist/solution/BaseSales/types.js +1 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +48 -81
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +59 -25
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/ScanOrder/index.js +20 -31
- package/dist/solution/ShopDiscount/index.js +15 -14
- package/dist/solution/VenueBooking/index.js +19 -30
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
- package/lib/model/strategy/adapter/index.d.ts +4 -0
- package/lib/model/strategy/adapter/index.js +13 -2
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
- package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/lib/model/strategy/adapter/promotion/examples.js +0 -91
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/lib/model/strategy/adapter/promotion/type.js +0 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
- package/lib/modules/Discount/index.d.ts +5 -2
- package/lib/modules/Discount/index.js +23 -3
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +14 -2
- package/lib/modules/Order/index.js +326 -60
- package/lib/modules/Order/types.d.ts +16 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
- package/lib/modules/Order/utils.d.ts +4 -3
- package/lib/modules/Order/utils.js +22 -23
- package/lib/modules/Product/types.d.ts +22 -0
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +4 -2
- package/lib/modules/ProductList/types.d.ts +2 -0
- package/lib/modules/Rules/index.d.ts +2 -9
- package/lib/modules/Rules/index.js +61 -29
- package/lib/modules/Rules/types.d.ts +10 -1
- package/lib/server/index.d.ts +55 -0
- package/lib/server/index.js +327 -31
- package/lib/server/modules/order/index.d.ts +10 -4
- package/lib/server/modules/order/index.js +198 -139
- package/lib/server/modules/order/types.d.ts +4 -0
- package/lib/server/modules/products/index.d.ts +31 -8
- package/lib/server/modules/products/index.js +134 -35
- package/lib/server/modules/products/types.d.ts +18 -0
- package/lib/solution/BaseSales/index.d.ts +21 -1
- package/lib/solution/BaseSales/index.js +313 -72
- package/lib/solution/BaseSales/types.d.ts +6 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +29 -60
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +33 -8
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/ScanOrder/index.js +0 -8
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/lib/solution/VenueBooking/index.js +0 -8
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -93,6 +93,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
93
93
|
});
|
|
94
94
|
// ---- 商品查询订阅者 ----
|
|
95
95
|
_defineProperty(this, "productQuerySubscribers", new Map());
|
|
96
|
+
/** subscriberId → 智能定价变价时间点定时器句柄(与 subscriber 分离存储,便于 clear) */
|
|
97
|
+
_defineProperty(this, "productQueryScheduleTimers", new Map());
|
|
96
98
|
// ---- 订单 / 预约列表查询订阅者 ----
|
|
97
99
|
_defineProperty(this, "orderQuerySubscribers", new Map());
|
|
98
100
|
_defineProperty(this, "bookingQuerySubscribers", new Map());
|
|
@@ -271,13 +273,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
271
273
|
*/
|
|
272
274
|
_defineProperty(this, "handleProductQuery", /*#__PURE__*/function () {
|
|
273
275
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref5) {
|
|
274
|
-
var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, extension_type, _ref7, callback, subscriberId;
|
|
276
|
+
var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, extension_type, strategy_context, _ref7, callback, subscriberId, result;
|
|
275
277
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
276
278
|
while (1) switch (_context3.prev = _context3.next) {
|
|
277
279
|
case 0:
|
|
278
280
|
url = _ref5.url, method = _ref5.method, data = _ref5.data, config = _ref5.config;
|
|
279
281
|
console.log('[Server] handleProductQuery:', url, method, data, config);
|
|
280
|
-
menu_list_ids = data.menu_list_ids, schedule_datetime = data.schedule_datetime, schedule_date = data.schedule_date, customer_id = data.customer_id, ids = data.ids, extension_type = data.extension_type;
|
|
282
|
+
menu_list_ids = data.menu_list_ids, schedule_datetime = data.schedule_datetime, schedule_date = data.schedule_date, customer_id = data.customer_id, ids = data.ids, extension_type = data.extension_type, strategy_context = data.strategy_context;
|
|
281
283
|
_ref7 = config || {}, callback = _ref7.callback, subscriberId = _ref7.subscriberId;
|
|
282
284
|
_this.logInfo('handleProductQuery: 开始处理商品查询请求', {
|
|
283
285
|
menu_list_ids: menu_list_ids,
|
|
@@ -285,7 +287,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
285
287
|
schedule_datetime: schedule_datetime,
|
|
286
288
|
schedule_date: schedule_date,
|
|
287
289
|
customer_id: customer_id,
|
|
288
|
-
extension_type: extension_type
|
|
290
|
+
extension_type: extension_type,
|
|
291
|
+
strategyContextKeys: strategy_context ? Object.keys(strategy_context) : []
|
|
289
292
|
});
|
|
290
293
|
|
|
291
294
|
// 存储订阅者:后续 pubsub 数据变更时可通过 callback 推送最新结果
|
|
@@ -298,7 +301,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
298
301
|
schedule_date: schedule_date,
|
|
299
302
|
schedule_datetime: schedule_datetime,
|
|
300
303
|
customer_id: customer_id,
|
|
301
|
-
extension_type: extension_type
|
|
304
|
+
extension_type: extension_type,
|
|
305
|
+
strategy_context: strategy_context
|
|
302
306
|
}
|
|
303
307
|
});
|
|
304
308
|
_this.logInfo('handleProductQuery: 已注册订阅者', {
|
|
@@ -306,15 +310,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
306
310
|
totalSubscribers: _this.productQuerySubscribers.size
|
|
307
311
|
});
|
|
308
312
|
}
|
|
309
|
-
|
|
313
|
+
_context3.next = 8;
|
|
314
|
+
return _this.computeProductQueryResult({
|
|
310
315
|
menu_list_ids: menu_list_ids,
|
|
311
316
|
ids: ids,
|
|
312
317
|
schedule_date: schedule_date,
|
|
313
318
|
schedule_datetime: schedule_datetime,
|
|
314
319
|
customer_id: customer_id,
|
|
315
|
-
extension_type: extension_type
|
|
316
|
-
|
|
317
|
-
|
|
320
|
+
extension_type: extension_type,
|
|
321
|
+
strategy_context: strategy_context
|
|
322
|
+
});
|
|
323
|
+
case 8:
|
|
324
|
+
result = _context3.sent;
|
|
325
|
+
if (subscriberId && typeof callback === 'function') {
|
|
326
|
+
_this.syncProductQueryScheduleTimers(subscriberId, strategy_context);
|
|
327
|
+
}
|
|
328
|
+
return _context3.abrupt("return", result);
|
|
329
|
+
case 11:
|
|
318
330
|
case "end":
|
|
319
331
|
return _context3.stop();
|
|
320
332
|
}
|
|
@@ -1201,7 +1213,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1201
1213
|
_defineProperty(this, "handleOrderSalesDetail", /*#__PURE__*/function () {
|
|
1202
1214
|
var _ref45 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref44) {
|
|
1203
1215
|
var _this$app3;
|
|
1204
|
-
var url, data, path, requestPath, lookup, localOrder, backendPath, _response$data3, response, fresh, savedOrder, errorMessage;
|
|
1216
|
+
var url, data, path, requestPath, lookup, localOrder, enrichedOrder, backendPath, _response$data3, response, fresh, savedOrder, _enrichedOrder, errorMessage;
|
|
1205
1217
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1206
1218
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1207
1219
|
case 0:
|
|
@@ -1241,7 +1253,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1241
1253
|
});
|
|
1242
1254
|
case 10:
|
|
1243
1255
|
if (_this.shouldForceRemoteSalesDetail(data)) {
|
|
1244
|
-
_context18.next =
|
|
1256
|
+
_context18.next = 20;
|
|
1245
1257
|
break;
|
|
1246
1258
|
}
|
|
1247
1259
|
_context18.next = 13;
|
|
@@ -1249,9 +1261,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
1249
1261
|
case 13:
|
|
1250
1262
|
localOrder = _context18.sent;
|
|
1251
1263
|
if (!localOrder) {
|
|
1252
|
-
_context18.next =
|
|
1264
|
+
_context18.next = 20;
|
|
1253
1265
|
break;
|
|
1254
1266
|
}
|
|
1267
|
+
_context18.next = 17;
|
|
1268
|
+
return _this.withSalesDetailProductSnapshots(localOrder);
|
|
1269
|
+
case 17:
|
|
1270
|
+
enrichedOrder = _context18.sent;
|
|
1255
1271
|
_this.logInfo('handleOrderSalesDetail: 命中本地订单', {
|
|
1256
1272
|
lookup: lookup
|
|
1257
1273
|
});
|
|
@@ -1259,11 +1275,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
1259
1275
|
code: 200,
|
|
1260
1276
|
status: true,
|
|
1261
1277
|
message: '',
|
|
1262
|
-
data:
|
|
1278
|
+
data: enrichedOrder
|
|
1263
1279
|
});
|
|
1264
|
-
case
|
|
1280
|
+
case 20:
|
|
1265
1281
|
if ((_this$app3 = _this.app) !== null && _this$app3 !== void 0 && _this$app3.request) {
|
|
1266
|
-
_context18.next =
|
|
1282
|
+
_context18.next = 23;
|
|
1267
1283
|
break;
|
|
1268
1284
|
}
|
|
1269
1285
|
_this.logError('handleOrderSalesDetail: app.request 不可用');
|
|
@@ -1273,21 +1289,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
1273
1289
|
message: 'app.request 不可用',
|
|
1274
1290
|
data: null
|
|
1275
1291
|
});
|
|
1276
|
-
case
|
|
1292
|
+
case 23:
|
|
1277
1293
|
backendPath = _this.buildOrderSalesDetailBackendPath(lookup, data);
|
|
1278
|
-
_context18.prev =
|
|
1279
|
-
_context18.next =
|
|
1294
|
+
_context18.prev = 24;
|
|
1295
|
+
_context18.next = 27;
|
|
1280
1296
|
return _this.app.request.get(backendPath, {
|
|
1281
1297
|
lookup_mode: 'multi'
|
|
1282
1298
|
}, {
|
|
1283
1299
|
isShopApi: true,
|
|
1284
1300
|
customToast: function customToast() {}
|
|
1285
1301
|
});
|
|
1286
|
-
case
|
|
1302
|
+
case 27:
|
|
1287
1303
|
response = _context18.sent;
|
|
1288
1304
|
fresh = (_response$data3 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data3 !== void 0 ? _response$data3 : response;
|
|
1289
1305
|
if (!(!fresh || _typeof(fresh) !== 'object' || fresh.order_id == null)) {
|
|
1290
|
-
_context18.next =
|
|
1306
|
+
_context18.next = 32;
|
|
1291
1307
|
break;
|
|
1292
1308
|
}
|
|
1293
1309
|
_this.logInfo('handleOrderSalesDetail: 后端返回订单为空', {
|
|
@@ -1300,16 +1316,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
1300
1316
|
message: '后端返回订单为空',
|
|
1301
1317
|
data: null
|
|
1302
1318
|
});
|
|
1303
|
-
case
|
|
1304
|
-
_context18.next =
|
|
1319
|
+
case 32:
|
|
1320
|
+
_context18.next = 34;
|
|
1305
1321
|
return _this.order.upsertOrdersFromRemote([fresh]);
|
|
1306
|
-
case
|
|
1307
|
-
_context18.next =
|
|
1322
|
+
case 34:
|
|
1323
|
+
_context18.next = 36;
|
|
1308
1324
|
return _this.order.getLocalOrderByLookup(lookup);
|
|
1309
|
-
case
|
|
1325
|
+
case 36:
|
|
1310
1326
|
savedOrder = _context18.sent;
|
|
1311
1327
|
if (savedOrder) {
|
|
1312
|
-
_context18.next =
|
|
1328
|
+
_context18.next = 40;
|
|
1313
1329
|
break;
|
|
1314
1330
|
}
|
|
1315
1331
|
_this.logError('handleOrderSalesDetail: 订单写入后回读失败', {
|
|
@@ -1321,19 +1337,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
1321
1337
|
message: '订单写入后回读失败',
|
|
1322
1338
|
data: null
|
|
1323
1339
|
});
|
|
1324
|
-
case
|
|
1340
|
+
case 40:
|
|
1325
1341
|
_this.logInfo('handleOrderSalesDetail: 远端订单已同步到本地', {
|
|
1326
1342
|
lookup: lookup
|
|
1327
1343
|
});
|
|
1344
|
+
_context18.next = 43;
|
|
1345
|
+
return _this.withSalesDetailProductSnapshots(savedOrder);
|
|
1346
|
+
case 43:
|
|
1347
|
+
_enrichedOrder = _context18.sent;
|
|
1328
1348
|
return _context18.abrupt("return", {
|
|
1329
1349
|
code: 200,
|
|
1330
1350
|
status: true,
|
|
1331
1351
|
message: '',
|
|
1332
|
-
data:
|
|
1352
|
+
data: _enrichedOrder
|
|
1333
1353
|
});
|
|
1334
|
-
case
|
|
1335
|
-
_context18.prev =
|
|
1336
|
-
_context18.t0 = _context18["catch"](
|
|
1354
|
+
case 47:
|
|
1355
|
+
_context18.prev = 47;
|
|
1356
|
+
_context18.t0 = _context18["catch"](24);
|
|
1337
1357
|
errorMessage = _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0);
|
|
1338
1358
|
_this.logInfo('handleOrderSalesDetail: 请求失败', {
|
|
1339
1359
|
lookup: lookup,
|
|
@@ -1346,11 +1366,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
1346
1366
|
message: errorMessage,
|
|
1347
1367
|
data: null
|
|
1348
1368
|
});
|
|
1349
|
-
case
|
|
1369
|
+
case 52:
|
|
1350
1370
|
case "end":
|
|
1351
1371
|
return _context18.stop();
|
|
1352
1372
|
}
|
|
1353
|
-
}, _callee18, null, [[
|
|
1373
|
+
}, _callee18, null, [[24, 47]]);
|
|
1354
1374
|
}));
|
|
1355
1375
|
return function (_x18) {
|
|
1356
1376
|
return _ref45.apply(this, arguments);
|
|
@@ -3108,6 +3128,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3108
3128
|
key: "removeProductQuerySubscriber",
|
|
3109
3129
|
value: function removeProductQuerySubscriber(subscriberId) {
|
|
3110
3130
|
if (subscriberId) {
|
|
3131
|
+
this.clearSubscriberScheduleTimers(subscriberId);
|
|
3111
3132
|
this.productQuerySubscribers.delete(subscriberId);
|
|
3112
3133
|
this.logInfo('removeProductQuerySubscriber: 已移除订阅者', {
|
|
3113
3134
|
subscriberId: subscriberId,
|
|
@@ -3115,6 +3136,243 @@ var Server = /*#__PURE__*/function () {
|
|
|
3115
3136
|
});
|
|
3116
3137
|
}
|
|
3117
3138
|
}
|
|
3139
|
+
|
|
3140
|
+
/**
|
|
3141
|
+
* 构建商品 query 响应 data 段,附带智能定价 schedule_time_points 元数据。
|
|
3142
|
+
*/
|
|
3143
|
+
}, {
|
|
3144
|
+
key: "buildProductQueryResultPayload",
|
|
3145
|
+
value: function buildProductQueryResultPayload(list, count) {
|
|
3146
|
+
var _this$products$getLas, _this$products, _this$products$getLas2;
|
|
3147
|
+
return {
|
|
3148
|
+
list: list,
|
|
3149
|
+
count: count !== null && count !== void 0 ? count : list.length,
|
|
3150
|
+
schedule_time_points: (_this$products$getLas = (_this$products = this.products) === null || _this$products === void 0 || (_this$products$getLas2 = _this$products.getLastScheduleTimePoints) === null || _this$products$getLas2 === void 0 ? void 0 : _this$products$getLas2.call(_this$products)) !== null && _this$products$getLas !== void 0 ? _this$products$getLas : []
|
|
3151
|
+
};
|
|
3152
|
+
}
|
|
3153
|
+
|
|
3154
|
+
/**
|
|
3155
|
+
* 是否启用商品 query 订阅的 schedule 时间点定时重算。
|
|
3156
|
+
* strategy_context.enable_schedule_reload === false 时关闭。
|
|
3157
|
+
*/
|
|
3158
|
+
}, {
|
|
3159
|
+
key: "shouldScheduleProductQueryReload",
|
|
3160
|
+
value: function shouldScheduleProductQueryReload(strategy_context) {
|
|
3161
|
+
return (strategy_context === null || strategy_context === void 0 ? void 0 : strategy_context.enable_schedule_reload) !== false;
|
|
3162
|
+
}
|
|
3163
|
+
|
|
3164
|
+
/**
|
|
3165
|
+
* 清除指定 subscriber 的全部 schedule 定时器,防止重复 query 或 unsubscribe 后泄漏。
|
|
3166
|
+
*/
|
|
3167
|
+
}, {
|
|
3168
|
+
key: "clearSubscriberScheduleTimers",
|
|
3169
|
+
value: function clearSubscriberScheduleTimers(subscriberId) {
|
|
3170
|
+
var timers = this.productQueryScheduleTimers.get(subscriberId);
|
|
3171
|
+
if (timers !== null && timers !== void 0 && timers.length) {
|
|
3172
|
+
timers.forEach(function (timerId) {
|
|
3173
|
+
return clearTimeout(timerId);
|
|
3174
|
+
});
|
|
3175
|
+
}
|
|
3176
|
+
this.productQueryScheduleTimers.delete(subscriberId);
|
|
3177
|
+
var subscriber = this.productQuerySubscribers.get(subscriberId);
|
|
3178
|
+
if (subscriber) {
|
|
3179
|
+
subscriber.scheduleTimerIds = [];
|
|
3180
|
+
}
|
|
3181
|
+
}
|
|
3182
|
+
|
|
3183
|
+
/**
|
|
3184
|
+
* 从 productQueryScheduleTimers 移除已触发的 timer 引用。
|
|
3185
|
+
*/
|
|
3186
|
+
}, {
|
|
3187
|
+
key: "removeScheduleTimerRef",
|
|
3188
|
+
value: function removeScheduleTimerRef(subscriberId, timerId) {
|
|
3189
|
+
var timers = this.productQueryScheduleTimers.get(subscriberId);
|
|
3190
|
+
if (!(timers !== null && timers !== void 0 && timers.length)) return;
|
|
3191
|
+
var next = timers.filter(function (id) {
|
|
3192
|
+
return id !== timerId;
|
|
3193
|
+
});
|
|
3194
|
+
if (next.length === 0) {
|
|
3195
|
+
this.productQueryScheduleTimers.delete(subscriberId);
|
|
3196
|
+
} else {
|
|
3197
|
+
this.productQueryScheduleTimers.set(subscriberId, next);
|
|
3198
|
+
}
|
|
3199
|
+
var subscriber = this.productQuerySubscribers.get(subscriberId);
|
|
3200
|
+
if (subscriber) {
|
|
3201
|
+
subscriber.scheduleTimerIds = next;
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
|
|
3205
|
+
/**
|
|
3206
|
+
* 计算 schedule 变价时间点到当前时刻的延迟(ms)。已过期返回 -1。
|
|
3207
|
+
*/
|
|
3208
|
+
}, {
|
|
3209
|
+
key: "computeScheduleTimePointDelayMs",
|
|
3210
|
+
value: function computeScheduleTimePointDelayMs(scheduleDate, timePoint) {
|
|
3211
|
+
var parts = timePoint.split(':');
|
|
3212
|
+
if (parts.length < 2) return -1;
|
|
3213
|
+
var hours = parseInt(parts[0], 10);
|
|
3214
|
+
var minutes = parseInt(parts[1], 10);
|
|
3215
|
+
if (!Number.isFinite(hours) || !Number.isFinite(minutes)) return -1;
|
|
3216
|
+
var target = dayjs(scheduleDate).hour(hours).minute(minutes).second(4).millisecond(0);
|
|
3217
|
+
var delayMs = target.diff(dayjs());
|
|
3218
|
+
return delayMs >= 0 ? delayMs : -1;
|
|
3219
|
+
}
|
|
3220
|
+
|
|
3221
|
+
/**
|
|
3222
|
+
* 定时重算前刷新 subscriber schedule 上下文:使用执行瞬间时间,禁止沿用首次 query 的 schedule_datetime。
|
|
3223
|
+
*/
|
|
3224
|
+
}, {
|
|
3225
|
+
key: "refreshSubscriberScheduleAtExecution",
|
|
3226
|
+
value: function refreshSubscriberScheduleAtExecution(subscriber) {
|
|
3227
|
+
var executedAt = dayjs();
|
|
3228
|
+
var bookingDate = subscriber.context.schedule_date || executedAt.format('YYYY-MM-DD');
|
|
3229
|
+
subscriber.context.schedule_date = bookingDate;
|
|
3230
|
+
subscriber.context.schedule_datetime = "".concat(bookingDate, " ").concat(executedAt.format('HH:mm:ss'));
|
|
3231
|
+
}
|
|
3232
|
+
|
|
3233
|
+
/**
|
|
3234
|
+
* 为 subscriber 注册智能定价 scheduleTimePoints 定时重算。
|
|
3235
|
+
* 必须先 clearSubscriberScheduleTimers,再调用本方法。
|
|
3236
|
+
*/
|
|
3237
|
+
}, {
|
|
3238
|
+
key: "scheduleSubscriberTimePointReloads",
|
|
3239
|
+
value: function scheduleSubscriberTimePointReloads(subscriberId, timePoints) {
|
|
3240
|
+
var _this7 = this;
|
|
3241
|
+
var subscriber = this.productQuerySubscribers.get(subscriberId);
|
|
3242
|
+
if (!subscriber || !timePoints.length) return;
|
|
3243
|
+
var scheduleDate = subscriber.context.schedule_date || dayjs().format('YYYY-MM-DD');
|
|
3244
|
+
var timerIds = [];
|
|
3245
|
+
var _iterator5 = _createForOfIteratorHelper(timePoints),
|
|
3246
|
+
_step5;
|
|
3247
|
+
try {
|
|
3248
|
+
var _loop = function _loop() {
|
|
3249
|
+
var timePoint = _step5.value;
|
|
3250
|
+
var delayMs = _this7.computeScheduleTimePointDelayMs(scheduleDate, timePoint);
|
|
3251
|
+
if (delayMs < 0) return 1; // continue
|
|
3252
|
+
var timerId = setTimeout(function () {
|
|
3253
|
+
void _this7.onScheduleTimePointTimerFire(subscriberId, timerId);
|
|
3254
|
+
}, delayMs);
|
|
3255
|
+
timerIds.push(timerId);
|
|
3256
|
+
};
|
|
3257
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
3258
|
+
if (_loop()) continue;
|
|
3259
|
+
}
|
|
3260
|
+
} catch (err) {
|
|
3261
|
+
_iterator5.e(err);
|
|
3262
|
+
} finally {
|
|
3263
|
+
_iterator5.f();
|
|
3264
|
+
}
|
|
3265
|
+
if (timerIds.length > 0) {
|
|
3266
|
+
this.productQueryScheduleTimers.set(subscriberId, timerIds);
|
|
3267
|
+
subscriber.scheduleTimerIds = timerIds;
|
|
3268
|
+
this.logInfo('scheduleSubscriberTimePointReloads: 已注册定时器', {
|
|
3269
|
+
subscriberId: subscriberId,
|
|
3270
|
+
timerCount: timerIds.length,
|
|
3271
|
+
timePoints: timePoints
|
|
3272
|
+
});
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
|
|
3276
|
+
/**
|
|
3277
|
+
* schedule 变价时间点定时器触发:刷新 schedule_datetime 后重算并 callback。
|
|
3278
|
+
*/
|
|
3279
|
+
}, {
|
|
3280
|
+
key: "onScheduleTimePointTimerFire",
|
|
3281
|
+
value: (function () {
|
|
3282
|
+
var _onScheduleTimePointTimerFire = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(subscriberId, timerId) {
|
|
3283
|
+
var subscriber;
|
|
3284
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3285
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3286
|
+
case 0:
|
|
3287
|
+
this.removeScheduleTimerRef(subscriberId, timerId);
|
|
3288
|
+
if (this.productQuerySubscribers.has(subscriberId)) {
|
|
3289
|
+
_context38.next = 3;
|
|
3290
|
+
break;
|
|
3291
|
+
}
|
|
3292
|
+
return _context38.abrupt("return");
|
|
3293
|
+
case 3:
|
|
3294
|
+
subscriber = this.productQuerySubscribers.get(subscriberId);
|
|
3295
|
+
this.refreshSubscriberScheduleAtExecution(subscriber);
|
|
3296
|
+
_context38.next = 7;
|
|
3297
|
+
return this.recomputeAndNotifySubscriber(subscriberId);
|
|
3298
|
+
case 7:
|
|
3299
|
+
case "end":
|
|
3300
|
+
return _context38.stop();
|
|
3301
|
+
}
|
|
3302
|
+
}, _callee38, this);
|
|
3303
|
+
}));
|
|
3304
|
+
function onScheduleTimePointTimerFire(_x37, _x38) {
|
|
3305
|
+
return _onScheduleTimePointTimerFire.apply(this, arguments);
|
|
3306
|
+
}
|
|
3307
|
+
return onScheduleTimePointTimerFire;
|
|
3308
|
+
}()
|
|
3309
|
+
/**
|
|
3310
|
+
* 对单个商品 query 订阅者重算并推送(定时路径;不新建 schedule timer)。
|
|
3311
|
+
*/
|
|
3312
|
+
)
|
|
3313
|
+
}, {
|
|
3314
|
+
key: "recomputeAndNotifySubscriber",
|
|
3315
|
+
value: (function () {
|
|
3316
|
+
var _recomputeAndNotifySubscriber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(subscriberId) {
|
|
3317
|
+
var subscriber, result, errorMessage;
|
|
3318
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3319
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3320
|
+
case 0:
|
|
3321
|
+
subscriber = this.productQuerySubscribers.get(subscriberId);
|
|
3322
|
+
if (subscriber) {
|
|
3323
|
+
_context39.next = 3;
|
|
3324
|
+
break;
|
|
3325
|
+
}
|
|
3326
|
+
return _context39.abrupt("return");
|
|
3327
|
+
case 3:
|
|
3328
|
+
_context39.prev = 3;
|
|
3329
|
+
_context39.next = 6;
|
|
3330
|
+
return this.computeProductQueryResult(subscriber.context);
|
|
3331
|
+
case 6:
|
|
3332
|
+
result = _context39.sent;
|
|
3333
|
+
subscriber.callback(result);
|
|
3334
|
+
this.logInfo('recomputeAndNotifySubscriber: 已推送', {
|
|
3335
|
+
subscriberId: subscriberId,
|
|
3336
|
+
schedule_datetime: subscriber.context.schedule_datetime
|
|
3337
|
+
});
|
|
3338
|
+
_context39.next = 15;
|
|
3339
|
+
break;
|
|
3340
|
+
case 11:
|
|
3341
|
+
_context39.prev = 11;
|
|
3342
|
+
_context39.t0 = _context39["catch"](3);
|
|
3343
|
+
errorMessage = _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0);
|
|
3344
|
+
this.logError('recomputeAndNotifySubscriber: 推送失败', {
|
|
3345
|
+
subscriberId: subscriberId,
|
|
3346
|
+
error: errorMessage
|
|
3347
|
+
});
|
|
3348
|
+
case 15:
|
|
3349
|
+
case "end":
|
|
3350
|
+
return _context39.stop();
|
|
3351
|
+
}
|
|
3352
|
+
}, _callee39, this, [[3, 11]]);
|
|
3353
|
+
}));
|
|
3354
|
+
function recomputeAndNotifySubscriber(_x39) {
|
|
3355
|
+
return _recomputeAndNotifySubscriber.apply(this, arguments);
|
|
3356
|
+
}
|
|
3357
|
+
return recomputeAndNotifySubscriber;
|
|
3358
|
+
}()
|
|
3359
|
+
/**
|
|
3360
|
+
* query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
|
|
3361
|
+
*/
|
|
3362
|
+
)
|
|
3363
|
+
}, {
|
|
3364
|
+
key: "syncProductQueryScheduleTimers",
|
|
3365
|
+
value: function syncProductQueryScheduleTimers(subscriberId, strategy_context) {
|
|
3366
|
+
var _this$products$getLas3, _this$products2, _this$products2$getLa;
|
|
3367
|
+
this.clearSubscriberScheduleTimers(subscriberId);
|
|
3368
|
+
if (!this.shouldScheduleProductQueryReload(strategy_context)) {
|
|
3369
|
+
return;
|
|
3370
|
+
}
|
|
3371
|
+
var timePoints = (_this$products$getLas3 = (_this$products2 = this.products) === null || _this$products2 === void 0 || (_this$products2$getLa = _this$products2.getLastScheduleTimePoints) === null || _this$products2$getLa === void 0 ? void 0 : _this$products2$getLa.call(_this$products2)) !== null && _this$products$getLas3 !== void 0 ? _this$products$getLas3 : [];
|
|
3372
|
+
if (timePoints.length > 0) {
|
|
3373
|
+
this.scheduleSubscriberTimePointReloads(subscriberId, timePoints);
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3118
3376
|
}, {
|
|
3119
3377
|
key: "handleSalesSearchRequest",
|
|
3120
3378
|
value: (
|
|
@@ -3126,32 +3384,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
3126
3384
|
* const result = await this.handleSalesSearchRequest('single', '/shop/es/search/sales', { keyword: '1001' }, {})
|
|
3127
3385
|
*/
|
|
3128
3386
|
function () {
|
|
3129
|
-
var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3130
|
-
var queryPayload, result, _ref55, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds,
|
|
3131
|
-
return _regeneratorRuntime().wrap(function
|
|
3132
|
-
while (1) switch (
|
|
3387
|
+
var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(kind, backendPath, data, config) {
|
|
3388
|
+
var queryPayload, result, _ref55, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator6, _step6, orderId;
|
|
3389
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3390
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3133
3391
|
case 0:
|
|
3134
3392
|
queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
|
|
3135
|
-
|
|
3393
|
+
_context40.next = 3;
|
|
3136
3394
|
return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
|
|
3137
3395
|
case 3:
|
|
3138
|
-
result =
|
|
3396
|
+
result = _context40.sent;
|
|
3139
3397
|
_ref55 = config || {}, callback = _ref55.callback, subscriberId = _ref55.subscriberId, resetVisibleOrderIds = _ref55.resetVisibleOrderIds;
|
|
3140
3398
|
if (subscriberId && typeof callback === 'function') {
|
|
3141
3399
|
contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
|
|
3142
3400
|
existing = this.salesSearchSubscribers.get(subscriberId);
|
|
3143
3401
|
shouldReset = resetVisibleOrderIds === true || !existing || existing.kind !== kind || existing.contextSignature !== contextSignature;
|
|
3144
3402
|
visibleOrderIds = shouldReset ? new Set() : new Set(existing.visibleOrderIds);
|
|
3145
|
-
|
|
3403
|
+
_iterator6 = _createForOfIteratorHelper(this.extractSalesSearchOrderIds(kind, result));
|
|
3146
3404
|
try {
|
|
3147
|
-
for (
|
|
3148
|
-
orderId =
|
|
3405
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
3406
|
+
orderId = _step6.value;
|
|
3149
3407
|
visibleOrderIds.add(orderId);
|
|
3150
3408
|
}
|
|
3151
3409
|
} catch (err) {
|
|
3152
|
-
|
|
3410
|
+
_iterator6.e(err);
|
|
3153
3411
|
} finally {
|
|
3154
|
-
|
|
3412
|
+
_iterator6.f();
|
|
3155
3413
|
}
|
|
3156
3414
|
this.salesSearchSubscribers.set(subscriberId, {
|
|
3157
3415
|
callback: callback,
|
|
@@ -3167,14 +3425,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
3167
3425
|
visibleCount: visibleOrderIds.size
|
|
3168
3426
|
});
|
|
3169
3427
|
}
|
|
3170
|
-
return
|
|
3428
|
+
return _context40.abrupt("return", result);
|
|
3171
3429
|
case 7:
|
|
3172
3430
|
case "end":
|
|
3173
|
-
return
|
|
3431
|
+
return _context40.stop();
|
|
3174
3432
|
}
|
|
3175
|
-
},
|
|
3433
|
+
}, _callee40, this);
|
|
3176
3434
|
}));
|
|
3177
|
-
function handleSalesSearchRequest(
|
|
3435
|
+
function handleSalesSearchRequest(_x40, _x41, _x42, _x43) {
|
|
3178
3436
|
return _handleSalesSearchRequest.apply(this, arguments);
|
|
3179
3437
|
}
|
|
3180
3438
|
return handleSalesSearchRequest;
|
|
@@ -3189,20 +3447,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
3189
3447
|
}, {
|
|
3190
3448
|
key: "fetchSalesSearchFromAPI",
|
|
3191
3449
|
value: (function () {
|
|
3192
|
-
var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3450
|
+
var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(backendPath, data) {
|
|
3193
3451
|
var _this$app8;
|
|
3194
3452
|
var _response$data4, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
|
|
3195
|
-
return _regeneratorRuntime().wrap(function
|
|
3196
|
-
while (1) switch (
|
|
3453
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3454
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3197
3455
|
case 0:
|
|
3198
3456
|
if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
|
|
3199
|
-
|
|
3457
|
+
_context41.next = 3;
|
|
3200
3458
|
break;
|
|
3201
3459
|
}
|
|
3202
3460
|
this.logError('fetchSalesSearchFromAPI: app.request 不可用', {
|
|
3203
3461
|
backendPath: backendPath
|
|
3204
3462
|
});
|
|
3205
|
-
return
|
|
3463
|
+
return _context41.abrupt("return", {
|
|
3206
3464
|
code: 500,
|
|
3207
3465
|
message: 'app.request 不可用',
|
|
3208
3466
|
data: backendPath === '/shop/es/search' ? {
|
|
@@ -3214,29 +3472,29 @@ var Server = /*#__PURE__*/function () {
|
|
|
3214
3472
|
status: false
|
|
3215
3473
|
});
|
|
3216
3474
|
case 3:
|
|
3217
|
-
|
|
3218
|
-
|
|
3475
|
+
_context41.prev = 3;
|
|
3476
|
+
_context41.next = 6;
|
|
3219
3477
|
return this.app.request.post(backendPath, data, {
|
|
3220
3478
|
isShopApi: true
|
|
3221
3479
|
});
|
|
3222
3480
|
case 6:
|
|
3223
|
-
response =
|
|
3481
|
+
response = _context41.sent;
|
|
3224
3482
|
_payload = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
|
|
3225
|
-
return
|
|
3483
|
+
return _context41.abrupt("return", {
|
|
3226
3484
|
code: (_response$code2 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code2 !== void 0 ? _response$code2 : 200,
|
|
3227
3485
|
status: (_response$status2 = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status2 !== void 0 ? _response$status2 : true,
|
|
3228
3486
|
message: (_response$message2 = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message2 !== void 0 ? _response$message2 : '',
|
|
3229
3487
|
data: _payload
|
|
3230
3488
|
});
|
|
3231
3489
|
case 11:
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
errorMessage =
|
|
3490
|
+
_context41.prev = 11;
|
|
3491
|
+
_context41.t0 = _context41["catch"](3);
|
|
3492
|
+
errorMessage = _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0);
|
|
3235
3493
|
this.logError('fetchSalesSearchFromAPI: 请求失败', {
|
|
3236
3494
|
backendPath: backendPath,
|
|
3237
3495
|
error: errorMessage
|
|
3238
3496
|
});
|
|
3239
|
-
return
|
|
3497
|
+
return _context41.abrupt("return", {
|
|
3240
3498
|
code: 500,
|
|
3241
3499
|
message: errorMessage,
|
|
3242
3500
|
data: backendPath === '/shop/es/search' ? {
|
|
@@ -3249,11 +3507,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3249
3507
|
});
|
|
3250
3508
|
case 16:
|
|
3251
3509
|
case "end":
|
|
3252
|
-
return
|
|
3510
|
+
return _context41.stop();
|
|
3253
3511
|
}
|
|
3254
|
-
},
|
|
3512
|
+
}, _callee41, this, [[3, 11]]);
|
|
3255
3513
|
}));
|
|
3256
|
-
function fetchSalesSearchFromAPI(
|
|
3514
|
+
function fetchSalesSearchFromAPI(_x44, _x45) {
|
|
3257
3515
|
return _fetchSalesSearchFromAPI.apply(this, arguments);
|
|
3258
3516
|
}
|
|
3259
3517
|
return fetchSalesSearchFromAPI;
|
|
@@ -3283,10 +3541,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
3283
3541
|
}, {
|
|
3284
3542
|
key: "stripSalesSearchPageParams",
|
|
3285
3543
|
value: function stripSalesSearchPageParams(value) {
|
|
3286
|
-
var
|
|
3544
|
+
var _this8 = this;
|
|
3287
3545
|
if (Array.isArray(value)) {
|
|
3288
3546
|
return value.map(function (item) {
|
|
3289
|
-
return
|
|
3547
|
+
return _this8.stripSalesSearchPageParams(item);
|
|
3290
3548
|
});
|
|
3291
3549
|
}
|
|
3292
3550
|
if (!value || _typeof(value) !== 'object') return value;
|
|
@@ -3324,12 +3582,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
3324
3582
|
key: "extractSalesSearchOrderIds",
|
|
3325
3583
|
value: function extractSalesSearchOrderIds(kind, result) {
|
|
3326
3584
|
var _this$findSalesSearch,
|
|
3327
|
-
|
|
3585
|
+
_this9 = this;
|
|
3328
3586
|
var data = this.extractSalesSearchResponseData(result);
|
|
3329
3587
|
var list = kind === 'aggregate' ? (_this$findSalesSearch = this.findSalesSearchAggregateGroup(data)) === null || _this$findSalesSearch === void 0 ? void 0 : _this$findSalesSearch.list : data === null || data === void 0 ? void 0 : data.list;
|
|
3330
3588
|
if (!Array.isArray(list)) return [];
|
|
3331
3589
|
return list.map(function (item) {
|
|
3332
|
-
return
|
|
3590
|
+
return _this9.getSalesSearchOrderId(item);
|
|
3333
3591
|
}).filter(function (id) {
|
|
3334
3592
|
return !!id;
|
|
3335
3593
|
});
|
|
@@ -3496,11 +3754,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3496
3754
|
}, {
|
|
3497
3755
|
key: "stableSerialize",
|
|
3498
3756
|
value: function stableSerialize(value) {
|
|
3499
|
-
var
|
|
3757
|
+
var _this10 = this;
|
|
3500
3758
|
if (value === null || value === undefined) return 'null';
|
|
3501
3759
|
if (Array.isArray(value)) {
|
|
3502
3760
|
return "[".concat(value.map(function (item) {
|
|
3503
|
-
return
|
|
3761
|
+
return _this10.stableSerialize(item);
|
|
3504
3762
|
}).join(','), "]");
|
|
3505
3763
|
}
|
|
3506
3764
|
if (_typeof(value) === 'object') {
|
|
@@ -3509,7 +3767,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3509
3767
|
return obj[k] !== undefined;
|
|
3510
3768
|
}).sort();
|
|
3511
3769
|
return "{".concat(keys.map(function (k) {
|
|
3512
|
-
return "".concat(JSON.stringify(k), ":").concat(
|
|
3770
|
+
return "".concat(JSON.stringify(k), ":").concat(_this10.stableSerialize(obj[k]));
|
|
3513
3771
|
}).join(','), "}");
|
|
3514
3772
|
}
|
|
3515
3773
|
return JSON.stringify(value);
|
|
@@ -3558,22 +3816,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
3558
3816
|
}
|
|
3559
3817
|
var oldestKey = null;
|
|
3560
3818
|
var oldestTime = Number.POSITIVE_INFINITY;
|
|
3561
|
-
var
|
|
3562
|
-
|
|
3819
|
+
var _iterator7 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
|
|
3820
|
+
_step7;
|
|
3563
3821
|
try {
|
|
3564
|
-
for (
|
|
3565
|
-
var
|
|
3566
|
-
_key3 =
|
|
3567
|
-
cache =
|
|
3822
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
3823
|
+
var _step7$value = _slicedToArray(_step7.value, 2),
|
|
3824
|
+
_key3 = _step7$value[0],
|
|
3825
|
+
cache = _step7$value[1];
|
|
3568
3826
|
if (cache.updatedAt < oldestTime) {
|
|
3569
3827
|
oldestTime = cache.updatedAt;
|
|
3570
3828
|
oldestKey = _key3;
|
|
3571
3829
|
}
|
|
3572
3830
|
}
|
|
3573
3831
|
} catch (err) {
|
|
3574
|
-
|
|
3832
|
+
_iterator7.e(err);
|
|
3575
3833
|
} finally {
|
|
3576
|
-
|
|
3834
|
+
_iterator7.f();
|
|
3577
3835
|
}
|
|
3578
3836
|
if (oldestKey) this.bookingRemoteCache.delete(oldestKey);
|
|
3579
3837
|
}
|
|
@@ -3589,17 +3847,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
3589
3847
|
key: "markBookingRemoteCacheAllStale",
|
|
3590
3848
|
value: function markBookingRemoteCacheAllStale(reason) {
|
|
3591
3849
|
if (this.bookingRemoteCache.size === 0) return;
|
|
3592
|
-
var
|
|
3593
|
-
|
|
3850
|
+
var _iterator8 = _createForOfIteratorHelper(this.bookingRemoteCache.values()),
|
|
3851
|
+
_step8;
|
|
3594
3852
|
try {
|
|
3595
|
-
for (
|
|
3596
|
-
var entry =
|
|
3853
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
3854
|
+
var entry = _step8.value;
|
|
3597
3855
|
entry.stale = true;
|
|
3598
3856
|
}
|
|
3599
3857
|
} catch (err) {
|
|
3600
|
-
|
|
3858
|
+
_iterator8.e(err);
|
|
3601
3859
|
} finally {
|
|
3602
|
-
|
|
3860
|
+
_iterator8.f();
|
|
3603
3861
|
}
|
|
3604
3862
|
this.logWarning('bookingRemoteCache: 全量标记失效', {
|
|
3605
3863
|
reason: reason,
|
|
@@ -3625,13 +3883,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
3625
3883
|
key: "notifyBookingRemoteSubscribersByCacheKey",
|
|
3626
3884
|
value: function notifyBookingRemoteSubscribersByCacheKey(cacheKey, entry, reason) {
|
|
3627
3885
|
if (this.bookingRemoteQuerySubscribers.size === 0) return;
|
|
3628
|
-
var
|
|
3629
|
-
|
|
3886
|
+
var _iterator9 = _createForOfIteratorHelper(this.bookingRemoteQuerySubscribers.entries()),
|
|
3887
|
+
_step9;
|
|
3630
3888
|
try {
|
|
3631
|
-
for (
|
|
3632
|
-
var
|
|
3633
|
-
subscriberId =
|
|
3634
|
-
subscriber =
|
|
3889
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
3890
|
+
var _step9$value = _slicedToArray(_step9.value, 2),
|
|
3891
|
+
subscriberId = _step9$value[0],
|
|
3892
|
+
subscriber = _step9$value[1];
|
|
3635
3893
|
if (subscriber.cacheKey !== cacheKey) continue;
|
|
3636
3894
|
try {
|
|
3637
3895
|
var callbackStartAt = Date.now();
|
|
@@ -3658,9 +3916,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
3658
3916
|
}
|
|
3659
3917
|
}
|
|
3660
3918
|
} catch (err) {
|
|
3661
|
-
|
|
3919
|
+
_iterator9.e(err);
|
|
3662
3920
|
} finally {
|
|
3663
|
-
|
|
3921
|
+
_iterator9.f();
|
|
3664
3922
|
}
|
|
3665
3923
|
}
|
|
3666
3924
|
}, {
|
|
@@ -3675,13 +3933,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
3675
3933
|
return;
|
|
3676
3934
|
}
|
|
3677
3935
|
var syncedEntryCount = 0;
|
|
3678
|
-
var
|
|
3679
|
-
|
|
3936
|
+
var _iterator10 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
|
|
3937
|
+
_step10;
|
|
3680
3938
|
try {
|
|
3681
|
-
for (
|
|
3682
|
-
var
|
|
3683
|
-
cacheKey =
|
|
3684
|
-
entry =
|
|
3939
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
3940
|
+
var _step10$value = _slicedToArray(_step10.value, 2),
|
|
3941
|
+
cacheKey = _step10$value[0],
|
|
3942
|
+
entry = _step10$value[1];
|
|
3685
3943
|
if (entry.stale) {
|
|
3686
3944
|
this.bookingRemoteCache.delete(cacheKey);
|
|
3687
3945
|
continue;
|
|
@@ -3689,25 +3947,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
3689
3947
|
try {
|
|
3690
3948
|
var queryPayload = entry.queryPayload;
|
|
3691
3949
|
var orderMap = new Map();
|
|
3692
|
-
var
|
|
3693
|
-
|
|
3950
|
+
var _iterator11 = _createForOfIteratorHelper(entry.rawOrders),
|
|
3951
|
+
_step11;
|
|
3694
3952
|
try {
|
|
3695
|
-
for (
|
|
3696
|
-
var order =
|
|
3953
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
3954
|
+
var order = _step11.value;
|
|
3697
3955
|
var _key4 = this.toOrderIdKey(order);
|
|
3698
3956
|
if (_key4) orderMap.set(_key4, order);
|
|
3699
3957
|
}
|
|
3700
3958
|
} catch (err) {
|
|
3701
|
-
|
|
3959
|
+
_iterator11.e(err);
|
|
3702
3960
|
} finally {
|
|
3703
|
-
|
|
3961
|
+
_iterator11.f();
|
|
3704
3962
|
}
|
|
3705
3963
|
var changed = false;
|
|
3706
|
-
var
|
|
3707
|
-
|
|
3964
|
+
var _iterator12 = _createForOfIteratorHelper(latestOrders),
|
|
3965
|
+
_step12;
|
|
3708
3966
|
try {
|
|
3709
|
-
for (
|
|
3710
|
-
var latest =
|
|
3967
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
3968
|
+
var latest = _step12.value;
|
|
3711
3969
|
var _key5 = this.toOrderIdKey(latest);
|
|
3712
3970
|
if (!_key5) continue;
|
|
3713
3971
|
if (orderMap.has(_key5)) {
|
|
@@ -3719,9 +3977,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
3719
3977
|
changed = true;
|
|
3720
3978
|
}
|
|
3721
3979
|
} catch (err) {
|
|
3722
|
-
|
|
3980
|
+
_iterator12.e(err);
|
|
3723
3981
|
} finally {
|
|
3724
|
-
|
|
3982
|
+
_iterator12.f();
|
|
3725
3983
|
}
|
|
3726
3984
|
if (!changed) continue;
|
|
3727
3985
|
var mergedOrders = _toConsumableArray(orderMap.values());
|
|
@@ -3754,9 +4012,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
3754
4012
|
}
|
|
3755
4013
|
}
|
|
3756
4014
|
} catch (err) {
|
|
3757
|
-
|
|
4015
|
+
_iterator10.e(err);
|
|
3758
4016
|
} finally {
|
|
3759
|
-
|
|
4017
|
+
_iterator10.f();
|
|
3760
4018
|
}
|
|
3761
4019
|
var syncEndAt = Date.now();
|
|
3762
4020
|
if (syncedEntryCount > 0) {
|
|
@@ -3774,18 +4032,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
3774
4032
|
}, {
|
|
3775
4033
|
key: "fetchOrderListFromAPI",
|
|
3776
4034
|
value: (function () {
|
|
3777
|
-
var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4035
|
+
var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(data) {
|
|
3778
4036
|
var _this$app9;
|
|
3779
4037
|
var _response$data5, response, _payload2, list, count, errorMessage;
|
|
3780
|
-
return _regeneratorRuntime().wrap(function
|
|
3781
|
-
while (1) switch (
|
|
4038
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
4039
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
3782
4040
|
case 0:
|
|
3783
4041
|
if ((_this$app9 = this.app) !== null && _this$app9 !== void 0 && _this$app9.request) {
|
|
3784
|
-
|
|
4042
|
+
_context42.next = 3;
|
|
3785
4043
|
break;
|
|
3786
4044
|
}
|
|
3787
4045
|
this.logError('fetchOrderListFromAPI: app.request 不可用');
|
|
3788
|
-
return
|
|
4046
|
+
return _context42.abrupt("return", {
|
|
3789
4047
|
code: 500,
|
|
3790
4048
|
message: 'app.request 不可用',
|
|
3791
4049
|
data: {
|
|
@@ -3795,17 +4053,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
3795
4053
|
status: false
|
|
3796
4054
|
});
|
|
3797
4055
|
case 3:
|
|
3798
|
-
|
|
3799
|
-
|
|
4056
|
+
_context42.prev = 3;
|
|
4057
|
+
_context42.next = 6;
|
|
3800
4058
|
return this.app.request.post('/shop/order/v2/list', data, {
|
|
3801
4059
|
isShopApi: true
|
|
3802
4060
|
});
|
|
3803
4061
|
case 6:
|
|
3804
|
-
response =
|
|
4062
|
+
response = _context42.sent;
|
|
3805
4063
|
_payload2 = (_response$data5 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data5 !== void 0 ? _response$data5 : response;
|
|
3806
4064
|
list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
|
|
3807
4065
|
count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
|
|
3808
|
-
return
|
|
4066
|
+
return _context42.abrupt("return", {
|
|
3809
4067
|
code: 200,
|
|
3810
4068
|
data: _objectSpread(_objectSpread({}, _payload2), {}, {
|
|
3811
4069
|
list: list,
|
|
@@ -3815,13 +4073,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
3815
4073
|
status: true
|
|
3816
4074
|
});
|
|
3817
4075
|
case 13:
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
errorMessage =
|
|
4076
|
+
_context42.prev = 13;
|
|
4077
|
+
_context42.t0 = _context42["catch"](3);
|
|
4078
|
+
errorMessage = _context42.t0 instanceof Error ? _context42.t0.message : String(_context42.t0);
|
|
3821
4079
|
this.logError('fetchOrderListFromAPI: 请求失败', {
|
|
3822
4080
|
error: errorMessage
|
|
3823
4081
|
});
|
|
3824
|
-
return
|
|
4082
|
+
return _context42.abrupt("return", {
|
|
3825
4083
|
code: 500,
|
|
3826
4084
|
message: errorMessage,
|
|
3827
4085
|
data: {
|
|
@@ -3832,11 +4090,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3832
4090
|
});
|
|
3833
4091
|
case 18:
|
|
3834
4092
|
case "end":
|
|
3835
|
-
return
|
|
4093
|
+
return _context42.stop();
|
|
3836
4094
|
}
|
|
3837
|
-
},
|
|
4095
|
+
}, _callee42, this, [[3, 13]]);
|
|
3838
4096
|
}));
|
|
3839
|
-
function fetchOrderListFromAPI(
|
|
4097
|
+
function fetchOrderListFromAPI(_x46) {
|
|
3840
4098
|
return _fetchOrderListFromAPI.apply(this, arguments);
|
|
3841
4099
|
}
|
|
3842
4100
|
return fetchOrderListFromAPI;
|
|
@@ -3848,17 +4106,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
3848
4106
|
}, {
|
|
3849
4107
|
key: "fetchBookingListFromAPI",
|
|
3850
4108
|
value: (function () {
|
|
3851
|
-
var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4109
|
+
var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(data) {
|
|
3852
4110
|
var memoryCacheEnabled, withFields, requestPayload, cacheKey, cached, rawList, bookingResult, _bookingResult$list, errorMessage;
|
|
3853
|
-
return _regeneratorRuntime().wrap(function
|
|
3854
|
-
while (1) switch (
|
|
4111
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4112
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
3855
4113
|
case 0:
|
|
3856
4114
|
if (this.order) {
|
|
3857
|
-
|
|
4115
|
+
_context43.next = 3;
|
|
3858
4116
|
break;
|
|
3859
4117
|
}
|
|
3860
4118
|
this.logError('fetchBookingListFromAPI: Order 模块不可用');
|
|
3861
|
-
return
|
|
4119
|
+
return _context43.abrupt("return", {
|
|
3862
4120
|
code: 500,
|
|
3863
4121
|
message: 'Order 模块不可用',
|
|
3864
4122
|
data: {
|
|
@@ -3868,18 +4126,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
3868
4126
|
status: false
|
|
3869
4127
|
});
|
|
3870
4128
|
case 3:
|
|
3871
|
-
|
|
4129
|
+
_context43.prev = 3;
|
|
3872
4130
|
memoryCacheEnabled = this.isBookingRemoteMemoryCacheEnabled(data);
|
|
3873
4131
|
withFields = this.resolveBookingSalesWith(data);
|
|
3874
4132
|
requestPayload = this.normalizeBookingRemoteQueryPayload(data, withFields);
|
|
3875
4133
|
cacheKey = this.buildBookingRemoteCacheKey(requestPayload);
|
|
3876
4134
|
if (!memoryCacheEnabled) {
|
|
3877
|
-
|
|
4135
|
+
_context43.next = 13;
|
|
3878
4136
|
break;
|
|
3879
4137
|
}
|
|
3880
4138
|
cached = this.readBookingRemoteCache(cacheKey);
|
|
3881
4139
|
if (!cached) {
|
|
3882
|
-
|
|
4140
|
+
_context43.next = 13;
|
|
3883
4141
|
break;
|
|
3884
4142
|
}
|
|
3885
4143
|
this.logInfo('fetchBookingListFromAPI: 命中内存缓存', {
|
|
@@ -3887,14 +4145,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
3887
4145
|
listCount: cached.bookingResult.count,
|
|
3888
4146
|
withFields: cached.withFields
|
|
3889
4147
|
});
|
|
3890
|
-
return
|
|
4148
|
+
return _context43.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
|
|
3891
4149
|
cache_hit: true
|
|
3892
4150
|
}));
|
|
3893
4151
|
case 13:
|
|
3894
|
-
|
|
4152
|
+
_context43.next = 15;
|
|
3895
4153
|
return this.order.fetchOrdersBySSE(requestPayload);
|
|
3896
4154
|
case 15:
|
|
3897
|
-
rawList =
|
|
4155
|
+
rawList = _context43.sent;
|
|
3898
4156
|
bookingResult = sortBookings(filterBookingsFromOrders(rawList, data), data); // DEBUG: 挂到 window 上方便排查 SSE → 日历数据丢失问题
|
|
3899
4157
|
if (typeof globalThis !== 'undefined') {
|
|
3900
4158
|
globalThis.__SSE_BOOKING_DEBUG__ = {
|
|
@@ -3941,15 +4199,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
3941
4199
|
cacheKey: cacheKey,
|
|
3942
4200
|
withFields: withFields
|
|
3943
4201
|
});
|
|
3944
|
-
return
|
|
4202
|
+
return _context43.abrupt("return", this.buildBookingResponse(bookingResult));
|
|
3945
4203
|
case 23:
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
errorMessage =
|
|
4204
|
+
_context43.prev = 23;
|
|
4205
|
+
_context43.t0 = _context43["catch"](3);
|
|
4206
|
+
errorMessage = _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0);
|
|
3949
4207
|
this.logError('fetchBookingListFromAPI: SSE 请求失败', {
|
|
3950
4208
|
error: errorMessage
|
|
3951
4209
|
});
|
|
3952
|
-
return
|
|
4210
|
+
return _context43.abrupt("return", {
|
|
3953
4211
|
code: 500,
|
|
3954
4212
|
message: errorMessage,
|
|
3955
4213
|
data: {
|
|
@@ -3960,11 +4218,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3960
4218
|
});
|
|
3961
4219
|
case 28:
|
|
3962
4220
|
case "end":
|
|
3963
|
-
return
|
|
4221
|
+
return _context43.stop();
|
|
3964
4222
|
}
|
|
3965
|
-
},
|
|
4223
|
+
}, _callee43, this, [[3, 23]]);
|
|
3966
4224
|
}));
|
|
3967
|
-
function fetchBookingListFromAPI(
|
|
4225
|
+
function fetchBookingListFromAPI(_x47) {
|
|
3968
4226
|
return _fetchBookingListFromAPI.apply(this, arguments);
|
|
3969
4227
|
}
|
|
3970
4228
|
return fetchBookingListFromAPI;
|
|
@@ -4040,32 +4298,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
4040
4298
|
}, {
|
|
4041
4299
|
key: "getShortNumberOrDeviceId",
|
|
4042
4300
|
value: function () {
|
|
4043
|
-
var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4301
|
+
var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
|
|
4044
4302
|
var getAsyncIotDeviceInfo, res;
|
|
4045
|
-
return _regeneratorRuntime().wrap(function
|
|
4046
|
-
while (1) switch (
|
|
4303
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4304
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
4047
4305
|
case 0:
|
|
4048
4306
|
getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
|
|
4049
4307
|
if (!getAsyncIotDeviceInfo) {
|
|
4050
|
-
|
|
4308
|
+
_context44.next = 7;
|
|
4051
4309
|
break;
|
|
4052
4310
|
}
|
|
4053
|
-
|
|
4311
|
+
_context44.next = 4;
|
|
4054
4312
|
return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
|
|
4055
4313
|
case 4:
|
|
4056
|
-
res =
|
|
4314
|
+
res = _context44.sent;
|
|
4057
4315
|
if (!(res !== null && res !== void 0 && res.short_number)) {
|
|
4058
|
-
|
|
4316
|
+
_context44.next = 7;
|
|
4059
4317
|
break;
|
|
4060
4318
|
}
|
|
4061
|
-
return
|
|
4319
|
+
return _context44.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
|
|
4062
4320
|
case 7:
|
|
4063
|
-
return
|
|
4321
|
+
return _context44.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
|
|
4064
4322
|
case 8:
|
|
4065
4323
|
case "end":
|
|
4066
|
-
return
|
|
4324
|
+
return _context44.stop();
|
|
4067
4325
|
}
|
|
4068
|
-
},
|
|
4326
|
+
}, _callee44, this);
|
|
4069
4327
|
}));
|
|
4070
4328
|
function getShortNumberOrDeviceId() {
|
|
4071
4329
|
return _getShortNumberOrDeviceId.apply(this, arguments);
|
|
@@ -4092,16 +4350,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
4092
4350
|
}, {
|
|
4093
4351
|
key: "normalizeCheckoutSubmitData",
|
|
4094
4352
|
value: function () {
|
|
4095
|
-
var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4353
|
+
var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(data, title) {
|
|
4096
4354
|
var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
|
|
4097
|
-
return _regeneratorRuntime().wrap(function
|
|
4098
|
-
while (1) switch (
|
|
4355
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
4356
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4099
4357
|
case 0:
|
|
4100
4358
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
4101
|
-
|
|
4359
|
+
_context45.next = 2;
|
|
4102
4360
|
break;
|
|
4103
4361
|
}
|
|
4104
|
-
return
|
|
4362
|
+
return _context45.abrupt("return", data);
|
|
4105
4363
|
case 2:
|
|
4106
4364
|
next = _objectSpread({}, data);
|
|
4107
4365
|
externalSaleNumber = next.external_sale_number;
|
|
@@ -4111,7 +4369,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4111
4369
|
delete next.vouchers;
|
|
4112
4370
|
hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
|
|
4113
4371
|
if (!hasCheckoutOrderNumbers) {
|
|
4114
|
-
|
|
4372
|
+
_context45.next = 11;
|
|
4115
4373
|
break;
|
|
4116
4374
|
}
|
|
4117
4375
|
this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
|
|
@@ -4121,10 +4379,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
4121
4379
|
shop_order_number: next.shop_order_number,
|
|
4122
4380
|
shop_full_order_number: next.shop_full_order_number
|
|
4123
4381
|
});
|
|
4124
|
-
return
|
|
4382
|
+
return _context45.abrupt("return", next);
|
|
4125
4383
|
case 11:
|
|
4126
4384
|
if (!this.isBlankCheckoutValue(externalSaleNumber)) {
|
|
4127
|
-
|
|
4385
|
+
_context45.next = 14;
|
|
4128
4386
|
break;
|
|
4129
4387
|
}
|
|
4130
4388
|
if (shouldClearLocalOrderId) {
|
|
@@ -4133,10 +4391,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
4133
4391
|
order_id: next.order_id
|
|
4134
4392
|
});
|
|
4135
4393
|
}
|
|
4136
|
-
return
|
|
4394
|
+
return _context45.abrupt("return", next);
|
|
4137
4395
|
case 14:
|
|
4138
4396
|
if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
|
|
4139
|
-
|
|
4397
|
+
_context45.next = 17;
|
|
4140
4398
|
break;
|
|
4141
4399
|
}
|
|
4142
4400
|
if (shouldClearLocalOrderId) {
|
|
@@ -4145,12 +4403,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
4145
4403
|
external_sale_number: externalSaleNumber
|
|
4146
4404
|
});
|
|
4147
4405
|
}
|
|
4148
|
-
return
|
|
4406
|
+
return _context45.abrupt("return", next);
|
|
4149
4407
|
case 17:
|
|
4150
|
-
|
|
4408
|
+
_context45.prev = 17;
|
|
4151
4409
|
localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
|
|
4152
4410
|
if (localOrder) {
|
|
4153
|
-
|
|
4411
|
+
_context45.next = 22;
|
|
4154
4412
|
break;
|
|
4155
4413
|
}
|
|
4156
4414
|
if (shouldClearLocalOrderId) {
|
|
@@ -4160,7 +4418,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4160
4418
|
localOrderFound: false
|
|
4161
4419
|
});
|
|
4162
4420
|
}
|
|
4163
|
-
return
|
|
4421
|
+
return _context45.abrupt("return", next);
|
|
4164
4422
|
case 22:
|
|
4165
4423
|
if (this.isBlankCheckoutValue(next.shop_order_number)) {
|
|
4166
4424
|
next.shop_order_number = localOrder.shop_order_number;
|
|
@@ -4177,23 +4435,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
4177
4435
|
shop_full_order_number: next.shop_full_order_number
|
|
4178
4436
|
});
|
|
4179
4437
|
// 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
|
|
4180
|
-
return
|
|
4438
|
+
return _context45.abrupt("return", next);
|
|
4181
4439
|
case 28:
|
|
4182
|
-
|
|
4183
|
-
|
|
4440
|
+
_context45.prev = 28;
|
|
4441
|
+
_context45.t0 = _context45["catch"](17);
|
|
4184
4442
|
this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
|
|
4185
4443
|
external_sale_number: externalSaleNumber,
|
|
4186
|
-
error: this.getUnknownErrorMessage(
|
|
4187
|
-
error_detail: this.normalizeUnknownError(
|
|
4444
|
+
error: this.getUnknownErrorMessage(_context45.t0),
|
|
4445
|
+
error_detail: this.normalizeUnknownError(_context45.t0)
|
|
4188
4446
|
});
|
|
4189
|
-
return
|
|
4447
|
+
return _context45.abrupt("return", next);
|
|
4190
4448
|
case 32:
|
|
4191
4449
|
case "end":
|
|
4192
|
-
return
|
|
4450
|
+
return _context45.stop();
|
|
4193
4451
|
}
|
|
4194
|
-
},
|
|
4452
|
+
}, _callee45, this, [[17, 28]]);
|
|
4195
4453
|
}));
|
|
4196
|
-
function normalizeCheckoutSubmitData(
|
|
4454
|
+
function normalizeCheckoutSubmitData(_x48, _x49) {
|
|
4197
4455
|
return _normalizeCheckoutSubmitData.apply(this, arguments);
|
|
4198
4456
|
}
|
|
4199
4457
|
return normalizeCheckoutSubmitData;
|
|
@@ -4201,81 +4459,81 @@ var Server = /*#__PURE__*/function () {
|
|
|
4201
4459
|
}, {
|
|
4202
4460
|
key: "ensureCheckoutOrderNumbers",
|
|
4203
4461
|
value: function () {
|
|
4204
|
-
var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4462
|
+
var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(data, title) {
|
|
4205
4463
|
var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
|
|
4206
|
-
return _regeneratorRuntime().wrap(function
|
|
4207
|
-
while (1) switch (
|
|
4464
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
4465
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4208
4466
|
case 0:
|
|
4209
4467
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
4210
|
-
|
|
4468
|
+
_context46.next = 2;
|
|
4211
4469
|
break;
|
|
4212
4470
|
}
|
|
4213
|
-
return
|
|
4471
|
+
return _context46.abrupt("return", data);
|
|
4214
4472
|
case 2:
|
|
4215
4473
|
next = _objectSpread({}, data);
|
|
4216
4474
|
needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
|
|
4217
4475
|
needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
|
|
4218
4476
|
if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
|
|
4219
|
-
|
|
4477
|
+
_context46.next = 7;
|
|
4220
4478
|
break;
|
|
4221
4479
|
}
|
|
4222
|
-
return
|
|
4480
|
+
return _context46.abrupt("return", next);
|
|
4223
4481
|
case 7:
|
|
4224
4482
|
idGenerator = this.getIdGeneratorPlugin();
|
|
4225
4483
|
if (idGenerator) {
|
|
4226
|
-
|
|
4484
|
+
_context46.next = 11;
|
|
4227
4485
|
break;
|
|
4228
4486
|
}
|
|
4229
4487
|
this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
|
|
4230
4488
|
needsShopOrderNumber: needsShopOrderNumber,
|
|
4231
4489
|
needsShopFullOrderNumber: needsShopFullOrderNumber
|
|
4232
4490
|
});
|
|
4233
|
-
return
|
|
4491
|
+
return _context46.abrupt("return", next);
|
|
4234
4492
|
case 11:
|
|
4235
|
-
|
|
4493
|
+
_context46.prev = 11;
|
|
4236
4494
|
if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
|
|
4237
|
-
|
|
4495
|
+
_context46.next = 16;
|
|
4238
4496
|
break;
|
|
4239
4497
|
}
|
|
4240
|
-
|
|
4498
|
+
_context46.next = 15;
|
|
4241
4499
|
return idGenerator.generateShopOrderNumber({
|
|
4242
4500
|
biz: next.business_code || 'ticket'
|
|
4243
4501
|
});
|
|
4244
4502
|
case 15:
|
|
4245
|
-
next.shop_order_number =
|
|
4503
|
+
next.shop_order_number = _context46.sent;
|
|
4246
4504
|
case 16:
|
|
4247
4505
|
if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
|
|
4248
|
-
|
|
4506
|
+
_context46.next = 20;
|
|
4249
4507
|
break;
|
|
4250
4508
|
}
|
|
4251
|
-
|
|
4509
|
+
_context46.next = 19;
|
|
4252
4510
|
return idGenerator.generateReceiptId({
|
|
4253
4511
|
biz: next.business_code || 'ticket'
|
|
4254
4512
|
});
|
|
4255
4513
|
case 19:
|
|
4256
|
-
next.shop_full_order_number =
|
|
4514
|
+
next.shop_full_order_number = _context46.sent;
|
|
4257
4515
|
case 20:
|
|
4258
4516
|
this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
|
|
4259
4517
|
shop_order_number: next.shop_order_number,
|
|
4260
4518
|
shop_full_order_number: next.shop_full_order_number
|
|
4261
4519
|
});
|
|
4262
|
-
|
|
4520
|
+
_context46.next = 26;
|
|
4263
4521
|
break;
|
|
4264
4522
|
case 23:
|
|
4265
|
-
|
|
4266
|
-
|
|
4523
|
+
_context46.prev = 23;
|
|
4524
|
+
_context46.t0 = _context46["catch"](11);
|
|
4267
4525
|
this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
|
|
4268
|
-
error:
|
|
4526
|
+
error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
|
|
4269
4527
|
});
|
|
4270
4528
|
case 26:
|
|
4271
|
-
return
|
|
4529
|
+
return _context46.abrupt("return", next);
|
|
4272
4530
|
case 27:
|
|
4273
4531
|
case "end":
|
|
4274
|
-
return
|
|
4532
|
+
return _context46.stop();
|
|
4275
4533
|
}
|
|
4276
|
-
},
|
|
4534
|
+
}, _callee46, this, [[11, 23]]);
|
|
4277
4535
|
}));
|
|
4278
|
-
function ensureCheckoutOrderNumbers(
|
|
4536
|
+
function ensureCheckoutOrderNumbers(_x50, _x51) {
|
|
4279
4537
|
return _ensureCheckoutOrderNumbers.apply(this, arguments);
|
|
4280
4538
|
}
|
|
4281
4539
|
return ensureCheckoutOrderNumbers;
|
|
@@ -4283,27 +4541,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
4283
4541
|
}, {
|
|
4284
4542
|
key: "dispatchCheckoutSyncTask",
|
|
4285
4543
|
value: function () {
|
|
4286
|
-
var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4544
|
+
var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
|
|
4287
4545
|
var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
|
|
4288
|
-
return _regeneratorRuntime().wrap(function
|
|
4289
|
-
while (1) switch (
|
|
4546
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
4547
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4290
4548
|
case 0:
|
|
4291
4549
|
this.registerDeviceTaskActions();
|
|
4292
4550
|
deviceTask = this.getDeviceTaskPlugin();
|
|
4293
|
-
|
|
4551
|
+
_context47.next = 4;
|
|
4294
4552
|
return this.getShortNumberOrDeviceId();
|
|
4295
4553
|
case 4:
|
|
4296
|
-
debugDeviceId =
|
|
4554
|
+
debugDeviceId = _context47.sent;
|
|
4297
4555
|
debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
|
|
4298
4556
|
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
4299
|
-
|
|
4557
|
+
_context47.next = 9;
|
|
4300
4558
|
break;
|
|
4301
4559
|
}
|
|
4302
4560
|
this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
|
|
4303
|
-
return
|
|
4561
|
+
return _context47.abrupt("return");
|
|
4304
4562
|
case 9:
|
|
4305
|
-
|
|
4306
|
-
|
|
4563
|
+
_context47.prev = 9;
|
|
4564
|
+
_context47.next = 12;
|
|
4307
4565
|
return deviceTask.dispatch({
|
|
4308
4566
|
action: 'sync_sales',
|
|
4309
4567
|
device_id: debugDeviceId,
|
|
@@ -4321,27 +4579,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
4321
4579
|
source_id: ((_params$data2 = params.data) === null || _params$data2 === void 0 ? void 0 : _params$data2.order_id) || ((_params$data3 = params.data) === null || _params$data3 === void 0 ? void 0 : _params$data3.external_sale_number) || ((_params$data4 = params.data) === null || _params$data4 === void 0 ? void 0 : _params$data4.shop_order_number)
|
|
4322
4580
|
});
|
|
4323
4581
|
case 12:
|
|
4324
|
-
result =
|
|
4582
|
+
result = _context47.sent;
|
|
4325
4583
|
this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
|
|
4326
4584
|
uuid: result === null || result === void 0 ? void 0 : result.uuid,
|
|
4327
4585
|
status: result === null || result === void 0 ? void 0 : result.status,
|
|
4328
4586
|
reused: result === null || result === void 0 ? void 0 : result.reused
|
|
4329
4587
|
});
|
|
4330
|
-
|
|
4588
|
+
_context47.next = 19;
|
|
4331
4589
|
break;
|
|
4332
4590
|
case 16:
|
|
4333
|
-
|
|
4334
|
-
|
|
4591
|
+
_context47.prev = 16;
|
|
4592
|
+
_context47.t0 = _context47["catch"](9);
|
|
4335
4593
|
this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
|
|
4336
|
-
error:
|
|
4594
|
+
error: _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0)
|
|
4337
4595
|
});
|
|
4338
4596
|
case 19:
|
|
4339
4597
|
case "end":
|
|
4340
|
-
return
|
|
4598
|
+
return _context47.stop();
|
|
4341
4599
|
}
|
|
4342
|
-
},
|
|
4600
|
+
}, _callee47, this, [[9, 16]]);
|
|
4343
4601
|
}));
|
|
4344
|
-
function dispatchCheckoutSyncTask(
|
|
4602
|
+
function dispatchCheckoutSyncTask(_x52) {
|
|
4345
4603
|
return _dispatchCheckoutSyncTask.apply(this, arguments);
|
|
4346
4604
|
}
|
|
4347
4605
|
return dispatchCheckoutSyncTask;
|
|
@@ -4349,26 +4607,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
4349
4607
|
}, {
|
|
4350
4608
|
key: "dispatchPrintOtherReceiptTask",
|
|
4351
4609
|
value: function () {
|
|
4352
|
-
var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4610
|
+
var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
|
|
4353
4611
|
var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
|
|
4354
|
-
return _regeneratorRuntime().wrap(function
|
|
4355
|
-
while (1) switch (
|
|
4612
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
4613
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4356
4614
|
case 0:
|
|
4357
4615
|
deviceTask = this.getDeviceTaskPlugin();
|
|
4358
4616
|
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
4359
|
-
|
|
4617
|
+
_context48.next = 4;
|
|
4360
4618
|
break;
|
|
4361
4619
|
}
|
|
4362
4620
|
this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
|
|
4363
|
-
return
|
|
4621
|
+
return _context48.abrupt("return");
|
|
4364
4622
|
case 4:
|
|
4365
|
-
|
|
4623
|
+
_context48.prev = 4;
|
|
4366
4624
|
printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
|
|
4367
|
-
|
|
4625
|
+
_context48.next = 8;
|
|
4368
4626
|
return this.getShortNumberOrDeviceId();
|
|
4369
4627
|
case 8:
|
|
4370
|
-
deviceId =
|
|
4371
|
-
|
|
4628
|
+
deviceId = _context48.sent;
|
|
4629
|
+
_context48.next = 11;
|
|
4372
4630
|
return deviceTask.dispatch({
|
|
4373
4631
|
action: 'print_all',
|
|
4374
4632
|
device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
|
|
@@ -4395,21 +4653,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
4395
4653
|
source_id: printIdentity
|
|
4396
4654
|
});
|
|
4397
4655
|
case 11:
|
|
4398
|
-
|
|
4656
|
+
_context48.next = 16;
|
|
4399
4657
|
break;
|
|
4400
4658
|
case 13:
|
|
4401
|
-
|
|
4402
|
-
|
|
4659
|
+
_context48.prev = 13;
|
|
4660
|
+
_context48.t0 = _context48["catch"](4);
|
|
4403
4661
|
this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
|
|
4404
|
-
error:
|
|
4662
|
+
error: _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0)
|
|
4405
4663
|
});
|
|
4406
4664
|
case 16:
|
|
4407
4665
|
case "end":
|
|
4408
|
-
return
|
|
4666
|
+
return _context48.stop();
|
|
4409
4667
|
}
|
|
4410
|
-
},
|
|
4668
|
+
}, _callee48, this, [[4, 13]]);
|
|
4411
4669
|
}));
|
|
4412
|
-
function dispatchPrintOtherReceiptTask(
|
|
4670
|
+
function dispatchPrintOtherReceiptTask(_x53) {
|
|
4413
4671
|
return _dispatchPrintOtherReceiptTask.apply(this, arguments);
|
|
4414
4672
|
}
|
|
4415
4673
|
return dispatchPrintOtherReceiptTask;
|
|
@@ -4429,32 +4687,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
4429
4687
|
}, {
|
|
4430
4688
|
key: "dispatchLocalReceiptPrint",
|
|
4431
4689
|
value: function () {
|
|
4432
|
-
var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4690
|
+
var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
|
|
4433
4691
|
var _payment_info;
|
|
4434
4692
|
var printableOrder;
|
|
4435
|
-
return _regeneratorRuntime().wrap(function
|
|
4436
|
-
while (1) switch (
|
|
4693
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
4694
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
4437
4695
|
case 0:
|
|
4438
4696
|
if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
|
|
4439
|
-
|
|
4697
|
+
_context49.next = 2;
|
|
4440
4698
|
break;
|
|
4441
4699
|
}
|
|
4442
|
-
return
|
|
4700
|
+
return _context49.abrupt("return", {
|
|
4443
4701
|
printed: false,
|
|
4444
4702
|
order: params.order
|
|
4445
4703
|
});
|
|
4446
4704
|
case 2:
|
|
4447
|
-
|
|
4705
|
+
_context49.next = 4;
|
|
4448
4706
|
return this.withLocalSmallTicketData(params.order, {
|
|
4449
4707
|
requireFullyPaid: params.requireFullyPaid
|
|
4450
4708
|
});
|
|
4451
4709
|
case 4:
|
|
4452
|
-
printableOrder =
|
|
4710
|
+
printableOrder = _context49.sent;
|
|
4453
4711
|
if (hasSmallTicketData((_payment_info = printableOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data)) {
|
|
4454
|
-
|
|
4712
|
+
_context49.next = 7;
|
|
4455
4713
|
break;
|
|
4456
4714
|
}
|
|
4457
|
-
return
|
|
4715
|
+
return _context49.abrupt("return", {
|
|
4458
4716
|
printed: false,
|
|
4459
4717
|
order: printableOrder
|
|
4460
4718
|
});
|
|
@@ -4464,7 +4722,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4464
4722
|
printableOrder: printableOrder,
|
|
4465
4723
|
response: params.response
|
|
4466
4724
|
});
|
|
4467
|
-
|
|
4725
|
+
_context49.next = 10;
|
|
4468
4726
|
return this.dispatchPrintOtherReceiptTask({
|
|
4469
4727
|
checkoutData: params.checkoutData,
|
|
4470
4728
|
syncedOrder: printableOrder,
|
|
@@ -4473,17 +4731,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
4473
4731
|
isManualPrint: params.isManualPrint
|
|
4474
4732
|
});
|
|
4475
4733
|
case 10:
|
|
4476
|
-
return
|
|
4734
|
+
return _context49.abrupt("return", {
|
|
4477
4735
|
printed: true,
|
|
4478
4736
|
order: printableOrder
|
|
4479
4737
|
});
|
|
4480
4738
|
case 11:
|
|
4481
4739
|
case "end":
|
|
4482
|
-
return
|
|
4740
|
+
return _context49.stop();
|
|
4483
4741
|
}
|
|
4484
|
-
},
|
|
4742
|
+
}, _callee49, this);
|
|
4485
4743
|
}));
|
|
4486
|
-
function dispatchLocalReceiptPrint(
|
|
4744
|
+
function dispatchLocalReceiptPrint(_x54) {
|
|
4487
4745
|
return _dispatchLocalReceiptPrint.apply(this, arguments);
|
|
4488
4746
|
}
|
|
4489
4747
|
return dispatchLocalReceiptPrint;
|
|
@@ -4518,47 +4776,47 @@ var Server = /*#__PURE__*/function () {
|
|
|
4518
4776
|
}, {
|
|
4519
4777
|
key: "syncMachinecodeRedeemStatusToLocalOrder",
|
|
4520
4778
|
value: function () {
|
|
4521
|
-
var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4779
|
+
var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(data, ids, status) {
|
|
4522
4780
|
var _this$order3;
|
|
4523
4781
|
var title, lookup, localOrder, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
|
|
4524
|
-
return _regeneratorRuntime().wrap(function
|
|
4525
|
-
while (1) switch (
|
|
4782
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
4783
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
4526
4784
|
case 0:
|
|
4527
4785
|
title = 'handleMachinecodeBatchMetadata';
|
|
4528
4786
|
lookup = this.resolveMachinecodeBatchMetadataLookup(data);
|
|
4529
4787
|
if (!(lookup === undefined)) {
|
|
4530
|
-
|
|
4788
|
+
_context50.next = 5;
|
|
4531
4789
|
break;
|
|
4532
4790
|
}
|
|
4533
4791
|
this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
4534
4792
|
batchSize: ids.length,
|
|
4535
4793
|
status: status
|
|
4536
4794
|
});
|
|
4537
|
-
return
|
|
4795
|
+
return _context50.abrupt("return");
|
|
4538
4796
|
case 5:
|
|
4539
4797
|
if ((_this$order3 = this.order) !== null && _this$order3 !== void 0 && _this$order3.getLocalOrderByLookup) {
|
|
4540
|
-
|
|
4798
|
+
_context50.next = 8;
|
|
4541
4799
|
break;
|
|
4542
4800
|
}
|
|
4543
4801
|
this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
4544
4802
|
lookup: lookup,
|
|
4545
4803
|
status: status
|
|
4546
4804
|
});
|
|
4547
|
-
return
|
|
4805
|
+
return _context50.abrupt("return");
|
|
4548
4806
|
case 8:
|
|
4549
|
-
|
|
4807
|
+
_context50.next = 10;
|
|
4550
4808
|
return this.order.getLocalOrderByLookup(lookup);
|
|
4551
4809
|
case 10:
|
|
4552
|
-
localOrder =
|
|
4810
|
+
localOrder = _context50.sent;
|
|
4553
4811
|
if (localOrder) {
|
|
4554
|
-
|
|
4812
|
+
_context50.next = 14;
|
|
4555
4813
|
break;
|
|
4556
4814
|
}
|
|
4557
4815
|
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
4558
4816
|
lookup: lookup,
|
|
4559
4817
|
status: status
|
|
4560
4818
|
});
|
|
4561
|
-
return
|
|
4819
|
+
return _context50.abrupt("return");
|
|
4562
4820
|
case 14:
|
|
4563
4821
|
voucherIdSet = new Set(ids.filter(function (id) {
|
|
4564
4822
|
return id !== undefined && id !== null && id !== '';
|
|
@@ -4566,14 +4824,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
4566
4824
|
return String(id);
|
|
4567
4825
|
}));
|
|
4568
4826
|
if (!(voucherIdSet.size === 0)) {
|
|
4569
|
-
|
|
4827
|
+
_context50.next = 18;
|
|
4570
4828
|
break;
|
|
4571
4829
|
}
|
|
4572
4830
|
this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
4573
4831
|
lookup: lookup,
|
|
4574
4832
|
status: status
|
|
4575
4833
|
});
|
|
4576
|
-
return
|
|
4834
|
+
return _context50.abrupt("return");
|
|
4577
4835
|
case 18:
|
|
4578
4836
|
vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
|
|
4579
4837
|
hasUpdatedVoucher = false;
|
|
@@ -4587,7 +4845,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4587
4845
|
});
|
|
4588
4846
|
});
|
|
4589
4847
|
if (hasUpdatedVoucher) {
|
|
4590
|
-
|
|
4848
|
+
_context50.next = 24;
|
|
4591
4849
|
break;
|
|
4592
4850
|
}
|
|
4593
4851
|
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
@@ -4595,13 +4853,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4595
4853
|
voucher_ids: Array.from(voucherIdSet),
|
|
4596
4854
|
status: status
|
|
4597
4855
|
});
|
|
4598
|
-
return
|
|
4856
|
+
return _context50.abrupt("return");
|
|
4599
4857
|
case 24:
|
|
4600
4858
|
if (!(typeof this.order.overwriteExistingOrder === 'function')) {
|
|
4601
|
-
|
|
4859
|
+
_context50.next = 29;
|
|
4602
4860
|
break;
|
|
4603
4861
|
}
|
|
4604
|
-
|
|
4862
|
+
_context50.next = 27;
|
|
4605
4863
|
return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
|
|
4606
4864
|
vouchers: nextVouchers
|
|
4607
4865
|
}));
|
|
@@ -4611,13 +4869,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4611
4869
|
updatedCount: voucherIdSet.size,
|
|
4612
4870
|
status: status
|
|
4613
4871
|
});
|
|
4614
|
-
return
|
|
4872
|
+
return _context50.abrupt("return");
|
|
4615
4873
|
case 29:
|
|
4616
4874
|
if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
|
|
4617
|
-
|
|
4875
|
+
_context50.next = 34;
|
|
4618
4876
|
break;
|
|
4619
4877
|
}
|
|
4620
|
-
|
|
4878
|
+
_context50.next = 32;
|
|
4621
4879
|
return this.order.markOrderSyncedByExternalSaleNumber({
|
|
4622
4880
|
externalSaleNumber: data.external_sale_number,
|
|
4623
4881
|
patch: {
|
|
@@ -4630,7 +4888,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4630
4888
|
updatedCount: voucherIdSet.size,
|
|
4631
4889
|
status: status
|
|
4632
4890
|
});
|
|
4633
|
-
return
|
|
4891
|
+
return _context50.abrupt("return");
|
|
4634
4892
|
case 34:
|
|
4635
4893
|
this.logWarning("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8BA2\u5355\u8986\u76D6\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
4636
4894
|
lookup: lookup,
|
|
@@ -4638,11 +4896,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4638
4896
|
});
|
|
4639
4897
|
case 35:
|
|
4640
4898
|
case "end":
|
|
4641
|
-
return
|
|
4899
|
+
return _context50.stop();
|
|
4642
4900
|
}
|
|
4643
|
-
},
|
|
4901
|
+
}, _callee50, this);
|
|
4644
4902
|
}));
|
|
4645
|
-
function syncMachinecodeRedeemStatusToLocalOrder(
|
|
4903
|
+
function syncMachinecodeRedeemStatusToLocalOrder(_x55, _x56, _x57) {
|
|
4646
4904
|
return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
|
|
4647
4905
|
}
|
|
4648
4906
|
return syncMachinecodeRedeemStatusToLocalOrder;
|
|
@@ -4650,10 +4908,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
4650
4908
|
}, {
|
|
4651
4909
|
key: "handleOrderCheckoutSubmit",
|
|
4652
4910
|
value: function () {
|
|
4653
|
-
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4911
|
+
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
|
|
4654
4912
|
var backendPath, data, title, normalizedData, checkoutData, pendingResult, pendingOrder;
|
|
4655
|
-
return _regeneratorRuntime().wrap(function
|
|
4656
|
-
while (1) switch (
|
|
4913
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
4914
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
4657
4915
|
case 0:
|
|
4658
4916
|
backendPath = params.backendPath, data = params.data, title = params.title;
|
|
4659
4917
|
this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
|
|
@@ -4663,24 +4921,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
4663
4921
|
order_number: data === null || data === void 0 ? void 0 : data.order_number
|
|
4664
4922
|
});
|
|
4665
4923
|
if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
|
|
4666
|
-
|
|
4924
|
+
_context51.next = 4;
|
|
4667
4925
|
break;
|
|
4668
4926
|
}
|
|
4669
|
-
return
|
|
4927
|
+
return _context51.abrupt("return", this.handleSyncCheckoutSubmit({
|
|
4670
4928
|
backendPath: backendPath,
|
|
4671
4929
|
data: data,
|
|
4672
4930
|
title: title
|
|
4673
4931
|
}));
|
|
4674
4932
|
case 4:
|
|
4675
|
-
|
|
4933
|
+
_context51.next = 6;
|
|
4676
4934
|
return this.normalizeCheckoutSubmitData(data, title);
|
|
4677
4935
|
case 6:
|
|
4678
|
-
normalizedData =
|
|
4679
|
-
|
|
4936
|
+
normalizedData = _context51.sent;
|
|
4937
|
+
_context51.next = 9;
|
|
4680
4938
|
return this.ensureCheckoutOrderNumbers(normalizedData, title);
|
|
4681
4939
|
case 9:
|
|
4682
|
-
checkoutData =
|
|
4683
|
-
|
|
4940
|
+
checkoutData = _context51.sent;
|
|
4941
|
+
_context51.next = 12;
|
|
4684
4942
|
return this.handlePendingSyncCheckoutOrder({
|
|
4685
4943
|
backendPath: backendPath,
|
|
4686
4944
|
data: checkoutData,
|
|
@@ -4688,9 +4946,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
4688
4946
|
reason: 'checkout 已转入设备任务同步'
|
|
4689
4947
|
});
|
|
4690
4948
|
case 12:
|
|
4691
|
-
pendingResult =
|
|
4949
|
+
pendingResult = _context51.sent;
|
|
4692
4950
|
if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
|
|
4693
|
-
|
|
4951
|
+
_context51.next = 20;
|
|
4694
4952
|
break;
|
|
4695
4953
|
}
|
|
4696
4954
|
pendingOrder = pendingResult.data;
|
|
@@ -4698,10 +4956,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
4698
4956
|
// TODO 这里先加个兼容,只有 type 为 virtual 才走打印
|
|
4699
4957
|
// 后期需要迁移到 picoding ,根据工作流配置
|
|
4700
4958
|
checkoutData.type === 'virtual')) {
|
|
4701
|
-
|
|
4959
|
+
_context51.next = 18;
|
|
4702
4960
|
break;
|
|
4703
4961
|
}
|
|
4704
|
-
|
|
4962
|
+
_context51.next = 18;
|
|
4705
4963
|
return this.dispatchLocalReceiptPrint({
|
|
4706
4964
|
checkoutData: checkoutData,
|
|
4707
4965
|
order: pendingOrder,
|
|
@@ -4709,7 +4967,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4709
4967
|
requireFullyPaid: true
|
|
4710
4968
|
});
|
|
4711
4969
|
case 18:
|
|
4712
|
-
|
|
4970
|
+
_context51.next = 20;
|
|
4713
4971
|
return this.dispatchCheckoutSyncTask({
|
|
4714
4972
|
backendPath: backendPath,
|
|
4715
4973
|
data: checkoutData,
|
|
@@ -4717,23 +4975,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
4717
4975
|
});
|
|
4718
4976
|
case 20:
|
|
4719
4977
|
if (pendingResult.data.order_id) {
|
|
4720
|
-
|
|
4978
|
+
_context51.next = 22;
|
|
4721
4979
|
break;
|
|
4722
4980
|
}
|
|
4723
|
-
return
|
|
4981
|
+
return _context51.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
|
|
4724
4982
|
data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
|
|
4725
4983
|
order_id: pendingResult.data.external_sale_number
|
|
4726
4984
|
})
|
|
4727
4985
|
}));
|
|
4728
4986
|
case 22:
|
|
4729
|
-
return
|
|
4987
|
+
return _context51.abrupt("return", pendingResult);
|
|
4730
4988
|
case 23:
|
|
4731
4989
|
case "end":
|
|
4732
|
-
return
|
|
4990
|
+
return _context51.stop();
|
|
4733
4991
|
}
|
|
4734
|
-
},
|
|
4992
|
+
}, _callee51, this);
|
|
4735
4993
|
}));
|
|
4736
|
-
function handleOrderCheckoutSubmit(
|
|
4994
|
+
function handleOrderCheckoutSubmit(_x58) {
|
|
4737
4995
|
return _handleOrderCheckoutSubmit.apply(this, arguments);
|
|
4738
4996
|
}
|
|
4739
4997
|
return handleOrderCheckoutSubmit;
|
|
@@ -4741,27 +4999,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
4741
4999
|
}, {
|
|
4742
5000
|
key: "handleSyncCheckoutSubmit",
|
|
4743
5001
|
value: function () {
|
|
4744
|
-
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5002
|
+
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
|
|
4745
5003
|
var _this$app16;
|
|
4746
5004
|
var backendPath, data, title, syncResult, _normalized$data, normalized, backendError, _normalized$data2, _normalized, message;
|
|
4747
|
-
return _regeneratorRuntime().wrap(function
|
|
4748
|
-
while (1) switch (
|
|
5005
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
5006
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
4749
5007
|
case 0:
|
|
4750
5008
|
backendPath = params.backendPath, data = params.data, title = params.title;
|
|
4751
5009
|
if ((_this$app16 = this.app) !== null && _this$app16 !== void 0 && (_this$app16 = _this$app16.request) !== null && _this$app16 !== void 0 && _this$app16.post) {
|
|
4752
|
-
|
|
5010
|
+
_context52.next = 4;
|
|
4753
5011
|
break;
|
|
4754
5012
|
}
|
|
4755
5013
|
this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
|
|
4756
|
-
return
|
|
5014
|
+
return _context52.abrupt("return", {
|
|
4757
5015
|
code: 500,
|
|
4758
5016
|
status: false,
|
|
4759
5017
|
message: 'app.request 不可用',
|
|
4760
5018
|
data: null
|
|
4761
5019
|
});
|
|
4762
5020
|
case 4:
|
|
4763
|
-
|
|
4764
|
-
|
|
5021
|
+
_context52.prev = 4;
|
|
5022
|
+
_context52.next = 7;
|
|
4765
5023
|
return this.runCheckoutSync({
|
|
4766
5024
|
backendPath: backendPath,
|
|
4767
5025
|
data: data,
|
|
@@ -4769,41 +5027,41 @@ var Server = /*#__PURE__*/function () {
|
|
|
4769
5027
|
persistCheckoutDataWithResponse: true
|
|
4770
5028
|
});
|
|
4771
5029
|
case 7:
|
|
4772
|
-
syncResult =
|
|
5030
|
+
syncResult = _context52.sent;
|
|
4773
5031
|
if (!syncResult.rejected) {
|
|
4774
|
-
|
|
5032
|
+
_context52.next = 11;
|
|
4775
5033
|
break;
|
|
4776
5034
|
}
|
|
4777
5035
|
normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
|
|
4778
|
-
return
|
|
5036
|
+
return _context52.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
|
|
4779
5037
|
status: false,
|
|
4780
5038
|
message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
|
|
4781
5039
|
data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
|
|
4782
5040
|
}));
|
|
4783
5041
|
case 11:
|
|
4784
|
-
return
|
|
5042
|
+
return _context52.abrupt("return", this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder));
|
|
4785
5043
|
case 14:
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
backendError = this.extractBackendErrorResponse(
|
|
5044
|
+
_context52.prev = 14;
|
|
5045
|
+
_context52.t0 = _context52["catch"](4);
|
|
5046
|
+
backendError = this.extractBackendErrorResponse(_context52.t0);
|
|
4789
5047
|
if (!backendError) {
|
|
4790
|
-
|
|
5048
|
+
_context52.next = 20;
|
|
4791
5049
|
break;
|
|
4792
5050
|
}
|
|
4793
5051
|
_normalized = this.normalizeCheckoutResponse(backendError);
|
|
4794
|
-
return
|
|
5052
|
+
return _context52.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
|
|
4795
5053
|
status: false,
|
|
4796
5054
|
message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
|
|
4797
5055
|
data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
|
|
4798
5056
|
}));
|
|
4799
5057
|
case 20:
|
|
4800
|
-
message = this.getUnknownErrorMessage(
|
|
5058
|
+
message = this.getUnknownErrorMessage(_context52.t0);
|
|
4801
5059
|
this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
|
|
4802
5060
|
backendPath: backendPath,
|
|
4803
5061
|
error: message,
|
|
4804
|
-
error_detail: this.normalizeUnknownError(
|
|
5062
|
+
error_detail: this.normalizeUnknownError(_context52.t0)
|
|
4805
5063
|
});
|
|
4806
|
-
return
|
|
5064
|
+
return _context52.abrupt("return", {
|
|
4807
5065
|
code: 500,
|
|
4808
5066
|
status: false,
|
|
4809
5067
|
message: message,
|
|
@@ -4811,11 +5069,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4811
5069
|
});
|
|
4812
5070
|
case 23:
|
|
4813
5071
|
case "end":
|
|
4814
|
-
return
|
|
5072
|
+
return _context52.stop();
|
|
4815
5073
|
}
|
|
4816
|
-
},
|
|
5074
|
+
}, _callee52, this, [[4, 14]]);
|
|
4817
5075
|
}));
|
|
4818
|
-
function handleSyncCheckoutSubmit(
|
|
5076
|
+
function handleSyncCheckoutSubmit(_x59) {
|
|
4819
5077
|
return _handleSyncCheckoutSubmit.apply(this, arguments);
|
|
4820
5078
|
}
|
|
4821
5079
|
return handleSyncCheckoutSubmit;
|
|
@@ -4823,26 +5081,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
4823
5081
|
}, {
|
|
4824
5082
|
key: "handlePendingSyncCheckoutOrder",
|
|
4825
5083
|
value: function () {
|
|
4826
|
-
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4827
|
-
var
|
|
5084
|
+
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
|
|
5085
|
+
var _this11 = this;
|
|
4828
5086
|
var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
|
|
4829
|
-
return _regeneratorRuntime().wrap(function
|
|
4830
|
-
while (1) switch (
|
|
5087
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
5088
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
4831
5089
|
case 0:
|
|
4832
5090
|
backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason;
|
|
4833
|
-
|
|
5091
|
+
_context53.next = 3;
|
|
4834
5092
|
return this.buildPendingSyncCheckoutOrder(data);
|
|
4835
5093
|
case 3:
|
|
4836
|
-
pendingOrder =
|
|
5094
|
+
pendingOrder = _context53.sent;
|
|
4837
5095
|
if (pendingOrder) {
|
|
4838
|
-
|
|
5096
|
+
_context53.next = 7;
|
|
4839
5097
|
break;
|
|
4840
5098
|
}
|
|
4841
5099
|
this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
|
|
4842
5100
|
backendPath: backendPath,
|
|
4843
5101
|
reason: reason
|
|
4844
5102
|
});
|
|
4845
|
-
return
|
|
5103
|
+
return _context53.abrupt("return", {
|
|
4846
5104
|
code: 500,
|
|
4847
5105
|
status: false,
|
|
4848
5106
|
message: '订单缺少本地存储标识,无法写入待同步队列',
|
|
@@ -4850,22 +5108,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
4850
5108
|
});
|
|
4851
5109
|
case 7:
|
|
4852
5110
|
if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
|
|
4853
|
-
|
|
5111
|
+
_context53.next = 10;
|
|
4854
5112
|
break;
|
|
4855
5113
|
}
|
|
4856
5114
|
this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
|
|
4857
5115
|
backendPath: backendPath,
|
|
4858
5116
|
reason: reason
|
|
4859
5117
|
});
|
|
4860
|
-
return
|
|
5118
|
+
return _context53.abrupt("return", {
|
|
4861
5119
|
code: 500,
|
|
4862
5120
|
status: false,
|
|
4863
5121
|
message: 'Order 模块不支持本地待同步写入',
|
|
4864
5122
|
data: null
|
|
4865
5123
|
});
|
|
4866
5124
|
case 10:
|
|
4867
|
-
|
|
4868
|
-
|
|
5125
|
+
_context53.prev = 10;
|
|
5126
|
+
_context53.next = 13;
|
|
4869
5127
|
return this.order.upsertPendingSyncOrders([pendingOrder]);
|
|
4870
5128
|
case 13:
|
|
4871
5129
|
this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
|
|
@@ -4877,9 +5135,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
4877
5135
|
});
|
|
4878
5136
|
changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
|
|
4879
5137
|
var _payment$metadata;
|
|
4880
|
-
return sum +
|
|
5138
|
+
return sum + _this11.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
|
|
4881
5139
|
}, 0);
|
|
4882
|
-
return
|
|
5140
|
+
return _context53.abrupt("return", {
|
|
4883
5141
|
code: 200,
|
|
4884
5142
|
status: true,
|
|
4885
5143
|
message: '',
|
|
@@ -4894,15 +5152,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
4894
5152
|
})
|
|
4895
5153
|
});
|
|
4896
5154
|
case 18:
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
errorMessage =
|
|
5155
|
+
_context53.prev = 18;
|
|
5156
|
+
_context53.t0 = _context53["catch"](10);
|
|
5157
|
+
errorMessage = _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0);
|
|
4900
5158
|
this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
|
|
4901
5159
|
backendPath: backendPath,
|
|
4902
5160
|
reason: reason,
|
|
4903
5161
|
error: errorMessage
|
|
4904
5162
|
});
|
|
4905
|
-
return
|
|
5163
|
+
return _context53.abrupt("return", {
|
|
4906
5164
|
code: 500,
|
|
4907
5165
|
status: false,
|
|
4908
5166
|
message: errorMessage,
|
|
@@ -4910,11 +5168,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4910
5168
|
});
|
|
4911
5169
|
case 23:
|
|
4912
5170
|
case "end":
|
|
4913
|
-
return
|
|
5171
|
+
return _context53.stop();
|
|
4914
5172
|
}
|
|
4915
|
-
},
|
|
5173
|
+
}, _callee53, this, [[10, 18]]);
|
|
4916
5174
|
}));
|
|
4917
|
-
function handlePendingSyncCheckoutOrder(
|
|
5175
|
+
function handlePendingSyncCheckoutOrder(_x60) {
|
|
4918
5176
|
return _handlePendingSyncCheckoutOrder.apply(this, arguments);
|
|
4919
5177
|
}
|
|
4920
5178
|
return handlePendingSyncCheckoutOrder;
|
|
@@ -4922,43 +5180,43 @@ var Server = /*#__PURE__*/function () {
|
|
|
4922
5180
|
}, {
|
|
4923
5181
|
key: "buildPendingSyncCheckoutOrder",
|
|
4924
5182
|
value: function () {
|
|
4925
|
-
var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5183
|
+
var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(data) {
|
|
4926
5184
|
var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
|
|
4927
|
-
return _regeneratorRuntime().wrap(function
|
|
4928
|
-
while (1) switch (
|
|
5185
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5186
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
4929
5187
|
case 0:
|
|
4930
5188
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
4931
|
-
|
|
5189
|
+
_context54.next = 2;
|
|
4932
5190
|
break;
|
|
4933
5191
|
}
|
|
4934
|
-
return
|
|
5192
|
+
return _context54.abrupt("return", null);
|
|
4935
5193
|
case 2:
|
|
4936
5194
|
hasStorageKey = data.external_sale_number !== undefined && data.external_sale_number !== null && data.external_sale_number !== '' ? true : data.order_id !== undefined && data.order_id !== null && data.order_id !== '';
|
|
4937
5195
|
if (hasStorageKey) {
|
|
4938
|
-
|
|
5196
|
+
_context54.next = 5;
|
|
4939
5197
|
break;
|
|
4940
5198
|
}
|
|
4941
|
-
return
|
|
5199
|
+
return _context54.abrupt("return", null);
|
|
4942
5200
|
case 5:
|
|
4943
5201
|
pendingOrder = _objectSpread(_objectSpread({}, data), {}, {
|
|
4944
5202
|
need_sync: 1
|
|
4945
5203
|
});
|
|
4946
|
-
|
|
5204
|
+
_context54.next = 8;
|
|
4947
5205
|
return this.buildSmallTicketProductMap(pendingOrder);
|
|
4948
5206
|
case 8:
|
|
4949
|
-
productMap =
|
|
5207
|
+
productMap = _context54.sent;
|
|
4950
5208
|
orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
|
|
4951
|
-
return
|
|
5209
|
+
return _context54.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
|
|
4952
5210
|
requireFullyPaid: true,
|
|
4953
5211
|
productMap: productMap
|
|
4954
5212
|
}));
|
|
4955
5213
|
case 11:
|
|
4956
5214
|
case "end":
|
|
4957
|
-
return
|
|
5215
|
+
return _context54.stop();
|
|
4958
5216
|
}
|
|
4959
|
-
},
|
|
5217
|
+
}, _callee54, this);
|
|
4960
5218
|
}));
|
|
4961
|
-
function buildPendingSyncCheckoutOrder(
|
|
5219
|
+
function buildPendingSyncCheckoutOrder(_x61) {
|
|
4962
5220
|
return _buildPendingSyncCheckoutOrder.apply(this, arguments);
|
|
4963
5221
|
}
|
|
4964
5222
|
return buildPendingSyncCheckoutOrder;
|
|
@@ -5006,13 +5264,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
5006
5264
|
}, {
|
|
5007
5265
|
key: "sumPaidOrderPayments",
|
|
5008
5266
|
value: function sumPaidOrderPayments(payments) {
|
|
5009
|
-
var
|
|
5267
|
+
var _this12 = this;
|
|
5010
5268
|
if (!Array.isArray(payments)) return 0;
|
|
5011
5269
|
return payments.reduce(function (sum, payment) {
|
|
5012
5270
|
var _payment$amount;
|
|
5013
5271
|
var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
|
|
5014
5272
|
if (status === 'voided' || status === 'failed' || status === 'cancelled') return sum;
|
|
5015
|
-
return sum +
|
|
5273
|
+
return sum + _this12.toAmountNumber((_payment$amount = payment === null || payment === void 0 ? void 0 : payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment === null || payment === void 0 ? void 0 : payment.origin_amount);
|
|
5016
5274
|
}, 0);
|
|
5017
5275
|
}
|
|
5018
5276
|
}, {
|
|
@@ -5026,12 +5284,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
5026
5284
|
}, {
|
|
5027
5285
|
key: "buildSmallTicketProductMap",
|
|
5028
5286
|
value: function () {
|
|
5029
|
-
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5030
|
-
var _this$
|
|
5031
|
-
|
|
5287
|
+
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(order) {
|
|
5288
|
+
var _this$products3,
|
|
5289
|
+
_this13 = this;
|
|
5032
5290
|
var products, productIdSet, productIds, entries;
|
|
5033
|
-
return _regeneratorRuntime().wrap(function
|
|
5034
|
-
while (1) switch (
|
|
5291
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
5292
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
5035
5293
|
case 0:
|
|
5036
5294
|
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
|
|
5037
5295
|
productIdSet = new Set();
|
|
@@ -5052,46 +5310,46 @@ var Server = /*#__PURE__*/function () {
|
|
|
5052
5310
|
}
|
|
5053
5311
|
});
|
|
5054
5312
|
productIds = Array.from(productIdSet);
|
|
5055
|
-
if (!(!productIds.length || typeof ((_this$
|
|
5056
|
-
|
|
5313
|
+
if (!(!productIds.length || typeof ((_this$products3 = this.products) === null || _this$products3 === void 0 ? void 0 : _this$products3.getProductById) !== 'function')) {
|
|
5314
|
+
_context56.next = 6;
|
|
5057
5315
|
break;
|
|
5058
5316
|
}
|
|
5059
|
-
return
|
|
5317
|
+
return _context56.abrupt("return", {});
|
|
5060
5318
|
case 6:
|
|
5061
|
-
|
|
5319
|
+
_context56.next = 8;
|
|
5062
5320
|
return Promise.all(productIds.map( /*#__PURE__*/function () {
|
|
5063
|
-
var _ref60 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5064
|
-
var
|
|
5065
|
-
return _regeneratorRuntime().wrap(function
|
|
5066
|
-
while (1) switch (
|
|
5321
|
+
var _ref60 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(id) {
|
|
5322
|
+
var _this13$products, _this13$products$getP, product;
|
|
5323
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5324
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
5067
5325
|
case 0:
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
return (
|
|
5326
|
+
_context55.prev = 0;
|
|
5327
|
+
_context55.next = 3;
|
|
5328
|
+
return (_this13$products = _this13.products) === null || _this13$products === void 0 || (_this13$products$getP = _this13$products.getProductById) === null || _this13$products$getP === void 0 ? void 0 : _this13$products$getP.call(_this13$products, Number(id));
|
|
5071
5329
|
case 3:
|
|
5072
|
-
product =
|
|
5073
|
-
return
|
|
5330
|
+
product = _context55.sent;
|
|
5331
|
+
return _context55.abrupt("return", product ? [String(id), product] : null);
|
|
5074
5332
|
case 7:
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5333
|
+
_context55.prev = 7;
|
|
5334
|
+
_context55.t0 = _context55["catch"](0);
|
|
5335
|
+
_this13.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
|
|
5078
5336
|
product_id: id,
|
|
5079
|
-
error:
|
|
5337
|
+
error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
|
|
5080
5338
|
});
|
|
5081
|
-
return
|
|
5339
|
+
return _context55.abrupt("return", null);
|
|
5082
5340
|
case 11:
|
|
5083
5341
|
case "end":
|
|
5084
|
-
return
|
|
5342
|
+
return _context55.stop();
|
|
5085
5343
|
}
|
|
5086
|
-
},
|
|
5344
|
+
}, _callee55, null, [[0, 7]]);
|
|
5087
5345
|
}));
|
|
5088
|
-
return function (
|
|
5346
|
+
return function (_x63) {
|
|
5089
5347
|
return _ref60.apply(this, arguments);
|
|
5090
5348
|
};
|
|
5091
5349
|
}()));
|
|
5092
5350
|
case 8:
|
|
5093
|
-
entries =
|
|
5094
|
-
return
|
|
5351
|
+
entries = _context56.sent;
|
|
5352
|
+
return _context56.abrupt("return", entries.reduce(function (map, entry) {
|
|
5095
5353
|
if (!entry) return map;
|
|
5096
5354
|
var _entry = _slicedToArray(entry, 2),
|
|
5097
5355
|
id = _entry[0],
|
|
@@ -5101,25 +5359,190 @@ var Server = /*#__PURE__*/function () {
|
|
|
5101
5359
|
}, {}));
|
|
5102
5360
|
case 10:
|
|
5103
5361
|
case "end":
|
|
5104
|
-
return
|
|
5362
|
+
return _context56.stop();
|
|
5105
5363
|
}
|
|
5106
|
-
},
|
|
5364
|
+
}, _callee56, this);
|
|
5107
5365
|
}));
|
|
5108
|
-
function buildSmallTicketProductMap(
|
|
5366
|
+
function buildSmallTicketProductMap(_x62) {
|
|
5109
5367
|
return _buildSmallTicketProductMap.apply(this, arguments);
|
|
5110
5368
|
}
|
|
5111
5369
|
return buildSmallTicketProductMap;
|
|
5112
5370
|
}()
|
|
5371
|
+
}, {
|
|
5372
|
+
key: "collectSalesDetailProductIds",
|
|
5373
|
+
value: function collectSalesDetailProductIds(order) {
|
|
5374
|
+
var products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
|
|
5375
|
+
var productIds = new Set();
|
|
5376
|
+
var addProductId = function addProductId(rawProductId) {
|
|
5377
|
+
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return;
|
|
5378
|
+
var productId = Number(rawProductId);
|
|
5379
|
+
if (Number.isFinite(productId)) productIds.add(productId);
|
|
5380
|
+
};
|
|
5381
|
+
products.forEach(function (product) {
|
|
5382
|
+
var _product$product_id2;
|
|
5383
|
+
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);
|
|
5384
|
+
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
5385
|
+
product.product_bundle.forEach(function (bundle) {
|
|
5386
|
+
var _ref61, _bundle$bundle_produc2;
|
|
5387
|
+
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);
|
|
5388
|
+
});
|
|
5389
|
+
}
|
|
5390
|
+
});
|
|
5391
|
+
return Array.from(productIds);
|
|
5392
|
+
}
|
|
5393
|
+
}, {
|
|
5394
|
+
key: "buildSalesDetailProductSnapshotMap",
|
|
5395
|
+
value: function () {
|
|
5396
|
+
var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(order) {
|
|
5397
|
+
var _this$products4;
|
|
5398
|
+
var productIds, getSnapshots;
|
|
5399
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5400
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
5401
|
+
case 0:
|
|
5402
|
+
productIds = this.collectSalesDetailProductIds(order);
|
|
5403
|
+
getSnapshots = (_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductSnapshotsByIds;
|
|
5404
|
+
if (!(!productIds.length || typeof getSnapshots !== 'function')) {
|
|
5405
|
+
_context57.next = 4;
|
|
5406
|
+
break;
|
|
5407
|
+
}
|
|
5408
|
+
return _context57.abrupt("return", {});
|
|
5409
|
+
case 4:
|
|
5410
|
+
_context57.prev = 4;
|
|
5411
|
+
_context57.next = 7;
|
|
5412
|
+
return getSnapshots.call(this.products, productIds);
|
|
5413
|
+
case 7:
|
|
5414
|
+
return _context57.abrupt("return", _context57.sent);
|
|
5415
|
+
case 10:
|
|
5416
|
+
_context57.prev = 10;
|
|
5417
|
+
_context57.t0 = _context57["catch"](4);
|
|
5418
|
+
this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
|
|
5419
|
+
product_ids: productIds,
|
|
5420
|
+
error: _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0)
|
|
5421
|
+
});
|
|
5422
|
+
return _context57.abrupt("return", {});
|
|
5423
|
+
case 14:
|
|
5424
|
+
case "end":
|
|
5425
|
+
return _context57.stop();
|
|
5426
|
+
}
|
|
5427
|
+
}, _callee57, this, [[4, 10]]);
|
|
5428
|
+
}));
|
|
5429
|
+
function buildSalesDetailProductSnapshotMap(_x64) {
|
|
5430
|
+
return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
|
|
5431
|
+
}
|
|
5432
|
+
return buildSalesDetailProductSnapshotMap;
|
|
5433
|
+
}()
|
|
5434
|
+
}, {
|
|
5435
|
+
key: "withProductCatalogSnapshots",
|
|
5436
|
+
value: function withProductCatalogSnapshots(product, snapshotMap) {
|
|
5437
|
+
var _product$product_id3;
|
|
5438
|
+
if (!product || _typeof(product) !== 'object') return product;
|
|
5439
|
+
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;
|
|
5440
|
+
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return product;
|
|
5441
|
+
var productId = Number(rawProductId);
|
|
5442
|
+
if (!Number.isFinite(productId)) return product;
|
|
5443
|
+
var snapshot = snapshotMap[String(productId)];
|
|
5444
|
+
if (!snapshot) return product;
|
|
5445
|
+
var shouldFillCover = (product.product_cover === undefined || product.product_cover === null || product.product_cover === '') && snapshot.cover !== undefined && snapshot.cover !== null && snapshot.cover !== '';
|
|
5446
|
+
var metadata = product.metadata && _typeof(product.metadata) === 'object' ? product.metadata : {};
|
|
5447
|
+
var shouldFillHolderConfig = (metadata.holder_config === undefined || metadata.holder_config === null) && snapshot.holder_config !== undefined && snapshot.holder_config !== null;
|
|
5448
|
+
if (!shouldFillCover && !shouldFillHolderConfig) return product;
|
|
5449
|
+
return _objectSpread(_objectSpread(_objectSpread({}, product), shouldFillCover ? {
|
|
5450
|
+
product_cover: snapshot.cover
|
|
5451
|
+
} : {}), shouldFillHolderConfig ? {
|
|
5452
|
+
metadata: _objectSpread(_objectSpread({}, metadata), {}, {
|
|
5453
|
+
holder_config: snapshot.holder_config
|
|
5454
|
+
})
|
|
5455
|
+
} : {});
|
|
5456
|
+
}
|
|
5457
|
+
}, {
|
|
5458
|
+
key: "withBundleCatalogSnapshots",
|
|
5459
|
+
value: function withBundleCatalogSnapshots(product, snapshotMap) {
|
|
5460
|
+
if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
|
|
5461
|
+
var hasChanged = false;
|
|
5462
|
+
var productBundle = product.product_bundle.map(function (bundle) {
|
|
5463
|
+
var _ref62, _bundle$bundle_produc3;
|
|
5464
|
+
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
5465
|
+
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;
|
|
5466
|
+
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
|
|
5467
|
+
var productId = Number(rawProductId);
|
|
5468
|
+
if (!Number.isFinite(productId)) return bundle;
|
|
5469
|
+
var snapshot = snapshotMap[String(productId)];
|
|
5470
|
+
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 !== '';
|
|
5471
|
+
if (!shouldFillCover) return bundle;
|
|
5472
|
+
hasChanged = true;
|
|
5473
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
5474
|
+
cover: snapshot.cover
|
|
5475
|
+
});
|
|
5476
|
+
});
|
|
5477
|
+
if (!hasChanged) return product;
|
|
5478
|
+
return _objectSpread(_objectSpread({}, product), {}, {
|
|
5479
|
+
product_bundle: productBundle
|
|
5480
|
+
});
|
|
5481
|
+
}
|
|
5482
|
+
}, {
|
|
5483
|
+
key: "withSalesDetailProductSnapshots",
|
|
5484
|
+
value: function () {
|
|
5485
|
+
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(order) {
|
|
5486
|
+
var _this14 = this;
|
|
5487
|
+
var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
|
|
5488
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
5489
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
5490
|
+
case 0:
|
|
5491
|
+
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
|
|
5492
|
+
if (products !== null && products !== void 0 && products.length) {
|
|
5493
|
+
_context58.next = 3;
|
|
5494
|
+
break;
|
|
5495
|
+
}
|
|
5496
|
+
return _context58.abrupt("return", order);
|
|
5497
|
+
case 3:
|
|
5498
|
+
_context58.next = 5;
|
|
5499
|
+
return this.buildSalesDetailProductSnapshotMap(order);
|
|
5500
|
+
case 5:
|
|
5501
|
+
snapshotMap = _context58.sent;
|
|
5502
|
+
if (Object.keys(snapshotMap).length) {
|
|
5503
|
+
_context58.next = 8;
|
|
5504
|
+
break;
|
|
5505
|
+
}
|
|
5506
|
+
return _context58.abrupt("return", order);
|
|
5507
|
+
case 8:
|
|
5508
|
+
hasChanged = false;
|
|
5509
|
+
enrichedProducts = products.map(function (product) {
|
|
5510
|
+
var productWithBundleSnapshots = _this14.withBundleCatalogSnapshots(product, snapshotMap);
|
|
5511
|
+
var nextProduct = _this14.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
|
|
5512
|
+
if (nextProduct !== product) hasChanged = true;
|
|
5513
|
+
return nextProduct;
|
|
5514
|
+
});
|
|
5515
|
+
if (hasChanged) {
|
|
5516
|
+
_context58.next = 12;
|
|
5517
|
+
break;
|
|
5518
|
+
}
|
|
5519
|
+
return _context58.abrupt("return", order);
|
|
5520
|
+
case 12:
|
|
5521
|
+
enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
|
|
5522
|
+
products: enrichedProducts
|
|
5523
|
+
});
|
|
5524
|
+
return _context58.abrupt("return", enrichedOrder);
|
|
5525
|
+
case 14:
|
|
5526
|
+
case "end":
|
|
5527
|
+
return _context58.stop();
|
|
5528
|
+
}
|
|
5529
|
+
}, _callee58, this);
|
|
5530
|
+
}));
|
|
5531
|
+
function withSalesDetailProductSnapshots(_x65) {
|
|
5532
|
+
return _withSalesDetailProductSnapshots.apply(this, arguments);
|
|
5533
|
+
}
|
|
5534
|
+
return withSalesDetailProductSnapshots;
|
|
5535
|
+
}()
|
|
5113
5536
|
}, {
|
|
5114
5537
|
key: "withPendingSyncProductTitles",
|
|
5115
5538
|
value: function withPendingSyncProductTitles(order, productMap) {
|
|
5116
|
-
var
|
|
5539
|
+
var _this15 = this;
|
|
5117
5540
|
var products = Array.isArray(order.products) ? order.products : null;
|
|
5118
5541
|
if (!(products !== null && products !== void 0 && products.length)) return order;
|
|
5119
5542
|
return _objectSpread(_objectSpread({}, order), {}, {
|
|
5120
5543
|
products: products.map(function (product) {
|
|
5121
5544
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
5122
|
-
product_title:
|
|
5545
|
+
product_title: _this15.buildProductTitleSnapshot(product, productMap)
|
|
5123
5546
|
});
|
|
5124
5547
|
})
|
|
5125
5548
|
});
|
|
@@ -5127,18 +5550,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
5127
5550
|
}, {
|
|
5128
5551
|
key: "buildProductTitleSnapshot",
|
|
5129
5552
|
value: function buildProductTitleSnapshot(product, productMap) {
|
|
5130
|
-
var _product$
|
|
5553
|
+
var _product$product_id4,
|
|
5131
5554
|
_product$product,
|
|
5132
5555
|
_fallbackProduct$prod,
|
|
5133
|
-
|
|
5134
|
-
var productId = (_product$
|
|
5556
|
+
_this16 = this;
|
|
5557
|
+
var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
|
|
5135
5558
|
var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
|
|
5136
5559
|
var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
|
|
5137
5560
|
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
5561
|
var currentLocale = this.getProductTitleSnapshotCurrentLocale();
|
|
5139
5562
|
var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
|
|
5140
5563
|
return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
|
|
5141
|
-
snapshot[key] =
|
|
5564
|
+
snapshot[key] = _this16.resolveProductTitleValue(ownTitle, key, currentLocale) || _this16.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
|
|
5142
5565
|
return snapshot;
|
|
5143
5566
|
}, {});
|
|
5144
5567
|
}
|
|
@@ -5163,7 +5586,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5163
5586
|
}, {
|
|
5164
5587
|
key: "resolveProductTitleValue",
|
|
5165
5588
|
value: function resolveProductTitleValue(value, key, currentLocale) {
|
|
5166
|
-
var
|
|
5589
|
+
var _ref63, _ref64, _value$key;
|
|
5167
5590
|
if (value === undefined || value === null || value === '') return null;
|
|
5168
5591
|
if (_typeof(value) !== 'object') {
|
|
5169
5592
|
var title = String(value);
|
|
@@ -5173,7 +5596,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5173
5596
|
}
|
|
5174
5597
|
var normalizedKey = key.replace('-', '_');
|
|
5175
5598
|
var dashedKey = key.replace('_', '-');
|
|
5176
|
-
var rawValue = (
|
|
5599
|
+
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
5600
|
if (rawValue === undefined || rawValue === null || rawValue === '') return null;
|
|
5178
5601
|
if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
|
|
5179
5602
|
return String(rawValue);
|
|
@@ -5236,50 +5659,50 @@ var Server = /*#__PURE__*/function () {
|
|
|
5236
5659
|
}, {
|
|
5237
5660
|
key: "enrichPaymentNamesByCode",
|
|
5238
5661
|
value: function () {
|
|
5239
|
-
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5240
|
-
var
|
|
5241
|
-
var payments, hasMissingName, paymentModule, payMethods, nameByCode,
|
|
5242
|
-
return _regeneratorRuntime().wrap(function
|
|
5243
|
-
while (1) switch (
|
|
5662
|
+
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(order) {
|
|
5663
|
+
var _this17 = this;
|
|
5664
|
+
var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator13, _step13, method, codeKey, name, hasResolvedName, enrichedPayments;
|
|
5665
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context59) {
|
|
5666
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
5244
5667
|
case 0:
|
|
5245
5668
|
payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
|
|
5246
5669
|
hasMissingName = payments.some(function (payment) {
|
|
5247
|
-
return
|
|
5670
|
+
return _this17.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this17.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
|
|
5248
5671
|
});
|
|
5249
5672
|
if (hasMissingName) {
|
|
5250
|
-
|
|
5673
|
+
_context59.next = 4;
|
|
5251
5674
|
break;
|
|
5252
5675
|
}
|
|
5253
|
-
return
|
|
5676
|
+
return _context59.abrupt("return", order);
|
|
5254
5677
|
case 4:
|
|
5255
|
-
|
|
5256
|
-
|
|
5678
|
+
_context59.prev = 4;
|
|
5679
|
+
_context59.next = 7;
|
|
5257
5680
|
return this.getPaymentRouteModule();
|
|
5258
5681
|
case 7:
|
|
5259
|
-
paymentModule =
|
|
5260
|
-
|
|
5682
|
+
paymentModule = _context59.sent;
|
|
5683
|
+
_context59.next = 10;
|
|
5261
5684
|
return paymentModule.getPayMethodListAsync();
|
|
5262
5685
|
case 10:
|
|
5263
|
-
payMethods =
|
|
5686
|
+
payMethods = _context59.sent;
|
|
5264
5687
|
nameByCode = new Map();
|
|
5265
|
-
|
|
5688
|
+
_iterator13 = _createForOfIteratorHelper(payMethods || []);
|
|
5266
5689
|
try {
|
|
5267
|
-
for (
|
|
5268
|
-
method =
|
|
5690
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
5691
|
+
method = _step13.value;
|
|
5269
5692
|
codeKey = this.getPaymentCodeKey(method === null || method === void 0 ? void 0 : method.code);
|
|
5270
5693
|
name = this.resolveFirstProductTitleValue(method === null || method === void 0 ? void 0 : method.name);
|
|
5271
5694
|
if (codeKey && name) nameByCode.set(codeKey, name);
|
|
5272
5695
|
}
|
|
5273
5696
|
} catch (err) {
|
|
5274
|
-
|
|
5697
|
+
_iterator13.e(err);
|
|
5275
5698
|
} finally {
|
|
5276
|
-
|
|
5699
|
+
_iterator13.f();
|
|
5277
5700
|
}
|
|
5278
5701
|
hasResolvedName = false;
|
|
5279
5702
|
enrichedPayments = payments.map(function (payment) {
|
|
5280
|
-
if (!
|
|
5281
|
-
if (!
|
|
5282
|
-
var name = nameByCode.get(
|
|
5703
|
+
if (!_this17.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
|
|
5704
|
+
if (!_this17.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
|
|
5705
|
+
var name = nameByCode.get(_this17.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
|
|
5283
5706
|
if (!name) return payment;
|
|
5284
5707
|
hasResolvedName = true;
|
|
5285
5708
|
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
@@ -5287,28 +5710,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
5287
5710
|
});
|
|
5288
5711
|
});
|
|
5289
5712
|
if (hasResolvedName) {
|
|
5290
|
-
|
|
5713
|
+
_context59.next = 18;
|
|
5291
5714
|
break;
|
|
5292
5715
|
}
|
|
5293
|
-
return
|
|
5716
|
+
return _context59.abrupt("return", order);
|
|
5294
5717
|
case 18:
|
|
5295
|
-
return
|
|
5718
|
+
return _context59.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
|
|
5296
5719
|
payments: enrichedPayments
|
|
5297
5720
|
}));
|
|
5298
5721
|
case 21:
|
|
5299
|
-
|
|
5300
|
-
|
|
5722
|
+
_context59.prev = 21;
|
|
5723
|
+
_context59.t0 = _context59["catch"](4);
|
|
5301
5724
|
this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
|
|
5302
|
-
error:
|
|
5725
|
+
error: _context59.t0 instanceof Error ? _context59.t0.message : String(_context59.t0)
|
|
5303
5726
|
});
|
|
5304
|
-
return
|
|
5727
|
+
return _context59.abrupt("return", order);
|
|
5305
5728
|
case 25:
|
|
5306
5729
|
case "end":
|
|
5307
|
-
return
|
|
5730
|
+
return _context59.stop();
|
|
5308
5731
|
}
|
|
5309
|
-
},
|
|
5732
|
+
}, _callee59, this, [[4, 21]]);
|
|
5310
5733
|
}));
|
|
5311
|
-
function enrichPaymentNamesByCode(
|
|
5734
|
+
function enrichPaymentNamesByCode(_x66) {
|
|
5312
5735
|
return _enrichPaymentNamesByCode.apply(this, arguments);
|
|
5313
5736
|
}
|
|
5314
5737
|
return enrichPaymentNamesByCode;
|
|
@@ -5316,66 +5739,66 @@ var Server = /*#__PURE__*/function () {
|
|
|
5316
5739
|
}, {
|
|
5317
5740
|
key: "withLocalSmallTicketData",
|
|
5318
5741
|
value: function () {
|
|
5319
|
-
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5742
|
+
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(order, options) {
|
|
5320
5743
|
var _options$productMap, enrichedOrder, productMap, smallTicketData;
|
|
5321
|
-
return _regeneratorRuntime().wrap(function
|
|
5322
|
-
while (1) switch (
|
|
5744
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
5745
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
5323
5746
|
case 0:
|
|
5324
5747
|
if (this.shouldBuildSmallTicketData(order)) {
|
|
5325
|
-
|
|
5748
|
+
_context60.next = 2;
|
|
5326
5749
|
break;
|
|
5327
5750
|
}
|
|
5328
|
-
return
|
|
5751
|
+
return _context60.abrupt("return", order);
|
|
5329
5752
|
case 2:
|
|
5330
5753
|
if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
|
|
5331
|
-
|
|
5754
|
+
_context60.next = 4;
|
|
5332
5755
|
break;
|
|
5333
5756
|
}
|
|
5334
|
-
return
|
|
5757
|
+
return _context60.abrupt("return", order);
|
|
5335
5758
|
case 4:
|
|
5336
|
-
|
|
5337
|
-
|
|
5759
|
+
_context60.prev = 4;
|
|
5760
|
+
_context60.next = 7;
|
|
5338
5761
|
return this.enrichPaymentNamesByCode(order);
|
|
5339
5762
|
case 7:
|
|
5340
|
-
enrichedOrder =
|
|
5763
|
+
enrichedOrder = _context60.sent;
|
|
5341
5764
|
if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
|
|
5342
|
-
|
|
5765
|
+
_context60.next = 12;
|
|
5343
5766
|
break;
|
|
5344
5767
|
}
|
|
5345
|
-
|
|
5346
|
-
|
|
5768
|
+
_context60.t0 = _options$productMap;
|
|
5769
|
+
_context60.next = 15;
|
|
5347
5770
|
break;
|
|
5348
5771
|
case 12:
|
|
5349
|
-
|
|
5772
|
+
_context60.next = 14;
|
|
5350
5773
|
return this.buildSmallTicketProductMap(enrichedOrder);
|
|
5351
5774
|
case 14:
|
|
5352
|
-
|
|
5775
|
+
_context60.t0 = _context60.sent;
|
|
5353
5776
|
case 15:
|
|
5354
|
-
productMap =
|
|
5777
|
+
productMap = _context60.t0;
|
|
5355
5778
|
smallTicketData = buildSmallTicketData({
|
|
5356
5779
|
order: enrichedOrder,
|
|
5357
5780
|
shopInfo: this.getSmallTicketShopInfo(),
|
|
5358
5781
|
productMap: productMap
|
|
5359
5782
|
});
|
|
5360
|
-
return
|
|
5783
|
+
return _context60.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
|
|
5361
5784
|
payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
|
|
5362
5785
|
small_ticket_data: smallTicketData
|
|
5363
5786
|
})
|
|
5364
5787
|
}));
|
|
5365
5788
|
case 20:
|
|
5366
|
-
|
|
5367
|
-
|
|
5789
|
+
_context60.prev = 20;
|
|
5790
|
+
_context60.t1 = _context60["catch"](4);
|
|
5368
5791
|
this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
|
|
5369
|
-
error:
|
|
5792
|
+
error: _context60.t1 instanceof Error ? _context60.t1.message : String(_context60.t1)
|
|
5370
5793
|
});
|
|
5371
|
-
return
|
|
5794
|
+
return _context60.abrupt("return", order);
|
|
5372
5795
|
case 24:
|
|
5373
5796
|
case "end":
|
|
5374
|
-
return
|
|
5797
|
+
return _context60.stop();
|
|
5375
5798
|
}
|
|
5376
|
-
},
|
|
5799
|
+
}, _callee60, this, [[4, 20]]);
|
|
5377
5800
|
}));
|
|
5378
|
-
function withLocalSmallTicketData(
|
|
5801
|
+
function withLocalSmallTicketData(_x67, _x68) {
|
|
5379
5802
|
return _withLocalSmallTicketData.apply(this, arguments);
|
|
5380
5803
|
}
|
|
5381
5804
|
return withLocalSmallTicketData;
|
|
@@ -5437,22 +5860,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
5437
5860
|
}, {
|
|
5438
5861
|
key: "handleUpdateLocalOrdersBatch",
|
|
5439
5862
|
value: (function () {
|
|
5440
|
-
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5863
|
+
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(orderIds) {
|
|
5441
5864
|
var _this$app17;
|
|
5442
|
-
var existedBefore,
|
|
5443
|
-
return _regeneratorRuntime().wrap(function
|
|
5444
|
-
while (1) switch (
|
|
5865
|
+
var existedBefore, _iterator14, _step14, id, fetched, message, fetchedMap, _iterator15, _step15, order, oid, freshOrders, succeedIds, failed, _iterator16, _step16, _id, fresh, _message2, overwritten, inserted;
|
|
5866
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
5867
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
5445
5868
|
case 0:
|
|
5446
5869
|
this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
|
|
5447
5870
|
count: orderIds.length,
|
|
5448
5871
|
orderIds: orderIds
|
|
5449
5872
|
});
|
|
5450
5873
|
if (this.order) {
|
|
5451
|
-
|
|
5874
|
+
_context61.next = 4;
|
|
5452
5875
|
break;
|
|
5453
5876
|
}
|
|
5454
5877
|
this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
|
|
5455
|
-
return
|
|
5878
|
+
return _context61.abrupt("return", {
|
|
5456
5879
|
code: 500,
|
|
5457
5880
|
status: false,
|
|
5458
5881
|
message: 'Order 模块未注册',
|
|
@@ -5460,11 +5883,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5460
5883
|
});
|
|
5461
5884
|
case 4:
|
|
5462
5885
|
if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && _this$app17.request) {
|
|
5463
|
-
|
|
5886
|
+
_context61.next = 7;
|
|
5464
5887
|
break;
|
|
5465
5888
|
}
|
|
5466
5889
|
this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
|
|
5467
|
-
return
|
|
5890
|
+
return _context61.abrupt("return", {
|
|
5468
5891
|
code: 500,
|
|
5469
5892
|
status: false,
|
|
5470
5893
|
message: 'app.request 不可用',
|
|
@@ -5473,35 +5896,35 @@ var Server = /*#__PURE__*/function () {
|
|
|
5473
5896
|
case 7:
|
|
5474
5897
|
// 拉取前先记录"本地是否已存在",用于区分 overwritten / inserted
|
|
5475
5898
|
existedBefore = new Map();
|
|
5476
|
-
|
|
5899
|
+
_iterator14 = _createForOfIteratorHelper(orderIds);
|
|
5477
5900
|
try {
|
|
5478
|
-
for (
|
|
5479
|
-
id =
|
|
5901
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
5902
|
+
id = _step14.value;
|
|
5480
5903
|
existedBefore.set(id, !!this.order.getOrderByOrderId(id));
|
|
5481
5904
|
}
|
|
5482
5905
|
|
|
5483
5906
|
// 走 orderDataSource 的批量 HTTP 通道,一次请求拉回多笔详情
|
|
5484
5907
|
} catch (err) {
|
|
5485
|
-
|
|
5908
|
+
_iterator14.e(err);
|
|
5486
5909
|
} finally {
|
|
5487
|
-
|
|
5910
|
+
_iterator14.f();
|
|
5488
5911
|
}
|
|
5489
5912
|
fetched = [];
|
|
5490
|
-
|
|
5491
|
-
|
|
5913
|
+
_context61.prev = 11;
|
|
5914
|
+
_context61.next = 14;
|
|
5492
5915
|
return this.order.fetchOrdersByHttp(orderIds);
|
|
5493
5916
|
case 14:
|
|
5494
|
-
fetched =
|
|
5495
|
-
|
|
5917
|
+
fetched = _context61.sent;
|
|
5918
|
+
_context61.next = 22;
|
|
5496
5919
|
break;
|
|
5497
5920
|
case 17:
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
message =
|
|
5921
|
+
_context61.prev = 17;
|
|
5922
|
+
_context61.t0 = _context61["catch"](11);
|
|
5923
|
+
message = _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0);
|
|
5501
5924
|
this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
|
|
5502
5925
|
message: message
|
|
5503
5926
|
});
|
|
5504
|
-
return
|
|
5927
|
+
return _context61.abrupt("return", {
|
|
5505
5928
|
code: 500,
|
|
5506
5929
|
status: false,
|
|
5507
5930
|
message: message,
|
|
@@ -5510,45 +5933,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
5510
5933
|
case 22:
|
|
5511
5934
|
// 按返回结果中的 order_id 建索引,未命中即视为单笔失败
|
|
5512
5935
|
fetchedMap = new Map();
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5936
|
+
_iterator15 = _createForOfIteratorHelper(fetched);
|
|
5937
|
+
_context61.prev = 24;
|
|
5938
|
+
_iterator15.s();
|
|
5516
5939
|
case 26:
|
|
5517
|
-
if ((
|
|
5518
|
-
|
|
5940
|
+
if ((_step15 = _iterator15.n()).done) {
|
|
5941
|
+
_context61.next = 34;
|
|
5519
5942
|
break;
|
|
5520
5943
|
}
|
|
5521
|
-
order =
|
|
5944
|
+
order = _step15.value;
|
|
5522
5945
|
oid = order === null || order === void 0 ? void 0 : order.order_id;
|
|
5523
5946
|
if (!(oid === undefined || oid === null)) {
|
|
5524
|
-
|
|
5947
|
+
_context61.next = 31;
|
|
5525
5948
|
break;
|
|
5526
5949
|
}
|
|
5527
|
-
return
|
|
5950
|
+
return _context61.abrupt("continue", 32);
|
|
5528
5951
|
case 31:
|
|
5529
5952
|
fetchedMap.set(String(oid), order);
|
|
5530
5953
|
case 32:
|
|
5531
|
-
|
|
5954
|
+
_context61.next = 26;
|
|
5532
5955
|
break;
|
|
5533
5956
|
case 34:
|
|
5534
|
-
|
|
5957
|
+
_context61.next = 39;
|
|
5535
5958
|
break;
|
|
5536
5959
|
case 36:
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5960
|
+
_context61.prev = 36;
|
|
5961
|
+
_context61.t1 = _context61["catch"](24);
|
|
5962
|
+
_iterator15.e(_context61.t1);
|
|
5540
5963
|
case 39:
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
return
|
|
5964
|
+
_context61.prev = 39;
|
|
5965
|
+
_iterator15.f();
|
|
5966
|
+
return _context61.finish(39);
|
|
5544
5967
|
case 42:
|
|
5545
5968
|
freshOrders = [];
|
|
5546
5969
|
succeedIds = [];
|
|
5547
5970
|
failed = [];
|
|
5548
|
-
|
|
5971
|
+
_iterator16 = _createForOfIteratorHelper(orderIds);
|
|
5549
5972
|
try {
|
|
5550
|
-
for (
|
|
5551
|
-
_id =
|
|
5973
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
5974
|
+
_id = _step16.value;
|
|
5552
5975
|
fresh = fetchedMap.get(_id);
|
|
5553
5976
|
if (fresh) {
|
|
5554
5977
|
freshOrders.push(fresh);
|
|
@@ -5561,28 +5984,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
5561
5984
|
}
|
|
5562
5985
|
}
|
|
5563
5986
|
} catch (err) {
|
|
5564
|
-
|
|
5987
|
+
_iterator16.e(err);
|
|
5565
5988
|
} finally {
|
|
5566
|
-
|
|
5989
|
+
_iterator16.f();
|
|
5567
5990
|
}
|
|
5568
5991
|
if (!(freshOrders.length > 0)) {
|
|
5569
|
-
|
|
5992
|
+
_context61.next = 58;
|
|
5570
5993
|
break;
|
|
5571
5994
|
}
|
|
5572
|
-
|
|
5573
|
-
|
|
5995
|
+
_context61.prev = 48;
|
|
5996
|
+
_context61.next = 51;
|
|
5574
5997
|
return this.order.upsertOrdersFromRemote(freshOrders);
|
|
5575
5998
|
case 51:
|
|
5576
|
-
|
|
5999
|
+
_context61.next = 58;
|
|
5577
6000
|
break;
|
|
5578
6001
|
case 53:
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
_message2 =
|
|
6002
|
+
_context61.prev = 53;
|
|
6003
|
+
_context61.t2 = _context61["catch"](48);
|
|
6004
|
+
_message2 = _context61.t2 instanceof Error ? _context61.t2.message : String(_context61.t2);
|
|
5582
6005
|
this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
|
|
5583
6006
|
message: _message2
|
|
5584
6007
|
});
|
|
5585
|
-
return
|
|
6008
|
+
return _context61.abrupt("return", {
|
|
5586
6009
|
code: 500,
|
|
5587
6010
|
status: false,
|
|
5588
6011
|
message: _message2,
|
|
@@ -5601,7 +6024,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5601
6024
|
insertedCount: inserted.length,
|
|
5602
6025
|
failedCount: failed.length
|
|
5603
6026
|
});
|
|
5604
|
-
return
|
|
6027
|
+
return _context61.abrupt("return", {
|
|
5605
6028
|
code: 200,
|
|
5606
6029
|
status: true,
|
|
5607
6030
|
message: '',
|
|
@@ -5613,11 +6036,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5613
6036
|
});
|
|
5614
6037
|
case 62:
|
|
5615
6038
|
case "end":
|
|
5616
|
-
return
|
|
6039
|
+
return _context61.stop();
|
|
5617
6040
|
}
|
|
5618
|
-
},
|
|
6041
|
+
}, _callee61, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
|
|
5619
6042
|
}));
|
|
5620
|
-
function handleUpdateLocalOrdersBatch(
|
|
6043
|
+
function handleUpdateLocalOrdersBatch(_x69) {
|
|
5621
6044
|
return _handleUpdateLocalOrdersBatch.apply(this, arguments);
|
|
5622
6045
|
}
|
|
5623
6046
|
return handleUpdateLocalOrdersBatch;
|
|
@@ -5638,11 +6061,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5638
6061
|
var queryIndex = url.indexOf('?');
|
|
5639
6062
|
if (queryIndex < 0) return null;
|
|
5640
6063
|
var query = url.slice(queryIndex + 1);
|
|
5641
|
-
var
|
|
5642
|
-
|
|
6064
|
+
var _iterator17 = _createForOfIteratorHelper(query.split('&')),
|
|
6065
|
+
_step17;
|
|
5643
6066
|
try {
|
|
5644
|
-
for (
|
|
5645
|
-
var pair =
|
|
6067
|
+
for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
|
|
6068
|
+
var pair = _step17.value;
|
|
5646
6069
|
if (!pair) continue;
|
|
5647
6070
|
var _pair$split = pair.split('='),
|
|
5648
6071
|
_pair$split2 = _slicedToArray(_pair$split, 2),
|
|
@@ -5658,9 +6081,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5658
6081
|
}
|
|
5659
6082
|
}
|
|
5660
6083
|
} catch (err) {
|
|
5661
|
-
|
|
6084
|
+
_iterator17.e(err);
|
|
5662
6085
|
} finally {
|
|
5663
|
-
|
|
6086
|
+
_iterator17.f();
|
|
5664
6087
|
}
|
|
5665
6088
|
return null;
|
|
5666
6089
|
}
|
|
@@ -5859,10 +6282,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5859
6282
|
value: function extractBackendErrorResponse(error) {
|
|
5860
6283
|
var _error$response3,
|
|
5861
6284
|
_error$response4,
|
|
5862
|
-
|
|
6285
|
+
_this18 = this;
|
|
5863
6286
|
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
6287
|
return candidates.find(function (candidate) {
|
|
5865
|
-
return
|
|
6288
|
+
return _this18.isExplicitBackendErrorResponse(candidate);
|
|
5866
6289
|
}) || null;
|
|
5867
6290
|
}
|
|
5868
6291
|
}, {
|
|
@@ -5981,24 +6404,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
5981
6404
|
}, {
|
|
5982
6405
|
key: "recomputeAndNotifyFloorPlanQuery",
|
|
5983
6406
|
value: (function () {
|
|
5984
|
-
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5985
|
-
var
|
|
5986
|
-
return _regeneratorRuntime().wrap(function
|
|
5987
|
-
while (1) switch (
|
|
6407
|
+
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62() {
|
|
6408
|
+
var _iterator18, _step18, _step18$value, subscriberId, sub, result, errorMessage;
|
|
6409
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
6410
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
5988
6411
|
case 0:
|
|
5989
6412
|
if (!(this.floorPlanQuerySubscribers.size === 0)) {
|
|
5990
|
-
|
|
6413
|
+
_context62.next = 2;
|
|
5991
6414
|
break;
|
|
5992
6415
|
}
|
|
5993
|
-
return
|
|
6416
|
+
return _context62.abrupt("return");
|
|
5994
6417
|
case 2:
|
|
5995
6418
|
this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
|
|
5996
6419
|
subscriberCount: this.floorPlanQuerySubscribers.size
|
|
5997
6420
|
});
|
|
5998
|
-
|
|
6421
|
+
_iterator18 = _createForOfIteratorHelper(this.floorPlanQuerySubscribers.entries());
|
|
5999
6422
|
try {
|
|
6000
|
-
for (
|
|
6001
|
-
|
|
6423
|
+
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
6424
|
+
_step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], sub = _step18$value[1];
|
|
6002
6425
|
try {
|
|
6003
6426
|
result = this.computeFloorPlanQueryResult(sub.context);
|
|
6004
6427
|
sub.callback(result);
|
|
@@ -6014,15 +6437,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
6014
6437
|
}
|
|
6015
6438
|
}
|
|
6016
6439
|
} catch (err) {
|
|
6017
|
-
|
|
6440
|
+
_iterator18.e(err);
|
|
6018
6441
|
} finally {
|
|
6019
|
-
|
|
6442
|
+
_iterator18.f();
|
|
6020
6443
|
}
|
|
6021
6444
|
case 5:
|
|
6022
6445
|
case "end":
|
|
6023
|
-
return
|
|
6446
|
+
return _context62.stop();
|
|
6024
6447
|
}
|
|
6025
|
-
},
|
|
6448
|
+
}, _callee62, this);
|
|
6026
6449
|
}));
|
|
6027
6450
|
function recomputeAndNotifyFloorPlanQuery() {
|
|
6028
6451
|
return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
|
|
@@ -6052,21 +6475,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
6052
6475
|
* filter 逻辑暂为 mock,仅记录参数
|
|
6053
6476
|
*/
|
|
6054
6477
|
function () {
|
|
6055
|
-
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6478
|
+
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(data) {
|
|
6056
6479
|
var rawList, result;
|
|
6057
|
-
return _regeneratorRuntime().wrap(function
|
|
6058
|
-
while (1) switch (
|
|
6480
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
6481
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
6059
6482
|
case 0:
|
|
6060
6483
|
this.logInfo('computeOrderQueryResult: 开始过滤', {
|
|
6061
6484
|
data: data
|
|
6062
6485
|
});
|
|
6063
6486
|
console.log('[Server] computeOrderQueryResult', data);
|
|
6064
6487
|
if (this.order) {
|
|
6065
|
-
|
|
6488
|
+
_context63.next = 5;
|
|
6066
6489
|
break;
|
|
6067
6490
|
}
|
|
6068
6491
|
this.logError('computeOrderQueryResult: Order 模块未注册');
|
|
6069
|
-
return
|
|
6492
|
+
return _context63.abrupt("return", {
|
|
6070
6493
|
code: 500,
|
|
6071
6494
|
message: 'Order 模块未注册',
|
|
6072
6495
|
data: {
|
|
@@ -6090,7 +6513,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6090
6513
|
skip: result.skip,
|
|
6091
6514
|
rejected: result.rejected
|
|
6092
6515
|
});
|
|
6093
|
-
return
|
|
6516
|
+
return _context63.abrupt("return", {
|
|
6094
6517
|
code: 200,
|
|
6095
6518
|
data: result,
|
|
6096
6519
|
message: '',
|
|
@@ -6098,11 +6521,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6098
6521
|
});
|
|
6099
6522
|
case 10:
|
|
6100
6523
|
case "end":
|
|
6101
|
-
return
|
|
6524
|
+
return _context63.stop();
|
|
6102
6525
|
}
|
|
6103
|
-
},
|
|
6526
|
+
}, _callee63, this);
|
|
6104
6527
|
}));
|
|
6105
|
-
function computeOrderQueryResult(
|
|
6528
|
+
function computeOrderQueryResult(_x70) {
|
|
6106
6529
|
return _computeOrderQueryResult.apply(this, arguments);
|
|
6107
6530
|
}
|
|
6108
6531
|
return computeOrderQueryResult;
|
|
@@ -6115,17 +6538,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
6115
6538
|
}, {
|
|
6116
6539
|
key: "computeBookingQueryResult",
|
|
6117
6540
|
value: (function () {
|
|
6118
|
-
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6541
|
+
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(data) {
|
|
6119
6542
|
var rawOrders, result;
|
|
6120
|
-
return _regeneratorRuntime().wrap(function
|
|
6121
|
-
while (1) switch (
|
|
6543
|
+
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
6544
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
6122
6545
|
case 0:
|
|
6123
6546
|
if (this.order) {
|
|
6124
|
-
|
|
6547
|
+
_context64.next = 3;
|
|
6125
6548
|
break;
|
|
6126
6549
|
}
|
|
6127
6550
|
this.logError('computeBookingQueryResult: Order 模块未注册');
|
|
6128
|
-
return
|
|
6551
|
+
return _context64.abrupt("return", {
|
|
6129
6552
|
code: 500,
|
|
6130
6553
|
message: 'Order 模块未注册',
|
|
6131
6554
|
data: {
|
|
@@ -6144,7 +6567,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6144
6567
|
size: result.size,
|
|
6145
6568
|
skip: result.skip
|
|
6146
6569
|
});
|
|
6147
|
-
return
|
|
6570
|
+
return _context64.abrupt("return", {
|
|
6148
6571
|
code: 200,
|
|
6149
6572
|
data: result,
|
|
6150
6573
|
message: '',
|
|
@@ -6152,11 +6575,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6152
6575
|
});
|
|
6153
6576
|
case 8:
|
|
6154
6577
|
case "end":
|
|
6155
|
-
return
|
|
6578
|
+
return _context64.stop();
|
|
6156
6579
|
}
|
|
6157
|
-
},
|
|
6580
|
+
}, _callee64, this);
|
|
6158
6581
|
}));
|
|
6159
|
-
function computeBookingQueryResult(
|
|
6582
|
+
function computeBookingQueryResult(_x71) {
|
|
6160
6583
|
return _computeBookingQueryResult.apply(this, arguments);
|
|
6161
6584
|
}
|
|
6162
6585
|
return computeBookingQueryResult;
|
|
@@ -6215,20 +6638,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
6215
6638
|
}, {
|
|
6216
6639
|
key: "computeProductQueryResult",
|
|
6217
6640
|
value: (function () {
|
|
6218
|
-
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6641
|
+
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(context, options) {
|
|
6219
6642
|
var _menu_list_ids$length3,
|
|
6220
|
-
|
|
6221
|
-
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 (
|
|
6643
|
+
_this19 = this;
|
|
6644
|
+
var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
|
|
6645
|
+
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
6646
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
6224
6647
|
case 0:
|
|
6225
6648
|
tTotal = performance.now();
|
|
6226
|
-
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;
|
|
6649
|
+
menu_list_ids = context.menu_list_ids, ids = context.ids, schedule_date = context.schedule_date, schedule_datetime = context.schedule_datetime, customer_id = context.customer_id, extension_type = context.extension_type, product_id = context.product_id, strategy_context = context.strategy_context;
|
|
6227
6650
|
queryIds = Array.isArray(ids) ? ids.map(function (id) {
|
|
6228
6651
|
return Number(id);
|
|
6229
6652
|
}).filter(function (id) {
|
|
6230
6653
|
return Number.isFinite(id);
|
|
6231
6654
|
}) : [];
|
|
6655
|
+
formatterContext = this.buildProductFormatterContext({
|
|
6656
|
+
schedule_date: schedule_date,
|
|
6657
|
+
schedule_datetime: schedule_datetime,
|
|
6658
|
+
customer_id: customer_id,
|
|
6659
|
+
strategy_context: strategy_context
|
|
6660
|
+
});
|
|
6232
6661
|
this.logInfo('computeProductQueryResult 开始', {
|
|
6233
6662
|
menuListIdsCount: (_menu_list_ids$length3 = menu_list_ids === null || menu_list_ids === void 0 ? void 0 : menu_list_ids.length) !== null && _menu_list_ids$length3 !== void 0 ? _menu_list_ids$length3 : 0,
|
|
6234
6663
|
ids: queryIds,
|
|
@@ -6237,38 +6666,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
6237
6666
|
customer_id: customer_id,
|
|
6238
6667
|
extension_type: extension_type,
|
|
6239
6668
|
product_id: product_id,
|
|
6669
|
+
strategyContextKeys: strategy_context ? Object.keys(strategy_context) : [],
|
|
6240
6670
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6241
6671
|
});
|
|
6242
6672
|
if (this.products) {
|
|
6243
|
-
|
|
6673
|
+
_context65.next = 8;
|
|
6244
6674
|
break;
|
|
6245
6675
|
}
|
|
6246
6676
|
this.logError('computeProductQueryResult: Products 模块未注册');
|
|
6247
|
-
return
|
|
6677
|
+
return _context65.abrupt("return", {
|
|
6248
6678
|
message: 'Products 模块未注册',
|
|
6249
|
-
data:
|
|
6250
|
-
list: [],
|
|
6251
|
-
count: 0
|
|
6252
|
-
}
|
|
6679
|
+
data: this.buildProductQueryResultPayload([], 0)
|
|
6253
6680
|
});
|
|
6254
|
-
case
|
|
6681
|
+
case 8:
|
|
6255
6682
|
if (!(queryIds.length > 0)) {
|
|
6256
|
-
|
|
6683
|
+
_context65.next = 20;
|
|
6257
6684
|
break;
|
|
6258
6685
|
}
|
|
6259
6686
|
uniqueIds = Array.from(new Set(queryIds));
|
|
6260
6687
|
_tPrice = performance.now();
|
|
6261
|
-
|
|
6262
|
-
return this.products.getProductsWithPrice(schedule_date, {
|
|
6263
|
-
scheduleModule: this.getSchedule(),
|
|
6264
|
-
schedule_datetime: schedule_datetime,
|
|
6265
|
-
customer_id: customer_id
|
|
6266
|
-
}, {
|
|
6688
|
+
_context65.next = 13;
|
|
6689
|
+
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
6267
6690
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
6268
6691
|
productIds: uniqueIds
|
|
6269
6692
|
});
|
|
6270
|
-
case
|
|
6271
|
-
productsWithPrice =
|
|
6693
|
+
case 13:
|
|
6694
|
+
productsWithPrice = _context65.sent;
|
|
6272
6695
|
perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
|
|
6273
6696
|
count: productsWithPrice.length,
|
|
6274
6697
|
ids: uniqueIds
|
|
@@ -6288,30 +6711,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
6288
6711
|
ids: uniqueIds,
|
|
6289
6712
|
count: extensionFilteredProducts.length
|
|
6290
6713
|
});
|
|
6291
|
-
return
|
|
6714
|
+
return _context65.abrupt("return", {
|
|
6292
6715
|
code: 200,
|
|
6293
|
-
data:
|
|
6294
|
-
list: extensionFilteredProducts,
|
|
6295
|
-
count: extensionFilteredProducts.length
|
|
6296
|
-
},
|
|
6716
|
+
data: this.buildProductQueryResultPayload(extensionFilteredProducts),
|
|
6297
6717
|
message: '',
|
|
6298
6718
|
status: true
|
|
6299
6719
|
});
|
|
6300
|
-
case
|
|
6720
|
+
case 20:
|
|
6301
6721
|
if (!(product_id != null && Number.isFinite(Number(product_id)))) {
|
|
6302
|
-
|
|
6722
|
+
_context65.next = 32;
|
|
6303
6723
|
break;
|
|
6304
6724
|
}
|
|
6305
6725
|
pid = Number(product_id);
|
|
6306
6726
|
_tPrice2 = performance.now();
|
|
6307
|
-
|
|
6308
|
-
return this.products.getProductsWithPrice(schedule_date, {
|
|
6309
|
-
scheduleModule: this.getSchedule()
|
|
6310
|
-
}, {
|
|
6727
|
+
_context65.next = 25;
|
|
6728
|
+
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
6311
6729
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6312
6730
|
});
|
|
6313
|
-
case
|
|
6314
|
-
allProductsWithPrice =
|
|
6731
|
+
case 25:
|
|
6732
|
+
allProductsWithPrice = _context65.sent;
|
|
6315
6733
|
perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
|
|
6316
6734
|
count: allProductsWithPrice.length,
|
|
6317
6735
|
productId: pid
|
|
@@ -6331,28 +6749,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
6331
6749
|
productId: pid,
|
|
6332
6750
|
found: !!item
|
|
6333
6751
|
});
|
|
6334
|
-
return
|
|
6752
|
+
return _context65.abrupt("return", {
|
|
6335
6753
|
code: 200,
|
|
6336
6754
|
data: item,
|
|
6337
6755
|
message: item ? '' : '商品不存在或未发布',
|
|
6338
6756
|
status: true
|
|
6339
6757
|
});
|
|
6340
|
-
case
|
|
6758
|
+
case 32:
|
|
6341
6759
|
if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
|
|
6342
|
-
|
|
6760
|
+
_context65.next = 52;
|
|
6343
6761
|
break;
|
|
6344
6762
|
}
|
|
6345
6763
|
_tPrice3 = performance.now();
|
|
6346
|
-
|
|
6347
|
-
return this.products.getProductsWithPrice(schedule_date, {
|
|
6348
|
-
scheduleModule: this.getSchedule(),
|
|
6349
|
-
schedule_datetime: schedule_datetime,
|
|
6350
|
-
customer_id: customer_id
|
|
6351
|
-
}, {
|
|
6764
|
+
_context65.next = 36;
|
|
6765
|
+
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
6352
6766
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6353
6767
|
});
|
|
6354
|
-
case
|
|
6355
|
-
_filteredProducts2 =
|
|
6768
|
+
case 36:
|
|
6769
|
+
_filteredProducts2 = _context65.sent;
|
|
6356
6770
|
perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
|
|
6357
6771
|
count: _filteredProducts2.length,
|
|
6358
6772
|
extension_type: extension_type
|
|
@@ -6391,49 +6805,40 @@ var Server = /*#__PURE__*/function () {
|
|
|
6391
6805
|
filteredCount: _filteredProducts2.length,
|
|
6392
6806
|
extension_type: extension_type
|
|
6393
6807
|
});
|
|
6394
|
-
return
|
|
6808
|
+
return _context65.abrupt("return", {
|
|
6395
6809
|
code: 200,
|
|
6396
|
-
data:
|
|
6397
|
-
list: _filteredProducts2,
|
|
6398
|
-
count: _filteredProducts2.length
|
|
6399
|
-
},
|
|
6810
|
+
data: this.buildProductQueryResultPayload(_filteredProducts2),
|
|
6400
6811
|
message: '',
|
|
6401
6812
|
status: true
|
|
6402
6813
|
});
|
|
6403
|
-
case
|
|
6814
|
+
case 52:
|
|
6404
6815
|
if (this.menu) {
|
|
6405
|
-
|
|
6816
|
+
_context65.next = 55;
|
|
6406
6817
|
break;
|
|
6407
6818
|
}
|
|
6408
6819
|
this.logError('computeProductQueryResult: Menu 模块未注册');
|
|
6409
|
-
return
|
|
6820
|
+
return _context65.abrupt("return", {
|
|
6410
6821
|
message: 'Menu 模块未注册',
|
|
6411
|
-
data:
|
|
6412
|
-
list: [],
|
|
6413
|
-
count: 0
|
|
6414
|
-
}
|
|
6822
|
+
data: this.buildProductQueryResultPayload([], 0)
|
|
6415
6823
|
});
|
|
6416
|
-
case
|
|
6824
|
+
case 55:
|
|
6417
6825
|
if (this.schedule) {
|
|
6418
|
-
|
|
6826
|
+
_context65.next = 58;
|
|
6419
6827
|
break;
|
|
6420
6828
|
}
|
|
6421
6829
|
this.logError('computeProductQueryResult: Schedule 模块未注册');
|
|
6422
|
-
return
|
|
6830
|
+
return _context65.abrupt("return", {
|
|
6423
6831
|
message: 'Schedule 模块未注册',
|
|
6424
|
-
data:
|
|
6425
|
-
list: [],
|
|
6426
|
-
count: 0
|
|
6427
|
-
}
|
|
6832
|
+
data: this.buildProductQueryResultPayload([], 0)
|
|
6428
6833
|
});
|
|
6429
|
-
case
|
|
6834
|
+
case 58:
|
|
6430
6835
|
activeMenuList = [];
|
|
6431
6836
|
if (menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0) {
|
|
6432
6837
|
tMenu = performance.now();
|
|
6433
6838
|
menuList = this.menu.getMenuByIds(menu_list_ids);
|
|
6434
6839
|
activeMenuList = menuList.filter(function (menu) {
|
|
6435
|
-
var
|
|
6436
|
-
return ((
|
|
6840
|
+
var _this19$schedule;
|
|
6841
|
+
return ((_this19$schedule = _this19.schedule) === null || _this19$schedule === void 0 ? void 0 : _this19$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
|
|
6437
6842
|
});
|
|
6438
6843
|
perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
|
|
6439
6844
|
totalMenu: menuList.length,
|
|
@@ -6450,26 +6855,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
6450
6855
|
});
|
|
6451
6856
|
tPrice = performance.now();
|
|
6452
6857
|
if (!(scopedProductIds.length > 0)) {
|
|
6453
|
-
|
|
6858
|
+
_context65.next = 71;
|
|
6454
6859
|
break;
|
|
6455
6860
|
}
|
|
6456
|
-
|
|
6457
|
-
return this.products.getProductsWithPrice(schedule_date, {
|
|
6458
|
-
scheduleModule: this.getSchedule(),
|
|
6459
|
-
schedule_datetime: schedule_datetime,
|
|
6460
|
-
customer_id: customer_id
|
|
6461
|
-
}, {
|
|
6861
|
+
_context65.next = 68;
|
|
6862
|
+
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
6462
6863
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
6463
6864
|
productIds: productScope.isAllProducts ? undefined : scopedProductIds
|
|
6464
6865
|
});
|
|
6465
|
-
case
|
|
6466
|
-
|
|
6467
|
-
|
|
6866
|
+
case 68:
|
|
6867
|
+
_context65.t0 = _context65.sent;
|
|
6868
|
+
_context65.next = 72;
|
|
6468
6869
|
break;
|
|
6469
|
-
case 70:
|
|
6470
|
-
_context61.t0 = [];
|
|
6471
6870
|
case 71:
|
|
6472
|
-
|
|
6871
|
+
_context65.t0 = [];
|
|
6872
|
+
case 72:
|
|
6873
|
+
filteredProducts = _context65.t0;
|
|
6473
6874
|
perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
|
|
6474
6875
|
count: filteredProducts.length,
|
|
6475
6876
|
scopedProductCount: scopedProductIds.length
|
|
@@ -6510,102 +6911,120 @@ var Server = /*#__PURE__*/function () {
|
|
|
6510
6911
|
filteredCount: filteredProducts.length,
|
|
6511
6912
|
activeMenuCount: activeMenuList.length
|
|
6512
6913
|
});
|
|
6513
|
-
return
|
|
6914
|
+
return _context65.abrupt("return", {
|
|
6514
6915
|
code: 200,
|
|
6515
|
-
data:
|
|
6516
|
-
list: filteredProducts,
|
|
6517
|
-
count: filteredProducts.length
|
|
6518
|
-
},
|
|
6916
|
+
data: this.buildProductQueryResultPayload(filteredProducts),
|
|
6519
6917
|
message: '',
|
|
6520
6918
|
status: true
|
|
6521
6919
|
});
|
|
6522
|
-
case
|
|
6920
|
+
case 88:
|
|
6523
6921
|
case "end":
|
|
6524
|
-
return
|
|
6922
|
+
return _context65.stop();
|
|
6525
6923
|
}
|
|
6526
|
-
},
|
|
6924
|
+
}, _callee65, this);
|
|
6527
6925
|
}));
|
|
6528
|
-
function computeProductQueryResult(
|
|
6926
|
+
function computeProductQueryResult(_x72, _x73) {
|
|
6529
6927
|
return _computeProductQueryResult.apply(this, arguments);
|
|
6530
6928
|
}
|
|
6531
6929
|
return computeProductQueryResult;
|
|
6532
6930
|
}()
|
|
6931
|
+
/**
|
|
6932
|
+
* 构建商品格式化上下文。
|
|
6933
|
+
*
|
|
6934
|
+
* 智能定价条件使用全量 menuList/scheduleList;Product Query 顶层参数只保留筛选商品集合所需字段。
|
|
6935
|
+
*/
|
|
6936
|
+
)
|
|
6937
|
+
}, {
|
|
6938
|
+
key: "buildProductFormatterContext",
|
|
6939
|
+
value: function buildProductFormatterContext(context) {
|
|
6940
|
+
var _this$menu, _this$menu$getMenuLis, _scheduleModule$getSc, _this$core$context4;
|
|
6941
|
+
var scheduleModule = this.getSchedule();
|
|
6942
|
+
return {
|
|
6943
|
+
scheduleModule: scheduleModule,
|
|
6944
|
+
schedule_datetime: context.schedule_datetime,
|
|
6945
|
+
customer_id: context.customer_id,
|
|
6946
|
+
strategy_context: context.strategy_context,
|
|
6947
|
+
menuList: ((_this$menu = this.menu) === null || _this$menu === void 0 || (_this$menu$getMenuLis = _this$menu.getMenuList) === null || _this$menu$getMenuLis === void 0 ? void 0 : _this$menu$getMenuLis.call(_this$menu)) || [],
|
|
6948
|
+
scheduleList: (scheduleModule === null || scheduleModule === void 0 || (_scheduleModule$getSc = scheduleModule.getScheduleList) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule)) || [],
|
|
6949
|
+
dataVariantEvaluator: (_this$core$context4 = this.core.context) === null || _this$core$context4 === void 0 ? void 0 : _this$core$context4.dataVariantEvaluator
|
|
6950
|
+
};
|
|
6951
|
+
}
|
|
6952
|
+
|
|
6533
6953
|
/**
|
|
6534
6954
|
* 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
|
|
6535
6955
|
* 由 ProductsModule 的 onProductsSyncCompleted 事件触发
|
|
6536
6956
|
* @param options 可选参数
|
|
6537
6957
|
* @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
|
|
6538
6958
|
*/
|
|
6539
|
-
)
|
|
6540
6959
|
}, {
|
|
6541
6960
|
key: "recomputeAndNotifyProductQuery",
|
|
6542
6961
|
value: (function () {
|
|
6543
|
-
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6544
|
-
var
|
|
6545
|
-
return _regeneratorRuntime().wrap(function
|
|
6546
|
-
while (1) switch (
|
|
6962
|
+
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(options) {
|
|
6963
|
+
var _iterator19, _step19, _step19$value, subscriberId, subscriber, result, errorMessage;
|
|
6964
|
+
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
6965
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
6547
6966
|
case 0:
|
|
6548
6967
|
if (!(this.productQuerySubscribers.size === 0)) {
|
|
6549
|
-
|
|
6968
|
+
_context66.next = 2;
|
|
6550
6969
|
break;
|
|
6551
6970
|
}
|
|
6552
|
-
return
|
|
6971
|
+
return _context66.abrupt("return");
|
|
6553
6972
|
case 2:
|
|
6554
6973
|
this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
|
|
6555
6974
|
subscriberCount: this.productQuerySubscribers.size,
|
|
6556
6975
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6557
6976
|
});
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6977
|
+
_iterator19 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
|
|
6978
|
+
_context66.prev = 4;
|
|
6979
|
+
_iterator19.s();
|
|
6561
6980
|
case 6:
|
|
6562
|
-
if ((
|
|
6563
|
-
|
|
6981
|
+
if ((_step19 = _iterator19.n()).done) {
|
|
6982
|
+
_context66.next = 22;
|
|
6564
6983
|
break;
|
|
6565
6984
|
}
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6985
|
+
_step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
|
|
6986
|
+
_context66.prev = 8;
|
|
6987
|
+
_context66.next = 11;
|
|
6569
6988
|
return this.computeProductQueryResult(subscriber.context, {
|
|
6570
6989
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6571
6990
|
});
|
|
6572
6991
|
case 11:
|
|
6573
|
-
result =
|
|
6992
|
+
result = _context66.sent;
|
|
6574
6993
|
subscriber.callback(result);
|
|
6575
6994
|
this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
|
|
6576
6995
|
subscriberId: subscriberId
|
|
6577
6996
|
});
|
|
6578
|
-
|
|
6997
|
+
_context66.next = 20;
|
|
6579
6998
|
break;
|
|
6580
6999
|
case 16:
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
errorMessage =
|
|
7000
|
+
_context66.prev = 16;
|
|
7001
|
+
_context66.t0 = _context66["catch"](8);
|
|
7002
|
+
errorMessage = _context66.t0 instanceof Error ? _context66.t0.message : String(_context66.t0);
|
|
6584
7003
|
this.logError('recomputeAndNotifyProductQuery: 推送失败', {
|
|
6585
7004
|
subscriberId: subscriberId,
|
|
6586
7005
|
error: errorMessage
|
|
6587
7006
|
});
|
|
6588
7007
|
case 20:
|
|
6589
|
-
|
|
7008
|
+
_context66.next = 6;
|
|
6590
7009
|
break;
|
|
6591
7010
|
case 22:
|
|
6592
|
-
|
|
7011
|
+
_context66.next = 27;
|
|
6593
7012
|
break;
|
|
6594
7013
|
case 24:
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
7014
|
+
_context66.prev = 24;
|
|
7015
|
+
_context66.t1 = _context66["catch"](4);
|
|
7016
|
+
_iterator19.e(_context66.t1);
|
|
6598
7017
|
case 27:
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
return
|
|
7018
|
+
_context66.prev = 27;
|
|
7019
|
+
_iterator19.f();
|
|
7020
|
+
return _context66.finish(27);
|
|
6602
7021
|
case 30:
|
|
6603
7022
|
case "end":
|
|
6604
|
-
return
|
|
7023
|
+
return _context66.stop();
|
|
6605
7024
|
}
|
|
6606
|
-
},
|
|
7025
|
+
}, _callee66, this, [[4, 24, 27, 30], [8, 16]]);
|
|
6607
7026
|
}));
|
|
6608
|
-
function recomputeAndNotifyProductQuery(
|
|
7027
|
+
function recomputeAndNotifyProductQuery(_x74) {
|
|
6609
7028
|
return _recomputeAndNotifyProductQuery.apply(this, arguments);
|
|
6610
7029
|
}
|
|
6611
7030
|
return recomputeAndNotifyProductQuery;
|
|
@@ -6617,37 +7036,37 @@ var Server = /*#__PURE__*/function () {
|
|
|
6617
7036
|
}, {
|
|
6618
7037
|
key: "recomputeAndNotifyOrderQuery",
|
|
6619
7038
|
value: (function () {
|
|
6620
|
-
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6621
|
-
var notifyStartAt,
|
|
6622
|
-
return _regeneratorRuntime().wrap(function
|
|
6623
|
-
while (1) switch (
|
|
7039
|
+
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67() {
|
|
7040
|
+
var notifyStartAt, _iterator20, _step20, _step20$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
|
|
7041
|
+
return _regeneratorRuntime().wrap(function _callee67$(_context67) {
|
|
7042
|
+
while (1) switch (_context67.prev = _context67.next) {
|
|
6624
7043
|
case 0:
|
|
6625
7044
|
if (!(this.orderQuerySubscribers.size === 0)) {
|
|
6626
|
-
|
|
7045
|
+
_context67.next = 2;
|
|
6627
7046
|
break;
|
|
6628
7047
|
}
|
|
6629
|
-
return
|
|
7048
|
+
return _context67.abrupt("return");
|
|
6630
7049
|
case 2:
|
|
6631
7050
|
notifyStartAt = Date.now();
|
|
6632
7051
|
this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
|
|
6633
7052
|
subscriberCount: this.orderQuerySubscribers.size,
|
|
6634
7053
|
notifyStartAt: new Date(notifyStartAt).toISOString()
|
|
6635
7054
|
});
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
7055
|
+
_iterator20 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
|
|
7056
|
+
_context67.prev = 5;
|
|
7057
|
+
_iterator20.s();
|
|
6639
7058
|
case 7:
|
|
6640
|
-
if ((
|
|
6641
|
-
|
|
7059
|
+
if ((_step20 = _iterator20.n()).done) {
|
|
7060
|
+
_context67.next = 27;
|
|
6642
7061
|
break;
|
|
6643
7062
|
}
|
|
6644
|
-
|
|
6645
|
-
|
|
7063
|
+
_step20$value = _slicedToArray(_step20.value, 2), subscriberId = _step20$value[0], subscriber = _step20$value[1];
|
|
7064
|
+
_context67.prev = 9;
|
|
6646
7065
|
computeStartAt = Date.now();
|
|
6647
|
-
|
|
7066
|
+
_context67.next = 13;
|
|
6648
7067
|
return this.computeOrderQueryResult(subscriber.context);
|
|
6649
7068
|
case 13:
|
|
6650
|
-
result =
|
|
7069
|
+
result = _context67.sent;
|
|
6651
7070
|
computeEndAt = Date.now();
|
|
6652
7071
|
callbackStartAt = Date.now();
|
|
6653
7072
|
subscriber.callback(result);
|
|
@@ -6658,30 +7077,30 @@ var Server = /*#__PURE__*/function () {
|
|
|
6658
7077
|
callbackDurationMs: callbackEndAt - callbackStartAt,
|
|
6659
7078
|
totalDurationMs: callbackEndAt - computeStartAt
|
|
6660
7079
|
});
|
|
6661
|
-
|
|
7080
|
+
_context67.next = 25;
|
|
6662
7081
|
break;
|
|
6663
7082
|
case 21:
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
errorMessage =
|
|
7083
|
+
_context67.prev = 21;
|
|
7084
|
+
_context67.t0 = _context67["catch"](9);
|
|
7085
|
+
errorMessage = _context67.t0 instanceof Error ? _context67.t0.message : String(_context67.t0);
|
|
6667
7086
|
this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
|
|
6668
7087
|
subscriberId: subscriberId,
|
|
6669
7088
|
error: errorMessage
|
|
6670
7089
|
});
|
|
6671
7090
|
case 25:
|
|
6672
|
-
|
|
7091
|
+
_context67.next = 7;
|
|
6673
7092
|
break;
|
|
6674
7093
|
case 27:
|
|
6675
|
-
|
|
7094
|
+
_context67.next = 32;
|
|
6676
7095
|
break;
|
|
6677
7096
|
case 29:
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
7097
|
+
_context67.prev = 29;
|
|
7098
|
+
_context67.t1 = _context67["catch"](5);
|
|
7099
|
+
_iterator20.e(_context67.t1);
|
|
6681
7100
|
case 32:
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
return
|
|
7101
|
+
_context67.prev = 32;
|
|
7102
|
+
_iterator20.f();
|
|
7103
|
+
return _context67.finish(32);
|
|
6685
7104
|
case 35:
|
|
6686
7105
|
notifyEndAt = Date.now();
|
|
6687
7106
|
this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
|
|
@@ -6690,9 +7109,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6690
7109
|
});
|
|
6691
7110
|
case 37:
|
|
6692
7111
|
case "end":
|
|
6693
|
-
return
|
|
7112
|
+
return _context67.stop();
|
|
6694
7113
|
}
|
|
6695
|
-
},
|
|
7114
|
+
}, _callee67, this, [[5, 29, 32, 35], [9, 21]]);
|
|
6696
7115
|
}));
|
|
6697
7116
|
function recomputeAndNotifyOrderQuery() {
|
|
6698
7117
|
return _recomputeAndNotifyOrderQuery.apply(this, arguments);
|
|
@@ -6710,7 +7129,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6710
7129
|
}, {
|
|
6711
7130
|
key: "notifySalesSearchSubscribers",
|
|
6712
7131
|
value: function notifySalesSearchSubscribers(payload) {
|
|
6713
|
-
var
|
|
7132
|
+
var _this20 = this;
|
|
6714
7133
|
if (this.salesSearchSubscribers.size === 0) return;
|
|
6715
7134
|
var changedOrders = this.extractChangedOrdersFromPayload(payload);
|
|
6716
7135
|
if (changedOrders.length === 0) {
|
|
@@ -6719,42 +7138,42 @@ var Server = /*#__PURE__*/function () {
|
|
|
6719
7138
|
// 如果当前开启了 checkout 弹窗,先不进行刷新,下面的代码会导致在全局搜索页调用 bookingTicket.destroy()
|
|
6720
7139
|
// 导致模块被销毁 ,checkout 弹窗永远无法关闭
|
|
6721
7140
|
if (window.isPaymentModalPluginOpen) return;
|
|
6722
|
-
var
|
|
6723
|
-
|
|
7141
|
+
var _iterator21 = _createForOfIteratorHelper(this.salesSearchSubscribers.entries()),
|
|
7142
|
+
_step21;
|
|
6724
7143
|
try {
|
|
6725
|
-
var
|
|
6726
|
-
var
|
|
6727
|
-
subscriberId =
|
|
6728
|
-
subscriber =
|
|
7144
|
+
var _loop2 = function _loop2() {
|
|
7145
|
+
var _step21$value = _slicedToArray(_step21.value, 2),
|
|
7146
|
+
subscriberId = _step21$value[0],
|
|
7147
|
+
subscriber = _step21$value[1];
|
|
6729
7148
|
try {
|
|
6730
7149
|
var changedVisibleOrders = changedOrders.filter(function (order) {
|
|
6731
|
-
var orderId =
|
|
7150
|
+
var orderId = _this20.getSalesSearchOrderId(order);
|
|
6732
7151
|
return !!orderId && subscriber.visibleOrderIds.has(orderId);
|
|
6733
7152
|
});
|
|
6734
7153
|
if (changedVisibleOrders.length === 0) {
|
|
6735
7154
|
return 1; // continue
|
|
6736
7155
|
}
|
|
6737
|
-
subscriber.callback(
|
|
6738
|
-
|
|
7156
|
+
subscriber.callback(_this20.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
|
|
7157
|
+
_this20.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
|
|
6739
7158
|
subscriberId: subscriberId,
|
|
6740
7159
|
kind: subscriber.kind,
|
|
6741
7160
|
count: changedVisibleOrders.length
|
|
6742
7161
|
});
|
|
6743
7162
|
} catch (error) {
|
|
6744
7163
|
var errorMessage = error instanceof Error ? error.message : String(error);
|
|
6745
|
-
|
|
7164
|
+
_this20.logError('notifySalesSearchSubscribers: 推送失败', {
|
|
6746
7165
|
subscriberId: subscriberId,
|
|
6747
7166
|
error: errorMessage
|
|
6748
7167
|
});
|
|
6749
7168
|
}
|
|
6750
7169
|
};
|
|
6751
|
-
for (
|
|
6752
|
-
if (
|
|
7170
|
+
for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
|
|
7171
|
+
if (_loop2()) continue;
|
|
6753
7172
|
}
|
|
6754
7173
|
} catch (err) {
|
|
6755
|
-
|
|
7174
|
+
_iterator21.e(err);
|
|
6756
7175
|
} finally {
|
|
6757
|
-
|
|
7176
|
+
_iterator21.f();
|
|
6758
7177
|
}
|
|
6759
7178
|
}
|
|
6760
7179
|
|
|
@@ -6833,67 +7252,67 @@ var Server = /*#__PURE__*/function () {
|
|
|
6833
7252
|
}, {
|
|
6834
7253
|
key: "recomputeAndNotifyBookingQuery",
|
|
6835
7254
|
value: (function () {
|
|
6836
|
-
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6837
|
-
var
|
|
6838
|
-
return _regeneratorRuntime().wrap(function
|
|
6839
|
-
while (1) switch (
|
|
7255
|
+
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68() {
|
|
7256
|
+
var _iterator22, _step22, _step22$value, subscriberId, subscriber, result, errorMessage;
|
|
7257
|
+
return _regeneratorRuntime().wrap(function _callee68$(_context68) {
|
|
7258
|
+
while (1) switch (_context68.prev = _context68.next) {
|
|
6840
7259
|
case 0:
|
|
6841
7260
|
if (!(this.bookingQuerySubscribers.size === 0)) {
|
|
6842
|
-
|
|
7261
|
+
_context68.next = 2;
|
|
6843
7262
|
break;
|
|
6844
7263
|
}
|
|
6845
|
-
return
|
|
7264
|
+
return _context68.abrupt("return");
|
|
6846
7265
|
case 2:
|
|
6847
7266
|
this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
|
|
6848
7267
|
subscriberCount: this.bookingQuerySubscribers.size
|
|
6849
7268
|
});
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
7269
|
+
_iterator22 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
|
|
7270
|
+
_context68.prev = 4;
|
|
7271
|
+
_iterator22.s();
|
|
6853
7272
|
case 6:
|
|
6854
|
-
if ((
|
|
6855
|
-
|
|
7273
|
+
if ((_step22 = _iterator22.n()).done) {
|
|
7274
|
+
_context68.next = 22;
|
|
6856
7275
|
break;
|
|
6857
7276
|
}
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
7277
|
+
_step22$value = _slicedToArray(_step22.value, 2), subscriberId = _step22$value[0], subscriber = _step22$value[1];
|
|
7278
|
+
_context68.prev = 8;
|
|
7279
|
+
_context68.next = 11;
|
|
6861
7280
|
return this.computeBookingQueryResult(subscriber.context);
|
|
6862
7281
|
case 11:
|
|
6863
|
-
result =
|
|
7282
|
+
result = _context68.sent;
|
|
6864
7283
|
subscriber.callback(result);
|
|
6865
7284
|
this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
|
|
6866
7285
|
subscriberId: subscriberId
|
|
6867
7286
|
});
|
|
6868
|
-
|
|
7287
|
+
_context68.next = 20;
|
|
6869
7288
|
break;
|
|
6870
7289
|
case 16:
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
errorMessage =
|
|
7290
|
+
_context68.prev = 16;
|
|
7291
|
+
_context68.t0 = _context68["catch"](8);
|
|
7292
|
+
errorMessage = _context68.t0 instanceof Error ? _context68.t0.message : String(_context68.t0);
|
|
6874
7293
|
this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
|
|
6875
7294
|
subscriberId: subscriberId,
|
|
6876
7295
|
error: errorMessage
|
|
6877
7296
|
});
|
|
6878
7297
|
case 20:
|
|
6879
|
-
|
|
7298
|
+
_context68.next = 6;
|
|
6880
7299
|
break;
|
|
6881
7300
|
case 22:
|
|
6882
|
-
|
|
7301
|
+
_context68.next = 27;
|
|
6883
7302
|
break;
|
|
6884
7303
|
case 24:
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
7304
|
+
_context68.prev = 24;
|
|
7305
|
+
_context68.t1 = _context68["catch"](4);
|
|
7306
|
+
_iterator22.e(_context68.t1);
|
|
6888
7307
|
case 27:
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
return
|
|
7308
|
+
_context68.prev = 27;
|
|
7309
|
+
_iterator22.f();
|
|
7310
|
+
return _context68.finish(27);
|
|
6892
7311
|
case 30:
|
|
6893
7312
|
case "end":
|
|
6894
|
-
return
|
|
7313
|
+
return _context68.stop();
|
|
6895
7314
|
}
|
|
6896
|
-
},
|
|
7315
|
+
}, _callee68, this, [[4, 24, 27, 30], [8, 16]]);
|
|
6897
7316
|
}));
|
|
6898
7317
|
function recomputeAndNotifyBookingQuery() {
|
|
6899
7318
|
return _recomputeAndNotifyBookingQuery.apply(this, arguments);
|
|
@@ -6923,11 +7342,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6923
7342
|
var allowedProductIds = new Set();
|
|
6924
7343
|
var allowedCollectionIds = new Set();
|
|
6925
7344
|
var hasProductAll = false;
|
|
6926
|
-
var
|
|
6927
|
-
|
|
7345
|
+
var _iterator23 = _createForOfIteratorHelper(activeMenuList),
|
|
7346
|
+
_step23;
|
|
6928
7347
|
try {
|
|
6929
|
-
for (
|
|
6930
|
-
var menu =
|
|
7348
|
+
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
7349
|
+
var menu = _step23.value;
|
|
6931
7350
|
var config = menu.partyroom_package;
|
|
6932
7351
|
if (!config) {
|
|
6933
7352
|
console.warn('[Server] 餐牌缺少 partyroom_package 配置:', menu);
|
|
@@ -6987,9 +7406,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6987
7406
|
|
|
6988
7407
|
// 如果有餐牌允许所有商品,返回所有商品
|
|
6989
7408
|
} catch (err) {
|
|
6990
|
-
|
|
7409
|
+
_iterator23.e(err);
|
|
6991
7410
|
} finally {
|
|
6992
|
-
|
|
7411
|
+
_iterator23.f();
|
|
6993
7412
|
}
|
|
6994
7413
|
if (hasProductAll) {
|
|
6995
7414
|
this.logInfo('getProductScopeByMenuConfig: 返回所有商品 scope(product_all)');
|