@pisell/pisellos 2.3.21 → 2.3.23

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.
@@ -341,15 +341,21 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
341
341
  if (!this.store.order)
342
342
  throw new Error("order 模块未初始化");
343
343
  const raw = await this.store.order.scanCode(code, customerId);
344
+ const scannedList = raw.scannedDiscountList || [];
345
+ const extractedCustomerId = this.getDiscountCustomerId(scannedList);
346
+ const hasOrderCustomer = Boolean(this.store.order.getOrderCustomer());
347
+ if (!hasOrderCustomer && extractedCustomerId) {
348
+ await this.hydrateOrderCustomerFromScanDiscounts(scannedList);
349
+ }
344
350
  if (raw.isAvailable) {
345
- await this.hydrateOrderCustomerFromScanDiscounts(raw.scannedDiscountList || []);
346
351
  await this.store.order.recalculateSummary({ createIfMissing: true });
347
352
  this.store.order.persistTempOrder();
348
353
  }
349
354
  return {
350
355
  isAvailable: raw.isAvailable,
351
356
  type: raw.type,
352
- unavailableReason: raw.unavailableReason
357
+ unavailableReason: raw.unavailableReason,
358
+ scannedDiscountList: raw.scannedDiscountList
353
359
  };
354
360
  }
355
361
  async hydrateOrderCustomerFromScanDiscounts(discounts) {
@@ -366,11 +372,13 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
366
372
  this.setOrderCustomer(customer);
367
373
  }
368
374
  getDiscountCustomerId(discounts) {
369
- const discount = discounts.find((item) => item.customer_id != null);
370
- const customerId = Number(discount == null ? void 0 : discount.customer_id);
371
- if (!Number.isFinite(customerId) || customerId <= 0)
372
- return null;
373
- return customerId;
375
+ for (const item of discounts) {
376
+ const topLevelId = Number(item.customer_id);
377
+ if (Number.isFinite(topLevelId) && topLevelId > 0) {
378
+ return topLevelId;
379
+ }
380
+ }
381
+ return null;
374
382
  }
375
383
  async resolveCustomerByDiscountCustomerId(customerId) {
376
384
  var _a;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.21",
4
+ "version": "2.3.23",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",