@pisell/pisellos 2.3.127 → 2.3.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +2 -4
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +19 -58
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +12 -24
- package/dist/modules/Customer/index.js +3 -6
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.d.ts +2 -2
- package/dist/modules/Discount/index.js +151 -37
- package/dist/modules/Discount/types.d.ts +5 -36
- package/dist/modules/Order/index.d.ts +2 -7
- package/dist/modules/Order/index.js +331 -480
- package/dist/modules/Order/utils/orderCollectionIdentity.js +12 -16
- package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/dist/modules/Order/utils/weighedProduct.js +94 -0
- package/dist/modules/Order/utils.d.ts +1 -1
- package/dist/modules/Order/utils.js +65 -104
- package/dist/modules/Payment/types.d.ts +1 -21
- package/dist/modules/Payment/types.js +0 -2
- package/dist/modules/Payment/walletpass.d.ts +1 -1
- package/dist/modules/Payment/walletpass.js +47 -80
- package/dist/modules/Rules/index.d.ts +2 -2
- package/dist/modules/Rules/index.js +190 -482
- package/dist/modules/Rules/types.d.ts +2 -4
- package/dist/server/modules/order/types.d.ts +0 -2
- package/dist/server/utils/small-ticket.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +2 -3
- package/dist/solution/BaseSales/index.js +77 -44
- package/dist/solution/BaseSales/types.d.ts +7 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +126 -141
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
- package/dist/solution/BaseSales/utils.js +3 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +3 -2
- package/dist/solution/BookingTicket/index.js +63 -60
- package/dist/solution/BookingTicket/types.d.ts +1 -5
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +147 -338
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +6 -19
- package/dist/solution/ScanOrder/utils.js +3 -2
- package/dist/solution/ShopDiscount/index.d.ts +0 -2
- package/dist/solution/ShopDiscount/index.js +42 -99
- package/dist/solution/ShopDiscount/utils.d.ts +2 -4
- package/dist/solution/ShopDiscount/utils.js +23 -43
- package/dist/solution/UnifiedBookingSales/index.js +2 -2
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +6 -35
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -13
- package/lib/modules/Customer/index.js +1 -5
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.d.ts +2 -2
- package/lib/modules/Discount/index.js +129 -23
- package/lib/modules/Discount/types.d.ts +5 -36
- package/lib/modules/Order/index.d.ts +2 -7
- package/lib/modules/Order/index.js +109 -222
- package/lib/modules/Order/utils/orderCollectionIdentity.js +11 -14
- package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/lib/modules/Order/utils/weighedProduct.js +89 -0
- package/lib/modules/Order/utils.d.ts +1 -1
- package/lib/modules/Order/utils.js +6 -41
- package/lib/modules/Payment/types.d.ts +1 -21
- package/lib/modules/Payment/types.js +0 -1
- package/lib/modules/Payment/walletpass.d.ts +1 -1
- package/lib/modules/Payment/walletpass.js +9 -29
- package/lib/modules/Rules/index.d.ts +2 -2
- package/lib/modules/Rules/index.js +114 -359
- package/lib/modules/Rules/types.d.ts +2 -4
- package/lib/server/modules/order/types.d.ts +0 -2
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +2 -3
- package/lib/solution/BaseSales/index.js +17 -11
- package/lib/solution/BaseSales/types.d.ts +7 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +4 -12
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
- package/lib/solution/BaseSales/utils.js +2 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +3 -2
- package/lib/solution/BookingTicket/index.js +33 -36
- package/lib/solution/BookingTicket/types.d.ts +1 -5
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +42 -174
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +3 -11
- package/lib/solution/ScanOrder/utils.js +2 -1
- package/lib/solution/ShopDiscount/index.d.ts +0 -2
- package/lib/solution/ShopDiscount/index.js +9 -55
- package/lib/solution/ShopDiscount/utils.d.ts +2 -4
- package/lib/solution/ShopDiscount/utils.js +25 -42
- package/lib/solution/UnifiedBookingSales/index.js +2 -2
- package/package.json +1 -1
- package/dist/modules/Discount/availability.d.ts +0 -7
- package/dist/modules/Discount/availability.js +0 -49
- package/dist/modules/Discount/entitlementPass.d.ts +0 -34
- package/dist/modules/Discount/entitlementPass.js +0 -147
- package/lib/modules/Discount/availability.d.ts +0 -7
- package/lib/modules/Discount/availability.js +0 -43
- package/lib/modules/Discount/entitlementPass.d.ts +0 -34
- package/lib/modules/Discount/entitlementPass.js +0 -141
|
@@ -12,7 +12,6 @@ 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";
|
|
16
15
|
var IDENTITY_CONFIG = {
|
|
17
16
|
product: {
|
|
18
17
|
persistentIdField: 'order_detail_id',
|
|
@@ -75,25 +74,22 @@ export function setOrderCollectionUid(kind, item, uid) {
|
|
|
75
74
|
delete record[uidField];
|
|
76
75
|
return record;
|
|
77
76
|
}
|
|
78
|
-
function
|
|
79
|
-
var _ref, _ref2,
|
|
80
|
-
var
|
|
81
|
-
|
|
77
|
+
function getGoodPassResourceId(product) {
|
|
78
|
+
var _ref, _ref2, _goodPass$discount$re, _goodPass$discount;
|
|
79
|
+
var goodPass = (product.discount_list || []).find(function (item) {
|
|
80
|
+
var _item$discount, _item$discount2;
|
|
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';
|
|
82
83
|
});
|
|
83
|
-
if (!
|
|
84
|
-
var resourceId = (_ref = (_ref2 = (
|
|
85
|
-
|
|
86
|
-
return {
|
|
87
|
-
type: String(pass.type || pass.tag),
|
|
88
|
-
resourceId: String(resourceId)
|
|
89
|
-
};
|
|
84
|
+
if (!goodPass) return null;
|
|
85
|
+
var resourceId = (_ref = (_ref2 = (_goodPass$discount$re = (_goodPass$discount = goodPass.discount) === null || _goodPass$discount === void 0 ? void 0 : _goodPass$discount.resource_id) !== null && _goodPass$discount$re !== void 0 ? _goodPass$discount$re : goodPass.resource_id) !== null && _ref2 !== void 0 ? _ref2 : goodPass.discount_id) !== null && _ref !== void 0 ? _ref : goodPass.id;
|
|
86
|
+
return isBlankOrderCollectionIdentity(resourceId) ? null : String(resourceId);
|
|
90
87
|
}
|
|
91
88
|
function buildSplitProductUid(originalUid, product, duplicateOrdinal) {
|
|
92
89
|
var encodedOriginalUid = encodeURIComponent(originalUid);
|
|
93
|
-
var
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
return "os-split:product:".concat(encodedOriginalUid, ":").concat(passType, ":").concat(encodeURIComponent(passIdentity.resourceId), ":").concat(duplicateOrdinal);
|
|
90
|
+
var resourceId = getGoodPassResourceId(product);
|
|
91
|
+
if (resourceId) {
|
|
92
|
+
return "os-split:product:".concat(encodedOriginalUid, ":good-pass:").concat(encodeURIComponent(resourceId), ":").concat(duplicateOrdinal);
|
|
97
93
|
}
|
|
98
94
|
return "os-split:product:".concat(encodedOriginalUid, ":duplicate:").concat(duplicateOrdinal);
|
|
99
95
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Only pricing/measurement fields participate; display and option data do not. */
|
|
2
|
+
export declare function getWeighedProductPriceFingerprint(sku?: Record<string, any>): string;
|
|
3
|
+
/**
|
|
4
|
+
* A weighed line's source is the amount for its net weight, never its catalog unit price.
|
|
5
|
+
* Persisted SKU measurements and the full catalog snapshot take priority over runtime
|
|
6
|
+
* _extend.weighing, which can survive repricing with an obsolete total_amount.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveWeighedSourcePrice(sku?: Record<string, any>, weighing?: Record<string, any>): string | undefined;
|
|
9
|
+
/** Original bundle totals must use the nested options before manual distribution. */
|
|
10
|
+
export declare function withOriginalBundleOptionPrices(bundles?: Array<Record<string, any>>): {
|
|
11
|
+
option: any;
|
|
12
|
+
}[] | undefined;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
7
|
+
import Decimal from 'decimal.js';
|
|
8
|
+
var UNIT_GRAMS = {
|
|
9
|
+
kg: '1000',
|
|
10
|
+
KILOGRAMS: '1000',
|
|
11
|
+
g: '1',
|
|
12
|
+
GRAMS: '1',
|
|
13
|
+
lb: '453.59237',
|
|
14
|
+
POUNDS: '453.59237',
|
|
15
|
+
oz: '28.349523125',
|
|
16
|
+
OUNCES: '28.349523125'
|
|
17
|
+
};
|
|
18
|
+
function nonNegative(value) {
|
|
19
|
+
if (value === null || value === undefined || value === '') return undefined;
|
|
20
|
+
try {
|
|
21
|
+
var result = new Decimal(value);
|
|
22
|
+
return result.isFinite() && result.gte(0) ? result : undefined;
|
|
23
|
+
} catch (_unused) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function numericKey(value) {
|
|
28
|
+
var _nonNegative;
|
|
29
|
+
return (_nonNegative = nonNegative(value)) === null || _nonNegative === void 0 ? void 0 : _nonNegative.toString();
|
|
30
|
+
}
|
|
31
|
+
function unitKey(value) {
|
|
32
|
+
return UNIT_GRAMS[String(value)] || (value == null ? undefined : String(value));
|
|
33
|
+
}
|
|
34
|
+
function snapshotKey(snapshot) {
|
|
35
|
+
var _snapshot$unit_value;
|
|
36
|
+
return [numericKey(snapshot === null || snapshot === void 0 ? void 0 : snapshot.price), unitKey(snapshot === null || snapshot === void 0 ? void 0 : snapshot.unit), numericKey((_snapshot$unit_value = snapshot === null || snapshot === void 0 ? void 0 : snapshot.unit_value) !== null && _snapshot$unit_value !== void 0 ? _snapshot$unit_value : 1)];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Only pricing/measurement fields participate; display and option data do not. */
|
|
40
|
+
export function getWeighedProductPriceFingerprint(sku) {
|
|
41
|
+
var _sku$unit_weight;
|
|
42
|
+
if (Number(sku === null || sku === void 0 ? void 0 : sku.open_sold_weight) !== 1) return 'unweighed';
|
|
43
|
+
return JSON.stringify([1, numericKey(sku === null || sku === void 0 ? void 0 : sku.net_weight), unitKey(sku === null || sku === void 0 ? void 0 : sku.unit), numericKey(sku === null || sku === void 0 ? void 0 : sku.unit_price), numericKey((_sku$unit_weight = sku === null || sku === void 0 ? void 0 : sku.unit_weight) !== null && _sku$unit_weight !== void 0 ? _sku$unit_weight : 1), snapshotKey(sku === null || sku === void 0 ? void 0 : sku.unit_data_snapshot)]);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A weighed line's source is the amount for its net weight, never its catalog unit price.
|
|
48
|
+
* Persisted SKU measurements and the full catalog snapshot take priority over runtime
|
|
49
|
+
* _extend.weighing, which can survive repricing with an obsolete total_amount.
|
|
50
|
+
*/
|
|
51
|
+
export function resolveWeighedSourcePrice(sku, weighing) {
|
|
52
|
+
var _snapshot$unit_value2, _weighing$unit_weight, _sku$unit_weight2, _measurement$unit_wei;
|
|
53
|
+
if ((sku === null || sku === void 0 ? void 0 : sku.open_sold_weight) != null && Number(sku.open_sold_weight) !== 1) return undefined;
|
|
54
|
+
if (Number(sku === null || sku === void 0 ? void 0 : sku.open_sold_weight) !== 1 && !weighing) return undefined;
|
|
55
|
+
var hasSkuMeasurement = (sku === null || sku === void 0 ? void 0 : sku.net_weight) !== undefined && (sku === null || sku === void 0 ? void 0 : sku.net_weight) !== null;
|
|
56
|
+
var measurement = hasSkuMeasurement ? sku : weighing;
|
|
57
|
+
var netWeight = nonNegative(measurement === null || measurement === void 0 ? void 0 : measurement.net_weight);
|
|
58
|
+
if (netWeight === undefined) return undefined;
|
|
59
|
+
var snapshot = hasSkuMeasurement ? sku === null || sku === void 0 ? void 0 : sku.unit_data_snapshot : weighing === null || weighing === void 0 ? void 0 : weighing.scalePriceProduct;
|
|
60
|
+
var snapshotPrice = nonNegative(snapshot === null || snapshot === void 0 ? void 0 : snapshot.price);
|
|
61
|
+
var snapshotUnits = nonNegative((_snapshot$unit_value2 = snapshot === null || snapshot === void 0 ? void 0 : snapshot.unit_value) !== null && _snapshot$unit_value2 !== void 0 ? _snapshot$unit_value2 : 1);
|
|
62
|
+
var sourceGrams = UNIT_GRAMS[String(snapshot === null || snapshot === void 0 ? void 0 : snapshot.unit)];
|
|
63
|
+
var targetGrams = UNIT_GRAMS[String(measurement === null || measurement === void 0 ? void 0 : measurement.unit)];
|
|
64
|
+
if (snapshotPrice && snapshotUnits !== null && snapshotUnits !== void 0 && snapshotUnits.gt(0) && sourceGrams && targetGrams) {
|
|
65
|
+
return snapshotPrice.mul(netWeight).mul(targetGrams).div(sourceGrams).div(snapshotUnits).toFixed(2);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Legacy callers may only retain the native scale's amount. Do not let an old
|
|
69
|
+
// amount overwrite a changed SKU measurement, unit price, or pricing snapshot.
|
|
70
|
+
var runtimeAmount = nonNegative(weighing === null || weighing === void 0 ? void 0 : weighing.total_amount);
|
|
71
|
+
var runtimeMatchesSku = !hasSkuMeasurement || numericKey(weighing === null || weighing === void 0 ? void 0 : weighing.net_weight) === numericKey(sku === null || sku === void 0 ? void 0 : sku.net_weight) && unitKey(weighing === null || weighing === void 0 ? void 0 : weighing.unit) === unitKey(sku === null || sku === void 0 ? void 0 : sku.unit) && numericKey(weighing === null || weighing === void 0 ? void 0 : weighing.unit_price) === numericKey(sku === null || sku === void 0 ? void 0 : sku.unit_price) && numericKey((_weighing$unit_weight = weighing === null || weighing === void 0 ? void 0 : weighing.unit_weight) !== null && _weighing$unit_weight !== void 0 ? _weighing$unit_weight : 1) === numericKey((_sku$unit_weight2 = sku === null || sku === void 0 ? void 0 : sku.unit_weight) !== null && _sku$unit_weight2 !== void 0 ? _sku$unit_weight2 : 1) && JSON.stringify(snapshotKey(weighing === null || weighing === void 0 ? void 0 : weighing.scalePriceProduct)) === JSON.stringify(snapshotKey(sku === null || sku === void 0 ? void 0 : sku.unit_data_snapshot));
|
|
72
|
+
if (runtimeAmount && runtimeMatchesSku) return runtimeAmount.toFixed(2);
|
|
73
|
+
|
|
74
|
+
// Older persisted orders have only a rounded per-scale-unit price.
|
|
75
|
+
var unitPrice = nonNegative(measurement === null || measurement === void 0 ? void 0 : measurement.unit_price);
|
|
76
|
+
var unitWeight = nonNegative((_measurement$unit_wei = measurement === null || measurement === void 0 ? void 0 : measurement.unit_weight) !== null && _measurement$unit_wei !== void 0 ? _measurement$unit_wei : 1);
|
|
77
|
+
if (!unitPrice || !(unitWeight !== null && unitWeight !== void 0 && unitWeight.gt(0))) return undefined;
|
|
78
|
+
return netWeight.div(unitWeight).mul(unitPrice).toFixed(2);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Original bundle totals must use the nested options before manual distribution. */
|
|
82
|
+
export function withOriginalBundleOptionPrices(bundles) {
|
|
83
|
+
return bundles === null || bundles === void 0 ? void 0 : bundles.map(function (bundle) {
|
|
84
|
+
var _bundle$option;
|
|
85
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
86
|
+
option: (_bundle$option = bundle.option) === null || _bundle$option === void 0 ? void 0 : _bundle$option.map(function (option) {
|
|
87
|
+
var _ref, _option$original_pric;
|
|
88
|
+
return _objectSpread(_objectSpread({}, option), {}, {
|
|
89
|
+
add_price: (_ref = (_option$original_pric = option.original_price) !== null && _option$original_pric !== void 0 ? _option$original_pric : option.add_price) !== null && _ref !== void 0 ? _ref : option.price
|
|
90
|
+
});
|
|
91
|
+
})
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
@@ -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(
|
|
174
|
+
export declare function createDefaultOrderRulesHooks(): RulesParamsHooks;
|
|
175
175
|
/**
|
|
176
176
|
* 通过 session 类商品的开始时间结束时间生成商品的时长
|
|
177
177
|
* @param {CartItem} cartItem
|
|
@@ -23,13 +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';
|
|
27
26
|
import Decimal from 'decimal.js';
|
|
27
|
+
import { withOriginalBundleOptionPrices } from "./utils/weighedProduct";
|
|
28
|
+
import { hasManualProductDiscountFlag } from "./utils/manualProductDiscount";
|
|
28
29
|
import { getProductHolderConfig } from "../Holder/utils";
|
|
29
30
|
import { buildProductLineFingerprint, createEmptySummary } from "../../solution/ScanOrder/utils";
|
|
30
31
|
import { createUuidV4 } from "./utils/orderCollectionIdentity";
|
|
31
32
|
import { encodeSalesNotes } from "./salesNotes";
|
|
32
|
-
dayjs.extend(customParseFormat);
|
|
33
33
|
var POINT_CARD_SNAPSHOT_TAG = 'point_card';
|
|
34
34
|
var VIRTUAL_CURRENCY_SNAPSHOT_TAG = 'virtual_currency';
|
|
35
35
|
function isPlainObject(value) {
|
|
@@ -659,22 +659,6 @@ function resolveSubmitBundleMapId(bundle) {
|
|
|
659
659
|
}
|
|
660
660
|
return undefined;
|
|
661
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
|
-
}
|
|
678
662
|
function collectSubmitProductDiscountList(product) {
|
|
679
663
|
var submitDiscountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? _toConsumableArray(product.discount_list) : [];
|
|
680
664
|
var _iterator5 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
|
|
@@ -710,7 +694,7 @@ function collectSubmitProductDiscountList(product) {
|
|
|
710
694
|
} finally {
|
|
711
695
|
_iterator5.f();
|
|
712
696
|
}
|
|
713
|
-
return normalizeOrderProductDiscountList(submitDiscountList
|
|
697
|
+
return normalizeOrderProductDiscountList(submitDiscountList);
|
|
714
698
|
}
|
|
715
699
|
|
|
716
700
|
/**
|
|
@@ -783,37 +767,14 @@ export function resolveEffectivePerUnitDiscount(product) {
|
|
|
783
767
|
if (!Number.isFinite(originalPrice) || !Number.isFinite(finalPrice)) return fromList;
|
|
784
768
|
return fromList + (originalPrice - finalPrice);
|
|
785
769
|
}
|
|
786
|
-
export function createDefaultOrderRulesHooks(
|
|
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
|
-
};
|
|
770
|
+
export function createDefaultOrderRulesHooks() {
|
|
810
771
|
var toUnitPriceString = function toUnitPriceString(totalLike, num) {
|
|
811
772
|
var effectiveNum = Number(num) > 0 ? Number(num) : 1;
|
|
812
773
|
return new Decimal(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
|
|
813
774
|
};
|
|
814
775
|
var getBundleIdentity = function getBundleIdentity(bundle) {
|
|
815
|
-
var
|
|
816
|
-
return [(
|
|
776
|
+
var _ref17, _bundle$bundle_id, _ref18, _ref19, _bundle$bundle_produc, _ref20, _ref21, _bundle$bundle_varian, _ref22, _bundle$bundle_group_;
|
|
777
|
+
return [(_ref17 = (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id) !== null && _ref17 !== void 0 ? _ref17 : '', (_ref18 = (_ref19 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref19 !== void 0 ? _ref19 : bundle.product_id) !== null && _ref18 !== void 0 ? _ref18 : '', (_ref20 = (_ref21 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref21 !== void 0 ? _ref21 : bundle.product_variant_id) !== null && _ref20 !== void 0 ? _ref20 : 0, (_ref22 = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id) !== null && _ref22 !== void 0 ? _ref22 : ''].join('|');
|
|
817
778
|
};
|
|
818
779
|
var mergeRulesBundlePrices = function mergeRulesBundlePrices(currentBundle, rulesBundle) {
|
|
819
780
|
if (!Array.isArray(rulesBundle)) return rulesBundle;
|
|
@@ -823,7 +784,7 @@ export function createDefaultOrderRulesHooks(getBookings) {
|
|
|
823
784
|
currentByIdentity.set(getBundleIdentity(bundle), bundle);
|
|
824
785
|
});
|
|
825
786
|
return rulesBundle.map(function (bundle) {
|
|
826
|
-
var _bundle$price_type_ex2,
|
|
787
|
+
var _bundle$price_type_ex2, _ref23, _ref24, _current$price, _ref25, _ref26, _ref27, _current$original_pri;
|
|
827
788
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
828
789
|
var current = currentByIdentity.get(getBundleIdentity(bundle));
|
|
829
790
|
if (!current) return bundle;
|
|
@@ -832,8 +793,8 @@ export function createDefaultOrderRulesHooks(getBookings) {
|
|
|
832
793
|
} : {});
|
|
833
794
|
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';
|
|
834
795
|
if (!isProductPriceBundle) return bundleWithDisplayFields;
|
|
835
|
-
var sourcePrice = (
|
|
836
|
-
var originalPrice = (
|
|
796
|
+
var sourcePrice = (_ref23 = (_ref24 = (_current$price = current.price) !== null && _current$price !== void 0 ? _current$price : current.custom_price) !== null && _ref24 !== void 0 ? _ref24 : current.original_price) !== null && _ref23 !== void 0 ? _ref23 : current.bundle_selling_price;
|
|
797
|
+
var originalPrice = (_ref25 = (_ref26 = (_ref27 = (_current$original_pri = current.original_price) !== null && _current$original_pri !== void 0 ? _current$original_pri : current.product_price) !== null && _ref27 !== void 0 ? _ref27 : current.price) !== null && _ref26 !== void 0 ? _ref26 : current.custom_price) !== null && _ref25 !== void 0 ? _ref25 : sourcePrice;
|
|
837
798
|
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, bundleWithDisplayFields), sourcePrice !== undefined ? {
|
|
838
799
|
price: sourcePrice
|
|
839
800
|
} : {}), originalPrice !== undefined ? {
|
|
@@ -845,7 +806,7 @@ export function createDefaultOrderRulesHooks(getBookings) {
|
|
|
845
806
|
};
|
|
846
807
|
return {
|
|
847
808
|
getProduct: function getProduct(product) {
|
|
848
|
-
var _product$
|
|
809
|
+
var _product$metadata2, _product$metadata3, _product$metadata4, _product$metadata5, _product$metadata6, _metadataAny$_promoti;
|
|
849
810
|
// source_product_price 是权威源;兜底链:source → mainSelling − options(反推)→ 行 selling_price
|
|
850
811
|
var metadataAny = product.metadata || {};
|
|
851
812
|
var optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
|
|
@@ -872,7 +833,7 @@ export function createDefaultOrderRulesHooks(getBookings) {
|
|
|
872
833
|
// 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
|
|
873
834
|
// 不透明 identity 契约下,normalizeOrderProduct / hydrate 已保证唯一值存在;
|
|
874
835
|
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
875
|
-
_id: (_product$
|
|
836
|
+
_id: (_product$metadata2 = product.metadata) !== null && _product$metadata2 !== void 0 && _product$metadata2.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)),
|
|
876
837
|
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
877
838
|
// 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
|
|
878
839
|
price: sourcePrice,
|
|
@@ -884,23 +845,23 @@ export function createDefaultOrderRulesHooks(getBookings) {
|
|
|
884
845
|
num: product.num || 1,
|
|
885
846
|
discount_list: product.discount_list || [],
|
|
886
847
|
bundle: product.product_bundle || [],
|
|
887
|
-
booking_id: ((_product$
|
|
848
|
+
booking_id: ((_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.booking_id) || null,
|
|
888
849
|
isClient: false,
|
|
889
850
|
// 勿写死 false:否则 Rules 不会走 total≠origin_total 的手动价推断,
|
|
890
851
|
// 无券时会把 bundle 价还原成 original_price(手动改价套餐会从 20 回到 30)。
|
|
891
852
|
isManualDiscount: resolveRulesManualDiscountFlag(metadataAny),
|
|
892
|
-
holder_id: (_product$
|
|
893
|
-
startDate:
|
|
853
|
+
holder_id: (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.holder_id,
|
|
854
|
+
startDate: ((_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),
|
|
894
855
|
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,
|
|
895
856
|
inPromotion: ((_metadataAny$_promoti = metadataAny._promotion) === null || _metadataAny$_promoti === void 0 ? void 0 : _metadataAny$_promoti.inPromotion) === true,
|
|
896
857
|
_promotion: metadataAny._promotion
|
|
897
858
|
};
|
|
898
859
|
},
|
|
899
860
|
setProduct: function setProduct(product, values) {
|
|
900
|
-
var
|
|
901
|
-
var nextNum = Number((
|
|
861
|
+
var _ref28, _values$quantity, _ref29, _metadataAny$source_p, _product$product_sku, _values$discount_list, _values$quantity2;
|
|
862
|
+
var nextNum = Number((_ref28 = (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num) !== null && _ref28 !== void 0 ? _ref28 : 1) || 1;
|
|
902
863
|
var metadataAny = product.metadata || {};
|
|
903
|
-
var existedSource = (
|
|
864
|
+
var existedSource = (_ref29 = (_metadataAny$source_p = metadataAny.source_product_price) !== null && _metadataAny$source_p !== void 0 ? _metadataAny$source_p : product.selling_price) !== null && _ref29 !== void 0 ? _ref29 : '0';
|
|
904
865
|
var nextOptions = getProductSkuOptions(product);
|
|
905
866
|
var optionSum = sumOptionUnitPrice(nextOptions);
|
|
906
867
|
|
|
@@ -923,7 +884,7 @@ export function createDefaultOrderRulesHooks(getBookings) {
|
|
|
923
884
|
});
|
|
924
885
|
var composedOriginalPrice = composeLinePrice({
|
|
925
886
|
mainPrice: nextMainOriginalPrice,
|
|
926
|
-
bundle: nextBundle,
|
|
887
|
+
bundle: Number((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.open_sold_weight) === 1 && hasManualProductDiscountFlag(metadataAny) ? withOriginalBundleOptionPrices(nextBundle) : nextBundle,
|
|
927
888
|
useOriginalBundle: true
|
|
928
889
|
});
|
|
929
890
|
var finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
|
|
@@ -1111,7 +1072,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1111
1072
|
var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1112
1073
|
if (!Array.isArray(bundle)) return [];
|
|
1113
1074
|
return bundle.map(function (b) {
|
|
1114
|
-
var
|
|
1075
|
+
var _ref30, _rawBundle$price, _rawBundle$surcharge_, _rawBundle$num, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$quantity, _rawBundle$extension_, _rawBundle$extension_2, _ref31, _rawBundle$price_type, _ref32, _rawBundle$price_type2, _rawBundle$bundle_gro, _rawBundle$bundle_id, _rawBundle$bundle_pro;
|
|
1115
1076
|
var rawBundle = b && _typeof(b) === 'object' ? b : {};
|
|
1116
1077
|
var existedMetadata = rawBundle.metadata && _typeof(rawBundle.metadata) === 'object' ? rawBundle.metadata : {};
|
|
1117
1078
|
var _customProductBundleMapId = existedMetadata.custom_product_bundle_map_id,
|
|
@@ -1122,7 +1083,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1122
1083
|
var sellingPrice = formatOptions.virtualSettlementMode ? '0.00' : getBundleSellingMagnitude(rawBundle).toFixed(2);
|
|
1123
1084
|
// payment 价由整单折扣均摊层产出;缺省(无折扣)时与 selling 净额同义。
|
|
1124
1085
|
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;
|
|
1125
|
-
var priceValue = formatOptions.virtualSettlementMode ? 0 : (
|
|
1086
|
+
var priceValue = formatOptions.virtualSettlementMode ? 0 : (_ref30 = (_rawBundle$price = rawBundle.price) !== null && _rawBundle$price !== void 0 ? _rawBundle$price : rawBundle.custom_price) !== null && _ref30 !== void 0 ? _ref30 : rawBundle.bundle_selling_price;
|
|
1126
1087
|
var relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
|
|
1127
1088
|
var surchargeFee = toMoneyString((_rawBundle$surcharge_ = rawBundle.surcharge_fee) !== null && _rawBundle$surcharge_ !== void 0 ? _rawBundle$surcharge_ : existedMetadata.surcharge_fee);
|
|
1128
1089
|
var productDiscountDifference = toBundleNumber(existedMetadata.product_discount_difference, 0);
|
|
@@ -1141,8 +1102,8 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1141
1102
|
extension_id: (_rawBundle$extension_ = rawBundle.extension_id) !== null && _rawBundle$extension_ !== void 0 ? _rawBundle$extension_ : 0,
|
|
1142
1103
|
extension_type: (_rawBundle$extension_2 = rawBundle.extension_type) !== null && _rawBundle$extension_2 !== void 0 ? _rawBundle$extension_2 : 'normal',
|
|
1143
1104
|
price: priceValue,
|
|
1144
|
-
price_type: (
|
|
1145
|
-
price_type_ext: (
|
|
1105
|
+
price_type: (_ref31 = (_rawBundle$price_type = rawBundle.price_type) !== null && _rawBundle$price_type !== void 0 ? _rawBundle$price_type : rawBundle.custom_price_type) !== null && _ref31 !== void 0 ? _ref31 : '',
|
|
1106
|
+
price_type_ext: (_ref32 = (_rawBundle$price_type2 = rawBundle.price_type_ext) !== null && _rawBundle$price_type2 !== void 0 ? _rawBundle$price_type2 : rawBundle.custom_price_type_ext) !== null && _ref32 !== void 0 ? _ref32 : '',
|
|
1146
1107
|
bundle_selling_price: sellingPrice,
|
|
1147
1108
|
bundle_payment_price: paymentPrice,
|
|
1148
1109
|
option: formatSubmitOptionItems(rawBundle.option, formatOptions),
|
|
@@ -1178,11 +1139,11 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1178
1139
|
* 法币仅做字段/metadata 裁剪;虚拟币在出站前再次执行零加价与固定单价断言。
|
|
1179
1140
|
*/
|
|
1180
1141
|
function normalizeSubmitProduct(product) {
|
|
1181
|
-
var
|
|
1142
|
+
var _ref34, _submitProduct$bundle, _rawMetadata$product_, _rawMetadata$selected, _rawMetadata$selected2, _submitProduct$produc, _submitProduct$paymen;
|
|
1182
1143
|
var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1183
|
-
var
|
|
1184
|
-
_runtimeUid =
|
|
1185
|
-
submitProduct = _objectWithoutProperties(
|
|
1144
|
+
var _ref33 = product,
|
|
1145
|
+
_runtimeUid = _ref33.unique_identification_number,
|
|
1146
|
+
submitProduct = _objectWithoutProperties(_ref33, _excluded2);
|
|
1186
1147
|
var num = submitProduct.num,
|
|
1187
1148
|
_productSurchargeFee = submitProduct.surcharge_fee,
|
|
1188
1149
|
_deprecatedDiscountAmount = submitProduct.discount_amount,
|
|
@@ -1199,7 +1160,7 @@ function normalizeSubmitProduct(product) {
|
|
|
1199
1160
|
// 兼容历史 BigSale 编辑链路:bundle_edit 曾被写入 metadata,
|
|
1200
1161
|
// 出站时需提升到商品顶层;套餐未编辑时也必须显式提交 0。
|
|
1201
1162
|
var hasProductBundle = Array.isArray(submitProduct.product_bundle) && submitProduct.product_bundle.length > 0;
|
|
1202
|
-
var bundleEdit = (
|
|
1163
|
+
var bundleEdit = (_ref34 = (_submitProduct$bundle = submitProduct.bundle_edit) !== null && _submitProduct$bundle !== void 0 ? _submitProduct$bundle : rawMetadata.bundle_edit) !== null && _ref34 !== void 0 ? _ref34 : hasProductBundle ? 0 : undefined;
|
|
1203
1164
|
var cleanMetadata = {};
|
|
1204
1165
|
if (rawMetadata.unique_identification_number) {
|
|
1205
1166
|
cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
|
|
@@ -1430,7 +1391,7 @@ export function resolveSubmitOrderType(params) {
|
|
|
1430
1391
|
return 'virtual';
|
|
1431
1392
|
}
|
|
1432
1393
|
export function buildSubmitPayload(params) {
|
|
1433
|
-
var _tempOrder$metadata2, _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_,
|
|
1394
|
+
var _tempOrder$metadata2, _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_, _ref36, _tempOrder$is_price_i, _tempOrder$is_deposit, _tempOrder$_extend, _enhancedPayload$summ;
|
|
1434
1395
|
var tempOrder = params.tempOrder,
|
|
1435
1396
|
cacheId = params.cacheId,
|
|
1436
1397
|
_params$now = params.now,
|
|
@@ -1444,29 +1405,29 @@ export function buildSubmitPayload(params) {
|
|
|
1444
1405
|
var scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
|
|
1445
1406
|
var bookingUuid = createUuidV4();
|
|
1446
1407
|
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';
|
|
1447
|
-
var
|
|
1448
|
-
_extend =
|
|
1449
|
-
_relationId =
|
|
1450
|
-
_tableFormId =
|
|
1451
|
-
_resourceId =
|
|
1452
|
-
_summary =
|
|
1453
|
-
_lastOrderInfo =
|
|
1454
|
-
_paidAmount =
|
|
1455
|
-
_shopId =
|
|
1456
|
-
_shopNote =
|
|
1457
|
-
_shopServiceType =
|
|
1458
|
-
_startTime =
|
|
1459
|
-
_customer =
|
|
1460
|
-
_discountList =
|
|
1461
|
-
_orderMetaList =
|
|
1462
|
-
_rootTaxFee =
|
|
1463
|
-
_totalAmount =
|
|
1464
|
-
_totalRefundAmount =
|
|
1465
|
-
_createDate =
|
|
1466
|
-
_holderId =
|
|
1467
|
-
_paymentStatus =
|
|
1468
|
-
_notes =
|
|
1469
|
-
tempOrderRest = _objectWithoutProperties(
|
|
1408
|
+
var _ref35 = tempOrder,
|
|
1409
|
+
_extend = _ref35._extend,
|
|
1410
|
+
_relationId = _ref35.relation_id,
|
|
1411
|
+
_tableFormId = _ref35.table_form_id,
|
|
1412
|
+
_resourceId = _ref35.resource_id,
|
|
1413
|
+
_summary = _ref35.summary,
|
|
1414
|
+
_lastOrderInfo = _ref35.lastOrderInfo,
|
|
1415
|
+
_paidAmount = _ref35.paid_amount,
|
|
1416
|
+
_shopId = _ref35.shop_id,
|
|
1417
|
+
_shopNote = _ref35.shop_note,
|
|
1418
|
+
_shopServiceType = _ref35.shop_service_type,
|
|
1419
|
+
_startTime = _ref35.start_time,
|
|
1420
|
+
_customer = _ref35.customer,
|
|
1421
|
+
_discountList = _ref35.discount_list,
|
|
1422
|
+
_orderMetaList = _ref35.order_meta_list,
|
|
1423
|
+
_rootTaxFee = _ref35.tax_fee,
|
|
1424
|
+
_totalAmount = _ref35.total_amount,
|
|
1425
|
+
_totalRefundAmount = _ref35.total_refund_amount,
|
|
1426
|
+
_createDate = _ref35.create_date,
|
|
1427
|
+
_holderId = _ref35.holder_id,
|
|
1428
|
+
_paymentStatus = _ref35.payment_status,
|
|
1429
|
+
_notes = _ref35.notes,
|
|
1430
|
+
tempOrderRest = _objectWithoutProperties(_ref35, _excluded4);
|
|
1470
1431
|
var resolvedBusinessCode = businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code;
|
|
1471
1432
|
var normalizedOrderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
|
|
1472
1433
|
var submitType = resolveSubmitOrderType({
|
|
@@ -1491,7 +1452,7 @@ export function buildSubmitPayload(params) {
|
|
|
1491
1452
|
type: submitType,
|
|
1492
1453
|
business_code: resolvedBusinessCode,
|
|
1493
1454
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
1494
|
-
order_sales_channel: (
|
|
1455
|
+
order_sales_channel: (_ref36 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref36 !== void 0 ? _ref36 : 'online_store',
|
|
1495
1456
|
status: tempOrder.status || 'normal'
|
|
1496
1457
|
}, params.includePaymentStatus !== false ? {
|
|
1497
1458
|
payment_status: tempOrder.payment_status || 'payment_processing'
|
|
@@ -1519,13 +1480,13 @@ export function buildSubmitPayload(params) {
|
|
|
1519
1480
|
// holder: tempOrder.holder || null,
|
|
1520
1481
|
summary: summary || tempOrder.summary || createEmptySummary(),
|
|
1521
1482
|
metadata: function () {
|
|
1522
|
-
var
|
|
1523
|
-
_collectPax =
|
|
1524
|
-
_tableOccupancyDuration =
|
|
1525
|
-
_cartSettlementKey =
|
|
1526
|
-
_cartSettlementSnapshot =
|
|
1527
|
-
_legalCurrencySnapshot =
|
|
1528
|
-
rest = _objectWithoutProperties(
|
|
1483
|
+
var _ref37 = tempOrder.metadata || {},
|
|
1484
|
+
_collectPax = _ref37.collect_pax,
|
|
1485
|
+
_tableOccupancyDuration = _ref37.table_occupancy_duration,
|
|
1486
|
+
_cartSettlementKey = _ref37.cart_settlement_key,
|
|
1487
|
+
_cartSettlementSnapshot = _ref37.cart_settlement_snapshot,
|
|
1488
|
+
_legalCurrencySnapshot = _ref37.legal_currency_snapshot,
|
|
1489
|
+
rest = _objectWithoutProperties(_ref37, _excluded5);
|
|
1529
1490
|
return _objectSpread({}, rest);
|
|
1530
1491
|
}()
|
|
1531
1492
|
}, (_tempOrder$_extend = tempOrder._extend) !== null && _tempOrder$_extend !== void 0 && (_tempOrder$_extend = _tempOrder$_extend.salesNotesState) !== null && _tempOrder$_extend !== void 0 && _tempOrder$_extend.dirty ? {
|
|
@@ -1627,11 +1588,11 @@ export function mapPaymentItemsToOrderPayments(paymentItems) {
|
|
|
1627
1588
|
*/
|
|
1628
1589
|
export function formatV1Product(products) {
|
|
1629
1590
|
return products.map(function (product) {
|
|
1630
|
-
var _product$
|
|
1591
|
+
var _product$product_sku2, _product$note;
|
|
1631
1592
|
return {
|
|
1632
1593
|
bundle: product.product_bundle,
|
|
1633
1594
|
key: product.product_id,
|
|
1634
|
-
option: ((_product$
|
|
1595
|
+
option: ((_product$product_sku2 = product.product_sku) === null || _product$product_sku2 === void 0 ? void 0 : _product$product_sku2.option) || [],
|
|
1635
1596
|
product_id: product.product_id,
|
|
1636
1597
|
product_variant_id: product.product_variant_id,
|
|
1637
1598
|
num: product.product_quantity,
|
|
@@ -1729,9 +1690,9 @@ export function clearTempOrderHolderAssignments(tempOrder) {
|
|
|
1729
1690
|
* getOrderProductLineUid({ metadata: { unique_identification_number: 'line-1' } }); // 'line-1'
|
|
1730
1691
|
*/
|
|
1731
1692
|
export function getOrderProductLineUid(product) {
|
|
1732
|
-
var _product$metadata$
|
|
1693
|
+
var _product$metadata$uni, _product$metadata7;
|
|
1733
1694
|
if (!product || _typeof(product) !== 'object') return null;
|
|
1734
|
-
var uid = (_product$metadata$
|
|
1695
|
+
var uid = (_product$metadata$uni = (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product.unique_identification_number;
|
|
1735
1696
|
if (uid === undefined || uid === null || uid === '') return null;
|
|
1736
1697
|
return String(uid);
|
|
1737
1698
|
}
|
|
@@ -1742,8 +1703,8 @@ export function getRuntimeProductOrigin(tempOrder, product) {
|
|
|
1742
1703
|
return tempOrder._extend.productsByUid[uid].origin;
|
|
1743
1704
|
}
|
|
1744
1705
|
var matchedProduct = ((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || []).find(function (item) {
|
|
1745
|
-
var
|
|
1746
|
-
return item === product || getOrderProductLineUid(item) === uid || String((
|
|
1706
|
+
var _ref38, _item$product_id, _ref39, _product$product_id;
|
|
1707
|
+
return item === product || getOrderProductLineUid(item) === uid || String((_ref38 = (_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 && _ref38 !== void 0 ? _ref38 : '') === String((_ref39 = (_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 && _ref39 !== void 0 ? _ref39 : '');
|
|
1747
1708
|
});
|
|
1748
1709
|
var matchedUid = matchedProduct ? getOrderProductLineUid(matchedProduct) : '';
|
|
1749
1710
|
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,8 +412,6 @@ export interface WalletAssetsBehaviorOptions {
|
|
|
412
412
|
export interface RefreshWalletAssetsOptions {
|
|
413
413
|
/** 商品/金额变化默认保留并重验选择;客户变化由实现层强制清空。 */
|
|
414
414
|
preserveSelection?: boolean;
|
|
415
|
-
/** 客户变化时,仅保留与本次扫码匹配的搜索结果;其他搜索缓存仍会清空。 */
|
|
416
|
-
retainSearchResultCodes?: string[];
|
|
417
415
|
}
|
|
418
416
|
export interface SelectWalletAssetOptions {
|
|
419
417
|
selected: boolean;
|
|
@@ -421,8 +419,6 @@ export interface SelectWalletAssetOptions {
|
|
|
421
419
|
}
|
|
422
420
|
export interface ScanWalletAssetResult {
|
|
423
421
|
type: SearchIdentificationCodeResult['type'];
|
|
424
|
-
/** walletCode 时保留完整 Wallet Detail,供客户解析与客户选择器使用。 */
|
|
425
|
-
data?: WalletDetailSearchData;
|
|
426
422
|
asset?: any;
|
|
427
423
|
selected: boolean;
|
|
428
424
|
state: WalletAssetsState;
|
|
@@ -868,8 +864,6 @@ export interface SearchIdentificationCodeParams extends WalletDeductionRecommend
|
|
|
868
864
|
* 搜索识别码响应数据
|
|
869
865
|
*/
|
|
870
866
|
export interface SearchIdentificationCodeResponse {
|
|
871
|
-
/** 业务是否成功 */
|
|
872
|
-
status?: boolean;
|
|
873
867
|
/** 响应状态码 */
|
|
874
868
|
code?: number;
|
|
875
869
|
/** 响应消息 */
|
|
@@ -877,26 +871,12 @@ export interface SearchIdentificationCodeResponse {
|
|
|
877
871
|
/** 响应数据 */
|
|
878
872
|
data?: SearchIdentificationCodeItem[];
|
|
879
873
|
}
|
|
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
|
-
}
|
|
894
874
|
/**
|
|
895
875
|
* 搜索识别码结果类型
|
|
896
876
|
*/
|
|
897
877
|
export type SearchIdentificationCodeResult = {
|
|
898
878
|
type: 'walletCode';
|
|
899
|
-
data:
|
|
879
|
+
data: SearchIdentificationCodeItem[];
|
|
900
880
|
} | {
|
|
901
881
|
type: 'normalCode';
|
|
902
882
|
data: SearchIdentificationCodeItem[];
|
|
@@ -96,7 +96,7 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
96
96
|
* 搜索识别码信息
|
|
97
97
|
* 通过识别码搜索相关的钱包通行证信息
|
|
98
98
|
* 基于 WalletDeductionRecommendParams 参数结构
|
|
99
|
-
*
|
|
99
|
+
* 特殊逻辑:当识别码长度为9位且前3位为"000"时,调用 /wallet/detail/search 接口
|
|
100
100
|
*/
|
|
101
101
|
searchIdentificationCodeAsync(params: SearchIdentificationCodeParams, config?: {
|
|
102
102
|
noCache?: boolean;
|