@pisell/pisellos 2.3.120 → 2.3.122

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.
@@ -511,7 +511,16 @@ function resolveProductBasePrice(product) {
511
511
  const variantId = product.product_variant_id ?? product.variant_id;
512
512
  const variant = Array.isArray(origin.variant) && isPresentId(variantId) ? origin.variant.find(item => isSameId(item?.id, variantId)) : undefined;
513
513
  const isV2 = metadata.price_schema_version === 2 || metadata.price_schema_version === '2';
514
- return firstPresentValue(metadata.source_product_price, variant?.price, product._origin?.price, product._origin?.base_price, !isV2 ? metadata.main_product_original_price : undefined, product.base_price, product.price);
514
+ const quantity = toNumber(product.product_quantity ?? product.quantity ?? product.num ?? 1, 1);
515
+ const hasEntitlementPass = normalizeArray(product.discount_list).some(discount => getProductWalletDiscountType(discount) === 'entitlement_pass');
516
+ const hasOptions = normalizeArray(product.options).length > 0 || normalizeArray(product.product_sku?.option).length > 0;
517
+ const hasCombinations = normalizeArray(product.combinations).length > 0 || normalizeArray(product.product_bundle).length > 0 || normalizeArray(product.bundle).length > 0;
518
+ const aggregateSourcePrice = firstPresentValue(metadata.source_product_price, product.price);
519
+ const originalPrice = product.original_price;
520
+ // 部分旧 entitlement 商品把 source/price 持久化成了整行总价,但
521
+ // original_price 仍是单件价。仅在等式能明确证明该口径时做窄幅回退。
522
+ const useOriginalPriceAsLegacyUnitPrice = hasEntitlementPass && quantity > 1 && !hasOptions && !hasCombinations && isNumericAmount(aggregateSourcePrice) && isNumericAmount(originalPrice) && new _decimal.default(aggregateSourcePrice).eq(new _decimal.default(originalPrice).mul(quantity));
523
+ return firstPresentValue(useOriginalPriceAsLegacyUnitPrice ? originalPrice : undefined, metadata.source_product_price, variant?.price, product._origin?.price, product._origin?.base_price, !isV2 ? metadata.main_product_original_price : undefined, product.base_price, product.price);
515
524
  }
516
525
  function normalizeProductDiscounts(params) {
517
526
  const {
@@ -528,7 +537,8 @@ function normalizeProductDiscounts(params) {
528
537
  const amount = discount.amount ?? discount.value ?? discount.discount_amount;
529
538
  const isMarkup = isManualMarkup(discount);
530
539
  const isAggregatedBundleDiscount = Boolean(getReceiptDiscountBundleMapId(discount));
531
- const totalAmount = new _decimal.default(toMoneyNumber(amount)).mul(isAggregatedBundleDiscount ? 1 : quantity);
540
+ const isEntitlementPass = getProductWalletDiscountType(discount) === 'entitlement_pass';
541
+ const totalAmount = new _decimal.default(toMoneyNumber(amount)).mul(isAggregatedBundleDiscount || isEntitlementPass ? 1 : quantity);
532
542
  const formattedAmount = isMarkup ? formatMoney(totalAmount.abs(), currencySymbol) : formatNegativeMoney(totalAmount, currencySymbol);
533
543
  return {
534
544
  item: title,
@@ -1191,7 +1201,8 @@ function buildDelivery(order, locale) {
1191
1201
  return items;
1192
1202
  }
1193
1203
  function buildAppointment(order, locale) {
1194
- const bookings = sortBookings(normalizeArray(order.bookings));
1204
+ const parentScheduleId = order.metadata?.appointment_booking_parent_schedule_id;
1205
+ const bookings = sortBookings(normalizeArray(order.bookings).filter(booking => isReceiptAppointmentBooking(booking, parentScheduleId)));
1195
1206
  if (bookings.length) {
1196
1207
  const allResources = normalizeArray(order.resources || order.resource_list);
1197
1208
  return bookings.flatMap(booking => buildAppointmentRows({
@@ -1208,6 +1219,19 @@ function buildAppointment(order, locale) {
1208
1219
  value: getLocalizedValue(tableName, locale)
1209
1220
  }];
1210
1221
  }
1222
+ function isReceiptAppointmentBooking(booking, parentScheduleId) {
1223
+ if (!booking || typeof booking !== 'object' || Array.isArray(booking)) {
1224
+ return false;
1225
+ }
1226
+ if (isPresentId(parentScheduleId) && isSameId(booking.schedule_event_id, parentScheduleId)) {
1227
+ return false;
1228
+ }
1229
+ const parentId = booking.parent_id;
1230
+ if (parentId === undefined || parentId === null || parentId === '') {
1231
+ return true;
1232
+ }
1233
+ return Number(parentId) !== 0;
1234
+ }
1211
1235
  function buildAppointmentRows(params) {
1212
1236
  const {
1213
1237
  booking,
@@ -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 | 6 | 5 | 1 | 2 | 3 | 4;
329
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -347,7 +347,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
347
347
  * 获取当前的客户搜索条件
348
348
  * @returns 当前搜索条件
349
349
  */
350
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
350
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
351
351
  /**
352
352
  * 获取客户列表状态(包含滚动加载相关状态)
353
353
  * @returns 客户状态
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.120",
4
+ "version": "2.3.122",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",