@pisell/pisellos 2.2.171 → 2.2.172

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.
Files changed (156) hide show
  1. package/dist/modules/BookingContext/index.d.ts +37 -0
  2. package/dist/modules/BookingContext/index.js +436 -0
  3. package/dist/modules/BookingContext/types.d.ts +102 -0
  4. package/dist/modules/BookingContext/types.js +51 -0
  5. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  6. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +193 -0
  7. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  8. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
  9. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
  10. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +215 -0
  11. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  12. package/dist/modules/BookingContext/utils/flexible.js +56 -0
  13. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  14. package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
  15. package/dist/modules/BookingContext/utils/index.d.ts +11 -0
  16. package/dist/modules/BookingContext/utils/index.js +11 -0
  17. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  18. package/dist/modules/BookingContext/utils/noResource.js +77 -0
  19. package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
  20. package/dist/modules/BookingContext/utils/productExtend.js +339 -0
  21. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  22. package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
  23. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  24. package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
  25. package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
  26. package/dist/modules/BookingContext/utils/resources.js +486 -0
  27. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  28. package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
  29. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  30. package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
  31. package/dist/modules/Customer/index.d.ts +6 -0
  32. package/dist/modules/Customer/index.js +129 -83
  33. package/dist/modules/Customer/types.d.ts +2 -0
  34. package/dist/modules/Discount/index.d.ts +2 -4
  35. package/dist/modules/Discount/index.js +8 -93
  36. package/dist/modules/Discount/types.d.ts +1 -7
  37. package/dist/modules/Order/index.d.ts +47 -16
  38. package/dist/modules/Order/index.js +743 -334
  39. package/dist/modules/Order/types.d.ts +57 -17
  40. package/dist/modules/Order/types.js +2 -0
  41. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  42. package/dist/modules/Order/utils/manualProductDiscount.js +212 -0
  43. package/dist/modules/Order/utils.d.ts +23 -1
  44. package/dist/modules/Order/utils.js +139 -30
  45. package/dist/modules/Quotation/index.js +16 -5
  46. package/dist/modules/Rules/index.d.ts +4 -0
  47. package/dist/modules/Rules/index.js +26 -10
  48. package/dist/modules/SalesSummary/index.js +4 -2
  49. package/dist/modules/Schedule/index.js +6 -2
  50. package/dist/modules/index.d.ts +1 -0
  51. package/dist/modules/index.js +2 -1
  52. package/dist/server/index.js +10 -6
  53. package/dist/server/modules/order/utils/filterOrders.js +20 -6
  54. package/dist/server/modules/products/index.js +9 -8
  55. package/dist/server/modules/schedule/index.js +13 -6
  56. package/dist/solution/BaseSales/index.d.ts +65 -7
  57. package/dist/solution/BaseSales/index.js +1066 -315
  58. package/dist/solution/BaseSales/types.d.ts +53 -1
  59. package/dist/solution/BaseSales/types.js +3 -1
  60. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  61. package/dist/solution/BaseSales/utils/quotationPrice.js +159 -0
  62. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +65 -15
  63. package/dist/solution/BaseSales/utils.js +46 -8
  64. package/dist/solution/BookingTicket/index.d.ts +134 -2
  65. package/dist/solution/BookingTicket/index.js +768 -175
  66. package/dist/solution/BookingTicket/types.d.ts +2 -0
  67. package/dist/solution/BookingTicket/types.js +3 -0
  68. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
  69. package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
  70. package/dist/solution/ScanOrder/index.d.ts +9 -3
  71. package/dist/solution/ScanOrder/index.js +231 -128
  72. package/dist/solution/ScanOrder/utils.js +46 -8
  73. package/dist/solution/ShopDiscount/index.d.ts +0 -1
  74. package/dist/solution/ShopDiscount/index.js +18 -23
  75. package/dist/solution/VenueBooking/index.d.ts +5 -9
  76. package/dist/solution/VenueBooking/index.js +103 -55
  77. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  78. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
  79. package/lib/modules/BookingContext/index.d.ts +37 -0
  80. package/lib/modules/BookingContext/index.js +297 -0
  81. package/lib/modules/BookingContext/types.d.ts +102 -0
  82. package/lib/modules/BookingContext/types.js +34 -0
  83. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  84. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +207 -0
  85. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  86. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
  87. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
  88. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +198 -0
  89. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  90. package/lib/modules/BookingContext/utils/flexible.js +80 -0
  91. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  92. package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
  93. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  94. package/lib/modules/BookingContext/utils/index.js +43 -0
  95. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  96. package/lib/modules/BookingContext/utils/noResource.js +90 -0
  97. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  98. package/lib/modules/BookingContext/utils/productExtend.js +283 -0
  99. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  100. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  101. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  102. package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
  103. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  104. package/lib/modules/BookingContext/utils/resources.js +377 -0
  105. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  106. package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
  107. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  108. package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
  109. package/lib/modules/Customer/index.d.ts +6 -0
  110. package/lib/modules/Customer/index.js +26 -11
  111. package/lib/modules/Customer/types.d.ts +2 -0
  112. package/lib/modules/Discount/index.d.ts +2 -4
  113. package/lib/modules/Discount/index.js +8 -63
  114. package/lib/modules/Discount/types.d.ts +1 -7
  115. package/lib/modules/Order/index.d.ts +47 -16
  116. package/lib/modules/Order/index.js +389 -90
  117. package/lib/modules/Order/types.d.ts +57 -17
  118. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  119. package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
  120. package/lib/modules/Order/utils.d.ts +23 -1
  121. package/lib/modules/Order/utils.js +145 -21
  122. package/lib/modules/Quotation/index.js +17 -6
  123. package/lib/modules/Rules/index.d.ts +4 -0
  124. package/lib/modules/Rules/index.js +22 -14
  125. package/lib/modules/SalesSummary/index.js +4 -2
  126. package/lib/modules/Schedule/index.js +3 -1
  127. package/lib/modules/index.d.ts +1 -0
  128. package/lib/modules/index.js +3 -1
  129. package/lib/server/index.js +2 -0
  130. package/lib/server/modules/order/utils/filterOrders.js +12 -4
  131. package/lib/server/modules/products/index.js +8 -9
  132. package/lib/server/modules/schedule/index.js +2 -1
  133. package/lib/solution/BaseSales/index.d.ts +65 -7
  134. package/lib/solution/BaseSales/index.js +492 -20
  135. package/lib/solution/BaseSales/types.d.ts +53 -1
  136. package/lib/solution/BaseSales/types.js +3 -1
  137. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  138. package/lib/solution/BaseSales/utils/quotationPrice.js +201 -0
  139. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +70 -11
  140. package/lib/solution/BaseSales/utils.js +46 -6
  141. package/lib/solution/BookingTicket/index.d.ts +134 -2
  142. package/lib/solution/BookingTicket/index.js +341 -8
  143. package/lib/solution/BookingTicket/types.d.ts +2 -0
  144. package/lib/solution/BookingTicket/types.js +6 -0
  145. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
  146. package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
  147. package/lib/solution/ScanOrder/index.d.ts +9 -3
  148. package/lib/solution/ScanOrder/index.js +147 -66
  149. package/lib/solution/ScanOrder/utils.js +46 -6
  150. package/lib/solution/ShopDiscount/index.d.ts +0 -1
  151. package/lib/solution/ShopDiscount/index.js +2 -4
  152. package/lib/solution/VenueBooking/index.d.ts +5 -9
  153. package/lib/solution/VenueBooking/index.js +50 -14
  154. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  155. package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
  156. package/package.json +2 -2
