@pisell/pisellos 2.2.266 → 2.2.271

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.
@@ -28,6 +28,8 @@ declare class PisellOSCore implements PisellCore {
28
28
  getModule<T extends Module>(name: string): T | null;
29
29
  getModuleExports<T = any>(name: string): T | null;
30
30
  hasModule(name: string): boolean;
31
+ /** 返回当前已注册模块名,供宿主在切换店铺等生命周期中定向清理运行态。 */
32
+ getModuleNames(): string[];
31
33
  destroy(): Promise<void>;
32
34
  setContext(ctx: Partial<BusinessContext>): void;
33
35
  /**
@@ -300,6 +300,13 @@ var PisellOSCore = /*#__PURE__*/function () {
300
300
  return this.modules.has(name);
301
301
  }
302
302
 
303
+ /** 返回当前已注册模块名,供宿主在切换店铺等生命周期中定向清理运行态。 */
304
+ }, {
305
+ key: "getModuleNames",
306
+ value: function getModuleNames() {
307
+ return Array.from(this.modules.keys());
308
+ }
309
+
303
310
  // 销毁方法
304
311
  }, {
305
312
  key: "destroy",
@@ -27,6 +27,8 @@ export declare class OpenDataModule extends BaseModule implements Module {
27
27
  fetchOpenData(params: OpenDataFetchParams): Promise<OpenDataConfig>;
28
28
  getOpenData(): OpenDataConfig | null;
29
29
  getLastFetchedAt(): number | null;
30
+ /** 清除内存与 sessionStorage 镜像中的 OpenData,供宿主切店时调用。 */
31
+ clearCache(): void;
30
32
  checkAvailability(scheduleModule?: ScheduleModule): OpenDataAvailabilityResult;
31
33
  storeChange(): void;
32
34
  }
@@ -166,6 +166,14 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
166
166
  var _this$store$lastFetch;
167
167
  return (_this$store$lastFetch = this.store.lastFetchedAt) !== null && _this$store$lastFetch !== void 0 ? _this$store$lastFetch : null;
168
168
  }
