@pisell/pisellos 2.1.140 → 2.1.142

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.
@@ -11,10 +11,12 @@ export declare class ScanOrderLoggerModule extends BaseModule implements Module,
11
11
  protected defaultName: string;
12
12
  protected defaultVersion: string;
13
13
  private store;
14
+ private window?;
14
15
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
15
16
  setContext(context: ScanOrderLoggerContext): void;
16
17
  setProvider(provider: ScanOrderLoggerProviderType): void;
17
18
  setProviderConfig(providerConfig: ScanOrderLoggerProviderConfig): void;
19
+ private getCurrentHost;
18
20
  private buildRecord;
19
21
  addLog(params: ScanOrderLogInput): Promise<void>;
20
22
  }
@@ -46,6 +46,7 @@ export var ScanOrderLoggerModule = /*#__PURE__*/function (_BaseModule) {
46
46
  _defineProperty(_assertThisInitialized(_this), "defaultName", 'scanOrderLogger');
47
47
  _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
48
48
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
49
+ _defineProperty(_assertThisInitialized(_this), "window", void 0);
49
50
  return _this;
50
51
  }
51
52
  _createClass(ScanOrderLoggerModule, [{
@@ -64,6 +65,7 @@ export var ScanOrderLoggerModule = /*#__PURE__*/function (_BaseModule) {
64
65
  options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
65
66
  this.core = core;
66
67
  this.store = options.store;
68
+ this.window = core.getPlugin('window') || undefined;
67
69
  provider = ((_options$otherParams = options.otherParams) === null || _options$otherParams === void 0 ? void 0 : _options$otherParams.provider) || 'feishu';
68
70
  providerConfig = ((_options$otherParams2 = options.otherParams) === null || _options$otherParams2 === void 0 ? void 0 : _options$otherParams2.providerConfig) || {};
69
71
  context = ((_options$otherParams3 = options.otherParams) === null || _options$otherParams3 === void 0 ? void 0 : _options$otherParams3.context) || {};
@@ -73,7 +75,7 @@ export var ScanOrderLoggerModule = /*#__PURE__*/function (_BaseModule) {
73
75
  grafana: _objectSpread(_objectSpread({}, defaultProviderConfig.grafana), providerConfig.grafana || {})
74
76
  });
75
77
  this.store.context = context;
76
- case 9:
78
+ case 10:
77
79
  case "end":
78
80
  return _context.stop();
79
81
  }
@@ -102,16 +104,27 @@ export var ScanOrderLoggerModule = /*#__PURE__*/function (_BaseModule) {
102
104
  grafana: _objectSpread(_objectSpread({}, this.store.providerConfig.grafana || {}), providerConfig.grafana || {})
103
105
  });
104
106
  }
107
+ }, {
108
+ key: "getCurrentHost",
109
+ value: function getCurrentHost() {
110
+ var _this$window;
111
+ var host = (_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.location) === null || _this$window === void 0 ? void 0 : _this$window.host;
112
+ if (typeof host === 'string' && host.length > 0) return host;
113
+ return undefined;
114
+ }
105
115
  }, {
106
116
  key: "buildRecord",
107
117
  value: function buildRecord(params) {
118
+ var host = this.getCurrentHost();
108
119
  return {
109
120
  level: params.level || 'info',
110
121
  title: params.title,
111
122
  timestamp: params.timestamp || dayjs().format('YYYY-MM-DD HH:mm:ss'),
112
123
  payload: params.payload || {},
113
124
  extra: params.extra || {},
114
- context: this.store.context || {}
125
+ context: _objectSpread(_objectSpread({}, this.store.context || {}), host ? {
126
+ host: host
127
+ } : {})
115
128
  };
116
129
  }
117
130
  }, {
@@ -310,7 +310,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
310
310
  date: string;
311
311
  status: string;
312
312
  week: string;
313
- weekNum: 0 | 2 | 1 | 4 | 3 | 5 | 6;
313
+ weekNum: 0 | 1 | 4 | 2 | 3 | 5 | 6;
314
314
  }[]>;
315
315
  submitTimeSlot(timeSlots: TimeSliceItem): void;
316
316
  private getScheduleDataByIds;
@@ -5,6 +5,7 @@ import type { UpdateProductInOrderParams } from '../../modules/Order/types';
5
5
  import type { Discount } from '../../modules/Discount/types';
