@pisell/pisellos 2.2.197 → 2.2.199

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.
Files changed (45) hide show
  1. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +7 -3
  2. package/dist/modules/Cart/utils/cartProduct.js +11 -1
  3. package/dist/modules/Cart/utils/changePrice.js +11 -11
  4. package/dist/modules/Order/index.d.ts +16 -0
  5. package/dist/modules/Order/index.js +1232 -568
  6. package/dist/modules/Order/types.d.ts +1 -0
  7. package/dist/modules/Order/utils.d.ts +33 -2
  8. package/dist/modules/Order/utils.js +112 -55
  9. package/dist/modules/Payment/walletpass.js +14 -7
  10. package/dist/modules/SalesSummary/utils.js +394 -149
  11. package/dist/server/index.d.ts +3 -0
  12. package/dist/server/index.js +294 -190
  13. package/dist/server/modules/order/index.d.ts +8 -0
  14. package/dist/server/modules/order/index.js +536 -317
  15. package/dist/server/modules/order/types.d.ts +2 -0
  16. package/dist/solution/BaseSales/index.js +2 -1
  17. package/dist/solution/BaseSales/types.d.ts +1 -0
  18. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +19 -4
  19. package/dist/solution/BookingByStep/index.d.ts +1 -1
  20. package/dist/solution/ScanOrder/types.d.ts +1 -0
  21. package/dist/solution/ScanOrder/utils.js +26 -9
  22. package/dist/solution/VenueBooking/index.js +2 -1
  23. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +4 -1
  24. package/lib/modules/Cart/utils/cartProduct.js +11 -1
  25. package/lib/modules/Cart/utils/changePrice.js +12 -20
  26. package/lib/modules/Order/index.d.ts +16 -0
  27. package/lib/modules/Order/index.js +525 -18
  28. package/lib/modules/Order/types.d.ts +1 -0
  29. package/lib/modules/Order/utils.d.ts +33 -2
  30. package/lib/modules/Order/utils.js +44 -9
  31. package/lib/modules/Payment/walletpass.js +7 -3
  32. package/lib/modules/SalesSummary/utils.js +256 -46
  33. package/lib/server/index.d.ts +3 -0
  34. package/lib/server/index.js +82 -3
  35. package/lib/server/modules/order/index.d.ts +8 -0
  36. package/lib/server/modules/order/index.js +106 -4
  37. package/lib/server/modules/order/types.d.ts +2 -0
  38. package/lib/solution/BaseSales/index.js +2 -1
  39. package/lib/solution/BaseSales/types.d.ts +1 -0
  40. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +15 -1
  41. package/lib/solution/BookingByStep/index.d.ts +1 -1
  42. package/lib/solution/ScanOrder/types.d.ts +1 -0
  43. package/lib/solution/ScanOrder/utils.js +28 -10
  44. package/lib/solution/VenueBooking/index.js +2 -1
  45. package/package.json +1 -1
