@pisell/pisellos 3.0.41 → 3.0.43
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/AccountList/index.js +17 -12
- package/dist/modules/Cart/index.d.ts +14 -0
- package/dist/modules/Cart/index.js +38 -1
- package/dist/modules/Cart/utils/cartProduct.d.ts +3 -0
- package/dist/modules/Cart/utils/cartProduct.js +28 -8
- package/dist/modules/Cart/utils/changePrice.d.ts +3 -0
- package/dist/modules/Cart/utils/changePrice.js +104 -0
- package/dist/modules/Date/index.js +74 -10
- package/dist/modules/Date/types.d.ts +2 -0
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +13 -6
- package/dist/modules/Discount/types.d.ts +10 -0
- package/dist/modules/ProductList/index.d.ts +7 -0
- package/dist/modules/ProductList/index.js +102 -39
- package/dist/modules/Rules/index.js +218 -80
- package/dist/modules/Rules/types.d.ts +7 -1
- package/dist/modules/Schedule/index.d.ts +9 -1
- package/dist/modules/Schedule/index.js +122 -2
- package/dist/modules/Schedule/types.d.ts +13 -0
- package/dist/modules/Schedule/utils.js +4 -0
- package/dist/solution/BookingByStep/index.d.ts +121 -30
- package/dist/solution/BookingByStep/index.js +760 -1065
- package/dist/solution/BookingByStep/utils/capacity.d.ts +47 -0
- package/dist/solution/BookingByStep/utils/capacity.js +132 -0
- package/dist/solution/BookingByStep/utils/resources.d.ts +21 -29
- package/dist/solution/BookingByStep/utils/resources.js +39 -95
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +11 -0
- package/dist/solution/BookingByStep/utils/timeslots.js +15 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +119 -44
- package/lib/modules/AccountList/index.js +4 -0
- package/lib/modules/Cart/index.d.ts +14 -0
- package/lib/modules/Cart/index.js +34 -1
- package/lib/modules/Cart/utils/cartProduct.d.ts +3 -0
- package/lib/modules/Cart/utils/cartProduct.js +20 -8
- package/lib/modules/Cart/utils/changePrice.d.ts +3 -0
- package/lib/modules/Cart/utils/changePrice.js +78 -0
- package/lib/modules/Date/index.js +62 -5
- package/lib/modules/Date/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +17 -6
- package/lib/modules/Discount/types.d.ts +10 -0
- package/lib/modules/ProductList/index.d.ts +7 -0
- package/lib/modules/ProductList/index.js +45 -0
- package/lib/modules/Rules/index.js +154 -63
- package/lib/modules/Rules/types.d.ts +7 -1
- package/lib/modules/Schedule/index.d.ts +9 -1
- package/lib/modules/Schedule/index.js +79 -1
- package/lib/modules/Schedule/types.d.ts +13 -0
- package/lib/modules/Schedule/utils.js +4 -1
- package/lib/solution/BookingByStep/index.d.ts +121 -30
- package/lib/solution/BookingByStep/index.js +395 -585
- package/lib/solution/BookingByStep/utils/capacity.d.ts +47 -0
- package/lib/solution/BookingByStep/utils/capacity.js +106 -0
- package/lib/solution/BookingByStep/utils/resources.d.ts +21 -29
- package/lib/solution/BookingByStep/utils/resources.js +21 -58
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +11 -0
- package/lib/solution/BookingByStep/utils/timeslots.js +7 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +91 -19
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/modules/Date/index.ts
|
|
@@ -24,6 +34,7 @@ __export(Date_exports, {
|
|
|
24
34
|
module.exports = __toCommonJS(Date_exports);
|
|
25
35
|
var import_BaseModule = require("../BaseModule");
|
|
26
36
|
var import_utils = require("./utils");
|
|
37
|
+
var import_cloneDeep = __toESM(require("lodash-es/cloneDeep"));
|
|
27
38
|
var DateModule = class extends import_BaseModule.BaseModule {
|
|
28
39
|
constructor(name, version) {
|
|
29
40
|
super(name, version);
|
|
@@ -58,18 +69,64 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
58
69
|
return this.store.dateRange;
|
|
59
70
|
}
|
|
60
71
|
async getResourceDates(params) {
|
|
72
|
+
var _a;
|
|
73
|
+
if (params.useCache) {
|
|
74
|
+
const currentDateList = this.getDateList() || [];
|
|
75
|
+
const currentDateListMap = new Map(
|
|
76
|
+
currentDateList.map((item) => [item.date, item])
|
|
77
|
+
);
|
|
78
|
+
const resourceIds = ((_a = params.query) == null ? void 0 : _a.resource_ids) || [];
|
|
79
|
+
const hasResource = resourceIds.every((id) => {
|
|
80
|
+
var _a2;
|
|
81
|
+
const currentItem = currentDateListMap.get(id.toString());
|
|
82
|
+
return (_a2 = currentItem == null ? void 0 : currentItem.resource) == null ? void 0 : _a2.some((n) => n.id === id);
|
|
83
|
+
});
|
|
84
|
+
if (hasResource) {
|
|
85
|
+
return currentDateList;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
61
88
|
const dates = await this.getResourceAvailableTimeList(params);
|
|
62
|
-
this.
|
|
89
|
+
this.setDateList(dates);
|
|
63
90
|
return dates;
|
|
64
91
|
}
|
|
65
92
|
getDateList() {
|
|
66
93
|
return this.store.dateList;
|
|
67
94
|
}
|
|
68
95
|
setDateList(dateList) {
|
|
69
|
-
this.store.dateList
|
|
96
|
+
const currentDateList = (0, import_cloneDeep.default)(this.store.dateList) || [];
|
|
97
|
+
dateList.forEach((item) => {
|
|
98
|
+
var _a, _b;
|
|
99
|
+
const currentItemIndex = currentDateList.findIndex(
|
|
100
|
+
(n) => n.date === item.date
|
|
101
|
+
);
|
|
102
|
+
if (currentItemIndex !== -1) {
|
|
103
|
+
const currentItem = currentDateList[currentItemIndex];
|
|
104
|
+
const newResource = (_a = item.resource) == null ? void 0 : _a.filter(
|
|
105
|
+
(n) => {
|
|
106
|
+
var _a2;
|
|
107
|
+
return !((_a2 = currentItem.resource) == null ? void 0 : _a2.some((m) => m.id === n.id));
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
(_b = currentItem.resource) == null ? void 0 : _b.forEach((n) => {
|
|
111
|
+
var _a2;
|
|
112
|
+
const newResource2 = (_a2 = item.resource) == null ? void 0 : _a2.find((m) => m.id === n.id);
|
|
113
|
+
if (newResource2) {
|
|
114
|
+
n.times = newResource2.times;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
currentItem.resource = [
|
|
118
|
+
...currentItem.resource || [],
|
|
119
|
+
...newResource || []
|
|
120
|
+
];
|
|
121
|
+
currentDateList[currentItemIndex] = currentItem;
|
|
122
|
+
} else {
|
|
123
|
+
currentDateList.push(item);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
this.store.dateList = currentDateList;
|
|
70
127
|
}
|
|
71
128
|
async fetchResourceDates(params) {
|
|
72
|
-
const { url, query } = params;
|
|
129
|
+
const { url, query, useCache = true } = params;
|
|
73
130
|
const fetchUrl = url || "/schedule/resource/list";
|
|
74
131
|
const { start_date, end_date, resource_ids } = query || {};
|
|
75
132
|
try {
|
|
@@ -77,9 +134,9 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
77
134
|
start_date,
|
|
78
135
|
end_date,
|
|
79
136
|
resource_ids,
|
|
80
|
-
front_end_cache_id: this.cacheId
|
|
137
|
+
front_end_cache_id: useCache && this.cacheId
|
|
81
138
|
}, {
|
|
82
|
-
useCache
|
|
139
|
+
useCache
|
|
83
140
|
});
|
|
84
141
|
return res;
|
|
85
142
|
} catch (error) {
|
|
@@ -17,6 +17,7 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
17
17
|
loadPrepareConfig(params: {
|
|
18
18
|
action?: 'create';
|
|
19
19
|
with_good_pass: 0 | 1;
|
|
20
|
+
with_discount_card: 0 | 1;
|
|
20
21
|
customer_id: number;
|
|
21
22
|
}): Promise<Discount[]>;
|
|
22
23
|
batchSearch(code: string): Promise<Discount[]>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/modules/Discount/index.ts
|
|
@@ -25,6 +35,7 @@ module.exports = __toCommonJS(Discount_exports);
|
|
|
25
35
|
var import_utils = require("../../solution/ShopDiscount/utils");
|
|
26
36
|
var import_BaseModule = require("../BaseModule");
|
|
27
37
|
var import_types = require("./types");
|
|
38
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
28
39
|
var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
29
40
|
constructor(name, version) {
|
|
30
41
|
super(name, version);
|
|
@@ -68,13 +79,13 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
68
79
|
return this.store.discountList;
|
|
69
80
|
}
|
|
70
81
|
async loadPrepareConfig(params) {
|
|
71
|
-
var _a;
|
|
82
|
+
var _a, _b;
|
|
72
83
|
const prepareConfig = await this.request.post(
|
|
73
84
|
`/order/prepare/config`,
|
|
74
85
|
params
|
|
75
86
|
);
|
|
76
87
|
const goodPassList = this.filterEnabledDiscountList(
|
|
77
|
-
((_a = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _a.good_pass_list) || []
|
|
88
|
+
[...((_a = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _a.good_pass_list) || [], ...((_b = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _b.discount_card_list) || []]
|
|
78
89
|
) || [];
|
|
79
90
|
return goodPassList;
|
|
80
91
|
}
|
|
@@ -82,7 +93,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
82
93
|
const result = await this.request.get(`/machinecode/batch-search`, {
|
|
83
94
|
code,
|
|
84
95
|
translate_flag: 1,
|
|
85
|
-
|
|
96
|
+
tags: ["good_pass", "product_discount_card"],
|
|
86
97
|
available: 1,
|
|
87
98
|
relation_product: 1
|
|
88
99
|
});
|
|
@@ -91,7 +102,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
91
102
|
}
|
|
92
103
|
filterEnabledDiscountList(discountList) {
|
|
93
104
|
return discountList.filter(
|
|
94
|
-
(discount) => discount.limit_status === "enable" &&
|
|
105
|
+
(discount) => discount.limit_status === "enable" && new import_decimal.default((discount == null ? void 0 : discount.par_value) || 0).minus(new import_decimal.default((discount == null ? void 0 : discount.used_par_value) || 0)).greaterThan(0)
|
|
95
106
|
);
|
|
96
107
|
}
|
|
97
108
|
// 根据productIds去重
|
|
@@ -110,8 +121,8 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
110
121
|
}
|
|
111
122
|
if (discount.appliedProductDetails) {
|
|
112
123
|
return discount.appliedProductDetails.reduce((total, product) => {
|
|
113
|
-
const price =
|
|
114
|
-
return total
|
|
124
|
+
const price = new import_decimal.default((product == null ? void 0 : product.amount) || 0).mul((product == null ? void 0 : product.num) || 1);
|
|
125
|
+
return new import_decimal.default(total).plus(price).toNumber();
|
|
115
126
|
}, 0);
|
|
116
127
|
}
|
|
117
128
|
}
|
|
@@ -27,6 +27,14 @@ interface ApplicableProductDetails {
|
|
|
27
27
|
resource_id: number;
|
|
28
28
|
title: string;
|
|
29
29
|
original_amount: string;
|
|
30
|
+
num: number;
|
|
31
|
+
discount?: {
|
|
32
|
+
product_id?: number;
|
|
33
|
+
original_amount?: string;
|
|
34
|
+
percent?: string;
|
|
35
|
+
resource_id?: number;
|
|
36
|
+
title?: string;
|
|
37
|
+
};
|
|
30
38
|
}
|
|
31
39
|
export interface Discount {
|
|
32
40
|
id: number;
|
|
@@ -60,6 +68,8 @@ export interface Discount {
|
|
|
60
68
|
applicableProductIds?: number[];
|
|
61
69
|
applicableProductDetails: ApplicableProductDetails[];
|
|
62
70
|
appliedProductDetails: ApplicableProductDetails[];
|
|
71
|
+
isDisabledForProductUsed?: boolean;
|
|
72
|
+
amount?: number;
|
|
63
73
|
}
|
|
64
74
|
export interface DiscountState {
|
|
65
75
|
discountList: Discount[];
|
|
@@ -11,6 +11,13 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
11
11
|
constructor(name?: string, version?: string);
|
|
12
12
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
13
13
|
storeChange(path?: string, value?: any): Promise<void>;
|
|
14
|
+
loadProducts({ category_ids, product_ids, collection, schedule_date, cacheId }: {
|
|
15
|
+
category_ids?: number[];
|
|
16
|
+
product_ids?: number[];
|
|
17
|
+
collection?: number | string[];
|
|
18
|
+
schedule_date?: string;
|
|
19
|
+
cacheId?: string;
|
|
20
|
+
}): Promise<any>;
|
|
14
21
|
loadProductsPrice({ ids, customer_id, schedule_date, channel, }: {
|
|
15
22
|
ids?: number[];
|
|
16
23
|
customer_id?: number;
|
|
@@ -64,6 +64,51 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
+
async loadProducts({
|
|
68
|
+
category_ids = [],
|
|
69
|
+
product_ids = [],
|
|
70
|
+
collection = [],
|
|
71
|
+
schedule_date,
|
|
72
|
+
cacheId
|
|
73
|
+
}) {
|
|
74
|
+
var _a;
|
|
75
|
+
let userPlugin = this.core.getPlugin("user");
|
|
76
|
+
let customer_id = void 0;
|
|
77
|
+
try {
|
|
78
|
+
customer_id = (_a = userPlugin == null ? void 0 : userPlugin.get()) == null ? void 0 : _a.id;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error(error);
|
|
81
|
+
}
|
|
82
|
+
const productsData = await this.request.post(
|
|
83
|
+
`/product/query`,
|
|
84
|
+
{
|
|
85
|
+
open_quotation: 1,
|
|
86
|
+
open_bundle: 0,
|
|
87
|
+
exclude_extension_type: [
|
|
88
|
+
"product_party",
|
|
89
|
+
"product_event",
|
|
90
|
+
"product_series_event",
|
|
91
|
+
"product_package_ticket",
|
|
92
|
+
"ticket",
|
|
93
|
+
"event_item"
|
|
94
|
+
],
|
|
95
|
+
with: ["category", "collection", "resourceRelation"],
|
|
96
|
+
status: "published",
|
|
97
|
+
num: 500,
|
|
98
|
+
skip: 1,
|
|
99
|
+
customer_id,
|
|
100
|
+
category_ids,
|
|
101
|
+
ids: product_ids,
|
|
102
|
+
collection,
|
|
103
|
+
front_end_cache_id: cacheId,
|
|
104
|
+
// client_schedule_ids: schedule_ids,
|
|
105
|
+
schedule_date
|
|
106
|
+
},
|
|
107
|
+
{ useCache: true }
|
|
108
|
+
);
|
|
109
|
+
this.addProduct(productsData.data.list);
|
|
110
|
+
return productsData.data.list;
|
|
111
|
+
}
|
|
67
112
|
async loadProductsPrice({
|
|
68
113
|
ids = [],
|
|
69
114
|
customer_id,
|