@pisell/pisellos 2.3.68 → 2.3.70

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.
@@ -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;
@@ -119,6 +119,15 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
119
119
  * application_code 仅作为接口兼容字段,不能替代 channel / business_code。
120
120
  */
121
121
  private getPriceQueryStrategyContext;
122
+ /**
123
+ * 子类可在商品重报价前准备客户维度的策略上下文,例如等待 Wallet/优惠资产加载。
124
+ */
125
+ protected prepareProductPriceQueryContext(_customerId?: number | string): Promise<void>;
126
+ /**
127
+ * 默认保留 BaseSales 的 legacy quotation 行为;已由 /product/query 统一完成
128
+ * 智能定价与报价合并的业务可在子类中覆盖,避免二次覆盖权威价格。
129
+ */
130
+ protected preferAuthoritativeProductQueryPrice(): boolean;
122
131
  private getPriceQuerySchedule;
123
132
  private loadProductsForPriceQuery;
124
133
  private loadProductForPriceQuery;
@@ -436,6 +445,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
436
445
  transformBaseProductToOrderProduct(params: TransformBaseProductToOrderProductParams): import("./utils/transformBaseProductToOrderProduct").BaseProductOrderProductInput | null;
437
446
  calculateProductBookingPrice(params: BaseSalesCalculateProductBookingPriceParams): Promise<BaseSalesProductBookingPriceResult>;
438
447
  getQuotationCustomerScopeInfo(): BaseSalesQuotationCustomerScopeInfo;
448
+ private hasSmartPricingStrategies;
439
449
  shouldRecalculateProductBookingPricesForContextChange(params: BaseSalesPriceRecalculationContextChange): boolean;
440
450
  calculateProductBookingPrices(paramsList: BaseSalesCalculateProductBookingPriceParams[]): Promise<BaseSalesProductBookingPriceResult[]>;
441
451
  addProductToOrder(product: Partial<BaseSalesOrderProduct> & BaseSalesOrderProductIdentity, booking?: AddProductBookingInput, options?: AddProductToOrderOptions): Promise<import("../../modules/Order/types").OrderProduct[]>;
@@ -734,8 +734,24 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
734
734
  if (businessCode !== void 0 && businessCode !== null && String(businessCode).trim() !== "") {
735
735
  strategyContext.business_code = String(businessCode).trim();
736
736
  }
737
+ const availableWalletIds = this.getAvailableWalletIds();
738
+ if (availableWalletIds.length > 0 && !Array.isArray(strategyContext.available_wallet_ids)) {
739
+ strategyContext.available_wallet_ids = availableWalletIds;
740
+ }
737
741
  return strategyContext;
738
742
  }
