@pisell/pisellos 2.3.126 → 2.3.127
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- 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 +440 -232
- 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 +2 -3
- 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/promotion/index.js +46 -1
- 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 +2 -3
- 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
|
}
|
|
@@ -171,7 +171,7 @@ export declare function resolveManualOverrideLineOriginalPrice(params: {
|
|
|
171
171
|
* // => -4
|
|
172
172
|
*/
|
|
173
173
|
export declare function resolveEffectivePerUnitDiscount(product: Record<string, any>): number;
|
|
174
|
-
export declare function createDefaultOrderRulesHooks(): RulesParamsHooks;
|
|
174
|
+
export declare function createDefaultOrderRulesHooks(getBookings?: () => OrderTempOrder['bookings']): RulesParamsHooks;
|
|
175
175
|
/**
|
|
176
176
|
* 通过 session 类商品的开始时间结束时间生成商品的时长
|
|
177
177
|
* @param {CartItem} cartItem
|
|
@@ -23,11 +23,13 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
23
23
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
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) {
|
|
@@ -657,6 +659,22 @@ function resolveSubmitBundleMapId(bundle) {
|
|
|
657
659
|
}
|
|
658
660
|
return undefined;
|
|
659
661
|
}
|
|
662
|
+
function ensureSubmitDiscountIdentity(discount) {
|
|
663
|
+
if (!discount || _typeof(discount) !== 'object' || Array.isArray(discount)) {
|
|
664
|
+
return discount;
|
|
665
|
+
}
|
|
666
|
+
var discountRecord = discount;
|
|
667
|
+
var metadata = discountRecord.metadata && _typeof(discountRecord.metadata) === 'object' && !Array.isArray(discountRecord.metadata) ? discountRecord.metadata : {};
|
|
668
|
+
var uniqueIdentificationNumber = metadata.unique_identification_number;
|
|
669
|
+
if (uniqueIdentificationNumber !== undefined && uniqueIdentificationNumber !== null && String(uniqueIdentificationNumber).trim() !== '') {
|
|
670
|
+
return discount;
|
|
671
|
+
}
|
|
672
|
+
return _objectSpread(_objectSpread({}, discountRecord), {}, {
|
|
673
|
+
metadata: _objectSpread(_objectSpread({}, metadata), {}, {
|
|
674
|
+
unique_identification_number: createUuidV4()
|
|
675
|
+
})
|
|
676
|
+
});
|
|
677
|
+
}
|
|
660
678
|
function collectSubmitProductDiscountList(product) {
|
|
661
679
|
var submitDiscountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? _toConsumableArray(product.discount_list) : [];
|
|
662
680
|
var _iterator5 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
|
|
@@ -692,7 +710,7 @@ function collectSubmitProductDiscountList(product) {
|
|
|
692
710
|
} finally {
|
|
693
711
|
_iterator5.f();
|
|
694
712
|
}
|
|
695
|
-
return normalizeOrderProductDiscountList(submitDiscountList);
|
|
713
|
+
return normalizeOrderProductDiscountList(submitDiscountList.map(ensureSubmitDiscountIdentity));
|
|
696
714
|
}
|
|
697
715
|
|
|
698
716
|
/**
|
|
@@ -765,14 +783,37 @@ export function resolveEffectivePerUnitDiscount(product) {
|
|
|
765
783
|
if (!Number.isFinite(originalPrice) || !Number.isFinite(finalPrice)) return fromList;
|
|
766
784
|
return fromList + (originalPrice - finalPrice);
|
|
767
785
|
}
|
|
768
|
-
export function createDefaultOrderRulesHooks() {
|
|
786
|
+
export function createDefaultOrderRulesHooks(getBookings) {
|
|
787
|
+
var getProductStartDate = function getProductStartDate(product) {
|
|
788
|
+
var _ref17, _product$metadata$uni, _product$metadata2, _ref18, _product$booking_uid, _product$metadata3, _product$metadata4, _product$metadata5, _product$metadata6;
|
|
789
|
+
var productUid = String((_ref17 = (_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 && _ref17 !== void 0 ? _ref17 : '');
|
|
790
|
+
var bookingUid = String((_ref18 = (_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 && _ref18 !== void 0 ? _ref18 : '');
|
|
791
|
+
// 每次读取当前 bookings,覆盖改期、订单回显以及直接调用 Rules 的选券入口。
|
|
792
|
+
var bookings = (getBookings === null || getBookings === void 0 ? void 0 : getBookings()) || [];
|
|
793
|
+
var booking = bookings.find(function (item) {
|
|
794
|
+
var _ref19, _item$product_uid, _item$metadata3;
|
|
795
|
+
return productUid && String((_ref19 = (_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 && _ref19 !== void 0 ? _ref19 : '') === productUid;
|
|
796
|
+
}) || bookings.find(function (item) {
|
|
797
|
+
var _ref20, _item$metadata$unique, _item$metadata4;
|
|
798
|
+
return bookingUid && String((_ref20 = (_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 && _ref20 !== void 0 ? _ref20 : '') === bookingUid;
|
|
799
|
+
});
|
|
800
|
+
if (booking) {
|
|
801
|
+
// 严格解析并保留 Invalid Date,让公共时间校验拒绝缺失/非法时间,避免回退到当前时间。
|
|
802
|
+
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);
|
|
803
|
+
}
|
|
804
|
+
if (getBookings && (bookingUid || product.booking_id || (_product$metadata4 = product.metadata) !== null && _product$metadata4 !== void 0 && _product$metadata4.booking_id)) {
|
|
805
|
+
return dayjs('');
|
|
806
|
+
}
|
|
807
|
+
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);
|
|
808
|
+
return legacyStartDate ? dayjs(legacyStartDate) : undefined;
|
|
809
|
+
};
|
|
769
810
|
var toUnitPriceString = function toUnitPriceString(totalLike, num) {
|
|
770
811
|
var effectiveNum = Number(num) > 0 ? Number(num) : 1;
|
|
771
812
|
return new Decimal(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
|
|
772
813
|
};
|
|
773
814
|
var getBundleIdentity = function getBundleIdentity(bundle) {
|
|
774
|
-
var
|
|
775
|
-
return [(
|
|
815
|
+
var _ref21, _bundle$bundle_id, _ref22, _ref23, _bundle$bundle_produc, _ref24, _ref25, _bundle$bundle_varian, _ref26, _bundle$bundle_group_;
|
|
816
|
+
return [(_ref21 = (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id) !== null && _ref21 !== void 0 ? _ref21 : '', (_ref22 = (_ref23 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref23 !== void 0 ? _ref23 : bundle.product_id) !== null && _ref22 !== void 0 ? _ref22 : '', (_ref24 = (_ref25 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref25 !== void 0 ? _ref25 : bundle.product_variant_id) !== null && _ref24 !== void 0 ? _ref24 : 0, (_ref26 = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id) !== null && _ref26 !== void 0 ? _ref26 : ''].join('|');
|
|
776
817
|
};
|
|
777
818
|
var mergeRulesBundlePrices = function mergeRulesBundlePrices(currentBundle, rulesBundle) {
|
|
778
819
|
if (!Array.isArray(rulesBundle)) return rulesBundle;
|
|
@@ -782,7 +823,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
782
823
|
currentByIdentity.set(getBundleIdentity(bundle), bundle);
|
|
783
824
|
});
|
|
784
825
|
return rulesBundle.map(function (bundle) {
|
|
785
|
-
var _bundle$price_type_ex2,
|
|
826
|
+
var _bundle$price_type_ex2, _ref27, _ref28, _current$price, _ref29, _ref30, _ref31, _current$original_pri;
|
|
786
827
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
787
828
|
var current = currentByIdentity.get(getBundleIdentity(bundle));
|
|
788
829
|
if (!current) return bundle;
|
|
@@ -791,8 +832,8 @@ export function createDefaultOrderRulesHooks() {
|
|
|
791
832
|
} : {});
|
|
792
833
|
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';
|
|
793
834
|
if (!isProductPriceBundle) return bundleWithDisplayFields;
|
|
794
|
-
var sourcePrice = (
|
|
795
|
-
var originalPrice = (
|
|
835
|
+
var sourcePrice = (_ref27 = (_ref28 = (_current$price = current.price) !== null && _current$price !== void 0 ? _current$price : current.custom_price) !== null && _ref28 !== void 0 ? _ref28 : current.original_price) !== null && _ref27 !== void 0 ? _ref27 : current.bundle_selling_price;
|
|
836
|
+
var originalPrice = (_ref29 = (_ref30 = (_ref31 = (_current$original_pri = current.original_price) !== null && _current$original_pri !== void 0 ? _current$original_pri : current.product_price) !== null && _ref31 !== void 0 ? _ref31 : current.price) !== null && _ref30 !== void 0 ? _ref30 : current.custom_price) !== null && _ref29 !== void 0 ? _ref29 : sourcePrice;
|
|
796
837
|
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, bundleWithDisplayFields), sourcePrice !== undefined ? {
|
|
797
838
|
price: sourcePrice
|
|
798
839
|
} : {}), originalPrice !== undefined ? {
|
|
@@ -804,7 +845,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
804
845
|
};
|
|
805
846
|
return {
|
|
806
847
|
getProduct: function getProduct(product) {
|
|
807
|
-
var _product$
|
|
848
|
+
var _product$metadata7, _product$metadata8, _product$metadata9, _metadataAny$_promoti;
|
|
808
849
|
// source_product_price 是权威源;兜底链:source → mainSelling − options(反推)→ 行 selling_price
|
|
809
850
|
var metadataAny = product.metadata || {};
|
|
810
851
|
var optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
|
|
@@ -831,7 +872,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
831
872
|
// 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
|
|
832
873
|
// 不透明 identity 契约下,normalizeOrderProduct / hydrate 已保证唯一值存在;
|
|
833
874
|
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
834
|
-
_id: (_product$
|
|
875
|
+
_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)),
|
|
835
876
|
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
836
877
|
// 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
|
|
837
878
|
price: sourcePrice,
|
|
@@ -843,23 +884,23 @@ export function createDefaultOrderRulesHooks() {
|
|
|
843
884
|
num: product.num || 1,
|
|
844
885
|
discount_list: product.discount_list || [],
|
|
845
886
|
bundle: product.product_bundle || [],
|
|
846
|
-
booking_id: ((_product$
|
|
887
|
+
booking_id: ((_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.booking_id) || null,
|
|
847
888
|
isClient: false,
|
|
848
889
|
// 勿写死 false:否则 Rules 不会走 total≠origin_total 的手动价推断,
|
|
849
890
|
// 无券时会把 bundle 价还原成 original_price(手动改价套餐会从 20 回到 30)。
|
|
850
891
|
isManualDiscount: resolveRulesManualDiscountFlag(metadataAny),
|
|
851
|
-
holder_id: (_product$
|
|
852
|
-
startDate: (
|
|
892
|
+
holder_id: (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.holder_id,
|
|
893
|
+
startDate: getProductStartDate(product),
|
|
853
894
|
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,
|
|
854
895
|
inPromotion: ((_metadataAny$_promoti = metadataAny._promotion) === null || _metadataAny$_promoti === void 0 ? void 0 : _metadataAny$_promoti.inPromotion) === true,
|
|
855
896
|
_promotion: metadataAny._promotion
|
|
856
897
|
};
|
|
857
898
|
},
|
|
858
899
|
setProduct: function setProduct(product, values) {
|
|
859
|
-
var
|
|
860
|
-
var nextNum = Number((
|
|
900
|
+
var _ref32, _values$quantity, _ref33, _metadataAny$source_p, _values$discount_list, _values$quantity2;
|
|
901
|
+
var nextNum = Number((_ref32 = (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num) !== null && _ref32 !== void 0 ? _ref32 : 1) || 1;
|
|
861
902
|
var metadataAny = product.metadata || {};
|
|
862
|
-
var existedSource = (
|
|
903
|
+
var existedSource = (_ref33 = (_metadataAny$source_p = metadataAny.source_product_price) !== null && _metadataAny$source_p !== void 0 ? _metadataAny$source_p : product.selling_price) !== null && _ref33 !== void 0 ? _ref33 : '0';
|
|
863
904
|
var nextOptions = getProductSkuOptions(product);
|
|
864
905
|
var optionSum = sumOptionUnitPrice(nextOptions);
|
|
865
906
|
|
|
@@ -1070,7 +1111,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1070
1111
|
var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1071
1112
|
if (!Array.isArray(bundle)) return [];
|
|
1072
1113
|
return bundle.map(function (b) {
|
|
1073
|
-
var
|
|
1114
|
+
var _ref34, _rawBundle$price, _rawBundle$surcharge_, _rawBundle$num, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$quantity, _rawBundle$extension_, _rawBundle$extension_2, _ref35, _rawBundle$price_type, _ref36, _rawBundle$price_type2, _rawBundle$bundle_gro, _rawBundle$bundle_id, _rawBundle$bundle_pro;
|
|
1074
1115
|
var rawBundle = b && _typeof(b) === 'object' ? b : {};
|
|
1075
1116
|
var existedMetadata = rawBundle.metadata && _typeof(rawBundle.metadata) === 'object' ? rawBundle.metadata : {};
|
|
1076
1117
|
var _customProductBundleMapId = existedMetadata.custom_product_bundle_map_id,
|
|
@@ -1081,7 +1122,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1081
1122
|
var sellingPrice = formatOptions.virtualSettlementMode ? '0.00' : getBundleSellingMagnitude(rawBundle).toFixed(2);
|
|
1082
1123
|
// payment 价由整单折扣均摊层产出;缺省(无折扣)时与 selling 净额同义。
|
|
1083
1124
|
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;
|
|
1084
|
-
var priceValue = formatOptions.virtualSettlementMode ? 0 : (
|
|
1125
|
+
var priceValue = formatOptions.virtualSettlementMode ? 0 : (_ref34 = (_rawBundle$price = rawBundle.price) !== null && _rawBundle$price !== void 0 ? _rawBundle$price : rawBundle.custom_price) !== null && _ref34 !== void 0 ? _ref34 : rawBundle.bundle_selling_price;
|
|
1085
1126
|
var relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
|
|
1086
1127
|
var surchargeFee = toMoneyString((_rawBundle$surcharge_ = rawBundle.surcharge_fee) !== null && _rawBundle$surcharge_ !== void 0 ? _rawBundle$surcharge_ : existedMetadata.surcharge_fee);
|
|
1087
1128
|
var productDiscountDifference = toBundleNumber(existedMetadata.product_discount_difference, 0);
|
|
@@ -1100,8 +1141,8 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1100
1141
|
extension_id: (_rawBundle$extension_ = rawBundle.extension_id) !== null && _rawBundle$extension_ !== void 0 ? _rawBundle$extension_ : 0,
|
|
1101
1142
|
extension_type: (_rawBundle$extension_2 = rawBundle.extension_type) !== null && _rawBundle$extension_2 !== void 0 ? _rawBundle$extension_2 : 'normal',
|
|
1102
1143
|
price: priceValue,
|
|
1103
|
-
price_type: (
|
|
1104
|
-
price_type_ext: (
|
|
1144
|
+
price_type: (_ref35 = (_rawBundle$price_type = rawBundle.price_type) !== null && _rawBundle$price_type !== void 0 ? _rawBundle$price_type : rawBundle.custom_price_type) !== null && _ref35 !== void 0 ? _ref35 : '',
|
|
1145
|
+
price_type_ext: (_ref36 = (_rawBundle$price_type2 = rawBundle.price_type_ext) !== null && _rawBundle$price_type2 !== void 0 ? _rawBundle$price_type2 : rawBundle.custom_price_type_ext) !== null && _ref36 !== void 0 ? _ref36 : '',
|
|
1105
1146
|
bundle_selling_price: sellingPrice,
|
|
1106
1147
|
bundle_payment_price: paymentPrice,
|
|
1107
1148
|
option: formatSubmitOptionItems(rawBundle.option, formatOptions),
|
|
@@ -1137,11 +1178,11 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1137
1178
|
* 法币仅做字段/metadata 裁剪;虚拟币在出站前再次执行零加价与固定单价断言。
|
|
1138
1179
|
*/
|
|
1139
1180
|
function normalizeSubmitProduct(product) {
|
|
1140
|
-
var
|
|
1181
|
+
var _ref38, _submitProduct$bundle, _rawMetadata$product_, _rawMetadata$selected, _rawMetadata$selected2, _submitProduct$produc, _submitProduct$paymen;
|
|
1141
1182
|
var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1142
|
-
var
|
|
1143
|
-
_runtimeUid =
|
|
1144
|
-
submitProduct = _objectWithoutProperties(
|
|
1183
|
+
var _ref37 = product,
|
|
1184
|
+
_runtimeUid = _ref37.unique_identification_number,
|
|
1185
|
+
submitProduct = _objectWithoutProperties(_ref37, _excluded2);
|
|
1145
1186
|
var num = submitProduct.num,
|
|
1146
1187
|
_productSurchargeFee = submitProduct.surcharge_fee,
|
|
1147
1188
|
_deprecatedDiscountAmount = submitProduct.discount_amount,
|
|
@@ -1158,7 +1199,7 @@ function normalizeSubmitProduct(product) {
|
|
|
1158
1199
|
// 兼容历史 BigSale 编辑链路:bundle_edit 曾被写入 metadata,
|
|
1159
1200
|
// 出站时需提升到商品顶层;套餐未编辑时也必须显式提交 0。
|
|
1160
1201
|
var hasProductBundle = Array.isArray(submitProduct.product_bundle) && submitProduct.product_bundle.length > 0;
|
|
1161
|
-
var bundleEdit = (
|
|
1202
|
+
var bundleEdit = (_ref38 = (_submitProduct$bundle = submitProduct.bundle_edit) !== null && _submitProduct$bundle !== void 0 ? _submitProduct$bundle : rawMetadata.bundle_edit) !== null && _ref38 !== void 0 ? _ref38 : hasProductBundle ? 0 : undefined;
|
|
1162
1203
|
var cleanMetadata = {};
|
|
1163
1204
|
if (rawMetadata.unique_identification_number) {
|
|
1164
1205
|
cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
|
|
@@ -1389,7 +1430,7 @@ export function resolveSubmitOrderType(params) {
|
|
|
1389
1430
|
return 'virtual';
|
|
1390
1431
|
}
|
|
1391
1432
|
export function buildSubmitPayload(params) {
|
|
1392
|
-
var _tempOrder$metadata2, _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_,
|
|
1433
|
+
var _tempOrder$metadata2, _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_, _ref40, _tempOrder$is_price_i, _tempOrder$is_deposit, _tempOrder$_extend, _enhancedPayload$summ;
|
|
1393
1434
|
var tempOrder = params.tempOrder,
|
|
1394
1435
|
cacheId = params.cacheId,
|
|
1395
1436
|
_params$now = params.now,
|
|
@@ -1403,29 +1444,29 @@ export function buildSubmitPayload(params) {
|
|
|
1403
1444
|
var scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
|
|
1404
1445
|
var bookingUuid = createUuidV4();
|
|
1405
1446
|
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';
|
|
1406
|
-
var
|
|
1407
|
-
_extend =
|
|
1408
|
-
_relationId =
|
|
1409
|
-
_tableFormId =
|
|
1410
|
-
_resourceId =
|
|
1411
|
-
_summary =
|
|
1412
|
-
_lastOrderInfo =
|
|
1413
|
-
_paidAmount =
|
|
1414
|
-
_shopId =
|
|
1415
|
-
_shopNote =
|
|
1416
|
-
_shopServiceType =
|
|
1417
|
-
_startTime =
|
|
1418
|
-
_customer =
|
|
1419
|
-
_discountList =
|
|
1420
|
-
_orderMetaList =
|
|
1421
|
-
_rootTaxFee =
|
|
1422
|
-
_totalAmount =
|
|
1423
|
-
_totalRefundAmount =
|
|
1424
|
-
_createDate =
|
|
1425
|
-
_holderId =
|
|
1426
|
-
_paymentStatus =
|
|
1427
|
-
_notes =
|
|
1428
|
-
tempOrderRest = _objectWithoutProperties(
|
|
1447
|
+
var _ref39 = tempOrder,
|
|
1448
|
+
_extend = _ref39._extend,
|
|
1449
|
+
_relationId = _ref39.relation_id,
|
|
1450
|
+
_tableFormId = _ref39.table_form_id,
|
|
1451
|
+
_resourceId = _ref39.resource_id,
|
|
1452
|
+
_summary = _ref39.summary,
|
|
1453
|
+
_lastOrderInfo = _ref39.lastOrderInfo,
|
|
1454
|
+
_paidAmount = _ref39.paid_amount,
|
|
1455
|
+
_shopId = _ref39.shop_id,
|
|
1456
|
+
_shopNote = _ref39.shop_note,
|
|
1457
|
+
_shopServiceType = _ref39.shop_service_type,
|
|
1458
|
+
_startTime = _ref39.start_time,
|
|
1459
|
+
_customer = _ref39.customer,
|
|
1460
|
+
_discountList = _ref39.discount_list,
|
|
1461
|
+
_orderMetaList = _ref39.order_meta_list,
|
|
1462
|
+
_rootTaxFee = _ref39.tax_fee,
|
|
1463
|
+
_totalAmount = _ref39.total_amount,
|
|
1464
|
+
_totalRefundAmount = _ref39.total_refund_amount,
|
|
1465
|
+
_createDate = _ref39.create_date,
|
|
1466
|
+
_holderId = _ref39.holder_id,
|
|
1467
|
+
_paymentStatus = _ref39.payment_status,
|
|
1468
|
+
_notes = _ref39.notes,
|
|
1469
|
+
tempOrderRest = _objectWithoutProperties(_ref39, _excluded4);
|
|
1429
1470
|
var resolvedBusinessCode = businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code;
|
|
1430
1471
|
var normalizedOrderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
|
|
1431
1472
|
var submitType = resolveSubmitOrderType({
|
|
@@ -1450,7 +1491,7 @@ export function buildSubmitPayload(params) {
|
|
|
1450
1491
|
type: submitType,
|
|
1451
1492
|
business_code: resolvedBusinessCode,
|
|
1452
1493
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
1453
|
-
order_sales_channel: (
|
|
1494
|
+
order_sales_channel: (_ref40 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref40 !== void 0 ? _ref40 : 'online_store',
|
|
1454
1495
|
status: tempOrder.status || 'normal'
|
|
1455
1496
|
}, params.includePaymentStatus !== false ? {
|
|
1456
1497
|
payment_status: tempOrder.payment_status || 'payment_processing'
|
|
@@ -1478,13 +1519,13 @@ export function buildSubmitPayload(params) {
|
|
|
1478
1519
|
// holder: tempOrder.holder || null,
|
|
1479
1520
|
summary: summary || tempOrder.summary || createEmptySummary(),
|
|
1480
1521
|
metadata: function () {
|
|
1481
|
-
var
|
|
1482
|
-
_collectPax =
|
|
1483
|
-
_tableOccupancyDuration =
|
|
1484
|
-
_cartSettlementKey =
|
|
1485
|
-
_cartSettlementSnapshot =
|
|
1486
|
-
_legalCurrencySnapshot =
|
|
1487
|
-
rest = _objectWithoutProperties(
|
|
1522
|
+
var _ref41 = tempOrder.metadata || {},
|
|
1523
|
+
_collectPax = _ref41.collect_pax,
|
|
1524
|
+
_tableOccupancyDuration = _ref41.table_occupancy_duration,
|
|
1525
|
+
_cartSettlementKey = _ref41.cart_settlement_key,
|
|
1526
|
+
_cartSettlementSnapshot = _ref41.cart_settlement_snapshot,
|
|
1527
|
+
_legalCurrencySnapshot = _ref41.legal_currency_snapshot,
|
|
1528
|
+
rest = _objectWithoutProperties(_ref41, _excluded5);
|
|
1488
1529
|
return _objectSpread({}, rest);
|
|
1489
1530
|
}()
|
|
1490
1531
|
}, (_tempOrder$_extend = tempOrder._extend) !== null && _tempOrder$_extend !== void 0 && (_tempOrder$_extend = _tempOrder$_extend.salesNotesState) !== null && _tempOrder$_extend !== void 0 && _tempOrder$_extend.dirty ? {
|
|
@@ -1688,9 +1729,9 @@ export function clearTempOrderHolderAssignments(tempOrder) {
|
|
|
1688
1729
|
* getOrderProductLineUid({ metadata: { unique_identification_number: 'line-1' } }); // 'line-1'
|
|
1689
1730
|
*/
|
|
1690
1731
|
export function getOrderProductLineUid(product) {
|
|
1691
|
-
var _product$metadata$
|
|
1732
|
+
var _product$metadata$uni2, _product$metadata10;
|
|
1692
1733
|
if (!product || _typeof(product) !== 'object') return null;
|
|
1693
|
-
var uid = (_product$metadata$
|
|
1734
|
+
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;
|
|
1694
1735
|
if (uid === undefined || uid === null || uid === '') return null;
|
|
1695
1736
|
return String(uid);
|
|
1696
1737
|
}
|
|
@@ -1701,8 +1742,8 @@ export function getRuntimeProductOrigin(tempOrder, product) {
|
|
|
1701
1742
|
return tempOrder._extend.productsByUid[uid].origin;
|
|
1702
1743
|
}
|
|
1703
1744
|
var matchedProduct = ((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || []).find(function (item) {
|
|
1704
|
-
var
|
|
1705
|
-
return item === product || getOrderProductLineUid(item) === uid || String((
|
|
1745
|
+
var _ref42, _item$product_id, _ref43, _product$product_id;
|
|
1746
|
+
return item === product || getOrderProductLineUid(item) === uid || String((_ref42 = (_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 && _ref42 !== void 0 ? _ref42 : '') === String((_ref43 = (_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 && _ref43 !== void 0 ? _ref43 : '');
|
|
1706
1747
|
});
|
|
1707
1748
|
var matchedUid = matchedProduct ? getOrderProductLineUid(matchedProduct) : '';
|
|
1708
1749
|
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;
|