169
+
170
+ /** 清除内存与 sessionStorage 镜像中的 OpenData,供宿主切店时调用。 */
171
+ }, {
172
+ key: "clearCache",
173
+ value: function clearCache() {
174
+ this.store.data = null;
175
+ this.store.lastFetchedAt = null;
176
+ }
169
177
  }, {
170
178
  key: "checkAvailability",
171
179
  value: function checkAvailability(scheduleModule) {
@@ -485,7 +485,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
485
485
  generateIdempotencyToken(): string;
486
486
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
487
487
  createOrder(params: CommitOrderParams['query']): {
488
- type: "virtual" | "appointment_booking";
488
+ type: "appointment_booking" | "virtual";
489
489
  platform: string;
490
490
  sales_channel: string;
491
491
  order_sales_channel: string;
@@ -1178,12 +1178,18 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1178
1178
  return false;
1179
1179
  });
1180
1180
 
1181
- // 选择第一个适用的优惠券(已经按过期时间排序)
1182
- // 如果有 isScan isSelected 的折扣卡,则优先选中,否则再选择第一个
1183
- // 用于处理:先手动扫描了一张折扣卡,扫描完以后带入客户信息,但是之前那张折扣卡不是最优惠的情况
1184
- var selectedDiscountCard = applicableDiscounts.find(function (n) {
1181
+ // 用户显式点击某张折扣卡时,本次选择优先于自动排序和扫码默认选择。
1182
+ // 目标仍必须在当前商品的 applicableDiscounts 中,因此不会绕过 Holder、时间或商品范围校验。
1183
+ var explicitlySelectedDiscountCard = (options === null || options === void 0 ? void 0 : options.isSelected) === true && options.discountId !== undefined ? applicableDiscounts.find(function (discount) {
1184
+ var discountType = discount.tag || discount.type;
1185
+ return String(discount.id) === String(options.discountId) && ['discount_card', 'product_discount_card'].includes(discountType);
1186
+ }) : undefined;
1187
+
1188
+ // 没有显式选择时保持现有行为:扫码且已选中的折扣卡优先,否则使用自动排序第一项。
1189
+ var scannedSelectedDiscountCard = applicableDiscounts.find(function (n) {
1185
1190
  return n.isScan && n.isSelected && (n.tag || n.type) !== 'good_pass';
1186
1191
  });
1192
+ var selectedDiscountCard = explicitlySelectedDiscountCard || scannedSelectedDiscountCard;
1187
1193
  var selectedDiscount = selectedDiscountCard || applicableDiscounts[0];
1188
1194
 
1189
1195
  // 如果是手动折扣,则不适用优惠券
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
314
+ weekNum: 0 | 1 | 2 | 6 | 4 | 3 | 5;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -46,6 +46,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
46
46
  private getIdGeneratorPlugin;
47
47
  private loadOpenDataConfig;
48
48
  getOpenData(): Promise<OpenDataConfig | null>;
49
+ /** 清除店铺级 OpenData;下一次 getOpenData 时会重新拉取。 */
50
+ clearOpenDataCache(): void;
49
51
  private getShortNumberOrDeviceId;
50
52
  private configureIdGeneratorFromOpenData;
51
53
  private normalizePositiveInteger;
@@ -189,10 +191,12 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
189
191
  */
190
192
  getCustomer(): ICustomer | null;
191
193
  /**
192
- * 通过 ids 获取商品列表(不加载到模块中)
193
- * @returns 商品列表
194
+ * 通过 ids 获取商品列表;默认只读取内存,显式开启 loadMissing 时按当前订单上下文补查缺失商品。
195
+ * 补查直接写入 ProductList,不更新 BookingTicket.productCatalog,避免当前商品列表被查询子集覆盖。
194
196
  */
195
- getProductByIds(ids: number[]): Promise<ProductData[] | undefined>;
197
+ getProductByIds(ids: number[], options?: {
198
+ loadMissing?: boolean;
199
+ }): Promise<ProductData[]>;
196
200
  /**
197
201
  * 获取日程时间段点
198
202
  * @param params 参数
@@ -322,7 +326,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
322
326
  * 获取当前的客户搜索条件
323
327
  * @returns 当前搜索条件
324
328
  */
325
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
329
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
326
330
  /**
327
331
  * 获取客户列表状态(包含滚动加载相关状态)
328
332
  * @returns 客户状态
@@ -337,11 +337,10 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
337
337
  key: "getOpenData",
338
338
  value: function () {
339
339
  var _getOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
340
- var _this$store$openData;
341
340
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
342
341
  while (1) switch (_context3.prev = _context3.next) {
343
342
  case 0:
344
- return _context3.abrupt("return", (_this$store$openData = this.store.openData) === null || _this$store$openData === void 0 ? void 0 : _this$store$openData.getOpenData());
343
+ return _context3.abrupt("return", this.loadOpenDataConfig());
345
344
  case 1:
346
345
  case "end":
347
346
  return _context3.stop();
@@ -352,7 +351,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
352
351
  return _getOpenData.apply(this, arguments);
353
352
  }
354
353
  return getOpenData;
355
- }()
354
+ }() /** 清除店铺级 OpenData;下一次 getOpenData 时会重新拉取。 */
355
+ }, {
356
+ key: "clearOpenDataCache",
357
+ value: function clearOpenDataCache() {
358
+ var _this$store$openData;
359
+ this.loadOpenDataConfigInFlight = null;
360
+ this.otherParams.openData = null;
361
+ (_this$store$openData = this.store.openData) === null || _this$store$openData === void 0 || _this$store$openData.clearCache();
362
+ }
356
363
  }, {
357
364
  key: "getShortNumberOrDeviceId",
358
365
  value: function () {
@@ -1263,24 +1270,88 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1263
1270
  }
1264
1271
 
1265
1272
  /**
1266
- * 通过 ids 获取商品列表(不加载到模块中)
1267
- * @returns 商品列表
1273
+ * 通过 ids 获取商品列表;默认只读取内存,显式开启 loadMissing 时按当前订单上下文补查缺失商品。
1274
+ * 补查直接写入 ProductList,不更新 BookingTicket.productCatalog,避免当前商品列表被查询子集覆盖。
1268
1275
  */
1269
1276
  }, {
1270
1277
  key: "getProductByIds",
1271
1278
  value: (function () {
1272
- var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(ids) {
1279
+ var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(ids, options) {
1280
+ var _this$getOrderCustome, _this$getOrderCustome2, _this$getOrderCustome3;
1281
+ var normalizedIds, localProducts, localProductIds, missingIds, rawBookingDate, bookingDate, customerId, loadedProducts, productById;
1273
1282
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1274
1283
  while (1) switch (_context18.prev = _context18.next) {
1275
1284
  case 0:
1276
- return _context18.abrupt("return", this.store.products.getProductByIds(ids));
1277
- case 1:
1285
+ normalizedIds = Array.from(new Set((ids || []).map(function (id) {
1286
+ return Number(id);
1287
+ }).filter(function (id) {
1288
+ return Number.isFinite(id);
1289
+ })));
1290
+ _context18.next = 3;
1291
+ return this.store.products.getProductByIds(normalizedIds);
1292
+ case 3:
1293
+ _context18.t0 = _context18.sent;
1294
+ if (_context18.t0) {
1295
+ _context18.next = 6;
1296
+ break;
1297
+ }
1298
+ _context18.t0 = [];
1299
+ case 6:
1300
+ localProducts = _context18.t0;
1301
+ if (options !== null && options !== void 0 && options.loadMissing) {
1302
+ _context18.next = 9;
1303
+ break;
1304
+ }
1305
+ return _context18.abrupt("return", localProducts);
1306
+ case 9:
1307
+ localProductIds = new Set(localProducts.map(function (product) {
1308
+ return Number(product.id);
1309
+ }));
1310
+ missingIds = normalizedIds.filter(function (id) {
1311
+ return !localProductIds.has(id);
1312
+ });
1313
+ if (missingIds.length) {
1314
+ _context18.next = 13;
1315
+ break;
1316
+ }
1317
+ return _context18.abrupt("return", localProducts);
1318
+ case 13:
1319
+ rawBookingDate = this.getBookingDate();
1320
+ bookingDate = rawBookingDate && dayjs(rawBookingDate).isValid() ? dayjs(rawBookingDate) : null;
1321
+ customerId = Number((_this$getOrderCustome = (_this$getOrderCustome2 = this.getOrderCustomerSnapshot()) === null || _this$getOrderCustome2 === void 0 ? void 0 : _this$getOrderCustome2.id) !== null && _this$getOrderCustome !== void 0 ? _this$getOrderCustome : (_this$getOrderCustome3 = this.getOrderCustomer()) === null || _this$getOrderCustome3 === void 0 ? void 0 : _this$getOrderCustome3.customer_id);
1322
+ _context18.next = 18;
1323
+ return this.store.products.loadProducts(_objectSpread(_objectSpread({
1324
+ product_ids: missingIds,
1325
+ with_count: ['bundleGroup', 'optionGroup'],
1326
+ with_schedule: 1,
1327
+ cacheId: this.cacheId
1328
+ }, bookingDate ? {
1329
+ schedule_date: bookingDate.format('YYYY-MM-DD'),
1330
+ schedule_datetime: bookingDate.format('YYYY-MM-DD HH:mm:ss')
1331
+ } : {}), Number.isFinite(customerId) && customerId > 0 ? {
1332
+ customer_id: customerId
1333
+ } : {}));
1334
+ case 18:
1335
+ loadedProducts = _context18.sent;
1336
+ productById = new Map();
1337
+ [].concat(_toConsumableArray(localProducts), _toConsumableArray(loadedProducts || [])).forEach(function (product) {
1338
+ var productId = Number(product.id);
1339
+ if (Number.isFinite(productId)) {
1340
+ productById.set(productId, product);
1341
+ }
1342
+ });
1343
+ return _context18.abrupt("return", normalizedIds.map(function (id) {
1344
+ return productById.get(id);
1345
+ }).filter(function (product) {
1346
+ return Boolean(product);
1347
+ }));
1348
+ case 22:
1278
1349
  case "end":
1279
1350
  return _context18.stop();
1280
1351
  }
1281
1352
  }, _callee18, this);
1282
1353
  }));
1283
- function getProductByIds(_x13) {
1354
+ function getProductByIds(_x13, _x14) {
1284
1355
  return _getProductByIds.apply(this, arguments);
1285
1356
  }
1286
1357
  return getProductByIds;
@@ -1314,7 +1385,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1314
1385
  }
1315
1386
  }, _callee19, this);