@@ -194,6 +194,7 @@ export interface OrderSummary {
194
194
  shipping_tax_fee: string;
195
195
  tax_fee: string;
196
196
  surcharge_fee: string;
197
+ surcharges: any[];
197
198
  discount_amount: string;
198
199
  deposit_amount: string;
199
200
  deposit?: {
@@ -1,5 +1,5 @@
1
1
  import Decimal from 'decimal.js';
2
- import { CartItem } from "../Cart";
2
+ import type { CartItem } from "../Cart";
3
3
  import type { OrderProductDiscountItem, OrderSubmitPayload, OrderSubmitProduct, OrderSummary, OrderTempOrder } from './types';
4
4
  import type { RulesParamsHooks } from '../Rules/types';
5
5
  import type { MapOrderPaymentsOptions, OrderPaymentData, OrderPaymentSource } from './types';
@@ -21,10 +21,20 @@ export declare function composeLinePrice(params: {
21
21
  bundle?: Array<{
22
22
  bundle_selling_price?: any;
23
23
  price?: any;
24
+ custom_price?: any;
24
25
  num?: any;
25
26
  quantity?: any;
26
27
  original_price?: any;
27
28
  product_price?: any;
29
+ price_type?: any;
30
+ price_type_ext?: any;
31
+ custom_price_type?: any;
32
+ custom_price_type_ext?: any;
33
+ option?: Array<{
34
+ add_price?: any;
35
+ price?: any;
36
+ num?: any;
37
+ }>;
28
38
  }> | null;
29
39
  useOriginalBundle?: boolean;
30
40
  }): string;
@@ -43,6 +53,27 @@ export declare function sumOptionUnitPrice(options?: Array<{
43
53
  price?: any;
44
54
  num?: any;
45
55
  }> | null): Decimal;
56
+ /**
57
+ * 判定套餐子商品是否为 markdown(减价)类型。
58
+ * 与后端口径一致:price_type='markdown' 且 price_type_ext 非 'product_price'(原价子商品)。
59
+ */
60
+ export declare function isMarkdownBundle(bundle: Record<string, any> | null | undefined): boolean;
61
+ /**
62
+ * 套餐子商品对「行价」的带符号单位贡献(与后端 markdown 口径对齐)。
63
+ *
64
+ * - markdown(减价):净额 = |catalog 毛价| − Σ(option.add_price×num),**取负**(行内减)。
65
+ * catalog 毛价优先 `price`/`custom_price`(避免读已落净额的 `bundle_selling_price` 造成 option 二次扣减);
66
+ * 仅当毛价缺失(历史/hydrate 仅剩净额)时退回 `bundle_selling_price`,且此时不再扣 option。
67
+ * - markup(加价)/原价子商品:维持 `+(bundle_selling_price ?? price)`,行为不变。
68
+ */
69
+ export declare function getBundleSignedUnit(bundle: Record<string, any> | null | undefined, options?: {
70
+ useOriginal?: boolean;
71
+ }): Decimal;
72
+ /**
73
+ * 套餐子商品 `bundle_selling_price` 的存储净额(正值幅度)。
74
+ * markdown 取净额绝对值(3.70);markup/原价维持原值。
75
+ */
76
+ export declare function getBundleSellingMagnitude(bundle: Record<string, any> | null | undefined): Decimal;
46
77
  /**
47
78
  * OrderModule 默认 Rules 钩子工厂。
48
79
  *
@@ -55,7 +86,7 @@ export declare function sumOptionUnitPrice(options?: Array<{
55
86
  * 不含折扣。**权威源**。
56
87
  * - `metadata.main_product_original_price` = source + Σ(option.price × option.num)(含 option、不含折扣)。
57
88
  * - `metadata.main_product_selling_price` = main_original − 主商品券 per-unit amount(含 option、含折扣)。
58
- * - `payment_price`:出站 payload 中由 `selling_price` 派生以兼容后端(composite)。
89
+ * - `payment_price`:出站 payload 中为行 composite 已减整单折扣均摊价(无折扣时与 `selling_price` 同义)。
59
90
  *
60
91
  * Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
61
92
  * - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
@@ -43,13 +43,15 @@ export function composeLinePrice(params) {
43
43
  _step;
44
44
  try {
45
45
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
46
- var _ref, _item$original_price, _item$bundle_selling_, _ref2, _item$num;
46
+ var _ref, _item$num;
47
47
  var item = _step.value;
48
- var rawPrice = useOriginalBundle ? (_ref = (_item$original_price = item === null || item === void 0 ? void 0 : item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item === null || item === void 0 ? void 0 : item.product_price) !== null && _ref !== void 0 ? _ref : item === null || item === void 0 ? void 0 : item.price : (_item$bundle_selling_ = item === null || item === void 0 ? void 0 : item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item === null || item === void 0 ? void 0 : item.price;
49
- var price = new Decimal(Number(rawPrice) || 0);
50
- var rawNum = (_ref2 = (_item$num = item === null || item === void 0 ? void 0 : item.num) !== null && _item$num !== void 0 ? _item$num : item === null || item === void 0 ? void 0 : item.quantity) !== null && _ref2 !== void 0 ? _ref2 : 1;
48
+ // markdown(减价)按带符号净额取减;markup/原价维持相加。
49
+ var signedUnit = getBundleSignedUnit(item, {
50
+ useOriginal: useOriginalBundle
51
+ });
52
+ var rawNum = (_ref = (_item$num = item === null || item === void 0 ? void 0 : item.num) !== null && _item$num !== void 0 ? _item$num : item === null || item === void 0 ? void 0 : item.quantity) !== null && _ref !== void 0 ? _ref : 1;
51
53
  var num = new Decimal(Number(rawNum) || 0);
52
- total = total.plus(price.times(num));
54
+ total = total.plus(signedUnit.times(num));
53
55
  }
54
56
  } catch (err) {
55
57
  _iterator.e(err);
@@ -106,6 +108,55 @@ export function sumOptionUnitPrice(options) {
106
108
  return total;
107
109
  }
108
110
 
111
+ /**
112
+ * 判定套餐子商品是否为 markdown(减价)类型。
113
+ * 与后端口径一致:price_type='markdown' 且 price_type_ext 非 'product_price'(原价子商品)。
114
+ */
115
+ export function isMarkdownBundle(bundle) {
116
+ var _bundle$price_type_ex, _bundle$price_type;
117
+ if (!bundle || _typeof(bundle) !== 'object') return false;
118
+ var ext = (_bundle$price_type_ex = bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : bundle.custom_price_type_ext;
119
+ var type = (_bundle$price_type = bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : bundle.custom_price_type;
120
+ return type === 'markdown' && ext !== 'product_price';
121
+ }
122
+
123
+ /**
124
+ * 套餐子商品对「行价」的带符号单位贡献(与后端 markdown 口径对齐)。
125
+ *
126
+ * - markdown(减价):净额 = |catalog 毛价| − Σ(option.add_price×num),**取负**(行内减)。
127
+ * catalog 毛价优先 `price`/`custom_price`(避免读已落净额的 `bundle_selling_price` 造成 option 二次扣减);
128
+ * 仅当毛价缺失(历史/hydrate 仅剩净额)时退回 `bundle_selling_price`,且此时不再扣 option。
129
+ * - markup(加价)/原价子商品:维持 `+(bundle_selling_price ?? price)`,行为不变。
130
+ */
131
+ export function getBundleSignedUnit(bundle, options) {
132
+ var _options$useOriginal, _ref8, _bundle$original_pric2, _bundle$bundle_sellin;
133
+ if (!bundle || _typeof(bundle) !== 'object') return new Decimal(0);
134
+ var useOriginal = (_options$useOriginal = options === null || options === void 0 ? void 0 : options.useOriginal) !== null && _options$useOriginal !== void 0 ? _options$useOriginal : false;
135
+ if (isMarkdownBundle(bundle)) {
136
+ var _ref2, _ref3, _ref4, _bundle$original_pric, _ref5, _ref6, _ref7, _bundle$custom_price;
137
+ var catalog = useOriginal ? (_ref2 = (_ref3 = (_ref4 = (_bundle$original_pric = bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle.product_price) !== null && _ref4 !== void 0 ? _ref4 : bundle.custom_price) !== null && _ref3 !== void 0 ? _ref3 : bundle.base_price) !== null && _ref2 !== void 0 ? _ref2 : bundle.price : (_ref5 = (_ref6 = (_ref7 = (_bundle$custom_price = bundle.custom_price) !== null && _bundle$custom_price !== void 0 ? _bundle$custom_price : bundle.product_price) !== null && _ref7 !== void 0 ? _ref7 : bundle.original_price) !== null && _ref6 !== void 0 ? _ref6 : bundle.base_price) !== null && _ref5 !== void 0 ? _ref5 : bundle.price;
138
+ if (catalog !== undefined && catalog !== null && catalog !== '') {
139
+ var raw = new Decimal(Number(catalog) || 0);
140
+ // 负值表示价格已是「带符号净额」(如 cart/changePrice 产出的 -3.7),直接取用不再扣 option,
141
+ // 避免与下游 option 二次扣减;正值为毛价(H5 路径,如 5),净额 = price − Σoptions 后取负。
142
+ if (raw.lt(0)) return raw;
143
+ return raw.minus(sumOptionUnitPrice(bundle.option)).negated();
144
+ }
145
+ // 仅剩净额(无毛价)兜底:直接取负,不再扣 option
146
+ return new Decimal(Number(bundle.bundle_selling_price) || 0).abs().negated();
147
+ }
148
+ var rawPrice = useOriginal ? (_ref8 = (_bundle$original_pric2 = bundle.original_price) !== null && _bundle$original_pric2 !== void 0 ? _bundle$original_pric2 : bundle.product_price) !== null && _ref8 !== void 0 ? _ref8 : bundle.price : (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.price;
149
+ return new Decimal(Number(rawPrice) || 0);
150
+ }
151
+
152
+ /**
153
+ * 套餐子商品 `bundle_selling_price` 的存储净额(正值幅度)。
154
+ * markdown 取净额绝对值(3.70);markup/原价维持原值。
155
+ */
156
+ export function getBundleSellingMagnitude(bundle) {
157
+ return getBundleSignedUnit(bundle).abs();
158
+ }
159
+
109
160
  /**
110
161
  * OrderModule 默认 Rules 钩子工厂。
111
162
  *
@@ -118,7 +169,7 @@ export function sumOptionUnitPrice(options) {
118
169
  * 不含折扣。**权威源**。
119
170
  * - `metadata.main_product_original_price` = source + Σ(option.price × option.num)(含 option、不含折扣)。
120
171
  * - `metadata.main_product_selling_price` = main_original − 主商品券 per-unit amount(含 option、含折扣)。
121
- * - `payment_price`:出站 payload 中由 `selling_price` 派生以兼容后端(composite)。
172
+ * - `payment_price`:出站 payload 中为行 composite 已减整单折扣均摊价(无折扣时与 `selling_price` 同义)。
122
173
  *
123
174
  * Rules 钩子契约(hook_adapt 方案,Rules 内部保持不变):
124
175
  * - `getProduct.price` / `getProduct.original_price` 回传 **source-level 主价**
@@ -263,8 +314,8 @@ export function createDefaultOrderRulesHooks() {
263
314
  return new Decimal(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
264
315
  };
265
316
  var getBundleIdentity = function getBundleIdentity(bundle) {
266
- var _ref3, _bundle$bundle_id, _ref4, _ref5, _bundle$bundle_produc, _ref6, _ref7, _bundle$bundle_varian, _ref8, _bundle$bundle_group_;
267
- return [(_ref3 = (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id) !== null && _ref3 !== void 0 ? _ref3 : '', (_ref4 = (_ref5 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref5 !== void 0 ? _ref5 : bundle.product_id) !== null && _ref4 !== void 0 ? _ref4 : '', (_ref6 = (_ref7 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref7 !== void 0 ? _ref7 : bundle.product_variant_id) !== null && _ref6 !== void 0 ? _ref6 : 0, (_ref8 = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id) !== null && _ref8 !== void 0 ? _ref8 : ''].join('|');
317
+ var _ref9, _bundle$bundle_id, _ref10, _ref11, _bundle$bundle_produc, _ref12, _ref13, _bundle$bundle_varian, _ref14, _bundle$bundle_group_;
318
+ return [(_ref9 = (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id) !== null && _ref9 !== void 0 ? _ref9 : '', (_ref10 = (_ref11 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref11 !== void 0 ? _ref11 : bundle.product_id) !== null && _ref10 !== void 0 ? _ref10 : '', (_ref12 = (_ref13 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref13 !== void 0 ? _ref13 : bundle.product_variant_id) !== null && _ref12 !== void 0 ? _ref12 : 0, (_ref14 = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id) !== null && _ref14 !== void 0 ? _ref14 : ''].join('|');
268
319
  };
269
320
  var mergeRulesBundlePrices = function mergeRulesBundlePrices(currentBundle, rulesBundle) {
270
321
  if (!Array.isArray(rulesBundle)) return rulesBundle;
@@ -274,14 +325,14 @@ export function createDefaultOrderRulesHooks() {
274
325
  currentByIdentity.set(getBundleIdentity(bundle), bundle);
275
326
  });
276
327
  return rulesBundle.map(function (bundle) {
277
- var _bundle$price_type_ex, _ref9, _ref10, _current$price, _ref11, _ref12, _ref13, _current$original_pri;
328
+ var _bundle$price_type_ex2, _ref15, _ref16, _current$price, _ref17, _ref18, _ref19, _current$original_pri;
278
329
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
279
330
  var current = currentByIdentity.get(getBundleIdentity(bundle));
280
331
  if (!current) return bundle;
281
- var isProductPriceBundle = ((_bundle$price_type_ex = bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : current.price_type_ext) === 'product_price';
332
+ var isProductPriceBundle = ((_bundle$price_type_ex2 = bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : current.price_type_ext) === 'product_price';
282
333
  if (!isProductPriceBundle) return bundle;
283
- var sourcePrice = (_ref9 = (_ref10 = (_current$price = current.price) !== null && _current$price !== void 0 ? _current$price : current.custom_price) !== null && _ref10 !== void 0 ? _ref10 : current.original_price) !== null && _ref9 !== void 0 ? _ref9 : current.bundle_selling_price;
284
- var originalPrice = (_ref11 = (_ref12 = (_ref13 = (_current$original_pri = current.original_price) !== null && _current$original_pri !== void 0 ? _current$original_pri : current.product_price) !== null && _ref13 !== void 0 ? _ref13 : current.price) !== null && _ref12 !== void 0 ? _ref12 : current.custom_price) !== null && _ref11 !== void 0 ? _ref11 : sourcePrice;
334
+ var sourcePrice = (_ref15 = (_ref16 = (_current$price = current.price) !== null && _current$price !== void 0 ? _current$price : current.custom_price) !== null && _ref16 !== void 0 ? _ref16 : current.original_price) !== null && _ref15 !== void 0 ? _ref15 : current.bundle_selling_price;
335
+ var originalPrice = (_ref17 = (_ref18 = (_ref19 = (_current$original_pri = current.original_price) !== null && _current$original_pri !== void 0 ? _current$original_pri : current.product_price) !== null && _ref19 !== void 0 ? _ref19 : current.price) !== null && _ref18 !== void 0 ? _ref18 : current.custom_price) !== null && _ref17 !== void 0 ? _ref17 : sourcePrice;
285
336
  return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, bundle), sourcePrice !== undefined ? {
286
337
  price: sourcePrice
287
338
  } : {}), originalPrice !== undefined ? {
@@ -345,10 +396,10 @@ export function createDefaultOrderRulesHooks() {
345
396
  };
346
397
  },
347
398
  setProduct: function setProduct(product, values) {
348
- var _ref14, _values$quantity, _ref15, _metadataAny$source_p, _values$discount_list, _values$quantity2;
349
- var nextNum = Number((_ref14 = (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num) !== null && _ref14 !== void 0 ? _ref14 : 1) || 1;
399
+ var _ref20, _values$quantity, _ref21, _metadataAny$source_p, _values$discount_list, _values$quantity2;
400
+ var nextNum = Number((_ref20 = (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num) !== null && _ref20 !== void 0 ? _ref20 : 1) || 1;
350
401
  var metadataAny = product.metadata || {};
351
- var existedSource = (_ref15 = (_metadataAny$source_p = metadataAny.source_product_price) !== null && _metadataAny$source_p !== void 0 ? _metadataAny$source_p : product.selling_price) !== null && _ref15 !== void 0 ? _ref15 : '0';
402
+ var existedSource = (_ref21 = (_metadataAny$source_p = metadataAny.source_product_price) !== null && _metadataAny$source_p !== void 0 ? _metadataAny$source_p : product.selling_price) !== null && _ref21 !== void 0 ? _ref21 : '0';
352
403
  var nextOptions = getProductSkuOptions(product);
353
404
  var optionSum = sumOptionUnitPrice(nextOptions);
354
405
 
@@ -521,11 +572,16 @@ function toMoneyString(value) {
521
572
  function formatSubmitBundleItems(bundle) {
522
573
  if (!Array.isArray(bundle)) return [];
523
574
  return bundle.map(function (b) {
524
- var _rawBundle$bundle_sel, _ref16, _rawBundle$price, _rawBundle$surcharge_, _rawBundle$num, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$quantity, _rawBundle$extension_, _rawBundle$extension_2, _ref17, _rawBundle$price_type, _ref18, _rawBundle$price_type2, _rawBundle$bundle_gro, _rawBundle$bundle_id, _rawBundle$bundle_pro;
575
+ var _ref22, _rawBundle$price, _rawBundle$surcharge_, _rawBundle$num, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$quantity, _rawBundle$extension_, _rawBundle$extension_2, _ref23, _rawBundle$price_type, _ref24, _rawBundle$price_type2, _rawBundle$bundle_gro, _rawBundle$bundle_id, _rawBundle$bundle_pro;
525
576
  var rawBundle = b && _typeof(b) === 'object' ? b : {};
526
577
  var existedMetadata = rawBundle.metadata && _typeof(rawBundle.metadata) === 'object' ? rawBundle.metadata : {};
527
- var sellingPrice = toMoneyString((_rawBundle$bundle_sel = rawBundle.bundle_selling_price) !== null && _rawBundle$bundle_sel !== void 0 ? _rawBundle$bundle_sel : rawBundle.price);
528
- var priceValue = (_ref16 = (_rawBundle$price = rawBundle.price) !== null && _rawBundle$price !== void 0 ? _rawBundle$price : rawBundle.custom_price) !== null && _ref16 !== void 0 ? _ref16 : rawBundle.bundle_selling_price;
578
+
579
+ // bundle_selling_price 出站存「正净额」:markdown |price| Σoptions(如 3.70),
580
+ // markup/原价维持原值;与后端口径一致(price 仍为毛价)。
581
+ var sellingPrice = getBundleSellingMagnitude(rawBundle).toFixed(2);
582
+ // payment 价由整单折扣均摊层产出;缺省(无折扣)时与 selling 净额同义。
583
+ var paymentPrice = rawBundle.bundle_payment_price !== undefined && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== '' ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
584
+ var priceValue = (_ref22 = (_rawBundle$price = rawBundle.price) !== null && _rawBundle$price !== void 0 ? _rawBundle$price : rawBundle.custom_price) !== null && _ref22 !== void 0 ? _ref22 : rawBundle.bundle_selling_price;
529
585
  var relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
530
586
  var surchargeFee = toMoneyString((_rawBundle$surcharge_ = rawBundle.surcharge_fee) !== null && _rawBundle$surcharge_ !== void 0 ? _rawBundle$surcharge_ : existedMetadata.surcharge_fee);
531
587
  var productDiscountDifference = toBundleNumber(existedMetadata.product_discount_difference, 0);
@@ -538,9 +594,10 @@ function formatSubmitBundleItems(bundle) {
538
594
  extension_id: (_rawBundle$extension_ = rawBundle.extension_id) !== null && _rawBundle$extension_ !== void 0 ? _rawBundle$extension_ : 0,
539
595
  extension_type: (_rawBundle$extension_2 = rawBundle.extension_type) !== null && _rawBundle$extension_2 !== void 0 ? _rawBundle$extension_2 : 'normal',
540
596
  price: priceValue,
541
- price_type: (_ref17 = (_rawBundle$price_type = rawBundle.price_type) !== null && _rawBundle$price_type !== void 0 ? _rawBundle$price_type : rawBundle.custom_price_type) !== null && _ref17 !== void 0 ? _ref17 : '',
542
- price_type_ext: (_ref18 = (_rawBundle$price_type2 = rawBundle.price_type_ext) !== null && _rawBundle$price_type2 !== void 0 ? _rawBundle$price_type2 : rawBundle.custom_price_type_ext) !== null && _ref18 !== void 0 ? _ref18 : '',
597
+ price_type: (_ref23 = (_rawBundle$price_type = rawBundle.price_type) !== null && _rawBundle$price_type !== void 0 ? _rawBundle$price_type : rawBundle.custom_price_type) !== null && _ref23 !== void 0 ? _ref23 : '',
598
+ price_type_ext: (_ref24 = (_rawBundle$price_type2 = rawBundle.price_type_ext) !== null && _rawBundle$price_type2 !== void 0 ? _rawBundle$price_type2 : rawBundle.custom_price_type_ext) !== null && _ref24 !== void 0 ? _ref24 : '',
543
599
  bundle_selling_price: sellingPrice,
600
+ bundle_payment_price: paymentPrice,
544
601
  option: formatSubmitOptionItems(rawBundle.option),
545
602
  bundle_group_id: (_rawBundle$bundle_gro = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_group_id) !== null && _rawBundle$bundle_gro !== void 0 ? _rawBundle$bundle_gro : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.group_id,
546
603
  bundle_id: (_rawBundle$bundle_id = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_id) !== null && _rawBundle$bundle_id !== void 0 ? _rawBundle$bundle_id : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.id,
@@ -562,7 +619,7 @@ function formatSubmitBundleItems(bundle) {
562
619
  * = `metadata.main_product_selling_price` + Σ(bundle_selling_price × num)。
563
620
  * - `original_price`:**行 composite 券前单价**
564
621
  * = `metadata.main_product_original_price` + Σ(bundle 原价 × num)。
565
- * - `payment_price`:兼容后端的出站字段,直接从 `selling_price` 派生(composite)。
622
+ * - `payment_price`:兼容后端的出站字段,行 composite 已减整单折扣均摊(无折扣时与 `selling_price` 同义)。
566
623
  * - `metadata.source_product_price`:主商品/variant 基础价(不含 option、不含折扣),权威源。
567
624
  * - `metadata.main_product_original_price`:含 option、不含折扣。
568
625
  * - `metadata.main_product_selling_price`:含 option、含主商品折扣。
@@ -571,10 +628,10 @@ function formatSubmitBundleItems(bundle) {
571
628
  * 本函数不再改造价格字段形状,仅做字段/metadata 裁剪。
572
629
  */
573
630
  function normalizeSubmitProduct(product) {
574
- var _rawMetadata$product_, _submitProduct$produc;
575
- var _ref19 = product,
576
- _runtimeUid = _ref19.unique_identification_number,
577
- submitProduct = _objectWithoutProperties(_ref19, _excluded);
631
+ var _rawMetadata$product_, _submitProduct$produc, _submitProduct$paymen;
632
+ var _ref25 = product,
633
+ _runtimeUid = _ref25.unique_identification_number,
634
+ submitProduct = _objectWithoutProperties(_ref25, _excluded);
578
635
  var num = submitProduct.num,
579
636
  _productSurchargeFee = submitProduct.surcharge_fee,
580
637
  _deprecatedDiscountAmount = submitProduct.discount_amount,
@@ -590,7 +647,7 @@ function normalizeSubmitProduct(product) {
590
647
  if (rawMetadata.unique_identification_number) {
591
648
  cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
592
649
  }
593
- var priceMetaKeys = ['main_product_original_price', 'main_product_selling_price', 'source_product_price', 'main_product_attached_bundle_surcharge_fee', 'main_product_attached_bundle_tax_fee', 'surcharge_rounding_remainder', 'tax_fee_rounding_remainder', 'relation_surcharge_ids', 'discountable_flag', 'parent_unique_identification_number', 'product_add_schedule_time'];
650
+ var priceMetaKeys = ['main_product_original_price', 'main_product_selling_price', 'main_product_attached_bundle_selling_price', 'main_product_attached_bundle_payment_price', 'average_discount_amount_rate', 'source_product_price', 'main_product_attached_bundle_surcharge_fee', 'main_product_attached_bundle_tax_fee', 'surcharge_rounding_remainder', 'tax_fee_rounding_remainder', 'relation_surcharge_ids', 'discountable_flag', 'parent_unique_identification_number', 'product_add_schedule_time'];
594
651
  for (var _i = 0, _priceMetaKeys = priceMetaKeys; _i < _priceMetaKeys.length; _i++) {
595
652
  var key = _priceMetaKeys[_i];
596
653
  if (rawMetadata[key] !== undefined) {
@@ -615,9 +672,9 @@ function normalizeSubmitProduct(product) {
615
672
  discount_list: normalizeOrderProductDiscountList(submitProduct.discount_list),
616
673
  product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
617
674
  metadata: cleanMetadata,
618
- // 出站兼容:后端消费 payment_price 字段,这里从 selling_price 直接派生。
619
- // 新语义下 selling_price 是 composite(含 option/bundle),payment_price 同语义。
620
- payment_price: submitProduct.selling_price
675
+ // 出站兼容:后端消费 payment_price 字段(行 composite 已减整单折扣均摊)。
676
+ // 由整单折扣均摊层产出;缺省(无折扣)时与 selling_price 同义。
677
+ payment_price: (_submitProduct$paymen = submitProduct.payment_price) !== null && _submitProduct$paymen !== void 0 ? _submitProduct$paymen : submitProduct.selling_price
621
678
  });
622
679
  }
623
680
  var SUBMIT_BOOKING_METADATA_WHITELIST = ['unique_identification_number', 'collect_pax', 'capacity', 'holder_id', 'resource_select_type'];
@@ -738,7 +795,7 @@ export function createDefaultTempOrder(params) {
738
795
  };
739
796
  }
740
797
  export function buildSubmitPayload(params) {
741
- var _tempOrder$customer_i, _ref21, _tempOrder$is_price_i, _tempOrder$is_deposit;
798
+ var _tempOrder$customer_i, _ref27, _tempOrder$is_price_i, _tempOrder$is_deposit;
742
799
  var tempOrder = params.tempOrder,
743
800
  cacheId = params.cacheId,
744
801
  _params$now = params.now,
@@ -750,26 +807,26 @@ export function buildSubmitPayload(params) {
750
807
  enhance = params.enhance;
751
808
  var scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
752
809
  var bookingUuid = createUuidV4();
753
- var _ref20 = tempOrder,
754
- _extend = _ref20._extend,
755
- _relationId = _ref20.relation_id,
756
- _tableFormId = _ref20.table_form_id,
757
- _resourceId = _ref20.resource_id,
758
- _summary = _ref20.summary,
759
- _lastOrderInfo = _ref20.lastOrderInfo,
760
- _paidAmount = _ref20.paid_amount,
761
- _shopId = _ref20.shop_id,
762
- _shopNote = _ref20.shop_note,
763
- _shopServiceType = _ref20.shop_service_type,
764
- _startTime = _ref20.start_time,
765
- _customer = _ref20.customer,
766
- _discountList = _ref20.discount_list,
767
- _rootTaxFee = _ref20.tax_fee,
768
- _totalAmount = _ref20.total_amount,
769
- _totalRefundAmount = _ref20.total_refund_amount,
770
- _createDate = _ref20.create_date,
771
- _holderId = _ref20.holder_id,
772
- tempOrderRest = _objectWithoutProperties(_ref20, _excluded3);
810
+ var _ref26 = tempOrder,
811
+ _extend = _ref26._extend,
812
+ _relationId = _ref26.relation_id,
813
+ _tableFormId = _ref26.table_form_id,
814
+ _resourceId = _ref26.resource_id,
815
+ _summary = _ref26.summary,
816
+ _lastOrderInfo = _ref26.lastOrderInfo,
817
+ _paidAmount = _ref26.paid_amount,
818
+ _shopId = _ref26.shop_id,
819
+ _shopNote = _ref26.shop_note,
820
+ _shopServiceType = _ref26.shop_service_type,
821
+ _startTime = _ref26.start_time,
822
+ _customer = _ref26.customer,
823
+ _discountList = _ref26.discount_list,
824
+ _rootTaxFee = _ref26.tax_fee,
825
+ _totalAmount = _ref26.total_amount,
826
+ _totalRefundAmount = _ref26.total_refund_amount,
827
+ _createDate = _ref26.create_date,
828
+ _holderId = _ref26.holder_id,
829
+ tempOrderRest = _objectWithoutProperties(_ref26, _excluded3);
773
830
  var submitType = type !== null && type !== void 0 ? type : tempOrder.type;
774
831
  if (!submitType) {
775
832
  var _tempOrder$bookings;
@@ -791,7 +848,7 @@ export function buildSubmitPayload(params) {
791
848
  type: submitType,
792
849
  business_code: businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code,
793
850
  sales_channel: tempOrder.sales_channel || 'my_pisel',
794
- order_sales_channel: (_ref21 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref21 !== void 0 ? _ref21 : 'online_store',
851
+ order_sales_channel: (_ref27 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref27 !== void 0 ? _ref27 : 'online_store',
795
852
  status: tempOrder.status || 'normal',
796
853
  payment_status: tempOrder.payment_status || 'payment_processing',
797
854
  // shipping_status: tempOrder.shipping_status || 'unfulfilled',
@@ -817,10 +874,10 @@ export function buildSubmitPayload(params) {
817
874
  // holder: tempOrder.holder || null,
818
875
  // summary,
819
876
  metadata: function () {
820
- var _ref22 = tempOrder.metadata || {},
821
- _collectPax = _ref22.collect_pax,
822
- _tableOccupancyDuration = _ref22.table_occupancy_duration,
823
- rest = _objectWithoutProperties(_ref22, _excluded4);
877
+ var _ref28 = tempOrder.metadata || {},
878
+ _collectPax = _ref28.collect_pax,
879
+ _tableOccupancyDuration = _ref28.table_occupancy_duration,
880
+ rest = _objectWithoutProperties(_ref28, _excluded4);
824
881
  return _objectSpread({}, rest);
825
882
  }(),
826
883
  products: (tempOrder.products || []).map(function (product) {
@@ -416,12 +416,19 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
416
416
  key: "getUserIdentificationCodeListAsync",
417
417
  value: function () {
418
418
  var _getUserIdentificationCodeListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
419
- var _newParams$prepare_pa, _this$walletParams2, newParams, response, sortedData;
419
+ var _newParams$products, _newParams$prepare_pa, _this$walletParams2, newParams, response, sortedData;
420
420
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
421
421
  while (1) switch (_context5.prev = _context5.next) {
422
422
  case 0:
423
423
  _context5.prev = 0;
424
424
  newParams = _objectSpread(_objectSpread({}, this.walletParams), params);
425
+ if ((_newParams$products = newParams.products) !== null && _newParams$products !== void 0 && _newParams$products.length) {
426
+ _context5.next = 5;
427
+ break;
428
+ }
429
+ this.paymentModule.logInfo('[WalletPass] 商品列表为空,跳过获取用户识别码列表');
430
+ return _context5.abrupt("return", []);
431
+ case 5:
425
432
  this.paymentModule.logInfo('[WalletPass] 开始获取用户识别码列表', {
426
433
  customer_id: newParams.customer_id,
427
434
  available: newParams.available,
@@ -429,9 +436,9 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
429
436
  filter_prepare_wallet_pass: newParams.filter_prepare_wallet_pass,
430
437
  payment_order_id: (_this$walletParams2 = this.walletParams) === null || _this$walletParams2 === void 0 ? void 0 : _this$walletParams2.payment_order_id
431
438
  });
432
- _context5.next = 5;
439
+ _context5.next = 8;
433
440
  return this.paymentModule.request.post('/machinecode/prepare/deduction', newParams);
434
- case 5:
441
+ case 8:
435
442
  response = _context5.sent;
436
443
  // 对获取到的数据进行排序,将错误码为 500100、500200、500300 的项目排到最后
437
444
  sortedData = sortUserIdentificationCodeList((response === null || response === void 0 ? void 0 : response.data) || []);
@@ -452,19 +459,19 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
452
459
  })
453
460
  });
454
461
  return _context5.abrupt("return", this.userIdentificationCodes);
455
- case 13:
456
- _context5.prev = 13;
462
+ case 16:
463
+ _context5.prev = 16;
457
464
  _context5.t0 = _context5["catch"](0);
458
465
  this.paymentModule.logError('[WalletPass] 获取用户识别码列表失败', _context5.t0, {
459
466
  customer_id: params.customer_id,
460
467
  available: params.available
461
468
  });
462
469
  return _context5.abrupt("return", []);
463
- case 17:
470
+ case 20:
464
471
  case "end":
465
472
  return _context5.stop();
466
473
  }
467
- }, _callee5, this, [[0, 13]]);
474
+ }, _callee5, this, [[0, 16]]);
468
475
  }));
469
476
  function getUserIdentificationCodeListAsync(_x5) {
470
477
  return _getUserIdentificationCodeListAsync.apply(this, arguments);