@pisell/pisellos 2.2.280 → 2.2.281

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.
@@ -1,9 +0,0 @@
1
- // 导出评估器
2
- export { PromotionEvaluator } from "./evaluator";
3
-
4
- // 导出适配器
5
- export { PromotionAdapter } from "./adapter";
6
- export { default } from "./adapter";
7
-
8
- // 导出策略配置示例常量
9
- export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
@@ -512,7 +512,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
512
512
  generateIdempotencyToken(): string;
513
513
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
514
514
  createOrder(params: CommitOrderParams['query']): {
515
- type: "appointment_booking" | "virtual";
515
+ type: "virtual" | "appointment_booking";
516
516
  platform: string;
517
517
  sales_channel: string;
518
518
  order_sales_channel: string;
@@ -157,11 +157,13 @@ export interface OrderCustomerPatch {
157
157
  * 下单客户变更事件 payload。
158
158
  * - `patch`:tempOrder 上的协议字段视图(会随订单提交)
159
159
  * - `snapshot`:UI 富字段快照(仅本地,不随订单提交)
160
+ * - `source`:缺省表示真实业务变更;`detailHydrate` 仅表示打开详情时快照已就绪
160
161
  * 清空时整个 payload 为 null。
161
162
  */
162
163
  export interface OrderCustomerChangePayload {
163
164
  patch: OrderCustomerView;
164
165
  snapshot: ICustomer | null;
166
+ source?: 'detailHydrate';
165
167
  }
166
168
  export interface OrderScanCodeResult {
167
169
  isAvailable: boolean;
@@ -60,6 +60,7 @@ export var OrderHooks = /*#__PURE__*/function (OrderHooks) {
60
60
  * 下单客户变更事件 payload。
61
61
  * - `patch`:tempOrder 上的协议字段视图(会随订单提交)
62
62
  * - `snapshot`:UI 富字段快照(仅本地,不随订单提交)
63
+ * - `source`:缺省表示真实业务变更;`detailHydrate` 仅表示打开详情时快照已就绪
63
64
  * 清空时整个 payload 为 null。
64
65
  */
65
66
 
@@ -2126,12 +2126,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2126
2126
  return !_this12.isPersistedOrderProduct(product);
2127
2127
  });
2128
2128
  if (hasDraftProduct) return false;
2129
- var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
2130
- return discount.isSelected || discount.isEditMode || discount.isManualSelect;
2129
+
2130
+ // 编辑详情 hydrate 时,商品行上的历史券卡会被还原为 isEditMode=true、
2131
+ // isSelected=true 的只读记录。它们表示“该折扣已在原订单结算”,不是用户在
2132
+ // 当前编辑会话中新做的选择,不能据此放行刚从 prepare/config 拉回来的折扣。
2133
+ // 否则后续 Rules.calcDiscount 会把没有 isManualSelect 标记的可用 runtime 卡
2134
+ // 当作自动候选,再次写入 tempOrder。这里只识别非 isEditMode 的 runtime 状态;
2135
+ // 新建单、编辑态新增商品以及用户本次明确选择/取消折扣的原有流程保持不变。
2136
+ var hasRuntimeDiscountSelection = params.currentDiscountList.some(function (discount) {
2137
+ return !discount.isEditMode && (discount.isSelected || discount.isManualSelect);
2131
2138
  });
2132
- if (hasSelectedDiscount) return false;
2139
+ if (hasRuntimeDiscountSelection) return false;
2140
+
2141
+ // nextDiscountList 已经合并了历史只读折扣与本次获取的 runtime 折扣,
2142
+ // 因此这里同样必须排除 isEditMode;只有 runtime 条目已有明确选择状态时,
2143
+ // 才允许继续进入折扣重算。
2133
2144
  return !params.nextDiscountList.some(function (discount) {
2134
- return discount.isSelected || discount.isEditMode || discount.isManualSelect;
2145
+ return !discount.isEditMode && (discount.isSelected || discount.isManualSelect);
2135
2146
  });
2136
2147
  }
2137
2148
  }, {
@@ -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 | 2 | 1 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 1 | 5 | 2 | 4 | 3 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -3,7 +3,7 @@ import { BookingTicketCartView, BookingTicketProductCatalogView, BookingTicketSt
3
3
  import type { ProductData } from '../../modules';
4
4
  import type { OpenDataConfig } from '../../modules/OpenData';
5
5
  import { type BookingContextConfig, type BookingContextDateInput, type BookingContextResource, type BookingContextResourceMap, type BookingContextState, type InitBookingContextParams, type LoadBookingConfigParams, type LoadBookingResourcesParams, type ResourceError, type BookingCalcContext } from '../../modules/BookingContext';
6
- import type { OrderCustomerView } from '../../modules/Order/types';
6
+ import type { OrderCustomerView, OrderCustomerChangePayload } from '../../modules/Order/types';
7
7
  import { BaseSalesImpl } from '../BaseSales';
8
8
  import type { BaseSalesScanCodeResult } from '../BaseSales/types';
9
9
  import type { ISalesDetail } from '../BaseSales/utils/parseSalesResponse';
@@ -260,7 +260,9 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
260
260
  * 同时透传 OrderModule 内部 emit 的 `order:onOrderCustomerChange` 之外,
261
261
  * 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
262
262
  */
263
- setOrderCustomer(customer: ICustomer | null): void;
263
+ setOrderCustomer(customer: ICustomer | null, options?: {
264
+ source?: OrderCustomerChangePayload['source'];
265
+ }): void;
264
266
  /**
265
267
  * 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
266
268
  */
@@ -451,19 +453,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
451
453
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
452
454
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
453
455
  */
454
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
455
- action: "reloadCatalog";
456
- } | {
457
- action: "add";
458
- cacheItem: any;
459
- } | {
460
- action: "requiresDetail";
461
- payload: AddProductRequiresDetailPayload;
462
- } | {
463
- action: "requiresBookingEdit";
464
- cacheItem: any;
465
- payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
466
- };
456
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
467
457
  /** 规格弹窗 callback 后的第二段决策。 */
468
458
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
469
459
  /**
@@ -542,7 +542,12 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
542
542
  country_calling_code: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.country_calling_code
543
543
  });
544
544
  customerModule.setSelectedCustomer(customer);
545
- this.setOrderCustomer(customer);
545
+ // 详情 hydrate 后仍需广播一次,让 CustomerContext 等 UI 订阅方拿到刚补齐的
546
+ // customerSnapshot;但它不是用户主动切换客户。通过 source 明确标记初始化事件,
547
+ // 商品报价/折扣订阅方即可跳过 prepare/config,其他旧订阅方仍可照常刷新 UI。
548
+ this.setOrderCustomer(customer, {
549
+ source: 'detailHydrate'
550
+ });
546
551
  // await this.store.order.saveDraft();
547
552
  }
548
553
  return _context6.abrupt("return", sales);
@@ -1558,7 +1563,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1558
1563
  */
1559
1564
  }, {
1560
1565
  key: "setOrderCustomer",
1561
- value: function setOrderCustomer(customer) {
1566
+ value: function setOrderCustomer(customer, options) {
1562
1567
  var _this$store$order$get3,
1563
1568
  _this3 = this;
1564
1569
  if (!customer) {
@@ -1581,12 +1586,16 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1581
1586
  var snapshotReplenished = !snapshotBeforeSet && Boolean(snapshotAfterOrderSet);
1582
1587
  if (snapshotReplenished) {
1583
1588
  var _next2 = this.buildOrderCustomerPayload();
1584
- this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), _next2);
1589
+ this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), _next2 && options !== null && options !== void 0 && options.source ? _objectSpread(_objectSpread({}, _next2), {}, {
1590
+ source: options.source
1591
+ }) : _next2);
1585
1592
  }
