@pisell/pisellos 2.3.7 → 2.3.9

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.
@@ -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,6 +537,7 @@ 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;
@@ -696,6 +697,7 @@ export interface OrderModuleAPI {
696
697
  payments?: OrderPaymentSource[];
697
698
  paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
698
699
  smallTicketDataFlag?: number;
700
+ confirmPendingVoucherPayments?: boolean;
699
701
  enhancePayload?: SubmitPayloadEnhancer;
700
702
  }) => Promise<T>;
701
703
  submitTempOrderAsync: <T = any>(params?: {
@@ -707,6 +709,7 @@ export interface OrderModuleAPI {
707
709
  payments?: OrderPaymentSource[];
708
710
  paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
709
711
  smallTicketDataFlag?: number;
712
+ confirmPendingVoucherPayments?: boolean;
710
713
  enhancePayload?: SubmitPayloadEnhancer;
711
714
  }) => Promise<T>;
712
715
  getOrderPayments: () => OrderPaymentData[];
@@ -714,7 +717,17 @@ export interface OrderModuleAPI {
714
717
  addOrderPayment: (payment: OrderPaymentSource) => OrderPaymentData[];
715
718
  updateOrderPayment: (paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>) => OrderPaymentData[];
716
719
  deleteOrderPayment: (paymentIdentity: string | number) => OrderPaymentData[];
717
- 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[];
718
731
  sendCustomerPayLink: <T = any>(params: SendCustomerPayLinkParams) => Promise<T>;
719
732
  saveDraft: () => Promise<void>;
720
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,144 @@
1
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
14
+ var BUNDLE_MAP_ID_KEY = 'custom_product_bundle_map_id';
15
+ function getBundleMapId(bundle) {
16
+ var _bundle$metadata;
17
+ var metadataMapId = bundle === null || bundle === void 0 || (_bundle$metadata = bundle.metadata) === null || _bundle$metadata === void 0 ? void 0 : _bundle$metadata[BUNDLE_MAP_ID_KEY];
18
+ if (metadataMapId !== undefined && metadataMapId !== null && metadataMapId !== '') {
19
+ return String(metadataMapId);
20
+ }
21
+ if ((bundle === null || bundle === void 0 ? void 0 : bundle._id) !== undefined && bundle._id !== null && bundle._id !== '') {
22
+ return String(bundle._id);
23
+ }
24
+ return null;
25
+ }
26
+ function getDiscountBundleMapId(discount) {
27
+ var _discount$metadata;
28
+ var mapId = discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata[BUNDLE_MAP_ID_KEY];
29
+ if (mapId === undefined || mapId === null || mapId === '') return null;
30
+ return String(mapId);
31
+ }
32
+ function hasSameBundleDiscount(discountList, discount) {
33
+ var _ref, _discount$discount$re, _discount$discount;
34
+ var targetOrderDiscountId = discount.order_discount_id;
35
+ if (targetOrderDiscountId !== undefined && targetOrderDiscountId !== null) {
36
+ return discountList.some(function (item) {
37
+ return (item === null || item === void 0 ? void 0 : item.order_discount_id) === targetOrderDiscountId;
38
+ });
39
+ }
40
+ var targetResourceId = (_ref = (_discount$discount$re = discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _discount$discount$re !== void 0 ? _discount$discount$re : discount === null || discount === void 0 ? void 0 : discount.resource_id) !== null && _ref !== void 0 ? _ref : discount === null || discount === void 0 ? void 0 : discount.discount_id;
41
+ var targetMapId = getDiscountBundleMapId(discount);
42
+ return discountList.some(function (item) {
43
+ var _ref2, _item$discount$resour, _item$discount, _item$amount, _discount$amount;
44
+ var resourceId = (_ref2 = (_item$discount$resour = item === null || item === void 0 || (_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id) !== null && _item$discount$resour !== void 0 ? _item$discount$resour : item === null || item === void 0 ? void 0 : item.resource_id) !== null && _ref2 !== void 0 ? _ref2 : item === null || item === void 0 ? void 0 : item.discount_id;
45
+ return resourceId === targetResourceId && String((_item$amount = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount !== void 0 ? _item$amount : '') === String((_discount$amount = discount === null || discount === void 0 ? void 0 : discount.amount) !== null && _discount$amount !== void 0 ? _discount$amount : '') && getDiscountBundleMapId(item) === targetMapId;
46
+ });
47
+ }
48
+ export function restoreHydratedBundleDiscounts(product, normalizeDiscountList) {
49
+ if (!Array.isArray(product.product_bundle) || !Array.isArray(product.discount_list)) {
50
+ return product;
51
+ }
52
+ var bundleByMapId = new Map();
53
+ product.product_bundle.forEach(function (bundle) {
54
+ if (!bundle || _typeof(bundle) !== 'object') return;
55
+ var mapId = getBundleMapId(bundle);
56
+ if (mapId) bundleByMapId.set(mapId, bundle);
57
+ });
58
+ if (!bundleByMapId.size) return product;
59
+ var mainDiscountList = [];
60
+ var bundleDiscounts = [];
61
+ product.discount_list.forEach(function (discount) {
62
+ var mapId = getDiscountBundleMapId(discount);
63
+ if (mapId && bundleByMapId.has(mapId)) {
64
+ bundleDiscounts.push({
65
+ mapId: mapId,
66
+ discount: discount
67
+ });
68
+ } else {
69
+ mainDiscountList.push(discount);
70
+ }
71
+ });
72
+ if (!bundleDiscounts.length) return product;
73
+ return _objectSpread(_objectSpread({}, product), {}, {
74
+ discount_list: normalizeDiscountList(mainDiscountList),
75
+ product_bundle: product.product_bundle.map(function (bundle) {
76
+ if (!bundle || _typeof(bundle) !== 'object') return bundle;
77
+ var mapId = getBundleMapId(bundle);
78
+ if (!mapId) return bundle;
79
+ var matchedDiscounts = bundleDiscounts.filter(function (item) {
80
+ return item.mapId === mapId;
81
+ }).map(function (item) {
82
+ return item.discount;
83
+ });
84
+ if (!matchedDiscounts.length) return bundle;
85
+ var currentDiscountList = Array.isArray(bundle.discount_list) ? _toConsumableArray(bundle.discount_list) : [];
86
+ var _iterator = _createForOfIteratorHelper(matchedDiscounts),
87
+ _step;
88
+ try {
89
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
90
+ var discount = _step.value;
91
+ if (!hasSameBundleDiscount(currentDiscountList, discount)) {
92
+ currentDiscountList.push(discount);
93
+ }
94
+ }
95
+ } catch (err) {
96
+ _iterator.e(err);
97
+ } finally {
98
+ _iterator.f();
99
+ }
100
+ return _objectSpread(_objectSpread({}, bundle), {}, {
101
+ discount_list: normalizeDiscountList(currentDiscountList),
102
+ metadata: _objectSpread(_objectSpread({}, bundle.metadata || {}), {}, _defineProperty({}, BUNDLE_MAP_ID_KEY, mapId))
103
+ });
104
+ })
105
+ });
106
+ }
107
+ export function expandHydratedProductsForDiscountCollection(products) {
108
+ var expanded = [];
109
+ var _iterator2 = _createForOfIteratorHelper(products || []),
110
+ _step2;
111
+ try {
112
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
113
+ var product = _step2.value;
114
+ expanded.push(product);
115
+ var _iterator3 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
116
+ _step3;
117
+ try {
118
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
119
+ var _ref3, _ref4, _bundle$bundle_produc, _ref5, _bundle$num, _ref6, _bundle$quantity, _ref7, _bundle$original_pric, _bundle$bundle_sellin, _bundle$is_charge_tax;
120
+ var bundle = _step3.value;
121
+ if (!Array.isArray(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || bundle.discount_list.length === 0) continue;
122
+ expanded.push(_objectSpread(_objectSpread({}, product), {}, {
123
+ product_id: (_ref3 = (_ref4 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref4 !== void 0 ? _ref4 : bundle.product_id) !== null && _ref3 !== void 0 ? _ref3 : product === null || product === void 0 ? void 0 : product.product_id,
124
+ num: (_ref5 = (_bundle$num = bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle.quantity) !== null && _ref5 !== void 0 ? _ref5 : product === null || product === void 0 ? void 0 : product.num,
125
+ product_quantity: (_ref6 = (_bundle$quantity = bundle.quantity) !== null && _bundle$quantity !== void 0 ? _bundle$quantity : bundle.num) !== null && _ref6 !== void 0 ? _ref6 : product === null || product === void 0 ? void 0 : product.product_quantity,
126
+ original_price: (_ref7 = (_bundle$original_pric = bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle.product_price) !== null && _ref7 !== void 0 ? _ref7 : bundle.price,
127
+ selling_price: (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.price,
128
+ is_charge_tax: (_bundle$is_charge_tax = bundle.is_charge_tax) !== null && _bundle$is_charge_tax !== void 0 ? _bundle$is_charge_tax : product === null || product === void 0 ? void 0 : product.is_charge_tax,
129
+ discount_list: bundle.discount_list
130
+ }));
131
+ }
132
+ } catch (err) {
133
+ _iterator3.e(err);
134
+ } finally {
135
+ _iterator3.f();
136
+ }
137
+ }
138
+ } catch (err) {
139
+ _iterator2.e(err);
140
+ } finally {
141
+ _iterator2.f();
142
+ }
143
+ return expanded;
144
+ }
@@ -1,7 +1,8 @@
1
- var _excluded = ["unique_identification_number"],
2
- _excluded2 = ["num", "surcharge_fee", "discount_amount", "discount_type", "discountway", "product_discount_reason", "discount_per"],
3
- _excluded3 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "discount_list", "tax_fee", "total_amount", "total_refund_amount", "create_date", "holder_id"],
4
- _excluded4 = ["collect_pax", "table_occupancy_duration"];
1
+ var _excluded = ["custom_product_bundle_map_id"],
2
+ _excluded2 = ["unique_identification_number"],
3
+ _excluded3 = ["num", "surcharge_fee", "discount_amount", "discount_type", "discountway", "product_discount_reason", "discount_per"],
4
+ _excluded4 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "discount_list", "tax_fee", "total_amount", "total_refund_amount", "create_date", "holder_id"],
5
+ _excluded5 = ["collect_pax", "table_occupancy_duration"];
5
6
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
6
7
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
7
8
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
@@ -446,6 +447,54 @@ export function normalizeOrderProductDiscountList(discountList) {
446
447
  return normalized;
447
448
  });
448
449
  }
450
+ function resolveSubmitBundleMapId(bundle) {
451
+ var _bundle$metadata;
452
+ var metadataMapId = (_bundle$metadata = bundle.metadata) === null || _bundle$metadata === void 0 ? void 0 : _bundle$metadata.custom_product_bundle_map_id;
453
+ if (metadataMapId !== undefined && metadataMapId !== null && metadataMapId !== '') {
454
+ return metadataMapId;
455
+ }
456
+ if (bundle._id !== undefined && bundle._id !== null && bundle._id !== '') {
457
+ return bundle._id;
458
+ }
459
+ return undefined;
460
+ }
461
+ function collectSubmitProductDiscountList(product) {
462
+ var submitDiscountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? _toConsumableArray(product.discount_list) : [];
463
+ var _iterator6 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
464
+ _step6;
465
+ try {
466
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
467
+ var bundle = _step6.value;
468
+ if (!bundle || _typeof(bundle) !== 'object') continue;
469
+ var bundleMapId = resolveSubmitBundleMapId(bundle);
470
+ var bundleDiscountList = Array.isArray(bundle.discount_list) ? bundle.discount_list : [];
471
+ var _iterator7 = _createForOfIteratorHelper(bundleDiscountList),
472
+ _step7;
473
+ try {
474
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
475
+ var discount = _step7.value;
476
+ if (!discount || _typeof(discount) !== 'object') continue;
477
+ var discountMetadata = discount.metadata && _typeof(discount.metadata) === 'object' ? discount.metadata : {};
478
+ var discountMapId = discountMetadata.custom_product_bundle_map_id !== undefined && discountMetadata.custom_product_bundle_map_id !== null && discountMetadata.custom_product_bundle_map_id !== '' ? discountMetadata.custom_product_bundle_map_id : bundleMapId;
479
+ submitDiscountList.push(_objectSpread(_objectSpread({}, discount), discountMapId !== undefined ? {
480
+ metadata: _objectSpread(_objectSpread({}, discountMetadata), {}, {
481
+ custom_product_bundle_map_id: discountMapId
482
+ })
483
+ } : {}));
484
+ }
485
+ } catch (err) {
486
+ _iterator7.e(err);
487
+ } finally {
488
+ _iterator7.f();
489
+ }
490
+ }
491
+ } catch (err) {
492
+ _iterator6.e(err);
493
+ } finally {
494
+ _iterator6.f();
495
+ }
496
+ return normalizeOrderProductDiscountList(submitDiscountList);
497
+ }
449
498
 
450
499
  /**
451
500
  * 手动改价(price_override)时行级 original_price(composite 单价):
@@ -783,6 +832,8 @@ function formatSubmitBundleItems(bundle) {
783
832
  var _ref25, _rawBundle$price, _rawBundle$surcharge_, _rawBundle$num, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$quantity, _rawBundle$extension_, _rawBundle$extension_2, _ref26, _rawBundle$price_type, _ref27, _rawBundle$price_type2, _rawBundle$bundle_gro, _rawBundle$bundle_id, _rawBundle$bundle_pro;
784
833
  var rawBundle = b && _typeof(b) === 'object' ? b : {};
785
834
  var existedMetadata = rawBundle.metadata && _typeof(rawBundle.metadata) === 'object' ? rawBundle.metadata : {};
835
+ var _customProductBundleMapId = existedMetadata.custom_product_bundle_map_id,
836
+ submitMetadata = _objectWithoutProperties(existedMetadata, _excluded);
786
837
 
787
838
  // bundle_selling_price 出站存「正净额」:markdown 为 |price| − Σoptions(如 3.70),
788
839
  // markup/原价维持原值;与后端口径一致(price 仍为毛价)。
@@ -794,6 +845,8 @@ function formatSubmitBundleItems(bundle) {
794
845
  var surchargeFee = toMoneyString((_rawBundle$surcharge_ = rawBundle.surcharge_fee) !== null && _rawBundle$surcharge_ !== void 0 ? _rawBundle$surcharge_ : existedMetadata.surcharge_fee);
795
846
  var productDiscountDifference = toBundleNumber(existedMetadata.product_discount_difference, 0);
796
847
  var num = toBundleNumber((_rawBundle$num = rawBundle.num) !== null && _rawBundle$num !== void 0 ? _rawBundle$num : rawBundle.quantity, 1);
848
+ var bundleMapId = resolveSubmitBundleMapId(rawBundle);
849
+ var hasSubmitBundleDiscounts = Array.isArray(rawBundle.discount_list) && rawBundle.discount_list.length > 0;
797
850
  return {
798
851
  is_charge_tax: (_rawBundle$is_charge_ = rawBundle.is_charge_tax) !== null && _rawBundle$is_charge_ !== void 0 ? _rawBundle$is_charge_ : 0,
799
852
  bundle_variant_id: (_rawBundle$bundle_var = rawBundle.bundle_variant_id) !== null && _rawBundle$bundle_var !== void 0 ? _rawBundle$bundle_var : 0,
@@ -810,7 +863,9 @@ function formatSubmitBundleItems(bundle) {
810
863
  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,
811
864
  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,
812
865
  bundle_product_id: (_rawBundle$bundle_pro = rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.bundle_product_id) !== null && _rawBundle$bundle_pro !== void 0 ? _rawBundle$bundle_pro : rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle._bundle_product_id,
813
- metadata: _objectSpread(_objectSpread({}, existedMetadata), {}, {
866
+ metadata: _objectSpread(_objectSpread(_objectSpread({}, submitMetadata), hasSubmitBundleDiscounts && bundleMapId !== undefined ? {
867
+ custom_product_bundle_map_id: bundleMapId
868
+ } : {}), {}, {
814
869
  surcharge_fee: surchargeFee,
815
870
  relation_surcharge_ids: relationSurchargeIds,
816
871
  product_discount_difference: productDiscountDifference
@@ -839,7 +894,7 @@ function normalizeSubmitProduct(product) {
839
894
  var _rawMetadata$product_, _submitProduct$produc, _submitProduct$paymen;
840
895
  var _ref28 = product,
841
896
  _runtimeUid = _ref28.unique_identification_number,
842
- submitProduct = _objectWithoutProperties(_ref28, _excluded);
897
+ submitProduct = _objectWithoutProperties(_ref28, _excluded2);
843
898
  var num = submitProduct.num,
844
899
  _productSurchargeFee = submitProduct.surcharge_fee,
845
900
  _deprecatedDiscountAmount = submitProduct.discount_amount,
@@ -847,7 +902,7 @@ function normalizeSubmitProduct(product) {
847
902
  _deprecatedDiscountway = submitProduct.discountway,
848
903
  _deprecatedProductDiscountReason = submitProduct.product_discount_reason,
849
904
  _deprecatedDiscountPer = submitProduct.discount_per,
850
- productRest = _objectWithoutProperties(submitProduct, _excluded2);
905
+ productRest = _objectWithoutProperties(submitProduct, _excluded3);
851
906
  delete productRest["product_".concat('option', "_item")];
852
907
  var rawMetadata = submitProduct.metadata || {};
853
908
  var bookingUid = rawMetadata.booking_uid;
@@ -877,7 +932,7 @@ function normalizeSubmitProduct(product) {
877
932
  } : {}), {}, {
878
933
  product_quantity: toBundleNumber(num !== null && num !== void 0 ? num : submitProduct.product_quantity, 1),
879
934
  product_sku: productSku,
880
- discount_list: normalizeOrderProductDiscountList(submitProduct.discount_list),
935
+ discount_list: collectSubmitProductDiscountList(submitProduct),
881
936
  product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
882
937
  metadata: cleanMetadata,
883
938
  // 出站兼容:后端消费 payment_price 字段(行 composite 已减整单折扣均摊)。
@@ -899,19 +954,19 @@ export function normalizeBookingSubType(booking) {
899
954
  export function normalizeSubmitBooking(booking) {
900
955
  var rawMetadata = booking.metadata || {};
901
956
  var cleanMetadata = {};
902
- var _iterator6 = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
903
- _step6;
957
+ var _iterator8 = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
958
+ _step8;
904
959
  try {
905
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
906
- var key = _step6.value;
960
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
961
+ var key = _step8.value;
907
962
  if (rawMetadata[key] !== undefined) {
908
963
  cleanMetadata[key] = rawMetadata[key];
909
964
  }
910
965
  }
911
966
  } catch (err) {
912
- _iterator6.e(err);
967
+ _iterator8.e(err);
913
968
  } finally {
914
- _iterator6.f();
969
+ _iterator8.f();
915
970
  }
916
971
  if (cleanMetadata.holder_id === undefined) cleanMetadata.holder_id = null;
917
972
  var bookingRecord = booking;
@@ -1035,7 +1090,7 @@ export function buildSubmitPayload(params) {
1035
1090
  _totalRefundAmount = _ref29.total_refund_amount,
1036
1091
  _createDate = _ref29.create_date,
1037
1092
  _holderId = _ref29.holder_id,
1038
- tempOrderRest = _objectWithoutProperties(_ref29, _excluded3);
1093
+ tempOrderRest = _objectWithoutProperties(_ref29, _excluded4);
1039
1094
  var submitType = type !== null && type !== void 0 ? type : tempOrder.type;
1040
1095
  if (!submitType) {
1041
1096
  var _tempOrder$bookings;
@@ -1086,7 +1141,7 @@ export function buildSubmitPayload(params) {
1086
1141
  var _ref31 = tempOrder.metadata || {},
1087
1142
  _collectPax = _ref31.collect_pax,
1088
1143
  _tableOccupancyDuration = _ref31.table_occupancy_duration,
1089
- rest = _objectWithoutProperties(_ref31, _excluded4);
1144
+ rest = _objectWithoutProperties(_ref31, _excluded5);
1090
1145
  return _objectSpread({}, rest);
1091
1146
  }(),
1092
1147
  products: (tempOrder.products || []).map(function (product) {
@@ -1224,25 +1279,25 @@ export function clearTempOrderHolderAssignments(tempOrder) {
1224
1279
  target[key] = null;
1225
1280
  changed = true;
1226
1281
  };
1227
- var _iterator7 = _createForOfIteratorHelper(tempOrder.products || []),
1228
- _step7;
1282
+ var _iterator9 = _createForOfIteratorHelper(tempOrder.products || []),
1283
+ _step9;
1229
1284
  try {
1230
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1231
- var product = _step7.value;
1285
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1286
+ var product = _step9.value;
1232
1287
  if (product.metadata && _typeof(product.metadata) === 'object') {
1233
1288
  resetHolderField(product.metadata);
1234
1289
  }
1235
1290
  }
1236
1291
  } catch (err) {
1237
- _iterator7.e(err);
1292
+ _iterator9.e(err);
1238
1293
  } finally {
1239
- _iterator7.f();
1294
+ _iterator9.f();
1240
1295
  }
1241
- var _iterator8 = _createForOfIteratorHelper(tempOrder.bookings || []),
1242
- _step8;
1296
+ var _iterator10 = _createForOfIteratorHelper(tempOrder.bookings || []),
1297
+ _step10;
1243
1298
  try {
1244
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1245
- var booking = _step8.value;
1299
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1300
+ var booking = _step10.value;
1246
1301
  var bookingRecord = booking;
1247
1302
  if (booking.metadata && _typeof(booking.metadata) === 'object') {
1248
1303
  resetHolderField(booking.metadata);
@@ -1253,9 +1308,9 @@ export function clearTempOrderHolderAssignments(tempOrder) {
1253
1308
  }
1254
1309
  }
1255
1310
  } catch (err) {
1256
- _iterator8.e(err);
1311
+ _iterator10.e(err);
1257
1312
  } finally {
1258
- _iterator8.f();
1313
+ _iterator10.f();
1259
1314
  }
1260
1315
  var productsByUid = (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.productsByUid;
1261
1316
  if (productsByUid && _typeof(productsByUid) === 'object') {
@@ -46,6 +46,9 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
46
46
  protected hasManualDiscountSelection: boolean;
47
47
  private readonly reusedSharedSubModuleNames;
48
48
  private paymentMethodsCache;
49
+ private queuedAutoPaymentSync;
50
+ private autoPaymentSyncFlushing;
51
+ private autoPaymentSyncTimer;
49
52
  constructor(name?: string, version?: string);
50
53
  /**
51
54
  * 子类可覆盖此方法以追加/收敛要注册的子模块。
@@ -195,6 +198,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
195
198
  payments?: OrderPaymentSource[];
196
199
  paymentStatus?: BaseSalesPaymentStatus;
197
200
  smallTicketDataFlag?: number;
201
+ confirmPendingVoucherPayments?: boolean;
198
202
  enhancePayload?: SubmitPayloadEnhancer;
199
203
  }): Promise<T>;
200
204
  /**
@@ -207,12 +211,14 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
207
211
  payments?: OrderPaymentSource[];
208
212
  paymentStatus?: BaseSalesPaymentStatus;
209
213
  smallTicketDataFlag?: number;
214
+ confirmPendingVoucherPayments?: boolean;
210
215
  enhancePayload?: SubmitPayloadEnhancer;
211
216
  }): Promise<T>;
212
217
  submitTempOrderAsync<T = any>(params?: {
213
218
  payments?: OrderPaymentSource[];
214
219
  paymentStatus?: BaseSalesPaymentStatus;
215
220
  smallTicketDataFlag?: number;
221
+ confirmPendingVoucherPayments?: boolean;
216
222
  enhancePayload?: SubmitPayloadEnhancer;
217
223
  }): Promise<T>;
218
224
  printLocalOrderReceipt<T = any>(lookup?: BaseSalesPrintLocalOrderReceiptParams): Promise<T>;
@@ -222,6 +228,10 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
222
228
  getOrderPayments(): OrderPaymentData[];
223
229
  /** 覆盖当前订单支付项,内部由 OrderModule 清洗为 Sales 协议字段。 */
224
230
  setOrderPayments(payments: OrderPaymentSource[]): OrderPaymentData[];
231
+ private getPaymentStatusForSync;
232
+ private queueLatestAutoPaymentSync;
233
+ private scheduleQueuedAutoPaymentSyncFlush;
234
+ private flushQueuedAutoPaymentSync;
225
235
  /** 追加单个支付项到当前订单。 */
226
236
  addOrderPayment(payment: OrderPaymentSource): OrderPaymentData[];
227
237
  /** 更新当前订单中的指定支付项。 */
@@ -229,7 +239,11 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
229
239
  /** 删除当前订单中的指定支付项。 */
230
240
  deleteOrderPayment(paymentIdentity: string | number): OrderPaymentData[];
231
241
  /** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
232
- updateVoucherOrderPayments(payments: OrderPaymentSource[]): OrderPaymentData[];
242
+ updateVoucherOrderPayments(payments: OrderPaymentSource[], options?: {
243
+ status?: 'paid' | 'payment_pending';
244
+ }): OrderPaymentData[];
245
+ confirmPendingVoucherPayments(): OrderPaymentData[];
246
+ discardPendingVoucherPayments(): OrderPaymentData[];
233
247
  private getWalletProductList;
234
248
  initWalletData(params?: {
235
249
  order_wait_pay_amount?: number;