@pisell/pisellos 2.2.279 → 2.2.280

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,51 +0,0 @@
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
- });
@@ -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()) {
@@ -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
  }
@@ -287,6 +287,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
287
287
  private buildOrderCustomerPayload;
288
288
  protected refreshDiscountConfigAfterOrderCustomerChange(customerId: number | null): Promise<void>;
289
289
  protected waitForOrderCustomerPromotionRefresh(): Promise<void>;
290
+ protected prepareProductPriceQueryContext(customerId?: number | string): Promise<void>;
291
+ protected preferAuthoritativeProductQueryPrice(): boolean;
290
292
  /**
291
293
  * 获取客户分页信息
292
294
  * @returns 分页信息
@@ -330,7 +332,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
330
332
  * 获取当前的客户搜索条件
331
333
  * @returns 当前搜索条件
332
334
  */
333
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
335
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
334
336
  /**
335
337
  * 获取客户列表状态(包含滚动加载相关状态)
336
338
  * @returns 客户状态
@@ -1036,6 +1036,18 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
1036
1036
  waitForOrderCustomerPromotionRefresh() {
1037
1037
  return this.orderCustomerPromotionRefreshInFlight || Promise.resolve();
1038
1038
  }
1039
+ async prepareProductPriceQueryContext(customerId) {
1040
+ await Promise.resolve();
1041
+ const normalizedCustomerId = Number(customerId || 0);
1042
+ const refreshTask = this.orderCustomerDiscountRefreshInFlight;
1043
+ const shouldWait = normalizedCustomerId > 1 && this.orderCustomerDiscountRefreshCustomerId === normalizedCustomerId && Boolean(refreshTask);
1044
+ if (shouldWait && refreshTask) {
1045
+ await refreshTask;
1046
+ }
1047
+ }
1048
+ preferAuthoritativeProductQueryPrice() {
1049
+ return true;
1050
+ }
1039
1051
  /**
1040
1052
  * 获取客户分页信息
1041
1053
  * @returns 分页信息
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.279",
4
+ "version": "2.2.280",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",