6
6
  import { type CartItemSummary, type PaxInfo, type QuantityCheckResult, type QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
7
7
  import type { StrategyConfig } from '../../model/strategy/type';
8
+ import type { ProductData } from '../../modules/Product/types';
8
9
  export * from './types';
9
10
  interface ScanOrderItemRuleRuntimeConfig {
10
11
  strategyConfigs?: StrategyConfig[];
@@ -41,6 +42,7 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
41
42
  private logMethodStart;
42
43
  private logMethodSuccess;
43
44
  private logMethodError;
45
+ private assertProductListLoaded;
44
46
  addLog(params: ScanOrderAddLogParams): Promise<void>;
45
47
  private normalizeCustomerId;
46
48
  private resolveCustomerIdFromLoginPayload;
@@ -122,7 +124,7 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
122
124
  orderAmount: number;
123
125
  orderItems: any[];
124
126
  }>;
125
- getProductList(): Promise<any>;
127
+ getProductList(): Promise<ProductData[]>;
126
128
  getOtherParams(): Record<string, any>;
127
129
  setOtherParams(params: Record<string, any>, { cover }?: {
128
130
  cover?: boolean;
@@ -192,6 +192,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
192
192
  })
193
193
  });
194
194
  }
195
+ }, {
196
+ key: "assertProductListLoaded",
197
+ value: function assertProductListLoaded(method, result) {
198
+ var payload = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
199
+ if (Array.isArray(result)) return result;
200
+ var error = result instanceof Error ? result : new Error('商品列表接口返回异常');
201
+ this.logMethodError(method, error, payload);
202
+ error.__scanOrderLogged = true;
203
+ throw error;
204
+ }
195
205
  }, {
196
206
  key: "addLog",
197
207
  value: function () {
@@ -2509,7 +2519,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2509
2519
  key: "checkResourceAvailable",
2510
2520
  value: function () {
2511
2521
  var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId, hasOrderId) {
2512
- var _this$otherParams$bus, _this$otherParams10, _this$otherParams$cha, _this$otherParams11, _this$otherParams12, _this$otherParams12$g, _occupyDetail$form_re, _occupyDetail$form_re2, _this$otherParams13, _this$store$order5, _this$store$order7, _this$store$order7$ge, _this$otherParams14, businessCode, channel, openDataTarget, openData, dineInConfig, closedBehaviorValue, closedMessage, basicUnavailableMessage, pauseMessage, makeShopClosed, operatingHourIds, outsideOperatingHours, scheduleList, now, tempOrder, reservationLinkIds, pendingRequestEntryPax, pendingRequestPaxMin, pendingRequestPaxMax, reservationProductList, scheduleDate, scheduleDatetime, loaded, occupancyMinutes, paxBounds, occupyDetail, resourceSelectType, resourceState, availabilityInfo, _this$store$order6, _res$data, res, entryPaxNumber, lastOrderInfo, historicalItems;
2522
+ var _this$otherParams$bus, _this$otherParams10, _this$otherParams$cha, _this$otherParams11, _this$otherParams12, _this$otherParams12$g, _occupyDetail$form_re, _occupyDetail$form_re2, _this$otherParams13, _this$store$order5, _this$store$order7, _this$store$order7$ge, _this$otherParams14, businessCode, channel, openDataTarget, openData, dineInConfig, closedBehaviorValue, closedMessage, basicUnavailableMessage, pauseMessage, makeShopClosed, operatingHourIds, outsideOperatingHours, scheduleList, now, tempOrder, reservationLinkIds, pendingRequestEntryPax, pendingRequestPaxMin, pendingRequestPaxMax, reservationProductList, scheduleDate, scheduleDatetime, loaded, occupancyMinutes, paxBounds, error, occupyDetail, resourceSelectType, resourceState, availabilityInfo, _this$store$order6, _res$data, res, entryPaxNumber, lastOrderInfo, historicalItems;
2513
2523
  return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2514
2524
  while (1) switch (_context36.prev = _context36.next) {
2515
2525
  case 0:
@@ -2643,13 +2653,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2643
2653
  }
2644
2654
  } else {
2645
2655
  this.enabledReservationRuleProducts = [];
2646
- void this.addScanOrderLog({
2647
- level: 'error',
2648
- title: '[ScanOrder] enabled_reservation_rules product query failed',
2649
- payload: {
2650
- linkIds: reservationLinkIds,
2651
- error: this.serializeError(loaded)
2652
- }
2656
+ error = loaded instanceof Error ? loaded : new Error('预约规则商品列表接口返回异常');
2657
+ this.logMethodError('loadReservationRuleProducts', error, {
2658
+ resourceId: resourceId,
2659
+ reservationLinkIds: reservationLinkIds,
2660
+ scheduleDate: scheduleDate,
2661
+ scheduleDatetime: scheduleDatetime,
2662
+ cacheId: this.cacheId
2653
2663
  });
2654
2664
  }
2655
2665
  case 46:
@@ -2820,7 +2830,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2820
2830
  value: function () {
2821
2831
  var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
2822
2832
  var _this$otherParams15;
2823
- var menu_list_ids, _this$store$products, res, formattedRes;
2833
+ var menu_list_ids, res, productList, formattedRes;
2824
2834
  return _regeneratorRuntime().wrap(function _callee38$(_context38) {
2825
2835
  while (1) switch (_context38.prev = _context38.next) {
2826
2836
  case 0:
@@ -2830,30 +2840,45 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2830
2840
  return Number(n.value);
2831
2841
  })) || [];
2832
2842
  _context38.prev = 2;
2833
- _context38.next = 5;
2834
- return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
2843
+ if (this.store.products) {
2844
+ _context38.next = 5;
2845
+ break;
2846
+ }
2847
+ throw new Error('products 模块未初始化');
2848
+ case 5:
2849
+ _context38.next = 7;
2850
+ return this.store.products.loadProducts({
2835
2851
  menu_list_ids: menu_list_ids,
2836
2852
  cacheId: this.cacheId,
2837
2853
  schedule_date: dayjs().format('YYYY-MM-DD'),
2838
2854
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
2839
2855
  });
2840
- case 5:
2856
+ case 7:
2841
2857
  res = _context38.sent;
2842
- formattedRes = attachItemRuleLimitsToTopLevelProducts(res, this.store.itemRuleQuantityLimits || []);
2858
+ productList = this.assertProductListLoaded('getProductList', res, {
2859
+ menu_list_ids: menu_list_ids,
2860
+ cacheId: this.cacheId
2861
+ });
2862
+ formattedRes = attachItemRuleLimitsToTopLevelProducts(productList, this.store.itemRuleQuantityLimits || []);
2843
2863
  this.logMethodSuccess('getProductList', {
2844
2864
  menuCount: menu_list_ids.length
2845
2865
  });
2846
2866
  return _context38.abrupt("return", formattedRes);
2847
- case 11:
2848
- _context38.prev = 11;
2867
+ case 14:
2868
+ _context38.prev = 14;
2849
2869
  _context38.t0 = _context38["catch"](2);
2850
- this.logMethodError('getProductList', _context38.t0.message);
2870
+ if (!(_context38.t0 !== null && _context38.t0 !== void 0 && _context38.t0.__scanOrderLogged)) {
2871
+ this.logMethodError('getProductList', _context38.t0, {
2872
+ menu_list_ids: menu_list_ids,
2873
+ cacheId: this.cacheId
2874
+ });
2875
+ }
2851
2876
  throw _context38.t0;
2852
- case 15:
2877
+ case 18:
2853
2878
  case "end":
2854
2879
  return _context38.stop();
2855
2880
  }
2856
- }, _callee38, this, [[2, 11]]);
2881
+ }, _callee38, this, [[2, 14]]);
2857
2882
  }));
