@pisell/pisellos 2.3.128 → 2.3.129
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 +6 -0
- package/dist/modules/Order/index.js +443 -235
- 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/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 +6 -0
- 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/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
|
}
|
|
@@ -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,6 +23,7 @@ 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 { withOriginalBundleOptionPrices } from "./utils/weighedProduct";
|
|
28
29
|
import { hasManualProductDiscountFlag } from "./utils/manualProductDiscount";
|
|
@@ -30,6 +31,7 @@ import { getProductHolderConfig } from "../Holder/utils";
|
|
|
30
31
|
import { buildProductLineFingerprint, createEmptySummary } from "../../solution/ScanOrder/utils";
|
|
31
32
|
import { createUuidV4 } from "./utils/orderCollectionIdentity";
|
|
32
33
|
import { encodeSalesNotes } from "./salesNotes";
|
|
34
|
+
dayjs.extend(customParseFormat);
|
|
33
35
|
var POINT_CARD_SNAPSHOT_TAG = 'point_card';
|
|
34
36
|
var VIRTUAL_CURRENCY_SNAPSHOT_TAG = 'virtual_currency';
|
|
35
37
|
function isPlainObject(value) {
|
|
@@ -659,6 +661,22 @@ function resolveSubmitBundleMapId(bundle) {
|
|
|
659
661
|
}
|
|
660
662
|
return undefined;
|
|
661
663
|
}
|
|
664
|
+
function ensureSubmitDiscountIdentity(discount) {
|
|
665
|
+
if (!discount || _typeof(discount) !== 'object' || Array.isArray(discount)) {
|
|
666
|
+
return discount;
|
|
667
|
+
}
|
|
668
|
+
var discountRecord = discount;
|
|
669
|
+
var metadata = discountRecord.metadata && _typeof(discountRecord.metadata) === 'object' && !Array.isArray(discountRecord.metadata) ? discountRecord.metadata : {};
|
|
670
|
+
var uniqueIdentificationNumber = metadata.unique_identification_number;
|
|
671
|
+
if (uniqueIdentificationNumber !== undefined && uniqueIdentificationNumber !== null && String(uniqueIdentificationNumber).trim() !== '') {
|
|
672
|
+
return discount;
|
|
673
|
+
}
|
|
674
|
+
return _objectSpread(_objectSpread({}, discountRecord), {}, {
|
|
675
|
+
metadata: _objectSpread(_objectSpread({}, metadata), {}, {
|
|
676
|
+
unique_identification_number: createUuidV4()
|
|
677
|
+
})
|
|
678
|
+
});
|
|
679
|
+
}
|
|
662
680
|
function collectSubmitProductDiscountList(product) {
|
|
663
681
|
var submitDiscountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? _toConsumableArray(product.discount_list) : [];
|
|
664
682
|
var _iterator5 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
|
|
@@ -694,7 +712,7 @@ function collectSubmitProductDiscountList(product) {
|
|
|
694
712
|
} finally {
|
|
695
713
|
_iterator5.f();
|
|
696
714
|
}
|
|
697
|
-
return normalizeOrderProductDiscountList(submitDiscountList);
|
|
715
|
+
return normalizeOrderProductDiscountList(submitDiscountList.map(ensureSubmitDiscountIdentity));
|
|
698
716
|
}
|
|
699
717
|
|
|
700
718
|
/**
|
|
@@ -767,14 +785,37 @@ export function resolveEffectivePerUnitDiscount(product) {
|
|
|
767
785
|
if (!Number.isFinite(originalPrice) || !Number.isFinite(finalPrice)) return fromList;
|
|
768
786
|
return fromList + (originalPrice - finalPrice);
|
|
769
787
|
}
|
|
770
|
-
export function createDefaultOrderRulesHooks() {
|
|
788
|
+
export function createDefaultOrderRulesHooks(getBookings) {
|
|
789
|
+
var getProductStartDate = function getProductStartDate(product) {
|
|
790
|
+
var _ref17, _product$metadata$uni, _product$metadata2, _ref18, _product$booking_uid, _product$metadata3, _product$metadata4, _product$metadata5, _product$metadata6;
|
|
791
|
+
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 : '');
|
|
792
|
+
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 : '');
|
|
793
|
+
// 每次读取当前 bookings,覆盖改期、订单回显以及直接调用 Rules 的选券入口。
|
|
794
|
+
var bookings = (getBookings === null || getBookings === void 0 ? void 0 : getBookings()) || [];
|
|
795
|
+
var booking = bookings.find(function (item) {
|
|
796
|
+
var _ref19, _item$product_uid, _item$metadata3;
|
|
797
|
+
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;
|
|
798
|
+
}) || bookings.find(function (item) {
|
|
799
|
+
var _ref20, _item$metadata$unique, _item$metadata4;
|
|
800
|
+
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;
|
|
801
|
+
});
|
|
802
|
+
if (booking) {
|
|
803
|
+
// 严格解析并保留 Invalid Date,让公共时间校验拒绝缺失/非法时间,避免回退到当前时间。
|
|
804
|
+
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);
|
|
805
|
+
}
|
|
806
|
+
if (getBookings && (bookingUid || product.booking_id || (_product$metadata4 = product.metadata) !== null && _product$metadata4 !== void 0 && _product$metadata4.booking_id)) {
|
|
807
|
+
return dayjs('');
|
|
808
|
+
}
|
|
809
|
+
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);
|
|
810
|
+
return legacyStartDate ? dayjs(legacyStartDate) : undefined;
|
|
811
|
+
};
|
|
771
812
|
var toUnitPriceString = function toUnitPriceString(totalLike, num) {
|
|
772
813
|
var effectiveNum = Number(num) > 0 ? Number(num) : 1;
|
|
773
814
|
return new Decimal(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
|
|
774
815
|
};
|
|
775
816
|
var getBundleIdentity = function getBundleIdentity(bundle) {
|
|
776
|
-
var
|
|
777
|
-
return [(
|
|
817
|
+
var _ref21, _bundle$bundle_id, _ref22, _ref23, _bundle$bundle_produc, _ref24, _ref25, _bundle$bundle_varian, _ref26, _bundle$bundle_group_;
|
|
818
|
+
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('|');
|
|
778
819
|
};
|
|
779
820
|
var mergeRulesBundlePrices = function mergeRulesBundlePrices(currentBundle, rulesBundle) {
|
|
780
821
|
if (!Array.isArray(rulesBundle)) return rulesBundle;
|
|
@@ -784,7 +825,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
784
825
|
currentByIdentity.set(getBundleIdentity(bundle), bundle);
|
|
785
826
|
});
|
|
786
827
|
return rulesBundle.map(function (bundle) {
|
|
787
|
-
var _bundle$price_type_ex2,
|
|
828
|
+
var _bundle$price_type_ex2, _ref27, _ref28, _current$price, _ref29, _ref30, _ref31, _current$original_pri;
|
|
788
829
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
789
830
|
var current = currentByIdentity.get(getBundleIdentity(bundle));
|
|
790
831
|
if (!current) return bundle;
|
|
@@ -793,8 +834,8 @@ export function createDefaultOrderRulesHooks() {
|
|
|
793
834
|
} : {});
|
|
794
835
|
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';
|
|
795
836
|
if (!isProductPriceBundle) return bundleWithDisplayFields;
|
|
796
|
-
var sourcePrice = (
|
|
797
|
-
var originalPrice = (
|
|
837
|
+
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;
|
|
838
|
+
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;
|
|
798
839
|
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, bundleWithDisplayFields), sourcePrice !== undefined ? {
|
|
799
840
|
price: sourcePrice
|
|
800
841
|
} : {}), originalPrice !== undefined ? {
|
|
@@ -806,7 +847,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
806
847
|
};
|
|
807
848
|
return {
|
|
808
849
|
getProduct: function getProduct(product) {
|
|
809
|
-
var _product$
|
|
850
|
+
var _product$metadata7, _product$metadata8, _product$metadata9, _metadataAny$_promoti;
|
|
810
851
|
// source_product_price 是权威源;兜底链:source → mainSelling − options(反推)→ 行 selling_price
|
|
811
852
|
var metadataAny = product.metadata || {};
|
|
812
853
|
var optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
|
|
@@ -833,7 +874,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
833
874
|
// 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
|
|
834
875
|
// 不透明 identity 契约下,normalizeOrderProduct / hydrate 已保证唯一值存在;
|
|
835
876
|
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
836
|
-
_id: (_product$
|
|
877
|
+
_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)),
|
|
837
878
|
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
838
879
|
// 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
|
|
839
880
|
price: sourcePrice,
|
|
@@ -845,23 +886,23 @@ export function createDefaultOrderRulesHooks() {
|
|
|
845
886
|
num: product.num || 1,
|
|
846
887
|
discount_list: product.discount_list || [],
|
|
847
888
|
bundle: product.product_bundle || [],
|
|
848
|
-
booking_id: ((_product$
|
|
889
|
+
booking_id: ((_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.booking_id) || null,
|
|
849
890
|
isClient: false,
|
|
850
891
|
// 勿写死 false:否则 Rules 不会走 total≠origin_total 的手动价推断,
|
|
851
892
|
// 无券时会把 bundle 价还原成 original_price(手动改价套餐会从 20 回到 30)。
|
|
852
893
|
isManualDiscount: resolveRulesManualDiscountFlag(metadataAny),
|
|
853
|
-
holder_id: (_product$
|
|
854
|
-
startDate: (
|
|
894
|
+
holder_id: (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.holder_id,
|
|
895
|
+
startDate: getProductStartDate(product),
|
|
855
896
|
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,
|
|
856
897
|
inPromotion: ((_metadataAny$_promoti = metadataAny._promotion) === null || _metadataAny$_promoti === void 0 ? void 0 : _metadataAny$_promoti.inPromotion) === true,
|
|
857
898
|
_promotion: metadataAny._promotion
|
|
858
899
|
};
|
|
859
900
|
},
|
|
860
901
|
setProduct: function setProduct(product, values) {
|
|
861
|
-
var
|
|
862
|
-
var nextNum = Number((
|
|
902
|
+
var _ref32, _values$quantity, _ref33, _metadataAny$source_p, _product$product_sku, _values$discount_list, _values$quantity2;
|
|
903
|
+
var nextNum = Number((_ref32 = (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num) !== null && _ref32 !== void 0 ? _ref32 : 1) || 1;
|
|
863
904
|
var metadataAny = product.metadata || {};
|
|
864
|
-
var existedSource = (
|
|
905
|
+
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';
|
|
865
906
|
var nextOptions = getProductSkuOptions(product);
|
|
866
907
|
var optionSum = sumOptionUnitPrice(nextOptions);
|
|
867
908
|
|
|
@@ -1072,7 +1113,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1072
1113
|
var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1073
1114
|
if (!Array.isArray(bundle)) return [];
|
|
1074
1115
|
return bundle.map(function (b) {
|
|
1075
|
-
var
|
|
1116
|
+
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;
|
|
1076
1117
|
var rawBundle = b && _typeof(b) === 'object' ? b : {};
|
|
1077
1118
|
var existedMetadata = rawBundle.metadata && _typeof(rawBundle.metadata) === 'object' ? rawBundle.metadata : {};
|
|
1078
1119
|
var _customProductBundleMapId = existedMetadata.custom_product_bundle_map_id,
|
|
@@ -1083,7 +1124,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1083
1124
|
var sellingPrice = formatOptions.virtualSettlementMode ? '0.00' : getBundleSellingMagnitude(rawBundle).toFixed(2);
|
|
1084
1125
|
// payment 价由整单折扣均摊层产出;缺省(无折扣)时与 selling 净额同义。
|
|
1085
1126
|
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;
|
|
1086
|
-
var priceValue = formatOptions.virtualSettlementMode ? 0 : (
|
|
1127
|
+
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;
|
|
1087
1128
|
var relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
|
|
1088
1129
|
var surchargeFee = toMoneyString((_rawBundle$surcharge_ = rawBundle.surcharge_fee) !== null && _rawBundle$surcharge_ !== void 0 ? _rawBundle$surcharge_ : existedMetadata.surcharge_fee);
|
|
1089
1130
|
var productDiscountDifference = toBundleNumber(existedMetadata.product_discount_difference, 0);
|
|
@@ -1102,8 +1143,8 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1102
1143
|
extension_id: (_rawBundle$extension_ = rawBundle.extension_id) !== null && _rawBundle$extension_ !== void 0 ? _rawBundle$extension_ : 0,
|
|
1103
1144
|
extension_type: (_rawBundle$extension_2 = rawBundle.extension_type) !== null && _rawBundle$extension_2 !== void 0 ? _rawBundle$extension_2 : 'normal',
|
|
1104
1145
|
price: priceValue,
|
|
1105
|
-
price_type: (
|
|
1106
|
-
price_type_ext: (
|
|
1146
|
+
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 : '',
|
|
1147
|
+
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 : '',
|
|
1107
1148
|
bundle_selling_price: sellingPrice,
|
|
1108
1149
|
bundle_payment_price: paymentPrice,
|
|
1109
1150
|
option: formatSubmitOptionItems(rawBundle.option, formatOptions),
|
|
@@ -1139,11 +1180,11 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1139
1180
|
* 法币仅做字段/metadata 裁剪;虚拟币在出站前再次执行零加价与固定单价断言。
|
|
1140
1181
|
*/
|
|
1141
1182
|
function normalizeSubmitProduct(product) {
|
|
1142
|
-
var
|
|
1183
|
+
var _ref38, _submitProduct$bundle, _rawMetadata$product_, _rawMetadata$selected, _rawMetadata$selected2, _submitProduct$produc, _submitProduct$paymen;
|
|
1143
1184
|
var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1144
|
-
var
|
|
1145
|
-
_runtimeUid =
|
|
1146
|
-
submitProduct = _objectWithoutProperties(
|
|
1185
|
+
var _ref37 = product,
|
|
1186
|
+
_runtimeUid = _ref37.unique_identification_number,
|
|
1187
|
+
submitProduct = _objectWithoutProperties(_ref37, _excluded2);
|
|
1147
1188
|
var num = submitProduct.num,
|
|
1148
1189
|
_productSurchargeFee = submitProduct.surcharge_fee,
|
|
1149
1190
|
_deprecatedDiscountAmount = submitProduct.discount_amount,
|
|
@@ -1160,7 +1201,7 @@ function normalizeSubmitProduct(product) {
|
|
|
1160
1201
|
// 兼容历史 BigSale 编辑链路:bundle_edit 曾被写入 metadata,
|
|
1161
1202
|
// 出站时需提升到商品顶层;套餐未编辑时也必须显式提交 0。
|
|
1162
1203
|
var hasProductBundle = Array.isArray(submitProduct.product_bundle) && submitProduct.product_bundle.length > 0;
|
|
1163
|
-
var bundleEdit = (
|
|
1204
|
+
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;
|
|
1164
1205
|
var cleanMetadata = {};
|
|
1165
1206
|
if (rawMetadata.unique_identification_number) {
|
|
1166
1207
|
cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
|
|
@@ -1391,7 +1432,7 @@ export function resolveSubmitOrderType(params) {
|
|
|
1391
1432
|
return 'virtual';
|
|
1392
1433
|
}
|
|
1393
1434
|
export function buildSubmitPayload(params) {
|
|
1394
|
-
var _tempOrder$metadata2, _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_,
|
|
1435
|
+
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;
|
|
1395
1436
|
var tempOrder = params.tempOrder,
|
|
1396
1437
|
cacheId = params.cacheId,
|
|
1397
1438
|
_params$now = params.now,
|
|
@@ -1405,29 +1446,29 @@ export function buildSubmitPayload(params) {
|
|
|
1405
1446
|
var scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
|
|
1406
1447
|
var bookingUuid = createUuidV4();
|
|
1407
1448
|
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';
|
|
1408
|
-
var
|
|
1409
|
-
_extend =
|
|
1410
|
-
_relationId =
|
|
1411
|
-
_tableFormId =
|
|
1412
|
-
_resourceId =
|
|
1413
|
-
_summary =
|
|
1414
|
-
_lastOrderInfo =
|
|
1415
|
-
_paidAmount =
|
|
1416
|
-
_shopId =
|
|
1417
|
-
_shopNote =
|
|
1418
|
-
_shopServiceType =
|
|
1419
|
-
_startTime =
|
|
1420
|
-
_customer =
|
|
1421
|
-
_discountList =
|
|
1422
|
-
_orderMetaList =
|
|
1423
|
-
_rootTaxFee =
|
|
1424
|
-
_totalAmount =
|
|
1425
|
-
_totalRefundAmount =
|
|
1426
|
-
_createDate =
|
|
1427
|
-
_holderId =
|
|
1428
|
-
_paymentStatus =
|
|
1429
|
-
_notes =
|
|
1430
|
-
tempOrderRest = _objectWithoutProperties(
|
|
1449
|
+
var _ref39 = tempOrder,
|
|
1450
|
+
_extend = _ref39._extend,
|
|
1451
|
+
_relationId = _ref39.relation_id,
|
|
1452
|
+
_tableFormId = _ref39.table_form_id,
|
|
1453
|
+
_resourceId = _ref39.resource_id,
|
|
1454
|
+
_summary = _ref39.summary,
|
|
1455
|
+
_lastOrderInfo = _ref39.lastOrderInfo,
|
|
1456
|
+
_paidAmount = _ref39.paid_amount,
|
|
1457
|
+
_shopId = _ref39.shop_id,
|
|
1458
|
+
_shopNote = _ref39.shop_note,
|
|
1459
|
+
_shopServiceType = _ref39.shop_service_type,
|
|
1460
|
+
_startTime = _ref39.start_time,
|
|
1461
|
+
_customer = _ref39.customer,
|
|
1462
|
+
_discountList = _ref39.discount_list,
|
|
1463
|
+
_orderMetaList = _ref39.order_meta_list,
|
|
1464
|
+
_rootTaxFee = _ref39.tax_fee,
|
|
1465
|
+
_totalAmount = _ref39.total_amount,
|
|
1466
|
+
_totalRefundAmount = _ref39.total_refund_amount,
|
|
1467
|
+
_createDate = _ref39.create_date,
|
|
1468
|
+
_holderId = _ref39.holder_id,
|
|
1469
|
+
_paymentStatus = _ref39.payment_status,
|
|
1470
|
+
_notes = _ref39.notes,
|
|
1471
|
+
tempOrderRest = _objectWithoutProperties(_ref39, _excluded4);
|
|
1431
1472
|
var resolvedBusinessCode = businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code;
|
|
1432
1473
|
var normalizedOrderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
|
|
1433
1474
|
var submitType = resolveSubmitOrderType({
|
|
@@ -1452,7 +1493,7 @@ export function buildSubmitPayload(params) {
|
|
|
1452
1493
|
type: submitType,
|
|
1453
1494
|
business_code: resolvedBusinessCode,
|
|
1454
1495
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
1455
|
-
order_sales_channel: (
|
|
1496
|
+
order_sales_channel: (_ref40 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref40 !== void 0 ? _ref40 : 'online_store',
|
|
1456
1497
|
status: tempOrder.status || 'normal'
|
|
1457
1498
|
}, params.includePaymentStatus !== false ? {
|
|
1458
1499
|
payment_status: tempOrder.payment_status || 'payment_processing'
|
|
@@ -1480,13 +1521,13 @@ export function buildSubmitPayload(params) {
|
|
|
1480
1521
|
// holder: tempOrder.holder || null,
|
|
1481
1522
|
summary: summary || tempOrder.summary || createEmptySummary(),
|
|
1482
1523
|
metadata: function () {
|
|
1483
|
-
var
|
|
1484
|
-
_collectPax =
|
|
1485
|
-
_tableOccupancyDuration =
|
|
1486
|
-
_cartSettlementKey =
|
|
1487
|
-
_cartSettlementSnapshot =
|
|
1488
|
-
_legalCurrencySnapshot =
|
|
1489
|
-
rest = _objectWithoutProperties(
|
|
1524
|
+
var _ref41 = tempOrder.metadata || {},
|
|
1525
|
+
_collectPax = _ref41.collect_pax,
|
|
1526
|
+
_tableOccupancyDuration = _ref41.table_occupancy_duration,
|
|
1527
|
+
_cartSettlementKey = _ref41.cart_settlement_key,
|
|
1528
|
+
_cartSettlementSnapshot = _ref41.cart_settlement_snapshot,
|
|
1529
|
+
_legalCurrencySnapshot = _ref41.legal_currency_snapshot,
|
|
1530
|
+
rest = _objectWithoutProperties(_ref41, _excluded5);
|
|
1490
1531
|
return _objectSpread({}, rest);
|
|
1491
1532
|
}()
|
|
1492
1533
|
}, (_tempOrder$_extend = tempOrder._extend) !== null && _tempOrder$_extend !== void 0 && (_tempOrder$_extend = _tempOrder$_extend.salesNotesState) !== null && _tempOrder$_extend !== void 0 && _tempOrder$_extend.dirty ? {
|
|
@@ -1690,9 +1731,9 @@ export function clearTempOrderHolderAssignments(tempOrder) {
|
|
|
1690
1731
|
* getOrderProductLineUid({ metadata: { unique_identification_number: 'line-1' } }); // 'line-1'
|
|
1691
1732
|
*/
|
|
1692
1733
|
export function getOrderProductLineUid(product) {
|
|
1693
|
-
var _product$metadata$
|
|
1734
|
+
var _product$metadata$uni2, _product$metadata10;
|
|
1694
1735
|
if (!product || _typeof(product) !== 'object') return null;
|
|
1695
|
-
var uid = (_product$metadata$
|
|
1736
|
+
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;
|
|
1696
1737
|
if (uid === undefined || uid === null || uid === '') return null;
|
|
1697
1738
|
return String(uid);
|
|
1698
1739
|
}
|
|
@@ -1703,8 +1744,8 @@ export function getRuntimeProductOrigin(tempOrder, product) {
|
|
|
1703
1744
|
return tempOrder._extend.productsByUid[uid].origin;
|
|
1704
1745
|
}
|
|
1705
1746
|
var matchedProduct = ((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || []).find(function (item) {
|
|
1706
|
-
var
|
|
1707
|
-
return item === product || getOrderProductLineUid(item) === uid || String((
|
|
1747
|
+
var _ref42, _item$product_id, _ref43, _product$product_id;
|
|
1748
|
+
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 : '');
|
|
1708
1749
|
});
|
|
1709
1750
|
var matchedUid = matchedProduct ? getOrderProductLineUid(matchedProduct) : '';
|
|
1710
1751
|
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;
|