@pisell/pisellos 2.3.6 → 2.3.8
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.
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +17 -13
- package/dist/modules/Order/index.d.ts +18 -2
- package/dist/modules/Order/index.js +392 -222
- package/dist/modules/Order/types.d.ts +15 -2
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
- package/dist/modules/Order/utils.d.ts +4 -0
- package/dist/modules/Order/utils.js +114 -28
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.d.ts +3 -3
- package/dist/modules/Rules/index.js +8 -3
- package/dist/modules/Rules/types.d.ts +2 -1
- package/dist/server/index.js +1 -0
- package/dist/server/modules/order/index.d.ts +4 -4
- package/dist/server/modules/order/index.js +4 -4
- package/dist/solution/BaseSales/index.d.ts +8 -1
- package/dist/solution/BaseSales/index.js +145 -104
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +11 -1
- package/lib/modules/Order/index.d.ts +18 -2
- package/lib/modules/Order/index.js +229 -40
- package/lib/modules/Order/types.d.ts +15 -2
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
- package/lib/modules/Order/utils.d.ts +4 -0
- package/lib/modules/Order/utils.js +84 -2
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.d.ts +3 -3
- package/lib/modules/Rules/index.js +4 -3
- package/lib/modules/Rules/types.d.ts +2 -1
- package/lib/server/modules/order/index.d.ts +4 -4
- package/lib/server/modules/order/index.js +4 -4
- package/lib/solution/BaseSales/index.d.ts +8 -1
- package/lib/solution/BaseSales/index.js +58 -22
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -5
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- 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,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[]
|
|
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
|
+
}
|
|
@@ -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
|
*
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
var _excluded = ["
|
|
2
|
-
_excluded2 = ["
|
|
3
|
-
_excluded3 = ["
|
|
4
|
-
_excluded4 = ["
|
|
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({},
|
|
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,
|
|
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,
|
|
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:
|
|
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
|
|
903
|
-
|
|
957
|
+
var _iterator8 = _createForOfIteratorHelper(SUBMIT_BOOKING_METADATA_WHITELIST),
|
|
958
|
+
_step8;
|
|
904
959
|
try {
|
|
905
|
-
for (
|
|
906
|
-
var key =
|
|
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
|
-
|
|
967
|
+
_iterator8.e(err);
|
|
913
968
|
} finally {
|
|
914
|
-
|
|
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,
|
|
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,
|
|
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
|
|
1228
|
-
|
|
1282
|
+
var _iterator9 = _createForOfIteratorHelper(tempOrder.products || []),
|
|
1283
|
+
_step9;
|
|
1229
1284
|
try {
|
|
1230
|
-
for (
|
|
1231
|
-
var product =
|
|
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
|
-
|
|
1292
|
+
_iterator9.e(err);
|
|
1238
1293
|
} finally {
|
|
1239
|
-
|
|
1294
|
+
_iterator9.f();
|
|
1240
1295
|
}
|
|
1241
|
-
var
|
|
1242
|
-
|
|
1296
|
+
var _iterator10 = _createForOfIteratorHelper(tempOrder.bookings || []),
|
|
1297
|
+
_step10;
|
|
1243
1298
|
try {
|
|
1244
|
-
for (
|
|
1245
|
-
var booking =
|
|
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
|
-
|
|
1311
|
+
_iterator10.e(err);
|
|
1257
1312
|
} finally {
|
|
1258
|
-
|
|
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') {
|
|
@@ -1287,6 +1342,37 @@ export function getOrderProductLineUid(product) {
|
|
|
1287
1342
|
if (uid === undefined || uid === null || uid === '') return null;
|
|
1288
1343
|
return String(uid);
|
|
1289
1344
|
}
|
|
1345
|
+
export function getRuntimeProductOrigin(tempOrder, product) {
|
|
1346
|
+
var _tempOrder$_extend2, _tempOrder$_extend3;
|
|
1347
|
+
var uid = getOrderProductLineUid(product);
|
|
1348
|
+
if (uid && tempOrder !== null && tempOrder !== void 0 && (_tempOrder$_extend2 = tempOrder._extend) !== null && _tempOrder$_extend2 !== void 0 && (_tempOrder$_extend2 = _tempOrder$_extend2.productsByUid) !== null && _tempOrder$_extend2 !== void 0 && (_tempOrder$_extend2 = _tempOrder$_extend2[uid]) !== null && _tempOrder$_extend2 !== void 0 && _tempOrder$_extend2.origin) {
|
|
1349
|
+
return tempOrder._extend.productsByUid[uid].origin;
|
|
1350
|
+
}
|
|
1351
|
+
var matchedProduct = ((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || []).find(function (item) {
|
|
1352
|
+
var _ref32, _item$product_id, _ref33, _product$product_id;
|
|
1353
|
+
return item === product || getOrderProductLineUid(item) === uid || String((_ref32 = (_item$product_id = item === null || item === void 0 ? void 0 : item.product_id) !== null && _item$product_id !== void 0 ? _item$product_id : item === null || item === void 0 ? void 0 : item.id) !== null && _ref32 !== void 0 ? _ref32 : '') === String((_ref33 = (_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product === null || product === void 0 ? void 0 : product.id) !== null && _ref33 !== void 0 ? _ref33 : '');
|
|
1354
|
+
});
|
|
1355
|
+
var matchedUid = matchedProduct ? getOrderProductLineUid(matchedProduct) : '';
|
|
1356
|
+
return matchedUid ? (tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[matchedUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin) || null : null;
|
|
1357
|
+
}
|
|
1358
|
+
export function isHolderConfigRequired(holderConfig) {
|
|
1359
|
+
if (!holderConfig || _typeof(holderConfig) !== 'object') return false;
|
|
1360
|
+
if (holderConfig.status === 'disable') return false;
|
|
1361
|
+
return Number(holderConfig.required) === 1;
|
|
1362
|
+
}
|
|
1363
|
+
export function productRequiresFormSubject(tempOrder, product) {
|
|
1364
|
+
var runtimeOrigin = getRuntimeProductOrigin(tempOrder, product);
|
|
1365
|
+
return isHolderConfigRequired(product === null || product === void 0 ? void 0 : product.holder_config) || isHolderConfigRequired(runtimeOrigin === null || runtimeOrigin === void 0 ? void 0 : runtimeOrigin.holder_config);
|
|
1366
|
+
}
|
|
1367
|
+
export function resolveIsFormSubject(tempOrder, product) {
|
|
1368
|
+
var _tempOrder$holder;
|
|
1369
|
+
// 旧版预约维度的 holder 类型仍然生效;新版则从当前商品 holder_config 判断。
|
|
1370
|
+
if ((tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.type) === 'form') return true;
|
|
1371
|
+
if (product) return productRequiresFormSubject(tempOrder, product);
|
|
1372
|
+
return ((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || []).some(function (item) {
|
|
1373
|
+
return productRequiresFormSubject(tempOrder, item);
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1290
1376
|
|
|
1291
1377
|
/**
|
|
1292
1378
|
* 判断展示字段是否为空(含 i18n 对象全空)。
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -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:
|
|
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:
|
|
46
|
+
isFormSubject: RulesFormSubject;
|
|
47
47
|
orderTotalAmount: number;
|
|
48
48
|
}, options?: {
|
|
49
49
|
isSelected?: boolean;
|
|
@@ -118,7 +118,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
118
118
|
// 非表单类型 holder 视为匹配
|
|
119
119
|
if (((_discount$holder = discount.holder) === null || _discount$holder === void 0 ? void 0 : _discount$holder.holder_type) !== 'form') return true;
|
|
120
120
|
// 主预约holder, 目前(20251124)默认只考虑单个holder的情况
|
|
121
|
-
|
|
121
|
+
// 旧版 holders[0].form_record_id 新版 holders[0]
|
|
122
|
+
var orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id || holders[0] : undefined;
|
|
122
123
|
var productHolderId = Array.isArray(product.holder_id) ? product.holder_id[0] : product.holder_id;
|
|
123
124
|
// 商品不需要选holder,则不对比holder,直接返回true,
|
|
124
125
|
if (!product.isNeedHolder) return true;
|
|
@@ -323,6 +324,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
323
324
|
holders = _ref2.holders,
|
|
324
325
|
isFormSubject = _ref2.isFormSubject,
|
|
325
326
|
orderTotalAmount = _ref2.orderTotalAmount;
|
|
327
|
+
var resolveIsFormSubject = function resolveIsFormSubject(product) {
|
|
328
|
+
return typeof isFormSubject === 'function' ? Boolean(isFormSubject(product)) : Boolean(isFormSubject);
|
|
329
|
+
};
|
|
330
|
+
|
|
326
331
|
// 识别出来是不是在编辑的界面里又新增了商品
|
|
327
332
|
// 这种情况下,如果有可用的优惠券,也会自动勾选上
|
|
328
333
|
var isEditModeAddNewProduct = productList.find(function (n) {
|
|
@@ -885,7 +890,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
885
890
|
// 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
|
|
886
891
|
var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
|
|
887
892
|
var isHolderMatch = _this3.checkHolderMatch(discount, {
|
|
888
|
-
isNeedHolder:
|
|
893
|
+
isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
|
|
889
894
|
holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
890
895
|
}, holders);
|
|
891
896
|
var timeLimit = true;
|
|
@@ -1088,7 +1093,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1088
1093
|
// 拿到discount配置的holder信息 product信息 product.holder 不可用return false
|
|
1089
1094
|
var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
|
|
1090
1095
|
var isHolderMatch = _this3.checkHolderMatch(discount, {
|
|
1091
|
-
isNeedHolder:
|
|
1096
|
+
isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
|
|
1092
1097
|
holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
1093
1098
|
}, holders);
|
|
1094
1099
|
// 如果 holder 不匹配,则不适用
|
|
@@ -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:
|
|
35
|
+
isFormSubject: RulesFormSubject;
|
|
35
36
|
orderTotalAmount: number;
|
|
36
37
|
}) => DiscountResult;
|
|
37
38
|
}
|
package/dist/server/index.js
CHANGED
|
@@ -4038,6 +4038,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4038
4038
|
shop_order_number: next.shop_order_number,
|
|
4039
4039
|
shop_full_order_number: next.shop_full_order_number
|
|
4040
4040
|
});
|
|
4041
|
+
// 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
|
|
4041
4042
|
return _context42.abrupt("return", next);
|
|
4042
4043
|
case 28:
|
|
4043
4044
|
_context42.prev = 28;
|
|
@@ -31,10 +31,10 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
31
31
|
private emitOrdersChanged;
|
|
32
32
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
33
33
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
* 记录信息日志
|
|
35
|
+
* @param title 日志标题
|
|
36
|
+
* @param metadata 日志元数据
|
|
37
|
+
*/
|
|
38
38
|
private logInfo;
|
|
39
39
|
/**
|
|
40
40
|
* 记录错误日志
|
|
@@ -177,10 +177,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
177
177
|
return initialize;
|
|
178
178
|
}()
|
|
179
179
|
/**
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
* 记录信息日志
|
|
181
|
+
* @param title 日志标题
|
|
182
|
+
* @param metadata 日志元数据
|
|
183
|
+
*/
|
|
184
184
|
}, {
|
|
185
185
|
key: "logInfo",
|
|
186
186
|
value: function logInfo(title, metadata) {
|
|
@@ -195,6 +195,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
195
195
|
payments?: OrderPaymentSource[];
|
|
196
196
|
paymentStatus?: BaseSalesPaymentStatus;
|
|
197
197
|
smallTicketDataFlag?: number;
|
|
198
|
+
confirmPendingVoucherPayments?: boolean;
|
|
198
199
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
199
200
|
}): Promise<T>;
|
|
200
201
|
/**
|
|
@@ -207,12 +208,14 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
207
208
|
payments?: OrderPaymentSource[];
|
|
208
209
|
paymentStatus?: BaseSalesPaymentStatus;
|
|
209
210
|
smallTicketDataFlag?: number;
|
|
211
|
+
confirmPendingVoucherPayments?: boolean;
|
|
210
212
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
211
213
|
}): Promise<T>;
|
|
212
214
|
submitTempOrderAsync<T = any>(params?: {
|
|
213
215
|
payments?: OrderPaymentSource[];
|
|
214
216
|
paymentStatus?: BaseSalesPaymentStatus;
|
|
215
217
|
smallTicketDataFlag?: number;
|
|
218
|
+
confirmPendingVoucherPayments?: boolean;
|
|
216
219
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
217
220
|
}): Promise<T>;
|
|
218
221
|
printLocalOrderReceipt<T = any>(lookup?: BaseSalesPrintLocalOrderReceiptParams): Promise<T>;
|
|
@@ -229,7 +232,11 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
229
232
|
/** 删除当前订单中的指定支付项。 */
|
|
230
233
|
deleteOrderPayment(paymentIdentity: string | number): OrderPaymentData[];
|
|
231
234
|
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
232
|
-
updateVoucherOrderPayments(payments: OrderPaymentSource[]
|
|
235
|
+
updateVoucherOrderPayments(payments: OrderPaymentSource[], options?: {
|
|
236
|
+
status?: 'paid' | 'payment_pending';
|
|
237
|
+
}): OrderPaymentData[];
|
|
238
|
+
confirmPendingVoucherPayments(): OrderPaymentData[];
|
|
239
|
+
discardPendingVoucherPayments(): OrderPaymentData[];
|
|
233
240
|
private getWalletProductList;
|
|
234
241
|
initWalletData(params?: {
|
|
235
242
|
order_wait_pay_amount?: number;
|