@pisell/pisellos 0.0.510 → 0.0.512

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.
@@ -706,31 +706,16 @@ var getBundleItemIsDiscountPrice = function getBundleItemIsDiscountPrice(item) {
706
706
  var getBundleItemIsMarkupOrDiscountPrice = function getBundleItemIsMarkupOrDiscountPrice(item) {
707
707
  return getBundleItemIsMarkupPrice(item) || getBundleItemIsDiscountPrice(item);
708
708
  };
709
- var getDiscountAmount = function getDiscountAmount(discounts) {
710
- return (discounts || []).reduce(function (total, discount) {
711
- return total.add(new Decimal(discount.amount || 0));
712
- }, new Decimal(0)).toNumber();
713
- };
714
709
 
715
710
  /**
716
711
  * 获取主商品加价减价后的总价 (主商品价格 + 子商品加价减价)
717
712
  */
718
713
  var getMainProductTotal = function getMainProductTotal(item) {
719
- var _ref8, _ref9, _item$main_product_se, _item$metadata, _item$_origin3, _item$_originData;
720
- var total = new Decimal((_ref8 = (_ref9 = (_item$main_product_se = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se !== void 0 ? _item$main_product_se : item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.main_product_selling_price) !== null && _ref9 !== void 0 ? _ref9 : item.price) !== null && _ref8 !== void 0 ? _ref8 : 0);
721
- var discount = (item === null || item === void 0 || (_item$_origin3 = item._origin) === null || _item$_origin3 === void 0 || (_item$_origin3 = _item$_origin3.product) === null || _item$_origin3 === void 0 ? void 0 : _item$_origin3.discount_list) || (item === null || item === void 0 || (_item$_originData = item._originData) === null || _item$_originData === void 0 || (_item$_originData = _item$_originData.product) === null || _item$_originData === void 0 || (_item$_originData = _item$_originData.discount_list) === null || _item$_originData === void 0 ? void 0 : _item$_originData.filter(function (item) {
722
- var _item$metadata2;
723
- return !(item !== null && item !== void 0 && (_item$metadata2 = item.metadata) !== null && _item$metadata2 !== void 0 && _item$metadata2.custom_product_bundle_map_id);
724
- })) || [];
725
- var mainProductDiscountAmount = getDiscountAmount(discount);
726
- total = total.minus(mainProductDiscountAmount);
727
-
728
- // 单规格
729
- if (item !== null && item !== void 0 && item.option && Array.isArray(item === null || item === void 0 ? void 0 : item.option)) {
730
- total = total.add(item === null || item === void 0 ? void 0 : item.option.reduce(function (t, option) {
731
- return t.add(new Decimal(option.price || 0).mul(option.num || 1));
732
- }, new Decimal(0)));
733
- }
714
+ var _ref8, _ref9, _item$main_product_se, _item$metadata, _item$metadata2;
715
+ // 新语义 v2 `main_product_selling_price` / `metadata.main_product_selling_price`
716
+ // 已经是"含 option、含主商品折扣"的主价,直接作为主商品基准,无需再减折扣或加 option。
717
+ // 仅需叠加 markup / markdown 类 bundle(原价 bundle 的税费单独处理)。
718
+ var total = new Decimal((_ref8 = (_ref9 = (_item$main_product_se = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se !== void 0 ? _item$main_product_se : item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.main_product_selling_price) !== null && _ref9 !== void 0 ? _ref9 : item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.main_product_original_price) !== null && _ref8 !== void 0 ? _ref8 : 0);
734
719
  var _iterator4 = _createForOfIteratorHelper((item === null || item === void 0 ? void 0 : item.bundle) || []),
735
720
  _step4;
736
721
  try {
@@ -738,7 +723,7 @@ var getMainProductTotal = function getMainProductTotal(item) {
738
723
  var bundleItem = _step4.value;
739
724
  if (getBundleItemIsMarkupOrDiscountPrice(bundleItem)) {
740
725
  var _ref10, _bundleItem$bundle_se2;
741
- // IMPORTANT: 套餐子商品如果应用了 discount,bundle_selling_price和 price 其实都已经是折后价格了,不需要单独再减一次
726
+ // IMPORTANT: 套餐子商品如果应用了 discount,bundle_selling_price 和 price 其实都已经是折后价格了,不需要单独再减一次
742
727
  var bundleItemTotal = new Decimal((_ref10 = (_bundleItem$bundle_se2 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se2 !== void 0 ? _bundleItem$bundle_se2 : bundleItem.price) !== null && _ref10 !== void 0 ? _ref10 : 0);
743
728
  total = total.add(bundleItemTotal);
744
729
  }
@@ -1,6 +1,7 @@
1
1
  import { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
3
  import { ScanOrderAddLogParams, ScanOrderAvailabilityInfo, ScanOrderOrderProduct, ScanOrderOrderProductIdentity, ScanOrderScanCodeResult } from './types';
4
+ import type { UpdateProductInOrderParams } from '../../modules/Order/types';
4
5
  import type { Discount } from '../../modules/Discount/types';
5
6
  import { type CartItemSummary, type PaxInfo, type QuantityCheckResult, type QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
6
7
  import type { StrategyConfig } from '../../model/strategy/type';
@@ -48,6 +49,9 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
48
49
  private registerCustomerLoginListeners;
49
50
  private refreshOrderMarketingAfterLogin;
50
51
  constructor(name?: string, version?: string);
52
+ /** 与 `otherParams.cacheId` 一致,供宿主在 URL 变化时判断是否需要重新注册模块 */
53
+ getCacheId(): string | undefined;
54
+ private destroyRegisteredChildModules;
51
55
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
52
56
  destroy(): Promise<void>;
53
57
  retryInit(): Promise<void>;
@@ -85,11 +89,12 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
85
89
  private buildSubmitPayloadEnhancer;
86
90
  submitScanOrder<T = any>(): Promise<T>;
87
91
  addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
88
- updateProductInOrder(params: {
89
- product_id: number | null;
90
- product_variant_id: number;
91
- updates: Partial<ScanOrderOrderProduct>;
92
- }): Promise<ScanOrderOrderProduct[]>;
92
+ updateProductInOrder(params: UpdateProductInOrderParams): Promise<ScanOrderOrderProduct[]>;
93
+ /**
94
+ * 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
95
+ * 多行同 SKU 时必须传入与删除/更新一致的 identity(如 `identity_key`)。
96
+ */
97
+ setOrderProductLineNote(identity: ScanOrderOrderProductIdentity, note: string): Promise<ScanOrderOrderProduct[]>;
93
98
  removeProductFromOrder(identity: ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
94
99
  private loadRuntimeConfigs;
95
100
  private syncItemRuleConfigsFromDineInConfig;