@pisell/pisellos 0.10.4 → 0.10.5

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.
@@ -1395,7 +1395,6 @@ export function productRequiresFormSubject(tempOrder, product) {
1395
1395
  }
1396
1396
  export function resolveIsFormSubject(tempOrder, product) {
1397
1397
  var _tempOrder$holder;
1398
- debugger;
1399
1398
  // 旧版预约维度的 holder 类型仍然生效;新版则从当前商品 holder_config 判断。
1400
1399
  if ((tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.type) === 'form') return true;
1401
1400
  if (product) return productRequiresFormSubject(tempOrder, product);
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 5 | 2 | 1 | 6 | 4 | 3;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -29,6 +29,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
29
29
  private addTimeProductsCatalog;
30
30
  private orderCustomerDiscountRefreshInFlight;
31
31
  private orderCustomerDiscountRefreshCustomerId;
32
+ private orderCustomerPromotionRefreshInFlight;
32
33
  private loadOpenDataConfigInFlight;
33
34
  /**
34
35
  * 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext。
@@ -282,7 +283,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
282
283
  restoreOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
283
284
  /** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */
284
285
  private buildOrderCustomerPayload;
285
- private refreshDiscountConfigAfterOrderCustomerChange;
286
+ protected refreshDiscountConfigAfterOrderCustomerChange(customerId: number | null): Promise<void>;
287
+ protected waitForOrderCustomerPromotionRefresh(): Promise<void>;
286
288
  /**
287
289
  * 获取客户分页信息
288
290
  * @returns 分页信息
@@ -445,7 +447,19 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
445
447
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
446
448
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
447
449
  */
448
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
450
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
451
+ action: "reloadCatalog";
452
+ } | {
453
+ action: "add";
454
+ cacheItem: any;
455
+ } | {
456
+ action: "requiresDetail";
457
+ payload: AddProductRequiresDetailPayload;
458
+ } | {
459
+ action: "requiresBookingEdit";
460
+ cacheItem: any;
461
+ payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
462
+ };
449
463
  /** 规格弹窗 callback 后的第二段决策。 */
