@pisell/pisellos 2.3.51 → 2.3.53
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/BookingContext/utils/buildCacheItemFromOrderLine.js +12 -10
- package/dist/modules/Discount/index.d.ts +0 -1
- package/dist/modules/Discount/index.js +11 -40
- package/dist/modules/Discount/types.d.ts +0 -1
- package/dist/modules/OpenData/index.js +2 -2
- package/dist/modules/Order/index.d.ts +7 -9
- package/dist/modules/Order/index.js +165 -140
- package/dist/modules/Order/types.d.ts +21 -12
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Order/utils.d.ts +0 -10
- package/dist/modules/Order/utils.js +3 -35
- package/dist/modules/Product/types.d.ts +0 -1
- package/dist/modules/ProductList/index.js +14 -33
- package/dist/modules/Quotation/index.d.ts +1 -1
- package/dist/modules/Quotation/index.js +2 -2
- package/dist/modules/Rules/index.js +32 -56
- package/dist/modules/SalesSummary/index.js +13 -12
- package/dist/modules/SalesSummary/utils.js +7 -1
- package/dist/modules/ScanOrderLogger/index.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/index.js +2 -15
- package/dist/modules/ScanOrderLogger/providers/feishu.js +27 -45
- package/dist/modules/ScanOrderLogger/types.d.ts +0 -1
- package/dist/modules/Schedule/index.d.ts +1 -3
- package/dist/modules/Schedule/index.js +16 -21
- package/dist/modules/Summary/utils.js +13 -38
- package/dist/modules/index.d.ts +0 -2
- package/dist/modules/index.js +1 -3
- package/dist/plugins/window.d.ts +0 -1
- package/dist/server/index.d.ts +0 -14
- package/dist/server/index.js +793 -907
- package/dist/solution/BaseSales/index.d.ts +15 -12
- package/dist/solution/BaseSales/index.js +194 -178
- package/dist/solution/BaseSales/utils/cartPromotion.js +5 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -16
- package/dist/solution/BookingByStep/index.js +215 -294
- package/dist/solution/BookingByStep/types.d.ts +1 -2
- package/dist/solution/BookingByStep/types.js +1 -3
- package/dist/solution/BookingByStep/utils/capacity.js +1 -17
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
- package/dist/solution/BookingTicket/index.d.ts +2 -14
- package/dist/solution/BookingTicket/index.js +2 -2
- package/dist/solution/BookingTicket/types.d.ts +3 -0
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -3
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -10
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +16 -2
- package/dist/solution/ScanOrder/index.d.ts +14 -26
- package/dist/solution/ScanOrder/index.js +739 -1142
- package/dist/solution/ScanOrder/types.d.ts +1 -21
- package/dist/solution/ScanOrder/utils.d.ts +0 -8
- package/dist/solution/ScanOrder/utils.js +25 -66
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +87 -125
- package/dist/solution/VenueBooking/index.d.ts +11 -39
- package/dist/solution/VenueBooking/index.js +841 -1167
- package/dist/solution/VenueBooking/types.d.ts +0 -3
- package/dist/solution/VenueBooking/utils/resource.js +0 -1
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +5 -10
- package/dist/solution/index.d.ts +0 -1
- package/dist/solution/index.js +1 -2
- package/dist/types/index.d.ts +0 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -1
- package/lib/modules/Discount/index.d.ts +0 -1
- package/lib/modules/Discount/index.js +0 -9
- package/lib/modules/Discount/types.d.ts +0 -1
- package/lib/modules/OpenData/index.js +1 -1
- package/lib/modules/Order/index.d.ts +7 -9
- package/lib/modules/Order/index.js +89 -38
- package/lib/modules/Order/types.d.ts +21 -12
- package/lib/modules/Order/utils.d.ts +0 -10
- package/lib/modules/Order/utils.js +5 -36
- package/lib/modules/Product/types.d.ts +0 -1
- package/lib/modules/ProductList/index.js +31 -40
- package/lib/modules/Quotation/index.d.ts +1 -1
- package/lib/modules/Quotation/index.js +2 -2
- package/lib/modules/Rules/index.js +32 -44
- package/lib/modules/SalesSummary/index.js +7 -6
- package/lib/modules/SalesSummary/utils.js +5 -1
- package/lib/modules/ScanOrderLogger/index.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/index.js +1 -13
- package/lib/modules/ScanOrderLogger/providers/feishu.js +6 -15
- package/lib/modules/ScanOrderLogger/types.d.ts +0 -1
- package/lib/modules/Schedule/index.d.ts +1 -3
- package/lib/modules/Schedule/index.js +8 -10
- package/lib/modules/Summary/utils.js +1 -21
- package/lib/modules/index.d.ts +0 -2
- package/lib/modules/index.js +1 -5
- package/lib/plugins/window.d.ts +0 -1
- package/lib/server/index.d.ts +0 -14
- package/lib/server/index.js +15 -72
- package/lib/solution/BaseSales/index.d.ts +15 -12
- package/lib/solution/BaseSales/index.js +52 -35
- package/lib/solution/BaseSales/utils/cartPromotion.js +5 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -16
- package/lib/solution/BookingByStep/index.js +18 -60
- package/lib/solution/BookingByStep/types.d.ts +1 -2
- package/lib/solution/BookingByStep/types.js +0 -5
- package/lib/solution/BookingByStep/utils/capacity.js +1 -20
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
- package/lib/solution/BookingTicket/index.d.ts +2 -14
- package/lib/solution/BookingTicket/index.js +2 -10
- package/lib/solution/BookingTicket/types.d.ts +3 -0
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -3
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +15 -3
- package/lib/solution/ScanOrder/index.d.ts +14 -26
- package/lib/solution/ScanOrder/index.js +182 -449
- package/lib/solution/ScanOrder/types.d.ts +1 -21
- package/lib/solution/ScanOrder/utils.d.ts +0 -8
- package/lib/solution/ScanOrder/utils.js +0 -31
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +0 -14
- package/lib/solution/VenueBooking/index.d.ts +11 -39
- package/lib/solution/VenueBooking/index.js +110 -322
- package/lib/solution/VenueBooking/types.d.ts +0 -3
- package/lib/solution/VenueBooking/utils/resource.js +0 -1
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +4 -6
- package/lib/solution/index.d.ts +0 -1
- package/lib/solution/index.js +1 -3
- package/lib/types/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/modules/Holder/index.d.ts +0 -48
- package/dist/modules/Holder/index.js +0 -640
- package/dist/modules/Holder/types.d.ts +0 -123
- package/dist/modules/Holder/types.js +0 -1
- package/dist/modules/Holder/utils.d.ts +0 -13
- package/dist/modules/Holder/utils.js +0 -34
- package/dist/modules/ResourcePlanner/index.d.ts +0 -24
- package/dist/modules/ResourcePlanner/index.js +0 -181
- package/dist/modules/ResourcePlanner/planner.d.ts +0 -14
- package/dist/modules/ResourcePlanner/planner.js +0 -1069
- package/dist/modules/ResourcePlanner/types.d.ts +0 -227
- package/dist/modules/ResourcePlanner/types.js +0 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +0 -183
- package/dist/solution/UnifiedBookingSales/index.js +0 -1891
- package/dist/solution/UnifiedBookingSales/types.d.ts +0 -143
- package/dist/solution/UnifiedBookingSales/types.js +0 -11
- package/lib/modules/Holder/index.d.ts +0 -48
- package/lib/modules/Holder/index.js +0 -402
- package/lib/modules/Holder/types.d.ts +0 -123
- package/lib/modules/Holder/types.js +0 -17
- package/lib/modules/Holder/utils.d.ts +0 -13
- package/lib/modules/Holder/utils.js +0 -71
- package/lib/modules/ResourcePlanner/index.d.ts +0 -24
- package/lib/modules/ResourcePlanner/index.js +0 -148
- package/lib/modules/ResourcePlanner/planner.d.ts +0 -14
- package/lib/modules/ResourcePlanner/planner.js +0 -933
- package/lib/modules/ResourcePlanner/types.d.ts +0 -227
- package/lib/modules/ResourcePlanner/types.js +0 -17
- package/lib/solution/UnifiedBookingSales/index.d.ts +0 -183
- package/lib/solution/UnifiedBookingSales/index.js +0 -1084
- package/lib/solution/UnifiedBookingSales/types.d.ts +0 -143
- package/lib/solution/UnifiedBookingSales/types.js +0 -33
package/dist/server/index.js
CHANGED
|
@@ -99,10 +99,6 @@ var Server = /*#__PURE__*/function () {
|
|
|
99
99
|
_defineProperty(this, "productQuerySubscribers", new Map());
|
|
100
100
|
/** subscriberId → 智能定价变价时间点定时器句柄(与 subscriber 分离存储,便于 clear) */
|
|
101
101
|
_defineProperty(this, "productQueryScheduleTimers", new Map());
|
|
102
|
-
/** 餐牌筛选为空时才触发的菜单/日程缓存自愈,避免每次商品查询都请求远端。 */
|
|
103
|
-
_defineProperty(this, "menuScheduleRefreshInFlight", null);
|
|
104
|
-
_defineProperty(this, "lastMenuScheduleRefreshAt", 0);
|
|
105
|
-
_defineProperty(this, "MENU_SCHEDULE_REFRESH_COOLDOWN_MS", 30 * 1000);
|
|
106
102
|
// ---- 订单 / 预约列表查询订阅者 ----
|
|
107
103
|
_defineProperty(this, "orderQuerySubscribers", new Map());
|
|
108
104
|
_defineProperty(this, "bookingQuerySubscribers", new Map());
|
|
@@ -282,17 +278,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
282
278
|
*/
|
|
283
279
|
_defineProperty(this, "handleProductQuery", /*#__PURE__*/function () {
|
|
284
280
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref5) {
|
|
285
|
-
var url, method, data, config, menu_list_ids, customer_id, ids, extension_type, strategy_context,
|
|
281
|
+
var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, extension_type, strategy_context, _ref7, callback, subscriberId, result;
|
|
286
282
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
287
283
|
while (1) switch (_context3.prev = _context3.next) {
|
|
288
284
|
case 0:
|
|
289
285
|
url = _ref5.url, method = _ref5.method, data = _ref5.data, config = _ref5.config;
|
|
290
286
|
console.log('[Server] handleProductQuery:', url, method, data, config);
|
|
291
|
-
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;
|
|
292
|
-
_this$resolveProductQ = _this.resolveProductQueryScheduleContext({
|
|
293
|
-
schedule_date: data.schedule_date,
|
|
294
|
-
schedule_datetime: data.schedule_datetime
|
|
295
|
-
}), schedule_date = _this$resolveProductQ.schedule_date, schedule_datetime = _this$resolveProductQ.schedule_datetime;
|
|
287
|
+
menu_list_ids = data.menu_list_ids, schedule_datetime = data.schedule_datetime, schedule_date = data.schedule_date, customer_id = data.customer_id, ids = data.ids, extension_type = data.extension_type, strategy_context = data.strategy_context;
|
|
296
288
|
_ref7 = config || {}, callback = _ref7.callback, subscriberId = _ref7.subscriberId;
|
|
297
289
|
_this.logInfo('handleProductQuery: 开始处理商品查询请求', {
|
|
298
290
|
menu_list_ids: menu_list_ids,
|
|
@@ -323,7 +315,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
323
315
|
totalSubscribers: _this.productQuerySubscribers.size
|
|
324
316
|
});
|
|
325
317
|
}
|
|
326
|
-
_context3.next =
|
|
318
|
+
_context3.next = 8;
|
|
327
319
|
return _this.computeProductQueryResult({
|
|
328
320
|
menu_list_ids: menu_list_ids,
|
|
329
321
|
ids: ids,
|
|
@@ -333,13 +325,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
333
325
|
extension_type: extension_type,
|
|
334
326
|
strategy_context: strategy_context
|
|
335
327
|
});
|
|
336
|
-
case
|
|
328
|
+
case 8:
|
|
337
329
|
result = _context3.sent;
|
|
338
330
|
if (subscriberId && typeof callback === 'function') {
|
|
339
331
|
_this.syncProductQueryScheduleTimers(subscriberId, strategy_context);
|
|
340
332
|
}
|
|
341
333
|
return _context3.abrupt("return", result);
|
|
342
|
-
case
|
|
334
|
+
case 11:
|
|
343
335
|
case "end":
|
|
344
336
|
return _context3.stop();
|
|
345
337
|
}
|
|
@@ -3514,25 +3506,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
3514
3506
|
if (!subscriber || !timePoints.length) return;
|
|
3515
3507
|
var scheduleDate = subscriber.context.schedule_date || dayjs().format('YYYY-MM-DD');
|
|
3516
3508
|
var timerIds = [];
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
var currentTime = dayjs().format('hh:mm');
|
|
3532
|
-
if (timePoints.includes(currentTime)) {
|
|
3533
|
-
_this7.onScheduleTimePointTimerFire(subscriberId);
|
|
3509
|
+
var _iterator5 = _createForOfIteratorHelper(timePoints),
|
|
3510
|
+
_step5;
|
|
3511
|
+
try {
|
|
3512
|
+
var _loop = function _loop() {
|
|
3513
|
+
var timePoint = _step5.value;
|
|
3514
|
+
var delayMs = _this7.computeScheduleTimePointDelayMs(scheduleDate, timePoint);
|
|
3515
|
+
if (delayMs < 0) return 1; // continue
|
|
3516
|
+
var timerId = setTimeout(function () {
|
|
3517
|
+
void _this7.onScheduleTimePointTimerFire(subscriberId, timerId);
|
|
3518
|
+
}, delayMs);
|
|
3519
|
+
timerIds.push(timerId);
|
|
3520
|
+
};
|
|
3521
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
3522
|
+
if (_loop()) continue;
|
|
3534
3523
|
}
|
|
3535
|
-
}
|
|
3524
|
+
} catch (err) {
|
|
3525
|
+
_iterator5.e(err);
|
|
3526
|
+
} finally {
|
|
3527
|
+
_iterator5.f();
|
|
3528
|
+
}
|
|
3536
3529
|
if (timerIds.length > 0) {
|
|
3537
3530
|
this.productQueryScheduleTimers.set(subscriberId, timerIds);
|
|
3538
3531
|
subscriber.scheduleTimerIds = timerIds;
|
|
@@ -3555,7 +3548,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3555
3548
|
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3556
3549
|
while (1) switch (_context41.prev = _context41.next) {
|
|
3557
3550
|
case 0:
|
|
3558
|
-
|
|
3551
|
+
this.removeScheduleTimerRef(subscriberId, timerId);
|
|
3559
3552
|
if (this.productQuerySubscribers.has(subscriberId)) {
|
|
3560
3553
|
_context41.next = 3;
|
|
3561
3554
|
break;
|
|
@@ -3644,76 +3637,6 @@ var Server = /*#__PURE__*/function () {
|
|
|
3644
3637
|
this.scheduleSubscriberTimePointReloads(subscriberId, timePoints);
|
|
3645
3638
|
}
|
|
3646
3639
|
}
|
|
3647
|
-
}, {
|
|
3648
|
-
key: "resolveProductQueryScheduleContext",
|
|
3649
|
-
value:
|
|
3650
|
-
/**
|
|
3651
|
-
* ProductList callers such as standalone retail pages do not always have a selected schedule.
|
|
3652
|
-
* In that case query against the current local time so menu availability can still be evaluated.
|
|
3653
|
-
*/
|
|
3654
|
-
function resolveProductQueryScheduleContext(params) {
|
|
3655
|
-
var now = dayjs();
|
|
3656
|
-
var schedule_datetime = typeof params.schedule_datetime === 'string' && params.schedule_datetime.trim() ? params.schedule_datetime : now.format('YYYY-MM-DD HH:mm:ss');
|
|
3657
|
-
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');
|
|
3658
|
-
return {
|
|
3659
|
-
schedule_date: schedule_date,
|
|
3660
|
-
schedule_datetime: schedule_datetime
|
|
3661
|
-
};
|
|
3662
|
-
}
|
|
3663
|
-
|
|
3664
|
-
/**
|
|
3665
|
-
* OpenData 的关联餐牌可能已更新,而 server_menu/server_schedule 仍命中本地持久化缓存。
|
|
3666
|
-
* 仅在当前筛选没有任何生效餐牌时刷新一次,并由调用方重新计算筛选结果。
|
|
3667
|
-
*/
|
|
3668
|
-
}, {
|
|
3669
|
-
key: "refreshMenuScheduleCacheAfterEmptyResult",
|
|
3670
|
-
value: (function () {
|
|
3671
|
-
var _refreshMenuScheduleCacheAfterEmptyResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
|
|
3672
|
-
var _this8 = this;
|
|
3673
|
-
var now;
|
|
3674
|
-
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3675
|
-
while (1) switch (_context43.prev = _context43.next) {
|
|
3676
|
-
case 0:
|
|
3677
|
-
if (!(!this.menu || !this.schedule)) {
|
|
3678
|
-
_context43.next = 2;
|
|
3679
|
-
break;
|
|
3680
|
-
}
|
|
3681
|
-
return _context43.abrupt("return", false);
|
|
3682
|
-
case 2:
|
|
3683
|
-
now = Date.now();
|
|
3684
|
-
if (!(now - this.lastMenuScheduleRefreshAt < this.MENU_SCHEDULE_REFRESH_COOLDOWN_MS)) {
|
|
3685
|
-
_context43.next = 5;
|
|
3686
|
-
break;
|
|
3687
|
-
}
|
|
3688
|
-
return _context43.abrupt("return", false);
|
|
3689
|
-
case 5:
|
|
3690
|
-
if (!this.menuScheduleRefreshInFlight) {
|
|
3691
|
-
this.lastMenuScheduleRefreshAt = now;
|
|
3692
|
-
this.menuScheduleRefreshInFlight = Promise.all([this.menu.loadMenuList(), this.schedule.loadAllSchedule()]).then(function () {
|
|
3693
|
-
return undefined;
|
|
3694
|
-
}).catch(function (error) {
|
|
3695
|
-
_this8.logWarning('刷新菜单/日程缓存失败,继续使用现有缓存', {
|
|
3696
|
-
error: error instanceof Error ? error.message : String(error)
|
|
3697
|
-
});
|
|
3698
|
-
}).finally(function () {
|
|
3699
|
-
_this8.menuScheduleRefreshInFlight = null;
|
|
3700
|
-
});
|
|
3701
|
-
}
|
|
3702
|
-
_context43.next = 8;
|
|
3703
|
-
return this.menuScheduleRefreshInFlight;
|
|
3704
|
-
case 8:
|
|
3705
|
-
return _context43.abrupt("return", true);
|
|
3706
|
-
case 9:
|
|
3707
|
-
case "end":
|
|
3708
|
-
return _context43.stop();
|
|
3709
|
-
}
|
|
3710
|
-
}, _callee43, this);
|
|
3711
|
-
}));
|
|
3712
|
-
function refreshMenuScheduleCacheAfterEmptyResult() {
|
|
3713
|
-
return _refreshMenuScheduleCacheAfterEmptyResult.apply(this, arguments);
|
|
3714
|
-
}
|
|
3715
|
-
return refreshMenuScheduleCacheAfterEmptyResult;
|
|
3716
|
-
}())
|
|
3717
3640
|
}, {
|
|
3718
3641
|
key: "handleSalesSearchRequest",
|
|
3719
3642
|
value: (
|
|
@@ -3725,32 +3648,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
3725
3648
|
* const result = await this.handleSalesSearchRequest('single', '/shop/es/search/sales', { keyword: '1001' }, {})
|
|
3726
3649
|
*/
|
|
3727
3650
|
function () {
|
|
3728
|
-
var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3729
|
-
var queryPayload, result, _ref61, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds,
|
|
3730
|
-
return _regeneratorRuntime().wrap(function
|
|
3731
|
-
while (1) switch (
|
|
3651
|
+
var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(kind, backendPath, data, config) {
|
|
3652
|
+
var queryPayload, result, _ref61, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator6, _step6, orderId;
|
|
3653
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3654
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
3732
3655
|
case 0:
|
|
3733
3656
|
queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
|
|
3734
|
-
|
|
3657
|
+
_context43.next = 3;
|
|
3735
3658
|
return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
|
|
3736
3659
|
case 3:
|
|
3737
|
-
result =
|
|
3660
|
+
result = _context43.sent;
|
|
3738
3661
|
_ref61 = config || {}, callback = _ref61.callback, subscriberId = _ref61.subscriberId, resetVisibleOrderIds = _ref61.resetVisibleOrderIds;
|
|
3739
3662
|
if (subscriberId && typeof callback === 'function') {
|
|
3740
3663
|
contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
|
|
3741
3664
|
existing = this.salesSearchSubscribers.get(subscriberId);
|
|
3742
3665
|
shouldReset = resetVisibleOrderIds === true || !existing || existing.kind !== kind || existing.contextSignature !== contextSignature;
|
|
3743
3666
|
visibleOrderIds = shouldReset ? new Set() : new Set(existing.visibleOrderIds);
|
|
3744
|
-
|
|
3667
|
+
_iterator6 = _createForOfIteratorHelper(this.extractSalesSearchOrderIds(kind, result));
|
|
3745
3668
|
try {
|
|
3746
|
-
for (
|
|
3747
|
-
orderId =
|
|
3669
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
3670
|
+
orderId = _step6.value;
|
|
3748
3671
|
visibleOrderIds.add(orderId);
|
|
3749
3672
|
}
|
|
3750
3673
|
} catch (err) {
|
|
3751
|
-
|
|
3674
|
+
_iterator6.e(err);
|
|
3752
3675
|
} finally {
|
|
3753
|
-
|
|
3676
|
+
_iterator6.f();
|
|
3754
3677
|
}
|
|
3755
3678
|
this.salesSearchSubscribers.set(subscriberId, {
|
|
3756
3679
|
callback: callback,
|
|
@@ -3766,12 +3689,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
3766
3689
|
visibleCount: visibleOrderIds.size
|
|
3767
3690
|
});
|
|
3768
3691
|
}
|
|
3769
|
-
return
|
|
3692
|
+
return _context43.abrupt("return", result);
|
|
3770
3693
|
case 7:
|
|
3771
3694
|
case "end":
|
|
3772
|
-
return
|
|
3695
|
+
return _context43.stop();
|
|
3773
3696
|
}
|
|
3774
|
-
},
|
|
3697
|
+
}, _callee43, this);
|
|
3775
3698
|
}));
|
|
3776
3699
|
function handleSalesSearchRequest(_x43, _x44, _x45, _x46) {
|
|
3777
3700
|
return _handleSalesSearchRequest.apply(this, arguments);
|
|
@@ -3788,20 +3711,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
3788
3711
|
}, {
|
|
3789
3712
|
key: "fetchSalesSearchFromAPI",
|
|
3790
3713
|
value: (function () {
|
|
3791
|
-
var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3714
|
+
var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(backendPath, data) {
|
|
3792
3715
|
var _this$app8;
|
|
3793
3716
|
var _response$data4, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
|
|
3794
|
-
return _regeneratorRuntime().wrap(function
|
|
3795
|
-
while (1) switch (
|
|
3717
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
3718
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
3796
3719
|
case 0:
|
|
3797
3720
|
if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
|
|
3798
|
-
|
|
3721
|
+
_context44.next = 3;
|
|
3799
3722
|
break;
|
|
3800
3723
|
}
|
|
3801
3724
|
this.logError('fetchSalesSearchFromAPI: app.request 不可用', {
|
|
3802
3725
|
backendPath: backendPath
|
|
3803
3726
|
});
|
|
3804
|
-
return
|
|
3727
|
+
return _context44.abrupt("return", {
|
|
3805
3728
|
code: 500,
|
|
3806
3729
|
message: 'app.request 不可用',
|
|
3807
3730
|
data: backendPath === '/shop/es/search' ? {
|
|
@@ -3813,29 +3736,29 @@ var Server = /*#__PURE__*/function () {
|
|
|
3813
3736
|
status: false
|
|
3814
3737
|
});
|
|
3815
3738
|
case 3:
|
|
3816
|
-
|
|
3817
|
-
|
|
3739
|
+
_context44.prev = 3;
|
|
3740
|
+
_context44.next = 6;
|
|
3818
3741
|
return this.app.request.post(backendPath, data, {
|
|
3819
3742
|
isShopApi: true
|
|
3820
3743
|
});
|
|
3821
3744
|
case 6:
|
|
3822
|
-
response =
|
|
3745
|
+
response = _context44.sent;
|
|
3823
3746
|
_payload = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
|
|
3824
|
-
return
|
|
3747
|
+
return _context44.abrupt("return", {
|
|
3825
3748
|
code: (_response$code2 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code2 !== void 0 ? _response$code2 : 200,
|
|
3826
3749
|
status: (_response$status2 = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status2 !== void 0 ? _response$status2 : true,
|
|
3827
3750
|
message: (_response$message2 = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message2 !== void 0 ? _response$message2 : '',
|
|
3828
3751
|
data: _payload
|
|
3829
3752
|
});
|
|
3830
3753
|
case 11:
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
errorMessage =
|
|
3754
|
+
_context44.prev = 11;
|
|
3755
|
+
_context44.t0 = _context44["catch"](3);
|
|
3756
|
+
errorMessage = _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0);
|
|
3834
3757
|
this.logError('fetchSalesSearchFromAPI: 请求失败', {
|
|
3835
3758
|
backendPath: backendPath,
|
|
3836
3759
|
error: errorMessage
|
|
3837
3760
|
});
|
|
3838
|
-
return
|
|
3761
|
+
return _context44.abrupt("return", {
|
|
3839
3762
|
code: 500,
|
|
3840
3763
|
message: errorMessage,
|
|
3841
3764
|
data: backendPath === '/shop/es/search' ? {
|
|
@@ -3848,9 +3771,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
3848
3771
|
});
|
|
3849
3772
|
case 16:
|
|
3850
3773
|
case "end":
|
|
3851
|
-
return
|
|
3774
|
+
return _context44.stop();
|
|
3852
3775
|
}
|
|
3853
|
-
},
|
|
3776
|
+
}, _callee44, this, [[3, 11]]);
|
|
3854
3777
|
}));
|
|
3855
3778
|
function fetchSalesSearchFromAPI(_x47, _x48) {
|
|
3856
3779
|
return _fetchSalesSearchFromAPI.apply(this, arguments);
|
|
@@ -3882,10 +3805,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
3882
3805
|
}, {
|
|
3883
3806
|
key: "stripSalesSearchPageParams",
|
|
3884
3807
|
value: function stripSalesSearchPageParams(value) {
|
|
3885
|
-
var
|
|
3808
|
+
var _this8 = this;
|
|
3886
3809
|
if (Array.isArray(value)) {
|
|
3887
3810
|
return value.map(function (item) {
|
|
3888
|
-
return
|
|
3811
|
+
return _this8.stripSalesSearchPageParams(item);
|
|
3889
3812
|
});
|
|
3890
3813
|
}
|
|
3891
3814
|
if (!value || _typeof(value) !== 'object') return value;
|
|
@@ -3923,12 +3846,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
3923
3846
|
key: "extractSalesSearchOrderIds",
|
|
3924
3847
|
value: function extractSalesSearchOrderIds(kind, result) {
|
|
3925
3848
|
var _this$findSalesSearch,
|
|
3926
|
-
|
|
3849
|
+
_this9 = this;
|
|
3927
3850
|
var data = this.extractSalesSearchResponseData(result);
|
|
3928
3851
|
var list = kind === 'aggregate' ? (_this$findSalesSearch = this.findSalesSearchAggregateGroup(data)) === null || _this$findSalesSearch === void 0 ? void 0 : _this$findSalesSearch.list : data === null || data === void 0 ? void 0 : data.list;
|
|
3929
3852
|
if (!Array.isArray(list)) return [];
|
|
3930
3853
|
return list.map(function (item) {
|
|
3931
|
-
return
|
|
3854
|
+
return _this9.getSalesSearchOrderId(item);
|
|
3932
3855
|
}).filter(function (id) {
|
|
3933
3856
|
return !!id;
|
|
3934
3857
|
});
|
|
@@ -4095,11 +4018,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4095
4018
|
}, {
|
|
4096
4019
|
key: "stableSerialize",
|
|
4097
4020
|
value: function stableSerialize(value) {
|
|
4098
|
-
var
|
|
4021
|
+
var _this10 = this;
|
|
4099
4022
|
if (value === null || value === undefined) return 'null';
|
|
4100
4023
|
if (Array.isArray(value)) {
|
|
4101
4024
|
return "[".concat(value.map(function (item) {
|
|
4102
|
-
return
|
|
4025
|
+
return _this10.stableSerialize(item);
|
|
4103
4026
|
}).join(','), "]");
|
|
4104
4027
|
}
|
|
4105
4028
|
if (_typeof(value) === 'object') {
|
|
@@ -4108,7 +4031,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4108
4031
|
return obj[k] !== undefined;
|
|
4109
4032
|
}).sort();
|
|
4110
4033
|
return "{".concat(keys.map(function (k) {
|
|
4111
|
-
return "".concat(JSON.stringify(k), ":").concat(
|
|
4034
|
+
return "".concat(JSON.stringify(k), ":").concat(_this10.stableSerialize(obj[k]));
|
|
4112
4035
|
}).join(','), "}");
|
|
4113
4036
|
}
|
|
4114
4037
|
return JSON.stringify(value);
|
|
@@ -4157,22 +4080,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
4157
4080
|
}
|
|
4158
4081
|
var oldestKey = null;
|
|
4159
4082
|
var oldestTime = Number.POSITIVE_INFINITY;
|
|
4160
|
-
var
|
|
4161
|
-
|
|
4083
|
+
var _iterator7 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
|
|
4084
|
+
_step7;
|
|
4162
4085
|
try {
|
|
4163
|
-
for (
|
|
4164
|
-
var
|
|
4165
|
-
_key3 =
|
|
4166
|
-
cache =
|
|
4086
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
4087
|
+
var _step7$value = _slicedToArray(_step7.value, 2),
|
|
4088
|
+
_key3 = _step7$value[0],
|
|
4089
|
+
cache = _step7$value[1];
|
|
4167
4090
|
if (cache.updatedAt < oldestTime) {
|
|
4168
4091
|
oldestTime = cache.updatedAt;
|
|
4169
4092
|
oldestKey = _key3;
|
|
4170
4093
|
}
|
|
4171
4094
|
}
|
|
4172
4095
|
} catch (err) {
|
|
4173
|
-
|
|
4096
|
+
_iterator7.e(err);
|
|
4174
4097
|
} finally {
|
|
4175
|
-
|
|
4098
|
+
_iterator7.f();
|
|
4176
4099
|
}
|
|
4177
4100
|
if (oldestKey) this.bookingRemoteCache.delete(oldestKey);
|
|
4178
4101
|
}
|
|
@@ -4188,17 +4111,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
4188
4111
|
key: "markBookingRemoteCacheAllStale",
|
|
4189
4112
|
value: function markBookingRemoteCacheAllStale(reason) {
|
|
4190
4113
|
if (this.bookingRemoteCache.size === 0) return;
|
|
4191
|
-
var
|
|
4192
|
-
|
|
4114
|
+
var _iterator8 = _createForOfIteratorHelper(this.bookingRemoteCache.values()),
|
|
4115
|
+
_step8;
|
|
4193
4116
|
try {
|
|
4194
|
-
for (
|
|
4195
|
-
var entry =
|
|
4117
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
4118
|
+
var entry = _step8.value;
|
|
4196
4119
|
entry.stale = true;
|
|
4197
4120
|
}
|
|
4198
4121
|
} catch (err) {
|
|
4199
|
-
|
|
4122
|
+
_iterator8.e(err);
|
|
4200
4123
|
} finally {
|
|
4201
|
-
|
|
4124
|
+
_iterator8.f();
|
|
4202
4125
|
}
|
|
4203
4126
|
this.logWarning('bookingRemoteCache: 全量标记失效', {
|
|
4204
4127
|
reason: reason,
|
|
@@ -4224,13 +4147,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4224
4147
|
key: "notifyBookingRemoteSubscribersByCacheKey",
|
|
4225
4148
|
value: function notifyBookingRemoteSubscribersByCacheKey(cacheKey, entry, reason) {
|
|
4226
4149
|
if (this.bookingRemoteQuerySubscribers.size === 0) return;
|
|
4227
|
-
var
|
|
4228
|
-
|
|
4150
|
+
var _iterator9 = _createForOfIteratorHelper(this.bookingRemoteQuerySubscribers.entries()),
|
|
4151
|
+
_step9;
|
|
4229
4152
|
try {
|
|
4230
|
-
for (
|
|
4231
|
-
var
|
|
4232
|
-
subscriberId =
|
|
4233
|
-
subscriber =
|
|
4153
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
4154
|
+
var _step9$value = _slicedToArray(_step9.value, 2),
|
|
4155
|
+
subscriberId = _step9$value[0],
|
|
4156
|
+
subscriber = _step9$value[1];
|
|
4234
4157
|
if (subscriber.cacheKey !== cacheKey) continue;
|
|
4235
4158
|
try {
|
|
4236
4159
|
var callbackStartAt = Date.now();
|
|
@@ -4257,9 +4180,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
4257
4180
|
}
|
|
4258
4181
|
}
|
|
4259
4182
|
} catch (err) {
|
|
4260
|
-
|
|
4183
|
+
_iterator9.e(err);
|
|
4261
4184
|
} finally {
|
|
4262
|
-
|
|
4185
|
+
_iterator9.f();
|
|
4263
4186
|
}
|
|
4264
4187
|
}
|
|
4265
4188
|
}, {
|
|
@@ -4274,13 +4197,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4274
4197
|
return;
|
|
4275
4198
|
}
|
|
4276
4199
|
var syncedEntryCount = 0;
|
|
4277
|
-
var
|
|
4278
|
-
|
|
4200
|
+
var _iterator10 = _createForOfIteratorHelper(this.bookingRemoteCache.entries()),
|
|
4201
|
+
_step10;
|
|
4279
4202
|
try {
|
|
4280
|
-
for (
|
|
4281
|
-
var
|
|
4282
|
-
cacheKey =
|
|
4283
|
-
entry =
|
|
4203
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
4204
|
+
var _step10$value = _slicedToArray(_step10.value, 2),
|
|
4205
|
+
cacheKey = _step10$value[0],
|
|
4206
|
+
entry = _step10$value[1];
|
|
4284
4207
|
if (entry.stale) {
|
|
4285
4208
|
this.bookingRemoteCache.delete(cacheKey);
|
|
4286
4209
|
continue;
|
|
@@ -4288,25 +4211,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
4288
4211
|
try {
|
|
4289
4212
|
var queryPayload = entry.queryPayload;
|
|
4290
4213
|
var orderMap = new Map();
|
|
4291
|
-
var
|
|
4292
|
-
|
|
4214
|
+
var _iterator11 = _createForOfIteratorHelper(entry.rawOrders),
|
|
4215
|
+
_step11;
|
|
4293
4216
|
try {
|
|
4294
|
-
for (
|
|
4295
|
-
var order =
|
|
4217
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
4218
|
+
var order = _step11.value;
|
|
4296
4219
|
var _key4 = this.toOrderIdKey(order);
|
|
4297
4220
|
if (_key4) orderMap.set(_key4, order);
|
|
4298
4221
|
}
|
|
4299
4222
|
} catch (err) {
|
|
4300
|
-
|
|
4223
|
+
_iterator11.e(err);
|
|
4301
4224
|
} finally {
|
|
4302
|
-
|
|
4225
|
+
_iterator11.f();
|
|
4303
4226
|
}
|
|
4304
4227
|
var changed = false;
|
|
4305
|
-
var
|
|
4306
|
-
|
|
4228
|
+
var _iterator12 = _createForOfIteratorHelper(latestOrders),
|
|
4229
|
+
_step12;
|
|
4307
4230
|
try {
|
|
4308
|
-
for (
|
|
4309
|
-
var latest =
|
|
4231
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
4232
|
+
var latest = _step12.value;
|
|
4310
4233
|
var _key5 = this.toOrderIdKey(latest);
|
|
4311
4234
|
if (!_key5) continue;
|
|
4312
4235
|
if (orderMap.has(_key5)) {
|
|
@@ -4318,9 +4241,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
4318
4241
|
changed = true;
|
|
4319
4242
|
}
|
|
4320
4243
|
} catch (err) {
|
|
4321
|
-
|
|
4244
|
+
_iterator12.e(err);
|
|
4322
4245
|
} finally {
|
|
4323
|
-
|
|
4246
|
+
_iterator12.f();
|
|
4324
4247
|
}
|
|
4325
4248
|
if (!changed) continue;
|
|
4326
4249
|
var mergedOrders = _toConsumableArray(orderMap.values());
|
|
@@ -4353,9 +4276,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
4353
4276
|
}
|
|
4354
4277
|
}
|
|
4355
4278
|
} catch (err) {
|
|
4356
|
-
|
|
4279
|
+
_iterator10.e(err);
|
|
4357
4280
|
} finally {
|
|
4358
|
-
|
|
4281
|
+
_iterator10.f();
|
|
4359
4282
|
}
|
|
4360
4283
|
var syncEndAt = Date.now();
|
|
4361
4284
|
if (syncedEntryCount > 0) {
|
|
@@ -4373,18 +4296,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
4373
4296
|
}, {
|
|
4374
4297
|
key: "fetchOrderListFromAPI",
|
|
4375
4298
|
value: (function () {
|
|
4376
|
-
var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4299
|
+
var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(data) {
|
|
4377
4300
|
var _this$app9;
|
|
4378
4301
|
var _response$data5, response, _payload2, list, count, errorMessage;
|
|
4379
|
-
return _regeneratorRuntime().wrap(function
|
|
4380
|
-
while (1) switch (
|
|
4302
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
4303
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4381
4304
|
case 0:
|
|
4382
4305
|
if ((_this$app9 = this.app) !== null && _this$app9 !== void 0 && _this$app9.request) {
|
|
4383
|
-
|
|
4306
|
+
_context45.next = 3;
|
|
4384
4307
|
break;
|
|
4385
4308
|
}
|
|
4386
4309
|
this.logError('fetchOrderListFromAPI: app.request 不可用');
|
|
4387
|
-
return
|
|
4310
|
+
return _context45.abrupt("return", {
|
|
4388
4311
|
code: 500,
|
|
4389
4312
|
message: 'app.request 不可用',
|
|
4390
4313
|
data: {
|
|
@@ -4394,17 +4317,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
4394
4317
|
status: false
|
|
4395
4318
|
});
|
|
4396
4319
|
case 3:
|
|
4397
|
-
|
|
4398
|
-
|
|
4320
|
+
_context45.prev = 3;
|
|
4321
|
+
_context45.next = 6;
|
|
4399
4322
|
return this.app.request.post('/shop/order/v2/list', data, {
|
|
4400
4323
|
isShopApi: true
|
|
4401
4324
|
});
|
|
4402
4325
|
case 6:
|
|
4403
|
-
response =
|
|
4326
|
+
response = _context45.sent;
|
|
4404
4327
|
_payload2 = (_response$data5 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data5 !== void 0 ? _response$data5 : response;
|
|
4405
4328
|
list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
|
|
4406
4329
|
count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
|
|
4407
|
-
return
|
|
4330
|
+
return _context45.abrupt("return", {
|
|
4408
4331
|
code: 200,
|
|
4409
4332
|
data: _objectSpread(_objectSpread({}, _payload2), {}, {
|
|
4410
4333
|
list: list,
|
|
@@ -4414,13 +4337,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4414
4337
|
status: true
|
|
4415
4338
|
});
|
|
4416
4339
|
case 13:
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
errorMessage =
|
|
4340
|
+
_context45.prev = 13;
|
|
4341
|
+
_context45.t0 = _context45["catch"](3);
|
|
4342
|
+
errorMessage = _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0);
|
|
4420
4343
|
this.logError('fetchOrderListFromAPI: 请求失败', {
|
|
4421
4344
|
error: errorMessage
|
|
4422
4345
|
});
|
|
4423
|
-
return
|
|
4346
|
+
return _context45.abrupt("return", {
|
|
4424
4347
|
code: 500,
|
|
4425
4348
|
message: errorMessage,
|
|
4426
4349
|
data: {
|
|
@@ -4431,9 +4354,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
4431
4354
|
});
|
|
4432
4355
|
case 18:
|
|
4433
4356
|
case "end":
|
|
4434
|
-
return
|
|
4357
|
+
return _context45.stop();
|
|
4435
4358
|
}
|
|
4436
|
-
},
|
|
4359
|
+
}, _callee45, this, [[3, 13]]);
|
|
4437
4360
|
}));
|
|
4438
4361
|
function fetchOrderListFromAPI(_x49) {
|
|
4439
4362
|
return _fetchOrderListFromAPI.apply(this, arguments);
|
|
@@ -4447,17 +4370,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
4447
4370
|
}, {
|
|
4448
4371
|
key: "fetchBookingListFromAPI",
|
|
4449
4372
|
value: (function () {
|
|
4450
|
-
var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4373
|
+
var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(data) {
|
|
4451
4374
|
var memoryCacheEnabled, withFields, requestPayload, cacheKey, cached, rawList, bookingResult, _bookingResult$list, errorMessage;
|
|
4452
|
-
return _regeneratorRuntime().wrap(function
|
|
4453
|
-
while (1) switch (
|
|
4375
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
4376
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4454
4377
|
case 0:
|
|
4455
4378
|
if (this.order) {
|
|
4456
|
-
|
|
4379
|
+
_context46.next = 3;
|
|
4457
4380
|
break;
|
|
4458
4381
|
}
|
|
4459
4382
|
this.logError('fetchBookingListFromAPI: Order 模块不可用');
|
|
4460
|
-
return
|
|
4383
|
+
return _context46.abrupt("return", {
|
|
4461
4384
|
code: 500,
|
|
4462
4385
|
message: 'Order 模块不可用',
|
|
4463
4386
|
data: {
|
|
@@ -4467,18 +4390,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
4467
4390
|
status: false
|
|
4468
4391
|
});
|
|
4469
4392
|
case 3:
|
|
4470
|
-
|
|
4393
|
+
_context46.prev = 3;
|
|
4471
4394
|
memoryCacheEnabled = this.isBookingRemoteMemoryCacheEnabled(data);
|
|
4472
4395
|
withFields = this.resolveBookingSalesWith(data);
|
|
4473
4396
|
requestPayload = this.normalizeBookingRemoteQueryPayload(data, withFields);
|
|
4474
4397
|
cacheKey = this.buildBookingRemoteCacheKey(requestPayload);
|
|
4475
4398
|
if (!memoryCacheEnabled) {
|
|
4476
|
-
|
|
4399
|
+
_context46.next = 13;
|
|
4477
4400
|
break;
|
|
4478
4401
|
}
|
|
4479
4402
|
cached = this.readBookingRemoteCache(cacheKey);
|
|
4480
4403
|
if (!cached) {
|
|
4481
|
-
|
|
4404
|
+
_context46.next = 13;
|
|
4482
4405
|
break;
|
|
4483
4406
|
}
|
|
4484
4407
|
this.logInfo('fetchBookingListFromAPI: 命中内存缓存', {
|
|
@@ -4486,14 +4409,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
4486
4409
|
listCount: cached.bookingResult.count,
|
|
4487
4410
|
withFields: cached.withFields
|
|
4488
4411
|
});
|
|
4489
|
-
return
|
|
4412
|
+
return _context46.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
|
|
4490
4413
|
cache_hit: true
|
|
4491
4414
|
}));
|
|
4492
4415
|
case 13:
|
|
4493
|
-
|
|
4416
|
+
_context46.next = 15;
|
|
4494
4417
|
return this.order.fetchOrdersBySSE(requestPayload);
|
|
4495
4418
|
case 15:
|
|
4496
|
-
rawList =
|
|
4419
|
+
rawList = _context46.sent;
|
|
4497
4420
|
bookingResult = sortBookings(filterBookingsFromOrders(rawList, data), data); // DEBUG: 挂到 window 上方便排查 SSE → 日历数据丢失问题
|
|
4498
4421
|
if (typeof globalThis !== 'undefined') {
|
|
4499
4422
|
globalThis.__SSE_BOOKING_DEBUG__ = {
|
|
@@ -4540,15 +4463,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
4540
4463
|
cacheKey: cacheKey,
|
|
4541
4464
|
withFields: withFields
|
|
4542
4465
|
});
|
|
4543
|
-
return
|
|
4466
|
+
return _context46.abrupt("return", this.buildBookingResponse(bookingResult));
|
|
4544
4467
|
case 23:
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
errorMessage =
|
|
4468
|
+
_context46.prev = 23;
|
|
4469
|
+
_context46.t0 = _context46["catch"](3);
|
|
4470
|
+
errorMessage = _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0);
|
|
4548
4471
|
this.logError('fetchBookingListFromAPI: SSE 请求失败', {
|
|
4549
4472
|
error: errorMessage
|
|
4550
4473
|
});
|
|
4551
|
-
return
|
|
4474
|
+
return _context46.abrupt("return", {
|
|
4552
4475
|
code: 500,
|
|
4553
4476
|
message: errorMessage,
|
|
4554
4477
|
data: {
|
|
@@ -4559,9 +4482,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
4559
4482
|
});
|
|
4560
4483
|
case 28:
|
|
4561
4484
|
case "end":
|
|
4562
|
-
return
|
|
4485
|
+
return _context46.stop();
|
|
4563
4486
|
}
|
|
4564
|
-
},
|
|
4487
|
+
}, _callee46, this, [[3, 23]]);
|
|
4565
4488
|
}));
|
|
4566
4489
|
function fetchBookingListFromAPI(_x50) {
|
|
4567
4490
|
return _fetchBookingListFromAPI.apply(this, arguments);
|
|
@@ -4647,11 +4570,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4647
4570
|
}, {
|
|
4648
4571
|
key: "runLocalPaymentUpdateInQueue",
|
|
4649
4572
|
value: function () {
|
|
4650
|
-
var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4651
|
-
var
|
|
4573
|
+
var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(key, task, context) {
|
|
4574
|
+
var _this11 = this;
|
|
4652
4575
|
var queuedAt, hasPreviousTask, previous, current, tail, _data, result, released;
|
|
4653
|
-
return _regeneratorRuntime().wrap(function
|
|
4654
|
-
while (1) switch (
|
|
4576
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
4577
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4655
4578
|
case 0:
|
|
4656
4579
|
queuedAt = Date.now();
|
|
4657
4580
|
hasPreviousTask = this.localPaymentUpdateQueues.has(key);
|
|
@@ -4663,20 +4586,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
4663
4586
|
}));
|
|
4664
4587
|
current = previous.catch(function () {
|
|
4665
4588
|
return undefined;
|
|
4666
|
-
}).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4667
|
-
return _regeneratorRuntime().wrap(function
|
|
4668
|
-
while (1) switch (
|
|
4589
|
+
}).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
|
|
4590
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
4591
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4669
4592
|
case 0:
|
|
4670
|
-
|
|
4593
|
+
_this11.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
|
|
4671
4594
|
queue_key: key,
|
|
4672
4595
|
queue_wait_ms: Date.now() - queuedAt
|
|
4673
4596
|
}));
|
|
4674
|
-
return
|
|
4597
|
+
return _context47.abrupt("return", task());
|
|
4675
4598
|
case 2:
|
|
4676
4599
|
case "end":
|
|
4677
|
-
return
|
|
4600
|
+
return _context47.stop();
|
|
4678
4601
|
}
|
|
4679
|
-
},
|
|
4602
|
+
}, _callee47);
|
|
4680
4603
|
})));
|
|
4681
4604
|
tail = current.then(function () {
|
|
4682
4605
|
return undefined;
|
|
@@ -4684,11 +4607,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4684
4607
|
return undefined;
|
|
4685
4608
|
});
|
|
4686
4609
|
this.localPaymentUpdateQueues.set(key, tail);
|
|
4687
|
-
|
|
4688
|
-
|
|
4610
|
+
_context48.prev = 7;
|
|
4611
|
+
_context48.next = 10;
|
|
4689
4612
|
return current;
|
|
4690
4613
|
case 10:
|
|
4691
|
-
result =
|
|
4614
|
+
result = _context48.sent;
|
|
4692
4615
|
this.logInfo('handleUpdateLocalPayment: 串行队列执行完成', _objectSpread(_objectSpread({}, context), {}, {
|
|
4693
4616
|
queue_key: key,
|
|
4694
4617
|
total_duration_ms: Date.now() - queuedAt,
|
|
@@ -4696,19 +4619,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
4696
4619
|
result_status: result === null || result === void 0 ? void 0 : result.status,
|
|
4697
4620
|
payment: result === null || result === void 0 || (_data = result.data) === null || _data === void 0 ? void 0 : _data.payment
|
|
4698
4621
|
}));
|
|
4699
|
-
return
|
|
4622
|
+
return _context48.abrupt("return", result);
|
|
4700
4623
|
case 15:
|
|
4701
|
-
|
|
4702
|
-
|
|
4624
|
+
_context48.prev = 15;
|
|
4625
|
+
_context48.t0 = _context48["catch"](7);
|
|
4703
4626
|
this.logError('handleUpdateLocalPayment: 串行队列执行失败', _objectSpread(_objectSpread({}, context), {}, {
|
|
4704
4627
|
queue_key: key,
|
|
4705
4628
|
total_duration_ms: Date.now() - queuedAt,
|
|
4706
|
-
error:
|
|
4707
|
-
error_detail: this.normalizeUnknownError(
|
|
4629
|
+
error: _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0),
|
|
4630
|
+
error_detail: this.normalizeUnknownError(_context48.t0)
|
|
4708
4631
|
}));
|
|
4709
|
-
throw
|
|
4632
|
+
throw _context48.t0;
|
|
4710
4633
|
case 19:
|
|
4711
|
-
|
|
4634
|
+
_context48.prev = 19;
|
|
4712
4635
|
released = false;
|
|
4713
4636
|
if (this.localPaymentUpdateQueues.get(key) === tail) {
|
|
4714
4637
|
this.localPaymentUpdateQueues.delete(key);
|
|
@@ -4719,12 +4642,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
4719
4642
|
released: released,
|
|
4720
4643
|
active_queue_count: this.localPaymentUpdateQueues.size
|
|
4721
4644
|
}));
|
|
4722
|
-
return
|
|
4645
|
+
return _context48.finish(19);
|
|
4723
4646
|
case 24:
|
|
4724
4647
|
case "end":
|
|
4725
|
-
return
|
|
4648
|
+
return _context48.stop();
|
|
4726
4649
|
}
|
|
4727
|
-
},
|
|
4650
|
+
}, _callee48, this, [[7, 15, 19, 24]]);
|
|
4728
4651
|
}));
|
|
4729
4652
|
function runLocalPaymentUpdateInQueue(_x51, _x52, _x53) {
|
|
4730
4653
|
return _runLocalPaymentUpdateInQueue.apply(this, arguments);
|
|
@@ -4734,11 +4657,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4734
4657
|
}, {
|
|
4735
4658
|
key: "processLocalPaymentUpdate",
|
|
4736
4659
|
value: function () {
|
|
4737
|
-
var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4660
|
+
var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
|
|
4738
4661
|
var _params$serviceCharge4, _params$cardReaderSur, _found$payment, _found$payment2;
|
|
4739
4662
|
var requestContext, found, surchargeUpdate, incomingPaymentUpdate, transactions, existingTransaction, hasRecordedSuccess, orderIsDraft, foundContext, alreadyRecordedFailure, updated;
|
|
4740
|
-
return _regeneratorRuntime().wrap(function
|
|
4741
|
-
while (1) switch (
|
|
4663
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
4664
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
4742
4665
|
case 0:
|
|
4743
4666
|
requestContext = {
|
|
4744
4667
|
operation_id: params.operationId,
|
|
@@ -4751,11 +4674,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4751
4674
|
};
|
|
4752
4675
|
this.logInfo('processLocalPaymentUpdate: 开始处理', requestContext);
|
|
4753
4676
|
if (this.order) {
|
|
4754
|
-
|
|
4677
|
+
_context49.next = 5;
|
|
4755
4678
|
break;
|
|
4756
4679
|
}
|
|
4757
4680
|
this.logError('processLocalPaymentUpdate: Order 模块未注册', requestContext);
|
|
4758
|
-
return
|
|
4681
|
+
return _context49.abrupt("return", {
|
|
4759
4682
|
code: 500,
|
|
4760
4683
|
status: false,
|
|
4761
4684
|
message: 'Order 模块未注册',
|
|
@@ -4763,20 +4686,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
4763
4686
|
});
|
|
4764
4687
|
case 5:
|
|
4765
4688
|
this.logInfo('processLocalPaymentUpdate: 开始查询本地支付项', requestContext);
|
|
4766
|
-
|
|
4689
|
+
_context49.next = 8;
|
|
4767
4690
|
return this.order.getLocalPayment({
|
|
4768
4691
|
saleId: params.saleId,
|
|
4769
4692
|
paymentNumber: params.paymentNumber,
|
|
4770
4693
|
operationId: params.operationId
|
|
4771
4694
|
});
|
|
4772
4695
|
case 8:
|
|
4773
|
-
found =
|
|
4696
|
+
found = _context49.sent;
|
|
4774
4697
|
if (found) {
|
|
4775
|
-
|
|
4698
|
+
_context49.next = 12;
|
|
4776
4699
|
break;
|
|
4777
4700
|
}
|
|
4778
4701
|
this.logWarning('processLocalPaymentUpdate: 本地支付项不存在', requestContext);
|
|
4779
|
-
return
|
|
4702
|
+
return _context49.abrupt("return", {
|
|
4780
4703
|
code: 404,
|
|
4781
4704
|
status: false,
|
|
4782
4705
|
message: '本地支付项不存在',
|
|
@@ -4825,13 +4748,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4825
4748
|
});
|
|
4826
4749
|
this.logInfo('processLocalPaymentUpdate: 查询命中', foundContext);
|
|
4827
4750
|
if (!(params.status === 'fail' && (found.payment.status === 'paid' || hasRecordedSuccess))) {
|
|
4828
|
-
|
|
4751
|
+
_context49.next = 23;
|
|
4829
4752
|
break;
|
|
4830
4753
|
}
|
|
4831
4754
|
this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
4832
4755
|
idempotent_reason: 'ignore_failure_after_success'
|
|
4833
4756
|
}));
|
|
4834
|
-
return
|
|
4757
|
+
return _context49.abrupt("return", {
|
|
4835
4758
|
code: 200,
|
|
4836
4759
|
status: true,
|
|
4837
4760
|
message: '',
|
|
@@ -4844,13 +4767,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4844
4767
|
case 23:
|
|
4845
4768
|
alreadyRecordedFailure = params.status === 'fail' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'fail';
|
|
4846
4769
|
if (!alreadyRecordedFailure) {
|
|
4847
|
-
|
|
4770
|
+
_context49.next = 27;
|
|
4848
4771
|
break;
|
|
4849
4772
|
}
|
|
4850
4773
|
this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
4851
4774
|
idempotent_reason: 'failure_already_recorded'
|
|
4852
4775
|
}));
|
|
4853
|
-
return
|
|
4776
|
+
return _context49.abrupt("return", {
|
|
4854
4777
|
code: 200,
|
|
4855
4778
|
status: true,
|
|
4856
4779
|
message: '',
|
|
@@ -4862,13 +4785,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4862
4785
|
});
|
|
4863
4786
|
case 27:
|
|
4864
4787
|
if (!(params.status === 'success' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'success' && found.payment.status === 'paid' && !orderIsDraft)) {
|
|
4865
|
-
|
|
4788
|
+
_context49.next = 30;
|
|
4866
4789
|
break;
|
|
4867
4790
|
}
|
|
4868
4791
|
this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
4869
4792
|
idempotent_reason: 'success_already_committed'
|
|
4870
4793
|
}));
|
|
4871
|
-
return
|
|
4794
|
+
return _context49.abrupt("return", {
|
|
4872
4795
|
code: 200,
|
|
4873
4796
|
status: true,
|
|
4874
4797
|
message: '',
|
|
@@ -4880,13 +4803,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4880
4803
|
});
|
|
4881
4804
|
case 30:
|
|
4882
4805
|
if (!(params.status === 'success')) {
|
|
4883
|
-
|
|
4806
|
+
_context49.next = 33;
|
|
4884
4807
|
break;
|
|
4885
4808
|
}
|
|
4886
4809
|
this.logInfo('processLocalPaymentUpdate: 进入 success 恢复分支', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
4887
4810
|
force_submit_if_paid: found.payment.status === 'paid' && orderIsDraft
|
|
4888
4811
|
}));
|
|
4889
|
-
return
|
|
4812
|
+
return _context49.abrupt("return", this.processSuccessfulLocalPayment(_objectSpread(_objectSpread({}, params), {}, {
|
|
4890
4813
|
order: found.order,
|
|
4891
4814
|
payment: found.payment,
|
|
4892
4815
|
matchBy: found.matchedBy === 'payment_number' ? 'payment_number' : 'compat',
|
|
@@ -4897,8 +4820,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
4897
4820
|
this.logInfo('processLocalPaymentUpdate: 进入 fail 本地更新分支', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
4898
4821
|
incoming_payment_update: incomingPaymentUpdate
|
|
4899
4822
|
}));
|
|
4900
|
-
|
|
4901
|
-
|
|
4823
|
+
_context49.prev = 34;
|
|
4824
|
+
_context49.next = 37;
|
|
4902
4825
|
return this.order.updateLocalPayment({
|
|
4903
4826
|
saleId: params.saleId,
|
|
4904
4827
|
paymentNumber: params.paymentNumber,
|
|
@@ -4906,25 +4829,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
4906
4829
|
updates: incomingPaymentUpdate
|
|
4907
4830
|
});
|
|
4908
4831
|
case 37:
|
|
4909
|
-
updated =
|
|
4910
|
-
|
|
4832
|
+
updated = _context49.sent;
|
|
4833
|
+
_context49.next = 44;
|
|
4911
4834
|
break;
|
|
4912
4835
|
case 40:
|
|
4913
|
-
|
|
4914
|
-
|
|
4836
|
+
_context49.prev = 40;
|
|
4837
|
+
_context49.t0 = _context49["catch"](34);
|
|
4915
4838
|
this.logError('processLocalPaymentUpdate: fail 本地更新失败', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
4916
4839
|
incoming_payment_update: incomingPaymentUpdate,
|
|
4917
|
-
error:
|
|
4918
|
-
error_detail: this.normalizeUnknownError(
|
|
4840
|
+
error: _context49.t0 instanceof Error ? _context49.t0.message : String(_context49.t0),
|
|
4841
|
+
error_detail: this.normalizeUnknownError(_context49.t0)
|
|
4919
4842
|
}));
|
|
4920
|
-
throw
|
|
4843
|
+
throw _context49.t0;
|
|
4921
4844
|
case 44:
|
|
4922
4845
|
if (updated) {
|
|
4923
|
-
|
|
4846
|
+
_context49.next = 47;
|
|
4924
4847
|
break;
|
|
4925
4848
|
}
|
|
4926
4849
|
this.logWarning('processLocalPaymentUpdate: fail 本地更新未命中', foundContext);
|
|
4927
|
-
return
|
|
4850
|
+
return _context49.abrupt("return", {
|
|
4928
4851
|
code: 404,
|
|
4929
4852
|
status: false,
|
|
4930
4853
|
message: '本地支付项不存在',
|
|
@@ -4935,7 +4858,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4935
4858
|
previous_payment: updated.previousPayment,
|
|
4936
4859
|
payment: updated.payment
|
|
4937
4860
|
}));
|
|
4938
|
-
return
|
|
4861
|
+
return _context49.abrupt("return", {
|
|
4939
4862
|
code: 200,
|
|
4940
4863
|
status: true,
|
|
4941
4864
|
message: '',
|
|
@@ -4947,9 +4870,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
4947
4870
|
});
|
|
4948
4871
|
case 49:
|
|
4949
4872
|
case "end":
|
|
4950
|
-
return
|
|
4873
|
+
return _context49.stop();
|
|
4951
4874
|
}
|
|
4952
|
-
},
|
|
4875
|
+
}, _callee49, this, [[34, 40]]);
|
|
4953
4876
|
}));
|
|
4954
4877
|
function processLocalPaymentUpdate(_x54) {
|
|
4955
4878
|
return _processLocalPaymentUpdate.apply(this, arguments);
|
|
@@ -4959,10 +4882,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
4959
4882
|
}, {
|
|
4960
4883
|
key: "processSuccessfulLocalPayment",
|
|
4961
4884
|
value: function () {
|
|
4962
|
-
var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4885
|
+
var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
|
|
4963
4886
|
var moduleName, baseSales, startedAt, recoveryContext, _order$order_id3, _result$payments, _result$syncResult$su, _result$syncResult$su2, _result$draftResult, _result$draftResult2, order, result, message;
|
|
4964
|
-
return _regeneratorRuntime().wrap(function
|
|
4965
|
-
while (1) switch (
|
|
4887
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
4888
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
4966
4889
|
case 0:
|
|
4967
4890
|
moduleName = "local_payment_recovery_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 8));
|
|
4968
4891
|
baseSales = new BaseSalesImpl(moduleName);
|
|
@@ -4981,13 +4904,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4981
4904
|
payment: params.payment
|
|
4982
4905
|
});
|
|
4983
4906
|
this.logInfo('processSuccessfulLocalPayment: 创建临时 BaseSales', recoveryContext);
|
|
4984
|
-
|
|
4907
|
+
_context50.prev = 5;
|
|
4985
4908
|
order = this.sanitizeLocalRecoveryOrder(params.order);
|
|
4986
4909
|
this.logInfo('processSuccessfulLocalPayment: 本地订单清洗完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
4987
4910
|
sanitized_order_id: (_order$order_id3 = order.order_id) !== null && _order$order_id3 !== void 0 ? _order$order_id3 : null,
|
|
4988
4911
|
removed_synthetic_order_id: params.order.order_id != null && order.order_id == null
|
|
4989
4912
|
}));
|
|
4990
|
-
|
|
4913
|
+
_context50.next = 10;
|
|
4991
4914
|
return baseSales.initialize(this.core, {
|
|
4992
4915
|
otherParams: {
|
|
4993
4916
|
platform: order.platform,
|
|
@@ -5000,14 +4923,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
5000
4923
|
});
|
|
5001
4924
|
case 10:
|
|
5002
4925
|
this.logInfo('processSuccessfulLocalPayment: BaseSales 初始化完成', recoveryContext);
|
|
5003
|
-
|
|
4926
|
+
_context50.next = 13;
|
|
5004
4927
|
return baseSales.replaceTempOrder(order);
|
|
5005
4928
|
case 13:
|
|
5006
4929
|
this.logInfo('processSuccessfulLocalPayment: 本地订单 tempOrder 恢复完成', recoveryContext);
|
|
5007
4930
|
this.logInfo('processSuccessfulLocalPayment: 开始更新支付项并提交', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
5008
4931
|
incoming_payment_update: params.paymentUpdate
|
|
5009
4932
|
}));
|
|
5010
|
-
|
|
4933
|
+
_context50.next = 17;
|
|
5011
4934
|
return baseSales.updateOrderPayment(params.paymentNumber, params.paymentUpdate, {
|
|
5012
4935
|
submitWhenPaid: true,
|
|
5013
4936
|
matchBy: params.matchBy,
|
|
@@ -5016,7 +4939,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5016
4939
|
smallTicketDataFlag: 1
|
|
5017
4940
|
});
|
|
5018
4941
|
case 17:
|
|
5019
|
-
result =
|
|
4942
|
+
result = _context50.sent;
|
|
5020
4943
|
this.logInfo('processSuccessfulLocalPayment: 支付恢复完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
5021
4944
|
duration_ms: Date.now() - startedAt,
|
|
5022
4945
|
payment: result.payment,
|
|
@@ -5038,7 +4961,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5038
4961
|
} : null,
|
|
5039
4962
|
draft_error: result.draftError instanceof Error ? result.draftError.message : result.draftError
|
|
5040
4963
|
}));
|
|
5041
|
-
return
|
|
4964
|
+
return _context50.abrupt("return", {
|
|
5042
4965
|
code: 200,
|
|
5043
4966
|
status: true,
|
|
5044
4967
|
message: '',
|
|
@@ -5050,46 +4973,46 @@ var Server = /*#__PURE__*/function () {
|
|
|
5050
4973
|
}
|
|
5051
4974
|
});
|
|
5052
4975
|
case 22:
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
message =
|
|
4976
|
+
_context50.prev = 22;
|
|
4977
|
+
_context50.t0 = _context50["catch"](5);
|
|
4978
|
+
message = _context50.t0 instanceof Error ? _context50.t0.message : String(_context50.t0);
|
|
5056
4979
|
this.logError('processSuccessfulLocalPayment: 支付恢复失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
5057
4980
|
duration_ms: Date.now() - startedAt,
|
|
5058
4981
|
error: message,
|
|
5059
|
-
error_detail: this.normalizeUnknownError(
|
|
4982
|
+
error_detail: this.normalizeUnknownError(_context50.t0)
|
|
5060
4983
|
}));
|
|
5061
|
-
return
|
|
4984
|
+
return _context50.abrupt("return", {
|
|
5062
4985
|
code: 500,
|
|
5063
4986
|
status: false,
|
|
5064
4987
|
message: message,
|
|
5065
4988
|
data: null
|
|
5066
4989
|
});
|
|
5067
4990
|
case 27:
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
4991
|
+
_context50.prev = 27;
|
|
4992
|
+
_context50.prev = 28;
|
|
4993
|
+
_context50.next = 31;
|
|
5071
4994
|
return baseSales.destroy();
|
|
5072
4995
|
case 31:
|
|
5073
4996
|
this.logInfo('processSuccessfulLocalPayment: 临时 BaseSales 销毁完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
5074
4997
|
duration_ms: Date.now() - startedAt
|
|
5075
4998
|
}));
|
|
5076
|
-
|
|
4999
|
+
_context50.next = 37;
|
|
5077
5000
|
break;
|
|
5078
5001
|
case 34:
|
|
5079
|
-
|
|
5080
|
-
|
|
5002
|
+
_context50.prev = 34;
|
|
5003
|
+
_context50.t1 = _context50["catch"](28);
|
|
5081
5004
|
this.logError('processSuccessfulLocalPayment: 临时 BaseSales 销毁失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
5082
5005
|
duration_ms: Date.now() - startedAt,
|
|
5083
|
-
error:
|
|
5084
|
-
error_detail: this.normalizeUnknownError(
|
|
5006
|
+
error: _context50.t1 instanceof Error ? _context50.t1.message : String(_context50.t1),
|
|
5007
|
+
error_detail: this.normalizeUnknownError(_context50.t1)
|
|
5085
5008
|
}));
|
|
5086
5009
|
case 37:
|
|
5087
|
-
return
|
|
5010
|
+
return _context50.finish(27);
|
|
5088
5011
|
case 38:
|
|
5089
5012
|
case "end":
|
|
5090
|
-
return
|
|
5013
|
+
return _context50.stop();
|
|
5091
5014
|
}
|
|
5092
|
-
},
|
|
5015
|
+
}, _callee50, this, [[5, 22, 27, 38], [28, 34]]);
|
|
5093
5016
|
}));
|
|
5094
5017
|
function processSuccessfulLocalPayment(_x55) {
|
|
5095
5018
|
return _processSuccessfulLocalPayment.apply(this, arguments);
|
|
@@ -5182,32 +5105,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
5182
5105
|
}, {
|
|
5183
5106
|
key: "getShortNumberOrDeviceId",
|
|
5184
5107
|
value: function () {
|
|
5185
|
-
var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5108
|
+
var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51() {
|
|
5186
5109
|
var getAsyncIotDeviceInfo, res;
|
|
5187
|
-
return _regeneratorRuntime().wrap(function
|
|
5188
|
-
while (1) switch (
|
|
5110
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
5111
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
5189
5112
|
case 0:
|
|
5190
5113
|
getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
|
|
5191
5114
|
if (!getAsyncIotDeviceInfo) {
|
|
5192
|
-
|
|
5115
|
+
_context51.next = 7;
|
|
5193
5116
|
break;
|
|
5194
5117
|
}
|
|
5195
|
-
|
|
5118
|
+
_context51.next = 4;
|
|
5196
5119
|
return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
|
|
5197
5120
|
case 4:
|
|
5198
|
-
res =
|
|
5121
|
+
res = _context51.sent;
|
|
5199
5122
|
if (!(res !== null && res !== void 0 && res.short_number)) {
|
|
5200
|
-
|
|
5123
|
+
_context51.next = 7;
|
|
5201
5124
|
break;
|
|
5202
5125
|
}
|
|
5203
|
-
return
|
|
5126
|
+
return _context51.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
|
|
5204
5127
|
case 7:
|
|
5205
|
-
return
|
|
5128
|
+
return _context51.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
|
|
5206
5129
|
case 8:
|
|
5207
5130
|
case "end":
|
|
5208
|
-
return
|
|
5131
|
+
return _context51.stop();
|
|
5209
5132
|
}
|
|
5210
|
-
},
|
|
5133
|
+
}, _callee51, this);
|
|
5211
5134
|
}));
|
|
5212
5135
|
function getShortNumberOrDeviceId() {
|
|
5213
5136
|
return _getShortNumberOrDeviceId.apply(this, arguments);
|
|
@@ -5234,16 +5157,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
5234
5157
|
}, {
|
|
5235
5158
|
key: "normalizeCheckoutSubmitData",
|
|
5236
5159
|
value: function () {
|
|
5237
|
-
var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5160
|
+
var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(data, title) {
|
|
5238
5161
|
var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
|
|
5239
|
-
return _regeneratorRuntime().wrap(function
|
|
5240
|
-
while (1) switch (
|
|
5162
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
5163
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
5241
5164
|
case 0:
|
|
5242
5165
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
5243
|
-
|
|
5166
|
+
_context52.next = 2;
|
|
5244
5167
|
break;
|
|
5245
5168
|
}
|
|
5246
|
-
return
|
|
5169
|
+
return _context52.abrupt("return", data);
|
|
5247
5170
|
case 2:
|
|
5248
5171
|
next = _objectSpread({}, data);
|
|
5249
5172
|
externalSaleNumber = next.external_sale_number;
|
|
@@ -5253,7 +5176,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5253
5176
|
delete next.vouchers;
|
|
5254
5177
|
hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
|
|
5255
5178
|
if (!hasCheckoutOrderNumbers) {
|
|
5256
|
-
|
|
5179
|
+
_context52.next = 11;
|
|
5257
5180
|
break;
|
|
5258
5181
|
}
|
|
5259
5182
|
this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
|
|
@@ -5263,10 +5186,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5263
5186
|
shop_order_number: next.shop_order_number,
|
|
5264
5187
|
shop_full_order_number: next.shop_full_order_number
|
|
5265
5188
|
});
|
|
5266
|
-
return
|
|
5189
|
+
return _context52.abrupt("return", next);
|
|
5267
5190
|
case 11:
|
|
5268
5191
|
if (!this.isBlankCheckoutValue(externalSaleNumber)) {
|
|
5269
|
-
|
|
5192
|
+
_context52.next = 14;
|
|
5270
5193
|
break;
|
|
5271
5194
|
}
|
|
5272
5195
|
if (shouldClearLocalOrderId) {
|
|
@@ -5275,10 +5198,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5275
5198
|
order_id: next.order_id
|
|
5276
5199
|
});
|
|
5277
5200
|
}
|
|
5278
|
-
return
|
|
5201
|
+
return _context52.abrupt("return", next);
|
|
5279
5202
|
case 14:
|
|
5280
5203
|
if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
|
|
5281
|
-
|
|
5204
|
+
_context52.next = 17;
|
|
5282
5205
|
break;
|
|
5283
5206
|
}
|
|
5284
5207
|
if (shouldClearLocalOrderId) {
|
|
@@ -5287,12 +5210,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
5287
5210
|
external_sale_number: externalSaleNumber
|
|
5288
5211
|
});
|
|
5289
5212
|
}
|
|
5290
|
-
return
|
|
5213
|
+
return _context52.abrupt("return", next);
|
|
5291
5214
|
case 17:
|
|
5292
|
-
|
|
5215
|
+
_context52.prev = 17;
|
|
5293
5216
|
localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
|
|
5294
5217
|
if (localOrder) {
|
|
5295
|
-
|
|
5218
|
+
_context52.next = 22;
|
|
5296
5219
|
break;
|
|
5297
5220
|
}
|
|
5298
5221
|
if (shouldClearLocalOrderId) {
|
|
@@ -5302,7 +5225,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5302
5225
|
localOrderFound: false
|
|
5303
5226
|
});
|
|
5304
5227
|
}
|
|
5305
|
-
return
|
|
5228
|
+
return _context52.abrupt("return", next);
|
|
5306
5229
|
case 22:
|
|
5307
5230
|
if (this.isBlankCheckoutValue(next.shop_order_number)) {
|
|
5308
5231
|
next.shop_order_number = localOrder.shop_order_number;
|
|
@@ -5319,21 +5242,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
5319
5242
|
shop_full_order_number: next.shop_full_order_number
|
|
5320
5243
|
});
|
|
5321
5244
|
// 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
|
|
5322
|
-
return
|
|
5245
|
+
return _context52.abrupt("return", next);
|
|
5323
5246
|
case 28:
|
|
5324
|
-
|
|
5325
|
-
|
|
5247
|
+
_context52.prev = 28;
|
|
5248
|
+
_context52.t0 = _context52["catch"](17);
|
|
5326
5249
|
this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
|
|
5327
5250
|
external_sale_number: externalSaleNumber,
|
|
5328
|
-
error: this.getUnknownErrorMessage(
|
|
5329
|
-
error_detail: this.normalizeUnknownError(
|
|
5251
|
+
error: this.getUnknownErrorMessage(_context52.t0),
|
|
5252
|
+
error_detail: this.normalizeUnknownError(_context52.t0)
|
|
5330
5253
|
});
|
|
5331
|
-
return
|
|
5254
|
+
return _context52.abrupt("return", next);
|
|
5332
5255
|
case 32:
|
|
5333
5256
|
case "end":
|
|
5334
|
-
return
|
|
5257
|
+
return _context52.stop();
|
|
5335
5258
|
}
|
|
5336
|
-
},
|
|
5259
|
+
}, _callee52, this, [[17, 28]]);
|
|
5337
5260
|
}));
|
|
5338
5261
|
function normalizeCheckoutSubmitData(_x56, _x57) {
|
|
5339
5262
|
return _normalizeCheckoutSubmitData.apply(this, arguments);
|
|
@@ -5343,79 +5266,79 @@ var Server = /*#__PURE__*/function () {
|
|
|
5343
5266
|
}, {
|
|
5344
5267
|
key: "ensureCheckoutOrderNumbers",
|
|
5345
5268
|
value: function () {
|
|
5346
|
-
var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5269
|
+
var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(data, title) {
|
|
5347
5270
|
var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
|
|
5348
|
-
return _regeneratorRuntime().wrap(function
|
|
5349
|
-
while (1) switch (
|
|
5271
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
5272
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
5350
5273
|
case 0:
|
|
5351
5274
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
5352
|
-
|
|
5275
|
+
_context53.next = 2;
|
|
5353
5276
|
break;
|
|
5354
5277
|
}
|
|
5355
|
-
return
|
|
5278
|
+
return _context53.abrupt("return", data);
|
|
5356
5279
|
case 2:
|
|
5357
5280
|
next = _objectSpread({}, data);
|
|
5358
5281
|
needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
|
|
5359
5282
|
needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
|
|
5360
5283
|
if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
|
|
5361
|
-
|
|
5284
|
+
_context53.next = 7;
|
|
5362
5285
|
break;
|
|
5363
5286
|
}
|
|
5364
|
-
return
|
|
5287
|
+
return _context53.abrupt("return", next);
|
|
5365
5288
|
case 7:
|
|
5366
5289
|
idGenerator = this.getIdGeneratorPlugin();
|
|
5367
5290
|
if (idGenerator) {
|
|
5368
|
-
|
|
5291
|
+
_context53.next = 11;
|
|
5369
5292
|
break;
|
|
5370
5293
|
}
|
|
5371
5294
|
this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
|
|
5372
5295
|
needsShopOrderNumber: needsShopOrderNumber,
|
|
5373
5296
|
needsShopFullOrderNumber: needsShopFullOrderNumber
|
|
5374
5297
|
});
|
|
5375
|
-
return
|
|
5298
|
+
return _context53.abrupt("return", next);
|
|
5376
5299
|
case 11:
|
|
5377
|
-
|
|
5300
|
+
_context53.prev = 11;
|
|
5378
5301
|
if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
|
|
5379
|
-
|
|
5302
|
+
_context53.next = 16;
|
|
5380
5303
|
break;
|
|
5381
5304
|
}
|
|
5382
|
-
|
|
5305
|
+
_context53.next = 15;
|
|
5383
5306
|
return idGenerator.generateShopOrderNumber({
|
|
5384
5307
|
biz: next.business_code || 'ticket'
|
|
5385
5308
|
});
|
|
5386
5309
|
case 15:
|
|
5387
|
-
next.shop_order_number =
|
|
5310
|
+
next.shop_order_number = _context53.sent;
|
|
5388
5311
|
case 16:
|
|
5389
5312
|
if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
|
|
5390
|
-
|
|
5313
|
+
_context53.next = 20;
|
|
5391
5314
|
break;
|
|
5392
5315
|
}
|
|
5393
|
-
|
|
5316
|
+
_context53.next = 19;
|
|
5394
5317
|
return idGenerator.generateReceiptId({
|
|
5395
5318
|
biz: next.business_code || 'ticket'
|
|
5396
5319
|
});
|
|
5397
5320
|
case 19:
|
|
5398
|
-
next.shop_full_order_number =
|
|
5321
|
+
next.shop_full_order_number = _context53.sent;
|
|
5399
5322
|
case 20:
|
|
5400
5323
|
this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
|
|
5401
5324
|
shop_order_number: next.shop_order_number,
|
|
5402
5325
|
shop_full_order_number: next.shop_full_order_number
|
|
5403
5326
|
});
|
|
5404
|
-
|
|
5327
|
+
_context53.next = 26;
|
|
5405
5328
|
break;
|
|
5406
5329
|
case 23:
|
|
5407
|
-
|
|
5408
|
-
|
|
5330
|
+
_context53.prev = 23;
|
|
5331
|
+
_context53.t0 = _context53["catch"](11);
|
|
5409
5332
|
this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
|
|
5410
|
-
error:
|
|
5333
|
+
error: _context53.t0 instanceof Error ? _context53.t0.message : String(_context53.t0)
|
|
5411
5334
|
});
|
|
5412
5335
|
case 26:
|
|
5413
|
-
return
|
|
5336
|
+
return _context53.abrupt("return", next);
|
|
5414
5337
|
case 27:
|
|
5415
5338
|
case "end":
|
|
5416
|
-
return
|
|
5339
|
+
return _context53.stop();
|
|
5417
5340
|
}
|
|
5418
|
-
},
|
|
5341
|
+
}, _callee53, this, [[11, 23]]);
|
|
5419
5342
|
}));
|
|
5420
5343
|
function ensureCheckoutOrderNumbers(_x58, _x59) {
|
|
5421
5344
|
return _ensureCheckoutOrderNumbers.apply(this, arguments);
|
|
@@ -5425,27 +5348,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
5425
5348
|
}, {
|
|
5426
5349
|
key: "dispatchCheckoutSyncTask",
|
|
5427
5350
|
value: function () {
|
|
5428
|
-
var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5351
|
+
var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
|
|
5429
5352
|
var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
|
|
5430
|
-
return _regeneratorRuntime().wrap(function
|
|
5431
|
-
while (1) switch (
|
|
5353
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5354
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
5432
5355
|
case 0:
|
|
5433
5356
|
this.registerDeviceTaskActions();
|
|
5434
5357
|
deviceTask = this.getDeviceTaskPlugin();
|
|
5435
|
-
|
|
5358
|
+
_context54.next = 4;
|
|
5436
5359
|
return this.getShortNumberOrDeviceId();
|
|
5437
5360
|
case 4:
|
|
5438
|
-
debugDeviceId =
|
|
5361
|
+
debugDeviceId = _context54.sent;
|
|
5439
5362
|
debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
|
|
5440
5363
|
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
5441
|
-
|
|
5364
|
+
_context54.next = 9;
|
|
5442
5365
|
break;
|
|
5443
5366
|
}
|
|
5444
5367
|
this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
|
|
5445
|
-
return
|
|
5368
|
+
return _context54.abrupt("return");
|
|
5446
5369
|
case 9:
|
|
5447
|
-
|
|
5448
|
-
|
|
5370
|
+
_context54.prev = 9;
|
|
5371
|
+
_context54.next = 12;
|
|
5449
5372
|
return deviceTask.dispatch({
|
|
5450
5373
|
action: 'sync_sales',
|
|
5451
5374
|
device_id: debugDeviceId,
|
|
@@ -5463,25 +5386,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
5463
5386
|
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)
|
|
5464
5387
|
});
|
|
5465
5388
|
case 12:
|
|
5466
|
-
result =
|
|
5389
|
+
result = _context54.sent;
|
|
5467
5390
|
this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
|
|
5468
5391
|
uuid: result === null || result === void 0 ? void 0 : result.uuid,
|
|
5469
5392
|
status: result === null || result === void 0 ? void 0 : result.status,
|
|
5470
5393
|
reused: result === null || result === void 0 ? void 0 : result.reused
|
|
5471
5394
|
});
|
|
5472
|
-
|
|
5395
|
+
_context54.next = 19;
|
|
5473
5396
|
break;
|
|
5474
5397
|
case 16:
|
|
5475
|
-
|
|
5476
|
-
|
|
5398
|
+
_context54.prev = 16;
|
|
5399
|
+
_context54.t0 = _context54["catch"](9);
|
|
5477
5400
|
this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
|
|
5478
|
-
error:
|
|
5401
|
+
error: _context54.t0 instanceof Error ? _context54.t0.message : String(_context54.t0)
|
|
5479
5402
|
});
|
|
5480
5403
|
case 19:
|
|
5481
5404
|
case "end":
|
|
5482
|
-
return
|
|
5405
|
+
return _context54.stop();
|
|
5483
5406
|
}
|
|
5484
|
-
},
|
|
5407
|
+
}, _callee54, this, [[9, 16]]);
|
|
5485
5408
|
}));
|
|
5486
5409
|
function dispatchCheckoutSyncTask(_x60) {
|
|
5487
5410
|
return _dispatchCheckoutSyncTask.apply(this, arguments);
|
|
@@ -5491,26 +5414,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
5491
5414
|
}, {
|
|
5492
5415
|
key: "dispatchPrintOtherReceiptTask",
|
|
5493
5416
|
value: function () {
|
|
5494
|
-
var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5417
|
+
var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
|
|
5495
5418
|
var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
|
|
5496
|
-
return _regeneratorRuntime().wrap(function
|
|
5497
|
-
while (1) switch (
|
|
5419
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5420
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
5498
5421
|
case 0:
|
|
5499
5422
|
deviceTask = this.getDeviceTaskPlugin();
|
|
5500
5423
|
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
5501
|
-
|
|
5424
|
+
_context55.next = 4;
|
|
5502
5425
|
break;
|
|
5503
5426
|
}
|
|
5504
5427
|
this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
|
|
5505
|
-
return
|
|
5428
|
+
return _context55.abrupt("return");
|
|
5506
5429
|
case 4:
|
|
5507
|
-
|
|
5430
|
+
_context55.prev = 4;
|
|
5508
5431
|
printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
|
|
5509
|
-
|
|
5432
|
+
_context55.next = 8;
|
|
5510
5433
|
return this.getShortNumberOrDeviceId();
|
|
5511
5434
|
case 8:
|
|
5512
|
-
deviceId =
|
|
5513
|
-
|
|
5435
|
+
deviceId = _context55.sent;
|
|
5436
|
+
_context55.next = 11;
|
|
5514
5437
|
return deviceTask.dispatch({
|
|
5515
5438
|
action: 'print_all',
|
|
5516
5439
|
device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
|
|
@@ -5537,19 +5460,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
5537
5460
|
source_id: printIdentity
|
|
5538
5461
|
});
|
|
5539
5462
|
case 11:
|
|
5540
|
-
|
|
5463
|
+
_context55.next = 16;
|
|
5541
5464
|
break;
|
|
5542
5465
|
case 13:
|
|
5543
|
-
|
|
5544
|
-
|
|
5466
|
+
_context55.prev = 13;
|
|
5467
|
+
_context55.t0 = _context55["catch"](4);
|
|
5545
5468
|
this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
|
|
5546
|
-
error:
|
|
5469
|
+
error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
|
|
5547
5470
|
});
|
|
5548
5471
|
case 16:
|
|
5549
5472
|
case "end":
|
|
5550
|
-
return
|
|
5473
|
+
return _context55.stop();
|
|
5551
5474
|
}
|
|
5552
|
-
},
|
|
5475
|
+
}, _callee55, this, [[4, 13]]);
|
|
5553
5476
|
}));
|
|
5554
5477
|
function dispatchPrintOtherReceiptTask(_x61) {
|
|
5555
5478
|
return _dispatchPrintOtherReceiptTask.apply(this, arguments);
|
|
@@ -5571,32 +5494,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
5571
5494
|
}, {
|
|
5572
5495
|
key: "dispatchLocalReceiptPrint",
|
|
5573
5496
|
value: function () {
|
|
5574
|
-
var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5497
|
+
var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
|
|
5575
5498
|
var _payment_info;
|
|
5576
5499
|
var printableOrder;
|
|
5577
|
-
return _regeneratorRuntime().wrap(function
|
|
5578
|
-
while (1) switch (
|
|
5500
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
5501
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
5579
5502
|
case 0:
|
|
5580
5503
|
if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
|
|
5581
|
-
|
|
5504
|
+
_context56.next = 2;
|
|
5582
5505
|
break;
|
|
5583
5506
|
}
|
|
5584
|
-
return
|
|
5507
|
+
return _context56.abrupt("return", {
|
|
5585
5508
|
printed: false,
|
|
5586
5509
|
order: params.order
|
|
5587
5510
|
});
|
|
5588
5511
|
case 2:
|
|
5589
|
-
|
|
5512
|
+
_context56.next = 4;
|
|
5590
5513
|
return this.withLocalSmallTicketData(params.order, {
|
|
5591
5514
|
requireFullyPaid: params.requireFullyPaid
|
|
5592
5515
|
});
|
|
5593
5516
|
case 4:
|
|
5594
|
-
printableOrder =
|
|
5517
|
+
printableOrder = _context56.sent;
|
|
5595
5518
|
if (hasSmallTicketData((_payment_info = printableOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data)) {
|
|
5596
|
-
|
|
5519
|
+
_context56.next = 7;
|
|
5597
5520
|
break;
|
|
5598
5521
|
}
|
|
5599
|
-
return
|
|
5522
|
+
return _context56.abrupt("return", {
|
|
5600
5523
|
printed: false,
|
|
5601
5524
|
order: printableOrder
|
|
5602
5525
|
});
|
|
@@ -5606,7 +5529,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5606
5529
|
printableOrder: printableOrder,
|
|
5607
5530
|
response: params.response
|
|
5608
5531
|
});
|
|
5609
|
-
|
|
5532
|
+
_context56.next = 10;
|
|
5610
5533
|
return this.dispatchPrintOtherReceiptTask({
|
|
5611
5534
|
checkoutData: params.checkoutData,
|
|
5612
5535
|
syncedOrder: printableOrder,
|
|
@@ -5615,15 +5538,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
5615
5538
|
isManualPrint: params.isManualPrint
|
|
5616
5539
|
});
|
|
5617
5540
|
case 10:
|
|
5618
|
-
return
|
|
5541
|
+
return _context56.abrupt("return", {
|
|
5619
5542
|
printed: true,
|
|
5620
5543
|
order: printableOrder
|
|
5621
5544
|
});
|
|
5622
5545
|
case 11:
|
|
5623
5546
|
case "end":
|
|
5624
|
-
return
|
|
5547
|
+
return _context56.stop();
|
|
5625
5548
|
}
|
|
5626
|
-
},
|
|
5549
|
+
}, _callee56, this);
|
|
5627
5550
|
}));
|
|
5628
5551
|
function dispatchLocalReceiptPrint(_x62) {
|
|
5629
5552
|
return _dispatchLocalReceiptPrint.apply(this, arguments);
|
|
@@ -5660,47 +5583,47 @@ var Server = /*#__PURE__*/function () {
|
|
|
5660
5583
|
}, {
|
|
5661
5584
|
key: "syncMachinecodeRedeemStatusToLocalOrder",
|
|
5662
5585
|
value: function () {
|
|
5663
|
-
var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5586
|
+
var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(data, ids, status) {
|
|
5664
5587
|
var _this$order3;
|
|
5665
5588
|
var title, lookup, localOrder, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
|
|
5666
|
-
return _regeneratorRuntime().wrap(function
|
|
5667
|
-
while (1) switch (
|
|
5589
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5590
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
5668
5591
|
case 0:
|
|
5669
5592
|
title = 'handleMachinecodeBatchMetadata';
|
|
5670
5593
|
lookup = this.resolveMachinecodeBatchMetadataLookup(data);
|
|
5671
5594
|
if (!(lookup === undefined)) {
|
|
5672
|
-
|
|
5595
|
+
_context57.next = 5;
|
|
5673
5596
|
break;
|
|
5674
5597
|
}
|
|
5675
5598
|
this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
5676
5599
|
batchSize: ids.length,
|
|
5677
5600
|
status: status
|
|
5678
5601
|
});
|
|
5679
|
-
return
|
|
5602
|
+
return _context57.abrupt("return");
|
|
5680
5603
|
case 5:
|
|
5681
5604
|
if ((_this$order3 = this.order) !== null && _this$order3 !== void 0 && _this$order3.getLocalOrderByLookup) {
|
|
5682
|
-
|
|
5605
|
+
_context57.next = 8;
|
|
5683
5606
|
break;
|
|
5684
5607
|
}
|
|
5685
5608
|
this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
5686
5609
|
lookup: lookup,
|
|
5687
5610
|
status: status
|
|
5688
5611
|
});
|
|
5689
|
-
return
|
|
5612
|
+
return _context57.abrupt("return");
|
|
5690
5613
|
case 8:
|
|
5691
|
-
|
|
5614
|
+
_context57.next = 10;
|
|
5692
5615
|
return this.order.getLocalOrderByLookup(lookup);
|
|
5693
5616
|
case 10:
|
|
5694
|
-
localOrder =
|
|
5617
|
+
localOrder = _context57.sent;
|
|
5695
5618
|
if (localOrder) {
|
|
5696
|
-
|
|
5619
|
+
_context57.next = 14;
|
|
5697
5620
|
break;
|
|
5698
5621
|
}
|
|
5699
5622
|
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
5700
5623
|
lookup: lookup,
|
|
5701
5624
|
status: status
|
|
5702
5625
|
});
|
|
5703
|
-
return
|
|
5626
|
+
return _context57.abrupt("return");
|
|
5704
5627
|
case 14:
|
|
5705
5628
|
voucherIdSet = new Set(ids.filter(function (id) {
|
|
5706
5629
|
return id !== undefined && id !== null && id !== '';
|
|
@@ -5708,14 +5631,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
5708
5631
|
return String(id);
|
|
5709
5632
|
}));
|
|
5710
5633
|
if (!(voucherIdSet.size === 0)) {
|
|
5711
|
-
|
|
5634
|
+
_context57.next = 18;
|
|
5712
5635
|
break;
|
|
5713
5636
|
}
|
|
5714
5637
|
this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
5715
5638
|
lookup: lookup,
|
|
5716
5639
|
status: status
|
|
5717
5640
|
});
|
|
5718
|
-
return
|
|
5641
|
+
return _context57.abrupt("return");
|
|
5719
5642
|
case 18:
|
|
5720
5643
|
vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
|
|
5721
5644
|
hasUpdatedVoucher = false;
|
|
@@ -5729,7 +5652,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5729
5652
|
});
|
|
5730
5653
|
});
|
|
5731
5654
|
if (hasUpdatedVoucher) {
|
|
5732
|
-
|
|
5655
|
+
_context57.next = 24;
|
|
5733
5656
|
break;
|
|
5734
5657
|
}
|
|
5735
5658
|
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
@@ -5737,13 +5660,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
5737
5660
|
voucher_ids: Array.from(voucherIdSet),
|
|
5738
5661
|
status: status
|
|
5739
5662
|
});
|
|
5740
|
-
return
|
|
5663
|
+
return _context57.abrupt("return");
|
|
5741
5664
|
case 24:
|
|
5742
5665
|
if (!(typeof this.order.overwriteExistingOrder === 'function')) {
|
|
5743
|
-
|
|
5666
|
+
_context57.next = 29;
|
|
5744
5667
|
break;
|
|
5745
5668
|
}
|
|
5746
|
-
|
|
5669
|
+
_context57.next = 27;
|
|
5747
5670
|
return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
|
|
5748
5671
|
vouchers: nextVouchers
|
|
5749
5672
|
}));
|
|
@@ -5753,13 +5676,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
5753
5676
|
updatedCount: voucherIdSet.size,
|
|
5754
5677
|
status: status
|
|
5755
5678
|
});
|
|
5756
|
-
return
|
|
5679
|
+
return _context57.abrupt("return");
|
|
5757
5680
|
case 29:
|
|
5758
5681
|
if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
|
|
5759
|
-
|
|
5682
|
+
_context57.next = 34;
|
|
5760
5683
|
break;
|
|
5761
5684
|
}
|
|
5762
|
-
|
|
5685
|
+
_context57.next = 32;
|
|
5763
5686
|
return this.order.markOrderSyncedByExternalSaleNumber({
|
|
5764
5687
|
externalSaleNumber: data.external_sale_number,
|
|
5765
5688
|
patch: {
|
|
@@ -5772,7 +5695,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5772
5695
|
updatedCount: voucherIdSet.size,
|
|
5773
5696
|
status: status
|
|
5774
5697
|
});
|
|
5775
|
-
return
|
|
5698
|
+
return _context57.abrupt("return");
|
|
5776
5699
|
case 34:
|
|
5777
5700
|
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"), {
|
|
5778
5701
|
lookup: lookup,
|
|
@@ -5780,9 +5703,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5780
5703
|
});
|
|
5781
5704
|
case 35:
|
|
5782
5705
|
case "end":
|
|
5783
|
-
return
|
|
5706
|
+
return _context57.stop();
|
|
5784
5707
|
}
|
|
5785
|
-
},
|
|
5708
|
+
}, _callee57, this);
|
|
5786
5709
|
}));
|
|
5787
5710
|
function syncMachinecodeRedeemStatusToLocalOrder(_x63, _x64, _x65) {
|
|
5788
5711
|
return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
|
|
@@ -5792,10 +5715,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5792
5715
|
}, {
|
|
5793
5716
|
key: "handleOrderCheckoutSubmit",
|
|
5794
5717
|
value: function () {
|
|
5795
|
-
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5718
|
+
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
|
|
5796
5719
|
var backendPath, data, title, normalizedData, checkoutData, pendingResult, _this$core$context2, pendingOrder, platform, isAndroid;
|
|
5797
|
-
return _regeneratorRuntime().wrap(function
|
|
5798
|
-
while (1) switch (
|
|
5720
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
5721
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
5799
5722
|
case 0:
|
|
5800
5723
|
backendPath = params.backendPath, data = params.data, title = params.title;
|
|
5801
5724
|
this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
|
|
@@ -5805,24 +5728,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
5805
5728
|
order_number: data === null || data === void 0 ? void 0 : data.order_number
|
|
5806
5729
|
});
|
|
5807
5730
|
if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
|
|
5808
|
-
|
|
5731
|
+
_context58.next = 4;
|
|
5809
5732
|
break;
|
|
5810
5733
|
}
|
|
5811
|
-
return
|
|
5734
|
+
return _context58.abrupt("return", this.handleSyncCheckoutSubmit({
|
|
5812
5735
|
backendPath: backendPath,
|
|
5813
5736
|
data: data,
|
|
5814
5737
|
title: title
|
|
5815
5738
|
}));
|
|
5816
5739
|
case 4:
|
|
5817
|
-
|
|
5740
|
+
_context58.next = 6;
|
|
5818
5741
|
return this.normalizeCheckoutSubmitData(data, title);
|
|
5819
5742
|
case 6:
|
|
5820
|
-
normalizedData =
|
|
5821
|
-
|
|
5743
|
+
normalizedData = _context58.sent;
|
|
5744
|
+
_context58.next = 9;
|
|
5822
5745
|
return this.ensureCheckoutOrderNumbers(normalizedData, title);
|
|
5823
5746
|
case 9:
|
|
5824
|
-
checkoutData =
|
|
5825
|
-
|
|
5747
|
+
checkoutData = _context58.sent;
|
|
5748
|
+
_context58.next = 12;
|
|
5826
5749
|
return this.handlePendingSyncCheckoutOrder({
|
|
5827
5750
|
backendPath: backendPath,
|
|
5828
5751
|
data: checkoutData,
|
|
@@ -5830,9 +5753,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5830
5753
|
reason: 'checkout 已转入设备任务同步'
|
|
5831
5754
|
});
|
|
5832
5755
|
case 12:
|
|
5833
|
-
pendingResult =
|
|
5756
|
+
pendingResult = _context58.sent;
|
|
5834
5757
|
if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
|
|
5835
|
-
|
|
5758
|
+
_context58.next = 22;
|
|
5836
5759
|
break;
|
|
5837
5760
|
}
|
|
5838
5761
|
pendingOrder = pendingResult.data;
|
|
@@ -5841,10 +5764,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5841
5764
|
if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && (
|
|
5842
5765
|
// TODO 这里先加个兼容,如果是安卓,则需要 type=virtual 才走打印,如果是苹果则无限制
|
|
5843
5766
|
isAndroid ? checkoutData.type === 'virtual' : true))) {
|
|
5844
|
-
|
|
5767
|
+
_context58.next = 20;
|
|
5845
5768
|
break;
|
|
5846
5769
|
}
|
|
5847
|
-
|
|
5770
|
+
_context58.next = 20;
|
|
5848
5771
|
return this.dispatchLocalReceiptPrint({
|
|
5849
5772
|
checkoutData: checkoutData,
|
|
5850
5773
|
order: pendingOrder,
|
|
@@ -5852,7 +5775,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5852
5775
|
requireFullyPaid: true
|
|
5853
5776
|
});
|
|
5854
5777
|
case 20:
|
|
5855
|
-
|
|
5778
|
+
_context58.next = 22;
|
|
5856
5779
|
return this.dispatchCheckoutSyncTask({
|
|
5857
5780
|
backendPath: backendPath,
|
|
5858
5781
|
data: checkoutData,
|
|
@@ -5860,21 +5783,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
5860
5783
|
});
|
|
5861
5784
|
case 22:
|
|
5862
5785
|
if (pendingResult.data.order_id) {
|
|
5863
|
-
|
|
5786
|
+
_context58.next = 24;
|
|
5864
5787
|
break;
|
|
5865
5788
|
}
|
|
5866
|
-
return
|
|
5789
|
+
return _context58.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
|
|
5867
5790
|
data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
|
|
5868
5791
|
order_id: pendingResult.data.external_sale_number
|
|
5869
5792
|
})
|
|
5870
5793
|
}));
|
|
5871
5794
|
case 24:
|
|
5872
|
-
return
|
|
5795
|
+
return _context58.abrupt("return", pendingResult);
|
|
5873
5796
|
case 25:
|
|
5874
5797
|
case "end":
|
|
5875
|
-
return
|
|
5798
|
+
return _context58.stop();
|
|
5876
5799
|
}
|
|
5877
|
-
},
|
|
5800
|
+
}, _callee58, this);
|
|
5878
5801
|
}));
|
|
5879
5802
|
function handleOrderCheckoutSubmit(_x66) {
|
|
5880
5803
|
return _handleOrderCheckoutSubmit.apply(this, arguments);
|
|
@@ -5884,27 +5807,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
5884
5807
|
}, {
|
|
5885
5808
|
key: "handleSyncCheckoutSubmit",
|
|
5886
5809
|
value: function () {
|
|
5887
|
-
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5810
|
+
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
|
|
5888
5811
|
var _this$app16;
|
|
5889
|
-
var backendPath, data, title, syncResult, _normalized$data, normalized,
|
|
5890
|
-
return _regeneratorRuntime().wrap(function
|
|
5891
|
-
while (1) switch (
|
|
5812
|
+
var backendPath, data, title, syncResult, _normalized$data, normalized, backendError, _normalized$data2, _normalized, message;
|
|
5813
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context59) {
|
|
5814
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
5892
5815
|
case 0:
|
|
5893
5816
|
backendPath = params.backendPath, data = params.data, title = params.title;
|
|
5894
5817
|
if ((_this$app16 = this.app) !== null && _this$app16 !== void 0 && (_this$app16 = _this$app16.request) !== null && _this$app16 !== void 0 && _this$app16.post) {
|
|
5895
|
-
|
|
5818
|
+
_context59.next = 4;
|
|
5896
5819
|
break;
|
|
5897
5820
|
}
|
|
5898
5821
|
this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
|
|
5899
|
-
return
|
|
5822
|
+
return _context59.abrupt("return", {
|
|
5900
5823
|
code: 500,
|
|
5901
5824
|
status: false,
|
|
5902
5825
|
message: 'app.request 不可用',
|
|
5903
5826
|
data: null
|
|
5904
5827
|
});
|
|
5905
5828
|
case 4:
|
|
5906
|
-
|
|
5907
|
-
|
|
5829
|
+
_context59.prev = 4;
|
|
5830
|
+
_context59.next = 7;
|
|
5908
5831
|
return this.runCheckoutSync({
|
|
5909
5832
|
backendPath: backendPath,
|
|
5910
5833
|
data: data,
|
|
@@ -5912,67 +5835,51 @@ var Server = /*#__PURE__*/function () {
|
|
|
5912
5835
|
persistCheckoutDataWithResponse: true
|
|
5913
5836
|
});
|
|
5914
5837
|
case 7:
|
|
5915
|
-
syncResult =
|
|
5838
|
+
syncResult = _context59.sent;
|
|
5916
5839
|
if (!syncResult.rejected) {
|
|
5917
|
-
|
|
5840
|
+
_context59.next = 11;
|
|
5918
5841
|
break;
|
|
5919
5842
|
}
|
|
5920
5843
|
normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
|
|
5921
|
-
return
|
|
5844
|
+
return _context59.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
|
|
5922
5845
|
status: false,
|
|
5923
5846
|
message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
|
|
5924
5847
|
data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
|
|
5925
5848
|
}));
|
|
5926
5849
|
case 11:
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
}
|
|
5933
|
-
_context60.next = 16;
|
|
5934
|
-
return this.dispatchLocalReceiptPrint({
|
|
5935
|
-
checkoutData: syncResult.checkoutData,
|
|
5936
|
-
order: syncedOrder,
|
|
5937
|
-
response: syncResult.normalizedResponse,
|
|
5938
|
-
requireFullyPaid: true,
|
|
5939
|
-
// print_all 的 type=0 是收据打印;不要沿用同步成功后的券/手环打印 type=99。
|
|
5940
|
-
isManualPrint: true
|
|
5941
|
-
});
|
|
5942
|
-
case 16:
|
|
5943
|
-
return _context60.abrupt("return", response);
|
|
5944
|
-
case 19:
|
|
5945
|
-
_context60.prev = 19;
|
|
5946
|
-
_context60.t0 = _context60["catch"](4);
|
|
5947
|
-
backendError = this.extractBackendErrorResponse(_context60.t0);
|
|
5850
|
+
return _context59.abrupt("return", this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder));
|
|
5851
|
+
case 14:
|
|
5852
|
+
_context59.prev = 14;
|
|
5853
|
+
_context59.t0 = _context59["catch"](4);
|
|
5854
|
+
backendError = this.extractBackendErrorResponse(_context59.t0);
|
|
5948
5855
|
if (!backendError) {
|
|
5949
|
-
|
|
5856
|
+
_context59.next = 20;
|
|
5950
5857
|
break;
|
|
5951
5858
|
}
|
|
5952
5859
|
_normalized = this.normalizeCheckoutResponse(backendError);
|
|
5953
|
-
return
|
|
5860
|
+
return _context59.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
|
|
5954
5861
|
status: false,
|
|
5955
5862
|
message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
|
|
5956
5863
|
data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
|
|
5957
5864
|
}));
|
|
5958
|
-
case
|
|
5959
|
-
message = this.getUnknownErrorMessage(
|
|
5865
|
+
case 20:
|
|
5866
|
+
message = this.getUnknownErrorMessage(_context59.t0);
|
|
5960
5867
|
this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
|
|
5961
5868
|
backendPath: backendPath,
|
|
5962
5869
|
error: message,
|
|
5963
|
-
error_detail: this.normalizeUnknownError(
|
|
5870
|
+
error_detail: this.normalizeUnknownError(_context59.t0)
|
|
5964
5871
|
});
|
|
5965
|
-
return
|
|
5872
|
+
return _context59.abrupt("return", {
|
|
5966
5873
|
code: 500,
|
|
5967
5874
|
status: false,
|
|
5968
5875
|
message: message,
|
|
5969
5876
|
data: null
|
|
5970
5877
|
});
|
|
5971
|
-
case
|
|
5878
|
+
case 23:
|
|
5972
5879
|
case "end":
|
|
5973
|
-
return
|
|
5880
|
+
return _context59.stop();
|
|
5974
5881
|
}
|
|
5975
|
-
},
|
|
5882
|
+
}, _callee59, this, [[4, 14]]);
|
|
5976
5883
|
}));
|
|
5977
5884
|
function handleSyncCheckoutSubmit(_x67) {
|
|
5978
5885
|
return _handleSyncCheckoutSubmit.apply(this, arguments);
|
|
@@ -5982,10 +5889,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5982
5889
|
}, {
|
|
5983
5890
|
key: "handleOrderDraftSubmit",
|
|
5984
5891
|
value: function () {
|
|
5985
|
-
var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5892
|
+
var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
|
|
5986
5893
|
var data, title, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
|
|
5987
|
-
return _regeneratorRuntime().wrap(function
|
|
5988
|
-
while (1) switch (
|
|
5894
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
5895
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
5989
5896
|
case 0:
|
|
5990
5897
|
data = params.data, title = params.title;
|
|
5991
5898
|
this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
|
|
@@ -5993,10 +5900,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5993
5900
|
external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
|
|
5994
5901
|
order_number: data === null || data === void 0 ? void 0 : data.order_number
|
|
5995
5902
|
});
|
|
5996
|
-
|
|
5903
|
+
_context60.next = 4;
|
|
5997
5904
|
return this.normalizeCheckoutSubmitData(data, title);
|
|
5998
5905
|
case 4:
|
|
5999
|
-
normalizedData =
|
|
5906
|
+
normalizedData = _context60.sent;
|
|
6000
5907
|
createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
6001
5908
|
draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
|
|
6002
5909
|
external_sale_number: normalizedData.external_sale_number || "LOCAL_DRAFT_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 10)),
|
|
@@ -6006,26 +5913,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
6006
5913
|
is_draft_order: 1
|
|
6007
5914
|
});
|
|
6008
5915
|
if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
|
|
6009
|
-
|
|
5916
|
+
_context60.next = 10;
|
|
6010
5917
|
break;
|
|
6011
5918
|
}
|
|
6012
5919
|
this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
|
|
6013
|
-
return
|
|
5920
|
+
return _context60.abrupt("return", {
|
|
6014
5921
|
code: 500,
|
|
6015
5922
|
status: false,
|
|
6016
5923
|
message: 'Order 模块不支持本地草稿写入',
|
|
6017
5924
|
data: null
|
|
6018
5925
|
});
|
|
6019
5926
|
case 10:
|
|
6020
|
-
|
|
6021
|
-
|
|
5927
|
+
_context60.prev = 10;
|
|
5928
|
+
_context60.next = 13;
|
|
6022
5929
|
return this.order.upsertLocalDraftOrders([draftOrder]);
|
|
6023
5930
|
case 13:
|
|
6024
5931
|
this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
|
|
6025
5932
|
order_id: draftOrder.order_id,
|
|
6026
5933
|
external_sale_number: draftOrder.external_sale_number
|
|
6027
5934
|
});
|
|
6028
|
-
return
|
|
5935
|
+
return _context60.abrupt("return", {
|
|
6029
5936
|
code: 200,
|
|
6030
5937
|
status: true,
|
|
6031
5938
|
message: '',
|
|
@@ -6037,13 +5944,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6037
5944
|
})
|
|
6038
5945
|
});
|
|
6039
5946
|
case 17:
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
errorMessage =
|
|
5947
|
+
_context60.prev = 17;
|
|
5948
|
+
_context60.t0 = _context60["catch"](10);
|
|
5949
|
+
errorMessage = _context60.t0 instanceof Error ? _context60.t0.message : String(_context60.t0);
|
|
6043
5950
|
this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
|
|
6044
5951
|
error: errorMessage
|
|
6045
5952
|
});
|
|
6046
|
-
return
|
|
5953
|
+
return _context60.abrupt("return", {
|
|
6047
5954
|
code: 500,
|
|
6048
5955
|
status: false,
|
|
6049
5956
|
message: errorMessage,
|
|
@@ -6051,9 +5958,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6051
5958
|
});
|
|
6052
5959
|
case 22:
|
|
6053
5960
|
case "end":
|
|
6054
|
-
return
|
|
5961
|
+
return _context60.stop();
|
|
6055
5962
|
}
|
|
6056
|
-
},
|
|
5963
|
+
}, _callee60, this, [[10, 17]]);
|
|
6057
5964
|
}));
|
|
6058
5965
|
function handleOrderDraftSubmit(_x68) {
|
|
6059
5966
|
return _handleOrderDraftSubmit.apply(this, arguments);
|
|
@@ -6063,26 +5970,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
6063
5970
|
}, {
|
|
6064
5971
|
key: "handlePendingSyncCheckoutOrder",
|
|
6065
5972
|
value: function () {
|
|
6066
|
-
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6067
|
-
var
|
|
5973
|
+
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
|
|
5974
|
+
var _this12 = this;
|
|
6068
5975
|
var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
|
|
6069
|
-
return _regeneratorRuntime().wrap(function
|
|
6070
|
-
while (1) switch (
|
|
5976
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
5977
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
6071
5978
|
case 0:
|
|
6072
5979
|
backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason;
|
|
6073
|
-
|
|
5980
|
+
_context61.next = 3;
|
|
6074
5981
|
return this.buildPendingSyncCheckoutOrder(data);
|
|
6075
5982
|
case 3:
|
|
6076
|
-
pendingOrder =
|
|
5983
|
+
pendingOrder = _context61.sent;
|
|
6077
5984
|
if (pendingOrder) {
|
|
6078
|
-
|
|
5985
|
+
_context61.next = 7;
|
|
6079
5986
|
break;
|
|
6080
5987
|
}
|
|
6081
5988
|
this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
|
|
6082
5989
|
backendPath: backendPath,
|
|
6083
5990
|
reason: reason
|
|
6084
5991
|
});
|
|
6085
|
-
return
|
|
5992
|
+
return _context61.abrupt("return", {
|
|
6086
5993
|
code: 500,
|
|
6087
5994
|
status: false,
|
|
6088
5995
|
message: '订单缺少本地存储标识,无法写入待同步队列',
|
|
@@ -6090,22 +5997,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
6090
5997
|
});
|
|
6091
5998
|
case 7:
|
|
6092
5999
|
if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
|
|
6093
|
-
|
|
6000
|
+
_context61.next = 10;
|
|
6094
6001
|
break;
|
|
6095
6002
|
}
|
|
6096
6003
|
this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
|
|
6097
6004
|
backendPath: backendPath,
|
|
6098
6005
|
reason: reason
|
|
6099
6006
|
});
|
|
6100
|
-
return
|
|
6007
|
+
return _context61.abrupt("return", {
|
|
6101
6008
|
code: 500,
|
|
6102
6009
|
status: false,
|
|
6103
6010
|
message: 'Order 模块不支持本地待同步写入',
|
|
6104
6011
|
data: null
|
|
6105
6012
|
});
|
|
6106
6013
|
case 10:
|
|
6107
|
-
|
|
6108
|
-
|
|
6014
|
+
_context61.prev = 10;
|
|
6015
|
+
_context61.next = 13;
|
|
6109
6016
|
return this.order.upsertPendingSyncOrders([pendingOrder]);
|
|
6110
6017
|
case 13:
|
|
6111
6018
|
this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
|
|
@@ -6117,9 +6024,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6117
6024
|
});
|
|
6118
6025
|
changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
|
|
6119
6026
|
var _payment$metadata;
|
|
6120
|
-
return sum +
|
|
6027
|
+
return sum + _this12.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
|
|
6121
6028
|
}, 0);
|
|
6122
|
-
return
|
|
6029
|
+
return _context61.abrupt("return", {
|
|
6123
6030
|
code: 200,
|
|
6124
6031
|
status: true,
|
|
6125
6032
|
message: '',
|
|
@@ -6134,15 +6041,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
6134
6041
|
})
|
|
6135
6042
|
});
|
|
6136
6043
|
case 18:
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
errorMessage =
|
|
6044
|
+
_context61.prev = 18;
|
|
6045
|
+
_context61.t0 = _context61["catch"](10);
|
|
6046
|
+
errorMessage = _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0);
|
|
6140
6047
|
this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
|
|
6141
6048
|
backendPath: backendPath,
|
|
6142
6049
|
reason: reason,
|
|
6143
6050
|
error: errorMessage
|
|
6144
6051
|
});
|
|
6145
|
-
return
|
|
6052
|
+
return _context61.abrupt("return", {
|
|
6146
6053
|
code: 500,
|
|
6147
6054
|
status: false,
|
|
6148
6055
|
message: errorMessage,
|
|
@@ -6150,9 +6057,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6150
6057
|
});
|
|
6151
6058
|
case 23:
|
|
6152
6059
|
case "end":
|
|
6153
|
-
return
|
|
6060
|
+
return _context61.stop();
|
|
6154
6061
|
}
|
|
6155
|
-
},
|
|
6062
|
+
}, _callee61, this, [[10, 18]]);
|
|
6156
6063
|
}));
|
|
6157
6064
|
function handlePendingSyncCheckoutOrder(_x69) {
|
|
6158
6065
|
return _handlePendingSyncCheckoutOrder.apply(this, arguments);
|
|
@@ -6162,42 +6069,42 @@ var Server = /*#__PURE__*/function () {
|
|
|
6162
6069
|
}, {
|
|
6163
6070
|
key: "buildPendingSyncCheckoutOrder",
|
|
6164
6071
|
value: function () {
|
|
6165
|
-
var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6072
|
+
var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(data) {
|
|
6166
6073
|
var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
|
|
6167
|
-
return _regeneratorRuntime().wrap(function
|
|
6168
|
-
while (1) switch (
|
|
6074
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
6075
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
6169
6076
|
case 0:
|
|
6170
6077
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
6171
|
-
|
|
6078
|
+
_context62.next = 2;
|
|
6172
6079
|
break;
|
|
6173
6080
|
}
|
|
6174
|
-
return
|
|
6081
|
+
return _context62.abrupt("return", null);
|
|
6175
6082
|
case 2:
|
|
6176
6083
|
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 !== '';
|
|
6177
6084
|
if (hasStorageKey) {
|
|
6178
|
-
|
|
6085
|
+
_context62.next = 5;
|
|
6179
6086
|
break;
|
|
6180
6087
|
}
|
|
6181
|
-
return
|
|
6088
|
+
return _context62.abrupt("return", null);
|
|
6182
6089
|
case 5:
|
|
6183
6090
|
pendingOrder = _objectSpread(_objectSpread({}, data), {}, {
|
|
6184
6091
|
need_sync: 1,
|
|
6185
6092
|
is_draft_order: 0
|
|
6186
6093
|
});
|
|
6187
|
-
|
|
6094
|
+
_context62.next = 8;
|
|
6188
6095
|
return this.buildSmallTicketProductMap(pendingOrder);
|
|
6189
6096
|
case 8:
|
|
6190
|
-
productMap =
|
|
6097
|
+
productMap = _context62.sent;
|
|
6191
6098
|
orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
|
|
6192
|
-
return
|
|
6099
|
+
return _context62.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
|
|
6193
6100
|
requireFullyPaid: true,
|
|
6194
6101
|
productMap: productMap
|
|
6195
6102
|
}));
|
|
6196
6103
|
case 11:
|
|
6197
6104
|
case "end":
|
|
6198
|
-
return
|
|
6105
|
+
return _context62.stop();
|
|
6199
6106
|
}
|
|
6200
|
-
},
|
|
6107
|
+
}, _callee62, this);
|
|
6201
6108
|
}));
|
|
6202
6109
|
function buildPendingSyncCheckoutOrder(_x70) {
|
|
6203
6110
|
return _buildPendingSyncCheckoutOrder.apply(this, arguments);
|
|
@@ -6247,13 +6154,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6247
6154
|
}, {
|
|
6248
6155
|
key: "sumPaidOrderPayments",
|
|
6249
6156
|
value: function sumPaidOrderPayments(payments) {
|
|
6250
|
-
var
|
|
6157
|
+
var _this13 = this;
|
|
6251
6158
|
if (!Array.isArray(payments)) return 0;
|
|
6252
6159
|
return payments.reduce(function (sum, payment) {
|
|
6253
6160
|
var _payment$amount;
|
|
6254
6161
|
var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
|
|
6255
6162
|
if (status !== 'paid') return sum;
|
|
6256
|
-
return sum +
|
|
6163
|
+
return sum + _this13.toAmountNumber((_payment$amount = payment === null || payment === void 0 ? void 0 : payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment === null || payment === void 0 ? void 0 : payment.origin_amount);
|
|
6257
6164
|
}, 0);
|
|
6258
6165
|
}
|
|
6259
6166
|
}, {
|
|
@@ -6267,12 +6174,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
6267
6174
|
}, {
|
|
6268
6175
|
key: "buildSmallTicketProductMap",
|
|
6269
6176
|
value: function () {
|
|
6270
|
-
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6177
|
+
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(order) {
|
|
6271
6178
|
var _this$products3,
|
|
6272
|
-
|
|
6179
|
+
_this14 = this;
|
|
6273
6180
|
var products, productIdSet, productIds, entries;
|
|
6274
|
-
return _regeneratorRuntime().wrap(function
|
|
6275
|
-
while (1) switch (
|
|
6181
|
+
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
6182
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
6276
6183
|
case 0:
|
|
6277
6184
|
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
|
|
6278
6185
|
productIdSet = new Set();
|
|
@@ -6294,45 +6201,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
6294
6201
|
});
|
|
6295
6202
|
productIds = Array.from(productIdSet);
|
|
6296
6203
|
if (!(!productIds.length || typeof ((_this$products3 = this.products) === null || _this$products3 === void 0 ? void 0 : _this$products3.getProductById) !== 'function')) {
|
|
6297
|
-
|
|
6204
|
+
_context64.next = 6;
|
|
6298
6205
|
break;
|
|
6299
6206
|
}
|
|
6300
|
-
return
|
|
6207
|
+
return _context64.abrupt("return", {});
|
|
6301
6208
|
case 6:
|
|
6302
|
-
|
|
6209
|
+
_context64.next = 8;
|
|
6303
6210
|
return Promise.all(productIds.map( /*#__PURE__*/function () {
|
|
6304
|
-
var _ref67 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6305
|
-
var
|
|
6306
|
-
return _regeneratorRuntime().wrap(function
|
|
6307
|
-
while (1) switch (
|
|
6211
|
+
var _ref67 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(id) {
|
|
6212
|
+
var _this14$products, _this14$products$getP, product;
|
|
6213
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
6214
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
6308
6215
|
case 0:
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
return (
|
|
6216
|
+
_context63.prev = 0;
|
|
6217
|
+
_context63.next = 3;
|
|
6218
|
+
return (_this14$products = _this14.products) === null || _this14$products === void 0 || (_this14$products$getP = _this14$products.getProductById) === null || _this14$products$getP === void 0 ? void 0 : _this14$products$getP.call(_this14$products, Number(id));
|
|
6312
6219
|
case 3:
|
|
6313
|
-
product =
|
|
6314
|
-
return
|
|
6220
|
+
product = _context63.sent;
|
|
6221
|
+
return _context63.abrupt("return", product ? [String(id), product] : null);
|
|
6315
6222
|
case 7:
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6223
|
+
_context63.prev = 7;
|
|
6224
|
+
_context63.t0 = _context63["catch"](0);
|
|
6225
|
+
_this14.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
|
|
6319
6226
|
product_id: id,
|
|
6320
|
-
error:
|
|
6227
|
+
error: _context63.t0 instanceof Error ? _context63.t0.message : String(_context63.t0)
|
|
6321
6228
|
});
|
|
6322
|
-
return
|
|
6229
|
+
return _context63.abrupt("return", null);
|
|
6323
6230
|
case 11:
|
|
6324
6231
|
case "end":
|
|
6325
|
-
return
|
|
6232
|
+
return _context63.stop();
|
|
6326
6233
|
}
|
|
6327
|
-
},
|
|
6234
|
+
}, _callee63, null, [[0, 7]]);
|
|
6328
6235
|
}));
|
|
6329
6236
|
return function (_x72) {
|
|
6330
6237
|
return _ref67.apply(this, arguments);
|
|
6331
6238
|
};
|
|
6332
6239
|
}()));
|
|
6333
6240
|
case 8:
|
|
6334
|
-
entries =
|
|
6335
|
-
return
|
|
6241
|
+
entries = _context64.sent;
|
|
6242
|
+
return _context64.abrupt("return", entries.reduce(function (map, entry) {
|
|
6336
6243
|
if (!entry) return map;
|
|
6337
6244
|
var _entry = _slicedToArray(entry, 2),
|
|
6338
6245
|
id = _entry[0],
|
|
@@ -6342,9 +6249,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6342
6249
|
}, {}));
|
|
6343
6250
|
case 10:
|
|
6344
6251
|
case "end":
|
|
6345
|
-
return
|
|
6252
|
+
return _context64.stop();
|
|
6346
6253
|
}
|
|
6347
|
-
},
|
|
6254
|
+
}, _callee64, this);
|
|
6348
6255
|
}));
|
|
6349
6256
|
function buildSmallTicketProductMap(_x71) {
|
|
6350
6257
|
return _buildSmallTicketProductMap.apply(this, arguments);
|
|
@@ -6376,38 +6283,38 @@ var Server = /*#__PURE__*/function () {
|
|
|
6376
6283
|
}, {
|
|
6377
6284
|
key: "buildSalesDetailProductSnapshotMap",
|
|
6378
6285
|
value: function () {
|
|
6379
|
-
var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6286
|
+
var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(order) {
|
|
6380
6287
|
var _this$products4;
|
|
6381
6288
|
var productIds, getSnapshots;
|
|
6382
|
-
return _regeneratorRuntime().wrap(function
|
|
6383
|
-
while (1) switch (
|
|
6289
|
+
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
6290
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
6384
6291
|
case 0:
|
|
6385
6292
|
productIds = this.collectSalesDetailProductIds(order);
|
|
6386
6293
|
getSnapshots = (_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductSnapshotsByIds;
|
|
6387
6294
|
if (!(!productIds.length || typeof getSnapshots !== 'function')) {
|
|
6388
|
-
|
|
6295
|
+
_context65.next = 4;
|
|
6389
6296
|
break;
|
|
6390
6297
|
}
|
|
6391
|
-
return
|
|
6298
|
+
return _context65.abrupt("return", {});
|
|
6392
6299
|
case 4:
|
|
6393
|
-
|
|
6394
|
-
|
|
6300
|
+
_context65.prev = 4;
|
|
6301
|
+
_context65.next = 7;
|
|
6395
6302
|
return getSnapshots.call(this.products, productIds);
|
|
6396
6303
|
case 7:
|
|
6397
|
-
return
|
|
6304
|
+
return _context65.abrupt("return", _context65.sent);
|
|
6398
6305
|
case 10:
|
|
6399
|
-
|
|
6400
|
-
|
|
6306
|
+
_context65.prev = 10;
|
|
6307
|
+
_context65.t0 = _context65["catch"](4);
|
|
6401
6308
|
this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
|
|
6402
6309
|
product_ids: productIds,
|
|
6403
|
-
error:
|
|
6310
|
+
error: _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0)
|
|
6404
6311
|
});
|
|
6405
|
-
return
|
|
6312
|
+
return _context65.abrupt("return", {});
|
|
6406
6313
|
case 14:
|
|
6407
6314
|
case "end":
|
|
6408
|
-
return
|
|
6315
|
+
return _context65.stop();
|
|
6409
6316
|
}
|
|
6410
|
-
},
|
|
6317
|
+
}, _callee65, this, [[4, 10]]);
|
|
6411
6318
|
}));
|
|
6412
6319
|
function buildSalesDetailProductSnapshotMap(_x73) {
|
|
6413
6320
|
return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
|
|
@@ -6465,51 +6372,51 @@ var Server = /*#__PURE__*/function () {
|
|
|
6465
6372
|
}, {
|
|
6466
6373
|
key: "withSalesDetailProductSnapshots",
|
|
6467
6374
|
value: function () {
|
|
6468
|
-
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6469
|
-
var
|
|
6375
|
+
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(order) {
|
|
6376
|
+
var _this15 = this;
|
|
6470
6377
|
var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
|
|
6471
|
-
return _regeneratorRuntime().wrap(function
|
|
6472
|
-
while (1) switch (
|
|
6378
|
+
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
6379
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
6473
6380
|
case 0:
|
|
6474
6381
|
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
|
|
6475
6382
|
if (products !== null && products !== void 0 && products.length) {
|
|
6476
|
-
|
|
6383
|
+
_context66.next = 3;
|
|
6477
6384
|
break;
|
|
6478
6385
|
}
|
|
6479
|
-
return
|
|
6386
|
+
return _context66.abrupt("return", order);
|
|
6480
6387
|
case 3:
|
|
6481
|
-
|
|
6388
|
+
_context66.next = 5;
|
|
6482
6389
|
return this.buildSalesDetailProductSnapshotMap(order);
|
|
6483
6390
|
case 5:
|
|
6484
|
-
snapshotMap =
|
|
6391
|
+
snapshotMap = _context66.sent;
|
|
6485
6392
|
if (Object.keys(snapshotMap).length) {
|
|
6486
|
-
|
|
6393
|
+
_context66.next = 8;
|
|
6487
6394
|
break;
|
|
6488
6395
|
}
|
|
6489
|
-
return
|
|
6396
|
+
return _context66.abrupt("return", order);
|
|
6490
6397
|
case 8:
|
|
6491
6398
|
hasChanged = false;
|
|
6492
6399
|
enrichedProducts = products.map(function (product) {
|
|
6493
|
-
var productWithBundleSnapshots =
|
|
6494
|
-
var nextProduct =
|
|
6400
|
+
var productWithBundleSnapshots = _this15.withBundleCatalogSnapshots(product, snapshotMap);
|
|
6401
|
+
var nextProduct = _this15.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
|
|
6495
6402
|
if (nextProduct !== product) hasChanged = true;
|
|
6496
6403
|
return nextProduct;
|
|
6497
6404
|
});
|
|
6498
6405
|
if (hasChanged) {
|
|
6499
|
-
|
|
6406
|
+
_context66.next = 12;
|
|
6500
6407
|
break;
|
|
6501
6408
|
}
|
|
6502
|
-
return
|
|
6409
|
+
return _context66.abrupt("return", order);
|
|
6503
6410
|
case 12:
|
|
6504
6411
|
enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
|
|
6505
6412
|
products: enrichedProducts
|
|
6506
6413
|
});
|
|
6507
|
-
return
|
|
6414
|
+
return _context66.abrupt("return", enrichedOrder);
|
|
6508
6415
|
case 14:
|
|
6509
6416
|
case "end":
|
|
6510
|
-
return
|
|
6417
|
+
return _context66.stop();
|
|
6511
6418
|
}
|
|
6512
|
-
},
|
|
6419
|
+
}, _callee66, this);
|
|
6513
6420
|
}));
|
|
6514
6421
|
function withSalesDetailProductSnapshots(_x74) {
|
|
6515
6422
|
return _withSalesDetailProductSnapshots.apply(this, arguments);
|
|
@@ -6519,13 +6426,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6519
6426
|
}, {
|
|
6520
6427
|
key: "withPendingSyncProductTitles",
|
|
6521
6428
|
value: function withPendingSyncProductTitles(order, productMap) {
|
|
6522
|
-
var
|
|
6429
|
+
var _this16 = this;
|
|
6523
6430
|
var products = Array.isArray(order.products) ? order.products : null;
|
|
6524
6431
|
if (!(products !== null && products !== void 0 && products.length)) return order;
|
|
6525
6432
|
return _objectSpread(_objectSpread({}, order), {}, {
|
|
6526
6433
|
products: products.map(function (product) {
|
|
6527
6434
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
6528
|
-
product_title:
|
|
6435
|
+
product_title: _this16.buildProductTitleSnapshot(product, productMap)
|
|
6529
6436
|
});
|
|
6530
6437
|
})
|
|
6531
6438
|
});
|
|
@@ -6536,7 +6443,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6536
6443
|
var _product$product_id4,
|
|
6537
6444
|
_product$product,
|
|
6538
6445
|
_fallbackProduct$prod,
|
|
6539
|
-
|
|
6446
|
+
_this17 = this;
|
|
6540
6447
|
var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
|
|
6541
6448
|
var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
|
|
6542
6449
|
var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
|
|
@@ -6544,7 +6451,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6544
6451
|
var currentLocale = this.getProductTitleSnapshotCurrentLocale();
|
|
6545
6452
|
var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
|
|
6546
6453
|
return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
|
|
6547
|
-
snapshot[key] =
|
|
6454
|
+
snapshot[key] = _this17.resolveProductTitleValue(ownTitle, key, currentLocale) || _this17.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
|
|
6548
6455
|
return snapshot;
|
|
6549
6456
|
}, {});
|
|
6550
6457
|
}
|
|
@@ -6642,50 +6549,50 @@ var Server = /*#__PURE__*/function () {
|
|
|
6642
6549
|
}, {
|
|
6643
6550
|
key: "enrichPaymentNamesByCode",
|
|
6644
6551
|
value: function () {
|
|
6645
|
-
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6646
|
-
var
|
|
6647
|
-
var payments, hasMissingName, paymentModule, payMethods, nameByCode,
|
|
6648
|
-
return _regeneratorRuntime().wrap(function
|
|
6649
|
-
while (1) switch (
|
|
6552
|
+
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(order) {
|
|
6553
|
+
var _this18 = this;
|
|
6554
|
+
var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator13, _step13, method, codeKey, name, hasResolvedName, enrichedPayments;
|
|
6555
|
+
return _regeneratorRuntime().wrap(function _callee67$(_context67) {
|
|
6556
|
+
while (1) switch (_context67.prev = _context67.next) {
|
|
6650
6557
|
case 0:
|
|
6651
6558
|
payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
|
|
6652
6559
|
hasMissingName = payments.some(function (payment) {
|
|
6653
|
-
return
|
|
6560
|
+
return _this18.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this18.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
|
|
6654
6561
|
});
|
|
6655
6562
|
if (hasMissingName) {
|
|
6656
|
-
|
|
6563
|
+
_context67.next = 4;
|
|
6657
6564
|
break;
|
|
6658
6565
|
}
|
|
6659
|
-
return
|
|
6566
|
+
return _context67.abrupt("return", order);
|
|
6660
6567
|
case 4:
|
|
6661
|
-
|
|
6662
|
-
|
|
6568
|
+
_context67.prev = 4;
|
|
6569
|
+
_context67.next = 7;
|
|
6663
6570
|
return this.getPaymentRouteModule();
|
|
6664
6571
|
case 7:
|
|
6665
|
-
paymentModule =
|
|
6666
|
-
|
|
6572
|
+
paymentModule = _context67.sent;
|
|
6573
|
+
_context67.next = 10;
|
|
6667
6574
|
return paymentModule.getPayMethodListAsync();
|
|
6668
6575
|
case 10:
|
|
6669
|
-
payMethods =
|
|
6576
|
+
payMethods = _context67.sent;
|
|
6670
6577
|
nameByCode = new Map();
|
|
6671
|
-
|
|
6578
|
+
_iterator13 = _createForOfIteratorHelper(payMethods || []);
|
|
6672
6579
|
try {
|
|
6673
|
-
for (
|
|
6674
|
-
method =
|
|
6580
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
6581
|
+
method = _step13.value;
|
|
6675
6582
|
codeKey = this.getPaymentCodeKey(method === null || method === void 0 ? void 0 : method.code);
|
|
6676
6583
|
name = this.resolveFirstProductTitleValue(method === null || method === void 0 ? void 0 : method.name);
|
|
6677
6584
|
if (codeKey && name) nameByCode.set(codeKey, name);
|
|
6678
6585
|
}
|
|
6679
6586
|
} catch (err) {
|
|
6680
|
-
|
|
6587
|
+
_iterator13.e(err);
|
|
6681
6588
|
} finally {
|
|
6682
|
-
|
|
6589
|
+
_iterator13.f();
|
|
6683
6590
|
}
|
|
6684
6591
|
hasResolvedName = false;
|
|
6685
6592
|
enrichedPayments = payments.map(function (payment) {
|
|
6686
|
-
if (!
|
|
6687
|
-
if (!
|
|
6688
|
-
var name = nameByCode.get(
|
|
6593
|
+
if (!_this18.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
|
|
6594
|
+
if (!_this18.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
|
|
6595
|
+
var name = nameByCode.get(_this18.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
|
|
6689
6596
|
if (!name) return payment;
|
|
6690
6597
|
hasResolvedName = true;
|
|
6691
6598
|
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
@@ -6693,26 +6600,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
6693
6600
|
});
|
|
6694
6601
|
});
|
|
6695
6602
|
if (hasResolvedName) {
|
|
6696
|
-
|
|
6603
|
+
_context67.next = 18;
|
|
6697
6604
|
break;
|
|
6698
6605
|
}
|
|
6699
|
-
return
|
|
6606
|
+
return _context67.abrupt("return", order);
|
|
6700
6607
|
case 18:
|
|
6701
|
-
return
|
|
6608
|
+
return _context67.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
|
|
6702
6609
|
payments: enrichedPayments
|
|
6703
6610
|
}));
|
|
6704
6611
|
case 21:
|
|
6705
|
-
|
|
6706
|
-
|
|
6612
|
+
_context67.prev = 21;
|
|
6613
|
+
_context67.t0 = _context67["catch"](4);
|
|
6707
6614
|
this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
|
|
6708
|
-
error:
|
|
6615
|
+
error: _context67.t0 instanceof Error ? _context67.t0.message : String(_context67.t0)
|
|
6709
6616
|
});
|
|
6710
|
-
return
|
|
6617
|
+
return _context67.abrupt("return", order);
|
|
6711
6618
|
case 25:
|
|
6712
6619
|
case "end":
|
|
6713
|
-
return
|
|
6620
|
+
return _context67.stop();
|
|
6714
6621
|
}
|
|
6715
|
-
},
|
|
6622
|
+
}, _callee67, this, [[4, 21]]);
|
|
6716
6623
|
}));
|
|
6717
6624
|
function enrichPaymentNamesByCode(_x75) {
|
|
6718
6625
|
return _enrichPaymentNamesByCode.apply(this, arguments);
|
|
@@ -6722,64 +6629,64 @@ var Server = /*#__PURE__*/function () {
|
|
|
6722
6629
|
}, {
|
|
6723
6630
|
key: "withLocalSmallTicketData",
|
|
6724
6631
|
value: function () {
|
|
6725
|
-
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6632
|
+
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(order, options) {
|
|
6726
6633
|
var _options$productMap, enrichedOrder, productMap, smallTicketData;
|
|
6727
|
-
return _regeneratorRuntime().wrap(function
|
|
6728
|
-
while (1) switch (
|
|
6634
|
+
return _regeneratorRuntime().wrap(function _callee68$(_context68) {
|
|
6635
|
+
while (1) switch (_context68.prev = _context68.next) {
|
|
6729
6636
|
case 0:
|
|
6730
6637
|
if (this.shouldBuildSmallTicketData(order)) {
|
|
6731
|
-
|
|
6638
|
+
_context68.next = 2;
|
|
6732
6639
|
break;
|
|
6733
6640
|
}
|
|
6734
|
-
return
|
|
6641
|
+
return _context68.abrupt("return", order);
|
|
6735
6642
|
case 2:
|
|
6736
6643
|
if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
|
|
6737
|
-
|
|
6644
|
+
_context68.next = 4;
|
|
6738
6645
|
break;
|
|
6739
6646
|
}
|
|
6740
|
-
return
|
|
6647
|
+
return _context68.abrupt("return", order);
|
|
6741
6648
|
case 4:
|
|
6742
|
-
|
|
6743
|
-
|
|
6649
|
+
_context68.prev = 4;
|
|
6650
|
+
_context68.next = 7;
|
|
6744
6651
|
return this.enrichPaymentNamesByCode(order);
|
|
6745
6652
|
case 7:
|
|
6746
|
-
enrichedOrder =
|
|
6653
|
+
enrichedOrder = _context68.sent;
|
|
6747
6654
|
if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
|
|
6748
|
-
|
|
6655
|
+
_context68.next = 12;
|
|
6749
6656
|
break;
|
|
6750
6657
|
}
|
|
6751
|
-
|
|
6752
|
-
|
|
6658
|
+
_context68.t0 = _options$productMap;
|
|
6659
|
+
_context68.next = 15;
|
|
6753
6660
|
break;
|
|
6754
6661
|
case 12:
|
|
6755
|
-
|
|
6662
|
+
_context68.next = 14;
|
|
6756
6663
|
return this.buildSmallTicketProductMap(enrichedOrder);
|
|
6757
6664
|
case 14:
|
|
6758
|
-
|
|
6665
|
+
_context68.t0 = _context68.sent;
|
|
6759
6666
|
case 15:
|
|
6760
|
-
productMap =
|
|
6667
|
+
productMap = _context68.t0;
|
|
6761
6668
|
smallTicketData = buildSmallTicketData({
|
|
6762
6669
|
order: enrichedOrder,
|
|
6763
6670
|
shopInfo: this.getSmallTicketShopInfo(),
|
|
6764
6671
|
productMap: productMap
|
|
6765
6672
|
});
|
|
6766
|
-
return
|
|
6673
|
+
return _context68.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
|
|
6767
6674
|
payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
|
|
6768
6675
|
small_ticket_data: smallTicketData
|
|
6769
6676
|
})
|
|
6770
6677
|
}));
|
|
6771
6678
|
case 20:
|
|
6772
|
-
|
|
6773
|
-
|
|
6679
|
+
_context68.prev = 20;
|
|
6680
|
+
_context68.t1 = _context68["catch"](4);
|
|
6774
6681
|
this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
|
|
6775
|
-
error:
|
|
6682
|
+
error: _context68.t1 instanceof Error ? _context68.t1.message : String(_context68.t1)
|
|
6776
6683
|
});
|
|
6777
|
-
return
|
|
6684
|
+
return _context68.abrupt("return", order);
|
|
6778
6685
|
case 24:
|
|
6779
6686
|
case "end":
|
|
6780
|
-
return
|
|
6687
|
+
return _context68.stop();
|
|
6781
6688
|
}
|
|
6782
|
-
},
|
|
6689
|
+
}, _callee68, this, [[4, 20]]);
|
|
6783
6690
|
}));
|
|
6784
6691
|
function withLocalSmallTicketData(_x76, _x77) {
|
|
6785
6692
|
return _withLocalSmallTicketData.apply(this, arguments);
|
|
@@ -6843,22 +6750,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
6843
6750
|
}, {
|
|
6844
6751
|
key: "handleUpdateLocalOrdersBatch",
|
|
6845
6752
|
value: (function () {
|
|
6846
|
-
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6753
|
+
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(orderIds) {
|
|
6847
6754
|
var _this$app17;
|
|
6848
|
-
var existedBefore,
|
|
6849
|
-
return _regeneratorRuntime().wrap(function
|
|
6850
|
-
while (1) switch (
|
|
6755
|
+
var existedBefore, _iterator14, _step14, id, fetched, message, fetchedMap, _iterator15, _step15, order, oid, freshOrders, succeedIds, failed, _iterator16, _step16, _id, fresh, _message2, overwritten, inserted;
|
|
6756
|
+
return _regeneratorRuntime().wrap(function _callee69$(_context69) {
|
|
6757
|
+
while (1) switch (_context69.prev = _context69.next) {
|
|
6851
6758
|
case 0:
|
|
6852
6759
|
this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
|
|
6853
6760
|
count: orderIds.length,
|
|
6854
6761
|
orderIds: orderIds
|
|
6855
6762
|
});
|
|
6856
6763
|
if (this.order) {
|
|
6857
|
-
|
|
6764
|
+
_context69.next = 4;
|
|
6858
6765
|
break;
|
|
6859
6766
|
}
|
|
6860
6767
|
this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
|
|
6861
|
-
return
|
|
6768
|
+
return _context69.abrupt("return", {
|
|
6862
6769
|
code: 500,
|
|
6863
6770
|
status: false,
|
|
6864
6771
|
message: 'Order 模块未注册',
|
|
@@ -6866,11 +6773,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6866
6773
|
});
|
|
6867
6774
|
case 4:
|
|
6868
6775
|
if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && _this$app17.request) {
|
|
6869
|
-
|
|
6776
|
+
_context69.next = 7;
|
|
6870
6777
|
break;
|
|
6871
6778
|
}
|
|
6872
6779
|
this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
|
|
6873
|
-
return
|
|
6780
|
+
return _context69.abrupt("return", {
|
|
6874
6781
|
code: 500,
|
|
6875
6782
|
status: false,
|
|
6876
6783
|
message: 'app.request 不可用',
|
|
@@ -6879,35 +6786,35 @@ var Server = /*#__PURE__*/function () {
|
|
|
6879
6786
|
case 7:
|
|
6880
6787
|
// 拉取前先记录"本地是否已存在",用于区分 overwritten / inserted
|
|
6881
6788
|
existedBefore = new Map();
|
|
6882
|
-
|
|
6789
|
+
_iterator14 = _createForOfIteratorHelper(orderIds);
|
|
6883
6790
|
try {
|
|
6884
|
-
for (
|
|
6885
|
-
id =
|
|
6791
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
6792
|
+
id = _step14.value;
|
|
6886
6793
|
existedBefore.set(id, !!this.order.getOrderByOrderId(id));
|
|
6887
6794
|
}
|
|
6888
6795
|
|
|
6889
6796
|
// 走 orderDataSource 的批量 HTTP 通道,一次请求拉回多笔详情
|
|
6890
6797
|
} catch (err) {
|
|
6891
|
-
|
|
6798
|
+
_iterator14.e(err);
|
|
6892
6799
|
} finally {
|
|
6893
|
-
|
|
6800
|
+
_iterator14.f();
|
|
6894
6801
|
}
|
|
6895
6802
|
fetched = [];
|
|
6896
|
-
|
|
6897
|
-
|
|
6803
|
+
_context69.prev = 11;
|
|
6804
|
+
_context69.next = 14;
|
|
6898
6805
|
return this.order.fetchOrdersByHttp(orderIds);
|
|
6899
6806
|
case 14:
|
|
6900
|
-
fetched =
|
|
6901
|
-
|
|
6807
|
+
fetched = _context69.sent;
|
|
6808
|
+
_context69.next = 22;
|
|
6902
6809
|
break;
|
|
6903
6810
|
case 17:
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
message =
|
|
6811
|
+
_context69.prev = 17;
|
|
6812
|
+
_context69.t0 = _context69["catch"](11);
|
|
6813
|
+
message = _context69.t0 instanceof Error ? _context69.t0.message : String(_context69.t0);
|
|
6907
6814
|
this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
|
|
6908
6815
|
message: message
|
|
6909
6816
|
});
|
|
6910
|
-
return
|
|
6817
|
+
return _context69.abrupt("return", {
|
|
6911
6818
|
code: 500,
|
|
6912
6819
|
status: false,
|
|
6913
6820
|
message: message,
|
|
@@ -6916,45 +6823,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
6916
6823
|
case 22:
|
|
6917
6824
|
// 按返回结果中的 order_id 建索引,未命中即视为单笔失败
|
|
6918
6825
|
fetchedMap = new Map();
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6826
|
+
_iterator15 = _createForOfIteratorHelper(fetched);
|
|
6827
|
+
_context69.prev = 24;
|
|
6828
|
+
_iterator15.s();
|
|
6922
6829
|
case 26:
|
|
6923
|
-
if ((
|
|
6924
|
-
|
|
6830
|
+
if ((_step15 = _iterator15.n()).done) {
|
|
6831
|
+
_context69.next = 34;
|
|
6925
6832
|
break;
|
|
6926
6833
|
}
|
|
6927
|
-
order =
|
|
6834
|
+
order = _step15.value;
|
|
6928
6835
|
oid = order === null || order === void 0 ? void 0 : order.order_id;
|
|
6929
6836
|
if (!(oid === undefined || oid === null)) {
|
|
6930
|
-
|
|
6837
|
+
_context69.next = 31;
|
|
6931
6838
|
break;
|
|
6932
6839
|
}
|
|
6933
|
-
return
|
|
6840
|
+
return _context69.abrupt("continue", 32);
|
|
6934
6841
|
case 31:
|
|
6935
6842
|
fetchedMap.set(String(oid), order);
|
|
6936
6843
|
case 32:
|
|
6937
|
-
|
|
6844
|
+
_context69.next = 26;
|
|
6938
6845
|
break;
|
|
6939
6846
|
case 34:
|
|
6940
|
-
|
|
6847
|
+
_context69.next = 39;
|
|
6941
6848
|
break;
|
|
6942
6849
|
case 36:
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6850
|
+
_context69.prev = 36;
|
|
6851
|
+
_context69.t1 = _context69["catch"](24);
|
|
6852
|
+
_iterator15.e(_context69.t1);
|
|
6946
6853
|
case 39:
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
return
|
|
6854
|
+
_context69.prev = 39;
|
|
6855
|
+
_iterator15.f();
|
|
6856
|
+
return _context69.finish(39);
|
|
6950
6857
|
case 42:
|
|
6951
6858
|
freshOrders = [];
|
|
6952
6859
|
succeedIds = [];
|
|
6953
6860
|
failed = [];
|
|
6954
|
-
|
|
6861
|
+
_iterator16 = _createForOfIteratorHelper(orderIds);
|
|
6955
6862
|
try {
|
|
6956
|
-
for (
|
|
6957
|
-
_id =
|
|
6863
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
6864
|
+
_id = _step16.value;
|
|
6958
6865
|
fresh = fetchedMap.get(_id);
|
|
6959
6866
|
if (fresh) {
|
|
6960
6867
|
freshOrders.push(fresh);
|
|
@@ -6967,28 +6874,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
6967
6874
|
}
|
|
6968
6875
|
}
|
|
6969
6876
|
} catch (err) {
|
|
6970
|
-
|
|
6877
|
+
_iterator16.e(err);
|
|
6971
6878
|
} finally {
|
|
6972
|
-
|
|
6879
|
+
_iterator16.f();
|
|
6973
6880
|
}
|
|
6974
6881
|
if (!(freshOrders.length > 0)) {
|
|
6975
|
-
|
|
6882
|
+
_context69.next = 58;
|
|
6976
6883
|
break;
|
|
6977
6884
|
}
|
|
6978
|
-
|
|
6979
|
-
|
|
6885
|
+
_context69.prev = 48;
|
|
6886
|
+
_context69.next = 51;
|
|
6980
6887
|
return this.order.upsertOrdersFromRemote(freshOrders);
|
|
6981
6888
|
case 51:
|
|
6982
|
-
|
|
6889
|
+
_context69.next = 58;
|
|
6983
6890
|
break;
|
|
6984
6891
|
case 53:
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
_message2 =
|
|
6892
|
+
_context69.prev = 53;
|
|
6893
|
+
_context69.t2 = _context69["catch"](48);
|
|
6894
|
+
_message2 = _context69.t2 instanceof Error ? _context69.t2.message : String(_context69.t2);
|
|
6988
6895
|
this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
|
|
6989
6896
|
message: _message2
|
|
6990
6897
|
});
|
|
6991
|
-
return
|
|
6898
|
+
return _context69.abrupt("return", {
|
|
6992
6899
|
code: 500,
|
|
6993
6900
|
status: false,
|
|
6994
6901
|
message: _message2,
|
|
@@ -7007,7 +6914,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7007
6914
|
insertedCount: inserted.length,
|
|
7008
6915
|
failedCount: failed.length
|
|
7009
6916
|
});
|
|
7010
|
-
return
|
|
6917
|
+
return _context69.abrupt("return", {
|
|
7011
6918
|
code: 200,
|
|
7012
6919
|
status: true,
|
|
7013
6920
|
message: '',
|
|
@@ -7019,9 +6926,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7019
6926
|
});
|
|
7020
6927
|
case 62:
|
|
7021
6928
|
case "end":
|
|
7022
|
-
return
|
|
6929
|
+
return _context69.stop();
|
|
7023
6930
|
}
|
|
7024
|
-
},
|
|
6931
|
+
}, _callee69, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
|
|
7025
6932
|
}));
|
|
7026
6933
|
function handleUpdateLocalOrdersBatch(_x78) {
|
|
7027
6934
|
return _handleUpdateLocalOrdersBatch.apply(this, arguments);
|
|
@@ -7044,11 +6951,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
7044
6951
|
var queryIndex = url.indexOf('?');
|
|
7045
6952
|
if (queryIndex < 0) return null;
|
|
7046
6953
|
var query = url.slice(queryIndex + 1);
|
|
7047
|
-
var
|
|
7048
|
-
|
|
6954
|
+
var _iterator17 = _createForOfIteratorHelper(query.split('&')),
|
|
6955
|
+
_step17;
|
|
7049
6956
|
try {
|
|
7050
|
-
for (
|
|
7051
|
-
var pair =
|
|
6957
|
+
for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
|
|
6958
|
+
var pair = _step17.value;
|
|
7052
6959
|
if (!pair) continue;
|
|
7053
6960
|
var _pair$split = pair.split('='),
|
|
7054
6961
|
_pair$split2 = _slicedToArray(_pair$split, 2),
|
|
@@ -7064,9 +6971,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7064
6971
|
}
|
|
7065
6972
|
}
|
|
7066
6973
|
} catch (err) {
|
|
7067
|
-
|
|
6974
|
+
_iterator17.e(err);
|
|
7068
6975
|
} finally {
|
|
7069
|
-
|
|
6976
|
+
_iterator17.f();
|
|
7070
6977
|
}
|
|
7071
6978
|
return null;
|
|
7072
6979
|
}
|
|
@@ -7267,10 +7174,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
7267
7174
|
value: function extractBackendErrorResponse(error) {
|
|
7268
7175
|
var _error$response3,
|
|
7269
7176
|
_error$response4,
|
|
7270
|
-
|
|
7177
|
+
_this19 = this;
|
|
7271
7178
|
var candidates = [error === null || error === void 0 || (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.body, error === null || error === void 0 ? void 0 : error.body];
|
|
7272
7179
|
return candidates.find(function (candidate) {
|
|
7273
|
-
return
|
|
7180
|
+
return _this19.isExplicitBackendErrorResponse(candidate);
|
|
7274
7181
|
}) || null;
|
|
7275
7182
|
}
|
|
7276
7183
|
}, {
|
|
@@ -7389,24 +7296,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
7389
7296
|
}, {
|
|
7390
7297
|
key: "recomputeAndNotifyFloorPlanQuery",
|
|
7391
7298
|
value: (function () {
|
|
7392
|
-
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7393
|
-
var
|
|
7394
|
-
return _regeneratorRuntime().wrap(function
|
|
7395
|
-
while (1) switch (
|
|
7299
|
+
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70() {
|
|
7300
|
+
var _iterator18, _step18, _step18$value, subscriberId, sub, result, errorMessage;
|
|
7301
|
+
return _regeneratorRuntime().wrap(function _callee70$(_context70) {
|
|
7302
|
+
while (1) switch (_context70.prev = _context70.next) {
|
|
7396
7303
|
case 0:
|
|
7397
7304
|
if (!(this.floorPlanQuerySubscribers.size === 0)) {
|
|
7398
|
-
|
|
7305
|
+
_context70.next = 2;
|
|
7399
7306
|
break;
|
|
7400
7307
|
}
|
|
7401
|
-
return
|
|
7308
|
+
return _context70.abrupt("return");
|
|
7402
7309
|
case 2:
|
|
7403
7310
|
this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
|
|
7404
7311
|
subscriberCount: this.floorPlanQuerySubscribers.size
|
|
7405
7312
|
});
|
|
7406
|
-
|
|
7313
|
+
_iterator18 = _createForOfIteratorHelper(this.floorPlanQuerySubscribers.entries());
|
|
7407
7314
|
try {
|
|
7408
|
-
for (
|
|
7409
|
-
|
|
7315
|
+
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
7316
|
+
_step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], sub = _step18$value[1];
|
|
7410
7317
|
try {
|
|
7411
7318
|
result = this.computeFloorPlanQueryResult(sub.context);
|
|
7412
7319
|
sub.callback(result);
|
|
@@ -7422,15 +7329,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
7422
7329
|
}
|
|
7423
7330
|
}
|
|
7424
7331
|
} catch (err) {
|
|
7425
|
-
|
|
7332
|
+
_iterator18.e(err);
|
|
7426
7333
|
} finally {
|
|
7427
|
-
|
|
7334
|
+
_iterator18.f();
|
|
7428
7335
|
}
|
|
7429
7336
|
case 5:
|
|
7430
7337
|
case "end":
|
|
7431
|
-
return
|
|
7338
|
+
return _context70.stop();
|
|
7432
7339
|
}
|
|
7433
|
-
},
|
|
7340
|
+
}, _callee70, this);
|
|
7434
7341
|
}));
|
|
7435
7342
|
function recomputeAndNotifyFloorPlanQuery() {
|
|
7436
7343
|
return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
|
|
@@ -7460,21 +7367,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
7460
7367
|
* filter 逻辑暂为 mock,仅记录参数
|
|
7461
7368
|
*/
|
|
7462
7369
|
function () {
|
|
7463
|
-
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7370
|
+
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(data) {
|
|
7464
7371
|
var rawList, result;
|
|
7465
|
-
return _regeneratorRuntime().wrap(function
|
|
7466
|
-
while (1) switch (
|
|
7372
|
+
return _regeneratorRuntime().wrap(function _callee71$(_context71) {
|
|
7373
|
+
while (1) switch (_context71.prev = _context71.next) {
|
|
7467
7374
|
case 0:
|
|
7468
7375
|
this.logInfo('computeOrderQueryResult: 开始过滤', {
|
|
7469
7376
|
data: data
|
|
7470
7377
|
});
|
|
7471
7378
|
console.log('[Server] computeOrderQueryResult', data);
|
|
7472
7379
|
if (this.order) {
|
|
7473
|
-
|
|
7380
|
+
_context71.next = 5;
|
|
7474
7381
|
break;
|
|
7475
7382
|
}
|
|
7476
7383
|
this.logError('computeOrderQueryResult: Order 模块未注册');
|
|
7477
|
-
return
|
|
7384
|
+
return _context71.abrupt("return", {
|
|
7478
7385
|
code: 500,
|
|
7479
7386
|
message: 'Order 模块未注册',
|
|
7480
7387
|
data: {
|
|
@@ -7504,7 +7411,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7504
7411
|
skip: result.skip,
|
|
7505
7412
|
rejected: result.rejected
|
|
7506
7413
|
});
|
|
7507
|
-
return
|
|
7414
|
+
return _context71.abrupt("return", {
|
|
7508
7415
|
code: 200,
|
|
7509
7416
|
data: result,
|
|
7510
7417
|
message: '',
|
|
@@ -7512,9 +7419,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7512
7419
|
});
|
|
7513
7420
|
case 11:
|
|
7514
7421
|
case "end":
|
|
7515
|
-
return
|
|
7422
|
+
return _context71.stop();
|
|
7516
7423
|
}
|
|
7517
|
-
},
|
|
7424
|
+
}, _callee71, this);
|
|
7518
7425
|
}));
|
|
7519
7426
|
function computeOrderQueryResult(_x79) {
|
|
7520
7427
|
return _computeOrderQueryResult.apply(this, arguments);
|
|
@@ -7529,17 +7436,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
7529
7436
|
}, {
|
|
7530
7437
|
key: "computeBookingQueryResult",
|
|
7531
7438
|
value: (function () {
|
|
7532
|
-
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7439
|
+
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(data) {
|
|
7533
7440
|
var rawOrders, result;
|
|
7534
|
-
return _regeneratorRuntime().wrap(function
|
|
7535
|
-
while (1) switch (
|
|
7441
|
+
return _regeneratorRuntime().wrap(function _callee72$(_context72) {
|
|
7442
|
+
while (1) switch (_context72.prev = _context72.next) {
|
|
7536
7443
|
case 0:
|
|
7537
7444
|
if (this.order) {
|
|
7538
|
-
|
|
7445
|
+
_context72.next = 3;
|
|
7539
7446
|
break;
|
|
7540
7447
|
}
|
|
7541
7448
|
this.logError('computeBookingQueryResult: Order 模块未注册');
|
|
7542
|
-
return
|
|
7449
|
+
return _context72.abrupt("return", {
|
|
7543
7450
|
code: 500,
|
|
7544
7451
|
message: 'Order 模块未注册',
|
|
7545
7452
|
data: {
|
|
@@ -7558,7 +7465,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7558
7465
|
size: result.size,
|
|
7559
7466
|
skip: result.skip
|
|
7560
7467
|
});
|
|
7561
|
-
return
|
|
7468
|
+
return _context72.abrupt("return", {
|
|
7562
7469
|
code: 200,
|
|
7563
7470
|
data: result,
|
|
7564
7471
|
message: '',
|
|
@@ -7566,9 +7473,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7566
7473
|
});
|
|
7567
7474
|
case 8:
|
|
7568
7475
|
case "end":
|
|
7569
|
-
return
|
|
7476
|
+
return _context72.stop();
|
|
7570
7477
|
}
|
|
7571
|
-
},
|
|
7478
|
+
}, _callee72, this);
|
|
7572
7479
|
}));
|
|
7573
7480
|
function computeBookingQueryResult(_x80) {
|
|
7574
7481
|
return _computeBookingQueryResult.apply(this, arguments);
|
|
@@ -7629,12 +7536,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
7629
7536
|
}, {
|
|
7630
7537
|
key: "computeProductQueryResult",
|
|
7631
7538
|
value: (function () {
|
|
7632
|
-
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7539
|
+
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(context, options) {
|
|
7633
7540
|
var _menu_list_ids$length3,
|
|
7634
|
-
|
|
7635
|
-
var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu,
|
|
7636
|
-
return _regeneratorRuntime().wrap(function
|
|
7637
|
-
while (1) switch (
|
|
7541
|
+
_this20 = this;
|
|
7542
|
+
var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
|
|
7543
|
+
return _regeneratorRuntime().wrap(function _callee73$(_context73) {
|
|
7544
|
+
while (1) switch (_context73.prev = _context73.next) {
|
|
7638
7545
|
case 0:
|
|
7639
7546
|
tTotal = performance.now();
|
|
7640
7547
|
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;
|
|
@@ -7661,28 +7568,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
7661
7568
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
7662
7569
|
});
|
|
7663
7570
|
if (this.products) {
|
|
7664
|
-
|
|
7571
|
+
_context73.next = 8;
|
|
7665
7572
|
break;
|
|
7666
7573
|
}
|
|
7667
7574
|
this.logError('computeProductQueryResult: Products 模块未注册');
|
|
7668
|
-
return
|
|
7575
|
+
return _context73.abrupt("return", {
|
|
7669
7576
|
message: 'Products 模块未注册',
|
|
7670
7577
|
data: this.buildProductQueryResultPayload([], 0)
|
|
7671
7578
|
});
|
|
7672
7579
|
case 8:
|
|
7673
7580
|
if (!(queryIds.length > 0)) {
|
|
7674
|
-
|
|
7581
|
+
_context73.next = 20;
|
|
7675
7582
|
break;
|
|
7676
7583
|
}
|
|
7677
7584
|
uniqueIds = Array.from(new Set(queryIds));
|
|
7678
7585
|
_tPrice = performance.now();
|
|
7679
|
-
|
|
7586
|
+
_context73.next = 13;
|
|
7680
7587
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
7681
7588
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
7682
7589
|
productIds: uniqueIds
|
|
7683
7590
|
});
|
|
7684
7591
|
case 13:
|
|
7685
|
-
productsWithPrice =
|
|
7592
|
+
productsWithPrice = _context73.sent;
|
|
7686
7593
|
perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
|
|
7687
7594
|
count: productsWithPrice.length,
|
|
7688
7595
|
ids: uniqueIds
|
|
@@ -7702,7 +7609,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7702
7609
|
ids: uniqueIds,
|
|
7703
7610
|
count: extensionFilteredProducts.length
|
|
7704
7611
|
});
|
|
7705
|
-
return
|
|
7612
|
+
return _context73.abrupt("return", {
|
|
7706
7613
|
code: 200,
|
|
7707
7614
|
data: this.buildProductQueryResultPayload(extensionFilteredProducts),
|
|
7708
7615
|
message: '',
|
|
@@ -7710,17 +7617,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
7710
7617
|
});
|
|
7711
7618
|
case 20:
|
|
7712
7619
|
if (!(product_id != null && Number.isFinite(Number(product_id)))) {
|
|
7713
|
-
|
|
7620
|
+
_context73.next = 32;
|
|
7714
7621
|
break;
|
|
7715
7622
|
}
|
|
7716
7623
|
pid = Number(product_id);
|
|
7717
7624
|
_tPrice2 = performance.now();
|
|
7718
|
-
|
|
7625
|
+
_context73.next = 25;
|
|
7719
7626
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
7720
7627
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
7721
7628
|
});
|
|
7722
7629
|
case 25:
|
|
7723
|
-
allProductsWithPrice =
|
|
7630
|
+
allProductsWithPrice = _context73.sent;
|
|
7724
7631
|
perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
|
|
7725
7632
|
count: allProductsWithPrice.length,
|
|
7726
7633
|
productId: pid
|
|
@@ -7740,7 +7647,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7740
7647
|
productId: pid,
|
|
7741
7648
|
found: !!item
|
|
7742
7649
|
});
|
|
7743
|
-
return
|
|
7650
|
+
return _context73.abrupt("return", {
|
|
7744
7651
|
code: 200,
|
|
7745
7652
|
data: item,
|
|
7746
7653
|
message: item ? '' : '商品不存在或未发布',
|
|
@@ -7748,16 +7655,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
7748
7655
|
});
|
|
7749
7656
|
case 32:
|
|
7750
7657
|
if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
|
|
7751
|
-
|
|
7658
|
+
_context73.next = 52;
|
|
7752
7659
|
break;
|
|
7753
7660
|
}
|
|
7754
7661
|
_tPrice3 = performance.now();
|
|
7755
|
-
|
|
7662
|
+
_context73.next = 36;
|
|
7756
7663
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
7757
7664
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
7758
7665
|
});
|
|
7759
7666
|
case 36:
|
|
7760
|
-
_filteredProducts2 =
|
|
7667
|
+
_filteredProducts2 = _context73.sent;
|
|
7761
7668
|
perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
|
|
7762
7669
|
count: _filteredProducts2.length,
|
|
7763
7670
|
extension_type: extension_type
|
|
@@ -7796,7 +7703,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7796
7703
|
filteredCount: _filteredProducts2.length,
|
|
7797
7704
|
extension_type: extension_type
|
|
7798
7705
|
});
|
|
7799
|
-
return
|
|
7706
|
+
return _context73.abrupt("return", {
|
|
7800
7707
|
code: 200,
|
|
7801
7708
|
data: this.buildProductQueryResultPayload(_filteredProducts2),
|
|
7802
7709
|
message: '',
|
|
@@ -7804,59 +7711,38 @@ var Server = /*#__PURE__*/function () {
|
|
|
7804
7711
|
});
|
|
7805
7712
|
case 52:
|
|
7806
7713
|
if (this.menu) {
|
|
7807
|
-
|
|
7714
|
+
_context73.next = 55;
|
|
7808
7715
|
break;
|
|
7809
7716
|
}
|
|
7810
7717
|
this.logError('computeProductQueryResult: Menu 模块未注册');
|
|
7811
|
-
return
|
|
7718
|
+
return _context73.abrupt("return", {
|
|
7812
7719
|
message: 'Menu 模块未注册',
|
|
7813
7720
|
data: this.buildProductQueryResultPayload([], 0)
|
|
7814
7721
|
});
|
|
7815
7722
|
case 55:
|
|
7816
7723
|
if (this.schedule) {
|
|
7817
|
-
|
|
7724
|
+
_context73.next = 58;
|
|
7818
7725
|
break;
|
|
7819
7726
|
}
|
|
7820
7727
|
this.logError('computeProductQueryResult: Schedule 模块未注册');
|
|
7821
|
-
return
|
|
7728
|
+
return _context73.abrupt("return", {
|
|
7822
7729
|
message: 'Schedule 模块未注册',
|
|
7823
7730
|
data: this.buildProductQueryResultPayload([], 0)
|
|
7824
7731
|
});
|
|
7825
7732
|
case 58:
|
|
7826
7733
|
activeMenuList = [];
|
|
7827
|
-
if (
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7734
|
+
if (menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0) {
|
|
7735
|
+
tMenu = performance.now();
|
|
7736
|
+
menuList = this.menu.getMenuByIds(menu_list_ids);
|
|
7737
|
+
activeMenuList = menuList.filter(function (menu) {
|
|
7738
|
+
var _this20$schedule;
|
|
7739
|
+
return ((_this20$schedule = _this20.schedule) === null || _this20$schedule === void 0 ? void 0 : _this20$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
|
|
7740
|
+
});
|
|
7741
|
+
perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
|
|
7742
|
+
totalMenu: menuList.length,
|
|
7743
|
+
activeMenu: activeMenuList.length
|
|
7836
7744
|
});
|
|
7837
|
-
};
|
|
7838
|
-
activeMenuList = getActiveMenus();
|
|
7839
|
-
_context74.t0 = !activeMenuList.length;
|
|
7840
|
-
if (!_context74.t0) {
|
|
7841
|
-
_context74.next = 68;
|
|
7842
|
-
break;
|
|
7843
|
-
}
|
|
7844
|
-
_context74.next = 67;
|
|
7845
|
-
return this.refreshMenuScheduleCacheAfterEmptyResult();
|
|
7846
|
-
case 67:
|
|
7847
|
-
_context74.t0 = _context74.sent;
|
|
7848
|
-
case 68:
|
|
7849
|
-
if (!_context74.t0) {
|
|
7850
|
-
_context74.next = 70;
|
|
7851
|
-
break;
|
|
7852
7745
|
}
|
|
7853
|
-
activeMenuList = getActiveMenus();
|
|
7854
|
-
case 70:
|
|
7855
|
-
perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
|
|
7856
|
-
totalMenu: menu_list_ids.length,
|
|
7857
|
-
activeMenu: activeMenuList.length
|
|
7858
|
-
});
|
|
7859
|
-
case 71:
|
|
7860
7746
|
tFilter = performance.now();
|
|
7861
7747
|
productScope = this.getProductScopeByMenuConfig(activeMenuList);
|
|
7862
7748
|
scopedProductIds = this.products.getProductIdsByScope(productScope);
|
|
@@ -7867,22 +7753,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
7867
7753
|
});
|
|
7868
7754
|
tPrice = performance.now();
|
|
7869
7755
|
if (!(scopedProductIds.length > 0)) {
|
|
7870
|
-
|
|
7756
|
+
_context73.next = 71;
|
|
7871
7757
|
break;
|
|
7872
7758
|
}
|
|
7873
|
-
|
|
7759
|
+
_context73.next = 68;
|
|
7874
7760
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
7875
7761
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
7876
7762
|
productIds: productScope.isAllProducts ? undefined : scopedProductIds
|
|
7877
7763
|
});
|
|
7878
|
-
case
|
|
7879
|
-
|
|
7880
|
-
|
|
7764
|
+
case 68:
|
|
7765
|
+
_context73.t0 = _context73.sent;
|
|
7766
|
+
_context73.next = 72;
|
|
7881
7767
|
break;
|
|
7882
|
-
case
|
|
7883
|
-
|
|
7884
|
-
case
|
|
7885
|
-
filteredProducts =
|
|
7768
|
+
case 71:
|
|
7769
|
+
_context73.t0 = [];
|
|
7770
|
+
case 72:
|
|
7771
|
+
filteredProducts = _context73.t0;
|
|
7886
7772
|
perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
|
|
7887
7773
|
count: filteredProducts.length,
|
|
7888
7774
|
scopedProductCount: scopedProductIds.length
|
|
@@ -7923,17 +7809,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
7923
7809
|
filteredCount: filteredProducts.length,
|
|
7924
7810
|
activeMenuCount: activeMenuList.length
|
|
7925
7811
|
});
|
|
7926
|
-
return
|
|
7812
|
+
return _context73.abrupt("return", {
|
|
7927
7813
|
code: 200,
|
|
7928
7814
|
data: this.buildProductQueryResultPayload(filteredProducts),
|
|
7929
7815
|
message: '',
|
|
7930
7816
|
status: true
|
|
7931
7817
|
});
|
|
7932
|
-
case
|
|
7818
|
+
case 88:
|
|
7933
7819
|
case "end":
|
|
7934
|
-
return
|
|
7820
|
+
return _context73.stop();
|
|
7935
7821
|
}
|
|
7936
|
-
},
|
|
7822
|
+
}, _callee73, this);
|
|
7937
7823
|
}));
|
|
7938
7824
|
function computeProductQueryResult(_x81, _x82) {
|
|
7939
7825
|
return _computeProductQueryResult.apply(this, arguments);
|
|
@@ -7971,70 +7857,70 @@ var Server = /*#__PURE__*/function () {
|
|
|
7971
7857
|
}, {
|
|
7972
7858
|
key: "recomputeAndNotifyProductQuery",
|
|
7973
7859
|
value: (function () {
|
|
7974
|
-
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7975
|
-
var
|
|
7976
|
-
return _regeneratorRuntime().wrap(function
|
|
7977
|
-
while (1) switch (
|
|
7860
|
+
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(options) {
|
|
7861
|
+
var _iterator19, _step19, _step19$value, subscriberId, subscriber, result, errorMessage;
|
|
7862
|
+
return _regeneratorRuntime().wrap(function _callee74$(_context74) {
|
|
7863
|
+
while (1) switch (_context74.prev = _context74.next) {
|
|
7978
7864
|
case 0:
|
|
7979
7865
|
if (!(this.productQuerySubscribers.size === 0)) {
|
|
7980
|
-
|
|
7866
|
+
_context74.next = 2;
|
|
7981
7867
|
break;
|
|
7982
7868
|
}
|
|
7983
|
-
return
|
|
7869
|
+
return _context74.abrupt("return");
|
|
7984
7870
|
case 2:
|
|
7985
7871
|
this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
|
|
7986
7872
|
subscriberCount: this.productQuerySubscribers.size,
|
|
7987
7873
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
7988
7874
|
});
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7875
|
+
_iterator19 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
|
|
7876
|
+
_context74.prev = 4;
|
|
7877
|
+
_iterator19.s();
|
|
7992
7878
|
case 6:
|
|
7993
|
-
if ((
|
|
7994
|
-
|
|
7879
|
+
if ((_step19 = _iterator19.n()).done) {
|
|
7880
|
+
_context74.next = 22;
|
|
7995
7881
|
break;
|
|
7996
7882
|
}
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
7883
|
+
_step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
|
|
7884
|
+
_context74.prev = 8;
|
|
7885
|
+
_context74.next = 11;
|
|
8000
7886
|
return this.computeProductQueryResult(subscriber.context, {
|
|
8001
7887
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
8002
7888
|
});
|
|
8003
7889
|
case 11:
|
|
8004
|
-
result =
|
|
7890
|
+
result = _context74.sent;
|
|
8005
7891
|
subscriber.callback(result);
|
|
8006
7892
|
this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
|
|
8007
7893
|
subscriberId: subscriberId
|
|
8008
7894
|
});
|
|
8009
|
-
|
|
7895
|
+
_context74.next = 20;
|
|
8010
7896
|
break;
|
|
8011
7897
|
case 16:
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
errorMessage =
|
|
7898
|
+
_context74.prev = 16;
|
|
7899
|
+
_context74.t0 = _context74["catch"](8);
|
|
7900
|
+
errorMessage = _context74.t0 instanceof Error ? _context74.t0.message : String(_context74.t0);
|
|
8015
7901
|
this.logError('recomputeAndNotifyProductQuery: 推送失败', {
|
|
8016
7902
|
subscriberId: subscriberId,
|
|
8017
7903
|
error: errorMessage
|
|
8018
7904
|
});
|
|
8019
7905
|
case 20:
|
|
8020
|
-
|
|
7906
|
+
_context74.next = 6;
|
|
8021
7907
|
break;
|
|
8022
7908
|
case 22:
|
|
8023
|
-
|
|
7909
|
+
_context74.next = 27;
|
|
8024
7910
|
break;
|
|
8025
7911
|
case 24:
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
7912
|
+
_context74.prev = 24;
|
|
7913
|
+
_context74.t1 = _context74["catch"](4);
|
|
7914
|
+
_iterator19.e(_context74.t1);
|
|
8029
7915
|
case 27:
|
|
8030
|
-
|
|
8031
|
-
|
|
8032
|
-
return
|
|
7916
|
+
_context74.prev = 27;
|
|
7917
|
+
_iterator19.f();
|
|
7918
|
+
return _context74.finish(27);
|
|
8033
7919
|
case 30:
|
|
8034
7920
|
case "end":
|
|
8035
|
-
return
|
|
7921
|
+
return _context74.stop();
|
|
8036
7922
|
}
|
|
8037
|
-
},
|
|
7923
|
+
}, _callee74, this, [[4, 24, 27, 30], [8, 16]]);
|
|
8038
7924
|
}));
|
|
8039
7925
|
function recomputeAndNotifyProductQuery(_x83) {
|
|
8040
7926
|
return _recomputeAndNotifyProductQuery.apply(this, arguments);
|
|
@@ -8048,37 +7934,37 @@ var Server = /*#__PURE__*/function () {
|
|
|
8048
7934
|
}, {
|
|
8049
7935
|
key: "recomputeAndNotifyOrderQuery",
|
|
8050
7936
|
value: (function () {
|
|
8051
|
-
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8052
|
-
var notifyStartAt,
|
|
8053
|
-
return _regeneratorRuntime().wrap(function
|
|
8054
|
-
while (1) switch (
|
|
7937
|
+
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75() {
|
|
7938
|
+
var notifyStartAt, _iterator20, _step20, _step20$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
|
|
7939
|
+
return _regeneratorRuntime().wrap(function _callee75$(_context75) {
|
|
7940
|
+
while (1) switch (_context75.prev = _context75.next) {
|
|
8055
7941
|
case 0:
|
|
8056
7942
|
if (!(this.orderQuerySubscribers.size === 0)) {
|
|
8057
|
-
|
|
7943
|
+
_context75.next = 2;
|
|
8058
7944
|
break;
|
|
8059
7945
|
}
|
|
8060
|
-
return
|
|
7946
|
+
return _context75.abrupt("return");
|
|
8061
7947
|
case 2:
|
|
8062
7948
|
notifyStartAt = Date.now();
|
|
8063
7949
|
this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
|
|
8064
7950
|
subscriberCount: this.orderQuerySubscribers.size,
|
|
8065
7951
|
notifyStartAt: new Date(notifyStartAt).toISOString()
|
|
8066
7952
|
});
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
7953
|
+
_iterator20 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
|
|
7954
|
+
_context75.prev = 5;
|
|
7955
|
+
_iterator20.s();
|
|
8070
7956
|
case 7:
|
|
8071
|
-
if ((
|
|
8072
|
-
|
|
7957
|
+
if ((_step20 = _iterator20.n()).done) {
|
|
7958
|
+
_context75.next = 27;
|
|
8073
7959
|
break;
|
|
8074
7960
|
}
|
|
8075
|
-
|
|
8076
|
-
|
|
7961
|
+
_step20$value = _slicedToArray(_step20.value, 2), subscriberId = _step20$value[0], subscriber = _step20$value[1];
|
|
7962
|
+
_context75.prev = 9;
|
|
8077
7963
|
computeStartAt = Date.now();
|
|
8078
|
-
|
|
7964
|
+
_context75.next = 13;
|
|
8079
7965
|
return this.computeOrderQueryResult(subscriber.context);
|
|
8080
7966
|
case 13:
|
|
8081
|
-
result =
|
|
7967
|
+
result = _context75.sent;
|
|
8082
7968
|
computeEndAt = Date.now();
|
|
8083
7969
|
callbackStartAt = Date.now();
|
|
8084
7970
|
subscriber.callback(result);
|
|
@@ -8089,30 +7975,30 @@ var Server = /*#__PURE__*/function () {
|
|
|
8089
7975
|
callbackDurationMs: callbackEndAt - callbackStartAt,
|
|
8090
7976
|
totalDurationMs: callbackEndAt - computeStartAt
|
|
8091
7977
|
});
|
|
8092
|
-
|
|
7978
|
+
_context75.next = 25;
|
|
8093
7979
|
break;
|
|
8094
7980
|
case 21:
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
errorMessage =
|
|
7981
|
+
_context75.prev = 21;
|
|
7982
|
+
_context75.t0 = _context75["catch"](9);
|
|
7983
|
+
errorMessage = _context75.t0 instanceof Error ? _context75.t0.message : String(_context75.t0);
|
|
8098
7984
|
this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
|
|
8099
7985
|
subscriberId: subscriberId,
|
|
8100
7986
|
error: errorMessage
|
|
8101
7987
|
});
|
|
8102
7988
|
case 25:
|
|
8103
|
-
|
|
7989
|
+
_context75.next = 7;
|
|
8104
7990
|
break;
|
|
8105
7991
|
case 27:
|
|
8106
|
-
|
|
7992
|
+
_context75.next = 32;
|
|
8107
7993
|
break;
|
|
8108
7994
|
case 29:
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
7995
|
+
_context75.prev = 29;
|
|
7996
|
+
_context75.t1 = _context75["catch"](5);
|
|
7997
|
+
_iterator20.e(_context75.t1);
|
|
8112
7998
|
case 32:
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
return
|
|
7999
|
+
_context75.prev = 32;
|
|
8000
|
+
_iterator20.f();
|
|
8001
|
+
return _context75.finish(32);
|
|
8116
8002
|
case 35:
|
|
8117
8003
|
notifyEndAt = Date.now();
|
|
8118
8004
|
this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
|
|
@@ -8121,9 +8007,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
8121
8007
|
});
|
|
8122
8008
|
case 37:
|
|
8123
8009
|
case "end":
|
|
8124
|
-
return
|
|
8010
|
+
return _context75.stop();
|
|
8125
8011
|
}
|
|
8126
|
-
},
|
|
8012
|
+
}, _callee75, this, [[5, 29, 32, 35], [9, 21]]);
|
|
8127
8013
|
}));
|
|
8128
8014
|
function recomputeAndNotifyOrderQuery() {
|
|
8129
8015
|
return _recomputeAndNotifyOrderQuery.apply(this, arguments);
|
|
@@ -8141,7 +8027,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8141
8027
|
}, {
|
|
8142
8028
|
key: "notifySalesSearchSubscribers",
|
|
8143
8029
|
value: function notifySalesSearchSubscribers(payload) {
|
|
8144
|
-
var
|
|
8030
|
+
var _this21 = this;
|
|
8145
8031
|
if (this.salesSearchSubscribers.size === 0) return;
|
|
8146
8032
|
var changedOrders = this.extractChangedOrdersFromPayload(payload);
|
|
8147
8033
|
if (changedOrders.length === 0) {
|
|
@@ -8150,42 +8036,42 @@ var Server = /*#__PURE__*/function () {
|
|
|
8150
8036
|
// 如果当前开启了 checkout 弹窗,先不进行刷新,下面的代码会导致在全局搜索页调用 bookingTicket.destroy()
|
|
8151
8037
|
// 导致模块被销毁 ,checkout 弹窗永远无法关闭
|
|
8152
8038
|
if (window.isPaymentModalPluginOpen) return;
|
|
8153
|
-
var
|
|
8154
|
-
|
|
8039
|
+
var _iterator21 = _createForOfIteratorHelper(this.salesSearchSubscribers.entries()),
|
|
8040
|
+
_step21;
|
|
8155
8041
|
try {
|
|
8156
|
-
var
|
|
8157
|
-
var
|
|
8158
|
-
subscriberId =
|
|
8159
|
-
subscriber =
|
|
8042
|
+
var _loop2 = function _loop2() {
|
|
8043
|
+
var _step21$value = _slicedToArray(_step21.value, 2),
|
|
8044
|
+
subscriberId = _step21$value[0],
|
|
8045
|
+
subscriber = _step21$value[1];
|
|
8160
8046
|
try {
|
|
8161
8047
|
var changedVisibleOrders = changedOrders.filter(function (order) {
|
|
8162
|
-
var orderId =
|
|
8048
|
+
var orderId = _this21.getSalesSearchOrderId(order);
|
|
8163
8049
|
return !!orderId && subscriber.visibleOrderIds.has(orderId);
|
|
8164
8050
|
});
|
|
8165
8051
|
if (changedVisibleOrders.length === 0) {
|
|
8166
8052
|
return 1; // continue
|
|
8167
8053
|
}
|
|
8168
|
-
subscriber.callback(
|
|
8169
|
-
|
|
8054
|
+
subscriber.callback(_this21.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
|
|
8055
|
+
_this21.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
|
|
8170
8056
|
subscriberId: subscriberId,
|
|
8171
8057
|
kind: subscriber.kind,
|
|
8172
8058
|
count: changedVisibleOrders.length
|
|
8173
8059
|
});
|
|
8174
8060
|
} catch (error) {
|
|
8175
8061
|
var errorMessage = error instanceof Error ? error.message : String(error);
|
|
8176
|
-
|
|
8062
|
+
_this21.logError('notifySalesSearchSubscribers: 推送失败', {
|
|
8177
8063
|
subscriberId: subscriberId,
|
|
8178
8064
|
error: errorMessage
|
|
8179
8065
|
});
|
|
8180
8066
|
}
|
|
8181
8067
|
};
|
|
8182
|
-
for (
|
|
8183
|
-
if (
|
|
8068
|
+
for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
|
|
8069
|
+
if (_loop2()) continue;
|
|
8184
8070
|
}
|
|
8185
8071
|
} catch (err) {
|
|
8186
|
-
|
|
8072
|
+
_iterator21.e(err);
|
|
8187
8073
|
} finally {
|
|
8188
|
-
|
|
8074
|
+
_iterator21.f();
|
|
8189
8075
|
}
|
|
8190
8076
|
}
|
|
8191
8077
|
|
|
@@ -8264,67 +8150,67 @@ var Server = /*#__PURE__*/function () {
|
|
|
8264
8150
|
}, {
|
|
8265
8151
|
key: "recomputeAndNotifyBookingQuery",
|
|
8266
8152
|
value: (function () {
|
|
8267
|
-
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8268
|
-
var
|
|
8269
|
-
return _regeneratorRuntime().wrap(function
|
|
8270
|
-
while (1) switch (
|
|
8153
|
+
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76() {
|
|
8154
|
+
var _iterator22, _step22, _step22$value, subscriberId, subscriber, result, errorMessage;
|
|
8155
|
+
return _regeneratorRuntime().wrap(function _callee76$(_context76) {
|
|
8156
|
+
while (1) switch (_context76.prev = _context76.next) {
|
|
8271
8157
|
case 0:
|
|
8272
8158
|
if (!(this.bookingQuerySubscribers.size === 0)) {
|
|
8273
|
-
|
|
8159
|
+
_context76.next = 2;
|
|
8274
8160
|
break;
|
|
8275
8161
|
}
|
|
8276
|
-
return
|
|
8162
|
+
return _context76.abrupt("return");
|
|
8277
8163
|
case 2:
|
|
8278
8164
|
this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
|
|
8279
8165
|
subscriberCount: this.bookingQuerySubscribers.size
|
|
8280
8166
|
});
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8167
|
+
_iterator22 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
|
|
8168
|
+
_context76.prev = 4;
|
|
8169
|
+
_iterator22.s();
|
|
8284
8170
|
case 6:
|
|
8285
|
-
if ((
|
|
8286
|
-
|
|
8171
|
+
if ((_step22 = _iterator22.n()).done) {
|
|
8172
|
+
_context76.next = 22;
|
|
8287
8173
|
break;
|
|
8288
8174
|
}
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8175
|
+
_step22$value = _slicedToArray(_step22.value, 2), subscriberId = _step22$value[0], subscriber = _step22$value[1];
|
|
8176
|
+
_context76.prev = 8;
|
|
8177
|
+
_context76.next = 11;
|
|
8292
8178
|
return this.computeBookingQueryResult(subscriber.context);
|
|
8293
8179
|
case 11:
|
|
8294
|
-
result =
|
|
8180
|
+
result = _context76.sent;
|
|
8295
8181
|
subscriber.callback(result);
|
|
8296
8182
|
this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
|
|
8297
8183
|
subscriberId: subscriberId
|
|
8298
8184
|
});
|
|
8299
|
-
|
|
8185
|
+
_context76.next = 20;
|
|
8300
8186
|
break;
|
|
8301
8187
|
case 16:
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
errorMessage =
|
|
8188
|
+
_context76.prev = 16;
|
|
8189
|
+
_context76.t0 = _context76["catch"](8);
|
|
8190
|
+
errorMessage = _context76.t0 instanceof Error ? _context76.t0.message : String(_context76.t0);
|
|
8305
8191
|
this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
|
|
8306
8192
|
subscriberId: subscriberId,
|
|
8307
8193
|
error: errorMessage
|
|
8308
8194
|
});
|
|
8309
8195
|
case 20:
|
|
8310
|
-
|
|
8196
|
+
_context76.next = 6;
|
|
8311
8197
|
break;
|
|
8312
8198
|
case 22:
|
|
8313
|
-
|
|
8199
|
+
_context76.next = 27;
|
|
8314
8200
|
break;
|
|
8315
8201
|
case 24:
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8202
|
+
_context76.prev = 24;
|
|
8203
|
+
_context76.t1 = _context76["catch"](4);
|
|
8204
|
+
_iterator22.e(_context76.t1);
|
|
8319
8205
|
case 27:
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
return
|
|
8206
|
+
_context76.prev = 27;
|
|
8207
|
+
_iterator22.f();
|
|
8208
|
+
return _context76.finish(27);
|
|
8323
8209
|
case 30:
|
|
8324
8210
|
case "end":
|
|
8325
|
-
return
|
|
8211
|
+
return _context76.stop();
|
|
8326
8212
|
}
|
|
8327
|
-
},
|
|
8213
|
+
}, _callee76, this, [[4, 24, 27, 30], [8, 16]]);
|
|
8328
8214
|
}));
|
|
8329
8215
|
function recomputeAndNotifyBookingQuery() {
|
|
8330
8216
|
return _recomputeAndNotifyBookingQuery.apply(this, arguments);
|
|
@@ -8354,11 +8240,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
8354
8240
|
var allowedProductIds = new Set();
|
|
8355
8241
|
var allowedCollectionIds = new Set();
|
|
8356
8242
|
var hasProductAll = false;
|
|
8357
|
-
var
|
|
8358
|
-
|
|
8243
|
+
var _iterator23 = _createForOfIteratorHelper(activeMenuList),
|
|
8244
|
+
_step23;
|
|
8359
8245
|
try {
|
|
8360
|
-
for (
|
|
8361
|
-
var menu =
|
|
8246
|
+
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
8247
|
+
var menu = _step23.value;
|
|
8362
8248
|
var config = menu.partyroom_package;
|
|
8363
8249
|
if (!config) {
|
|
8364
8250
|
console.warn('[Server] 餐牌缺少 partyroom_package 配置:', menu);
|
|
@@ -8418,9 +8304,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
8418
8304
|
|
|
8419
8305
|
// 如果有餐牌允许所有商品,返回所有商品
|
|
8420
8306
|
} catch (err) {
|
|
8421
|
-
|
|
8307
|
+
_iterator23.e(err);
|
|
8422
8308
|
} finally {
|
|
8423
|
-
|
|
8309
|
+
_iterator23.f();
|
|
8424
8310
|
}
|
|
8425
8311
|
if (hasProductAll) {
|
|
8426
8312
|
this.logInfo('getProductScopeByMenuConfig: 返回所有商品 scope(product_all)');
|