@pisell/pisellos 2.2.256 → 2.2.257
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/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Product/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/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Product/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/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -5
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 导出评估器
|
|
2
|
+
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
+
|
|
4
|
+
// 导出适配器
|
|
5
|
+
export { PromotionAdapter } from "./adapter";
|
|
6
|
+
export { default } from "./adapter";
|
|
7
|
+
|
|
8
|
+
// 导出策略配置示例常量
|
|
9
|
+
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
|
|
@@ -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: "virtual" | "appointment_booking";
|
|
435
435
|
platform: string;
|
|
436
436
|
sales_channel: string;
|
|
437
437
|
order_sales_channel: string;
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -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
|
/**
|
|
@@ -105,7 +105,9 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
105
105
|
var origin = _objectSpread(_objectSpread({}, sourceProduct || {}), callbackOrigin || {});
|
|
106
106
|
var matchedVariant = (_ref15 = (_findVariantById = findVariantById(callbackOrigin, productVariantId)) !== null && _findVariantById !== void 0 ? _findVariantById : findVariantById(sourceProduct, productVariantId)) !== null && _ref15 !== void 0 ? _ref15 : findVariantById(origin, productVariantId);
|
|
107
107
|
var sourceProductPrice = toPriceString((_ref16 = (_ref17 = (_ref18 = (_ref19 = (_ref20 = (_ref21 = (_ref22 = (_payload$price = payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload.selling_price) !== null && _ref22 !== void 0 ? _ref22 : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.price) !== null && _ref21 !== void 0 ? _ref21 : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.base_price) !== null && _ref20 !== void 0 ? _ref20 : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref19 !== void 0 ? _ref19 : origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _ref18 !== void 0 ? _ref18 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _ref17 !== void 0 ? _ref17 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.selling_price) !== null && _ref16 !== void 0 ? _ref16 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price, '0.00');
|
|
108
|
-
var
|
|
108
|
+
var explicitLineTotal = (_ref23 = (_payload$line_total = payload.line_total) !== null && _payload$line_total !== void 0 ? _payload$line_total : payload.total) !== null && _ref23 !== void 0 ? _ref23 : (_payload$_extend = payload._extend) === null || _payload$_extend === void 0 ? void 0 : _payload$_extend.total;
|
|
109
|
+
var hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
|
|
110
|
+
var lineCompositeTotal = toPriceString(explicitLineTotal, sourceProductPrice);
|
|
109
111
|
var hasPriceOverride = payload.price_override !== undefined && payload.price_override !== null && payload.price_override !== '';
|
|
110
112
|
var productOptionItem = normalizeProductSkuOptions(normalizeOptionItems((_ref24 = (_ref25 = (_payload$product_sku$ = (_payload$product_sku = payload.product_sku) === null || _payload$product_sku === void 0 ? void 0 : _payload$product_sku.option) !== null && _payload$product_sku$ !== void 0 ? _payload$product_sku$ : payload.option) !== null && _ref25 !== void 0 ? _ref25 : payload.options) !== null && _ref24 !== void 0 ? _ref24 : payload.product_option_item));
|
|
111
113
|
var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle, hasPriceOverride);
|
|
@@ -148,7 +150,7 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
148
150
|
mainPrice: 0,
|
|
149
151
|
bundle: productBundle
|
|
150
152
|
});
|
|
151
|
-
var derivedMainSelling = Number(lineCompositeTotal) - Number(bundleOnlyComposite);
|
|
153
|
+
var derivedMainSelling = hasExplicitLineTotal ? Number(lineCompositeTotal) - Number(bundleOnlyComposite) : Number(mainProductOriginalPrice);
|
|
152
154
|
var mainProductSellingPrice = toPriceString(Number.isFinite(derivedMainSelling) && derivedMainSelling >= 0 ? derivedMainSelling : Number(mainProductOriginalPrice));
|
|
153
155
|
var metadata = _objectSpread(_objectSpread({
|
|
154
156
|
unique: payload.unique,
|
|
@@ -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 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -0,0 +1,49 @@
|
|
|
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/model/strategy/adapter/promotion/index.ts
|
|
30
|
+
var promotion_exports = {};
|
|
31
|
+
__export(promotion_exports, {
|
|
32
|
+
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
+
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
+
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
+
default: () => import_adapter2.default
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
+
var import_evaluator = require("./evaluator");
|
|
40
|
+
var import_adapter = require("./adapter");
|
|
41
|
+
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
+
var import_examples = require("./examples");
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
+
PromotionAdapter,
|
|
47
|
+
PromotionEvaluator,
|
|
48
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
+
});
|
|
@@ -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: "virtual" | "appointment_booking";
|
|
435
435
|
platform: string;
|
|
436
436
|
sales_channel: string;
|
|
437
437
|
order_sales_channel: string;
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -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
|
* 预约查询是否走本地:
|
|
@@ -129,10 +129,9 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
129
129
|
payload.price ?? payload.selling_price ?? (matchedVariant == null ? void 0 : matchedVariant.price) ?? (matchedVariant == null ? void 0 : matchedVariant.base_price) ?? (origin == null ? void 0 : origin.price) ?? (origin == null ? void 0 : origin.base_price) ?? (sourceProduct == null ? void 0 : sourceProduct.price) ?? (sourceProduct == null ? void 0 : sourceProduct.selling_price) ?? (sourceProduct == null ? void 0 : sourceProduct.base_price),
|
|
130
130
|
"0.00"
|
|
131
131
|
);
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
);
|
|
132
|
+
const explicitLineTotal = payload.line_total ?? payload.total ?? ((_c = payload._extend) == null ? void 0 : _c.total);
|
|
133
|
+
const hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
|
|
134
|
+
const lineCompositeTotal = toPriceString(explicitLineTotal, sourceProductPrice);
|
|
136
135
|
const hasPriceOverride = payload.price_override !== void 0 && payload.price_override !== null && payload.price_override !== "";
|
|
137
136
|
const productOptionItem = (0, import_utils.normalizeProductSkuOptions)(
|
|
138
137
|
normalizeOptionItems(
|
|
@@ -180,7 +179,7 @@ function transformBaseProductToOrderProduct(params) {
|
|
|
180
179
|
const optionSum = (0, import_utils.sumOptionUnitPrice)(productOptionItem).toNumber();
|
|
181
180
|
const mainProductOriginalPrice = toPriceString(Number(sourceProductPrice) + optionSum);
|
|
182
181
|
const bundleOnlyComposite = (0, import_utils.composeLinePrice)({ mainPrice: 0, bundle: productBundle });
|
|
183
|
-
const derivedMainSelling = Number(lineCompositeTotal) - Number(bundleOnlyComposite);
|
|
182
|
+
const derivedMainSelling = hasExplicitLineTotal ? Number(lineCompositeTotal) - Number(bundleOnlyComposite) : Number(mainProductOriginalPrice);
|
|
184
183
|
const mainProductSellingPrice = toPriceString(
|
|
185
184
|
Number.isFinite(derivedMainSelling) && derivedMainSelling >= 0 ? derivedMainSelling : Number(mainProductOriginalPrice)
|
|
186
185
|
);
|
|
@@ -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 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|