@pisell/pisellos 2.3.166 → 2.3.168

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.
@@ -1299,29 +1299,40 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1299
1299
  if (!Number.isFinite(productId) || targetQuantity <= 0) continue;
1300
1300
  if (Number.isNaN(productVariantId)) continue;
1301
1301
  const sourceItem = productSourceMap.get((0, _utils.buildProductKey)(productId, productVariantId)) || productSourceMap.get((0, _utils.buildProductKey)(productId, 0)) || null;
1302
+ const sourceTitle = sourceItem?.product_title || sourceItem?.title || sourceItem?.name;
1303
+ const productTitle = typeof sourceTitle === 'string' ? {
1304
+ auto: sourceTitle
1305
+ } : sourceTitle;
1306
+ // 标准标题在归一化后补入,供购物车展示,并由 Order 在折扣重算时保留。
1307
+ const displayFields = productTitle ? {
1308
+ product_title: productTitle
1309
+ } : {};
1302
1310
  const productIndex = (0, _utils.getProductIdentityIndex)(tempOrder.products, {
1303
1311
  product_id: productId,
1304
1312
  product_variant_id: productVariantId
1305
1313
  });
1306
1314
  if (productIndex === -1) {
1307
1315
  const sellingPrice = (0, _utils.toPriceString)(sourceItem?.price ?? sourceItem?.selling_price, '0.00');
1308
- tempOrder.products.push((0, _utils.normalizeOrderProduct)({
1309
- ...sourceItem,
1310
- product_id: productId,
1311
- product_variant_id: productVariantId,
1312
- num: targetQuantity,
1313
- selling_price: sellingPrice,
1314
- original_price: sellingPrice,
1315
- metadata: {
1316
- item_rule_prefill: true,
1317
- item_rule_id: prefillItem.ruleId
1318
- },
1319
- _origin: {
1320
- ...(sourceItem || {}),
1321
- item_rule_prefill: true,
1322
- item_rule_id: prefillItem.ruleId
1323
- }
1324
- }));
1316
+ tempOrder.products.push({
1317
+ ...(0, _utils.normalizeOrderProduct)({
1318
+ ...sourceItem,
1319
+ product_id: productId,
1320
+ product_variant_id: productVariantId,
1321
+ num: targetQuantity,
1322
+ selling_price: sellingPrice,
1323
+ original_price: sellingPrice,
1324
+ metadata: {
1325
+ item_rule_prefill: true,
1326
+ item_rule_id: prefillItem.ruleId
1327
+ },
1328
+ _origin: {
1329
+ ...(sourceItem || {}),
1330
+ item_rule_prefill: true,
1331
+ item_rule_id: prefillItem.ruleId
1332
+ }
1333
+ }),
1334
+ ...displayFields
1335
+ });
1325
1336
  hasChanges = true;
1326
1337
  continue;
1327
1338
  }
@@ -1330,6 +1341,7 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1330
1341
  const delta = targetQuantity - existedQuantity;
1331
1342
  const nextProduct = {
1332
1343
  ...targetProduct,
1344
+ ...displayFields,
1333
1345
  ...(delta > 0 ? {
1334
1346
  num: (0, _utils.getSafeProductNum)(existedQuantity + delta)
1335
1347
  } : {}),
@@ -1344,8 +1356,9 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
1344
1356
  } : targetProduct._origin
1345
1357
  };
1346
1358
  const hasQuantityChanged = delta > 0;
1359
+ const hasTitleChanged = Boolean(productTitle && JSON.stringify(targetProduct.product_title) !== JSON.stringify(productTitle));
1347
1360
  const hasOriginChanged = Boolean(sourceItem && (!targetProduct._origin || targetProduct._origin?.name !== sourceItem?.name || targetProduct._origin?.title !== sourceItem?.title || targetProduct._origin?.price !== sourceItem?.price));
1348
- if (hasQuantityChanged || hasOriginChanged) {
1361
+ if (hasQuantityChanged || hasTitleChanged || hasOriginChanged) {
1349
1362
  tempOrder.products[productIndex] = nextProduct;
1350
1363
  hasChanges = true;
1351
1364
  }
@@ -1,5 +1,6 @@
1
1
  import { OrderModule, ProductList, SalesSummaryModule, ScanOrderLogInput, ScanOrderLoggerModule, ScanOrderLoggerProviderConfig, ScanOrderLoggerProviderType, ScheduleModule } from '../../modules';
2
2
  import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
3
+ import type { OrderLocalizedText } from '../../modules/Order/types';
3
4
  /**
4
5
  * 扫码下单流程 hook
5
6
  */
@@ -43,6 +44,8 @@ export interface ScanOrderProductSku {
43
44
  }
44
45
  export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
45
46
  order_detail_id: number | null;
47
+ /** 与 Order 一致的商品展示名称。 */
48
+ product_title?: OrderLocalizedText;
46
49
  num: number;
47
50
  /** Product 或当前 Variant 的生产编码 */
48
51
  production_code?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.166",
4
+ "version": "2.3.168",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",