@pisell/pisellos 2.2.175 → 2.2.176
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/modules/BookingContext/index.d.ts +37 -0
- package/dist/modules/BookingContext/index.js +436 -0
- package/dist/modules/BookingContext/types.d.ts +102 -0
- package/dist/modules/BookingContext/types.js +51 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +193 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +215 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/flexible.js +56 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
- package/dist/modules/BookingContext/utils/index.d.ts +11 -0
- package/dist/modules/BookingContext/utils/index.js +11 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/noResource.js +77 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/dist/modules/BookingContext/utils/productExtend.js +339 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
- package/dist/modules/BookingContext/utils/resources.js +486 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
- package/dist/modules/Customer/index.d.ts +6 -0
- package/dist/modules/Customer/index.js +129 -83
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.d.ts +2 -4
- package/dist/modules/Discount/index.js +8 -93
- package/dist/modules/Discount/types.d.ts +1 -7
- package/dist/modules/Order/index.d.ts +84 -17
- package/dist/modules/Order/index.js +1239 -495
- package/dist/modules/Order/types.d.ts +198 -18
- package/dist/modules/Order/types.js +31 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/manualProductDiscount.js +212 -0
- package/dist/modules/Order/utils.d.ts +50 -1
- package/dist/modules/Order/utils.js +261 -31
- package/dist/modules/Quotation/index.d.ts +0 -1
- package/dist/modules/Quotation/index.js +23 -21
- package/dist/modules/Rules/index.d.ts +4 -0
- package/dist/modules/Rules/index.js +26 -10
- package/dist/modules/SalesSummary/index.js +4 -2
- package/dist/modules/SalesSummary/utils.js +3 -3
- package/dist/modules/Schedule/index.js +6 -2
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +2 -1
- package/dist/server/index.js +87 -29
- package/dist/server/modules/order/utils/filterOrders.js +20 -6
- package/dist/server/modules/products/index.d.ts +1 -1
- package/dist/server/modules/products/index.js +130 -113
- package/dist/server/modules/schedule/index.js +13 -6
- package/dist/solution/BaseSales/index.d.ts +89 -7
- package/dist/solution/BaseSales/index.js +1484 -365
- package/dist/solution/BaseSales/types.d.ts +67 -1
- package/dist/solution/BaseSales/types.js +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +275 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +1258 -0
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +237 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +68 -16
- package/dist/solution/BaseSales/utils.js +46 -8
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +133 -1
- package/dist/solution/BookingTicket/index.js +780 -175
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/BookingTicket/types.js +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
- package/dist/solution/BookingTicket/utils/cartView.js +4 -2
- package/dist/solution/ScanOrder/index.d.ts +9 -3
- package/dist/solution/ScanOrder/index.js +231 -128
- package/dist/solution/ScanOrder/utils.js +46 -8
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +18 -23
- package/dist/solution/VenueBooking/index.d.ts +5 -9
- package/dist/solution/VenueBooking/index.js +103 -55
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/BookingContext/index.d.ts +37 -0
- package/lib/modules/BookingContext/index.js +297 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +34 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +207 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +198 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +80 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +43 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +90 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +283 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +377 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
- package/lib/modules/Customer/index.d.ts +6 -0
- package/lib/modules/Customer/index.js +26 -11
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +2 -4
- package/lib/modules/Discount/index.js +8 -63
- package/lib/modules/Discount/types.d.ts +1 -7
- package/lib/modules/Order/index.d.ts +84 -17
- package/lib/modules/Order/index.js +588 -145
- package/lib/modules/Order/types.d.ts +198 -18
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
- package/lib/modules/Order/utils.d.ts +50 -1
- package/lib/modules/Order/utils.js +229 -21
- package/lib/modules/Quotation/index.d.ts +0 -1
- package/lib/modules/Quotation/index.js +18 -15
- package/lib/modules/Rules/index.d.ts +4 -0
- package/lib/modules/Rules/index.js +22 -14
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/SalesSummary/utils.js +3 -3
- package/lib/modules/Schedule/index.js +3 -1
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +3 -1
- package/lib/server/index.js +41 -4
- package/lib/server/modules/order/utils/filterOrders.js +12 -4
- package/lib/server/modules/products/index.d.ts +1 -1
- package/lib/server/modules/products/index.js +30 -20
- package/lib/server/modules/schedule/index.js +2 -1
- package/lib/solution/BaseSales/index.d.ts +89 -7
- package/lib/solution/BaseSales/index.js +736 -22
- package/lib/solution/BaseSales/types.d.ts +67 -1
- package/lib/solution/BaseSales/types.js +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +275 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +836 -0
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +277 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +71 -12
- package/lib/solution/BaseSales/utils.js +46 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +133 -1
- package/lib/solution/BookingTicket/index.js +352 -8
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/BookingTicket/types.js +6 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
- package/lib/solution/BookingTicket/utils/cartView.js +4 -2
- package/lib/solution/ScanOrder/index.d.ts +9 -3
- package/lib/solution/ScanOrder/index.js +147 -66
- package/lib/solution/ScanOrder/utils.js +46 -6
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +2 -4
- package/lib/solution/VenueBooking/index.d.ts +5 -9
- package/lib/solution/VenueBooking/index.js +50 -14
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/package.json +2 -2
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
var _excluded = ["unique_identification_number"],
|
|
2
|
-
_excluded2 = ["num", "product_option_item", "surcharge_fee"],
|
|
3
|
-
_excluded3 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "
|
|
2
|
+
_excluded2 = ["num", "product_option_item", "surcharge_fee", "discount_amount", "discount_type", "discountway", "product_discount_reason", "discount_per"],
|
|
3
|
+
_excluded3 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "discount_list", "tax_fee", "total_amount", "total_refund_amount", "create_date", "holder_id"],
|
|
4
4
|
_excluded4 = ["collect_pax", "table_occupancy_duration"];
|
|
5
5
|
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; }
|
|
6
6
|
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; }
|
|
7
|
-
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); }
|
|
8
7
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
8
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
9
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
@@ -14,6 +13,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
14
13
|
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; }
|
|
15
14
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
16
15
|
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); }
|
|
16
|
+
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); }
|
|
17
17
|
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; } } }; }
|
|
18
18
|
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); }
|
|
19
19
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
@@ -113,6 +113,128 @@ export function sumOptionUnitPrice(options) {
|
|
|
113
113
|
*
|
|
114
114
|
* 导出为纯函数方便单测直接驱动钩子,不依赖 OrderModule 实例。
|
|
115
115
|
*/
|
|
116
|
+
|
|
117
|
+
/** Rules calcDiscount 用手动价标记;undefined 表示交给 Rules 用 total/origin_total 推断 */
|
|
118
|
+
export function resolveRulesManualDiscountFlag(metadata) {
|
|
119
|
+
if (!metadata) return undefined;
|
|
120
|
+
if (metadata.is_manual_discount === true || metadata.is_manual_discount === 1) {
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
var priceOverride = metadata.price_override;
|
|
124
|
+
if (priceOverride !== undefined && priceOverride !== null && priceOverride !== '') {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
function normalizeOrderProductDiscountAmount(amount) {
|
|
130
|
+
if (amount === undefined || amount === null) return undefined;
|
|
131
|
+
return String(amount);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* 商品行折扣只保留后端 OrderProductDiscountItem 协议字段。
|
|
136
|
+
* Rules/券计算过程中的 `_num`、`config` 等运行态字段不应进入 tempOrder 或提交 payload。
|
|
137
|
+
*/
|
|
138
|
+
export function normalizeOrderProductDiscountList(discountList) {
|
|
139
|
+
if (!Array.isArray(discountList)) return [];
|
|
140
|
+
return discountList.filter(function (item) {
|
|
141
|
+
return !!item && _typeof(item) === 'object';
|
|
142
|
+
}).map(function (item) {
|
|
143
|
+
var normalized = {
|
|
144
|
+
discount_id: Number.isFinite(Number(item.discount_id)) ? Number(item.discount_id) : 0
|
|
145
|
+
};
|
|
146
|
+
if (item.order_discount_id === null) {
|
|
147
|
+
normalized.order_discount_id = null;
|
|
148
|
+
} else if (item.order_discount_id !== undefined) {
|
|
149
|
+
var orderDiscountId = Number(item.order_discount_id);
|
|
150
|
+
if (Number.isFinite(orderDiscountId)) {
|
|
151
|
+
normalized.order_discount_id = orderDiscountId;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (item.type !== undefined) normalized.type = item.type;
|
|
155
|
+
var amount = normalizeOrderProductDiscountAmount(item.amount);
|
|
156
|
+
if (amount !== undefined) normalized.amount = amount;
|
|
157
|
+
if (item.discount && _typeof(item.discount) === 'object') {
|
|
158
|
+
normalized.discount = _objectSpread({}, item.discount);
|
|
159
|
+
}
|
|
160
|
+
if (item.metadata === null) {
|
|
161
|
+
normalized.metadata = null;
|
|
162
|
+
} else if (item.metadata && _typeof(item.metadata) === 'object') {
|
|
163
|
+
normalized.metadata = _objectSpread({}, item.metadata);
|
|
164
|
+
}
|
|
165
|
+
return normalized;
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* 手动改价(price_override)时行级 original_price(composite 单价):
|
|
171
|
+
* 购物车划线价应对齐 metadata.origin._extend.origin_total(改价前单价 composite,如 40),
|
|
172
|
+
* 而非 bundle 子项 catalog 原价合成的 composedOriginalPrice(如 30)。
|
|
173
|
+
*
|
|
174
|
+
* origin_total 与 SkuDetailModal / cacheItem._extend 一致,为单价语义,不再除以 num。
|
|
175
|
+
*/
|
|
176
|
+
export function resolveManualOverrideLineOriginalPrice(params, fallbackCompositeOriginal) {
|
|
177
|
+
var _metadata$origin;
|
|
178
|
+
var metadata = params.metadata || {};
|
|
179
|
+
var priceOverride = metadata.price_override;
|
|
180
|
+
if (priceOverride === undefined || priceOverride === null || priceOverride === '') {
|
|
181
|
+
return fallbackCompositeOriginal;
|
|
182
|
+
}
|
|
183
|
+
var refTotal = (_metadata$origin = metadata.origin) === null || _metadata$origin === void 0 || (_metadata$origin = _metadata$origin._extend) === null || _metadata$origin === void 0 ? void 0 : _metadata$origin.origin_total;
|
|
184
|
+
if (refTotal !== undefined && refTotal !== null && refTotal !== '') {
|
|
185
|
+
var parsed = Number(refTotal);
|
|
186
|
+
if (Number.isFinite(parsed)) {
|
|
187
|
+
return new Decimal(parsed).toDecimalPlaces(2).toFixed(2);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
var lineOriginal = params.lineOriginalPrice;
|
|
191
|
+
if (lineOriginal !== undefined && lineOriginal !== null && lineOriginal !== '') {
|
|
192
|
+
var parsedLine = Number(lineOriginal);
|
|
193
|
+
var parsedFallback = Number(fallbackCompositeOriginal);
|
|
194
|
+
if (Number.isFinite(parsedLine) && Number.isFinite(parsedFallback) && parsedLine > parsedFallback) {
|
|
195
|
+
return new Decimal(parsedLine).toDecimalPlaces(2).toFixed(2);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return fallbackCompositeOriginal;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* 计算商品行「每单位有效折扣」:discount_list 合计 + 被 Rules 剥离但仍 inPromotion 的差额。
|
|
203
|
+
*
|
|
204
|
+
* Rules.calcDiscount 会把 type=promotion 从 discount_list 去掉,但 metadata._promotion 仍保留;
|
|
205
|
+
* applyProductDiscountPrices 必须回读 _promotion,否则抬价/降价都会在第二步被 source 原价覆盖。
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* resolveEffectivePerUnitDiscount({ metadata: { _promotion: { inPromotion: true, originalPrice: 1, finalPrice: 5 } }, discount_list: [] });
|
|
209
|
+
* // => -4
|
|
210
|
+
*/
|
|
211
|
+
export function resolveEffectivePerUnitDiscount(product) {
|
|
212
|
+
var discountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? product.discount_list : [];
|
|
213
|
+
var fromList = discountList.reduce(function (sum, discount) {
|
|
214
|
+
return sum + Number((discount === null || discount === void 0 ? void 0 : discount.amount) || 0);
|
|
215
|
+
}, 0);
|
|
216
|
+
var hasPromoDiscountItem = discountList.some(function (item) {
|
|
217
|
+
return (item === null || item === void 0 ? void 0 : item.type) === 'promotion';
|
|
218
|
+
});
|
|
219
|
+
if (hasPromoDiscountItem) return fromList;
|
|
220
|
+
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
221
|
+
var optionSum = sumOptionUnitPrice(product === null || product === void 0 ? void 0 : product.product_option_item).toNumber();
|
|
222
|
+
|
|
223
|
+
// applyPromotion 写价后、Rules 剥离 promotion discount 的兜底
|
|
224
|
+
if (metadata.source_product_price != null && metadata.main_product_selling_price != null) {
|
|
225
|
+
var source = Number(metadata.source_product_price);
|
|
226
|
+
var selling = Number(metadata.main_product_selling_price) - optionSum;
|
|
227
|
+
if (Number.isFinite(source) && Number.isFinite(selling) && source !== selling) {
|
|
228
|
+
return fromList + (source - selling);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
var promo = metadata._promotion;
|
|
232
|
+
if ((promo === null || promo === void 0 ? void 0 : promo.inPromotion) !== true) return fromList;
|
|
233
|
+
var originalPrice = Number(promo.originalPrice);
|
|
234
|
+
var finalPrice = Number(promo.finalPrice);
|
|
235
|
+
if (!Number.isFinite(originalPrice) || !Number.isFinite(finalPrice)) return fromList;
|
|
236
|
+
return fromList + (originalPrice - finalPrice);
|
|
237
|
+
}
|
|
116
238
|
export function createDefaultOrderRulesHooks() {
|
|
117
239
|
var toUnitPriceString = function toUnitPriceString(totalLike, num) {
|
|
118
240
|
var effectiveNum = Number(num) > 0 ? Number(num) : 1;
|
|
@@ -120,7 +242,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
120
242
|
};
|
|
121
243
|
return {
|
|
122
244
|
getProduct: function getProduct(product) {
|
|
123
|
-
var _product$metadata, _product$metadata2, _product$metadata3, _product$metadata4, _product$metadata5,
|
|
245
|
+
var _product$metadata, _product$metadata2, _product$metadata3, _product$metadata4, _product$metadata5, _metadataAny$_promoti;
|
|
124
246
|
// source_product_price 是权威源;兜底链:source → mainSelling − options(反推)→ 行 selling_price
|
|
125
247
|
var metadataAny = product.metadata || {};
|
|
126
248
|
var optionSum = sumOptionUnitPrice(product.product_option_item);
|
|
@@ -145,7 +267,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
145
267
|
id: product.product_id,
|
|
146
268
|
// Rules 引擎用 _id 作为 processedProductsMap 键;必须与购物车行级 identity 一致,
|
|
147
269
|
// 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
|
|
148
|
-
// 不透明 identity 契约下,normalizeOrderProduct /
|
|
270
|
+
// 不透明 identity 契约下,normalizeOrderProduct / hydrate 已保证唯一值存在;
|
|
149
271
|
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
150
272
|
_id: (_product$metadata = product.metadata) !== null && _product$metadata !== void 0 && _product$metadata.unique_identification_number ? "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(product.metadata.unique_identification_number) : "".concat(product.product_id, "_").concat(product.product_variant_id, "_").concat(buildProductLineFingerprint(product.product_option_item, product.product_bundle)),
|
|
151
273
|
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
@@ -161,9 +283,14 @@ export function createDefaultOrderRulesHooks() {
|
|
|
161
283
|
bundle: product.product_bundle || [],
|
|
162
284
|
booking_id: ((_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.booking_id) || null,
|
|
163
285
|
isClient: false,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
286
|
+
// 勿写死 false:否则 Rules 不会走 total≠origin_total 的手动价推断,
|
|
287
|
+
// 无券时会把 bundle 价还原成 original_price(手动改价套餐会从 20 回到 30)。
|
|
288
|
+
isManualDiscount: resolveRulesManualDiscountFlag(metadataAny),
|
|
289
|
+
holder_id: (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.holder_id,
|
|
290
|
+
startDate: ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.start_date) || ((_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.startDate),
|
|
291
|
+
main_product_selling_price: metadataAny.main_product_selling_price !== undefined ? new Decimal(Number(metadataAny.main_product_selling_price) || 0).minus(optionSum).toDecimalPlaces(2).toString() : undefined,
|
|
292
|
+
inPromotion: ((_metadataAny$_promoti = metadataAny._promotion) === null || _metadataAny$_promoti === void 0 ? void 0 : _metadataAny$_promoti.inPromotion) === true,
|
|
293
|
+
_promotion: metadataAny._promotion
|
|
167
294
|
};
|
|
168
295
|
},
|
|
169
296
|
setProduct: function setProduct(product, values) {
|
|
@@ -196,9 +323,14 @@ export function createDefaultOrderRulesHooks() {
|
|
|
196
323
|
bundle: nextBundle,
|
|
197
324
|
useOriginalBundle: true
|
|
198
325
|
});
|
|
326
|
+
var finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
|
|
327
|
+
num: nextNum,
|
|
328
|
+
metadata: metadataAny,
|
|
329
|
+
lineOriginalPrice: product.original_price
|
|
330
|
+
}, composedOriginalPrice);
|
|
199
331
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
200
332
|
selling_price: composedSellingPrice,
|
|
201
|
-
original_price:
|
|
333
|
+
original_price: finalOriginalPrice,
|
|
202
334
|
discount_list: (_values$discount_list = values.discount_list) !== null && _values$discount_list !== void 0 ? _values$discount_list : product.discount_list,
|
|
203
335
|
num: (_values$quantity2 = values.quantity) !== null && _values$quantity2 !== void 0 ? _values$quantity2 : product.num,
|
|
204
336
|
product_bundle: nextBundle,
|
|
@@ -394,6 +526,11 @@ function normalizeSubmitProduct(product) {
|
|
|
394
526
|
var num = submitProduct.num,
|
|
395
527
|
productOptionItem = submitProduct.product_option_item,
|
|
396
528
|
_productSurchargeFee = submitProduct.surcharge_fee,
|
|
529
|
+
_deprecatedDiscountAmount = submitProduct.discount_amount,
|
|
530
|
+
_deprecatedDiscountType = submitProduct.discount_type,
|
|
531
|
+
_deprecatedDiscountway = submitProduct.discountway,
|
|
532
|
+
_deprecatedProductDiscountReason = submitProduct.product_discount_reason,
|
|
533
|
+
_deprecatedDiscountPer = submitProduct.discount_per,
|
|
397
534
|
productRest = _objectWithoutProperties(submitProduct, _excluded2);
|
|
398
535
|
var rawMetadata = submitProduct.metadata || {};
|
|
399
536
|
var bookingUid = rawMetadata.booking_uid;
|
|
@@ -423,7 +560,7 @@ function normalizeSubmitProduct(product) {
|
|
|
423
560
|
} : {}), {}, {
|
|
424
561
|
product_quantity: toBundleNumber(num !== null && num !== void 0 ? num : submitProduct.product_quantity, 1),
|
|
425
562
|
product_sku: productSku,
|
|
426
|
-
discount_list: submitProduct.discount_list
|
|
563
|
+
discount_list: normalizeOrderProductDiscountList(submitProduct.discount_list),
|
|
427
564
|
product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
|
|
428
565
|
metadata: cleanMetadata,
|
|
429
566
|
// 出站兼容:后端消费 payment_price 字段,这里从 selling_price 直接派生。
|
|
@@ -502,22 +639,23 @@ export function createDefaultTempOrder(params) {
|
|
|
502
639
|
return {
|
|
503
640
|
order_id: null,
|
|
504
641
|
external_sale_number: '',
|
|
505
|
-
order_number:
|
|
506
|
-
shop_order_number:
|
|
507
|
-
shop_full_order_number:
|
|
508
|
-
type: '
|
|
509
|
-
business_code:
|
|
642
|
+
order_number: null,
|
|
643
|
+
shop_order_number: null,
|
|
644
|
+
shop_full_order_number: null,
|
|
645
|
+
type: '',
|
|
646
|
+
business_code: undefined,
|
|
510
647
|
platform: 'h5',
|
|
511
648
|
sales_channel: 'my_pisel',
|
|
512
649
|
order_sales_channel: 'online_store',
|
|
513
650
|
status: 'normal',
|
|
514
651
|
payment_status: 'payment_processing',
|
|
515
652
|
shipping_status: 'unfulfilled',
|
|
516
|
-
customer_id:
|
|
653
|
+
customer_id: 0,
|
|
517
654
|
customer_name: '',
|
|
518
655
|
country_calling_code: '',
|
|
519
656
|
phone: '',
|
|
520
657
|
email: '',
|
|
658
|
+
customer: null,
|
|
521
659
|
is_price_include_tax: 1,
|
|
522
660
|
tax_title: '',
|
|
523
661
|
tax_country_code: '',
|
|
@@ -536,7 +674,6 @@ export function createDefaultTempOrder(params) {
|
|
|
536
674
|
bookings: [],
|
|
537
675
|
payments: [],
|
|
538
676
|
surcharges: [],
|
|
539
|
-
discount_list: [],
|
|
540
677
|
relation_forms: [],
|
|
541
678
|
contacts: [],
|
|
542
679
|
contacts_info: null,
|
|
@@ -548,7 +685,7 @@ export function createDefaultTempOrder(params) {
|
|
|
548
685
|
};
|
|
549
686
|
}
|
|
550
687
|
export function buildSubmitPayload(params) {
|
|
551
|
-
var
|
|
688
|
+
var _tempOrder$customer_i, _ref10, _tempOrder$is_price_i, _tempOrder$is_deposit;
|
|
552
689
|
var tempOrder = params.tempOrder,
|
|
553
690
|
cacheId = params.cacheId,
|
|
554
691
|
_params$now = params.now,
|
|
@@ -573,20 +710,35 @@ export function buildSubmitPayload(params) {
|
|
|
573
710
|
_shopServiceType = _ref9.shop_service_type,
|
|
574
711
|
_startTime = _ref9.start_time,
|
|
575
712
|
_customer = _ref9.customer,
|
|
576
|
-
|
|
713
|
+
_discountList = _ref9.discount_list,
|
|
577
714
|
_rootTaxFee = _ref9.tax_fee,
|
|
578
715
|
_totalAmount = _ref9.total_amount,
|
|
579
716
|
_totalRefundAmount = _ref9.total_refund_amount,
|
|
580
717
|
_createDate = _ref9.create_date,
|
|
581
718
|
_holderId = _ref9.holder_id,
|
|
582
719
|
tempOrderRest = _objectWithoutProperties(_ref9, _excluded3);
|
|
720
|
+
var submitType = type !== null && type !== void 0 ? type : tempOrder.type;
|
|
721
|
+
if (!submitType) {
|
|
722
|
+
var _tempOrder$bookings;
|
|
723
|
+
// 如果外部没有传递 types,根据订单里当前是否有 bookings 来决定是 appointment_booking 还是 virtual
|
|
724
|
+
if (tempOrder !== null && tempOrder !== void 0 && (_tempOrder$bookings = tempOrder.bookings) !== null && _tempOrder$bookings !== void 0 && _tempOrder$bookings.length) {
|
|
725
|
+
submitType = 'appointment_booking';
|
|
726
|
+
} else {
|
|
727
|
+
submitType = 'virtual';
|
|
728
|
+
}
|
|
729
|
+
}
|
|
583
730
|
var payload = _objectSpread(_objectSpread({}, tempOrderRest), {}, {
|
|
731
|
+
customer_id: (_tempOrder$customer_i = tempOrder.customer_id) !== null && _tempOrder$customer_i !== void 0 ? _tempOrder$customer_i : 1,
|
|
732
|
+
customer_name: tempOrder.customer_name || 'Select a customer',
|
|
733
|
+
order_number: null,
|
|
734
|
+
shop_order_number: null,
|
|
735
|
+
shop_full_order_number: null,
|
|
584
736
|
platform: normalizeSubmitPlatform(platform),
|
|
585
737
|
request_unique_idempotency_token: tempOrder.request_unique_idempotency_token || "".concat(tempOrder.external_sale_number, "_").concat(now.getTime()),
|
|
586
|
-
type:
|
|
587
|
-
business_code:
|
|
738
|
+
type: submitType,
|
|
739
|
+
business_code: businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code,
|
|
588
740
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
589
|
-
order_sales_channel: (
|
|
741
|
+
order_sales_channel: (_ref10 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref10 !== void 0 ? _ref10 : 'online_store',
|
|
590
742
|
status: tempOrder.status || 'normal',
|
|
591
743
|
payment_status: tempOrder.payment_status || 'payment_processing',
|
|
592
744
|
// shipping_status: tempOrder.shipping_status || 'unfulfilled',
|
|
@@ -599,25 +751,23 @@ export function buildSubmitPayload(params) {
|
|
|
599
751
|
note: tempOrder.note || '',
|
|
600
752
|
delivery_type: tempOrder.delivery_type || 'nil',
|
|
601
753
|
schedule_date: scheduleDate,
|
|
602
|
-
created_at: tempOrder.created_at || formatDateTime(now),
|
|
754
|
+
// created_at: tempOrder.created_at || formatDateTime(now), 和后端协定这个字段先不提交到接口
|
|
603
755
|
bookings: (tempOrder.bookings || []).filter(function (booking) {
|
|
604
|
-
|
|
605
|
-
return Number((_parent_id = booking.parent_id) !== null && _parent_id !== void 0 ? _parent_id : 0) !== 0;
|
|
756
|
+
return Number(booking.parent_id) !== 0;
|
|
606
757
|
}).map(function (booking) {
|
|
607
758
|
return normalizeSubmitBooking(booking);
|
|
608
759
|
}),
|
|
609
760
|
payments: tempOrder.payments || [],
|
|
610
|
-
// discount_list: tempOrder.discount_list || [],
|
|
611
761
|
relation_forms: tempOrder.relation_forms || [],
|
|
612
762
|
// contacts: tempOrder.contacts || [],
|
|
613
763
|
contacts_info: tempOrder.contacts_info && !Array.isArray(tempOrder.contacts_info) ? tempOrder.contacts_info : null,
|
|
614
764
|
// holder: tempOrder.holder || null,
|
|
615
765
|
// summary,
|
|
616
766
|
metadata: function () {
|
|
617
|
-
var
|
|
618
|
-
_collectPax =
|
|
619
|
-
_tableOccupancyDuration =
|
|
620
|
-
rest = _objectWithoutProperties(
|
|
767
|
+
var _ref11 = tempOrder.metadata || {},
|
|
768
|
+
_collectPax = _ref11.collect_pax,
|
|
769
|
+
_tableOccupancyDuration = _ref11.table_occupancy_duration,
|
|
770
|
+
rest = _objectWithoutProperties(_ref11, _excluded4);
|
|
621
771
|
return _objectSpread({}, rest);
|
|
622
772
|
}(),
|
|
623
773
|
products: (tempOrder.products || []).map(function (product) {
|
|
@@ -712,4 +862,84 @@ export function formatV1Product(products) {
|
|
|
712
862
|
};
|
|
713
863
|
});
|
|
714
864
|
}
|
|
715
|
-
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* 判断 holder_id 是否已分配(非空)。
|
|
868
|
+
*
|
|
869
|
+
* @example
|
|
870
|
+
* hasAssignedHolderId(12); // true
|
|
871
|
+
* hasAssignedHolderId([]); // false
|
|
872
|
+
*/
|
|
873
|
+
export function hasAssignedHolderId(value) {
|
|
874
|
+
if (value === undefined || value === null || value === '') return false;
|
|
875
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
876
|
+
return true;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* 清空 tempOrder 购物车行上的 holder 分配(products / bookings / runtime origin)。
|
|
881
|
+
* 移除或更换下单客户时调用,与 booking 页换客户清 holder 行为对齐。
|
|
882
|
+
*
|
|
883
|
+
* @example
|
|
884
|
+
* clearTempOrderHolderAssignments(tempOrder);
|
|
885
|
+
*/
|
|
886
|
+
export function clearTempOrderHolderAssignments(tempOrder) {
|
|
887
|
+
var _tempOrder$_extend;
|
|
888
|
+
var changed = false;
|
|
889
|
+
var resetHolderField = function resetHolderField(target) {
|
|
890
|
+
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'holder_id';
|
|
891
|
+
if (!hasAssignedHolderId(target[key])) return;
|
|
892
|
+
target[key] = null;
|
|
893
|
+
changed = true;
|
|
894
|
+
};
|
|
895
|
+
var _iterator4 = _createForOfIteratorHelper(tempOrder.products || []),
|
|
896
|
+
_step4;
|
|
897
|
+
try {
|
|
898
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
899
|
+
var product = _step4.value;
|
|
900
|
+
if (product.metadata && _typeof(product.metadata) === 'object') {
|
|
901
|
+
resetHolderField(product.metadata);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
} catch (err) {
|
|
905
|
+
_iterator4.e(err);
|
|
906
|
+
} finally {
|
|
907
|
+
_iterator4.f();
|
|
908
|
+
}
|
|
909
|
+
var _iterator5 = _createForOfIteratorHelper(tempOrder.bookings || []),
|
|
910
|
+
_step5;
|
|
911
|
+
try {
|
|
912
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
913
|
+
var booking = _step5.value;
|
|
914
|
+
var bookingRecord = booking;
|
|
915
|
+
if (booking.metadata && _typeof(booking.metadata) === 'object') {
|
|
916
|
+
resetHolderField(booking.metadata);
|
|
917
|
+
}
|
|
918
|
+
if (bookingRecord.holder !== undefined && bookingRecord.holder !== null) {
|
|
919
|
+
delete bookingRecord.holder;
|
|
920
|
+
changed = true;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
} catch (err) {
|
|
924
|
+
_iterator5.e(err);
|
|
925
|
+
} finally {
|
|
926
|
+
_iterator5.f();
|
|
927
|
+
}
|
|
928
|
+
var productsByUid = (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.productsByUid;
|
|
929
|
+
if (productsByUid && _typeof(productsByUid) === 'object') {
|
|
930
|
+
for (var _i4 = 0, _Object$values = Object.values(productsByUid); _i4 < _Object$values.length; _i4++) {
|
|
931
|
+
var entry = _Object$values[_i4];
|
|
932
|
+
var origin = entry === null || entry === void 0 ? void 0 : entry.origin;
|
|
933
|
+
if (!origin || _typeof(origin) !== 'object') continue;
|
|
934
|
+
if (origin.metadata && _typeof(origin.metadata) === 'object') {
|
|
935
|
+
resetHolderField(origin.metadata);
|
|
936
|
+
}
|
|
937
|
+
if (origin._extend && _typeof(origin._extend) === 'object') {
|
|
938
|
+
resetHolderField(origin._extend);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
return changed;
|
|
943
|
+
}
|
|
944
|
+
export { createEmptySummary } from "../../solution/ScanOrder/utils";
|
|
945
|
+
export { buildManualProductDiscountItem, ensureManualProductDiscountList, findManualProductDiscountItem, mergeManualProductDiscountIntoList, resolveManualDiscountMessage, resolveManualDiscountOriginTotal, resolveManualDiscountReasonFromSources, resolveSafeProductNum, shouldBuildManualProductDiscount, syncManualProductDiscountProductNum, stripManualProductDiscountItems } from "./utils/manualProductDiscount";
|
|
@@ -47,7 +47,6 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
47
47
|
customer_id?: number | string;
|
|
48
48
|
}): Map<string, string | null>;
|
|
49
49
|
setScheduleResolver(resolver: (id: number) => ScheduleItem | undefined): void;
|
|
50
|
-
private filterQuotationsByCustomer;
|
|
51
50
|
private isQuotationVisibleForCustomer;
|
|
52
51
|
private hasValidCustomerId;
|
|
53
52
|
private isQuotationActiveAt;
|
|
@@ -78,22 +78,21 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
78
78
|
case 0:
|
|
79
79
|
query = {};
|
|
80
80
|
if (params !== null && params !== void 0 && params.channel) query.channel = params.channel;
|
|
81
|
-
if (params !== null && params !== void 0 && params.customer_id) query.customer_id = String(params.customer_id);
|
|
82
81
|
if ((params === null || params === void 0 ? void 0 : params.channel) === 'online_store') {
|
|
83
82
|
query.channel = 'online-store';
|
|
84
83
|
}
|
|
85
|
-
_context2.next =
|
|
84
|
+
_context2.next = 5;
|
|
86
85
|
return this.request.get('/quotation/available', query, {
|
|
87
86
|
useCache: false
|
|
88
87
|
});
|
|
89
|
-
case
|
|
88
|
+
case 5:
|
|
90
89
|
res = _context2.sent;
|
|
91
|
-
list =
|
|
90
|
+
list = (res === null || res === void 0 || (_data = res.data) === null || _data === void 0 ? void 0 : _data.list) || (res === null || res === void 0 ? void 0 : res.list) || [];
|
|
92
91
|
list.sort(function (a, b) {
|
|
93
92
|
return a.sort - b.sort;
|
|
94
93
|
});
|
|
95
94
|
this.store.list = list;
|
|
96
|
-
case
|
|
95
|
+
case 9:
|
|
97
96
|
case "end":
|
|
98
97
|
return _context2.stop();
|
|
99
98
|
}
|
|
@@ -130,8 +129,10 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
130
129
|
try {
|
|
131
130
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
132
131
|
var quotation = _step.value;
|
|
133
|
-
|
|
134
|
-
if (!
|
|
132
|
+
var visible = this.isQuotationVisibleForCustomer(quotation, customer_id);
|
|
133
|
+
if (!visible) continue;
|
|
134
|
+
var active = this.isQuotationActiveAt(quotation, datetime);
|
|
135
|
+
if (!active) continue;
|
|
135
136
|
var match = this.findProductData(quotation.product_data, productId, variantId);
|
|
136
137
|
if (!match) continue;
|
|
137
138
|
if (match.value === 0) continue;
|
|
@@ -218,14 +219,6 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
218
219
|
value: function setScheduleResolver(resolver) {
|
|
219
220
|
this.scheduleResolver = resolver;
|
|
220
221
|
}
|
|
221
|
-
}, {
|
|
222
|
-
key: "filterQuotationsByCustomer",
|
|
223
|
-
value: function filterQuotationsByCustomer(list, customerId) {
|
|
224
|
-
var _this2 = this;
|
|
225
|
-
return list.filter(function (quotation) {
|
|
226
|
-
return _this2.isQuotationVisibleForCustomer(quotation, customerId);
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
222
|
}, {
|
|
230
223
|
key: "isQuotationVisibleForCustomer",
|
|
231
224
|
value: function isQuotationVisibleForCustomer(quotation, customerId) {
|
|
@@ -246,18 +239,27 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
246
239
|
key: "isQuotationActiveAt",
|
|
247
240
|
value: function isQuotationActiveAt(quotation, datetime) {
|
|
248
241
|
var _quotation$schedule,
|
|
249
|
-
|
|
242
|
+
_this2 = this;
|
|
250
243
|
if (!((_quotation$schedule = quotation.schedule) !== null && _quotation$schedule !== void 0 && _quotation$schedule.length)) return false;
|
|
251
|
-
var scheduleItems =
|
|
252
|
-
|
|
253
|
-
var
|
|
254
|
-
|
|
255
|
-
|
|
244
|
+
var scheduleItems = [];
|
|
245
|
+
quotation.schedule.forEach(function (s) {
|
|
246
|
+
var _this2$scheduleResolv;
|
|
247
|
+
var full = (_this2$scheduleResolv = _this2.scheduleResolver) === null || _this2$scheduleResolv === void 0 ? void 0 : _this2$scheduleResolv.call(_this2, s.id);
|
|
248
|
+
if (full) {
|
|
249
|
+
scheduleItems.push(full);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (_this2.scheduleResolver) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
var fallbackSchedule = _objectSpread(_objectSpread({}, s), {}, {
|
|
256
256
|
repeat_type: s.repeat_type || 'none',
|
|
257
257
|
repeat_rule: s.repeat_rule || null,
|
|
258
258
|
time_slot: s.time_slot || []
|
|
259
259
|
});
|
|
260
|
+
scheduleItems.push(fallbackSchedule);
|
|
260
261
|
});
|
|
262
|
+
if (!scheduleItems.length) return false;
|
|
261
263
|
return getDateIsInSchedule(datetime, scheduleItems);
|
|
262
264
|
}
|
|
263
265
|
}, {
|
|
@@ -32,6 +32,10 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
32
32
|
unavailableReason?: UnavailableReason;
|
|
33
33
|
};
|
|
34
34
|
filterDiscountListByType(discountList: Discount[], type: string): Discount[];
|
|
35
|
+
/** 剔除指定 type/tag 的折扣项,保留手动改价(type=product) / 券等 */
|
|
36
|
+
excludeDiscountListByType(discountList: Discount[], type: string): Discount[];
|
|
37
|
+
/** 手动改价场景:去掉 promotion,保留 type=product 等行内折扣 */
|
|
38
|
+
resolveDiscountListForManualOverride(discountList: Discount[]): Discount[];
|
|
35
39
|
private getUnavailableReason;
|
|
36
40
|
calcDiscount({ discountList, productList, holders, isFormSubject, orderTotalAmount }: {
|
|
37
41
|
discountList: Discount[];
|
|
@@ -222,6 +222,22 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
222
222
|
return item.type === type || item.tag === type;
|
|
223
223
|
});
|
|
224
224
|
}
|
|
225
|
+
|
|
226
|
+
/** 剔除指定 type/tag 的折扣项,保留手动改价(type=product) / 券等 */
|
|
227
|
+
}, {
|
|
228
|
+
key: "excludeDiscountListByType",
|
|
229
|
+
value: function excludeDiscountListByType(discountList, type) {
|
|
230
|
+
return (discountList || []).filter(function (item) {
|
|
231
|
+
return item.type !== type && item.tag !== type;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** 手动改价场景:去掉 promotion,保留 type=product 等行内折扣 */
|
|
236
|
+
}, {
|
|
237
|
+
key: "resolveDiscountListForManualOverride",
|
|
238
|
+
value: function resolveDiscountListForManualOverride(discountList) {
|
|
239
|
+
return this.excludeDiscountListByType(discountList, 'promotion');
|
|
240
|
+
}
|
|
225
241
|
// 获取券不可用的原因
|
|
226
242
|
}, {
|
|
227
243
|
key: "getUnavailableReason",
|
|
@@ -1208,7 +1224,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1208
1224
|
price: product.price,
|
|
1209
1225
|
options: restoredOptions
|
|
1210
1226
|
}), {}, {
|
|
1211
|
-
discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1227
|
+
discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(product.discount_list) : _this3.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1212
1228
|
}))]);
|
|
1213
1229
|
} else {
|
|
1214
1230
|
var _ref13, _product$_promotion$f, _product13, _product$origin_total;
|
|
@@ -1231,14 +1247,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1231
1247
|
main_product_selling_price: main_product_selling_price,
|
|
1232
1248
|
options: restoredOptions
|
|
1233
1249
|
}), {}, {
|
|
1234
|
-
discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1250
|
+
discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(product.discount_list) : _this3.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1235
1251
|
}))]);
|
|
1236
1252
|
}
|
|
1237
1253
|
} else {
|
|
1238
|
-
var _flatItem$bundleItem8;
|
|
1254
|
+
var _flatItem$bundleItem8, _flatItem$bundleItem9;
|
|
1239
1255
|
// bundle子商品:保存到扁平化Map
|
|
1240
1256
|
processedFlatItemsMap.set(flatItem._id, [_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1241
|
-
discount_list: _this3.
|
|
1257
|
+
discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(((_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.discount_list) || []) : _this3.filterDiscountListByType(((_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.discount_list) || [], 'promotion'),
|
|
1242
1258
|
price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
|
|
1243
1259
|
processed: true
|
|
1244
1260
|
})]);
|
|
@@ -2069,10 +2085,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2069
2085
|
return true; // 单独购买时可用
|
|
2070
2086
|
}
|
|
2071
2087
|
if (isBundleItem) {
|
|
2072
|
-
var _flatItem$
|
|
2088
|
+
var _flatItem$bundleItem10, _flatItem$bundleItem11, _flatItem$originProdu, _flatItem$parentProdu10;
|
|
2073
2089
|
// 套餐中购买时,判断是否为原价
|
|
2074
|
-
var priceType = (_flatItem$
|
|
2075
|
-
var priceTypeExt = (_flatItem$
|
|
2090
|
+
var priceType = (_flatItem$bundleItem10 = flatItem.bundleItem) === null || _flatItem$bundleItem10 === void 0 ? void 0 : _flatItem$bundleItem10.price_type;
|
|
2091
|
+
var priceTypeExt = (_flatItem$bundleItem11 = flatItem.bundleItem) === null || _flatItem$bundleItem11 === void 0 ? void 0 : _flatItem$bundleItem11.price_type_ext;
|
|
2076
2092
|
// 主商品id
|
|
2077
2093
|
var mainProductId = (flatItem === null || flatItem === void 0 || (_flatItem$originProdu = flatItem.originProduct) === null || _flatItem$originProdu === void 0 || (_flatItem$originProdu = _flatItem$originProdu._productOrigin) === null || _flatItem$originProdu === void 0 ? void 0 : _flatItem$originProdu.id) || (flatItem === null || flatItem === void 0 || (_flatItem$parentProdu10 = flatItem.parentProduct) === null || _flatItem$parentProdu10 === void 0 ? void 0 : _flatItem$parentProdu10.id) || 0;
|
|
2078
2094
|
// original_price 对应:
|
|
@@ -2139,10 +2155,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2139
2155
|
return false; // 单独购买时不可用
|
|
2140
2156
|
}
|
|
2141
2157
|
if (isBundleItem) {
|
|
2142
|
-
var _flatItem$
|
|
2158
|
+
var _flatItem$bundleItem12, _flatItem$bundleItem13;
|
|
2143
2159
|
// 套餐中购买时,判断是否为原价
|
|
2144
|
-
var _priceType = (_flatItem$
|
|
2145
|
-
var _priceTypeExt = (_flatItem$
|
|
2160
|
+
var _priceType = (_flatItem$bundleItem12 = flatItem.bundleItem) === null || _flatItem$bundleItem12 === void 0 ? void 0 : _flatItem$bundleItem12.price_type;
|
|
2161
|
+
var _priceTypeExt = (_flatItem$bundleItem13 = flatItem.bundleItem) === null || _flatItem$bundleItem13 === void 0 ? void 0 : _flatItem$bundleItem13.price_type_ext;
|
|
2146
2162
|
|
|
2147
2163
|
// original_price 对应:
|
|
2148
2164
|
// 1. price_type: "markup" && price_type_ext: "product_price"
|
|
@@ -27,7 +27,8 @@ export * from "./types";
|
|
|
27
27
|
var salesSummaryDataKeys = {
|
|
28
28
|
isPriceIncludeTax: 'is_price_include_tax',
|
|
29
29
|
taxRate: 'tax_rate',
|
|
30
|
-
taxTitle: 'tax_title'
|
|
30
|
+
taxTitle: 'tax_title',
|
|
31
|
+
taxCountryCode: 'tax_country_code'
|
|
31
32
|
};
|
|
32
33
|
export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
33
34
|
_inherits(SalesSummaryModule, _BaseModule);
|
|
@@ -135,7 +136,8 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
135
136
|
return {
|
|
136
137
|
isPriceIncludeTax: this.getAppData(salesSummaryDataKeys.isPriceIncludeTax),
|
|
137
138
|
taxRate: this.getAppData(salesSummaryDataKeys.taxRate),
|
|
138
|
-
taxTitle: this.getAppData(salesSummaryDataKeys.taxTitle)
|
|
139
|
+
taxTitle: this.getAppData(salesSummaryDataKeys.taxTitle),
|
|
140
|
+
taxCountryCode: this.getAppData(salesSummaryDataKeys.taxCountryCode)
|
|
139
141
|
};
|
|
140
142
|
}
|
|
141
143
|
}, {
|