@pisell/pisellos 2.2.263 → 2.2.264
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/index.d.ts +0 -4
- package/dist/model/strategy/adapter/index.js +1 -5
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
- package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/dist/model/strategy/adapter/promotion/examples.js +99 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -16
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -2
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +1 -32
- package/dist/modules/Discount/index.d.ts +2 -5
- package/dist/modules/Discount/index.js +7 -30
- package/dist/modules/Discount/types.d.ts +0 -4
- package/dist/modules/Order/index.d.ts +2 -14
- package/dist/modules/Order/index.js +736 -1035
- package/dist/modules/Order/types.d.ts +0 -16
- package/dist/modules/Order/utils.d.ts +3 -4
- package/dist/modules/Order/utils.js +61 -54
- package/dist/modules/Product/types.d.ts +0 -22
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -4
- package/dist/modules/ProductList/types.d.ts +0 -2
- package/dist/modules/Rules/index.d.ts +9 -2
- package/dist/modules/Rules/index.js +43 -69
- package/dist/modules/Rules/types.d.ts +1 -10
- package/dist/server/index.d.ts +0 -55
- package/dist/server/index.js +753 -1173
- package/dist/server/modules/order/index.d.ts +4 -10
- package/dist/server/modules/order/index.js +399 -404
- package/dist/server/modules/order/types.d.ts +0 -4
- package/dist/server/modules/products/index.d.ts +8 -31
- package/dist/server/modules/products/index.js +390 -549
- package/dist/server/modules/products/types.d.ts +0 -18
- package/dist/solution/BaseSales/index.d.ts +1 -21
- package/dist/solution/BaseSales/index.js +789 -1136
- package/dist/solution/BaseSales/types.d.ts +1 -6
- package/dist/solution/BaseSales/types.js +1 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +97 -50
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +8 -6
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -14
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +25 -59
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/ScanOrder/index.js +31 -20
- package/dist/solution/ShopDiscount/index.js +14 -15
- package/dist/solution/VenueBooking/index.js +30 -19
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/lib/model/strategy/adapter/promotion/examples.js +91 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +51 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -5
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +2 -23
- package/lib/modules/Discount/index.d.ts +2 -5
- package/lib/modules/Discount/index.js +3 -23
- package/lib/modules/Discount/types.d.ts +0 -4
- package/lib/modules/Order/index.d.ts +2 -14
- package/lib/modules/Order/index.js +60 -326
- package/lib/modules/Order/types.d.ts +0 -16
- package/lib/modules/Order/utils.d.ts +3 -4
- package/lib/modules/Order/utils.js +23 -22
- package/lib/modules/Product/types.d.ts +0 -22
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -4
- package/lib/modules/ProductList/types.d.ts +0 -2
- package/lib/modules/Rules/index.d.ts +9 -2
- package/lib/modules/Rules/index.js +29 -61
- package/lib/modules/Rules/types.d.ts +1 -10
- package/lib/server/index.d.ts +0 -55
- package/lib/server/index.js +34 -332
- package/lib/server/modules/order/index.d.ts +4 -10
- package/lib/server/modules/order/index.js +139 -198
- package/lib/server/modules/order/types.d.ts +0 -4
- package/lib/server/modules/products/index.d.ts +8 -31
- package/lib/server/modules/products/index.js +35 -134
- package/lib/server/modules/products/types.d.ts +0 -18
- package/lib/solution/BaseSales/index.d.ts +1 -21
- package/lib/solution/BaseSales/index.js +72 -313
- package/lib/solution/BaseSales/types.d.ts +1 -6
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +64 -25
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +5 -4
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +0 -8
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +8 -33
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/ShopDiscount/index.js +1 -2
- package/lib/solution/VenueBooking/index.js +8 -0
- package/package.json +1 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +0 -53
- package/dist/modules/Order/utils/orderCollectionIdentity.js +0 -405
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +0 -53
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -415
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Discount } from '../../modules/Discount/types';
|
|
2
1
|
import { OrderModule, ProductList, QuotationModule, SalesSummaryModule, ScanOrderLoggerModule as BaseSalesLoggerModule, ScheduleModule } from '../../modules';
|
|
3
2
|
import type { ScanOrderLogInput as BaseSalesLogInput, ScanOrderLoggerProviderConfig as BaseSalesLoggerProviderConfig, ScanOrderLoggerProviderType as BaseSalesLoggerProviderType } from '../../modules/ScanOrderLogger/types';
|
|
4
3
|
import type { QuantityCheckResult, QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
@@ -86,8 +85,6 @@ export interface BaseSalesOrderProduct extends BaseSalesOrderProductIdentity {
|
|
|
86
85
|
booking_uid?: string;
|
|
87
86
|
/** 多语言商品标题快照,随 tempOrder 提交到 checkout。 */
|
|
88
87
|
product_title?: BaseSalesLocalizedText;
|
|
89
|
-
/** 商品封面图快照,随 tempOrder 提交到 checkout。 */
|
|
90
|
-
product_cover?: string;
|
|
91
88
|
/**
|
|
92
89
|
* 行级扩展 metadata。价格相关的权威字段:
|
|
93
90
|
*
|
|
@@ -384,11 +381,9 @@ export interface BaseSalesLoggerRuntimeConfig {
|
|
|
384
381
|
}
|
|
385
382
|
export interface BaseSalesAddLogParams extends BaseSalesLogInput {
|
|
386
383
|
}
|
|
387
|
-
/** BaseSales.scanPromotionCode
|
|
384
|
+
/** BaseSales.scanPromotionCode 对外的轻量结果(不含 discountList,UI 在 resolve 后调 getDiscountList) */
|
|
388
385
|
export interface BaseSalesScanCodeResult {
|
|
389
386
|
isAvailable: boolean;
|
|
390
387
|
type?: 'server' | string;
|
|
391
388
|
unavailableReason?: 'time_limit' | string;
|
|
392
|
-
/** batchSearch 原始结果;isAvailable=false 时 discountList 可能未写入 store,Holder 补全需读此字段 */
|
|
393
|
-
scannedDiscountList?: Discount[];
|
|
394
389
|
}
|
|
@@ -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 对外的轻量结果(不含 discountList,UI 在 resolve 后调 getDiscountList) */
|
|
@@ -78,6 +78,7 @@ export interface CartPromotionEvaluator {
|
|
|
78
78
|
}>;
|
|
79
79
|
hasApplicableStrategy: boolean;
|
|
80
80
|
}>;
|
|
81
|
+
getStrategyConfigs?: () => unknown[];
|
|
81
82
|
}
|
|
82
83
|
/** 单个赠品减量项 */
|
|
83
84
|
export interface GiftReduceItem {
|
|
@@ -267,7 +268,8 @@ export declare function appendPromotionTags<T extends Record<string, any>>(produ
|
|
|
267
268
|
* 处理购物车的促销计算与赠品差异化。
|
|
268
269
|
*
|
|
269
270
|
* 流程:
|
|
270
|
-
* 1. 分离 main / gift / edit-product
|
|
271
|
+
* 1. 分离 main / gift / edit-product 三类(普通促销下带 `booking_id` 的编辑态商品不参与;
|
|
272
|
+
* 配置 ITEM_REWARD 时,编辑态商品也参与商品奖励重算)
|
|
271
273
|
* 2. 转 PromotionProduct 喂评估器 → 拿到 `evaluateCartWithPricing` 与 `getProductsApplicableStrategies`
|
|
272
274
|
* 3. 把 PricedProduct 映射回 OrderProduct 形态:
|
|
273
275
|
* - 参与促销的,写 `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); }
|
|
9
4
|
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); }
|
|
10
5
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
6
|
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."); }
|
|
12
7
|
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; } }
|
|
13
8
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
9
|
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,24 +116,50 @@ 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 isItemRewardPromotionDiscountItem(item) {
|
|
123
|
+
var _item$metadata, _item$metadata2;
|
|
124
|
+
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;
|
|
125
|
+
}
|
|
126
|
+
function isManagedPromotionDiscountItem(item) {
|
|
127
|
+
if ((item === null || item === void 0 ? void 0 : item.type) === 'promotion') return true;
|
|
128
|
+
return isItemRewardPromotionDiscountItem(item);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* 判断商品行在本轮评估前是否已享受促销。
|
|
133
|
+
*
|
|
134
|
+
* `_promotion` 仅存在于当前运行时;订单保存后会被裁剪,因此编辑态需通过
|
|
135
|
+
* ITEM_REWARD 写入的受管商品折扣恢复上一轮状态。
|
|
136
|
+
*/
|
|
137
|
+
function wasInPromotionBeforeEvaluation(item) {
|
|
138
|
+
var _item$metadata3;
|
|
139
|
+
if ((item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 || (_item$metadata3 = _item$metadata3._promotion) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.inPromotion) === true) return true;
|
|
140
|
+
return Array.isArray(item === null || item === void 0 ? void 0 : item.discount_list) && item.discount_list.some(isItemRewardPromotionDiscountItem);
|
|
141
|
+
}
|
|
119
142
|
|
|
120
143
|
/**
|
|
121
|
-
* 写入/清除促销 discount_list
|
|
144
|
+
* 写入/清除促销 discount_list。
|
|
122
145
|
*
|
|
123
146
|
* applyDiscount → applyProductDiscountPrices 会从 source_product_price 减去 discount_list 合计
|
|
124
147
|
* 重算 main_product_selling_price;保留券前 source 时必须同步写入促销差额,否则会还原成原价。
|
|
125
148
|
*
|
|
149
|
+
* ITEM_REWARD 使用 type=product,复用商品级折扣排他规则,避免客户折扣继续叠加到奖励商品行。
|
|
150
|
+
*
|
|
126
151
|
* @example
|
|
127
152
|
* updatePromotionDiscountList(line, { title: '2 items for $10', amount: '17.00', original_amount: '22.00', fixed_amount: '17.00' });
|
|
128
153
|
*/
|
|
129
|
-
function updatePromotionDiscountList(item, promotionDiscount) {
|
|
154
|
+
function updatePromotionDiscountList(item, promotionDiscount, options) {
|
|
130
155
|
var discountList = Array.isArray(item.discount_list) ? _toConsumableArray(item.discount_list) : [];
|
|
131
156
|
discountList = discountList.filter(function (d) {
|
|
132
|
-
return (d
|
|
157
|
+
return !isManagedPromotionDiscountItem(d);
|
|
133
158
|
});
|
|
134
159
|
if (promotionDiscount) {
|
|
135
|
-
|
|
136
|
-
|
|
160
|
+
var discountType = (options === null || options === void 0 ? void 0 : options.discountType) || 'promotion';
|
|
161
|
+
discountList.push(_objectSpread({
|
|
162
|
+
type: discountType,
|
|
137
163
|
amount: promotionDiscount.amount,
|
|
138
164
|
discount: {
|
|
139
165
|
original_amount: promotionDiscount.original_amount,
|
|
@@ -141,7 +167,12 @@ function updatePromotionDiscountList(item, promotionDiscount) {
|
|
|
141
167
|
title: promotionDiscount.title,
|
|
142
168
|
resource_id: ''
|
|
143
169
|
}
|
|
144
|
-
}
|
|
170
|
+
}, discountType === 'product' ? {
|
|
171
|
+
metadata: {
|
|
172
|
+
source: 'promotion',
|
|
173
|
+
actionType: (options === null || options === void 0 ? void 0 : options.actionType) || ITEM_REWARD
|
|
174
|
+
}
|
|
175
|
+
} : {}));
|
|
145
176
|
}
|
|
146
177
|
if (discountList.length > 0) {
|
|
147
178
|
item.discount_list = discountList;
|
|
@@ -149,11 +180,19 @@ function updatePromotionDiscountList(item, promotionDiscount) {
|
|
|
149
180
|
delete item.discount_list;
|
|
150
181
|
}
|
|
151
182
|
}
|
|
152
|
-
|
|
153
|
-
var
|
|
183
|
+
function evaluatorHasActionType(evaluator, actionType) {
|
|
184
|
+
var _evaluator$getStrateg;
|
|
185
|
+
var configs = evaluator === null || evaluator === void 0 || (_evaluator$getStrateg = evaluator.getStrategyConfigs) === null || _evaluator$getStrateg === void 0 ? void 0 : _evaluator$getStrateg.call(evaluator);
|
|
186
|
+
if (!Array.isArray(configs)) return false;
|
|
187
|
+
return configs.some(function (config) {
|
|
188
|
+
return ((config === null || config === void 0 ? void 0 : config.actions) || []).some(function (action) {
|
|
189
|
+
return (action === null || action === void 0 ? void 0 : action.type) === actionType;
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
}
|
|
154
193
|
|
|
155
194
|
/**
|
|
156
|
-
* 将促销单价写入 OrderProduct(含 metadata 三字段 +
|
|
195
|
+
* 将促销单价写入 OrderProduct(含 metadata 三字段 + 行内折扣)。
|
|
157
196
|
*
|
|
158
197
|
* @example
|
|
159
198
|
* applyPromoUnitPriceToLine(newItem, { promoUnitPrice: '5.00', originalBasePrice: 1, strategyTitle: '2 for 10' });
|
|
@@ -184,6 +223,9 @@ function applyPromoUnitPriceToLine(item, input) {
|
|
|
184
223
|
amount: discountAmount,
|
|
185
224
|
original_amount: catalogSource,
|
|
186
225
|
fixed_amount: discountAmount
|
|
226
|
+
}, {
|
|
227
|
+
actionType: input.actionType,
|
|
228
|
+
discountType: input.actionType === ITEM_REWARD ? 'product' : 'promotion'
|
|
187
229
|
});
|
|
188
230
|
} else {
|
|
189
231
|
updatePromotionDiscountList(item, null);
|
|
@@ -245,10 +287,9 @@ export function mergeIdenticalPromotionCartLines(products) {
|
|
|
245
287
|
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 : '');
|
|
246
288
|
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 : '');
|
|
247
289
|
var noteSignature = getProductLineNoteSignature(line);
|
|
248
|
-
var lineMergeBoundary = getPromotionLineMergeBoundary(line);
|
|
249
290
|
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;
|
|
250
291
|
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;
|
|
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,
|
|
292
|
+
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('#');
|
|
252
293
|
var hitIndex = indexByKey.get(mergeKey);
|
|
253
294
|
if (hitIndex === undefined) {
|
|
254
295
|
indexByKey.set(mergeKey, merged.length);
|
|
@@ -424,16 +465,6 @@ function getProductLineNoteSignature(product) {
|
|
|
424
465
|
var uid = getOrderProductUid(product);
|
|
425
466
|
return uid ? "note:".concat(uid) : "note:".concat(normalizedNote);
|
|
426
467
|
}
|
|
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
|
-
}
|
|
437
468
|
function isPersistedGeneratedVoucher(product) {
|
|
438
469
|
var _product$order_detail;
|
|
439
470
|
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;
|
|
@@ -471,21 +502,20 @@ function getProductBundleForEvaluator(product) {
|
|
|
471
502
|
* // => 单行 num=4,清除 _promotion 后重新评估
|
|
472
503
|
*/
|
|
473
504
|
export function buildConsolidateKeyForPromotion(item) {
|
|
474
|
-
var _item$booking_uid, _item$
|
|
505
|
+
var _item$booking_uid, _item$metadata4, _item$order_detail_id, _item$product_variant3;
|
|
475
506
|
var fingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
476
507
|
var noteSignature = getProductLineNoteSignature(item);
|
|
477
|
-
var
|
|
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;
|
|
508
|
+
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$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.booking_uid;
|
|
479
509
|
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;
|
|
480
510
|
if (orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '') {
|
|
481
511
|
var _item$product_variant;
|
|
482
|
-
return [item.product_id, (_item$product_variant = item.product_variant_id) !== null && _item$product_variant !== void 0 ? _item$product_variant : 0, fingerprint, noteSignature,
|
|
512
|
+
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('#');
|
|
483
513
|
}
|
|
484
514
|
if (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '') {
|
|
485
515
|
var _item$product_variant2;
|
|
486
|
-
return [item.product_id, (_item$product_variant2 = item.product_variant_id) !== null && _item$product_variant2 !== void 0 ? _item$product_variant2 : 0, fingerprint, noteSignature,
|
|
516
|
+
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('#');
|
|
487
517
|
}
|
|
488
|
-
return [item.product_id, (_item$product_variant3 = item.product_variant_id) !== null && _item$product_variant3 !== void 0 ? _item$product_variant3 : 0, fingerprint, noteSignature
|
|
518
|
+
return [item.product_id, (_item$product_variant3 = item.product_variant_id) !== null && _item$product_variant3 !== void 0 ? _item$product_variant3 : 0, fingerprint, noteSignature].join('#');
|
|
489
519
|
}
|
|
490
520
|
function consolidateMainProductsForPromotion(entries) {
|
|
491
521
|
if (!Array.isArray(entries) || entries.length <= 1) {
|
|
@@ -496,12 +526,11 @@ function consolidateMainProductsForPromotion(entries) {
|
|
|
496
526
|
_step5;
|
|
497
527
|
try {
|
|
498
528
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
499
|
-
var _item$metadata2;
|
|
500
529
|
var _step5$value = _step5.value,
|
|
501
530
|
item = _step5$value.item,
|
|
502
531
|
originalListIndex = _step5$value.originalListIndex;
|
|
503
532
|
var key = buildConsolidateKeyForPromotion(item);
|
|
504
|
-
var wasInPromotion = (item
|
|
533
|
+
var wasInPromotion = wasInPromotionBeforeEvaluation(item);
|
|
505
534
|
var existing = groups.get(key);
|
|
506
535
|
if (!existing) {
|
|
507
536
|
var mergedItem = cloneDeep(item);
|
|
@@ -598,6 +627,9 @@ function splitXItemsPromoLinesByGroup(lines, strategyActionMap) {
|
|
|
598
627
|
function generateNumericId() {
|
|
599
628
|
return Math.floor(Math.random() * 1000000000) + Date.now();
|
|
600
629
|
}
|
|
630
|
+
function isBookingEditProductLine(product) {
|
|
631
|
+
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';
|
|
632
|
+
}
|
|
601
633
|
|
|
602
634
|
/**
|
|
603
635
|
* 把 OrderProduct 转成 evaluator 的 PromotionProduct(仅评估期使用)。
|
|
@@ -618,6 +650,7 @@ function convertToPromotionProduct(product, index) {
|
|
|
618
650
|
price: getOrderProductOriginalPriceForPromotion(product),
|
|
619
651
|
quantity: Number((_product$num = product === null || product === void 0 ? void 0 : product.num) !== null && _product$num !== void 0 ? _product$num : 1) || 1,
|
|
620
652
|
bundle: getProductBundleForEvaluator(product),
|
|
653
|
+
_promotionOnlyForItemReward: isBookingEditProductLine(product),
|
|
621
654
|
_originalItem: originalItem,
|
|
622
655
|
_originalId: getOrderProductUid(product),
|
|
623
656
|
_originalIndex: index
|
|
@@ -825,6 +858,9 @@ export function resolveStrategyRequiredQuantity(matched) {
|
|
|
825
858
|
if (matched.actionType === 'BUY_X_GET_Y_FREE') {
|
|
826
859
|
return Number(detail.buyQuantity) || 1;
|
|
827
860
|
}
|
|
861
|
+
if (matched.actionType === 'ITEM_REWARD') {
|
|
862
|
+
return Number(detail.triggerQuantity) || 1;
|
|
863
|
+
}
|
|
828
864
|
return 1;
|
|
829
865
|
}
|
|
830
866
|
|
|
@@ -850,13 +886,13 @@ export function resolveStrategyEligibleProducts(matched) {
|
|
|
850
886
|
export function calculateUnfulfilledPromotions(processedProducts, applicableStrategiesResult, mainProducts) {
|
|
851
887
|
var unfulfilledMap = new Map();
|
|
852
888
|
var _loop2 = function _loop2() {
|
|
853
|
-
var _product$
|
|
889
|
+
var _product$metadata3, _ref13, _product$_originalPro, _product$metadata4, _product$num2;
|
|
854
890
|
var product = processedProducts[i];
|
|
855
|
-
var promotion = product === null || product === void 0 || (_product$
|
|
891
|
+
var promotion = product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3._promotion;
|
|
856
892
|
if (!promotion || promotion.inPromotion !== false) return 0; // continue
|
|
857
893
|
var strategyId = promotion.strategyId;
|
|
858
894
|
if (!strategyId) return 0; // continue
|
|
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$
|
|
895
|
+
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$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.unique_identification_number) !== null && _ref13 !== void 0 ? _ref13 : '');
|
|
860
896
|
var originalIndex = mainProducts.findIndex(function (item) {
|
|
861
897
|
return getOrderProductUid(item) === lookupUid;
|
|
862
898
|
});
|
|
@@ -984,7 +1020,8 @@ export function appendPromotionTags(products, evaluator) {
|
|
|
984
1020
|
* 处理购物车的促销计算与赠品差异化。
|
|
985
1021
|
*
|
|
986
1022
|
* 流程:
|
|
987
|
-
* 1. 分离 main / gift / edit-product
|
|
1023
|
+
* 1. 分离 main / gift / edit-product 三类(普通促销下带 `booking_id` 的编辑态商品不参与;
|
|
1024
|
+
* 配置 ITEM_REWARD 时,编辑态商品也参与商品奖励重算)
|
|
988
1025
|
* 2. 转 PromotionProduct 喂评估器 → 拿到 `evaluateCartWithPricing` 与 `getProductsApplicableStrategies`
|
|
989
1026
|
* 3. 把 PricedProduct 映射回 OrderProduct 形态:
|
|
990
1027
|
* - 参与促销的,写 `metadata._promotion` + 调整 `selling_price` / `main_product_selling_price`
|
|
@@ -1014,6 +1051,7 @@ export function processCartPromotion(list, evaluator, options) {
|
|
|
1014
1051
|
if (!list || list.length === 0 || !evaluator) return empty;
|
|
1015
1052
|
|
|
1016
1053
|
// 0. 分类
|
|
1054
|
+
var shouldIncludeEditProductsForItemReward = evaluatorHasActionType(evaluator, ITEM_REWARD);
|
|
1017
1055
|
var mainProductsWithIndex = [];
|
|
1018
1056
|
var existingGiftsWithIndex = [];
|
|
1019
1057
|
var editProductsWithIndex = [];
|
|
@@ -1030,11 +1068,18 @@ export function processCartPromotion(list, evaluator, options) {
|
|
|
1030
1068
|
item: item,
|
|
1031
1069
|
originalListIndex: i
|
|
1032
1070
|
});
|
|
1033
|
-
} else if ((item
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1071
|
+
} else if (isBookingEditProductLine(item)) {
|
|
1072
|
+
if (shouldIncludeEditProductsForItemReward) {
|
|
1073
|
+
mainProductsWithIndex.push({
|
|
1074
|
+
item: item,
|
|
1075
|
+
originalListIndex: i
|
|
1076
|
+
});
|
|
1077
|
+
} else {
|
|
1078
|
+
editProductsWithIndex.push({
|
|
1079
|
+
item: item,
|
|
1080
|
+
originalListIndex: i
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1038
1083
|
} else {
|
|
1039
1084
|
mainProductsWithIndex.push({
|
|
1040
1085
|
item: item,
|
|
@@ -1089,16 +1134,17 @@ export function processCartPromotion(list, evaluator, options) {
|
|
|
1089
1134
|
var promotionProducts = [];
|
|
1090
1135
|
var originalItemMap = new Map();
|
|
1091
1136
|
var productsForStrategies = consolidatedMainProductsWithIndex.map(function (_ref16, i) {
|
|
1092
|
-
var _item$product_id, _item$product_variant5, _item$
|
|
1137
|
+
var _item$product_id, _item$product_variant5, _item$metadata5, _item$num;
|
|
1093
1138
|
var item = _ref16.item;
|
|
1094
1139
|
return {
|
|
1095
1140
|
id: i,
|
|
1096
1141
|
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,
|
|
1097
1142
|
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,
|
|
1098
|
-
name: (item === null || item === void 0 || (_item$
|
|
1143
|
+
name: (item === null || item === void 0 || (_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.product_name) || (item === null || item === void 0 ? void 0 : item.title) || '',
|
|
1099
1144
|
price: getOrderProductBasePrice(item),
|
|
1100
1145
|
quantity: Number((_item$num = item === null || item === void 0 ? void 0 : item.num) !== null && _item$num !== void 0 ? _item$num : 1) || 1,
|
|
1101
|
-
bundle: getProductBundleForEvaluator(item)
|
|
1146
|
+
bundle: getProductBundleForEvaluator(item),
|
|
1147
|
+
_promotionOnlyForItemReward: isBookingEditProductLine(item)
|
|
1102
1148
|
};
|
|
1103
1149
|
});
|
|
1104
1150
|
for (var _i = 0; _i < consolidatedMainProductsWithIndex.length; _i++) {
|
|
@@ -1206,7 +1252,7 @@ export function processCartPromotion(list, evaluator, options) {
|
|
|
1206
1252
|
_step20;
|
|
1207
1253
|
try {
|
|
1208
1254
|
for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
|
|
1209
|
-
var _priced$originalId2, _priced$product_id, _originalItem$product
|
|
1255
|
+
var _priced$originalId2, _priced$product_id, _originalItem$product;
|
|
1210
1256
|
var _priced = _step20.value;
|
|
1211
1257
|
var rawSourceId = (_priced$originalId2 = _priced.originalId) !== null && _priced$originalId2 !== void 0 ? _priced$originalId2 : _priced.id;
|
|
1212
1258
|
var _sourceId = Number(rawSourceId);
|
|
@@ -1225,7 +1271,7 @@ export function processCartPromotion(list, evaluator, options) {
|
|
|
1225
1271
|
newItem._sourceCartNum = sourceCartNum;
|
|
1226
1272
|
|
|
1227
1273
|
// 清掉历史促销字段
|
|
1228
|
-
var wasInPromotion = (
|
|
1274
|
+
var wasInPromotion = wasInPromotionBeforeEvaluation(originalItem) || originalItem._wasInPromotionBeforeConsolidate === true;
|
|
1229
1275
|
delete metadata._promotion;
|
|
1230
1276
|
if (Array.isArray(newItem.product_bundle)) {
|
|
1231
1277
|
var _iterator23 = _createForOfIteratorHelper(newItem.product_bundle),
|
|
@@ -1246,12 +1292,13 @@ export function processCartPromotion(list, evaluator, options) {
|
|
|
1246
1292
|
var priceUnchangedPromo = _priced.inPromotion && Number(_priced.finalPrice) === Number(originalBasePrice);
|
|
1247
1293
|
if (shouldModifyPrice) {
|
|
1248
1294
|
if (_priced.inPromotion && !priceUnchangedPromo) {
|
|
1249
|
-
var _priced$strategyMetad;
|
|
1295
|
+
var _priced$strategyMetad, _strategyActionMap$ge;
|
|
1250
1296
|
var promoUnitPrice = new Decimal(_priced.finalPrice).toDecimalPlaces(2).toFixed(2);
|
|
1251
1297
|
applyPromoUnitPriceToLine(newItem, {
|
|
1252
1298
|
promoUnitPrice: promoUnitPrice,
|
|
1253
1299
|
originalBasePrice: originalBasePrice,
|
|
1254
|
-
strategyTitle: (_priced$strategyMetad = _priced.strategyMetadata) === null || _priced$strategyMetad === void 0 ? void 0 : _priced$strategyMetad.name
|
|
1300
|
+
strategyTitle: (_priced$strategyMetad = _priced.strategyMetadata) === null || _priced$strategyMetad === void 0 ? void 0 : _priced$strategyMetad.name,
|
|
1301
|
+
actionType: _priced.strategyId ? (_strategyActionMap$ge = strategyActionMap.get(_priced.strategyId)) === null || _strategyActionMap$ge === void 0 ? void 0 : _strategyActionMap$ge.actionType : undefined
|
|
1255
1302
|
});
|
|
1256
1303
|
} else {
|
|
1257
1304
|
// 撤销上一轮促销:还原 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 保留原字段;字段补齐由 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,7 +23,6 @@ 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";
|
|
27
26
|
/** OrderData 中除大数组外的"顶层 header 字段"白名单,按需扩展。 */
|
|
28
27
|
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'];
|
|
29
28
|
function pickHeader(raw) {
|
|
@@ -109,16 +108,19 @@ function indexBookingsByProductUid(bookings) {
|
|
|
109
108
|
*
|
|
110
109
|
* 注意:
|
|
111
110
|
* - 入参允许是 `{ data: OrderData }` 或直接 `OrderData`,自动识别。
|
|
112
|
-
* - products
|
|
111
|
+
* - products 保留原字段;字段补齐由 OrderModule hydrate 负责。
|
|
113
112
|
* - 不做远程请求;不修改入参;返回新对象。
|
|
114
113
|
*/
|
|
115
114
|
export function parseSalesResponse(input) {
|
|
116
|
-
var
|
|
117
|
-
var raw = normalizeOrderCollections(sourceRaw).order;
|
|
115
|
+
var raw = input && _typeof(input) === 'object' && input.data && input.order_id == null ? input.data : input || {};
|
|
118
116
|
var productsRaw = Array.isArray(raw === null || raw === void 0 ? void 0 : raw.products) ? raw.products : [];
|
|
119
|
-
var products = productsRaw.map(function (p) {
|
|
117
|
+
var products = productsRaw.map(function (p, index) {
|
|
120
118
|
var row = _objectSpread({}, p || {});
|
|
121
119
|
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
|
+
}
|
|
122
124
|
delete metadata.price_schema_version;
|
|
123
125
|
delete row.identity_key;
|
|
124
126
|
return _objectSpread(_objectSpread({}, row), {}, {
|
|
@@ -30,17 +30,6 @@ 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
|
-
}
|
|
44
33
|
function normalizeOptionItems(optionItems) {
|
|
45
34
|
if (!Array.isArray(optionItems)) return [];
|
|
46
35
|
return optionItems.map(function (optionItem) {
|
|
@@ -177,8 +166,7 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
177
166
|
source_product_price: sourceProductPrice,
|
|
178
167
|
main_product_selling_price: mainProductSellingPrice,
|
|
179
168
|
main_product_original_price: mainProductOriginalPrice,
|
|
180
|
-
price_schema_version: 2
|
|
181
|
-
holder_config: sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.holder_config
|
|
169
|
+
price_schema_version: 2
|
|
182
170
|
}, hasPriceOverride ? {
|
|
183
171
|
price_override: String(payload.price_override),
|
|
184
172
|
is_manual_discount: 1
|
|
@@ -210,7 +198,6 @@ export function transformBaseProductToOrderProduct(params) {
|
|
|
210
198
|
metadata: metadata,
|
|
211
199
|
note: payload.note != null ? String(payload.note) : '',
|
|
212
200
|
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),
|
|
214
201
|
_origin: _objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
|
|
215
202
|
callbackData: payload
|
|
216
203
|
})
|
|
@@ -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 | 5 | 3 | 4 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|