@pisell/pisellos 2.2.257 → 2.2.259

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 (59) hide show
  1. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +17 -13
  2. package/dist/modules/Order/index.d.ts +32 -1
  3. package/dist/modules/Order/index.js +615 -288
  4. package/dist/modules/Order/types.d.ts +20 -2
  5. package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  6. package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
  7. package/dist/modules/Order/utils.d.ts +4 -0
  8. package/dist/modules/Order/utils.js +114 -28
  9. package/dist/modules/Rules/index.d.ts +3 -3
  10. package/dist/modules/Rules/index.js +8 -3
  11. package/dist/modules/Rules/types.d.ts +2 -1
  12. package/dist/modules/SalesSummary/index.d.ts +7 -3
  13. package/dist/modules/SalesSummary/index.js +67 -39
  14. package/dist/modules/SalesSummary/types.d.ts +1 -0
  15. package/dist/modules/SalesSummary/utils.js +2 -1
  16. package/dist/modules/SurchargeList/index.d.ts +6 -4
  17. package/dist/modules/SurchargeList/index.js +62 -39
  18. package/dist/modules/SurchargeList/types.d.ts +6 -2
  19. package/dist/server/index.d.ts +3 -0
  20. package/dist/server/index.js +1136 -855
  21. package/dist/server/modules/order/index.d.ts +22 -3
  22. package/dist/server/modules/order/index.js +398 -316
  23. package/dist/solution/BaseSales/index.d.ts +22 -2
  24. package/dist/solution/BaseSales/index.js +995 -701
  25. package/dist/solution/BaseSales/types.d.ts +1 -0
  26. package/dist/solution/BaseSales/types.js +2 -1
  27. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -1
  28. package/dist/solution/BookingTicket/index.d.ts +8 -0
  29. package/dist/solution/BookingTicket/index.js +153 -6
  30. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +11 -1
  31. package/lib/modules/Order/index.d.ts +32 -1
  32. package/lib/modules/Order/index.js +402 -64
  33. package/lib/modules/Order/types.d.ts +20 -2
  34. package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  35. package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
  36. package/lib/modules/Order/utils.d.ts +4 -0
  37. package/lib/modules/Order/utils.js +84 -2
  38. package/lib/modules/Rules/index.d.ts +3 -3
  39. package/lib/modules/Rules/index.js +4 -3
  40. package/lib/modules/Rules/types.d.ts +2 -1
  41. package/lib/modules/SalesSummary/index.d.ts +7 -3
  42. package/lib/modules/SalesSummary/index.js +28 -11
  43. package/lib/modules/SalesSummary/types.d.ts +1 -0
  44. package/lib/modules/SalesSummary/utils.js +2 -0
  45. package/lib/modules/SurchargeList/index.d.ts +6 -4
  46. package/lib/modules/SurchargeList/index.js +41 -21
  47. package/lib/modules/SurchargeList/types.d.ts +6 -2
  48. package/lib/server/index.d.ts +3 -0
  49. package/lib/server/index.js +215 -9
  50. package/lib/server/modules/order/index.d.ts +22 -3
  51. package/lib/server/modules/order/index.js +103 -53
  52. package/lib/solution/BaseSales/index.d.ts +22 -2
  53. package/lib/solution/BaseSales/index.js +246 -60
  54. package/lib/solution/BaseSales/types.d.ts +1 -0
  55. package/lib/solution/BaseSales/types.js +2 -1
  56. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -1
  57. package/lib/solution/BookingTicket/index.d.ts +8 -0
  58. package/lib/solution/BookingTicket/index.js +101 -0
  59. package/package.json +1 -1
