@pisell/pisellos 2.1.174 → 2.1.176
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +2 -4
- package/dist/modules/Discount/index.d.ts +3 -6
- package/dist/modules/Discount/index.js +23 -125
- package/dist/modules/Discount/types.d.ts +5 -34
- package/dist/modules/OpenData/types.d.ts +1 -0
- package/dist/modules/ProductList/index.js +13 -6
- package/dist/modules/Rules/index.d.ts +2 -12
- package/dist/modules/Rules/index.js +113 -377
- package/dist/modules/Rules/types.d.ts +2 -2
- package/dist/plugins/window.d.ts +0 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.d.ts +7 -5
- package/dist/solution/ScanOrder/index.js +123 -31
- package/dist/solution/ScanOrder/resourceSchedule.d.ts +12 -0
- package/dist/solution/ScanOrder/resourceSchedule.js +300 -0
- package/dist/solution/ScanOrder/types.d.ts +9 -1
- package/dist/solution/ShopDiscount/index.d.ts +0 -3
- package/dist/solution/ShopDiscount/index.js +78 -161
- package/dist/solution/ShopDiscount/utils.d.ts +0 -1
- package/dist/solution/ShopDiscount/utils.js +1 -40
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -4
- package/lib/modules/Discount/index.d.ts +3 -6
- package/lib/modules/Discount/index.js +16 -66
- package/lib/modules/Discount/types.d.ts +5 -34
- package/lib/modules/OpenData/types.d.ts +1 -0
- package/lib/modules/ProductList/index.js +8 -1
- package/lib/modules/Rules/index.d.ts +2 -12
- package/lib/modules/Rules/index.js +69 -303
- package/lib/modules/Rules/types.d.ts +2 -2
- package/lib/plugins/window.d.ts +0 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.d.ts +7 -5
- package/lib/solution/ScanOrder/index.js +90 -12
- package/lib/solution/ScanOrder/resourceSchedule.d.ts +12 -0
- package/lib/solution/ScanOrder/resourceSchedule.js +272 -0
- package/lib/solution/ScanOrder/types.d.ts +9 -1
- package/lib/solution/ShopDiscount/index.d.ts +0 -3
- package/lib/solution/ShopDiscount/index.js +28 -78
- package/lib/solution/ShopDiscount/utils.d.ts +0 -1
- package/lib/solution/ShopDiscount/utils.js +1 -42
- package/package.json +1 -1
- package/dist/modules/Discount/availability.d.ts +0 -7
- package/dist/modules/Discount/availability.js +0 -52
- package/dist/modules/Discount/entitlementPass.d.ts +0 -34
- package/dist/modules/Discount/entitlementPass.js +0 -147
- package/dist/modules/Discount/entitlementState.d.ts +0 -8
- package/dist/modules/Discount/entitlementState.js +0 -205
- package/dist/modules/Rules/entitlementLines.d.ts +0 -8
- package/dist/modules/Rules/entitlementLines.js +0 -157
- package/lib/modules/Discount/availability.d.ts +0 -7
- package/lib/modules/Discount/availability.js +0 -91
- package/lib/modules/Discount/entitlementPass.d.ts +0 -34
- package/lib/modules/Discount/entitlementPass.js +0 -184
- package/lib/modules/Discount/entitlementState.d.ts +0 -8
- package/lib/modules/Discount/entitlementState.js +0 -206
- package/lib/modules/Rules/entitlementLines.d.ts +0 -8
- package/lib/modules/Rules/entitlementLines.js +0 -158
|
@@ -31,9 +31,6 @@ import { filterDiscountListByBookingTime as _filterDiscountListByBookingTime, is
|
|
|
31
31
|
import { UnavailableReason } from "../../modules/Rules/types";
|
|
32
32
|
import Decimal from 'decimal.js';
|
|
33
33
|
import { isBoolean } from 'lodash-es';
|
|
34
|
-
import { isEntitlementPass } from "../../modules/Discount/entitlementPass";
|
|
35
|
-
import { getDiscountLifecycleReason } from "../../modules/Discount/availability";
|
|
36
|
-
import { mergeEntitlementDiscountLists, retainScannedEntitlements, withCommittedEntitlementDetails } from "../../modules/Discount/entitlementState";
|
|
37
34
|
export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
38
35
|
_inherits(ShopDiscountImpl, _BaseModule);
|
|
39
36
|
var _super = _createSuper(ShopDiscountImpl);
|
|
@@ -50,7 +47,6 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
50
47
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
51
48
|
_defineProperty(_assertThisInitialized(_this), "options", {});
|
|
52
49
|
_defineProperty(_assertThisInitialized(_this), "hooks", void 0);
|
|
53
|
-
_defineProperty(_assertThisInitialized(_this), "entitlementPassEnabled", false);
|
|
54
50
|
_this.store = {
|
|
55
51
|
customer: null,
|
|
56
52
|
productList: [],
|
|
@@ -68,21 +64,6 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
68
64
|
|
|
69
65
|
// =========== 生命周期方法 ===========
|
|
70
66
|
_createClass(ShopDiscountImpl, [{
|
|
71
|
-
key: "setEntitlementPassEnabled",
|
|
72
|
-
value:
|
|
73
|
-
// 由使用多次卡的预约组件显式开启,其他入口沿用原券流程。
|
|
74
|
-
function setEntitlementPassEnabled(enabled) {
|
|
75
|
-
var _this$store$rules;
|
|
76
|
-
this.entitlementPassEnabled = enabled;
|
|
77
|
-
(_this$store$rules = this.store.rules) === null || _this$store$rules === void 0 || _this$store$rules.setEntitlementPassEnabled(enabled);
|
|
78
|
-
if (!enabled) {
|
|
79
|
-
var _this$store$discount;
|
|
80
|
-
(_this$store$discount = this.store.discount) === null || _this$store$discount === void 0 || _this$store$discount.setDiscountList(this.getDiscountList().filter(function (item) {
|
|
81
|
-
return !isEntitlementPass(item);
|
|
82
|
-
}));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}, {
|
|
86
67
|
key: "initialize",
|
|
87
68
|
value: function () {
|
|
88
69
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
@@ -119,14 +100,14 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
119
100
|
key: "destroy",
|
|
120
101
|
value: function () {
|
|
121
102
|
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
122
|
-
var _this$store$
|
|
103
|
+
var _this$store$discount, _this$store$rules;
|
|
123
104
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
124
105
|
while (1) switch (_context2.prev = _context2.next) {
|
|
125
106
|
case 0:
|
|
126
107
|
this.store.productList = [];
|
|
127
108
|
this.store.customer = null;
|
|
128
|
-
(_this$store$
|
|
129
|
-
(_this$store$
|
|
109
|
+
(_this$store$discount = this.store.discount) === null || _this$store$discount === void 0 || _this$store$discount.destroy();
|
|
110
|
+
(_this$store$rules = this.store.rules) === null || _this$store$rules === void 0 || _this$store$rules.destroy();
|
|
130
111
|
this.core.effects.offByModuleDestroy(this.name);
|
|
131
112
|
_context2.next = 7;
|
|
132
113
|
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
@@ -147,14 +128,14 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
147
128
|
key: "clear",
|
|
148
129
|
value: function () {
|
|
149
130
|
var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
150
|
-
var _this$store$
|
|
131
|
+
var _this$store$discount2, _this$store$rules2;
|
|
151
132
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
152
133
|
while (1) switch (_context3.prev = _context3.next) {
|
|
153
134
|
case 0:
|
|
154
135
|
this.store.productList = [];
|
|
155
136
|
this.store.customer = null;
|
|
156
|
-
(_this$store$
|
|
157
|
-
(_this$store$
|
|
137
|
+
(_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 || _this$store$discount2.clear();
|
|
138
|
+
(_this$store$rules2 = this.store.rules) === null || _this$store$rules2 === void 0 || _this$store$rules2.clear();
|
|
158
139
|
console.log('[ShopDiscount] clear');
|
|
159
140
|
case 5:
|
|
160
141
|
case "end":
|
|
@@ -219,7 +200,9 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
219
200
|
var _this2 = this;
|
|
220
201
|
this.core.effects.only("".concat(this.name, ":onCustomerChange"), function (customer) {
|
|
221
202
|
var _this2$options$otherP;
|
|
222
|
-
if (
|
|
203
|
+
if ((_this2$options$otherP = _this2.options.otherParams) !== null && _this2$options$otherP !== void 0 && _this2$options$otherP.cacheId && _this2.getDiscountList().length) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
223
206
|
_this2.loadPrepareConfig({
|
|
224
207
|
customerId: customer.id,
|
|
225
208
|
action: 'create',
|
|
@@ -286,28 +269,17 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
286
269
|
value: function () {
|
|
287
270
|
var _setCustomer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(customer) {
|
|
288
271
|
var _this$store$customer;
|
|
289
|
-
var _this$store$discount4, retained;
|
|
290
272
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
291
273
|
while (1) switch (_context4.prev = _context4.next) {
|
|
292
274
|
case 0:
|
|
293
275
|
if (!(((_this$store$customer = this.store.customer) === null || _this$store$customer === void 0 ? void 0 : _this$store$customer.id) !== customer.id)) {
|
|
294
|
-
_context4.next =
|
|
276
|
+
_context4.next = 4;
|
|
295
277
|
break;
|
|
296
278
|
}
|
|
297
279
|
this.store.customer = customer;
|
|
298
|
-
|
|
299
|
-
_context4.next = 6;
|
|
300
|
-
break;
|
|
301
|
-
}
|
|
302
|
-
retained = this.getDiscountList().filter(function (item) {
|
|
303
|
-
return !isEntitlementPass(item) || item.isEditMode || item.isScan && String(item.customer_id) === String(customer.id);
|
|
304
|
-
});
|
|
305
|
-
_context4.next = 6;
|
|
306
|
-
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(retained);
|
|
307
|
-
case 6:
|
|
308
|
-
_context4.next = 8;
|
|
280
|
+
_context4.next = 4;
|
|
309
281
|
return this.core.effects.emit("".concat(this.name, ":onCustomerChange"), customer);
|
|
310
|
-
case
|
|
282
|
+
case 4:
|
|
311
283
|
case "end":
|
|
312
284
|
return _context4.stop();
|
|
313
285
|
}
|
|
@@ -358,7 +330,6 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
358
330
|
},
|
|
359
331
|
newProductList = _ref.productList,
|
|
360
332
|
newDiscountList = _ref.discountList;
|
|
361
|
-
if (this.entitlementPassEnabled) this.store.productList = newProductList || productList;
|
|
362
333
|
if (newDiscountList) {
|
|
363
334
|
newDiscountList = this.setDiscountList(newDiscountList);
|
|
364
335
|
}
|
|
@@ -423,13 +394,13 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
423
394
|
key: "batchSearchByProductIds",
|
|
424
395
|
value: function () {
|
|
425
396
|
var _batchSearchByProductIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(productIds) {
|
|
426
|
-
var _this$store$
|
|
397
|
+
var _this$store$discount3;
|
|
427
398
|
var resultDiscountList, currentDiscountList, newDiscountList;
|
|
428
399
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
429
400
|
while (1) switch (_context5.prev = _context5.next) {
|
|
430
401
|
case 0:
|
|
431
402
|
_context5.next = 2;
|
|
432
|
-
return (_this$store$
|
|
403
|
+
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.batchSearchByProductIds(productIds);
|
|
433
404
|
case 2:
|
|
434
405
|
_context5.t0 = _context5.sent;
|
|
435
406
|
if (_context5.t0) {
|
|
@@ -463,16 +434,15 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
463
434
|
key: "scanCode",
|
|
464
435
|
value: function () {
|
|
465
436
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
466
|
-
var _this$store$
|
|
437
|
+
var _this$store$discount4, _this$store$bookingSu2, resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, unavailableReason, _this$options$otherPa6;
|
|
467
438
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
468
439
|
while (1) switch (_context6.prev = _context6.next) {
|
|
469
440
|
case 0:
|
|
470
441
|
_context6.prev = 0;
|
|
471
442
|
_context6.next = 3;
|
|
472
|
-
return (_this$store$
|
|
443
|
+
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.batchSearch(code, {
|
|
473
444
|
customerId: customerId,
|
|
474
|
-
orderId: this.store.orderId
|
|
475
|
-
withEntitlementPass: this.entitlementPassEnabled
|
|
445
|
+
orderId: this.store.orderId
|
|
476
446
|
});
|
|
477
447
|
case 3:
|
|
478
448
|
_context6.t0 = _context6.sent;
|
|
@@ -520,7 +490,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
520
490
|
currentSelectedDiscountList = this.getDiscountList().filter(function (n) {
|
|
521
491
|
return n.isSelected;
|
|
522
492
|
});
|
|
523
|
-
if (!(
|
|
493
|
+
if (!(currentSelectedDiscountList.length && currentSelectedDiscountList.some(function (n) {
|
|
524
494
|
return withScanList.some(function (m) {
|
|
525
495
|
return m.id === n.id;
|
|
526
496
|
});
|
|
@@ -545,58 +515,30 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
545
515
|
isAvailable: false,
|
|
546
516
|
productList: this.store.productList || [],
|
|
547
517
|
discountList: this.getDiscountList()
|
|
548
|
-
}, newProductList = _ref2.productList, newDiscountList = _ref2.discountList,
|
|
549
|
-
isAccepted = isAvailable;
|
|
518
|
+
}, newProductList = _ref2.productList, newDiscountList = _ref2.discountList, isAvailable = _ref2.isAvailable, unavailableReason = _ref2.unavailableReason;
|
|
550
519
|
if (!isAvailable) {
|
|
551
|
-
_context6.next =
|
|
520
|
+
_context6.next = 25;
|
|
552
521
|
break;
|
|
553
522
|
}
|
|
554
|
-
if (this.entitlementPassEnabled) this.setProductList(newProductList || []);
|
|
555
523
|
this.setDiscountList(newDiscountList || []);
|
|
556
524
|
this.store.originalDiscountList = newDiscountList || [];
|
|
557
|
-
|
|
525
|
+
this.setProductList(newProductList || []);
|
|
558
526
|
if (!(this.isWalkIn() && resultDiscountList.length && ((_this$options$otherPa6 = this.options.otherParams) === null || _this$options$otherPa6 === void 0 ? void 0 : _this$options$otherPa6.platform) === 'shop')) {
|
|
559
|
-
_context6.next =
|
|
527
|
+
_context6.next = 25;
|
|
560
528
|
break;
|
|
561
529
|
}
|
|
562
|
-
_context6.next =
|
|
530
|
+
_context6.next = 25;
|
|
563
531
|
return this.getCustomerWallet(resultDiscountList[0].customer_id);
|
|
564
|
-
case
|
|
565
|
-
if (!isAvailable) {
|
|
566
|
-
ids = new Set(withScanList.map(function (item) {
|
|
567
|
-
return String(item.id);
|
|
568
|
-
}));
|
|
569
|
-
retainable = (evaluatedDiscountList || []).filter(function (item) {
|
|
570
|
-
return ids.has(String(item.id)) && isEntitlementPass(item) && !getDiscountLifecycleReason(item);
|
|
571
|
-
});
|
|
572
|
-
if (retainable.length) {
|
|
573
|
-
this.setDiscountList(retainScannedEntitlements(this.getDiscountList(), retainable));
|
|
574
|
-
isAccepted = true;
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
if (!this.entitlementPassEnabled) {
|
|
578
|
-
_context6.next = 32;
|
|
579
|
-
break;
|
|
580
|
-
}
|
|
581
|
-
this.store.originalDiscountList = this.getDiscountList();
|
|
582
|
-
_context6.next = 32;
|
|
583
|
-
return (_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.setOriginalDiscountList(this.getDiscountList());
|
|
584
|
-
case 32:
|
|
532
|
+
case 25:
|
|
585
533
|
return _context6.abrupt("return", {
|
|
586
534
|
type: "clientCalc",
|
|
587
535
|
isAvailable: isAvailable || false,
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
unavailableReason: unavailableReason,
|
|
592
|
-
unavailableReasonKey: ((_find = (evaluatedDiscountList || []).find(function (item) {
|
|
593
|
-
return withScanList.some(function (scanned) {
|
|
594
|
-
return String(scanned.id) === String(item.id);
|
|
595
|
-
}) && item.reasonCode;
|
|
596
|
-
})) === null || _find === void 0 ? void 0 : _find.reasonCode) || unavailableReasonKey
|
|
536
|
+
productList: newProductList || this.store.productList || [],
|
|
537
|
+
discountList: newDiscountList || this.getDiscountList(),
|
|
538
|
+
unavailableReason: unavailableReason
|
|
597
539
|
});
|
|
598
|
-
case
|
|
599
|
-
_context6.prev =
|
|
540
|
+
case 28:
|
|
541
|
+
_context6.prev = 28;
|
|
600
542
|
_context6.t1 = _context6["catch"](0);
|
|
601
543
|
console.error('[ShopDiscount] 扫码出错:', _context6.t1);
|
|
602
544
|
return _context6.abrupt("return", {
|
|
@@ -606,11 +548,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
606
548
|
discountList: this.getDiscountList(),
|
|
607
549
|
unavailableReason: UnavailableReason.Unknown
|
|
608
550
|
});
|
|
609
|
-
case
|
|
551
|
+
case 32:
|
|
610
552
|
case "end":
|
|
611
553
|
return _context6.stop();
|
|
612
554
|
}
|
|
613
|
-
}, _callee6, this, [[0,
|
|
555
|
+
}, _callee6, this, [[0, 28]]);
|
|
614
556
|
}));
|
|
615
557
|
function scanCode(_x5, _x6) {
|
|
616
558
|
return _scanCode.apply(this, arguments);
|
|
@@ -620,8 +562,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
620
562
|
}, {
|
|
621
563
|
key: "calcDiscountApplicableProductTotalPrice",
|
|
622
564
|
value: function calcDiscountApplicableProductTotalPrice(discount) {
|
|
623
|
-
var _this$store$
|
|
624
|
-
return (_this$store$
|
|
565
|
+
var _this$store$discount5;
|
|
566
|
+
return (_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 ? void 0 : _this$store$discount5.calcDiscountApplicableProductTotalPrice(discount);
|
|
625
567
|
}
|
|
626
568
|
|
|
627
569
|
// =========== 私有辅助方法 ===========
|
|
@@ -666,8 +608,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
666
608
|
key: "setDiscountList",
|
|
667
609
|
value: function setDiscountList(discountList) {
|
|
668
610
|
var _this3 = this,
|
|
669
|
-
_this$
|
|
670
|
-
_this$store$discount9;
|
|
611
|
+
_this$store$discount6;
|
|
671
612
|
var productList = this.store.productList || [];
|
|
672
613
|
var editModeDiscountList = [];
|
|
673
614
|
productList.forEach(function (item) {
|
|
@@ -708,14 +649,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
708
649
|
});
|
|
709
650
|
}
|
|
710
651
|
});
|
|
711
|
-
var newDiscountList =
|
|
712
|
-
return !
|
|
713
|
-
})), _toConsumableArray(discountList.filter(function (item) {
|
|
714
|
-
return isEntitlementPass(item) || !item.isDisabled;
|
|
715
|
-
}))), productList, ((_this$hooks = this.hooks) === null || _this$hooks === void 0 ? void 0 : _this$hooks.getProduct) || function (item) {
|
|
716
|
-
return item;
|
|
717
|
-
}) : [].concat(editModeDiscountList, _toConsumableArray(discountList.filter(function (item) {
|
|
718
|
-
return !item.isDisabled && !isEntitlementPass(item);
|
|
652
|
+
var newDiscountList = [].concat(editModeDiscountList, _toConsumableArray(discountList.filter(function (item) {
|
|
653
|
+
return !item.isDisabled;
|
|
719
654
|
})));
|
|
720
655
|
var isProductFree = function isProductFree(id) {
|
|
721
656
|
var _this3$hooks2;
|
|
@@ -756,7 +691,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
756
691
|
item.isDisabledForProductUsed = false;
|
|
757
692
|
}
|
|
758
693
|
});
|
|
759
|
-
(_this$store$
|
|
694
|
+
(_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 || _this$store$discount6.setDiscountList(newDiscountList);
|
|
760
695
|
this.emitDiscountListChange(newDiscountList);
|
|
761
696
|
return newDiscountList;
|
|
762
697
|
}
|
|
@@ -765,8 +700,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
765
700
|
}, {
|
|
766
701
|
key: "getDiscountList",
|
|
767
702
|
value: function getDiscountList() {
|
|
768
|
-
var _this$store$
|
|
769
|
-
return ((_this$store$
|
|
703
|
+
var _this$store$discount7;
|
|
704
|
+
return ((_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.getDiscountList()) || [];
|
|
770
705
|
}
|
|
771
706
|
|
|
772
707
|
// 获取客户钱包信息
|
|
@@ -774,7 +709,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
774
709
|
key: "getCustomerWallet",
|
|
775
710
|
value: function () {
|
|
776
711
|
var _getCustomerWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(id) {
|
|
777
|
-
var _result, customer
|
|
712
|
+
var _result, customer;
|
|
778
713
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
779
714
|
while (1) switch (_context8.prev = _context8.next) {
|
|
780
715
|
case 0:
|
|
@@ -786,32 +721,25 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
786
721
|
case 3:
|
|
787
722
|
_result = _context8.sent;
|
|
788
723
|
if (!(_result !== null && _result !== void 0 && _result.data)) {
|
|
789
|
-
_context8.next =
|
|
724
|
+
_context8.next = 9;
|
|
790
725
|
break;
|
|
791
726
|
}
|
|
792
727
|
customer = Object.assign({}, (_objectDestructuringEmpty(_result.data), _result.data));
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
_context8.next = 10;
|
|
796
|
-
break;
|
|
797
|
-
}
|
|
798
|
-
_context8.next = 10;
|
|
799
|
-
return customerUpdate;
|
|
800
|
-
case 10:
|
|
801
|
-
_context8.next = 12;
|
|
728
|
+
this.setCustomer(customer);
|
|
729
|
+
_context8.next = 9;
|
|
802
730
|
return this.core.effects.emit("".concat(this.name, ":onScanCustomerChange"), customer);
|
|
803
|
-
case
|
|
804
|
-
_context8.next =
|
|
731
|
+
case 9:
|
|
732
|
+
_context8.next = 14;
|
|
805
733
|
break;
|
|
806
|
-
case
|
|
807
|
-
_context8.prev =
|
|
734
|
+
case 11:
|
|
735
|
+
_context8.prev = 11;
|
|
808
736
|
_context8.t0 = _context8["catch"](0);
|
|
809
737
|
console.error('[ShopDiscount] 获取客户钱包信息出错:', _context8.t0);
|
|
810
|
-
case
|
|
738
|
+
case 14:
|
|
811
739
|
case "end":
|
|
812
740
|
return _context8.stop();
|
|
813
741
|
}
|
|
814
|
-
}, _callee8, this, [[0,
|
|
742
|
+
}, _callee8, this, [[0, 11]]);
|
|
815
743
|
}));
|
|
816
744
|
function getCustomerWallet(_x8) {
|
|
817
745
|
return _getCustomerWallet.apply(this, arguments);
|
|
@@ -855,79 +783,68 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
855
783
|
key: "loadPrepareConfig",
|
|
856
784
|
value: function () {
|
|
857
785
|
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
858
|
-
var
|
|
859
|
-
var _this$getCustomer2, _this$store$discount11, _this$getCustomer3, _this$store$discount12, _this$store$discount13, _this$store$productLi2, entitlementPassEnabled, orderId, customerId, goodPassList, newDiscountList, filteredDiscountList, _result3;
|
|
786
|
+
var _this$getCustomer2, _this$store$discount8, _this$getDiscountList, _this$store$discount9, _this$store$productLi2, orderId, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
|
|
860
787
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
861
788
|
while (1) switch (_context10.prev = _context10.next) {
|
|
862
789
|
case 0:
|
|
863
790
|
_context10.prev = 0;
|
|
864
|
-
entitlementPassEnabled = this.entitlementPassEnabled;
|
|
865
791
|
orderId = this.store.orderId;
|
|
866
792
|
customerId = params.customerId || ((_this$getCustomer2 = this.getCustomer()) === null || _this$getCustomer2 === void 0 ? void 0 : _this$getCustomer2.id); // if (customerId === 1 || !customerId) {
|
|
867
793
|
// return
|
|
868
794
|
// }
|
|
869
|
-
_context10.next =
|
|
870
|
-
return (_this$store$
|
|
795
|
+
_context10.next = 5;
|
|
796
|
+
return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.loadPrepareConfig(_objectSpread({
|
|
871
797
|
customer_id: customerId,
|
|
872
798
|
action: orderId ? 'edit' : 'create',
|
|
873
799
|
with_good_pass: 1,
|
|
874
800
|
with_discount_card: 1,
|
|
875
|
-
with_wallet_pass_holder: 1
|
|
876
|
-
}, this.entitlementPassEnabled ? {
|
|
877
|
-
with_entitlement_pass: 1,
|
|
878
|
-
filter_order_wallet_pass_usage: 0
|
|
879
|
-
} : {}), {}, {
|
|
801
|
+
with_wallet_pass_holder: 1,
|
|
880
802
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
881
803
|
}, orderId ? {
|
|
882
804
|
order_id: orderId
|
|
883
805
|
} : {}));
|
|
884
|
-
case
|
|
806
|
+
case 5:
|
|
885
807
|
goodPassList = _context10.sent;
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
return _context10.abrupt("return");
|
|
897
|
-
case 11:
|
|
898
|
-
newDiscountList = mergeEntitlementDiscountLists(this.getDiscountList(), goodPassList || [], (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.getOriginalDiscountList()); // 存储原始优惠券列表
|
|
808
|
+
scanDiscount = (_this$getDiscountList = this.getDiscountList()) === null || _this$getDiscountList === void 0 ? void 0 : _this$getDiscountList.filter(function (item) {
|
|
809
|
+
return item.isScan;
|
|
810
|
+
}); // goodPassList 里可能有 scanDiscount 重合的部分,goodPassList 需要剔除
|
|
811
|
+
scanDiscountIds = scanDiscount.map(function (n) {
|
|
812
|
+
return n.id;
|
|
813
|
+
});
|
|
814
|
+
newGoodPassList = goodPassList === null || goodPassList === void 0 ? void 0 : goodPassList.filter(function (n) {
|
|
815
|
+
return !scanDiscountIds.includes(n.id);
|
|
816
|
+
});
|
|
817
|
+
newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || [])); // 存储原始优惠券列表
|
|
899
818
|
this.store.originalDiscountList = newDiscountList;
|
|
900
|
-
_context10.next =
|
|
901
|
-
return (_this$store$
|
|
902
|
-
case
|
|
819
|
+
_context10.next = 13;
|
|
820
|
+
return (_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.setOriginalDiscountList(newDiscountList);
|
|
821
|
+
case 13:
|
|
903
822
|
// 根据当前预约时间过滤优惠券列表
|
|
904
|
-
filteredDiscountList =
|
|
905
|
-
return isEntitlementPass(item) || _this4.filterDiscountListByBookingTime([item], _this4.store.currentBookingTime).length > 0;
|
|
906
|
-
});
|
|
823
|
+
filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
|
|
907
824
|
this.store.filteredDiscountList = filteredDiscountList;
|
|
908
825
|
this.setDiscountList(filteredDiscountList || []);
|
|
909
826
|
if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
|
|
910
|
-
_context10.next =
|
|
827
|
+
_context10.next = 20;
|
|
911
828
|
break;
|
|
912
829
|
}
|
|
913
830
|
_result3 = this.calcDiscount(this.store.productList);
|
|
914
|
-
_context10.next =
|
|
831
|
+
_context10.next = 20;
|
|
915
832
|
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
|
|
916
|
-
case
|
|
917
|
-
_context10.next =
|
|
833
|
+
case 20:
|
|
834
|
+
_context10.next = 22;
|
|
918
835
|
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
|
|
919
|
-
case
|
|
920
|
-
_context10.next =
|
|
836
|
+
case 22:
|
|
837
|
+
_context10.next = 27;
|
|
921
838
|
break;
|
|
922
|
-
case
|
|
923
|
-
_context10.prev =
|
|
839
|
+
case 24:
|
|
840
|
+
_context10.prev = 24;
|
|
924
841
|
_context10.t0 = _context10["catch"](0);
|
|
925
842
|
console.error('[ShopDiscount] 加载准备配置出错:', _context10.t0);
|
|
926
|
-
case
|
|
843
|
+
case 27:
|
|
927
844
|
case "end":
|
|
928
845
|
return _context10.stop();
|
|
929
846
|
}
|
|
930
|
-
}, _callee10, this, [[0,
|
|
847
|
+
}, _callee10, this, [[0, 24]]);
|
|
931
848
|
}));
|
|
932
849
|
function loadPrepareConfig(_x10) {
|
|
933
850
|
return _loadPrepareConfig.apply(this, arguments);
|
|
@@ -89,4 +89,3 @@ export declare const calculateOrderLevelDiscountAllocation: (discount: Discount,
|
|
|
89
89
|
discountAmount: number;
|
|
90
90
|
difference: number;
|
|
91
91
|
}>;
|
|
92
|
-
export declare const getDiscountTimeUnavailableReason: (discount: Discount, useTime: string) => 'not_started' | 'time_limit' | 'outside_schedule' | undefined;
|
|
@@ -9,11 +9,6 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
9
9
|
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; }
|
|
10
10
|
import Decimal from "decimal.js";
|
|
11
11
|
import dayjs from "dayjs";
|
|
12
|
-
import isSameOrAfter from "dayjs/plugin/isSameOrAfter";
|
|
13
|
-
import isSameOrBefore from "dayjs/plugin/isSameOrBefore";
|
|
14
|
-
import { isEntitlementPass, isFullCoveragePass } from "../../modules/Discount/entitlementPass";
|
|
15
|
-
dayjs.extend(isSameOrAfter);
|
|
16
|
-
dayjs.extend(isSameOrBefore);
|
|
17
12
|
export var uniqueById = function uniqueById(arr) {
|
|
18
13
|
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id';
|
|
19
14
|
var seen = new Set();
|
|
@@ -47,7 +42,7 @@ export var isAllNormalProduct = function isAllNormalProduct(items) {
|
|
|
47
42
|
export var getDiscountAmount = function getDiscountAmount(discount, total, price) {
|
|
48
43
|
var _discount$metadata;
|
|
49
44
|
// 商品券
|
|
50
|
-
if (
|
|
45
|
+
if (discount.tag === 'good_pass') {
|
|
51
46
|
return new Decimal(price).minus(new Decimal(price || 0)).toNumber();
|
|
52
47
|
}
|
|
53
48
|
|
|
@@ -455,7 +450,6 @@ export var filterDiscountListByBookingTime = function filterDiscountListByBookin
|
|
|
455
450
|
}
|
|
456
451
|
return discountList.filter(function (discount) {
|
|
457
452
|
var _discount$metadata2;
|
|
458
|
-
if (isEntitlementPass(discount)) return !getDiscountTimeUnavailableReason(discount, bookingTime);
|
|
459
453
|
if ((discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.validity_type) === "custom_schedule_validity") {
|
|
460
454
|
var _discount$custom_sche;
|
|
461
455
|
return getDateIsInSchedule(bookingTime, ((_discount$custom_sche = discount.custom_schedule_snapshot) === null || _discount$custom_sche === void 0 ? void 0 : _discount$custom_sche.data) || []);
|
|
@@ -602,37 +596,4 @@ export var calculateOrderLevelDiscountAllocation = function calculateOrderLevelD
|
|
|
602
596
|
}
|
|
603
597
|
}
|
|
604
598
|
return result;
|
|
605
|
-
};
|
|
606
|
-
export var getDiscountTimeUnavailableReason = function getDiscountTimeUnavailableReason(discount, useTime) {
|
|
607
|
-
var useTimeDayjs = dayjs(useTime);
|
|
608
|
-
if (!useTimeDayjs.isValid()) return 'time_limit';
|
|
609
|
-
try {
|
|
610
|
-
var _discount$metadata5, _discount$extension_d, _discount$custom_sche3;
|
|
611
|
-
if ((discount === null || discount === void 0 || (_discount$metadata5 = discount.metadata) === null || _discount$metadata5 === void 0 ? void 0 : _discount$metadata5.validity_type) === "custom_schedule_validity") {
|
|
612
|
-
var _discount$custom_sche2;
|
|
613
|
-
return getDateIsInSchedule(useTime, ((_discount$custom_sche2 = discount.custom_schedule_snapshot) === null || _discount$custom_sche2 === void 0 ? void 0 : _discount$custom_sche2.data) || []) ? undefined : 'outside_schedule';
|
|
614
|
-
}
|
|
615
|
-
var isHasStart = !!discount.start_date && !!discount.start_time;
|
|
616
|
-
var startDate = dayjs("".concat(discount.start_date, " ").concat(discount.start_time));
|
|
617
|
-
|
|
618
|
-
// 开始时刻包含在有效期内。
|
|
619
|
-
if (isHasStart) {
|
|
620
|
-
if (!startDate.isValid()) return 'time_limit';
|
|
621
|
-
if (useTimeDayjs.isBefore(startDate)) return 'not_started';
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
// 到期时刻不再可用;expire_time 为空时为长期有效。
|
|
625
|
-
var expireTime = discount.expire_time ? dayjs(discount.expire_time) : null;
|
|
626
|
-
var isBeforeExpire = expireTime ? expireTime.isValid() && useTimeDayjs.isBefore(expireTime) : true;
|
|
627
|
-
if (!isBeforeExpire) return 'time_limit';
|
|
628
|
-
var validity = (_discount$extension_d = discount.extension_data) === null || _discount$extension_d === void 0 || (_discount$extension_d = _discount$extension_d.find(function (field) {
|
|
629
|
-
return field.field_key === 'valid_times';
|
|
630
|
-
})) === null || _discount$extension_d === void 0 ? void 0 : _discount$extension_d.value;
|
|
631
|
-
if ((validity === null || validity === void 0 ? void 0 : validity.restrict_use_by_schedule) === true && !getDateIsInSchedule(useTime, ((_discount$custom_sche3 = discount.custom_schedule_snapshot) === null || _discount$custom_sche3 === void 0 ? void 0 : _discount$custom_sche3.data) || [])) {
|
|
632
|
-
return 'outside_schedule';
|
|
633
|
-
}
|
|
634
|
-
return undefined;
|
|
635
|
-
} catch (error) {
|
|
636
|
-
return 'time_limit';
|
|
637
|
-
}
|
|
638
599
|
};
|
|
@@ -26,8 +26,6 @@ export declare class WalletPassEvaluator {
|
|
|
26
26
|
/** 检查代金券/折扣卡是否可用 并返回config */
|
|
27
27
|
checkVoucherAvailability(input: EvaluatorInput): {
|
|
28
28
|
isAvailable: boolean;
|
|
29
|
-
reason: string | undefined;
|
|
30
|
-
reasonCode: string | undefined;
|
|
31
29
|
config: {
|
|
32
30
|
[x: string]: any;
|
|
33
31
|
};
|
|
@@ -203,16 +203,14 @@ var WalletPassEvaluator = class {
|
|
|
203
203
|
}
|
|
204
204
|
/** 检查代金券/折扣卡是否可用 并返回config */
|
|
205
205
|
checkVoucherAvailability(input) {
|
|
206
|
-
var _a, _b, _c, _d, _e
|
|
206
|
+
var _a, _b, _c, _d, _e;
|
|
207
207
|
const { orderTotalAmount, products, vouchers } = input;
|
|
208
208
|
const results = this.evaluate(input);
|
|
209
209
|
const isAvailable = ((_a = results[0]) == null ? void 0 : _a.isApplicable) || false;
|
|
210
210
|
return {
|
|
211
211
|
isAvailable,
|
|
212
|
-
reason: (_b = results[0]) == null ? void 0 : _b.reason,
|
|
213
|
-
reasonCode: (_c = results[0]) == null ? void 0 : _c.reasonCode,
|
|
214
212
|
config: {
|
|
215
|
-
...(
|
|
213
|
+
...(_e = (_d = (_c = (_b = results[0]) == null ? void 0 : _b.strategyResult) == null ? void 0 : _c.config) == null ? void 0 : _d.metadata) == null ? void 0 : _e.custom
|
|
216
214
|
}
|
|
217
215
|
};
|
|
218
216
|
}
|
|
@@ -23,14 +23,11 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
23
23
|
customer_id: number;
|
|
24
24
|
with_wallet_pass_holder: 0 | 1;
|
|
25
25
|
request_timezone: string;
|
|
26
|
-
order_id?: number
|
|
27
|
-
with_entitlement_pass?: 0 | 1;
|
|
28
|
-
filter_order_wallet_pass_usage?: 0 | 1;
|
|
26
|
+
order_id?: number;
|
|
29
27
|
}): Promise<Discount[]>;
|
|
30
|
-
batchSearch(code: string,
|
|
28
|
+
batchSearch(code: string, options?: {
|
|
31
29
|
customerId?: number;
|
|
32
|
-
orderId?: number
|
|
33
|
-
withEntitlementPass?: boolean;
|
|
30
|
+
orderId?: number;
|
|
34
31
|
}): Promise<DiscountWithReason>;
|
|
35
32
|
batchSearchByProductIds(productIds: number[]): Promise<any>;
|
|
36
33
|
filterEnabledDiscountList(discountList: Discount[]): Discount[];
|