@pisell/pisellos 2.2.130 → 2.2.132
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/Discount/types.d.ts +1 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.js +4 -4
- package/dist/server/index.d.ts +5 -0
- package/dist/server/index.js +529 -414
- package/dist/server/modules/order/types.d.ts +1 -0
- package/dist/server/modules/order/utils/filterOrders.js +6 -0
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Discount/types.d.ts +1 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.js +2 -2
- package/lib/server/index.d.ts +5 -0
- package/lib/server/index.js +78 -1
- package/lib/server/modules/order/types.d.ts +1 -0
- package/lib/server/modules/order/utils/filterOrders.js +5 -0
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -28,6 +28,12 @@ export function filterOrders(orders, filters) {
|
|
|
28
28
|
|
|
29
29
|
// 1. 过滤
|
|
30
30
|
var filteredList = orders.filter(function (order) {
|
|
31
|
+
if (safeFilters.keyword) {
|
|
32
|
+
if (!JSON.stringify(order).toLowerCase().includes(safeFilters.keyword.toLowerCase())) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
31
37
|
// status - 订单状态
|
|
32
38
|
if (safeFilters.status && safeFilters.status.length > 0) {
|
|
33
39
|
if (!order.status || !safeFilters.status.includes(order.status)) {
|
|
@@ -136,7 +136,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
136
136
|
* 获取当前的客户搜索条件
|
|
137
137
|
* @returns 当前搜索条件
|
|
138
138
|
*/
|
|
139
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
139
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
140
140
|
/**
|
|
141
141
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
142
142
|
* @returns 客户状态
|
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -19,7 +19,7 @@ interface PackageSubItemUsageRules {
|
|
|
19
19
|
type: 'universal_discount' | 'package_exclusive' | 'single_item_promo' | 'custom_usage_rules';
|
|
20
20
|
rules: ("original_price" | "markup_price")[];
|
|
21
21
|
package_scope?: {
|
|
22
|
-
type: 'all_packages' | 'specific_packages';
|
|
22
|
+
type: 'all_packages' | 'specific_packages' | 'product_all' | 'products';
|
|
23
23
|
exclude_bundle_product_ids: number[];
|
|
24
24
|
include_bundle_product_ids: number[];
|
|
25
25
|
filter: 0 | 1;
|
|
@@ -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(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -1621,14 +1621,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1621
1621
|
const _isMarkupPrice = isMarkupPrice && rules.includes("markup_price");
|
|
1622
1622
|
const isPriceValid = _isOriginalPrice || _isMarkupPrice;
|
|
1623
1623
|
let isScopeValid = false;
|
|
1624
|
-
if (scopeType === "all_packages") {
|
|
1624
|
+
if (scopeType === "all_packages" || scopeType === "product_all") {
|
|
1625
1625
|
if (!filter) {
|
|
1626
1626
|
isScopeValid = true;
|
|
1627
1627
|
} else {
|
|
1628
1628
|
isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
|
|
1629
1629
|
}
|
|
1630
1630
|
}
|
|
1631
|
-
if (scopeType === "specific_packages") {
|
|
1631
|
+
if (scopeType === "specific_packages" || scopeType === "products") {
|
|
1632
1632
|
isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
|
|
1633
1633
|
}
|
|
1634
1634
|
if (isPriceValid && isScopeValid) {
|
package/lib/server/index.d.ts
CHANGED
|
@@ -166,6 +166,11 @@ declare class Server {
|
|
|
166
166
|
* 存储订阅者信息,便于数据变更时推送最新结果
|
|
167
167
|
*/
|
|
168
168
|
private handleProductQuery;
|
|
169
|
+
/**
|
|
170
|
+
* 按商品 id 查询单条(GET /shop/product/query/:productId)
|
|
171
|
+
* schedule_date 必填:query 或 data;schedule_datetime 可选。不走订阅。
|
|
172
|
+
*/
|
|
173
|
+
private handleProductQueryById;
|
|
169
174
|
/**
|
|
170
175
|
* 取消商品查询订阅(HTTP 路由入口)
|
|
171
176
|
*/
|
package/lib/server/index.js
CHANGED
|
@@ -168,6 +168,49 @@ var Server = class {
|
|
|
168
168
|
}
|
|
169
169
|
return this.computeProductQueryResult({ menu_list_ids, schedule_date, schedule_datetime });
|
|
170
170
|
};
|
|
171
|
+
/**
|
|
172
|
+
* 按商品 id 查询单条(GET /shop/product/query/:productId)
|
|
173
|
+
* schedule_date 必填:query 或 data;schedule_datetime 可选。不走订阅。
|
|
174
|
+
*/
|
|
175
|
+
this.handleProductQueryById = async ({ path, method, data, url }) => {
|
|
176
|
+
const pathname = this.parseRequestPath(url || "", path);
|
|
177
|
+
const idMatch = pathname.match(/^\/shop\/product\/query\/(\d+)$/);
|
|
178
|
+
const productId = idMatch ? Number(idMatch[1]) : NaN;
|
|
179
|
+
console.log("[Server] handleProductQueryById:", pathname, method, data);
|
|
180
|
+
if (!Number.isFinite(productId)) {
|
|
181
|
+
this.logWarning("handleProductQueryById: 无效的商品 id", { path: pathname });
|
|
182
|
+
return {
|
|
183
|
+
code: 400,
|
|
184
|
+
message: "无效的商品路径",
|
|
185
|
+
status: false,
|
|
186
|
+
data: { item: null }
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
const scheduleDateFromData = data && typeof data === "object" && typeof data.schedule_date === "string" ? data.schedule_date.trim() : "";
|
|
190
|
+
const schedule_date = scheduleDateFromData || (this.extractQueryParam(url || "", "schedule_date") || "").trim() || (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
191
|
+
if (!schedule_date) {
|
|
192
|
+
this.logWarning("handleProductQueryById: 缺少 schedule_date", { productId });
|
|
193
|
+
return {
|
|
194
|
+
code: 400,
|
|
195
|
+
message: "schedule_date 为必填(query 或 data)",
|
|
196
|
+
status: false,
|
|
197
|
+
data: null
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
const scheduleDtFromData = data && typeof data === "object" && typeof data.schedule_datetime === "string" ? data.schedule_datetime.trim() : "";
|
|
201
|
+
const scheduleDtFromUrl = (this.extractQueryParam(url || "", "schedule_datetime") || "").trim();
|
|
202
|
+
const scheduleDatetime = scheduleDtFromData || scheduleDtFromUrl || `${schedule_date}T00:00:00`;
|
|
203
|
+
this.logInfo("handleProductQueryById: 开始", {
|
|
204
|
+
productId,
|
|
205
|
+
schedule_date,
|
|
206
|
+
schedule_datetime: scheduleDatetime
|
|
207
|
+
});
|
|
208
|
+
return this.computeProductQueryResult({
|
|
209
|
+
schedule_date,
|
|
210
|
+
schedule_datetime: scheduleDatetime,
|
|
211
|
+
product_id: productId
|
|
212
|
+
});
|
|
213
|
+
};
|
|
171
214
|
/**
|
|
172
215
|
* 取消商品查询订阅(HTTP 路由入口)
|
|
173
216
|
*/
|
|
@@ -920,6 +963,9 @@ var Server = class {
|
|
|
920
963
|
if (exact) {
|
|
921
964
|
return exact;
|
|
922
965
|
}
|
|
966
|
+
if (method === "get" && /^\/shop\/product\/query\/\d+$/.test(path)) {
|
|
967
|
+
return this.handleProductQueryById;
|
|
968
|
+
}
|
|
923
969
|
if (method === "get" && this.prefixRouterGet.length > 0) {
|
|
924
970
|
for (const { prefix, handler } of this.prefixRouterGet) {
|
|
925
971
|
if (path === prefix || path.startsWith(`${prefix}/`)) {
|
|
@@ -1712,17 +1758,48 @@ var Server = class {
|
|
|
1712
1758
|
*/
|
|
1713
1759
|
async computeProductQueryResult(context, options) {
|
|
1714
1760
|
const tTotal = performance.now();
|
|
1715
|
-
const { menu_list_ids, schedule_date, schedule_datetime } = context;
|
|
1761
|
+
const { menu_list_ids, schedule_date, schedule_datetime, product_id } = context;
|
|
1716
1762
|
this.logInfo("computeProductQueryResult 开始", {
|
|
1717
1763
|
menuListIdsCount: (menu_list_ids == null ? void 0 : menu_list_ids.length) ?? 0,
|
|
1718
1764
|
schedule_datetime,
|
|
1719
1765
|
schedule_date,
|
|
1766
|
+
product_id,
|
|
1720
1767
|
changedIds: options == null ? void 0 : options.changedIds
|
|
1721
1768
|
});
|
|
1722
1769
|
if (!this.products) {
|
|
1723
1770
|
this.logError("computeProductQueryResult: Products 模块未注册");
|
|
1724
1771
|
return { message: "Products 模块未注册", data: { list: [], count: 0 } };
|
|
1725
1772
|
}
|
|
1773
|
+
if (product_id != null && Number.isFinite(Number(product_id))) {
|
|
1774
|
+
const pid = Number(product_id);
|
|
1775
|
+
const tPrice2 = performance.now();
|
|
1776
|
+
const allProductsWithPrice2 = await this.products.getProductsWithPrice(schedule_date, {
|
|
1777
|
+
scheduleModule: this.getSchedule()
|
|
1778
|
+
}, {
|
|
1779
|
+
changedIds: options == null ? void 0 : options.changedIds
|
|
1780
|
+
});
|
|
1781
|
+
(0, import_product.perfMark)("computeQuery.getProductsWithPrice(single)", performance.now() - tPrice2, {
|
|
1782
|
+
count: allProductsWithPrice2.length,
|
|
1783
|
+
productId: pid
|
|
1784
|
+
});
|
|
1785
|
+
const published = allProductsWithPrice2.filter((p) => ((p == null ? void 0 : p.status) || "published") === "published");
|
|
1786
|
+
const item = published.find((p) => Number(p.id) === pid) ?? null;
|
|
1787
|
+
(0, import_product.perfMark)("computeProductQueryResult", performance.now() - tTotal, {
|
|
1788
|
+
mode: "single",
|
|
1789
|
+
productId: pid,
|
|
1790
|
+
found: !!item
|
|
1791
|
+
});
|
|
1792
|
+
this.logInfo("computeProductQueryResult 完成(单商品)", {
|
|
1793
|
+
productId: pid,
|
|
1794
|
+
found: !!item
|
|
1795
|
+
});
|
|
1796
|
+
return {
|
|
1797
|
+
code: 200,
|
|
1798
|
+
data: item,
|
|
1799
|
+
message: item ? "" : "商品不存在或未发布",
|
|
1800
|
+
status: true
|
|
1801
|
+
};
|
|
1802
|
+
}
|
|
1726
1803
|
if (!this.menu) {
|
|
1727
1804
|
this.logError("computeProductQueryResult: Menu 模块未注册");
|
|
1728
1805
|
return { message: "Menu 模块未注册", data: { list: [], count: 0 } };
|
|
@@ -35,6 +35,11 @@ function filterOrders(orders, filters) {
|
|
|
35
35
|
const size = safeFilters.num || 20;
|
|
36
36
|
const page = safeFilters.skip || 1;
|
|
37
37
|
let filteredList = orders.filter((order) => {
|
|
38
|
+
if (safeFilters.keyword) {
|
|
39
|
+
if (!JSON.stringify(order).toLowerCase().includes(safeFilters.keyword.toLowerCase())) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
38
43
|
if (safeFilters.status && safeFilters.status.length > 0) {
|
|
39
44
|
if (!order.status || !safeFilters.status.includes(order.status)) {
|
|
40
45
|
return false;
|
|
@@ -136,7 +136,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
136
136
|
* 获取当前的客户搜索条件
|
|
137
137
|
* @returns 当前搜索条件
|
|
138
138
|
*/
|
|
139
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
139
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
140
140
|
/**
|
|
141
141
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
142
142
|
* @returns 客户状态
|