@pisell/pisellos 2.2.261 → 2.2.263
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 +1 -1
- 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 +1173 -753
- 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 +332 -34
- 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
|
|
4654
|
-
var backendPath, data, title, normalizedData, checkoutData, pendingResult, pendingOrder;
|
|
4655
|
-
return _regeneratorRuntime().wrap(function
|
|
4656
|
-
while (1) switch (
|
|
4911
|
+
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
|
|
4912
|
+
var backendPath, data, title, normalizedData, checkoutData, pendingResult, _this$core$context2, pendingOrder, platform, isAndroid;
|
|
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,52 +4946,53 @@ 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 = 22;
|
|
4694
4952
|
break;
|
|
4695
4953
|
}
|
|
4696
4954
|
pendingOrder = pendingResult.data;
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4955
|
+
platform = (_this$core$context2 = this.core.context) === null || _this$core$context2 === void 0 ? void 0 : _this$core$context2.getPlatform();
|
|
4956
|
+
isAndroid = platform === 'android';
|
|
4957
|
+
if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && (
|
|
4958
|
+
// TODO 这里先加个兼容,如果是安卓,则需要 type=virtual 才走打印,如果是苹果则无限制
|
|
4959
|
+
isAndroid ? checkoutData.type === 'virtual' : true))) {
|
|
4960
|
+
_context51.next = 20;
|
|
4702
4961
|
break;
|
|
4703
4962
|
}
|
|
4704
|
-
|
|
4963
|
+
_context51.next = 20;
|
|
4705
4964
|
return this.dispatchLocalReceiptPrint({
|
|
4706
4965
|
checkoutData: checkoutData,
|
|
4707
4966
|
order: pendingOrder,
|
|
4708
4967
|
response: pendingResult,
|
|
4709
4968
|
requireFullyPaid: true
|
|
4710
4969
|
});
|
|
4711
|
-
case
|
|
4712
|
-
|
|
4970
|
+
case 20:
|
|
4971
|
+
_context51.next = 22;
|
|
4713
4972
|
return this.dispatchCheckoutSyncTask({
|
|
4714
4973
|
backendPath: backendPath,
|
|
4715
4974
|
data: checkoutData,
|
|
4716
4975
|
title: title
|
|
4717
4976
|
});
|
|
4718
|
-
case
|
|
4977
|
+
case 22:
|
|
4719
4978
|
if (pendingResult.data.order_id) {
|
|
4720
|
-
|
|
4979
|
+
_context51.next = 24;
|
|
4721
4980
|
break;
|
|
4722
4981
|
}
|
|
4723
|
-
return
|
|
4982
|
+
return _context51.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
|
|
4724
4983
|
data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
|
|
4725
4984
|
order_id: pendingResult.data.external_sale_number
|
|
4726
4985
|
})
|
|
4727
4986
|
}));
|
|
4728
|
-
case
|
|
4729
|
-
return
|
|
4730
|
-
case
|
|
4987
|
+
case 24:
|
|
4988
|
+
return _context51.abrupt("return", pendingResult);
|
|
4989
|
+
case 25:
|
|
4731
4990
|
case "end":
|
|
4732
|
-
return
|
|
4991
|
+
return _context51.stop();
|
|
4733
4992
|
}
|
|
4734
|
-
},
|
|
4993
|
+
}, _callee51, this);
|
|
4735
4994
|
}));
|
|
4736
|
-
function handleOrderCheckoutSubmit(
|
|
4995
|
+
function handleOrderCheckoutSubmit(_x58) {
|
|
4737
4996
|
return _handleOrderCheckoutSubmit.apply(this, arguments);
|
|
4738
4997
|
}
|
|
4739
4998
|
return handleOrderCheckoutSubmit;
|
|
@@ -4741,27 +5000,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
4741
5000
|
}, {
|
|
4742
5001
|
key: "handleSyncCheckoutSubmit",
|
|
4743
5002
|
value: function () {
|
|
4744
|
-
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5003
|
+
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
|
|
4745
5004
|
var _this$app16;
|
|
4746
5005
|
var backendPath, data, title, syncResult, _normalized$data, normalized, backendError, _normalized$data2, _normalized, message;
|
|
4747
|
-
return _regeneratorRuntime().wrap(function
|
|
4748
|
-
while (1) switch (
|
|
5006
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
5007
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
4749
5008
|
case 0:
|
|
4750
5009
|
backendPath = params.backendPath, data = params.data, title = params.title;
|
|
4751
5010
|
if ((_this$app16 = this.app) !== null && _this$app16 !== void 0 && (_this$app16 = _this$app16.request) !== null && _this$app16 !== void 0 && _this$app16.post) {
|
|
4752
|
-
|
|
5011
|
+
_context52.next = 4;
|
|
4753
5012
|
break;
|
|
4754
5013
|
}
|
|
4755
5014
|
this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
|
|
4756
|
-
return
|
|
5015
|
+
return _context52.abrupt("return", {
|
|
4757
5016
|
code: 500,
|
|
4758
5017
|
status: false,
|
|
4759
5018
|
message: 'app.request 不可用',
|
|
4760
5019
|
data: null
|
|
4761
5020
|
});
|
|
4762
5021
|
case 4:
|
|
4763
|
-
|
|
4764
|
-
|
|
5022
|
+
_context52.prev = 4;
|
|
5023
|
+
_context52.next = 7;
|
|
4765
5024
|
return this.runCheckoutSync({
|
|
4766
5025
|
backendPath: backendPath,
|
|
4767
5026
|
data: data,
|
|
@@ -4769,41 +5028,41 @@ var Server = /*#__PURE__*/function () {
|
|
|
4769
5028
|
persistCheckoutDataWithResponse: true
|
|
4770
5029
|
});
|
|
4771
5030
|
case 7:
|
|
4772
|
-
syncResult =
|
|
5031
|
+
syncResult = _context52.sent;
|
|
4773
5032
|
if (!syncResult.rejected) {
|
|
4774
|
-
|
|
5033
|
+
_context52.next = 11;
|
|
4775
5034
|
break;
|
|
4776
5035
|
}
|
|
4777
5036
|
normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
|
|
4778
|
-
return
|
|
5037
|
+
return _context52.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
|
|
4779
5038
|
status: false,
|
|
4780
5039
|
message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
|
|
4781
5040
|
data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
|
|
4782
5041
|
}));
|
|
4783
5042
|
case 11:
|
|
4784
|
-
return
|
|
5043
|
+
return _context52.abrupt("return", this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder));
|
|
4785
5044
|
case 14:
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
backendError = this.extractBackendErrorResponse(
|
|
5045
|
+
_context52.prev = 14;
|
|
5046
|
+
_context52.t0 = _context52["catch"](4);
|
|
5047
|
+
backendError = this.extractBackendErrorResponse(_context52.t0);
|
|
4789
5048
|
if (!backendError) {
|
|
4790
|
-
|
|
5049
|
+
_context52.next = 20;
|
|
4791
5050
|
break;
|
|
4792
5051
|
}
|
|
4793
5052
|
_normalized = this.normalizeCheckoutResponse(backendError);
|
|
4794
|
-
return
|
|
5053
|
+
return _context52.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
|
|
4795
5054
|
status: false,
|
|
4796
5055
|
message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
|
|
4797
5056
|
data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
|
|
4798
5057
|
}));
|
|
4799
5058
|
case 20:
|
|
4800
|
-
message = this.getUnknownErrorMessage(
|
|
5059
|
+
message = this.getUnknownErrorMessage(_context52.t0);
|
|
4801
5060
|
this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
|
|
4802
5061
|
backendPath: backendPath,
|
|
4803
5062
|
error: message,
|
|
4804
|
-
error_detail: this.normalizeUnknownError(
|
|
5063
|
+
error_detail: this.normalizeUnknownError(_context52.t0)
|
|
4805
5064
|
});
|
|
4806
|
-
return
|
|
5065
|
+
return _context52.abrupt("return", {
|
|
4807
5066
|
code: 500,
|
|
4808
5067
|
status: false,
|
|
4809
5068
|
message: message,
|
|
@@ -4811,11 +5070,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4811
5070
|
});
|
|
4812
5071
|
case 23:
|
|
4813
5072
|
case "end":
|
|
4814
|
-
return
|
|
5073
|
+
return _context52.stop();
|
|
4815
5074
|
}
|
|
4816
|
-
},
|
|
5075
|
+
}, _callee52, this, [[4, 14]]);
|
|
4817
5076
|
}));
|
|
4818
|
-
function handleSyncCheckoutSubmit(
|
|
5077
|
+
function handleSyncCheckoutSubmit(_x59) {
|
|
4819
5078
|
return _handleSyncCheckoutSubmit.apply(this, arguments);
|
|
4820
5079
|
}
|
|
4821
5080
|
return handleSyncCheckoutSubmit;
|
|
@@ -4823,26 +5082,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
4823
5082
|
}, {
|
|
4824
5083
|
key: "handlePendingSyncCheckoutOrder",
|
|
4825
5084
|
value: function () {
|
|
4826
|
-
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4827
|
-
var
|
|
5085
|
+
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
|
|
5086
|
+
var _this11 = this;
|
|
4828
5087
|
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 (
|
|
5088
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
5089
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
4831
5090
|
case 0:
|
|
4832
5091
|
backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason;
|
|
4833
|
-
|
|
5092
|
+
_context53.next = 3;
|
|
4834
5093
|
return this.buildPendingSyncCheckoutOrder(data);
|
|
4835
5094
|
case 3:
|
|
4836
|
-
pendingOrder =
|
|
5095
|
+
pendingOrder = _context53.sent;
|
|
4837
5096
|
if (pendingOrder) {
|
|
4838
|
-
|
|
5097
|
+
_context53.next = 7;
|
|
4839
5098
|
break;
|
|
4840
5099
|
}
|
|
4841
5100
|
this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
|
|
4842
5101
|
backendPath: backendPath,
|
|
4843
5102
|
reason: reason
|
|
4844
5103
|
});
|
|
4845
|
-
return
|
|
5104
|
+
return _context53.abrupt("return", {
|
|
4846
5105
|
code: 500,
|
|
4847
5106
|
status: false,
|
|
4848
5107
|
message: '订单缺少本地存储标识,无法写入待同步队列',
|
|
@@ -4850,22 +5109,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
4850
5109
|
});
|
|
4851
5110
|
case 7:
|
|
4852
5111
|
if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
|
|
4853
|
-
|
|
5112
|
+
_context53.next = 10;
|
|
4854
5113
|
break;
|
|
4855
5114
|
}
|
|
4856
5115
|
this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
|
|
4857
5116
|
backendPath: backendPath,
|
|
4858
5117
|
reason: reason
|
|
4859
5118
|
});
|
|
4860
|
-
return
|
|
5119
|
+
return _context53.abrupt("return", {
|
|
4861
5120
|
code: 500,
|
|
4862
5121
|
status: false,
|
|
4863
5122
|
message: 'Order 模块不支持本地待同步写入',
|
|
4864
5123
|
data: null
|
|
4865
5124
|
});
|
|
4866
5125
|
case 10:
|
|
4867
|
-
|
|
4868
|
-
|
|
5126
|
+
_context53.prev = 10;
|
|
5127
|
+
_context53.next = 13;
|
|
4869
5128
|
return this.order.upsertPendingSyncOrders([pendingOrder]);
|
|
4870
5129
|
case 13:
|
|
4871
5130
|
this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
|
|
@@ -4877,9 +5136,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
4877
5136
|
});
|
|
4878
5137
|
changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
|
|
4879
5138
|
var _payment$metadata;
|
|
4880
|
-
return sum +
|
|
5139
|
+
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
5140
|
}, 0);
|
|
4882
|
-
return
|
|
5141
|
+
return _context53.abrupt("return", {
|
|
4883
5142
|
code: 200,
|
|
4884
5143
|
status: true,
|
|
4885
5144
|
message: '',
|
|
@@ -4894,15 +5153,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
4894
5153
|
})
|
|
4895
5154
|
});
|
|
4896
5155
|
case 18:
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
errorMessage =
|
|
5156
|
+
_context53.prev = 18;
|
|
5157
|
+
_context53.t0 = _context53["catch"](10);
|
|
5158
|
+
errorMessage = _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0);
|
|
4900
5159
|
this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
|
|
4901
5160
|
backendPath: backendPath,
|
|
4902
5161
|
reason: reason,
|
|
4903
5162
|
error: errorMessage
|
|
4904
5163
|
});
|
|
4905
|
-
return
|
|
5164
|
+
return _context53.abrupt("return", {
|
|
4906
5165
|
code: 500,
|
|
4907
5166
|
status: false,
|
|
4908
5167
|
message: errorMessage,
|
|
@@ -4910,11 +5169,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4910
5169
|
});
|
|
4911
5170
|
case 23:
|
|
4912
5171
|
case "end":
|
|
4913
|
-
return
|
|
5172
|
+
return _context53.stop();
|
|
4914
5173
|
}
|
|
4915
|
-
},
|
|
5174
|
+
}, _callee53, this, [[10, 18]]);
|
|
4916
5175
|
}));
|
|
4917
|
-
function handlePendingSyncCheckoutOrder(
|
|
5176
|
+
function handlePendingSyncCheckoutOrder(_x60) {
|
|
4918
5177
|
return _handlePendingSyncCheckoutOrder.apply(this, arguments);
|
|
4919
5178
|
}
|
|
4920
5179
|
return handlePendingSyncCheckoutOrder;
|
|
@@ -4922,43 +5181,43 @@ var Server = /*#__PURE__*/function () {
|
|
|
4922
5181
|
}, {
|
|
4923
5182
|
key: "buildPendingSyncCheckoutOrder",
|
|
4924
5183
|
value: function () {
|
|
4925
|
-
var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5184
|
+
var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(data) {
|
|
4926
5185
|
var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
|
|
4927
|
-
return _regeneratorRuntime().wrap(function
|
|
4928
|
-
while (1) switch (
|
|
5186
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5187
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
4929
5188
|
case 0:
|
|
4930
5189
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
4931
|
-
|
|
5190
|
+
_context54.next = 2;
|
|
4932
5191
|
break;
|
|
4933
5192
|
}
|
|
4934
|
-
return
|
|
5193
|
+
return _context54.abrupt("return", null);
|
|
4935
5194
|
case 2:
|
|
4936
5195
|
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
5196
|
if (hasStorageKey) {
|
|
4938
|
-
|
|
5197
|
+
_context54.next = 5;
|
|
4939
5198
|
break;
|
|
4940
5199
|
}
|
|
4941
|
-
return
|
|
5200
|
+
return _context54.abrupt("return", null);
|
|
4942
5201
|
case 5:
|
|
4943
5202
|
pendingOrder = _objectSpread(_objectSpread({}, data), {}, {
|
|
4944
5203
|
need_sync: 1
|
|
4945
5204
|
});
|
|
4946
|
-
|
|
5205
|
+
_context54.next = 8;
|
|
4947
5206
|
return this.buildSmallTicketProductMap(pendingOrder);
|
|
4948
5207
|
case 8:
|
|
4949
|
-
productMap =
|
|
5208
|
+
productMap = _context54.sent;
|
|
4950
5209
|
orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
|
|
4951
|
-
return
|
|
5210
|
+
return _context54.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
|
|
4952
5211
|
requireFullyPaid: true,
|
|
4953
5212
|
productMap: productMap
|
|
4954
5213
|
}));
|
|
4955
5214
|
case 11:
|
|
4956
5215
|
case "end":
|
|
4957
|
-
return
|
|
5216
|
+
return _context54.stop();
|
|
4958
5217
|
}
|
|
4959
|
-
},
|
|
5218
|
+
}, _callee54, this);
|
|
4960
5219
|
}));
|
|
4961
|
-
function buildPendingSyncCheckoutOrder(
|
|
5220
|
+
function buildPendingSyncCheckoutOrder(_x61) {
|
|
4962
5221
|
return _buildPendingSyncCheckoutOrder.apply(this, arguments);
|
|
4963
5222
|
}
|
|
4964
5223
|
return buildPendingSyncCheckoutOrder;
|
|
@@ -5006,13 +5265,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
5006
5265
|
}, {
|
|
5007
5266
|
key: "sumPaidOrderPayments",
|
|
5008
5267
|
value: function sumPaidOrderPayments(payments) {
|
|
5009
|
-
var
|
|
5268
|
+
var _this12 = this;
|
|
5010
5269
|
if (!Array.isArray(payments)) return 0;
|
|
5011
5270
|
return payments.reduce(function (sum, payment) {
|
|
5012
5271
|
var _payment$amount;
|
|
5013
5272
|
var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
|
|
5014
5273
|
if (status === 'voided' || status === 'failed' || status === 'cancelled') return sum;
|
|
5015
|
-
return sum +
|
|
5274
|
+
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
5275
|
}, 0);
|
|
5017
5276
|
}
|
|
5018
5277
|
}, {
|
|
@@ -5026,12 +5285,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
5026
5285
|
}, {
|
|
5027
5286
|
key: "buildSmallTicketProductMap",
|
|
5028
5287
|
value: function () {
|
|
5029
|
-
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5030
|
-
var _this$
|
|
5031
|
-
|
|
5288
|
+
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(order) {
|
|
5289
|
+
var _this$products3,
|
|
5290
|
+
_this13 = this;
|
|
5032
5291
|
var products, productIdSet, productIds, entries;
|
|
5033
|
-
return _regeneratorRuntime().wrap(function
|
|
5034
|
-
while (1) switch (
|
|
5292
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
5293
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
5035
5294
|
case 0:
|
|
5036
5295
|
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
|
|
5037
5296
|
productIdSet = new Set();
|
|
@@ -5052,46 +5311,46 @@ var Server = /*#__PURE__*/function () {
|
|
|
5052
5311
|
}
|
|
5053
5312
|
});
|
|
5054
5313
|
productIds = Array.from(productIdSet);
|
|
5055
|
-
if (!(!productIds.length || typeof ((_this$
|
|
5056
|
-
|
|
5314
|
+
if (!(!productIds.length || typeof ((_this$products3 = this.products) === null || _this$products3 === void 0 ? void 0 : _this$products3.getProductById) !== 'function')) {
|
|
5315
|
+
_context56.next = 6;
|
|
5057
5316
|
break;
|
|
5058
5317
|
}
|
|
5059
|
-
return
|
|
5318
|
+
return _context56.abrupt("return", {});
|
|
5060
5319
|
case 6:
|
|
5061
|
-
|
|
5320
|
+
_context56.next = 8;
|
|
5062
5321
|
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 (
|
|
5322
|
+
var _ref60 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(id) {
|
|
5323
|
+
var _this13$products, _this13$products$getP, product;
|
|
5324
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5325
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
5067
5326
|
case 0:
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
return (
|
|
5327
|
+
_context55.prev = 0;
|
|
5328
|
+
_context55.next = 3;
|
|
5329
|
+
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
5330
|
case 3:
|
|
5072
|
-
product =
|
|
5073
|
-
return
|
|
5331
|
+
product = _context55.sent;
|
|
5332
|
+
return _context55.abrupt("return", product ? [String(id), product] : null);
|
|
5074
5333
|
case 7:
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5334
|
+
_context55.prev = 7;
|
|
5335
|
+
_context55.t0 = _context55["catch"](0);
|
|
5336
|
+
_this13.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
|
|
5078
5337
|
product_id: id,
|
|
5079
|
-
error:
|
|
5338
|
+
error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
|
|
5080
5339
|
});
|
|
5081
|
-
return
|
|
5340
|
+
return _context55.abrupt("return", null);
|
|
5082
5341
|
case 11:
|
|
5083
5342
|
case "end":
|
|
5084
|
-
return
|
|
5343
|
+
return _context55.stop();
|
|
5085
5344
|
}
|
|
5086
|
-
},
|
|
5345
|
+
}, _callee55, null, [[0, 7]]);
|
|
5087
5346
|
}));
|
|
5088
|
-
return function (
|
|
5347
|
+
return function (_x63) {
|
|
5089
5348
|
return _ref60.apply(this, arguments);
|
|
5090
5349
|
};
|
|
5091
5350
|
}()));
|
|
5092
5351
|
case 8:
|
|
5093
|
-
entries =
|
|
5094
|
-
return
|
|
5352
|
+
entries = _context56.sent;
|
|
5353
|
+
return _context56.abrupt("return", entries.reduce(function (map, entry) {
|
|
5095
5354
|
if (!entry) return map;
|
|
5096
5355
|
var _entry = _slicedToArray(entry, 2),
|
|
5097
5356
|
id = _entry[0],
|
|
@@ -5101,25 +5360,190 @@ var Server = /*#__PURE__*/function () {
|
|
|
5101
5360
|
}, {}));
|
|
5102
5361
|
case 10:
|
|
5103
5362
|
case "end":
|
|
5104
|
-
return
|
|
5363
|
+
return _context56.stop();
|
|
5105
5364
|
}
|
|
5106
|
-
},
|
|
5365
|
+
}, _callee56, this);
|
|
5107
5366
|
}));
|
|
5108
|
-
function buildSmallTicketProductMap(
|
|
5367
|
+
function buildSmallTicketProductMap(_x62) {
|
|
5109
5368
|
return _buildSmallTicketProductMap.apply(this, arguments);
|
|
5110
5369
|
}
|
|
5111
5370
|
return buildSmallTicketProductMap;
|
|
5112
5371
|
}()
|
|
5372
|
+
}, {
|
|
5373
|
+
key: "collectSalesDetailProductIds",
|
|
5374
|
+
value: function collectSalesDetailProductIds(order) {
|
|
5375
|
+
var products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
|
|
5376
|
+
var productIds = new Set();
|
|
5377
|
+
var addProductId = function addProductId(rawProductId) {
|
|
5378
|
+
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return;
|
|
5379
|
+
var productId = Number(rawProductId);
|
|
5380
|
+
if (Number.isFinite(productId)) productIds.add(productId);
|
|
5381
|
+
};
|
|
5382
|
+
products.forEach(function (product) {
|
|
5383
|
+
var _product$product_id2;
|
|
5384
|
+
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);
|
|
5385
|
+
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
5386
|
+
product.product_bundle.forEach(function (bundle) {
|
|
5387
|
+
var _ref61, _bundle$bundle_produc2;
|
|
5388
|
+
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);
|
|
5389
|
+
});
|
|
5390
|
+
}
|
|
5391
|
+
});
|
|
5392
|
+
return Array.from(productIds);
|
|
5393
|
+
}
|
|
5394
|
+
}, {
|
|
5395
|
+
key: "buildSalesDetailProductSnapshotMap",
|
|
5396
|
+
value: function () {
|
|
5397
|
+
var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(order) {
|
|
5398
|
+
var _this$products4;
|
|
5399
|
+
var productIds, getSnapshots;
|
|
5400
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5401
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
5402
|
+
case 0:
|
|
5403
|
+
productIds = this.collectSalesDetailProductIds(order);
|
|
5404
|
+
getSnapshots = (_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductSnapshotsByIds;
|
|
5405
|
+
if (!(!productIds.length || typeof getSnapshots !== 'function')) {
|
|
5406
|
+
_context57.next = 4;
|
|
5407
|
+
break;
|
|
5408
|
+
}
|
|
5409
|
+
return _context57.abrupt("return", {});
|
|
5410
|
+
case 4:
|
|
5411
|
+
_context57.prev = 4;
|
|
5412
|
+
_context57.next = 7;
|
|
5413
|
+
return getSnapshots.call(this.products, productIds);
|
|
5414
|
+
case 7:
|
|
5415
|
+
return _context57.abrupt("return", _context57.sent);
|
|
5416
|
+
case 10:
|
|
5417
|
+
_context57.prev = 10;
|
|
5418
|
+
_context57.t0 = _context57["catch"](4);
|
|
5419
|
+
this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
|
|
5420
|
+
product_ids: productIds,
|
|
5421
|
+
error: _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0)
|
|
5422
|
+
});
|
|
5423
|
+
return _context57.abrupt("return", {});
|
|
5424
|
+
case 14:
|
|
5425
|
+
case "end":
|
|
5426
|
+
return _context57.stop();
|
|
5427
|
+
}
|
|
5428
|
+
}, _callee57, this, [[4, 10]]);
|
|
5429
|
+
}));
|
|
5430
|
+
function buildSalesDetailProductSnapshotMap(_x64) {
|
|
5431
|
+
return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
|
|
5432
|
+
}
|
|
5433
|
+
return buildSalesDetailProductSnapshotMap;
|
|
5434
|
+
}()
|
|
5435
|
+
}, {
|
|
5436
|
+
key: "withProductCatalogSnapshots",
|
|
5437
|
+
value: function withProductCatalogSnapshots(product, snapshotMap) {
|
|
5438
|
+
var _product$product_id3;
|
|
5439
|
+
if (!product || _typeof(product) !== 'object') return product;
|
|
5440
|
+
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;
|
|
5441
|
+
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return product;
|
|
5442
|
+
var productId = Number(rawProductId);
|
|
5443
|
+
if (!Number.isFinite(productId)) return product;
|
|
5444
|
+
var snapshot = snapshotMap[String(productId)];
|
|
5445
|
+
if (!snapshot) return product;
|
|
5446
|
+
var shouldFillCover = (product.product_cover === undefined || product.product_cover === null || product.product_cover === '') && snapshot.cover !== undefined && snapshot.cover !== null && snapshot.cover !== '';
|
|
5447
|
+
var metadata = product.metadata && _typeof(product.metadata) === 'object' ? product.metadata : {};
|
|
5448
|
+
var shouldFillHolderConfig = (metadata.holder_config === undefined || metadata.holder_config === null) && snapshot.holder_config !== undefined && snapshot.holder_config !== null;
|
|
5449
|
+
if (!shouldFillCover && !shouldFillHolderConfig) return product;
|
|
5450
|
+
return _objectSpread(_objectSpread(_objectSpread({}, product), shouldFillCover ? {
|
|
5451
|
+
product_cover: snapshot.cover
|
|
5452
|
+
} : {}), shouldFillHolderConfig ? {
|
|
5453
|
+
metadata: _objectSpread(_objectSpread({}, metadata), {}, {
|
|
5454
|
+
holder_config: snapshot.holder_config
|
|
5455
|
+
})
|
|
5456
|
+
} : {});
|
|
5457
|
+
}
|
|
5458
|
+
}, {
|
|
5459
|
+
key: "withBundleCatalogSnapshots",
|
|
5460
|
+
value: function withBundleCatalogSnapshots(product, snapshotMap) {
|
|
5461
|
+
if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
|
|
5462
|
+
var hasChanged = false;
|
|
5463
|
+
var productBundle = product.product_bundle.map(function (bundle) {
|
|
5464
|
+
var _ref62, _bundle$bundle_produc3;
|
|
5465
|
+
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
5466
|
+
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;
|
|
5467
|
+
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
|
|
5468
|
+
var productId = Number(rawProductId);
|
|
5469
|
+
if (!Number.isFinite(productId)) return bundle;
|
|
5470
|
+
var snapshot = snapshotMap[String(productId)];
|
|
5471
|
+
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 !== '';
|
|
5472
|
+
if (!shouldFillCover) return bundle;
|
|
5473
|
+
hasChanged = true;
|
|
5474
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
5475
|
+
cover: snapshot.cover
|
|
5476
|
+
});
|
|
5477
|
+
});
|
|
5478
|
+
if (!hasChanged) return product;
|
|
5479
|
+
return _objectSpread(_objectSpread({}, product), {}, {
|
|
5480
|
+
product_bundle: productBundle
|
|
5481
|
+
});
|
|
5482
|
+
}
|
|
5483
|
+
}, {
|
|
5484
|
+
key: "withSalesDetailProductSnapshots",
|
|
5485
|
+
value: function () {
|
|
5486
|
+
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(order) {
|
|
5487
|
+
var _this14 = this;
|
|
5488
|
+
var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
|
|
5489
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
5490
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
5491
|
+
case 0:
|
|
5492
|
+
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
|
|
5493
|
+
if (products !== null && products !== void 0 && products.length) {
|
|
5494
|
+
_context58.next = 3;
|
|
5495
|
+
break;
|
|
5496
|
+
}
|
|
5497
|
+
return _context58.abrupt("return", order);
|
|
5498
|
+
case 3:
|
|
5499
|
+
_context58.next = 5;
|
|
5500
|
+
return this.buildSalesDetailProductSnapshotMap(order);
|
|
5501
|
+
case 5:
|
|
5502
|
+
snapshotMap = _context58.sent;
|
|
5503
|
+
if (Object.keys(snapshotMap).length) {
|
|
5504
|
+
_context58.next = 8;
|
|
5505
|
+
break;
|
|
5506
|
+
}
|
|
5507
|
+
return _context58.abrupt("return", order);
|
|
5508
|
+
case 8:
|
|
5509
|
+
hasChanged = false;
|
|
5510
|
+
enrichedProducts = products.map(function (product) {
|
|
5511
|
+
var productWithBundleSnapshots = _this14.withBundleCatalogSnapshots(product, snapshotMap);
|
|
5512
|
+
var nextProduct = _this14.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
|
|
5513
|
+
if (nextProduct !== product) hasChanged = true;
|
|
5514
|
+
return nextProduct;
|
|
5515
|
+
});
|
|
5516
|
+
if (hasChanged) {
|
|
5517
|
+
_context58.next = 12;
|
|
5518
|
+
break;
|
|
5519
|
+
}
|
|
5520
|
+
return _context58.abrupt("return", order);
|
|
5521
|
+
case 12:
|
|
5522
|
+
enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
|
|
5523
|
+
products: enrichedProducts
|
|
5524
|
+
});
|
|
5525
|
+
return _context58.abrupt("return", enrichedOrder);
|
|
5526
|
+
case 14:
|
|
5527
|
+
case "end":
|
|
5528
|
+
return _context58.stop();
|
|
5529
|
+
}
|
|
5530
|
+
}, _callee58, this);
|
|
5531
|
+
}));
|
|
5532
|
+
function withSalesDetailProductSnapshots(_x65) {
|
|
5533
|
+
return _withSalesDetailProductSnapshots.apply(this, arguments);
|
|
5534
|
+
}
|
|
5535
|
+
return withSalesDetailProductSnapshots;
|
|
5536
|
+
}()
|
|
5113
5537
|
}, {
|
|
5114
5538
|
key: "withPendingSyncProductTitles",
|
|
5115
5539
|
value: function withPendingSyncProductTitles(order, productMap) {
|
|
5116
|
-
var
|
|
5540
|
+
var _this15 = this;
|
|
5117
5541
|
var products = Array.isArray(order.products) ? order.products : null;
|
|
5118
5542
|
if (!(products !== null && products !== void 0 && products.length)) return order;
|
|
5119
5543
|
return _objectSpread(_objectSpread({}, order), {}, {
|
|
5120
5544
|
products: products.map(function (product) {
|
|
5121
5545
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
5122
|
-
product_title:
|
|
5546
|
+
product_title: _this15.buildProductTitleSnapshot(product, productMap)
|
|
5123
5547
|
});
|
|
5124
5548
|
})
|
|
5125
5549
|
});
|
|
@@ -5127,27 +5551,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
5127
5551
|
}, {
|
|
5128
5552
|
key: "buildProductTitleSnapshot",
|
|
5129
5553
|
value: function buildProductTitleSnapshot(product, productMap) {
|
|
5130
|
-
var _product$
|
|
5554
|
+
var _product$product_id4,
|
|
5131
5555
|
_product$product,
|
|
5132
5556
|
_fallbackProduct$prod,
|
|
5133
|
-
|
|
5134
|
-
var productId = (_product$
|
|
5557
|
+
_this16 = this;
|
|
5558
|
+
var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
|
|
5135
5559
|
var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
|
|
5136
5560
|
var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
|
|
5137
5561
|
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
5562
|
var currentLocale = this.getProductTitleSnapshotCurrentLocale();
|
|
5139
5563
|
var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
|
|
5140
5564
|
return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
|
|
5141
|
-
snapshot[key] =
|
|
5565
|
+
snapshot[key] = _this16.resolveProductTitleValue(ownTitle, key, currentLocale) || _this16.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
|
|
5142
5566
|
return snapshot;
|
|
5143
5567
|
}, {});
|
|
5144
5568
|
}
|
|
5145
5569
|
}, {
|
|
5146
5570
|
key: "getProductTitleSnapshotCurrentLocale",
|
|
5147
5571
|
value: function getProductTitleSnapshotCurrentLocale() {
|
|
5148
|
-
var _this$core$
|
|
5572
|
+
var _this$core$context3, _this$core$context4;
|
|
5149
5573
|
var shopInfo = this.getSmallTicketShopInfo();
|
|
5150
|
-
var rawLocale = shopInfo.primary_locale || this.getAppData('locale') || this.getAppData('language') || ((_this$core$
|
|
5574
|
+
var rawLocale = shopInfo.primary_locale || this.getAppData('locale') || this.getAppData('language') || ((_this$core$context3 = this.core.context) === null || _this$core$context3 === void 0 ? void 0 : _this$core$context3.locale) || ((_this$core$context4 = this.core.context) === null || _this$core$context4 === void 0 ? void 0 : _this$core$context4.language);
|
|
5151
5575
|
return this.normalizeProductTitleSnapshotLocale(rawLocale);
|
|
5152
5576
|
}
|
|
5153
5577
|
}, {
|
|
@@ -5163,7 +5587,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5163
5587
|
}, {
|
|
5164
5588
|
key: "resolveProductTitleValue",
|
|
5165
5589
|
value: function resolveProductTitleValue(value, key, currentLocale) {
|
|
5166
|
-
var
|
|
5590
|
+
var _ref63, _ref64, _value$key;
|
|
5167
5591
|
if (value === undefined || value === null || value === '') return null;
|
|
5168
5592
|
if (_typeof(value) !== 'object') {
|
|
5169
5593
|
var title = String(value);
|
|
@@ -5173,7 +5597,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5173
5597
|
}
|
|
5174
5598
|
var normalizedKey = key.replace('-', '_');
|
|
5175
5599
|
var dashedKey = key.replace('_', '-');
|
|
5176
|
-
var rawValue = (
|
|
5600
|
+
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
5601
|
if (rawValue === undefined || rawValue === null || rawValue === '') return null;
|
|
5178
5602
|
if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
|
|
5179
5603
|
return String(rawValue);
|
|
@@ -5236,50 +5660,50 @@ var Server = /*#__PURE__*/function () {
|
|
|
5236
5660
|
}, {
|
|
5237
5661
|
key: "enrichPaymentNamesByCode",
|
|
5238
5662
|
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 (
|
|
5663
|
+
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(order) {
|
|
5664
|
+
var _this17 = this;
|
|
5665
|
+
var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator13, _step13, method, codeKey, name, hasResolvedName, enrichedPayments;
|
|
5666
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context59) {
|
|
5667
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
5244
5668
|
case 0:
|
|
5245
5669
|
payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
|
|
5246
5670
|
hasMissingName = payments.some(function (payment) {
|
|
5247
|
-
return
|
|
5671
|
+
return _this17.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this17.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
|
|
5248
5672
|
});
|
|
5249
5673
|
if (hasMissingName) {
|
|
5250
|
-
|
|
5674
|
+
_context59.next = 4;
|
|
5251
5675
|
break;
|
|
5252
5676
|
}
|
|
5253
|
-
return
|
|
5677
|
+
return _context59.abrupt("return", order);
|
|
5254
5678
|
case 4:
|
|
5255
|
-
|
|
5256
|
-
|
|
5679
|
+
_context59.prev = 4;
|
|
5680
|
+
_context59.next = 7;
|
|
5257
5681
|
return this.getPaymentRouteModule();
|
|
5258
5682
|
case 7:
|
|
5259
|
-
paymentModule =
|
|
5260
|
-
|
|
5683
|
+
paymentModule = _context59.sent;
|
|
5684
|
+
_context59.next = 10;
|
|
5261
5685
|
return paymentModule.getPayMethodListAsync();
|
|
5262
5686
|
case 10:
|
|
5263
|
-
payMethods =
|
|
5687
|
+
payMethods = _context59.sent;
|
|
5264
5688
|
nameByCode = new Map();
|
|
5265
|
-
|
|
5689
|
+
_iterator13 = _createForOfIteratorHelper(payMethods || []);
|
|
5266
5690
|
try {
|
|
5267
|
-
for (
|
|
5268
|
-
method =
|
|
5691
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
5692
|
+
method = _step13.value;
|
|
5269
5693
|
codeKey = this.getPaymentCodeKey(method === null || method === void 0 ? void 0 : method.code);
|
|
5270
5694
|
name = this.resolveFirstProductTitleValue(method === null || method === void 0 ? void 0 : method.name);
|
|
5271
5695
|
if (codeKey && name) nameByCode.set(codeKey, name);
|
|
5272
5696
|
}
|
|
5273
5697
|
} catch (err) {
|
|
5274
|
-
|
|
5698
|
+
_iterator13.e(err);
|
|
5275
5699
|
} finally {
|
|
5276
|
-
|
|
5700
|
+
_iterator13.f();
|
|
5277
5701
|
}
|
|
5278
5702
|
hasResolvedName = false;
|
|
5279
5703
|
enrichedPayments = payments.map(function (payment) {
|
|
5280
|
-
if (!
|
|
5281
|
-
if (!
|
|
5282
|
-
var name = nameByCode.get(
|
|
5704
|
+
if (!_this17.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
|
|
5705
|
+
if (!_this17.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
|
|
5706
|
+
var name = nameByCode.get(_this17.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
|
|
5283
5707
|
if (!name) return payment;
|
|
5284
5708
|
hasResolvedName = true;
|
|
5285
5709
|
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
@@ -5287,28 +5711,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
5287
5711
|
});
|
|
5288
5712
|
});
|
|
5289
5713
|
if (hasResolvedName) {
|
|
5290
|
-
|
|
5714
|
+
_context59.next = 18;
|
|
5291
5715
|
break;
|
|
5292
5716
|
}
|
|
5293
|
-
return
|
|
5717
|
+
return _context59.abrupt("return", order);
|
|
5294
5718
|
case 18:
|
|
5295
|
-
return
|
|
5719
|
+
return _context59.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
|
|
5296
5720
|
payments: enrichedPayments
|
|
5297
5721
|
}));
|
|
5298
5722
|
case 21:
|
|
5299
|
-
|
|
5300
|
-
|
|
5723
|
+
_context59.prev = 21;
|
|
5724
|
+
_context59.t0 = _context59["catch"](4);
|
|
5301
5725
|
this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
|
|
5302
|
-
error:
|
|
5726
|
+
error: _context59.t0 instanceof Error ? _context59.t0.message : String(_context59.t0)
|
|
5303
5727
|
});
|
|
5304
|
-
return
|
|
5728
|
+
return _context59.abrupt("return", order);
|
|
5305
5729
|
case 25:
|
|
5306
5730
|
case "end":
|
|
5307
|
-
return
|
|
5731
|
+
return _context59.stop();
|
|
5308
5732
|
}
|
|
5309
|
-
},
|
|
5733
|
+
}, _callee59, this, [[4, 21]]);
|
|
5310
5734
|
}));
|
|
5311
|
-
function enrichPaymentNamesByCode(
|
|
5735
|
+
function enrichPaymentNamesByCode(_x66) {
|
|
5312
5736
|
return _enrichPaymentNamesByCode.apply(this, arguments);
|
|
5313
5737
|
}
|
|
5314
5738
|
return enrichPaymentNamesByCode;
|
|
@@ -5316,66 +5740,66 @@ var Server = /*#__PURE__*/function () {
|
|
|
5316
5740
|
}, {
|
|
5317
5741
|
key: "withLocalSmallTicketData",
|
|
5318
5742
|
value: function () {
|
|
5319
|
-
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5743
|
+
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(order, options) {
|
|
5320
5744
|
var _options$productMap, enrichedOrder, productMap, smallTicketData;
|
|
5321
|
-
return _regeneratorRuntime().wrap(function
|
|
5322
|
-
while (1) switch (
|
|
5745
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
5746
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
5323
5747
|
case 0:
|
|
5324
5748
|
if (this.shouldBuildSmallTicketData(order)) {
|
|
5325
|
-
|
|
5749
|
+
_context60.next = 2;
|
|
5326
5750
|
break;
|
|
5327
5751
|
}
|
|
5328
|
-
return
|
|
5752
|
+
return _context60.abrupt("return", order);
|
|
5329
5753
|
case 2:
|
|
5330
5754
|
if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
|
|
5331
|
-
|
|
5755
|
+
_context60.next = 4;
|
|
5332
5756
|
break;
|
|
5333
5757
|
}
|
|
5334
|
-
return
|
|
5758
|
+
return _context60.abrupt("return", order);
|
|
5335
5759
|
case 4:
|
|
5336
|
-
|
|
5337
|
-
|
|
5760
|
+
_context60.prev = 4;
|
|
5761
|
+
_context60.next = 7;
|
|
5338
5762
|
return this.enrichPaymentNamesByCode(order);
|
|
5339
5763
|
case 7:
|
|
5340
|
-
enrichedOrder =
|
|
5764
|
+
enrichedOrder = _context60.sent;
|
|
5341
5765
|
if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
|
|
5342
|
-
|
|
5766
|
+
_context60.next = 12;
|
|
5343
5767
|
break;
|
|
5344
5768
|
}
|
|
5345
|
-
|
|
5346
|
-
|
|
5769
|
+
_context60.t0 = _options$productMap;
|
|
5770
|
+
_context60.next = 15;
|
|
5347
5771
|
break;
|
|
5348
5772
|
case 12:
|
|
5349
|
-
|
|
5773
|
+
_context60.next = 14;
|
|
5350
5774
|
return this.buildSmallTicketProductMap(enrichedOrder);
|
|
5351
5775
|
case 14:
|
|
5352
|
-
|
|
5776
|
+
_context60.t0 = _context60.sent;
|
|
5353
5777
|
case 15:
|
|
5354
|
-
productMap =
|
|
5778
|
+
productMap = _context60.t0;
|
|
5355
5779
|
smallTicketData = buildSmallTicketData({
|
|
5356
5780
|
order: enrichedOrder,
|
|
5357
5781
|
shopInfo: this.getSmallTicketShopInfo(),
|
|
5358
5782
|
productMap: productMap
|
|
5359
5783
|
});
|
|
5360
|
-
return
|
|
5784
|
+
return _context60.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
|
|
5361
5785
|
payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
|
|
5362
5786
|
small_ticket_data: smallTicketData
|
|
5363
5787
|
})
|
|
5364
5788
|
}));
|
|
5365
5789
|
case 20:
|
|
5366
|
-
|
|
5367
|
-
|
|
5790
|
+
_context60.prev = 20;
|
|
5791
|
+
_context60.t1 = _context60["catch"](4);
|
|
5368
5792
|
this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
|
|
5369
|
-
error:
|
|
5793
|
+
error: _context60.t1 instanceof Error ? _context60.t1.message : String(_context60.t1)
|
|
5370
5794
|
});
|
|
5371
|
-
return
|
|
5795
|
+
return _context60.abrupt("return", order);
|
|
5372
5796
|
case 24:
|
|
5373
5797
|
case "end":
|
|
5374
|
-
return
|
|
5798
|
+
return _context60.stop();
|
|
5375
5799
|
}
|
|
5376
|
-
},
|
|
5800
|
+
}, _callee60, this, [[4, 20]]);
|
|
5377
5801
|
}));
|
|
5378
|
-
function withLocalSmallTicketData(
|
|
5802
|
+
function withLocalSmallTicketData(_x67, _x68) {
|
|
5379
5803
|
return _withLocalSmallTicketData.apply(this, arguments);
|
|
5380
5804
|
}
|
|
5381
5805
|
return withLocalSmallTicketData;
|
|
@@ -5437,22 +5861,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
5437
5861
|
}, {
|
|
5438
5862
|
key: "handleUpdateLocalOrdersBatch",
|
|
5439
5863
|
value: (function () {
|
|
5440
|
-
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5864
|
+
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(orderIds) {
|
|
5441
5865
|
var _this$app17;
|
|
5442
|
-
var existedBefore,
|
|
5443
|
-
return _regeneratorRuntime().wrap(function
|
|
5444
|
-
while (1) switch (
|
|
5866
|
+
var existedBefore, _iterator14, _step14, id, fetched, message, fetchedMap, _iterator15, _step15, order, oid, freshOrders, succeedIds, failed, _iterator16, _step16, _id, fresh, _message2, overwritten, inserted;
|
|
5867
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
5868
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
5445
5869
|
case 0:
|
|
5446
5870
|
this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
|
|
5447
5871
|
count: orderIds.length,
|
|
5448
5872
|
orderIds: orderIds
|
|
5449
5873
|
});
|
|
5450
5874
|
if (this.order) {
|
|
5451
|
-
|
|
5875
|
+
_context61.next = 4;
|
|
5452
5876
|
break;
|
|
5453
5877
|
}
|
|
5454
5878
|
this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
|
|
5455
|
-
return
|
|
5879
|
+
return _context61.abrupt("return", {
|
|
5456
5880
|
code: 500,
|
|
5457
5881
|
status: false,
|
|
5458
5882
|
message: 'Order 模块未注册',
|
|
@@ -5460,11 +5884,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5460
5884
|
});
|
|
5461
5885
|
case 4:
|
|
5462
5886
|
if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && _this$app17.request) {
|
|
5463
|
-
|
|
5887
|
+
_context61.next = 7;
|
|
5464
5888
|
break;
|
|
5465
5889
|
}
|
|
5466
5890
|
this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
|
|
5467
|
-
return
|
|
5891
|
+
return _context61.abrupt("return", {
|
|
5468
5892
|
code: 500,
|
|
5469
5893
|
status: false,
|
|
5470
5894
|
message: 'app.request 不可用',
|
|
@@ -5473,35 +5897,35 @@ var Server = /*#__PURE__*/function () {
|
|
|
5473
5897
|
case 7:
|
|
5474
5898
|
// 拉取前先记录"本地是否已存在",用于区分 overwritten / inserted
|
|
5475
5899
|
existedBefore = new Map();
|
|
5476
|
-
|
|
5900
|
+
_iterator14 = _createForOfIteratorHelper(orderIds);
|
|
5477
5901
|
try {
|
|
5478
|
-
for (
|
|
5479
|
-
id =
|
|
5902
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
5903
|
+
id = _step14.value;
|
|
5480
5904
|
existedBefore.set(id, !!this.order.getOrderByOrderId(id));
|
|
5481
5905
|
}
|
|
5482
5906
|
|
|
5483
5907
|
// 走 orderDataSource 的批量 HTTP 通道,一次请求拉回多笔详情
|
|
5484
5908
|
} catch (err) {
|
|
5485
|
-
|
|
5909
|
+
_iterator14.e(err);
|
|
5486
5910
|
} finally {
|
|
5487
|
-
|
|
5911
|
+
_iterator14.f();
|
|
5488
5912
|
}
|
|
5489
5913
|
fetched = [];
|
|
5490
|
-
|
|
5491
|
-
|
|
5914
|
+
_context61.prev = 11;
|
|
5915
|
+
_context61.next = 14;
|
|
5492
5916
|
return this.order.fetchOrdersByHttp(orderIds);
|
|
5493
5917
|
case 14:
|
|
5494
|
-
fetched =
|
|
5495
|
-
|
|
5918
|
+
fetched = _context61.sent;
|
|
5919
|
+
_context61.next = 22;
|
|
5496
5920
|
break;
|
|
5497
5921
|
case 17:
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
message =
|
|
5922
|
+
_context61.prev = 17;
|
|
5923
|
+
_context61.t0 = _context61["catch"](11);
|
|
5924
|
+
message = _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0);
|
|
5501
5925
|
this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
|
|
5502
5926
|
message: message
|
|
5503
5927
|
});
|
|
5504
|
-
return
|
|
5928
|
+
return _context61.abrupt("return", {
|
|
5505
5929
|
code: 500,
|
|
5506
5930
|
status: false,
|
|
5507
5931
|
message: message,
|
|
@@ -5510,45 +5934,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
5510
5934
|
case 22:
|
|
5511
5935
|
// 按返回结果中的 order_id 建索引,未命中即视为单笔失败
|
|
5512
5936
|
fetchedMap = new Map();
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5937
|
+
_iterator15 = _createForOfIteratorHelper(fetched);
|
|
5938
|
+
_context61.prev = 24;
|
|
5939
|
+
_iterator15.s();
|
|
5516
5940
|
case 26:
|
|
5517
|
-
if ((
|
|
5518
|
-
|
|
5941
|
+
if ((_step15 = _iterator15.n()).done) {
|
|
5942
|
+
_context61.next = 34;
|
|
5519
5943
|
break;
|
|
5520
5944
|
}
|
|
5521
|
-
order =
|
|
5945
|
+
order = _step15.value;
|
|
5522
5946
|
oid = order === null || order === void 0 ? void 0 : order.order_id;
|
|
5523
5947
|
if (!(oid === undefined || oid === null)) {
|
|
5524
|
-
|
|
5948
|
+
_context61.next = 31;
|
|
5525
5949
|
break;
|
|
5526
5950
|
}
|
|
5527
|
-
return
|
|
5951
|
+
return _context61.abrupt("continue", 32);
|
|
5528
5952
|
case 31:
|
|
5529
5953
|
fetchedMap.set(String(oid), order);
|
|
5530
5954
|
case 32:
|
|
5531
|
-
|
|
5955
|
+
_context61.next = 26;
|
|
5532
5956
|
break;
|
|
5533
5957
|
case 34:
|
|
5534
|
-
|
|
5958
|
+
_context61.next = 39;
|
|
5535
5959
|
break;
|
|
5536
5960
|
case 36:
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5961
|
+
_context61.prev = 36;
|
|
5962
|
+
_context61.t1 = _context61["catch"](24);
|
|
5963
|
+
_iterator15.e(_context61.t1);
|
|
5540
5964
|
case 39:
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
return
|
|
5965
|
+
_context61.prev = 39;
|
|
5966
|
+
_iterator15.f();
|
|
5967
|
+
return _context61.finish(39);
|
|
5544
5968
|
case 42:
|
|
5545
5969
|
freshOrders = [];
|
|
5546
5970
|
succeedIds = [];
|
|
5547
5971
|
failed = [];
|
|
5548
|
-
|
|
5972
|
+
_iterator16 = _createForOfIteratorHelper(orderIds);
|
|
5549
5973
|
try {
|
|
5550
|
-
for (
|
|
5551
|
-
_id =
|
|
5974
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
5975
|
+
_id = _step16.value;
|
|
5552
5976
|
fresh = fetchedMap.get(_id);
|
|
5553
5977
|
if (fresh) {
|
|
5554
5978
|
freshOrders.push(fresh);
|
|
@@ -5561,28 +5985,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
5561
5985
|
}
|
|
5562
5986
|
}
|
|
5563
5987
|
} catch (err) {
|
|
5564
|
-
|
|
5988
|
+
_iterator16.e(err);
|
|
5565
5989
|
} finally {
|
|
5566
|
-
|
|
5990
|
+
_iterator16.f();
|
|
5567
5991
|
}
|
|
5568
5992
|
if (!(freshOrders.length > 0)) {
|
|
5569
|
-
|
|
5993
|
+
_context61.next = 58;
|
|
5570
5994
|
break;
|
|
5571
5995
|
}
|
|
5572
|
-
|
|
5573
|
-
|
|
5996
|
+
_context61.prev = 48;
|
|
5997
|
+
_context61.next = 51;
|
|
5574
5998
|
return this.order.upsertOrdersFromRemote(freshOrders);
|
|
5575
5999
|
case 51:
|
|
5576
|
-
|
|
6000
|
+
_context61.next = 58;
|
|
5577
6001
|
break;
|
|
5578
6002
|
case 53:
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
_message2 =
|
|
6003
|
+
_context61.prev = 53;
|
|
6004
|
+
_context61.t2 = _context61["catch"](48);
|
|
6005
|
+
_message2 = _context61.t2 instanceof Error ? _context61.t2.message : String(_context61.t2);
|
|
5582
6006
|
this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
|
|
5583
6007
|
message: _message2
|
|
5584
6008
|
});
|
|
5585
|
-
return
|
|
6009
|
+
return _context61.abrupt("return", {
|
|
5586
6010
|
code: 500,
|
|
5587
6011
|
status: false,
|
|
5588
6012
|
message: _message2,
|
|
@@ -5601,7 +6025,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5601
6025
|
insertedCount: inserted.length,
|
|
5602
6026
|
failedCount: failed.length
|
|
5603
6027
|
});
|
|
5604
|
-
return
|
|
6028
|
+
return _context61.abrupt("return", {
|
|
5605
6029
|
code: 200,
|
|
5606
6030
|
status: true,
|
|
5607
6031
|
message: '',
|
|
@@ -5613,11 +6037,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5613
6037
|
});
|
|
5614
6038
|
case 62:
|
|
5615
6039
|
case "end":
|
|
5616
|
-
return
|
|
6040
|
+
return _context61.stop();
|
|
5617
6041
|
}
|
|
5618
|
-
},
|
|
6042
|
+
}, _callee61, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
|
|
5619
6043
|
}));
|
|
5620
|
-
function handleUpdateLocalOrdersBatch(
|
|
6044
|
+
function handleUpdateLocalOrdersBatch(_x69) {
|
|
5621
6045
|
return _handleUpdateLocalOrdersBatch.apply(this, arguments);
|
|
5622
6046
|
}
|
|
5623
6047
|
return handleUpdateLocalOrdersBatch;
|
|
@@ -5638,11 +6062,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5638
6062
|
var queryIndex = url.indexOf('?');
|
|
5639
6063
|
if (queryIndex < 0) return null;
|
|
5640
6064
|
var query = url.slice(queryIndex + 1);
|
|
5641
|
-
var
|
|
5642
|
-
|
|
6065
|
+
var _iterator17 = _createForOfIteratorHelper(query.split('&')),
|
|
6066
|
+
_step17;
|
|
5643
6067
|
try {
|
|
5644
|
-
for (
|
|
5645
|
-
var pair =
|
|
6068
|
+
for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
|
|
6069
|
+
var pair = _step17.value;
|
|
5646
6070
|
if (!pair) continue;
|
|
5647
6071
|
var _pair$split = pair.split('='),
|
|
5648
6072
|
_pair$split2 = _slicedToArray(_pair$split, 2),
|
|
@@ -5658,9 +6082,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5658
6082
|
}
|
|
5659
6083
|
}
|
|
5660
6084
|
} catch (err) {
|
|
5661
|
-
|
|
6085
|
+
_iterator17.e(err);
|
|
5662
6086
|
} finally {
|
|
5663
|
-
|
|
6087
|
+
_iterator17.f();
|
|
5664
6088
|
}
|
|
5665
6089
|
return null;
|
|
5666
6090
|
}
|
|
@@ -5859,10 +6283,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5859
6283
|
value: function extractBackendErrorResponse(error) {
|
|
5860
6284
|
var _error$response3,
|
|
5861
6285
|
_error$response4,
|
|
5862
|
-
|
|
6286
|
+
_this18 = this;
|
|
5863
6287
|
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
6288
|
return candidates.find(function (candidate) {
|
|
5865
|
-
return
|
|
6289
|
+
return _this18.isExplicitBackendErrorResponse(candidate);
|
|
5866
6290
|
}) || null;
|
|
5867
6291
|
}
|
|
5868
6292
|
}, {
|
|
@@ -5981,24 +6405,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
5981
6405
|
}, {
|
|
5982
6406
|
key: "recomputeAndNotifyFloorPlanQuery",
|
|
5983
6407
|
value: (function () {
|
|
5984
|
-
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5985
|
-
var
|
|
5986
|
-
return _regeneratorRuntime().wrap(function
|
|
5987
|
-
while (1) switch (
|
|
6408
|
+
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62() {
|
|
6409
|
+
var _iterator18, _step18, _step18$value, subscriberId, sub, result, errorMessage;
|
|
6410
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
6411
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
5988
6412
|
case 0:
|
|
5989
6413
|
if (!(this.floorPlanQuerySubscribers.size === 0)) {
|
|
5990
|
-
|
|
6414
|
+
_context62.next = 2;
|
|
5991
6415
|
break;
|
|
5992
6416
|
}
|
|
5993
|
-
return
|
|
6417
|
+
return _context62.abrupt("return");
|
|
5994
6418
|
case 2:
|
|
5995
6419
|
this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
|
|
5996
6420
|
subscriberCount: this.floorPlanQuerySubscribers.size
|
|
5997
6421
|
});
|
|
5998
|
-
|
|
6422
|
+
_iterator18 = _createForOfIteratorHelper(this.floorPlanQuerySubscribers.entries());
|
|
5999
6423
|
try {
|
|
6000
|
-
for (
|
|
6001
|
-
|
|
6424
|
+
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
6425
|
+
_step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], sub = _step18$value[1];
|
|
6002
6426
|
try {
|
|
6003
6427
|
result = this.computeFloorPlanQueryResult(sub.context);
|
|
6004
6428
|
sub.callback(result);
|
|
@@ -6014,15 +6438,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
6014
6438
|
}
|
|
6015
6439
|
}
|
|
6016
6440
|
} catch (err) {
|
|
6017
|
-
|
|
6441
|
+
_iterator18.e(err);
|
|
6018
6442
|
} finally {
|
|
6019
|
-
|
|
6443
|
+
_iterator18.f();
|
|
6020
6444
|
}
|
|
6021
6445
|
case 5:
|
|
6022
6446
|
case "end":
|
|
6023
|
-
return
|
|
6447
|
+
return _context62.stop();
|
|
6024
6448
|
}
|
|
6025
|
-
},
|
|
6449
|
+
}, _callee62, this);
|
|
6026
6450
|
}));
|
|
6027
6451
|
function recomputeAndNotifyFloorPlanQuery() {
|
|
6028
6452
|
return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
|
|
@@ -6052,21 +6476,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
6052
6476
|
* filter 逻辑暂为 mock,仅记录参数
|
|
6053
6477
|
*/
|
|
6054
6478
|
function () {
|
|
6055
|
-
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6479
|
+
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(data) {
|
|
6056
6480
|
var rawList, result;
|
|
6057
|
-
return _regeneratorRuntime().wrap(function
|
|
6058
|
-
while (1) switch (
|
|
6481
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
6482
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
6059
6483
|
case 0:
|
|
6060
6484
|
this.logInfo('computeOrderQueryResult: 开始过滤', {
|
|
6061
6485
|
data: data
|
|
6062
6486
|
});
|
|
6063
6487
|
console.log('[Server] computeOrderQueryResult', data);
|
|
6064
6488
|
if (this.order) {
|
|
6065
|
-
|
|
6489
|
+
_context63.next = 5;
|
|
6066
6490
|
break;
|
|
6067
6491
|
}
|
|
6068
6492
|
this.logError('computeOrderQueryResult: Order 模块未注册');
|
|
6069
|
-
return
|
|
6493
|
+
return _context63.abrupt("return", {
|
|
6070
6494
|
code: 500,
|
|
6071
6495
|
message: 'Order 模块未注册',
|
|
6072
6496
|
data: {
|
|
@@ -6090,7 +6514,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6090
6514
|
skip: result.skip,
|
|
6091
6515
|
rejected: result.rejected
|
|
6092
6516
|
});
|
|
6093
|
-
return
|
|
6517
|
+
return _context63.abrupt("return", {
|
|
6094
6518
|
code: 200,
|
|
6095
6519
|
data: result,
|
|
6096
6520
|
message: '',
|
|
@@ -6098,11 +6522,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6098
6522
|
});
|
|
6099
6523
|
case 10:
|
|
6100
6524
|
case "end":
|
|
6101
|
-
return
|
|
6525
|
+
return _context63.stop();
|
|
6102
6526
|
}
|
|
6103
|
-
},
|
|
6527
|
+
}, _callee63, this);
|
|
6104
6528
|
}));
|
|
6105
|
-
function computeOrderQueryResult(
|
|
6529
|
+
function computeOrderQueryResult(_x70) {
|
|
6106
6530
|
return _computeOrderQueryResult.apply(this, arguments);
|
|
6107
6531
|
}
|
|
6108
6532
|
return computeOrderQueryResult;
|
|
@@ -6115,17 +6539,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
6115
6539
|
}, {
|
|
6116
6540
|
key: "computeBookingQueryResult",
|
|
6117
6541
|
value: (function () {
|
|
6118
|
-
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6542
|
+
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(data) {
|
|
6119
6543
|
var rawOrders, result;
|
|
6120
|
-
return _regeneratorRuntime().wrap(function
|
|
6121
|
-
while (1) switch (
|
|
6544
|
+
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
6545
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
6122
6546
|
case 0:
|
|
6123
6547
|
if (this.order) {
|
|
6124
|
-
|
|
6548
|
+
_context64.next = 3;
|
|
6125
6549
|
break;
|
|
6126
6550
|
}
|
|
6127
6551
|
this.logError('computeBookingQueryResult: Order 模块未注册');
|
|
6128
|
-
return
|
|
6552
|
+
return _context64.abrupt("return", {
|
|
6129
6553
|
code: 500,
|
|
6130
6554
|
message: 'Order 模块未注册',
|
|
6131
6555
|
data: {
|
|
@@ -6144,7 +6568,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6144
6568
|
size: result.size,
|
|
6145
6569
|
skip: result.skip
|
|
6146
6570
|
});
|
|
6147
|
-
return
|
|
6571
|
+
return _context64.abrupt("return", {
|
|
6148
6572
|
code: 200,
|
|
6149
6573
|
data: result,
|
|
6150
6574
|
message: '',
|
|
@@ -6152,11 +6576,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6152
6576
|
});
|
|
6153
6577
|
case 8:
|
|
6154
6578
|
case "end":
|
|
6155
|
-
return
|
|
6579
|
+
return _context64.stop();
|
|
6156
6580
|
}
|
|
6157
|
-
},
|
|
6581
|
+
}, _callee64, this);
|
|
6158
6582
|
}));
|
|
6159
|
-
function computeBookingQueryResult(
|
|
6583
|
+
function computeBookingQueryResult(_x71) {
|
|
6160
6584
|
return _computeBookingQueryResult.apply(this, arguments);
|
|
6161
6585
|
}
|
|
6162
6586
|
return computeBookingQueryResult;
|
|
@@ -6215,20 +6639,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
6215
6639
|
}, {
|
|
6216
6640
|
key: "computeProductQueryResult",
|
|
6217
6641
|
value: (function () {
|
|
6218
|
-
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6642
|
+
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(context, options) {
|
|
6219
6643
|
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 (
|
|
6644
|
+
_this19 = this;
|
|
6645
|
+
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;
|
|
6646
|
+
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
6647
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
6224
6648
|
case 0:
|
|
6225
6649
|
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;
|
|
6650
|
+
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
6651
|
queryIds = Array.isArray(ids) ? ids.map(function (id) {
|
|
6228
6652
|
return Number(id);
|
|
6229
6653
|
}).filter(function (id) {
|
|
6230
6654
|
return Number.isFinite(id);
|
|
6231
6655
|
}) : [];
|
|
6656
|
+
formatterContext = this.buildProductFormatterContext({
|
|
6657
|
+
schedule_date: schedule_date,
|
|
6658
|
+
schedule_datetime: schedule_datetime,
|
|
6659
|
+
customer_id: customer_id,
|
|
6660
|
+
strategy_context: strategy_context
|
|
6661
|
+
});
|
|
6232
6662
|
this.logInfo('computeProductQueryResult 开始', {
|
|
6233
6663
|
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
6664
|
ids: queryIds,
|
|
@@ -6237,38 +6667,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
6237
6667
|
customer_id: customer_id,
|
|
6238
6668
|
extension_type: extension_type,
|
|
6239
6669
|
product_id: product_id,
|
|
6670
|
+
strategyContextKeys: strategy_context ? Object.keys(strategy_context) : [],
|
|
6240
6671
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6241
6672
|
});
|
|
6242
6673
|
if (this.products) {
|
|
6243
|
-
|
|
6674
|
+
_context65.next = 8;
|
|
6244
6675
|
break;
|
|
6245
6676
|
}
|
|
6246
6677
|
this.logError('computeProductQueryResult: Products 模块未注册');
|
|
6247
|
-
return
|
|
6678
|
+
return _context65.abrupt("return", {
|
|
6248
6679
|
message: 'Products 模块未注册',
|
|
6249
|
-
data:
|
|
6250
|
-
list: [],
|
|
6251
|
-
count: 0
|
|
6252
|
-
}
|
|
6680
|
+
data: this.buildProductQueryResultPayload([], 0)
|
|
6253
6681
|
});
|
|
6254
|
-
case
|
|
6682
|
+
case 8:
|
|
6255
6683
|
if (!(queryIds.length > 0)) {
|
|
6256
|
-
|
|
6684
|
+
_context65.next = 20;
|
|
6257
6685
|
break;
|
|
6258
6686
|
}
|
|
6259
6687
|
uniqueIds = Array.from(new Set(queryIds));
|
|
6260
6688
|
_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
|
-
}, {
|
|
6689
|
+
_context65.next = 13;
|
|
6690
|
+
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
6267
6691
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
6268
6692
|
productIds: uniqueIds
|
|
6269
6693
|
});
|
|
6270
|
-
case
|
|
6271
|
-
productsWithPrice =
|
|
6694
|
+
case 13:
|
|
6695
|
+
productsWithPrice = _context65.sent;
|
|
6272
6696
|
perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
|
|
6273
6697
|
count: productsWithPrice.length,
|
|
6274
6698
|
ids: uniqueIds
|
|
@@ -6288,30 +6712,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
6288
6712
|
ids: uniqueIds,
|
|
6289
6713
|
count: extensionFilteredProducts.length
|
|
6290
6714
|
});
|
|
6291
|
-
return
|
|
6715
|
+
return _context65.abrupt("return", {
|
|
6292
6716
|
code: 200,
|
|
6293
|
-
data:
|
|
6294
|
-
list: extensionFilteredProducts,
|
|
6295
|
-
count: extensionFilteredProducts.length
|
|
6296
|
-
},
|
|
6717
|
+
data: this.buildProductQueryResultPayload(extensionFilteredProducts),
|
|
6297
6718
|
message: '',
|
|
6298
6719
|
status: true
|
|
6299
6720
|
});
|
|
6300
|
-
case
|
|
6721
|
+
case 20:
|
|
6301
6722
|
if (!(product_id != null && Number.isFinite(Number(product_id)))) {
|
|
6302
|
-
|
|
6723
|
+
_context65.next = 32;
|
|
6303
6724
|
break;
|
|
6304
6725
|
}
|
|
6305
6726
|
pid = Number(product_id);
|
|
6306
6727
|
_tPrice2 = performance.now();
|
|
6307
|
-
|
|
6308
|
-
return this.products.getProductsWithPrice(schedule_date, {
|
|
6309
|
-
scheduleModule: this.getSchedule()
|
|
6310
|
-
}, {
|
|
6728
|
+
_context65.next = 25;
|
|
6729
|
+
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
6311
6730
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6312
6731
|
});
|
|
6313
|
-
case
|
|
6314
|
-
allProductsWithPrice =
|
|
6732
|
+
case 25:
|
|
6733
|
+
allProductsWithPrice = _context65.sent;
|
|
6315
6734
|
perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
|
|
6316
6735
|
count: allProductsWithPrice.length,
|
|
6317
6736
|
productId: pid
|
|
@@ -6331,28 +6750,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
6331
6750
|
productId: pid,
|
|
6332
6751
|
found: !!item
|
|
6333
6752
|
});
|
|
6334
|
-
return
|
|
6753
|
+
return _context65.abrupt("return", {
|
|
6335
6754
|
code: 200,
|
|
6336
6755
|
data: item,
|
|
6337
6756
|
message: item ? '' : '商品不存在或未发布',
|
|
6338
6757
|
status: true
|
|
6339
6758
|
});
|
|
6340
|
-
case
|
|
6759
|
+
case 32:
|
|
6341
6760
|
if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
|
|
6342
|
-
|
|
6761
|
+
_context65.next = 52;
|
|
6343
6762
|
break;
|
|
6344
6763
|
}
|
|
6345
6764
|
_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
|
-
}, {
|
|
6765
|
+
_context65.next = 36;
|
|
6766
|
+
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
6352
6767
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6353
6768
|
});
|
|
6354
|
-
case
|
|
6355
|
-
_filteredProducts2 =
|
|
6769
|
+
case 36:
|
|
6770
|
+
_filteredProducts2 = _context65.sent;
|
|
6356
6771
|
perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
|
|
6357
6772
|
count: _filteredProducts2.length,
|
|
6358
6773
|
extension_type: extension_type
|
|
@@ -6391,49 +6806,40 @@ var Server = /*#__PURE__*/function () {
|
|
|
6391
6806
|
filteredCount: _filteredProducts2.length,
|
|
6392
6807
|
extension_type: extension_type
|
|
6393
6808
|
});
|
|
6394
|
-
return
|
|
6809
|
+
return _context65.abrupt("return", {
|
|
6395
6810
|
code: 200,
|
|
6396
|
-
data:
|
|
6397
|
-
list: _filteredProducts2,
|
|
6398
|
-
count: _filteredProducts2.length
|
|
6399
|
-
},
|
|
6811
|
+
data: this.buildProductQueryResultPayload(_filteredProducts2),
|
|
6400
6812
|
message: '',
|
|
6401
6813
|
status: true
|
|
6402
6814
|
});
|
|
6403
|
-
case
|
|
6815
|
+
case 52:
|
|
6404
6816
|
if (this.menu) {
|
|
6405
|
-
|
|
6817
|
+
_context65.next = 55;
|
|
6406
6818
|
break;
|
|
6407
6819
|
}
|
|
6408
6820
|
this.logError('computeProductQueryResult: Menu 模块未注册');
|
|
6409
|
-
return
|
|
6821
|
+
return _context65.abrupt("return", {
|
|
6410
6822
|
message: 'Menu 模块未注册',
|
|
6411
|
-
data:
|
|
6412
|
-
list: [],
|
|
6413
|
-
count: 0
|
|
6414
|
-
}
|
|
6823
|
+
data: this.buildProductQueryResultPayload([], 0)
|
|
6415
6824
|
});
|
|
6416
|
-
case
|
|
6825
|
+
case 55:
|
|
6417
6826
|
if (this.schedule) {
|
|
6418
|
-
|
|
6827
|
+
_context65.next = 58;
|
|
6419
6828
|
break;
|
|
6420
6829
|
}
|
|
6421
6830
|
this.logError('computeProductQueryResult: Schedule 模块未注册');
|
|
6422
|
-
return
|
|
6831
|
+
return _context65.abrupt("return", {
|
|
6423
6832
|
message: 'Schedule 模块未注册',
|
|
6424
|
-
data:
|
|
6425
|
-
list: [],
|
|
6426
|
-
count: 0
|
|
6427
|
-
}
|
|
6833
|
+
data: this.buildProductQueryResultPayload([], 0)
|
|
6428
6834
|
});
|
|
6429
|
-
case
|
|
6835
|
+
case 58:
|
|
6430
6836
|
activeMenuList = [];
|
|
6431
6837
|
if (menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0) {
|
|
6432
6838
|
tMenu = performance.now();
|
|
6433
6839
|
menuList = this.menu.getMenuByIds(menu_list_ids);
|
|
6434
6840
|
activeMenuList = menuList.filter(function (menu) {
|
|
6435
|
-
var
|
|
6436
|
-
return ((
|
|
6841
|
+
var _this19$schedule;
|
|
6842
|
+
return ((_this19$schedule = _this19.schedule) === null || _this19$schedule === void 0 ? void 0 : _this19$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
|
|
6437
6843
|
});
|
|
6438
6844
|
perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
|
|
6439
6845
|
totalMenu: menuList.length,
|
|
@@ -6450,26 +6856,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
6450
6856
|
});
|
|
6451
6857
|
tPrice = performance.now();
|
|
6452
6858
|
if (!(scopedProductIds.length > 0)) {
|
|
6453
|
-
|
|
6859
|
+
_context65.next = 71;
|
|
6454
6860
|
break;
|
|
6455
6861
|
}
|
|
6456
|
-
|
|
6457
|
-
return this.products.getProductsWithPrice(schedule_date, {
|
|
6458
|
-
scheduleModule: this.getSchedule(),
|
|
6459
|
-
schedule_datetime: schedule_datetime,
|
|
6460
|
-
customer_id: customer_id
|
|
6461
|
-
}, {
|
|
6862
|
+
_context65.next = 68;
|
|
6863
|
+
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
6462
6864
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
6463
6865
|
productIds: productScope.isAllProducts ? undefined : scopedProductIds
|
|
6464
6866
|
});
|
|
6465
|
-
case
|
|
6466
|
-
|
|
6467
|
-
|
|
6867
|
+
case 68:
|
|
6868
|
+
_context65.t0 = _context65.sent;
|
|
6869
|
+
_context65.next = 72;
|
|
6468
6870
|
break;
|
|
6469
|
-
case 70:
|
|
6470
|
-
_context61.t0 = [];
|
|
6471
6871
|
case 71:
|
|
6472
|
-
|
|
6872
|
+
_context65.t0 = [];
|
|
6873
|
+
case 72:
|
|
6874
|
+
filteredProducts = _context65.t0;
|
|
6473
6875
|
perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
|
|
6474
6876
|
count: filteredProducts.length,
|
|
6475
6877
|
scopedProductCount: scopedProductIds.length
|
|
@@ -6510,102 +6912,120 @@ var Server = /*#__PURE__*/function () {
|
|
|
6510
6912
|
filteredCount: filteredProducts.length,
|
|
6511
6913
|
activeMenuCount: activeMenuList.length
|
|
6512
6914
|
});
|
|
6513
|
-
return
|
|
6915
|
+
return _context65.abrupt("return", {
|
|
6514
6916
|
code: 200,
|
|
6515
|
-
data:
|
|
6516
|
-
list: filteredProducts,
|
|
6517
|
-
count: filteredProducts.length
|
|
6518
|
-
},
|
|
6917
|
+
data: this.buildProductQueryResultPayload(filteredProducts),
|
|
6519
6918
|
message: '',
|
|
6520
6919
|
status: true
|
|
6521
6920
|
});
|
|
6522
|
-
case
|
|
6921
|
+
case 88:
|
|
6523
6922
|
case "end":
|
|
6524
|
-
return
|
|
6923
|
+
return _context65.stop();
|
|
6525
6924
|
}
|
|
6526
|
-
},
|
|
6925
|
+
}, _callee65, this);
|
|
6527
6926
|
}));
|
|
6528
|
-
function computeProductQueryResult(
|
|
6927
|
+
function computeProductQueryResult(_x72, _x73) {
|
|
6529
6928
|
return _computeProductQueryResult.apply(this, arguments);
|
|
6530
6929
|
}
|
|
6531
6930
|
return computeProductQueryResult;
|
|
6532
6931
|
}()
|
|
6932
|
+
/**
|
|
6933
|
+
* 构建商品格式化上下文。
|
|
6934
|
+
*
|
|
6935
|
+
* 智能定价条件使用全量 menuList/scheduleList;Product Query 顶层参数只保留筛选商品集合所需字段。
|
|
6936
|
+
*/
|
|
6937
|
+
)
|
|
6938
|
+
}, {
|
|
6939
|
+
key: "buildProductFormatterContext",
|
|
6940
|
+
value: function buildProductFormatterContext(context) {
|
|
6941
|
+
var _this$menu, _this$menu$getMenuLis, _scheduleModule$getSc, _this$core$context5;
|
|
6942
|
+
var scheduleModule = this.getSchedule();
|
|
6943
|
+
return {
|
|
6944
|
+
scheduleModule: scheduleModule,
|
|
6945
|
+
schedule_datetime: context.schedule_datetime,
|
|
6946
|
+
customer_id: context.customer_id,
|
|
6947
|
+
strategy_context: context.strategy_context,
|
|
6948
|
+
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)) || [],
|
|
6949
|
+
scheduleList: (scheduleModule === null || scheduleModule === void 0 || (_scheduleModule$getSc = scheduleModule.getScheduleList) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule)) || [],
|
|
6950
|
+
dataVariantEvaluator: (_this$core$context5 = this.core.context) === null || _this$core$context5 === void 0 ? void 0 : _this$core$context5.dataVariantEvaluator
|
|
6951
|
+
};
|
|
6952
|
+
}
|
|
6953
|
+
|
|
6533
6954
|
/**
|
|
6534
6955
|
* 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
|
|
6535
6956
|
* 由 ProductsModule 的 onProductsSyncCompleted 事件触发
|
|
6536
6957
|
* @param options 可选参数
|
|
6537
6958
|
* @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
|
|
6538
6959
|
*/
|
|
6539
|
-
)
|
|
6540
6960
|
}, {
|
|
6541
6961
|
key: "recomputeAndNotifyProductQuery",
|
|
6542
6962
|
value: (function () {
|
|
6543
|
-
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6544
|
-
var
|
|
6545
|
-
return _regeneratorRuntime().wrap(function
|
|
6546
|
-
while (1) switch (
|
|
6963
|
+
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(options) {
|
|
6964
|
+
var _iterator19, _step19, _step19$value, subscriberId, subscriber, result, errorMessage;
|
|
6965
|
+
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
6966
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
6547
6967
|
case 0:
|
|
6548
6968
|
if (!(this.productQuerySubscribers.size === 0)) {
|
|
6549
|
-
|
|
6969
|
+
_context66.next = 2;
|
|
6550
6970
|
break;
|
|
6551
6971
|
}
|
|
6552
|
-
return
|
|
6972
|
+
return _context66.abrupt("return");
|
|
6553
6973
|
case 2:
|
|
6554
6974
|
this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
|
|
6555
6975
|
subscriberCount: this.productQuerySubscribers.size,
|
|
6556
6976
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6557
6977
|
});
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6978
|
+
_iterator19 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
|
|
6979
|
+
_context66.prev = 4;
|
|
6980
|
+
_iterator19.s();
|
|
6561
6981
|
case 6:
|
|
6562
|
-
if ((
|
|
6563
|
-
|
|
6982
|
+
if ((_step19 = _iterator19.n()).done) {
|
|
6983
|
+
_context66.next = 22;
|
|
6564
6984
|
break;
|
|
6565
6985
|
}
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6986
|
+
_step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
|
|
6987
|
+
_context66.prev = 8;
|
|
6988
|
+
_context66.next = 11;
|
|
6569
6989
|
return this.computeProductQueryResult(subscriber.context, {
|
|
6570
6990
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6571
6991
|
});
|
|
6572
6992
|
case 11:
|
|
6573
|
-
result =
|
|
6993
|
+
result = _context66.sent;
|
|
6574
6994
|
subscriber.callback(result);
|
|
6575
6995
|
this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
|
|
6576
6996
|
subscriberId: subscriberId
|
|
6577
6997
|
});
|
|
6578
|
-
|
|
6998
|
+
_context66.next = 20;
|
|
6579
6999
|
break;
|
|
6580
7000
|
case 16:
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
errorMessage =
|
|
7001
|
+
_context66.prev = 16;
|
|
7002
|
+
_context66.t0 = _context66["catch"](8);
|
|
7003
|
+
errorMessage = _context66.t0 instanceof Error ? _context66.t0.message : String(_context66.t0);
|
|
6584
7004
|
this.logError('recomputeAndNotifyProductQuery: 推送失败', {
|
|
6585
7005
|
subscriberId: subscriberId,
|
|
6586
7006
|
error: errorMessage
|
|
6587
7007
|
});
|
|
6588
7008
|
case 20:
|
|
6589
|
-
|
|
7009
|
+
_context66.next = 6;
|
|
6590
7010
|
break;
|
|
6591
7011
|
case 22:
|
|
6592
|
-
|
|
7012
|
+
_context66.next = 27;
|
|
6593
7013
|
break;
|
|
6594
7014
|
case 24:
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
7015
|
+
_context66.prev = 24;
|
|
7016
|
+
_context66.t1 = _context66["catch"](4);
|
|
7017
|
+
_iterator19.e(_context66.t1);
|
|
6598
7018
|
case 27:
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
return
|
|
7019
|
+
_context66.prev = 27;
|
|
7020
|
+
_iterator19.f();
|
|
7021
|
+
return _context66.finish(27);
|
|
6602
7022
|
case 30:
|
|
6603
7023
|
case "end":
|
|
6604
|
-
return
|
|
7024
|
+
return _context66.stop();
|
|
6605
7025
|
}
|
|
6606
|
-
},
|
|
7026
|
+
}, _callee66, this, [[4, 24, 27, 30], [8, 16]]);
|
|
6607
7027
|
}));
|
|
6608
|
-
function recomputeAndNotifyProductQuery(
|
|
7028
|
+
function recomputeAndNotifyProductQuery(_x74) {
|
|
6609
7029
|
return _recomputeAndNotifyProductQuery.apply(this, arguments);
|
|
6610
7030
|
}
|
|
6611
7031
|
return recomputeAndNotifyProductQuery;
|
|
@@ -6617,37 +7037,37 @@ var Server = /*#__PURE__*/function () {
|
|
|
6617
7037
|
}, {
|
|
6618
7038
|
key: "recomputeAndNotifyOrderQuery",
|
|
6619
7039
|
value: (function () {
|
|
6620
|
-
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6621
|
-
var notifyStartAt,
|
|
6622
|
-
return _regeneratorRuntime().wrap(function
|
|
6623
|
-
while (1) switch (
|
|
7040
|
+
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67() {
|
|
7041
|
+
var notifyStartAt, _iterator20, _step20, _step20$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
|
|
7042
|
+
return _regeneratorRuntime().wrap(function _callee67$(_context67) {
|
|
7043
|
+
while (1) switch (_context67.prev = _context67.next) {
|
|
6624
7044
|
case 0:
|
|
6625
7045
|
if (!(this.orderQuerySubscribers.size === 0)) {
|
|
6626
|
-
|
|
7046
|
+
_context67.next = 2;
|
|
6627
7047
|
break;
|
|
6628
7048
|
}
|
|
6629
|
-
return
|
|
7049
|
+
return _context67.abrupt("return");
|
|
6630
7050
|
case 2:
|
|
6631
7051
|
notifyStartAt = Date.now();
|
|
6632
7052
|
this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
|
|
6633
7053
|
subscriberCount: this.orderQuerySubscribers.size,
|
|
6634
7054
|
notifyStartAt: new Date(notifyStartAt).toISOString()
|
|
6635
7055
|
});
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
7056
|
+
_iterator20 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
|
|
7057
|
+
_context67.prev = 5;
|
|
7058
|
+
_iterator20.s();
|
|
6639
7059
|
case 7:
|
|
6640
|
-
if ((
|
|
6641
|
-
|
|
7060
|
+
if ((_step20 = _iterator20.n()).done) {
|
|
7061
|
+
_context67.next = 27;
|
|
6642
7062
|
break;
|
|
6643
7063
|
}
|
|
6644
|
-
|
|
6645
|
-
|
|
7064
|
+
_step20$value = _slicedToArray(_step20.value, 2), subscriberId = _step20$value[0], subscriber = _step20$value[1];
|
|
7065
|
+
_context67.prev = 9;
|
|
6646
7066
|
computeStartAt = Date.now();
|
|
6647
|
-
|
|
7067
|
+
_context67.next = 13;
|
|
6648
7068
|
return this.computeOrderQueryResult(subscriber.context);
|
|
6649
7069
|
case 13:
|
|
6650
|
-
result =
|
|
7070
|
+
result = _context67.sent;
|
|
6651
7071
|
computeEndAt = Date.now();
|
|
6652
7072
|
callbackStartAt = Date.now();
|
|
6653
7073
|
subscriber.callback(result);
|
|
@@ -6658,30 +7078,30 @@ var Server = /*#__PURE__*/function () {
|
|
|
6658
7078
|
callbackDurationMs: callbackEndAt - callbackStartAt,
|
|
6659
7079
|
totalDurationMs: callbackEndAt - computeStartAt
|
|
6660
7080
|
});
|
|
6661
|
-
|
|
7081
|
+
_context67.next = 25;
|
|
6662
7082
|
break;
|
|
6663
7083
|
case 21:
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
errorMessage =
|
|
7084
|
+
_context67.prev = 21;
|
|
7085
|
+
_context67.t0 = _context67["catch"](9);
|
|
7086
|
+
errorMessage = _context67.t0 instanceof Error ? _context67.t0.message : String(_context67.t0);
|
|
6667
7087
|
this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
|
|
6668
7088
|
subscriberId: subscriberId,
|
|
6669
7089
|
error: errorMessage
|
|
6670
7090
|
});
|
|
6671
7091
|
case 25:
|
|
6672
|
-
|
|
7092
|
+
_context67.next = 7;
|
|
6673
7093
|
break;
|
|
6674
7094
|
case 27:
|
|
6675
|
-
|
|
7095
|
+
_context67.next = 32;
|
|
6676
7096
|
break;
|
|
6677
7097
|
case 29:
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
7098
|
+
_context67.prev = 29;
|
|
7099
|
+
_context67.t1 = _context67["catch"](5);
|
|
7100
|
+
_iterator20.e(_context67.t1);
|
|
6681
7101
|
case 32:
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
return
|
|
7102
|
+
_context67.prev = 32;
|
|
7103
|
+
_iterator20.f();
|
|
7104
|
+
return _context67.finish(32);
|
|
6685
7105
|
case 35:
|
|
6686
7106
|
notifyEndAt = Date.now();
|
|
6687
7107
|
this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
|
|
@@ -6690,9 +7110,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6690
7110
|
});
|
|
6691
7111
|
case 37:
|
|
6692
7112
|
case "end":
|
|
6693
|
-
return
|
|
7113
|
+
return _context67.stop();
|
|
6694
7114
|
}
|
|
6695
|
-
},
|
|
7115
|
+
}, _callee67, this, [[5, 29, 32, 35], [9, 21]]);
|
|
6696
7116
|
}));
|
|
6697
7117
|
function recomputeAndNotifyOrderQuery() {
|
|
6698
7118
|
return _recomputeAndNotifyOrderQuery.apply(this, arguments);
|
|
@@ -6710,7 +7130,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6710
7130
|
}, {
|
|
6711
7131
|
key: "notifySalesSearchSubscribers",
|
|
6712
7132
|
value: function notifySalesSearchSubscribers(payload) {
|
|
6713
|
-
var
|
|
7133
|
+
var _this20 = this;
|
|
6714
7134
|
if (this.salesSearchSubscribers.size === 0) return;
|
|
6715
7135
|
var changedOrders = this.extractChangedOrdersFromPayload(payload);
|
|
6716
7136
|
if (changedOrders.length === 0) {
|
|
@@ -6719,42 +7139,42 @@ var Server = /*#__PURE__*/function () {
|
|
|
6719
7139
|
// 如果当前开启了 checkout 弹窗,先不进行刷新,下面的代码会导致在全局搜索页调用 bookingTicket.destroy()
|
|
6720
7140
|
// 导致模块被销毁 ,checkout 弹窗永远无法关闭
|
|
6721
7141
|
if (window.isPaymentModalPluginOpen) return;
|
|
6722
|
-
var
|
|
6723
|
-
|
|
7142
|
+
var _iterator21 = _createForOfIteratorHelper(this.salesSearchSubscribers.entries()),
|
|
7143
|
+
_step21;
|
|
6724
7144
|
try {
|
|
6725
|
-
var
|
|
6726
|
-
var
|
|
6727
|
-
subscriberId =
|
|
6728
|
-
subscriber =
|
|
7145
|
+
var _loop2 = function _loop2() {
|
|
7146
|
+
var _step21$value = _slicedToArray(_step21.value, 2),
|
|
7147
|
+
subscriberId = _step21$value[0],
|
|
7148
|
+
subscriber = _step21$value[1];
|
|
6729
7149
|
try {
|
|
6730
7150
|
var changedVisibleOrders = changedOrders.filter(function (order) {
|
|
6731
|
-
var orderId =
|
|
7151
|
+
var orderId = _this20.getSalesSearchOrderId(order);
|
|
6732
7152
|
return !!orderId && subscriber.visibleOrderIds.has(orderId);
|
|
6733
7153
|
});
|
|
6734
7154
|
if (changedVisibleOrders.length === 0) {
|
|
6735
7155
|
return 1; // continue
|
|
6736
7156
|
}
|
|
6737
|
-
subscriber.callback(
|
|
6738
|
-
|
|
7157
|
+
subscriber.callback(_this20.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
|
|
7158
|
+
_this20.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
|
|
6739
7159
|
subscriberId: subscriberId,
|
|
6740
7160
|
kind: subscriber.kind,
|
|
6741
7161
|
count: changedVisibleOrders.length
|
|
6742
7162
|
});
|
|
6743
7163
|
} catch (error) {
|
|
6744
7164
|
var errorMessage = error instanceof Error ? error.message : String(error);
|
|
6745
|
-
|
|
7165
|
+
_this20.logError('notifySalesSearchSubscribers: 推送失败', {
|
|
6746
7166
|
subscriberId: subscriberId,
|
|
6747
7167
|
error: errorMessage
|
|
6748
7168
|
});
|
|
6749
7169
|
}
|
|
6750
7170
|
};
|
|
6751
|
-
for (
|
|
6752
|
-
if (
|
|
7171
|
+
for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
|
|
7172
|
+
if (_loop2()) continue;
|
|
6753
7173
|
}
|
|
6754
7174
|
} catch (err) {
|
|
6755
|
-
|
|
7175
|
+
_iterator21.e(err);
|
|
6756
7176
|
} finally {
|
|
6757
|
-
|
|
7177
|
+
_iterator21.f();
|
|
6758
7178
|
}
|
|
6759
7179
|
}
|
|
6760
7180
|
|
|
@@ -6833,67 +7253,67 @@ var Server = /*#__PURE__*/function () {
|
|
|
6833
7253
|
}, {
|
|
6834
7254
|
key: "recomputeAndNotifyBookingQuery",
|
|
6835
7255
|
value: (function () {
|
|
6836
|
-
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6837
|
-
var
|
|
6838
|
-
return _regeneratorRuntime().wrap(function
|
|
6839
|
-
while (1) switch (
|
|
7256
|
+
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68() {
|
|
7257
|
+
var _iterator22, _step22, _step22$value, subscriberId, subscriber, result, errorMessage;
|
|
7258
|
+
return _regeneratorRuntime().wrap(function _callee68$(_context68) {
|
|
7259
|
+
while (1) switch (_context68.prev = _context68.next) {
|
|
6840
7260
|
case 0:
|
|
6841
7261
|
if (!(this.bookingQuerySubscribers.size === 0)) {
|
|
6842
|
-
|
|
7262
|
+
_context68.next = 2;
|
|
6843
7263
|
break;
|
|
6844
7264
|
}
|
|
6845
|
-
return
|
|
7265
|
+
return _context68.abrupt("return");
|
|
6846
7266
|
case 2:
|
|
6847
7267
|
this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
|
|
6848
7268
|
subscriberCount: this.bookingQuerySubscribers.size
|
|
6849
7269
|
});
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
7270
|
+
_iterator22 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
|
|
7271
|
+
_context68.prev = 4;
|
|
7272
|
+
_iterator22.s();
|
|
6853
7273
|
case 6:
|
|
6854
|
-
if ((
|
|
6855
|
-
|
|
7274
|
+
if ((_step22 = _iterator22.n()).done) {
|
|
7275
|
+
_context68.next = 22;
|
|
6856
7276
|
break;
|
|
6857
7277
|
}
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
7278
|
+
_step22$value = _slicedToArray(_step22.value, 2), subscriberId = _step22$value[0], subscriber = _step22$value[1];
|
|
7279
|
+
_context68.prev = 8;
|
|
7280
|
+
_context68.next = 11;
|
|
6861
7281
|
return this.computeBookingQueryResult(subscriber.context);
|
|
6862
7282
|
case 11:
|
|
6863
|
-
result =
|
|
7283
|
+
result = _context68.sent;
|
|
6864
7284
|
subscriber.callback(result);
|
|
6865
7285
|
this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
|
|
6866
7286
|
subscriberId: subscriberId
|
|
6867
7287
|
});
|
|
6868
|
-
|
|
7288
|
+
_context68.next = 20;
|
|
6869
7289
|
break;
|
|
6870
7290
|
case 16:
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
errorMessage =
|
|
7291
|
+
_context68.prev = 16;
|
|
7292
|
+
_context68.t0 = _context68["catch"](8);
|
|
7293
|
+
errorMessage = _context68.t0 instanceof Error ? _context68.t0.message : String(_context68.t0);
|
|
6874
7294
|
this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
|
|
6875
7295
|
subscriberId: subscriberId,
|
|
6876
7296
|
error: errorMessage
|
|
6877
7297
|
});
|
|
6878
7298
|
case 20:
|
|
6879
|
-
|
|
7299
|
+
_context68.next = 6;
|
|
6880
7300
|
break;
|
|
6881
7301
|
case 22:
|
|
6882
|
-
|
|
7302
|
+
_context68.next = 27;
|
|
6883
7303
|
break;
|
|
6884
7304
|
case 24:
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
7305
|
+
_context68.prev = 24;
|
|
7306
|
+
_context68.t1 = _context68["catch"](4);
|
|
7307
|
+
_iterator22.e(_context68.t1);
|
|
6888
7308
|
case 27:
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
return
|
|
7309
|
+
_context68.prev = 27;
|
|
7310
|
+
_iterator22.f();
|
|
7311
|
+
return _context68.finish(27);
|
|
6892
7312
|
case 30:
|
|
6893
7313
|
case "end":
|
|
6894
|
-
return
|
|
7314
|
+
return _context68.stop();
|
|
6895
7315
|
}
|
|
6896
|
-
},
|
|
7316
|
+
}, _callee68, this, [[4, 24, 27, 30], [8, 16]]);
|
|
6897
7317
|
}));
|
|
6898
7318
|
function recomputeAndNotifyBookingQuery() {
|
|
6899
7319
|
return _recomputeAndNotifyBookingQuery.apply(this, arguments);
|
|
@@ -6923,11 +7343,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6923
7343
|
var allowedProductIds = new Set();
|
|
6924
7344
|
var allowedCollectionIds = new Set();
|
|
6925
7345
|
var hasProductAll = false;
|
|
6926
|
-
var
|
|
6927
|
-
|
|
7346
|
+
var _iterator23 = _createForOfIteratorHelper(activeMenuList),
|
|
7347
|
+
_step23;
|
|
6928
7348
|
try {
|
|
6929
|
-
for (
|
|
6930
|
-
var menu =
|
|
7349
|
+
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
7350
|
+
var menu = _step23.value;
|
|
6931
7351
|
var config = menu.partyroom_package;
|
|
6932
7352
|
if (!config) {
|
|
6933
7353
|
console.warn('[Server] 餐牌缺少 partyroom_package 配置:', menu);
|
|
@@ -6987,9 +7407,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6987
7407
|
|
|
6988
7408
|
// 如果有餐牌允许所有商品,返回所有商品
|
|
6989
7409
|
} catch (err) {
|
|
6990
|
-
|
|
7410
|
+
_iterator23.e(err);
|
|
6991
7411
|
} finally {
|
|
6992
|
-
|
|
7412
|
+
_iterator23.f();
|
|
6993
7413
|
}
|
|
6994
7414
|
if (hasProductAll) {
|
|
6995
7415
|
this.logInfo('getProductScopeByMenuConfig: 返回所有商品 scope(product_all)');
|