450
464
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
451
465
  /**
@@ -52,6 +52,7 @@ import { resolveBestAddTimePlan as _resolveBestAddTimePlan } from "./utils/resol
52
52
  import { createUuidV4 } from "../../modules/Order/utils";
53
53
  var OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow'];
54
54
  var OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
55
+ var USER_PLATFORM = ['pc', 'h5'];
55
56
 
56
57
  /**
57
58
  * 读取已有 booking 的协议唯一值,用于加时商品行绑定原预约。
@@ -178,6 +179,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
178
179
  _defineProperty(_assertThisInitialized(_this), "addTimeProductsCatalog", []);
179
180
  _defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshInFlight", null);
180
181
  _defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshCustomerId", null);
182
+ _defineProperty(_assertThisInitialized(_this), "orderCustomerPromotionRefreshInFlight", null);
181
183
  _defineProperty(_assertThisInitialized(_this), "loadOpenDataConfigInFlight", null);
182
184
  return _this;
183
185
  }
@@ -559,7 +561,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
559
561
  key: "scanPromotionCode",
560
562
  value: function () {
561
563
  var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(code, customerId) {
562
- var raw, scannedList, extractedCustomerId, hasOrderCustomer, tempOrder;
564
+ var raw, scannedList, extractedCustomerId, hasOrderCustomer, isUserPlatform, tempOrder;
563
565
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
564
566
  while (1) switch (_context7.prev = _context7.next) {
565
567
  case 0:
@@ -575,33 +577,34 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
575
577
  raw = _context7.sent;
576
578
  scannedList = raw.scannedDiscountList || [];
577
579
  extractedCustomerId = this.getDiscountCustomerId(scannedList);
578
- hasOrderCustomer = Boolean(this.store.order.getOrderCustomer()); // 缺 Holder 等场景 isAvailable=false,但仍需把 Pass 归属客户带入订单,供 Holder 弹窗使用。
579
- if (!(!hasOrderCustomer && extractedCustomerId)) {
580
- _context7.next = 11;
580
+ hasOrderCustomer = Boolean(this.store.order.getOrderCustomer());
581
+ isUserPlatform = USER_PLATFORM.includes(this.otherParams.platform); // Holder 等场景 isAvailable=false,但仍需把 Pass 归属客户带入订单,供 Holder 弹窗使用。
582
+ if (!(!hasOrderCustomer && extractedCustomerId && !isUserPlatform)) {
583
+ _context7.next = 12;
581
584
  break;
582
585
  }
583
- _context7.next = 11;
586
+ _context7.next = 12;
584
587
  return this.hydrateOrderCustomerFromScanDiscounts(scannedList);
585
- case 11:
588
+ case 12:
586
589
  if (!raw.isAvailable) {
587
- _context7.next = 18;
590
+ _context7.next = 19;
588
591
  break;
589
592
  }
590
- _context7.next = 14;
593
+ _context7.next = 15;
591
594
  return this.store.order.recalculateSummary({
592
595
  createIfMissing: true
593
596
  });
594
- case 14:
597
+ case 15:
595
598
  this.store.order.persistTempOrder();
596
599
  tempOrder = this.store.order.ensureTempOrder();
597
- _context7.next = 18;
600
+ _context7.next = 19;
598
601
  return this.effectsEmit('onDiscountApplied', {
599
602
  productList: tempOrder.products || [],
600
603
  discountList: this.store.order.getDiscountList(),
601
604
  selectedDiscountList: tempOrder.discount_list || [],
602
605
  tempOrder: tempOrder
603
606
  });
604
- case 18:
607
+ case 19:
605
608
  return _context7.abrupt("return", _objectSpread(_objectSpread({
606
609
  isAvailable: raw.isAvailable
607
610
  }, raw.isAccepted !== undefined ? {
@@ -611,7 +614,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
611
614
  unavailableReason: raw.unavailableReason,
612
615
  scannedDiscountList: raw.scannedDiscountList
613
616
  }));
614
- case 19:
617
+ case 20:
615
618
  case "end":
616
619
  return _context7.stop();
617
620
  }
@@ -1532,7 +1535,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1532
1535
  }, {
1533
1536
  key: "setOrderCustomer",
1534
1537
  value: function setOrderCustomer(customer) {
1535
- var _this$store$order$get3;
1538
+ var _this$store$order$get3,
1539
+ _this3 = this;
1536
1540
  if (!customer) {
1537
1541
  this.clearOrderCustomer();
1538
1542
  return;
@@ -1561,8 +1565,17 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1561
1565
  this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), next);
1562
1566
  this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
1563
1567
  // 客户切换可能改变可用促销/赠品;触发一次重算(recursion-safe)。
1564
- void this.store.order.applyPromotion().catch(function (error) {
1568
+ var promotionRefreshTask = this.store.order.applyPromotion().then(function () {
1569
+ return undefined;
1570
+ });
1571
+ this.orderCustomerPromotionRefreshInFlight = promotionRefreshTask;
1572
+ void promotionRefreshTask.then(function () {
1573
+ if (_this3.orderCustomerPromotionRefreshInFlight !== promotionRefreshTask) return;
1574
+ _this3.orderCustomerPromotionRefreshInFlight = null;
1575
+ }, function (error) {
1565
1576
  console.error('[BookingTicket] applyPromotion after customer change failed', error);
1577
+ if (_this3.orderCustomerPromotionRefreshInFlight !== promotionRefreshTask) return;
1578
+ _this3.orderCustomerPromotionRefreshInFlight = null;
1566
1579
  });
1567
1580
  }
1568
1581
 
@@ -1592,7 +1605,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1592
1605
  value: function clearOrderCustomer() {
1593
1606
  var _discountModule$setOr,
1594
1607
  _discountModule$setDi,
1595
- _this3 = this;
1608
+ _this4 = this;
1596
1609
  this.store.order.clearOrderCustomer();
1597
1610
  this.discountConfigCacheKey = null;
1598
1611
  this.hasManualDiscountSelection = false;
@@ -1605,9 +1618,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1605
1618
  createIfMissing: true
1606
1619
  }).then(function () {
1607
1620
  var _discountModule$getDi;
1608
- var tempOrder = _this3.store.order.ensureTempOrder();
1609
- _this3.store.order.persistTempOrder();
1610
- return _this3.effectsEmit('onDiscountApplied', {
1621
+ var tempOrder = _this4.store.order.ensureTempOrder();
1622
+ _this4.store.order.persistTempOrder();
1623
+ return _this4.effectsEmit('onDiscountApplied', {
1611
1624
  productList: tempOrder.products || [],
1612
1625
  discountList: (discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [],
1613
1626
  selectedDiscountList: tempOrder.discount_list || [],
@@ -1668,14 +1681,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1668
1681
  }, {
1669
1682
  key: "refreshDiscountConfigAfterOrderCustomerChange",
1670
1683
  value: function refreshDiscountConfigAfterOrderCustomerChange(customerId) {
1671
- var _this4 = this;
1672
- if (!customerId || customerId === 1) return;
1684
+ var _this5 = this;
1685
+ if (!customerId || customerId === 1) return Promise.resolve();
1673
1686
  if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
1674
- return;
1687
+ return this.orderCustomerDiscountRefreshInFlight;
1675
1688
  }
1676
1689
  var previousRefresh = this.orderCustomerDiscountRefreshInFlight;
1677
1690
  var refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1678
- var currentCustomer;
1691
+ var _this5$store$order$ge, _this5$store$order, _this5$getOrderIdenti;
1692
+ var currentCustomer, tempOrder, orderId, action;
1679
1693
  return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1680
1694
  while (1) switch (_context22.prev = _context22.next) {
1681
1695
  case 0:
@@ -1688,18 +1702,22 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1688
1702
  return undefined;
1689
1703
  });
1690
1704
  case 3:
1691
- currentCustomer = _this4.store.order.getOrderCustomer();
1705
+ currentCustomer = _this5.store.order.getOrderCustomer();
1692
1706
  if (!(!currentCustomer || Number(currentCustomer.customer_id) !== customerId)) {
1693
1707
  _context22.next = 6;
1694
1708
  break;
1695
1709
  }
1696
1710
  return _context22.abrupt("return");
1697
1711
  case 6:
1698
- _context22.next = 8;
1699
- return _this4.loadDiscountConfig({
1700
- customerId: customerId
1712
+ tempOrder = (_this5$store$order$ge = (_this5$store$order = _this5.store.order).getTempOrder) === null || _this5$store$order$ge === void 0 ? void 0 : _this5$store$order$ge.call(_this5$store$order);
1713
+ orderId = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) || ((_this5$getOrderIdenti = _this5.getOrderIdentity) === null || _this5$getOrderIdenti === void 0 || (_this5$getOrderIdenti = _this5$getOrderIdenti.call(_this5)) === null || _this5$getOrderIdenti === void 0 ? void 0 : _this5$getOrderIdenti.orderId);
1714
+ action = !orderId || String(orderId).startsWith('local_order') ? 'create' : 'edit';
1715
+ _context22.next = 11;
1716
+ return _this5.loadDiscountConfig({
1717
+ customerId: customerId,
1718
+ action: action
1701
1719
  });
1702
- case 8:
1720
+ case 11:
1703
1721
  case "end":
1704
1722
  return _context22.stop();
1705
1723
  }
@@ -1710,10 +1728,16 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1710
1728
  refreshTask.catch(function (error) {
1711
1729
  console.error('Failed to load discount config after customer change:', error);
1712
1730
  }).finally(function () {
1713
- if (_this4.orderCustomerDiscountRefreshInFlight !== refreshTask) return;
1714
- _this4.orderCustomerDiscountRefreshInFlight = null;
1715
- _this4.orderCustomerDiscountRefreshCustomerId = null;
1731
+ if (_this5.orderCustomerDiscountRefreshInFlight !== refreshTask) return;
1732
+ _this5.orderCustomerDiscountRefreshInFlight = null;
1733
+ _this5.orderCustomerDiscountRefreshCustomerId = null;
1716
1734
  });
1735
+ return refreshTask;
1736
+ }
1737
+ }, {
1738
+ key: "waitForOrderCustomerPromotionRefresh",
1739
+ value: function waitForOrderCustomerPromotionRefresh() {
1740
+ return this.orderCustomerPromotionRefreshInFlight || Promise.resolve();
1717
1741
  }
1718
1742
 
1719
1743
  /**
@@ -1897,9 +1921,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1897
1921
  }, {
1898
1922
  key: "scanGlobalListener",
1899
1923
  value: function scanGlobalListener(callback) {
1900
- var _this5 = this;
1924
+ var _this6 = this;
1901
1925
  var localSearch = function localSearch(v) {
1902
- return _this5.store.products.findProductsByCodeOrBarcode(v);
1926
+ return _this6.store.products.findProductsByCodeOrBarcode(v);
1903
1927
  };
1904
1928
  var scanCallback = handleGlobalScan(this.request, localSearch, this.getSubmitOrderSalesChannel());
1905
1929
  var safeCallback = function safeCallback(d) {
@@ -2375,7 +2399,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2375
2399
  key: "handleGlobalScanCode",
2376
2400
  value: (function () {
2377
2401
  var _handleGlobalScanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(code, bridge) {
2378
- var _this6 = this;
2402
+ var _this7 = this;
2379
2403
  var trimmed, _bridge$onNotify, _bridge$refresh, localSearch, scanCallback, raw, formatted, _bridge$onNotify2, _result7, _bridge$onNotify3;
2380
2404
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2381
2405
  while (1) switch (_context28.prev = _context28.next) {
@@ -2393,7 +2417,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2393
2417
  case 4:
2394
2418
  _context28.prev = 4;
2395
2419
  localSearch = function localSearch(v) {
2396
- return _this6.store.products.findProductsByCodeOrBarcode(v);
2420
+ return _this7.store.products.findProductsByCodeOrBarcode(v);
2397
2421
  };
2398
2422
  scanCallback = handleGlobalScan(this.request, localSearch, this.getSubmitOrderSalesChannel());
2399
2423
  _context28.next = 9;
@@ -2417,35 +2441,35 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2417
2441
  _context28.next = 16;
2418
2442
  return applyGlobalScan({
2419
2443
  setOrderCustomer: function setOrderCustomer(customer) {
2420
- return _this6.setOrderCustomer(customer);
2444
+ return _this7.setOrderCustomer(customer);
2421
2445
  },
2422
2446
  getOrderCustomerSnapshot: function getOrderCustomerSnapshot() {
2423
- return _this6.getOrderCustomerSnapshot();
2447
+ return _this7.getOrderCustomerSnapshot();
2424
2448
  },
2425
2449
  getBusinessCode: function getBusinessCode() {
2426
- var _this6$otherParams;
2427
- return (_this6$otherParams = _this6.otherParams) === null || _this6$otherParams === void 0 ? void 0 : _this6$otherParams.businessCode;
2450
+ var _this7$otherParams;
2451
+ return (_this7$otherParams = _this7.otherParams) === null || _this7$otherParams === void 0 ? void 0 : _this7$otherParams.businessCode;
2428
2452
  },
2429
2453
  buildAddProductCtx: function buildAddProductCtx(extra) {
2430
- return _this6.buildAddProductCtx(extra);
2454
+ return _this7.buildAddProductCtx(extra);
2431
2455
  },
2432
2456
  decideAddProduct: function decideAddProduct(item, options) {
2433
- return _this6.decideAddProduct(item, options);
2457
+ return _this7.decideAddProduct(item, options);
2434
2458
  },
2435
2459
  decideAfterDetail: function decideAfterDetail(cacheItem, options) {
2436
- return _this6.decideAfterDetail(cacheItem, options);
2460
+ return _this7.decideAfterDetail(cacheItem, options);
2437
2461
  },
2438
2462
  transformDetailToProductAndBooking: function transformDetailToProductAndBooking(input) {
2439
- return _this6.transformDetailToProductAndBooking(input);
2463
+ return _this7.transformDetailToProductAndBooking(input);
2440
2464
  },
2441
2465
  addProductToOrder: function addProductToOrder(product, booking) {
2442
- return _this6.addProductToOrder(product, booking);
2466
+ return _this7.addProductToOrder(product, booking);
2443
2467
  },
2444
2468
  refreshWalletAssets: function refreshWalletAssets(params) {
2445
- return _this6.refreshWalletAssets(params);
2469
+ return _this7.refreshWalletAssets(params);
2446
2470
  },
2447
2471
  scanWalletAsset: function scanWalletAsset(scanCode) {
2448
- return _this6.scanWalletAsset(scanCode);
2472
+ return _this7.scanWalletAsset(scanCode);
2449
2473
  }
2450
2474
  }, formatted, bridge);
2451
2475
  case 16:
@@ -2584,7 +2608,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2584
2608
  key: "addAddTimeProductsToBooking",
2585
2609
  value: (function () {
2586
2610
  var _addAddTimeProductsToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(input) {
2587
- var _this7 = this,
2611
+ var _this8 = this,
2588
2612
  _input$bookingPatch;
2589
2613
  var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator2, _step2, line;
2590
2614
  return _regeneratorRuntime().wrap(function _callee30$(_context30) {
@@ -2599,7 +2623,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2599
2623
  case 3:
2600
2624
  orderLines = (input.products || []).map(function (line) {
2601
2625
  return {
2602
- product: _this7.buildAddTimeOrderLine(line, bookingUid)
2626
+ product: _this8.buildAddTimeOrderLine(line, bookingUid)
2603
2627
  };
2604
2628
  });
2605
2629
  if (this.store.order) {
@@ -75,6 +75,12 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
75
75
  protected getRegisteredModuleNames(): readonly string[];
76
76
  protected createSubModule(moduleName: string): Module | null;
77
77
  addNewOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
78
+ syncAuthenticatedOrderCustomer(): Promise<boolean>;
79
+ private isAuthenticatedCustomerUserPlatform;
80
+ private resolveDiscountOrderIdentity;
81
+ private resolveDiscountAction;
82
+ private resetCachedCustomerDiscountState;
83
+ private refreshLegacySessionCustomerDiscounts;
78
84
  /**
79
85
  * Loads OpenData without borrowing BookingTicket. Cache ownership is tied to the exact
80
86
  * business/channel target so a reused solution instance cannot leak another entry's menus.