@pisell/pisellos 2.2.258 → 2.2.260
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +152 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +755 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +282 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +146 -0
- package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
- package/dist/model/strategy/adapter/index.d.ts +4 -0
- package/dist/model/strategy/adapter/index.js +5 -1
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +13 -17
- package/dist/modules/Order/index.d.ts +2 -30
- package/dist/modules/Order/index.js +241 -508
- package/dist/modules/Order/types.d.ts +2 -20
- package/dist/modules/Order/utils.d.ts +0 -4
- package/dist/modules/Order/utils.js +28 -114
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/types.d.ts +22 -0
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -2
- package/dist/modules/ProductList/types.d.ts +2 -0
- package/dist/modules/Rules/index.d.ts +3 -3
- package/dist/modules/Rules/index.js +3 -8
- package/dist/modules/Rules/types.d.ts +1 -2
- package/dist/server/index.d.ts +50 -3
- package/dist/server/index.js +958 -1000
- package/dist/server/modules/order/index.d.ts +3 -22
- package/dist/server/modules/order/index.js +314 -397
- package/dist/server/modules/products/index.d.ts +26 -7
- package/dist/server/modules/products/index.js +166 -76
- package/dist/server/modules/products/types.d.ts +14 -0
- package/dist/solution/BaseSales/index.d.ts +2 -16
- package/dist/solution/BaseSales/index.js +314 -484
- package/dist/solution/BaseSales/types.d.ts +0 -1
- package/dist/solution/BaseSales/types.js +1 -2
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -4
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -9
- package/dist/solution/BookingTicket/index.js +6 -162
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +139 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +564 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/examples.js +295 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +146 -0
- package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
- package/lib/model/strategy/adapter/index.d.ts +4 -0
- package/lib/model/strategy/adapter/index.js +13 -2
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -11
- package/lib/modules/Order/index.d.ts +2 -30
- package/lib/modules/Order/index.js +57 -340
- package/lib/modules/Order/types.d.ts +2 -20
- package/lib/modules/Order/utils.d.ts +0 -4
- package/lib/modules/Order/utils.js +2 -84
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +22 -0
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +4 -2
- package/lib/modules/ProductList/types.d.ts +2 -0
- package/lib/modules/Rules/index.d.ts +3 -3
- package/lib/modules/Rules/index.js +3 -4
- package/lib/modules/Rules/types.d.ts +1 -2
- package/lib/server/index.d.ts +50 -3
- package/lib/server/index.js +215 -230
- package/lib/server/modules/order/index.d.ts +3 -22
- package/lib/server/modules/order/index.js +51 -102
- package/lib/server/modules/products/index.d.ts +26 -7
- package/lib/server/modules/products/index.js +113 -35
- package/lib/server/modules/products/types.d.ts +14 -0
- package/lib/solution/BaseSales/index.d.ts +2 -16
- package/lib/solution/BaseSales/index.js +31 -143
- package/lib/solution/BaseSales/types.d.ts +0 -1
- package/lib/solution/BaseSales/types.js +1 -2
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +5 -4
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -9
- package/lib/solution/BookingTicket/index.js +0 -112
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/package.json +1 -1
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
- package/dist/modules/Order/utils/bundleDiscountHydration.js +0 -144
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
- package/lib/modules/Order/utils/bundleDiscountHydration.js +0 -139
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$app3;
|
|
66
66
|
_classCallCheck(this, Server);
|
|
67
67
|
_defineProperty(this, "core", void 0);
|
|
68
68
|
_defineProperty(this, "app", void 0);
|
|
@@ -93,6 +93,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
93
93
|
});
|
|
94
94
|
// ---- 商品查询订阅者 ----
|
|
95
95
|
_defineProperty(this, "productQuerySubscribers", new Map());
|
|
96
|
+
/** subscriberId → 智能定价变价时间点定时器句柄(与 subscriber 分离存储,便于 clear) */
|
|
97
|
+
_defineProperty(this, "productQueryScheduleTimers", new Map());
|
|
96
98
|
// ---- 订单 / 预约列表查询订阅者 ----
|
|
97
99
|
_defineProperty(this, "orderQuerySubscribers", new Map());
|
|
98
100
|
_defineProperty(this, "bookingQuerySubscribers", new Map());
|
|
@@ -271,13 +273,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
271
273
|
*/
|
|
272
274
|
_defineProperty(this, "handleProductQuery", /*#__PURE__*/function () {
|
|
273
275
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref5) {
|
|
274
|
-
var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, extension_type, _ref7, callback, subscriberId;
|
|
276
|
+
var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, extension_type, strategy_context, _ref7, callback, subscriberId, result;
|
|
275
277
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
276
278
|
while (1) switch (_context3.prev = _context3.next) {
|
|
277
279
|
case 0:
|
|
278
280
|
url = _ref5.url, method = _ref5.method, data = _ref5.data, config = _ref5.config;
|
|
279
281
|
console.log('[Server] handleProductQuery:', url, method, data, config);
|
|
280
|
-
menu_list_ids = data.menu_list_ids, schedule_datetime = data.schedule_datetime, schedule_date = data.schedule_date, customer_id = data.customer_id, ids = data.ids, extension_type = data.extension_type;
|
|
282
|
+
menu_list_ids = data.menu_list_ids, schedule_datetime = data.schedule_datetime, schedule_date = data.schedule_date, customer_id = data.customer_id, ids = data.ids, extension_type = data.extension_type, strategy_context = data.strategy_context;
|
|
281
283
|
_ref7 = config || {}, callback = _ref7.callback, subscriberId = _ref7.subscriberId;
|
|
282
284
|
_this.logInfo('handleProductQuery: 开始处理商品查询请求', {
|
|
283
285
|
menu_list_ids: menu_list_ids,
|
|
@@ -285,7 +287,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
285
287
|
schedule_datetime: schedule_datetime,
|
|
286
288
|
schedule_date: schedule_date,
|
|
287
289
|
customer_id: customer_id,
|
|
288
|
-
extension_type: extension_type
|
|
290
|
+
extension_type: extension_type,
|
|
291
|
+
strategyContextKeys: strategy_context ? Object.keys(strategy_context) : []
|
|
289
292
|
});
|
|
290
293
|
|
|
291
294
|
// 存储订阅者:后续 pubsub 数据变更时可通过 callback 推送最新结果
|
|
@@ -298,7 +301,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
298
301
|
schedule_date: schedule_date,
|
|
299
302
|
schedule_datetime: schedule_datetime,
|
|
300
303
|
customer_id: customer_id,
|
|
301
|
-
extension_type: extension_type
|
|
304
|
+
extension_type: extension_type,
|
|
305
|
+
strategy_context: strategy_context
|
|
302
306
|
}
|
|
303
307
|
});
|
|
304
308
|
_this.logInfo('handleProductQuery: 已注册订阅者', {
|
|
@@ -306,15 +310,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
306
310
|
totalSubscribers: _this.productQuerySubscribers.size
|
|
307
311
|
});
|
|
308
312
|
}
|
|
309
|
-
|
|
313
|
+
_context3.next = 8;
|
|
314
|
+
return _this.computeProductQueryResult({
|
|
310
315
|
menu_list_ids: menu_list_ids,
|
|
311
316
|
ids: ids,
|
|
312
317
|
schedule_date: schedule_date,
|
|
313
318
|
schedule_datetime: schedule_datetime,
|
|
314
319
|
customer_id: customer_id,
|
|
315
|
-
extension_type: extension_type
|
|
316
|
-
|
|
317
|
-
|
|
320
|
+
extension_type: extension_type,
|
|
321
|
+
strategy_context: strategy_context
|
|
322
|
+
});
|
|
323
|
+
case 8:
|
|
324
|
+
result = _context3.sent;
|
|
325
|
+
if (subscriberId && typeof callback === 'function') {
|
|
326
|
+
_this.syncProductQueryScheduleTimers(subscriberId, strategy_context);
|
|
327
|
+
}
|
|
328
|
+
return _context3.abrupt("return", result);
|
|
329
|
+
case 11:
|
|
318
330
|
case "end":
|
|
319
331
|
return _context3.stop();
|
|
320
332
|
}
|
|
@@ -1029,8 +1041,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1029
1041
|
checkoutData: checkoutData,
|
|
1030
1042
|
order: printableOrder,
|
|
1031
1043
|
response: null,
|
|
1032
|
-
requireFullyPaid: false
|
|
1033
|
-
isManualPrint: true
|
|
1044
|
+
requireFullyPaid: false
|
|
1034
1045
|
});
|
|
1035
1046
|
case 27:
|
|
1036
1047
|
printResult = _context16.sent;
|
|
@@ -1069,129 +1080,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1069
1080
|
return _ref39.apply(this, arguments);
|
|
1070
1081
|
};
|
|
1071
1082
|
}());
|
|
1072
|
-
_defineProperty(this, "
|
|
1083
|
+
_defineProperty(this, "handleOrderSalesDetail", /*#__PURE__*/function () {
|
|
1073
1084
|
var _ref43 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref42) {
|
|
1074
|
-
var _this$
|
|
1075
|
-
var
|
|
1085
|
+
var _this$app2;
|
|
1086
|
+
var url, data, path, requestPath, lookup, localOrder, backendPath, _response$data2, response, fresh, savedOrder, errorMessage;
|
|
1076
1087
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1077
1088
|
while (1) switch (_context17.prev = _context17.next) {
|
|
1078
1089
|
case 0:
|
|
1079
|
-
data = _ref42.data;
|
|
1080
|
-
title = 'handleMachinecodeBatchMetadata';
|
|
1081
|
-
backendPath = '/shop/machinecode/batch-metadata';
|
|
1082
|
-
batchMetadata = Array.isArray(data === null || data === void 0 ? void 0 : data.data) ? data.data : [];
|
|
1083
|
-
_this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
|
|
1084
|
-
backendPath: backendPath,
|
|
1085
|
-
batchSize: batchMetadata.length,
|
|
1086
|
-
order_lookup: (_this$resolveMachinec = _this.resolveMachinecodeBatchMetadataLookup(data)) !== null && _this$resolveMachinec !== void 0 ? _this$resolveMachinec : null
|
|
1087
|
-
});
|
|
1088
|
-
if (!(batchMetadata.length === 0)) {
|
|
1089
|
-
_context17.next = 7;
|
|
1090
|
-
break;
|
|
1091
|
-
}
|
|
1092
|
-
return _context17.abrupt("return", {
|
|
1093
|
-
code: 200,
|
|
1094
|
-
status: true,
|
|
1095
|
-
message: '',
|
|
1096
|
-
data: []
|
|
1097
|
-
});
|
|
1098
|
-
case 7:
|
|
1099
|
-
_context17.prev = 7;
|
|
1100
|
-
_context17.next = 10;
|
|
1101
|
-
return _this.syncMachinecodeBatchMetadataToLocalOrder(data, batchMetadata);
|
|
1102
|
-
case 10:
|
|
1103
|
-
_context17.next = 17;
|
|
1104
|
-
break;
|
|
1105
|
-
case 12:
|
|
1106
|
-
_context17.prev = 12;
|
|
1107
|
-
_context17.t0 = _context17["catch"](7);
|
|
1108
|
-
message = _this.getUnknownErrorMessage(_context17.t0);
|
|
1109
|
-
_this.logError("".concat(title, ": \u672C\u5730\u8BA2\u5355 metadata \u66F4\u65B0\u5931\u8D25"), {
|
|
1110
|
-
error: message,
|
|
1111
|
-
error_detail: _this.normalizeUnknownError(_context17.t0)
|
|
1112
|
-
});
|
|
1113
|
-
return _context17.abrupt("return", {
|
|
1114
|
-
code: 500,
|
|
1115
|
-
status: false,
|
|
1116
|
-
message: message,
|
|
1117
|
-
data: null
|
|
1118
|
-
});
|
|
1119
|
-
case 17:
|
|
1120
|
-
if ((_this$app2 = _this.app) !== null && _this$app2 !== void 0 && (_this$app2 = _this$app2.request) !== null && _this$app2 !== void 0 && _this$app2.post) {
|
|
1121
|
-
_context17.next = 20;
|
|
1122
|
-
break;
|
|
1123
|
-
}
|
|
1124
|
-
_this.logError("".concat(title, ": app.request \u4E0D\u53EF\u7528"), {
|
|
1125
|
-
backendPath: backendPath
|
|
1126
|
-
});
|
|
1127
|
-
return _context17.abrupt("return", {
|
|
1128
|
-
code: 500,
|
|
1129
|
-
status: false,
|
|
1130
|
-
message: 'app.request 不可用',
|
|
1131
|
-
data: null
|
|
1132
|
-
});
|
|
1133
|
-
case 20:
|
|
1134
|
-
_context17.prev = 20;
|
|
1135
|
-
_context17.next = 23;
|
|
1136
|
-
return _this.app.request.post(backendPath, {
|
|
1137
|
-
data: batchMetadata
|
|
1138
|
-
}, {
|
|
1139
|
-
isShopApi: true,
|
|
1140
|
-
customToast: function customToast() {}
|
|
1141
|
-
});
|
|
1142
|
-
case 23:
|
|
1143
|
-
response = _context17.sent;
|
|
1144
|
-
return _context17.abrupt("return", {
|
|
1145
|
-
code: (_response$code = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code !== void 0 ? _response$code : 200,
|
|
1146
|
-
status: (_response$status = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status !== void 0 ? _response$status : true,
|
|
1147
|
-
message: (_response$message = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message !== void 0 ? _response$message : '',
|
|
1148
|
-
data: (_response$data2 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data2 !== void 0 ? _response$data2 : response
|
|
1149
|
-
});
|
|
1150
|
-
case 27:
|
|
1151
|
-
_context17.prev = 27;
|
|
1152
|
-
_context17.t1 = _context17["catch"](20);
|
|
1153
|
-
backendError = _this.extractBackendErrorResponse(_context17.t1);
|
|
1154
|
-
if (!backendError) {
|
|
1155
|
-
_context17.next = 32;
|
|
1156
|
-
break;
|
|
1157
|
-
}
|
|
1158
|
-
return _context17.abrupt("return", {
|
|
1159
|
-
code: (_backendError$code = backendError.code) !== null && _backendError$code !== void 0 ? _backendError$code : 500,
|
|
1160
|
-
status: (_backendError$status = backendError.status) !== null && _backendError$status !== void 0 ? _backendError$status : false,
|
|
1161
|
-
message: (_backendError$message = backendError.message) !== null && _backendError$message !== void 0 ? _backendError$message : '后端拒绝 batch-metadata',
|
|
1162
|
-
data: (_backendError$data = backendError.data) !== null && _backendError$data !== void 0 ? _backendError$data : null
|
|
1163
|
-
});
|
|
1164
|
-
case 32:
|
|
1165
|
-
_message = _this.getUnknownErrorMessage(_context17.t1);
|
|
1166
|
-
_this.logError("".concat(title, ": \u8BF7\u6C42\u5931\u8D25"), {
|
|
1167
|
-
backendPath: backendPath,
|
|
1168
|
-
error: _message,
|
|
1169
|
-
error_detail: _this.normalizeUnknownError(_context17.t1)
|
|
1170
|
-
});
|
|
1171
|
-
return _context17.abrupt("return", {
|
|
1172
|
-
code: 500,
|
|
1173
|
-
status: false,
|
|
1174
|
-
message: _message,
|
|
1175
|
-
data: null
|
|
1176
|
-
});
|
|
1177
|
-
case 35:
|
|
1178
|
-
case "end":
|
|
1179
|
-
return _context17.stop();
|
|
1180
|
-
}
|
|
1181
|
-
}, _callee17, null, [[7, 12], [20, 27]]);
|
|
1182
|
-
}));
|
|
1183
|
-
return function (_x17) {
|
|
1184
|
-
return _ref43.apply(this, arguments);
|
|
1185
|
-
};
|
|
1186
|
-
}());
|
|
1187
|
-
_defineProperty(this, "handleOrderSalesDetail", /*#__PURE__*/function () {
|
|
1188
|
-
var _ref45 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref44) {
|
|
1189
|
-
var _this$app3;
|
|
1190
|
-
var url, data, path, requestPath, lookup, localOrder, backendPath, _response$data3, response, fresh, savedOrder, errorMessage;
|
|
1191
|
-
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1192
|
-
while (1) switch (_context18.prev = _context18.next) {
|
|
1193
|
-
case 0:
|
|
1194
|
-
url = _ref44.url, data = _ref44.data, path = _ref44.path;
|
|
1090
|
+
url = _ref42.url, data = _ref42.data, path = _ref42.path;
|
|
1195
1091
|
requestPath = _this.parseRequestPath(url, path);
|
|
1196
1092
|
lookup = _this.extractOrderSalesDetailLookup(requestPath);
|
|
1197
1093
|
_this.logInfo('handleOrderSalesDetail: 开始处理', {
|
|
@@ -1200,14 +1096,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1200
1096
|
lookup: lookup
|
|
1201
1097
|
});
|
|
1202
1098
|
if (lookup) {
|
|
1203
|
-
|
|
1099
|
+
_context17.next = 7;
|
|
1204
1100
|
break;
|
|
1205
1101
|
}
|
|
1206
1102
|
_this.logWarning('handleOrderSalesDetail: lookup 缺失', {
|
|
1207
1103
|
url: url,
|
|
1208
1104
|
path: requestPath
|
|
1209
1105
|
});
|
|
1210
|
-
return
|
|
1106
|
+
return _context17.abrupt("return", {
|
|
1211
1107
|
code: 400,
|
|
1212
1108
|
status: false,
|
|
1213
1109
|
message: '订单 lookup 缺失',
|
|
@@ -1215,11 +1111,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
1215
1111
|
});
|
|
1216
1112
|
case 7:
|
|
1217
1113
|
if (_this.order) {
|
|
1218
|
-
|
|
1114
|
+
_context17.next = 10;
|
|
1219
1115
|
break;
|
|
1220
1116
|
}
|
|
1221
1117
|
_this.logError('handleOrderSalesDetail: Order 模块未注册');
|
|
1222
|
-
return
|
|
1118
|
+
return _context17.abrupt("return", {
|
|
1223
1119
|
code: 500,
|
|
1224
1120
|
status: false,
|
|
1225
1121
|
message: 'Order 模块未注册',
|
|
@@ -1227,33 +1123,33 @@ var Server = /*#__PURE__*/function () {
|
|
|
1227
1123
|
});
|
|
1228
1124
|
case 10:
|
|
1229
1125
|
if (_this.shouldForceRemoteSalesDetail(data)) {
|
|
1230
|
-
|
|
1126
|
+
_context17.next = 17;
|
|
1231
1127
|
break;
|
|
1232
1128
|
}
|
|
1233
|
-
|
|
1129
|
+
_context17.next = 13;
|
|
1234
1130
|
return _this.order.getLocalOrderByLookup(lookup);
|
|
1235
1131
|
case 13:
|
|
1236
|
-
localOrder =
|
|
1132
|
+
localOrder = _context17.sent;
|
|
1237
1133
|
if (!localOrder) {
|
|
1238
|
-
|
|
1134
|
+
_context17.next = 17;
|
|
1239
1135
|
break;
|
|
1240
1136
|
}
|
|
1241
1137
|
_this.logInfo('handleOrderSalesDetail: 命中本地订单', {
|
|
1242
1138
|
lookup: lookup
|
|
1243
1139
|
});
|
|
1244
|
-
return
|
|
1140
|
+
return _context17.abrupt("return", {
|
|
1245
1141
|
code: 200,
|
|
1246
1142
|
status: true,
|
|
1247
1143
|
message: '',
|
|
1248
1144
|
data: localOrder
|
|
1249
1145
|
});
|
|
1250
1146
|
case 17:
|
|
1251
|
-
if ((_this$
|
|
1252
|
-
|
|
1147
|
+
if ((_this$app2 = _this.app) !== null && _this$app2 !== void 0 && _this$app2.request) {
|
|
1148
|
+
_context17.next = 20;
|
|
1253
1149
|
break;
|
|
1254
1150
|
}
|
|
1255
1151
|
_this.logError('handleOrderSalesDetail: app.request 不可用');
|
|
1256
|
-
return
|
|
1152
|
+
return _context17.abrupt("return", {
|
|
1257
1153
|
code: 500,
|
|
1258
1154
|
status: false,
|
|
1259
1155
|
message: 'app.request 不可用',
|
|
@@ -1261,8 +1157,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
1261
1157
|
});
|
|
1262
1158
|
case 20:
|
|
1263
1159
|
backendPath = _this.buildOrderSalesDetailBackendPath(lookup, data);
|
|
1264
|
-
|
|
1265
|
-
|
|
1160
|
+
_context17.prev = 21;
|
|
1161
|
+
_context17.next = 24;
|
|
1266
1162
|
return _this.app.request.get(backendPath, {
|
|
1267
1163
|
lookup_mode: 'multi'
|
|
1268
1164
|
}, {
|
|
@@ -1270,38 +1166,38 @@ var Server = /*#__PURE__*/function () {
|
|
|
1270
1166
|
customToast: function customToast() {}
|
|
1271
1167
|
});
|
|
1272
1168
|
case 24:
|
|
1273
|
-
response =
|
|
1274
|
-
fresh = (_response$
|
|
1169
|
+
response = _context17.sent;
|
|
1170
|
+
fresh = (_response$data2 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data2 !== void 0 ? _response$data2 : response;
|
|
1275
1171
|
if (!(!fresh || _typeof(fresh) !== 'object' || fresh.order_id == null)) {
|
|
1276
|
-
|
|
1172
|
+
_context17.next = 29;
|
|
1277
1173
|
break;
|
|
1278
1174
|
}
|
|
1279
1175
|
_this.logInfo('handleOrderSalesDetail: 后端返回订单为空', {
|
|
1280
1176
|
lookup: lookup,
|
|
1281
1177
|
backendPath: backendPath
|
|
1282
1178
|
});
|
|
1283
|
-
return
|
|
1179
|
+
return _context17.abrupt("return", {
|
|
1284
1180
|
code: 500,
|
|
1285
1181
|
status: false,
|
|
1286
1182
|
message: '后端返回订单为空',
|
|
1287
1183
|
data: null
|
|
1288
1184
|
});
|
|
1289
1185
|
case 29:
|
|
1290
|
-
|
|
1186
|
+
_context17.next = 31;
|
|
1291
1187
|
return _this.order.upsertOrdersFromRemote([fresh]);
|
|
1292
1188
|
case 31:
|
|
1293
|
-
|
|
1189
|
+
_context17.next = 33;
|
|
1294
1190
|
return _this.order.getLocalOrderByLookup(lookup);
|
|
1295
1191
|
case 33:
|
|
1296
|
-
savedOrder =
|
|
1192
|
+
savedOrder = _context17.sent;
|
|
1297
1193
|
if (savedOrder) {
|
|
1298
|
-
|
|
1194
|
+
_context17.next = 37;
|
|
1299
1195
|
break;
|
|
1300
1196
|
}
|
|
1301
1197
|
_this.logError('handleOrderSalesDetail: 订单写入后回读失败', {
|
|
1302
1198
|
lookup: lookup
|
|
1303
1199
|
});
|
|
1304
|
-
return
|
|
1200
|
+
return _context17.abrupt("return", {
|
|
1305
1201
|
code: 500,
|
|
1306
1202
|
status: false,
|
|
1307
1203
|
message: '订单写入后回读失败',
|
|
@@ -1311,22 +1207,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
1311
1207
|
_this.logInfo('handleOrderSalesDetail: 远端订单已同步到本地', {
|
|
1312
1208
|
lookup: lookup
|
|
1313
1209
|
});
|
|
1314
|
-
return
|
|
1210
|
+
return _context17.abrupt("return", {
|
|
1315
1211
|
code: 200,
|
|
1316
1212
|
status: true,
|
|
1317
1213
|
message: '',
|
|
1318
1214
|
data: savedOrder
|
|
1319
1215
|
});
|
|
1320
1216
|
case 41:
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
errorMessage =
|
|
1324
|
-
_this.
|
|
1217
|
+
_context17.prev = 41;
|
|
1218
|
+
_context17.t0 = _context17["catch"](21);
|
|
1219
|
+
errorMessage = _context17.t0 instanceof Error ? _context17.t0.message : String(_context17.t0);
|
|
1220
|
+
_this.logError('handleOrderSalesDetail: 请求失败', {
|
|
1325
1221
|
lookup: lookup,
|
|
1326
1222
|
backendPath: backendPath,
|
|
1327
1223
|
error: errorMessage
|
|
1328
1224
|
});
|
|
1329
|
-
return
|
|
1225
|
+
return _context17.abrupt("return", {
|
|
1330
1226
|
code: 500,
|
|
1331
1227
|
status: false,
|
|
1332
1228
|
message: errorMessage,
|
|
@@ -1334,28 +1230,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
1334
1230
|
});
|
|
1335
1231
|
case 46:
|
|
1336
1232
|
case "end":
|
|
1337
|
-
return
|
|
1233
|
+
return _context17.stop();
|
|
1338
1234
|
}
|
|
1339
|
-
},
|
|
1235
|
+
}, _callee17, null, [[21, 41]]);
|
|
1340
1236
|
}));
|
|
1341
|
-
return function (
|
|
1342
|
-
return
|
|
1237
|
+
return function (_x17) {
|
|
1238
|
+
return _ref43.apply(this, arguments);
|
|
1343
1239
|
};
|
|
1344
1240
|
}());
|
|
1345
1241
|
/**
|
|
1346
1242
|
* GET /shop/schedule/floor-plan* 前缀路由:读本地 store;支持 subscriberId + callback 订阅更新
|
|
1347
1243
|
*/
|
|
1348
1244
|
_defineProperty(this, "handleFloorPlanGet", /*#__PURE__*/function () {
|
|
1349
|
-
var
|
|
1350
|
-
var url, data, config, routePath, base, path, _subscriberId,
|
|
1351
|
-
return _regeneratorRuntime().wrap(function
|
|
1352
|
-
while (1) switch (
|
|
1245
|
+
var _ref45 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref44) {
|
|
1246
|
+
var url, data, config, routePath, base, path, _subscriberId, _ref46, callback, subscriberId, ctx;
|
|
1247
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1248
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1353
1249
|
case 0:
|
|
1354
|
-
url =
|
|
1250
|
+
url = _ref44.url, data = _ref44.data, config = _ref44.config, routePath = _ref44.path;
|
|
1355
1251
|
base = '/shop/schedule/floor-plan';
|
|
1356
1252
|
path = _this.parseRequestPath(url, routePath);
|
|
1357
1253
|
if (!(path === "".concat(base, "/unsubscribe") || path === "".concat(base, "/code/unsubscribe"))) {
|
|
1358
|
-
|
|
1254
|
+
_context18.next = 7;
|
|
1359
1255
|
break;
|
|
1360
1256
|
}
|
|
1361
1257
|
_subscriberId = data === null || data === void 0 ? void 0 : data.subscriberId;
|
|
@@ -1366,19 +1262,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
1366
1262
|
remaining: _this.floorPlanQuerySubscribers.size
|
|
1367
1263
|
});
|
|
1368
1264
|
}
|
|
1369
|
-
return
|
|
1265
|
+
return _context18.abrupt("return", {
|
|
1370
1266
|
code: 200,
|
|
1371
1267
|
message: 'ok',
|
|
1372
1268
|
status: true
|
|
1373
1269
|
});
|
|
1374
1270
|
case 7:
|
|
1375
|
-
|
|
1271
|
+
_ref46 = config || {}, callback = _ref46.callback, subscriberId = _ref46.subscriberId;
|
|
1376
1272
|
ctx = _this.resolveFloorPlanQueryContext(path, base);
|
|
1377
1273
|
if (ctx) {
|
|
1378
|
-
|
|
1274
|
+
_context18.next = 11;
|
|
1379
1275
|
break;
|
|
1380
1276
|
}
|
|
1381
|
-
return
|
|
1277
|
+
return _context18.abrupt("return", {
|
|
1382
1278
|
status: false,
|
|
1383
1279
|
code: 404,
|
|
1384
1280
|
message: 'Not Found',
|
|
@@ -1396,28 +1292,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
1396
1292
|
total: _this.floorPlanQuerySubscribers.size
|
|
1397
1293
|
});
|
|
1398
1294
|
}
|
|
1399
|
-
return
|
|
1295
|
+
return _context18.abrupt("return", _this.computeFloorPlanQueryResult(ctx));
|
|
1400
1296
|
case 13:
|
|
1401
1297
|
case "end":
|
|
1402
|
-
return
|
|
1298
|
+
return _context18.stop();
|
|
1403
1299
|
}
|
|
1404
|
-
},
|
|
1300
|
+
}, _callee18);
|
|
1405
1301
|
}));
|
|
1406
|
-
return function (
|
|
1407
|
-
return
|
|
1302
|
+
return function (_x18) {
|
|
1303
|
+
return _ref45.apply(this, arguments);
|
|
1408
1304
|
};
|
|
1409
1305
|
}());
|
|
1410
1306
|
/**
|
|
1411
1307
|
* 取消预约列表查询订阅(HTTP 路由入口)
|
|
1412
1308
|
*/
|
|
1413
1309
|
_defineProperty(this, "handleUnsubscribeBookingQuery", /*#__PURE__*/function () {
|
|
1414
|
-
var
|
|
1415
|
-
var data,
|
|
1416
|
-
return _regeneratorRuntime().wrap(function
|
|
1417
|
-
while (1) switch (
|
|
1310
|
+
var _ref48 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(_ref47) {
|
|
1311
|
+
var data, _ref49, subscriberId;
|
|
1312
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1313
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1418
1314
|
case 0:
|
|
1419
|
-
data =
|
|
1420
|
-
|
|
1315
|
+
data = _ref47.data;
|
|
1316
|
+
_ref49 = data || {}, subscriberId = _ref49.subscriberId;
|
|
1421
1317
|
if (subscriberId) {
|
|
1422
1318
|
_this.bookingQuerySubscribers.delete(subscriberId);
|
|
1423
1319
|
_this.bookingRemoteQuerySubscribers.delete(subscriberId);
|
|
@@ -1427,19 +1323,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
1427
1323
|
remainingRemote: _this.bookingRemoteQuerySubscribers.size
|
|
1428
1324
|
});
|
|
1429
1325
|
}
|
|
1430
|
-
return
|
|
1326
|
+
return _context19.abrupt("return", {
|
|
1431
1327
|
code: 200,
|
|
1432
1328
|
message: 'ok',
|
|
1433
1329
|
status: true
|
|
1434
1330
|
});
|
|
1435
1331
|
case 4:
|
|
1436
1332
|
case "end":
|
|
1437
|
-
return
|
|
1333
|
+
return _context19.stop();
|
|
1438
1334
|
}
|
|
1439
|
-
},
|
|
1335
|
+
}, _callee19);
|
|
1440
1336
|
}));
|
|
1441
|
-
return function (
|
|
1442
|
-
return
|
|
1337
|
+
return function (_x19) {
|
|
1338
|
+
return _ref48.apply(this, arguments);
|
|
1443
1339
|
};
|
|
1444
1340
|
}());
|
|
1445
1341
|
/**
|
|
@@ -1447,13 +1343,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
1447
1343
|
* 通过餐牌ID列表获取所有相关日程的时间段点
|
|
1448
1344
|
*/
|
|
1449
1345
|
_defineProperty(this, "handleGetScheduleTimePoints", /*#__PURE__*/function () {
|
|
1450
|
-
var
|
|
1346
|
+
var _ref51 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(_ref50) {
|
|
1451
1347
|
var _menu_list_ids$length;
|
|
1452
1348
|
var url, method, data, config, menu_list_ids, _menu_list_ids$length2, menuList, scheduleIds, scheduleList, timePoints, errorMessage;
|
|
1453
|
-
return _regeneratorRuntime().wrap(function
|
|
1454
|
-
while (1) switch (
|
|
1349
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1350
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1455
1351
|
case 0:
|
|
1456
|
-
url =
|
|
1352
|
+
url = _ref50.url, method = _ref50.method, data = _ref50.data, config = _ref50.config;
|
|
1457
1353
|
console.log('[Server] handleGetScheduleTimePoints:', url, method, data, config);
|
|
1458
1354
|
menu_list_ids = data.menu_list_ids;
|
|
1459
1355
|
_this.logInfo('handleGetScheduleTimePoints 开始处理', {
|
|
@@ -1463,12 +1359,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
1463
1359
|
|
|
1464
1360
|
// 检查必要的模块是否已注册
|
|
1465
1361
|
if (_this.menu) {
|
|
1466
|
-
|
|
1362
|
+
_context20.next = 8;
|
|
1467
1363
|
break;
|
|
1468
1364
|
}
|
|
1469
1365
|
console.error('[Server] Menu 模块未注册');
|
|
1470
1366
|
_this.logError('handleGetScheduleTimePoints: Menu 模块未注册');
|
|
1471
|
-
return
|
|
1367
|
+
return _context20.abrupt("return", {
|
|
1472
1368
|
code: 500,
|
|
1473
1369
|
message: 'Menu 模块未注册',
|
|
1474
1370
|
data: [],
|
|
@@ -1476,12 +1372,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
1476
1372
|
});
|
|
1477
1373
|
case 8:
|
|
1478
1374
|
if (_this.schedule) {
|
|
1479
|
-
|
|
1375
|
+
_context20.next = 12;
|
|
1480
1376
|
break;
|
|
1481
1377
|
}
|
|
1482
1378
|
console.error('[Server] Schedule 模块未注册');
|
|
1483
1379
|
_this.logError('handleGetScheduleTimePoints: Schedule 模块未注册');
|
|
1484
|
-
return
|
|
1380
|
+
return _context20.abrupt("return", {
|
|
1485
1381
|
code: 500,
|
|
1486
1382
|
message: 'Schedule 模块未注册',
|
|
1487
1383
|
data: [],
|
|
@@ -1489,7 +1385,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1489
1385
|
});
|
|
1490
1386
|
case 12:
|
|
1491
1387
|
if (!(!menu_list_ids || !Array.isArray(menu_list_ids) || menu_list_ids.length === 0)) {
|
|
1492
|
-
|
|
1388
|
+
_context20.next = 16;
|
|
1493
1389
|
break;
|
|
1494
1390
|
}
|
|
1495
1391
|
console.error('[Server] menu_list_ids 参数无效');
|
|
@@ -1497,14 +1393,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1497
1393
|
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,
|
|
1498
1394
|
menu_list_ids: menu_list_ids
|
|
1499
1395
|
});
|
|
1500
|
-
return
|
|
1396
|
+
return _context20.abrupt("return", {
|
|
1501
1397
|
code: 400,
|
|
1502
1398
|
message: 'menu_list_ids 参数无效',
|
|
1503
1399
|
data: [],
|
|
1504
1400
|
status: false
|
|
1505
1401
|
});
|
|
1506
1402
|
case 16:
|
|
1507
|
-
|
|
1403
|
+
_context20.prev = 16;
|
|
1508
1404
|
// 1. 获取餐牌列表
|
|
1509
1405
|
menuList = _this.menu.getMenuByIds(menu_list_ids);
|
|
1510
1406
|
console.log("[Server] \u627E\u5230 ".concat(menuList.length, " \u4E2A\u9910\u724C"));
|
|
@@ -1522,13 +1418,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
1522
1418
|
scheduleCount: scheduleIds.length
|
|
1523
1419
|
});
|
|
1524
1420
|
if (!(scheduleIds.length === 0)) {
|
|
1525
|
-
|
|
1421
|
+
_context20.next = 26;
|
|
1526
1422
|
break;
|
|
1527
1423
|
}
|
|
1528
1424
|
_this.logInfo('handleGetScheduleTimePoints: 没有找到相关日程', {
|
|
1529
1425
|
menuListIdsCount: menu_list_ids.length
|
|
1530
1426
|
});
|
|
1531
|
-
return
|
|
1427
|
+
return _context20.abrupt("return", {
|
|
1532
1428
|
code: 200,
|
|
1533
1429
|
message: '没有找到相关日程',
|
|
1534
1430
|
data: [],
|
|
@@ -1552,22 +1448,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
1552
1448
|
scheduleCount: scheduleList.length,
|
|
1553
1449
|
timePointCount: timePoints.length
|
|
1554
1450
|
});
|
|
1555
|
-
return
|
|
1451
|
+
return _context20.abrupt("return", {
|
|
1556
1452
|
code: 200,
|
|
1557
1453
|
message: '获取成功',
|
|
1558
1454
|
data: timePoints,
|
|
1559
1455
|
status: true
|
|
1560
1456
|
});
|
|
1561
1457
|
case 35:
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
errorMessage =
|
|
1565
|
-
console.error('[Server] 获取日程时间点失败:',
|
|
1458
|
+
_context20.prev = 35;
|
|
1459
|
+
_context20.t0 = _context20["catch"](16);
|
|
1460
|
+
errorMessage = _context20.t0 instanceof Error ? _context20.t0.message : '未知错误';
|
|
1461
|
+
console.error('[Server] 获取日程时间点失败:', _context20.t0);
|
|
1566
1462
|
_this.logError('handleGetScheduleTimePoints: 获取日程时间点失败', {
|
|
1567
1463
|
menuListIdsCount: menu_list_ids.length,
|
|
1568
1464
|
error: errorMessage
|
|
1569
1465
|
});
|
|
1570
|
-
return
|
|
1466
|
+
return _context20.abrupt("return", {
|
|
1571
1467
|
code: 500,
|
|
1572
1468
|
message: "\u83B7\u53D6\u5931\u8D25: ".concat(errorMessage),
|
|
1573
1469
|
data: [],
|
|
@@ -1575,18 +1471,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
1575
1471
|
});
|
|
1576
1472
|
case 41:
|
|
1577
1473
|
case "end":
|
|
1578
|
-
return
|
|
1474
|
+
return _context20.stop();
|
|
1579
1475
|
}
|
|
1580
|
-
},
|
|
1476
|
+
}, _callee20, null, [[16, 35]]);
|
|
1581
1477
|
}));
|
|
1582
|
-
return function (
|
|
1583
|
-
return
|
|
1478
|
+
return function (_x20) {
|
|
1479
|
+
return _ref51.apply(this, arguments);
|
|
1584
1480
|
};
|
|
1585
1481
|
}());
|
|
1586
1482
|
this.core = core;
|
|
1587
1483
|
var appPlugin = core.getPlugin('app');
|
|
1588
1484
|
this.app = (appPlugin === null || appPlugin === void 0 ? void 0 : appPlugin.getApp()) || null;
|
|
1589
|
-
this.logger = ((_this$
|
|
1485
|
+
this.logger = ((_this$app3 = this.app) === null || _this$app3 === void 0 ? void 0 : _this$app3.logger) || null;
|
|
1590
1486
|
console.log('[Server] Server 初始化', this.core);
|
|
1591
1487
|
this.logInfo('Server 初始化', {
|
|
1592
1488
|
hasApp: !!this.app,
|
|
@@ -1701,10 +1597,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
1701
1597
|
}, {
|
|
1702
1598
|
key: "registerModuleWithRoutes",
|
|
1703
1599
|
value: (function () {
|
|
1704
|
-
var _registerModuleWithRoutes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1600
|
+
var _registerModuleWithRoutes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(module, options, moduleName) {
|
|
1705
1601
|
var routes;
|
|
1706
|
-
return _regeneratorRuntime().wrap(function
|
|
1707
|
-
while (1) switch (
|
|
1602
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1603
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1708
1604
|
case 0:
|
|
1709
1605
|
this.logInfo("\u5F00\u59CB\u6CE8\u518C\u6A21\u5757: ".concat(moduleName), {
|
|
1710
1606
|
moduleName: moduleName,
|
|
@@ -1712,7 +1608,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1712
1608
|
});
|
|
1713
1609
|
|
|
1714
1610
|
// 注册模块到 Core
|
|
1715
|
-
|
|
1611
|
+
_context21.next = 3;
|
|
1716
1612
|
return this.core.registerModule(module, options);
|
|
1717
1613
|
case 3:
|
|
1718
1614
|
console.log("[Server] \u2705 ".concat(moduleName, " \u6A21\u5757\u5DF2\u6CE8\u518C"));
|
|
@@ -1733,11 +1629,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
1733
1629
|
}
|
|
1734
1630
|
case 6:
|
|
1735
1631
|
case "end":
|
|
1736
|
-
return
|
|
1632
|
+
return _context21.stop();
|
|
1737
1633
|
}
|
|
1738
|
-
},
|
|
1634
|
+
}, _callee21, this);
|
|
1739
1635
|
}));
|
|
1740
|
-
function registerModuleWithRoutes(_x22, _x23
|
|
1636
|
+
function registerModuleWithRoutes(_x21, _x22, _x23) {
|
|
1741
1637
|
return _registerModuleWithRoutes.apply(this, arguments);
|
|
1742
1638
|
}
|
|
1743
1639
|
return registerModuleWithRoutes;
|
|
@@ -1750,10 +1646,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
1750
1646
|
}, {
|
|
1751
1647
|
key: "registerModuleByName",
|
|
1752
1648
|
value: (function () {
|
|
1753
|
-
var _registerModuleByName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1649
|
+
var _registerModuleByName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(moduleConfig) {
|
|
1754
1650
|
var moduleName, shouldPreload, customConfig, registryConfig, ModuleClass, moduleInstance, moduleOptions;
|
|
1755
|
-
return _regeneratorRuntime().wrap(function
|
|
1756
|
-
while (1) switch (
|
|
1651
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1652
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1757
1653
|
case 0:
|
|
1758
1654
|
// 解析配置
|
|
1759
1655
|
moduleName = typeof moduleConfig === 'string' ? moduleConfig : moduleConfig.name;
|
|
@@ -1768,7 +1664,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1768
1664
|
// 查找模块配置
|
|
1769
1665
|
registryConfig = this.moduleRegistry[moduleName];
|
|
1770
1666
|
if (registryConfig) {
|
|
1771
|
-
|
|
1667
|
+
_context22.next = 8;
|
|
1772
1668
|
break;
|
|
1773
1669
|
}
|
|
1774
1670
|
this.logError("\u672A\u627E\u5230\u6A21\u5757\u914D\u7F6E: ".concat(moduleName), {
|
|
@@ -1782,7 +1678,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1782
1678
|
moduleOptions = _objectSpread({
|
|
1783
1679
|
store: _objectSpread({}, registryConfig.defaultStore)
|
|
1784
1680
|
}, customConfig); // 注册模块和路由
|
|
1785
|
-
|
|
1681
|
+
_context22.next = 13;
|
|
1786
1682
|
return this.registerModuleWithRoutes(moduleInstance, moduleOptions, moduleName.charAt(0).toUpperCase() + moduleName.slice(1));
|
|
1787
1683
|
case 13:
|
|
1788
1684
|
// 保存模块实例
|
|
@@ -1792,18 +1688,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
1792
1688
|
shouldPreload: shouldPreload,
|
|
1793
1689
|
version: registryConfig.version
|
|
1794
1690
|
});
|
|
1795
|
-
return
|
|
1691
|
+
return _context22.abrupt("return", {
|
|
1796
1692
|
module: moduleInstance,
|
|
1797
1693
|
config: registryConfig,
|
|
1798
1694
|
shouldPreload: shouldPreload
|
|
1799
1695
|
});
|
|
1800
1696
|
case 16:
|
|
1801
1697
|
case "end":
|
|
1802
|
-
return
|
|
1698
|
+
return _context22.stop();
|
|
1803
1699
|
}
|
|
1804
|
-
},
|
|
1700
|
+
}, _callee22, this);
|
|
1805
1701
|
}));
|
|
1806
|
-
function registerModuleByName(
|
|
1702
|
+
function registerModuleByName(_x24) {
|
|
1807
1703
|
return _registerModuleByName.apply(this, arguments);
|
|
1808
1704
|
}
|
|
1809
1705
|
return registerModuleByName;
|
|
@@ -1816,10 +1712,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
1816
1712
|
}, {
|
|
1817
1713
|
key: "registerModules",
|
|
1818
1714
|
value: (function () {
|
|
1819
|
-
var _registerModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1715
|
+
var _registerModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(moduleConfigs) {
|
|
1820
1716
|
var configs, registeredModules, _iterator2, _step2, config, configName, result, errorMessage;
|
|
1821
|
-
return _regeneratorRuntime().wrap(function
|
|
1822
|
-
while (1) switch (
|
|
1717
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1718
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1823
1719
|
case 0:
|
|
1824
1720
|
console.log('[Server] 开始注册模块...');
|
|
1825
1721
|
|
|
@@ -1831,47 +1727,47 @@ var Server = /*#__PURE__*/function () {
|
|
|
1831
1727
|
});
|
|
1832
1728
|
registeredModules = [];
|
|
1833
1729
|
_iterator2 = _createForOfIteratorHelper(configs);
|
|
1834
|
-
|
|
1730
|
+
_context23.prev = 5;
|
|
1835
1731
|
_iterator2.s();
|
|
1836
1732
|
case 7:
|
|
1837
1733
|
if ((_step2 = _iterator2.n()).done) {
|
|
1838
|
-
|
|
1734
|
+
_context23.next = 25;
|
|
1839
1735
|
break;
|
|
1840
1736
|
}
|
|
1841
1737
|
config = _step2.value;
|
|
1842
1738
|
configName = typeof config === 'string' ? config : config.name;
|
|
1843
|
-
|
|
1844
|
-
|
|
1739
|
+
_context23.prev = 10;
|
|
1740
|
+
_context23.next = 13;
|
|
1845
1741
|
return this.registerModuleByName(config);
|
|
1846
1742
|
case 13:
|
|
1847
|
-
result =
|
|
1743
|
+
result = _context23.sent;
|
|
1848
1744
|
registeredModules.push(result);
|
|
1849
|
-
|
|
1745
|
+
_context23.next = 23;
|
|
1850
1746
|
break;
|
|
1851
1747
|
case 17:
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
errorMessage =
|
|
1748
|
+
_context23.prev = 17;
|
|
1749
|
+
_context23.t0 = _context23["catch"](10);
|
|
1750
|
+
errorMessage = _context23.t0 instanceof Error ? _context23.t0.message : String(_context23.t0);
|
|
1855
1751
|
this.logError("\u6A21\u5757\u6CE8\u518C\u5931\u8D25: ".concat(configName), {
|
|
1856
1752
|
moduleName: configName,
|
|
1857
1753
|
error: errorMessage
|
|
1858
1754
|
});
|
|
1859
|
-
console.error("[Server] \u6A21\u5757\u6CE8\u518C\u5931\u8D25:",
|
|
1860
|
-
throw
|
|
1755
|
+
console.error("[Server] \u6A21\u5757\u6CE8\u518C\u5931\u8D25:", _context23.t0);
|
|
1756
|
+
throw _context23.t0;
|
|
1861
1757
|
case 23:
|
|
1862
|
-
|
|
1758
|
+
_context23.next = 7;
|
|
1863
1759
|
break;
|
|
1864
1760
|
case 25:
|
|
1865
|
-
|
|
1761
|
+
_context23.next = 30;
|
|
1866
1762
|
break;
|
|
1867
1763
|
case 27:
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
_iterator2.e(
|
|
1764
|
+
_context23.prev = 27;
|
|
1765
|
+
_context23.t1 = _context23["catch"](5);
|
|
1766
|
+
_iterator2.e(_context23.t1);
|
|
1871
1767
|
case 30:
|
|
1872
|
-
|
|
1768
|
+
_context23.prev = 30;
|
|
1873
1769
|
_iterator2.f();
|
|
1874
|
-
return
|
|
1770
|
+
return _context23.finish(30);
|
|
1875
1771
|
case 33:
|
|
1876
1772
|
console.log('[Server] ✅ 所有模块注册完成');
|
|
1877
1773
|
this.logInfo('所有模块注册完成', {
|
|
@@ -1881,14 +1777,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1881
1777
|
return m === null || m === void 0 || (_m$config = m.config) === null || _m$config === void 0 ? void 0 : _m$config.name;
|
|
1882
1778
|
})
|
|
1883
1779
|
});
|
|
1884
|
-
return
|
|
1780
|
+
return _context23.abrupt("return", registeredModules);
|
|
1885
1781
|
case 36:
|
|
1886
1782
|
case "end":
|
|
1887
|
-
return
|
|
1783
|
+
return _context23.stop();
|
|
1888
1784
|
}
|
|
1889
|
-
},
|
|
1785
|
+
}, _callee23, this, [[5, 27, 30, 33], [10, 17]]);
|
|
1890
1786
|
}));
|
|
1891
|
-
function registerModules(
|
|
1787
|
+
function registerModules(_x25) {
|
|
1892
1788
|
return _registerModules.apply(this, arguments);
|
|
1893
1789
|
}
|
|
1894
1790
|
return registerModules;
|
|
@@ -1901,10 +1797,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
1901
1797
|
}, {
|
|
1902
1798
|
key: "preloadModulesData",
|
|
1903
1799
|
value: (function () {
|
|
1904
|
-
var _preloadModulesData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1800
|
+
var _preloadModulesData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(registeredModules, options) {
|
|
1905
1801
|
var modulesToPreload, preloadResults, _iterator3, _step3, _step3$value, module, config, shouldPreload, startTime, _options$onModuleLoad, _options$onModuleLoad2, duration, _duration, errorMessage, successCount, failCount;
|
|
1906
|
-
return _regeneratorRuntime().wrap(function
|
|
1907
|
-
while (1) switch (
|
|
1802
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1803
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1908
1804
|
case 0:
|
|
1909
1805
|
console.log('[Server] 开始预加载模块数据...');
|
|
1910
1806
|
modulesToPreload = registeredModules.filter(function (m) {
|
|
@@ -1917,16 +1813,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
1917
1813
|
});
|
|
1918
1814
|
preloadResults = [];
|
|
1919
1815
|
_iterator3 = _createForOfIteratorHelper(registeredModules);
|
|
1920
|
-
|
|
1816
|
+
_context24.prev = 5;
|
|
1921
1817
|
_iterator3.s();
|
|
1922
1818
|
case 7:
|
|
1923
1819
|
if ((_step3 = _iterator3.n()).done) {
|
|
1924
|
-
|
|
1820
|
+
_context24.next = 40;
|
|
1925
1821
|
break;
|
|
1926
1822
|
}
|
|
1927
1823
|
_step3$value = _step3.value, module = _step3$value.module, config = _step3$value.config, shouldPreload = _step3$value.shouldPreload;
|
|
1928
1824
|
if (shouldPreload) {
|
|
1929
|
-
|
|
1825
|
+
_context24.next = 13;
|
|
1930
1826
|
break;
|
|
1931
1827
|
}
|
|
1932
1828
|
console.log("[Server] \u23ED\uFE0F \u8DF3\u8FC7 ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D"));
|
|
@@ -1934,19 +1830,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
1934
1830
|
moduleName: config.name,
|
|
1935
1831
|
reason: 'shouldPreload=false'
|
|
1936
1832
|
});
|
|
1937
|
-
return
|
|
1833
|
+
return _context24.abrupt("continue", 38);
|
|
1938
1834
|
case 13:
|
|
1939
1835
|
if (!(typeof module.preload === 'function')) {
|
|
1940
|
-
|
|
1836
|
+
_context24.next = 36;
|
|
1941
1837
|
break;
|
|
1942
1838
|
}
|
|
1943
1839
|
startTime = Date.now();
|
|
1944
|
-
|
|
1840
|
+
_context24.prev = 15;
|
|
1945
1841
|
this.logInfo("\u5F00\u59CB\u9884\u52A0\u8F7D\u6A21\u5757: ".concat(config.name), {
|
|
1946
1842
|
moduleName: config.name
|
|
1947
1843
|
});
|
|
1948
1844
|
options === null || options === void 0 || (_options$onModuleLoad = options.onModuleLoad) === null || _options$onModuleLoad === void 0 || _options$onModuleLoad.call(options, config.name);
|
|
1949
|
-
|
|
1845
|
+
_context24.next = 20;
|
|
1950
1846
|
return module.preload();
|
|
1951
1847
|
case 20:
|
|
1952
1848
|
options === null || options === void 0 || (_options$onModuleLoad2 = options.onModuleLoadComplete) === null || _options$onModuleLoad2 === void 0 || _options$onModuleLoad2.call(options, config.name);
|
|
@@ -1960,14 +1856,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1960
1856
|
name: config.name,
|
|
1961
1857
|
success: true
|
|
1962
1858
|
});
|
|
1963
|
-
|
|
1859
|
+
_context24.next = 34;
|
|
1964
1860
|
break;
|
|
1965
1861
|
case 27:
|
|
1966
|
-
|
|
1967
|
-
|
|
1862
|
+
_context24.prev = 27;
|
|
1863
|
+
_context24.t0 = _context24["catch"](15);
|
|
1968
1864
|
_duration = Date.now() - startTime;
|
|
1969
|
-
errorMessage =
|
|
1970
|
-
console.error("[Server] \u274C ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25:"),
|
|
1865
|
+
errorMessage = _context24.t0 instanceof Error ? _context24.t0.message : String(_context24.t0);
|
|
1866
|
+
console.error("[Server] \u274C ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25:"), _context24.t0);
|
|
1971
1867
|
this.logError("\u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25: ".concat(config.name), {
|
|
1972
1868
|
moduleName: config.name,
|
|
1973
1869
|
duration: "".concat(_duration, "ms"),
|
|
@@ -1979,7 +1875,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1979
1875
|
error: errorMessage
|
|
1980
1876
|
});
|
|
1981
1877
|
case 34:
|
|
1982
|
-
|
|
1878
|
+
_context24.next = 38;
|
|
1983
1879
|
break;
|
|
1984
1880
|
case 36:
|
|
1985
1881
|
console.log("[Server] \u26A0\uFE0F ".concat(config.name, " \u6A21\u5757\u672A\u5B9E\u73B0 preload() \u65B9\u6CD5"));
|
|
@@ -1987,19 +1883,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
1987
1883
|
moduleName: config.name
|
|
1988
1884
|
});
|
|
1989
1885
|
case 38:
|
|
1990
|
-
|
|
1886
|
+
_context24.next = 7;
|
|
1991
1887
|
break;
|
|
1992
1888
|
case 40:
|
|
1993
|
-
|
|
1889
|
+
_context24.next = 45;
|
|
1994
1890
|
break;
|
|
1995
1891
|
case 42:
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
_iterator3.e(
|
|
1892
|
+
_context24.prev = 42;
|
|
1893
|
+
_context24.t1 = _context24["catch"](5);
|
|
1894
|
+
_iterator3.e(_context24.t1);
|
|
1999
1895
|
case 45:
|
|
2000
|
-
|
|
1896
|
+
_context24.prev = 45;
|
|
2001
1897
|
_iterator3.f();
|
|
2002
|
-
return
|
|
1898
|
+
return _context24.finish(45);
|
|
2003
1899
|
case 48:
|
|
2004
1900
|
successCount = preloadResults.filter(function (r) {
|
|
2005
1901
|
return r.success;
|
|
@@ -2014,11 +1910,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
2014
1910
|
});
|
|
2015
1911
|
case 52:
|
|
2016
1912
|
case "end":
|
|
2017
|
-
return
|
|
1913
|
+
return _context24.stop();
|
|
2018
1914
|
}
|
|
2019
|
-
},
|
|
1915
|
+
}, _callee24, this, [[5, 42, 45, 48], [15, 27]]);
|
|
2020
1916
|
}));
|
|
2021
|
-
function preloadModulesData(
|
|
1917
|
+
function preloadModulesData(_x26, _x27) {
|
|
2022
1918
|
return _preloadModulesData.apply(this, arguments);
|
|
2023
1919
|
}
|
|
2024
1920
|
return preloadModulesData;
|
|
@@ -2032,7 +1928,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2032
1928
|
}, {
|
|
2033
1929
|
key: "initialize",
|
|
2034
1930
|
value: (function () {
|
|
2035
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1931
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(moduleConfigs) {
|
|
2036
1932
|
var _moduleConfigs$length,
|
|
2037
1933
|
_this3 = this;
|
|
2038
1934
|
var autoPreload,
|
|
@@ -2040,12 +1936,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
2040
1936
|
startTime,
|
|
2041
1937
|
registeredModules,
|
|
2042
1938
|
duration,
|
|
2043
|
-
|
|
2044
|
-
return _regeneratorRuntime().wrap(function
|
|
2045
|
-
while (1) switch (
|
|
1939
|
+
_args25 = arguments;
|
|
1940
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1941
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2046
1942
|
case 0:
|
|
2047
|
-
autoPreload =
|
|
2048
|
-
options =
|
|
1943
|
+
autoPreload = _args25.length > 1 && _args25[1] !== undefined ? _args25[1] : true;
|
|
1944
|
+
options = _args25.length > 2 ? _args25[2] : undefined;
|
|
2049
1945
|
startTime = Date.now();
|
|
2050
1946
|
this.logInfo('Server 初始化开始', {
|
|
2051
1947
|
moduleConfigCount: (_moduleConfigs$length = moduleConfigs === null || moduleConfigs === void 0 ? void 0 : moduleConfigs.length) !== null && _moduleConfigs$length !== void 0 ? _moduleConfigs$length : 'all',
|
|
@@ -2058,25 +1954,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
2058
1954
|
this.registerDeviceTaskActions();
|
|
2059
1955
|
|
|
2060
1956
|
// 注册模块
|
|
2061
|
-
|
|
1957
|
+
_context25.next = 8;
|
|
2062
1958
|
return this.registerModules(moduleConfigs);
|
|
2063
1959
|
case 8:
|
|
2064
|
-
registeredModules =
|
|
1960
|
+
registeredModules = _context25.sent;
|
|
2065
1961
|
if (!autoPreload) {
|
|
2066
|
-
|
|
1962
|
+
_context25.next = 14;
|
|
2067
1963
|
break;
|
|
2068
1964
|
}
|
|
2069
|
-
|
|
1965
|
+
_context25.next = 12;
|
|
2070
1966
|
return this.preloadModulesData(registeredModules, options);
|
|
2071
1967
|
case 12:
|
|
2072
|
-
|
|
1968
|
+
_context25.next = 15;
|
|
2073
1969
|
break;
|
|
2074
1970
|
case 14:
|
|
2075
1971
|
this.logInfo('跳过自动预加载', {
|
|
2076
1972
|
autoPreload: autoPreload
|
|
2077
1973
|
});
|
|
2078
1974
|
case 15:
|
|
2079
|
-
|
|
1975
|
+
_context25.next = 17;
|
|
2080
1976
|
return this.setupProductsQuotationPriceBridge();
|
|
2081
1977
|
case 17:
|
|
2082
1978
|
// 监听 ProductsModule 同步完成事件,重新计算并推送查询结果
|
|
@@ -2103,14 +1999,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
2103
1999
|
duration: "".concat(duration, "ms"),
|
|
2104
2000
|
registeredModuleCount: registeredModules.length
|
|
2105
2001
|
});
|
|
2106
|
-
return
|
|
2002
|
+
return _context25.abrupt("return", registeredModules);
|
|
2107
2003
|
case 23:
|
|
2108
2004
|
case "end":
|
|
2109
|
-
return
|
|
2005
|
+
return _context25.stop();
|
|
2110
2006
|
}
|
|
2111
|
-
},
|
|
2007
|
+
}, _callee25, this);
|
|
2112
2008
|
}));
|
|
2113
|
-
function initialize(
|
|
2009
|
+
function initialize(_x28) {
|
|
2114
2010
|
return _initialize.apply(this, arguments);
|
|
2115
2011
|
}
|
|
2116
2012
|
return initialize;
|
|
@@ -2152,31 +2048,31 @@ var Server = /*#__PURE__*/function () {
|
|
|
2152
2048
|
}, {
|
|
2153
2049
|
key: "handleSyncSalesTask",
|
|
2154
2050
|
value: function () {
|
|
2155
|
-
var _handleSyncSalesTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2156
|
-
var _ctx$task, _this$
|
|
2051
|
+
var _handleSyncSalesTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(ctx) {
|
|
2052
|
+
var _ctx$task, _this$app4;
|
|
2157
2053
|
var payload, backendPath, data, title, _ctx$task2, _syncResult$syncedOrd, syncResult, backendError, message, errorMessage;
|
|
2158
|
-
return _regeneratorRuntime().wrap(function
|
|
2159
|
-
while (1) switch (
|
|
2054
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2055
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2160
2056
|
case 0:
|
|
2161
2057
|
payload = ((_ctx$task = ctx.task) === null || _ctx$task === void 0 ? void 0 : _ctx$task.payload) || {};
|
|
2162
2058
|
backendPath = payload.backendPath;
|
|
2163
2059
|
data = payload.data;
|
|
2164
2060
|
title = payload.title || 'sync_sales';
|
|
2165
2061
|
if (!(!backendPath || !data)) {
|
|
2166
|
-
|
|
2062
|
+
_context26.next = 6;
|
|
2167
2063
|
break;
|
|
2168
2064
|
}
|
|
2169
|
-
return
|
|
2065
|
+
return _context26.abrupt("return", this.taskFail('INVALID_PAYLOAD', '缺少 backendPath 或 data'));
|
|
2170
2066
|
case 6:
|
|
2171
|
-
if ((_this$
|
|
2172
|
-
|
|
2067
|
+
if ((_this$app4 = this.app) !== null && _this$app4 !== void 0 && _this$app4.request) {
|
|
2068
|
+
_context26.next = 9;
|
|
2173
2069
|
break;
|
|
2174
2070
|
}
|
|
2175
2071
|
this.logError("".concat(title, ": sync_sales app.request \u4E0D\u53EF\u7528"));
|
|
2176
|
-
return
|
|
2072
|
+
return _context26.abrupt("return", this.taskTimeout('app.request 不可用'));
|
|
2177
2073
|
case 9:
|
|
2178
|
-
|
|
2179
|
-
|
|
2074
|
+
_context26.prev = 9;
|
|
2075
|
+
_context26.next = 12;
|
|
2180
2076
|
return this.runCheckoutSync({
|
|
2181
2077
|
backendPath: backendPath,
|
|
2182
2078
|
data: data,
|
|
@@ -2186,27 +2082,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
2186
2082
|
persistCheckoutDataWithResponse: false
|
|
2187
2083
|
});
|
|
2188
2084
|
case 12:
|
|
2189
|
-
syncResult =
|
|
2085
|
+
syncResult = _context26.sent;
|
|
2190
2086
|
if (!syncResult.rejected) {
|
|
2191
|
-
|
|
2087
|
+
_context26.next = 16;
|
|
2192
2088
|
break;
|
|
2193
2089
|
}
|
|
2194
2090
|
this.logError("".concat(title, ": sync_sales \u540E\u7AEF\u660E\u786E\u5931\u8D25"), {
|
|
2195
2091
|
backendPath: backendPath,
|
|
2196
2092
|
response: syncResult.errorResponse
|
|
2197
2093
|
});
|
|
2198
|
-
return
|
|
2094
|
+
return _context26.abrupt("return", this.taskFail('BACKEND_REJECTED', syncResult.message || '后端明确拒绝 checkout', syncResult.errorResponse));
|
|
2199
2095
|
case 16:
|
|
2200
|
-
return
|
|
2096
|
+
return _context26.abrupt("return", this.taskOk({
|
|
2201
2097
|
order: (_syncResult$syncedOrd = syncResult.syncedOrder) !== null && _syncResult$syncedOrd !== void 0 ? _syncResult$syncedOrd : null,
|
|
2202
2098
|
response: syncResult.normalizedResponse
|
|
2203
2099
|
}));
|
|
2204
2100
|
case 19:
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
backendError = this.extractBackendErrorResponse(
|
|
2101
|
+
_context26.prev = 19;
|
|
2102
|
+
_context26.t0 = _context26["catch"](9);
|
|
2103
|
+
backendError = this.extractBackendErrorResponse(_context26.t0);
|
|
2208
2104
|
if (!backendError) {
|
|
2209
|
-
|
|
2105
|
+
_context26.next = 26;
|
|
2210
2106
|
break;
|
|
2211
2107
|
}
|
|
2212
2108
|
message = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || '后端明确拒绝 checkout';
|
|
@@ -2214,22 +2110,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
2214
2110
|
backendPath: backendPath,
|
|
2215
2111
|
backendError: backendError
|
|
2216
2112
|
});
|
|
2217
|
-
return
|
|
2113
|
+
return _context26.abrupt("return", this.taskFail('BACKEND_REJECTED', message, backendError));
|
|
2218
2114
|
case 26:
|
|
2219
|
-
errorMessage = this.getUnknownErrorMessage(
|
|
2115
|
+
errorMessage = this.getUnknownErrorMessage(_context26.t0);
|
|
2220
2116
|
this.logError("".concat(title, ": sync_sales \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
|
|
2221
2117
|
backendPath: backendPath,
|
|
2222
2118
|
error: errorMessage,
|
|
2223
|
-
error_detail: this.normalizeUnknownError(
|
|
2119
|
+
error_detail: this.normalizeUnknownError(_context26.t0)
|
|
2224
2120
|
});
|
|
2225
|
-
return
|
|
2121
|
+
return _context26.abrupt("return", this.taskTimeout(errorMessage));
|
|
2226
2122
|
case 29:
|
|
2227
2123
|
case "end":
|
|
2228
|
-
return
|
|
2124
|
+
return _context26.stop();
|
|
2229
2125
|
}
|
|
2230
|
-
},
|
|
2126
|
+
}, _callee26, this, [[9, 19]]);
|
|
2231
2127
|
}));
|
|
2232
|
-
function handleSyncSalesTask(
|
|
2128
|
+
function handleSyncSalesTask(_x29) {
|
|
2233
2129
|
return _handleSyncSalesTask.apply(this, arguments);
|
|
2234
2130
|
}
|
|
2235
2131
|
return handleSyncSalesTask;
|
|
@@ -2237,40 +2133,40 @@ var Server = /*#__PURE__*/function () {
|
|
|
2237
2133
|
}, {
|
|
2238
2134
|
key: "runCheckoutSync",
|
|
2239
2135
|
value: function () {
|
|
2240
|
-
var _runCheckoutSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2241
|
-
var _this$
|
|
2136
|
+
var _runCheckoutSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
2137
|
+
var _this$app5;
|
|
2242
2138
|
var backendPath, title, normalizedData, checkoutData, remoteCheckoutData, response, fresh, externalSaleNumber, syncedOrder, printableSyncedOrder;
|
|
2243
|
-
return _regeneratorRuntime().wrap(function
|
|
2244
|
-
while (1) switch (
|
|
2139
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2140
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2245
2141
|
case 0:
|
|
2246
2142
|
backendPath = params.backendPath, title = params.title;
|
|
2247
|
-
|
|
2143
|
+
_context27.next = 3;
|
|
2248
2144
|
return this.normalizeCheckoutSubmitData(params.data, title);
|
|
2249
2145
|
case 3:
|
|
2250
|
-
normalizedData =
|
|
2251
|
-
|
|
2146
|
+
normalizedData = _context27.sent;
|
|
2147
|
+
_context27.next = 6;
|
|
2252
2148
|
return this.ensureCheckoutOrderNumbers(normalizedData, title);
|
|
2253
2149
|
case 6:
|
|
2254
|
-
checkoutData =
|
|
2150
|
+
checkoutData = _context27.sent;
|
|
2255
2151
|
remoteCheckoutData = this.omitCheckoutSyncMode(checkoutData);
|
|
2256
|
-
if ((_this$
|
|
2257
|
-
|
|
2152
|
+
if ((_this$app5 = this.app) !== null && _this$app5 !== void 0 && (_this$app5 = _this$app5.request) !== null && _this$app5 !== void 0 && _this$app5.post) {
|
|
2153
|
+
_context27.next = 10;
|
|
2258
2154
|
break;
|
|
2259
2155
|
}
|
|
2260
2156
|
throw new Error('app.request 不可用');
|
|
2261
2157
|
case 10:
|
|
2262
|
-
|
|
2158
|
+
_context27.next = 12;
|
|
2263
2159
|
return this.app.request.post(backendPath, remoteCheckoutData, {
|
|
2264
2160
|
isShopApi: true,
|
|
2265
2161
|
customToast: function customToast() {}
|
|
2266
2162
|
});
|
|
2267
2163
|
case 12:
|
|
2268
|
-
response =
|
|
2164
|
+
response = _context27.sent;
|
|
2269
2165
|
if (!this.isCheckoutResponseRejected(response)) {
|
|
2270
|
-
|
|
2166
|
+
_context27.next = 15;
|
|
2271
2167
|
break;
|
|
2272
2168
|
}
|
|
2273
|
-
return
|
|
2169
|
+
return _context27.abrupt("return", {
|
|
2274
2170
|
rejected: true,
|
|
2275
2171
|
message: (response === null || response === void 0 ? void 0 : response.message) || '后端明确拒绝 checkout',
|
|
2276
2172
|
errorResponse: response,
|
|
@@ -2284,7 +2180,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2284
2180
|
external_sale_number: params.externalSaleNumber,
|
|
2285
2181
|
data: remoteCheckoutData
|
|
2286
2182
|
});
|
|
2287
|
-
|
|
2183
|
+
_context27.next = 19;
|
|
2288
2184
|
return this.persistSyncedCheckoutOrder({
|
|
2289
2185
|
backendPath: backendPath,
|
|
2290
2186
|
checkoutData: remoteCheckoutData,
|
|
@@ -2294,7 +2190,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2294
2190
|
persistCheckoutDataWithResponse: params.persistCheckoutDataWithResponse === true
|
|
2295
2191
|
});
|
|
2296
2192
|
case 19:
|
|
2297
|
-
syncedOrder =
|
|
2193
|
+
syncedOrder = _context27.sent;
|
|
2298
2194
|
printableSyncedOrder = syncedOrder ? this.buildSyncedOrderForPrint({
|
|
2299
2195
|
syncedOrder: syncedOrder,
|
|
2300
2196
|
checkoutResponseOrder: fresh
|
|
@@ -2303,10 +2199,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
2303
2199
|
checkoutData: remoteCheckoutData,
|
|
2304
2200
|
syncedOrder: printableSyncedOrder
|
|
2305
2201
|
}))) {
|
|
2306
|
-
|
|
2202
|
+
_context27.next = 24;
|
|
2307
2203
|
break;
|
|
2308
2204
|
}
|
|
2309
|
-
|
|
2205
|
+
_context27.next = 24;
|
|
2310
2206
|
return this.dispatchPrintOtherReceiptTask({
|
|
2311
2207
|
checkoutData: remoteCheckoutData,
|
|
2312
2208
|
syncedOrder: printableSyncedOrder,
|
|
@@ -2314,7 +2210,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2314
2210
|
deviceId: params.deviceId
|
|
2315
2211
|
});
|
|
2316
2212
|
case 24:
|
|
2317
|
-
return
|
|
2213
|
+
return _context27.abrupt("return", {
|
|
2318
2214
|
rejected: false,
|
|
2319
2215
|
response: response,
|
|
2320
2216
|
normalizedResponse: this.normalizeCheckoutResponse(response),
|
|
@@ -2324,11 +2220,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
2324
2220
|
});
|
|
2325
2221
|
case 25:
|
|
2326
2222
|
case "end":
|
|
2327
|
-
return
|
|
2223
|
+
return _context27.stop();
|
|
2328
2224
|
}
|
|
2329
|
-
},
|
|
2225
|
+
}, _callee27, this);
|
|
2330
2226
|
}));
|
|
2331
|
-
function runCheckoutSync(
|
|
2227
|
+
function runCheckoutSync(_x30) {
|
|
2332
2228
|
return _runCheckoutSync.apply(this, arguments);
|
|
2333
2229
|
}
|
|
2334
2230
|
return runCheckoutSync;
|
|
@@ -2345,15 +2241,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
2345
2241
|
}, {
|
|
2346
2242
|
key: "persistSyncedCheckoutOrder",
|
|
2347
2243
|
value: function () {
|
|
2348
|
-
var _persistSyncedCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2244
|
+
var _persistSyncedCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
2349
2245
|
var backendPath, checkoutData, externalSaleNumber, fresh, title, persistCheckoutDataWithResponse, shouldMergeRemoteOrder, syncedOrder, _external_sale_number2, _external_sale_number3, _syncedOrder$order_id, _syncedOrder, patch, result;
|
|
2350
|
-
return _regeneratorRuntime().wrap(function
|
|
2351
|
-
while (1) switch (
|
|
2246
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2247
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2352
2248
|
case 0:
|
|
2353
2249
|
backendPath = params.backendPath, checkoutData = params.checkoutData, externalSaleNumber = params.externalSaleNumber, fresh = params.fresh, title = params.title, persistCheckoutDataWithResponse = params.persistCheckoutDataWithResponse;
|
|
2354
2250
|
shouldMergeRemoteOrder = fresh ? this.isMergeableCheckoutOrder(fresh, externalSaleNumber) : false;
|
|
2355
2251
|
if (!(this.order && fresh && (shouldMergeRemoteOrder || persistCheckoutDataWithResponse))) {
|
|
2356
|
-
|
|
2252
|
+
_context28.next = 9;
|
|
2357
2253
|
break;
|
|
2358
2254
|
}
|
|
2359
2255
|
syncedOrder = persistCheckoutDataWithResponse ? _objectSpread(_objectSpread(_objectSpread({}, checkoutData), fresh), {}, {
|
|
@@ -2363,7 +2259,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2363
2259
|
external_sale_number: (_external_sale_number3 = fresh.external_sale_number) !== null && _external_sale_number3 !== void 0 ? _external_sale_number3 : externalSaleNumber,
|
|
2364
2260
|
need_sync: 0
|
|
2365
2261
|
});
|
|
2366
|
-
|
|
2262
|
+
_context28.next = 6;
|
|
2367
2263
|
return this.order.upsertOrdersFromRemote([syncedOrder]);
|
|
2368
2264
|
case 6:
|
|
2369
2265
|
this.logInfo("".concat(title, ": sync_sales \u5B8C\u6574\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u672C\u5730"), {
|
|
@@ -2373,21 +2269,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
2373
2269
|
mergedRemoteOrder: shouldMergeRemoteOrder,
|
|
2374
2270
|
persistedCheckoutDataWithResponse: persistCheckoutDataWithResponse
|
|
2375
2271
|
});
|
|
2376
|
-
|
|
2272
|
+
_context28.next = 19;
|
|
2377
2273
|
break;
|
|
2378
2274
|
case 9:
|
|
2379
2275
|
if (!(this.order && externalSaleNumber && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
|
|
2380
|
-
|
|
2276
|
+
_context28.next = 18;
|
|
2381
2277
|
break;
|
|
2382
2278
|
}
|
|
2383
2279
|
patch = this.buildCheckoutSyncSuccessPatch(fresh);
|
|
2384
|
-
|
|
2280
|
+
_context28.next = 13;
|
|
2385
2281
|
return this.order.markOrderSyncedByExternalSaleNumber({
|
|
2386
2282
|
externalSaleNumber: externalSaleNumber,
|
|
2387
2283
|
patch: patch
|
|
2388
2284
|
});
|
|
2389
2285
|
case 13:
|
|
2390
|
-
result =
|
|
2286
|
+
result = _context28.sent;
|
|
2391
2287
|
syncedOrder = (result === null || result === void 0 ? void 0 : result.order) || _objectSpread(_objectSpread(_objectSpread({}, checkoutData), patch), {}, {
|
|
2392
2288
|
external_sale_number: externalSaleNumber,
|
|
2393
2289
|
need_sync: 0
|
|
@@ -2398,7 +2294,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2398
2294
|
hasRemoteOrder: !!fresh,
|
|
2399
2295
|
mergedRemoteOrder: false
|
|
2400
2296
|
});
|
|
2401
|
-
|
|
2297
|
+
_context28.next = 19;
|
|
2402
2298
|
break;
|
|
2403
2299
|
case 18:
|
|
2404
2300
|
this.logWarning("".concat(title, ": sync_sales Order \u6A21\u5757\u672A\u6CE8\u518C"), {
|
|
@@ -2407,14 +2303,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
2407
2303
|
order_id: fresh === null || fresh === void 0 ? void 0 : fresh.order_id
|
|
2408
2304
|
});
|
|
2409
2305
|
case 19:
|
|
2410
|
-
return
|
|
2306
|
+
return _context28.abrupt("return", syncedOrder);
|
|
2411
2307
|
case 20:
|
|
2412
2308
|
case "end":
|
|
2413
|
-
return
|
|
2309
|
+
return _context28.stop();
|
|
2414
2310
|
}
|
|
2415
|
-
},
|
|
2311
|
+
}, _callee28, this);
|
|
2416
2312
|
}));
|
|
2417
|
-
function persistSyncedCheckoutOrder(
|
|
2313
|
+
function persistSyncedCheckoutOrder(_x31) {
|
|
2418
2314
|
return _persistSyncedCheckoutOrder.apply(this, arguments);
|
|
2419
2315
|
}
|
|
2420
2316
|
return persistSyncedCheckoutOrder;
|
|
@@ -2425,51 +2321,51 @@ var Server = /*#__PURE__*/function () {
|
|
|
2425
2321
|
}, {
|
|
2426
2322
|
key: "setupProductsQuotationPriceBridge",
|
|
2427
2323
|
value: (function () {
|
|
2428
|
-
var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2324
|
+
var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
2429
2325
|
var _this$core$context, errorMessage;
|
|
2430
|
-
return _regeneratorRuntime().wrap(function
|
|
2431
|
-
while (1) switch (
|
|
2326
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2327
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2432
2328
|
case 0:
|
|
2433
2329
|
if (this.products) {
|
|
2434
|
-
|
|
2330
|
+
_context29.next = 3;
|
|
2435
2331
|
break;
|
|
2436
2332
|
}
|
|
2437
2333
|
this.logInfo('setupProductsQuotationPriceBridge: Products 模块未注册');
|
|
2438
|
-
return
|
|
2334
|
+
return _context29.abrupt("return");
|
|
2439
2335
|
case 3:
|
|
2440
2336
|
if (this.schedule) {
|
|
2441
|
-
|
|
2337
|
+
_context29.next = 6;
|
|
2442
2338
|
break;
|
|
2443
2339
|
}
|
|
2444
2340
|
this.logInfo('setupProductsQuotationPriceBridge: Schedule 模块未注册');
|
|
2445
|
-
return
|
|
2341
|
+
return _context29.abrupt("return");
|
|
2446
2342
|
case 6:
|
|
2447
|
-
|
|
2448
|
-
|
|
2343
|
+
_context29.prev = 6;
|
|
2344
|
+
_context29.next = 9;
|
|
2449
2345
|
return this.schedule.loadAllSchedule();
|
|
2450
2346
|
case 9:
|
|
2451
2347
|
this.products.clearPriceCache();
|
|
2452
|
-
|
|
2348
|
+
_context29.next = 12;
|
|
2453
2349
|
return this.products.setupQuotationPriceBridge({
|
|
2454
2350
|
scheduleModule: this.schedule,
|
|
2455
2351
|
channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel
|
|
2456
2352
|
});
|
|
2457
2353
|
case 12:
|
|
2458
2354
|
this.logInfo('Products 报价单价格桥接初始化完成');
|
|
2459
|
-
|
|
2355
|
+
_context29.next = 19;
|
|
2460
2356
|
break;
|
|
2461
2357
|
case 15:
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
errorMessage =
|
|
2358
|
+
_context29.prev = 15;
|
|
2359
|
+
_context29.t0 = _context29["catch"](6);
|
|
2360
|
+
errorMessage = _context29.t0 instanceof Error ? _context29.t0.message : String(_context29.t0);
|
|
2465
2361
|
this.logError('Products 报价单价格桥接初始化失败', {
|
|
2466
2362
|
error: errorMessage
|
|
2467
2363
|
});
|
|
2468
2364
|
case 19:
|
|
2469
2365
|
case "end":
|
|
2470
|
-
return
|
|
2366
|
+
return _context29.stop();
|
|
2471
2367
|
}
|
|
2472
|
-
},
|
|
2368
|
+
}, _callee29, this, [[6, 15]]);
|
|
2473
2369
|
}));
|
|
2474
2370
|
function setupProductsQuotationPriceBridge() {
|
|
2475
2371
|
return _setupProductsQuotationPriceBridge.apply(this, arguments);
|
|
@@ -2538,45 +2434,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
2538
2434
|
}, {
|
|
2539
2435
|
key: "refreshProductsInBackground",
|
|
2540
2436
|
value: (function () {
|
|
2541
|
-
var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2437
|
+
var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2542
2438
|
var startTime, duration, _duration2, errorMessage;
|
|
2543
|
-
return _regeneratorRuntime().wrap(function
|
|
2544
|
-
while (1) switch (
|
|
2439
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2440
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2545
2441
|
case 0:
|
|
2546
2442
|
if (this.products) {
|
|
2547
|
-
|
|
2443
|
+
_context30.next = 3;
|
|
2548
2444
|
break;
|
|
2549
2445
|
}
|
|
2550
2446
|
this.logWarning('refreshProductsInBackground: Products 模块未注册');
|
|
2551
|
-
return
|
|
2447
|
+
return _context30.abrupt("return");
|
|
2552
2448
|
case 3:
|
|
2553
2449
|
this.logInfo('refreshProductsInBackground 开始');
|
|
2554
2450
|
startTime = Date.now();
|
|
2555
|
-
|
|
2556
|
-
|
|
2451
|
+
_context30.prev = 5;
|
|
2452
|
+
_context30.next = 8;
|
|
2557
2453
|
return this.products.silentRefresh();
|
|
2558
2454
|
case 8:
|
|
2559
2455
|
duration = Date.now() - startTime;
|
|
2560
2456
|
this.logInfo('refreshProductsInBackground 完成', {
|
|
2561
2457
|
duration: "".concat(duration, "ms")
|
|
2562
2458
|
});
|
|
2563
|
-
|
|
2459
|
+
_context30.next = 18;
|
|
2564
2460
|
break;
|
|
2565
2461
|
case 12:
|
|
2566
|
-
|
|
2567
|
-
|
|
2462
|
+
_context30.prev = 12;
|
|
2463
|
+
_context30.t0 = _context30["catch"](5);
|
|
2568
2464
|
_duration2 = Date.now() - startTime;
|
|
2569
|
-
errorMessage =
|
|
2570
|
-
console.error('[Server] refreshProductsInBackground 失败:',
|
|
2465
|
+
errorMessage = _context30.t0 instanceof Error ? _context30.t0.message : String(_context30.t0);
|
|
2466
|
+
console.error('[Server] refreshProductsInBackground 失败:', _context30.t0);
|
|
2571
2467
|
this.logError('refreshProductsInBackground 失败', {
|
|
2572
2468
|
duration: "".concat(_duration2, "ms"),
|
|
2573
2469
|
error: errorMessage
|
|
2574
2470
|
});
|
|
2575
2471
|
case 18:
|
|
2576
2472
|
case "end":
|
|
2577
|
-
return
|
|
2473
|
+
return _context30.stop();
|
|
2578
2474
|
}
|
|
2579
|
-
},
|
|
2475
|
+
}, _callee30, this, [[5, 12]]);
|
|
2580
2476
|
}));
|
|
2581
2477
|
function refreshProductsInBackground() {
|
|
2582
2478
|
return _refreshProductsInBackground.apply(this, arguments);
|
|
@@ -2592,45 +2488,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
2592
2488
|
}, {
|
|
2593
2489
|
key: "refreshOrdersInBackground",
|
|
2594
2490
|
value: (function () {
|
|
2595
|
-
var _refreshOrdersInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2491
|
+
var _refreshOrdersInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
2596
2492
|
var startTime, duration, _duration3, errorMessage;
|
|
2597
|
-
return _regeneratorRuntime().wrap(function
|
|
2598
|
-
while (1) switch (
|
|
2493
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2494
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2599
2495
|
case 0:
|
|
2600
2496
|
if (this.order) {
|
|
2601
|
-
|
|
2497
|
+
_context31.next = 3;
|
|
2602
2498
|
break;
|
|
2603
2499
|
}
|
|
2604
2500
|
this.logWarning('refreshOrdersInBackground: Order 模块未注册');
|
|
2605
|
-
return
|
|
2501
|
+
return _context31.abrupt("return");
|
|
2606
2502
|
case 3:
|
|
2607
2503
|
this.logInfo('refreshOrdersInBackground 开始');
|
|
2608
2504
|
startTime = Date.now();
|
|
2609
|
-
|
|
2610
|
-
|
|
2505
|
+
_context31.prev = 5;
|
|
2506
|
+
_context31.next = 8;
|
|
2611
2507
|
return this.order.silentRefresh();
|
|
2612
2508
|
case 8:
|
|
2613
2509
|
duration = Date.now() - startTime;
|
|
2614
2510
|
this.logInfo('refreshOrdersInBackground 完成', {
|
|
2615
2511
|
duration: "".concat(duration, "ms")
|
|
2616
2512
|
});
|
|
2617
|
-
|
|
2513
|
+
_context31.next = 18;
|
|
2618
2514
|
break;
|
|
2619
2515
|
case 12:
|
|
2620
|
-
|
|
2621
|
-
|
|
2516
|
+
_context31.prev = 12;
|
|
2517
|
+
_context31.t0 = _context31["catch"](5);
|
|
2622
2518
|
_duration3 = Date.now() - startTime;
|
|
2623
|
-
errorMessage =
|
|
2624
|
-
console.error('[Server] refreshOrdersInBackground 失败:',
|
|
2519
|
+
errorMessage = _context31.t0 instanceof Error ? _context31.t0.message : String(_context31.t0);
|
|
2520
|
+
console.error('[Server] refreshOrdersInBackground 失败:', _context31.t0);
|
|
2625
2521
|
this.logError('refreshOrdersInBackground 失败', {
|
|
2626
2522
|
duration: "".concat(_duration3, "ms"),
|
|
2627
2523
|
error: errorMessage
|
|
2628
2524
|
});
|
|
2629
2525
|
case 18:
|
|
2630
2526
|
case "end":
|
|
2631
|
-
return
|
|
2527
|
+
return _context31.stop();
|
|
2632
2528
|
}
|
|
2633
|
-
},
|
|
2529
|
+
}, _callee31, this, [[5, 12]]);
|
|
2634
2530
|
}));
|
|
2635
2531
|
function refreshOrdersInBackground() {
|
|
2636
2532
|
return _refreshOrdersInBackground.apply(this, arguments);
|
|
@@ -2645,10 +2541,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
2645
2541
|
}, {
|
|
2646
2542
|
key: "clearAllIndexDB",
|
|
2647
2543
|
value: (function () {
|
|
2648
|
-
var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2544
|
+
var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
2649
2545
|
var clearTasks, moduleNames, errorMessage;
|
|
2650
|
-
return _regeneratorRuntime().wrap(function
|
|
2651
|
-
while (1) switch (
|
|
2546
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2547
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2652
2548
|
case 0:
|
|
2653
2549
|
console.log('[Server] 开始清空所有模块的IndexedDB缓存...');
|
|
2654
2550
|
this.logInfo('开始清空所有模块的 IndexedDB 缓存');
|
|
@@ -2683,41 +2579,41 @@ var Server = /*#__PURE__*/function () {
|
|
|
2683
2579
|
moduleNames.push('FloorPlan');
|
|
2684
2580
|
}
|
|
2685
2581
|
if (!(clearTasks.length === 0)) {
|
|
2686
|
-
|
|
2582
|
+
_context32.next = 15;
|
|
2687
2583
|
break;
|
|
2688
2584
|
}
|
|
2689
2585
|
console.warn('[Server] 没有找到已注册的模块,无需清空');
|
|
2690
2586
|
this.logWarning('没有找到已注册的模块,无需清空 IndexedDB');
|
|
2691
|
-
return
|
|
2587
|
+
return _context32.abrupt("return");
|
|
2692
2588
|
case 15:
|
|
2693
2589
|
this.logInfo('准备清空模块缓存', {
|
|
2694
2590
|
moduleNames: moduleNames
|
|
2695
2591
|
});
|
|
2696
|
-
|
|
2697
|
-
|
|
2592
|
+
_context32.prev = 16;
|
|
2593
|
+
_context32.next = 19;
|
|
2698
2594
|
return Promise.all(clearTasks);
|
|
2699
2595
|
case 19:
|
|
2700
2596
|
console.log("[Server] \u2705 \u5DF2\u6210\u529F\u6E05\u7A7A\u6240\u6709\u6A21\u5757\u7684IndexedDB\u7F13\u5B58: ".concat(moduleNames.join(', ')));
|
|
2701
2597
|
this.logInfo('成功清空所有模块的 IndexedDB 缓存', {
|
|
2702
2598
|
moduleNames: moduleNames
|
|
2703
2599
|
});
|
|
2704
|
-
|
|
2600
|
+
_context32.next = 29;
|
|
2705
2601
|
break;
|
|
2706
2602
|
case 23:
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
errorMessage =
|
|
2710
|
-
console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:',
|
|
2603
|
+
_context32.prev = 23;
|
|
2604
|
+
_context32.t0 = _context32["catch"](16);
|
|
2605
|
+
errorMessage = _context32.t0 instanceof Error ? _context32.t0.message : String(_context32.t0);
|
|
2606
|
+
console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context32.t0);
|
|
2711
2607
|
this.logError('清空 IndexedDB 缓存时发生错误', {
|
|
2712
2608
|
moduleNames: moduleNames,
|
|
2713
2609
|
error: errorMessage
|
|
2714
2610
|
});
|
|
2715
|
-
throw
|
|
2611
|
+
throw _context32.t0;
|
|
2716
2612
|
case 29:
|
|
2717
2613
|
case "end":
|
|
2718
|
-
return
|
|
2614
|
+
return _context32.stop();
|
|
2719
2615
|
}
|
|
2720
|
-
},
|
|
2616
|
+
}, _callee32, this, [[16, 23]]);
|
|
2721
2617
|
}));
|
|
2722
2618
|
function clearAllIndexDB() {
|
|
2723
2619
|
return _clearAllIndexDB.apply(this, arguments);
|
|
@@ -2792,10 +2688,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
2792
2688
|
}, {
|
|
2793
2689
|
key: "handleRoute",
|
|
2794
2690
|
value: (function () {
|
|
2795
|
-
var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2691
|
+
var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(method, path, params) {
|
|
2796
2692
|
var startTime, handler, result, duration, _duration4, errorMessage;
|
|
2797
|
-
return _regeneratorRuntime().wrap(function
|
|
2798
|
-
while (1) switch (
|
|
2693
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2694
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
2799
2695
|
case 0:
|
|
2800
2696
|
startTime = Date.now();
|
|
2801
2697
|
this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5F00\u59CB: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
@@ -2806,7 +2702,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2806
2702
|
});
|
|
2807
2703
|
handler = this.getRouteHandler(method, path);
|
|
2808
2704
|
if (handler) {
|
|
2809
|
-
|
|
2705
|
+
_context33.next = 6;
|
|
2810
2706
|
break;
|
|
2811
2707
|
}
|
|
2812
2708
|
this.logError("\u8DEF\u7531\u672A\u627E\u5230: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
@@ -2815,13 +2711,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
2815
2711
|
});
|
|
2816
2712
|
throw new Error("Route not found: ".concat(method.toUpperCase(), " ").concat(path));
|
|
2817
2713
|
case 6:
|
|
2818
|
-
|
|
2819
|
-
|
|
2714
|
+
_context33.prev = 6;
|
|
2715
|
+
_context33.next = 9;
|
|
2820
2716
|
return handler(_objectSpread(_objectSpread({}, params), {}, {
|
|
2821
2717
|
path: path
|
|
2822
2718
|
}));
|
|
2823
2719
|
case 9:
|
|
2824
|
-
result =
|
|
2720
|
+
result = _context33.sent;
|
|
2825
2721
|
duration = Date.now() - startTime;
|
|
2826
2722
|
this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5B8C\u6210: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
2827
2723
|
method: method.toUpperCase(),
|
|
@@ -2830,12 +2726,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
2830
2726
|
resultCode: result === null || result === void 0 ? void 0 : result.code,
|
|
2831
2727
|
resultStatus: result === null || result === void 0 ? void 0 : result.status
|
|
2832
2728
|
});
|
|
2833
|
-
return
|
|
2729
|
+
return _context33.abrupt("return", result);
|
|
2834
2730
|
case 15:
|
|
2835
|
-
|
|
2836
|
-
|
|
2731
|
+
_context33.prev = 15;
|
|
2732
|
+
_context33.t0 = _context33["catch"](6);
|
|
2837
2733
|
_duration4 = Date.now() - startTime;
|
|
2838
|
-
errorMessage =
|
|
2734
|
+
errorMessage = _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0);
|
|
2839
2735
|
this.logError("\u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
2840
2736
|
method: method.toUpperCase(),
|
|
2841
2737
|
path: path,
|
|
@@ -2843,15 +2739,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
2843
2739
|
error: errorMessage,
|
|
2844
2740
|
data: params.data
|
|
2845
2741
|
});
|
|
2846
|
-
console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path),
|
|
2847
|
-
throw
|
|
2742
|
+
console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context33.t0);
|
|
2743
|
+
throw _context33.t0;
|
|
2848
2744
|
case 22:
|
|
2849
2745
|
case "end":
|
|
2850
|
-
return
|
|
2746
|
+
return _context33.stop();
|
|
2851
2747
|
}
|
|
2852
|
-
},
|
|
2748
|
+
}, _callee33, this, [[6, 15]]);
|
|
2853
2749
|
}));
|
|
2854
|
-
function handleRoute(_x33, _x34
|
|
2750
|
+
function handleRoute(_x32, _x33, _x34) {
|
|
2855
2751
|
return _handleRoute.apply(this, arguments);
|
|
2856
2752
|
}
|
|
2857
2753
|
return handleRoute;
|
|
@@ -2961,14 +2857,6 @@ var Server = /*#__PURE__*/function () {
|
|
|
2961
2857
|
method: 'post',
|
|
2962
2858
|
path: '/shop/local/print-order',
|
|
2963
2859
|
handler: this.handleLocalPrintOrder.bind(this)
|
|
2964
|
-
}, {
|
|
2965
|
-
method: 'post',
|
|
2966
|
-
path: '/shop/machinecode/batch-metadata',
|
|
2967
|
-
handler: this.handleMachinecodeBatchMetadata.bind(this)
|
|
2968
|
-
}, {
|
|
2969
|
-
method: 'post',
|
|
2970
|
-
path: '/machinecode/batch-metadata',
|
|
2971
|
-
handler: this.handleMachinecodeBatchMetadata.bind(this)
|
|
2972
2860
|
}]);
|
|
2973
2861
|
this.registerPrefixRoutes([{
|
|
2974
2862
|
method: 'get',
|
|
@@ -2983,36 +2871,36 @@ var Server = /*#__PURE__*/function () {
|
|
|
2983
2871
|
}, {
|
|
2984
2872
|
key: "getPaymentRouteModule",
|
|
2985
2873
|
value: function () {
|
|
2986
|
-
var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2874
|
+
var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
|
|
2987
2875
|
var _this6 = this;
|
|
2988
|
-
return _regeneratorRuntime().wrap(function
|
|
2989
|
-
while (1) switch (
|
|
2876
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2877
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
2990
2878
|
case 0:
|
|
2991
2879
|
if (!this.payment) {
|
|
2992
|
-
|
|
2880
|
+
_context35.next = 2;
|
|
2993
2881
|
break;
|
|
2994
2882
|
}
|
|
2995
|
-
return
|
|
2883
|
+
return _context35.abrupt("return", this.payment);
|
|
2996
2884
|
case 2:
|
|
2997
2885
|
if (!this.paymentRouteModule) {
|
|
2998
|
-
|
|
2886
|
+
_context35.next = 4;
|
|
2999
2887
|
break;
|
|
3000
2888
|
}
|
|
3001
|
-
return
|
|
2889
|
+
return _context35.abrupt("return", this.paymentRouteModule);
|
|
3002
2890
|
case 4:
|
|
3003
2891
|
if (!this.paymentRouteModuleInFlight) {
|
|
3004
|
-
|
|
2892
|
+
_context35.next = 6;
|
|
3005
2893
|
break;
|
|
3006
2894
|
}
|
|
3007
|
-
return
|
|
2895
|
+
return _context35.abrupt("return", this.paymentRouteModuleInFlight);
|
|
3008
2896
|
case 6:
|
|
3009
|
-
this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2897
|
+
this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
3010
2898
|
var module;
|
|
3011
|
-
return _regeneratorRuntime().wrap(function
|
|
3012
|
-
while (1) switch (
|
|
2899
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2900
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3013
2901
|
case 0:
|
|
3014
2902
|
module = new PaymentServerModule('server_payment_route', '1.0.0');
|
|
3015
|
-
|
|
2903
|
+
_context34.next = 3;
|
|
3016
2904
|
return module.initialize(_this6.core, {
|
|
3017
2905
|
store: {
|
|
3018
2906
|
payMethods: []
|
|
@@ -3020,21 +2908,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
3020
2908
|
});
|
|
3021
2909
|
case 3:
|
|
3022
2910
|
_this6.paymentRouteModule = module;
|
|
3023
|
-
return
|
|
2911
|
+
return _context34.abrupt("return", module);
|
|
3024
2912
|
case 5:
|
|
3025
2913
|
case "end":
|
|
3026
|
-
return
|
|
2914
|
+
return _context34.stop();
|
|
3027
2915
|
}
|
|
3028
|
-
},
|
|
2916
|
+
}, _callee34);
|
|
3029
2917
|
}))().finally(function () {
|
|
3030
2918
|
_this6.paymentRouteModuleInFlight = undefined;
|
|
3031
2919
|
});
|
|
3032
|
-
return
|
|
2920
|
+
return _context35.abrupt("return", this.paymentRouteModuleInFlight);
|
|
3033
2921
|
case 8:
|
|
3034
2922
|
case "end":
|
|
3035
|
-
return
|
|
2923
|
+
return _context35.stop();
|
|
3036
2924
|
}
|
|
3037
|
-
},
|
|
2925
|
+
}, _callee35, this);
|
|
3038
2926
|
}));
|
|
3039
2927
|
function getPaymentRouteModule() {
|
|
3040
2928
|
return _getPaymentRouteModule.apply(this, arguments);
|
|
@@ -3044,19 +2932,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
3044
2932
|
}, {
|
|
3045
2933
|
key: "fetchQuotationAvailableFromAPI",
|
|
3046
2934
|
value: function () {
|
|
3047
|
-
var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3048
|
-
var _this$
|
|
2935
|
+
var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(data) {
|
|
2936
|
+
var _this$app6;
|
|
3049
2937
|
var requester;
|
|
3050
|
-
return _regeneratorRuntime().wrap(function
|
|
3051
|
-
while (1) switch (
|
|
2938
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2939
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3052
2940
|
case 0:
|
|
3053
|
-
requester = ((_this$
|
|
2941
|
+
requester = ((_this$app6 = this.app) === null || _this$app6 === void 0 ? void 0 : _this$app6.request) || this.core.getPlugin('request');
|
|
3054
2942
|
if (requester !== null && requester !== void 0 && requester.get) {
|
|
3055
|
-
|
|
2943
|
+
_context36.next = 4;
|
|
3056
2944
|
break;
|
|
3057
2945
|
}
|
|
3058
2946
|
this.logError('fetchQuotationAvailableFromAPI: request 不可用');
|
|
3059
|
-
return
|
|
2947
|
+
return _context36.abrupt("return", {
|
|
3060
2948
|
code: 500,
|
|
3061
2949
|
message: 'request 不可用',
|
|
3062
2950
|
data: {
|
|
@@ -3065,14 +2953,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
3065
2953
|
status: false
|
|
3066
2954
|
});
|
|
3067
2955
|
case 4:
|
|
3068
|
-
return
|
|
2956
|
+
return _context36.abrupt("return", requester.get('/shop/quotation/available', data));
|
|
3069
2957
|
case 5:
|
|
3070
2958
|
case "end":
|
|
3071
|
-
return
|
|
2959
|
+
return _context36.stop();
|
|
3072
2960
|
}
|
|
3073
|
-
},
|
|
2961
|
+
}, _callee36, this);
|
|
3074
2962
|
}));
|
|
3075
|
-
function fetchQuotationAvailableFromAPI(
|
|
2963
|
+
function fetchQuotationAvailableFromAPI(_x35) {
|
|
3076
2964
|
return _fetchQuotationAvailableFromAPI.apply(this, arguments);
|
|
3077
2965
|
}
|
|
3078
2966
|
return fetchQuotationAvailableFromAPI;
|
|
@@ -3094,6 +2982,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3094
2982
|
key: "removeProductQuerySubscriber",
|
|
3095
2983
|
value: function removeProductQuerySubscriber(subscriberId) {
|
|
3096
2984
|
if (subscriberId) {
|
|
2985
|
+
this.clearSubscriberScheduleTimers(subscriberId);
|
|
3097
2986
|
this.productQuerySubscribers.delete(subscriberId);
|
|
3098
2987
|
this.logInfo('removeProductQuerySubscriber: 已移除订阅者', {
|
|
3099
2988
|
subscriberId: subscriberId,
|
|
@@ -3101,6 +2990,243 @@ var Server = /*#__PURE__*/function () {
|
|
|
3101
2990
|
});
|
|
3102
2991
|
}
|
|
3103
2992
|
}
|
|
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
|
+
}
|
|
3104
3230
|
}, {
|
|
3105
3231
|
key: "handleSalesSearchRequest",
|
|
3106
3232
|
value: (
|
|
@@ -3112,32 +3238,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
3112
3238
|
* const result = await this.handleSalesSearchRequest('single', '/shop/es/search/sales', { keyword: '1001' }, {})
|
|
3113
3239
|
*/
|
|
3114
3240
|
function () {
|
|
3115
|
-
var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3116
|
-
var queryPayload, result,
|
|
3117
|
-
return _regeneratorRuntime().wrap(function
|
|
3118
|
-
while (1) switch (
|
|
3241
|
+
var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(kind, backendPath, data, config) {
|
|
3242
|
+
var queryPayload, result, _ref53, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator6, _step6, orderId;
|
|
3243
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3244
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3119
3245
|
case 0:
|
|
3120
3246
|
queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
|
|
3121
|
-
|
|
3247
|
+
_context39.next = 3;
|
|
3122
3248
|
return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
|
|
3123
3249
|
case 3:
|
|
3124
|
-
result =
|
|
3125
|
-
|
|
3250
|
+
result = _context39.sent;
|
|
3251
|
+
_ref53 = config || {}, callback = _ref53.callback, subscriberId = _ref53.subscriberId, resetVisibleOrderIds = _ref53.resetVisibleOrderIds;
|
|
3126
3252
|
if (subscriberId && typeof callback === 'function') {
|
|
3127
3253
|
contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
|
|
3128
3254
|
existing = this.salesSearchSubscribers.get(subscriberId);
|
|
3129
3255
|
shouldReset = resetVisibleOrderIds === true || !existing || existing.kind !== kind || existing.contextSignature !== contextSignature;
|
|
3130
3256
|
visibleOrderIds = shouldReset ? new Set() : new Set(existing.visibleOrderIds);
|
|
3131
|
-
|
|
3257
|
+
_iterator6 = _createForOfIteratorHelper(this.extractSalesSearchOrderIds(kind, result));
|
|
3132
3258
|
try {
|
|
3133
|
-
for (
|
|
3134
|
-
orderId =
|
|
3259
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
3260
|
+
orderId = _step6.value;
|
|
3135
3261
|
visibleOrderIds.add(orderId);
|
|
3136
3262
|
}
|
|
3137
3263
|
} catch (err) {
|
|
3138
|
-
|
|
3264
|
+
_iterator6.e(err);
|
|
3139
3265
|
} finally {
|
|
3140
|
-
|
|
3266
|
+
_iterator6.f();
|
|
3141
3267
|
}
|
|
3142
3268
|
this.salesSearchSubscribers.set(subscriberId, {
|
|
3143
3269
|
callback: callback,
|
|
@@ -3153,14 +3279,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
3153
3279
|
visibleCount: visibleOrderIds.size
|
|
3154
3280
|
});
|
|
3155
3281
|
}
|
|
3156
|
-
return
|
|
3282
|
+
return _context39.abrupt("return", result);
|
|
3157
3283
|
case 7:
|
|
3158
3284
|
case "end":
|
|
3159
|
-
return
|
|
3285
|
+
return _context39.stop();
|
|
3160
3286
|
}
|
|
3161
|
-
},
|
|
3287
|
+
}, _callee39, this);
|
|
3162
3288
|
}));
|
|
3163
|
-
function handleSalesSearchRequest(
|
|
3289
|
+
function handleSalesSearchRequest(_x39, _x40, _x41, _x42) {
|
|
3164
3290
|
return _handleSalesSearchRequest.apply(this, arguments);
|
|
3165
3291
|
}
|
|
3166
3292
|
return handleSalesSearchRequest;
|
|
@@ -3175,20 +3301,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
3175
3301
|
}, {
|
|
3176
3302
|
key: "fetchSalesSearchFromAPI",
|
|
3177
3303
|
value: (function () {
|
|
3178
|
-
var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3179
|
-
var _this$
|
|
3180
|
-
var _response$
|
|
3181
|
-
return _regeneratorRuntime().wrap(function
|
|
3182
|
-
while (1) switch (
|
|
3304
|
+
var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(backendPath, data) {
|
|
3305
|
+
var _this$app7;
|
|
3306
|
+
var _response$data3, _response$code, _response$status, _response$message, response, _payload, errorMessage;
|
|
3307
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3308
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3183
3309
|
case 0:
|
|
3184
|
-
if ((_this$
|
|
3185
|
-
|
|
3310
|
+
if ((_this$app7 = this.app) !== null && _this$app7 !== void 0 && _this$app7.request) {
|
|
3311
|
+
_context40.next = 3;
|
|
3186
3312
|
break;
|
|
3187
3313
|
}
|
|
3188
3314
|
this.logError('fetchSalesSearchFromAPI: app.request 不可用', {
|
|
3189
3315
|
backendPath: backendPath
|
|
3190
3316
|
});
|
|
3191
|
-
return
|
|
3317
|
+
return _context40.abrupt("return", {
|
|
3192
3318
|
code: 500,
|
|
3193
3319
|
message: 'app.request 不可用',
|
|
3194
3320
|
data: backendPath === '/shop/es/search' ? {
|
|
@@ -3200,29 +3326,29 @@ var Server = /*#__PURE__*/function () {
|
|
|
3200
3326
|
status: false
|
|
3201
3327
|
});
|
|
3202
3328
|
case 3:
|
|
3203
|
-
|
|
3204
|
-
|
|
3329
|
+
_context40.prev = 3;
|
|
3330
|
+
_context40.next = 6;
|
|
3205
3331
|
return this.app.request.post(backendPath, data, {
|
|
3206
3332
|
isShopApi: true
|
|
3207
3333
|
});
|
|
3208
3334
|
case 6:
|
|
3209
|
-
response =
|
|
3210
|
-
_payload = (_response$
|
|
3211
|
-
return
|
|
3212
|
-
code: (_response$
|
|
3213
|
-
status: (_response$
|
|
3214
|
-
message: (_response$
|
|
3335
|
+
response = _context40.sent;
|
|
3336
|
+
_payload = (_response$data3 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data3 !== void 0 ? _response$data3 : response;
|
|
3337
|
+
return _context40.abrupt("return", {
|
|
3338
|
+
code: (_response$code = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code !== void 0 ? _response$code : 200,
|
|
3339
|
+
status: (_response$status = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status !== void 0 ? _response$status : true,
|
|
3340
|
+
message: (_response$message = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message !== void 0 ? _response$message : '',
|
|
3215
3341
|
data: _payload
|
|
3216
3342
|
});
|
|
3217
3343
|
case 11:
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
errorMessage =
|
|
3344
|
+
_context40.prev = 11;
|
|
3345
|
+
_context40.t0 = _context40["catch"](3);
|
|
3346
|
+
errorMessage = _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0);
|
|
3221
3347
|
this.logError('fetchSalesSearchFromAPI: 请求失败', {
|
|
3222
3348
|
backendPath: backendPath,
|
|
3223
3349
|
error: errorMessage
|
|
3224
3350
|
});
|
|
3225
|
-
return
|
|
3351
|
+
return _context40.abrupt("return", {
|
|
3226
3352
|
code: 500,
|
|
3227
3353
|
message: errorMessage,
|
|
3228
3354
|
data: backendPath === '/shop/es/search' ? {
|
|
@@ -3235,11 +3361,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3235
3361
|
});
|
|
3236
3362
|
case 16:
|
|
3237
3363
|
case "end":
|
|
3238
|
-
return
|
|
3364
|
+
return _context40.stop();
|
|
3239
3365
|
}
|
|
3240
|
-
},
|
|
3366
|
+
}, _callee40, this, [[3, 11]]);
|
|
3241
3367
|
}));
|
|
3242
|
-
function fetchSalesSearchFromAPI(
|
|
3368
|
+
function fetchSalesSearchFromAPI(_x43, _x44) {
|
|
3243
3369
|
return _fetchSalesSearchFromAPI.apply(this, arguments);
|
|
3244
3370
|
}
|
|
3245
3371
|
return fetchSalesSearchFromAPI;
|
|
@@ -3269,10 +3395,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
3269
3395
|
}, {
|
|
3270
3396
|
key: "stripSalesSearchPageParams",
|
|
3271
3397
|
value: function stripSalesSearchPageParams(value) {
|
|
3272
|
-
var
|
|
3398
|
+
var _this8 = this;
|
|
3273
3399
|
if (Array.isArray(value)) {
|
|
3274
3400
|
return value.map(function (item) {
|
|
3275
|
-
return
|
|
3401
|
+
return _this8.stripSalesSearchPageParams(item);
|
|
3276
3402
|
});
|
|
3277
3403
|
}
|
|
3278
3404
|
if (!value || _typeof(value) !== 'object') return value;
|
|
@@ -3310,12 +3436,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
3310
3436
|
key: "extractSalesSearchOrderIds",
|
|
3311
3437
|
value: function extractSalesSearchOrderIds(kind, result) {
|
|
3312
3438
|
var _this$findSalesSearch,
|
|
3313
|
-
|
|
3439
|
+
_this9 = this;
|
|
3314
3440
|
var data = this.extractSalesSearchResponseData(result);
|
|
3315
3441
|
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;
|
|
3316
3442
|
if (!Array.isArray(list)) return [];
|
|
3317
3443
|
return list.map(function (item) {
|
|
3318
|
-
return
|
|
3444
|
+
return _this9.getSalesSearchOrderId(item);
|
|
3319
3445
|
}).filter(function (id) {
|
|
3320
3446
|
return !!id;
|
|
3321
3447
|
});
|
|
@@ -3482,11 +3608,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3482
3608
|
}, {
|
|
3483
3609
|
key: "stableSerialize",
|
|
3484
3610
|
value: function stableSerialize(value) {
|
|
3485
|
-
var
|
|
3611
|
+
var _this10 = this;
|
|
3486
3612
|
if (value === null || value === undefined) return 'null';
|
|
3487
3613
|
if (Array.isArray(value)) {
|
|
3488
3614
|
return "[".concat(value.map(function (item) {
|
|
3489
|
-
return
|
|
3615
|
+
return _this10.stableSerialize(item);
|
|
3490
3616
|
}).join(','), "]");
|
|
3491
3617
|
}
|
|
3492
3618
|
if (_typeof(value) === 'object') {
|
|
@@ -3495,7 +3621,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3495
3621
|
return obj[k] !== undefined;
|
|
3496
3622
|
}).sort();
|
|
3497
3623
|
return "{".concat(keys.map(function (k) {
|
|
3498
|
-
return "".concat(JSON.stringify(k), ":").concat(
|
|
3624
|
+
return "".concat(JSON.stringify(k), ":").concat(_this10.stableSerialize(obj[k]));
|
|
3499
3625
|
}).join(','), "}");
|
|
3500
3626
|
}
|
|
3501
3627
|
return JSON.stringify(value);
|
|
@@ -3544,22 +3670,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
3544
3670
|
}
|
|
3545
3671
|
var oldestKey = null;
|
|
3546
3672
|
var oldestTime = Number.POSITIVE_INFINITY;
|
|
3547
|
-
var
|
|
3548
|
-
|
|
3673
|
+
var _iterator7 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
|
|
3674
|
+
_step7;
|
|
3549
3675
|
try {
|
|
3550
|
-
for (
|
|
3551
|
-
var
|
|
3552
|
-
_key3 =
|
|
3553
|
-
cache =
|
|
3676
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
3677
|
+
var _step7$value = _slicedToArray(_step7.value, 2),
|
|
3678
|
+
_key3 = _step7$value[0],
|
|
3679
|
+
cache = _step7$value[1];
|
|
3554
3680
|
if (cache.updatedAt < oldestTime) {
|
|
3555
3681
|
oldestTime = cache.updatedAt;
|
|
3556
3682
|
oldestKey = _key3;
|
|
3557
3683
|
}
|
|
3558
3684
|
}
|
|
3559
3685
|
} catch (err) {
|
|
3560
|
-
|
|
3686
|
+
_iterator7.e(err);
|
|
3561
3687
|
} finally {
|
|
3562
|
-
|
|
3688
|
+
_iterator7.f();
|
|
3563
3689
|
}
|
|
3564
3690
|
if (oldestKey) this.bookingRemoteCache.delete(oldestKey);
|
|
3565
3691
|
}
|
|
@@ -3575,17 +3701,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
3575
3701
|
key: "markBookingRemoteCacheAllStale",
|
|
3576
3702
|
value: function markBookingRemoteCacheAllStale(reason) {
|
|
3577
3703
|
if (this.bookingRemoteCache.size === 0) return;
|
|
3578
|
-
var
|
|
3579
|
-
|
|
3704
|
+
var _iterator8 = _createForOfIteratorHelper(this.bookingRemoteCache.values()),
|
|
3705
|
+
_step8;
|
|
3580
3706
|
try {
|
|
3581
|
-
for (
|
|
3582
|
-
var entry =
|
|
3707
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
3708
|
+
var entry = _step8.value;
|
|
3583
3709
|
entry.stale = true;
|
|
3584
3710
|
}
|
|
3585
3711
|
} catch (err) {
|
|
3586
|
-
|
|
3712
|
+
_iterator8.e(err);
|
|
3587
3713
|
} finally {
|
|
3588
|
-
|
|
3714
|
+
_iterator8.f();
|
|
3589
3715
|
}
|
|
3590
3716
|
this.logWarning('bookingRemoteCache: 全量标记失效', {
|
|
3591
3717
|
reason: reason,
|
|
@@ -3611,13 +3737,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
3611
3737
|
key: "notifyBookingRemoteSubscribersByCacheKey",
|
|
3612
3738
|
value: function notifyBookingRemoteSubscribersByCacheKey(cacheKey, entry, reason) {
|
|
3613
3739
|
if (this.bookingRemoteQuerySubscribers.size === 0) return;
|
|
3614
|
-
var
|
|
3615
|
-
|
|
3740
|
+
var _iterator9 = _createForOfIteratorHelper(this.bookingRemoteQuerySubscribers.entries()),
|
|
3741
|
+
_step9;
|
|
3616
3742
|
try {
|
|
3617
|
-
for (
|
|
3618
|
-
var
|
|
3619
|
-
subscriberId =
|
|
3620
|
-
subscriber =
|
|
3743
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
3744
|
+
var _step9$value = _slicedToArray(_step9.value, 2),
|
|
3745
|
+
subscriberId = _step9$value[0],
|
|
3746
|
+
subscriber = _step9$value[1];
|
|
3621
3747
|
if (subscriber.cacheKey !== cacheKey) continue;
|
|
3622
3748
|
try {
|
|
3623
3749
|
var callbackStartAt = Date.now();
|
|
@@ -3644,9 +3770,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
3644
3770
|
}
|
|
3645
3771
|
}
|
|
3646
3772
|
} catch (err) {
|
|
3647
|
-
|
|
3773
|
+
_iterator9.e(err);
|
|
3648
3774
|
} finally {
|
|
3649
|
-
|
|
3775
|
+
_iterator9.f();
|
|
3650
3776
|
}
|
|
3651
3777
|
}
|
|
3652
3778
|
}, {
|
|
@@ -3661,13 +3787,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
3661
3787
|
return;
|
|
3662
3788
|
}
|
|
3663
3789
|
var syncedEntryCount = 0;
|
|
3664
|
-
var
|
|
3665
|
-
|
|
3790
|
+
var _iterator10 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
|
|
3791
|
+
_step10;
|
|
3666
3792
|
try {
|
|
3667
|
-
for (
|
|
3668
|
-
var
|
|
3669
|
-
cacheKey =
|
|
3670
|
-
entry =
|
|
3793
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
3794
|
+
var _step10$value = _slicedToArray(_step10.value, 2),
|
|
3795
|
+
cacheKey = _step10$value[0],
|
|
3796
|
+
entry = _step10$value[1];
|
|
3671
3797
|
if (entry.stale) {
|
|
3672
3798
|
this.bookingRemoteCache.delete(cacheKey);
|
|
3673
3799
|
continue;
|
|
@@ -3675,25 +3801,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
3675
3801
|
try {
|
|
3676
3802
|
var queryPayload = entry.queryPayload;
|
|
3677
3803
|
var orderMap = new Map();
|
|
3678
|
-
var
|
|
3679
|
-
|
|
3804
|
+
var _iterator11 = _createForOfIteratorHelper(entry.rawOrders),
|
|
3805
|
+
_step11;
|
|
3680
3806
|
try {
|
|
3681
|
-
for (
|
|
3682
|
-
var order =
|
|
3807
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
3808
|
+
var order = _step11.value;
|
|
3683
3809
|
var _key4 = this.toOrderIdKey(order);
|
|
3684
3810
|
if (_key4) orderMap.set(_key4, order);
|
|
3685
3811
|
}
|
|
3686
3812
|
} catch (err) {
|
|
3687
|
-
|
|
3813
|
+
_iterator11.e(err);
|
|
3688
3814
|
} finally {
|
|
3689
|
-
|
|
3815
|
+
_iterator11.f();
|
|
3690
3816
|
}
|
|
3691
3817
|
var changed = false;
|
|
3692
|
-
var
|
|
3693
|
-
|
|
3818
|
+
var _iterator12 = _createForOfIteratorHelper(latestOrders),
|
|
3819
|
+
_step12;
|
|
3694
3820
|
try {
|
|
3695
|
-
for (
|
|
3696
|
-
var latest =
|
|
3821
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
3822
|
+
var latest = _step12.value;
|
|
3697
3823
|
var _key5 = this.toOrderIdKey(latest);
|
|
3698
3824
|
if (!_key5) continue;
|
|
3699
3825
|
if (orderMap.has(_key5)) {
|
|
@@ -3705,9 +3831,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
3705
3831
|
changed = true;
|
|
3706
3832
|
}
|
|
3707
3833
|
} catch (err) {
|
|
3708
|
-
|
|
3834
|
+
_iterator12.e(err);
|
|
3709
3835
|
} finally {
|
|
3710
|
-
|
|
3836
|
+
_iterator12.f();
|
|
3711
3837
|
}
|
|
3712
3838
|
if (!changed) continue;
|
|
3713
3839
|
var mergedOrders = _toConsumableArray(orderMap.values());
|
|
@@ -3740,9 +3866,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
3740
3866
|
}
|
|
3741
3867
|
}
|
|
3742
3868
|
} catch (err) {
|
|
3743
|
-
|
|
3869
|
+
_iterator10.e(err);
|
|
3744
3870
|
} finally {
|
|
3745
|
-
|
|
3871
|
+
_iterator10.f();
|
|
3746
3872
|
}
|
|
3747
3873
|
var syncEndAt = Date.now();
|
|
3748
3874
|
if (syncedEntryCount > 0) {
|
|
@@ -3760,18 +3886,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
3760
3886
|
}, {
|
|
3761
3887
|
key: "fetchOrderListFromAPI",
|
|
3762
3888
|
value: (function () {
|
|
3763
|
-
var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3764
|
-
var _this$
|
|
3765
|
-
var _response$
|
|
3766
|
-
return _regeneratorRuntime().wrap(function
|
|
3767
|
-
while (1) switch (
|
|
3889
|
+
var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(data) {
|
|
3890
|
+
var _this$app8;
|
|
3891
|
+
var _response$data4, response, _payload2, list, count, errorMessage;
|
|
3892
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3893
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3768
3894
|
case 0:
|
|
3769
|
-
if ((_this$
|
|
3770
|
-
|
|
3895
|
+
if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
|
|
3896
|
+
_context41.next = 3;
|
|
3771
3897
|
break;
|
|
3772
3898
|
}
|
|
3773
3899
|
this.logError('fetchOrderListFromAPI: app.request 不可用');
|
|
3774
|
-
return
|
|
3900
|
+
return _context41.abrupt("return", {
|
|
3775
3901
|
code: 500,
|
|
3776
3902
|
message: 'app.request 不可用',
|
|
3777
3903
|
data: {
|
|
@@ -3781,17 +3907,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
3781
3907
|
status: false
|
|
3782
3908
|
});
|
|
3783
3909
|
case 3:
|
|
3784
|
-
|
|
3785
|
-
|
|
3910
|
+
_context41.prev = 3;
|
|
3911
|
+
_context41.next = 6;
|
|
3786
3912
|
return this.app.request.post('/shop/order/v2/list', data, {
|
|
3787
3913
|
isShopApi: true
|
|
3788
3914
|
});
|
|
3789
3915
|
case 6:
|
|
3790
|
-
response =
|
|
3791
|
-
_payload2 = (_response$
|
|
3916
|
+
response = _context41.sent;
|
|
3917
|
+
_payload2 = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
|
|
3792
3918
|
list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
|
|
3793
3919
|
count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
|
|
3794
|
-
return
|
|
3920
|
+
return _context41.abrupt("return", {
|
|
3795
3921
|
code: 200,
|
|
3796
3922
|
data: _objectSpread(_objectSpread({}, _payload2), {}, {
|
|
3797
3923
|
list: list,
|
|
@@ -3801,13 +3927,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
3801
3927
|
status: true
|
|
3802
3928
|
});
|
|
3803
3929
|
case 13:
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
errorMessage =
|
|
3930
|
+
_context41.prev = 13;
|
|
3931
|
+
_context41.t0 = _context41["catch"](3);
|
|
3932
|
+
errorMessage = _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0);
|
|
3807
3933
|
this.logError('fetchOrderListFromAPI: 请求失败', {
|
|
3808
3934
|
error: errorMessage
|
|
3809
3935
|
});
|
|
3810
|
-
return
|
|
3936
|
+
return _context41.abrupt("return", {
|
|
3811
3937
|
code: 500,
|
|
3812
3938
|
message: errorMessage,
|
|
3813
3939
|
data: {
|
|
@@ -3818,11 +3944,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3818
3944
|
});
|
|
3819
3945
|
case 18:
|
|
3820
3946
|
case "end":
|
|
3821
|
-
return
|
|
3947
|
+
return _context41.stop();
|
|
3822
3948
|
}
|
|
3823
|
-
},
|
|
3949
|
+
}, _callee41, this, [[3, 13]]);
|
|
3824
3950
|
}));
|
|
3825
|
-
function fetchOrderListFromAPI(
|
|
3951
|
+
function fetchOrderListFromAPI(_x45) {
|
|
3826
3952
|
return _fetchOrderListFromAPI.apply(this, arguments);
|
|
3827
3953
|
}
|
|
3828
3954
|
return fetchOrderListFromAPI;
|
|
@@ -3834,17 +3960,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
3834
3960
|
}, {
|
|
3835
3961
|
key: "fetchBookingListFromAPI",
|
|
3836
3962
|
value: (function () {
|
|
3837
|
-
var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3963
|
+
var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(data) {
|
|
3838
3964
|
var memoryCacheEnabled, withFields, requestPayload, cacheKey, cached, rawList, bookingResult, _bookingResult$list, errorMessage;
|
|
3839
|
-
return _regeneratorRuntime().wrap(function
|
|
3840
|
-
while (1) switch (
|
|
3965
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3966
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
3841
3967
|
case 0:
|
|
3842
3968
|
if (this.order) {
|
|
3843
|
-
|
|
3969
|
+
_context42.next = 3;
|
|
3844
3970
|
break;
|
|
3845
3971
|
}
|
|
3846
3972
|
this.logError('fetchBookingListFromAPI: Order 模块不可用');
|
|
3847
|
-
return
|
|
3973
|
+
return _context42.abrupt("return", {
|
|
3848
3974
|
code: 500,
|
|
3849
3975
|
message: 'Order 模块不可用',
|
|
3850
3976
|
data: {
|
|
@@ -3854,18 +3980,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
3854
3980
|
status: false
|
|
3855
3981
|
});
|
|
3856
3982
|
case 3:
|
|
3857
|
-
|
|
3983
|
+
_context42.prev = 3;
|
|
3858
3984
|
memoryCacheEnabled = this.isBookingRemoteMemoryCacheEnabled(data);
|
|
3859
3985
|
withFields = this.resolveBookingSalesWith(data);
|
|
3860
3986
|
requestPayload = this.normalizeBookingRemoteQueryPayload(data, withFields);
|
|
3861
3987
|
cacheKey = this.buildBookingRemoteCacheKey(requestPayload);
|
|
3862
3988
|
if (!memoryCacheEnabled) {
|
|
3863
|
-
|
|
3989
|
+
_context42.next = 13;
|
|
3864
3990
|
break;
|
|
3865
3991
|
}
|
|
3866
3992
|
cached = this.readBookingRemoteCache(cacheKey);
|
|
3867
3993
|
if (!cached) {
|
|
3868
|
-
|
|
3994
|
+
_context42.next = 13;
|
|
3869
3995
|
break;
|
|
3870
3996
|
}
|
|
3871
3997
|
this.logInfo('fetchBookingListFromAPI: 命中内存缓存', {
|
|
@@ -3873,14 +3999,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
3873
3999
|
listCount: cached.bookingResult.count,
|
|
3874
4000
|
withFields: cached.withFields
|
|
3875
4001
|
});
|
|
3876
|
-
return
|
|
4002
|
+
return _context42.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
|
|
3877
4003
|
cache_hit: true
|
|
3878
4004
|
}));
|
|
3879
4005
|
case 13:
|
|
3880
|
-
|
|
4006
|
+
_context42.next = 15;
|
|
3881
4007
|
return this.order.fetchOrdersBySSE(requestPayload);
|
|
3882
4008
|
case 15:
|
|
3883
|
-
rawList =
|
|
4009
|
+
rawList = _context42.sent;
|
|
3884
4010
|
bookingResult = sortBookings(filterBookingsFromOrders(rawList, data), data); // DEBUG: 挂到 window 上方便排查 SSE → 日历数据丢失问题
|
|
3885
4011
|
if (typeof globalThis !== 'undefined') {
|
|
3886
4012
|
globalThis.__SSE_BOOKING_DEBUG__ = {
|
|
@@ -3927,15 +4053,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
3927
4053
|
cacheKey: cacheKey,
|
|
3928
4054
|
withFields: withFields
|
|
3929
4055
|
});
|
|
3930
|
-
return
|
|
4056
|
+
return _context42.abrupt("return", this.buildBookingResponse(bookingResult));
|
|
3931
4057
|
case 23:
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
errorMessage =
|
|
4058
|
+
_context42.prev = 23;
|
|
4059
|
+
_context42.t0 = _context42["catch"](3);
|
|
4060
|
+
errorMessage = _context42.t0 instanceof Error ? _context42.t0.message : String(_context42.t0);
|
|
3935
4061
|
this.logError('fetchBookingListFromAPI: SSE 请求失败', {
|
|
3936
4062
|
error: errorMessage
|
|
3937
4063
|
});
|
|
3938
|
-
return
|
|
4064
|
+
return _context42.abrupt("return", {
|
|
3939
4065
|
code: 500,
|
|
3940
4066
|
message: errorMessage,
|
|
3941
4067
|
data: {
|
|
@@ -3946,11 +4072,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3946
4072
|
});
|
|
3947
4073
|
case 28:
|
|
3948
4074
|
case "end":
|
|
3949
|
-
return
|
|
4075
|
+
return _context42.stop();
|
|
3950
4076
|
}
|
|
3951
|
-
},
|
|
4077
|
+
}, _callee42, this, [[3, 23]]);
|
|
3952
4078
|
}));
|
|
3953
|
-
function fetchBookingListFromAPI(
|
|
4079
|
+
function fetchBookingListFromAPI(_x46) {
|
|
3954
4080
|
return _fetchBookingListFromAPI.apply(this, arguments);
|
|
3955
4081
|
}
|
|
3956
4082
|
return fetchBookingListFromAPI;
|
|
@@ -3958,24 +4084,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
3958
4084
|
}, {
|
|
3959
4085
|
key: "getDeviceTaskPlugin",
|
|
3960
4086
|
value: function getDeviceTaskPlugin() {
|
|
3961
|
-
var _this$
|
|
3962
|
-
return ((_this$
|
|
4087
|
+
var _this$app9, _this$app9$getPlugin;
|
|
4088
|
+
return ((_this$app9 = this.app) === null || _this$app9 === void 0 || (_this$app9$getPlugin = _this$app9.getPlugin) === null || _this$app9$getPlugin === void 0 ? void 0 : _this$app9$getPlugin.call(_this$app9, 'deviceTask')) || null;
|
|
3963
4089
|
}
|
|
3964
4090
|
}, {
|
|
3965
4091
|
key: "getIdGeneratorPlugin",
|
|
3966
4092
|
value: function getIdGeneratorPlugin() {
|
|
3967
|
-
var _this$
|
|
3968
|
-
return ((_this$
|
|
4093
|
+
var _this$app10, _this$app10$getPlugin;
|
|
4094
|
+
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, 'idGenerator')) || null;
|
|
3969
4095
|
}
|
|
3970
4096
|
}, {
|
|
3971
4097
|
key: "getAppData",
|
|
3972
4098
|
value: function getAppData(key) {
|
|
3973
|
-
var _this$core$getPlugin, _this$core$getPlugin$, _this$
|
|
4099
|
+
var _this$core$getPlugin, _this$core$getPlugin$, _this$app11, _this$app11$getData, _this$app12, _this$app12$getStore, _this$app12$getStore$, _this$app12$getStore$2, _this$app13, _this$app13$getStore, _this$app13$getStore$, _this$app13$getStore$2, _this$app14, _this$app14$getStore, _this$app14$getStore$, _this$app14$getStore$2;
|
|
3974
4100
|
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);
|
|
3975
4101
|
if (typeof getData === 'function') return getData(key);
|
|
3976
|
-
var directValue = (_this$
|
|
4102
|
+
var directValue = (_this$app11 = this.app) === null || _this$app11 === void 0 || (_this$app11$getData = _this$app11.getData) === null || _this$app11$getData === void 0 ? void 0 : _this$app11$getData.call(_this$app11, key);
|
|
3977
4103
|
if (directValue !== undefined) return directValue;
|
|
3978
|
-
var coreData = ((_this$
|
|
4104
|
+
var coreData = ((_this$app12 = this.app) === null || _this$app12 === void 0 || (_this$app12 = _this$app12.models) === null || _this$app12 === void 0 || (_this$app12$getStore = _this$app12.getStore) === null || _this$app12$getStore === void 0 || (_this$app12$getStore$ = (_this$app12$getStore$2 = _this$app12$getStore.call(_this$app12)).getDataByModel) === null || _this$app12$getStore$ === void 0 ? void 0 : _this$app12$getStore$.call(_this$app12$getStore$2, 'core', 'core')) || ((_this$app13 = this.app) === null || _this$app13 === void 0 || (_this$app13 = _this$app13.data) === null || _this$app13 === void 0 || (_this$app13 = _this$app13.store) === 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 || (_this$app14$getStore$ = _this$app14$getStore$.call(_this$app14$getStore$2, 'core')) === null || _this$app14$getStore$ === void 0 ? void 0 : _this$app14$getStore$.core);
|
|
3979
4105
|
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
3980
4106
|
}
|
|
3981
4107
|
}, {
|
|
@@ -4026,32 +4152,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
4026
4152
|
}, {
|
|
4027
4153
|
key: "getShortNumberOrDeviceId",
|
|
4028
4154
|
value: function () {
|
|
4029
|
-
var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4155
|
+
var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
|
|
4030
4156
|
var getAsyncIotDeviceInfo, res;
|
|
4031
|
-
return _regeneratorRuntime().wrap(function
|
|
4032
|
-
while (1) switch (
|
|
4157
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4158
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
4033
4159
|
case 0:
|
|
4034
4160
|
getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
|
|
4035
4161
|
if (!getAsyncIotDeviceInfo) {
|
|
4036
|
-
|
|
4162
|
+
_context43.next = 7;
|
|
4037
4163
|
break;
|
|
4038
4164
|
}
|
|
4039
|
-
|
|
4165
|
+
_context43.next = 4;
|
|
4040
4166
|
return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
|
|
4041
4167
|
case 4:
|
|
4042
|
-
res =
|
|
4168
|
+
res = _context43.sent;
|
|
4043
4169
|
if (!(res !== null && res !== void 0 && res.short_number)) {
|
|
4044
|
-
|
|
4170
|
+
_context43.next = 7;
|
|
4045
4171
|
break;
|
|
4046
4172
|
}
|
|
4047
|
-
return
|
|
4173
|
+
return _context43.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
|
|
4048
4174
|
case 7:
|
|
4049
|
-
return
|
|
4175
|
+
return _context43.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
|
|
4050
4176
|
case 8:
|
|
4051
4177
|
case "end":
|
|
4052
|
-
return
|
|
4178
|
+
return _context43.stop();
|
|
4053
4179
|
}
|
|
4054
|
-
},
|
|
4180
|
+
}, _callee43, this);
|
|
4055
4181
|
}));
|
|
4056
4182
|
function getShortNumberOrDeviceId() {
|
|
4057
4183
|
return _getShortNumberOrDeviceId.apply(this, arguments);
|
|
@@ -4078,16 +4204,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
4078
4204
|
}, {
|
|
4079
4205
|
key: "normalizeCheckoutSubmitData",
|
|
4080
4206
|
value: function () {
|
|
4081
|
-
var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4207
|
+
var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(data, title) {
|
|
4082
4208
|
var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
|
|
4083
|
-
return _regeneratorRuntime().wrap(function
|
|
4084
|
-
while (1) switch (
|
|
4209
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4210
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
4085
4211
|
case 0:
|
|
4086
4212
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
4087
|
-
|
|
4213
|
+
_context44.next = 2;
|
|
4088
4214
|
break;
|
|
4089
4215
|
}
|
|
4090
|
-
return
|
|
4216
|
+
return _context44.abrupt("return", data);
|
|
4091
4217
|
case 2:
|
|
4092
4218
|
next = _objectSpread({}, data);
|
|
4093
4219
|
externalSaleNumber = next.external_sale_number;
|
|
@@ -4097,7 +4223,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4097
4223
|
delete next.vouchers;
|
|
4098
4224
|
hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
|
|
4099
4225
|
if (!hasCheckoutOrderNumbers) {
|
|
4100
|
-
|
|
4226
|
+
_context44.next = 11;
|
|
4101
4227
|
break;
|
|
4102
4228
|
}
|
|
4103
4229
|
this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
|
|
@@ -4107,10 +4233,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
4107
4233
|
shop_order_number: next.shop_order_number,
|
|
4108
4234
|
shop_full_order_number: next.shop_full_order_number
|
|
4109
4235
|
});
|
|
4110
|
-
return
|
|
4236
|
+
return _context44.abrupt("return", next);
|
|
4111
4237
|
case 11:
|
|
4112
4238
|
if (!this.isBlankCheckoutValue(externalSaleNumber)) {
|
|
4113
|
-
|
|
4239
|
+
_context44.next = 14;
|
|
4114
4240
|
break;
|
|
4115
4241
|
}
|
|
4116
4242
|
if (shouldClearLocalOrderId) {
|
|
@@ -4119,10 +4245,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
4119
4245
|
order_id: next.order_id
|
|
4120
4246
|
});
|
|
4121
4247
|
}
|
|
4122
|
-
return
|
|
4248
|
+
return _context44.abrupt("return", next);
|
|
4123
4249
|
case 14:
|
|
4124
4250
|
if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
|
|
4125
|
-
|
|
4251
|
+
_context44.next = 17;
|
|
4126
4252
|
break;
|
|
4127
4253
|
}
|
|
4128
4254
|
if (shouldClearLocalOrderId) {
|
|
@@ -4131,12 +4257,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
4131
4257
|
external_sale_number: externalSaleNumber
|
|
4132
4258
|
});
|
|
4133
4259
|
}
|
|
4134
|
-
return
|
|
4260
|
+
return _context44.abrupt("return", next);
|
|
4135
4261
|
case 17:
|
|
4136
|
-
|
|
4262
|
+
_context44.prev = 17;
|
|
4137
4263
|
localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
|
|
4138
4264
|
if (localOrder) {
|
|
4139
|
-
|
|
4265
|
+
_context44.next = 22;
|
|
4140
4266
|
break;
|
|
4141
4267
|
}
|
|
4142
4268
|
if (shouldClearLocalOrderId) {
|
|
@@ -4146,7 +4272,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4146
4272
|
localOrderFound: false
|
|
4147
4273
|
});
|
|
4148
4274
|
}
|
|
4149
|
-
return
|
|
4275
|
+
return _context44.abrupt("return", next);
|
|
4150
4276
|
case 22:
|
|
4151
4277
|
if (this.isBlankCheckoutValue(next.shop_order_number)) {
|
|
4152
4278
|
next.shop_order_number = localOrder.shop_order_number;
|
|
@@ -4163,23 +4289,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
4163
4289
|
shop_full_order_number: next.shop_full_order_number
|
|
4164
4290
|
});
|
|
4165
4291
|
// 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
|
|
4166
|
-
return
|
|
4292
|
+
return _context44.abrupt("return", next);
|
|
4167
4293
|
case 28:
|
|
4168
|
-
|
|
4169
|
-
|
|
4294
|
+
_context44.prev = 28;
|
|
4295
|
+
_context44.t0 = _context44["catch"](17);
|
|
4170
4296
|
this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
|
|
4171
4297
|
external_sale_number: externalSaleNumber,
|
|
4172
|
-
error: this.getUnknownErrorMessage(
|
|
4173
|
-
error_detail: this.normalizeUnknownError(
|
|
4298
|
+
error: this.getUnknownErrorMessage(_context44.t0),
|
|
4299
|
+
error_detail: this.normalizeUnknownError(_context44.t0)
|
|
4174
4300
|
});
|
|
4175
|
-
return
|
|
4301
|
+
return _context44.abrupt("return", next);
|
|
4176
4302
|
case 32:
|
|
4177
4303
|
case "end":
|
|
4178
|
-
return
|
|
4304
|
+
return _context44.stop();
|
|
4179
4305
|
}
|
|
4180
|
-
},
|
|
4306
|
+
}, _callee44, this, [[17, 28]]);
|
|
4181
4307
|
}));
|
|
4182
|
-
function normalizeCheckoutSubmitData(
|
|
4308
|
+
function normalizeCheckoutSubmitData(_x47, _x48) {
|
|
4183
4309
|
return _normalizeCheckoutSubmitData.apply(this, arguments);
|
|
4184
4310
|
}
|
|
4185
4311
|
return normalizeCheckoutSubmitData;
|
|
@@ -4187,81 +4313,81 @@ var Server = /*#__PURE__*/function () {
|
|
|
4187
4313
|
}, {
|
|
4188
4314
|
key: "ensureCheckoutOrderNumbers",
|
|
4189
4315
|
value: function () {
|
|
4190
|
-
var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4316
|
+
var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(data, title) {
|
|
4191
4317
|
var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
|
|
4192
|
-
return _regeneratorRuntime().wrap(function
|
|
4193
|
-
while (1) switch (
|
|
4318
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
4319
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4194
4320
|
case 0:
|
|
4195
4321
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
4196
|
-
|
|
4322
|
+
_context45.next = 2;
|
|
4197
4323
|
break;
|
|
4198
4324
|
}
|
|
4199
|
-
return
|
|
4325
|
+
return _context45.abrupt("return", data);
|
|
4200
4326
|
case 2:
|
|
4201
4327
|
next = _objectSpread({}, data);
|
|
4202
4328
|
needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
|
|
4203
4329
|
needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
|
|
4204
4330
|
if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
|
|
4205
|
-
|
|
4331
|
+
_context45.next = 7;
|
|
4206
4332
|
break;
|
|
4207
4333
|
}
|
|
4208
|
-
return
|
|
4334
|
+
return _context45.abrupt("return", next);
|
|
4209
4335
|
case 7:
|
|
4210
4336
|
idGenerator = this.getIdGeneratorPlugin();
|
|
4211
4337
|
if (idGenerator) {
|
|
4212
|
-
|
|
4338
|
+
_context45.next = 11;
|
|
4213
4339
|
break;
|
|
4214
4340
|
}
|
|
4215
4341
|
this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
|
|
4216
4342
|
needsShopOrderNumber: needsShopOrderNumber,
|
|
4217
4343
|
needsShopFullOrderNumber: needsShopFullOrderNumber
|
|
4218
4344
|
});
|
|
4219
|
-
return
|
|
4345
|
+
return _context45.abrupt("return", next);
|
|
4220
4346
|
case 11:
|
|
4221
|
-
|
|
4347
|
+
_context45.prev = 11;
|
|
4222
4348
|
if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
|
|
4223
|
-
|
|
4349
|
+
_context45.next = 16;
|
|
4224
4350
|
break;
|
|
4225
4351
|
}
|
|
4226
|
-
|
|
4352
|
+
_context45.next = 15;
|
|
4227
4353
|
return idGenerator.generateShopOrderNumber({
|
|
4228
4354
|
biz: next.business_code || 'ticket'
|
|
4229
4355
|
});
|
|
4230
4356
|
case 15:
|
|
4231
|
-
next.shop_order_number =
|
|
4357
|
+
next.shop_order_number = _context45.sent;
|
|
4232
4358
|
case 16:
|
|
4233
4359
|
if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
|
|
4234
|
-
|
|
4360
|
+
_context45.next = 20;
|
|
4235
4361
|
break;
|
|
4236
4362
|
}
|
|
4237
|
-
|
|
4363
|
+
_context45.next = 19;
|
|
4238
4364
|
return idGenerator.generateReceiptId({
|
|
4239
4365
|
biz: next.business_code || 'ticket'
|
|
4240
4366
|
});
|
|
4241
4367
|
case 19:
|
|
4242
|
-
next.shop_full_order_number =
|
|
4368
|
+
next.shop_full_order_number = _context45.sent;
|
|
4243
4369
|
case 20:
|
|
4244
4370
|
this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
|
|
4245
4371
|
shop_order_number: next.shop_order_number,
|
|
4246
4372
|
shop_full_order_number: next.shop_full_order_number
|
|
4247
4373
|
});
|
|
4248
|
-
|
|
4374
|
+
_context45.next = 26;
|
|
4249
4375
|
break;
|
|
4250
4376
|
case 23:
|
|
4251
|
-
|
|
4252
|
-
|
|
4377
|
+
_context45.prev = 23;
|
|
4378
|
+
_context45.t0 = _context45["catch"](11);
|
|
4253
4379
|
this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
|
|
4254
|
-
error:
|
|
4380
|
+
error: _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0)
|
|
4255
4381
|
});
|
|
4256
4382
|
case 26:
|
|
4257
|
-
return
|
|
4383
|
+
return _context45.abrupt("return", next);
|
|
4258
4384
|
case 27:
|
|
4259
4385
|
case "end":
|
|
4260
|
-
return
|
|
4386
|
+
return _context45.stop();
|
|
4261
4387
|
}
|
|
4262
|
-
},
|
|
4388
|
+
}, _callee45, this, [[11, 23]]);
|
|
4263
4389
|
}));
|
|
4264
|
-
function ensureCheckoutOrderNumbers(
|
|
4390
|
+
function ensureCheckoutOrderNumbers(_x49, _x50) {
|
|
4265
4391
|
return _ensureCheckoutOrderNumbers.apply(this, arguments);
|
|
4266
4392
|
}
|
|
4267
4393
|
return ensureCheckoutOrderNumbers;
|
|
@@ -4269,27 +4395,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
4269
4395
|
}, {
|
|
4270
4396
|
key: "dispatchCheckoutSyncTask",
|
|
4271
4397
|
value: function () {
|
|
4272
|
-
var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4398
|
+
var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
|
|
4273
4399
|
var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
|
|
4274
|
-
return _regeneratorRuntime().wrap(function
|
|
4275
|
-
while (1) switch (
|
|
4400
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
4401
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4276
4402
|
case 0:
|
|
4277
4403
|
this.registerDeviceTaskActions();
|
|
4278
4404
|
deviceTask = this.getDeviceTaskPlugin();
|
|
4279
|
-
|
|
4405
|
+
_context46.next = 4;
|
|
4280
4406
|
return this.getShortNumberOrDeviceId();
|
|
4281
4407
|
case 4:
|
|
4282
|
-
debugDeviceId =
|
|
4408
|
+
debugDeviceId = _context46.sent;
|
|
4283
4409
|
debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
|
|
4284
4410
|
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
4285
|
-
|
|
4411
|
+
_context46.next = 9;
|
|
4286
4412
|
break;
|
|
4287
4413
|
}
|
|
4288
4414
|
this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
|
|
4289
|
-
return
|
|
4415
|
+
return _context46.abrupt("return");
|
|
4290
4416
|
case 9:
|
|
4291
|
-
|
|
4292
|
-
|
|
4417
|
+
_context46.prev = 9;
|
|
4418
|
+
_context46.next = 12;
|
|
4293
4419
|
return deviceTask.dispatch({
|
|
4294
4420
|
action: 'sync_sales',
|
|
4295
4421
|
device_id: debugDeviceId,
|
|
@@ -4307,27 +4433,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
4307
4433
|
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)
|
|
4308
4434
|
});
|
|
4309
4435
|
case 12:
|
|
4310
|
-
result =
|
|
4436
|
+
result = _context46.sent;
|
|
4311
4437
|
this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
|
|
4312
4438
|
uuid: result === null || result === void 0 ? void 0 : result.uuid,
|
|
4313
4439
|
status: result === null || result === void 0 ? void 0 : result.status,
|
|
4314
4440
|
reused: result === null || result === void 0 ? void 0 : result.reused
|
|
4315
4441
|
});
|
|
4316
|
-
|
|
4442
|
+
_context46.next = 19;
|
|
4317
4443
|
break;
|
|
4318
4444
|
case 16:
|
|
4319
|
-
|
|
4320
|
-
|
|
4445
|
+
_context46.prev = 16;
|
|
4446
|
+
_context46.t0 = _context46["catch"](9);
|
|
4321
4447
|
this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
|
|
4322
|
-
error:
|
|
4448
|
+
error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
|
|
4323
4449
|
});
|
|
4324
4450
|
case 19:
|
|
4325
4451
|
case "end":
|
|
4326
|
-
return
|
|
4452
|
+
return _context46.stop();
|
|
4327
4453
|
}
|
|
4328
|
-
},
|
|
4454
|
+
}, _callee46, this, [[9, 16]]);
|
|
4329
4455
|
}));
|
|
4330
|
-
function dispatchCheckoutSyncTask(
|
|
4456
|
+
function dispatchCheckoutSyncTask(_x51) {
|
|
4331
4457
|
return _dispatchCheckoutSyncTask.apply(this, arguments);
|
|
4332
4458
|
}
|
|
4333
4459
|
return dispatchCheckoutSyncTask;
|
|
@@ -4335,36 +4461,34 @@ var Server = /*#__PURE__*/function () {
|
|
|
4335
4461
|
}, {
|
|
4336
4462
|
key: "dispatchPrintOtherReceiptTask",
|
|
4337
4463
|
value: function () {
|
|
4338
|
-
var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4464
|
+
var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
|
|
4339
4465
|
var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
|
|
4340
|
-
return _regeneratorRuntime().wrap(function
|
|
4341
|
-
while (1) switch (
|
|
4466
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
4467
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4342
4468
|
case 0:
|
|
4343
4469
|
deviceTask = this.getDeviceTaskPlugin();
|
|
4344
4470
|
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
4345
|
-
|
|
4471
|
+
_context47.next = 4;
|
|
4346
4472
|
break;
|
|
4347
4473
|
}
|
|
4348
4474
|
this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
|
|
4349
|
-
return
|
|
4475
|
+
return _context47.abrupt("return");
|
|
4350
4476
|
case 4:
|
|
4351
|
-
|
|
4477
|
+
_context47.prev = 4;
|
|
4352
4478
|
printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
|
|
4353
|
-
|
|
4479
|
+
_context47.next = 8;
|
|
4354
4480
|
return this.getShortNumberOrDeviceId();
|
|
4355
4481
|
case 8:
|
|
4356
|
-
deviceId =
|
|
4357
|
-
|
|
4482
|
+
deviceId = _context47.sent;
|
|
4483
|
+
_context47.next = 11;
|
|
4358
4484
|
return deviceTask.dispatch({
|
|
4359
4485
|
action: 'print_all',
|
|
4360
4486
|
device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
|
|
4361
4487
|
payload: {
|
|
4362
|
-
type: params.
|
|
4488
|
+
type: params.receiptOnly ? '0' : '99',
|
|
4363
4489
|
data: params.receiptOnly ? {
|
|
4364
4490
|
order_id: printIdentity,
|
|
4365
|
-
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
|
|
4366
|
-
skip_wristband: true,
|
|
4367
|
-
skip_voucher: true
|
|
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
|
|
4368
4492
|
} : {
|
|
4369
4493
|
order_id: printIdentity,
|
|
4370
4494
|
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,
|
|
@@ -4375,27 +4499,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
4375
4499
|
idempotency_key: this.buildPrintOtherReceiptIdempotencyKey(params.syncedOrder, {
|
|
4376
4500
|
receiptOnly: params.receiptOnly
|
|
4377
4501
|
}),
|
|
4378
|
-
name: '
|
|
4502
|
+
name: '打印转发',
|
|
4379
4503
|
source: 'server',
|
|
4380
4504
|
source_type: 'order',
|
|
4381
4505
|
source_id: printIdentity
|
|
4382
4506
|
});
|
|
4383
4507
|
case 11:
|
|
4384
|
-
|
|
4508
|
+
_context47.next = 16;
|
|
4385
4509
|
break;
|
|
4386
4510
|
case 13:
|
|
4387
|
-
|
|
4388
|
-
|
|
4511
|
+
_context47.prev = 13;
|
|
4512
|
+
_context47.t0 = _context47["catch"](4);
|
|
4389
4513
|
this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
|
|
4390
|
-
error:
|
|
4514
|
+
error: _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0)
|
|
4391
4515
|
});
|
|
4392
4516
|
case 16:
|
|
4393
4517
|
case "end":
|
|
4394
|
-
return
|
|
4518
|
+
return _context47.stop();
|
|
4395
4519
|
}
|
|
4396
|
-
},
|
|
4520
|
+
}, _callee47, this, [[4, 13]]);
|
|
4397
4521
|
}));
|
|
4398
|
-
function dispatchPrintOtherReceiptTask(
|
|
4522
|
+
function dispatchPrintOtherReceiptTask(_x52) {
|
|
4399
4523
|
return _dispatchPrintOtherReceiptTask.apply(this, arguments);
|
|
4400
4524
|
}
|
|
4401
4525
|
return dispatchPrintOtherReceiptTask;
|
|
@@ -4415,32 +4539,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
4415
4539
|
}, {
|
|
4416
4540
|
key: "dispatchLocalReceiptPrint",
|
|
4417
4541
|
value: function () {
|
|
4418
|
-
var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4542
|
+
var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
|
|
4419
4543
|
var _payment_info;
|
|
4420
4544
|
var printableOrder;
|
|
4421
|
-
return _regeneratorRuntime().wrap(function
|
|
4422
|
-
while (1) switch (
|
|
4545
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
4546
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4423
4547
|
case 0:
|
|
4424
4548
|
if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
|
|
4425
|
-
|
|
4549
|
+
_context48.next = 2;
|
|
4426
4550
|
break;
|
|
4427
4551
|
}
|
|
4428
|
-
return
|
|
4552
|
+
return _context48.abrupt("return", {
|
|
4429
4553
|
printed: false,
|
|
4430
4554
|
order: params.order
|
|
4431
4555
|
});
|
|
4432
4556
|
case 2:
|
|
4433
|
-
|
|
4557
|
+
_context48.next = 4;
|
|
4434
4558
|
return this.withLocalSmallTicketData(params.order, {
|
|
4435
4559
|
requireFullyPaid: params.requireFullyPaid
|
|
4436
4560
|
});
|
|
4437
4561
|
case 4:
|
|
4438
|
-
printableOrder =
|
|
4562
|
+
printableOrder = _context48.sent;
|
|
4439
4563
|
if (hasSmallTicketData((_payment_info = printableOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data)) {
|
|
4440
|
-
|
|
4564
|
+
_context48.next = 7;
|
|
4441
4565
|
break;
|
|
4442
4566
|
}
|
|
4443
|
-
return
|
|
4567
|
+
return _context48.abrupt("return", {
|
|
4444
4568
|
printed: false,
|
|
4445
4569
|
order: printableOrder
|
|
4446
4570
|
});
|
|
@@ -4450,26 +4574,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
4450
4574
|
printableOrder: printableOrder,
|
|
4451
4575
|
response: params.response
|
|
4452
4576
|
});
|
|
4453
|
-
|
|
4577
|
+
_context48.next = 10;
|
|
4454
4578
|
return this.dispatchPrintOtherReceiptTask({
|
|
4455
4579
|
checkoutData: params.checkoutData,
|
|
4456
4580
|
syncedOrder: printableOrder,
|
|
4457
4581
|
response: params.response,
|
|
4458
|
-
receiptOnly: true
|
|
4459
|
-
isManualPrint: params.isManualPrint
|
|
4582
|
+
receiptOnly: true
|
|
4460
4583
|
});
|
|
4461
4584
|
case 10:
|
|
4462
|
-
return
|
|
4585
|
+
return _context48.abrupt("return", {
|
|
4463
4586
|
printed: true,
|
|
4464
4587
|
order: printableOrder
|
|
4465
4588
|
});
|
|
4466
4589
|
case 11:
|
|
4467
4590
|
case "end":
|
|
4468
|
-
return
|
|
4591
|
+
return _context48.stop();
|
|
4469
4592
|
}
|
|
4470
|
-
},
|
|
4593
|
+
}, _callee48, this);
|
|
4471
4594
|
}));
|
|
4472
|
-
function dispatchLocalReceiptPrint(
|
|
4595
|
+
function dispatchLocalReceiptPrint(_x53) {
|
|
4473
4596
|
return _dispatchLocalReceiptPrint.apply(this, arguments);
|
|
4474
4597
|
}
|
|
4475
4598
|
return dispatchLocalReceiptPrint;
|
|
@@ -4493,167 +4616,6 @@ var Server = /*#__PURE__*/function () {
|
|
|
4493
4616
|
}
|
|
4494
4617
|
return undefined;
|
|
4495
4618
|
}
|
|
4496
|
-
}, {
|
|
4497
|
-
key: "resolveMachinecodeBatchMetadataLookup",
|
|
4498
|
-
value: function resolveMachinecodeBatchMetadataLookup(data) {
|
|
4499
|
-
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];
|
|
4500
|
-
return candidates.find(function (candidate) {
|
|
4501
|
-
return candidate !== undefined && candidate !== null && candidate !== '';
|
|
4502
|
-
});
|
|
4503
|
-
}
|
|
4504
|
-
}, {
|
|
4505
|
-
key: "syncMachinecodeBatchMetadataToLocalOrder",
|
|
4506
|
-
value: function () {
|
|
4507
|
-
var _syncMachinecodeBatchMetadataToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(data, batchMetadata) {
|
|
4508
|
-
var _this$order3;
|
|
4509
|
-
var title, lookup, localOrder, metadataByVoucherId, _iterator12, _step12, _item$voucher_id, item, voucherId, vouchers, hasUpdatedVoucher, nextVouchers;
|
|
4510
|
-
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
4511
|
-
while (1) switch (_context48.prev = _context48.next) {
|
|
4512
|
-
case 0:
|
|
4513
|
-
title = 'handleMachinecodeBatchMetadata';
|
|
4514
|
-
lookup = this.resolveMachinecodeBatchMetadataLookup(data);
|
|
4515
|
-
if (!(lookup === undefined)) {
|
|
4516
|
-
_context48.next = 5;
|
|
4517
|
-
break;
|
|
4518
|
-
}
|
|
4519
|
-
this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355 metadata \u66F4\u65B0"), {
|
|
4520
|
-
batchSize: batchMetadata.length
|
|
4521
|
-
});
|
|
4522
|
-
return _context48.abrupt("return");
|
|
4523
|
-
case 5:
|
|
4524
|
-
if ((_this$order3 = this.order) !== null && _this$order3 !== void 0 && _this$order3.getLocalOrderByLookup) {
|
|
4525
|
-
_context48.next = 8;
|
|
4526
|
-
break;
|
|
4527
|
-
}
|
|
4528
|
-
this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355 metadata \u66F4\u65B0"), {
|
|
4529
|
-
lookup: lookup
|
|
4530
|
-
});
|
|
4531
|
-
return _context48.abrupt("return");
|
|
4532
|
-
case 8:
|
|
4533
|
-
_context48.next = 10;
|
|
4534
|
-
return this.order.getLocalOrderByLookup(lookup);
|
|
4535
|
-
case 10:
|
|
4536
|
-
localOrder = _context48.sent;
|
|
4537
|
-
if (localOrder) {
|
|
4538
|
-
_context48.next = 14;
|
|
4539
|
-
break;
|
|
4540
|
-
}
|
|
4541
|
-
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7 metadata \u66F4\u65B0"), {
|
|
4542
|
-
lookup: lookup
|
|
4543
|
-
});
|
|
4544
|
-
return _context48.abrupt("return");
|
|
4545
|
-
case 14:
|
|
4546
|
-
metadataByVoucherId = new Map();
|
|
4547
|
-
_iterator12 = _createForOfIteratorHelper(batchMetadata);
|
|
4548
|
-
_context48.prev = 16;
|
|
4549
|
-
_iterator12.s();
|
|
4550
|
-
case 18:
|
|
4551
|
-
if ((_step12 = _iterator12.n()).done) {
|
|
4552
|
-
_context48.next = 26;
|
|
4553
|
-
break;
|
|
4554
|
-
}
|
|
4555
|
-
item = _step12.value;
|
|
4556
|
-
voucherId = (_item$voucher_id = item === null || item === void 0 ? void 0 : item.voucher_id) !== null && _item$voucher_id !== void 0 ? _item$voucher_id : item === null || item === void 0 ? void 0 : item.voucherId;
|
|
4557
|
-
if (!(voucherId === undefined || voucherId === null || voucherId === '')) {
|
|
4558
|
-
_context48.next = 23;
|
|
4559
|
-
break;
|
|
4560
|
-
}
|
|
4561
|
-
return _context48.abrupt("continue", 24);
|
|
4562
|
-
case 23:
|
|
4563
|
-
metadataByVoucherId.set(String(voucherId), (item === null || item === void 0 ? void 0 : item.metadata) || {});
|
|
4564
|
-
case 24:
|
|
4565
|
-
_context48.next = 18;
|
|
4566
|
-
break;
|
|
4567
|
-
case 26:
|
|
4568
|
-
_context48.next = 31;
|
|
4569
|
-
break;
|
|
4570
|
-
case 28:
|
|
4571
|
-
_context48.prev = 28;
|
|
4572
|
-
_context48.t0 = _context48["catch"](16);
|
|
4573
|
-
_iterator12.e(_context48.t0);
|
|
4574
|
-
case 31:
|
|
4575
|
-
_context48.prev = 31;
|
|
4576
|
-
_iterator12.f();
|
|
4577
|
-
return _context48.finish(31);
|
|
4578
|
-
case 34:
|
|
4579
|
-
if (!(metadataByVoucherId.size === 0)) {
|
|
4580
|
-
_context48.next = 37;
|
|
4581
|
-
break;
|
|
4582
|
-
}
|
|
4583
|
-
this.logWarning("".concat(title, ": voucher metadata \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355 metadata \u66F4\u65B0"), {
|
|
4584
|
-
lookup: lookup
|
|
4585
|
-
});
|
|
4586
|
-
return _context48.abrupt("return");
|
|
4587
|
-
case 37:
|
|
4588
|
-
vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
|
|
4589
|
-
hasUpdatedVoucher = false;
|
|
4590
|
-
nextVouchers = vouchers.map(function (voucher) {
|
|
4591
|
-
var voucherId = voucher === null || voucher === void 0 ? void 0 : voucher.voucher_id;
|
|
4592
|
-
if (voucherId === undefined || voucherId === null) return voucher;
|
|
4593
|
-
var metadata = metadataByVoucherId.get(String(voucherId));
|
|
4594
|
-
if (!metadata) return voucher;
|
|
4595
|
-
hasUpdatedVoucher = true;
|
|
4596
|
-
return _objectSpread(_objectSpread({}, voucher), {}, {
|
|
4597
|
-
metadata: metadata
|
|
4598
|
-
});
|
|
4599
|
-
});
|
|
4600
|
-
if (hasUpdatedVoucher) {
|
|
4601
|
-
_context48.next = 43;
|
|
4602
|
-
break;
|
|
4603
|
-
}
|
|
4604
|
-
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7 metadata \u66F4\u65B0"), {
|
|
4605
|
-
lookup: lookup,
|
|
4606
|
-
voucher_ids: Array.from(metadataByVoucherId.keys())
|
|
4607
|
-
});
|
|
4608
|
-
return _context48.abrupt("return");
|
|
4609
|
-
case 43:
|
|
4610
|
-
if (!(typeof this.order.overwriteExistingOrder === 'function')) {
|
|
4611
|
-
_context48.next = 48;
|
|
4612
|
-
break;
|
|
4613
|
-
}
|
|
4614
|
-
_context48.next = 46;
|
|
4615
|
-
return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
|
|
4616
|
-
vouchers: nextVouchers
|
|
4617
|
-
}));
|
|
4618
|
-
case 46:
|
|
4619
|
-
this.logInfo("".concat(title, ": \u672C\u5730\u8BA2\u5355 vouchers metadata \u5DF2\u66F4\u65B0"), {
|
|
4620
|
-
lookup: lookup,
|
|
4621
|
-
updatedCount: metadataByVoucherId.size
|
|
4622
|
-
});
|
|
4623
|
-
return _context48.abrupt("return");
|
|
4624
|
-
case 48:
|
|
4625
|
-
if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
|
|
4626
|
-
_context48.next = 53;
|
|
4627
|
-
break;
|
|
4628
|
-
}
|
|
4629
|
-
_context48.next = 51;
|
|
4630
|
-
return this.order.markOrderSyncedByExternalSaleNumber({
|
|
4631
|
-
externalSaleNumber: data.external_sale_number,
|
|
4632
|
-
patch: {
|
|
4633
|
-
vouchers: nextVouchers
|
|
4634
|
-
}
|
|
4635
|
-
});
|
|
4636
|
-
case 51:
|
|
4637
|
-
this.logInfo("".concat(title, ": \u672C\u5730\u8BA2\u5355 vouchers metadata \u5DF2\u66F4\u65B0"), {
|
|
4638
|
-
lookup: lookup,
|
|
4639
|
-
updatedCount: metadataByVoucherId.size
|
|
4640
|
-
});
|
|
4641
|
-
return _context48.abrupt("return");
|
|
4642
|
-
case 53:
|
|
4643
|
-
this.logWarning("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8BA2\u5355\u8986\u76D6\uFF0C\u8DF3\u8FC7 metadata \u66F4\u65B0"), {
|
|
4644
|
-
lookup: lookup
|
|
4645
|
-
});
|
|
4646
|
-
case 54:
|
|
4647
|
-
case "end":
|
|
4648
|
-
return _context48.stop();
|
|
4649
|
-
}
|
|
4650
|
-
}, _callee48, this, [[16, 28, 31, 34]]);
|
|
4651
|
-
}));
|
|
4652
|
-
function syncMachinecodeBatchMetadataToLocalOrder(_x52, _x53) {
|
|
4653
|
-
return _syncMachinecodeBatchMetadataToLocalOrder.apply(this, arguments);
|
|
4654
|
-
}
|
|
4655
|
-
return syncMachinecodeBatchMetadataToLocalOrder;
|
|
4656
|
-
}()
|
|
4657
4619
|
}, {
|
|
4658
4620
|
key: "handleOrderCheckoutSubmit",
|
|
4659
4621
|
value: function () {
|
|
@@ -4749,13 +4711,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4749
4711
|
key: "handleSyncCheckoutSubmit",
|
|
4750
4712
|
value: function () {
|
|
4751
4713
|
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
|
|
4752
|
-
var _this$
|
|
4714
|
+
var _this$app15;
|
|
4753
4715
|
var backendPath, data, title, syncResult, _normalized$data, normalized, backendError, _normalized$data2, _normalized, message;
|
|
4754
4716
|
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
4755
4717
|
while (1) switch (_context50.prev = _context50.next) {
|
|
4756
4718
|
case 0:
|
|
4757
4719
|
backendPath = params.backendPath, data = params.data, title = params.title;
|
|
4758
|
-
if ((_this$
|
|
4720
|
+
if ((_this$app15 = this.app) !== null && _this$app15 !== void 0 && (_this$app15 = _this$app15.request) !== null && _this$app15 !== void 0 && _this$app15.post) {
|
|
4759
4721
|
_context50.next = 4;
|
|
4760
4722
|
break;
|
|
4761
4723
|
}
|
|
@@ -4831,7 +4793,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4831
4793
|
key: "handlePendingSyncCheckoutOrder",
|
|
4832
4794
|
value: function () {
|
|
4833
4795
|
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
|
|
4834
|
-
var
|
|
4796
|
+
var _this11 = this;
|
|
4835
4797
|
var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
|
|
4836
4798
|
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
4837
4799
|
while (1) switch (_context51.prev = _context51.next) {
|
|
@@ -4884,7 +4846,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4884
4846
|
});
|
|
4885
4847
|
changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
|
|
4886
4848
|
var _payment$metadata;
|
|
4887
|
-
return sum +
|
|
4849
|
+
return sum + _this11.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
|
|
4888
4850
|
}, 0);
|
|
4889
4851
|
return _context51.abrupt("return", {
|
|
4890
4852
|
code: 200,
|
|
@@ -4973,10 +4935,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
4973
4935
|
}, {
|
|
4974
4936
|
key: "shouldBuildSmallTicketData",
|
|
4975
4937
|
value: function shouldBuildSmallTicketData(order) {
|
|
4976
|
-
var
|
|
4938
|
+
var _order$payment_info, _ref54, _order$small_ticket_d;
|
|
4977
4939
|
if (!order || _typeof(order) !== 'object') return false;
|
|
4978
|
-
|
|
4979
|
-
return Number((
|
|
4940
|
+
if (hasSmallTicketData((_order$payment_info = order.payment_info) === null || _order$payment_info === void 0 ? void 0 : _order$payment_info.small_ticket_data)) return false;
|
|
4941
|
+
return Number((_ref54 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref54 !== void 0 ? _ref54 : 0) === 1;
|
|
4980
4942
|
}
|
|
4981
4943
|
}, {
|
|
4982
4944
|
key: "shouldPrintSyncedOrder",
|
|
@@ -4994,7 +4956,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4994
4956
|
}, {
|
|
4995
4957
|
key: "isSalesOrderFullyPaid",
|
|
4996
4958
|
value: function isSalesOrderFullyPaid(order) {
|
|
4997
|
-
var _order$summary$amount, _order$summary,
|
|
4959
|
+
var _order$summary$amount, _order$summary, _ref55, _ref56, _order$summary$expect, _order$summary2, _order$summary3;
|
|
4998
4960
|
if (!order || _typeof(order) !== 'object') return false;
|
|
4999
4961
|
var paymentStatus = String(order.payment_status || '').toLowerCase();
|
|
5000
4962
|
if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
|
|
@@ -5006,20 +4968,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
5006
4968
|
return this.toAmountNumber(amountGap) <= 0;
|
|
5007
4969
|
}
|
|
5008
4970
|
var paidAmount = this.sumPaidOrderPayments(order.payments);
|
|
5009
|
-
var targetAmount = this.toAmountNumber((
|
|
4971
|
+
var targetAmount = this.toAmountNumber((_ref55 = (_ref56 = (_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 && _ref56 !== void 0 ? _ref56 : order.expect_amount) !== null && _ref55 !== void 0 ? _ref55 : order.total_amount);
|
|
5010
4972
|
if (targetAmount <= 0) return paidAmount > 0;
|
|
5011
4973
|
return paidAmount >= targetAmount;
|
|
5012
4974
|
}
|
|
5013
4975
|
}, {
|
|
5014
4976
|
key: "sumPaidOrderPayments",
|
|
5015
4977
|
value: function sumPaidOrderPayments(payments) {
|
|
5016
|
-
var
|
|
4978
|
+
var _this12 = this;
|
|
5017
4979
|
if (!Array.isArray(payments)) return 0;
|
|
5018
4980
|
return payments.reduce(function (sum, payment) {
|
|
5019
4981
|
var _payment$amount;
|
|
5020
4982
|
var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
|
|
5021
4983
|
if (status === 'voided' || status === 'failed' || status === 'cancelled') return sum;
|
|
5022
|
-
return sum +
|
|
4984
|
+
return sum + _this12.toAmountNumber((_payment$amount = payment === null || payment === void 0 ? void 0 : payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment === null || payment === void 0 ? void 0 : payment.origin_amount);
|
|
5023
4985
|
}, 0);
|
|
5024
4986
|
}
|
|
5025
4987
|
}, {
|
|
@@ -5034,8 +4996,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
5034
4996
|
key: "buildSmallTicketProductMap",
|
|
5035
4997
|
value: function () {
|
|
5036
4998
|
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(order) {
|
|
5037
|
-
var _this$
|
|
5038
|
-
|
|
4999
|
+
var _this$products3,
|
|
5000
|
+
_this13 = this;
|
|
5039
5001
|
var products, productIdSet, productIds, entries;
|
|
5040
5002
|
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5041
5003
|
while (1) switch (_context54.prev = _context54.next) {
|
|
@@ -5050,8 +5012,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
5050
5012
|
}
|
|
5051
5013
|
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
5052
5014
|
product.product_bundle.forEach(function (bundle) {
|
|
5053
|
-
var
|
|
5054
|
-
var bundleProductId = (
|
|
5015
|
+
var _ref57, _bundle$bundle_produc;
|
|
5016
|
+
var bundleProductId = (_ref57 = (_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 && _ref57 !== void 0 ? _ref57 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
|
|
5055
5017
|
if (bundleProductId !== undefined && bundleProductId !== null && bundleProductId !== '') {
|
|
5056
5018
|
productIdSet.add(bundleProductId);
|
|
5057
5019
|
}
|
|
@@ -5059,7 +5021,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5059
5021
|
}
|
|
5060
5022
|
});
|
|
5061
5023
|
productIds = Array.from(productIdSet);
|
|
5062
|
-
if (!(!productIds.length || typeof ((_this$
|
|
5024
|
+
if (!(!productIds.length || typeof ((_this$products3 = this.products) === null || _this$products3 === void 0 ? void 0 : _this$products3.getProductById) !== 'function')) {
|
|
5063
5025
|
_context54.next = 6;
|
|
5064
5026
|
break;
|
|
5065
5027
|
}
|
|
@@ -5067,21 +5029,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
5067
5029
|
case 6:
|
|
5068
5030
|
_context54.next = 8;
|
|
5069
5031
|
return Promise.all(productIds.map( /*#__PURE__*/function () {
|
|
5070
|
-
var
|
|
5071
|
-
var
|
|
5032
|
+
var _ref58 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(id) {
|
|
5033
|
+
var _this13$products, _this13$products$getP, product;
|
|
5072
5034
|
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
5073
5035
|
while (1) switch (_context53.prev = _context53.next) {
|
|
5074
5036
|
case 0:
|
|
5075
5037
|
_context53.prev = 0;
|
|
5076
5038
|
_context53.next = 3;
|
|
5077
|
-
return (
|
|
5039
|
+
return (_this13$products = _this13.products) === null || _this13$products === void 0 || (_this13$products$getP = _this13$products.getProductById) === null || _this13$products$getP === void 0 ? void 0 : _this13$products$getP.call(_this13$products, Number(id));
|
|
5078
5040
|
case 3:
|
|
5079
5041
|
product = _context53.sent;
|
|
5080
5042
|
return _context53.abrupt("return", product ? [String(id), product] : null);
|
|
5081
5043
|
case 7:
|
|
5082
5044
|
_context53.prev = 7;
|
|
5083
5045
|
_context53.t0 = _context53["catch"](0);
|
|
5084
|
-
|
|
5046
|
+
_this13.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
|
|
5085
5047
|
product_id: id,
|
|
5086
5048
|
error: _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0)
|
|
5087
5049
|
});
|
|
@@ -5093,7 +5055,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5093
5055
|
}, _callee53, null, [[0, 7]]);
|
|
5094
5056
|
}));
|
|
5095
5057
|
return function (_x59) {
|
|
5096
|
-
return
|
|
5058
|
+
return _ref58.apply(this, arguments);
|
|
5097
5059
|
};
|
|
5098
5060
|
}()));
|
|
5099
5061
|
case 8:
|
|
@@ -5120,13 +5082,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
5120
5082
|
}, {
|
|
5121
5083
|
key: "withPendingSyncProductTitles",
|
|
5122
5084
|
value: function withPendingSyncProductTitles(order, productMap) {
|
|
5123
|
-
var
|
|
5085
|
+
var _this14 = this;
|
|
5124
5086
|
var products = Array.isArray(order.products) ? order.products : null;
|
|
5125
5087
|
if (!(products !== null && products !== void 0 && products.length)) return order;
|
|
5126
5088
|
return _objectSpread(_objectSpread({}, order), {}, {
|
|
5127
5089
|
products: products.map(function (product) {
|
|
5128
5090
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
5129
|
-
product_title:
|
|
5091
|
+
product_title: _this14.buildProductTitleSnapshot(product, productMap)
|
|
5130
5092
|
});
|
|
5131
5093
|
})
|
|
5132
5094
|
});
|
|
@@ -5137,7 +5099,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5137
5099
|
var _product$product_id2,
|
|
5138
5100
|
_product$product,
|
|
5139
5101
|
_fallbackProduct$prod,
|
|
5140
|
-
|
|
5102
|
+
_this15 = this;
|
|
5141
5103
|
var productId = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product.id;
|
|
5142
5104
|
var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
|
|
5143
5105
|
var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
|
|
@@ -5145,7 +5107,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5145
5107
|
var currentLocale = this.getProductTitleSnapshotCurrentLocale();
|
|
5146
5108
|
var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
|
|
5147
5109
|
return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
|
|
5148
|
-
snapshot[key] =
|
|
5110
|
+
snapshot[key] = _this15.resolveProductTitleValue(ownTitle, key, currentLocale) || _this15.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
|
|
5149
5111
|
return snapshot;
|
|
5150
5112
|
}, {});
|
|
5151
5113
|
}
|
|
@@ -5170,7 +5132,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5170
5132
|
}, {
|
|
5171
5133
|
key: "resolveProductTitleValue",
|
|
5172
5134
|
value: function resolveProductTitleValue(value, key, currentLocale) {
|
|
5173
|
-
var
|
|
5135
|
+
var _ref59, _ref60, _value$key;
|
|
5174
5136
|
if (value === undefined || value === null || value === '') return null;
|
|
5175
5137
|
if (_typeof(value) !== 'object') {
|
|
5176
5138
|
var title = String(value);
|
|
@@ -5180,7 +5142,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5180
5142
|
}
|
|
5181
5143
|
var normalizedKey = key.replace('-', '_');
|
|
5182
5144
|
var dashedKey = key.replace('_', '-');
|
|
5183
|
-
var rawValue = (
|
|
5145
|
+
var rawValue = (_ref59 = (_ref60 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref60 !== void 0 ? _ref60 : value[dashedKey]) !== null && _ref59 !== void 0 ? _ref59 : key === 'auto' ? value.default : undefined;
|
|
5184
5146
|
if (rawValue === undefined || rawValue === null || rawValue === '') return null;
|
|
5185
5147
|
if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
|
|
5186
5148
|
return String(rawValue);
|
|
@@ -5244,14 +5206,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
5244
5206
|
key: "enrichPaymentNamesByCode",
|
|
5245
5207
|
value: function () {
|
|
5246
5208
|
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(order) {
|
|
5247
|
-
var
|
|
5209
|
+
var _this16 = this;
|
|
5248
5210
|
var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator13, _step13, method, codeKey, name, hasResolvedName, enrichedPayments;
|
|
5249
5211
|
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5250
5212
|
while (1) switch (_context55.prev = _context55.next) {
|
|
5251
5213
|
case 0:
|
|
5252
5214
|
payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
|
|
5253
5215
|
hasMissingName = payments.some(function (payment) {
|
|
5254
|
-
return
|
|
5216
|
+
return _this16.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this16.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
|
|
5255
5217
|
});
|
|
5256
5218
|
if (hasMissingName) {
|
|
5257
5219
|
_context55.next = 4;
|
|
@@ -5284,9 +5246,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5284
5246
|
}
|
|
5285
5247
|
hasResolvedName = false;
|
|
5286
5248
|
enrichedPayments = payments.map(function (payment) {
|
|
5287
|
-
if (!
|
|
5288
|
-
if (!
|
|
5289
|
-
var name = nameByCode.get(
|
|
5249
|
+
if (!_this16.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
|
|
5250
|
+
if (!_this16.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
|
|
5251
|
+
var name = nameByCode.get(_this16.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
|
|
5290
5252
|
if (!name) return payment;
|
|
5291
5253
|
hasResolvedName = true;
|
|
5292
5254
|
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
@@ -5445,8 +5407,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
5445
5407
|
key: "handleUpdateLocalOrdersBatch",
|
|
5446
5408
|
value: (function () {
|
|
5447
5409
|
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(orderIds) {
|
|
5448
|
-
var _this$
|
|
5449
|
-
var existedBefore, _iterator14, _step14, id, fetched, message, fetchedMap, _iterator15, _step15, order, oid, freshOrders, succeedIds, failed, _iterator16, _step16, _id, fresh,
|
|
5410
|
+
var _this$app16;
|
|
5411
|
+
var existedBefore, _iterator14, _step14, id, fetched, message, fetchedMap, _iterator15, _step15, order, oid, freshOrders, succeedIds, failed, _iterator16, _step16, _id, fresh, _message, overwritten, inserted;
|
|
5450
5412
|
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5451
5413
|
while (1) switch (_context57.prev = _context57.next) {
|
|
5452
5414
|
case 0:
|
|
@@ -5466,7 +5428,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5466
5428
|
data: null
|
|
5467
5429
|
});
|
|
5468
5430
|
case 4:
|
|
5469
|
-
if ((_this$
|
|
5431
|
+
if ((_this$app16 = this.app) !== null && _this$app16 !== void 0 && _this$app16.request) {
|
|
5470
5432
|
_context57.next = 7;
|
|
5471
5433
|
break;
|
|
5472
5434
|
}
|
|
@@ -5585,14 +5547,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
5585
5547
|
case 53:
|
|
5586
5548
|
_context57.prev = 53;
|
|
5587
5549
|
_context57.t2 = _context57["catch"](48);
|
|
5588
|
-
|
|
5550
|
+
_message = _context57.t2 instanceof Error ? _context57.t2.message : String(_context57.t2);
|
|
5589
5551
|
this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
|
|
5590
|
-
message:
|
|
5552
|
+
message: _message
|
|
5591
5553
|
});
|
|
5592
5554
|
return _context57.abrupt("return", {
|
|
5593
5555
|
code: 500,
|
|
5594
5556
|
status: false,
|
|
5595
|
-
message:
|
|
5557
|
+
message: _message,
|
|
5596
5558
|
data: null
|
|
5597
5559
|
});
|
|
5598
5560
|
case 58:
|
|
@@ -5701,8 +5663,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
5701
5663
|
}, {
|
|
5702
5664
|
key: "extractOrderDataFromCheckoutResponse",
|
|
5703
5665
|
value: function extractOrderDataFromCheckoutResponse(response) {
|
|
5704
|
-
var _response$
|
|
5705
|
-
var candidates = [response === null || response === void 0 || (_response$
|
|
5666
|
+
var _response$data5, _response$data6;
|
|
5667
|
+
var candidates = [response === null || response === void 0 || (_response$data5 = response.data) === null || _response$data5 === void 0 ? void 0 : _response$data5.order, response === null || response === void 0 || (_response$data6 = response.data) === null || _response$data6 === void 0 ? void 0 : _response$data6.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];
|
|
5706
5668
|
for (var _i4 = 0, _candidates = candidates; _i4 < _candidates.length; _i4++) {
|
|
5707
5669
|
var candidate = _candidates[_i4];
|
|
5708
5670
|
if (!candidate || _typeof(candidate) !== 'object') continue;
|
|
@@ -5866,10 +5828,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5866
5828
|
value: function extractBackendErrorResponse(error) {
|
|
5867
5829
|
var _error$response3,
|
|
5868
5830
|
_error$response4,
|
|
5869
|
-
|
|
5831
|
+
_this17 = this;
|
|
5870
5832
|
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];
|
|
5871
5833
|
return candidates.find(function (candidate) {
|
|
5872
|
-
return
|
|
5834
|
+
return _this17.isExplicitBackendErrorResponse(candidate);
|
|
5873
5835
|
}) || null;
|
|
5874
5836
|
}
|
|
5875
5837
|
}, {
|
|
@@ -6224,18 +6186,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
6224
6186
|
value: (function () {
|
|
6225
6187
|
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(context, options) {
|
|
6226
6188
|
var _menu_list_ids$length3,
|
|
6227
|
-
|
|
6228
|
-
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;
|
|
6189
|
+
_this18 = this;
|
|
6190
|
+
var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
|
|
6229
6191
|
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
6230
6192
|
while (1) switch (_context61.prev = _context61.next) {
|
|
6231
6193
|
case 0:
|
|
6232
6194
|
tTotal = performance.now();
|
|
6233
|
-
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;
|
|
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, strategy_context = context.strategy_context;
|
|
6234
6196
|
queryIds = Array.isArray(ids) ? ids.map(function (id) {
|
|
6235
6197
|
return Number(id);
|
|
6236
6198
|
}).filter(function (id) {
|
|
6237
6199
|
return Number.isFinite(id);
|
|
6238
6200
|
}) : [];
|
|
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
|
+
});
|
|
6239
6207
|
this.logInfo('computeProductQueryResult 开始', {
|
|
6240
6208
|
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,
|
|
6241
6209
|
ids: queryIds,
|
|
@@ -6244,37 +6212,31 @@ var Server = /*#__PURE__*/function () {
|
|
|
6244
6212
|
customer_id: customer_id,
|
|
6245
6213
|
extension_type: extension_type,
|
|
6246
6214
|
product_id: product_id,
|
|
6215
|
+
strategyContextKeys: strategy_context ? Object.keys(strategy_context) : [],
|
|
6247
6216
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6248
6217
|
});
|
|
6249
6218
|
if (this.products) {
|
|
6250
|
-
_context61.next =
|
|
6219
|
+
_context61.next = 8;
|
|
6251
6220
|
break;
|
|
6252
6221
|
}
|
|
6253
6222
|
this.logError('computeProductQueryResult: Products 模块未注册');
|
|
6254
6223
|
return _context61.abrupt("return", {
|
|
6255
6224
|
message: 'Products 模块未注册',
|
|
6256
|
-
data:
|
|
6257
|
-
list: [],
|
|
6258
|
-
count: 0
|
|
6259
|
-
}
|
|
6225
|
+
data: this.buildProductQueryResultPayload([], 0)
|
|
6260
6226
|
});
|
|
6261
|
-
case
|
|
6227
|
+
case 8:
|
|
6262
6228
|
if (!(queryIds.length > 0)) {
|
|
6263
|
-
_context61.next =
|
|
6229
|
+
_context61.next = 20;
|
|
6264
6230
|
break;
|
|
6265
6231
|
}
|
|
6266
6232
|
uniqueIds = Array.from(new Set(queryIds));
|
|
6267
6233
|
_tPrice = performance.now();
|
|
6268
|
-
_context61.next =
|
|
6269
|
-
return this.products.getProductsWithPrice(schedule_date, {
|
|
6270
|
-
scheduleModule: this.getSchedule(),
|
|
6271
|
-
schedule_datetime: schedule_datetime,
|
|
6272
|
-
customer_id: customer_id
|
|
6273
|
-
}, {
|
|
6234
|
+
_context61.next = 13;
|
|
6235
|
+
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
6274
6236
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
6275
6237
|
productIds: uniqueIds
|
|
6276
6238
|
});
|
|
6277
|
-
case
|
|
6239
|
+
case 13:
|
|
6278
6240
|
productsWithPrice = _context61.sent;
|
|
6279
6241
|
perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
|
|
6280
6242
|
count: productsWithPrice.length,
|
|
@@ -6297,27 +6259,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
6297
6259
|
});
|
|
6298
6260
|
return _context61.abrupt("return", {
|
|
6299
6261
|
code: 200,
|
|
6300
|
-
data:
|
|
6301
|
-
list: extensionFilteredProducts,
|
|
6302
|
-
count: extensionFilteredProducts.length
|
|
6303
|
-
},
|
|
6262
|
+
data: this.buildProductQueryResultPayload(extensionFilteredProducts),
|
|
6304
6263
|
message: '',
|
|
6305
6264
|
status: true
|
|
6306
6265
|
});
|
|
6307
|
-
case
|
|
6266
|
+
case 20:
|
|
6308
6267
|
if (!(product_id != null && Number.isFinite(Number(product_id)))) {
|
|
6309
|
-
_context61.next =
|
|
6268
|
+
_context61.next = 32;
|
|
6310
6269
|
break;
|
|
6311
6270
|
}
|
|
6312
6271
|
pid = Number(product_id);
|
|
6313
6272
|
_tPrice2 = performance.now();
|
|
6314
|
-
_context61.next =
|
|
6315
|
-
return this.products.getProductsWithPrice(schedule_date, {
|
|
6316
|
-
scheduleModule: this.getSchedule()
|
|
6317
|
-
}, {
|
|
6273
|
+
_context61.next = 25;
|
|
6274
|
+
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
6318
6275
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6319
6276
|
});
|
|
6320
|
-
case
|
|
6277
|
+
case 25:
|
|
6321
6278
|
allProductsWithPrice = _context61.sent;
|
|
6322
6279
|
perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
|
|
6323
6280
|
count: allProductsWithPrice.length,
|
|
@@ -6344,21 +6301,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
6344
6301
|
message: item ? '' : '商品不存在或未发布',
|
|
6345
6302
|
status: true
|
|
6346
6303
|
});
|
|
6347
|
-
case
|
|
6304
|
+
case 32:
|
|
6348
6305
|
if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
|
|
6349
|
-
_context61.next =
|
|
6306
|
+
_context61.next = 52;
|
|
6350
6307
|
break;
|
|
6351
6308
|
}
|
|
6352
6309
|
_tPrice3 = performance.now();
|
|
6353
|
-
_context61.next =
|
|
6354
|
-
return this.products.getProductsWithPrice(schedule_date, {
|
|
6355
|
-
scheduleModule: this.getSchedule(),
|
|
6356
|
-
schedule_datetime: schedule_datetime,
|
|
6357
|
-
customer_id: customer_id
|
|
6358
|
-
}, {
|
|
6310
|
+
_context61.next = 36;
|
|
6311
|
+
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
6359
6312
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6360
6313
|
});
|
|
6361
|
-
case
|
|
6314
|
+
case 36:
|
|
6362
6315
|
_filteredProducts2 = _context61.sent;
|
|
6363
6316
|
perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
|
|
6364
6317
|
count: _filteredProducts2.length,
|
|
@@ -6400,47 +6353,38 @@ var Server = /*#__PURE__*/function () {
|
|
|
6400
6353
|
});
|
|
6401
6354
|
return _context61.abrupt("return", {
|
|
6402
6355
|
code: 200,
|
|
6403
|
-
data:
|
|
6404
|
-
list: _filteredProducts2,
|
|
6405
|
-
count: _filteredProducts2.length
|
|
6406
|
-
},
|
|
6356
|
+
data: this.buildProductQueryResultPayload(_filteredProducts2),
|
|
6407
6357
|
message: '',
|
|
6408
6358
|
status: true
|
|
6409
6359
|
});
|
|
6410
|
-
case
|
|
6360
|
+
case 52:
|
|
6411
6361
|
if (this.menu) {
|
|
6412
|
-
_context61.next =
|
|
6362
|
+
_context61.next = 55;
|
|
6413
6363
|
break;
|
|
6414
6364
|
}
|
|
6415
6365
|
this.logError('computeProductQueryResult: Menu 模块未注册');
|
|
6416
6366
|
return _context61.abrupt("return", {
|
|
6417
6367
|
message: 'Menu 模块未注册',
|
|
6418
|
-
data:
|
|
6419
|
-
list: [],
|
|
6420
|
-
count: 0
|
|
6421
|
-
}
|
|
6368
|
+
data: this.buildProductQueryResultPayload([], 0)
|
|
6422
6369
|
});
|
|
6423
|
-
case
|
|
6370
|
+
case 55:
|
|
6424
6371
|
if (this.schedule) {
|
|
6425
|
-
_context61.next =
|
|
6372
|
+
_context61.next = 58;
|
|
6426
6373
|
break;
|
|
6427
6374
|
}
|
|
6428
6375
|
this.logError('computeProductQueryResult: Schedule 模块未注册');
|
|
6429
6376
|
return _context61.abrupt("return", {
|
|
6430
6377
|
message: 'Schedule 模块未注册',
|
|
6431
|
-
data:
|
|
6432
|
-
list: [],
|
|
6433
|
-
count: 0
|
|
6434
|
-
}
|
|
6378
|
+
data: this.buildProductQueryResultPayload([], 0)
|
|
6435
6379
|
});
|
|
6436
|
-
case
|
|
6380
|
+
case 58:
|
|
6437
6381
|
activeMenuList = [];
|
|
6438
6382
|
if (menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0) {
|
|
6439
6383
|
tMenu = performance.now();
|
|
6440
6384
|
menuList = this.menu.getMenuByIds(menu_list_ids);
|
|
6441
6385
|
activeMenuList = menuList.filter(function (menu) {
|
|
6442
|
-
var
|
|
6443
|
-
return ((
|
|
6386
|
+
var _this18$schedule;
|
|
6387
|
+
return ((_this18$schedule = _this18.schedule) === null || _this18$schedule === void 0 ? void 0 : _this18$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
|
|
6444
6388
|
});
|
|
6445
6389
|
perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
|
|
6446
6390
|
totalMenu: menuList.length,
|
|
@@ -6457,25 +6401,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
6457
6401
|
});
|
|
6458
6402
|
tPrice = performance.now();
|
|
6459
6403
|
if (!(scopedProductIds.length > 0)) {
|
|
6460
|
-
_context61.next =
|
|
6404
|
+
_context61.next = 71;
|
|
6461
6405
|
break;
|
|
6462
6406
|
}
|
|
6463
|
-
_context61.next =
|
|
6464
|
-
return this.products.getProductsWithPrice(schedule_date, {
|
|
6465
|
-
scheduleModule: this.getSchedule(),
|
|
6466
|
-
schedule_datetime: schedule_datetime,
|
|
6467
|
-
customer_id: customer_id
|
|
6468
|
-
}, {
|
|
6407
|
+
_context61.next = 68;
|
|
6408
|
+
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
6469
6409
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
6470
6410
|
productIds: productScope.isAllProducts ? undefined : scopedProductIds
|
|
6471
6411
|
});
|
|
6472
|
-
case
|
|
6412
|
+
case 68:
|
|
6473
6413
|
_context61.t0 = _context61.sent;
|
|
6474
|
-
_context61.next =
|
|
6414
|
+
_context61.next = 72;
|
|
6475
6415
|
break;
|
|
6476
|
-
case 70:
|
|
6477
|
-
_context61.t0 = [];
|
|
6478
6416
|
case 71:
|
|
6417
|
+
_context61.t0 = [];
|
|
6418
|
+
case 72:
|
|
6479
6419
|
filteredProducts = _context61.t0;
|
|
6480
6420
|
perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
|
|
6481
6421
|
count: filteredProducts.length,
|
|
@@ -6519,14 +6459,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6519
6459
|
});
|
|
6520
6460
|
return _context61.abrupt("return", {
|
|
6521
6461
|
code: 200,
|
|
6522
|
-
data:
|
|
6523
|
-
list: filteredProducts,
|
|
6524
|
-
count: filteredProducts.length
|
|
6525
|
-
},
|
|
6462
|
+
data: this.buildProductQueryResultPayload(filteredProducts),
|
|
6526
6463
|
message: '',
|
|
6527
6464
|
status: true
|
|
6528
6465
|
});
|
|
6529
|
-
case
|
|
6466
|
+
case 88:
|
|
6530
6467
|
case "end":
|
|
6531
6468
|
return _context61.stop();
|
|
6532
6469
|
}
|
|
@@ -6537,13 +6474,34 @@ var Server = /*#__PURE__*/function () {
|
|
|
6537
6474
|
}
|
|
6538
6475
|
return computeProductQueryResult;
|
|
6539
6476
|
}()
|
|
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
|
+
|
|
6540
6499
|
/**
|
|
6541
6500
|
* 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
|
|
6542
6501
|
* 由 ProductsModule 的 onProductsSyncCompleted 事件触发
|
|
6543
6502
|
* @param options 可选参数
|
|
6544
6503
|
* @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
|
|
6545
6504
|
*/
|
|
6546
|
-
)
|
|
6547
6505
|
}, {
|
|
6548
6506
|
key: "recomputeAndNotifyProductQuery",
|
|
6549
6507
|
value: (function () {
|
|
@@ -6717,7 +6675,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6717
6675
|
}, {
|
|
6718
6676
|
key: "notifySalesSearchSubscribers",
|
|
6719
6677
|
value: function notifySalesSearchSubscribers(payload) {
|
|
6720
|
-
var
|
|
6678
|
+
var _this19 = this;
|
|
6721
6679
|
if (this.salesSearchSubscribers.size === 0) return;
|
|
6722
6680
|
var changedOrders = this.extractChangedOrdersFromPayload(payload);
|
|
6723
6681
|
if (changedOrders.length === 0) {
|
|
@@ -6729,34 +6687,34 @@ var Server = /*#__PURE__*/function () {
|
|
|
6729
6687
|
var _iterator21 = _createForOfIteratorHelper(this.salesSearchSubscribers.entries()),
|
|
6730
6688
|
_step21;
|
|
6731
6689
|
try {
|
|
6732
|
-
var
|
|
6690
|
+
var _loop2 = function _loop2() {
|
|
6733
6691
|
var _step21$value = _slicedToArray(_step21.value, 2),
|
|
6734
6692
|
subscriberId = _step21$value[0],
|
|
6735
6693
|
subscriber = _step21$value[1];
|
|
6736
6694
|
try {
|
|
6737
6695
|
var changedVisibleOrders = changedOrders.filter(function (order) {
|
|
6738
|
-
var orderId =
|
|
6696
|
+
var orderId = _this19.getSalesSearchOrderId(order);
|
|
6739
6697
|
return !!orderId && subscriber.visibleOrderIds.has(orderId);
|
|
6740
6698
|
});
|
|
6741
6699
|
if (changedVisibleOrders.length === 0) {
|
|
6742
6700
|
return 1; // continue
|
|
6743
6701
|
}
|
|
6744
|
-
subscriber.callback(
|
|
6745
|
-
|
|
6702
|
+
subscriber.callback(_this19.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
|
|
6703
|
+
_this19.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
|
|
6746
6704
|
subscriberId: subscriberId,
|
|
6747
6705
|
kind: subscriber.kind,
|
|
6748
6706
|
count: changedVisibleOrders.length
|
|
6749
6707
|
});
|
|
6750
6708
|
} catch (error) {
|
|
6751
6709
|
var errorMessage = error instanceof Error ? error.message : String(error);
|
|
6752
|
-
|
|
6710
|
+
_this19.logError('notifySalesSearchSubscribers: 推送失败', {
|
|
6753
6711
|
subscriberId: subscriberId,
|
|
6754
6712
|
error: errorMessage
|
|
6755
6713
|
});
|
|
6756
6714
|
}
|
|
6757
6715
|
};
|
|
6758
6716
|
for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
|
|
6759
|
-
if (
|
|
6717
|
+
if (_loop2()) continue;
|
|
6760
6718
|
}
|
|
6761
6719
|
} catch (err) {
|
|
6762
6720
|
_iterator21.e(err);
|