2858
2883
  function getProductList() {
2859
2884
  return _getProductList.apply(this, arguments);
@@ -41,6 +41,8 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
41
41
  private loadOpenDataConfigInFlight;
42
42
  private static readonly OPEN_DATA_CACHE_TTL;
43
43
  private getLoggerContext;
44
+ private safeStringify;
45
+ private pickErrorMessage;
44
46
  private serializeError;
45
47
  private addVenueBookingLog;
46
48
  private logMethodStart;
@@ -112,6 +112,26 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
112
112
  moduleName: 'venueBooking'
113
113
  };
114
114
  }
115
+ }, {
116
+ key: "safeStringify",
117
+ value: function safeStringify(value) {
118
+ try {
119
+ return JSON.stringify(value);
120
+ } catch (_unused) {
121
+ return undefined;
122
+ }
123
+ }
124
+ }, {
125
+ key: "pickErrorMessage",
126
+ value: function pickErrorMessage(error) {
127
+ var _error$data, _error$response, _error$error;
128
+ var candidates = [error.message, (_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.message, (_error$response = error.response) === null || _error$response === void 0 || (_error$response = _error$response.data) === null || _error$response === void 0 ? void 0 : _error$response.message, (_error$error = error.error) === null || _error$error === void 0 ? void 0 : _error$error.message];
129
+ for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
130
+ var candidate = _candidates[_i];
131
+ if (typeof candidate === 'string' && candidate.trim()) return candidate;
132
+ }
133
+ return undefined;
134
+ }
115
135
  }, {
116
136
  key: "serializeError",
117
137
  value: function serializeError(error) {
@@ -122,6 +142,21 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
122
142
  stack: error.stack
123
143
  };
124
144
  }
