@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.
- package/dist/modules/Order/index.d.ts +17 -1
- package/dist/modules/Order/index.js +282 -121
- 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.js +83 -28
- package/dist/solution/BaseSales/index.d.ts +15 -1
- package/dist/solution/BaseSales/index.js +405 -260
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Order/index.d.ts +17 -1
- package/lib/modules/Order/index.js +205 -36
- 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.js +45 -2
- package/lib/solution/BaseSales/index.d.ts +15 -1
- package/lib/solution/BaseSales/index.js +105 -14
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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
|
+
});
|
|
@@ -380,6 +380,42 @@ function normalizeOrderProductDiscountList(discountList) {
|
|
|
380
380
|
return normalized;
|
|
381
381
|
});
|
|
382
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
|
+
}
|
|
383
419
|
function resolveManualOverrideLineOriginalPrice(params, fallbackCompositeOriginal) {
|
|
384
420
|
var _a, _b;
|
|
385
421
|
const metadata = params.metadata || {};
|
|
@@ -675,6 +711,10 @@ function formatSubmitBundleItems(bundle) {
|
|
|
675
711
|
return bundle.map((b) => {
|
|
676
712
|
const rawBundle = b && typeof b === "object" ? b : {};
|
|
677
713
|
const existedMetadata = rawBundle.metadata && typeof rawBundle.metadata === "object" ? rawBundle.metadata : {};
|
|
714
|
+
const {
|
|
715
|
+
custom_product_bundle_map_id: _customProductBundleMapId,
|
|
716
|
+
...submitMetadata
|
|
717
|
+
} = existedMetadata;
|
|
678
718
|
const sellingPrice = getBundleSellingMagnitude(rawBundle).toFixed(2);
|
|
679
719
|
const paymentPrice = rawBundle.bundle_payment_price !== void 0 && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== "" ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
|
|
680
720
|
const priceValue = rawBundle.price ?? rawBundle.custom_price ?? rawBundle.bundle_selling_price;
|
|
@@ -687,6 +727,8 @@ function formatSubmitBundleItems(bundle) {
|
|
|
687
727
|
0
|
|
688
728
|
);
|
|
689
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;
|
|
690
732
|
return {
|
|
691
733
|
is_charge_tax: rawBundle.is_charge_tax ?? 0,
|
|
692
734
|
bundle_variant_id: rawBundle.bundle_variant_id ?? 0,
|
|
@@ -704,7 +746,8 @@ function formatSubmitBundleItems(bundle) {
|
|
|
704
746
|
bundle_id: (rawBundle == null ? void 0 : rawBundle.bundle_id) ?? (rawBundle == null ? void 0 : rawBundle.id),
|
|
705
747
|
bundle_product_id: (rawBundle == null ? void 0 : rawBundle.bundle_product_id) ?? (rawBundle == null ? void 0 : rawBundle._bundle_product_id),
|
|
706
748
|
metadata: {
|
|
707
|
-
...
|
|
749
|
+
...submitMetadata,
|
|
750
|
+
...hasSubmitBundleDiscounts && bundleMapId !== void 0 ? { custom_product_bundle_map_id: bundleMapId } : {},
|
|
708
751
|
surcharge_fee: surchargeFee,
|
|
709
752
|
relation_surcharge_ids: relationSurchargeIds,
|
|
710
753
|
product_discount_difference: productDiscountDifference
|
|
@@ -769,7 +812,7 @@ function normalizeSubmitProduct(product) {
|
|
|
769
812
|
...bookingUid ? { booking_uid: bookingUid } : {},
|
|
770
813
|
product_quantity: toBundleNumber(num ?? submitProduct.product_quantity, 1),
|
|
771
814
|
product_sku: productSku,
|
|
772
|
-
discount_list:
|
|
815
|
+
discount_list: collectSubmitProductDiscountList(submitProduct),
|
|
773
816
|
product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
|
|
774
817
|
metadata: cleanMetadata,
|
|
775
818
|
// 出站兼容:后端消费 payment_price 字段(行 composite 已减整单折扣均摊)。
|
|
@@ -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[]
|
|
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;
|
|
@@ -156,6 +156,9 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
156
156
|
this.hasManualDiscountSelection = false;
|
|
157
157
|
this.reusedSharedSubModuleNames = /* @__PURE__ */ new Set();
|
|
158
158
|
this.paymentMethodsCache = [];
|
|
159
|
+
this.queuedAutoPaymentSync = false;
|
|
160
|
+
this.autoPaymentSyncFlushing = false;
|
|
161
|
+
this.autoPaymentSyncTimer = null;
|
|
159
162
|
}
|
|
160
163
|
/**
|
|
161
164
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
@@ -165,10 +168,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
165
168
|
return ["products", "order", "salesSummary", "schedule", "payment", "quotation"];
|
|
166
169
|
}
|
|
167
170
|
getReusableSharedSubModule(moduleName) {
|
|
168
|
-
var _a;
|
|
171
|
+
var _a, _b;
|
|
169
172
|
if (moduleName !== "schedule" && moduleName !== "quotation")
|
|
170
173
|
return null;
|
|
171
|
-
return ((_a = this.core) == null ? void 0 : _a.getModule(moduleName)) || null;
|
|
174
|
+
return ((_b = (_a = this.core) == null ? void 0 : _a.getModule) == null ? void 0 : _b.call(_a, moduleName)) || null;
|
|
172
175
|
}
|
|
173
176
|
isScheduleListLoaded(scheduleModule) {
|
|
174
177
|
if (!scheduleModule)
|
|
@@ -1283,6 +1286,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1283
1286
|
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
1284
1287
|
d.isSelected = false;
|
|
1285
1288
|
d.isManualSelect = true;
|
|
1289
|
+
d.appliedProductDetails = [];
|
|
1286
1290
|
}
|
|
1287
1291
|
}
|
|
1288
1292
|
}
|
|
@@ -1291,16 +1295,32 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1291
1295
|
const selectedResourceIds = new Set(
|
|
1292
1296
|
nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
|
|
1293
1297
|
);
|
|
1298
|
+
const filterSelectedDiscountDetails = (discountList) => (discountList || []).filter((pd) => {
|
|
1299
|
+
var _a2;
|
|
1300
|
+
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
1301
|
+
return rid != null && selectedResourceIds.has(rid);
|
|
1302
|
+
});
|
|
1294
1303
|
for (const product of tempOrder.products) {
|
|
1295
1304
|
const productUid = (_c = product.metadata) == null ? void 0 : _c.unique_identification_number;
|
|
1296
1305
|
const runtimeOrigin = productUid ? (_f = (_e = (_d = tempOrder._extend) == null ? void 0 : _d.productsByUid) == null ? void 0 : _e[productUid]) == null ? void 0 : _f.origin : void 0;
|
|
1297
1306
|
if ((runtimeOrigin == null ? void 0 : runtimeOrigin.isManualDiscount) || isBaseSalesManualProductDiscountProduct(product))
|
|
1298
1307
|
continue;
|
|
1299
|
-
product.discount_list = (product.discount_list
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1308
|
+
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
1309
|
+
if (Array.isArray(product.product_bundle)) {
|
|
1310
|
+
product.product_bundle = product.product_bundle.map((bundle) => {
|
|
1311
|
+
const nextBundleDiscountList = filterSelectedDiscountDetails(bundle == null ? void 0 : bundle.discount_list);
|
|
1312
|
+
const shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
1313
|
+
const restoredBundlePrice = (bundle == null ? void 0 : bundle.original_price) ?? (bundle == null ? void 0 : bundle.product_price) ?? (bundle == null ? void 0 : bundle.price);
|
|
1314
|
+
return {
|
|
1315
|
+
...bundle,
|
|
1316
|
+
...shouldRestoreBundlePrice ? {
|
|
1317
|
+
price: restoredBundlePrice,
|
|
1318
|
+
bundle_selling_price: restoredBundlePrice
|
|
1319
|
+
} : {},
|
|
1320
|
+
discount_list: nextBundleDiscountList
|
|
1321
|
+
};
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1304
1324
|
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
1305
1325
|
(sum, pd) => sum + (pd.amount || 0),
|
|
1306
1326
|
0
|
|
@@ -1389,6 +1409,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1389
1409
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
1390
1410
|
...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
|
|
1391
1411
|
...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
|
|
1412
|
+
...(params == null ? void 0 : params.confirmPendingVoucherPayments) !== void 0 ? { confirmPendingVoucherPayments: params.confirmPendingVoucherPayments } : {},
|
|
1392
1413
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1393
1414
|
};
|
|
1394
1415
|
return this.store.order.submitTempOrder(submitParams);
|
|
@@ -1408,6 +1429,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1408
1429
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
1409
1430
|
...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
|
|
1410
1431
|
...(params == null ? void 0 : params.smallTicketDataFlag) !== void 0 ? { smallTicketDataFlag: params.smallTicketDataFlag } : {},
|
|
1432
|
+
...(params == null ? void 0 : params.confirmPendingVoucherPayments) !== void 0 ? { confirmPendingVoucherPayments: params.confirmPendingVoucherPayments } : {},
|
|
1411
1433
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1412
1434
|
};
|
|
1413
1435
|
return this.store.order.submitTempOrderAsync(submitParams);
|
|
@@ -1476,6 +1498,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1476
1498
|
};
|
|
1477
1499
|
const syncState = this.store.order.getOrderSyncState();
|
|
1478
1500
|
if (params.submitWhenPaid && syncState === "submitting") {
|
|
1501
|
+
this.queueLatestAutoPaymentSync();
|
|
1479
1502
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
1480
1503
|
}
|
|
1481
1504
|
const payments = params.payments || [];
|
|
@@ -1508,6 +1531,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1508
1531
|
if (syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid) {
|
|
1509
1532
|
await this.effectsEmit(import_types.BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
1510
1533
|
}
|
|
1534
|
+
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
1511
1535
|
return syncResult;
|
|
1512
1536
|
} catch (error) {
|
|
1513
1537
|
await this.effectsEmit(import_types.BaseSalesHookNames.onPaymentSyncEnd, {
|
|
@@ -1518,6 +1542,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1518
1542
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
1519
1543
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1520
1544
|
});
|
|
1545
|
+
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
1521
1546
|
throw error;
|
|
1522
1547
|
}
|
|
1523
1548
|
}
|
|
@@ -1534,6 +1559,61 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1534
1559
|
throw new Error("order 模块未初始化");
|
|
1535
1560
|
return this.store.order.setOrderPayments(payments);
|
|
1536
1561
|
}
|
|
1562
|
+
getPaymentStatusForSync(payments) {
|
|
1563
|
+
const order = this.store.order;
|
|
1564
|
+
if (!order)
|
|
1565
|
+
throw new Error("order 模块未初始化");
|
|
1566
|
+
const completion = order.getPaymentCompletion(payments);
|
|
1567
|
+
return completion.isOrderFullyPaid ? "paid" : "partially_paid";
|
|
1568
|
+
}
|
|
1569
|
+
queueLatestAutoPaymentSync() {
|
|
1570
|
+
this.queuedAutoPaymentSync = true;
|
|
1571
|
+
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
1572
|
+
}
|
|
1573
|
+
scheduleQueuedAutoPaymentSyncFlush(delay = 100) {
|
|
1574
|
+
if (!this.queuedAutoPaymentSync)
|
|
1575
|
+
return;
|
|
1576
|
+
if (this.autoPaymentSyncTimer)
|
|
1577
|
+
return;
|
|
1578
|
+
this.autoPaymentSyncTimer = setTimeout(() => {
|
|
1579
|
+
this.autoPaymentSyncTimer = null;
|
|
1580
|
+
void this.flushQueuedAutoPaymentSync();
|
|
1581
|
+
}, delay);
|
|
1582
|
+
}
|
|
1583
|
+
async flushQueuedAutoPaymentSync() {
|
|
1584
|
+
if (!this.store.order)
|
|
1585
|
+
return;
|
|
1586
|
+
if (!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)
|
|
1587
|
+
return;
|
|
1588
|
+
if (this.store.order.getOrderSyncState() === "submitting") {
|
|
1589
|
+
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
1590
|
+
return;
|
|
1591
|
+
}
|
|
1592
|
+
this.autoPaymentSyncFlushing = true;
|
|
1593
|
+
try {
|
|
1594
|
+
while (this.queuedAutoPaymentSync) {
|
|
1595
|
+
this.queuedAutoPaymentSync = false;
|
|
1596
|
+
const payments = this.store.order.getOrderPayments();
|
|
1597
|
+
if (!payments.length)
|
|
1598
|
+
continue;
|
|
1599
|
+
await this.syncPaymentsToOrder({
|
|
1600
|
+
payments,
|
|
1601
|
+
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
1602
|
+
submitWhenPaid: true,
|
|
1603
|
+
smallTicketDataFlag: 1
|
|
1604
|
+
});
|
|
1605
|
+
}
|
|
1606
|
+
} catch (error) {
|
|
1607
|
+
this.logError("queued auto sync payments failed", {
|
|
1608
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1609
|
+
});
|
|
1610
|
+
} finally {
|
|
1611
|
+
this.autoPaymentSyncFlushing = false;
|
|
1612
|
+
if (this.queuedAutoPaymentSync) {
|
|
1613
|
+
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1537
1617
|
/** 追加单个支付项到当前订单。 */
|
|
1538
1618
|
addOrderPayment(payment) {
|
|
1539
1619
|
var _a;
|
|
@@ -1569,12 +1649,14 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1569
1649
|
});
|
|
1570
1650
|
const amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
1571
1651
|
const syncState = this.store.order.getOrderSyncState();
|
|
1572
|
-
if (amountSnapshot
|
|
1573
|
-
|
|
1574
|
-
|
|
1652
|
+
if (amountSnapshot) {
|
|
1653
|
+
if (syncState === "submitting") {
|
|
1654
|
+
this.queueLatestAutoPaymentSync();
|
|
1655
|
+
return payments;
|
|
1656
|
+
}
|
|
1575
1657
|
void this.syncPaymentsToOrder({
|
|
1576
1658
|
payments,
|
|
1577
|
-
paymentStatus,
|
|
1659
|
+
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
1578
1660
|
submitWhenPaid: true,
|
|
1579
1661
|
smallTicketDataFlag: 1
|
|
1580
1662
|
}).catch((error) => {
|
|
@@ -1582,7 +1664,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1582
1664
|
error: error instanceof Error ? error.message : String(error)
|
|
1583
1665
|
});
|
|
1584
1666
|
});
|
|
1585
|
-
} else {
|
|
1586
1667
|
}
|
|
1587
1668
|
return payments;
|
|
1588
1669
|
}
|
|
@@ -1599,10 +1680,20 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1599
1680
|
return this.store.order.deleteOrderPayment(paymentIdentity);
|
|
1600
1681
|
}
|
|
1601
1682
|
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
1602
|
-
updateVoucherOrderPayments(payments) {
|
|
1683
|
+
updateVoucherOrderPayments(payments, options) {
|
|
1684
|
+
if (!this.store.order)
|
|
1685
|
+
throw new Error("order 模块未初始化");
|
|
1686
|
+
return this.store.order.updateVoucherOrderPayments(payments, options);
|
|
1687
|
+
}
|
|
1688
|
+
confirmPendingVoucherPayments() {
|
|
1689
|
+
if (!this.store.order)
|
|
1690
|
+
throw new Error("order 模块未初始化");
|
|
1691
|
+
return this.store.order.confirmPendingVoucherPayments();
|
|
1692
|
+
}
|
|
1693
|
+
discardPendingVoucherPayments() {
|
|
1603
1694
|
if (!this.store.order)
|
|
1604
1695
|
throw new Error("order 模块未初始化");
|
|
1605
|
-
return this.store.order.
|
|
1696
|
+
return this.store.order.discardPendingVoucherPayments();
|
|
1606
1697
|
}
|
|
1607
1698
|
getWalletProductList() {
|
|
1608
1699
|
var _a, _b, _c;
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 6 | 3 | 4 | 5;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|