743
+ /**
744
+ * 子类可在商品重报价前准备客户维度的策略上下文,例如等待 Wallet/优惠资产加载。
745
+ */
746
+ async prepareProductPriceQueryContext(_customerId) {
747
+ }
748
+ /**
749
+ * 默认保留 BaseSales 的 legacy quotation 行为;已由 /product/query 统一完成
750
+ * 智能定价与报价合并的业务可在子类中覆盖,避免二次覆盖权威价格。
751
+ */
752
+ preferAuthoritativeProductQueryPrice() {
753
+ return false;
754
+ }
739
755
  getPriceQuerySchedule(params) {
740
756
  const booking = params.booking || {};
741
757
  if (typeof booking.start_date === "string" && booking.start_date.trim()) {
@@ -1478,13 +1494,13 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1478
1494
  const hasDraftProduct = params.products.some((product) => !this.isPersistedOrderProduct(product));
1479
1495
  if (hasDraftProduct)
1480
1496
  return false;
1481
- const hasSelectedDiscount = params.currentDiscountList.some(
1482
- (discount) => discount.isSelected || discount.isEditMode || discount.isManualSelect
1497
+ const hasRuntimeDiscountSelection = params.currentDiscountList.some(
1498
+ (discount) => !discount.isEditMode && (discount.isSelected || discount.isManualSelect)
1483
1499
  );
1484
- if (hasSelectedDiscount)
1500
+ if (hasRuntimeDiscountSelection)
1485
1501
  return false;
1486
1502
  return !params.nextDiscountList.some(
1487
- (discount) => discount.isSelected || discount.isEditMode || discount.isManualSelect
1503
+ (discount) => !discount.isEditMode && (discount.isSelected || discount.isManualSelect)
1488
1504
  );
1489
1505
  }
1490
1506
  mergeCurrentDiscountSelectionState(discountList, currentDiscountList) {
@@ -3129,6 +3145,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
3129
3145
  async calculateProductBookingPrice(params) {
3130
3146
  const quotation = this.store.quotation;
3131
3147
  const customerId = params.customer_id ?? this.getCurrentOrderCustomerId();
3148
+ await this.prepareProductPriceQueryContext(customerId);
3132
3149
  const authoritativeProduct = await this.loadProductForPriceQuery(params, customerId);
3133
3150
  const product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
3134
3151
  await this.loadQuotationForPriceQuery({
@@ -3141,7 +3158,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
3141
3158
  product,
3142
3159
  fallback_price: authoritativeProduct ? void 0 : params.fallback_price,
3143
3160
  customer_id: customerId,
3144
- quotation
3161
+ quotation: authoritativeProduct && this.preferAuthoritativeProductQueryPrice() ? void 0 : quotation
3145
3162
  });
3146
3163
  }
3147
3164
  getQuotationCustomerScopeInfo() {
@@ -3178,11 +3195,23 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
3178
3195
  quotationScopes
3179
3196
  };
3180
3197
  }
3198
+ hasSmartPricingStrategies() {
3199
+ var _a, _b;
3200
+ const evaluator = (_b = (_a = this.core) == null ? void 0 : _a.context) == null ? void 0 : _b.dataVariantEvaluator;
3201
+ if (!evaluator || typeof evaluator.getStrategyConfigs !== "function") {
3202
+ return false;
3203
+ }
3204
+ const configs = evaluator.getStrategyConfigs();
3205
+ return Array.isArray(configs) && configs.length > 0;
3206
+ }
3181
3207
  shouldRecalculateProductBookingPricesForContextChange(params) {
3182
3208
  const scopeInfo = this.getQuotationCustomerScopeInfo();
3183
3209
  const scopedCustomerIds = new Set(scopeInfo.customerIds.map((id) => String(id)));
3184
3210
  const previousCustomerId = this.normalizePriceContextCustomerId(params.previousCustomerId);
3185
3211
  const nextCustomerId = this.normalizePriceContextCustomerId(params.nextCustomerId);
3212
+ if (this.hasSmartPricingStrategies()) {
3213
+ return previousCustomerId !== nextCustomerId;
3214
+ }
3186
3215
  const previousInScope = previousCustomerId ? scopedCustomerIds.has(previousCustomerId) : false;
3187
3216
  const nextInScope = nextCustomerId ? scopedCustomerIds.has(nextCustomerId) : false;
3188
3217
  let shouldRecalculate = false;
@@ -3203,6 +3232,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
3203
3232
  return [];
3204
3233
  const quotation = this.store.quotation;
3205
3234
  const customerId = ((_a = paramsList[0]) == null ? void 0 : _a.customer_id) ?? this.getCurrentOrderCustomerId();
3235
+ await this.prepareProductPriceQueryContext(customerId);
3206
3236
  const productMapsByGroup = /* @__PURE__ */ new Map();
3207
3237
  const groups = /* @__PURE__ */ new Map();
3208
3238
  paramsList.forEach((params) => {
@@ -3260,7 +3290,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
3260
3290
  product,
3261
3291
  fallback_price: authoritativeProduct ? void 0 : params.fallback_price,
3262
3292
  customer_id: customerId,
3263
- quotation
3293
+ quotation: authoritativeProduct && this.preferAuthoritativeProductQueryPrice() ? void 0 : quotation
3264
3294
  });
3265
3295
  });
3266
3296
  }
@@ -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
  */
@@ -287,6 +289,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
287
289
  private buildOrderCustomerPayload;
288
290
  protected refreshDiscountConfigAfterOrderCustomerChange(customerId: number | null): Promise<void>;
289
291
  protected waitForOrderCustomerPromotionRefresh(): Promise<void>;
292
+ protected prepareProductPriceQueryContext(customerId?: number | string): Promise<void>;
293
+ protected preferAuthoritativeProductQueryPrice(): boolean;
290
294
  /**
291
295
  * 获取客户分页信息
292
296
  * @returns 分页信息
@@ -330,7 +334,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
330
334
  * 获取当前的客户搜索条件
331
335
  * @returns 当前搜索条件
332
336
  */
333
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
337
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
334
338
  /**
335
339
  * 获取客户列表状态(包含滚动加载相关状态)
336
340
  * @returns 客户状态
@@ -449,19 +453,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
449
453
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
450
454
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
451
455
  */
452
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
453
- action: "reloadCatalog";
454
- } | {
455
- action: "add";
456
- cacheItem: any;
457
- } | {
458
- action: "requiresDetail";
459
- payload: AddProductRequiresDetailPayload;
460
- } | {
461
- action: "requiresBookingEdit";
462
- cacheItem: any;
463
- payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
464
- };
456
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
465
457
  /** 规格弹窗 callback 后的第二段决策。 */
466
458
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
467
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;
@@ -1036,6 +1042,18 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
1036
1042
  waitForOrderCustomerPromotionRefresh() {
1037
1043
  return this.orderCustomerPromotionRefreshInFlight || Promise.resolve();
1038
1044
  }
1045
+ async prepareProductPriceQueryContext(customerId) {
1046
+ await Promise.resolve();
1047
+ const normalizedCustomerId = Number(customerId || 0);
1048
+ const refreshTask = this.orderCustomerDiscountRefreshInFlight;
1049
+ const shouldWait = normalizedCustomerId > 1 && this.orderCustomerDiscountRefreshCustomerId === normalizedCustomerId && Boolean(refreshTask);
1050
+ if (shouldWait && refreshTask) {
1051
+ await refreshTask;
1052
+ }
1053
+ }
1054
+ preferAuthoritativeProductQueryPrice() {
1055
+ return true;
1056
+ }
1039
1057
  /**
1040
1058
  * 获取客户分页信息
1041
1059
  * @returns 分页信息
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.68",
4
+ "version": "2.3.70",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",