@pisell/pisellos 2.2.164 → 2.2.166
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/buildNormalProductCacheItemFromOrderLine.js +45 -15
- package/dist/modules/Order/index.d.ts +10 -3
- package/dist/modules/Order/index.js +275 -142
- package/dist/modules/Order/types.d.ts +9 -2
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +13 -0
- package/dist/modules/Order/utils.js +69 -15
- package/dist/server/index.js +1 -0
- package/dist/solution/BaseSales/index.d.ts +9 -1
- package/dist/solution/BaseSales/index.js +378 -241
- package/dist/solution/BaseSales/types.d.ts +3 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +33 -14
- package/dist/solution/BaseSales/utils.js +36 -7
- package/dist/solution/BookingTicket/index.d.ts +3 -0
- package/dist/solution/BookingTicket/index.js +170 -86
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +4 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.js +37 -19
- package/dist/solution/ScanOrder/utils.js +36 -7
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +35 -9
- package/lib/modules/Order/index.d.ts +10 -3
- package/lib/modules/Order/index.js +107 -4
- package/lib/modules/Order/types.d.ts +9 -2
- package/lib/modules/Order/utils.d.ts +13 -0
- package/lib/modules/Order/utils.js +57 -9
- package/lib/server/index.js +1 -0
- package/lib/solution/BaseSales/index.d.ts +9 -1
- package/lib/solution/BaseSales/index.js +71 -3
- package/lib/solution/BaseSales/types.d.ts +3 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +31 -10
- package/lib/solution/BaseSales/utils.js +37 -5
- package/lib/solution/BookingTicket/index.d.ts +3 -0
- package/lib/solution/BookingTicket/index.js +57 -6
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +4 -2
- package/lib/solution/BookingTicket/utils/addProductDecision.js +28 -12
- package/lib/solution/ScanOrder/utils.js +37 -5
- package/package.json +1 -1
|
@@ -401,6 +401,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
401
401
|
throw error;
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
|
+
updateRemoteOrderNote(orderId, note) {
|
|
405
|
+
if (!this.store.order)
|
|
406
|
+
throw new Error("order 模块未初始化");
|
|
407
|
+
this.store.order.syncTempOrderNoteToRemote(orderId, note);
|
|
408
|
+
}
|
|
404
409
|
updateTempOrderShopDiscount(amount) {
|
|
405
410
|
if (!this.store.order)
|
|
406
411
|
throw new Error("order 模块未初始化");
|
|
@@ -444,6 +449,37 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
444
449
|
throw new Error("scanOrder 解决方案需要 order 模块支持");
|
|
445
450
|
}
|
|
446
451
|
const tempOrder = this.store.order.restoreOrder();
|
|
452
|
+
this.currentSalesDetail = null;
|
|
453
|
+
await this.effectsEmit("onTempOrderReplaced", { tempOrder });
|
|
454
|
+
if (this.syncAppDataToTempOrder(tempOrder)) {
|
|
455
|
+
this.store.order.persistTempOrder();
|
|
456
|
+
await this.store.order.saveDraft();
|
|
457
|
+
}
|
|
458
|
+
return tempOrder;
|
|
459
|
+
} catch (error) {
|
|
460
|
+
throw error;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* 仅清空 tempOrder 购物车行(products / bookings / discount_list)。
|
|
465
|
+
* 同步清空内存中的 salesDetail 商品/预约视图,避免编辑态仍读到旧 bookings。
|
|
466
|
+
*/
|
|
467
|
+
async clearOrderCartLines() {
|
|
468
|
+
try {
|
|
469
|
+
if (!this.store.order)
|
|
470
|
+
throw new Error("order 模块未初始化");
|
|
471
|
+
const tempOrder = await this.store.order.clearOrderCartLines();
|
|
472
|
+
if (this.currentSalesDetail) {
|
|
473
|
+
this.currentSalesDetail = {
|
|
474
|
+
...this.currentSalesDetail,
|
|
475
|
+
products: [],
|
|
476
|
+
bookings: [],
|
|
477
|
+
rootBooking: null,
|
|
478
|
+
bookingsByProductUid: {},
|
|
479
|
+
discount_list: []
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
await this.effectsEmit("onTempOrderReplaced", { tempOrder });
|
|
447
483
|
if (this.syncAppDataToTempOrder(tempOrder)) {
|
|
448
484
|
this.store.order.persistTempOrder();
|
|
449
485
|
await this.store.order.saveDraft();
|
|
@@ -472,6 +508,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
472
508
|
getHistoricalProductDiscountList(products) {
|
|
473
509
|
const historyDiscountList = [];
|
|
474
510
|
products.forEach((item) => {
|
|
511
|
+
if (!this.isPersistedOrderProduct(item))
|
|
512
|
+
return;
|
|
475
513
|
(item.discount_list || []).forEach((discount) => {
|
|
476
514
|
var _a, _b, _c, _d, _e, _f;
|
|
477
515
|
const discountId = ((_a = discount.discount) == null ? void 0 : _a.resource_id) || discount.id;
|
|
@@ -506,6 +544,14 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
506
544
|
});
|
|
507
545
|
return historyDiscountList;
|
|
508
546
|
}
|
|
547
|
+
isPersistedOrderProduct(product) {
|
|
548
|
+
const orderDetailId = product.order_detail_id ?? product.orderDetailId;
|
|
549
|
+
if (orderDetailId !== void 0 && orderDetailId !== null && orderDetailId !== "") {
|
|
550
|
+
return true;
|
|
551
|
+
}
|
|
552
|
+
const bookingId = product.booking_id ?? product.bookingId;
|
|
553
|
+
return bookingId !== void 0 && bookingId !== null && bookingId !== "";
|
|
554
|
+
}
|
|
509
555
|
mergeHistoricalDiscountList(discountList, products) {
|
|
510
556
|
const historyDiscountList = this.getHistoricalProductDiscountList(products);
|
|
511
557
|
const historyIds = new Set(historyDiscountList.map((discount) => discount.id));
|
|
@@ -564,6 +610,12 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
564
610
|
}
|
|
565
611
|
}
|
|
566
612
|
this.store.order.persistTempOrder();
|
|
613
|
+
await this.effectsEmit("onDiscountApplied", {
|
|
614
|
+
productList: tempOrder.products || [],
|
|
615
|
+
discountList: nextDiscountList,
|
|
616
|
+
selectedDiscountList: tempOrder.discount_list || [],
|
|
617
|
+
tempOrder
|
|
618
|
+
});
|
|
567
619
|
return {
|
|
568
620
|
productList: tempOrder.products || [],
|
|
569
621
|
discountList: nextDiscountList
|
|
@@ -791,7 +843,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
791
843
|
async syncPaymentsToOrder(params) {
|
|
792
844
|
if (!this.store.order)
|
|
793
845
|
throw new Error("order 模块未初始化");
|
|
794
|
-
|
|
846
|
+
const channel = params.channel ?? this.getSubmitOrderSalesChannel();
|
|
847
|
+
return this.store.order.syncPaymentsToOrder({
|
|
848
|
+
...params,
|
|
849
|
+
...channel !== void 0 ? { channel } : {}
|
|
850
|
+
});
|
|
795
851
|
}
|
|
796
852
|
/** 读取当前 BaseSales 订单上下文中的 Sales 协议支付项。 */
|
|
797
853
|
getOrderPayments() {
|
|
@@ -858,8 +914,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
858
914
|
const bundleMetadata = bundle.metadata || {};
|
|
859
915
|
return {
|
|
860
916
|
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
861
|
-
|
|
862
|
-
|
|
917
|
+
// 套餐子项在 tempOrder 上常为 id(如 1718),prepare/deduction 协议要求 bundle_id
|
|
918
|
+
bundle_id: bundle.bundle_id ?? bundle.id,
|
|
919
|
+
bundle_product_id: bundle.bundle_product_id ?? bundle._bundle_product_id,
|
|
920
|
+
bundle_group_id: bundle.bundle_group_id ?? bundle.group_id,
|
|
863
921
|
bundle_variant_id: bundle.bundle_variant_id,
|
|
864
922
|
price_type: bundle.price_type,
|
|
865
923
|
price_type_ext: bundle.price_type_ext,
|
|
@@ -1032,6 +1090,16 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1032
1090
|
throw error;
|
|
1033
1091
|
}
|
|
1034
1092
|
}
|
|
1093
|
+
async updateOrderProductQuantity(params) {
|
|
1094
|
+
try {
|
|
1095
|
+
if (!this.store.order)
|
|
1096
|
+
throw new Error("order 模块未初始化");
|
|
1097
|
+
const products = await this.store.order.updateOrderProductQuantity(params);
|
|
1098
|
+
return products;
|
|
1099
|
+
} catch (error) {
|
|
1100
|
+
throw error;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1035
1103
|
updateOrderBooking(params) {
|
|
1036
1104
|
try {
|
|
1037
1105
|
if (!this.store.order)
|
|
@@ -42,6 +42,9 @@ export interface BaseSalesOrderProductIdentity {
|
|
|
42
42
|
product_option_item?: any[];
|
|
43
43
|
product_bundle?: any[];
|
|
44
44
|
}
|
|
45
|
+
export interface BaseSalesUpdateOrderProductQuantityParams extends BaseSalesOrderProductIdentity {
|
|
46
|
+
num: number;
|
|
47
|
+
}
|
|
45
48
|
export interface BaseSalesOrderProduct extends BaseSalesOrderProductIdentity {
|
|
46
49
|
order_detail_id: number | null;
|
|
47
50
|
num: number;
|
|
@@ -62,13 +62,23 @@ function normalizeOptionItems(optionItems) {
|
|
|
62
62
|
};
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function normalizeBundleItems(bundleItems) {
|
|
65
|
+
function normalizeBundleItems(bundleItems, preferPriceField = false) {
|
|
66
66
|
if (!Array.isArray(bundleItems))
|
|
67
67
|
return [];
|
|
68
|
-
return bundleItems.map((bundleItem) =>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
return bundleItems.map((bundleItem) => {
|
|
69
|
+
const unitSelling = preferPriceField ? bundleItem.price ?? bundleItem.bundle_selling_price ?? bundleItem.custom_price ?? bundleItem.product_price ?? "0" : bundleItem.bundle_selling_price ?? bundleItem.price ?? bundleItem.custom_price ?? bundleItem.product_price ?? "0";
|
|
70
|
+
const unitStr = toPriceString(unitSelling, "0.00");
|
|
71
|
+
const num = toSafePositiveInt((bundleItem == null ? void 0 : bundleItem.num) ?? (bundleItem == null ? void 0 : bundleItem.quantity), 1);
|
|
72
|
+
return {
|
|
73
|
+
...bundleItem,
|
|
74
|
+
num,
|
|
75
|
+
quantity: (bundleItem == null ? void 0 : bundleItem.quantity) ?? num,
|
|
76
|
+
price: bundleItem.price ?? unitStr,
|
|
77
|
+
bundle_selling_price: unitStr,
|
|
78
|
+
original_price: bundleItem.original_price ?? bundleItem.product_price ?? bundleItem.price ?? unitStr,
|
|
79
|
+
option: normalizeOptionItems(bundleItem == null ? void 0 : bundleItem.option)
|
|
80
|
+
};
|
|
81
|
+
});
|
|
72
82
|
}
|
|
73
83
|
function findVariantById(origin, variantId) {
|
|
74
84
|
if (!origin || !variantId || variantId <= 0)
|
|
@@ -77,7 +87,7 @@ function findVariantById(origin, variantId) {
|
|
|
77
87
|
return variants.find((variant) => Number(variant == null ? void 0 : variant.id) === variantId) || null;
|
|
78
88
|
}
|
|
79
89
|
function transformBaseProductToOrderProduct(params) {
|
|
80
|
-
var _a, _b;
|
|
90
|
+
var _a, _b, _c;
|
|
81
91
|
const { payload, fallbackProductId = null } = params;
|
|
82
92
|
if (!payload || typeof payload !== "object")
|
|
83
93
|
return null;
|
|
@@ -101,11 +111,17 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
101
111
|
payload.price ?? payload.selling_price ?? (matchedVariant == null ? void 0 : matchedVariant.price) ?? (matchedVariant == null ? void 0 : matchedVariant.base_price) ?? (origin == null ? void 0 : origin.price) ?? (origin == null ? void 0 : origin.base_price) ?? (sourceProduct == null ? void 0 : sourceProduct.price) ?? (sourceProduct == null ? void 0 : sourceProduct.selling_price) ?? (sourceProduct == null ? void 0 : sourceProduct.base_price),
|
|
102
112
|
"0.00"
|
|
103
113
|
);
|
|
114
|
+
const lineCompositeTotal = toPriceString(
|
|
115
|
+
payload.line_total ?? payload.total ?? ((_c = payload._extend) == null ? void 0 : _c.total),
|
|
116
|
+
sourceProductPrice
|
|
117
|
+
);
|
|
118
|
+
const hasPriceOverride = payload.price_override !== void 0 && payload.price_override !== null && payload.price_override !== "";
|
|
104
119
|
const productOptionItem = normalizeOptionItems(
|
|
105
120
|
payload.option ?? payload.options ?? payload.product_option_item
|
|
106
121
|
);
|
|
107
122
|
const productBundle = normalizeBundleItems(
|
|
108
|
-
payload.bundle ?? payload.product_bundle
|
|
123
|
+
payload.bundle ?? payload.product_bundle,
|
|
124
|
+
hasPriceOverride
|
|
109
125
|
);
|
|
110
126
|
const uniqueIdentificationNumber = payload.unique_identification_number ?? payload.unique;
|
|
111
127
|
const metadata = {
|
|
@@ -119,7 +135,11 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
119
135
|
policy_id: payload.policy_id,
|
|
120
136
|
source_shop_id: payload.source_shop_id,
|
|
121
137
|
origin,
|
|
122
|
-
source_product_price: sourceProductPrice
|
|
138
|
+
source_product_price: sourceProductPrice,
|
|
139
|
+
main_product_selling_price: sourceProductPrice,
|
|
140
|
+
main_product_original_price: sourceProductPrice,
|
|
141
|
+
...hasPriceOverride ? { price_override: String(payload.price_override) } : {},
|
|
142
|
+
...payload.bundle_edit !== void 0 ? { bundle_edit: payload.bundle_edit } : {}
|
|
123
143
|
};
|
|
124
144
|
if (uniqueIdentificationNumber) {
|
|
125
145
|
metadata.unique_identification_number = String(uniqueIdentificationNumber);
|
|
@@ -131,8 +151,9 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
131
151
|
num: toSafePositiveInt(payload.quantity ?? payload.num, 1),
|
|
132
152
|
product_option_item: productOptionItem,
|
|
133
153
|
product_bundle: productBundle,
|
|
134
|
-
|
|
135
|
-
|
|
154
|
+
// 折后行价由 normalizeOrderProduct 按 main + bundle 合成;手动改价时 bundle 已为分摊后单价
|
|
155
|
+
selling_price: lineCompositeTotal,
|
|
156
|
+
original_price: lineCompositeTotal,
|
|
136
157
|
tax_fee: toPriceString(
|
|
137
158
|
payload.tax_fee ?? (matchedVariant == null ? void 0 : matchedVariant.tax_fee) ?? (origin == null ? void 0 : origin.tax_fee) ?? (sourceProduct == null ? void 0 : sourceProduct.tax_fee),
|
|
138
159
|
"0.00"
|
|
@@ -102,12 +102,40 @@ function isSkuOnlyDeleteIdentity(x) {
|
|
|
102
102
|
return !("product_option_item" in x) && !("product_bundle" in x);
|
|
103
103
|
}
|
|
104
104
|
function normalizeOrderProduct(product) {
|
|
105
|
-
var _a, _b, _c;
|
|
105
|
+
var _a, _b, _c, _d, _e, _f;
|
|
106
106
|
const metadata = { ...product.metadata || {} };
|
|
107
107
|
const resolvedIdentityKey = ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? String(product.metadata.unique_identification_number) : product.unique_identification_number && String(product.unique_identification_number).length > 0 ? String(product.unique_identification_number) : product.identity_key && String(product.identity_key).length > 0 ? String(product.identity_key) : (0, import_utils.createUuidV4)();
|
|
108
108
|
metadata.unique_identification_number = resolvedIdentityKey;
|
|
109
|
-
const
|
|
109
|
+
const priceOverride = metadata.price_override;
|
|
110
|
+
const originOtherBundle = (_d = (_c = (_b = metadata.origin) == null ? void 0 : _b._extend) == null ? void 0 : _c.other) == null ? void 0 : _d.bundle;
|
|
111
|
+
let bundleInput = product.product_bundle || [];
|
|
112
|
+
if (priceOverride !== void 0 && priceOverride !== null && priceOverride !== "" && Array.isArray(originOtherBundle) && originOtherBundle.length > 0) {
|
|
113
|
+
const priceById = /* @__PURE__ */ new Map();
|
|
114
|
+
originOtherBundle.forEach((item) => {
|
|
115
|
+
if ((item == null ? void 0 : item.id) == null)
|
|
116
|
+
return;
|
|
117
|
+
const unit = item.price ?? item.bundle_selling_price;
|
|
118
|
+
if (unit === void 0 || unit === null)
|
|
119
|
+
return;
|
|
120
|
+
priceById.set(String(item.id), String(unit));
|
|
121
|
+
});
|
|
122
|
+
const base = Array.isArray(bundleInput) && bundleInput.length > 0 ? bundleInput : originOtherBundle;
|
|
123
|
+
bundleInput = base.map((item) => {
|
|
124
|
+
const unit = priceById.get(String(item == null ? void 0 : item.id));
|
|
125
|
+
if (unit === void 0)
|
|
126
|
+
return item;
|
|
127
|
+
return {
|
|
128
|
+
...item,
|
|
129
|
+
price: unit,
|
|
130
|
+
bundle_selling_price: unit
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
const normalizedBundle = bundleInput.map((item) => ({
|
|
110
135
|
...item,
|
|
136
|
+
bundle_id: item.bundle_id ?? item.id,
|
|
137
|
+
bundle_product_id: item.bundle_product_id ?? item._bundle_product_id,
|
|
138
|
+
bundle_group_id: item.bundle_group_id ?? item.group_id,
|
|
111
139
|
bundle_selling_price: item.bundle_selling_price ?? item.price ?? "0.00",
|
|
112
140
|
price: item.price ?? item.custom_price ?? item.bundle_selling_price ?? "0.00",
|
|
113
141
|
price_type: item.price_type ?? item.custom_price_type ?? "",
|
|
@@ -117,8 +145,8 @@ function normalizeOrderProduct(product) {
|
|
|
117
145
|
const optionSum = (0, import_utils.sumOptionUnitPrice)(normalizedOptions);
|
|
118
146
|
const isV2 = metadata.price_schema_version === 2 || metadata.price_schema_version === "2";
|
|
119
147
|
const variantId = Number(product.product_variant_id || 0);
|
|
120
|
-
const variantList = variantId ? (
|
|
121
|
-
const variantPrice = Array.isArray(variantList) ? (
|
|
148
|
+
const variantList = variantId ? (_e = metadata == null ? void 0 : metadata.origin) == null ? void 0 : _e.variant : null;
|
|
149
|
+
const variantPrice = Array.isArray(variantList) ? (_f = variantList.find((v) => Number(v == null ? void 0 : v.id) === variantId)) == null ? void 0 : _f.price : void 0;
|
|
122
150
|
const resolvedSource = (() => {
|
|
123
151
|
var _a2, _b2;
|
|
124
152
|
if (metadata.source_product_price !== void 0) {
|
|
@@ -174,6 +202,10 @@ function normalizeOrderProduct(product) {
|
|
|
174
202
|
bundle: normalizedBundle,
|
|
175
203
|
useOriginalBundle: true
|
|
176
204
|
});
|
|
205
|
+
const finalOriginalPrice = (0, import_utils.resolveManualOverrideLineOriginalPrice)(
|
|
206
|
+
{ num: product.num, metadata },
|
|
207
|
+
composedOriginalPrice
|
|
208
|
+
);
|
|
177
209
|
return {
|
|
178
210
|
order_detail_id: product.order_detail_id || null,
|
|
179
211
|
product_id: product.product_id,
|
|
@@ -181,7 +213,7 @@ function normalizeOrderProduct(product) {
|
|
|
181
213
|
product_variant_id: product.product_variant_id,
|
|
182
214
|
product_option_item: normalizedOptions,
|
|
183
215
|
selling_price: composedSellingPrice,
|
|
184
|
-
original_price:
|
|
216
|
+
original_price: finalOriginalPrice,
|
|
185
217
|
tax_fee: product.tax_fee || "0.00",
|
|
186
218
|
is_charge_tax: product.is_charge_tax ?? 0,
|
|
187
219
|
discount_list: product.discount_list || [],
|
|
@@ -21,6 +21,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
21
21
|
private platform;
|
|
22
22
|
private scan;
|
|
23
23
|
private productCatalog;
|
|
24
|
+
private orderCustomerDiscountRefreshInFlight;
|
|
25
|
+
private orderCustomerDiscountRefreshCustomerId;
|
|
24
26
|
/**
|
|
25
27
|
* 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext。
|
|
26
28
|
* bookingContext 是 SalesSdk 加车下沉所需的「预约 UI 上下文」(bookingConfig / resourcesOrigin / date)。
|
|
@@ -205,6 +207,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
205
207
|
restoreOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
|
|
206
208
|
/** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */
|
|
207
209
|
private buildOrderCustomerPayload;
|
|
210
|
+
private refreshDiscountConfigAfterOrderCustomerChange;
|
|
208
211
|
/**
|
|
209
212
|
* 获取客户分页信息
|
|
210
213
|
* @returns 分页信息
|
|
@@ -58,6 +58,8 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
58
58
|
*/
|
|
59
59
|
this.store = {};
|
|
60
60
|
this.productCatalog = [];
|
|
61
|
+
this.orderCustomerDiscountRefreshInFlight = null;
|
|
62
|
+
this.orderCustomerDiscountRefreshCustomerId = null;
|
|
61
63
|
}
|
|
62
64
|
/**
|
|
63
65
|
* 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext。
|
|
@@ -104,19 +106,30 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
104
106
|
console.log(sales, "1234sales");
|
|
105
107
|
const customerModule = this.store.customer;
|
|
106
108
|
const detailCustomer = sales == null ? void 0 : sales.customer;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
const orderCustomerSnapshot = this.store.order.getOrderCustomerSnapshot();
|
|
110
|
+
const protocolCustomerId = sales == null ? void 0 : sales.customer_id;
|
|
111
|
+
const protocolCustomer = protocolCustomerId !== void 0 && protocolCustomerId !== null ? {
|
|
112
|
+
id: protocolCustomerId,
|
|
113
|
+
name: String((sales == null ? void 0 : sales.customer_name) || ""),
|
|
114
|
+
phone: sales == null ? void 0 : sales.phone,
|
|
115
|
+
email: sales == null ? void 0 : sales.email,
|
|
116
|
+
country_calling_code: sales == null ? void 0 : sales.country_calling_code
|
|
117
|
+
} : null;
|
|
118
|
+
const selectedCustomer = detailCustomer ?? orderCustomerSnapshot ?? protocolCustomer;
|
|
119
|
+
if (customerModule && selectedCustomer) {
|
|
120
|
+
const { id: detailCustomerId, ...detailCustomerRest } = selectedCustomer ?? {};
|
|
109
121
|
const rawId = detailCustomerId ?? "";
|
|
110
122
|
const customer = {
|
|
111
123
|
...detailCustomerRest,
|
|
112
124
|
id: rawId == null ? "" : rawId,
|
|
113
|
-
name: (
|
|
114
|
-
phone:
|
|
115
|
-
email:
|
|
116
|
-
country_calling_code:
|
|
125
|
+
name: (selectedCustomer == null ? void 0 : selectedCustomer.name) ?? "",
|
|
126
|
+
phone: selectedCustomer == null ? void 0 : selectedCustomer.phone,
|
|
127
|
+
email: selectedCustomer == null ? void 0 : selectedCustomer.email,
|
|
128
|
+
country_calling_code: selectedCustomer == null ? void 0 : selectedCustomer.country_calling_code
|
|
117
129
|
};
|
|
118
130
|
customerModule.setSelectedCustomer(customer);
|
|
119
131
|
this.setOrderCustomer(customer);
|
|
132
|
+
await this.store.order.saveDraft();
|
|
120
133
|
}
|
|
121
134
|
return sales;
|
|
122
135
|
}
|
|
@@ -400,6 +413,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
400
413
|
this.store.order.setOrderCustomer(patch, customer);
|
|
401
414
|
const next = this.buildOrderCustomerPayload();
|
|
402
415
|
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next);
|
|
416
|
+
this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
|
|
403
417
|
}
|
|
404
418
|
/**
|
|
405
419
|
* 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
|
|
@@ -417,7 +431,16 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
417
431
|
* 清空下单客户(协议字段 + snapshot)。
|
|
418
432
|
*/
|
|
419
433
|
clearOrderCustomer() {
|
|
434
|
+
var _a, _b;
|
|
420
435
|
this.store.order.clearOrderCustomer();
|
|
436
|
+
const orderStore = this.store.order.store || {};
|
|
437
|
+
const discountModule = orderStore.discount;
|
|
438
|
+
void ((_a = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _a.call(discountModule, []));
|
|
439
|
+
void ((_b = discountModule == null ? void 0 : discountModule.setDiscountList) == null ? void 0 : _b.call(discountModule, []));
|
|
440
|
+
this.store.order.applyDiscount();
|
|
441
|
+
void this.store.order.recalculateSummary({ createIfMissing: true }).then(() => this.store.order.persistTempOrder()).catch((error) => {
|
|
442
|
+
console.error("Failed to recalculate summary after clearing customer:", error);
|
|
443
|
+
});
|
|
421
444
|
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, null);
|
|
422
445
|
}
|
|
423
446
|
/**
|
|
@@ -446,6 +469,34 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
446
469
|
snapshot: this.store.order.getOrderCustomerSnapshot()
|
|
447
470
|
};
|
|
448
471
|
}
|
|
472
|
+
refreshDiscountConfigAfterOrderCustomerChange(customerId) {
|
|
473
|
+
if (!customerId || customerId === 1)
|
|
474
|
+
return;
|
|
475
|
+
if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
const previousRefresh = this.orderCustomerDiscountRefreshInFlight;
|
|
479
|
+
const refreshTask = (async () => {
|
|
480
|
+
if (previousRefresh) {
|
|
481
|
+
await previousRefresh.catch(() => void 0);
|
|
482
|
+
}
|
|
483
|
+
const currentCustomer = this.store.order.getOrderCustomer();
|
|
484
|
+
if (!currentCustomer || Number(currentCustomer.customer_id) !== customerId) {
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
await this.loadDiscountConfig({ customerId });
|
|
488
|
+
})();
|
|
489
|
+
this.orderCustomerDiscountRefreshInFlight = refreshTask;
|
|
490
|
+
this.orderCustomerDiscountRefreshCustomerId = customerId;
|
|
491
|
+
refreshTask.catch((error) => {
|
|
492
|
+
console.error("Failed to load discount config after customer change:", error);
|
|
493
|
+
}).finally(() => {
|
|
494
|
+
if (this.orderCustomerDiscountRefreshInFlight !== refreshTask)
|
|
495
|
+
return;
|
|
496
|
+
this.orderCustomerDiscountRefreshInFlight = null;
|
|
497
|
+
this.orderCustomerDiscountRefreshCustomerId = null;
|
|
498
|
+
});
|
|
499
|
+
}
|
|
449
500
|
/**
|
|
450
501
|
* 获取客户分页信息
|
|
451
502
|
* @returns 分页信息
|
|
@@ -89,8 +89,10 @@ export declare function buildRequiresDetailPayload(item: any, ctx?: AddProductDe
|
|
|
89
89
|
*/
|
|
90
90
|
export declare function buildCacheItemFromCartDetail(item: any, ctx?: AddProductDecideContext): any;
|
|
91
91
|
/**
|
|
92
|
-
* 用 Info2 callback 的 (e, extension_type, detail)
|
|
93
|
-
*
|
|
92
|
+
* 用 Info2 callback 的 (e, extension_type, detail) 拼装 cacheItem。
|
|
93
|
+
*
|
|
94
|
+
* 保留 detail._extend 中的 pricing / note(规格弹窗改价、备注等),
|
|
95
|
+
* 再叠加 session 时间、ctx.quantity 等运行态字段;other 以 callback `e` 为准。
|
|
94
96
|
*/
|
|
95
97
|
export declare function buildCacheItemFromDetail(item: any, detailResult: {
|
|
96
98
|
e: any;
|
|
@@ -200,7 +200,8 @@ function buildCacheItemFromCartDetail(item, ctx) {
|
|
|
200
200
|
item,
|
|
201
201
|
{
|
|
202
202
|
start_date: (ctx == null ? void 0 : ctx.date) || void 0,
|
|
203
|
-
|
|
203
|
+
/** 列表连点 / 防抖合并时以 ctx.quantity 为准,避免 cartDetailValue 默认 1 盖掉合并数量 */
|
|
204
|
+
quantity: (ctx == null ? void 0 : ctx.quantity) ?? (cartDetailValue == null ? void 0 : cartDetailValue.quantity) ?? 1,
|
|
204
205
|
product_name: item.title,
|
|
205
206
|
other,
|
|
206
207
|
isNormalProduct: !(0, import_BookingContext.isBookingProduct)(item),
|
|
@@ -221,28 +222,36 @@ function buildCacheItemFromDetail(item, detailResult, ctx) {
|
|
|
221
222
|
var _a, _b, _c;
|
|
222
223
|
const _currentItem = detailResult.detail || item;
|
|
223
224
|
const _detail = _currentItem;
|
|
225
|
+
const detailExtend = (_detail == null ? void 0 : _detail._extend) || {};
|
|
224
226
|
const other = JSON.parse(JSON.stringify(detailResult.e || {}));
|
|
225
227
|
other.session = (_a = detailResult.e) == null ? void 0 : _a.session;
|
|
226
228
|
const resolvedId = _currentItem.id ?? _currentItem.product_id;
|
|
227
229
|
const mergedItem = { ...item, ..._detail, extension_type: _detail.extension_type ?? item.extension_type };
|
|
228
|
-
const
|
|
230
|
+
const runtimeExtend = (0, import_BookingContext.applySessionTimesToExtend)(
|
|
229
231
|
mergedItem,
|
|
230
232
|
{
|
|
231
|
-
start_date: (ctx == null ? void 0 : ctx.date) || void 0,
|
|
232
|
-
quantity: (
|
|
233
|
-
price: _detail == null ? void 0 : _detail.price,
|
|
234
|
-
product_name: _currentItem.title,
|
|
233
|
+
start_date: (ctx == null ? void 0 : ctx.date) || detailExtend.start_date || void 0,
|
|
234
|
+
quantity: (ctx == null ? void 0 : ctx.quantity) ?? ((_b = detailResult.e) == null ? void 0 : _b.quantity) ?? detailExtend.quantity ?? 1,
|
|
235
|
+
price: detailExtend.price ?? (_detail == null ? void 0 : _detail.price) ?? (item == null ? void 0 : item.price),
|
|
236
|
+
product_name: _currentItem.title ?? detailExtend.product_name,
|
|
235
237
|
other,
|
|
236
238
|
isNormalProduct: !(0, import_BookingContext.isBookingProduct)(mergedItem)
|
|
237
239
|
},
|
|
238
240
|
{ date: ctx == null ? void 0 : ctx.date }
|
|
239
241
|
);
|
|
242
|
+
const extend = {
|
|
243
|
+
...detailExtend,
|
|
244
|
+
...runtimeExtend,
|
|
245
|
+
other
|
|
246
|
+
};
|
|
247
|
+
const note = detailExtend.note ?? (_detail == null ? void 0 : _detail.note);
|
|
240
248
|
return {
|
|
241
249
|
..._detail,
|
|
242
250
|
id: resolvedId,
|
|
243
251
|
product_id: resolvedId,
|
|
244
252
|
extension_type: mergedItem.extension_type,
|
|
245
253
|
_key: (_c = detailResult.e) == null ? void 0 : _c.key,
|
|
254
|
+
...note != null && note !== "" ? { note: String(note) } : {},
|
|
246
255
|
_extend: extend,
|
|
247
256
|
new: 1
|
|
248
257
|
};
|
|
@@ -267,22 +276,29 @@ function transformDetailToProductAndBooking(cacheItem, ctx) {
|
|
|
267
276
|
return { product: productInput, booking, cacheItem: preparedCacheItem };
|
|
268
277
|
}
|
|
269
278
|
function buildBasePayloadFromCacheItem(cacheItem, ctx) {
|
|
270
|
-
var _a, _b, _c, _d
|
|
279
|
+
var _a, _b, _c, _d;
|
|
271
280
|
const other = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.other) || {};
|
|
272
|
-
const quantity = (
|
|
281
|
+
const quantity = (ctx == null ? void 0 : ctx.quantity) != null && ctx.quantity > 0 ? ctx.quantity : ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.quantity) ?? 1;
|
|
273
282
|
const resolvedPid = (cacheItem == null ? void 0 : cacheItem.product_id) ?? (cacheItem == null ? void 0 : cacheItem.id);
|
|
283
|
+
const extend = (cacheItem == null ? void 0 : cacheItem._extend) || {};
|
|
274
284
|
return {
|
|
275
285
|
id: (cacheItem == null ? void 0 : cacheItem.id) ?? (cacheItem == null ? void 0 : cacheItem.product_id),
|
|
276
286
|
product_id: resolvedPid,
|
|
277
287
|
variant_id: (other == null ? void 0 : other.product_variant_id) ?? (other == null ? void 0 : other.variant_id) ?? 0,
|
|
278
288
|
quantity,
|
|
279
289
|
option: (other == null ? void 0 : other.option) || [],
|
|
280
|
-
bundle: (other == null ? void 0 : other.bundle) || [],
|
|
290
|
+
bundle: (other == null ? void 0 : other.bundle) || ((_c = extend == null ? void 0 : extend.skuValue) == null ? void 0 : _c.bundle) || ((_d = extend == null ? void 0 : extend._skuValue) == null ? void 0 : _d.bundle) || [],
|
|
281
291
|
unique: other == null ? void 0 : other.unique,
|
|
282
292
|
session: other == null ? void 0 : other.session,
|
|
283
|
-
note:
|
|
284
|
-
price: (
|
|
285
|
-
selling_price: (
|
|
293
|
+
note: extend == null ? void 0 : extend.note,
|
|
294
|
+
price: (extend == null ? void 0 : extend.price) ?? (cacheItem == null ? void 0 : cacheItem.price),
|
|
295
|
+
selling_price: (extend == null ? void 0 : extend.price) ?? (cacheItem == null ? void 0 : cacheItem.price),
|
|
296
|
+
line_total: extend == null ? void 0 : extend.total,
|
|
297
|
+
total: extend == null ? void 0 : extend.total,
|
|
298
|
+
origin_total: extend == null ? void 0 : extend.origin_total,
|
|
299
|
+
price_override: extend == null ? void 0 : extend.priceOverride,
|
|
300
|
+
bundle_edit: extend == null ? void 0 : extend.bundle_edit,
|
|
301
|
+
_extend: extend
|
|
286
302
|
};
|
|
287
303
|
}
|
|
288
304
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -406,12 +406,40 @@ function getProductIdentityIndex(products, identity) {
|
|
|
406
406
|
return products.findIndex((item) => isIdentityMatch(item, identity));
|
|
407
407
|
}
|
|
408
408
|
function normalizeOrderProduct(product) {
|
|
409
|
-
var _a, _b, _c;
|
|
409
|
+
var _a, _b, _c, _d, _e, _f;
|
|
410
410
|
const metadata = { ...product.metadata || {} };
|
|
411
411
|
const resolvedIdentityKey = ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? String(product.metadata.unique_identification_number) : product.unique_identification_number && String(product.unique_identification_number).length > 0 ? String(product.unique_identification_number) : product.identity_key && String(product.identity_key).length > 0 ? String(product.identity_key) : (0, import_utils.createUuidV4)();
|
|
412
412
|
metadata.unique_identification_number = resolvedIdentityKey;
|
|
413
|
-
const
|
|
413
|
+
const priceOverride = metadata.price_override;
|
|
414
|
+
const originOtherBundle = (_d = (_c = (_b = metadata.origin) == null ? void 0 : _b._extend) == null ? void 0 : _c.other) == null ? void 0 : _d.bundle;
|
|
415
|
+
let bundleInput = product.product_bundle || [];
|
|
416
|
+
if (priceOverride !== void 0 && priceOverride !== null && priceOverride !== "" && Array.isArray(originOtherBundle) && originOtherBundle.length > 0) {
|
|
417
|
+
const priceById = /* @__PURE__ */ new Map();
|
|
418
|
+
originOtherBundle.forEach((item) => {
|
|
419
|
+
if ((item == null ? void 0 : item.id) == null)
|
|
420
|
+
return;
|
|
421
|
+
const unit = item.price ?? item.bundle_selling_price;
|
|
422
|
+
if (unit === void 0 || unit === null)
|
|
423
|
+
return;
|
|
424
|
+
priceById.set(String(item.id), String(unit));
|
|
425
|
+
});
|
|
426
|
+
const base = Array.isArray(bundleInput) && bundleInput.length > 0 ? bundleInput : originOtherBundle;
|
|
427
|
+
bundleInput = base.map((item) => {
|
|
428
|
+
const unit = priceById.get(String(item == null ? void 0 : item.id));
|
|
429
|
+
if (unit === void 0)
|
|
430
|
+
return item;
|
|
431
|
+
return {
|
|
432
|
+
...item,
|
|
433
|
+
price: unit,
|
|
434
|
+
bundle_selling_price: unit
|
|
435
|
+
};
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
const normalizedBundle = bundleInput.map((item) => ({
|
|
414
439
|
...item,
|
|
440
|
+
bundle_id: item.bundle_id ?? item.id,
|
|
441
|
+
bundle_product_id: item.bundle_product_id ?? item._bundle_product_id,
|
|
442
|
+
bundle_group_id: item.bundle_group_id ?? item.group_id,
|
|
415
443
|
bundle_selling_price: item.bundle_selling_price ?? item.price ?? "0.00",
|
|
416
444
|
price: item.price ?? item.custom_price ?? item.bundle_selling_price ?? "0.00",
|
|
417
445
|
price_type: item.price_type ?? item.custom_price_type ?? "",
|
|
@@ -421,8 +449,8 @@ function normalizeOrderProduct(product) {
|
|
|
421
449
|
const optionSum = (0, import_utils.sumOptionUnitPrice)(normalizedOptions);
|
|
422
450
|
const isV2 = metadata.price_schema_version === 2 || metadata.price_schema_version === "2";
|
|
423
451
|
const variantId = Number(product.product_variant_id || 0);
|
|
424
|
-
const variantList = variantId ? (
|
|
425
|
-
const variantPrice = Array.isArray(variantList) ? (
|
|
452
|
+
const variantList = variantId ? (_e = metadata == null ? void 0 : metadata.origin) == null ? void 0 : _e.variant : null;
|
|
453
|
+
const variantPrice = Array.isArray(variantList) ? (_f = variantList.find((v) => Number(v == null ? void 0 : v.id) === variantId)) == null ? void 0 : _f.price : void 0;
|
|
426
454
|
const resolvedSource = (() => {
|
|
427
455
|
var _a2, _b2;
|
|
428
456
|
if (metadata.source_product_price !== void 0) {
|
|
@@ -478,6 +506,10 @@ function normalizeOrderProduct(product) {
|
|
|
478
506
|
bundle: normalizedBundle,
|
|
479
507
|
useOriginalBundle: true
|
|
480
508
|
});
|
|
509
|
+
const finalOriginalPrice = (0, import_utils.resolveManualOverrideLineOriginalPrice)(
|
|
510
|
+
{ num: product.num, metadata },
|
|
511
|
+
composedOriginalPrice
|
|
512
|
+
);
|
|
481
513
|
return {
|
|
482
514
|
order_detail_id: product.order_detail_id || null,
|
|
483
515
|
product_id: product.product_id,
|
|
@@ -485,7 +517,7 @@ function normalizeOrderProduct(product) {
|
|
|
485
517
|
product_variant_id: product.product_variant_id,
|
|
486
518
|
product_option_item: normalizedOptions,
|
|
487
519
|
selling_price: composedSellingPrice,
|
|
488
|
-
original_price:
|
|
520
|
+
original_price: finalOriginalPrice,
|
|
489
521
|
tax_fee: product.tax_fee || "0.00",
|
|
490
522
|
is_charge_tax: product.is_charge_tax ?? 0,
|
|
491
523
|
discount_list: product.discount_list || [],
|