@pisell/pisellos 2.2.14 → 2.2.16
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/Order/index.js +18 -13
- package/dist/modules/Payment/index.d.ts +1 -0
- package/dist/modules/Payment/index.js +505 -470
- 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 +63 -22
- 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/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Checkout/index.js +61 -17
- package/lib/modules/Customer/index.js +1 -1
- package/lib/modules/Order/index.js +20 -18
- package/lib/modules/Payment/index.d.ts +1 -0
- package/lib/modules/Payment/index.js +17 -3
- 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 +40 -21
- 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/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Checkout/index.js +66 -17
- package/package.json +2 -2
|
@@ -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;
|
|
@@ -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")
|
|
@@ -473,7 +474,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
473
474
|
}))) {
|
|
474
475
|
isManualDiscount = false;
|
|
475
476
|
}
|
|
476
|
-
if (applicableDiscounts.length === 0 || isManualDiscount) {
|
|
477
|
+
if (applicableDiscounts.length === 0 || isManualDiscount || (0, import_lodash_es.isBoolean)(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
477
478
|
if (flatItem.type === "main") {
|
|
478
479
|
if (product.isClient) {
|
|
479
480
|
processedProductsMap.set(
|
|
@@ -505,7 +506,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
505
506
|
processedProductsMap.set(
|
|
506
507
|
product._id,
|
|
507
508
|
[this.hooks.setProduct(originProduct, {
|
|
508
|
-
...isManualDiscount ? {
|
|
509
|
+
...isManualDiscount ? {
|
|
510
|
+
price: product.price,
|
|
511
|
+
main_product_selling_price: product.price
|
|
512
|
+
} : {
|
|
509
513
|
_id: product._id.split("___")[0] + "___" + index,
|
|
510
514
|
total: product.origin_total || product.total,
|
|
511
515
|
price: product.price,
|
|
@@ -519,7 +523,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
519
523
|
processedFlatItemsMap.set(flatItem._id, [{
|
|
520
524
|
...flatItem,
|
|
521
525
|
discount_list: [],
|
|
522
|
-
price: flatItem.bundleItem.original_price,
|
|
526
|
+
price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
|
|
523
527
|
processed: true
|
|
524
528
|
}]);
|
|
525
529
|
}
|
|
@@ -859,14 +863,16 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
859
863
|
const allDiscountAmount = (0, import_utils.getDiscountListAmountTotal)(mainDiscountList);
|
|
860
864
|
newTotalWithDiscount = new import_decimal.default(mainProductData.price || 0).minus(allDiscountAmount).toNumber() ?? newTotalWithDiscount;
|
|
861
865
|
newOriginTotalWithDiscount = mainProductData.origin_total ?? newOriginTotalWithDiscount;
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
866
|
+
}
|
|
867
|
+
if (newBundleWithDiscount.length > 0) {
|
|
868
|
+
newBundleWithDiscount.forEach((item) => {
|
|
869
|
+
newTotalWithDiscount += Number(item.price) * Number(item.num);
|
|
870
|
+
});
|
|
871
|
+
newBundleWithDiscount.forEach((item) => {
|
|
872
|
+
var _a, _b, _c;
|
|
873
|
+
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;
|
|
874
|
+
newOriginTotalWithDiscount += Number(originalPrice) * Number(item.num);
|
|
875
|
+
});
|
|
870
876
|
}
|
|
871
877
|
if (product == null ? void 0 : product.options) {
|
|
872
878
|
newTotalWithDiscount = product.options.reduce((accumulator, currentValue) => {
|
|
@@ -918,12 +924,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
918
924
|
const allDiscountAmount = (0, import_utils.getDiscountListAmount)(mainDiscountListOriginal);
|
|
919
925
|
newTotalOriginal = new import_decimal.default(mainProductData.price || 0).minus(allDiscountAmount).toNumber() ?? newTotalOriginal;
|
|
920
926
|
newOriginTotalOriginal = mainProductData.origin_total ?? newOriginTotalOriginal;
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
}
|
|
927
|
+
}
|
|
928
|
+
if (newBundleOriginal.length > 0) {
|
|
929
|
+
newBundleOriginal.forEach((item) => {
|
|
930
|
+
newTotalOriginal += Number(item.price) * Number(item.num);
|
|
931
|
+
newOriginTotalOriginal += Number(item.price) * Number(item.num);
|
|
932
|
+
});
|
|
927
933
|
}
|
|
928
934
|
if (product == null ? void 0 : product.options) {
|
|
929
935
|
newTotalOriginal = product.options.reduce((accumulator, currentValue) => {
|
|
@@ -998,8 +1004,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
998
1004
|
}
|
|
999
1005
|
if (newBundle.length > 0) {
|
|
1000
1006
|
newBundle.forEach((item) => {
|
|
1001
|
-
var _a2, _b2, _c2;
|
|
1002
1007
|
newTotal += Number(item.price) * Number(item.num);
|
|
1008
|
+
});
|
|
1009
|
+
newBundle.forEach((item) => {
|
|
1010
|
+
var _a2, _b2, _c2;
|
|
1003
1011
|
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
1012
|
newOriginTotal += Number(originalPrice) * Number(item.num);
|
|
1005
1013
|
});
|
|
@@ -1140,7 +1148,18 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1140
1148
|
if (isBundleItem) {
|
|
1141
1149
|
const priceType = (_c = flatItem.bundleItem) == null ? void 0 : _c.price_type;
|
|
1142
1150
|
const priceTypeExt = (_d = flatItem.bundleItem) == null ? void 0 : _d.price_type_ext;
|
|
1143
|
-
|
|
1151
|
+
const isOriginalPrice = priceType === "markup" && priceTypeExt === "product_price";
|
|
1152
|
+
const isMarkupPrice = priceType === "markup" && (priceTypeExt === "" || !priceTypeExt);
|
|
1153
|
+
if (rules.length > 0) {
|
|
1154
|
+
if (isOriginalPrice && rules.includes("original_price")) {
|
|
1155
|
+
return true;
|
|
1156
|
+
}
|
|
1157
|
+
if (isMarkupPrice && rules.includes("markup_price")) {
|
|
1158
|
+
return true;
|
|
1159
|
+
}
|
|
1160
|
+
return false;
|
|
1161
|
+
}
|
|
1162
|
+
return isOriginalPrice;
|
|
1144
1163
|
}
|
|
1145
1164
|
return false;
|
|
1146
1165
|
}
|
|
@@ -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
|
});
|
|
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
123
123
|
* 获取当前的客户搜索条件
|
|
124
124
|
* @returns 当前搜索条件
|
|
125
125
|
*/
|
|
126
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
126
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
127
127
|
/**
|
|
128
128
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
129
129
|
* @returns 客户状态
|
|
@@ -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.16",
|
|
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
|
+
}
|