@pisell/pisellos 2.2.260 → 2.2.262
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +1 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +15 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +25 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +1 -6
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +2 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +23 -13
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
- package/dist/modules/Discount/index.d.ts +5 -2
- package/dist/modules/Discount/index.js +30 -7
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +45 -2
- package/dist/modules/Order/index.js +1552 -926
- package/dist/modules/Order/types.d.ts +36 -2
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
- package/dist/modules/Order/utils.d.ts +8 -3
- package/dist/modules/Order/utils.js +136 -56
- package/dist/modules/Rules/index.d.ts +4 -10
- package/dist/modules/Rules/index.js +63 -12
- package/dist/modules/Rules/types.d.ts +12 -2
- package/dist/modules/SalesSummary/index.d.ts +7 -3
- package/dist/modules/SalesSummary/index.js +67 -39
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +2 -1
- package/dist/modules/SurchargeList/index.d.ts +6 -4
- package/dist/modules/SurchargeList/index.js +62 -39
- package/dist/modules/SurchargeList/types.d.ts +6 -2
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.js +1365 -911
- package/dist/server/modules/order/index.d.ts +32 -7
- package/dist/server/modules/order/index.js +551 -464
- package/dist/server/modules/order/types.d.ts +4 -0
- package/dist/server/modules/products/index.d.ts +5 -1
- package/dist/server/modules/products/index.js +384 -315
- package/dist/server/modules/products/types.d.ts +4 -0
- package/dist/solution/BaseSales/index.d.ts +42 -2
- package/dist/solution/BaseSales/index.js +1416 -775
- package/dist/solution/BaseSales/types.d.ts +7 -1
- package/dist/solution/BaseSales/types.js +3 -2
- package/dist/solution/BaseSales/utils/cartPromotion.js +19 -7
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +20 -4
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +8 -0
- package/dist/solution/BookingTicket/index.js +212 -31
- package/dist/solution/ShopDiscount/index.js +15 -14
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +1 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +10 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +20 -1
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -2
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +2 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
- package/lib/modules/Discount/index.d.ts +5 -2
- package/lib/modules/Discount/index.js +23 -3
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +45 -2
- package/lib/modules/Order/index.js +720 -116
- package/lib/modules/Order/types.d.ts +36 -2
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
- package/lib/modules/Order/utils.d.ts +8 -3
- package/lib/modules/Order/utils.js +104 -18
- package/lib/modules/Rules/index.d.ts +4 -10
- package/lib/modules/Rules/index.js +61 -9
- package/lib/modules/Rules/types.d.ts +12 -2
- package/lib/modules/SalesSummary/index.d.ts +7 -3
- package/lib/modules/SalesSummary/index.js +28 -11
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +2 -0
- package/lib/modules/SurchargeList/index.d.ts +6 -4
- package/lib/modules/SurchargeList/index.js +41 -21
- package/lib/modules/SurchargeList/types.d.ts +6 -2
- package/lib/server/index.d.ts +8 -0
- package/lib/server/index.js +336 -11
- package/lib/server/modules/order/index.d.ts +32 -7
- package/lib/server/modules/order/index.js +298 -189
- package/lib/server/modules/order/types.d.ts +4 -0
- package/lib/server/modules/products/index.d.ts +5 -1
- package/lib/server/modules/products/index.js +21 -0
- package/lib/server/modules/products/types.d.ts +4 -0
- package/lib/solution/BaseSales/index.d.ts +42 -2
- package/lib/solution/BaseSales/index.js +535 -108
- package/lib/solution/BaseSales/types.d.ts +7 -1
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +13 -1
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +8 -0
- package/lib/solution/BookingTicket/index.js +134 -8
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -62,7 +62,7 @@ var PRODUCT_TITLE_SNAPSHOT_KEYS = ['en', 'ja', 'pt', 'auto', 'zh-CN', 'zh-HK', '
|
|
|
62
62
|
var Server = /*#__PURE__*/function () {
|
|
63
63
|
function Server(core) {
|
|
64
64
|
var _this = this,
|
|
65
|
-
_this$
|
|
65
|
+
_this$app4;
|
|
66
66
|
_classCallCheck(this, Server);
|
|
67
67
|
_defineProperty(this, "core", void 0);
|
|
68
68
|
_defineProperty(this, "app", void 0);
|
|
@@ -1041,7 +1041,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
1041
1041
|
checkoutData: checkoutData,
|
|
1042
1042
|
order: printableOrder,
|
|
1043
1043
|
response: null,
|
|
1044
|
-
requireFullyPaid: false
|
|
1044
|
+
requireFullyPaid: false,
|
|
1045
|
+
isManualPrint: true
|
|
1045
1046
|
});
|
|
1046
1047
|
case 27:
|
|
1047
1048
|
printResult = _context16.sent;
|
|
@@ -1080,14 +1081,143 @@ var Server = /*#__PURE__*/function () {
|
|
|
1080
1081
|
return _ref39.apply(this, arguments);
|
|
1081
1082
|
};
|
|
1082
1083
|
}());
|
|
1083
|
-
_defineProperty(this, "
|
|
1084
|
+
_defineProperty(this, "handleMachinecodeBatchMeta", /*#__PURE__*/function () {
|
|
1084
1085
|
var _ref43 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref42) {
|
|
1085
|
-
var _this$app2;
|
|
1086
|
-
var
|
|
1086
|
+
var _this$resolveMachinec, _this$app2;
|
|
1087
|
+
var data, title, backendPath, ids, status, message, _response$code, _response$status, _response$message, _response$data2, response, backendError, _backendError$code, _backendError$status, _backendError$message, _backendError$data, _message;
|
|
1087
1088
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1088
1089
|
while (1) switch (_context17.prev = _context17.next) {
|
|
1089
1090
|
case 0:
|
|
1090
|
-
|
|
1091
|
+
data = _ref42.data;
|
|
1092
|
+
title = 'handleMachinecodeBatchMeta';
|
|
1093
|
+
backendPath = '/shop/machinecode/batch';
|
|
1094
|
+
ids = Array.isArray(data === null || data === void 0 ? void 0 : data.ids) ? data.ids : [];
|
|
1095
|
+
status = data === null || data === void 0 ? void 0 : data.status;
|
|
1096
|
+
_this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
|
|
1097
|
+
backendPath: backendPath,
|
|
1098
|
+
batchSize: ids.length,
|
|
1099
|
+
status: status,
|
|
1100
|
+
order_lookup: (_this$resolveMachinec = _this.resolveMachinecodeBatchMetadataLookup(data)) !== null && _this$resolveMachinec !== void 0 ? _this$resolveMachinec : null
|
|
1101
|
+
});
|
|
1102
|
+
if (!(ids.length === 0)) {
|
|
1103
|
+
_context17.next = 8;
|
|
1104
|
+
break;
|
|
1105
|
+
}
|
|
1106
|
+
return _context17.abrupt("return", {
|
|
1107
|
+
code: 200,
|
|
1108
|
+
status: true,
|
|
1109
|
+
message: '',
|
|
1110
|
+
data: []
|
|
1111
|
+
});
|
|
1112
|
+
case 8:
|
|
1113
|
+
if (!(status !== 'used' && status !== 'unused')) {
|
|
1114
|
+
_context17.next = 10;
|
|
1115
|
+
break;
|
|
1116
|
+
}
|
|
1117
|
+
return _context17.abrupt("return", {
|
|
1118
|
+
code: 400,
|
|
1119
|
+
status: false,
|
|
1120
|
+
message: '无效的核销状态',
|
|
1121
|
+
data: null
|
|
1122
|
+
});
|
|
1123
|
+
case 10:
|
|
1124
|
+
_context17.prev = 10;
|
|
1125
|
+
_context17.next = 13;
|
|
1126
|
+
return _this.syncMachinecodeRedeemStatusToLocalOrder(data, ids, status);
|
|
1127
|
+
case 13:
|
|
1128
|
+
_context17.next = 20;
|
|
1129
|
+
break;
|
|
1130
|
+
case 15:
|
|
1131
|
+
_context17.prev = 15;
|
|
1132
|
+
_context17.t0 = _context17["catch"](10);
|
|
1133
|
+
message = _this.getUnknownErrorMessage(_context17.t0);
|
|
1134
|
+
_this.logError("".concat(title, ": \u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0\u5931\u8D25"), {
|
|
1135
|
+
error: message,
|
|
1136
|
+
error_detail: _this.normalizeUnknownError(_context17.t0)
|
|
1137
|
+
});
|
|
1138
|
+
return _context17.abrupt("return", {
|
|
1139
|
+
code: 500,
|
|
1140
|
+
status: false,
|
|
1141
|
+
message: message,
|
|
1142
|
+
data: null
|
|
1143
|
+
});
|
|
1144
|
+
case 20:
|
|
1145
|
+
if ((_this$app2 = _this.app) !== null && _this$app2 !== void 0 && (_this$app2 = _this$app2.request) !== null && _this$app2 !== void 0 && _this$app2.post) {
|
|
1146
|
+
_context17.next = 23;
|
|
1147
|
+
break;
|
|
1148
|
+
}
|
|
1149
|
+
_this.logError("".concat(title, ": app.request \u4E0D\u53EF\u7528"), {
|
|
1150
|
+
backendPath: backendPath
|
|
1151
|
+
});
|
|
1152
|
+
return _context17.abrupt("return", {
|
|
1153
|
+
code: 500,
|
|
1154
|
+
status: false,
|
|
1155
|
+
message: 'app.request 不可用',
|
|
1156
|
+
data: null
|
|
1157
|
+
});
|
|
1158
|
+
case 23:
|
|
1159
|
+
_context17.prev = 23;
|
|
1160
|
+
_context17.next = 26;
|
|
1161
|
+
return _this.app.request.post(backendPath, {
|
|
1162
|
+
ids: ids,
|
|
1163
|
+
status: status
|
|
1164
|
+
}, {
|
|
1165
|
+
isShopApi: true,
|
|
1166
|
+
customToast: function customToast() {}
|
|
1167
|
+
});
|
|
1168
|
+
case 26:
|
|
1169
|
+
response = _context17.sent;
|
|
1170
|
+
return _context17.abrupt("return", {
|
|
1171
|
+
code: (_response$code = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code !== void 0 ? _response$code : 200,
|
|
1172
|
+
status: (_response$status = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status !== void 0 ? _response$status : true,
|
|
1173
|
+
message: (_response$message = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message !== void 0 ? _response$message : '',
|
|
1174
|
+
data: (_response$data2 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data2 !== void 0 ? _response$data2 : response
|
|
1175
|
+
});
|
|
1176
|
+
case 30:
|
|
1177
|
+
_context17.prev = 30;
|
|
1178
|
+
_context17.t1 = _context17["catch"](23);
|
|
1179
|
+
backendError = _this.extractBackendErrorResponse(_context17.t1);
|
|
1180
|
+
if (!backendError) {
|
|
1181
|
+
_context17.next = 35;
|
|
1182
|
+
break;
|
|
1183
|
+
}
|
|
1184
|
+
return _context17.abrupt("return", {
|
|
1185
|
+
code: (_backendError$code = backendError.code) !== null && _backendError$code !== void 0 ? _backendError$code : 500,
|
|
1186
|
+
status: (_backendError$status = backendError.status) !== null && _backendError$status !== void 0 ? _backendError$status : false,
|
|
1187
|
+
message: (_backendError$message = backendError.message) !== null && _backendError$message !== void 0 ? _backendError$message : '后端拒绝 batch-metadata',
|
|
1188
|
+
data: (_backendError$data = backendError.data) !== null && _backendError$data !== void 0 ? _backendError$data : null
|
|
1189
|
+
});
|
|
1190
|
+
case 35:
|
|
1191
|
+
_message = _this.getUnknownErrorMessage(_context17.t1);
|
|
1192
|
+
_this.logError("".concat(title, ": \u8BF7\u6C42\u5931\u8D25"), {
|
|
1193
|
+
backendPath: backendPath,
|
|
1194
|
+
error: _message,
|
|
1195
|
+
error_detail: _this.normalizeUnknownError(_context17.t1)
|
|
1196
|
+
});
|
|
1197
|
+
return _context17.abrupt("return", {
|
|
1198
|
+
code: 500,
|
|
1199
|
+
status: false,
|
|
1200
|
+
message: _message,
|
|
1201
|
+
data: null
|
|
1202
|
+
});
|
|
1203
|
+
case 38:
|
|
1204
|
+
case "end":
|
|
1205
|
+
return _context17.stop();
|
|
1206
|
+
}
|
|
1207
|
+
}, _callee17, null, [[10, 15], [23, 30]]);
|
|
1208
|
+
}));
|
|
1209
|
+
return function (_x17) {
|
|
1210
|
+
return _ref43.apply(this, arguments);
|
|
1211
|
+
};
|
|
1212
|
+
}());
|
|
1213
|
+
_defineProperty(this, "handleOrderSalesDetail", /*#__PURE__*/function () {
|
|
1214
|
+
var _ref45 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_ref44) {
|
|
1215
|
+
var _this$app3;
|
|
1216
|
+
var url, data, path, requestPath, lookup, localOrder, enrichedOrder, backendPath, _response$data3, response, fresh, savedOrder, _enrichedOrder, errorMessage;
|
|
1217
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1218
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1219
|
+
case 0:
|
|
1220
|
+
url = _ref44.url, data = _ref44.data, path = _ref44.path;
|
|
1091
1221
|
requestPath = _this.parseRequestPath(url, path);
|
|
1092
1222
|
lookup = _this.extractOrderSalesDetailLookup(requestPath);
|
|
1093
1223
|
_this.logInfo('handleOrderSalesDetail: 开始处理', {
|
|
@@ -1096,14 +1226,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1096
1226
|
lookup: lookup
|
|
1097
1227
|
});
|
|
1098
1228
|
if (lookup) {
|
|
1099
|
-
|
|
1229
|
+
_context18.next = 7;
|
|
1100
1230
|
break;
|
|
1101
1231
|
}
|
|
1102
1232
|
_this.logWarning('handleOrderSalesDetail: lookup 缺失', {
|
|
1103
1233
|
url: url,
|
|
1104
1234
|
path: requestPath
|
|
1105
1235
|
});
|
|
1106
|
-
return
|
|
1236
|
+
return _context18.abrupt("return", {
|
|
1107
1237
|
code: 400,
|
|
1108
1238
|
status: false,
|
|
1109
1239
|
message: '订单 lookup 缺失',
|
|
@@ -1111,11 +1241,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
1111
1241
|
});
|
|
1112
1242
|
case 7:
|
|
1113
1243
|
if (_this.order) {
|
|
1114
|
-
|
|
1244
|
+
_context18.next = 10;
|
|
1115
1245
|
break;
|
|
1116
1246
|
}
|
|
1117
1247
|
_this.logError('handleOrderSalesDetail: Order 模块未注册');
|
|
1118
|
-
return
|
|
1248
|
+
return _context18.abrupt("return", {
|
|
1119
1249
|
code: 500,
|
|
1120
1250
|
status: false,
|
|
1121
1251
|
message: 'Order 模块未注册',
|
|
@@ -1123,135 +1253,143 @@ var Server = /*#__PURE__*/function () {
|
|
|
1123
1253
|
});
|
|
1124
1254
|
case 10:
|
|
1125
1255
|
if (_this.shouldForceRemoteSalesDetail(data)) {
|
|
1126
|
-
|
|
1256
|
+
_context18.next = 20;
|
|
1127
1257
|
break;
|
|
1128
1258
|
}
|
|
1129
|
-
|
|
1259
|
+
_context18.next = 13;
|
|
1130
1260
|
return _this.order.getLocalOrderByLookup(lookup);
|
|
1131
1261
|
case 13:
|
|
1132
|
-
localOrder =
|
|
1262
|
+
localOrder = _context18.sent;
|
|
1133
1263
|
if (!localOrder) {
|
|
1134
|
-
|
|
1264
|
+
_context18.next = 20;
|
|
1135
1265
|
break;
|
|
1136
1266
|
}
|
|
1267
|
+
_context18.next = 17;
|
|
1268
|
+
return _this.withSalesDetailProductSnapshots(localOrder);
|
|
1269
|
+
case 17:
|
|
1270
|
+
enrichedOrder = _context18.sent;
|
|
1137
1271
|
_this.logInfo('handleOrderSalesDetail: 命中本地订单', {
|
|
1138
1272
|
lookup: lookup
|
|
1139
1273
|
});
|
|
1140
|
-
return
|
|
1274
|
+
return _context18.abrupt("return", {
|
|
1141
1275
|
code: 200,
|
|
1142
1276
|
status: true,
|
|
1143
1277
|
message: '',
|
|
1144
|
-
data:
|
|
1278
|
+
data: enrichedOrder
|
|
1145
1279
|
});
|
|
1146
|
-
case
|
|
1147
|
-
if ((_this$
|
|
1148
|
-
|
|
1280
|
+
case 20:
|
|
1281
|
+
if ((_this$app3 = _this.app) !== null && _this$app3 !== void 0 && _this$app3.request) {
|
|
1282
|
+
_context18.next = 23;
|
|
1149
1283
|
break;
|
|
1150
1284
|
}
|
|
1151
1285
|
_this.logError('handleOrderSalesDetail: app.request 不可用');
|
|
1152
|
-
return
|
|
1286
|
+
return _context18.abrupt("return", {
|
|
1153
1287
|
code: 500,
|
|
1154
1288
|
status: false,
|
|
1155
1289
|
message: 'app.request 不可用',
|
|
1156
1290
|
data: null
|
|
1157
1291
|
});
|
|
1158
|
-
case
|
|
1292
|
+
case 23:
|
|
1159
1293
|
backendPath = _this.buildOrderSalesDetailBackendPath(lookup, data);
|
|
1160
|
-
|
|
1161
|
-
|
|
1294
|
+
_context18.prev = 24;
|
|
1295
|
+
_context18.next = 27;
|
|
1162
1296
|
return _this.app.request.get(backendPath, {
|
|
1163
1297
|
lookup_mode: 'multi'
|
|
1164
1298
|
}, {
|
|
1165
1299
|
isShopApi: true,
|
|
1166
1300
|
customToast: function customToast() {}
|
|
1167
1301
|
});
|
|
1168
|
-
case
|
|
1169
|
-
response =
|
|
1170
|
-
fresh = (_response$
|
|
1302
|
+
case 27:
|
|
1303
|
+
response = _context18.sent;
|
|
1304
|
+
fresh = (_response$data3 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data3 !== void 0 ? _response$data3 : response;
|
|
1171
1305
|
if (!(!fresh || _typeof(fresh) !== 'object' || fresh.order_id == null)) {
|
|
1172
|
-
|
|
1306
|
+
_context18.next = 32;
|
|
1173
1307
|
break;
|
|
1174
1308
|
}
|
|
1175
1309
|
_this.logInfo('handleOrderSalesDetail: 后端返回订单为空', {
|
|
1176
1310
|
lookup: lookup,
|
|
1177
1311
|
backendPath: backendPath
|
|
1178
1312
|
});
|
|
1179
|
-
return
|
|
1313
|
+
return _context18.abrupt("return", {
|
|
1180
1314
|
code: 500,
|
|
1181
1315
|
status: false,
|
|
1182
1316
|
message: '后端返回订单为空',
|
|
1183
1317
|
data: null
|
|
1184
1318
|
});
|
|
1185
|
-
case
|
|
1186
|
-
|
|
1319
|
+
case 32:
|
|
1320
|
+
_context18.next = 34;
|
|
1187
1321
|
return _this.order.upsertOrdersFromRemote([fresh]);
|
|
1188
|
-
case
|
|
1189
|
-
|
|
1322
|
+
case 34:
|
|
1323
|
+
_context18.next = 36;
|
|
1190
1324
|
return _this.order.getLocalOrderByLookup(lookup);
|
|
1191
|
-
case
|
|
1192
|
-
savedOrder =
|
|
1325
|
+
case 36:
|
|
1326
|
+
savedOrder = _context18.sent;
|
|
1193
1327
|
if (savedOrder) {
|
|
1194
|
-
|
|
1328
|
+
_context18.next = 40;
|
|
1195
1329
|
break;
|
|
1196
1330
|
}
|
|
1197
1331
|
_this.logError('handleOrderSalesDetail: 订单写入后回读失败', {
|
|
1198
1332
|
lookup: lookup
|
|
1199
1333
|
});
|
|
1200
|
-
return
|
|
1334
|
+
return _context18.abrupt("return", {
|
|
1201
1335
|
code: 500,
|
|
1202
1336
|
status: false,
|
|
1203
1337
|
message: '订单写入后回读失败',
|
|
1204
1338
|
data: null
|
|
1205
1339
|
});
|
|
1206
|
-
case
|
|
1340
|
+
case 40:
|
|
1207
1341
|
_this.logInfo('handleOrderSalesDetail: 远端订单已同步到本地', {
|
|
1208
1342
|
lookup: lookup
|
|
1209
1343
|
});
|
|
1210
|
-
|
|
1344
|
+
_context18.next = 43;
|
|
1345
|
+
return _this.withSalesDetailProductSnapshots(savedOrder);
|
|
1346
|
+
case 43:
|
|
1347
|
+
_enrichedOrder = _context18.sent;
|
|
1348
|
+
return _context18.abrupt("return", {
|
|
1211
1349
|
code: 200,
|
|
1212
1350
|
status: true,
|
|
1213
1351
|
message: '',
|
|
1214
|
-
data:
|
|
1352
|
+
data: _enrichedOrder
|
|
1215
1353
|
});
|
|
1216
|
-
case
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
errorMessage =
|
|
1220
|
-
_this.
|
|
1354
|
+
case 47:
|
|
1355
|
+
_context18.prev = 47;
|
|
1356
|
+
_context18.t0 = _context18["catch"](24);
|
|
1357
|
+
errorMessage = _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0);
|
|
1358
|
+
_this.logInfo('handleOrderSalesDetail: 请求失败', {
|
|
1221
1359
|
lookup: lookup,
|
|
1222
1360
|
backendPath: backendPath,
|
|
1223
1361
|
error: errorMessage
|
|
1224
1362
|
});
|
|
1225
|
-
return
|
|
1363
|
+
return _context18.abrupt("return", {
|
|
1226
1364
|
code: 500,
|
|
1227
1365
|
status: false,
|
|
1228
1366
|
message: errorMessage,
|
|
1229
1367
|
data: null
|
|
1230
1368
|
});
|
|
1231
|
-
case
|
|
1369
|
+
case 52:
|
|
1232
1370
|
case "end":
|
|
1233
|
-
return
|
|
1371
|
+
return _context18.stop();
|
|
1234
1372
|
}
|
|
1235
|
-
},
|
|
1373
|
+
}, _callee18, null, [[24, 47]]);
|
|
1236
1374
|
}));
|
|
1237
|
-
return function (
|
|
1238
|
-
return
|
|
1375
|
+
return function (_x18) {
|
|
1376
|
+
return _ref45.apply(this, arguments);
|
|
1239
1377
|
};
|
|
1240
1378
|
}());
|
|
1241
1379
|
/**
|
|
1242
1380
|
* GET /shop/schedule/floor-plan* 前缀路由:读本地 store;支持 subscriberId + callback 订阅更新
|
|
1243
1381
|
*/
|
|
1244
1382
|
_defineProperty(this, "handleFloorPlanGet", /*#__PURE__*/function () {
|
|
1245
|
-
var
|
|
1246
|
-
var url, data, config, routePath, base, path, _subscriberId,
|
|
1247
|
-
return _regeneratorRuntime().wrap(function
|
|
1248
|
-
while (1) switch (
|
|
1383
|
+
var _ref47 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(_ref46) {
|
|
1384
|
+
var url, data, config, routePath, base, path, _subscriberId, _ref48, callback, subscriberId, ctx;
|
|
1385
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1386
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1249
1387
|
case 0:
|
|
1250
|
-
url =
|
|
1388
|
+
url = _ref46.url, data = _ref46.data, config = _ref46.config, routePath = _ref46.path;
|
|
1251
1389
|
base = '/shop/schedule/floor-plan';
|
|
1252
1390
|
path = _this.parseRequestPath(url, routePath);
|
|
1253
1391
|
if (!(path === "".concat(base, "/unsubscribe") || path === "".concat(base, "/code/unsubscribe"))) {
|
|
1254
|
-
|
|
1392
|
+
_context19.next = 7;
|
|
1255
1393
|
break;
|
|
1256
1394
|
}
|
|
1257
1395
|
_subscriberId = data === null || data === void 0 ? void 0 : data.subscriberId;
|
|
@@ -1262,19 +1400,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
1262
1400
|
remaining: _this.floorPlanQuerySubscribers.size
|
|
1263
1401
|
});
|
|
1264
1402
|
}
|
|
1265
|
-
return
|
|
1403
|
+
return _context19.abrupt("return", {
|
|
1266
1404
|
code: 200,
|
|
1267
1405
|
message: 'ok',
|
|
1268
1406
|
status: true
|
|
1269
1407
|
});
|
|
1270
1408
|
case 7:
|
|
1271
|
-
|
|
1409
|
+
_ref48 = config || {}, callback = _ref48.callback, subscriberId = _ref48.subscriberId;
|
|
1272
1410
|
ctx = _this.resolveFloorPlanQueryContext(path, base);
|
|
1273
1411
|
if (ctx) {
|
|
1274
|
-
|
|
1412
|
+
_context19.next = 11;
|
|
1275
1413
|
break;
|
|
1276
1414
|
}
|
|
1277
|
-
return
|
|
1415
|
+
return _context19.abrupt("return", {
|
|
1278
1416
|
status: false,
|
|
1279
1417
|
code: 404,
|
|
1280
1418
|
message: 'Not Found',
|
|
@@ -1292,28 +1430,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
1292
1430
|
total: _this.floorPlanQuerySubscribers.size
|
|
1293
1431
|
});
|
|
1294
1432
|
}
|
|
1295
|
-
return
|
|
1433
|
+
return _context19.abrupt("return", _this.computeFloorPlanQueryResult(ctx));
|
|
1296
1434
|
case 13:
|
|
1297
1435
|
case "end":
|
|
1298
|
-
return
|
|
1436
|
+
return _context19.stop();
|
|
1299
1437
|
}
|
|
1300
|
-
},
|
|
1438
|
+
}, _callee19);
|
|
1301
1439
|
}));
|
|
1302
|
-
return function (
|
|
1303
|
-
return
|
|
1440
|
+
return function (_x19) {
|
|
1441
|
+
return _ref47.apply(this, arguments);
|
|
1304
1442
|
};
|
|
1305
1443
|
}());
|
|
1306
1444
|
/**
|
|
1307
1445
|
* 取消预约列表查询订阅(HTTP 路由入口)
|
|
1308
1446
|
*/
|
|
1309
1447
|
_defineProperty(this, "handleUnsubscribeBookingQuery", /*#__PURE__*/function () {
|
|
1310
|
-
var
|
|
1311
|
-
var data,
|
|
1312
|
-
return _regeneratorRuntime().wrap(function
|
|
1313
|
-
while (1) switch (
|
|
1448
|
+
var _ref50 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(_ref49) {
|
|
1449
|
+
var data, _ref51, subscriberId;
|
|
1450
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1451
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1314
1452
|
case 0:
|
|
1315
|
-
data =
|
|
1316
|
-
|
|
1453
|
+
data = _ref49.data;
|
|
1454
|
+
_ref51 = data || {}, subscriberId = _ref51.subscriberId;
|
|
1317
1455
|
if (subscriberId) {
|
|
1318
1456
|
_this.bookingQuerySubscribers.delete(subscriberId);
|
|
1319
1457
|
_this.bookingRemoteQuerySubscribers.delete(subscriberId);
|
|
@@ -1323,19 +1461,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
1323
1461
|
remainingRemote: _this.bookingRemoteQuerySubscribers.size
|
|
1324
1462
|
});
|
|
1325
1463
|
}
|
|
1326
|
-
return
|
|
1464
|
+
return _context20.abrupt("return", {
|
|
1327
1465
|
code: 200,
|
|
1328
1466
|
message: 'ok',
|
|
1329
1467
|
status: true
|
|
1330
1468
|
});
|
|
1331
1469
|
case 4:
|
|
1332
1470
|
case "end":
|
|
1333
|
-
return
|
|
1471
|
+
return _context20.stop();
|
|
1334
1472
|
}
|
|
1335
|
-
},
|
|
1473
|
+
}, _callee20);
|
|
1336
1474
|
}));
|
|
1337
|
-
return function (
|
|
1338
|
-
return
|
|
1475
|
+
return function (_x20) {
|
|
1476
|
+
return _ref50.apply(this, arguments);
|
|
1339
1477
|
};
|
|
1340
1478
|
}());
|
|
1341
1479
|
/**
|
|
@@ -1343,13 +1481,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
1343
1481
|
* 通过餐牌ID列表获取所有相关日程的时间段点
|
|
1344
1482
|
*/
|
|
1345
1483
|
_defineProperty(this, "handleGetScheduleTimePoints", /*#__PURE__*/function () {
|
|
1346
|
-
var
|
|
1484
|
+
var _ref53 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(_ref52) {
|
|
1347
1485
|
var _menu_list_ids$length;
|
|
1348
1486
|
var url, method, data, config, menu_list_ids, _menu_list_ids$length2, menuList, scheduleIds, scheduleList, timePoints, errorMessage;
|
|
1349
|
-
return _regeneratorRuntime().wrap(function
|
|
1350
|
-
while (1) switch (
|
|
1487
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1488
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1351
1489
|
case 0:
|
|
1352
|
-
url =
|
|
1490
|
+
url = _ref52.url, method = _ref52.method, data = _ref52.data, config = _ref52.config;
|
|
1353
1491
|
console.log('[Server] handleGetScheduleTimePoints:', url, method, data, config);
|
|
1354
1492
|
menu_list_ids = data.menu_list_ids;
|
|
1355
1493
|
_this.logInfo('handleGetScheduleTimePoints 开始处理', {
|
|
@@ -1359,12 +1497,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
1359
1497
|
|
|
1360
1498
|
// 检查必要的模块是否已注册
|
|
1361
1499
|
if (_this.menu) {
|
|
1362
|
-
|
|
1500
|
+
_context21.next = 8;
|
|
1363
1501
|
break;
|
|
1364
1502
|
}
|
|
1365
1503
|
console.error('[Server] Menu 模块未注册');
|
|
1366
1504
|
_this.logError('handleGetScheduleTimePoints: Menu 模块未注册');
|
|
1367
|
-
return
|
|
1505
|
+
return _context21.abrupt("return", {
|
|
1368
1506
|
code: 500,
|
|
1369
1507
|
message: 'Menu 模块未注册',
|
|
1370
1508
|
data: [],
|
|
@@ -1372,12 +1510,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
1372
1510
|
});
|
|
1373
1511
|
case 8:
|
|
1374
1512
|
if (_this.schedule) {
|
|
1375
|
-
|
|
1513
|
+
_context21.next = 12;
|
|
1376
1514
|
break;
|
|
1377
1515
|
}
|
|
1378
1516
|
console.error('[Server] Schedule 模块未注册');
|
|
1379
1517
|
_this.logError('handleGetScheduleTimePoints: Schedule 模块未注册');
|
|
1380
|
-
return
|
|
1518
|
+
return _context21.abrupt("return", {
|
|
1381
1519
|
code: 500,
|
|
1382
1520
|
message: 'Schedule 模块未注册',
|
|
1383
1521
|
data: [],
|
|
@@ -1385,7 +1523,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1385
1523
|
});
|
|
1386
1524
|
case 12:
|
|
1387
1525
|
if (!(!menu_list_ids || !Array.isArray(menu_list_ids) || menu_list_ids.length === 0)) {
|
|
1388
|
-
|
|
1526
|
+
_context21.next = 16;
|
|
1389
1527
|
break;
|
|
1390
1528
|
}
|
|
1391
1529
|
console.error('[Server] menu_list_ids 参数无效');
|
|
@@ -1393,14 +1531,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1393
1531
|
menuListIdsCount: (_menu_list_ids$length2 = menu_list_ids === null || menu_list_ids === void 0 ? void 0 : menu_list_ids.length) !== null && _menu_list_ids$length2 !== void 0 ? _menu_list_ids$length2 : 0,
|
|
1394
1532
|
menu_list_ids: menu_list_ids
|
|
1395
1533
|
});
|
|
1396
|
-
return
|
|
1534
|
+
return _context21.abrupt("return", {
|
|
1397
1535
|
code: 400,
|
|
1398
1536
|
message: 'menu_list_ids 参数无效',
|
|
1399
1537
|
data: [],
|
|
1400
1538
|
status: false
|
|
1401
1539
|
});
|
|
1402
1540
|
case 16:
|
|
1403
|
-
|
|
1541
|
+
_context21.prev = 16;
|
|
1404
1542
|
// 1. 获取餐牌列表
|
|
1405
1543
|
menuList = _this.menu.getMenuByIds(menu_list_ids);
|
|
1406
1544
|
console.log("[Server] \u627E\u5230 ".concat(menuList.length, " \u4E2A\u9910\u724C"));
|
|
@@ -1418,13 +1556,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
1418
1556
|
scheduleCount: scheduleIds.length
|
|
1419
1557
|
});
|
|
1420
1558
|
if (!(scheduleIds.length === 0)) {
|
|
1421
|
-
|
|
1559
|
+
_context21.next = 26;
|
|
1422
1560
|
break;
|
|
1423
1561
|
}
|
|
1424
1562
|
_this.logInfo('handleGetScheduleTimePoints: 没有找到相关日程', {
|
|
1425
1563
|
menuListIdsCount: menu_list_ids.length
|
|
1426
1564
|
});
|
|
1427
|
-
return
|
|
1565
|
+
return _context21.abrupt("return", {
|
|
1428
1566
|
code: 200,
|
|
1429
1567
|
message: '没有找到相关日程',
|
|
1430
1568
|
data: [],
|
|
@@ -1448,22 +1586,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
1448
1586
|
scheduleCount: scheduleList.length,
|
|
1449
1587
|
timePointCount: timePoints.length
|
|
1450
1588
|
});
|
|
1451
|
-
return
|
|
1589
|
+
return _context21.abrupt("return", {
|
|
1452
1590
|
code: 200,
|
|
1453
1591
|
message: '获取成功',
|
|
1454
1592
|
data: timePoints,
|
|
1455
1593
|
status: true
|
|
1456
1594
|
});
|
|
1457
1595
|
case 35:
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
errorMessage =
|
|
1461
|
-
console.error('[Server] 获取日程时间点失败:',
|
|
1596
|
+
_context21.prev = 35;
|
|
1597
|
+
_context21.t0 = _context21["catch"](16);
|
|
1598
|
+
errorMessage = _context21.t0 instanceof Error ? _context21.t0.message : '未知错误';
|
|
1599
|
+
console.error('[Server] 获取日程时间点失败:', _context21.t0);
|
|
1462
1600
|
_this.logError('handleGetScheduleTimePoints: 获取日程时间点失败', {
|
|
1463
1601
|
menuListIdsCount: menu_list_ids.length,
|
|
1464
1602
|
error: errorMessage
|
|
1465
1603
|
});
|
|
1466
|
-
return
|
|
1604
|
+
return _context21.abrupt("return", {
|
|
1467
1605
|
code: 500,
|
|
1468
1606
|
message: "\u83B7\u53D6\u5931\u8D25: ".concat(errorMessage),
|
|
1469
1607
|
data: [],
|
|
@@ -1471,18 +1609,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
1471
1609
|
});
|
|
1472
1610
|
case 41:
|
|
1473
1611
|
case "end":
|
|
1474
|
-
return
|
|
1612
|
+
return _context21.stop();
|
|
1475
1613
|
}
|
|
1476
|
-
},
|
|
1614
|
+
}, _callee21, null, [[16, 35]]);
|
|
1477
1615
|
}));
|
|
1478
|
-
return function (
|
|
1479
|
-
return
|
|
1616
|
+
return function (_x21) {
|
|
1617
|
+
return _ref53.apply(this, arguments);
|
|
1480
1618
|
};
|
|
1481
1619
|
}());
|
|
1482
1620
|
this.core = core;
|
|
1483
1621
|
var appPlugin = core.getPlugin('app');
|
|
1484
1622
|
this.app = (appPlugin === null || appPlugin === void 0 ? void 0 : appPlugin.getApp()) || null;
|
|
1485
|
-
this.logger = ((_this$
|
|
1623
|
+
this.logger = ((_this$app4 = this.app) === null || _this$app4 === void 0 ? void 0 : _this$app4.logger) || null;
|
|
1486
1624
|
console.log('[Server] Server 初始化', this.core);
|
|
1487
1625
|
this.logInfo('Server 初始化', {
|
|
1488
1626
|
hasApp: !!this.app,
|
|
@@ -1597,10 +1735,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
1597
1735
|
}, {
|
|
1598
1736
|
key: "registerModuleWithRoutes",
|
|
1599
1737
|
value: (function () {
|
|
1600
|
-
var _registerModuleWithRoutes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1738
|
+
var _registerModuleWithRoutes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(module, options, moduleName) {
|
|
1601
1739
|
var routes;
|
|
1602
|
-
return _regeneratorRuntime().wrap(function
|
|
1603
|
-
while (1) switch (
|
|
1740
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1741
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1604
1742
|
case 0:
|
|
1605
1743
|
this.logInfo("\u5F00\u59CB\u6CE8\u518C\u6A21\u5757: ".concat(moduleName), {
|
|
1606
1744
|
moduleName: moduleName,
|
|
@@ -1608,7 +1746,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1608
1746
|
});
|
|
1609
1747
|
|
|
1610
1748
|
// 注册模块到 Core
|
|
1611
|
-
|
|
1749
|
+
_context22.next = 3;
|
|
1612
1750
|
return this.core.registerModule(module, options);
|
|
1613
1751
|
case 3:
|
|
1614
1752
|
console.log("[Server] \u2705 ".concat(moduleName, " \u6A21\u5757\u5DF2\u6CE8\u518C"));
|
|
@@ -1629,11 +1767,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
1629
1767
|
}
|
|
1630
1768
|
case 6:
|
|
1631
1769
|
case "end":
|
|
1632
|
-
return
|
|
1770
|
+
return _context22.stop();
|
|
1633
1771
|
}
|
|
1634
|
-
},
|
|
1772
|
+
}, _callee22, this);
|
|
1635
1773
|
}));
|
|
1636
|
-
function registerModuleWithRoutes(
|
|
1774
|
+
function registerModuleWithRoutes(_x22, _x23, _x24) {
|
|
1637
1775
|
return _registerModuleWithRoutes.apply(this, arguments);
|
|
1638
1776
|
}
|
|
1639
1777
|
return registerModuleWithRoutes;
|
|
@@ -1646,10 +1784,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
1646
1784
|
}, {
|
|
1647
1785
|
key: "registerModuleByName",
|
|
1648
1786
|
value: (function () {
|
|
1649
|
-
var _registerModuleByName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1787
|
+
var _registerModuleByName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(moduleConfig) {
|
|
1650
1788
|
var moduleName, shouldPreload, customConfig, registryConfig, ModuleClass, moduleInstance, moduleOptions;
|
|
1651
|
-
return _regeneratorRuntime().wrap(function
|
|
1652
|
-
while (1) switch (
|
|
1789
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1790
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1653
1791
|
case 0:
|
|
1654
1792
|
// 解析配置
|
|
1655
1793
|
moduleName = typeof moduleConfig === 'string' ? moduleConfig : moduleConfig.name;
|
|
@@ -1664,7 +1802,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1664
1802
|
// 查找模块配置
|
|
1665
1803
|
registryConfig = this.moduleRegistry[moduleName];
|
|
1666
1804
|
if (registryConfig) {
|
|
1667
|
-
|
|
1805
|
+
_context23.next = 8;
|
|
1668
1806
|
break;
|
|
1669
1807
|
}
|
|
1670
1808
|
this.logError("\u672A\u627E\u5230\u6A21\u5757\u914D\u7F6E: ".concat(moduleName), {
|
|
@@ -1678,7 +1816,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1678
1816
|
moduleOptions = _objectSpread({
|
|
1679
1817
|
store: _objectSpread({}, registryConfig.defaultStore)
|
|
1680
1818
|
}, customConfig); // 注册模块和路由
|
|
1681
|
-
|
|
1819
|
+
_context23.next = 13;
|
|
1682
1820
|
return this.registerModuleWithRoutes(moduleInstance, moduleOptions, moduleName.charAt(0).toUpperCase() + moduleName.slice(1));
|
|
1683
1821
|
case 13:
|
|
1684
1822
|
// 保存模块实例
|
|
@@ -1688,18 +1826,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
1688
1826
|
shouldPreload: shouldPreload,
|
|
1689
1827
|
version: registryConfig.version
|
|
1690
1828
|
});
|
|
1691
|
-
return
|
|
1829
|
+
return _context23.abrupt("return", {
|
|
1692
1830
|
module: moduleInstance,
|
|
1693
1831
|
config: registryConfig,
|
|
1694
1832
|
shouldPreload: shouldPreload
|
|
1695
1833
|
});
|
|
1696
1834
|
case 16:
|
|
1697
1835
|
case "end":
|
|
1698
|
-
return
|
|
1836
|
+
return _context23.stop();
|
|
1699
1837
|
}
|
|
1700
|
-
},
|
|
1838
|
+
}, _callee23, this);
|
|
1701
1839
|
}));
|
|
1702
|
-
function registerModuleByName(
|
|
1840
|
+
function registerModuleByName(_x25) {
|
|
1703
1841
|
return _registerModuleByName.apply(this, arguments);
|
|
1704
1842
|
}
|
|
1705
1843
|
return registerModuleByName;
|
|
@@ -1712,10 +1850,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
1712
1850
|
}, {
|
|
1713
1851
|
key: "registerModules",
|
|
1714
1852
|
value: (function () {
|
|
1715
|
-
var _registerModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1853
|
+
var _registerModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(moduleConfigs) {
|
|
1716
1854
|
var configs, registeredModules, _iterator2, _step2, config, configName, result, errorMessage;
|
|
1717
|
-
return _regeneratorRuntime().wrap(function
|
|
1718
|
-
while (1) switch (
|
|
1855
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1856
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1719
1857
|
case 0:
|
|
1720
1858
|
console.log('[Server] 开始注册模块...');
|
|
1721
1859
|
|
|
@@ -1727,47 +1865,47 @@ var Server = /*#__PURE__*/function () {
|
|
|
1727
1865
|
});
|
|
1728
1866
|
registeredModules = [];
|
|
1729
1867
|
_iterator2 = _createForOfIteratorHelper(configs);
|
|
1730
|
-
|
|
1868
|
+
_context24.prev = 5;
|
|
1731
1869
|
_iterator2.s();
|
|
1732
1870
|
case 7:
|
|
1733
1871
|
if ((_step2 = _iterator2.n()).done) {
|
|
1734
|
-
|
|
1872
|
+
_context24.next = 25;
|
|
1735
1873
|
break;
|
|
1736
1874
|
}
|
|
1737
1875
|
config = _step2.value;
|
|
1738
1876
|
configName = typeof config === 'string' ? config : config.name;
|
|
1739
|
-
|
|
1740
|
-
|
|
1877
|
+
_context24.prev = 10;
|
|
1878
|
+
_context24.next = 13;
|
|
1741
1879
|
return this.registerModuleByName(config);
|
|
1742
1880
|
case 13:
|
|
1743
|
-
result =
|
|
1881
|
+
result = _context24.sent;
|
|
1744
1882
|
registeredModules.push(result);
|
|
1745
|
-
|
|
1883
|
+
_context24.next = 23;
|
|
1746
1884
|
break;
|
|
1747
1885
|
case 17:
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
errorMessage =
|
|
1886
|
+
_context24.prev = 17;
|
|
1887
|
+
_context24.t0 = _context24["catch"](10);
|
|
1888
|
+
errorMessage = _context24.t0 instanceof Error ? _context24.t0.message : String(_context24.t0);
|
|
1751
1889
|
this.logError("\u6A21\u5757\u6CE8\u518C\u5931\u8D25: ".concat(configName), {
|
|
1752
1890
|
moduleName: configName,
|
|
1753
1891
|
error: errorMessage
|
|
1754
1892
|
});
|
|
1755
|
-
console.error("[Server] \u6A21\u5757\u6CE8\u518C\u5931\u8D25:",
|
|
1756
|
-
throw
|
|
1893
|
+
console.error("[Server] \u6A21\u5757\u6CE8\u518C\u5931\u8D25:", _context24.t0);
|
|
1894
|
+
throw _context24.t0;
|
|
1757
1895
|
case 23:
|
|
1758
|
-
|
|
1896
|
+
_context24.next = 7;
|
|
1759
1897
|
break;
|
|
1760
1898
|
case 25:
|
|
1761
|
-
|
|
1899
|
+
_context24.next = 30;
|
|
1762
1900
|
break;
|
|
1763
1901
|
case 27:
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
_iterator2.e(
|
|
1902
|
+
_context24.prev = 27;
|
|
1903
|
+
_context24.t1 = _context24["catch"](5);
|
|
1904
|
+
_iterator2.e(_context24.t1);
|
|
1767
1905
|
case 30:
|
|
1768
|
-
|
|
1906
|
+
_context24.prev = 30;
|
|
1769
1907
|
_iterator2.f();
|
|
1770
|
-
return
|
|
1908
|
+
return _context24.finish(30);
|
|
1771
1909
|
case 33:
|
|
1772
1910
|
console.log('[Server] ✅ 所有模块注册完成');
|
|
1773
1911
|
this.logInfo('所有模块注册完成', {
|
|
@@ -1777,14 +1915,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1777
1915
|
return m === null || m === void 0 || (_m$config = m.config) === null || _m$config === void 0 ? void 0 : _m$config.name;
|
|
1778
1916
|
})
|
|
1779
1917
|
});
|
|
1780
|
-
return
|
|
1918
|
+
return _context24.abrupt("return", registeredModules);
|
|
1781
1919
|
case 36:
|
|
1782
1920
|
case "end":
|
|
1783
|
-
return
|
|
1921
|
+
return _context24.stop();
|
|
1784
1922
|
}
|
|
1785
|
-
},
|
|
1923
|
+
}, _callee24, this, [[5, 27, 30, 33], [10, 17]]);
|
|
1786
1924
|
}));
|
|
1787
|
-
function registerModules(
|
|
1925
|
+
function registerModules(_x26) {
|
|
1788
1926
|
return _registerModules.apply(this, arguments);
|
|
1789
1927
|
}
|
|
1790
1928
|
return registerModules;
|
|
@@ -1797,10 +1935,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
1797
1935
|
}, {
|
|
1798
1936
|
key: "preloadModulesData",
|
|
1799
1937
|
value: (function () {
|
|
1800
|
-
var _preloadModulesData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1938
|
+
var _preloadModulesData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(registeredModules, options) {
|
|
1801
1939
|
var modulesToPreload, preloadResults, _iterator3, _step3, _step3$value, module, config, shouldPreload, startTime, _options$onModuleLoad, _options$onModuleLoad2, duration, _duration, errorMessage, successCount, failCount;
|
|
1802
|
-
return _regeneratorRuntime().wrap(function
|
|
1803
|
-
while (1) switch (
|
|
1940
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1941
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1804
1942
|
case 0:
|
|
1805
1943
|
console.log('[Server] 开始预加载模块数据...');
|
|
1806
1944
|
modulesToPreload = registeredModules.filter(function (m) {
|
|
@@ -1813,16 +1951,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
1813
1951
|
});
|
|
1814
1952
|
preloadResults = [];
|
|
1815
1953
|
_iterator3 = _createForOfIteratorHelper(registeredModules);
|
|
1816
|
-
|
|
1954
|
+
_context25.prev = 5;
|
|
1817
1955
|
_iterator3.s();
|
|
1818
1956
|
case 7:
|
|
1819
1957
|
if ((_step3 = _iterator3.n()).done) {
|
|
1820
|
-
|
|
1958
|
+
_context25.next = 40;
|
|
1821
1959
|
break;
|
|
1822
1960
|
}
|
|
1823
1961
|
_step3$value = _step3.value, module = _step3$value.module, config = _step3$value.config, shouldPreload = _step3$value.shouldPreload;
|
|
1824
1962
|
if (shouldPreload) {
|
|
1825
|
-
|
|
1963
|
+
_context25.next = 13;
|
|
1826
1964
|
break;
|
|
1827
1965
|
}
|
|
1828
1966
|
console.log("[Server] \u23ED\uFE0F \u8DF3\u8FC7 ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D"));
|
|
@@ -1830,19 +1968,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
1830
1968
|
moduleName: config.name,
|
|
1831
1969
|
reason: 'shouldPreload=false'
|
|
1832
1970
|
});
|
|
1833
|
-
return
|
|
1971
|
+
return _context25.abrupt("continue", 38);
|
|
1834
1972
|
case 13:
|
|
1835
1973
|
if (!(typeof module.preload === 'function')) {
|
|
1836
|
-
|
|
1974
|
+
_context25.next = 36;
|
|
1837
1975
|
break;
|
|
1838
1976
|
}
|
|
1839
1977
|
startTime = Date.now();
|
|
1840
|
-
|
|
1978
|
+
_context25.prev = 15;
|
|
1841
1979
|
this.logInfo("\u5F00\u59CB\u9884\u52A0\u8F7D\u6A21\u5757: ".concat(config.name), {
|
|
1842
1980
|
moduleName: config.name
|
|
1843
1981
|
});
|
|
1844
1982
|
options === null || options === void 0 || (_options$onModuleLoad = options.onModuleLoad) === null || _options$onModuleLoad === void 0 || _options$onModuleLoad.call(options, config.name);
|
|
1845
|
-
|
|
1983
|
+
_context25.next = 20;
|
|
1846
1984
|
return module.preload();
|
|
1847
1985
|
case 20:
|
|
1848
1986
|
options === null || options === void 0 || (_options$onModuleLoad2 = options.onModuleLoadComplete) === null || _options$onModuleLoad2 === void 0 || _options$onModuleLoad2.call(options, config.name);
|
|
@@ -1856,14 +1994,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1856
1994
|
name: config.name,
|
|
1857
1995
|
success: true
|
|
1858
1996
|
});
|
|
1859
|
-
|
|
1997
|
+
_context25.next = 34;
|
|
1860
1998
|
break;
|
|
1861
1999
|
case 27:
|
|
1862
|
-
|
|
1863
|
-
|
|
2000
|
+
_context25.prev = 27;
|
|
2001
|
+
_context25.t0 = _context25["catch"](15);
|
|
1864
2002
|
_duration = Date.now() - startTime;
|
|
1865
|
-
errorMessage =
|
|
1866
|
-
console.error("[Server] \u274C ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25:"),
|
|
2003
|
+
errorMessage = _context25.t0 instanceof Error ? _context25.t0.message : String(_context25.t0);
|
|
2004
|
+
console.error("[Server] \u274C ".concat(config.name, " \u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25:"), _context25.t0);
|
|
1867
2005
|
this.logError("\u6A21\u5757\u9884\u52A0\u8F7D\u5931\u8D25: ".concat(config.name), {
|
|
1868
2006
|
moduleName: config.name,
|
|
1869
2007
|
duration: "".concat(_duration, "ms"),
|
|
@@ -1875,7 +2013,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1875
2013
|
error: errorMessage
|
|
1876
2014
|
});
|
|
1877
2015
|
case 34:
|
|
1878
|
-
|
|
2016
|
+
_context25.next = 38;
|
|
1879
2017
|
break;
|
|
1880
2018
|
case 36:
|
|
1881
2019
|
console.log("[Server] \u26A0\uFE0F ".concat(config.name, " \u6A21\u5757\u672A\u5B9E\u73B0 preload() \u65B9\u6CD5"));
|
|
@@ -1883,19 +2021,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
1883
2021
|
moduleName: config.name
|
|
1884
2022
|
});
|
|
1885
2023
|
case 38:
|
|
1886
|
-
|
|
2024
|
+
_context25.next = 7;
|
|
1887
2025
|
break;
|
|
1888
2026
|
case 40:
|
|
1889
|
-
|
|
2027
|
+
_context25.next = 45;
|
|
1890
2028
|
break;
|
|
1891
2029
|
case 42:
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
_iterator3.e(
|
|
2030
|
+
_context25.prev = 42;
|
|
2031
|
+
_context25.t1 = _context25["catch"](5);
|
|
2032
|
+
_iterator3.e(_context25.t1);
|
|
1895
2033
|
case 45:
|
|
1896
|
-
|
|
2034
|
+
_context25.prev = 45;
|
|
1897
2035
|
_iterator3.f();
|
|
1898
|
-
return
|
|
2036
|
+
return _context25.finish(45);
|
|
1899
2037
|
case 48:
|
|
1900
2038
|
successCount = preloadResults.filter(function (r) {
|
|
1901
2039
|
return r.success;
|
|
@@ -1910,11 +2048,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
1910
2048
|
});
|
|
1911
2049
|
case 52:
|
|
1912
2050
|
case "end":
|
|
1913
|
-
return
|
|
2051
|
+
return _context25.stop();
|
|
1914
2052
|
}
|
|
1915
|
-
},
|
|
2053
|
+
}, _callee25, this, [[5, 42, 45, 48], [15, 27]]);
|
|
1916
2054
|
}));
|
|
1917
|
-
function preloadModulesData(
|
|
2055
|
+
function preloadModulesData(_x27, _x28) {
|
|
1918
2056
|
return _preloadModulesData.apply(this, arguments);
|
|
1919
2057
|
}
|
|
1920
2058
|
return preloadModulesData;
|
|
@@ -1928,7 +2066,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1928
2066
|
}, {
|
|
1929
2067
|
key: "initialize",
|
|
1930
2068
|
value: (function () {
|
|
1931
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2069
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(moduleConfigs) {
|
|
1932
2070
|
var _moduleConfigs$length,
|
|
1933
2071
|
_this3 = this;
|
|
1934
2072
|
var autoPreload,
|
|
@@ -1936,12 +2074,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
1936
2074
|
startTime,
|
|
1937
2075
|
registeredModules,
|
|
1938
2076
|
duration,
|
|
1939
|
-
|
|
1940
|
-
return _regeneratorRuntime().wrap(function
|
|
1941
|
-
while (1) switch (
|
|
2077
|
+
_args26 = arguments;
|
|
2078
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2079
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1942
2080
|
case 0:
|
|
1943
|
-
autoPreload =
|
|
1944
|
-
options =
|
|
2081
|
+
autoPreload = _args26.length > 1 && _args26[1] !== undefined ? _args26[1] : true;
|
|
2082
|
+
options = _args26.length > 2 ? _args26[2] : undefined;
|
|
1945
2083
|
startTime = Date.now();
|
|
1946
2084
|
this.logInfo('Server 初始化开始', {
|
|
1947
2085
|
moduleConfigCount: (_moduleConfigs$length = moduleConfigs === null || moduleConfigs === void 0 ? void 0 : moduleConfigs.length) !== null && _moduleConfigs$length !== void 0 ? _moduleConfigs$length : 'all',
|
|
@@ -1954,25 +2092,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
1954
2092
|
this.registerDeviceTaskActions();
|
|
1955
2093
|
|
|
1956
2094
|
// 注册模块
|
|
1957
|
-
|
|
2095
|
+
_context26.next = 8;
|
|
1958
2096
|
return this.registerModules(moduleConfigs);
|
|
1959
2097
|
case 8:
|
|
1960
|
-
registeredModules =
|
|
2098
|
+
registeredModules = _context26.sent;
|
|
1961
2099
|
if (!autoPreload) {
|
|
1962
|
-
|
|
2100
|
+
_context26.next = 14;
|
|
1963
2101
|
break;
|
|
1964
2102
|
}
|
|
1965
|
-
|
|
2103
|
+
_context26.next = 12;
|
|
1966
2104
|
return this.preloadModulesData(registeredModules, options);
|
|
1967
2105
|
case 12:
|
|
1968
|
-
|
|
2106
|
+
_context26.next = 15;
|
|
1969
2107
|
break;
|
|
1970
2108
|
case 14:
|
|
1971
2109
|
this.logInfo('跳过自动预加载', {
|
|
1972
2110
|
autoPreload: autoPreload
|
|
1973
2111
|
});
|
|
1974
2112
|
case 15:
|
|
1975
|
-
|
|
2113
|
+
_context26.next = 17;
|
|
1976
2114
|
return this.setupProductsQuotationPriceBridge();
|
|
1977
2115
|
case 17:
|
|
1978
2116
|
// 监听 ProductsModule 同步完成事件,重新计算并推送查询结果
|
|
@@ -1999,14 +2137,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
1999
2137
|
duration: "".concat(duration, "ms"),
|
|
2000
2138
|
registeredModuleCount: registeredModules.length
|
|
2001
2139
|
});
|
|
2002
|
-
return
|
|
2140
|
+
return _context26.abrupt("return", registeredModules);
|
|
2003
2141
|
case 23:
|
|
2004
2142
|
case "end":
|
|
2005
|
-
return
|
|
2143
|
+
return _context26.stop();
|
|
2006
2144
|
}
|
|
2007
|
-
},
|
|
2145
|
+
}, _callee26, this);
|
|
2008
2146
|
}));
|
|
2009
|
-
function initialize(
|
|
2147
|
+
function initialize(_x29) {
|
|
2010
2148
|
return _initialize.apply(this, arguments);
|
|
2011
2149
|
}
|
|
2012
2150
|
return initialize;
|
|
@@ -2048,31 +2186,31 @@ var Server = /*#__PURE__*/function () {
|
|
|
2048
2186
|
}, {
|
|
2049
2187
|
key: "handleSyncSalesTask",
|
|
2050
2188
|
value: function () {
|
|
2051
|
-
var _handleSyncSalesTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2052
|
-
var _ctx$task, _this$
|
|
2189
|
+
var _handleSyncSalesTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(ctx) {
|
|
2190
|
+
var _ctx$task, _this$app5;
|
|
2053
2191
|
var payload, backendPath, data, title, _ctx$task2, _syncResult$syncedOrd, syncResult, backendError, message, errorMessage;
|
|
2054
|
-
return _regeneratorRuntime().wrap(function
|
|
2055
|
-
while (1) switch (
|
|
2192
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2193
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2056
2194
|
case 0:
|
|
2057
2195
|
payload = ((_ctx$task = ctx.task) === null || _ctx$task === void 0 ? void 0 : _ctx$task.payload) || {};
|
|
2058
2196
|
backendPath = payload.backendPath;
|
|
2059
2197
|
data = payload.data;
|
|
2060
2198
|
title = payload.title || 'sync_sales';
|
|
2061
2199
|
if (!(!backendPath || !data)) {
|
|
2062
|
-
|
|
2200
|
+
_context27.next = 6;
|
|
2063
2201
|
break;
|
|
2064
2202
|
}
|
|
2065
|
-
return
|
|
2203
|
+
return _context27.abrupt("return", this.taskFail('INVALID_PAYLOAD', '缺少 backendPath 或 data'));
|
|
2066
2204
|
case 6:
|
|
2067
|
-
if ((_this$
|
|
2068
|
-
|
|
2205
|
+
if ((_this$app5 = this.app) !== null && _this$app5 !== void 0 && _this$app5.request) {
|
|
2206
|
+
_context27.next = 9;
|
|
2069
2207
|
break;
|
|
2070
2208
|
}
|
|
2071
2209
|
this.logError("".concat(title, ": sync_sales app.request \u4E0D\u53EF\u7528"));
|
|
2072
|
-
return
|
|
2210
|
+
return _context27.abrupt("return", this.taskTimeout('app.request 不可用'));
|
|
2073
2211
|
case 9:
|
|
2074
|
-
|
|
2075
|
-
|
|
2212
|
+
_context27.prev = 9;
|
|
2213
|
+
_context27.next = 12;
|
|
2076
2214
|
return this.runCheckoutSync({
|
|
2077
2215
|
backendPath: backendPath,
|
|
2078
2216
|
data: data,
|
|
@@ -2082,27 +2220,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
2082
2220
|
persistCheckoutDataWithResponse: false
|
|
2083
2221
|
});
|
|
2084
2222
|
case 12:
|
|
2085
|
-
syncResult =
|
|
2223
|
+
syncResult = _context27.sent;
|
|
2086
2224
|
if (!syncResult.rejected) {
|
|
2087
|
-
|
|
2225
|
+
_context27.next = 16;
|
|
2088
2226
|
break;
|
|
2089
2227
|
}
|
|
2090
2228
|
this.logError("".concat(title, ": sync_sales \u540E\u7AEF\u660E\u786E\u5931\u8D25"), {
|
|
2091
2229
|
backendPath: backendPath,
|
|
2092
2230
|
response: syncResult.errorResponse
|
|
2093
2231
|
});
|
|
2094
|
-
return
|
|
2232
|
+
return _context27.abrupt("return", this.taskFail('BACKEND_REJECTED', syncResult.message || '后端明确拒绝 checkout', syncResult.errorResponse));
|
|
2095
2233
|
case 16:
|
|
2096
|
-
return
|
|
2234
|
+
return _context27.abrupt("return", this.taskOk({
|
|
2097
2235
|
order: (_syncResult$syncedOrd = syncResult.syncedOrder) !== null && _syncResult$syncedOrd !== void 0 ? _syncResult$syncedOrd : null,
|
|
2098
2236
|
response: syncResult.normalizedResponse
|
|
2099
2237
|
}));
|
|
2100
2238
|
case 19:
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
backendError = this.extractBackendErrorResponse(
|
|
2239
|
+
_context27.prev = 19;
|
|
2240
|
+
_context27.t0 = _context27["catch"](9);
|
|
2241
|
+
backendError = this.extractBackendErrorResponse(_context27.t0);
|
|
2104
2242
|
if (!backendError) {
|
|
2105
|
-
|
|
2243
|
+
_context27.next = 26;
|
|
2106
2244
|
break;
|
|
2107
2245
|
}
|
|
2108
2246
|
message = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || '后端明确拒绝 checkout';
|
|
@@ -2110,22 +2248,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
2110
2248
|
backendPath: backendPath,
|
|
2111
2249
|
backendError: backendError
|
|
2112
2250
|
});
|
|
2113
|
-
return
|
|
2251
|
+
return _context27.abrupt("return", this.taskFail('BACKEND_REJECTED', message, backendError));
|
|
2114
2252
|
case 26:
|
|
2115
|
-
errorMessage = this.getUnknownErrorMessage(
|
|
2253
|
+
errorMessage = this.getUnknownErrorMessage(_context27.t0);
|
|
2116
2254
|
this.logError("".concat(title, ": sync_sales \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
|
|
2117
2255
|
backendPath: backendPath,
|
|
2118
2256
|
error: errorMessage,
|
|
2119
|
-
error_detail: this.normalizeUnknownError(
|
|
2257
|
+
error_detail: this.normalizeUnknownError(_context27.t0)
|
|
2120
2258
|
});
|
|
2121
|
-
return
|
|
2259
|
+
return _context27.abrupt("return", this.taskTimeout(errorMessage));
|
|
2122
2260
|
case 29:
|
|
2123
2261
|
case "end":
|
|
2124
|
-
return
|
|
2262
|
+
return _context27.stop();
|
|
2125
2263
|
}
|
|
2126
|
-
},
|
|
2264
|
+
}, _callee27, this, [[9, 19]]);
|
|
2127
2265
|
}));
|
|
2128
|
-
function handleSyncSalesTask(
|
|
2266
|
+
function handleSyncSalesTask(_x30) {
|
|
2129
2267
|
return _handleSyncSalesTask.apply(this, arguments);
|
|
2130
2268
|
}
|
|
2131
2269
|
return handleSyncSalesTask;
|
|
@@ -2133,40 +2271,40 @@ var Server = /*#__PURE__*/function () {
|
|
|
2133
2271
|
}, {
|
|
2134
2272
|
key: "runCheckoutSync",
|
|
2135
2273
|
value: function () {
|
|
2136
|
-
var _runCheckoutSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2137
|
-
var _this$
|
|
2274
|
+
var _runCheckoutSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
2275
|
+
var _this$app6;
|
|
2138
2276
|
var backendPath, title, normalizedData, checkoutData, remoteCheckoutData, response, fresh, externalSaleNumber, syncedOrder, printableSyncedOrder;
|
|
2139
|
-
return _regeneratorRuntime().wrap(function
|
|
2140
|
-
while (1) switch (
|
|
2277
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2278
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2141
2279
|
case 0:
|
|
2142
2280
|
backendPath = params.backendPath, title = params.title;
|
|
2143
|
-
|
|
2281
|
+
_context28.next = 3;
|
|
2144
2282
|
return this.normalizeCheckoutSubmitData(params.data, title);
|
|
2145
2283
|
case 3:
|
|
2146
|
-
normalizedData =
|
|
2147
|
-
|
|
2284
|
+
normalizedData = _context28.sent;
|
|
2285
|
+
_context28.next = 6;
|
|
2148
2286
|
return this.ensureCheckoutOrderNumbers(normalizedData, title);
|
|
2149
2287
|
case 6:
|
|
2150
|
-
checkoutData =
|
|
2288
|
+
checkoutData = _context28.sent;
|
|
2151
2289
|
remoteCheckoutData = this.omitCheckoutSyncMode(checkoutData);
|
|
2152
|
-
if ((_this$
|
|
2153
|
-
|
|
2290
|
+
if ((_this$app6 = this.app) !== null && _this$app6 !== void 0 && (_this$app6 = _this$app6.request) !== null && _this$app6 !== void 0 && _this$app6.post) {
|
|
2291
|
+
_context28.next = 10;
|
|
2154
2292
|
break;
|
|
2155
2293
|
}
|
|
2156
2294
|
throw new Error('app.request 不可用');
|
|
2157
2295
|
case 10:
|
|
2158
|
-
|
|
2296
|
+
_context28.next = 12;
|
|
2159
2297
|
return this.app.request.post(backendPath, remoteCheckoutData, {
|
|
2160
2298
|
isShopApi: true,
|
|
2161
2299
|
customToast: function customToast() {}
|
|
2162
2300
|
});
|
|
2163
2301
|
case 12:
|
|
2164
|
-
response =
|
|
2302
|
+
response = _context28.sent;
|
|
2165
2303
|
if (!this.isCheckoutResponseRejected(response)) {
|
|
2166
|
-
|
|
2304
|
+
_context28.next = 15;
|
|
2167
2305
|
break;
|
|
2168
2306
|
}
|
|
2169
|
-
return
|
|
2307
|
+
return _context28.abrupt("return", {
|
|
2170
2308
|
rejected: true,
|
|
2171
2309
|
message: (response === null || response === void 0 ? void 0 : response.message) || '后端明确拒绝 checkout',
|
|
2172
2310
|
errorResponse: response,
|
|
@@ -2180,7 +2318,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2180
2318
|
external_sale_number: params.externalSaleNumber,
|
|
2181
2319
|
data: remoteCheckoutData
|
|
2182
2320
|
});
|
|
2183
|
-
|
|
2321
|
+
_context28.next = 19;
|
|
2184
2322
|
return this.persistSyncedCheckoutOrder({
|
|
2185
2323
|
backendPath: backendPath,
|
|
2186
2324
|
checkoutData: remoteCheckoutData,
|
|
@@ -2190,7 +2328,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2190
2328
|
persistCheckoutDataWithResponse: params.persistCheckoutDataWithResponse === true
|
|
2191
2329
|
});
|
|
2192
2330
|
case 19:
|
|
2193
|
-
syncedOrder =
|
|
2331
|
+
syncedOrder = _context28.sent;
|
|
2194
2332
|
printableSyncedOrder = syncedOrder ? this.buildSyncedOrderForPrint({
|
|
2195
2333
|
syncedOrder: syncedOrder,
|
|
2196
2334
|
checkoutResponseOrder: fresh
|
|
@@ -2199,10 +2337,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
2199
2337
|
checkoutData: remoteCheckoutData,
|
|
2200
2338
|
syncedOrder: printableSyncedOrder
|
|
2201
2339
|
}))) {
|
|
2202
|
-
|
|
2340
|
+
_context28.next = 24;
|
|
2203
2341
|
break;
|
|
2204
2342
|
}
|
|
2205
|
-
|
|
2343
|
+
_context28.next = 24;
|
|
2206
2344
|
return this.dispatchPrintOtherReceiptTask({
|
|
2207
2345
|
checkoutData: remoteCheckoutData,
|
|
2208
2346
|
syncedOrder: printableSyncedOrder,
|
|
@@ -2210,7 +2348,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2210
2348
|
deviceId: params.deviceId
|
|
2211
2349
|
});
|
|
2212
2350
|
case 24:
|
|
2213
|
-
return
|
|
2351
|
+
return _context28.abrupt("return", {
|
|
2214
2352
|
rejected: false,
|
|
2215
2353
|
response: response,
|
|
2216
2354
|
normalizedResponse: this.normalizeCheckoutResponse(response),
|
|
@@ -2220,11 +2358,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
2220
2358
|
});
|
|
2221
2359
|
case 25:
|
|
2222
2360
|
case "end":
|
|
2223
|
-
return
|
|
2361
|
+
return _context28.stop();
|
|
2224
2362
|
}
|
|
2225
|
-
},
|
|
2363
|
+
}, _callee28, this);
|
|
2226
2364
|
}));
|
|
2227
|
-
function runCheckoutSync(
|
|
2365
|
+
function runCheckoutSync(_x31) {
|
|
2228
2366
|
return _runCheckoutSync.apply(this, arguments);
|
|
2229
2367
|
}
|
|
2230
2368
|
return runCheckoutSync;
|
|
@@ -2241,15 +2379,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
2241
2379
|
}, {
|
|
2242
2380
|
key: "persistSyncedCheckoutOrder",
|
|
2243
2381
|
value: function () {
|
|
2244
|
-
var _persistSyncedCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2382
|
+
var _persistSyncedCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
2245
2383
|
var backendPath, checkoutData, externalSaleNumber, fresh, title, persistCheckoutDataWithResponse, shouldMergeRemoteOrder, syncedOrder, _external_sale_number2, _external_sale_number3, _syncedOrder$order_id, _syncedOrder, patch, result;
|
|
2246
|
-
return _regeneratorRuntime().wrap(function
|
|
2247
|
-
while (1) switch (
|
|
2384
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2385
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2248
2386
|
case 0:
|
|
2249
2387
|
backendPath = params.backendPath, checkoutData = params.checkoutData, externalSaleNumber = params.externalSaleNumber, fresh = params.fresh, title = params.title, persistCheckoutDataWithResponse = params.persistCheckoutDataWithResponse;
|
|
2250
2388
|
shouldMergeRemoteOrder = fresh ? this.isMergeableCheckoutOrder(fresh, externalSaleNumber) : false;
|
|
2251
2389
|
if (!(this.order && fresh && (shouldMergeRemoteOrder || persistCheckoutDataWithResponse))) {
|
|
2252
|
-
|
|
2390
|
+
_context29.next = 9;
|
|
2253
2391
|
break;
|
|
2254
2392
|
}
|
|
2255
2393
|
syncedOrder = persistCheckoutDataWithResponse ? _objectSpread(_objectSpread(_objectSpread({}, checkoutData), fresh), {}, {
|
|
@@ -2259,7 +2397,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2259
2397
|
external_sale_number: (_external_sale_number3 = fresh.external_sale_number) !== null && _external_sale_number3 !== void 0 ? _external_sale_number3 : externalSaleNumber,
|
|
2260
2398
|
need_sync: 0
|
|
2261
2399
|
});
|
|
2262
|
-
|
|
2400
|
+
_context29.next = 6;
|
|
2263
2401
|
return this.order.upsertOrdersFromRemote([syncedOrder]);
|
|
2264
2402
|
case 6:
|
|
2265
2403
|
this.logInfo("".concat(title, ": sync_sales \u5B8C\u6574\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u672C\u5730"), {
|
|
@@ -2269,21 +2407,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
2269
2407
|
mergedRemoteOrder: shouldMergeRemoteOrder,
|
|
2270
2408
|
persistedCheckoutDataWithResponse: persistCheckoutDataWithResponse
|
|
2271
2409
|
});
|
|
2272
|
-
|
|
2410
|
+
_context29.next = 19;
|
|
2273
2411
|
break;
|
|
2274
2412
|
case 9:
|
|
2275
2413
|
if (!(this.order && externalSaleNumber && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
|
|
2276
|
-
|
|
2414
|
+
_context29.next = 18;
|
|
2277
2415
|
break;
|
|
2278
2416
|
}
|
|
2279
2417
|
patch = this.buildCheckoutSyncSuccessPatch(fresh);
|
|
2280
|
-
|
|
2418
|
+
_context29.next = 13;
|
|
2281
2419
|
return this.order.markOrderSyncedByExternalSaleNumber({
|
|
2282
2420
|
externalSaleNumber: externalSaleNumber,
|
|
2283
2421
|
patch: patch
|
|
2284
2422
|
});
|
|
2285
2423
|
case 13:
|
|
2286
|
-
result =
|
|
2424
|
+
result = _context29.sent;
|
|
2287
2425
|
syncedOrder = (result === null || result === void 0 ? void 0 : result.order) || _objectSpread(_objectSpread(_objectSpread({}, checkoutData), patch), {}, {
|
|
2288
2426
|
external_sale_number: externalSaleNumber,
|
|
2289
2427
|
need_sync: 0
|
|
@@ -2294,7 +2432,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2294
2432
|
hasRemoteOrder: !!fresh,
|
|
2295
2433
|
mergedRemoteOrder: false
|
|
2296
2434
|
});
|
|
2297
|
-
|
|
2435
|
+
_context29.next = 19;
|
|
2298
2436
|
break;
|
|
2299
2437
|
case 18:
|
|
2300
2438
|
this.logWarning("".concat(title, ": sync_sales Order \u6A21\u5757\u672A\u6CE8\u518C"), {
|
|
@@ -2303,14 +2441,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
2303
2441
|
order_id: fresh === null || fresh === void 0 ? void 0 : fresh.order_id
|
|
2304
2442
|
});
|
|
2305
2443
|
case 19:
|
|
2306
|
-
return
|
|
2444
|
+
return _context29.abrupt("return", syncedOrder);
|
|
2307
2445
|
case 20:
|
|
2308
2446
|
case "end":
|
|
2309
|
-
return
|
|
2447
|
+
return _context29.stop();
|
|
2310
2448
|
}
|
|
2311
|
-
},
|
|
2449
|
+
}, _callee29, this);
|
|
2312
2450
|
}));
|
|
2313
|
-
function persistSyncedCheckoutOrder(
|
|
2451
|
+
function persistSyncedCheckoutOrder(_x32) {
|
|
2314
2452
|
return _persistSyncedCheckoutOrder.apply(this, arguments);
|
|
2315
2453
|
}
|
|
2316
2454
|
return persistSyncedCheckoutOrder;
|
|
@@ -2321,51 +2459,51 @@ var Server = /*#__PURE__*/function () {
|
|
|
2321
2459
|
}, {
|
|
2322
2460
|
key: "setupProductsQuotationPriceBridge",
|
|
2323
2461
|
value: (function () {
|
|
2324
|
-
var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2462
|
+
var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2325
2463
|
var _this$core$context, errorMessage;
|
|
2326
|
-
return _regeneratorRuntime().wrap(function
|
|
2327
|
-
while (1) switch (
|
|
2464
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2465
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2328
2466
|
case 0:
|
|
2329
2467
|
if (this.products) {
|
|
2330
|
-
|
|
2468
|
+
_context30.next = 3;
|
|
2331
2469
|
break;
|
|
2332
2470
|
}
|
|
2333
2471
|
this.logInfo('setupProductsQuotationPriceBridge: Products 模块未注册');
|
|
2334
|
-
return
|
|
2472
|
+
return _context30.abrupt("return");
|
|
2335
2473
|
case 3:
|
|
2336
2474
|
if (this.schedule) {
|
|
2337
|
-
|
|
2475
|
+
_context30.next = 6;
|
|
2338
2476
|
break;
|
|
2339
2477
|
}
|
|
2340
2478
|
this.logInfo('setupProductsQuotationPriceBridge: Schedule 模块未注册');
|
|
2341
|
-
return
|
|
2479
|
+
return _context30.abrupt("return");
|
|
2342
2480
|
case 6:
|
|
2343
|
-
|
|
2344
|
-
|
|
2481
|
+
_context30.prev = 6;
|
|
2482
|
+
_context30.next = 9;
|
|
2345
2483
|
return this.schedule.loadAllSchedule();
|
|
2346
2484
|
case 9:
|
|
2347
2485
|
this.products.clearPriceCache();
|
|
2348
|
-
|
|
2486
|
+
_context30.next = 12;
|
|
2349
2487
|
return this.products.setupQuotationPriceBridge({
|
|
2350
2488
|
scheduleModule: this.schedule,
|
|
2351
2489
|
channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel
|
|
2352
2490
|
});
|
|
2353
2491
|
case 12:
|
|
2354
2492
|
this.logInfo('Products 报价单价格桥接初始化完成');
|
|
2355
|
-
|
|
2493
|
+
_context30.next = 19;
|
|
2356
2494
|
break;
|
|
2357
2495
|
case 15:
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
errorMessage =
|
|
2496
|
+
_context30.prev = 15;
|
|
2497
|
+
_context30.t0 = _context30["catch"](6);
|
|
2498
|
+
errorMessage = _context30.t0 instanceof Error ? _context30.t0.message : String(_context30.t0);
|
|
2361
2499
|
this.logError('Products 报价单价格桥接初始化失败', {
|
|
2362
2500
|
error: errorMessage
|
|
2363
2501
|
});
|
|
2364
2502
|
case 19:
|
|
2365
2503
|
case "end":
|
|
2366
|
-
return
|
|
2504
|
+
return _context30.stop();
|
|
2367
2505
|
}
|
|
2368
|
-
},
|
|
2506
|
+
}, _callee30, this, [[6, 15]]);
|
|
2369
2507
|
}));
|
|
2370
2508
|
function setupProductsQuotationPriceBridge() {
|
|
2371
2509
|
return _setupProductsQuotationPriceBridge.apply(this, arguments);
|
|
@@ -2434,45 +2572,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
2434
2572
|
}, {
|
|
2435
2573
|
key: "refreshProductsInBackground",
|
|
2436
2574
|
value: (function () {
|
|
2437
|
-
var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2575
|
+
var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
2438
2576
|
var startTime, duration, _duration2, errorMessage;
|
|
2439
|
-
return _regeneratorRuntime().wrap(function
|
|
2440
|
-
while (1) switch (
|
|
2577
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2578
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2441
2579
|
case 0:
|
|
2442
2580
|
if (this.products) {
|
|
2443
|
-
|
|
2581
|
+
_context31.next = 3;
|
|
2444
2582
|
break;
|
|
2445
2583
|
}
|
|
2446
2584
|
this.logWarning('refreshProductsInBackground: Products 模块未注册');
|
|
2447
|
-
return
|
|
2585
|
+
return _context31.abrupt("return");
|
|
2448
2586
|
case 3:
|
|
2449
2587
|
this.logInfo('refreshProductsInBackground 开始');
|
|
2450
2588
|
startTime = Date.now();
|
|
2451
|
-
|
|
2452
|
-
|
|
2589
|
+
_context31.prev = 5;
|
|
2590
|
+
_context31.next = 8;
|
|
2453
2591
|
return this.products.silentRefresh();
|
|
2454
2592
|
case 8:
|
|
2455
2593
|
duration = Date.now() - startTime;
|
|
2456
2594
|
this.logInfo('refreshProductsInBackground 完成', {
|
|
2457
2595
|
duration: "".concat(duration, "ms")
|
|
2458
2596
|
});
|
|
2459
|
-
|
|
2597
|
+
_context31.next = 18;
|
|
2460
2598
|
break;
|
|
2461
2599
|
case 12:
|
|
2462
|
-
|
|
2463
|
-
|
|
2600
|
+
_context31.prev = 12;
|
|
2601
|
+
_context31.t0 = _context31["catch"](5);
|
|
2464
2602
|
_duration2 = Date.now() - startTime;
|
|
2465
|
-
errorMessage =
|
|
2466
|
-
console.error('[Server] refreshProductsInBackground 失败:',
|
|
2603
|
+
errorMessage = _context31.t0 instanceof Error ? _context31.t0.message : String(_context31.t0);
|
|
2604
|
+
console.error('[Server] refreshProductsInBackground 失败:', _context31.t0);
|
|
2467
2605
|
this.logError('refreshProductsInBackground 失败', {
|
|
2468
2606
|
duration: "".concat(_duration2, "ms"),
|
|
2469
2607
|
error: errorMessage
|
|
2470
2608
|
});
|
|
2471
2609
|
case 18:
|
|
2472
2610
|
case "end":
|
|
2473
|
-
return
|
|
2611
|
+
return _context31.stop();
|
|
2474
2612
|
}
|
|
2475
|
-
},
|
|
2613
|
+
}, _callee31, this, [[5, 12]]);
|
|
2476
2614
|
}));
|
|
2477
2615
|
function refreshProductsInBackground() {
|
|
2478
2616
|
return _refreshProductsInBackground.apply(this, arguments);
|
|
@@ -2488,45 +2626,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
2488
2626
|
}, {
|
|
2489
2627
|
key: "refreshOrdersInBackground",
|
|
2490
2628
|
value: (function () {
|
|
2491
|
-
var _refreshOrdersInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2629
|
+
var _refreshOrdersInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
2492
2630
|
var startTime, duration, _duration3, errorMessage;
|
|
2493
|
-
return _regeneratorRuntime().wrap(function
|
|
2494
|
-
while (1) switch (
|
|
2631
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2632
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2495
2633
|
case 0:
|
|
2496
2634
|
if (this.order) {
|
|
2497
|
-
|
|
2635
|
+
_context32.next = 3;
|
|
2498
2636
|
break;
|
|
2499
2637
|
}
|
|
2500
2638
|
this.logWarning('refreshOrdersInBackground: Order 模块未注册');
|
|
2501
|
-
return
|
|
2639
|
+
return _context32.abrupt("return");
|
|
2502
2640
|
case 3:
|
|
2503
2641
|
this.logInfo('refreshOrdersInBackground 开始');
|
|
2504
2642
|
startTime = Date.now();
|
|
2505
|
-
|
|
2506
|
-
|
|
2643
|
+
_context32.prev = 5;
|
|
2644
|
+
_context32.next = 8;
|
|
2507
2645
|
return this.order.silentRefresh();
|
|
2508
2646
|
case 8:
|
|
2509
2647
|
duration = Date.now() - startTime;
|
|
2510
2648
|
this.logInfo('refreshOrdersInBackground 完成', {
|
|
2511
2649
|
duration: "".concat(duration, "ms")
|
|
2512
2650
|
});
|
|
2513
|
-
|
|
2651
|
+
_context32.next = 18;
|
|
2514
2652
|
break;
|
|
2515
2653
|
case 12:
|
|
2516
|
-
|
|
2517
|
-
|
|
2654
|
+
_context32.prev = 12;
|
|
2655
|
+
_context32.t0 = _context32["catch"](5);
|
|
2518
2656
|
_duration3 = Date.now() - startTime;
|
|
2519
|
-
errorMessage =
|
|
2520
|
-
console.error('[Server] refreshOrdersInBackground 失败:',
|
|
2657
|
+
errorMessage = _context32.t0 instanceof Error ? _context32.t0.message : String(_context32.t0);
|
|
2658
|
+
console.error('[Server] refreshOrdersInBackground 失败:', _context32.t0);
|
|
2521
2659
|
this.logError('refreshOrdersInBackground 失败', {
|
|
2522
2660
|
duration: "".concat(_duration3, "ms"),
|
|
2523
2661
|
error: errorMessage
|
|
2524
2662
|
});
|
|
2525
2663
|
case 18:
|
|
2526
2664
|
case "end":
|
|
2527
|
-
return
|
|
2665
|
+
return _context32.stop();
|
|
2528
2666
|
}
|
|
2529
|
-
},
|
|
2667
|
+
}, _callee32, this, [[5, 12]]);
|
|
2530
2668
|
}));
|
|
2531
2669
|
function refreshOrdersInBackground() {
|
|
2532
2670
|
return _refreshOrdersInBackground.apply(this, arguments);
|
|
@@ -2541,10 +2679,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
2541
2679
|
}, {
|
|
2542
2680
|
key: "clearAllIndexDB",
|
|
2543
2681
|
value: (function () {
|
|
2544
|
-
var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2682
|
+
var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
2545
2683
|
var clearTasks, moduleNames, errorMessage;
|
|
2546
|
-
return _regeneratorRuntime().wrap(function
|
|
2547
|
-
while (1) switch (
|
|
2684
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2685
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
2548
2686
|
case 0:
|
|
2549
2687
|
console.log('[Server] 开始清空所有模块的IndexedDB缓存...');
|
|
2550
2688
|
this.logInfo('开始清空所有模块的 IndexedDB 缓存');
|
|
@@ -2579,41 +2717,41 @@ var Server = /*#__PURE__*/function () {
|
|
|
2579
2717
|
moduleNames.push('FloorPlan');
|
|
2580
2718
|
}
|
|
2581
2719
|
if (!(clearTasks.length === 0)) {
|
|
2582
|
-
|
|
2720
|
+
_context33.next = 15;
|
|
2583
2721
|
break;
|
|
2584
2722
|
}
|
|
2585
2723
|
console.warn('[Server] 没有找到已注册的模块,无需清空');
|
|
2586
2724
|
this.logWarning('没有找到已注册的模块,无需清空 IndexedDB');
|
|
2587
|
-
return
|
|
2725
|
+
return _context33.abrupt("return");
|
|
2588
2726
|
case 15:
|
|
2589
2727
|
this.logInfo('准备清空模块缓存', {
|
|
2590
2728
|
moduleNames: moduleNames
|
|
2591
2729
|
});
|
|
2592
|
-
|
|
2593
|
-
|
|
2730
|
+
_context33.prev = 16;
|
|
2731
|
+
_context33.next = 19;
|
|
2594
2732
|
return Promise.all(clearTasks);
|
|
2595
2733
|
case 19:
|
|
2596
2734
|
console.log("[Server] \u2705 \u5DF2\u6210\u529F\u6E05\u7A7A\u6240\u6709\u6A21\u5757\u7684IndexedDB\u7F13\u5B58: ".concat(moduleNames.join(', ')));
|
|
2597
2735
|
this.logInfo('成功清空所有模块的 IndexedDB 缓存', {
|
|
2598
2736
|
moduleNames: moduleNames
|
|
2599
2737
|
});
|
|
2600
|
-
|
|
2738
|
+
_context33.next = 29;
|
|
2601
2739
|
break;
|
|
2602
2740
|
case 23:
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
errorMessage =
|
|
2606
|
-
console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:',
|
|
2741
|
+
_context33.prev = 23;
|
|
2742
|
+
_context33.t0 = _context33["catch"](16);
|
|
2743
|
+
errorMessage = _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0);
|
|
2744
|
+
console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context33.t0);
|
|
2607
2745
|
this.logError('清空 IndexedDB 缓存时发生错误', {
|
|
2608
2746
|
moduleNames: moduleNames,
|
|
2609
2747
|
error: errorMessage
|
|
2610
2748
|
});
|
|
2611
|
-
throw
|
|
2749
|
+
throw _context33.t0;
|
|
2612
2750
|
case 29:
|
|
2613
2751
|
case "end":
|
|
2614
|
-
return
|
|
2752
|
+
return _context33.stop();
|
|
2615
2753
|
}
|
|
2616
|
-
},
|
|
2754
|
+
}, _callee33, this, [[16, 23]]);
|
|
2617
2755
|
}));
|
|
2618
2756
|
function clearAllIndexDB() {
|
|
2619
2757
|
return _clearAllIndexDB.apply(this, arguments);
|
|
@@ -2688,10 +2826,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
2688
2826
|
}, {
|
|
2689
2827
|
key: "handleRoute",
|
|
2690
2828
|
value: (function () {
|
|
2691
|
-
var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2829
|
+
var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(method, path, params) {
|
|
2692
2830
|
var startTime, handler, result, duration, _duration4, errorMessage;
|
|
2693
|
-
return _regeneratorRuntime().wrap(function
|
|
2694
|
-
while (1) switch (
|
|
2831
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2832
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
2695
2833
|
case 0:
|
|
2696
2834
|
startTime = Date.now();
|
|
2697
2835
|
this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5F00\u59CB: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
@@ -2702,7 +2840,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2702
2840
|
});
|
|
2703
2841
|
handler = this.getRouteHandler(method, path);
|
|
2704
2842
|
if (handler) {
|
|
2705
|
-
|
|
2843
|
+
_context34.next = 6;
|
|
2706
2844
|
break;
|
|
2707
2845
|
}
|
|
2708
2846
|
this.logError("\u8DEF\u7531\u672A\u627E\u5230: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
@@ -2711,13 +2849,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
2711
2849
|
});
|
|
2712
2850
|
throw new Error("Route not found: ".concat(method.toUpperCase(), " ").concat(path));
|
|
2713
2851
|
case 6:
|
|
2714
|
-
|
|
2715
|
-
|
|
2852
|
+
_context34.prev = 6;
|
|
2853
|
+
_context34.next = 9;
|
|
2716
2854
|
return handler(_objectSpread(_objectSpread({}, params), {}, {
|
|
2717
2855
|
path: path
|
|
2718
2856
|
}));
|
|
2719
2857
|
case 9:
|
|
2720
|
-
result =
|
|
2858
|
+
result = _context34.sent;
|
|
2721
2859
|
duration = Date.now() - startTime;
|
|
2722
2860
|
this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5B8C\u6210: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
2723
2861
|
method: method.toUpperCase(),
|
|
@@ -2726,12 +2864,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
2726
2864
|
resultCode: result === null || result === void 0 ? void 0 : result.code,
|
|
2727
2865
|
resultStatus: result === null || result === void 0 ? void 0 : result.status
|
|
2728
2866
|
});
|
|
2729
|
-
return
|
|
2867
|
+
return _context34.abrupt("return", result);
|
|
2730
2868
|
case 15:
|
|
2731
|
-
|
|
2732
|
-
|
|
2869
|
+
_context34.prev = 15;
|
|
2870
|
+
_context34.t0 = _context34["catch"](6);
|
|
2733
2871
|
_duration4 = Date.now() - startTime;
|
|
2734
|
-
errorMessage =
|
|
2872
|
+
errorMessage = _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0);
|
|
2735
2873
|
this.logError("\u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
2736
2874
|
method: method.toUpperCase(),
|
|
2737
2875
|
path: path,
|
|
@@ -2739,15 +2877,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
2739
2877
|
error: errorMessage,
|
|
2740
2878
|
data: params.data
|
|
2741
2879
|
});
|
|
2742
|
-
console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path),
|
|
2743
|
-
throw
|
|
2880
|
+
console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context34.t0);
|
|
2881
|
+
throw _context34.t0;
|
|
2744
2882
|
case 22:
|
|
2745
2883
|
case "end":
|
|
2746
|
-
return
|
|
2884
|
+
return _context34.stop();
|
|
2747
2885
|
}
|
|
2748
|
-
},
|
|
2886
|
+
}, _callee34, this, [[6, 15]]);
|
|
2749
2887
|
}));
|
|
2750
|
-
function handleRoute(
|
|
2888
|
+
function handleRoute(_x33, _x34, _x35) {
|
|
2751
2889
|
return _handleRoute.apply(this, arguments);
|
|
2752
2890
|
}
|
|
2753
2891
|
return handleRoute;
|
|
@@ -2857,6 +2995,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
2857
2995
|
method: 'post',
|
|
2858
2996
|
path: '/shop/local/print-order',
|
|
2859
2997
|
handler: this.handleLocalPrintOrder.bind(this)
|
|
2998
|
+
}, {
|
|
2999
|
+
method: 'post',
|
|
3000
|
+
path: '/shop/machinecode/batch',
|
|
3001
|
+
handler: this.handleMachinecodeBatchMeta.bind(this)
|
|
3002
|
+
}, {
|
|
3003
|
+
method: 'post',
|
|
3004
|
+
path: '/machinecode/batch',
|
|
3005
|
+
handler: this.handleMachinecodeBatchMeta.bind(this)
|
|
2860
3006
|
}]);
|
|
2861
3007
|
this.registerPrefixRoutes([{
|
|
2862
3008
|
method: 'get',
|
|
@@ -2871,36 +3017,36 @@ var Server = /*#__PURE__*/function () {
|
|
|
2871
3017
|
}, {
|
|
2872
3018
|
key: "getPaymentRouteModule",
|
|
2873
3019
|
value: function () {
|
|
2874
|
-
var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3020
|
+
var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
|
|
2875
3021
|
var _this6 = this;
|
|
2876
|
-
return _regeneratorRuntime().wrap(function
|
|
2877
|
-
while (1) switch (
|
|
3022
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
3023
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
2878
3024
|
case 0:
|
|
2879
3025
|
if (!this.payment) {
|
|
2880
|
-
|
|
3026
|
+
_context36.next = 2;
|
|
2881
3027
|
break;
|
|
2882
3028
|
}
|
|
2883
|
-
return
|
|
3029
|
+
return _context36.abrupt("return", this.payment);
|
|
2884
3030
|
case 2:
|
|
2885
3031
|
if (!this.paymentRouteModule) {
|
|
2886
|
-
|
|
3032
|
+
_context36.next = 4;
|
|
2887
3033
|
break;
|
|
2888
3034
|
}
|
|
2889
|
-
return
|
|
3035
|
+
return _context36.abrupt("return", this.paymentRouteModule);
|
|
2890
3036
|
case 4:
|
|
2891
3037
|
if (!this.paymentRouteModuleInFlight) {
|
|
2892
|
-
|
|
3038
|
+
_context36.next = 6;
|
|
2893
3039
|
break;
|
|
2894
3040
|
}
|
|
2895
|
-
return
|
|
3041
|
+
return _context36.abrupt("return", this.paymentRouteModuleInFlight);
|
|
2896
3042
|
case 6:
|
|
2897
|
-
this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3043
|
+
this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
|
|
2898
3044
|
var module;
|
|
2899
|
-
return _regeneratorRuntime().wrap(function
|
|
2900
|
-
while (1) switch (
|
|
3045
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3046
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
2901
3047
|
case 0:
|
|
2902
3048
|
module = new PaymentServerModule('server_payment_route', '1.0.0');
|
|
2903
|
-
|
|
3049
|
+
_context35.next = 3;
|
|
2904
3050
|
return module.initialize(_this6.core, {
|
|
2905
3051
|
store: {
|
|
2906
3052
|
payMethods: []
|
|
@@ -2908,21 +3054,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
2908
3054
|
});
|
|
2909
3055
|
case 3:
|
|
2910
3056
|
_this6.paymentRouteModule = module;
|
|
2911
|
-
return
|
|
3057
|
+
return _context35.abrupt("return", module);
|
|
2912
3058
|
case 5:
|
|
2913
3059
|
case "end":
|
|
2914
|
-
return
|
|
3060
|
+
return _context35.stop();
|
|
2915
3061
|
}
|
|
2916
|
-
},
|
|
3062
|
+
}, _callee35);
|
|
2917
3063
|
}))().finally(function () {
|
|
2918
3064
|
_this6.paymentRouteModuleInFlight = undefined;
|
|
2919
3065
|
});
|
|
2920
|
-
return
|
|
3066
|
+
return _context36.abrupt("return", this.paymentRouteModuleInFlight);
|
|
2921
3067
|
case 8:
|
|
2922
3068
|
case "end":
|
|
2923
|
-
return
|
|
3069
|
+
return _context36.stop();
|
|
2924
3070
|
}
|
|
2925
|
-
},
|
|
3071
|
+
}, _callee36, this);
|
|
2926
3072
|
}));
|
|
2927
3073
|
function getPaymentRouteModule() {
|
|
2928
3074
|
return _getPaymentRouteModule.apply(this, arguments);
|
|
@@ -2932,19 +3078,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
2932
3078
|
}, {
|
|
2933
3079
|
key: "fetchQuotationAvailableFromAPI",
|
|
2934
3080
|
value: function () {
|
|
2935
|
-
var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2936
|
-
var _this$
|
|
3081
|
+
var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(data) {
|
|
3082
|
+
var _this$app7;
|
|
2937
3083
|
var requester;
|
|
2938
|
-
return _regeneratorRuntime().wrap(function
|
|
2939
|
-
while (1) switch (
|
|
3084
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3085
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
2940
3086
|
case 0:
|
|
2941
|
-
requester = ((_this$
|
|
3087
|
+
requester = ((_this$app7 = this.app) === null || _this$app7 === void 0 ? void 0 : _this$app7.request) || this.core.getPlugin('request');
|
|
2942
3088
|
if (requester !== null && requester !== void 0 && requester.get) {
|
|
2943
|
-
|
|
3089
|
+
_context37.next = 4;
|
|
2944
3090
|
break;
|
|
2945
3091
|
}
|
|
2946
3092
|
this.logError('fetchQuotationAvailableFromAPI: request 不可用');
|
|
2947
|
-
return
|
|
3093
|
+
return _context37.abrupt("return", {
|
|
2948
3094
|
code: 500,
|
|
2949
3095
|
message: 'request 不可用',
|
|
2950
3096
|
data: {
|
|
@@ -2953,14 +3099,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
2953
3099
|
status: false
|
|
2954
3100
|
});
|
|
2955
3101
|
case 4:
|
|
2956
|
-
return
|
|
3102
|
+
return _context37.abrupt("return", requester.get('/shop/quotation/available', data));
|
|
2957
3103
|
case 5:
|
|
2958
3104
|
case "end":
|
|
2959
|
-
return
|
|
3105
|
+
return _context37.stop();
|
|
2960
3106
|
}
|
|
2961
|
-
},
|
|
3107
|
+
}, _callee37, this);
|
|
2962
3108
|
}));
|
|
2963
|
-
function fetchQuotationAvailableFromAPI(
|
|
3109
|
+
function fetchQuotationAvailableFromAPI(_x36) {
|
|
2964
3110
|
return _fetchQuotationAvailableFromAPI.apply(this, arguments);
|
|
2965
3111
|
}
|
|
2966
3112
|
return fetchQuotationAvailableFromAPI;
|
|
@@ -3133,29 +3279,29 @@ var Server = /*#__PURE__*/function () {
|
|
|
3133
3279
|
}, {
|
|
3134
3280
|
key: "onScheduleTimePointTimerFire",
|
|
3135
3281
|
value: (function () {
|
|
3136
|
-
var _onScheduleTimePointTimerFire = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3282
|
+
var _onScheduleTimePointTimerFire = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(subscriberId, timerId) {
|
|
3137
3283
|
var subscriber;
|
|
3138
|
-
return _regeneratorRuntime().wrap(function
|
|
3139
|
-
while (1) switch (
|
|
3284
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3285
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3140
3286
|
case 0:
|
|
3141
3287
|
this.removeScheduleTimerRef(subscriberId, timerId);
|
|
3142
3288
|
if (this.productQuerySubscribers.has(subscriberId)) {
|
|
3143
|
-
|
|
3289
|
+
_context38.next = 3;
|
|
3144
3290
|
break;
|
|
3145
3291
|
}
|
|
3146
|
-
return
|
|
3292
|
+
return _context38.abrupt("return");
|
|
3147
3293
|
case 3:
|
|
3148
3294
|
subscriber = this.productQuerySubscribers.get(subscriberId);
|
|
3149
3295
|
this.refreshSubscriberScheduleAtExecution(subscriber);
|
|
3150
|
-
|
|
3296
|
+
_context38.next = 7;
|
|
3151
3297
|
return this.recomputeAndNotifySubscriber(subscriberId);
|
|
3152
3298
|
case 7:
|
|
3153
3299
|
case "end":
|
|
3154
|
-
return
|
|
3300
|
+
return _context38.stop();
|
|
3155
3301
|
}
|
|
3156
|
-
},
|
|
3302
|
+
}, _callee38, this);
|
|
3157
3303
|
}));
|
|
3158
|
-
function onScheduleTimePointTimerFire(
|
|
3304
|
+
function onScheduleTimePointTimerFire(_x37, _x38) {
|
|
3159
3305
|
return _onScheduleTimePointTimerFire.apply(this, arguments);
|
|
3160
3306
|
}
|
|
3161
3307
|
return onScheduleTimePointTimerFire;
|
|
@@ -3167,45 +3313,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
3167
3313
|
}, {
|
|
3168
3314
|
key: "recomputeAndNotifySubscriber",
|
|
3169
3315
|
value: (function () {
|
|
3170
|
-
var _recomputeAndNotifySubscriber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3316
|
+
var _recomputeAndNotifySubscriber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(subscriberId) {
|
|
3171
3317
|
var subscriber, result, errorMessage;
|
|
3172
|
-
return _regeneratorRuntime().wrap(function
|
|
3173
|
-
while (1) switch (
|
|
3318
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3319
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3174
3320
|
case 0:
|
|
3175
3321
|
subscriber = this.productQuerySubscribers.get(subscriberId);
|
|
3176
3322
|
if (subscriber) {
|
|
3177
|
-
|
|
3323
|
+
_context39.next = 3;
|
|
3178
3324
|
break;
|
|
3179
3325
|
}
|
|
3180
|
-
return
|
|
3326
|
+
return _context39.abrupt("return");
|
|
3181
3327
|
case 3:
|
|
3182
|
-
|
|
3183
|
-
|
|
3328
|
+
_context39.prev = 3;
|
|
3329
|
+
_context39.next = 6;
|
|
3184
3330
|
return this.computeProductQueryResult(subscriber.context);
|
|
3185
3331
|
case 6:
|
|
3186
|
-
result =
|
|
3332
|
+
result = _context39.sent;
|
|
3187
3333
|
subscriber.callback(result);
|
|
3188
3334
|
this.logInfo('recomputeAndNotifySubscriber: 已推送', {
|
|
3189
3335
|
subscriberId: subscriberId,
|
|
3190
3336
|
schedule_datetime: subscriber.context.schedule_datetime
|
|
3191
3337
|
});
|
|
3192
|
-
|
|
3338
|
+
_context39.next = 15;
|
|
3193
3339
|
break;
|
|
3194
3340
|
case 11:
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
errorMessage =
|
|
3341
|
+
_context39.prev = 11;
|
|
3342
|
+
_context39.t0 = _context39["catch"](3);
|
|
3343
|
+
errorMessage = _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0);
|
|
3198
3344
|
this.logError('recomputeAndNotifySubscriber: 推送失败', {
|
|
3199
3345
|
subscriberId: subscriberId,
|
|
3200
3346
|
error: errorMessage
|
|
3201
3347
|
});
|
|
3202
3348
|
case 15:
|
|
3203
3349
|
case "end":
|
|
3204
|
-
return
|
|
3350
|
+
return _context39.stop();
|
|
3205
3351
|
}
|
|
3206
|
-
},
|
|
3352
|
+
}, _callee39, this, [[3, 11]]);
|
|
3207
3353
|
}));
|
|
3208
|
-
function recomputeAndNotifySubscriber(
|
|
3354
|
+
function recomputeAndNotifySubscriber(_x39) {
|
|
3209
3355
|
return _recomputeAndNotifySubscriber.apply(this, arguments);
|
|
3210
3356
|
}
|
|
3211
3357
|
return recomputeAndNotifySubscriber;
|
|
@@ -3238,17 +3384,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
3238
3384
|
* const result = await this.handleSalesSearchRequest('single', '/shop/es/search/sales', { keyword: '1001' }, {})
|
|
3239
3385
|
*/
|
|
3240
3386
|
function () {
|
|
3241
|
-
var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3242
|
-
var queryPayload, result,
|
|
3243
|
-
return _regeneratorRuntime().wrap(function
|
|
3244
|
-
while (1) switch (
|
|
3387
|
+
var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(kind, backendPath, data, config) {
|
|
3388
|
+
var queryPayload, result, _ref55, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator6, _step6, orderId;
|
|
3389
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3390
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3245
3391
|
case 0:
|
|
3246
3392
|
queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
|
|
3247
|
-
|
|
3393
|
+
_context40.next = 3;
|
|
3248
3394
|
return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
|
|
3249
3395
|
case 3:
|
|
3250
|
-
result =
|
|
3251
|
-
|
|
3396
|
+
result = _context40.sent;
|
|
3397
|
+
_ref55 = config || {}, callback = _ref55.callback, subscriberId = _ref55.subscriberId, resetVisibleOrderIds = _ref55.resetVisibleOrderIds;
|
|
3252
3398
|
if (subscriberId && typeof callback === 'function') {
|
|
3253
3399
|
contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
|
|
3254
3400
|
existing = this.salesSearchSubscribers.get(subscriberId);
|
|
@@ -3279,14 +3425,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
3279
3425
|
visibleCount: visibleOrderIds.size
|
|
3280
3426
|
});
|
|
3281
3427
|
}
|
|
3282
|
-
return
|
|
3428
|
+
return _context40.abrupt("return", result);
|
|
3283
3429
|
case 7:
|
|
3284
3430
|
case "end":
|
|
3285
|
-
return
|
|
3431
|
+
return _context40.stop();
|
|
3286
3432
|
}
|
|
3287
|
-
},
|
|
3433
|
+
}, _callee40, this);
|
|
3288
3434
|
}));
|
|
3289
|
-
function handleSalesSearchRequest(
|
|
3435
|
+
function handleSalesSearchRequest(_x40, _x41, _x42, _x43) {
|
|
3290
3436
|
return _handleSalesSearchRequest.apply(this, arguments);
|
|
3291
3437
|
}
|
|
3292
3438
|
return handleSalesSearchRequest;
|
|
@@ -3301,20 +3447,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
3301
3447
|
}, {
|
|
3302
3448
|
key: "fetchSalesSearchFromAPI",
|
|
3303
3449
|
value: (function () {
|
|
3304
|
-
var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3305
|
-
var _this$
|
|
3306
|
-
var _response$
|
|
3307
|
-
return _regeneratorRuntime().wrap(function
|
|
3308
|
-
while (1) switch (
|
|
3450
|
+
var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(backendPath, data) {
|
|
3451
|
+
var _this$app8;
|
|
3452
|
+
var _response$data4, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
|
|
3453
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3454
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3309
3455
|
case 0:
|
|
3310
|
-
if ((_this$
|
|
3311
|
-
|
|
3456
|
+
if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
|
|
3457
|
+
_context41.next = 3;
|
|
3312
3458
|
break;
|
|
3313
3459
|
}
|
|
3314
3460
|
this.logError('fetchSalesSearchFromAPI: app.request 不可用', {
|
|
3315
3461
|
backendPath: backendPath
|
|
3316
3462
|
});
|
|
3317
|
-
return
|
|
3463
|
+
return _context41.abrupt("return", {
|
|
3318
3464
|
code: 500,
|
|
3319
3465
|
message: 'app.request 不可用',
|
|
3320
3466
|
data: backendPath === '/shop/es/search' ? {
|
|
@@ -3326,29 +3472,29 @@ var Server = /*#__PURE__*/function () {
|
|
|
3326
3472
|
status: false
|
|
3327
3473
|
});
|
|
3328
3474
|
case 3:
|
|
3329
|
-
|
|
3330
|
-
|
|
3475
|
+
_context41.prev = 3;
|
|
3476
|
+
_context41.next = 6;
|
|
3331
3477
|
return this.app.request.post(backendPath, data, {
|
|
3332
3478
|
isShopApi: true
|
|
3333
3479
|
});
|
|
3334
3480
|
case 6:
|
|
3335
|
-
response =
|
|
3336
|
-
_payload = (_response$
|
|
3337
|
-
return
|
|
3338
|
-
code: (_response$
|
|
3339
|
-
status: (_response$
|
|
3340
|
-
message: (_response$
|
|
3481
|
+
response = _context41.sent;
|
|
3482
|
+
_payload = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
|
|
3483
|
+
return _context41.abrupt("return", {
|
|
3484
|
+
code: (_response$code2 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code2 !== void 0 ? _response$code2 : 200,
|
|
3485
|
+
status: (_response$status2 = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status2 !== void 0 ? _response$status2 : true,
|
|
3486
|
+
message: (_response$message2 = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message2 !== void 0 ? _response$message2 : '',
|
|
3341
3487
|
data: _payload
|
|
3342
3488
|
});
|
|
3343
3489
|
case 11:
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
errorMessage =
|
|
3490
|
+
_context41.prev = 11;
|
|
3491
|
+
_context41.t0 = _context41["catch"](3);
|
|
3492
|
+
errorMessage = _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0);
|
|
3347
3493
|
this.logError('fetchSalesSearchFromAPI: 请求失败', {
|
|
3348
3494
|
backendPath: backendPath,
|
|
3349
3495
|
error: errorMessage
|
|
3350
3496
|
});
|
|
3351
|
-
return
|
|
3497
|
+
return _context41.abrupt("return", {
|
|
3352
3498
|
code: 500,
|
|
3353
3499
|
message: errorMessage,
|
|
3354
3500
|
data: backendPath === '/shop/es/search' ? {
|
|
@@ -3361,11 +3507,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3361
3507
|
});
|
|
3362
3508
|
case 16:
|
|
3363
3509
|
case "end":
|
|
3364
|
-
return
|
|
3510
|
+
return _context41.stop();
|
|
3365
3511
|
}
|
|
3366
|
-
},
|
|
3512
|
+
}, _callee41, this, [[3, 11]]);
|
|
3367
3513
|
}));
|
|
3368
|
-
function fetchSalesSearchFromAPI(
|
|
3514
|
+
function fetchSalesSearchFromAPI(_x44, _x45) {
|
|
3369
3515
|
return _fetchSalesSearchFromAPI.apply(this, arguments);
|
|
3370
3516
|
}
|
|
3371
3517
|
return fetchSalesSearchFromAPI;
|
|
@@ -3886,18 +4032,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
3886
4032
|
}, {
|
|
3887
4033
|
key: "fetchOrderListFromAPI",
|
|
3888
4034
|
value: (function () {
|
|
3889
|
-
var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3890
|
-
var _this$
|
|
3891
|
-
var _response$
|
|
3892
|
-
return _regeneratorRuntime().wrap(function
|
|
3893
|
-
while (1) switch (
|
|
4035
|
+
var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(data) {
|
|
4036
|
+
var _this$app9;
|
|
4037
|
+
var _response$data5, response, _payload2, list, count, errorMessage;
|
|
4038
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
4039
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
3894
4040
|
case 0:
|
|
3895
|
-
if ((_this$
|
|
3896
|
-
|
|
4041
|
+
if ((_this$app9 = this.app) !== null && _this$app9 !== void 0 && _this$app9.request) {
|
|
4042
|
+
_context42.next = 3;
|
|
3897
4043
|
break;
|
|
3898
4044
|
}
|
|
3899
4045
|
this.logError('fetchOrderListFromAPI: app.request 不可用');
|
|
3900
|
-
return
|
|
4046
|
+
return _context42.abrupt("return", {
|
|
3901
4047
|
code: 500,
|
|
3902
4048
|
message: 'app.request 不可用',
|
|
3903
4049
|
data: {
|
|
@@ -3907,17 +4053,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
3907
4053
|
status: false
|
|
3908
4054
|
});
|
|
3909
4055
|
case 3:
|
|
3910
|
-
|
|
3911
|
-
|
|
4056
|
+
_context42.prev = 3;
|
|
4057
|
+
_context42.next = 6;
|
|
3912
4058
|
return this.app.request.post('/shop/order/v2/list', data, {
|
|
3913
4059
|
isShopApi: true
|
|
3914
4060
|
});
|
|
3915
4061
|
case 6:
|
|
3916
|
-
response =
|
|
3917
|
-
_payload2 = (_response$
|
|
4062
|
+
response = _context42.sent;
|
|
4063
|
+
_payload2 = (_response$data5 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data5 !== void 0 ? _response$data5 : response;
|
|
3918
4064
|
list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
|
|
3919
4065
|
count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
|
|
3920
|
-
return
|
|
4066
|
+
return _context42.abrupt("return", {
|
|
3921
4067
|
code: 200,
|
|
3922
4068
|
data: _objectSpread(_objectSpread({}, _payload2), {}, {
|
|
3923
4069
|
list: list,
|
|
@@ -3927,13 +4073,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
3927
4073
|
status: true
|
|
3928
4074
|
});
|
|
3929
4075
|
case 13:
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
errorMessage =
|
|
4076
|
+
_context42.prev = 13;
|
|
4077
|
+
_context42.t0 = _context42["catch"](3);
|
|
4078
|
+
errorMessage = _context42.t0 instanceof Error ? _context42.t0.message : String(_context42.t0);
|
|
3933
4079
|
this.logError('fetchOrderListFromAPI: 请求失败', {
|
|
3934
4080
|
error: errorMessage
|
|
3935
4081
|
});
|
|
3936
|
-
return
|
|
4082
|
+
return _context42.abrupt("return", {
|
|
3937
4083
|
code: 500,
|
|
3938
4084
|
message: errorMessage,
|
|
3939
4085
|
data: {
|
|
@@ -3944,11 +4090,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3944
4090
|
});
|
|
3945
4091
|
case 18:
|
|
3946
4092
|
case "end":
|
|
3947
|
-
return
|
|
4093
|
+
return _context42.stop();
|
|
3948
4094
|
}
|
|
3949
|
-
},
|
|
4095
|
+
}, _callee42, this, [[3, 13]]);
|
|
3950
4096
|
}));
|
|
3951
|
-
function fetchOrderListFromAPI(
|
|
4097
|
+
function fetchOrderListFromAPI(_x46) {
|
|
3952
4098
|
return _fetchOrderListFromAPI.apply(this, arguments);
|
|
3953
4099
|
}
|
|
3954
4100
|
return fetchOrderListFromAPI;
|
|
@@ -3960,17 +4106,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
3960
4106
|
}, {
|
|
3961
4107
|
key: "fetchBookingListFromAPI",
|
|
3962
4108
|
value: (function () {
|
|
3963
|
-
var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4109
|
+
var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(data) {
|
|
3964
4110
|
var memoryCacheEnabled, withFields, requestPayload, cacheKey, cached, rawList, bookingResult, _bookingResult$list, errorMessage;
|
|
3965
|
-
return _regeneratorRuntime().wrap(function
|
|
3966
|
-
while (1) switch (
|
|
4111
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4112
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
3967
4113
|
case 0:
|
|
3968
4114
|
if (this.order) {
|
|
3969
|
-
|
|
4115
|
+
_context43.next = 3;
|
|
3970
4116
|
break;
|
|
3971
4117
|
}
|
|
3972
4118
|
this.logError('fetchBookingListFromAPI: Order 模块不可用');
|
|
3973
|
-
return
|
|
4119
|
+
return _context43.abrupt("return", {
|
|
3974
4120
|
code: 500,
|
|
3975
4121
|
message: 'Order 模块不可用',
|
|
3976
4122
|
data: {
|
|
@@ -3980,18 +4126,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
3980
4126
|
status: false
|
|
3981
4127
|
});
|
|
3982
4128
|
case 3:
|
|
3983
|
-
|
|
4129
|
+
_context43.prev = 3;
|
|
3984
4130
|
memoryCacheEnabled = this.isBookingRemoteMemoryCacheEnabled(data);
|
|
3985
4131
|
withFields = this.resolveBookingSalesWith(data);
|
|
3986
4132
|
requestPayload = this.normalizeBookingRemoteQueryPayload(data, withFields);
|
|
3987
4133
|
cacheKey = this.buildBookingRemoteCacheKey(requestPayload);
|
|
3988
4134
|
if (!memoryCacheEnabled) {
|
|
3989
|
-
|
|
4135
|
+
_context43.next = 13;
|
|
3990
4136
|
break;
|
|
3991
4137
|
}
|
|
3992
4138
|
cached = this.readBookingRemoteCache(cacheKey);
|
|
3993
4139
|
if (!cached) {
|
|
3994
|
-
|
|
4140
|
+
_context43.next = 13;
|
|
3995
4141
|
break;
|
|
3996
4142
|
}
|
|
3997
4143
|
this.logInfo('fetchBookingListFromAPI: 命中内存缓存', {
|
|
@@ -3999,14 +4145,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
3999
4145
|
listCount: cached.bookingResult.count,
|
|
4000
4146
|
withFields: cached.withFields
|
|
4001
4147
|
});
|
|
4002
|
-
return
|
|
4148
|
+
return _context43.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
|
|
4003
4149
|
cache_hit: true
|
|
4004
4150
|
}));
|
|
4005
4151
|
case 13:
|
|
4006
|
-
|
|
4152
|
+
_context43.next = 15;
|
|
4007
4153
|
return this.order.fetchOrdersBySSE(requestPayload);
|
|
4008
4154
|
case 15:
|
|
4009
|
-
rawList =
|
|
4155
|
+
rawList = _context43.sent;
|
|
4010
4156
|
bookingResult = sortBookings(filterBookingsFromOrders(rawList, data), data); // DEBUG: 挂到 window 上方便排查 SSE → 日历数据丢失问题
|
|
4011
4157
|
if (typeof globalThis !== 'undefined') {
|
|
4012
4158
|
globalThis.__SSE_BOOKING_DEBUG__ = {
|
|
@@ -4053,15 +4199,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
4053
4199
|
cacheKey: cacheKey,
|
|
4054
4200
|
withFields: withFields
|
|
4055
4201
|
});
|
|
4056
|
-
return
|
|
4202
|
+
return _context43.abrupt("return", this.buildBookingResponse(bookingResult));
|
|
4057
4203
|
case 23:
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
errorMessage =
|
|
4204
|
+
_context43.prev = 23;
|
|
4205
|
+
_context43.t0 = _context43["catch"](3);
|
|
4206
|
+
errorMessage = _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0);
|
|
4061
4207
|
this.logError('fetchBookingListFromAPI: SSE 请求失败', {
|
|
4062
4208
|
error: errorMessage
|
|
4063
4209
|
});
|
|
4064
|
-
return
|
|
4210
|
+
return _context43.abrupt("return", {
|
|
4065
4211
|
code: 500,
|
|
4066
4212
|
message: errorMessage,
|
|
4067
4213
|
data: {
|
|
@@ -4072,11 +4218,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4072
4218
|
});
|
|
4073
4219
|
case 28:
|
|
4074
4220
|
case "end":
|
|
4075
|
-
return
|
|
4221
|
+
return _context43.stop();
|
|
4076
4222
|
}
|
|
4077
|
-
},
|
|
4223
|
+
}, _callee43, this, [[3, 23]]);
|
|
4078
4224
|
}));
|
|
4079
|
-
function fetchBookingListFromAPI(
|
|
4225
|
+
function fetchBookingListFromAPI(_x47) {
|
|
4080
4226
|
return _fetchBookingListFromAPI.apply(this, arguments);
|
|
4081
4227
|
}
|
|
4082
4228
|
return fetchBookingListFromAPI;
|
|
@@ -4084,24 +4230,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
4084
4230
|
}, {
|
|
4085
4231
|
key: "getDeviceTaskPlugin",
|
|
4086
4232
|
value: function getDeviceTaskPlugin() {
|
|
4087
|
-
var _this$
|
|
4088
|
-
return ((_this$
|
|
4233
|
+
var _this$app10, _this$app10$getPlugin;
|
|
4234
|
+
return ((_this$app10 = this.app) === null || _this$app10 === void 0 || (_this$app10$getPlugin = _this$app10.getPlugin) === null || _this$app10$getPlugin === void 0 ? void 0 : _this$app10$getPlugin.call(_this$app10, 'deviceTask')) || null;
|
|
4089
4235
|
}
|
|
4090
4236
|
}, {
|
|
4091
4237
|
key: "getIdGeneratorPlugin",
|
|
4092
4238
|
value: function getIdGeneratorPlugin() {
|
|
4093
|
-
var _this$
|
|
4094
|
-
return ((_this$
|
|
4239
|
+
var _this$app11, _this$app11$getPlugin;
|
|
4240
|
+
return ((_this$app11 = this.app) === null || _this$app11 === void 0 || (_this$app11$getPlugin = _this$app11.getPlugin) === null || _this$app11$getPlugin === void 0 ? void 0 : _this$app11$getPlugin.call(_this$app11, 'idGenerator')) || null;
|
|
4095
4241
|
}
|
|
4096
4242
|
}, {
|
|
4097
4243
|
key: "getAppData",
|
|
4098
4244
|
value: function getAppData(key) {
|
|
4099
|
-
var _this$core$getPlugin, _this$core$getPlugin$, _this$
|
|
4245
|
+
var _this$core$getPlugin, _this$core$getPlugin$, _this$app12, _this$app12$getData, _this$app13, _this$app13$getStore, _this$app13$getStore$, _this$app13$getStore$2, _this$app14, _this$app14$getStore, _this$app14$getStore$, _this$app14$getStore$2, _this$app15, _this$app15$getStore, _this$app15$getStore$, _this$app15$getStore$2;
|
|
4100
4246
|
var getData = (_this$core$getPlugin = this.core.getPlugin('app')) === null || _this$core$getPlugin === void 0 || (_this$core$getPlugin$ = _this$core$getPlugin.getData) === null || _this$core$getPlugin$ === void 0 ? void 0 : _this$core$getPlugin$.call(_this$core$getPlugin);
|
|
4101
4247
|
if (typeof getData === 'function') return getData(key);
|
|
4102
|
-
var directValue = (_this$
|
|
4248
|
+
var directValue = (_this$app12 = this.app) === null || _this$app12 === void 0 || (_this$app12$getData = _this$app12.getData) === null || _this$app12$getData === void 0 ? void 0 : _this$app12$getData.call(_this$app12, key);
|
|
4103
4249
|
if (directValue !== undefined) return directValue;
|
|
4104
|
-
var coreData = ((_this$
|
|
4250
|
+
var coreData = ((_this$app13 = this.app) === null || _this$app13 === void 0 || (_this$app13 = _this$app13.models) === null || _this$app13 === void 0 || (_this$app13$getStore = _this$app13.getStore) === null || _this$app13$getStore === void 0 || (_this$app13$getStore$ = (_this$app13$getStore$2 = _this$app13$getStore.call(_this$app13)).getDataByModel) === null || _this$app13$getStore$ === void 0 ? void 0 : _this$app13$getStore$.call(_this$app13$getStore$2, 'core', 'core')) || ((_this$app14 = this.app) === null || _this$app14 === void 0 || (_this$app14 = _this$app14.data) === null || _this$app14 === void 0 || (_this$app14 = _this$app14.store) === null || _this$app14 === void 0 || (_this$app14$getStore = _this$app14.getStore) === null || _this$app14$getStore === void 0 || (_this$app14$getStore$ = (_this$app14$getStore$2 = _this$app14$getStore.call(_this$app14)).getDataByModel) === null || _this$app14$getStore$ === void 0 ? void 0 : _this$app14$getStore$.call(_this$app14$getStore$2, 'core', 'core')) || ((_this$app15 = this.app) === null || _this$app15 === void 0 || (_this$app15 = _this$app15.data) === null || _this$app15 === void 0 || (_this$app15 = _this$app15.store) === null || _this$app15 === void 0 || (_this$app15$getStore = _this$app15.getStore) === null || _this$app15$getStore === void 0 || (_this$app15$getStore$ = (_this$app15$getStore$2 = _this$app15$getStore.call(_this$app15)).getDataByModel) === null || _this$app15$getStore$ === void 0 || (_this$app15$getStore$ = _this$app15$getStore$.call(_this$app15$getStore$2, 'core')) === null || _this$app15$getStore$ === void 0 ? void 0 : _this$app15$getStore$.core);
|
|
4105
4251
|
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
4106
4252
|
}
|
|
4107
4253
|
}, {
|
|
@@ -4152,32 +4298,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
4152
4298
|
}, {
|
|
4153
4299
|
key: "getShortNumberOrDeviceId",
|
|
4154
4300
|
value: function () {
|
|
4155
|
-
var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4301
|
+
var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
|
|
4156
4302
|
var getAsyncIotDeviceInfo, res;
|
|
4157
|
-
return _regeneratorRuntime().wrap(function
|
|
4158
|
-
while (1) switch (
|
|
4303
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4304
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
4159
4305
|
case 0:
|
|
4160
4306
|
getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
|
|
4161
4307
|
if (!getAsyncIotDeviceInfo) {
|
|
4162
|
-
|
|
4308
|
+
_context44.next = 7;
|
|
4163
4309
|
break;
|
|
4164
4310
|
}
|
|
4165
|
-
|
|
4311
|
+
_context44.next = 4;
|
|
4166
4312
|
return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
|
|
4167
4313
|
case 4:
|
|
4168
|
-
res =
|
|
4314
|
+
res = _context44.sent;
|
|
4169
4315
|
if (!(res !== null && res !== void 0 && res.short_number)) {
|
|
4170
|
-
|
|
4316
|
+
_context44.next = 7;
|
|
4171
4317
|
break;
|
|
4172
4318
|
}
|
|
4173
|
-
return
|
|
4319
|
+
return _context44.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
|
|
4174
4320
|
case 7:
|
|
4175
|
-
return
|
|
4321
|
+
return _context44.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
|
|
4176
4322
|
case 8:
|
|
4177
4323
|
case "end":
|
|
4178
|
-
return
|
|
4324
|
+
return _context44.stop();
|
|
4179
4325
|
}
|
|
4180
|
-
},
|
|
4326
|
+
}, _callee44, this);
|
|
4181
4327
|
}));
|
|
4182
4328
|
function getShortNumberOrDeviceId() {
|
|
4183
4329
|
return _getShortNumberOrDeviceId.apply(this, arguments);
|
|
@@ -4204,16 +4350,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
4204
4350
|
}, {
|
|
4205
4351
|
key: "normalizeCheckoutSubmitData",
|
|
4206
4352
|
value: function () {
|
|
4207
|
-
var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4353
|
+
var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(data, title) {
|
|
4208
4354
|
var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
|
|
4209
|
-
return _regeneratorRuntime().wrap(function
|
|
4210
|
-
while (1) switch (
|
|
4355
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
4356
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4211
4357
|
case 0:
|
|
4212
4358
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
4213
|
-
|
|
4359
|
+
_context45.next = 2;
|
|
4214
4360
|
break;
|
|
4215
4361
|
}
|
|
4216
|
-
return
|
|
4362
|
+
return _context45.abrupt("return", data);
|
|
4217
4363
|
case 2:
|
|
4218
4364
|
next = _objectSpread({}, data);
|
|
4219
4365
|
externalSaleNumber = next.external_sale_number;
|
|
@@ -4223,7 +4369,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4223
4369
|
delete next.vouchers;
|
|
4224
4370
|
hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
|
|
4225
4371
|
if (!hasCheckoutOrderNumbers) {
|
|
4226
|
-
|
|
4372
|
+
_context45.next = 11;
|
|
4227
4373
|
break;
|
|
4228
4374
|
}
|
|
4229
4375
|
this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
|
|
@@ -4233,10 +4379,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
4233
4379
|
shop_order_number: next.shop_order_number,
|
|
4234
4380
|
shop_full_order_number: next.shop_full_order_number
|
|
4235
4381
|
});
|
|
4236
|
-
return
|
|
4382
|
+
return _context45.abrupt("return", next);
|
|
4237
4383
|
case 11:
|
|
4238
4384
|
if (!this.isBlankCheckoutValue(externalSaleNumber)) {
|
|
4239
|
-
|
|
4385
|
+
_context45.next = 14;
|
|
4240
4386
|
break;
|
|
4241
4387
|
}
|
|
4242
4388
|
if (shouldClearLocalOrderId) {
|
|
@@ -4245,10 +4391,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
4245
4391
|
order_id: next.order_id
|
|
4246
4392
|
});
|
|
4247
4393
|
}
|
|
4248
|
-
return
|
|
4394
|
+
return _context45.abrupt("return", next);
|
|
4249
4395
|
case 14:
|
|
4250
4396
|
if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
|
|
4251
|
-
|
|
4397
|
+
_context45.next = 17;
|
|
4252
4398
|
break;
|
|
4253
4399
|
}
|
|
4254
4400
|
if (shouldClearLocalOrderId) {
|
|
@@ -4257,12 +4403,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
4257
4403
|
external_sale_number: externalSaleNumber
|
|
4258
4404
|
});
|
|
4259
4405
|
}
|
|
4260
|
-
return
|
|
4406
|
+
return _context45.abrupt("return", next);
|
|
4261
4407
|
case 17:
|
|
4262
|
-
|
|
4408
|
+
_context45.prev = 17;
|
|
4263
4409
|
localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
|
|
4264
4410
|
if (localOrder) {
|
|
4265
|
-
|
|
4411
|
+
_context45.next = 22;
|
|
4266
4412
|
break;
|
|
4267
4413
|
}
|
|
4268
4414
|
if (shouldClearLocalOrderId) {
|
|
@@ -4272,7 +4418,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4272
4418
|
localOrderFound: false
|
|
4273
4419
|
});
|
|
4274
4420
|
}
|
|
4275
|
-
return
|
|
4421
|
+
return _context45.abrupt("return", next);
|
|
4276
4422
|
case 22:
|
|
4277
4423
|
if (this.isBlankCheckoutValue(next.shop_order_number)) {
|
|
4278
4424
|
next.shop_order_number = localOrder.shop_order_number;
|
|
@@ -4289,23 +4435,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
4289
4435
|
shop_full_order_number: next.shop_full_order_number
|
|
4290
4436
|
});
|
|
4291
4437
|
// 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
|
|
4292
|
-
return
|
|
4438
|
+
return _context45.abrupt("return", next);
|
|
4293
4439
|
case 28:
|
|
4294
|
-
|
|
4295
|
-
|
|
4440
|
+
_context45.prev = 28;
|
|
4441
|
+
_context45.t0 = _context45["catch"](17);
|
|
4296
4442
|
this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
|
|
4297
4443
|
external_sale_number: externalSaleNumber,
|
|
4298
|
-
error: this.getUnknownErrorMessage(
|
|
4299
|
-
error_detail: this.normalizeUnknownError(
|
|
4444
|
+
error: this.getUnknownErrorMessage(_context45.t0),
|
|
4445
|
+
error_detail: this.normalizeUnknownError(_context45.t0)
|
|
4300
4446
|
});
|
|
4301
|
-
return
|
|
4447
|
+
return _context45.abrupt("return", next);
|
|
4302
4448
|
case 32:
|
|
4303
4449
|
case "end":
|
|
4304
|
-
return
|
|
4450
|
+
return _context45.stop();
|
|
4305
4451
|
}
|
|
4306
|
-
},
|
|
4452
|
+
}, _callee45, this, [[17, 28]]);
|
|
4307
4453
|
}));
|
|
4308
|
-
function normalizeCheckoutSubmitData(
|
|
4454
|
+
function normalizeCheckoutSubmitData(_x48, _x49) {
|
|
4309
4455
|
return _normalizeCheckoutSubmitData.apply(this, arguments);
|
|
4310
4456
|
}
|
|
4311
4457
|
return normalizeCheckoutSubmitData;
|
|
@@ -4313,81 +4459,81 @@ var Server = /*#__PURE__*/function () {
|
|
|
4313
4459
|
}, {
|
|
4314
4460
|
key: "ensureCheckoutOrderNumbers",
|
|
4315
4461
|
value: function () {
|
|
4316
|
-
var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4462
|
+
var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(data, title) {
|
|
4317
4463
|
var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
|
|
4318
|
-
return _regeneratorRuntime().wrap(function
|
|
4319
|
-
while (1) switch (
|
|
4464
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
4465
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4320
4466
|
case 0:
|
|
4321
4467
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
4322
|
-
|
|
4468
|
+
_context46.next = 2;
|
|
4323
4469
|
break;
|
|
4324
4470
|
}
|
|
4325
|
-
return
|
|
4471
|
+
return _context46.abrupt("return", data);
|
|
4326
4472
|
case 2:
|
|
4327
4473
|
next = _objectSpread({}, data);
|
|
4328
4474
|
needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
|
|
4329
4475
|
needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
|
|
4330
4476
|
if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
|
|
4331
|
-
|
|
4477
|
+
_context46.next = 7;
|
|
4332
4478
|
break;
|
|
4333
4479
|
}
|
|
4334
|
-
return
|
|
4480
|
+
return _context46.abrupt("return", next);
|
|
4335
4481
|
case 7:
|
|
4336
4482
|
idGenerator = this.getIdGeneratorPlugin();
|
|
4337
4483
|
if (idGenerator) {
|
|
4338
|
-
|
|
4484
|
+
_context46.next = 11;
|
|
4339
4485
|
break;
|
|
4340
4486
|
}
|
|
4341
4487
|
this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
|
|
4342
4488
|
needsShopOrderNumber: needsShopOrderNumber,
|
|
4343
4489
|
needsShopFullOrderNumber: needsShopFullOrderNumber
|
|
4344
4490
|
});
|
|
4345
|
-
return
|
|
4491
|
+
return _context46.abrupt("return", next);
|
|
4346
4492
|
case 11:
|
|
4347
|
-
|
|
4493
|
+
_context46.prev = 11;
|
|
4348
4494
|
if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
|
|
4349
|
-
|
|
4495
|
+
_context46.next = 16;
|
|
4350
4496
|
break;
|
|
4351
4497
|
}
|
|
4352
|
-
|
|
4498
|
+
_context46.next = 15;
|
|
4353
4499
|
return idGenerator.generateShopOrderNumber({
|
|
4354
4500
|
biz: next.business_code || 'ticket'
|
|
4355
4501
|
});
|
|
4356
4502
|
case 15:
|
|
4357
|
-
next.shop_order_number =
|
|
4503
|
+
next.shop_order_number = _context46.sent;
|
|
4358
4504
|
case 16:
|
|
4359
4505
|
if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
|
|
4360
|
-
|
|
4506
|
+
_context46.next = 20;
|
|
4361
4507
|
break;
|
|
4362
4508
|
}
|
|
4363
|
-
|
|
4509
|
+
_context46.next = 19;
|
|
4364
4510
|
return idGenerator.generateReceiptId({
|
|
4365
4511
|
biz: next.business_code || 'ticket'
|
|
4366
4512
|
});
|
|
4367
4513
|
case 19:
|
|
4368
|
-
next.shop_full_order_number =
|
|
4514
|
+
next.shop_full_order_number = _context46.sent;
|
|
4369
4515
|
case 20:
|
|
4370
4516
|
this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
|
|
4371
4517
|
shop_order_number: next.shop_order_number,
|
|
4372
4518
|
shop_full_order_number: next.shop_full_order_number
|
|
4373
4519
|
});
|
|
4374
|
-
|
|
4520
|
+
_context46.next = 26;
|
|
4375
4521
|
break;
|
|
4376
4522
|
case 23:
|
|
4377
|
-
|
|
4378
|
-
|
|
4523
|
+
_context46.prev = 23;
|
|
4524
|
+
_context46.t0 = _context46["catch"](11);
|
|
4379
4525
|
this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
|
|
4380
|
-
error:
|
|
4526
|
+
error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
|
|
4381
4527
|
});
|
|
4382
4528
|
case 26:
|
|
4383
|
-
return
|
|
4529
|
+
return _context46.abrupt("return", next);
|
|
4384
4530
|
case 27:
|
|
4385
4531
|
case "end":
|
|
4386
|
-
return
|
|
4532
|
+
return _context46.stop();
|
|
4387
4533
|
}
|
|
4388
|
-
},
|
|
4534
|
+
}, _callee46, this, [[11, 23]]);
|
|
4389
4535
|
}));
|
|
4390
|
-
function ensureCheckoutOrderNumbers(
|
|
4536
|
+
function ensureCheckoutOrderNumbers(_x50, _x51) {
|
|
4391
4537
|
return _ensureCheckoutOrderNumbers.apply(this, arguments);
|
|
4392
4538
|
}
|
|
4393
4539
|
return ensureCheckoutOrderNumbers;
|
|
@@ -4395,27 +4541,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
4395
4541
|
}, {
|
|
4396
4542
|
key: "dispatchCheckoutSyncTask",
|
|
4397
4543
|
value: function () {
|
|
4398
|
-
var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4544
|
+
var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
|
|
4399
4545
|
var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
|
|
4400
|
-
return _regeneratorRuntime().wrap(function
|
|
4401
|
-
while (1) switch (
|
|
4546
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
4547
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4402
4548
|
case 0:
|
|
4403
4549
|
this.registerDeviceTaskActions();
|
|
4404
4550
|
deviceTask = this.getDeviceTaskPlugin();
|
|
4405
|
-
|
|
4551
|
+
_context47.next = 4;
|
|
4406
4552
|
return this.getShortNumberOrDeviceId();
|
|
4407
4553
|
case 4:
|
|
4408
|
-
debugDeviceId =
|
|
4554
|
+
debugDeviceId = _context47.sent;
|
|
4409
4555
|
debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
|
|
4410
4556
|
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
4411
|
-
|
|
4557
|
+
_context47.next = 9;
|
|
4412
4558
|
break;
|
|
4413
4559
|
}
|
|
4414
4560
|
this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
|
|
4415
|
-
return
|
|
4561
|
+
return _context47.abrupt("return");
|
|
4416
4562
|
case 9:
|
|
4417
|
-
|
|
4418
|
-
|
|
4563
|
+
_context47.prev = 9;
|
|
4564
|
+
_context47.next = 12;
|
|
4419
4565
|
return deviceTask.dispatch({
|
|
4420
4566
|
action: 'sync_sales',
|
|
4421
4567
|
device_id: debugDeviceId,
|
|
@@ -4433,27 +4579,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
4433
4579
|
source_id: ((_params$data2 = params.data) === null || _params$data2 === void 0 ? void 0 : _params$data2.order_id) || ((_params$data3 = params.data) === null || _params$data3 === void 0 ? void 0 : _params$data3.external_sale_number) || ((_params$data4 = params.data) === null || _params$data4 === void 0 ? void 0 : _params$data4.shop_order_number)
|
|
4434
4580
|
});
|
|
4435
4581
|
case 12:
|
|
4436
|
-
result =
|
|
4582
|
+
result = _context47.sent;
|
|
4437
4583
|
this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
|
|
4438
4584
|
uuid: result === null || result === void 0 ? void 0 : result.uuid,
|
|
4439
4585
|
status: result === null || result === void 0 ? void 0 : result.status,
|
|
4440
4586
|
reused: result === null || result === void 0 ? void 0 : result.reused
|
|
4441
4587
|
});
|
|
4442
|
-
|
|
4588
|
+
_context47.next = 19;
|
|
4443
4589
|
break;
|
|
4444
4590
|
case 16:
|
|
4445
|
-
|
|
4446
|
-
|
|
4591
|
+
_context47.prev = 16;
|
|
4592
|
+
_context47.t0 = _context47["catch"](9);
|
|
4447
4593
|
this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
|
|
4448
|
-
error:
|
|
4594
|
+
error: _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0)
|
|
4449
4595
|
});
|
|
4450
4596
|
case 19:
|
|
4451
4597
|
case "end":
|
|
4452
|
-
return
|
|
4598
|
+
return _context47.stop();
|
|
4453
4599
|
}
|
|
4454
|
-
},
|
|
4600
|
+
}, _callee47, this, [[9, 16]]);
|
|
4455
4601
|
}));
|
|
4456
|
-
function dispatchCheckoutSyncTask(
|
|
4602
|
+
function dispatchCheckoutSyncTask(_x52) {
|
|
4457
4603
|
return _dispatchCheckoutSyncTask.apply(this, arguments);
|
|
4458
4604
|
}
|
|
4459
4605
|
return dispatchCheckoutSyncTask;
|
|
@@ -4461,34 +4607,36 @@ var Server = /*#__PURE__*/function () {
|
|
|
4461
4607
|
}, {
|
|
4462
4608
|
key: "dispatchPrintOtherReceiptTask",
|
|
4463
4609
|
value: function () {
|
|
4464
|
-
var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4610
|
+
var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
|
|
4465
4611
|
var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
|
|
4466
|
-
return _regeneratorRuntime().wrap(function
|
|
4467
|
-
while (1) switch (
|
|
4612
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
4613
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4468
4614
|
case 0:
|
|
4469
4615
|
deviceTask = this.getDeviceTaskPlugin();
|
|
4470
4616
|
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
4471
|
-
|
|
4617
|
+
_context48.next = 4;
|
|
4472
4618
|
break;
|
|
4473
4619
|
}
|
|
4474
4620
|
this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
|
|
4475
|
-
return
|
|
4621
|
+
return _context48.abrupt("return");
|
|
4476
4622
|
case 4:
|
|
4477
|
-
|
|
4623
|
+
_context48.prev = 4;
|
|
4478
4624
|
printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
|
|
4479
|
-
|
|
4625
|
+
_context48.next = 8;
|
|
4480
4626
|
return this.getShortNumberOrDeviceId();
|
|
4481
4627
|
case 8:
|
|
4482
|
-
deviceId =
|
|
4483
|
-
|
|
4628
|
+
deviceId = _context48.sent;
|
|
4629
|
+
_context48.next = 11;
|
|
4484
4630
|
return deviceTask.dispatch({
|
|
4485
4631
|
action: 'print_all',
|
|
4486
4632
|
device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
|
|
4487
4633
|
payload: {
|
|
4488
|
-
type: params.
|
|
4634
|
+
type: params.isManualPrint ? '0' : '99',
|
|
4489
4635
|
data: params.receiptOnly ? {
|
|
4490
4636
|
order_id: printIdentity,
|
|
4491
|
-
small_ticket_data: (_params$syncedOrder = params.syncedOrder) === null || _params$syncedOrder === void 0 || (_params$syncedOrder = _params$syncedOrder.payment_info) === null || _params$syncedOrder === void 0 ? void 0 : _params$syncedOrder.small_ticket_data
|
|
4637
|
+
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,
|
|
4638
|
+
skip_wristband: true,
|
|
4639
|
+
skip_voucher: true
|
|
4492
4640
|
} : {
|
|
4493
4641
|
order_id: printIdentity,
|
|
4494
4642
|
machine_code_print_info: (_params$syncedOrder2 = params.syncedOrder) === null || _params$syncedOrder2 === void 0 || (_params$syncedOrder2 = _params$syncedOrder2.payment_info) === null || _params$syncedOrder2 === void 0 ? void 0 : _params$syncedOrder2.machine_code_print_info,
|
|
@@ -4499,27 +4647,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
4499
4647
|
idempotency_key: this.buildPrintOtherReceiptIdempotencyKey(params.syncedOrder, {
|
|
4500
4648
|
receiptOnly: params.receiptOnly
|
|
4501
4649
|
}),
|
|
4502
|
-
name: '
|
|
4650
|
+
name: 'PRINT_V1',
|
|
4503
4651
|
source: 'server',
|
|
4504
4652
|
source_type: 'order',
|
|
4505
4653
|
source_id: printIdentity
|
|
4506
4654
|
});
|
|
4507
4655
|
case 11:
|
|
4508
|
-
|
|
4656
|
+
_context48.next = 16;
|
|
4509
4657
|
break;
|
|
4510
4658
|
case 13:
|
|
4511
|
-
|
|
4512
|
-
|
|
4659
|
+
_context48.prev = 13;
|
|
4660
|
+
_context48.t0 = _context48["catch"](4);
|
|
4513
4661
|
this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
|
|
4514
|
-
error:
|
|
4662
|
+
error: _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0)
|
|
4515
4663
|
});
|
|
4516
4664
|
case 16:
|
|
4517
4665
|
case "end":
|
|
4518
|
-
return
|
|
4666
|
+
return _context48.stop();
|
|
4519
4667
|
}
|
|
4520
|
-
},
|
|
4668
|
+
}, _callee48, this, [[4, 13]]);
|
|
4521
4669
|
}));
|
|
4522
|
-
function dispatchPrintOtherReceiptTask(
|
|
4670
|
+
function dispatchPrintOtherReceiptTask(_x53) {
|
|
4523
4671
|
return _dispatchPrintOtherReceiptTask.apply(this, arguments);
|
|
4524
4672
|
}
|
|
4525
4673
|
return dispatchPrintOtherReceiptTask;
|
|
@@ -4539,32 +4687,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
4539
4687
|
}, {
|
|
4540
4688
|
key: "dispatchLocalReceiptPrint",
|
|
4541
4689
|
value: function () {
|
|
4542
|
-
var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4690
|
+
var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
|
|
4543
4691
|
var _payment_info;
|
|
4544
4692
|
var printableOrder;
|
|
4545
|
-
return _regeneratorRuntime().wrap(function
|
|
4546
|
-
while (1) switch (
|
|
4693
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
4694
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
4547
4695
|
case 0:
|
|
4548
4696
|
if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
|
|
4549
|
-
|
|
4697
|
+
_context49.next = 2;
|
|
4550
4698
|
break;
|
|
4551
4699
|
}
|
|
4552
|
-
return
|
|
4700
|
+
return _context49.abrupt("return", {
|
|
4553
4701
|
printed: false,
|
|
4554
4702
|
order: params.order
|
|
4555
4703
|
});
|
|
4556
4704
|
case 2:
|
|
4557
|
-
|
|
4705
|
+
_context49.next = 4;
|
|
4558
4706
|
return this.withLocalSmallTicketData(params.order, {
|
|
4559
4707
|
requireFullyPaid: params.requireFullyPaid
|
|
4560
4708
|
});
|
|
4561
4709
|
case 4:
|
|
4562
|
-
printableOrder =
|
|
4710
|
+
printableOrder = _context49.sent;
|
|
4563
4711
|
if (hasSmallTicketData((_payment_info = printableOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data)) {
|
|
4564
|
-
|
|
4712
|
+
_context49.next = 7;
|
|
4565
4713
|
break;
|
|
4566
4714
|
}
|
|
4567
|
-
return
|
|
4715
|
+
return _context49.abrupt("return", {
|
|
4568
4716
|
printed: false,
|
|
4569
4717
|
order: printableOrder
|
|
4570
4718
|
});
|
|
@@ -4574,25 +4722,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
4574
4722
|
printableOrder: printableOrder,
|
|
4575
4723
|
response: params.response
|
|
4576
4724
|
});
|
|
4577
|
-
|
|
4725
|
+
_context49.next = 10;
|
|
4578
4726
|
return this.dispatchPrintOtherReceiptTask({
|
|
4579
4727
|
checkoutData: params.checkoutData,
|
|
4580
4728
|
syncedOrder: printableOrder,
|
|
4581
4729
|
response: params.response,
|
|
4582
|
-
receiptOnly: true
|
|
4730
|
+
receiptOnly: true,
|
|
4731
|
+
isManualPrint: params.isManualPrint
|
|
4583
4732
|
});
|
|
4584
4733
|
case 10:
|
|
4585
|
-
return
|
|
4734
|
+
return _context49.abrupt("return", {
|
|
4586
4735
|
printed: true,
|
|
4587
4736
|
order: printableOrder
|
|
4588
4737
|
});
|
|
4589
4738
|
case 11:
|
|
4590
4739
|
case "end":
|
|
4591
|
-
return
|
|
4740
|
+
return _context49.stop();
|
|
4592
4741
|
}
|
|
4593
|
-
},
|
|
4742
|
+
}, _callee49, this);
|
|
4594
4743
|
}));
|
|
4595
|
-
function dispatchLocalReceiptPrint(
|
|
4744
|
+
function dispatchLocalReceiptPrint(_x54) {
|
|
4596
4745
|
return _dispatchLocalReceiptPrint.apply(this, arguments);
|
|
4597
4746
|
}
|
|
4598
4747
|
return dispatchLocalReceiptPrint;
|
|
@@ -4616,13 +4765,153 @@ var Server = /*#__PURE__*/function () {
|
|
|
4616
4765
|
}
|
|
4617
4766
|
return undefined;
|
|
4618
4767
|
}
|
|
4768
|
+
}, {
|
|
4769
|
+
key: "resolveMachinecodeBatchMetadataLookup",
|
|
4770
|
+
value: function resolveMachinecodeBatchMetadataLookup(data) {
|
|
4771
|
+
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];
|
|
4772
|
+
return candidates.find(function (candidate) {
|
|
4773
|
+
return candidate !== undefined && candidate !== null && candidate !== '';
|
|
4774
|
+
});
|
|
4775
|
+
}
|
|
4776
|
+
}, {
|
|
4777
|
+
key: "syncMachinecodeRedeemStatusToLocalOrder",
|
|
4778
|
+
value: function () {
|
|
4779
|
+
var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(data, ids, status) {
|
|
4780
|
+
var _this$order3;
|
|
4781
|
+
var title, lookup, localOrder, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
|
|
4782
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
4783
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
4784
|
+
case 0:
|
|
4785
|
+
title = 'handleMachinecodeBatchMetadata';
|
|
4786
|
+
lookup = this.resolveMachinecodeBatchMetadataLookup(data);
|
|
4787
|
+
if (!(lookup === undefined)) {
|
|
4788
|
+
_context50.next = 5;
|
|
4789
|
+
break;
|
|
4790
|
+
}
|
|
4791
|
+
this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
4792
|
+
batchSize: ids.length,
|
|
4793
|
+
status: status
|
|
4794
|
+
});
|
|
4795
|
+
return _context50.abrupt("return");
|
|
4796
|
+
case 5:
|
|
4797
|
+
if ((_this$order3 = this.order) !== null && _this$order3 !== void 0 && _this$order3.getLocalOrderByLookup) {
|
|
4798
|
+
_context50.next = 8;
|
|
4799
|
+
break;
|
|
4800
|
+
}
|
|
4801
|
+
this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
4802
|
+
lookup: lookup,
|
|
4803
|
+
status: status
|
|
4804
|
+
});
|
|
4805
|
+
return _context50.abrupt("return");
|
|
4806
|
+
case 8:
|
|
4807
|
+
_context50.next = 10;
|
|
4808
|
+
return this.order.getLocalOrderByLookup(lookup);
|
|
4809
|
+
case 10:
|
|
4810
|
+
localOrder = _context50.sent;
|
|
4811
|
+
if (localOrder) {
|
|
4812
|
+
_context50.next = 14;
|
|
4813
|
+
break;
|
|
4814
|
+
}
|
|
4815
|
+
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
4816
|
+
lookup: lookup,
|
|
4817
|
+
status: status
|
|
4818
|
+
});
|
|
4819
|
+
return _context50.abrupt("return");
|
|
4820
|
+
case 14:
|
|
4821
|
+
voucherIdSet = new Set(ids.filter(function (id) {
|
|
4822
|
+
return id !== undefined && id !== null && id !== '';
|
|
4823
|
+
}).map(function (id) {
|
|
4824
|
+
return String(id);
|
|
4825
|
+
}));
|
|
4826
|
+
if (!(voucherIdSet.size === 0)) {
|
|
4827
|
+
_context50.next = 18;
|
|
4828
|
+
break;
|
|
4829
|
+
}
|
|
4830
|
+
this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
4831
|
+
lookup: lookup,
|
|
4832
|
+
status: status
|
|
4833
|
+
});
|
|
4834
|
+
return _context50.abrupt("return");
|
|
4835
|
+
case 18:
|
|
4836
|
+
vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
|
|
4837
|
+
hasUpdatedVoucher = false;
|
|
4838
|
+
nextVouchers = vouchers.map(function (voucher) {
|
|
4839
|
+
var voucherId = voucher === null || voucher === void 0 ? void 0 : voucher.voucher_id;
|
|
4840
|
+
if (voucherId === undefined || voucherId === null) return voucher;
|
|
4841
|
+
if (!voucherIdSet.has(String(voucherId))) return voucher;
|
|
4842
|
+
hasUpdatedVoucher = true;
|
|
4843
|
+
return _objectSpread(_objectSpread({}, voucher), {}, {
|
|
4844
|
+
status: status
|
|
4845
|
+
});
|
|
4846
|
+
});
|
|
4847
|
+
if (hasUpdatedVoucher) {
|
|
4848
|
+
_context50.next = 24;
|
|
4849
|
+
break;
|
|
4850
|
+
}
|
|
4851
|
+
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
4852
|
+
lookup: lookup,
|
|
4853
|
+
voucher_ids: Array.from(voucherIdSet),
|
|
4854
|
+
status: status
|
|
4855
|
+
});
|
|
4856
|
+
return _context50.abrupt("return");
|
|
4857
|
+
case 24:
|
|
4858
|
+
if (!(typeof this.order.overwriteExistingOrder === 'function')) {
|
|
4859
|
+
_context50.next = 29;
|
|
4860
|
+
break;
|
|
4861
|
+
}
|
|
4862
|
+
_context50.next = 27;
|
|
4863
|
+
return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
|
|
4864
|
+
vouchers: nextVouchers
|
|
4865
|
+
}));
|
|
4866
|
+
case 27:
|
|
4867
|
+
this.logInfo("".concat(title, ": \u672C\u5730\u8BA2\u5355 vouchers \u6838\u9500\u72B6\u6001\u5DF2\u66F4\u65B0"), {
|
|
4868
|
+
lookup: lookup,
|
|
4869
|
+
updatedCount: voucherIdSet.size,
|
|
4870
|
+
status: status
|
|
4871
|
+
});
|
|
4872
|
+
return _context50.abrupt("return");
|
|
4873
|
+
case 29:
|
|
4874
|
+
if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
|
|
4875
|
+
_context50.next = 34;
|
|
4876
|
+
break;
|
|
4877
|
+
}
|
|
4878
|
+
_context50.next = 32;
|
|
4879
|
+
return this.order.markOrderSyncedByExternalSaleNumber({
|
|
4880
|
+
externalSaleNumber: data.external_sale_number,
|
|
4881
|
+
patch: {
|
|
4882
|
+
vouchers: nextVouchers
|
|
4883
|
+
}
|
|
4884
|
+
});
|
|
4885
|
+
case 32:
|
|
4886
|
+
this.logInfo("".concat(title, ": \u672C\u5730\u8BA2\u5355 vouchers \u6838\u9500\u72B6\u6001\u5DF2\u66F4\u65B0"), {
|
|
4887
|
+
lookup: lookup,
|
|
4888
|
+
updatedCount: voucherIdSet.size,
|
|
4889
|
+
status: status
|
|
4890
|
+
});
|
|
4891
|
+
return _context50.abrupt("return");
|
|
4892
|
+
case 34:
|
|
4893
|
+
this.logWarning("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8BA2\u5355\u8986\u76D6\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
4894
|
+
lookup: lookup,
|
|
4895
|
+
status: status
|
|
4896
|
+
});
|
|
4897
|
+
case 35:
|
|
4898
|
+
case "end":
|
|
4899
|
+
return _context50.stop();
|
|
4900
|
+
}
|
|
4901
|
+
}, _callee50, this);
|
|
4902
|
+
}));
|
|
4903
|
+
function syncMachinecodeRedeemStatusToLocalOrder(_x55, _x56, _x57) {
|
|
4904
|
+
return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
|
|
4905
|
+
}
|
|
4906
|
+
return syncMachinecodeRedeemStatusToLocalOrder;
|
|
4907
|
+
}()
|
|
4619
4908
|
}, {
|
|
4620
4909
|
key: "handleOrderCheckoutSubmit",
|
|
4621
4910
|
value: function () {
|
|
4622
|
-
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4911
|
+
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
|
|
4623
4912
|
var backendPath, data, title, normalizedData, checkoutData, pendingResult, pendingOrder;
|
|
4624
|
-
return _regeneratorRuntime().wrap(function
|
|
4625
|
-
while (1) switch (
|
|
4913
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
4914
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
4626
4915
|
case 0:
|
|
4627
4916
|
backendPath = params.backendPath, data = params.data, title = params.title;
|
|
4628
4917
|
this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
|
|
@@ -4632,24 +4921,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
4632
4921
|
order_number: data === null || data === void 0 ? void 0 : data.order_number
|
|
4633
4922
|
});
|
|
4634
4923
|
if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
|
|
4635
|
-
|
|
4924
|
+
_context51.next = 4;
|
|
4636
4925
|
break;
|
|
4637
4926
|
}
|
|
4638
|
-
return
|
|
4927
|
+
return _context51.abrupt("return", this.handleSyncCheckoutSubmit({
|
|
4639
4928
|
backendPath: backendPath,
|
|
4640
4929
|
data: data,
|
|
4641
4930
|
title: title
|
|
4642
4931
|
}));
|
|
4643
4932
|
case 4:
|
|
4644
|
-
|
|
4933
|
+
_context51.next = 6;
|
|
4645
4934
|
return this.normalizeCheckoutSubmitData(data, title);
|
|
4646
4935
|
case 6:
|
|
4647
|
-
normalizedData =
|
|
4648
|
-
|
|
4936
|
+
normalizedData = _context51.sent;
|
|
4937
|
+
_context51.next = 9;
|
|
4649
4938
|
return this.ensureCheckoutOrderNumbers(normalizedData, title);
|
|
4650
4939
|
case 9:
|
|
4651
|
-
checkoutData =
|
|
4652
|
-
|
|
4940
|
+
checkoutData = _context51.sent;
|
|
4941
|
+
_context51.next = 12;
|
|
4653
4942
|
return this.handlePendingSyncCheckoutOrder({
|
|
4654
4943
|
backendPath: backendPath,
|
|
4655
4944
|
data: checkoutData,
|
|
@@ -4657,9 +4946,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
4657
4946
|
reason: 'checkout 已转入设备任务同步'
|
|
4658
4947
|
});
|
|
4659
4948
|
case 12:
|
|
4660
|
-
pendingResult =
|
|
4949
|
+
pendingResult = _context51.sent;
|
|
4661
4950
|
if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
|
|
4662
|
-
|
|
4951
|
+
_context51.next = 20;
|
|
4663
4952
|
break;
|
|
4664
4953
|
}
|
|
4665
4954
|
pendingOrder = pendingResult.data;
|
|
@@ -4667,10 +4956,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
4667
4956
|
// TODO 这里先加个兼容,只有 type 为 virtual 才走打印
|
|
4668
4957
|
// 后期需要迁移到 picoding ,根据工作流配置
|
|
4669
4958
|
checkoutData.type === 'virtual')) {
|
|
4670
|
-
|
|
4959
|
+
_context51.next = 18;
|
|
4671
4960
|
break;
|
|
4672
4961
|
}
|
|
4673
|
-
|
|
4962
|
+
_context51.next = 18;
|
|
4674
4963
|
return this.dispatchLocalReceiptPrint({
|
|
4675
4964
|
checkoutData: checkoutData,
|
|
4676
4965
|
order: pendingOrder,
|
|
@@ -4678,7 +4967,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4678
4967
|
requireFullyPaid: true
|
|
4679
4968
|
});
|
|
4680
4969
|
case 18:
|
|
4681
|
-
|
|
4970
|
+
_context51.next = 20;
|
|
4682
4971
|
return this.dispatchCheckoutSyncTask({
|
|
4683
4972
|
backendPath: backendPath,
|
|
4684
4973
|
data: checkoutData,
|
|
@@ -4686,23 +4975,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
4686
4975
|
});
|
|
4687
4976
|
case 20:
|
|
4688
4977
|
if (pendingResult.data.order_id) {
|
|
4689
|
-
|
|
4978
|
+
_context51.next = 22;
|
|
4690
4979
|
break;
|
|
4691
4980
|
}
|
|
4692
|
-
return
|
|
4981
|
+
return _context51.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
|
|
4693
4982
|
data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
|
|
4694
4983
|
order_id: pendingResult.data.external_sale_number
|
|
4695
4984
|
})
|
|
4696
4985
|
}));
|
|
4697
4986
|
case 22:
|
|
4698
|
-
return
|
|
4987
|
+
return _context51.abrupt("return", pendingResult);
|
|
4699
4988
|
case 23:
|
|
4700
4989
|
case "end":
|
|
4701
|
-
return
|
|
4990
|
+
return _context51.stop();
|
|
4702
4991
|
}
|
|
4703
|
-
},
|
|
4992
|
+
}, _callee51, this);
|
|
4704
4993
|
}));
|
|
4705
|
-
function handleOrderCheckoutSubmit(
|
|
4994
|
+
function handleOrderCheckoutSubmit(_x58) {
|
|
4706
4995
|
return _handleOrderCheckoutSubmit.apply(this, arguments);
|
|
4707
4996
|
}
|
|
4708
4997
|
return handleOrderCheckoutSubmit;
|
|
@@ -4710,27 +4999,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
4710
4999
|
}, {
|
|
4711
5000
|
key: "handleSyncCheckoutSubmit",
|
|
4712
5001
|
value: function () {
|
|
4713
|
-
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4714
|
-
var _this$
|
|
5002
|
+
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
|
|
5003
|
+
var _this$app16;
|
|
4715
5004
|
var backendPath, data, title, syncResult, _normalized$data, normalized, backendError, _normalized$data2, _normalized, message;
|
|
4716
|
-
return _regeneratorRuntime().wrap(function
|
|
4717
|
-
while (1) switch (
|
|
5005
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
5006
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
4718
5007
|
case 0:
|
|
4719
5008
|
backendPath = params.backendPath, data = params.data, title = params.title;
|
|
4720
|
-
if ((_this$
|
|
4721
|
-
|
|
5009
|
+
if ((_this$app16 = this.app) !== null && _this$app16 !== void 0 && (_this$app16 = _this$app16.request) !== null && _this$app16 !== void 0 && _this$app16.post) {
|
|
5010
|
+
_context52.next = 4;
|
|
4722
5011
|
break;
|
|
4723
5012
|
}
|
|
4724
5013
|
this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
|
|
4725
|
-
return
|
|
5014
|
+
return _context52.abrupt("return", {
|
|
4726
5015
|
code: 500,
|
|
4727
5016
|
status: false,
|
|
4728
5017
|
message: 'app.request 不可用',
|
|
4729
5018
|
data: null
|
|
4730
5019
|
});
|
|
4731
5020
|
case 4:
|
|
4732
|
-
|
|
4733
|
-
|
|
5021
|
+
_context52.prev = 4;
|
|
5022
|
+
_context52.next = 7;
|
|
4734
5023
|
return this.runCheckoutSync({
|
|
4735
5024
|
backendPath: backendPath,
|
|
4736
5025
|
data: data,
|
|
@@ -4738,41 +5027,41 @@ var Server = /*#__PURE__*/function () {
|
|
|
4738
5027
|
persistCheckoutDataWithResponse: true
|
|
4739
5028
|
});
|
|
4740
5029
|
case 7:
|
|
4741
|
-
syncResult =
|
|
5030
|
+
syncResult = _context52.sent;
|
|
4742
5031
|
if (!syncResult.rejected) {
|
|
4743
|
-
|
|
5032
|
+
_context52.next = 11;
|
|
4744
5033
|
break;
|
|
4745
5034
|
}
|
|
4746
5035
|
normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
|
|
4747
|
-
return
|
|
5036
|
+
return _context52.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
|
|
4748
5037
|
status: false,
|
|
4749
5038
|
message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
|
|
4750
5039
|
data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
|
|
4751
5040
|
}));
|
|
4752
5041
|
case 11:
|
|
4753
|
-
return
|
|
5042
|
+
return _context52.abrupt("return", this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder));
|
|
4754
5043
|
case 14:
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
backendError = this.extractBackendErrorResponse(
|
|
5044
|
+
_context52.prev = 14;
|
|
5045
|
+
_context52.t0 = _context52["catch"](4);
|
|
5046
|
+
backendError = this.extractBackendErrorResponse(_context52.t0);
|
|
4758
5047
|
if (!backendError) {
|
|
4759
|
-
|
|
5048
|
+
_context52.next = 20;
|
|
4760
5049
|
break;
|
|
4761
5050
|
}
|
|
4762
5051
|
_normalized = this.normalizeCheckoutResponse(backendError);
|
|
4763
|
-
return
|
|
5052
|
+
return _context52.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
|
|
4764
5053
|
status: false,
|
|
4765
5054
|
message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
|
|
4766
5055
|
data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
|
|
4767
5056
|
}));
|
|
4768
5057
|
case 20:
|
|
4769
|
-
message = this.getUnknownErrorMessage(
|
|
5058
|
+
message = this.getUnknownErrorMessage(_context52.t0);
|
|
4770
5059
|
this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
|
|
4771
5060
|
backendPath: backendPath,
|
|
4772
5061
|
error: message,
|
|
4773
|
-
error_detail: this.normalizeUnknownError(
|
|
5062
|
+
error_detail: this.normalizeUnknownError(_context52.t0)
|
|
4774
5063
|
});
|
|
4775
|
-
return
|
|
5064
|
+
return _context52.abrupt("return", {
|
|
4776
5065
|
code: 500,
|
|
4777
5066
|
status: false,
|
|
4778
5067
|
message: message,
|
|
@@ -4780,11 +5069,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4780
5069
|
});
|
|
4781
5070
|
case 23:
|
|
4782
5071
|
case "end":
|
|
4783
|
-
return
|
|
5072
|
+
return _context52.stop();
|
|
4784
5073
|
}
|
|
4785
|
-
},
|
|
5074
|
+
}, _callee52, this, [[4, 14]]);
|
|
4786
5075
|
}));
|
|
4787
|
-
function handleSyncCheckoutSubmit(
|
|
5076
|
+
function handleSyncCheckoutSubmit(_x59) {
|
|
4788
5077
|
return _handleSyncCheckoutSubmit.apply(this, arguments);
|
|
4789
5078
|
}
|
|
4790
5079
|
return handleSyncCheckoutSubmit;
|
|
@@ -4792,26 +5081,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
4792
5081
|
}, {
|
|
4793
5082
|
key: "handlePendingSyncCheckoutOrder",
|
|
4794
5083
|
value: function () {
|
|
4795
|
-
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5084
|
+
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
|
|
4796
5085
|
var _this11 = this;
|
|
4797
5086
|
var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
|
|
4798
|
-
return _regeneratorRuntime().wrap(function
|
|
4799
|
-
while (1) switch (
|
|
5087
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
5088
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
4800
5089
|
case 0:
|
|
4801
5090
|
backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason;
|
|
4802
|
-
|
|
5091
|
+
_context53.next = 3;
|
|
4803
5092
|
return this.buildPendingSyncCheckoutOrder(data);
|
|
4804
5093
|
case 3:
|
|
4805
|
-
pendingOrder =
|
|
5094
|
+
pendingOrder = _context53.sent;
|
|
4806
5095
|
if (pendingOrder) {
|
|
4807
|
-
|
|
5096
|
+
_context53.next = 7;
|
|
4808
5097
|
break;
|
|
4809
5098
|
}
|
|
4810
5099
|
this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
|
|
4811
5100
|
backendPath: backendPath,
|
|
4812
5101
|
reason: reason
|
|
4813
5102
|
});
|
|
4814
|
-
return
|
|
5103
|
+
return _context53.abrupt("return", {
|
|
4815
5104
|
code: 500,
|
|
4816
5105
|
status: false,
|
|
4817
5106
|
message: '订单缺少本地存储标识,无法写入待同步队列',
|
|
@@ -4819,22 +5108,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
4819
5108
|
});
|
|
4820
5109
|
case 7:
|
|
4821
5110
|
if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
|
|
4822
|
-
|
|
5111
|
+
_context53.next = 10;
|
|
4823
5112
|
break;
|
|
4824
5113
|
}
|
|
4825
5114
|
this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
|
|
4826
5115
|
backendPath: backendPath,
|
|
4827
5116
|
reason: reason
|
|
4828
5117
|
});
|
|
4829
|
-
return
|
|
5118
|
+
return _context53.abrupt("return", {
|
|
4830
5119
|
code: 500,
|
|
4831
5120
|
status: false,
|
|
4832
5121
|
message: 'Order 模块不支持本地待同步写入',
|
|
4833
5122
|
data: null
|
|
4834
5123
|
});
|
|
4835
5124
|
case 10:
|
|
4836
|
-
|
|
4837
|
-
|
|
5125
|
+
_context53.prev = 10;
|
|
5126
|
+
_context53.next = 13;
|
|
4838
5127
|
return this.order.upsertPendingSyncOrders([pendingOrder]);
|
|
4839
5128
|
case 13:
|
|
4840
5129
|
this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
|
|
@@ -4848,7 +5137,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4848
5137
|
var _payment$metadata;
|
|
4849
5138
|
return sum + _this11.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
|
|
4850
5139
|
}, 0);
|
|
4851
|
-
return
|
|
5140
|
+
return _context53.abrupt("return", {
|
|
4852
5141
|
code: 200,
|
|
4853
5142
|
status: true,
|
|
4854
5143
|
message: '',
|
|
@@ -4863,15 +5152,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
4863
5152
|
})
|
|
4864
5153
|
});
|
|
4865
5154
|
case 18:
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
errorMessage =
|
|
5155
|
+
_context53.prev = 18;
|
|
5156
|
+
_context53.t0 = _context53["catch"](10);
|
|
5157
|
+
errorMessage = _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0);
|
|
4869
5158
|
this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
|
|
4870
5159
|
backendPath: backendPath,
|
|
4871
5160
|
reason: reason,
|
|
4872
5161
|
error: errorMessage
|
|
4873
5162
|
});
|
|
4874
|
-
return
|
|
5163
|
+
return _context53.abrupt("return", {
|
|
4875
5164
|
code: 500,
|
|
4876
5165
|
status: false,
|
|
4877
5166
|
message: errorMessage,
|
|
@@ -4879,11 +5168,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4879
5168
|
});
|
|
4880
5169
|
case 23:
|
|
4881
5170
|
case "end":
|
|
4882
|
-
return
|
|
5171
|
+
return _context53.stop();
|
|
4883
5172
|
}
|
|
4884
|
-
},
|
|
5173
|
+
}, _callee53, this, [[10, 18]]);
|
|
4885
5174
|
}));
|
|
4886
|
-
function handlePendingSyncCheckoutOrder(
|
|
5175
|
+
function handlePendingSyncCheckoutOrder(_x60) {
|
|
4887
5176
|
return _handlePendingSyncCheckoutOrder.apply(this, arguments);
|
|
4888
5177
|
}
|
|
4889
5178
|
return handlePendingSyncCheckoutOrder;
|
|
@@ -4891,43 +5180,43 @@ var Server = /*#__PURE__*/function () {
|
|
|
4891
5180
|
}, {
|
|
4892
5181
|
key: "buildPendingSyncCheckoutOrder",
|
|
4893
5182
|
value: function () {
|
|
4894
|
-
var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5183
|
+
var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(data) {
|
|
4895
5184
|
var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
|
|
4896
|
-
return _regeneratorRuntime().wrap(function
|
|
4897
|
-
while (1) switch (
|
|
5185
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5186
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
4898
5187
|
case 0:
|
|
4899
5188
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
4900
|
-
|
|
5189
|
+
_context54.next = 2;
|
|
4901
5190
|
break;
|
|
4902
5191
|
}
|
|
4903
|
-
return
|
|
5192
|
+
return _context54.abrupt("return", null);
|
|
4904
5193
|
case 2:
|
|
4905
5194
|
hasStorageKey = data.external_sale_number !== undefined && data.external_sale_number !== null && data.external_sale_number !== '' ? true : data.order_id !== undefined && data.order_id !== null && data.order_id !== '';
|
|
4906
5195
|
if (hasStorageKey) {
|
|
4907
|
-
|
|
5196
|
+
_context54.next = 5;
|
|
4908
5197
|
break;
|
|
4909
5198
|
}
|
|
4910
|
-
return
|
|
5199
|
+
return _context54.abrupt("return", null);
|
|
4911
5200
|
case 5:
|
|
4912
5201
|
pendingOrder = _objectSpread(_objectSpread({}, data), {}, {
|
|
4913
5202
|
need_sync: 1
|
|
4914
5203
|
});
|
|
4915
|
-
|
|
5204
|
+
_context54.next = 8;
|
|
4916
5205
|
return this.buildSmallTicketProductMap(pendingOrder);
|
|
4917
5206
|
case 8:
|
|
4918
|
-
productMap =
|
|
5207
|
+
productMap = _context54.sent;
|
|
4919
5208
|
orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
|
|
4920
|
-
return
|
|
5209
|
+
return _context54.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
|
|
4921
5210
|
requireFullyPaid: true,
|
|
4922
5211
|
productMap: productMap
|
|
4923
5212
|
}));
|
|
4924
5213
|
case 11:
|
|
4925
5214
|
case "end":
|
|
4926
|
-
return
|
|
5215
|
+
return _context54.stop();
|
|
4927
5216
|
}
|
|
4928
|
-
},
|
|
5217
|
+
}, _callee54, this);
|
|
4929
5218
|
}));
|
|
4930
|
-
function buildPendingSyncCheckoutOrder(
|
|
5219
|
+
function buildPendingSyncCheckoutOrder(_x61) {
|
|
4931
5220
|
return _buildPendingSyncCheckoutOrder.apply(this, arguments);
|
|
4932
5221
|
}
|
|
4933
5222
|
return buildPendingSyncCheckoutOrder;
|
|
@@ -4935,10 +5224,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
4935
5224
|
}, {
|
|
4936
5225
|
key: "shouldBuildSmallTicketData",
|
|
4937
5226
|
value: function shouldBuildSmallTicketData(order) {
|
|
4938
|
-
var
|
|
5227
|
+
var _ref56, _order$small_ticket_d;
|
|
4939
5228
|
if (!order || _typeof(order) !== 'object') return false;
|
|
4940
|
-
if (hasSmallTicketData(
|
|
4941
|
-
return Number((
|
|
5229
|
+
// if (hasSmallTicketData(order.payment_info?.small_ticket_data)) return false;
|
|
5230
|
+
return Number((_ref56 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref56 !== void 0 ? _ref56 : 0) === 1;
|
|
4942
5231
|
}
|
|
4943
5232
|
}, {
|
|
4944
5233
|
key: "shouldPrintSyncedOrder",
|
|
@@ -4956,7 +5245,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4956
5245
|
}, {
|
|
4957
5246
|
key: "isSalesOrderFullyPaid",
|
|
4958
5247
|
value: function isSalesOrderFullyPaid(order) {
|
|
4959
|
-
var _order$summary$amount, _order$summary,
|
|
5248
|
+
var _order$summary$amount, _order$summary, _ref57, _ref58, _order$summary$expect, _order$summary2, _order$summary3;
|
|
4960
5249
|
if (!order || _typeof(order) !== 'object') return false;
|
|
4961
5250
|
var paymentStatus = String(order.payment_status || '').toLowerCase();
|
|
4962
5251
|
if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
|
|
@@ -4968,7 +5257,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4968
5257
|
return this.toAmountNumber(amountGap) <= 0;
|
|
4969
5258
|
}
|
|
4970
5259
|
var paidAmount = this.sumPaidOrderPayments(order.payments);
|
|
4971
|
-
var targetAmount = this.toAmountNumber((
|
|
5260
|
+
var targetAmount = this.toAmountNumber((_ref57 = (_ref58 = (_order$summary$expect = (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.total_amount) !== null && _ref58 !== void 0 ? _ref58 : order.expect_amount) !== null && _ref57 !== void 0 ? _ref57 : order.total_amount);
|
|
4972
5261
|
if (targetAmount <= 0) return paidAmount > 0;
|
|
4973
5262
|
return paidAmount >= targetAmount;
|
|
4974
5263
|
}
|
|
@@ -4995,12 +5284,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
4995
5284
|
}, {
|
|
4996
5285
|
key: "buildSmallTicketProductMap",
|
|
4997
5286
|
value: function () {
|
|
4998
|
-
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5287
|
+
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(order) {
|
|
4999
5288
|
var _this$products3,
|
|
5000
5289
|
_this13 = this;
|
|
5001
5290
|
var products, productIdSet, productIds, entries;
|
|
5002
|
-
return _regeneratorRuntime().wrap(function
|
|
5003
|
-
while (1) switch (
|
|
5291
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
5292
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
5004
5293
|
case 0:
|
|
5005
5294
|
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
|
|
5006
5295
|
productIdSet = new Set();
|
|
@@ -5012,8 +5301,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
5012
5301
|
}
|
|
5013
5302
|
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
5014
5303
|
product.product_bundle.forEach(function (bundle) {
|
|
5015
|
-
var
|
|
5016
|
-
var bundleProductId = (
|
|
5304
|
+
var _ref59, _bundle$bundle_produc;
|
|
5305
|
+
var bundleProductId = (_ref59 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref59 !== void 0 ? _ref59 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
|
|
5017
5306
|
if (bundleProductId !== undefined && bundleProductId !== null && bundleProductId !== '') {
|
|
5018
5307
|
productIdSet.add(bundleProductId);
|
|
5019
5308
|
}
|
|
@@ -5022,45 +5311,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
5022
5311
|
});
|
|
5023
5312
|
productIds = Array.from(productIdSet);
|
|
5024
5313
|
if (!(!productIds.length || typeof ((_this$products3 = this.products) === null || _this$products3 === void 0 ? void 0 : _this$products3.getProductById) !== 'function')) {
|
|
5025
|
-
|
|
5314
|
+
_context56.next = 6;
|
|
5026
5315
|
break;
|
|
5027
5316
|
}
|
|
5028
|
-
return
|
|
5317
|
+
return _context56.abrupt("return", {});
|
|
5029
5318
|
case 6:
|
|
5030
|
-
|
|
5319
|
+
_context56.next = 8;
|
|
5031
5320
|
return Promise.all(productIds.map( /*#__PURE__*/function () {
|
|
5032
|
-
var
|
|
5321
|
+
var _ref60 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(id) {
|
|
5033
5322
|
var _this13$products, _this13$products$getP, product;
|
|
5034
|
-
return _regeneratorRuntime().wrap(function
|
|
5035
|
-
while (1) switch (
|
|
5323
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5324
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
5036
5325
|
case 0:
|
|
5037
|
-
|
|
5038
|
-
|
|
5326
|
+
_context55.prev = 0;
|
|
5327
|
+
_context55.next = 3;
|
|
5039
5328
|
return (_this13$products = _this13.products) === null || _this13$products === void 0 || (_this13$products$getP = _this13$products.getProductById) === null || _this13$products$getP === void 0 ? void 0 : _this13$products$getP.call(_this13$products, Number(id));
|
|
5040
5329
|
case 3:
|
|
5041
|
-
product =
|
|
5042
|
-
return
|
|
5330
|
+
product = _context55.sent;
|
|
5331
|
+
return _context55.abrupt("return", product ? [String(id), product] : null);
|
|
5043
5332
|
case 7:
|
|
5044
|
-
|
|
5045
|
-
|
|
5333
|
+
_context55.prev = 7;
|
|
5334
|
+
_context55.t0 = _context55["catch"](0);
|
|
5046
5335
|
_this13.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
|
|
5047
5336
|
product_id: id,
|
|
5048
|
-
error:
|
|
5337
|
+
error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
|
|
5049
5338
|
});
|
|
5050
|
-
return
|
|
5339
|
+
return _context55.abrupt("return", null);
|
|
5051
5340
|
case 11:
|
|
5052
5341
|
case "end":
|
|
5053
|
-
return
|
|
5342
|
+
return _context55.stop();
|
|
5054
5343
|
}
|
|
5055
|
-
},
|
|
5344
|
+
}, _callee55, null, [[0, 7]]);
|
|
5056
5345
|
}));
|
|
5057
|
-
return function (
|
|
5058
|
-
return
|
|
5346
|
+
return function (_x63) {
|
|
5347
|
+
return _ref60.apply(this, arguments);
|
|
5059
5348
|
};
|
|
5060
5349
|
}()));
|
|
5061
5350
|
case 8:
|
|
5062
|
-
entries =
|
|
5063
|
-
return
|
|
5351
|
+
entries = _context56.sent;
|
|
5352
|
+
return _context56.abrupt("return", entries.reduce(function (map, entry) {
|
|
5064
5353
|
if (!entry) return map;
|
|
5065
5354
|
var _entry = _slicedToArray(entry, 2),
|
|
5066
5355
|
id = _entry[0],
|
|
@@ -5070,25 +5359,190 @@ var Server = /*#__PURE__*/function () {
|
|
|
5070
5359
|
}, {}));
|
|
5071
5360
|
case 10:
|
|
5072
5361
|
case "end":
|
|
5073
|
-
return
|
|
5362
|
+
return _context56.stop();
|
|
5074
5363
|
}
|
|
5075
|
-
},
|
|
5364
|
+
}, _callee56, this);
|
|
5076
5365
|
}));
|
|
5077
|
-
function buildSmallTicketProductMap(
|
|
5366
|
+
function buildSmallTicketProductMap(_x62) {
|
|
5078
5367
|
return _buildSmallTicketProductMap.apply(this, arguments);
|
|
5079
5368
|
}
|
|
5080
5369
|
return buildSmallTicketProductMap;
|
|
5081
5370
|
}()
|
|
5371
|
+
}, {
|
|
5372
|
+
key: "collectSalesDetailProductIds",
|
|
5373
|
+
value: function collectSalesDetailProductIds(order) {
|
|
5374
|
+
var products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
|
|
5375
|
+
var productIds = new Set();
|
|
5376
|
+
var addProductId = function addProductId(rawProductId) {
|
|
5377
|
+
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return;
|
|
5378
|
+
var productId = Number(rawProductId);
|
|
5379
|
+
if (Number.isFinite(productId)) productIds.add(productId);
|
|
5380
|
+
};
|
|
5381
|
+
products.forEach(function (product) {
|
|
5382
|
+
var _product$product_id2;
|
|
5383
|
+
addProductId((_product$product_id2 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product === null || product === void 0 ? void 0 : product.id);
|
|
5384
|
+
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
5385
|
+
product.product_bundle.forEach(function (bundle) {
|
|
5386
|
+
var _ref61, _bundle$bundle_produc2;
|
|
5387
|
+
addProductId((_ref61 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref61 !== void 0 ? _ref61 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
|
|
5388
|
+
});
|
|
5389
|
+
}
|
|
5390
|
+
});
|
|
5391
|
+
return Array.from(productIds);
|
|
5392
|
+
}
|
|
5393
|
+
}, {
|
|
5394
|
+
key: "buildSalesDetailProductSnapshotMap",
|
|
5395
|
+
value: function () {
|
|
5396
|
+
var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(order) {
|
|
5397
|
+
var _this$products4;
|
|
5398
|
+
var productIds, getSnapshots;
|
|
5399
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5400
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
5401
|
+
case 0:
|
|
5402
|
+
productIds = this.collectSalesDetailProductIds(order);
|
|
5403
|
+
getSnapshots = (_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductSnapshotsByIds;
|
|
5404
|
+
if (!(!productIds.length || typeof getSnapshots !== 'function')) {
|
|
5405
|
+
_context57.next = 4;
|
|
5406
|
+
break;
|
|
5407
|
+
}
|
|
5408
|
+
return _context57.abrupt("return", {});
|
|
5409
|
+
case 4:
|
|
5410
|
+
_context57.prev = 4;
|
|
5411
|
+
_context57.next = 7;
|
|
5412
|
+
return getSnapshots.call(this.products, productIds);
|
|
5413
|
+
case 7:
|
|
5414
|
+
return _context57.abrupt("return", _context57.sent);
|
|
5415
|
+
case 10:
|
|
5416
|
+
_context57.prev = 10;
|
|
5417
|
+
_context57.t0 = _context57["catch"](4);
|
|
5418
|
+
this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
|
|
5419
|
+
product_ids: productIds,
|
|
5420
|
+
error: _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0)
|
|
5421
|
+
});
|
|
5422
|
+
return _context57.abrupt("return", {});
|
|
5423
|
+
case 14:
|
|
5424
|
+
case "end":
|
|
5425
|
+
return _context57.stop();
|
|
5426
|
+
}
|
|
5427
|
+
}, _callee57, this, [[4, 10]]);
|
|
5428
|
+
}));
|
|
5429
|
+
function buildSalesDetailProductSnapshotMap(_x64) {
|
|
5430
|
+
return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
|
|
5431
|
+
}
|
|
5432
|
+
return buildSalesDetailProductSnapshotMap;
|
|
5433
|
+
}()
|
|
5434
|
+
}, {
|
|
5435
|
+
key: "withProductCatalogSnapshots",
|
|
5436
|
+
value: function withProductCatalogSnapshots(product, snapshotMap) {
|
|
5437
|
+
var _product$product_id3;
|
|
5438
|
+
if (!product || _typeof(product) !== 'object') return product;
|
|
5439
|
+
var rawProductId = (_product$product_id3 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id3 !== void 0 ? _product$product_id3 : product === null || product === void 0 ? void 0 : product.id;
|
|
5440
|
+
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return product;
|
|
5441
|
+
var productId = Number(rawProductId);
|
|
5442
|
+
if (!Number.isFinite(productId)) return product;
|
|
5443
|
+
var snapshot = snapshotMap[String(productId)];
|
|
5444
|
+
if (!snapshot) return product;
|
|
5445
|
+
var shouldFillCover = (product.product_cover === undefined || product.product_cover === null || product.product_cover === '') && snapshot.cover !== undefined && snapshot.cover !== null && snapshot.cover !== '';
|
|
5446
|
+
var metadata = product.metadata && _typeof(product.metadata) === 'object' ? product.metadata : {};
|
|
5447
|
+
var shouldFillHolderConfig = (metadata.holder_config === undefined || metadata.holder_config === null) && snapshot.holder_config !== undefined && snapshot.holder_config !== null;
|
|
5448
|
+
if (!shouldFillCover && !shouldFillHolderConfig) return product;
|
|
5449
|
+
return _objectSpread(_objectSpread(_objectSpread({}, product), shouldFillCover ? {
|
|
5450
|
+
product_cover: snapshot.cover
|
|
5451
|
+
} : {}), shouldFillHolderConfig ? {
|
|
5452
|
+
metadata: _objectSpread(_objectSpread({}, metadata), {}, {
|
|
5453
|
+
holder_config: snapshot.holder_config
|
|
5454
|
+
})
|
|
5455
|
+
} : {});
|
|
5456
|
+
}
|
|
5457
|
+
}, {
|
|
5458
|
+
key: "withBundleCatalogSnapshots",
|
|
5459
|
+
value: function withBundleCatalogSnapshots(product, snapshotMap) {
|
|
5460
|
+
if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
|
|
5461
|
+
var hasChanged = false;
|
|
5462
|
+
var productBundle = product.product_bundle.map(function (bundle) {
|
|
5463
|
+
var _ref62, _bundle$bundle_produc3;
|
|
5464
|
+
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
5465
|
+
var rawProductId = (_ref62 = (_bundle$bundle_produc3 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref62 !== void 0 ? _ref62 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
|
|
5466
|
+
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
|
|
5467
|
+
var productId = Number(rawProductId);
|
|
5468
|
+
if (!Number.isFinite(productId)) return bundle;
|
|
5469
|
+
var snapshot = snapshotMap[String(productId)];
|
|
5470
|
+
var shouldFillCover = (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && (snapshot === null || snapshot === void 0 ? void 0 : snapshot.cover) !== undefined && snapshot.cover !== null && snapshot.cover !== '';
|
|
5471
|
+
if (!shouldFillCover) return bundle;
|
|
5472
|
+
hasChanged = true;
|
|
5473
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
5474
|
+
cover: snapshot.cover
|
|
5475
|
+
});
|
|
5476
|
+
});
|
|
5477
|
+
if (!hasChanged) return product;
|
|
5478
|
+
return _objectSpread(_objectSpread({}, product), {}, {
|
|
5479
|
+
product_bundle: productBundle
|
|
5480
|
+
});
|
|
5481
|
+
}
|
|
5482
|
+
}, {
|
|
5483
|
+
key: "withSalesDetailProductSnapshots",
|
|
5484
|
+
value: function () {
|
|
5485
|
+
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(order) {
|
|
5486
|
+
var _this14 = this;
|
|
5487
|
+
var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
|
|
5488
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
5489
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
5490
|
+
case 0:
|
|
5491
|
+
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
|
|
5492
|
+
if (products !== null && products !== void 0 && products.length) {
|
|
5493
|
+
_context58.next = 3;
|
|
5494
|
+
break;
|
|
5495
|
+
}
|
|
5496
|
+
return _context58.abrupt("return", order);
|
|
5497
|
+
case 3:
|
|
5498
|
+
_context58.next = 5;
|
|
5499
|
+
return this.buildSalesDetailProductSnapshotMap(order);
|
|
5500
|
+
case 5:
|
|
5501
|
+
snapshotMap = _context58.sent;
|
|
5502
|
+
if (Object.keys(snapshotMap).length) {
|
|
5503
|
+
_context58.next = 8;
|
|
5504
|
+
break;
|
|
5505
|
+
}
|
|
5506
|
+
return _context58.abrupt("return", order);
|
|
5507
|
+
case 8:
|
|
5508
|
+
hasChanged = false;
|
|
5509
|
+
enrichedProducts = products.map(function (product) {
|
|
5510
|
+
var productWithBundleSnapshots = _this14.withBundleCatalogSnapshots(product, snapshotMap);
|
|
5511
|
+
var nextProduct = _this14.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
|
|
5512
|
+
if (nextProduct !== product) hasChanged = true;
|
|
5513
|
+
return nextProduct;
|
|
5514
|
+
});
|
|
5515
|
+
if (hasChanged) {
|
|
5516
|
+
_context58.next = 12;
|
|
5517
|
+
break;
|
|
5518
|
+
}
|
|
5519
|
+
return _context58.abrupt("return", order);
|
|
5520
|
+
case 12:
|
|
5521
|
+
enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
|
|
5522
|
+
products: enrichedProducts
|
|
5523
|
+
});
|
|
5524
|
+
return _context58.abrupt("return", enrichedOrder);
|
|
5525
|
+
case 14:
|
|
5526
|
+
case "end":
|
|
5527
|
+
return _context58.stop();
|
|
5528
|
+
}
|
|
5529
|
+
}, _callee58, this);
|
|
5530
|
+
}));
|
|
5531
|
+
function withSalesDetailProductSnapshots(_x65) {
|
|
5532
|
+
return _withSalesDetailProductSnapshots.apply(this, arguments);
|
|
5533
|
+
}
|
|
5534
|
+
return withSalesDetailProductSnapshots;
|
|
5535
|
+
}()
|
|
5082
5536
|
}, {
|
|
5083
5537
|
key: "withPendingSyncProductTitles",
|
|
5084
5538
|
value: function withPendingSyncProductTitles(order, productMap) {
|
|
5085
|
-
var
|
|
5539
|
+
var _this15 = this;
|
|
5086
5540
|
var products = Array.isArray(order.products) ? order.products : null;
|
|
5087
5541
|
if (!(products !== null && products !== void 0 && products.length)) return order;
|
|
5088
5542
|
return _objectSpread(_objectSpread({}, order), {}, {
|
|
5089
5543
|
products: products.map(function (product) {
|
|
5090
5544
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
5091
|
-
product_title:
|
|
5545
|
+
product_title: _this15.buildProductTitleSnapshot(product, productMap)
|
|
5092
5546
|
});
|
|
5093
5547
|
})
|
|
5094
5548
|
});
|
|
@@ -5096,18 +5550,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
5096
5550
|
}, {
|
|
5097
5551
|
key: "buildProductTitleSnapshot",
|
|
5098
5552
|
value: function buildProductTitleSnapshot(product, productMap) {
|
|
5099
|
-
var _product$
|
|
5553
|
+
var _product$product_id4,
|
|
5100
5554
|
_product$product,
|
|
5101
5555
|
_fallbackProduct$prod,
|
|
5102
|
-
|
|
5103
|
-
var productId = (_product$
|
|
5556
|
+
_this16 = this;
|
|
5557
|
+
var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
|
|
5104
5558
|
var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
|
|
5105
5559
|
var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
|
|
5106
5560
|
var fallbackTitle = (fallbackProduct === null || fallbackProduct === void 0 ? void 0 : fallbackProduct.product_title) || (fallbackProduct === null || fallbackProduct === void 0 ? void 0 : fallbackProduct.title) || (fallbackProduct === null || fallbackProduct === void 0 ? void 0 : fallbackProduct.name) || (fallbackProduct === null || fallbackProduct === void 0 ? void 0 : fallbackProduct.format_title) || (fallbackProduct === null || fallbackProduct === void 0 || (_fallbackProduct$prod = fallbackProduct.product) === null || _fallbackProduct$prod === void 0 ? void 0 : _fallbackProduct$prod.title);
|
|
5107
5561
|
var currentLocale = this.getProductTitleSnapshotCurrentLocale();
|
|
5108
5562
|
var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
|
|
5109
5563
|
return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
|
|
5110
|
-
snapshot[key] =
|
|
5564
|
+
snapshot[key] = _this16.resolveProductTitleValue(ownTitle, key, currentLocale) || _this16.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
|
|
5111
5565
|
return snapshot;
|
|
5112
5566
|
}, {});
|
|
5113
5567
|
}
|
|
@@ -5132,7 +5586,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5132
5586
|
}, {
|
|
5133
5587
|
key: "resolveProductTitleValue",
|
|
5134
5588
|
value: function resolveProductTitleValue(value, key, currentLocale) {
|
|
5135
|
-
var
|
|
5589
|
+
var _ref63, _ref64, _value$key;
|
|
5136
5590
|
if (value === undefined || value === null || value === '') return null;
|
|
5137
5591
|
if (_typeof(value) !== 'object') {
|
|
5138
5592
|
var title = String(value);
|
|
@@ -5142,7 +5596,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5142
5596
|
}
|
|
5143
5597
|
var normalizedKey = key.replace('-', '_');
|
|
5144
5598
|
var dashedKey = key.replace('_', '-');
|
|
5145
|
-
var rawValue = (
|
|
5599
|
+
var rawValue = (_ref63 = (_ref64 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref64 !== void 0 ? _ref64 : value[dashedKey]) !== null && _ref63 !== void 0 ? _ref63 : key === 'auto' ? value.default : undefined;
|
|
5146
5600
|
if (rawValue === undefined || rawValue === null || rawValue === '') return null;
|
|
5147
5601
|
if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
|
|
5148
5602
|
return String(rawValue);
|
|
@@ -5205,31 +5659,31 @@ var Server = /*#__PURE__*/function () {
|
|
|
5205
5659
|
}, {
|
|
5206
5660
|
key: "enrichPaymentNamesByCode",
|
|
5207
5661
|
value: function () {
|
|
5208
|
-
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5209
|
-
var
|
|
5662
|
+
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(order) {
|
|
5663
|
+
var _this17 = this;
|
|
5210
5664
|
var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator13, _step13, method, codeKey, name, hasResolvedName, enrichedPayments;
|
|
5211
|
-
return _regeneratorRuntime().wrap(function
|
|
5212
|
-
while (1) switch (
|
|
5665
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context59) {
|
|
5666
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
5213
5667
|
case 0:
|
|
5214
5668
|
payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
|
|
5215
5669
|
hasMissingName = payments.some(function (payment) {
|
|
5216
|
-
return
|
|
5670
|
+
return _this17.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this17.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
|
|
5217
5671
|
});
|
|
5218
5672
|
if (hasMissingName) {
|
|
5219
|
-
|
|
5673
|
+
_context59.next = 4;
|
|
5220
5674
|
break;
|
|
5221
5675
|
}
|
|
5222
|
-
return
|
|
5676
|
+
return _context59.abrupt("return", order);
|
|
5223
5677
|
case 4:
|
|
5224
|
-
|
|
5225
|
-
|
|
5678
|
+
_context59.prev = 4;
|
|
5679
|
+
_context59.next = 7;
|
|
5226
5680
|
return this.getPaymentRouteModule();
|
|
5227
5681
|
case 7:
|
|
5228
|
-
paymentModule =
|
|
5229
|
-
|
|
5682
|
+
paymentModule = _context59.sent;
|
|
5683
|
+
_context59.next = 10;
|
|
5230
5684
|
return paymentModule.getPayMethodListAsync();
|
|
5231
5685
|
case 10:
|
|
5232
|
-
payMethods =
|
|
5686
|
+
payMethods = _context59.sent;
|
|
5233
5687
|
nameByCode = new Map();
|
|
5234
5688
|
_iterator13 = _createForOfIteratorHelper(payMethods || []);
|
|
5235
5689
|
try {
|
|
@@ -5246,9 +5700,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5246
5700
|
}
|
|
5247
5701
|
hasResolvedName = false;
|
|
5248
5702
|
enrichedPayments = payments.map(function (payment) {
|
|
5249
|
-
if (!
|
|
5250
|
-
if (!
|
|
5251
|
-
var name = nameByCode.get(
|
|
5703
|
+
if (!_this17.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
|
|
5704
|
+
if (!_this17.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
|
|
5705
|
+
var name = nameByCode.get(_this17.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
|
|
5252
5706
|
if (!name) return payment;
|
|
5253
5707
|
hasResolvedName = true;
|
|
5254
5708
|
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
@@ -5256,28 +5710,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
5256
5710
|
});
|
|
5257
5711
|
});
|
|
5258
5712
|
if (hasResolvedName) {
|
|
5259
|
-
|
|
5713
|
+
_context59.next = 18;
|
|
5260
5714
|
break;
|
|
5261
5715
|
}
|
|
5262
|
-
return
|
|
5716
|
+
return _context59.abrupt("return", order);
|
|
5263
5717
|
case 18:
|
|
5264
|
-
return
|
|
5718
|
+
return _context59.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
|
|
5265
5719
|
payments: enrichedPayments
|
|
5266
5720
|
}));
|
|
5267
5721
|
case 21:
|
|
5268
|
-
|
|
5269
|
-
|
|
5722
|
+
_context59.prev = 21;
|
|
5723
|
+
_context59.t0 = _context59["catch"](4);
|
|
5270
5724
|
this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
|
|
5271
|
-
error:
|
|
5725
|
+
error: _context59.t0 instanceof Error ? _context59.t0.message : String(_context59.t0)
|
|
5272
5726
|
});
|
|
5273
|
-
return
|
|
5727
|
+
return _context59.abrupt("return", order);
|
|
5274
5728
|
case 25:
|
|
5275
5729
|
case "end":
|
|
5276
|
-
return
|
|
5730
|
+
return _context59.stop();
|
|
5277
5731
|
}
|
|
5278
|
-
},
|
|
5732
|
+
}, _callee59, this, [[4, 21]]);
|
|
5279
5733
|
}));
|
|
5280
|
-
function enrichPaymentNamesByCode(
|
|
5734
|
+
function enrichPaymentNamesByCode(_x66) {
|
|
5281
5735
|
return _enrichPaymentNamesByCode.apply(this, arguments);
|
|
5282
5736
|
}
|
|
5283
5737
|
return enrichPaymentNamesByCode;
|
|
@@ -5285,66 +5739,66 @@ var Server = /*#__PURE__*/function () {
|
|
|
5285
5739
|
}, {
|
|
5286
5740
|
key: "withLocalSmallTicketData",
|
|
5287
5741
|
value: function () {
|
|
5288
|
-
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5742
|
+
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(order, options) {
|
|
5289
5743
|
var _options$productMap, enrichedOrder, productMap, smallTicketData;
|
|
5290
|
-
return _regeneratorRuntime().wrap(function
|
|
5291
|
-
while (1) switch (
|
|
5744
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
5745
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
5292
5746
|
case 0:
|
|
5293
5747
|
if (this.shouldBuildSmallTicketData(order)) {
|
|
5294
|
-
|
|
5748
|
+
_context60.next = 2;
|
|
5295
5749
|
break;
|
|
5296
5750
|
}
|
|
5297
|
-
return
|
|
5751
|
+
return _context60.abrupt("return", order);
|
|
5298
5752
|
case 2:
|
|
5299
5753
|
if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
|
|
5300
|
-
|
|
5754
|
+
_context60.next = 4;
|
|
5301
5755
|
break;
|
|
5302
5756
|
}
|
|
5303
|
-
return
|
|
5757
|
+
return _context60.abrupt("return", order);
|
|
5304
5758
|
case 4:
|
|
5305
|
-
|
|
5306
|
-
|
|
5759
|
+
_context60.prev = 4;
|
|
5760
|
+
_context60.next = 7;
|
|
5307
5761
|
return this.enrichPaymentNamesByCode(order);
|
|
5308
5762
|
case 7:
|
|
5309
|
-
enrichedOrder =
|
|
5763
|
+
enrichedOrder = _context60.sent;
|
|
5310
5764
|
if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
|
|
5311
|
-
|
|
5765
|
+
_context60.next = 12;
|
|
5312
5766
|
break;
|
|
5313
5767
|
}
|
|
5314
|
-
|
|
5315
|
-
|
|
5768
|
+
_context60.t0 = _options$productMap;
|
|
5769
|
+
_context60.next = 15;
|
|
5316
5770
|
break;
|
|
5317
5771
|
case 12:
|
|
5318
|
-
|
|
5772
|
+
_context60.next = 14;
|
|
5319
5773
|
return this.buildSmallTicketProductMap(enrichedOrder);
|
|
5320
5774
|
case 14:
|
|
5321
|
-
|
|
5775
|
+
_context60.t0 = _context60.sent;
|
|
5322
5776
|
case 15:
|
|
5323
|
-
productMap =
|
|
5777
|
+
productMap = _context60.t0;
|
|
5324
5778
|
smallTicketData = buildSmallTicketData({
|
|
5325
5779
|
order: enrichedOrder,
|
|
5326
5780
|
shopInfo: this.getSmallTicketShopInfo(),
|
|
5327
5781
|
productMap: productMap
|
|
5328
5782
|
});
|
|
5329
|
-
return
|
|
5783
|
+
return _context60.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
|
|
5330
5784
|
payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
|
|
5331
5785
|
small_ticket_data: smallTicketData
|
|
5332
5786
|
})
|
|
5333
5787
|
}));
|
|
5334
5788
|
case 20:
|
|
5335
|
-
|
|
5336
|
-
|
|
5789
|
+
_context60.prev = 20;
|
|
5790
|
+
_context60.t1 = _context60["catch"](4);
|
|
5337
5791
|
this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
|
|
5338
|
-
error:
|
|
5792
|
+
error: _context60.t1 instanceof Error ? _context60.t1.message : String(_context60.t1)
|
|
5339
5793
|
});
|
|
5340
|
-
return
|
|
5794
|
+
return _context60.abrupt("return", order);
|
|
5341
5795
|
case 24:
|
|
5342
5796
|
case "end":
|
|
5343
|
-
return
|
|
5797
|
+
return _context60.stop();
|
|
5344
5798
|
}
|
|
5345
|
-
},
|
|
5799
|
+
}, _callee60, this, [[4, 20]]);
|
|
5346
5800
|
}));
|
|
5347
|
-
function withLocalSmallTicketData(
|
|
5801
|
+
function withLocalSmallTicketData(_x67, _x68) {
|
|
5348
5802
|
return _withLocalSmallTicketData.apply(this, arguments);
|
|
5349
5803
|
}
|
|
5350
5804
|
return withLocalSmallTicketData;
|
|
@@ -5406,34 +5860,34 @@ var Server = /*#__PURE__*/function () {
|
|
|
5406
5860
|
}, {
|
|
5407
5861
|
key: "handleUpdateLocalOrdersBatch",
|
|
5408
5862
|
value: (function () {
|
|
5409
|
-
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5410
|
-
var _this$
|
|
5411
|
-
var existedBefore, _iterator14, _step14, id, fetched, message, fetchedMap, _iterator15, _step15, order, oid, freshOrders, succeedIds, failed, _iterator16, _step16, _id, fresh,
|
|
5412
|
-
return _regeneratorRuntime().wrap(function
|
|
5413
|
-
while (1) switch (
|
|
5863
|
+
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(orderIds) {
|
|
5864
|
+
var _this$app17;
|
|
5865
|
+
var existedBefore, _iterator14, _step14, id, fetched, message, fetchedMap, _iterator15, _step15, order, oid, freshOrders, succeedIds, failed, _iterator16, _step16, _id, fresh, _message2, overwritten, inserted;
|
|
5866
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
5867
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
5414
5868
|
case 0:
|
|
5415
5869
|
this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
|
|
5416
5870
|
count: orderIds.length,
|
|
5417
5871
|
orderIds: orderIds
|
|
5418
5872
|
});
|
|
5419
5873
|
if (this.order) {
|
|
5420
|
-
|
|
5874
|
+
_context61.next = 4;
|
|
5421
5875
|
break;
|
|
5422
5876
|
}
|
|
5423
5877
|
this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
|
|
5424
|
-
return
|
|
5878
|
+
return _context61.abrupt("return", {
|
|
5425
5879
|
code: 500,
|
|
5426
5880
|
status: false,
|
|
5427
5881
|
message: 'Order 模块未注册',
|
|
5428
5882
|
data: null
|
|
5429
5883
|
});
|
|
5430
5884
|
case 4:
|
|
5431
|
-
if ((_this$
|
|
5432
|
-
|
|
5885
|
+
if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && _this$app17.request) {
|
|
5886
|
+
_context61.next = 7;
|
|
5433
5887
|
break;
|
|
5434
5888
|
}
|
|
5435
5889
|
this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
|
|
5436
|
-
return
|
|
5890
|
+
return _context61.abrupt("return", {
|
|
5437
5891
|
code: 500,
|
|
5438
5892
|
status: false,
|
|
5439
5893
|
message: 'app.request 不可用',
|
|
@@ -5456,21 +5910,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
5456
5910
|
_iterator14.f();
|
|
5457
5911
|
}
|
|
5458
5912
|
fetched = [];
|
|
5459
|
-
|
|
5460
|
-
|
|
5913
|
+
_context61.prev = 11;
|
|
5914
|
+
_context61.next = 14;
|
|
5461
5915
|
return this.order.fetchOrdersByHttp(orderIds);
|
|
5462
5916
|
case 14:
|
|
5463
|
-
fetched =
|
|
5464
|
-
|
|
5917
|
+
fetched = _context61.sent;
|
|
5918
|
+
_context61.next = 22;
|
|
5465
5919
|
break;
|
|
5466
5920
|
case 17:
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
message =
|
|
5921
|
+
_context61.prev = 17;
|
|
5922
|
+
_context61.t0 = _context61["catch"](11);
|
|
5923
|
+
message = _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0);
|
|
5470
5924
|
this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
|
|
5471
5925
|
message: message
|
|
5472
5926
|
});
|
|
5473
|
-
return
|
|
5927
|
+
return _context61.abrupt("return", {
|
|
5474
5928
|
code: 500,
|
|
5475
5929
|
status: false,
|
|
5476
5930
|
message: message,
|
|
@@ -5480,36 +5934,36 @@ var Server = /*#__PURE__*/function () {
|
|
|
5480
5934
|
// 按返回结果中的 order_id 建索引,未命中即视为单笔失败
|
|
5481
5935
|
fetchedMap = new Map();
|
|
5482
5936
|
_iterator15 = _createForOfIteratorHelper(fetched);
|
|
5483
|
-
|
|
5937
|
+
_context61.prev = 24;
|
|
5484
5938
|
_iterator15.s();
|
|
5485
5939
|
case 26:
|
|
5486
5940
|
if ((_step15 = _iterator15.n()).done) {
|
|
5487
|
-
|
|
5941
|
+
_context61.next = 34;
|
|
5488
5942
|
break;
|
|
5489
5943
|
}
|
|
5490
5944
|
order = _step15.value;
|
|
5491
5945
|
oid = order === null || order === void 0 ? void 0 : order.order_id;
|
|
5492
5946
|
if (!(oid === undefined || oid === null)) {
|
|
5493
|
-
|
|
5947
|
+
_context61.next = 31;
|
|
5494
5948
|
break;
|
|
5495
5949
|
}
|
|
5496
|
-
return
|
|
5950
|
+
return _context61.abrupt("continue", 32);
|
|
5497
5951
|
case 31:
|
|
5498
5952
|
fetchedMap.set(String(oid), order);
|
|
5499
5953
|
case 32:
|
|
5500
|
-
|
|
5954
|
+
_context61.next = 26;
|
|
5501
5955
|
break;
|
|
5502
5956
|
case 34:
|
|
5503
|
-
|
|
5957
|
+
_context61.next = 39;
|
|
5504
5958
|
break;
|
|
5505
5959
|
case 36:
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
_iterator15.e(
|
|
5960
|
+
_context61.prev = 36;
|
|
5961
|
+
_context61.t1 = _context61["catch"](24);
|
|
5962
|
+
_iterator15.e(_context61.t1);
|
|
5509
5963
|
case 39:
|
|
5510
|
-
|
|
5964
|
+
_context61.prev = 39;
|
|
5511
5965
|
_iterator15.f();
|
|
5512
|
-
return
|
|
5966
|
+
return _context61.finish(39);
|
|
5513
5967
|
case 42:
|
|
5514
5968
|
freshOrders = [];
|
|
5515
5969
|
succeedIds = [];
|
|
@@ -5535,26 +5989,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
5535
5989
|
_iterator16.f();
|
|
5536
5990
|
}
|
|
5537
5991
|
if (!(freshOrders.length > 0)) {
|
|
5538
|
-
|
|
5992
|
+
_context61.next = 58;
|
|
5539
5993
|
break;
|
|
5540
5994
|
}
|
|
5541
|
-
|
|
5542
|
-
|
|
5995
|
+
_context61.prev = 48;
|
|
5996
|
+
_context61.next = 51;
|
|
5543
5997
|
return this.order.upsertOrdersFromRemote(freshOrders);
|
|
5544
5998
|
case 51:
|
|
5545
|
-
|
|
5999
|
+
_context61.next = 58;
|
|
5546
6000
|
break;
|
|
5547
6001
|
case 53:
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
6002
|
+
_context61.prev = 53;
|
|
6003
|
+
_context61.t2 = _context61["catch"](48);
|
|
6004
|
+
_message2 = _context61.t2 instanceof Error ? _context61.t2.message : String(_context61.t2);
|
|
5551
6005
|
this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
|
|
5552
|
-
message:
|
|
6006
|
+
message: _message2
|
|
5553
6007
|
});
|
|
5554
|
-
return
|
|
6008
|
+
return _context61.abrupt("return", {
|
|
5555
6009
|
code: 500,
|
|
5556
6010
|
status: false,
|
|
5557
|
-
message:
|
|
6011
|
+
message: _message2,
|
|
5558
6012
|
data: null
|
|
5559
6013
|
});
|
|
5560
6014
|
case 58:
|
|
@@ -5570,7 +6024,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5570
6024
|
insertedCount: inserted.length,
|
|
5571
6025
|
failedCount: failed.length
|
|
5572
6026
|
});
|
|
5573
|
-
return
|
|
6027
|
+
return _context61.abrupt("return", {
|
|
5574
6028
|
code: 200,
|
|
5575
6029
|
status: true,
|
|
5576
6030
|
message: '',
|
|
@@ -5582,11 +6036,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5582
6036
|
});
|
|
5583
6037
|
case 62:
|
|
5584
6038
|
case "end":
|
|
5585
|
-
return
|
|
6039
|
+
return _context61.stop();
|
|
5586
6040
|
}
|
|
5587
|
-
},
|
|
6041
|
+
}, _callee61, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
|
|
5588
6042
|
}));
|
|
5589
|
-
function handleUpdateLocalOrdersBatch(
|
|
6043
|
+
function handleUpdateLocalOrdersBatch(_x69) {
|
|
5590
6044
|
return _handleUpdateLocalOrdersBatch.apply(this, arguments);
|
|
5591
6045
|
}
|
|
5592
6046
|
return handleUpdateLocalOrdersBatch;
|
|
@@ -5663,8 +6117,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
5663
6117
|
}, {
|
|
5664
6118
|
key: "extractOrderDataFromCheckoutResponse",
|
|
5665
6119
|
value: function extractOrderDataFromCheckoutResponse(response) {
|
|
5666
|
-
var _response$
|
|
5667
|
-
var candidates = [response === null || response === void 0 || (_response$
|
|
6120
|
+
var _response$data6, _response$data7;
|
|
6121
|
+
var candidates = [response === null || response === void 0 || (_response$data6 = response.data) === null || _response$data6 === void 0 ? void 0 : _response$data6.order, response === null || response === void 0 || (_response$data7 = response.data) === null || _response$data7 === void 0 ? void 0 : _response$data7.sales, response === null || response === void 0 ? void 0 : response.data, response === null || response === void 0 ? void 0 : response.order, response === null || response === void 0 ? void 0 : response.sales, response];
|
|
5668
6122
|
for (var _i4 = 0, _candidates = candidates; _i4 < _candidates.length; _i4++) {
|
|
5669
6123
|
var candidate = _candidates[_i4];
|
|
5670
6124
|
if (!candidate || _typeof(candidate) !== 'object') continue;
|
|
@@ -5828,10 +6282,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5828
6282
|
value: function extractBackendErrorResponse(error) {
|
|
5829
6283
|
var _error$response3,
|
|
5830
6284
|
_error$response4,
|
|
5831
|
-
|
|
6285
|
+
_this18 = this;
|
|
5832
6286
|
var candidates = [error === null || error === void 0 || (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.body, error === null || error === void 0 ? void 0 : error.body];
|
|
5833
6287
|
return candidates.find(function (candidate) {
|
|
5834
|
-
return
|
|
6288
|
+
return _this18.isExplicitBackendErrorResponse(candidate);
|
|
5835
6289
|
}) || null;
|
|
5836
6290
|
}
|
|
5837
6291
|
}, {
|
|
@@ -5950,16 +6404,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
5950
6404
|
}, {
|
|
5951
6405
|
key: "recomputeAndNotifyFloorPlanQuery",
|
|
5952
6406
|
value: (function () {
|
|
5953
|
-
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6407
|
+
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62() {
|
|
5954
6408
|
var _iterator18, _step18, _step18$value, subscriberId, sub, result, errorMessage;
|
|
5955
|
-
return _regeneratorRuntime().wrap(function
|
|
5956
|
-
while (1) switch (
|
|
6409
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
6410
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
5957
6411
|
case 0:
|
|
5958
6412
|
if (!(this.floorPlanQuerySubscribers.size === 0)) {
|
|
5959
|
-
|
|
6413
|
+
_context62.next = 2;
|
|
5960
6414
|
break;
|
|
5961
6415
|
}
|
|
5962
|
-
return
|
|
6416
|
+
return _context62.abrupt("return");
|
|
5963
6417
|
case 2:
|
|
5964
6418
|
this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
|
|
5965
6419
|
subscriberCount: this.floorPlanQuerySubscribers.size
|
|
@@ -5989,9 +6443,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5989
6443
|
}
|
|
5990
6444
|
case 5:
|
|
5991
6445
|
case "end":
|
|
5992
|
-
return
|
|
6446
|
+
return _context62.stop();
|
|
5993
6447
|
}
|
|
5994
|
-
},
|
|
6448
|
+
}, _callee62, this);
|
|
5995
6449
|
}));
|
|
5996
6450
|
function recomputeAndNotifyFloorPlanQuery() {
|
|
5997
6451
|
return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
|
|
@@ -6021,21 +6475,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
6021
6475
|
* filter 逻辑暂为 mock,仅记录参数
|
|
6022
6476
|
*/
|
|
6023
6477
|
function () {
|
|
6024
|
-
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6478
|
+
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(data) {
|
|
6025
6479
|
var rawList, result;
|
|
6026
|
-
return _regeneratorRuntime().wrap(function
|
|
6027
|
-
while (1) switch (
|
|
6480
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
6481
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
6028
6482
|
case 0:
|
|
6029
6483
|
this.logInfo('computeOrderQueryResult: 开始过滤', {
|
|
6030
6484
|
data: data
|
|
6031
6485
|
});
|
|
6032
6486
|
console.log('[Server] computeOrderQueryResult', data);
|
|
6033
6487
|
if (this.order) {
|
|
6034
|
-
|
|
6488
|
+
_context63.next = 5;
|
|
6035
6489
|
break;
|
|
6036
6490
|
}
|
|
6037
6491
|
this.logError('computeOrderQueryResult: Order 模块未注册');
|
|
6038
|
-
return
|
|
6492
|
+
return _context63.abrupt("return", {
|
|
6039
6493
|
code: 500,
|
|
6040
6494
|
message: 'Order 模块未注册',
|
|
6041
6495
|
data: {
|
|
@@ -6059,7 +6513,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6059
6513
|
skip: result.skip,
|
|
6060
6514
|
rejected: result.rejected
|
|
6061
6515
|
});
|
|
6062
|
-
return
|
|
6516
|
+
return _context63.abrupt("return", {
|
|
6063
6517
|
code: 200,
|
|
6064
6518
|
data: result,
|
|
6065
6519
|
message: '',
|
|
@@ -6067,11 +6521,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6067
6521
|
});
|
|
6068
6522
|
case 10:
|
|
6069
6523
|
case "end":
|
|
6070
|
-
return
|
|
6524
|
+
return _context63.stop();
|
|
6071
6525
|
}
|
|
6072
|
-
},
|
|
6526
|
+
}, _callee63, this);
|
|
6073
6527
|
}));
|
|
6074
|
-
function computeOrderQueryResult(
|
|
6528
|
+
function computeOrderQueryResult(_x70) {
|
|
6075
6529
|
return _computeOrderQueryResult.apply(this, arguments);
|
|
6076
6530
|
}
|
|
6077
6531
|
return computeOrderQueryResult;
|
|
@@ -6084,17 +6538,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
6084
6538
|
}, {
|
|
6085
6539
|
key: "computeBookingQueryResult",
|
|
6086
6540
|
value: (function () {
|
|
6087
|
-
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6541
|
+
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(data) {
|
|
6088
6542
|
var rawOrders, result;
|
|
6089
|
-
return _regeneratorRuntime().wrap(function
|
|
6090
|
-
while (1) switch (
|
|
6543
|
+
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
6544
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
6091
6545
|
case 0:
|
|
6092
6546
|
if (this.order) {
|
|
6093
|
-
|
|
6547
|
+
_context64.next = 3;
|
|
6094
6548
|
break;
|
|
6095
6549
|
}
|
|
6096
6550
|
this.logError('computeBookingQueryResult: Order 模块未注册');
|
|
6097
|
-
return
|
|
6551
|
+
return _context64.abrupt("return", {
|
|
6098
6552
|
code: 500,
|
|
6099
6553
|
message: 'Order 模块未注册',
|
|
6100
6554
|
data: {
|
|
@@ -6113,7 +6567,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6113
6567
|
size: result.size,
|
|
6114
6568
|
skip: result.skip
|
|
6115
6569
|
});
|
|
6116
|
-
return
|
|
6570
|
+
return _context64.abrupt("return", {
|
|
6117
6571
|
code: 200,
|
|
6118
6572
|
data: result,
|
|
6119
6573
|
message: '',
|
|
@@ -6121,11 +6575,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6121
6575
|
});
|
|
6122
6576
|
case 8:
|
|
6123
6577
|
case "end":
|
|
6124
|
-
return
|
|
6578
|
+
return _context64.stop();
|
|
6125
6579
|
}
|
|
6126
|
-
},
|
|
6580
|
+
}, _callee64, this);
|
|
6127
6581
|
}));
|
|
6128
|
-
function computeBookingQueryResult(
|
|
6582
|
+
function computeBookingQueryResult(_x71) {
|
|
6129
6583
|
return _computeBookingQueryResult.apply(this, arguments);
|
|
6130
6584
|
}
|
|
6131
6585
|
return computeBookingQueryResult;
|
|
@@ -6184,12 +6638,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
6184
6638
|
}, {
|
|
6185
6639
|
key: "computeProductQueryResult",
|
|
6186
6640
|
value: (function () {
|
|
6187
|
-
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6641
|
+
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(context, options) {
|
|
6188
6642
|
var _menu_list_ids$length3,
|
|
6189
|
-
|
|
6643
|
+
_this19 = this;
|
|
6190
6644
|
var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
|
|
6191
|
-
return _regeneratorRuntime().wrap(function
|
|
6192
|
-
while (1) switch (
|
|
6645
|
+
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
6646
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
6193
6647
|
case 0:
|
|
6194
6648
|
tTotal = performance.now();
|
|
6195
6649
|
menu_list_ids = context.menu_list_ids, ids = context.ids, schedule_date = context.schedule_date, schedule_datetime = context.schedule_datetime, customer_id = context.customer_id, extension_type = context.extension_type, product_id = context.product_id, strategy_context = context.strategy_context;
|
|
@@ -6216,28 +6670,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
6216
6670
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6217
6671
|
});
|
|
6218
6672
|
if (this.products) {
|
|
6219
|
-
|
|
6673
|
+
_context65.next = 8;
|
|
6220
6674
|
break;
|
|
6221
6675
|
}
|
|
6222
6676
|
this.logError('computeProductQueryResult: Products 模块未注册');
|
|
6223
|
-
return
|
|
6677
|
+
return _context65.abrupt("return", {
|
|
6224
6678
|
message: 'Products 模块未注册',
|
|
6225
6679
|
data: this.buildProductQueryResultPayload([], 0)
|
|
6226
6680
|
});
|
|
6227
6681
|
case 8:
|
|
6228
6682
|
if (!(queryIds.length > 0)) {
|
|
6229
|
-
|
|
6683
|
+
_context65.next = 20;
|
|
6230
6684
|
break;
|
|
6231
6685
|
}
|
|
6232
6686
|
uniqueIds = Array.from(new Set(queryIds));
|
|
6233
6687
|
_tPrice = performance.now();
|
|
6234
|
-
|
|
6688
|
+
_context65.next = 13;
|
|
6235
6689
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
6236
6690
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
6237
6691
|
productIds: uniqueIds
|
|
6238
6692
|
});
|
|
6239
6693
|
case 13:
|
|
6240
|
-
productsWithPrice =
|
|
6694
|
+
productsWithPrice = _context65.sent;
|
|
6241
6695
|
perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
|
|
6242
6696
|
count: productsWithPrice.length,
|
|
6243
6697
|
ids: uniqueIds
|
|
@@ -6257,7 +6711,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6257
6711
|
ids: uniqueIds,
|
|
6258
6712
|
count: extensionFilteredProducts.length
|
|
6259
6713
|
});
|
|
6260
|
-
return
|
|
6714
|
+
return _context65.abrupt("return", {
|
|
6261
6715
|
code: 200,
|
|
6262
6716
|
data: this.buildProductQueryResultPayload(extensionFilteredProducts),
|
|
6263
6717
|
message: '',
|
|
@@ -6265,17 +6719,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
6265
6719
|
});
|
|
6266
6720
|
case 20:
|
|
6267
6721
|
if (!(product_id != null && Number.isFinite(Number(product_id)))) {
|
|
6268
|
-
|
|
6722
|
+
_context65.next = 32;
|
|
6269
6723
|
break;
|
|
6270
6724
|
}
|
|
6271
6725
|
pid = Number(product_id);
|
|
6272
6726
|
_tPrice2 = performance.now();
|
|
6273
|
-
|
|
6727
|
+
_context65.next = 25;
|
|
6274
6728
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
6275
6729
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6276
6730
|
});
|
|
6277
6731
|
case 25:
|
|
6278
|
-
allProductsWithPrice =
|
|
6732
|
+
allProductsWithPrice = _context65.sent;
|
|
6279
6733
|
perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
|
|
6280
6734
|
count: allProductsWithPrice.length,
|
|
6281
6735
|
productId: pid
|
|
@@ -6295,7 +6749,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6295
6749
|
productId: pid,
|
|
6296
6750
|
found: !!item
|
|
6297
6751
|
});
|
|
6298
|
-
return
|
|
6752
|
+
return _context65.abrupt("return", {
|
|
6299
6753
|
code: 200,
|
|
6300
6754
|
data: item,
|
|
6301
6755
|
message: item ? '' : '商品不存在或未发布',
|
|
@@ -6303,16 +6757,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
6303
6757
|
});
|
|
6304
6758
|
case 32:
|
|
6305
6759
|
if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
|
|
6306
|
-
|
|
6760
|
+
_context65.next = 52;
|
|
6307
6761
|
break;
|
|
6308
6762
|
}
|
|
6309
6763
|
_tPrice3 = performance.now();
|
|
6310
|
-
|
|
6764
|
+
_context65.next = 36;
|
|
6311
6765
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
6312
6766
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6313
6767
|
});
|
|
6314
6768
|
case 36:
|
|
6315
|
-
_filteredProducts2 =
|
|
6769
|
+
_filteredProducts2 = _context65.sent;
|
|
6316
6770
|
perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
|
|
6317
6771
|
count: _filteredProducts2.length,
|
|
6318
6772
|
extension_type: extension_type
|
|
@@ -6351,7 +6805,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6351
6805
|
filteredCount: _filteredProducts2.length,
|
|
6352
6806
|
extension_type: extension_type
|
|
6353
6807
|
});
|
|
6354
|
-
return
|
|
6808
|
+
return _context65.abrupt("return", {
|
|
6355
6809
|
code: 200,
|
|
6356
6810
|
data: this.buildProductQueryResultPayload(_filteredProducts2),
|
|
6357
6811
|
message: '',
|
|
@@ -6359,21 +6813,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
6359
6813
|
});
|
|
6360
6814
|
case 52:
|
|
6361
6815
|
if (this.menu) {
|
|
6362
|
-
|
|
6816
|
+
_context65.next = 55;
|
|
6363
6817
|
break;
|
|
6364
6818
|
}
|
|
6365
6819
|
this.logError('computeProductQueryResult: Menu 模块未注册');
|
|
6366
|
-
return
|
|
6820
|
+
return _context65.abrupt("return", {
|
|
6367
6821
|
message: 'Menu 模块未注册',
|
|
6368
6822
|
data: this.buildProductQueryResultPayload([], 0)
|
|
6369
6823
|
});
|
|
6370
6824
|
case 55:
|
|
6371
6825
|
if (this.schedule) {
|
|
6372
|
-
|
|
6826
|
+
_context65.next = 58;
|
|
6373
6827
|
break;
|
|
6374
6828
|
}
|
|
6375
6829
|
this.logError('computeProductQueryResult: Schedule 模块未注册');
|
|
6376
|
-
return
|
|
6830
|
+
return _context65.abrupt("return", {
|
|
6377
6831
|
message: 'Schedule 模块未注册',
|
|
6378
6832
|
data: this.buildProductQueryResultPayload([], 0)
|
|
6379
6833
|
});
|
|
@@ -6383,8 +6837,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
6383
6837
|
tMenu = performance.now();
|
|
6384
6838
|
menuList = this.menu.getMenuByIds(menu_list_ids);
|
|
6385
6839
|
activeMenuList = menuList.filter(function (menu) {
|
|
6386
|
-
var
|
|
6387
|
-
return ((
|
|
6840
|
+
var _this19$schedule;
|
|
6841
|
+
return ((_this19$schedule = _this19.schedule) === null || _this19$schedule === void 0 ? void 0 : _this19$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
|
|
6388
6842
|
});
|
|
6389
6843
|
perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
|
|
6390
6844
|
totalMenu: menuList.length,
|
|
@@ -6401,22 +6855,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
6401
6855
|
});
|
|
6402
6856
|
tPrice = performance.now();
|
|
6403
6857
|
if (!(scopedProductIds.length > 0)) {
|
|
6404
|
-
|
|
6858
|
+
_context65.next = 71;
|
|
6405
6859
|
break;
|
|
6406
6860
|
}
|
|
6407
|
-
|
|
6861
|
+
_context65.next = 68;
|
|
6408
6862
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
6409
6863
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
6410
6864
|
productIds: productScope.isAllProducts ? undefined : scopedProductIds
|
|
6411
6865
|
});
|
|
6412
6866
|
case 68:
|
|
6413
|
-
|
|
6414
|
-
|
|
6867
|
+
_context65.t0 = _context65.sent;
|
|
6868
|
+
_context65.next = 72;
|
|
6415
6869
|
break;
|
|
6416
6870
|
case 71:
|
|
6417
|
-
|
|
6871
|
+
_context65.t0 = [];
|
|
6418
6872
|
case 72:
|
|
6419
|
-
filteredProducts =
|
|
6873
|
+
filteredProducts = _context65.t0;
|
|
6420
6874
|
perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
|
|
6421
6875
|
count: filteredProducts.length,
|
|
6422
6876
|
scopedProductCount: scopedProductIds.length
|
|
@@ -6457,7 +6911,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6457
6911
|
filteredCount: filteredProducts.length,
|
|
6458
6912
|
activeMenuCount: activeMenuList.length
|
|
6459
6913
|
});
|
|
6460
|
-
return
|
|
6914
|
+
return _context65.abrupt("return", {
|
|
6461
6915
|
code: 200,
|
|
6462
6916
|
data: this.buildProductQueryResultPayload(filteredProducts),
|
|
6463
6917
|
message: '',
|
|
@@ -6465,11 +6919,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6465
6919
|
});
|
|
6466
6920
|
case 88:
|
|
6467
6921
|
case "end":
|
|
6468
|
-
return
|
|
6922
|
+
return _context65.stop();
|
|
6469
6923
|
}
|
|
6470
|
-
},
|
|
6924
|
+
}, _callee65, this);
|
|
6471
6925
|
}));
|
|
6472
|
-
function computeProductQueryResult(
|
|
6926
|
+
function computeProductQueryResult(_x72, _x73) {
|
|
6473
6927
|
return _computeProductQueryResult.apply(this, arguments);
|
|
6474
6928
|
}
|
|
6475
6929
|
return computeProductQueryResult;
|
|
@@ -6505,72 +6959,72 @@ var Server = /*#__PURE__*/function () {
|
|
|
6505
6959
|
}, {
|
|
6506
6960
|
key: "recomputeAndNotifyProductQuery",
|
|
6507
6961
|
value: (function () {
|
|
6508
|
-
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6962
|
+
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(options) {
|
|
6509
6963
|
var _iterator19, _step19, _step19$value, subscriberId, subscriber, result, errorMessage;
|
|
6510
|
-
return _regeneratorRuntime().wrap(function
|
|
6511
|
-
while (1) switch (
|
|
6964
|
+
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
6965
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
6512
6966
|
case 0:
|
|
6513
6967
|
if (!(this.productQuerySubscribers.size === 0)) {
|
|
6514
|
-
|
|
6968
|
+
_context66.next = 2;
|
|
6515
6969
|
break;
|
|
6516
6970
|
}
|
|
6517
|
-
return
|
|
6971
|
+
return _context66.abrupt("return");
|
|
6518
6972
|
case 2:
|
|
6519
6973
|
this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
|
|
6520
6974
|
subscriberCount: this.productQuerySubscribers.size,
|
|
6521
6975
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6522
6976
|
});
|
|
6523
6977
|
_iterator19 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
|
|
6524
|
-
|
|
6978
|
+
_context66.prev = 4;
|
|
6525
6979
|
_iterator19.s();
|
|
6526
6980
|
case 6:
|
|
6527
6981
|
if ((_step19 = _iterator19.n()).done) {
|
|
6528
|
-
|
|
6982
|
+
_context66.next = 22;
|
|
6529
6983
|
break;
|
|
6530
6984
|
}
|
|
6531
6985
|
_step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
|
|
6532
|
-
|
|
6533
|
-
|
|
6986
|
+
_context66.prev = 8;
|
|
6987
|
+
_context66.next = 11;
|
|
6534
6988
|
return this.computeProductQueryResult(subscriber.context, {
|
|
6535
6989
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
6536
6990
|
});
|
|
6537
6991
|
case 11:
|
|
6538
|
-
result =
|
|
6992
|
+
result = _context66.sent;
|
|
6539
6993
|
subscriber.callback(result);
|
|
6540
6994
|
this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
|
|
6541
6995
|
subscriberId: subscriberId
|
|
6542
6996
|
});
|
|
6543
|
-
|
|
6997
|
+
_context66.next = 20;
|
|
6544
6998
|
break;
|
|
6545
6999
|
case 16:
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
errorMessage =
|
|
7000
|
+
_context66.prev = 16;
|
|
7001
|
+
_context66.t0 = _context66["catch"](8);
|
|
7002
|
+
errorMessage = _context66.t0 instanceof Error ? _context66.t0.message : String(_context66.t0);
|
|
6549
7003
|
this.logError('recomputeAndNotifyProductQuery: 推送失败', {
|
|
6550
7004
|
subscriberId: subscriberId,
|
|
6551
7005
|
error: errorMessage
|
|
6552
7006
|
});
|
|
6553
7007
|
case 20:
|
|
6554
|
-
|
|
7008
|
+
_context66.next = 6;
|
|
6555
7009
|
break;
|
|
6556
7010
|
case 22:
|
|
6557
|
-
|
|
7011
|
+
_context66.next = 27;
|
|
6558
7012
|
break;
|
|
6559
7013
|
case 24:
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
_iterator19.e(
|
|
7014
|
+
_context66.prev = 24;
|
|
7015
|
+
_context66.t1 = _context66["catch"](4);
|
|
7016
|
+
_iterator19.e(_context66.t1);
|
|
6563
7017
|
case 27:
|
|
6564
|
-
|
|
7018
|
+
_context66.prev = 27;
|
|
6565
7019
|
_iterator19.f();
|
|
6566
|
-
return
|
|
7020
|
+
return _context66.finish(27);
|
|
6567
7021
|
case 30:
|
|
6568
7022
|
case "end":
|
|
6569
|
-
return
|
|
7023
|
+
return _context66.stop();
|
|
6570
7024
|
}
|
|
6571
|
-
},
|
|
7025
|
+
}, _callee66, this, [[4, 24, 27, 30], [8, 16]]);
|
|
6572
7026
|
}));
|
|
6573
|
-
function recomputeAndNotifyProductQuery(
|
|
7027
|
+
function recomputeAndNotifyProductQuery(_x74) {
|
|
6574
7028
|
return _recomputeAndNotifyProductQuery.apply(this, arguments);
|
|
6575
7029
|
}
|
|
6576
7030
|
return recomputeAndNotifyProductQuery;
|
|
@@ -6582,16 +7036,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
6582
7036
|
}, {
|
|
6583
7037
|
key: "recomputeAndNotifyOrderQuery",
|
|
6584
7038
|
value: (function () {
|
|
6585
|
-
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7039
|
+
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67() {
|
|
6586
7040
|
var notifyStartAt, _iterator20, _step20, _step20$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
|
|
6587
|
-
return _regeneratorRuntime().wrap(function
|
|
6588
|
-
while (1) switch (
|
|
7041
|
+
return _regeneratorRuntime().wrap(function _callee67$(_context67) {
|
|
7042
|
+
while (1) switch (_context67.prev = _context67.next) {
|
|
6589
7043
|
case 0:
|
|
6590
7044
|
if (!(this.orderQuerySubscribers.size === 0)) {
|
|
6591
|
-
|
|
7045
|
+
_context67.next = 2;
|
|
6592
7046
|
break;
|
|
6593
7047
|
}
|
|
6594
|
-
return
|
|
7048
|
+
return _context67.abrupt("return");
|
|
6595
7049
|
case 2:
|
|
6596
7050
|
notifyStartAt = Date.now();
|
|
6597
7051
|
this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
|
|
@@ -6599,20 +7053,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
6599
7053
|
notifyStartAt: new Date(notifyStartAt).toISOString()
|
|
6600
7054
|
});
|
|
6601
7055
|
_iterator20 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
|
|
6602
|
-
|
|
7056
|
+
_context67.prev = 5;
|
|
6603
7057
|
_iterator20.s();
|
|
6604
7058
|
case 7:
|
|
6605
7059
|
if ((_step20 = _iterator20.n()).done) {
|
|
6606
|
-
|
|
7060
|
+
_context67.next = 27;
|
|
6607
7061
|
break;
|
|
6608
7062
|
}
|
|
6609
7063
|
_step20$value = _slicedToArray(_step20.value, 2), subscriberId = _step20$value[0], subscriber = _step20$value[1];
|
|
6610
|
-
|
|
7064
|
+
_context67.prev = 9;
|
|
6611
7065
|
computeStartAt = Date.now();
|
|
6612
|
-
|
|
7066
|
+
_context67.next = 13;
|
|
6613
7067
|
return this.computeOrderQueryResult(subscriber.context);
|
|
6614
7068
|
case 13:
|
|
6615
|
-
result =
|
|
7069
|
+
result = _context67.sent;
|
|
6616
7070
|
computeEndAt = Date.now();
|
|
6617
7071
|
callbackStartAt = Date.now();
|
|
6618
7072
|
subscriber.callback(result);
|
|
@@ -6623,30 +7077,30 @@ var Server = /*#__PURE__*/function () {
|
|
|
6623
7077
|
callbackDurationMs: callbackEndAt - callbackStartAt,
|
|
6624
7078
|
totalDurationMs: callbackEndAt - computeStartAt
|
|
6625
7079
|
});
|
|
6626
|
-
|
|
7080
|
+
_context67.next = 25;
|
|
6627
7081
|
break;
|
|
6628
7082
|
case 21:
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
errorMessage =
|
|
7083
|
+
_context67.prev = 21;
|
|
7084
|
+
_context67.t0 = _context67["catch"](9);
|
|
7085
|
+
errorMessage = _context67.t0 instanceof Error ? _context67.t0.message : String(_context67.t0);
|
|
6632
7086
|
this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
|
|
6633
7087
|
subscriberId: subscriberId,
|
|
6634
7088
|
error: errorMessage
|
|
6635
7089
|
});
|
|
6636
7090
|
case 25:
|
|
6637
|
-
|
|
7091
|
+
_context67.next = 7;
|
|
6638
7092
|
break;
|
|
6639
7093
|
case 27:
|
|
6640
|
-
|
|
7094
|
+
_context67.next = 32;
|
|
6641
7095
|
break;
|
|
6642
7096
|
case 29:
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
_iterator20.e(
|
|
7097
|
+
_context67.prev = 29;
|
|
7098
|
+
_context67.t1 = _context67["catch"](5);
|
|
7099
|
+
_iterator20.e(_context67.t1);
|
|
6646
7100
|
case 32:
|
|
6647
|
-
|
|
7101
|
+
_context67.prev = 32;
|
|
6648
7102
|
_iterator20.f();
|
|
6649
|
-
return
|
|
7103
|
+
return _context67.finish(32);
|
|
6650
7104
|
case 35:
|
|
6651
7105
|
notifyEndAt = Date.now();
|
|
6652
7106
|
this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
|
|
@@ -6655,9 +7109,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6655
7109
|
});
|
|
6656
7110
|
case 37:
|
|
6657
7111
|
case "end":
|
|
6658
|
-
return
|
|
7112
|
+
return _context67.stop();
|
|
6659
7113
|
}
|
|
6660
|
-
},
|
|
7114
|
+
}, _callee67, this, [[5, 29, 32, 35], [9, 21]]);
|
|
6661
7115
|
}));
|
|
6662
7116
|
function recomputeAndNotifyOrderQuery() {
|
|
6663
7117
|
return _recomputeAndNotifyOrderQuery.apply(this, arguments);
|
|
@@ -6675,7 +7129,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6675
7129
|
}, {
|
|
6676
7130
|
key: "notifySalesSearchSubscribers",
|
|
6677
7131
|
value: function notifySalesSearchSubscribers(payload) {
|
|
6678
|
-
var
|
|
7132
|
+
var _this20 = this;
|
|
6679
7133
|
if (this.salesSearchSubscribers.size === 0) return;
|
|
6680
7134
|
var changedOrders = this.extractChangedOrdersFromPayload(payload);
|
|
6681
7135
|
if (changedOrders.length === 0) {
|
|
@@ -6693,21 +7147,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
6693
7147
|
subscriber = _step21$value[1];
|
|
6694
7148
|
try {
|
|
6695
7149
|
var changedVisibleOrders = changedOrders.filter(function (order) {
|
|
6696
|
-
var orderId =
|
|
7150
|
+
var orderId = _this20.getSalesSearchOrderId(order);
|
|
6697
7151
|
return !!orderId && subscriber.visibleOrderIds.has(orderId);
|
|
6698
7152
|
});
|
|
6699
7153
|
if (changedVisibleOrders.length === 0) {
|
|
6700
7154
|
return 1; // continue
|
|
6701
7155
|
}
|
|
6702
|
-
subscriber.callback(
|
|
6703
|
-
|
|
7156
|
+
subscriber.callback(_this20.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
|
|
7157
|
+
_this20.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
|
|
6704
7158
|
subscriberId: subscriberId,
|
|
6705
7159
|
kind: subscriber.kind,
|
|
6706
7160
|
count: changedVisibleOrders.length
|
|
6707
7161
|
});
|
|
6708
7162
|
} catch (error) {
|
|
6709
7163
|
var errorMessage = error instanceof Error ? error.message : String(error);
|
|
6710
|
-
|
|
7164
|
+
_this20.logError('notifySalesSearchSubscribers: 推送失败', {
|
|
6711
7165
|
subscriberId: subscriberId,
|
|
6712
7166
|
error: errorMessage
|
|
6713
7167
|
});
|
|
@@ -6798,67 +7252,67 @@ var Server = /*#__PURE__*/function () {
|
|
|
6798
7252
|
}, {
|
|
6799
7253
|
key: "recomputeAndNotifyBookingQuery",
|
|
6800
7254
|
value: (function () {
|
|
6801
|
-
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7255
|
+
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68() {
|
|
6802
7256
|
var _iterator22, _step22, _step22$value, subscriberId, subscriber, result, errorMessage;
|
|
6803
|
-
return _regeneratorRuntime().wrap(function
|
|
6804
|
-
while (1) switch (
|
|
7257
|
+
return _regeneratorRuntime().wrap(function _callee68$(_context68) {
|
|
7258
|
+
while (1) switch (_context68.prev = _context68.next) {
|
|
6805
7259
|
case 0:
|
|
6806
7260
|
if (!(this.bookingQuerySubscribers.size === 0)) {
|
|
6807
|
-
|
|
7261
|
+
_context68.next = 2;
|
|
6808
7262
|
break;
|
|
6809
7263
|
}
|
|
6810
|
-
return
|
|
7264
|
+
return _context68.abrupt("return");
|
|
6811
7265
|
case 2:
|
|
6812
7266
|
this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
|
|
6813
7267
|
subscriberCount: this.bookingQuerySubscribers.size
|
|
6814
7268
|
});
|
|
6815
7269
|
_iterator22 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
|
|
6816
|
-
|
|
7270
|
+
_context68.prev = 4;
|
|
6817
7271
|
_iterator22.s();
|
|
6818
7272
|
case 6:
|
|
6819
7273
|
if ((_step22 = _iterator22.n()).done) {
|
|
6820
|
-
|
|
7274
|
+
_context68.next = 22;
|
|
6821
7275
|
break;
|
|
6822
7276
|
}
|
|
6823
7277
|
_step22$value = _slicedToArray(_step22.value, 2), subscriberId = _step22$value[0], subscriber = _step22$value[1];
|
|
6824
|
-
|
|
6825
|
-
|
|
7278
|
+
_context68.prev = 8;
|
|
7279
|
+
_context68.next = 11;
|
|
6826
7280
|
return this.computeBookingQueryResult(subscriber.context);
|
|
6827
7281
|
case 11:
|
|
6828
|
-
result =
|
|
7282
|
+
result = _context68.sent;
|
|
6829
7283
|
subscriber.callback(result);
|
|
6830
7284
|
this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
|
|
6831
7285
|
subscriberId: subscriberId
|
|
6832
7286
|
});
|
|
6833
|
-
|
|
7287
|
+
_context68.next = 20;
|
|
6834
7288
|
break;
|
|
6835
7289
|
case 16:
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
errorMessage =
|
|
7290
|
+
_context68.prev = 16;
|
|
7291
|
+
_context68.t0 = _context68["catch"](8);
|
|
7292
|
+
errorMessage = _context68.t0 instanceof Error ? _context68.t0.message : String(_context68.t0);
|
|
6839
7293
|
this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
|
|
6840
7294
|
subscriberId: subscriberId,
|
|
6841
7295
|
error: errorMessage
|
|
6842
7296
|
});
|
|
6843
7297
|
case 20:
|
|
6844
|
-
|
|
7298
|
+
_context68.next = 6;
|
|
6845
7299
|
break;
|
|
6846
7300
|
case 22:
|
|
6847
|
-
|
|
7301
|
+
_context68.next = 27;
|
|
6848
7302
|
break;
|
|
6849
7303
|
case 24:
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
_iterator22.e(
|
|
7304
|
+
_context68.prev = 24;
|
|
7305
|
+
_context68.t1 = _context68["catch"](4);
|
|
7306
|
+
_iterator22.e(_context68.t1);
|
|
6853
7307
|
case 27:
|
|
6854
|
-
|
|
7308
|
+
_context68.prev = 27;
|
|
6855
7309
|
_iterator22.f();
|
|
6856
|
-
return
|
|
7310
|
+
return _context68.finish(27);
|
|
6857
7311
|
case 30:
|
|
6858
7312
|
case "end":
|
|
6859
|
-
return
|
|
7313
|
+
return _context68.stop();
|
|
6860
7314
|
}
|
|
6861
|
-
},
|
|
7315
|
+
}, _callee68, this, [[4, 24, 27, 30], [8, 16]]);
|
|
6862
7316
|
}));
|
|
6863
7317
|
function recomputeAndNotifyBookingQuery() {
|
|
6864
7318
|
return _recomputeAndNotifyBookingQuery.apply(this, arguments);
|