@pisell/pisellos 0.0.373 → 0.0.376
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/effects/index.d.ts +2 -2
- package/dist/model/strategy/adapter/walletPass/utils.js +7 -2
- package/dist/model/strategy/type.d.ts +1 -1
- package/dist/modules/Customer/types.d.ts +1 -1
- package/dist/modules/Payment/index.js +35 -7
- package/dist/modules/Payment/types.d.ts +9 -7
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/types.d.ts +1 -1
- package/dist/modules/Schedule/type.d.ts +7 -7
- package/dist/modules/Schedule/types.d.ts +9 -9
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/dist/solution/Checkout/index.js +31 -2
- package/dist/solution/Checkout/types.d.ts +2 -0
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/solution/ShopDiscount/utils.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/task.d.ts +2 -2
- package/dist/utils/watch.d.ts +2 -2
- package/lib/core/index.js +28 -27
- package/lib/effects/index.d.ts +2 -2
- package/lib/effects/index.js +7 -3
- package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -3
- package/lib/model/strategy/adapter/walletPass/example.js +21 -21
- package/lib/model/strategy/adapter/walletPass/index.js +4 -2
- package/lib/model/strategy/adapter/walletPass/locales.js +10 -10
- package/lib/model/strategy/adapter/walletPass/utils.js +9 -4
- package/lib/model/strategy/index.js +10 -7
- package/lib/model/strategy/strategy-example.js +19 -19
- package/lib/model/strategy/type.d.ts +1 -1
- package/lib/modules/Account/index.js +10 -9
- package/lib/modules/AccountList/index.js +11 -14
- package/lib/modules/BaseModule.js +3 -6
- package/lib/modules/Cart/index.js +9 -14
- package/lib/modules/Cart/utils/cartProduct.js +6 -3
- package/lib/modules/Customer/constants.js +1 -1
- package/lib/modules/Customer/index.js +15 -18
- package/lib/modules/Customer/types.d.ts +1 -1
- package/lib/modules/Date/index.js +6 -10
- package/lib/modules/Date/types.js +0 -1
- package/lib/modules/Discount/index.js +6 -11
- package/lib/modules/Guests/index.js +15 -10
- package/lib/modules/Order/index.js +9 -11
- package/lib/modules/Payment/cash.js +1 -1
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
- package/lib/modules/Payment/eftpos.js +1 -1
- package/lib/modules/Payment/index.js +94 -86
- package/lib/modules/Payment/types.d.ts +9 -7
- package/lib/modules/Payment/utils.js +6 -3
- package/lib/modules/Payment/walletpass.js +33 -33
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/index.js +5 -6
- package/lib/modules/ProductList/index.js +3 -5
- package/lib/modules/Resource/index.js +12 -8
- package/lib/modules/Rules/index.js +21 -16
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/index.js +5 -8
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +9 -9
- package/lib/modules/Schedule/utils.js +4 -2
- package/lib/modules/Step/index.js +4 -7
- package/lib/modules/Summary/index.js +4 -9
- package/lib/plugins/request.js +33 -34
- package/lib/plugins/window.js +113 -101
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingByStep/index.js +129 -86
- package/lib/solution/BookingByStep/utils/capacity.js +15 -10
- package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +8 -4
- package/lib/solution/BookingByStep/utils/stock.js +6 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +27 -24
- package/lib/solution/BookingTicket/index.js +14 -19
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
- package/lib/solution/BookingTicket/utils/scan/index.js +1 -3
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +9 -10
- package/lib/solution/BuyTickets/index.js +15 -15
- package/lib/solution/Checkout/index.js +233 -217
- package/lib/solution/Checkout/types.d.ts +2 -0
- package/lib/solution/Checkout/utils/index.js +22 -18
- package/lib/solution/RegisterAndLogin/config.js +2 -2
- package/lib/solution/RegisterAndLogin/index.js +110 -114
- package/lib/solution/RegisterAndLogin/utils.js +9 -9
- package/lib/solution/ShopDiscount/index.js +13 -16
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.d.ts +2 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/utils/task.d.ts +2 -2
- package/lib/utils/task.js +3 -3
- package/lib/utils/watch.d.ts +2 -2
- package/lib/utils/watch.js +7 -5
- package/package.json +18 -17
|
@@ -37,10 +37,9 @@ var import_utils = require("./utils");
|
|
|
37
37
|
var import_locales = require("./locales");
|
|
38
38
|
var import_decimal = __toESM(require("decimal.js"));
|
|
39
39
|
var WalletPassEvaluator = class {
|
|
40
|
-
engine;
|
|
41
|
-
strategyConfigs = [];
|
|
42
|
-
locale = "en";
|
|
43
40
|
constructor() {
|
|
41
|
+
this.strategyConfigs = [];
|
|
42
|
+
this.locale = "en";
|
|
44
43
|
this.engine = new import__.StrategyEngine({
|
|
45
44
|
debug: false,
|
|
46
45
|
enableTrace: false
|
|
@@ -5,13 +5,13 @@ var products = [
|
|
|
5
5
|
product_id: 60734,
|
|
6
6
|
price: 80,
|
|
7
7
|
quantity: 1,
|
|
8
|
-
name: "
|
|
8
|
+
name: "商品A"
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
product_id: 60735,
|
|
12
12
|
price: 50,
|
|
13
13
|
quantity: 2,
|
|
14
|
-
name: "
|
|
14
|
+
name: "商品B"
|
|
15
15
|
}
|
|
16
16
|
];
|
|
17
17
|
var vouchers = [
|
|
@@ -39,7 +39,7 @@ var strategyConfigs = [
|
|
|
39
39
|
{
|
|
40
40
|
metadata: {
|
|
41
41
|
id: "STRATEGY_001",
|
|
42
|
-
name: "
|
|
42
|
+
name: "满100减10",
|
|
43
43
|
type: "wallet_pass",
|
|
44
44
|
custom: {
|
|
45
45
|
maxDeductionAmount: 10,
|
|
@@ -86,7 +86,7 @@ var strategyConfigs = [
|
|
|
86
86
|
{
|
|
87
87
|
metadata: {
|
|
88
88
|
id: "STRATEGY_002",
|
|
89
|
-
name: "
|
|
89
|
+
name: "满150减20",
|
|
90
90
|
type: "wallet_pass",
|
|
91
91
|
custom: {
|
|
92
92
|
maxDeductionAmount: 20,
|
|
@@ -127,7 +127,7 @@ var strategyConfigs = [
|
|
|
127
127
|
{
|
|
128
128
|
metadata: {
|
|
129
129
|
id: "STRATEGY_003",
|
|
130
|
-
name: "
|
|
130
|
+
name: "满200减50",
|
|
131
131
|
type: "wallet_pass",
|
|
132
132
|
custom: {
|
|
133
133
|
maxDeductionAmount: 50,
|
|
@@ -166,7 +166,7 @@ var strategyConfigs = [
|
|
|
166
166
|
}
|
|
167
167
|
];
|
|
168
168
|
function runExample() {
|
|
169
|
-
console.log("========== WalletPass
|
|
169
|
+
console.log("========== WalletPass 评估器示例 ==========\n");
|
|
170
170
|
const evaluator = new import_evaluator.WalletPassEvaluator();
|
|
171
171
|
const results = evaluator.evaluate({
|
|
172
172
|
orderTotalAmount: 180,
|
|
@@ -174,33 +174,33 @@ function runExample() {
|
|
|
174
174
|
vouchers,
|
|
175
175
|
strategyConfigs
|
|
176
176
|
});
|
|
177
|
-
console.log("
|
|
178
|
-
console.log(`-
|
|
179
|
-
console.log(`-
|
|
177
|
+
console.log("订单信息:");
|
|
178
|
+
console.log(`- 总金额: ${180} 元`);
|
|
179
|
+
console.log(`- 商品: ${products.map((p) => `${p.name}(${p.quantity}件)`).join(", ")}
|
|
180
180
|
`);
|
|
181
|
-
console.log("
|
|
181
|
+
console.log("评估结果:\n");
|
|
182
182
|
results.forEach((result, index) => {
|
|
183
183
|
console.log(`Voucher ${index + 1}: ${result.voucher.id}`);
|
|
184
|
-
console.log(`
|
|
185
|
-
console.log(`
|
|
184
|
+
console.log(` 面额: ${result.voucher.amount} 元`);
|
|
185
|
+
console.log(` 可用: ${result.isApplicable ? "✅ 是" : "❌ 否"}`);
|
|
186
186
|
if (result.isApplicable) {
|
|
187
|
-
console.log(`
|
|
188
|
-
console.log(`
|
|
189
|
-
console.log(`
|
|
190
|
-
console.log(`
|
|
187
|
+
console.log(` 最大抵扣: ${result.maxDeduction} 元`);
|
|
188
|
+
console.log(` 每单可用: ${result.canUseCount} 张`);
|
|
189
|
+
console.log(` 抵扣税费: ${result.deductTaxAndFee ? "是" : "否"}`);
|
|
190
|
+
console.log(` 适用商品: ${result.applicableProductIds.join(", ")}`);
|
|
191
191
|
} else {
|
|
192
|
-
console.log(`
|
|
193
|
-
console.log(`
|
|
192
|
+
console.log(` 原因: ${result.reason}`);
|
|
193
|
+
console.log(` 原因码: ${result.reasonCode}`);
|
|
194
194
|
}
|
|
195
195
|
console.log("");
|
|
196
196
|
});
|
|
197
197
|
const availableVouchers = results.filter((r) => r.isApplicable);
|
|
198
198
|
console.log(`
|
|
199
|
-
|
|
199
|
+
共 ${availableVouchers.length} 张可用`);
|
|
200
200
|
if (availableVouchers.length > 0) {
|
|
201
|
-
console.log("
|
|
201
|
+
console.log("可用 voucher ID:");
|
|
202
202
|
availableVouchers.forEach((v) => {
|
|
203
|
-
console.log(` - ${v.voucher.id}:
|
|
203
|
+
console.log(` - ${v.voucher.id}: 最多抵扣 ${v.maxDeduction} 元`);
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
}
|
|
@@ -24,8 +24,10 @@ __export(walletPass_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(walletPass_exports);
|
|
25
25
|
var import_utils = require("./utils");
|
|
26
26
|
var WalletPassAdapter = class {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
constructor() {
|
|
28
|
+
this.name = "WalletPassAdapter";
|
|
29
|
+
this.version = "1.0.0";
|
|
30
|
+
}
|
|
29
31
|
/**
|
|
30
32
|
* 准备运行时上下文
|
|
31
33
|
* 将业务数据转换为策略引擎可识别的 RuntimeContext
|
|
@@ -24,11 +24,11 @@ __export(locales_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(locales_exports);
|
|
25
25
|
var locales = {
|
|
26
26
|
"zh-CN": {
|
|
27
|
-
"not_meet_the_required_conditions": "
|
|
28
|
-
"exceeds_the_maximum_deduction_limit": "
|
|
29
|
-
"usage_limit_reached": "
|
|
30
|
-
"not_available_for_this_channel": "
|
|
31
|
-
"not_valid_for_this_order_type": "
|
|
27
|
+
"not_meet_the_required_conditions": "未达到使用条件",
|
|
28
|
+
"exceeds_the_maximum_deduction_limit": "超出最大抵扣金额限制",
|
|
29
|
+
"usage_limit_reached": "已达到使用次数上限",
|
|
30
|
+
"not_available_for_this_channel": "当前渠道不可使用",
|
|
31
|
+
"not_valid_for_this_order_type": "当前订单类型不适用"
|
|
32
32
|
},
|
|
33
33
|
"en": {
|
|
34
34
|
"not_meet_the_required_conditions": "Not meet the required conditions.",
|
|
@@ -38,11 +38,11 @@ var locales = {
|
|
|
38
38
|
"not_valid_for_this_order_type": "Not valid for this order type."
|
|
39
39
|
},
|
|
40
40
|
"zh-HK": {
|
|
41
|
-
"not_meet_the_required_conditions": "
|
|
42
|
-
"exceeds_the_maximum_deduction_limit": "
|
|
43
|
-
"usage_limit_reached": "
|
|
44
|
-
"not_available_for_this_channel": "
|
|
45
|
-
"not_valid_for_this_order_type": "
|
|
41
|
+
"not_meet_the_required_conditions": "未達使用條件",
|
|
42
|
+
"exceeds_the_maximum_deduction_limit": "超出最大抵扣金額限制",
|
|
43
|
+
"usage_limit_reached": "已達使用次數上限",
|
|
44
|
+
"not_available_for_this_channel": "當前渠道不可使用",
|
|
45
|
+
"not_valid_for_this_order_type": "當前訂單類型不適用"
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -182,7 +182,8 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
|
|
|
182
182
|
voucher,
|
|
183
183
|
productsForRecommendation
|
|
184
184
|
).filter((p) => p[amountField].greaterThan(0));
|
|
185
|
-
if (applicableProducts.length === 0)
|
|
185
|
+
if (applicableProducts.length === 0)
|
|
186
|
+
return false;
|
|
186
187
|
if (allowCrossProduct && applicableProductLimit > 0) {
|
|
187
188
|
applicableProducts = applicableProducts.sort((a, b) => a[amountField].comparedTo(b[amountField]) > 0 ? -1 : 1).slice(0, applicableProductLimit);
|
|
188
189
|
}
|
|
@@ -219,7 +220,8 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
|
|
|
219
220
|
(a, b) => a[amountField].comparedTo(b[amountField]) > 0 ? -1 : 1
|
|
220
221
|
);
|
|
221
222
|
for (const product of sortedProducts) {
|
|
222
|
-
if (deductionLeft.lessThanOrEqualTo(0))
|
|
223
|
+
if (deductionLeft.lessThanOrEqualTo(0))
|
|
224
|
+
break;
|
|
223
225
|
const deductAmount = import_decimal.default.min(deductionLeft, product[amountField]);
|
|
224
226
|
product[amountField] = product[amountField].minus(deductAmount);
|
|
225
227
|
deductionLeft = deductionLeft.minus(deductAmount);
|
|
@@ -329,7 +331,8 @@ function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, pr
|
|
|
329
331
|
(a, b) => a[amountField].comparedTo(b[amountField]) > 0 ? -1 : 1
|
|
330
332
|
);
|
|
331
333
|
for (const product of sortedProducts) {
|
|
332
|
-
if (deductionLeft.lessThanOrEqualTo(0))
|
|
334
|
+
if (deductionLeft.lessThanOrEqualTo(0))
|
|
335
|
+
break;
|
|
333
336
|
const deductAmount = import_decimal.default.min(deductionLeft, product[amountField]);
|
|
334
337
|
product[amountField] = product[amountField].minus(deductAmount);
|
|
335
338
|
deductionLeft = deductionLeft.minus(deductAmount);
|
|
@@ -470,7 +473,9 @@ var getMainProductPrice = (product, isDeductTaxAndFee) => {
|
|
|
470
473
|
mainProductPrice = mainProductPrice.add(bundleItemPrice.times(bundleItem.num));
|
|
471
474
|
}
|
|
472
475
|
}
|
|
473
|
-
|
|
476
|
+
const taxFee = new import_decimal.default((product == null ? void 0 : product.tax_fee) || ((_b = product == null ? void 0 : product.metadata) == null ? void 0 : _b.main_product_attached_bundle_tax_fee) || 0);
|
|
477
|
+
const surchargeFee = new import_decimal.default(((_c = product == null ? void 0 : product.metadata) == null ? void 0 : _c.main_product_attached_bundle_surcharge_fee) || 0);
|
|
478
|
+
const taxAndFeeTotal = taxFee.add(surchargeFee);
|
|
474
479
|
if (isDeductTaxAndFee) {
|
|
475
480
|
mainProductPrice = mainProductPrice.add(taxAndFeeTotal);
|
|
476
481
|
}
|
|
@@ -28,8 +28,6 @@ module.exports = __toCommonJS(strategy_exports);
|
|
|
28
28
|
var import_type = require("./type");
|
|
29
29
|
__reExport(strategy_exports, require("./adapter"), module.exports);
|
|
30
30
|
var StrategyEngine = class {
|
|
31
|
-
options;
|
|
32
|
-
operatorHandlers;
|
|
33
31
|
constructor(options = {}) {
|
|
34
32
|
this.options = {
|
|
35
33
|
debug: options.debug ?? false,
|
|
@@ -183,7 +181,8 @@ var StrategyEngine = class {
|
|
|
183
181
|
case "or":
|
|
184
182
|
return rules.some((rule) => this.evaluateRule(rule, context));
|
|
185
183
|
case "not":
|
|
186
|
-
if (rules.length === 0)
|
|
184
|
+
if (rules.length === 0)
|
|
185
|
+
return false;
|
|
187
186
|
return !this.evaluateRule(rules[0], context);
|
|
188
187
|
default:
|
|
189
188
|
throw new Error(`Unknown operator: ${operator}`);
|
|
@@ -306,14 +305,18 @@ var StrategyEngine = class {
|
|
|
306
305
|
case "is_not_null":
|
|
307
306
|
return fieldValue !== null && fieldValue !== void 0;
|
|
308
307
|
case "is_empty":
|
|
309
|
-
if (Array.isArray(fieldValue))
|
|
310
|
-
|
|
308
|
+
if (Array.isArray(fieldValue))
|
|
309
|
+
return fieldValue.length === 0;
|
|
310
|
+
if (typeof fieldValue === "string")
|
|
311
|
+
return fieldValue.length === 0;
|
|
311
312
|
if (typeof fieldValue === "object")
|
|
312
313
|
return Object.keys(fieldValue).length === 0;
|
|
313
314
|
return !fieldValue;
|
|
314
315
|
case "is_not_empty":
|
|
315
|
-
if (Array.isArray(fieldValue))
|
|
316
|
-
|
|
316
|
+
if (Array.isArray(fieldValue))
|
|
317
|
+
return fieldValue.length > 0;
|
|
318
|
+
if (typeof fieldValue === "string")
|
|
319
|
+
return fieldValue.length > 0;
|
|
317
320
|
if (typeof fieldValue === "object")
|
|
318
321
|
return Object.keys(fieldValue).length > 0;
|
|
319
322
|
return Boolean(fieldValue);
|
|
@@ -26,7 +26,7 @@ var import_index = require("./index");
|
|
|
26
26
|
var voucherConfig = {
|
|
27
27
|
metadata: {
|
|
28
28
|
id: "VOUCHER_10",
|
|
29
|
-
name: "10
|
|
29
|
+
name: "10元代金券",
|
|
30
30
|
type: "wallet_pass",
|
|
31
31
|
calculationType: "single"
|
|
32
32
|
},
|
|
@@ -70,7 +70,7 @@ var voucherConfig = {
|
|
|
70
70
|
type: "DEDUCT_AMOUNT",
|
|
71
71
|
value: 10,
|
|
72
72
|
valueType: "number",
|
|
73
|
-
valueUnit: "
|
|
73
|
+
valueUnit: "元",
|
|
74
74
|
target: "applicable_products",
|
|
75
75
|
priority: 1,
|
|
76
76
|
config: {
|
|
@@ -108,7 +108,7 @@ var voucherContext = {
|
|
|
108
108
|
var tieredDiscountConfig = {
|
|
109
109
|
metadata: {
|
|
110
110
|
id: "TIERED_DISCOUNT",
|
|
111
|
-
name: "
|
|
111
|
+
name: "阶梯满减",
|
|
112
112
|
type: "promotion",
|
|
113
113
|
calculationType: "single"
|
|
114
114
|
},
|
|
@@ -212,7 +212,7 @@ var tieredContext = {
|
|
|
212
212
|
var codeConditionConfig = {
|
|
213
213
|
metadata: {
|
|
214
214
|
id: "CODE_CONDITION_EXAMPLE",
|
|
215
|
-
name: "
|
|
215
|
+
name: "代码条件示例",
|
|
216
216
|
type: "custom"
|
|
217
217
|
},
|
|
218
218
|
conditions: {
|
|
@@ -257,34 +257,34 @@ var codeContext = {
|
|
|
257
257
|
}
|
|
258
258
|
};
|
|
259
259
|
function runExamples() {
|
|
260
|
-
console.log("======
|
|
260
|
+
console.log("====== 策略模型使用示例 ======\n");
|
|
261
261
|
const engine = (0, import_index.createStrategyEngine)({
|
|
262
262
|
debug: true,
|
|
263
263
|
enableTrace: true
|
|
264
264
|
});
|
|
265
|
-
console.log("
|
|
265
|
+
console.log("示例1: 10元代金券");
|
|
266
266
|
const result1 = engine.evaluate(voucherConfig, voucherContext);
|
|
267
|
-
console.log("
|
|
267
|
+
console.log("结果:", JSON.stringify(result1, null, 2));
|
|
268
268
|
console.log("\n");
|
|
269
|
-
console.log("
|
|
269
|
+
console.log("示例2: 阶梯满减(订单金额250)");
|
|
270
270
|
const result2 = engine.evaluate(tieredDiscountConfig, tieredContext);
|
|
271
|
-
console.log("
|
|
271
|
+
console.log("结果:", JSON.stringify(result2, null, 2));
|
|
272
272
|
console.log("\n");
|
|
273
|
-
console.log("
|
|
273
|
+
console.log("示例3: Code 模式条件");
|
|
274
274
|
const result3 = engine.evaluate(codeConditionConfig, codeContext);
|
|
275
|
-
console.log("
|
|
275
|
+
console.log("结果:", JSON.stringify(result3, null, 2));
|
|
276
276
|
console.log("\n");
|
|
277
|
-
console.log("
|
|
277
|
+
console.log("示例4: 快速评估");
|
|
278
278
|
const result4 = (0, import_index.evaluate)(voucherConfig, voucherContext);
|
|
279
|
-
console.log("
|
|
280
|
-
console.log("
|
|
279
|
+
console.log("适用:", result4.applicable);
|
|
280
|
+
console.log("匹配动作数:", result4.matchedActions.length);
|
|
281
281
|
console.log("\n");
|
|
282
|
-
console.log("
|
|
282
|
+
console.log("示例5: 自定义运算符");
|
|
283
283
|
engine.registerOperator("divisible_by", (fieldValue, compareValue) => {
|
|
284
284
|
return Number(fieldValue) % Number(compareValue) === 0;
|
|
285
285
|
});
|
|
286
286
|
const customOperatorConfig = {
|
|
287
|
-
metadata: { id: "CUSTOM_OP", name: "
|
|
287
|
+
metadata: { id: "CUSTOM_OP", name: "自定义运算符", type: "test" },
|
|
288
288
|
conditions: {
|
|
289
289
|
operator: "and",
|
|
290
290
|
rules: [
|
|
@@ -305,9 +305,9 @@ function runExamples() {
|
|
|
305
305
|
metadata: { timestamp: Date.now() }
|
|
306
306
|
};
|
|
307
307
|
const result5 = engine.evaluate(customOperatorConfig, customContext);
|
|
308
|
-
console.log("
|
|
309
|
-
console.log("
|
|
310
|
-
console.log("\n
|
|
308
|
+
console.log("结果:", result5.applicable ? "适用" : "不适用");
|
|
309
|
+
console.log("匹配动作:", result5.matchedActions);
|
|
310
|
+
console.log("\n引擎调试信息:", engine.getDebugInfo());
|
|
311
311
|
}
|
|
312
312
|
if (require.main === module) {
|
|
313
313
|
runExamples();
|
|
@@ -225,4 +225,4 @@ export interface EngineOptions {
|
|
|
225
225
|
/**
|
|
226
226
|
* 运算符处理器
|
|
227
227
|
*/
|
|
228
|
-
export
|
|
228
|
+
export type OperatorHandler = (fieldValue: any, compareValue: any, rule: ConditionRule) => boolean;
|
|
@@ -26,16 +26,16 @@ module.exports = __toCommonJS(Account_exports);
|
|
|
26
26
|
var import_BaseModule = require("../BaseModule");
|
|
27
27
|
__reExport(Account_exports, require("./types"), module.exports);
|
|
28
28
|
var AccountModule = class extends import_BaseModule.BaseModule {
|
|
29
|
-
defaultName = "account";
|
|
30
|
-
defaultVersion = "1.0.0";
|
|
31
|
-
isGuest = false;
|
|
32
|
-
store = {
|
|
33
|
-
accountInfo: null,
|
|
34
|
-
isLoggedIn: false,
|
|
35
|
-
active: false
|
|
36
|
-
};
|
|
37
29
|
constructor(name, version) {
|
|
38
30
|
super(name, version);
|
|
31
|
+
this.defaultName = "account";
|
|
32
|
+
this.defaultVersion = "1.0.0";
|
|
33
|
+
this.isGuest = false;
|
|
34
|
+
this.store = {
|
|
35
|
+
accountInfo: null,
|
|
36
|
+
isLoggedIn: false,
|
|
37
|
+
active: false
|
|
38
|
+
};
|
|
39
39
|
}
|
|
40
40
|
async initialize(core, options) {
|
|
41
41
|
this.core = core;
|
|
@@ -64,7 +64,8 @@ var AccountModule = class extends import_BaseModule.BaseModule {
|
|
|
64
64
|
return this.store.accountInfo;
|
|
65
65
|
}
|
|
66
66
|
async updateProfile(updates) {
|
|
67
|
-
if (!this.store.accountInfo)
|
|
67
|
+
if (!this.store.accountInfo)
|
|
68
|
+
return;
|
|
68
69
|
this.store.accountInfo = {
|
|
69
70
|
...this.store.accountInfo,
|
|
70
71
|
...updates
|
|
@@ -28,22 +28,19 @@ var import_BaseModule = require("../BaseModule");
|
|
|
28
28
|
var import_types = require("./types");
|
|
29
29
|
var import_utils = require("./utils");
|
|
30
30
|
var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
31
|
-
defaultName = "accountList";
|
|
32
|
-
defaultVersion = "1.0.0";
|
|
33
|
-
store = {
|
|
34
|
-
accountList: [],
|
|
35
|
-
// 账号的纯数据列表
|
|
36
|
-
accounts: [],
|
|
37
|
-
// 账号的 module 列表
|
|
38
|
-
isLoading: false,
|
|
39
|
-
error: null
|
|
40
|
-
};
|
|
41
|
-
request;
|
|
42
|
-
cacheId;
|
|
43
|
-
openCache = false;
|
|
44
|
-
fatherModule;
|
|
45
31
|
constructor(name, version) {
|
|
46
32
|
super(name, version);
|
|
33
|
+
this.defaultName = "accountList";
|
|
34
|
+
this.defaultVersion = "1.0.0";
|
|
35
|
+
this.store = {
|
|
36
|
+
accountList: [],
|
|
37
|
+
// 账号的纯数据列表
|
|
38
|
+
accounts: [],
|
|
39
|
+
// 账号的 module 列表
|
|
40
|
+
isLoading: false,
|
|
41
|
+
error: null
|
|
42
|
+
};
|
|
43
|
+
this.openCache = false;
|
|
47
44
|
}
|
|
48
45
|
async initialize(core, options) {
|
|
49
46
|
var _a, _b, _c;
|
|
@@ -23,13 +23,10 @@ __export(BaseModule_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(BaseModule_exports);
|
|
25
25
|
var BaseModule = class {
|
|
26
|
-
defaultName = "baseModule";
|
|
27
|
-
defaultVersion = "1.0.0";
|
|
28
|
-
name;
|
|
29
|
-
version;
|
|
30
|
-
isSolution = false;
|
|
31
|
-
core;
|
|
32
26
|
constructor(name, version) {
|
|
27
|
+
this.defaultName = "baseModule";
|
|
28
|
+
this.defaultVersion = "1.0.0";
|
|
29
|
+
this.isSolution = false;
|
|
33
30
|
this.name = name || this.defaultName;
|
|
34
31
|
this.version = version || this.defaultVersion;
|
|
35
32
|
}
|
|
@@ -32,17 +32,12 @@ var import_utils2 = require("../Product/utils");
|
|
|
32
32
|
__reExport(Cart_exports, require("./types"), module.exports);
|
|
33
33
|
var import_utils3 = require("./utils");
|
|
34
34
|
var CartModule = class extends import_BaseModule.BaseModule {
|
|
35
|
-
// 提供给 baseModule 用的默认名称 和 默认版本
|
|
36
|
-
defaultName = "cart";
|
|
37
|
-
defaultVersion = "1.0.0";
|
|
38
|
-
request;
|
|
39
|
-
window;
|
|
40
|
-
store;
|
|
41
|
-
cacheId;
|
|
42
|
-
openCache = false;
|
|
43
|
-
fatherModule;
|
|
44
35
|
constructor(name, version) {
|
|
45
36
|
super(name || "cart", version || "1.0.0");
|
|
37
|
+
// 提供给 baseModule 用的默认名称 和 默认版本
|
|
38
|
+
this.defaultName = "cart";
|
|
39
|
+
this.defaultVersion = "1.0.0";
|
|
40
|
+
this.openCache = false;
|
|
46
41
|
}
|
|
47
42
|
/**
|
|
48
43
|
* 初始化购物车模块
|
|
@@ -67,12 +62,12 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
67
62
|
this.request = core.getPlugin("request");
|
|
68
63
|
this.window = core.getPlugin("window");
|
|
69
64
|
if (!this.request) {
|
|
70
|
-
throw new Error("
|
|
65
|
+
throw new Error("购物车模块需要 request 插件支持");
|
|
71
66
|
}
|
|
72
67
|
if (!this.window) {
|
|
73
|
-
throw new Error("
|
|
68
|
+
throw new Error("购物车模块需要 window 插件支持");
|
|
74
69
|
}
|
|
75
|
-
console.log("[CartModule]
|
|
70
|
+
console.log("[CartModule] 初始化完成");
|
|
76
71
|
}
|
|
77
72
|
/**
|
|
78
73
|
* 添加商品到购物车
|
|
@@ -123,7 +118,7 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
123
118
|
this.store.list = [...items];
|
|
124
119
|
await this.core.effects.emit(`${this.name}:onUpdateItem`, tempCartItem);
|
|
125
120
|
} catch (error) {
|
|
126
|
-
console.error("[CartModule]
|
|
121
|
+
console.error("[CartModule] 更新购物车商品失败", error);
|
|
127
122
|
}
|
|
128
123
|
}
|
|
129
124
|
// 更新购物车中商品的初始信息
|
|
@@ -160,7 +155,7 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
160
155
|
quantity = (tempCartItem == null ? void 0 : tempCartItem.num) || 1;
|
|
161
156
|
}
|
|
162
157
|
if (!tempCartItem) {
|
|
163
|
-
throw new Error("[CartModule]
|
|
158
|
+
throw new Error("[CartModule] 格式化数据到购物车失败,商品不存在");
|
|
164
159
|
}
|
|
165
160
|
if (cartItem) {
|
|
166
161
|
tempCartItem = cartItem;
|
|
@@ -225,7 +225,8 @@ var getProductOriginTotalPrice = (params) => {
|
|
|
225
225
|
return price;
|
|
226
226
|
};
|
|
227
227
|
var formatOptions = (options) => {
|
|
228
|
-
if (!(options == null ? void 0 : options.length))
|
|
228
|
+
if (!(options == null ? void 0 : options.length))
|
|
229
|
+
return [];
|
|
229
230
|
return options.map((item) => {
|
|
230
231
|
return {
|
|
231
232
|
id: item == null ? void 0 : item.id,
|
|
@@ -250,7 +251,8 @@ var formatOptionsToOrigin = (options) => {
|
|
|
250
251
|
});
|
|
251
252
|
};
|
|
252
253
|
var formatBundle = (bundle) => {
|
|
253
|
-
if (!(bundle == null ? void 0 : bundle.length))
|
|
254
|
+
if (!(bundle == null ? void 0 : bundle.length))
|
|
255
|
+
return [];
|
|
254
256
|
return bundle.map((item) => {
|
|
255
257
|
return {
|
|
256
258
|
id: item == null ? void 0 : item.id,
|
|
@@ -272,7 +274,8 @@ var formatBundle = (bundle) => {
|
|
|
272
274
|
});
|
|
273
275
|
};
|
|
274
276
|
var formatBundleToOrigin = (bundle) => {
|
|
275
|
-
if (!(bundle == null ? void 0 : bundle.length))
|
|
277
|
+
if (!(bundle == null ? void 0 : bundle.length))
|
|
278
|
+
return [];
|
|
276
279
|
return bundle.map((d) => {
|
|
277
280
|
const getBundleValueByKey = (key) => {
|
|
278
281
|
var _a;
|
|
@@ -29,7 +29,7 @@ var DEFAULT_PAGE_SIZE = 20;
|
|
|
29
29
|
var DEFAULT_CUSTOMER = {
|
|
30
30
|
"id": 1,
|
|
31
31
|
"nickname": "Select a customer",
|
|
32
|
-
"name": "
|
|
32
|
+
"name": "选择一个客户"
|
|
33
33
|
};
|
|
34
34
|
// Annotate the CommonJS export names for ESM import in node:
|
|
35
35
|
0 && (module.exports = {
|
|
@@ -28,26 +28,23 @@ var import_BaseModule = require("../BaseModule");
|
|
|
28
28
|
var import_constants = require("./constants");
|
|
29
29
|
__reExport(Customer_exports, require("./types"), module.exports);
|
|
30
30
|
var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
31
|
-
defaultName = "customer";
|
|
32
|
-
defaultVersion = "1.0.0";
|
|
33
|
-
store = {
|
|
34
|
-
customerList: [],
|
|
35
|
-
selectedCustomer: null,
|
|
36
|
-
total: 0,
|
|
37
|
-
currentPage: 1,
|
|
38
|
-
pageSize: import_constants.DEFAULT_PAGE_SIZE,
|
|
39
|
-
loading: false,
|
|
40
|
-
error: null,
|
|
41
|
-
hasMore: true,
|
|
42
|
-
loadingMore: false,
|
|
43
|
-
searchParams: {}
|
|
44
|
-
};
|
|
45
|
-
request;
|
|
46
|
-
cacheId;
|
|
47
|
-
openCache = false;
|
|
48
|
-
fatherModule;
|
|
49
31
|
constructor(name, version) {
|
|
50
32
|
super(name, version);
|
|
33
|
+
this.defaultName = "customer";
|
|
34
|
+
this.defaultVersion = "1.0.0";
|
|
35
|
+
this.store = {
|
|
36
|
+
customerList: [],
|
|
37
|
+
selectedCustomer: null,
|
|
38
|
+
total: 0,
|
|
39
|
+
currentPage: 1,
|
|
40
|
+
pageSize: import_constants.DEFAULT_PAGE_SIZE,
|
|
41
|
+
loading: false,
|
|
42
|
+
error: null,
|
|
43
|
+
hasMore: true,
|
|
44
|
+
loadingMore: false,
|
|
45
|
+
searchParams: {}
|
|
46
|
+
};
|
|
47
|
+
this.openCache = false;
|
|
51
48
|
}
|
|
52
49
|
async initialize(core, options) {
|
|
53
50
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
@@ -33,7 +33,7 @@ export interface ShopCustomer extends ICustomer {
|
|
|
33
33
|
* walletDetails.wallet: 用户所有wallet
|
|
34
34
|
* latestWalletDetail.wallet: 用户最新wallet
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
type CustomerWith = 'formRecord' | 'walletDetails.wallet' | 'latestWalletDetail.wallet';
|
|
37
37
|
/**
|
|
38
38
|
* 获取客户列表参数
|
|
39
39
|
*/
|
|
@@ -37,15 +37,11 @@ var import_BaseModule = require("../BaseModule");
|
|
|
37
37
|
var import_utils = require("./utils");
|
|
38
38
|
var import_cloneDeep = __toESM(require("lodash-es/cloneDeep"));
|
|
39
39
|
var DateModule = class extends import_BaseModule.BaseModule {
|
|
40
|
-
defaultName = "date";
|
|
41
|
-
defaultVersion = "1.0.0";
|
|
42
|
-
store;
|
|
43
|
-
request;
|
|
44
|
-
cacheId;
|
|
45
|
-
openCache = false;
|
|
46
|
-
fatherModule;
|
|
47
40
|
constructor(name, version) {
|
|
48
41
|
super(name, version);
|
|
42
|
+
this.defaultName = "date";
|
|
43
|
+
this.defaultVersion = "1.0.0";
|
|
44
|
+
this.openCache = false;
|
|
49
45
|
}
|
|
50
46
|
async initialize(core, options) {
|
|
51
47
|
var _a, _b;
|
|
@@ -57,7 +53,7 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
57
53
|
this.store.dateList = options.initialState.dateList;
|
|
58
54
|
}
|
|
59
55
|
if (!this.request) {
|
|
60
|
-
throw new Error("DateModule
|
|
56
|
+
throw new Error("DateModule 需要 request 插件支持");
|
|
61
57
|
}
|
|
62
58
|
if ((_a = options.otherParams) == null ? void 0 : _a.cacheId) {
|
|
63
59
|
this.openCache = options.otherParams.openCache;
|
|
@@ -195,13 +191,13 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
195
191
|
if (startAt.isBefore(resourceStartTime)) {
|
|
196
192
|
const roundedStartTime = this.roundUpToNext10Minutes(resourceStartTime);
|
|
197
193
|
const roundedStartTimeDayjs = (0, import_dayjs.default)(roundedStartTime);
|
|
198
|
-
console.log(`[DateModule]
|
|
194
|
+
console.log(`[DateModule] 修正时间段开始时间: ${timeSlot.start_at} -> ${roundedStartTime} (资源ID: ${resource.id}, 原始start_time: ${resource.start_time})`);
|
|
199
195
|
const correctedTimeSlot = {
|
|
200
196
|
...timeSlot,
|
|
201
197
|
start_at: roundedStartTime
|
|
202
198
|
};
|
|
203
199
|
if (endAt.isBefore(roundedStartTimeDayjs)) {
|
|
204
|
-
console.log(`[DateModule]
|
|
200
|
+
console.log(`[DateModule] 时间段无效,将被删除: ${timeSlot.start_at} - ${timeSlot.end_at} (资源ID: ${resource.id}, 修正后start_time: ${roundedStartTime})`);
|
|
205
201
|
return null;
|
|
206
202
|
}
|
|
207
203
|
return correctedTimeSlot;
|
|
@@ -23,7 +23,6 @@ __export(types_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(types_exports);
|
|
25
25
|
var DateHooks = /* @__PURE__ */ ((DateHooks2) => {
|
|
26
|
-
return DateHooks2;
|
|
27
26
|
})(DateHooks || {});
|
|
28
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
29
28
|
0 && (module.exports = {
|