@pisell/pisellos 0.10.83 → 0.10.84
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/modules/ProductList/index.js +5 -2
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +789 -705
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/ProductList/index.js +4 -1
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +39 -0
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -299,6 +299,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
299
299
|
while (1) switch (_context3.prev = _context3.next) {
|
|
300
300
|
case 0:
|
|
301
301
|
url = _ref5.url, method = _ref5.method, data = _ref5.data, config = _ref5.config;
|
|
302
|
+
if (!((data === null || data === void 0 ? void 0 : data.open_quotation) === 0 && (data === null || data === void 0 ? void 0 : data.application_code) === 'kiosk')) {
|
|
303
|
+
_context3.next = 3;
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
return _context3.abrupt("return", _this.queryRawKioskProductPool(data));
|
|
307
|
+
case 3:
|
|
302
308
|
menu_list_ids = data.menu_list_ids, customer_id = data.customer_id, ids = data.ids, extension_type = data.extension_type, strategy_context = data.strategy_context;
|
|
303
309
|
_this$resolveProductQ = _this.resolveProductQueryScheduleContext({
|
|
304
310
|
schedule_date: data.schedule_date,
|
|
@@ -334,7 +340,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
334
340
|
totalSubscribers: _this.productQuerySubscribers.size
|
|
335
341
|
});
|
|
336
342
|
}
|
|
337
|
-
_context3.next =
|
|
343
|
+
_context3.next = 10;
|
|
338
344
|
return _this.computeProductQueryResult({
|
|
339
345
|
menu_list_ids: menu_list_ids,
|
|
340
346
|
ids: ids,
|
|
@@ -344,7 +350,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
344
350
|
extension_type: extension_type,
|
|
345
351
|
strategy_context: strategy_context
|
|
346
352
|
});
|
|
347
|
-
case
|
|
353
|
+
case 10:
|
|
348
354
|
result = _context3.sent;
|
|
349
355
|
if (subscriberId && typeof callback === 'function') {
|
|
350
356
|
_this.syncProductQueryScheduleTimers({
|
|
@@ -354,7 +360,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
354
360
|
});
|
|
355
361
|
}
|
|
356
362
|
return _context3.abrupt("return", result);
|
|
357
|
-
case
|
|
363
|
+
case 13:
|
|
358
364
|
case "end":
|
|
359
365
|
return _context3.stop();
|
|
360
366
|
}
|
|
@@ -4008,13 +4014,91 @@ var Server = /*#__PURE__*/function () {
|
|
|
4008
4014
|
}
|
|
4009
4015
|
}
|
|
4010
4016
|
}, {
|
|
4011
|
-
key: "
|
|
4012
|
-
value:
|
|
4017
|
+
key: "queryRawKioskProductPool",
|
|
4018
|
+
value: function () {
|
|
4019
|
+
var _queryRawKioskProductPool = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(data) {
|
|
4020
|
+
var _this$products3;
|
|
4021
|
+
var preload, products, filterSet, ids, collections, categories, extensionTypes, list;
|
|
4022
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
4023
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4024
|
+
case 0:
|
|
4025
|
+
preload = this.startupModulePreloadInFlight;
|
|
4026
|
+
if (!preload) {
|
|
4027
|
+
_context46.next = 4;
|
|
4028
|
+
break;
|
|
4029
|
+
}
|
|
4030
|
+
_context46.next = 4;
|
|
4031
|
+
return preload;
|
|
4032
|
+
case 4:
|
|
4033
|
+
if ((_this$products3 = this.products) !== null && _this$products3 !== void 0 && _this$products3.getProducts) {
|
|
4034
|
+
_context46.next = 6;
|
|
4035
|
+
break;
|
|
4036
|
+
}
|
|
4037
|
+
throw new Error('The local product catalog is not ready.');
|
|
4038
|
+
case 6:
|
|
4039
|
+
_context46.next = 8;
|
|
4040
|
+
return this.products.getProducts();
|
|
4041
|
+
case 8:
|
|
4042
|
+
products = _context46.sent;
|
|
4043
|
+
if (Array.isArray(products)) {
|
|
4044
|
+
_context46.next = 11;
|
|
4045
|
+
break;
|
|
4046
|
+
}
|
|
4047
|
+
throw new Error('The local product catalog is unavailable.');
|
|
4048
|
+
case 11:
|
|
4049
|
+
filterSet = function filterSet(value) {
|
|
4050
|
+
return Array.isArray(value) && value.length ? new Set(value.filter(function (item) {
|
|
4051
|
+
return typeof item === 'string' || typeof item === 'number';
|
|
4052
|
+
}).map(function (item) {
|
|
4053
|
+
return String(item).trim();
|
|
4054
|
+
}).filter(Boolean)) : undefined;
|
|
4055
|
+
};
|
|
4056
|
+
ids = filterSet(data.ids);
|
|
4057
|
+
collections = filterSet(typeof data.collection === 'number' ? [data.collection] : data.collection);
|
|
4058
|
+
categories = filterSet(data.category_ids);
|
|
4059
|
+
extensionTypes = filterSet(data.extension_type);
|
|
4060
|
+
list = products.filter(function (product) {
|
|
4061
|
+
var _product$collection, _product$categories;
|
|
4062
|
+
if ((product.status || 'published') !== 'published' || 'deleted_at' in product && product.deleted_at) return false;
|
|
4063
|
+
if (!Array.isArray(product.channel_application) || !product.channel_application.includes('kiosk')) return false;
|
|
4064
|
+
if (ids && !ids.has(String(product.id))) return false;
|
|
4065
|
+
if (collections && !((_product$collection = product.collection) !== null && _product$collection !== void 0 && _product$collection.some(function (collection) {
|
|
4066
|
+
return collections.has(String(collection.id));
|
|
4067
|
+
}))) return false;
|
|
4068
|
+
if (categories && !((_product$categories = product.categories) !== null && _product$categories !== void 0 && _product$categories.some(function (category) {
|
|
4069
|
+
var _category$pivot;
|
|
4070
|
+
return categories.has(String(category.id)) || categories.has(String((_category$pivot = category.pivot) === null || _category$pivot === void 0 ? void 0 : _category$pivot.product_category_id));
|
|
4071
|
+
}))) return false;
|
|
4072
|
+
return !extensionTypes || extensionTypes.has(String(product.extension_type));
|
|
4073
|
+
});
|
|
4074
|
+
return _context46.abrupt("return", {
|
|
4075
|
+
code: 200,
|
|
4076
|
+
status: true,
|
|
4077
|
+
message: '',
|
|
4078
|
+
data: {
|
|
4079
|
+
list: list,
|
|
4080
|
+
count: list.length,
|
|
4081
|
+
schedule_time_points: []
|
|
4082
|
+
}
|
|
4083
|
+
});
|
|
4084
|
+
case 18:
|
|
4085
|
+
case "end":
|
|
4086
|
+
return _context46.stop();
|
|
4087
|
+
}
|
|
4088
|
+
}, _callee46, this);
|
|
4089
|
+
}));
|
|
4090
|
+
function queryRawKioskProductPool(_x46) {
|
|
4091
|
+
return _queryRawKioskProductPool.apply(this, arguments);
|
|
4092
|
+
}
|
|
4093
|
+
return queryRawKioskProductPool;
|
|
4094
|
+
}()
|
|
4013
4095
|
/**
|
|
4014
4096
|
* ProductList callers such as standalone retail pages do not always have a selected schedule.
|
|
4015
4097
|
* In that case query against the current local time so menu availability can still be evaluated.
|
|
4016
4098
|
*/
|
|
4017
|
-
|
|
4099
|
+
}, {
|
|
4100
|
+
key: "resolveProductQueryScheduleContext",
|
|
4101
|
+
value: function resolveProductQueryScheduleContext(params) {
|
|
4018
4102
|
var now = dayjs();
|
|
4019
4103
|
var schedule_datetime = typeof params.schedule_datetime === 'string' && params.schedule_datetime.trim() ? params.schedule_datetime : now.format('YYYY-MM-DD HH:mm:ss');
|
|
4020
4104
|
var schedule_date = typeof params.schedule_date === 'string' && params.schedule_date.trim() ? params.schedule_date : dayjs(schedule_datetime).isValid() ? dayjs(schedule_datetime).format('YYYY-MM-DD') : now.format('YYYY-MM-DD');
|
|
@@ -4031,24 +4115,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
4031
4115
|
}, {
|
|
4032
4116
|
key: "refreshMenuScheduleCacheAfterEmptyResult",
|
|
4033
4117
|
value: (function () {
|
|
4034
|
-
var _refreshMenuScheduleCacheAfterEmptyResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4118
|
+
var _refreshMenuScheduleCacheAfterEmptyResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
|
|
4035
4119
|
var _this10 = this;
|
|
4036
4120
|
var now;
|
|
4037
|
-
return _regeneratorRuntime().wrap(function
|
|
4038
|
-
while (1) switch (
|
|
4121
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
4122
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4039
4123
|
case 0:
|
|
4040
4124
|
if (!(!this.menu || !this.schedule)) {
|
|
4041
|
-
|
|
4125
|
+
_context47.next = 2;
|
|
4042
4126
|
break;
|
|
4043
4127
|
}
|
|
4044
|
-
return
|
|
4128
|
+
return _context47.abrupt("return", false);
|
|
4045
4129
|
case 2:
|
|
4046
4130
|
now = Date.now();
|
|
4047
4131
|
if (!(now - this.lastMenuScheduleRefreshAt < this.MENU_SCHEDULE_REFRESH_COOLDOWN_MS)) {
|
|
4048
|
-
|
|
4132
|
+
_context47.next = 5;
|
|
4049
4133
|
break;
|
|
4050
4134
|
}
|
|
4051
|
-
return
|
|
4135
|
+
return _context47.abrupt("return", false);
|
|
4052
4136
|
case 5:
|
|
4053
4137
|
if (!this.menuScheduleRefreshInFlight) {
|
|
4054
4138
|
this.lastMenuScheduleRefreshAt = now;
|
|
@@ -4062,15 +4146,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
4062
4146
|
_this10.menuScheduleRefreshInFlight = null;
|
|
4063
4147
|
});
|
|
4064
4148
|
}
|
|
4065
|
-
|
|
4149
|
+
_context47.next = 8;
|
|
4066
4150
|
return this.menuScheduleRefreshInFlight;
|
|
4067
4151
|
case 8:
|
|
4068
|
-
return
|
|
4152
|
+
return _context47.abrupt("return", true);
|
|
4069
4153
|
case 9:
|
|
4070
4154
|
case "end":
|
|
4071
|
-
return
|
|
4155
|
+
return _context47.stop();
|
|
4072
4156
|
}
|
|
4073
|
-
},
|
|
4157
|
+
}, _callee47, this);
|
|
4074
4158
|
}));
|
|
4075
4159
|
function refreshMenuScheduleCacheAfterEmptyResult() {
|
|
4076
4160
|
return _refreshMenuScheduleCacheAfterEmptyResult.apply(this, arguments);
|
|
@@ -4088,16 +4172,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
4088
4172
|
* const result = await this.handleSalesSearchRequest('single', '/shop/es/search/sales', { keyword: '1001' }, {})
|
|
4089
4173
|
*/
|
|
4090
4174
|
function () {
|
|
4091
|
-
var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4175
|
+
var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(kind, backendPath, data, config) {
|
|
4092
4176
|
var queryPayload, result, _ref62, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
|
|
4093
|
-
return _regeneratorRuntime().wrap(function
|
|
4094
|
-
while (1) switch (
|
|
4177
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
4178
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4095
4179
|
case 0:
|
|
4096
4180
|
queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
|
|
4097
|
-
|
|
4181
|
+
_context48.next = 3;
|
|
4098
4182
|
return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
|
|
4099
4183
|
case 3:
|
|
4100
|
-
result =
|
|
4184
|
+
result = _context48.sent;
|
|
4101
4185
|
_ref62 = config || {}, callback = _ref62.callback, subscriberId = _ref62.subscriberId, resetVisibleOrderIds = _ref62.resetVisibleOrderIds;
|
|
4102
4186
|
if (subscriberId && typeof callback === 'function') {
|
|
4103
4187
|
contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
|
|
@@ -4129,14 +4213,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
4129
4213
|
visibleCount: visibleOrderIds.size
|
|
4130
4214
|
});
|
|
4131
4215
|
}
|
|
4132
|
-
return
|
|
4216
|
+
return _context48.abrupt("return", result);
|
|
4133
4217
|
case 7:
|
|
4134
4218
|
case "end":
|
|
4135
|
-
return
|
|
4219
|
+
return _context48.stop();
|
|
4136
4220
|
}
|
|
4137
|
-
},
|
|
4221
|
+
}, _callee48, this);
|
|
4138
4222
|
}));
|
|
4139
|
-
function handleSalesSearchRequest(
|
|
4223
|
+
function handleSalesSearchRequest(_x47, _x48, _x49, _x50) {
|
|
4140
4224
|
return _handleSalesSearchRequest.apply(this, arguments);
|
|
4141
4225
|
}
|
|
4142
4226
|
return handleSalesSearchRequest;
|
|
@@ -4151,20 +4235,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
4151
4235
|
}, {
|
|
4152
4236
|
key: "fetchSalesSearchFromAPI",
|
|
4153
4237
|
value: (function () {
|
|
4154
|
-
var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4238
|
+
var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(backendPath, data) {
|
|
4155
4239
|
var _this$app7;
|
|
4156
4240
|
var _response$data3, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
|
|
4157
|
-
return _regeneratorRuntime().wrap(function
|
|
4158
|
-
while (1) switch (
|
|
4241
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
4242
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
4159
4243
|
case 0:
|
|
4160
4244
|
if ((_this$app7 = this.app) !== null && _this$app7 !== void 0 && _this$app7.request) {
|
|
4161
|
-
|
|
4245
|
+
_context49.next = 3;
|
|
4162
4246
|
break;
|
|
4163
4247
|
}
|
|
4164
4248
|
this.logError('fetchSalesSearchFromAPI: app.request 不可用', {
|
|
4165
4249
|
backendPath: backendPath
|
|
4166
4250
|
});
|
|
4167
|
-
return
|
|
4251
|
+
return _context49.abrupt("return", {
|
|
4168
4252
|
code: 500,
|
|
4169
4253
|
message: 'app.request 不可用',
|
|
4170
4254
|
data: backendPath === '/shop/es/search' ? {
|
|
@@ -4176,29 +4260,29 @@ var Server = /*#__PURE__*/function () {
|
|
|
4176
4260
|
status: false
|
|
4177
4261
|
});
|
|
4178
4262
|
case 3:
|
|
4179
|
-
|
|
4180
|
-
|
|
4263
|
+
_context49.prev = 3;
|
|
4264
|
+
_context49.next = 6;
|
|
4181
4265
|
return this.app.request.post(backendPath, data, {
|
|
4182
4266
|
isShopApi: true
|
|
4183
4267
|
});
|
|
4184
4268
|
case 6:
|
|
4185
|
-
response =
|
|
4269
|
+
response = _context49.sent;
|
|
4186
4270
|
_payload = (_response$data3 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data3 !== void 0 ? _response$data3 : response;
|
|
4187
|
-
return
|
|
4271
|
+
return _context49.abrupt("return", {
|
|
4188
4272
|
code: (_response$code2 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code2 !== void 0 ? _response$code2 : 200,
|
|
4189
4273
|
status: (_response$status2 = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status2 !== void 0 ? _response$status2 : true,
|
|
4190
4274
|
message: (_response$message2 = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message2 !== void 0 ? _response$message2 : '',
|
|
4191
4275
|
data: _payload
|
|
4192
4276
|
});
|
|
4193
4277
|
case 11:
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
errorMessage =
|
|
4278
|
+
_context49.prev = 11;
|
|
4279
|
+
_context49.t0 = _context49["catch"](3);
|
|
4280
|
+
errorMessage = _context49.t0 instanceof Error ? _context49.t0.message : String(_context49.t0);
|
|
4197
4281
|
this.logError('fetchSalesSearchFromAPI: 请求失败', {
|
|
4198
4282
|
backendPath: backendPath,
|
|
4199
4283
|
error: errorMessage
|
|
4200
4284
|
});
|
|
4201
|
-
return
|
|
4285
|
+
return _context49.abrupt("return", {
|
|
4202
4286
|
code: 500,
|
|
4203
4287
|
message: errorMessage,
|
|
4204
4288
|
data: backendPath === '/shop/es/search' ? {
|
|
@@ -4211,11 +4295,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4211
4295
|
});
|
|
4212
4296
|
case 16:
|
|
4213
4297
|
case "end":
|
|
4214
|
-
return
|
|
4298
|
+
return _context49.stop();
|
|
4215
4299
|
}
|
|
4216
|
-
},
|
|
4300
|
+
}, _callee49, this, [[3, 11]]);
|
|
4217
4301
|
}));
|
|
4218
|
-
function fetchSalesSearchFromAPI(
|
|
4302
|
+
function fetchSalesSearchFromAPI(_x51, _x52) {
|
|
4219
4303
|
return _fetchSalesSearchFromAPI.apply(this, arguments);
|
|
4220
4304
|
}
|
|
4221
4305
|
return fetchSalesSearchFromAPI;
|
|
@@ -4738,18 +4822,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
4738
4822
|
}, {
|
|
4739
4823
|
key: "fetchOrderListFromAPI",
|
|
4740
4824
|
value: (function () {
|
|
4741
|
-
var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4825
|
+
var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(data) {
|
|
4742
4826
|
var _this$app8;
|
|
4743
4827
|
var _response$data4, response, _payload2, list, count, errorMessage;
|
|
4744
|
-
return _regeneratorRuntime().wrap(function
|
|
4745
|
-
while (1) switch (
|
|
4828
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
4829
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
4746
4830
|
case 0:
|
|
4747
4831
|
if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
|
|
4748
|
-
|
|
4832
|
+
_context50.next = 3;
|
|
4749
4833
|
break;
|
|
4750
4834
|
}
|
|
4751
4835
|
this.logError('fetchOrderListFromAPI: app.request 不可用');
|
|
4752
|
-
return
|
|
4836
|
+
return _context50.abrupt("return", {
|
|
4753
4837
|
code: 500,
|
|
4754
4838
|
message: 'app.request 不可用',
|
|
4755
4839
|
data: {
|
|
@@ -4759,17 +4843,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
4759
4843
|
status: false
|
|
4760
4844
|
});
|
|
4761
4845
|
case 3:
|
|
4762
|
-
|
|
4763
|
-
|
|
4846
|
+
_context50.prev = 3;
|
|
4847
|
+
_context50.next = 6;
|
|
4764
4848
|
return this.app.request.post('/shop/order/v2/list', data, {
|
|
4765
4849
|
isShopApi: true
|
|
4766
4850
|
});
|
|
4767
4851
|
case 6:
|
|
4768
|
-
response =
|
|
4852
|
+
response = _context50.sent;
|
|
4769
4853
|
_payload2 = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
|
|
4770
4854
|
list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
|
|
4771
4855
|
count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
|
|
4772
|
-
return
|
|
4856
|
+
return _context50.abrupt("return", {
|
|
4773
4857
|
code: 200,
|
|
4774
4858
|
data: _objectSpread(_objectSpread({}, _payload2), {}, {
|
|
4775
4859
|
list: list,
|
|
@@ -4779,13 +4863,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4779
4863
|
status: true
|
|
4780
4864
|
});
|
|
4781
4865
|
case 13:
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
errorMessage =
|
|
4866
|
+
_context50.prev = 13;
|
|
4867
|
+
_context50.t0 = _context50["catch"](3);
|
|
4868
|
+
errorMessage = _context50.t0 instanceof Error ? _context50.t0.message : String(_context50.t0);
|
|
4785
4869
|
this.logError('fetchOrderListFromAPI: 请求失败', {
|
|
4786
4870
|
error: errorMessage
|
|
4787
4871
|
});
|
|
4788
|
-
return
|
|
4872
|
+
return _context50.abrupt("return", {
|
|
4789
4873
|
code: 500,
|
|
4790
4874
|
message: errorMessage,
|
|
4791
4875
|
data: {
|
|
@@ -4796,11 +4880,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4796
4880
|
});
|
|
4797
4881
|
case 18:
|
|
4798
4882
|
case "end":
|
|
4799
|
-
return
|
|
4883
|
+
return _context50.stop();
|
|
4800
4884
|
}
|
|
4801
|
-
},
|
|
4885
|
+
}, _callee50, this, [[3, 13]]);
|
|
4802
4886
|
}));
|
|
4803
|
-
function fetchOrderListFromAPI(
|
|
4887
|
+
function fetchOrderListFromAPI(_x53) {
|
|
4804
4888
|
return _fetchOrderListFromAPI.apply(this, arguments);
|
|
4805
4889
|
}
|
|
4806
4890
|
return fetchOrderListFromAPI;
|
|
@@ -4812,17 +4896,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
4812
4896
|
}, {
|
|
4813
4897
|
key: "fetchBookingListFromAPI",
|
|
4814
4898
|
value: (function () {
|
|
4815
|
-
var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4899
|
+
var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(data) {
|
|
4816
4900
|
var memoryCacheEnabled, withFields, requestPayload, cacheKey, cached, rawList, bookingResult, _bookingResult$list, errorMessage;
|
|
4817
|
-
return _regeneratorRuntime().wrap(function
|
|
4818
|
-
while (1) switch (
|
|
4901
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
4902
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
4819
4903
|
case 0:
|
|
4820
4904
|
if (this.order) {
|
|
4821
|
-
|
|
4905
|
+
_context51.next = 3;
|
|
4822
4906
|
break;
|
|
4823
4907
|
}
|
|
4824
4908
|
this.logError('fetchBookingListFromAPI: Order 模块不可用');
|
|
4825
|
-
return
|
|
4909
|
+
return _context51.abrupt("return", {
|
|
4826
4910
|
code: 500,
|
|
4827
4911
|
message: 'Order 模块不可用',
|
|
4828
4912
|
data: {
|
|
@@ -4832,18 +4916,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
4832
4916
|
status: false
|
|
4833
4917
|
});
|
|
4834
4918
|
case 3:
|
|
4835
|
-
|
|
4919
|
+
_context51.prev = 3;
|
|
4836
4920
|
memoryCacheEnabled = this.isBookingRemoteMemoryCacheEnabled(data);
|
|
4837
4921
|
withFields = this.resolveBookingSalesWith(data);
|
|
4838
4922
|
requestPayload = this.normalizeBookingRemoteQueryPayload(data, withFields);
|
|
4839
4923
|
cacheKey = this.buildBookingRemoteCacheKey(requestPayload);
|
|
4840
4924
|
if (!memoryCacheEnabled) {
|
|
4841
|
-
|
|
4925
|
+
_context51.next = 13;
|
|
4842
4926
|
break;
|
|
4843
4927
|
}
|
|
4844
4928
|
cached = this.readBookingRemoteCache(cacheKey);
|
|
4845
4929
|
if (!cached) {
|
|
4846
|
-
|
|
4930
|
+
_context51.next = 13;
|
|
4847
4931
|
break;
|
|
4848
4932
|
}
|
|
4849
4933
|
this.logInfo('fetchBookingListFromAPI: 命中内存缓存', {
|
|
@@ -4851,14 +4935,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
4851
4935
|
listCount: cached.bookingResult.count,
|
|
4852
4936
|
withFields: cached.withFields
|
|
4853
4937
|
});
|
|
4854
|
-
return
|
|
4938
|
+
return _context51.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
|
|
4855
4939
|
cache_hit: true
|
|
4856
4940
|
}));
|
|
4857
4941
|
case 13:
|
|
4858
|
-
|
|
4942
|
+
_context51.next = 15;
|
|
4859
4943
|
return this.order.fetchOrdersBySSE(requestPayload);
|
|
4860
4944
|
case 15:
|
|
4861
|
-
rawList =
|
|
4945
|
+
rawList = _context51.sent;
|
|
4862
4946
|
bookingResult = sortBookings(filterBookingsFromOrders(rawList, data), data); // DEBUG: 挂到 window 上方便排查 SSE → 日历数据丢失问题
|
|
4863
4947
|
if (typeof globalThis !== 'undefined') {
|
|
4864
4948
|
globalThis.__SSE_BOOKING_DEBUG__ = {
|
|
@@ -4905,15 +4989,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
4905
4989
|
cacheKey: cacheKey,
|
|
4906
4990
|
withFields: withFields
|
|
4907
4991
|
});
|
|
4908
|
-
return
|
|
4992
|
+
return _context51.abrupt("return", this.buildBookingResponse(bookingResult));
|
|
4909
4993
|
case 23:
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
errorMessage =
|
|
4994
|
+
_context51.prev = 23;
|
|
4995
|
+
_context51.t0 = _context51["catch"](3);
|
|
4996
|
+
errorMessage = _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0);
|
|
4913
4997
|
this.logError('fetchBookingListFromAPI: SSE 请求失败', {
|
|
4914
4998
|
error: errorMessage
|
|
4915
4999
|
});
|
|
4916
|
-
return
|
|
5000
|
+
return _context51.abrupt("return", {
|
|
4917
5001
|
code: 500,
|
|
4918
5002
|
message: errorMessage,
|
|
4919
5003
|
data: {
|
|
@@ -4924,11 +5008,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4924
5008
|
});
|
|
4925
5009
|
case 28:
|
|
4926
5010
|
case "end":
|
|
4927
|
-
return
|
|
5011
|
+
return _context51.stop();
|
|
4928
5012
|
}
|
|
4929
|
-
},
|
|
5013
|
+
}, _callee51, this, [[3, 23]]);
|
|
4930
5014
|
}));
|
|
4931
|
-
function fetchBookingListFromAPI(
|
|
5015
|
+
function fetchBookingListFromAPI(_x54) {
|
|
4932
5016
|
return _fetchBookingListFromAPI.apply(this, arguments);
|
|
4933
5017
|
}
|
|
4934
5018
|
return fetchBookingListFromAPI;
|
|
@@ -5012,11 +5096,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5012
5096
|
}, {
|
|
5013
5097
|
key: "runLocalPaymentUpdateInQueue",
|
|
5014
5098
|
value: function () {
|
|
5015
|
-
var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5099
|
+
var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(key, task, context) {
|
|
5016
5100
|
var _this14 = this;
|
|
5017
5101
|
var queuedAt, hasPreviousTask, previous, current, tail, _data, result, released;
|
|
5018
|
-
return _regeneratorRuntime().wrap(function
|
|
5019
|
-
while (1) switch (
|
|
5102
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
5103
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
5020
5104
|
case 0:
|
|
5021
5105
|
queuedAt = Date.now();
|
|
5022
5106
|
hasPreviousTask = this.localPaymentUpdateQueues.has(key);
|
|
@@ -5028,20 +5112,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
5028
5112
|
}));
|
|
5029
5113
|
current = previous.catch(function () {
|
|
5030
5114
|
return undefined;
|
|
5031
|
-
}).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5032
|
-
return _regeneratorRuntime().wrap(function
|
|
5033
|
-
while (1) switch (
|
|
5115
|
+
}).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52() {
|
|
5116
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
5117
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
5034
5118
|
case 0:
|
|
5035
5119
|
_this14.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
|
|
5036
5120
|
queue_key: key,
|
|
5037
5121
|
queue_wait_ms: Date.now() - queuedAt
|
|
5038
5122
|
}));
|
|
5039
|
-
return
|
|
5123
|
+
return _context52.abrupt("return", task());
|
|
5040
5124
|
case 2:
|
|
5041
5125
|
case "end":
|
|
5042
|
-
return
|
|
5126
|
+
return _context52.stop();
|
|
5043
5127
|
}
|
|
5044
|
-
},
|
|
5128
|
+
}, _callee52);
|
|
5045
5129
|
})));
|
|
5046
5130
|
tail = current.then(function () {
|
|
5047
5131
|
return undefined;
|
|
@@ -5049,11 +5133,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5049
5133
|
return undefined;
|
|
5050
5134
|
});
|
|
5051
5135
|
this.localPaymentUpdateQueues.set(key, tail);
|
|
5052
|
-
|
|
5053
|
-
|
|
5136
|
+
_context53.prev = 7;
|
|
5137
|
+
_context53.next = 10;
|
|
5054
5138
|
return current;
|
|
5055
5139
|
case 10:
|
|
5056
|
-
result =
|
|
5140
|
+
result = _context53.sent;
|
|
5057
5141
|
this.logInfo('handleUpdateLocalPayment: 串行队列执行完成', _objectSpread(_objectSpread({}, context), {}, {
|
|
5058
5142
|
queue_key: key,
|
|
5059
5143
|
total_duration_ms: Date.now() - queuedAt,
|
|
@@ -5061,19 +5145,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
5061
5145
|
result_status: result === null || result === void 0 ? void 0 : result.status,
|
|
5062
5146
|
payment: result === null || result === void 0 || (_data = result.data) === null || _data === void 0 ? void 0 : _data.payment
|
|
5063
5147
|
}));
|
|
5064
|
-
return
|
|
5148
|
+
return _context53.abrupt("return", result);
|
|
5065
5149
|
case 15:
|
|
5066
|
-
|
|
5067
|
-
|
|
5150
|
+
_context53.prev = 15;
|
|
5151
|
+
_context53.t0 = _context53["catch"](7);
|
|
5068
5152
|
this.logError('handleUpdateLocalPayment: 串行队列执行失败', _objectSpread(_objectSpread({}, context), {}, {
|
|
5069
5153
|
queue_key: key,
|
|
5070
5154
|
total_duration_ms: Date.now() - queuedAt,
|
|
5071
|
-
error:
|
|
5072
|
-
error_detail: this.normalizeUnknownError(
|
|
5155
|
+
error: _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0),
|
|
5156
|
+
error_detail: this.normalizeUnknownError(_context53.t0)
|
|
5073
5157
|
}));
|
|
5074
|
-
throw
|
|
5158
|
+
throw _context53.t0;
|
|
5075
5159
|
case 19:
|
|
5076
|
-
|
|
5160
|
+
_context53.prev = 19;
|
|
5077
5161
|
released = false;
|
|
5078
5162
|
if (this.localPaymentUpdateQueues.get(key) === tail) {
|
|
5079
5163
|
this.localPaymentUpdateQueues.delete(key);
|
|
@@ -5084,14 +5168,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
5084
5168
|
released: released,
|
|
5085
5169
|
active_queue_count: this.localPaymentUpdateQueues.size
|
|
5086
5170
|
}));
|
|
5087
|
-
return
|
|
5171
|
+
return _context53.finish(19);
|
|
5088
5172
|
case 24:
|
|
5089
5173
|
case "end":
|
|
5090
|
-
return
|
|
5174
|
+
return _context53.stop();
|
|
5091
5175
|
}
|
|
5092
|
-
},
|
|
5176
|
+
}, _callee53, this, [[7, 15, 19, 24]]);
|
|
5093
5177
|
}));
|
|
5094
|
-
function runLocalPaymentUpdateInQueue(
|
|
5178
|
+
function runLocalPaymentUpdateInQueue(_x55, _x56, _x57) {
|
|
5095
5179
|
return _runLocalPaymentUpdateInQueue.apply(this, arguments);
|
|
5096
5180
|
}
|
|
5097
5181
|
return runLocalPaymentUpdateInQueue;
|
|
@@ -5099,11 +5183,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5099
5183
|
}, {
|
|
5100
5184
|
key: "processLocalPaymentUpdate",
|
|
5101
5185
|
value: function () {
|
|
5102
|
-
var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5186
|
+
var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
|
|
5103
5187
|
var _params$serviceCharge4, _params$cardReaderSur, _found$payment, _found$payment2;
|
|
5104
5188
|
var requestContext, found, surchargeUpdate, incomingPaymentUpdate, transactions, existingTransaction, hasRecordedSuccess, orderIsDraft, foundContext, alreadyRecordedFailure, updated;
|
|
5105
|
-
return _regeneratorRuntime().wrap(function
|
|
5106
|
-
while (1) switch (
|
|
5189
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5190
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
5107
5191
|
case 0:
|
|
5108
5192
|
requestContext = {
|
|
5109
5193
|
operation_id: params.operationId,
|
|
@@ -5116,11 +5200,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5116
5200
|
};
|
|
5117
5201
|
this.logInfo('processLocalPaymentUpdate: 开始处理', requestContext);
|
|
5118
5202
|
if (this.order) {
|
|
5119
|
-
|
|
5203
|
+
_context54.next = 5;
|
|
5120
5204
|
break;
|
|
5121
5205
|
}
|
|
5122
5206
|
this.logError('processLocalPaymentUpdate: Order 模块未注册', requestContext);
|
|
5123
|
-
return
|
|
5207
|
+
return _context54.abrupt("return", {
|
|
5124
5208
|
code: 500,
|
|
5125
5209
|
status: false,
|
|
5126
5210
|
message: 'Order 模块未注册',
|
|
@@ -5128,20 +5212,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
5128
5212
|
});
|
|
5129
5213
|
case 5:
|
|
5130
5214
|
this.logInfo('processLocalPaymentUpdate: 开始查询本地支付项', requestContext);
|
|
5131
|
-
|
|
5215
|
+
_context54.next = 8;
|
|
5132
5216
|
return this.order.getLocalPayment({
|
|
5133
5217
|
saleId: params.saleId,
|
|
5134
5218
|
paymentNumber: params.paymentNumber,
|
|
5135
5219
|
operationId: params.operationId
|
|
5136
5220
|
});
|
|
5137
5221
|
case 8:
|
|
5138
|
-
found =
|
|
5222
|
+
found = _context54.sent;
|
|
5139
5223
|
if (found) {
|
|
5140
|
-
|
|
5224
|
+
_context54.next = 12;
|
|
5141
5225
|
break;
|
|
5142
5226
|
}
|
|
5143
5227
|
this.logWarning('processLocalPaymentUpdate: 本地支付项不存在', requestContext);
|
|
5144
|
-
return
|
|
5228
|
+
return _context54.abrupt("return", {
|
|
5145
5229
|
code: 404,
|
|
5146
5230
|
status: false,
|
|
5147
5231
|
message: '本地支付项不存在',
|
|
@@ -5190,13 +5274,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
5190
5274
|
});
|
|
5191
5275
|
this.logInfo('processLocalPaymentUpdate: 查询命中', foundContext);
|
|
5192
5276
|
if (!(params.status === 'fail' && (found.payment.status === 'paid' || hasRecordedSuccess))) {
|
|
5193
|
-
|
|
5277
|
+
_context54.next = 23;
|
|
5194
5278
|
break;
|
|
5195
5279
|
}
|
|
5196
5280
|
this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
5197
5281
|
idempotent_reason: 'ignore_failure_after_success'
|
|
5198
5282
|
}));
|
|
5199
|
-
return
|
|
5283
|
+
return _context54.abrupt("return", {
|
|
5200
5284
|
code: 200,
|
|
5201
5285
|
status: true,
|
|
5202
5286
|
message: '',
|
|
@@ -5209,13 +5293,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
5209
5293
|
case 23:
|
|
5210
5294
|
alreadyRecordedFailure = params.status === 'fail' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'fail';
|
|
5211
5295
|
if (!alreadyRecordedFailure) {
|
|
5212
|
-
|
|
5296
|
+
_context54.next = 27;
|
|
5213
5297
|
break;
|
|
5214
5298
|
}
|
|
5215
5299
|
this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
5216
5300
|
idempotent_reason: 'failure_already_recorded'
|
|
5217
5301
|
}));
|
|
5218
|
-
return
|
|
5302
|
+
return _context54.abrupt("return", {
|
|
5219
5303
|
code: 200,
|
|
5220
5304
|
status: true,
|
|
5221
5305
|
message: '',
|
|
@@ -5227,13 +5311,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
5227
5311
|
});
|
|
5228
5312
|
case 27:
|
|
5229
5313
|
if (!(params.status === 'success' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'success' && found.payment.status === 'paid' && !orderIsDraft)) {
|
|
5230
|
-
|
|
5314
|
+
_context54.next = 30;
|
|
5231
5315
|
break;
|
|
5232
5316
|
}
|
|
5233
5317
|
this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
5234
5318
|
idempotent_reason: 'success_already_committed'
|
|
5235
5319
|
}));
|
|
5236
|
-
return
|
|
5320
|
+
return _context54.abrupt("return", {
|
|
5237
5321
|
code: 200,
|
|
5238
5322
|
status: true,
|
|
5239
5323
|
message: '',
|
|
@@ -5245,13 +5329,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
5245
5329
|
});
|
|
5246
5330
|
case 30:
|
|
5247
5331
|
if (!(params.status === 'success')) {
|
|
5248
|
-
|
|
5332
|
+
_context54.next = 33;
|
|
5249
5333
|
break;
|
|
5250
5334
|
}
|
|
5251
5335
|
this.logInfo('processLocalPaymentUpdate: 进入 success 恢复分支', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
5252
5336
|
force_submit_if_paid: found.payment.status === 'paid' && orderIsDraft
|
|
5253
5337
|
}));
|
|
5254
|
-
return
|
|
5338
|
+
return _context54.abrupt("return", this.processSuccessfulLocalPayment(_objectSpread(_objectSpread({}, params), {}, {
|
|
5255
5339
|
order: found.order,
|
|
5256
5340
|
payment: found.payment,
|
|
5257
5341
|
matchBy: found.matchedBy === 'payment_number' ? 'payment_number' : 'compat',
|
|
@@ -5262,8 +5346,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
5262
5346
|
this.logInfo('processLocalPaymentUpdate: 进入 fail 本地更新分支', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
5263
5347
|
incoming_payment_update: incomingPaymentUpdate
|
|
5264
5348
|
}));
|
|
5265
|
-
|
|
5266
|
-
|
|
5349
|
+
_context54.prev = 34;
|
|
5350
|
+
_context54.next = 37;
|
|
5267
5351
|
return this.order.updateLocalPayment({
|
|
5268
5352
|
saleId: params.saleId,
|
|
5269
5353
|
paymentNumber: params.paymentNumber,
|
|
@@ -5271,25 +5355,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
5271
5355
|
updates: incomingPaymentUpdate
|
|
5272
5356
|
});
|
|
5273
5357
|
case 37:
|
|
5274
|
-
updated =
|
|
5275
|
-
|
|
5358
|
+
updated = _context54.sent;
|
|
5359
|
+
_context54.next = 44;
|
|
5276
5360
|
break;
|
|
5277
5361
|
case 40:
|
|
5278
|
-
|
|
5279
|
-
|
|
5362
|
+
_context54.prev = 40;
|
|
5363
|
+
_context54.t0 = _context54["catch"](34);
|
|
5280
5364
|
this.logError('processLocalPaymentUpdate: fail 本地更新失败', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
5281
5365
|
incoming_payment_update: incomingPaymentUpdate,
|
|
5282
|
-
error:
|
|
5283
|
-
error_detail: this.normalizeUnknownError(
|
|
5366
|
+
error: _context54.t0 instanceof Error ? _context54.t0.message : String(_context54.t0),
|
|
5367
|
+
error_detail: this.normalizeUnknownError(_context54.t0)
|
|
5284
5368
|
}));
|
|
5285
|
-
throw
|
|
5369
|
+
throw _context54.t0;
|
|
5286
5370
|
case 44:
|
|
5287
5371
|
if (updated) {
|
|
5288
|
-
|
|
5372
|
+
_context54.next = 47;
|
|
5289
5373
|
break;
|
|
5290
5374
|
}
|
|
5291
5375
|
this.logWarning('processLocalPaymentUpdate: fail 本地更新未命中', foundContext);
|
|
5292
|
-
return
|
|
5376
|
+
return _context54.abrupt("return", {
|
|
5293
5377
|
code: 404,
|
|
5294
5378
|
status: false,
|
|
5295
5379
|
message: '本地支付项不存在',
|
|
@@ -5300,7 +5384,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5300
5384
|
previous_payment: updated.previousPayment,
|
|
5301
5385
|
payment: updated.payment
|
|
5302
5386
|
}));
|
|
5303
|
-
return
|
|
5387
|
+
return _context54.abrupt("return", {
|
|
5304
5388
|
code: 200,
|
|
5305
5389
|
status: true,
|
|
5306
5390
|
message: '',
|
|
@@ -5312,11 +5396,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5312
5396
|
});
|
|
5313
5397
|
case 49:
|
|
5314
5398
|
case "end":
|
|
5315
|
-
return
|
|
5399
|
+
return _context54.stop();
|
|
5316
5400
|
}
|
|
5317
|
-
},
|
|
5401
|
+
}, _callee54, this, [[34, 40]]);
|
|
5318
5402
|
}));
|
|
5319
|
-
function processLocalPaymentUpdate(
|
|
5403
|
+
function processLocalPaymentUpdate(_x58) {
|
|
5320
5404
|
return _processLocalPaymentUpdate.apply(this, arguments);
|
|
5321
5405
|
}
|
|
5322
5406
|
return processLocalPaymentUpdate;
|
|
@@ -5324,10 +5408,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5324
5408
|
}, {
|
|
5325
5409
|
key: "processSuccessfulLocalPayment",
|
|
5326
5410
|
value: function () {
|
|
5327
|
-
var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5411
|
+
var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
|
|
5328
5412
|
var moduleName, baseSales, startedAt, recoveryContext, _order$order_id3, _result$payments, _result$syncResult$su, _result$syncResult$su2, _result$draftResult, _result$draftResult2, order, result, message;
|
|
5329
|
-
return _regeneratorRuntime().wrap(function
|
|
5330
|
-
while (1) switch (
|
|
5413
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5414
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
5331
5415
|
case 0:
|
|
5332
5416
|
moduleName = "local_payment_recovery_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 8));
|
|
5333
5417
|
baseSales = new BaseSalesImpl(moduleName);
|
|
@@ -5346,13 +5430,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
5346
5430
|
payment: params.payment
|
|
5347
5431
|
});
|
|
5348
5432
|
this.logInfo('processSuccessfulLocalPayment: 创建临时 BaseSales', recoveryContext);
|
|
5349
|
-
|
|
5433
|
+
_context55.prev = 5;
|
|
5350
5434
|
order = this.sanitizeLocalRecoveryOrder(params.order);
|
|
5351
5435
|
this.logInfo('processSuccessfulLocalPayment: 本地订单清洗完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
5352
5436
|
sanitized_order_id: (_order$order_id3 = order.order_id) !== null && _order$order_id3 !== void 0 ? _order$order_id3 : null,
|
|
5353
5437
|
removed_synthetic_order_id: params.order.order_id != null && order.order_id == null
|
|
5354
5438
|
}));
|
|
5355
|
-
|
|
5439
|
+
_context55.next = 10;
|
|
5356
5440
|
return baseSales.initialize(this.core, {
|
|
5357
5441
|
otherParams: {
|
|
5358
5442
|
platform: order.platform,
|
|
@@ -5365,14 +5449,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
5365
5449
|
});
|
|
5366
5450
|
case 10:
|
|
5367
5451
|
this.logInfo('processSuccessfulLocalPayment: BaseSales 初始化完成', recoveryContext);
|
|
5368
|
-
|
|
5452
|
+
_context55.next = 13;
|
|
5369
5453
|
return baseSales.replaceTempOrder(order);
|
|
5370
5454
|
case 13:
|
|
5371
5455
|
this.logInfo('processSuccessfulLocalPayment: 本地订单 tempOrder 恢复完成', recoveryContext);
|
|
5372
5456
|
this.logInfo('processSuccessfulLocalPayment: 开始更新支付项并提交', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
5373
5457
|
incoming_payment_update: params.paymentUpdate
|
|
5374
5458
|
}));
|
|
5375
|
-
|
|
5459
|
+
_context55.next = 17;
|
|
5376
5460
|
return baseSales.updateOrderPayment(params.paymentNumber, params.paymentUpdate, {
|
|
5377
5461
|
submitWhenPaid: true,
|
|
5378
5462
|
matchBy: params.matchBy,
|
|
@@ -5381,7 +5465,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5381
5465
|
smallTicketDataFlag: 1
|
|
5382
5466
|
});
|
|
5383
5467
|
case 17:
|
|
5384
|
-
result =
|
|
5468
|
+
result = _context55.sent;
|
|
5385
5469
|
this.logInfo('processSuccessfulLocalPayment: 支付恢复完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
5386
5470
|
duration_ms: Date.now() - startedAt,
|
|
5387
5471
|
payment: result.payment,
|
|
@@ -5403,7 +5487,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5403
5487
|
} : null,
|
|
5404
5488
|
draft_error: result.draftError instanceof Error ? result.draftError.message : result.draftError
|
|
5405
5489
|
}));
|
|
5406
|
-
return
|
|
5490
|
+
return _context55.abrupt("return", {
|
|
5407
5491
|
code: 200,
|
|
5408
5492
|
status: true,
|
|
5409
5493
|
message: '',
|
|
@@ -5415,48 +5499,48 @@ var Server = /*#__PURE__*/function () {
|
|
|
5415
5499
|
}
|
|
5416
5500
|
});
|
|
5417
5501
|
case 22:
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
message =
|
|
5502
|
+
_context55.prev = 22;
|
|
5503
|
+
_context55.t0 = _context55["catch"](5);
|
|
5504
|
+
message = _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0);
|
|
5421
5505
|
this.logError('processSuccessfulLocalPayment: 支付恢复失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
5422
5506
|
duration_ms: Date.now() - startedAt,
|
|
5423
5507
|
error: message,
|
|
5424
|
-
error_detail: this.normalizeUnknownError(
|
|
5508
|
+
error_detail: this.normalizeUnknownError(_context55.t0)
|
|
5425
5509
|
}));
|
|
5426
|
-
return
|
|
5510
|
+
return _context55.abrupt("return", {
|
|
5427
5511
|
code: 500,
|
|
5428
5512
|
status: false,
|
|
5429
5513
|
message: message,
|
|
5430
5514
|
data: null
|
|
5431
5515
|
});
|
|
5432
5516
|
case 27:
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5517
|
+
_context55.prev = 27;
|
|
5518
|
+
_context55.prev = 28;
|
|
5519
|
+
_context55.next = 31;
|
|
5436
5520
|
return baseSales.destroy();
|
|
5437
5521
|
case 31:
|
|
5438
5522
|
this.logInfo('processSuccessfulLocalPayment: 临时 BaseSales 销毁完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
5439
5523
|
duration_ms: Date.now() - startedAt
|
|
5440
5524
|
}));
|
|
5441
|
-
|
|
5525
|
+
_context55.next = 37;
|
|
5442
5526
|
break;
|
|
5443
5527
|
case 34:
|
|
5444
|
-
|
|
5445
|
-
|
|
5528
|
+
_context55.prev = 34;
|
|
5529
|
+
_context55.t1 = _context55["catch"](28);
|
|
5446
5530
|
this.logError('processSuccessfulLocalPayment: 临时 BaseSales 销毁失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
5447
5531
|
duration_ms: Date.now() - startedAt,
|
|
5448
|
-
error:
|
|
5449
|
-
error_detail: this.normalizeUnknownError(
|
|
5532
|
+
error: _context55.t1 instanceof Error ? _context55.t1.message : String(_context55.t1),
|
|
5533
|
+
error_detail: this.normalizeUnknownError(_context55.t1)
|
|
5450
5534
|
}));
|
|
5451
5535
|
case 37:
|
|
5452
|
-
return
|
|
5536
|
+
return _context55.finish(27);
|
|
5453
5537
|
case 38:
|
|
5454
5538
|
case "end":
|
|
5455
|
-
return
|
|
5539
|
+
return _context55.stop();
|
|
5456
5540
|
}
|
|
5457
|
-
},
|
|
5541
|
+
}, _callee55, this, [[5, 22, 27, 38], [28, 34]]);
|
|
5458
5542
|
}));
|
|
5459
|
-
function processSuccessfulLocalPayment(
|
|
5543
|
+
function processSuccessfulLocalPayment(_x59) {
|
|
5460
5544
|
return _processSuccessfulLocalPayment.apply(this, arguments);
|
|
5461
5545
|
}
|
|
5462
5546
|
return processSuccessfulLocalPayment;
|
|
@@ -5552,32 +5636,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
5552
5636
|
}, {
|
|
5553
5637
|
key: "getShortNumberOrDeviceId",
|
|
5554
5638
|
value: function () {
|
|
5555
|
-
var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5639
|
+
var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56() {
|
|
5556
5640
|
var getAsyncIotDeviceInfo, res;
|
|
5557
|
-
return _regeneratorRuntime().wrap(function
|
|
5558
|
-
while (1) switch (
|
|
5641
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
5642
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
5559
5643
|
case 0:
|
|
5560
5644
|
getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
|
|
5561
5645
|
if (!getAsyncIotDeviceInfo) {
|
|
5562
|
-
|
|
5646
|
+
_context56.next = 7;
|
|
5563
5647
|
break;
|
|
5564
5648
|
}
|
|
5565
|
-
|
|
5649
|
+
_context56.next = 4;
|
|
5566
5650
|
return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
|
|
5567
5651
|
case 4:
|
|
5568
|
-
res =
|
|
5652
|
+
res = _context56.sent;
|
|
5569
5653
|
if (!(res !== null && res !== void 0 && res.short_number)) {
|
|
5570
|
-
|
|
5654
|
+
_context56.next = 7;
|
|
5571
5655
|
break;
|
|
5572
5656
|
}
|
|
5573
|
-
return
|
|
5657
|
+
return _context56.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
|
|
5574
5658
|
case 7:
|
|
5575
|
-
return
|
|
5659
|
+
return _context56.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
|
|
5576
5660
|
case 8:
|
|
5577
5661
|
case "end":
|
|
5578
|
-
return
|
|
5662
|
+
return _context56.stop();
|
|
5579
5663
|
}
|
|
5580
|
-
},
|
|
5664
|
+
}, _callee56, this);
|
|
5581
5665
|
}));
|
|
5582
5666
|
function getShortNumberOrDeviceId() {
|
|
5583
5667
|
return _getShortNumberOrDeviceId.apply(this, arguments);
|
|
@@ -5771,16 +5855,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
5771
5855
|
}, {
|
|
5772
5856
|
key: "normalizeCheckoutSubmitData",
|
|
5773
5857
|
value: function () {
|
|
5774
|
-
var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5858
|
+
var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(data, title) {
|
|
5775
5859
|
var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
|
|
5776
|
-
return _regeneratorRuntime().wrap(function
|
|
5777
|
-
while (1) switch (
|
|
5860
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5861
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
5778
5862
|
case 0:
|
|
5779
5863
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
5780
|
-
|
|
5864
|
+
_context57.next = 2;
|
|
5781
5865
|
break;
|
|
5782
5866
|
}
|
|
5783
|
-
return
|
|
5867
|
+
return _context57.abrupt("return", data);
|
|
5784
5868
|
case 2:
|
|
5785
5869
|
next = _objectSpread({}, data);
|
|
5786
5870
|
externalSaleNumber = next.external_sale_number;
|
|
@@ -5790,7 +5874,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5790
5874
|
delete next.vouchers;
|
|
5791
5875
|
hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
|
|
5792
5876
|
if (!hasCheckoutOrderNumbers) {
|
|
5793
|
-
|
|
5877
|
+
_context57.next = 11;
|
|
5794
5878
|
break;
|
|
5795
5879
|
}
|
|
5796
5880
|
this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
|
|
@@ -5800,10 +5884,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5800
5884
|
shop_order_number: next.shop_order_number,
|
|
5801
5885
|
shop_full_order_number: next.shop_full_order_number
|
|
5802
5886
|
});
|
|
5803
|
-
return
|
|
5887
|
+
return _context57.abrupt("return", next);
|
|
5804
5888
|
case 11:
|
|
5805
5889
|
if (!this.isBlankCheckoutValue(externalSaleNumber)) {
|
|
5806
|
-
|
|
5890
|
+
_context57.next = 14;
|
|
5807
5891
|
break;
|
|
5808
5892
|
}
|
|
5809
5893
|
if (shouldClearLocalOrderId) {
|
|
@@ -5812,10 +5896,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5812
5896
|
order_id: next.order_id
|
|
5813
5897
|
});
|
|
5814
5898
|
}
|
|
5815
|
-
return
|
|
5899
|
+
return _context57.abrupt("return", next);
|
|
5816
5900
|
case 14:
|
|
5817
5901
|
if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
|
|
5818
|
-
|
|
5902
|
+
_context57.next = 17;
|
|
5819
5903
|
break;
|
|
5820
5904
|
}
|
|
5821
5905
|
if (shouldClearLocalOrderId) {
|
|
@@ -5824,12 +5908,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
5824
5908
|
external_sale_number: externalSaleNumber
|
|
5825
5909
|
});
|
|
5826
5910
|
}
|
|
5827
|
-
return
|
|
5911
|
+
return _context57.abrupt("return", next);
|
|
5828
5912
|
case 17:
|
|
5829
|
-
|
|
5913
|
+
_context57.prev = 17;
|
|
5830
5914
|
localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
|
|
5831
5915
|
if (localOrder) {
|
|
5832
|
-
|
|
5916
|
+
_context57.next = 22;
|
|
5833
5917
|
break;
|
|
5834
5918
|
}
|
|
5835
5919
|
if (shouldClearLocalOrderId) {
|
|
@@ -5839,7 +5923,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5839
5923
|
localOrderFound: false
|
|
5840
5924
|
});
|
|
5841
5925
|
}
|
|
5842
|
-
return
|
|
5926
|
+
return _context57.abrupt("return", next);
|
|
5843
5927
|
case 22:
|
|
5844
5928
|
if (this.isBlankCheckoutValue(next.shop_order_number)) {
|
|
5845
5929
|
next.shop_order_number = localOrder.shop_order_number;
|
|
@@ -5856,23 +5940,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
5856
5940
|
shop_full_order_number: next.shop_full_order_number
|
|
5857
5941
|
});
|
|
5858
5942
|
// 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
|
|
5859
|
-
return
|
|
5943
|
+
return _context57.abrupt("return", next);
|
|
5860
5944
|
case 28:
|
|
5861
|
-
|
|
5862
|
-
|
|
5945
|
+
_context57.prev = 28;
|
|
5946
|
+
_context57.t0 = _context57["catch"](17);
|
|
5863
5947
|
this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
|
|
5864
5948
|
external_sale_number: externalSaleNumber,
|
|
5865
|
-
error: this.getUnknownErrorMessage(
|
|
5866
|
-
error_detail: this.normalizeUnknownError(
|
|
5949
|
+
error: this.getUnknownErrorMessage(_context57.t0),
|
|
5950
|
+
error_detail: this.normalizeUnknownError(_context57.t0)
|
|
5867
5951
|
});
|
|
5868
|
-
return
|
|
5952
|
+
return _context57.abrupt("return", next);
|
|
5869
5953
|
case 32:
|
|
5870
5954
|
case "end":
|
|
5871
|
-
return
|
|
5955
|
+
return _context57.stop();
|
|
5872
5956
|
}
|
|
5873
|
-
},
|
|
5957
|
+
}, _callee57, this, [[17, 28]]);
|
|
5874
5958
|
}));
|
|
5875
|
-
function normalizeCheckoutSubmitData(
|
|
5959
|
+
function normalizeCheckoutSubmitData(_x60, _x61) {
|
|
5876
5960
|
return _normalizeCheckoutSubmitData.apply(this, arguments);
|
|
5877
5961
|
}
|
|
5878
5962
|
return normalizeCheckoutSubmitData;
|
|
@@ -5880,81 +5964,81 @@ var Server = /*#__PURE__*/function () {
|
|
|
5880
5964
|
}, {
|
|
5881
5965
|
key: "ensureCheckoutOrderNumbers",
|
|
5882
5966
|
value: function () {
|
|
5883
|
-
var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5967
|
+
var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(data, title) {
|
|
5884
5968
|
var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
|
|
5885
|
-
return _regeneratorRuntime().wrap(function
|
|
5886
|
-
while (1) switch (
|
|
5969
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
5970
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
5887
5971
|
case 0:
|
|
5888
5972
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
5889
|
-
|
|
5973
|
+
_context58.next = 2;
|
|
5890
5974
|
break;
|
|
5891
5975
|
}
|
|
5892
|
-
return
|
|
5976
|
+
return _context58.abrupt("return", data);
|
|
5893
5977
|
case 2:
|
|
5894
5978
|
next = _objectSpread({}, data);
|
|
5895
5979
|
needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
|
|
5896
5980
|
needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
|
|
5897
5981
|
if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
|
|
5898
|
-
|
|
5982
|
+
_context58.next = 7;
|
|
5899
5983
|
break;
|
|
5900
5984
|
}
|
|
5901
|
-
return
|
|
5985
|
+
return _context58.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
|
|
5902
5986
|
case 7:
|
|
5903
5987
|
idGenerator = this.getIdGeneratorPlugin();
|
|
5904
5988
|
if (idGenerator) {
|
|
5905
|
-
|
|
5989
|
+
_context58.next = 11;
|
|
5906
5990
|
break;
|
|
5907
5991
|
}
|
|
5908
5992
|
this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
|
|
5909
5993
|
needsShopOrderNumber: needsShopOrderNumber,
|
|
5910
5994
|
needsShopFullOrderNumber: needsShopFullOrderNumber
|
|
5911
5995
|
});
|
|
5912
|
-
return
|
|
5996
|
+
return _context58.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
|
|
5913
5997
|
case 11:
|
|
5914
|
-
|
|
5998
|
+
_context58.prev = 11;
|
|
5915
5999
|
if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
|
|
5916
|
-
|
|
6000
|
+
_context58.next = 16;
|
|
5917
6001
|
break;
|
|
5918
6002
|
}
|
|
5919
|
-
|
|
6003
|
+
_context58.next = 15;
|
|
5920
6004
|
return idGenerator.generateShopOrderNumber({
|
|
5921
6005
|
biz: next.business_code || 'ticket'
|
|
5922
6006
|
});
|
|
5923
6007
|
case 15:
|
|
5924
|
-
next.shop_order_number =
|
|
6008
|
+
next.shop_order_number = _context58.sent;
|
|
5925
6009
|
case 16:
|
|
5926
6010
|
if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
|
|
5927
|
-
|
|
6011
|
+
_context58.next = 20;
|
|
5928
6012
|
break;
|
|
5929
6013
|
}
|
|
5930
|
-
|
|
6014
|
+
_context58.next = 19;
|
|
5931
6015
|
return idGenerator.generateReceiptId({
|
|
5932
6016
|
biz: next.business_code || 'ticket'
|
|
5933
6017
|
});
|
|
5934
6018
|
case 19:
|
|
5935
|
-
next.shop_full_order_number =
|
|
6019
|
+
next.shop_full_order_number = _context58.sent;
|
|
5936
6020
|
case 20:
|
|
5937
6021
|
this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
|
|
5938
6022
|
shop_order_number: next.shop_order_number,
|
|
5939
6023
|
shop_full_order_number: next.shop_full_order_number
|
|
5940
6024
|
});
|
|
5941
|
-
|
|
6025
|
+
_context58.next = 26;
|
|
5942
6026
|
break;
|
|
5943
6027
|
case 23:
|
|
5944
|
-
|
|
5945
|
-
|
|
6028
|
+
_context58.prev = 23;
|
|
6029
|
+
_context58.t0 = _context58["catch"](11);
|
|
5946
6030
|
this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
|
|
5947
|
-
error:
|
|
6031
|
+
error: _context58.t0 instanceof Error ? _context58.t0.message : String(_context58.t0)
|
|
5948
6032
|
});
|
|
5949
6033
|
case 26:
|
|
5950
|
-
return
|
|
6034
|
+
return _context58.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
|
|
5951
6035
|
case 27:
|
|
5952
6036
|
case "end":
|
|
5953
|
-
return
|
|
6037
|
+
return _context58.stop();
|
|
5954
6038
|
}
|
|
5955
|
-
},
|
|
6039
|
+
}, _callee58, this, [[11, 23]]);
|
|
5956
6040
|
}));
|
|
5957
|
-
function ensureCheckoutOrderNumbers(
|
|
6041
|
+
function ensureCheckoutOrderNumbers(_x62, _x63) {
|
|
5958
6042
|
return _ensureCheckoutOrderNumbers.apply(this, arguments);
|
|
5959
6043
|
}
|
|
5960
6044
|
return ensureCheckoutOrderNumbers;
|
|
@@ -6001,27 +6085,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
6001
6085
|
}, {
|
|
6002
6086
|
key: "dispatchCheckoutSyncTask",
|
|
6003
6087
|
value: function () {
|
|
6004
|
-
var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6088
|
+
var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
|
|
6005
6089
|
var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
|
|
6006
|
-
return _regeneratorRuntime().wrap(function
|
|
6007
|
-
while (1) switch (
|
|
6090
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context59) {
|
|
6091
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
6008
6092
|
case 0:
|
|
6009
6093
|
this.registerDeviceTaskActions();
|
|
6010
6094
|
deviceTask = this.getDeviceTaskPlugin();
|
|
6011
|
-
|
|
6095
|
+
_context59.next = 4;
|
|
6012
6096
|
return this.getShortNumberOrDeviceId();
|
|
6013
6097
|
case 4:
|
|
6014
|
-
debugDeviceId =
|
|
6098
|
+
debugDeviceId = _context59.sent;
|
|
6015
6099
|
debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
|
|
6016
6100
|
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
6017
|
-
|
|
6101
|
+
_context59.next = 9;
|
|
6018
6102
|
break;
|
|
6019
6103
|
}
|
|
6020
6104
|
this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
|
|
6021
|
-
return
|
|
6105
|
+
return _context59.abrupt("return");
|
|
6022
6106
|
case 9:
|
|
6023
|
-
|
|
6024
|
-
|
|
6107
|
+
_context59.prev = 9;
|
|
6108
|
+
_context59.next = 12;
|
|
6025
6109
|
return deviceTask.dispatch({
|
|
6026
6110
|
action: 'sync_sales',
|
|
6027
6111
|
device_id: debugDeviceId,
|
|
@@ -6041,27 +6125,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
6041
6125
|
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)
|
|
6042
6126
|
});
|
|
6043
6127
|
case 12:
|
|
6044
|
-
result =
|
|
6128
|
+
result = _context59.sent;
|
|
6045
6129
|
this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
|
|
6046
6130
|
uuid: result === null || result === void 0 ? void 0 : result.uuid,
|
|
6047
6131
|
status: result === null || result === void 0 ? void 0 : result.status,
|
|
6048
6132
|
reused: result === null || result === void 0 ? void 0 : result.reused
|
|
6049
6133
|
});
|
|
6050
|
-
|
|
6134
|
+
_context59.next = 19;
|
|
6051
6135
|
break;
|
|
6052
6136
|
case 16:
|
|
6053
|
-
|
|
6054
|
-
|
|
6137
|
+
_context59.prev = 16;
|
|
6138
|
+
_context59.t0 = _context59["catch"](9);
|
|
6055
6139
|
this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
|
|
6056
|
-
error:
|
|
6140
|
+
error: _context59.t0 instanceof Error ? _context59.t0.message : String(_context59.t0)
|
|
6057
6141
|
});
|
|
6058
6142
|
case 19:
|
|
6059
6143
|
case "end":
|
|
6060
|
-
return
|
|
6144
|
+
return _context59.stop();
|
|
6061
6145
|
}
|
|
6062
|
-
},
|
|
6146
|
+
}, _callee59, this, [[9, 16]]);
|
|
6063
6147
|
}));
|
|
6064
|
-
function dispatchCheckoutSyncTask(
|
|
6148
|
+
function dispatchCheckoutSyncTask(_x64) {
|
|
6065
6149
|
return _dispatchCheckoutSyncTask.apply(this, arguments);
|
|
6066
6150
|
}
|
|
6067
6151
|
return dispatchCheckoutSyncTask;
|
|
@@ -6069,26 +6153,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
6069
6153
|
}, {
|
|
6070
6154
|
key: "dispatchPrintOtherReceiptTask",
|
|
6071
6155
|
value: function () {
|
|
6072
|
-
var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6156
|
+
var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
|
|
6073
6157
|
var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
|
|
6074
|
-
return _regeneratorRuntime().wrap(function
|
|
6075
|
-
while (1) switch (
|
|
6158
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
6159
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
6076
6160
|
case 0:
|
|
6077
6161
|
deviceTask = this.getDeviceTaskPlugin();
|
|
6078
6162
|
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
6079
|
-
|
|
6163
|
+
_context60.next = 4;
|
|
6080
6164
|
break;
|
|
6081
6165
|
}
|
|
6082
6166
|
this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
|
|
6083
|
-
return
|
|
6167
|
+
return _context60.abrupt("return");
|
|
6084
6168
|
case 4:
|
|
6085
|
-
|
|
6169
|
+
_context60.prev = 4;
|
|
6086
6170
|
printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
|
|
6087
|
-
|
|
6171
|
+
_context60.next = 8;
|
|
6088
6172
|
return this.getShortNumberOrDeviceId();
|
|
6089
6173
|
case 8:
|
|
6090
|
-
deviceId =
|
|
6091
|
-
|
|
6174
|
+
deviceId = _context60.sent;
|
|
6175
|
+
_context60.next = 11;
|
|
6092
6176
|
return deviceTask.dispatch({
|
|
6093
6177
|
action: 'print_all',
|
|
6094
6178
|
device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
|
|
@@ -6117,21 +6201,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
6117
6201
|
source_id: printIdentity
|
|
6118
6202
|
});
|
|
6119
6203
|
case 11:
|
|
6120
|
-
|
|
6204
|
+
_context60.next = 16;
|
|
6121
6205
|
break;
|
|
6122
6206
|
case 13:
|
|
6123
|
-
|
|
6124
|
-
|
|
6207
|
+
_context60.prev = 13;
|
|
6208
|
+
_context60.t0 = _context60["catch"](4);
|
|
6125
6209
|
this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
|
|
6126
|
-
error:
|
|
6210
|
+
error: _context60.t0 instanceof Error ? _context60.t0.message : String(_context60.t0)
|
|
6127
6211
|
});
|
|
6128
6212
|
case 16:
|
|
6129
6213
|
case "end":
|
|
6130
|
-
return
|
|
6214
|
+
return _context60.stop();
|
|
6131
6215
|
}
|
|
6132
|
-
},
|
|
6216
|
+
}, _callee60, this, [[4, 13]]);
|
|
6133
6217
|
}));
|
|
6134
|
-
function dispatchPrintOtherReceiptTask(
|
|
6218
|
+
function dispatchPrintOtherReceiptTask(_x65) {
|
|
6135
6219
|
return _dispatchPrintOtherReceiptTask.apply(this, arguments);
|
|
6136
6220
|
}
|
|
6137
6221
|
return dispatchPrintOtherReceiptTask;
|
|
@@ -6151,34 +6235,34 @@ var Server = /*#__PURE__*/function () {
|
|
|
6151
6235
|
}, {
|
|
6152
6236
|
key: "dispatchLocalReceiptPrint",
|
|
6153
6237
|
value: function () {
|
|
6154
|
-
var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6238
|
+
var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
|
|
6155
6239
|
var _payment_info2;
|
|
6156
6240
|
var printableOrder;
|
|
6157
|
-
return _regeneratorRuntime().wrap(function
|
|
6158
|
-
while (1) switch (
|
|
6241
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
6242
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
6159
6243
|
case 0:
|
|
6160
6244
|
if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
|
|
6161
|
-
|
|
6245
|
+
_context61.next = 2;
|
|
6162
6246
|
break;
|
|
6163
6247
|
}
|
|
6164
|
-
return
|
|
6248
|
+
return _context61.abrupt("return", {
|
|
6165
6249
|
printed: false,
|
|
6166
6250
|
order: params.order
|
|
6167
6251
|
});
|
|
6168
6252
|
case 2:
|
|
6169
|
-
|
|
6253
|
+
_context61.next = 4;
|
|
6170
6254
|
return this.withLocalSmallTicketData(params.order, {
|
|
6171
6255
|
requireFullyPaid: params.requireFullyPaid,
|
|
6172
6256
|
invoiceTemplateSettings: params.invoiceTemplateSettings,
|
|
6173
6257
|
applyTemplateVisibility: true
|
|
6174
6258
|
});
|
|
6175
6259
|
case 4:
|
|
6176
|
-
printableOrder =
|
|
6260
|
+
printableOrder = _context61.sent;
|
|
6177
6261
|
if (hasSmallTicketData((_payment_info2 = printableOrder.payment_info) === null || _payment_info2 === void 0 ? void 0 : _payment_info2.small_ticket_data)) {
|
|
6178
|
-
|
|
6262
|
+
_context61.next = 7;
|
|
6179
6263
|
break;
|
|
6180
6264
|
}
|
|
6181
|
-
return
|
|
6265
|
+
return _context61.abrupt("return", {
|
|
6182
6266
|
printed: false,
|
|
6183
6267
|
order: printableOrder
|
|
6184
6268
|
});
|
|
@@ -6188,7 +6272,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6188
6272
|
printableOrder: printableOrder,
|
|
6189
6273
|
response: params.response
|
|
6190
6274
|
});
|
|
6191
|
-
|
|
6275
|
+
_context61.next = 10;
|
|
6192
6276
|
return this.dispatchPrintOtherReceiptTask({
|
|
6193
6277
|
checkoutData: params.checkoutData,
|
|
6194
6278
|
syncedOrder: printableOrder,
|
|
@@ -6199,17 +6283,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
6199
6283
|
invoiceTemplateSettings: params.invoiceTemplateSettings
|
|
6200
6284
|
});
|
|
6201
6285
|
case 10:
|
|
6202
|
-
return
|
|
6286
|
+
return _context61.abrupt("return", {
|
|
6203
6287
|
printed: true,
|
|
6204
6288
|
order: requiresInvoiceDataFiltering(params.invoiceTemplateSettings) ? params.order : printableOrder
|
|
6205
6289
|
});
|
|
6206
6290
|
case 11:
|
|
6207
6291
|
case "end":
|
|
6208
|
-
return
|
|
6292
|
+
return _context61.stop();
|
|
6209
6293
|
}
|
|
6210
|
-
},
|
|
6294
|
+
}, _callee61, this);
|
|
6211
6295
|
}));
|
|
6212
|
-
function dispatchLocalReceiptPrint(
|
|
6296
|
+
function dispatchLocalReceiptPrint(_x66) {
|
|
6213
6297
|
return _dispatchLocalReceiptPrint.apply(this, arguments);
|
|
6214
6298
|
}
|
|
6215
6299
|
return dispatchLocalReceiptPrint;
|
|
@@ -6268,47 +6352,47 @@ var Server = /*#__PURE__*/function () {
|
|
|
6268
6352
|
}, {
|
|
6269
6353
|
key: "syncMachinecodeRedeemStatusToLocalOrder",
|
|
6270
6354
|
value: function () {
|
|
6271
|
-
var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6355
|
+
var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(data, ids, status) {
|
|
6272
6356
|
var _this$order4;
|
|
6273
6357
|
var title, lookup, localOrder, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
|
|
6274
|
-
return _regeneratorRuntime().wrap(function
|
|
6275
|
-
while (1) switch (
|
|
6358
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
6359
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
6276
6360
|
case 0:
|
|
6277
6361
|
title = 'handleMachinecodeBatchMetadata';
|
|
6278
6362
|
lookup = this.resolveMachinecodeBatchMetadataLookup(data);
|
|
6279
6363
|
if (!(lookup === undefined)) {
|
|
6280
|
-
|
|
6364
|
+
_context62.next = 5;
|
|
6281
6365
|
break;
|
|
6282
6366
|
}
|
|
6283
6367
|
this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
6284
6368
|
batchSize: ids.length,
|
|
6285
6369
|
status: status
|
|
6286
6370
|
});
|
|
6287
|
-
return
|
|
6371
|
+
return _context62.abrupt("return");
|
|
6288
6372
|
case 5:
|
|
6289
6373
|
if ((_this$order4 = this.order) !== null && _this$order4 !== void 0 && _this$order4.getLocalOrderByLookup) {
|
|
6290
|
-
|
|
6374
|
+
_context62.next = 8;
|
|
6291
6375
|
break;
|
|
6292
6376
|
}
|
|
6293
6377
|
this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
6294
6378
|
lookup: lookup,
|
|
6295
6379
|
status: status
|
|
6296
6380
|
});
|
|
6297
|
-
return
|
|
6381
|
+
return _context62.abrupt("return");
|
|
6298
6382
|
case 8:
|
|
6299
|
-
|
|
6383
|
+
_context62.next = 10;
|
|
6300
6384
|
return this.order.getLocalOrderByLookup(lookup);
|
|
6301
6385
|
case 10:
|
|
6302
|
-
localOrder =
|
|
6386
|
+
localOrder = _context62.sent;
|
|
6303
6387
|
if (localOrder) {
|
|
6304
|
-
|
|
6388
|
+
_context62.next = 14;
|
|
6305
6389
|
break;
|
|
6306
6390
|
}
|
|
6307
6391
|
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
6308
6392
|
lookup: lookup,
|
|
6309
6393
|
status: status
|
|
6310
6394
|
});
|
|
6311
|
-
return
|
|
6395
|
+
return _context62.abrupt("return");
|
|
6312
6396
|
case 14:
|
|
6313
6397
|
voucherIdSet = new Set(ids.filter(function (id) {
|
|
6314
6398
|
return id !== undefined && id !== null && id !== '';
|
|
@@ -6316,14 +6400,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
6316
6400
|
return String(id);
|
|
6317
6401
|
}));
|
|
6318
6402
|
if (!(voucherIdSet.size === 0)) {
|
|
6319
|
-
|
|
6403
|
+
_context62.next = 18;
|
|
6320
6404
|
break;
|
|
6321
6405
|
}
|
|
6322
6406
|
this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
6323
6407
|
lookup: lookup,
|
|
6324
6408
|
status: status
|
|
6325
6409
|
});
|
|
6326
|
-
return
|
|
6410
|
+
return _context62.abrupt("return");
|
|
6327
6411
|
case 18:
|
|
6328
6412
|
vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
|
|
6329
6413
|
hasUpdatedVoucher = false;
|
|
@@ -6337,7 +6421,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6337
6421
|
});
|
|
6338
6422
|
});
|
|
6339
6423
|
if (hasUpdatedVoucher) {
|
|
6340
|
-
|
|
6424
|
+
_context62.next = 24;
|
|
6341
6425
|
break;
|
|
6342
6426
|
}
|
|
6343
6427
|
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
@@ -6345,13 +6429,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6345
6429
|
voucher_ids: Array.from(voucherIdSet),
|
|
6346
6430
|
status: status
|
|
6347
6431
|
});
|
|
6348
|
-
return
|
|
6432
|
+
return _context62.abrupt("return");
|
|
6349
6433
|
case 24:
|
|
6350
6434
|
if (!(typeof this.order.overwriteExistingOrder === 'function')) {
|
|
6351
|
-
|
|
6435
|
+
_context62.next = 29;
|
|
6352
6436
|
break;
|
|
6353
6437
|
}
|
|
6354
|
-
|
|
6438
|
+
_context62.next = 27;
|
|
6355
6439
|
return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
|
|
6356
6440
|
vouchers: nextVouchers
|
|
6357
6441
|
}));
|
|
@@ -6361,13 +6445,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6361
6445
|
updatedCount: voucherIdSet.size,
|
|
6362
6446
|
status: status
|
|
6363
6447
|
});
|
|
6364
|
-
return
|
|
6448
|
+
return _context62.abrupt("return");
|
|
6365
6449
|
case 29:
|
|
6366
6450
|
if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
|
|
6367
|
-
|
|
6451
|
+
_context62.next = 34;
|
|
6368
6452
|
break;
|
|
6369
6453
|
}
|
|
6370
|
-
|
|
6454
|
+
_context62.next = 32;
|
|
6371
6455
|
return this.order.markOrderSyncedByExternalSaleNumber({
|
|
6372
6456
|
externalSaleNumber: data.external_sale_number,
|
|
6373
6457
|
patch: {
|
|
@@ -6380,7 +6464,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6380
6464
|
updatedCount: voucherIdSet.size,
|
|
6381
6465
|
status: status
|
|
6382
6466
|
});
|
|
6383
|
-
return
|
|
6467
|
+
return _context62.abrupt("return");
|
|
6384
6468
|
case 34:
|
|
6385
6469
|
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"), {
|
|
6386
6470
|
lookup: lookup,
|
|
@@ -6388,11 +6472,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6388
6472
|
});
|
|
6389
6473
|
case 35:
|
|
6390
6474
|
case "end":
|
|
6391
|
-
return
|
|
6475
|
+
return _context62.stop();
|
|
6392
6476
|
}
|
|
6393
|
-
},
|
|
6477
|
+
}, _callee62, this);
|
|
6394
6478
|
}));
|
|
6395
|
-
function syncMachinecodeRedeemStatusToLocalOrder(
|
|
6479
|
+
function syncMachinecodeRedeemStatusToLocalOrder(_x67, _x68, _x69) {
|
|
6396
6480
|
return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
|
|
6397
6481
|
}
|
|
6398
6482
|
return syncMachinecodeRedeemStatusToLocalOrder;
|
|
@@ -6400,10 +6484,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
6400
6484
|
}, {
|
|
6401
6485
|
key: "handleOrderCheckoutSubmit",
|
|
6402
6486
|
value: function () {
|
|
6403
|
-
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6487
|
+
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
|
|
6404
6488
|
var backendPath, title, extractedInvoice, extractedTemplateSettings, data, invoiceLayoutConfig, invoiceTemplateSettings, normalizedData, numberedData, checkoutData, pendingResult, pendingOrder;
|
|
6405
|
-
return _regeneratorRuntime().wrap(function
|
|
6406
|
-
while (1) switch (
|
|
6489
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
6490
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
6407
6491
|
case 0:
|
|
6408
6492
|
backendPath = params.backendPath, title = params.title;
|
|
6409
6493
|
extractedInvoice = this.extractInvoiceLayoutConfig(params.data, {
|
|
@@ -6422,10 +6506,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
6422
6506
|
order_number: data === null || data === void 0 ? void 0 : data.order_number
|
|
6423
6507
|
});
|
|
6424
6508
|
if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
|
|
6425
|
-
|
|
6509
|
+
_context63.next = 9;
|
|
6426
6510
|
break;
|
|
6427
6511
|
}
|
|
6428
|
-
return
|
|
6512
|
+
return _context63.abrupt("return", this.handleSyncCheckoutSubmit({
|
|
6429
6513
|
backendPath: backendPath,
|
|
6430
6514
|
data: data,
|
|
6431
6515
|
title: title,
|
|
@@ -6433,16 +6517,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
6433
6517
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6434
6518
|
}));
|
|
6435
6519
|
case 9:
|
|
6436
|
-
|
|
6520
|
+
_context63.next = 11;
|
|
6437
6521
|
return this.normalizeCheckoutSubmitData(data, title);
|
|
6438
6522
|
case 11:
|
|
6439
|
-
normalizedData =
|
|
6440
|
-
|
|
6523
|
+
normalizedData = _context63.sent;
|
|
6524
|
+
_context63.next = 14;
|
|
6441
6525
|
return this.ensureCheckoutOrderNumbers(normalizedData, title);
|
|
6442
6526
|
case 14:
|
|
6443
|
-
numberedData =
|
|
6527
|
+
numberedData = _context63.sent;
|
|
6444
6528
|
checkoutData = this.normalizeCheckoutCollections(stripOsPrivatePayloadFields(this.applyCheckoutFulfillmentBuzzer(numberedData, title)));
|
|
6445
|
-
|
|
6529
|
+
_context63.next = 18;
|
|
6446
6530
|
return this.handlePendingSyncCheckoutOrder({
|
|
6447
6531
|
backendPath: backendPath,
|
|
6448
6532
|
data: checkoutData,
|
|
@@ -6451,18 +6535,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
6451
6535
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6452
6536
|
});
|
|
6453
6537
|
case 18:
|
|
6454
|
-
pendingResult =
|
|
6538
|
+
pendingResult = _context63.sent;
|
|
6455
6539
|
if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
|
|
6456
|
-
|
|
6540
|
+
_context63.next = 33;
|
|
6457
6541
|
break;
|
|
6458
6542
|
}
|
|
6459
6543
|
pendingOrder = pendingResult.data;
|
|
6460
6544
|
if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData, invoiceTemplateSettings) && this.isSalesOrderFullyPaid(pendingOrder) && this.shouldAutoPrintCheckoutReceipt())) {
|
|
6461
|
-
|
|
6545
|
+
_context63.next = 31;
|
|
6462
6546
|
break;
|
|
6463
6547
|
}
|
|
6464
|
-
|
|
6465
|
-
|
|
6548
|
+
_context63.prev = 22;
|
|
6549
|
+
_context63.next = 25;
|
|
6466
6550
|
return this.dispatchLocalReceiptPrint({
|
|
6467
6551
|
checkoutData: checkoutData,
|
|
6468
6552
|
order: pendingOrder,
|
|
@@ -6472,19 +6556,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
6472
6556
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6473
6557
|
});
|
|
6474
6558
|
case 25:
|
|
6475
|
-
|
|
6559
|
+
_context63.next = 31;
|
|
6476
6560
|
break;
|
|
6477
6561
|
case 27:
|
|
6478
|
-
|
|
6479
|
-
|
|
6562
|
+
_context63.prev = 27;
|
|
6563
|
+
_context63.t0 = _context63["catch"](22);
|
|
6480
6564
|
// The sale is already persisted. A failed receipt must not cancel its
|
|
6481
6565
|
// sync task or send an unfiltered fallback to the printer.
|
|
6482
|
-
pendingResult.receipt_print_error = this.getUnknownErrorMessage(
|
|
6566
|
+
pendingResult.receipt_print_error = this.getUnknownErrorMessage(_context63.t0);
|
|
6483
6567
|
this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u4ECD\u7EE7\u7EED\u540C\u6B65"), {
|
|
6484
6568
|
error: pendingResult.receipt_print_error
|
|
6485
6569
|
});
|
|
6486
6570
|
case 31:
|
|
6487
|
-
|
|
6571
|
+
_context63.next = 33;
|
|
6488
6572
|
return this.dispatchCheckoutSyncTask({
|
|
6489
6573
|
backendPath: backendPath,
|
|
6490
6574
|
data: checkoutData,
|
|
@@ -6494,23 +6578,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
6494
6578
|
});
|
|
6495
6579
|
case 33:
|
|
6496
6580
|
if (pendingResult.data.order_id) {
|
|
6497
|
-
|
|
6581
|
+
_context63.next = 35;
|
|
6498
6582
|
break;
|
|
6499
6583
|
}
|
|
6500
|
-
return
|
|
6584
|
+
return _context63.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
|
|
6501
6585
|
data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
|
|
6502
6586
|
order_id: pendingResult.data.external_sale_number
|
|
6503
6587
|
})
|
|
6504
6588
|
}));
|
|
6505
6589
|
case 35:
|
|
6506
|
-
return
|
|
6590
|
+
return _context63.abrupt("return", pendingResult);
|
|
6507
6591
|
case 36:
|
|
6508
6592
|
case "end":
|
|
6509
|
-
return
|
|
6593
|
+
return _context63.stop();
|
|
6510
6594
|
}
|
|
6511
|
-
},
|
|
6595
|
+
}, _callee63, this, [[22, 27]]);
|
|
6512
6596
|
}));
|
|
6513
|
-
function handleOrderCheckoutSubmit(
|
|
6597
|
+
function handleOrderCheckoutSubmit(_x70) {
|
|
6514
6598
|
return _handleOrderCheckoutSubmit.apply(this, arguments);
|
|
6515
6599
|
}
|
|
6516
6600
|
return handleOrderCheckoutSubmit;
|
|
@@ -6518,27 +6602,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
6518
6602
|
}, {
|
|
6519
6603
|
key: "handleSyncCheckoutSubmit",
|
|
6520
6604
|
value: function () {
|
|
6521
|
-
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6605
|
+
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(params) {
|
|
6522
6606
|
var _this$app17;
|
|
6523
6607
|
var backendPath, data, title, invoiceLayoutConfig, invoiceTemplateSettings, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
|
|
6524
|
-
return _regeneratorRuntime().wrap(function
|
|
6525
|
-
while (1) switch (
|
|
6608
|
+
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
6609
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
6526
6610
|
case 0:
|
|
6527
6611
|
backendPath = params.backendPath, data = params.data, title = params.title, invoiceLayoutConfig = params.invoiceLayoutConfig, invoiceTemplateSettings = params.invoiceTemplateSettings;
|
|
6528
6612
|
if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && (_this$app17 = _this$app17.request) !== null && _this$app17 !== void 0 && _this$app17.post) {
|
|
6529
|
-
|
|
6613
|
+
_context64.next = 4;
|
|
6530
6614
|
break;
|
|
6531
6615
|
}
|
|
6532
6616
|
this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
|
|
6533
|
-
return
|
|
6617
|
+
return _context64.abrupt("return", {
|
|
6534
6618
|
code: 500,
|
|
6535
6619
|
status: false,
|
|
6536
6620
|
message: 'app.request 不可用',
|
|
6537
6621
|
data: null
|
|
6538
6622
|
});
|
|
6539
6623
|
case 4:
|
|
6540
|
-
|
|
6541
|
-
|
|
6624
|
+
_context64.prev = 4;
|
|
6625
|
+
_context64.next = 7;
|
|
6542
6626
|
return this.runCheckoutSync({
|
|
6543
6627
|
backendPath: backendPath,
|
|
6544
6628
|
data: data,
|
|
@@ -6548,13 +6632,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6548
6632
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6549
6633
|
});
|
|
6550
6634
|
case 7:
|
|
6551
|
-
syncResult =
|
|
6635
|
+
syncResult = _context64.sent;
|
|
6552
6636
|
if (!syncResult.rejected) {
|
|
6553
|
-
|
|
6637
|
+
_context64.next = 11;
|
|
6554
6638
|
break;
|
|
6555
6639
|
}
|
|
6556
6640
|
normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
|
|
6557
|
-
return
|
|
6641
|
+
return _context64.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
|
|
6558
6642
|
status: false,
|
|
6559
6643
|
message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
|
|
6560
6644
|
data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
|
|
@@ -6563,11 +6647,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6563
6647
|
response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
|
|
6564
6648
|
syncedOrder = syncResult.syncedOrder;
|
|
6565
6649
|
if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData, invoiceTemplateSettings) && this.isSalesOrderFullyPaid(syncedOrder))) {
|
|
6566
|
-
|
|
6650
|
+
_context64.next = 23;
|
|
6567
6651
|
break;
|
|
6568
6652
|
}
|
|
6569
|
-
|
|
6570
|
-
|
|
6653
|
+
_context64.prev = 14;
|
|
6654
|
+
_context64.next = 17;
|
|
6571
6655
|
return this.dispatchLocalReceiptPrint({
|
|
6572
6656
|
checkoutData: syncResult.checkoutData,
|
|
6573
6657
|
order: syncedOrder,
|
|
@@ -6577,41 +6661,41 @@ var Server = /*#__PURE__*/function () {
|
|
|
6577
6661
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6578
6662
|
});
|
|
6579
6663
|
case 17:
|
|
6580
|
-
|
|
6664
|
+
_context64.next = 23;
|
|
6581
6665
|
break;
|
|
6582
6666
|
case 19:
|
|
6583
|
-
|
|
6584
|
-
|
|
6667
|
+
_context64.prev = 19;
|
|
6668
|
+
_context64.t0 = _context64["catch"](14);
|
|
6585
6669
|
// Checkout already succeeded remotely; report the receipt failure
|
|
6586
6670
|
// separately instead of implying that payment/order creation failed.
|
|
6587
|
-
response.receipt_print_error = this.getUnknownErrorMessage(
|
|
6671
|
+
response.receipt_print_error = this.getUnknownErrorMessage(_context64.t0);
|
|
6588
6672
|
this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u5DF2\u540C\u6B65"), {
|
|
6589
6673
|
error: response.receipt_print_error
|
|
6590
6674
|
});
|
|
6591
6675
|
case 23:
|
|
6592
|
-
return
|
|
6676
|
+
return _context64.abrupt("return", response);
|
|
6593
6677
|
case 26:
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
backendError = this.extractBackendErrorResponse(
|
|
6678
|
+
_context64.prev = 26;
|
|
6679
|
+
_context64.t1 = _context64["catch"](4);
|
|
6680
|
+
backendError = this.extractBackendErrorResponse(_context64.t1);
|
|
6597
6681
|
if (!backendError) {
|
|
6598
|
-
|
|
6682
|
+
_context64.next = 32;
|
|
6599
6683
|
break;
|
|
6600
6684
|
}
|
|
6601
6685
|
_normalized = this.normalizeCheckoutResponse(backendError);
|
|
6602
|
-
return
|
|
6686
|
+
return _context64.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
|
|
6603
6687
|
status: false,
|
|
6604
6688
|
message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
|
|
6605
6689
|
data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
|
|
6606
6690
|
}));
|
|
6607
6691
|
case 32:
|
|
6608
|
-
message = this.getUnknownErrorMessage(
|
|
6692
|
+
message = this.getUnknownErrorMessage(_context64.t1);
|
|
6609
6693
|
this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
|
|
6610
6694
|
backendPath: backendPath,
|
|
6611
6695
|
error: message,
|
|
6612
|
-
error_detail: this.normalizeUnknownError(
|
|
6696
|
+
error_detail: this.normalizeUnknownError(_context64.t1)
|
|
6613
6697
|
});
|
|
6614
|
-
return
|
|
6698
|
+
return _context64.abrupt("return", {
|
|
6615
6699
|
code: 500,
|
|
6616
6700
|
status: false,
|
|
6617
6701
|
message: message,
|
|
@@ -6619,11 +6703,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6619
6703
|
});
|
|
6620
6704
|
case 35:
|
|
6621
6705
|
case "end":
|
|
6622
|
-
return
|
|
6706
|
+
return _context64.stop();
|
|
6623
6707
|
}
|
|
6624
|
-
},
|
|
6708
|
+
}, _callee64, this, [[4, 26], [14, 19]]);
|
|
6625
6709
|
}));
|
|
6626
|
-
function handleSyncCheckoutSubmit(
|
|
6710
|
+
function handleSyncCheckoutSubmit(_x71) {
|
|
6627
6711
|
return _handleSyncCheckoutSubmit.apply(this, arguments);
|
|
6628
6712
|
}
|
|
6629
6713
|
return handleSyncCheckoutSubmit;
|
|
@@ -6631,10 +6715,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
6631
6715
|
}, {
|
|
6632
6716
|
key: "handleOrderDraftSubmit",
|
|
6633
6717
|
value: function () {
|
|
6634
|
-
var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6718
|
+
var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(params) {
|
|
6635
6719
|
var title, extractedInvoice, _this$extractInvoiceT, data, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
|
|
6636
|
-
return _regeneratorRuntime().wrap(function
|
|
6637
|
-
while (1) switch (
|
|
6720
|
+
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
6721
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
6638
6722
|
case 0:
|
|
6639
6723
|
title = params.title;
|
|
6640
6724
|
extractedInvoice = this.extractInvoiceLayoutConfig(params.data, {
|
|
@@ -6648,10 +6732,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
6648
6732
|
external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
|
|
6649
6733
|
order_number: data === null || data === void 0 ? void 0 : data.order_number
|
|
6650
6734
|
});
|
|
6651
|
-
|
|
6735
|
+
_context65.next = 6;
|
|
6652
6736
|
return this.normalizeCheckoutSubmitData(data, title);
|
|
6653
6737
|
case 6:
|
|
6654
|
-
normalizedData =
|
|
6738
|
+
normalizedData = _context65.sent;
|
|
6655
6739
|
createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
6656
6740
|
draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
|
|
6657
6741
|
external_sale_number: normalizedData.external_sale_number || "LOCAL_DRAFT_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 10)),
|
|
@@ -6661,26 +6745,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
6661
6745
|
is_draft_order: 1
|
|
6662
6746
|
});
|
|
6663
6747
|
if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
|
|
6664
|
-
|
|
6748
|
+
_context65.next = 12;
|
|
6665
6749
|
break;
|
|
6666
6750
|
}
|
|
6667
6751
|
this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
|
|
6668
|
-
return
|
|
6752
|
+
return _context65.abrupt("return", {
|
|
6669
6753
|
code: 500,
|
|
6670
6754
|
status: false,
|
|
6671
6755
|
message: 'Order 模块不支持本地草稿写入',
|
|
6672
6756
|
data: null
|
|
6673
6757
|
});
|
|
6674
6758
|
case 12:
|
|
6675
|
-
|
|
6676
|
-
|
|
6759
|
+
_context65.prev = 12;
|
|
6760
|
+
_context65.next = 15;
|
|
6677
6761
|
return this.order.upsertLocalDraftOrders([draftOrder]);
|
|
6678
6762
|
case 15:
|
|
6679
6763
|
this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
|
|
6680
6764
|
order_id: draftOrder.order_id,
|
|
6681
6765
|
external_sale_number: draftOrder.external_sale_number
|
|
6682
6766
|
});
|
|
6683
|
-
return
|
|
6767
|
+
return _context65.abrupt("return", {
|
|
6684
6768
|
code: 200,
|
|
6685
6769
|
status: true,
|
|
6686
6770
|
message: '',
|
|
@@ -6692,13 +6776,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6692
6776
|
})
|
|
6693
6777
|
});
|
|
6694
6778
|
case 19:
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
errorMessage =
|
|
6779
|
+
_context65.prev = 19;
|
|
6780
|
+
_context65.t0 = _context65["catch"](12);
|
|
6781
|
+
errorMessage = _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0);
|
|
6698
6782
|
this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
|
|
6699
6783
|
error: errorMessage
|
|
6700
6784
|
});
|
|
6701
|
-
return
|
|
6785
|
+
return _context65.abrupt("return", {
|
|
6702
6786
|
code: 500,
|
|
6703
6787
|
status: false,
|
|
6704
6788
|
message: errorMessage,
|
|
@@ -6706,11 +6790,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6706
6790
|
});
|
|
6707
6791
|
case 24:
|
|
6708
6792
|
case "end":
|
|
6709
|
-
return
|
|
6793
|
+
return _context65.stop();
|
|
6710
6794
|
}
|
|
6711
|
-
},
|
|
6795
|
+
}, _callee65, this, [[12, 19]]);
|
|
6712
6796
|
}));
|
|
6713
|
-
function handleOrderDraftSubmit(
|
|
6797
|
+
function handleOrderDraftSubmit(_x72) {
|
|
6714
6798
|
return _handleOrderDraftSubmit.apply(this, arguments);
|
|
6715
6799
|
}
|
|
6716
6800
|
return handleOrderDraftSubmit;
|
|
@@ -6718,26 +6802,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
6718
6802
|
}, {
|
|
6719
6803
|
key: "handlePendingSyncCheckoutOrder",
|
|
6720
6804
|
value: function () {
|
|
6721
|
-
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6805
|
+
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(params) {
|
|
6722
6806
|
var _this16 = this;
|
|
6723
6807
|
var backendPath, data, title, reason, invoiceTemplateSettings, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
|
|
6724
|
-
return _regeneratorRuntime().wrap(function
|
|
6725
|
-
while (1) switch (
|
|
6808
|
+
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
6809
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
6726
6810
|
case 0:
|
|
6727
6811
|
backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason, invoiceTemplateSettings = params.invoiceTemplateSettings;
|
|
6728
|
-
|
|
6812
|
+
_context66.next = 3;
|
|
6729
6813
|
return this.buildPendingSyncCheckoutOrder(data, invoiceTemplateSettings);
|
|
6730
6814
|
case 3:
|
|
6731
|
-
pendingOrder =
|
|
6815
|
+
pendingOrder = _context66.sent;
|
|
6732
6816
|
if (pendingOrder) {
|
|
6733
|
-
|
|
6817
|
+
_context66.next = 7;
|
|
6734
6818
|
break;
|
|
6735
6819
|
}
|
|
6736
6820
|
this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
|
|
6737
6821
|
backendPath: backendPath,
|
|
6738
6822
|
reason: reason
|
|
6739
6823
|
});
|
|
6740
|
-
return
|
|
6824
|
+
return _context66.abrupt("return", {
|
|
6741
6825
|
code: 500,
|
|
6742
6826
|
status: false,
|
|
6743
6827
|
message: '订单缺少本地存储标识,无法写入待同步队列',
|
|
@@ -6745,22 +6829,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
6745
6829
|
});
|
|
6746
6830
|
case 7:
|
|
6747
6831
|
if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
|
|
6748
|
-
|
|
6832
|
+
_context66.next = 10;
|
|
6749
6833
|
break;
|
|
6750
6834
|
}
|
|
6751
6835
|
this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
|
|
6752
6836
|
backendPath: backendPath,
|
|
6753
6837
|
reason: reason
|
|
6754
6838
|
});
|
|
6755
|
-
return
|
|
6839
|
+
return _context66.abrupt("return", {
|
|
6756
6840
|
code: 500,
|
|
6757
6841
|
status: false,
|
|
6758
6842
|
message: 'Order 模块不支持本地待同步写入',
|
|
6759
6843
|
data: null
|
|
6760
6844
|
});
|
|
6761
6845
|
case 10:
|
|
6762
|
-
|
|
6763
|
-
|
|
6846
|
+
_context66.prev = 10;
|
|
6847
|
+
_context66.next = 13;
|
|
6764
6848
|
return this.order.upsertPendingSyncOrders([pendingOrder]);
|
|
6765
6849
|
case 13:
|
|
6766
6850
|
this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
|
|
@@ -6774,7 +6858,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6774
6858
|
var _payment$metadata;
|
|
6775
6859
|
return sum + _this16.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
|
|
6776
6860
|
}, 0);
|
|
6777
|
-
return
|
|
6861
|
+
return _context66.abrupt("return", {
|
|
6778
6862
|
code: 200,
|
|
6779
6863
|
status: true,
|
|
6780
6864
|
message: '',
|
|
@@ -6789,15 +6873,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
6789
6873
|
})
|
|
6790
6874
|
});
|
|
6791
6875
|
case 18:
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
errorMessage =
|
|
6876
|
+
_context66.prev = 18;
|
|
6877
|
+
_context66.t0 = _context66["catch"](10);
|
|
6878
|
+
errorMessage = _context66.t0 instanceof Error ? _context66.t0.message : String(_context66.t0);
|
|
6795
6879
|
this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
|
|
6796
6880
|
backendPath: backendPath,
|
|
6797
6881
|
reason: reason,
|
|
6798
6882
|
error: errorMessage
|
|
6799
6883
|
});
|
|
6800
|
-
return
|
|
6884
|
+
return _context66.abrupt("return", {
|
|
6801
6885
|
code: 500,
|
|
6802
6886
|
status: false,
|
|
6803
6887
|
message: errorMessage,
|
|
@@ -6805,11 +6889,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6805
6889
|
});
|
|
6806
6890
|
case 23:
|
|
6807
6891
|
case "end":
|
|
6808
|
-
return
|
|
6892
|
+
return _context66.stop();
|
|
6809
6893
|
}
|
|
6810
|
-
},
|
|
6894
|
+
}, _callee66, this, [[10, 18]]);
|
|
6811
6895
|
}));
|
|
6812
|
-
function handlePendingSyncCheckoutOrder(
|
|
6896
|
+
function handlePendingSyncCheckoutOrder(_x73) {
|
|
6813
6897
|
return _handlePendingSyncCheckoutOrder.apply(this, arguments);
|
|
6814
6898
|
}
|
|
6815
6899
|
return handlePendingSyncCheckoutOrder;
|
|
@@ -6817,45 +6901,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
6817
6901
|
}, {
|
|
6818
6902
|
key: "buildPendingSyncCheckoutOrder",
|
|
6819
6903
|
value: function () {
|
|
6820
|
-
var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6904
|
+
var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(data, invoiceTemplateSettings) {
|
|
6821
6905
|
var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
|
|
6822
|
-
return _regeneratorRuntime().wrap(function
|
|
6823
|
-
while (1) switch (
|
|
6906
|
+
return _regeneratorRuntime().wrap(function _callee67$(_context67) {
|
|
6907
|
+
while (1) switch (_context67.prev = _context67.next) {
|
|
6824
6908
|
case 0:
|
|
6825
6909
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
6826
|
-
|
|
6910
|
+
_context67.next = 2;
|
|
6827
6911
|
break;
|
|
6828
6912
|
}
|
|
6829
|
-
return
|
|
6913
|
+
return _context67.abrupt("return", null);
|
|
6830
6914
|
case 2:
|
|
6831
6915
|
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 !== '';
|
|
6832
6916
|
if (hasStorageKey) {
|
|
6833
|
-
|
|
6917
|
+
_context67.next = 5;
|
|
6834
6918
|
break;
|
|
6835
6919
|
}
|
|
6836
|
-
return
|
|
6920
|
+
return _context67.abrupt("return", null);
|
|
6837
6921
|
case 5:
|
|
6838
6922
|
pendingOrder = this.normalizeCheckoutCollections(_objectSpread(_objectSpread({}, data), {}, {
|
|
6839
6923
|
need_sync: 1,
|
|
6840
6924
|
is_draft_order: 0
|
|
6841
6925
|
}));
|
|
6842
|
-
|
|
6926
|
+
_context67.next = 8;
|
|
6843
6927
|
return this.buildSmallTicketProductMap(pendingOrder);
|
|
6844
6928
|
case 8:
|
|
6845
|
-
productMap =
|
|
6929
|
+
productMap = _context67.sent;
|
|
6846
6930
|
orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
|
|
6847
|
-
return
|
|
6931
|
+
return _context67.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
|
|
6848
6932
|
requireFullyPaid: true,
|
|
6849
6933
|
productMap: productMap,
|
|
6850
6934
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6851
6935
|
}));
|
|
6852
6936
|
case 11:
|
|
6853
6937
|
case "end":
|
|
6854
|
-
return
|
|
6938
|
+
return _context67.stop();
|
|
6855
6939
|
}
|
|
6856
|
-
},
|
|
6940
|
+
}, _callee67, this);
|
|
6857
6941
|
}));
|
|
6858
|
-
function buildPendingSyncCheckoutOrder(
|
|
6942
|
+
function buildPendingSyncCheckoutOrder(_x74, _x75) {
|
|
6859
6943
|
return _buildPendingSyncCheckoutOrder.apply(this, arguments);
|
|
6860
6944
|
}
|
|
6861
6945
|
return buildPendingSyncCheckoutOrder;
|
|
@@ -6952,12 +7036,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
6952
7036
|
}, {
|
|
6953
7037
|
key: "buildSmallTicketProductMap",
|
|
6954
7038
|
value: function () {
|
|
6955
|
-
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6956
|
-
var _this$
|
|
7039
|
+
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(order) {
|
|
7040
|
+
var _this$products4,
|
|
6957
7041
|
_this18 = this;
|
|
6958
7042
|
var products, productIdSet, productIds, entries;
|
|
6959
|
-
return _regeneratorRuntime().wrap(function
|
|
6960
|
-
while (1) switch (
|
|
7043
|
+
return _regeneratorRuntime().wrap(function _callee69$(_context69) {
|
|
7044
|
+
while (1) switch (_context69.prev = _context69.next) {
|
|
6961
7045
|
case 0:
|
|
6962
7046
|
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
|
|
6963
7047
|
productIdSet = new Set();
|
|
@@ -6978,46 +7062,46 @@ var Server = /*#__PURE__*/function () {
|
|
|
6978
7062
|
}
|
|
6979
7063
|
});
|
|
6980
7064
|
productIds = Array.from(productIdSet);
|
|
6981
|
-
if (!(!productIds.length || typeof ((_this$
|
|
6982
|
-
|
|
7065
|
+
if (!(!productIds.length || typeof ((_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductById) !== 'function')) {
|
|
7066
|
+
_context69.next = 6;
|
|
6983
7067
|
break;
|
|
6984
7068
|
}
|
|
6985
|
-
return
|
|
7069
|
+
return _context69.abrupt("return", {});
|
|
6986
7070
|
case 6:
|
|
6987
|
-
|
|
7071
|
+
_context69.next = 8;
|
|
6988
7072
|
return Promise.all(productIds.map( /*#__PURE__*/function () {
|
|
6989
|
-
var _ref71 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7073
|
+
var _ref71 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(id) {
|
|
6990
7074
|
var _this18$products, _this18$products$getP, product;
|
|
6991
|
-
return _regeneratorRuntime().wrap(function
|
|
6992
|
-
while (1) switch (
|
|
7075
|
+
return _regeneratorRuntime().wrap(function _callee68$(_context68) {
|
|
7076
|
+
while (1) switch (_context68.prev = _context68.next) {
|
|
6993
7077
|
case 0:
|
|
6994
|
-
|
|
6995
|
-
|
|
7078
|
+
_context68.prev = 0;
|
|
7079
|
+
_context68.next = 3;
|
|
6996
7080
|
return (_this18$products = _this18.products) === null || _this18$products === void 0 || (_this18$products$getP = _this18$products.getProductById) === null || _this18$products$getP === void 0 ? void 0 : _this18$products$getP.call(_this18$products, Number(id));
|
|
6997
7081
|
case 3:
|
|
6998
|
-
product =
|
|
6999
|
-
return
|
|
7082
|
+
product = _context68.sent;
|
|
7083
|
+
return _context68.abrupt("return", product ? [String(id), product] : null);
|
|
7000
7084
|
case 7:
|
|
7001
|
-
|
|
7002
|
-
|
|
7085
|
+
_context68.prev = 7;
|
|
7086
|
+
_context68.t0 = _context68["catch"](0);
|
|
7003
7087
|
_this18.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
|
|
7004
7088
|
product_id: id,
|
|
7005
|
-
error:
|
|
7089
|
+
error: _context68.t0 instanceof Error ? _context68.t0.message : String(_context68.t0)
|
|
7006
7090
|
});
|
|
7007
|
-
return
|
|
7091
|
+
return _context68.abrupt("return", null);
|
|
7008
7092
|
case 11:
|
|
7009
7093
|
case "end":
|
|
7010
|
-
return
|
|
7094
|
+
return _context68.stop();
|
|
7011
7095
|
}
|
|
7012
|
-
},
|
|
7096
|
+
}, _callee68, null, [[0, 7]]);
|
|
7013
7097
|
}));
|
|
7014
|
-
return function (
|
|
7098
|
+
return function (_x77) {
|
|
7015
7099
|
return _ref71.apply(this, arguments);
|
|
7016
7100
|
};
|
|
7017
7101
|
}()));
|
|
7018
7102
|
case 8:
|
|
7019
|
-
entries =
|
|
7020
|
-
return
|
|
7103
|
+
entries = _context69.sent;
|
|
7104
|
+
return _context69.abrupt("return", entries.reduce(function (map, entry) {
|
|
7021
7105
|
if (!entry) return map;
|
|
7022
7106
|
var _entry = _slicedToArray(entry, 2),
|
|
7023
7107
|
id = _entry[0],
|
|
@@ -7027,11 +7111,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
7027
7111
|
}, {}));
|
|
7028
7112
|
case 10:
|
|
7029
7113
|
case "end":
|
|
7030
|
-
return
|
|
7114
|
+
return _context69.stop();
|
|
7031
7115
|
}
|
|
7032
|
-
},
|
|
7116
|
+
}, _callee69, this);
|
|
7033
7117
|
}));
|
|
7034
|
-
function buildSmallTicketProductMap(
|
|
7118
|
+
function buildSmallTicketProductMap(_x76) {
|
|
7035
7119
|
return _buildSmallTicketProductMap.apply(this, arguments);
|
|
7036
7120
|
}
|
|
7037
7121
|
return buildSmallTicketProductMap;
|
|
@@ -7061,40 +7145,40 @@ var Server = /*#__PURE__*/function () {
|
|
|
7061
7145
|
}, {
|
|
7062
7146
|
key: "buildSalesDetailProductSnapshotMap",
|
|
7063
7147
|
value: function () {
|
|
7064
|
-
var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7065
|
-
var _this$
|
|
7148
|
+
var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(order) {
|
|
7149
|
+
var _this$products5;
|
|
7066
7150
|
var productIds, getSnapshots;
|
|
7067
|
-
return _regeneratorRuntime().wrap(function
|
|
7068
|
-
while (1) switch (
|
|
7151
|
+
return _regeneratorRuntime().wrap(function _callee70$(_context70) {
|
|
7152
|
+
while (1) switch (_context70.prev = _context70.next) {
|
|
7069
7153
|
case 0:
|
|
7070
7154
|
productIds = this.collectSalesDetailProductIds(order);
|
|
7071
|
-
getSnapshots = (_this$
|
|
7155
|
+
getSnapshots = (_this$products5 = this.products) === null || _this$products5 === void 0 ? void 0 : _this$products5.getProductSnapshotsByIds;
|
|
7072
7156
|
if (!(!productIds.length || typeof getSnapshots !== 'function')) {
|
|
7073
|
-
|
|
7157
|
+
_context70.next = 4;
|
|
7074
7158
|
break;
|
|
7075
7159
|
}
|
|
7076
|
-
return
|
|
7160
|
+
return _context70.abrupt("return", {});
|
|
7077
7161
|
case 4:
|
|
7078
|
-
|
|
7079
|
-
|
|
7162
|
+
_context70.prev = 4;
|
|
7163
|
+
_context70.next = 7;
|
|
7080
7164
|
return getSnapshots.call(this.products, productIds);
|
|
7081
7165
|
case 7:
|
|
7082
|
-
return
|
|
7166
|
+
return _context70.abrupt("return", _context70.sent);
|
|
7083
7167
|
case 10:
|
|
7084
|
-
|
|
7085
|
-
|
|
7168
|
+
_context70.prev = 10;
|
|
7169
|
+
_context70.t0 = _context70["catch"](4);
|
|
7086
7170
|
this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
|
|
7087
7171
|
product_ids: productIds,
|
|
7088
|
-
error:
|
|
7172
|
+
error: _context70.t0 instanceof Error ? _context70.t0.message : String(_context70.t0)
|
|
7089
7173
|
});
|
|
7090
|
-
return
|
|
7174
|
+
return _context70.abrupt("return", {});
|
|
7091
7175
|
case 14:
|
|
7092
7176
|
case "end":
|
|
7093
|
-
return
|
|
7177
|
+
return _context70.stop();
|
|
7094
7178
|
}
|
|
7095
|
-
},
|
|
7179
|
+
}, _callee70, this, [[4, 10]]);
|
|
7096
7180
|
}));
|
|
7097
|
-
function buildSalesDetailProductSnapshotMap(
|
|
7181
|
+
function buildSalesDetailProductSnapshotMap(_x78) {
|
|
7098
7182
|
return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
|
|
7099
7183
|
}
|
|
7100
7184
|
return buildSalesDetailProductSnapshotMap;
|
|
@@ -7150,28 +7234,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
7150
7234
|
}, {
|
|
7151
7235
|
key: "withSalesDetailProductSnapshots",
|
|
7152
7236
|
value: function () {
|
|
7153
|
-
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7237
|
+
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(order) {
|
|
7154
7238
|
var _this19 = this;
|
|
7155
7239
|
var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
|
|
7156
|
-
return _regeneratorRuntime().wrap(function
|
|
7157
|
-
while (1) switch (
|
|
7240
|
+
return _regeneratorRuntime().wrap(function _callee71$(_context71) {
|
|
7241
|
+
while (1) switch (_context71.prev = _context71.next) {
|
|
7158
7242
|
case 0:
|
|
7159
7243
|
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
|
|
7160
7244
|
if (products !== null && products !== void 0 && products.length) {
|
|
7161
|
-
|
|
7245
|
+
_context71.next = 3;
|
|
7162
7246
|
break;
|
|
7163
7247
|
}
|
|
7164
|
-
return
|
|
7248
|
+
return _context71.abrupt("return", order);
|
|
7165
7249
|
case 3:
|
|
7166
|
-
|
|
7250
|
+
_context71.next = 5;
|
|
7167
7251
|
return this.buildSalesDetailProductSnapshotMap(order);
|
|
7168
7252
|
case 5:
|
|
7169
|
-
snapshotMap =
|
|
7253
|
+
snapshotMap = _context71.sent;
|
|
7170
7254
|
if (Object.keys(snapshotMap).length) {
|
|
7171
|
-
|
|
7255
|
+
_context71.next = 8;
|
|
7172
7256
|
break;
|
|
7173
7257
|
}
|
|
7174
|
-
return
|
|
7258
|
+
return _context71.abrupt("return", order);
|
|
7175
7259
|
case 8:
|
|
7176
7260
|
hasChanged = false;
|
|
7177
7261
|
enrichedProducts = products.map(function (product) {
|
|
@@ -7181,22 +7265,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
7181
7265
|
return nextProduct;
|
|
7182
7266
|
});
|
|
7183
7267
|
if (hasChanged) {
|
|
7184
|
-
|
|
7268
|
+
_context71.next = 12;
|
|
7185
7269
|
break;
|
|
7186
7270
|
}
|
|
7187
|
-
return
|
|
7271
|
+
return _context71.abrupt("return", order);
|
|
7188
7272
|
case 12:
|
|
7189
7273
|
enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
|
|
7190
7274
|
products: enrichedProducts
|
|
7191
7275
|
});
|
|
7192
|
-
return
|
|
7276
|
+
return _context71.abrupt("return", enrichedOrder);
|
|
7193
7277
|
case 14:
|
|
7194
7278
|
case "end":
|
|
7195
|
-
return
|
|
7279
|
+
return _context71.stop();
|
|
7196
7280
|
}
|
|
7197
|
-
},
|
|
7281
|
+
}, _callee71, this);
|
|
7198
7282
|
}));
|
|
7199
|
-
function withSalesDetailProductSnapshots(
|
|
7283
|
+
function withSalesDetailProductSnapshots(_x79) {
|
|
7200
7284
|
return _withSalesDetailProductSnapshots.apply(this, arguments);
|
|
7201
7285
|
}
|
|
7202
7286
|
return withSalesDetailProductSnapshots;
|
|
@@ -7327,31 +7411,31 @@ var Server = /*#__PURE__*/function () {
|
|
|
7327
7411
|
}, {
|
|
7328
7412
|
key: "enrichPaymentNamesByCode",
|
|
7329
7413
|
value: function () {
|
|
7330
|
-
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7414
|
+
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(order) {
|
|
7331
7415
|
var _this22 = this;
|
|
7332
7416
|
var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
|
|
7333
|
-
return _regeneratorRuntime().wrap(function
|
|
7334
|
-
while (1) switch (
|
|
7417
|
+
return _regeneratorRuntime().wrap(function _callee72$(_context72) {
|
|
7418
|
+
while (1) switch (_context72.prev = _context72.next) {
|
|
7335
7419
|
case 0:
|
|
7336
7420
|
payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
|
|
7337
7421
|
hasMissingName = payments.some(function (payment) {
|
|
7338
7422
|
return _this22.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this22.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
|
|
7339
7423
|
});
|
|
7340
7424
|
if (hasMissingName) {
|
|
7341
|
-
|
|
7425
|
+
_context72.next = 4;
|
|
7342
7426
|
break;
|
|
7343
7427
|
}
|
|
7344
|
-
return
|
|
7428
|
+
return _context72.abrupt("return", order);
|
|
7345
7429
|
case 4:
|
|
7346
|
-
|
|
7347
|
-
|
|
7430
|
+
_context72.prev = 4;
|
|
7431
|
+
_context72.next = 7;
|
|
7348
7432
|
return this.getPaymentRouteModule();
|
|
7349
7433
|
case 7:
|
|
7350
|
-
paymentModule =
|
|
7351
|
-
|
|
7434
|
+
paymentModule = _context72.sent;
|
|
7435
|
+
_context72.next = 10;
|
|
7352
7436
|
return paymentModule.getPayMethodListAsync();
|
|
7353
7437
|
case 10:
|
|
7354
|
-
payMethods =
|
|
7438
|
+
payMethods = _context72.sent;
|
|
7355
7439
|
nameByCode = new Map();
|
|
7356
7440
|
_iterator12 = _createForOfIteratorHelper(payMethods || []);
|
|
7357
7441
|
try {
|
|
@@ -7378,28 +7462,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
7378
7462
|
});
|
|
7379
7463
|
});
|
|
7380
7464
|
if (hasResolvedName) {
|
|
7381
|
-
|
|
7465
|
+
_context72.next = 18;
|
|
7382
7466
|
break;
|
|
7383
7467
|
}
|
|
7384
|
-
return
|
|
7468
|
+
return _context72.abrupt("return", order);
|
|
7385
7469
|
case 18:
|
|
7386
|
-
return
|
|
7470
|
+
return _context72.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
|
|
7387
7471
|
payments: enrichedPayments
|
|
7388
7472
|
}));
|
|
7389
7473
|
case 21:
|
|
7390
|
-
|
|
7391
|
-
|
|
7474
|
+
_context72.prev = 21;
|
|
7475
|
+
_context72.t0 = _context72["catch"](4);
|
|
7392
7476
|
this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
|
|
7393
|
-
error:
|
|
7477
|
+
error: _context72.t0 instanceof Error ? _context72.t0.message : String(_context72.t0)
|
|
7394
7478
|
});
|
|
7395
|
-
return
|
|
7479
|
+
return _context72.abrupt("return", order);
|
|
7396
7480
|
case 25:
|
|
7397
7481
|
case "end":
|
|
7398
|
-
return
|
|
7482
|
+
return _context72.stop();
|
|
7399
7483
|
}
|
|
7400
|
-
},
|
|
7484
|
+
}, _callee72, this, [[4, 21]]);
|
|
7401
7485
|
}));
|
|
7402
|
-
function enrichPaymentNamesByCode(
|
|
7486
|
+
function enrichPaymentNamesByCode(_x80) {
|
|
7403
7487
|
return _enrichPaymentNamesByCode.apply(this, arguments);
|
|
7404
7488
|
}
|
|
7405
7489
|
return enrichPaymentNamesByCode;
|
|
@@ -7407,25 +7491,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
7407
7491
|
}, {
|
|
7408
7492
|
key: "withLocalSmallTicketData",
|
|
7409
7493
|
value: function () {
|
|
7410
|
-
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7494
|
+
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(order, options) {
|
|
7411
7495
|
var mustApplyVisibility, _options$productMap, normalizedCollections, normalizedOrder, collapsedDuplicateCounts, _ref76, _ref77, _order_id, enrichedOrder, productMap, smallTicketData;
|
|
7412
|
-
return _regeneratorRuntime().wrap(function
|
|
7413
|
-
while (1) switch (
|
|
7496
|
+
return _regeneratorRuntime().wrap(function _callee73$(_context73) {
|
|
7497
|
+
while (1) switch (_context73.prev = _context73.next) {
|
|
7414
7498
|
case 0:
|
|
7415
7499
|
mustApplyVisibility = (options === null || options === void 0 ? void 0 : options.applyTemplateVisibility) === true && requiresInvoiceDataFiltering(options.invoiceTemplateSettings);
|
|
7416
7500
|
if (!(!this.shouldBuildSmallTicketData(order) && !mustApplyVisibility)) {
|
|
7417
|
-
|
|
7501
|
+
_context73.next = 3;
|
|
7418
7502
|
break;
|
|
7419
7503
|
}
|
|
7420
|
-
return
|
|
7504
|
+
return _context73.abrupt("return", order);
|
|
7421
7505
|
case 3:
|
|
7422
7506
|
if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
|
|
7423
|
-
|
|
7507
|
+
_context73.next = 5;
|
|
7424
7508
|
break;
|
|
7425
7509
|
}
|
|
7426
|
-
return
|
|
7510
|
+
return _context73.abrupt("return", order);
|
|
7427
7511
|
case 5:
|
|
7428
|
-
|
|
7512
|
+
_context73.prev = 5;
|
|
7429
7513
|
normalizedCollections = normalizeOrderCollections(order, {
|
|
7430
7514
|
ensureUid: false
|
|
7431
7515
|
});
|
|
@@ -7443,24 +7527,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
7443
7527
|
collapsed_duplicate_counts: collapsedDuplicateCounts
|
|
7444
7528
|
});
|
|
7445
7529
|
}
|
|
7446
|
-
|
|
7530
|
+
_context73.next = 12;
|
|
7447
7531
|
return this.enrichPaymentNamesByCode(normalizedOrder);
|
|
7448
7532
|
case 12:
|
|
7449
|
-
enrichedOrder =
|
|
7533
|
+
enrichedOrder = _context73.sent;
|
|
7450
7534
|
if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
|
|
7451
|
-
|
|
7535
|
+
_context73.next = 17;
|
|
7452
7536
|
break;
|
|
7453
7537
|
}
|
|
7454
|
-
|
|
7455
|
-
|
|
7538
|
+
_context73.t0 = _options$productMap;
|
|
7539
|
+
_context73.next = 20;
|
|
7456
7540
|
break;
|
|
7457
7541
|
case 17:
|
|
7458
|
-
|
|
7542
|
+
_context73.next = 19;
|
|
7459
7543
|
return this.buildSmallTicketProductMap(enrichedOrder);
|
|
7460
7544
|
case 19:
|
|
7461
|
-
|
|
7545
|
+
_context73.t0 = _context73.sent;
|
|
7462
7546
|
case 20:
|
|
7463
|
-
productMap =
|
|
7547
|
+
productMap = _context73.t0;
|
|
7464
7548
|
smallTicketData = buildSmallTicketData({
|
|
7465
7549
|
order: enrichedOrder,
|
|
7466
7550
|
shopInfo: this.getSmallTicketShopInfo(),
|
|
@@ -7469,31 +7553,31 @@ var Server = /*#__PURE__*/function () {
|
|
|
7469
7553
|
includeReceiptKeys: options === null || options === void 0 ? void 0 : options.includeReceiptKeys,
|
|
7470
7554
|
templateSettings: options !== null && options !== void 0 && options.applyTemplateVisibility ? options.invoiceTemplateSettings : undefined
|
|
7471
7555
|
});
|
|
7472
|
-
return
|
|
7556
|
+
return _context73.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
|
|
7473
7557
|
payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
|
|
7474
7558
|
small_ticket_data: smallTicketData
|
|
7475
7559
|
})
|
|
7476
7560
|
}));
|
|
7477
7561
|
case 25:
|
|
7478
|
-
|
|
7479
|
-
|
|
7562
|
+
_context73.prev = 25;
|
|
7563
|
+
_context73.t1 = _context73["catch"](5);
|
|
7480
7564
|
this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
|
|
7481
|
-
error:
|
|
7565
|
+
error: _context73.t1 instanceof Error ? _context73.t1.message : String(_context73.t1)
|
|
7482
7566
|
});
|
|
7483
7567
|
if (!mustApplyVisibility) {
|
|
7484
|
-
|
|
7568
|
+
_context73.next = 30;
|
|
7485
7569
|
break;
|
|
7486
7570
|
}
|
|
7487
|
-
throw
|
|
7571
|
+
throw _context73.t1;
|
|
7488
7572
|
case 30:
|
|
7489
|
-
return
|
|
7573
|
+
return _context73.abrupt("return", order);
|
|
7490
7574
|
case 31:
|
|
7491
7575
|
case "end":
|
|
7492
|
-
return
|
|
7576
|
+
return _context73.stop();
|
|
7493
7577
|
}
|
|
7494
|
-
},
|
|
7578
|
+
}, _callee73, this, [[5, 25]]);
|
|
7495
7579
|
}));
|
|
7496
|
-
function withLocalSmallTicketData(
|
|
7580
|
+
function withLocalSmallTicketData(_x81, _x82) {
|
|
7497
7581
|
return _withLocalSmallTicketData.apply(this, arguments);
|
|
7498
7582
|
}
|
|
7499
7583
|
return withLocalSmallTicketData;
|
|
@@ -7508,37 +7592,37 @@ var Server = /*#__PURE__*/function () {
|
|
|
7508
7592
|
}, {
|
|
7509
7593
|
key: "fetchAndPersistSalesOrderByLookup",
|
|
7510
7594
|
value: function () {
|
|
7511
|
-
var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7595
|
+
var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(lookup, data, title) {
|
|
7512
7596
|
var _this$order5, _this$order6, _this$app19;
|
|
7513
7597
|
var backendPath, response, _response$code3, responseStatusCode, code, message, fresh, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode, _ref78, _backendError$code2, backendStatusCode, _code, _message2, _message3;
|
|
7514
|
-
return _regeneratorRuntime().wrap(function
|
|
7515
|
-
while (1) switch (
|
|
7598
|
+
return _regeneratorRuntime().wrap(function _callee74$(_context74) {
|
|
7599
|
+
while (1) switch (_context74.prev = _context74.next) {
|
|
7516
7600
|
case 0:
|
|
7517
7601
|
if (!(!((_this$order5 = this.order) !== null && _this$order5 !== void 0 && _this$order5.getLocalOrderByLookup) || !((_this$order6 = this.order) !== null && _this$order6 !== void 0 && _this$order6.upsertOrdersFromRemote))) {
|
|
7518
|
-
|
|
7602
|
+
_context74.next = 3;
|
|
7519
7603
|
break;
|
|
7520
7604
|
}
|
|
7521
7605
|
this.logError("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C"));
|
|
7522
|
-
return
|
|
7606
|
+
return _context74.abrupt("return", {
|
|
7523
7607
|
code: 500,
|
|
7524
7608
|
message: 'Order 模块未注册',
|
|
7525
7609
|
order: null
|
|
7526
7610
|
});
|
|
7527
7611
|
case 3:
|
|
7528
7612
|
if ((_this$app19 = this.app) !== null && _this$app19 !== void 0 && (_this$app19 = _this$app19.request) !== null && _this$app19 !== void 0 && _this$app19.get) {
|
|
7529
|
-
|
|
7613
|
+
_context74.next = 6;
|
|
7530
7614
|
break;
|
|
7531
7615
|
}
|
|
7532
7616
|
this.logError("".concat(title, ": app.request \u4E0D\u53EF\u7528"));
|
|
7533
|
-
return
|
|
7617
|
+
return _context74.abrupt("return", {
|
|
7534
7618
|
code: 500,
|
|
7535
7619
|
message: 'app.request 不可用',
|
|
7536
7620
|
order: null
|
|
7537
7621
|
});
|
|
7538
7622
|
case 6:
|
|
7539
7623
|
backendPath = this.buildOrderSalesDetailBackendPath(String(lookup), data);
|
|
7540
|
-
|
|
7541
|
-
|
|
7624
|
+
_context74.prev = 7;
|
|
7625
|
+
_context74.next = 10;
|
|
7542
7626
|
return this.app.request.get(backendPath, {
|
|
7543
7627
|
lookup_mode: 'multi'
|
|
7544
7628
|
}, {
|
|
@@ -7546,9 +7630,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7546
7630
|
customToast: function customToast() {}
|
|
7547
7631
|
});
|
|
7548
7632
|
case 10:
|
|
7549
|
-
response =
|
|
7633
|
+
response = _context74.sent;
|
|
7550
7634
|
if (!this.isCheckoutResponseRejected(response)) {
|
|
7551
|
-
|
|
7635
|
+
_context74.next = 17;
|
|
7552
7636
|
break;
|
|
7553
7637
|
}
|
|
7554
7638
|
responseStatusCode = typeof (response === null || response === void 0 ? void 0 : response.status) === 'number' ? response.status : undefined;
|
|
@@ -7560,7 +7644,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7560
7644
|
code: code,
|
|
7561
7645
|
message: message
|
|
7562
7646
|
});
|
|
7563
|
-
return
|
|
7647
|
+
return _context74.abrupt("return", {
|
|
7564
7648
|
code: code,
|
|
7565
7649
|
message: message,
|
|
7566
7650
|
order: null
|
|
@@ -7568,44 +7652,44 @@ var Server = /*#__PURE__*/function () {
|
|
|
7568
7652
|
case 17:
|
|
7569
7653
|
fresh = this.extractOrderDataFromCheckoutResponse(response);
|
|
7570
7654
|
if (!(!fresh || fresh.order_id === undefined || fresh.order_id === null || String(fresh.order_id).trim() === '')) {
|
|
7571
|
-
|
|
7655
|
+
_context74.next = 21;
|
|
7572
7656
|
break;
|
|
7573
7657
|
}
|
|
7574
7658
|
this.logInfo("".concat(title, ": \u540E\u7AEF\u8FD4\u56DE\u8BA2\u5355\u4E3A\u7A7A"), {
|
|
7575
7659
|
lookup: lookup,
|
|
7576
7660
|
backendPath: backendPath
|
|
7577
7661
|
});
|
|
7578
|
-
return
|
|
7662
|
+
return _context74.abrupt("return", {
|
|
7579
7663
|
code: 500,
|
|
7580
7664
|
message: '后端返回订单为空',
|
|
7581
7665
|
order: null
|
|
7582
7666
|
});
|
|
7583
7667
|
case 21:
|
|
7584
|
-
|
|
7668
|
+
_context74.next = 23;
|
|
7585
7669
|
return this.order.upsertOrdersFromRemote([fresh]);
|
|
7586
7670
|
case 23:
|
|
7587
|
-
|
|
7671
|
+
_context74.next = 25;
|
|
7588
7672
|
return this.order.getLocalOrderByLookup(lookup);
|
|
7589
7673
|
case 25:
|
|
7590
|
-
savedOrder =
|
|
7674
|
+
savedOrder = _context74.sent;
|
|
7591
7675
|
if (!(!savedOrder && fresh.order_id !== undefined && fresh.order_id !== null && String(fresh.order_id) !== String(lookup))) {
|
|
7592
|
-
|
|
7676
|
+
_context74.next = 30;
|
|
7593
7677
|
break;
|
|
7594
7678
|
}
|
|
7595
|
-
|
|
7679
|
+
_context74.next = 29;
|
|
7596
7680
|
return this.order.getLocalOrderByLookup(fresh.order_id);
|
|
7597
7681
|
case 29:
|
|
7598
|
-
savedOrder =
|
|
7682
|
+
savedOrder = _context74.sent;
|
|
7599
7683
|
case 30:
|
|
7600
7684
|
if (savedOrder) {
|
|
7601
|
-
|
|
7685
|
+
_context74.next = 33;
|
|
7602
7686
|
break;
|
|
7603
7687
|
}
|
|
7604
7688
|
this.logError("".concat(title, ": \u8BA2\u5355\u5199\u5165\u540E\u56DE\u8BFB\u5931\u8D25"), {
|
|
7605
7689
|
lookup: lookup,
|
|
7606
7690
|
remote_order_id: fresh.order_id
|
|
7607
7691
|
});
|
|
7608
|
-
return
|
|
7692
|
+
return _context74.abrupt("return", {
|
|
7609
7693
|
code: 500,
|
|
7610
7694
|
message: '订单写入后回读失败',
|
|
7611
7695
|
order: null
|
|
@@ -7615,54 +7699,54 @@ var Server = /*#__PURE__*/function () {
|
|
|
7615
7699
|
lookup: lookup,
|
|
7616
7700
|
remote_order_id: fresh.order_id
|
|
7617
7701
|
});
|
|
7618
|
-
return
|
|
7702
|
+
return _context74.abrupt("return", {
|
|
7619
7703
|
code: 200,
|
|
7620
7704
|
message: '',
|
|
7621
7705
|
order: savedOrder
|
|
7622
7706
|
});
|
|
7623
7707
|
case 37:
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
backendError = this.extractBackendErrorResponse(
|
|
7627
|
-
errorRecord =
|
|
7708
|
+
_context74.prev = 37;
|
|
7709
|
+
_context74.t0 = _context74["catch"](7);
|
|
7710
|
+
backendError = this.extractBackendErrorResponse(_context74.t0);
|
|
7711
|
+
errorRecord = _context74.t0;
|
|
7628
7712
|
_responseStatusCode = typeof (errorRecord === null || errorRecord === void 0 || (_errorRecord$response = errorRecord.response) === null || _errorRecord$response === void 0 ? void 0 : _errorRecord$response.status) === 'number' ? errorRecord.response.status : undefined;
|
|
7629
7713
|
if (!(backendError || _responseStatusCode !== undefined)) {
|
|
7630
|
-
|
|
7714
|
+
_context74.next = 48;
|
|
7631
7715
|
break;
|
|
7632
7716
|
}
|
|
7633
7717
|
backendStatusCode = typeof (backendError === null || backendError === void 0 ? void 0 : backendError.status) === 'number' ? backendError.status : undefined;
|
|
7634
7718
|
_code = this.normalizeRemoteSalesOrderErrorCode((_ref78 = (_backendError$code2 = backendError === null || backendError === void 0 ? void 0 : backendError.code) !== null && _backendError$code2 !== void 0 ? _backendError$code2 : backendStatusCode) !== null && _ref78 !== void 0 ? _ref78 : _responseStatusCode);
|
|
7635
|
-
_message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(
|
|
7719
|
+
_message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context74.t0);
|
|
7636
7720
|
this.logInfo("".concat(title, ": \u540E\u7AEF\u8BA2\u5355\u67E5\u8BE2\u5931\u8D25"), {
|
|
7637
7721
|
lookup: lookup,
|
|
7638
7722
|
backendPath: backendPath,
|
|
7639
7723
|
code: _code,
|
|
7640
7724
|
message: _message2
|
|
7641
7725
|
});
|
|
7642
|
-
return
|
|
7726
|
+
return _context74.abrupt("return", {
|
|
7643
7727
|
code: _code,
|
|
7644
7728
|
message: _message2,
|
|
7645
7729
|
order: null
|
|
7646
7730
|
});
|
|
7647
7731
|
case 48:
|
|
7648
|
-
_message3 = this.getUnknownErrorMessage(
|
|
7732
|
+
_message3 = this.getUnknownErrorMessage(_context74.t0);
|
|
7649
7733
|
this.logInfo("".concat(title, ": \u8BF7\u6C42\u5931\u8D25"), {
|
|
7650
7734
|
lookup: lookup,
|
|
7651
7735
|
backendPath: backendPath,
|
|
7652
7736
|
error: _message3
|
|
7653
7737
|
});
|
|
7654
|
-
return
|
|
7738
|
+
return _context74.abrupt("return", {
|
|
7655
7739
|
code: 500,
|
|
7656
7740
|
message: _message3,
|
|
7657
7741
|
order: null
|
|
7658
7742
|
});
|
|
7659
7743
|
case 51:
|
|
7660
7744
|
case "end":
|
|
7661
|
-
return
|
|
7745
|
+
return _context74.stop();
|
|
7662
7746
|
}
|
|
7663
|
-
},
|
|
7747
|
+
}, _callee74, this, [[7, 37]]);
|
|
7664
7748
|
}));
|
|
7665
|
-
function fetchAndPersistSalesOrderByLookup(
|
|
7749
|
+
function fetchAndPersistSalesOrderByLookup(_x83, _x84, _x85) {
|
|
7666
7750
|
return _fetchAndPersistSalesOrderByLookup.apply(this, arguments);
|
|
7667
7751
|
}
|
|
7668
7752
|
return fetchAndPersistSalesOrderByLookup;
|
|
@@ -7724,22 +7808,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
7724
7808
|
}, {
|
|
7725
7809
|
key: "handleUpdateLocalOrdersBatch",
|
|
7726
7810
|
value: (function () {
|
|
7727
|
-
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7811
|
+
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(orderIds) {
|
|
7728
7812
|
var _this$app20;
|
|
7729
7813
|
var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message4, overwritten, inserted;
|
|
7730
|
-
return _regeneratorRuntime().wrap(function
|
|
7731
|
-
while (1) switch (
|
|
7814
|
+
return _regeneratorRuntime().wrap(function _callee75$(_context75) {
|
|
7815
|
+
while (1) switch (_context75.prev = _context75.next) {
|
|
7732
7816
|
case 0:
|
|
7733
7817
|
this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
|
|
7734
7818
|
count: orderIds.length,
|
|
7735
7819
|
orderIds: orderIds
|
|
7736
7820
|
});
|
|
7737
7821
|
if (this.order) {
|
|
7738
|
-
|
|
7822
|
+
_context75.next = 4;
|
|
7739
7823
|
break;
|
|
7740
7824
|
}
|
|
7741
7825
|
this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
|
|
7742
|
-
return
|
|
7826
|
+
return _context75.abrupt("return", {
|
|
7743
7827
|
code: 500,
|
|
7744
7828
|
status: false,
|
|
7745
7829
|
message: 'Order 模块未注册',
|
|
@@ -7747,11 +7831,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
7747
7831
|
});
|
|
7748
7832
|
case 4:
|
|
7749
7833
|
if ((_this$app20 = this.app) !== null && _this$app20 !== void 0 && _this$app20.request) {
|
|
7750
|
-
|
|
7834
|
+
_context75.next = 7;
|
|
7751
7835
|
break;
|
|
7752
7836
|
}
|
|
7753
7837
|
this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
|
|
7754
|
-
return
|
|
7838
|
+
return _context75.abrupt("return", {
|
|
7755
7839
|
code: 500,
|
|
7756
7840
|
status: false,
|
|
7757
7841
|
message: 'app.request 不可用',
|
|
@@ -7774,21 +7858,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
7774
7858
|
_iterator13.f();
|
|
7775
7859
|
}
|
|
7776
7860
|
fetched = [];
|
|
7777
|
-
|
|
7778
|
-
|
|
7861
|
+
_context75.prev = 11;
|
|
7862
|
+
_context75.next = 14;
|
|
7779
7863
|
return this.order.fetchOrdersByHttp(orderIds);
|
|
7780
7864
|
case 14:
|
|
7781
|
-
fetched =
|
|
7782
|
-
|
|
7865
|
+
fetched = _context75.sent;
|
|
7866
|
+
_context75.next = 22;
|
|
7783
7867
|
break;
|
|
7784
7868
|
case 17:
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
message =
|
|
7869
|
+
_context75.prev = 17;
|
|
7870
|
+
_context75.t0 = _context75["catch"](11);
|
|
7871
|
+
message = _context75.t0 instanceof Error ? _context75.t0.message : String(_context75.t0);
|
|
7788
7872
|
this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
|
|
7789
7873
|
message: message
|
|
7790
7874
|
});
|
|
7791
|
-
return
|
|
7875
|
+
return _context75.abrupt("return", {
|
|
7792
7876
|
code: 500,
|
|
7793
7877
|
status: false,
|
|
7794
7878
|
message: message,
|
|
@@ -7798,36 +7882,36 @@ var Server = /*#__PURE__*/function () {
|
|
|
7798
7882
|
// 按返回结果中的 order_id 建索引,未命中即视为单笔失败
|
|
7799
7883
|
fetchedMap = new Map();
|
|
7800
7884
|
_iterator14 = _createForOfIteratorHelper(fetched);
|
|
7801
|
-
|
|
7885
|
+
_context75.prev = 24;
|
|
7802
7886
|
_iterator14.s();
|
|
7803
7887
|
case 26:
|
|
7804
7888
|
if ((_step14 = _iterator14.n()).done) {
|
|
7805
|
-
|
|
7889
|
+
_context75.next = 34;
|
|
7806
7890
|
break;
|
|
7807
7891
|
}
|
|
7808
7892
|
order = _step14.value;
|
|
7809
7893
|
oid = order === null || order === void 0 ? void 0 : order.order_id;
|
|
7810
7894
|
if (!(oid === undefined || oid === null)) {
|
|
7811
|
-
|
|
7895
|
+
_context75.next = 31;
|
|
7812
7896
|
break;
|
|
7813
7897
|
}
|
|
7814
|
-
return
|
|
7898
|
+
return _context75.abrupt("continue", 32);
|
|
7815
7899
|
case 31:
|
|
7816
7900
|
fetchedMap.set(String(oid), order);
|
|
7817
7901
|
case 32:
|
|
7818
|
-
|
|
7902
|
+
_context75.next = 26;
|
|
7819
7903
|
break;
|
|
7820
7904
|
case 34:
|
|
7821
|
-
|
|
7905
|
+
_context75.next = 39;
|
|
7822
7906
|
break;
|
|
7823
7907
|
case 36:
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
_iterator14.e(
|
|
7908
|
+
_context75.prev = 36;
|
|
7909
|
+
_context75.t1 = _context75["catch"](24);
|
|
7910
|
+
_iterator14.e(_context75.t1);
|
|
7827
7911
|
case 39:
|
|
7828
|
-
|
|
7912
|
+
_context75.prev = 39;
|
|
7829
7913
|
_iterator14.f();
|
|
7830
|
-
return
|
|
7914
|
+
return _context75.finish(39);
|
|
7831
7915
|
case 42:
|
|
7832
7916
|
freshOrders = [];
|
|
7833
7917
|
succeedIds = [];
|
|
@@ -7853,23 +7937,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
7853
7937
|
_iterator15.f();
|
|
7854
7938
|
}
|
|
7855
7939
|
if (!(freshOrders.length > 0)) {
|
|
7856
|
-
|
|
7940
|
+
_context75.next = 58;
|
|
7857
7941
|
break;
|
|
7858
7942
|
}
|
|
7859
|
-
|
|
7860
|
-
|
|
7943
|
+
_context75.prev = 48;
|
|
7944
|
+
_context75.next = 51;
|
|
7861
7945
|
return this.order.upsertOrdersFromRemote(freshOrders);
|
|
7862
7946
|
case 51:
|
|
7863
|
-
|
|
7947
|
+
_context75.next = 58;
|
|
7864
7948
|
break;
|
|
7865
7949
|
case 53:
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
_message4 =
|
|
7950
|
+
_context75.prev = 53;
|
|
7951
|
+
_context75.t2 = _context75["catch"](48);
|
|
7952
|
+
_message4 = _context75.t2 instanceof Error ? _context75.t2.message : String(_context75.t2);
|
|
7869
7953
|
this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
|
|
7870
7954
|
message: _message4
|
|
7871
7955
|
});
|
|
7872
|
-
return
|
|
7956
|
+
return _context75.abrupt("return", {
|
|
7873
7957
|
code: 500,
|
|
7874
7958
|
status: false,
|
|
7875
7959
|
message: _message4,
|
|
@@ -7888,7 +7972,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7888
7972
|
insertedCount: inserted.length,
|
|
7889
7973
|
failedCount: failed.length
|
|
7890
7974
|
});
|
|
7891
|
-
return
|
|
7975
|
+
return _context75.abrupt("return", {
|
|
7892
7976
|
code: 200,
|
|
7893
7977
|
status: true,
|
|
7894
7978
|
message: '',
|
|
@@ -7900,11 +7984,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
7900
7984
|
});
|
|
7901
7985
|
case 62:
|
|
7902
7986
|
case "end":
|
|
7903
|
-
return
|
|
7987
|
+
return _context75.stop();
|
|
7904
7988
|
}
|
|
7905
|
-
},
|
|
7989
|
+
}, _callee75, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
|
|
7906
7990
|
}));
|
|
7907
|
-
function handleUpdateLocalOrdersBatch(
|
|
7991
|
+
function handleUpdateLocalOrdersBatch(_x86) {
|
|
7908
7992
|
return _handleUpdateLocalOrdersBatch.apply(this, arguments);
|
|
7909
7993
|
}
|
|
7910
7994
|
return handleUpdateLocalOrdersBatch;
|
|
@@ -8273,16 +8357,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
8273
8357
|
}, {
|
|
8274
8358
|
key: "recomputeAndNotifyFloorPlanQuery",
|
|
8275
8359
|
value: (function () {
|
|
8276
|
-
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8360
|
+
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76() {
|
|
8277
8361
|
var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
|
|
8278
|
-
return _regeneratorRuntime().wrap(function
|
|
8279
|
-
while (1) switch (
|
|
8362
|
+
return _regeneratorRuntime().wrap(function _callee76$(_context76) {
|
|
8363
|
+
while (1) switch (_context76.prev = _context76.next) {
|
|
8280
8364
|
case 0:
|
|
8281
8365
|
if (!(this.floorPlanQuerySubscribers.size === 0)) {
|
|
8282
|
-
|
|
8366
|
+
_context76.next = 2;
|
|
8283
8367
|
break;
|
|
8284
8368
|
}
|
|
8285
|
-
return
|
|
8369
|
+
return _context76.abrupt("return");
|
|
8286
8370
|
case 2:
|
|
8287
8371
|
this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
|
|
8288
8372
|
subscriberCount: this.floorPlanQuerySubscribers.size
|
|
@@ -8312,9 +8396,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
8312
8396
|
}
|
|
8313
8397
|
case 5:
|
|
8314
8398
|
case "end":
|
|
8315
|
-
return
|
|
8399
|
+
return _context76.stop();
|
|
8316
8400
|
}
|
|
8317
|
-
},
|
|
8401
|
+
}, _callee76, this);
|
|
8318
8402
|
}));
|
|
8319
8403
|
function recomputeAndNotifyFloorPlanQuery() {
|
|
8320
8404
|
return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
|
|
@@ -8344,20 +8428,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
8344
8428
|
* filter 逻辑暂为 mock,仅记录参数
|
|
8345
8429
|
*/
|
|
8346
8430
|
function () {
|
|
8347
|
-
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8431
|
+
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(data) {
|
|
8348
8432
|
var rawList, result;
|
|
8349
|
-
return _regeneratorRuntime().wrap(function
|
|
8350
|
-
while (1) switch (
|
|
8433
|
+
return _regeneratorRuntime().wrap(function _callee77$(_context77) {
|
|
8434
|
+
while (1) switch (_context77.prev = _context77.next) {
|
|
8351
8435
|
case 0:
|
|
8352
8436
|
this.logInfo('computeOrderQueryResult: 开始过滤', {
|
|
8353
8437
|
data: data
|
|
8354
8438
|
});
|
|
8355
8439
|
if (this.order) {
|
|
8356
|
-
|
|
8440
|
+
_context77.next = 4;
|
|
8357
8441
|
break;
|
|
8358
8442
|
}
|
|
8359
8443
|
this.logError('computeOrderQueryResult: Order 模块未注册');
|
|
8360
|
-
return
|
|
8444
|
+
return _context77.abrupt("return", {
|
|
8361
8445
|
code: 500,
|
|
8362
8446
|
message: 'Order 模块未注册',
|
|
8363
8447
|
data: {
|
|
@@ -8387,7 +8471,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8387
8471
|
skip: result.skip,
|
|
8388
8472
|
rejected: result.rejected
|
|
8389
8473
|
});
|
|
8390
|
-
return
|
|
8474
|
+
return _context77.abrupt("return", {
|
|
8391
8475
|
code: 200,
|
|
8392
8476
|
data: result,
|
|
8393
8477
|
message: '',
|
|
@@ -8395,11 +8479,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
8395
8479
|
});
|
|
8396
8480
|
case 10:
|
|
8397
8481
|
case "end":
|
|
8398
|
-
return
|
|
8482
|
+
return _context77.stop();
|
|
8399
8483
|
}
|
|
8400
|
-
},
|
|
8484
|
+
}, _callee77, this);
|
|
8401
8485
|
}));
|
|
8402
|
-
function computeOrderQueryResult(
|
|
8486
|
+
function computeOrderQueryResult(_x87) {
|
|
8403
8487
|
return _computeOrderQueryResult.apply(this, arguments);
|
|
8404
8488
|
}
|
|
8405
8489
|
return computeOrderQueryResult;
|
|
@@ -8412,17 +8496,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
8412
8496
|
}, {
|
|
8413
8497
|
key: "computeBookingQueryResult",
|
|
8414
8498
|
value: (function () {
|
|
8415
|
-
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8499
|
+
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78(data) {
|
|
8416
8500
|
var rawOrders, result;
|
|
8417
|
-
return _regeneratorRuntime().wrap(function
|
|
8418
|
-
while (1) switch (
|
|
8501
|
+
return _regeneratorRuntime().wrap(function _callee78$(_context78) {
|
|
8502
|
+
while (1) switch (_context78.prev = _context78.next) {
|
|
8419
8503
|
case 0:
|
|
8420
8504
|
if (this.order) {
|
|
8421
|
-
|
|
8505
|
+
_context78.next = 3;
|
|
8422
8506
|
break;
|
|
8423
8507
|
}
|
|
8424
8508
|
this.logError('computeBookingQueryResult: Order 模块未注册');
|
|
8425
|
-
return
|
|
8509
|
+
return _context78.abrupt("return", {
|
|
8426
8510
|
code: 500,
|
|
8427
8511
|
message: 'Order 模块未注册',
|
|
8428
8512
|
data: {
|
|
@@ -8441,7 +8525,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8441
8525
|
size: result.size,
|
|
8442
8526
|
skip: result.skip
|
|
8443
8527
|
});
|
|
8444
|
-
return
|
|
8528
|
+
return _context78.abrupt("return", {
|
|
8445
8529
|
code: 200,
|
|
8446
8530
|
data: result,
|
|
8447
8531
|
message: '',
|
|
@@ -8449,11 +8533,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
8449
8533
|
});
|
|
8450
8534
|
case 8:
|
|
8451
8535
|
case "end":
|
|
8452
|
-
return
|
|
8536
|
+
return _context78.stop();
|
|
8453
8537
|
}
|
|
8454
|
-
},
|
|
8538
|
+
}, _callee78, this);
|
|
8455
8539
|
}));
|
|
8456
|
-
function computeBookingQueryResult(
|
|
8540
|
+
function computeBookingQueryResult(_x88) {
|
|
8457
8541
|
return _computeBookingQueryResult.apply(this, arguments);
|
|
8458
8542
|
}
|
|
8459
8543
|
return computeBookingQueryResult;
|
|
@@ -8512,12 +8596,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
8512
8596
|
}, {
|
|
8513
8597
|
key: "computeProductQueryResult",
|
|
8514
8598
|
value: (function () {
|
|
8515
|
-
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8599
|
+
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79(context, options) {
|
|
8516
8600
|
var _menu_list_ids$length3,
|
|
8517
8601
|
_this24 = this;
|
|
8518
8602
|
var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, startupPreloadTask, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, getActiveMenus, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
|
|
8519
|
-
return _regeneratorRuntime().wrap(function
|
|
8520
|
-
while (1) switch (
|
|
8603
|
+
return _regeneratorRuntime().wrap(function _callee79$(_context79) {
|
|
8604
|
+
while (1) switch (_context79.prev = _context79.next) {
|
|
8521
8605
|
case 0:
|
|
8522
8606
|
tTotal = performance.now();
|
|
8523
8607
|
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;
|
|
@@ -8543,10 +8627,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
8543
8627
|
// SQLite/IndexDB,造成 preload 读到空数据并重复请求。正常运行期该字段为 null,不增加等待。
|
|
8544
8628
|
startupPreloadTask = this.startupModulePreloadInFlight;
|
|
8545
8629
|
if (!startupPreloadTask) {
|
|
8546
|
-
|
|
8630
|
+
_context79.next = 8;
|
|
8547
8631
|
break;
|
|
8548
8632
|
}
|
|
8549
|
-
|
|
8633
|
+
_context79.next = 8;
|
|
8550
8634
|
return startupPreloadTask;
|
|
8551
8635
|
case 8:
|
|
8552
8636
|
// Menu/Schedule preload 会替换 store 中的数组;必须在等待完成后再读取,
|
|
@@ -8558,28 +8642,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
8558
8642
|
strategy_context: strategy_context
|
|
8559
8643
|
});
|
|
8560
8644
|
if (this.products) {
|
|
8561
|
-
|
|
8645
|
+
_context79.next = 12;
|
|
8562
8646
|
break;
|
|
8563
8647
|
}
|
|
8564
8648
|
this.logError('computeProductQueryResult: Products 模块未注册');
|
|
8565
|
-
return
|
|
8649
|
+
return _context79.abrupt("return", {
|
|
8566
8650
|
message: 'Products 模块未注册',
|
|
8567
8651
|
data: this.buildProductQueryResultPayload([], 0)
|
|
8568
8652
|
});
|
|
8569
8653
|
case 12:
|
|
8570
8654
|
if (!(queryIds.length > 0)) {
|
|
8571
|
-
|
|
8655
|
+
_context79.next = 24;
|
|
8572
8656
|
break;
|
|
8573
8657
|
}
|
|
8574
8658
|
uniqueIds = Array.from(new Set(queryIds));
|
|
8575
8659
|
_tPrice = performance.now();
|
|
8576
|
-
|
|
8660
|
+
_context79.next = 17;
|
|
8577
8661
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
8578
8662
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
8579
8663
|
productIds: uniqueIds
|
|
8580
8664
|
});
|
|
8581
8665
|
case 17:
|
|
8582
|
-
productsWithPrice =
|
|
8666
|
+
productsWithPrice = _context79.sent;
|
|
8583
8667
|
perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
|
|
8584
8668
|
count: productsWithPrice.length,
|
|
8585
8669
|
ids: uniqueIds
|
|
@@ -8599,7 +8683,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8599
8683
|
ids: uniqueIds,
|
|
8600
8684
|
count: extensionFilteredProducts.length
|
|
8601
8685
|
});
|
|
8602
|
-
return
|
|
8686
|
+
return _context79.abrupt("return", {
|
|
8603
8687
|
code: 200,
|
|
8604
8688
|
data: this.buildProductQueryResultPayload(extensionFilteredProducts),
|
|
8605
8689
|
message: '',
|
|
@@ -8607,17 +8691,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
8607
8691
|
});
|
|
8608
8692
|
case 24:
|
|
8609
8693
|
if (!(product_id != null && Number.isFinite(Number(product_id)))) {
|
|
8610
|
-
|
|
8694
|
+
_context79.next = 36;
|
|
8611
8695
|
break;
|
|
8612
8696
|
}
|
|
8613
8697
|
pid = Number(product_id);
|
|
8614
8698
|
_tPrice2 = performance.now();
|
|
8615
|
-
|
|
8699
|
+
_context79.next = 29;
|
|
8616
8700
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
8617
8701
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
8618
8702
|
});
|
|
8619
8703
|
case 29:
|
|
8620
|
-
allProductsWithPrice =
|
|
8704
|
+
allProductsWithPrice = _context79.sent;
|
|
8621
8705
|
perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
|
|
8622
8706
|
count: allProductsWithPrice.length,
|
|
8623
8707
|
productId: pid
|
|
@@ -8637,7 +8721,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8637
8721
|
productId: pid,
|
|
8638
8722
|
found: !!item
|
|
8639
8723
|
});
|
|
8640
|
-
return
|
|
8724
|
+
return _context79.abrupt("return", {
|
|
8641
8725
|
code: 200,
|
|
8642
8726
|
data: item,
|
|
8643
8727
|
message: item ? '' : '商品不存在或未发布',
|
|
@@ -8645,16 +8729,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
8645
8729
|
});
|
|
8646
8730
|
case 36:
|
|
8647
8731
|
if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
|
|
8648
|
-
|
|
8732
|
+
_context79.next = 56;
|
|
8649
8733
|
break;
|
|
8650
8734
|
}
|
|
8651
8735
|
_tPrice3 = performance.now();
|
|
8652
|
-
|
|
8736
|
+
_context79.next = 40;
|
|
8653
8737
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
8654
8738
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
8655
8739
|
});
|
|
8656
8740
|
case 40:
|
|
8657
|
-
_filteredProducts2 =
|
|
8741
|
+
_filteredProducts2 = _context79.sent;
|
|
8658
8742
|
perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
|
|
8659
8743
|
count: _filteredProducts2.length,
|
|
8660
8744
|
extension_type: extension_type
|
|
@@ -8693,7 +8777,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8693
8777
|
filteredCount: _filteredProducts2.length,
|
|
8694
8778
|
extension_type: extension_type
|
|
8695
8779
|
});
|
|
8696
|
-
return
|
|
8780
|
+
return _context79.abrupt("return", {
|
|
8697
8781
|
code: 200,
|
|
8698
8782
|
data: this.buildProductQueryResultPayload(_filteredProducts2),
|
|
8699
8783
|
message: '',
|
|
@@ -8701,28 +8785,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
8701
8785
|
});
|
|
8702
8786
|
case 56:
|
|
8703
8787
|
if (this.menu) {
|
|
8704
|
-
|
|
8788
|
+
_context79.next = 59;
|
|
8705
8789
|
break;
|
|
8706
8790
|
}
|
|
8707
8791
|
this.logError('computeProductQueryResult: Menu 模块未注册');
|
|
8708
|
-
return
|
|
8792
|
+
return _context79.abrupt("return", {
|
|
8709
8793
|
message: 'Menu 模块未注册',
|
|
8710
8794
|
data: this.buildProductQueryResultPayload([], 0)
|
|
8711
8795
|
});
|
|
8712
8796
|
case 59:
|
|
8713
8797
|
if (this.schedule) {
|
|
8714
|
-
|
|
8798
|
+
_context79.next = 62;
|
|
8715
8799
|
break;
|
|
8716
8800
|
}
|
|
8717
8801
|
this.logError('computeProductQueryResult: Schedule 模块未注册');
|
|
8718
|
-
return
|
|
8802
|
+
return _context79.abrupt("return", {
|
|
8719
8803
|
message: 'Schedule 模块未注册',
|
|
8720
8804
|
data: this.buildProductQueryResultPayload([], 0)
|
|
8721
8805
|
});
|
|
8722
8806
|
case 62:
|
|
8723
8807
|
activeMenuList = [];
|
|
8724
8808
|
if (!(menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0)) {
|
|
8725
|
-
|
|
8809
|
+
_context79.next = 75;
|
|
8726
8810
|
break;
|
|
8727
8811
|
}
|
|
8728
8812
|
tMenu = performance.now();
|
|
@@ -8733,18 +8817,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
8733
8817
|
});
|
|
8734
8818
|
};
|
|
8735
8819
|
activeMenuList = getActiveMenus();
|
|
8736
|
-
|
|
8737
|
-
if (!
|
|
8738
|
-
|
|
8820
|
+
_context79.t0 = !activeMenuList.length;
|
|
8821
|
+
if (!_context79.t0) {
|
|
8822
|
+
_context79.next = 72;
|
|
8739
8823
|
break;
|
|
8740
8824
|
}
|
|
8741
|
-
|
|
8825
|
+
_context79.next = 71;
|
|
8742
8826
|
return this.refreshMenuScheduleCacheAfterEmptyResult();
|
|
8743
8827
|
case 71:
|
|
8744
|
-
|
|
8828
|
+
_context79.t0 = _context79.sent;
|
|
8745
8829
|
case 72:
|
|
8746
|
-
if (!
|
|
8747
|
-
|
|
8830
|
+
if (!_context79.t0) {
|
|
8831
|
+
_context79.next = 74;
|
|
8748
8832
|
break;
|
|
8749
8833
|
}
|
|
8750
8834
|
activeMenuList = getActiveMenus();
|
|
@@ -8764,22 +8848,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
8764
8848
|
});
|
|
8765
8849
|
tPrice = performance.now();
|
|
8766
8850
|
if (!(scopedProductIds.length > 0)) {
|
|
8767
|
-
|
|
8851
|
+
_context79.next = 86;
|
|
8768
8852
|
break;
|
|
8769
8853
|
}
|
|
8770
|
-
|
|
8854
|
+
_context79.next = 83;
|
|
8771
8855
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
8772
8856
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
8773
8857
|
productIds: productScope.isAllProducts ? undefined : scopedProductIds
|
|
8774
8858
|
});
|
|
8775
8859
|
case 83:
|
|
8776
|
-
|
|
8777
|
-
|
|
8860
|
+
_context79.t1 = _context79.sent;
|
|
8861
|
+
_context79.next = 87;
|
|
8778
8862
|
break;
|
|
8779
8863
|
case 86:
|
|
8780
|
-
|
|
8864
|
+
_context79.t1 = [];
|
|
8781
8865
|
case 87:
|
|
8782
|
-
filteredProducts =
|
|
8866
|
+
filteredProducts = _context79.t1;
|
|
8783
8867
|
perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
|
|
8784
8868
|
count: filteredProducts.length,
|
|
8785
8869
|
scopedProductCount: scopedProductIds.length
|
|
@@ -8820,7 +8904,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8820
8904
|
filteredCount: filteredProducts.length,
|
|
8821
8905
|
activeMenuCount: activeMenuList.length
|
|
8822
8906
|
});
|
|
8823
|
-
return
|
|
8907
|
+
return _context79.abrupt("return", {
|
|
8824
8908
|
code: 200,
|
|
8825
8909
|
data: this.buildProductQueryResultPayload(filteredProducts),
|
|
8826
8910
|
message: '',
|
|
@@ -8828,11 +8912,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
8828
8912
|
});
|
|
8829
8913
|
case 103:
|
|
8830
8914
|
case "end":
|
|
8831
|
-
return
|
|
8915
|
+
return _context79.stop();
|
|
8832
8916
|
}
|
|
8833
|
-
},
|
|
8917
|
+
}, _callee79, this);
|
|
8834
8918
|
}));
|
|
8835
|
-
function computeProductQueryResult(
|
|
8919
|
+
function computeProductQueryResult(_x89, _x90) {
|
|
8836
8920
|
return _computeProductQueryResult.apply(this, arguments);
|
|
8837
8921
|
}
|
|
8838
8922
|
return computeProductQueryResult;
|
|
@@ -8870,72 +8954,72 @@ var Server = /*#__PURE__*/function () {
|
|
|
8870
8954
|
}, {
|
|
8871
8955
|
key: "recomputeAndNotifyProductQuery",
|
|
8872
8956
|
value: (function () {
|
|
8873
|
-
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8957
|
+
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80(options) {
|
|
8874
8958
|
var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
|
|
8875
|
-
return _regeneratorRuntime().wrap(function
|
|
8876
|
-
while (1) switch (
|
|
8959
|
+
return _regeneratorRuntime().wrap(function _callee80$(_context80) {
|
|
8960
|
+
while (1) switch (_context80.prev = _context80.next) {
|
|
8877
8961
|
case 0:
|
|
8878
8962
|
if (!(this.productQuerySubscribers.size === 0)) {
|
|
8879
|
-
|
|
8963
|
+
_context80.next = 2;
|
|
8880
8964
|
break;
|
|
8881
8965
|
}
|
|
8882
|
-
return
|
|
8966
|
+
return _context80.abrupt("return");
|
|
8883
8967
|
case 2:
|
|
8884
8968
|
this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
|
|
8885
8969
|
subscriberCount: this.productQuerySubscribers.size,
|
|
8886
8970
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
8887
8971
|
});
|
|
8888
8972
|
_iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
|
|
8889
|
-
|
|
8973
|
+
_context80.prev = 4;
|
|
8890
8974
|
_iterator18.s();
|
|
8891
8975
|
case 6:
|
|
8892
8976
|
if ((_step18 = _iterator18.n()).done) {
|
|
8893
|
-
|
|
8977
|
+
_context80.next = 22;
|
|
8894
8978
|
break;
|
|
8895
8979
|
}
|
|
8896
8980
|
_step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
|
|
8897
|
-
|
|
8898
|
-
|
|
8981
|
+
_context80.prev = 8;
|
|
8982
|
+
_context80.next = 11;
|
|
8899
8983
|
return this.computeProductQueryResult(subscriber.context, {
|
|
8900
8984
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
8901
8985
|
});
|
|
8902
8986
|
case 11:
|
|
8903
|
-
result =
|
|
8987
|
+
result = _context80.sent;
|
|
8904
8988
|
subscriber.callback(result);
|
|
8905
8989
|
this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
|
|
8906
8990
|
subscriberId: subscriberId
|
|
8907
8991
|
});
|
|
8908
|
-
|
|
8992
|
+
_context80.next = 20;
|
|
8909
8993
|
break;
|
|
8910
8994
|
case 16:
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
errorMessage =
|
|
8995
|
+
_context80.prev = 16;
|
|
8996
|
+
_context80.t0 = _context80["catch"](8);
|
|
8997
|
+
errorMessage = _context80.t0 instanceof Error ? _context80.t0.message : String(_context80.t0);
|
|
8914
8998
|
this.logError('recomputeAndNotifyProductQuery: 推送失败', {
|
|
8915
8999
|
subscriberId: subscriberId,
|
|
8916
9000
|
error: errorMessage
|
|
8917
9001
|
});
|
|
8918
9002
|
case 20:
|
|
8919
|
-
|
|
9003
|
+
_context80.next = 6;
|
|
8920
9004
|
break;
|
|
8921
9005
|
case 22:
|
|
8922
|
-
|
|
9006
|
+
_context80.next = 27;
|
|
8923
9007
|
break;
|
|
8924
9008
|
case 24:
|
|
8925
|
-
|
|
8926
|
-
|
|
8927
|
-
_iterator18.e(
|
|
9009
|
+
_context80.prev = 24;
|
|
9010
|
+
_context80.t1 = _context80["catch"](4);
|
|
9011
|
+
_iterator18.e(_context80.t1);
|
|
8928
9012
|
case 27:
|
|
8929
|
-
|
|
9013
|
+
_context80.prev = 27;
|
|
8930
9014
|
_iterator18.f();
|
|
8931
|
-
return
|
|
9015
|
+
return _context80.finish(27);
|
|
8932
9016
|
case 30:
|
|
8933
9017
|
case "end":
|
|
8934
|
-
return
|
|
9018
|
+
return _context80.stop();
|
|
8935
9019
|
}
|
|
8936
|
-
},
|
|
9020
|
+
}, _callee80, this, [[4, 24, 27, 30], [8, 16]]);
|
|
8937
9021
|
}));
|
|
8938
|
-
function recomputeAndNotifyProductQuery(
|
|
9022
|
+
function recomputeAndNotifyProductQuery(_x91) {
|
|
8939
9023
|
return _recomputeAndNotifyProductQuery.apply(this, arguments);
|
|
8940
9024
|
}
|
|
8941
9025
|
return recomputeAndNotifyProductQuery;
|
|
@@ -8947,16 +9031,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
8947
9031
|
}, {
|
|
8948
9032
|
key: "recomputeAndNotifyOrderQuery",
|
|
8949
9033
|
value: (function () {
|
|
8950
|
-
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9034
|
+
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee81() {
|
|
8951
9035
|
var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
|
|
8952
|
-
return _regeneratorRuntime().wrap(function
|
|
8953
|
-
while (1) switch (
|
|
9036
|
+
return _regeneratorRuntime().wrap(function _callee81$(_context81) {
|
|
9037
|
+
while (1) switch (_context81.prev = _context81.next) {
|
|
8954
9038
|
case 0:
|
|
8955
9039
|
if (!(this.orderQuerySubscribers.size === 0)) {
|
|
8956
|
-
|
|
9040
|
+
_context81.next = 2;
|
|
8957
9041
|
break;
|
|
8958
9042
|
}
|
|
8959
|
-
return
|
|
9043
|
+
return _context81.abrupt("return");
|
|
8960
9044
|
case 2:
|
|
8961
9045
|
notifyStartAt = Date.now();
|
|
8962
9046
|
this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
|
|
@@ -8964,20 +9048,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
8964
9048
|
notifyStartAt: new Date(notifyStartAt).toISOString()
|
|
8965
9049
|
});
|
|
8966
9050
|
_iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
|
|
8967
|
-
|
|
9051
|
+
_context81.prev = 5;
|
|
8968
9052
|
_iterator19.s();
|
|
8969
9053
|
case 7:
|
|
8970
9054
|
if ((_step19 = _iterator19.n()).done) {
|
|
8971
|
-
|
|
9055
|
+
_context81.next = 27;
|
|
8972
9056
|
break;
|
|
8973
9057
|
}
|
|
8974
9058
|
_step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
|
|
8975
|
-
|
|
9059
|
+
_context81.prev = 9;
|
|
8976
9060
|
computeStartAt = Date.now();
|
|
8977
|
-
|
|
9061
|
+
_context81.next = 13;
|
|
8978
9062
|
return this.computeOrderQueryResult(subscriber.context);
|
|
8979
9063
|
case 13:
|
|
8980
|
-
result =
|
|
9064
|
+
result = _context81.sent;
|
|
8981
9065
|
computeEndAt = Date.now();
|
|
8982
9066
|
callbackStartAt = Date.now();
|
|
8983
9067
|
subscriber.callback(result);
|
|
@@ -8988,30 +9072,30 @@ var Server = /*#__PURE__*/function () {
|
|
|
8988
9072
|
callbackDurationMs: callbackEndAt - callbackStartAt,
|
|
8989
9073
|
totalDurationMs: callbackEndAt - computeStartAt
|
|
8990
9074
|
});
|
|
8991
|
-
|
|
9075
|
+
_context81.next = 25;
|
|
8992
9076
|
break;
|
|
8993
9077
|
case 21:
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
errorMessage =
|
|
9078
|
+
_context81.prev = 21;
|
|
9079
|
+
_context81.t0 = _context81["catch"](9);
|
|
9080
|
+
errorMessage = _context81.t0 instanceof Error ? _context81.t0.message : String(_context81.t0);
|
|
8997
9081
|
this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
|
|
8998
9082
|
subscriberId: subscriberId,
|
|
8999
9083
|
error: errorMessage
|
|
9000
9084
|
});
|
|
9001
9085
|
case 25:
|
|
9002
|
-
|
|
9086
|
+
_context81.next = 7;
|
|
9003
9087
|
break;
|
|
9004
9088
|
case 27:
|
|
9005
|
-
|
|
9089
|
+
_context81.next = 32;
|
|
9006
9090
|
break;
|
|
9007
9091
|
case 29:
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
_iterator19.e(
|
|
9092
|
+
_context81.prev = 29;
|
|
9093
|
+
_context81.t1 = _context81["catch"](5);
|
|
9094
|
+
_iterator19.e(_context81.t1);
|
|
9011
9095
|
case 32:
|
|
9012
|
-
|
|
9096
|
+
_context81.prev = 32;
|
|
9013
9097
|
_iterator19.f();
|
|
9014
|
-
return
|
|
9098
|
+
return _context81.finish(32);
|
|
9015
9099
|
case 35:
|
|
9016
9100
|
notifyEndAt = Date.now();
|
|
9017
9101
|
this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
|
|
@@ -9020,9 +9104,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
9020
9104
|
});
|
|
9021
9105
|
case 37:
|
|
9022
9106
|
case "end":
|
|
9023
|
-
return
|
|
9107
|
+
return _context81.stop();
|
|
9024
9108
|
}
|
|
9025
|
-
},
|
|
9109
|
+
}, _callee81, this, [[5, 29, 32, 35], [9, 21]]);
|
|
9026
9110
|
}));
|
|
9027
9111
|
function recomputeAndNotifyOrderQuery() {
|
|
9028
9112
|
return _recomputeAndNotifyOrderQuery.apply(this, arguments);
|
|
@@ -9163,67 +9247,67 @@ var Server = /*#__PURE__*/function () {
|
|
|
9163
9247
|
}, {
|
|
9164
9248
|
key: "recomputeAndNotifyBookingQuery",
|
|
9165
9249
|
value: (function () {
|
|
9166
|
-
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9250
|
+
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82() {
|
|
9167
9251
|
var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
|
|
9168
|
-
return _regeneratorRuntime().wrap(function
|
|
9169
|
-
while (1) switch (
|
|
9252
|
+
return _regeneratorRuntime().wrap(function _callee82$(_context82) {
|
|
9253
|
+
while (1) switch (_context82.prev = _context82.next) {
|
|
9170
9254
|
case 0:
|
|
9171
9255
|
if (!(this.bookingQuerySubscribers.size === 0)) {
|
|
9172
|
-
|
|
9256
|
+
_context82.next = 2;
|
|
9173
9257
|
break;
|
|
9174
9258
|
}
|
|
9175
|
-
return
|
|
9259
|
+
return _context82.abrupt("return");
|
|
9176
9260
|
case 2:
|
|
9177
9261
|
this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
|
|
9178
9262
|
subscriberCount: this.bookingQuerySubscribers.size
|
|
9179
9263
|
});
|
|
9180
9264
|
_iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
|
|
9181
|
-
|
|
9265
|
+
_context82.prev = 4;
|
|
9182
9266
|
_iterator21.s();
|
|
9183
9267
|
case 6:
|
|
9184
9268
|
if ((_step21 = _iterator21.n()).done) {
|
|
9185
|
-
|
|
9269
|
+
_context82.next = 22;
|
|
9186
9270
|
break;
|
|
9187
9271
|
}
|
|
9188
9272
|
_step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
|
|
9189
|
-
|
|
9190
|
-
|
|
9273
|
+
_context82.prev = 8;
|
|
9274
|
+
_context82.next = 11;
|
|
9191
9275
|
return this.computeBookingQueryResult(subscriber.context);
|
|
9192
9276
|
case 11:
|
|
9193
|
-
result =
|
|
9277
|
+
result = _context82.sent;
|
|
9194
9278
|
subscriber.callback(result);
|
|
9195
9279
|
this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
|
|
9196
9280
|
subscriberId: subscriberId
|
|
9197
9281
|
});
|
|
9198
|
-
|
|
9282
|
+
_context82.next = 20;
|
|
9199
9283
|
break;
|
|
9200
9284
|
case 16:
|
|
9201
|
-
|
|
9202
|
-
|
|
9203
|
-
errorMessage =
|
|
9285
|
+
_context82.prev = 16;
|
|
9286
|
+
_context82.t0 = _context82["catch"](8);
|
|
9287
|
+
errorMessage = _context82.t0 instanceof Error ? _context82.t0.message : String(_context82.t0);
|
|
9204
9288
|
this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
|
|
9205
9289
|
subscriberId: subscriberId,
|
|
9206
9290
|
error: errorMessage
|
|
9207
9291
|
});
|
|
9208
9292
|
case 20:
|
|
9209
|
-
|
|
9293
|
+
_context82.next = 6;
|
|
9210
9294
|
break;
|
|
9211
9295
|
case 22:
|
|
9212
|
-
|
|
9296
|
+
_context82.next = 27;
|
|
9213
9297
|
break;
|
|
9214
9298
|
case 24:
|
|
9215
|
-
|
|
9216
|
-
|
|
9217
|
-
_iterator21.e(
|
|
9299
|
+
_context82.prev = 24;
|
|
9300
|
+
_context82.t1 = _context82["catch"](4);
|
|
9301
|
+
_iterator21.e(_context82.t1);
|
|
9218
9302
|
case 27:
|
|
9219
|
-
|
|
9303
|
+
_context82.prev = 27;
|
|
9220
9304
|
_iterator21.f();
|
|
9221
|
-
return
|
|
9305
|
+
return _context82.finish(27);
|
|
9222
9306
|
case 30:
|
|
9223
9307
|
case "end":
|
|
9224
|
-
return
|
|
9308
|
+
return _context82.stop();
|
|
9225
9309
|
}
|
|
9226
|
-
},
|
|
9310
|
+
}, _callee82, this, [[4, 24, 27, 30], [8, 16]]);
|
|
9227
9311
|
}));
|
|
9228
9312
|
function recomputeAndNotifyBookingQuery() {
|
|
9229
9313
|
return _recomputeAndNotifyBookingQuery.apply(this, arguments);
|