145
+ if (error && _typeof(error) === 'object') {
146
+ var raw = error;
147
+ var message = this.pickErrorMessage(raw) || this.safeStringify(raw) || String(error);
148
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, typeof raw.name === 'string' ? {
149
+ name: raw.name
150
+ } : {}), {}, {
151
+ message: message
152
+ }, 'code' in raw ? {
153
+ code: raw.code
154
+ } : {}), 'status' in raw ? {
155
+ status: raw.status
156
+ } : {}), this.safeStringify(raw) ? {
157
+ raw: this.safeStringify(raw)
158
+ } : {});
159
+ }
125
160
  return {
126
161
  message: String(error)
127
162
  };
@@ -246,8 +281,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
246
281
  value: function resolveCustomerIdFromLoginPayload(payload) {
247
282
  var _payload$user, _payload$user2, _payload$user3, _payload$user4, _payload$account, _payload$account2, _payload$account3, _payload$_origin;
248
283
  var candidates = [payload === null || payload === void 0 ? void 0 : payload.customerId, payload === null || payload === void 0 ? void 0 : payload.customer_id, payload === null || payload === void 0 ? void 0 : payload.id, payload === null || payload === void 0 || (_payload$user = payload.user) === null || _payload$user === void 0 ? void 0 : _payload$user.customerId, payload === null || payload === void 0 || (_payload$user2 = payload.user) === null || _payload$user2 === void 0 ? void 0 : _payload$user2.customer_id, payload === null || payload === void 0 || (_payload$user3 = payload.user) === null || _payload$user3 === void 0 ? void 0 : _payload$user3.id, payload === null || payload === void 0 || (_payload$user4 = payload.user) === null || _payload$user4 === void 0 || (_payload$user4 = _payload$user4._origin) === null || _payload$user4 === void 0 ? void 0 : _payload$user4.customer_id, payload === null || payload === void 0 || (_payload$account = payload.account) === null || _payload$account === void 0 ? void 0 : _payload$account.customerId, payload === null || payload === void 0 || (_payload$account2 = payload.account) === null || _payload$account2 === void 0 ? void 0 : _payload$account2.customer_id, payload === null || payload === void 0 || (_payload$account3 = payload.account) === null || _payload$account3 === void 0 ? void 0 : _payload$account3.id, payload === null || payload === void 0 || (_payload$_origin = payload._origin) === null || _payload$_origin === void 0 ? void 0 : _payload$_origin.customer_id];
249
- for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
250
- var candidate = _candidates[_i];
284
+ for (var _i2 = 0, _candidates2 = candidates; _i2 < _candidates2.length; _i2++) {
285
+ var candidate = _candidates2[_i2];
251
286
  var customerId = this.normalizeCustomerId(candidate);
252
287
  if (customerId) return customerId;
253
288
  }
@@ -1001,7 +1036,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1001
1036
  key: "fetchResourceAvailability",
1002
1037
  value: function () {
1003
1038
  var _fetchResourceAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
1004
- var venueProducts, resourceIds, config, crossDay, effectiveEndDate, res, rawData, _iterator2, _step2, item, _i2, _rawData, _item, mappings, _iterator3, _step3, mapping;
1039
+ var venueProducts, resourceIds, config, crossDay, effectiveEndDate, res, rawData, _iterator2, _step2, item, _i3, _rawData, _item, mappings, _iterator3, _step3, mapping;
1005
1040
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1006
1041
  while (1) switch (_context15.prev = _context15.next) {
1007
1042
  case 0:
@@ -1069,13 +1104,13 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1069
1104
  }
1070
1105
  }
1071
1106
  this.store.rawResourceData = rawData;
1072
- _i2 = 0, _rawData = rawData;
1107
+ _i3 = 0, _rawData = rawData;
1073
1108
  case 24:
1074
- if (!(_i2 < _rawData.length)) {
1109
+ if (!(_i3 < _rawData.length)) {
1075
1110
  _context15.next = 34;
1076
1111
  break;
1077
1112
  }
1078
- _item = _rawData[_i2];
1113
+ _item = _rawData[_i3];
1079
1114
  mappings = this.resourceProductMap.get(_item.resourceId);
1080
1115
  if (mappings) {
1081
1116
  _context15.next = 29;
@@ -1096,7 +1131,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1096
1131
  _iterator3.f();
1097
1132
  }
1098
1133
  case 31:
1099
- _i2++;
1134
+ _i3++;
1100
1135
  _context15.next = 24;
1101
1136
  break;
1102
1137
  case 34:
@@ -2794,8 +2829,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2794
2829
  var key = buildProductKey(productId, normalizedVariantId);
2795
2830
  if (!sourceMap.has(key)) sourceMap.set(key, node);
2796
2831
  }
2797
- for (var _i3 = 0, _Object$values = Object.values(node); _i3 < _Object$values.length; _i3++) {
2798
- var childValue = _Object$values[_i3];
2832
+ for (var _i4 = 0, _Object$values = Object.values(node); _i4 < _Object$values.length; _i4++) {
2833
+ var childValue = _Object$values[_i4];
2799
2834
  if (childValue && _typeof(childValue) === 'object') collectFromValue(childValue);
2800
2835
  }
2801
2836
  };
@@ -3322,7 +3357,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
3322
3357
  var raw = this.window.sessionStorage.getItem(key) || '{}';
3323
3358
  var parsed = JSON.parse(raw);
3324
3359
  return parsed && _typeof(parsed) === 'object' ? parsed : {};
3325
- } catch (_unused2) {
3360
+ } catch (_unused3) {
3326
3361
  return {};
3327
3362
  }
