@pisell/pisellos 2.3.154 → 2.3.155

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.
@@ -595,7 +595,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
595
595
  generateIdempotencyToken(): string;
596
596
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
597
597
  createOrder(params: CommitOrderParams['query']): {
598
- type: "virtual" | "appointment_booking";
598
+ type: "appointment_booking" | "virtual";
599
599
  platform: string;
600
600
  sales_channel: string;
601
601
  order_sales_channel: string;
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "normal" | "session";
53
53
  }
@@ -1399,7 +1399,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1399
1399
  value: function () {
1400
1400
  var _resolveProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
1401
1401
  var _this7 = this;
1402
- var selectedProducts, productIds, ids, handledByOsServer, canUseLocalFastPath, productsById, queryPayload, cachedRawProducts, authoritativeProducts, missingIds, remoteRawProducts;
1402
+ var selectedProducts, productIds, ids, handledByOsServer, canUseLocalFastPath, productsById, shouldAlignSelectedVariantPrice, queryPayload, cachedRawProducts, authoritativeProducts, missingIds, remoteRawProducts;
1403
1403
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1404
1404
  while (1) switch (_context10.prev = _context10.next) {
1405
1405
  case 0:
@@ -1423,7 +1423,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1423
1423
  handledByOsServer = this.request ? isProductQueryHandledByOsServer(this.core, this.request) : false;
1424
1424
  canUseLocalFastPath = this.isCustomerUserPriceQuery() && !handledByOsServer;
1425
1425
  if (canUseLocalFastPath) {
1426
- _context10.next = 14;
1426
+ _context10.next = 15;
1427
1427
  break;
1428
1428
  }
1429
1429
  if (this.request) {
@@ -1443,10 +1443,37 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1443
1443
  });
1444
1444
  case 12:
1445
1445
  productsById = _context10.sent;
1446
- return _context10.abrupt("return", productIds.map(function (productId) {
1447
- return productId === null ? null : productsById.get(productId) || null;
1446
+ shouldAlignSelectedVariantPrice = handledByOsServer && this.preferAuthoritativeProductQueryPrice();
1447
+ return _context10.abrupt("return", productIds.map(function (productId, index) {
1448
+ var _authoritativeProduct;
1449
+ var authoritativeProduct = productId === null ? null : productsById.get(productId) || null;
1450
+ if (!shouldAlignSelectedVariantPrice || !authoritativeProduct) return authoritativeProduct;
1451
+ var selectedProduct = selectedProducts[index];
1452
+ var selectedVariantId = _this7.getSelectedProductVariantId(selectedProduct);
1453
+ if (!selectedVariantId || _this7.getSelectedProductVariantId(authoritativeProduct) === selectedVariantId) {
1454
+ return authoritativeProduct;
1455
+ }
1456
+
1457
+ // OS 返回的是目录商品;已命中的智能价格不能被规格基础价覆盖。
1458
+ var appliedFields = (_authoritativeProduct = authoritativeProduct._dataVariant) === null || _authoritativeProduct === void 0 ? void 0 : _authoritativeProduct.appliedFields;
1459
+ if (Array.isArray(appliedFields) && ['price', 'selling_price', 'original_price', 'base_price'].some(function (field) {
1460
+ return appliedFields.includes(field);
1461
+ })) {
1462
+ return authoritativeProduct;
1463
+ }
1464
+ var selectedVariant = Array.isArray(authoritativeProduct.variant) ? authoritativeProduct.variant.find(function (variant) {
1465
+ return Number(variant === null || variant === void 0 ? void 0 : variant.id) === selectedVariantId;
1466
+ }) : undefined;
1467
+ var selectedPrice = [selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.price, selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.selling_price, selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.base_price, params.priceQueries[index].fallback_price, selectedProduct.price, selectedProduct.selling_price, selectedProduct.original_price].find(function (value) {
1468
+ return (typeof value === 'number' || typeof value === 'string' && value.trim() !== '') && Number.isFinite(Number(value));
1469
+ });
1470
+
1471
+ // 每行独立保留所选规格价格(含 0 元),避免同商品多规格共用目录对象串价。
1472
+ return selectedPrice === undefined ? authoritativeProduct : _objectSpread(_objectSpread({}, authoritativeProduct), {}, {
1473
+ price: selectedPrice
1474
+ });
1448
1475
  }));
1449
- case 14:
1476
+ case 15:
1450
1477
  queryPayload = this.buildPriceQueryPayload({
1451
1478
  ids: ids,
1452
1479
  schedule: params.schedule,
@@ -1466,25 +1493,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1466
1493
  return productId !== null && !authoritativeProducts[index];
1467
1494
  })));
1468
1495
  if (missingIds.length) {
1469
- _context10.next = 20;
1496
+ _context10.next = 21;
1470
1497
  break;
1471
1498
  }
1472
1499
  return _context10.abrupt("return", authoritativeProducts);
1473
- case 20:
1500
+ case 21:
1474
1501
  if (this.request) {
1475
- _context10.next = 22;
1502
+ _context10.next = 23;
1476
1503
  break;
1477
1504
  }
1478
1505
  return _context10.abrupt("return", authoritativeProducts);
1479
- case 22:
1480
- _context10.next = 24;
1506
+ case 23:
1507
+ _context10.next = 25;
1481
1508
  return this.loadProductsForPriceQuery({
1482
1509
  ids: missingIds,
1483
1510
  schedule: params.schedule,
1484
1511
  customerId: params.customerId,
1485
1512
  channel: params.channel
1486
1513
  });
1487
- case 24:
1514
+ case 25:
1488
1515
  remoteRawProducts = _context10.sent;
1489
1516
  authoritativeProducts.forEach(function (authoritativeProduct, index) {
1490
1517
  if (authoritativeProduct) return;
@@ -1506,7 +1533,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1506
1533
  authoritativeProducts[index] = rawProduct ? _this7.prepareRawProductForPriceQuery(rawProduct, selectedProducts[index]) || rawProduct : null;
1507
1534
  });
1508
1535
  return _context10.abrupt("return", authoritativeProducts);
1509
- case 27:
1536
+ case 28:
1510
1537
  case "end":
1511
1538
  return _context10.stop();
1512
1539
  }
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
328
328
  date: string;
329
329
  status: string;
330
330
  week: string;
331
- weekNum: 0 | 1 | 2 | 3 | 5 | 4 | 6;
331
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
332
332
  }[]>;
