@pisell/pisellos 2.2.323 → 2.2.325
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/inventory/index.d.ts +92 -0
- package/dist/inventory/index.js +509 -0
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/BookingContext/index.d.ts +2 -2
- package/dist/modules/BookingContext/index.js +55 -25
- package/dist/modules/BookingContext/types.d.ts +2 -0
- package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
- package/dist/modules/BookingContext/utils/index.d.ts +1 -0
- package/dist/modules/BookingContext/utils/index.js +1 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +20 -1
- package/dist/modules/BookingContext/utils/productExtend.js +122 -29
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +60 -14
- package/dist/modules/Date/types.d.ts +5 -0
- package/dist/modules/Discount/index.js +1 -0
- package/dist/modules/OpenData/index.d.ts +1 -0
- package/dist/modules/OpenData/index.js +1 -0
- package/dist/modules/OpenData/salesSettings.d.ts +32 -0
- package/dist/modules/OpenData/salesSettings.js +80 -0
- package/dist/modules/OpenData/types.d.ts +16 -0
- package/dist/modules/OpenData/utils.d.ts +1 -1
- package/dist/modules/OpenData/utils.js +3 -2
- package/dist/modules/Order/index.d.ts +55 -12
- package/dist/modules/Order/index.js +2699 -1411
- package/dist/modules/Order/types.d.ts +43 -5
- package/dist/modules/Order/types.js +4 -0
- package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/dist/modules/Order/unpaidAmountGap.js +72 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.js +2 -2
- package/dist/modules/Order/utils/productVoucherGroups.d.ts +15 -0
- package/dist/modules/Order/utils/productVoucherGroups.js +115 -0
- package/dist/modules/Order/utils.d.ts +3 -1
- package/dist/modules/Order/utils.js +6 -2
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/clientDataVariants.js +6 -2
- package/dist/modules/ProductList/index.d.ts +2 -0
- package/dist/modules/ProductList/index.js +161 -51
- package/dist/modules/ResourcePlanner/planner.js +58 -2
- package/dist/modules/ResourcePlanner/types.d.ts +13 -0
- package/dist/modules/Rules/index.d.ts +2 -0
- package/dist/modules/Rules/index.js +58 -39
- package/dist/modules/Schedule/index.d.ts +7 -1
- package/dist/modules/Schedule/index.js +155 -39
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/modules/bookingReadValidation.d.ts +6 -0
- package/dist/modules/bookingReadValidation.js +72 -0
- package/dist/plugins/request.d.ts +2 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.js +1458 -1166
- package/dist/server/modules/order/index.js +2 -1
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/dist/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/dist/shared/receipt/small-ticket.d.ts +4 -0
- package/dist/shared/receipt/small-ticket.js +70 -12
- package/dist/solution/BaseSales/index.d.ts +39 -5
- package/dist/solution/BaseSales/index.js +1828 -1462
- package/dist/solution/BaseSales/types.d.ts +1 -0
- package/dist/solution/BaseSales/types.js +1 -0
- package/dist/solution/BookingByStep/index.d.ts +16 -2
- package/dist/solution/BookingByStep/index.js +676 -361
- package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/dist/solution/BookingByStep/utils/resources.js +117 -76
- package/dist/solution/BookingTicket/index.d.ts +15 -3
- package/dist/solution/BookingTicket/index.js +249 -135
- package/dist/solution/BookingTicket/types.d.ts +14 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +3 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +39 -11
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +88 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -1
- package/dist/solution/OrderInvoicePreview/index.js +14 -8
- package/dist/solution/ScanOrder/index.d.ts +2 -0
- package/dist/solution/ScanOrder/index.js +166 -67
- package/dist/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/dist/solution/ScanOrder/menuAvailability.js +363 -0
- package/dist/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
- package/dist/solution/UnifiedBookingSales/catalogQueryBatch.js +202 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +96 -4
- package/dist/solution/UnifiedBookingSales/index.js +3374 -1177
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +4 -0
- package/dist/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
- package/dist/solution/UnifiedBookingSales/salesSettings.js +81 -0
- package/dist/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/sessionResourceCache.js +271 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +71 -2
- package/dist/solution/UnifiedBookingSales/types.js +7 -1
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +283 -0
- package/dist/utils/platform.d.ts +2 -0
- package/dist/utils/platform.js +6 -0
- package/dist/utils/pos-receipt-auto-print.d.ts +4 -0
- package/dist/utils/pos-receipt-auto-print.js +14 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +12 -0
- package/lib/inventory/index.d.ts +92 -0
- package/lib/inventory/index.js +287 -0
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/BookingContext/index.d.ts +2 -2
- package/lib/modules/BookingContext/index.js +42 -10
- package/lib/modules/BookingContext/types.d.ts +2 -0
- package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
- package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
- package/lib/modules/BookingContext/utils/index.d.ts +1 -0
- package/lib/modules/BookingContext/utils/index.js +11 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +20 -1
- package/lib/modules/BookingContext/utils/productExtend.js +96 -7
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +28 -5
- package/lib/modules/Date/types.d.ts +5 -0
- package/lib/modules/Discount/index.js +1 -0
- package/lib/modules/OpenData/index.d.ts +1 -0
- package/lib/modules/OpenData/index.js +12 -0
- package/lib/modules/OpenData/salesSettings.d.ts +32 -0
- package/lib/modules/OpenData/salesSettings.js +70 -0
- package/lib/modules/OpenData/types.d.ts +16 -0
- package/lib/modules/OpenData/utils.d.ts +1 -1
- package/lib/modules/OpenData/utils.js +3 -2
- package/lib/modules/Order/index.d.ts +55 -12
- package/lib/modules/Order/index.js +659 -80
- package/lib/modules/Order/types.d.ts +43 -5
- package/lib/modules/Order/types.js +2 -0
- package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
- package/lib/modules/Order/unpaidAmountGap.js +60 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.js +1 -1
- package/lib/modules/Order/utils/productVoucherGroups.d.ts +15 -0
- package/lib/modules/Order/utils/productVoucherGroups.js +64 -0
- package/lib/modules/Order/utils.d.ts +3 -1
- package/lib/modules/Order/utils.js +6 -2
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ProductList/clientDataVariants.js +6 -2
- package/lib/modules/ProductList/index.d.ts +2 -0
- package/lib/modules/ProductList/index.js +74 -0
- package/lib/modules/ResourcePlanner/planner.js +52 -1
- package/lib/modules/ResourcePlanner/types.d.ts +13 -0
- package/lib/modules/Rules/index.d.ts +2 -0
- package/lib/modules/Rules/index.js +25 -9
- package/lib/modules/Schedule/index.d.ts +7 -1
- package/lib/modules/Schedule/index.js +68 -4
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/modules/bookingReadValidation.d.ts +6 -0
- package/lib/modules/bookingReadValidation.js +56 -0
- package/lib/plugins/request.d.ts +2 -0
- package/lib/server/index.d.ts +8 -0
- package/lib/server/index.js +194 -19
- package/lib/server/modules/order/index.js +2 -1
- package/lib/shared/receipt/customerInvoiceLanguages.d.ts +1 -1
- package/lib/shared/receipt/customerInvoiceLanguages.js +5 -3
- package/lib/shared/receipt/small-ticket.d.ts +4 -0
- package/lib/shared/receipt/small-ticket.js +63 -8
- package/lib/solution/BaseSales/index.d.ts +39 -5
- package/lib/solution/BaseSales/index.js +212 -18
- package/lib/solution/BaseSales/types.d.ts +1 -0
- package/lib/solution/BaseSales/types.js +1 -0
- package/lib/solution/BookingByStep/index.d.ts +16 -2
- package/lib/solution/BookingByStep/index.js +222 -14
- package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/lib/solution/BookingByStep/utils/resources.js +25 -15
- package/lib/solution/BookingTicket/index.d.ts +15 -3
- package/lib/solution/BookingTicket/index.js +47 -4
- package/lib/solution/BookingTicket/types.d.ts +14 -2
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +3 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +37 -6
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +54 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -1
- package/lib/solution/OrderInvoicePreview/index.js +7 -1
- package/lib/solution/ScanOrder/index.d.ts +2 -0
- package/lib/solution/ScanOrder/index.js +72 -2
- package/lib/solution/ScanOrder/menuAvailability.d.ts +24 -0
- package/lib/solution/ScanOrder/menuAvailability.js +203 -0
- package/lib/solution/UnifiedBookingSales/catalogQueryBatch.d.ts +21 -0
- package/lib/solution/UnifiedBookingSales/catalogQueryBatch.js +109 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +96 -4
- package/lib/solution/UnifiedBookingSales/index.js +1316 -73
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +2 -0
- package/lib/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
- package/lib/solution/UnifiedBookingSales/salesSettings.js +72 -0
- package/lib/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/sessionResourceCache.js +199 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +71 -2
- package/lib/solution/UnifiedBookingSales/types.js +4 -1
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +155 -0
- package/lib/utils/platform.d.ts +2 -0
- package/lib/utils/platform.js +7 -0
- package/lib/utils/pos-receipt-auto-print.d.ts +4 -0
- package/lib/utils/pos-receipt-auto-print.js +13 -0
- package/package.json +1 -1
|
@@ -9,6 +9,8 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
9
9
|
private store;
|
|
10
10
|
window: WindowPlugin;
|
|
11
11
|
private hooks;
|
|
12
|
+
private discountScope?;
|
|
13
|
+
setDiscountScope(scope: (product: any, discount: Discount) => boolean): void;
|
|
12
14
|
constructor(name?: string, version?: string);
|
|
13
15
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
14
16
|
setRulesList(rulesList: Rules[]): Promise<void>;
|
|
@@ -22,6 +22,10 @@ class RulesModule extends _BaseModule.BaseModule {
|
|
|
22
22
|
store;
|
|
23
23
|
window; // WindowPlugin 实例
|
|
24
24
|
hooks;
|
|
25
|
+
discountScope;
|
|
26
|
+
setDiscountScope(scope) {
|
|
27
|
+
this.discountScope = scope;
|
|
28
|
+
}
|
|
25
29
|
constructor(name, version) {
|
|
26
30
|
super(name, version);
|
|
27
31
|
this.hooks = {};
|
|
@@ -745,6 +749,7 @@ class RulesModule extends _BaseModule.BaseModule {
|
|
|
745
749
|
|
|
746
750
|
// 辅助函数:检查商品是否对某个折扣卡可用
|
|
747
751
|
const checkItemApplicableForDiscount = (flatItem, discount) => {
|
|
752
|
+
if (this.discountScope && !this.discountScope(flatItem.originProduct, discount)) return false;
|
|
748
753
|
if (discount.config?.isAvailable === false) return false;
|
|
749
754
|
if (isCardBlockedByPromotion(flatItem, discount)) return false;
|
|
750
755
|
let product;
|
|
@@ -935,6 +940,22 @@ class RulesModule extends _BaseModule.BaseModule {
|
|
|
935
940
|
|
|
936
941
|
// 记录已应用优惠券的商品信息
|
|
937
942
|
const appliedDiscountProducts = new Map();
|
|
943
|
+
const hasPayableOptions = product => {
|
|
944
|
+
return (product.options || []).reduce((total, option) => {
|
|
945
|
+
const unitPrice = Number(option._original_price ?? option._original_add_price ?? option.price ?? option.add_price ?? 0);
|
|
946
|
+
const quantity = Number(option.num ?? option.quantity ?? 1);
|
|
947
|
+
if (!Number.isFinite(unitPrice) || !Number.isFinite(quantity) || quantity <= 0) {
|
|
948
|
+
return total;
|
|
949
|
+
}
|
|
950
|
+
return total.plus(new _decimal.default(unitPrice).mul(quantity));
|
|
951
|
+
}, new _decimal.default(0)).greaterThan(0);
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
// 只排除赠品主项的零可抵扣金额;收费 option 和独立 bundle 保持原有规则。
|
|
955
|
+
const isGiftWithoutDeductibleAmount = (flatItem, discount) => {
|
|
956
|
+
if (flatItem.type !== 'main' || !flatItem.originProduct?.metadata?._giftInfo || Number(flatItem.price || 0) > 0) return false;
|
|
957
|
+
return !discount.config?.deductOptionPrice || !hasPayableOptions(flatItem.product);
|
|
958
|
+
};
|
|
938
959
|
|
|
939
960
|
// 可用性和实际应用共用金额判断;零基础价商品可按策略抵扣收费 option。
|
|
940
961
|
const isDiscountCardPriceAvailable = (flatItem, discount) => {
|
|
@@ -945,14 +966,7 @@ class RulesModule extends _BaseModule.BaseModule {
|
|
|
945
966
|
if (flatItem.type !== 'main' || Number(flatItem.price) !== 0 || !['discount_card', 'product_discount_card'].includes(discount.tag || discount.type || '') || !discount.config?.deductOptionPrice || (0, _utils.isOrderLevelFixedAmountDiscount)(discount)) {
|
|
946
967
|
return false;
|
|
947
968
|
}
|
|
948
|
-
return (product
|
|
949
|
-
const unitPrice = Number(option._original_price ?? option._original_add_price ?? option.price ?? option.add_price ?? 0);
|
|
950
|
-
const quantity = Number(option.num ?? option.quantity ?? 1);
|
|
951
|
-
if (!Number.isFinite(unitPrice) || !Number.isFinite(quantity) || quantity <= 0) {
|
|
952
|
-
return total;
|
|
953
|
-
}
|
|
954
|
-
return total.plus(new _decimal.default(unitPrice).mul(quantity));
|
|
955
|
-
}, new _decimal.default(0)).greaterThan(0);
|
|
969
|
+
return hasPayableOptions(product);
|
|
956
970
|
};
|
|
957
971
|
|
|
958
972
|
// 首先遍历所有商品和所有优惠券,确定每个优惠券的适用范围,包括isSelected为false的优惠券
|
|
@@ -1007,7 +1021,7 @@ class RulesModule extends _BaseModule.BaseModule {
|
|
|
1007
1021
|
}
|
|
1008
1022
|
|
|
1009
1023
|
// 判断优惠券是否适用于该商品
|
|
1010
|
-
if (isAvailableProduct && !isItemRewardProductDiscount && isLimitedProduct && timeLimit && isBundleAvailable && discount.config?.isAvailable && ((0, _entitlementPass.isFullCoveragePass)(discount) || isDiscountCardPriceAvailable(flatItem, discount)) && (!(0, _entitlementPass.isEntitlementPass)(discount) || (0, _entitlementPass.getRemainingEntitlementUses)(discount, 0, 1) > 0)) {
|
|
1024
|
+
if (isAvailableProduct && !isItemRewardProductDiscount && !isGiftWithoutDeductibleAmount(flatItem, discount) && isLimitedProduct && timeLimit && isBundleAvailable && discount.config?.isAvailable && ((0, _entitlementPass.isFullCoveragePass)(discount) || isDiscountCardPriceAvailable(flatItem, discount)) && (!(0, _entitlementPass.isEntitlementPass)(discount) || (0, _entitlementPass.getRemainingEntitlementUses)(discount, 0, 1) > 0)) {
|
|
1011
1025
|
// 记录此优惠券适用的商品
|
|
1012
1026
|
discountApplicability.get(discount.id)?.push(product.id);
|
|
1013
1027
|
if (flatItem.type === 'main' && (0, _promotionSelection.isPromotionDiscountCard)(discount)) {
|
|
@@ -1156,6 +1170,8 @@ class RulesModule extends _BaseModule.BaseModule {
|
|
|
1156
1170
|
|
|
1157
1171
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
1158
1172
|
const applicableDiscounts = sortedDiscountList.filter(discount => {
|
|
1173
|
+
if (isGiftWithoutDeductibleAmount(flatItem, discount)) return false;
|
|
1174
|
+
if (this.discountScope && !this.discountScope(originProduct, discount)) return false;
|
|
1159
1175
|
if (this.isItemRewardProductDiscount(product)) return false;
|
|
1160
1176
|
if (isCardBlockedByPromotion(flatItem, discount)) return false;
|
|
1161
1177
|
// 🔥 检查策略可用性(针对全额抵扣卡和折扣卡)
|
|
@@ -14,6 +14,9 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
14
14
|
private scheduleListRequestVersion;
|
|
15
15
|
private scheduleCatalogScope;
|
|
16
16
|
private otherParams;
|
|
17
|
+
private catalogVersion;
|
|
18
|
+
private destroyed;
|
|
19
|
+
private availabilityRequestVersion;
|
|
17
20
|
constructor(name?: string, version?: string);
|
|
18
21
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
19
22
|
/**
|
|
@@ -34,12 +37,15 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
34
37
|
loadAllSchedule(options?: {
|
|
35
38
|
useCache?: boolean;
|
|
36
39
|
}): Promise<void>;
|
|
40
|
+
getScheduleCatalogVersion(): number;
|
|
41
|
+
/** Resolve only after the current scope has a successful catalog. */
|
|
42
|
+
ensureScheduleReady(): Promise<void>;
|
|
37
43
|
private loadScheduleCatalog;
|
|
38
44
|
setScheduleList(list: ScheduleItem[]): void;
|
|
39
45
|
private syncScheduleMap;
|
|
40
46
|
getScheduleList(): ScheduleItem[];
|
|
41
47
|
isScheduleListLoaded(): boolean;
|
|
42
|
-
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel, }: LoadScheduleAvailableDateParams): Promise<import("../Date/types").ITime[]>;
|
|
48
|
+
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel, assertCurrent, }: LoadScheduleAvailableDateParams): Promise<import("../Date/types").ITime[]>;
|
|
43
49
|
getScheduleListByIds(ids: number[]): ScheduleItem[];
|
|
44
50
|
setAvailabilityScheduleDateList(list: ScheduleAvailabilityDateItem[]): void;
|
|
45
51
|
getAvailabilityScheduleDateList(): ScheduleAvailabilityDateItem[];
|
|
@@ -12,6 +12,7 @@ var _isSameOrAfter = _interopRequireDefault(require("dayjs/plugin/isSameOrAfter"
|
|
|
12
12
|
var _utils = require("../Date/utils");
|
|
13
13
|
var _utils2 = require("./utils");
|
|
14
14
|
var _getDateIsInSchedule = require("./getDateIsInSchedule");
|
|
15
|
+
var _bookingReadValidation = require("../bookingReadValidation");
|
|
15
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
17
|
_dayjs.default.extend(_isSameOrBefore.default);
|
|
17
18
|
_dayjs.default.extend(_isSameOrAfter.default);
|
|
@@ -28,13 +29,17 @@ class ScheduleModule extends _BaseModule.BaseModule {
|
|
|
28
29
|
scheduleListRequestVersion = 0;
|
|
29
30
|
scheduleCatalogScope = '';
|
|
30
31
|
otherParams = {};
|
|
32
|
+
catalogVersion = 0;
|
|
33
|
+
destroyed = false;
|
|
34
|
+
availabilityRequestVersion = 0;
|
|
31
35
|
constructor(name, version) {
|
|
32
36
|
super(name, version);
|
|
33
37
|
}
|
|
34
38
|
async initialize(core, options) {
|
|
35
39
|
// The store proxies initialState, so capture its input before resets write through it.
|
|
36
40
|
const initialScheduleList = options.initialState?.scheduleList;
|
|
37
|
-
const hasInitialScheduleList = Array.isArray(initialScheduleList);
|
|
41
|
+
const hasInitialScheduleList = options.otherParams?.scheduleCatalogCache !== 'memory' && Array.isArray(initialScheduleList);
|
|
42
|
+
this.destroyed = false;
|
|
38
43
|
this.resetScheduleCatalog();
|
|
39
44
|
this.core = core;
|
|
40
45
|
|
|
@@ -89,6 +94,8 @@ class ScheduleModule extends _BaseModule.BaseModule {
|
|
|
89
94
|
}
|
|
90
95
|
}
|
|
91
96
|
resetScheduleCatalog() {
|
|
97
|
+
this.catalogVersion += 1;
|
|
98
|
+
this.availabilityRequestVersion += 1;
|
|
92
99
|
this.scheduleListRequestVersion += 1;
|
|
93
100
|
this.scheduleListPromise = null;
|
|
94
101
|
this.hasLoadedScheduleList = false;
|
|
@@ -96,6 +103,7 @@ class ScheduleModule extends _BaseModule.BaseModule {
|
|
|
96
103
|
this.store.map = new Map();
|
|
97
104
|
}
|
|
98
105
|
destroy() {
|
|
106
|
+
this.destroyed = true;
|
|
99
107
|
this.resetScheduleCatalog();
|
|
100
108
|
super.destroy();
|
|
101
109
|
}
|
|
@@ -123,15 +131,48 @@ class ScheduleModule extends _BaseModule.BaseModule {
|
|
|
123
131
|
}
|
|
124
132
|
}
|
|
125
133
|
}
|
|
134
|
+
getScheduleCatalogVersion() {
|
|
135
|
+
this.syncScheduleCatalogScope();
|
|
136
|
+
return this.catalogVersion;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Resolve only after the current scope has a successful catalog. */
|
|
140
|
+
async ensureScheduleReady() {
|
|
141
|
+
while (!this.destroyed) {
|
|
142
|
+
this.syncScheduleCatalogScope();
|
|
143
|
+
const scope = this.scheduleCatalogScope;
|
|
144
|
+
try {
|
|
145
|
+
await this.loadAllSchedule();
|
|
146
|
+
} catch (error) {
|
|
147
|
+
if (this.destroyed) throw Object.assign(new Error('Schedule catalog was closed'), {
|
|
148
|
+
name: 'AbortError'
|
|
149
|
+
});
|
|
150
|
+
this.syncScheduleCatalogScope();
|
|
151
|
+
if (scope === this.scheduleCatalogScope) throw error;
|
|
152
|
+
// A failed old-scope request does not describe the new scope.
|
|
153
|
+
}
|
|
154
|
+
this.syncScheduleCatalogScope();
|
|
155
|
+
if (!this.destroyed && this.hasLoadedScheduleList && !this.scheduleListPromise) return;
|
|
156
|
+
}
|
|
157
|
+
throw Object.assign(new Error('Schedule catalog was closed'), {
|
|
158
|
+
name: 'AbortError'
|
|
159
|
+
});
|
|
160
|
+
}
|
|
126
161
|
async loadScheduleCatalog(useCache, requestVersion) {
|
|
127
162
|
const response = await this.request.get(`/schedule`, {
|
|
128
163
|
num: 999
|
|
129
164
|
}, {
|
|
130
|
-
useCache
|
|
165
|
+
useCache: this.otherParams.scheduleCatalogCache === 'memory' ? false : useCache,
|
|
166
|
+
...(this.otherParams.bookingRead ? {
|
|
167
|
+
bookingRead: true
|
|
168
|
+
} : {})
|
|
131
169
|
});
|
|
132
170
|
if (response.code !== undefined && Number(response.code) !== 200 || response.status === false || typeof response.status === 'number' && response.status >= 400 || response.success === false) {
|
|
133
171
|
throw new Error(response.message || 'Schedule catalog request failed');
|
|
134
172
|
}
|
|
173
|
+
if ((this.otherParams.bookingRead || this.otherParams.scheduleCatalogCache === 'memory') && !(0, _bookingReadValidation.isBookingScheduleList)(response?.data?.list)) {
|
|
174
|
+
throw new Error('Invalid schedule catalog response');
|
|
175
|
+
}
|
|
135
176
|
this.syncScheduleCatalogScope();
|
|
136
177
|
// A refresh or a different runtime may have superseded this request.
|
|
137
178
|
if (requestVersion === this.scheduleListRequestVersion) {
|
|
@@ -143,6 +184,7 @@ class ScheduleModule extends _BaseModule.BaseModule {
|
|
|
143
184
|
this.store.scheduleList = list;
|
|
144
185
|
this.syncScheduleMap();
|
|
145
186
|
this.hasLoadedScheduleList = true;
|
|
187
|
+
this.catalogVersion += 1;
|
|
146
188
|
}
|
|
147
189
|
syncScheduleMap() {
|
|
148
190
|
this.store.map = new Map((this.store.scheduleList || []).map(schedule => [Number(schedule.id), schedule]));
|
|
@@ -159,8 +201,12 @@ class ScheduleModule extends _BaseModule.BaseModule {
|
|
|
159
201
|
startDate,
|
|
160
202
|
endDate,
|
|
161
203
|
custom_page_id,
|
|
162
|
-
channel
|
|
204
|
+
channel,
|
|
205
|
+
assertCurrent
|
|
163
206
|
}) {
|
|
207
|
+
this.syncScheduleCatalogScope();
|
|
208
|
+
const requestVersion = ++this.availabilityRequestVersion;
|
|
209
|
+
const scope = this.scheduleCatalogScope;
|
|
164
210
|
// 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天,需要把 startDate 置为今天
|
|
165
211
|
if ((0, _dayjs.default)(startDate).isBefore((0, _dayjs.default)(), 'day')) {
|
|
166
212
|
startDate = (0, _dayjs.default)().format('YYYY-MM-DD');
|
|
@@ -177,7 +223,25 @@ class ScheduleModule extends _BaseModule.BaseModule {
|
|
|
177
223
|
end_date: endDate,
|
|
178
224
|
custom_page_id,
|
|
179
225
|
channel
|
|
226
|
+
}, this.otherParams.bookingRead ? {
|
|
227
|
+
bookingRead: true
|
|
228
|
+
} : undefined).catch(error => {
|
|
229
|
+
assertCurrent?.();
|
|
230
|
+
throw error;
|
|
180
231
|
});
|
|
232
|
+
assertCurrent?.();
|
|
233
|
+
if (this.otherParams.bookingRead) {
|
|
234
|
+
const response = res;
|
|
235
|
+
if (!response || response.code !== undefined && Number(response.code) !== 200 || response.status === false || response.success === false || typeof response.status === 'number' && response.status >= 400 || !(0, _bookingReadValidation.isBookingAvailabilityData)(response.data)) {
|
|
236
|
+
throw new Error(response?.message || 'Invalid schedule availability response');
|
|
237
|
+
}
|
|
238
|
+
this.syncScheduleCatalogScope();
|
|
239
|
+
if (this.destroyed || scope !== this.scheduleCatalogScope || requestVersion !== this.availabilityRequestVersion) {
|
|
240
|
+
throw Object.assign(new Error('Schedule availability context changed'), {
|
|
241
|
+
name: 'AbortError'
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
181
245
|
const responseData = res.data || {};
|
|
182
246
|
const dateList = Array.isArray(responseData.date_list) ? responseData.date_list : [];
|
|
183
247
|
const otherProductIds = Array.isArray(responseData.other_product_ids) ? responseData.other_product_ids : [];
|
|
@@ -232,7 +296,7 @@ class ScheduleModule extends _BaseModule.BaseModule {
|
|
|
232
296
|
cacheId: this.cacheId,
|
|
233
297
|
fatherModule: this.fatherModule,
|
|
234
298
|
store,
|
|
235
|
-
cacheKey: ['scheduleList', 'availabilityDateList', 'otherProductsIds']
|
|
299
|
+
cacheKey: this.otherParams.scheduleCatalogCache === 'memory' ? ['availabilityDateList', 'otherProductsIds'] : ['scheduleList', 'availabilityDateList', 'otherProductsIds']
|
|
236
300
|
});
|
|
237
301
|
}
|
|
238
302
|
}
|
|
@@ -15,6 +15,8 @@ export type ScheduleAvailabilityDateItem = {
|
|
|
15
15
|
* 加载日程可用日期参数接口
|
|
16
16
|
*/
|
|
17
17
|
export interface LoadScheduleAvailableDateParams {
|
|
18
|
+
/** Caller lifecycle guard, checked before committing availability. */
|
|
19
|
+
assertCurrent?: () => void;
|
|
18
20
|
/** 开始日期 */
|
|
19
21
|
startDate: string;
|
|
20
22
|
/** 结束日期 */
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Validate only the catalog fields consumed by booking reads, not display metadata. */
|
|
2
|
+
export declare const isBookingScheduleList: (value: unknown) => boolean;
|
|
3
|
+
/** Empty resource/time/event arrays and zero capacity are valid successful results. */
|
|
4
|
+
export declare const isBookingResourceList: (value: unknown) => boolean;
|
|
5
|
+
/** The availability endpoint may return either or both lists. */
|
|
6
|
+
export declare const isBookingAvailabilityData: (value: unknown) => boolean;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isBookingScheduleList = exports.isBookingResourceList = exports.isBookingAvailabilityData = void 0;
|
|
7
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
const isRecord = value => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
10
|
+
const isNumericValue = value => (typeof value === 'number' || typeof value === 'string' && value.trim() !== '') && Number.isFinite(Number(value));
|
|
11
|
+
const isDateValue = value => {
|
|
12
|
+
if (typeof value !== 'string' || !value.trim() || !(0, _dayjs.default)(value).isValid()) return false;
|
|
13
|
+
// dayjs accepts overflowing calendar components; do not turn them into another date.
|
|
14
|
+
const dateParts = /^(\d{4})-(\d{2})-(\d{2})(?:$|[ T])/.exec(value);
|
|
15
|
+
if (!dateParts) return true;
|
|
16
|
+
const [, year, month, date] = dateParts.map(Number);
|
|
17
|
+
const calendarDate = new Date(0);
|
|
18
|
+
calendarDate.setUTCFullYear(year, month - 1, date);
|
|
19
|
+
return calendarDate.getUTCFullYear() === year && calendarDate.getUTCMonth() === month - 1 && calendarDate.getUTCDate() === date;
|
|
20
|
+
};
|
|
21
|
+
const isRecordArray = value => Array.isArray(value) && value.every(isRecord);
|
|
22
|
+
|
|
23
|
+
/** Validate only the catalog fields consumed by booking reads, not display metadata. */
|
|
24
|
+
const isBookingScheduleList = value => Array.isArray(value) && value.every(schedule => {
|
|
25
|
+
if (!isRecord(schedule) || !isNumericValue(schedule.id)) return false;
|
|
26
|
+
if (schedule.type === 'time-slots' && !isRecordArray(schedule.time_slot)) return false;
|
|
27
|
+
if (schedule.type === 'designation' && !isRecord(schedule.designation) && !isRecordArray(schedule.designation)) return false;
|
|
28
|
+
if ((schedule.repeat_type === 'daily' || schedule.repeat_type === 'weekly') && !isRecord(schedule.repeat_rule)) return false;
|
|
29
|
+
if (schedule.repeat_rule !== undefined && schedule.repeat_rule !== null) {
|
|
30
|
+
if (!isRecord(schedule.repeat_rule)) return false;
|
|
31
|
+
const rule = schedule.repeat_rule;
|
|
32
|
+
if (rule.end !== undefined && rule.end !== null && !isRecord(rule.end)) return false;
|
|
33
|
+
for (const key of ['excluded_date', 'included_date', 'frequency_date']) {
|
|
34
|
+
if (rule[key] !== undefined && rule[key] !== null && !Array.isArray(rule[key])) return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/** Empty resource/time/event arrays and zero capacity are valid successful results. */
|
|
41
|
+
exports.isBookingScheduleList = isBookingScheduleList;
|
|
42
|
+
const isBookingResourceList = value => Array.isArray(value) && value.every(resource => {
|
|
43
|
+
if (!isRecord(resource) || !isNumericValue(resource.id) || !isNumericValue(resource.form_id) || !Array.isArray(resource.times)) return false;
|
|
44
|
+
if (resource.capacity !== undefined && !isNumericValue(resource.capacity)) return false;
|
|
45
|
+
return resource.times.every(time => isRecord(time) && isDateValue(time.start_at) && isDateValue(time.end_at) && (time.event_list === undefined || isRecordArray(time.event_list)));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
/** The availability endpoint may return either or both lists. */
|
|
49
|
+
exports.isBookingResourceList = isBookingResourceList;
|
|
50
|
+
const isBookingAvailabilityData = value => {
|
|
51
|
+
if (!isRecord(value) || value.date_list === undefined && value.other_product_ids === undefined) return false;
|
|
52
|
+
if (value.date_list !== undefined && (!Array.isArray(value.date_list) || !value.date_list.every(date => isRecord(date) && isDateValue(date.date)))) return false;
|
|
53
|
+
if (value.other_product_ids !== undefined && (!Array.isArray(value.other_product_ids) || !value.other_product_ids.every(isNumericValue))) return false;
|
|
54
|
+
return true;
|
|
55
|
+
};
|
|
56
|
+
exports.isBookingAvailabilityData = isBookingAvailabilityData;
|
package/lib/plugins/request.d.ts
CHANGED
|
@@ -56,6 +56,8 @@ export interface CacheProps {
|
|
|
56
56
|
* 请求配置
|
|
57
57
|
*/
|
|
58
58
|
export interface RequestOptions {
|
|
59
|
+
/** Opt in to the host's bounded retry policy for booking availability GETs. */
|
|
60
|
+
bookingRead?: boolean;
|
|
59
61
|
/** Customer-only, credential-free GET /open/document/{id} on picoding. */
|
|
60
62
|
publicInvoiceDocument?: boolean;
|
|
61
63
|
/** Route through the host's configured picoding environment. */
|
package/lib/server/index.d.ts
CHANGED
|
@@ -64,6 +64,8 @@ declare class Server {
|
|
|
64
64
|
private salesSearchSubscribers;
|
|
65
65
|
private deviceTaskActionsRegistered;
|
|
66
66
|
private localPaymentUpdateQueues;
|
|
67
|
+
private paymentIdentityRefreshes;
|
|
68
|
+
private receiptFulfillmentConfigInFlight;
|
|
67
69
|
private floorPlanQuerySubscribers;
|
|
68
70
|
private moduleRegistry;
|
|
69
71
|
constructor(core: PisellCore);
|
|
@@ -133,6 +135,8 @@ declare class Server {
|
|
|
133
135
|
private resolveKioskCheckoutOperatorId;
|
|
134
136
|
private mergeCheckoutSyncPayments;
|
|
135
137
|
private persistSyncedCheckoutOrder;
|
|
138
|
+
private hasPaidPaymentWithoutId;
|
|
139
|
+
private refreshMissingPaymentIds;
|
|
136
140
|
/**
|
|
137
141
|
* 将普通层 QuotationModule 的报价单计算能力桥接到 Server Products 模块。
|
|
138
142
|
*/
|
|
@@ -522,6 +526,8 @@ declare class Server {
|
|
|
522
526
|
private extractInvoiceTemplateSettings;
|
|
523
527
|
private applyCheckoutFulfillmentBuzzer;
|
|
524
528
|
private buildCheckoutResourceIdentifierBuzzer;
|
|
529
|
+
/** Refresh derived references on receipt copies; manual references and stored orders stay intact. */
|
|
530
|
+
private withCurrentReceiptResourceReference;
|
|
525
531
|
private getCheckoutResourceIdentifier;
|
|
526
532
|
private stringifyCheckoutResourceIdentifier;
|
|
527
533
|
private normalizeCheckoutSubmitData;
|
|
@@ -560,6 +566,8 @@ declare class Server {
|
|
|
560
566
|
* Android 结账自动小票由当前设备设置控制;其它平台保持原有行为。
|
|
561
567
|
*/
|
|
562
568
|
private shouldAutoPrintCheckoutReceipt;
|
|
569
|
+
/** Only receipt auto-printing uses this policy; vouchers retain their paid-order gate. */
|
|
570
|
+
private shouldAutoPrintReceiptForPaymentStatus;
|
|
563
571
|
private shouldBuildSmallTicketData;
|
|
564
572
|
private shouldPrintSyncedOrder;
|
|
565
573
|
private hasPaymentStatus;
|