@pisell/pisellos 2.3.102 → 2.3.103

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.
@@ -192,10 +192,11 @@ function synthesizeProductResourceFromBooking(booking) {
192
192
  * 调用方须传入与该行关联的 booking(通常 bookings[].product_uid === product.metadata.unique_identification_number)。
193
193
  */
194
194
  export function buildCacheItemFromOrderLine(input) {
195
- var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$bundle_edit, _product$product_vari, _product$num, _ref11, _product$note, _booking$detail2, _product$metadata, _product$metadata2, _ref12, _extension_type, _booking$product2, _booking$product3, _price, _product$product_sku, _product$order_detail, _ref13, _booking$id;
195
+ var _ref11, _sourceProduct$holder, _sourceProduct$origin, _product$metadata, _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$bundle_edit, _product$product_vari, _product$num, _ref12, _product$note, _booking$detail2, _product$metadata2, _product$metadata3, _ref13, _extension_type, _booking$product2, _booking$product3, _price, _product$product_sku, _product$order_detail, _ref14, _booking$id;
196
196
  var product = input.product,
197
197
  booking = input.booking,
198
198
  sourceProduct = input.sourceProduct;
199
+ var holderConfig = (_ref11 = (_sourceProduct$holder = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.holder_config) !== null && _sourceProduct$holder !== void 0 ? _sourceProduct$holder : sourceProduct === null || sourceProduct === void 0 || (_sourceProduct$origin = sourceProduct.origin) === null || _sourceProduct$origin === void 0 ? void 0 : _sourceProduct$origin.holder_config) !== null && _ref11 !== void 0 ? _ref11 : (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.holder_config;
199
200
  var resolvedId = (_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.id;
200
201
  var selling = Number((_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : 0);
201
202
  var original = Number((_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : selling);
@@ -229,7 +230,7 @@ export function buildCacheItemFromOrderLine(input) {
229
230
  quantity: (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : 1,
230
231
  product_name: productTitle,
231
232
  product_cover: productCover,
232
- note: (_ref11 = (_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : booking === null || booking === void 0 || (_booking$detail2 = booking.detail) === null || _booking$detail2 === void 0 ? void 0 : _booking$detail2.note) !== null && _ref11 !== void 0 ? _ref11 : '',
233
+ note: (_ref12 = (_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : booking === null || booking === void 0 || (_booking$detail2 = booking.detail) === null || _booking$detail2 === void 0 ? void 0 : _booking$detail2.note) !== null && _ref12 !== void 0 ? _ref12 : '',
233
234
  price: mainProductPrice,
234
235
  total: selling,
235
236
  origin_total: original,
@@ -238,7 +239,7 @@ export function buildCacheItemFromOrderLine(input) {
238
239
  holder_id: holderId,
239
240
  other: other,
240
241
  like_status: booking.like_status || 'common',
241
- discount_reason: resolveManualDiscountMessage(product.discount_list, (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.product_discount_reason) || undefined
242
+ discount_reason: resolveManualDiscountMessage(product.discount_list, (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.product_discount_reason) || undefined
242
243
  }, bundleEdit !== undefined ? {
243
244
  bundle_edit: bundleEdit
244
245
  } : {}), productOptionString ? {
@@ -254,7 +255,7 @@ export function buildCacheItemFromOrderLine(input) {
254
255
  extend.origin_total = selling + manualAmount;
255
256
  }
256
257
  }
257
- if (((_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.price_override) != null || manualDiscount) {
258
+ if (((_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.price_override) != null || manualDiscount) {
258
259
  extend.priceOverride = selling;
259
260
  }
260
261
  if (booking.holder !== undefined) {
@@ -263,10 +264,12 @@ export function buildCacheItemFromOrderLine(input) {
263
264
  if (Array.isArray(booking.relation_forms)) {
264
265
  extend.relation_forms = booking.relation_forms;
265
266
  }
266
- var base = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
267
+ var base = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), holderConfig !== undefined && holderConfig !== null ? {
268
+ holder_config: holderConfig
269
+ } : {}), {}, {
267
270
  id: resolvedId,
268
271
  product_id: resolvedId,
269
- extension_type: (_ref12 = (_extension_type = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type) !== null && _extension_type !== void 0 ? _extension_type : booking === null || booking === void 0 || (_booking$product2 = booking.product) === null || _booking$product2 === void 0 ? void 0 : _booking$product2.extension_type) !== null && _ref12 !== void 0 ? _ref12 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
272
+ extension_type: (_ref13 = (_extension_type = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type) !== null && _extension_type !== void 0 ? _extension_type : booking === null || booking === void 0 || (_booking$product2 = booking.product) === null || _booking$product2 === void 0 ? void 0 : _booking$product2.extension_type) !== null && _ref13 !== void 0 ? _ref13 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
270
273
  title: productTitle || (sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) || (booking === null || booking === void 0 || (_booking$product3 = booking.product) === null || _booking$product3 === void 0 ? void 0 : _booking$product3.title),
271
274
  price: (_price = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price !== void 0 ? _price : selling,
272
275
  selling_price: product.selling_price,
@@ -280,7 +283,7 @@ export function buildCacheItemFromOrderLine(input) {
280
283
  new: 0,
281
284
  autoClose: false,
282
285
  order_detail_id: (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : null,
283
- booking_id: (_ref13 = (_booking$id = booking.id) !== null && _booking$id !== void 0 ? _booking$id : booking.booking_id) !== null && _ref13 !== void 0 ? _ref13 : 0
286
+ booking_id: (_ref14 = (_booking$id = booking.id) !== null && _booking$id !== void 0 ? _booking$id : booking.booking_id) !== null && _ref14 !== void 0 ? _ref14 : 0
284
287
  });
285
288
  if ((sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.capacity) !== undefined) {
286
289
  base.capacity = sourceProduct.capacity;
@@ -29,8 +29,10 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
29
29
  private promotionEvaluator;
30
30
  /** 赠品选择 resolver;由 SDK host bridge 注入 */
31
31
  private giftSelectResolver;
32
- /** applyPromotion 递归保护 flag(写路径同步调 applyPromotion,禁止重入) */
32
+ /** 促销评估递归保护 flag(写路径同步评估促销,禁止重入) */
33
33
  private isApplyingPromotion;
34
+ /** 保持旧事件语义:同步事件监听器内触发的订单写入不得递归评估促销。 */
35
+ private isEmittingPromotionApplied;
34
36
  /** 商品曾应用过客户券卡,客户变更剥离后需强制跑一次 calcDiscount 复位价格 */
35
37
  private hasActiveCustomerBoundDiscount;
36
38
  /** 最近一次 applyPromotion 的未满足促销提示 */
@@ -124,7 +126,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
124
126
  */
125
127
  appendPromotionTags<T extends Record<string, any>>(products: T[]): T[];
126
128
  /**
127
- * 应用购物车促销:计算 → 差异化赠品 → 写回 tempOrder.products → emit onPromotionApplied。
129
+ * 只执行购物车促销评估与赠品写回,不发布稳定态事件。
128
130
  *
129
131
  * 调用时机:写路径(add/update/remove/clear/setCustomer)末尾自动触发;外部一般无需手动调。
130
132
  *
@@ -132,8 +134,13 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
132
134
  * - 不调用任何公开 CRUD API(如 removeProductFromOrder),全部内部 mutate tempOrder.products,避免事件风暴;
133
135
  * - 用 `isApplyingPromotion` 防递归;
134
136
  * - 多选项赠品依赖 giftSelectResolver,未注入则跳过且 console.warn;
135
- * - 不主动调用 applyDiscount / recalculateSummary,调用方负责跟进。
137
+ * - 不主动调用 applyDiscount / recalculateSummary,调用方负责跟进;
138
+ * - 返回的 payload 只能在 applyDiscount(商品写路径还需 summary/persist)完成后发布。
136
139
  */
140
+ private evaluatePromotion;
141
+ /** 发布促销稳定态;products 必须读取折扣计算后的当前数组。 */
142
+ private emitPromotionApplied;
143
+ /** 公开入口:促销、折扣、summary 与持久化完成后发布稳定态事件。 */
137
144
  applyPromotion(): Promise<void>;
138
145
  /** 最近一次 applyPromotion 输出的未满足促销列表 */
139
146
  getUnfulfilledPromotions(): OrderUnfulfilledPromotion[];
@@ -430,6 +437,11 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
430
437
  * if (pending) await pending;
431
438
  */
432
439
  private appendProductLineToTempOrder;
440
+ /**
441
+ * booking 数量拆行时,若 Holder 数量与拆行数严格一致,则按下标分配。
442
+ * 数量不一致时保持旧数据,避免猜测 Holder 与商品份数的对应关系。
443
+ */
444
+ private createSplitBookingLine;
433
445
  /**
434
446
  * 添加商品行。带 booking 时强制独立行;num>1 时拆成多条 num=1 的 product+booking(对齐 BookingByStep / ticketBooking addService)。
435
447
  *