333
333
  submitTimeSlot(timeSlots: TimeSliceItem): void;
334
334
  private getScheduleDataByIds;
@@ -375,7 +375,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
375
375
  };
376
376
  setOtherData(key: string, value: any): void;
377
377
  getOtherData(key: string): any;
378
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
378
+ getProductTypeById(id: number): Promise<"duration" | "normal" | "session">;
379
379
  /**
380
380
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
381
381
  *
@@ -595,7 +595,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
595
595
  generateIdempotencyToken(): string;
596
596
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
597
597
  createOrder(params: CommitOrderParams['query']): {
598
- type: "virtual" | "appointment_booking";
598
+ type: "appointment_booking" | "virtual";
599
599
  platform: string;
600
600
  sales_channel: string;
601
601
  order_sales_channel: string;
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "normal" | "session";
53
53
  }
@@ -1043,7 +1043,30 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
1043
1043
  customerId: params.customerId,
1044
1044
  channel: params.channel
1045
1045
  });
1046
- return productIds.map(productId => productId === null ? null : productsById.get(productId) || null);
1046
+ const shouldAlignSelectedVariantPrice = handledByOsServer && this.preferAuthoritativeProductQueryPrice();
1047
+ return productIds.map((productId, index) => {
1048
+ const authoritativeProduct = productId === null ? null : productsById.get(productId) || null;
1049
+ if (!shouldAlignSelectedVariantPrice || !authoritativeProduct) return authoritativeProduct;
1050
+ const selectedProduct = selectedProducts[index];
1051
+ const selectedVariantId = this.getSelectedProductVariantId(selectedProduct);
1052
+ if (!selectedVariantId || this.getSelectedProductVariantId(authoritativeProduct) === selectedVariantId) {
1053
+ return authoritativeProduct;
1054
+ }
1055
+
1056
+ // OS 返回的是目录商品;已命中的智能价格不能被规格基础价覆盖。
1057
+ const appliedFields = authoritativeProduct._dataVariant?.appliedFields;
1058
+ if (Array.isArray(appliedFields) && ['price', 'selling_price', 'original_price', 'base_price'].some(field => appliedFields.includes(field))) {
1059
+ return authoritativeProduct;
1060
+ }
1061
+ const selectedVariant = Array.isArray(authoritativeProduct.variant) ? authoritativeProduct.variant.find(variant => Number(variant?.id) === selectedVariantId) : undefined;
1062
+ const selectedPrice = [selectedVariant?.price, selectedVariant?.selling_price, selectedVariant?.base_price, params.priceQueries[index].fallback_price, selectedProduct.price, selectedProduct.selling_price, selectedProduct.original_price].find(value => (typeof value === 'number' || typeof value === 'string' && value.trim() !== '') && Number.isFinite(Number(value)));
1063
+
1064
+ // 每行独立保留所选规格价格(含 0 元),避免同商品多规格共用目录对象串价。
1065
+ return selectedPrice === undefined ? authoritativeProduct : {
1066
+ ...authoritativeProduct,
1067
+ price: selectedPrice
1068
+ };
1069
+ });
1047
1070
  }
1048
1071
  const queryPayload = this.buildPriceQueryPayload({
1049
1072
  ids,
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
328
328
  date: string;
329
329
  status: string;
330
330
  week: string;
331
- weekNum: 0 | 1 | 2 | 3 | 5 | 4 | 6;
331
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
332
332
  }[]>;
333
333
  submitTimeSlot(timeSlots: TimeSliceItem): void;
334
334
  private getScheduleDataByIds;
@@ -375,7 +375,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
375
375
  };
376
376
  setOtherData(key: string, value: any): void;
377
377
  getOtherData(key: string): any;
378
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
378
+ getProductTypeById(id: number): Promise<"duration" | "normal" | "session">;
379
379
  /**
380
380
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
381
381
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.154",
4
+ "version": "2.3.155",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",