@@ -0,0 +1,55 @@
1
+ import { Dayjs } from 'dayjs';
2
+ import { getDurationValue } from './flexible';
3
+ /**
4
+ * 判断商品是否为跨日预约(duration.type === 'days')。与 info2 isMultiDayProduct 等价。
5
+ */
6
+ export declare function isMultiDayProduct(product: any): boolean;
7
+ /**
8
+ * 判断 cacheItem 是否为 session 商品(extension_type ∈ session_product / session_ticket)。
9
+ */
10
+ export declare function isSessionProduct(cacheItem: any): boolean;
11
+ /** 从 catalog `cartDetailValue` 或 `_extend.other` 取 session 快照。 */
12
+ export declare function getSessionFromItem(item: any): Record<string, any> | null;
13
+ /**
14
+ * 将 cartDetailValue.session 写入 _extend 的起止时间(与 info2 getServiceStartTimeAndEndTime 的 session 分支一致)。
15
+ * 日历日优先用 ctx.date,时分取自 session.start_at / end_at 或 session.start_time / end_time。
16
+ */
17
+ export declare function applySessionTimesToExtend(item: any, extend: Record<string, any>, ctx?: {
18
+ date?: string | Dayjs | null;
19
+ }): Record<string, any>;
20
+ /**
21
+ * 是否应写入 booking(与 Product.utils isNormalProduct 对齐,并覆盖 session_ticket / cartDetailValue.session)。
22
+ */
23
+ export declare function isBookingProduct(item: any): boolean;
24
+ /**
25
+ * 处理 'now' 时间占位:'now' → 当前 HH:mm;其他原样返回。
26
+ * 与 info2 `getServeStartTime` 等价。
27
+ */
28
+ export declare function getServeStartTime(startTime: string | undefined | null): string;
29
+ /**
30
+ * 计算商品的开始结束时间(统一为 dayjs 实例)。
31
+ * 与 info2 `getServiceTimes` 行为等价:
32
+ * - 跨日商品:startDate = start_date + start_time,endDate = _extend.end_date 原样
33
+ * - session 商品:从 _extend.other.session 取 start_at / end_at
34
+ * - 普通商品:startDate + duration(含 flexible 处理)
35
+ */
36
+ export declare function getServiceTimes(service: any): {
37
+ startDate: Dayjs;
38
+ endDate: Dayjs;
39
+ };
40
+ /**
41
+ * 跨日预约相关:把 _extend.start_date / end_date 都对齐到 dayjs startOf('day')。
42
+ * 与 info2 `formatDayDate` 等价。
43
+ */
44
+ export declare function formatDayDate(_extend: any): {
45
+ start_date: Dayjs;
46
+ end_date: Dayjs;
47
+ };
48
+ /**
49
+ * 计算跨日预约时长:
50
+ * - type='days' → end - start 的天数
51
+ * - type='minutes' → end - start 的分钟数
52
+ * 与 info2 `getDays` 等价。
53
+ */
54
+ export declare function getDays(cacheItem: any, type: 'minutes' | 'days'): number;
55
+ export { getDurationValue };
@@ -0,0 +1,162 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
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
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/modules/BookingContext/utils/serviceTimes.ts
30
+ var serviceTimes_exports = {};
31
+ __export(serviceTimes_exports, {
32
+ applySessionTimesToExtend: () => applySessionTimesToExtend,
33
+ formatDayDate: () => formatDayDate,
34
+ getDays: () => getDays,
35
+ getDurationValue: () => import_flexible.getDurationValue,
36
+ getServeStartTime: () => getServeStartTime,
37
+ getServiceTimes: () => getServiceTimes,
38
+ getSessionFromItem: () => getSessionFromItem,
39
+ isBookingProduct: () => isBookingProduct,
40
+ isMultiDayProduct: () => isMultiDayProduct,
41
+ isSessionProduct: () => isSessionProduct
42
+ });
43
+ module.exports = __toCommonJS(serviceTimes_exports);
44
+ var import_dayjs = __toESM(require("dayjs"));
45
+ var import_flexible = require("./flexible");
46
+ function isMultiDayProduct(product) {
47
+ var _a;
48
+ return ((_a = product == null ? void 0 : product.duration) == null ? void 0 : _a.type) === "days";
49
+ }
50
+ function isSessionProduct(cacheItem) {
51
+ return ["session_product", "session_ticket"].includes(cacheItem == null ? void 0 : cacheItem.extension_type);
52
+ }
53
+ function getSessionFromItem(item) {
54
+ var _a, _b, _c;
55
+ const session = ((_a = item == null ? void 0 : item.cartDetailValue) == null ? void 0 : _a.session) ?? ((_c = (_b = item == null ? void 0 : item._extend) == null ? void 0 : _b.other) == null ? void 0 : _c.session);
56
+ return session && typeof session === "object" ? session : null;
57
+ }
58
+ function applySessionTimesToExtend(item, extend, ctx) {
59
+ var _a;
60
+ const session = ((_a = extend == null ? void 0 : extend.other) == null ? void 0 : _a.session) ?? getSessionFromItem(item);
61
+ if (!session || !isSessionProduct(item)) {
62
+ return extend;
63
+ }
64
+ const baseDate = (ctx == null ? void 0 : ctx.date) ? (0, import_dayjs.default)(ctx.date) : (0, import_dayjs.default)();
65
+ const startAt = (0, import_dayjs.default)(
66
+ `${baseDate.format("YYYY-MM-DD")} ${(0, import_dayjs.default)(session.start_at).format("HH:mm:ss")}`
67
+ );
68
+ const endAt = (0, import_dayjs.default)(
69
+ `${baseDate.format("YYYY-MM-DD")} ${(0, import_dayjs.default)(session.end_at).format("HH:mm:ss")}`
70
+ );
71
+ const nextExtend = {
72
+ ...extend,
73
+ other: { ...extend.other || {}, session },
74
+ start_date: startAt,
75
+ startDate: startAt,
76
+ start_time: session.start_time ?? (0, import_dayjs.default)(session.start_at).format("HH:mm"),
77
+ end_date: endAt,
78
+ endDate: endAt,
79
+ end_time: session.end_time ?? (0, import_dayjs.default)(session.end_at).format("HH:mm")
80
+ };
81
+ return {
82
+ ...nextExtend,
83
+ duration: getDays({ _extend: nextExtend }, "minutes")
84
+ };
85
+ }
86
+ function isBookingProduct(item) {
87
+ var _a, _b;
88
+ if (!item)
89
+ return false;
90
+ if (item.duration)
91
+ return true;
92
+ if ((_a = item == null ? void 0 : item.schedules) == null ? void 0 : _a.length)
93
+ return true;
94
+ if ((_b = item == null ? void 0 : item["schedule.ids"]) == null ? void 0 : _b.length)
95
+ return true;
96
+ if (isSessionProduct(item))
97
+ return true;
98
+ if (getSessionFromItem(item))
99
+ return true;
100
+ return false;
101
+ }
102
+ function getServeStartTime(startTime) {
103
+ if (startTime === "now")
104
+ return (0, import_dayjs.default)().format("HH:mm");
105
+ return startTime || "";
106
+ }
107
+ function getServiceTimes(service) {
108
+ var _a, _b, _c, _d, _e, _f, _g, _h;
109
+ const startDate = (0, import_dayjs.default)(
110
+ `${(0, import_dayjs.default)((_a = service == null ? void 0 : service._extend) == null ? void 0 : _a.start_date).format("YYYY-MM-DD")} ${getServeStartTime(
111
+ (_b = service == null ? void 0 : service._extend) == null ? void 0 : _b.start_time
112
+ )}`
113
+ );
114
+ if (isMultiDayProduct(service)) {
115
+ const startTime = getServeStartTime((_c = service == null ? void 0 : service._extend) == null ? void 0 : _c.start_time);
116
+ const endDateRaw = ((_d = service == null ? void 0 : service._extend) == null ? void 0 : _d.end_date) ?? ((_e = service == null ? void 0 : service._extend) == null ? void 0 : _e.endDate);
117
+ const endBase = (0, import_dayjs.default)(endDateRaw);
118
+ const endDate2 = endBase.isValid() ? (0, import_dayjs.default)(`${endBase.format("YYYY-MM-DD")} ${startTime}`) : endBase;
119
+ return {
120
+ startDate,
121
+ endDate: endDate2
122
+ };
123
+ }
124
+ const session = (_g = (_f = service == null ? void 0 : service._extend) == null ? void 0 : _f.other) == null ? void 0 : _g.session;
125
+ if (isSessionProduct(service) && session) {
126
+ return {
127
+ startDate: (0, import_dayjs.default)(session.start_at),
128
+ endDate: (0, import_dayjs.default)(session.end_at)
129
+ };
130
+ }
131
+ const endDate = startDate.add(import_flexible.flexibleObj.getValue((_h = service == null ? void 0 : service._extend) == null ? void 0 : _h.duration), "minute");
132
+ return { startDate, endDate };
133
+ }
134
+ function formatDayDate(_extend) {
135
+ return {
136
+ start_date: (0, import_dayjs.default)(_extend == null ? void 0 : _extend.start_date).startOf("day"),
137
+ end_date: (0, import_dayjs.default)(_extend == null ? void 0 : _extend.end_date).startOf("day")
138
+ };
139
+ }
140
+ function getDays(cacheItem, type) {
141
+ var _a, _b;
142
+ if (type === "days") {
143
+ const { start_date, end_date } = formatDayDate(cacheItem._extend);
144
+ return end_date.diff(start_date, "day");
145
+ }
146
+ const startDate = (0, import_dayjs.default)((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.start_date);
147
+ const endDate = (0, import_dayjs.default)((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.end_date);
148
+ return endDate.diff(startDate, type);
149
+ }
150
+ // Annotate the CommonJS export names for ESM import in node:
151
+ 0 && (module.exports = {
152
+ applySessionTimesToExtend,
153
+ formatDayDate,
154
+ getDays,
155
+ getDurationValue,
156
+ getServeStartTime,
157
+ getServiceTimes,
158
+ getSessionFromItem,
159
+ isBookingProduct,
160
+ isMultiDayProduct,
161
+ isSessionProduct
162
+ });
@@ -0,0 +1,42 @@
1
+ import dayjs from 'dayjs';
2
+ import { getDurationValue } from './flexible';
3
+ export interface TimeSlice {
4
+ label: string;
5
+ value: string;
6
+ }
7
+ export interface DurationSlice {
8
+ label: string;
9
+ value: number;
10
+ }
11
+ export interface TimeSlicesResult {
12
+ timeSlices: TimeSlice[];
13
+ durationSlicesBasedOnTime: DurationSlice[];
14
+ }
15
+ /**
16
+ * 把一天切成等长时间槽,输出 timeSlices(开始时间标签)与 durationSlicesBasedOnTime(基于切片的时长选项)。
17
+ *
18
+ * 与 info2 `sliceDayIntoFiveMinutes` 行为等价;为了不依赖 `locales`,label 输出原始时间字符串('08:00 AM' / '90'),
19
+ * UI 侧需要本地化展示时可基于 value 自行包装。
20
+ *
21
+ * @param config booking config `basic.service_time`,{ value: minutes }
22
+ * @param isDay 是否跨日预约(true 时按 1~30 天切片)
23
+ */
24
+ export declare function sliceDayIntoFiveMinutes(config: {
25
+ value?: number;
26
+ } | undefined | null, isDay?: boolean): TimeSlicesResult;
27
+ /**
28
+ * 取「下一个 duration 选项」:优先用 defaultValue;否则在 array 中找匹配的;找不到取第一个。
29
+ * 与 info2 `findNextDuration` 等价。
30
+ */
31
+ export declare function findNextDuration(current: {
32
+ value?: number;
33
+ } | undefined, array: DurationSlice[], defaultValue?: number): number | undefined;
34
+ /** 取首选 time slice:若指定 date(HH:mm)则找第一个 >= date 的;否则第一个。 */
35
+ export declare function findNextSlice(params: {
36
+ timeSlices: TimeSlice[];
37
+ index?: number;
38
+ date?: string;
39
+ }): string | undefined;
40
+ /** 取 endDate;duration='flexible' 时取 endDate 与店铺营业时间的较小值,否则 startDate + duration 分钟。 */
41
+ export declare function getEndDate(startDate: dayjs.Dayjs, duration: string | number, endDate: any, shopOpeningHours?: string): dayjs.Dayjs;
42
+ export { getDurationValue };
@@ -0,0 +1,124 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
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
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/modules/BookingContext/utils/timeSlices.ts
30
+ var timeSlices_exports = {};
31
+ __export(timeSlices_exports, {
32
+ findNextDuration: () => findNextDuration,
33
+ findNextSlice: () => findNextSlice,
34
+ getDurationValue: () => import_flexible.getDurationValue,
35
+ getEndDate: () => getEndDate,
36
+ sliceDayIntoFiveMinutes: () => sliceDayIntoFiveMinutes
37
+ });
38
+ module.exports = __toCommonJS(timeSlices_exports);
39
+ var import_dayjs = __toESM(require("dayjs"));
40
+ var import_flexible = require("./flexible");
41
+ function sliceDayIntoFiveMinutes(config, isDay) {
42
+ const startTime = (0, import_dayjs.default)().startOf("day");
43
+ const endTime = (0, import_dayjs.default)().endOf("day");
44
+ const timeSlice = config && config.value || 5;
45
+ const timeSlices = [];
46
+ const durationSlicesBasedOnTime = [];
47
+ let currentTime = startTime;
48
+ if (isDay) {
49
+ let currentDay = 1;
50
+ while (currentDay <= 30) {
51
+ timeSlices.push({
52
+ label: currentTime.format("hh:mm A"),
53
+ value: currentTime.format("HH:mm")
54
+ });
55
+ durationSlicesBasedOnTime.push({
56
+ label: String(currentDay),
57
+ value: currentDay
58
+ });
59
+ currentDay += 1;
60
+ }
61
+ return { timeSlices, durationSlicesBasedOnTime };
62
+ }
63
+ while (currentTime.isBefore(endTime)) {
64
+ timeSlices.push({
65
+ label: currentTime.format("hh:mm A"),
66
+ value: currentTime.format("HH:mm")
67
+ });
68
+ const nextTime = currentTime.add(timeSlice, "minute");
69
+ const durationValue = nextTime.diff(startTime, "minute");
70
+ durationSlicesBasedOnTime.push({
71
+ label: String(durationValue),
72
+ value: durationValue
73
+ });
74
+ currentTime = nextTime;
75
+ }
76
+ return { timeSlices, durationSlicesBasedOnTime };
77
+ }
78
+ function findNextDuration(current, array, defaultValue) {
79
+ if (defaultValue !== void 0 && defaultValue !== null)
80
+ return defaultValue;
81
+ if (!array || array.length === 0)
82
+ return void 0;
83
+ for (let i = 0; i < array.length; i += 1) {
84
+ if (array[i].value === (current == null ? void 0 : current.value))
85
+ return array[i].value;
86
+ }
87
+ return array[0].value;
88
+ }
89
+ function findNextSlice(params) {
90
+ var _a;
91
+ const { timeSlices, index = 0, date = "" } = params;
92
+ const currentTimeValue = date || (0, import_dayjs.default)().format("HH:mm");
93
+ for (let i = 0; i < timeSlices.length; i += 1) {
94
+ if (timeSlices[i].value !== "now" && timeSlices[i].value >= currentTimeValue) {
95
+ return timeSlices[i].value;
96
+ }
97
+ }
98
+ return (_a = timeSlices[index]) == null ? void 0 : _a.value;
99
+ }
100
+ function getEndDate(startDate, duration, endDate, shopOpeningHours) {
101
+ if (duration === "flexible") {
102
+ let openingDate = (0, import_dayjs.default)(
103
+ `${startDate.format("YYYY-MM-DD")} ${shopOpeningHours || "23:59"}`
104
+ );
105
+ if ((0, import_dayjs.default)(startDate).isAfter(openingDate)) {
106
+ openingDate = openingDate.add(1, "day");
107
+ }
108
+ if (!endDate)
109
+ return openingDate;
110
+ const endDateObj = (0, import_dayjs.default)(endDate);
111
+ if (endDateObj.isAfter(openingDate))
112
+ return openingDate;
113
+ return endDateObj;
114
+ }
115
+ return startDate.add(Number(duration), "minute");
116
+ }
117
+ // Annotate the CommonJS export names for ESM import in node:
118
+ 0 && (module.exports = {
119
+ findNextDuration,
120
+ findNextSlice,
121
+ getDurationValue,
122
+ getEndDate,
123
+ sliceDayIntoFiveMinutes
124
+ });
@@ -24,6 +24,12 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
24
24
  * @param operation 操作名称
25
25
  */
26
26
  private handleCustomerListError;
27
+ /**
28
+ * 查询客户列表但不写入 customerList / pagination 状态。
29
+ *
30
+ * 用于按 ID 补齐客户等内部查询,避免把临时的 num/searchParams 污染到滚动列表。
31
+ */
32
+ queryCustomerList(params?: ShopGetCustomerListParams): Promise<ICustomerListResponse>;
27
33
  /**
28
34
  * 获取客户列表
29
35
  * @param params 查询参数
@@ -75,7 +75,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
75
75
  } else {
76
76
  this.store.currentPage = 1;
77
77
  }
78
- if (typeof ((_e = options == null ? void 0 : options.initialState) == null ? void 0 : _e.pageSize) === "number") {
78
+ if (typeof ((_e = options == null ? void 0 : options.initialState) == null ? void 0 : _e.pageSize) === "number" && options.initialState.pageSize > 1) {
79
79
  this.store.pageSize = options.initialState.pageSize;
80
80
  } else {
81
81
  this.store.pageSize = import_constants.DEFAULT_PAGE_SIZE;
@@ -152,6 +152,20 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
152
152
  this.store.error
153
153
  );
154
154
  }
155
+ /**
156
+ * 查询客户列表但不写入 customerList / pagination 状态。
157
+ *
158
+ * 用于按 ID 补齐客户等内部查询,避免把临时的 num/searchParams 污染到滚动列表。
159
+ */
160
+ async queryCustomerList(params = {}) {
161
+ const { customerList, total, page, pageSize } = await this.fetchCustomerListData(params);
162
+ return {
163
+ list: customerList,
164
+ total,
165
+ page,
166
+ pageSize
167
+ };
168
+ }
155
169
  /**
156
170
  * 获取客户列表
157
171
  * @param params 查询参数
@@ -169,10 +183,6 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
169
183
  this.store.total = total;
170
184
  this.store.hasMore = page * pageSize < total;
171
185
  this.store.customerList = (0, import_lodash_es.cloneDeep)(customerList);
172
- await this.core.effects.emit(
173
- `${this.name}:onCustomerListUpdate`,
174
- this.store
175
- );
176
186
  this.triggerPaginationChange({
177
187
  page,
178
188
  pageSize,
@@ -192,6 +202,10 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
192
202
  } finally {
193
203
  this.store.loading = false;
194
204
  this.storeChange();
205
+ await this.core.effects.emit(
206
+ `${this.name}:onCustomerListUpdate`,
207
+ this.store
208
+ );
195
209
  }
196
210
  }
197
211
  /**
@@ -352,12 +366,13 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
352
366
  try {
353
367
  this.store.loadingMore = true;
354
368
  this.store.error = null;
355
- const { customerList: newCustomers, total, page, pageSize } = await this.fetchCustomerListData({
369
+ const loadMoreParams = {
356
370
  skip: nextPage,
357
371
  num: this.store.pageSize,
358
372
  ...this.store.searchParams
359
373
  // 使用存储的搜索条件
360
- });
374
+ };
375
+ const { customerList: newCustomers, total, page, pageSize } = await this.fetchCustomerListData(loadMoreParams);
361
376
  const updatedCustomerList = [...this.store.customerList, ...(0, import_lodash_es.cloneDeep)(newCustomers)];
362
377
  this.store.customerList = updatedCustomerList;
363
378
  this.store.currentPage = page;
@@ -372,10 +387,6 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
372
387
  hasMore: this.store.hasMore
373
388
  }
374
389
  );
375
- await this.core.effects.emit(
376
- `${this.name}:onCustomerListUpdate`,
377
- this.store
378
- );
379
390
  this.triggerPaginationChange({
380
391
  page,
381
392
  pageSize,
@@ -396,6 +407,10 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
396
407
  } finally {
397
408
  this.store.loadingMore = false;
398
409
  this.storeChange();
410
+ await this.core.effects.emit(
411
+ `${this.name}:onCustomerListUpdate`,
412
+ this.store
413
+ );
399
414
  }
400
415
  }
401
416
  /**
@@ -110,6 +110,8 @@ export interface CustomerState {
110
110
  export interface CustomerModuleAPI {
111
111
  /** 获取客户列表 */
112
112
  getCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
113
+ /** 查询客户列表但不更新列表分页状态 */
114
+ queryCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
113
115
  /** 设置客户列表 */
114
116
  setCustomerList: (customers: ShopCustomer[], total?: number) => void;
115
117
  /** 设置当前选择的客户 */
@@ -1,6 +1,6 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { Discount, DiscountModuleAPI, DiscountWithReason } from './types';
3
+ import { Discount, DiscountModuleAPI } from './types';
4
4
  export declare class DiscountModule extends BaseModule implements Module, DiscountModuleAPI {
5
5
  protected defaultName: string;
6
6
  protected defaultVersion: string;
@@ -28,11 +28,9 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
28
28
  batchSearch(code: string, options?: {
29
29
  customerId?: number;
30
30
  orderId?: number;
31
- }): Promise<DiscountWithReason>;
31
+ }): Promise<Discount[]>;
32
32
  filterEnabledDiscountList(discountList: Discount[]): Discount[];
33
33
  private checkUsageCreditsLimit;
34
- filterEnabledDiscountListWithReason(discountList: Discount[]): DiscountWithReason;
35
- private checkUsageCreditsLimitWithFailKey;
36
34
  uniqueByProductId(discountList: Discount[]): Discount[];
37
35
  filterDiscountListByProductIds(discountList: Discount[], productIds: number[]): Discount[];
38
36
  calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
@@ -97,8 +97,12 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
97
97
  `/order/prepare/config`,
98
98
  params
99
99
  );
