@pisell/pisellos 2.2.245 → 2.2.247
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 +6 -3
- package/dist/modules/Order/index.d.ts +8 -1
- package/dist/modules/Order/index.js +485 -314
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Payment/walletpass.js +1 -1
- package/dist/server/modules/order/index.js +7 -3
- package/dist/server/utils/small-ticket.d.ts +1 -0
- package/dist/server/utils/small-ticket.js +81 -41
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +5 -2
- package/lib/modules/Order/index.d.ts +8 -1
- package/lib/modules/Order/index.js +120 -10
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Payment/walletpass.js +1 -1
- package/lib/server/modules/order/index.js +7 -3
- package/lib/server/utils/small-ticket.d.ts +1 -0
- package/lib/server/utils/small-ticket.js +40 -3
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -76,6 +76,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
76
76
|
this.giftSelectResolver = null;
|
|
77
77
|
/** applyPromotion 递归保护 flag(写路径同步调 applyPromotion,禁止重入) */
|
|
78
78
|
this.isApplyingPromotion = false;
|
|
79
|
+
/** 商品曾应用过客户券卡,客户变更剥离后需强制跑一次 calcDiscount 复位价格 */
|
|
80
|
+
this.hasActiveCustomerBoundDiscount = false;
|
|
79
81
|
/** 最近一次 applyPromotion 的未满足促销提示 */
|
|
80
82
|
this.lastUnfulfilledPromotions = [];
|
|
81
83
|
/** 最近一次 applyPromotion 的赠品操作 diff(debug / SDK 读取使用) */
|
|
@@ -471,6 +473,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
471
473
|
if (!tempOrder)
|
|
472
474
|
return;
|
|
473
475
|
delete tempOrder.discount_list;
|
|
476
|
+
if (this.shouldSkipDiscountCalculation(tempOrder))
|
|
477
|
+
return;
|
|
474
478
|
const rulesModule = this.store.rules;
|
|
475
479
|
if (!rulesModule)
|
|
476
480
|
return;
|
|
@@ -512,6 +516,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
512
516
|
);
|
|
513
517
|
(_e = this.store.discount) == null ? void 0 : _e.setDiscountList(result.discountList);
|
|
514
518
|
}
|
|
519
|
+
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(
|
|
520
|
+
(product) => this.productHasCustomerBoundDiscount(product)
|
|
521
|
+
);
|
|
515
522
|
}
|
|
516
523
|
// ─── 促销/赠品 ──────────────────────────────────────
|
|
517
524
|
/**
|
|
@@ -556,7 +563,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
556
563
|
* - 不主动调用 applyDiscount / recalculateSummary,调用方负责跟进。
|
|
557
564
|
*/
|
|
558
565
|
async applyPromotion() {
|
|
559
|
-
var _a;
|
|
566
|
+
var _a, _b, _c;
|
|
560
567
|
if (this.isApplyingPromotion) {
|
|
561
568
|
return;
|
|
562
569
|
}
|
|
@@ -567,6 +574,10 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
567
574
|
if (!tempOrder) {
|
|
568
575
|
return;
|
|
569
576
|
}
|
|
577
|
+
const strategyConfigs = (_b = (_a = this.promotionEvaluator).getStrategyConfigs) == null ? void 0 : _b.call(_a);
|
|
578
|
+
if (Array.isArray(strategyConfigs) && strategyConfigs.length === 0) {
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
570
581
|
this.isApplyingPromotion = true;
|
|
571
582
|
try {
|
|
572
583
|
const result = (0, import_cartPromotion.processCartPromotion)(
|
|
@@ -608,11 +619,11 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
608
619
|
if (addAction.giftOptions.length === 1) {
|
|
609
620
|
const sameStrategy = result.products.find(
|
|
610
621
|
(p) => {
|
|
611
|
-
var _a2,
|
|
612
|
-
return ((
|
|
622
|
+
var _a2, _b2;
|
|
623
|
+
return ((_b2 = (_a2 = p.metadata) == null ? void 0 : _a2._giftInfo) == null ? void 0 : _b2.strategyId) === addAction.strategyId;
|
|
613
624
|
}
|
|
614
625
|
);
|
|
615
|
-
if (sameStrategy && !sameStrategy.booking_uid && !((
|
|
626
|
+
if (sameStrategy && !sameStrategy.booking_uid && !((_c = sameStrategy.metadata) == null ? void 0 : _c.booking_uid)) {
|
|
616
627
|
sameStrategy.num = (Number(sameStrategy.num) || 0) + (addAction.giftCount || 1);
|
|
617
628
|
continue;
|
|
618
629
|
}
|
|
@@ -1256,6 +1267,33 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1256
1267
|
items.sort((left, right) => JSON.stringify(left).localeCompare(JSON.stringify(right)));
|
|
1257
1268
|
return JSON.stringify(items);
|
|
1258
1269
|
}
|
|
1270
|
+
getManualDepositOverride(tempOrder) {
|
|
1271
|
+
var _a;
|
|
1272
|
+
const override = (_a = tempOrder._extend) == null ? void 0 : _a.manualDepositOverride;
|
|
1273
|
+
if (!override || typeof override !== "object")
|
|
1274
|
+
return null;
|
|
1275
|
+
if (typeof override.amount !== "string")
|
|
1276
|
+
return null;
|
|
1277
|
+
if (typeof override.productStructuralFingerprint !== "string")
|
|
1278
|
+
return null;
|
|
1279
|
+
return override;
|
|
1280
|
+
}
|
|
1281
|
+
setManualDepositOverride(tempOrder, amount) {
|
|
1282
|
+
tempOrder._extend = {
|
|
1283
|
+
...tempOrder._extend || {},
|
|
1284
|
+
manualDepositOverride: {
|
|
1285
|
+
amount,
|
|
1286
|
+
productStructuralFingerprint: this.buildOrderProductsStructuralFingerprint(tempOrder.products)
|
|
1287
|
+
}
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1290
|
+
clearManualDepositOverride(tempOrder) {
|
|
1291
|
+
var _a;
|
|
1292
|
+
if (!((_a = tempOrder._extend) == null ? void 0 : _a.manualDepositOverride))
|
|
1293
|
+
return;
|
|
1294
|
+
tempOrder._extend = { ...tempOrder._extend };
|
|
1295
|
+
delete tempOrder._extend.manualDepositOverride;
|
|
1296
|
+
}
|
|
1259
1297
|
getOriginalSalesSnapshot(tempOrder) {
|
|
1260
1298
|
var _a;
|
|
1261
1299
|
const snapshot = (_a = tempOrder._extend) == null ? void 0 : _a.originalSalesSnapshot;
|
|
@@ -1717,18 +1755,28 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1717
1755
|
const depositSummary = (0, import_utils.calculateOrderProductsDeposit)(tempOrder.products || [], {
|
|
1718
1756
|
productsByUid: (_a = tempOrder._extend) == null ? void 0 : _a.productsByUid
|
|
1719
1757
|
});
|
|
1758
|
+
const manualDepositOverride = this.getManualDepositOverride(tempOrder);
|
|
1759
|
+
const currentStructuralFingerprint = manualDepositOverride ? this.buildOrderProductsStructuralFingerprint(tempOrder.products) : "";
|
|
1760
|
+
const shouldUseManualDepositOverride = Boolean(
|
|
1761
|
+
manualDepositOverride && manualDepositOverride.productStructuralFingerprint === currentStructuralFingerprint
|
|
1762
|
+
);
|
|
1763
|
+
if (manualDepositOverride && !shouldUseManualDepositOverride) {
|
|
1764
|
+
this.clearManualDepositOverride(tempOrder);
|
|
1765
|
+
}
|
|
1766
|
+
const depositAmount = shouldUseManualDepositOverride ? manualDepositOverride.amount : depositSummary.totalText;
|
|
1767
|
+
const hasDepositAmount = new import_decimal.default(depositAmount).gt(0);
|
|
1720
1768
|
const nextSummary = {
|
|
1721
1769
|
...summary,
|
|
1722
|
-
deposit_amount:
|
|
1723
|
-
deposit:
|
|
1724
|
-
total:
|
|
1770
|
+
deposit_amount: depositAmount,
|
|
1771
|
+
deposit: hasDepositAmount ? {
|
|
1772
|
+
total: depositAmount,
|
|
1725
1773
|
deposit_policy_ids: depositSummary.deposit_policy_ids,
|
|
1726
1774
|
deposit_policy_data: depositSummary.protocols,
|
|
1727
1775
|
hasDeposit: true
|
|
1728
1776
|
} : void 0
|
|
1729
1777
|
};
|
|
1730
|
-
tempOrder.deposit_amount =
|
|
1731
|
-
tempOrder.is_deposit =
|
|
1778
|
+
tempOrder.deposit_amount = depositAmount;
|
|
1779
|
+
tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
|
|
1732
1780
|
return nextSummary;
|
|
1733
1781
|
}
|
|
1734
1782
|
async recalculateSummary(options) {
|
|
@@ -1887,6 +1935,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1887
1935
|
},
|
|
1888
1936
|
depositAmount
|
|
1889
1937
|
);
|
|
1938
|
+
this.setManualDepositOverride(tempOrder, depositAmount);
|
|
1890
1939
|
const paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
1891
1940
|
const summary = {
|
|
1892
1941
|
...summaryWithDeposit,
|
|
@@ -1939,12 +1988,37 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1939
1988
|
const type = (discount == null ? void 0 : discount.type) ?? (discount == null ? void 0 : discount.tag);
|
|
1940
1989
|
return type === "good_pass" || type === "discount_card" || type === "product_discount_card";
|
|
1941
1990
|
}
|
|
1991
|
+
productHasCustomerBoundDiscount(product) {
|
|
1992
|
+
if (((product == null ? void 0 : product.discount_list) || []).some((discount) => this.isCustomerBoundDiscount(discount))) {
|
|
1993
|
+
return true;
|
|
1994
|
+
}
|
|
1995
|
+
return ((product == null ? void 0 : product.product_bundle) || []).some(
|
|
1996
|
+
(bundle) => ((bundle == null ? void 0 : bundle.discount_list) || []).some((discount) => this.isCustomerBoundDiscount(discount))
|
|
1997
|
+
);
|
|
1998
|
+
}
|
|
1999
|
+
shouldSkipDiscountCalculation(tempOrder) {
|
|
2000
|
+
var _a, _b;
|
|
2001
|
+
if (this.hasActiveCustomerBoundDiscount)
|
|
2002
|
+
return false;
|
|
2003
|
+
const discountList = ((_b = (_a = this.store.discount) == null ? void 0 : _a.getDiscountList) == null ? void 0 : _b.call(_a)) || [];
|
|
2004
|
+
if (discountList.length > 0)
|
|
2005
|
+
return false;
|
|
2006
|
+
return !(tempOrder.products || []).some(
|
|
2007
|
+
(product) => this.productHasCustomerBoundDiscount(product)
|
|
2008
|
+
);
|
|
2009
|
+
}
|
|
1942
2010
|
clearCustomerBoundDiscounts(tempOrder) {
|
|
1943
2011
|
var _a, _b, _c, _d;
|
|
2012
|
+
let didRemoveCustomerBoundDiscount = false;
|
|
1944
2013
|
const filterDiscountList = (discountList) => {
|
|
1945
2014
|
if (!Array.isArray(discountList))
|
|
1946
2015
|
return [];
|
|
1947
|
-
return discountList.filter((discount) =>
|
|
2016
|
+
return discountList.filter((discount) => {
|
|
2017
|
+
const shouldRemove = this.isCustomerBoundDiscount(discount);
|
|
2018
|
+
if (shouldRemove)
|
|
2019
|
+
didRemoveCustomerBoundDiscount = true;
|
|
2020
|
+
return !shouldRemove;
|
|
2021
|
+
});
|
|
1948
2022
|
};
|
|
1949
2023
|
tempOrder.products = (tempOrder.products || []).map((product) => {
|
|
1950
2024
|
const nextProduct = {
|
|
@@ -1960,6 +2034,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1960
2034
|
return nextProduct;
|
|
1961
2035
|
});
|
|
1962
2036
|
delete tempOrder.discount_list;
|
|
2037
|
+
if (didRemoveCustomerBoundDiscount) {
|
|
2038
|
+
this.hasActiveCustomerBoundDiscount = true;
|
|
2039
|
+
}
|
|
1963
2040
|
const discountModule = this.store.discount;
|
|
1964
2041
|
if (!discountModule)
|
|
1965
2042
|
return;
|
|
@@ -2858,10 +2935,16 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2858
2935
|
* await order.removeProductsFromOrder([identityA, identityB]);
|
|
2859
2936
|
*/
|
|
2860
2937
|
async removeProductsFromOrder(identities) {
|
|
2938
|
+
var _a, _b, _c, _d;
|
|
2861
2939
|
const tempOrder = this.ensureTempOrder();
|
|
2862
2940
|
if (!identities.length) {
|
|
2863
2941
|
return tempOrder.products;
|
|
2864
2942
|
}
|
|
2943
|
+
const productsBeforeRemove = tempOrder.products || [];
|
|
2944
|
+
const bookingsBeforeRemove = tempOrder.bookings || [];
|
|
2945
|
+
const matchedProducts = productsBeforeRemove.filter((item) => {
|
|
2946
|
+
return identities.some((identity) => (0, import_utils3.isIdentityMatch)(item, identity));
|
|
2947
|
+
});
|
|
2865
2948
|
const removedProducts = [];
|
|
2866
2949
|
tempOrder.products = tempOrder.products.filter((item) => {
|
|
2867
2950
|
const shouldRemove = identities.some((identity) => (0, import_utils3.isIdentityMatch)(item, identity));
|
|
@@ -2872,6 +2955,33 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2872
2955
|
for (const product of removedProducts) {
|
|
2873
2956
|
this.removeLinkedBookingsForProduct(tempOrder, product);
|
|
2874
2957
|
}
|
|
2958
|
+
const linkedBookingUidsToRemove = /* @__PURE__ */ new Set();
|
|
2959
|
+
for (const product of matchedProducts) {
|
|
2960
|
+
const productUid = ((_a = product == null ? void 0 : product.metadata) == null ? void 0 : _a.unique_identification_number) || (product == null ? void 0 : product.unique_identification_number);
|
|
2961
|
+
const productBookingUid = (product == null ? void 0 : product.booking_uid) || ((_b = product == null ? void 0 : product.metadata) == null ? void 0 : _b.booking_uid);
|
|
2962
|
+
const isAddTimeProduct = ((_c = product == null ? void 0 : product.metadata) == null ? void 0 : _c.product_add_schedule_time) !== void 0 && ((_d = product == null ? void 0 : product.metadata) == null ? void 0 : _d.product_add_schedule_time) !== null;
|
|
2963
|
+
if (isAddTimeProduct)
|
|
2964
|
+
continue;
|
|
2965
|
+
if (productBookingUid !== void 0 && productBookingUid !== null && productBookingUid !== "") {
|
|
2966
|
+
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
2967
|
+
}
|
|
2968
|
+
if (productUid !== void 0 && productUid !== null && productUid !== "") {
|
|
2969
|
+
bookingsBeforeRemove.forEach((booking) => {
|
|
2970
|
+
const bookingUid = this.getBookingUniqueIdentificationNumber(booking);
|
|
2971
|
+
if (bookingUid && String((booking == null ? void 0 : booking.product_uid) || "") === String(productUid)) {
|
|
2972
|
+
linkedBookingUidsToRemove.add(bookingUid);
|
|
2973
|
+
}
|
|
2974
|
+
});
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
if (linkedBookingUidsToRemove.size > 0) {
|
|
2978
|
+
tempOrder.products = (tempOrder.products || []).filter((line) => {
|
|
2979
|
+
var _a2, _b2, _c2;
|
|
2980
|
+
const lineBookingUid = ((_a2 = line == null ? void 0 : line.metadata) == null ? void 0 : _a2.booking_uid) || (line == null ? void 0 : line.booking_uid);
|
|
2981
|
+
const isAddTimeProduct = ((_b2 = line == null ? void 0 : line.metadata) == null ? void 0 : _b2.product_add_schedule_time) !== void 0 && ((_c2 = line == null ? void 0 : line.metadata) == null ? void 0 : _c2.product_add_schedule_time) !== null;
|
|
2982
|
+
return !(isAddTimeProduct && lineBookingUid !== void 0 && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
|
|
2983
|
+
});
|
|
2984
|
+
}
|
|
2875
2985
|
await this.finalizeAfterProductsMutation(tempOrder);
|
|
2876
2986
|
return tempOrder.products;
|
|
2877
2987
|
}
|
|
@@ -214,7 +214,7 @@ var WalletPassPaymentImpl = class {
|
|
|
214
214
|
};
|
|
215
215
|
const [allList, orderBasicDetail] = await Promise.all([
|
|
216
216
|
this.getUserIdentificationCodeListAsync(identificationParams),
|
|
217
|
-
baseParams.payment_order_id ? this.getOrderBasicDetailAsync(baseParams.payment_order_id) : Promise.resolve(null)
|
|
217
|
+
baseParams.payment_order_id && typeof baseParams.payment_order_id === "string" && !baseParams.payment_order_id.startsWith("LOCAL_") ? this.getOrderBasicDetailAsync(baseParams.payment_order_id) : Promise.resolve(null)
|
|
218
218
|
]);
|
|
219
219
|
const walletPassEvaluator = (_b = (_a = this.paymentModule.window) == null ? void 0 : _a.getWalletPassEvaluator) == null ? void 0 : _b.call(_a);
|
|
220
220
|
if (!walletPassEvaluator) {
|
|
@@ -621,7 +621,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
621
621
|
const matchIndex = this.findOrderIndexByIdentity(updatedList, pendingOrder);
|
|
622
622
|
if (matchIndex < 0)
|
|
623
623
|
continue;
|
|
624
|
-
updatedList[matchIndex] = this.mergeOrderRecords(updatedList[matchIndex], pendingOrder
|
|
624
|
+
updatedList[matchIndex] = this.mergeOrderRecords(updatedList[matchIndex], pendingOrder, {
|
|
625
|
+
preferIncomingProducts: true
|
|
626
|
+
});
|
|
625
627
|
pendingMap.delete(storageKey);
|
|
626
628
|
memoryPendingMap.delete(storageKey);
|
|
627
629
|
mergeActions[storageKey] = "update";
|
|
@@ -1181,7 +1183,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1181
1183
|
}
|
|
1182
1184
|
return result;
|
|
1183
1185
|
}
|
|
1184
|
-
mergeOrderRecords(existing, incoming) {
|
|
1186
|
+
mergeOrderRecords(existing, incoming, options) {
|
|
1185
1187
|
const preferred = this.pickPreferredOrder(existing, incoming);
|
|
1186
1188
|
const secondary = preferred === existing ? incoming : existing;
|
|
1187
1189
|
const merged = {
|
|
@@ -1219,6 +1221,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1219
1221
|
mergedRecord[field] = secondaryRecord[field];
|
|
1220
1222
|
}
|
|
1221
1223
|
}
|
|
1224
|
+
const hasIncomingProducts = Object.prototype.hasOwnProperty.call(incomingRecord, "products");
|
|
1225
|
+
const shouldUseIncomingProductsSnapshot = (options == null ? void 0 : options.preferIncomingProducts) === true && hasIncomingProducts && incomingRecord.products !== void 0 && incomingRecord.products !== null;
|
|
1222
1226
|
for (const field of incomingPatchFields) {
|
|
1223
1227
|
if (!Object.prototype.hasOwnProperty.call(incomingRecord, field))
|
|
1224
1228
|
continue;
|
|
@@ -1228,7 +1232,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1228
1232
|
continue;
|
|
1229
1233
|
mergedRecord[field] = (0, import_lodash_es.cloneDeep)(incomingRecord[field]);
|
|
1230
1234
|
}
|
|
1231
|
-
mergedRecord.products = this.mergeOrderProductLists(preferredRecord.products, secondaryRecord.products);
|
|
1235
|
+
mergedRecord.products = shouldUseIncomingProductsSnapshot ? (0, import_lodash_es.cloneDeep)(incomingRecord.products) : this.mergeOrderProductLists(preferredRecord.products, secondaryRecord.products);
|
|
1232
1236
|
if (!this.isPendingSyncOrder(preferred) || !this.isPendingSyncOrder(secondary)) {
|
|
1233
1237
|
merged.need_sync = 0;
|
|
1234
1238
|
}
|
|
@@ -57,6 +57,7 @@ var LABELS = {
|
|
|
57
57
|
remainingPoints: "Remaining points",
|
|
58
58
|
table: "Table",
|
|
59
59
|
orderDiscount: "Order discount",
|
|
60
|
+
manualDiscount: "Manual discount",
|
|
60
61
|
payProcessingFee: "Pay processing fee",
|
|
61
62
|
rounding: "Rounding"
|
|
62
63
|
},
|
|
@@ -80,6 +81,7 @@ var LABELS = {
|
|
|
80
81
|
remainingPoints: "剩余积分",
|
|
81
82
|
table: "桌台",
|
|
82
83
|
orderDiscount: "整单折扣",
|
|
84
|
+
manualDiscount: "手动折扣",
|
|
83
85
|
payProcessingFee: "支付手续费",
|
|
84
86
|
rounding: "抹零"
|
|
85
87
|
},
|
|
@@ -103,6 +105,7 @@ var LABELS = {
|
|
|
103
105
|
remainingPoints: "剩餘積分",
|
|
104
106
|
table: "桌台",
|
|
105
107
|
orderDiscount: "整單折扣",
|
|
108
|
+
manualDiscount: "手動折扣",
|
|
106
109
|
payProcessingFee: "支付手續費",
|
|
107
110
|
rounding: "抹零"
|
|
108
111
|
}
|
|
@@ -184,6 +187,7 @@ function buildProducts(order, locale, productMap) {
|
|
|
184
187
|
parentProduct
|
|
185
188
|
});
|
|
186
189
|
const resolvedVariant = resolveProductVariantText({ product, parentProduct, locale });
|
|
190
|
+
const discountList = normalizeProductDiscounts({ product, locale, currencySymbol });
|
|
187
191
|
return {
|
|
188
192
|
product_title: productTitle,
|
|
189
193
|
product_quantity: quantity,
|
|
@@ -191,12 +195,40 @@ function buildProducts(order, locale, productMap) {
|
|
|
191
195
|
original_price: formatMoney(originalPrice, currencySymbol),
|
|
192
196
|
total_original_price: formatMoney(new import_decimal.default(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol),
|
|
193
197
|
extension_list: Array.isArray(product.extension_list) ? product.extension_list : [],
|
|
198
|
+
...discountList.length ? { discount_list: discountList } : {},
|
|
194
199
|
...options.length ? { options } : {},
|
|
195
200
|
...resolvedVariant ? { variant: resolvedVariant } : {},
|
|
196
201
|
...Array.isArray(product.combinations) ? { combinations: product.combinations } : combinations.length ? { combinations } : {}
|
|
197
202
|
};
|
|
198
203
|
});
|
|
199
204
|
}
|
|
205
|
+
function normalizeProductDiscounts(params) {
|
|
206
|
+
const { product, locale, currencySymbol } = params;
|
|
207
|
+
return normalizeArray(product.discount_list).map((discount) => {
|
|
208
|
+
const title = resolveDiscountTitle(discount, locale);
|
|
209
|
+
const amount = discount.amount ?? discount.value ?? discount.discount_amount;
|
|
210
|
+
const formattedAmount = formatNegativeMoney(amount, currencySymbol);
|
|
211
|
+
return {
|
|
212
|
+
...discount,
|
|
213
|
+
item: title,
|
|
214
|
+
name: title,
|
|
215
|
+
title,
|
|
216
|
+
value: formattedAmount
|
|
217
|
+
};
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
function resolveDiscountTitle(discount, locale) {
|
|
221
|
+
var _a, _b, _c;
|
|
222
|
+
const title = getLocalizedValue(
|
|
223
|
+
((_a = discount.discount) == null ? void 0 : _a.name) ?? ((_b = discount.discount) == null ? void 0 : _b.title) ?? ((_c = discount.discount) == null ? void 0 : _c.message) ?? discount.name ?? discount.title ?? discount.message,
|
|
224
|
+
locale
|
|
225
|
+
);
|
|
226
|
+
if (title)
|
|
227
|
+
return title;
|
|
228
|
+
if (discount.type === "product")
|
|
229
|
+
return label(locale, "manualDiscount");
|
|
230
|
+
return "";
|
|
231
|
+
}
|
|
200
232
|
function resolveProductTitle(params) {
|
|
201
233
|
const { product, productMap, locale } = params;
|
|
202
234
|
const ownTitle = getProductTitleSource(product, locale);
|
|
@@ -480,11 +512,11 @@ function buildFees(params) {
|
|
|
480
512
|
value: formatMoney(value, currencySymbol)
|
|
481
513
|
});
|
|
482
514
|
}
|
|
483
|
-
const discountAmount =
|
|
515
|
+
const discountAmount = order.shop_discount ?? summary.discount_amount ?? order.discount_amount;
|
|
484
516
|
if (isNonZero(discountAmount)) {
|
|
485
517
|
fees.push({
|
|
486
518
|
item: label(locale, "orderDiscount"),
|
|
487
|
-
value:
|
|
519
|
+
value: formatNegativeMoney(discountAmount, currencySymbol)
|
|
488
520
|
});
|
|
489
521
|
}
|
|
490
522
|
const taxFee = summary.tax_fee || order.tax_fee;
|
|
@@ -712,8 +744,9 @@ function getLocalizedValue(value, locale) {
|
|
|
712
744
|
if (typeof value !== "object")
|
|
713
745
|
return stringify(value);
|
|
714
746
|
const dashedLocale = locale.replace("_", "-");
|
|
747
|
+
const underscoredLocale = locale.replace("-", "_");
|
|
715
748
|
return stringify(
|
|
716
|
-
value[locale] ?? value[dashedLocale] ?? value.default ?? value.en ?? ""
|
|
749
|
+
value[locale] ?? value[dashedLocale] ?? value[underscoredLocale] ?? value.original ?? value.auto ?? value.default ?? value.en ?? ""
|
|
717
750
|
);
|
|
718
751
|
}
|
|
719
752
|
function buildShopAddress(shopInfo) {
|
|
@@ -742,6 +775,10 @@ function formatMoney(value, currencySymbol) {
|
|
|
742
775
|
const amount = new import_decimal.default(toMoneyNumber(value));
|
|
743
776
|
return `${currencySymbol}${amount.toFixed(2)}`;
|
|
744
777
|
}
|
|
778
|
+
function formatNegativeMoney(value, currencySymbol) {
|
|
779
|
+
const amount = new import_decimal.default(toMoneyNumber(value)).abs();
|
|
780
|
+
return `-${currencySymbol}${amount.toFixed(2)}`;
|
|
781
|
+
}
|
|
745
782
|
function calculateReceiptPaidAmount(order, summary) {
|
|
746
783
|
const paidAmount = sumPayments(order.payments);
|
|
747
784
|
const payProcessingFee = new import_decimal.default(
|
|
@@ -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 | 5 | 1 | 4 | 2 | 3 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
322
322
|
* 获取当前的客户搜索条件
|
|
323
323
|
* @returns 当前搜索条件
|
|
324
324
|
*/
|
|
325
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
325
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
326
326
|
/**
|
|
327
327
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
328
328
|
* @returns 客户状态
|