@pisell/pisellos 2.2.258 → 2.2.260
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/dataVariant/adapter.d.ts +49 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +152 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +755 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +282 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +146 -0
- package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
- package/dist/model/strategy/adapter/index.d.ts +4 -0
- package/dist/model/strategy/adapter/index.js +5 -1
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +13 -17
- package/dist/modules/Order/index.d.ts +2 -30
- package/dist/modules/Order/index.js +241 -508
- package/dist/modules/Order/types.d.ts +2 -20
- package/dist/modules/Order/utils.d.ts +0 -4
- package/dist/modules/Order/utils.js +28 -114
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/types.d.ts +22 -0
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -2
- package/dist/modules/ProductList/types.d.ts +2 -0
- package/dist/modules/Rules/index.d.ts +3 -3
- package/dist/modules/Rules/index.js +3 -8
- package/dist/modules/Rules/types.d.ts +1 -2
- package/dist/server/index.d.ts +50 -3
- package/dist/server/index.js +958 -1000
- package/dist/server/modules/order/index.d.ts +3 -22
- package/dist/server/modules/order/index.js +314 -397
- package/dist/server/modules/products/index.d.ts +26 -7
- package/dist/server/modules/products/index.js +166 -76
- package/dist/server/modules/products/types.d.ts +14 -0
- package/dist/solution/BaseSales/index.d.ts +2 -16
- package/dist/solution/BaseSales/index.js +314 -484
- package/dist/solution/BaseSales/types.d.ts +0 -1
- package/dist/solution/BaseSales/types.js +1 -2
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -4
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -9
- package/dist/solution/BookingTicket/index.js +6 -162
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +139 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +564 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/examples.js +295 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +146 -0
- package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
- package/lib/model/strategy/adapter/index.d.ts +4 -0
- package/lib/model/strategy/adapter/index.js +13 -2
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -11
- package/lib/modules/Order/index.d.ts +2 -30
- package/lib/modules/Order/index.js +57 -340
- package/lib/modules/Order/types.d.ts +2 -20
- package/lib/modules/Order/utils.d.ts +0 -4
- package/lib/modules/Order/utils.js +2 -84
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +22 -0
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +4 -2
- package/lib/modules/ProductList/types.d.ts +2 -0
- package/lib/modules/Rules/index.d.ts +3 -3
- package/lib/modules/Rules/index.js +3 -4
- package/lib/modules/Rules/types.d.ts +1 -2
- package/lib/server/index.d.ts +50 -3
- package/lib/server/index.js +215 -230
- package/lib/server/modules/order/index.d.ts +3 -22
- package/lib/server/modules/order/index.js +51 -102
- package/lib/server/modules/products/index.d.ts +26 -7
- package/lib/server/modules/products/index.js +113 -35
- package/lib/server/modules/products/types.d.ts +14 -0
- package/lib/solution/BaseSales/index.d.ts +2 -16
- package/lib/solution/BaseSales/index.js +31 -143
- package/lib/solution/BaseSales/types.d.ts +0 -1
- package/lib/solution/BaseSales/types.js +1 -2
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +5 -4
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -9
- package/lib/solution/BookingTicket/index.js +0 -112
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/package.json +1 -1
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
- package/dist/modules/Order/utils/bundleDiscountHydration.js +0 -144
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
- package/lib/modules/Order/utils/bundleDiscountHydration.js +0 -139
|
@@ -491,7 +491,7 @@ export interface OrderPaymentData {
|
|
|
491
491
|
voucher_id?: string | number;
|
|
492
492
|
origin_amount?: string;
|
|
493
493
|
service_fee?: string;
|
|
494
|
-
status?: 'active' | '
|
|
494
|
+
status?: 'active' | 'voided' | string;
|
|
495
495
|
/** 支付时间 (格式: YYYY-MM-DD HH:mm:ss) */
|
|
496
496
|
payment_time?: string;
|
|
497
497
|
wallet_pass_usage_unit?: unknown;
|
|
@@ -537,15 +537,9 @@ export interface SyncPaymentsToOrderParams {
|
|
|
537
537
|
smallTicketDataFlag?: number;
|
|
538
538
|
businessCode?: string;
|
|
539
539
|
channel?: string;
|
|
540
|
-
confirmPendingVoucherPayments?: boolean;
|
|
541
540
|
}
|
|
542
541
|
export interface SyncPaymentsToOrderResult<T = any> {
|
|
543
542
|
isFullyPaid: boolean;
|
|
544
|
-
isOrderFullyPaid: boolean;
|
|
545
|
-
isDepositFullyPaid: boolean;
|
|
546
|
-
paymentStage: 'deposit' | 'normal';
|
|
547
|
-
depositAmount: string;
|
|
548
|
-
orderExpectedAmount: string;
|
|
549
543
|
submitResult?: T;
|
|
550
544
|
}
|
|
551
545
|
export interface OrderIdentitySnapshot {
|
|
@@ -697,7 +691,6 @@ export interface OrderModuleAPI {
|
|
|
697
691
|
payments?: OrderPaymentSource[];
|
|
698
692
|
paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
|
|
699
693
|
smallTicketDataFlag?: number;
|
|
700
|
-
confirmPendingVoucherPayments?: boolean;
|
|
701
694
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
702
695
|
}) => Promise<T>;
|
|
703
696
|
submitTempOrderAsync: <T = any>(params?: {
|
|
@@ -709,7 +702,6 @@ export interface OrderModuleAPI {
|
|
|
709
702
|
payments?: OrderPaymentSource[];
|
|
710
703
|
paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
|
|
711
704
|
smallTicketDataFlag?: number;
|
|
712
|
-
confirmPendingVoucherPayments?: boolean;
|
|
713
705
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
714
706
|
}) => Promise<T>;
|
|
715
707
|
getOrderPayments: () => OrderPaymentData[];
|
|
@@ -717,17 +709,7 @@ export interface OrderModuleAPI {
|
|
|
717
709
|
addOrderPayment: (payment: OrderPaymentSource) => OrderPaymentData[];
|
|
718
710
|
updateOrderPayment: (paymentIdentity: string | number, updates: Partial<OrderPaymentData> & Record<string, any>) => OrderPaymentData[];
|
|
719
711
|
deleteOrderPayment: (paymentIdentity: string | number) => OrderPaymentData[];
|
|
720
|
-
updateVoucherOrderPayments: (payments: OrderPaymentSource[]
|
|
721
|
-
status?: 'paid' | 'payment_pending';
|
|
722
|
-
}) => OrderPaymentData[];
|
|
723
|
-
confirmPendingVoucherPayments: (options?: {
|
|
724
|
-
persist?: boolean;
|
|
725
|
-
recalculateSummary?: boolean;
|
|
726
|
-
}) => OrderPaymentData[];
|
|
727
|
-
discardPendingVoucherPayments: (options?: {
|
|
728
|
-
persist?: boolean;
|
|
729
|
-
recalculateSummary?: boolean;
|
|
730
|
-
}) => OrderPaymentData[];
|
|
712
|
+
updateVoucherOrderPayments: (payments: OrderPaymentSource[]) => OrderPaymentData[];
|
|
731
713
|
sendCustomerPayLink: <T = any>(params: SendCustomerPayLinkParams) => Promise<T>;
|
|
732
714
|
saveDraft: () => Promise<void>;
|
|
733
715
|
hydrateTempOrderFromRecord: (record: Record<string, any>, options?: {
|
|
@@ -254,10 +254,6 @@ export declare function clearTempOrderHolderAssignments(tempOrder: OrderTempOrde
|
|
|
254
254
|
* getOrderProductLineUid({ metadata: { unique_identification_number: 'line-1' } }); // 'line-1'
|
|
255
255
|
*/
|
|
256
256
|
export declare function getOrderProductLineUid(product: Record<string, any> | null | undefined): string | null;
|
|
257
|
-
export declare function getRuntimeProductOrigin(tempOrder: OrderTempOrder | null | undefined, product: any): Record<string, any> | null;
|
|
258
|
-
export declare function isHolderConfigRequired(holderConfig: any): boolean;
|
|
259
|
-
export declare function productRequiresFormSubject(tempOrder: OrderTempOrder | null | undefined, product: any): boolean;
|
|
260
|
-
export declare function resolveIsFormSubject(tempOrder: OrderTempOrder | null | undefined, product?: any): boolean;
|
|
261
257
|
/**
|
|
262
258
|
* 判断展示字段是否为空(含 i18n 对象全空)。
|
|
263
259
|
*
|
|
@@ -49,11 +49,9 @@ __export(utils_exports, {
|
|
|
49
49
|
getBundleSignedUnit: () => getBundleSignedUnit,
|
|
50
50
|
getOrderProductLineUid: () => getOrderProductLineUid,
|
|
51
51
|
getProductSkuOptions: () => getProductSkuOptions,
|
|
52
|
-
getRuntimeProductOrigin: () => getRuntimeProductOrigin,
|
|
53
52
|
hasAssignedHolderId: () => hasAssignedHolderId,
|
|
54
53
|
indexOrderProductsByUid: () => indexOrderProductsByUid,
|
|
55
54
|
isEmptyOrderProductDisplayValue: () => isEmptyOrderProductDisplayValue,
|
|
56
|
-
isHolderConfigRequired: () => isHolderConfigRequired,
|
|
57
55
|
isMarkdownBundle: () => isMarkdownBundle,
|
|
58
56
|
isTempOrder: () => isTempOrder,
|
|
59
57
|
mapPaymentItemToOrderPayment: () => mapPaymentItemToOrderPayment,
|
|
@@ -67,9 +65,7 @@ __export(utils_exports, {
|
|
|
67
65
|
normalizeProductSkuOptions: () => normalizeProductSkuOptions,
|
|
68
66
|
normalizeSubmitBooking: () => normalizeSubmitBooking,
|
|
69
67
|
normalizeSubmitCollectPaxValue: () => normalizeSubmitCollectPaxValue,
|
|
70
|
-
productRequiresFormSubject: () => productRequiresFormSubject,
|
|
71
68
|
resolveEffectivePerUnitDiscount: () => resolveEffectivePerUnitDiscount,
|
|
72
|
-
resolveIsFormSubject: () => resolveIsFormSubject,
|
|
73
69
|
resolveManualDiscountMessage: () => import_manualProductDiscount.resolveManualDiscountMessage,
|
|
74
70
|
resolveManualDiscountOriginTotal: () => import_manualProductDiscount.resolveManualDiscountOriginTotal,
|
|
75
71
|
resolveManualDiscountReasonFromSources: () => import_manualProductDiscount.resolveManualDiscountReasonFromSources,
|
|
@@ -380,42 +376,6 @@ function normalizeOrderProductDiscountList(discountList) {
|
|
|
380
376
|
return normalized;
|
|
381
377
|
});
|
|
382
378
|
}
|
|
383
|
-
function resolveSubmitBundleMapId(bundle) {
|
|
384
|
-
var _a;
|
|
385
|
-
const metadataMapId = (_a = bundle.metadata) == null ? void 0 : _a.custom_product_bundle_map_id;
|
|
386
|
-
if (metadataMapId !== void 0 && metadataMapId !== null && metadataMapId !== "") {
|
|
387
|
-
return metadataMapId;
|
|
388
|
-
}
|
|
389
|
-
if (bundle._id !== void 0 && bundle._id !== null && bundle._id !== "") {
|
|
390
|
-
return bundle._id;
|
|
391
|
-
}
|
|
392
|
-
return void 0;
|
|
393
|
-
}
|
|
394
|
-
function collectSubmitProductDiscountList(product) {
|
|
395
|
-
const submitDiscountList = Array.isArray(product == null ? void 0 : product.discount_list) ? [...product.discount_list] : [];
|
|
396
|
-
for (const bundle of (product == null ? void 0 : product.product_bundle) || []) {
|
|
397
|
-
if (!bundle || typeof bundle !== "object")
|
|
398
|
-
continue;
|
|
399
|
-
const bundleMapId = resolveSubmitBundleMapId(bundle);
|
|
400
|
-
const bundleDiscountList = Array.isArray(bundle.discount_list) ? bundle.discount_list : [];
|
|
401
|
-
for (const discount of bundleDiscountList) {
|
|
402
|
-
if (!discount || typeof discount !== "object")
|
|
403
|
-
continue;
|
|
404
|
-
const discountMetadata = discount.metadata && typeof discount.metadata === "object" ? discount.metadata : {};
|
|
405
|
-
const discountMapId = discountMetadata.custom_product_bundle_map_id !== void 0 && discountMetadata.custom_product_bundle_map_id !== null && discountMetadata.custom_product_bundle_map_id !== "" ? discountMetadata.custom_product_bundle_map_id : bundleMapId;
|
|
406
|
-
submitDiscountList.push({
|
|
407
|
-
...discount,
|
|
408
|
-
...discountMapId !== void 0 ? {
|
|
409
|
-
metadata: {
|
|
410
|
-
...discountMetadata,
|
|
411
|
-
custom_product_bundle_map_id: discountMapId
|
|
412
|
-
}
|
|
413
|
-
} : {}
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
return normalizeOrderProductDiscountList(submitDiscountList);
|
|
418
|
-
}
|
|
419
379
|
function resolveManualOverrideLineOriginalPrice(params, fallbackCompositeOriginal) {
|
|
420
380
|
var _a, _b;
|
|
421
381
|
const metadata = params.metadata || {};
|
|
@@ -711,10 +671,6 @@ function formatSubmitBundleItems(bundle) {
|
|
|
711
671
|
return bundle.map((b) => {
|
|
712
672
|
const rawBundle = b && typeof b === "object" ? b : {};
|
|
713
673
|
const existedMetadata = rawBundle.metadata && typeof rawBundle.metadata === "object" ? rawBundle.metadata : {};
|
|
714
|
-
const {
|
|
715
|
-
custom_product_bundle_map_id: _customProductBundleMapId,
|
|
716
|
-
...submitMetadata
|
|
717
|
-
} = existedMetadata;
|
|
718
674
|
const sellingPrice = getBundleSellingMagnitude(rawBundle).toFixed(2);
|
|
719
675
|
const paymentPrice = rawBundle.bundle_payment_price !== void 0 && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== "" ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
|
|
720
676
|
const priceValue = rawBundle.price ?? rawBundle.custom_price ?? rawBundle.bundle_selling_price;
|
|
@@ -727,8 +683,6 @@ function formatSubmitBundleItems(bundle) {
|
|
|
727
683
|
0
|
|
728
684
|
);
|
|
729
685
|
const num = toBundleNumber(rawBundle.num ?? rawBundle.quantity, 1);
|
|
730
|
-
const bundleMapId = resolveSubmitBundleMapId(rawBundle);
|
|
731
|
-
const hasSubmitBundleDiscounts = Array.isArray(rawBundle.discount_list) && rawBundle.discount_list.length > 0;
|
|
732
686
|
return {
|
|
733
687
|
is_charge_tax: rawBundle.is_charge_tax ?? 0,
|
|
734
688
|
bundle_variant_id: rawBundle.bundle_variant_id ?? 0,
|
|
@@ -746,8 +700,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
746
700
|
bundle_id: (rawBundle == null ? void 0 : rawBundle.bundle_id) ?? (rawBundle == null ? void 0 : rawBundle.id),
|
|
747
701
|
bundle_product_id: (rawBundle == null ? void 0 : rawBundle.bundle_product_id) ?? (rawBundle == null ? void 0 : rawBundle._bundle_product_id),
|
|
748
702
|
metadata: {
|
|
749
|
-
...
|
|
750
|
-
...hasSubmitBundleDiscounts && bundleMapId !== void 0 ? { custom_product_bundle_map_id: bundleMapId } : {},
|
|
703
|
+
...existedMetadata,
|
|
751
704
|
surcharge_fee: surchargeFee,
|
|
752
705
|
relation_surcharge_ids: relationSurchargeIds,
|
|
753
706
|
product_discount_difference: productDiscountDifference
|
|
@@ -812,7 +765,7 @@ function normalizeSubmitProduct(product) {
|
|
|
812
765
|
...bookingUid ? { booking_uid: bookingUid } : {},
|
|
813
766
|
product_quantity: toBundleNumber(num ?? submitProduct.product_quantity, 1),
|
|
814
767
|
product_sku: productSku,
|
|
815
|
-
discount_list:
|
|
768
|
+
discount_list: normalizeOrderProductDiscountList(submitProduct.discount_list),
|
|
816
769
|
product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
|
|
817
770
|
metadata: cleanMetadata,
|
|
818
771
|
// 出站兼容:后端消费 payment_price 字段(行 composite 已减整单折扣均摊)。
|
|
@@ -1141,37 +1094,6 @@ function getOrderProductLineUid(product) {
|
|
|
1141
1094
|
return null;
|
|
1142
1095
|
return String(uid);
|
|
1143
1096
|
}
|
|
1144
|
-
function getRuntimeProductOrigin(tempOrder, product) {
|
|
1145
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1146
|
-
const uid = getOrderProductLineUid(product);
|
|
1147
|
-
if (uid && ((_c = (_b = (_a = tempOrder == null ? void 0 : tempOrder._extend) == null ? void 0 : _a.productsByUid) == null ? void 0 : _b[uid]) == null ? void 0 : _c.origin)) {
|
|
1148
|
-
return tempOrder._extend.productsByUid[uid].origin;
|
|
1149
|
-
}
|
|
1150
|
-
const matchedProduct = ((tempOrder == null ? void 0 : tempOrder.products) || []).find((item) => item === product || getOrderProductLineUid(item) === uid || String((item == null ? void 0 : item.product_id) ?? (item == null ? void 0 : item.id) ?? "") === String((product == null ? void 0 : product.product_id) ?? (product == null ? void 0 : product.id) ?? ""));
|
|
1151
|
-
const matchedUid = matchedProduct ? getOrderProductLineUid(matchedProduct) : "";
|
|
1152
|
-
return matchedUid ? ((_f = (_e = (_d = tempOrder == null ? void 0 : tempOrder._extend) == null ? void 0 : _d.productsByUid) == null ? void 0 : _e[matchedUid]) == null ? void 0 : _f.origin) || null : null;
|
|
1153
|
-
}
|
|
1154
|
-
function isHolderConfigRequired(holderConfig) {
|
|
1155
|
-
if (!holderConfig || typeof holderConfig !== "object")
|
|
1156
|
-
return false;
|
|
1157
|
-
if (holderConfig.status === "disable")
|
|
1158
|
-
return false;
|
|
1159
|
-
return Number(holderConfig.required) === 1;
|
|
1160
|
-
}
|
|
1161
|
-
function productRequiresFormSubject(tempOrder, product) {
|
|
1162
|
-
const runtimeOrigin = getRuntimeProductOrigin(tempOrder, product);
|
|
1163
|
-
return isHolderConfigRequired(product == null ? void 0 : product.holder_config) || isHolderConfigRequired(runtimeOrigin == null ? void 0 : runtimeOrigin.holder_config);
|
|
1164
|
-
}
|
|
1165
|
-
function resolveIsFormSubject(tempOrder, product) {
|
|
1166
|
-
var _a;
|
|
1167
|
-
if (((_a = tempOrder == null ? void 0 : tempOrder.holder) == null ? void 0 : _a.type) === "form")
|
|
1168
|
-
return true;
|
|
1169
|
-
if (product)
|
|
1170
|
-
return productRequiresFormSubject(tempOrder, product);
|
|
1171
|
-
return ((tempOrder == null ? void 0 : tempOrder.products) || []).some(
|
|
1172
|
-
(item) => productRequiresFormSubject(tempOrder, item)
|
|
1173
|
-
);
|
|
1174
|
-
}
|
|
1175
1097
|
function isEmptyOrderProductDisplayValue(value) {
|
|
1176
1098
|
if (value === void 0 || value === null)
|
|
1177
1099
|
return true;
|
|
@@ -1252,11 +1174,9 @@ function indexOrderProductsByUid(products) {
|
|
|
1252
1174
|
getBundleSignedUnit,
|
|
1253
1175
|
getOrderProductLineUid,
|
|
1254
1176
|
getProductSkuOptions,
|
|
1255
|
-
getRuntimeProductOrigin,
|
|
1256
1177
|
hasAssignedHolderId,
|
|
1257
1178
|
indexOrderProductsByUid,
|
|
1258
1179
|
isEmptyOrderProductDisplayValue,
|
|
1259
|
-
isHolderConfigRequired,
|
|
1260
1180
|
isMarkdownBundle,
|
|
1261
1181
|
isTempOrder,
|
|
1262
1182
|
mapPaymentItemToOrderPayment,
|
|
@@ -1270,9 +1190,7 @@ function indexOrderProductsByUid(products) {
|
|
|
1270
1190
|
normalizeProductSkuOptions,
|
|
1271
1191
|
normalizeSubmitBooking,
|
|
1272
1192
|
normalizeSubmitCollectPaxValue,
|
|
1273
|
-
productRequiresFormSubject,
|
|
1274
1193
|
resolveEffectivePerUnitDiscount,
|
|
1275
|
-
resolveIsFormSubject,
|
|
1276
1194
|
resolveManualDiscountMessage,
|
|
1277
1195
|
resolveManualDiscountOriginTotal,
|
|
1278
1196
|
resolveManualDiscountReasonFromSources,
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -9,6 +9,26 @@ export interface ProductCollection {
|
|
|
9
9
|
/** 商品集合封面 */
|
|
10
10
|
cover: string;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* 商品 Data Variant 记录,结构与后端 data_variant 表对齐。
|
|
14
|
+
*/
|
|
15
|
+
export interface ProductDataVariant {
|
|
16
|
+
/** 变体记录 id */
|
|
17
|
+
id: number;
|
|
18
|
+
/** 店铺 id */
|
|
19
|
+
shop_id: number;
|
|
20
|
+
/** 所属模块,商品场景固定为 product */
|
|
21
|
+
module: string;
|
|
22
|
+
/** 模块数据 id,商品场景对应 product.id */
|
|
23
|
+
module_data_id: number;
|
|
24
|
+
/** 关联 data_variant_rule.id */
|
|
25
|
+
data_variant_rule_id: number;
|
|
26
|
+
/** 命中策略后覆盖到商品上的字段 */
|
|
27
|
+
data: Record<string, any>;
|
|
28
|
+
created_at: string | null;
|
|
29
|
+
updated_at: string | null;
|
|
30
|
+
deleted_at: string | null;
|
|
31
|
+
}
|
|
12
32
|
/**
|
|
13
33
|
* 商品基本信息接口
|
|
14
34
|
*/
|
|
@@ -214,6 +234,8 @@ export interface ProductData {
|
|
|
214
234
|
bundle_group_count: number;
|
|
215
235
|
/** 选项组数量 */
|
|
216
236
|
option_group_count: number;
|
|
237
|
+
/** 智能定价变体列表,/product/query with dataVariants 返回 */
|
|
238
|
+
data_variants?: ProductDataVariant[];
|
|
217
239
|
/** 服务时长 */
|
|
218
240
|
service_times?: any;
|
|
219
241
|
}
|
|
@@ -26,7 +26,7 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
26
26
|
* const products = await productList.getAddTimeProducts({ schedule_date: '2026-06-16' });
|
|
27
27
|
*/
|
|
28
28
|
getAddTimeProducts(params?: ProductListLoadProductsParams): Promise<any>;
|
|
29
|
-
loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, extension_type, status, }?: ProductListLoadProductsParams, options?: {
|
|
29
|
+
loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, extension_type, status, strategy_context, }?: ProductListLoadProductsParams, options?: {
|
|
30
30
|
callback?: (result: any) => void;
|
|
31
31
|
subscriberId?: string;
|
|
32
32
|
}): Promise<any>;
|
|
@@ -95,7 +95,8 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
95
95
|
cacheId,
|
|
96
96
|
with_schedule,
|
|
97
97
|
extension_type,
|
|
98
|
-
status = "published"
|
|
98
|
+
status = "published",
|
|
99
|
+
strategy_context
|
|
99
100
|
} = {}, options) {
|
|
100
101
|
var _a, _b;
|
|
101
102
|
let userPlugin = this.core.getPlugin("user");
|
|
@@ -135,7 +136,8 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
135
136
|
is_eject: 1,
|
|
136
137
|
with_schedule,
|
|
137
138
|
schedule_datetime,
|
|
138
|
-
extension_type
|
|
139
|
+
extension_type,
|
|
140
|
+
strategy_context
|
|
139
141
|
},
|
|
140
142
|
{ osServer: true, callback: options == null ? void 0 : options.callback, subscriberId: options == null ? void 0 : options.subscriberId, customToast: () => {
|
|
141
143
|
} }
|
|
@@ -12,6 +12,8 @@ export interface ProductListLoadProductsParams {
|
|
|
12
12
|
with_schedule?: number;
|
|
13
13
|
extension_type?: string[];
|
|
14
14
|
status?: string;
|
|
15
|
+
/** 智能定价条件上下文,仅影响策略命中,不参与商品集合筛选 */
|
|
16
|
+
strategy_context?: Record<string, any>;
|
|
15
17
|
}
|
|
16
18
|
export interface ProductListData {
|
|
17
19
|
list: ProductData[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { Rules, RulesModuleAPI, DiscountResult,
|
|
3
|
+
import { Rules, RulesModuleAPI, DiscountResult, UnavailableReason } from './types';
|
|
4
4
|
import { Discount } from '../Discount/types';
|
|
5
5
|
import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
|
|
6
6
|
import { WindowPlugin } from '../../plugins';
|
|
@@ -24,7 +24,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
24
24
|
holders: {
|
|
25
25
|
form_record_id: number;
|
|
26
26
|
}[];
|
|
27
|
-
isFormSubject:
|
|
27
|
+
isFormSubject: boolean;
|
|
28
28
|
}): {
|
|
29
29
|
isAvailable: boolean;
|
|
30
30
|
discountList: Discount[];
|
|
@@ -43,7 +43,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
43
43
|
holders: {
|
|
44
44
|
form_record_id: number;
|
|
45
45
|
}[];
|
|
46
|
-
isFormSubject:
|
|
46
|
+
isFormSubject: boolean;
|
|
47
47
|
orderTotalAmount: number;
|
|
48
48
|
}, options?: {
|
|
49
49
|
isSelected?: boolean;
|
|
@@ -70,7 +70,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
70
70
|
var _a;
|
|
71
71
|
if (((_a = discount.holder) == null ? void 0 : _a.holder_type) !== "form")
|
|
72
72
|
return true;
|
|
73
|
-
const orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id
|
|
73
|
+
const orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id : void 0;
|
|
74
74
|
const productHolderId = Array.isArray(product.holder_id) ? product.holder_id[0] : product.holder_id;
|
|
75
75
|
if (!product.isNeedHolder)
|
|
76
76
|
return true;
|
|
@@ -207,7 +207,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
207
207
|
orderTotalAmount
|
|
208
208
|
}, options) {
|
|
209
209
|
var _a;
|
|
210
|
-
const resolveIsFormSubject = (product) => typeof isFormSubject === "function" ? Boolean(isFormSubject(product)) : Boolean(isFormSubject);
|
|
211
210
|
const isEditModeAddNewProduct = productList.find((n) => n.booking_id) && productList.find((n) => !n.booking_id);
|
|
212
211
|
const editModeDiscount = [];
|
|
213
212
|
const addModeDiscount = [];
|
|
@@ -597,7 +596,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
597
596
|
const isHolderMatch = this.checkHolderMatch(
|
|
598
597
|
discount,
|
|
599
598
|
{
|
|
600
|
-
isNeedHolder:
|
|
599
|
+
isNeedHolder: isFormSubject && !(_tempVar == null ? void 0 : _tempVar.isNormalProduct),
|
|
601
600
|
holder_id: (_tempVar == null ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
602
601
|
},
|
|
603
602
|
holders
|
|
@@ -768,7 +767,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
768
767
|
const isHolderMatch = this.checkHolderMatch(
|
|
769
768
|
discount,
|
|
770
769
|
{
|
|
771
|
-
isNeedHolder:
|
|
770
|
+
isNeedHolder: isFormSubject && !(_tempVar == null ? void 0 : _tempVar.isNormalProduct),
|
|
772
771
|
holder_id: (_tempVar == null ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
773
772
|
},
|
|
774
773
|
holders
|
|
@@ -22,7 +22,6 @@ export interface DiscountResult {
|
|
|
22
22
|
productList: any[];
|
|
23
23
|
discountList: any[];
|
|
24
24
|
}
|
|
25
|
-
export type RulesFormSubject = boolean | ((product: any) => boolean);
|
|
26
25
|
export interface RulesModuleAPI {
|
|
27
26
|
setRulesList: (rulesList: Rules[]) => Promise<void>;
|
|
28
27
|
clear: () => Promise<void>;
|
|
@@ -32,7 +31,7 @@ export interface RulesModuleAPI {
|
|
|
32
31
|
holders: {
|
|
33
32
|
form_record_id: number;
|
|
34
33
|
}[];
|
|
35
|
-
isFormSubject:
|
|
34
|
+
isFormSubject: boolean;
|
|
36
35
|
orderTotalAmount: number;
|
|
37
36
|
}) => DiscountResult;
|
|
38
37
|
}
|
package/lib/server/index.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ declare class Server {
|
|
|
47
47
|
private prefixRouterGet;
|
|
48
48
|
router: Router;
|
|
49
49
|
private productQuerySubscribers;
|
|
50
|
+
/** subscriberId → 智能定价变价时间点定时器句柄(与 subscriber 分离存储,便于 clear) */
|
|
51
|
+
private productQueryScheduleTimers;
|
|
50
52
|
private orderQuerySubscribers;
|
|
51
53
|
private bookingQuerySubscribers;
|
|
52
54
|
private bookingRemoteQuerySubscribers;
|
|
@@ -210,6 +212,48 @@ declare class Server {
|
|
|
210
212
|
* 根据 subscriberId 移除商品查询订阅者
|
|
211
213
|
*/
|
|
212
214
|
removeProductQuerySubscriber(subscriberId?: string): void;
|
|
215
|
+
/**
|
|
216
|
+
* 构建商品 query 响应 data 段,附带智能定价 schedule_time_points 元数据。
|
|
217
|
+
*/
|
|
218
|
+
private buildProductQueryResultPayload;
|
|
219
|
+
/**
|
|
220
|
+
* 是否启用商品 query 订阅的 schedule 时间点定时重算。
|
|
221
|
+
* strategy_context.enable_schedule_reload === false 时关闭。
|
|
222
|
+
*/
|
|
223
|
+
private shouldScheduleProductQueryReload;
|
|
224
|
+
/**
|
|
225
|
+
* 清除指定 subscriber 的全部 schedule 定时器,防止重复 query 或 unsubscribe 后泄漏。
|
|
226
|
+
*/
|
|
227
|
+
private clearSubscriberScheduleTimers;
|
|
228
|
+
/**
|
|
229
|
+
* 从 productQueryScheduleTimers 移除已触发的 timer 引用。
|
|
230
|
+
*/
|
|
231
|
+
private removeScheduleTimerRef;
|
|
232
|
+
/**
|
|
233
|
+
* 计算 schedule 变价时间点到当前时刻的延迟(ms)。已过期返回 -1。
|
|
234
|
+
*/
|
|
235
|
+
private computeScheduleTimePointDelayMs;
|
|
236
|
+
/**
|
|
237
|
+
* 定时重算前刷新 subscriber schedule 上下文:使用执行瞬间时间,禁止沿用首次 query 的 schedule_datetime。
|
|
238
|
+
*/
|
|
239
|
+
private refreshSubscriberScheduleAtExecution;
|
|
240
|
+
/**
|
|
241
|
+
* 为 subscriber 注册智能定价 scheduleTimePoints 定时重算。
|
|
242
|
+
* 必须先 clearSubscriberScheduleTimers,再调用本方法。
|
|
243
|
+
*/
|
|
244
|
+
private scheduleSubscriberTimePointReloads;
|
|
245
|
+
/**
|
|
246
|
+
* schedule 变价时间点定时器触发:刷新 schedule_datetime 后重算并 callback。
|
|
247
|
+
*/
|
|
248
|
+
private onScheduleTimePointTimerFire;
|
|
249
|
+
/**
|
|
250
|
+
* 对单个商品 query 订阅者重算并推送(定时路径;不新建 schedule timer)。
|
|
251
|
+
*/
|
|
252
|
+
private recomputeAndNotifySubscriber;
|
|
253
|
+
/**
|
|
254
|
+
* query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
|
|
255
|
+
*/
|
|
256
|
+
private syncProductQueryScheduleTimers;
|
|
213
257
|
/**
|
|
214
258
|
* 处理商品查询请求
|
|
215
259
|
* 存储订阅者信息,便于数据变更时推送最新结果
|
|
@@ -431,9 +475,6 @@ declare class Server {
|
|
|
431
475
|
private shouldLookupLocalPrintOrder;
|
|
432
476
|
private getLocalPrintOrderLookup;
|
|
433
477
|
private handleLocalPrintOrder;
|
|
434
|
-
private handleMachinecodeBatchMetadata;
|
|
435
|
-
private resolveMachinecodeBatchMetadataLookup;
|
|
436
|
-
private syncMachinecodeBatchMetadataToLocalOrder;
|
|
437
478
|
private handleOrderCheckoutSubmit;
|
|
438
479
|
private handleSyncCheckoutSubmit;
|
|
439
480
|
private handlePendingSyncCheckoutOrder;
|
|
@@ -565,6 +606,12 @@ declare class Server {
|
|
|
565
606
|
* @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
|
|
566
607
|
*/
|
|
567
608
|
private computeProductQueryResult;
|
|
609
|
+
/**
|
|
610
|
+
* 构建商品格式化上下文。
|
|
611
|
+
*
|
|
612
|
+
* 智能定价条件使用全量 menuList/scheduleList;Product Query 顶层参数只保留筛选商品集合所需字段。
|
|
613
|
+
*/
|
|
614
|
+
private buildProductFormatterContext;
|
|
568
615
|
/**
|
|
569
616
|
* 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
|
|
570
617
|
* 由 ProductsModule 的 onProductsSyncCompleted 事件触发
|