@@ -491,7 +491,7 @@ export interface OrderPaymentData {
491
491
  voucher_id?: string | number;
492
492
  origin_amount?: string;
493
493
  service_fee?: string;
494
- status?: 'active' | 'voided' | string;
494
+ status?: 'active' | 'paid' | 'voided' | 'payment_pending' | string;
495
495
  /** 支付时间 (格式: YYYY-MM-DD HH:mm:ss) */
496
496
  payment_time?: string;
497
497
  wallet_pass_usage_unit?: unknown;
@@ -537,9 +537,15 @@ export interface SyncPaymentsToOrderParams {
537
537
  smallTicketDataFlag?: number;
538
538
  businessCode?: string;
539
539
  channel?: string;
540
+ confirmPendingVoucherPayments?: boolean;
540
541
  }
541
542
  export interface SyncPaymentsToOrderResult<T = any> {
542
543
  isFullyPaid: boolean;
544
+ isOrderFullyPaid: boolean;
545
+ isDepositFullyPaid: boolean;
546
+ paymentStage: 'deposit' | 'normal';
547
+ depositAmount: string;
548
+ orderExpectedAmount: string;
543
549
  submitResult?: T;
544
550
  }
545
551
  export interface OrderIdentitySnapshot {
@@ -691,6 +697,7 @@ export interface OrderModuleAPI {
691
697
  payments?: OrderPaymentSource[];
692
698
  paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
693
699
  smallTicketDataFlag?: number;
700
+ confirmPendingVoucherPayments?: boolean;
694
701
  enhancePayload?: SubmitPayloadEnhancer;
695
702
  }) => Promise<T>;
696
703
  submitTempOrderAsync: <T = any>(params?: {
@@ -702,6 +709,7 @@ export interface OrderModuleAPI {
702
709
  payments?: OrderPaymentSource[];
703
710
  paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
704
711
  smallTicketDataFlag?: number;
712
+ confirmPendingVoucherPayments?: boolean;
705
713
  enhancePayload?: SubmitPayloadEnhancer;
706
714
  }) => Promise<T>;
707
715
  getOrderPayments: () => OrderPaymentData[];
@@ -709,7 +717,17 @@ export interface OrderModuleAPI {
709
717
  addOrderPayment: (payment: OrderPaymentSource) => OrderPaymentData[];
710
718
  updateOrderPayment: (paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>) => OrderPaymentData[];
711
719
  deleteOrderPayment: (paymentIdentity: string | number) => OrderPaymentData[];
712
- updateVoucherOrderPayments: (payments: OrderPaymentSource[]) => OrderPaymentData[];
720
+ updateVoucherOrderPayments: (payments: OrderPaymentSource[], options?: {
721
+ status?: 'paid' | 'payment_pending';
722
+ }) => OrderPaymentData[];
723
+ confirmPendingVoucherPayments: (options?: {
724
+ persist?: boolean;
725
+ recalculateSummary?: boolean;
726
+ }) => OrderPaymentData[];
727
+ discardPendingVoucherPayments: (options?: {
728
+ persist?: boolean;
729
+ recalculateSummary?: boolean;
730
+ }) => OrderPaymentData[];
713
731
  sendCustomerPayLink: <T = any>(params: SendCustomerPayLinkParams) => Promise<T>;
714
732
  saveDraft: () => Promise<void>;
715
733
  hydrateTempOrderFromRecord: (record: Record<string, any>, options?: {
@@ -0,0 +1,5 @@
1
+ import type { OrderProductDiscountItem } from '../types';
2
+ type NormalizeDiscountList = (discountList?: unknown[] | null) => OrderProductDiscountItem[];
3
+ export declare function restoreHydratedBundleDiscounts<T extends Record<string, any>>(product: T, normalizeDiscountList: NormalizeDiscountList): T;
4
+ export declare function expandHydratedProductsForDiscountCollection(products: any[] | undefined | null): any[];
5
+ export {};
@@ -0,0 +1,139 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/modules/Order/utils/bundleDiscountHydration.ts
20
+ var bundleDiscountHydration_exports = {};
21
+ __export(bundleDiscountHydration_exports, {
22
+ expandHydratedProductsForDiscountCollection: () => expandHydratedProductsForDiscountCollection,
23
+ restoreHydratedBundleDiscounts: () => restoreHydratedBundleDiscounts
24
+ });
25
+ module.exports = __toCommonJS(bundleDiscountHydration_exports);
26
+ var BUNDLE_MAP_ID_KEY = "custom_product_bundle_map_id";
27
+ function getBundleMapId(bundle) {
28
+ var _a;
29
+ const metadataMapId = (_a = bundle == null ? void 0 : bundle.metadata) == null ? void 0 : _a[BUNDLE_MAP_ID_KEY];
30
+ if (metadataMapId !== void 0 && metadataMapId !== null && metadataMapId !== "") {
31
+ return String(metadataMapId);
32
+ }
33
+ if ((bundle == null ? void 0 : bundle._id) !== void 0 && bundle._id !== null && bundle._id !== "") {
34
+ return String(bundle._id);
35
+ }
36
+ return null;
37
+ }
38
+ function getDiscountBundleMapId(discount) {
39
+ var _a;
40
+ const mapId = (_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a[BUNDLE_MAP_ID_KEY];
41
+ if (mapId === void 0 || mapId === null || mapId === "")
42
+ return null;
43
+ return String(mapId);
44
+ }
45
+ function hasSameBundleDiscount(discountList, discount) {
46
+ var _a;
47
+ const targetOrderDiscountId = discount.order_discount_id;
48
+ if (targetOrderDiscountId !== void 0 && targetOrderDiscountId !== null) {
49
+ return discountList.some((item) => (item == null ? void 0 : item.order_discount_id) === targetOrderDiscountId);
50
+ }
51
+ const targetResourceId = ((_a = discount == null ? void 0 : discount.discount) == null ? void 0 : _a.resource_id) ?? (discount == null ? void 0 : discount.resource_id) ?? (discount == null ? void 0 : discount.discount_id);
52
+ const targetMapId = getDiscountBundleMapId(discount);
53
+ return discountList.some((item) => {
54
+ var _a2;
55
+ const resourceId = ((_a2 = item == null ? void 0 : item.discount) == null ? void 0 : _a2.resource_id) ?? (item == null ? void 0 : item.resource_id) ?? (item == null ? void 0 : item.discount_id);
56
+ return resourceId === targetResourceId && String((item == null ? void 0 : item.amount) ?? "") === String((discount == null ? void 0 : discount.amount) ?? "") && getDiscountBundleMapId(item) === targetMapId;
57
+ });
58
+ }
59
+ function restoreHydratedBundleDiscounts(product, normalizeDiscountList) {
60
+ if (!Array.isArray(product.product_bundle) || !Array.isArray(product.discount_list)) {
61
+ return product;
62
+ }
63
+ const bundleByMapId = /* @__PURE__ */ new Map();
64
+ product.product_bundle.forEach((bundle) => {
65
+ if (!bundle || typeof bundle !== "object")
66
+ return;
67
+ const mapId = getBundleMapId(bundle);
68
+ if (mapId)
69
+ bundleByMapId.set(mapId, bundle);
70
+ });
71
+ if (!bundleByMapId.size)
72
+ return product;
73
+ const mainDiscountList = [];
74
+ const bundleDiscounts = [];
75
+ product.discount_list.forEach((discount) => {
76
+ const mapId = getDiscountBundleMapId(discount);
77
+ if (mapId && bundleByMapId.has(mapId)) {
78
+ bundleDiscounts.push({ mapId, discount });
79
+ } else {
80
+ mainDiscountList.push(discount);
81
+ }
82
+ });
83
+ if (!bundleDiscounts.length)
84
+ return product;
85
+ return {
86
+ ...product,
87
+ discount_list: normalizeDiscountList(mainDiscountList),
88
+ product_bundle: product.product_bundle.map((bundle) => {
89
+ if (!bundle || typeof bundle !== "object")
90
+ return bundle;
91
+ const mapId = getBundleMapId(bundle);
92
+ if (!mapId)
93
+ return bundle;
94
+ const matchedDiscounts = bundleDiscounts.filter((item) => item.mapId === mapId).map((item) => item.discount);
95
+ if (!matchedDiscounts.length)
96
+ return bundle;
97
+ const currentDiscountList = Array.isArray(bundle.discount_list) ? [...bundle.discount_list] : [];
98
+ for (const discount of matchedDiscounts) {
99
+ if (!hasSameBundleDiscount(currentDiscountList, discount)) {
100
+ currentDiscountList.push(discount);
101
+ }
102
+ }
103
+ return {
104
+ ...bundle,
105
+ discount_list: normalizeDiscountList(currentDiscountList),
106
+ metadata: {
107
+ ...bundle.metadata || {},
108
+ [BUNDLE_MAP_ID_KEY]: mapId
109
+ }
110
+ };
111
+ })
112
+ };
113
+ }
114
+ function expandHydratedProductsForDiscountCollection(products) {
115
+ const expanded = [];
116
+ for (const product of products || []) {
117
+ expanded.push(product);
118
+ for (const bundle of (product == null ? void 0 : product.product_bundle) || []) {
119
+ if (!Array.isArray(bundle == null ? void 0 : bundle.discount_list) || bundle.discount_list.length === 0)
120
+ continue;
121
+ expanded.push({
122
+ ...product,
123
+ product_id: bundle.bundle_product_id ?? bundle._bundle_product_id ?? bundle.product_id ?? (product == null ? void 0 : product.product_id),
124
+ num: bundle.num ?? bundle.quantity ?? (product == null ? void 0 : product.num),
125
+ product_quantity: bundle.quantity ?? bundle.num ?? (product == null ? void 0 : product.product_quantity),
126
+ original_price: bundle.original_price ?? bundle.product_price ?? bundle.price,
127
+ selling_price: bundle.bundle_selling_price ?? bundle.price,
128
+ is_charge_tax: bundle.is_charge_tax ?? (product == null ? void 0 : product.is_charge_tax),
129
+ discount_list: bundle.discount_list
130
+ });
131
+ }
132
+ }
133
+ return expanded;
134
+ }
135
+ // Annotate the CommonJS export names for ESM import in node:
136
+ 0 && (module.exports = {
137
+ expandHydratedProductsForDiscountCollection,
138
+ restoreHydratedBundleDiscounts
139
+ });
@@ -254,6 +254,10 @@ export declare function clearTempOrderHolderAssignments(tempOrder: OrderTempOrde
254
254
  * getOrderProductLineUid({ metadata: { unique_identification_number: 'line-1' } }); // 'line-1'
255
255
  */
256
256
  export declare function getOrderProductLineUid(product: Record<string, any> | null | undefined): string | null;
257
+ export declare function getRuntimeProductOrigin(tempOrder: OrderTempOrder | null | undefined, product: any): Record<string, any> | null;
258
+ export declare function isHolderConfigRequired(holderConfig: any): boolean;
259
+ export declare function productRequiresFormSubject(tempOrder: OrderTempOrder | null | undefined, product: any): boolean;
260
+ export declare function resolveIsFormSubject(tempOrder: OrderTempOrder | null | undefined, product?: any): boolean;
257
261
  /**
258
262
  * 判断展示字段是否为空(含 i18n 对象全空)。
259
263
  *
@@ -49,9 +49,11 @@ __export(utils_exports, {
49
49
  getBundleSignedUnit: () => getBundleSignedUnit,
50
50
  getOrderProductLineUid: () => getOrderProductLineUid,
51
51
  getProductSkuOptions: () => getProductSkuOptions,
52
+ getRuntimeProductOrigin: () => getRuntimeProductOrigin,
52
53
  hasAssignedHolderId: () => hasAssignedHolderId,
53
54
  indexOrderProductsByUid: () => indexOrderProductsByUid,
54
55
  isEmptyOrderProductDisplayValue: () => isEmptyOrderProductDisplayValue,
56
+ isHolderConfigRequired: () => isHolderConfigRequired,
55
57
  isMarkdownBundle: () => isMarkdownBundle,
56
58
  isTempOrder: () => isTempOrder,
57
59
  mapPaymentItemToOrderPayment: () => mapPaymentItemToOrderPayment,
@@ -65,7 +67,9 @@ __export(utils_exports, {
65
67
  normalizeProductSkuOptions: () => normalizeProductSkuOptions,
66
68
  normalizeSubmitBooking: () => normalizeSubmitBooking,
67
69
  normalizeSubmitCollectPaxValue: () => normalizeSubmitCollectPaxValue,
70
+ productRequiresFormSubject: () => productRequiresFormSubject,
68
71
  resolveEffectivePerUnitDiscount: () => resolveEffectivePerUnitDiscount,
72
+ resolveIsFormSubject: () => resolveIsFormSubject,
69
73
  resolveManualDiscountMessage: () => import_manualProductDiscount.resolveManualDiscountMessage,
70
74
  resolveManualDiscountOriginTotal: () => import_manualProductDiscount.resolveManualDiscountOriginTotal,
71
75
  resolveManualDiscountReasonFromSources: () => import_manualProductDiscount.resolveManualDiscountReasonFromSources,
@@ -376,6 +380,42 @@ function normalizeOrderProductDiscountList(discountList) {
376
380
  return normalized;
377
381
  });
378
382
  }
383
+ function resolveSubmitBundleMapId(bundle) {
384
+ var _a;
385
+ const metadataMapId = (_a = bundle.metadata) == null ? void 0 : _a.custom_product_bundle_map_id;
386
+ if (metadataMapId !== void 0 && metadataMapId !== null && metadataMapId !== "") {
387
+ return metadataMapId;
388
+ }
389
+ if (bundle._id !== void 0 && bundle._id !== null && bundle._id !== "") {
390
+ return bundle._id;
391
+ }
392
+ return void 0;
393
+ }
394
+ function collectSubmitProductDiscountList(product) {
395
+ const submitDiscountList = Array.isArray(product == null ? void 0 : product.discount_list) ? [...product.discount_list] : [];
396
+ for (const bundle of (product == null ? void 0 : product.product_bundle) || []) {
397
+ if (!bundle || typeof bundle !== "object")
398
+ continue;
399
+ const bundleMapId = resolveSubmitBundleMapId(bundle);
400
+ const bundleDiscountList = Array.isArray(bundle.discount_list) ? bundle.discount_list : [];
401
+ for (const discount of bundleDiscountList) {
402
+ if (!discount || typeof discount !== "object")
403
+ continue;
404
+ const discountMetadata = discount.metadata && typeof discount.metadata === "object" ? discount.metadata : {};
405
+ const discountMapId = discountMetadata.custom_product_bundle_map_id !== void 0 && discountMetadata.custom_product_bundle_map_id !== null && discountMetadata.custom_product_bundle_map_id !== "" ? discountMetadata.custom_product_bundle_map_id : bundleMapId;
406
+ submitDiscountList.push({
407
+ ...discount,
408
+ ...discountMapId !== void 0 ? {
409
+ metadata: {
410
+ ...discountMetadata,
411
+ custom_product_bundle_map_id: discountMapId
412
+ }
413
+ } : {}
414
+ });
415
+ }
416
+ }
417
+ return normalizeOrderProductDiscountList(submitDiscountList);
418
+ }
379
419
  function resolveManualOverrideLineOriginalPrice(params, fallbackCompositeOriginal) {
380
420
  var _a, _b;
381
421
  const metadata = params.metadata || {};
@@ -671,6 +711,10 @@ function formatSubmitBundleItems(bundle) {
671
711
  return bundle.map((b) => {
672
712
  const rawBundle = b && typeof b === "object" ? b : {};
673
713
  const existedMetadata = rawBundle.metadata && typeof rawBundle.metadata === "object" ? rawBundle.metadata : {};
714
+ const {
715
+ custom_product_bundle_map_id: _customProductBundleMapId,
716
+ ...submitMetadata
717
+ } = existedMetadata;
674
718
  const sellingPrice = getBundleSellingMagnitude(rawBundle).toFixed(2);
675
719
  const paymentPrice = rawBundle.bundle_payment_price !== void 0 && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== "" ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
676
720
  const priceValue = rawBundle.price ?? rawBundle.custom_price ?? rawBundle.bundle_selling_price;
@@ -683,6 +727,8 @@ function formatSubmitBundleItems(bundle) {
683
727
  0
684
728
  );
685
729
  const num = toBundleNumber(rawBundle.num ?? rawBundle.quantity, 1);
730
+ const bundleMapId = resolveSubmitBundleMapId(rawBundle);
731
+ const hasSubmitBundleDiscounts = Array.isArray(rawBundle.discount_list) && rawBundle.discount_list.length > 0;
686
732
  return {
687
733
  is_charge_tax: rawBundle.is_charge_tax ?? 0,
688
734
  bundle_variant_id: rawBundle.bundle_variant_id ?? 0,
@@ -700,7 +746,8 @@ function formatSubmitBundleItems(bundle) {
700
746
  bundle_id: (rawBundle == null ? void 0 : rawBundle.bundle_id) ?? (rawBundle == null ? void 0 : rawBundle.id),
701
747
  bundle_product_id: (rawBundle == null ? void 0 : rawBundle.bundle_product_id) ?? (rawBundle == null ? void 0 : rawBundle._bundle_product_id),
702
748
  metadata: {
703
- ...existedMetadata,
749
+ ...submitMetadata,
750
+ ...hasSubmitBundleDiscounts && bundleMapId !== void 0 ? { custom_product_bundle_map_id: bundleMapId } : {},
704
751
  surcharge_fee: surchargeFee,
705
752
  relation_surcharge_ids: relationSurchargeIds,
706
753
  product_discount_difference: productDiscountDifference
@@ -765,7 +812,7 @@ function normalizeSubmitProduct(product) {
765
812
  ...bookingUid ? { booking_uid: bookingUid } : {},
766
813
  product_quantity: toBundleNumber(num ?? submitProduct.product_quantity, 1),
767
814
  product_sku: productSku,
768
- discount_list: normalizeOrderProductDiscountList(submitProduct.discount_list),
815
+ discount_list: collectSubmitProductDiscountList(submitProduct),
769
816
  product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
770
817
  metadata: cleanMetadata,
771
818
  // 出站兼容:后端消费 payment_price 字段(行 composite 已减整单折扣均摊)。
@@ -1094,6 +1141,37 @@ function getOrderProductLineUid(product) {
1094
1141
  return null;
1095
1142
  return String(uid);
1096
1143
  }
1144
+ function getRuntimeProductOrigin(tempOrder, product) {
1145
+ var _a, _b, _c, _d, _e, _f;
1146
+ const uid = getOrderProductLineUid(product);
1147
+ if (uid && ((_c = (_b = (_a = tempOrder == null ? void 0 : tempOrder._extend) == null ? void 0 : _a.productsByUid) == null ? void 0 : _b[uid]) == null ? void 0 : _c.origin)) {
1148
+ return tempOrder._extend.productsByUid[uid].origin;
1149
+ }
1150
+ const matchedProduct = ((tempOrder == null ? void 0 : tempOrder.products) || []).find((item) => item === product || getOrderProductLineUid(item) === uid || String((item == null ? void 0 : item.product_id) ?? (item == null ? void 0 : item.id) ?? "") === String((product == null ? void 0 : product.product_id) ?? (product == null ? void 0 : product.id) ?? ""));
1151
+ const matchedUid = matchedProduct ? getOrderProductLineUid(matchedProduct) : "";
1152
+ return matchedUid ? ((_f = (_e = (_d = tempOrder == null ? void 0 : tempOrder._extend) == null ? void 0 : _d.productsByUid) == null ? void 0 : _e[matchedUid]) == null ? void 0 : _f.origin) || null : null;
1153
+ }
1154
+ function isHolderConfigRequired(holderConfig) {
1155
+ if (!holderConfig || typeof holderConfig !== "object")
1156
+ return false;
1157
+ if (holderConfig.status === "disable")
1158
+ return false;
1159
+ return Number(holderConfig.required) === 1;
1160
+ }
1161
+ function productRequiresFormSubject(tempOrder, product) {
1162
+ const runtimeOrigin = getRuntimeProductOrigin(tempOrder, product);
1163
+ return isHolderConfigRequired(product == null ? void 0 : product.holder_config) || isHolderConfigRequired(runtimeOrigin == null ? void 0 : runtimeOrigin.holder_config);
1164
+ }
1165
+ function resolveIsFormSubject(tempOrder, product) {
1166
+ var _a;
1167
+ if (((_a = tempOrder == null ? void 0 : tempOrder.holder) == null ? void 0 : _a.type) === "form")
1168
+ return true;
1169
+ if (product)
1170
+ return productRequiresFormSubject(tempOrder, product);
1171
+ return ((tempOrder == null ? void 0 : tempOrder.products) || []).some(
1172
+ (item) => productRequiresFormSubject(tempOrder, item)
1173
+ );
1174
+ }
1097
1175
  function isEmptyOrderProductDisplayValue(value) {
1098
1176
  if (value === void 0 || value === null)
1099
1177
  return true;
@@ -1174,9 +1252,11 @@ function indexOrderProductsByUid(products) {
1174
1252
  getBundleSignedUnit,
1175
1253
  getOrderProductLineUid,
1176
1254
  getProductSkuOptions,
1255
+ getRuntimeProductOrigin,
1177
1256
  hasAssignedHolderId,
1178
1257
  indexOrderProductsByUid,
1179
1258
  isEmptyOrderProductDisplayValue,
1259
+ isHolderConfigRequired,
1180
1260
  isMarkdownBundle,
1181
1261
  isTempOrder,
1182
1262
  mapPaymentItemToOrderPayment,
@@ -1190,7 +1270,9 @@ function indexOrderProductsByUid(products) {
1190
1270
  normalizeProductSkuOptions,
1191
1271
  normalizeSubmitBooking,
1192
1272
  normalizeSubmitCollectPaxValue,
1273
+ productRequiresFormSubject,
1193
1274
  resolveEffectivePerUnitDiscount,
1275
+ resolveIsFormSubject,
1194
1276
  resolveManualDiscountMessage,
1195
1277
  resolveManualDiscountOriginTotal,
1196
1278
  resolveManualDiscountReasonFromSources,
@@ -1,6 +1,6 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { Rules, RulesModuleAPI, DiscountResult, UnavailableReason } from './types';
3
+ import { Rules, RulesModuleAPI, DiscountResult, RulesFormSubject, UnavailableReason } from './types';
4
4
  import { Discount } from '../Discount/types';
5
5
  import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
6
6
  import { WindowPlugin } from '../../plugins';
@@ -24,7 +24,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
24
24
  holders: {
25
25
  form_record_id: number;
26
26
  }[];
27
- isFormSubject: boolean;
27
+ isFormSubject: RulesFormSubject;
28
28
  }): {
29
29
  isAvailable: boolean;
30
30
  discountList: Discount[];
@@ -43,7 +43,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
43
43
  holders: {
44
44
  form_record_id: number;
45
45
  }[];
46
- isFormSubject: boolean;
46
+ isFormSubject: RulesFormSubject;
47
47
  orderTotalAmount: number;
48
48
  }, options?: {
49
49
  isSelected?: boolean;
@@ -70,7 +70,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
70
70
  var _a;
71
71
  if (((_a = discount.holder) == null ? void 0 : _a.holder_type) !== "form")
72
72
  return true;
73
- const orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id : void 0;
73
+ const orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id || holders[0] : void 0;
74
74
  const productHolderId = Array.isArray(product.holder_id) ? product.holder_id[0] : product.holder_id;
75
75
  if (!product.isNeedHolder)
76
76
  return true;
@@ -207,6 +207,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
207
207
  orderTotalAmount
208
208
  }, options) {
209
209
  var _a;
210
+ const resolveIsFormSubject = (product) => typeof isFormSubject === "function" ? Boolean(isFormSubject(product)) : Boolean(isFormSubject);
210
211
  const isEditModeAddNewProduct = productList.find((n) => n.booking_id) && productList.find((n) => !n.booking_id);
211
212
  const editModeDiscount = [];
212
213
  const addModeDiscount = [];
@@ -596,7 +597,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
596
597
  const isHolderMatch = this.checkHolderMatch(
597
598
  discount,
598
599
  {
599
- isNeedHolder: isFormSubject && !(_tempVar == null ? void 0 : _tempVar.isNormalProduct),
600
+ isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar == null ? void 0 : _tempVar.isNormalProduct),
600
601
  holder_id: (_tempVar == null ? void 0 : _tempVar.holder_id) || product.holder_id
601
602
  },
602
603
  holders
@@ -767,7 +768,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
767
768
  const isHolderMatch = this.checkHolderMatch(
768
769
  discount,
769
770
  {
770
- isNeedHolder: isFormSubject && !(_tempVar == null ? void 0 : _tempVar.isNormalProduct),
771
+ isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar == null ? void 0 : _tempVar.isNormalProduct),
771
772
  holder_id: (_tempVar == null ? void 0 : _tempVar.holder_id) || product.holder_id
772
773
  },
773
774
  holders
@@ -22,6 +22,7 @@ export interface DiscountResult {
22
22
  productList: any[];
23
23
  discountList: any[];
24
24
  }
25
+ export type RulesFormSubject = boolean | ((product: any) => boolean);
25
26
  export interface RulesModuleAPI {
26
27
  setRulesList: (rulesList: Rules[]) => Promise<void>;
27
28
  clear: () => Promise<void>;
@@ -31,7 +32,7 @@ export interface RulesModuleAPI {
31
32
  holders: {
32
33
  form_record_id: number;
33
34
  }[];
34
- isFormSubject: boolean;
35
+ isFormSubject: RulesFormSubject;
35
36
  orderTotalAmount: number;
36
37
  }) => DiscountResult;
37
38
  }
@@ -9,16 +9,19 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
9
9
  private store;
10
10
  private request;
11
11
  private surchargeListModuleName;
12
+ private otherParams;
13
+ private surchargeListChannel;
12
14
  constructor(name?: string, version?: string);
13
15
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
14
16
  /**
15
- * 更新父级解决方案透传的运行态参数,并在 surcharge 模块名变化时刷新附加费列表。
17
+ * 更新父级解决方案透传的运行态参数,并在 surcharge 模块名或渠道变化时刷新附加费列表。
16
18
  *
17
19
  * @example
18
- * await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
20
+ * await salesSummaryModule.updateOtherParams({ channel: 'pos', surchargeListModuleName: 'custom_surchargeList' });
19
21
  */
20
22
  updateOtherParams(params: Record<string, any>): Promise<void>;
21
- getSurchargeList(): Promise<void>;
23
+ private resolveChannel;
24
+ getSurchargeList(channel?: string): Promise<void>;
22
25
  private getAppData;
23
26
  private getTaxConfig;
24
27
  getSummary(params: {
@@ -26,6 +29,7 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
26
29
  isPriceIncludeTax?: number;
27
30
  taxRate?: number;
28
31
  shopDiscount?: string | number;
32
+ channel?: string;
29
33
  }): Promise<{
30
34
  tax_title: string;
31
35
  tax_rate: number | undefined;
@@ -33,12 +33,15 @@ var salesSummaryDataKeys = {
33
33
  taxTitle: "tax_title",
34
34
  taxCountryCode: "tax_country_code"
35
35
  };
36
+ var DEFAULT_SURCHARGE_CHANNEL = "online-store";
36
37
  var SalesSummaryModule = class extends import_BaseModule.BaseModule {
37
38
  constructor(name, version) {
38
39
  super(name, version);
39
40
  this.defaultName = "salesSummary";
40
41
  this.defaultVersion = "1.0.0";
41
42
  this.surchargeListModuleName = "surchargeList";
43
+ this.otherParams = {};
44
+ this.surchargeListChannel = DEFAULT_SURCHARGE_CHANNEL;
42
45
  }
43
46
  async initialize(core, options) {
44
47
  var _a, _b, _c;
@@ -46,9 +49,10 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
46
49
  this.store = options.store;
47
50
  this.appPlugin = this.core.getPlugin("app");
48
51
  this.request = this.core.getPlugin("request");
52
+ this.otherParams = options.otherParams || {};
49
53
  this.store.surchargeList = ((_a = options.initialState) == null ? void 0 : _a.surchargeList) || [];
50
54
  this.store.summary = ((_b = options.initialState) == null ? void 0 : _b.summary) || (0, import_utils.createEmptySalesSummary)();
51
- this.surchargeListModuleName = ((_c = options.otherParams) == null ? void 0 : _c.surchargeListModuleName) || "surchargeList";
55
+ this.surchargeListModuleName = ((_c = this.otherParams) == null ? void 0 : _c.surchargeListModuleName) || "surchargeList";
52
56
  if (!this.appPlugin) {
53
57
  throw new Error("SalesSummaryModule 需要 app 插件支持");
54
58
  }
@@ -58,41 +62,50 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
58
62
  await this.getSurchargeList();
59
63
  }
60
64
  /**
61
- * 更新父级解决方案透传的运行态参数,并在 surcharge 模块名变化时刷新附加费列表。
65
+ * 更新父级解决方案透传的运行态参数,并在 surcharge 模块名或渠道变化时刷新附加费列表。
62
66
  *
63
67
  * @example
64
- * await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
68
+ * await salesSummaryModule.updateOtherParams({ channel: 'pos', surchargeListModuleName: 'custom_surchargeList' });
65
69
  */
66
70
  async updateOtherParams(params) {
71
+ const previousChannel = this.resolveChannel();
67
72
  const nextSurchargeListModuleName = (params == null ? void 0 : params.surchargeListModuleName) || "surchargeList";
68
- if (nextSurchargeListModuleName === this.surchargeListModuleName)
69
- return;
73
+ const nextChannel = this.resolveChannel(params);
74
+ const shouldReload = nextSurchargeListModuleName !== this.surchargeListModuleName || nextChannel !== previousChannel;
75
+ this.otherParams = params || {};
70
76
  this.surchargeListModuleName = nextSurchargeListModuleName;
71
- await this.getSurchargeList();
77
+ if (shouldReload) {
78
+ await this.getSurchargeList(nextChannel);
79
+ }
72
80
  }
73
- async getSurchargeList() {
81
+ resolveChannel(params = this.otherParams) {
82
+ return (params == null ? void 0 : params.channel) || DEFAULT_SURCHARGE_CHANNEL;
83
+ }
84
+ async getSurchargeList(channel = this.resolveChannel()) {
74
85
  try {
75
86
  const surchargeListModule = this.core.getModule(
76
87
  this.surchargeListModuleName
77
88
  );
78
89
  if (surchargeListModule == null ? void 0 : surchargeListModule.getSurchargeList) {
79
- this.store.surchargeList = await surchargeListModule.getSurchargeList();
90
+ this.store.surchargeList = await surchargeListModule.getSurchargeList({ channel });
91
+ this.surchargeListChannel = channel;
80
92
  return;
81
93
  }
82
94
  const surchargeList = await this.request.get(
83
95
  "/order/custom-surcharge/available/v2",
84
96
  {
85
- // TODO 真实的渠道
86
- channel: "online-store",
97
+ channel,
87
98
  is_assemble_product_data: 1,
88
99
  is_assemble_schedule_data: 1,
89
100
  with: ["relationSchedule"]
90
101
  }
91
102
  );
92
103
  this.store.surchargeList = (surchargeList == null ? void 0 : surchargeList.data) || [];
104
+ this.surchargeListChannel = channel;
93
105
  } catch (error) {
94
106
  console.warn("[SalesSummaryModule] 加载附加费配置失败", error);
95
107
  this.store.surchargeList = [];
108
+ this.surchargeListChannel = channel;
96
109
  }
97
110
  }
98
111
  getAppData(key) {
@@ -114,7 +127,11 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
114
127
  }
115
128
  async getSummary(params) {
116
129
  var _a, _b;
117
- const { products = [], isPriceIncludeTax, taxRate, shopDiscount } = params;
130
+ const { products = [], isPriceIncludeTax, taxRate, shopDiscount, channel } = params;
131
+ const summaryChannel = channel || this.resolveChannel();
132
+ if (summaryChannel !== this.surchargeListChannel) {
133
+ await this.getSurchargeList(summaryChannel);
134
+ }
118
135
  const taxConfig = this.getTaxConfig();
119
136
  const summarySchedule = this.core.getModule(
120
137
  `${this.name.split("_")[0]}_schedule`
@@ -63,5 +63,6 @@ export interface SalesSummaryModuleAPI {
63
63
  isPriceIncludeTax?: number;
64
64
  taxRate?: number;
65
65
  shopDiscount?: string | number;
66
+ channel?: string;
66
67
  }): Promise<SalesSummaryData>;
67
68
  }
@@ -308,6 +308,8 @@ function getFallbackAllProductSurchargeIds(surchargeList) {
308
308
  return ids;
309
309
  if (Number(config.is_all ?? 0) !== 1)
310
310
  return ids;
311
+ if (Number(config.open_schedule ?? 0) === 1 && config.schedule_type !== "all")
312
+ return ids;
311
313
  ids.push(id);
312
314
  return ids;
313
315
  }, []);
@@ -1,16 +1,18 @@
1
1
  import { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { SurchargeListItem, SurchargeListModuleAPI } from './types';
3
+ import { SurchargeListItem, SurchargeListModuleAPI, SurchargeListQuery } from './types';
4
4
  export * from './types';
5
5
  export declare class SurchargeListModule extends BaseModule implements Module, SurchargeListModuleAPI {
6
6
  protected defaultName: string;
7
7
  protected defaultVersion: string;
8
8
  private request;
9
9
  private store;
10
- private loadingPromise;
10
+ private loadingPromises;
11
+ private requestVersion;
11
12
  constructor(name?: string, version?: string);
12
13
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
13
- getSurchargeList(): Promise<SurchargeListItem[]>;
14
- refreshSurchargeList(): Promise<SurchargeListItem[]>;
14
+ private resolveChannel;
15
+ getSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
16
+ refreshSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
15
17
  private loadSurchargeList;
16
18
  }