@pisell/pisellos 2.2.148 → 2.2.149
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/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +2 -0
- package/dist/model/strategy/adapter/index.js +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +483 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +382 -0
- package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/dist/model/strategy/adapter/itemRule/index.js +5 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +22 -1
- package/dist/modules/Cart/utils/changePrice.js +6 -0
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +16 -8
- package/dist/modules/Date/types.d.ts +3 -1
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +171 -1
- package/dist/modules/Order/index.js +2052 -112
- package/dist/modules/Order/types.d.ts +441 -20
- package/dist/modules/Order/types.js +23 -0
- package/dist/modules/Order/utils.d.ts +120 -0
- package/dist/modules/Order/utils.js +653 -2
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Quotation/index.d.ts +8 -1
- package/dist/modules/Quotation/index.js +40 -10
- package/dist/modules/Quotation/types.d.ts +5 -0
- package/dist/modules/Rules/index.d.ts +3 -1
- package/dist/modules/Rules/index.js +136 -50
- package/dist/modules/Rules/types.d.ts +6 -0
- package/dist/modules/Rules/types.js +8 -0
- package/dist/modules/SalesSummary/index.d.ts +70 -0
- package/dist/modules/SalesSummary/index.js +175 -0
- package/dist/modules/SalesSummary/types.d.ts +64 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +34 -0
- package/dist/modules/SalesSummary/utils.js +488 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
- package/dist/modules/ScanOrderLogger/index.js +161 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +203 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +52 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +7 -7
- package/dist/modules/Schedule/index.d.ts +4 -13
- package/dist/modules/Schedule/index.js +6 -23
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/index.d.ts +3 -0
- package/dist/modules/Summary/index.js +134 -15
- package/dist/modules/Summary/types.d.ts +7 -0
- package/dist/modules/Summary/utils.d.ts +104 -1
- package/dist/modules/Summary/utils.js +1116 -13
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/server/index.d.ts +41 -4
- package/dist/server/index.js +900 -405
- package/dist/server/modules/order/index.d.ts +10 -2
- package/dist/server/modules/order/index.js +246 -193
- package/dist/server/modules/products/index.d.ts +26 -0
- package/dist/server/modules/products/index.js +618 -338
- package/dist/server/modules/products/types.d.ts +5 -1
- package/dist/solution/BaseSales/index.d.ts +175 -0
- package/dist/solution/BaseSales/index.js +1293 -0
- package/dist/solution/BaseSales/types.d.ts +305 -0
- package/dist/solution/BaseSales/types.js +38 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +159 -0
- package/dist/solution/BaseSales/utils.d.ts +40 -0
- package/dist/solution/BaseSales/utils.js +222 -0
- package/dist/solution/BookingByStep/index.d.ts +14 -0
- package/dist/solution/BookingByStep/index.js +699 -212
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingByStep/utils/capacity.js +1 -1
- package/dist/solution/BookingByStep/utils/resources.js +6 -1
- package/dist/solution/BookingTicket/index.d.ts +113 -15
- package/dist/solution/BookingTicket/index.js +534 -196
- package/dist/solution/BookingTicket/types.d.ts +69 -6
- package/dist/solution/BookingTicket/types.js +40 -9
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +66 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/dist/solution/BookingTicket/utils/cartView.js +84 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +1 -0
- package/dist/solution/ScanOrder/index.d.ts +146 -0
- package/dist/solution/ScanOrder/index.js +3029 -0
- package/dist/solution/ScanOrder/types.d.ts +305 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +167 -0
- package/dist/solution/ScanOrder/utils.js +768 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +9 -5
- package/dist/solution/ShopDiscount/types.d.ts +4 -0
- package/dist/solution/VenueBooking/index.d.ts +197 -0
- package/dist/solution/VenueBooking/index.js +3411 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +153 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/dist/solution/VenueBooking/utils/resource.js +130 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +224 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +3 -0
- package/dist/solution/index.js +4 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/strategy/adapter/index.d.ts +2 -0
- package/lib/model/strategy/adapter/index.js +6 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +377 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +316 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +60 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +17 -1
- package/lib/modules/Cart/utils/changePrice.js +5 -0
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +7 -1
- package/lib/modules/Date/types.d.ts +3 -1
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +171 -1
- package/lib/modules/Order/index.js +1396 -5
- package/lib/modules/Order/types.d.ts +441 -20
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils.d.ts +120 -0
- package/lib/modules/Order/utils.js +562 -2
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +8 -1
- package/lib/modules/Quotation/index.js +33 -4
- package/lib/modules/Quotation/types.d.ts +5 -0
- package/lib/modules/Rules/index.d.ts +3 -1
- package/lib/modules/Rules/index.js +46 -6
- package/lib/modules/Rules/types.d.ts +6 -0
- package/lib/modules/Rules/types.js +11 -2
- package/lib/modules/SalesSummary/index.d.ts +70 -0
- package/lib/modules/SalesSummary/index.js +106 -0
- package/lib/modules/SalesSummary/types.d.ts +64 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +34 -0
- package/lib/modules/SalesSummary/utils.js +430 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
- package/lib/modules/ScanOrderLogger/index.js +135 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +148 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +52 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +5 -5
- package/lib/modules/Schedule/index.d.ts +4 -13
- package/lib/modules/Schedule/index.js +4 -15
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/index.d.ts +3 -0
- package/lib/modules/Summary/index.js +61 -2
- package/lib/modules/Summary/types.d.ts +7 -0
- package/lib/modules/Summary/utils.d.ts +104 -1
- package/lib/modules/Summary/utils.js +659 -8
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/server/index.d.ts +41 -4
- package/lib/server/index.js +272 -10
- package/lib/server/modules/order/index.d.ts +10 -2
- package/lib/server/modules/order/index.js +26 -1
- package/lib/server/modules/products/index.d.ts +26 -0
- package/lib/server/modules/products/index.js +174 -22
- package/lib/server/modules/products/types.d.ts +5 -1
- package/lib/solution/BaseSales/index.d.ts +175 -0
- package/lib/solution/BaseSales/index.js +655 -0
- package/lib/solution/BaseSales/types.d.ts +305 -0
- package/lib/solution/BaseSales/types.js +40 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
- package/lib/solution/BaseSales/utils.d.ts +40 -0
- package/lib/solution/BaseSales/utils.js +200 -0
- package/lib/solution/BookingByStep/index.d.ts +14 -0
- package/lib/solution/BookingByStep/index.js +469 -91
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingByStep/utils/capacity.js +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +5 -2
- package/lib/solution/BookingTicket/index.d.ts +113 -15
- package/lib/solution/BookingTicket/index.js +253 -61
- package/lib/solution/BookingTicket/types.d.ts +69 -6
- package/lib/solution/BookingTicket/types.js +16 -14
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +65 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/lib/solution/BookingTicket/utils/cartView.js +103 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.d.ts +146 -0
- package/lib/solution/ScanOrder/index.js +1820 -0
- package/lib/solution/ScanOrder/types.d.ts +305 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +167 -0
- package/lib/solution/ScanOrder/utils.js +639 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +9 -4
- package/lib/solution/ShopDiscount/types.d.ts +4 -0
- package/lib/solution/VenueBooking/index.d.ts +197 -0
- package/lib/solution/VenueBooking/index.js +1892 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +153 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/lib/solution/VenueBooking/utils/resource.js +91 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +225 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +3 -0
- package/lib/solution/index.js +7 -1
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
5
5
|
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; }
|
|
6
6
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
8
9
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
10
|
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
11
|
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); }
|
|
@@ -28,6 +29,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
28
29
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
29
30
|
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); }
|
|
30
31
|
import { BaseModule } from "../BaseModule";
|
|
32
|
+
import { UnavailableReason } from "./types";
|
|
31
33
|
import { uniqueById, getDiscountAmount, getDiscountListAmountTotal, getDiscountListAmount, filterDiscountListByBookingTime } from "../../solution/ShopDiscount/utils";
|
|
32
34
|
import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils";
|
|
33
35
|
import Decimal from 'decimal.js';
|
|
@@ -120,7 +122,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
120
122
|
if (!product.isNeedHolder) return true;
|
|
121
123
|
// 商品需要holder,但父预约及商品都无holder,返回false
|
|
122
124
|
if (!orderHolderId && !productHolderId) return false;
|
|
123
|
-
|
|
124
125
|
// 最终直接匹配 holder 是否相同
|
|
125
126
|
return (productHolderId || orderHolderId) === discount.holder.holder_id;
|
|
126
127
|
}
|
|
@@ -154,7 +155,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
154
155
|
return {
|
|
155
156
|
isAvailable: false,
|
|
156
157
|
discountList: oldDiscountList,
|
|
157
|
-
productList: productList
|
|
158
|
+
productList: productList,
|
|
159
|
+
unavailableReason: UnavailableReason.AlreadyUsed
|
|
158
160
|
};
|
|
159
161
|
}
|
|
160
162
|
|
|
@@ -200,10 +202,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
200
202
|
}
|
|
201
203
|
}
|
|
202
204
|
});
|
|
205
|
+
|
|
206
|
+
// 如果券不可用,判断不可用原因
|
|
207
|
+
var unavailableReason;
|
|
208
|
+
if (!hasApplicableDiscount) {
|
|
209
|
+
unavailableReason = this.getUnavailableReason(newDiscountList, productList);
|
|
210
|
+
}
|
|
203
211
|
return {
|
|
204
212
|
isAvailable: hasApplicableDiscount,
|
|
205
213
|
discountList: hasApplicableDiscount ? result.discountList : oldDiscountList,
|
|
206
|
-
productList: hasApplicableDiscount ? result.productList : productList
|
|
214
|
+
productList: hasApplicableDiscount ? result.productList : productList,
|
|
215
|
+
unavailableReason: unavailableReason
|
|
207
216
|
};
|
|
208
217
|
}
|
|
209
218
|
}, {
|
|
@@ -213,6 +222,79 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
213
222
|
return item.type === type || item.tag === type;
|
|
214
223
|
});
|
|
215
224
|
}
|
|
225
|
+
// 获取券不可用的原因
|
|
226
|
+
}, {
|
|
227
|
+
key: "getUnavailableReason",
|
|
228
|
+
value: function getUnavailableReason(discountList, productList) {
|
|
229
|
+
// 检查时间限制
|
|
230
|
+
var _iterator = _createForOfIteratorHelper(discountList),
|
|
231
|
+
_step;
|
|
232
|
+
try {
|
|
233
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
234
|
+
var discount = _step.value;
|
|
235
|
+
var _iterator3 = _createForOfIteratorHelper(productList),
|
|
236
|
+
_step3;
|
|
237
|
+
try {
|
|
238
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
239
|
+
var item = _step3.value;
|
|
240
|
+
var product = this.hooks.getProduct(item);
|
|
241
|
+
var bookingTime = ((product === null || product === void 0 ? void 0 : product.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss');
|
|
242
|
+
var filteredList = filterDiscountListByBookingTime([discount], bookingTime);
|
|
243
|
+
if (filteredList.length === 0) {
|
|
244
|
+
return UnavailableReason.TimeLimit;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
} catch (err) {
|
|
248
|
+
_iterator3.e(err);
|
|
249
|
+
} finally {
|
|
250
|
+
_iterator3.f();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// 检查商品适用性
|
|
255
|
+
} catch (err) {
|
|
256
|
+
_iterator.e(err);
|
|
257
|
+
} finally {
|
|
258
|
+
_iterator.f();
|
|
259
|
+
}
|
|
260
|
+
var _iterator2 = _createForOfIteratorHelper(discountList),
|
|
261
|
+
_step2;
|
|
262
|
+
try {
|
|
263
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
264
|
+
var _discount = _step2.value;
|
|
265
|
+
var limitedData = _discount.limited_relation_product_data;
|
|
266
|
+
var hasApplicableProduct = false;
|
|
267
|
+
var _iterator4 = _createForOfIteratorHelper(productList),
|
|
268
|
+
_step4;
|
|
269
|
+
try {
|
|
270
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
271
|
+
var _limitedData$product_;
|
|
272
|
+
var _item = _step4.value;
|
|
273
|
+
var _product = this.hooks.getProduct(_item);
|
|
274
|
+
if (limitedData.type === 'product_all') {
|
|
275
|
+
hasApplicableProduct = true;
|
|
276
|
+
break;
|
|
277
|
+
} else if ((_limitedData$product_ = limitedData.product_ids) !== null && _limitedData$product_ !== void 0 && _limitedData$product_.includes(_product.id)) {
|
|
278
|
+
hasApplicableProduct = true;
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
} catch (err) {
|
|
283
|
+
_iterator4.e(err);
|
|
284
|
+
} finally {
|
|
285
|
+
_iterator4.f();
|
|
286
|
+
}
|
|
287
|
+
if (!hasApplicableProduct) {
|
|
288
|
+
return UnavailableReason.ProductNotApplicable;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
} catch (err) {
|
|
292
|
+
_iterator2.e(err);
|
|
293
|
+
} finally {
|
|
294
|
+
_iterator2.f();
|
|
295
|
+
}
|
|
296
|
+
return UnavailableReason.Unknown;
|
|
297
|
+
}
|
|
216
298
|
}, {
|
|
217
299
|
key: "calcDiscount",
|
|
218
300
|
value: function calcDiscount(_ref2, options) {
|
|
@@ -568,7 +650,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
568
650
|
|
|
569
651
|
// 辅助函数:检查商品是否对某个折扣卡可用
|
|
570
652
|
var checkItemApplicableForDiscount = function checkItemApplicableForDiscount(flatItem, discount) {
|
|
571
|
-
var
|
|
653
|
+
var _product2, _product3, _product4, _flatItem$bundleItem, _flatItem$bundleItem2, _product5;
|
|
572
654
|
var product;
|
|
573
655
|
if (flatItem.type === 'main') {
|
|
574
656
|
product = flatItem.product;
|
|
@@ -587,7 +669,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
587
669
|
}
|
|
588
670
|
|
|
589
671
|
// 编辑的商品使用了优惠券不可用
|
|
590
|
-
var isAvailableProduct = flatItem.type === 'main' ? !((
|
|
672
|
+
var isAvailableProduct = flatItem.type === 'main' ? !((_product2 = product) !== null && _product2 !== void 0 && _product2.booking_id && (_product3 = product) !== null && _product3 !== void 0 && (_product3 = _product3.discount_list) !== null && _product3 !== void 0 && _product3.length && (_product4 = product) !== null && _product4 !== void 0 && (_product4 = _product4.discount_list) !== null && _product4 !== void 0 && _product4.every(function (d) {
|
|
591
673
|
return d.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(d.tag || d.type);
|
|
592
674
|
})) : !(flatItem !== null && flatItem !== void 0 && flatItem.booking_id && !!(flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem = flatItem.bundleItem) !== null && _flatItem$bundleItem !== void 0 && (_flatItem$bundleItem = _flatItem$bundleItem.discount_list) !== null && _flatItem$bundleItem !== void 0 && _flatItem$bundleItem.length) && flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem2 = flatItem.bundleItem) !== null && _flatItem$bundleItem2 !== void 0 && (_flatItem$bundleItem2 = _flatItem$bundleItem2.discount_list) !== null && _flatItem$bundleItem2 !== void 0 && _flatItem$bundleItem2.every(function (d) {
|
|
593
675
|
return d.id;
|
|
@@ -608,7 +690,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
608
690
|
var limitedData = discount.limited_relation_product_data;
|
|
609
691
|
|
|
610
692
|
// 时间限制检查
|
|
611
|
-
var timeLimit = !!filterDiscountListByBookingTime([discount], (((
|
|
693
|
+
var timeLimit = !!filterDiscountListByBookingTime([discount], (((_product5 = product) === null || _product5 === void 0 ? void 0 : _product5.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
|
|
612
694
|
if (!timeLimit) {
|
|
613
695
|
return false;
|
|
614
696
|
}
|
|
@@ -689,7 +771,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
689
771
|
// 收集该折扣卡适用的商品(排除被其他专属折扣卡占用的商品)
|
|
690
772
|
var applicableProducts = [];
|
|
691
773
|
sortedFlattenedList.forEach(function (flatItem) {
|
|
692
|
-
var _flatItem$parentProdu2;
|
|
774
|
+
var _flatItem$parentProdu2, _flatItem$parentProdu3, _product$price, _ref5, _flatItem$original_pr;
|
|
693
775
|
// 🔥 检查该商品是否被其他专属折扣卡占用
|
|
694
776
|
var occupyingDiscountId = occupiedItems.get(flatItem._id);
|
|
695
777
|
if (occupyingDiscountId !== undefined && occupyingDiscountId !== discount.id) {
|
|
@@ -713,19 +795,23 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
713
795
|
}
|
|
714
796
|
|
|
715
797
|
// 对于 bundle 子商品,quantity 需要乘以主商品的购买数量
|
|
716
|
-
var quantity = flatItem.type === 'main' ? product.quantity || 1 : (product.num || 1) * (((_flatItem$parentProdu2 = flatItem.parentProduct) === null || _flatItem$parentProdu2 === void 0 ? void 0 : _flatItem$parentProdu2.quantity) || 1);
|
|
798
|
+
var quantity = flatItem.type === 'main' ? product.num || product.quantity || 1 : (product.num || product.quantity || 1) * (((_flatItem$parentProdu2 = flatItem.parentProduct) === null || _flatItem$parentProdu2 === void 0 ? void 0 : _flatItem$parentProdu2.num) || ((_flatItem$parentProdu3 = flatItem.parentProduct) === null || _flatItem$parentProdu3 === void 0 ? void 0 : _flatItem$parentProdu3.quantity) || 1);
|
|
799
|
+
|
|
800
|
+
// 对于主商品:使用 price
|
|
801
|
+
// 对于子商品:优先使用 flatItem.original_price,否则使用 flatItem.price
|
|
802
|
+
var originalAmount = flatItem.type === 'main' ? Number((_product$price = product.price) !== null && _product$price !== void 0 ? _product$price : 0) : Number((_ref5 = (_flatItem$original_pr = flatItem.original_price) !== null && _flatItem$original_pr !== void 0 ? _flatItem$original_pr : flatItem.price) !== null && _ref5 !== void 0 ? _ref5 : 0);
|
|
717
803
|
|
|
718
804
|
// 传递 parentQuantity 用于差值处理时判断是否是真正的"数量为1"
|
|
719
805
|
var productData = {
|
|
720
806
|
productId: flatItem._id,
|
|
721
|
-
amount:
|
|
807
|
+
amount: originalAmount,
|
|
722
808
|
quantity: quantity
|
|
723
809
|
};
|
|
724
810
|
|
|
725
811
|
// 子商品需要传递主商品数量
|
|
726
812
|
if (flatItem.type === 'bundle') {
|
|
727
|
-
var _flatItem$
|
|
728
|
-
productData.parentQuantity = ((_flatItem$
|
|
813
|
+
var _flatItem$parentProdu4;
|
|
814
|
+
productData.parentQuantity = ((_flatItem$parentProdu4 = flatItem.parentProduct) === null || _flatItem$parentProdu4 === void 0 ? void 0 : _flatItem$parentProdu4.quantity) || 1;
|
|
729
815
|
}
|
|
730
816
|
applicableProducts.push(productData);
|
|
731
817
|
});
|
|
@@ -752,7 +838,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
752
838
|
product = flatItem.product;
|
|
753
839
|
originProduct = flatItem.originProduct;
|
|
754
840
|
} else {
|
|
755
|
-
var _flatItem$
|
|
841
|
+
var _flatItem$parentProdu5;
|
|
756
842
|
// bundle子商品:构造虚拟商品对象
|
|
757
843
|
product = {
|
|
758
844
|
_id: flatItem._id,
|
|
@@ -764,12 +850,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
764
850
|
origin_total: flatItem.origin_total,
|
|
765
851
|
booking_id: flatItem.booking_id,
|
|
766
852
|
discount_list: flatItem.discount_list || [],
|
|
767
|
-
startDate: (_flatItem$
|
|
853
|
+
startDate: (_flatItem$parentProdu5 = flatItem.parentProduct) === null || _flatItem$parentProdu5 === void 0 ? void 0 : _flatItem$parentProdu5.startDate
|
|
768
854
|
};
|
|
769
855
|
originProduct = flatItem.originProduct;
|
|
770
856
|
}
|
|
771
857
|
addModeDiscount.forEach(function (discount) {
|
|
772
|
-
var
|
|
858
|
+
var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config;
|
|
773
859
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
774
860
|
// 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
|
|
775
861
|
var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
|
|
@@ -778,12 +864,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
778
864
|
holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
779
865
|
}, holders);
|
|
780
866
|
var timeLimit = true;
|
|
781
|
-
timeLimit = !!filterDiscountListByBookingTime([discount], (((
|
|
867
|
+
timeLimit = !!filterDiscountListByBookingTime([discount], (((_product6 = product) === null || _product6 === void 0 ? void 0 : _product6.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
|
|
782
868
|
// 是符合折扣的商品
|
|
783
869
|
var isLimitedProduct = (limitedData.type === 'product_all' && limitedData.filter !== 1 || limitedData.type === 'product_all' && limitedData.filter === 1 && !limitedData.exclude_product_ids.includes(product.id) || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
|
|
784
870
|
|
|
785
871
|
// 编辑的商品 使用了优惠券不可用
|
|
786
|
-
var isAvailableProduct = flatItem.type === 'main' ? !((
|
|
872
|
+
var isAvailableProduct = flatItem.type === 'main' ? !((_product7 = product) !== null && _product7 !== void 0 && _product7.booking_id && (_product8 = product) !== null && _product8 !== void 0 && (_product8 = _product8.discount_list) !== null && _product8 !== void 0 && _product8.length && (_product9 = product) !== null && _product9 !== void 0 && (_product9 = _product9.discount_list) !== null && _product9 !== void 0 && _product9.every(function (discount) {
|
|
787
873
|
return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
|
|
788
874
|
})) : !(flatItem !== null && flatItem !== void 0 && flatItem.booking_id && !!(flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem3 = flatItem.bundleItem) !== null && _flatItem$bundleItem3 !== void 0 && (_flatItem$bundleItem3 = _flatItem$bundleItem3.discount_list) !== null && _flatItem$bundleItem3 !== void 0 && _flatItem$bundleItem3.length) && flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem4 = flatItem.bundleItem) !== null && _flatItem$bundleItem4 !== void 0 && (_flatItem$bundleItem4 = _flatItem$bundleItem4.discount_list) !== null && _flatItem$bundleItem4 !== void 0 && _flatItem$bundleItem4.every(function (discount) {
|
|
789
875
|
return discount.id;
|
|
@@ -841,13 +927,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
841
927
|
};
|
|
842
928
|
var optionDiscountAmount = 0;
|
|
843
929
|
var discountedOptions = options.map(function (option) {
|
|
844
|
-
var
|
|
930
|
+
var _ref6, _ref7, _option$_original_pri, _ref8, _option$num, _rest$price, _option$_original_pri2;
|
|
845
931
|
// 折前单价:优先 price,缺失再 add_price;已写回折后价时用 _original_price(或旧字段 _original_add_price)
|
|
846
|
-
var rawUnit = (
|
|
932
|
+
var rawUnit = (_ref6 = (_ref7 = (_option$_original_pri = option._original_price) !== null && _option$_original_pri !== void 0 ? _option$_original_pri : option._original_add_price) !== null && _ref7 !== void 0 ? _ref7 : option.price) !== null && _ref6 !== void 0 ? _ref6 : option.add_price;
|
|
847
933
|
var baseUnitNum = Number(rawUnit !== null && rawUnit !== void 0 ? rawUnit : 0);
|
|
848
934
|
if (baseUnitNum <= 0) return option;
|
|
849
935
|
var discountedPrice = getDiscountAmount(discount, baseUnitNum, baseUnitNum);
|
|
850
|
-
var optQty = Number((
|
|
936
|
+
var optQty = Number((_ref8 = (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity) !== null && _ref8 !== void 0 ? _ref8 : 1);
|
|
851
937
|
optionDiscountAmount = new Decimal(optionDiscountAmount).plus(new Decimal(baseUnitNum).minus(discountedPrice).mul(optQty)).toNumber();
|
|
852
938
|
var _original_add_price = option._original_add_price,
|
|
853
939
|
rest = _objectWithoutProperties(option, _excluded);
|
|
@@ -881,9 +967,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
881
967
|
var getOptionTotal = function getOptionTotal(options) {
|
|
882
968
|
if (!(options !== null && options !== void 0 && options.length)) return 0;
|
|
883
969
|
return options.reduce(function (sum, opt) {
|
|
884
|
-
var
|
|
885
|
-
var unit = Number((
|
|
886
|
-
var n = Number((
|
|
970
|
+
var _ref9, _opt$price, _ref10, _opt$num;
|
|
971
|
+
var unit = Number((_ref9 = (_opt$price = opt.price) !== null && _opt$price !== void 0 ? _opt$price : opt.add_price) !== null && _ref9 !== void 0 ? _ref9 : 0);
|
|
972
|
+
var n = Number((_ref10 = (_opt$num = opt.num) !== null && _opt$num !== void 0 ? _opt$num : opt.quantity) !== null && _ref10 !== void 0 ? _ref10 : 1);
|
|
887
973
|
return new Decimal(sum).plus(new Decimal(unit).mul(n)).toNumber();
|
|
888
974
|
}, 0);
|
|
889
975
|
};
|
|
@@ -891,14 +977,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
891
977
|
// 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
|
|
892
978
|
// 🔥 使用扁平化后的列表进行处理
|
|
893
979
|
sortedFlattenedList.forEach(function (flatItem, index) {
|
|
894
|
-
var
|
|
980
|
+
var _product10, _product$discount_lis2, _product11;
|
|
895
981
|
// 获取商品数据
|
|
896
982
|
var product, originProduct;
|
|
897
983
|
if (flatItem.type === 'main') {
|
|
898
984
|
product = flatItem.product;
|
|
899
985
|
originProduct = flatItem.originProduct;
|
|
900
986
|
} else {
|
|
901
|
-
var _flatItem$bundleItem5, _flatItem$bundleItem6, _flatItem$bundleItem7, _flatItem$
|
|
987
|
+
var _flatItem$bundleItem5, _flatItem$bundleItem6, _flatItem$bundleItem7, _flatItem$parentProdu6;
|
|
902
988
|
// bundle子商品
|
|
903
989
|
product = {
|
|
904
990
|
_id: flatItem._id,
|
|
@@ -911,13 +997,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
911
997
|
origin_total: flatItem === null || flatItem === void 0 || (_flatItem$bundleItem6 = flatItem.bundleItem) === null || _flatItem$bundleItem6 === void 0 ? void 0 : _flatItem$bundleItem6.original_price,
|
|
912
998
|
booking_id: flatItem.booking_id,
|
|
913
999
|
discount_list: (flatItem === null || flatItem === void 0 || (_flatItem$bundleItem7 = flatItem.bundleItem) === null || _flatItem$bundleItem7 === void 0 ? void 0 : _flatItem$bundleItem7.discount_list) || [],
|
|
914
|
-
startDate: (_flatItem$
|
|
1000
|
+
startDate: (_flatItem$parentProdu6 = flatItem.parentProduct) === null || _flatItem$parentProdu6 === void 0 ? void 0 : _flatItem$parentProdu6.startDate
|
|
915
1001
|
};
|
|
916
1002
|
originProduct = flatItem.originProduct;
|
|
917
1003
|
}
|
|
918
1004
|
|
|
919
1005
|
// 已有优惠的商品跳过
|
|
920
|
-
if ((
|
|
1006
|
+
if ((_product10 = product) !== null && _product10 !== void 0 && _product10.booking_id && (_product$discount_lis2 = product.discount_list) !== null && _product$discount_lis2 !== void 0 && _product$discount_lis2.length && (_product11 = product) !== null && _product11 !== void 0 && (_product11 = _product11.discount_list) !== null && _product11 !== void 0 && _product11.every(function (discount) {
|
|
921
1007
|
return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
|
|
922
1008
|
})) {
|
|
923
1009
|
if (flatItem.type === 'main') {
|
|
@@ -1014,12 +1100,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1014
1100
|
// 如果是手动折扣,则不适用优惠券
|
|
1015
1101
|
var isManualDiscount = false;
|
|
1016
1102
|
if (flatItem.type === 'main') {
|
|
1017
|
-
var _product$discount_lis5,
|
|
1103
|
+
var _product$discount_lis5, _product12, _product12$every;
|
|
1018
1104
|
// 主商品:判断自身是否手动折扣
|
|
1019
1105
|
isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && (product.bundle || []).every(function (item) {
|
|
1020
|
-
var
|
|
1021
|
-
return !((
|
|
1022
|
-
}) && (!((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length) || ((
|
|
1106
|
+
var _ref11;
|
|
1107
|
+
return !((_ref11 = item.discount_list || []) !== null && _ref11 !== void 0 && _ref11.length);
|
|
1108
|
+
}) && (!((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length) || ((_product12 = product) === null || _product12 === void 0 || (_product12 = _product12.discount_list) === null || _product12 === void 0 || (_product12$every = _product12.every) === null || _product12$every === void 0 ? void 0 : _product12$every.call(_product12, function (item) {
|
|
1023
1109
|
return item.type === 'product';
|
|
1024
1110
|
})));
|
|
1025
1111
|
if (product.inPromotion) {
|
|
@@ -1031,8 +1117,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1031
1117
|
if (parentProduct) {
|
|
1032
1118
|
var _parentProduct$discou, _parentProduct$discou2, _parentProduct$discou3;
|
|
1033
1119
|
isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
|
|
1034
|
-
var
|
|
1035
|
-
return !((
|
|
1120
|
+
var _ref12;
|
|
1121
|
+
return !((_ref12 = item.discount_list || []) !== null && _ref12 !== void 0 && _ref12.length);
|
|
1036
1122
|
}) && (!((_parentProduct$discou = parentProduct.discount_list) !== null && _parentProduct$discou !== void 0 && _parentProduct$discou.length) || (parentProduct === null || parentProduct === void 0 || (_parentProduct$discou2 = parentProduct.discount_list) === null || _parentProduct$discou2 === void 0 || (_parentProduct$discou3 = _parentProduct$discou2.every) === null || _parentProduct$discou3 === void 0 ? void 0 : _parentProduct$discou3.call(_parentProduct$discou2, function (item) {
|
|
1037
1123
|
return item.type === 'product';
|
|
1038
1124
|
})));
|
|
@@ -1051,11 +1137,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1051
1137
|
}
|
|
1052
1138
|
// bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
|
|
1053
1139
|
if (flatItem.type === 'bundle') {
|
|
1054
|
-
var _product$discount_lis7, _flatItem$
|
|
1140
|
+
var _product$discount_lis7, _flatItem$parentProdu7;
|
|
1055
1141
|
if ((_product$discount_lis7 = product.discount_list) !== null && _product$discount_lis7 !== void 0 && _product$discount_lis7.some(function (item) {
|
|
1056
1142
|
var _item$discount2;
|
|
1057
1143
|
return ((_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) === options.discountId;
|
|
1058
|
-
}) || (_flatItem$
|
|
1144
|
+
}) || (_flatItem$parentProdu7 = flatItem.parentProduct) !== null && _flatItem$parentProdu7 !== void 0 && (_flatItem$parentProdu7 = _flatItem$parentProdu7.discount_list) !== null && _flatItem$parentProdu7 !== void 0 && _flatItem$parentProdu7.some(function (item) {
|
|
1059
1145
|
var _item$discount3;
|
|
1060
1146
|
return ((_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.resource_id) === options.discountId;
|
|
1061
1147
|
})) {
|
|
@@ -1077,14 +1163,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1077
1163
|
}
|
|
1078
1164
|
// bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
|
|
1079
1165
|
if (flatItem.type === 'bundle') {
|
|
1080
|
-
var _product$discount_lis9, _flatItem$
|
|
1166
|
+
var _product$discount_lis9, _flatItem$parentProdu8;
|
|
1081
1167
|
if ((_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.some(function (item) {
|
|
1082
1168
|
var _options$selectedList2;
|
|
1083
1169
|
return options === null || options === void 0 || (_options$selectedList2 = options.selectedList) === null || _options$selectedList2 === void 0 ? void 0 : _options$selectedList2.some(function (n) {
|
|
1084
1170
|
var _item$discount5;
|
|
1085
1171
|
return n.discountId === ((_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.resource_id);
|
|
1086
1172
|
});
|
|
1087
|
-
}) || (_flatItem$
|
|
1173
|
+
}) || (_flatItem$parentProdu8 = flatItem.parentProduct) !== null && _flatItem$parentProdu8 !== void 0 && (_flatItem$parentProdu8 = _flatItem$parentProdu8.discount_list) !== null && _flatItem$parentProdu8 !== void 0 && _flatItem$parentProdu8.some(function (item) {
|
|
1088
1174
|
var _options$selectedList3;
|
|
1089
1175
|
return options === null || options === void 0 || (_options$selectedList3 = options.selectedList) === null || _options$selectedList3 === void 0 ? void 0 : _options$selectedList3.some(function (n) {
|
|
1090
1176
|
var _item$discount6;
|
|
@@ -1125,8 +1211,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1125
1211
|
discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1126
1212
|
}))]);
|
|
1127
1213
|
} else {
|
|
1128
|
-
var
|
|
1129
|
-
var total = product.inPromotion ? (
|
|
1214
|
+
var _ref13, _product$_promotion$f, _product13, _product$origin_total;
|
|
1215
|
+
var total = product.inPromotion ? (_ref13 = (_product$_promotion$f = (_product13 = product) === null || _product13 === void 0 || (_product13 = _product13._promotion) === null || _product13 === void 0 ? void 0 : _product13.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref13 !== void 0 ? _ref13 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
|
|
1130
1216
|
var main_product_selling_price = product.price;
|
|
1131
1217
|
if ((product.discount_list || []).some(function (item) {
|
|
1132
1218
|
return item.type === 'promotion';
|
|
@@ -1404,7 +1490,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1404
1490
|
}));
|
|
1405
1491
|
}
|
|
1406
1492
|
} else {
|
|
1407
|
-
var _selectedDiscount3$me, _selectedDiscount3$me2, _flatItem$
|
|
1493
|
+
var _selectedDiscount3$me, _selectedDiscount3$me2, _flatItem$parentProdu9;
|
|
1408
1494
|
// 折扣卡:不拆分数量,直接应用
|
|
1409
1495
|
var _selectedDiscount3 = selectedDiscountCard || applicableDiscounts[0];
|
|
1410
1496
|
usedDiscounts.set(_selectedDiscount3.id, true);
|
|
@@ -1457,7 +1543,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1457
1543
|
product_discount_difference: _productDiscountDifference
|
|
1458
1544
|
}),
|
|
1459
1545
|
config: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.config,
|
|
1460
|
-
_num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$
|
|
1546
|
+
_num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$parentProdu9 = flatItem.parentProduct) === null || _flatItem$parentProdu9 === void 0 ? void 0 : _flatItem$parentProdu9.num) || 1)
|
|
1461
1547
|
};
|
|
1462
1548
|
|
|
1463
1549
|
// 记录实际应用的折扣
|
|
@@ -1961,14 +2047,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1961
2047
|
var ruleType = usageRules.type;
|
|
1962
2048
|
// 套餐适用范围配置
|
|
1963
2049
|
var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
|
|
1964
|
-
var
|
|
1965
|
-
scopeType =
|
|
1966
|
-
|
|
1967
|
-
exclude_bundle_product_ids =
|
|
1968
|
-
|
|
1969
|
-
include_bundle_product_ids =
|
|
1970
|
-
|
|
1971
|
-
filter =
|
|
2050
|
+
var _ref14 = packageScope || {},
|
|
2051
|
+
scopeType = _ref14.type,
|
|
2052
|
+
_ref14$exclude_bundle = _ref14.exclude_bundle_product_ids,
|
|
2053
|
+
exclude_bundle_product_ids = _ref14$exclude_bundle === void 0 ? [] : _ref14$exclude_bundle,
|
|
2054
|
+
_ref14$include_bundle = _ref14.include_bundle_product_ids,
|
|
2055
|
+
include_bundle_product_ids = _ref14$include_bundle === void 0 ? [] : _ref14$include_bundle,
|
|
2056
|
+
_ref14$filter = _ref14.filter,
|
|
2057
|
+
filter = _ref14$filter === void 0 ? 0 : _ref14$filter;
|
|
1972
2058
|
var isMainProduct = flatItem.type === 'main'; // 单独购买
|
|
1973
2059
|
var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
|
|
1974
2060
|
|
|
@@ -1983,12 +2069,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1983
2069
|
return true; // 单独购买时可用
|
|
1984
2070
|
}
|
|
1985
2071
|
if (isBundleItem) {
|
|
1986
|
-
var _flatItem$bundleItem9, _flatItem$bundleItem10, _flatItem$originProdu, _flatItem$
|
|
2072
|
+
var _flatItem$bundleItem9, _flatItem$bundleItem10, _flatItem$originProdu, _flatItem$parentProdu10;
|
|
1987
2073
|
// 套餐中购买时,判断是否为原价
|
|
1988
2074
|
var priceType = (_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.price_type;
|
|
1989
2075
|
var priceTypeExt = (_flatItem$bundleItem10 = flatItem.bundleItem) === null || _flatItem$bundleItem10 === void 0 ? void 0 : _flatItem$bundleItem10.price_type_ext;
|
|
1990
2076
|
// 主商品id
|
|
1991
|
-
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$
|
|
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;
|
|
1992
2078
|
// original_price 对应:
|
|
1993
2079
|
// 1. price_type: "markup" && price_type_ext: "product_price"
|
|
1994
2080
|
// markup_price 对应:
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { Discount } from '../Discount/types';
|
|
2
|
+
export declare enum UnavailableReason {
|
|
3
|
+
TimeLimit = "time_limit",
|
|
4
|
+
ProductNotApplicable = "product_not_applicable",
|
|
5
|
+
AlreadyUsed = "already_used",
|
|
6
|
+
Unknown = "unknown"
|
|
7
|
+
}
|
|
2
8
|
export declare enum RulesHooks {
|
|
3
9
|
OnRulesListChange = "rules:onRulesListChange",
|
|
4
10
|
OnDestroy = "rules:onDestroy"
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
// 券不可用原因枚举
|
|
2
|
+
export var UnavailableReason = /*#__PURE__*/function (UnavailableReason) {
|
|
3
|
+
UnavailableReason["TimeLimit"] = "time_limit";
|
|
4
|
+
UnavailableReason["ProductNotApplicable"] = "product_not_applicable";
|
|
5
|
+
UnavailableReason["AlreadyUsed"] = "already_used";
|
|
6
|
+
UnavailableReason["Unknown"] = "unknown";
|
|
7
|
+
return UnavailableReason;
|
|
8
|
+
}({});
|
|
1
9
|
export var RulesHooks = /*#__PURE__*/function (RulesHooks) {
|
|
2
10
|
RulesHooks["OnRulesListChange"] = "rules:onRulesListChange";
|
|
3
11
|
RulesHooks["OnDestroy"] = "rules:onDestroy";
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import { SalesSummaryModuleAPI } from './types';
|
|
4
|
+
export * from './types';
|
|
5
|
+
export declare class SalesSummaryModule extends BaseModule implements Module, SalesSummaryModuleAPI {
|
|
6
|
+
protected defaultName: string;
|
|
7
|
+
protected defaultVersion: string;
|
|
8
|
+
private shopStore;
|
|
9
|
+
private store;
|
|
10
|
+
private request;
|
|
11
|
+
constructor(name?: string, version?: string);
|
|
12
|
+
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
13
|
+
getSurchargeList(): Promise<void>;
|
|
14
|
+
getSummary(params: {
|
|
15
|
+
products: any[];
|
|
16
|
+
isPriceIncludeTax?: number;
|
|
17
|
+
taxRate?: number;
|
|
18
|
+
shopDiscount?: string | number;
|
|
19
|
+
}): Promise<{
|
|
20
|
+
tax_title: any;
|
|
21
|
+
tax_rate: any;
|
|
22
|
+
product_quantity: number;
|
|
23
|
+
product_original_amount: string;
|
|
24
|
+
product_amount: string;
|
|
25
|
+
product_expect_amount: string;
|
|
26
|
+
product_tax_fee: string;
|
|
27
|
+
shipping_fee: string;
|
|
28
|
+
shipping_tax_fee: string;
|
|
29
|
+
tax_fee: string;
|
|
30
|
+
surcharge_fee: string;
|
|
31
|
+
surcharges: any[];
|
|
32
|
+
discount_amount: string;
|
|
33
|
+
deposit_amount: string;
|
|
34
|
+
deposit?: import("./types").DepositInfo | undefined;
|
|
35
|
+
expect_amount: string;
|
|
36
|
+
total_amount: string;
|
|
37
|
+
total_refund_amount: string;
|
|
38
|
+
customer_paid_amount: string;
|
|
39
|
+
order_paid_amount: string;
|
|
40
|
+
amount_gap: string;
|
|
41
|
+
rounding_amount: string;
|
|
42
|
+
pay_service_charge_amount: string;
|
|
43
|
+
is_price_include_tax?: number | undefined;
|
|
44
|
+
} | {
|
|
45
|
+
tax_title: any;
|
|
46
|
+
tax_rate: any;
|
|
47
|
+
product_quantity: number;
|
|
48
|
+
product_original_amount: string;
|
|
49
|
+
product_amount: string;
|
|
50
|
+
product_expect_amount: string;
|
|
51
|
+
product_tax_fee: string;
|
|
52
|
+
shipping_fee: string;
|
|
53
|
+
shipping_tax_fee: string;
|
|
54
|
+
tax_fee: string;
|
|
55
|
+
surcharge_fee: string;
|
|
56
|
+
surcharges: any;
|
|
57
|
+
discount_amount: string;
|
|
58
|
+
deposit_amount: string;
|
|
59
|
+
deposit: import("./types").DepositInfo | undefined;
|
|
60
|
+
expect_amount: string;
|
|
61
|
+
total_amount: string;
|
|
62
|
+
total_refund_amount: string;
|
|
63
|
+
customer_paid_amount: string;
|
|
64
|
+
order_paid_amount: string;
|
|
65
|
+
amount_gap: string;
|
|
66
|
+
rounding_amount: string;
|
|
67
|
+
pay_service_charge_amount: string;
|
|
68
|
+
is_price_include_tax: number;
|
|
69
|
+
}>;
|
|
70
|
+
}
|