3328
3363
  }
@@ -0,0 +1,49 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/model/strategy/adapter/promotion/index.ts
30
+ var promotion_exports = {};
31
+ __export(promotion_exports, {
32
+ BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
+ PromotionAdapter: () => import_adapter.PromotionAdapter,
34
+ PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
+ X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
+ default: () => import_adapter2.default
37
+ });
38
+ module.exports = __toCommonJS(promotion_exports);
39
+ var import_evaluator = require("./evaluator");
40
+ var import_adapter = require("./adapter");
41
+ var import_adapter2 = __toESM(require("./adapter"));
42
+ var import_examples = require("./examples");
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ BUY_X_GET_Y_FREE_STRATEGY,
46
+ PromotionAdapter,
47
+ PromotionEvaluator,
48
+ X_ITEMS_FOR_Y_PRICE_STRATEGY
49
+ });
@@ -11,10 +11,12 @@ export declare class ScanOrderLoggerModule extends BaseModule implements Module,
11
11
  protected defaultName: string;
12
12
  protected defaultVersion: string;
13
13
  private store;
14
+ private window?;
14
15
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
15
16
  setContext(context: ScanOrderLoggerContext): void;
16
17
  setProvider(provider: ScanOrderLoggerProviderType): void;
17
18
  setProviderConfig(providerConfig: ScanOrderLoggerProviderConfig): void;
19
+ private getCurrentHost;
18
20
  private buildRecord;
19
21
  addLog(params: ScanOrderLogInput): Promise<void>;
20
22
  }
@@ -60,6 +60,7 @@ var ScanOrderLoggerModule = class extends import_BaseModule.BaseModule {
60
60
  var _a, _b, _c;
61
61
  this.core = core;
62
62
  this.store = options.store;
63
+ this.window = core.getPlugin("window") || void 0;
63
64
  const provider = ((_a = options.otherParams) == null ? void 0 : _a.provider) || "feishu";
64
65
  const providerConfig = ((_b = options.otherParams) == null ? void 0 : _b.providerConfig) || {};
65
66
  const context = ((_c = options.otherParams) == null ? void 0 : _c.context) || {};
@@ -101,14 +102,25 @@ var ScanOrderLoggerModule = class extends import_BaseModule.BaseModule {
101
102
  }
102
103
  };
