@pisell/pisellos 2.3.3 → 2.3.5
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/core/index.js +1 -1
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +9 -1
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Product/types.d.ts +6 -0
- package/dist/server/index.d.ts +9 -2
- package/dist/server/index.js +19 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/core/index.js +1 -1
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +8 -1
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +6 -0
- package/lib/server/index.d.ts +9 -2
- package/lib/server/index.js +17 -3
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/core/index.js
CHANGED
|
@@ -125,6 +125,13 @@ function resolveProductTitle(product, booking, sourceProduct) {
|
|
|
125
125
|
var metadata = product.metadata || {};
|
|
126
126
|
return (_ref = (_ref2 = (_ref3 = (_ref4 = (_ref5 = (_title = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) !== null && _title !== void 0 ? _title : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.name) !== null && _ref5 !== void 0 ? _ref5 : metadata.product_title) !== null && _ref4 !== void 0 ? _ref4 : metadata.product_name) !== null && _ref3 !== void 0 ? _ref3 : booking === null || booking === void 0 || (_booking$product = booking.product) === null || _booking$product === void 0 ? void 0 : _booking$product.title) !== null && _ref2 !== void 0 ? _ref2 : booking === null || booking === void 0 || (_booking$detail = booking.detail) === null || _booking$detail === void 0 ? void 0 : _booking$detail.product_title) !== null && _ref !== void 0 ? _ref : '';
|
|
127
127
|
}
|
|
128
|
+
function resolveMainProductPrice(product, fallback) {
|
|
129
|
+
var _metadata$main_produc;
|
|
130
|
+
var metadata = product.metadata || {};
|
|
131
|
+
var value = (_metadata$main_produc = metadata.main_product_original_price) !== null && _metadata$main_produc !== void 0 ? _metadata$main_produc : metadata.source_product_price;
|
|
132
|
+
var parsed = Number(value);
|
|
133
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
134
|
+
}
|
|
128
135
|
|
|
129
136
|
/**
|
|
130
137
|
* catalog 缺 product_resource 时,从 booking.resources 反推最小 product_resource 结构,
|
|
@@ -182,6 +189,7 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
182
189
|
var resolvedId = (_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.id;
|
|
183
190
|
var selling = Number((_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : 0);
|
|
184
191
|
var original = Number((_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : selling);
|
|
192
|
+
var mainProductPrice = resolveMainProductPrice(product, selling);
|
|
185
193
|
var startDate = safeFormat(booking.start_date, 'YYYY-MM-DD');
|
|
186
194
|
var endDate = safeFormat(booking.end_date, 'YYYY-MM-DD');
|
|
187
195
|
var startTime = normalizeTimeString(booking.start_time);
|
|
@@ -208,7 +216,7 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
208
216
|
quantity: (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : 1,
|
|
209
217
|
product_name: productTitle,
|
|
210
218
|
note: (_ref8 = (_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : booking === null || booking === void 0 || (_booking$detail2 = booking.detail) === null || _booking$detail2 === void 0 ? void 0 : _booking$detail2.note) !== null && _ref8 !== void 0 ? _ref8 : '',
|
|
211
|
-
price:
|
|
219
|
+
price: mainProductPrice,
|
|
212
220
|
total: selling,
|
|
213
221
|
origin_total: original,
|
|
214
222
|
resource: resource,
|
|
@@ -431,7 +431,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
431
431
|
generateIdempotencyToken(): string;
|
|
432
432
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
433
433
|
createOrder(params: CommitOrderParams['query']): {
|
|
434
|
-
type: "
|
|
434
|
+
type: "appointment_booking" | "virtual";
|
|
435
435
|
platform: string;
|
|
436
436
|
sales_channel: string;
|
|
437
437
|
order_sales_channel: string;
|
|
@@ -168,6 +168,12 @@ export interface ProductData {
|
|
|
168
168
|
product_resource?: {
|
|
169
169
|
resources?: ProductResourceItem[];
|
|
170
170
|
};
|
|
171
|
+
/** 商品级持有人配置,resource_id 对应 holder 表单 id */
|
|
172
|
+
holder_config?: {
|
|
173
|
+
status?: string;
|
|
174
|
+
required?: number | string | boolean;
|
|
175
|
+
resource_id?: number | string | null;
|
|
176
|
+
};
|
|
171
177
|
/** 组合商品id,动态附加 */
|
|
172
178
|
product_variant_id?: number;
|
|
173
179
|
/** 套餐信息 */
|
package/dist/server/index.d.ts
CHANGED
|
@@ -318,6 +318,13 @@ declare class Server {
|
|
|
318
318
|
* this.extractQueryDate('2026-04-15 09:58:00') // => '2026-04-15'
|
|
319
319
|
*/
|
|
320
320
|
private extractQueryDate;
|
|
321
|
+
/**
|
|
322
|
+
* 判断时间范围是否完整落在今天。
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* this.isRangeFullyToday('2026-04-15', '2026-04-15') // => true
|
|
326
|
+
*/
|
|
327
|
+
private isRangeFullyToday;
|
|
321
328
|
/**
|
|
322
329
|
* 判断时间范围是否「开始和结束都不是今天」。
|
|
323
330
|
*
|
|
@@ -327,8 +334,8 @@ declare class Server {
|
|
|
327
334
|
private isRangeBothNotToday;
|
|
328
335
|
/**
|
|
329
336
|
* 订单查询是否走本地:
|
|
330
|
-
* -
|
|
331
|
-
* -
|
|
337
|
+
* - 仅当 start_time 与 end_time 都是今天时,走本地;
|
|
338
|
+
* - 任意一端不是今天时,走云端,确保跨天查询能拉取非本地窗口数据。
|
|
332
339
|
*/
|
|
333
340
|
private shouldUseLocalOrderQuery;
|
|
334
341
|
/**
|
package/dist/server/index.js
CHANGED
|
@@ -3247,6 +3247,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
3247
3247
|
return text.split('T')[0].split(' ')[0] || null;
|
|
3248
3248
|
}
|
|
3249
3249
|
|
|
3250
|
+
/**
|
|
3251
|
+
* 判断时间范围是否完整落在今天。
|
|
3252
|
+
*
|
|
3253
|
+
* @example
|
|
3254
|
+
* this.isRangeFullyToday('2026-04-15', '2026-04-15') // => true
|
|
3255
|
+
*/
|
|
3256
|
+
}, {
|
|
3257
|
+
key: "isRangeFullyToday",
|
|
3258
|
+
value: function isRangeFullyToday(startRaw, endRaw) {
|
|
3259
|
+
var startDate = this.extractQueryDate(startRaw);
|
|
3260
|
+
var endDate = this.extractQueryDate(endRaw);
|
|
3261
|
+
if (!startDate || !endDate) return false;
|
|
3262
|
+
var today = dayjs().format('YYYY-MM-DD');
|
|
3263
|
+
return startDate === today && endDate === today;
|
|
3264
|
+
}
|
|
3265
|
+
|
|
3250
3266
|
/**
|
|
3251
3267
|
* 判断时间范围是否「开始和结束都不是今天」。
|
|
3252
3268
|
*
|
|
@@ -3265,13 +3281,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
3265
3281
|
|
|
3266
3282
|
/**
|
|
3267
3283
|
* 订单查询是否走本地:
|
|
3268
|
-
* -
|
|
3269
|
-
* -
|
|
3284
|
+
* - 仅当 start_time 与 end_time 都是今天时,走本地;
|
|
3285
|
+
* - 任意一端不是今天时,走云端,确保跨天查询能拉取非本地窗口数据。
|
|
3270
3286
|
*/
|
|
3271
3287
|
}, {
|
|
3272
3288
|
key: "shouldUseLocalOrderQuery",
|
|
3273
3289
|
value: function shouldUseLocalOrderQuery(data) {
|
|
3274
|
-
return
|
|
3290
|
+
return this.isRangeFullyToday(data === null || data === void 0 ? void 0 : data.start_time, data === null || data === void 0 ? void 0 : data.end_time);
|
|
3275
3291
|
}
|
|
3276
3292
|
|
|
3277
3293
|
/**
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 2 | 1 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
package/lib/core/index.js
CHANGED
|
@@ -136,6 +136,12 @@ function resolveProductTitle(product, booking, sourceProduct) {
|
|
|
136
136
|
const metadata = product.metadata || {};
|
|
137
137
|
return (sourceProduct == null ? void 0 : sourceProduct.title) ?? (sourceProduct == null ? void 0 : sourceProduct.name) ?? metadata.product_title ?? metadata.product_name ?? ((_a = booking == null ? void 0 : booking.product) == null ? void 0 : _a.title) ?? ((_b = booking == null ? void 0 : booking.detail) == null ? void 0 : _b.product_title) ?? "";
|
|
138
138
|
}
|
|
139
|
+
function resolveMainProductPrice(product, fallback) {
|
|
140
|
+
const metadata = product.metadata || {};
|
|
141
|
+
const value = metadata.main_product_original_price ?? metadata.source_product_price;
|
|
142
|
+
const parsed = Number(value);
|
|
143
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
144
|
+
}
|
|
139
145
|
function synthesizeProductResourceFromBooking(booking) {
|
|
140
146
|
const rows = booking == null ? void 0 : booking.resources;
|
|
141
147
|
if (!Array.isArray(rows) || rows.length === 0)
|
|
@@ -172,6 +178,7 @@ function buildCacheItemFromOrderLine(input) {
|
|
|
172
178
|
const resolvedId = product.product_id ?? (sourceProduct == null ? void 0 : sourceProduct.id);
|
|
173
179
|
const selling = Number(product.selling_price ?? 0);
|
|
174
180
|
const original = Number(product.original_price ?? selling);
|
|
181
|
+
const mainProductPrice = resolveMainProductPrice(product, selling);
|
|
175
182
|
const startDate = safeFormat(booking.start_date, "YYYY-MM-DD");
|
|
176
183
|
const endDate = safeFormat(booking.end_date, "YYYY-MM-DD");
|
|
177
184
|
const startTime = normalizeTimeString(booking.start_time);
|
|
@@ -198,7 +205,7 @@ function buildCacheItemFromOrderLine(input) {
|
|
|
198
205
|
quantity: product.num ?? 1,
|
|
199
206
|
product_name: productTitle,
|
|
200
207
|
note: product.note ?? ((_b = booking == null ? void 0 : booking.detail) == null ? void 0 : _b.note) ?? "",
|
|
201
|
-
price:
|
|
208
|
+
price: mainProductPrice,
|
|
202
209
|
total: selling,
|
|
203
210
|
origin_total: original,
|
|
204
211
|
resource,
|
|
@@ -431,7 +431,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
431
431
|
generateIdempotencyToken(): string;
|
|
432
432
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
433
433
|
createOrder(params: CommitOrderParams['query']): {
|
|
434
|
-
type: "
|
|
434
|
+
type: "appointment_booking" | "virtual";
|
|
435
435
|
platform: string;
|
|
436
436
|
sales_channel: string;
|
|
437
437
|
order_sales_channel: string;
|
|
@@ -168,6 +168,12 @@ export interface ProductData {
|
|
|
168
168
|
product_resource?: {
|
|
169
169
|
resources?: ProductResourceItem[];
|
|
170
170
|
};
|
|
171
|
+
/** 商品级持有人配置,resource_id 对应 holder 表单 id */
|
|
172
|
+
holder_config?: {
|
|
173
|
+
status?: string;
|
|
174
|
+
required?: number | string | boolean;
|
|
175
|
+
resource_id?: number | string | null;
|
|
176
|
+
};
|
|
171
177
|
/** 组合商品id,动态附加 */
|
|
172
178
|
product_variant_id?: number;
|
|
173
179
|
/** 套餐信息 */
|
package/lib/server/index.d.ts
CHANGED
|
@@ -318,6 +318,13 @@ declare class Server {
|
|
|
318
318
|
* this.extractQueryDate('2026-04-15 09:58:00') // => '2026-04-15'
|
|
319
319
|
*/
|
|
320
320
|
private extractQueryDate;
|
|
321
|
+
/**
|
|
322
|
+
* 判断时间范围是否完整落在今天。
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* this.isRangeFullyToday('2026-04-15', '2026-04-15') // => true
|
|
326
|
+
*/
|
|
327
|
+
private isRangeFullyToday;
|
|
321
328
|
/**
|
|
322
329
|
* 判断时间范围是否「开始和结束都不是今天」。
|
|
323
330
|
*
|
|
@@ -327,8 +334,8 @@ declare class Server {
|
|
|
327
334
|
private isRangeBothNotToday;
|
|
328
335
|
/**
|
|
329
336
|
* 订单查询是否走本地:
|
|
330
|
-
* -
|
|
331
|
-
* -
|
|
337
|
+
* - 仅当 start_time 与 end_time 都是今天时,走本地;
|
|
338
|
+
* - 任意一端不是今天时,走云端,确保跨天查询能拉取非本地窗口数据。
|
|
332
339
|
*/
|
|
333
340
|
private shouldUseLocalOrderQuery;
|
|
334
341
|
/**
|
package/lib/server/index.js
CHANGED
|
@@ -1988,6 +1988,20 @@ var Server = class {
|
|
|
1988
1988
|
return null;
|
|
1989
1989
|
return text.split("T")[0].split(" ")[0] || null;
|
|
1990
1990
|
}
|
|
1991
|
+
/**
|
|
1992
|
+
* 判断时间范围是否完整落在今天。
|
|
1993
|
+
*
|
|
1994
|
+
* @example
|
|
1995
|
+
* this.isRangeFullyToday('2026-04-15', '2026-04-15') // => true
|
|
1996
|
+
*/
|
|
1997
|
+
isRangeFullyToday(startRaw, endRaw) {
|
|
1998
|
+
const startDate = this.extractQueryDate(startRaw);
|
|
1999
|
+
const endDate = this.extractQueryDate(endRaw);
|
|
2000
|
+
if (!startDate || !endDate)
|
|
2001
|
+
return false;
|
|
2002
|
+
const today = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
2003
|
+
return startDate === today && endDate === today;
|
|
2004
|
+
}
|
|
1991
2005
|
/**
|
|
1992
2006
|
* 判断时间范围是否「开始和结束都不是今天」。
|
|
1993
2007
|
*
|
|
@@ -2004,11 +2018,11 @@ var Server = class {
|
|
|
2004
2018
|
}
|
|
2005
2019
|
/**
|
|
2006
2020
|
* 订单查询是否走本地:
|
|
2007
|
-
* -
|
|
2008
|
-
* -
|
|
2021
|
+
* - 仅当 start_time 与 end_time 都是今天时,走本地;
|
|
2022
|
+
* - 任意一端不是今天时,走云端,确保跨天查询能拉取非本地窗口数据。
|
|
2009
2023
|
*/
|
|
2010
2024
|
shouldUseLocalOrderQuery(data) {
|
|
2011
|
-
return
|
|
2025
|
+
return this.isRangeFullyToday(data == null ? void 0 : data.start_time, data == null ? void 0 : data.end_time);
|
|
2012
2026
|
}
|
|
2013
2027
|
/**
|
|
2014
2028
|
* 预约查询是否走本地:
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 2 | 1 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|