@pisell/pisellos 2.3.58 → 2.3.59
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/core/index.d.ts +7 -0
- package/dist/core/index.js +109 -66
- package/dist/modules/Quotation/index.d.ts +6 -0
- package/dist/modules/Quotation/index.js +75 -19
- package/dist/plugins/request.d.ts +1 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +166 -119
- package/dist/server/modules/floor-plan/index.d.ts +4 -0
- package/dist/server/modules/floor-plan/index.js +240 -98
- package/dist/server/modules/order/index.d.ts +6 -5
- package/dist/server/modules/order/index.js +176 -78
- package/dist/server/modules/products/index.d.ts +2 -0
- package/dist/server/modules/products/index.js +17 -3
- package/dist/server/modules/resource/index.js +21 -13
- package/lib/core/index.d.ts +7 -0
- package/lib/core/index.js +20 -3
- package/lib/modules/Quotation/index.d.ts +6 -0
- package/lib/modules/Quotation/index.js +49 -5
- package/lib/plugins/request.d.ts +1 -0
- package/lib/server/index.d.ts +9 -0
- package/lib/server/index.js +69 -15
- package/lib/server/modules/floor-plan/index.d.ts +4 -0
- package/lib/server/modules/floor-plan/index.js +54 -6
- package/lib/server/modules/order/index.d.ts +6 -5
- package/lib/server/modules/order/index.js +105 -23
- package/lib/server/modules/products/index.d.ts +2 -0
- package/lib/server/modules/products/index.js +15 -4
- package/lib/server/modules/resource/index.js +7 -2
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -33,6 +33,7 @@ import { FloorPlanModule } from "./modules/floor-plan";
|
|
|
33
33
|
import { FloorPlanHooks } from "./modules/floor-plan/types";
|
|
34
34
|
import { PaymentServerModule } from "./modules/payment";
|
|
35
35
|
import { extractScheduleIdsFromMenus, extractTimePointsFromSchedules } from "./utils/schedule";
|
|
36
|
+
import { sortTimePoints } from "./utils/time";
|
|
36
37
|
import { ProductsHooks } from "./modules/products/types";
|
|
37
38
|
import { perfMark } from "./utils/product";
|
|
38
39
|
import { OrderModule } from "./modules/order";
|
|
@@ -58,6 +59,7 @@ import { getOrderPaymentIdentityKeys, isIdentifiedPendingOrderPayment, isPending
|
|
|
58
59
|
/** 平面图 GET 查询订阅者(列表 / id 详情 / code 详情) */
|
|
59
60
|
|
|
60
61
|
var PRODUCT_TITLE_SNAPSHOT_KEYS = ['en', 'ja', 'pt', 'auto', 'zh-CN', 'zh-HK', 'kitchen', 'original'];
|
|
62
|
+
var AUTO_PRINT_STORAGE_KEY = 'auto_print';
|
|
61
63
|
|
|
62
64
|
/**
|
|
63
65
|
* Server 类
|
|
@@ -336,7 +338,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
336
338
|
case 9:
|
|
337
339
|
result = _context3.sent;
|
|
338
340
|
if (subscriberId && typeof callback === 'function') {
|
|
339
|
-
_this.syncProductQueryScheduleTimers(
|
|
341
|
+
_this.syncProductQueryScheduleTimers({
|
|
342
|
+
subscriberId: subscriberId,
|
|
343
|
+
menu_list_ids: menu_list_ids,
|
|
344
|
+
strategy_context: strategy_context
|
|
345
|
+
});
|
|
340
346
|
}
|
|
341
347
|
return _context3.abrupt("return", result);
|
|
342
348
|
case 12:
|
|
@@ -1679,7 +1685,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1679
1685
|
_defineProperty(this, "handleGetScheduleTimePoints", /*#__PURE__*/function () {
|
|
1680
1686
|
var _ref59 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(_ref58) {
|
|
1681
1687
|
var _menu_list_ids$length;
|
|
1682
|
-
var url, method, data, config, menu_list_ids, _menu_list_ids$length2, menuList, scheduleIds, scheduleList, timePoints, errorMessage;
|
|
1688
|
+
var url, method, data, config, menu_list_ids, _menu_list_ids$length2, _this$getMenuSchedule, menuList, scheduleIds, scheduleList, timePoints, errorMessage;
|
|
1683
1689
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1684
1690
|
while (1) switch (_context24.prev = _context24.next) {
|
|
1685
1691
|
case 0:
|
|
@@ -1735,8 +1741,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
1735
1741
|
});
|
|
1736
1742
|
case 16:
|
|
1737
1743
|
_context24.prev = 16;
|
|
1738
|
-
|
|
1739
|
-
menuList = _this.menu.getMenuByIds(menu_list_ids);
|
|
1744
|
+
_this$getMenuSchedule = _this.getMenuScheduleTimePoints(menu_list_ids), menuList = _this$getMenuSchedule.menuList, scheduleIds = _this$getMenuSchedule.scheduleIds, scheduleList = _this$getMenuSchedule.scheduleList, timePoints = _this$getMenuSchedule.timePoints;
|
|
1740
1745
|
console.log("[Server] \u627E\u5230 ".concat(menuList.length, " \u4E2A\u9910\u724C"));
|
|
1741
1746
|
_this.logInfo('handleGetScheduleTimePoints: 获取到餐牌列表', {
|
|
1742
1747
|
requestedCount: menu_list_ids.length,
|
|
@@ -1744,15 +1749,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
1744
1749
|
menu_list_ids: menu_list_ids,
|
|
1745
1750
|
menuList: menuList
|
|
1746
1751
|
});
|
|
1747
|
-
|
|
1748
|
-
// 2. 提取所有的 schedule IDs
|
|
1749
|
-
scheduleIds = extractScheduleIdsFromMenus(menuList);
|
|
1750
1752
|
console.log("[Server] \u63D0\u53D6\u5230 ".concat(scheduleIds.length, " \u4E2A\u65E5\u7A0BID:"), scheduleIds);
|
|
1751
1753
|
_this.logInfo('handleGetScheduleTimePoints: 提取到日程 IDs', {
|
|
1752
1754
|
scheduleCount: scheduleIds.length
|
|
1753
1755
|
});
|
|
1754
1756
|
if (!(scheduleIds.length === 0)) {
|
|
1755
|
-
_context24.next =
|
|
1757
|
+
_context24.next = 25;
|
|
1756
1758
|
break;
|
|
1757
1759
|
}
|
|
1758
1760
|
_this.logInfo('handleGetScheduleTimePoints: 没有找到相关日程', {
|
|
@@ -1764,17 +1766,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
1764
1766
|
data: [],
|
|
1765
1767
|
status: true
|
|
1766
1768
|
});
|
|
1767
|
-
case
|
|
1768
|
-
// 3. 获取日程详情
|
|
1769
|
-
scheduleList = _this.schedule.getScheduleByIds(scheduleIds);
|
|
1769
|
+
case 25:
|
|
1770
1770
|
console.log("[Server] \u627E\u5230 ".concat(scheduleList.length, " \u4E2A\u65E5\u7A0B"));
|
|
1771
1771
|
_this.logInfo('handleGetScheduleTimePoints: 获取到日程详情', {
|
|
1772
1772
|
requestedCount: scheduleIds.length,
|
|
1773
1773
|
foundCount: scheduleList.length
|
|
1774
1774
|
});
|
|
1775
|
-
|
|
1776
|
-
// 4. 提取时间点
|
|
1777
|
-
timePoints = extractTimePointsFromSchedules(scheduleList);
|
|
1778
1775
|
console.log("[Server] \u63D0\u53D6\u5230 ".concat(timePoints.length, " \u4E2A\u65F6\u95F4\u70B9:"), timePoints);
|
|
1779
1776
|
_this.logInfo('handleGetScheduleTimePoints 处理完成', {
|
|
1780
1777
|
menuListIdsCount: menu_list_ids.length,
|
|
@@ -1788,8 +1785,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
1788
1785
|
data: timePoints,
|
|
1789
1786
|
status: true
|
|
1790
1787
|
});
|
|
1791
|
-
case
|
|
1792
|
-
_context24.prev =
|
|
1788
|
+
case 32:
|
|
1789
|
+
_context24.prev = 32;
|
|
1793
1790
|
_context24.t0 = _context24["catch"](16);
|
|
1794
1791
|
errorMessage = _context24.t0 instanceof Error ? _context24.t0.message : '未知错误';
|
|
1795
1792
|
console.error('[Server] 获取日程时间点失败:', _context24.t0);
|
|
@@ -1803,11 +1800,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
1803
1800
|
data: [],
|
|
1804
1801
|
status: false
|
|
1805
1802
|
});
|
|
1806
|
-
case
|
|
1803
|
+
case 38:
|
|
1807
1804
|
case "end":
|
|
1808
1805
|
return _context24.stop();
|
|
1809
1806
|
}
|
|
1810
|
-
}, _callee24, null, [[16,
|
|
1807
|
+
}, _callee24, null, [[16, 32]]);
|
|
1811
1808
|
}));
|
|
1812
1809
|
return function (_x24) {
|
|
1813
1810
|
return _ref59.apply(this, arguments);
|
|
@@ -2720,6 +2717,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2720
2717
|
key: "setupProductsQuotationPriceBridge",
|
|
2721
2718
|
value: (function () {
|
|
2722
2719
|
var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
2720
|
+
var _this5 = this;
|
|
2723
2721
|
var _this$core$context, errorMessage;
|
|
2724
2722
|
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2725
2723
|
while (1) switch (_context33.prev = _context33.next) {
|
|
@@ -2739,31 +2737,42 @@ var Server = /*#__PURE__*/function () {
|
|
|
2739
2737
|
return _context33.abrupt("return");
|
|
2740
2738
|
case 6:
|
|
2741
2739
|
_context33.prev = 6;
|
|
2742
|
-
_context33.next = 9;
|
|
2743
|
-
return this.schedule.loadAllSchedule();
|
|
2744
|
-
case 9:
|
|
2745
2740
|
this.products.clearPriceCache();
|
|
2746
|
-
_context33.next =
|
|
2741
|
+
_context33.next = 10;
|
|
2747
2742
|
return this.products.setupQuotationPriceBridge({
|
|
2748
2743
|
scheduleModule: this.schedule,
|
|
2749
|
-
channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel
|
|
2744
|
+
channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel,
|
|
2745
|
+
onQuotationUpdated: function onQuotationUpdated() {
|
|
2746
|
+
void _this5.recomputeAndNotifyProductQuery();
|
|
2747
|
+
}
|
|
2748
|
+
});
|
|
2749
|
+
case 10:
|
|
2750
|
+
// Schedule 已在模块 preload 阶段加载完成。价格桥接先使用本地数据,
|
|
2751
|
+
// 远端刷新转为后台校准,避免二次启动重复阻塞请求。
|
|
2752
|
+
void this.schedule.loadAllSchedule().then(function () {
|
|
2753
|
+
var _this5$products;
|
|
2754
|
+
(_this5$products = _this5.products) === null || _this5$products === void 0 || _this5$products.clearPriceCache();
|
|
2755
|
+
void _this5.recomputeAndNotifyProductQuery();
|
|
2756
|
+
}).catch(function (error) {
|
|
2757
|
+
_this5.logWarning('Products 报价单价格桥接后台刷新 Schedule 失败,继续使用本地数据', {
|
|
2758
|
+
error: error instanceof Error ? error.message : String(error)
|
|
2759
|
+
});
|
|
2750
2760
|
});
|
|
2751
|
-
case 12:
|
|
2752
2761
|
this.logInfo('Products 报价单价格桥接初始化完成');
|
|
2753
|
-
_context33.next =
|
|
2762
|
+
_context33.next = 18;
|
|
2754
2763
|
break;
|
|
2755
|
-
case
|
|
2756
|
-
_context33.prev =
|
|
2764
|
+
case 14:
|
|
2765
|
+
_context33.prev = 14;
|
|
2757
2766
|
_context33.t0 = _context33["catch"](6);
|
|
2758
2767
|
errorMessage = _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0);
|
|
2759
2768
|
this.logError('Products 报价单价格桥接初始化失败', {
|
|
2760
2769
|
error: errorMessage
|
|
2761
2770
|
});
|
|
2762
|
-
case
|
|
2771
|
+
case 18:
|
|
2763
2772
|
case "end":
|
|
2764
2773
|
return _context33.stop();
|
|
2765
2774
|
}
|
|
2766
|
-
}, _callee33, this, [[6,
|
|
2775
|
+
}, _callee33, this, [[6, 14]]);
|
|
2767
2776
|
}));
|
|
2768
2777
|
function setupProductsQuotationPriceBridge() {
|
|
2769
2778
|
return _setupProductsQuotationPriceBridge.apply(this, arguments);
|
|
@@ -3238,10 +3247,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
3238
3247
|
}, {
|
|
3239
3248
|
key: "getAllRoutes",
|
|
3240
3249
|
value: function getAllRoutes() {
|
|
3241
|
-
var
|
|
3250
|
+
var _this6 = this;
|
|
3242
3251
|
var routes = [];
|
|
3243
3252
|
['get', 'post', 'put', 'remove'].forEach(function (method) {
|
|
3244
|
-
Object.keys(
|
|
3253
|
+
Object.keys(_this6.router[method]).forEach(function (path) {
|
|
3245
3254
|
routes.push({
|
|
3246
3255
|
method: method,
|
|
3247
3256
|
path: path
|
|
@@ -3371,7 +3380,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3371
3380
|
key: "getPaymentRouteModule",
|
|
3372
3381
|
value: function () {
|
|
3373
3382
|
var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
|
|
3374
|
-
var
|
|
3383
|
+
var _this7 = this;
|
|
3375
3384
|
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3376
3385
|
while (1) switch (_context40.prev = _context40.next) {
|
|
3377
3386
|
case 0:
|
|
@@ -3400,13 +3409,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
3400
3409
|
case 0:
|
|
3401
3410
|
module = new PaymentServerModule('server_payment_route', '1.0.0');
|
|
3402
3411
|
_context39.next = 3;
|
|
3403
|
-
return module.initialize(
|
|
3412
|
+
return module.initialize(_this7.core, {
|
|
3404
3413
|
store: {
|
|
3405
3414
|
payMethods: []
|
|
3406
3415
|
}
|
|
3407
3416
|
});
|
|
3408
3417
|
case 3:
|
|
3409
|
-
|
|
3418
|
+
_this7.paymentRouteModule = module;
|
|
3410
3419
|
return _context39.abrupt("return", module);
|
|
3411
3420
|
case 5:
|
|
3412
3421
|
case "end":
|
|
@@ -3414,7 +3423,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3414
3423
|
}
|
|
3415
3424
|
}, _callee39);
|
|
3416
3425
|
}))().finally(function () {
|
|
3417
|
-
|
|
3426
|
+
_this7.paymentRouteModuleInFlight = undefined;
|
|
3418
3427
|
});
|
|
3419
3428
|
return _context40.abrupt("return", this.paymentRouteModuleInFlight);
|
|
3420
3429
|
case 8:
|
|
@@ -3590,7 +3599,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3590
3599
|
}, {
|
|
3591
3600
|
key: "scheduleSubscriberTimePointReloads",
|
|
3592
3601
|
value: function scheduleSubscriberTimePointReloads(subscriberId, timePoints) {
|
|
3593
|
-
var
|
|
3602
|
+
var _this8 = this;
|
|
3594
3603
|
var subscriber = this.productQuerySubscribers.get(subscriberId);
|
|
3595
3604
|
if (!subscriber || !timePoints.length) return;
|
|
3596
3605
|
var scheduleDate = subscriber.context.schedule_date || dayjs().format('YYYY-MM-DD');
|
|
@@ -3611,7 +3620,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3611
3620
|
setInterval(function () {
|
|
3612
3621
|
var currentTime = dayjs().format('hh:mm');
|
|
3613
3622
|
if (timePoints.includes(currentTime)) {
|
|
3614
|
-
|
|
3623
|
+
_this8.onScheduleTimePointTimerFire(subscriberId);
|
|
3615
3624
|
}
|
|
3616
3625
|
}, 60000);
|
|
3617
3626
|
if (timerIds.length > 0) {
|
|
@@ -3709,18 +3718,48 @@ var Server = /*#__PURE__*/function () {
|
|
|
3709
3718
|
return recomputeAndNotifySubscriber;
|
|
3710
3719
|
}()
|
|
3711
3720
|
/**
|
|
3712
|
-
*
|
|
3721
|
+
* 根据餐牌 ID 获取其绑定日程中的全部时间点。
|
|
3722
|
+
* 商品查询定时器与 schedule-time-points 路由共用此逻辑。
|
|
3713
3723
|
*/
|
|
3714
3724
|
)
|
|
3725
|
+
}, {
|
|
3726
|
+
key: "getMenuScheduleTimePoints",
|
|
3727
|
+
value: function getMenuScheduleTimePoints(menuListIds) {
|
|
3728
|
+
var _this$menu$getMenuByI, _this$menu, _this$schedule$getSch, _this$schedule;
|
|
3729
|
+
var menuList = (_this$menu$getMenuByI = (_this$menu = this.menu) === null || _this$menu === void 0 ? void 0 : _this$menu.getMenuByIds(menuListIds)) !== null && _this$menu$getMenuByI !== void 0 ? _this$menu$getMenuByI : [];
|
|
3730
|
+
var scheduleIds = extractScheduleIdsFromMenus(menuList);
|
|
3731
|
+
var scheduleList = scheduleIds.length > 0 ? (_this$schedule$getSch = (_this$schedule = this.schedule) === null || _this$schedule === void 0 ? void 0 : _this$schedule.getScheduleByIds(scheduleIds)) !== null && _this$schedule$getSch !== void 0 ? _this$schedule$getSch : [] : [];
|
|
3732
|
+
var timePoints = extractTimePointsFromSchedules(scheduleList);
|
|
3733
|
+
return {
|
|
3734
|
+
menuList: menuList,
|
|
3735
|
+
scheduleIds: scheduleIds,
|
|
3736
|
+
scheduleList: scheduleList,
|
|
3737
|
+
timePoints: timePoints
|
|
3738
|
+
};
|
|
3739
|
+
}
|
|
3740
|
+
|
|
3741
|
+
/**
|
|
3742
|
+
* query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
|
|
3743
|
+
*/
|
|
3715
3744
|
}, {
|
|
3716
3745
|
key: "syncProductQueryScheduleTimers",
|
|
3717
|
-
value: function syncProductQueryScheduleTimers(
|
|
3746
|
+
value: function syncProductQueryScheduleTimers(_ref61) {
|
|
3718
3747
|
var _this$products$getLas3, _this$products2, _this$products2$getLa;
|
|
3748
|
+
var subscriberId = _ref61.subscriberId,
|
|
3749
|
+
menu_list_ids = _ref61.menu_list_ids,
|
|
3750
|
+
strategy_context = _ref61.strategy_context;
|
|
3719
3751
|
this.clearSubscriberScheduleTimers(subscriberId);
|
|
3720
3752
|
if (!this.shouldScheduleProductQueryReload(strategy_context)) {
|
|
3721
3753
|
return;
|
|
3722
3754
|
}
|
|
3723
|
-
var
|
|
3755
|
+
var productTimePoints = (_this$products$getLas3 = (_this$products2 = this.products) === null || _this$products2 === void 0 || (_this$products2$getLa = _this$products2.getLastScheduleTimePoints) === null || _this$products2$getLa === void 0 ? void 0 : _this$products2$getLa.call(_this$products2)) !== null && _this$products$getLas3 !== void 0 ? _this$products$getLas3 : [];
|
|
3756
|
+
var menuListIds = Array.isArray(menu_list_ids) ? Array.from(new Set(menu_list_ids.map(function (id) {
|
|
3757
|
+
return Number(id);
|
|
3758
|
+
}).filter(function (id) {
|
|
3759
|
+
return Number.isFinite(id);
|
|
3760
|
+
}))) : [];
|
|
3761
|
+
var menuTimePoints = this.getMenuScheduleTimePoints(menuListIds).timePoints;
|
|
3762
|
+
var timePoints = sortTimePoints(Array.from(new Set([].concat(_toConsumableArray(productTimePoints), _toConsumableArray(menuTimePoints)))));
|
|
3724
3763
|
if (timePoints.length > 0) {
|
|
3725
3764
|
this.scheduleSubscriberTimePointReloads(subscriberId, timePoints);
|
|
3726
3765
|
}
|
|
@@ -3750,7 +3789,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3750
3789
|
key: "refreshMenuScheduleCacheAfterEmptyResult",
|
|
3751
3790
|
value: (function () {
|
|
3752
3791
|
var _refreshMenuScheduleCacheAfterEmptyResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
|
|
3753
|
-
var
|
|
3792
|
+
var _this9 = this;
|
|
3754
3793
|
var now;
|
|
3755
3794
|
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
3756
3795
|
while (1) switch (_context44.prev = _context44.next) {
|
|
@@ -3773,11 +3812,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3773
3812
|
this.menuScheduleRefreshInFlight = Promise.all([this.menu.loadMenuList(), this.schedule.loadAllSchedule()]).then(function () {
|
|
3774
3813
|
return undefined;
|
|
3775
3814
|
}).catch(function (error) {
|
|
3776
|
-
|
|
3815
|
+
_this9.logWarning('刷新菜单/日程缓存失败,继续使用现有缓存', {
|
|
3777
3816
|
error: error instanceof Error ? error.message : String(error)
|
|
3778
3817
|
});
|
|
3779
3818
|
}).finally(function () {
|
|
3780
|
-
|
|
3819
|
+
_this9.menuScheduleRefreshInFlight = null;
|
|
3781
3820
|
});
|
|
3782
3821
|
}
|
|
3783
3822
|
_context44.next = 8;
|
|
@@ -3807,7 +3846,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3807
3846
|
*/
|
|
3808
3847
|
function () {
|
|
3809
3848
|
var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(kind, backendPath, data, config) {
|
|
3810
|
-
var queryPayload, result,
|
|
3849
|
+
var queryPayload, result, _ref62, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
|
|
3811
3850
|
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
3812
3851
|
while (1) switch (_context45.prev = _context45.next) {
|
|
3813
3852
|
case 0:
|
|
@@ -3816,7 +3855,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3816
3855
|
return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
|
|
3817
3856
|
case 3:
|
|
3818
3857
|
result = _context45.sent;
|
|
3819
|
-
|
|
3858
|
+
_ref62 = config || {}, callback = _ref62.callback, subscriberId = _ref62.subscriberId, resetVisibleOrderIds = _ref62.resetVisibleOrderIds;
|
|
3820
3859
|
if (subscriberId && typeof callback === 'function') {
|
|
3821
3860
|
contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
|
|
3822
3861
|
existing = this.salesSearchSubscribers.get(subscriberId);
|
|
@@ -3963,10 +4002,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
3963
4002
|
}, {
|
|
3964
4003
|
key: "stripSalesSearchPageParams",
|
|
3965
4004
|
value: function stripSalesSearchPageParams(value) {
|
|
3966
|
-
var
|
|
4005
|
+
var _this10 = this;
|
|
3967
4006
|
if (Array.isArray(value)) {
|
|
3968
4007
|
return value.map(function (item) {
|
|
3969
|
-
return
|
|
4008
|
+
return _this10.stripSalesSearchPageParams(item);
|
|
3970
4009
|
});
|
|
3971
4010
|
}
|
|
3972
4011
|
if (!value || _typeof(value) !== 'object') return value;
|
|
@@ -4004,12 +4043,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
4004
4043
|
key: "extractSalesSearchOrderIds",
|
|
4005
4044
|
value: function extractSalesSearchOrderIds(kind, result) {
|
|
4006
4045
|
var _this$findSalesSearch,
|
|
4007
|
-
|
|
4046
|
+
_this11 = this;
|
|
4008
4047
|
var data = this.extractSalesSearchResponseData(result);
|
|
4009
4048
|
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;
|
|
4010
4049
|
if (!Array.isArray(list)) return [];
|
|
4011
4050
|
return list.map(function (item) {
|
|
4012
|
-
return
|
|
4051
|
+
return _this11.getSalesSearchOrderId(item);
|
|
4013
4052
|
}).filter(function (id) {
|
|
4014
4053
|
return !!id;
|
|
4015
4054
|
});
|
|
@@ -4176,11 +4215,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4176
4215
|
}, {
|
|
4177
4216
|
key: "stableSerialize",
|
|
4178
4217
|
value: function stableSerialize(value) {
|
|
4179
|
-
var
|
|
4218
|
+
var _this12 = this;
|
|
4180
4219
|
if (value === null || value === undefined) return 'null';
|
|
4181
4220
|
if (Array.isArray(value)) {
|
|
4182
4221
|
return "[".concat(value.map(function (item) {
|
|
4183
|
-
return
|
|
4222
|
+
return _this12.stableSerialize(item);
|
|
4184
4223
|
}).join(','), "]");
|
|
4185
4224
|
}
|
|
4186
4225
|
if (_typeof(value) === 'object') {
|
|
@@ -4189,7 +4228,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4189
4228
|
return obj[k] !== undefined;
|
|
4190
4229
|
}).sort();
|
|
4191
4230
|
return "{".concat(keys.map(function (k) {
|
|
4192
|
-
return "".concat(JSON.stringify(k), ":").concat(
|
|
4231
|
+
return "".concat(JSON.stringify(k), ":").concat(_this12.stableSerialize(obj[k]));
|
|
4193
4232
|
}).join(','), "}");
|
|
4194
4233
|
}
|
|
4195
4234
|
return JSON.stringify(value);
|
|
@@ -4729,7 +4768,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4729
4768
|
key: "runLocalPaymentUpdateInQueue",
|
|
4730
4769
|
value: function () {
|
|
4731
4770
|
var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(key, task, context) {
|
|
4732
|
-
var
|
|
4771
|
+
var _this13 = this;
|
|
4733
4772
|
var queuedAt, hasPreviousTask, previous, current, tail, _data, result, released;
|
|
4734
4773
|
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
4735
4774
|
while (1) switch (_context50.prev = _context50.next) {
|
|
@@ -4748,7 +4787,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4748
4787
|
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
4749
4788
|
while (1) switch (_context49.prev = _context49.next) {
|
|
4750
4789
|
case 0:
|
|
4751
|
-
|
|
4790
|
+
_this13.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
|
|
4752
4791
|
queue_key: key,
|
|
4753
4792
|
queue_wait_ms: Date.now() - queuedAt
|
|
4754
4793
|
}));
|
|
@@ -5874,7 +5913,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5874
5913
|
key: "handleOrderCheckoutSubmit",
|
|
5875
5914
|
value: function () {
|
|
5876
5915
|
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
|
|
5877
|
-
var backendPath, data, title, normalizedData, checkoutData, pendingResult,
|
|
5916
|
+
var backendPath, data, title, normalizedData, checkoutData, pendingResult, pendingOrder;
|
|
5878
5917
|
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
5879
5918
|
while (1) switch (_context60.prev = _context60.next) {
|
|
5880
5919
|
case 0:
|
|
@@ -5913,35 +5952,33 @@ var Server = /*#__PURE__*/function () {
|
|
|
5913
5952
|
case 12:
|
|
5914
5953
|
pendingResult = _context60.sent;
|
|
5915
5954
|
if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
|
|
5916
|
-
_context60.next =
|
|
5955
|
+
_context60.next = 20;
|
|
5917
5956
|
break;
|
|
5918
5957
|
}
|
|
5919
5958
|
pendingOrder = pendingResult.data;
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && (
|
|
5923
|
-
// TODO 这里先加个兼容,如果是安卓,则需要 type=virtual 才走打印,如果是苹果则无限制
|
|
5924
|
-
isAndroid ? checkoutData.type === 'virtual' : true))) {
|
|
5925
|
-
_context60.next = 20;
|
|
5959
|
+
if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && this.shouldAutoPrintCheckoutReceipt())) {
|
|
5960
|
+
_context60.next = 18;
|
|
5926
5961
|
break;
|
|
5927
5962
|
}
|
|
5928
|
-
_context60.next =
|
|
5963
|
+
_context60.next = 18;
|
|
5929
5964
|
return this.dispatchLocalReceiptPrint({
|
|
5930
5965
|
checkoutData: checkoutData,
|
|
5931
5966
|
order: pendingOrder,
|
|
5932
5967
|
response: pendingResult,
|
|
5933
|
-
requireFullyPaid: true
|
|
5968
|
+
requireFullyPaid: true,
|
|
5969
|
+
// 自动小票固定使用 print_all 的收据类型 0,不随订单 type 改成券/手环类型 99。
|
|
5970
|
+
isManualPrint: true
|
|
5934
5971
|
});
|
|
5935
|
-
case
|
|
5936
|
-
_context60.next =
|
|
5972
|
+
case 18:
|
|
5973
|
+
_context60.next = 20;
|
|
5937
5974
|
return this.dispatchCheckoutSyncTask({
|
|
5938
5975
|
backendPath: backendPath,
|
|
5939
5976
|
data: checkoutData,
|
|
5940
5977
|
title: title
|
|
5941
5978
|
});
|
|
5942
|
-
case
|
|
5979
|
+
case 20:
|
|
5943
5980
|
if (pendingResult.data.order_id) {
|
|
5944
|
-
_context60.next =
|
|
5981
|
+
_context60.next = 22;
|
|
5945
5982
|
break;
|
|
5946
5983
|
}
|
|
5947
5984
|
return _context60.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
|
|
@@ -5949,9 +5986,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5949
5986
|
order_id: pendingResult.data.external_sale_number
|
|
5950
5987
|
})
|
|
5951
5988
|
}));
|
|
5952
|
-
case
|
|
5989
|
+
case 22:
|
|
5953
5990
|
return _context60.abrupt("return", pendingResult);
|
|
5954
|
-
case
|
|
5991
|
+
case 23:
|
|
5955
5992
|
case "end":
|
|
5956
5993
|
return _context60.stop();
|
|
5957
5994
|
}
|
|
@@ -6145,7 +6182,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6145
6182
|
key: "handlePendingSyncCheckoutOrder",
|
|
6146
6183
|
value: function () {
|
|
6147
6184
|
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
|
|
6148
|
-
var
|
|
6185
|
+
var _this14 = this;
|
|
6149
6186
|
var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
|
|
6150
6187
|
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
6151
6188
|
while (1) switch (_context63.prev = _context63.next) {
|
|
@@ -6198,7 +6235,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6198
6235
|
});
|
|
6199
6236
|
changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
|
|
6200
6237
|
var _payment$metadata;
|
|
6201
|
-
return sum +
|
|
6238
|
+
return sum + _this14.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
|
|
6202
6239
|
}, 0);
|
|
6203
6240
|
return _context63.abrupt("return", {
|
|
6204
6241
|
code: 200,
|
|
@@ -6285,13 +6322,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
6285
6322
|
}
|
|
6286
6323
|
return buildPendingSyncCheckoutOrder;
|
|
6287
6324
|
}()
|
|
6325
|
+
/**
|
|
6326
|
+
* Android 结账自动小票由当前设备设置控制;其它平台保持原有行为。
|
|
6327
|
+
*/
|
|
6328
|
+
}, {
|
|
6329
|
+
key: "shouldAutoPrintCheckoutReceipt",
|
|
6330
|
+
value: function shouldAutoPrintCheckoutReceipt() {
|
|
6331
|
+
var _this$core$context2, _this$core$context2$g, _this$app17, _this$app17$getStorag;
|
|
6332
|
+
if (((_this$core$context2 = this.core.context) === null || _this$core$context2 === void 0 || (_this$core$context2$g = _this$core$context2.getPlatform) === null || _this$core$context2$g === void 0 ? void 0 : _this$core$context2$g.call(_this$core$context2)) !== 'android') return true;
|
|
6333
|
+
return ((_this$app17 = this.app) === null || _this$app17 === void 0 || (_this$app17 = _this$app17.storage) === null || _this$app17 === void 0 || (_this$app17$getStorag = _this$app17.getStorage) === null || _this$app17$getStorag === void 0 ? void 0 : _this$app17$getStorag.call(_this$app17, AUTO_PRINT_STORAGE_KEY)) === 'true';
|
|
6334
|
+
}
|
|
6288
6335
|
}, {
|
|
6289
6336
|
key: "shouldBuildSmallTicketData",
|
|
6290
6337
|
value: function shouldBuildSmallTicketData(order) {
|
|
6291
|
-
var
|
|
6338
|
+
var _ref64, _order$small_ticket_d;
|
|
6292
6339
|
if (!order || _typeof(order) !== 'object') return false;
|
|
6293
6340
|
// if (hasSmallTicketData(order.payment_info?.small_ticket_data)) return false;
|
|
6294
|
-
return Number((
|
|
6341
|
+
return Number((_ref64 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref64 !== void 0 ? _ref64 : 0) === 1;
|
|
6295
6342
|
}
|
|
6296
6343
|
}, {
|
|
6297
6344
|
key: "shouldPrintSyncedOrder",
|
|
@@ -6309,7 +6356,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6309
6356
|
}, {
|
|
6310
6357
|
key: "isSalesOrderFullyPaid",
|
|
6311
6358
|
value: function isSalesOrderFullyPaid(order) {
|
|
6312
|
-
var _order$summary$amount, _order$summary,
|
|
6359
|
+
var _order$summary$amount, _order$summary, _ref65, _ref66, _order$summary$expect, _order$summary2, _order$summary3;
|
|
6313
6360
|
if (!order || _typeof(order) !== 'object') return false;
|
|
6314
6361
|
var paymentStatus = String(order.payment_status || '').toLowerCase();
|
|
6315
6362
|
if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
|
|
@@ -6321,20 +6368,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
6321
6368
|
return this.toAmountNumber(amountGap) <= 0;
|
|
6322
6369
|
}
|
|
6323
6370
|
var paidAmount = this.sumPaidOrderPayments(order.payments);
|
|
6324
|
-
var targetAmount = this.toAmountNumber((
|
|
6371
|
+
var targetAmount = this.toAmountNumber((_ref65 = (_ref66 = (_order$summary$expect = (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.total_amount) !== null && _ref66 !== void 0 ? _ref66 : order.expect_amount) !== null && _ref65 !== void 0 ? _ref65 : order.total_amount);
|
|
6325
6372
|
if (targetAmount <= 0) return paidAmount > 0;
|
|
6326
6373
|
return paidAmount >= targetAmount;
|
|
6327
6374
|
}
|
|
6328
6375
|
}, {
|
|
6329
6376
|
key: "sumPaidOrderPayments",
|
|
6330
6377
|
value: function sumPaidOrderPayments(payments) {
|
|
6331
|
-
var
|
|
6378
|
+
var _this15 = this;
|
|
6332
6379
|
if (!Array.isArray(payments)) return 0;
|
|
6333
6380
|
return payments.reduce(function (sum, payment) {
|
|
6334
6381
|
var _payment$amount;
|
|
6335
6382
|
var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
|
|
6336
6383
|
if (status !== 'paid') return sum;
|
|
6337
|
-
return sum +
|
|
6384
|
+
return sum + _this15.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);
|
|
6338
6385
|
}, 0);
|
|
6339
6386
|
}
|
|
6340
6387
|
}, {
|
|
@@ -6350,7 +6397,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6350
6397
|
value: function () {
|
|
6351
6398
|
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(order) {
|
|
6352
6399
|
var _this$products3,
|
|
6353
|
-
|
|
6400
|
+
_this16 = this;
|
|
6354
6401
|
var products, productIdSet, productIds, entries;
|
|
6355
6402
|
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
6356
6403
|
while (1) switch (_context66.prev = _context66.next) {
|
|
@@ -6365,8 +6412,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
6365
6412
|
}
|
|
6366
6413
|
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
6367
6414
|
product.product_bundle.forEach(function (bundle) {
|
|
6368
|
-
var
|
|
6369
|
-
var bundleProductId = (
|
|
6415
|
+
var _ref67, _bundle$bundle_produc;
|
|
6416
|
+
var bundleProductId = (_ref67 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref67 !== void 0 ? _ref67 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
|
|
6370
6417
|
if (bundleProductId !== undefined && bundleProductId !== null && bundleProductId !== '') {
|
|
6371
6418
|
productIdSet.add(bundleProductId);
|
|
6372
6419
|
}
|
|
@@ -6382,21 +6429,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
6382
6429
|
case 6:
|
|
6383
6430
|
_context66.next = 8;
|
|
6384
6431
|
return Promise.all(productIds.map( /*#__PURE__*/function () {
|
|
6385
|
-
var
|
|
6386
|
-
var
|
|
6432
|
+
var _ref68 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(id) {
|
|
6433
|
+
var _this16$products, _this16$products$getP, product;
|
|
6387
6434
|
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
6388
6435
|
while (1) switch (_context65.prev = _context65.next) {
|
|
6389
6436
|
case 0:
|
|
6390
6437
|
_context65.prev = 0;
|
|
6391
6438
|
_context65.next = 3;
|
|
6392
|
-
return (
|
|
6439
|
+
return (_this16$products = _this16.products) === null || _this16$products === void 0 || (_this16$products$getP = _this16$products.getProductById) === null || _this16$products$getP === void 0 ? void 0 : _this16$products$getP.call(_this16$products, Number(id));
|
|
6393
6440
|
case 3:
|
|
6394
6441
|
product = _context65.sent;
|
|
6395
6442
|
return _context65.abrupt("return", product ? [String(id), product] : null);
|
|
6396
6443
|
case 7:
|
|
6397
6444
|
_context65.prev = 7;
|
|
6398
6445
|
_context65.t0 = _context65["catch"](0);
|
|
6399
|
-
|
|
6446
|
+
_this16.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
|
|
6400
6447
|
product_id: id,
|
|
6401
6448
|
error: _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0)
|
|
6402
6449
|
});
|
|
@@ -6408,7 +6455,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6408
6455
|
}, _callee65, null, [[0, 7]]);
|
|
6409
6456
|
}));
|
|
6410
6457
|
return function (_x73) {
|
|
6411
|
-
return
|
|
6458
|
+
return _ref68.apply(this, arguments);
|
|
6412
6459
|
};
|
|
6413
6460
|
}()));
|
|
6414
6461
|
case 8:
|
|
@@ -6447,8 +6494,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
6447
6494
|
addProductId((_product$product_id2 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product === null || product === void 0 ? void 0 : product.id);
|
|
6448
6495
|
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
6449
6496
|
product.product_bundle.forEach(function (bundle) {
|
|
6450
|
-
var
|
|
6451
|
-
addProductId((
|
|
6497
|
+
var _ref69, _bundle$bundle_produc2;
|
|
6498
|
+
addProductId((_ref69 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref69 !== void 0 ? _ref69 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
|
|
6452
6499
|
});
|
|
6453
6500
|
}
|
|
6454
6501
|
});
|
|
@@ -6524,9 +6571,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6524
6571
|
if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
|
|
6525
6572
|
var hasChanged = false;
|
|
6526
6573
|
var productBundle = product.product_bundle.map(function (bundle) {
|
|
6527
|
-
var
|
|
6574
|
+
var _ref70, _bundle$bundle_produc3;
|
|
6528
6575
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
6529
|
-
var rawProductId = (
|
|
6576
|
+
var rawProductId = (_ref70 = (_bundle$bundle_produc3 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref70 !== void 0 ? _ref70 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
|
|
6530
6577
|
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
|
|
6531
6578
|
var productId = Number(rawProductId);
|
|
6532
6579
|
if (!Number.isFinite(productId)) return bundle;
|
|
@@ -6547,7 +6594,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6547
6594
|
key: "withSalesDetailProductSnapshots",
|
|
6548
6595
|
value: function () {
|
|
6549
6596
|
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(order) {
|
|
6550
|
-
var
|
|
6597
|
+
var _this17 = this;
|
|
6551
6598
|
var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
|
|
6552
6599
|
return _regeneratorRuntime().wrap(function _callee68$(_context68) {
|
|
6553
6600
|
while (1) switch (_context68.prev = _context68.next) {
|
|
@@ -6571,8 +6618,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
6571
6618
|
case 8:
|
|
6572
6619
|
hasChanged = false;
|
|
6573
6620
|
enrichedProducts = products.map(function (product) {
|
|
6574
|
-
var productWithBundleSnapshots =
|
|
6575
|
-
var nextProduct =
|
|
6621
|
+
var productWithBundleSnapshots = _this17.withBundleCatalogSnapshots(product, snapshotMap);
|
|
6622
|
+
var nextProduct = _this17.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
|
|
6576
6623
|
if (nextProduct !== product) hasChanged = true;
|
|
6577
6624
|
return nextProduct;
|
|
6578
6625
|
});
|
|
@@ -6600,13 +6647,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6600
6647
|
}, {
|
|
6601
6648
|
key: "withPendingSyncProductTitles",
|
|
6602
6649
|
value: function withPendingSyncProductTitles(order, productMap) {
|
|
6603
|
-
var
|
|
6650
|
+
var _this18 = this;
|
|
6604
6651
|
var products = Array.isArray(order.products) ? order.products : null;
|
|
6605
6652
|
if (!(products !== null && products !== void 0 && products.length)) return order;
|
|
6606
6653
|
return _objectSpread(_objectSpread({}, order), {}, {
|
|
6607
6654
|
products: products.map(function (product) {
|
|
6608
6655
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
6609
|
-
product_title:
|
|
6656
|
+
product_title: _this18.buildProductTitleSnapshot(product, productMap)
|
|
6610
6657
|
});
|
|
6611
6658
|
})
|
|
6612
6659
|
});
|
|
@@ -6617,7 +6664,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6617
6664
|
var _product$product_id4,
|
|
6618
6665
|
_product$product,
|
|
6619
6666
|
_fallbackProduct$prod,
|
|
6620
|
-
|
|
6667
|
+
_this19 = this;
|
|
6621
6668
|
var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
|
|
6622
6669
|
var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
|
|
6623
6670
|
var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
|
|
@@ -6625,7 +6672,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6625
6672
|
var currentLocale = this.getProductTitleSnapshotCurrentLocale();
|
|
6626
6673
|
var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
|
|
6627
6674
|
return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
|
|
6628
|
-
snapshot[key] =
|
|
6675
|
+
snapshot[key] = _this19.resolveProductTitleValue(ownTitle, key, currentLocale) || _this19.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
|
|
6629
6676
|
return snapshot;
|
|
6630
6677
|
}, {});
|
|
6631
6678
|
}
|
|
@@ -6650,7 +6697,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6650
6697
|
}, {
|
|
6651
6698
|
key: "resolveProductTitleValue",
|
|
6652
6699
|
value: function resolveProductTitleValue(value, key, currentLocale) {
|
|
6653
|
-
var
|
|
6700
|
+
var _ref71, _ref72, _value$key;
|
|
6654
6701
|
if (value === undefined || value === null || value === '') return null;
|
|
6655
6702
|
if (_typeof(value) !== 'object') {
|
|
6656
6703
|
var title = String(value);
|
|
@@ -6660,7 +6707,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6660
6707
|
}
|
|
6661
6708
|
var normalizedKey = key.replace('-', '_');
|
|
6662
6709
|
var dashedKey = key.replace('_', '-');
|
|
6663
|
-
var rawValue = (
|
|
6710
|
+
var rawValue = (_ref71 = (_ref72 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref72 !== void 0 ? _ref72 : value[dashedKey]) !== null && _ref71 !== void 0 ? _ref71 : key === 'auto' ? value.default : undefined;
|
|
6664
6711
|
if (rawValue === undefined || rawValue === null || rawValue === '') return null;
|
|
6665
6712
|
if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
|
|
6666
6713
|
return String(rawValue);
|
|
@@ -6724,14 +6771,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
6724
6771
|
key: "enrichPaymentNamesByCode",
|
|
6725
6772
|
value: function () {
|
|
6726
6773
|
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(order) {
|
|
6727
|
-
var
|
|
6774
|
+
var _this20 = this;
|
|
6728
6775
|
var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
|
|
6729
6776
|
return _regeneratorRuntime().wrap(function _callee69$(_context69) {
|
|
6730
6777
|
while (1) switch (_context69.prev = _context69.next) {
|
|
6731
6778
|
case 0:
|
|
6732
6779
|
payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
|
|
6733
6780
|
hasMissingName = payments.some(function (payment) {
|
|
6734
|
-
return
|
|
6781
|
+
return _this20.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this20.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
|
|
6735
6782
|
});
|
|
6736
6783
|
if (hasMissingName) {
|
|
6737
6784
|
_context69.next = 4;
|
|
@@ -6764,9 +6811,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6764
6811
|
}
|
|
6765
6812
|
hasResolvedName = false;
|
|
6766
6813
|
enrichedPayments = payments.map(function (payment) {
|
|
6767
|
-
if (!
|
|
6768
|
-
if (!
|
|
6769
|
-
var name = nameByCode.get(
|
|
6814
|
+
if (!_this20.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
|
|
6815
|
+
if (!_this20.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
|
|
6816
|
+
var name = nameByCode.get(_this20.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
|
|
6770
6817
|
if (!name) return payment;
|
|
6771
6818
|
hasResolvedName = true;
|
|
6772
6819
|
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
@@ -6925,7 +6972,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6925
6972
|
key: "handleUpdateLocalOrdersBatch",
|
|
6926
6973
|
value: (function () {
|
|
6927
6974
|
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(orderIds) {
|
|
6928
|
-
var _this$
|
|
6975
|
+
var _this$app18;
|
|
6929
6976
|
var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message2, overwritten, inserted;
|
|
6930
6977
|
return _regeneratorRuntime().wrap(function _callee71$(_context71) {
|
|
6931
6978
|
while (1) switch (_context71.prev = _context71.next) {
|
|
@@ -6946,7 +6993,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6946
6993
|
data: null
|
|
6947
6994
|
});
|
|
6948
6995
|
case 4:
|
|
6949
|
-
if ((_this$
|
|
6996
|
+
if ((_this$app18 = this.app) !== null && _this$app18 !== void 0 && _this$app18.request) {
|
|
6950
6997
|
_context71.next = 7;
|
|
6951
6998
|
break;
|
|
6952
6999
|
}
|
|
@@ -7348,10 +7395,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
7348
7395
|
value: function extractBackendErrorResponse(error) {
|
|
7349
7396
|
var _error$response3,
|
|
7350
7397
|
_error$response4,
|
|
7351
|
-
|
|
7398
|
+
_this21 = this;
|
|
7352
7399
|
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];
|
|
7353
7400
|
return candidates.find(function (candidate) {
|
|
7354
|
-
return
|
|
7401
|
+
return _this21.isExplicitBackendErrorResponse(candidate);
|
|
7355
7402
|
}) || null;
|
|
7356
7403
|
}
|
|
7357
7404
|
}, {
|
|
@@ -7712,7 +7759,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7712
7759
|
value: (function () {
|
|
7713
7760
|
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(context, options) {
|
|
7714
7761
|
var _menu_list_ids$length3,
|
|
7715
|
-
|
|
7762
|
+
_this22 = this;
|
|
7716
7763
|
var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, getActiveMenus, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
|
|
7717
7764
|
return _regeneratorRuntime().wrap(function _callee75$(_context75) {
|
|
7718
7765
|
while (1) switch (_context75.prev = _context75.next) {
|
|
@@ -7911,9 +7958,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7911
7958
|
}
|
|
7912
7959
|
tMenu = performance.now();
|
|
7913
7960
|
getActiveMenus = function getActiveMenus() {
|
|
7914
|
-
return
|
|
7915
|
-
var
|
|
7916
|
-
return ((
|
|
7961
|
+
return _this22.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
|
|
7962
|
+
var _this22$schedule;
|
|
7963
|
+
return ((_this22$schedule = _this22.schedule) === null || _this22$schedule === void 0 ? void 0 : _this22$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
|
|
7917
7964
|
});
|
|
7918
7965
|
};
|
|
7919
7966
|
activeMenuList = getActiveMenus();
|
|
@@ -8030,14 +8077,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
8030
8077
|
}, {
|
|
8031
8078
|
key: "buildProductFormatterContext",
|
|
8032
8079
|
value: function buildProductFormatterContext(context) {
|
|
8033
|
-
var _this$
|
|
8080
|
+
var _this$menu2, _this$menu2$getMenuLi, _scheduleModule$getSc, _this$core$context5;
|
|
8034
8081
|
var scheduleModule = this.getSchedule();
|
|
8035
8082
|
return {
|
|
8036
8083
|
scheduleModule: scheduleModule,
|
|
8037
8084
|
schedule_datetime: context.schedule_datetime,
|
|
8038
8085
|
customer_id: context.customer_id,
|
|
8039
8086
|
strategy_context: context.strategy_context,
|
|
8040
|
-
menuList: ((_this$
|
|
8087
|
+
menuList: ((_this$menu2 = this.menu) === null || _this$menu2 === void 0 || (_this$menu2$getMenuLi = _this$menu2.getMenuList) === null || _this$menu2$getMenuLi === void 0 ? void 0 : _this$menu2$getMenuLi.call(_this$menu2)) || [],
|
|
8041
8088
|
scheduleList: (scheduleModule === null || scheduleModule === void 0 || (_scheduleModule$getSc = scheduleModule.getScheduleList) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule)) || [],
|
|
8042
8089
|
dataVariantEvaluator: (_this$core$context5 = this.core.context) === null || _this$core$context5 === void 0 ? void 0 : _this$core$context5.dataVariantEvaluator
|
|
8043
8090
|
};
|
|
@@ -8222,7 +8269,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8222
8269
|
}, {
|
|
8223
8270
|
key: "notifySalesSearchSubscribers",
|
|
8224
8271
|
value: function notifySalesSearchSubscribers(payload) {
|
|
8225
|
-
var
|
|
8272
|
+
var _this23 = this;
|
|
8226
8273
|
if (this.salesSearchSubscribers.size === 0) return;
|
|
8227
8274
|
var changedOrders = this.extractChangedOrdersFromPayload(payload);
|
|
8228
8275
|
if (changedOrders.length === 0) {
|
|
@@ -8240,21 +8287,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
8240
8287
|
subscriber = _step20$value[1];
|
|
8241
8288
|
try {
|
|
8242
8289
|
var changedVisibleOrders = changedOrders.filter(function (order) {
|
|
8243
|
-
var orderId =
|
|
8290
|
+
var orderId = _this23.getSalesSearchOrderId(order);
|
|
8244
8291
|
return !!orderId && subscriber.visibleOrderIds.has(orderId);
|
|
8245
8292
|
});
|
|
8246
8293
|
if (changedVisibleOrders.length === 0) {
|
|
8247
8294
|
return 1; // continue
|
|
8248
8295
|
}
|
|
8249
|
-
subscriber.callback(
|
|
8250
|
-
|
|
8296
|
+
subscriber.callback(_this23.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
|
|
8297
|
+
_this23.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
|
|
8251
8298
|
subscriberId: subscriberId,
|
|
8252
8299
|
kind: subscriber.kind,
|
|
8253
8300
|
count: changedVisibleOrders.length
|
|
8254
8301
|
});
|
|
8255
8302
|
} catch (error) {
|
|
8256
8303
|
var errorMessage = error instanceof Error ? error.message : String(error);
|
|
8257
|
-
|
|
8304
|
+
_this23.logError('notifySalesSearchSubscribers: 推送失败', {
|
|
8258
8305
|
subscriberId: subscriberId,
|
|
8259
8306
|
error: errorMessage
|
|
8260
8307
|
});
|