@pisell/pisellos 2.1.172 → 2.1.174
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/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/model/strategy/adapter/promotion/evaluator.js +26 -99
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +12 -63
- package/dist/model/strategy/adapter/walletPass/locales.js +3 -12
- package/dist/model/strategy/engine.d.ts +5 -18
- package/dist/model/strategy/engine.js +45 -145
- package/dist/model/strategy/type.d.ts +0 -17
- package/dist/model/strategy/type.js +0 -4
- package/dist/modules/Cart/types.d.ts +0 -2
- package/dist/modules/Cart/utils/cartProduct.js +25 -56
- package/dist/modules/Cart/utils/changePrice.js +16 -9
- package/dist/modules/Discount/availability.d.ts +7 -0
- package/dist/modules/Discount/availability.js +52 -0
- package/dist/modules/Discount/entitlementPass.d.ts +34 -0
- package/dist/modules/Discount/entitlementPass.js +147 -0
- package/dist/modules/Discount/entitlementState.d.ts +8 -0
- package/dist/modules/Discount/entitlementState.js +205 -0
- package/dist/modules/Discount/index.d.ts +12 -3
- package/dist/modules/Discount/index.js +211 -17
- package/dist/modules/Discount/types.d.ts +42 -22
- package/dist/modules/Holder/index.d.ts +48 -0
- package/dist/modules/Holder/index.js +640 -0
- package/dist/modules/Holder/types.d.ts +123 -0
- package/dist/modules/Holder/types.js +1 -0
- package/dist/modules/Holder/utils.d.ts +13 -0
- package/dist/modules/Holder/utils.js +34 -0
- 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 +67 -1
- package/dist/modules/Order/index.js +923 -30
- package/dist/modules/Order/types.d.ts +176 -12
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +128 -0
- package/dist/modules/Order/utils.js +621 -5
- package/dist/modules/Payment/index.d.ts +1 -2
- package/dist/modules/Payment/index.js +7 -10
- package/dist/modules/Payment/utils.js +0 -3
- package/dist/modules/Payment/walletpass.d.ts +0 -23
- package/dist/modules/Payment/walletpass.js +95 -191
- package/dist/modules/Product/types.d.ts +7 -0
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -3
- package/dist/modules/Quotation/index.d.ts +48 -0
- package/dist/modules/Quotation/index.js +248 -0
- package/dist/modules/Quotation/types.d.ts +42 -0
- package/dist/modules/Quotation/types.js +1 -0
- package/dist/modules/Rules/entitlementLines.d.ts +8 -0
- package/dist/modules/Rules/entitlementLines.js +157 -0
- package/dist/modules/Rules/index.d.ts +17 -11
- package/dist/modules/Rules/index.js +495 -726
- package/dist/modules/Rules/types.d.ts +2 -4
- package/dist/modules/SalesSummary/index.d.ts +63 -0
- package/dist/modules/SalesSummary/index.js +174 -0
- package/dist/modules/SalesSummary/types.d.ts +60 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +30 -0
- package/dist/modules/SalesSummary/utils.js +480 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +23 -0
- package/dist/modules/ScanOrderLogger/index.js +174 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +221 -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 +53 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/types.d.ts +0 -2
- package/dist/modules/Summary/utils.d.ts +3 -9
- package/dist/modules/Summary/utils.js +67 -57
- package/dist/modules/index.d.ts +5 -0
- package/dist/modules/index.js +6 -1
- package/dist/plugins/window.d.ts +3 -2
- package/dist/solution/BookingByStep/index.d.ts +17 -3
- package/dist/solution/BookingByStep/index.js +322 -247
- package/dist/solution/BookingByStep/types.d.ts +4 -1
- package/dist/solution/BookingByStep/types.js +7 -1
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
- package/dist/solution/Checkout/index.js +0 -2
- package/dist/solution/ScanOrder/index.d.ts +158 -0
- package/dist/solution/ScanOrder/index.js +3474 -0
- package/dist/solution/ScanOrder/types.d.ts +307 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +172 -0
- package/dist/solution/ScanOrder/utils.js +796 -0
- package/dist/solution/ShopDiscount/index.d.ts +6 -2
- package/dist/solution/ShopDiscount/index.js +194 -110
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/solution/ShopDiscount/types.js +1 -2
- package/dist/solution/ShopDiscount/utils.d.ts +1 -0
- package/dist/solution/ShopDiscount/utils.js +52 -27
- package/dist/solution/VenueBooking/index.d.ts +225 -0
- package/dist/solution/VenueBooking/index.js +3749 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +156 -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 +131 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +239 -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 +2 -0
- package/dist/solution/index.js +3 -1
- package/dist/types/index.d.ts +1 -0
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -3
- package/lib/model/strategy/adapter/promotion/evaluator.js +8 -57
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.js +7 -36
- package/lib/model/strategy/adapter/walletPass/locales.js +3 -12
- package/lib/model/strategy/engine.d.ts +5 -18
- package/lib/model/strategy/engine.js +21 -85
- package/lib/model/strategy/type.d.ts +0 -17
- package/lib/modules/Cart/types.d.ts +0 -2
- package/lib/modules/Cart/utils/cartProduct.js +12 -39
- package/lib/modules/Cart/utils/changePrice.js +13 -9
- package/lib/modules/Discount/availability.d.ts +7 -0
- package/lib/modules/Discount/availability.js +91 -0
- package/lib/modules/Discount/entitlementPass.d.ts +34 -0
- package/lib/modules/Discount/entitlementPass.js +184 -0
- package/lib/modules/Discount/entitlementState.d.ts +8 -0
- package/lib/modules/Discount/entitlementState.js +206 -0
- package/lib/modules/Discount/index.d.ts +12 -3
- package/lib/modules/Discount/index.js +123 -12
- package/lib/modules/Discount/types.d.ts +42 -22
- package/lib/modules/Holder/index.d.ts +48 -0
- package/lib/modules/Holder/index.js +402 -0
- package/lib/modules/Holder/types.d.ts +123 -0
- package/lib/modules/Holder/types.js +17 -0
- package/lib/modules/Holder/utils.d.ts +13 -0
- package/lib/modules/Holder/utils.js +71 -0
- 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 +67 -1
- package/lib/modules/Order/index.js +529 -1
- package/lib/modules/Order/types.d.ts +176 -12
- package/lib/modules/Order/utils.d.ts +128 -0
- package/lib/modules/Order/utils.js +514 -2
- package/lib/modules/Payment/index.d.ts +1 -2
- package/lib/modules/Payment/index.js +0 -1
- package/lib/modules/Payment/utils.js +0 -3
- package/lib/modules/Payment/walletpass.d.ts +0 -23
- package/lib/modules/Payment/walletpass.js +17 -94
- package/lib/modules/Product/types.d.ts +7 -0
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +5 -4
- package/lib/modules/Quotation/index.d.ts +48 -0
- package/lib/modules/Quotation/index.js +152 -0
- package/lib/modules/Quotation/types.d.ts +42 -0
- package/lib/modules/Quotation/types.js +17 -0
- package/lib/modules/Rules/entitlementLines.d.ts +8 -0
- package/lib/modules/Rules/entitlementLines.js +158 -0
- package/lib/modules/Rules/index.d.ts +17 -11
- package/lib/modules/Rules/index.js +548 -798
- package/lib/modules/Rules/types.d.ts +2 -4
- package/lib/modules/SalesSummary/index.d.ts +63 -0
- package/lib/modules/SalesSummary/index.js +105 -0
- package/lib/modules/SalesSummary/types.d.ts +60 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +30 -0
- package/lib/modules/SalesSummary/utils.js +420 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +23 -0
- package/lib/modules/ScanOrderLogger/index.js +147 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +157 -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 +53 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/types.d.ts +0 -2
- package/lib/modules/Summary/utils.d.ts +3 -9
- package/lib/modules/Summary/utils.js +45 -34
- package/lib/modules/index.d.ts +5 -0
- package/lib/modules/index.js +11 -1
- package/lib/plugins/window.d.ts +3 -2
- package/lib/solution/BookingByStep/index.d.ts +17 -3
- package/lib/solution/BookingByStep/index.js +45 -4
- package/lib/solution/BookingByStep/types.d.ts +4 -1
- package/lib/solution/BookingByStep/types.js +15 -0
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
- package/lib/solution/Checkout/index.js +0 -2
- package/lib/solution/ScanOrder/index.d.ts +158 -0
- package/lib/solution/ScanOrder/index.js +2135 -0
- package/lib/solution/ScanOrder/types.d.ts +307 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +172 -0
- package/lib/solution/ScanOrder/utils.js +658 -0
- package/lib/solution/ShopDiscount/index.d.ts +6 -2
- package/lib/solution/ShopDiscount/index.js +94 -50
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.d.ts +1 -0
- package/lib/solution/ShopDiscount/utils.js +48 -11
- package/lib/solution/VenueBooking/index.d.ts +225 -0
- package/lib/solution/VenueBooking/index.js +2073 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +156 -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 +92 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +237 -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 +2 -0
- package/lib/solution/index.js +5 -1
- package/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
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); }
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
5
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
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
|
+
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; }
|
|
2
8
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
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."); }
|
|
4
10
|
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); }
|
|
@@ -25,6 +31,8 @@ import { uniqueById } from "../../solution/ShopDiscount/utils";
|
|
|
25
31
|
import { BaseModule } from "../BaseModule";
|
|
26
32
|
import { DiscountHooks } from "./types";
|
|
27
33
|
import Decimal from 'decimal.js';
|
|
34
|
+
import { isEntitlementPass } from "./entitlementPass";
|
|
35
|
+
import { getDiscountLifecycleReason, getDiscountUsageLimitFailKey } from "./availability";
|
|
28
36
|
export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
29
37
|
_inherits(DiscountModule, _BaseModule);
|
|
30
38
|
var _super = _createSuper(DiscountModule);
|
|
@@ -151,8 +159,8 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
151
159
|
key: "loadPrepareConfig",
|
|
152
160
|
value: function () {
|
|
153
161
|
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
154
|
-
var _prepareConfig$
|
|
155
|
-
var prepareConfig, goodPassList;
|
|
162
|
+
var _prepareConfig$data3, _prepareConfig$data4, _prepareConfig$data5;
|
|
163
|
+
var prepareConfig, _prepareConfig$data, _prepareConfig$data2, entitlementPassList, ids, rawDiscountList, goodPassList;
|
|
156
164
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
157
165
|
while (1) switch (_context4.prev = _context4.next) {
|
|
158
166
|
case 0:
|
|
@@ -160,9 +168,29 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
160
168
|
return this.request.post("/order/prepare/config", params);
|
|
161
169
|
case 2:
|
|
162
170
|
prepareConfig = _context4.sent;
|
|
163
|
-
|
|
164
|
-
|
|
171
|
+
if (params.with_entitlement_pass) {
|
|
172
|
+
_context4.next = 5;
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
return _context4.abrupt("return", this.filterEnabledDiscountList([].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data = prepareConfig.data) === null || _prepareConfig$data === void 0 ? void 0 : _prepareConfig$data.good_pass_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data2 = prepareConfig.data) === null || _prepareConfig$data2 === void 0 ? void 0 : _prepareConfig$data2.discount_card_list) || [])).filter(function (item) {
|
|
176
|
+
return !isEntitlementPass(item);
|
|
177
|
+
})));
|
|
165
178
|
case 5:
|
|
179
|
+
entitlementPassList = (prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data3 = prepareConfig.data) === null || _prepareConfig$data3 === void 0 ? void 0 : _prepareConfig$data3.entitlement_pass_list) || [];
|
|
180
|
+
ids = new Set(entitlementPassList.map(function (item) {
|
|
181
|
+
return String(item.id);
|
|
182
|
+
}));
|
|
183
|
+
rawDiscountList = [].concat(_toConsumableArray(entitlementPassList), _toConsumableArray(((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data4 = prepareConfig.data) === null || _prepareConfig$data4 === void 0 ? void 0 : _prepareConfig$data4.good_pass_list) || []).filter(function (item) {
|
|
184
|
+
return !ids.has(String(item.id));
|
|
185
|
+
})), _toConsumableArray(((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data5 = prepareConfig.data) === null || _prepareConfig$data5 === void 0 ? void 0 : _prepareConfig$data5.discount_card_list) || []).filter(function (item) {
|
|
186
|
+
return !ids.has(String(item.id));
|
|
187
|
+
})));
|
|
188
|
+
_context4.next = 10;
|
|
189
|
+
return this.setOriginalDiscountList(rawDiscountList);
|
|
190
|
+
case 10:
|
|
191
|
+
goodPassList = this.filterEnabledDiscountList(rawDiscountList); // this.setDiscountList(goodPassList);
|
|
192
|
+
return _context4.abrupt("return", goodPassList);
|
|
193
|
+
case 12:
|
|
166
194
|
case "end":
|
|
167
195
|
return _context4.stop();
|
|
168
196
|
}
|
|
@@ -176,28 +204,100 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
176
204
|
}, {
|
|
177
205
|
key: "batchSearch",
|
|
178
206
|
value: function () {
|
|
179
|
-
var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code,
|
|
180
|
-
var
|
|
207
|
+
var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerIdOrOptions) {
|
|
208
|
+
var _this2 = this,
|
|
209
|
+
_entitlement$value,
|
|
210
|
+
_legacy$value;
|
|
211
|
+
var _ref, customerId, orderId, withEntitlementPass, params, _result, search, _yield$Promise$all, _yield$Promise$all2, legacy, entitlement, entitlementList, legacyList, ids, result;
|
|
181
212
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
182
213
|
while (1) switch (_context5.prev = _context5.next) {
|
|
183
214
|
case 0:
|
|
184
|
-
|
|
185
|
-
|
|
215
|
+
_ref = typeof customerIdOrOptions === 'number' ? {
|
|
216
|
+
customerId: customerIdOrOptions,
|
|
217
|
+
orderId: undefined,
|
|
218
|
+
withEntitlementPass: false
|
|
219
|
+
} : customerIdOrOptions || {}, customerId = _ref.customerId, orderId = _ref.orderId, withEntitlementPass = _ref.withEntitlementPass;
|
|
220
|
+
params = _objectSpread(_objectSpread({
|
|
186
221
|
code: code,
|
|
187
222
|
translate_flag: 1,
|
|
188
|
-
tags: ['good_pass', 'product_discount_card'],
|
|
189
|
-
available: 1,
|
|
190
223
|
relation_product: 1,
|
|
191
224
|
with: ['extensionData', 'customScheduleSnapshot', 'holder.detail'],
|
|
192
225
|
order_behavior_count: 1,
|
|
193
|
-
order_behavior_count_customer_id: customerId || 1
|
|
226
|
+
order_behavior_count_customer_id: customerId || 1
|
|
227
|
+
}, orderId ? {
|
|
228
|
+
order_behavior_count_order_id: orderId
|
|
229
|
+
} : {}), {}, {
|
|
230
|
+
unified_status_info_flag: 1,
|
|
194
231
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
195
232
|
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
233
|
+
if (withEntitlementPass) {
|
|
234
|
+
_context5.next = 7;
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
_context5.next = 5;
|
|
238
|
+
return this.request.get("/machinecode/batch-search", _objectSpread(_objectSpread({}, params), {}, {
|
|
239
|
+
tags: ['good_pass', 'product_discount_card']
|
|
240
|
+
}));
|
|
200
241
|
case 5:
|
|
242
|
+
_result = _context5.sent;
|
|
243
|
+
return _context5.abrupt("return", this.filterEnabledDiscountListWithReason(((_result === null || _result === void 0 ? void 0 : _result.data) || []).filter(function (item) {
|
|
244
|
+
return !isEntitlementPass(item);
|
|
245
|
+
})));
|
|
246
|
+
case 7:
|
|
247
|
+
// 旧券沿用统一状态校验;多次卡单独查询,保留暂不可用的卡供展示。
|
|
248
|
+
search = function search(query) {
|
|
249
|
+
return _this2.request.get("/machinecode/batch-search", query).then(function (value) {
|
|
250
|
+
return {
|
|
251
|
+
status: 'fulfilled',
|
|
252
|
+
value: value
|
|
253
|
+
};
|
|
254
|
+
}, function (reason) {
|
|
255
|
+
return {
|
|
256
|
+
status: 'rejected',
|
|
257
|
+
reason: reason
|
|
258
|
+
};
|
|
259
|
+
});
|
|
260
|
+
};
|
|
261
|
+
_context5.next = 10;
|
|
262
|
+
return Promise.all([search(_objectSpread(_objectSpread({}, params), {}, {
|
|
263
|
+
tags: ['good_pass', 'product_discount_card']
|
|
264
|
+
})), search(_objectSpread(_objectSpread({}, params), {}, {
|
|
265
|
+
tags: ['entitlement_pass'],
|
|
266
|
+
with_franchisor_data: 1,
|
|
267
|
+
unified_status_info_flag: 1,
|
|
268
|
+
with: [].concat(_toConsumableArray(params.with), ['franchiseeWalletPass:shop_id,source_shop_id,product_id,use'])
|
|
269
|
+
}))]);
|
|
270
|
+
case 10:
|
|
271
|
+
_yield$Promise$all = _context5.sent;
|
|
272
|
+
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
273
|
+
legacy = _yield$Promise$all2[0];
|
|
274
|
+
entitlement = _yield$Promise$all2[1];
|
|
275
|
+
entitlementList = (entitlement.status === 'fulfilled' ? ((_entitlement$value = entitlement.value) === null || _entitlement$value === void 0 ? void 0 : _entitlement$value.data) || [] : []).filter(isEntitlementPass);
|
|
276
|
+
legacyList = legacy.status === 'fulfilled' ? ((_legacy$value = legacy.value) === null || _legacy$value === void 0 ? void 0 : _legacy$value.data) || [] : [];
|
|
277
|
+
ids = new Set(entitlementList.map(function (item) {
|
|
278
|
+
return String(item.id);
|
|
279
|
+
}));
|
|
280
|
+
result = this.filterEnabledDiscountListWithReason([].concat(_toConsumableArray(entitlementList), _toConsumableArray(legacyList.filter(function (item) {
|
|
281
|
+
return !isEntitlementPass(item) && !ids.has(String(item.id));
|
|
282
|
+
})))); // 任一类型查到可用卡即可继续,另一类型的查询失败不阻断该卡。
|
|
283
|
+
if (result.discountList.length) {
|
|
284
|
+
_context5.next = 23;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
if (!(legacy.status === 'rejected')) {
|
|
288
|
+
_context5.next = 21;
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
throw legacy.reason;
|
|
292
|
+
case 21:
|
|
293
|
+
if (!(entitlement.status === 'rejected')) {
|
|
294
|
+
_context5.next = 23;
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
throw entitlement.reason;
|
|
298
|
+
case 23:
|
|
299
|
+
return _context5.abrupt("return", result);
|
|
300
|
+
case 24:
|
|
201
301
|
case "end":
|
|
202
302
|
return _context5.stop();
|
|
203
303
|
}
|
|
@@ -240,9 +340,9 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
240
340
|
}, {
|
|
241
341
|
key: "filterEnabledDiscountList",
|
|
242
342
|
value: function filterEnabledDiscountList(discountList) {
|
|
243
|
-
var
|
|
343
|
+
var _this3 = this;
|
|
244
344
|
return discountList.filter(function (discount) {
|
|
245
|
-
return discount.limit_status === 'enable' && new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0) &&
|
|
345
|
+
return isEntitlementPass(discount) ? !getDiscountLifecycleReason(discount) : discount.limit_status === 'enable' && new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0) && _this3.checkUsageCreditsLimit(discount);
|
|
246
346
|
});
|
|
247
347
|
}
|
|
248
348
|
|
|
@@ -305,6 +405,100 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
305
405
|
return true;
|
|
306
406
|
}
|
|
307
407
|
|
|
408
|
+
// 过滤启用且可用的优惠券,并返回校验失败原因
|
|
409
|
+
}, {
|
|
410
|
+
key: "filterEnabledDiscountListWithReason",
|
|
411
|
+
value: function filterEnabledDiscountListWithReason(discountList) {
|
|
412
|
+
var _this4 = this;
|
|
413
|
+
var entitlementPasses = discountList.filter(function (item) {
|
|
414
|
+
return isEntitlementPass(item) && !getDiscountLifecycleReason(item);
|
|
415
|
+
});
|
|
416
|
+
var lists = discountList.filter(function (item) {
|
|
417
|
+
return !isEntitlementPass(item);
|
|
418
|
+
}).filter(function (discount) {
|
|
419
|
+
return discount.limit_status === 'enable';
|
|
420
|
+
}).filter(function (discount) {
|
|
421
|
+
var remaining = new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0);
|
|
422
|
+
return remaining;
|
|
423
|
+
}).map(function (discount) {
|
|
424
|
+
var limitFailKey = _this4.checkUsageCreditsLimitWithFailKey(discount);
|
|
425
|
+
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
426
|
+
usageLimitFailKey: limitFailKey
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
// 可用的列表
|
|
431
|
+
var availableLists = lists.filter(function (item) {
|
|
432
|
+
return !item.usageLimitFailKey && item.unified_available_status !== 0;
|
|
433
|
+
});
|
|
434
|
+
// 不可用数据
|
|
435
|
+
var currentFailDiscount = lists.find(function (item) {
|
|
436
|
+
return item.usageLimitFailKey;
|
|
437
|
+
});
|
|
438
|
+
return {
|
|
439
|
+
discountList: [].concat(_toConsumableArray(entitlementPasses.map(function (item) {
|
|
440
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
441
|
+
usageLimitFailKey: getDiscountUsageLimitFailKey(item)
|
|
442
|
+
});
|
|
443
|
+
})), _toConsumableArray(availableLists)),
|
|
444
|
+
unavailableReasonKey: (currentFailDiscount === null || currentFailDiscount === void 0 ? void 0 : currentFailDiscount.usageLimitFailKey) || discountList.filter(isEntitlementPass).map(getDiscountLifecycleReason).find(Boolean) || null
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// 检查使用次数限制,并返回校验失败原因
|
|
449
|
+
}, {
|
|
450
|
+
key: "checkUsageCreditsLimitWithFailKey",
|
|
451
|
+
value: function checkUsageCreditsLimitWithFailKey(discount) {
|
|
452
|
+
if (!discount.extension_data || discount.extension_data.length === 0) {
|
|
453
|
+
return null;
|
|
454
|
+
}
|
|
455
|
+
var usageCreditsData = discount.extension_data.find(function (data) {
|
|
456
|
+
return data.field_key === 'usage_credits';
|
|
457
|
+
});
|
|
458
|
+
if (!usageCreditsData) {
|
|
459
|
+
return null;
|
|
460
|
+
}
|
|
461
|
+
var value = usageCreditsData.value;
|
|
462
|
+
|
|
463
|
+
// 总次数限制
|
|
464
|
+
if (value.total_credits && value.total_credits > 0) {
|
|
465
|
+
if ((discount.total_order_behavior_count || 0) >= value.total_credits) {
|
|
466
|
+
return 'total_credits';
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// 单用户限制
|
|
471
|
+
if (value.per_user_limit && value.per_user_limit > 0) {
|
|
472
|
+
if ((discount.customer_order_behavior_count || 0) >= value.per_user_limit) {
|
|
473
|
+
return 'per_user_limit';
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// 单日限制
|
|
478
|
+
if (value.max_per_day && value.max_per_day > 0) {
|
|
479
|
+
if ((discount.today_order_behavior_count || 0) >= value.max_per_day) {
|
|
480
|
+
return 'max_per_day';
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// 单周限制
|
|
485
|
+
if (value.max_per_week && value.max_per_week > 0) {
|
|
486
|
+
if ((discount.week_order_behavior_count || 0) >= value.max_per_week) {
|
|
487
|
+
return 'max_per_week';
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// 单月限制
|
|
492
|
+
if (value.max_per_month && value.max_per_month > 0) {
|
|
493
|
+
if ((discount.month_order_behavior_count || 0) >= value.max_per_month) {
|
|
494
|
+
return 'max_per_month';
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// 全部通过
|
|
499
|
+
return null;
|
|
500
|
+
}
|
|
501
|
+
|
|
308
502
|
// 根据productIds去重
|
|
309
503
|
}, {
|
|
310
504
|
key: "uniqueByProductId",
|
|
@@ -33,8 +33,8 @@ interface Limitedrelationproductdata {
|
|
|
33
33
|
product_ids: number[];
|
|
34
34
|
product_collection_id: number[];
|
|
35
35
|
package_sub_item_usage_rules?: PackageSubItemUsageRules;
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
exclude_product_ids?: number[];
|
|
37
|
+
filter?: 0 | 1;
|
|
38
38
|
}
|
|
39
39
|
interface ApplicableProductDetails {
|
|
40
40
|
amount: string;
|
|
@@ -45,6 +45,8 @@ interface ApplicableProductDetails {
|
|
|
45
45
|
num: number;
|
|
46
46
|
metadata?: {
|
|
47
47
|
product_discount_difference?: number;
|
|
48
|
+
num?: number;
|
|
49
|
+
custom_product_bundle_map_id?: string;
|
|
48
50
|
};
|
|
49
51
|
discount?: {
|
|
50
52
|
fixed_amount?: number;
|
|
@@ -63,6 +65,18 @@ interface UsageCreditsValue {
|
|
|
63
65
|
max_per_week: number;
|
|
64
66
|
max_per_month: number;
|
|
65
67
|
}
|
|
68
|
+
export type IncludedUses = {
|
|
69
|
+
type: 'limited';
|
|
70
|
+
value: number;
|
|
71
|
+
} | {
|
|
72
|
+
type: 'unlimited';
|
|
73
|
+
value: null;
|
|
74
|
+
};
|
|
75
|
+
export type DiscountFilterRejectKey = 'total_credits' | 'per_user_limit' | 'max_per_day' | 'max_per_week' | 'max_per_month';
|
|
76
|
+
export interface DiscountWithReason {
|
|
77
|
+
discountList: Discount[];
|
|
78
|
+
unavailableReasonKey: DiscountFilterRejectKey | string | null;
|
|
79
|
+
}
|
|
66
80
|
interface ExtensionData {
|
|
67
81
|
id: number;
|
|
68
82
|
shop_id: number;
|
|
@@ -88,20 +102,39 @@ export interface Discount {
|
|
|
88
102
|
used_par_value: string;
|
|
89
103
|
limit_status: string;
|
|
90
104
|
limited_relation_product_data: Limitedrelationproductdata;
|
|
91
|
-
balance
|
|
105
|
+
balance?: string | number | null;
|
|
92
106
|
format_title: Formattitle;
|
|
93
107
|
metadata?: {
|
|
94
|
-
num?: number;
|
|
95
108
|
discount_card_type?: 'fixed_amount' | 'percent';
|
|
96
109
|
custom_product_bundle_map_id?: string;
|
|
97
110
|
validity_type?: "custom_schedule_validity" | "fixed_validity";
|
|
98
|
-
|
|
99
|
-
|
|
111
|
+
included_uses?: IncludedUses;
|
|
112
|
+
discount_calculation_mode?: 'item_level' | 'order_level';
|
|
113
|
+
holder?: {
|
|
100
114
|
type: "customer" | "custom";
|
|
101
115
|
};
|
|
102
116
|
};
|
|
103
117
|
product: Product;
|
|
104
|
-
type
|
|
118
|
+
type?: 'product' | 'good_pass' | 'entitlement_pass' | 'discount_card' | 'product_discount_card';
|
|
119
|
+
shop_id?: number;
|
|
120
|
+
customer_id?: number | string | null;
|
|
121
|
+
holder?: {
|
|
122
|
+
holder_type?: string;
|
|
123
|
+
holder_id?: number | string | Array<number | string>;
|
|
124
|
+
[key: string]: any;
|
|
125
|
+
};
|
|
126
|
+
config?: {
|
|
127
|
+
isAvailable?: boolean;
|
|
128
|
+
maxUsagePerOrder?: number;
|
|
129
|
+
[key: string]: any;
|
|
130
|
+
};
|
|
131
|
+
reason?: string;
|
|
132
|
+
reasonCode?: string;
|
|
133
|
+
is_franchisor_pass?: number;
|
|
134
|
+
franchisee_wallet_pass?: {
|
|
135
|
+
use?: string;
|
|
136
|
+
};
|
|
137
|
+
committedAppliedProductDetails?: ApplicableProductDetails[];
|
|
105
138
|
resource_id?: number;
|
|
106
139
|
savedAmount?: number;
|
|
107
140
|
isEditMode?: boolean;
|
|
@@ -116,21 +149,6 @@ export interface Discount {
|
|
|
116
149
|
isSelected?: boolean;
|
|
117
150
|
isAvailable?: boolean;
|
|
118
151
|
isUsed?: boolean;
|
|
119
|
-
config?: {
|
|
120
|
-
isAvailable?: boolean;
|
|
121
|
-
/** 最大抵扣金额 */
|
|
122
|
-
maxDeductionAmount?: number;
|
|
123
|
-
/** 每单最多使用张数 */
|
|
124
|
-
maxUsagePerOrder?: number;
|
|
125
|
-
/** 是否抵扣税费与附加费 */
|
|
126
|
-
deductTaxAndFee?: boolean;
|
|
127
|
-
/** 适用粒度(多商品共用) */
|
|
128
|
-
allowCrossProduct?: boolean;
|
|
129
|
-
/** 可用商品数量上限 */
|
|
130
|
-
applicableProductLimit?: number;
|
|
131
|
-
/** 是否抵扣单规格价格 (Option Price) */
|
|
132
|
-
deductOptionPrice?: boolean;
|
|
133
|
-
};
|
|
134
152
|
applicableProductIds?: number[];
|
|
135
153
|
applicableProductDetails: ApplicableProductDetails[];
|
|
136
154
|
appliedProductDetails: ApplicableProductDetails[];
|
|
@@ -149,6 +167,8 @@ export interface Discount {
|
|
|
149
167
|
start_date?: string;
|
|
150
168
|
start_time?: string;
|
|
151
169
|
discount_rule_uncheck_flag?: boolean;
|
|
170
|
+
usageLimitFailKey?: string | null;
|
|
171
|
+
unified_available_status?: number | undefined | null;
|
|
152
172
|
}
|
|
153
173
|
export interface DiscountState {
|
|
154
174
|
discountList: Discount[];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import { IFormInfo, IFormRecord, IFormItemData, IFetchFormInfoParams, IFetchFormRecordsParams, IAddFormRecordParams, IAppendFormRecordParams, IEnsureFormDataParams, IEnsureFormByProductParams, IRefreshAllFormRecordsParams, HolderModuleAPI, HolderFormMap } from './types';
|
|
4
|
+
export * from './types';
|
|
5
|
+
export * from './utils';
|
|
6
|
+
export declare class HolderModule extends BaseModule implements Module, HolderModuleAPI {
|
|
7
|
+
protected defaultName: string;
|
|
8
|
+
protected defaultVersion: string;
|
|
9
|
+
private store;
|
|
10
|
+
private request;
|
|
11
|
+
private cacheId;
|
|
12
|
+
private openCache;
|
|
13
|
+
private fatherModule;
|
|
14
|
+
private isLoading;
|
|
15
|
+
private error;
|
|
16
|
+
/** 已加载过表单数据的 form_id 缓存标记 */
|
|
17
|
+
private loadedFormIds;
|
|
18
|
+
private window;
|
|
19
|
+
constructor(name?: string, version?: string);
|
|
20
|
+
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
21
|
+
/** 统一提交 formMap,仅此处触发 store changed */
|
|
22
|
+
private commitFormMap;
|
|
23
|
+
/** 通知 UI 刷新(数据未变但需要 re-read 的场景) */
|
|
24
|
+
private notifyFormMapChanged;
|
|
25
|
+
getHolderFormMap(): HolderFormMap;
|
|
26
|
+
getHolderFormData(formId: number | string): IFormItemData | undefined;
|
|
27
|
+
setFormData(formId: number | string, data: Partial<IFormItemData>): void;
|
|
28
|
+
private ensureFormItem;
|
|
29
|
+
private hasFormData;
|
|
30
|
+
private patchFormMap;
|
|
31
|
+
fetchFormInfo(params: IFetchFormInfoParams): Promise<IFormInfo | IFormInfo[]>;
|
|
32
|
+
fetchRecords(params: IFetchFormRecordsParams): Promise<any>;
|
|
33
|
+
ensureFormData(params: IEnsureFormDataParams): Promise<IFormItemData>;
|
|
34
|
+
ensureFormByProduct(params: IEnsureFormByProductParams): Promise<IFormItemData | null>;
|
|
35
|
+
addFormRecord(params: IAddFormRecordParams): Promise<any>;
|
|
36
|
+
/**
|
|
37
|
+
* UI 层自行请求添加接口后,将返回记录合并到 holderMap 对应 form_id 的 records 中
|
|
38
|
+
*/
|
|
39
|
+
appendFormRecord(params: IAppendFormRecordParams): IFormRecord;
|
|
40
|
+
removeFormRecord(formId: number | string, formRecordId: number): void;
|
|
41
|
+
clearFormData(formId?: number | string): void;
|
|
42
|
+
/**
|
|
43
|
+
* 登录后按当前 holderMap 批量刷新所有表单的 records。
|
|
44
|
+
* 遍历 holderMap,从 form.form 中读取 form_id、shop_id,结合 customer_id 重新拉取记录。
|
|
45
|
+
*/
|
|
46
|
+
refreshAllFormRecords(params?: IRefreshAllFormRecordsParams): Promise<HolderFormMap>;
|
|
47
|
+
storeChange(path?: string): void;
|
|
48
|
+
}
|