@pisell/pisellos 0.0.479 → 0.0.481
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/core/index.d.ts +3 -2
- package/dist/core/index.js +7 -0
- package/dist/effects/index.d.ts +2 -2
- package/dist/effects/index.js +34 -81
- package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
- package/dist/model/strategy/adapter/walletPass/type.d.ts +9 -2
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +6 -6
- package/dist/model/strategy/adapter/walletPass/utils.js +111 -72
- package/dist/modules/Customer/index.js +1 -1
- package/dist/modules/Discount/index.d.ts +6 -2
- package/dist/modules/Discount/index.js +14 -8
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +18 -13
- package/dist/modules/Payment/index.d.ts +4 -0
- package/dist/modules/Payment/index.js +774 -649
- package/dist/modules/Payment/walletpass.js +44 -17
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/types.d.ts +2 -0
- package/dist/modules/ProductList/index.d.ts +3 -0
- package/dist/modules/ProductList/index.js +9 -7
- package/dist/modules/Rules/index.d.ts +2 -2
- package/dist/modules/Rules/index.js +37 -31
- package/dist/modules/Rules/types.d.ts +2 -2
- package/dist/modules/Schedule/index.d.ts +9 -0
- package/dist/modules/Schedule/index.js +15 -2
- package/dist/plugins/app-types/app/app.d.ts +1 -0
- package/dist/plugins/request.d.ts +2 -0
- package/dist/server/index.d.ts +107 -2
- package/dist/server/index.js +1507 -279
- package/dist/server/modules/index.d.ts +6 -0
- package/dist/server/modules/index.js +7 -0
- package/dist/server/modules/menu/index.d.ts +19 -0
- package/dist/server/modules/menu/index.js +221 -71
- package/dist/server/modules/order/index.d.ts +87 -0
- package/dist/server/modules/order/index.js +916 -0
- package/dist/server/modules/order/types.d.ts +530 -0
- package/dist/server/modules/order/types.js +141 -0
- package/dist/server/modules/order/utils/filterBookings.d.ts +6 -0
- package/dist/server/modules/order/utils/filterBookings.js +350 -0
- package/dist/server/modules/order/utils/filterOrders.d.ts +15 -0
- package/dist/server/modules/order/utils/filterOrders.js +226 -0
- package/dist/server/modules/products/index.d.ts +117 -5
- package/dist/server/modules/products/index.js +1450 -240
- package/dist/server/modules/products/types.d.ts +25 -1
- package/dist/server/modules/products/types.js +3 -0
- package/dist/server/modules/resource/index.d.ts +86 -0
- package/dist/server/modules/resource/index.js +1128 -0
- package/dist/server/modules/resource/types.d.ts +121 -0
- package/dist/server/modules/resource/types.js +47 -0
- package/dist/server/modules/schedule/index.d.ts +19 -0
- package/dist/server/modules/schedule/index.js +229 -68
- package/dist/server/utils/product.d.ts +5 -0
- package/dist/server/utils/product.js +71 -31
- package/dist/solution/BookingTicket/index.d.ts +10 -2
- package/dist/solution/BookingTicket/index.js +41 -28
- package/dist/solution/BookingTicket/utils/scan/index.js +1 -1
- package/dist/solution/Checkout/index.d.ts +1 -0
- package/dist/solution/Checkout/index.js +286 -188
- package/dist/solution/Checkout/utils/index.d.ts +2 -1
- package/dist/solution/Checkout/utils/index.js +6 -4
- package/dist/solution/RegisterAndLogin/config.js +340 -1
- package/dist/solution/Sales/index.d.ts +96 -0
- package/dist/solution/Sales/index.js +566 -0
- package/dist/solution/Sales/types.d.ts +67 -0
- package/dist/solution/Sales/types.js +26 -0
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +35 -22
- package/dist/solution/ShopDiscount/types.d.ts +6 -0
- package/dist/solution/ShopDiscount/utils.d.ts +9 -0
- package/dist/solution/ShopDiscount/utils.js +21 -27
- package/dist/solution/index.d.ts +2 -1
- package/dist/solution/index.js +2 -1
- package/dist/types/index.d.ts +5 -0
- package/lib/core/index.d.ts +3 -2
- package/lib/core/index.js +4 -0
- package/lib/effects/index.d.ts +2 -2
- package/lib/effects/index.js +22 -31
- package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
- package/lib/model/strategy/adapter/walletPass/type.d.ts +9 -2
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +6 -6
- package/lib/model/strategy/adapter/walletPass/utils.js +115 -48
- package/lib/modules/Customer/index.js +1 -1
- package/lib/modules/Discount/index.d.ts +6 -2
- package/lib/modules/Discount/index.js +3 -1
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +20 -18
- package/lib/modules/Payment/index.d.ts +4 -0
- package/lib/modules/Payment/index.js +134 -66
- package/lib/modules/Payment/walletpass.js +23 -4
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +2 -0
- package/lib/modules/ProductList/index.d.ts +3 -0
- package/lib/modules/ProductList/index.js +2 -2
- package/lib/modules/Rules/index.d.ts +2 -2
- package/lib/modules/Rules/index.js +69 -73
- package/lib/modules/Rules/types.d.ts +2 -2
- package/lib/modules/Schedule/index.d.ts +9 -0
- package/lib/modules/Schedule/index.js +11 -0
- package/lib/plugins/app-types/app/app.d.ts +1 -0
- package/lib/plugins/request.d.ts +2 -0
- package/lib/server/index.d.ts +107 -2
- package/lib/server/index.js +773 -51
- package/lib/server/modules/index.d.ts +6 -0
- package/lib/server/modules/index.js +16 -2
- package/lib/server/modules/menu/index.d.ts +19 -0
- package/lib/server/modules/menu/index.js +121 -2
- package/lib/server/modules/order/index.d.ts +87 -0
- package/lib/server/modules/order/index.js +543 -0
- package/lib/server/modules/order/types.d.ts +530 -0
- package/lib/server/modules/order/types.js +34 -0
- package/lib/server/modules/order/utils/filterBookings.d.ts +6 -0
- package/lib/server/modules/order/utils/filterBookings.js +320 -0
- package/lib/server/modules/order/utils/filterOrders.d.ts +15 -0
- package/lib/server/modules/order/utils/filterOrders.js +197 -0
- package/lib/server/modules/products/index.d.ts +117 -5
- package/lib/server/modules/products/index.js +799 -62
- package/lib/server/modules/products/types.d.ts +25 -1
- package/lib/server/modules/products/types.js +1 -0
- package/lib/server/modules/resource/index.d.ts +86 -0
- package/lib/server/modules/resource/index.js +557 -0
- package/lib/server/modules/resource/types.d.ts +121 -0
- package/lib/server/modules/resource/types.js +35 -0
- package/lib/server/modules/schedule/index.d.ts +19 -0
- package/lib/server/modules/schedule/index.js +141 -12
- package/lib/server/utils/product.d.ts +5 -0
- package/lib/server/utils/product.js +56 -27
- package/lib/solution/BookingTicket/index.d.ts +10 -2
- package/lib/solution/BookingTicket/index.js +10 -2
- package/lib/solution/BookingTicket/utils/scan/index.js +0 -1
- package/lib/solution/Checkout/index.d.ts +1 -0
- package/lib/solution/Checkout/index.js +399 -331
- package/lib/solution/Checkout/utils/index.d.ts +2 -1
- package/lib/solution/Checkout/utils/index.js +6 -4
- package/lib/solution/RegisterAndLogin/config.js +266 -1
- package/lib/solution/Sales/index.d.ts +96 -0
- package/lib/solution/Sales/index.js +416 -0
- package/lib/solution/Sales/types.d.ts +67 -0
- package/lib/solution/Sales/types.js +35 -0
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +14 -6
- package/lib/solution/ShopDiscount/types.d.ts +6 -0
- package/lib/solution/ShopDiscount/utils.d.ts +9 -0
- package/lib/solution/ShopDiscount/utils.js +6 -10
- package/lib/solution/index.d.ts +2 -1
- package/lib/solution/index.js +4 -2
- package/lib/types/index.d.ts +5 -0
- package/package.json +1 -1
|
@@ -12,6 +12,63 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
|
|
|
12
12
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
13
13
|
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; }
|
|
14
14
|
import Decimal from 'decimal.js';
|
|
15
|
+
/** 订单商品数量 */
|
|
16
|
+
export var getProductQuantity = function getProductQuantity(product) {
|
|
17
|
+
return product.quantity || product.product_quantity || 1;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 订单商品行唯一键,用于 maxPassesPerItem 按行、按件配额(同 SPU 不同规格视为不同行)。
|
|
22
|
+
*/
|
|
23
|
+
export function resolveWalletPassLineKey(product, indexInOrder) {
|
|
24
|
+
var m = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
25
|
+
var u1 = m.product_unique;
|
|
26
|
+
if (u1 != null && String(u1).length > 0) return String(u1);
|
|
27
|
+
var u2 = m.unique_identification_number;
|
|
28
|
+
if (u2 != null && String(u2).length > 0) return String(u2);
|
|
29
|
+
if ((product === null || product === void 0 ? void 0 : product.id) != null && String(product.id).length > 0) return "order_item:".concat(product.id);
|
|
30
|
+
if ((product === null || product === void 0 ? void 0 : product.product_unique_string) != null && String(product.product_unique_string).length > 0) {
|
|
31
|
+
return String(product.product_unique_string);
|
|
32
|
+
}
|
|
33
|
+
return "order_line_".concat(indexInOrder);
|
|
34
|
+
}
|
|
35
|
+
function getExpandedOrderLineQuantity(p) {
|
|
36
|
+
if ((p === null || p === void 0 ? void 0 : p._orderLineQuantity) != null && p._orderLineQuantity > 0) return p._orderLineQuantity;
|
|
37
|
+
return getProductQuantity(p);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** 该行允许消耗的「券次」上限:maxPassesPerItem × 订单行件数 */
|
|
41
|
+
function getMaxPassSlotsForExpandedLine(maxPassesPerItem, p) {
|
|
42
|
+
if (maxPassesPerItem <= 0) return Infinity;
|
|
43
|
+
return maxPassesPerItem * getExpandedOrderLineQuantity(p);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 本次抵扣占用多少「券次」配额:有抵扣时至少占 1,并与按金额折算的件数挂钩,不超过剩余额度。
|
|
48
|
+
*/
|
|
49
|
+
function computePassSlotsIncrement(deductAmount, deductQty, maxPassesPerItem, orderLineQuantity, currentUsage) {
|
|
50
|
+
if (maxPassesPerItem <= 0 || !deductAmount.greaterThan(0)) return 0;
|
|
51
|
+
var cap = maxPassesPerItem * orderLineQuantity;
|
|
52
|
+
var room = Math.max(0, cap - currentUsage);
|
|
53
|
+
if (room <= 0) return 0;
|
|
54
|
+
var raw = Math.max(1, Math.ceil(Number(deductQty)) || 1);
|
|
55
|
+
return Math.min(raw, room);
|
|
56
|
+
}
|
|
57
|
+
function applyMaxPassUsageIncrements(usageMap, walletPassProductId, maxPassesPerItem, deductionDetails) {
|
|
58
|
+
deductionDetails.forEach(function (detail) {
|
|
59
|
+
var _usageMap$get;
|
|
60
|
+
var lineKey = detail.lineKey;
|
|
61
|
+
if (!lineKey || maxPassesPerItem <= 0) return;
|
|
62
|
+
var orderLineQty = detail.orderLineQuantity != null && detail.orderLineQuantity > 0 ? detail.orderLineQuantity : 1;
|
|
63
|
+
var cur = ((_usageMap$get = usageMap.get(walletPassProductId)) === null || _usageMap$get === void 0 ? void 0 : _usageMap$get.get(lineKey)) || 0;
|
|
64
|
+
var inc = computePassSlotsIncrement(new Decimal(detail.deductAmount), detail.deductQuantity, maxPassesPerItem, orderLineQty, cur);
|
|
65
|
+
if (inc <= 0) return;
|
|
66
|
+
if (!usageMap.has(walletPassProductId)) usageMap.set(walletPassProductId, new Map());
|
|
67
|
+
var inner = usageMap.get(walletPassProductId);
|
|
68
|
+
inner.set(lineKey, cur + inc);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
15
72
|
// 辅助函数:根据 deductTaxAndFee 配置获取推荐使用金额
|
|
16
73
|
var getRecommendedAmount = function getRecommendedAmount(voucher) {
|
|
17
74
|
var _config$deductTaxAndF;
|
|
@@ -118,29 +175,19 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
118
175
|
var productsCopy = expandProductsWithBundleItems(products, true);
|
|
119
176
|
var remainingOrderAmount = new Decimal(orderTotalAmount); // 订单剩余应付金额
|
|
120
177
|
|
|
121
|
-
// ========== 辅助工具:maxPassesPerItem
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return ((_usageMap$get = usageMap.get(walletPassProductId)) === null || _usageMap$get === void 0 ? void 0 : _usageMap$get.get(orderItemProductId)) || 0;
|
|
178
|
+
// ========== 辅助工具:maxPassesPerItem(按订单行 + 件数)追踪 ==========
|
|
179
|
+
var getItemPassUsage = function getItemPassUsage(usageMap, walletPassProductId, lineKey) {
|
|
180
|
+
var _usageMap$get2;
|
|
181
|
+
return ((_usageMap$get2 = usageMap.get(walletPassProductId)) === null || _usageMap$get2 === void 0 ? void 0 : _usageMap$get2.get(lineKey)) || 0;
|
|
126
182
|
};
|
|
127
183
|
|
|
128
|
-
//
|
|
129
|
-
var incrementItemPassUsage = function incrementItemPassUsage(usageMap, walletPassProductId, orderItemProductId) {
|
|
130
|
-
var count = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
131
|
-
if (!usageMap.has(walletPassProductId)) {
|
|
132
|
-
usageMap.set(walletPassProductId, new Map());
|
|
133
|
-
}
|
|
134
|
-
var innerMap = usageMap.get(walletPassProductId);
|
|
135
|
-
innerMap.set(orderItemProductId, (innerMap.get(orderItemProductId) || 0) + count);
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
// 按 maxPassesPerItem 过滤商品:排除已达到单商品可用卡券上限的商品
|
|
139
|
-
// maxPassesPerItem 是 per-unit 的限制,总上限 = maxPassesPerItem × quantity
|
|
184
|
+
// 按 maxPassesPerItem 过滤:排除已达到该行「券次」上限的展开行(按 _walletPassLineKey)
|
|
140
185
|
var filterByMaxPassesPerItem = function filterByMaxPassesPerItem(products, usageMap, walletPassProductId, maxPassesPerItem) {
|
|
141
|
-
if (maxPassesPerItem <= 0) return products;
|
|
186
|
+
if (maxPassesPerItem <= 0) return products;
|
|
142
187
|
return products.filter(function (p) {
|
|
143
|
-
|
|
188
|
+
var lineKey = p._walletPassLineKey;
|
|
189
|
+
if (!lineKey) return true;
|
|
190
|
+
return getItemPassUsage(usageMap, walletPassProductId, lineKey) < getMaxPassSlotsForExpandedLine(maxPassesPerItem, p);
|
|
144
191
|
});
|
|
145
192
|
};
|
|
146
193
|
// ================================================================
|
|
@@ -219,9 +266,9 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
219
266
|
}, new Decimal(0));
|
|
220
267
|
}
|
|
221
268
|
} else {
|
|
222
|
-
//
|
|
269
|
+
// 非跨商品券:选择单价最高的商品(优先抵扣高价商品)
|
|
223
270
|
var maxProduct = applicableProducts.reduce(function (max, p) {
|
|
224
|
-
return p[
|
|
271
|
+
return p[unitPriceField].greaterThan(max[unitPriceField]) ? p : max;
|
|
225
272
|
});
|
|
226
273
|
// maxPassesPerItem 限制每张券最多抵扣的单位数
|
|
227
274
|
if (maxPassesPerItem > 0) {
|
|
@@ -289,7 +336,9 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
289
336
|
var availableAfterPassLimit = getApplicableProducts(voucher, productsData).filter(function (p) {
|
|
290
337
|
return p[amountField].greaterThan(0);
|
|
291
338
|
}).filter(function (p) {
|
|
292
|
-
|
|
339
|
+
var lineKey = p._walletPassLineKey;
|
|
340
|
+
if (!lineKey) return true;
|
|
341
|
+
return getItemPassUsage(itemPassUsage, product_id, lineKey) < getMaxPassSlotsForExpandedLine(maxPassesPerItem, p);
|
|
293
342
|
});
|
|
294
343
|
if (availableAfterPassLimit.length === 0) {
|
|
295
344
|
return {
|
|
@@ -325,7 +374,7 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
325
374
|
// 重置商品余额追踪(同时维护含税和不含税两个金额池)
|
|
326
375
|
var productsForRecommendation = expandProductsWithBundleItems(products, true);
|
|
327
376
|
remainingOrderAmount = new Decimal(orderTotalAmount);
|
|
328
|
-
// 追踪推荐阶段每个 Wallet Pass
|
|
377
|
+
// 追踪推荐阶段每个 Wallet Pass 商品对每个订单商品行的已使用卡券次数(按行唯一键)
|
|
329
378
|
var itemPassUsageMap = new Map();
|
|
330
379
|
|
|
331
380
|
/**
|
|
@@ -428,9 +477,9 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
428
477
|
}, new Decimal(0));
|
|
429
478
|
}
|
|
430
479
|
} else {
|
|
431
|
-
//
|
|
480
|
+
// 非跨商品券:选择单价最高的商品(优先抵扣高价商品)
|
|
432
481
|
var maxProduct = applicableProducts.reduce(function (max, p) {
|
|
433
|
-
return p[
|
|
482
|
+
return p[unitPriceField].greaterThan(max[unitPriceField]) ? p : max;
|
|
434
483
|
});
|
|
435
484
|
// maxPassesPerItem 限制每张券最多抵扣的单位数
|
|
436
485
|
if (maxPassesPerItem > 0) {
|
|
@@ -480,6 +529,8 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
480
529
|
product_id: _product.product_id,
|
|
481
530
|
parent_product_id: _product.parent_product_id || null,
|
|
482
531
|
is_bundle_item: _product.is_bundle_item || false,
|
|
532
|
+
lineKey: _product._walletPassLineKey,
|
|
533
|
+
orderLineQuantity: getExpandedOrderLineQuantity(_product),
|
|
483
534
|
deductAmount: actualDeductAmount.toNumber(),
|
|
484
535
|
// 转换为数字
|
|
485
536
|
deductQuantity: actualDeductQty // 抵扣涉及的数量(用于记录)
|
|
@@ -491,9 +542,9 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
491
542
|
_iterator3.f();
|
|
492
543
|
}
|
|
493
544
|
} else {
|
|
494
|
-
//
|
|
545
|
+
// 非跨商品券:选择单价最高的商品(优先抵扣高价商品)
|
|
495
546
|
var targetProduct = applicableProducts.reduce(function (max, p) {
|
|
496
|
-
return p[
|
|
547
|
+
return p[unitPriceField].greaterThan(max[unitPriceField]) ? p : max;
|
|
497
548
|
});
|
|
498
549
|
|
|
499
550
|
// maxPassesPerItem 限制每张券最多抵扣的单位数
|
|
@@ -513,6 +564,8 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
513
564
|
product_id: targetProduct.product_id,
|
|
514
565
|
parent_product_id: targetProduct.parent_product_id || null,
|
|
515
566
|
is_bundle_item: targetProduct.is_bundle_item || false,
|
|
567
|
+
lineKey: targetProduct._walletPassLineKey,
|
|
568
|
+
orderLineQuantity: getExpandedOrderLineQuantity(targetProduct),
|
|
516
569
|
deductAmount: _actualDeductAmount.toNumber(),
|
|
517
570
|
deductQuantity: _actualDeductQty
|
|
518
571
|
});
|
|
@@ -524,11 +577,7 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
524
577
|
|
|
525
578
|
// 更新券使用次数(按 product_id 统计)
|
|
526
579
|
usedVoucherCounts.set(product_id, (usedVoucherCounts.get(product_id) || 0) + 1);
|
|
527
|
-
|
|
528
|
-
// 更新 maxPassesPerItem 追踪:按实际抵扣数量递增
|
|
529
|
-
deductionDetails.forEach(function (detail) {
|
|
530
|
-
incrementItemPassUsage(itemPassUsageMap, product_id, detail.product_id, detail.deductQuantity);
|
|
531
|
-
});
|
|
580
|
+
applyMaxPassUsageIncrements(itemPassUsageMap, product_id, maxPassesPerItem, deductionDetails);
|
|
532
581
|
|
|
533
582
|
// 添加到推荐列表(包含基于当前剩余金额计算的 available_max_amount)
|
|
534
583
|
recommendedVouchers.push(_objectSpread(_objectSpread({}, voucher), {}, {
|
|
@@ -611,25 +660,18 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
611
660
|
var remainingOrderAmount = new Decimal(orderTotalAmount);
|
|
612
661
|
var selectedWithDetails = [];
|
|
613
662
|
|
|
614
|
-
// 追踪每个 Wallet Pass
|
|
615
|
-
// Map<walletPassProductId, Map<orderItemProductId, usedCount>>
|
|
663
|
+
// 追踪每个 Wallet Pass 商品对每个订单商品行的已使用卡券次数(按行唯一键)
|
|
616
664
|
var itemPassUsageMap = new Map();
|
|
617
|
-
var
|
|
665
|
+
var getItemPassUsageRecalc = function getItemPassUsageRecalc(walletPassProductId, lineKey) {
|
|
618
666
|
var _itemPassUsageMap$get;
|
|
619
|
-
return ((_itemPassUsageMap$get = itemPassUsageMap.get(walletPassProductId)) === null || _itemPassUsageMap$get === void 0 ? void 0 : _itemPassUsageMap$get.get(
|
|
620
|
-
};
|
|
621
|
-
var incrementItemPassUsage = function incrementItemPassUsage(walletPassProductId, orderItemProductId) {
|
|
622
|
-
var count = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
623
|
-
if (!itemPassUsageMap.has(walletPassProductId)) {
|
|
624
|
-
itemPassUsageMap.set(walletPassProductId, new Map());
|
|
625
|
-
}
|
|
626
|
-
var innerMap = itemPassUsageMap.get(walletPassProductId);
|
|
627
|
-
innerMap.set(orderItemProductId, (innerMap.get(orderItemProductId) || 0) + count);
|
|
667
|
+
return ((_itemPassUsageMap$get = itemPassUsageMap.get(walletPassProductId)) === null || _itemPassUsageMap$get === void 0 ? void 0 : _itemPassUsageMap$get.get(lineKey)) || 0;
|
|
628
668
|
};
|
|
629
|
-
var
|
|
630
|
-
if (maxPassesPerItem <= 0) return products;
|
|
669
|
+
var filterByMaxPassesPerItemRecalc = function filterByMaxPassesPerItemRecalc(products, walletPassProductId, maxPassesPerItem) {
|
|
670
|
+
if (maxPassesPerItem <= 0) return products;
|
|
631
671
|
return products.filter(function (p) {
|
|
632
|
-
|
|
672
|
+
var lineKey = p._walletPassLineKey;
|
|
673
|
+
if (!lineKey) return true;
|
|
674
|
+
return getItemPassUsageRecalc(walletPassProductId, lineKey) < getMaxPassSlotsForExpandedLine(maxPassesPerItem, p);
|
|
633
675
|
});
|
|
634
676
|
};
|
|
635
677
|
|
|
@@ -654,8 +696,8 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
654
696
|
return p[amountField].greaterThan(0);
|
|
655
697
|
});
|
|
656
698
|
|
|
657
|
-
// 按 maxPassesPerItem
|
|
658
|
-
applicableProducts =
|
|
699
|
+
// 按 maxPassesPerItem 过滤:排除已达到该行券次上限的展开行
|
|
700
|
+
applicableProducts = filterByMaxPassesPerItemRecalc(applicableProducts, selectedVoucher.product_id, maxPassesPerItem);
|
|
659
701
|
if (applicableProducts.length === 0) {
|
|
660
702
|
// 无适用商品,跳过
|
|
661
703
|
selectedWithDetails.push(_objectSpread(_objectSpread({}, selectedVoucher), {}, {
|
|
@@ -706,6 +748,8 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
706
748
|
product_id: product.product_id,
|
|
707
749
|
parent_product_id: product.parent_product_id || null,
|
|
708
750
|
is_bundle_item: product.is_bundle_item || false,
|
|
751
|
+
lineKey: product._walletPassLineKey,
|
|
752
|
+
orderLineQuantity: getExpandedOrderLineQuantity(product),
|
|
709
753
|
deductAmount: actualDeductAmount.toNumber(),
|
|
710
754
|
// 转换为数字
|
|
711
755
|
deductQuantity: actualDeductQty // 抵扣涉及的数量(用于记录)
|
|
@@ -717,9 +761,9 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
717
761
|
_iterator4.f();
|
|
718
762
|
}
|
|
719
763
|
} else {
|
|
720
|
-
//
|
|
764
|
+
// 非跨商品券:选择单价最高的商品(优先抵扣高价商品)
|
|
721
765
|
var targetProduct = applicableProducts.reduce(function (max, p) {
|
|
722
|
-
return p[
|
|
766
|
+
return p[unitPriceField].greaterThan(max[unitPriceField]) ? p : max;
|
|
723
767
|
});
|
|
724
768
|
|
|
725
769
|
// maxPassesPerItem 限制每张券最多抵扣的单位数
|
|
@@ -739,6 +783,8 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
739
783
|
product_id: targetProduct.product_id,
|
|
740
784
|
parent_product_id: targetProduct.parent_product_id || null,
|
|
741
785
|
is_bundle_item: targetProduct.is_bundle_item || false,
|
|
786
|
+
lineKey: targetProduct._walletPassLineKey,
|
|
787
|
+
orderLineQuantity: getExpandedOrderLineQuantity(targetProduct),
|
|
742
788
|
deductAmount: _actualDeductAmount2.toNumber(),
|
|
743
789
|
deductQuantity: _actualDeductQty2
|
|
744
790
|
});
|
|
@@ -747,11 +793,7 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
747
793
|
|
|
748
794
|
// 更新订单剩余金额
|
|
749
795
|
remainingOrderAmount = remainingOrderAmount.minus(totalDeducted);
|
|
750
|
-
|
|
751
|
-
// 更新 maxPassesPerItem 追踪:按实际抵扣数量递增
|
|
752
|
-
deductionDetails.forEach(function (detail) {
|
|
753
|
-
incrementItemPassUsage(selectedVoucher.product_id, detail.product_id, detail.deductQuantity);
|
|
754
|
-
});
|
|
796
|
+
applyMaxPassUsageIncrements(itemPassUsageMap, selectedVoucher.product_id, maxPassesPerItem, deductionDetails);
|
|
755
797
|
selectedWithDetails.push(_objectSpread(_objectSpread({}, selectedVoucher), {}, {
|
|
756
798
|
actualDeduction: totalDeducted.toNumber(),
|
|
757
799
|
// 转换为数字
|
|
@@ -824,7 +866,7 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
824
866
|
});
|
|
825
867
|
|
|
826
868
|
// 按 maxPassesPerItem 过滤:排除已达到单商品可用卡券上限的商品
|
|
827
|
-
applicableProducts =
|
|
869
|
+
applicableProducts = filterByMaxPassesPerItemRecalc(applicableProducts, product_id, maxPassesPerItem);
|
|
828
870
|
if (applicableProducts.length === 0) {
|
|
829
871
|
isAvailable = false;
|
|
830
872
|
reasonCode = 'not_meet_the_required_conditions';
|
|
@@ -864,9 +906,9 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
864
906
|
}, new Decimal(0));
|
|
865
907
|
}
|
|
866
908
|
} else {
|
|
867
|
-
//
|
|
909
|
+
// 非跨商品券:选择单价最高的商品(优先抵扣高价商品)
|
|
868
910
|
var maxProduct = applicableProducts.reduce(function (max, p) {
|
|
869
|
-
return p[
|
|
911
|
+
return p[unitPriceField].greaterThan(max[unitPriceField]) ? p : max;
|
|
870
912
|
});
|
|
871
913
|
// maxPassesPerItem 限制每张券最多抵扣的单位数
|
|
872
914
|
if (maxPassesPerItem > 0) {
|
|
@@ -938,7 +980,7 @@ export var getProductDiscountDifference = function getProductDiscountDifference(
|
|
|
938
980
|
* @returns 商品单价
|
|
939
981
|
*/
|
|
940
982
|
export var getMainProductPrice = function getMainProductPrice(product, isDeductTaxAndFee) {
|
|
941
|
-
var _product$metadata4, _product$metadata5, _product$metadata6;
|
|
983
|
+
var _product$metadata4, _product$metadata5, _product$metadata6, _product$metadata7;
|
|
942
984
|
var mainProductPrice = new Decimal((product === null || product === void 0 ? void 0 : product.main_product_selling_price) || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.main_product_selling_price) || 0);
|
|
943
985
|
var _iterator6 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
|
|
944
986
|
_step6;
|
|
@@ -958,14 +1000,14 @@ export var getMainProductPrice = function getMainProductPrice(product, isDeductT
|
|
|
958
1000
|
} finally {
|
|
959
1001
|
_iterator6.f();
|
|
960
1002
|
}
|
|
961
|
-
var taxFee = new Decimal((product === null || product === void 0 ? void 0 : product.tax_fee) || (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.main_product_attached_bundle_tax_fee) || 0);
|
|
1003
|
+
var taxFee = new Decimal((product === null || product === void 0 ? void 0 : product.tax_fee) || (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.main_product_attached_bundle_tax_fee) || 0).add((product === null || product === void 0 || (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.tax_fee_rounding_remainder) || 0);
|
|
962
1004
|
if (product.is_price_include_tax === 1) {
|
|
963
1005
|
taxFee = new Decimal(0);
|
|
964
1006
|
}
|
|
965
1007
|
|
|
966
1008
|
// 税费
|
|
967
1009
|
// 附加费
|
|
968
|
-
var surchargeFee = new Decimal((product === null || product === void 0 || (_product$
|
|
1010
|
+
var surchargeFee = new Decimal((product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.main_product_attached_bundle_surcharge_fee) || 0);
|
|
969
1011
|
|
|
970
1012
|
// 税费附加费总额
|
|
971
1013
|
var taxAndFeeTotal = taxFee.add(surchargeFee);
|
|
@@ -1047,8 +1089,9 @@ export var getBundleItemPrice = function getBundleItemPrice(bundleItem, parentQu
|
|
|
1047
1089
|
*/
|
|
1048
1090
|
var expandProductsWithBundleItems = function expandProductsWithBundleItems(products, deductTaxAndFee) {
|
|
1049
1091
|
var expandedProducts = [];
|
|
1050
|
-
products.forEach(function (product) {
|
|
1092
|
+
products.forEach(function (product, indexInOrder) {
|
|
1051
1093
|
var productQuantity = getProductQuantity(product);
|
|
1094
|
+
var parentLineKey = resolveWalletPassLineKey(product, indexInOrder);
|
|
1052
1095
|
|
|
1053
1096
|
// 计算主商品单价(含税和不含税)
|
|
1054
1097
|
var unitPriceWithTax = getMainProductPrice(product, true);
|
|
@@ -1063,6 +1106,8 @@ var expandProductsWithBundleItems = function expandProductsWithBundleItems(produ
|
|
|
1063
1106
|
expandedProducts.push(_objectSpread(_objectSpread({}, product), {}, {
|
|
1064
1107
|
is_bundle_item: false,
|
|
1065
1108
|
parent_product_id: null,
|
|
1109
|
+
_walletPassLineKey: parentLineKey,
|
|
1110
|
+
_orderLineQuantity: productQuantity,
|
|
1066
1111
|
// 单价(用于按 quantity 计算抵扣)
|
|
1067
1112
|
unitPriceWithTax: new Decimal(unitPriceWithTax),
|
|
1068
1113
|
unitPricePure: new Decimal(unitPricePure),
|
|
@@ -1079,6 +1124,7 @@ var expandProductsWithBundleItems = function expandProductsWithBundleItems(produ
|
|
|
1079
1124
|
product.product_bundle.forEach(function (bundleItem) {
|
|
1080
1125
|
if (getBundleItemIsOriginalPrice(bundleItem)) {
|
|
1081
1126
|
var bundleQuantity = bundleItem.num * productQuantity;
|
|
1127
|
+
var bundleLineKey = "".concat(parentLineKey, "#bundle:").concat(bundleItem.bundle_id, ":").concat(bundleItem.bundle_product_id);
|
|
1082
1128
|
// 计算子商品单价(注意:getBundleItemPrice 返回的是总价,需要除以数量得到单价)
|
|
1083
1129
|
var bundleUnitPriceWithTax = new Decimal(getBundleItemPrice(bundleItem, 1, true)).dividedBy(bundleItem.num);
|
|
1084
1130
|
var bundleUnitPricePure = new Decimal(getBundleItemPrice(bundleItem, 1, false)).dividedBy(bundleItem.num);
|
|
@@ -1096,6 +1142,8 @@ var expandProductsWithBundleItems = function expandProductsWithBundleItems(produ
|
|
|
1096
1142
|
parent_product_id: product.product_id,
|
|
1097
1143
|
quantity: bundleQuantity,
|
|
1098
1144
|
// 子商品数量 * 主商品数量
|
|
1145
|
+
_walletPassLineKey: bundleLineKey,
|
|
1146
|
+
_orderLineQuantity: bundleQuantity,
|
|
1099
1147
|
// 单价(用于按 quantity 计算抵扣)
|
|
1100
1148
|
unitPriceWithTax: bundleUnitPriceWithTax,
|
|
1101
1149
|
unitPricePure: bundleUnitPricePure,
|
|
@@ -1113,15 +1161,6 @@ var expandProductsWithBundleItems = function expandProductsWithBundleItems(produ
|
|
|
1113
1161
|
return expandedProducts;
|
|
1114
1162
|
};
|
|
1115
1163
|
|
|
1116
|
-
/**
|
|
1117
|
-
* 获取商品数量
|
|
1118
|
-
* @param product 商品
|
|
1119
|
-
* @returns 商品数量
|
|
1120
|
-
*/
|
|
1121
|
-
export var getProductQuantity = function getProductQuantity(product) {
|
|
1122
|
-
return product.quantity || product.product_quantity || 1;
|
|
1123
|
-
};
|
|
1124
|
-
|
|
1125
1164
|
// bundle商品是否是原价
|
|
1126
1165
|
export var getBundleItemIsOriginalPrice = function getBundleItemIsOriginalPrice(item) {
|
|
1127
1166
|
return (item === null || item === void 0 ? void 0 : item.price_type) === 'markup' && (item === null || item === void 0 ? void 0 : item.price_type_ext) === 'product_price';
|
|
@@ -17,14 +17,18 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
17
17
|
setOriginalDiscountList(originalDiscountList: Discount[]): Promise<void>;
|
|
18
18
|
getOriginalDiscountList(): Discount[];
|
|
19
19
|
loadPrepareConfig(params: {
|
|
20
|
-
action?: 'create';
|
|
20
|
+
action?: 'create' | 'update';
|
|
21
21
|
with_good_pass: 0 | 1;
|
|
22
22
|
with_discount_card: 0 | 1;
|
|
23
23
|
customer_id: number;
|
|
24
24
|
with_wallet_pass_holder: 0 | 1;
|
|
25
25
|
request_timezone: string;
|
|
26
|
+
order_id?: number;
|
|
27
|
+
}): Promise<Discount[]>;
|
|
28
|
+
batchSearch(code: string, options?: {
|
|
29
|
+
customerId?: number;
|
|
30
|
+
orderId?: number;
|
|
26
31
|
}): Promise<Discount[]>;
|
|
27
|
-
batchSearch(code: string, customerId?: number): Promise<Discount[]>;
|
|
28
32
|
batchSearchByProductIds(productIds: number[]): Promise<any>;
|
|
29
33
|
filterEnabledDiscountList(discountList: Discount[]): Discount[];
|
|
30
34
|
private checkUsageCreditsLimit;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
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); }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
2
4
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
5
|
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
6
|
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); }
|
|
@@ -176,13 +178,14 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
176
178
|
}, {
|
|
177
179
|
key: "batchSearch",
|
|
178
180
|
value: function () {
|
|
179
|
-
var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code,
|
|
180
|
-
var result, resultDiscountList;
|
|
181
|
+
var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, options) {
|
|
182
|
+
var _ref, customerId, orderId, result, resultDiscountList;
|
|
181
183
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
182
184
|
while (1) switch (_context5.prev = _context5.next) {
|
|
183
185
|
case 0:
|
|
184
|
-
|
|
185
|
-
|
|
186
|
+
_ref = options || {}, customerId = _ref.customerId, orderId = _ref.orderId;
|
|
187
|
+
_context5.next = 3;
|
|
188
|
+
return this.request.get("/machinecode/batch-search", _objectSpread(_objectSpread({
|
|
186
189
|
code: code,
|
|
187
190
|
translate_flag: 1,
|
|
188
191
|
tags: ['good_pass', 'product_discount_card'],
|
|
@@ -190,14 +193,17 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
190
193
|
relation_product: 1,
|
|
191
194
|
with: ['extensionData', 'customScheduleSnapshot', 'holder.detail'],
|
|
192
195
|
order_behavior_count: 1,
|
|
193
|
-
order_behavior_count_customer_id: customerId || 1
|
|
196
|
+
order_behavior_count_customer_id: customerId || 1
|
|
197
|
+
}, orderId ? {
|
|
198
|
+
order_behavior_count_order_id: orderId
|
|
199
|
+
} : {}), {}, {
|
|
194
200
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
195
|
-
});
|
|
196
|
-
case
|
|
201
|
+
}));
|
|
202
|
+
case 3:
|
|
197
203
|
result = _context5.sent;
|
|
198
204
|
resultDiscountList = this.filterEnabledDiscountList((result === null || result === void 0 ? void 0 : result.data) || []) || [];
|
|
199
205
|
return _context5.abrupt("return", resultDiscountList);
|
|
200
|
-
case
|
|
206
|
+
case 6:
|
|
201
207
|
case "end":
|
|
202
208
|
return _context5.stop();
|
|
203
209
|
}
|
|
@@ -23,7 +23,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
23
23
|
*/
|
|
24
24
|
private logError;
|
|
25
25
|
createOrder(params: CommitOrderParams['query']): {
|
|
26
|
-
type: "
|
|
26
|
+
type: "appointment_booking" | "virtual";
|
|
27
27
|
platform: string;
|
|
28
28
|
sales_channel: string;
|
|
29
29
|
order_sales_channel: string;
|
|
@@ -250,11 +250,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
250
250
|
key: "createOrderByCheckout",
|
|
251
251
|
value: (function () {
|
|
252
252
|
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
253
|
-
var _params$bookings2, _params$relation_prod2, _params$
|
|
254
|
-
var _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
|
|
253
|
+
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
254
|
+
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
|
|
255
255
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
256
256
|
while (1) switch (_context3.prev = _context3.next) {
|
|
257
257
|
case 0:
|
|
258
|
+
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
259
|
+
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
260
|
+
params.payments = (_params$payments = params.payments) === null || _params$payments === void 0 ? void 0 : _params$payments.filter(function (p) {
|
|
261
|
+
return !onlineStorePaymentCodeList.includes(p.code);
|
|
262
|
+
});
|
|
258
263
|
this.logInfo('createOrderByCheckout called', {
|
|
259
264
|
type: params.type,
|
|
260
265
|
platform: params.platform,
|
|
@@ -262,14 +267,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
262
267
|
customer_id: params.customer_id,
|
|
263
268
|
bookingsCount: ((_params$bookings2 = params.bookings) === null || _params$bookings2 === void 0 ? void 0 : _params$bookings2.length) || 0,
|
|
264
269
|
relationProductsCount: ((_params$relation_prod2 = params.relation_products) === null || _params$relation_prod2 === void 0 ? void 0 : _params$relation_prod2.length) || 0,
|
|
265
|
-
paymentsCount: ((_params$
|
|
270
|
+
paymentsCount: ((_params$payments2 = params.payments) === null || _params$payments2 === void 0 ? void 0 : _params$payments2.length) || 0,
|
|
266
271
|
depositAmount: params.deposit_amount,
|
|
267
272
|
productTaxFee: params.product_tax_fee,
|
|
268
273
|
note: params.note,
|
|
269
274
|
scheduleDate: params.schedule_date,
|
|
270
275
|
hasOrderId: !!params.order_id,
|
|
271
276
|
orderIdIncluded: params.order_id,
|
|
272
|
-
paymentMethods: ((_params$
|
|
277
|
+
paymentMethods: ((_params$payments3 = params.payments) === null || _params$payments3 === void 0 ? void 0 : _params$payments3.map(function (p) {
|
|
273
278
|
return p.code;
|
|
274
279
|
})) || []
|
|
275
280
|
});
|
|
@@ -280,9 +285,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
280
285
|
customer_id: params.customer_id,
|
|
281
286
|
bookingsCount: ((_params$bookings3 = params.bookings) === null || _params$bookings3 === void 0 ? void 0 : _params$bookings3.length) || 0,
|
|
282
287
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
283
|
-
paymentsCount: ((_params$
|
|
288
|
+
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
284
289
|
});
|
|
285
|
-
_context3.prev =
|
|
290
|
+
_context3.prev = 4;
|
|
286
291
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
287
292
|
orderData = _objectSpread({
|
|
288
293
|
sales_channel: 'my_pisel',
|
|
@@ -346,9 +351,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
346
351
|
});
|
|
347
352
|
|
|
348
353
|
// 调用后端接口
|
|
349
|
-
_context3.next =
|
|
354
|
+
_context3.next = 12;
|
|
350
355
|
return this.request.post('/order/checkout', orderData);
|
|
351
|
-
case
|
|
356
|
+
case 12:
|
|
352
357
|
response = _context3.sent;
|
|
353
358
|
this.logInfo('Order API called successfully', {
|
|
354
359
|
response: response
|
|
@@ -358,19 +363,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
358
363
|
hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
|
|
359
364
|
});
|
|
360
365
|
return _context3.abrupt("return", response);
|
|
361
|
-
case
|
|
362
|
-
_context3.prev =
|
|
363
|
-
_context3.t0 = _context3["catch"](
|
|
366
|
+
case 18:
|
|
367
|
+
_context3.prev = 18;
|
|
368
|
+
_context3.t0 = _context3["catch"](4);
|
|
364
369
|
console.error('[Order] createOrderByCheckout 创建订单失败:', _context3.t0);
|
|
365
370
|
this.logInfo('Order API called failed', {
|
|
366
371
|
error: _context3.t0 instanceof Error ? _context3.t0.message : String(_context3.t0)
|
|
367
372
|
});
|
|
368
373
|
throw _context3.t0;
|
|
369
|
-
case
|
|
374
|
+
case 23:
|
|
370
375
|
case "end":
|
|
371
376
|
return _context3.stop();
|
|
372
377
|
}
|
|
373
|
-
}, _callee3, this, [[
|
|
378
|
+
}, _callee3, this, [[4, 18]]);
|
|
374
379
|
}));
|
|
375
380
|
function createOrderByCheckout(_x4) {
|
|
376
381
|
return _createOrderByCheckout.apply(this, arguments);
|
|
@@ -24,11 +24,14 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
|
|
|
24
24
|
window: WindowPlugin;
|
|
25
25
|
private dbManager;
|
|
26
26
|
private logger;
|
|
27
|
+
private voucherUpdateLockByOrderUuid;
|
|
27
28
|
protected otherParams: any;
|
|
28
29
|
cash: CashPayment;
|
|
29
30
|
eftpos: EftposPayment;
|
|
30
31
|
wallet: WalletPassPayment;
|
|
31
32
|
constructor(name?: string, version?: string);
|
|
33
|
+
private runVoucherUpdateLocked;
|
|
34
|
+
private normalizeVoucherPaymentItems;
|
|
32
35
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
33
36
|
/**
|
|
34
37
|
* 记录信息日志
|
|
@@ -51,6 +54,7 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
|
|
|
51
54
|
*
|
|
52
55
|
*/
|
|
53
56
|
private registerNetworkHandlers;
|
|
57
|
+
private filterPayMethods;
|
|
54
58
|
/**
|
|
55
59
|
* 获取支付方式列表
|
|
56
60
|
*/
|