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