1316
1387
  }));
1317
- function getScheduleTimePoints(_x14) {
1388
+ function getScheduleTimePoints(_x15) {
1318
1389
  return _getScheduleTimePoints.apply(this, arguments);
1319
1390
  }
1320
1391
  return getScheduleTimePoints;
@@ -1704,7 +1775,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1704
1775
  }
1705
1776
  }, _callee23, this, [[0, 7]]);
1706
1777
  }));
1707
- function changeCustomerPage(_x15, _x16) {
1778
+ function changeCustomerPage(_x16, _x17) {
1708
1779
  return _changeCustomerPage.apply(this, arguments);
1709
1780
  }
1710
1781
  return changeCustomerPage;
@@ -2158,10 +2229,10 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2158
2229
  }, {
2159
2230
  key: "buildAddProductCtx",
2160
2231
  value: function buildAddProductCtx(extra) {
2161
- var _extra$date2, _ref12, _this$getOrderCustome, _this$getOrderCustome2, _this$store$order$get4, _extra$presetStartTim2;
2232
+ var _extra$date2, _ref12, _this$getOrderCustome4, _this$getOrderCustome5, _this$store$order$get4, _extra$presetStartTim2;
2162
2233
  var bookingContextState = this.store.bookingContext.getState();
2163
2234
  var date = (_extra$date2 = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date2 !== void 0 ? _extra$date2 : bookingContextState.date;
2164
- var orderCustomerId = (_ref12 = (_this$getOrderCustome = (_this$getOrderCustome2 = this.getOrderCustomerSnapshot()) === null || _this$getOrderCustome2 === void 0 ? void 0 : _this$getOrderCustome2.id) !== null && _this$getOrderCustome !== void 0 ? _this$getOrderCustome : (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.customer_id) !== null && _ref12 !== void 0 ? _ref12 : undefined;
2235
+ var orderCustomerId = (_ref12 = (_this$getOrderCustome4 = (_this$getOrderCustome5 = this.getOrderCustomerSnapshot()) === null || _this$getOrderCustome5 === void 0 ? void 0 : _this$getOrderCustome5.id) !== null && _this$getOrderCustome4 !== void 0 ? _this$getOrderCustome4 : (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.customer_id) !== null && _ref12 !== void 0 ? _ref12 : undefined;
2165
2236
  return _objectSpread({
2166
2237
  bookingConfig: bookingContextState.bookingConfig,
2167
2238
  resourcesOrigin: bookingContextState.resourcesOrigin,
@@ -2278,7 +2349,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2278
2349
  }
2279
2350
  }, _callee27, this);
2280
2351
  }));
2281
- function updateProductInOrder(_x17) {
2352
+ function updateProductInOrder(_x18) {
2282
2353
  return _updateProductInOrder.apply(this, arguments);
2283
2354
  }
2284
2355
  return updateProductInOrder;
@@ -2387,7 +2458,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2387
2458
  }
2388
2459
  }, _callee28, this, [[4, 21]]);