100
+ const rawDiscountList = [
101
+ ...((_a = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _a.good_pass_list) || [],
102
+ ...((_b = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _b.discount_card_list) || []
103
+ ];
100
104
  const goodPassList = this.filterEnabledDiscountList(
101
- [...((_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) || []]
105
+ rawDiscountList
102
106
  ) || [];
103
107
  return goodPassList;
104
108
  }
@@ -108,17 +112,16 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
108
112
  code,
109
113
  translate_flag: 1,
110
114
  tags: ["good_pass", "product_discount_card"],
111
- // available: 1,
115
+ available: 1,
112
116
  relation_product: 1,
113
117
  with: ["extensionData", "customScheduleSnapshot", "holder.detail"],
114
118
  order_behavior_count: 1,
115
119
  order_behavior_count_customer_id: customerId || 1,
116
120
  ...orderId ? { order_behavior_count_order_id: orderId } : {},
117
- unified_status_info_flag: 1,
118
121
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
119
122
  });
120
- const resultDiscountWithReason = this.filterEnabledDiscountListWithReason((result == null ? void 0 : result.data) || []) || [];
121
- return resultDiscountWithReason;
123
+ const resultDiscountList = this.filterEnabledDiscountList((result == null ? void 0 : result.data) || []) || [];
124
+ return resultDiscountList;
122
125
  }