103
104
  }
105
+ getCurrentHost() {
106
+ var _a, _b;
107
+ const host = (_b = (_a = this.window) == null ? void 0 : _a.location) == null ? void 0 : _b.host;
108
+ if (typeof host === "string" && host.length > 0)
109
+ return host;
110
+ return void 0;
111
+ }
104
112
  buildRecord(params) {
113
+ const host = this.getCurrentHost();
105
114
  return {
106
115
  level: params.level || "info",
107
116
  title: params.title,
108
117
  timestamp: params.timestamp || (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss"),
109
118
  payload: params.payload || {},
110
119
  extra: params.extra || {},
111
- context: this.store.context || {}
120
+ context: {
121
+ ...this.store.context || {},
122
+ ...host ? { host } : {}
123
+ }
112
124
  };
113
125
  }
114
126
  async addLog(params) {
@@ -310,7 +310,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
310
310
  date: string;
311
311
  status: string;
312
312
  week: string;
313
- weekNum: 0 | 2 | 1 | 4 | 3 | 5 | 6;
313
+ weekNum: 0 | 1 | 4 | 2 | 3 | 5 | 6;
314
314
  }[]>;
315
315
  submitTimeSlot(timeSlots: TimeSliceItem): void;
316
316
  private getScheduleDataByIds;
@@ -5,6 +5,7 @@ import type { UpdateProductInOrderParams } from '../../modules/Order/types';
5
5
  import type { Discount } from '../../modules/Discount/types';
6
6
  import { type CartItemSummary, type PaxInfo, type QuantityCheckResult, type QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
7
7
  import type { StrategyConfig } from '../../model/strategy/type';
8
+ import type { ProductData } from '../../modules/Product/types';
8
9
  export * from './types';
9
10
  interface ScanOrderItemRuleRuntimeConfig {
10
11
  strategyConfigs?: StrategyConfig[];
@@ -41,6 +42,7 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
41
42
  private logMethodStart;
42
43
  private logMethodSuccess;
43
44
  private logMethodError;
45
+ private assertProductListLoaded;
44
46
  addLog(params: ScanOrderAddLogParams): Promise<void>;
45
47
  private normalizeCustomerId;
46
48
  private resolveCustomerIdFromLoginPayload;
@@ -122,7 +124,7 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
122
124
  orderAmount: number;
123
125
  orderItems: any[];
124
126
  }>;
125
- getProductList(): Promise<any>;
127
+ getProductList(): Promise<ProductData[]>;
126
128
  getOtherParams(): Record<string, any>;
127
129
  setOtherParams(params: Record<string, any>, { cover }?: {
128
130
  cover?: boolean;
@@ -155,6 +155,14 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
155
155
  }
156
156
  });
157
157
  }
