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