@pisell/pisellos 0.0.500 → 0.0.501
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/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Order/index.d.ts +6 -0
- package/dist/modules/Order/index.js +42 -38
- package/dist/modules/Order/types.d.ts +4 -0
- package/dist/modules/Order/utils.d.ts +28 -0
- package/dist/modules/Order/utils.js +93 -13
- package/dist/modules/ProductList/index.js +2 -2
- package/dist/modules/Quotation/index.js +6 -3
- 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/BookingByStep/index.d.ts +2 -2
- package/dist/solution/ScanOrder/index.d.ts +7 -0
- package/dist/solution/ScanOrder/index.js +284 -67
- package/dist/solution/ScanOrder/types.d.ts +22 -5
- package/dist/solution/ScanOrder/utils.d.ts +26 -0
- package/dist/solution/ScanOrder/utils.js +191 -44
- package/dist/solution/VenueBooking/index.d.ts +14 -0
- package/dist/solution/VenueBooking/index.js +318 -144
- 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 +0 -49
- package/lib/modules/Order/index.d.ts +6 -0
- package/lib/modules/Order/index.js +20 -36
- package/lib/modules/Order/types.d.ts +4 -0
- package/lib/modules/Order/utils.d.ts +28 -0
- package/lib/modules/Order/utils.js +78 -9
- package/lib/modules/ProductList/index.js +3 -2
- package/lib/modules/Quotation/index.js +3 -0
- 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/BookingByStep/index.d.ts +2 -2
- package/lib/solution/ScanOrder/index.d.ts +7 -0
- package/lib/solution/ScanOrder/index.js +162 -18
- package/lib/solution/ScanOrder/types.d.ts +22 -5
- package/lib/solution/ScanOrder/utils.d.ts +26 -0
- package/lib/solution/ScanOrder/utils.js +128 -19
- package/lib/solution/VenueBooking/index.d.ts +14 -0
- package/lib/solution/VenueBooking/index.js +156 -30
- 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 评估器的完整输出结果
|
|
@@ -0,0 +1,9 @@
|
|
|
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";
|
|
@@ -76,6 +76,10 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
76
76
|
removeProductFromOrder(identity: ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
|
|
77
77
|
submitTempOrder<T = any>(params?: {
|
|
78
78
|
cacheId?: string;
|
|
79
|
+
platform?: string;
|
|
80
|
+
businessCode?: string;
|
|
81
|
+
channel?: string;
|
|
82
|
+
type?: string;
|
|
79
83
|
}): Promise<T>;
|
|
80
84
|
createOrder(params: CommitOrderParams['query']): {
|
|
81
85
|
type: "virtual" | "appointment_booking";
|
|
@@ -108,4 +112,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
108
112
|
createOrderByCheckout(params: CheckoutOrderParams): Promise<any>;
|
|
109
113
|
submitScanOrder<T = any>(params: SubmitScanOrderParams): Promise<T>;
|
|
110
114
|
scanOrderMore<T = any>(params: ScanOrderMoreParams): Promise<T>;
|
|
115
|
+
getOrderInfoByRemote(order_id: number): Promise<any>;
|
|
116
|
+
getLastOrderInfo(): Record<string, any> | undefined;
|
|
111
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";
|
|
@@ -173,42 +173,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
173
173
|
}, {
|
|
174
174
|
key: "createDefaultRulesHooks",
|
|
175
175
|
value: function createDefaultRulesHooks() {
|
|
176
|
-
return
|
|
177
|
-
getProduct: function getProduct(product) {
|
|
178
|
-
var _product$_origin, _product$_origin2, _product$_origin3, _product$_origin4;
|
|
179
|
-
return {
|
|
180
|
-
id: product.product_id,
|
|
181
|
-
_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),
|
|
182
|
-
price: product.selling_price,
|
|
183
|
-
total: new Decimal(product.payment_price || product.selling_price || 0).times(product.num || 1).toNumber(),
|
|
184
|
-
origin_total: new Decimal(product.original_price || product.selling_price || 0).times(product.num || 1).toNumber(),
|
|
185
|
-
original_price: product.original_price,
|
|
186
|
-
quantity: product.num || 1,
|
|
187
|
-
num: product.num || 1,
|
|
188
|
-
discount_list: product.discount_list || [],
|
|
189
|
-
bundle: product.product_bundle || [],
|
|
190
|
-
booking_id: ((_product$_origin = product._origin) === null || _product$_origin === void 0 ? void 0 : _product$_origin.booking_id) || null,
|
|
191
|
-
isClient: false,
|
|
192
|
-
isManualDiscount: ((_product$_origin2 = product._origin) === null || _product$_origin2 === void 0 ? void 0 : _product$_origin2.isManualDiscount) || false,
|
|
193
|
-
holder_id: (_product$_origin3 = product._origin) === null || _product$_origin3 === void 0 ? void 0 : _product$_origin3.holder_id,
|
|
194
|
-
startDate: (_product$_origin4 = product._origin) === null || _product$_origin4 === void 0 ? void 0 : _product$_origin4.startDate
|
|
195
|
-
};
|
|
196
|
-
},
|
|
197
|
-
setProduct: function setProduct(product, values) {
|
|
198
|
-
var _values$discount_list, _values$quantity, _values$bundle;
|
|
199
|
-
return _objectSpread(_objectSpread({}, product), {}, {
|
|
200
|
-
selling_price: values.price !== undefined ? String(values.price) : product.selling_price,
|
|
201
|
-
payment_price: values.total !== undefined ? String(values.total) : product.payment_price,
|
|
202
|
-
original_price: values.original_price !== undefined ? String(values.original_price) : product.original_price,
|
|
203
|
-
discount_list: (_values$discount_list = values.discount_list) !== null && _values$discount_list !== void 0 ? _values$discount_list : product.discount_list,
|
|
204
|
-
num: (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num,
|
|
205
|
-
product_bundle: (_values$bundle = values.bundle) !== null && _values$bundle !== void 0 ? _values$bundle : product.product_bundle,
|
|
206
|
-
metadata: _objectSpread(_objectSpread({}, product.metadata || {}), values.main_product_selling_price !== undefined ? {
|
|
207
|
-
main_product_selling_price: String(values.main_product_selling_price)
|
|
208
|
-
} : {})
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
};
|
|
176
|
+
return createDefaultOrderRulesHooks();
|
|
212
177
|
}
|
|
213
178
|
|
|
214
179
|
// ─── Discount: 公共 API ───
|
|
@@ -742,7 +707,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
742
707
|
effectiveCacheId = (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId;
|
|
743
708
|
payload = buildSubmitPayload({
|
|
744
709
|
tempOrder: tempOrder,
|
|
745
|
-
cacheId: effectiveCacheId
|
|
710
|
+
cacheId: effectiveCacheId,
|
|
711
|
+
platform: params === null || params === void 0 ? void 0 : params.platform,
|
|
712
|
+
businessCode: params === null || params === void 0 ? void 0 : params.businessCode,
|
|
713
|
+
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
714
|
+
type: params === null || params === void 0 ? void 0 : params.type
|
|
746
715
|
});
|
|
747
716
|
if (!tempOrder.order_id) {
|
|
748
717
|
_context10.next = 12;
|
|
@@ -1101,7 +1070,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1101
1070
|
return _scanOrderMore.apply(this, arguments);
|
|
1102
1071
|
}
|
|
1103
1072
|
return scanOrderMore;
|
|
1073
|
+
}() // TODO 获取详情的接口
|
|
1074
|
+
}, {
|
|
1075
|
+
key: "getOrderInfoByRemote",
|
|
1076
|
+
value: function () {
|
|
1077
|
+
var _getOrderInfoByRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(order_id) {
|
|
1078
|
+
var res;
|
|
1079
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1080
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1081
|
+
case 0:
|
|
1082
|
+
_context15.next = 2;
|
|
1083
|
+
return this.request.get("/order/sales/".concat(order_id), {
|
|
1084
|
+
with: ['products', 'scheduleEvents']
|
|
1085
|
+
});
|
|
1086
|
+
case 2:
|
|
1087
|
+
res = _context15.sent;
|
|
1088
|
+
if (res.code === 200 && this.store.tempOrder) {
|
|
1089
|
+
this.store.tempOrder.lastOrderInfo = res.data;
|
|
1090
|
+
}
|
|
1091
|
+
return _context15.abrupt("return", res);
|
|
1092
|
+
case 5:
|
|
1093
|
+
case "end":
|
|
1094
|
+
return _context15.stop();
|
|
1095
|
+
}
|
|
1096
|
+
}, _callee15, this);
|
|
1097
|
+
}));
|
|
1098
|
+
function getOrderInfoByRemote(_x15) {
|
|
1099
|
+
return _getOrderInfoByRemote.apply(this, arguments);
|
|
1100
|
+
}
|
|
1101
|
+
return getOrderInfoByRemote;
|
|
1104
1102
|
}()
|
|
1103
|
+
}, {
|
|
1104
|
+
key: "getLastOrderInfo",
|
|
1105
|
+
value: function getLastOrderInfo() {
|
|
1106
|
+
var _this$store;
|
|
1107
|
+
return (_this$store = this.store) === null || _this$store === void 0 || (_this$store = _this$store.tempOrder) === null || _this$store === void 0 ? void 0 : _this$store.lastOrderInfo;
|
|
1108
|
+
}
|
|
1105
1109
|
}], [{
|
|
1106
1110
|
key: "populateSavedAmounts",
|
|
1107
1111
|
value:
|
|
@@ -212,6 +212,10 @@ export interface OrderModuleAPI {
|
|
|
212
212
|
persistTempOrder: () => void;
|
|
213
213
|
submitTempOrder: <T = any>(params?: {
|
|
214
214
|
cacheId?: string;
|
|
215
|
+
platform?: string;
|
|
216
|
+
businessCode?: string;
|
|
217
|
+
channel?: string;
|
|
218
|
+
type?: string;
|
|
215
219
|
}) => Promise<T>;
|
|
216
220
|
loadDiscountConfig: (params: {
|
|
217
221
|
customerId: number;
|
|
@@ -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;
|
|
@@ -36,6 +60,10 @@ export declare function buildSubmitPayload(params: {
|
|
|
36
60
|
tempOrder: ScanOrderTempOrder;
|
|
37
61
|
cacheId?: string;
|
|
38
62
|
now?: Date;
|
|
63
|
+
platform?: string;
|
|
64
|
+
businessCode?: string;
|
|
65
|
+
channel?: string;
|
|
66
|
+
type?: string;
|
|
39
67
|
}): ScanOrderSubmitPayload;
|
|
40
68
|
export declare function formatV1Product(products: ScanOrderSubmitProduct[]): {
|
|
41
69
|
bundle: any[];
|
|
@@ -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,11 +295,15 @@ export function createDefaultTempOrder(params) {
|
|
|
219
295
|
};
|
|
220
296
|
}
|
|
221
297
|
export function buildSubmitPayload(params) {
|
|
222
|
-
var _tempOrder$is_price_i, _tempOrder$is_deposit;
|
|
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,
|
|
226
|
-
now = _params$now === void 0 ? new Date() : _params$now
|
|
302
|
+
now = _params$now === void 0 ? new Date() : _params$now,
|
|
303
|
+
platform = params.platform,
|
|
304
|
+
businessCode = params.businessCode,
|
|
305
|
+
channel = params.channel,
|
|
306
|
+
type = params.type;
|
|
227
307
|
var scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
|
|
228
308
|
var summary = tempOrder.summary || createEmptySummary();
|
|
229
309
|
var relationId = tempOrder.relation_id;
|
|
@@ -242,7 +322,7 @@ export function buildSubmitPayload(params) {
|
|
|
242
322
|
duration: bookingDuration,
|
|
243
323
|
metadata: {
|
|
244
324
|
unique_identification_number: bookingUuid,
|
|
245
|
-
collect_pax:
|
|
325
|
+
collect_pax: resolveSubmitCollectPax(tempOrder)
|
|
246
326
|
},
|
|
247
327
|
select_date: bookingStart.format('YYYY-MM-DD'),
|
|
248
328
|
is_all: false,
|
|
@@ -260,12 +340,12 @@ export function buildSubmitPayload(params) {
|
|
|
260
340
|
_surcharges = tempOrder.surcharges,
|
|
261
341
|
tempOrderRest = _objectWithoutProperties(tempOrder, _excluded2);
|
|
262
342
|
return _objectSpread(_objectSpread({}, tempOrderRest), {}, {
|
|
263
|
-
platform: normalizeSubmitPlatform(tempOrder.platform),
|
|
343
|
+
platform: normalizeSubmitPlatform(platform !== null && platform !== void 0 ? platform : tempOrder.platform),
|
|
264
344
|
request_unique_idempotency_token: cacheId,
|
|
265
|
-
type: tempOrder.type
|
|
266
|
-
business_code: tempOrder.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',
|
|
267
347
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
268
|
-
order_sales_channel: tempOrder.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',
|
|
269
349
|
status: tempOrder.status || 'normal',
|
|
270
350
|
payment_status: tempOrder.payment_status || 'payment_processing',
|
|
271
351
|
// shipping_status: tempOrder.shipping_status || 'unfulfilled',
|
|
@@ -85,7 +85,6 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
85
85
|
key: "loadProducts",
|
|
86
86
|
value: function () {
|
|
87
87
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref, options) {
|
|
88
|
-
var _this$otherParams;
|
|
89
88
|
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$menu_list_ids, menu_list_ids, paramsCustomerId, _ref$with_count, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, userPlugin, customer_id, _userPlugin$get, productsData, sortedList;
|
|
90
89
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
91
90
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -131,7 +130,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
131
130
|
schedule_date: schedule_date,
|
|
132
131
|
with_schedule: with_schedule,
|
|
133
132
|
schedule_datetime: schedule_datetime,
|
|
134
|
-
application_code:
|
|
133
|
+
// application_code: this.otherParams?.channel,
|
|
134
|
+
application_code: 'online-store',
|
|
135
135
|
is_eject: 1
|
|
136
136
|
}, {
|
|
137
137
|
osServer: true,
|