2389
2460
  }));
2390
- function handleGlobalScanCode(_x18, _x19) {
2461
+ function handleGlobalScanCode(_x19, _x20) {
2391
2462
  return _handleGlobalScanCode.apply(this, arguments);
2392
2463
  }
2393
2464
  return handleGlobalScanCode;
@@ -2485,7 +2556,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2485
2556
  }
2486
2557
  }, _callee29, this);
2487
2558
  }));
2488
- function addAddTimeProductToBooking(_x20) {
2559
+ function addAddTimeProductToBooking(_x21) {
2489
2560
  return _addAddTimeProductToBooking.apply(this, arguments);
2490
2561
  }
2491
2562
  return addAddTimeProductToBooking;
@@ -2588,7 +2659,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2588
2659
  }
2589
2660
  }, _callee30, this, [[13, 31, 34, 37]]);
2590
2661
  }));
2591
- function addAddTimeProductsToBooking(_x21) {
2662
+ function addAddTimeProductsToBooking(_x22) {
2592
2663
  return _addAddTimeProductsToBooking.apply(this, arguments);
2593
2664
  }
2594
2665
  return addAddTimeProductsToBooking;
@@ -2622,7 +2693,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2622
2693
  }
2623
2694
  }, _callee31, this);
2624
2695
  }));