123
126
  filterEnabledDiscountList(discountList) {
124
127
  return discountList.filter(
@@ -164,64 +167,6 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
164
167
  }
165
168
  return true;
166
169
  }
167
- // 过滤启用且可用的优惠券,并返回校验失败原因
168
- filterEnabledDiscountListWithReason(discountList) {
169
- let lists = discountList.filter((discount) => discount.limit_status === "enable").filter((discount) => {
170
- const remaining = 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);
171
- return remaining;
172
- }).map((discount) => {
173
- const limitFailKey = this.checkUsageCreditsLimitWithFailKey(discount);
174
- return {
175
- ...discount,
176
- usageLimitFailKey: limitFailKey
177
- };
178
- });
179
- const availableLists = lists.filter((item) => !item.usageLimitFailKey && item.unified_available_status !== 0);
180
- const currentFailDiscount = lists.find((item) => item.usageLimitFailKey);
181
- return {
182
- discountList: availableLists,
183
- unavailableReasonKey: currentFailDiscount == null ? void 0 : currentFailDiscount.usageLimitFailKey
184
- };
185
- }
186
- // 检查使用次数限制,并返回校验失败原因
187
- checkUsageCreditsLimitWithFailKey(discount) {
188
- if (!discount.extension_data || discount.extension_data.length === 0) {
189
- return null;
190
- }
191
- const usageCreditsData = discount.extension_data.find(
192
- (data) => data.field_key === "usage_credits"
193
- );
194
- if (!usageCreditsData) {
195
- return null;
196
- }
197
- const value = usageCreditsData.value;
198
- if (value.total_credits && value.total_credits > 0) {
199
- if ((discount.total_order_behavior_count || 0) >= value.total_credits) {
200
- return "total_credits";
201
- }
202
- }
203
- if (value.per_user_limit && value.per_user_limit > 0) {
204
- if ((discount.customer_order_behavior_count || 0) >= value.per_user_limit) {
205
- return "per_user_limit";
206
- }
207
- }
208
- if (value.max_per_day && value.max_per_day > 0) {
209
- if ((discount.today_order_behavior_count || 0) >= value.max_per_day) {
210
- return "max_per_day";
211
- }
212
- }
213
- if (value.max_per_week && value.max_per_week > 0) {
214
- if ((discount.week_order_behavior_count || 0) >= value.max_per_week) {
215
- return "max_per_week";
216
- }
217
- }
218
- if (value.max_per_month && value.max_per_month > 0) {
219
- if ((discount.month_order_behavior_count || 0) >= value.max_per_month) {
220
- return "max_per_month";
221
- }
222
- }
223
- return null;
224
- }
225
170
  // 根据productIds去重
