@pisell/pisellos 2.1.125 → 2.1.127
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/itemRule/adapter.d.ts +8 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +52 -8
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +15 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +68 -1
- package/dist/model/strategy/adapter/itemRule/index.d.ts +1 -1
- package/dist/model/strategy/adapter/itemRule/index.js +1 -1
- package/dist/model/strategy/adapter/itemRule/type.d.ts +20 -1
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +6 -40
- package/dist/modules/Order/utils.d.ts +24 -0
- package/dist/modules/Order/utils.js +87 -11
- package/dist/modules/SalesSummary/types.d.ts +2 -1
- package/dist/modules/SalesSummary/utils.js +10 -10
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/solution/ScanOrder/index.d.ts +5 -0
- package/dist/solution/ScanOrder/index.js +205 -64
- package/dist/solution/ScanOrder/types.d.ts +19 -5
- package/dist/solution/ScanOrder/utils.d.ts +15 -0
- package/dist/solution/ScanOrder/utils.js +142 -62
- package/dist/solution/VenueBooking/index.d.ts +4 -0
- package/dist/solution/VenueBooking/index.js +219 -141
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +6 -4
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +8 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +41 -2
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +15 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +47 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +1 -1
- package/lib/model/strategy/adapter/itemRule/index.js +2 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +20 -1
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +4 -37
- package/lib/modules/Order/utils.d.ts +24 -0
- package/lib/modules/Order/utils.js +65 -4
- package/lib/modules/SalesSummary/types.d.ts +2 -1
- package/lib/modules/SalesSummary/utils.js +2 -2
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/solution/ScanOrder/index.d.ts +5 -0
- package/lib/solution/ScanOrder/index.js +94 -18
- package/lib/solution/ScanOrder/types.d.ts +19 -5
- package/lib/solution/ScanOrder/utils.d.ts +15 -0
- package/lib/solution/ScanOrder/utils.js +86 -19
- package/lib/solution/VenueBooking/index.d.ts +4 -0
- package/lib/solution/VenueBooking/index.js +85 -25
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +13 -4
- package/package.json +1 -1
|
@@ -50,6 +50,14 @@ export declare class ItemRuleAdapter implements BusinessAdapter {
|
|
|
50
50
|
* 不适用或无配置时返回 null。
|
|
51
51
|
*/
|
|
52
52
|
extractQuantityLimits(action: ActionEffect, businessData: ItemRuleBusinessData): QuantityLimitResult | null;
|
|
53
|
+
/**
|
|
54
|
+
* 计算当前提交剩余可选的最大数量。
|
|
55
|
+
*
|
|
56
|
+
* 仅在 scope='cumulative' 且存在 requiredMax 时生效:
|
|
57
|
+
* 用 requiredMax 减去 historicalItems 中目标商品的累计数量,保底 0。
|
|
58
|
+
* 其余场景返回 undefined,保持向后兼容。
|
|
59
|
+
*/
|
|
60
|
+
private calculateRemainingMax;
|
|
53
61
|
private processPrefillCart;
|
|
54
62
|
/**
|
|
55
63
|
* 根据 quantityFrom 计算预填数量
|
|
@@ -327,7 +327,8 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
|
|
|
327
327
|
var scope = config.scope,
|
|
328
328
|
quantityRules = config.quantityRules,
|
|
329
329
|
targetType = config.targetType,
|
|
330
|
-
targets = config.targets
|
|
330
|
+
targets = config.targets,
|
|
331
|
+
validationMessage = config.validationMessage;
|
|
331
332
|
if (!this.shouldEvaluateForScope(scope, (_businessData$submiss2 = businessData.submissionIndex) !== null && _businessData$submiss2 !== void 0 ? _businessData$submiss2 : 0)) {
|
|
332
333
|
return null;
|
|
333
334
|
}
|
|
@@ -373,18 +374,61 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
|
|
|
373
374
|
} finally {
|
|
374
375
|
_iterator4.f();
|
|
375
376
|
}
|
|
377
|
+
var remainingMax = this.calculateRemainingMax(scope, requiredMax, targets, businessData);
|
|
378
|
+
var formattedValidationMessage = this.formatValidationMessage(validationMessage, requiredMin, requiredMax, requiredExact);
|
|
376
379
|
return {
|
|
377
380
|
ruleId: action.id,
|
|
378
381
|
targetType: targetType,
|
|
379
382
|
targets: targets,
|
|
380
383
|
requiredMin: requiredMin,
|
|
381
384
|
requiredMax: requiredMax,
|
|
385
|
+
remainingMax: remainingMax,
|
|
382
386
|
requiredExact: requiredExact,
|
|
383
387
|
mustInclude: mustInclude,
|
|
384
|
-
scope: scope
|
|
388
|
+
scope: scope,
|
|
389
|
+
validationMessage: formattedValidationMessage,
|
|
390
|
+
rawValidationMessage: validationMessage
|
|
385
391
|
};
|
|
386
392
|
}
|
|
387
393
|
|
|
394
|
+
/**
|
|
395
|
+
* 计算当前提交剩余可选的最大数量。
|
|
396
|
+
*
|
|
397
|
+
* 仅在 scope='cumulative' 且存在 requiredMax 时生效:
|
|
398
|
+
* 用 requiredMax 减去 historicalItems 中目标商品的累计数量,保底 0。
|
|
399
|
+
* 其余场景返回 undefined,保持向后兼容。
|
|
400
|
+
*/
|
|
401
|
+
}, {
|
|
402
|
+
key: "calculateRemainingMax",
|
|
403
|
+
value: function calculateRemainingMax(scope, requiredMax, targets, businessData) {
|
|
404
|
+
if (scope !== 'cumulative' || typeof requiredMax !== 'number') {
|
|
405
|
+
return undefined;
|
|
406
|
+
}
|
|
407
|
+
var historicalItems = businessData.historicalItems;
|
|
408
|
+
if (!(historicalItems !== null && historicalItems !== void 0 && historicalItems.length)) {
|
|
409
|
+
return Math.max(0, requiredMax);
|
|
410
|
+
}
|
|
411
|
+
var targetIds = new Set(targets.map(function (t) {
|
|
412
|
+
return t.product_id;
|
|
413
|
+
}));
|
|
414
|
+
var historicalQty = 0;
|
|
415
|
+
var _iterator5 = _createForOfIteratorHelper(historicalItems),
|
|
416
|
+
_step5;
|
|
417
|
+
try {
|
|
418
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
419
|
+
var item = _step5.value;
|
|
420
|
+
if (targetIds.has(item.product_id)) {
|
|
421
|
+
historicalQty += item.quantity;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
} catch (err) {
|
|
425
|
+
_iterator5.e(err);
|
|
426
|
+
} finally {
|
|
427
|
+
_iterator5.f();
|
|
428
|
+
}
|
|
429
|
+
return Math.max(0, requiredMax - historicalQty);
|
|
430
|
+
}
|
|
431
|
+
|
|
388
432
|
// ============================================
|
|
389
433
|
// Prefill Cart 处理
|
|
390
434
|
// ============================================
|
|
@@ -394,11 +438,11 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
|
|
|
394
438
|
var config = action.config;
|
|
395
439
|
if (!(config !== null && config !== void 0 && config.products)) return [];
|
|
396
440
|
var results = [];
|
|
397
|
-
var
|
|
398
|
-
|
|
441
|
+
var _iterator6 = _createForOfIteratorHelper(config.products),
|
|
442
|
+
_step6;
|
|
399
443
|
try {
|
|
400
|
-
for (
|
|
401
|
-
var prefillProduct =
|
|
444
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
445
|
+
var prefillProduct = _step6.value;
|
|
402
446
|
var quantity = this.resolvePrefillQuantity(prefillProduct.quantityFrom, prefillProduct.quantity, businessData);
|
|
403
447
|
if (quantity <= 0) continue;
|
|
404
448
|
results.push({
|
|
@@ -409,9 +453,9 @@ export var ItemRuleAdapter = /*#__PURE__*/function () {
|
|
|
409
453
|
});
|
|
410
454
|
}
|
|
411
455
|
} catch (err) {
|
|
412
|
-
|
|
456
|
+
_iterator6.e(err);
|
|
413
457
|
} finally {
|
|
414
|
-
|
|
458
|
+
_iterator6.f();
|
|
415
459
|
}
|
|
416
460
|
return results;
|
|
417
461
|
}
|
|
@@ -25,6 +25,21 @@ export declare const MAX_BUNS_PER_TABLE_STRATEGY: StrategyConfig;
|
|
|
25
25
|
* - Prefill Cart: 自动添加默认锅底 x 1
|
|
26
26
|
*/
|
|
27
27
|
export declare const HOTPOT_BASE_REQUIRED_STRATEGY: StrategyConfig;
|
|
28
|
+
/**
|
|
29
|
+
* 场景:4 款锅底里任选至少 1 款,不自动预填,不限制多选上限
|
|
30
|
+
*
|
|
31
|
+
* WHEN: Always active
|
|
32
|
+
* THEN:
|
|
33
|
+
* - Quantity Check: 4 个锅底商品合计数量 >= 1 (OR 组语义)
|
|
34
|
+
*
|
|
35
|
+
* 说明:
|
|
36
|
+
* - targets 里放多个 product_id 时,ItemRuleAdapter 会把它们视为 OR 组,
|
|
37
|
+
* 仅校验「合计数量」,不会要求每款各自满足 min。
|
|
38
|
+
* - ScanOrder 工具层 buildQuantityLimitIndex 会跳过多目标规则的
|
|
39
|
+
* 单品索引,避免 UI 把组级 min 误当作每张商品卡的减号下限,
|
|
40
|
+
* 锁死用户切换锅底的操作。
|
|
41
|
+
*/
|
|
42
|
+
export declare const HOTPOT_BASE_PICK_ONE_STRATEGY: StrategyConfig;
|
|
28
43
|
/**
|
|
29
44
|
* ItemRuleEvaluator 简洁调用示例
|
|
30
45
|
*
|
|
@@ -205,7 +205,74 @@ export var HOTPOT_BASE_REQUIRED_STRATEGY = {
|
|
|
205
205
|
};
|
|
206
206
|
|
|
207
207
|
// ============================================
|
|
208
|
-
// 示例 4
|
|
208
|
+
// 示例 4:锅底四选一(Multi-target OR 组至少 1 份)
|
|
209
|
+
// ============================================
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* 场景:4 款锅底里任选至少 1 款,不自动预填,不限制多选上限
|
|
213
|
+
*
|
|
214
|
+
* WHEN: Always active
|
|
215
|
+
* THEN:
|
|
216
|
+
* - Quantity Check: 4 个锅底商品合计数量 >= 1 (OR 组语义)
|
|
217
|
+
*
|
|
218
|
+
* 说明:
|
|
219
|
+
* - targets 里放多个 product_id 时,ItemRuleAdapter 会把它们视为 OR 组,
|
|
220
|
+
* 仅校验「合计数量」,不会要求每款各自满足 min。
|
|
221
|
+
* - ScanOrder 工具层 buildQuantityLimitIndex 会跳过多目标规则的
|
|
222
|
+
* 单品索引,避免 UI 把组级 min 误当作每张商品卡的减号下限,
|
|
223
|
+
* 锁死用户切换锅底的操作。
|
|
224
|
+
*/
|
|
225
|
+
export var HOTPOT_BASE_PICK_ONE_STRATEGY = {
|
|
226
|
+
metadata: {
|
|
227
|
+
id: 'RULE_HOTPOT_BASE_PICK_ONE',
|
|
228
|
+
name: {
|
|
229
|
+
'zh-CN': '锅底必选(四选一)',
|
|
230
|
+
en: 'Hotpot base required (pick any)'
|
|
231
|
+
},
|
|
232
|
+
type: 'item_rule',
|
|
233
|
+
description: {
|
|
234
|
+
'zh-CN': '4 款锅底任选至少 1 份',
|
|
235
|
+
en: 'Pick at least 1 hotpot base from the available options'
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
conditions: {
|
|
239
|
+
operator: 'and',
|
|
240
|
+
rules: [],
|
|
241
|
+
actionIds: ['quantity_check_hotpot_base_group']
|
|
242
|
+
},
|
|
243
|
+
actions: [{
|
|
244
|
+
id: 'quantity_check_hotpot_base_group',
|
|
245
|
+
type: ITEM_RULE_ACTION_TYPES.QUANTITY_CHECK,
|
|
246
|
+
value: null,
|
|
247
|
+
target: 'cart',
|
|
248
|
+
priority: 10,
|
|
249
|
+
config: {
|
|
250
|
+
targetType: 'product',
|
|
251
|
+
targets: [{
|
|
252
|
+
product_id: 30001
|
|
253
|
+
}, {
|
|
254
|
+
product_id: 30002
|
|
255
|
+
}, {
|
|
256
|
+
product_id: 30003
|
|
257
|
+
}, {
|
|
258
|
+
product_id: 30004
|
|
259
|
+
}],
|
|
260
|
+
quantityRules: [{
|
|
261
|
+
comparison: 'minimum',
|
|
262
|
+
source: 'fixed',
|
|
263
|
+
value: 1
|
|
264
|
+
}],
|
|
265
|
+
scope: 'first_submission_only',
|
|
266
|
+
validationMessage: {
|
|
267
|
+
'zh-CN': '请至少选择 {min} 款锅底',
|
|
268
|
+
en: 'Please select at least {min} hotpot base'
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}]
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
// ============================================
|
|
275
|
+
// 示例 5:ItemRuleEvaluator 用法(简洁调用 + 完整 Demo)
|
|
209
276
|
// ============================================
|
|
210
277
|
|
|
211
278
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ItemRuleEvaluator } from './evaluator';
|
|
2
2
|
export { ItemRuleAdapter } from './adapter';
|
|
3
3
|
export { default } from './adapter';
|
|
4
|
-
export { MIN_CONDIMENT_PER_PERSON_STRATEGY, MAX_BUNS_PER_TABLE_STRATEGY, HOTPOT_BASE_REQUIRED_STRATEGY, quickUseItemRuleEvaluator, runItemRuleEvaluatorDemo, } from './examples';
|
|
4
|
+
export { MIN_CONDIMENT_PER_PERSON_STRATEGY, MAX_BUNS_PER_TABLE_STRATEGY, HOTPOT_BASE_REQUIRED_STRATEGY, HOTPOT_BASE_PICK_ONE_STRATEGY, quickUseItemRuleEvaluator, runItemRuleEvaluatorDemo, } from './examples';
|
|
5
5
|
export * from './type';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ItemRuleEvaluator } from "./evaluator";
|
|
2
2
|
export { ItemRuleAdapter } from "./adapter";
|
|
3
3
|
export { default } from "./adapter";
|
|
4
|
-
export { MIN_CONDIMENT_PER_PERSON_STRATEGY, MAX_BUNS_PER_TABLE_STRATEGY, HOTPOT_BASE_REQUIRED_STRATEGY, quickUseItemRuleEvaluator, runItemRuleEvaluatorDemo } from "./examples";
|
|
4
|
+
export { MIN_CONDIMENT_PER_PERSON_STRATEGY, MAX_BUNS_PER_TABLE_STRATEGY, HOTPOT_BASE_REQUIRED_STRATEGY, HOTPOT_BASE_PICK_ONE_STRATEGY, quickUseItemRuleEvaluator, runItemRuleEvaluatorDemo } from "./examples";
|
|
5
5
|
export * from "./type";
|
|
@@ -180,14 +180,33 @@ export interface QuantityLimitResult {
|
|
|
180
180
|
targets: TargetItem[];
|
|
181
181
|
/** 要求的最小数量 */
|
|
182
182
|
requiredMin?: number;
|
|
183
|
-
/**
|
|
183
|
+
/** 要求的最大数量(规则配置的原始上限,用于 UI 文案展示) */
|
|
184
184
|
requiredMax?: number;
|
|
185
|
+
/**
|
|
186
|
+
* 当前提交剩余可选的最大数量。
|
|
187
|
+
*
|
|
188
|
+
* 仅在 scope='cumulative' 且存在 requiredMax 时计算:
|
|
189
|
+
* remainingMax = max(0, requiredMax - historicalItems 中目标商品累计数量)
|
|
190
|
+
*
|
|
191
|
+
* 非 cumulative 场景不设置此字段;调用方用于限制加购上限时,
|
|
192
|
+
* 应优先读取本字段,未定义时回退到 requiredMax。
|
|
193
|
+
*/
|
|
194
|
+
remainingMax?: number;
|
|
185
195
|
/** 要求的精确数量 */
|
|
186
196
|
requiredExact?: number;
|
|
187
197
|
/** 是否必须包含 */
|
|
188
198
|
mustInclude?: boolean;
|
|
189
199
|
/** 作用范围 */
|
|
190
200
|
scope: RuleScope;
|
|
201
|
+
/**
|
|
202
|
+
* 校验失败时的提示语(已做 {min}/{max}/{exact} 占位符替换)。
|
|
203
|
+
* 当 rawValidationMessage 为多语言对象时,后端不做 locale 选择,
|
|
204
|
+
* 默认按 en → Object.values()[0] 的顺序兜底,前端可再根据自身 locale
|
|
205
|
+
* 读取 rawValidationMessage 做精确匹配。
|
|
206
|
+
*/
|
|
207
|
+
validationMessage?: string;
|
|
208
|
+
/** 原始多语言模板,前端可根据自身 locale 做二次选择 */
|
|
209
|
+
rawValidationMessage?: string | Record<string, string>;
|
|
191
210
|
}
|
|
192
211
|
/**
|
|
193
212
|
* ItemRule 评估器的完整输出结果
|
|
@@ -112,6 +112,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
112
112
|
createOrderByCheckout(params: CheckoutOrderParams): Promise<any>;
|
|
113
113
|
submitScanOrder<T = any>(params: SubmitScanOrderParams): Promise<T>;
|
|
114
114
|
scanOrderMore<T = any>(params: ScanOrderMoreParams): Promise<T>;
|
|
115
|
-
getOrderInfoByRemote(order_id: number): Promise<
|
|
115
|
+
getOrderInfoByRemote(order_id: number): Promise<any>;
|
|
116
116
|
getLastOrderInfo(): Record<string, any> | undefined;
|
|
117
117
|
}
|
|
@@ -25,7 +25,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
25
25
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
26
26
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
27
27
|
import { BaseModule } from "../BaseModule";
|
|
28
|
-
import { generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createEmptySummary, formatDateTime, formatV1Product, isTempOrder } from "./utils";
|
|
28
|
+
import { generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, formatDateTime, formatV1Product, isTempOrder } from "./utils";
|
|
29
29
|
import { isNormalProduct } from "../Product/utils";
|
|
30
30
|
import dayjs from 'dayjs';
|
|
31
31
|
import { getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
|
|
@@ -176,42 +176,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
176
176
|
}, {
|
|
177
177
|
key: "createDefaultRulesHooks",
|
|
178
178
|
value: function createDefaultRulesHooks() {
|
|
179
|
-
return
|
|
180
|
-
getProduct: function getProduct(product) {
|
|
181
|
-
var _product$_origin, _product$_origin2, _product$_origin3, _product$_origin4;
|
|
182
|
-
return {
|
|
183
|
-
id: product.product_id,
|
|
184
|
-
_id: product.identity_key ? "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(product.identity_key) : "".concat(product.product_id, "_").concat(product.product_variant_id),
|
|
185
|
-
price: product.selling_price,
|
|
186
|
-
total: new Decimal(product.payment_price || product.selling_price || 0).times(product.num || 1).toNumber(),
|
|
187
|
-
origin_total: new Decimal(product.original_price || product.selling_price || 0).times(product.num || 1).toNumber(),
|
|
188
|
-
original_price: product.original_price,
|
|
189
|
-
quantity: product.num || 1,
|
|
190
|
-
num: product.num || 1,
|
|
191
|
-
discount_list: product.discount_list || [],
|
|
192
|
-
bundle: product.product_bundle || [],
|
|
193
|
-
booking_id: ((_product$_origin = product._origin) === null || _product$_origin === void 0 ? void 0 : _product$_origin.booking_id) || null,
|
|
194
|
-
isClient: false,
|
|
195
|
-
isManualDiscount: ((_product$_origin2 = product._origin) === null || _product$_origin2 === void 0 ? void 0 : _product$_origin2.isManualDiscount) || false,
|
|
196
|
-
holder_id: (_product$_origin3 = product._origin) === null || _product$_origin3 === void 0 ? void 0 : _product$_origin3.holder_id,
|
|
197
|
-
startDate: (_product$_origin4 = product._origin) === null || _product$_origin4 === void 0 ? void 0 : _product$_origin4.startDate
|
|
198
|
-
};
|
|
199
|
-
},
|
|
200
|
-
setProduct: function setProduct(product, values) {
|
|
201
|
-
var _values$discount_list, _values$quantity, _values$bundle;
|
|
202
|
-
return _objectSpread(_objectSpread({}, product), {}, {
|
|
203
|
-
selling_price: values.price !== undefined ? String(values.price) : product.selling_price,
|
|
204
|
-
payment_price: values.total !== undefined ? String(values.total) : product.payment_price,
|
|
205
|
-
original_price: values.original_price !== undefined ? String(values.original_price) : product.original_price,
|
|
206
|
-
discount_list: (_values$discount_list = values.discount_list) !== null && _values$discount_list !== void 0 ? _values$discount_list : product.discount_list,
|
|
207
|
-
num: (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num,
|
|
208
|
-
product_bundle: (_values$bundle = values.bundle) !== null && _values$bundle !== void 0 ? _values$bundle : product.product_bundle,
|
|
209
|
-
metadata: _objectSpread(_objectSpread({}, product.metadata || {}), values.main_product_selling_price !== undefined ? {
|
|
210
|
-
main_product_selling_price: String(values.main_product_selling_price)
|
|
211
|
-
} : {})
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
};
|
|
179
|
+
return createDefaultOrderRulesHooks();
|
|
215
180
|
}
|
|
216
181
|
|
|
217
182
|
// ─── Discount: 公共 API ───
|
|
@@ -1114,10 +1079,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1114
1079
|
});
|
|
1115
1080
|
case 2:
|
|
1116
1081
|
res = _context15.sent;
|
|
1117
|
-
if (res.
|
|
1118
|
-
this.store.tempOrder.lastOrderInfo = res.data
|
|
1082
|
+
if (res.code === 200 && this.store.tempOrder) {
|
|
1083
|
+
this.store.tempOrder.lastOrderInfo = res.data;
|
|
1119
1084
|
}
|
|
1120
|
-
|
|
1085
|
+
return _context15.abrupt("return", res);
|
|
1086
|
+
case 5:
|
|
1121
1087
|
case "end":
|
|
1122
1088
|
return _context15.stop();
|
|
1123
1089
|
}
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
import { CartItem } from "../Cart";
|
|
2
2
|
import type { ScanOrderSubmitPayload, ScanOrderSubmitProduct, ScanOrderSummary, ScanOrderTempOrder } from '../../solution/ScanOrder/types';
|
|
3
|
+
import type { RulesParamsHooks } from '../Rules/types';
|
|
4
|
+
/**
|
|
5
|
+
* OrderModule 默认 Rules 钩子工厂。
|
|
6
|
+
*
|
|
7
|
+
* 价格语义约定(订单域):
|
|
8
|
+
* - `selling_price`:券后单品单价(实际成交单价)。初次加购 = `original_price`;券应用后由 Rules 引擎更新。
|
|
9
|
+
* - `original_price`:券前单品单价(店铺售价)。不承载后台划线价语义。
|
|
10
|
+
* - `payment_price`:已从内部字段移除;只在出站 payload 中由 `selling_price` 派生以兼容后端。
|
|
11
|
+
*
|
|
12
|
+
* Rules 钩子契约:
|
|
13
|
+
* - `getProduct.total` = `selling_price × num`(当前成交总价)
|
|
14
|
+
* - `getProduct.origin_total` = `original_price × num`(券前总价)
|
|
15
|
+
* - `setProduct` 写回 `selling_price` 的优先级:
|
|
16
|
+
* 1. `values.main_product_selling_price`(券应用分支,per-unit 券后主价)
|
|
17
|
+
* 2. `values.price`(还原分支 `restoredPrice`、good_pass 归零)
|
|
18
|
+
* 3. `values.total / num`(仅当 Rules 只给出总价时的兜底)
|
|
19
|
+
*
|
|
20
|
+
* 导出为纯函数方便单测直接驱动钩子,不依赖 OrderModule 实例。
|
|
21
|
+
*/
|
|
22
|
+
export declare function createDefaultOrderRulesHooks(): RulesParamsHooks;
|
|
3
23
|
/**
|
|
4
24
|
* 通过 session 类商品的开始时间结束时间生成商品的时长
|
|
5
25
|
* @param {CartItem} cartItem
|
|
@@ -28,6 +48,10 @@ export declare function formatDateTime(date: Date): string;
|
|
|
28
48
|
export declare function normalizeSubmitBooking<T extends {
|
|
29
49
|
metadata?: Record<string, any>;
|
|
30
50
|
}>(booking: T): T;
|
|
51
|
+
/** 提交用人数:有限且为正则向下取整,否则为 1 */
|
|
52
|
+
export declare function normalizeSubmitCollectPaxValue(value: unknown): number;
|
|
53
|
+
/** 从临时订单 metadata 解析合成 booking 的 collect_pax */
|
|
54
|
+
export declare function resolveSubmitCollectPax(tempOrder: ScanOrderTempOrder): number;
|
|
31
55
|
export declare function createDefaultTempOrder(params: {
|
|
32
56
|
now: string;
|
|
33
57
|
summary?: ScanOrderSummary;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
var _excluded = ["_origin", "identity_key"],
|
|
2
2
|
_excluded2 = ["created_at", "summary", "surcharges"];
|
|
3
3
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
4
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
4
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
5
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
11
6
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
@@ -15,8 +10,75 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
15
10
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
16
11
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
17
12
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
17
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
18
|
import dayjs from "dayjs";
|
|
19
|
+
import Decimal from 'decimal.js';
|
|
19
20
|
import { createEmptySummary } from "../../solution/ScanOrder/utils";
|
|
21
|
+
/**
|
|
22
|
+
* OrderModule 默认 Rules 钩子工厂。
|
|
23
|
+
*
|
|
24
|
+
* 价格语义约定(订单域):
|
|
25
|
+
* - `selling_price`:券后单品单价(实际成交单价)。初次加购 = `original_price`;券应用后由 Rules 引擎更新。
|
|
26
|
+
* - `original_price`:券前单品单价(店铺售价)。不承载后台划线价语义。
|
|
27
|
+
* - `payment_price`:已从内部字段移除;只在出站 payload 中由 `selling_price` 派生以兼容后端。
|
|
28
|
+
*
|
|
29
|
+
* Rules 钩子契约:
|
|
30
|
+
* - `getProduct.total` = `selling_price × num`(当前成交总价)
|
|
31
|
+
* - `getProduct.origin_total` = `original_price × num`(券前总价)
|
|
32
|
+
* - `setProduct` 写回 `selling_price` 的优先级:
|
|
33
|
+
* 1. `values.main_product_selling_price`(券应用分支,per-unit 券后主价)
|
|
34
|
+
* 2. `values.price`(还原分支 `restoredPrice`、good_pass 归零)
|
|
35
|
+
* 3. `values.total / num`(仅当 Rules 只给出总价时的兜底)
|
|
36
|
+
*
|
|
37
|
+
* 导出为纯函数方便单测直接驱动钩子,不依赖 OrderModule 实例。
|
|
38
|
+
*/
|
|
39
|
+
export function createDefaultOrderRulesHooks() {
|
|
40
|
+
var toUnitPriceString = function toUnitPriceString(totalLike, num) {
|
|
41
|
+
var effectiveNum = Number(num) > 0 ? Number(num) : 1;
|
|
42
|
+
return new Decimal(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
getProduct: function getProduct(product) {
|
|
46
|
+
var _product$_origin, _product$_origin2, _product$_origin3, _product$_origin4;
|
|
47
|
+
return {
|
|
48
|
+
id: product.product_id,
|
|
49
|
+
_id: product.identity_key ? "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(product.identity_key) : "".concat(product.product_id, "_").concat(product.product_variant_id),
|
|
50
|
+
price: product.selling_price,
|
|
51
|
+
total: new Decimal(product.selling_price || 0).times(product.num || 1).toNumber(),
|
|
52
|
+
origin_total: new Decimal(product.original_price || product.selling_price || 0).times(product.num || 1).toNumber(),
|
|
53
|
+
original_price: product.original_price,
|
|
54
|
+
quantity: product.num || 1,
|
|
55
|
+
num: product.num || 1,
|
|
56
|
+
discount_list: product.discount_list || [],
|
|
57
|
+
bundle: product.product_bundle || [],
|
|
58
|
+
booking_id: ((_product$_origin = product._origin) === null || _product$_origin === void 0 ? void 0 : _product$_origin.booking_id) || null,
|
|
59
|
+
isClient: false,
|
|
60
|
+
isManualDiscount: ((_product$_origin2 = product._origin) === null || _product$_origin2 === void 0 ? void 0 : _product$_origin2.isManualDiscount) || false,
|
|
61
|
+
holder_id: (_product$_origin3 = product._origin) === null || _product$_origin3 === void 0 ? void 0 : _product$_origin3.holder_id,
|
|
62
|
+
startDate: (_product$_origin4 = product._origin) === null || _product$_origin4 === void 0 ? void 0 : _product$_origin4.startDate
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
setProduct: function setProduct(product, values) {
|
|
66
|
+
var _ref, _values$quantity, _values$discount_list, _values$quantity2, _values$bundle;
|
|
67
|
+
var nextNum = Number((_ref = (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num) !== null && _ref !== void 0 ? _ref : 1) || 1;
|
|
68
|
+
var nextSellingPrice = values.main_product_selling_price !== undefined ? String(values.main_product_selling_price) : values.price !== undefined ? String(values.price) : values.total !== undefined ? toUnitPriceString(values.total, nextNum) : product.selling_price;
|
|
69
|
+
return _objectSpread(_objectSpread({}, product), {}, {
|
|
70
|
+
selling_price: nextSellingPrice,
|
|
71
|
+
original_price: values.original_price !== undefined ? String(values.original_price) : product.original_price,
|
|
72
|
+
discount_list: (_values$discount_list = values.discount_list) !== null && _values$discount_list !== void 0 ? _values$discount_list : product.discount_list,
|
|
73
|
+
num: (_values$quantity2 = values.quantity) !== null && _values$quantity2 !== void 0 ? _values$quantity2 : product.num,
|
|
74
|
+
product_bundle: (_values$bundle = values.bundle) !== null && _values$bundle !== void 0 ? _values$bundle : product.product_bundle,
|
|
75
|
+
metadata: _objectSpread(_objectSpread({}, product.metadata || {}), values.main_product_selling_price !== undefined ? {
|
|
76
|
+
main_product_selling_price: String(values.main_product_selling_price)
|
|
77
|
+
} : {})
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
20
82
|
|
|
21
83
|
/**
|
|
22
84
|
* 通过 session 类商品的开始时间结束时间生成商品的时长
|
|
@@ -131,7 +193,9 @@ function normalizeSubmitProduct(product) {
|
|
|
131
193
|
product_option_item: submitProduct.product_option_item || [],
|
|
132
194
|
discount_list: submitProduct.discount_list || [],
|
|
133
195
|
product_bundle: submitProduct.product_bundle || [],
|
|
134
|
-
metadata: cleanMetadata
|
|
196
|
+
metadata: cleanMetadata,
|
|
197
|
+
// 出站兼容:后端仍消费 payment_price 字段,从 selling_price(券后单价)派生。
|
|
198
|
+
payment_price: submitProduct.selling_price
|
|
135
199
|
});
|
|
136
200
|
}
|
|
137
201
|
var SUBMIT_BOOKING_METADATA_WHITELIST = ['unique_identification_number', 'collect_pax'];
|
|
@@ -170,6 +234,18 @@ function resolveTableOccupancyDuration(tempOrder) {
|
|
|
170
234
|
}
|
|
171
235
|
return DEFAULT_TABLE_OCCUPANCY_DURATION;
|
|
172
236
|
}
|
|
237
|
+
|
|
238
|
+
/** 提交用人数:有限且为正则向下取整,否则为 1 */
|
|
239
|
+
export function normalizeSubmitCollectPaxValue(value) {
|
|
240
|
+
var n = Number(value);
|
|
241
|
+
return Number.isFinite(n) && n > 0 ? Math.floor(n) : 1;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** 从临时订单 metadata 解析合成 booking 的 collect_pax */
|
|
245
|
+
export function resolveSubmitCollectPax(tempOrder) {
|
|
246
|
+
var _tempOrder$metadata;
|
|
247
|
+
return normalizeSubmitCollectPaxValue((_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.collect_pax);
|
|
248
|
+
}
|
|
173
249
|
export function createDefaultTempOrder(params) {
|
|
174
250
|
var summary = params.summary || createEmptySummary();
|
|
175
251
|
return {
|
|
@@ -219,7 +295,7 @@ export function createDefaultTempOrder(params) {
|
|
|
219
295
|
};
|
|
220
296
|
}
|
|
221
297
|
export function buildSubmitPayload(params) {
|
|
222
|
-
var
|
|
298
|
+
var _ref2, _ref3, _ref4, _tempOrder$is_price_i, _tempOrder$is_deposit;
|
|
223
299
|
var tempOrder = params.tempOrder,
|
|
224
300
|
cacheId = params.cacheId,
|
|
225
301
|
_params$now = params.now,
|
|
@@ -246,7 +322,7 @@ export function buildSubmitPayload(params) {
|
|
|
246
322
|
duration: bookingDuration,
|
|
247
323
|
metadata: {
|
|
248
324
|
unique_identification_number: bookingUuid,
|
|
249
|
-
collect_pax:
|
|
325
|
+
collect_pax: resolveSubmitCollectPax(tempOrder)
|
|
250
326
|
},
|
|
251
327
|
select_date: bookingStart.format('YYYY-MM-DD'),
|
|
252
328
|
is_all: false,
|
|
@@ -266,10 +342,10 @@ export function buildSubmitPayload(params) {
|
|
|
266
342
|
return _objectSpread(_objectSpread({}, tempOrderRest), {}, {
|
|
267
343
|
platform: normalizeSubmitPlatform(platform !== null && platform !== void 0 ? platform : tempOrder.platform),
|
|
268
344
|
request_unique_idempotency_token: cacheId,
|
|
269
|
-
type: (
|
|
270
|
-
business_code: (
|
|
345
|
+
type: (_ref2 = type !== null && type !== void 0 ? type : tempOrder.type) !== null && _ref2 !== void 0 ? _ref2 : 'table-order',
|
|
346
|
+
business_code: (_ref3 = businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code) !== null && _ref3 !== void 0 ? _ref3 : 'table-order',
|
|
271
347
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
272
|
-
order_sales_channel: (
|
|
348
|
+
order_sales_channel: (_ref4 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref4 !== void 0 ? _ref4 : 'online_store',
|
|
273
349
|
status: tempOrder.status || 'normal',
|
|
274
350
|
payment_status: tempOrder.payment_status || 'payment_processing',
|
|
275
351
|
// shipping_status: tempOrder.shipping_status || 'unfulfilled',
|
|
@@ -2,9 +2,10 @@ export interface SalesSummaryProduct {
|
|
|
2
2
|
product_id: number | null;
|
|
3
3
|
product_variant_id: number;
|
|
4
4
|
num: number;
|
|
5
|
+
/** 券后单品单价(订单域成交单价),由 OrderModule 维护。 */
|
|
5
6
|
selling_price: string;
|
|
7
|
+
/** 券前单品单价(店铺售价)。 */
|
|
6
8
|
original_price: string;
|
|
7
|
-
payment_price: string;
|
|
8
9
|
tax_fee: string;
|
|
9
10
|
is_charge_tax?: number;
|
|
10
11
|
product_option_item?: any[];
|
|
@@ -68,7 +68,7 @@ function getBundleUnitPrice(product) {
|
|
|
68
68
|
// 单商品总价口径:主商品单价 + option + bundle(随后再乘商品数量)
|
|
69
69
|
function getUnitPaymentTotal(product) {
|
|
70
70
|
var variantPrice = getVariantPrice(product);
|
|
71
|
-
var basePrice = variantPrice || toDecimal(product.selling_price
|
|
71
|
+
var basePrice = variantPrice || toDecimal(product.selling_price);
|
|
72
72
|
return basePrice.plus(getOptionUnitPrice(product)).plus(getBundleUnitPrice(product));
|
|
73
73
|
}
|
|
74
74
|
function getUnitOriginalTotal(product) {
|
|
@@ -254,9 +254,9 @@ function calculateSingleItemTax(params) {
|
|
|
254
254
|
* 与 Summary/utils.ts 的 getMainProductTotal 逻辑对齐,适配 SalesSummaryProduct 结构。
|
|
255
255
|
*/
|
|
256
256
|
function getMainProductPaymentTotal(product) {
|
|
257
|
-
var
|
|
257
|
+
var _product$metadata$mai, _product$metadata4, _product$_origin3, _product$_origin4;
|
|
258
258
|
var variantPrice = getVariantPrice(product);
|
|
259
|
-
var total = variantPrice || toDecimal((
|
|
259
|
+
var total = variantPrice || toDecimal((_product$metadata$mai = (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.main_product_selling_price) !== null && _product$metadata$mai !== void 0 ? _product$metadata$mai : product.selling_price);
|
|
260
260
|
var mainDiscountList = ((_product$_origin3 = product._origin) === null || _product$_origin3 === void 0 || (_product$_origin3 = _product$_origin3.product) === null || _product$_origin3 === void 0 ? void 0 : _product$_origin3.discount_list) || ((_product$_origin4 = product._origin) === null || _product$_origin4 === void 0 ? void 0 : _product$_origin4.discount_list) || [];
|
|
261
261
|
var mainDiscountAmount = getDiscountListAmount(mainDiscountList.filter(function (d) {
|
|
262
262
|
var _d$metadata;
|
|
@@ -271,8 +271,8 @@ function getMainProductPaymentTotal(product) {
|
|
|
271
271
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
272
272
|
var bundleItem = _step5.value;
|
|
273
273
|
if (isBundleMarkupOrDiscount(bundleItem)) {
|
|
274
|
-
var
|
|
275
|
-
total = total.plus(toDecimal((
|
|
274
|
+
var _ref2, _bundleItem$bundle_se;
|
|
275
|
+
total = total.plus(toDecimal((_ref2 = (_bundleItem$bundle_se = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se !== void 0 ? _bundleItem$bundle_se : bundleItem.price) !== null && _ref2 !== void 0 ? _ref2 : 0));
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
} catch (err) {
|
|
@@ -340,24 +340,24 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
|
|
|
340
340
|
_step7;
|
|
341
341
|
try {
|
|
342
342
|
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
343
|
-
var _bundleItem$num,
|
|
343
|
+
var _bundleItem$num, _ref3, _bundleItem$bundle_se2, _ref4, _ref5, _bundleItem$original_, _ref6, _bundleItem$is_charge, _ref7, _bundleItem$is_charge2;
|
|
344
344
|
var bundleItem = _step7.value;
|
|
345
345
|
if (!isBundleOriginalPrice(bundleItem)) continue;
|
|
346
346
|
var bundleQuantity = new Decimal(getSafeNum((_bundleItem$num = bundleItem.num) !== null && _bundleItem$num !== void 0 ? _bundleItem$num : bundleItem.quantity));
|
|
347
|
-
var bundlePrice = toDecimal((
|
|
348
|
-
var bundleOriginalPrice = toDecimal((
|
|
347
|
+
var bundlePrice = toDecimal((_ref3 = (_bundleItem$bundle_se2 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se2 !== void 0 ? _bundleItem$bundle_se2 : bundleItem.price) !== null && _ref3 !== void 0 ? _ref3 : 0);
|
|
348
|
+
var bundleOriginalPrice = toDecimal((_ref4 = (_ref5 = (_bundleItem$original_ = bundleItem.original_price) !== null && _bundleItem$original_ !== void 0 ? _bundleItem$original_ : bundleItem.product_price) !== null && _ref5 !== void 0 ? _ref5 : bundleItem.price) !== null && _ref4 !== void 0 ? _ref4 : 0);
|
|
349
349
|
var bundleTaxPrecise = calculateSingleItemTax({
|
|
350
350
|
price: bundlePrice,
|
|
351
351
|
taxRate: rate,
|
|
352
352
|
isPriceIncludeTax: isPriceIncludeTax,
|
|
353
|
-
isChargeTax: (
|
|
353
|
+
isChargeTax: (_ref6 = (_bundleItem$is_charge = bundleItem.is_charge_tax) !== null && _bundleItem$is_charge !== void 0 ? _bundleItem$is_charge : product.is_charge_tax) !== null && _ref6 !== void 0 ? _ref6 : 0
|
|
354
354
|
});
|
|
355
355
|
var bundleTaxRounded = bundleTaxPrecise.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
|
|
356
356
|
var bundleOrigTaxPrecise = calculateSingleItemTax({
|
|
357
357
|
price: bundleOriginalPrice,
|
|
358
358
|
taxRate: rate,
|
|
359
359
|
isPriceIncludeTax: isPriceIncludeTax,
|
|
360
|
-
isChargeTax: (
|
|
360
|
+
isChargeTax: (_ref7 = (_bundleItem$is_charge2 = bundleItem.is_charge_tax) !== null && _bundleItem$is_charge2 !== void 0 ? _bundleItem$is_charge2 : product.is_charge_tax) !== null && _ref7 !== void 0 ? _ref7 : 0
|
|
361
361
|
});
|
|
362
362
|
var bundleOrigTaxRounded = bundleOrigTaxPrecise.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
|
|
363
363
|
bundleItem.tax_fee = bundleTaxRounded.toNumber();
|
|
@@ -46,7 +46,7 @@ export declare const formatScheduleResult: (schedule: ScheduleItem) => {
|
|
|
46
46
|
};
|
|
47
47
|
export declare const calcScheduleDateRange: (schedule: ScheduleItem) => any[];
|
|
48
48
|
export declare const calcCalendarDataBySchedules: (schedules: ScheduleItem[]) => unknown[];
|
|
49
|
-
export declare const calcMinTimeMaxTimeBySchedules: (schedules: ScheduleItem[], scheduleAllMap?: ScheduleAllMap, selectDate?: string) =>
|
|
49
|
+
export declare const calcMinTimeMaxTimeBySchedules: (schedules: ScheduleItem[], scheduleAllMap?: ScheduleAllMap, selectDate?: string) => ScheduleAllMap;
|
|
50
50
|
/**
|
|
51
51
|
* @title: 格式化日程数据
|
|
52
52
|
* @description:
|
|
@@ -89,4 +89,9 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
|
|
|
89
89
|
}>;
|
|
90
90
|
getProductList(): Promise<any>;
|
|
91
91
|
getOtherParams(): Record<string, any>;
|
|
92
|
+
setOtherParams(params: Record<string, any>, { cover }?: {
|
|
93
|
+
cover?: boolean;
|
|
94
|
+
}): Promise<void>;
|
|
95
|
+
setEntryPaxNumber(number: number): Promise<void>;
|
|
96
|
+
getEntryPaxNumber(): number | null;
|
|
92
97
|
}
|