2625
- function setOtherParams(_x22) {
2696
+ function setOtherParams(_x23) {
2626
2697
  return _setOtherParams.apply(this, arguments);
2627
2698
  }
2628
2699
  return setOtherParams;
@@ -2693,7 +2764,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2693
2764
  }
2694
2765
  }, _callee32, this);
2695
2766
  }));
2696
- function handlePrintWristband(_x23) {
2767
+ function handlePrintWristband(_x24) {
2697
2768
  return _handlePrintWristband.apply(this, arguments);
2698
2769
  }
2699
2770
  return handlePrintWristband;
@@ -2768,7 +2839,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2768
2839
  }
2769
2840
  }, _callee33, this);
2770
2841
  }));
2771
- function handleRedeem(_x24) {
2842
+ function handleRedeem(_x25) {
2772
2843
  return _handleRedeem.apply(this, arguments);
2773
2844
  }
2774
2845
  return handleRedeem;
@@ -47,6 +47,7 @@ export interface PisellCore {
47
47
  getModule: <T extends Module>(name: string) => T | null;
48
48
  getModuleExports: <T = any>(name: string) => T | null;
49
49
  hasModule: (name: string) => boolean;
50
+ getModuleNames: () => string[];
50
51
  effects: {
51
52
  on: (event: string, callback: (payload: any) => void) => () => void;
52
53
  once: (event: string, callback: (payload: any) => void) => () => void;
@@ -28,6 +28,8 @@ declare class PisellOSCore implements PisellCore {
28
28
  getModule<T extends Module>(name: string): T | null;
29
29
  getModuleExports<T = any>(name: string): T | null;
30
30
  hasModule(name: string): boolean;
31
+ /** 返回当前已注册模块名,供宿主在切换店铺等生命周期中定向清理运行态。 */
32
+ getModuleNames(): string[];
31
33
  destroy(): Promise<void>;
32
34
  setContext(ctx: Partial<BusinessContext>): void;
33
35
  /**
package/lib/core/index.js CHANGED
@@ -210,6 +210,10 @@ var PisellOSCore = class {
210
210
  hasModule(name) {
211
211
  return this.modules.has(name);
212
212
  }
213
+ /** 返回当前已注册模块名,供宿主在切换店铺等生命周期中定向清理运行态。 */
214
+ getModuleNames() {
215
+ return Array.from(this.modules.keys());
216
+ }
213
217
  // 销毁方法
214
218
  async destroy() {
215
219
  for (const [name, module2] of this.modules.entries()) {
@@ -27,6 +27,8 @@ export declare class OpenDataModule extends BaseModule implements Module {
27
27
  fetchOpenData(params: OpenDataFetchParams): Promise<OpenDataConfig>;
28
28
  getOpenData(): OpenDataConfig | null;
29
29
  getLastFetchedAt(): number | null;
30
+ /** 清除内存与 sessionStorage 镜像中的 OpenData,供宿主切店时调用。 */
31
+ clearCache(): void;
30
32
  checkAvailability(scheduleModule?: ScheduleModule): OpenDataAvailabilityResult;
31
33
  storeChange(): void;
32
34
  }
@@ -104,6 +104,11 @@ var OpenDataModule = class extends import_BaseModule.BaseModule {
104
104
  getLastFetchedAt() {
105
105
  return this.store.lastFetchedAt ?? null;
106
106
  }
107
+ /** 清除内存与 sessionStorage 镜像中的 OpenData,供宿主切店时调用。 */
108
+ clearCache() {
109
+ this.store.data = null;
110
+ this.store.lastFetchedAt = null;
111
+ }
107
112
  checkAvailability(scheduleModule) {
108
113
  var _a;
109
114
  const scheduleList = scheduleModule ? scheduleModule == null ? void 0 : scheduleModule.getScheduleListByIds(
@@ -485,7 +485,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
485
485
  generateIdempotencyToken(): string;
486
486
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
487
487
  createOrder(params: CommitOrderParams['query']): {
488
- type: "virtual" | "appointment_booking";
488
+ type: "appointment_booking" | "virtual";
489
489
  platform: string;
490
490
  sales_channel: string;
491
491
  order_sales_channel: string;
@@ -856,9 +856,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
856
856
  }
857
857
  return false;
858
858
  });
859
- const selectedDiscountCard = applicableDiscounts.find(
859
+ const explicitlySelectedDiscountCard = (options == null ? void 0 : options.isSelected) === true && options.discountId !== void 0 ? applicableDiscounts.find((discount) => {
860
+ const discountType = discount.tag || discount.type;
861
+ return String(discount.id) === String(options.discountId) && ["discount_card", "product_discount_card"].includes(discountType);
862
+ }) : void 0;
863
+ const scannedSelectedDiscountCard = applicableDiscounts.find(
860
864
  (n) => n.isScan && n.isSelected && (n.tag || n.type) !== "good_pass"
861
865
  );
866
+ const selectedDiscountCard = explicitlySelectedDiscountCard || scannedSelectedDiscountCard;
862
867
  const selectedDiscount = selectedDiscountCard || applicableDiscounts[0];
863
868
  let isManualDiscount = false;
864
869
  let isItemRewardProductDiscount = false;
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
314
+ weekNum: 0 | 1 | 2 | 6 | 4 | 3 | 5;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -46,6 +46,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
46
46
  private getIdGeneratorPlugin;
47
47
  private loadOpenDataConfig;
48
48
  getOpenData(): Promise<OpenDataConfig | null>;
49
+ /** 清除店铺级 OpenData;下一次 getOpenData 时会重新拉取。 */
50
+ clearOpenDataCache(): void;
49
51
  private getShortNumberOrDeviceId;
50
52
  private configureIdGeneratorFromOpenData;
51
53
  private normalizePositiveInteger;
@@ -189,10 +191,12 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
189
191
  */
190
192
  getCustomer(): ICustomer | null;
191
193
  /**
192
- * 通过 ids 获取商品列表(不加载到模块中)
193
- * @returns 商品列表
194
+ * 通过 ids 获取商品列表;默认只读取内存,显式开启 loadMissing 时按当前订单上下文补查缺失商品。
195
+ * 补查直接写入 ProductList,不更新 BookingTicket.productCatalog,避免当前商品列表被查询子集覆盖。
194
196
  */
195
- getProductByIds(ids: number[]): Promise<ProductData[] | undefined>;
197
+ getProductByIds(ids: number[], options?: {
198
+ loadMissing?: boolean;
199
+ }): Promise<ProductData[]>;
196
200
  /**
197
201
  * 获取日程时间段点
198
202
  * @param params 参数
@@ -322,7 +326,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
322
326
  * 获取当前的客户搜索条件
323
327
  * @returns 当前搜索条件
324
328
  */
325
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
329
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
326
330
  /**
327
331
  * 获取客户列表状态(包含滚动加载相关状态)
328
332
  * @returns 客户状态
@@ -219,8 +219,14 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
219
219
  }
220
220
  }
221
221
  async getOpenData() {
222
+ return this.loadOpenDataConfig();
223
+ }
224
+ /** 清除店铺级 OpenData;下一次 getOpenData 时会重新拉取。 */
225
+ clearOpenDataCache() {
222
226
  var _a;
223
- return (_a = this.store.openData) == null ? void 0 : _a.getOpenData();
227
+ this.loadOpenDataConfigInFlight = null;
228
+ this.otherParams.openData = null;
229
+ (_a = this.store.openData) == null ? void 0 : _a.clearCache();
224
230
  }
225
231
  async getShortNumberOrDeviceId() {
226
232
  const getAsyncIotDeviceInfo = this.getAppData("async_iot_device_info");
@@ -716,11 +722,53 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
716
722
  return this.getOrderCustomerSnapshot();
717
723
  }
718
724
  /**
719
- * 通过 ids 获取商品列表(不加载到模块中)
720
- * @returns 商品列表
725
+ * 通过 ids 获取商品列表;默认只读取内存,显式开启 loadMissing 时按当前订单上下文补查缺失商品。
726
+ * 补查直接写入 ProductList,不更新 BookingTicket.productCatalog,避免当前商品列表被查询子集覆盖。
721
727
  */
722
- async getProductByIds(ids) {
723
- return this.store.products.getProductByIds(ids);
728
+ async getProductByIds(ids, options) {
729
+ var _a, _b;
730
+ const normalizedIds = Array.from(
731
+ new Set(
732
+ (ids || []).map((id) => Number(id)).filter((id) => Number.isFinite(id))
733
+ )
734
+ );
735
+ const localProducts = await this.store.products.getProductByIds(normalizedIds) || [];
736
+ if (!(options == null ? void 0 : options.loadMissing)) {
737
+ return localProducts;
738
+ }
739
+ const localProductIds = new Set(
740
+ localProducts.map((product) => Number(product.id))
741
+ );
742
+ const missingIds = normalizedIds.filter(
743
+ (id) => !localProductIds.has(id)
744
+ );
745
+ if (!missingIds.length) {
746
+ return localProducts;
747
+ }
748
+ const rawBookingDate = this.getBookingDate();
749
+ const bookingDate = rawBookingDate && (0, import_dayjs.default)(rawBookingDate).isValid() ? (0, import_dayjs.default)(rawBookingDate) : null;
750
+ const customerId = Number(
751
+ ((_a = this.getOrderCustomerSnapshot()) == null ? void 0 : _a.id) ?? ((_b = this.getOrderCustomer()) == null ? void 0 : _b.customer_id)
752
+ );
753
+ const loadedProducts = await this.store.products.loadProducts({
754
+ product_ids: missingIds,
755
+ with_count: ["bundleGroup", "optionGroup"],
756
+ with_schedule: 1,
757
+ cacheId: this.cacheId,
758
+ ...bookingDate ? {
759
+ schedule_date: bookingDate.format("YYYY-MM-DD"),
760
+ schedule_datetime: bookingDate.format("YYYY-MM-DD HH:mm:ss")
761
+ } : {},
762
+ ...Number.isFinite(customerId) && customerId > 0 ? { customer_id: customerId } : {}
763
+ });
764
+ const productById = /* @__PURE__ */ new Map();
765
+ [...localProducts, ...loadedProducts || []].forEach((product) => {
766
+ const productId = Number(product.id);
767
+ if (Number.isFinite(productId)) {
768
+ productById.set(productId, product);
769
+ }
770
+ });
771
+ return normalizedIds.map((id) => productById.get(id)).filter((product) => Boolean(product));
724
772
  }
725
773
  /**
726
774
  * 获取日程时间段点
@@ -47,6 +47,7 @@ export interface PisellCore {
47
47
  getModule: <T extends Module>(name: string) => T | null;
48
48
  getModuleExports: <T = any>(name: string) => T | null;
49
49
  hasModule: (name: string) => boolean;
50
+ getModuleNames: () => string[];
50
51
  effects: {
51
52
  on: (event: string, callback: (payload: any) => void) => () => void;
52
53
  once: (event: string, callback: (payload: any) => void) => () => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.266",
4
+ "version": "2.2.271",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
19
19
  "changeset": "changeset",
20
20
  "version": "changeset version",
21
- "release": "changeset publish --registry=https://registry.npmjs.com/ && npm run sync && git push",
21
+ "release": "changeset publish && npm run sync && git push",
22
22
  "example": "npx parcel-bundler examples/index.html",
23
23
  "docs": "typedoc --out docs src/index.ts",
24
24
  "sync": "node sync.js",