@pisell/pisellos 2.2.260 → 2.2.261
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/index.js +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 +17 -13
- package/dist/modules/Order/index.d.ts +33 -2
- package/dist/modules/Order/index.js +615 -288
- package/dist/modules/Order/types.d.ts +20 -2
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
- package/dist/modules/Order/utils.d.ts +4 -0
- package/dist/modules/Order/utils.js +116 -29
- 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 +4 -3
- package/dist/modules/Rules/index.js +42 -17
- package/dist/modules/Rules/types.d.ts +2 -1
- package/dist/modules/SalesSummary/index.d.ts +7 -3
- package/dist/modules/SalesSummary/index.js +67 -39
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +2 -1
- package/dist/modules/SurchargeList/index.d.ts +6 -4
- package/dist/modules/SurchargeList/index.js +62 -39
- package/dist/modules/SurchargeList/types.d.ts +6 -2
- package/dist/server/index.d.ts +3 -50
- package/dist/server/index.js +1075 -1040
- package/dist/server/modules/order/index.d.ts +22 -3
- package/dist/server/modules/order/index.js +398 -316
- package/dist/server/modules/products/index.d.ts +7 -26
- package/dist/server/modules/products/index.js +76 -166
- package/dist/server/modules/products/types.d.ts +0 -14
- package/dist/solution/BaseSales/index.d.ts +22 -2
- package/dist/solution/BaseSales/index.js +995 -701
- package/dist/solution/BaseSales/types.d.ts +1 -0
- package/dist/solution/BaseSales/types.js +2 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +74 -29
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +9 -1
- package/dist/solution/BookingTicket/index.js +153 -6
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/ScanOrder/index.js +31 -20
- 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 +2 -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 +11 -1
- package/lib/modules/Order/index.d.ts +33 -2
- package/lib/modules/Order/index.js +402 -64
- package/lib/modules/Order/types.d.ts +20 -2
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
- package/lib/modules/Order/utils.d.ts +4 -0
- package/lib/modules/Order/utils.js +90 -3
- 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 +4 -3
- package/lib/modules/Rules/index.js +27 -7
- package/lib/modules/Rules/types.d.ts +2 -1
- package/lib/modules/SalesSummary/index.d.ts +7 -3
- package/lib/modules/SalesSummary/index.js +28 -11
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +2 -0
- package/lib/modules/SurchargeList/index.d.ts +6 -4
- package/lib/modules/SurchargeList/index.js +41 -21
- package/lib/modules/SurchargeList/types.d.ts +6 -2
- package/lib/server/index.d.ts +3 -50
- package/lib/server/index.js +244 -215
- package/lib/server/modules/order/index.d.ts +22 -3
- package/lib/server/modules/order/index.js +103 -53
- package/lib/server/modules/products/index.d.ts +7 -26
- package/lib/server/modules/products/index.js +35 -113
- package/lib/server/modules/products/types.d.ts +0 -14
- package/lib/solution/BaseSales/index.d.ts +22 -2
- package/lib/solution/BaseSales/index.js +246 -60
- package/lib/solution/BaseSales/types.d.ts +1 -0
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +59 -16
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +9 -1
- package/lib/solution/BookingTicket/index.js +101 -0
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/VenueBooking/index.js +8 -0
- package/package.json +1 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -49
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -152
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -87
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -755
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -282
- 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 -146
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -49
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -139
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -87
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -564
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -295
- 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 -146
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
package/dist/server/index.js
CHANGED
|
@@ -62,7 +62,7 @@ var PRODUCT_TITLE_SNAPSHOT_KEYS = ['en', 'ja', 'pt', 'auto', 'zh-CN', 'zh-HK', '
|
|
|
62
62
|
var Server = /*#__PURE__*/function () {
|
|
63
63
|
function Server(core) {
|
|
64
64
|
var _this = this,
|
|
65
|
-
_this$
|
|
65
|
+
_this$app4;
|
|
66
66
|
_classCallCheck(this, Server);
|
|
67
67
|
_defineProperty(this, "core", void 0);
|
|
68
68
|
_defineProperty(this, "app", void 0);
|
|
@@ -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
|
}
|
|
@@ -1041,7 +1029,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
1041
1029
|
checkoutData: checkoutData,
|
|
1042
1030
|
order: printableOrder,
|
|
1043
1031
|
response: null,
|
|
1044
|
-
requireFullyPaid: false
|
|
1032
|
+
requireFullyPaid: false,
|
|
1033
|
+
isManualPrint: true
|
|
1045
1034
|
});
|
|
1046
1035
|
case 27:
|
|
1047
1036
|
printResult = _context16.sent;
|
|
@@ -1080,14 +1069,143 @@ var Server = /*#__PURE__*/function () {
|
|
|
1080
1069
|
return _ref39.apply(this, arguments);
|
|
1081
1070
|
};
|
|
1082
1071
|
}());
|
|
1083
|
-
_defineProperty(this, "
|
|
1072
|
+
_defineProperty(this, "handleMachinecodeBatchMeta", /*#__PURE__*/function () {
|
|
1084
1073
|
var _ref43 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref42) {
|
|
1085
|
-
var _this$app2;
|
|
1086
|
-
var
|
|
1074
|
+
var _this$resolveMachinec, _this$app2;
|
|
1075
|
+
var data, title, backendPath, ids, status, message, _response$code, _response$status, _response$message, _response$data2, response, backendError, _backendError$code, _backendError$status, _backendError$message, _backendError$data, _message;
|
|
1087
1076
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1088
1077
|
while (1) switch (_context17.prev = _context17.next) {
|
|
1089
1078
|
case 0:
|
|
1090
|
-
|
|
1079
|
+
data = _ref42.data;
|
|
1080
|
+
title = 'handleMachinecodeBatchMeta';
|
|
1081
|
+
backendPath = '/shop/machinecode/batch';
|
|
1082
|
+
ids = Array.isArray(data === null || data === void 0 ? void 0 : data.ids) ? data.ids : [];
|
|
1083
|
+
status = data === null || data === void 0 ? void 0 : data.status;
|
|
1084
|
+
_this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
|
|
1085
|
+
backendPath: backendPath,
|
|
1086
|
+
batchSize: ids.length,
|
|
1087
|
+
status: status,
|
|
1088
|
+
order_lookup: (_this$resolveMachinec = _this.resolveMachinecodeBatchMetadataLookup(data)) !== null && _this$resolveMachinec !== void 0 ? _this$resolveMachinec : null
|
|
1089
|
+
});
|
|
1090
|
+
if (!(ids.length === 0)) {
|
|
1091
|
+
_context17.next = 8;
|
|
1092
|
+
break;
|
|
1093
|
+
}
|
|
1094
|
+
return _context17.abrupt("return", {
|
|
1095
|
+
code: 200,
|
|
1096
|
+
status: true,
|
|
1097
|
+
message: '',
|
|
1098
|
+
data: []
|
|
1099
|
+
});
|
|
1100
|
+
case 8:
|
|
1101
|
+
if (!(status !== 'used' && status !== 'unused')) {
|
|
1102
|
+
_context17.next = 10;
|
|
1103
|
+
break;
|
|
1104
|
+
}
|
|
1105
|
+
return _context17.abrupt("return", {
|
|
1106
|
+
code: 400,
|
|
1107
|
+
status: false,
|
|
1108
|
+
message: '无效的核销状态',
|
|
1109
|
+
data: null
|
|
1110
|
+
});
|
|
1111
|
+
case 10:
|
|
1112
|
+
_context17.prev = 10;
|
|
1113
|
+
_context17.next = 13;
|
|
1114
|
+
return _this.syncMachinecodeRedeemStatusToLocalOrder(data, ids, status);
|
|
1115
|
+
case 13:
|
|
1116
|
+
_context17.next = 20;
|
|
1117
|
+
break;
|
|
1118
|
+
case 15:
|
|
1119
|
+
_context17.prev = 15;
|
|
1120
|
+
_context17.t0 = _context17["catch"](10);
|
|
1121
|
+
message = _this.getUnknownErrorMessage(_context17.t0);
|
|
1122
|
+
_this.logError("".concat(title, ": \u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0\u5931\u8D25"), {
|
|
1123
|
+
error: message,
|
|
1124
|
+
error_detail: _this.normalizeUnknownError(_context17.t0)
|
|
1125
|
+
});
|
|
1126
|
+
return _context17.abrupt("return", {
|
|
1127
|
+
code: 500,
|
|
1128
|
+
status: false,
|
|
1129
|
+
message: message,
|
|
1130
|
+
data: null
|
|
1131
|
+
});
|
|
1132
|
+
case 20:
|
|
1133
|
+
if ((_this$app2 = _this.app) !== null && _this$app2 !== void 0 && (_this$app2 = _this$app2.request) !== null && _this$app2 !== void 0 && _this$app2.post) {
|
|
1134
|
+
_context17.next = 23;
|
|
1135
|
+
break;
|
|
1136
|
+
}
|
|
1137
|
+
_this.logError("".concat(title, ": app.request \u4E0D\u53EF\u7528"), {
|
|
1138
|
+
backendPath: backendPath
|
|
1139
|
+
});
|
|
1140
|
+
return _context17.abrupt("return", {
|
|
1141
|
+
code: 500,
|
|
1142
|
+
status: false,
|
|
1143
|
+
message: 'app.request 不可用',
|
|
1144
|
+
data: null
|
|
1145
|
+
});
|
|
1146
|
+
case 23:
|
|
1147
|
+
_context17.prev = 23;
|
|
1148
|
+
_context17.next = 26;
|
|
1149
|
+
return _this.app.request.post(backendPath, {
|
|
1150
|
+
ids: ids,
|
|
1151
|
+
status: status
|
|
1152
|
+
}, {
|
|
1153
|
+
isShopApi: true,
|
|
1154
|
+
customToast: function customToast() {}
|
|
1155
|
+
});
|
|
1156
|
+
case 26:
|
|
1157
|
+
response = _context17.sent;
|
|
1158
|
+
return _context17.abrupt("return", {
|
|
1159
|
+
code: (_response$code = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code !== void 0 ? _response$code : 200,
|
|
1160
|
+
status: (_response$status = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status !== void 0 ? _response$status : true,
|
|
1161
|
+
message: (_response$message = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message !== void 0 ? _response$message : '',
|
|
1162
|
+
data: (_response$data2 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data2 !== void 0 ? _response$data2 : response
|
|
1163
|
+
});
|
|
1164
|
+
case 30:
|
|
1165
|
+
_context17.prev = 30;
|
|
1166
|
+
_context17.t1 = _context17["catch"](23);
|
|
1167
|
+
backendError = _this.extractBackendErrorResponse(_context17.t1);
|
|
1168
|
+
if (!backendError) {
|
|
1169
|
+
_context17.next = 35;
|
|
1170
|
+
break;
|
|
1171
|
+
}
|
|
1172
|
+
return _context17.abrupt("return", {
|
|
1173
|
+
code: (_backendError$code = backendError.code) !== null && _backendError$code !== void 0 ? _backendError$code : 500,
|
|
1174
|
+
status: (_backendError$status = backendError.status) !== null && _backendError$status !== void 0 ? _backendError$status : false,
|
|
1175
|
+
message: (_backendError$message = backendError.message) !== null && _backendError$message !== void 0 ? _backendError$message : '后端拒绝 batch-metadata',
|
|
1176
|
+
data: (_backendError$data = backendError.data) !== null && _backendError$data !== void 0 ? _backendError$data : null
|
|
1177
|
+
});
|
|
1178
|
+
case 35:
|
|
1179
|
+
_message = _this.getUnknownErrorMessage(_context17.t1);
|
|
1180
|
+
_this.logError("".concat(title, ": \u8BF7\u6C42\u5931\u8D25"), {
|
|
1181
|
+
backendPath: backendPath,
|
|
1182
|
+
error: _message,
|
|
1183
|
+
error_detail: _this.normalizeUnknownError(_context17.t1)
|
|
1184
|
+
});
|
|
1185
|
+
return _context17.abrupt("return", {
|
|
1186
|
+
code: 500,
|
|
1187
|
+
status: false,
|
|
1188
|
+
message: _message,
|
|
1189
|
+
data: null
|
|
1190
|
+
});
|
|
1191
|
+
case 38:
|
|
1192
|
+
case "end":
|
|
1193
|
+
return _context17.stop();
|
|
1194
|
+
}
|
|
1195
|
+
}, _callee17, null, [[10, 15], [23, 30]]);
|
|
1196
|
+
}));
|
|
1197
|
+
return function (_x17) {
|
|
1198
|
+
return _ref43.apply(this, arguments);
|
|
1199
|
+
};
|
|
1200
|
+
}());
|
|
1201
|
+
_defineProperty(this, "handleOrderSalesDetail", /*#__PURE__*/function () {
|
|
1202
|
+
var _ref45 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref44) {
|
|
1203
|
+
var _this$app3;
|
|
1204
|
+
var url, data, path, requestPath, lookup, localOrder, backendPath, _response$data3, response, fresh, savedOrder, errorMessage;
|
|
1205
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1206
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1207
|
+
case 0:
|
|
1208
|
+
url = _ref44.url, data = _ref44.data, path = _ref44.path;
|
|
1091
1209
|
requestPath = _this.parseRequestPath(url, path);
|
|
1092
1210
|
lookup = _this.extractOrderSalesDetailLookup(requestPath);
|
|
1093
1211
|
_this.logInfo('handleOrderSalesDetail: 开始处理', {
|
|
@@ -1096,14 +1214,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1096
1214
|
lookup: lookup
|
|
1097
1215
|
});
|
|
1098
1216
|
if (lookup) {
|
|
1099
|
-
|
|
1217
|
+
_context18.next = 7;
|
|
1100
1218
|
break;
|
|
1101
1219
|
}
|
|
1102
1220
|
_this.logWarning('handleOrderSalesDetail: lookup 缺失', {
|
|
1103
1221
|
url: url,
|
|
1104
1222
|
path: requestPath
|
|
1105
1223
|
});
|
|
1106
|
-
return
|
|
1224
|
+
return _context18.abrupt("return", {
|
|
1107
1225
|
code: 400,
|
|
1108
1226
|
status: false,
|
|
1109
1227
|
message: '订单 lookup 缺失',
|
|
@@ -1111,11 +1229,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
1111
1229
|
});
|
|
1112
1230
|
case 7:
|
|
1113
1231
|
if (_this.order) {
|
|
1114
|
-
|
|
1232
|
+
_context18.next = 10;
|
|
1115
1233
|
break;
|
|
1116
1234
|
}
|
|
1117
1235
|
_this.logError('handleOrderSalesDetail: Order 模块未注册');
|
|
1118
|
-
return
|
|
1236
|
+
return _context18.abrupt("return", {
|
|
1119
1237
|
code: 500,
|
|
1120
1238
|
status: false,
|
|
1121
1239
|
message: 'Order 模块未注册',
|
|
@@ -1123,33 +1241,33 @@ var Server = /*#__PURE__*/function () {
|
|
|
1123
1241
|
});
|
|
1124
1242
|
case 10:
|
|
1125
1243
|
if (_this.shouldForceRemoteSalesDetail(data)) {
|
|
1126
|
-
|
|
1244
|
+
_context18.next = 17;
|
|
1127
1245
|
break;
|
|
1128
1246
|
}
|
|
1129
|
-
|
|
1247
|
+
_context18.next = 13;
|
|
1130
1248
|
return _this.order.getLocalOrderByLookup(lookup);
|
|
1131
1249
|
case 13:
|
|
1132
|
-
localOrder =
|
|
1250
|
+
localOrder = _context18.sent;
|
|
1133
1251
|
if (!localOrder) {
|
|
1134
|
-
|
|
1252
|
+
_context18.next = 17;
|
|
1135
1253
|
break;
|
|
1136
1254
|
}
|
|
1137
1255
|
_this.logInfo('handleOrderSalesDetail: 命中本地订单', {
|
|
1138
1256
|
lookup: lookup
|
|
1139
1257
|
});
|
|
1140
|
-
return
|
|
1258
|
+
return _context18.abrupt("return", {
|
|
1141
1259
|
code: 200,
|
|
1142
1260
|
status: true,
|
|
1143
1261
|
message: '',
|
|
1144
1262
|
data: localOrder
|
|
1145
1263
|
});
|
|
1146
1264
|
case 17:
|
|
1147
|
-
if ((_this$
|
|
1148
|
-
|
|
1265
|
+
if ((_this$app3 = _this.app) !== null && _this$app3 !== void 0 && _this$app3.request) {
|
|
1266
|
+
_context18.next = 20;
|
|
1149
1267
|
break;
|
|
1150
1268
|
}
|
|
1151
1269
|
_this.logError('handleOrderSalesDetail: app.request 不可用');
|
|
1152
|
-
return
|
|
1270
|
+
return _context18.abrupt("return", {
|
|
1153
1271
|
code: 500,
|
|
1154
1272
|
status: false,
|
|
1155
1273
|
message: 'app.request 不可用',
|
|
@@ -1157,8 +1275,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
1157
1275
|
});
|
|
1158
1276
|
case 20:
|
|
1159
1277
|
backendPath = _this.buildOrderSalesDetailBackendPath(lookup, data);
|
|
1160
|
-
|
|
1161
|
-
|
|
1278
|
+
_context18.prev = 21;
|
|
1279
|
+
_context18.next = 24;
|
|
1162
1280
|
return _this.app.request.get(backendPath, {
|
|
1163
1281
|
lookup_mode: 'multi'
|
|
1164
1282
|
}, {
|
|
@@ -1166,38 +1284,38 @@ var Server = /*#__PURE__*/function () {
|
|
|
1166
1284
|
customToast: function customToast() {}
|
|
1167
1285
|
});
|
|
1168
1286
|
case 24:
|
|
1169
|
-
response =
|
|
1170
|
-
fresh = (_response$
|
|
1287
|
+
response = _context18.sent;
|
|
1288
|
+
fresh = (_response$data3 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data3 !== void 0 ? _response$data3 : response;
|
|
1171
1289
|
if (!(!fresh || _typeof(fresh) !== 'object' || fresh.order_id == null)) {
|
|
1172
|
-
|
|
1290
|
+
_context18.next = 29;
|
|
1173
1291
|
break;
|
|
1174
1292
|
}
|
|
1175
1293
|
_this.logInfo('handleOrderSalesDetail: 后端返回订单为空', {
|
|
1176
1294
|
lookup: lookup,
|
|
1177
1295
|
backendPath: backendPath
|
|
1178
1296
|
});
|
|
1179
|
-
return
|
|
1297
|
+
return _context18.abrupt("return", {
|
|
1180
1298
|
code: 500,
|
|
1181
1299
|
status: false,
|
|
1182
1300
|
message: '后端返回订单为空',
|
|
1183
1301
|
data: null
|
|
1184
1302
|
});
|
|
1185
1303
|
case 29:
|
|
1186
|
-
|
|
1304
|
+
_context18.next = 31;
|
|
1187
1305
|
return _this.order.upsertOrdersFromRemote([fresh]);
|
|
1188
1306
|
case 31:
|
|
1189
|
-
|
|
1307
|
+
_context18.next = 33;
|
|
1190
1308
|
return _this.order.getLocalOrderByLookup(lookup);
|
|
1191
1309
|
case 33:
|
|
1192
|
-
savedOrder =
|
|
1310
|
+
savedOrder = _context18.sent;
|
|
1193
1311
|
if (savedOrder) {
|
|
1194
|
-
|
|
1312
|
+
_context18.next = 37;
|
|
1195
1313
|
break;
|
|
1196
1314
|
}
|
|
1197
1315
|
_this.logError('handleOrderSalesDetail: 订单写入后回读失败', {
|
|
1198
1316
|
lookup: lookup
|
|
1199
1317
|
});
|
|
1200
|
-
return
|
|
1318
|
+
return _context18.abrupt("return", {
|
|
1201
1319
|
code: 500,
|
|
1202
1320
|
status: false,
|
|
1203
1321
|
message: '订单写入后回读失败',
|
|
@@ -1207,22 +1325,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
1207
1325
|
_this.logInfo('handleOrderSalesDetail: 远端订单已同步到本地', {
|
|
1208
1326
|
lookup: lookup
|
|
1209
1327
|
});
|
|
1210
|
-
return
|
|
1328
|
+
return _context18.abrupt("return", {
|
|
1211
1329
|
code: 200,
|
|
1212
1330
|
status: true,
|
|
1213
1331
|
message: '',
|
|
1214
1332
|
data: savedOrder
|
|
1215
1333
|
});
|
|
1216
1334
|
case 41:
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
errorMessage =
|
|
1220
|
-
_this.
|
|
1335
|
+
_context18.prev = 41;
|
|
1336
|
+
_context18.t0 = _context18["catch"](21);
|
|
1337
|
+
errorMessage = _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0);
|
|
1338
|
+
_this.logInfo('handleOrderSalesDetail: 请求失败', {
|
|
1221
1339
|
lookup: lookup,
|
|
1222
1340
|
backendPath: backendPath,
|
|
1223
1341
|
error: errorMessage
|
|
1224
1342
|
});
|
|
1225
|
-
return
|
|
1343
|
+
return _context18.abrupt("return", {
|
|
1226
1344
|
code: 500,
|
|
1227
1345
|
status: false,
|
|
1228
1346
|
message: errorMessage,
|
|
@@ -1230,28 +1348,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
1230
1348
|
});
|
|
1231
1349
|
case 46:
|
|
1232
1350
|
case "end":
|
|
1233
|
-
return
|
|
1351
|
+
return _context18.stop();
|
|
1234
1352
|
}
|
|
1235
|
-
},
|
|
1353
|
+
}, _callee18, null, [[21, 41]]);
|
|
1236
1354
|
}));
|
|
1237
|
-
return function (
|
|
1238
|
-
return
|
|
1355
|
+
return function (_x18) {
|
|
1356
|
+
return _ref45.apply(this, arguments);
|
|
1239
1357
|
};
|
|
1240
1358
|
}());
|
|
1241
1359
|
/**
|
|
1242
1360
|
* GET /shop/schedule/floor-plan* 前缀路由:读本地 store;支持 subscriberId + callback 订阅更新
|
|
1243
1361
|
*/
|
|
1244
1362
|
_defineProperty(this, "handleFloorPlanGet", /*#__PURE__*/function () {
|
|
1245
|
-
var
|
|
1246
|
-
var url, data, config, routePath, base, path, _subscriberId,
|
|
1247
|
-
return _regeneratorRuntime().wrap(function
|
|
1248
|
-
while (1) switch (
|
|
1363
|
+
var _ref47 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(_ref46) {
|
|
1364
|
+
var url, data, config, routePath, base, path, _subscriberId, _ref48, callback, subscriberId, ctx;
|
|
1365
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1366
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1249
1367
|
case 0:
|
|
1250
|
-
url =
|
|
1368
|
+
url = _ref46.url, data = _ref46.data, config = _ref46.config, routePath = _ref46.path;
|
|
1251
1369
|
base = '/shop/schedule/floor-plan';
|
|
1252
1370
|
path = _this.parseRequestPath(url, routePath);
|
|
1253
1371
|
if (!(path === "".concat(base, "/unsubscribe") || path === "".concat(base, "/code/unsubscribe"))) {
|
|
1254
|
-
|
|
1372
|
+
_context19.next = 7;
|
|
1255
1373
|
break;
|
|
1256
1374
|
}
|
|
1257
1375
|
_subscriberId = data === null || data === void 0 ? void 0 : data.subscriberId;
|
|
@@ -1262,19 +1380,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
1262
1380
|
remaining: _this.floorPlanQuerySubscribers.size
|
|
1263
1381
|
});
|
|
1264
1382
|
}
|
|
1265
|
-
return
|
|
1383
|
+
return _context19.abrupt("return", {
|
|
1266
1384
|
code: 200,
|
|
1267
1385
|
message: 'ok',
|
|
1268
1386
|
status: true
|
|
1269
1387
|
});
|
|
1270
1388
|
case 7:
|
|
1271
|
-
|
|
1389
|
+
_ref48 = config || {}, callback = _ref48.callback, subscriberId = _ref48.subscriberId;
|
|
1272
1390
|
ctx = _this.resolveFloorPlanQueryContext(path, base);
|
|
1273
1391
|
if (ctx) {
|
|
1274
|
-
|
|
1392
|
+
_context19.next = 11;
|
|
1275
1393
|
break;
|
|
1276
1394
|
}
|
|
1277
|
-
return
|
|
1395
|
+
return _context19.abrupt("return", {
|
|
1278
1396
|
status: false,
|
|
1279
1397
|
code: 404,
|
|
1280
1398
|
message: 'Not Found',
|
|
@@ -1292,28 +1410,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
1292
1410
|
total: _this.floorPlanQuerySubscribers.size
|
|
1293
1411
|
});
|
|
1294
1412
|
}
|
|
1295
|
-
return
|
|
1413
|
+
return _context19.abrupt("return", _this.computeFloorPlanQueryResult(ctx));
|
|
1296
1414
|
case 13:
|
|
1297
1415
|
case "end":
|
|
1298
|
-
return
|
|
1416
|
+
return _context19.stop();
|
|
1299
1417
|
}
|
|
1300
|
-
},
|
|
1418
|
+
}, _callee19);
|
|
1301
1419
|
}));
|
|
1302
|
-
return function (
|
|
1303
|
-
return
|
|
1420
|
+
return function (_x19) {
|
|
1421
|
+
return _ref47.apply(this, arguments);
|
|
1304
1422
|
};
|
|
1305
1423
|
}());
|
|
1306
1424
|
/**
|
|
1307
1425
|
* 取消预约列表查询订阅(HTTP 路由入口)
|
|
1308
1426
|
*/
|
|
1309
1427
|
_defineProperty(this, "handleUnsubscribeBookingQuery", /*#__PURE__*/function () {
|
|
1310
|
-
var
|
|
1311
|
-
var data,
|
|
1312
|
-
return _regeneratorRuntime().wrap(function
|
|
1313
|
-
while (1) switch (
|
|
1428
|
+
var _ref50 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(_ref49) {
|
|
1429
|
+
var data, _ref51, subscriberId;
|
|
1430
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1431
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1314
1432
|
case 0:
|
|
1315
|
-
data =
|
|
1316
|
-
|
|
1433
|
+
data = _ref49.data;
|
|
1434
|
+
_ref51 = data || {}, subscriberId = _ref51.subscriberId;
|
|
1317
1435
|
if (subscriberId) {
|
|
1318
1436
|
_this.bookingQuerySubscribers.delete(subscriberId);
|
|
1319
1437
|
_this.bookingRemoteQuerySubscribers.delete(subscriberId);
|
|
@@ -1323,19 +1441,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
1323
1441
|
remainingRemote: _this.bookingRemoteQuerySubscribers.size
|
|
1324
1442
|
});
|
|
1325
1443
|
}
|
|
1326
|
-
return
|
|
1444
|
+
return _context20.abrupt("return", {
|
|
1327
1445
|
code: 200,
|
|
1328
1446
|
message: 'ok',
|
|
1329
1447
|
status: true
|
|
1330
1448
|
});
|
|
1331
1449
|
case 4:
|
|
1332
1450
|
case "end":
|
|
1333
|
-
return
|
|
1451
|
+
return _context20.stop();
|
|
1334
1452
|
}
|
|
1335
|
-
},
|
|
1453
|
+
}, _callee20);
|
|
1336
1454
|
}));
|
|
1337
|
-
return function (
|
|
1338
|
-
return
|
|
1455
|
+
return function (_x20) {
|
|
1456
|
+
return _ref50.apply(this, arguments);
|
|
1339
1457
|
};
|
|
1340
1458
|
}());
|
|
1341
1459
|
/**
|
|
@@ -1343,13 +1461,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
1343
1461
|
* 通过餐牌ID列表获取所有相关日程的时间段点
|
|
1344
1462
|
*/
|
|
1345
1463
|
_defineProperty(this, "handleGetScheduleTimePoints", /*#__PURE__*/function () {
|
|
1346
|
-
var
|
|
1464
|
+
var _ref53 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(_ref52) {
|
|
1347
1465
|
var _menu_list_ids$length;
|
|
1348
1466
|
var url, method, data, config, menu_list_ids, _menu_list_ids$length2, menuList, scheduleIds, scheduleList, timePoints, errorMessage;
|
|
1349
|
-
return _regeneratorRuntime().wrap(function
|
|
1350
|
-
while (1) switch (
|
|
1467
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1468
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1351
1469
|
case 0:
|
|
1352
|
-
url =
|
|
1470
|
+
url = _ref52.url, method = _ref52.method, data = _ref52.data, config = _ref52.config;
|
|
1353
1471
|
console.log('[Server] handleGetScheduleTimePoints:', url, method, data, config);
|
|
1354
1472
|
menu_list_ids = data.menu_list_ids;
|
|
1355
1473
|
_this.logInfo('handleGetScheduleTimePoints 开始处理', {
|
|
@@ -1359,12 +1477,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
1359
1477
|
|
|
1360
1478
|
// 检查必要的模块是否已注册
|
|
1361
1479
|
if (_this.menu) {
|
|
1362
|
-
|
|
1480
|
+
_context21.next = 8;
|
|
1363
1481
|
break;
|
|
1364
1482
|
}
|
|
1365
1483
|
console.error('[Server] Menu 模块未注册');
|
|
1366
1484
|
_this.logError('handleGetScheduleTimePoints: Menu 模块未注册');
|
|
1367
|
-
return
|
|
1485
|
+
return _context21.abrupt("return", {
|
|
1368
1486
|
code: 500,
|
|
1369
1487
|
message: 'Menu 模块未注册',
|
|
1370
1488
|
data: [],
|
|
@@ -1372,12 +1490,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
1372
1490
|
});
|
|
1373
1491
|
case 8:
|
|
1374
1492
|
if (_this.schedule) {
|
|
1375
|
-
|
|
1493
|
+
_context21.next = 12;
|
|
1376
1494
|
break;
|
|
1377
1495
|
}
|
|
1378
1496
|
console.error('[Server] Schedule 模块未注册');
|
|
1379
1497
|
_this.logError('handleGetScheduleTimePoints: Schedule 模块未注册');
|
|
1380
|
-
return
|
|
1498
|
+
return _context21.abrupt("return", {
|
|
1381
1499
|
code: 500,
|
|
1382
1500
|
message: 'Schedule 模块未注册',
|
|
1383
1501
|
data: [],
|
|
@@ -1385,7 +1503,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1385
1503
|
});
|
|
1386
1504
|
case 12:
|
|
1387
1505
|
if (!(!menu_list_ids || !Array.isArray(menu_list_ids) || menu_list_ids.length === 0)) {
|
|
1388
|
-
|
|
1506
|
+
_context21.next = 16;
|
|
1389
1507
|
break;
|
|
1390
1508
|
}
|
|
1391
1509
|
console.error('[Server] menu_list_ids 参数无效');
|
|
@@ -1393,14 +1511,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1393
1511
|
menuListIdsCount: (_menu_list_ids$length2 = menu_list_ids === null || menu_list_ids === void 0 ? void 0 : menu_list_ids.length) !== null && _menu_list_ids$length2 !== void 0 ? _menu_list_ids$length2 : 0,
|
|
1394
1512
|
menu_list_ids: menu_list_ids
|
|
1395
1513
|
});
|
|
1396
|
-
return
|
|
1514
|
+
return _context21.abrupt("return", {
|
|
1397
1515
|
code: 400,
|
|
1398
1516
|
message: 'menu_list_ids 参数无效',
|
|
1399
1517
|
data: [],
|
|
1400
1518
|
status: false
|
|
1401
1519
|
});
|
|
1402
1520
|
case 16:
|
|
1403
|
-
|
|
1521
|
+
_context21.prev = 16;
|
|
1404
1522
|
// 1. 获取餐牌列表
|
|
1405
1523
|
menuList = _this.menu.getMenuByIds(menu_list_ids);
|
|
1406
1524
|
console.log("[Server] \u627E\u5230 ".concat(menuList.length, " \u4E2A\u9910\u724C"));
|
|
@@ -1418,13 +1536,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
1418
1536
|
scheduleCount: scheduleIds.length
|
|
1419
1537
|
});
|
|
1420
1538
|
if (!(scheduleIds.length === 0)) {
|
|
1421
|
-
|
|
1539
|
+
_context21.next = 26;
|
|
1422
1540
|
break;
|
|
1423
1541
|
}
|
|
1424
1542
|
_this.logInfo('handleGetScheduleTimePoints: 没有找到相关日程', {
|
|
1425
1543
|
menuListIdsCount: menu_list_ids.length
|
|
1426
1544
|
});
|
|
1427
|
-
return
|
|
1545
|
+
return _context21.abrupt("return", {
|
|
1428
1546
|
code: 200,
|
|
1429
1547
|
message: '没有找到相关日程',
|
|
1430
1548
|
data: [],
|
|
@@ -1448,22 +1566,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
1448
1566
|
scheduleCount: scheduleList.length,
|
|
1449
1567
|
timePointCount: timePoints.length
|
|
1450
1568
|
});
|
|
1451
|
-
return
|
|
1569
|
+
return _context21.abrupt("return", {
|
|
1452
1570
|
code: 200,
|
|
1453
1571
|
message: '获取成功',
|
|
1454
1572
|
data: timePoints,
|
|
1455
1573
|
status: true
|
|
1456
1574
|
});
|
|
1457
1575
|
case 35:
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
errorMessage =
|
|
1461
|
-
console.error('[Server] 获取日程时间点失败:',
|
|
1576
|
+
_context21.prev = 35;
|
|
1577
|
+
_context21.t0 = _context21["catch"](16);
|
|
1578
|
+
errorMessage = _context21.t0 instanceof Error ? _context21.t0.message : '未知错误';
|
|
1579
|
+
console.error('[Server] 获取日程时间点失败:', _context21.t0);
|
|
1462
1580
|
_this.logError('handleGetScheduleTimePoints: 获取日程时间点失败', {
|
|
1463
1581
|
menuListIdsCount: menu_list_ids.length,
|
|
1464
1582
|
error: errorMessage
|
|
1465
1583
|
});
|
|
1466
|
-
return
|
|
1584
|
+
return _context21.abrupt("return", {
|
|
1467
1585
|
code: 500,
|
|
1468
1586
|
message: "\u83B7\u53D6\u5931\u8D25: ".concat(errorMessage),
|
|
1469
1587
|
data: [],
|
|
@@ -1471,18 +1589,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
1471
1589
|
});
|
|
1472
1590
|
case 41:
|
|
1473
1591
|
case "end":
|
|
1474
|
-
return
|
|
1592
|
+
return _context21.stop();
|
|
1475
1593
|
}
|
|
1476
|
-
},
|
|
1594
|
+
}, _callee21, null, [[16, 35]]);
|
|
1477
1595
|
}));
|
|
1478
|
-
return function (
|
|
1479
|
-
return
|
|
1596
|
+
return function (_x21) {
|
|
1597
|
+
return _ref53.apply(this, arguments);
|
|
1480
1598
|
};
|
|
1481
1599
|
}());
|
|
1482
1600
|
this.core = core;
|
|
1483
1601
|
var appPlugin = core.getPlugin('app');
|
|
1484
1602
|
this.app = (appPlugin === null || appPlugin === void 0 ? void 0 : appPlugin.getApp()) || null;
|
|
1485
|
-
this.logger = ((_this$
|
|
1603
|
+
this.logger = ((_this$app4 = this.app) === null || _this$app4 === void 0 ? void 0 : _this$app4.logger) || null;
|
|
1486
1604
|
console.log('[Server] Server 初始化', this.core);
|
|
1487
1605
|
this.logInfo('Server 初始化', {
|
|
1488
1606
|
hasApp: !!this.app,
|
|
@@ -1597,10 +1715,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
1597
1715
|
}, {
|
|
1598
1716
|
key: "registerModuleWithRoutes",
|
|
1599
1717
|
value: (function () {
|
|
1600
|
-
var _registerModuleWithRoutes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1718
|
+
var _registerModuleWithRoutes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(module, options, moduleName) {
|
|
1601
1719
|
var routes;
|
|
1602
|
-
return _regeneratorRuntime().wrap(function
|
|
1603
|
-
while (1) switch (
|
|
1720
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1721
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1604
1722
|
case 0:
|
|
1605
1723
|
this.logInfo("\u5F00\u59CB\u6CE8\u518C\u6A21\u5757: ".concat(moduleName), {
|
|
1606
1724
|
moduleName: moduleName,
|
|
@@ -1608,7 +1726,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1608
1726
|
});
|
|
1609
1727
|
|
|
1610
1728
|
// 注册模块到 Core
|
|
1611
|
-
|
|
1729
|
+
_context22.next = 3;
|
|
1612
1730
|
return this.core.registerModule(module, options);
|
|
1613
1731
|
case 3:
|
|
1614
1732
|
console.log("[Server] \u2705 ".concat(moduleName, " \u6A21\u5757\u5DF2\u6CE8\u518C"));
|
|
@@ -1629,11 +1747,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
1629
1747
|
}
|
|
1630
1748
|
case 6:
|
|
1631
1749
|
case "end":
|
|
1632
|
-
return
|
|
1750
|
+
return _context22.stop();
|
|
1633
1751
|
}
|
|
1634
|
-
},
|
|
1752
|
+
}, _callee22, this);
|
|
1635
1753
|
}));
|
|
1636
|
-
function registerModuleWithRoutes(
|
|
1754
|
+
function registerModuleWithRoutes(_x22, _x23, _x24) {
|
|
1637
1755
|
return _registerModuleWithRoutes.apply(this, arguments);
|
|
1638
1756
|
}
|
|
1639
1757
|
return registerModuleWithRoutes;
|
|
@@ -1646,10 +1764,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
1646
1764
|
}, {
|
|
1647
1765
|
key: "registerModuleByName",
|
|
1648
1766
|
value: (function () {
|
|
1649
|
-
var _registerModuleByName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1767
|
+
var _registerModuleByName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(moduleConfig) {
|
|
1650
1768
|
var moduleName, shouldPreload, customConfig, registryConfig, ModuleClass, moduleInstance, moduleOptions;
|
|
1651
|
-
return _regeneratorRuntime().wrap(function
|
|
1652
|
-
while (1) switch (
|
|
1769
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1770
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1653
1771
|
case 0:
|
|
1654
1772
|
// 解析配置
|
|
1655
1773
|
moduleName = typeof moduleConfig === 'string' ? moduleConfig : moduleConfig.name;
|
|
@@ -1664,7 +1782,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1664
1782
|
// 查找模块配置
|
|
1665
1783
|
registryConfig = this.moduleRegistry[moduleName];
|
|
1666
1784
|
if (registryConfig) {
|
|
1667
|
-
|
|
1785
|
+
_context23.next = 8;
|
|
1668
1786
|
break;
|
|
1669
1787
|
}
|
|
1670
1788
|
this.logError("\u672A\u627E\u5230\u6A21\u5757\u914D\u7F6E: ".concat(moduleName), {
|
|
@@ -1678,7 +1796,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1678
1796
|
moduleOptions = _objectSpread({
|
|
1679
1797
|
store: _objectSpread({}, registryConfig.defaultStore)
|
|
1680
1798
|
}, customConfig); // 注册模块和路由
|
|
1681
|
-
|
|
1799
|
+
_context23.next = 13;
|
|
1682
1800
|
return this.registerModuleWithRoutes(moduleInstance, moduleOptions, moduleName.charAt(0).toUpperCase() + moduleName.slice(1));
|
|
1683
1801
|
case 13:
|
|
1684
1802
|
// 保存模块实例
|
|
@@ -1688,18 +1806,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
1688
1806
|
shouldPreload: shouldPreload,
|
|
1689
1807
|
version: registryConfig.version
|
|
1690
1808
|
});
|
|
1691
|
-
return
|
|
1809
|
+
return _context23.abrupt("return", {
|
|
1692
1810
|
module: moduleInstance,
|
|
1693
1811
|
config: registryConfig,
|
|
1694
1812
|
shouldPreload: shouldPreload
|
|
1695
1813
|
});
|
|
1696
1814
|
case 16:
|
|
1697
1815
|
case "end":
|
|
1698
|
-
return
|
|
1816
|
+
return _context23.stop();
|
|
1699
1817
|
}
|
|
1700
|
-
},
|
|
1818
|
+
}, _callee23, this);
|
|
1701
1819
|
}));
|
|
1702
|
-
function registerModuleByName(
|
|
1820
|
+
function registerModuleByName(_x25) {
|
|
1703
1821
|
return _registerModuleByName.apply(this, arguments);
|
|
1704
1822
|
}
|
|
1705
1823
|
return registerModuleByName;
|
|
@@ -1712,10 +1830,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
1712
1830
|
}, {
|
|
1713
1831
|
key: "registerModules",
|
|
1714
1832
|
value: (function () {
|
|
1715
|
-
var _registerModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1833
|
+
var _registerModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(moduleConfigs) {
|
|
1716
1834
|
var configs, registeredModules, _iterator2, _step2, config, configName, result, errorMessage;
|
|
1717
|
-
return _regeneratorRuntime().wrap(function
|
|
1718
|
-
while (1) switch (
|
|
1835
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1836
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1719
1837
|
case 0:
|
|
1720
1838
|
console.log('[Server] 开始注册模块...');
|
|
1721
1839
|
|
|
@@ -1727,47 +1845,47 @@ var Server = /*#__PURE__*/function () {
|
|
|
1727
1845
|
});
|
|
1728
1846
|
registeredModules = [];
|
|
1729
1847
|
_iterator2 = _createForOfIteratorHelper(configs);
|
|
1730
|
-
|
|
1848
|
+
_context24.prev = 5;
|
|
1731
1849
|
_iterator2.s();
|
|
1732
1850
|
case 7:
|
|
1733
1851
|
if ((_step2 = _iterator2.n()).done) {
|
|
1734
|
-
|
|
1852
|
+
_context24.next = 25;
|
|
1735
1853
|
break;
|
|
1736
1854
|
}
|
|
1737
1855
|
config = _step2.value;
|
|
1738
1856
|
configName = typeof config === 'string' ? config : config.name;
|
|
1739
|
-
|
|
1740
|
-
|
|
1857
|
+
_context24.prev = 10;
|
|
1858
|
+
_context24.next = 13;
|
|
1741
1859
|
return this.registerModuleByName(config);
|
|
1742
1860
|
case 13:
|
|
1743
|
-
result =
|
|
1861
|
+
result = _context24.sent;
|
|
1744
1862
|
registeredModules.push(result);
|
|
1745
|
-
|
|
1863
|
+
_context24.next = 23;
|
|
1746
1864
|
break;
|
|
1747
1865
|
case 17:
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
errorMessage =
|
|
1866
|
+
_context24.prev = 17;
|
|
1867
|
+
_context24.t0 = _context24["catch"](10);
|
|
1868
|
+
errorMessage = _context24.t0 instanceof Error ? _context24.t0.message : String(_context24.t0);
|
|
1751
1869
|
this.logError("\u6A21\u5757\u6CE8\u518C\u5931\u8D25: ".concat(configName), {
|
|
1752
1870
|
moduleName: configName,
|
|
1753
1871
|
error: errorMessage
|
|
1754
1872
|
});
|
|
1755
|
-
console.error("[Server] \u6A21\u5757\u6CE8\u518C\u5931\u8D25:",
|
|
1756
|
-
throw
|
|
1873
|
+
console.error("[Server] \u6A21\u5757\u6CE8\u518C\u5931\u8D25:", _context24.t0);
|
|
1874
|
+
throw _context24.t0;
|
|
1757
1875
|
case 23:
|
|
1758
|
-
|
|
1876
|
+
_context24.next = 7;
|
|
1759
1877
|
break;
|
|
1760
1878
|
case 25:
|
|
1761
|
-
|
|
1879
|
+
_context24.next = 30;
|
|
1762
1880
|
break;
|
|
1763
1881
|
case 27:
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
_iterator2.e(
|
|
1882
|
+
_context24.prev = 27;
|
|
1883
|
+
_context24.t1 = _context24["catch"](5);
|
|
1884
|
+
_iterator2.e(_context24.t1);
|
|
1767
1885
|
case 30:
|
|
1768
|
-
|
|
1886
|
+
_context24.prev = 30;
|
|
1769
1887
|
_iterator2.f();
|
|
1770
|
-
return
|
|
1888
|
+
return _context24.finish(30);
|
|
1771
1889
|
case 33:
|
|
1772
1890
|
console.log('[Server] ✅ 所有模块注册完成');
|
|
1773
1891
|
this.logInfo('所有模块注册完成', {
|
|
@@ -1777,14 +1895,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1777
1895
|
return m === null || m === void 0 || (_m$config = m.config) === null || _m$config === void 0 ? void 0 : _m$config.name;
|
|
1778
1896
|
})
|
|
1779
1897
|
});
|
|
1780
|
-
return
|
|
1898
|
+
return _context24.abrupt("return", registeredModules);
|
|
1781
1899
|
case 36:
|
|
1782
1900
|
case "end":
|
|
1783
|
-
return
|
|
1901
|
+
return _context24.stop();
|
|
1784
1902
|
}
|
|
1785
|
-
},
|
|
1903
|
+
}, _callee24, this, [[5, 27, 30, 33], [10, 17]]);
|
|
1786
1904
|
}));
|
|
1787
|
-
function registerModules(
|
|
1905
|
+
function registerModules(_x26) {
|
|
1788
1906
|
return _registerModules.apply(this, arguments);
|
|
1789
1907
|
}
|
|
1790
1908
|
return registerModules;
|
|
@@ -1797,10 +1915,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
1797
1915
|
}, {
|
|
1798
1916
|
key: "preloadModulesData",
|
|
1799
1917
|
value: (function () {
|
|
1800
|
-
var _preloadModulesData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1918
|
+
var _preloadModulesData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(registeredModules, options) {
|
|
1801
1919
|
var modulesToPreload, preloadResults, _iterator3, _step3, _step3$value, module, config, shouldPreload, startTime, _options$onModuleLoad, _options$onModuleLoad2, duration, _duration, errorMessage, successCount, failCount;
|
|
1802
|
-
return _regeneratorRuntime().wrap(function
|
|
1803
|
-
while (1) switch (
|
|
1920
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1921
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1804
1922
|
case 0:
|
|
1805
1923
|
console.log('[Server] 开始预加载模块数据...');
|
|
1806
1924
|
modulesToPreload = registeredModules.filter(function (m) {
|
|
@@ -1813,16 +1931,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
1813
1931
|
});
|
|
1814
1932
|
preloadResults = [];
|
|
1815
1933
|
_iterator3 = _createForOfIteratorHelper(registeredModules);
|
|
1816
|
-
|
|
1934
|
+
_context25.prev = 5;
|
|
1817
1935
|
_iterator3.s();
|
|
1818
1936
|
case 7:
|
|
1819
1937
|
if ((_step3 = _iterator3.n()).done) {
|
|
1820
|
-
|
|
1938
|
+
_context25.next = 40;
|
|
1821
1939
|
break;
|
|
1822
1940
|
}
|
|
1823
1941
|
_step3$value = _step3.value, module = _step3$value.module, config = _step3$value.config, shouldPreload = _step3$value.shouldPreload;
|
|
1824
1942
|
if (shouldPreload) {
|
|
1825
|
-
|
|
1943
|
+
_context25.next = 13;
|
|
1826
1944
|
break;
|
|
1827
1945
|
}
|
|
1828
1946
|
console.log("[Server] \u23ED\uFE0F \u8DF3\u8FC7 ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D"));
|
|
@@ -1830,19 +1948,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
1830
1948
|
moduleName: config.name,
|
|
1831
1949
|
reason: 'shouldPreload=false'
|
|
1832
1950
|
});
|
|
1833
|
-
return
|
|
1951
|
+
return _context25.abrupt("continue", 38);
|
|
1834
1952
|
case 13:
|
|
1835
1953
|
if (!(typeof module.preload === 'function')) {
|
|
1836
|
-
|
|
1954
|
+
_context25.next = 36;
|
|
1837
1955
|
break;
|
|
1838
1956
|
}
|
|
1839
1957
|
startTime = Date.now();
|
|
1840
|
-
|
|
1958
|
+
_context25.prev = 15;
|
|
1841
1959
|
this.logInfo("\u5F00\u59CB\u9884\u52A0\u8F7D\u6A21\u5757: ".concat(config.name), {
|
|
1842
1960
|
moduleName: config.name
|
|
1843
1961
|
});
|
|
1844
1962
|
options === null || options === void 0 || (_options$onModuleLoad = options.onModuleLoad) === null || _options$onModuleLoad === void 0 || _options$onModuleLoad.call(options, config.name);
|
|
1845
|
-
|
|
1963
|
+
_context25.next = 20;
|
|
1846
1964
|
return module.preload();
|
|
1847
1965
|
case 20:
|
|
1848
1966
|
options === null || options === void 0 || (_options$onModuleLoad2 = options.onModuleLoadComplete) === null || _options$onModuleLoad2 === void 0 || _options$onModuleLoad2.call(options, config.name);
|
|
@@ -1856,14 +1974,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1856
1974
|
name: config.name,
|
|
1857
1975
|
success: true
|
|
1858
1976
|
});
|
|
1859
|
-
|
|
1977
|
+
_context25.next = 34;
|
|
1860
1978
|
break;
|
|
1861
1979
|
case 27:
|
|
1862
|
-
|
|
1863
|
-
|
|
1980
|
+
_context25.prev = 27;
|
|
1981
|
+
_context25.t0 = _context25["catch"](15);
|
|
1864
1982
|
_duration = Date.now() - startTime;
|
|
1865
|
-
errorMessage =
|
|
1866
|
-
console.error("[Server] \u274C ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25:"),
|
|
1983
|
+
errorMessage = _context25.t0 instanceof Error ? _context25.t0.message : String(_context25.t0);
|
|
1984
|
+
console.error("[Server] \u274C ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25:"), _context25.t0);
|
|
1867
1985
|
this.logError("\u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25: ".concat(config.name), {
|
|
1868
1986
|
moduleName: config.name,
|
|
1869
1987
|
duration: "".concat(_duration, "ms"),
|
|
@@ -1875,7 +1993,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1875
1993
|
error: errorMessage
|
|
1876
1994
|
});
|
|
1877
1995
|
case 34:
|
|
1878
|
-
|
|
1996
|
+
_context25.next = 38;
|
|
1879
1997
|
break;
|
|
1880
1998
|
case 36:
|
|
1881
1999
|
console.log("[Server] \u26A0\uFE0F ".concat(config.name, " \u6A21\u5757\u672A\u5B9E\u73B0 preload() \u65B9\u6CD5"));
|
|
@@ -1883,19 +2001,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
1883
2001
|
moduleName: config.name
|
|
1884
2002
|
});
|
|
1885
2003
|
case 38:
|
|
1886
|
-
|
|
2004
|
+
_context25.next = 7;
|
|
1887
2005
|
break;
|
|
1888
2006
|
case 40:
|
|
1889
|
-
|
|
2007
|
+
_context25.next = 45;
|
|
1890
2008
|
break;
|
|
1891
2009
|
case 42:
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
_iterator3.e(
|
|
2010
|
+
_context25.prev = 42;
|
|
2011
|
+
_context25.t1 = _context25["catch"](5);
|
|
2012
|
+
_iterator3.e(_context25.t1);
|
|
1895
2013
|
case 45:
|
|
1896
|
-
|
|
2014
|
+
_context25.prev = 45;
|
|
1897
2015
|
_iterator3.f();
|
|
1898
|
-
return
|
|
2016
|
+
return _context25.finish(45);
|
|
1899
2017
|
case 48:
|
|
1900
2018
|
successCount = preloadResults.filter(function (r) {
|
|
1901
2019
|
return r.success;
|
|
@@ -1910,11 +2028,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
1910
2028
|
});
|
|
1911
2029
|
case 52:
|
|
1912
2030
|
case "end":
|
|
1913
|
-
return
|
|
2031
|
+
return _context25.stop();
|
|
1914
2032
|
}
|
|
1915
|
-
},
|
|
2033
|
+
}, _callee25, this, [[5, 42, 45, 48], [15, 27]]);
|
|
1916
2034
|
}));
|
|
1917
|
-
function preloadModulesData(
|
|
2035
|
+
function preloadModulesData(_x27, _x28) {
|
|
1918
2036
|
return _preloadModulesData.apply(this, arguments);
|
|
1919
2037
|
}
|
|
1920
2038
|
return preloadModulesData;
|
|
@@ -1928,7 +2046,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1928
2046
|
}, {
|
|
1929
2047
|
key: "initialize",
|
|
1930
2048
|
value: (function () {
|
|
1931
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2049
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(moduleConfigs) {
|
|
1932
2050
|
var _moduleConfigs$length,
|
|
1933
2051
|
_this3 = this;
|
|
1934
2052
|
var autoPreload,
|
|
@@ -1936,12 +2054,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
1936
2054
|
startTime,
|
|
1937
2055
|
registeredModules,
|
|
1938
2056
|
duration,
|
|
1939
|
-
|
|
1940
|
-
return _regeneratorRuntime().wrap(function
|
|
1941
|
-
while (1) switch (
|
|
2057
|
+
_args26 = arguments;
|
|
2058
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2059
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1942
2060
|
case 0:
|
|
1943
|
-
autoPreload =
|
|
1944
|
-
options =
|
|
2061
|
+
autoPreload = _args26.length > 1 && _args26[1] !== undefined ? _args26[1] : true;
|
|
2062
|
+
options = _args26.length > 2 ? _args26[2] : undefined;
|
|
1945
2063
|
startTime = Date.now();
|
|
1946
2064
|
this.logInfo('Server 初始化开始', {
|
|
1947
2065
|
moduleConfigCount: (_moduleConfigs$length = moduleConfigs === null || moduleConfigs === void 0 ? void 0 : moduleConfigs.length) !== null && _moduleConfigs$length !== void 0 ? _moduleConfigs$length : 'all',
|
|
@@ -1954,25 +2072,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
1954
2072
|
this.registerDeviceTaskActions();
|
|
1955
2073
|
|
|
1956
2074
|
// 注册模块
|
|
1957
|
-
|
|
2075
|
+
_context26.next = 8;
|
|
1958
2076
|
return this.registerModules(moduleConfigs);
|
|
1959
2077
|
case 8:
|
|
1960
|
-
registeredModules =
|
|
2078
|
+
registeredModules = _context26.sent;
|
|
1961
2079
|
if (!autoPreload) {
|
|
1962
|
-
|
|
2080
|
+
_context26.next = 14;
|
|
1963
2081
|
break;
|
|
1964
2082
|
}
|
|
1965
|
-
|
|
2083
|
+
_context26.next = 12;
|
|
1966
2084
|
return this.preloadModulesData(registeredModules, options);
|
|
1967
2085
|
case 12:
|
|
1968
|
-
|
|
2086
|
+
_context26.next = 15;
|
|
1969
2087
|
break;
|
|
1970
2088
|
case 14:
|
|
1971
2089
|
this.logInfo('跳过自动预加载', {
|
|
1972
2090
|
autoPreload: autoPreload
|
|
1973
2091
|
});
|
|
1974
2092
|
case 15:
|
|
1975
|
-
|
|
2093
|
+
_context26.next = 17;
|
|
1976
2094
|
return this.setupProductsQuotationPriceBridge();
|
|
1977
2095
|
case 17:
|
|
1978
2096
|
// 监听 ProductsModule 同步完成事件,重新计算并推送查询结果
|
|
@@ -1999,14 +2117,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1999
2117
|
duration: "".concat(duration, "ms"),
|
|
2000
2118
|
registeredModuleCount: registeredModules.length
|
|
2001
2119
|
});
|
|
2002
|
-
return
|
|
2120
|
+
return _context26.abrupt("return", registeredModules);
|
|
2003
2121
|
case 23:
|
|
2004
2122
|
case "end":
|
|
2005
|
-
return
|
|
2123
|
+
return _context26.stop();
|
|
2006
2124
|
}
|
|
2007
|
-
},
|
|
2125
|
+
}, _callee26, this);
|
|
2008
2126
|
}));
|
|
2009
|
-
function initialize(
|
|
2127
|
+
function initialize(_x29) {
|
|
2010
2128
|
return _initialize.apply(this, arguments);
|
|
2011
2129
|
}
|
|
2012
2130
|
return initialize;
|
|
@@ -2048,31 +2166,31 @@ var Server = /*#__PURE__*/function () {
|
|
|
2048
2166
|
}, {
|
|
2049
2167
|
key: "handleSyncSalesTask",
|
|
2050
2168
|
value: function () {
|
|
2051
|
-
var _handleSyncSalesTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2052
|
-
var _ctx$task, _this$
|
|
2169
|
+
var _handleSyncSalesTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(ctx) {
|
|
2170
|
+
var _ctx$task, _this$app5;
|
|
2053
2171
|
var payload, backendPath, data, title, _ctx$task2, _syncResult$syncedOrd, syncResult, backendError, message, errorMessage;
|
|
2054
|
-
return _regeneratorRuntime().wrap(function
|
|
2055
|
-
while (1) switch (
|
|
2172
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2173
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2056
2174
|
case 0:
|
|
2057
2175
|
payload = ((_ctx$task = ctx.task) === null || _ctx$task === void 0 ? void 0 : _ctx$task.payload) || {};
|
|
2058
2176
|
backendPath = payload.backendPath;
|
|
2059
2177
|
data = payload.data;
|
|
2060
2178
|
title = payload.title || 'sync_sales';
|
|
2061
2179
|
if (!(!backendPath || !data)) {
|
|
2062
|
-
|
|
2180
|
+
_context27.next = 6;
|
|
2063
2181
|
break;
|
|
2064
2182
|
}
|
|
2065
|
-
return
|
|
2183
|
+
return _context27.abrupt("return", this.taskFail('INVALID_PAYLOAD', '缺少 backendPath 或 data'));
|
|
2066
2184
|
case 6:
|
|
2067
|
-
if ((_this$
|
|
2068
|
-
|
|
2185
|
+
if ((_this$app5 = this.app) !== null && _this$app5 !== void 0 && _this$app5.request) {
|
|
2186
|
+
_context27.next = 9;
|
|
2069
2187
|
break;
|
|
2070
2188
|
}
|
|
2071
2189
|
this.logError("".concat(title, ": sync_sales app.request \u4E0D\u53EF\u7528"));
|
|
2072
|
-
return
|
|
2190
|
+
return _context27.abrupt("return", this.taskTimeout('app.request 不可用'));
|
|
2073
2191
|
case 9:
|
|
2074
|
-
|
|
2075
|
-
|
|
2192
|
+
_context27.prev = 9;
|
|
2193
|
+
_context27.next = 12;
|
|
2076
2194
|
return this.runCheckoutSync({
|
|
2077
2195
|
backendPath: backendPath,
|
|
2078
2196
|
data: data,
|
|
@@ -2082,27 +2200,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
2082
2200
|
persistCheckoutDataWithResponse: false
|
|
2083
2201
|
});
|
|
2084
2202
|
case 12:
|
|
2085
|
-
syncResult =
|
|
2203
|
+
syncResult = _context27.sent;
|
|
2086
2204
|
if (!syncResult.rejected) {
|
|
2087
|
-
|
|
2205
|
+
_context27.next = 16;
|
|
2088
2206
|
break;
|
|
2089
2207
|
}
|
|
2090
2208
|
this.logError("".concat(title, ": sync_sales \u540E\u7AEF\u660E\u786E\u5931\u8D25"), {
|
|
2091
2209
|
backendPath: backendPath,
|
|
2092
2210
|
response: syncResult.errorResponse
|
|
2093
2211
|
});
|
|
2094
|
-
return
|
|
2212
|
+
return _context27.abrupt("return", this.taskFail('BACKEND_REJECTED', syncResult.message || '后端明确拒绝 checkout', syncResult.errorResponse));
|
|
2095
2213
|
case 16:
|
|
2096
|
-
return
|
|
2214
|
+
return _context27.abrupt("return", this.taskOk({
|
|
2097
2215
|
order: (_syncResult$syncedOrd = syncResult.syncedOrder) !== null && _syncResult$syncedOrd !== void 0 ? _syncResult$syncedOrd : null,
|
|
2098
2216
|
response: syncResult.normalizedResponse
|
|
2099
2217
|
}));
|
|
2100
2218
|
case 19:
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
backendError = this.extractBackendErrorResponse(
|
|
2219
|
+
_context27.prev = 19;
|
|
2220
|
+
_context27.t0 = _context27["catch"](9);
|
|
2221
|
+
backendError = this.extractBackendErrorResponse(_context27.t0);
|
|
2104
2222
|
if (!backendError) {
|
|
2105
|
-
|
|
2223
|
+
_context27.next = 26;
|
|
2106
2224
|
break;
|
|
2107
2225
|
}
|
|
2108
2226
|
message = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || '后端明确拒绝 checkout';
|
|
@@ -2110,22 +2228,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
2110
2228
|
backendPath: backendPath,
|
|
2111
2229
|
backendError: backendError
|
|
2112
2230
|
});
|
|
2113
|
-
return
|
|
2231
|
+
return _context27.abrupt("return", this.taskFail('BACKEND_REJECTED', message, backendError));
|
|
2114
2232
|
case 26:
|
|
2115
|
-
errorMessage = this.getUnknownErrorMessage(
|
|
2233
|
+
errorMessage = this.getUnknownErrorMessage(_context27.t0);
|
|
2116
2234
|
this.logError("".concat(title, ": sync_sales \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
|
|
2117
2235
|
backendPath: backendPath,
|
|
2118
2236
|
error: errorMessage,
|
|
2119
|
-
error_detail: this.normalizeUnknownError(
|
|
2237
|
+
error_detail: this.normalizeUnknownError(_context27.t0)
|
|
2120
2238
|
});
|
|
2121
|
-
return
|
|
2239
|
+
return _context27.abrupt("return", this.taskTimeout(errorMessage));
|
|
2122
2240
|
case 29:
|
|
2123
2241
|
case "end":
|
|
2124
|
-
return
|
|
2242
|
+
return _context27.stop();
|
|
2125
2243
|
}
|
|
2126
|
-
},
|
|
2244
|
+
}, _callee27, this, [[9, 19]]);
|
|
2127
2245
|
}));
|
|
2128
|
-
function handleSyncSalesTask(
|
|
2246
|
+
function handleSyncSalesTask(_x30) {
|
|
2129
2247
|
return _handleSyncSalesTask.apply(this, arguments);
|
|
2130
2248
|
}
|
|
2131
2249
|
return handleSyncSalesTask;
|
|
@@ -2133,40 +2251,40 @@ var Server = /*#__PURE__*/function () {
|
|
|
2133
2251
|
}, {
|
|
2134
2252
|
key: "runCheckoutSync",
|
|
2135
2253
|
value: function () {
|
|
2136
|
-
var _runCheckoutSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2137
|
-
var _this$
|
|
2254
|
+
var _runCheckoutSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
2255
|
+
var _this$app6;
|
|
2138
2256
|
var backendPath, title, normalizedData, checkoutData, remoteCheckoutData, response, fresh, externalSaleNumber, syncedOrder, printableSyncedOrder;
|
|
2139
|
-
return _regeneratorRuntime().wrap(function
|
|
2140
|
-
while (1) switch (
|
|
2257
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2258
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2141
2259
|
case 0:
|
|
2142
2260
|
backendPath = params.backendPath, title = params.title;
|
|
2143
|
-
|
|
2261
|
+
_context28.next = 3;
|
|
2144
2262
|
return this.normalizeCheckoutSubmitData(params.data, title);
|
|
2145
2263
|
case 3:
|
|
2146
|
-
normalizedData =
|
|
2147
|
-
|
|
2264
|
+
normalizedData = _context28.sent;
|
|
2265
|
+
_context28.next = 6;
|
|
2148
2266
|
return this.ensureCheckoutOrderNumbers(normalizedData, title);
|
|
2149
2267
|
case 6:
|
|
2150
|
-
checkoutData =
|
|
2268
|
+
checkoutData = _context28.sent;
|
|
2151
2269
|
remoteCheckoutData = this.omitCheckoutSyncMode(checkoutData);
|
|
2152
|
-
if ((_this$
|
|
2153
|
-
|
|
2270
|
+
if ((_this$app6 = this.app) !== null && _this$app6 !== void 0 && (_this$app6 = _this$app6.request) !== null && _this$app6 !== void 0 && _this$app6.post) {
|
|
2271
|
+
_context28.next = 10;
|
|
2154
2272
|
break;
|
|
2155
2273
|
}
|
|
2156
2274
|
throw new Error('app.request 不可用');
|
|
2157
2275
|
case 10:
|
|
2158
|
-
|
|
2276
|
+
_context28.next = 12;
|
|
2159
2277
|
return this.app.request.post(backendPath, remoteCheckoutData, {
|
|
2160
2278
|
isShopApi: true,
|
|
2161
2279
|
customToast: function customToast() {}
|
|
2162
2280
|
});
|
|
2163
2281
|
case 12:
|
|
2164
|
-
response =
|
|
2282
|
+
response = _context28.sent;
|
|
2165
2283
|
if (!this.isCheckoutResponseRejected(response)) {
|
|
2166
|
-
|
|
2284
|
+
_context28.next = 15;
|
|
2167
2285
|
break;
|
|
2168
2286
|
}
|
|
2169
|
-
return
|
|
2287
|
+
return _context28.abrupt("return", {
|
|
2170
2288
|
rejected: true,
|
|
2171
2289
|
message: (response === null || response === void 0 ? void 0 : response.message) || '后端明确拒绝 checkout',
|
|
2172
2290
|
errorResponse: response,
|
|
@@ -2180,7 +2298,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2180
2298
|
external_sale_number: params.externalSaleNumber,
|
|
2181
2299
|
data: remoteCheckoutData
|
|
2182
2300
|
});
|
|
2183
|
-
|
|
2301
|
+
_context28.next = 19;
|
|
2184
2302
|
return this.persistSyncedCheckoutOrder({
|
|
2185
2303
|
backendPath: backendPath,
|
|
2186
2304
|
checkoutData: remoteCheckoutData,
|
|
@@ -2190,7 +2308,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2190
2308
|
persistCheckoutDataWithResponse: params.persistCheckoutDataWithResponse === true
|
|
2191
2309
|
});
|
|
2192
2310
|
case 19:
|
|
2193
|
-
syncedOrder =
|
|
2311
|
+
syncedOrder = _context28.sent;
|
|
2194
2312
|
printableSyncedOrder = syncedOrder ? this.buildSyncedOrderForPrint({
|
|
2195
2313
|
syncedOrder: syncedOrder,
|
|
2196
2314
|
checkoutResponseOrder: fresh
|
|
@@ -2199,10 +2317,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
2199
2317
|
checkoutData: remoteCheckoutData,
|
|
2200
2318
|
syncedOrder: printableSyncedOrder
|
|
2201
2319
|
}))) {
|
|
2202
|
-
|
|
2320
|
+
_context28.next = 24;
|
|
2203
2321
|
break;
|
|
2204
2322
|
}
|
|
2205
|
-
|
|
2323
|
+
_context28.next = 24;
|
|
2206
2324
|
return this.dispatchPrintOtherReceiptTask({
|
|
2207
2325
|
checkoutData: remoteCheckoutData,
|
|
2208
2326
|
syncedOrder: printableSyncedOrder,
|
|
@@ -2210,7 +2328,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2210
2328
|
deviceId: params.deviceId
|
|
2211
2329
|
});
|
|
2212
2330
|
case 24:
|
|
2213
|
-
return
|
|
2331
|
+
return _context28.abrupt("return", {
|
|
2214
2332
|
rejected: false,
|
|
2215
2333
|
response: response,
|
|
2216
2334
|
normalizedResponse: this.normalizeCheckoutResponse(response),
|
|
@@ -2220,11 +2338,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
2220
2338
|
});
|
|
2221
2339
|
case 25:
|
|
2222
2340
|
case "end":
|
|
2223
|
-
return
|
|
2341
|
+
return _context28.stop();
|
|
2224
2342
|
}
|
|
2225
|
-
},
|
|
2343
|
+
}, _callee28, this);
|
|
2226
2344
|
}));
|
|
2227
|
-
function runCheckoutSync(
|
|
2345
|
+
function runCheckoutSync(_x31) {
|
|
2228
2346
|
return _runCheckoutSync.apply(this, arguments);
|
|
2229
2347
|
}
|
|
2230
2348
|
return runCheckoutSync;
|
|
@@ -2241,15 +2359,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
2241
2359
|
}, {
|
|
2242
2360
|
key: "persistSyncedCheckoutOrder",
|
|
2243
2361
|
value: function () {
|
|
2244
|
-
var _persistSyncedCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2362
|
+
var _persistSyncedCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
2245
2363
|
var backendPath, checkoutData, externalSaleNumber, fresh, title, persistCheckoutDataWithResponse, shouldMergeRemoteOrder, syncedOrder, _external_sale_number2, _external_sale_number3, _syncedOrder$order_id, _syncedOrder, patch, result;
|
|
2246
|
-
return _regeneratorRuntime().wrap(function
|
|
2247
|
-
while (1) switch (
|
|
2364
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2365
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2248
2366
|
case 0:
|
|
2249
2367
|
backendPath = params.backendPath, checkoutData = params.checkoutData, externalSaleNumber = params.externalSaleNumber, fresh = params.fresh, title = params.title, persistCheckoutDataWithResponse = params.persistCheckoutDataWithResponse;
|
|
2250
2368
|
shouldMergeRemoteOrder = fresh ? this.isMergeableCheckoutOrder(fresh, externalSaleNumber) : false;
|
|
2251
2369
|
if (!(this.order && fresh && (shouldMergeRemoteOrder || persistCheckoutDataWithResponse))) {
|
|
2252
|
-
|
|
2370
|
+
_context29.next = 9;
|
|
2253
2371
|
break;
|
|
2254
2372
|
}
|
|
2255
2373
|
syncedOrder = persistCheckoutDataWithResponse ? _objectSpread(_objectSpread(_objectSpread({}, checkoutData), fresh), {}, {
|
|
@@ -2259,7 +2377,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2259
2377
|
external_sale_number: (_external_sale_number3 = fresh.external_sale_number) !== null && _external_sale_number3 !== void 0 ? _external_sale_number3 : externalSaleNumber,
|
|
2260
2378
|
need_sync: 0
|
|
2261
2379
|
});
|
|
2262
|
-
|
|
2380
|
+
_context29.next = 6;
|
|
2263
2381
|
return this.order.upsertOrdersFromRemote([syncedOrder]);
|
|
2264
2382
|
case 6:
|
|
2265
2383
|
this.logInfo("".concat(title, ": sync_sales \u5B8C\u6574\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u672C\u5730"), {
|
|
@@ -2269,21 +2387,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
2269
2387
|
mergedRemoteOrder: shouldMergeRemoteOrder,
|
|
2270
2388
|
persistedCheckoutDataWithResponse: persistCheckoutDataWithResponse
|
|
2271
2389
|
});
|
|
2272
|
-
|
|
2390
|
+
_context29.next = 19;
|
|
2273
2391
|
break;
|
|
2274
2392
|
case 9:
|
|
2275
2393
|
if (!(this.order && externalSaleNumber && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
|
|
2276
|
-
|
|
2394
|
+
_context29.next = 18;
|
|
2277
2395
|
break;
|
|
2278
2396
|
}
|
|
2279
2397
|
patch = this.buildCheckoutSyncSuccessPatch(fresh);
|
|
2280
|
-
|
|
2398
|
+
_context29.next = 13;
|
|
2281
2399
|
return this.order.markOrderSyncedByExternalSaleNumber({
|
|
2282
2400
|
externalSaleNumber: externalSaleNumber,
|
|
2283
2401
|
patch: patch
|
|
2284
2402
|
});
|
|
2285
2403
|
case 13:
|
|
2286
|
-
result =
|
|
2404
|
+
result = _context29.sent;
|
|
2287
2405
|
syncedOrder = (result === null || result === void 0 ? void 0 : result.order) || _objectSpread(_objectSpread(_objectSpread({}, checkoutData), patch), {}, {
|
|
2288
2406
|
external_sale_number: externalSaleNumber,
|
|
2289
2407
|
need_sync: 0
|
|
@@ -2294,7 +2412,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2294
2412
|
hasRemoteOrder: !!fresh,
|
|
2295
2413
|
mergedRemoteOrder: false
|
|
2296
2414
|
});
|
|
2297
|
-
|
|
2415
|
+
_context29.next = 19;
|
|
2298
2416
|
break;
|
|
2299
2417
|
case 18:
|
|
2300
2418
|
this.logWarning("".concat(title, ": sync_sales Order \u6A21\u5757\u672A\u6CE8\u518C"), {
|
|
@@ -2303,14 +2421,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
2303
2421
|
order_id: fresh === null || fresh === void 0 ? void 0 : fresh.order_id
|
|
2304
2422
|
});
|
|
2305
2423
|
case 19:
|
|
2306
|
-
return
|
|
2424
|
+
return _context29.abrupt("return", syncedOrder);
|
|
2307
2425
|
case 20:
|
|
2308
2426
|
case "end":
|
|
2309
|
-
return
|
|
2427
|
+
return _context29.stop();
|
|
2310
2428
|
}
|
|
2311
|
-
},
|
|
2429
|
+
}, _callee29, this);
|
|
2312
2430
|
}));
|
|
2313
|
-
function persistSyncedCheckoutOrder(
|
|
2431
|
+
function persistSyncedCheckoutOrder(_x32) {
|
|
2314
2432
|
return _persistSyncedCheckoutOrder.apply(this, arguments);
|
|
2315
2433
|
}
|
|
2316
2434
|
return persistSyncedCheckoutOrder;
|
|
@@ -2321,51 +2439,51 @@ var Server = /*#__PURE__*/function () {
|
|
|
2321
2439
|
}, {
|
|
2322
2440
|
key: "setupProductsQuotationPriceBridge",
|
|
2323
2441
|
value: (function () {
|
|
2324
|
-
var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2442
|
+
var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2325
2443
|
var _this$core$context, errorMessage;
|
|
2326
|
-
return _regeneratorRuntime().wrap(function
|
|
2327
|
-
while (1) switch (
|
|
2444
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2445
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2328
2446
|
case 0:
|
|
2329
2447
|
if (this.products) {
|
|
2330
|
-
|
|
2448
|
+
_context30.next = 3;
|
|
2331
2449
|
break;
|
|
2332
2450
|
}
|
|
2333
2451
|
this.logInfo('setupProductsQuotationPriceBridge: Products 模块未注册');
|
|
2334
|
-
return
|
|
2452
|
+
return _context30.abrupt("return");
|
|
2335
2453
|
case 3:
|
|
2336
2454
|
if (this.schedule) {
|
|
2337
|
-
|
|
2455
|
+
_context30.next = 6;
|
|
2338
2456
|
break;
|
|
2339
2457
|
}
|
|
2340
2458
|
this.logInfo('setupProductsQuotationPriceBridge: Schedule 模块未注册');
|
|
2341
|
-
return
|
|
2459
|
+
return _context30.abrupt("return");
|
|
2342
2460
|
case 6:
|
|
2343
|
-
|
|
2344
|
-
|
|
2461
|
+
_context30.prev = 6;
|
|
2462
|
+
_context30.next = 9;
|
|
2345
2463
|
return this.schedule.loadAllSchedule();
|
|
2346
2464
|
case 9:
|
|
2347
2465
|
this.products.clearPriceCache();
|
|
2348
|
-
|
|
2466
|
+
_context30.next = 12;
|
|
2349
2467
|
return this.products.setupQuotationPriceBridge({
|
|
2350
2468
|
scheduleModule: this.schedule,
|
|
2351
2469
|
channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel
|
|
2352
2470
|
});
|
|
2353
2471
|
case 12:
|
|
2354
2472
|
this.logInfo('Products 报价单价格桥接初始化完成');
|
|
2355
|
-
|
|
2473
|
+
_context30.next = 19;
|
|
2356
2474
|
break;
|
|
2357
2475
|
case 15:
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
errorMessage =
|
|
2476
|
+
_context30.prev = 15;
|
|
2477
|
+
_context30.t0 = _context30["catch"](6);
|
|
2478
|
+
errorMessage = _context30.t0 instanceof Error ? _context30.t0.message : String(_context30.t0);
|
|
2361
2479
|
this.logError('Products 报价单价格桥接初始化失败', {
|
|
2362
2480
|
error: errorMessage
|
|
2363
2481
|
});
|
|
2364
2482
|
case 19:
|
|
2365
2483
|
case "end":
|
|
2366
|
-
return
|
|
2484
|
+
return _context30.stop();
|
|
2367
2485
|
}
|
|
2368
|
-
},
|
|
2486
|
+
}, _callee30, this, [[6, 15]]);
|
|
2369
2487
|
}));
|
|
2370
2488
|
function setupProductsQuotationPriceBridge() {
|
|
2371
2489
|
return _setupProductsQuotationPriceBridge.apply(this, arguments);
|
|
@@ -2434,45 +2552,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
2434
2552
|
}, {
|
|
2435
2553
|
key: "refreshProductsInBackground",
|
|
2436
2554
|
value: (function () {
|
|
2437
|
-
var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2555
|
+
var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
2438
2556
|
var startTime, duration, _duration2, errorMessage;
|
|
2439
|
-
return _regeneratorRuntime().wrap(function
|
|
2440
|
-
while (1) switch (
|
|
2557
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2558
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2441
2559
|
case 0:
|
|
2442
2560
|
if (this.products) {
|
|
2443
|
-
|
|
2561
|
+
_context31.next = 3;
|
|
2444
2562
|
break;
|
|
2445
2563
|
}
|
|
2446
2564
|
this.logWarning('refreshProductsInBackground: Products 模块未注册');
|
|
2447
|
-
return
|
|
2565
|
+
return _context31.abrupt("return");
|
|
2448
2566
|
case 3:
|
|
2449
2567
|
this.logInfo('refreshProductsInBackground 开始');
|
|
2450
2568
|
startTime = Date.now();
|
|
2451
|
-
|
|
2452
|
-
|
|
2569
|
+
_context31.prev = 5;
|
|
2570
|
+
_context31.next = 8;
|
|
2453
2571
|
return this.products.silentRefresh();
|
|
2454
2572
|
case 8:
|
|
2455
2573
|
duration = Date.now() - startTime;
|
|
2456
2574
|
this.logInfo('refreshProductsInBackground 完成', {
|
|
2457
2575
|
duration: "".concat(duration, "ms")
|
|
2458
2576
|
});
|
|
2459
|
-
|
|
2577
|
+
_context31.next = 18;
|
|
2460
2578
|
break;
|
|
2461
2579
|
case 12:
|
|
2462
|
-
|
|
2463
|
-
|
|
2580
|
+
_context31.prev = 12;
|
|
2581
|
+
_context31.t0 = _context31["catch"](5);
|
|
2464
2582
|
_duration2 = Date.now() - startTime;
|
|
2465
|
-
errorMessage =
|
|
2466
|
-
console.error('[Server] refreshProductsInBackground 失败:',
|
|
2583
|
+
errorMessage = _context31.t0 instanceof Error ? _context31.t0.message : String(_context31.t0);
|
|
2584
|
+
console.error('[Server] refreshProductsInBackground 失败:', _context31.t0);
|
|
2467
2585
|
this.logError('refreshProductsInBackground 失败', {
|
|
2468
2586
|
duration: "".concat(_duration2, "ms"),
|
|
2469
2587
|
error: errorMessage
|
|
2470
2588
|
});
|
|
2471
2589
|
case 18:
|
|
2472
2590
|
case "end":
|
|
2473
|
-
return
|
|
2591
|
+
return _context31.stop();
|
|
2474
2592
|
}
|
|
2475
|
-
},
|
|
2593
|
+
}, _callee31, this, [[5, 12]]);
|
|
2476
2594
|
}));
|
|
2477
2595
|
function refreshProductsInBackground() {
|
|
2478
2596
|
return _refreshProductsInBackground.apply(this, arguments);
|
|
@@ -2488,45 +2606,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
2488
2606
|
}, {
|
|
2489
2607
|
key: "refreshOrdersInBackground",
|
|
2490
2608
|
value: (function () {
|
|
2491
|
-
var _refreshOrdersInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2609
|
+
var _refreshOrdersInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
2492
2610
|
var startTime, duration, _duration3, errorMessage;
|
|
2493
|
-
return _regeneratorRuntime().wrap(function
|
|
2494
|
-
while (1) switch (
|
|
2611
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2612
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2495
2613
|
case 0:
|
|
2496
2614
|
if (this.order) {
|
|
2497
|
-
|
|
2615
|
+
_context32.next = 3;
|
|
2498
2616
|
break;
|
|
2499
2617
|
}
|
|
2500
2618
|
this.logWarning('refreshOrdersInBackground: Order 模块未注册');
|
|
2501
|
-
return
|
|
2619
|
+
return _context32.abrupt("return");
|
|
2502
2620
|
case 3:
|
|
2503
2621
|
this.logInfo('refreshOrdersInBackground 开始');
|
|
2504
2622
|
startTime = Date.now();
|
|
2505
|
-
|
|
2506
|
-
|
|
2623
|
+
_context32.prev = 5;
|
|
2624
|
+
_context32.next = 8;
|
|
2507
2625
|
return this.order.silentRefresh();
|
|
2508
2626
|
case 8:
|
|
2509
2627
|
duration = Date.now() - startTime;
|
|
2510
2628
|
this.logInfo('refreshOrdersInBackground 完成', {
|
|
2511
2629
|
duration: "".concat(duration, "ms")
|
|
2512
2630
|
});
|
|
2513
|
-
|
|
2631
|
+
_context32.next = 18;
|
|
2514
2632
|
break;
|
|
2515
2633
|
case 12:
|
|
2516
|
-
|
|
2517
|
-
|
|
2634
|
+
_context32.prev = 12;
|
|
2635
|
+
_context32.t0 = _context32["catch"](5);
|
|
2518
2636
|
_duration3 = Date.now() - startTime;
|
|
2519
|
-
errorMessage =
|
|
2520
|
-
console.error('[Server] refreshOrdersInBackground 失败:',
|
|
2637
|
+
errorMessage = _context32.t0 instanceof Error ? _context32.t0.message : String(_context32.t0);
|
|
2638
|
+
console.error('[Server] refreshOrdersInBackground 失败:', _context32.t0);
|
|
2521
2639
|
this.logError('refreshOrdersInBackground 失败', {
|
|
2522
2640
|
duration: "".concat(_duration3, "ms"),
|
|
2523
2641
|
error: errorMessage
|
|
2524
2642
|
});
|
|
2525
2643
|
case 18:
|
|
2526
2644
|
case "end":
|
|
2527
|
-
return
|
|
2645
|
+
return _context32.stop();
|
|
2528
2646
|
}
|
|
2529
|
-
},
|
|
2647
|
+
}, _callee32, this, [[5, 12]]);
|
|
2530
2648
|
}));
|
|
2531
2649
|
function refreshOrdersInBackground() {
|
|
2532
2650
|
return _refreshOrdersInBackground.apply(this, arguments);
|
|
@@ -2541,10 +2659,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
2541
2659
|
}, {
|
|
2542
2660
|
key: "clearAllIndexDB",
|
|
2543
2661
|
value: (function () {
|
|
2544
|
-
var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2662
|
+
var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
2545
2663
|
var clearTasks, moduleNames, errorMessage;
|
|
2546
|
-
return _regeneratorRuntime().wrap(function
|
|
2547
|
-
while (1) switch (
|
|
2664
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2665
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
2548
2666
|
case 0:
|
|
2549
2667
|
console.log('[Server] 开始清空所有模块的IndexedDB缓存...');
|
|
2550
2668
|
this.logInfo('开始清空所有模块的 IndexedDB 缓存');
|
|
@@ -2579,41 +2697,41 @@ var Server = /*#__PURE__*/function () {
|
|
|
2579
2697
|
moduleNames.push('FloorPlan');
|
|
2580
2698
|
}
|
|
2581
2699
|
if (!(clearTasks.length === 0)) {
|
|
2582
|
-
|
|
2700
|
+
_context33.next = 15;
|
|
2583
2701
|
break;
|
|
2584
2702
|
}
|
|
2585
2703
|
console.warn('[Server] 没有找到已注册的模块,无需清空');
|
|
2586
2704
|
this.logWarning('没有找到已注册的模块,无需清空 IndexedDB');
|
|
2587
|
-
return
|
|
2705
|
+
return _context33.abrupt("return");
|
|
2588
2706
|
case 15:
|
|
2589
2707
|
this.logInfo('准备清空模块缓存', {
|
|
2590
2708
|
moduleNames: moduleNames
|
|
2591
2709
|
});
|
|
2592
|
-
|
|
2593
|
-
|
|
2710
|
+
_context33.prev = 16;
|
|
2711
|
+
_context33.next = 19;
|
|
2594
2712
|
return Promise.all(clearTasks);
|
|
2595
2713
|
case 19:
|
|
2596
2714
|
console.log("[Server] \u2705 \u5DF2\u6210\u529F\u6E05\u7A7A\u6240\u6709\u6A21\u5757\u7684IndexedDB\u7F13\u5B58: ".concat(moduleNames.join(', ')));
|
|
2597
2715
|
this.logInfo('成功清空所有模块的 IndexedDB 缓存', {
|
|
2598
2716
|
moduleNames: moduleNames
|
|
2599
2717
|
});
|
|
2600
|
-
|
|
2718
|
+
_context33.next = 29;
|
|
2601
2719
|
break;
|
|
2602
2720
|
case 23:
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
errorMessage =
|
|
2606
|
-
console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:',
|
|
2721
|
+
_context33.prev = 23;
|
|
2722
|
+
_context33.t0 = _context33["catch"](16);
|
|
2723
|
+
errorMessage = _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0);
|
|
2724
|
+
console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context33.t0);
|
|
2607
2725
|
this.logError('清空 IndexedDB 缓存时发生错误', {
|
|
2608
2726
|
moduleNames: moduleNames,
|
|
2609
2727
|
error: errorMessage
|
|
2610
2728
|
});
|
|
2611
|
-
throw
|
|
2729
|
+
throw _context33.t0;
|
|
2612
2730
|
case 29:
|
|
2613
2731
|
case "end":
|
|
2614
|
-
return
|
|
2732
|
+
return _context33.stop();
|
|
2615
2733
|
}
|
|
2616
|
-
},
|
|
2734
|
+
}, _callee33, this, [[16, 23]]);
|
|
2617
2735
|
}));
|
|
2618
2736
|
function clearAllIndexDB() {
|
|
2619
2737
|
return _clearAllIndexDB.apply(this, arguments);
|
|
@@ -2688,10 +2806,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
2688
2806
|
}, {
|
|
2689
2807
|
key: "handleRoute",
|
|
2690
2808
|
value: (function () {
|
|
2691
|
-
var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2809
|
+
var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(method, path, params) {
|
|
2692
2810
|
var startTime, handler, result, duration, _duration4, errorMessage;
|
|
2693
|
-
return _regeneratorRuntime().wrap(function
|
|
2694
|
-
while (1) switch (
|
|
2811
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2812
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
2695
2813
|
case 0:
|
|
2696
2814
|
startTime = Date.now();
|
|
2697
2815
|
this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5F00\u59CB: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
@@ -2702,7 +2820,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2702
2820
|
});
|
|
2703
2821
|
handler = this.getRouteHandler(method, path);
|
|
2704
2822
|
if (handler) {
|
|
2705
|
-
|
|
2823
|
+
_context34.next = 6;
|
|
2706
2824
|
break;
|
|
2707
2825
|
}
|
|
2708
2826
|
this.logError("\u8DEF\u7531\u672A\u627E\u5230: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
@@ -2711,13 +2829,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
2711
2829
|
});
|
|
2712
2830
|
throw new Error("Route not found: ".concat(method.toUpperCase(), " ").concat(path));
|
|
2713
2831
|
case 6:
|
|
2714
|
-
|
|
2715
|
-
|
|
2832
|
+
_context34.prev = 6;
|
|
2833
|
+
_context34.next = 9;
|
|
2716
2834
|
return handler(_objectSpread(_objectSpread({}, params), {}, {
|
|
2717
2835
|
path: path
|
|
2718
2836
|
}));
|
|
2719
2837
|
case 9:
|
|
2720
|
-
result =
|
|
2838
|
+
result = _context34.sent;
|
|
2721
2839
|
duration = Date.now() - startTime;
|
|
2722
2840
|
this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5B8C\u6210: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
2723
2841
|
method: method.toUpperCase(),
|
|
@@ -2726,12 +2844,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
2726
2844
|
resultCode: result === null || result === void 0 ? void 0 : result.code,
|
|
2727
2845
|
resultStatus: result === null || result === void 0 ? void 0 : result.status
|
|
2728
2846
|
});
|
|
2729
|
-
return
|
|
2847
|
+
return _context34.abrupt("return", result);
|
|
2730
2848
|
case 15:
|
|
2731
|
-
|
|
2732
|
-
|
|
2849
|
+
_context34.prev = 15;
|
|
2850
|
+
_context34.t0 = _context34["catch"](6);
|
|
2733
2851
|
_duration4 = Date.now() - startTime;
|
|
2734
|
-
errorMessage =
|
|
2852
|
+
errorMessage = _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0);
|
|
2735
2853
|
this.logError("\u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
2736
2854
|
method: method.toUpperCase(),
|
|
2737
2855
|
path: path,
|
|
@@ -2739,15 +2857,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
2739
2857
|
error: errorMessage,
|
|
2740
2858
|
data: params.data
|
|
2741
2859
|
});
|
|
2742
|
-
console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path),
|
|
2743
|
-
throw
|
|
2860
|
+
console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context34.t0);
|
|
2861
|
+
throw _context34.t0;
|
|
2744
2862
|
case 22:
|
|
2745
2863
|
case "end":
|
|
2746
|
-
return
|
|
2864
|
+
return _context34.stop();
|
|
2747
2865
|
}
|
|
2748
|
-
},
|
|
2866
|
+
}, _callee34, this, [[6, 15]]);
|
|
2749
2867
|
}));
|
|
2750
|
-
function handleRoute(
|
|
2868
|
+
function handleRoute(_x33, _x34, _x35) {
|
|
2751
2869
|
return _handleRoute.apply(this, arguments);
|
|
2752
2870
|
}
|
|
2753
2871
|
return handleRoute;
|
|
@@ -2857,6 +2975,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
2857
2975
|
method: 'post',
|
|
2858
2976
|
path: '/shop/local/print-order',
|
|
2859
2977
|
handler: this.handleLocalPrintOrder.bind(this)
|
|
2978
|
+
}, {
|
|
2979
|
+
method: 'post',
|
|
2980
|
+
path: '/shop/machinecode/batch',
|
|
2981
|
+
handler: this.handleMachinecodeBatchMeta.bind(this)
|
|
2982
|
+
}, {
|
|
2983
|
+
method: 'post',
|
|
2984
|
+
path: '/machinecode/batch',
|
|
2985
|
+
handler: this.handleMachinecodeBatchMeta.bind(this)
|
|
2860
2986
|
}]);
|
|
2861
2987
|
this.registerPrefixRoutes([{
|
|
2862
2988
|
method: 'get',
|
|
@@ -2871,36 +2997,36 @@ var Server = /*#__PURE__*/function () {
|
|
|
2871
2997
|
}, {
|
|
2872
2998
|
key: "getPaymentRouteModule",
|
|
2873
2999
|
value: function () {
|
|
2874
|
-
var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3000
|
+
var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
|
|
2875
3001
|
var _this6 = this;
|
|
2876
|
-
return _regeneratorRuntime().wrap(function
|
|
2877
|
-
while (1) switch (
|
|
3002
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
3003
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
2878
3004
|
case 0:
|
|
2879
3005
|
if (!this.payment) {
|
|
2880
|
-
|
|
3006
|
+
_context36.next = 2;
|
|
2881
3007
|
break;
|
|
2882
3008
|
}
|
|
2883
|
-
return
|
|
3009
|
+
return _context36.abrupt("return", this.payment);
|
|
2884
3010
|
case 2:
|
|
2885
3011
|
if (!this.paymentRouteModule) {
|
|
2886
|
-
|
|
3012
|
+
_context36.next = 4;
|
|
2887
3013
|
break;
|
|
2888
3014
|
}
|
|
2889
|
-
return
|
|
3015
|
+
return _context36.abrupt("return", this.paymentRouteModule);
|
|
2890
3016
|
case 4:
|
|
2891
3017
|
if (!this.paymentRouteModuleInFlight) {
|
|
2892
|
-
|
|
3018
|
+
_context36.next = 6;
|
|
2893
3019
|
break;
|
|
2894
3020
|
}
|
|
2895
|
-
return
|
|
3021
|
+
return _context36.abrupt("return", this.paymentRouteModuleInFlight);
|
|
2896
3022
|
case 6:
|
|
2897
|
-
this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3023
|
+
this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
|
|
2898
3024
|
var module;
|
|
2899
|
-
return _regeneratorRuntime().wrap(function
|
|
2900
|
-
while (1) switch (
|
|
3025
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3026
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
2901
3027
|
case 0:
|
|
2902
3028
|
module = new PaymentServerModule('server_payment_route', '1.0.0');
|
|
2903
|
-
|
|
3029
|
+
_context35.next = 3;
|
|
2904
3030
|
return module.initialize(_this6.core, {
|
|
2905
3031
|
store: {
|
|
2906
3032
|
payMethods: []
|
|
@@ -2908,21 +3034,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
2908
3034
|
});
|
|
2909
3035
|
case 3:
|
|
2910
3036
|
_this6.paymentRouteModule = module;
|
|
2911
|
-
return
|
|
3037
|
+
return _context35.abrupt("return", module);
|
|
2912
3038
|
case 5:
|
|
2913
3039
|
case "end":
|
|
2914
|
-
return
|
|
3040
|
+
return _context35.stop();
|
|
2915
3041
|
}
|
|
2916
|
-
},
|
|
3042
|
+
}, _callee35);
|
|
2917
3043
|
}))().finally(function () {
|
|
2918
3044
|
_this6.paymentRouteModuleInFlight = undefined;
|
|
2919
3045
|
});
|
|
2920
|
-
return
|
|
3046
|
+
return _context36.abrupt("return", this.paymentRouteModuleInFlight);
|
|
2921
3047
|
case 8:
|
|
2922
3048
|
case "end":
|
|
2923
|
-
return
|
|
3049
|
+
return _context36.stop();
|
|
2924
3050
|
}
|
|
2925
|
-
},
|
|
3051
|
+
}, _callee36, this);
|
|
2926
3052
|
}));
|
|
2927
3053
|
function getPaymentRouteModule() {
|
|
2928
3054
|
return _getPaymentRouteModule.apply(this, arguments);
|
|
@@ -2932,19 +3058,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
2932
3058
|
}, {
|
|
2933
3059
|
key: "fetchQuotationAvailableFromAPI",
|
|
2934
3060
|
value: function () {
|
|
2935
|
-
var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2936
|
-
var _this$
|
|
3061
|
+
var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(data) {
|
|
3062
|
+
var _this$app7;
|
|
2937
3063
|
var requester;
|
|
2938
|
-
return _regeneratorRuntime().wrap(function
|
|
2939
|
-
while (1) switch (
|
|
3064
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3065
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
2940
3066
|
case 0:
|
|
2941
|
-
requester = ((_this$
|
|
3067
|
+
requester = ((_this$app7 = this.app) === null || _this$app7 === void 0 ? void 0 : _this$app7.request) || this.core.getPlugin('request');
|
|
2942
3068
|
if (requester !== null && requester !== void 0 && requester.get) {
|
|
2943
|
-
|
|
3069
|
+
_context37.next = 4;
|
|
2944
3070
|
break;
|
|
2945
3071
|
}
|
|
2946
3072
|
this.logError('fetchQuotationAvailableFromAPI: request 不可用');
|
|
2947
|
-
return
|
|
3073
|
+
return _context37.abrupt("return", {
|
|
2948
3074
|
code: 500,
|
|
2949
3075
|
message: 'request 不可用',
|
|
2950
3076
|
data: {
|
|
@@ -2953,14 +3079,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
2953
3079
|
status: false
|
|
2954
3080
|
});
|
|
2955
3081
|
case 4:
|
|
2956
|
-
return
|
|
3082
|
+
return _context37.abrupt("return", requester.get('/shop/quotation/available', data));
|
|
2957
3083
|
case 5:
|
|
2958
3084
|
case "end":
|
|
2959
|
-
return
|
|
3085
|
+
return _context37.stop();
|
|
2960
3086
|
}
|
|
2961
|
-
},
|
|
3087
|
+
}, _callee37, this);
|
|
2962
3088
|
}));
|
|
2963
|
-
function fetchQuotationAvailableFromAPI(
|
|
3089
|
+
function fetchQuotationAvailableFromAPI(_x36) {
|
|
2964
3090
|
return _fetchQuotationAvailableFromAPI.apply(this, arguments);
|
|
2965
3091
|
}
|
|
2966
3092
|
return fetchQuotationAvailableFromAPI;
|
|
@@ -2982,7 +3108,6 @@ var Server = /*#__PURE__*/function () {
|
|
|
2982
3108
|
key: "removeProductQuerySubscriber",
|
|
2983
3109
|
value: function removeProductQuerySubscriber(subscriberId) {
|
|
2984
3110
|
if (subscriberId) {
|
|
2985
|
-
this.clearSubscriberScheduleTimers(subscriberId);
|
|
2986
3111
|
this.productQuerySubscribers.delete(subscriberId);
|
|
2987
3112
|
this.logInfo('removeProductQuerySubscriber: 已移除订阅者', {
|
|
2988
3113
|
subscriberId: subscriberId,
|
|
@@ -2990,243 +3115,6 @@ var Server = /*#__PURE__*/function () {
|
|
|
2990
3115
|
});
|
|
2991
3116
|
}
|
|
2992
3117
|
}
|
|
2993
|
-
|
|
2994
|
-
/**
|
|
2995
|
-
* 构建商品 query 响应 data 段,附带智能定价 schedule_time_points 元数据。
|
|
2996
|
-
*/
|
|
2997
|
-
}, {
|
|
2998
|
-
key: "buildProductQueryResultPayload",
|
|
2999
|
-
value: function buildProductQueryResultPayload(list, count) {
|
|
3000
|
-
var _this$products$getLas, _this$products, _this$products$getLas2;
|
|
3001
|
-
return {
|
|
3002
|
-
list: list,
|
|
3003
|
-
count: count !== null && count !== void 0 ? count : list.length,
|
|
3004
|
-
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 : []
|
|
3005
|
-
};
|
|
3006
|
-
}
|
|
3007
|
-
|
|
3008
|
-
/**
|
|
3009
|
-
* 是否启用商品 query 订阅的 schedule 时间点定时重算。
|
|
3010
|
-
* strategy_context.enable_schedule_reload === false 时关闭。
|
|
3011
|
-
*/
|
|
3012
|
-
}, {
|
|
3013
|
-
key: "shouldScheduleProductQueryReload",
|
|
3014
|
-
value: function shouldScheduleProductQueryReload(strategy_context) {
|
|
3015
|
-
return (strategy_context === null || strategy_context === void 0 ? void 0 : strategy_context.enable_schedule_reload) !== false;
|
|
3016
|
-
}
|
|
3017
|
-
|
|
3018
|
-
/**
|
|
3019
|
-
* 清除指定 subscriber 的全部 schedule 定时器,防止重复 query 或 unsubscribe 后泄漏。
|
|
3020
|
-
*/
|
|
3021
|
-
}, {
|
|
3022
|
-
key: "clearSubscriberScheduleTimers",
|
|
3023
|
-
value: function clearSubscriberScheduleTimers(subscriberId) {
|
|
3024
|
-
var timers = this.productQueryScheduleTimers.get(subscriberId);
|
|
3025
|
-
if (timers !== null && timers !== void 0 && timers.length) {
|
|
3026
|
-
timers.forEach(function (timerId) {
|
|
3027
|
-
return clearTimeout(timerId);
|
|
3028
|
-
});
|
|
3029
|
-
}
|
|
3030
|
-
this.productQueryScheduleTimers.delete(subscriberId);
|
|
3031
|
-
var subscriber = this.productQuerySubscribers.get(subscriberId);
|
|
3032
|
-
if (subscriber) {
|
|
3033
|
-
subscriber.scheduleTimerIds = [];
|
|
3034
|
-
}
|
|
3035
|
-
}
|
|
3036
|
-
|
|
3037
|
-
/**
|
|
3038
|
-
* 从 productQueryScheduleTimers 移除已触发的 timer 引用。
|
|
3039
|
-
*/
|
|
3040
|
-
}, {
|
|
3041
|
-
key: "removeScheduleTimerRef",
|
|
3042
|
-
value: function removeScheduleTimerRef(subscriberId, timerId) {
|
|
3043
|
-
var timers = this.productQueryScheduleTimers.get(subscriberId);
|
|
3044
|
-
if (!(timers !== null && timers !== void 0 && timers.length)) return;
|
|
3045
|
-
var next = timers.filter(function (id) {
|
|
3046
|
-
return id !== timerId;
|
|
3047
|
-
});
|
|
3048
|
-
if (next.length === 0) {
|
|
3049
|
-
this.productQueryScheduleTimers.delete(subscriberId);
|
|
3050
|
-
} else {
|
|
3051
|
-
this.productQueryScheduleTimers.set(subscriberId, next);
|
|
3052
|
-
}
|
|
3053
|
-
var subscriber = this.productQuerySubscribers.get(subscriberId);
|
|
3054
|
-
if (subscriber) {
|
|
3055
|
-
subscriber.scheduleTimerIds = next;
|
|
3056
|
-
}
|
|
3057
|
-
}
|
|
3058
|
-
|
|
3059
|
-
/**
|
|
3060
|
-
* 计算 schedule 变价时间点到当前时刻的延迟(ms)。已过期返回 -1。
|
|
3061
|
-
*/
|
|
3062
|
-
}, {
|
|
3063
|
-
key: "computeScheduleTimePointDelayMs",
|
|
3064
|
-
value: function computeScheduleTimePointDelayMs(scheduleDate, timePoint) {
|
|
3065
|
-
var parts = timePoint.split(':');
|
|
3066
|
-
if (parts.length < 2) return -1;
|
|
3067
|
-
var hours = parseInt(parts[0], 10);
|
|
3068
|
-
var minutes = parseInt(parts[1], 10);
|
|
3069
|
-
if (!Number.isFinite(hours) || !Number.isFinite(minutes)) return -1;
|
|
3070
|
-
var target = dayjs(scheduleDate).hour(hours).minute(minutes).second(4).millisecond(0);
|
|
3071
|
-
var delayMs = target.diff(dayjs());
|
|
3072
|
-
return delayMs >= 0 ? delayMs : -1;
|
|
3073
|
-
}
|
|
3074
|
-
|
|
3075
|
-
/**
|
|
3076
|
-
* 定时重算前刷新 subscriber schedule 上下文:使用执行瞬间时间,禁止沿用首次 query 的 schedule_datetime。
|
|
3077
|
-
*/
|
|
3078
|
-
}, {
|
|
3079
|
-
key: "refreshSubscriberScheduleAtExecution",
|
|
3080
|
-
value: function refreshSubscriberScheduleAtExecution(subscriber) {
|
|
3081
|
-
var executedAt = dayjs();
|
|
3082
|
-
var bookingDate = subscriber.context.schedule_date || executedAt.format('YYYY-MM-DD');
|
|
3083
|
-
subscriber.context.schedule_date = bookingDate;
|
|
3084
|
-
subscriber.context.schedule_datetime = "".concat(bookingDate, " ").concat(executedAt.format('HH:mm:ss'));
|
|
3085
|
-
}
|
|
3086
|
-
|
|
3087
|
-
/**
|
|
3088
|
-
* 为 subscriber 注册智能定价 scheduleTimePoints 定时重算。
|
|
3089
|
-
* 必须先 clearSubscriberScheduleTimers,再调用本方法。
|
|
3090
|
-
*/
|
|
3091
|
-
}, {
|
|
3092
|
-
key: "scheduleSubscriberTimePointReloads",
|
|
3093
|
-
value: function scheduleSubscriberTimePointReloads(subscriberId, timePoints) {
|
|
3094
|
-
var _this7 = this;
|
|
3095
|
-
var subscriber = this.productQuerySubscribers.get(subscriberId);
|
|
3096
|
-
if (!subscriber || !timePoints.length) return;
|
|
3097
|
-
var scheduleDate = subscriber.context.schedule_date || dayjs().format('YYYY-MM-DD');
|
|
3098
|
-
var timerIds = [];
|
|
3099
|
-
var _iterator5 = _createForOfIteratorHelper(timePoints),
|
|
3100
|
-
_step5;
|
|
3101
|
-
try {
|
|
3102
|
-
var _loop = function _loop() {
|
|
3103
|
-
var timePoint = _step5.value;
|
|
3104
|
-
var delayMs = _this7.computeScheduleTimePointDelayMs(scheduleDate, timePoint);
|
|
3105
|
-
if (delayMs < 0) return 1; // continue
|
|
3106
|
-
var timerId = setTimeout(function () {
|
|
3107
|
-
void _this7.onScheduleTimePointTimerFire(subscriberId, timerId);
|
|
3108
|
-
}, delayMs);
|
|
3109
|
-
timerIds.push(timerId);
|
|
3110
|
-
};
|
|
3111
|
-
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
3112
|
-
if (_loop()) continue;
|
|
3113
|
-
}
|
|
3114
|
-
} catch (err) {
|
|
3115
|
-
_iterator5.e(err);
|
|
3116
|
-
} finally {
|
|
3117
|
-
_iterator5.f();
|
|
3118
|
-
}
|
|
3119
|
-
if (timerIds.length > 0) {
|
|
3120
|
-
this.productQueryScheduleTimers.set(subscriberId, timerIds);
|
|
3121
|
-
subscriber.scheduleTimerIds = timerIds;
|
|
3122
|
-
this.logInfo('scheduleSubscriberTimePointReloads: 已注册定时器', {
|
|
3123
|
-
subscriberId: subscriberId,
|
|
3124
|
-
timerCount: timerIds.length,
|
|
3125
|
-
timePoints: timePoints
|
|
3126
|
-
});
|
|
3127
|
-
}
|
|
3128
|
-
}
|
|
3129
|
-
|
|
3130
|
-
/**
|
|
3131
|
-
* schedule 变价时间点定时器触发:刷新 schedule_datetime 后重算并 callback。
|
|
3132
|
-
*/
|
|
3133
|
-
}, {
|
|
3134
|
-
key: "onScheduleTimePointTimerFire",
|
|
3135
|
-
value: (function () {
|
|
3136
|
-
var _onScheduleTimePointTimerFire = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(subscriberId, timerId) {
|
|
3137
|
-
var subscriber;
|
|
3138
|
-
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3139
|
-
while (1) switch (_context37.prev = _context37.next) {
|
|
3140
|
-
case 0:
|
|
3141
|
-
this.removeScheduleTimerRef(subscriberId, timerId);
|
|
3142
|
-
if (this.productQuerySubscribers.has(subscriberId)) {
|
|
3143
|
-
_context37.next = 3;
|
|
3144
|
-
break;
|
|
3145
|
-
}
|
|
3146
|
-
return _context37.abrupt("return");
|
|
3147
|
-
case 3:
|
|
3148
|
-
subscriber = this.productQuerySubscribers.get(subscriberId);
|
|
3149
|
-
this.refreshSubscriberScheduleAtExecution(subscriber);
|
|
3150
|
-
_context37.next = 7;
|
|
3151
|
-
return this.recomputeAndNotifySubscriber(subscriberId);
|
|
3152
|
-
case 7:
|
|
3153
|
-
case "end":
|
|
3154
|
-
return _context37.stop();
|
|
3155
|
-
}
|
|
3156
|
-
}, _callee37, this);
|
|
3157
|
-
}));
|
|
3158
|
-
function onScheduleTimePointTimerFire(_x36, _x37) {
|
|
3159
|
-
return _onScheduleTimePointTimerFire.apply(this, arguments);
|
|
3160
|
-
}
|
|
3161
|
-
return onScheduleTimePointTimerFire;
|
|
3162
|
-
}()
|
|
3163
|
-
/**
|
|
3164
|
-
* 对单个商品 query 订阅者重算并推送(定时路径;不新建 schedule timer)。
|
|
3165
|
-
*/
|
|
3166
|
-
)
|
|
3167
|
-
}, {
|
|
3168
|
-
key: "recomputeAndNotifySubscriber",
|
|
3169
|
-
value: (function () {
|
|
3170
|
-
var _recomputeAndNotifySubscriber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(subscriberId) {
|
|
3171
|
-
var subscriber, result, errorMessage;
|
|
3172
|
-
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3173
|
-
while (1) switch (_context38.prev = _context38.next) {
|
|
3174
|
-
case 0:
|
|
3175
|
-
subscriber = this.productQuerySubscribers.get(subscriberId);
|
|
3176
|
-
if (subscriber) {
|
|
3177
|
-
_context38.next = 3;
|
|
3178
|
-
break;
|
|
3179
|
-
}
|
|
3180
|
-
return _context38.abrupt("return");
|
|
3181
|
-
case 3:
|
|
3182
|
-
_context38.prev = 3;
|
|
3183
|
-
_context38.next = 6;
|
|
3184
|
-
return this.computeProductQueryResult(subscriber.context);
|
|
3185
|
-
case 6:
|
|
3186
|
-
result = _context38.sent;
|
|
3187
|
-
subscriber.callback(result);
|
|
3188
|
-
this.logInfo('recomputeAndNotifySubscriber: 已推送', {
|
|
3189
|
-
subscriberId: subscriberId,
|
|
3190
|
-
schedule_datetime: subscriber.context.schedule_datetime
|
|
3191
|
-
});
|
|
3192
|
-
_context38.next = 15;
|
|
3193
|
-
break;
|
|
3194
|
-
case 11:
|
|
3195
|
-
_context38.prev = 11;
|
|
3196
|
-
_context38.t0 = _context38["catch"](3);
|
|
3197
|
-
errorMessage = _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0);
|
|
3198
|
-
this.logError('recomputeAndNotifySubscriber: 推送失败', {
|
|
3199
|
-
subscriberId: subscriberId,
|
|
3200
|
-
error: errorMessage
|
|
3201
|
-
});
|
|
3202
|
-
case 15:
|
|
3203
|
-
case "end":
|
|
3204
|
-
return _context38.stop();
|
|
3205
|
-
}
|
|
3206
|
-
}, _callee38, this, [[3, 11]]);
|
|
3207
|
-
}));
|
|
3208
|
-
function recomputeAndNotifySubscriber(_x38) {
|
|
3209
|
-
return _recomputeAndNotifySubscriber.apply(this, arguments);
|
|
3210
|
-
}
|
|
3211
|
-
return recomputeAndNotifySubscriber;
|
|
3212
|
-
}()
|
|
3213
|
-
/**
|
|
3214
|
-
* query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
|
|
3215
|
-
*/
|
|
3216
|
-
)
|
|
3217
|
-
}, {
|
|
3218
|
-
key: "syncProductQueryScheduleTimers",
|
|
3219
|
-
value: function syncProductQueryScheduleTimers(subscriberId, strategy_context) {
|
|
3220
|
-
var _this$products$getLas3, _this$products2, _this$products2$getLa;
|
|
3221
|
-
this.clearSubscriberScheduleTimers(subscriberId);
|
|
3222
|
-
if (!this.shouldScheduleProductQueryReload(strategy_context)) {
|
|
3223
|
-
return;
|
|
3224
|
-
}
|
|
3225
|
-
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 : [];
|
|
3226
|
-
if (timePoints.length > 0) {
|
|
3227
|
-
this.scheduleSubscriberTimePointReloads(subscriberId, timePoints);
|
|
3228
|
-
}
|
|
3229
|
-
}
|
|
3230
3118
|
}, {
|
|
3231
3119
|
key: "handleSalesSearchRequest",
|
|
3232
3120
|
value: (
|
|
@@ -3238,32 +3126,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
3238
3126
|
* const result = await this.handleSalesSearchRequest('single', '/shop/es/search/sales', { keyword: '1001' }, {})
|
|
3239
3127
|
*/
|
|
3240
3128
|
function () {
|
|
3241
|
-
var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3242
|
-
var queryPayload, result,
|
|
3243
|
-
return _regeneratorRuntime().wrap(function
|
|
3244
|
-
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) {
|
|
3245
3133
|
case 0:
|
|
3246
3134
|
queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
|
|
3247
|
-
|
|
3135
|
+
_context38.next = 3;
|
|
3248
3136
|
return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
|
|
3249
3137
|
case 3:
|
|
3250
|
-
result =
|
|
3251
|
-
|
|
3138
|
+
result = _context38.sent;
|
|
3139
|
+
_ref55 = config || {}, callback = _ref55.callback, subscriberId = _ref55.subscriberId, resetVisibleOrderIds = _ref55.resetVisibleOrderIds;
|
|
3252
3140
|
if (subscriberId && typeof callback === 'function') {
|
|
3253
3141
|
contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
|
|
3254
3142
|
existing = this.salesSearchSubscribers.get(subscriberId);
|
|
3255
3143
|
shouldReset = resetVisibleOrderIds === true || !existing || existing.kind !== kind || existing.contextSignature !== contextSignature;
|
|
3256
3144
|
visibleOrderIds = shouldReset ? new Set() : new Set(existing.visibleOrderIds);
|
|
3257
|
-
|
|
3145
|
+
_iterator5 = _createForOfIteratorHelper(this.extractSalesSearchOrderIds(kind, result));
|
|
3258
3146
|
try {
|
|
3259
|
-
for (
|
|
3260
|
-
orderId =
|
|
3147
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
3148
|
+
orderId = _step5.value;
|
|
3261
3149
|
visibleOrderIds.add(orderId);
|
|
3262
3150
|
}
|
|
3263
3151
|
} catch (err) {
|
|
3264
|
-
|
|
3152
|
+
_iterator5.e(err);
|
|
3265
3153
|
} finally {
|
|
3266
|
-
|
|
3154
|
+
_iterator5.f();
|
|
3267
3155
|
}
|
|
3268
3156
|
this.salesSearchSubscribers.set(subscriberId, {
|
|
3269
3157
|
callback: callback,
|
|
@@ -3279,14 +3167,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
3279
3167
|
visibleCount: visibleOrderIds.size
|
|
3280
3168
|
});
|
|
3281
3169
|
}
|
|
3282
|
-
return
|
|
3170
|
+
return _context38.abrupt("return", result);
|
|
3283
3171
|
case 7:
|
|
3284
3172
|
case "end":
|
|
3285
|
-
return
|
|
3173
|
+
return _context38.stop();
|
|
3286
3174
|
}
|
|
3287
|
-
},
|
|
3175
|
+
}, _callee38, this);
|
|
3288
3176
|
}));
|
|
3289
|
-
function handleSalesSearchRequest(
|
|
3177
|
+
function handleSalesSearchRequest(_x37, _x38, _x39, _x40) {
|
|
3290
3178
|
return _handleSalesSearchRequest.apply(this, arguments);
|
|
3291
3179
|
}
|
|
3292
3180
|
return handleSalesSearchRequest;
|
|
@@ -3301,20 +3189,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
3301
3189
|
}, {
|
|
3302
3190
|
key: "fetchSalesSearchFromAPI",
|
|
3303
3191
|
value: (function () {
|
|
3304
|
-
var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3305
|
-
var _this$
|
|
3306
|
-
var _response$
|
|
3307
|
-
return _regeneratorRuntime().wrap(function
|
|
3308
|
-
while (1) switch (
|
|
3192
|
+
var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(backendPath, data) {
|
|
3193
|
+
var _this$app8;
|
|
3194
|
+
var _response$data4, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
|
|
3195
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3196
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3309
3197
|
case 0:
|
|
3310
|
-
if ((_this$
|
|
3311
|
-
|
|
3198
|
+
if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
|
|
3199
|
+
_context39.next = 3;
|
|
3312
3200
|
break;
|
|
3313
3201
|
}
|
|
3314
3202
|
this.logError('fetchSalesSearchFromAPI: app.request 不可用', {
|
|
3315
3203
|
backendPath: backendPath
|
|
3316
3204
|
});
|
|
3317
|
-
return
|
|
3205
|
+
return _context39.abrupt("return", {
|
|
3318
3206
|
code: 500,
|
|
3319
3207
|
message: 'app.request 不可用',
|
|
3320
3208
|
data: backendPath === '/shop/es/search' ? {
|
|
@@ -3326,29 +3214,29 @@ var Server = /*#__PURE__*/function () {
|
|
|
3326
3214
|
status: false
|
|
3327
3215
|
});
|
|
3328
3216
|
case 3:
|
|
3329
|
-
|
|
3330
|
-
|
|
3217
|
+
_context39.prev = 3;
|
|
3218
|
+
_context39.next = 6;
|
|
3331
3219
|
return this.app.request.post(backendPath, data, {
|
|
3332
3220
|
isShopApi: true
|
|
3333
3221
|
});
|
|
3334
3222
|
case 6:
|
|
3335
|
-
response =
|
|
3336
|
-
_payload = (_response$
|
|
3337
|
-
return
|
|
3338
|
-
code: (_response$
|
|
3339
|
-
status: (_response$
|
|
3340
|
-
message: (_response$
|
|
3223
|
+
response = _context39.sent;
|
|
3224
|
+
_payload = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
|
|
3225
|
+
return _context39.abrupt("return", {
|
|
3226
|
+
code: (_response$code2 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code2 !== void 0 ? _response$code2 : 200,
|
|
3227
|
+
status: (_response$status2 = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status2 !== void 0 ? _response$status2 : true,
|
|
3228
|
+
message: (_response$message2 = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message2 !== void 0 ? _response$message2 : '',
|
|
3341
3229
|
data: _payload
|
|
3342
3230
|
});
|
|
3343
3231
|
case 11:
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
errorMessage =
|
|
3232
|
+
_context39.prev = 11;
|
|
3233
|
+
_context39.t0 = _context39["catch"](3);
|
|
3234
|
+
errorMessage = _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0);
|
|
3347
3235
|
this.logError('fetchSalesSearchFromAPI: 请求失败', {
|
|
3348
3236
|
backendPath: backendPath,
|
|
3349
3237
|
error: errorMessage
|
|
3350
3238
|
});
|
|
3351
|
-
return
|
|
3239
|
+
return _context39.abrupt("return", {
|
|
3352
3240
|
code: 500,
|
|
3353
3241
|
message: errorMessage,
|
|
3354
3242
|
data: backendPath === '/shop/es/search' ? {
|
|
@@ -3361,11 +3249,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3361
3249
|
});
|
|
3362
3250
|
case 16:
|
|
3363
3251
|
case "end":
|
|
3364
|
-
return
|
|
3252
|
+
return _context39.stop();
|
|
3365
3253
|
}
|
|
3366
|
-
},
|
|
3254
|
+
}, _callee39, this, [[3, 11]]);
|
|
3367
3255
|
}));
|
|
3368
|
-
function fetchSalesSearchFromAPI(
|
|
3256
|
+
function fetchSalesSearchFromAPI(_x41, _x42) {
|
|
3369
3257
|
return _fetchSalesSearchFromAPI.apply(this, arguments);
|
|
3370
3258
|
}
|
|
3371
3259
|
return fetchSalesSearchFromAPI;
|
|
@@ -3395,10 +3283,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
3395
3283
|
}, {
|
|
3396
3284
|
key: "stripSalesSearchPageParams",
|
|
3397
3285
|
value: function stripSalesSearchPageParams(value) {
|
|
3398
|
-
var
|
|
3286
|
+
var _this7 = this;
|
|
3399
3287
|
if (Array.isArray(value)) {
|
|
3400
3288
|
return value.map(function (item) {
|
|
3401
|
-
return
|
|
3289
|
+
return _this7.stripSalesSearchPageParams(item);
|
|
3402
3290
|
});
|
|
3403
3291
|
}
|
|
3404
3292
|
if (!value || _typeof(value) !== 'object') return value;
|
|
@@ -3436,12 +3324,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
3436
3324
|
key: "extractSalesSearchOrderIds",
|
|
3437
3325
|
value: function extractSalesSearchOrderIds(kind, result) {
|
|
3438
3326
|
var _this$findSalesSearch,
|
|
3439
|
-
|
|
3327
|
+
_this8 = this;
|
|
3440
3328
|
var data = this.extractSalesSearchResponseData(result);
|
|
3441
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;
|
|
3442
3330
|
if (!Array.isArray(list)) return [];
|
|
3443
3331
|
return list.map(function (item) {
|
|
3444
|
-
return
|
|
3332
|
+
return _this8.getSalesSearchOrderId(item);
|
|
3445
3333
|
}).filter(function (id) {
|
|
3446
3334
|
return !!id;
|
|
3447
3335
|
});
|
|
@@ -3608,11 +3496,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3608
3496
|
}, {
|
|
3609
3497
|
key: "stableSerialize",
|
|
3610
3498
|
value: function stableSerialize(value) {
|
|
3611
|
-
var
|
|
3499
|
+
var _this9 = this;
|
|
3612
3500
|
if (value === null || value === undefined) return 'null';
|
|
3613
3501
|
if (Array.isArray(value)) {
|
|
3614
3502
|
return "[".concat(value.map(function (item) {
|
|
3615
|
-
return
|
|
3503
|
+
return _this9.stableSerialize(item);
|
|
3616
3504
|
}).join(','), "]");
|
|
3617
3505
|
}
|
|
3618
3506
|
if (_typeof(value) === 'object') {
|
|
@@ -3621,7 +3509,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3621
3509
|
return obj[k] !== undefined;
|
|
3622
3510
|
}).sort();
|
|
3623
3511
|
return "{".concat(keys.map(function (k) {
|
|
3624
|
-
return "".concat(JSON.stringify(k), ":").concat(
|
|
3512
|
+
return "".concat(JSON.stringify(k), ":").concat(_this9.stableSerialize(obj[k]));
|
|
3625
3513
|
}).join(','), "}");
|
|
3626
3514
|
}
|
|
3627
3515
|
return JSON.stringify(value);
|
|
@@ -3670,22 +3558,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
3670
3558
|
}
|
|
3671
3559
|
var oldestKey = null;
|
|
3672
3560
|
var oldestTime = Number.POSITIVE_INFINITY;
|
|
3673
|
-
var
|
|
3674
|
-
|
|
3561
|
+
var _iterator6 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
|
|
3562
|
+
_step6;
|
|
3675
3563
|
try {
|
|
3676
|
-
for (
|
|
3677
|
-
var
|
|
3678
|
-
_key3 =
|
|
3679
|
-
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];
|
|
3680
3568
|
if (cache.updatedAt < oldestTime) {
|
|
3681
3569
|
oldestTime = cache.updatedAt;
|
|
3682
3570
|
oldestKey = _key3;
|
|
3683
3571
|
}
|
|
3684
3572
|
}
|
|
3685
3573
|
} catch (err) {
|
|
3686
|
-
|
|
3574
|
+
_iterator6.e(err);
|
|
3687
3575
|
} finally {
|
|
3688
|
-
|
|
3576
|
+
_iterator6.f();
|
|
3689
3577
|
}
|
|
3690
3578
|
if (oldestKey) this.bookingRemoteCache.delete(oldestKey);
|
|
3691
3579
|
}
|
|
@@ -3701,17 +3589,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
3701
3589
|
key: "markBookingRemoteCacheAllStale",
|
|
3702
3590
|
value: function markBookingRemoteCacheAllStale(reason) {
|
|
3703
3591
|
if (this.bookingRemoteCache.size === 0) return;
|
|
3704
|
-
var
|
|
3705
|
-
|
|
3592
|
+
var _iterator7 = _createForOfIteratorHelper(this.bookingRemoteCache.values()),
|
|
3593
|
+
_step7;
|
|
3706
3594
|
try {
|
|
3707
|
-
for (
|
|
3708
|
-
var entry =
|
|
3595
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
3596
|
+
var entry = _step7.value;
|
|
3709
3597
|
entry.stale = true;
|
|
3710
3598
|
}
|
|
3711
3599
|
} catch (err) {
|
|
3712
|
-
|
|
3600
|
+
_iterator7.e(err);
|
|
3713
3601
|
} finally {
|
|
3714
|
-
|
|
3602
|
+
_iterator7.f();
|
|
3715
3603
|
}
|
|
3716
3604
|
this.logWarning('bookingRemoteCache: 全量标记失效', {
|
|
3717
3605
|
reason: reason,
|
|
@@ -3737,13 +3625,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
3737
3625
|
key: "notifyBookingRemoteSubscribersByCacheKey",
|
|
3738
3626
|
value: function notifyBookingRemoteSubscribersByCacheKey(cacheKey, entry, reason) {
|
|
3739
3627
|
if (this.bookingRemoteQuerySubscribers.size === 0) return;
|
|
3740
|
-
var
|
|
3741
|
-
|
|
3628
|
+
var _iterator8 = _createForOfIteratorHelper(this.bookingRemoteQuerySubscribers.entries()),
|
|
3629
|
+
_step8;
|
|
3742
3630
|
try {
|
|
3743
|
-
for (
|
|
3744
|
-
var
|
|
3745
|
-
subscriberId =
|
|
3746
|
-
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];
|
|
3747
3635
|
if (subscriber.cacheKey !== cacheKey) continue;
|
|
3748
3636
|
try {
|
|
3749
3637
|
var callbackStartAt = Date.now();
|
|
@@ -3770,9 +3658,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
3770
3658
|
}
|
|
3771
3659
|
}
|
|
3772
3660
|
} catch (err) {
|
|
3773
|
-
|
|
3661
|
+
_iterator8.e(err);
|
|
3774
3662
|
} finally {
|
|
3775
|
-
|
|
3663
|
+
_iterator8.f();
|
|
3776
3664
|
}
|
|
3777
3665
|
}
|
|
3778
3666
|
}, {
|
|
@@ -3787,13 +3675,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
3787
3675
|
return;
|
|
3788
3676
|
}
|
|
3789
3677
|
var syncedEntryCount = 0;
|
|
3790
|
-
var
|
|
3791
|
-
|
|
3678
|
+
var _iterator9 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
|
|
3679
|
+
_step9;
|
|
3792
3680
|
try {
|
|
3793
|
-
for (
|
|
3794
|
-
var
|
|
3795
|
-
cacheKey =
|
|
3796
|
-
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];
|
|
3797
3685
|
if (entry.stale) {
|
|
3798
3686
|
this.bookingRemoteCache.delete(cacheKey);
|
|
3799
3687
|
continue;
|
|
@@ -3801,25 +3689,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
3801
3689
|
try {
|
|
3802
3690
|
var queryPayload = entry.queryPayload;
|
|
3803
3691
|
var orderMap = new Map();
|
|
3804
|
-
var
|
|
3805
|
-
|
|
3692
|
+
var _iterator10 = _createForOfIteratorHelper(entry.rawOrders),
|
|
3693
|
+
_step10;
|
|
3806
3694
|
try {
|
|
3807
|
-
for (
|
|
3808
|
-
var order =
|
|
3695
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
3696
|
+
var order = _step10.value;
|
|
3809
3697
|
var _key4 = this.toOrderIdKey(order);
|
|
3810
3698
|
if (_key4) orderMap.set(_key4, order);
|
|
3811
3699
|
}
|
|
3812
3700
|
} catch (err) {
|
|
3813
|
-
|
|
3701
|
+
_iterator10.e(err);
|
|
3814
3702
|
} finally {
|
|
3815
|
-
|
|
3703
|
+
_iterator10.f();
|
|
3816
3704
|
}
|
|
3817
3705
|
var changed = false;
|
|
3818
|
-
var
|
|
3819
|
-
|
|
3706
|
+
var _iterator11 = _createForOfIteratorHelper(latestOrders),
|
|
3707
|
+
_step11;
|
|
3820
3708
|
try {
|
|
3821
|
-
for (
|
|
3822
|
-
var latest =
|
|
3709
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
3710
|
+
var latest = _step11.value;
|
|
3823
3711
|
var _key5 = this.toOrderIdKey(latest);
|
|
3824
3712
|
if (!_key5) continue;
|
|
3825
3713
|
if (orderMap.has(_key5)) {
|
|
@@ -3831,9 +3719,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
3831
3719
|
changed = true;
|
|
3832
3720
|
}
|
|
3833
3721
|
} catch (err) {
|
|
3834
|
-
|
|
3722
|
+
_iterator11.e(err);
|
|
3835
3723
|
} finally {
|
|
3836
|
-
|
|
3724
|
+
_iterator11.f();
|
|
3837
3725
|
}
|
|
3838
3726
|
if (!changed) continue;
|
|
3839
3727
|
var mergedOrders = _toConsumableArray(orderMap.values());
|
|
@@ -3866,9 +3754,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
3866
3754
|
}
|
|
3867
3755
|
}
|
|
3868
3756
|
} catch (err) {
|
|
3869
|
-
|
|
3757
|
+
_iterator9.e(err);
|
|
3870
3758
|
} finally {
|
|
3871
|
-
|
|
3759
|
+
_iterator9.f();
|
|
3872
3760
|
}
|
|
3873
3761
|
var syncEndAt = Date.now();
|
|
3874
3762
|
if (syncedEntryCount > 0) {
|
|
@@ -3886,18 +3774,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
3886
3774
|
}, {
|
|
3887
3775
|
key: "fetchOrderListFromAPI",
|
|
3888
3776
|
value: (function () {
|
|
3889
|
-
var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3890
|
-
var _this$
|
|
3891
|
-
var _response$
|
|
3892
|
-
return _regeneratorRuntime().wrap(function
|
|
3893
|
-
while (1) switch (
|
|
3777
|
+
var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(data) {
|
|
3778
|
+
var _this$app9;
|
|
3779
|
+
var _response$data5, response, _payload2, list, count, errorMessage;
|
|
3780
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3781
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3894
3782
|
case 0:
|
|
3895
|
-
if ((_this$
|
|
3896
|
-
|
|
3783
|
+
if ((_this$app9 = this.app) !== null && _this$app9 !== void 0 && _this$app9.request) {
|
|
3784
|
+
_context40.next = 3;
|
|
3897
3785
|
break;
|
|
3898
3786
|
}
|
|
3899
3787
|
this.logError('fetchOrderListFromAPI: app.request 不可用');
|
|
3900
|
-
return
|
|
3788
|
+
return _context40.abrupt("return", {
|
|
3901
3789
|
code: 500,
|
|
3902
3790
|
message: 'app.request 不可用',
|
|
3903
3791
|
data: {
|
|
@@ -3907,17 +3795,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
3907
3795
|
status: false
|
|
3908
3796
|
});
|
|
3909
3797
|
case 3:
|
|
3910
|
-
|
|
3911
|
-
|
|
3798
|
+
_context40.prev = 3;
|
|
3799
|
+
_context40.next = 6;
|
|
3912
3800
|
return this.app.request.post('/shop/order/v2/list', data, {
|
|
3913
3801
|
isShopApi: true
|
|
3914
3802
|
});
|
|
3915
3803
|
case 6:
|
|
3916
|
-
response =
|
|
3917
|
-
_payload2 = (_response$
|
|
3804
|
+
response = _context40.sent;
|
|
3805
|
+
_payload2 = (_response$data5 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data5 !== void 0 ? _response$data5 : response;
|
|
3918
3806
|
list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
|
|
3919
3807
|
count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
|
|
3920
|
-
return
|
|
3808
|
+
return _context40.abrupt("return", {
|
|
3921
3809
|
code: 200,
|
|
3922
3810
|
data: _objectSpread(_objectSpread({}, _payload2), {}, {
|
|
3923
3811
|
list: list,
|
|
@@ -3927,13 +3815,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
3927
3815
|
status: true
|
|
3928
3816
|
});
|
|
3929
3817
|
case 13:
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
errorMessage =
|
|
3818
|
+
_context40.prev = 13;
|
|
3819
|
+
_context40.t0 = _context40["catch"](3);
|
|
3820
|
+
errorMessage = _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0);
|
|
3933
3821
|
this.logError('fetchOrderListFromAPI: 请求失败', {
|
|
3934
3822
|
error: errorMessage
|
|
3935
3823
|
});
|
|
3936
|
-
return
|
|
3824
|
+
return _context40.abrupt("return", {
|
|
3937
3825
|
code: 500,
|
|
3938
3826
|
message: errorMessage,
|
|
3939
3827
|
data: {
|
|
@@ -3944,11 +3832,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3944
3832
|
});
|
|
3945
3833
|
case 18:
|
|
3946
3834
|
case "end":
|
|
3947
|
-
return
|
|
3835
|
+
return _context40.stop();
|
|
3948
3836
|
}
|
|
3949
|
-
},
|
|
3837
|
+
}, _callee40, this, [[3, 13]]);
|
|
3950
3838
|
}));
|
|
3951
|
-
function fetchOrderListFromAPI(
|
|
3839
|
+
function fetchOrderListFromAPI(_x43) {
|
|
3952
3840
|
return _fetchOrderListFromAPI.apply(this, arguments);
|
|
3953
3841
|
}
|
|
3954
3842
|
return fetchOrderListFromAPI;
|
|
@@ -3960,17 +3848,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
3960
3848
|
}, {
|
|
3961
3849
|
key: "fetchBookingListFromAPI",
|
|
3962
3850
|
value: (function () {
|
|
3963
|
-
var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3851
|
+
var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(data) {
|
|
3964
3852
|
var memoryCacheEnabled, withFields, requestPayload, cacheKey, cached, rawList, bookingResult, _bookingResult$list, errorMessage;
|
|
3965
|
-
return _regeneratorRuntime().wrap(function
|
|
3966
|
-
while (1) switch (
|
|
3853
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3854
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3967
3855
|
case 0:
|
|
3968
3856
|
if (this.order) {
|
|
3969
|
-
|
|
3857
|
+
_context41.next = 3;
|
|
3970
3858
|
break;
|
|
3971
3859
|
}
|
|
3972
3860
|
this.logError('fetchBookingListFromAPI: Order 模块不可用');
|
|
3973
|
-
return
|
|
3861
|
+
return _context41.abrupt("return", {
|
|
3974
3862
|
code: 500,
|
|
3975
3863
|
message: 'Order 模块不可用',
|
|
3976
3864
|
data: {
|
|
@@ -3980,18 +3868,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
3980
3868
|
status: false
|
|
3981
3869
|
});
|
|
3982
3870
|
case 3:
|
|
3983
|
-
|
|
3871
|
+
_context41.prev = 3;
|
|
3984
3872
|
memoryCacheEnabled = this.isBookingRemoteMemoryCacheEnabled(data);
|
|
3985
3873
|
withFields = this.resolveBookingSalesWith(data);
|
|
3986
3874
|
requestPayload = this.normalizeBookingRemoteQueryPayload(data, withFields);
|
|
3987
3875
|
cacheKey = this.buildBookingRemoteCacheKey(requestPayload);
|
|
3988
3876
|
if (!memoryCacheEnabled) {
|
|
3989
|
-
|
|
3877
|
+
_context41.next = 13;
|
|
3990
3878
|
break;
|
|
3991
3879
|
}
|
|
3992
3880
|
cached = this.readBookingRemoteCache(cacheKey);
|
|
3993
3881
|
if (!cached) {
|
|
3994
|
-
|
|
3882
|
+
_context41.next = 13;
|
|
3995
3883
|
break;
|
|
3996
3884
|
}
|
|
3997
3885
|
this.logInfo('fetchBookingListFromAPI: 命中内存缓存', {
|
|
@@ -3999,14 +3887,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
3999
3887
|
listCount: cached.bookingResult.count,
|
|
4000
3888
|
withFields: cached.withFields
|
|
4001
3889
|
});
|
|
4002
|
-
return
|
|
3890
|
+
return _context41.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
|
|
4003
3891
|
cache_hit: true
|
|
4004
3892
|
}));
|
|
4005
3893
|
case 13:
|
|
4006
|
-
|
|
3894
|
+
_context41.next = 15;
|
|
4007
3895
|
return this.order.fetchOrdersBySSE(requestPayload);
|
|
4008
3896
|
case 15:
|
|
4009
|
-
rawList =
|
|
3897
|
+
rawList = _context41.sent;
|
|
4010
3898
|
bookingResult = sortBookings(filterBookingsFromOrders(rawList, data), data); // DEBUG: 挂到 window 上方便排查 SSE → 日历数据丢失问题
|
|
4011
3899
|
if (typeof globalThis !== 'undefined') {
|
|
4012
3900
|
globalThis.__SSE_BOOKING_DEBUG__ = {
|
|
@@ -4053,15 +3941,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
4053
3941
|
cacheKey: cacheKey,
|
|
4054
3942
|
withFields: withFields
|
|
4055
3943
|
});
|
|
4056
|
-
return
|
|
3944
|
+
return _context41.abrupt("return", this.buildBookingResponse(bookingResult));
|
|
4057
3945
|
case 23:
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
errorMessage =
|
|
3946
|
+
_context41.prev = 23;
|
|
3947
|
+
_context41.t0 = _context41["catch"](3);
|
|
3948
|
+
errorMessage = _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0);
|
|
4061
3949
|
this.logError('fetchBookingListFromAPI: SSE 请求失败', {
|
|
4062
3950
|
error: errorMessage
|
|
4063
3951
|
});
|
|
4064
|
-
return
|
|
3952
|
+
return _context41.abrupt("return", {
|
|
4065
3953
|
code: 500,
|
|
4066
3954
|
message: errorMessage,
|
|
4067
3955
|
data: {
|
|
@@ -4072,11 +3960,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4072
3960
|
});
|
|
4073
3961
|
case 28:
|
|
4074
3962
|
case "end":
|
|
4075
|
-
return
|
|
3963
|
+
return _context41.stop();
|
|
4076
3964
|
}
|
|
4077
|
-
},
|
|
3965
|
+
}, _callee41, this, [[3, 23]]);
|
|
4078
3966
|
}));
|
|
4079
|
-
function fetchBookingListFromAPI(
|
|
3967
|
+
function fetchBookingListFromAPI(_x44) {
|
|
4080
3968
|
return _fetchBookingListFromAPI.apply(this, arguments);
|
|
4081
3969
|
}
|
|
4082
3970
|
return fetchBookingListFromAPI;
|
|
@@ -4084,24 +3972,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
4084
3972
|
}, {
|
|
4085
3973
|
key: "getDeviceTaskPlugin",
|
|
4086
3974
|
value: function getDeviceTaskPlugin() {
|
|
4087
|
-
var _this$
|
|
4088
|
-
return ((_this$
|
|
3975
|
+
var _this$app10, _this$app10$getPlugin;
|
|
3976
|
+
return ((_this$app10 = this.app) === null || _this$app10 === void 0 || (_this$app10$getPlugin = _this$app10.getPlugin) === null || _this$app10$getPlugin === void 0 ? void 0 : _this$app10$getPlugin.call(_this$app10, 'deviceTask')) || null;
|
|
4089
3977
|
}
|
|
4090
3978
|
}, {
|
|
4091
3979
|
key: "getIdGeneratorPlugin",
|
|
4092
3980
|
value: function getIdGeneratorPlugin() {
|
|
4093
|
-
var _this$
|
|
4094
|
-
return ((_this$
|
|
3981
|
+
var _this$app11, _this$app11$getPlugin;
|
|
3982
|
+
return ((_this$app11 = this.app) === null || _this$app11 === void 0 || (_this$app11$getPlugin = _this$app11.getPlugin) === null || _this$app11$getPlugin === void 0 ? void 0 : _this$app11$getPlugin.call(_this$app11, 'idGenerator')) || null;
|
|
4095
3983
|
}
|
|
4096
3984
|
}, {
|
|
4097
3985
|
key: "getAppData",
|
|
4098
3986
|
value: function getAppData(key) {
|
|
4099
|
-
var _this$core$getPlugin, _this$core$getPlugin$, _this$
|
|
3987
|
+
var _this$core$getPlugin, _this$core$getPlugin$, _this$app12, _this$app12$getData, _this$app13, _this$app13$getStore, _this$app13$getStore$, _this$app13$getStore$2, _this$app14, _this$app14$getStore, _this$app14$getStore$, _this$app14$getStore$2, _this$app15, _this$app15$getStore, _this$app15$getStore$, _this$app15$getStore$2;
|
|
4100
3988
|
var getData = (_this$core$getPlugin = this.core.getPlugin('app')) === null || _this$core$getPlugin === void 0 || (_this$core$getPlugin$ = _this$core$getPlugin.getData) === null || _this$core$getPlugin$ === void 0 ? void 0 : _this$core$getPlugin$.call(_this$core$getPlugin);
|
|
4101
3989
|
if (typeof getData === 'function') return getData(key);
|
|
4102
|
-
var directValue = (_this$
|
|
3990
|
+
var directValue = (_this$app12 = this.app) === null || _this$app12 === void 0 || (_this$app12$getData = _this$app12.getData) === null || _this$app12$getData === void 0 ? void 0 : _this$app12$getData.call(_this$app12, key);
|
|
4103
3991
|
if (directValue !== undefined) return directValue;
|
|
4104
|
-
var coreData = ((_this$
|
|
3992
|
+
var coreData = ((_this$app13 = this.app) === null || _this$app13 === void 0 || (_this$app13 = _this$app13.models) === null || _this$app13 === void 0 || (_this$app13$getStore = _this$app13.getStore) === null || _this$app13$getStore === void 0 || (_this$app13$getStore$ = (_this$app13$getStore$2 = _this$app13$getStore.call(_this$app13)).getDataByModel) === null || _this$app13$getStore$ === void 0 ? void 0 : _this$app13$getStore$.call(_this$app13$getStore$2, 'core', 'core')) || ((_this$app14 = this.app) === null || _this$app14 === void 0 || (_this$app14 = _this$app14.data) === null || _this$app14 === void 0 || (_this$app14 = _this$app14.store) === null || _this$app14 === void 0 || (_this$app14$getStore = _this$app14.getStore) === null || _this$app14$getStore === void 0 || (_this$app14$getStore$ = (_this$app14$getStore$2 = _this$app14$getStore.call(_this$app14)).getDataByModel) === null || _this$app14$getStore$ === void 0 ? void 0 : _this$app14$getStore$.call(_this$app14$getStore$2, 'core', 'core')) || ((_this$app15 = this.app) === null || _this$app15 === void 0 || (_this$app15 = _this$app15.data) === null || _this$app15 === void 0 || (_this$app15 = _this$app15.store) === null || _this$app15 === void 0 || (_this$app15$getStore = _this$app15.getStore) === null || _this$app15$getStore === void 0 || (_this$app15$getStore$ = (_this$app15$getStore$2 = _this$app15$getStore.call(_this$app15)).getDataByModel) === null || _this$app15$getStore$ === void 0 || (_this$app15$getStore$ = _this$app15$getStore$.call(_this$app15$getStore$2, 'core')) === null || _this$app15$getStore$ === void 0 ? void 0 : _this$app15$getStore$.core);
|
|
4105
3993
|
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
4106
3994
|
}
|
|
4107
3995
|
}, {
|
|
@@ -4152,32 +4040,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
4152
4040
|
}, {
|
|
4153
4041
|
key: "getShortNumberOrDeviceId",
|
|
4154
4042
|
value: function () {
|
|
4155
|
-
var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4043
|
+
var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
|
|
4156
4044
|
var getAsyncIotDeviceInfo, res;
|
|
4157
|
-
return _regeneratorRuntime().wrap(function
|
|
4158
|
-
while (1) switch (
|
|
4045
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
4046
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
4159
4047
|
case 0:
|
|
4160
4048
|
getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
|
|
4161
4049
|
if (!getAsyncIotDeviceInfo) {
|
|
4162
|
-
|
|
4050
|
+
_context42.next = 7;
|
|
4163
4051
|
break;
|
|
4164
4052
|
}
|
|
4165
|
-
|
|
4053
|
+
_context42.next = 4;
|
|
4166
4054
|
return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
|
|
4167
4055
|
case 4:
|
|
4168
|
-
res =
|
|
4056
|
+
res = _context42.sent;
|
|
4169
4057
|
if (!(res !== null && res !== void 0 && res.short_number)) {
|
|
4170
|
-
|
|
4058
|
+
_context42.next = 7;
|
|
4171
4059
|
break;
|
|
4172
4060
|
}
|
|
4173
|
-
return
|
|
4061
|
+
return _context42.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
|
|
4174
4062
|
case 7:
|
|
4175
|
-
return
|
|
4063
|
+
return _context42.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
|
|
4176
4064
|
case 8:
|
|
4177
4065
|
case "end":
|
|
4178
|
-
return
|
|
4066
|
+
return _context42.stop();
|
|
4179
4067
|
}
|
|
4180
|
-
},
|
|
4068
|
+
}, _callee42, this);
|
|
4181
4069
|
}));
|
|
4182
4070
|
function getShortNumberOrDeviceId() {
|
|
4183
4071
|
return _getShortNumberOrDeviceId.apply(this, arguments);
|
|
@@ -4204,16 +4092,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
4204
4092
|
}, {
|
|
4205
4093
|
key: "normalizeCheckoutSubmitData",
|
|
4206
4094
|
value: function () {
|
|
4207
|
-
var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4095
|
+
var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(data, title) {
|
|
4208
4096
|
var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
|
|
4209
|
-
return _regeneratorRuntime().wrap(function
|
|
4210
|
-
while (1) switch (
|
|
4097
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4098
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
4211
4099
|
case 0:
|
|
4212
4100
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
4213
|
-
|
|
4101
|
+
_context43.next = 2;
|
|
4214
4102
|
break;
|
|
4215
4103
|
}
|
|
4216
|
-
return
|
|
4104
|
+
return _context43.abrupt("return", data);
|
|
4217
4105
|
case 2:
|
|
4218
4106
|
next = _objectSpread({}, data);
|
|
4219
4107
|
externalSaleNumber = next.external_sale_number;
|
|
@@ -4223,7 +4111,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4223
4111
|
delete next.vouchers;
|
|
4224
4112
|
hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
|
|
4225
4113
|
if (!hasCheckoutOrderNumbers) {
|
|
4226
|
-
|
|
4114
|
+
_context43.next = 11;
|
|
4227
4115
|
break;
|
|
4228
4116
|
}
|
|
4229
4117
|
this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
|
|
@@ -4233,10 +4121,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
4233
4121
|
shop_order_number: next.shop_order_number,
|
|
4234
4122
|
shop_full_order_number: next.shop_full_order_number
|
|
4235
4123
|
});
|
|
4236
|
-
return
|
|
4124
|
+
return _context43.abrupt("return", next);
|
|
4237
4125
|
case 11:
|
|
4238
4126
|
if (!this.isBlankCheckoutValue(externalSaleNumber)) {
|
|
4239
|
-
|
|
4127
|
+
_context43.next = 14;
|
|
4240
4128
|
break;
|
|
4241
4129
|
}
|
|
4242
4130
|
if (shouldClearLocalOrderId) {
|
|
@@ -4245,10 +4133,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
4245
4133
|
order_id: next.order_id
|
|
4246
4134
|
});
|
|
4247
4135
|
}
|
|
4248
|
-
return
|
|
4136
|
+
return _context43.abrupt("return", next);
|
|
4249
4137
|
case 14:
|
|
4250
4138
|
if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
|
|
4251
|
-
|
|
4139
|
+
_context43.next = 17;
|
|
4252
4140
|
break;
|
|
4253
4141
|
}
|
|
4254
4142
|
if (shouldClearLocalOrderId) {
|
|
@@ -4257,12 +4145,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
4257
4145
|
external_sale_number: externalSaleNumber
|
|
4258
4146
|
});
|
|
4259
4147
|
}
|
|
4260
|
-
return
|
|
4148
|
+
return _context43.abrupt("return", next);
|
|
4261
4149
|
case 17:
|
|
4262
|
-
|
|
4150
|
+
_context43.prev = 17;
|
|
4263
4151
|
localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
|
|
4264
4152
|
if (localOrder) {
|
|
4265
|
-
|
|
4153
|
+
_context43.next = 22;
|
|
4266
4154
|
break;
|
|
4267
4155
|
}
|
|
4268
4156
|
if (shouldClearLocalOrderId) {
|
|
@@ -4272,7 +4160,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4272
4160
|
localOrderFound: false
|
|
4273
4161
|
});
|
|
4274
4162
|
}
|
|
4275
|
-
return
|
|
4163
|
+
return _context43.abrupt("return", next);
|
|
4276
4164
|
case 22:
|
|
4277
4165
|
if (this.isBlankCheckoutValue(next.shop_order_number)) {
|
|
4278
4166
|
next.shop_order_number = localOrder.shop_order_number;
|
|
@@ -4289,23 +4177,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
4289
4177
|
shop_full_order_number: next.shop_full_order_number
|
|
4290
4178
|
});
|
|
4291
4179
|
// 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
|
|
4292
|
-
return
|
|
4180
|
+
return _context43.abrupt("return", next);
|
|
4293
4181
|
case 28:
|
|
4294
|
-
|
|
4295
|
-
|
|
4182
|
+
_context43.prev = 28;
|
|
4183
|
+
_context43.t0 = _context43["catch"](17);
|
|
4296
4184
|
this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
|
|
4297
4185
|
external_sale_number: externalSaleNumber,
|
|
4298
|
-
error: this.getUnknownErrorMessage(
|
|
4299
|
-
error_detail: this.normalizeUnknownError(
|
|
4186
|
+
error: this.getUnknownErrorMessage(_context43.t0),
|
|
4187
|
+
error_detail: this.normalizeUnknownError(_context43.t0)
|
|
4300
4188
|
});
|
|
4301
|
-
return
|
|
4189
|
+
return _context43.abrupt("return", next);
|
|
4302
4190
|
case 32:
|
|
4303
4191
|
case "end":
|
|
4304
|
-
return
|
|
4192
|
+
return _context43.stop();
|
|
4305
4193
|
}
|
|
4306
|
-
},
|
|
4194
|
+
}, _callee43, this, [[17, 28]]);
|
|
4307
4195
|
}));
|
|
4308
|
-
function normalizeCheckoutSubmitData(
|
|
4196
|
+
function normalizeCheckoutSubmitData(_x45, _x46) {
|
|
4309
4197
|
return _normalizeCheckoutSubmitData.apply(this, arguments);
|
|
4310
4198
|
}
|
|
4311
4199
|
return normalizeCheckoutSubmitData;
|
|
@@ -4313,81 +4201,81 @@ var Server = /*#__PURE__*/function () {
|
|
|
4313
4201
|
}, {
|
|
4314
4202
|
key: "ensureCheckoutOrderNumbers",
|
|
4315
4203
|
value: function () {
|
|
4316
|
-
var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4204
|
+
var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(data, title) {
|
|
4317
4205
|
var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
|
|
4318
|
-
return _regeneratorRuntime().wrap(function
|
|
4319
|
-
while (1) switch (
|
|
4206
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4207
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
4320
4208
|
case 0:
|
|
4321
4209
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
4322
|
-
|
|
4210
|
+
_context44.next = 2;
|
|
4323
4211
|
break;
|
|
4324
4212
|
}
|
|
4325
|
-
return
|
|
4213
|
+
return _context44.abrupt("return", data);
|
|
4326
4214
|
case 2:
|
|
4327
4215
|
next = _objectSpread({}, data);
|
|
4328
4216
|
needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
|
|
4329
4217
|
needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
|
|
4330
4218
|
if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
|
|
4331
|
-
|
|
4219
|
+
_context44.next = 7;
|
|
4332
4220
|
break;
|
|
4333
4221
|
}
|
|
4334
|
-
return
|
|
4222
|
+
return _context44.abrupt("return", next);
|
|
4335
4223
|
case 7:
|
|
4336
4224
|
idGenerator = this.getIdGeneratorPlugin();
|
|
4337
4225
|
if (idGenerator) {
|
|
4338
|
-
|
|
4226
|
+
_context44.next = 11;
|
|
4339
4227
|
break;
|
|
4340
4228
|
}
|
|
4341
4229
|
this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
|
|
4342
4230
|
needsShopOrderNumber: needsShopOrderNumber,
|
|
4343
4231
|
needsShopFullOrderNumber: needsShopFullOrderNumber
|
|
4344
4232
|
});
|
|
4345
|
-
return
|
|
4233
|
+
return _context44.abrupt("return", next);
|
|
4346
4234
|
case 11:
|
|
4347
|
-
|
|
4235
|
+
_context44.prev = 11;
|
|
4348
4236
|
if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
|
|
4349
|
-
|
|
4237
|
+
_context44.next = 16;
|
|
4350
4238
|
break;
|
|
4351
4239
|
}
|
|
4352
|
-
|
|
4240
|
+
_context44.next = 15;
|
|
4353
4241
|
return idGenerator.generateShopOrderNumber({
|
|
4354
4242
|
biz: next.business_code || 'ticket'
|
|
4355
4243
|
});
|
|
4356
4244
|
case 15:
|
|
4357
|
-
next.shop_order_number =
|
|
4245
|
+
next.shop_order_number = _context44.sent;
|
|
4358
4246
|
case 16:
|
|
4359
4247
|
if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
|
|
4360
|
-
|
|
4248
|
+
_context44.next = 20;
|
|
4361
4249
|
break;
|
|
4362
4250
|
}
|
|
4363
|
-
|
|
4251
|
+
_context44.next = 19;
|
|
4364
4252
|
return idGenerator.generateReceiptId({
|
|
4365
4253
|
biz: next.business_code || 'ticket'
|
|
4366
4254
|
});
|
|
4367
4255
|
case 19:
|
|
4368
|
-
next.shop_full_order_number =
|
|
4256
|
+
next.shop_full_order_number = _context44.sent;
|
|
4369
4257
|
case 20:
|
|
4370
4258
|
this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
|
|
4371
4259
|
shop_order_number: next.shop_order_number,
|
|
4372
4260
|
shop_full_order_number: next.shop_full_order_number
|
|
4373
4261
|
});
|
|
4374
|
-
|
|
4262
|
+
_context44.next = 26;
|
|
4375
4263
|
break;
|
|
4376
4264
|
case 23:
|
|
4377
|
-
|
|
4378
|
-
|
|
4265
|
+
_context44.prev = 23;
|
|
4266
|
+
_context44.t0 = _context44["catch"](11);
|
|
4379
4267
|
this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
|
|
4380
|
-
error:
|
|
4268
|
+
error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
|
|
4381
4269
|
});
|
|
4382
4270
|
case 26:
|
|
4383
|
-
return
|
|
4271
|
+
return _context44.abrupt("return", next);
|
|
4384
4272
|
case 27:
|
|
4385
4273
|
case "end":
|
|
4386
|
-
return
|
|
4274
|
+
return _context44.stop();
|
|
4387
4275
|
}
|
|
4388
|
-
},
|
|
4276
|
+
}, _callee44, this, [[11, 23]]);
|
|
4389
4277
|
}));
|
|
4390
|
-
function ensureCheckoutOrderNumbers(
|
|
4278
|
+
function ensureCheckoutOrderNumbers(_x47, _x48) {
|
|
4391
4279
|
return _ensureCheckoutOrderNumbers.apply(this, arguments);
|
|
4392
4280
|
}
|
|
4393
4281
|
return ensureCheckoutOrderNumbers;
|
|
@@ -4395,27 +4283,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
4395
4283
|
}, {
|
|
4396
4284
|
key: "dispatchCheckoutSyncTask",
|
|
4397
4285
|
value: function () {
|
|
4398
|
-
var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4286
|
+
var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
|
|
4399
4287
|
var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
|
|
4400
|
-
return _regeneratorRuntime().wrap(function
|
|
4401
|
-
while (1) switch (
|
|
4288
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
4289
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4402
4290
|
case 0:
|
|
4403
4291
|
this.registerDeviceTaskActions();
|
|
4404
4292
|
deviceTask = this.getDeviceTaskPlugin();
|
|
4405
|
-
|
|
4293
|
+
_context45.next = 4;
|
|
4406
4294
|
return this.getShortNumberOrDeviceId();
|
|
4407
4295
|
case 4:
|
|
4408
|
-
debugDeviceId =
|
|
4296
|
+
debugDeviceId = _context45.sent;
|
|
4409
4297
|
debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
|
|
4410
4298
|
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
4411
|
-
|
|
4299
|
+
_context45.next = 9;
|
|
4412
4300
|
break;
|
|
4413
4301
|
}
|
|
4414
4302
|
this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
|
|
4415
|
-
return
|
|
4303
|
+
return _context45.abrupt("return");
|
|
4416
4304
|
case 9:
|
|
4417
|
-
|
|
4418
|
-
|
|
4305
|
+
_context45.prev = 9;
|
|
4306
|
+
_context45.next = 12;
|
|
4419
4307
|
return deviceTask.dispatch({
|
|
4420
4308
|
action: 'sync_sales',
|
|
4421
4309
|
device_id: debugDeviceId,
|
|
@@ -4433,27 +4321,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
4433
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)
|
|
4434
4322
|
});
|
|
4435
4323
|
case 12:
|
|
4436
|
-
result =
|
|
4324
|
+
result = _context45.sent;
|
|
4437
4325
|
this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
|
|
4438
4326
|
uuid: result === null || result === void 0 ? void 0 : result.uuid,
|
|
4439
4327
|
status: result === null || result === void 0 ? void 0 : result.status,
|
|
4440
4328
|
reused: result === null || result === void 0 ? void 0 : result.reused
|
|
4441
4329
|
});
|
|
4442
|
-
|
|
4330
|
+
_context45.next = 19;
|
|
4443
4331
|
break;
|
|
4444
4332
|
case 16:
|
|
4445
|
-
|
|
4446
|
-
|
|
4333
|
+
_context45.prev = 16;
|
|
4334
|
+
_context45.t0 = _context45["catch"](9);
|
|
4447
4335
|
this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
|
|
4448
|
-
error:
|
|
4336
|
+
error: _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0)
|
|
4449
4337
|
});
|
|
4450
4338
|
case 19:
|
|
4451
4339
|
case "end":
|
|
4452
|
-
return
|
|
4340
|
+
return _context45.stop();
|
|
4453
4341
|
}
|
|
4454
|
-
},
|
|
4342
|
+
}, _callee45, this, [[9, 16]]);
|
|
4455
4343
|
}));
|
|
4456
|
-
function dispatchCheckoutSyncTask(
|
|
4344
|
+
function dispatchCheckoutSyncTask(_x49) {
|
|
4457
4345
|
return _dispatchCheckoutSyncTask.apply(this, arguments);
|
|
4458
4346
|
}
|
|
4459
4347
|
return dispatchCheckoutSyncTask;
|
|
@@ -4461,34 +4349,36 @@ var Server = /*#__PURE__*/function () {
|
|
|
4461
4349
|
}, {
|
|
4462
4350
|
key: "dispatchPrintOtherReceiptTask",
|
|
4463
4351
|
value: function () {
|
|
4464
|
-
var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4352
|
+
var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
|
|
4465
4353
|
var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
|
|
4466
|
-
return _regeneratorRuntime().wrap(function
|
|
4467
|
-
while (1) switch (
|
|
4354
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
4355
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4468
4356
|
case 0:
|
|
4469
4357
|
deviceTask = this.getDeviceTaskPlugin();
|
|
4470
4358
|
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
4471
|
-
|
|
4359
|
+
_context46.next = 4;
|
|
4472
4360
|
break;
|
|
4473
4361
|
}
|
|
4474
4362
|
this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
|
|
4475
|
-
return
|
|
4363
|
+
return _context46.abrupt("return");
|
|
4476
4364
|
case 4:
|
|
4477
|
-
|
|
4365
|
+
_context46.prev = 4;
|
|
4478
4366
|
printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
|
|
4479
|
-
|
|
4367
|
+
_context46.next = 8;
|
|
4480
4368
|
return this.getShortNumberOrDeviceId();
|
|
4481
4369
|
case 8:
|
|
4482
|
-
deviceId =
|
|
4483
|
-
|
|
4370
|
+
deviceId = _context46.sent;
|
|
4371
|
+
_context46.next = 11;
|
|
4484
4372
|
return deviceTask.dispatch({
|
|
4485
4373
|
action: 'print_all',
|
|
4486
4374
|
device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
|
|
4487
4375
|
payload: {
|
|
4488
|
-
type: params.
|
|
4376
|
+
type: params.isManualPrint ? '0' : '99',
|
|
4489
4377
|
data: params.receiptOnly ? {
|
|
4490
4378
|
order_id: printIdentity,
|
|
4491
|
-
small_ticket_data: (_params$syncedOrder = params.syncedOrder) === null || _params$syncedOrder === void 0 || (_params$syncedOrder = _params$syncedOrder.payment_info) === null || _params$syncedOrder === void 0 ? void 0 : _params$syncedOrder.small_ticket_data
|
|
4379
|
+
small_ticket_data: (_params$syncedOrder = params.syncedOrder) === null || _params$syncedOrder === void 0 || (_params$syncedOrder = _params$syncedOrder.payment_info) === null || _params$syncedOrder === void 0 ? void 0 : _params$syncedOrder.small_ticket_data,
|
|
4380
|
+
skip_wristband: true,
|
|
4381
|
+
skip_voucher: true
|
|
4492
4382
|
} : {
|
|
4493
4383
|
order_id: printIdentity,
|
|
4494
4384
|
machine_code_print_info: (_params$syncedOrder2 = params.syncedOrder) === null || _params$syncedOrder2 === void 0 || (_params$syncedOrder2 = _params$syncedOrder2.payment_info) === null || _params$syncedOrder2 === void 0 ? void 0 : _params$syncedOrder2.machine_code_print_info,
|
|
@@ -4499,27 +4389,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
4499
4389
|
idempotency_key: this.buildPrintOtherReceiptIdempotencyKey(params.syncedOrder, {
|
|
4500
4390
|
receiptOnly: params.receiptOnly
|
|
4501
4391
|
}),
|
|
4502
|
-
name: '
|
|
4392
|
+
name: 'PRINT_V1',
|
|
4503
4393
|
source: 'server',
|
|
4504
4394
|
source_type: 'order',
|
|
4505
4395
|
source_id: printIdentity
|
|
4506
4396
|
});
|
|
4507
4397
|
case 11:
|
|
4508
|
-
|
|
4398
|
+
_context46.next = 16;
|
|
4509
4399
|
break;
|
|
4510
4400
|
case 13:
|
|
4511
|
-
|
|
4512
|
-
|
|
4401
|
+
_context46.prev = 13;
|
|
4402
|
+
_context46.t0 = _context46["catch"](4);
|
|
4513
4403
|
this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
|
|
4514
|
-
error:
|
|
4404
|
+
error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
|
|
4515
4405
|
});
|
|
4516
4406
|
case 16:
|
|
4517
4407
|
case "end":
|
|
4518
|
-
return
|
|
4408
|
+
return _context46.stop();
|
|
4519
4409
|
}
|
|
4520
|
-
},
|
|
4410
|
+
}, _callee46, this, [[4, 13]]);
|
|
4521
4411
|
}));
|
|
4522
|
-
function dispatchPrintOtherReceiptTask(
|
|
4412
|
+
function dispatchPrintOtherReceiptTask(_x50) {
|
|
4523
4413
|
return _dispatchPrintOtherReceiptTask.apply(this, arguments);
|
|
4524
4414
|
}
|
|
4525
4415
|
return dispatchPrintOtherReceiptTask;
|
|
@@ -4539,32 +4429,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
4539
4429
|
}, {
|
|
4540
4430
|
key: "dispatchLocalReceiptPrint",
|
|
4541
4431
|
value: function () {
|
|
4542
|
-
var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4432
|
+
var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
|
|
4543
4433
|
var _payment_info;
|
|
4544
4434
|
var printableOrder;
|
|
4545
|
-
return _regeneratorRuntime().wrap(function
|
|
4546
|
-
while (1) switch (
|
|
4435
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
4436
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4547
4437
|
case 0:
|
|
4548
4438
|
if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
|
|
4549
|
-
|
|
4439
|
+
_context47.next = 2;
|
|
4550
4440
|
break;
|
|
4551
4441
|
}
|
|
4552
|
-
return
|
|
4442
|
+
return _context47.abrupt("return", {
|
|
4553
4443
|
printed: false,
|
|
4554
4444
|
order: params.order
|
|
4555
4445
|
});
|
|
4556
4446
|
case 2:
|
|
4557
|
-
|
|
4447
|
+
_context47.next = 4;
|
|
4558
4448
|
return this.withLocalSmallTicketData(params.order, {
|
|
4559
4449
|
requireFullyPaid: params.requireFullyPaid
|
|
4560
4450
|
});
|
|
4561
4451
|
case 4:
|
|
4562
|
-
printableOrder =
|
|
4452
|
+
printableOrder = _context47.sent;
|
|
4563
4453
|
if (hasSmallTicketData((_payment_info = printableOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data)) {
|
|
4564
|
-
|
|
4454
|
+
_context47.next = 7;
|
|
4565
4455
|
break;
|
|
4566
4456
|
}
|
|
4567
|
-
return
|
|
4457
|
+
return _context47.abrupt("return", {
|
|
4568
4458
|
printed: false,
|
|
4569
4459
|
order: printableOrder
|
|
4570
4460
|
});
|
|
@@ -4574,25 +4464,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
4574
4464
|
printableOrder: printableOrder,
|
|
4575
4465
|
response: params.response
|
|
4576
4466
|
});
|
|
4577
|
-
|
|
4467
|
+
_context47.next = 10;
|
|
4578
4468
|
return this.dispatchPrintOtherReceiptTask({
|
|
4579
4469
|
checkoutData: params.checkoutData,
|
|
4580
4470
|
syncedOrder: printableOrder,
|
|
4581
4471
|
response: params.response,
|
|
4582
|
-
receiptOnly: true
|
|
4472
|
+
receiptOnly: true,
|
|
4473
|
+
isManualPrint: params.isManualPrint
|
|
4583
4474
|
});
|
|
4584
4475
|
case 10:
|
|
4585
|
-
return
|
|
4476
|
+
return _context47.abrupt("return", {
|
|
4586
4477
|
printed: true,
|
|
4587
4478
|
order: printableOrder
|
|
4588
4479
|
});
|
|
4589
4480
|
case 11:
|
|
4590
4481
|
case "end":
|
|
4591
|
-
return
|
|
4482
|
+
return _context47.stop();
|
|
4592
4483
|
}
|
|
4593
|
-
},
|
|
4484
|
+
}, _callee47, this);
|
|
4594
4485
|
}));
|
|
4595
|
-
function dispatchLocalReceiptPrint(
|
|
4486
|
+
function dispatchLocalReceiptPrint(_x51) {
|
|
4596
4487
|
return _dispatchLocalReceiptPrint.apply(this, arguments);
|
|
4597
4488
|
}
|
|
4598
4489
|
return dispatchLocalReceiptPrint;
|
|
@@ -4616,6 +4507,146 @@ var Server = /*#__PURE__*/function () {
|
|
|
4616
4507
|
}
|
|
4617
4508
|
return undefined;
|
|
4618
4509
|
}
|
|
4510
|
+
}, {
|
|
4511
|
+
key: "resolveMachinecodeBatchMetadataLookup",
|
|
4512
|
+
value: function resolveMachinecodeBatchMetadataLookup(data) {
|
|
4513
|
+
var candidates = [data === null || data === void 0 ? void 0 : data.order_lookup, data === null || data === void 0 ? void 0 : data.orderLookup, data === null || data === void 0 ? void 0 : data.external_sale_number, data === null || data === void 0 ? void 0 : data.externalSaleNumber, data === null || data === void 0 ? void 0 : data.order_id, data === null || data === void 0 ? void 0 : data.orderId, data === null || data === void 0 ? void 0 : data.order_number, data === null || data === void 0 ? void 0 : data.orderNumber, data === null || data === void 0 ? void 0 : data.shop_order_number, data === null || data === void 0 ? void 0 : data.shopOrderNumber, data === null || data === void 0 ? void 0 : data.shop_full_order_number, data === null || data === void 0 ? void 0 : data.shopFullOrderNumber];
|
|
4514
|
+
return candidates.find(function (candidate) {
|
|
4515
|
+
return candidate !== undefined && candidate !== null && candidate !== '';
|
|
4516
|
+
});
|
|
4517
|
+
}
|
|
4518
|
+
}, {
|
|
4519
|
+
key: "syncMachinecodeRedeemStatusToLocalOrder",
|
|
4520
|
+
value: function () {
|
|
4521
|
+
var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(data, ids, status) {
|
|
4522
|
+
var _this$order3;
|
|
4523
|
+
var title, lookup, localOrder, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
|
|
4524
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
4525
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4526
|
+
case 0:
|
|
4527
|
+
title = 'handleMachinecodeBatchMetadata';
|
|
4528
|
+
lookup = this.resolveMachinecodeBatchMetadataLookup(data);
|
|
4529
|
+
if (!(lookup === undefined)) {
|
|
4530
|
+
_context48.next = 5;
|
|
4531
|
+
break;
|
|
4532
|
+
}
|
|
4533
|
+
this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
4534
|
+
batchSize: ids.length,
|
|
4535
|
+
status: status
|
|
4536
|
+
});
|
|
4537
|
+
return _context48.abrupt("return");
|
|
4538
|
+
case 5:
|
|
4539
|
+
if ((_this$order3 = this.order) !== null && _this$order3 !== void 0 && _this$order3.getLocalOrderByLookup) {
|
|
4540
|
+
_context48.next = 8;
|
|
4541
|
+
break;
|
|
4542
|
+
}
|
|
4543
|
+
this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
4544
|
+
lookup: lookup,
|
|
4545
|
+
status: status
|
|
4546
|
+
});
|
|
4547
|
+
return _context48.abrupt("return");
|
|
4548
|
+
case 8:
|
|
4549
|
+
_context48.next = 10;
|
|
4550
|
+
return this.order.getLocalOrderByLookup(lookup);
|
|
4551
|
+
case 10:
|
|
4552
|
+
localOrder = _context48.sent;
|
|
4553
|
+
if (localOrder) {
|
|
4554
|
+
_context48.next = 14;
|
|
4555
|
+
break;
|
|
4556
|
+
}
|
|
4557
|
+
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
4558
|
+
lookup: lookup,
|
|
4559
|
+
status: status
|
|
4560
|
+
});
|
|
4561
|
+
return _context48.abrupt("return");
|
|
4562
|
+
case 14:
|
|
4563
|
+
voucherIdSet = new Set(ids.filter(function (id) {
|
|
4564
|
+
return id !== undefined && id !== null && id !== '';
|
|
4565
|
+
}).map(function (id) {
|
|
4566
|
+
return String(id);
|
|
4567
|
+
}));
|
|
4568
|
+
if (!(voucherIdSet.size === 0)) {
|
|
4569
|
+
_context48.next = 18;
|
|
4570
|
+
break;
|
|
4571
|
+
}
|
|
4572
|
+
this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
4573
|
+
lookup: lookup,
|
|
4574
|
+
status: status
|
|
4575
|
+
});
|
|
4576
|
+
return _context48.abrupt("return");
|
|
4577
|
+
case 18:
|
|
4578
|
+
vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
|
|
4579
|
+
hasUpdatedVoucher = false;
|
|
4580
|
+
nextVouchers = vouchers.map(function (voucher) {
|
|
4581
|
+
var voucherId = voucher === null || voucher === void 0 ? void 0 : voucher.voucher_id;
|
|
4582
|
+
if (voucherId === undefined || voucherId === null) return voucher;
|
|
4583
|
+
if (!voucherIdSet.has(String(voucherId))) return voucher;
|
|
4584
|
+
hasUpdatedVoucher = true;
|
|
4585
|
+
return _objectSpread(_objectSpread({}, voucher), {}, {
|
|
4586
|
+
status: status
|
|
4587
|
+
});
|
|
4588
|
+
});
|
|
4589
|
+
if (hasUpdatedVoucher) {
|
|
4590
|
+
_context48.next = 24;
|
|
4591
|
+
break;
|
|
4592
|
+
}
|
|
4593
|
+
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
4594
|
+
lookup: lookup,
|
|
4595
|
+
voucher_ids: Array.from(voucherIdSet),
|
|
4596
|
+
status: status
|
|
4597
|
+
});
|
|
4598
|
+
return _context48.abrupt("return");
|
|
4599
|
+
case 24:
|
|
4600
|
+
if (!(typeof this.order.overwriteExistingOrder === 'function')) {
|
|
4601
|
+
_context48.next = 29;
|
|
4602
|
+
break;
|
|
4603
|
+
}
|
|
4604
|
+
_context48.next = 27;
|
|
4605
|
+
return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
|
|
4606
|
+
vouchers: nextVouchers
|
|
4607
|
+
}));
|
|
4608
|
+
case 27:
|
|
4609
|
+
this.logInfo("".concat(title, ": \u672C\u5730\u8BA2\u5355 vouchers \u6838\u9500\u72B6\u6001\u5DF2\u66F4\u65B0"), {
|
|
4610
|
+
lookup: lookup,
|
|
4611
|
+
updatedCount: voucherIdSet.size,
|
|
4612
|
+
status: status
|
|
4613
|
+
});
|
|
4614
|
+
return _context48.abrupt("return");
|
|
4615
|
+
case 29:
|
|
4616
|
+
if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
|
|
4617
|
+
_context48.next = 34;
|
|
4618
|
+
break;
|
|
4619
|
+
}
|
|
4620
|
+
_context48.next = 32;
|
|
4621
|
+
return this.order.markOrderSyncedByExternalSaleNumber({
|
|
4622
|
+
externalSaleNumber: data.external_sale_number,
|
|
4623
|
+
patch: {
|
|
4624
|
+
vouchers: nextVouchers
|
|
4625
|
+
}
|
|
4626
|
+
});
|
|
4627
|
+
case 32:
|
|
4628
|
+
this.logInfo("".concat(title, ": \u672C\u5730\u8BA2\u5355 vouchers \u6838\u9500\u72B6\u6001\u5DF2\u66F4\u65B0"), {
|
|
4629
|
+
lookup: lookup,
|
|
4630
|
+
updatedCount: voucherIdSet.size,
|
|
4631
|
+
status: status
|
|
4632
|
+
});
|
|
4633
|
+
return _context48.abrupt("return");
|
|
4634
|
+
case 34:
|
|
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"), {
|
|
4636
|
+
lookup: lookup,
|
|
4637
|
+
status: status
|
|
4638
|
+
});
|
|
4639
|
+
case 35:
|
|
4640
|
+
case "end":
|
|
4641
|
+
return _context48.stop();
|
|
4642
|
+
}
|
|
4643
|
+
}, _callee48, this);
|
|
4644
|
+
}));
|
|
4645
|
+
function syncMachinecodeRedeemStatusToLocalOrder(_x52, _x53, _x54) {
|
|
4646
|
+
return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
|
|
4647
|
+
}
|
|
4648
|
+
return syncMachinecodeRedeemStatusToLocalOrder;
|
|
4649
|
+
}()
|
|
4619
4650
|
}, {
|
|
4620
4651
|
key: "handleOrderCheckoutSubmit",
|
|
4621
4652
|
value: function () {
|
|
@@ -4702,7 +4733,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4702
4733
|
}
|
|
4703
4734
|
}, _callee49, this);
|
|
4704
4735
|
}));
|
|
4705
|
-
function handleOrderCheckoutSubmit(
|
|
4736
|
+
function handleOrderCheckoutSubmit(_x55) {
|
|
4706
4737
|
return _handleOrderCheckoutSubmit.apply(this, arguments);
|
|
4707
4738
|
}
|
|
4708
4739
|
return handleOrderCheckoutSubmit;
|
|
@@ -4711,13 +4742,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4711
4742
|
key: "handleSyncCheckoutSubmit",
|
|
4712
4743
|
value: function () {
|
|
4713
4744
|
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
|
|
4714
|
-
var _this$
|
|
4745
|
+
var _this$app16;
|
|
4715
4746
|
var backendPath, data, title, syncResult, _normalized$data, normalized, backendError, _normalized$data2, _normalized, message;
|
|
4716
4747
|
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
4717
4748
|
while (1) switch (_context50.prev = _context50.next) {
|
|
4718
4749
|
case 0:
|
|
4719
4750
|
backendPath = params.backendPath, data = params.data, title = params.title;
|
|
4720
|
-
if ((_this$
|
|
4751
|
+
if ((_this$app16 = this.app) !== null && _this$app16 !== void 0 && (_this$app16 = _this$app16.request) !== null && _this$app16 !== void 0 && _this$app16.post) {
|
|
4721
4752
|
_context50.next = 4;
|
|
4722
4753
|
break;
|
|
4723
4754
|
}
|
|
@@ -4784,7 +4815,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4784
4815
|
}
|
|
4785
4816
|
}, _callee50, this, [[4, 14]]);
|
|
4786
4817
|
}));
|
|
4787
|
-
function handleSyncCheckoutSubmit(
|
|
4818
|
+
function handleSyncCheckoutSubmit(_x56) {
|
|
4788
4819
|
return _handleSyncCheckoutSubmit.apply(this, arguments);
|
|
4789
4820
|
}
|
|
4790
4821
|
return handleSyncCheckoutSubmit;
|
|
@@ -4793,7 +4824,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4793
4824
|
key: "handlePendingSyncCheckoutOrder",
|
|
4794
4825
|
value: function () {
|
|
4795
4826
|
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
|
|
4796
|
-
var
|
|
4827
|
+
var _this10 = this;
|
|
4797
4828
|
var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
|
|
4798
4829
|
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
4799
4830
|
while (1) switch (_context51.prev = _context51.next) {
|
|
@@ -4846,7 +4877,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4846
4877
|
});
|
|
4847
4878
|
changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
|
|
4848
4879
|
var _payment$metadata;
|
|
4849
|
-
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);
|
|
4850
4881
|
}, 0);
|
|
4851
4882
|
return _context51.abrupt("return", {
|
|
4852
4883
|
code: 200,
|
|
@@ -4883,7 +4914,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4883
4914
|
}
|
|
4884
4915
|
}, _callee51, this, [[10, 18]]);
|
|
4885
4916
|
}));
|
|
4886
|
-
function handlePendingSyncCheckoutOrder(
|
|
4917
|
+
function handlePendingSyncCheckoutOrder(_x57) {
|
|
4887
4918
|
return _handlePendingSyncCheckoutOrder.apply(this, arguments);
|
|
4888
4919
|
}
|
|
4889
4920
|
return handlePendingSyncCheckoutOrder;
|
|
@@ -4927,7 +4958,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4927
4958
|
}
|
|
4928
4959
|
}, _callee52, this);
|
|
4929
4960
|
}));
|
|
4930
|
-
function buildPendingSyncCheckoutOrder(
|
|
4961
|
+
function buildPendingSyncCheckoutOrder(_x58) {
|
|
4931
4962
|
return _buildPendingSyncCheckoutOrder.apply(this, arguments);
|
|
4932
4963
|
}
|
|
4933
4964
|
return buildPendingSyncCheckoutOrder;
|
|
@@ -4935,10 +4966,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
4935
4966
|
}, {
|
|
4936
4967
|
key: "shouldBuildSmallTicketData",
|
|
4937
4968
|
value: function shouldBuildSmallTicketData(order) {
|
|
4938
|
-
var
|
|
4969
|
+
var _ref56, _order$small_ticket_d;
|
|
4939
4970
|
if (!order || _typeof(order) !== 'object') return false;
|
|
4940
|
-
if (hasSmallTicketData(
|
|
4941
|
-
return Number((
|
|
4971
|
+
// if (hasSmallTicketData(order.payment_info?.small_ticket_data)) return false;
|
|
4972
|
+
return Number((_ref56 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref56 !== void 0 ? _ref56 : 0) === 1;
|
|
4942
4973
|
}
|
|
4943
4974
|
}, {
|
|
4944
4975
|
key: "shouldPrintSyncedOrder",
|
|
@@ -4956,7 +4987,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4956
4987
|
}, {
|
|
4957
4988
|
key: "isSalesOrderFullyPaid",
|
|
4958
4989
|
value: function isSalesOrderFullyPaid(order) {
|
|
4959
|
-
var _order$summary$amount, _order$summary,
|
|
4990
|
+
var _order$summary$amount, _order$summary, _ref57, _ref58, _order$summary$expect, _order$summary2, _order$summary3;
|
|
4960
4991
|
if (!order || _typeof(order) !== 'object') return false;
|
|
4961
4992
|
var paymentStatus = String(order.payment_status || '').toLowerCase();
|
|
4962
4993
|
if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
|
|
@@ -4968,20 +4999,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
4968
4999
|
return this.toAmountNumber(amountGap) <= 0;
|
|
4969
5000
|
}
|
|
4970
5001
|
var paidAmount = this.sumPaidOrderPayments(order.payments);
|
|
4971
|
-
var targetAmount = this.toAmountNumber((
|
|
5002
|
+
var targetAmount = this.toAmountNumber((_ref57 = (_ref58 = (_order$summary$expect = (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.total_amount) !== null && _ref58 !== void 0 ? _ref58 : order.expect_amount) !== null && _ref57 !== void 0 ? _ref57 : order.total_amount);
|
|
4972
5003
|
if (targetAmount <= 0) return paidAmount > 0;
|
|
4973
5004
|
return paidAmount >= targetAmount;
|
|
4974
5005
|
}
|
|
4975
5006
|
}, {
|
|
4976
5007
|
key: "sumPaidOrderPayments",
|
|
4977
5008
|
value: function sumPaidOrderPayments(payments) {
|
|
4978
|
-
var
|
|
5009
|
+
var _this11 = this;
|
|
4979
5010
|
if (!Array.isArray(payments)) return 0;
|
|
4980
5011
|
return payments.reduce(function (sum, payment) {
|
|
4981
5012
|
var _payment$amount;
|
|
4982
5013
|
var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
|
|
4983
5014
|
if (status === 'voided' || status === 'failed' || status === 'cancelled') return sum;
|
|
4984
|
-
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);
|
|
4985
5016
|
}, 0);
|
|
4986
5017
|
}
|
|
4987
5018
|
}, {
|
|
@@ -4996,8 +5027,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
4996
5027
|
key: "buildSmallTicketProductMap",
|
|
4997
5028
|
value: function () {
|
|
4998
5029
|
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(order) {
|
|
4999
|
-
var _this$
|
|
5000
|
-
|
|
5030
|
+
var _this$products,
|
|
5031
|
+
_this12 = this;
|
|
5001
5032
|
var products, productIdSet, productIds, entries;
|
|
5002
5033
|
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5003
5034
|
while (1) switch (_context54.prev = _context54.next) {
|
|
@@ -5012,8 +5043,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
5012
5043
|
}
|
|
5013
5044
|
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
5014
5045
|
product.product_bundle.forEach(function (bundle) {
|
|
5015
|
-
var
|
|
5016
|
-
var bundleProductId = (
|
|
5046
|
+
var _ref59, _bundle$bundle_produc;
|
|
5047
|
+
var bundleProductId = (_ref59 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref59 !== void 0 ? _ref59 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
|
|
5017
5048
|
if (bundleProductId !== undefined && bundleProductId !== null && bundleProductId !== '') {
|
|
5018
5049
|
productIdSet.add(bundleProductId);
|
|
5019
5050
|
}
|
|
@@ -5021,7 +5052,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5021
5052
|
}
|
|
5022
5053
|
});
|
|
5023
5054
|
productIds = Array.from(productIdSet);
|
|
5024
|
-
if (!(!productIds.length || typeof ((_this$
|
|
5055
|
+
if (!(!productIds.length || typeof ((_this$products = this.products) === null || _this$products === void 0 ? void 0 : _this$products.getProductById) !== 'function')) {
|
|
5025
5056
|
_context54.next = 6;
|
|
5026
5057
|
break;
|
|
5027
5058
|
}
|
|
@@ -5029,21 +5060,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
5029
5060
|
case 6:
|
|
5030
5061
|
_context54.next = 8;
|
|
5031
5062
|
return Promise.all(productIds.map( /*#__PURE__*/function () {
|
|
5032
|
-
var
|
|
5033
|
-
var
|
|
5063
|
+
var _ref60 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(id) {
|
|
5064
|
+
var _this12$products, _this12$products$getP, product;
|
|
5034
5065
|
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
5035
5066
|
while (1) switch (_context53.prev = _context53.next) {
|
|
5036
5067
|
case 0:
|
|
5037
5068
|
_context53.prev = 0;
|
|
5038
5069
|
_context53.next = 3;
|
|
5039
|
-
return (
|
|
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));
|
|
5040
5071
|
case 3:
|
|
5041
5072
|
product = _context53.sent;
|
|
5042
5073
|
return _context53.abrupt("return", product ? [String(id), product] : null);
|
|
5043
5074
|
case 7:
|
|
5044
5075
|
_context53.prev = 7;
|
|
5045
5076
|
_context53.t0 = _context53["catch"](0);
|
|
5046
|
-
|
|
5077
|
+
_this12.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
|
|
5047
5078
|
product_id: id,
|
|
5048
5079
|
error: _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0)
|
|
5049
5080
|
});
|
|
@@ -5054,8 +5085,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
5054
5085
|
}
|
|
5055
5086
|
}, _callee53, null, [[0, 7]]);
|
|
5056
5087
|
}));
|
|
5057
|
-
return function (
|
|
5058
|
-
return
|
|
5088
|
+
return function (_x60) {
|
|
5089
|
+
return _ref60.apply(this, arguments);
|
|
5059
5090
|
};
|
|
5060
5091
|
}()));
|
|
5061
5092
|
case 8:
|
|
@@ -5074,7 +5105,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5074
5105
|
}
|
|
5075
5106
|
}, _callee54, this);
|
|
5076
5107
|
}));
|
|
5077
|
-
function buildSmallTicketProductMap(
|
|
5108
|
+
function buildSmallTicketProductMap(_x59) {
|
|
5078
5109
|
return _buildSmallTicketProductMap.apply(this, arguments);
|
|
5079
5110
|
}
|
|
5080
5111
|
return buildSmallTicketProductMap;
|
|
@@ -5082,13 +5113,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
5082
5113
|
}, {
|
|
5083
5114
|
key: "withPendingSyncProductTitles",
|
|
5084
5115
|
value: function withPendingSyncProductTitles(order, productMap) {
|
|
5085
|
-
var
|
|
5116
|
+
var _this13 = this;
|
|
5086
5117
|
var products = Array.isArray(order.products) ? order.products : null;
|
|
5087
5118
|
if (!(products !== null && products !== void 0 && products.length)) return order;
|
|
5088
5119
|
return _objectSpread(_objectSpread({}, order), {}, {
|
|
5089
5120
|
products: products.map(function (product) {
|
|
5090
5121
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
5091
|
-
product_title:
|
|
5122
|
+
product_title: _this13.buildProductTitleSnapshot(product, productMap)
|
|
5092
5123
|
});
|
|
5093
5124
|
})
|
|
5094
5125
|
});
|
|
@@ -5099,7 +5130,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5099
5130
|
var _product$product_id2,
|
|
5100
5131
|
_product$product,
|
|
5101
5132
|
_fallbackProduct$prod,
|
|
5102
|
-
|
|
5133
|
+
_this14 = this;
|
|
5103
5134
|
var productId = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product.id;
|
|
5104
5135
|
var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
|
|
5105
5136
|
var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
|
|
@@ -5107,7 +5138,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5107
5138
|
var currentLocale = this.getProductTitleSnapshotCurrentLocale();
|
|
5108
5139
|
var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
|
|
5109
5140
|
return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
|
|
5110
|
-
snapshot[key] =
|
|
5141
|
+
snapshot[key] = _this14.resolveProductTitleValue(ownTitle, key, currentLocale) || _this14.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
|
|
5111
5142
|
return snapshot;
|
|
5112
5143
|
}, {});
|
|
5113
5144
|
}
|
|
@@ -5132,7 +5163,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5132
5163
|
}, {
|
|
5133
5164
|
key: "resolveProductTitleValue",
|
|
5134
5165
|
value: function resolveProductTitleValue(value, key, currentLocale) {
|
|
5135
|
-
var
|
|
5166
|
+
var _ref61, _ref62, _value$key;
|
|
5136
5167
|
if (value === undefined || value === null || value === '') return null;
|
|
5137
5168
|
if (_typeof(value) !== 'object') {
|
|
5138
5169
|
var title = String(value);
|
|
@@ -5142,7 +5173,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5142
5173
|
}
|
|
5143
5174
|
var normalizedKey = key.replace('-', '_');
|
|
5144
5175
|
var dashedKey = key.replace('_', '-');
|
|
5145
|
-
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;
|
|
5146
5177
|
if (rawValue === undefined || rawValue === null || rawValue === '') return null;
|
|
5147
5178
|
if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
|
|
5148
5179
|
return String(rawValue);
|
|
@@ -5206,14 +5237,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
5206
5237
|
key: "enrichPaymentNamesByCode",
|
|
5207
5238
|
value: function () {
|
|
5208
5239
|
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(order) {
|
|
5209
|
-
var
|
|
5210
|
-
var payments, hasMissingName, paymentModule, payMethods, nameByCode,
|
|
5240
|
+
var _this15 = this;
|
|
5241
|
+
var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
|
|
5211
5242
|
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5212
5243
|
while (1) switch (_context55.prev = _context55.next) {
|
|
5213
5244
|
case 0:
|
|
5214
5245
|
payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
|
|
5215
5246
|
hasMissingName = payments.some(function (payment) {
|
|
5216
|
-
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);
|
|
5217
5248
|
});
|
|
5218
5249
|
if (hasMissingName) {
|
|
5219
5250
|
_context55.next = 4;
|
|
@@ -5231,24 +5262,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
5231
5262
|
case 10:
|
|
5232
5263
|
payMethods = _context55.sent;
|
|
5233
5264
|
nameByCode = new Map();
|
|
5234
|
-
|
|
5265
|
+
_iterator12 = _createForOfIteratorHelper(payMethods || []);
|
|
5235
5266
|
try {
|
|
5236
|
-
for (
|
|
5237
|
-
method =
|
|
5267
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
5268
|
+
method = _step12.value;
|
|
5238
5269
|
codeKey = this.getPaymentCodeKey(method === null || method === void 0 ? void 0 : method.code);
|
|
5239
5270
|
name = this.resolveFirstProductTitleValue(method === null || method === void 0 ? void 0 : method.name);
|
|
5240
5271
|
if (codeKey && name) nameByCode.set(codeKey, name);
|
|
5241
5272
|
}
|
|
5242
5273
|
} catch (err) {
|
|
5243
|
-
|
|
5274
|
+
_iterator12.e(err);
|
|
5244
5275
|
} finally {
|
|
5245
|
-
|
|
5276
|
+
_iterator12.f();
|
|
5246
5277
|
}
|
|
5247
5278
|
hasResolvedName = false;
|
|
5248
5279
|
enrichedPayments = payments.map(function (payment) {
|
|
5249
|
-
if (!
|
|
5250
|
-
if (!
|
|
5251
|
-
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));
|
|
5252
5283
|
if (!name) return payment;
|
|
5253
5284
|
hasResolvedName = true;
|
|
5254
5285
|
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
@@ -5277,7 +5308,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5277
5308
|
}
|
|
5278
5309
|
}, _callee55, this, [[4, 21]]);
|
|
5279
5310
|
}));
|
|
5280
|
-
function enrichPaymentNamesByCode(
|
|
5311
|
+
function enrichPaymentNamesByCode(_x61) {
|
|
5281
5312
|
return _enrichPaymentNamesByCode.apply(this, arguments);
|
|
5282
5313
|
}
|
|
5283
5314
|
return enrichPaymentNamesByCode;
|
|
@@ -5344,7 +5375,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5344
5375
|
}
|
|
5345
5376
|
}, _callee56, this, [[4, 20]]);
|
|
5346
5377
|
}));
|
|
5347
|
-
function withLocalSmallTicketData(
|
|
5378
|
+
function withLocalSmallTicketData(_x62, _x63) {
|
|
5348
5379
|
return _withLocalSmallTicketData.apply(this, arguments);
|
|
5349
5380
|
}
|
|
5350
5381
|
return withLocalSmallTicketData;
|
|
@@ -5407,8 +5438,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
5407
5438
|
key: "handleUpdateLocalOrdersBatch",
|
|
5408
5439
|
value: (function () {
|
|
5409
5440
|
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(orderIds) {
|
|
5410
|
-
var _this$
|
|
5411
|
-
var existedBefore,
|
|
5441
|
+
var _this$app17;
|
|
5442
|
+
var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message2, overwritten, inserted;
|
|
5412
5443
|
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5413
5444
|
while (1) switch (_context57.prev = _context57.next) {
|
|
5414
5445
|
case 0:
|
|
@@ -5428,7 +5459,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5428
5459
|
data: null
|
|
5429
5460
|
});
|
|
5430
5461
|
case 4:
|
|
5431
|
-
if ((_this$
|
|
5462
|
+
if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && _this$app17.request) {
|
|
5432
5463
|
_context57.next = 7;
|
|
5433
5464
|
break;
|
|
5434
5465
|
}
|
|
@@ -5442,18 +5473,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
5442
5473
|
case 7:
|
|
5443
5474
|
// 拉取前先记录"本地是否已存在",用于区分 overwritten / inserted
|
|
5444
5475
|
existedBefore = new Map();
|
|
5445
|
-
|
|
5476
|
+
_iterator13 = _createForOfIteratorHelper(orderIds);
|
|
5446
5477
|
try {
|
|
5447
|
-
for (
|
|
5448
|
-
id =
|
|
5478
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
5479
|
+
id = _step13.value;
|
|
5449
5480
|
existedBefore.set(id, !!this.order.getOrderByOrderId(id));
|
|
5450
5481
|
}
|
|
5451
5482
|
|
|
5452
5483
|
// 走 orderDataSource 的批量 HTTP 通道,一次请求拉回多笔详情
|
|
5453
5484
|
} catch (err) {
|
|
5454
|
-
|
|
5485
|
+
_iterator13.e(err);
|
|
5455
5486
|
} finally {
|
|
5456
|
-
|
|
5487
|
+
_iterator13.f();
|
|
5457
5488
|
}
|
|
5458
5489
|
fetched = [];
|
|
5459
5490
|
_context57.prev = 11;
|
|
@@ -5479,15 +5510,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
5479
5510
|
case 22:
|
|
5480
5511
|
// 按返回结果中的 order_id 建索引,未命中即视为单笔失败
|
|
5481
5512
|
fetchedMap = new Map();
|
|
5482
|
-
|
|
5513
|
+
_iterator14 = _createForOfIteratorHelper(fetched);
|
|
5483
5514
|
_context57.prev = 24;
|
|
5484
|
-
|
|
5515
|
+
_iterator14.s();
|
|
5485
5516
|
case 26:
|
|
5486
|
-
if ((
|
|
5517
|
+
if ((_step14 = _iterator14.n()).done) {
|
|
5487
5518
|
_context57.next = 34;
|
|
5488
5519
|
break;
|
|
5489
5520
|
}
|
|
5490
|
-
order =
|
|
5521
|
+
order = _step14.value;
|
|
5491
5522
|
oid = order === null || order === void 0 ? void 0 : order.order_id;
|
|
5492
5523
|
if (!(oid === undefined || oid === null)) {
|
|
5493
5524
|
_context57.next = 31;
|
|
@@ -5505,19 +5536,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
5505
5536
|
case 36:
|
|
5506
5537
|
_context57.prev = 36;
|
|
5507
5538
|
_context57.t1 = _context57["catch"](24);
|
|
5508
|
-
|
|
5539
|
+
_iterator14.e(_context57.t1);
|
|
5509
5540
|
case 39:
|
|
5510
5541
|
_context57.prev = 39;
|
|
5511
|
-
|
|
5542
|
+
_iterator14.f();
|
|
5512
5543
|
return _context57.finish(39);
|
|
5513
5544
|
case 42:
|
|
5514
5545
|
freshOrders = [];
|
|
5515
5546
|
succeedIds = [];
|
|
5516
5547
|
failed = [];
|
|
5517
|
-
|
|
5548
|
+
_iterator15 = _createForOfIteratorHelper(orderIds);
|
|
5518
5549
|
try {
|
|
5519
|
-
for (
|
|
5520
|
-
_id =
|
|
5550
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
5551
|
+
_id = _step15.value;
|
|
5521
5552
|
fresh = fetchedMap.get(_id);
|
|
5522
5553
|
if (fresh) {
|
|
5523
5554
|
freshOrders.push(fresh);
|
|
@@ -5530,9 +5561,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5530
5561
|
}
|
|
5531
5562
|
}
|
|
5532
5563
|
} catch (err) {
|
|
5533
|
-
|
|
5564
|
+
_iterator15.e(err);
|
|
5534
5565
|
} finally {
|
|
5535
|
-
|
|
5566
|
+
_iterator15.f();
|
|
5536
5567
|
}
|
|
5537
5568
|
if (!(freshOrders.length > 0)) {
|
|
5538
5569
|
_context57.next = 58;
|
|
@@ -5547,14 +5578,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
5547
5578
|
case 53:
|
|
5548
5579
|
_context57.prev = 53;
|
|
5549
5580
|
_context57.t2 = _context57["catch"](48);
|
|
5550
|
-
|
|
5581
|
+
_message2 = _context57.t2 instanceof Error ? _context57.t2.message : String(_context57.t2);
|
|
5551
5582
|
this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
|
|
5552
|
-
message:
|
|
5583
|
+
message: _message2
|
|
5553
5584
|
});
|
|
5554
5585
|
return _context57.abrupt("return", {
|
|
5555
5586
|
code: 500,
|
|
5556
5587
|
status: false,
|
|
5557
|
-
message:
|
|
5588
|
+
message: _message2,
|
|
5558
5589
|
data: null
|
|
5559
5590
|
});
|
|
5560
5591
|
case 58:
|
|
@@ -5586,7 +5617,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5586
5617
|
}
|
|
5587
5618
|
}, _callee57, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
|
|
5588
5619
|
}));
|
|
5589
|
-
function handleUpdateLocalOrdersBatch(
|
|
5620
|
+
function handleUpdateLocalOrdersBatch(_x64) {
|
|
5590
5621
|
return _handleUpdateLocalOrdersBatch.apply(this, arguments);
|
|
5591
5622
|
}
|
|
5592
5623
|
return handleUpdateLocalOrdersBatch;
|
|
@@ -5607,11 +5638,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5607
5638
|
var queryIndex = url.indexOf('?');
|
|
5608
5639
|
if (queryIndex < 0) return null;
|
|
5609
5640
|
var query = url.slice(queryIndex + 1);
|
|
5610
|
-
var
|
|
5611
|
-
|
|
5641
|
+
var _iterator16 = _createForOfIteratorHelper(query.split('&')),
|
|
5642
|
+
_step16;
|
|
5612
5643
|
try {
|
|
5613
|
-
for (
|
|
5614
|
-
var pair =
|
|
5644
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
5645
|
+
var pair = _step16.value;
|
|
5615
5646
|
if (!pair) continue;
|
|
5616
5647
|
var _pair$split = pair.split('='),
|
|
5617
5648
|
_pair$split2 = _slicedToArray(_pair$split, 2),
|
|
@@ -5627,9 +5658,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5627
5658
|
}
|
|
5628
5659
|
}
|
|
5629
5660
|
} catch (err) {
|
|
5630
|
-
|
|
5661
|
+
_iterator16.e(err);
|
|
5631
5662
|
} finally {
|
|
5632
|
-
|
|
5663
|
+
_iterator16.f();
|
|
5633
5664
|
}
|
|
5634
5665
|
return null;
|
|
5635
5666
|
}
|
|
@@ -5663,8 +5694,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
5663
5694
|
}, {
|
|
5664
5695
|
key: "extractOrderDataFromCheckoutResponse",
|
|
5665
5696
|
value: function extractOrderDataFromCheckoutResponse(response) {
|
|
5666
|
-
var _response$
|
|
5667
|
-
var candidates = [response === null || response === void 0 || (_response$
|
|
5697
|
+
var _response$data6, _response$data7;
|
|
5698
|
+
var candidates = [response === null || response === void 0 || (_response$data6 = response.data) === null || _response$data6 === void 0 ? void 0 : _response$data6.order, response === null || response === void 0 || (_response$data7 = response.data) === null || _response$data7 === void 0 ? void 0 : _response$data7.sales, response === null || response === void 0 ? void 0 : response.data, response === null || response === void 0 ? void 0 : response.order, response === null || response === void 0 ? void 0 : response.sales, response];
|
|
5668
5699
|
for (var _i4 = 0, _candidates = candidates; _i4 < _candidates.length; _i4++) {
|
|
5669
5700
|
var candidate = _candidates[_i4];
|
|
5670
5701
|
if (!candidate || _typeof(candidate) !== 'object') continue;
|
|
@@ -5828,10 +5859,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5828
5859
|
value: function extractBackendErrorResponse(error) {
|
|
5829
5860
|
var _error$response3,
|
|
5830
5861
|
_error$response4,
|
|
5831
|
-
|
|
5862
|
+
_this16 = this;
|
|
5832
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];
|
|
5833
5864
|
return candidates.find(function (candidate) {
|
|
5834
|
-
return
|
|
5865
|
+
return _this16.isExplicitBackendErrorResponse(candidate);
|
|
5835
5866
|
}) || null;
|
|
5836
5867
|
}
|
|
5837
5868
|
}, {
|
|
@@ -5951,7 +5982,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5951
5982
|
key: "recomputeAndNotifyFloorPlanQuery",
|
|
5952
5983
|
value: (function () {
|
|
5953
5984
|
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58() {
|
|
5954
|
-
var
|
|
5985
|
+
var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
|
|
5955
5986
|
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
5956
5987
|
while (1) switch (_context58.prev = _context58.next) {
|
|
5957
5988
|
case 0:
|
|
@@ -5964,10 +5995,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5964
5995
|
this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
|
|
5965
5996
|
subscriberCount: this.floorPlanQuerySubscribers.size
|
|
5966
5997
|
});
|
|
5967
|
-
|
|
5998
|
+
_iterator17 = _createForOfIteratorHelper(this.floorPlanQuerySubscribers.entries());
|
|
5968
5999
|
try {
|
|
5969
|
-
for (
|
|
5970
|
-
|
|
6000
|
+
for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
|
|
6001
|
+
_step17$value = _slicedToArray(_step17.value, 2), subscriberId = _step17$value[0], sub = _step17$value[1];
|
|
5971
6002
|
try {
|
|
5972
6003
|
result = this.computeFloorPlanQueryResult(sub.context);
|
|
5973
6004
|
sub.callback(result);
|
|
@@ -5983,9 +6014,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5983
6014
|
}
|
|
5984
6015
|
}
|
|
5985
6016
|
} catch (err) {
|
|
5986
|
-
|
|
6017
|
+
_iterator17.e(err);
|
|
5987
6018
|
} finally {
|
|
5988
|
-
|
|
6019
|
+
_iterator17.f();
|
|
5989
6020
|
}
|
|
5990
6021
|
case 5:
|
|
5991
6022
|
case "end":
|
|
@@ -6071,7 +6102,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6071
6102
|
}
|
|
6072
6103
|
}, _callee59, this);
|
|
6073
6104
|
}));
|
|
6074
|
-
function computeOrderQueryResult(
|
|
6105
|
+
function computeOrderQueryResult(_x65) {
|
|
6075
6106
|
return _computeOrderQueryResult.apply(this, arguments);
|
|
6076
6107
|
}
|
|
6077
6108
|
return computeOrderQueryResult;
|
|
@@ -6125,7 +6156,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6125
6156
|
}
|
|
6126
6157
|
}, _callee60, this);
|
|
6127
6158
|
}));
|
|
6128
|
-
function computeBookingQueryResult(
|
|
6159
|
+
function computeBookingQueryResult(_x66) {
|
|
6129
6160
|
return _computeBookingQueryResult.apply(this, arguments);
|
|
6130
6161
|
}
|
|
6131
6162
|
return computeBookingQueryResult;
|
|
@@ -6186,24 +6217,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
6186
6217
|
value: (function () {
|
|
6187
6218
|
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(context, options) {
|
|
6188
6219
|
var _menu_list_ids$length3,
|
|
6189
|
-
|
|
6190
|
-
var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id,
|
|
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;
|
|
6191
6222
|
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
6192
6223
|
while (1) switch (_context61.prev = _context61.next) {
|
|
6193
6224
|
case 0:
|
|
6194
6225
|
tTotal = performance.now();
|
|
6195
|
-
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;
|
|
6196
6227
|
queryIds = Array.isArray(ids) ? ids.map(function (id) {
|
|
6197
6228
|
return Number(id);
|
|
6198
6229
|
}).filter(function (id) {
|
|
6199
6230
|
return Number.isFinite(id);
|
|
6200
6231
|
}) : [];
|
|
6201
|
-
formatterContext = this.buildProductFormatterContext({
|
|
6202
|
-
schedule_date: schedule_date,
|
|
6203
|
-
schedule_datetime: schedule_datetime,
|
|
6204
|
-
customer_id: customer_id,
|
|
6205
|
-
strategy_context: strategy_context
|
|
6206
|
-
});
|
|
6207
6232
|
this.logInfo('computeProductQueryResult 开始', {
|
|
6208
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,
|
|
6209
6234
|
ids: queryIds,
|
|
@@ -6212,31 +6237,37 @@ var Server = /*#__PURE__*/function () {
|
|
|
6212
6237
|
customer_id: customer_id,
|
|
6213
6238
|
extension_type: extension_type,
|
|
6214
6239
|
product_id: product_id,
|
|
6215
|
-
strategyContextKeys: strategy_context ? Object.keys(strategy_context) : [],
|
|
6216
6240
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6217
6241
|
});
|
|
6218
6242
|
if (this.products) {
|
|
6219
|
-
_context61.next =
|
|
6243
|
+
_context61.next = 7;
|
|
6220
6244
|
break;
|
|
6221
6245
|
}
|
|
6222
6246
|
this.logError('computeProductQueryResult: Products 模块未注册');
|
|
6223
6247
|
return _context61.abrupt("return", {
|
|
6224
6248
|
message: 'Products 模块未注册',
|
|
6225
|
-
data:
|
|
6249
|
+
data: {
|
|
6250
|
+
list: [],
|
|
6251
|
+
count: 0
|
|
6252
|
+
}
|
|
6226
6253
|
});
|
|
6227
|
-
case
|
|
6254
|
+
case 7:
|
|
6228
6255
|
if (!(queryIds.length > 0)) {
|
|
6229
|
-
_context61.next =
|
|
6256
|
+
_context61.next = 19;
|
|
6230
6257
|
break;
|
|
6231
6258
|
}
|
|
6232
6259
|
uniqueIds = Array.from(new Set(queryIds));
|
|
6233
6260
|
_tPrice = performance.now();
|
|
6234
|
-
_context61.next =
|
|
6235
|
-
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
|
+
}, {
|
|
6236
6267
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
6237
6268
|
productIds: uniqueIds
|
|
6238
6269
|
});
|
|
6239
|
-
case
|
|
6270
|
+
case 12:
|
|
6240
6271
|
productsWithPrice = _context61.sent;
|
|
6241
6272
|
perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
|
|
6242
6273
|
count: productsWithPrice.length,
|
|
@@ -6259,22 +6290,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
6259
6290
|
});
|
|
6260
6291
|
return _context61.abrupt("return", {
|
|
6261
6292
|
code: 200,
|
|
6262
|
-
data:
|
|
6293
|
+
data: {
|
|
6294
|
+
list: extensionFilteredProducts,
|
|
6295
|
+
count: extensionFilteredProducts.length
|
|
6296
|
+
},
|
|
6263
6297
|
message: '',
|
|
6264
6298
|
status: true
|
|
6265
6299
|
});
|
|
6266
|
-
case
|
|
6300
|
+
case 19:
|
|
6267
6301
|
if (!(product_id != null && Number.isFinite(Number(product_id)))) {
|
|
6268
|
-
_context61.next =
|
|
6302
|
+
_context61.next = 31;
|
|
6269
6303
|
break;
|
|
6270
6304
|
}
|
|
6271
6305
|
pid = Number(product_id);
|
|
6272
6306
|
_tPrice2 = performance.now();
|
|
6273
|
-
_context61.next =
|
|
6274
|
-
return this.products.getProductsWithPrice(schedule_date,
|
|
6307
|
+
_context61.next = 24;
|
|
6308
|
+
return this.products.getProductsWithPrice(schedule_date, {
|
|
6309
|
+
scheduleModule: this.getSchedule()
|
|
6310
|
+
}, {
|
|
6275
6311
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6276
6312
|
});
|
|
6277
|
-
case
|
|
6313
|
+
case 24:
|
|
6278
6314
|
allProductsWithPrice = _context61.sent;
|
|
6279
6315
|
perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
|
|
6280
6316
|
count: allProductsWithPrice.length,
|
|
@@ -6301,17 +6337,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
6301
6337
|
message: item ? '' : '商品不存在或未发布',
|
|
6302
6338
|
status: true
|
|
6303
6339
|
});
|
|
6304
|
-
case
|
|
6340
|
+
case 31:
|
|
6305
6341
|
if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
|
|
6306
|
-
_context61.next =
|
|
6342
|
+
_context61.next = 51;
|
|
6307
6343
|
break;
|
|
6308
6344
|
}
|
|
6309
6345
|
_tPrice3 = performance.now();
|
|
6310
|
-
_context61.next =
|
|
6311
|
-
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
|
+
}, {
|
|
6312
6352
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6313
6353
|
});
|
|
6314
|
-
case
|
|
6354
|
+
case 35:
|
|
6315
6355
|
_filteredProducts2 = _context61.sent;
|
|
6316
6356
|
perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
|
|
6317
6357
|
count: _filteredProducts2.length,
|
|
@@ -6353,38 +6393,47 @@ var Server = /*#__PURE__*/function () {
|
|
|
6353
6393
|
});
|
|
6354
6394
|
return _context61.abrupt("return", {
|
|
6355
6395
|
code: 200,
|
|
6356
|
-
data:
|
|
6396
|
+
data: {
|
|
6397
|
+
list: _filteredProducts2,
|
|
6398
|
+
count: _filteredProducts2.length
|
|
6399
|
+
},
|
|
6357
6400
|
message: '',
|
|
6358
6401
|
status: true
|
|
6359
6402
|
});
|
|
6360
|
-
case
|
|
6403
|
+
case 51:
|
|
6361
6404
|
if (this.menu) {
|
|
6362
|
-
_context61.next =
|
|
6405
|
+
_context61.next = 54;
|
|
6363
6406
|
break;
|
|
6364
6407
|
}
|
|
6365
6408
|
this.logError('computeProductQueryResult: Menu 模块未注册');
|
|
6366
6409
|
return _context61.abrupt("return", {
|
|
6367
6410
|
message: 'Menu 模块未注册',
|
|
6368
|
-
data:
|
|
6411
|
+
data: {
|
|
6412
|
+
list: [],
|
|
6413
|
+
count: 0
|
|
6414
|
+
}
|
|
6369
6415
|
});
|
|
6370
|
-
case
|
|
6416
|
+
case 54:
|
|
6371
6417
|
if (this.schedule) {
|
|
6372
|
-
_context61.next =
|
|
6418
|
+
_context61.next = 57;
|
|
6373
6419
|
break;
|
|
6374
6420
|
}
|
|
6375
6421
|
this.logError('computeProductQueryResult: Schedule 模块未注册');
|
|
6376
6422
|
return _context61.abrupt("return", {
|
|
6377
6423
|
message: 'Schedule 模块未注册',
|
|
6378
|
-
data:
|
|
6424
|
+
data: {
|
|
6425
|
+
list: [],
|
|
6426
|
+
count: 0
|
|
6427
|
+
}
|
|
6379
6428
|
});
|
|
6380
|
-
case
|
|
6429
|
+
case 57:
|
|
6381
6430
|
activeMenuList = [];
|
|
6382
6431
|
if (menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0) {
|
|
6383
6432
|
tMenu = performance.now();
|
|
6384
6433
|
menuList = this.menu.getMenuByIds(menu_list_ids);
|
|
6385
6434
|
activeMenuList = menuList.filter(function (menu) {
|
|
6386
|
-
var
|
|
6387
|
-
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;
|
|
6388
6437
|
});
|
|
6389
6438
|
perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
|
|
6390
6439
|
totalMenu: menuList.length,
|
|
@@ -6401,21 +6450,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
6401
6450
|
});
|
|
6402
6451
|
tPrice = performance.now();
|
|
6403
6452
|
if (!(scopedProductIds.length > 0)) {
|
|
6404
|
-
_context61.next =
|
|
6453
|
+
_context61.next = 70;
|
|
6405
6454
|
break;
|
|
6406
6455
|
}
|
|
6407
|
-
_context61.next =
|
|
6408
|
-
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
|
+
}, {
|
|
6409
6462
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
6410
6463
|
productIds: productScope.isAllProducts ? undefined : scopedProductIds
|
|
6411
6464
|
});
|
|
6412
|
-
case
|
|
6465
|
+
case 67:
|
|
6413
6466
|
_context61.t0 = _context61.sent;
|
|
6414
|
-
_context61.next =
|
|
6467
|
+
_context61.next = 71;
|
|
6415
6468
|
break;
|
|
6416
|
-
case
|
|
6469
|
+
case 70:
|
|
6417
6470
|
_context61.t0 = [];
|
|
6418
|
-
case
|
|
6471
|
+
case 71:
|
|
6419
6472
|
filteredProducts = _context61.t0;
|
|
6420
6473
|
perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
|
|
6421
6474
|
count: filteredProducts.length,
|
|
@@ -6459,54 +6512,36 @@ var Server = /*#__PURE__*/function () {
|
|
|
6459
6512
|
});
|
|
6460
6513
|
return _context61.abrupt("return", {
|
|
6461
6514
|
code: 200,
|
|
6462
|
-
data:
|
|
6515
|
+
data: {
|
|
6516
|
+
list: filteredProducts,
|
|
6517
|
+
count: filteredProducts.length
|
|
6518
|
+
},
|
|
6463
6519
|
message: '',
|
|
6464
6520
|
status: true
|
|
6465
6521
|
});
|
|
6466
|
-
case
|
|
6522
|
+
case 87:
|
|
6467
6523
|
case "end":
|
|
6468
6524
|
return _context61.stop();
|
|
6469
6525
|
}
|
|
6470
6526
|
}, _callee61, this);
|
|
6471
6527
|
}));
|
|
6472
|
-
function computeProductQueryResult(
|
|
6528
|
+
function computeProductQueryResult(_x67, _x68) {
|
|
6473
6529
|
return _computeProductQueryResult.apply(this, arguments);
|
|
6474
6530
|
}
|
|
6475
6531
|
return computeProductQueryResult;
|
|
6476
6532
|
}()
|
|
6477
|
-
/**
|
|
6478
|
-
* 构建商品格式化上下文。
|
|
6479
|
-
*
|
|
6480
|
-
* 智能定价条件使用全量 menuList/scheduleList;Product Query 顶层参数只保留筛选商品集合所需字段。
|
|
6481
|
-
*/
|
|
6482
|
-
)
|
|
6483
|
-
}, {
|
|
6484
|
-
key: "buildProductFormatterContext",
|
|
6485
|
-
value: function buildProductFormatterContext(context) {
|
|
6486
|
-
var _this$menu, _this$menu$getMenuLis, _scheduleModule$getSc, _this$core$context4;
|
|
6487
|
-
var scheduleModule = this.getSchedule();
|
|
6488
|
-
return {
|
|
6489
|
-
scheduleModule: scheduleModule,
|
|
6490
|
-
schedule_datetime: context.schedule_datetime,
|
|
6491
|
-
customer_id: context.customer_id,
|
|
6492
|
-
strategy_context: context.strategy_context,
|
|
6493
|
-
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)) || [],
|
|
6494
|
-
scheduleList: (scheduleModule === null || scheduleModule === void 0 || (_scheduleModule$getSc = scheduleModule.getScheduleList) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule)) || [],
|
|
6495
|
-
dataVariantEvaluator: (_this$core$context4 = this.core.context) === null || _this$core$context4 === void 0 ? void 0 : _this$core$context4.dataVariantEvaluator
|
|
6496
|
-
};
|
|
6497
|
-
}
|
|
6498
|
-
|
|
6499
6533
|
/**
|
|
6500
6534
|
* 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
|
|
6501
6535
|
* 由 ProductsModule 的 onProductsSyncCompleted 事件触发
|
|
6502
6536
|
* @param options 可选参数
|
|
6503
6537
|
* @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
|
|
6504
6538
|
*/
|
|
6539
|
+
)
|
|
6505
6540
|
}, {
|
|
6506
6541
|
key: "recomputeAndNotifyProductQuery",
|
|
6507
6542
|
value: (function () {
|
|
6508
6543
|
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(options) {
|
|
6509
|
-
var
|
|
6544
|
+
var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
|
|
6510
6545
|
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
6511
6546
|
while (1) switch (_context62.prev = _context62.next) {
|
|
6512
6547
|
case 0:
|
|
@@ -6520,15 +6555,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
6520
6555
|
subscriberCount: this.productQuerySubscribers.size,
|
|
6521
6556
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6522
6557
|
});
|
|
6523
|
-
|
|
6558
|
+
_iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
|
|
6524
6559
|
_context62.prev = 4;
|
|
6525
|
-
|
|
6560
|
+
_iterator18.s();
|
|
6526
6561
|
case 6:
|
|
6527
|
-
if ((
|
|
6562
|
+
if ((_step18 = _iterator18.n()).done) {
|
|
6528
6563
|
_context62.next = 22;
|
|
6529
6564
|
break;
|
|
6530
6565
|
}
|
|
6531
|
-
|
|
6566
|
+
_step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
|
|
6532
6567
|
_context62.prev = 8;
|
|
6533
6568
|
_context62.next = 11;
|
|
6534
6569
|
return this.computeProductQueryResult(subscriber.context, {
|
|
@@ -6559,10 +6594,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
6559
6594
|
case 24:
|
|
6560
6595
|
_context62.prev = 24;
|
|
6561
6596
|
_context62.t1 = _context62["catch"](4);
|
|
6562
|
-
|
|
6597
|
+
_iterator18.e(_context62.t1);
|
|
6563
6598
|
case 27:
|
|
6564
6599
|
_context62.prev = 27;
|
|
6565
|
-
|
|
6600
|
+
_iterator18.f();
|
|
6566
6601
|
return _context62.finish(27);
|
|
6567
6602
|
case 30:
|
|
6568
6603
|
case "end":
|
|
@@ -6570,7 +6605,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6570
6605
|
}
|
|
6571
6606
|
}, _callee62, this, [[4, 24, 27, 30], [8, 16]]);
|
|
6572
6607
|
}));
|
|
6573
|
-
function recomputeAndNotifyProductQuery(
|
|
6608
|
+
function recomputeAndNotifyProductQuery(_x69) {
|
|
6574
6609
|
return _recomputeAndNotifyProductQuery.apply(this, arguments);
|
|
6575
6610
|
}
|
|
6576
6611
|
return recomputeAndNotifyProductQuery;
|
|
@@ -6583,7 +6618,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6583
6618
|
key: "recomputeAndNotifyOrderQuery",
|
|
6584
6619
|
value: (function () {
|
|
6585
6620
|
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63() {
|
|
6586
|
-
var notifyStartAt,
|
|
6621
|
+
var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
|
|
6587
6622
|
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
6588
6623
|
while (1) switch (_context63.prev = _context63.next) {
|
|
6589
6624
|
case 0:
|
|
@@ -6598,15 +6633,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
6598
6633
|
subscriberCount: this.orderQuerySubscribers.size,
|
|
6599
6634
|
notifyStartAt: new Date(notifyStartAt).toISOString()
|
|
6600
6635
|
});
|
|
6601
|
-
|
|
6636
|
+
_iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
|
|
6602
6637
|
_context63.prev = 5;
|
|
6603
|
-
|
|
6638
|
+
_iterator19.s();
|
|
6604
6639
|
case 7:
|
|
6605
|
-
if ((
|
|
6640
|
+
if ((_step19 = _iterator19.n()).done) {
|
|
6606
6641
|
_context63.next = 27;
|
|
6607
6642
|
break;
|
|
6608
6643
|
}
|
|
6609
|
-
|
|
6644
|
+
_step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
|
|
6610
6645
|
_context63.prev = 9;
|
|
6611
6646
|
computeStartAt = Date.now();
|
|
6612
6647
|
_context63.next = 13;
|
|
@@ -6642,10 +6677,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
6642
6677
|
case 29:
|
|
6643
6678
|
_context63.prev = 29;
|
|
6644
6679
|
_context63.t1 = _context63["catch"](5);
|
|
6645
|
-
|
|
6680
|
+
_iterator19.e(_context63.t1);
|
|
6646
6681
|
case 32:
|
|
6647
6682
|
_context63.prev = 32;
|
|
6648
|
-
|
|
6683
|
+
_iterator19.f();
|
|
6649
6684
|
return _context63.finish(32);
|
|
6650
6685
|
case 35:
|
|
6651
6686
|
notifyEndAt = Date.now();
|
|
@@ -6675,7 +6710,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6675
6710
|
}, {
|
|
6676
6711
|
key: "notifySalesSearchSubscribers",
|
|
6677
6712
|
value: function notifySalesSearchSubscribers(payload) {
|
|
6678
|
-
var
|
|
6713
|
+
var _this18 = this;
|
|
6679
6714
|
if (this.salesSearchSubscribers.size === 0) return;
|
|
6680
6715
|
var changedOrders = this.extractChangedOrdersFromPayload(payload);
|
|
6681
6716
|
if (changedOrders.length === 0) {
|
|
@@ -6684,42 +6719,42 @@ var Server = /*#__PURE__*/function () {
|
|
|
6684
6719
|
// 如果当前开启了 checkout 弹窗,先不进行刷新,下面的代码会导致在全局搜索页调用 bookingTicket.destroy()
|
|
6685
6720
|
// 导致模块被销毁 ,checkout 弹窗永远无法关闭
|
|
6686
6721
|
if (window.isPaymentModalPluginOpen) return;
|
|
6687
|
-
var
|
|
6688
|
-
|
|
6722
|
+
var _iterator20 = _createForOfIteratorHelper(this.salesSearchSubscribers.entries()),
|
|
6723
|
+
_step20;
|
|
6689
6724
|
try {
|
|
6690
|
-
var
|
|
6691
|
-
var
|
|
6692
|
-
subscriberId =
|
|
6693
|
-
subscriber =
|
|
6725
|
+
var _loop = function _loop() {
|
|
6726
|
+
var _step20$value = _slicedToArray(_step20.value, 2),
|
|
6727
|
+
subscriberId = _step20$value[0],
|
|
6728
|
+
subscriber = _step20$value[1];
|
|
6694
6729
|
try {
|
|
6695
6730
|
var changedVisibleOrders = changedOrders.filter(function (order) {
|
|
6696
|
-
var orderId =
|
|
6731
|
+
var orderId = _this18.getSalesSearchOrderId(order);
|
|
6697
6732
|
return !!orderId && subscriber.visibleOrderIds.has(orderId);
|
|
6698
6733
|
});
|
|
6699
6734
|
if (changedVisibleOrders.length === 0) {
|
|
6700
6735
|
return 1; // continue
|
|
6701
6736
|
}
|
|
6702
|
-
subscriber.callback(
|
|
6703
|
-
|
|
6737
|
+
subscriber.callback(_this18.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
|
|
6738
|
+
_this18.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
|
|
6704
6739
|
subscriberId: subscriberId,
|
|
6705
6740
|
kind: subscriber.kind,
|
|
6706
6741
|
count: changedVisibleOrders.length
|
|
6707
6742
|
});
|
|
6708
6743
|
} catch (error) {
|
|
6709
6744
|
var errorMessage = error instanceof Error ? error.message : String(error);
|
|
6710
|
-
|
|
6745
|
+
_this18.logError('notifySalesSearchSubscribers: 推送失败', {
|
|
6711
6746
|
subscriberId: subscriberId,
|
|
6712
6747
|
error: errorMessage
|
|
6713
6748
|
});
|
|
6714
6749
|
}
|
|
6715
6750
|
};
|
|
6716
|
-
for (
|
|
6717
|
-
if (
|
|
6751
|
+
for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
|
|
6752
|
+
if (_loop()) continue;
|
|
6718
6753
|
}
|
|
6719
6754
|
} catch (err) {
|
|
6720
|
-
|
|
6755
|
+
_iterator20.e(err);
|
|
6721
6756
|
} finally {
|
|
6722
|
-
|
|
6757
|
+
_iterator20.f();
|
|
6723
6758
|
}
|
|
6724
6759
|
}
|
|
6725
6760
|
|
|
@@ -6799,7 +6834,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6799
6834
|
key: "recomputeAndNotifyBookingQuery",
|
|
6800
6835
|
value: (function () {
|
|
6801
6836
|
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64() {
|
|
6802
|
-
var
|
|
6837
|
+
var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
|
|
6803
6838
|
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
6804
6839
|
while (1) switch (_context64.prev = _context64.next) {
|
|
6805
6840
|
case 0:
|
|
@@ -6812,15 +6847,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
6812
6847
|
this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
|
|
6813
6848
|
subscriberCount: this.bookingQuerySubscribers.size
|
|
6814
6849
|
});
|
|
6815
|
-
|
|
6850
|
+
_iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
|
|
6816
6851
|
_context64.prev = 4;
|
|
6817
|
-
|
|
6852
|
+
_iterator21.s();
|
|
6818
6853
|
case 6:
|
|
6819
|
-
if ((
|
|
6854
|
+
if ((_step21 = _iterator21.n()).done) {
|
|
6820
6855
|
_context64.next = 22;
|
|
6821
6856
|
break;
|
|
6822
6857
|
}
|
|
6823
|
-
|
|
6858
|
+
_step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
|
|
6824
6859
|
_context64.prev = 8;
|
|
6825
6860
|
_context64.next = 11;
|
|
6826
6861
|
return this.computeBookingQueryResult(subscriber.context);
|
|
@@ -6849,10 +6884,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
6849
6884
|
case 24:
|
|
6850
6885
|
_context64.prev = 24;
|
|
6851
6886
|
_context64.t1 = _context64["catch"](4);
|
|
6852
|
-
|
|
6887
|
+
_iterator21.e(_context64.t1);
|
|
6853
6888
|
case 27:
|
|
6854
6889
|
_context64.prev = 27;
|
|
6855
|
-
|
|
6890
|
+
_iterator21.f();
|
|
6856
6891
|
return _context64.finish(27);
|
|
6857
6892
|
case 30:
|
|
6858
6893
|
case "end":
|
|
@@ -6888,11 +6923,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6888
6923
|
var allowedProductIds = new Set();
|
|
6889
6924
|
var allowedCollectionIds = new Set();
|
|
6890
6925
|
var hasProductAll = false;
|
|
6891
|
-
var
|
|
6892
|
-
|
|
6926
|
+
var _iterator22 = _createForOfIteratorHelper(activeMenuList),
|
|
6927
|
+
_step22;
|
|
6893
6928
|
try {
|
|
6894
|
-
for (
|
|
6895
|
-
var menu =
|
|
6929
|
+
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
6930
|
+
var menu = _step22.value;
|
|
6896
6931
|
var config = menu.partyroom_package;
|
|
6897
6932
|
if (!config) {
|
|
6898
6933
|
console.warn('[Server] 餐牌缺少 partyroom_package 配置:', menu);
|
|
@@ -6952,9 +6987,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6952
6987
|
|
|
6953
6988
|
// 如果有餐牌允许所有商品,返回所有商品
|
|
6954
6989
|
} catch (err) {
|
|
6955
|
-
|
|
6990
|
+
_iterator22.e(err);
|
|
6956
6991
|
} finally {
|
|
6957
|
-
|
|
6992
|
+
_iterator22.f();
|
|
6958
6993
|
}
|
|
6959
6994
|
if (hasProductAll) {
|
|
6960
6995
|
this.logInfo('getProductScopeByMenuConfig: 返回所有商品 scope(product_all)');
|