@pisell/pisellos 2.2.273 → 2.2.275
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 +9 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +12 -10
- package/dist/modules/Order/index.d.ts +7 -6
- package/dist/modules/Order/index.js +217 -115
- package/dist/modules/Order/types.d.ts +23 -3
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Payment/index.js +1 -1
- package/dist/modules/Payment/types.d.ts +81 -4
- package/dist/modules/Payment/types.js +18 -3
- package/dist/modules/Payment/walletpass.d.ts +38 -1
- package/dist/modules/Payment/walletpass.js +917 -114
- package/dist/modules/Rules/index.d.ts +2 -0
- package/dist/modules/Rules/index.js +78 -64
- package/dist/modules/SalesSummary/utils.js +7 -1
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.js +27 -18
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/order/index.d.ts +16 -0
- package/dist/server/modules/order/index.js +964 -776
- package/dist/server/modules/order/types.d.ts +14 -0
- package/dist/server/modules/order/types.js +6 -0
- package/dist/solution/BaseSales/index.d.ts +80 -15
- package/dist/solution/BaseSales/index.js +1498 -444
- package/dist/solution/BaseSales/types.d.ts +55 -1
- package/dist/solution/BaseSales/types.js +2 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +8 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +12 -3
- package/dist/solution/BookingTicket/types.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +173 -83
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +16 -2
- package/dist/solution/VenueBooking/index.d.ts +1 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -1
- package/lib/modules/Order/index.d.ts +7 -6
- package/lib/modules/Order/index.js +127 -20
- package/lib/modules/Order/types.d.ts +23 -3
- package/lib/modules/Payment/index.js +1 -1
- package/lib/modules/Payment/types.d.ts +81 -4
- package/lib/modules/Payment/types.js +4 -3
- package/lib/modules/Payment/walletpass.d.ts +38 -1
- package/lib/modules/Payment/walletpass.js +730 -21
- package/lib/modules/Rules/index.d.ts +2 -0
- package/lib/modules/Rules/index.js +24 -14
- package/lib/modules/SalesSummary/utils.js +5 -1
- package/lib/server/index.d.ts +4 -0
- package/lib/server/index.js +14 -6
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/order/index.d.ts +16 -0
- package/lib/server/modules/order/index.js +140 -4
- package/lib/server/modules/order/types.d.ts +14 -0
- package/lib/server/modules/order/types.js +1 -0
- package/lib/solution/BaseSales/index.d.ts +80 -15
- package/lib/solution/BaseSales/index.js +712 -48
- package/lib/solution/BaseSales/types.d.ts +55 -1
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +8 -2
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +4 -1
- package/lib/solution/BookingTicket/types.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +37 -5
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +15 -3
- package/lib/solution/VenueBooking/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -10,8 +10,6 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
|
|
|
10
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."); }
|
|
11
11
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
12
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
13
|
-
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; }
|
|
14
|
-
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; }
|
|
15
13
|
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; } } }; }
|
|
16
14
|
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); }
|
|
17
15
|
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; }
|
|
@@ -27,6 +25,8 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
27
25
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
28
26
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
29
27
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
28
|
+
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; }
|
|
29
|
+
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; }
|
|
30
30
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
31
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
32
32
|
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); }
|
|
@@ -70,6 +70,22 @@ function isManualProductDiscountProduct(product) {
|
|
|
70
70
|
}
|
|
71
71
|
var ORDER_PAYMENT_STATUS_PAID = 'paid';
|
|
72
72
|
var ORDER_PAYMENT_STATUS_PENDING = 'payment_pending';
|
|
73
|
+
var CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['good_pass', 'product_discount_card', 'discount_card']);
|
|
74
|
+
function isCustomerPromotionDiscount(discount) {
|
|
75
|
+
return CUSTOMER_PROMOTION_DISCOUNT_TAGS.has(String((discount === null || discount === void 0 ? void 0 : discount.tag) || (discount === null || discount === void 0 ? void 0 : discount.type) || '').toLowerCase());
|
|
76
|
+
}
|
|
77
|
+
function markScannedDiscounts(discountList, scannedDiscountList) {
|
|
78
|
+
var scannedIds = new Set(scannedDiscountList.map(function (discount) {
|
|
79
|
+
return discount === null || discount === void 0 ? void 0 : discount.id;
|
|
80
|
+
}).filter(function (id) {
|
|
81
|
+
return id !== undefined && id !== null;
|
|
82
|
+
}).map(String));
|
|
83
|
+
return discountList.map(function (discount) {
|
|
84
|
+
return scannedIds.has(String(discount === null || discount === void 0 ? void 0 : discount.id)) ? _objectSpread(_objectSpread({}, discount), {}, {
|
|
85
|
+
isScan: true
|
|
86
|
+
}) : discount;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
73
89
|
function isVoucherPaymentRecord(payment) {
|
|
74
90
|
return (payment === null || payment === void 0 ? void 0 : payment.voucher_id) !== undefined && Number(payment.voucher_id) !== 0;
|
|
75
91
|
}
|
|
@@ -147,6 +163,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
147
163
|
var item = _step2.value;
|
|
148
164
|
var type = (_item$type2 = item === null || item === void 0 ? void 0 : item.type) !== null && _item$type2 !== void 0 ? _item$type2 : item === null || item === void 0 ? void 0 : item.tag;
|
|
149
165
|
if (!type || type === 'product') continue;
|
|
166
|
+
var isDiscountCard = type === 'discount_card' || type === 'product_discount_card';
|
|
150
167
|
var resourceId = (_ref = (_ref2 = (_item$discount$resour = item === null || item === void 0 || (_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id) !== null && _item$discount$resour !== void 0 ? _item$discount$resour : item === null || item === void 0 ? void 0 : item.resource_id) !== null && _ref2 !== void 0 ? _ref2 : item === null || item === void 0 ? void 0 : item.discount_id) !== null && _ref !== void 0 ? _ref : item === null || item === void 0 ? void 0 : item.order_discount_id;
|
|
151
168
|
if (resourceId === undefined || resourceId === null || resourceId === '') continue;
|
|
152
169
|
var id = Number(resourceId);
|
|
@@ -169,7 +186,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
169
186
|
var _existed$limited_rela;
|
|
170
187
|
existed.amount = Number(existed.amount || 0) + amount;
|
|
171
188
|
existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
|
|
172
|
-
|
|
189
|
+
if (!isDiscountCard) {
|
|
190
|
+
existed.balance = String(Number(existed.balance || 0) + amount);
|
|
191
|
+
}
|
|
173
192
|
var productIds = Array.isArray((_existed$limited_rela = existed.limited_relation_product_data) === null || _existed$limited_rela === void 0 ? void 0 : _existed$limited_rela.product_ids) ? existed.limited_relation_product_data.product_ids : [];
|
|
174
193
|
if ((product === null || product === void 0 ? void 0 : product.product_id) !== undefined && (product === null || product === void 0 ? void 0 : product.product_id) !== null && !productIds.includes(product.product_id)) {
|
|
175
194
|
existed.limited_relation_product_data = _objectSpread(_objectSpread({}, existed.limited_relation_product_data || {}), {}, {
|
|
@@ -201,7 +220,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
201
220
|
filter: 0,
|
|
202
221
|
exclude_product_ids: []
|
|
203
222
|
},
|
|
204
|
-
balance: String((_item$amount3 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount3 !== void 0 ? _item$amount3 : '0'),
|
|
223
|
+
balance: isDiscountCard ? undefined : String((_item$amount3 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount3 !== void 0 ? _item$amount3 : '0'),
|
|
205
224
|
format_title: title,
|
|
206
225
|
product: {
|
|
207
226
|
id: (_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : 0,
|
|
@@ -667,7 +686,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
667
686
|
value: function () {
|
|
668
687
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
669
688
|
var _this$store$discount11, _tempOrder$holder, _this$store$summary;
|
|
670
|
-
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, unavailableReason, _this$store$discount12;
|
|
689
|
+
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, shouldRetainForLater, normalizedNewDiscountList, retainedDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13;
|
|
671
690
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
672
691
|
while (1) switch (_context6.prev = _context6.next) {
|
|
673
692
|
case 0:
|
|
@@ -696,6 +715,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
696
715
|
return _context6.abrupt("return", {
|
|
697
716
|
type: 'clientCalc',
|
|
698
717
|
isAvailable: false,
|
|
718
|
+
isAccepted: false,
|
|
699
719
|
discountList: this.getDiscountList(),
|
|
700
720
|
scannedDiscountList: resultDiscountList,
|
|
701
721
|
unavailableReason: UnavailableReason.Unknown
|
|
@@ -708,6 +728,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
708
728
|
return _context6.abrupt("return", {
|
|
709
729
|
type: 'server',
|
|
710
730
|
isAvailable: false,
|
|
731
|
+
isAccepted: false,
|
|
711
732
|
discountList: this.getDiscountList(),
|
|
712
733
|
scannedDiscountList: resultDiscountList,
|
|
713
734
|
unavailableReasonKey: unavailableReasonKey
|
|
@@ -735,6 +756,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
735
756
|
return _context6.abrupt("return", {
|
|
736
757
|
type: 'clientCalc',
|
|
737
758
|
isAvailable: true,
|
|
759
|
+
isAccepted: true,
|
|
738
760
|
discountList: this.getDiscountList(),
|
|
739
761
|
scannedDiscountList: resultDiscountList
|
|
740
762
|
});
|
|
@@ -753,24 +775,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
753
775
|
}) || {
|
|
754
776
|
isAvailable: false,
|
|
755
777
|
discountList: this.getDiscountList()
|
|
756
|
-
}, isAvailable = _ref13.isAvailable, newDiscountList = _ref13.discountList, unavailableReason = _ref13.unavailableReason;
|
|
757
|
-
|
|
758
|
-
|
|
778
|
+
}, isAvailable = _ref13.isAvailable, newDiscountList = _ref13.discountList, evaluatedDiscountList = _ref13.evaluatedDiscountList, unavailableReason = _ref13.unavailableReason;
|
|
779
|
+
shouldRetainForLater = !isAvailable && unavailableReason === UnavailableReason.ProductNotApplicable && withScanList.some(isCustomerPromotionDiscount);
|
|
780
|
+
normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
|
|
781
|
+
retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
|
|
782
|
+
resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
|
|
783
|
+
if (!(isAvailable && normalizedNewDiscountList)) {
|
|
784
|
+
_context6.next = 34;
|
|
759
785
|
break;
|
|
760
786
|
}
|
|
761
|
-
|
|
787
|
+
_context6.next = 28;
|
|
788
|
+
return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
|
|
789
|
+
case 28:
|
|
762
790
|
this.applyDiscount();
|
|
763
|
-
_context6.next =
|
|
791
|
+
_context6.next = 31;
|
|
764
792
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
765
|
-
case
|
|
793
|
+
case 31:
|
|
794
|
+
resolvedDiscountList = this.getDiscountList();
|
|
795
|
+
_context6.next = 40;
|
|
796
|
+
break;
|
|
797
|
+
case 34:
|
|
798
|
+
if (!(shouldRetainForLater && retainedDiscountList)) {
|
|
799
|
+
_context6.next = 40;
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
802
|
+
_context6.next = 37;
|
|
803
|
+
return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(retainedDiscountList);
|
|
804
|
+
case 37:
|
|
805
|
+
_context6.next = 39;
|
|
806
|
+
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
807
|
+
case 39:
|
|
808
|
+
resolvedDiscountList = this.getDiscountList();
|
|
809
|
+
case 40:
|
|
766
810
|
return _context6.abrupt("return", {
|
|
767
811
|
type: 'clientCalc',
|
|
768
812
|
isAvailable: isAvailable || false,
|
|
769
|
-
|
|
813
|
+
isAccepted: Boolean(isAvailable || shouldRetainForLater),
|
|
814
|
+
discountList: resolvedDiscountList,
|
|
770
815
|
scannedDiscountList: resultDiscountList,
|
|
771
816
|
unavailableReason: unavailableReason
|
|
772
817
|
});
|
|
773
|
-
case
|
|
818
|
+
case 41:
|
|
774
819
|
case "end":
|
|
775
820
|
return _context6.stop();
|
|
776
821
|
}
|
|
@@ -784,7 +829,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
784
829
|
}, {
|
|
785
830
|
key: "applyDiscount",
|
|
786
831
|
value: function applyDiscount(options) {
|
|
787
|
-
var _this$store$
|
|
832
|
+
var _this$store$discount14,
|
|
788
833
|
_this$store$summary2,
|
|
789
834
|
_this2 = this;
|
|
790
835
|
var tempOrder = this.store.tempOrder;
|
|
@@ -794,7 +839,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
794
839
|
if (!tempOrder) return;
|
|
795
840
|
this.syncLinkedBookingHoldersToProducts(tempOrder);
|
|
796
841
|
delete tempOrder.discount_list;
|
|
797
|
-
var discountList = ((_this$store$
|
|
842
|
+
var discountList = ((_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.getDiscountList()) || [];
|
|
798
843
|
var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
|
|
799
844
|
if (shouldSkipDiscountCalculation) return;
|
|
800
845
|
var rulesModule = this.store.rules;
|
|
@@ -826,9 +871,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
826
871
|
}));
|
|
827
872
|
}
|
|
828
873
|
if (result !== null && result !== void 0 && result.discountList) {
|
|
829
|
-
var _this$store$
|
|
874
|
+
var _this$store$discount15;
|
|
830
875
|
OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
|
|
831
|
-
(_this$store$
|
|
876
|
+
(_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 || _this$store$discount15.setDiscountList(result.discountList);
|
|
832
877
|
}
|
|
833
878
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
834
879
|
return _this2.productHasCustomerBoundDiscount(product);
|
|
@@ -2282,7 +2327,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2282
2327
|
}, {
|
|
2283
2328
|
key: "restoreOrder",
|
|
2284
2329
|
value: function restoreOrder() {
|
|
2285
|
-
var _this$store$
|
|
2330
|
+
var _this$store$discount16, _this$store$discount17;
|
|
2286
2331
|
this.logInfo('restoreOrder start', {});
|
|
2287
2332
|
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
2288
2333
|
this.ensureExternalSaleNumber(freshTempOrder);
|
|
@@ -2290,8 +2335,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2290
2335
|
this.store.summary = createEmptySummary();
|
|
2291
2336
|
this.store.lastOrderInfo = undefined;
|
|
2292
2337
|
this.store.syncState = undefined;
|
|
2293
|
-
void ((_this$store$
|
|
2294
|
-
void ((_this$store$
|
|
2338
|
+
void ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setOriginalDiscountList([]));
|
|
2339
|
+
void ((_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 ? void 0 : _this$store$discount17.setDiscountList([]));
|
|
2295
2340
|
this.persistTempOrder();
|
|
2296
2341
|
return freshTempOrder;
|
|
2297
2342
|
}
|
|
@@ -3114,11 +3159,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3114
3159
|
}, {
|
|
3115
3160
|
key: "shouldSkipDiscountCalculation",
|
|
3116
3161
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
3117
|
-
var _this$store$
|
|
3118
|
-
_this$store$
|
|
3162
|
+
var _this$store$discount18,
|
|
3163
|
+
_this$store$discount19,
|
|
3119
3164
|
_this20 = this;
|
|
3120
3165
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
3121
|
-
var discountList = ((_this$store$
|
|
3166
|
+
var discountList = ((_this$store$discount18 = this.store.discount) === null || _this$store$discount18 === void 0 || (_this$store$discount19 = _this$store$discount18.getDiscountList) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.call(_this$store$discount18)) || [];
|
|
3122
3167
|
if (discountList.length > 0) return false;
|
|
3123
3168
|
return !(tempOrder.products || []).some(function (product) {
|
|
3124
3169
|
return _this20.productHasCustomerBoundDiscount(product);
|
|
@@ -3831,11 +3876,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3831
3876
|
}, {
|
|
3832
3877
|
key: "appendProductLineToTempOrder",
|
|
3833
3878
|
value: (function () {
|
|
3834
|
-
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(tempOrder, product, booking) {
|
|
3835
|
-
var
|
|
3879
|
+
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(tempOrder, product, booking, options) {
|
|
3880
|
+
var _normalizedIncoming$p,
|
|
3881
|
+
_normalizedIncoming$p2,
|
|
3882
|
+
_booking_uid,
|
|
3836
3883
|
_metadata,
|
|
3884
|
+
_productToAdd$metadat,
|
|
3885
|
+
_origin,
|
|
3837
3886
|
_this26 = this;
|
|
3838
|
-
var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
|
|
3887
|
+
var linked, productToAdd, incomingFingerprint, normalizedIncoming, isWeighingProduct, netWeight, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, isIncomingCustomItem, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, insertAtIndex, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList, mergedProduct;
|
|
3839
3888
|
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
3840
3889
|
while (1) switch (_context22.prev = _context22.next) {
|
|
3841
3890
|
case 0:
|
|
@@ -3846,6 +3895,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3846
3895
|
productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
|
|
3847
3896
|
incomingFingerprint = buildProductLineFingerprint(getProductSkuOptions(productToAdd), productToAdd.product_bundle);
|
|
3848
3897
|
normalizedIncoming = mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd));
|
|
3898
|
+
isWeighingProduct = Number(((_normalizedIncoming$p = normalizedIncoming.product_sku) === null || _normalizedIncoming$p === void 0 ? void 0 : _normalizedIncoming$p.open_sold_weight) || 0) === 1;
|
|
3899
|
+
netWeight = Number((_normalizedIncoming$p2 = normalizedIncoming.product_sku) === null || _normalizedIncoming$p2 === void 0 ? void 0 : _normalizedIncoming$p2.net_weight);
|
|
3900
|
+
if (!(isWeighingProduct && (!Number.isFinite(netWeight) || netWeight <= 0))) {
|
|
3901
|
+
_context22.next = 8;
|
|
3902
|
+
break;
|
|
3903
|
+
}
|
|
3904
|
+
throw new Error('[Order] 称重商品净重必须大于 0');
|
|
3905
|
+
case 8:
|
|
3849
3906
|
incomingBookingUid = (_booking_uid = productToAdd.booking_uid) !== null && _booking_uid !== void 0 ? _booking_uid : (_metadata = productToAdd.metadata) === null || _metadata === void 0 ? void 0 : _metadata.booking_uid;
|
|
3850
3907
|
if (incomingBookingUid !== undefined && incomingBookingUid !== null && String(incomingBookingUid) !== '') {
|
|
3851
3908
|
normalizedIncoming.booking_uid = String(incomingBookingUid);
|
|
@@ -3857,7 +3914,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3857
3914
|
hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
3858
3915
|
hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
|
|
3859
3916
|
hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
3860
|
-
|
|
3917
|
+
isIncomingCustomItem = ((_productToAdd$metadat = productToAdd.metadata) === null || _productToAdd$metadat === void 0 || (_productToAdd$metadat = _productToAdd$metadat.origin) === null || _productToAdd$metadat === void 0 ? void 0 : _productToAdd$metadat.isCustomItem) === true || ((_origin = productToAdd._origin) === null || _origin === void 0 ? void 0 : _origin.isCustomItem) === true;
|
|
3918
|
+
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
3861
3919
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
3862
3920
|
var _item$metadata3;
|
|
3863
3921
|
if (_this26.hasGoodPassDiscount(item)) return false;
|
|
@@ -3872,10 +3930,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3872
3930
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
3873
3931
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
3874
3932
|
if (!matchedProduct) {
|
|
3875
|
-
_context22.next =
|
|
3933
|
+
_context22.next = 25;
|
|
3876
3934
|
break;
|
|
3877
3935
|
}
|
|
3878
|
-
_context22.next =
|
|
3936
|
+
_context22.next = 22;
|
|
3879
3937
|
return this.shouldMergeProductToOrder({
|
|
3880
3938
|
incomingProduct: productToAdd,
|
|
3881
3939
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -3886,13 +3944,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3886
3944
|
tempOrder: tempOrder,
|
|
3887
3945
|
booking: booking
|
|
3888
3946
|
});
|
|
3889
|
-
case
|
|
3947
|
+
case 22:
|
|
3890
3948
|
_context22.t0 = _context22.sent;
|
|
3891
|
-
_context22.next =
|
|
3949
|
+
_context22.next = 26;
|
|
3892
3950
|
break;
|
|
3893
|
-
case
|
|
3951
|
+
case 25:
|
|
3894
3952
|
_context22.t0 = false;
|
|
3895
|
-
case
|
|
3953
|
+
case 26:
|
|
3896
3954
|
shouldMerge = _context22.t0;
|
|
3897
3955
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
3898
3956
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
@@ -3902,8 +3960,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3902
3960
|
booking_uid: linked.bookingUid
|
|
3903
3961
|
});
|
|
3904
3962
|
}
|
|
3905
|
-
|
|
3906
|
-
|
|
3963
|
+
insertAtIndex = options === null || options === void 0 ? void 0 : options.insertAtIndex;
|
|
3964
|
+
if (Number.isInteger(insertAtIndex) && Number(insertAtIndex) >= 0 && Number(insertAtIndex) < tempOrder.products.length) {
|
|
3965
|
+
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, insertAtIndex)), [normalizedIncoming], _toConsumableArray(tempOrder.products.slice(insertAtIndex)));
|
|
3966
|
+
} else {
|
|
3967
|
+
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products), [normalizedIncoming]);
|
|
3968
|
+
}
|
|
3907
3969
|
} else {
|
|
3908
3970
|
targetProduct = matchedProduct;
|
|
3909
3971
|
targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
@@ -3941,17 +4003,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3941
4003
|
num: nextNum
|
|
3942
4004
|
});
|
|
3943
4005
|
this.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
4006
|
+
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
4007
|
+
mergedProduct = tempOrder.products[matchedIndex];
|
|
4008
|
+
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, matchedIndex)), _toConsumableArray(tempOrder.products.slice(matchedIndex + 1)), [mergedProduct]);
|
|
4009
|
+
}
|
|
3944
4010
|
}
|
|
3945
4011
|
if (linked) {
|
|
3946
4012
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
3947
4013
|
}
|
|
3948
|
-
case
|
|
4014
|
+
case 29:
|
|
3949
4015
|
case "end":
|
|
3950
4016
|
return _context22.stop();
|
|
3951
4017
|
}
|
|
3952
4018
|
}, _callee20, this);
|
|
3953
4019
|
}));
|
|
3954
|
-
function appendProductLineToTempOrder(_x22, _x23, _x24) {
|
|
4020
|
+
function appendProductLineToTempOrder(_x22, _x23, _x24, _x25) {
|
|
3955
4021
|
return _appendProductLineToTempOrder.apply(this, arguments);
|
|
3956
4022
|
}
|
|
3957
4023
|
return appendProductLineToTempOrder;
|
|
@@ -3967,61 +4033,74 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3967
4033
|
}, {
|
|
3968
4034
|
key: "addProductToOrder",
|
|
3969
4035
|
value: (function () {
|
|
3970
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(product, booking) {
|
|
3971
|
-
var tempOrder, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
|
|
4036
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(product, booking, options) {
|
|
4037
|
+
var tempOrder, insertAfterProductUid, anchorIndex, insertAtIndex, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
|
|
3972
4038
|
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
3973
4039
|
while (1) switch (_context23.prev = _context23.next) {
|
|
3974
4040
|
case 0:
|
|
3975
4041
|
tempOrder = this.ensureTempOrder();
|
|
4042
|
+
insertAfterProductUid = options === null || options === void 0 ? void 0 : options.insertAfterProductUid;
|
|
4043
|
+
anchorIndex = booking && insertAfterProductUid ? tempOrder.products.findIndex(function (line) {
|
|
4044
|
+
var _line$metadata;
|
|
4045
|
+
var uid = ((_line$metadata = line.metadata) === null || _line$metadata === void 0 ? void 0 : _line$metadata.unique_identification_number) || line.unique_identification_number;
|
|
4046
|
+
return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
|
|
4047
|
+
}) : -1;
|
|
4048
|
+
insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
3976
4049
|
if (!booking) {
|
|
3977
|
-
_context23.next =
|
|
4050
|
+
_context23.next = 22;
|
|
3978
4051
|
break;
|
|
3979
4052
|
}
|
|
3980
4053
|
productRecord = product;
|
|
3981
4054
|
splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
|
|
3982
4055
|
if (!(splitCount > 1)) {
|
|
3983
|
-
_context23.next =
|
|
4056
|
+
_context23.next = 22;
|
|
3984
4057
|
break;
|
|
3985
4058
|
}
|
|
3986
4059
|
i = 0;
|
|
3987
|
-
case
|
|
4060
|
+
case 9:
|
|
3988
4061
|
if (!(i < splitCount)) {
|
|
3989
|
-
_context23.next =
|
|
4062
|
+
_context23.next = 19;
|
|
3990
4063
|
break;
|
|
3991
4064
|
}
|
|
3992
4065
|
singleLine = cloneDeep(productRecord);
|
|
3993
4066
|
singleLine.num = 1;
|
|
3994
4067
|
delete singleLine.product_quantity;
|
|
3995
|
-
_context23.next =
|
|
3996
|
-
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking)
|
|
3997
|
-
|
|
4068
|
+
_context23.next = 15;
|
|
4069
|
+
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking), {
|
|
4070
|
+
insertAtIndex: insertAtIndex
|
|
4071
|
+
});
|
|
4072
|
+
case 15:
|
|
4073
|
+
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
4074
|
+
case 16:
|
|
3998
4075
|
i += 1;
|
|
3999
|
-
_context23.next =
|
|
4076
|
+
_context23.next = 9;
|
|
4000
4077
|
break;
|
|
4001
|
-
case
|
|
4002
|
-
_context23.next =
|
|
4078
|
+
case 19:
|
|
4079
|
+
_context23.next = 21;
|
|
4003
4080
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
4004
|
-
case
|
|
4081
|
+
case 21:
|
|
4005
4082
|
return _context23.abrupt("return", tempOrder.products);
|
|
4006
|
-
case 18:
|
|
4007
|
-
_context23.next = 20;
|
|
4008
|
-
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
4009
|
-
case 20:
|
|
4010
|
-
_context23.next = 22;
|
|
4011
|
-
return this.finalizeProductOrderMutation(tempOrder);
|
|
4012
4083
|
case 22:
|
|
4084
|
+
_context23.next = 24;
|
|
4085
|
+
return this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
4086
|
+
insertAtIndex: insertAtIndex
|
|
4087
|
+
});
|
|
4088
|
+
case 24:
|
|
4089
|
+
_context23.next = 26;
|
|
4090
|
+
return this.finalizeProductOrderMutation(tempOrder);
|
|
4091
|
+
case 26:
|
|
4013
4092
|
this.logInfo('addProductToOrder success', {
|
|
4014
4093
|
product_id: product.product_id,
|
|
4015
4094
|
with_booking: !!booking
|
|
4016
4095
|
});
|
|
4017
4096
|
return _context23.abrupt("return", tempOrder.products);
|
|
4018
|
-
case
|
|
4097
|
+
case 28:
|
|
4019
4098
|
case "end":
|
|
4020
4099
|
return _context23.stop();
|
|
4021
4100
|
}
|
|
4022
4101
|
}, _callee21, this);
|
|
4023
4102
|
}));
|
|
4024
|
-
function addProductToOrder(
|
|
4103
|
+
function addProductToOrder(_x26, _x27, _x28) {
|
|
4025
4104
|
return _addProductToOrder.apply(this, arguments);
|
|
4026
4105
|
}
|
|
4027
4106
|
return addProductToOrder;
|
|
@@ -4125,7 +4204,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4125
4204
|
}
|
|
4126
4205
|
}, _callee22, this, [[4, 32, 35, 38]]);
|
|
4127
4206
|
}));
|
|
4128
|
-
function addProductsToOrder(
|
|
4207
|
+
function addProductsToOrder(_x29, _x30) {
|
|
4129
4208
|
return _addProductsToOrder.apply(this, arguments);
|
|
4130
4209
|
}
|
|
4131
4210
|
return addProductsToOrder;
|
|
@@ -4400,7 +4479,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4400
4479
|
}
|
|
4401
4480
|
}, _callee23, this);
|
|
4402
4481
|
}));
|
|
4403
|
-
function updateOrderProduct(
|
|
4482
|
+
function updateOrderProduct(_x31) {
|
|
4404
4483
|
return _updateOrderProduct.apply(this, arguments);
|
|
4405
4484
|
}
|
|
4406
4485
|
return updateOrderProduct;
|
|
@@ -4444,7 +4523,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4444
4523
|
}
|
|
4445
4524
|
}, _callee24, this);
|
|
4446
4525
|
}));
|
|
4447
|
-
function updateOrderProducts(
|
|
4526
|
+
function updateOrderProducts(_x32) {
|
|
4448
4527
|
return _updateOrderProducts.apply(this, arguments);
|
|
4449
4528
|
}
|
|
4450
4529
|
return updateOrderProducts;
|
|
@@ -4520,7 +4599,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4520
4599
|
}
|
|
4521
4600
|
}, _callee25, this);
|
|
4522
4601
|
}));
|
|
4523
|
-
function updateOrderProductQuantity(
|
|
4602
|
+
function updateOrderProductQuantity(_x33) {
|
|
4524
4603
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
4525
4604
|
}
|
|
4526
4605
|
return updateOrderProductQuantity;
|
|
@@ -4585,7 +4664,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4585
4664
|
}
|
|
4586
4665
|
}, _callee26, this);
|
|
4587
4666
|
}));
|
|
4588
|
-
function finalizeAfterProductsMutation(
|
|
4667
|
+
function finalizeAfterProductsMutation(_x34, _x35) {
|
|
4589
4668
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
4590
4669
|
}
|
|
4591
4670
|
return finalizeAfterProductsMutation;
|
|
@@ -4600,9 +4679,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4600
4679
|
}, {
|
|
4601
4680
|
key: "removeProductsFromOrder",
|
|
4602
4681
|
value: (function () {
|
|
4603
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identities) {
|
|
4682
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identities, options) {
|
|
4604
4683
|
var _this29 = this;
|
|
4605
|
-
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
|
|
4684
|
+
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
4606
4685
|
return _regeneratorRuntime().wrap(function _callee27$(_context30) {
|
|
4607
4686
|
while (1) switch (_context30.prev = _context30.next) {
|
|
4608
4687
|
case 0:
|
|
@@ -4615,6 +4694,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4615
4694
|
case 3:
|
|
4616
4695
|
productsBeforeRemove = tempOrder.products || [];
|
|
4617
4696
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
4697
|
+
preserveDisplayPosition = options === null || options === void 0 ? void 0 : options.preserveDisplayPosition;
|
|
4698
|
+
anchorIndex = preserveDisplayPosition ? productsBeforeRemove.findIndex(function (item) {
|
|
4699
|
+
var _item$metadata6;
|
|
4700
|
+
var uid = ((_item$metadata6 = item.metadata) === null || _item$metadata6 === void 0 ? void 0 : _item$metadata6.unique_identification_number) || item.unique_identification_number;
|
|
4701
|
+
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.anchorProductUid);
|
|
4702
|
+
}) : -1;
|
|
4703
|
+
productsAfterAnchor = anchorIndex >= 0 ? productsBeforeRemove.slice(anchorIndex + 1) : [];
|
|
4618
4704
|
matchedProducts = productsBeforeRemove.filter(function (item) {
|
|
4619
4705
|
return identities.some(function (identity) {
|
|
4620
4706
|
return isIdentityMatch(item, identity);
|
|
@@ -4634,7 +4720,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4634
4720
|
}
|
|
4635
4721
|
linkedBookingUidsToRemove = new Set();
|
|
4636
4722
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
4637
|
-
_context30.prev =
|
|
4723
|
+
_context30.prev = 14;
|
|
4638
4724
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
4639
4725
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
4640
4726
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
@@ -4669,56 +4755,72 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4669
4755
|
}, _loop3);
|
|
4670
4756
|
});
|
|
4671
4757
|
_iterator21.s();
|
|
4672
|
-
case
|
|
4758
|
+
case 17:
|
|
4673
4759
|
if ((_step21 = _iterator21.n()).done) {
|
|
4674
|
-
_context30.next =
|
|
4760
|
+
_context30.next = 23;
|
|
4675
4761
|
break;
|
|
4676
4762
|
}
|
|
4677
|
-
return _context30.delegateYield(_loop3(), "t0",
|
|
4678
|
-
case
|
|
4763
|
+
return _context30.delegateYield(_loop3(), "t0", 19);
|
|
4764
|
+
case 19:
|
|
4679
4765
|
if (!_context30.t0) {
|
|
4680
|
-
_context30.next =
|
|
4766
|
+
_context30.next = 21;
|
|
4681
4767
|
break;
|
|
4682
4768
|
}
|
|
4683
|
-
return _context30.abrupt("continue",
|
|
4684
|
-
case
|
|
4685
|
-
_context30.next =
|
|
4769
|
+
return _context30.abrupt("continue", 21);
|
|
4770
|
+
case 21:
|
|
4771
|
+
_context30.next = 17;
|
|
4686
4772
|
break;
|
|
4687
|
-
case
|
|
4688
|
-
_context30.next =
|
|
4773
|
+
case 23:
|
|
4774
|
+
_context30.next = 28;
|
|
4689
4775
|
break;
|
|
4690
|
-
case 22:
|
|
4691
|
-
_context30.prev = 22;
|
|
4692
|
-
_context30.t1 = _context30["catch"](11);
|
|
4693
|
-
_iterator21.e(_context30.t1);
|
|
4694
4776
|
case 25:
|
|
4695
4777
|
_context30.prev = 25;
|
|
4696
|
-
|
|
4697
|
-
|
|
4778
|
+
_context30.t1 = _context30["catch"](14);
|
|
4779
|
+
_iterator21.e(_context30.t1);
|
|
4698
4780
|
case 28:
|
|
4781
|
+
_context30.prev = 28;
|
|
4782
|
+
_iterator21.f();
|
|
4783
|
+
return _context30.finish(28);
|
|
4784
|
+
case 31:
|
|
4699
4785
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
4700
4786
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
4701
4787
|
tempOrder.products = (tempOrder.products || []).filter(function (line) {
|
|
4702
|
-
var _line$
|
|
4703
|
-
var lineBookingUid = (line === null || line === void 0 || (_line$
|
|
4704
|
-
var isAddTimeProduct = (line === null || line === void 0 || (_line$
|
|
4788
|
+
var _line$metadata2, _line$metadata3, _line$metadata4;
|
|
4789
|
+
var lineBookingUid = (line === null || line === void 0 || (_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.booking_uid) || (line === null || line === void 0 ? void 0 : line.booking_uid);
|
|
4790
|
+
var isAddTimeProduct = (line === null || line === void 0 || (_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.product_add_schedule_time) !== undefined && (line === null || line === void 0 || (_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.product_add_schedule_time) !== null;
|
|
4705
4791
|
return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
|
|
4706
4792
|
});
|
|
4707
4793
|
}
|
|
4708
|
-
|
|
4794
|
+
if (preserveDisplayPosition && anchorIndex >= 0) {
|
|
4795
|
+
remainingProductIndex = tempOrder.products.findIndex(function (item) {
|
|
4796
|
+
var _item$metadata7;
|
|
4797
|
+
var uid = ((_item$metadata7 = item.metadata) === null || _item$metadata7 === void 0 ? void 0 : _item$metadata7.unique_identification_number) || item.unique_identification_number;
|
|
4798
|
+
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.remainingProductUid);
|
|
4799
|
+
});
|
|
4800
|
+
if (remainingProductIndex >= 0) {
|
|
4801
|
+
remainingProduct = tempOrder.products[remainingProductIndex];
|
|
4802
|
+
nextProduct = productsAfterAnchor.find(function (item) {
|
|
4803
|
+
return tempOrder.products.includes(item);
|
|
4804
|
+
});
|
|
4805
|
+
productsWithoutRemaining = [].concat(_toConsumableArray(tempOrder.products.slice(0, remainingProductIndex)), _toConsumableArray(tempOrder.products.slice(remainingProductIndex + 1)));
|
|
4806
|
+
nextProductIndex = nextProduct ? productsWithoutRemaining.indexOf(nextProduct) : -1;
|
|
4807
|
+
tempOrder.products = nextProductIndex >= 0 ? [].concat(_toConsumableArray(productsWithoutRemaining.slice(0, nextProductIndex)), [remainingProduct], _toConsumableArray(productsWithoutRemaining.slice(nextProductIndex))) : [].concat(_toConsumableArray(productsWithoutRemaining), [remainingProduct]);
|
|
4808
|
+
}
|
|
4809
|
+
}
|
|
4810
|
+
_context30.next = 35;
|
|
4709
4811
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
4710
|
-
case
|
|
4812
|
+
case 35:
|
|
4711
4813
|
this.logInfo('removeProductsFromOrder success', {
|
|
4712
4814
|
identities: identities
|
|
4713
4815
|
});
|
|
4714
4816
|
return _context30.abrupt("return", tempOrder.products);
|
|
4715
|
-
case
|
|
4817
|
+
case 37:
|
|
4716
4818
|
case "end":
|
|
4717
4819
|
return _context30.stop();
|
|
4718
4820
|
}
|
|
4719
|
-
}, _callee27, this, [[
|
|
4821
|
+
}, _callee27, this, [[14, 25, 28, 31]]);
|
|
4720
4822
|
}));
|
|
4721
|
-
function removeProductsFromOrder(
|
|
4823
|
+
function removeProductsFromOrder(_x36, _x37) {
|
|
4722
4824
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
4723
4825
|
}
|
|
4724
4826
|
return removeProductsFromOrder;
|
|
@@ -4726,18 +4828,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4726
4828
|
}, {
|
|
4727
4829
|
key: "removeProductFromOrder",
|
|
4728
4830
|
value: function () {
|
|
4729
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity) {
|
|
4831
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity, options) {
|
|
4730
4832
|
return _regeneratorRuntime().wrap(function _callee28$(_context31) {
|
|
4731
4833
|
while (1) switch (_context31.prev = _context31.next) {
|
|
4732
4834
|
case 0:
|
|
4733
|
-
return _context31.abrupt("return", this.removeProductsFromOrder([identity]));
|
|
4835
|
+
return _context31.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
4734
4836
|
case 1:
|
|
4735
4837
|
case "end":
|
|
4736
4838
|
return _context31.stop();
|
|
4737
4839
|
}
|
|
4738
4840
|
}, _callee28, this);
|
|
4739
4841
|
}));
|
|
4740
|
-
function removeProductFromOrder(
|
|
4842
|
+
function removeProductFromOrder(_x38, _x39) {
|
|
4741
4843
|
return _removeProductFromOrder.apply(this, arguments);
|
|
4742
4844
|
}
|
|
4743
4845
|
return removeProductFromOrder;
|
|
@@ -4849,7 +4951,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4849
4951
|
}
|
|
4850
4952
|
}, _callee30, this);
|
|
4851
4953
|
}));
|
|
4852
|
-
function applyLocalPrintOrderNumbers(
|
|
4954
|
+
function applyLocalPrintOrderNumbers(_x40) {
|
|
4853
4955
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
4854
4956
|
}
|
|
4855
4957
|
return applyLocalPrintOrderNumbers;
|
|
@@ -4916,7 +5018,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4916
5018
|
}
|
|
4917
5019
|
}, _callee31, this);
|
|
4918
5020
|
}));
|
|
4919
|
-
function saveTempOrderAsDraft(
|
|
5021
|
+
function saveTempOrderAsDraft(_x41) {
|
|
4920
5022
|
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
4921
5023
|
}
|
|
4922
5024
|
return saveTempOrderAsDraft;
|
|
@@ -4941,7 +5043,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4941
5043
|
}
|
|
4942
5044
|
}, _callee32, this);
|
|
4943
5045
|
}));
|
|
4944
|
-
function submitTempOrder(
|
|
5046
|
+
function submitTempOrder(_x42) {
|
|
4945
5047
|
return _submitTempOrder.apply(this, arguments);
|
|
4946
5048
|
}
|
|
4947
5049
|
return submitTempOrder;
|
|
@@ -4962,7 +5064,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4962
5064
|
}
|
|
4963
5065
|
}, _callee33, this);
|
|
4964
5066
|
}));
|
|
4965
|
-
function submitTempOrderAsync(
|
|
5067
|
+
function submitTempOrderAsync(_x43) {
|
|
4966
5068
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
4967
5069
|
}
|
|
4968
5070
|
return submitTempOrderAsync;
|
|
@@ -5132,7 +5234,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5132
5234
|
}
|
|
5133
5235
|
}, _callee34, this, [[26, 33]]);
|
|
5134
5236
|
}));
|
|
5135
|
-
function runSubmitTempOrder(
|
|
5237
|
+
function runSubmitTempOrder(_x44) {
|
|
5136
5238
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
5137
5239
|
}
|
|
5138
5240
|
return runSubmitTempOrder;
|
|
@@ -5159,7 +5261,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5159
5261
|
}
|
|
5160
5262
|
}, _callee35, this);
|
|
5161
5263
|
}));
|
|
5162
|
-
function markLocalOrderSynced(
|
|
5264
|
+
function markLocalOrderSynced(_x45, _x46) {
|
|
5163
5265
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
5164
5266
|
}
|
|
5165
5267
|
return markLocalOrderSynced;
|
|
@@ -5314,7 +5416,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5314
5416
|
}
|
|
5315
5417
|
}, _callee36, this);
|
|
5316
5418
|
}));
|
|
5317
|
-
function syncPaymentsToOrder(
|
|
5419
|
+
function syncPaymentsToOrder(_x47) {
|
|
5318
5420
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
5319
5421
|
}
|
|
5320
5422
|
return syncPaymentsToOrder;
|
|
@@ -5434,7 +5536,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5434
5536
|
}
|
|
5435
5537
|
}, _callee37, this);
|
|
5436
5538
|
}));
|
|
5437
|
-
function submitOrder(
|
|
5539
|
+
function submitOrder(_x48) {
|
|
5438
5540
|
return _submitOrder.apply(this, arguments);
|
|
5439
5541
|
}
|
|
5440
5542
|
return submitOrder;
|
|
@@ -5473,7 +5575,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5473
5575
|
}
|
|
5474
5576
|
}, _callee38, this);
|
|
5475
5577
|
}));
|
|
5476
|
-
function cancelOrder(
|
|
5578
|
+
function cancelOrder(_x49) {
|
|
5477
5579
|
return _cancelOrder.apply(this, arguments);
|
|
5478
5580
|
}
|
|
5479
5581
|
return cancelOrder;
|
|
@@ -5517,7 +5619,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5517
5619
|
}
|
|
5518
5620
|
}, _callee39, this);
|
|
5519
5621
|
}));
|
|
5520
|
-
function changeBookingStatus(
|
|
5622
|
+
function changeBookingStatus(_x50) {
|
|
5521
5623
|
return _changeBookingStatus.apply(this, arguments);
|
|
5522
5624
|
}
|
|
5523
5625
|
return changeBookingStatus;
|
|
@@ -5664,7 +5766,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5664
5766
|
}
|
|
5665
5767
|
}, _callee40, this, [[4, 18]]);
|
|
5666
5768
|
}));
|
|
5667
|
-
function createOrderByCheckout(
|
|
5769
|
+
function createOrderByCheckout(_x51) {
|
|
5668
5770
|
return _createOrderByCheckout.apply(this, arguments);
|
|
5669
5771
|
}
|
|
5670
5772
|
return createOrderByCheckout;
|
|
@@ -5689,7 +5791,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5689
5791
|
}
|
|
5690
5792
|
}, _callee41, this);
|
|
5691
5793
|
}));
|
|
5692
|
-
function submitSalesOrder(
|
|
5794
|
+
function submitSalesOrder(_x52) {
|
|
5693
5795
|
return _submitSalesOrder.apply(this, arguments);
|
|
5694
5796
|
}
|
|
5695
5797
|
return submitSalesOrder;
|
|
@@ -5733,7 +5835,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5733
5835
|
}
|
|
5734
5836
|
}, _callee42, this);
|
|
5735
5837
|
}));
|
|
5736
|
-
function sendCustomerPayLink(
|
|
5838
|
+
function sendCustomerPayLink(_x53) {
|
|
5737
5839
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
5738
5840
|
}
|
|
5739
5841
|
return sendCustomerPayLink;
|
|
@@ -5759,7 +5861,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5759
5861
|
}
|
|
5760
5862
|
_context46.next = 6;
|
|
5761
5863
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
5762
|
-
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
5864
|
+
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'refunds']
|
|
5763
5865
|
}, params.forceRemote ? {
|
|
5764
5866
|
forceRemote: true
|
|
5765
5867
|
} : {}), {
|
|
@@ -5777,7 +5879,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5777
5879
|
}
|
|
5778
5880
|
}, _callee43, this);
|
|
5779
5881
|
}));
|
|
5780
|
-
function getSalesOrderByLookup(
|
|
5882
|
+
function getSalesOrderByLookup(_x54) {
|
|
5781
5883
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
5782
5884
|
}
|
|
5783
5885
|
return getSalesOrderByLookup;
|
|
@@ -5792,8 +5894,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5792
5894
|
key: "hydrateTempOrderFromRecord",
|
|
5793
5895
|
value: (function () {
|
|
5794
5896
|
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(record, options) {
|
|
5795
|
-
var _this$store$
|
|
5796
|
-
var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$
|
|
5897
|
+
var _this$store$discount20;
|
|
5898
|
+
var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount21, _this$store$discount22;
|
|
5797
5899
|
return _regeneratorRuntime().wrap(function _callee44$(_context47) {
|
|
5798
5900
|
while (1) switch (_context47.prev = _context47.next) {
|
|
5799
5901
|
case 0:
|
|
@@ -5852,7 +5954,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5852
5954
|
this.store.syncState = 'local';
|
|
5853
5955
|
}
|
|
5854
5956
|
hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
5855
|
-
currentDiscounts = typeof ((_this$store$
|
|
5957
|
+
currentDiscounts = typeof ((_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
|
|
5856
5958
|
currentScanDiscounts = currentDiscounts.filter(function (discount) {
|
|
5857
5959
|
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
5858
5960
|
});
|
|
@@ -5870,10 +5972,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5870
5972
|
}
|
|
5871
5973
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
5872
5974
|
_context47.next = 29;
|
|
5873
|
-
return (_this$store$
|
|
5975
|
+
return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setOriginalDiscountList(nextDiscounts);
|
|
5874
5976
|
case 29:
|
|
5875
5977
|
_context47.next = 31;
|
|
5876
|
-
return (_this$store$
|
|
5978
|
+
return (_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.setDiscountList(nextDiscounts);
|
|
5877
5979
|
case 31:
|
|
5878
5980
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
5879
5981
|
_context47.next = 34;
|
|
@@ -5892,7 +5994,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5892
5994
|
}
|
|
5893
5995
|
}, _callee44, this);
|
|
5894
5996
|
}));
|
|
5895
|
-
function hydrateTempOrderFromRecord(
|
|
5997
|
+
function hydrateTempOrderFromRecord(_x55, _x56) {
|
|
5896
5998
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
5897
5999
|
}
|
|
5898
6000
|
return hydrateTempOrderFromRecord;
|
|
@@ -6287,7 +6389,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6287
6389
|
}
|
|
6288
6390
|
}, _callee45, this);
|
|
6289
6391
|
}));
|
|
6290
|
-
function getOrderInfo(
|
|
6392
|
+
function getOrderInfo(_x57) {
|
|
6291
6393
|
return _getOrderInfo.apply(this, arguments);
|
|
6292
6394
|
}
|
|
6293
6395
|
return getOrderInfo;
|