226
171
  uniqueByProductId(discountList) {
227
172
  return (0, import_utils.uniqueById)(discountList, "product_id");
@@ -63,11 +63,6 @@ interface UsageCreditsValue {
63
63
  max_per_week: number;
64
64
  max_per_month: number;
65
65
  }
66
- export type DiscountFilterRejectKey = 'total_credits' | 'per_user_limit' | 'max_per_day' | 'max_per_week' | 'max_per_month';
67
- export interface DiscountWithReason {
68
- discountList: Discount[];
69
- unavailableReasonKey: DiscountFilterRejectKey | null;
70
- }
71
66
  interface ExtensionData {
72
67
  id: number;
73
68
  shop_id: number;
@@ -140,6 +135,7 @@ export interface Discount {
140
135
  appliedProductDetails: ApplicableProductDetails[];
141
136
  isDisabledForProductUsed?: boolean;
142
137
  amount?: number;
138
+ customer_id?: number | string | null;
143
139
  extension_data?: ExtensionData[];
144
140
  total_order_behavior_count?: number;
145
141
  today_order_behavior_count?: number;
@@ -152,8 +148,6 @@ export interface Discount {
152
148
  num?: number;
153
149
  start_date?: string;
154
150
  start_time?: string;
155
- usageLimitFailKey?: string | null;
156
- unified_available_status?: number | undefined | null;
157
151
  }
158
152
  export interface DiscountState {
159
153
  discountList: Discount[];