@pisell/pisellos 3.0.77 → 3.0.78
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/Date/types.d.ts +3 -1
- package/dist/modules/ProductList/index.js +8 -9
- package/dist/modules/Rules/index.d.ts +3 -1
- package/dist/modules/Rules/index.js +96 -13
- package/dist/modules/Rules/types.d.ts +6 -0
- package/dist/modules/Rules/types.js +8 -0
- package/dist/solution/BookingByStep/index.d.ts +17 -0
- package/dist/solution/BookingByStep/index.js +517 -152
- package/dist/solution/BookingByStep/utils/capacity.js +1 -1
- package/dist/solution/BookingByStep/utils/resources.js +4 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +9 -5
- package/lib/modules/Date/types.d.ts +3 -1
- package/lib/modules/ProductList/index.js +0 -7
- package/lib/modules/Rules/index.d.ts +3 -1
- package/lib/modules/Rules/index.js +40 -2
- package/lib/modules/Rules/types.d.ts +6 -0
- package/lib/modules/Rules/types.js +11 -2
- package/lib/solution/BookingByStep/index.d.ts +17 -0
- package/lib/solution/BookingByStep/index.js +321 -44
- package/lib/solution/BookingByStep/utils/capacity.js +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +4 -1
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +9 -4
- package/package.json +1 -1
|
@@ -320,7 +320,7 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
|
|
|
320
320
|
resourcesInType.forEach(function (resource) {
|
|
321
321
|
// 过滤出在时间段内的资源时间片
|
|
322
322
|
var availableTimes = resource.times.filter(function (time) {
|
|
323
|
-
return !dayjs(time.start_at).isAfter(dayjs(timeSlotStart), 'minute') && !dayjs(time.end_at).isBefore(dayjs(timeSlotEnd), 'minute') || dayjs(time.start_at).isBefore(dayjs(timeSlotEnd), 'minute') && dayjs(time.end_at).isAfter(dayjs(timeSlotStart), 'minute');
|
|
323
|
+
return !dayjs(time.start_at).isAfter(dayjs(timeSlotStart), 'minute') && !dayjs(time.end_at).isBefore(dayjs(timeSlotEnd), 'minute') || resource.onlyComputed && dayjs(time.start_at).isBefore(dayjs(timeSlotEnd), 'minute') && dayjs(time.end_at).isAfter(dayjs(timeSlotStart), 'minute');
|
|
324
324
|
});
|
|
325
325
|
if (availableTimes.length > 0) {
|
|
326
326
|
// 简化逻辑:如果资源在时间段内有可用时间,就计算其容量
|
|
@@ -444,6 +444,10 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
|
|
|
444
444
|
// 解析开始和结束时间
|
|
445
445
|
var startTime = dayjs("".concat(time.start_at));
|
|
446
446
|
var endTime = dayjs("".concat(time.end_at));
|
|
447
|
+
// 结束时间要做修复,如果time.end_at 是超过了 currentDate 的那一天,则把 end_at 设置为 currentDate 那一天的 23:59:59
|
|
448
|
+
if (endTime.isAfter(dayjs(currentDate).endOf('day'))) {
|
|
449
|
+
endTime = dayjs(currentDate).endOf('day');
|
|
450
|
+
}
|
|
447
451
|
|
|
448
452
|
// 当前切片的开始时间
|
|
449
453
|
var currentStart = startTime;
|
|
@@ -2,6 +2,7 @@ import { Module, PisellCore } from '../../types';
|
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
3
|
import { Customer } from './types';
|
|
4
4
|
import { Discount } from '../../modules/Discount/types';
|
|
5
|
+
import { UnavailableReason } from '../../modules/Rules/types';
|
|
5
6
|
export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
6
7
|
protected defaultName: string;
|
|
7
8
|
protected defaultVersion: string;
|
|
@@ -48,6 +49,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
48
49
|
productList: Record<string, any>[];
|
|
49
50
|
discountList: Discount[];
|
|
50
51
|
type: "server" | "clientCalc";
|
|
52
|
+
unavailableReason?: UnavailableReason;
|
|
51
53
|
}>;
|
|
52
54
|
calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
|
|
53
55
|
private getCustomer;
|
|
@@ -29,6 +29,7 @@ import { ShopDiscountHooks } from "./types";
|
|
|
29
29
|
import { DiscountModule } from "../../modules/Discount";
|
|
30
30
|
import { RulesModule } from "../../modules/Rules";
|
|
31
31
|
import { filterDiscountListByBookingTime as _filterDiscountListByBookingTime, isAllNormalProduct } from "./utils";
|
|
32
|
+
import { UnavailableReason } from "../../modules/Rules/types";
|
|
32
33
|
import Decimal from 'decimal.js';
|
|
33
34
|
export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
34
35
|
_inherits(ShopDiscountImpl, _BaseModule);
|
|
@@ -375,7 +376,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
375
376
|
key: "scanCode",
|
|
376
377
|
value: function () {
|
|
377
378
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
|
|
378
|
-
var _this$store$discount3, _this$store$bookingSu2, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref3, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
|
|
379
|
+
var _this$store$discount3, _this$store$bookingSu2, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref3, newProductList, newDiscountList, isAvailable, unavailableReason, _this$options$otherPa6;
|
|
379
380
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
380
381
|
while (1) switch (_context5.prev = _context5.next) {
|
|
381
382
|
case 0:
|
|
@@ -400,7 +401,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
400
401
|
type: "clientCalc",
|
|
401
402
|
isAvailable: false,
|
|
402
403
|
productList: this.store.productList || [],
|
|
403
|
-
discountList: this.getDiscountList()
|
|
404
|
+
discountList: this.getDiscountList(),
|
|
405
|
+
unavailableReason: UnavailableReason.Unknown
|
|
404
406
|
});
|
|
405
407
|
case 10:
|
|
406
408
|
if (resultDiscountList.length) {
|
|
@@ -447,7 +449,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
447
449
|
isAvailable: false,
|
|
448
450
|
productList: this.store.productList || [],
|
|
449
451
|
discountList: this.getDiscountList()
|
|
450
|
-
}, newProductList = _ref3.productList, newDiscountList = _ref3.discountList, isAvailable = _ref3.isAvailable;
|
|
452
|
+
}, newProductList = _ref3.productList, newDiscountList = _ref3.discountList, isAvailable = _ref3.isAvailable, unavailableReason = _ref3.unavailableReason;
|
|
451
453
|
if (!isAvailable) {
|
|
452
454
|
_context5.next = 23;
|
|
453
455
|
break;
|
|
@@ -465,7 +467,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
465
467
|
type: "clientCalc",
|
|
466
468
|
isAvailable: isAvailable || false,
|
|
467
469
|
productList: newProductList || this.store.productList || [],
|
|
468
|
-
discountList: newDiscountList || this.getDiscountList()
|
|
470
|
+
discountList: newDiscountList || this.getDiscountList(),
|
|
471
|
+
unavailableReason: unavailableReason
|
|
469
472
|
});
|
|
470
473
|
case 26:
|
|
471
474
|
_context5.prev = 26;
|
|
@@ -475,7 +478,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
475
478
|
type: "clientCalc",
|
|
476
479
|
isAvailable: false,
|
|
477
480
|
productList: this.store.productList || [],
|
|
478
|
-
discountList: this.getDiscountList()
|
|
481
|
+
discountList: this.getDiscountList(),
|
|
482
|
+
unavailableReason: UnavailableReason.Unknown
|
|
479
483
|
});
|
|
480
484
|
case 30:
|
|
481
485
|
case "end":
|
|
@@ -20,7 +20,9 @@ export interface ITime {
|
|
|
20
20
|
date: string;
|
|
21
21
|
week: string;
|
|
22
22
|
weekNum: number;
|
|
23
|
-
status: 'unavailable' | 'available';
|
|
23
|
+
status: 'unavailable' | 'available' | 'lots_of_space' | 'filling_up_fast' | 'sold_out';
|
|
24
|
+
summaryCount?: number;
|
|
25
|
+
availableCount?: number;
|
|
24
26
|
resource?: any[];
|
|
25
27
|
color?: string[];
|
|
26
28
|
}
|
|
@@ -95,13 +95,6 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
95
95
|
{ useCache: true }
|
|
96
96
|
);
|
|
97
97
|
const sortedList = (productsData.data.list || []).slice().sort((a, b) => Number(b.sort) - Number(a.sort));
|
|
98
|
-
if (sortedList.length) {
|
|
99
|
-
sortedList.forEach((n) => {
|
|
100
|
-
if (n.is_eject !== 1 && n["schedule.ids"] && n["schedule.ids"].length) {
|
|
101
|
-
n.is_eject = 1;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
98
|
this.addProduct(sortedList);
|
|
106
99
|
return sortedList;
|
|
107
100
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { Rules, RulesModuleAPI, DiscountResult } from './types';
|
|
3
|
+
import { Rules, RulesModuleAPI, DiscountResult, UnavailableReason } from './types';
|
|
4
4
|
import { Discount } from "../Discount/types";
|
|
5
5
|
export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
|
|
6
6
|
protected defaultName: string;
|
|
@@ -24,7 +24,9 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
24
24
|
isAvailable: boolean;
|
|
25
25
|
discountList: Discount[];
|
|
26
26
|
productList: any[];
|
|
27
|
+
unavailableReason?: UnavailableReason;
|
|
27
28
|
};
|
|
29
|
+
private getUnavailableReason;
|
|
28
30
|
calcDiscount({ discountList, productList, holders, isFormSubject, }: {
|
|
29
31
|
discountList: Discount[];
|
|
30
32
|
productList: any[];
|
|
@@ -94,7 +94,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
94
94
|
return {
|
|
95
95
|
isAvailable: false,
|
|
96
96
|
discountList: oldDiscountList,
|
|
97
|
-
productList
|
|
97
|
+
productList,
|
|
98
|
+
unavailableReason: import_types.UnavailableReason.AlreadyUsed
|
|
98
99
|
};
|
|
99
100
|
}
|
|
100
101
|
const filteredOldDiscountList = oldDiscountList.filter(
|
|
@@ -132,12 +133,49 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
135
|
});
|
|
136
|
+
let unavailableReason;
|
|
137
|
+
if (!hasApplicableDiscount) {
|
|
138
|
+
unavailableReason = this.getUnavailableReason(newDiscountList, productList);
|
|
139
|
+
}
|
|
135
140
|
return {
|
|
136
141
|
isAvailable: hasApplicableDiscount,
|
|
137
142
|
discountList: hasApplicableDiscount ? result.discountList : oldDiscountList,
|
|
138
|
-
productList: hasApplicableDiscount ? result.productList : productList
|
|
143
|
+
productList: hasApplicableDiscount ? result.productList : productList,
|
|
144
|
+
unavailableReason
|
|
139
145
|
};
|
|
140
146
|
}
|
|
147
|
+
// 获取券不可用的原因
|
|
148
|
+
getUnavailableReason(discountList, productList) {
|
|
149
|
+
var _a;
|
|
150
|
+
for (const discount of discountList) {
|
|
151
|
+
for (const item of productList) {
|
|
152
|
+
const product = this.hooks.getProduct(item);
|
|
153
|
+
const bookingTime = ((product == null ? void 0 : product.startDate) || (0, import_dayjs.default)()).format("YYYY-MM-DD HH:mm:ss");
|
|
154
|
+
const filteredList = (0, import_utils.filterDiscountListByBookingTime)([discount], bookingTime);
|
|
155
|
+
if (filteredList.length === 0) {
|
|
156
|
+
return import_types.UnavailableReason.TimeLimit;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
for (const discount of discountList) {
|
|
161
|
+
const limitedData = discount.limited_relation_product_data;
|
|
162
|
+
let hasApplicableProduct = false;
|
|
163
|
+
for (const item of productList) {
|
|
164
|
+
const product = this.hooks.getProduct(item);
|
|
165
|
+
if (limitedData.type === "product_all") {
|
|
166
|
+
hasApplicableProduct = true;
|
|
167
|
+
break;
|
|
168
|
+
} else if ((_a = limitedData.product_ids) == null ? void 0 : _a.includes(product.id)) {
|
|
169
|
+
hasApplicableProduct = true;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (!hasApplicableProduct) {
|
|
174
|
+
return import_types.UnavailableReason.ProductNotApplicable;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return import_types.UnavailableReason.Unknown;
|
|
178
|
+
}
|
|
141
179
|
calcDiscount({
|
|
142
180
|
discountList,
|
|
143
181
|
productList,
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { Discount } from '../Discount/types';
|
|
2
|
+
export declare enum UnavailableReason {
|
|
3
|
+
TimeLimit = "time_limit",
|
|
4
|
+
ProductNotApplicable = "product_not_applicable",
|
|
5
|
+
AlreadyUsed = "already_used",
|
|
6
|
+
Unknown = "unknown"
|
|
7
|
+
}
|
|
2
8
|
export declare enum RulesHooks {
|
|
3
9
|
OnRulesListChange = "rules:onRulesListChange",
|
|
4
10
|
OnDestroy = "rules:onDestroy"
|
|
@@ -19,9 +19,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/modules/Rules/types.ts
|
|
20
20
|
var types_exports = {};
|
|
21
21
|
__export(types_exports, {
|
|
22
|
-
RulesHooks: () => RulesHooks
|
|
22
|
+
RulesHooks: () => RulesHooks,
|
|
23
|
+
UnavailableReason: () => UnavailableReason
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(types_exports);
|
|
26
|
+
var UnavailableReason = /* @__PURE__ */ ((UnavailableReason2) => {
|
|
27
|
+
UnavailableReason2["TimeLimit"] = "time_limit";
|
|
28
|
+
UnavailableReason2["ProductNotApplicable"] = "product_not_applicable";
|
|
29
|
+
UnavailableReason2["AlreadyUsed"] = "already_used";
|
|
30
|
+
UnavailableReason2["Unknown"] = "unknown";
|
|
31
|
+
return UnavailableReason2;
|
|
32
|
+
})(UnavailableReason || {});
|
|
25
33
|
var RulesHooks = /* @__PURE__ */ ((RulesHooks2) => {
|
|
26
34
|
RulesHooks2["OnRulesListChange"] = "rules:onRulesListChange";
|
|
27
35
|
RulesHooks2["OnDestroy"] = "rules:onDestroy";
|
|
@@ -29,5 +37,6 @@ var RulesHooks = /* @__PURE__ */ ((RulesHooks2) => {
|
|
|
29
37
|
})(RulesHooks || {});
|
|
30
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
31
39
|
0 && (module.exports = {
|
|
32
|
-
RulesHooks
|
|
40
|
+
RulesHooks,
|
|
41
|
+
UnavailableReason
|
|
33
42
|
});
|
|
@@ -299,6 +299,16 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
299
299
|
errorList: any[];
|
|
300
300
|
};
|
|
301
301
|
getTimeSlotByAllResources(resources_code: string): any[];
|
|
302
|
+
getTimeSlotByAllResourcesForDate({ resources_code, startDate, endDate }: {
|
|
303
|
+
resources_code: string;
|
|
304
|
+
startDate: string;
|
|
305
|
+
endDate: string;
|
|
306
|
+
}): Promise<{
|
|
307
|
+
date: string;
|
|
308
|
+
status: string;
|
|
309
|
+
week: string;
|
|
310
|
+
weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
311
|
+
}[]>;
|
|
302
312
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
303
313
|
private getScheduleDataByIds;
|
|
304
314
|
openProductDetail(productId: number): Promise<void>;
|
|
@@ -316,6 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
316
326
|
count: number;
|
|
317
327
|
left: number;
|
|
318
328
|
summaryCount: number;
|
|
329
|
+
status: keyof TimeStatusMap;
|
|
319
330
|
}[];
|
|
320
331
|
/**
|
|
321
332
|
* 找到多个资源的公共可用时间段
|
|
@@ -380,3 +391,9 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
380
391
|
*/
|
|
381
392
|
getContactInfo(params: any): Promise<any>;
|
|
382
393
|
}
|
|
394
|
+
interface TimeStatusMap {
|
|
395
|
+
lots_of_space: true;
|
|
396
|
+
filling_up_fast: true;
|
|
397
|
+
sold_out: true;
|
|
398
|
+
}
|
|
399
|
+
export {};
|