@pisell/pisellos 2.3.114 → 2.3.116
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/Order/index.d.ts +13 -3
- package/dist/modules/Order/index.js +316 -248
- package/dist/modules/Order/types.d.ts +11 -0
- package/dist/modules/Order/utils.d.ts +3 -1
- package/dist/modules/Order/utils.js +171 -63
- package/dist/server/modules/order/index.js +6 -0
- package/dist/server/modules/order/types.d.ts +9 -0
- package/dist/server/utils/small-ticket.js +108 -4
- package/dist/solution/BaseSales/index.d.ts +6 -0
- package/dist/solution/BaseSales/index.js +364 -163
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +4 -0
- package/dist/solution/BookingTicket/index.js +155 -94
- package/lib/modules/Order/index.d.ts +13 -3
- package/lib/modules/Order/index.js +50 -15
- package/lib/modules/Order/types.d.ts +11 -0
- package/lib/modules/Order/utils.d.ts +3 -1
- package/lib/modules/Order/utils.js +101 -0
- package/lib/server/modules/order/index.js +6 -0
- package/lib/server/modules/order/types.d.ts +9 -0
- package/lib/server/utils/small-ticket.js +114 -11
- package/lib/solution/BaseSales/index.d.ts +6 -0
- package/lib/solution/BaseSales/index.js +120 -22
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +4 -0
- package/lib/solution/BookingTicket/index.js +35 -5
- package/package.json +1 -1
|
@@ -32,7 +32,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
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); }
|
|
33
33
|
import { BaseModule } from "../BaseModule";
|
|
34
34
|
import { OrderHooks } from "./types";
|
|
35
|
-
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeOrderMetaList, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, buildPointCardSnapshotFromWalletPassList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
|
|
35
|
+
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeOrderMetaList, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, buildPointCardSnapshotFromWalletPassList, buildVirtualCurrencySnapshotFromList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
|
|
36
36
|
import { isNormalProduct } from "../Product/utils";
|
|
37
37
|
import dayjs from 'dayjs';
|
|
38
38
|
import { stripOsPrivatePayloadFields } from "../../utils/os-private-payload";
|
|
@@ -128,6 +128,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
128
128
|
_defineProperty(_assertThisInitialized(_this), "openCache", false);
|
|
129
129
|
_defineProperty(_assertThisInitialized(_this), "sessionStoragePersistEnabled", false);
|
|
130
130
|
_defineProperty(_assertThisInitialized(_this), "sessionStorageRestoreRecord", null);
|
|
131
|
+
/** 只允许当前订单最新的 prepare/config 请求回写客户资产态。 */
|
|
132
|
+
_defineProperty(_assertThisInitialized(_this), "customerWalletPrepareConfigEpoch", 0);
|
|
131
133
|
_defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
|
|
132
134
|
_defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
|
|
133
135
|
_defineProperty(_assertThisInitialized(_this), "moduleHooksOverride", void 0);
|
|
@@ -557,18 +559,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
557
559
|
return createDefaultOrderRulesHooks();
|
|
558
560
|
}
|
|
559
561
|
|
|
562
|
+
/**
|
|
563
|
+
* Stable across notifyTempOrderChanged's immutable copy, but changes when a
|
|
564
|
+
* different local/server order becomes current.
|
|
565
|
+
*/
|
|
566
|
+
}, {
|
|
567
|
+
key: "getDiscountConfigOrderIdentityKey",
|
|
568
|
+
value: function getDiscountConfigOrderIdentityKey(tempOrder) {
|
|
569
|
+
var _ref12, _identity$orderId, _tempOrder$request_un, _ref13, _identity$externalSal, _ref14, _ref15, _identity$localId, _tempOrder$_extend;
|
|
570
|
+
var identity = this.getOrderIdentity();
|
|
571
|
+
return JSON.stringify([(_ref12 = (_identity$orderId = identity === null || identity === void 0 ? void 0 : identity.orderId) !== null && _identity$orderId !== void 0 ? _identity$orderId : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) !== null && _ref12 !== void 0 ? _ref12 : '', (_tempOrder$request_un = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.request_unique_idempotency_token) !== null && _tempOrder$request_un !== void 0 ? _tempOrder$request_un : '', (_ref13 = (_identity$externalSal = identity === null || identity === void 0 ? void 0 : identity.externalSaleNumber) !== null && _identity$externalSal !== void 0 ? _identity$externalSal : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number) !== null && _ref13 !== void 0 ? _ref13 : '', (_ref14 = (_ref15 = (_identity$localId = identity === null || identity === void 0 ? void 0 : identity.localId) !== null && _identity$localId !== void 0 ? _identity$localId : tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.localId) !== null && _ref15 !== void 0 ? _ref15 : this.cacheId) !== null && _ref14 !== void 0 ? _ref14 : '']);
|
|
572
|
+
}
|
|
573
|
+
|
|
560
574
|
// ─── Discount: 公共 API ───
|
|
561
575
|
}, {
|
|
562
576
|
key: "loadDiscountConfig",
|
|
563
577
|
value: function () {
|
|
564
578
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
565
|
-
var _this$store$tempOrder,
|
|
566
|
-
|
|
579
|
+
var _this$store$tempOrder,
|
|
580
|
+
_this$store$discount,
|
|
581
|
+
_this2 = this,
|
|
582
|
+
_this$store$tempOrder2;
|
|
583
|
+
var orderId, requestEpoch, requestOrderIdentityKey, prepareConfigResult, isCurrentRequest, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentEditDiscounts, currentScanDiscounts, currentScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
|
|
567
584
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
568
585
|
while (1) switch (_context3.prev = _context3.next) {
|
|
569
586
|
case 0:
|
|
570
587
|
orderId = params.orderId || ((_this$store$tempOrder = this.store.tempOrder) === null || _this$store$tempOrder === void 0 ? void 0 : _this$store$tempOrder.order_id) || undefined;
|
|
571
|
-
|
|
588
|
+
requestEpoch = ++this.customerWalletPrepareConfigEpoch;
|
|
589
|
+
requestOrderIdentityKey = this.getDiscountConfigOrderIdentityKey(this.store.tempOrder);
|
|
590
|
+
_context3.next = 5;
|
|
572
591
|
return (_this$store$discount = this.store.discount) === null || _this$store$discount === void 0 ? void 0 : _this$store$discount.loadPrepareConfig(_objectSpread({
|
|
573
592
|
customer_id: params.customerId,
|
|
574
593
|
action: params.action || (orderId ? 'edit' : 'create'),
|
|
@@ -582,19 +601,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
582
601
|
}, orderId ? {
|
|
583
602
|
order_id: orderId
|
|
584
603
|
} : {}));
|
|
585
|
-
case
|
|
604
|
+
case 5:
|
|
586
605
|
prepareConfigResult = _context3.sent;
|
|
606
|
+
isCurrentRequest = function isCurrentRequest() {
|
|
607
|
+
var _this2$store$tempOrde, _this2$store$tempOrde2;
|
|
608
|
+
return requestEpoch === _this2.customerWalletPrepareConfigEpoch && _this2.getDiscountConfigOrderIdentityKey(_this2.store.tempOrder) === requestOrderIdentityKey && String((_this2$store$tempOrde = (_this2$store$tempOrde2 = _this2.store.tempOrder) === null || _this2$store$tempOrde2 === void 0 ? void 0 : _this2$store$tempOrde2.customer_id) !== null && _this2$store$tempOrde !== void 0 ? _this2$store$tempOrde : '') === String(params.customerId);
|
|
609
|
+
};
|
|
610
|
+
if (isCurrentRequest()) {
|
|
611
|
+
_context3.next = 9;
|
|
612
|
+
break;
|
|
613
|
+
}
|
|
614
|
+
return _context3.abrupt("return", this.getDiscountList());
|
|
615
|
+
case 9:
|
|
587
616
|
discountList = prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.discountList;
|
|
588
|
-
this.store.availableWalletIds = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.availableWalletIds) || [];
|
|
589
|
-
this.store.virtualCurrencyList = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.virtualCurrencyList) || [];
|
|
590
617
|
if (prepareConfigResult) {
|
|
591
|
-
this.
|
|
618
|
+
this.writeCustomerWalletSnapshotsFromPrepareConfig({
|
|
592
619
|
customerId: params.customerId,
|
|
593
|
-
|
|
620
|
+
availableWalletIds: prepareConfigResult.availableWalletIds || [],
|
|
621
|
+
availableWalletPassList: prepareConfigResult.availableWalletPassList || [],
|
|
622
|
+
virtualCurrencyList: prepareConfigResult.virtualCurrencyList || []
|
|
594
623
|
});
|
|
595
624
|
}
|
|
596
625
|
if (!discountList) {
|
|
597
|
-
_context3.next =
|
|
626
|
+
_context3.next = 27;
|
|
598
627
|
break;
|
|
599
628
|
}
|
|
600
629
|
currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
|
|
@@ -615,17 +644,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
615
644
|
return true;
|
|
616
645
|
});
|
|
617
646
|
mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(currentScanDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
618
|
-
|
|
647
|
+
if (isCurrentRequest()) {
|
|
648
|
+
_context3.next = 21;
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
651
|
+
return _context3.abrupt("return", this.getDiscountList());
|
|
652
|
+
case 21:
|
|
653
|
+
_context3.next = 23;
|
|
619
654
|
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
|
|
620
|
-
case
|
|
621
|
-
|
|
655
|
+
case 23:
|
|
656
|
+
if (isCurrentRequest()) {
|
|
657
|
+
_context3.next = 25;
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
return _context3.abrupt("return", this.getDiscountList());
|
|
661
|
+
case 25:
|
|
662
|
+
_context3.next = 27;
|
|
622
663
|
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
|
|
623
|
-
case
|
|
664
|
+
case 27:
|
|
665
|
+
if (isCurrentRequest()) {
|
|
666
|
+
_context3.next = 29;
|
|
667
|
+
break;
|
|
668
|
+
}
|
|
669
|
+
return _context3.abrupt("return", this.getDiscountList());
|
|
670
|
+
case 29:
|
|
624
671
|
if (params.apply !== false && (_this$store$tempOrder2 = this.store.tempOrder) !== null && _this$store$tempOrder2 !== void 0 && (_this$store$tempOrder2 = _this$store$tempOrder2.products) !== null && _this$store$tempOrder2 !== void 0 && _this$store$tempOrder2.length) {
|
|
625
672
|
this.applyDiscount();
|
|
626
673
|
}
|
|
627
674
|
return _context3.abrupt("return", this.getDiscountList());
|
|
628
|
-
case
|
|
675
|
+
case 31:
|
|
629
676
|
case "end":
|
|
630
677
|
return _context3.stop();
|
|
631
678
|
}
|
|
@@ -652,6 +699,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
652
699
|
value: function getVirtualCurrencyList() {
|
|
653
700
|
return cloneDeep(this.store.virtualCurrencyList || []);
|
|
654
701
|
}
|
|
702
|
+
}, {
|
|
703
|
+
key: "getCustomerWalletPrepareConfigEpoch",
|
|
704
|
+
value: function getCustomerWalletPrepareConfigEpoch() {
|
|
705
|
+
return this.customerWalletPrepareConfigEpoch;
|
|
706
|
+
}
|
|
655
707
|
}, {
|
|
656
708
|
key: "syncScannedDiscountsToOriginalDiscountList",
|
|
657
709
|
value: function () {
|
|
@@ -694,13 +746,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
694
746
|
key: "ensureEditDiscountConfigForProductChange",
|
|
695
747
|
value: function () {
|
|
696
748
|
var _ensureEditDiscountConfigForProductChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(tempOrder) {
|
|
697
|
-
var _tempOrder$customer, _tempOrder$
|
|
749
|
+
var _tempOrder$customer, _tempOrder$_extend2, _tempOrder$_extend3, _this$store$discount10;
|
|
698
750
|
var orderId, customerId, currentDiscountList, hasRuntimeDiscounts;
|
|
699
751
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
700
752
|
while (1) switch (_context5.prev = _context5.next) {
|
|
701
753
|
case 0:
|
|
702
754
|
orderId = tempOrder.order_id;
|
|
703
|
-
customerId = Number(tempOrder.customer_id || ((_tempOrder$customer = tempOrder.customer) === null || _tempOrder$customer === void 0 ? void 0 : _tempOrder$customer.id) || ((_tempOrder$
|
|
755
|
+
customerId = Number(tempOrder.customer_id || ((_tempOrder$customer = tempOrder.customer) === null || _tempOrder$customer === void 0 ? void 0 : _tempOrder$customer.id) || ((_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2.customerSnapshot) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.id) || ((_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.customerSnapshot) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.customer_id) || 0);
|
|
704
756
|
if (!(!orderId || !customerId || customerId === 1)) {
|
|
705
757
|
_context5.next = 4;
|
|
706
758
|
break;
|
|
@@ -740,7 +792,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
740
792
|
value: function () {
|
|
741
793
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
742
794
|
var _this$store$discount11, _tempOrder$holder, _this$store$summary;
|
|
743
|
-
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders,
|
|
795
|
+
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref16, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, shouldRetainForLater, normalizedNewDiscountList, retainedDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13;
|
|
744
796
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
745
797
|
while (1) switch (_context6.prev = _context6.next) {
|
|
746
798
|
case 0:
|
|
@@ -830,7 +882,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
830
882
|
case 20:
|
|
831
883
|
tempOrder = this.store.tempOrder;
|
|
832
884
|
holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
|
|
833
|
-
|
|
885
|
+
_ref16 = rulesModule.isDiscountListAvailable({
|
|
834
886
|
productList: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
|
|
835
887
|
oldDiscountList: this.getDiscountList(),
|
|
836
888
|
newDiscountList: withScanList,
|
|
@@ -842,7 +894,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
842
894
|
}) || {
|
|
843
895
|
isAvailable: false,
|
|
844
896
|
discountList: this.getDiscountList()
|
|
845
|
-
}, isAvailable =
|
|
897
|
+
}, isAvailable = _ref16.isAvailable, newDiscountList = _ref16.discountList, evaluatedDiscountList = _ref16.evaluatedDiscountList, unavailableReason = _ref16.unavailableReason;
|
|
846
898
|
shouldRetainForLater = !isAvailable && unavailableReason === UnavailableReason.ProductNotApplicable && withScanList.some(isCustomerPromotionDiscount);
|
|
847
899
|
normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
|
|
848
900
|
retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
|
|
@@ -898,7 +950,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
898
950
|
value: function applyDiscount(options) {
|
|
899
951
|
var _this$store$discount16,
|
|
900
952
|
_this$store$summary2,
|
|
901
|
-
|
|
953
|
+
_this3 = this;
|
|
902
954
|
var tempOrder = this.store.tempOrder;
|
|
903
955
|
// 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
|
|
904
956
|
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
@@ -934,9 +986,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
934
986
|
if (result !== null && result !== void 0 && result.productList) {
|
|
935
987
|
var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
|
|
936
988
|
tempOrder.products = this.applyProductDiscountPrices((result.productList || []).map(function (product, index) {
|
|
937
|
-
var
|
|
989
|
+
var _ref17;
|
|
938
990
|
var uid = getOrderProductLineUid(product);
|
|
939
|
-
var previous = (
|
|
991
|
+
var previous = (_ref17 = uid ? previousProductsByUid.get(uid) : undefined) !== null && _ref17 !== void 0 ? _ref17 : previousProductsByUid.get("__index__:".concat(index));
|
|
940
992
|
if (isManualProductDiscountProduct(previous)) {
|
|
941
993
|
return previous;
|
|
942
994
|
}
|
|
@@ -954,7 +1006,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
954
1006
|
(_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || _this$store$discount17.setDiscountList(result.discountList);
|
|
955
1007
|
}
|
|
956
1008
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
957
|
-
return
|
|
1009
|
+
return _this3.productHasCustomerBoundDiscount(product);
|
|
958
1010
|
});
|
|
959
1011
|
}
|
|
960
1012
|
|
|
@@ -1017,7 +1069,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1017
1069
|
var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
1018
1070
|
var _this$promotionEvalua,
|
|
1019
1071
|
_this$promotionEvalua2,
|
|
1020
|
-
|
|
1072
|
+
_this4 = this;
|
|
1021
1073
|
var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
|
|
1022
1074
|
return _regeneratorRuntime().wrap(function _callee7$(_context9) {
|
|
1023
1075
|
while (1) switch (_context9.prev = _context9.next) {
|
|
@@ -1176,7 +1228,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1176
1228
|
case 6:
|
|
1177
1229
|
_context7.prev = 6;
|
|
1178
1230
|
_context7.next = 9;
|
|
1179
|
-
return
|
|
1231
|
+
return _this4.giftSelectResolver({
|
|
1180
1232
|
strategyId: addAction.strategyId,
|
|
1181
1233
|
strategyName: addAction.strategyName,
|
|
1182
1234
|
giftCount: addAction.giftCount,
|
|
@@ -1211,7 +1263,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1211
1263
|
_context7.next = 26;
|
|
1212
1264
|
break;
|
|
1213
1265
|
}
|
|
1214
|
-
linked =
|
|
1266
|
+
linked = _this4.createLinkedProductAndBooking({
|
|
1215
1267
|
product: gp,
|
|
1216
1268
|
booking: booking
|
|
1217
1269
|
});
|
|
@@ -1511,12 +1563,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1511
1563
|
});
|
|
1512
1564
|
}
|
|
1513
1565
|
}, {
|
|
1514
|
-
key: "
|
|
1515
|
-
value: function
|
|
1566
|
+
key: "clearTempOrderCustomerWalletSnapshots",
|
|
1567
|
+
value: function clearTempOrderCustomerWalletSnapshots(tempOrder) {
|
|
1516
1568
|
var orderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
|
|
1517
1569
|
if (!orderMetaList) return;
|
|
1518
1570
|
var nextOrderMetaList = _objectSpread({}, orderMetaList);
|
|
1519
1571
|
delete nextOrderMetaList.point_cards_snapshot;
|
|
1572
|
+
delete nextOrderMetaList.virtual_currency_snapshot;
|
|
1520
1573
|
if (Object.keys(nextOrderMetaList).length === 0) {
|
|
1521
1574
|
delete tempOrder.order_meta_list;
|
|
1522
1575
|
return;
|
|
@@ -1524,15 +1577,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1524
1577
|
tempOrder.order_meta_list = nextOrderMetaList;
|
|
1525
1578
|
}
|
|
1526
1579
|
}, {
|
|
1527
|
-
key: "
|
|
1528
|
-
value: function
|
|
1580
|
+
key: "clearCustomerWalletState",
|
|
1581
|
+
value: function clearCustomerWalletState(tempOrder) {
|
|
1582
|
+
this.clearCustomerWalletRuntimeState();
|
|
1583
|
+
this.clearTempOrderCustomerWalletSnapshots(tempOrder);
|
|
1584
|
+
}
|
|
1585
|
+
}, {
|
|
1586
|
+
key: "clearCustomerWalletRuntimeState",
|
|
1587
|
+
value: function clearCustomerWalletRuntimeState() {
|
|
1588
|
+
this.customerWalletPrepareConfigEpoch += 1;
|
|
1589
|
+
this.store.availableWalletIds = [];
|
|
1590
|
+
this.store.virtualCurrencyList = [];
|
|
1591
|
+
}
|
|
1592
|
+
}, {
|
|
1593
|
+
key: "writeCustomerWalletSnapshotsFromPrepareConfig",
|
|
1594
|
+
value: function writeCustomerWalletSnapshotsFromPrepareConfig(params) {
|
|
1529
1595
|
var _tempOrder$customer_i;
|
|
1530
1596
|
var tempOrder = this.store.tempOrder;
|
|
1531
1597
|
if (!tempOrder) return;
|
|
1532
1598
|
if (String((_tempOrder$customer_i = tempOrder.customer_id) !== null && _tempOrder$customer_i !== void 0 ? _tempOrder$customer_i : '') !== String(params.customerId)) return;
|
|
1599
|
+
var virtualCurrencyList = Array.isArray(params.virtualCurrencyList) ? params.virtualCurrencyList : [];
|
|
1533
1600
|
tempOrder.order_meta_list = _objectSpread(_objectSpread({}, normalizeOrderMetaList(tempOrder.order_meta_list) || {}), {}, {
|
|
1534
|
-
point_cards_snapshot: buildPointCardSnapshotFromWalletPassList(params.availableWalletPassList)
|
|
1601
|
+
point_cards_snapshot: buildPointCardSnapshotFromWalletPassList(params.availableWalletPassList),
|
|
1602
|
+
virtual_currency_snapshot: buildVirtualCurrencySnapshotFromList(virtualCurrencyList)
|
|
1535
1603
|
});
|
|
1604
|
+
this.store.availableWalletIds = _toConsumableArray(params.availableWalletIds);
|
|
1605
|
+
this.store.virtualCurrencyList = cloneDeep(virtualCurrencyList);
|
|
1536
1606
|
this.persistTempOrder();
|
|
1537
1607
|
this.saveDraftInBackground();
|
|
1538
1608
|
}
|
|
@@ -1636,15 +1706,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1636
1706
|
}, {
|
|
1637
1707
|
key: "extractOrderIdFromSubmitResult",
|
|
1638
1708
|
value: function extractOrderIdFromSubmitResult(result) {
|
|
1639
|
-
var
|
|
1640
|
-
return (
|
|
1709
|
+
var _ref18, _ref19, _ref20, _result$data$order_id, _result$data, _result$data2;
|
|
1710
|
+
return (_ref18 = (_ref19 = (_ref20 = (_result$data$order_id = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.order_id) !== null && _result$data$order_id !== void 0 ? _result$data$order_id : result === null || result === void 0 ? void 0 : result.order_id) !== null && _ref20 !== void 0 ? _ref20 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref19 !== void 0 ? _ref19 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref18 !== void 0 ? _ref18 : null;
|
|
1641
1711
|
}
|
|
1642
1712
|
}, {
|
|
1643
1713
|
key: "calculatePaymentEffectiveAmount",
|
|
1644
1714
|
value: function calculatePaymentEffectiveAmount(payment) {
|
|
1645
|
-
var
|
|
1715
|
+
var _ref21, _payment$origin_amoun;
|
|
1646
1716
|
var amount = new Decimal(payment.amount || 0);
|
|
1647
|
-
var originAmount = new Decimal((
|
|
1717
|
+
var originAmount = new Decimal((_ref21 = (_payment$origin_amoun = payment.origin_amount) !== null && _payment$origin_amoun !== void 0 ? _payment$origin_amoun : payment.amount) !== null && _ref21 !== void 0 ? _ref21 : 0);
|
|
1648
1718
|
var serviceFee = new Decimal(payment.service_fee || 0);
|
|
1649
1719
|
// TODO: 后端允许 amount 表示顾客实际支付总额后,移除这个兼容分支。
|
|
1650
1720
|
var effectiveAmount = serviceFee.gt(0) && amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
|
|
@@ -1654,23 +1724,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1654
1724
|
}, {
|
|
1655
1725
|
key: "calculatePaymentTotal",
|
|
1656
1726
|
value: function calculatePaymentTotal(payments) {
|
|
1657
|
-
var
|
|
1727
|
+
var _this5 = this;
|
|
1658
1728
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1659
1729
|
includeVoided: false
|
|
1660
1730
|
}).reduce(function (sum, payment) {
|
|
1661
1731
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1662
|
-
return sum.plus(
|
|
1732
|
+
return sum.plus(_this5.calculatePaymentEffectiveAmount(payment));
|
|
1663
1733
|
}, new Decimal(0));
|
|
1664
1734
|
}
|
|
1665
1735
|
}, {
|
|
1666
1736
|
key: "calculateOrderPaidPaymentTotal",
|
|
1667
1737
|
value: function calculateOrderPaidPaymentTotal(payments) {
|
|
1668
|
-
var
|
|
1738
|
+
var _this6 = this;
|
|
1669
1739
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1670
1740
|
includeVoided: false
|
|
1671
1741
|
}).reduce(function (sum, payment) {
|
|
1672
1742
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1673
|
-
return sum.plus(
|
|
1743
|
+
return sum.plus(_this6.calculatePaymentGapAmount(payment));
|
|
1674
1744
|
}, new Decimal(0));
|
|
1675
1745
|
}
|
|
1676
1746
|
}, {
|
|
@@ -1806,13 +1876,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1806
1876
|
}, {
|
|
1807
1877
|
key: "calculateDepositPaidAmount",
|
|
1808
1878
|
value: function calculateDepositPaidAmount(payments) {
|
|
1809
|
-
var
|
|
1879
|
+
var _this7 = this;
|
|
1810
1880
|
return (payments || []).reduce(function (sum, payment) {
|
|
1811
1881
|
var paymentRecord = payment;
|
|
1812
1882
|
if (!isPaidPaymentRecord(paymentRecord)) return sum;
|
|
1813
1883
|
var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
|
|
1814
1884
|
if (!isDepositPayment) return sum;
|
|
1815
|
-
return sum.plus(
|
|
1885
|
+
return sum.plus(_this7.calculatePaymentGapAmount(paymentRecord));
|
|
1816
1886
|
}, new Decimal(0));
|
|
1817
1887
|
}
|
|
1818
1888
|
}, {
|
|
@@ -1849,28 +1919,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1849
1919
|
}, {
|
|
1850
1920
|
key: "getPaymentNumberDevicePrefixSync",
|
|
1851
1921
|
value: function getPaymentNumberDevicePrefixSync() {
|
|
1852
|
-
var
|
|
1922
|
+
var _this8 = this;
|
|
1853
1923
|
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
1854
|
-
return
|
|
1924
|
+
return _this8.getPaymentNumberAppData(key);
|
|
1855
1925
|
});
|
|
1856
1926
|
}
|
|
1857
1927
|
}, {
|
|
1858
1928
|
key: "getPaymentNumberDevicePrefixAsync",
|
|
1859
1929
|
value: function getPaymentNumberDevicePrefixAsync() {
|
|
1860
|
-
var
|
|
1930
|
+
var _this9 = this;
|
|
1861
1931
|
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
1862
|
-
return
|
|
1932
|
+
return _this9.getPaymentNumberAppData(key);
|
|
1863
1933
|
});
|
|
1864
1934
|
}
|
|
1865
1935
|
}, {
|
|
1866
1936
|
key: "normalizePaymentSource",
|
|
1867
1937
|
value: function normalizePaymentSource(payment, options) {
|
|
1868
|
-
var
|
|
1938
|
+
var _ref22, _paymentRecord$origin;
|
|
1869
1939
|
var paymentRecord = payment;
|
|
1870
1940
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
1871
1941
|
var normalized = ensureOrderPaymentNumber(_objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
1872
1942
|
metadata: metadata,
|
|
1873
|
-
origin_amount: (
|
|
1943
|
+
origin_amount: (_ref22 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref22 !== void 0 ? _ref22 : '0.00'
|
|
1874
1944
|
}), (options === null || options === void 0 ? void 0 : options.devicePrefix) || this.getPaymentNumberDevicePrefixSync(), createUuidV4);
|
|
1875
1945
|
if (paymentRecord.status !== undefined) {
|
|
1876
1946
|
normalized.status = paymentRecord.status;
|
|
@@ -1989,16 +2059,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1989
2059
|
}, {
|
|
1990
2060
|
key: "calculatePaidPaymentSummary",
|
|
1991
2061
|
value: function calculatePaidPaymentSummary(payments) {
|
|
1992
|
-
var
|
|
2062
|
+
var _this10 = this;
|
|
1993
2063
|
return (payments || []).reduce(function (summary, payment) {
|
|
1994
2064
|
var paymentRecord = payment;
|
|
1995
2065
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
1996
2066
|
return {
|
|
1997
2067
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
1998
|
-
orderPaidAmount: summary.orderPaidAmount.plus(
|
|
1999
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
2000
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
2001
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
2068
|
+
orderPaidAmount: summary.orderPaidAmount.plus(_this10.calculatePaymentOrderAmount(paymentRecord)),
|
|
2069
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this10.calculatePaymentGapAmount(paymentRecord)),
|
|
2070
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this10.calculatePaymentServiceFee(paymentRecord)),
|
|
2071
|
+
roundingAmount: summary.roundingAmount.plus(_this10.calculatePaymentRoundingAmount(paymentRecord))
|
|
2002
2072
|
};
|
|
2003
2073
|
}, {
|
|
2004
2074
|
customerPaidAmount: new Decimal(0),
|
|
@@ -2205,15 +2275,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2205
2275
|
}, {
|
|
2206
2276
|
key: "normalizeFingerprintValue",
|
|
2207
2277
|
value: function normalizeFingerprintValue(value) {
|
|
2208
|
-
var
|
|
2278
|
+
var _this11 = this;
|
|
2209
2279
|
if (Array.isArray(value)) {
|
|
2210
2280
|
return value.map(function (item) {
|
|
2211
|
-
return
|
|
2281
|
+
return _this11.normalizeFingerprintValue(item);
|
|
2212
2282
|
});
|
|
2213
2283
|
}
|
|
2214
2284
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
2215
2285
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
2216
|
-
result[key] =
|
|
2286
|
+
result[key] = _this11.normalizeFingerprintValue(value[key]);
|
|
2217
2287
|
return result;
|
|
2218
2288
|
}, {});
|
|
2219
2289
|
}
|
|
@@ -2226,9 +2296,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2226
2296
|
_product$payment_pric,
|
|
2227
2297
|
_sku$code,
|
|
2228
2298
|
_sku$barcode,
|
|
2229
|
-
|
|
2299
|
+
_ref23,
|
|
2230
2300
|
_sku$variant_id,
|
|
2231
|
-
|
|
2301
|
+
_this12 = this;
|
|
2232
2302
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2233
2303
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2234
2304
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2253,37 +2323,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2253
2323
|
product_sku: this.normalizeFingerprintValue({
|
|
2254
2324
|
code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
|
|
2255
2325
|
barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
|
|
2256
|
-
variant_id: (
|
|
2326
|
+
variant_id: (_ref23 = (_sku$variant_id = sku.variant_id) !== null && _sku$variant_id !== void 0 ? _sku$variant_id : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref23 !== void 0 ? _ref23 : 0,
|
|
2257
2327
|
variant: sku.variant || [],
|
|
2258
2328
|
option: getProductSkuOptions(product || {}).map(function (option) {
|
|
2259
|
-
var
|
|
2329
|
+
var _ref24, _option$id, _option$option_group_, _ref25, _option$option_group_2, _option$num, _option$add_price;
|
|
2260
2330
|
return {
|
|
2261
|
-
id: (
|
|
2331
|
+
id: (_ref24 = (_option$id = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id !== void 0 ? _option$id : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref24 !== void 0 ? _ref24 : null,
|
|
2262
2332
|
option_group_id: (_option$option_group_ = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : null,
|
|
2263
|
-
option_group_item_id: (
|
|
2333
|
+
option_group_item_id: (_ref25 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref25 !== void 0 ? _ref25 : null,
|
|
2264
2334
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
2265
|
-
add_price:
|
|
2335
|
+
add_price: _this12.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
|
|
2266
2336
|
};
|
|
2267
2337
|
})
|
|
2268
2338
|
}),
|
|
2269
2339
|
product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
|
|
2270
|
-
var
|
|
2340
|
+
var _ref26, _ref27, _bundle$bundle_produc, _ref28, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
|
|
2271
2341
|
return {
|
|
2272
|
-
bundle_product_id: (
|
|
2273
|
-
bundle_variant_id: (
|
|
2342
|
+
bundle_product_id: (_ref26 = (_ref27 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref27 !== void 0 ? _ref27 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref26 !== void 0 ? _ref26 : null,
|
|
2343
|
+
bundle_variant_id: (_ref28 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref28 !== void 0 ? _ref28 : 0,
|
|
2274
2344
|
num: getSafeProductNum((_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
|
|
2275
|
-
price:
|
|
2276
|
-
bundle_selling_price:
|
|
2345
|
+
price: _this12.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
2346
|
+
bundle_selling_price: _this12.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
2277
2347
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
2278
2348
|
price_type_ext: (_bundle$price_type_ex = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : ''
|
|
2279
2349
|
};
|
|
2280
2350
|
})),
|
|
2281
2351
|
discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
2282
|
-
var
|
|
2352
|
+
var _ref29, _discount$type2, _ref30, _ref31, _discount$discount_id, _discount$discount;
|
|
2283
2353
|
return {
|
|
2284
|
-
type: (
|
|
2285
|
-
discount_id: (
|
|
2286
|
-
amount:
|
|
2354
|
+
type: (_ref29 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref29 !== void 0 ? _ref29 : '',
|
|
2355
|
+
discount_id: (_ref30 = (_ref31 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref31 !== void 0 ? _ref31 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref30 !== void 0 ? _ref30 : null,
|
|
2356
|
+
amount: _this12.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2287
2357
|
};
|
|
2288
2358
|
}))
|
|
2289
2359
|
};
|
|
@@ -2291,9 +2361,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2291
2361
|
}, {
|
|
2292
2362
|
key: "buildOrderProductsFingerprint",
|
|
2293
2363
|
value: function buildOrderProductsFingerprint(products) {
|
|
2294
|
-
var
|
|
2364
|
+
var _this13 = this;
|
|
2295
2365
|
var items = (products || []).map(function (product) {
|
|
2296
|
-
return
|
|
2366
|
+
return _this13.buildProductFingerprintItem(product);
|
|
2297
2367
|
});
|
|
2298
2368
|
items.sort(function (left, right) {
|
|
2299
2369
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2306,16 +2376,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2306
2376
|
var _product$product_id3,
|
|
2307
2377
|
_product$product_vari2,
|
|
2308
2378
|
_product$num2,
|
|
2309
|
-
|
|
2379
|
+
_ref32,
|
|
2310
2380
|
_metadata$unique_iden,
|
|
2311
2381
|
_metadata$price_overr,
|
|
2312
2382
|
_metadata$is_manual_d,
|
|
2313
2383
|
_metadata$product_dis,
|
|
2314
2384
|
_sku$code2,
|
|
2315
2385
|
_sku$barcode2,
|
|
2316
|
-
|
|
2386
|
+
_ref33,
|
|
2317
2387
|
_sku$variant_id2,
|
|
2318
|
-
|
|
2388
|
+
_this14 = this;
|
|
2319
2389
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2320
2390
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2321
2391
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2329,7 +2399,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2329
2399
|
extension_type: extensionType,
|
|
2330
2400
|
num: getSafeProductNum((_product$num2 = product === null || product === void 0 ? void 0 : product.num) !== null && _product$num2 !== void 0 ? _product$num2 : product === null || product === void 0 ? void 0 : product.product_quantity),
|
|
2331
2401
|
metadata: {
|
|
2332
|
-
unique_identification_number: (
|
|
2402
|
+
unique_identification_number: (_ref32 = (_metadata$unique_iden = metadata.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref32 !== void 0 ? _ref32 : '',
|
|
2333
2403
|
price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
|
|
2334
2404
|
is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
|
|
2335
2405
|
product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
|
|
@@ -2337,47 +2407,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2337
2407
|
product_sku: this.normalizeFingerprintValue({
|
|
2338
2408
|
code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
|
|
2339
2409
|
barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
|
|
2340
|
-
variant_id: (
|
|
2410
|
+
variant_id: (_ref33 = (_sku$variant_id2 = sku.variant_id) !== null && _sku$variant_id2 !== void 0 ? _sku$variant_id2 : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref33 !== void 0 ? _ref33 : 0,
|
|
2341
2411
|
variant: sku.variant || [],
|
|
2342
2412
|
option: getProductSkuOptions(product || {}).map(function (option) {
|
|
2343
|
-
var
|
|
2413
|
+
var _ref34, _option$id2, _option$option_group_3, _ref35, _option$option_group_4, _option$num2, _option$add_price2;
|
|
2344
2414
|
return {
|
|
2345
|
-
id: (
|
|
2415
|
+
id: (_ref34 = (_option$id2 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id2 !== void 0 ? _option$id2 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref34 !== void 0 ? _ref34 : null,
|
|
2346
2416
|
option_group_id: (_option$option_group_3 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_3 !== void 0 ? _option$option_group_3 : null,
|
|
2347
|
-
option_group_item_id: (
|
|
2417
|
+
option_group_item_id: (_ref35 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref35 !== void 0 ? _ref35 : null,
|
|
2348
2418
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
2349
|
-
add_price:
|
|
2419
|
+
add_price: _this14.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
|
|
2350
2420
|
};
|
|
2351
2421
|
})
|
|
2352
2422
|
}),
|
|
2353
2423
|
product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
|
|
2354
|
-
var
|
|
2424
|
+
var _ref36, _bundle$bundle_id, _ref37, _bundle$bundle_group_, _ref38, _ref39, _bundle$bundle_produc2, _ref40, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
|
|
2355
2425
|
return {
|
|
2356
|
-
bundle_id: (
|
|
2357
|
-
bundle_group_id: (
|
|
2358
|
-
bundle_product_id: (
|
|
2359
|
-
bundle_variant_id: (
|
|
2426
|
+
bundle_id: (_ref36 = (_bundle$bundle_id = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle === null || bundle === void 0 ? void 0 : bundle.id) !== null && _ref36 !== void 0 ? _ref36 : null,
|
|
2427
|
+
bundle_group_id: (_ref37 = (_bundle$bundle_group_ = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle === null || bundle === void 0 ? void 0 : bundle.group_id) !== null && _ref37 !== void 0 ? _ref37 : null,
|
|
2428
|
+
bundle_product_id: (_ref38 = (_ref39 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref39 !== void 0 ? _ref39 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref38 !== void 0 ? _ref38 : null,
|
|
2429
|
+
bundle_variant_id: (_ref40 = (_bundle$bundle_varian2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian2 !== void 0 ? _bundle$bundle_varian2 : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref40 !== void 0 ? _ref40 : 0,
|
|
2360
2430
|
num: getSafeProductNum((_bundle$num2 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num2 !== void 0 ? _bundle$num2 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
|
|
2361
2431
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
2362
2432
|
price_type_ext: (_bundle$price_type_ex2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : '',
|
|
2363
|
-
option:
|
|
2364
|
-
var
|
|
2433
|
+
option: _this14.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2434
|
+
var _ref41, _option$id3, _option$option_group_5, _ref42, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2365
2435
|
return {
|
|
2366
|
-
id: (
|
|
2436
|
+
id: (_ref41 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref41 !== void 0 ? _ref41 : null,
|
|
2367
2437
|
option_group_id: (_option$option_group_5 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_5 !== void 0 ? _option$option_group_5 : null,
|
|
2368
|
-
option_group_item_id: (
|
|
2438
|
+
option_group_item_id: (_ref42 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref42 !== void 0 ? _ref42 : null,
|
|
2369
2439
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
2370
|
-
add_price:
|
|
2440
|
+
add_price: _this14.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
|
|
2371
2441
|
};
|
|
2372
2442
|
}))
|
|
2373
2443
|
};
|
|
2374
2444
|
})),
|
|
2375
2445
|
discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
2376
|
-
var
|
|
2446
|
+
var _ref43, _discount$type4, _ref44, _ref45, _discount$discount_id2, _discount$discount2;
|
|
2377
2447
|
return {
|
|
2378
|
-
type: (
|
|
2379
|
-
discount_id: (
|
|
2380
|
-
amount:
|
|
2448
|
+
type: (_ref43 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref43 !== void 0 ? _ref43 : '',
|
|
2449
|
+
discount_id: (_ref44 = (_ref45 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref45 !== void 0 ? _ref45 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref44 !== void 0 ? _ref44 : null,
|
|
2450
|
+
amount: _this14.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2381
2451
|
};
|
|
2382
2452
|
}))
|
|
2383
2453
|
};
|
|
@@ -2385,9 +2455,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2385
2455
|
}, {
|
|
2386
2456
|
key: "buildOrderProductsStructuralFingerprint",
|
|
2387
2457
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
2388
|
-
var
|
|
2458
|
+
var _this15 = this;
|
|
2389
2459
|
var items = (products || []).map(function (product) {
|
|
2390
|
-
return
|
|
2460
|
+
return _this15.buildProductStructuralFingerprintItem(product);
|
|
2391
2461
|
});
|
|
2392
2462
|
items.sort(function (left, right) {
|
|
2393
2463
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2397,8 +2467,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2397
2467
|
}, {
|
|
2398
2468
|
key: "getManualDepositOverride",
|
|
2399
2469
|
value: function getManualDepositOverride(tempOrder) {
|
|
2400
|
-
var _tempOrder$
|
|
2401
|
-
var override = (_tempOrder$
|
|
2470
|
+
var _tempOrder$_extend4;
|
|
2471
|
+
var override = (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.manualDepositOverride;
|
|
2402
2472
|
if (!override || _typeof(override) !== 'object') return null;
|
|
2403
2473
|
if (typeof override.amount !== 'string') return null;
|
|
2404
2474
|
if (typeof override.productStructuralFingerprint !== 'string') return null;
|
|
@@ -2417,16 +2487,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2417
2487
|
}, {
|
|
2418
2488
|
key: "clearManualDepositOverride",
|
|
2419
2489
|
value: function clearManualDepositOverride(tempOrder) {
|
|
2420
|
-
var _tempOrder$
|
|
2421
|
-
if (!((_tempOrder$
|
|
2490
|
+
var _tempOrder$_extend5;
|
|
2491
|
+
if (!((_tempOrder$_extend5 = tempOrder._extend) !== null && _tempOrder$_extend5 !== void 0 && _tempOrder$_extend5.manualDepositOverride)) return;
|
|
2422
2492
|
tempOrder._extend = _objectSpread({}, tempOrder._extend);
|
|
2423
2493
|
delete tempOrder._extend.manualDepositOverride;
|
|
2424
2494
|
}
|
|
2425
2495
|
}, {
|
|
2426
2496
|
key: "getOriginalSalesSnapshot",
|
|
2427
2497
|
value: function getOriginalSalesSnapshot(tempOrder) {
|
|
2428
|
-
var _tempOrder$
|
|
2429
|
-
var snapshot = (_tempOrder$
|
|
2498
|
+
var _tempOrder$_extend6;
|
|
2499
|
+
var snapshot = (_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.originalSalesSnapshot;
|
|
2430
2500
|
if (!snapshot || _typeof(snapshot) !== 'object') return null;
|
|
2431
2501
|
if (typeof snapshot.productFingerprint !== 'string') return null;
|
|
2432
2502
|
return snapshot;
|
|
@@ -2630,6 +2700,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2630
2700
|
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
2631
2701
|
this.ensureExternalSaleNumber(freshTempOrder);
|
|
2632
2702
|
this.store.tempOrder = freshTempOrder;
|
|
2703
|
+
this.clearCustomerWalletRuntimeState();
|
|
2633
2704
|
this.store.summary = createEmptySummary();
|
|
2634
2705
|
this.store.lastOrderInfo = undefined;
|
|
2635
2706
|
this.store.syncState = undefined;
|
|
@@ -2662,32 +2733,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2662
2733
|
ensureIdentity: false
|
|
2663
2734
|
});
|
|
2664
2735
|
this.store.tempOrder = nextTempOrder;
|
|
2736
|
+
this.clearCustomerWalletRuntimeState();
|
|
2665
2737
|
if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
|
|
2666
|
-
_context13.next =
|
|
2738
|
+
_context13.next = 11;
|
|
2667
2739
|
break;
|
|
2668
2740
|
}
|
|
2669
|
-
_context13.next =
|
|
2741
|
+
_context13.next = 9;
|
|
2670
2742
|
return this.recalculateSummary({
|
|
2671
2743
|
createIfMissing: false
|
|
2672
2744
|
});
|
|
2673
|
-
case
|
|
2674
|
-
_context13.next =
|
|
2745
|
+
case 9:
|
|
2746
|
+
_context13.next = 12;
|
|
2675
2747
|
break;
|
|
2676
|
-
case 10:
|
|
2677
|
-
this.store.summary = createEmptySummary();
|
|
2678
2748
|
case 11:
|
|
2749
|
+
this.store.summary = createEmptySummary();
|
|
2750
|
+
case 12:
|
|
2679
2751
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
2680
2752
|
this.persistTempOrder();
|
|
2681
2753
|
}
|
|
2682
2754
|
if (!(options !== null && options !== void 0 && options.saveDraft)) {
|
|
2683
|
-
_context13.next =
|
|
2755
|
+
_context13.next = 16;
|
|
2684
2756
|
break;
|
|
2685
2757
|
}
|
|
2686
|
-
_context13.next =
|
|
2758
|
+
_context13.next = 16;
|
|
2687
2759
|
return this.saveDraft();
|
|
2688
|
-
case 15:
|
|
2689
|
-
return _context13.abrupt("return", nextTempOrder);
|
|
2690
2760
|
case 16:
|
|
2761
|
+
return _context13.abrupt("return", nextTempOrder);
|
|
2762
|
+
case 17:
|
|
2691
2763
|
case "end":
|
|
2692
2764
|
return _context13.stop();
|
|
2693
2765
|
}
|
|
@@ -2701,13 +2773,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2701
2773
|
}, {
|
|
2702
2774
|
key: "getOrderIdentity",
|
|
2703
2775
|
value: function getOrderIdentity() {
|
|
2704
|
-
var
|
|
2776
|
+
var _ref46, _ref47, _tempOrder$order_id, _tempOrder$_extend7;
|
|
2705
2777
|
var tempOrder = this.store.tempOrder;
|
|
2706
2778
|
if (!tempOrder) return null;
|
|
2707
2779
|
var lastOrderInfo = this.store.lastOrderInfo || {};
|
|
2708
|
-
var orderId = (
|
|
2780
|
+
var orderId = (_ref46 = (_ref47 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref47 !== void 0 ? _ref47 : lastOrderInfo.id) !== null && _ref46 !== void 0 ? _ref46 : null;
|
|
2709
2781
|
return {
|
|
2710
|
-
localId: this.cacheId || ((_tempOrder$
|
|
2782
|
+
localId: this.cacheId || ((_tempOrder$_extend7 = tempOrder._extend) === null || _tempOrder$_extend7 === void 0 ? void 0 : _tempOrder$_extend7.localId),
|
|
2711
2783
|
orderId: orderId,
|
|
2712
2784
|
externalSaleNumber: tempOrder.external_sale_number || lastOrderInfo.external_sale_number || '',
|
|
2713
2785
|
orderNumber: tempOrder.order_number || lastOrderInfo.order_number || '',
|
|
@@ -2837,9 +2909,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2837
2909
|
}, {
|
|
2838
2910
|
key: "sanitizeTempOrderProducts",
|
|
2839
2911
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
2840
|
-
var
|
|
2912
|
+
var _this16 = this;
|
|
2841
2913
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2842
|
-
return
|
|
2914
|
+
return _this16.sanitizeOrderProductForTempOrder(_this16.normalizeVirtualSettlementProductIfEnabled(product));
|
|
2843
2915
|
});
|
|
2844
2916
|
this.syncTempOrderSettlementState(tempOrder);
|
|
2845
2917
|
ensureUniqueProductLineUids(tempOrder);
|
|
@@ -2860,8 +2932,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2860
2932
|
}, {
|
|
2861
2933
|
key: "repairDuplicateProductLineIdentities",
|
|
2862
2934
|
value: function repairDuplicateProductLineIdentities(tempOrder) {
|
|
2863
|
-
var _tempOrder$
|
|
2864
|
-
var result = repairDuplicateOrderProductLineIdentities(tempOrder.products, (_tempOrder$
|
|
2935
|
+
var _tempOrder$_extend8;
|
|
2936
|
+
var result = repairDuplicateOrderProductLineIdentities(tempOrder.products, (_tempOrder$_extend8 = tempOrder._extend) === null || _tempOrder$_extend8 === void 0 ? void 0 : _tempOrder$_extend8.productsByUid);
|
|
2865
2937
|
if (!result.repairs.length) return;
|
|
2866
2938
|
tempOrder.products = result.products;
|
|
2867
2939
|
if (result.productsByUid) {
|
|
@@ -2875,11 +2947,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2875
2947
|
}, {
|
|
2876
2948
|
key: "captureProductRuntime",
|
|
2877
2949
|
value: function captureProductRuntime(tempOrder, rawProduct, normalizedProduct, existedUid) {
|
|
2878
|
-
var _extend$productsByUid,
|
|
2950
|
+
var _extend$productsByUid, _ref48, _rawProduct$_origin;
|
|
2879
2951
|
var uid = existedUid || this.getProductUid(normalizedProduct);
|
|
2880
2952
|
var extend = this.ensureExtend(tempOrder);
|
|
2881
2953
|
var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
|
|
2882
|
-
var origin = (
|
|
2954
|
+
var origin = (_ref48 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref48 !== void 0 ? _ref48 : existed.origin;
|
|
2883
2955
|
extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
|
|
2884
2956
|
origin: origin
|
|
2885
2957
|
} : {});
|
|
@@ -2959,7 +3031,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2959
3031
|
}, {
|
|
2960
3032
|
key: "syncLinkedBookingHoldersToProducts",
|
|
2961
3033
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
2962
|
-
var
|
|
3034
|
+
var _this17 = this;
|
|
2963
3035
|
var bookings = tempOrder.bookings || [];
|
|
2964
3036
|
var products = tempOrder.products || [];
|
|
2965
3037
|
if (!bookings.length || !products.length) return;
|
|
@@ -2984,7 +3056,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2984
3056
|
var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
|
|
2985
3057
|
var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
|
|
2986
3058
|
if (linkedBooking) {
|
|
2987
|
-
|
|
3059
|
+
_this17.setProductHolderFromBooking(product, linkedBooking);
|
|
2988
3060
|
}
|
|
2989
3061
|
});
|
|
2990
3062
|
}
|
|
@@ -3022,7 +3094,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3022
3094
|
}, {
|
|
3023
3095
|
key: "buildTempOrderHolderFromBookings",
|
|
3024
3096
|
value: function buildTempOrderHolderFromBookings(tempOrder) {
|
|
3025
|
-
var _baseHolder$customer_, _baseHolder,
|
|
3097
|
+
var _baseHolder$customer_, _baseHolder, _ref49, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams2;
|
|
3026
3098
|
var holderRecords = [];
|
|
3027
3099
|
var holderNames = [];
|
|
3028
3100
|
var baseHolder = null;
|
|
@@ -3069,7 +3141,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3069
3141
|
}
|
|
3070
3142
|
var nextHolder = {
|
|
3071
3143
|
customer_id: (_baseHolder$customer_ = (_baseHolder = baseHolder) === null || _baseHolder === void 0 ? void 0 : _baseHolder.customer_id) !== null && _baseHolder$customer_ !== void 0 ? _baseHolder$customer_ : tempOrder.customer_id,
|
|
3072
|
-
form_id: (
|
|
3144
|
+
form_id: (_ref49 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_id) !== null && _ref49 !== void 0 ? _ref49 : 0,
|
|
3073
3145
|
form_record: holderRecords
|
|
3074
3146
|
};
|
|
3075
3147
|
if (holderNames.length) {
|
|
@@ -3112,9 +3184,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3112
3184
|
}, {
|
|
3113
3185
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
3114
3186
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
3115
|
-
var
|
|
3187
|
+
var _this18 = this;
|
|
3116
3188
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
3117
|
-
return
|
|
3189
|
+
return _this18.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
3118
3190
|
});
|
|
3119
3191
|
}
|
|
3120
3192
|
}, {
|
|
@@ -3122,12 +3194,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3122
3194
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
3123
3195
|
var _product$metadata5,
|
|
3124
3196
|
_product$metadata6,
|
|
3125
|
-
|
|
3197
|
+
_this19 = this;
|
|
3126
3198
|
var productUid = (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
3127
3199
|
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
|
|
3128
3200
|
if (!productUid && !bookingUid) return;
|
|
3129
3201
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
3130
|
-
var currentBookingUid =
|
|
3202
|
+
var currentBookingUid = _this19.getBookingUniqueIdentificationNumber(booking);
|
|
3131
3203
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
3132
3204
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
3133
3205
|
return true;
|
|
@@ -3144,9 +3216,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3144
3216
|
}, {
|
|
3145
3217
|
key: "applyOrderProductsDepositSummary",
|
|
3146
3218
|
value: function applyOrderProductsDepositSummary(tempOrder, summary) {
|
|
3147
|
-
var _tempOrder$
|
|
3219
|
+
var _tempOrder$_extend9;
|
|
3148
3220
|
var depositSummary = calculateOrderProductsDeposit(tempOrder.products || [], {
|
|
3149
|
-
productsByUid: (_tempOrder$
|
|
3221
|
+
productsByUid: (_tempOrder$_extend9 = tempOrder._extend) === null || _tempOrder$_extend9 === void 0 ? void 0 : _tempOrder$_extend9.productsByUid
|
|
3150
3222
|
});
|
|
3151
3223
|
var manualDepositOverride = this.getManualDepositOverride(tempOrder);
|
|
3152
3224
|
var currentStructuralFingerprint = manualDepositOverride ? this.buildOrderProductsStructuralFingerprint(tempOrder.products) : '';
|
|
@@ -3174,7 +3246,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3174
3246
|
key: "recalculateSummary",
|
|
3175
3247
|
value: function () {
|
|
3176
3248
|
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(options) {
|
|
3177
|
-
var _this$otherParams3,
|
|
3249
|
+
var _this$otherParams3, _ref50, _salesSummaryResult$e;
|
|
3178
3250
|
var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
3179
3251
|
return _regeneratorRuntime().wrap(function _callee13$(_context15) {
|
|
3180
3252
|
while (1) switch (_context15.prev = _context15.next) {
|
|
@@ -3253,7 +3325,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3253
3325
|
roundingAmount = paidPaymentSummary.roundingAmount;
|
|
3254
3326
|
payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
|
|
3255
3327
|
hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
|
|
3256
|
-
expectAmount = hasSalesSummaryAmount ? new Decimal((
|
|
3328
|
+
expectAmount = hasSalesSummaryAmount ? new Decimal((_ref50 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref50 !== void 0 ? _ref50 : 0) : null;
|
|
3257
3329
|
amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
|
|
3258
3330
|
rounding_amount: roundingAmount.toFixed(2)
|
|
3259
3331
|
}, expectAmount ? {
|
|
@@ -3429,7 +3501,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3429
3501
|
}, {
|
|
3430
3502
|
key: "removeSalesNotesForMissingProductLines",
|
|
3431
3503
|
value: function removeSalesNotesForMissingProductLines(tempOrder) {
|
|
3432
|
-
var
|
|
3504
|
+
var _this20 = this;
|
|
3433
3505
|
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3434
3506
|
if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
|
|
3435
3507
|
return;
|
|
@@ -3441,7 +3513,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3441
3513
|
return typeof uid === 'string' && uid.length > 0;
|
|
3442
3514
|
}));
|
|
3443
3515
|
var nextNotes = tempOrder.notes.filter(function (note) {
|
|
3444
|
-
var primary =
|
|
3516
|
+
var primary = _this20.getSalesNotePrimaryRelation(note);
|
|
3445
3517
|
if (!primary || primary.target_type !== 'order_detail') return true;
|
|
3446
3518
|
return remainingProductUids.has(primary.target_uuid);
|
|
3447
3519
|
});
|
|
@@ -3453,7 +3525,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3453
3525
|
key: "setSalesNoteOnTempOrder",
|
|
3454
3526
|
value: function setSalesNoteOnTempOrder(tempOrder, input) {
|
|
3455
3527
|
var _input$target,
|
|
3456
|
-
|
|
3528
|
+
_this21 = this,
|
|
3457
3529
|
_tempOrder$shop_order;
|
|
3458
3530
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
3459
3531
|
var note_type = String(input.note_type || '').trim();
|
|
@@ -3477,7 +3549,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3477
3549
|
var notes = tempOrder.notes || [];
|
|
3478
3550
|
// 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
|
|
3479
3551
|
var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
|
|
3480
|
-
var primary =
|
|
3552
|
+
var primary = _this21.getSalesNotePrimaryRelation(note);
|
|
3481
3553
|
return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
|
|
3482
3554
|
}) : -1;
|
|
3483
3555
|
var existing = existingIndex >= 0 ? notes[existingIndex] : null;
|
|
@@ -3729,17 +3801,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3729
3801
|
}, {
|
|
3730
3802
|
key: "buildTempOrderCustomer",
|
|
3731
3803
|
value: function buildTempOrderCustomer(params) {
|
|
3732
|
-
var
|
|
3804
|
+
var _ref51, _ref52, _ref53, _source$name, _ref54, _ref55, _ref56, _source$customer_name, _source$id, _source$customer_id, _ref57, _source$country_calli, _source$phone, _source$email;
|
|
3733
3805
|
if (!params.customerId) return null;
|
|
3734
3806
|
var source = params.source ? cloneDeep(params.source) : {};
|
|
3735
|
-
var name = (
|
|
3736
|
-
var customerName = (
|
|
3807
|
+
var name = (_ref51 = (_ref52 = (_ref53 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref53 !== void 0 ? _ref53 : source.customerName) !== null && _ref52 !== void 0 ? _ref52 : source.customer_name) !== null && _ref51 !== void 0 ? _ref51 : params.customerName;
|
|
3808
|
+
var customerName = (_ref54 = (_ref55 = (_ref56 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref56 !== void 0 ? _ref56 : source.display_name) !== null && _ref55 !== void 0 ? _ref55 : source.name) !== null && _ref54 !== void 0 ? _ref54 : params.customerName;
|
|
3737
3809
|
return _objectSpread(_objectSpread({}, source), {}, {
|
|
3738
3810
|
id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
|
|
3739
3811
|
customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
|
|
3740
3812
|
name: String(name || ''),
|
|
3741
3813
|
customer_name: String(customerName || ''),
|
|
3742
|
-
country_calling_code: String((
|
|
3814
|
+
country_calling_code: String((_ref57 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref57 !== void 0 ? _ref57 : params.countryCallingCode),
|
|
3743
3815
|
phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
|
|
3744
3816
|
email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
|
|
3745
3817
|
});
|
|
@@ -3759,15 +3831,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3759
3831
|
}, {
|
|
3760
3832
|
key: "productHasCustomerBoundDiscount",
|
|
3761
3833
|
value: function productHasCustomerBoundDiscount(product) {
|
|
3762
|
-
var
|
|
3834
|
+
var _this22 = this;
|
|
3763
3835
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
3764
|
-
return
|
|
3836
|
+
return _this22.isCustomerBoundDiscount(discount);
|
|
3765
3837
|
})) {
|
|
3766
3838
|
return true;
|
|
3767
3839
|
}
|
|
3768
3840
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
3769
3841
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
3770
|
-
return
|
|
3842
|
+
return _this22.isCustomerBoundDiscount(discount);
|
|
3771
3843
|
});
|
|
3772
3844
|
});
|
|
3773
3845
|
}
|
|
@@ -3776,18 +3848,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3776
3848
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
3777
3849
|
var _this$store$discount20,
|
|
3778
3850
|
_this$store$discount21,
|
|
3779
|
-
|
|
3851
|
+
_this23 = this;
|
|
3780
3852
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
3781
3853
|
var discountList = ((_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 || (_this$store$discount21 = _this$store$discount20.getDiscountList) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.call(_this$store$discount20)) || [];
|
|
3782
3854
|
if (discountList.length > 0) return false;
|
|
3783
3855
|
return !(tempOrder.products || []).some(function (product) {
|
|
3784
|
-
return
|
|
3856
|
+
return _this23.productHasCustomerBoundDiscount(product);
|
|
3785
3857
|
});
|
|
3786
3858
|
}
|
|
3787
3859
|
}, {
|
|
3788
3860
|
key: "clearCustomerBoundDiscounts",
|
|
3789
3861
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
3790
|
-
var
|
|
3862
|
+
var _this24 = this,
|
|
3791
3863
|
_discountModule$getDi,
|
|
3792
3864
|
_discountModule$getOr,
|
|
3793
3865
|
_discountModule$setDi,
|
|
@@ -3796,7 +3868,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3796
3868
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
3797
3869
|
if (!Array.isArray(discountList)) return [];
|
|
3798
3870
|
return discountList.filter(function (discount) {
|
|
3799
|
-
var shouldRemove =
|
|
3871
|
+
var shouldRemove = _this24.isCustomerBoundDiscount(discount);
|
|
3800
3872
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
3801
3873
|
return !shouldRemove;
|
|
3802
3874
|
});
|
|
@@ -3823,12 +3895,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3823
3895
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
3824
3896
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
3825
3897
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
3826
|
-
if (
|
|
3827
|
-
return !
|
|
3898
|
+
if (_this24.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3899
|
+
return !_this24.isCustomerBoundDiscount(discount);
|
|
3828
3900
|
});
|
|
3829
3901
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
3830
|
-
if (
|
|
3831
|
-
return !
|
|
3902
|
+
if (_this24.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3903
|
+
return !_this24.isCustomerBoundDiscount(discount);
|
|
3832
3904
|
});
|
|
3833
3905
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
3834
3906
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -3843,14 +3915,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3843
3915
|
}, {
|
|
3844
3916
|
key: "updateTempOrderCustomer",
|
|
3845
3917
|
value: function updateTempOrderCustomer(customer) {
|
|
3846
|
-
var _tempOrder$customer_i3,
|
|
3918
|
+
var _tempOrder$customer_i3, _ref58, _ref59, _customer$customer_id, _ref60, _ref61, _ref62, _customer$customer_na, _ref63, _customer$country_cal, _tempOrder$customer_i4;
|
|
3847
3919
|
var tempOrder = this.ensureTempOrder();
|
|
3848
3920
|
var previousCustomerId = (_tempOrder$customer_i3 = tempOrder.customer_id) !== null && _tempOrder$customer_i3 !== void 0 ? _tempOrder$customer_i3 : null;
|
|
3849
|
-
var customerId = (
|
|
3850
|
-
var customerName = (
|
|
3921
|
+
var customerId = (_ref58 = (_ref59 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref59 !== void 0 ? _ref59 : customer.id) !== null && _ref58 !== void 0 ? _ref58 : null;
|
|
3922
|
+
var customerName = (_ref60 = (_ref61 = (_ref62 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref62 !== void 0 ? _ref62 : customer.display_name) !== null && _ref61 !== void 0 ? _ref61 : customer.name) !== null && _ref60 !== void 0 ? _ref60 : '';
|
|
3851
3923
|
tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
|
|
3852
3924
|
tempOrder.customer_name = String(customerName || '');
|
|
3853
|
-
tempOrder.country_calling_code = String((
|
|
3925
|
+
tempOrder.country_calling_code = String((_ref63 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref63 !== void 0 ? _ref63 : '');
|
|
3854
3926
|
tempOrder.phone = String(customer.phone || '');
|
|
3855
3927
|
tempOrder.email = String(customer.email || '');
|
|
3856
3928
|
tempOrder.customer = this.buildTempOrderCustomer({
|
|
@@ -3863,8 +3935,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3863
3935
|
});
|
|
3864
3936
|
var nextCustomerId = (_tempOrder$customer_i4 = tempOrder.customer_id) !== null && _tempOrder$customer_i4 !== void 0 ? _tempOrder$customer_i4 : null;
|
|
3865
3937
|
if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
|
|
3866
|
-
this.
|
|
3867
|
-
this.clearTempOrderPointCardSnapshot(tempOrder);
|
|
3938
|
+
this.clearCustomerWalletState(tempOrder);
|
|
3868
3939
|
}
|
|
3869
3940
|
this.persistTempOrder();
|
|
3870
3941
|
return {
|
|
@@ -3903,9 +3974,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3903
3974
|
}
|
|
3904
3975
|
var nextCustomerId = (_tempOrder$customer_i6 = tempOrder.customer_id) !== null && _tempOrder$customer_i6 !== void 0 ? _tempOrder$customer_i6 : null;
|
|
3905
3976
|
if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
|
|
3906
|
-
this.
|
|
3907
|
-
this.store.virtualCurrencyList = [];
|
|
3908
|
-
this.clearTempOrderPointCardSnapshot(tempOrder);
|
|
3977
|
+
this.clearCustomerWalletState(tempOrder);
|
|
3909
3978
|
clearTempOrderHolderAssignments(tempOrder);
|
|
3910
3979
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3911
3980
|
this.applyDiscount();
|
|
@@ -3950,9 +4019,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3950
4019
|
tempOrder.email = '';
|
|
3951
4020
|
tempOrder.customer = null;
|
|
3952
4021
|
if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
|
|
3953
|
-
this.
|
|
3954
|
-
this.store.virtualCurrencyList = [];
|
|
3955
|
-
this.clearTempOrderPointCardSnapshot(tempOrder);
|
|
4022
|
+
this.clearCustomerWalletState(tempOrder);
|
|
3956
4023
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3957
4024
|
this.applyDiscount();
|
|
3958
4025
|
this.persistTempOrder();
|
|
@@ -3997,10 +4064,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3997
4064
|
}, {
|
|
3998
4065
|
key: "setOrderPayments",
|
|
3999
4066
|
value: function setOrderPayments(payments) {
|
|
4000
|
-
var
|
|
4067
|
+
var _this25 = this;
|
|
4001
4068
|
var tempOrder = this.ensureTempOrder();
|
|
4002
4069
|
tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
|
|
4003
|
-
return
|
|
4070
|
+
return _this25.normalizePaymentSource(payment, {
|
|
4004
4071
|
defaultPaid: false
|
|
4005
4072
|
});
|
|
4006
4073
|
}));
|
|
@@ -4055,7 +4122,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4055
4122
|
}, {
|
|
4056
4123
|
key: "addOrderPaymentWithDevicePrefix",
|
|
4057
4124
|
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
4058
|
-
var
|
|
4125
|
+
var _this26 = this;
|
|
4059
4126
|
this.logInfo('addOrderPayment', {
|
|
4060
4127
|
payment: payment
|
|
4061
4128
|
});
|
|
@@ -4073,7 +4140,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4073
4140
|
void this.recalculateSummary({
|
|
4074
4141
|
createIfMissing: true
|
|
4075
4142
|
}).catch(function (error) {
|
|
4076
|
-
|
|
4143
|
+
_this26.logError('recalculate summary after addOrderPayment failed', {
|
|
4077
4144
|
error: error instanceof Error ? error.message : String(error)
|
|
4078
4145
|
});
|
|
4079
4146
|
});
|
|
@@ -4186,7 +4253,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4186
4253
|
}, {
|
|
4187
4254
|
key: "applyPaymentLifecycleChange",
|
|
4188
4255
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
4189
|
-
var
|
|
4256
|
+
var _this27 = this;
|
|
4190
4257
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
4191
4258
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
4192
4259
|
this.persistTempOrder();
|
|
@@ -4196,7 +4263,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4196
4263
|
void this.recalculateSummary({
|
|
4197
4264
|
createIfMissing: true
|
|
4198
4265
|
}).catch(function (error) {
|
|
4199
|
-
|
|
4266
|
+
_this27.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
4200
4267
|
error: error instanceof Error ? error.message : String(error)
|
|
4201
4268
|
});
|
|
4202
4269
|
});
|
|
@@ -4240,7 +4307,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4240
4307
|
}, {
|
|
4241
4308
|
key: "updateVoucherOrderPayments",
|
|
4242
4309
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
4243
|
-
var
|
|
4310
|
+
var _this28 = this;
|
|
4244
4311
|
var tempOrder = this.ensureTempOrder();
|
|
4245
4312
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
4246
4313
|
return value === 'normal' || value === 'deposit';
|
|
@@ -4275,7 +4342,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4275
4342
|
});
|
|
4276
4343
|
};
|
|
4277
4344
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
4278
|
-
return
|
|
4345
|
+
return _this28.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
4279
4346
|
defaultPaid: false,
|
|
4280
4347
|
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
4281
4348
|
});
|
|
@@ -4328,7 +4395,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4328
4395
|
void this.recalculateSummary({
|
|
4329
4396
|
createIfMissing: true
|
|
4330
4397
|
}).catch(function (error) {
|
|
4331
|
-
|
|
4398
|
+
_this28.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
4332
4399
|
error: error instanceof Error ? error.message : String(error)
|
|
4333
4400
|
});
|
|
4334
4401
|
});
|
|
@@ -4386,7 +4453,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4386
4453
|
key: "shouldMergeProductToOrder",
|
|
4387
4454
|
value: function shouldMergeProductToOrder(params) {
|
|
4388
4455
|
var _this$orderHooks,
|
|
4389
|
-
|
|
4456
|
+
_this29 = this;
|
|
4390
4457
|
var onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
4391
4458
|
if (!onBeforeMergeProductToOrder) return true;
|
|
4392
4459
|
var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -4394,7 +4461,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4394
4461
|
}));
|
|
4395
4462
|
if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
|
|
4396
4463
|
return Promise.resolve(result).then(function (resolved) {
|
|
4397
|
-
return
|
|
4464
|
+
return _this29.normalizeShouldMergeProductResult(resolved);
|
|
4398
4465
|
});
|
|
4399
4466
|
}
|
|
4400
4467
|
return this.normalizeShouldMergeProductResult(result);
|
|
@@ -4443,7 +4510,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4443
4510
|
}, {
|
|
4444
4511
|
key: "assertAndLockProductSettlement",
|
|
4445
4512
|
value: function assertAndLockProductSettlement(tempOrder, product) {
|
|
4446
|
-
var
|
|
4513
|
+
var _ref64, _ref65, _product$selling_pric;
|
|
4447
4514
|
if (!this.isMultiCurrencySettlementEnabled()) return;
|
|
4448
4515
|
var currentKey = getTempOrderSettlementKey(tempOrder);
|
|
4449
4516
|
var incomingKey = getSettlementKey(getSelectedSettlementSnapshot(product)) || 'legal_currency';
|
|
@@ -4470,7 +4537,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4470
4537
|
}
|
|
4471
4538
|
applyTempOrderSettlementState(tempOrder, snapshot || {
|
|
4472
4539
|
settlement_type: 'legal_currency',
|
|
4473
|
-
price: (
|
|
4540
|
+
price: (_ref64 = (_ref65 = (_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : product.original_price) !== null && _ref65 !== void 0 ? _ref65 : product.payment_price) !== null && _ref64 !== void 0 ? _ref64 : 0,
|
|
4474
4541
|
unit_label: tempOrder.currency_code,
|
|
4475
4542
|
symbol: tempOrder.currency_symbol,
|
|
4476
4543
|
amount_format: tempOrder.currency_format
|
|
@@ -4595,7 +4662,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4595
4662
|
_metadata,
|
|
4596
4663
|
_productToAdd$metadat,
|
|
4597
4664
|
_origin,
|
|
4598
|
-
|
|
4665
|
+
_this30 = this;
|
|
4599
4666
|
var linked = booking ? this.createLinkedProductAndBooking({
|
|
4600
4667
|
product: product,
|
|
4601
4668
|
booking: booking
|
|
@@ -4629,8 +4696,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4629
4696
|
var shouldForceNewLine = disableMerge || !!booking || hasIncomingProductNote || hasIncomingManualProductDiscount || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
4630
4697
|
var matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
4631
4698
|
var _item$metadata3;
|
|
4632
|
-
if (
|
|
4633
|
-
if (
|
|
4699
|
+
if (_this30.hasGoodPassDiscount(item)) return false;
|
|
4700
|
+
if (_this30.hasOrderProductLineNote(item)) return false;
|
|
4634
4701
|
if (isManualProductDiscountProduct(item)) return false;
|
|
4635
4702
|
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
4636
4703
|
if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
|
|
@@ -4644,7 +4711,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4644
4711
|
var commitProductLine = function commitProductLine(shouldMerge) {
|
|
4645
4712
|
var committedProduct;
|
|
4646
4713
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
4647
|
-
|
|
4714
|
+
_this30.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
4648
4715
|
if (linked) {
|
|
4649
4716
|
normalizedIncoming.booking_uid = linked.bookingUid;
|
|
4650
4717
|
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
|
|
@@ -4662,7 +4729,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4662
4729
|
var _targetProduct$metada;
|
|
4663
4730
|
var targetProduct = matchedProduct;
|
|
4664
4731
|
var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
4665
|
-
var normalizedProduct =
|
|
4732
|
+
var normalizedProduct = _this30.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
4666
4733
|
metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
|
|
4667
4734
|
unique_identification_number: targetUid
|
|
4668
4735
|
})
|
|
@@ -4685,7 +4752,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4685
4752
|
order_detail_id: targetProduct.order_detail_id,
|
|
4686
4753
|
num: nextNum
|
|
4687
4754
|
});
|
|
4688
|
-
|
|
4755
|
+
_this30.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
4689
4756
|
committedProduct = tempOrder.products[matchedIndex];
|
|
4690
4757
|
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
4691
4758
|
var mergedProduct = tempOrder.products[matchedIndex];
|
|
@@ -4723,14 +4790,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4723
4790
|
}, {
|
|
4724
4791
|
key: "createSplitBookingLine",
|
|
4725
4792
|
value: function createSplitBookingLine(product, booking, index, splitCount) {
|
|
4726
|
-
var _booking$metadata6,
|
|
4793
|
+
var _booking$metadata6, _ref66, _ref67, _bookingHolder$form_r, _booking$metadata7, _product$metadata10, _bookingHolder$name, _singleBooking$metada;
|
|
4727
4794
|
var singleLine = cloneDeep(product);
|
|
4728
4795
|
singleLine.num = 1;
|
|
4729
4796
|
delete singleLine.product_quantity;
|
|
4730
4797
|
var singleBooking = cloneDeep(booking);
|
|
4731
4798
|
var bookingHolder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
|
|
4732
4799
|
var metadataHolder = booking !== null && booking !== void 0 && (_booking$metadata6 = booking.metadata) !== null && _booking$metadata6 !== void 0 && _booking$metadata6.holder && _typeof(booking.metadata.holder) === 'object' ? booking.metadata.holder : null;
|
|
4733
|
-
var rawHolderIds = (
|
|
4800
|
+
var rawHolderIds = (_ref66 = (_ref67 = (_bookingHolder$form_r = bookingHolder === null || bookingHolder === void 0 ? void 0 : bookingHolder.form_record) !== null && _bookingHolder$form_r !== void 0 ? _bookingHolder$form_r : booking === null || booking === void 0 || (_booking$metadata7 = booking.metadata) === null || _booking$metadata7 === void 0 ? void 0 : _booking$metadata7.holder_id) !== null && _ref67 !== void 0 ? _ref67 : metadataHolder === null || metadataHolder === void 0 ? void 0 : metadataHolder.form_record) !== null && _ref66 !== void 0 ? _ref66 : product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.holder_id;
|
|
4734
4801
|
var holderIds = (Array.isArray(rawHolderIds) ? rawHolderIds : [rawHolderIds]).map(function (holderId) {
|
|
4735
4802
|
return holderId && _typeof(holderId) === 'object' ? holderId.form_record_id : holderId;
|
|
4736
4803
|
}).filter(function (holderId) {
|
|
@@ -4795,8 +4862,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4795
4862
|
key: "addProductToOrder",
|
|
4796
4863
|
value: (function () {
|
|
4797
4864
|
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
|
|
4798
|
-
var
|
|
4799
|
-
var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex,
|
|
4865
|
+
var _this31 = this;
|
|
4866
|
+
var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref68, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
|
|
4800
4867
|
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
4801
4868
|
while (1) switch (_context25.prev = _context25.next) {
|
|
4802
4869
|
case 0:
|
|
@@ -4824,7 +4891,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4824
4891
|
throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
|
|
4825
4892
|
}
|
|
4826
4893
|
salesNoteDrafts.forEach(function (draft) {
|
|
4827
|
-
|
|
4894
|
+
_this31.setSalesNoteOnTempOrder(tempOrder, {
|
|
4828
4895
|
note_type: draft.note_type,
|
|
4829
4896
|
target: {
|
|
4830
4897
|
target_type: 'order_detail',
|
|
@@ -4854,7 +4921,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4854
4921
|
break;
|
|
4855
4922
|
}
|
|
4856
4923
|
productRecord = product;
|
|
4857
|
-
splitCount = getSafeProductNum((
|
|
4924
|
+
splitCount = getSafeProductNum((_ref68 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref68 !== void 0 ? _ref68 : 1);
|
|
4858
4925
|
if (!(splitCount > 1)) {
|
|
4859
4926
|
_context25.next = 27;
|
|
4860
4927
|
break;
|
|
@@ -4959,7 +5026,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4959
5026
|
key: "addProductsToOrder",
|
|
4960
5027
|
value: (function () {
|
|
4961
5028
|
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(items, options) {
|
|
4962
|
-
var tempOrder, _iterator20, _step20, item, product, booking,
|
|
5029
|
+
var tempOrder, _iterator20, _step20, item, product, booking, _ref69, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
|
|
4963
5030
|
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
4964
5031
|
while (1) switch (_context26.prev = _context26.next) {
|
|
4965
5032
|
case 0:
|
|
@@ -4991,7 +5058,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4991
5058
|
break;
|
|
4992
5059
|
}
|
|
4993
5060
|
productRecord = product;
|
|
4994
|
-
splitCount = getSafeProductNum((
|
|
5061
|
+
splitCount = getSafeProductNum((_ref69 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref69 !== void 0 ? _ref69 : 1);
|
|
4995
5062
|
if (!(splitCount > 1)) {
|
|
4996
5063
|
_context26.next = 26;
|
|
4997
5064
|
break;
|
|
@@ -5079,24 +5146,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5079
5146
|
}, {
|
|
5080
5147
|
key: "getBundleRuntimeIdentity",
|
|
5081
5148
|
value: function getBundleRuntimeIdentity(bundle) {
|
|
5082
|
-
var
|
|
5149
|
+
var _ref70, _bundle$bundle_id2, _ref71, _bundle$bundle_group_2, _ref72, _ref73, _bundle$bundle_produc3, _ref74, _bundle$bundle_varian3;
|
|
5083
5150
|
if (!bundle || _typeof(bundle) !== 'object') return '';
|
|
5084
|
-
return [(
|
|
5151
|
+
return [(_ref70 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref70 !== void 0 ? _ref70 : '', (_ref71 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref71 !== void 0 ? _ref71 : '', (_ref72 = (_ref73 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref73 !== void 0 ? _ref73 : bundle.product_id) !== null && _ref72 !== void 0 ? _ref72 : '', (_ref74 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref74 !== void 0 ? _ref74 : 0].join('|');
|
|
5085
5152
|
}
|
|
5086
5153
|
}, {
|
|
5087
5154
|
key: "preservePersistedBundlePriceFields",
|
|
5088
5155
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
5089
|
-
var
|
|
5156
|
+
var _this32 = this;
|
|
5090
5157
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
5091
5158
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
5092
5159
|
var previousByIdentity = new Map();
|
|
5093
5160
|
previousBundles.forEach(function (bundle) {
|
|
5094
|
-
var identity =
|
|
5161
|
+
var identity = _this32.getBundleRuntimeIdentity(bundle);
|
|
5095
5162
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
5096
5163
|
});
|
|
5097
5164
|
return nextBundles.map(function (bundle, index) {
|
|
5098
5165
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
5099
|
-
var previous = previousByIdentity.get(
|
|
5166
|
+
var previous = previousByIdentity.get(_this32.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
5100
5167
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
5101
5168
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
5102
5169
|
cover: previous.cover
|
|
@@ -5232,13 +5299,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5232
5299
|
delete nextProduct.metadata.main_product_original_price;
|
|
5233
5300
|
delete nextProduct.metadata.price_schema_version;
|
|
5234
5301
|
} else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
5235
|
-
var
|
|
5302
|
+
var _ref75, _targetProduct$metada10, _targetProduct$metada11, _ref76, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
|
|
5236
5303
|
// 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
|
|
5237
5304
|
// 但必须让 original 与 selling 一起随新的 option 金额移动。
|
|
5238
5305
|
var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
|
|
5239
5306
|
var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
|
|
5240
|
-
var _previousMainOriginal = new Decimal(Number((
|
|
5241
|
-
var _previousMainSelling = new Decimal(Number((
|
|
5307
|
+
var _previousMainOriginal = new Decimal(Number((_ref75 = (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.main_product_original_price) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : targetProduct.original_price) !== null && _ref75 !== void 0 ? _ref75 : 0) || 0);
|
|
5308
|
+
var _previousMainSelling = new Decimal(Number((_ref76 = (_targetProduct$metada12 = (_targetProduct$metada13 = targetProduct.metadata) === null || _targetProduct$metada13 === void 0 ? void 0 : _targetProduct$metada13.main_product_selling_price) !== null && _targetProduct$metada12 !== void 0 ? _targetProduct$metada12 : targetProduct.selling_price) !== null && _ref76 !== void 0 ? _ref76 : _previousMainOriginal.toNumber()) || 0);
|
|
5242
5309
|
var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
|
|
5243
5310
|
var previousSource = ((_targetProduct$metada14 = targetProduct.metadata) === null || _targetProduct$metada14 === void 0 ? void 0 : _targetProduct$metada14.source_product_price) != null ? new Decimal(Number(targetProduct.metadata.source_product_price) || 0) : _previousMainOriginal.minus(previousOptionSum);
|
|
5244
5311
|
var _nextMainOriginal = previousSource.plus(nextOptionSum);
|
|
@@ -5338,7 +5405,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5338
5405
|
key: "updateOrderProducts",
|
|
5339
5406
|
value: function () {
|
|
5340
5407
|
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
|
|
5341
|
-
var
|
|
5408
|
+
var _this33 = this;
|
|
5342
5409
|
var tempOrder, reapplyBookingDiscountProductUids;
|
|
5343
5410
|
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
5344
5411
|
while (1) switch (_context28.prev = _context28.next) {
|
|
@@ -5351,7 +5418,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5351
5418
|
return _context28.abrupt("return", tempOrder.products);
|
|
5352
5419
|
case 3:
|
|
5353
5420
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
5354
|
-
var updatedProductUid =
|
|
5421
|
+
var updatedProductUid = _this33.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
5355
5422
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
5356
5423
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
5357
5424
|
acc.push(String(updatedProductUid));
|
|
@@ -5577,7 +5644,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5577
5644
|
key: "removeProductsFromOrder",
|
|
5578
5645
|
value: (function () {
|
|
5579
5646
|
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
|
|
5580
|
-
var
|
|
5647
|
+
var _this34 = this;
|
|
5581
5648
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
5582
5649
|
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
5583
5650
|
while (1) switch (_context32.prev = _context32.next) {
|
|
@@ -5642,7 +5709,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5642
5709
|
}
|
|
5643
5710
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
5644
5711
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
5645
|
-
var bookingUid =
|
|
5712
|
+
var bookingUid = _this34.getBookingUniqueIdentificationNumber(booking);
|
|
5646
5713
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
5647
5714
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
5648
5715
|
}
|
|
@@ -5857,23 +5924,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5857
5924
|
}, {
|
|
5858
5925
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
5859
5926
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
5860
|
-
var _params$cacheId, _this$otherParams5,
|
|
5927
|
+
var _params$cacheId, _this$otherParams5, _ref77, _params$businessCode, _this$otherParams6, _this$otherParams7;
|
|
5861
5928
|
var tempOrder = this.ensureTempOrder();
|
|
5862
5929
|
this.persistTempOrder();
|
|
5863
5930
|
var payload = buildSubmitPayload({
|
|
5864
5931
|
tempOrder: tempOrder,
|
|
5865
5932
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
5866
5933
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
|
|
5867
|
-
businessCode: (
|
|
5934
|
+
businessCode: (_ref77 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref77 !== void 0 ? _ref77 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
|
|
5868
5935
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5869
5936
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
5870
5937
|
summary: this.store.summary || createEmptySummary(),
|
|
5871
5938
|
enhance: function enhance(nextPayload) {
|
|
5872
|
-
var
|
|
5939
|
+
var _ref78, _tempOrder$order_numb, _ref79, _tempOrder$shop_order2, _ref80, _tempOrder$shop_full_;
|
|
5873
5940
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
5874
|
-
order_number: (
|
|
5875
|
-
shop_order_number: (
|
|
5876
|
-
shop_full_order_number: (
|
|
5941
|
+
order_number: (_ref78 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref78 !== void 0 ? _ref78 : null,
|
|
5942
|
+
shop_order_number: (_ref79 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref79 !== void 0 ? _ref79 : null,
|
|
5943
|
+
shop_full_order_number: (_ref80 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref80 !== void 0 ? _ref80 : null,
|
|
5877
5944
|
small_ticket_data_flag: 1
|
|
5878
5945
|
});
|
|
5879
5946
|
}
|
|
@@ -6037,7 +6104,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6037
6104
|
key: "runSubmitTempOrder",
|
|
6038
6105
|
value: function () {
|
|
6039
6106
|
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
6040
|
-
var _params$cacheId3, _this$otherParams12,
|
|
6107
|
+
var _params$cacheId3, _this$otherParams12, _ref81, _ref82, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
|
|
6041
6108
|
var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
|
|
6042
6109
|
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
6043
6110
|
while (1) switch (_context40.prev = _context40.next) {
|
|
@@ -6104,7 +6171,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6104
6171
|
tempOrder: tempOrder,
|
|
6105
6172
|
cacheId: effectiveCacheId,
|
|
6106
6173
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform),
|
|
6107
|
-
businessCode: (
|
|
6174
|
+
businessCode: (_ref81 = (_ref82 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref82 !== void 0 ? _ref82 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref81 !== void 0 ? _ref81 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
|
|
6108
6175
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
6109
6176
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
6110
6177
|
summary: latestSummary,
|
|
@@ -6274,10 +6341,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6274
6341
|
value: function extractSubmitErrorResponse(error) {
|
|
6275
6342
|
var _error$response,
|
|
6276
6343
|
_error$response2,
|
|
6277
|
-
|
|
6344
|
+
_this35 = this;
|
|
6278
6345
|
var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
|
|
6279
6346
|
return candidates.find(function (candidate) {
|
|
6280
|
-
return
|
|
6347
|
+
return _this35.isSubmitErrorResponse(candidate);
|
|
6281
6348
|
}) || null;
|
|
6282
6349
|
}
|
|
6283
6350
|
}, {
|
|
@@ -6305,7 +6372,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6305
6372
|
key: "syncPaymentsToOrder",
|
|
6306
6373
|
value: function () {
|
|
6307
6374
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
6308
|
-
var
|
|
6375
|
+
var _this36 = this,
|
|
6309
6376
|
_params$confirmPendin;
|
|
6310
6377
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
6311
6378
|
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
@@ -6330,7 +6397,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6330
6397
|
case 9:
|
|
6331
6398
|
devicePrefix = _context42.t0;
|
|
6332
6399
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
6333
|
-
return
|
|
6400
|
+
return _this36.normalizePaymentSource(payment, {
|
|
6334
6401
|
defaultPaid: false,
|
|
6335
6402
|
devicePrefix: devicePrefix
|
|
6336
6403
|
});
|
|
@@ -6409,7 +6476,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6409
6476
|
}, {
|
|
6410
6477
|
key: "createOrder",
|
|
6411
6478
|
value: function createOrder(params) {
|
|
6412
|
-
var
|
|
6479
|
+
var _this37 = this;
|
|
6413
6480
|
var order = _objectSpread({
|
|
6414
6481
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
6415
6482
|
// 要从外面拿,virtual
|
|
@@ -6441,7 +6508,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6441
6508
|
|
|
6442
6509
|
// 为预约补齐 holder 信息
|
|
6443
6510
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
6444
|
-
ensureCartItemOriginHolder(item,
|
|
6511
|
+
ensureCartItemOriginHolder(item, _this37.window);
|
|
6445
6512
|
}
|
|
6446
6513
|
|
|
6447
6514
|
// 购物车是否为普通商品
|
|
@@ -6917,8 +6984,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6917
6984
|
allowUnresolvedSalesNotes: isSessionStorageHydrate
|
|
6918
6985
|
});
|
|
6919
6986
|
this.store.tempOrder = nextTempOrder;
|
|
6987
|
+
this.clearCustomerWalletRuntimeState();
|
|
6920
6988
|
if (!isSessionStorageHydrate) {
|
|
6921
|
-
_context50.next =
|
|
6989
|
+
_context50.next = 31;
|
|
6922
6990
|
break;
|
|
6923
6991
|
}
|
|
6924
6992
|
// 会话快照是未提交购物车,不应获得编辑订单的 saved/edit 标记与服务端基线。
|
|
@@ -6934,24 +7002,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6934
7002
|
nextTempOrder.discount_list = restoredSessionDiscounts;
|
|
6935
7003
|
this.store.summary = createEmptySummary();
|
|
6936
7004
|
this.store.lastOrderInfo = undefined;
|
|
6937
|
-
_context50.next =
|
|
7005
|
+
_context50.next = 24;
|
|
6938
7006
|
return (_this$store$discount24 = this.store.discount) === null || _this$store$discount24 === void 0 ? void 0 : _this$store$discount24.setOriginalDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
6939
|
-
case
|
|
6940
|
-
_context50.next =
|
|
7007
|
+
case 24:
|
|
7008
|
+
_context50.next = 26;
|
|
6941
7009
|
return (_this$store$discount25 = this.store.discount) === null || _this$store$discount25 === void 0 ? void 0 : _this$store$discount25.setDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
6942
|
-
case
|
|
7010
|
+
case 26:
|
|
6943
7011
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
6944
|
-
_context50.next =
|
|
7012
|
+
_context50.next = 29;
|
|
6945
7013
|
break;
|
|
6946
7014
|
}
|
|
6947
|
-
_context50.next =
|
|
7015
|
+
_context50.next = 29;
|
|
6948
7016
|
return this.recalculateSummary({
|
|
6949
7017
|
createIfMissing: false
|
|
6950
7018
|
});
|
|
6951
|
-
case
|
|
7019
|
+
case 29:
|
|
6952
7020
|
this.persistTempOrder();
|
|
6953
7021
|
return _context50.abrupt("return", nextTempOrder);
|
|
6954
|
-
case
|
|
7022
|
+
case 31:
|
|
6955
7023
|
// Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
|
|
6956
7024
|
sourceLastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
|
|
6957
7025
|
isDraftOrder = Number(nextTempOrder.is_draft_order || 0) === 1;
|
|
@@ -7002,28 +7070,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7002
7070
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
7003
7071
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
7004
7072
|
if (shouldSkipEmptyDiscountSync) {
|
|
7005
|
-
_context50.next =
|
|
7073
|
+
_context50.next = 55;
|
|
7006
7074
|
break;
|
|
7007
7075
|
}
|
|
7008
7076
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
7009
|
-
_context50.next =
|
|
7077
|
+
_context50.next = 53;
|
|
7010
7078
|
return (_this$store$discount27 = this.store.discount) === null || _this$store$discount27 === void 0 ? void 0 : _this$store$discount27.setOriginalDiscountList(nextDiscounts);
|
|
7011
|
-
case
|
|
7012
|
-
_context50.next =
|
|
7079
|
+
case 53:
|
|
7080
|
+
_context50.next = 55;
|
|
7013
7081
|
return (_this$store$discount28 = this.store.discount) === null || _this$store$discount28 === void 0 ? void 0 : _this$store$discount28.setDiscountList(nextDiscounts);
|
|
7014
|
-
case
|
|
7082
|
+
case 55:
|
|
7015
7083
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
7016
|
-
_context50.next =
|
|
7084
|
+
_context50.next = 58;
|
|
7017
7085
|
break;
|
|
7018
7086
|
}
|
|
7019
|
-
_context50.next =
|
|
7087
|
+
_context50.next = 58;
|
|
7020
7088
|
return this.recalculateSummary({
|
|
7021
7089
|
createIfMissing: false
|
|
7022
7090
|
});
|
|
7023
|
-
case
|
|
7091
|
+
case 58:
|
|
7024
7092
|
this.persistTempOrder();
|
|
7025
7093
|
return _context50.abrupt("return", nextTempOrder);
|
|
7026
|
-
case
|
|
7094
|
+
case 60:
|
|
7027
7095
|
case "end":
|
|
7028
7096
|
return _context50.stop();
|
|
7029
7097
|
}
|
|
@@ -7143,7 +7211,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7143
7211
|
}, {
|
|
7144
7212
|
key: "normalizeTempOrderForRuntime",
|
|
7145
7213
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
7146
|
-
var
|
|
7214
|
+
var _this38 = this,
|
|
7147
7215
|
_raw$_extend;
|
|
7148
7216
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
7149
7217
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
@@ -7168,12 +7236,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7168
7236
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
7169
7237
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
7170
7238
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
7171
|
-
return
|
|
7239
|
+
return _this38.normalizeHydratedOrderProduct(p, {
|
|
7172
7240
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
7173
7241
|
});
|
|
7174
7242
|
}) : [];
|
|
7175
7243
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
7176
|
-
var booking =
|
|
7244
|
+
var booking = _this38.normalizeHydratedBookingHolder(b || {});
|
|
7177
7245
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
7178
7246
|
is_all: normalizeBookingIsAll(booking),
|
|
7179
7247
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -7223,7 +7291,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7223
7291
|
_step24;
|
|
7224
7292
|
try {
|
|
7225
7293
|
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
7226
|
-
var _product$metadata12,
|
|
7294
|
+
var _product$metadata12, _ref83, _ref84, _existed$origin, _rawProduct$metadata;
|
|
7227
7295
|
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
7228
7296
|
index = _step24$value[0],
|
|
7229
7297
|
product = _step24$value[1];
|
|
@@ -7231,7 +7299,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7231
7299
|
if (!uid) continue;
|
|
7232
7300
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
7233
7301
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
7234
|
-
var origin = (
|
|
7302
|
+
var origin = (_ref83 = (_ref84 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref84 !== void 0 ? _ref84 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref83 !== void 0 ? _ref83 : rawProduct;
|
|
7235
7303
|
var originSnapshot = cloneDeep(origin);
|
|
7236
7304
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
7237
7305
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -7360,10 +7428,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7360
7428
|
}, {
|
|
7361
7429
|
key: "normalizeHydratedProductOptionItem",
|
|
7362
7430
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
7363
|
-
var
|
|
7364
|
-
var rawNum = (
|
|
7431
|
+
var _ref85, _optionItem$num, _ref86, _optionItem$add_price;
|
|
7432
|
+
var rawNum = (_ref85 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref85 !== void 0 ? _ref85 : 1;
|
|
7365
7433
|
var parsedNum = Number(rawNum);
|
|
7366
|
-
var rawPrice = (
|
|
7434
|
+
var rawPrice = (_ref86 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref86 !== void 0 ? _ref86 : 0;
|
|
7367
7435
|
var parsedPrice = Number(rawPrice);
|
|
7368
7436
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
7369
7437
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -7380,7 +7448,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7380
7448
|
}, {
|
|
7381
7449
|
key: "normalizeHydratedOrderProduct",
|
|
7382
7450
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
7383
|
-
var
|
|
7451
|
+
var _this39 = this;
|
|
7384
7452
|
var row = _objectSpread({}, product || {});
|
|
7385
7453
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
7386
7454
|
row.num = row.product_quantity;
|
|
@@ -7388,7 +7456,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7388
7456
|
var productSku = ensureProductSku(row);
|
|
7389
7457
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
7390
7458
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
7391
|
-
return
|
|
7459
|
+
return _this39.normalizeHydratedProductOptionItem(optionItem || {});
|
|
7392
7460
|
}))
|
|
7393
7461
|
});
|
|
7394
7462
|
delete row["product_".concat('option', "_item")];
|