1586
1593
  return;
1587
1594
  }
1588
1595
  var next = this.buildOrderCustomerPayload();
1589
- this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), next);
1596
+ this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), next && options !== null && options !== void 0 && options.source ? _objectSpread(_objectSpread({}, next), {}, {
1597
+ source: options.source
1598
+ }) : next);
1590
1599
  this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
1591
1600
  // 客户切换可能改变可用促销/赠品;触发一次重算(recursion-safe)。
1592
1601
  var promotionRefreshTask = this.store.order.applyPromotion().then(function () {
@@ -0,0 +1,51 @@
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
+ ITEM_REWARD_STRATEGY: () => import_examples.ITEM_REWARD_STRATEGY,
34
+ PromotionAdapter: () => import_adapter.PromotionAdapter,
35
+ PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
36
+ X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
37
+ default: () => import_adapter2.default
38
+ });
39
+ module.exports = __toCommonJS(promotion_exports);
40
+ var import_evaluator = require("./evaluator");
41
+ var import_adapter = require("./adapter");
42
+ var import_adapter2 = __toESM(require("./adapter"));
43
+ var import_examples = require("./examples");
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ BUY_X_GET_Y_FREE_STRATEGY,
47
+ ITEM_REWARD_STRATEGY,
48
+ PromotionAdapter,
49
+ PromotionEvaluator,
50
+ X_ITEMS_FOR_Y_PRICE_STRATEGY
51
+ });
@@ -512,7 +512,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
512
512
  generateIdempotencyToken(): string;