158
+ assertProductListLoaded(method, result, payload = {}) {
159
+ if (Array.isArray(result))
160
+ return result;
161
+ const error = result instanceof Error ? result : new Error("商品列表接口返回异常");
162
+ this.logMethodError(method, error, payload);
163
+ error.__scanOrderLogged = true;
164
+ throw error;
165
+ }
158
166
  async addLog(params) {
159
167
  await this.addScanOrderLog({
160
168
  ...params,
@@ -1559,13 +1567,13 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1559
1567
  }
1560
1568
  } else {
1561
1569
  this.enabledReservationRuleProducts = [];
1562
- void this.addScanOrderLog({
1563
- level: "error",
1564
- title: "[ScanOrder] enabled_reservation_rules product query failed",
1565
- payload: {
1566
- linkIds: reservationLinkIds,
1567
- error: this.serializeError(loaded)
1568
- }
1570
+ const error = loaded instanceof Error ? loaded : new Error("预约规则商品列表接口返回异常");
1571
+ this.logMethodError("loadReservationRuleProducts", error, {
1572
+ resourceId,
1573
+ reservationLinkIds,
1574
+ scheduleDate,
1575
+ scheduleDatetime,
1576
+ cacheId: this.cacheId
1569
1577
  });
1570
1578
  }
1571
1579
  }
@@ -1681,18 +1689,24 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1681
1689
  }
1682
1690
  // 获取商品列表
1683
1691
  async getProductList() {
1684
- var _a, _b, _c;
1692
+ var _a, _b;
1685
1693
  this.logMethodStart("getProductList");
1686
1694
  const menu_list_ids = ((_b = (_a = this.otherParams) == null ? void 0 : _a.dineInConfig) == null ? void 0 : _b["menu.associated_menus"].map((n) => Number(n.value))) || [];
1687
1695
  try {
1688
- const res = await ((_c = this.store.products) == null ? void 0 : _c.loadProducts({
1696
+ if (!this.store.products)
1697
+ throw new Error("products 模块未初始化");
1698
+ const res = await this.store.products.loadProducts({
1689
1699
  menu_list_ids,
1690
1700
  cacheId: this.cacheId,
1691
1701
  schedule_date: (0, import_dayjs.default)().format("YYYY-MM-DD"),
1692
1702
  schedule_datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
1693
- }));
1703
+ });
1704
+ const productList = this.assertProductListLoaded("getProductList", res, {
1705
+ menu_list_ids,
1706
+ cacheId: this.cacheId
1707
+ });
1694
1708
  const formattedRes = (0, import_utils.attachItemRuleLimitsToTopLevelProducts)(
1695
- res,
1709
+ productList,
1696
1710
  this.store.itemRuleQuantityLimits || []
1697
1711
  );
1698
1712
  this.logMethodSuccess("getProductList", {
@@ -1700,7 +1714,12 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
1700
1714
  });
1701
1715
  return formattedRes;
1702
1716
  } catch (error) {
1703
- this.logMethodError("getProductList", error.message);
1717
+ if (!(error == null ? void 0 : error.__scanOrderLogged)) {
1718
+ this.logMethodError("getProductList", error, {
1719
+ menu_list_ids,
1720
+ cacheId: this.cacheId
1721
+ });
1722
+ }
1704
1723
  throw error;
1705
1724
  }
1706
1725
  }
@@ -41,6 +41,8 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
41
41
  private loadOpenDataConfigInFlight;
42
42
  private static readonly OPEN_DATA_CACHE_TTL;
43
43
  private getLoggerContext;
44
+ private safeStringify;
45
+ private pickErrorMessage;
44
46
  private serializeError;
45
47
  private addVenueBookingLog;
46
48
  private logMethodStart;
@@ -118,6 +118,27 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
118
118
  moduleName: "venueBooking"
119
119
  };
120
120
  }
121
+ safeStringify(value) {
122
+ try {
123
+ return JSON.stringify(value);
124
+ } catch {
125
+ return void 0;
126
+ }
127
+ }
128
+ pickErrorMessage(error) {
129
+ var _a, _b, _c, _d;
130
+ const candidates = [
131
+ error.message,
132
+ (_a = error.data) == null ? void 0 : _a.message,
133
+ (_c = (_b = error.response) == null ? void 0 : _b.data) == null ? void 0 : _c.message,
134
+ (_d = error.error) == null ? void 0 : _d.message
135
+ ];
136
+ for (const candidate of candidates) {
137
+ if (typeof candidate === "string" && candidate.trim())
138
+ return candidate;
139
+ }
140
+ return void 0;
141
+ }
121
142
  serializeError(error) {
122
143
  if (error instanceof Error) {
123
144
  return {
@@ -126,6 +147,17 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
126
147
  stack: error.stack
127
148
  };
128
149
  }
150
+ if (error && typeof error === "object") {
151
+ const raw = error;
152
+ const message = this.pickErrorMessage(raw) || this.safeStringify(raw) || String(error);
153
+ return {
154
+ ...typeof raw.name === "string" ? { name: raw.name } : {},
155
+ message,
156
+ ..."code" in raw ? { code: raw.code } : {},
157
+ ..."status" in raw ? { status: raw.status } : {},
158
+ ...this.safeStringify(raw) ? { raw: this.safeStringify(raw) } : {}
159
+ };
160
+ }
129
161
  return {
130
162
  message: String(error)
131
163
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.140",
4
+ "version": "2.1.142",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",