@pisell/pisellos 3.0.91 → 3.0.93
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/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Discount/types.d.ts +2 -0
- package/dist/modules/ProductList/index.js +18 -11
- package/dist/modules/Rules/index.js +13 -0
- package/dist/modules/Summary/utils.js +42 -21
- package/dist/solution/VenueBooking/index.d.ts +5 -0
- package/dist/solution/VenueBooking/index.js +312 -265
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Discount/types.d.ts +2 -0
- package/lib/modules/ProductList/index.js +9 -3
- package/lib/modules/Rules/index.js +8 -0
- package/lib/modules/Summary/utils.js +23 -3
- package/lib/solution/VenueBooking/index.d.ts +5 -0
- package/lib/solution/VenueBooking/index.js +18 -0
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 导出评估器
|
|
2
|
+
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
+
|
|
4
|
+
// 导出适配器
|
|
5
|
+
export { PromotionAdapter } from "./adapter";
|
|
6
|
+
export { default } from "./adapter";
|
|
7
|
+
|
|
8
|
+
// 导出策略配置示例常量
|
|
9
|
+
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
|
|
@@ -33,6 +33,8 @@ interface Limitedrelationproductdata {
|
|
|
33
33
|
product_ids: number[];
|
|
34
34
|
product_collection_id: number[];
|
|
35
35
|
package_sub_item_usage_rules?: PackageSubItemUsageRules;
|
|
36
|
+
exclude_product_ids?: number[];
|
|
37
|
+
filter?: 0 | 1;
|
|
36
38
|
}
|
|
37
39
|
interface ApplicableProductDetails {
|
|
38
40
|
amount: string;
|
|
@@ -86,7 +86,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
86
86
|
key: "loadProducts",
|
|
87
87
|
value: function () {
|
|
88
88
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref) {
|
|
89
|
-
var
|
|
89
|
+
var _this$otherParams, _this$otherParams2;
|
|
90
|
+
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date, schedule_datetime, cacheId, _ref$menu_list_ids, menu_list_ids, userPlugin, customer_id, _userPlugin$get, channelMap, saleChannel, productsData, sortedList;
|
|
90
91
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
91
92
|
while (1) switch (_context3.prev = _context3.next) {
|
|
92
93
|
case 0:
|
|
@@ -110,8 +111,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
110
111
|
} catch (error) {
|
|
111
112
|
console.error(error);
|
|
112
113
|
}
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
channelMap = {
|
|
115
|
+
'online_store': 'online-store',
|
|
116
|
+
'scan_to_order': 'online-store',
|
|
117
|
+
'scan_to_order_2': 'online-store',
|
|
118
|
+
'scan_to_order_3': 'online-store'
|
|
119
|
+
};
|
|
120
|
+
saleChannel = channelMap[(_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel] || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.channel);
|
|
121
|
+
_context3.prev = 6;
|
|
122
|
+
_context3.next = 9;
|
|
115
123
|
return this.request.post("/product/query", {
|
|
116
124
|
open_quotation: 1,
|
|
117
125
|
open_bundle: 0,
|
|
@@ -128,8 +136,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
128
136
|
// client_schedule_ids: schedule_ids,
|
|
129
137
|
schedule_date: schedule_date,
|
|
130
138
|
schedule_datetime: schedule_datetime,
|
|
131
|
-
|
|
132
|
-
application_code: 'online-store',
|
|
139
|
+
application_code: saleChannel,
|
|
133
140
|
is_eject: 1,
|
|
134
141
|
menu_list_ids: menu_list_ids,
|
|
135
142
|
open_deposit: 1
|
|
@@ -137,7 +144,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
137
144
|
useCache: true,
|
|
138
145
|
customToast: function customToast() {}
|
|
139
146
|
});
|
|
140
|
-
case
|
|
147
|
+
case 9:
|
|
141
148
|
productsData = _context3.sent;
|
|
142
149
|
sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
|
|
143
150
|
return Number(b.sort) - Number(a.sort);
|
|
@@ -150,15 +157,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
150
157
|
// }
|
|
151
158
|
this.addProduct(sortedList);
|
|
152
159
|
return _context3.abrupt("return", sortedList);
|
|
153
|
-
case
|
|
154
|
-
_context3.prev =
|
|
155
|
-
_context3.t0 = _context3["catch"](
|
|
160
|
+
case 15:
|
|
161
|
+
_context3.prev = 15;
|
|
162
|
+
_context3.t0 = _context3["catch"](6);
|
|
156
163
|
return _context3.abrupt("return", _context3.t0);
|
|
157
|
-
case
|
|
164
|
+
case 18:
|
|
158
165
|
case "end":
|
|
159
166
|
return _context3.stop();
|
|
160
167
|
}
|
|
161
|
-
}, _callee3, this, [[
|
|
168
|
+
}, _callee3, this, [[6, 15]]);
|
|
162
169
|
}));
|
|
163
170
|
function loadProducts(_x5) {
|
|
164
171
|
return _loadProducts.apply(this, arguments);
|
|
@@ -526,6 +526,15 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
526
526
|
return priceB.minus(priceA).toNumber();
|
|
527
527
|
});
|
|
528
528
|
|
|
529
|
+
// 检查商品是否被排除(全品类)
|
|
530
|
+
var isProductIncludedByLimitedData = function isProductIncludedByLimitedData(limitedData, productId) {
|
|
531
|
+
var excludedIds = (limitedData === null || limitedData === void 0 ? void 0 : limitedData.exclude_product_ids) || [];
|
|
532
|
+
var isExcluded = (limitedData === null || limitedData === void 0 ? void 0 : limitedData.filter) === 1 && excludedIds.some(function (id) {
|
|
533
|
+
return String(id) === String(productId);
|
|
534
|
+
});
|
|
535
|
+
return !isExcluded;
|
|
536
|
+
};
|
|
537
|
+
|
|
529
538
|
/**
|
|
530
539
|
// 对productList按价格降序排序(用于应用优惠券时优先选择高价商品) 价格相同时使用quantity 排序
|
|
531
540
|
const sortedProductList = [...productList].sort((a, b) => {
|
|
@@ -914,6 +923,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
914
923
|
|
|
915
924
|
// 判断优惠券是否适用于该商品
|
|
916
925
|
if (limitedData.type === 'product_all') {
|
|
926
|
+
if (!isProductIncludedByLimitedData(limitedData, product.id)) {
|
|
927
|
+
return false;
|
|
928
|
+
}
|
|
929
|
+
|
|
917
930
|
// 检查 package_sub_item_usage_rules
|
|
918
931
|
if (!_this3.checkPackageSubItemUsageRules(discount, flatItem)) {
|
|
919
932
|
return false;
|
|
@@ -595,6 +595,27 @@ export var calculateTaxFee = function calculateTaxFee(shopInfo, items) {
|
|
|
595
595
|
}, new Decimal(0));
|
|
596
596
|
return totalTaxFee;
|
|
597
597
|
};
|
|
598
|
+
var getCartItemDepositData = function getCartItemDepositData(item) {
|
|
599
|
+
var _target$_productOrigi, _target$_origin, _target$_origin2;
|
|
600
|
+
var target = item;
|
|
601
|
+
return (target === null || target === void 0 || (_target$_productOrigi = target._productOrigin) === null || _target$_productOrigi === void 0 ? void 0 : _target$_productOrigi.custom_deposit_data) || (target === null || target === void 0 || (_target$_origin = target._origin) === null || _target$_origin === void 0 ? void 0 : _target$_origin.custom_deposit_data) || (target === null || target === void 0 || (_target$_origin2 = target._origin) === null || _target$_origin2 === void 0 || (_target$_origin2 = _target$_origin2.product) === null || _target$_origin2 === void 0 ? void 0 : _target$_origin2.custom_deposit_data);
|
|
602
|
+
};
|
|
603
|
+
var getCartItemQuantity = function getCartItemQuantity(item) {
|
|
604
|
+
return new Decimal((item === null || item === void 0 ? void 0 : item.num) || 1);
|
|
605
|
+
};
|
|
606
|
+
var calculateCartItemDepositTotal = function calculateCartItemDepositTotal(item) {
|
|
607
|
+
var _item$deposit;
|
|
608
|
+
var depositData = getCartItemDepositData(item);
|
|
609
|
+
if ((depositData === null || depositData === void 0 ? void 0 : depositData.has_deposit) == 1 && typeof (depositData === null || depositData === void 0 ? void 0 : depositData.deposit_fixed) === 'string' && typeof (depositData === null || depositData === void 0 ? void 0 : depositData.deposit_percentage) === 'string') {
|
|
610
|
+
var _ref7, _summaryTotal;
|
|
611
|
+
var lineTotal = new Decimal((_ref7 = (_summaryTotal = item.summaryTotal) !== null && _summaryTotal !== void 0 ? _summaryTotal : item.total) !== null && _ref7 !== void 0 ? _ref7 : 0);
|
|
612
|
+
var quantity = getCartItemQuantity(item);
|
|
613
|
+
var fixedTotal = new Decimal(depositData.deposit_fixed || 0).times(quantity);
|
|
614
|
+
var percentageTotal = new Decimal(depositData.deposit_percentage || 0).times(lineTotal);
|
|
615
|
+
return fixedTotal.plus(percentageTotal);
|
|
616
|
+
}
|
|
617
|
+
return new Decimal((item === null || item === void 0 || (_item$deposit = item.deposit) === null || _item$deposit === void 0 ? void 0 : _item$deposit.total) || 0);
|
|
618
|
+
};
|
|
598
619
|
|
|
599
620
|
/**
|
|
600
621
|
* @title: 计算定金
|
|
@@ -609,9 +630,9 @@ export var calculateDeposit = function calculateDeposit(items) {
|
|
|
609
630
|
var hasDeposit = false;
|
|
610
631
|
var total = items.reduce(function (sum, item) {
|
|
611
632
|
if (item !== null && item !== void 0 && item.deposit) {
|
|
612
|
-
var _item$
|
|
633
|
+
var _item$deposit2;
|
|
613
634
|
hasDeposit = true;
|
|
614
|
-
var cartItemTotalPrice =
|
|
635
|
+
var cartItemTotalPrice = calculateCartItemDepositTotal(item);
|
|
615
636
|
// 将协议数据去重合并
|
|
616
637
|
item === null || item === void 0 || (_item$deposit2 = item.deposit) === null || _item$deposit2 === void 0 || (_item$deposit2 = _item$deposit2.protocols) === null || _item$deposit2 === void 0 || _item$deposit2.forEach(function (protocol) {
|
|
617
638
|
if (protocols.findIndex(function (p) {
|
|
@@ -648,9 +669,9 @@ export var calculateDeposit = function calculateDeposit(items) {
|
|
|
648
669
|
* @param options.isEdit 是否处于“编辑中”。`false` 时会优先走后端金额直取逻辑(若存在)
|
|
649
670
|
* @returns 订单附加费金额(number,金额单位与商品价格一致)
|
|
650
671
|
*/
|
|
651
|
-
export var getSurchargeAmount = function getSurchargeAmount(
|
|
652
|
-
var bookingDetail =
|
|
653
|
-
bookingId =
|
|
672
|
+
export var getSurchargeAmount = function getSurchargeAmount(_ref8, surcharge, options) {
|
|
673
|
+
var bookingDetail = _ref8.bookingDetail,
|
|
674
|
+
bookingId = _ref8.bookingId;
|
|
654
675
|
var isEdit = options.isEdit;
|
|
655
676
|
// 订单未变更过
|
|
656
677
|
if (!isEdit) {
|
|
@@ -695,17 +716,17 @@ var getDiscountAmount = function getDiscountAmount(discounts) {
|
|
|
695
716
|
* 获取主商品加价减价后的总价 (主商品价格 + 子商品加价减价)
|
|
696
717
|
*/
|
|
697
718
|
var getMainProductTotal = function getMainProductTotal(item) {
|
|
698
|
-
var
|
|
719
|
+
var _ref9, _ref10, _item$main_product_se, _item$metadata, _item$metadata2, _item$metadata3, _item$metadata4;
|
|
699
720
|
// 新语义 v2 下 `main_product_selling_price` / `metadata.main_product_selling_price`
|
|
700
721
|
// 已经是"含 option、含主商品折扣"的主价,直接作为主商品基准,无需再减折扣或加 option。
|
|
701
722
|
// 仅需叠加 markup / markdown 类 bundle(原价 bundle 的税费单独处理)。
|
|
702
|
-
var total = new Decimal((
|
|
723
|
+
var total = new Decimal((_ref9 = (_ref10 = (_item$main_product_se = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se !== void 0 ? _item$main_product_se : item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.main_product_selling_price) !== null && _ref10 !== void 0 ? _ref10 : item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.main_product_original_price) !== null && _ref9 !== void 0 ? _ref9 : 0);
|
|
703
724
|
|
|
704
725
|
// 做个兜底 如果新语义价格字段都没有,则切换回老逻辑
|
|
705
726
|
var hasMainProductPrice = (item === null || item === void 0 ? void 0 : item.main_product_selling_price) != null || (item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.main_product_selling_price) != null || (item === null || item === void 0 || (_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.main_product_original_price) != null;
|
|
706
727
|
if (!hasMainProductPrice) {
|
|
707
|
-
var
|
|
708
|
-
total = new Decimal((
|
|
728
|
+
var _ref11, _ref12, _item$main_product_se2, _item$metadata5, _item$_origin3, _item$_originData;
|
|
729
|
+
total = new Decimal((_ref11 = (_ref12 = (_item$main_product_se2 = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se2 !== void 0 ? _item$main_product_se2 : item === null || item === void 0 || (_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.main_product_selling_price) !== null && _ref12 !== void 0 ? _ref12 : item.price) !== null && _ref11 !== void 0 ? _ref11 : 0);
|
|
709
730
|
var discount = (item === null || item === void 0 || (_item$_origin3 = item._origin) === null || _item$_origin3 === void 0 || (_item$_origin3 = _item$_origin3.product) === null || _item$_origin3 === void 0 ? void 0 : _item$_origin3.discount_list) || (item === null || item === void 0 || (_item$_originData = item._originData) === null || _item$_originData === void 0 || (_item$_originData = _item$_originData.product) === null || _item$_originData === void 0 || (_item$_originData = _item$_originData.discount_list) === null || _item$_originData === void 0 ? void 0 : _item$_originData.filter(function (item) {
|
|
710
731
|
var _item$metadata6;
|
|
711
732
|
return !(item !== null && item !== void 0 && (_item$metadata6 = item.metadata) !== null && _item$metadata6 !== void 0 && _item$metadata6.custom_product_bundle_map_id);
|
|
@@ -726,9 +747,9 @@ var getMainProductTotal = function getMainProductTotal(item) {
|
|
|
726
747
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
727
748
|
var bundleItem = _step4.value;
|
|
728
749
|
if (getBundleItemIsMarkupOrDiscountPrice(bundleItem)) {
|
|
729
|
-
var
|
|
750
|
+
var _ref13, _bundleItem$bundle_se2;
|
|
730
751
|
// IMPORTANT: 套餐子商品如果应用了 discount,bundle_selling_price 和 price 其实都已经是折后价格了,不需要单独再减一次
|
|
731
|
-
var bundleItemTotal = new Decimal((
|
|
752
|
+
var bundleItemTotal = new Decimal((_ref13 = (_bundleItem$bundle_se2 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se2 !== void 0 ? _bundleItem$bundle_se2 : bundleItem.price) !== null && _ref13 !== void 0 ? _ref13 : 0);
|
|
732
753
|
total = total.add(bundleItemTotal);
|
|
733
754
|
}
|
|
734
755
|
}
|
|
@@ -848,12 +869,12 @@ var isProductMatchSurchargeCondition = function isProductMatchSurchargeCondition
|
|
|
848
869
|
* @param options.scheduleById schedule 映射表:`{ [scheduleId]: schedule }`(用于根据配置的 `available_schedule_ids` 做日程匹配)
|
|
849
870
|
* @returns 附加费列表(仅返回金额 > 0 的项)
|
|
850
871
|
*/
|
|
851
|
-
export var getSurcharge = function getSurcharge(
|
|
872
|
+
export var getSurcharge = function getSurcharge(_ref14, options) {
|
|
852
873
|
var _service$filter;
|
|
853
|
-
var service =
|
|
854
|
-
addons =
|
|
855
|
-
bookingDetail =
|
|
856
|
-
bookingId =
|
|
874
|
+
var service = _ref14.service,
|
|
875
|
+
addons = _ref14.addons,
|
|
876
|
+
bookingDetail = _ref14.bookingDetail,
|
|
877
|
+
bookingId = _ref14.bookingId;
|
|
857
878
|
var isEdit = options.isEdit,
|
|
858
879
|
isInScheduleByDate = options.isInScheduleByDate,
|
|
859
880
|
surcharge_list = options.surcharge_list,
|
|
@@ -975,11 +996,11 @@ export var getSurcharge = function getSurcharge(_ref13, options) {
|
|
|
975
996
|
scheduleById: scheduleById || {},
|
|
976
997
|
isInScheduleByDate: isInScheduleByDate
|
|
977
998
|
})) {
|
|
978
|
-
var
|
|
999
|
+
var _ref15, _bundleItem$bundle_se3;
|
|
979
1000
|
var _mainQuantity = item.num || 1;
|
|
980
1001
|
matchedItems.push({
|
|
981
1002
|
isMain: false,
|
|
982
|
-
total: Number((
|
|
1003
|
+
total: Number((_ref15 = (_bundleItem$bundle_se3 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se3 !== void 0 ? _bundleItem$bundle_se3 : bundleItem.price) !== null && _ref15 !== void 0 ? _ref15 : 0),
|
|
983
1004
|
quantity: bundleItem.num || bundleItem.quantity || 1,
|
|
984
1005
|
item: bundleItem,
|
|
985
1006
|
mainQuantity: _mainQuantity // 子商品的mainQuantity是所属主商品的quantity
|
|
@@ -1195,9 +1216,9 @@ export var getSurcharge = function getSurcharge(_ref13, options) {
|
|
|
1195
1216
|
}
|
|
1196
1217
|
return surchargeWithAmount;
|
|
1197
1218
|
};
|
|
1198
|
-
function resetItemsSurchargeSideEffects(
|
|
1199
|
-
var service =
|
|
1200
|
-
addons =
|
|
1219
|
+
function resetItemsSurchargeSideEffects(_ref16) {
|
|
1220
|
+
var service = _ref16.service,
|
|
1221
|
+
addons = _ref16.addons;
|
|
1201
1222
|
var resetItem = function resetItem(item) {
|
|
1202
1223
|
if (!item) return;
|
|
1203
1224
|
item.surcharge_fee = 0;
|
|
@@ -168,6 +168,11 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
|
|
|
168
168
|
getOrderProducts(): ScanOrderOrderProduct[];
|
|
169
169
|
getSummary(): Promise<import("./types").ScanOrderSummary>;
|
|
170
170
|
submitOrder<T = any>(): Promise<T>;
|
|
171
|
+
/**
|
|
172
|
+
* 0 元订单免费领取(非定金场景)
|
|
173
|
+
* 与 appointment getFreeProduct 同接口:POST /pay/order/free-pay/:id
|
|
174
|
+
*/
|
|
175
|
+
submitFreeOrder(id: string | number): Promise<any>;
|
|
171
176
|
addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
|
|
172
177
|
updateProductInOrder(params: UpdateProductInOrderParams): Promise<ScanOrderOrderProduct[]>;
|
|
173
178
|
removeProductFromOrder(identity: ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
|