@pisell/pisellos 2.2.11 → 2.2.12
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/Cart/utils/cartProduct.js +41 -26
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +69 -36
- package/dist/modules/Discount/types.d.ts +16 -0
- package/dist/modules/Order/index.js +4 -1
- package/dist/modules/Order/utils.d.ts +1 -0
- package/dist/modules/Order/utils.js +9 -0
- package/dist/modules/Rules/index.d.ts +7 -0
- package/dist/modules/Rules/index.js +1032 -195
- package/dist/modules/Rules/types.d.ts +4 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +1 -0
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +80 -19
- package/dist/solution/ShopDiscount/types.d.ts +4 -1
- package/dist/solution/ShopDiscount/utils.d.ts +55 -0
- package/dist/solution/ShopDiscount/utils.js +432 -3
- package/lib/modules/Cart/utils/cartProduct.js +35 -22
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +19 -4
- package/lib/modules/Discount/types.d.ts +16 -0
- package/lib/modules/Order/index.js +2 -0
- package/lib/modules/Order/utils.d.ts +1 -0
- package/lib/modules/Order/utils.js +11 -0
- package/lib/modules/Rules/index.d.ts +7 -0
- package/lib/modules/Rules/index.js +809 -177
- package/lib/modules/Rules/types.d.ts +4 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +4 -0
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +55 -9
- package/lib/solution/ShopDiscount/types.d.ts +4 -1
- package/lib/solution/ShopDiscount/utils.d.ts +55 -0
- package/lib/solution/ShopDiscount/utils.js +266 -3
- package/package.json +1 -1
|
@@ -44,6 +44,7 @@ type ProductDetail = {
|
|
|
44
44
|
quantity: number;
|
|
45
45
|
vouchersApplicable?: boolean;
|
|
46
46
|
holder_id?: number;
|
|
47
|
+
startDate?: any;
|
|
47
48
|
};
|
|
48
49
|
export interface RulesParamsHooks {
|
|
49
50
|
getProduct: (product: Record<string, any>) => ProductDetail;
|
|
@@ -54,8 +55,10 @@ export interface RulesParamsHooks {
|
|
|
54
55
|
origin_total?: number;
|
|
55
56
|
price?: string | number;
|
|
56
57
|
variant?: any[];
|
|
57
|
-
original_price?: number;
|
|
58
|
+
original_price?: number | string;
|
|
58
59
|
quantity?: number;
|
|
60
|
+
bundle?: any[];
|
|
61
|
+
main_product_selling_price?: string | number;
|
|
59
62
|
}) => Record<string, any>;
|
|
60
63
|
}
|
|
61
64
|
export {};
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
};
|
|
343
343
|
setOtherData(key: string, value: any): void;
|
|
344
344
|
getOtherData(key: string): any;
|
|
345
|
-
getProductTypeById(id: number): Promise<"
|
|
345
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
346
346
|
/**
|
|
347
347
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
348
348
|
*
|
|
@@ -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 客户状态
|
|
@@ -18,6 +18,8 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
18
18
|
private initializePlugins;
|
|
19
19
|
private registerDependentModules;
|
|
20
20
|
private registerEventListeners;
|
|
21
|
+
getCurrentBookingTime(): string | null;
|
|
22
|
+
private filterDiscountListByBookingTime;
|
|
21
23
|
setCustomer(customer: Customer): Promise<void>;
|
|
22
24
|
setHolders(holders: {
|
|
23
25
|
form_record_id: number;
|
|
@@ -27,6 +27,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
27
27
|
import { BaseModule } from "../../modules/BaseModule";
|
|
28
28
|
import { DiscountModule } from "../../modules/Discount";
|
|
29
29
|
import { RulesModule } from "../../modules/Rules";
|
|
30
|
+
import { filterDiscountListByBookingTime as _filterDiscountListByBookingTime, isAllNormalProduct } from "./utils";
|
|
30
31
|
import Decimal from 'decimal.js';
|
|
31
32
|
import { isBoolean } from 'lodash-es';
|
|
32
33
|
export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
@@ -51,6 +52,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
51
52
|
discount: null,
|
|
52
53
|
rules: null,
|
|
53
54
|
originalDiscountList: [],
|
|
55
|
+
currentBookingTime: "",
|
|
56
|
+
filteredDiscountList: [],
|
|
54
57
|
holders: []
|
|
55
58
|
};
|
|
56
59
|
return _this;
|
|
@@ -208,6 +211,55 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
208
211
|
|
|
209
212
|
// =========== 公共 API ===========
|
|
210
213
|
|
|
214
|
+
// 设置预约时间
|
|
215
|
+
// public async setBookingTime(bookingTime: string | null): Promise<void> {
|
|
216
|
+
// if (this.store.currentBookingTime !== bookingTime) {
|
|
217
|
+
// this.store.currentBookingTime = bookingTime;
|
|
218
|
+
//
|
|
219
|
+
// // 更新过滤后的优惠券列表
|
|
220
|
+
// await this.updateFilteredDiscountList();
|
|
221
|
+
// }
|
|
222
|
+
// }
|
|
223
|
+
|
|
224
|
+
// 获取当前预约时间
|
|
225
|
+
}, {
|
|
226
|
+
key: "getCurrentBookingTime",
|
|
227
|
+
value: function getCurrentBookingTime() {
|
|
228
|
+
return this.store.currentBookingTime;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// 根据预约时间过滤优惠券列表
|
|
232
|
+
}, {
|
|
233
|
+
key: "filterDiscountListByBookingTime",
|
|
234
|
+
value: function filterDiscountListByBookingTime(discountList, bookingTime) {
|
|
235
|
+
// 如果全部是普通商品,不需要过滤,直接返回当前数据
|
|
236
|
+
if (isAllNormalProduct(this.store.productList || [])) {
|
|
237
|
+
return discountList;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// 否则使用 bookingTime 进行过滤
|
|
241
|
+
return _filterDiscountListByBookingTime(discountList, bookingTime);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// 更新过滤后的优惠券列表
|
|
245
|
+
// private async updateFilteredDiscountList(): Promise<void> {
|
|
246
|
+
// const originalList = this.store.originalDiscountList;
|
|
247
|
+
// const filteredList = this.filterDiscountListByBookingTime(originalList, this.store.currentBookingTime);
|
|
248
|
+
//
|
|
249
|
+
// this.store.filteredDiscountList = filteredList;
|
|
250
|
+
//
|
|
251
|
+
// // 更新 DiscountModule 中的优惠券列表
|
|
252
|
+
// this.setDiscountList(filteredList);
|
|
253
|
+
//
|
|
254
|
+
// if (this.store.productList?.length) {
|
|
255
|
+
// const result = this.calcDiscount(this.store.productList);
|
|
256
|
+
// await this.core.effects.emit(
|
|
257
|
+
// ShopDiscountHooks.onLoadPrepareCalcResult,
|
|
258
|
+
// result,
|
|
259
|
+
// );
|
|
260
|
+
// }
|
|
261
|
+
// }
|
|
262
|
+
|
|
211
263
|
// 设置客户
|
|
212
264
|
}, {
|
|
213
265
|
key: "setCustomer",
|
|
@@ -507,7 +559,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
507
559
|
if (index !== -1) {
|
|
508
560
|
editModeDiscountList[index] = _objectSpread(_objectSpread({}, editModeDiscountList[index]), {}, {
|
|
509
561
|
amount: new Decimal(discount.amount || 0).plus(new Decimal(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
510
|
-
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.num) || 1).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
562
|
+
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
511
563
|
});
|
|
512
564
|
} else {
|
|
513
565
|
var _discount$discount2, _discount$discount3, _discount$discount4;
|
|
@@ -518,7 +570,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
518
570
|
name: discount.name || discount.discount.title.auto,
|
|
519
571
|
isEditMode: true,
|
|
520
572
|
limited_relation_product_data: {},
|
|
521
|
-
savedAmount: discount.amount * ((product === null || product === void 0 ? void 0 : product.num) || 1),
|
|
573
|
+
savedAmount: discount.amount * ((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1),
|
|
522
574
|
isAvailable: true,
|
|
523
575
|
id: ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) || discount.id,
|
|
524
576
|
format_title: ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.title) || discount.format_title,
|
|
@@ -539,17 +591,20 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
539
591
|
var targetProduct = productList.find(function (n) {
|
|
540
592
|
return n.id === id;
|
|
541
593
|
});
|
|
594
|
+
if (!targetProduct) return false;
|
|
542
595
|
var product = (_this3$hooks2 = _this3.hooks) === null || _this3$hooks2 === void 0 ? void 0 : _this3$hooks2.getProduct(targetProduct);
|
|
543
596
|
// 如果 product.total 是小于等于0有可能是她已经用过商品券或者折扣卡导致的,或者本身就是负数价格,所以此时还需要判断 origin_total 是否小于等于0
|
|
544
597
|
// 如果 product.vouchersApplicable是布尔值,并且是 false,也当做免费商品处理,此商品不可用优惠券或折扣卡
|
|
545
598
|
return Number(product === null || product === void 0 ? void 0 : product.total) <= 0 && (Number(product === null || product === void 0 ? void 0 : product.origin_total) <= 0 || !(product !== null && product !== void 0 && product.origin_total)) || isBoolean(product === null || product === void 0 ? void 0 : product.vouchersApplicable) && !(product !== null && product !== void 0 && product.vouchersApplicable);
|
|
546
599
|
};
|
|
547
|
-
var allUsedProductIds = newDiscountList.
|
|
600
|
+
var allUsedProductIds = newDiscountList.filter(function (item) {
|
|
601
|
+
return !(item !== null && item !== void 0 && item.isEditMode);
|
|
602
|
+
}).map(function (n) {
|
|
548
603
|
var _n$appliedProductDeta;
|
|
549
|
-
return n.isSelected ? (_n$appliedProductDeta = n.appliedProductDetails) === null || _n$appliedProductDeta === void 0 ? void 0 : _n$appliedProductDeta.map(function (n) {
|
|
604
|
+
return n.isSelected ? ((_n$appliedProductDeta = n.appliedProductDetails) === null || _n$appliedProductDeta === void 0 ? void 0 : _n$appliedProductDeta.map(function (n) {
|
|
550
605
|
var _n$discount;
|
|
551
606
|
return (_n$discount = n.discount) === null || _n$discount === void 0 ? void 0 : _n$discount.product_id;
|
|
552
|
-
}) : [];
|
|
607
|
+
})) || n.product_id : [];
|
|
553
608
|
}).flat();
|
|
554
609
|
newDiscountList.forEach(function (item) {
|
|
555
610
|
var _item$applicableProdu;
|
|
@@ -662,7 +717,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
662
717
|
key: "loadPrepareConfig",
|
|
663
718
|
value: function () {
|
|
664
719
|
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
665
|
-
var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$productLi2, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, _result3;
|
|
720
|
+
var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$discount8, _this$store$productLi2, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
|
|
666
721
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
667
722
|
while (1) switch (_context9.prev = _context9.next) {
|
|
668
723
|
case 0:
|
|
@@ -689,31 +744,37 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
689
744
|
newGoodPassList = goodPassList === null || goodPassList === void 0 ? void 0 : goodPassList.filter(function (n) {
|
|
690
745
|
return !scanDiscountIds.includes(n.id);
|
|
691
746
|
});
|
|
692
|
-
newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || []));
|
|
747
|
+
newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || [])); // 存储原始优惠券列表
|
|
693
748
|
this.store.originalDiscountList = newDiscountList;
|
|
694
|
-
|
|
749
|
+
_context9.next = 12;
|
|
750
|
+
return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.setOriginalDiscountList(newDiscountList);
|
|
751
|
+
case 12:
|
|
752
|
+
// 根据当前预约时间过滤优惠券列表
|
|
753
|
+
filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
|
|
754
|
+
this.store.filteredDiscountList = filteredDiscountList;
|
|
755
|
+
this.setDiscountList(filteredDiscountList || []);
|
|
695
756
|
if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
|
|
696
|
-
_context9.next =
|
|
757
|
+
_context9.next = 19;
|
|
697
758
|
break;
|
|
698
759
|
}
|
|
699
760
|
_result3 = this.calcDiscount(this.store.productList);
|
|
700
|
-
_context9.next =
|
|
761
|
+
_context9.next = 19;
|
|
701
762
|
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
|
|
702
|
-
case 15:
|
|
703
|
-
_context9.next = 17;
|
|
704
|
-
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), newDiscountList);
|
|
705
|
-
case 17:
|
|
706
|
-
_context9.next = 22;
|
|
707
|
-
break;
|
|
708
763
|
case 19:
|
|
709
|
-
_context9.
|
|
764
|
+
_context9.next = 21;
|
|
765
|
+
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
|
|
766
|
+
case 21:
|
|
767
|
+
_context9.next = 26;
|
|
768
|
+
break;
|
|
769
|
+
case 23:
|
|
770
|
+
_context9.prev = 23;
|
|
710
771
|
_context9.t0 = _context9["catch"](0);
|
|
711
772
|
console.error('[ShopDiscount] 加载准备配置出错:', _context9.t0);
|
|
712
|
-
case
|
|
773
|
+
case 26:
|
|
713
774
|
case "end":
|
|
714
775
|
return _context9.stop();
|
|
715
776
|
}
|
|
716
|
-
}, _callee9, this, [[0,
|
|
777
|
+
}, _callee9, this, [[0, 23]]);
|
|
717
778
|
}));
|
|
718
779
|
function loadPrepareConfig(_x9) {
|
|
719
780
|
return _loadPrepareConfig.apply(this, arguments);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { DiscountModule
|
|
1
|
+
import { DiscountModule } from '../../modules/Discount';
|
|
2
2
|
import { RulesModule } from '../../modules/Rules';
|
|
3
|
+
import { Discount } from "../../modules/Discount/types";
|
|
3
4
|
export declare enum ShopDiscountHooks {
|
|
4
5
|
onInited = "shopDiscount:onInited",
|
|
5
6
|
onDestroy = "shopDiscount:onDestroy",
|
|
@@ -28,6 +29,8 @@ export interface ShopDiscountState {
|
|
|
28
29
|
form_id?: number;
|
|
29
30
|
main_field?: string;
|
|
30
31
|
}[];
|
|
32
|
+
currentBookingTime: string | null;
|
|
33
|
+
filteredDiscountList: Discount[];
|
|
31
34
|
}
|
|
32
35
|
export interface SetDiscountSelectedParams {
|
|
33
36
|
discountId: number;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Discount } from "../../modules/Discount/types";
|
|
2
2
|
export declare const uniqueById: <T>(arr: T[], key?: string) => T[];
|
|
3
|
+
export declare const isNormalProductByDurationSchedule: (item: any) => boolean;
|
|
4
|
+
export declare const isAllNormalProduct: (items: any[]) => boolean;
|
|
3
5
|
/**
|
|
4
6
|
* 获取折扣金额 基于折扣卡类型计算
|
|
5
7
|
* 商品券:直接返回商品价格
|
|
@@ -10,3 +12,56 @@ export declare const uniqueById: <T>(arr: T[], key?: string) => T[];
|
|
|
10
12
|
* @returns
|
|
11
13
|
*/
|
|
12
14
|
export declare const getDiscountAmount: (discount: Discount, total: number, price: number) => number;
|
|
15
|
+
export declare const getDiscountListAmountTotal: (discount: Discount[]) => any;
|
|
16
|
+
/**
|
|
17
|
+
* 获取折扣金额 计算每个折扣的金额
|
|
18
|
+
* @param discount
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
export declare const getDiscountListAmount: (discount: Discount[]) => any;
|
|
22
|
+
export interface ScheduleItem {
|
|
23
|
+
id: number;
|
|
24
|
+
name: string | {
|
|
25
|
+
[key: string]: string;
|
|
26
|
+
};
|
|
27
|
+
type: 'standard' | 'time-slots' | 'designation';
|
|
28
|
+
start_time: string | null;
|
|
29
|
+
end_time: string | null;
|
|
30
|
+
repeat_type: 'none' | 'daily' | 'weekly';
|
|
31
|
+
repeat_rule: {
|
|
32
|
+
end: {
|
|
33
|
+
type: 'never' | 'date' | 'occurrence';
|
|
34
|
+
end_date: string | null;
|
|
35
|
+
occurrence: number | null;
|
|
36
|
+
};
|
|
37
|
+
frequency: number;
|
|
38
|
+
excluded_date: Array<{
|
|
39
|
+
start: string;
|
|
40
|
+
end: string;
|
|
41
|
+
}>;
|
|
42
|
+
included_date: Array<{
|
|
43
|
+
start: string;
|
|
44
|
+
end: string;
|
|
45
|
+
}>;
|
|
46
|
+
frequency_date: number[];
|
|
47
|
+
} | null;
|
|
48
|
+
designation: Array<{
|
|
49
|
+
start_date: string;
|
|
50
|
+
start_time: string;
|
|
51
|
+
end_date: string;
|
|
52
|
+
end_time: string;
|
|
53
|
+
}> | null;
|
|
54
|
+
is_all: number;
|
|
55
|
+
time_slot: Array<{
|
|
56
|
+
start_time: string;
|
|
57
|
+
end_time: string;
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
export declare const getDateIsInSchedule: (dateTime: string, scheduleList: ScheduleItem[]) => boolean;
|
|
61
|
+
/**
|
|
62
|
+
* 根据预约时间过滤优惠券列表
|
|
63
|
+
* @param discountList 优惠券列表
|
|
64
|
+
* @param bookingTime 预约时间 (格式: YYYY-MM-DD HH:mm:ss)
|
|
65
|
+
* @returns 过滤后的优惠券列表
|
|
66
|
+
*/
|
|
67
|
+
export declare const filterDiscountListByBookingTime: (discountList: Discount[], bookingTime: string | null) => Discount[];
|