@pisell/pisellos 2.2.178 → 2.2.180
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/Customer/index.d.ts +0 -6
- package/dist/modules/Customer/index.js +83 -129
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.d.ts +4 -2
- package/dist/modules/Discount/index.js +93 -8
- package/dist/modules/Discount/types.d.ts +7 -1
- package/dist/modules/Order/index.d.ts +17 -87
- package/dist/modules/Order/index.js +501 -1357
- package/dist/modules/Order/types.d.ts +19 -198
- package/dist/modules/Order/types.js +0 -31
- package/dist/modules/Order/utils.d.ts +1 -50
- package/dist/modules/Order/utils.js +32 -261
- package/dist/modules/Quotation/index.d.ts +1 -0
- package/dist/modules/Quotation/index.js +21 -23
- package/dist/modules/Rules/index.d.ts +0 -4
- package/dist/modules/Rules/index.js +10 -26
- package/dist/modules/SalesSummary/index.js +2 -4
- package/dist/modules/SalesSummary/utils.js +7 -21
- package/dist/modules/Schedule/index.js +2 -6
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +1 -2
- package/dist/server/index.js +29 -87
- package/dist/server/modules/order/index.d.ts +0 -23
- package/dist/server/modules/order/index.js +46 -123
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/server/modules/order/utils/filterOrders.js +6 -20
- package/dist/server/modules/products/index.d.ts +1 -1
- package/dist/server/modules/products/index.js +113 -130
- package/dist/server/modules/schedule/index.js +6 -13
- package/dist/solution/BaseSales/index.d.ts +7 -89
- package/dist/solution/BaseSales/index.js +375 -1494
- package/dist/solution/BaseSales/types.d.ts +1 -67
- package/dist/solution/BaseSales/types.js +1 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -68
- package/dist/solution/BaseSales/utils.js +8 -46
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -133
- package/dist/solution/BookingTicket/index.js +175 -780
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/BookingTicket/types.js +0 -3
- package/dist/solution/BookingTicket/utils/cartView.js +2 -4
- package/dist/solution/ScanOrder/index.d.ts +3 -9
- package/dist/solution/ScanOrder/index.js +128 -231
- package/dist/solution/ScanOrder/utils.js +8 -46
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +23 -18
- package/dist/solution/VenueBooking/index.d.ts +9 -5
- package/dist/solution/VenueBooking/index.js +55 -103
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Customer/index.d.ts +0 -6
- package/lib/modules/Customer/index.js +11 -26
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.d.ts +4 -2
- package/lib/modules/Discount/index.js +63 -8
- package/lib/modules/Discount/types.d.ts +7 -1
- package/lib/modules/Order/index.d.ts +17 -87
- package/lib/modules/Order/index.js +150 -677
- package/lib/modules/Order/types.d.ts +19 -198
- package/lib/modules/Order/types.js +0 -1
- package/lib/modules/Order/utils.d.ts +1 -50
- package/lib/modules/Order/utils.js +22 -229
- package/lib/modules/Quotation/index.d.ts +1 -0
- package/lib/modules/Quotation/index.js +15 -18
- package/lib/modules/Rules/index.d.ts +0 -4
- package/lib/modules/Rules/index.js +14 -22
- package/lib/modules/SalesSummary/index.js +2 -4
- package/lib/modules/SalesSummary/utils.js +7 -21
- package/lib/modules/Schedule/index.js +1 -3
- package/lib/modules/index.d.ts +0 -1
- package/lib/modules/index.js +1 -3
- package/lib/server/index.js +4 -41
- package/lib/server/modules/order/index.d.ts +0 -23
- package/lib/server/modules/order/index.js +14 -46
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/server/modules/order/utils/filterOrders.js +4 -12
- package/lib/server/modules/products/index.d.ts +1 -1
- package/lib/server/modules/products/index.js +20 -30
- package/lib/server/modules/schedule/index.js +1 -2
- package/lib/solution/BaseSales/index.d.ts +7 -89
- package/lib/solution/BaseSales/index.js +22 -736
- package/lib/solution/BaseSales/types.d.ts +1 -67
- package/lib/solution/BaseSales/types.js +1 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +12 -71
- package/lib/solution/BaseSales/utils.js +6 -46
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -133
- package/lib/solution/BookingTicket/index.js +8 -352
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/BookingTicket/types.js +0 -6
- package/lib/solution/BookingTicket/utils/cartView.js +2 -4
- package/lib/solution/ScanOrder/index.d.ts +3 -9
- package/lib/solution/ScanOrder/index.js +66 -147
- package/lib/solution/ScanOrder/utils.js +6 -46
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +4 -2
- package/lib/solution/VenueBooking/index.d.ts +9 -5
- package/lib/solution/VenueBooking/index.js +14 -50
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/package.json +2 -2
- package/dist/modules/BookingContext/index.d.ts +0 -37
- package/dist/modules/BookingContext/index.js +0 -436
- package/dist/modules/BookingContext/types.d.ts +0 -102
- package/dist/modules/BookingContext/types.js +0 -51
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
- package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/dist/modules/BookingContext/utils/flexible.js +0 -56
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
- package/dist/modules/BookingContext/utils/index.d.ts +0 -11
- package/dist/modules/BookingContext/utils/index.js +0 -11
- package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/dist/modules/BookingContext/utils/noResource.js +0 -77
- package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/dist/modules/BookingContext/utils/productExtend.js +0 -339
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
- package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
- package/dist/modules/BookingContext/utils/resources.js +0 -486
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
- package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1258
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
- package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
- package/lib/modules/BookingContext/index.d.ts +0 -37
- package/lib/modules/BookingContext/index.js +0 -297
- package/lib/modules/BookingContext/types.d.ts +0 -102
- package/lib/modules/BookingContext/types.js +0 -34
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
- package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/lib/modules/BookingContext/utils/flexible.js +0 -80
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
- package/lib/modules/BookingContext/utils/index.d.ts +0 -11
- package/lib/modules/BookingContext/utils/index.js +0 -43
- package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/lib/modules/BookingContext/utils/noResource.js +0 -90
- package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/lib/modules/BookingContext/utils/productExtend.js +0 -283
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
- package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
- package/lib/modules/BookingContext/utils/resources.js +0 -377
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
- package/lib/solution/BaseSales/utils/cartPromotion.js +0 -836
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
- package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
|
@@ -1,9 +1,10 @@
|
|
|
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"],
|
|
3
|
+
_excluded3 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "shop_full_order_number", "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); }
|
|
7
8
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
9
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
10
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
@@ -13,7 +14,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
13
14
|
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; }
|
|
14
15
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
15
16
|
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,128 +113,6 @@ 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
|
-
}
|
|
238
116
|
export function createDefaultOrderRulesHooks() {
|
|
239
117
|
var toUnitPriceString = function toUnitPriceString(totalLike, num) {
|
|
240
118
|
var effectiveNum = Number(num) > 0 ? Number(num) : 1;
|
|
@@ -242,7 +120,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
242
120
|
};
|
|
243
121
|
return {
|
|
244
122
|
getProduct: function getProduct(product) {
|
|
245
|
-
var _product$metadata, _product$metadata2, _product$metadata3, _product$metadata4, _product$metadata5,
|
|
123
|
+
var _product$metadata, _product$metadata2, _product$metadata3, _product$metadata4, _product$metadata5, _product$metadata6;
|
|
246
124
|
// source_product_price 是权威源;兜底链:source → mainSelling − options(反推)→ 行 selling_price
|
|
247
125
|
var metadataAny = product.metadata || {};
|
|
248
126
|
var optionSum = sumOptionUnitPrice(product.product_option_item);
|
|
@@ -267,7 +145,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
267
145
|
id: product.product_id,
|
|
268
146
|
// Rules 引擎用 _id 作为 processedProductsMap 键;必须与购物车行级 identity 一致,
|
|
269
147
|
// 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
|
|
270
|
-
// 不透明 identity 契约下,normalizeOrderProduct /
|
|
148
|
+
// 不透明 identity 契约下,normalizeOrderProduct / restoreTempOrderFromStorage 已保证唯一值存在;
|
|
271
149
|
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
272
150
|
_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)),
|
|
273
151
|
// Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
|
|
@@ -283,14 +161,9 @@ export function createDefaultOrderRulesHooks() {
|
|
|
283
161
|
bundle: product.product_bundle || [],
|
|
284
162
|
booking_id: ((_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.booking_id) || null,
|
|
285
163
|
isClient: false,
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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
|
|
164
|
+
isManualDiscount: ((_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.is_manual_discount) || false,
|
|
165
|
+
holder_id: (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.holder_id,
|
|
166
|
+
startDate: ((_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.start_date) || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.startDate)
|
|
294
167
|
};
|
|
295
168
|
},
|
|
296
169
|
setProduct: function setProduct(product, values) {
|
|
@@ -323,14 +196,9 @@ export function createDefaultOrderRulesHooks() {
|
|
|
323
196
|
bundle: nextBundle,
|
|
324
197
|
useOriginalBundle: true
|
|
325
198
|
});
|
|
326
|
-
var finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
|
|
327
|
-
num: nextNum,
|
|
328
|
-
metadata: metadataAny,
|
|
329
|
-
lineOriginalPrice: product.original_price
|
|
330
|
-
}, composedOriginalPrice);
|
|
331
199
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
332
200
|
selling_price: composedSellingPrice,
|
|
333
|
-
original_price:
|
|
201
|
+
original_price: composedOriginalPrice,
|
|
334
202
|
discount_list: (_values$discount_list = values.discount_list) !== null && _values$discount_list !== void 0 ? _values$discount_list : product.discount_list,
|
|
335
203
|
num: (_values$quantity2 = values.quantity) !== null && _values$quantity2 !== void 0 ? _values$quantity2 : product.num,
|
|
336
204
|
product_bundle: nextBundle,
|
|
@@ -526,11 +394,6 @@ function normalizeSubmitProduct(product) {
|
|
|
526
394
|
var num = submitProduct.num,
|
|
527
395
|
productOptionItem = submitProduct.product_option_item,
|
|
528
396
|
_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,
|
|
534
397
|
productRest = _objectWithoutProperties(submitProduct, _excluded2);
|
|
535
398
|
var rawMetadata = submitProduct.metadata || {};
|
|
536
399
|
var bookingUid = rawMetadata.booking_uid;
|
|
@@ -560,7 +423,7 @@ function normalizeSubmitProduct(product) {
|
|
|
560
423
|
} : {}), {}, {
|
|
561
424
|
product_quantity: toBundleNumber(num !== null && num !== void 0 ? num : submitProduct.product_quantity, 1),
|
|
562
425
|
product_sku: productSku,
|
|
563
|
-
discount_list:
|
|
426
|
+
discount_list: submitProduct.discount_list || [],
|
|
564
427
|
product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
|
|
565
428
|
metadata: cleanMetadata,
|
|
566
429
|
// 出站兼容:后端消费 payment_price 字段,这里从 selling_price 直接派生。
|
|
@@ -639,23 +502,22 @@ export function createDefaultTempOrder(params) {
|
|
|
639
502
|
return {
|
|
640
503
|
order_id: null,
|
|
641
504
|
external_sale_number: '',
|
|
642
|
-
order_number:
|
|
643
|
-
shop_order_number:
|
|
644
|
-
shop_full_order_number:
|
|
645
|
-
type: '',
|
|
646
|
-
business_code:
|
|
505
|
+
order_number: '',
|
|
506
|
+
shop_order_number: '',
|
|
507
|
+
shop_full_order_number: '',
|
|
508
|
+
type: 'appointment_booking',
|
|
509
|
+
business_code: 'appointment_booking',
|
|
647
510
|
platform: 'h5',
|
|
648
511
|
sales_channel: 'my_pisel',
|
|
649
512
|
order_sales_channel: 'online_store',
|
|
650
513
|
status: 'normal',
|
|
651
514
|
payment_status: 'payment_processing',
|
|
652
515
|
shipping_status: 'unfulfilled',
|
|
653
|
-
customer_id:
|
|
516
|
+
customer_id: null,
|
|
654
517
|
customer_name: '',
|
|
655
518
|
country_calling_code: '',
|
|
656
519
|
phone: '',
|
|
657
520
|
email: '',
|
|
658
|
-
customer: null,
|
|
659
521
|
is_price_include_tax: 1,
|
|
660
522
|
tax_title: '',
|
|
661
523
|
tax_country_code: '',
|
|
@@ -670,10 +532,12 @@ export function createDefaultTempOrder(params) {
|
|
|
670
532
|
schedule_date: params.now,
|
|
671
533
|
created_at: params.now,
|
|
672
534
|
request_unique_idempotency_token: '',
|
|
535
|
+
vouchers: [],
|
|
673
536
|
products: [],
|
|
674
537
|
bookings: [],
|
|
675
538
|
payments: [],
|
|
676
539
|
surcharges: [],
|
|
540
|
+
discount_list: [],
|
|
677
541
|
relation_forms: [],
|
|
678
542
|
contacts: [],
|
|
679
543
|
contacts_info: null,
|
|
@@ -685,7 +549,7 @@ export function createDefaultTempOrder(params) {
|
|
|
685
549
|
};
|
|
686
550
|
}
|
|
687
551
|
export function buildSubmitPayload(params) {
|
|
688
|
-
var
|
|
552
|
+
var _ref10, _ref11, _ref12, _tempOrder$is_price_i, _tempOrder$is_deposit;
|
|
689
553
|
var tempOrder = params.tempOrder,
|
|
690
554
|
cacheId = params.cacheId,
|
|
691
555
|
_params$now = params.now,
|
|
@@ -710,35 +574,20 @@ export function buildSubmitPayload(params) {
|
|
|
710
574
|
_shopServiceType = _ref9.shop_service_type,
|
|
711
575
|
_startTime = _ref9.start_time,
|
|
712
576
|
_customer = _ref9.customer,
|
|
713
|
-
|
|
577
|
+
_shopFullOrderNumber = _ref9.shop_full_order_number,
|
|
714
578
|
_rootTaxFee = _ref9.tax_fee,
|
|
715
579
|
_totalAmount = _ref9.total_amount,
|
|
716
580
|
_totalRefundAmount = _ref9.total_refund_amount,
|
|
717
581
|
_createDate = _ref9.create_date,
|
|
718
582
|
_holderId = _ref9.holder_id,
|
|
719
583
|
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
|
-
}
|
|
730
584
|
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,
|
|
736
585
|
platform: normalizeSubmitPlatform(platform),
|
|
737
586
|
request_unique_idempotency_token: tempOrder.request_unique_idempotency_token || "".concat(tempOrder.external_sale_number, "_").concat(now.getTime()),
|
|
738
|
-
type:
|
|
739
|
-
business_code: businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code,
|
|
587
|
+
type: (_ref10 = type !== null && type !== void 0 ? type : tempOrder.type) !== null && _ref10 !== void 0 ? _ref10 : 'table-order',
|
|
588
|
+
business_code: (_ref11 = businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code) !== null && _ref11 !== void 0 ? _ref11 : 'table-order',
|
|
740
589
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
741
|
-
order_sales_channel: (
|
|
590
|
+
order_sales_channel: (_ref12 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref12 !== void 0 ? _ref12 : 'online_store',
|
|
742
591
|
status: tempOrder.status || 'normal',
|
|
743
592
|
payment_status: tempOrder.payment_status || 'payment_processing',
|
|
744
593
|
// shipping_status: tempOrder.shipping_status || 'unfulfilled',
|
|
@@ -751,23 +600,25 @@ export function buildSubmitPayload(params) {
|
|
|
751
600
|
note: tempOrder.note || '',
|
|
752
601
|
delivery_type: tempOrder.delivery_type || 'nil',
|
|
753
602
|
schedule_date: scheduleDate,
|
|
754
|
-
|
|
603
|
+
created_at: tempOrder.created_at || formatDateTime(now),
|
|
755
604
|
bookings: (tempOrder.bookings || []).filter(function (booking) {
|
|
756
|
-
|
|
605
|
+
var _parent_id;
|
|
606
|
+
return Number((_parent_id = booking.parent_id) !== null && _parent_id !== void 0 ? _parent_id : 0) !== 0;
|
|
757
607
|
}).map(function (booking) {
|
|
758
608
|
return normalizeSubmitBooking(booking);
|
|
759
609
|
}),
|
|
760
610
|
payments: tempOrder.payments || [],
|
|
611
|
+
// discount_list: tempOrder.discount_list || [],
|
|
761
612
|
relation_forms: tempOrder.relation_forms || [],
|
|
762
613
|
// contacts: tempOrder.contacts || [],
|
|
763
614
|
contacts_info: tempOrder.contacts_info && !Array.isArray(tempOrder.contacts_info) ? tempOrder.contacts_info : null,
|
|
764
615
|
// holder: tempOrder.holder || null,
|
|
765
616
|
// summary,
|
|
766
617
|
metadata: function () {
|
|
767
|
-
var
|
|
768
|
-
_collectPax =
|
|
769
|
-
_tableOccupancyDuration =
|
|
770
|
-
rest = _objectWithoutProperties(
|
|
618
|
+
var _ref13 = tempOrder.metadata || {},
|
|
619
|
+
_collectPax = _ref13.collect_pax,
|
|
620
|
+
_tableOccupancyDuration = _ref13.table_occupancy_duration,
|
|
621
|
+
rest = _objectWithoutProperties(_ref13, _excluded4);
|
|
771
622
|
return _objectSpread({}, rest);
|
|
772
623
|
}(),
|
|
773
624
|
products: (tempOrder.products || []).map(function (product) {
|
|
@@ -862,84 +713,4 @@ export function formatV1Product(products) {
|
|
|
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";
|
|
716
|
+
export { createEmptySummary } from "../../solution/ScanOrder/utils";
|
|
@@ -47,6 +47,7 @@ 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;
|
|
50
51
|
private isQuotationVisibleForCustomer;
|
|
51
52
|
private hasValidCustomerId;
|
|
52
53
|
private isQuotationActiveAt;
|
|
@@ -78,21 +78,22 @@ 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);
|
|
81
82
|
if ((params === null || params === void 0 ? void 0 : params.channel) === 'online_store') {
|
|
82
83
|
query.channel = 'online-store';
|
|
83
84
|
}
|
|
84
|
-
_context2.next =
|
|
85
|
+
_context2.next = 6;
|
|
85
86
|
return this.request.get('/quotation/available', query, {
|
|
86
87
|
useCache: false
|
|
87
88
|
});
|
|
88
|
-
case
|
|
89
|
+
case 6:
|
|
89
90
|
res = _context2.sent;
|
|
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) || [];
|
|
91
|
+
list = this.filterQuotationsByCustomer((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) || [], params === null || params === void 0 ? void 0 : params.customer_id);
|
|
91
92
|
list.sort(function (a, b) {
|
|
92
93
|
return a.sort - b.sort;
|
|
93
94
|
});
|
|
94
95
|
this.store.list = list;
|
|
95
|
-
case
|
|
96
|
+
case 10:
|
|
96
97
|
case "end":
|
|
97
98
|
return _context2.stop();
|
|
98
99
|
}
|
|
@@ -129,10 +130,8 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
129
130
|
try {
|
|
130
131
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
131
132
|
var quotation = _step.value;
|
|
132
|
-
|
|
133
|
-
if (!
|
|
134
|
-
var active = this.isQuotationActiveAt(quotation, datetime);
|
|
135
|
-
if (!active) continue;
|
|
133
|
+
if (!this.isQuotationVisibleForCustomer(quotation, customer_id)) continue;
|
|
134
|
+
if (!this.isQuotationActiveAt(quotation, datetime)) continue;
|
|
136
135
|
var match = this.findProductData(quotation.product_data, productId, variantId);
|
|
137
136
|
if (!match) continue;
|
|
138
137
|
if (match.value === 0) continue;
|
|
@@ -219,6 +218,14 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
219
218
|
value: function setScheduleResolver(resolver) {
|
|
220
219
|
this.scheduleResolver = resolver;
|
|
221
220
|
}
|
|
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
|
+
}
|
|
222
229
|
}, {
|
|
223
230
|
key: "isQuotationVisibleForCustomer",
|
|
224
231
|
value: function isQuotationVisibleForCustomer(quotation, customerId) {
|
|
@@ -239,27 +246,18 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
239
246
|
key: "isQuotationActiveAt",
|
|
240
247
|
value: function isQuotationActiveAt(quotation, datetime) {
|
|
241
248
|
var _quotation$schedule,
|
|
242
|
-
|
|
249
|
+
_this3 = this;
|
|
243
250
|
if (!((_quotation$schedule = quotation.schedule) !== null && _quotation$schedule !== void 0 && _quotation$schedule.length)) return false;
|
|
244
|
-
var scheduleItems =
|
|
245
|
-
|
|
246
|
-
var
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
scheduleItems.push(full);
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
if (_this2.scheduleResolver) {
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
var fallbackSchedule = _objectSpread(_objectSpread({}, s), {}, {
|
|
251
|
+
var scheduleItems = quotation.schedule.map(function (s) {
|
|
252
|
+
var _this3$scheduleResolv;
|
|
253
|
+
var full = (_this3$scheduleResolv = _this3.scheduleResolver) === null || _this3$scheduleResolv === void 0 ? void 0 : _this3$scheduleResolv.call(_this3, s.id);
|
|
254
|
+
if (full) return full;
|
|
255
|
+
return _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);
|
|
261
260
|
});
|
|
262
|
-
if (!scheduleItems.length) return false;
|
|
263
261
|
return getDateIsInSchedule(datetime, scheduleItems);
|
|
264
262
|
}
|
|
265
263
|
}, {
|
|
@@ -32,10 +32,6 @@ 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[];
|
|
39
35
|
private getUnavailableReason;
|
|
40
36
|
calcDiscount({ discountList, productList, holders, isFormSubject, orderTotalAmount }: {
|
|
41
37
|
discountList: Discount[];
|
|
@@ -222,22 +222,6 @@ 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
|
-
}
|
|
241
225
|
// 获取券不可用的原因
|
|
242
226
|
}, {
|
|
243
227
|
key: "getUnavailableReason",
|
|
@@ -1224,7 +1208,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1224
1208
|
price: product.price,
|
|
1225
1209
|
options: restoredOptions
|
|
1226
1210
|
}), {}, {
|
|
1227
|
-
discount_list:
|
|
1211
|
+
discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1228
1212
|
}))]);
|
|
1229
1213
|
} else {
|
|
1230
1214
|
var _ref13, _product$_promotion$f, _product13, _product$origin_total;
|
|
@@ -1247,14 +1231,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1247
1231
|
main_product_selling_price: main_product_selling_price,
|
|
1248
1232
|
options: restoredOptions
|
|
1249
1233
|
}), {}, {
|
|
1250
|
-
discount_list:
|
|
1234
|
+
discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1251
1235
|
}))]);
|
|
1252
1236
|
}
|
|
1253
1237
|
} else {
|
|
1254
|
-
var _flatItem$bundleItem8
|
|
1238
|
+
var _flatItem$bundleItem8;
|
|
1255
1239
|
// bundle子商品:保存到扁平化Map
|
|
1256
1240
|
processedFlatItemsMap.set(flatItem._id, [_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1257
|
-
discount_list:
|
|
1241
|
+
discount_list: _this3.filterDiscountListByType(((_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.discount_list) || [], 'promotion'),
|
|
1258
1242
|
price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
|
|
1259
1243
|
processed: true
|
|
1260
1244
|
})]);
|
|
@@ -2085,10 +2069,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2085
2069
|
return true; // 单独购买时可用
|
|
2086
2070
|
}
|
|
2087
2071
|
if (isBundleItem) {
|
|
2088
|
-
var _flatItem$
|
|
2072
|
+
var _flatItem$bundleItem9, _flatItem$bundleItem10, _flatItem$originProdu, _flatItem$parentProdu10;
|
|
2089
2073
|
// 套餐中购买时,判断是否为原价
|
|
2090
|
-
var priceType = (_flatItem$
|
|
2091
|
-
var priceTypeExt = (_flatItem$
|
|
2074
|
+
var priceType = (_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.price_type;
|
|
2075
|
+
var priceTypeExt = (_flatItem$bundleItem10 = flatItem.bundleItem) === null || _flatItem$bundleItem10 === void 0 ? void 0 : _flatItem$bundleItem10.price_type_ext;
|
|
2092
2076
|
// 主商品id
|
|
2093
2077
|
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;
|
|
2094
2078
|
// original_price 对应:
|
|
@@ -2155,10 +2139,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2155
2139
|
return false; // 单独购买时不可用
|
|
2156
2140
|
}
|
|
2157
2141
|
if (isBundleItem) {
|
|
2158
|
-
var _flatItem$
|
|
2142
|
+
var _flatItem$bundleItem11, _flatItem$bundleItem12;
|
|
2159
2143
|
// 套餐中购买时,判断是否为原价
|
|
2160
|
-
var _priceType = (_flatItem$
|
|
2161
|
-
var _priceTypeExt = (_flatItem$
|
|
2144
|
+
var _priceType = (_flatItem$bundleItem11 = flatItem.bundleItem) === null || _flatItem$bundleItem11 === void 0 ? void 0 : _flatItem$bundleItem11.price_type;
|
|
2145
|
+
var _priceTypeExt = (_flatItem$bundleItem12 = flatItem.bundleItem) === null || _flatItem$bundleItem12 === void 0 ? void 0 : _flatItem$bundleItem12.price_type_ext;
|
|
2162
2146
|
|
|
2163
2147
|
// original_price 对应:
|
|
2164
2148
|
// 1. price_type: "markup" && price_type_ext: "product_price"
|
|
@@ -27,8 +27,7 @@ export * from "./types";
|
|
|
27
27
|
var salesSummaryDataKeys = {
|
|
28
28
|
isPriceIncludeTax: 'is_price_include_tax',
|
|
29
29
|
taxRate: 'tax_rate',
|
|
30
|
-
taxTitle: 'tax_title'
|
|
31
|
-
taxCountryCode: 'tax_country_code'
|
|
30
|
+
taxTitle: 'tax_title'
|
|
32
31
|
};
|
|
33
32
|
export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
34
33
|
_inherits(SalesSummaryModule, _BaseModule);
|
|
@@ -136,8 +135,7 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
136
135
|
return {
|
|
137
136
|
isPriceIncludeTax: this.getAppData(salesSummaryDataKeys.isPriceIncludeTax),
|
|
138
137
|
taxRate: this.getAppData(salesSummaryDataKeys.taxRate),
|
|
139
|
-
taxTitle: this.getAppData(salesSummaryDataKeys.taxTitle)
|
|
140
|
-
taxCountryCode: this.getAppData(salesSummaryDataKeys.taxCountryCode)
|
|
138
|
+
taxTitle: this.getAppData(salesSummaryDataKeys.taxTitle)
|
|
141
139
|
};
|
|
142
140
|
}
|
|
143
141
|
}, {
|