@pisell/pisellos 2.3.66 → 2.3.67
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 -65
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/evaluator.js +1 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +2 -0
- package/dist/modules/Customer/index.d.ts +0 -4
- package/dist/modules/Customer/index.js +59 -91
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Payment/walletpass.js +11 -31
- 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 +8 -2
- package/dist/server/index.js +212 -143
- 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/menu/index.js +48 -23
- package/dist/server/modules/order/index.d.ts +17 -8
- package/dist/server/modules/order/index.js +506 -453
- package/dist/server/modules/products/index.d.ts +8 -2
- package/dist/server/modules/products/index.js +167 -75
- package/dist/server/modules/resource/index.js +21 -13
- package/dist/server/utils/small-ticket.js +1 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +0 -2
- package/dist/solution/BookingTicket/index.js +10 -34
- package/lib/core/index.d.ts +7 -0
- package/lib/core/index.js +20 -2
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/model/strategy/adapter/walletPass/evaluator.js +1 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +1 -0
- package/lib/modules/Customer/index.d.ts +0 -4
- package/lib/modules/Customer/index.js +0 -11
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Payment/walletpass.js +2 -15
- 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 +8 -2
- package/lib/server/index.js +58 -20
- 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/menu/index.js +31 -5
- package/lib/server/modules/order/index.d.ts +17 -8
- package/lib/server/modules/order/index.js +199 -106
- package/lib/server/modules/products/index.d.ts +8 -2
- package/lib/server/modules/products/index.js +97 -24
- package/lib/server/modules/resource/index.js +7 -2
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +0 -2
- package/lib/solution/BookingTicket/index.js +2 -18
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -103,6 +103,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
103
103
|
_defineProperty(this, "productQueryScheduleTimers", new Map());
|
|
104
104
|
/** 餐牌筛选为空时才触发的菜单/日程缓存自愈,避免每次商品查询都请求远端。 */
|
|
105
105
|
_defineProperty(this, "menuScheduleRefreshInFlight", null);
|
|
106
|
+
/** 启动阶段模块预加载任务;预渲染商品查询复用该任务,避免缓存尚未 ready 时误触发远端自愈。 */
|
|
107
|
+
_defineProperty(this, "startupModulePreloadInFlight", null);
|
|
106
108
|
_defineProperty(this, "lastMenuScheduleRefreshAt", 0);
|
|
107
109
|
_defineProperty(this, "MENU_SCHEDULE_REFRESH_COOLDOWN_MS", 30 * 1000);
|
|
108
110
|
// ---- 订单 / 预约列表查询订阅者 ----
|
|
@@ -2266,6 +2268,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2266
2268
|
options,
|
|
2267
2269
|
startTime,
|
|
2268
2270
|
registeredModules,
|
|
2271
|
+
preloadTask,
|
|
2269
2272
|
duration,
|
|
2270
2273
|
_args29 = arguments;
|
|
2271
2274
|
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
@@ -2290,22 +2293,31 @@ var Server = /*#__PURE__*/function () {
|
|
|
2290
2293
|
case 8:
|
|
2291
2294
|
registeredModules = _context29.sent;
|
|
2292
2295
|
if (!autoPreload) {
|
|
2293
|
-
_context29.next =
|
|
2296
|
+
_context29.next = 20;
|
|
2294
2297
|
break;
|
|
2295
2298
|
}
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
+
preloadTask = this.preloadModulesData(registeredModules, options);
|
|
2300
|
+
this.startupModulePreloadInFlight = preloadTask;
|
|
2301
|
+
_context29.prev = 12;
|
|
2299
2302
|
_context29.next = 15;
|
|
2303
|
+
return preloadTask;
|
|
2304
|
+
case 15:
|
|
2305
|
+
_context29.prev = 15;
|
|
2306
|
+
if (this.startupModulePreloadInFlight === preloadTask) {
|
|
2307
|
+
this.startupModulePreloadInFlight = null;
|
|
2308
|
+
}
|
|
2309
|
+
return _context29.finish(15);
|
|
2310
|
+
case 18:
|
|
2311
|
+
_context29.next = 21;
|
|
2300
2312
|
break;
|
|
2301
|
-
case
|
|
2313
|
+
case 20:
|
|
2302
2314
|
this.logInfo('跳过自动预加载', {
|
|
2303
2315
|
autoPreload: autoPreload
|
|
2304
2316
|
});
|
|
2305
|
-
case
|
|
2306
|
-
_context29.next =
|
|
2317
|
+
case 21:
|
|
2318
|
+
_context29.next = 23;
|
|
2307
2319
|
return this.setupProductsQuotationPriceBridge();
|
|
2308
|
-
case
|
|
2320
|
+
case 23:
|
|
2309
2321
|
// 监听 ProductsModule 同步完成事件,重新计算并推送查询结果
|
|
2310
2322
|
this.core.effects.on(ProductsHooks.onProductsSyncCompleted, function (payload) {
|
|
2311
2323
|
_this3.recomputeAndNotifyProductQuery({
|
|
@@ -2331,11 +2343,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
2331
2343
|
registeredModuleCount: registeredModules.length
|
|
2332
2344
|
});
|
|
2333
2345
|
return _context29.abrupt("return", registeredModules);
|
|
2334
|
-
case
|
|
2346
|
+
case 29:
|
|
2335
2347
|
case "end":
|
|
2336
2348
|
return _context29.stop();
|
|
2337
2349
|
}
|
|
2338
|
-
}, _callee29, this);
|
|
2350
|
+
}, _callee29, this, [[12,, 15, 18]]);
|
|
2339
2351
|
}));
|
|
2340
2352
|
function initialize(_x32) {
|
|
2341
2353
|
return _initialize.apply(this, arguments);
|
|
@@ -2717,6 +2729,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2717
2729
|
key: "setupProductsQuotationPriceBridge",
|
|
2718
2730
|
value: (function () {
|
|
2719
2731
|
var _setupProductsQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
2732
|
+
var _this5 = this;
|
|
2720
2733
|
var _this$core$context, errorMessage;
|
|
2721
2734
|
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2722
2735
|
while (1) switch (_context33.prev = _context33.next) {
|
|
@@ -2736,31 +2749,42 @@ var Server = /*#__PURE__*/function () {
|
|
|
2736
2749
|
return _context33.abrupt("return");
|
|
2737
2750
|
case 6:
|
|
2738
2751
|
_context33.prev = 6;
|
|
2739
|
-
_context33.next = 9;
|
|
2740
|
-
return this.schedule.loadAllSchedule();
|
|
2741
|
-
case 9:
|
|
2742
2752
|
this.products.clearPriceCache();
|
|
2743
|
-
_context33.next =
|
|
2753
|
+
_context33.next = 10;
|
|
2744
2754
|
return this.products.setupQuotationPriceBridge({
|
|
2745
2755
|
scheduleModule: this.schedule,
|
|
2746
|
-
channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel
|
|
2756
|
+
channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel,
|
|
2757
|
+
onQuotationUpdated: function onQuotationUpdated() {
|
|
2758
|
+
void _this5.recomputeAndNotifyProductQuery();
|
|
2759
|
+
}
|
|
2760
|
+
});
|
|
2761
|
+
case 10:
|
|
2762
|
+
// Schedule 已在模块 preload 阶段加载完成。价格桥接先使用本地数据,
|
|
2763
|
+
// 远端刷新转为后台校准,避免二次启动重复阻塞请求。
|
|
2764
|
+
void this.schedule.loadAllSchedule().then(function () {
|
|
2765
|
+
var _this5$products;
|
|
2766
|
+
(_this5$products = _this5.products) === null || _this5$products === void 0 || _this5$products.clearPriceCache();
|
|
2767
|
+
void _this5.recomputeAndNotifyProductQuery();
|
|
2768
|
+
}).catch(function (error) {
|
|
2769
|
+
_this5.logWarning('Products 报价单价格桥接后台刷新 Schedule 失败,继续使用本地数据', {
|
|
2770
|
+
error: error instanceof Error ? error.message : String(error)
|
|
2771
|
+
});
|
|
2747
2772
|
});
|
|
2748
|
-
case 12:
|
|
2749
2773
|
this.logInfo('Products 报价单价格桥接初始化完成');
|
|
2750
|
-
_context33.next =
|
|
2774
|
+
_context33.next = 18;
|
|
2751
2775
|
break;
|
|
2752
|
-
case
|
|
2753
|
-
_context33.prev =
|
|
2776
|
+
case 14:
|
|
2777
|
+
_context33.prev = 14;
|
|
2754
2778
|
_context33.t0 = _context33["catch"](6);
|
|
2755
2779
|
errorMessage = _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0);
|
|
2756
2780
|
this.logError('Products 报价单价格桥接初始化失败', {
|
|
2757
2781
|
error: errorMessage
|
|
2758
2782
|
});
|
|
2759
|
-
case
|
|
2783
|
+
case 18:
|
|
2760
2784
|
case "end":
|
|
2761
2785
|
return _context33.stop();
|
|
2762
2786
|
}
|
|
2763
|
-
}, _callee33, this, [[6,
|
|
2787
|
+
}, _callee33, this, [[6, 14]]);
|
|
2764
2788
|
}));
|
|
2765
2789
|
function setupProductsQuotationPriceBridge() {
|
|
2766
2790
|
return _setupProductsQuotationPriceBridge.apply(this, arguments);
|
|
@@ -2830,44 +2854,58 @@ var Server = /*#__PURE__*/function () {
|
|
|
2830
2854
|
key: "refreshProductsInBackground",
|
|
2831
2855
|
value: (function () {
|
|
2832
2856
|
var _refreshProductsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
2833
|
-
var
|
|
2857
|
+
var options,
|
|
2858
|
+
trigger,
|
|
2859
|
+
startTime,
|
|
2860
|
+
duration,
|
|
2861
|
+
_duration2,
|
|
2862
|
+
errorMessage,
|
|
2863
|
+
_args34 = arguments;
|
|
2834
2864
|
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2835
2865
|
while (1) switch (_context34.prev = _context34.next) {
|
|
2836
2866
|
case 0:
|
|
2867
|
+
options = _args34.length > 0 && _args34[0] !== undefined ? _args34[0] : {};
|
|
2837
2868
|
if (this.products) {
|
|
2838
|
-
_context34.next =
|
|
2869
|
+
_context34.next = 4;
|
|
2839
2870
|
break;
|
|
2840
2871
|
}
|
|
2841
2872
|
this.logWarning('refreshProductsInBackground: Products 模块未注册');
|
|
2842
2873
|
return _context34.abrupt("return");
|
|
2843
|
-
case
|
|
2844
|
-
|
|
2874
|
+
case 4:
|
|
2875
|
+
trigger = options.trigger || 'background';
|
|
2876
|
+
this.logInfo('refreshProductsInBackground 开始', {
|
|
2877
|
+
trigger: trigger
|
|
2878
|
+
});
|
|
2845
2879
|
startTime = Date.now();
|
|
2846
|
-
_context34.prev =
|
|
2847
|
-
_context34.next =
|
|
2848
|
-
return this.products.silentRefresh(
|
|
2849
|
-
|
|
2880
|
+
_context34.prev = 7;
|
|
2881
|
+
_context34.next = 10;
|
|
2882
|
+
return this.products.silentRefresh({
|
|
2883
|
+
trigger: trigger
|
|
2884
|
+
});
|
|
2885
|
+
case 10:
|
|
2850
2886
|
duration = Date.now() - startTime;
|
|
2851
2887
|
this.logInfo('refreshProductsInBackground 完成', {
|
|
2888
|
+
trigger: trigger,
|
|
2852
2889
|
duration: "".concat(duration, "ms")
|
|
2853
2890
|
});
|
|
2854
|
-
_context34.next =
|
|
2891
|
+
_context34.next = 20;
|
|
2855
2892
|
break;
|
|
2856
|
-
case
|
|
2857
|
-
_context34.prev =
|
|
2858
|
-
_context34.t0 = _context34["catch"](
|
|
2893
|
+
case 14:
|
|
2894
|
+
_context34.prev = 14;
|
|
2895
|
+
_context34.t0 = _context34["catch"](7);
|
|
2859
2896
|
_duration2 = Date.now() - startTime;
|
|
2860
2897
|
errorMessage = _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0);
|
|
2861
2898
|
console.error('[Server] refreshProductsInBackground 失败:', _context34.t0);
|
|
2862
2899
|
this.logError('refreshProductsInBackground 失败', {
|
|
2900
|
+
trigger: trigger,
|
|
2863
2901
|
duration: "".concat(_duration2, "ms"),
|
|
2864
2902
|
error: errorMessage
|
|
2865
2903
|
});
|
|
2866
|
-
case
|
|
2904
|
+
case 20:
|
|
2867
2905
|
case "end":
|
|
2868
2906
|
return _context34.stop();
|
|
2869
2907
|
}
|
|
2870
|
-
}, _callee34, this, [[
|
|
2908
|
+
}, _callee34, this, [[7, 14]]);
|
|
2871
2909
|
}));
|
|
2872
2910
|
function refreshProductsInBackground() {
|
|
2873
2911
|
return _refreshProductsInBackground.apply(this, arguments);
|
|
@@ -2884,44 +2922,58 @@ var Server = /*#__PURE__*/function () {
|
|
|
2884
2922
|
key: "refreshOrdersInBackground",
|
|
2885
2923
|
value: (function () {
|
|
2886
2924
|
var _refreshOrdersInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
|
|
2887
|
-
var
|
|
2925
|
+
var options,
|
|
2926
|
+
trigger,
|
|
2927
|
+
startTime,
|
|
2928
|
+
duration,
|
|
2929
|
+
_duration3,
|
|
2930
|
+
errorMessage,
|
|
2931
|
+
_args35 = arguments;
|
|
2888
2932
|
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2889
2933
|
while (1) switch (_context35.prev = _context35.next) {
|
|
2890
2934
|
case 0:
|
|
2935
|
+
options = _args35.length > 0 && _args35[0] !== undefined ? _args35[0] : {};
|
|
2891
2936
|
if (this.order) {
|
|
2892
|
-
_context35.next =
|
|
2937
|
+
_context35.next = 4;
|
|
2893
2938
|
break;
|
|
2894
2939
|
}
|
|
2895
2940
|
this.logWarning('refreshOrdersInBackground: Order 模块未注册');
|
|
2896
2941
|
return _context35.abrupt("return");
|
|
2897
|
-
case
|
|
2898
|
-
|
|
2942
|
+
case 4:
|
|
2943
|
+
trigger = options.trigger || 'background';
|
|
2944
|
+
this.logInfo('refreshOrdersInBackground 开始', {
|
|
2945
|
+
trigger: trigger
|
|
2946
|
+
});
|
|
2899
2947
|
startTime = Date.now();
|
|
2900
|
-
_context35.prev =
|
|
2901
|
-
_context35.next =
|
|
2902
|
-
return this.order.silentRefresh(
|
|
2903
|
-
|
|
2948
|
+
_context35.prev = 7;
|
|
2949
|
+
_context35.next = 10;
|
|
2950
|
+
return this.order.silentRefresh({
|
|
2951
|
+
trigger: trigger
|
|
2952
|
+
});
|
|
2953
|
+
case 10:
|
|
2904
2954
|
duration = Date.now() - startTime;
|
|
2905
2955
|
this.logInfo('refreshOrdersInBackground 完成', {
|
|
2956
|
+
trigger: trigger,
|
|
2906
2957
|
duration: "".concat(duration, "ms")
|
|
2907
2958
|
});
|
|
2908
|
-
_context35.next =
|
|
2959
|
+
_context35.next = 20;
|
|
2909
2960
|
break;
|
|
2910
|
-
case
|
|
2911
|
-
_context35.prev =
|
|
2912
|
-
_context35.t0 = _context35["catch"](
|
|
2961
|
+
case 14:
|
|
2962
|
+
_context35.prev = 14;
|
|
2963
|
+
_context35.t0 = _context35["catch"](7);
|
|
2913
2964
|
_duration3 = Date.now() - startTime;
|
|
2914
2965
|
errorMessage = _context35.t0 instanceof Error ? _context35.t0.message : String(_context35.t0);
|
|
2915
2966
|
console.error('[Server] refreshOrdersInBackground 失败:', _context35.t0);
|
|
2916
2967
|
this.logError('refreshOrdersInBackground 失败', {
|
|
2968
|
+
trigger: trigger,
|
|
2917
2969
|
duration: "".concat(_duration3, "ms"),
|
|
2918
2970
|
error: errorMessage
|
|
2919
2971
|
});
|
|
2920
|
-
case
|
|
2972
|
+
case 20:
|
|
2921
2973
|
case "end":
|
|
2922
2974
|
return _context35.stop();
|
|
2923
2975
|
}
|
|
2924
|
-
}, _callee35, this, [[
|
|
2976
|
+
}, _callee35, this, [[7, 14]]);
|
|
2925
2977
|
}));
|
|
2926
2978
|
function refreshOrdersInBackground() {
|
|
2927
2979
|
return _refreshOrdersInBackground.apply(this, arguments);
|
|
@@ -3235,10 +3287,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
3235
3287
|
}, {
|
|
3236
3288
|
key: "getAllRoutes",
|
|
3237
3289
|
value: function getAllRoutes() {
|
|
3238
|
-
var
|
|
3290
|
+
var _this6 = this;
|
|
3239
3291
|
var routes = [];
|
|
3240
3292
|
['get', 'post', 'put', 'remove'].forEach(function (method) {
|
|
3241
|
-
Object.keys(
|
|
3293
|
+
Object.keys(_this6.router[method]).forEach(function (path) {
|
|
3242
3294
|
routes.push({
|
|
3243
3295
|
method: method,
|
|
3244
3296
|
path: path
|
|
@@ -3368,7 +3420,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3368
3420
|
key: "getPaymentRouteModule",
|
|
3369
3421
|
value: function () {
|
|
3370
3422
|
var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
|
|
3371
|
-
var
|
|
3423
|
+
var _this7 = this;
|
|
3372
3424
|
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3373
3425
|
while (1) switch (_context40.prev = _context40.next) {
|
|
3374
3426
|
case 0:
|
|
@@ -3397,13 +3449,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
3397
3449
|
case 0:
|
|
3398
3450
|
module = new PaymentServerModule('server_payment_route', '1.0.0');
|
|
3399
3451
|
_context39.next = 3;
|
|
3400
|
-
return module.initialize(
|
|
3452
|
+
return module.initialize(_this7.core, {
|
|
3401
3453
|
store: {
|
|
3402
3454
|
payMethods: []
|
|
3403
3455
|
}
|
|
3404
3456
|
});
|
|
3405
3457
|
case 3:
|
|
3406
|
-
|
|
3458
|
+
_this7.paymentRouteModule = module;
|
|
3407
3459
|
return _context39.abrupt("return", module);
|
|
3408
3460
|
case 5:
|
|
3409
3461
|
case "end":
|
|
@@ -3411,7 +3463,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3411
3463
|
}
|
|
3412
3464
|
}, _callee39);
|
|
3413
3465
|
}))().finally(function () {
|
|
3414
|
-
|
|
3466
|
+
_this7.paymentRouteModuleInFlight = undefined;
|
|
3415
3467
|
});
|
|
3416
3468
|
return _context40.abrupt("return", this.paymentRouteModuleInFlight);
|
|
3417
3469
|
case 8:
|
|
@@ -3587,7 +3639,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3587
3639
|
}, {
|
|
3588
3640
|
key: "scheduleSubscriberTimePointReloads",
|
|
3589
3641
|
value: function scheduleSubscriberTimePointReloads(subscriberId, timePoints) {
|
|
3590
|
-
var
|
|
3642
|
+
var _this8 = this;
|
|
3591
3643
|
var subscriber = this.productQuerySubscribers.get(subscriberId);
|
|
3592
3644
|
if (!subscriber || !timePoints.length) return;
|
|
3593
3645
|
var scheduleDate = subscriber.context.schedule_date || dayjs().format('YYYY-MM-DD');
|
|
@@ -3608,7 +3660,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3608
3660
|
setInterval(function () {
|
|
3609
3661
|
var currentTime = dayjs().format('hh:mm');
|
|
3610
3662
|
if (timePoints.includes(currentTime)) {
|
|
3611
|
-
|
|
3663
|
+
_this8.onScheduleTimePointTimerFire(subscriberId);
|
|
3612
3664
|
}
|
|
3613
3665
|
}, 60000);
|
|
3614
3666
|
if (timerIds.length > 0) {
|
|
@@ -3777,7 +3829,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3777
3829
|
key: "refreshMenuScheduleCacheAfterEmptyResult",
|
|
3778
3830
|
value: (function () {
|
|
3779
3831
|
var _refreshMenuScheduleCacheAfterEmptyResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
|
|
3780
|
-
var
|
|
3832
|
+
var _this9 = this;
|
|
3781
3833
|
var now;
|
|
3782
3834
|
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
3783
3835
|
while (1) switch (_context44.prev = _context44.next) {
|
|
@@ -3800,11 +3852,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3800
3852
|
this.menuScheduleRefreshInFlight = Promise.all([this.menu.loadMenuList(), this.schedule.loadAllSchedule()]).then(function () {
|
|
3801
3853
|
return undefined;
|
|
3802
3854
|
}).catch(function (error) {
|
|
3803
|
-
|
|
3855
|
+
_this9.logWarning('刷新菜单/日程缓存失败,继续使用现有缓存', {
|
|
3804
3856
|
error: error instanceof Error ? error.message : String(error)
|
|
3805
3857
|
});
|
|
3806
3858
|
}).finally(function () {
|
|
3807
|
-
|
|
3859
|
+
_this9.menuScheduleRefreshInFlight = null;
|
|
3808
3860
|
});
|
|
3809
3861
|
}
|
|
3810
3862
|
_context44.next = 8;
|
|
@@ -3990,10 +4042,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
3990
4042
|
}, {
|
|
3991
4043
|
key: "stripSalesSearchPageParams",
|
|
3992
4044
|
value: function stripSalesSearchPageParams(value) {
|
|
3993
|
-
var
|
|
4045
|
+
var _this10 = this;
|
|
3994
4046
|
if (Array.isArray(value)) {
|
|
3995
4047
|
return value.map(function (item) {
|
|
3996
|
-
return
|
|
4048
|
+
return _this10.stripSalesSearchPageParams(item);
|
|
3997
4049
|
});
|
|
3998
4050
|
}
|
|
3999
4051
|
if (!value || _typeof(value) !== 'object') return value;
|
|
@@ -4031,12 +4083,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
4031
4083
|
key: "extractSalesSearchOrderIds",
|
|
4032
4084
|
value: function extractSalesSearchOrderIds(kind, result) {
|
|
4033
4085
|
var _this$findSalesSearch,
|
|
4034
|
-
|
|
4086
|
+
_this11 = this;
|
|
4035
4087
|
var data = this.extractSalesSearchResponseData(result);
|
|
4036
4088
|
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;
|
|
4037
4089
|
if (!Array.isArray(list)) return [];
|
|
4038
4090
|
return list.map(function (item) {
|
|
4039
|
-
return
|
|
4091
|
+
return _this11.getSalesSearchOrderId(item);
|
|
4040
4092
|
}).filter(function (id) {
|
|
4041
4093
|
return !!id;
|
|
4042
4094
|
});
|
|
@@ -4203,11 +4255,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4203
4255
|
}, {
|
|
4204
4256
|
key: "stableSerialize",
|
|
4205
4257
|
value: function stableSerialize(value) {
|
|
4206
|
-
var
|
|
4258
|
+
var _this12 = this;
|
|
4207
4259
|
if (value === null || value === undefined) return 'null';
|
|
4208
4260
|
if (Array.isArray(value)) {
|
|
4209
4261
|
return "[".concat(value.map(function (item) {
|
|
4210
|
-
return
|
|
4262
|
+
return _this12.stableSerialize(item);
|
|
4211
4263
|
}).join(','), "]");
|
|
4212
4264
|
}
|
|
4213
4265
|
if (_typeof(value) === 'object') {
|
|
@@ -4216,7 +4268,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4216
4268
|
return obj[k] !== undefined;
|
|
4217
4269
|
}).sort();
|
|
4218
4270
|
return "{".concat(keys.map(function (k) {
|
|
4219
|
-
return "".concat(JSON.stringify(k), ":").concat(
|
|
4271
|
+
return "".concat(JSON.stringify(k), ":").concat(_this12.stableSerialize(obj[k]));
|
|
4220
4272
|
}).join(','), "}");
|
|
4221
4273
|
}
|
|
4222
4274
|
return JSON.stringify(value);
|
|
@@ -4756,7 +4808,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4756
4808
|
key: "runLocalPaymentUpdateInQueue",
|
|
4757
4809
|
value: function () {
|
|
4758
4810
|
var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(key, task, context) {
|
|
4759
|
-
var
|
|
4811
|
+
var _this13 = this;
|
|
4760
4812
|
var queuedAt, hasPreviousTask, previous, current, tail, _data, result, released;
|
|
4761
4813
|
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
4762
4814
|
while (1) switch (_context50.prev = _context50.next) {
|
|
@@ -4775,7 +4827,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4775
4827
|
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
4776
4828
|
while (1) switch (_context49.prev = _context49.next) {
|
|
4777
4829
|
case 0:
|
|
4778
|
-
|
|
4830
|
+
_this13.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
|
|
4779
4831
|
queue_key: key,
|
|
4780
4832
|
queue_wait_ms: Date.now() - queuedAt
|
|
4781
4833
|
}));
|
|
@@ -5953,7 +6005,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5953
6005
|
checkoutData: checkoutData,
|
|
5954
6006
|
order: pendingOrder,
|
|
5955
6007
|
response: pendingResult,
|
|
5956
|
-
requireFullyPaid: true
|
|
6008
|
+
requireFullyPaid: true,
|
|
6009
|
+
// 自动小票固定使用 print_all 的收据类型 0,不随订单 type 改成券/手环类型 99。
|
|
6010
|
+
isManualPrint: true
|
|
5957
6011
|
});
|
|
5958
6012
|
case 18:
|
|
5959
6013
|
_context60.next = 20;
|
|
@@ -6039,8 +6093,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6039
6093
|
checkoutData: syncResult.checkoutData,
|
|
6040
6094
|
order: syncedOrder,
|
|
6041
6095
|
response: syncResult.normalizedResponse,
|
|
6042
|
-
requireFullyPaid: true
|
|
6096
|
+
requireFullyPaid: true,
|
|
6043
6097
|
// print_all 的 type=0 是收据打印;不要沿用同步成功后的券/手环打印 type=99。
|
|
6098
|
+
isManualPrint: true
|
|
6044
6099
|
});
|
|
6045
6100
|
case 16:
|
|
6046
6101
|
return _context61.abrupt("return", response);
|
|
@@ -6167,7 +6222,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6167
6222
|
key: "handlePendingSyncCheckoutOrder",
|
|
6168
6223
|
value: function () {
|
|
6169
6224
|
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
|
|
6170
|
-
var
|
|
6225
|
+
var _this14 = this;
|
|
6171
6226
|
var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
|
|
6172
6227
|
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
6173
6228
|
while (1) switch (_context63.prev = _context63.next) {
|
|
@@ -6220,7 +6275,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6220
6275
|
});
|
|
6221
6276
|
changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
|
|
6222
6277
|
var _payment$metadata;
|
|
6223
|
-
return sum +
|
|
6278
|
+
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);
|
|
6224
6279
|
}, 0);
|
|
6225
6280
|
return _context63.abrupt("return", {
|
|
6226
6281
|
code: 200,
|
|
@@ -6315,7 +6370,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6315
6370
|
value: function shouldAutoPrintCheckoutReceipt() {
|
|
6316
6371
|
var _this$core$context2, _this$core$context2$g, _this$app17, _this$app17$getStorag;
|
|
6317
6372
|
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;
|
|
6318
|
-
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))
|
|
6373
|
+
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';
|
|
6319
6374
|
}
|
|
6320
6375
|
}, {
|
|
6321
6376
|
key: "shouldBuildSmallTicketData",
|
|
@@ -6360,13 +6415,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6360
6415
|
}, {
|
|
6361
6416
|
key: "sumPaidOrderPayments",
|
|
6362
6417
|
value: function sumPaidOrderPayments(payments) {
|
|
6363
|
-
var
|
|
6418
|
+
var _this15 = this;
|
|
6364
6419
|
if (!Array.isArray(payments)) return 0;
|
|
6365
6420
|
return payments.reduce(function (sum, payment) {
|
|
6366
6421
|
var _payment$amount;
|
|
6367
6422
|
var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
|
|
6368
6423
|
if (status !== 'paid') return sum;
|
|
6369
|
-
return sum +
|
|
6424
|
+
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);
|
|
6370
6425
|
}, 0);
|
|
6371
6426
|
}
|
|
6372
6427
|
}, {
|
|
@@ -6382,7 +6437,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6382
6437
|
value: function () {
|
|
6383
6438
|
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(order) {
|
|
6384
6439
|
var _this$products3,
|
|
6385
|
-
|
|
6440
|
+
_this16 = this;
|
|
6386
6441
|
var products, productIdSet, productIds, entries;
|
|
6387
6442
|
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
6388
6443
|
while (1) switch (_context66.prev = _context66.next) {
|
|
@@ -6415,20 +6470,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
6415
6470
|
_context66.next = 8;
|
|
6416
6471
|
return Promise.all(productIds.map( /*#__PURE__*/function () {
|
|
6417
6472
|
var _ref68 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(id) {
|
|
6418
|
-
var
|
|
6473
|
+
var _this16$products, _this16$products$getP, product;
|
|
6419
6474
|
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
6420
6475
|
while (1) switch (_context65.prev = _context65.next) {
|
|
6421
6476
|
case 0:
|
|
6422
6477
|
_context65.prev = 0;
|
|
6423
6478
|
_context65.next = 3;
|
|
6424
|
-
return (
|
|
6479
|
+
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));
|
|
6425
6480
|
case 3:
|
|
6426
6481
|
product = _context65.sent;
|
|
6427
6482
|
return _context65.abrupt("return", product ? [String(id), product] : null);
|
|
6428
6483
|
case 7:
|
|
6429
6484
|
_context65.prev = 7;
|
|
6430
6485
|
_context65.t0 = _context65["catch"](0);
|
|
6431
|
-
|
|
6486
|
+
_this16.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
|
|
6432
6487
|
product_id: id,
|
|
6433
6488
|
error: _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0)
|
|
6434
6489
|
});
|
|
@@ -6579,7 +6634,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6579
6634
|
key: "withSalesDetailProductSnapshots",
|
|
6580
6635
|
value: function () {
|
|
6581
6636
|
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(order) {
|
|
6582
|
-
var
|
|
6637
|
+
var _this17 = this;
|
|
6583
6638
|
var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
|
|
6584
6639
|
return _regeneratorRuntime().wrap(function _callee68$(_context68) {
|
|
6585
6640
|
while (1) switch (_context68.prev = _context68.next) {
|
|
@@ -6603,8 +6658,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
6603
6658
|
case 8:
|
|
6604
6659
|
hasChanged = false;
|
|
6605
6660
|
enrichedProducts = products.map(function (product) {
|
|
6606
|
-
var productWithBundleSnapshots =
|
|
6607
|
-
var nextProduct =
|
|
6661
|
+
var productWithBundleSnapshots = _this17.withBundleCatalogSnapshots(product, snapshotMap);
|
|
6662
|
+
var nextProduct = _this17.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
|
|
6608
6663
|
if (nextProduct !== product) hasChanged = true;
|
|
6609
6664
|
return nextProduct;
|
|
6610
6665
|
});
|
|
@@ -6632,13 +6687,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6632
6687
|
}, {
|
|
6633
6688
|
key: "withPendingSyncProductTitles",
|
|
6634
6689
|
value: function withPendingSyncProductTitles(order, productMap) {
|
|
6635
|
-
var
|
|
6690
|
+
var _this18 = this;
|
|
6636
6691
|
var products = Array.isArray(order.products) ? order.products : null;
|
|
6637
6692
|
if (!(products !== null && products !== void 0 && products.length)) return order;
|
|
6638
6693
|
return _objectSpread(_objectSpread({}, order), {}, {
|
|
6639
6694
|
products: products.map(function (product) {
|
|
6640
6695
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
6641
|
-
product_title:
|
|
6696
|
+
product_title: _this18.buildProductTitleSnapshot(product, productMap)
|
|
6642
6697
|
});
|
|
6643
6698
|
})
|
|
6644
6699
|
});
|
|
@@ -6649,7 +6704,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6649
6704
|
var _product$product_id4,
|
|
6650
6705
|
_product$product,
|
|
6651
6706
|
_fallbackProduct$prod,
|
|
6652
|
-
|
|
6707
|
+
_this19 = this;
|
|
6653
6708
|
var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
|
|
6654
6709
|
var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
|
|
6655
6710
|
var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
|
|
@@ -6657,7 +6712,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6657
6712
|
var currentLocale = this.getProductTitleSnapshotCurrentLocale();
|
|
6658
6713
|
var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
|
|
6659
6714
|
return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
|
|
6660
|
-
snapshot[key] =
|
|
6715
|
+
snapshot[key] = _this19.resolveProductTitleValue(ownTitle, key, currentLocale) || _this19.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
|
|
6661
6716
|
return snapshot;
|
|
6662
6717
|
}, {});
|
|
6663
6718
|
}
|
|
@@ -6756,14 +6811,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
6756
6811
|
key: "enrichPaymentNamesByCode",
|
|
6757
6812
|
value: function () {
|
|
6758
6813
|
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(order) {
|
|
6759
|
-
var
|
|
6814
|
+
var _this20 = this;
|
|
6760
6815
|
var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
|
|
6761
6816
|
return _regeneratorRuntime().wrap(function _callee69$(_context69) {
|
|
6762
6817
|
while (1) switch (_context69.prev = _context69.next) {
|
|
6763
6818
|
case 0:
|
|
6764
6819
|
payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
|
|
6765
6820
|
hasMissingName = payments.some(function (payment) {
|
|
6766
|
-
return
|
|
6821
|
+
return _this20.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this20.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
|
|
6767
6822
|
});
|
|
6768
6823
|
if (hasMissingName) {
|
|
6769
6824
|
_context69.next = 4;
|
|
@@ -6796,9 +6851,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
6796
6851
|
}
|
|
6797
6852
|
hasResolvedName = false;
|
|
6798
6853
|
enrichedPayments = payments.map(function (payment) {
|
|
6799
|
-
if (!
|
|
6800
|
-
if (!
|
|
6801
|
-
var name = nameByCode.get(
|
|
6854
|
+
if (!_this20.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
|
|
6855
|
+
if (!_this20.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
|
|
6856
|
+
var name = nameByCode.get(_this20.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
|
|
6802
6857
|
if (!name) return payment;
|
|
6803
6858
|
hasResolvedName = true;
|
|
6804
6859
|
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
@@ -7380,10 +7435,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
7380
7435
|
value: function extractBackendErrorResponse(error) {
|
|
7381
7436
|
var _error$response3,
|
|
7382
7437
|
_error$response4,
|
|
7383
|
-
|
|
7438
|
+
_this21 = this;
|
|
7384
7439
|
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];
|
|
7385
7440
|
return candidates.find(function (candidate) {
|
|
7386
|
-
return
|
|
7441
|
+
return _this21.isExplicitBackendErrorResponse(candidate);
|
|
7387
7442
|
}) || null;
|
|
7388
7443
|
}
|
|
7389
7444
|
}, {
|
|
@@ -7744,8 +7799,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
7744
7799
|
value: (function () {
|
|
7745
7800
|
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(context, options) {
|
|
7746
7801
|
var _menu_list_ids$length3,
|
|
7747
|
-
|
|
7748
|
-
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;
|
|
7802
|
+
_this22 = this;
|
|
7803
|
+
var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, startupPreloadTask, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, getActiveMenus, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
|
|
7749
7804
|
return _regeneratorRuntime().wrap(function _callee75$(_context75) {
|
|
7750
7805
|
while (1) switch (_context75.prev = _context75.next) {
|
|
7751
7806
|
case 0:
|
|
@@ -7756,12 +7811,6 @@ var Server = /*#__PURE__*/function () {
|
|
|
7756
7811
|
}).filter(function (id) {
|
|
7757
7812
|
return Number.isFinite(id);
|
|
7758
7813
|
}) : [];
|
|
7759
|
-
formatterContext = this.buildProductFormatterContext({
|
|
7760
|
-
schedule_date: schedule_date,
|
|
7761
|
-
schedule_datetime: schedule_datetime,
|
|
7762
|
-
customer_id: customer_id,
|
|
7763
|
-
strategy_context: strategy_context
|
|
7764
|
-
});
|
|
7765
7814
|
this.logInfo('computeProductQueryResult 开始', {
|
|
7766
7815
|
menuListIdsCount: (_menu_list_ids$length3 = menu_list_ids === null || menu_list_ids === void 0 ? void 0 : menu_list_ids.length) !== null && _menu_list_ids$length3 !== void 0 ? _menu_list_ids$length3 : 0,
|
|
7767
7816
|
ids: queryIds,
|
|
@@ -7773,28 +7822,48 @@ var Server = /*#__PURE__*/function () {
|
|
|
7773
7822
|
strategyContextKeys: strategy_context ? Object.keys(strategy_context) : [],
|
|
7774
7823
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
7775
7824
|
});
|
|
7776
|
-
|
|
7825
|
+
|
|
7826
|
+
// 预渲染可能在 PisellOS 顺序 preload 尚未完成时发起商品查询。此时 Menu/Schedule
|
|
7827
|
+
// 暂时为空不代表缓存失效;等待当前 preload 后再按原逻辑查询,避免并发远端刷新先 clear
|
|
7828
|
+
// SQLite/IndexDB,造成 preload 读到空数据并重复请求。正常运行期该字段为 null,不增加等待。
|
|
7829
|
+
startupPreloadTask = this.startupModulePreloadInFlight;
|
|
7830
|
+
if (!startupPreloadTask) {
|
|
7777
7831
|
_context75.next = 8;
|
|
7778
7832
|
break;
|
|
7779
7833
|
}
|
|
7834
|
+
_context75.next = 8;
|
|
7835
|
+
return startupPreloadTask;
|
|
7836
|
+
case 8:
|
|
7837
|
+
// Menu/Schedule preload 会替换 store 中的数组;必须在等待完成后再读取,
|
|
7838
|
+
// 避免 formatterContext 持有预加载前的空数组快照。
|
|
7839
|
+
formatterContext = this.buildProductFormatterContext({
|
|
7840
|
+
schedule_date: schedule_date,
|
|
7841
|
+
schedule_datetime: schedule_datetime,
|
|
7842
|
+
customer_id: customer_id,
|
|
7843
|
+
strategy_context: strategy_context
|
|
7844
|
+
});
|
|
7845
|
+
if (this.products) {
|
|
7846
|
+
_context75.next = 12;
|
|
7847
|
+
break;
|
|
7848
|
+
}
|
|
7780
7849
|
this.logError('computeProductQueryResult: Products 模块未注册');
|
|
7781
7850
|
return _context75.abrupt("return", {
|
|
7782
7851
|
message: 'Products 模块未注册',
|
|
7783
7852
|
data: this.buildProductQueryResultPayload([], 0)
|
|
7784
7853
|
});
|
|
7785
|
-
case
|
|
7854
|
+
case 12:
|
|
7786
7855
|
if (!(queryIds.length > 0)) {
|
|
7787
|
-
_context75.next =
|
|
7856
|
+
_context75.next = 24;
|
|
7788
7857
|
break;
|
|
7789
7858
|
}
|
|
7790
7859
|
uniqueIds = Array.from(new Set(queryIds));
|
|
7791
7860
|
_tPrice = performance.now();
|
|
7792
|
-
_context75.next =
|
|
7861
|
+
_context75.next = 17;
|
|
7793
7862
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
7794
7863
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
7795
7864
|
productIds: uniqueIds
|
|
7796
7865
|
});
|
|
7797
|
-
case
|
|
7866
|
+
case 17:
|
|
7798
7867
|
productsWithPrice = _context75.sent;
|
|
7799
7868
|
perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
|
|
7800
7869
|
count: productsWithPrice.length,
|
|
@@ -7821,18 +7890,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
7821
7890
|
message: '',
|
|
7822
7891
|
status: true
|
|
7823
7892
|
});
|
|
7824
|
-
case
|
|
7893
|
+
case 24:
|
|
7825
7894
|
if (!(product_id != null && Number.isFinite(Number(product_id)))) {
|
|
7826
|
-
_context75.next =
|
|
7895
|
+
_context75.next = 36;
|
|
7827
7896
|
break;
|
|
7828
7897
|
}
|
|
7829
7898
|
pid = Number(product_id);
|
|
7830
7899
|
_tPrice2 = performance.now();
|
|
7831
|
-
_context75.next =
|
|
7900
|
+
_context75.next = 29;
|
|
7832
7901
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
7833
7902
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
7834
7903
|
});
|
|
7835
|
-
case
|
|
7904
|
+
case 29:
|
|
7836
7905
|
allProductsWithPrice = _context75.sent;
|
|
7837
7906
|
perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
|
|
7838
7907
|
count: allProductsWithPrice.length,
|
|
@@ -7859,17 +7928,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
7859
7928
|
message: item ? '' : '商品不存在或未发布',
|
|
7860
7929
|
status: true
|
|
7861
7930
|
});
|
|
7862
|
-
case
|
|
7931
|
+
case 36:
|
|
7863
7932
|
if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
|
|
7864
|
-
_context75.next =
|
|
7933
|
+
_context75.next = 56;
|
|
7865
7934
|
break;
|
|
7866
7935
|
}
|
|
7867
7936
|
_tPrice3 = performance.now();
|
|
7868
|
-
_context75.next =
|
|
7937
|
+
_context75.next = 40;
|
|
7869
7938
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
7870
7939
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
7871
7940
|
});
|
|
7872
|
-
case
|
|
7941
|
+
case 40:
|
|
7873
7942
|
_filteredProducts2 = _context75.sent;
|
|
7874
7943
|
perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
|
|
7875
7944
|
count: _filteredProducts2.length,
|
|
@@ -7915,9 +7984,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7915
7984
|
message: '',
|
|
7916
7985
|
status: true
|
|
7917
7986
|
});
|
|
7918
|
-
case
|
|
7987
|
+
case 56:
|
|
7919
7988
|
if (this.menu) {
|
|
7920
|
-
_context75.next =
|
|
7989
|
+
_context75.next = 59;
|
|
7921
7990
|
break;
|
|
7922
7991
|
}
|
|
7923
7992
|
this.logError('computeProductQueryResult: Menu 模块未注册');
|
|
@@ -7925,9 +7994,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7925
7994
|
message: 'Menu 模块未注册',
|
|
7926
7995
|
data: this.buildProductQueryResultPayload([], 0)
|
|
7927
7996
|
});
|
|
7928
|
-
case
|
|
7997
|
+
case 59:
|
|
7929
7998
|
if (this.schedule) {
|
|
7930
|
-
_context75.next =
|
|
7999
|
+
_context75.next = 62;
|
|
7931
8000
|
break;
|
|
7932
8001
|
}
|
|
7933
8002
|
this.logError('computeProductQueryResult: Schedule 模块未注册');
|
|
@@ -7935,41 +8004,41 @@ var Server = /*#__PURE__*/function () {
|
|
|
7935
8004
|
message: 'Schedule 模块未注册',
|
|
7936
8005
|
data: this.buildProductQueryResultPayload([], 0)
|
|
7937
8006
|
});
|
|
7938
|
-
case
|
|
8007
|
+
case 62:
|
|
7939
8008
|
activeMenuList = [];
|
|
7940
8009
|
if (!(menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0)) {
|
|
7941
|
-
_context75.next =
|
|
8010
|
+
_context75.next = 75;
|
|
7942
8011
|
break;
|
|
7943
8012
|
}
|
|
7944
8013
|
tMenu = performance.now();
|
|
7945
8014
|
getActiveMenus = function getActiveMenus() {
|
|
7946
|
-
return
|
|
7947
|
-
var
|
|
7948
|
-
return ((
|
|
8015
|
+
return _this22.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
|
|
8016
|
+
var _this22$schedule;
|
|
8017
|
+
return ((_this22$schedule = _this22.schedule) === null || _this22$schedule === void 0 ? void 0 : _this22$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
|
|
7949
8018
|
});
|
|
7950
8019
|
};
|
|
7951
8020
|
activeMenuList = getActiveMenus();
|
|
7952
8021
|
_context75.t0 = !activeMenuList.length;
|
|
7953
8022
|
if (!_context75.t0) {
|
|
7954
|
-
_context75.next =
|
|
8023
|
+
_context75.next = 72;
|
|
7955
8024
|
break;
|
|
7956
8025
|
}
|
|
7957
|
-
_context75.next =
|
|
8026
|
+
_context75.next = 71;
|
|
7958
8027
|
return this.refreshMenuScheduleCacheAfterEmptyResult();
|
|
7959
|
-
case
|
|
8028
|
+
case 71:
|
|
7960
8029
|
_context75.t0 = _context75.sent;
|
|
7961
|
-
case
|
|
8030
|
+
case 72:
|
|
7962
8031
|
if (!_context75.t0) {
|
|
7963
|
-
_context75.next =
|
|
8032
|
+
_context75.next = 74;
|
|
7964
8033
|
break;
|
|
7965
8034
|
}
|
|
7966
8035
|
activeMenuList = getActiveMenus();
|
|
7967
|
-
case
|
|
8036
|
+
case 74:
|
|
7968
8037
|
perfMark('computeQuery.filterActiveMenu', performance.now() - tMenu, {
|
|
7969
8038
|
totalMenu: menu_list_ids.length,
|
|
7970
8039
|
activeMenu: activeMenuList.length
|
|
7971
8040
|
});
|
|
7972
|
-
case
|
|
8041
|
+
case 75:
|
|
7973
8042
|
tFilter = performance.now();
|
|
7974
8043
|
productScope = this.getProductScopeByMenuConfig(activeMenuList);
|
|
7975
8044
|
scopedProductIds = this.products.getProductIdsByScope(productScope);
|
|
@@ -7980,21 +8049,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
7980
8049
|
});
|
|
7981
8050
|
tPrice = performance.now();
|
|
7982
8051
|
if (!(scopedProductIds.length > 0)) {
|
|
7983
|
-
_context75.next =
|
|
8052
|
+
_context75.next = 86;
|
|
7984
8053
|
break;
|
|
7985
8054
|
}
|
|
7986
|
-
_context75.next =
|
|
8055
|
+
_context75.next = 83;
|
|
7987
8056
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
7988
8057
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
7989
8058
|
productIds: productScope.isAllProducts ? undefined : scopedProductIds
|
|
7990
8059
|
});
|
|
7991
|
-
case
|
|
8060
|
+
case 83:
|
|
7992
8061
|
_context75.t1 = _context75.sent;
|
|
7993
|
-
_context75.next =
|
|
8062
|
+
_context75.next = 87;
|
|
7994
8063
|
break;
|
|
7995
|
-
case
|
|
8064
|
+
case 86:
|
|
7996
8065
|
_context75.t1 = [];
|
|
7997
|
-
case
|
|
8066
|
+
case 87:
|
|
7998
8067
|
filteredProducts = _context75.t1;
|
|
7999
8068
|
perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
|
|
8000
8069
|
count: filteredProducts.length,
|
|
@@ -8042,7 +8111,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8042
8111
|
message: '',
|
|
8043
8112
|
status: true
|
|
8044
8113
|
});
|
|
8045
|
-
case
|
|
8114
|
+
case 103:
|
|
8046
8115
|
case "end":
|
|
8047
8116
|
return _context75.stop();
|
|
8048
8117
|
}
|
|
@@ -8254,7 +8323,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8254
8323
|
}, {
|
|
8255
8324
|
key: "notifySalesSearchSubscribers",
|
|
8256
8325
|
value: function notifySalesSearchSubscribers(payload) {
|
|
8257
|
-
var
|
|
8326
|
+
var _this23 = this;
|
|
8258
8327
|
if (this.salesSearchSubscribers.size === 0) return;
|
|
8259
8328
|
var changedOrders = this.extractChangedOrdersFromPayload(payload);
|
|
8260
8329
|
if (changedOrders.length === 0) {
|
|
@@ -8272,21 +8341,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
8272
8341
|
subscriber = _step20$value[1];
|
|
8273
8342
|
try {
|
|
8274
8343
|
var changedVisibleOrders = changedOrders.filter(function (order) {
|
|
8275
|
-
var orderId =
|
|
8344
|
+
var orderId = _this23.getSalesSearchOrderId(order);
|
|
8276
8345
|
return !!orderId && subscriber.visibleOrderIds.has(orderId);
|
|
8277
8346
|
});
|
|
8278
8347
|
if (changedVisibleOrders.length === 0) {
|
|
8279
8348
|
return 1; // continue
|
|
8280
8349
|
}
|
|
8281
|
-
subscriber.callback(
|
|
8282
|
-
|
|
8350
|
+
subscriber.callback(_this23.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
|
|
8351
|
+
_this23.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
|
|
8283
8352
|
subscriberId: subscriberId,
|
|
8284
8353
|
kind: subscriber.kind,
|
|
8285
8354
|
count: changedVisibleOrders.length
|
|
8286
8355
|
});
|
|
8287
8356
|
} catch (error) {
|
|
8288
8357
|
var errorMessage = error instanceof Error ? error.message : String(error);
|
|
8289
|
-
|
|
8358
|
+
_this23.logError('notifySalesSearchSubscribers: 推送失败', {
|
|
8290
8359
|
subscriberId: subscriberId,
|
|
8291
8360
|
error: errorMessage
|
|
8292
8361
|
});
|