@pisell/pisellos 2.2.12 → 2.2.13
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/Customer/index.js +1 -1
- package/dist/modules/Payment/index.js +2 -2
- package/dist/modules/Payment/types.d.ts +1 -0
- package/dist/modules/Payment/walletpass.js +3 -1
- package/dist/modules/ProductList/index.js +8 -9
- package/dist/modules/Rules/index.js +66 -34
- package/dist/solution/BookingByStep/index.js +29 -8
- package/dist/solution/BookingByStep/utils/products.d.ts +6 -0
- package/dist/solution/BookingByStep/utils/products.js +10 -0
- package/dist/solution/Checkout/index.js +61 -17
- package/lib/modules/Customer/index.js +1 -1
- package/lib/modules/Payment/index.js +1 -1
- package/lib/modules/Payment/types.d.ts +1 -0
- package/lib/modules/Payment/walletpass.js +10 -1
- package/lib/modules/ProductList/index.js +0 -7
- package/lib/modules/Rules/index.js +46 -36
- package/lib/solution/BookingByStep/index.js +15 -2
- package/lib/solution/BookingByStep/utils/products.d.ts +6 -0
- package/lib/solution/BookingByStep/utils/products.js +8 -2
- package/lib/solution/Checkout/index.js +66 -17
- package/package.json +2 -2
|
@@ -154,7 +154,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
154
154
|
skip: skip,
|
|
155
155
|
num: num,
|
|
156
156
|
sort_by: SORT_BY,
|
|
157
|
-
with: ['latestWalletDetail.wallet'],
|
|
157
|
+
with: ['latestWalletDetail.wallet', 'contactsInfo'],
|
|
158
158
|
search_wallet_flag: 1,
|
|
159
159
|
search_wallet_pass_flag: 1
|
|
160
160
|
}, search && {
|
|
@@ -21,7 +21,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
21
21
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
22
22
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
23
23
|
import { BaseModule } from "../BaseModule";
|
|
24
|
-
import { PaymentStatus,
|
|
24
|
+
import { PaymentStatus, PaymentMethodType, RoundingRule } from "./types";
|
|
25
25
|
import { getUniqueId } from "../Cart/utils";
|
|
26
26
|
import { CashPaymentImpl } from "./cash";
|
|
27
27
|
import { EftposPaymentImpl } from "./eftpos";
|
|
@@ -1200,7 +1200,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1200
1200
|
this.logInfo('更新订单支付项完成', {
|
|
1201
1201
|
orderUuid: orderUuid
|
|
1202
1202
|
});
|
|
1203
|
-
this.core.effects.emit(
|
|
1203
|
+
this.core.effects.emit("".concat(this.name, ":onPaymentAdded"), {
|
|
1204
1204
|
orderUuid: orderUuid,
|
|
1205
1205
|
payment: newPaymentItem
|
|
1206
1206
|
});
|
|
@@ -64,12 +64,14 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
64
64
|
amountInfo = businessData.amountInfo,
|
|
65
65
|
products = businessData.products,
|
|
66
66
|
order_wait_pay_amount = businessData.order_wait_pay_amount,
|
|
67
|
-
payment_order_id = businessData.payment_order_id
|
|
67
|
+
payment_order_id = businessData.payment_order_id,
|
|
68
|
+
is_price_include_tax = businessData.is_price_include_tax;
|
|
68
69
|
|
|
69
70
|
// 转换金额为数字类型
|
|
70
71
|
var totalAmount = Number(amountInfo.totalAmount);
|
|
71
72
|
var subTotal = Number(amountInfo.subTotal);
|
|
72
73
|
var walletParams = {
|
|
74
|
+
is_price_include_tax: is_price_include_tax,
|
|
73
75
|
sale_channel: 'pos',
|
|
74
76
|
customer_id: customer_id || 0,
|
|
75
77
|
// 提供默认值,确保类型为 number
|
|
@@ -140,17 +140,16 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
140
140
|
productsData = _context3.sent;
|
|
141
141
|
sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
|
|
142
142
|
return Number(b.sort) - Number(a.sort);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
143
|
+
}); // if (sortedList.length) {
|
|
144
|
+
// sortedList.forEach((n: any) => {
|
|
145
|
+
// if (n.is_eject !== 1 && n['schedule.ids'] && n['schedule.ids'].length) {
|
|
146
|
+
// n.is_eject = 1
|
|
147
|
+
// }
|
|
148
|
+
// })
|
|
149
|
+
// }
|
|
151
150
|
this.addProduct(sortedList);
|
|
152
151
|
return _context3.abrupt("return", sortedList);
|
|
153
|
-
case
|
|
152
|
+
case 10:
|
|
154
153
|
case "end":
|
|
155
154
|
return _context3.stop();
|
|
156
155
|
}
|
|
@@ -24,10 +24,12 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
24
24
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
25
25
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
26
26
|
import { BaseModule } from "../BaseModule";
|
|
27
|
-
import { uniqueById, getDiscountAmount, getDiscountListAmountTotal, getDiscountListAmount
|
|
27
|
+
import { uniqueById, getDiscountAmount, filterDiscountListByBookingTime, getDiscountListAmountTotal, getDiscountListAmount } from "../../solution/ShopDiscount/utils";
|
|
28
28
|
import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils";
|
|
29
29
|
import Decimal from 'decimal.js';
|
|
30
|
+
import { isBoolean } from 'lodash-es';
|
|
30
31
|
import dayjs from 'dayjs';
|
|
32
|
+
|
|
31
33
|
// 临时变量
|
|
32
34
|
var flatItem;
|
|
33
35
|
export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
@@ -447,7 +449,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
447
449
|
var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
|
|
448
450
|
|
|
449
451
|
// 判断优惠券是否适用于该商品
|
|
450
|
-
if (isAvailableProduct && isLimitedProduct &&
|
|
452
|
+
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable) {
|
|
451
453
|
var _discountApplicabilit, _discount$metadata;
|
|
452
454
|
// 记录此优惠券适用的商品
|
|
453
455
|
(_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
|
|
@@ -488,7 +490,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
488
490
|
// 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
|
|
489
491
|
// 🔥 使用扁平化后的列表进行处理
|
|
490
492
|
sortedFlattenedList.forEach(function (flatItem, index) {
|
|
491
|
-
var _product5, _product$discount_lis2, _product6
|
|
493
|
+
var _product5, _product$discount_lis2, _product6;
|
|
492
494
|
// 获取商品数据
|
|
493
495
|
var product, originProduct;
|
|
494
496
|
if (flatItem.type === 'main') {
|
|
@@ -537,7 +539,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
537
539
|
})) && (discount.tag || discount.type) === 'good_pass') return false;
|
|
538
540
|
|
|
539
541
|
// 折扣卡商品价格为0时不可用
|
|
540
|
-
if ((Number(product.price)
|
|
542
|
+
if ((Number(product.price) <= 0 || !product.price) && !((_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.find(function (n) {
|
|
541
543
|
var _n$discount2;
|
|
542
544
|
return ((_n$discount2 = n.discount) === null || _n$discount2 === void 0 ? void 0 : _n$discount2.resource_id) === discount.id;
|
|
543
545
|
})) && (discount.tag || discount.type) !== 'good_pass') return false;
|
|
@@ -664,18 +666,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
664
666
|
}
|
|
665
667
|
}
|
|
666
668
|
}
|
|
667
|
-
if (options !== null && options !== void 0 && options.selectedList && (_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.some(function (item) {
|
|
668
|
-
var _options$selectedList4;
|
|
669
|
-
return options === null || options === void 0 || (_options$selectedList4 = options.selectedList) === null || _options$selectedList4 === void 0 ? void 0 : _options$selectedList4.some(function (n) {
|
|
670
|
-
var _item$discount7;
|
|
671
|
-
return n.discountId === ((_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.resource_id);
|
|
672
|
-
});
|
|
673
|
-
})) {
|
|
674
|
-
isManualDiscount = false;
|
|
675
|
-
}
|
|
676
669
|
|
|
677
670
|
// 如果没有适用的优惠券,或者手动折扣,则不适用优惠券
|
|
678
|
-
if (applicableDiscounts.length === 0 || isManualDiscount) {
|
|
671
|
+
if (applicableDiscounts.length === 0 || isManualDiscount || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
679
672
|
if (flatItem.type === 'main') {
|
|
680
673
|
// 主商品:保持原有逻辑
|
|
681
674
|
if (product.isClient) {
|
|
@@ -701,7 +694,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
701
694
|
discount_list: []
|
|
702
695
|
}))]);
|
|
703
696
|
} else {
|
|
704
|
-
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
|
|
697
|
+
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
|
|
698
|
+
price: product.price,
|
|
699
|
+
main_product_selling_price: product.price
|
|
700
|
+
} : {
|
|
705
701
|
_id: product._id.split('___')[0] + '___' + index,
|
|
706
702
|
total: product.origin_total || product.total,
|
|
707
703
|
price: product.price,
|
|
@@ -714,7 +710,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
714
710
|
// bundle子商品:保存到扁平化Map
|
|
715
711
|
processedFlatItemsMap.set(flatItem._id, [_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
716
712
|
discount_list: [],
|
|
717
|
-
price: flatItem.bundleItem.original_price,
|
|
713
|
+
price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
|
|
718
714
|
processed: true
|
|
719
715
|
})]);
|
|
720
716
|
}
|
|
@@ -746,7 +742,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
746
742
|
}));
|
|
747
743
|
}
|
|
748
744
|
for (var i = 0; i < splitCount; i++) {
|
|
749
|
-
var _product$
|
|
745
|
+
var _product$discount_lis10, _originProduct, _selectedDiscount$met;
|
|
750
746
|
// 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
|
|
751
747
|
var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
|
|
752
748
|
// 标记优惠券为已使用
|
|
@@ -758,7 +754,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
758
754
|
// 优先从 origin_total拿,可能会拿不到(比如用户端预约在没有配置 original_price 的情况下)
|
|
759
755
|
var productOriginTotal = product.origin_total || product.total || 0;
|
|
760
756
|
// 如果当前 product 有 discount_list,则先从 origin_total 拿
|
|
761
|
-
if ((_product$
|
|
757
|
+
if ((_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.length && product.origin_total) {
|
|
762
758
|
productOriginTotal = product.origin_total;
|
|
763
759
|
}
|
|
764
760
|
// 如果originProduct?._productInit?.original_price为 0,product.origin_total可能为空,此时取 product.total
|
|
@@ -1114,14 +1110,18 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1114
1110
|
var allDiscountAmount = getDiscountListAmountTotal(mainDiscountList);
|
|
1115
1111
|
newTotalWithDiscount = (_Decimal$minus$toNumb = new Decimal(mainProductData.price || 0).minus(allDiscountAmount).toNumber()) !== null && _Decimal$minus$toNumb !== void 0 ? _Decimal$minus$toNumb : newTotalWithDiscount;
|
|
1116
1112
|
newOriginTotalWithDiscount = (_mainProductData$orig = mainProductData.origin_total) !== null && _mainProductData$orig !== void 0 ? _mainProductData$orig : newOriginTotalWithDiscount;
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
// 累加bundle的价格(只累加一次)
|
|
1116
|
+
if (newBundleWithDiscount.length > 0) {
|
|
1117
|
+
newBundleWithDiscount.forEach(function (item) {
|
|
1118
|
+
newTotalWithDiscount += Number(item.price) * Number(item.num);
|
|
1119
|
+
});
|
|
1120
|
+
newBundleWithDiscount.forEach(function (item) {
|
|
1121
|
+
var _item$discount_list2;
|
|
1122
|
+
var originalPrice = ((_item$discount_list2 = item.discount_list) === null || _item$discount_list2 === void 0 || (_item$discount_list2 = _item$discount_list2[0]) === null || _item$discount_list2 === void 0 || (_item$discount_list2 = _item$discount_list2.discount) === null || _item$discount_list2 === void 0 ? void 0 : _item$discount_list2.original_amount) || item.price;
|
|
1123
|
+
newOriginTotalWithDiscount += Number(originalPrice) * Number(item.num);
|
|
1124
|
+
});
|
|
1125
1125
|
}
|
|
1126
1126
|
|
|
1127
1127
|
// 累加options的价格(options不参与折扣,在最终设置total时处理)
|
|
@@ -1184,12 +1184,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1184
1184
|
var _allDiscountAmount = getDiscountListAmount(mainDiscountListOriginal);
|
|
1185
1185
|
newTotalOriginal = (_Decimal$minus$toNumb2 = new Decimal(mainProductData.price || 0).minus(_allDiscountAmount).toNumber()) !== null && _Decimal$minus$toNumb2 !== void 0 ? _Decimal$minus$toNumb2 : newTotalOriginal;
|
|
1186
1186
|
newOriginTotalOriginal = (_mainProductData$orig2 = mainProductData.origin_total) !== null && _mainProductData$orig2 !== void 0 ? _mainProductData$orig2 : newOriginTotalOriginal;
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
// 累加bundle的价格(只累加一次)
|
|
1190
|
+
if (newBundleOriginal.length > 0) {
|
|
1191
|
+
newBundleOriginal.forEach(function (item) {
|
|
1192
|
+
newTotalOriginal += Number(item.price) * Number(item.num);
|
|
1193
|
+
newOriginTotalOriginal += Number(item.price) * Number(item.num);
|
|
1194
|
+
});
|
|
1193
1195
|
}
|
|
1194
1196
|
|
|
1195
1197
|
// 累加options的价格(options不参与折扣,在最终设置total时处理)
|
|
@@ -1284,8 +1286,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1284
1286
|
// 累加bundle的价格(只累加一次)
|
|
1285
1287
|
if (newBundle.length > 0) {
|
|
1286
1288
|
newBundle.forEach(function (item) {
|
|
1287
|
-
var _item$discount_list3;
|
|
1288
1289
|
newTotal += Number(item.price) * Number(item.num);
|
|
1290
|
+
});
|
|
1291
|
+
|
|
1292
|
+
// 计算原始总价(不考虑折扣)
|
|
1293
|
+
newBundle.forEach(function (item) {
|
|
1294
|
+
var _item$discount_list3;
|
|
1289
1295
|
var originalPrice = ((_item$discount_list3 = item.discount_list) === null || _item$discount_list3 === void 0 || (_item$discount_list3 = _item$discount_list3[0]) === null || _item$discount_list3 === void 0 || (_item$discount_list3 = _item$discount_list3.discount) === null || _item$discount_list3 === void 0 ? void 0 : _item$discount_list3.original_amount) || item.price;
|
|
1290
1296
|
newOriginTotal += Number(originalPrice) * Number(item.num);
|
|
1291
1297
|
});
|
|
@@ -1464,8 +1470,34 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1464
1470
|
// 套餐中购买时,判断是否为原价
|
|
1465
1471
|
var _priceType = (_flatItem$bundleItem7 = flatItem.bundleItem) === null || _flatItem$bundleItem7 === void 0 ? void 0 : _flatItem$bundleItem7.price_type;
|
|
1466
1472
|
var _priceTypeExt = (_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.price_type_ext;
|
|
1473
|
+
|
|
1474
|
+
// original_price 对应:
|
|
1475
|
+
// 1. price_type: "markup" && price_type_ext: "product_price"
|
|
1476
|
+
// markup_price 对应:
|
|
1477
|
+
// price_type: "markup" && price_type_ext: ""
|
|
1478
|
+
/** 原价 */
|
|
1479
|
+
var _isOriginalPrice = _priceType === 'markup' && _priceTypeExt === 'product_price';
|
|
1480
|
+
/** 加价 */
|
|
1481
|
+
var _isMarkupPrice = _priceType === 'markup' && (_priceTypeExt === '' || !_priceTypeExt);
|
|
1482
|
+
|
|
1483
|
+
// 检查 rules
|
|
1484
|
+
if (rules.length > 0) {
|
|
1485
|
+
// 检查原价
|
|
1486
|
+
if (_isOriginalPrice && rules.includes('original_price')) {
|
|
1487
|
+
return true;
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
// 检查加价
|
|
1491
|
+
if (_isMarkupPrice && rules.includes('markup_price')) {
|
|
1492
|
+
return true;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
// 如果都不匹配,则不可用
|
|
1496
|
+
return false;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1467
1499
|
// 原价包括:price_type: "markup" && price_type_ext: "product_price"
|
|
1468
|
-
return
|
|
1500
|
+
return _isOriginalPrice;
|
|
1469
1501
|
}
|
|
1470
1502
|
return false;
|
|
1471
1503
|
}
|
|
@@ -31,7 +31,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
31
31
|
import { BaseModule } from "../../modules/BaseModule";
|
|
32
32
|
import { createModule } from "./types";
|
|
33
33
|
import { formatProductToCartItem, createCartItemOrigin, getUniqueId, handleVariantProduct, formatDateToCartItem, formatAccountToCartItem } from "../../modules/Cart/utils";
|
|
34
|
-
import { getAvailableProductResources } from "./utils/products";
|
|
34
|
+
import { getAvailableProductResources, isSessionProduct } from "./utils/products";
|
|
35
35
|
import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection, isConflict } from "./utils/resources";
|
|
36
36
|
import dayjs from 'dayjs';
|
|
37
37
|
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
|
@@ -238,19 +238,29 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
238
238
|
key: "loadProducts",
|
|
239
239
|
value: (function () {
|
|
240
240
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
241
|
-
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date;
|
|
241
|
+
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date, res;
|
|
242
242
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
243
243
|
while (1) switch (_context2.prev = _context2.next) {
|
|
244
244
|
case 0:
|
|
245
245
|
_ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, schedule_date = _ref.schedule_date;
|
|
246
|
-
|
|
246
|
+
_context2.next = 3;
|
|
247
|
+
return this.store.products.loadProducts({
|
|
247
248
|
category_ids: category_ids,
|
|
248
249
|
product_ids: product_ids,
|
|
249
250
|
collection: collection,
|
|
250
251
|
schedule_date: schedule_date,
|
|
251
252
|
cacheId: this.cacheId
|
|
252
|
-
})
|
|
253
|
-
case
|
|
253
|
+
});
|
|
254
|
+
case 3:
|
|
255
|
+
res = _context2.sent;
|
|
256
|
+
// 预拉取当天的资源数据
|
|
257
|
+
this.getAvailableDate({
|
|
258
|
+
startDate: schedule_date || dayjs().format('YYYY-MM-DD'),
|
|
259
|
+
endDate: schedule_date || dayjs().format('YYYY-MM-DD'),
|
|
260
|
+
products: _toConsumableArray(res)
|
|
261
|
+
});
|
|
262
|
+
return _context2.abrupt("return", res);
|
|
263
|
+
case 6:
|
|
254
264
|
case "end":
|
|
255
265
|
return _context2.stop();
|
|
256
266
|
}
|
|
@@ -282,7 +292,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
282
292
|
value: (function () {
|
|
283
293
|
var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
|
|
284
294
|
var _schedule$product_ids;
|
|
285
|
-
var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, newProductIds, schedule, otherProductsIds, allProductIds;
|
|
295
|
+
var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, newProductIds, schedule, otherProductsIds, allProductIds, res;
|
|
286
296
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
287
297
|
while (1) switch (_context3.prev = _context3.next) {
|
|
288
298
|
case 0:
|
|
@@ -329,8 +339,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
329
339
|
schedule_date: date
|
|
330
340
|
});
|
|
331
341
|
case 10:
|
|
332
|
-
|
|
333
|
-
|
|
342
|
+
res = _context3.sent;
|
|
343
|
+
return _context3.abrupt("return", res);
|
|
344
|
+
case 12:
|
|
334
345
|
case "end":
|
|
335
346
|
return _context3.stop();
|
|
336
347
|
}
|
|
@@ -1150,6 +1161,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1150
1161
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
1151
1162
|
product_variant_id: product_variant_id
|
|
1152
1163
|
});
|
|
1164
|
+
debugger;
|
|
1165
|
+
// 保护,如果进来的是 session 商品,则必须要有 date 和时间片,否则不允许添加
|
|
1166
|
+
if (isSessionProduct(productData)) {
|
|
1167
|
+
if (!date || !date.startTime || !date.endTime) {
|
|
1168
|
+
return {
|
|
1169
|
+
success: false,
|
|
1170
|
+
errorCode: 'date_or_time_required'
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1153
1174
|
|
|
1154
1175
|
// 库存检测
|
|
1155
1176
|
var currentCartItems = this.store.cart.getItems();
|
|
@@ -9,3 +9,9 @@ export declare const getAvailableProductResources: (products: ProductData[]) =>
|
|
|
9
9
|
rules: any[];
|
|
10
10
|
resourcesMap: Record<number, ProductResourceItem>;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* 判断商品是否是 session 商品
|
|
14
|
+
* @param product 商品数据
|
|
15
|
+
* @returns 是否是 session 商品
|
|
16
|
+
*/
|
|
17
|
+
export declare const isSessionProduct: (product: ProductData) => boolean;
|
|
@@ -47,4 +47,14 @@ export var getAvailableProductResources = function getAvailableProductResources(
|
|
|
47
47
|
rules: rules,
|
|
48
48
|
resourcesMap: resourcesMap
|
|
49
49
|
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 判断商品是否是 session 商品
|
|
54
|
+
* @param product 商品数据
|
|
55
|
+
* @returns 是否是 session 商品
|
|
56
|
+
*/
|
|
57
|
+
export var isSessionProduct = function isSessionProduct(product) {
|
|
58
|
+
var _product$scheduleIds, _product$scheduleIds2;
|
|
59
|
+
return ((_product$scheduleIds = product === null || product === void 0 || (_product$scheduleIds2 = product['schedule.ids']) === null || _product$scheduleIds2 === void 0 ? void 0 : _product$scheduleIds2.length) !== null && _product$scheduleIds !== void 0 ? _product$scheduleIds : 0) > 0;
|
|
50
60
|
};
|
|
@@ -396,23 +396,66 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
396
396
|
return pre + (item.amount || 0);
|
|
397
397
|
}, 0);
|
|
398
398
|
};
|
|
399
|
-
var
|
|
400
|
-
return {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
399
|
+
var formatProduct = function formatProduct(items) {
|
|
400
|
+
return items.map(function (item) {
|
|
401
|
+
var _item$is_charge_tax;
|
|
402
|
+
return {
|
|
403
|
+
product_id: item.product_id,
|
|
404
|
+
product_variant_id: item.product_variant_id,
|
|
405
|
+
quantity: item.num,
|
|
406
|
+
// 商品是否含税:1;0
|
|
407
|
+
is_charge_tax: (_item$is_charge_tax = item.is_charge_tax) !== null && _item$is_charge_tax !== void 0 ? _item$is_charge_tax : 0,
|
|
408
|
+
// 若商品不含税,计算得到的税费,单位(元)
|
|
409
|
+
tax_fee: item.tax_fee,
|
|
410
|
+
// 整个商品折扣后的总金额
|
|
411
|
+
selling_price: item.calculated_selling_price,
|
|
412
|
+
// 使用者id
|
|
413
|
+
holder_id: item.holder_id,
|
|
414
|
+
// 整个商品折扣前的总金额
|
|
415
|
+
original_price: item.calculated_original_price,
|
|
416
|
+
// 主商品折扣前金额,不包含套餐子商品
|
|
417
|
+
main_product_original_price: item.price,
|
|
418
|
+
// 主商品折扣后金额,不包含套餐子商品
|
|
419
|
+
main_product_selling_price: item.main_product_selling_price,
|
|
420
|
+
metadata: {
|
|
421
|
+
// 主商品+非原价(加减价)子商品税费
|
|
422
|
+
"main_product_attached_bundle_tax_fee": item.metadata.main_product_attached_bundle_tax_fee,
|
|
423
|
+
// 主商品+非原价(加减价)子商品附加费
|
|
424
|
+
"main_product_attached_bundle_surcharge_fee": item.metadata.main_product_attached_bundle_surcharge_fee,
|
|
425
|
+
// 可选,附加费均摊舍入金额
|
|
426
|
+
"surcharge_rounding_remainder": item.metadata.surcharge_rounding_remainder
|
|
427
|
+
},
|
|
428
|
+
product_bundle: item.product_bundle.map(function (bundle) {
|
|
429
|
+
return {
|
|
430
|
+
bundle_id: bundle.bundle_id,
|
|
431
|
+
bundle_product_id: bundle.bundle_product_id,
|
|
432
|
+
bundle_variant_id: bundle.bundle_variant_id,
|
|
433
|
+
price_type: bundle.price_type,
|
|
434
|
+
price_type_ext: bundle.price_type_ext,
|
|
435
|
+
// 套餐子商品总价,不包含折扣金额
|
|
436
|
+
bundle_sum_price: bundle.bundle_sum_price,
|
|
437
|
+
// 套餐子商品折扣后金额
|
|
438
|
+
bundle_selling_price: bundle.bundle_selling_price,
|
|
439
|
+
num: bundle.num,
|
|
440
|
+
is_charge_tax: bundle.is_charge_tax,
|
|
441
|
+
tax_fee: bundle.tax_fee,
|
|
442
|
+
metadata: {
|
|
443
|
+
// 子商品单数量附加费
|
|
444
|
+
"surcharge_fee": bundle.metadata.surcharge_fee,
|
|
445
|
+
// 可选,附加费均摊舍入金额
|
|
446
|
+
"surcharge_rounding_remainder": bundle.metadata.surcharge_rounding_remainder
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
})
|
|
450
|
+
};
|
|
451
|
+
}) || [];
|
|
452
|
+
};
|
|
453
|
+
var productList = formatProduct(((_this$store$currentOr = this.store.currentOrder.order_info) === null || _this$store$currentOr === void 0 || (_this$store$currentOr = _this$store$currentOr.original_order_data) === null || _this$store$currentOr === void 0 || (_this$store$currentOr = _this$store$currentOr.bookings) === null || _this$store$currentOr === void 0 ? void 0 : _this$store$currentOr.map(function (item) {
|
|
454
|
+
return _objectSpread(_objectSpread({}, item.product), {}, {
|
|
405
455
|
holder_id: _this3.getHolderIdFromBooking(item)
|
|
406
|
-
};
|
|
407
|
-
})) || [];
|
|
408
|
-
var relationProducts = ((_this$store$currentOr2 = this.store.currentOrder.order_info) === null || _this$store$currentOr2 === void 0 || (_this$store$currentOr2 = _this$store$currentOr2.original_order_data) === null || _this$store$currentOr2 === void 0
|
|
409
|
-
return {
|
|
410
|
-
product_id: item.product_id,
|
|
411
|
-
product_variant_id: item.product_variant_id,
|
|
412
|
-
quantity: item.num,
|
|
413
|
-
selling_price: item.source_product_price
|
|
414
|
-
};
|
|
415
|
-
})) || [];
|
|
456
|
+
});
|
|
457
|
+
})) || []);
|
|
458
|
+
var relationProducts = formatProduct(((_this$store$currentOr2 = this.store.currentOrder.order_info) === null || _this$store$currentOr2 === void 0 || (_this$store$currentOr2 = _this$store$currentOr2.original_order_data) === null || _this$store$currentOr2 === void 0 ? void 0 : _this$store$currentOr2.relation_products) || []);
|
|
416
459
|
return [].concat(_toConsumableArray(productList), _toConsumableArray(relationProducts));
|
|
417
460
|
}
|
|
418
461
|
}, {
|
|
@@ -447,7 +490,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
447
490
|
depositAmount: (_this$store$currentOr5 = this.store.currentOrder) === null || _this$store$currentOr5 === void 0 ? void 0 : _this$store$currentOr5.deposit_amount,
|
|
448
491
|
isDeposit: (_this$store$currentOr6 = this.store.currentOrder) === null || _this$store$currentOr6 === void 0 ? void 0 : _this$store$currentOr6.is_deposit
|
|
449
492
|
},
|
|
450
|
-
products: this.getProductListByOrder()
|
|
493
|
+
products: this.getProductListByOrder(),
|
|
494
|
+
is_price_include_tax: this.otherParams.is_price_include_tax
|
|
451
495
|
}, params); // 判断订单是否已经同步,如果是则追加payment_order_id参数
|
|
452
496
|
if (this.store.isOrderSynced) {
|
|
453
497
|
walletBusinessData.payment_order_id = (_this$store$currentOr7 = this.store.currentOrder) === null || _this$store$currentOr7 === void 0 ? void 0 : _this$store$currentOr7.order_id;
|
|
@@ -102,7 +102,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
102
102
|
skip,
|
|
103
103
|
num,
|
|
104
104
|
sort_by: import_constants.SORT_BY,
|
|
105
|
-
with: ["latestWalletDetail.wallet"],
|
|
105
|
+
with: ["latestWalletDetail.wallet", "contactsInfo"],
|
|
106
106
|
search_wallet_flag: 1,
|
|
107
107
|
search_wallet_pass_flag: 1,
|
|
108
108
|
...search && { search },
|
|
@@ -623,7 +623,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
623
623
|
this.logInfo("更新订单支付项完成", {
|
|
624
624
|
orderUuid
|
|
625
625
|
});
|
|
626
|
-
this.core.effects.emit(
|
|
626
|
+
this.core.effects.emit(`${this.name}:onPaymentAdded`, {
|
|
627
627
|
orderUuid,
|
|
628
628
|
payment: newPaymentItem
|
|
629
629
|
});
|
|
@@ -51,10 +51,19 @@ var WalletPassPaymentImpl = class {
|
|
|
51
51
|
*/
|
|
52
52
|
generateWalletParams(businessData) {
|
|
53
53
|
var _a, _b;
|
|
54
|
-
const {
|
|
54
|
+
const {
|
|
55
|
+
customer_id,
|
|
56
|
+
holder,
|
|
57
|
+
amountInfo,
|
|
58
|
+
products,
|
|
59
|
+
order_wait_pay_amount,
|
|
60
|
+
payment_order_id,
|
|
61
|
+
is_price_include_tax
|
|
62
|
+
} = businessData;
|
|
55
63
|
const totalAmount = Number(amountInfo.totalAmount);
|
|
56
64
|
const subTotal = Number(amountInfo.subTotal);
|
|
57
65
|
const walletParams = {
|
|
66
|
+
is_price_include_tax,
|
|
58
67
|
sale_channel: "pos",
|
|
59
68
|
customer_id: customer_id || 0,
|
|
60
69
|
// 提供默认值,确保类型为 number
|
|
@@ -103,13 +103,6 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
103
103
|
{ osServer: true }
|
|
104
104
|
);
|
|
105
105
|
const sortedList = (productsData.data.list || []).slice().sort((a, b) => Number(b.sort) - Number(a.sort));
|
|
106
|
-
if (sortedList.length) {
|
|
107
|
-
sortedList.forEach((n) => {
|
|
108
|
-
if (n.is_eject !== 1 && n["schedule.ids"] && n["schedule.ids"].length) {
|
|
109
|
-
n.is_eject = 1;
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
106
|
this.addProduct(sortedList);
|
|
114
107
|
return sortedList;
|
|
115
108
|
}
|
|
@@ -36,6 +36,7 @@ var import_BaseModule = require("../BaseModule");
|
|
|
36
36
|
var import_utils = require("../../solution/ShopDiscount/utils");
|
|
37
37
|
var import_utils2 = require("../Cart/utils");
|
|
38
38
|
var import_decimal = __toESM(require("decimal.js"));
|
|
39
|
+
var import_lodash_es = require("lodash-es");
|
|
39
40
|
var import_dayjs = __toESM(require("dayjs"));
|
|
40
41
|
var RulesModule = class extends import_BaseModule.BaseModule {
|
|
41
42
|
constructor(name, version) {
|
|
@@ -296,7 +297,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
296
297
|
const isLimitedProduct = (limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
|
|
297
298
|
const isAvailableProduct = flatItem.type === "main" ? !((product == null ? void 0 : product.booking_id) && ((_c = product == null ? void 0 : product.discount_list) == null ? void 0 : _c.length) && ((_d = product == null ? void 0 : product.discount_list) == null ? void 0 : _d.every((discount2) => discount2.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount2.tag || discount2.type)))) : !((flatItem == null ? void 0 : flatItem.booking_id) && ((_f = (_e = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _e.metadata) == null ? void 0 : _f.custom_product_bundle_map_id));
|
|
298
299
|
const isBundleAvailable = this.checkPackageSubItemUsageRules(discount, flatItem);
|
|
299
|
-
if (isAvailableProduct && isLimitedProduct &&
|
|
300
|
+
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable) {
|
|
300
301
|
(_g = discountApplicability.get(discount.id)) == null ? void 0 : _g.push(product.id);
|
|
301
302
|
const applicableProducts = discountApplicableProducts.get(discount.id) || [];
|
|
302
303
|
const discountType = discount.tag || discount.type;
|
|
@@ -326,7 +327,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
326
327
|
});
|
|
327
328
|
const processedFlatItemsMap = /* @__PURE__ */ new Map();
|
|
328
329
|
sortedFlattenedList.forEach((flatItem, index) => {
|
|
329
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x
|
|
330
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
330
331
|
let product, originProduct;
|
|
331
332
|
if (flatItem.type === "main") {
|
|
332
333
|
product = flatItem.product;
|
|
@@ -364,7 +365,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
364
365
|
return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
|
|
365
366
|
})) && (discount.tag || discount.type) === "good_pass")
|
|
366
367
|
return false;
|
|
367
|
-
if ((Number(product.price)
|
|
368
|
+
if ((Number(product.price) <= 0 || !product.price) && !((_b2 = product.discount_list) == null ? void 0 : _b2.find((n) => {
|
|
368
369
|
var _a3;
|
|
369
370
|
return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
|
|
370
371
|
})) && (discount.tag || discount.type) !== "good_pass")
|
|
@@ -464,16 +465,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
464
465
|
}
|
|
465
466
|
}
|
|
466
467
|
}
|
|
467
|
-
if (
|
|
468
|
-
var _a2;
|
|
469
|
-
return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some((n) => {
|
|
470
|
-
var _a3;
|
|
471
|
-
return n.discountId === ((_a3 = item.discount) == null ? void 0 : _a3.resource_id);
|
|
472
|
-
});
|
|
473
|
-
}))) {
|
|
474
|
-
isManualDiscount = false;
|
|
475
|
-
}
|
|
476
|
-
if (applicableDiscounts.length === 0 || isManualDiscount) {
|
|
468
|
+
if (applicableDiscounts.length === 0 || isManualDiscount || (0, import_lodash_es.isBoolean)(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
477
469
|
if (flatItem.type === "main") {
|
|
478
470
|
if (product.isClient) {
|
|
479
471
|
processedProductsMap.set(
|
|
@@ -505,7 +497,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
505
497
|
processedProductsMap.set(
|
|
506
498
|
product._id,
|
|
507
499
|
[this.hooks.setProduct(originProduct, {
|
|
508
|
-
...isManualDiscount ? {
|
|
500
|
+
...isManualDiscount ? {
|
|
501
|
+
price: product.price,
|
|
502
|
+
main_product_selling_price: product.price
|
|
503
|
+
} : {
|
|
509
504
|
_id: product._id.split("___")[0] + "___" + index,
|
|
510
505
|
total: product.origin_total || product.total,
|
|
511
506
|
price: product.price,
|
|
@@ -519,7 +514,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
519
514
|
processedFlatItemsMap.set(flatItem._id, [{
|
|
520
515
|
...flatItem,
|
|
521
516
|
discount_list: [],
|
|
522
|
-
price: flatItem.bundleItem.original_price,
|
|
517
|
+
price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
|
|
523
518
|
processed: true
|
|
524
519
|
}]);
|
|
525
520
|
}
|
|
@@ -546,10 +541,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
546
541
|
usedDiscounts.set(selectedDiscount2.id, true);
|
|
547
542
|
const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
|
|
548
543
|
let productOriginTotal = product.origin_total || product.total || 0;
|
|
549
|
-
if (((
|
|
544
|
+
if (((_t = product.discount_list) == null ? void 0 : _t.length) && product.origin_total) {
|
|
550
545
|
productOriginTotal = product.origin_total;
|
|
551
546
|
}
|
|
552
|
-
if (Number(((
|
|
547
|
+
if (Number(((_u = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _u.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
|
|
553
548
|
productOriginTotal = product.total;
|
|
554
549
|
}
|
|
555
550
|
const targetProductTotal = (0, import_utils.getDiscountAmount)(selectedDiscount2, product.price, product.price);
|
|
@@ -560,7 +555,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
560
555
|
amount,
|
|
561
556
|
type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : discountType,
|
|
562
557
|
discount: {
|
|
563
|
-
discount_card_type: (
|
|
558
|
+
discount_card_type: (_v = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _v.discount_card_type,
|
|
564
559
|
fixed_amount: amount,
|
|
565
560
|
resource_id: selectedDiscount2.id,
|
|
566
561
|
title: selectedDiscount2.format_title,
|
|
@@ -682,7 +677,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
682
677
|
amount: new import_decimal.default(productOriginTotal).minus(targetProductTotal).toNumber() * (product.num || 1),
|
|
683
678
|
type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag,
|
|
684
679
|
discount: {
|
|
685
|
-
discount_card_type: (
|
|
680
|
+
discount_card_type: (_w = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _w.discount_card_type,
|
|
686
681
|
fixed_amount: new import_decimal.default(productOriginTotal).minus(targetProductTotal).toNumber(),
|
|
687
682
|
resource_id: selectedDiscount2.id,
|
|
688
683
|
title: selectedDiscount2.format_title,
|
|
@@ -695,7 +690,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
695
690
|
custom_product_bundle_map_id: uniqueId,
|
|
696
691
|
num: product.num || 1
|
|
697
692
|
},
|
|
698
|
-
_num: (product.num || 1) * (((
|
|
693
|
+
_num: (product.num || 1) * (((_x = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _x.num) || 1)
|
|
699
694
|
};
|
|
700
695
|
const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
|
|
701
696
|
appliedProducts.push(discountDetail);
|
|
@@ -859,14 +854,16 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
859
854
|
const allDiscountAmount = (0, import_utils.getDiscountListAmountTotal)(mainDiscountList);
|
|
860
855
|
newTotalWithDiscount = new import_decimal.default(mainProductData.price || 0).minus(allDiscountAmount).toNumber() ?? newTotalWithDiscount;
|
|
861
856
|
newOriginTotalWithDiscount = mainProductData.origin_total ?? newOriginTotalWithDiscount;
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
857
|
+
}
|
|
858
|
+
if (newBundleWithDiscount.length > 0) {
|
|
859
|
+
newBundleWithDiscount.forEach((item) => {
|
|
860
|
+
newTotalWithDiscount += Number(item.price) * Number(item.num);
|
|
861
|
+
});
|
|
862
|
+
newBundleWithDiscount.forEach((item) => {
|
|
863
|
+
var _a, _b, _c;
|
|
864
|
+
const originalPrice = ((_c = (_b = (_a = item.discount_list) == null ? void 0 : _a[0]) == null ? void 0 : _b.discount) == null ? void 0 : _c.original_amount) || item.price;
|
|
865
|
+
newOriginTotalWithDiscount += Number(originalPrice) * Number(item.num);
|
|
866
|
+
});
|
|
870
867
|
}
|
|
871
868
|
if (product == null ? void 0 : product.options) {
|
|
872
869
|
newTotalWithDiscount = product.options.reduce((accumulator, currentValue) => {
|
|
@@ -918,12 +915,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
918
915
|
const allDiscountAmount = (0, import_utils.getDiscountListAmount)(mainDiscountListOriginal);
|
|
919
916
|
newTotalOriginal = new import_decimal.default(mainProductData.price || 0).minus(allDiscountAmount).toNumber() ?? newTotalOriginal;
|
|
920
917
|
newOriginTotalOriginal = mainProductData.origin_total ?? newOriginTotalOriginal;
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
}
|
|
918
|
+
}
|
|
919
|
+
if (newBundleOriginal.length > 0) {
|
|
920
|
+
newBundleOriginal.forEach((item) => {
|
|
921
|
+
newTotalOriginal += Number(item.price) * Number(item.num);
|
|
922
|
+
newOriginTotalOriginal += Number(item.price) * Number(item.num);
|
|
923
|
+
});
|
|
927
924
|
}
|
|
928
925
|
if (product == null ? void 0 : product.options) {
|
|
929
926
|
newTotalOriginal = product.options.reduce((accumulator, currentValue) => {
|
|
@@ -998,8 +995,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
998
995
|
}
|
|
999
996
|
if (newBundle.length > 0) {
|
|
1000
997
|
newBundle.forEach((item) => {
|
|
1001
|
-
var _a2, _b2, _c2;
|
|
1002
998
|
newTotal += Number(item.price) * Number(item.num);
|
|
999
|
+
});
|
|
1000
|
+
newBundle.forEach((item) => {
|
|
1001
|
+
var _a2, _b2, _c2;
|
|
1003
1002
|
const originalPrice = ((_c2 = (_b2 = (_a2 = item.discount_list) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.discount) == null ? void 0 : _c2.original_amount) || item.price;
|
|
1004
1003
|
newOriginTotal += Number(originalPrice) * Number(item.num);
|
|
1005
1004
|
});
|
|
@@ -1140,7 +1139,18 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1140
1139
|
if (isBundleItem) {
|
|
1141
1140
|
const priceType = (_c = flatItem.bundleItem) == null ? void 0 : _c.price_type;
|
|
1142
1141
|
const priceTypeExt = (_d = flatItem.bundleItem) == null ? void 0 : _d.price_type_ext;
|
|
1143
|
-
|
|
1142
|
+
const isOriginalPrice = priceType === "markup" && priceTypeExt === "product_price";
|
|
1143
|
+
const isMarkupPrice = priceType === "markup" && (priceTypeExt === "" || !priceTypeExt);
|
|
1144
|
+
if (rules.length > 0) {
|
|
1145
|
+
if (isOriginalPrice && rules.includes("original_price")) {
|
|
1146
|
+
return true;
|
|
1147
|
+
}
|
|
1148
|
+
if (isMarkupPrice && rules.includes("markup_price")) {
|
|
1149
|
+
return true;
|
|
1150
|
+
}
|
|
1151
|
+
return false;
|
|
1152
|
+
}
|
|
1153
|
+
return isOriginalPrice;
|
|
1144
1154
|
}
|
|
1145
1155
|
return false;
|
|
1146
1156
|
}
|
|
@@ -185,13 +185,19 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
185
185
|
collection = [],
|
|
186
186
|
schedule_date
|
|
187
187
|
}) {
|
|
188
|
-
|
|
188
|
+
const res = await this.store.products.loadProducts({
|
|
189
189
|
category_ids,
|
|
190
190
|
product_ids,
|
|
191
191
|
collection,
|
|
192
192
|
schedule_date,
|
|
193
193
|
cacheId: this.cacheId
|
|
194
194
|
});
|
|
195
|
+
this.getAvailableDate({
|
|
196
|
+
startDate: schedule_date || (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
197
|
+
endDate: schedule_date || (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
198
|
+
products: [...res]
|
|
199
|
+
});
|
|
200
|
+
return res;
|
|
195
201
|
}
|
|
196
202
|
/**
|
|
197
203
|
* 通过 schedule 来读取商品,适用于 session 类商品
|
|
@@ -228,11 +234,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
228
234
|
const allProductIds = [...newProductIds, ...otherProductsIds].filter(
|
|
229
235
|
(n, index, self) => self.indexOf(n) === index
|
|
230
236
|
);
|
|
231
|
-
|
|
237
|
+
const res = await this.loadProducts({
|
|
232
238
|
product_ids: allProductIds,
|
|
233
239
|
category_ids,
|
|
234
240
|
schedule_date: date
|
|
235
241
|
});
|
|
242
|
+
return res;
|
|
236
243
|
}
|
|
237
244
|
/**
|
|
238
245
|
* 更新完商品数据、切换日期、或者在较后的流程里登录了,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
|
|
@@ -599,6 +606,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
599
606
|
quantity = 1
|
|
600
607
|
} = product || {};
|
|
601
608
|
const productData = { ...origin, product_variant_id };
|
|
609
|
+
debugger;
|
|
610
|
+
if ((0, import_products.isSessionProduct)(productData)) {
|
|
611
|
+
if (!date || !date.startTime || !date.endTime) {
|
|
612
|
+
return { success: false, errorCode: "date_or_time_required" };
|
|
613
|
+
}
|
|
614
|
+
}
|
|
602
615
|
const currentCartItems = this.store.cart.getItems();
|
|
603
616
|
const stockCheckResult = (0, import_stock.checkProductStock)({
|
|
604
617
|
productData,
|
|
@@ -9,3 +9,9 @@ export declare const getAvailableProductResources: (products: ProductData[]) =>
|
|
|
9
9
|
rules: any[];
|
|
10
10
|
resourcesMap: Record<number, ProductResourceItem>;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* 判断商品是否是 session 商品
|
|
14
|
+
* @param product 商品数据
|
|
15
|
+
* @returns 是否是 session 商品
|
|
16
|
+
*/
|
|
17
|
+
export declare const isSessionProduct: (product: ProductData) => boolean;
|
|
@@ -19,7 +19,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/solution/BookingByStep/utils/products.ts
|
|
20
20
|
var products_exports = {};
|
|
21
21
|
__export(products_exports, {
|
|
22
|
-
getAvailableProductResources: () => getAvailableProductResources
|
|
22
|
+
getAvailableProductResources: () => getAvailableProductResources,
|
|
23
|
+
isSessionProduct: () => isSessionProduct
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(products_exports);
|
|
25
26
|
var getAvailableProductResources = (products) => {
|
|
@@ -57,7 +58,12 @@ var getAvailableProductResources = (products) => {
|
|
|
57
58
|
});
|
|
58
59
|
return { resourceIds: [...new Set(resourceIds)], rules, resourcesMap };
|
|
59
60
|
};
|
|
61
|
+
var isSessionProduct = (product) => {
|
|
62
|
+
var _a;
|
|
63
|
+
return (((_a = product == null ? void 0 : product["schedule.ids"]) == null ? void 0 : _a.length) ?? 0) > 0;
|
|
64
|
+
};
|
|
60
65
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
66
|
0 && (module.exports = {
|
|
62
|
-
getAvailableProductResources
|
|
67
|
+
getAvailableProductResources,
|
|
68
|
+
isSessionProduct
|
|
63
69
|
});
|
|
@@ -216,23 +216,70 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
216
216
|
return pre + (item.amount || 0);
|
|
217
217
|
}, 0);
|
|
218
218
|
};
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
219
|
+
const formatProduct = (items) => {
|
|
220
|
+
return items.map(
|
|
221
|
+
(item) => ({
|
|
222
|
+
product_id: item.product_id,
|
|
223
|
+
product_variant_id: item.product_variant_id,
|
|
224
|
+
quantity: item.num,
|
|
225
|
+
// 商品是否含税:1;0
|
|
226
|
+
is_charge_tax: item.is_charge_tax ?? 0,
|
|
227
|
+
// 若商品不含税,计算得到的税费,单位(元)
|
|
228
|
+
tax_fee: item.tax_fee,
|
|
229
|
+
// 整个商品折扣后的总金额
|
|
230
|
+
selling_price: item.calculated_selling_price,
|
|
231
|
+
// 使用者id
|
|
232
|
+
holder_id: item.holder_id,
|
|
233
|
+
// 整个商品折扣前的总金额
|
|
234
|
+
original_price: item.calculated_original_price,
|
|
235
|
+
// 主商品折扣前金额,不包含套餐子商品
|
|
236
|
+
main_product_original_price: item.price,
|
|
237
|
+
// 主商品折扣后金额,不包含套餐子商品
|
|
238
|
+
main_product_selling_price: item.main_product_selling_price,
|
|
239
|
+
metadata: {
|
|
240
|
+
// 主商品+非原价(加减价)子商品税费
|
|
241
|
+
"main_product_attached_bundle_tax_fee": item.metadata.main_product_attached_bundle_tax_fee,
|
|
242
|
+
// 主商品+非原价(加减价)子商品附加费
|
|
243
|
+
"main_product_attached_bundle_surcharge_fee": item.metadata.main_product_attached_bundle_surcharge_fee,
|
|
244
|
+
// 可选,附加费均摊舍入金额
|
|
245
|
+
"surcharge_rounding_remainder": item.metadata.surcharge_rounding_remainder
|
|
246
|
+
},
|
|
247
|
+
product_bundle: item.product_bundle.map((bundle) => {
|
|
248
|
+
return {
|
|
249
|
+
bundle_id: bundle.bundle_id,
|
|
250
|
+
bundle_product_id: bundle.bundle_product_id,
|
|
251
|
+
bundle_variant_id: bundle.bundle_variant_id,
|
|
252
|
+
price_type: bundle.price_type,
|
|
253
|
+
price_type_ext: bundle.price_type_ext,
|
|
254
|
+
// 套餐子商品总价,不包含折扣金额
|
|
255
|
+
bundle_sum_price: bundle.bundle_sum_price,
|
|
256
|
+
// 套餐子商品折扣后金额
|
|
257
|
+
bundle_selling_price: bundle.bundle_selling_price,
|
|
258
|
+
num: bundle.num,
|
|
259
|
+
is_charge_tax: bundle.is_charge_tax,
|
|
260
|
+
tax_fee: bundle.tax_fee,
|
|
261
|
+
metadata: {
|
|
262
|
+
// 子商品单数量附加费
|
|
263
|
+
"surcharge_fee": bundle.metadata.surcharge_fee,
|
|
264
|
+
// 可选,附加费均摊舍入金额
|
|
265
|
+
"surcharge_rounding_remainder": bundle.metadata.surcharge_rounding_remainder
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
})
|
|
269
|
+
})
|
|
270
|
+
) || [];
|
|
271
|
+
};
|
|
272
|
+
const productList = formatProduct(
|
|
273
|
+
((_c = (_b = (_a = this.store.currentOrder.order_info) == null ? void 0 : _a.original_order_data) == null ? void 0 : _b.bookings) == null ? void 0 : _c.map(
|
|
274
|
+
(item) => {
|
|
275
|
+
return {
|
|
276
|
+
...item.product,
|
|
277
|
+
holder_id: this.getHolderIdFromBooking(item)
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
)) || []
|
|
281
|
+
);
|
|
282
|
+
const relationProducts = formatProduct(((_e = (_d = this.store.currentOrder.order_info) == null ? void 0 : _d.original_order_data) == null ? void 0 : _e.relation_products) || []);
|
|
236
283
|
return [...productList, ...relationProducts];
|
|
237
284
|
}
|
|
238
285
|
async initWalletData(params) {
|
|
@@ -257,6 +304,8 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
257
304
|
isDeposit: (_h = this.store.currentOrder) == null ? void 0 : _h.is_deposit
|
|
258
305
|
},
|
|
259
306
|
products: this.getProductListByOrder(),
|
|
307
|
+
is_price_include_tax: this.otherParams.is_price_include_tax,
|
|
308
|
+
// core 有
|
|
260
309
|
...params
|
|
261
310
|
};
|
|
262
311
|
if (this.store.isOrderSynced) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@pisell/pisellos",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.13",
|
|
5
5
|
"description": "一个可扩展的前端模块化SDK框架,支持插件系统",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -69,4 +69,4 @@
|
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
71
71
|
}
|
|
72
|
-
}
|
|
72
|
+
}
|