@pisell/pisellos 2.3.212 → 2.3.214
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Discount/availability.d.ts +2 -0
- package/dist/modules/Discount/availability.js +26 -6
- package/dist/modules/Discount/index.js +7 -3
- package/dist/modules/Discount/types.d.ts +1 -1
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/solution/BaseSales/index.js +1 -0
- package/dist/solution/BaseSales/types.d.ts +2 -0
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.js +1 -0
- package/dist/solution/ScanOrder/index.js +53 -21
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Discount/availability.d.ts +2 -0
- package/lib/modules/Discount/availability.js +26 -5
- package/lib/modules/Discount/index.js +4 -2
- package/lib/modules/Discount/types.d.ts +1 -1
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/solution/BaseSales/index.js +1 -0
- package/lib/solution/BaseSales/types.d.ts +2 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.js +1 -0
- package/lib/solution/ScanOrder/index.js +21 -5
- package/package.json +1 -1
|
@@ -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, ITEM_REWARD_STRATEGY } from "./examples";
|
|
@@ -4,4 +4,6 @@ export declare function getDiscountUsageLimitFailKey(discount: Discount): Discou
|
|
|
4
4
|
export declare function hasAvailableDiscountBalance(discount: Discount): boolean;
|
|
5
5
|
/** 按卡本身当前生命周期判断;预约时间或一次日程不匹配不代表已失效。 */
|
|
6
6
|
export declare function getDiscountLifecycleReason(discount: Discount): 'disabled' | 'exhausted' | 'expired' | undefined;
|
|
7
|
+
/** 仅用于扫码被过滤后的提示;不改变卡券过滤、优惠计算或列表保留规则。 */
|
|
8
|
+
export declare function getDiscountFilterRejectKey(discount: Discount): DiscountFilterRejectKey | null;
|
|
7
9
|
export declare function getDiscountUsageBlockReason(discount: Discount): string | undefined;
|
|
@@ -27,23 +27,43 @@ export function hasAvailableDiscountBalance(discount) {
|
|
|
27
27
|
if (isEntitlementPass(discount)) return hasAvailableEntitlementUses(discount);
|
|
28
28
|
return new Decimal(discount.par_value || 0).minus(discount.used_par_value || 0).greaterThan(0);
|
|
29
29
|
}
|
|
30
|
+
function isDiscountExpired(discount) {
|
|
31
|
+
var _discount$metadata;
|
|
32
|
+
// 自定义日程沿用快照语义,不使用遗留固定有效期字段推断过期。
|
|
33
|
+
if (((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.validity_type) !== 'custom_schedule_validity' && discount.expire_time) {
|
|
34
|
+
var expiry = dayjs(discount.expire_time);
|
|
35
|
+
return expiry.isValid() && !dayjs().isBefore(expiry);
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
30
39
|
|
|
31
40
|
/** 按卡本身当前生命周期判断;预约时间或一次日程不匹配不代表已失效。 */
|
|
32
41
|
export function getDiscountLifecycleReason(discount) {
|
|
33
|
-
var _discount$metadata;
|
|
34
42
|
if (discount.limit_status && discount.limit_status !== 'enable') {
|
|
35
43
|
return 'disabled';
|
|
36
44
|
}
|
|
37
45
|
if ((isEntitlementPass(discount) || discount.par_value != null) && !hasAvailableDiscountBalance(discount) || getDiscountUsageLimitFailKey(discount) === 'total_credits') {
|
|
38
46
|
return 'exhausted';
|
|
39
47
|
}
|
|
40
|
-
|
|
41
|
-
if (((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.validity_type) !== 'custom_schedule_validity' && discount.expire_time) {
|
|
42
|
-
var expiry = dayjs(discount.expire_time);
|
|
43
|
-
if (expiry.isValid() && !dayjs().isBefore(expiry)) return 'expired';
|
|
44
|
-
}
|
|
48
|
+
if (isDiscountExpired(discount)) return 'expired';
|
|
45
49
|
return undefined;
|
|
46
50
|
}
|
|
51
|
+
|
|
52
|
+
/** 仅用于扫码被过滤后的提示;不改变卡券过滤、优惠计算或列表保留规则。 */
|
|
53
|
+
export function getDiscountFilterRejectKey(discount) {
|
|
54
|
+
var lifecycleReason = getDiscountLifecycleReason(discount);
|
|
55
|
+
if (lifecycleReason === 'disabled') return 'disabled';
|
|
56
|
+
// 卡片同时过期、额度耗尽时,扫码提示优先说明已过期。
|
|
57
|
+
if (isDiscountExpired(discount)) return 'expired';
|
|
58
|
+
if ((discount.tag || discount.type) === 'product_discount_card' && new Decimal(discount.par_value || 0).lessThanOrEqualTo(0)) {
|
|
59
|
+
return 'invalid_discount_value';
|
|
60
|
+
}
|
|
61
|
+
var usageLimitFailKey = getDiscountUsageLimitFailKey(discount);
|
|
62
|
+
if (lifecycleReason === 'exhausted') {
|
|
63
|
+
return usageLimitFailKey === 'total_credits' ? usageLimitFailKey : 'exhausted';
|
|
64
|
+
}
|
|
65
|
+
return usageLimitFailKey;
|
|
66
|
+
}
|
|
47
67
|
export function getDiscountUsageBlockReason(discount) {
|
|
48
68
|
return getDiscountLifecycleReason(discount) || getDiscountUsageLimitFailKey(discount) || (discount.unified_available_status != null && String(discount.unified_available_status) !== '' && Number(discount.unified_available_status) === 0 ? 'server_unavailable' : undefined);
|
|
49
69
|
}
|
|
@@ -29,7 +29,7 @@ import { uniqueById } from "../../solution/ShopDiscount/utils";
|
|
|
29
29
|
import { BaseModule } from "../BaseModule";
|
|
30
30
|
import { DiscountHooks } from "./types";
|
|
31
31
|
import Decimal from 'decimal.js';
|
|
32
|
-
import { getDiscountLifecycleReason, getDiscountUsageBlockReason, getDiscountUsageLimitFailKey, hasAvailableDiscountBalance } from "./availability";
|
|
32
|
+
import { getDiscountFilterRejectKey, getDiscountLifecycleReason, getDiscountUsageBlockReason, getDiscountUsageLimitFailKey, hasAvailableDiscountBalance } from "./availability";
|
|
33
33
|
export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
34
34
|
_inherits(DiscountModule, _BaseModule);
|
|
35
35
|
var _super = _createSuper(DiscountModule);
|
|
@@ -341,9 +341,13 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
341
341
|
}, {
|
|
342
342
|
key: "filterEnabledDiscountListWithReason",
|
|
343
343
|
value: function filterEnabledDiscountListWithReason(discountList) {
|
|
344
|
+
var enabledDiscountList = this.filterEnabledDiscountList(discountList);
|
|
344
345
|
return {
|
|
345
|
-
discountList:
|
|
346
|
-
|
|
346
|
+
discountList: enabledDiscountList,
|
|
347
|
+
// 查到卡但全部被过滤时保留具体原因;空响应仍沿用无效码提示。
|
|
348
|
+
unavailableReasonKey: discountList.length > 0 && !enabledDiscountList.length ? discountList.map(getDiscountFilterRejectKey).find(function (key) {
|
|
349
|
+
return key !== null;
|
|
350
|
+
}) || 'unavailable' : discountList.map(getDiscountUsageLimitFailKey).find(function (key) {
|
|
347
351
|
return key !== null;
|
|
348
352
|
}) || null
|
|
349
353
|
};
|
|
@@ -73,7 +73,7 @@ export type IncludedUses = {
|
|
|
73
73
|
type: 'unlimited';
|
|
74
74
|
value: null;
|
|
75
75
|
};
|
|
76
|
-
export type DiscountFilterRejectKey = 'total_credits' | 'per_user_limit' | 'max_per_day' | 'max_per_week' | 'max_per_month';
|
|
76
|
+
export type DiscountFilterRejectKey = 'disabled' | 'expired' | 'exhausted' | 'invalid_discount_value' | 'unavailable' | 'total_credits' | 'per_user_limit' | 'max_per_day' | 'max_per_week' | 'max_per_month';
|
|
77
77
|
export interface DiscountWithReason {
|
|
78
78
|
discountList: Discount[];
|
|
79
79
|
unavailableReasonKey: DiscountFilterRejectKey | null;
|
|
@@ -640,7 +640,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
640
640
|
generateIdempotencyToken(): string;
|
|
641
641
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
642
642
|
createOrder(params: CommitOrderParams['query']): {
|
|
643
|
-
type: "
|
|
643
|
+
type: "virtual" | "appointment_booking";
|
|
644
644
|
platform: string;
|
|
645
645
|
sales_channel: string;
|
|
646
646
|
order_sales_channel: string;
|
|
@@ -181,6 +181,8 @@ export interface OrderScanCodeResult {
|
|
|
181
181
|
scannedDiscountList: Discount[];
|
|
182
182
|
type: 'server' | 'clientCalc';
|
|
183
183
|
unavailableReason?: UnavailableReason;
|
|
184
|
+
/** 扫码过滤原因,供销售层透传给提示组件。 */
|
|
185
|
+
unavailableReasonKey?: string | null;
|
|
184
186
|
}
|
|
185
187
|
export interface OrderProductIdentity {
|
|
186
188
|
product_id: number | null;
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "normal" | "
|
|
52
|
+
getProductType(): "normal" | "session" | "duration";
|
|
53
53
|
}
|
|
@@ -4306,6 +4306,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4306
4306
|
} : {}), {}, {
|
|
4307
4307
|
type: raw.type,
|
|
4308
4308
|
unavailableReason: raw.unavailableReason,
|
|
4309
|
+
unavailableReasonKey: raw.unavailableReasonKey,
|
|
4309
4310
|
scannedDiscountList: raw.scannedDiscountList
|
|
4310
4311
|
}));
|
|
4311
4312
|
case 16:
|
|
@@ -465,6 +465,8 @@ export interface BaseSalesScanCodeResult {
|
|
|
465
465
|
isAccepted?: boolean;
|
|
466
466
|
type?: 'server' | string;
|
|
467
467
|
unavailableReason?: 'time_limit' | string;
|
|
468
|
+
/** 扫码过滤原因(禁用、过期、额度或次数限制等);仅用于提示。 */
|
|
469
|
+
unavailableReasonKey?: string | null;
|
|
468
470
|
/** 扫码卡券资料及最新可用状态,供 Holder 补全等流程使用。 */
|
|
469
471
|
scannedDiscountList?: Discount[];
|
|
470
472
|
}
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 | 2 | 1 |
|
|
345
|
+
weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
389
389
|
};
|
|
390
390
|
setOtherData(key: string, value: any): void;
|
|
391
391
|
getOtherData(key: string): any;
|
|
392
|
-
getProductTypeById(id: number): Promise<"normal" | "
|
|
392
|
+
getProductTypeById(id: number): Promise<"normal" | "session" | "duration">;
|
|
393
393
|
/**
|
|
394
394
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
395
395
|
*
|
|
@@ -880,6 +880,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
880
880
|
} : {}), {}, {
|
|
881
881
|
type: raw.type,
|
|
882
882
|
unavailableReason: raw.unavailableReason,
|
|
883
|
+
unavailableReasonKey: raw.unavailableReasonKey,
|
|
883
884
|
scannedDiscountList: raw.scannedDiscountList
|
|
884
885
|
}));
|
|
885
886
|
case 26:
|
|
@@ -1358,7 +1358,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1358
1358
|
return 1;
|
|
1359
1359
|
};
|
|
1360
1360
|
return function (payload, _ref3) {
|
|
1361
|
-
var _resourceState$relati, _tempOrder$metadata, _ref4,
|
|
1361
|
+
var _resourceState$relati, _tempOrder$metadata, _resourceState$table_2, _this5$core, _this5$core$getPlugin, _this5$core$getPlugin2, _coreState$core, _ref4, _ref5, _ref6, _ref7, _pickFromCandidates, _resourceState$table_3, _resourceState$relati2, _pickFirstCustomCapac;
|
|
1362
1362
|
var bookingUuid = _ref3.bookingUuid,
|
|
1363
1363
|
tempOrder = _ref3.tempOrder,
|
|
1364
1364
|
now = _ref3.now;
|
|
@@ -1373,14 +1373,46 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1373
1373
|
var rawCollectPax = (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.collect_pax;
|
|
1374
1374
|
var hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
|
|
1375
1375
|
var bookingCapacityValue = resolveBookingCapacityValue();
|
|
1376
|
-
var
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1376
|
+
var resourceNameCandidates = [tempOrder.table_number, resourceState === null || resourceState === void 0 || (_resourceState$table_2 = resourceState.table_form_record) === null || _resourceState$table_2 === void 0 ? void 0 : _resourceState$table_2.name];
|
|
1377
|
+
var toNonEmptyString = function toNonEmptyString(value) {
|
|
1378
|
+
return typeof value === 'string' && value.trim().length > 0 ? value : undefined;
|
|
1379
|
+
};
|
|
1380
|
+
var toNameMap = function toNameMap(value) {
|
|
1381
|
+
return value && _typeof(value) === 'object' && !Array.isArray(value) ? value : undefined;
|
|
1382
|
+
};
|
|
1383
|
+
var pickFromCandidates = function pickFromCandidates(picker) {
|
|
1384
|
+
for (var _i3 = 0, _resourceNameCandidat = resourceNameCandidates; _i3 < _resourceNameCandidat.length; _i3++) {
|
|
1385
|
+
var candidate = _resourceNameCandidat[_i3];
|
|
1386
|
+
var resolved = picker(candidate);
|
|
1387
|
+
if (resolved !== undefined) return resolved;
|
|
1388
|
+
}
|
|
1389
|
+
return undefined;
|
|
1390
|
+
};
|
|
1391
|
+
var pickDirectOrOriginal = function pickDirectOrOriginal(value) {
|
|
1392
|
+
var _toNonEmptyString, _toNameMap;
|
|
1393
|
+
return (_toNonEmptyString = toNonEmptyString(value)) !== null && _toNonEmptyString !== void 0 ? _toNonEmptyString : toNonEmptyString((_toNameMap = toNameMap(value)) === null || _toNameMap === void 0 ? void 0 : _toNameMap.original);
|
|
1394
|
+
};
|
|
1395
|
+
var pickLocalized = function pickLocalized(value, locale) {
|
|
1396
|
+
var _toNameMap2;
|
|
1397
|
+
return toNonEmptyString((_toNameMap2 = toNameMap(value)) === null || _toNameMap2 === void 0 ? void 0 : _toNameMap2[locale]);
|
|
1398
|
+
};
|
|
1399
|
+
var pickFirstNonEmpty = function pickFirstNonEmpty(value) {
|
|
1400
|
+
var nameMap = toNameMap(value);
|
|
1401
|
+
if (!nameMap) return undefined;
|
|
1402
|
+
for (var _i4 = 0, _Object$values = Object.values(nameMap); _i4 < _Object$values.length; _i4++) {
|
|
1403
|
+
var candidate = _Object$values[_i4];
|
|
1404
|
+
var resolved = toNonEmptyString(candidate);
|
|
1405
|
+
if (resolved !== undefined) return resolved;
|
|
1380
1406
|
}
|
|
1381
1407
|
return undefined;
|
|
1382
1408
|
};
|
|
1383
|
-
var
|
|
1409
|
+
var coreState = (_this5$core = _this5.core) === null || _this5$core === void 0 || (_this5$core$getPlugin = _this5$core.getPlugin) === null || _this5$core$getPlugin === void 0 || (_this5$core$getPlugin = _this5$core$getPlugin.call(_this5$core, 'shopStore')) === null || _this5$core$getPlugin === void 0 || (_this5$core$getPlugin2 = _this5$core$getPlugin.get) === null || _this5$core$getPlugin2 === void 0 ? void 0 : _this5$core$getPlugin2.call(_this5$core$getPlugin, 'core');
|
|
1410
|
+
var activeLocale = String((coreState === null || coreState === void 0 ? void 0 : coreState.translateLocale) || (coreState === null || coreState === void 0 || (_coreState$core = coreState.core) === null || _coreState$core === void 0 || (_coreState$core = _coreState$core.shop) === null || _coreState$core === void 0 ? void 0 : _coreState$core.primary_locale) || 'en');
|
|
1411
|
+
var mainField = (_ref4 = (_ref5 = (_ref6 = (_ref7 = (_pickFromCandidates = pickFromCandidates(pickDirectOrOriginal)) !== null && _pickFromCandidates !== void 0 ? _pickFromCandidates : toNonEmptyString(resourceState === null || resourceState === void 0 || (_resourceState$table_3 = resourceState.table_form_record) === null || _resourceState$table_3 === void 0 ? void 0 : _resourceState$table_3.main_field)) !== null && _ref7 !== void 0 ? _ref7 : pickFromCandidates(function (value) {
|
|
1412
|
+
return pickLocalized(value, activeLocale);
|
|
1413
|
+
})) !== null && _ref6 !== void 0 ? _ref6 : pickFromCandidates(function (value) {
|
|
1414
|
+
return pickLocalized(value, 'en');
|
|
1415
|
+
})) !== null && _ref5 !== void 0 ? _ref5 : pickFromCandidates(pickFirstNonEmpty)) !== null && _ref4 !== void 0 ? _ref4 : '';
|
|
1384
1416
|
var resourceEntry = resourceState && resourceId ? {
|
|
1385
1417
|
relation_type: 'form',
|
|
1386
1418
|
like_status: 'common',
|
|
@@ -1448,9 +1480,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1448
1480
|
var nextProducts = _toConsumableArray(payload.products || []);
|
|
1449
1481
|
// 加餐(已有 order_id)走 scanOrderMore,原单已含 booking 规则行,勿再追加虚拟规则商品
|
|
1450
1482
|
if (ruleProduct && ruleProductUid && !tempOrder.order_id) {
|
|
1451
|
-
var _ruleProduct$price,
|
|
1483
|
+
var _ruleProduct$price, _ref8, _ruleProduct$original, _ruleProduct$is_gst;
|
|
1452
1484
|
var sellingPrice = String((_ruleProduct$price = ruleProduct.price) !== null && _ruleProduct$price !== void 0 ? _ruleProduct$price : '0.00');
|
|
1453
|
-
var originalPrice = String((
|
|
1485
|
+
var originalPrice = String((_ref8 = (_ruleProduct$original = ruleProduct.original_price) !== null && _ruleProduct$original !== void 0 ? _ruleProduct$original : ruleProduct.price) !== null && _ref8 !== void 0 ? _ref8 : '0.00');
|
|
1454
1486
|
nextProducts.push({
|
|
1455
1487
|
product_id: ruleProduct.id,
|
|
1456
1488
|
product_variant_id: 0,
|
|
@@ -1570,8 +1602,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1570
1602
|
var product = _step5.value;
|
|
1571
1603
|
var uid = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.unique_identification_number;
|
|
1572
1604
|
var origins = [product._origin, (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.origin, uid ? (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.productsByUid) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend[String(uid)]) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.origin : undefined];
|
|
1573
|
-
for (var
|
|
1574
|
-
var origin = _origins[
|
|
1605
|
+
for (var _i5 = 0, _origins = origins; _i5 < _origins.length; _i5++) {
|
|
1606
|
+
var origin = _origins[_i5];
|
|
1575
1607
|
if (origin && _typeof(origin) === 'object' && !Array.isArray(origin)) {
|
|
1576
1608
|
sources.push(_objectSpread(_objectSpread({}, origin), {}, {
|
|
1577
1609
|
product_id: product.product_id
|
|
@@ -2105,16 +2137,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2105
2137
|
var rawProductId = (_node$product_id = node.product_id) !== null && _node$product_id !== void 0 ? _node$product_id : node.id;
|
|
2106
2138
|
var productId = Number(rawProductId);
|
|
2107
2139
|
if (Number.isFinite(productId) && productId > 0) {
|
|
2108
|
-
var
|
|
2109
|
-
var productVariantId = Number((
|
|
2140
|
+
var _ref9, _node$product_variant;
|
|
2141
|
+
var productVariantId = Number((_ref9 = (_node$product_variant = node.product_variant_id) !== null && _node$product_variant !== void 0 ? _node$product_variant : node.variant_id) !== null && _ref9 !== void 0 ? _ref9 : 0);
|
|
2110
2142
|
var normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
|
|
2111
2143
|
var key = buildProductKey(productId, normalizedVariantId);
|
|
2112
2144
|
if (!sourceMap.has(key)) {
|
|
2113
2145
|
sourceMap.set(key, node);
|
|
2114
2146
|
}
|
|
2115
2147
|
}
|
|
2116
|
-
for (var
|
|
2117
|
-
var childValue = _Object$
|
|
2148
|
+
for (var _i6 = 0, _Object$values2 = Object.values(node); _i6 < _Object$values2.length; _i6++) {
|
|
2149
|
+
var childValue = _Object$values2[_i6];
|
|
2118
2150
|
if (childValue && _typeof(childValue) === 'object') {
|
|
2119
2151
|
collectFromValue(childValue);
|
|
2120
2152
|
}
|
|
@@ -2143,10 +2175,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2143
2175
|
}, {
|
|
2144
2176
|
key: "getItemRuleRuntimeConfig",
|
|
2145
2177
|
value: function getItemRuleRuntimeConfig() {
|
|
2146
|
-
var
|
|
2178
|
+
var _ref10, _runtimeConfig$channe, _runtimeConfig$custom, _this$otherParams14;
|
|
2147
2179
|
var runtimeConfig = this.itemRuleRuntimeConfig || {};
|
|
2148
2180
|
return _objectSpread(_objectSpread({}, runtimeConfig), {}, {
|
|
2149
|
-
channel: (
|
|
2181
|
+
channel: (_ref10 = (_runtimeConfig$channe = runtimeConfig.channel) !== null && _runtimeConfig$channe !== void 0 ? _runtimeConfig$channe : (_runtimeConfig$custom = runtimeConfig.custom) === null || _runtimeConfig$custom === void 0 ? void 0 : _runtimeConfig$custom.channel) !== null && _ref10 !== void 0 ? _ref10 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.channel
|
|
2150
2182
|
});
|
|
2151
2183
|
}
|
|
2152
2184
|
}, {
|
|
@@ -3367,14 +3399,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3367
3399
|
key: "setOtherParams",
|
|
3368
3400
|
value: function () {
|
|
3369
3401
|
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
3370
|
-
var
|
|
3371
|
-
|
|
3402
|
+
var _ref12,
|
|
3403
|
+
_ref12$cover,
|
|
3372
3404
|
cover,
|
|
3373
3405
|
_args41 = arguments;
|
|
3374
3406
|
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3375
3407
|
while (1) switch (_context41.prev = _context41.next) {
|
|
3376
3408
|
case 0:
|
|
3377
|
-
|
|
3409
|
+
_ref12 = _args41.length > 1 && _args41[1] !== undefined ? _args41[1] : {}, _ref12$cover = _ref12.cover, cover = _ref12$cover === void 0 ? false : _ref12$cover;
|
|
3378
3410
|
if (cover) {
|
|
3379
3411
|
this.otherParams = params;
|
|
3380
3412
|
} else {
|
|
@@ -3525,7 +3557,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3525
3557
|
key: "syncAdditionalOrderFromResource",
|
|
3526
3558
|
value: function () {
|
|
3527
3559
|
var _syncAdditionalOrderFromResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(resourceId) {
|
|
3528
|
-
var
|
|
3560
|
+
var _ref13, _ref14, _ref15, _this$store$resource5, _this$store$resource6, _occupyDetails$2, _this$store$resource7, _this$otherParams22, _this$store$resource8, _this$store$order8;
|
|
3529
3561
|
var tempOrder, normalizedResourceId, _result, occupyDetails, occupyDetail, resourceSelectType, allowAddItems, result, resourceState;
|
|
3530
3562
|
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3531
3563
|
while (1) switch (_context43.prev = _context43.next) {
|
|
@@ -3537,7 +3569,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3537
3569
|
throw new Error('order 模块未初始化');
|
|
3538
3570
|
case 2:
|
|
3539
3571
|
tempOrder = this.store.order.ensureTempOrder();
|
|
3540
|
-
normalizedResourceId = String((
|
|
3572
|
+
normalizedResourceId = String((_ref13 = (_ref14 = (_ref15 = resourceId !== null && resourceId !== void 0 ? resourceId : tempOrder.resource_id) !== null && _ref15 !== void 0 ? _ref15 : (_this$store$resource5 = this.store.resource) === null || _this$store$resource5 === void 0 ? void 0 : _this$store$resource5.relationId) !== null && _ref14 !== void 0 ? _ref14 : (_this$store$resource6 = this.store.resource) === null || _this$store$resource6 === void 0 ? void 0 : _this$store$resource6.relation_id) !== null && _ref13 !== void 0 ? _ref13 : '').trim();
|
|
3541
3573
|
this.logMethodStart('syncAdditionalOrderFromResource', {
|
|
3542
3574
|
resourceId: normalizedResourceId
|
|
3543
3575
|
});
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _adapter.PromotionAdapter;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _evaluator.PromotionEvaluator;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "default", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _adapter.default;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
var _evaluator = require("./evaluator");
|
|
43
|
-
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
-
var _examples = require("./examples");
|
|
45
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
1
|
+
"use strict";
|
|
@@ -4,4 +4,6 @@ export declare function getDiscountUsageLimitFailKey(discount: Discount): Discou
|
|
|
4
4
|
export declare function hasAvailableDiscountBalance(discount: Discount): boolean;
|
|
5
5
|
/** 按卡本身当前生命周期判断;预约时间或一次日程不匹配不代表已失效。 */
|
|
6
6
|
export declare function getDiscountLifecycleReason(discount: Discount): 'disabled' | 'exhausted' | 'expired' | undefined;
|
|
7
|
+
/** 仅用于扫码被过滤后的提示;不改变卡券过滤、优惠计算或列表保留规则。 */
|
|
8
|
+
export declare function getDiscountFilterRejectKey(discount: Discount): DiscountFilterRejectKey | null;
|
|
7
9
|
export declare function getDiscountUsageBlockReason(discount: Discount): string | undefined;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.getDiscountFilterRejectKey = getDiscountFilterRejectKey;
|
|
6
7
|
exports.getDiscountLifecycleReason = getDiscountLifecycleReason;
|
|
7
8
|
exports.getDiscountUsageBlockReason = getDiscountUsageBlockReason;
|
|
8
9
|
exports.getDiscountUsageLimitFailKey = getDiscountUsageLimitFailKey;
|
|
@@ -22,6 +23,14 @@ function hasAvailableDiscountBalance(discount) {
|
|
|
22
23
|
if ((0, _entitlementPass.isEntitlementPass)(discount)) return (0, _entitlementPass.hasAvailableEntitlementUses)(discount);
|
|
23
24
|
return new _decimal.default(discount.par_value || 0).minus(discount.used_par_value || 0).greaterThan(0);
|
|
24
25
|
}
|
|
26
|
+
function isDiscountExpired(discount) {
|
|
27
|
+
// 自定义日程沿用快照语义,不使用遗留固定有效期字段推断过期。
|
|
28
|
+
if (discount.metadata?.validity_type !== 'custom_schedule_validity' && discount.expire_time) {
|
|
29
|
+
const expiry = (0, _dayjs.default)(discount.expire_time);
|
|
30
|
+
return expiry.isValid() && !(0, _dayjs.default)().isBefore(expiry);
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
25
34
|
|
|
26
35
|
/** 按卡本身当前生命周期判断;预约时间或一次日程不匹配不代表已失效。 */
|
|
27
36
|
function getDiscountLifecycleReason(discount) {
|
|
@@ -31,13 +40,25 @@ function getDiscountLifecycleReason(discount) {
|
|
|
31
40
|
if (((0, _entitlementPass.isEntitlementPass)(discount) || discount.par_value != null) && !hasAvailableDiscountBalance(discount) || getDiscountUsageLimitFailKey(discount) === 'total_credits') {
|
|
32
41
|
return 'exhausted';
|
|
33
42
|
}
|
|
34
|
-
|
|
35
|
-
if (discount.metadata?.validity_type !== 'custom_schedule_validity' && discount.expire_time) {
|
|
36
|
-
const expiry = (0, _dayjs.default)(discount.expire_time);
|
|
37
|
-
if (expiry.isValid() && !(0, _dayjs.default)().isBefore(expiry)) return 'expired';
|
|
38
|
-
}
|
|
43
|
+
if (isDiscountExpired(discount)) return 'expired';
|
|
39
44
|
return undefined;
|
|
40
45
|
}
|
|
46
|
+
|
|
47
|
+
/** 仅用于扫码被过滤后的提示;不改变卡券过滤、优惠计算或列表保留规则。 */
|
|
48
|
+
function getDiscountFilterRejectKey(discount) {
|
|
49
|
+
const lifecycleReason = getDiscountLifecycleReason(discount);
|
|
50
|
+
if (lifecycleReason === 'disabled') return 'disabled';
|
|
51
|
+
// 卡片同时过期、额度耗尽时,扫码提示优先说明已过期。
|
|
52
|
+
if (isDiscountExpired(discount)) return 'expired';
|
|
53
|
+
if ((discount.tag || discount.type) === 'product_discount_card' && new _decimal.default(discount.par_value || 0).lessThanOrEqualTo(0)) {
|
|
54
|
+
return 'invalid_discount_value';
|
|
55
|
+
}
|
|
56
|
+
const usageLimitFailKey = getDiscountUsageLimitFailKey(discount);
|
|
57
|
+
if (lifecycleReason === 'exhausted') {
|
|
58
|
+
return usageLimitFailKey === 'total_credits' ? usageLimitFailKey : 'exhausted';
|
|
59
|
+
}
|
|
60
|
+
return usageLimitFailKey;
|
|
61
|
+
}
|
|
41
62
|
function getDiscountUsageBlockReason(discount) {
|
|
42
63
|
return getDiscountLifecycleReason(discount) || getDiscountUsageLimitFailKey(discount) || (discount.unified_available_status != null && String(discount.unified_available_status) !== '' && Number(discount.unified_available_status) === 0 ? 'server_unavailable' : undefined);
|
|
43
64
|
}
|
|
@@ -180,9 +180,11 @@ class DiscountModule extends _BaseModule.BaseModule {
|
|
|
180
180
|
}));
|
|
181
181
|
}
|
|
182
182
|
filterEnabledDiscountListWithReason(discountList) {
|
|
183
|
+
const enabledDiscountList = this.filterEnabledDiscountList(discountList);
|
|
183
184
|
return {
|
|
184
|
-
discountList:
|
|
185
|
-
|
|
185
|
+
discountList: enabledDiscountList,
|
|
186
|
+
// 查到卡但全部被过滤时保留具体原因;空响应仍沿用无效码提示。
|
|
187
|
+
unavailableReasonKey: discountList.length > 0 && !enabledDiscountList.length ? discountList.map(_availability.getDiscountFilterRejectKey).find(key => key !== null) || 'unavailable' : discountList.map(_availability.getDiscountUsageLimitFailKey).find(key => key !== null) || null
|
|
186
188
|
};
|
|
187
189
|
}
|
|
188
190
|
|
|
@@ -73,7 +73,7 @@ export type IncludedUses = {
|
|
|
73
73
|
type: 'unlimited';
|
|
74
74
|
value: null;
|
|
75
75
|
};
|
|
76
|
-
export type DiscountFilterRejectKey = 'total_credits' | 'per_user_limit' | 'max_per_day' | 'max_per_week' | 'max_per_month';
|
|
76
|
+
export type DiscountFilterRejectKey = 'disabled' | 'expired' | 'exhausted' | 'invalid_discount_value' | 'unavailable' | 'total_credits' | 'per_user_limit' | 'max_per_day' | 'max_per_week' | 'max_per_month';
|
|
77
77
|
export interface DiscountWithReason {
|
|
78
78
|
discountList: Discount[];
|
|
79
79
|
unavailableReasonKey: DiscountFilterRejectKey | null;
|
|
@@ -640,7 +640,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
640
640
|
generateIdempotencyToken(): string;
|
|
641
641
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
642
642
|
createOrder(params: CommitOrderParams['query']): {
|
|
643
|
-
type: "
|
|
643
|
+
type: "virtual" | "appointment_booking";
|
|
644
644
|
platform: string;
|
|
645
645
|
sales_channel: string;
|
|
646
646
|
order_sales_channel: string;
|
|
@@ -181,6 +181,8 @@ export interface OrderScanCodeResult {
|
|
|
181
181
|
scannedDiscountList: Discount[];
|
|
182
182
|
type: 'server' | 'clientCalc';
|
|
183
183
|
unavailableReason?: UnavailableReason;
|
|
184
|
+
/** 扫码过滤原因,供销售层透传给提示组件。 */
|
|
185
|
+
unavailableReasonKey?: string | null;
|
|
184
186
|
}
|
|
185
187
|
export interface OrderProductIdentity {
|
|
186
188
|
product_id: number | null;
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "normal" | "
|
|
52
|
+
getProductType(): "normal" | "session" | "duration";
|
|
53
53
|
}
|
|
@@ -2628,6 +2628,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2628
2628
|
} : {}),
|
|
2629
2629
|
type: raw.type,
|
|
2630
2630
|
unavailableReason: raw.unavailableReason,
|
|
2631
|
+
unavailableReasonKey: raw.unavailableReasonKey,
|
|
2631
2632
|
scannedDiscountList: raw.scannedDiscountList
|
|
2632
2633
|
};
|
|
2633
2634
|
} catch (error) {
|
|
@@ -465,6 +465,8 @@ export interface BaseSalesScanCodeResult {
|
|
|
465
465
|
isAccepted?: boolean;
|
|
466
466
|
type?: 'server' | string;
|
|
467
467
|
unavailableReason?: 'time_limit' | string;
|
|
468
|
+
/** 扫码过滤原因(禁用、过期、额度或次数限制等);仅用于提示。 */
|
|
469
|
+
unavailableReasonKey?: string | null;
|
|
468
470
|
/** 扫码卡券资料及最新可用状态,供 Holder 补全等流程使用。 */
|
|
469
471
|
scannedDiscountList?: Discount[];
|
|
470
472
|
}
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 | 2 | 1 |
|
|
345
|
+
weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
389
389
|
};
|
|
390
390
|
setOtherData(key: string, value: any): void;
|
|
391
391
|
getOtherData(key: string): any;
|
|
392
|
-
getProductTypeById(id: number): Promise<"normal" | "
|
|
392
|
+
getProductTypeById(id: number): Promise<"normal" | "session" | "duration">;
|
|
393
393
|
/**
|
|
394
394
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
395
395
|
*
|
|
@@ -835,14 +835,30 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
835
835
|
const rawCollectPax = tempOrder.metadata?.collect_pax;
|
|
836
836
|
const hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
|
|
837
837
|
const bookingCapacityValue = resolveBookingCapacityValue();
|
|
838
|
-
const
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
838
|
+
const resourceNameCandidates = [tempOrder.table_number, resourceState?.table_form_record?.name];
|
|
839
|
+
const toNonEmptyString = value => typeof value === 'string' && value.trim().length > 0 ? value : undefined;
|
|
840
|
+
const toNameMap = value => value && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
841
|
+
const pickFromCandidates = picker => {
|
|
842
|
+
for (const candidate of resourceNameCandidates) {
|
|
843
|
+
const resolved = picker(candidate);
|
|
844
|
+
if (resolved !== undefined) return resolved;
|
|
842
845
|
}
|
|
843
846
|
return undefined;
|
|
844
847
|
};
|
|
845
|
-
const
|
|
848
|
+
const pickDirectOrOriginal = value => toNonEmptyString(value) ?? toNonEmptyString(toNameMap(value)?.original);
|
|
849
|
+
const pickLocalized = (value, locale) => toNonEmptyString(toNameMap(value)?.[locale]);
|
|
850
|
+
const pickFirstNonEmpty = value => {
|
|
851
|
+
const nameMap = toNameMap(value);
|
|
852
|
+
if (!nameMap) return undefined;
|
|
853
|
+
for (const candidate of Object.values(nameMap)) {
|
|
854
|
+
const resolved = toNonEmptyString(candidate);
|
|
855
|
+
if (resolved !== undefined) return resolved;
|
|
856
|
+
}
|
|
857
|
+
return undefined;
|
|
858
|
+
};
|
|
859
|
+
const coreState = this.core?.getPlugin?.('shopStore')?.get?.('core');
|
|
860
|
+
const activeLocale = String(coreState?.translateLocale || coreState?.core?.shop?.primary_locale || 'en');
|
|
861
|
+
const mainField = pickFromCandidates(pickDirectOrOriginal) ?? toNonEmptyString(resourceState?.table_form_record?.main_field) ?? pickFromCandidates(value => pickLocalized(value, activeLocale)) ?? pickFromCandidates(value => pickLocalized(value, 'en')) ?? pickFromCandidates(pickFirstNonEmpty) ?? '';
|
|
846
862
|
const resourceEntry = resourceState && resourceId ? {
|
|
847
863
|
relation_type: 'form',
|
|
848
864
|
like_status: 'common',
|