@pisell/pisellos 2.3.3 → 2.3.4
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 +0 -9
- 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/solution/BookingByStep/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- 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/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,9 +0,0 @@
|
|
|
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";
|
|
@@ -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
|
/** 套餐信息 */
|
|
@@ -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;
|
|
@@ -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
|
+
});
|
|
@@ -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
|
/** 套餐信息 */
|
|
@@ -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;
|