513
513
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
514
514
  createOrder(params: CommitOrderParams['query']): {
515
- type: "appointment_booking" | "virtual";
515
+ type: "virtual" | "appointment_booking";
516
516
  platform: string;
517
517
  sales_channel: string;
518
518
  order_sales_channel: string;
@@ -157,11 +157,13 @@ export interface OrderCustomerPatch {
157
157
  * 下单客户变更事件 payload。
158
158
  * - `patch`:tempOrder 上的协议字段视图(会随订单提交)
159
159
  * - `snapshot`:UI 富字段快照(仅本地,不随订单提交)
160
+ * - `source`:缺省表示真实业务变更;`detailHydrate` 仅表示打开详情时快照已就绪
160
161
  * 清空时整个 payload 为 null。
161
162
  */
162
163
  export interface OrderCustomerChangePayload {
163
164
  patch: OrderCustomerView;
164
165
  snapshot: ICustomer | null;
166
+ source?: 'detailHydrate';
165
167
  }
166
168
  export interface OrderScanCodeResult {
167
169
  isAvailable: boolean;
@@ -1494,13 +1494,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1494
1494
  const hasDraftProduct = params.products.some((product) => !this.isPersistedOrderProduct(product));
1495
1495
  if (hasDraftProduct)
1496
1496
  return false;
1497
- const hasSelectedDiscount = params.currentDiscountList.some(
1498
- (discount) => discount.isSelected || discount.isEditMode || discount.isManualSelect
1497
+ const hasRuntimeDiscountSelection = params.currentDiscountList.some(
1498
+ (discount) => !discount.isEditMode && (discount.isSelected || discount.isManualSelect)
1499
1499
  );
1500
- if (hasSelectedDiscount)
1500
+ if (hasRuntimeDiscountSelection)
1501
1501
  return false;
1502
1502
  return !params.nextDiscountList.some(
1503
- (discount) => discount.isSelected || discount.isEditMode || discount.isManualSelect
1503
+ (discount) => !discount.isEditMode && (discount.isSelected || discount.isManualSelect)
1504
1504
  );
1505
1505
  }
1506
1506
  mergeCurrentDiscountSelectionState(discountList, currentDiscountList) {
@@ -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 | 2 | 1 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 1 | 5 | 2 | 4 | 3 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -3,7 +3,7 @@ import { BookingTicketCartView, BookingTicketProductCatalogView, BookingTicketSt
3
3
  import type { ProductData } from '../../modules';
4
4
  import type { OpenDataConfig } from '../../modules/OpenData';
5
5
  import { type BookingContextConfig, type BookingContextDateInput, type BookingContextResource, type BookingContextResourceMap, type BookingContextState, type InitBookingContextParams, type LoadBookingConfigParams, type LoadBookingResourcesParams, type ResourceError, type BookingCalcContext } from '../../modules/BookingContext';
6
- import type { OrderCustomerView } from '../../modules/Order/types';
6
+ import type { OrderCustomerView, OrderCustomerChangePayload } from '../../modules/Order/types';
7
7
  import { BaseSalesImpl } from '../BaseSales';
8
8
  import type { BaseSalesScanCodeResult } from '../BaseSales/types';
9
9
  import type { ISalesDetail } from '../BaseSales/utils/parseSalesResponse';
@@ -260,7 +260,9 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
260
260
  * 同时透传 OrderModule 内部 emit 的 `order:onOrderCustomerChange` 之外,
261
261
  * 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
262
262
  */
263
- setOrderCustomer(customer: ICustomer | null): void;
263
+ setOrderCustomer(customer: ICustomer | null, options?: {
264
+ source?: OrderCustomerChangePayload['source'];
265
+ }): void;
264
266
  /**
265
267
  * 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
266
268
  */
@@ -451,19 +453,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
451
453
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
452
454
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
453
455
  */
454
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
455
- action: "reloadCatalog";
456
- } | {
457
- action: "add";
458
- cacheItem: any;
459
- } | {
460
- action: "requiresDetail";
461
- payload: AddProductRequiresDetailPayload;
462
- } | {
463
- action: "requiresBookingEdit";
464
- cacheItem: any;
465
- payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
466
- };
456
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
467
457
  /** 规格弹窗 callback 后的第二段决策。 */
468
458
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
469
459
  /**
@@ -343,7 +343,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
343
343
  country_calling_code: selectedCustomer == null ? void 0 : selectedCustomer.country_calling_code
344
344
  };
345
345
  customerModule.setSelectedCustomer(customer);
346
- this.setOrderCustomer(customer);
346
+ this.setOrderCustomer(customer, { source: "detailHydrate" });
347
347
  }
348
348
  return sales;
349
349
  }
@@ -891,7 +891,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
891
891
  * 同时透传 OrderModule 内部 emit 的 `order:onOrderCustomerChange` 之外,
892
892
  * 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
893
893
  */
894
- setOrderCustomer(customer) {
894
+ setOrderCustomer(customer, options) {
895
895
  var _a;
896
896
  if (!customer) {
897
897
  this.clearOrderCustomer();
@@ -911,12 +911,18 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
911
911
  const snapshotReplenished = !snapshotBeforeSet && Boolean(snapshotAfterOrderSet);
912
912
  if (snapshotReplenished) {
913
913
  const next2 = this.buildOrderCustomerPayload();
914
- this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next2);
914
+ this.core.effects.emit(
915
+ `${this.name}:onOrderCustomerChange`,
916
+ next2 && (options == null ? void 0 : options.source) ? { ...next2, source: options.source } : next2
917
+ );
915
918
  }
916
919
  return;
917
920
  }
918
921
  const next = this.buildOrderCustomerPayload();
919
- this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next);
922
+ this.core.effects.emit(
923
+ `${this.name}:onOrderCustomerChange`,
924
+ next && (options == null ? void 0 : options.source) ? { ...next, source: options.source } : next
925
+ );
920
926
  this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
921
927
  const promotionRefreshTask = this.store.order.applyPromotion().then(() => void 0);
922
928
  this.orderCustomerPromotionRefreshInFlight = promotionRefreshTask;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.280",
4
+ "version": "2.2.281",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",