@pisell/pisellos 2.3.123 → 2.3.124
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/walletPass/evaluator.d.ts +2 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +4 -2
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +58 -19
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +24 -12
- package/dist/modules/Customer/index.js +6 -3
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/availability.d.ts +7 -0
- package/dist/modules/Discount/availability.js +49 -0
- package/dist/modules/Discount/entitlementPass.d.ts +34 -0
- package/dist/modules/Discount/entitlementPass.js +147 -0
- package/dist/modules/Discount/index.d.ts +2 -2
- package/dist/modules/Discount/index.js +37 -151
- package/dist/modules/Discount/types.d.ts +36 -5
- package/dist/modules/Order/index.d.ts +7 -1
- package/dist/modules/Order/index.js +437 -229
- package/dist/modules/Order/utils/orderCollectionIdentity.js +16 -12
- package/dist/modules/Order/utils.d.ts +1 -1
- package/dist/modules/Order/utils.js +101 -60
- package/dist/modules/Payment/types.d.ts +21 -1
- package/dist/modules/Payment/types.js +2 -0
- package/dist/modules/Payment/walletpass.d.ts +1 -1
- package/dist/modules/Payment/walletpass.js +80 -47
- package/dist/modules/Rules/index.d.ts +2 -2
- package/dist/modules/Rules/index.js +480 -186
- package/dist/modules/Rules/types.d.ts +4 -0
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/solution/BaseSales/index.d.ts +1 -0
- package/dist/solution/BaseSales/index.js +5 -2
- package/dist/solution/BaseSales/types.d.ts +2 -2
- package/dist/solution/BaseSales/utils/cartPromotion.js +141 -126
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -2
- package/dist/solution/BookingTicket/index.js +60 -63
- package/dist/solution/BookingTicket/types.d.ts +5 -1
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +338 -147
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +19 -6
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +99 -42
- package/dist/solution/ShopDiscount/utils.d.ts +4 -2
- package/dist/solution/ShopDiscount/utils.js +43 -23
- package/dist/solution/UnifiedBookingSales/index.js +2 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +35 -6
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +13 -6
- package/lib/modules/Customer/index.js +5 -1
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/availability.d.ts +7 -0
- package/lib/modules/Discount/availability.js +43 -0
- package/lib/modules/Discount/entitlementPass.d.ts +34 -0
- package/lib/modules/Discount/entitlementPass.js +141 -0
- package/lib/modules/Discount/index.d.ts +2 -2
- package/lib/modules/Discount/index.js +23 -129
- package/lib/modules/Discount/types.d.ts +36 -5
- package/lib/modules/Order/index.d.ts +7 -1
- package/lib/modules/Order/index.js +213 -40
- package/lib/modules/Order/utils/orderCollectionIdentity.js +14 -11
- package/lib/modules/Order/utils.d.ts +1 -1
- package/lib/modules/Order/utils.js +39 -3
- package/lib/modules/Payment/types.d.ts +21 -1
- package/lib/modules/Payment/types.js +1 -0
- package/lib/modules/Payment/walletpass.d.ts +1 -1
- package/lib/modules/Payment/walletpass.js +29 -9
- package/lib/modules/Rules/index.d.ts +2 -2
- package/lib/modules/Rules/index.js +357 -110
- package/lib/modules/Rules/types.d.ts +4 -0
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/solution/BaseSales/index.d.ts +1 -0
- package/lib/solution/BaseSales/index.js +5 -2
- package/lib/solution/BaseSales/types.d.ts +2 -2
- package/lib/solution/BaseSales/utils/cartPromotion.js +12 -4
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -2
- package/lib/solution/BookingTicket/index.js +36 -33
- package/lib/solution/BookingTicket/types.d.ts +5 -1
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +174 -42
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +8 -4
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +6 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +11 -3
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +55 -9
- package/lib/solution/ShopDiscount/utils.d.ts +4 -2
- package/lib/solution/ShopDiscount/utils.js +42 -25
- package/lib/solution/UnifiedBookingSales/index.js +2 -2
- package/package.json +1 -1
|
@@ -12,6 +12,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
12
12
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
13
13
|
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); }
|
|
14
14
|
import { cloneDeep } from 'lodash-es';
|
|
15
|
+
import { isFullCoveragePass } from "../../Discount/entitlementPass";
|
|
15
16
|
var IDENTITY_CONFIG = {
|
|
16
17
|
product: {
|
|
17
18
|
persistentIdField: 'order_detail_id',
|
|
@@ -74,22 +75,25 @@ export function setOrderCollectionUid(kind, item, uid) {
|
|
|
74
75
|
delete record[uidField];
|
|
75
76
|
return record;
|
|
76
77
|
}
|
|
77
|
-
function
|
|
78
|
-
var _ref, _ref2,
|
|
79
|
-
var
|
|
80
|
-
|
|
81
|
-
var type = (item === null || item === void 0 ? void 0 : item.type) || (item === null || item === void 0 ? void 0 : item.tag) || (item === null || item === void 0 || (_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.type) || (item === null || item === void 0 || (_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.tag);
|
|
82
|
-
return type === 'good_pass';
|
|
78
|
+
function getFullCoveragePassIdentity(product) {
|
|
79
|
+
var _ref, _ref2, _pass$discount$resour, _pass$discount;
|
|
80
|
+
var pass = (product.discount_list || []).find(function (item) {
|
|
81
|
+
return isFullCoveragePass(item);
|
|
83
82
|
});
|
|
84
|
-
if (!
|
|
85
|
-
var resourceId = (_ref = (_ref2 = (
|
|
86
|
-
|
|
83
|
+
if (!pass) return null;
|
|
84
|
+
var resourceId = (_ref = (_ref2 = (_pass$discount$resour = (_pass$discount = pass.discount) === null || _pass$discount === void 0 ? void 0 : _pass$discount.resource_id) !== null && _pass$discount$resour !== void 0 ? _pass$discount$resour : pass.resource_id) !== null && _ref2 !== void 0 ? _ref2 : pass.discount_id) !== null && _ref !== void 0 ? _ref : pass.id;
|
|
85
|
+
if (isBlankOrderCollectionIdentity(resourceId)) return null;
|
|
86
|
+
return {
|
|
87
|
+
type: String(pass.type || pass.tag),
|
|
88
|
+
resourceId: String(resourceId)
|
|
89
|
+
};
|
|
87
90
|
}
|
|
88
91
|
function buildSplitProductUid(originalUid, product, duplicateOrdinal) {
|
|
89
92
|
var encodedOriginalUid = encodeURIComponent(originalUid);
|
|
90
|
-
var
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
+
var passIdentity = getFullCoveragePassIdentity(product);
|
|
94
|
+
if (passIdentity) {
|
|
95
|
+
var passType = passIdentity.type === 'good_pass' ? 'good-pass' : 'entitlement-pass';
|
|
96
|
+
return "os-split:product:".concat(encodedOriginalUid, ":").concat(passType, ":").concat(encodeURIComponent(passIdentity.resourceId), ":").concat(duplicateOrdinal);
|
|
93
97
|
}
|
|
94
98
|
return "os-split:product:".concat(encodedOriginalUid, ":duplicate:").concat(duplicateOrdinal);
|
|
95
99
|
}
|
|
@@ -161,7 +161,7 @@ export declare function resolveManualOverrideLineOriginalPrice(params: {
|
|
|
161
161
|
* // => -4
|
|
162
162
|
*/
|
|
163
163
|
export declare function resolveEffectivePerUnitDiscount(product: Record<string, any>): number;
|
|
164
|
-
export declare function createDefaultOrderRulesHooks(): RulesParamsHooks;
|
|
164
|
+
export declare function createDefaultOrderRulesHooks(getBookings?: () => OrderTempOrder['bookings']): RulesParamsHooks;
|
|
165
165
|
/**
|
|
166
166
|
* 通过 session 类商品的开始时间结束时间生成商品的时长
|
|
167
167
|
* @param {CartItem} cartItem
|
|
@@ -23,11 +23,13 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
23
23
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
24
24
|
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); }
|
|
25
25
|
import dayjs from "dayjs";
|
|
26
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
26
27
|
import Decimal from 'decimal.js';
|
|
27
28
|
import { getProductHolderConfig } from "../Holder/utils";
|
|
28
29
|
import { buildProductLineFingerprint, createEmptySummary } from "../../solution/ScanOrder/utils";
|
|
29
30
|
import { createUuidV4 } from "./utils/orderCollectionIdentity";
|
|
30
31
|
import { encodeSalesNotes } from "./salesNotes";
|
|
32
|
+
dayjs.extend(customParseFormat);
|
|
31
33
|
var POINT_CARD_SNAPSHOT_TAG = 'point_card';
|
|
32
34
|
var VIRTUAL_CURRENCY_SNAPSHOT_TAG = 'virtual_currency';
|
|
33
35
|
function isPlainObject(value) {
|
|
@@ -611,6 +613,22 @@ function resolveSubmitBundleMapId(bundle) {
|
|
|
611
613
|
}
|
|
612
614
|
return undefined;
|
|
613
615
|
}
|
|
616
|
+
function ensureSubmitDiscountIdentity(discount) {
|
|
617
|
+
if (!discount || _typeof(discount) !== 'object' || Array.isArray(discount)) {
|
|
618
|
+
return discount;
|
|
619
|
+
}
|
|
620
|
+
var discountRecord = discount;
|
|
621
|
+
var metadata = discountRecord.metadata && _typeof(discountRecord.metadata) === 'object' && !Array.isArray(discountRecord.metadata) ? discountRecord.metadata : {};
|
|
622
|
+
var uniqueIdentificationNumber = metadata.unique_identification_number;
|
|
623
|
+
if (uniqueIdentificationNumber !== undefined && uniqueIdentificationNumber !== null && String(uniqueIdentificationNumber).trim() !== '') {
|
|
624
|
+
return discount;
|
|
625
|
+
}
|
|
626
|
+
return _objectSpread(_objectSpread({}, discountRecord), {}, {
|
|
627
|
+
metadata: _objectSpread(_objectSpread({}, metadata), {}, {
|
|
628
|
+
unique_identification_number: createUuidV4()
|
|
629
|
+
})
|
|
630
|
+
});
|
|
631
|
+
}
|
|
614
632
|
function collectSubmitProductDiscountList(product) {
|
|
615
633
|
var submitDiscountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? _toConsumableArray(product.discount_list) : [];
|
|
616
634
|
var _iterator5 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
|
|
@@ -646,7 +664,7 @@ function collectSubmitProductDiscountList(product) {
|
|
|
646
664
|
} finally {
|
|
647
665
|
_iterator5.f();
|
|
648
666
|
}
|
|
649
|
-
return normalizeOrderProductDiscountList(submitDiscountList);
|
|
667
|
+
return normalizeOrderProductDiscountList(submitDiscountList.map(ensureSubmitDiscountIdentity));
|
|
650
668
|
}
|
|
651
669
|
|
|
652
670
|
/**
|
|
@@ -719,14 +737,37 @@ export function resolveEffectivePerUnitDiscount(product) {
|
|
|
719
737
|
if (!Number.isFinite(originalPrice) || !Number.isFinite(finalPrice)) return fromList;
|
|
720
738
|
return fromList + (originalPrice - finalPrice);
|
|
721
739
|
}
|
|
722
|
-
export function createDefaultOrderRulesHooks() {
|
|
740
|
+
export function createDefaultOrderRulesHooks(getBookings) {
|
|
741
|
+
var getProductStartDate = function getProductStartDate(product) {
|
|
742
|
+
var _ref14, _product$metadata$uni, _product$metadata2, _ref15, _product$booking_uid, _product$metadata3, _product$metadata4, _product$metadata5, _product$metadata6;
|
|
743
|
+
var productUid = String((_ref14 = (_product$metadata$uni = (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product.unique_identification_number) !== null && _ref14 !== void 0 ? _ref14 : '');
|
|
744
|
+
var bookingUid = String((_ref15 = (_product$booking_uid = product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.booking_uid) !== null && _ref15 !== void 0 ? _ref15 : '');
|
|
745
|
+
// 每次读取当前 bookings,覆盖改期、订单回显以及直接调用 Rules 的选券入口。
|
|
746
|
+
var bookings = (getBookings === null || getBookings === void 0 ? void 0 : getBookings()) || [];
|
|
747
|
+
var booking = bookings.find(function (item) {
|
|
748
|
+
var _ref16, _item$product_uid, _item$metadata3;
|
|
749
|
+
return productUid && String((_ref16 = (_item$product_uid = item === null || item === void 0 ? void 0 : item.product_uid) !== null && _item$product_uid !== void 0 ? _item$product_uid : item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.product_uid) !== null && _ref16 !== void 0 ? _ref16 : '') === productUid;
|
|
750
|
+
}) || bookings.find(function (item) {
|
|
751
|
+
var _ref17, _item$metadata$unique, _item$metadata4;
|
|
752
|
+
return bookingUid && String((_ref17 = (_item$metadata$unique = item === null || item === void 0 || (_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.unique_identification_number) !== null && _item$metadata$unique !== void 0 ? _item$metadata$unique : item === null || item === void 0 ? void 0 : item.booking_uid) !== null && _ref17 !== void 0 ? _ref17 : '') === bookingUid;
|
|
753
|
+
});
|
|
754
|
+
if (booking) {
|
|
755
|
+
// 严格解析并保留 Invalid Date,让公共时间校验拒绝缺失/非法时间,避免回退到当前时间。
|
|
756
|
+
return dayjs("".concat(booking.start_date, " ").concat(booking.start_time), ['YYYY-MM-DD HH:mm', 'YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD H:mm', 'YYYY-MM-DD H:mm:ss'], true);
|
|
757
|
+
}
|
|
758
|
+
if (getBookings && (bookingUid || product.booking_id || (_product$metadata4 = product.metadata) !== null && _product$metadata4 !== void 0 && _product$metadata4.booking_id)) {
|
|
759
|
+
return dayjs('');
|
|
760
|
+
}
|
|
761
|
+
var legacyStartDate = ((_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.start_date) || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.startDate);
|
|
762
|
+
return legacyStartDate ? dayjs(legacyStartDate) : undefined;
|
|
763
|
+
};
|
|
723
764
|
var toUnitPriceString = function toUnitPriceString(totalLike, num) {
|
|
724
765
|
var effectiveNum = Number(num) > 0 ? Number(num) : 1;
|
|
725
766
|
return new Decimal(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
|
|
726
767
|
};
|
|
727
768
|
var getBundleIdentity = function getBundleIdentity(bundle) {
|
|
728
|
-
var
|
|
729
|
-
return [(
|
|
769
|
+
var _ref18, _bundle$bundle_id, _ref19, _ref20, _bundle$bundle_produc, _ref21, _ref22, _bundle$bundle_varian, _ref23, _bundle$bundle_group_;
|
|
770
|
+
return [(_ref18 = (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id) !== null && _ref18 !== void 0 ? _ref18 : '', (_ref19 = (_ref20 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref20 !== void 0 ? _ref20 : bundle.product_id) !== null && _ref19 !== void 0 ? _ref19 : '', (_ref21 = (_ref22 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref22 !== void 0 ? _ref22 : bundle.product_variant_id) !== null && _ref21 !== void 0 ? _ref21 : 0, (_ref23 = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id) !== null && _ref23 !== void 0 ? _ref23 : ''].join('|');
|
|
730
771
|
};
|
|
731
772
|
var mergeRulesBundlePrices = function mergeRulesBundlePrices(currentBundle, rulesBundle) {
|
|
732
773
|
if (!Array.isArray(rulesBundle)) return rulesBundle;
|
|
@@ -736,7 +777,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
736
777
|
currentByIdentity.set(getBundleIdentity(bundle), bundle);
|
|
737
778
|
});
|
|
738
779
|
return rulesBundle.map(function (bundle) {
|
|
739
|
-
var _bundle$price_type_ex2,
|
|
780
|
+
var _bundle$price_type_ex2, _ref24, _ref25, _current$price, _ref26, _ref27, _ref28, _current$original_pri;
|
|
740
781
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
741
782
|
var current = currentByIdentity.get(getBundleIdentity(bundle));
|
|
742
783
|
if (!current) return bundle;
|
|
@@ -745,8 +786,8 @@ export function createDefaultOrderRulesHooks() {
|
|
|
745
786
|
} : {});
|
|
746
787
|
var isProductPriceBundle = ((_bundle$price_type_ex2 = bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : current.price_type_ext) === 'product_price';
|
|
747
788
|
if (!isProductPriceBundle) return bundleWithDisplayFields;
|
|
748
|
-
var sourcePrice = (
|
|
749
|
-
var originalPrice = (
|
|
789
|
+
var sourcePrice = (_ref24 = (_ref25 = (_current$price = current.price) !== null && _current$price !== void 0 ? _current$price : current.custom_price) !== null && _ref25 !== void 0 ? _ref25 : current.original_price) !== null && _ref24 !== void 0 ? _ref24 : current.bundle_selling_price;
|
|
790
|
+
var originalPrice = (_ref26 = (_ref27 = (_ref28 = (_current$original_pri = current.original_price) !== null && _current$original_pri !== void 0 ? _current$original_pri : current.product_price) !== null && _ref28 !== void 0 ? _ref28 : current.price) !== null && _ref27 !== void 0 ? _ref27 : current.custom_price) !== null && _ref26 !== void 0 ? _ref26 : sourcePrice;
|
|
750
791
|
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, bundleWithDisplayFields), sourcePrice !== undefined ? {
|
|
751
792
|
price: sourcePrice
|
|
752
793
|
} : {}), originalPrice !== undefined ? {
|
|
@@ -758,7 +799,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
758
799
|
};
|
|
759
800
|
return {
|
|
760
801
|
getProduct: function getProduct(product) {
|
|
761
|
-
var _product$
|
|
802
|
+
var _product$metadata7, _product$metadata8, _product$metadata9, _metadataAny$_promoti;
|
|
762
803
|
// source_product_price 是权威源;兜底链:source → mainSelling − options(反推)→ 行 selling_price
|
|
763
804
|
var metadataAny = product.metadata || {};
|
|
764
805
|
var optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
|
|
@@ -785,7 +826,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
785
826
|
// 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
|
|
786
827
|
// 不透明 identity 契约下,normalizeOrderProduct / hydrate 已保证唯一值存在;
|
|
787
828
|
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
788
|
-
_id: (_product$
|
|
829
|
+
_id: (_product$metadata7 = product.metadata) !== null && _product$metadata7 !== void 0 && _product$metadata7.unique_identification_number ? "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(product.metadata.unique_identification_number) : "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(buildProductLineFingerprint(getProductSkuOptions(product), product.product_bundle)),
|
|
789
830
|
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
790
831
|
// 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
|
|
791
832
|
price: sourcePrice,
|
|
@@ -797,23 +838,23 @@ export function createDefaultOrderRulesHooks() {
|
|
|
797
838
|
num: product.num || 1,
|
|
798
839
|
discount_list: product.discount_list || [],
|
|
799
840
|
bundle: product.product_bundle || [],
|
|
800
|
-
booking_id: ((_product$
|
|
841
|
+
booking_id: ((_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.booking_id) || null,
|
|
801
842
|
isClient: false,
|
|
802
843
|
// 勿写死 false:否则 Rules 不会走 total≠origin_total 的手动价推断,
|
|
803
844
|
// 无券时会把 bundle 价还原成 original_price(手动改价套餐会从 20 回到 30)。
|
|
804
845
|
isManualDiscount: resolveRulesManualDiscountFlag(metadataAny),
|
|
805
|
-
holder_id: (_product$
|
|
806
|
-
startDate: (
|
|
846
|
+
holder_id: (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.holder_id,
|
|
847
|
+
startDate: getProductStartDate(product),
|
|
807
848
|
main_product_selling_price: metadataAny.main_product_selling_price !== undefined ? new Decimal(Number(metadataAny.main_product_selling_price) || 0).minus(optionSum).toDecimalPlaces(2).toString() : undefined,
|
|
808
849
|
inPromotion: ((_metadataAny$_promoti = metadataAny._promotion) === null || _metadataAny$_promoti === void 0 ? void 0 : _metadataAny$_promoti.inPromotion) === true,
|
|
809
850
|
_promotion: metadataAny._promotion
|
|
810
851
|
};
|
|
811
852
|
},
|
|
812
853
|
setProduct: function setProduct(product, values) {
|
|
813
|
-
var
|
|
814
|
-
var nextNum = Number((
|
|
854
|
+
var _ref29, _values$quantity, _ref30, _metadataAny$source_p, _values$discount_list, _values$quantity2;
|
|
855
|
+
var nextNum = Number((_ref29 = (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num) !== null && _ref29 !== void 0 ? _ref29 : 1) || 1;
|
|
815
856
|
var metadataAny = product.metadata || {};
|
|
816
|
-
var existedSource = (
|
|
857
|
+
var existedSource = (_ref30 = (_metadataAny$source_p = metadataAny.source_product_price) !== null && _metadataAny$source_p !== void 0 ? _metadataAny$source_p : product.selling_price) !== null && _ref30 !== void 0 ? _ref30 : '0';
|
|
817
858
|
var nextOptions = getProductSkuOptions(product);
|
|
818
859
|
var optionSum = sumOptionUnitPrice(nextOptions);
|
|
819
860
|
|
|
@@ -1024,7 +1065,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1024
1065
|
var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1025
1066
|
if (!Array.isArray(bundle)) return [];
|
|
1026
1067
|
return bundle.map(function (b) {
|
|
1027
|
-
var
|
|
1068
|
+
var _ref31, _rawBundle$price, _rawBundle$surcharge_, _rawBundle$num, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$quantity, _rawBundle$extension_, _rawBundle$extension_2, _ref32, _rawBundle$price_type, _ref33, _rawBundle$price_type2, _rawBundle$bundle_gro, _rawBundle$bundle_id, _rawBundle$bundle_pro;
|
|
1028
1069
|
var rawBundle = b && _typeof(b) === 'object' ? b : {};
|
|
1029
1070
|
var existedMetadata = rawBundle.metadata && _typeof(rawBundle.metadata) === 'object' ? rawBundle.metadata : {};
|
|
1030
1071
|
var _customProductBundleMapId = existedMetadata.custom_product_bundle_map_id,
|
|
@@ -1035,7 +1076,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1035
1076
|
var sellingPrice = formatOptions.virtualSettlementMode ? '0.00' : getBundleSellingMagnitude(rawBundle).toFixed(2);
|
|
1036
1077
|
// payment 价由整单折扣均摊层产出;缺省(无折扣)时与 selling 净额同义。
|
|
1037
1078
|
var paymentPrice = formatOptions.virtualSettlementMode ? '0.00' : rawBundle.bundle_payment_price !== undefined && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== '' ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
|
|
1038
|
-
var priceValue = formatOptions.virtualSettlementMode ? 0 : (
|
|
1079
|
+
var priceValue = formatOptions.virtualSettlementMode ? 0 : (_ref31 = (_rawBundle$price = rawBundle.price) !== null && _rawBundle$price !== void 0 ? _rawBundle$price : rawBundle.custom_price) !== null && _ref31 !== void 0 ? _ref31 : rawBundle.bundle_selling_price;
|
|
1039
1080
|
var relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
|
|
1040
1081
|
var surchargeFee = toMoneyString((_rawBundle$surcharge_ = rawBundle.surcharge_fee) !== null && _rawBundle$surcharge_ !== void 0 ? _rawBundle$surcharge_ : existedMetadata.surcharge_fee);
|
|
1041
1082
|
var productDiscountDifference = toBundleNumber(existedMetadata.product_discount_difference, 0);
|
|
@@ -1054,8 +1095,8 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1054
1095
|
extension_id: (_rawBundle$extension_ = rawBundle.extension_id) !== null && _rawBundle$extension_ !== void 0 ? _rawBundle$extension_ : 0,
|
|
1055
1096
|
extension_type: (_rawBundle$extension_2 = rawBundle.extension_type) !== null && _rawBundle$extension_2 !== void 0 ? _rawBundle$extension_2 : 'normal',
|
|
1056
1097
|
price: priceValue,
|
|
1057
|
-
price_type: (
|
|
1058
|
-
price_type_ext: (
|
|
1098
|
+
price_type: (_ref32 = (_rawBundle$price_type = rawBundle.price_type) !== null && _rawBundle$price_type !== void 0 ? _rawBundle$price_type : rawBundle.custom_price_type) !== null && _ref32 !== void 0 ? _ref32 : '',
|
|
1099
|
+
price_type_ext: (_ref33 = (_rawBundle$price_type2 = rawBundle.price_type_ext) !== null && _rawBundle$price_type2 !== void 0 ? _rawBundle$price_type2 : rawBundle.custom_price_type_ext) !== null && _ref33 !== void 0 ? _ref33 : '',
|
|
1059
1100
|
bundle_selling_price: sellingPrice,
|
|
1060
1101
|
bundle_payment_price: paymentPrice,
|
|
1061
1102
|
option: formatSubmitOptionItems(rawBundle.option, formatOptions),
|
|
@@ -1091,11 +1132,11 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1091
1132
|
* 法币仅做字段/metadata 裁剪;虚拟币在出站前再次执行零加价与固定单价断言。
|
|
1092
1133
|
*/
|
|
1093
1134
|
function normalizeSubmitProduct(product) {
|
|
1094
|
-
var
|
|
1135
|
+
var _ref35, _submitProduct$bundle, _rawMetadata$product_, _rawMetadata$selected, _rawMetadata$selected2, _submitProduct$produc, _submitProduct$paymen;
|
|
1095
1136
|
var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1096
|
-
var
|
|
1097
|
-
_runtimeUid =
|
|
1098
|
-
submitProduct = _objectWithoutProperties(
|
|
1137
|
+
var _ref34 = product,
|
|
1138
|
+
_runtimeUid = _ref34.unique_identification_number,
|
|
1139
|
+
submitProduct = _objectWithoutProperties(_ref34, _excluded2);
|
|
1099
1140
|
var num = submitProduct.num,
|
|
1100
1141
|
_productSurchargeFee = submitProduct.surcharge_fee,
|
|
1101
1142
|
_deprecatedDiscountAmount = submitProduct.discount_amount,
|
|
@@ -1112,7 +1153,7 @@ function normalizeSubmitProduct(product) {
|
|
|
1112
1153
|
// 兼容历史 BigSale 编辑链路:bundle_edit 曾被写入 metadata,
|
|
1113
1154
|
// 出站时需提升到商品顶层;套餐未编辑时也必须显式提交 0。
|
|
1114
1155
|
var hasProductBundle = Array.isArray(submitProduct.product_bundle) && submitProduct.product_bundle.length > 0;
|
|
1115
|
-
var bundleEdit = (
|
|
1156
|
+
var bundleEdit = (_ref35 = (_submitProduct$bundle = submitProduct.bundle_edit) !== null && _submitProduct$bundle !== void 0 ? _submitProduct$bundle : rawMetadata.bundle_edit) !== null && _ref35 !== void 0 ? _ref35 : hasProductBundle ? 0 : undefined;
|
|
1116
1157
|
var cleanMetadata = {};
|
|
1117
1158
|
if (rawMetadata.unique_identification_number) {
|
|
1118
1159
|
cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
|
|
@@ -1343,7 +1384,7 @@ export function resolveSubmitOrderType(params) {
|
|
|
1343
1384
|
return 'virtual';
|
|
1344
1385
|
}
|
|
1345
1386
|
export function buildSubmitPayload(params) {
|
|
1346
|
-
var _tempOrder$metadata2, _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_,
|
|
1387
|
+
var _tempOrder$metadata2, _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_, _ref37, _tempOrder$is_price_i, _tempOrder$is_deposit, _tempOrder$_extend, _enhancedPayload$summ;
|
|
1347
1388
|
var tempOrder = params.tempOrder,
|
|
1348
1389
|
cacheId = params.cacheId,
|
|
1349
1390
|
_params$now = params.now,
|
|
@@ -1357,29 +1398,29 @@ export function buildSubmitPayload(params) {
|
|
|
1357
1398
|
var scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
|
|
1358
1399
|
var bookingUuid = createUuidV4();
|
|
1359
1400
|
var virtualSettlementMode = ((_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.currency_settlement_config) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2.settlement_type) === 'virtual_currency';
|
|
1360
|
-
var
|
|
1361
|
-
_extend =
|
|
1362
|
-
_relationId =
|
|
1363
|
-
_tableFormId =
|
|
1364
|
-
_resourceId =
|
|
1365
|
-
_summary =
|
|
1366
|
-
_lastOrderInfo =
|
|
1367
|
-
_paidAmount =
|
|
1368
|
-
_shopId =
|
|
1369
|
-
_shopNote =
|
|
1370
|
-
_shopServiceType =
|
|
1371
|
-
_startTime =
|
|
1372
|
-
_customer =
|
|
1373
|
-
_discountList =
|
|
1374
|
-
_orderMetaList =
|
|
1375
|
-
_rootTaxFee =
|
|
1376
|
-
_totalAmount =
|
|
1377
|
-
_totalRefundAmount =
|
|
1378
|
-
_createDate =
|
|
1379
|
-
_holderId =
|
|
1380
|
-
_paymentStatus =
|
|
1381
|
-
_notes =
|
|
1382
|
-
tempOrderRest = _objectWithoutProperties(
|
|
1401
|
+
var _ref36 = tempOrder,
|
|
1402
|
+
_extend = _ref36._extend,
|
|
1403
|
+
_relationId = _ref36.relation_id,
|
|
1404
|
+
_tableFormId = _ref36.table_form_id,
|
|
1405
|
+
_resourceId = _ref36.resource_id,
|
|
1406
|
+
_summary = _ref36.summary,
|
|
1407
|
+
_lastOrderInfo = _ref36.lastOrderInfo,
|
|
1408
|
+
_paidAmount = _ref36.paid_amount,
|
|
1409
|
+
_shopId = _ref36.shop_id,
|
|
1410
|
+
_shopNote = _ref36.shop_note,
|
|
1411
|
+
_shopServiceType = _ref36.shop_service_type,
|
|
1412
|
+
_startTime = _ref36.start_time,
|
|
1413
|
+
_customer = _ref36.customer,
|
|
1414
|
+
_discountList = _ref36.discount_list,
|
|
1415
|
+
_orderMetaList = _ref36.order_meta_list,
|
|
1416
|
+
_rootTaxFee = _ref36.tax_fee,
|
|
1417
|
+
_totalAmount = _ref36.total_amount,
|
|
1418
|
+
_totalRefundAmount = _ref36.total_refund_amount,
|
|
1419
|
+
_createDate = _ref36.create_date,
|
|
1420
|
+
_holderId = _ref36.holder_id,
|
|
1421
|
+
_paymentStatus = _ref36.payment_status,
|
|
1422
|
+
_notes = _ref36.notes,
|
|
1423
|
+
tempOrderRest = _objectWithoutProperties(_ref36, _excluded4);
|
|
1383
1424
|
var resolvedBusinessCode = businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code;
|
|
1384
1425
|
var normalizedOrderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
|
|
1385
1426
|
var submitType = resolveSubmitOrderType({
|
|
@@ -1404,7 +1445,7 @@ export function buildSubmitPayload(params) {
|
|
|
1404
1445
|
type: submitType,
|
|
1405
1446
|
business_code: resolvedBusinessCode,
|
|
1406
1447
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
1407
|
-
order_sales_channel: (
|
|
1448
|
+
order_sales_channel: (_ref37 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref37 !== void 0 ? _ref37 : 'online_store',
|
|
1408
1449
|
status: tempOrder.status || 'normal'
|
|
1409
1450
|
}, params.includePaymentStatus !== false ? {
|
|
1410
1451
|
payment_status: tempOrder.payment_status || 'payment_processing'
|
|
@@ -1432,13 +1473,13 @@ export function buildSubmitPayload(params) {
|
|
|
1432
1473
|
// holder: tempOrder.holder || null,
|
|
1433
1474
|
summary: summary || tempOrder.summary || createEmptySummary(),
|
|
1434
1475
|
metadata: function () {
|
|
1435
|
-
var
|
|
1436
|
-
_collectPax =
|
|
1437
|
-
_tableOccupancyDuration =
|
|
1438
|
-
_cartSettlementKey =
|
|
1439
|
-
_cartSettlementSnapshot =
|
|
1440
|
-
_legalCurrencySnapshot =
|
|
1441
|
-
rest = _objectWithoutProperties(
|
|
1476
|
+
var _ref38 = tempOrder.metadata || {},
|
|
1477
|
+
_collectPax = _ref38.collect_pax,
|
|
1478
|
+
_tableOccupancyDuration = _ref38.table_occupancy_duration,
|
|
1479
|
+
_cartSettlementKey = _ref38.cart_settlement_key,
|
|
1480
|
+
_cartSettlementSnapshot = _ref38.cart_settlement_snapshot,
|
|
1481
|
+
_legalCurrencySnapshot = _ref38.legal_currency_snapshot,
|
|
1482
|
+
rest = _objectWithoutProperties(_ref38, _excluded5);
|
|
1442
1483
|
return _objectSpread({}, rest);
|
|
1443
1484
|
}()
|
|
1444
1485
|
}, (_tempOrder$_extend = tempOrder._extend) !== null && _tempOrder$_extend !== void 0 && (_tempOrder$_extend = _tempOrder$_extend.salesNotesState) !== null && _tempOrder$_extend !== void 0 && _tempOrder$_extend.dirty ? {
|
|
@@ -1642,9 +1683,9 @@ export function clearTempOrderHolderAssignments(tempOrder) {
|
|
|
1642
1683
|
* getOrderProductLineUid({ metadata: { unique_identification_number: 'line-1' } }); // 'line-1'
|
|
1643
1684
|
*/
|
|
1644
1685
|
export function getOrderProductLineUid(product) {
|
|
1645
|
-
var _product$metadata$
|
|
1686
|
+
var _product$metadata$uni2, _product$metadata10;
|
|
1646
1687
|
if (!product || _typeof(product) !== 'object') return null;
|
|
1647
|
-
var uid = (_product$metadata$
|
|
1688
|
+
var uid = (_product$metadata$uni2 = (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.unique_identification_number) !== null && _product$metadata$uni2 !== void 0 ? _product$metadata$uni2 : product.unique_identification_number;
|
|
1648
1689
|
if (uid === undefined || uid === null || uid === '') return null;
|
|
1649
1690
|
return String(uid);
|
|
1650
1691
|
}
|
|
@@ -1655,8 +1696,8 @@ export function getRuntimeProductOrigin(tempOrder, product) {
|
|
|
1655
1696
|
return tempOrder._extend.productsByUid[uid].origin;
|
|
1656
1697
|
}
|
|
1657
1698
|
var matchedProduct = ((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || []).find(function (item) {
|
|
1658
|
-
var
|
|
1659
|
-
return item === product || getOrderProductLineUid(item) === uid || String((
|
|
1699
|
+
var _ref39, _item$product_id, _ref40, _product$product_id;
|
|
1700
|
+
return item === product || getOrderProductLineUid(item) === uid || String((_ref39 = (_item$product_id = item === null || item === void 0 ? void 0 : item.product_id) !== null && _item$product_id !== void 0 ? _item$product_id : item === null || item === void 0 ? void 0 : item.id) !== null && _ref39 !== void 0 ? _ref39 : '') === String((_ref40 = (_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product === null || product === void 0 ? void 0 : product.id) !== null && _ref40 !== void 0 ? _ref40 : '');
|
|
1660
1701
|
});
|
|
1661
1702
|
var matchedUid = matchedProduct ? getOrderProductLineUid(matchedProduct) : '';
|
|
1662
1703
|
return matchedUid ? (tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[matchedUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin) || null : null;
|
|
@@ -412,6 +412,8 @@ export interface WalletAssetsBehaviorOptions {
|
|
|
412
412
|
export interface RefreshWalletAssetsOptions {
|
|
413
413
|
/** 商品/金额变化默认保留并重验选择;客户变化由实现层强制清空。 */
|
|
414
414
|
preserveSelection?: boolean;
|
|
415
|
+
/** 客户变化时,仅保留与本次扫码匹配的搜索结果;其他搜索缓存仍会清空。 */
|
|
416
|
+
retainSearchResultCodes?: string[];
|
|
415
417
|
}
|
|
416
418
|
export interface SelectWalletAssetOptions {
|
|
417
419
|
selected: boolean;
|
|
@@ -419,6 +421,8 @@ export interface SelectWalletAssetOptions {
|
|
|
419
421
|
}
|
|
420
422
|
export interface ScanWalletAssetResult {
|
|
421
423
|
type: SearchIdentificationCodeResult['type'];
|
|
424
|
+
/** walletCode 时保留完整 Wallet Detail,供客户解析与客户选择器使用。 */
|
|
425
|
+
data?: WalletDetailSearchData;
|
|
422
426
|
asset?: any;
|
|
423
427
|
selected: boolean;
|
|
424
428
|
state: WalletAssetsState;
|
|
@@ -864,6 +868,8 @@ export interface SearchIdentificationCodeParams extends WalletDeductionRecommend
|
|
|
864
868
|
* 搜索识别码响应数据
|
|
865
869
|
*/
|
|
866
870
|
export interface SearchIdentificationCodeResponse {
|
|
871
|
+
/** 业务是否成功 */
|
|
872
|
+
status?: boolean;
|
|
867
873
|
/** 响应状态码 */
|
|
868
874
|
code?: number;
|
|
869
875
|
/** 响应消息 */
|
|
@@ -871,12 +877,26 @@ export interface SearchIdentificationCodeResponse {
|
|
|
871
877
|
/** 响应数据 */
|
|
872
878
|
data?: SearchIdentificationCodeItem[];
|
|
873
879
|
}
|
|
880
|
+
/** Wallet code 精确搜索返回的 Wallet Detail。 */
|
|
881
|
+
export interface WalletDetailSearchData {
|
|
882
|
+
id?: string | number;
|
|
883
|
+
customer_id?: string | number;
|
|
884
|
+
customer?: Record<string, any> | null;
|
|
885
|
+
is_cross_shop_wallet?: boolean | 0 | 1;
|
|
886
|
+
[key: string]: any;
|
|
887
|
+
}
|
|
888
|
+
export interface WalletDetailSearchResponse {
|
|
889
|
+
status?: boolean;
|
|
890
|
+
code?: number;
|
|
891
|
+
message?: string;
|
|
892
|
+
data?: WalletDetailSearchData | null;
|
|
893
|
+
}
|
|
874
894
|
/**
|
|
875
895
|
* 搜索识别码结果类型
|
|
876
896
|
*/
|
|
877
897
|
export type SearchIdentificationCodeResult = {
|
|
878
898
|
type: 'walletCode';
|
|
879
|
-
data:
|
|
899
|
+
data: WalletDetailSearchData;
|
|
880
900
|
} | {
|
|
881
901
|
type: 'normalCode';
|
|
882
902
|
data: SearchIdentificationCodeItem[];
|
|
@@ -96,7 +96,7 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
96
96
|
* 搜索识别码信息
|
|
97
97
|
* 通过识别码搜索相关的钱包通行证信息
|
|
98
98
|
* 基于 WalletDeductionRecommendParams 参数结构
|
|
99
|
-
*
|
|
99
|
+
* 特殊逻辑:WL 或指定 200 格式的 Wallet Code 调用 /wallet/detail/search 接口。
|
|
100
100
|
*/
|
|
101
101
|
searchIdentificationCodeAsync(params: SearchIdentificationCodeParams, config?: {
|
|
102
102
|
noCache?: boolean;
|