@pisell/pisellos 2.3.206 → 2.3.208

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.
@@ -2548,8 +2548,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2548
2548
  key: "ensureLocalOrderNumbersForCheckout",
2549
2549
  value: (function () {
2550
2550
  var _ensureLocalOrderNumbersForCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
2551
- var _this$otherParams19, _this$appPlugin, _this$appPlugin$getAp, _this$appPlugin$getAp2;
2552
- var order, tempOrder, biz, idGenerator;
2551
+ var _this$otherParams19, _this$appPlugin, _this$appPlugin$getAp, _this$appPlugin$getAp2, _idGenerator$getConfi;
2552
+ var order, tempOrder, biz, idGenerator, useLongNumber;
2553
2553
  return _regeneratorRuntime().wrap(function _callee9$(_context10) {
2554
2554
  while (1) switch (_context10.prev = _context10.next) {
2555
2555
  case 0:
@@ -2581,56 +2581,67 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2581
2581
  throw new Error('当前订单缺少业务类型,无法生成订单编号');
2582
2582
  case 11:
2583
2583
  idGenerator = (_this$appPlugin = this.appPlugin) === null || _this$appPlugin === void 0 || (_this$appPlugin$getAp = _this$appPlugin.getApp) === null || _this$appPlugin$getAp === void 0 || (_this$appPlugin$getAp = _this$appPlugin$getAp.call(_this$appPlugin)) === null || _this$appPlugin$getAp === void 0 || (_this$appPlugin$getAp2 = _this$appPlugin$getAp.getPlugin) === null || _this$appPlugin$getAp2 === void 0 ? void 0 : _this$appPlugin$getAp2.call(_this$appPlugin$getAp, 'idGenerator');
2584
- if (!(!tempOrder.shop_order_number && typeof (idGenerator === null || idGenerator === void 0 ? void 0 : idGenerator.generateShopOrderNumber) !== 'function' || !tempOrder.shop_full_order_number && typeof (idGenerator === null || idGenerator === void 0 ? void 0 : idGenerator.generateReceiptId) !== 'function')) {
2585
- _context10.next = 14;
2584
+ useLongNumber = (idGenerator === null || idGenerator === void 0 || (_idGenerator$getConfi = idGenerator.getConfig) === null || _idGenerator$getConfi === void 0 || (_idGenerator$getConfi = _idGenerator$getConfi.call(idGenerator, biz)) === null || _idGenerator$getConfi === void 0 ? void 0 : _idGenerator$getConfi.enableShortNumber) === false;
2585
+ if (!(!tempOrder.shop_order_number && typeof (idGenerator === null || idGenerator === void 0 ? void 0 : idGenerator.generateShopOrderNumber) !== 'function' || !tempOrder.shop_full_order_number && !useLongNumber && typeof (idGenerator === null || idGenerator === void 0 ? void 0 : idGenerator.generateReceiptId) !== 'function')) {
2586
+ _context10.next = 15;
2586
2587
  break;
2587
2588
  }
2588
2589
  throw new Error('订单编号生成器不可用,请重启应用后重试');
2589
- case 14:
2590
- _context10.prev = 14;
2590
+ case 15:
2591
+ _context10.prev = 15;
2591
2592
  if (tempOrder.shop_order_number) {
2592
- _context10.next = 19;
2593
+ _context10.next = 20;
2593
2594
  break;
2594
2595
  }
2595
- _context10.next = 18;
2596
+ _context10.next = 19;
2596
2597
  return idGenerator.generateShopOrderNumber({
2597
2598
  biz: biz
2598
2599
  });
2599
- case 18:
2600
- tempOrder.shop_order_number = _context10.sent;
2601
2600
  case 19:
2601
+ tempOrder.shop_order_number = _context10.sent;
2602
+ case 20:
2602
2603
  if (tempOrder.shop_full_order_number) {
2603
- _context10.next = 23;
2604
+ _context10.next = 29;
2604
2605
  break;
2605
2606
  }
2606
- _context10.next = 22;
2607
+ if (!useLongNumber) {
2608
+ _context10.next = 25;
2609
+ break;
2610
+ }
2611
+ _context10.t0 = tempOrder.shop_order_number;
2612
+ _context10.next = 28;
2613
+ break;
2614
+ case 25:
2615
+ _context10.next = 27;
2607
2616
  return idGenerator.generateReceiptId({
2608
2617
  biz: biz
2609
2618
  });
2610
- case 22:
2611
- tempOrder.shop_full_order_number = _context10.sent;
2612
- case 23:
2619
+ case 27:
2620
+ _context10.t0 = _context10.sent;
2621
+ case 28:
2622
+ tempOrder.shop_full_order_number = _context10.t0;
2623
+ case 29:
2613
2624
  if (!(order.getTempOrder() !== tempOrder)) {
2614
- _context10.next = 25;
2625
+ _context10.next = 31;
2615
2626
  break;
2616
2627
  }
2617
2628
  throw new Error('当前订单已切换,请重新发起支付');
2618
- case 25:
2629
+ case 31:
2619
2630
  if (!(!tempOrder.shop_order_number || !tempOrder.shop_full_order_number)) {
2620
- _context10.next = 27;
2631
+ _context10.next = 33;
2621
2632
  break;
2622
2633
  }
2623
2634
  throw new Error('订单编号生成失败,请重试');
2624
- case 27:
2625
- _context10.prev = 27;
2635
+ case 33:
2636
+ _context10.prev = 33;
2626
2637
  // 部分生成成功时也保留号码,后续只补仍然缺失的字段。
2627
2638
  if (order.getTempOrder() === tempOrder) order.persistTempOrder();
2628
- return _context10.finish(27);
2629
- case 30:
2639
+ return _context10.finish(33);
2640
+ case 36:
2630
2641
  case "end":
2631
2642
  return _context10.stop();
2632
2643
  }
2633
- }, _callee9, this, [[14,, 27, 30]]);
2644
+ }, _callee9, this, [[15,, 33, 36]]);
2634
2645
  }));
