@pisell/pisellos 2.2.118 → 2.2.121
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 +8 -0
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.js +50 -11
- package/dist/server/modules/resource/index.js +15 -13
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Sales/index.js +2 -2
- package/lib/modules/Discount/types.d.ts +8 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.js +20 -6
- package/lib/server/modules/resource/index.js +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Sales/index.js +2 -2
- 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";
|
|
@@ -18,6 +18,14 @@ interface Formattitle {
|
|
|
18
18
|
interface PackageSubItemUsageRules {
|
|
19
19
|
type: 'universal_discount' | 'package_exclusive' | 'single_item_promo' | 'custom_usage_rules';
|
|
20
20
|
rules: ("original_price" | "markup_price")[];
|
|
21
|
+
package_scope?: {
|
|
22
|
+
type: 'all_packages' | 'specific_packages';
|
|
23
|
+
exclude_bundle_product_ids: number[];
|
|
24
|
+
include_bundle_product_ids: number[];
|
|
25
|
+
filter: 0 | 1;
|
|
26
|
+
rule: any[];
|
|
27
|
+
rule_type: 'and' | 'or';
|
|
28
|
+
};
|
|
21
29
|
}
|
|
22
30
|
interface Limitedrelationproductdata {
|
|
23
31
|
id: number;
|
|
@@ -23,7 +23,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
23
23
|
*/
|
|
24
24
|
private logError;
|
|
25
25
|
createOrder(params: CommitOrderParams['query']): {
|
|
26
|
-
type: "
|
|
26
|
+
type: "virtual" | "appointment_booking";
|
|
27
27
|
platform: string;
|
|
28
28
|
sales_channel: string;
|
|
29
29
|
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(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -1958,6 +1958,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1958
1958
|
return true;
|
|
1959
1959
|
}
|
|
1960
1960
|
var ruleType = usageRules.type;
|
|
1961
|
+
// 套餐适用范围配置
|
|
1962
|
+
var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
|
|
1963
|
+
var _ref13 = packageScope || {},
|
|
1964
|
+
scopeType = _ref13.type,
|
|
1965
|
+
_ref13$exclude_bundle = _ref13.exclude_bundle_product_ids,
|
|
1966
|
+
exclude_bundle_product_ids = _ref13$exclude_bundle === void 0 ? [] : _ref13$exclude_bundle,
|
|
1967
|
+
_ref13$include_bundle = _ref13.include_bundle_product_ids,
|
|
1968
|
+
include_bundle_product_ids = _ref13$include_bundle === void 0 ? [] : _ref13$include_bundle,
|
|
1969
|
+
_ref13$filter = _ref13.filter,
|
|
1970
|
+
filter = _ref13$filter === void 0 ? 0 : _ref13$filter;
|
|
1961
1971
|
var isMainProduct = flatItem.type === 'main'; // 单独购买
|
|
1962
1972
|
var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
|
|
1963
1973
|
|
|
@@ -1972,10 +1982,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1972
1982
|
return true; // 单独购买时可用
|
|
1973
1983
|
}
|
|
1974
1984
|
if (isBundleItem) {
|
|
1975
|
-
var _flatItem$bundleItem9, _flatItem$bundleItem10;
|
|
1985
|
+
var _flatItem$bundleItem9, _flatItem$bundleItem10, _flatItem$originProdu, _flatItem$originProdu2;
|
|
1976
1986
|
// 套餐中购买时,判断是否为原价
|
|
1977
1987
|
var priceType = (_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.price_type;
|
|
1978
1988
|
var priceTypeExt = (_flatItem$bundleItem10 = flatItem.bundleItem) === null || _flatItem$bundleItem10 === void 0 ? void 0 : _flatItem$bundleItem10.price_type_ext;
|
|
1989
|
+
// 主商品id
|
|
1990
|
+
var mainProductId = (flatItem === null || flatItem === void 0 || (_flatItem$originProdu = flatItem.originProduct) === null || _flatItem$originProdu === void 0 ? void 0 : _flatItem$originProdu.product_id) || (flatItem === null || flatItem === void 0 || (_flatItem$originProdu2 = flatItem.originProduct) === null || _flatItem$originProdu2 === void 0 ? void 0 : _flatItem$originProdu2.id);
|
|
1979
1991
|
// original_price 对应:
|
|
1980
1992
|
// 1. price_type: "markup" && price_type_ext: "product_price"
|
|
1981
1993
|
// markup_price 对应:
|
|
@@ -1987,16 +1999,43 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1987
1999
|
|
|
1988
2000
|
// 检查 rules
|
|
1989
2001
|
if (rules.length > 0) {
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
2002
|
+
var _isOriginalPrice = isOriginalPrice && rules.includes('original_price');
|
|
2003
|
+
var _isMarkupPrice = isMarkupPrice && rules.includes('markup_price');
|
|
2004
|
+
// 价格是否符合规则:原价或加价
|
|
2005
|
+
var isPriceValid = _isOriginalPrice || _isMarkupPrice;
|
|
2006
|
+
// 套餐适用范围校验
|
|
2007
|
+
var isScopeValid = false;
|
|
2008
|
+
|
|
2009
|
+
// 排除套餐判断
|
|
2010
|
+
if (scopeType === 'all_packages') {
|
|
2011
|
+
// 所有套餐可用
|
|
2012
|
+
if (!filter) {
|
|
2013
|
+
isScopeValid = true;
|
|
2014
|
+
} else {
|
|
2015
|
+
isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
|
|
2016
|
+
}
|
|
1993
2017
|
}
|
|
1994
2018
|
|
|
1995
|
-
//
|
|
1996
|
-
if (
|
|
2019
|
+
// 包含套餐判断
|
|
2020
|
+
if (scopeType === 'specific_packages') {
|
|
2021
|
+
isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
// 价格和套餐适用范围都符合,则可用
|
|
2025
|
+
if (isPriceValid && isScopeValid) {
|
|
1997
2026
|
return true;
|
|
1998
2027
|
}
|
|
1999
2028
|
|
|
2029
|
+
// 检查原价
|
|
2030
|
+
// if (isOriginalPrice && rules.includes('original_price')) {
|
|
2031
|
+
// return true;
|
|
2032
|
+
// }
|
|
2033
|
+
|
|
2034
|
+
// 检查加价
|
|
2035
|
+
// if (isMarkupPrice && rules.includes('markup_price')) {
|
|
2036
|
+
// return true;
|
|
2037
|
+
// }
|
|
2038
|
+
|
|
2000
2039
|
// 如果都不匹配,则不可用
|
|
2001
2040
|
return false;
|
|
2002
2041
|
}
|
|
@@ -2023,19 +2062,19 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2023
2062
|
// markup_price 对应:
|
|
2024
2063
|
// price_type: "markup" && price_type_ext: ""
|
|
2025
2064
|
/** 原价 */
|
|
2026
|
-
var
|
|
2065
|
+
var _isOriginalPrice2 = _priceType === 'markup' && _priceTypeExt === 'product_price';
|
|
2027
2066
|
/** 加价 */
|
|
2028
|
-
var
|
|
2067
|
+
var _isMarkupPrice2 = _priceType === 'markup' && (_priceTypeExt === '' || !_priceTypeExt);
|
|
2029
2068
|
|
|
2030
2069
|
// 检查 rules
|
|
2031
2070
|
if (rules.length > 0) {
|
|
2032
2071
|
// 检查原价
|
|
2033
|
-
if (
|
|
2072
|
+
if (_isOriginalPrice2 && rules.includes('original_price')) {
|
|
2034
2073
|
return true;
|
|
2035
2074
|
}
|
|
2036
2075
|
|
|
2037
2076
|
// 检查加价
|
|
2038
|
-
if (
|
|
2077
|
+
if (_isMarkupPrice2 && rules.includes('markup_price')) {
|
|
2039
2078
|
return true;
|
|
2040
2079
|
}
|
|
2041
2080
|
|
|
@@ -2044,7 +2083,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2044
2083
|
}
|
|
2045
2084
|
|
|
2046
2085
|
// 原价包括:price_type: "markup" && price_type_ext: "product_price"
|
|
2047
|
-
return
|
|
2086
|
+
return _isOriginalPrice2;
|
|
2048
2087
|
}
|
|
2049
2088
|
return false;
|
|
2050
2089
|
}
|
|
@@ -106,8 +106,7 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
106
106
|
this.logger = app.logger;
|
|
107
107
|
}
|
|
108
108
|
this.initResourceDataSource();
|
|
109
|
-
|
|
110
|
-
case 8:
|
|
109
|
+
case 7:
|
|
111
110
|
case "end":
|
|
112
111
|
return _context.stop();
|
|
113
112
|
}
|
|
@@ -150,38 +149,41 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
150
149
|
while (1) switch (_context2.prev = _context2.next) {
|
|
151
150
|
case 0:
|
|
152
151
|
_context2.next = 2;
|
|
153
|
-
return this.
|
|
152
|
+
return this.setupResourceSync();
|
|
154
153
|
case 2:
|
|
154
|
+
_context2.next = 4;
|
|
155
|
+
return this.loadResourcesFromSQLite();
|
|
156
|
+
case 4:
|
|
155
157
|
cachedResources = _context2.sent;
|
|
156
158
|
if (!(cachedResources.length > 0)) {
|
|
157
|
-
_context2.next =
|
|
159
|
+
_context2.next = 12;
|
|
158
160
|
break;
|
|
159
161
|
}
|
|
160
162
|
this.store.list = cloneDeep(cachedResources).map(function (item) {
|
|
161
163
|
return _this3.normalizeResource(item);
|
|
162
164
|
});
|
|
163
165
|
this.syncResourcesMap();
|
|
164
|
-
_context2.next =
|
|
166
|
+
_context2.next = 10;
|
|
165
167
|
return this.safeEmit(ResourceHooks.onResourcesChanged, this.store.list);
|
|
166
|
-
case 8:
|
|
167
|
-
_context2.next = 18;
|
|
168
|
-
break;
|
|
169
168
|
case 10:
|
|
170
|
-
_context2.next =
|
|
171
|
-
|
|
169
|
+
_context2.next = 20;
|
|
170
|
+
break;
|
|
172
171
|
case 12:
|
|
172
|
+
_context2.next = 14;
|
|
173
|
+
return this.loadResourcesByServer();
|
|
174
|
+
case 14:
|
|
173
175
|
resources = _context2.sent;
|
|
174
176
|
if (!(resources.length > 0)) {
|
|
175
|
-
_context2.next =
|
|
177
|
+
_context2.next = 20;
|
|
176
178
|
break;
|
|
177
179
|
}
|
|
178
180
|
this.store.list = cloneDeep(resources).map(function (item) {
|
|
179
181
|
return _this3.normalizeResource(item);
|
|
180
182
|
});
|
|
181
183
|
this.syncResourcesMap();
|
|
182
|
-
_context2.next =
|
|
184
|
+
_context2.next = 20;
|
|
183
185
|
return this.safeEmit(ResourceHooks.onResourcesChanged, this.store.list);
|
|
184
|
-
case
|
|
186
|
+
case 20:
|
|
185
187
|
case "end":
|
|
186
188
|
return _context2.stop();
|
|
187
189
|
}
|
|
@@ -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 客户状态
|
|
@@ -598,9 +598,9 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
598
598
|
title: 'getResourceBookingList',
|
|
599
599
|
metadata: {
|
|
600
600
|
currentTime: currentTime,
|
|
601
|
-
bookingList: bookingList,
|
|
601
|
+
bookingList: bookingList === null || bookingList === void 0 ? void 0 : bookingList.length,
|
|
602
602
|
deviceTime: deviceTime,
|
|
603
|
-
list: list
|
|
603
|
+
list: list === null || list === void 0 ? void 0 : list.length
|
|
604
604
|
}
|
|
605
605
|
});
|
|
606
606
|
return _context3.abrupt("return", list);
|
|
@@ -18,6 +18,14 @@ interface Formattitle {
|
|
|
18
18
|
interface PackageSubItemUsageRules {
|
|
19
19
|
type: 'universal_discount' | 'package_exclusive' | 'single_item_promo' | 'custom_usage_rules';
|
|
20
20
|
rules: ("original_price" | "markup_price")[];
|
|
21
|
+
package_scope?: {
|
|
22
|
+
type: 'all_packages' | 'specific_packages';
|
|
23
|
+
exclude_bundle_product_ids: number[];
|
|
24
|
+
include_bundle_product_ids: number[];
|
|
25
|
+
filter: 0 | 1;
|
|
26
|
+
rule: any[];
|
|
27
|
+
rule_type: 'and' | 'or';
|
|
28
|
+
};
|
|
21
29
|
}
|
|
22
30
|
interface Limitedrelationproductdata {
|
|
23
31
|
id: number;
|
|
@@ -23,7 +23,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
23
23
|
*/
|
|
24
24
|
private logError;
|
|
25
25
|
createOrder(params: CommitOrderParams['query']): {
|
|
26
|
-
type: "
|
|
26
|
+
type: "virtual" | "appointment_booking";
|
|
27
27
|
platform: string;
|
|
28
28
|
sales_channel: string;
|
|
29
29
|
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(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -1591,7 +1591,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1591
1591
|
* @returns 是否可用
|
|
1592
1592
|
*/
|
|
1593
1593
|
checkPackageSubItemUsageRules(discount, flatItem) {
|
|
1594
|
-
var _a, _b, _c, _d;
|
|
1594
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1595
1595
|
const limitedData = discount.limited_relation_product_data;
|
|
1596
1596
|
const usageRules = limitedData == null ? void 0 : limitedData.package_sub_item_usage_rules;
|
|
1597
1597
|
const rules = ["original_price", ...(usageRules == null ? void 0 : usageRules.rules) || []];
|
|
@@ -1599,6 +1599,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1599
1599
|
return true;
|
|
1600
1600
|
}
|
|
1601
1601
|
const ruleType = usageRules.type;
|
|
1602
|
+
const packageScope = usageRules == null ? void 0 : usageRules.package_scope;
|
|
1603
|
+
const { type: scopeType, exclude_bundle_product_ids = [], include_bundle_product_ids = [], filter = 0 } = packageScope || {};
|
|
1602
1604
|
const isMainProduct = flatItem.type === "main";
|
|
1603
1605
|
const isBundleItem = flatItem.type === "bundle";
|
|
1604
1606
|
if (isMainProduct) {
|
|
@@ -1611,13 +1613,25 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1611
1613
|
if (isBundleItem) {
|
|
1612
1614
|
const priceType = (_a = flatItem.bundleItem) == null ? void 0 : _a.price_type;
|
|
1613
1615
|
const priceTypeExt = (_b = flatItem.bundleItem) == null ? void 0 : _b.price_type_ext;
|
|
1616
|
+
const mainProductId = ((_c = flatItem == null ? void 0 : flatItem.originProduct) == null ? void 0 : _c.product_id) || ((_d = flatItem == null ? void 0 : flatItem.originProduct) == null ? void 0 : _d.id);
|
|
1614
1617
|
const isOriginalPrice = priceType === "markup" && priceTypeExt === "product_price";
|
|
1615
1618
|
const isMarkupPrice = priceType === "markup" && (priceTypeExt === "" || !priceTypeExt);
|
|
1616
1619
|
if (rules.length > 0) {
|
|
1617
|
-
|
|
1618
|
-
|
|
1620
|
+
const _isOriginalPrice = isOriginalPrice && rules.includes("original_price");
|
|
1621
|
+
const _isMarkupPrice = isMarkupPrice && rules.includes("markup_price");
|
|
1622
|
+
const isPriceValid = _isOriginalPrice || _isMarkupPrice;
|
|
1623
|
+
let isScopeValid = false;
|
|
1624
|
+
if (scopeType === "all_packages") {
|
|
1625
|
+
if (!filter) {
|
|
1626
|
+
isScopeValid = true;
|
|
1627
|
+
} else {
|
|
1628
|
+
isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
|
|
1629
|
+
}
|
|
1619
1630
|
}
|
|
1620
|
-
if (
|
|
1631
|
+
if (scopeType === "specific_packages") {
|
|
1632
|
+
isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
|
|
1633
|
+
}
|
|
1634
|
+
if (isPriceValid && isScopeValid) {
|
|
1621
1635
|
return true;
|
|
1622
1636
|
}
|
|
1623
1637
|
return false;
|
|
@@ -1631,8 +1645,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1631
1645
|
return false;
|
|
1632
1646
|
}
|
|
1633
1647
|
if (isBundleItem) {
|
|
1634
|
-
const priceType = (
|
|
1635
|
-
const priceTypeExt = (
|
|
1648
|
+
const priceType = (_e = flatItem.bundleItem) == null ? void 0 : _e.price_type;
|
|
1649
|
+
const priceTypeExt = (_f = flatItem.bundleItem) == null ? void 0 : _f.price_type_ext;
|
|
1636
1650
|
const isOriginalPrice = priceType === "markup" && priceTypeExt === "product_price";
|
|
1637
1651
|
const isMarkupPrice = priceType === "markup" && (priceTypeExt === "" || !priceTypeExt);
|
|
1638
1652
|
if (rules.length > 0) {
|
|
@@ -68,7 +68,6 @@ var ResourceModule = class extends import_BaseModule.BaseModule {
|
|
|
68
68
|
this.logger = app.logger;
|
|
69
69
|
}
|
|
70
70
|
this.initResourceDataSource();
|
|
71
|
-
this.setupResourceSync();
|
|
72
71
|
}
|
|
73
72
|
logInfo(title, metadata) {
|
|
74
73
|
if (this.logger) {
|
|
@@ -89,6 +88,7 @@ var ResourceModule = class extends import_BaseModule.BaseModule {
|
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
90
|
async preload() {
|
|
91
|
+
await this.setupResourceSync();
|
|
92
92
|
const cachedResources = await this.loadResourcesFromSQLite();
|
|
93
93
|
if (cachedResources.length > 0) {
|
|
94
94
|
this.store.list = (0, import_lodash_es.cloneDeep)(cachedResources).map((item) => this.normalizeResource(item));
|
|
@@ -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 客户状态
|
|
@@ -444,9 +444,9 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
444
444
|
title: "getResourceBookingList",
|
|
445
445
|
metadata: {
|
|
446
446
|
currentTime,
|
|
447
|
-
bookingList,
|
|
447
|
+
bookingList: bookingList == null ? void 0 : bookingList.length,
|
|
448
448
|
deviceTime,
|
|
449
|
-
list
|
|
449
|
+
list: list == null ? void 0 : list.length
|
|
450
450
|
}
|
|
451
451
|
});
|
|
452
452
|
return list;
|