@pisell/pisellos 2.2.261 → 2.2.263
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/dataVariant/adapter.d.ts +50 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
- package/dist/model/strategy/adapter/index.d.ts +4 -0
- package/dist/model/strategy/adapter/index.js +5 -1
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
- package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/dist/model/strategy/adapter/promotion/examples.js +0 -99
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +1 -1
- package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/dist/model/strategy/adapter/promotion/type.js +0 -45
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -10
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
- package/dist/modules/Discount/index.d.ts +5 -2
- package/dist/modules/Discount/index.js +30 -7
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +14 -2
- package/dist/modules/Order/index.js +1035 -736
- package/dist/modules/Order/types.d.ts +16 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
- package/dist/modules/Order/utils.d.ts +4 -3
- package/dist/modules/Order/utils.js +54 -61
- package/dist/modules/Product/types.d.ts +22 -0
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -2
- package/dist/modules/ProductList/types.d.ts +2 -0
- package/dist/modules/Rules/index.d.ts +2 -9
- package/dist/modules/Rules/index.js +69 -43
- package/dist/modules/Rules/types.d.ts +10 -1
- package/dist/server/index.d.ts +55 -0
- package/dist/server/index.js +1173 -753
- package/dist/server/modules/order/index.d.ts +10 -4
- package/dist/server/modules/order/index.js +404 -399
- package/dist/server/modules/order/types.d.ts +4 -0
- package/dist/server/modules/products/index.d.ts +31 -8
- package/dist/server/modules/products/index.js +549 -390
- package/dist/server/modules/products/types.d.ts +18 -0
- package/dist/solution/BaseSales/index.d.ts +21 -1
- package/dist/solution/BaseSales/index.js +1136 -789
- package/dist/solution/BaseSales/types.d.ts +6 -1
- package/dist/solution/BaseSales/types.js +1 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +48 -81
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +59 -25
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/ScanOrder/index.js +20 -31
- package/dist/solution/ShopDiscount/index.js +15 -14
- package/dist/solution/VenueBooking/index.js +19 -30
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
- package/lib/model/strategy/adapter/index.d.ts +4 -0
- package/lib/model/strategy/adapter/index.js +13 -2
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
- package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/lib/model/strategy/adapter/promotion/examples.js +0 -91
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/lib/model/strategy/adapter/promotion/type.js +0 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
- package/lib/modules/Discount/index.d.ts +5 -2
- package/lib/modules/Discount/index.js +23 -3
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +14 -2
- package/lib/modules/Order/index.js +326 -60
- package/lib/modules/Order/types.d.ts +16 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
- package/lib/modules/Order/utils.d.ts +4 -3
- package/lib/modules/Order/utils.js +22 -23
- package/lib/modules/Product/types.d.ts +22 -0
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +4 -2
- package/lib/modules/ProductList/types.d.ts +2 -0
- package/lib/modules/Rules/index.d.ts +2 -9
- package/lib/modules/Rules/index.js +61 -29
- package/lib/modules/Rules/types.d.ts +10 -1
- package/lib/server/index.d.ts +55 -0
- package/lib/server/index.js +332 -34
- package/lib/server/modules/order/index.d.ts +10 -4
- package/lib/server/modules/order/index.js +198 -139
- package/lib/server/modules/order/types.d.ts +4 -0
- package/lib/server/modules/products/index.d.ts +31 -8
- package/lib/server/modules/products/index.js +134 -35
- package/lib/server/modules/products/types.d.ts +18 -0
- package/lib/solution/BaseSales/index.d.ts +21 -1
- package/lib/solution/BaseSales/index.js +313 -72
- package/lib/solution/BaseSales/types.d.ts +6 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +29 -60
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +33 -8
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/ScanOrder/index.js +0 -8
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/lib/solution/VenueBooking/index.js +0 -8
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Discount } from '../../modules/Discount/types';
|
|
1
2
|
import { OrderModule, ProductList, QuotationModule, SalesSummaryModule, ScanOrderLoggerModule as BaseSalesLoggerModule, ScheduleModule } from '../../modules';
|
|
2
3
|
import type { ScanOrderLogInput as BaseSalesLogInput, ScanOrderLoggerProviderConfig as BaseSalesLoggerProviderConfig, ScanOrderLoggerProviderType as BaseSalesLoggerProviderType } from '../../modules/ScanOrderLogger/types';
|
|
3
4
|
import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
@@ -85,6 +86,8 @@ export interface BaseSalesOrderProduct extends BaseSalesOrderProductIdentity {
|
|
|
85
86
|
booking_uid?: string;
|
|
86
87
|
/** 多语言商品标题快照,随 tempOrder 提交到 checkout。 */
|
|
87
88
|
product_title?: BaseSalesLocalizedText;
|
|
89
|
+
/** 商品封面图快照,随 tempOrder 提交到 checkout。 */
|
|
90
|
+
product_cover?: string;
|
|
88
91
|
/**
|
|
89
92
|
* 行级扩展 metadata。价格相关的权威字段:
|
|
90
93
|
*
|
|
@@ -381,9 +384,11 @@ export interface BaseSalesLoggerRuntimeConfig {
|
|
|
381
384
|
}
|
|
382
385
|
export interface BaseSalesAddLogParams extends BaseSalesLogInput {
|
|
383
386
|
}
|
|
384
|
-
/** BaseSales.scanPromotionCode
|
|
387
|
+
/** BaseSales.scanPromotionCode 对外的轻量结果(UI 可用 getDiscountList 或 scannedDiscountList 补 Holder) */
|
|
385
388
|
export interface BaseSalesScanCodeResult {
|
|
386
389
|
isAvailable: boolean;
|
|
387
390
|
type?: 'server' | string;
|
|
388
391
|
unavailableReason?: 'time_limit' | string;
|
|
392
|
+
/** batchSearch 原始结果;isAvailable=false 时 discountList 可能未写入 store,Holder 补全需读此字段 */
|
|
393
|
+
scannedDiscountList?: Discount[];
|
|
389
394
|
}
|
|
@@ -37,4 +37,4 @@ export function createBaseSalesHook(moduleName, hookName) {
|
|
|
37
37
|
|
|
38
38
|
/** `/order/resource/occupy-detail` 单条 `occupy_details[i]` */
|
|
39
39
|
|
|
40
|
-
/** BaseSales.scanPromotionCode
|
|
40
|
+
/** BaseSales.scanPromotionCode 对外的轻量结果(UI 可用 getDiscountList 或 scannedDiscountList 补 Holder) */
|
|
@@ -78,7 +78,6 @@ export interface CartPromotionEvaluator {
|
|
|
78
78
|
}>;
|
|
79
79
|
hasApplicableStrategy: boolean;
|
|
80
80
|
}>;
|
|
81
|
-
getStrategyConfigs?: () => unknown[];
|
|
82
81
|
}
|
|
83
82
|
/** 单个赠品减量项 */
|
|
84
83
|
export interface GiftReduceItem {
|
|
@@ -268,8 +267,7 @@ export declare function appendPromotionTags<T extends Record<string, any>>(produ
|
|
|
268
267
|
* 处理购物车的促销计算与赠品差异化。
|
|
269
268
|
*
|
|
270
269
|
* 流程:
|
|
271
|
-
* 1. 分离 main / gift / edit-product
|
|
272
|
-
* 配置 ITEM_REWARD 时,编辑态商品也参与商品奖励重算)
|
|
270
|
+
* 1. 分离 main / gift / edit-product 三类(带 `booking_id` 的编辑态商品不参与促销)
|
|
273
271
|
* 2. 转 PromotionProduct 喂评估器 → 拿到 `evaluateCartWithPricing` 与 `getProductsApplicableStrategies`
|
|
274
272
|
* 3. 把 PricedProduct 映射回 OrderProduct 形态:
|
|
275
273
|
* - 参与促销的,写 `metadata._promotion` + 调整 `selling_price` / `main_product_selling_price`
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
var _excluded = ["_promotionTags"];
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
|
+
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); }
|
|
4
9
|
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); }
|
|
5
10
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
11
|
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."); }
|
|
7
12
|
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; } }
|
|
8
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
14
|
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; } } }; }
|
|
10
|
-
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; }
|
|
11
|
-
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; }
|
|
12
|
-
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; }
|
|
13
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
-
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); }
|
|
15
15
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
16
16
|
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."); }
|
|
17
17
|
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); }
|
|
@@ -116,35 +116,24 @@ export function getOrderProductOriginalPriceForPromotion(product) {
|
|
|
116
116
|
}
|
|
117
117
|
return getOrderProductBasePrice(product);
|
|
118
118
|
}
|
|
119
|
-
var X_ITEMS_FOR_Y_PRICE = 'X_ITEMS_FOR_Y_PRICE';
|
|
120
|
-
var BUY_X_GET_Y_FREE = 'BUY_X_GET_Y_FREE';
|
|
121
|
-
var ITEM_REWARD = 'ITEM_REWARD';
|
|
122
|
-
function isManagedPromotionDiscountItem(item) {
|
|
123
|
-
var _item$metadata, _item$metadata2;
|
|
124
|
-
if ((item === null || item === void 0 ? void 0 : item.type) === 'promotion') return true;
|
|
125
|
-
return (item === null || item === void 0 ? void 0 : item.type) === 'product' && (item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.source) === 'promotion' && (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.actionType) === ITEM_REWARD;
|
|
126
|
-
}
|
|
127
119
|
|
|
128
120
|
/**
|
|
129
|
-
* 写入/清除促销 discount_list
|
|
121
|
+
* 写入/清除促销 discount_list(type=promotion)。
|
|
130
122
|
*
|
|
131
123
|
* applyDiscount → applyProductDiscountPrices 会从 source_product_price 减去 discount_list 合计
|
|
132
124
|
* 重算 main_product_selling_price;保留券前 source 时必须同步写入促销差额,否则会还原成原价。
|
|
133
125
|
*
|
|
134
|
-
* ITEM_REWARD 使用 type=product,复用商品级折扣排他规则,避免客户折扣继续叠加到奖励商品行。
|
|
135
|
-
*
|
|
136
126
|
* @example
|
|
137
127
|
* updatePromotionDiscountList(line, { title: '2 items for $10', amount: '17.00', original_amount: '22.00', fixed_amount: '17.00' });
|
|
138
128
|
*/
|
|
139
|
-
function updatePromotionDiscountList(item, promotionDiscount
|
|
129
|
+
function updatePromotionDiscountList(item, promotionDiscount) {
|
|
140
130
|
var discountList = Array.isArray(item.discount_list) ? _toConsumableArray(item.discount_list) : [];
|
|
141
131
|
discountList = discountList.filter(function (d) {
|
|
142
|
-
return
|
|
132
|
+
return (d === null || d === void 0 ? void 0 : d.type) !== 'promotion';
|
|
143
133
|
});
|
|
144
134
|
if (promotionDiscount) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
type: discountType,
|
|
135
|
+
discountList.push({
|
|
136
|
+
type: 'promotion',
|
|
148
137
|
amount: promotionDiscount.amount,
|
|
149
138
|
discount: {
|
|
150
139
|
original_amount: promotionDiscount.original_amount,
|
|
@@ -152,12 +141,7 @@ function updatePromotionDiscountList(item, promotionDiscount, options) {
|
|
|
152
141
|
title: promotionDiscount.title,
|
|
153
142
|
resource_id: ''
|
|
154
143
|
}
|
|
155
|
-
}
|
|
156
|
-
metadata: {
|
|
157
|
-
source: 'promotion',
|
|
158
|
-
actionType: (options === null || options === void 0 ? void 0 : options.actionType) || ITEM_REWARD
|
|
159
|
-
}
|
|
160
|
-
} : {}));
|
|
144
|
+
});
|
|
161
145
|
}
|
|
162
146
|
if (discountList.length > 0) {
|
|
163
147
|
item.discount_list = discountList;
|
|
@@ -165,19 +149,11 @@ function updatePromotionDiscountList(item, promotionDiscount, options) {
|
|
|
165
149
|
delete item.discount_list;
|
|
166
150
|
}
|
|
167
151
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
var configs = evaluator === null || evaluator === void 0 || (_evaluator$getStrateg = evaluator.getStrategyConfigs) === null || _evaluator$getStrateg === void 0 ? void 0 : _evaluator$getStrateg.call(evaluator);
|
|
171
|
-
if (!Array.isArray(configs)) return false;
|
|
172
|
-
return configs.some(function (config) {
|
|
173
|
-
return ((config === null || config === void 0 ? void 0 : config.actions) || []).some(function (action) {
|
|
174
|
-
return (action === null || action === void 0 ? void 0 : action.type) === actionType;
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
}
|
|
152
|
+
var X_ITEMS_FOR_Y_PRICE = 'X_ITEMS_FOR_Y_PRICE';
|
|
153
|
+
var BUY_X_GET_Y_FREE = 'BUY_X_GET_Y_FREE';
|
|
178
154
|
|
|
179
155
|
/**
|
|
180
|
-
* 将促销单价写入 OrderProduct(含 metadata 三字段 +
|
|
156
|
+
* 将促销单价写入 OrderProduct(含 metadata 三字段 + promotion discount_list)。
|
|
181
157
|
*
|
|
182
158
|
* @example
|
|
183
159
|
* applyPromoUnitPriceToLine(newItem, { promoUnitPrice: '5.00', originalBasePrice: 1, strategyTitle: '2 for 10' });
|
|
@@ -208,9 +184,6 @@ function applyPromoUnitPriceToLine(item, input) {
|
|
|
208
184
|
amount: discountAmount,
|
|
209
185
|
original_amount: catalogSource,
|
|
210
186
|
fixed_amount: discountAmount
|
|
211
|
-
}, {
|
|
212
|
-
actionType: input.actionType,
|
|
213
|
-
discountType: input.actionType === ITEM_REWARD ? 'product' : 'promotion'
|
|
214
187
|
});
|
|
215
188
|
} else {
|
|
216
189
|
updatePromotionDiscountList(item, null);
|
|
@@ -272,9 +245,10 @@ export function mergeIdenticalPromotionCartLines(products) {
|
|
|
272
245
|
var unitPrice = String((_ref2 = (_line$metadata$source = (_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.source_product_price) !== null && _line$metadata$source !== void 0 ? _line$metadata$source : line.selling_price) !== null && _ref2 !== void 0 ? _ref2 : '');
|
|
273
246
|
var promoUnitPrice = String((_ref3 = (_promotion$finalPrice = promotion.finalPrice) !== null && _promotion$finalPrice !== void 0 ? _promotion$finalPrice : (_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.main_product_selling_price) !== null && _ref3 !== void 0 ? _ref3 : '');
|
|
274
247
|
var noteSignature = getProductLineNoteSignature(line);
|
|
248
|
+
var lineMergeBoundary = getPromotionLineMergeBoundary(line);
|
|
275
249
|
var bookingUid = (_line$booking_uid = line === null || line === void 0 ? void 0 : line.booking_uid) !== null && _line$booking_uid !== void 0 ? _line$booking_uid : line === null || line === void 0 || (_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.booking_uid;
|
|
276
250
|
var orderDetailId = (_line$order_detail_id = line === null || line === void 0 ? void 0 : line.order_detail_id) !== null && _line$order_detail_id !== void 0 ? _line$order_detail_id : line === null || line === void 0 ? void 0 : line.orderDetailId;
|
|
277
|
-
var mergeKey = [line.product_id, (_line$product_variant = line.product_variant_id) !== null && _line$product_variant !== void 0 ? _line$product_variant : 0, fingerprint, noteSignature, bookingUid ? String(bookingUid) : '', orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '' ? String(orderDetailId) : '', promotion.strategyId, unitPrice, promoUnitPrice].join('#');
|
|
251
|
+
var mergeKey = [line.product_id, (_line$product_variant = line.product_variant_id) !== null && _line$product_variant !== void 0 ? _line$product_variant : 0, fingerprint, noteSignature, lineMergeBoundary, bookingUid ? String(bookingUid) : '', orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '' ? String(orderDetailId) : '', promotion.strategyId, unitPrice, promoUnitPrice].join('#');
|
|
278
252
|
var hitIndex = indexByKey.get(mergeKey);
|
|
279
253
|
if (hitIndex === undefined) {
|
|
280
254
|
indexByKey.set(mergeKey, merged.length);
|
|
@@ -450,6 +424,16 @@ function getProductLineNoteSignature(product) {
|
|
|
450
424
|
var uid = getOrderProductUid(product);
|
|
451
425
|
return uid ? "note:".concat(uid) : "note:".concat(normalizedNote);
|
|
452
426
|
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* 编辑订单时,历史行仍参与整车促销评估,但不能与本次新增行合并。
|
|
430
|
+
* 以历史行 uid 作为促销前后的行边界;新增行返回空边界,仍保留原有合并语义。
|
|
431
|
+
*/
|
|
432
|
+
function getPromotionLineMergeBoundary(product) {
|
|
433
|
+
var _product$metadata3;
|
|
434
|
+
if ((product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.is_edit_for_runtime) !== true) return '';
|
|
435
|
+
return "edit:".concat(getOrderProductUid(product));
|
|
436
|
+
}
|
|
453
437
|
function isPersistedGeneratedVoucher(product) {
|
|
454
438
|
var _product$order_detail;
|
|
455
439
|
var orderDetailId = (_product$order_detail = product === null || product === void 0 ? void 0 : product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : product === null || product === void 0 ? void 0 : product.orderDetailId;
|
|
@@ -487,20 +471,21 @@ function getProductBundleForEvaluator(product) {
|
|
|
487
471
|
* // => 单行 num=4,清除 _promotion 后重新评估
|
|
488
472
|
*/
|
|
489
473
|
export function buildConsolidateKeyForPromotion(item) {
|
|
490
|
-
var _item$booking_uid, _item$
|
|
474
|
+
var _item$booking_uid, _item$metadata, _item$order_detail_id, _item$product_variant3;
|
|
491
475
|
var fingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
492
476
|
var noteSignature = getProductLineNoteSignature(item);
|
|
493
|
-
var
|
|
477
|
+
var lineMergeBoundary = getPromotionLineMergeBoundary(item);
|
|
478
|
+
var bookingUid = (_item$booking_uid = item === null || item === void 0 ? void 0 : item.booking_uid) !== null && _item$booking_uid !== void 0 ? _item$booking_uid : item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.booking_uid;
|
|
494
479
|
var orderDetailId = (_item$order_detail_id = item === null || item === void 0 ? void 0 : item.order_detail_id) !== null && _item$order_detail_id !== void 0 ? _item$order_detail_id : item === null || item === void 0 ? void 0 : item.orderDetailId;
|
|
495
480
|
if (orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '') {
|
|
496
481
|
var _item$product_variant;
|
|
497
|
-
return [item.product_id, (_item$product_variant = item.product_variant_id) !== null && _item$product_variant !== void 0 ? _item$product_variant : 0, fingerprint, noteSignature, String(orderDetailId)].join('#');
|
|
482
|
+
return [item.product_id, (_item$product_variant = item.product_variant_id) !== null && _item$product_variant !== void 0 ? _item$product_variant : 0, fingerprint, noteSignature, lineMergeBoundary, String(orderDetailId)].join('#');
|
|
498
483
|
}
|
|
499
484
|
if (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '') {
|
|
500
485
|
var _item$product_variant2;
|
|
501
|
-
return [item.product_id, (_item$product_variant2 = item.product_variant_id) !== null && _item$product_variant2 !== void 0 ? _item$product_variant2 : 0, fingerprint, noteSignature, String(bookingUid)].join('#');
|
|
486
|
+
return [item.product_id, (_item$product_variant2 = item.product_variant_id) !== null && _item$product_variant2 !== void 0 ? _item$product_variant2 : 0, fingerprint, noteSignature, lineMergeBoundary, String(bookingUid)].join('#');
|
|
502
487
|
}
|
|
503
|
-
return [item.product_id, (_item$product_variant3 = item.product_variant_id) !== null && _item$product_variant3 !== void 0 ? _item$product_variant3 : 0, fingerprint, noteSignature].join('#');
|
|
488
|
+
return [item.product_id, (_item$product_variant3 = item.product_variant_id) !== null && _item$product_variant3 !== void 0 ? _item$product_variant3 : 0, fingerprint, noteSignature, lineMergeBoundary].join('#');
|
|
504
489
|
}
|
|
505
490
|
function consolidateMainProductsForPromotion(entries) {
|
|
506
491
|
if (!Array.isArray(entries) || entries.length <= 1) {
|
|
@@ -511,12 +496,12 @@ function consolidateMainProductsForPromotion(entries) {
|
|
|
511
496
|
_step5;
|
|
512
497
|
try {
|
|
513
498
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
514
|
-
var _item$
|
|
499
|
+
var _item$metadata2;
|
|
515
500
|
var _step5$value = _step5.value,
|
|
516
501
|
item = _step5$value.item,
|
|
517
502
|
originalListIndex = _step5$value.originalListIndex;
|
|
518
503
|
var key = buildConsolidateKeyForPromotion(item);
|
|
519
|
-
var wasInPromotion = (item === null || item === void 0 || (_item$
|
|
504
|
+
var wasInPromotion = (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 || (_item$metadata2 = _item$metadata2._promotion) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.inPromotion) === true;
|
|
520
505
|
var existing = groups.get(key);
|
|
521
506
|
if (!existing) {
|
|
522
507
|
var mergedItem = cloneDeep(item);
|
|
@@ -613,9 +598,6 @@ function splitXItemsPromoLinesByGroup(lines, strategyActionMap) {
|
|
|
613
598
|
function generateNumericId() {
|
|
614
599
|
return Math.floor(Math.random() * 1000000000) + Date.now();
|
|
615
600
|
}
|
|
616
|
-
function isBookingEditProductLine(product) {
|
|
617
|
-
return (product === null || product === void 0 ? void 0 : product.booking_id) !== undefined && (product === null || product === void 0 ? void 0 : product.booking_id) !== null && product.booking_id !== 0 && product.booking_id !== '0';
|
|
618
|
-
}
|
|
619
601
|
|
|
620
602
|
/**
|
|
621
603
|
* 把 OrderProduct 转成 evaluator 的 PromotionProduct(仅评估期使用)。
|
|
@@ -636,7 +618,6 @@ function convertToPromotionProduct(product, index) {
|
|
|
636
618
|
price: getOrderProductOriginalPriceForPromotion(product),
|
|
637
619
|
quantity: Number((_product$num = product === null || product === void 0 ? void 0 : product.num) !== null && _product$num !== void 0 ? _product$num : 1) || 1,
|
|
638
620
|
bundle: getProductBundleForEvaluator(product),
|
|
639
|
-
_promotionOnlyForItemReward: isBookingEditProductLine(product),
|
|
640
621
|
_originalItem: originalItem,
|
|
641
622
|
_originalId: getOrderProductUid(product),
|
|
642
623
|
_originalIndex: index
|
|
@@ -844,9 +825,6 @@ export function resolveStrategyRequiredQuantity(matched) {
|
|
|
844
825
|
if (matched.actionType === 'BUY_X_GET_Y_FREE') {
|
|
845
826
|
return Number(detail.buyQuantity) || 1;
|
|
846
827
|
}
|
|
847
|
-
if (matched.actionType === 'ITEM_REWARD') {
|
|
848
|
-
return Number(detail.triggerQuantity) || 1;
|
|
849
|
-
}
|
|
850
828
|
return 1;
|
|
851
829
|
}
|
|
852
830
|
|
|
@@ -872,13 +850,13 @@ export function resolveStrategyEligibleProducts(matched) {
|
|
|
872
850
|
export function calculateUnfulfilledPromotions(processedProducts, applicableStrategiesResult, mainProducts) {
|
|
873
851
|
var unfulfilledMap = new Map();
|
|
874
852
|
var _loop2 = function _loop2() {
|
|
875
|
-
var _product$
|
|
853
|
+
var _product$metadata4, _ref13, _product$_originalPro, _product$metadata5, _product$num2;
|
|
876
854
|
var product = processedProducts[i];
|
|
877
|
-
var promotion = product === null || product === void 0 || (_product$
|
|
855
|
+
var promotion = product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4._promotion;
|
|
878
856
|
if (!promotion || promotion.inPromotion !== false) return 0; // continue
|
|
879
857
|
var strategyId = promotion.strategyId;
|
|
880
858
|
if (!strategyId) return 0; // continue
|
|
881
|
-
var lookupUid = String((_ref13 = (_product$_originalPro = product === null || product === void 0 ? void 0 : product._originalProductUid) !== null && _product$_originalPro !== void 0 ? _product$_originalPro : product === null || product === void 0 || (_product$
|
|
859
|
+
var lookupUid = String((_ref13 = (_product$_originalPro = product === null || product === void 0 ? void 0 : product._originalProductUid) !== null && _product$_originalPro !== void 0 ? _product$_originalPro : product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) !== null && _ref13 !== void 0 ? _ref13 : '');
|
|
882
860
|
var originalIndex = mainProducts.findIndex(function (item) {
|
|
883
861
|
return getOrderProductUid(item) === lookupUid;
|
|
884
862
|
});
|
|
@@ -1006,8 +984,7 @@ export function appendPromotionTags(products, evaluator) {
|
|
|
1006
984
|
* 处理购物车的促销计算与赠品差异化。
|
|
1007
985
|
*
|
|
1008
986
|
* 流程:
|
|
1009
|
-
* 1. 分离 main / gift / edit-product
|
|
1010
|
-
* 配置 ITEM_REWARD 时,编辑态商品也参与商品奖励重算)
|
|
987
|
+
* 1. 分离 main / gift / edit-product 三类(带 `booking_id` 的编辑态商品不参与促销)
|
|
1011
988
|
* 2. 转 PromotionProduct 喂评估器 → 拿到 `evaluateCartWithPricing` 与 `getProductsApplicableStrategies`
|
|
1012
989
|
* 3. 把 PricedProduct 映射回 OrderProduct 形态:
|
|
1013
990
|
* - 参与促销的,写 `metadata._promotion` + 调整 `selling_price` / `main_product_selling_price`
|
|
@@ -1037,7 +1014,6 @@ export function processCartPromotion(list, evaluator, options) {
|
|
|
1037
1014
|
if (!list || list.length === 0 || !evaluator) return empty;
|
|
1038
1015
|
|
|
1039
1016
|
// 0. 分类
|
|
1040
|
-
var shouldIncludeEditProductsForItemReward = evaluatorHasActionType(evaluator, ITEM_REWARD);
|
|
1041
1017
|
var mainProductsWithIndex = [];
|
|
1042
1018
|
var existingGiftsWithIndex = [];
|
|
1043
1019
|
var editProductsWithIndex = [];
|
|
@@ -1054,18 +1030,11 @@ export function processCartPromotion(list, evaluator, options) {
|
|
|
1054
1030
|
item: item,
|
|
1055
1031
|
originalListIndex: i
|
|
1056
1032
|
});
|
|
1057
|
-
} else if (
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
});
|
|
1063
|
-
} else {
|
|
1064
|
-
editProductsWithIndex.push({
|
|
1065
|
-
item: item,
|
|
1066
|
-
originalListIndex: i
|
|
1067
|
-
});
|
|
1068
|
-
}
|
|
1033
|
+
} else if ((item === null || item === void 0 ? void 0 : item.booking_id) !== undefined && (item === null || item === void 0 ? void 0 : item.booking_id) !== null && item.booking_id !== 0 && item.booking_id !== '0') {
|
|
1034
|
+
editProductsWithIndex.push({
|
|
1035
|
+
item: item,
|
|
1036
|
+
originalListIndex: i
|
|
1037
|
+
});
|
|
1069
1038
|
} else {
|
|
1070
1039
|
mainProductsWithIndex.push({
|
|
1071
1040
|
item: item,
|
|
@@ -1120,17 +1089,16 @@ export function processCartPromotion(list, evaluator, options) {
|
|
|
1120
1089
|
var promotionProducts = [];
|
|
1121
1090
|
var originalItemMap = new Map();
|
|
1122
1091
|
var productsForStrategies = consolidatedMainProductsWithIndex.map(function (_ref16, i) {
|
|
1123
|
-
var _item$product_id, _item$product_variant5, _item$
|
|
1092
|
+
var _item$product_id, _item$product_variant5, _item$metadata3, _item$num;
|
|
1124
1093
|
var item = _ref16.item;
|
|
1125
1094
|
return {
|
|
1126
1095
|
id: i,
|
|
1127
1096
|
product_id: Number((_item$product_id = item === null || item === void 0 ? void 0 : item.product_id) !== null && _item$product_id !== void 0 ? _item$product_id : 0) || 0,
|
|
1128
1097
|
product_variant_id: Number((_item$product_variant5 = item === null || item === void 0 ? void 0 : item.product_variant_id) !== null && _item$product_variant5 !== void 0 ? _item$product_variant5 : 0) || 0,
|
|
1129
|
-
name: (item === null || item === void 0 || (_item$
|
|
1098
|
+
name: (item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.product_name) || (item === null || item === void 0 ? void 0 : item.title) || '',
|
|
1130
1099
|
price: getOrderProductBasePrice(item),
|
|
1131
1100
|
quantity: Number((_item$num = item === null || item === void 0 ? void 0 : item.num) !== null && _item$num !== void 0 ? _item$num : 1) || 1,
|
|
1132
|
-
bundle: getProductBundleForEvaluator(item)
|
|
1133
|
-
_promotionOnlyForItemReward: isBookingEditProductLine(item)
|
|
1101
|
+
bundle: getProductBundleForEvaluator(item)
|
|
1134
1102
|
};
|
|
1135
1103
|
});
|
|
1136
1104
|
for (var _i = 0; _i < consolidatedMainProductsWithIndex.length; _i++) {
|
|
@@ -1278,13 +1246,12 @@ export function processCartPromotion(list, evaluator, options) {
|
|
|
1278
1246
|
var priceUnchangedPromo = _priced.inPromotion && Number(_priced.finalPrice) === Number(originalBasePrice);
|
|
1279
1247
|
if (shouldModifyPrice) {
|
|
1280
1248
|
if (_priced.inPromotion && !priceUnchangedPromo) {
|
|
1281
|
-
var _priced$strategyMetad
|
|
1249
|
+
var _priced$strategyMetad;
|
|
1282
1250
|
var promoUnitPrice = new Decimal(_priced.finalPrice).toDecimalPlaces(2).toFixed(2);
|
|
1283
1251
|
applyPromoUnitPriceToLine(newItem, {
|
|
1284
1252
|
promoUnitPrice: promoUnitPrice,
|
|
1285
1253
|
originalBasePrice: originalBasePrice,
|
|
1286
|
-
strategyTitle: (_priced$strategyMetad = _priced.strategyMetadata) === null || _priced$strategyMetad === void 0 ? void 0 : _priced$strategyMetad.name
|
|
1287
|
-
actionType: _priced.strategyId ? (_strategyActionMap$ge = strategyActionMap.get(_priced.strategyId)) === null || _strategyActionMap$ge === void 0 ? void 0 : _strategyActionMap$ge.actionType : undefined
|
|
1254
|
+
strategyTitle: (_priced$strategyMetad = _priced.strategyMetadata) === null || _priced$strategyMetad === void 0 ? void 0 : _priced$strategyMetad.name
|
|
1288
1255
|
});
|
|
1289
1256
|
} else {
|
|
1290
1257
|
// 撤销上一轮促销:还原 selling_price 到 main_product_original_price 派生值
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* 把 `/order/sales/{id}` 响应(OrderData)解析为 ISalesDetail。
|
|
3
3
|
*
|
|
4
4
|
* - 纯函数:不依赖任何运行时模块/插件,便于单测与 view-model 适配
|
|
5
|
-
* - products 保留 tempOrder /
|
|
5
|
+
* - products 保留 tempOrder / 后端详情原字段,仅规范化集合身份并浅拷贝,避免丢失 product_sku 等协议字段
|
|
6
6
|
* - bookings 平铺保留服务端原顺序,同时输出 byProductUid 反查表与 rootBooking
|
|
7
7
|
* - header 收敛"非数组顶层字段",便于 ticketBooking view-model 直接消费
|
|
8
8
|
*
|
|
@@ -130,7 +130,7 @@ export interface ISalesDetail {
|
|
|
130
130
|
customer: ISalesDetailCustomer | null;
|
|
131
131
|
/** 服务端 summary(仅输出) */
|
|
132
132
|
summary: Record<string, any>;
|
|
133
|
-
/**
|
|
133
|
+
/** 规范化后的响应快照,方便 UI 兜底使用 */
|
|
134
134
|
raw: Record<string, any>;
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
@@ -138,7 +138,7 @@ export interface ISalesDetail {
|
|
|
138
138
|
*
|
|
139
139
|
* 注意:
|
|
140
140
|
* - 入参允许是 `{ data: OrderData }` 或直接 `OrderData`,自动识别。
|
|
141
|
-
* - products
|
|
141
|
+
* - products/bookings/payments 在此补齐集合身份;其余 runtime 字段由 OrderModule hydrate 负责。
|
|
142
142
|
* - 不做远程请求;不修改入参;返回新对象。
|
|
143
143
|
*/
|
|
144
144
|
export declare function parseSalesResponse(input: Record<string, any> | null | undefined): ISalesDetail;
|
|
@@ -11,7 +11,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
11
11
|
* 把 `/order/sales/{id}` 响应(OrderData)解析为 ISalesDetail。
|
|
12
12
|
*
|
|
13
13
|
* - 纯函数:不依赖任何运行时模块/插件,便于单测与 view-model 适配
|
|
14
|
-
* - products 保留 tempOrder /
|
|
14
|
+
* - products 保留 tempOrder / 后端详情原字段,仅规范化集合身份并浅拷贝,避免丢失 product_sku 等协议字段
|
|
15
15
|
* - bookings 平铺保留服务端原顺序,同时输出 byProductUid 反查表与 rootBooking
|
|
16
16
|
* - header 收敛"非数组顶层字段",便于 ticketBooking view-model 直接消费
|
|
17
17
|
*
|
|
@@ -23,6 +23,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
23
23
|
* - 不在此处发明等价关系;UI 侧(ticketBooking)若需要别的字段,由 view-model 适配层做转换
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
+
import { normalizeOrderCollections } from "../../../modules/Order/utils/orderCollectionIdentity";
|
|
26
27
|
/** OrderData 中除大数组外的"顶层 header 字段"白名单,按需扩展。 */
|
|
27
28
|
var HEADER_KEYS = ['order_id', 'order_number', 'shop_order_number', 'shop_full_order_number', 'type', 'business_code', 'platform', 'sales_channel', 'order_sales_channel', 'vouchers', 'status', 'payment_status', 'shipping_status', 'customer_id', 'customer_name', 'country_calling_code', 'phone', 'email', 'is_price_include_tax', 'tax_title', 'tax_country_code', 'currency_code', 'currency_symbol', 'currency_format', 'is_deposit', 'deposit_amount', 'shop_discount', 'surcharge_fee', 'note', 'schedule_date', 'created_at', 'updated_at', 'metadata', 'total_amount', 'shop_id', 'create_date', 'holder', 'relation_forms', 'contacts', 'contacts_info'];
|
|
28
29
|
function pickHeader(raw) {
|
|
@@ -108,19 +109,16 @@ function indexBookingsByProductUid(bookings) {
|
|
|
108
109
|
*
|
|
109
110
|
* 注意:
|
|
110
111
|
* - 入参允许是 `{ data: OrderData }` 或直接 `OrderData`,自动识别。
|
|
111
|
-
* - products
|
|
112
|
+
* - products/bookings/payments 在此补齐集合身份;其余 runtime 字段由 OrderModule hydrate 负责。
|
|
112
113
|
* - 不做远程请求;不修改入参;返回新对象。
|
|
113
114
|
*/
|
|
114
115
|
export function parseSalesResponse(input) {
|
|
115
|
-
var
|
|
116
|
+
var sourceRaw = input && _typeof(input) === 'object' && input.data && input.order_id == null ? input.data : input || {};
|
|
117
|
+
var raw = normalizeOrderCollections(sourceRaw).order;
|
|
116
118
|
var productsRaw = Array.isArray(raw === null || raw === void 0 ? void 0 : raw.products) ? raw.products : [];
|
|
117
|
-
var products = productsRaw.map(function (p
|
|
119
|
+
var products = productsRaw.map(function (p) {
|
|
118
120
|
var row = _objectSpread({}, p || {});
|
|
119
121
|
var metadata = row.metadata && _typeof(row.metadata) === 'object' ? _objectSpread({}, row.metadata) : {};
|
|
120
|
-
if (!metadata.unique_identification_number) {
|
|
121
|
-
var _row$product_id, _row$product_variant_;
|
|
122
|
-
metadata.unique_identification_number = "sales-product-".concat((_row$product_id = row.product_id) !== null && _row$product_id !== void 0 ? _row$product_id : 'unknown', "-").concat((_row$product_variant_ = row.product_variant_id) !== null && _row$product_variant_ !== void 0 ? _row$product_variant_ : 0, "-").concat(index);
|
|
123
|
-
}
|
|
124
122
|
delete metadata.price_schema_version;
|
|
125
123
|
delete row.identity_key;
|
|
126
124
|
return _objectSpread(_objectSpread({}, row), {}, {
|
|
@@ -30,6 +30,17 @@ function toPriceString(value) {
|
|
|
30
30
|
if (!Number.isFinite(parsedValue)) return fallback;
|
|
31
31
|
return parsedValue.toFixed(2);
|
|
32
32
|
}
|
|
33
|
+
function isBlankValue(value) {
|
|
34
|
+
return value === undefined || value === null || typeof value === 'string' && value.trim() === '';
|
|
35
|
+
}
|
|
36
|
+
function firstNonBlank() {
|
|
37
|
+
for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
38
|
+
values[_key] = arguments[_key];
|
|
39
|
+
}
|
|
40
|
+
return values.find(function (value) {
|
|
41
|
+
return !isBlankValue(value);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
33
44
|
function normalizeOptionItems(optionItems) {
|
|
34
45
|
if (!Array.isArray(optionItems)) return [];
|
|
35
46
|
return optionItems.map(function (optionItem) {
|
|
@@ -166,7 +177,8 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
166
177
|
source_product_price: sourceProductPrice,
|
|
167
178
|
main_product_selling_price: mainProductSellingPrice,
|
|
168
179
|
main_product_original_price: mainProductOriginalPrice,
|
|
169
|
-
price_schema_version: 2
|
|
180
|
+
price_schema_version: 2,
|
|
181
|
+
holder_config: sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.holder_config
|
|
170
182
|
}, hasPriceOverride ? {
|
|
171
183
|
price_override: String(payload.price_override),
|
|
172
184
|
is_manual_discount: 1
|
|
@@ -198,6 +210,7 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
198
210
|
metadata: metadata,
|
|
199
211
|
note: payload.note != null ? String(payload.note) : '',
|
|
200
212
|
product_title: productTitle,
|
|
213
|
+
product_cover: firstNonBlank(matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.cover, sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.cover),
|
|
201
214
|
_origin: _objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
|
|
202
215
|
callbackData: payload
|
|
203
216
|
})
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 2 | 1 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 6 | 4 | 3 | 5;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
322
322
|
* 获取当前的客户搜索条件
|
|
323
323
|
* @returns 当前搜索条件
|
|
324
324
|
*/
|
|
325
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
325
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
326
326
|
/**
|
|
327
327
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
328
328
|
* @returns 客户状态
|