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