2635
2646
  function ensureLocalOrderNumbersForCheckout() {
2636
2647
  return _ensureLocalOrderNumbersForCheckout.apply(this, arguments);
@@ -640,7 +640,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
640
640
  generateIdempotencyToken(): string;
641
641
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
642
642
  createOrder(params: CommitOrderParams['query']): {
643
- type: "appointment_booking" | "virtual";
643
+ type: "virtual" | "appointment_booking";
644
644
  platform: string;
645
645
  sales_channel: string;
646
646
  order_sales_channel: string;
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "normal" | "session" | "duration";
53
53
  }
@@ -3833,10 +3833,15 @@ class Server {
3833
3833
  biz: next.business_code || 'ticket'
3834
3834
  });
3835
3835
  }
3836
- if (needsShopFullOrderNumber && idGenerator.generateReceiptId) {
3837
- next.shop_full_order_number = await idGenerator.generateReceiptId({
3838
- biz: next.business_code || 'ticket'
3839
- });
3836
+ if (needsShopFullOrderNumber) {
3837
+ const biz = next.business_code || 'ticket';
3838
+ if (idGenerator.getConfig?.(biz)?.enableShortNumber === false) {
3839
+ next.shop_full_order_number = next.shop_order_number;
3840
+ } else if (idGenerator.generateReceiptId) {
3841
+ next.shop_full_order_number = await idGenerator.generateReceiptId({
3842
+ biz
3843
+ });
3844
+ }
3840
3845
  }
3841
3846
  this.logInfo(`${title}: checkout 订单号已准备`, {
3842
3847
  shop_order_number: next.shop_order_number,
@@ -55,6 +55,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
55
55
  protected store: BaseSalesState;
56
56
  protected otherParams: Record<string, any>;
57
57
  getInventory(): InventoryController | undefined;
58
+ /** Retail and standard POS opt in per sales instance; other hosts retain their member flow. */
59
+ isMemberCartConsistencyEnabled(): boolean;
58
60
  prepareCheckout(signal?: AbortSignal): Promise<CheckoutRuntimeSnapshot | undefined>;
59
61
  protected cacheId: string | undefined;
60
62
  /**
@@ -23,6 +23,7 @@ Object.keys(_types).forEach(function (key) {
23
23
  });
24
24
  });
25
25
  var _Order = require("../../modules/Order");
26
+ var _discountProductLineIdentity = require("../../modules/Order/utils/discountProductLineIdentity");
26
27
  var _pickupTiming = require("../../modules/Order/pickupTiming");
27
28
  var _pickupTiming2 = require("./pickupTiming");
28
29
  var _fulfillmentItemRules = require("./fulfillmentItemRules");
@@ -156,6 +157,14 @@ function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
156
157
  return previous && isBaseSalesManualProductDiscountProduct(previous) ? previous : product;
157
158
  });
158
159
  }
160
+
161
+ /** Rules may split a coupon quantity into rows that still share the original UID. */
162
+ function applyDiscountProductLines(tempOrder, products, discounts, enableMemberCartConsistency) {
163
+ tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, products);
164
+ if (!enableMemberCartConsistency) return;
165
+ (0, _discountProductLineIdentity.ensureUniqueProductLineUids)(tempOrder, discounts);
166
+ (0, _discountProductLineIdentity.consolidateDiscountFreeProductLines)(tempOrder);
167
+ }
159
168
  function isBaseSalesHistoricalDiscountEntry(discount) {
160
169
  return Boolean(discount?.isEditMode || discount?.isDisabled || discount?.order_discount_id != null);
161
170
  }
@@ -517,6 +526,11 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
517
526
  getInventory() {
518
527
  return this.otherParams.inventory;
519
528
  }
529
+
530
+ /** Retail and standard POS opt in per sales instance; other hosts retain their member flow. */
531
+ isMemberCartConsistencyEnabled() {
532
+ return this.otherParams.enableMemberCartConsistency === true;
533
+ }
520
534
  async prepareCheckout(signal) {
521
535
  const inventory = this.getInventory();
522
536
  const hooks = this.otherParams.checkoutHooks;
@@ -2316,7 +2330,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2316
2330
  }
2317
2331
  async loadDiscountConfig(params) {
2318
2332
  if (!this.store.order) throw new Error('order 模块未初始化');
2319
- const tempOrder = this.store.order.ensureTempOrder();
2333
+ let tempOrder = this.store.order.ensureTempOrder();
2320
2334
  const orderStore = this.store.order.store || {};
2321
2335
  const discountModule = orderStore.discount;
2322
2336
  const rulesModule = orderStore.rules;
@@ -2331,7 +2345,11 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2331
2345
  let requestEpoch = this.store.order.getCustomerWalletPrepareConfigEpoch?.();
2332
2346
  const isCurrentRequest = () => {
2333
2347
  const currentTempOrder = this.store.order?.getTempOrder?.();
2334
- return Boolean(currentTempOrder && (requestEpoch === undefined || this.store.order?.getCustomerWalletPrepareConfigEpoch?.() === requestEpoch) && this.resolveDiscountConfigCustomerId(currentTempOrder) === customerId && this.getDiscountConfigOrderIdentityKey(currentTempOrder) === requestOrderIdentityKey);
2348
+ const current = Boolean(currentTempOrder && (requestEpoch === undefined || this.store.order?.getCustomerWalletPrepareConfigEpoch?.() === requestEpoch) && this.resolveDiscountConfigCustomerId(currentTempOrder) === customerId && this.getDiscountConfigOrderIdentityKey(currentTempOrder) === requestOrderIdentityKey);
2349
+ // Cart edits can replace the object while member configuration is pending.
2350
+ // Keep the logical-order guard, but apply coupons to its latest rows.
2351
+ if (current && this.isMemberCartConsistencyEnabled()) tempOrder = currentTempOrder;
2352
+ return current;
2335
2353
  };
2336
2354
  const getCurrentResult = () => {
2337
2355
  const currentTempOrder = this.store.order?.getTempOrder?.();
@@ -2460,7 +2478,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2460
2478
  discountList: nextDiscountList
2461
2479
  };
2462
2480
  if (result.productList) {
2463
- tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2481
+ applyDiscountProductLines(tempOrder, result.productList, result.discountList || nextDiscountList, this.isMemberCartConsistencyEnabled());
2464
2482
  }
2465
2483
  for (const product of tempOrder.products || []) {
2466
2484
  const productUid = product.metadata?.unique_identification_number;
@@ -2553,7 +2571,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2553
2571
  preserveEntitlementSelection: false
2554
2572
  }) || result;
2555
2573
  if (result.productList) {
2556
- tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2574
+ applyDiscountProductLines(tempOrder, result.productList, result.discountList || nextDiscountList, this.isMemberCartConsistencyEnabled());
2557
2575
  }
2558
2576
  if (result.discountList) {
2559
2577
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
@@ -2679,7 +2697,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2679
2697
  discountList: updated
2680
2698
  };
2681
2699
  if (result?.productList) {
2682
- tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2700
+ applyDiscountProductLines(tempOrder, result.productList, result.discountList || updated, this.isMemberCartConsistencyEnabled());
2683
2701
  }
2684
2702
  if (result?.discountList) {
2685
2703
  nextDiscountList = result.discountList;
@@ -2767,7 +2785,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
2767
2785
  const orderStore = this.store.order.store || {};
2768
2786
  const discountModule = orderStore.discount;
2769
2787
  if (result.productList) {
2770
- tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2788
+ applyDiscountProductLines(tempOrder, result.productList, result.discountList || this.getDiscountList(), this.isMemberCartConsistencyEnabled());
2771
2789
  }
2772
2790
  if (result.discountList) {
2773
2791
  _Order.OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
@@ -4407,6 +4425,9 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
4407
4425
  const currentOrderCustomerId = this.getCurrentOrderCustomerId();
4408
4426
  const resolvedChannels = paramsList.map(params => this.getPriceQueryChannel(params.channel));
4409
4427
  const authoritativeProducts = await this.resolveProductBookingPriceGroups(paramsList, currentOrderCustomerId);
4428
+ if (paramsList.some((params, index) => params.requireAuthoritativePrice && !authoritativeProducts[index])) {
4429
+ throw new Error('The current customer product price is unavailable. Please retry before paying.');
4430
+ }
4410
4431
  const plans = paramsList.map((params, index) => {
4411
4432
  if (!isPos) return null;
4412
4433
  const product = authoritativeProducts[index];
@@ -305,6 +305,8 @@ export interface BaseSalesQuotationDurationConfig {
305
305
  }
306
306
  export interface BaseSalesCalculateProductBookingPriceParams {
307
307
  product: Record<string, any>;
308
+ /** Fail closed when the current customer price cannot be resolved; no old-line fallback. */
309
+ requireAuthoritativePrice?: boolean;
308
310
  booking?: {
309
311
  start_date?: string;
310
312
  start_time?: string;
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
342
342
  date: string;
343
343
  status: string;
344
344
  week: string;
345
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
345
+ weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
346
346
  }[]>;
347
347
  submitTimeSlot(timeSlots: TimeSliceItem): void;
348
348
  private getScheduleDataByIds;
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
389
389
  };
390
390
  setOtherData(key: string, value: any): void;
391
391
  getOtherData(key: string): any;
392
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
392
+ getProductTypeById(id: number): Promise<"normal" | "session" | "duration">;
393
393
  /**
394
394
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
395
395
  *
@@ -32,6 +32,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
32
32
  private orderCustomerDiscountRefreshCustomerId;
33
33
  private orderCustomerDiscountRefreshTarget;
34
34
  private orderCustomerPromotionRefreshInFlight;
35
+ private orderCustomerRefreshTask;
36
+ private orderCustomerRefreshRevision;
35
37
  private orderCustomerContactRequest;
36
38
  private readonly customerResolveRequests;
37
39
  protected loadOpenDataInFlight: Promise<OpenDataConfig> | null;
@@ -283,6 +285,9 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
283
285
  setOrderCustomer(customer: ICustomer | null, options?: {
284
286
  source?: OrderCustomerChangePayload['source'];
285
287
  }): void;
288
+ /** Shared by customer changes and an explicit retry; keep the selected customer/cart intact. */
289
+ private refreshMemberCartContext;
290
+ retryOrderCustomerRefresh(): Promise<void>;
286
291
  private resetOrderCustomerContactInfo;
287
292
  /** Explicit edits, including clearing the contact, must win over a pending default. */
288
293
  updateTempOrderContactsInfo(contact: Record<string, any> | null): Record<string, any> | null;
@@ -321,6 +326,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
321
326
  private buildOrderCustomerPayload;
322
327
  protected refreshDiscountConfigAfterOrderCustomerChange(customerId: number | null): Promise<void>;
323
328
  protected waitForOrderCustomerPromotionRefresh(): Promise<void>;
329
+ /** Wait before reading cart rows: member coupons can split or consolidate them. */
330
+ waitForOrderCustomerRefresh(): Promise<void>;
324
331
  protected prepareProductPriceQueryContext(customerId?: number | string): Promise<void>;
325
332
  protected preferAuthoritativeProductQueryPrice(): boolean;
326
333
  /**
@@ -366,7 +373,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
366
373
  * 获取当前的客户搜索条件
367
374
  * @returns 当前搜索条件
368
375
  */
369
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
376
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
370
377
  /**
371
378
  * 获取客户列表状态(包含滚动加载相关状态)
372
379
  * @returns 客户状态
@@ -167,6 +167,9 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
167
167
  orderCustomerDiscountRefreshCustomerId = null;
168
168
  orderCustomerDiscountRefreshTarget = null;
169
169
  orderCustomerPromotionRefreshInFlight = null;
170
+ // Retain the settled result too: a failed refresh must remain observable by checkout callers.
171
+ orderCustomerRefreshTask = Promise.resolve();
172
+ orderCustomerRefreshRevision = 0;
170
173
  orderCustomerContactRequest = null;
171
174
  customerResolveRequests = new Map();
172
175
  loadOpenDataInFlight = null;
@@ -385,6 +388,7 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
385
388
  await idGenerator.configure({
386
389
  biz: businessCode,
387
390
  config: {
391
+ enableShortNumber: openDataConfig?.['sale.enable_short_number'] !== false,
388
392
  prefix,
389
393
  deviceCode: deviceId,
390
394
  padReceiptSequence: openDataConfig?.['sale.pad_with_leading_zeros'] === true,
@@ -1081,13 +1085,17 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1081
1085
  }
1082
1086
  return;
1083
1087
  }
1088
+ const enableMemberCartConsistency = this.isMemberCartConsistencyEnabled();
1084
1089
  const next = this.buildOrderCustomerPayload();
1085
1090
  this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next && options?.source ? {
1086
1091
  ...next,
1087
1092
  source: options.source
1088
1093
  } : next);
1089
- this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
1090
- // 客户切换可能改变可用促销/赠品;触发一次重算(recursion-safe)。
1094
+ if (enableMemberCartConsistency) {
1095
+ this.refreshMemberCartContext(patch.customer_id);
1096
+ return;
1097
+ }
1098
+ void this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
1091
1099
  const promotionRefreshTask = this.store.order.applyPromotion().then(() => undefined);
1092
1100
  this.orderCustomerPromotionRefreshInFlight = promotionRefreshTask;
1093
1101
  void promotionRefreshTask.then(() => {
@@ -1099,6 +1107,31 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1099
1107
  this.orderCustomerPromotionRefreshInFlight = null;
1100
1108
  });
1101
1109
  }
1110
+
1111
+ /** Shared by customer changes and an explicit retry; keep the selected customer/cart intact. */
1112
+ refreshMemberCartContext(customerId) {
1113
+ const revision = ++this.orderCustomerRefreshRevision;
1114
+ const orderKey = this.getCustomerContactOrderKey();
1115
+ const isCurrent = () => revision === this.orderCustomerRefreshRevision && this.getCustomerContactOrderKey() === orderKey && Number(this.store.order.getOrderCustomer()?.customer_id || 0) === Number(customerId || 0);
1116
+ const task = (async () => {
1117
+ if (customerId) await this.refreshDiscountConfigAfterOrderCustomerChange(customerId);else await this.loadDiscountConfig({
1118
+ force: true
1119
+ });
1120
+ if (isCurrent()) await this.store.order.applyPromotion();
1121
+ })();
1122
+ this.orderCustomerRefreshTask = task;
1123
+ this.orderCustomerPromotionRefreshInFlight = task;
1124
+ void task.catch(error => {
1125
+ if (isCurrent()) console.error('[BookingTicket] Member cart refresh failed', error);
1126
+ }).finally(() => {
1127
+ if (this.orderCustomerPromotionRefreshInFlight === task) this.orderCustomerPromotionRefreshInFlight = null;
1128
+ });
1129
+ }
1130
+ async retryOrderCustomerRefresh() {
1131
+ if (!this.isMemberCartConsistencyEnabled()) return;
1132
+ this.refreshMemberCartContext(this.store.order.getOrderCustomer()?.customer_id ?? null);
1133
+ await this.waitForOrderCustomerRefresh();
1134
+ }
1102
1135
  resetOrderCustomerContactInfo() {
1103
1136
  this.orderCustomerContactRequest = null;
1104
1137
  const order = this.getTempOrder();
@@ -1217,6 +1250,8 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1217
1250
  * 清空下单客户(协议字段 + snapshot)。
1218
1251
  */
1219
1252
  clearOrderCustomer(options) {
1253
+ const enableMemberCartConsistency = this.isMemberCartConsistencyEnabled();
1254
+ const refreshRevision = enableMemberCartConsistency ? ++this.orderCustomerRefreshRevision : undefined;
1220
1255
  this.orderCustomerContactRequest = null;
1221
1256
  if (!options?.preserveContactInfo) this.resetOrderCustomerContactInfo();
1222
1257
  if (!options?.preserveContactInfo) this.store.order.updateTempOrderContactsInfo(null);
@@ -1228,9 +1263,11 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1228
1263
  void discountModule?.setOriginalDiscountList?.([]);
1229
1264
  void discountModule?.setDiscountList?.([]);
1230
1265
  this.store.order.applyDiscount();
1231
- void this.store.order.recalculateSummary({
1266
+ const customerOrderKey = enableMemberCartConsistency ? this.getCustomerContactOrderKey() : undefined;
1267
+ const refreshTask = this.store.order.recalculateSummary({
1232
1268
  createIfMissing: true
1233
1269
  }).then(() => {
1270
+ if (enableMemberCartConsistency && (this.orderCustomerRefreshRevision !== refreshRevision || this.getCustomerContactOrderKey() !== customerOrderKey)) return;
1234
1271
  const tempOrder = this.store.order.ensureTempOrder();
1235
1272
  this.store.order.persistTempOrder();
1236
1273
  return this.effectsEmit('onDiscountApplied', {
@@ -1239,7 +1276,9 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1239
1276
  selectedDiscountList: tempOrder.discount_list || [],
1240
1277
  tempOrder
1241
1278
  });
1242
- }).catch(error => {
1279
+ });
1280
+ if (enableMemberCartConsistency) this.orderCustomerRefreshTask = refreshTask.then(() => undefined);
1281
+ void (enableMemberCartConsistency ? this.orderCustomerRefreshTask : refreshTask).catch(error => {
1243
1282
  console.error('Failed to recalculate summary after clearing customer:', error);
1244
1283
  });
1245
1284
  this.core.effects.emit(`${this.name}:onOrderCustomerChange`, null);
@@ -1323,6 +1362,14 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1323
1362
  waitForOrderCustomerPromotionRefresh() {
1324
1363
  return this.orderCustomerPromotionRefreshInFlight || Promise.resolve();
1325
1364
  }
1365
+
1366
+ /** Wait before reading cart rows: member coupons can split or consolidate them. */
1367
+ async waitForOrderCustomerRefresh() {
1368
+ if (!this.isMemberCartConsistencyEnabled()) return;
1369
+ // Customer-change listeners run synchronously before setOrderCustomer assigns its task.
1370
+ await Promise.resolve();
1371
+ await this.orderCustomerRefreshTask;
1372
+ }
1326
1373
  async prepareProductPriceQueryContext(customerId) {
1327
1374
  // onOrderCustomerChange 的订阅回调会立即开始重报价,而客户 Wallet/优惠资产
1328
1375
  // 在事件派发后才创建异步刷新任务。先让出一个微任务,确保能观察到该任务。
@@ -2077,7 +2124,7 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
2077
2124
  if (invoiceContextChanged) {
2078
2125
  await this.prepareInvoiceTemplateAtSolutionReady(Object.prototype.hasOwnProperty.call(params, 'openData') ? this.getInjectedOpenDataConfig() : undefined);
2079
2126
  }
2080
- if (params?.businessCode !== undefined || params?.business_code !== undefined) {
2127
+ if (params?.businessCode !== undefined || params?.business_code !== undefined || Object.prototype.hasOwnProperty.call(params ?? {}, 'openData')) {
2081
2128
  await this.configureIdGeneratorFromOpenData();
2082
2129
  }
2083
2130
  }
@@ -2001,7 +2001,8 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2001
2001
  const biz = this.getBookingTicketBusinessCode();
2002
2002
  if (!biz) throw new Error('当前订单缺少业务类型,无法生成订单编号');
2003
2003
  const idGenerator = this.appPlugin?.getApp?.()?.getPlugin?.('idGenerator');
2004
- if (!tempOrder.shop_order_number && typeof idGenerator?.generateShopOrderNumber !== 'function' || !tempOrder.shop_full_order_number && typeof idGenerator?.generateReceiptId !== 'function') {
2004
+ const useLongNumber = idGenerator?.getConfig?.(biz)?.enableShortNumber === false;
2005
+ if (!tempOrder.shop_order_number && typeof idGenerator?.generateShopOrderNumber !== 'function' || !tempOrder.shop_full_order_number && !useLongNumber && typeof idGenerator?.generateReceiptId !== 'function') {
2005
2006
  throw new Error('订单编号生成器不可用,请重启应用后重试');
2006
2007
  }
2007
2008
  try {
@@ -2011,7 +2012,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2011
2012
  });
2012
2013
  }
2013
2014
  if (!tempOrder.shop_full_order_number) {
2014
- tempOrder.shop_full_order_number = await idGenerator.generateReceiptId({
2015
+ tempOrder.shop_full_order_number = useLongNumber ? tempOrder.shop_order_number : await idGenerator.generateReceiptId({
2015
2016
  biz
2016
2017
  });
2017
2018
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.206",
4
+ "version": "2.3.208",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",