@pisell/pisellos 2.3.123 → 2.3.125
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/modules/Order/index.d.ts +12 -1
- package/dist/modules/Order/index.js +261 -178
- package/dist/modules/Order/types.d.ts +5 -0
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +118 -72
- package/dist/solution/BaseSales/index.js +57 -46
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Order/index.d.ts +12 -1
- package/lib/modules/Order/index.js +67 -2
- package/lib/modules/Order/types.d.ts +5 -0
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +42 -0
- package/lib/solution/BaseSales/index.js +10 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -204,6 +204,10 @@ export interface PointCardSnapshotItem {
|
|
|
204
204
|
par_value: string;
|
|
205
205
|
used_par_value: string;
|
|
206
206
|
}
|
|
207
|
+
export interface PointCardSnapshotMergeContext {
|
|
208
|
+
customerId?: number | string | null;
|
|
209
|
+
orderIdentity?: OrderIdentitySnapshot | null;
|
|
210
|
+
}
|
|
207
211
|
export interface VirtualCurrencySnapshotItem {
|
|
208
212
|
id: number | string;
|
|
209
213
|
tag: 'virtual_currency';
|
|
@@ -976,6 +980,7 @@ export interface OrderModuleAPI {
|
|
|
976
980
|
getDiscountList: () => Discount[];
|
|
977
981
|
getAvailableWalletIds: () => number[];
|
|
978
982
|
getCustomerWalletPrepareConfigEpoch: () => number;
|
|
983
|
+
mergePointCardSnapshotCodes: (walletPassList: unknown, context?: PointCardSnapshotMergeContext) => PointCardSnapshotItem[];
|
|
979
984
|
applyDiscount: () => void;
|
|
980
985
|
/**
|
|
981
986
|
* 注入促销评估器。
|
|
@@ -18,6 +18,16 @@ export interface OrderProductsDepositSummary {
|
|
|
18
18
|
import type { WindowPlugin } from '../../plugins';
|
|
19
19
|
export declare function normalizePointCardSnapshotItem(value: unknown): PointCardSnapshotItem | null;
|
|
20
20
|
export declare function buildPointCardSnapshotFromWalletPassList(value: unknown): PointCardSnapshotItem[];
|
|
21
|
+
export declare function collectPointCardSnapshotCodeCandidates(value: unknown): Array<{
|
|
22
|
+
id: string;
|
|
23
|
+
code: string;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Payment 的 WalletPass 列表包含实例 code,而 prepare/config 通常只提供
|
|
27
|
+
* 卡名称和余额。按实例 ID 仅补齐 Snapshot 缺失的 code,避免后到的运行态
|
|
28
|
+
* 数据覆盖下单时已经冻结的卡名称和余额。
|
|
29
|
+
*/
|
|
30
|
+
export declare function mergePointCardSnapshotCodes(snapshotsValue: unknown, walletPassesValue: unknown): PointCardSnapshotItem[];
|
|
21
31
|
export declare function normalizeVirtualCurrencySnapshotItem(value: unknown): VirtualCurrencySnapshotItem | null;
|
|
22
32
|
export declare function buildVirtualCurrencySnapshotFromList(value: unknown): VirtualCurrencySnapshotItem[];
|
|
23
33
|
export declare function normalizeOrderMetaList(value: unknown): OrderMetaList | undefined;
|
|
@@ -5,10 +5,6 @@ var _excluded = ["custom_product_bundle_map_id"],
|
|
|
5
5
|
_excluded5 = ["collect_pax", "table_occupancy_duration", "cart_settlement_key", "cart_settlement_snapshot", "legal_currency_snapshot"];
|
|
6
6
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
7
7
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
8
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
8
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
13
9
|
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; }
|
|
14
10
|
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; }
|
|
@@ -17,10 +13,14 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
17
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); }
|
|
18
14
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
19
15
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
20
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
21
|
-
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; }
|
|
22
16
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
23
17
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
19
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
20
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
21
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
22
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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
26
|
import Decimal from 'decimal.js';
|
|
@@ -72,6 +72,52 @@ export function buildPointCardSnapshotFromWalletPassList(value) {
|
|
|
72
72
|
return result;
|
|
73
73
|
}, []);
|
|
74
74
|
}
|
|
75
|
+
export function collectPointCardSnapshotCodeCandidates(value) {
|
|
76
|
+
if (!Array.isArray(value)) return [];
|
|
77
|
+
var codeById = new Map();
|
|
78
|
+
value.forEach(function (item) {
|
|
79
|
+
var _item$id;
|
|
80
|
+
if (!isPlainObject(item)) return;
|
|
81
|
+
var id = normalizeSnapshotScalar((_item$id = item.id) !== null && _item$id !== void 0 ? _item$id : item.voucher_id);
|
|
82
|
+
var code = normalizeSnapshotScalar(item.code);
|
|
83
|
+
if (id === undefined || code === undefined) return;
|
|
84
|
+
var identity = String(id).trim();
|
|
85
|
+
var normalizedCode = String(code).trim();
|
|
86
|
+
if (!identity || !normalizedCode || codeById.has(identity)) return;
|
|
87
|
+
codeById.set(identity, normalizedCode);
|
|
88
|
+
});
|
|
89
|
+
return _toConsumableArray(codeById).map(function (_ref) {
|
|
90
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
91
|
+
id = _ref2[0],
|
|
92
|
+
code = _ref2[1];
|
|
93
|
+
return {
|
|
94
|
+
id: id,
|
|
95
|
+
code: code
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Payment 的 WalletPass 列表包含实例 code,而 prepare/config 通常只提供
|
|
102
|
+
* 卡名称和余额。按实例 ID 仅补齐 Snapshot 缺失的 code,避免后到的运行态
|
|
103
|
+
* 数据覆盖下单时已经冻结的卡名称和余额。
|
|
104
|
+
*/
|
|
105
|
+
export function mergePointCardSnapshotCodes(snapshotsValue, walletPassesValue) {
|
|
106
|
+
var snapshots = buildPointCardSnapshotFromWalletPassList(snapshotsValue);
|
|
107
|
+
if (!snapshots.length || !Array.isArray(walletPassesValue)) return snapshots;
|
|
108
|
+
var codeById = new Map(collectPointCardSnapshotCodeCandidates(walletPassesValue).map(function (_ref3) {
|
|
109
|
+
var id = _ref3.id,
|
|
110
|
+
code = _ref3.code;
|
|
111
|
+
return [id, code];
|
|
112
|
+
}));
|
|
113
|
+
return snapshots.map(function (snapshot) {
|
|
114
|
+
if (snapshot.code) return snapshot;
|
|
115
|
+
var code = codeById.get(String(snapshot.id).trim());
|
|
116
|
+
return code ? _objectSpread(_objectSpread({}, snapshot), {}, {
|
|
117
|
+
code: code
|
|
118
|
+
}) : snapshot;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
75
121
|
function normalizeSnapshotNameMap(value) {
|
|
76
122
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
77
123
|
var normalizedText = String(value).trim();
|
|
@@ -80,10 +126,10 @@ function normalizeSnapshotNameMap(value) {
|
|
|
80
126
|
} : {};
|
|
81
127
|
}
|
|
82
128
|
if (!isPlainObject(value)) return {};
|
|
83
|
-
return Object.entries(value).reduce(function (result,
|
|
84
|
-
var
|
|
85
|
-
locale =
|
|
86
|
-
text =
|
|
129
|
+
return Object.entries(value).reduce(function (result, _ref4) {
|
|
130
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
|
131
|
+
locale = _ref5[0],
|
|
132
|
+
text = _ref5[1];
|
|
87
133
|
if (!locale.trim()) return result;
|
|
88
134
|
if (typeof text !== 'string' && typeof text !== 'number') return result;
|
|
89
135
|
var normalizedText = String(text).trim();
|
|
@@ -209,13 +255,13 @@ export function composeLinePrice(params) {
|
|
|
209
255
|
_step;
|
|
210
256
|
try {
|
|
211
257
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
212
|
-
var
|
|
258
|
+
var _ref6, _item$num;
|
|
213
259
|
var item = _step.value;
|
|
214
260
|
// markdown(减价)按带符号净额取减;markup/原价维持相加。
|
|
215
261
|
var signedUnit = getBundleSignedUnit(item, {
|
|
216
262
|
useOriginal: useOriginalBundle
|
|
217
263
|
});
|
|
218
|
-
var rawNum = (
|
|
264
|
+
var rawNum = (_ref6 = (_item$num = item === null || item === void 0 ? void 0 : item.num) !== null && _item$num !== void 0 ? _item$num : item === null || item === void 0 ? void 0 : item.quantity) !== null && _ref6 !== void 0 ? _ref6 : 1;
|
|
219
265
|
var num = new Decimal(Number(rawNum) || 0);
|
|
220
266
|
total = total.plus(signedUnit.times(num));
|
|
221
267
|
}
|
|
@@ -279,12 +325,12 @@ function getSafeOrderProductNum(num) {
|
|
|
279
325
|
return Math.floor(parsedNum);
|
|
280
326
|
}
|
|
281
327
|
function getOrderProductDepositUnitTotal(product) {
|
|
282
|
-
var
|
|
328
|
+
var _ref7;
|
|
283
329
|
var metadata = product.metadata || {};
|
|
284
330
|
var paymentPrice = metadata.main_product_attached_bundle_payment_price;
|
|
285
331
|
var mainSellingPrice = metadata.main_product_selling_price;
|
|
286
332
|
var fallbackPrice = product.selling_price;
|
|
287
|
-
return new Decimal(Number((
|
|
333
|
+
return new Decimal(Number((_ref7 = paymentPrice !== null && paymentPrice !== void 0 ? paymentPrice : mainSellingPrice) !== null && _ref7 !== void 0 ? _ref7 : fallbackPrice) || 0);
|
|
288
334
|
}
|
|
289
335
|
function normalizeDepositProtocols(protocols) {
|
|
290
336
|
if (!Array.isArray(protocols)) return [];
|
|
@@ -333,13 +379,13 @@ function handleOrderProductDeposit(params) {
|
|
|
333
379
|
};
|
|
334
380
|
}
|
|
335
381
|
function resolveOrderProductDepositSource(product, runtimeOrigin) {
|
|
336
|
-
var
|
|
382
|
+
var _ref8, _record$custom_deposi, _ref9, _record$variant;
|
|
337
383
|
var record = product;
|
|
338
384
|
var origin = record._origin || runtimeOrigin || {};
|
|
339
385
|
var originProduct = origin.product || {};
|
|
340
386
|
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, originProduct), origin), record), {}, {
|
|
341
|
-
custom_deposit_data: (
|
|
342
|
-
variant: (
|
|
387
|
+
custom_deposit_data: (_ref8 = (_record$custom_deposi = record.custom_deposit_data) !== null && _record$custom_deposi !== void 0 ? _record$custom_deposi : origin.custom_deposit_data) !== null && _ref8 !== void 0 ? _ref8 : originProduct.custom_deposit_data,
|
|
388
|
+
variant: (_ref9 = (_record$variant = record.variant) !== null && _record$variant !== void 0 ? _record$variant : origin.variant) !== null && _ref9 !== void 0 ? _ref9 : originProduct.variant
|
|
343
389
|
});
|
|
344
390
|
}
|
|
345
391
|
function getOrderProductDeposit(product, runtimeOrigin) {
|
|
@@ -491,12 +537,12 @@ export function isMarkdownBundle(bundle) {
|
|
|
491
537
|
* - markup(加价)/原价子商品:维持 `+(bundle_selling_price ?? price)`,行为不变。
|
|
492
538
|
*/
|
|
493
539
|
export function getBundleSignedUnit(bundle, options) {
|
|
494
|
-
var _options$useOriginal,
|
|
540
|
+
var _options$useOriginal, _ref16, _bundle$original_pric2, _bundle$bundle_sellin;
|
|
495
541
|
if (!bundle || _typeof(bundle) !== 'object') return new Decimal(0);
|
|
496
542
|
var useOriginal = (_options$useOriginal = options === null || options === void 0 ? void 0 : options.useOriginal) !== null && _options$useOriginal !== void 0 ? _options$useOriginal : false;
|
|
497
543
|
if (isMarkdownBundle(bundle)) {
|
|
498
|
-
var
|
|
499
|
-
var catalog = useOriginal ? (
|
|
544
|
+
var _ref10, _ref11, _ref12, _bundle$original_pric, _ref13, _ref14, _ref15, _bundle$custom_price;
|
|
545
|
+
var catalog = useOriginal ? (_ref10 = (_ref11 = (_ref12 = (_bundle$original_pric = bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle.product_price) !== null && _ref12 !== void 0 ? _ref12 : bundle.custom_price) !== null && _ref11 !== void 0 ? _ref11 : bundle.base_price) !== null && _ref10 !== void 0 ? _ref10 : bundle.price : (_ref13 = (_ref14 = (_ref15 = (_bundle$custom_price = bundle.custom_price) !== null && _bundle$custom_price !== void 0 ? _bundle$custom_price : bundle.product_price) !== null && _ref15 !== void 0 ? _ref15 : bundle.original_price) !== null && _ref14 !== void 0 ? _ref14 : bundle.base_price) !== null && _ref13 !== void 0 ? _ref13 : bundle.price;
|
|
500
546
|
if (catalog !== undefined && catalog !== null && catalog !== '') {
|
|
501
547
|
var raw = new Decimal(Number(catalog) || 0);
|
|
502
548
|
// 负值表示价格已是「带符号净额」(如 cart/changePrice 产出的 -3.7),直接取用不再扣 option,
|
|
@@ -507,7 +553,7 @@ export function getBundleSignedUnit(bundle, options) {
|
|
|
507
553
|
// 仅剩净额(无毛价)兜底:直接取负,不再扣 option
|
|
508
554
|
return new Decimal(Number(bundle.bundle_selling_price) || 0).abs().negated();
|
|
509
555
|
}
|
|
510
|
-
var rawPrice = useOriginal ? (
|
|
556
|
+
var rawPrice = useOriginal ? (_ref16 = (_bundle$original_pric2 = bundle.original_price) !== null && _bundle$original_pric2 !== void 0 ? _bundle$original_pric2 : bundle.product_price) !== null && _ref16 !== void 0 ? _ref16 : bundle.price : (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.price;
|
|
511
557
|
return new Decimal(Number(rawPrice) || 0);
|
|
512
558
|
}
|
|
513
559
|
|
|
@@ -725,8 +771,8 @@ export function createDefaultOrderRulesHooks() {
|
|
|
725
771
|
return new Decimal(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
|
|
726
772
|
};
|
|
727
773
|
var getBundleIdentity = function getBundleIdentity(bundle) {
|
|
728
|
-
var
|
|
729
|
-
return [(
|
|
774
|
+
var _ref17, _bundle$bundle_id, _ref18, _ref19, _bundle$bundle_produc, _ref20, _ref21, _bundle$bundle_varian, _ref22, _bundle$bundle_group_;
|
|
775
|
+
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('|');
|
|
730
776
|
};
|
|
731
777
|
var mergeRulesBundlePrices = function mergeRulesBundlePrices(currentBundle, rulesBundle) {
|
|
732
778
|
if (!Array.isArray(rulesBundle)) return rulesBundle;
|
|
@@ -736,7 +782,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
736
782
|
currentByIdentity.set(getBundleIdentity(bundle), bundle);
|
|
737
783
|
});
|
|
738
784
|
return rulesBundle.map(function (bundle) {
|
|
739
|
-
var _bundle$price_type_ex2,
|
|
785
|
+
var _bundle$price_type_ex2, _ref23, _ref24, _current$price, _ref25, _ref26, _ref27, _current$original_pri;
|
|
740
786
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
741
787
|
var current = currentByIdentity.get(getBundleIdentity(bundle));
|
|
742
788
|
if (!current) return bundle;
|
|
@@ -745,8 +791,8 @@ export function createDefaultOrderRulesHooks() {
|
|
|
745
791
|
} : {});
|
|
746
792
|
var isProductPriceBundle = ((_bundle$price_type_ex2 = bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : current.price_type_ext) === 'product_price';
|
|
747
793
|
if (!isProductPriceBundle) return bundleWithDisplayFields;
|
|
748
|
-
var sourcePrice = (
|
|
749
|
-
var originalPrice = (
|
|
794
|
+
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;
|
|
795
|
+
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;
|
|
750
796
|
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, bundleWithDisplayFields), sourcePrice !== undefined ? {
|
|
751
797
|
price: sourcePrice
|
|
752
798
|
} : {}), originalPrice !== undefined ? {
|
|
@@ -810,10 +856,10 @@ export function createDefaultOrderRulesHooks() {
|
|
|
810
856
|
};
|
|
811
857
|
},
|
|
812
858
|
setProduct: function setProduct(product, values) {
|
|
813
|
-
var
|
|
814
|
-
var nextNum = Number((
|
|
859
|
+
var _ref28, _values$quantity, _ref29, _metadataAny$source_p, _values$discount_list, _values$quantity2;
|
|
860
|
+
var nextNum = Number((_ref28 = (_values$quantity = values.quantity) !== null && _values$quantity !== void 0 ? _values$quantity : product.num) !== null && _ref28 !== void 0 ? _ref28 : 1) || 1;
|
|
815
861
|
var metadataAny = product.metadata || {};
|
|
816
|
-
var existedSource = (
|
|
862
|
+
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';
|
|
817
863
|
var nextOptions = getProductSkuOptions(product);
|
|
818
864
|
var optionSum = sumOptionUnitPrice(nextOptions);
|
|
819
865
|
|
|
@@ -1024,7 +1070,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1024
1070
|
var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1025
1071
|
if (!Array.isArray(bundle)) return [];
|
|
1026
1072
|
return bundle.map(function (b) {
|
|
1027
|
-
var
|
|
1073
|
+
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;
|
|
1028
1074
|
var rawBundle = b && _typeof(b) === 'object' ? b : {};
|
|
1029
1075
|
var existedMetadata = rawBundle.metadata && _typeof(rawBundle.metadata) === 'object' ? rawBundle.metadata : {};
|
|
1030
1076
|
var _customProductBundleMapId = existedMetadata.custom_product_bundle_map_id,
|
|
@@ -1035,7 +1081,7 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1035
1081
|
var sellingPrice = formatOptions.virtualSettlementMode ? '0.00' : getBundleSellingMagnitude(rawBundle).toFixed(2);
|
|
1036
1082
|
// payment 价由整单折扣均摊层产出;缺省(无折扣)时与 selling 净额同义。
|
|
1037
1083
|
var paymentPrice = formatOptions.virtualSettlementMode ? '0.00' : rawBundle.bundle_payment_price !== undefined && rawBundle.bundle_payment_price !== null && rawBundle.bundle_payment_price !== '' ? toMoneyString(rawBundle.bundle_payment_price) : sellingPrice;
|
|
1038
|
-
var priceValue = formatOptions.virtualSettlementMode ? 0 : (
|
|
1084
|
+
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;
|
|
1039
1085
|
var relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
|
|
1040
1086
|
var surchargeFee = toMoneyString((_rawBundle$surcharge_ = rawBundle.surcharge_fee) !== null && _rawBundle$surcharge_ !== void 0 ? _rawBundle$surcharge_ : existedMetadata.surcharge_fee);
|
|
1041
1087
|
var productDiscountDifference = toBundleNumber(existedMetadata.product_discount_difference, 0);
|
|
@@ -1054,8 +1100,8 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1054
1100
|
extension_id: (_rawBundle$extension_ = rawBundle.extension_id) !== null && _rawBundle$extension_ !== void 0 ? _rawBundle$extension_ : 0,
|
|
1055
1101
|
extension_type: (_rawBundle$extension_2 = rawBundle.extension_type) !== null && _rawBundle$extension_2 !== void 0 ? _rawBundle$extension_2 : 'normal',
|
|
1056
1102
|
price: priceValue,
|
|
1057
|
-
price_type: (
|
|
1058
|
-
price_type_ext: (
|
|
1103
|
+
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 : '',
|
|
1104
|
+
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 : '',
|
|
1059
1105
|
bundle_selling_price: sellingPrice,
|
|
1060
1106
|
bundle_payment_price: paymentPrice,
|
|
1061
1107
|
option: formatSubmitOptionItems(rawBundle.option, formatOptions),
|
|
@@ -1091,11 +1137,11 @@ function formatSubmitBundleItems(bundle) {
|
|
|
1091
1137
|
* 法币仅做字段/metadata 裁剪;虚拟币在出站前再次执行零加价与固定单价断言。
|
|
1092
1138
|
*/
|
|
1093
1139
|
function normalizeSubmitProduct(product) {
|
|
1094
|
-
var
|
|
1140
|
+
var _ref34, _submitProduct$bundle, _rawMetadata$product_, _rawMetadata$selected, _rawMetadata$selected2, _submitProduct$produc, _submitProduct$paymen;
|
|
1095
1141
|
var formatOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1096
|
-
var
|
|
1097
|
-
_runtimeUid =
|
|
1098
|
-
submitProduct = _objectWithoutProperties(
|
|
1142
|
+
var _ref33 = product,
|
|
1143
|
+
_runtimeUid = _ref33.unique_identification_number,
|
|
1144
|
+
submitProduct = _objectWithoutProperties(_ref33, _excluded2);
|
|
1099
1145
|
var num = submitProduct.num,
|
|
1100
1146
|
_productSurchargeFee = submitProduct.surcharge_fee,
|
|
1101
1147
|
_deprecatedDiscountAmount = submitProduct.discount_amount,
|
|
@@ -1112,7 +1158,7 @@ function normalizeSubmitProduct(product) {
|
|
|
1112
1158
|
// 兼容历史 BigSale 编辑链路:bundle_edit 曾被写入 metadata,
|
|
1113
1159
|
// 出站时需提升到商品顶层;套餐未编辑时也必须显式提交 0。
|
|
1114
1160
|
var hasProductBundle = Array.isArray(submitProduct.product_bundle) && submitProduct.product_bundle.length > 0;
|
|
1115
|
-
var bundleEdit = (
|
|
1161
|
+
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;
|
|
1116
1162
|
var cleanMetadata = {};
|
|
1117
1163
|
if (rawMetadata.unique_identification_number) {
|
|
1118
1164
|
cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
|
|
@@ -1343,7 +1389,7 @@ export function resolveSubmitOrderType(params) {
|
|
|
1343
1389
|
return 'virtual';
|
|
1344
1390
|
}
|
|
1345
1391
|
export function buildSubmitPayload(params) {
|
|
1346
|
-
var _tempOrder$metadata2, _tempOrder$customer_i, _tempOrder$country_ca, _tempOrder$phone, _tempOrder$email, _tempOrder$order_numb, _tempOrder$shop_order, _tempOrder$shop_full_,
|
|
1392
|
+
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;
|
|
1347
1393
|
var tempOrder = params.tempOrder,
|
|
1348
1394
|
cacheId = params.cacheId,
|
|
1349
1395
|
_params$now = params.now,
|
|
@@ -1357,29 +1403,29 @@ export function buildSubmitPayload(params) {
|
|
|
1357
1403
|
var scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
|
|
1358
1404
|
var bookingUuid = createUuidV4();
|
|
1359
1405
|
var virtualSettlementMode = ((_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.currency_settlement_config) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2.settlement_type) === 'virtual_currency';
|
|
1360
|
-
var
|
|
1361
|
-
_extend =
|
|
1362
|
-
_relationId =
|
|
1363
|
-
_tableFormId =
|
|
1364
|
-
_resourceId =
|
|
1365
|
-
_summary =
|
|
1366
|
-
_lastOrderInfo =
|
|
1367
|
-
_paidAmount =
|
|
1368
|
-
_shopId =
|
|
1369
|
-
_shopNote =
|
|
1370
|
-
_shopServiceType =
|
|
1371
|
-
_startTime =
|
|
1372
|
-
_customer =
|
|
1373
|
-
_discountList =
|
|
1374
|
-
_orderMetaList =
|
|
1375
|
-
_rootTaxFee =
|
|
1376
|
-
_totalAmount =
|
|
1377
|
-
_totalRefundAmount =
|
|
1378
|
-
_createDate =
|
|
1379
|
-
_holderId =
|
|
1380
|
-
_paymentStatus =
|
|
1381
|
-
_notes =
|
|
1382
|
-
tempOrderRest = _objectWithoutProperties(
|
|
1406
|
+
var _ref35 = tempOrder,
|
|
1407
|
+
_extend = _ref35._extend,
|
|
1408
|
+
_relationId = _ref35.relation_id,
|
|
1409
|
+
_tableFormId = _ref35.table_form_id,
|
|
1410
|
+
_resourceId = _ref35.resource_id,
|
|
1411
|
+
_summary = _ref35.summary,
|
|
1412
|
+
_lastOrderInfo = _ref35.lastOrderInfo,
|
|
1413
|
+
_paidAmount = _ref35.paid_amount,
|
|
1414
|
+
_shopId = _ref35.shop_id,
|
|
1415
|
+
_shopNote = _ref35.shop_note,
|
|
1416
|
+
_shopServiceType = _ref35.shop_service_type,
|
|
1417
|
+
_startTime = _ref35.start_time,
|
|
1418
|
+
_customer = _ref35.customer,
|
|
1419
|
+
_discountList = _ref35.discount_list,
|
|
1420
|
+
_orderMetaList = _ref35.order_meta_list,
|
|
1421
|
+
_rootTaxFee = _ref35.tax_fee,
|
|
1422
|
+
_totalAmount = _ref35.total_amount,
|
|
1423
|
+
_totalRefundAmount = _ref35.total_refund_amount,
|
|
1424
|
+
_createDate = _ref35.create_date,
|
|
1425
|
+
_holderId = _ref35.holder_id,
|
|
1426
|
+
_paymentStatus = _ref35.payment_status,
|
|
1427
|
+
_notes = _ref35.notes,
|
|
1428
|
+
tempOrderRest = _objectWithoutProperties(_ref35, _excluded4);
|
|
1383
1429
|
var resolvedBusinessCode = businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code;
|
|
1384
1430
|
var normalizedOrderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
|
|
1385
1431
|
var submitType = resolveSubmitOrderType({
|
|
@@ -1404,7 +1450,7 @@ export function buildSubmitPayload(params) {
|
|
|
1404
1450
|
type: submitType,
|
|
1405
1451
|
business_code: resolvedBusinessCode,
|
|
1406
1452
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
1407
|
-
order_sales_channel: (
|
|
1453
|
+
order_sales_channel: (_ref36 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref36 !== void 0 ? _ref36 : 'online_store',
|
|
1408
1454
|
status: tempOrder.status || 'normal'
|
|
1409
1455
|
}, params.includePaymentStatus !== false ? {
|
|
1410
1456
|
payment_status: tempOrder.payment_status || 'payment_processing'
|
|
@@ -1432,13 +1478,13 @@ export function buildSubmitPayload(params) {
|
|
|
1432
1478
|
// holder: tempOrder.holder || null,
|
|
1433
1479
|
summary: summary || tempOrder.summary || createEmptySummary(),
|
|
1434
1480
|
metadata: function () {
|
|
1435
|
-
var
|
|
1436
|
-
_collectPax =
|
|
1437
|
-
_tableOccupancyDuration =
|
|
1438
|
-
_cartSettlementKey =
|
|
1439
|
-
_cartSettlementSnapshot =
|
|
1440
|
-
_legalCurrencySnapshot =
|
|
1441
|
-
rest = _objectWithoutProperties(
|
|
1481
|
+
var _ref37 = tempOrder.metadata || {},
|
|
1482
|
+
_collectPax = _ref37.collect_pax,
|
|
1483
|
+
_tableOccupancyDuration = _ref37.table_occupancy_duration,
|
|
1484
|
+
_cartSettlementKey = _ref37.cart_settlement_key,
|
|
1485
|
+
_cartSettlementSnapshot = _ref37.cart_settlement_snapshot,
|
|
1486
|
+
_legalCurrencySnapshot = _ref37.legal_currency_snapshot,
|
|
1487
|
+
rest = _objectWithoutProperties(_ref37, _excluded5);
|
|
1442
1488
|
return _objectSpread({}, rest);
|
|
1443
1489
|
}()
|
|
1444
1490
|
}, (_tempOrder$_extend = tempOrder._extend) !== null && _tempOrder$_extend !== void 0 && (_tempOrder$_extend = _tempOrder$_extend.salesNotesState) !== null && _tempOrder$_extend !== void 0 && _tempOrder$_extend.dirty ? {
|
|
@@ -1655,8 +1701,8 @@ export function getRuntimeProductOrigin(tempOrder, product) {
|
|
|
1655
1701
|
return tempOrder._extend.productsByUid[uid].origin;
|
|
1656
1702
|
}
|
|
1657
1703
|
var matchedProduct = ((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || []).find(function (item) {
|
|
1658
|
-
var
|
|
1659
|
-
return item === product || getOrderProductLineUid(item) === uid || String((
|
|
1704
|
+
var _ref38, _item$product_id, _ref39, _product$product_id;
|
|
1705
|
+
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 : '');
|
|
1660
1706
|
});
|
|
1661
1707
|
var matchedUid = matchedProduct ? getOrderProductLineUid(matchedProduct) : '';
|
|
1662
1708
|
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;
|