@pisell/pisellos 0.10.43 → 0.10.44
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/itemRule/adapter.d.ts +4 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +135 -35
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +25 -1
- package/dist/model/strategy/adapter/itemRule/type.d.ts +44 -0
- package/dist/model/strategy/adapter/itemRule/type.js +19 -1
- package/dist/modules/Order/index.d.ts +41 -9
- package/dist/modules/Order/index.js +1438 -878
- package/dist/modules/Order/salesNotes.d.ts +31 -0
- package/dist/modules/Order/salesNotes.js +492 -0
- package/dist/modules/Order/types.d.ts +105 -8
- package/dist/modules/Order/types.js +6 -1
- package/dist/modules/Order/utils.d.ts +3 -1
- package/dist/modules/Order/utils.js +191 -71
- package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +4 -5
- package/dist/modules/Payment/cashRecommendationAlgorithm.js +17 -367
- package/dist/modules/ProductList/index.d.ts +2 -1
- package/dist/modules/ProductList/index.js +100 -20
- package/dist/modules/ProductList/types.d.ts +10 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.js +45 -3
- 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.d.ts +1 -0
- package/dist/server/utils/small-ticket.js +142 -14
- package/dist/solution/BaseSales/index.d.ts +15 -1
- package/dist/solution/BaseSales/index.js +1240 -877
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -0
- package/dist/solution/BookingTicket/index.js +37 -16
- package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
- package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
- package/dist/solution/RegisterAndLogin/config.js +95 -40
- package/dist/solution/RegisterAndLogin/index.js +4 -1
- package/dist/solution/ScanOrder/index.d.ts +1 -0
- package/dist/solution/ScanOrder/index.js +31 -27
- package/dist/solution/ScanOrder/utils.d.ts +1 -0
- package/dist/solution/ScanOrder/utils.js +2 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +15 -2
- package/dist/solution/UnifiedBookingSales/index.js +777 -510
- package/dist/solution/UnifiedBookingSales/types.d.ts +14 -1
- package/dist/solution/VenueBooking/index.d.ts +1 -0
- package/dist/solution/VenueBooking/index.js +8 -4
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
- package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
- package/lib/model/strategy/adapter/itemRule/type.js +19 -1
- package/lib/modules/Order/index.d.ts +41 -9
- package/lib/modules/Order/index.js +434 -61
- package/lib/modules/Order/salesNotes.d.ts +31 -0
- package/lib/modules/Order/salesNotes.js +382 -0
- package/lib/modules/Order/types.d.ts +105 -8
- package/lib/modules/Order/types.js +5 -1
- package/lib/modules/Order/utils.d.ts +3 -1
- package/lib/modules/Order/utils.js +114 -1
- package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +4 -5
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +9 -354
- package/lib/modules/ProductList/index.d.ts +2 -1
- package/lib/modules/ProductList/index.js +47 -2
- package/lib/modules/ProductList/types.d.ts +10 -0
- package/lib/server/index.d.ts +7 -0
- package/lib/server/index.js +39 -3
- 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.d.ts +1 -0
- package/lib/server/utils/small-ticket.js +136 -12
- package/lib/solution/BaseSales/index.d.ts +15 -1
- package/lib/solution/BaseSales/index.js +192 -22
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -0
- package/lib/solution/BookingTicket/index.js +23 -5
- package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
- package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
- package/lib/solution/RegisterAndLogin/config.js +49 -8
- package/lib/solution/RegisterAndLogin/index.js +4 -1
- package/lib/solution/ScanOrder/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.js +5 -1
- package/lib/solution/ScanOrder/utils.d.ts +1 -0
- package/lib/solution/ScanOrder/utils.js +1 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +15 -2
- package/lib/solution/UnifiedBookingSales/index.js +125 -1
- package/lib/solution/UnifiedBookingSales/types.d.ts +14 -1
- package/lib/solution/VenueBooking/index.d.ts +1 -0
- package/lib/solution/VenueBooking/index.js +5 -1
- package/package.json +1 -1
|
@@ -32,10 +32,11 @@ 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";
|
|
39
|
+
import { buildSalesNoteText, decodeSalesNotesSnapshot, getSalesNotePolicy } from "./salesNotes";
|
|
39
40
|
import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
|
|
40
41
|
import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
|
|
41
42
|
import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid, PRODUCT_LINE_MERGE_DISABLED_METADATA_KEY } from "../../solution/BaseSales/utils/cartPromotion";
|
|
@@ -166,6 +167,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
166
167
|
_defineProperty(_assertThisInitialized(_this), "openCache", false);
|
|
167
168
|
_defineProperty(_assertThisInitialized(_this), "sessionStoragePersistEnabled", false);
|
|
168
169
|
_defineProperty(_assertThisInitialized(_this), "sessionStorageRestoreRecord", null);
|
|
170
|
+
/** 只允许当前订单最新的 prepare/config 请求回写客户资产态。 */
|
|
171
|
+
_defineProperty(_assertThisInitialized(_this), "customerWalletPrepareConfigEpoch", 0);
|
|
169
172
|
_defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
|
|
170
173
|
_defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
|
|
171
174
|
_defineProperty(_assertThisInitialized(_this), "moduleHooksOverride", void 0);
|
|
@@ -176,8 +179,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
176
179
|
_defineProperty(_assertThisInitialized(_this), "promotionEvaluator", null);
|
|
177
180
|
/** 赠品选择 resolver;由 SDK host bridge 注入 */
|
|
178
181
|
_defineProperty(_assertThisInitialized(_this), "giftSelectResolver", null);
|
|
179
|
-
/**
|
|
182
|
+
/** 促销评估递归保护 flag(写路径同步评估促销,禁止重入) */
|
|
180
183
|
_defineProperty(_assertThisInitialized(_this), "isApplyingPromotion", false);
|
|
184
|
+
/** 保持旧事件语义:同步事件监听器内触发的订单写入不得递归评估促销。 */
|
|
185
|
+
_defineProperty(_assertThisInitialized(_this), "isEmittingPromotionApplied", false);
|
|
181
186
|
/** 商品曾应用过客户券卡,客户变更剥离后需强制跑一次 calcDiscount 复位价格 */
|
|
182
187
|
_defineProperty(_assertThisInitialized(_this), "hasActiveCustomerBoundDiscount", false);
|
|
183
188
|
/** 最近一次 applyPromotion 的未满足促销提示 */
|
|
@@ -595,18 +600,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
595
600
|
return createDefaultOrderRulesHooks();
|
|
596
601
|
}
|
|
597
602
|
|
|
603
|
+
/**
|
|
604
|
+
* Stable across notifyTempOrderChanged's immutable copy, but changes when a
|
|
605
|
+
* different local/server order becomes current.
|
|
606
|
+
*/
|
|
607
|
+
}, {
|
|
608
|
+
key: "getDiscountConfigOrderIdentityKey",
|
|
609
|
+
value: function getDiscountConfigOrderIdentityKey(tempOrder) {
|
|
610
|
+
var _ref12, _identity$orderId, _tempOrder$request_un, _ref13, _identity$externalSal, _ref14, _ref15, _identity$localId, _tempOrder$_extend;
|
|
611
|
+
var identity = this.getOrderIdentity();
|
|
612
|
+
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 : '']);
|
|
613
|
+
}
|
|
614
|
+
|
|
598
615
|
// ─── Discount: 公共 API ───
|
|
599
616
|
}, {
|
|
600
617
|
key: "loadDiscountConfig",
|
|
601
618
|
value: function () {
|
|
602
619
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
603
|
-
var _this$store$tempOrder,
|
|
604
|
-
|
|
620
|
+
var _this$store$tempOrder,
|
|
621
|
+
_this$store$discount,
|
|
622
|
+
_this2 = this,
|
|
623
|
+
_this$store$tempOrder2;
|
|
624
|
+
var orderId, requestEpoch, requestOrderIdentityKey, prepareConfigResult, isCurrentRequest, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentCommittedDiscounts, currentScanDiscounts, currentScanDiscountById, committedDiscountById, mergedCommittedDiscountIds, refreshedScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, retainedCommittedDiscounts, retainedScanDiscounts, mergedDiscountList;
|
|
605
625
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
606
626
|
while (1) switch (_context3.prev = _context3.next) {
|
|
607
627
|
case 0:
|
|
608
628
|
orderId = params.orderId || ((_this$store$tempOrder = this.store.tempOrder) === null || _this$store$tempOrder === void 0 ? void 0 : _this$store$tempOrder.order_id) || undefined;
|
|
609
|
-
|
|
629
|
+
requestEpoch = ++this.customerWalletPrepareConfigEpoch;
|
|
630
|
+
requestOrderIdentityKey = this.getDiscountConfigOrderIdentityKey(this.store.tempOrder);
|
|
631
|
+
_context3.next = 5;
|
|
610
632
|
return (_this$store$discount = this.store.discount) === null || _this$store$discount === void 0 ? void 0 : _this$store$discount.loadPrepareConfig(_objectSpread({
|
|
611
633
|
customer_id: params.customerId,
|
|
612
634
|
action: params.action || (orderId ? 'edit' : 'create'),
|
|
@@ -621,19 +643,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
621
643
|
}, orderId ? {
|
|
622
644
|
order_id: orderId
|
|
623
645
|
} : {}));
|
|
624
|
-
case
|
|
646
|
+
case 5:
|
|
625
647
|
prepareConfigResult = _context3.sent;
|
|
648
|
+
isCurrentRequest = function isCurrentRequest() {
|
|
649
|
+
var _this2$store$tempOrde, _this2$store$tempOrde2;
|
|
650
|
+
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);
|
|
651
|
+
};
|
|
652
|
+
if (isCurrentRequest()) {
|
|
653
|
+
_context3.next = 9;
|
|
654
|
+
break;
|
|
655
|
+
}
|
|
656
|
+
return _context3.abrupt("return", this.getDiscountList());
|
|
657
|
+
case 9:
|
|
626
658
|
discountList = prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.discountList;
|
|
627
|
-
this.store.availableWalletIds = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.availableWalletIds) || [];
|
|
628
|
-
this.store.virtualCurrencyList = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.virtualCurrencyList) || [];
|
|
629
659
|
if (prepareConfigResult) {
|
|
630
|
-
this.
|
|
660
|
+
this.writeCustomerWalletSnapshotsFromPrepareConfig({
|
|
631
661
|
customerId: params.customerId,
|
|
632
|
-
|
|
662
|
+
availableWalletIds: prepareConfigResult.availableWalletIds || [],
|
|
663
|
+
availableWalletPassList: prepareConfigResult.availableWalletPassList || [],
|
|
664
|
+
virtualCurrencyList: prepareConfigResult.virtualCurrencyList || []
|
|
633
665
|
});
|
|
634
666
|
}
|
|
635
667
|
if (!discountList) {
|
|
636
|
-
_context3.next =
|
|
668
|
+
_context3.next = 32;
|
|
637
669
|
break;
|
|
638
670
|
}
|
|
639
671
|
currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
|
|
@@ -699,17 +731,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
699
731
|
return id === null || !refreshedScanDiscountIds.has(id);
|
|
700
732
|
});
|
|
701
733
|
mergedDiscountList = [].concat(_toConsumableArray(retainedCommittedDiscounts), _toConsumableArray(retainedScanDiscounts), _toConsumableArray(runtimeDiscounts));
|
|
702
|
-
|
|
734
|
+
if (isCurrentRequest()) {
|
|
735
|
+
_context3.next = 26;
|
|
736
|
+
break;
|
|
737
|
+
}
|
|
738
|
+
return _context3.abrupt("return", this.getDiscountList());
|
|
739
|
+
case 26:
|
|
740
|
+
_context3.next = 28;
|
|
703
741
|
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
|
|
704
|
-
case
|
|
705
|
-
|
|
742
|
+
case 28:
|
|
743
|
+
if (isCurrentRequest()) {
|
|
744
|
+
_context3.next = 30;
|
|
745
|
+
break;
|
|
746
|
+
}
|
|
747
|
+
return _context3.abrupt("return", this.getDiscountList());
|
|
748
|
+
case 30:
|
|
749
|
+
_context3.next = 32;
|
|
706
750
|
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
|
|
707
|
-
case
|
|
751
|
+
case 32:
|
|
752
|
+
if (isCurrentRequest()) {
|
|
753
|
+
_context3.next = 34;
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
return _context3.abrupt("return", this.getDiscountList());
|
|
757
|
+
case 34:
|
|
708
758
|
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) {
|
|
709
759
|
this.applyDiscount();
|
|
710
760
|
}
|
|
711
761
|
return _context3.abrupt("return", this.getDiscountList());
|
|
712
|
-
case
|
|
762
|
+
case 36:
|
|
713
763
|
case "end":
|
|
714
764
|
return _context3.stop();
|
|
715
765
|
}
|
|
@@ -736,6 +786,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
736
786
|
value: function getVirtualCurrencyList() {
|
|
737
787
|
return cloneDeep(this.store.virtualCurrencyList || []);
|
|
738
788
|
}
|
|
789
|
+
}, {
|
|
790
|
+
key: "getCustomerWalletPrepareConfigEpoch",
|
|
791
|
+
value: function getCustomerWalletPrepareConfigEpoch() {
|
|
792
|
+
return this.customerWalletPrepareConfigEpoch;
|
|
793
|
+
}
|
|
739
794
|
}, {
|
|
740
795
|
key: "syncScannedDiscountsToOriginalDiscountList",
|
|
741
796
|
value: function () {
|
|
@@ -778,13 +833,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
778
833
|
key: "ensureEditDiscountConfigForProductChange",
|
|
779
834
|
value: function () {
|
|
780
835
|
var _ensureEditDiscountConfigForProductChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(tempOrder) {
|
|
781
|
-
var _tempOrder$customer, _tempOrder$
|
|
836
|
+
var _tempOrder$customer, _tempOrder$_extend2, _tempOrder$_extend3, _this$store$discount10;
|
|
782
837
|
var orderId, customerId, currentDiscountList, hasRuntimeDiscounts;
|
|
783
838
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
784
839
|
while (1) switch (_context5.prev = _context5.next) {
|
|
785
840
|
case 0:
|
|
786
841
|
orderId = tempOrder.order_id;
|
|
787
|
-
customerId = Number(tempOrder.customer_id || ((_tempOrder$customer = tempOrder.customer) === null || _tempOrder$customer === void 0 ? void 0 : _tempOrder$customer.id) || ((_tempOrder$
|
|
842
|
+
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);
|
|
788
843
|
if (!(!orderId || !customerId || customerId === 1)) {
|
|
789
844
|
_context5.next = 4;
|
|
790
845
|
break;
|
|
@@ -824,7 +879,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
824
879
|
value: function () {
|
|
825
880
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
826
881
|
var _this$store$discount11, _tempOrder$holder, _this$store$summary;
|
|
827
|
-
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders,
|
|
882
|
+
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref16, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, shouldRetainForLater, normalizedNewDiscountList, retainedDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13;
|
|
828
883
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
829
884
|
while (1) switch (_context6.prev = _context6.next) {
|
|
830
885
|
case 0:
|
|
@@ -914,7 +969,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
914
969
|
case 20:
|
|
915
970
|
tempOrder = this.store.tempOrder;
|
|
916
971
|
holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
|
|
917
|
-
|
|
972
|
+
_ref16 = rulesModule.isDiscountListAvailable({
|
|
918
973
|
productList: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
|
|
919
974
|
oldDiscountList: this.getDiscountList(),
|
|
920
975
|
newDiscountList: withScanList,
|
|
@@ -926,7 +981,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
926
981
|
}) || {
|
|
927
982
|
isAvailable: false,
|
|
928
983
|
discountList: this.getDiscountList()
|
|
929
|
-
}, isAvailable =
|
|
984
|
+
}, isAvailable = _ref16.isAvailable, newDiscountList = _ref16.discountList, evaluatedDiscountList = _ref16.evaluatedDiscountList, unavailableReason = _ref16.unavailableReason;
|
|
930
985
|
shouldRetainForLater = !isAvailable && unavailableReason === UnavailableReason.ProductNotApplicable && withScanList.some(isCustomerPromotionDiscount);
|
|
931
986
|
normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
|
|
932
987
|
retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
|
|
@@ -982,7 +1037,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
982
1037
|
value: function applyDiscount(options) {
|
|
983
1038
|
var _this$store$discount16,
|
|
984
1039
|
_this$store$summary2,
|
|
985
|
-
|
|
1040
|
+
_this3 = this;
|
|
986
1041
|
var tempOrder = this.store.tempOrder;
|
|
987
1042
|
// 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
|
|
988
1043
|
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
@@ -1018,9 +1073,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1018
1073
|
if (result !== null && result !== void 0 && result.productList) {
|
|
1019
1074
|
var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
|
|
1020
1075
|
tempOrder.products = this.applyProductDiscountPrices((result.productList || []).map(function (product, index) {
|
|
1021
|
-
var
|
|
1076
|
+
var _ref17;
|
|
1022
1077
|
var uid = getOrderProductLineUid(product);
|
|
1023
|
-
var previous = (
|
|
1078
|
+
var previous = (_ref17 = uid ? previousProductsByUid.get(uid) : undefined) !== null && _ref17 !== void 0 ? _ref17 : previousProductsByUid.get("__index__:".concat(index));
|
|
1024
1079
|
if (isManualProductDiscountProduct(previous)) {
|
|
1025
1080
|
return previous;
|
|
1026
1081
|
}
|
|
@@ -1038,7 +1093,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1038
1093
|
(_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || _this$store$discount17.setDiscountList(result.discountList);
|
|
1039
1094
|
}
|
|
1040
1095
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
1041
|
-
return
|
|
1096
|
+
return _this3.productHasCustomerBoundDiscount(product);
|
|
1042
1097
|
});
|
|
1043
1098
|
}
|
|
1044
1099
|
|
|
@@ -1084,7 +1139,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1084
1139
|
}
|
|
1085
1140
|
|
|
1086
1141
|
/**
|
|
1087
|
-
*
|
|
1142
|
+
* 只执行购物车促销评估与赠品写回,不发布稳定态事件。
|
|
1088
1143
|
*
|
|
1089
1144
|
* 调用时机:写路径(add/update/remove/clear/setCustomer)末尾自动触发;外部一般无需手动调。
|
|
1090
1145
|
*
|
|
@@ -1092,51 +1147,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1092
1147
|
* - 不调用任何公开 CRUD API(如 removeProductFromOrder),全部内部 mutate tempOrder.products,避免事件风暴;
|
|
1093
1148
|
* - 用 `isApplyingPromotion` 防递归;
|
|
1094
1149
|
* - 多选项赠品依赖 giftSelectResolver,未注入则跳过且 console.warn;
|
|
1095
|
-
* - 不主动调用 applyDiscount / recalculateSummary
|
|
1150
|
+
* - 不主动调用 applyDiscount / recalculateSummary,调用方负责跟进;
|
|
1151
|
+
* - 返回的 payload 只能在 applyDiscount(商品写路径还需 summary/persist)完成后发布。
|
|
1096
1152
|
*/
|
|
1097
1153
|
}, {
|
|
1098
|
-
key: "
|
|
1154
|
+
key: "evaluatePromotion",
|
|
1099
1155
|
value: (function () {
|
|
1100
|
-
var
|
|
1156
|
+
var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
1101
1157
|
var _this$promotionEvalua,
|
|
1102
1158
|
_this$promotionEvalua2,
|
|
1103
|
-
|
|
1159
|
+
_this4 = this;
|
|
1104
1160
|
var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
|
|
1105
1161
|
return _regeneratorRuntime().wrap(function _callee7$(_context9) {
|
|
1106
1162
|
while (1) switch (_context9.prev = _context9.next) {
|
|
1107
1163
|
case 0:
|
|
1108
|
-
if (!this.isApplyingPromotion) {
|
|
1164
|
+
if (!(this.isApplyingPromotion || this.isEmittingPromotionApplied)) {
|
|
1109
1165
|
_context9.next = 2;
|
|
1110
1166
|
break;
|
|
1111
1167
|
}
|
|
1112
|
-
return _context9.abrupt("return");
|
|
1168
|
+
return _context9.abrupt("return", null);
|
|
1113
1169
|
case 2:
|
|
1114
1170
|
if (this.promotionEvaluator) {
|
|
1115
1171
|
_context9.next = 4;
|
|
1116
1172
|
break;
|
|
1117
1173
|
}
|
|
1118
|
-
return _context9.abrupt("return");
|
|
1174
|
+
return _context9.abrupt("return", null);
|
|
1119
1175
|
case 4:
|
|
1120
1176
|
tempOrder = this.store.tempOrder;
|
|
1121
1177
|
if (tempOrder) {
|
|
1122
1178
|
_context9.next = 7;
|
|
1123
1179
|
break;
|
|
1124
1180
|
}
|
|
1125
|
-
return _context9.abrupt("return");
|
|
1181
|
+
return _context9.abrupt("return", null);
|
|
1126
1182
|
case 7:
|
|
1127
1183
|
if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
1128
1184
|
_context9.next = 10;
|
|
1129
1185
|
break;
|
|
1130
1186
|
}
|
|
1131
1187
|
tempOrder.products = normalizeVirtualSettlementProducts(tempOrder.products);
|
|
1132
|
-
return _context9.abrupt("return");
|
|
1188
|
+
return _context9.abrupt("return", null);
|
|
1133
1189
|
case 10:
|
|
1134
1190
|
strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
|
|
1135
1191
|
if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
|
|
1136
1192
|
_context9.next = 13;
|
|
1137
1193
|
break;
|
|
1138
1194
|
}
|
|
1139
|
-
return _context9.abrupt("return");
|
|
1195
|
+
return _context9.abrupt("return", null);
|
|
1140
1196
|
case 13:
|
|
1141
1197
|
this.isApplyingPromotion = true;
|
|
1142
1198
|
_context9.prev = 14;
|
|
@@ -1259,7 +1315,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1259
1315
|
case 6:
|
|
1260
1316
|
_context7.prev = 6;
|
|
1261
1317
|
_context7.next = 9;
|
|
1262
|
-
return
|
|
1318
|
+
return _this4.giftSelectResolver({
|
|
1263
1319
|
strategyId: addAction.strategyId,
|
|
1264
1320
|
strategyName: addAction.strategyName,
|
|
1265
1321
|
giftCount: addAction.giftCount,
|
|
@@ -1294,7 +1350,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1294
1350
|
_context7.next = 26;
|
|
1295
1351
|
break;
|
|
1296
1352
|
}
|
|
1297
|
-
linked =
|
|
1353
|
+
linked = _this4.createLinkedProductAndBooking({
|
|
1298
1354
|
product: gp,
|
|
1299
1355
|
booking: booking
|
|
1300
1356
|
});
|
|
@@ -1376,22 +1432,84 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1376
1432
|
}),
|
|
1377
1433
|
products: tempOrder.products
|
|
1378
1434
|
};
|
|
1379
|
-
|
|
1380
|
-
_context9.next = 81;
|
|
1381
|
-
break;
|
|
1435
|
+
return _context9.abrupt("return", payload);
|
|
1382
1436
|
case 78:
|
|
1383
1437
|
_context9.prev = 78;
|
|
1384
1438
|
_context9.t5 = _context9["catch"](14);
|
|
1385
1439
|
console.error('[OrderModule] applyPromotion failed', _context9.t5);
|
|
1386
|
-
|
|
1387
|
-
|
|
1440
|
+
return _context9.abrupt("return", null);
|
|
1441
|
+
case 82:
|
|
1442
|
+
_context9.prev = 82;
|
|
1388
1443
|
this.isApplyingPromotion = false;
|
|
1389
|
-
return _context9.finish(
|
|
1390
|
-
case
|
|
1444
|
+
return _context9.finish(82);
|
|
1445
|
+
case 85:
|
|
1391
1446
|
case "end":
|
|
1392
1447
|
return _context9.stop();
|
|
1393
1448
|
}
|
|
1394
|
-
}, _callee7, this, [[14, 78,
|
|
1449
|
+
}, _callee7, this, [[14, 78, 82, 85], [18, 42, 45, 48], [23, 32, 35, 38], [54, 65, 68, 71]]);
|
|
1450
|
+
}));
|
|
1451
|
+
function evaluatePromotion() {
|
|
1452
|
+
return _evaluatePromotion.apply(this, arguments);
|
|
1453
|
+
}
|
|
1454
|
+
return evaluatePromotion;
|
|
1455
|
+
}() /** 发布促销稳定态;products 必须读取折扣计算后的当前数组。 */)
|
|
1456
|
+
}, {
|
|
1457
|
+
key: "emitPromotionApplied",
|
|
1458
|
+
value: function emitPromotionApplied(payload) {
|
|
1459
|
+
var _this$store$tempOrder3;
|
|
1460
|
+
if (!payload) return;
|
|
1461
|
+
var products = ((_this$store$tempOrder3 = this.store.tempOrder) === null || _this$store$tempOrder3 === void 0 ? void 0 : _this$store$tempOrder3.products) || payload.products;
|
|
1462
|
+
this.isEmittingPromotionApplied = true;
|
|
1463
|
+
try {
|
|
1464
|
+
void this.effectsEmit('onPromotionApplied', _objectSpread(_objectSpread({}, payload), {}, {
|
|
1465
|
+
products: products
|
|
1466
|
+
}));
|
|
1467
|
+
} finally {
|
|
1468
|
+
// effectsEmit 同步调用监听器后返回 Promise;保持既有的非阻塞事件行为。
|
|
1469
|
+
this.isEmittingPromotionApplied = false;
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
/** 公开入口:促销、折扣、summary 与持久化完成后发布稳定态事件。 */
|
|
1474
|
+
}, {
|
|
1475
|
+
key: "applyPromotion",
|
|
1476
|
+
value: (function () {
|
|
1477
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
1478
|
+
var payload, tempOrder;
|
|
1479
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context10) {
|
|
1480
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1481
|
+
case 0:
|
|
1482
|
+
_context10.next = 2;
|
|
1483
|
+
return this.evaluatePromotion();
|
|
1484
|
+
case 2:
|
|
1485
|
+
payload = _context10.sent;
|
|
1486
|
+
if (payload) {
|
|
1487
|
+
_context10.next = 5;
|
|
1488
|
+
break;
|
|
1489
|
+
}
|
|
1490
|
+
return _context10.abrupt("return");
|
|
1491
|
+
case 5:
|
|
1492
|
+
tempOrder = this.store.tempOrder;
|
|
1493
|
+
if (tempOrder) {
|
|
1494
|
+
_context10.next = 8;
|
|
1495
|
+
break;
|
|
1496
|
+
}
|
|
1497
|
+
return _context10.abrupt("return");
|
|
1498
|
+
case 8:
|
|
1499
|
+
this.applyDiscount();
|
|
1500
|
+
this.sanitizeTempOrderProducts(tempOrder);
|
|
1501
|
+
_context10.next = 12;
|
|
1502
|
+
return this.recalculateSummary({
|
|
1503
|
+
createIfMissing: true
|
|
1504
|
+
});
|
|
1505
|
+
case 12:
|
|
1506
|
+
this.persistTempOrder();
|
|
1507
|
+
this.emitPromotionApplied(payload);
|
|
1508
|
+
case 14:
|
|
1509
|
+
case "end":
|
|
1510
|
+
return _context10.stop();
|
|
1511
|
+
}
|
|
1512
|
+
}, _callee8, this);
|
|
1395
1513
|
}));
|
|
1396
1514
|
function applyPromotion() {
|
|
1397
1515
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -1517,6 +1635,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1517
1635
|
if (!this.store.tempOrder) return;
|
|
1518
1636
|
this.store.tempOrder = _objectSpread(_objectSpread({}, this.store.tempOrder), {}, {
|
|
1519
1637
|
products: _toConsumableArray(this.store.tempOrder.products),
|
|
1638
|
+
notes: _toConsumableArray(this.store.tempOrder.notes || []),
|
|
1520
1639
|
bookings: this.store.tempOrder.bookings ? _toConsumableArray(this.store.tempOrder.bookings) : []
|
|
1521
1640
|
});
|
|
1522
1641
|
this.persistTempOrder();
|
|
@@ -1531,12 +1650,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1531
1650
|
});
|
|
1532
1651
|
}
|
|
1533
1652
|
}, {
|
|
1534
|
-
key: "
|
|
1535
|
-
value: function
|
|
1653
|
+
key: "clearTempOrderCustomerWalletSnapshots",
|
|
1654
|
+
value: function clearTempOrderCustomerWalletSnapshots(tempOrder) {
|
|
1536
1655
|
var orderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
|
|
1537
1656
|
if (!orderMetaList) return;
|
|
1538
1657
|
var nextOrderMetaList = _objectSpread({}, orderMetaList);
|
|
1539
1658
|
delete nextOrderMetaList.point_cards_snapshot;
|
|
1659
|
+
delete nextOrderMetaList.virtual_currency_snapshot;
|
|
1540
1660
|
if (Object.keys(nextOrderMetaList).length === 0) {
|
|
1541
1661
|
delete tempOrder.order_meta_list;
|
|
1542
1662
|
return;
|
|
@@ -1544,15 +1664,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1544
1664
|
tempOrder.order_meta_list = nextOrderMetaList;
|
|
1545
1665
|
}
|
|
1546
1666
|
}, {
|
|
1547
|
-
key: "
|
|
1548
|
-
value: function
|
|
1667
|
+
key: "clearCustomerWalletState",
|
|
1668
|
+
value: function clearCustomerWalletState(tempOrder) {
|
|
1669
|
+
this.clearCustomerWalletRuntimeState();
|
|
1670
|
+
this.clearTempOrderCustomerWalletSnapshots(tempOrder);
|
|
1671
|
+
}
|
|
1672
|
+
}, {
|
|
1673
|
+
key: "clearCustomerWalletRuntimeState",
|
|
1674
|
+
value: function clearCustomerWalletRuntimeState() {
|
|
1675
|
+
this.customerWalletPrepareConfigEpoch += 1;
|
|
1676
|
+
this.store.availableWalletIds = [];
|
|
1677
|
+
this.store.virtualCurrencyList = [];
|
|
1678
|
+
}
|
|
1679
|
+
}, {
|
|
1680
|
+
key: "writeCustomerWalletSnapshotsFromPrepareConfig",
|
|
1681
|
+
value: function writeCustomerWalletSnapshotsFromPrepareConfig(params) {
|
|
1549
1682
|
var _tempOrder$customer_i;
|
|
1550
1683
|
var tempOrder = this.store.tempOrder;
|
|
1551
1684
|
if (!tempOrder) return;
|
|
1552
1685
|
if (String((_tempOrder$customer_i = tempOrder.customer_id) !== null && _tempOrder$customer_i !== void 0 ? _tempOrder$customer_i : '') !== String(params.customerId)) return;
|
|
1686
|
+
var virtualCurrencyList = Array.isArray(params.virtualCurrencyList) ? params.virtualCurrencyList : [];
|
|
1553
1687
|
tempOrder.order_meta_list = _objectSpread(_objectSpread({}, normalizeOrderMetaList(tempOrder.order_meta_list) || {}), {}, {
|
|
1554
|
-
point_cards_snapshot: buildPointCardSnapshotFromWalletPassList(params.availableWalletPassList)
|
|
1688
|
+
point_cards_snapshot: buildPointCardSnapshotFromWalletPassList(params.availableWalletPassList),
|
|
1689
|
+
virtual_currency_snapshot: buildVirtualCurrencySnapshotFromList(virtualCurrencyList)
|
|
1555
1690
|
});
|
|
1691
|
+
this.store.availableWalletIds = _toConsumableArray(params.availableWalletIds);
|
|
1692
|
+
this.store.virtualCurrencyList = cloneDeep(virtualCurrencyList);
|
|
1556
1693
|
this.persistTempOrder();
|
|
1557
1694
|
this.saveDraftInBackground();
|
|
1558
1695
|
}
|
|
@@ -1615,14 +1752,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1615
1752
|
}, {
|
|
1616
1753
|
key: "saveDraft",
|
|
1617
1754
|
value: function () {
|
|
1618
|
-
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1619
|
-
return _regeneratorRuntime().wrap(function
|
|
1620
|
-
while (1) switch (
|
|
1755
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
1756
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context11) {
|
|
1757
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1621
1758
|
case 0:
|
|
1622
1759
|
case "end":
|
|
1623
|
-
return
|
|
1760
|
+
return _context11.stop();
|
|
1624
1761
|
}
|
|
1625
|
-
},
|
|
1762
|
+
}, _callee9);
|
|
1626
1763
|
}));
|
|
1627
1764
|
function saveDraft() {
|
|
1628
1765
|
return _saveDraft.apply(this, arguments);
|
|
@@ -1637,16 +1774,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1637
1774
|
}, {
|
|
1638
1775
|
key: "hydrateTempOrderFromLocalRecord",
|
|
1639
1776
|
value: function () {
|
|
1640
|
-
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1641
|
-
return _regeneratorRuntime().wrap(function
|
|
1642
|
-
while (1) switch (
|
|
1777
|
+
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(record) {
|
|
1778
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context12) {
|
|
1779
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1643
1780
|
case 0:
|
|
1644
|
-
return
|
|
1781
|
+
return _context12.abrupt("return", this.hydrateTempOrderFromRecord(record));
|
|
1645
1782
|
case 1:
|
|
1646
1783
|
case "end":
|
|
1647
|
-
return
|
|
1784
|
+
return _context12.stop();
|
|
1648
1785
|
}
|
|
1649
|
-
},
|
|
1786
|
+
}, _callee10, this);
|
|
1650
1787
|
}));
|
|
1651
1788
|
function hydrateTempOrderFromLocalRecord(_x8) {
|
|
1652
1789
|
return _hydrateTempOrderFromLocalRecord.apply(this, arguments);
|
|
@@ -1656,15 +1793,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1656
1793
|
}, {
|
|
1657
1794
|
key: "extractOrderIdFromSubmitResult",
|
|
1658
1795
|
value: function extractOrderIdFromSubmitResult(result) {
|
|
1659
|
-
var
|
|
1660
|
-
return (
|
|
1796
|
+
var _ref18, _ref19, _ref20, _result$data$order_id, _result$data, _result$data2;
|
|
1797
|
+
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;
|
|
1661
1798
|
}
|
|
1662
1799
|
}, {
|
|
1663
1800
|
key: "calculatePaymentEffectiveAmount",
|
|
1664
1801
|
value: function calculatePaymentEffectiveAmount(payment) {
|
|
1665
|
-
var
|
|
1802
|
+
var _ref21, _payment$origin_amoun;
|
|
1666
1803
|
var amount = new Decimal(payment.amount || 0);
|
|
1667
|
-
var originAmount = new Decimal((
|
|
1804
|
+
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);
|
|
1668
1805
|
var serviceFee = new Decimal(payment.service_fee || 0);
|
|
1669
1806
|
// TODO: 后端允许 amount 表示顾客实际支付总额后,移除这个兼容分支。
|
|
1670
1807
|
var effectiveAmount = serviceFee.gt(0) && amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
|
|
@@ -1674,23 +1811,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1674
1811
|
}, {
|
|
1675
1812
|
key: "calculatePaymentTotal",
|
|
1676
1813
|
value: function calculatePaymentTotal(payments) {
|
|
1677
|
-
var
|
|
1814
|
+
var _this5 = this;
|
|
1678
1815
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1679
1816
|
includeVoided: false
|
|
1680
1817
|
}).reduce(function (sum, payment) {
|
|
1681
1818
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1682
|
-
return sum.plus(
|
|
1819
|
+
return sum.plus(_this5.calculatePaymentEffectiveAmount(payment));
|
|
1683
1820
|
}, new Decimal(0));
|
|
1684
1821
|
}
|
|
1685
1822
|
}, {
|
|
1686
1823
|
key: "calculateOrderPaidPaymentTotal",
|
|
1687
1824
|
value: function calculateOrderPaidPaymentTotal(payments) {
|
|
1688
|
-
var
|
|
1825
|
+
var _this6 = this;
|
|
1689
1826
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1690
1827
|
includeVoided: false
|
|
1691
1828
|
}).reduce(function (sum, payment) {
|
|
1692
1829
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1693
|
-
return sum.plus(
|
|
1830
|
+
return sum.plus(_this6.calculatePaymentGapAmount(payment));
|
|
1694
1831
|
}, new Decimal(0));
|
|
1695
1832
|
}
|
|
1696
1833
|
}, {
|
|
@@ -1826,13 +1963,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1826
1963
|
}, {
|
|
1827
1964
|
key: "calculateDepositPaidAmount",
|
|
1828
1965
|
value: function calculateDepositPaidAmount(payments) {
|
|
1829
|
-
var
|
|
1966
|
+
var _this7 = this;
|
|
1830
1967
|
return (payments || []).reduce(function (sum, payment) {
|
|
1831
1968
|
var paymentRecord = payment;
|
|
1832
1969
|
if (!isPaidPaymentRecord(paymentRecord)) return sum;
|
|
1833
1970
|
var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
|
|
1834
1971
|
if (!isDepositPayment) return sum;
|
|
1835
|
-
return sum.plus(
|
|
1972
|
+
return sum.plus(_this7.calculatePaymentGapAmount(paymentRecord));
|
|
1836
1973
|
}, new Decimal(0));
|
|
1837
1974
|
}
|
|
1838
1975
|
}, {
|
|
@@ -1869,28 +2006,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1869
2006
|
}, {
|
|
1870
2007
|
key: "getPaymentNumberDevicePrefixSync",
|
|
1871
2008
|
value: function getPaymentNumberDevicePrefixSync() {
|
|
1872
|
-
var
|
|
2009
|
+
var _this8 = this;
|
|
1873
2010
|
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
1874
|
-
return
|
|
2011
|
+
return _this8.getPaymentNumberAppData(key);
|
|
1875
2012
|
});
|
|
1876
2013
|
}
|
|
1877
2014
|
}, {
|
|
1878
2015
|
key: "getPaymentNumberDevicePrefixAsync",
|
|
1879
2016
|
value: function getPaymentNumberDevicePrefixAsync() {
|
|
1880
|
-
var
|
|
2017
|
+
var _this9 = this;
|
|
1881
2018
|
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
1882
|
-
return
|
|
2019
|
+
return _this9.getPaymentNumberAppData(key);
|
|
1883
2020
|
});
|
|
1884
2021
|
}
|
|
1885
2022
|
}, {
|
|
1886
2023
|
key: "normalizePaymentSource",
|
|
1887
2024
|
value: function normalizePaymentSource(payment, options) {
|
|
1888
|
-
var
|
|
2025
|
+
var _ref22, _paymentRecord$origin;
|
|
1889
2026
|
var paymentRecord = payment;
|
|
1890
2027
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
1891
2028
|
var normalized = ensureOrderPaymentNumber(_objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
1892
2029
|
metadata: metadata,
|
|
1893
|
-
origin_amount: (
|
|
2030
|
+
origin_amount: (_ref22 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref22 !== void 0 ? _ref22 : '0.00'
|
|
1894
2031
|
}), (options === null || options === void 0 ? void 0 : options.devicePrefix) || this.getPaymentNumberDevicePrefixSync(), createUuidV4);
|
|
1895
2032
|
if (paymentRecord.status !== undefined) {
|
|
1896
2033
|
normalized.status = paymentRecord.status;
|
|
@@ -2009,16 +2146,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2009
2146
|
}, {
|
|
2010
2147
|
key: "calculatePaidPaymentSummary",
|
|
2011
2148
|
value: function calculatePaidPaymentSummary(payments) {
|
|
2012
|
-
var
|
|
2149
|
+
var _this10 = this;
|
|
2013
2150
|
return (payments || []).reduce(function (summary, payment) {
|
|
2014
2151
|
var paymentRecord = payment;
|
|
2015
2152
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
2016
2153
|
return {
|
|
2017
2154
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
2018
|
-
orderPaidAmount: summary.orderPaidAmount.plus(
|
|
2019
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
2020
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
2021
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
2155
|
+
orderPaidAmount: summary.orderPaidAmount.plus(_this10.calculatePaymentOrderAmount(paymentRecord)),
|
|
2156
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this10.calculatePaymentGapAmount(paymentRecord)),
|
|
2157
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this10.calculatePaymentServiceFee(paymentRecord)),
|
|
2158
|
+
roundingAmount: summary.roundingAmount.plus(_this10.calculatePaymentRoundingAmount(paymentRecord))
|
|
2022
2159
|
};
|
|
2023
2160
|
}, {
|
|
2024
2161
|
customerPaidAmount: new Decimal(0),
|
|
@@ -2225,15 +2362,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2225
2362
|
}, {
|
|
2226
2363
|
key: "normalizeFingerprintValue",
|
|
2227
2364
|
value: function normalizeFingerprintValue(value) {
|
|
2228
|
-
var
|
|
2365
|
+
var _this11 = this;
|
|
2229
2366
|
if (Array.isArray(value)) {
|
|
2230
2367
|
return value.map(function (item) {
|
|
2231
|
-
return
|
|
2368
|
+
return _this11.normalizeFingerprintValue(item);
|
|
2232
2369
|
});
|
|
2233
2370
|
}
|
|
2234
2371
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
2235
2372
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
2236
|
-
result[key] =
|
|
2373
|
+
result[key] = _this11.normalizeFingerprintValue(value[key]);
|
|
2237
2374
|
return result;
|
|
2238
2375
|
}, {});
|
|
2239
2376
|
}
|
|
@@ -2246,9 +2383,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2246
2383
|
_product$payment_pric,
|
|
2247
2384
|
_sku$code,
|
|
2248
2385
|
_sku$barcode,
|
|
2249
|
-
|
|
2386
|
+
_ref23,
|
|
2250
2387
|
_sku$variant_id,
|
|
2251
|
-
|
|
2388
|
+
_this12 = this;
|
|
2252
2389
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2253
2390
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2254
2391
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2276,37 +2413,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2276
2413
|
product_sku: this.normalizeFingerprintValue({
|
|
2277
2414
|
code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
|
|
2278
2415
|
barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
|
|
2279
|
-
variant_id: (
|
|
2416
|
+
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,
|
|
2280
2417
|
variant: sku.variant || [],
|
|
2281
2418
|
option: getProductSkuOptions(product || {}).map(function (option) {
|
|
2282
|
-
var
|
|
2419
|
+
var _ref24, _option$id, _option$option_group_, _ref25, _option$option_group_2, _option$num, _option$add_price;
|
|
2283
2420
|
return {
|
|
2284
|
-
id: (
|
|
2421
|
+
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,
|
|
2285
2422
|
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,
|
|
2286
|
-
option_group_item_id: (
|
|
2423
|
+
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,
|
|
2287
2424
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
2288
|
-
add_price:
|
|
2425
|
+
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)
|
|
2289
2426
|
};
|
|
2290
2427
|
})
|
|
2291
2428
|
}),
|
|
2292
2429
|
product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
|
|
2293
|
-
var
|
|
2430
|
+
var _ref26, _ref27, _bundle$bundle_produc, _ref28, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
|
|
2294
2431
|
return {
|
|
2295
|
-
bundle_product_id: (
|
|
2296
|
-
bundle_variant_id: (
|
|
2432
|
+
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,
|
|
2433
|
+
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,
|
|
2297
2434
|
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),
|
|
2298
|
-
price:
|
|
2299
|
-
bundle_selling_price:
|
|
2435
|
+
price: _this12.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
2436
|
+
bundle_selling_price: _this12.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
2300
2437
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
2301
2438
|
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 : ''
|
|
2302
2439
|
};
|
|
2303
2440
|
})),
|
|
2304
2441
|
discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
2305
|
-
var
|
|
2442
|
+
var _ref29, _discount$type2, _ref30, _ref31, _discount$discount_id, _discount$discount;
|
|
2306
2443
|
return {
|
|
2307
|
-
type: (
|
|
2308
|
-
discount_id: (
|
|
2309
|
-
amount:
|
|
2444
|
+
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 : '',
|
|
2445
|
+
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,
|
|
2446
|
+
amount: _this12.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2310
2447
|
};
|
|
2311
2448
|
}))
|
|
2312
2449
|
};
|
|
@@ -2314,9 +2451,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2314
2451
|
}, {
|
|
2315
2452
|
key: "buildOrderProductsFingerprint",
|
|
2316
2453
|
value: function buildOrderProductsFingerprint(products) {
|
|
2317
|
-
var
|
|
2454
|
+
var _this13 = this;
|
|
2318
2455
|
var items = (products || []).map(function (product) {
|
|
2319
|
-
return
|
|
2456
|
+
return _this13.buildProductFingerprintItem(product);
|
|
2320
2457
|
});
|
|
2321
2458
|
items.sort(function (left, right) {
|
|
2322
2459
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2329,16 +2466,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2329
2466
|
var _product$product_id3,
|
|
2330
2467
|
_product$product_vari2,
|
|
2331
2468
|
_product$num2,
|
|
2332
|
-
|
|
2469
|
+
_ref32,
|
|
2333
2470
|
_metadata$unique_iden,
|
|
2334
2471
|
_metadata$price_overr,
|
|
2335
2472
|
_metadata$is_manual_d,
|
|
2336
2473
|
_metadata$product_dis,
|
|
2337
2474
|
_sku$code2,
|
|
2338
2475
|
_sku$barcode2,
|
|
2339
|
-
|
|
2476
|
+
_ref33,
|
|
2340
2477
|
_sku$variant_id2,
|
|
2341
|
-
|
|
2478
|
+
_this14 = this;
|
|
2342
2479
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2343
2480
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2344
2481
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2355,7 +2492,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2355
2492
|
extension_type: extensionType,
|
|
2356
2493
|
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),
|
|
2357
2494
|
metadata: {
|
|
2358
|
-
unique_identification_number: (
|
|
2495
|
+
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 : '',
|
|
2359
2496
|
price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
|
|
2360
2497
|
is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
|
|
2361
2498
|
product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
|
|
@@ -2363,47 +2500,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2363
2500
|
product_sku: this.normalizeFingerprintValue({
|
|
2364
2501
|
code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
|
|
2365
2502
|
barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
|
|
2366
|
-
variant_id: (
|
|
2503
|
+
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,
|
|
2367
2504
|
variant: sku.variant || [],
|
|
2368
2505
|
option: getProductSkuOptions(product || {}).map(function (option) {
|
|
2369
|
-
var
|
|
2506
|
+
var _ref34, _option$id2, _option$option_group_3, _ref35, _option$option_group_4, _option$num2, _option$add_price2;
|
|
2370
2507
|
return {
|
|
2371
|
-
id: (
|
|
2508
|
+
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,
|
|
2372
2509
|
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,
|
|
2373
|
-
option_group_item_id: (
|
|
2510
|
+
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,
|
|
2374
2511
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
2375
|
-
add_price:
|
|
2512
|
+
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)
|
|
2376
2513
|
};
|
|
2377
2514
|
})
|
|
2378
2515
|
}),
|
|
2379
2516
|
product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
|
|
2380
|
-
var
|
|
2517
|
+
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;
|
|
2381
2518
|
return {
|
|
2382
|
-
bundle_id: (
|
|
2383
|
-
bundle_group_id: (
|
|
2384
|
-
bundle_product_id: (
|
|
2385
|
-
bundle_variant_id: (
|
|
2519
|
+
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,
|
|
2520
|
+
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,
|
|
2521
|
+
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,
|
|
2522
|
+
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,
|
|
2386
2523
|
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),
|
|
2387
2524
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
2388
2525
|
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 : '',
|
|
2389
|
-
option:
|
|
2390
|
-
var
|
|
2526
|
+
option: _this14.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2527
|
+
var _ref41, _option$id3, _option$option_group_5, _ref42, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2391
2528
|
return {
|
|
2392
|
-
id: (
|
|
2529
|
+
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,
|
|
2393
2530
|
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,
|
|
2394
|
-
option_group_item_id: (
|
|
2531
|
+
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,
|
|
2395
2532
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
2396
|
-
add_price:
|
|
2533
|
+
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)
|
|
2397
2534
|
};
|
|
2398
2535
|
}))
|
|
2399
2536
|
};
|
|
2400
2537
|
})),
|
|
2401
2538
|
discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
2402
|
-
var
|
|
2539
|
+
var _ref43, _discount$type4, _ref44, _ref45, _discount$discount_id2, _discount$discount2;
|
|
2403
2540
|
return {
|
|
2404
|
-
type: (
|
|
2405
|
-
discount_id: (
|
|
2406
|
-
amount:
|
|
2541
|
+
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 : '',
|
|
2542
|
+
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,
|
|
2543
|
+
amount: _this14.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2407
2544
|
};
|
|
2408
2545
|
}))
|
|
2409
2546
|
};
|
|
@@ -2411,9 +2548,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2411
2548
|
}, {
|
|
2412
2549
|
key: "buildOrderProductsStructuralFingerprint",
|
|
2413
2550
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
2414
|
-
var
|
|
2551
|
+
var _this15 = this;
|
|
2415
2552
|
var items = (products || []).map(function (product) {
|
|
2416
|
-
return
|
|
2553
|
+
return _this15.buildProductStructuralFingerprintItem(product);
|
|
2417
2554
|
});
|
|
2418
2555
|
items.sort(function (left, right) {
|
|
2419
2556
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2423,8 +2560,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2423
2560
|
}, {
|
|
2424
2561
|
key: "getManualDepositOverride",
|
|
2425
2562
|
value: function getManualDepositOverride(tempOrder) {
|
|
2426
|
-
var _tempOrder$
|
|
2427
|
-
var override = (_tempOrder$
|
|
2563
|
+
var _tempOrder$_extend4;
|
|
2564
|
+
var override = (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.manualDepositOverride;
|
|
2428
2565
|
if (!override || _typeof(override) !== 'object') return null;
|
|
2429
2566
|
if (typeof override.amount !== 'string') return null;
|
|
2430
2567
|
if (typeof override.productStructuralFingerprint !== 'string') return null;
|
|
@@ -2443,16 +2580,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2443
2580
|
}, {
|
|
2444
2581
|
key: "clearManualDepositOverride",
|
|
2445
2582
|
value: function clearManualDepositOverride(tempOrder) {
|
|
2446
|
-
var _tempOrder$
|
|
2447
|
-
if (!((_tempOrder$
|
|
2583
|
+
var _tempOrder$_extend5;
|
|
2584
|
+
if (!((_tempOrder$_extend5 = tempOrder._extend) !== null && _tempOrder$_extend5 !== void 0 && _tempOrder$_extend5.manualDepositOverride)) return;
|
|
2448
2585
|
tempOrder._extend = _objectSpread({}, tempOrder._extend);
|
|
2449
2586
|
delete tempOrder._extend.manualDepositOverride;
|
|
2450
2587
|
}
|
|
2451
2588
|
}, {
|
|
2452
2589
|
key: "getOriginalSalesSnapshot",
|
|
2453
2590
|
value: function getOriginalSalesSnapshot(tempOrder) {
|
|
2454
|
-
var _tempOrder$
|
|
2455
|
-
var snapshot = (_tempOrder$
|
|
2591
|
+
var _tempOrder$_extend6;
|
|
2592
|
+
var snapshot = (_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.originalSalesSnapshot;
|
|
2456
2593
|
if (!snapshot || _typeof(snapshot) !== 'object') return null;
|
|
2457
2594
|
if (typeof snapshot.productFingerprint !== 'string') return null;
|
|
2458
2595
|
return snapshot;
|
|
@@ -2656,6 +2793,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2656
2793
|
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
2657
2794
|
this.ensureExternalSaleNumber(freshTempOrder);
|
|
2658
2795
|
this.store.tempOrder = freshTempOrder;
|
|
2796
|
+
this.clearCustomerWalletRuntimeState();
|
|
2659
2797
|
this.store.summary = createEmptySummary();
|
|
2660
2798
|
this.store.lastOrderInfo = undefined;
|
|
2661
2799
|
this.store.syncState = undefined;
|
|
@@ -2672,13 +2810,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2672
2810
|
}, {
|
|
2673
2811
|
key: "replaceTempOrder",
|
|
2674
2812
|
value: function () {
|
|
2675
|
-
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2813
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(tempOrder, options) {
|
|
2676
2814
|
var nextTempOrder;
|
|
2677
|
-
return _regeneratorRuntime().wrap(function
|
|
2678
|
-
while (1) switch (
|
|
2815
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context13) {
|
|
2816
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
2679
2817
|
case 0:
|
|
2680
2818
|
if (isTempOrder(tempOrder)) {
|
|
2681
|
-
|
|
2819
|
+
_context13.next = 2;
|
|
2682
2820
|
break;
|
|
2683
2821
|
}
|
|
2684
2822
|
throw new Error('无效的 tempOrder 数据');
|
|
@@ -2688,36 +2826,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2688
2826
|
ensureIdentity: false
|
|
2689
2827
|
});
|
|
2690
2828
|
this.store.tempOrder = nextTempOrder;
|
|
2829
|
+
this.clearCustomerWalletRuntimeState();
|
|
2691
2830
|
if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
|
|
2692
|
-
|
|
2831
|
+
_context13.next = 11;
|
|
2693
2832
|
break;
|
|
2694
2833
|
}
|
|
2695
|
-
|
|
2834
|
+
_context13.next = 9;
|
|
2696
2835
|
return this.recalculateSummary({
|
|
2697
2836
|
createIfMissing: false
|
|
2698
2837
|
});
|
|
2699
|
-
case
|
|
2700
|
-
|
|
2838
|
+
case 9:
|
|
2839
|
+
_context13.next = 12;
|
|
2701
2840
|
break;
|
|
2702
|
-
case 10:
|
|
2703
|
-
this.store.summary = createEmptySummary();
|
|
2704
2841
|
case 11:
|
|
2842
|
+
this.store.summary = createEmptySummary();
|
|
2843
|
+
case 12:
|
|
2705
2844
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
2706
2845
|
this.persistTempOrder();
|
|
2707
2846
|
}
|
|
2708
2847
|
if (!(options !== null && options !== void 0 && options.saveDraft)) {
|
|
2709
|
-
|
|
2848
|
+
_context13.next = 16;
|
|
2710
2849
|
break;
|
|
2711
2850
|
}
|
|
2712
|
-
|
|
2851
|
+
_context13.next = 16;
|
|
2713
2852
|
return this.saveDraft();
|
|
2714
|
-
case 15:
|
|
2715
|
-
return _context12.abrupt("return", nextTempOrder);
|
|
2716
2853
|
case 16:
|
|
2854
|
+
return _context13.abrupt("return", nextTempOrder);
|
|
2855
|
+
case 17:
|
|
2717
2856
|
case "end":
|
|
2718
|
-
return
|
|
2857
|
+
return _context13.stop();
|
|
2719
2858
|
}
|
|
2720
|
-
},
|
|
2859
|
+
}, _callee11, this);
|
|
2721
2860
|
}));
|
|
2722
2861
|
function replaceTempOrder(_x9, _x10) {
|
|
2723
2862
|
return _replaceTempOrder.apply(this, arguments);
|
|
@@ -2727,13 +2866,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2727
2866
|
}, {
|
|
2728
2867
|
key: "getOrderIdentity",
|
|
2729
2868
|
value: function getOrderIdentity() {
|
|
2730
|
-
var
|
|
2869
|
+
var _ref46, _ref47, _tempOrder$order_id, _tempOrder$_extend7;
|
|
2731
2870
|
var tempOrder = this.store.tempOrder;
|
|
2732
2871
|
if (!tempOrder) return null;
|
|
2733
2872
|
var lastOrderInfo = this.store.lastOrderInfo || {};
|
|
2734
|
-
var orderId = (
|
|
2873
|
+
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;
|
|
2735
2874
|
return {
|
|
2736
|
-
localId: this.cacheId || ((_tempOrder$
|
|
2875
|
+
localId: this.cacheId || ((_tempOrder$_extend7 = tempOrder._extend) === null || _tempOrder$_extend7 === void 0 ? void 0 : _tempOrder$_extend7.localId),
|
|
2737
2876
|
orderId: orderId,
|
|
2738
2877
|
externalSaleNumber: tempOrder.external_sale_number || lastOrderInfo.external_sale_number || '',
|
|
2739
2878
|
orderNumber: tempOrder.order_number || lastOrderInfo.order_number || '',
|
|
@@ -2805,32 +2944,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2805
2944
|
}, {
|
|
2806
2945
|
key: "addNewOrder",
|
|
2807
2946
|
value: function () {
|
|
2808
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2947
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
2809
2948
|
var tempOrder;
|
|
2810
|
-
return _regeneratorRuntime().wrap(function
|
|
2811
|
-
while (1) switch (
|
|
2949
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context14) {
|
|
2950
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
2812
2951
|
case 0:
|
|
2813
2952
|
tempOrder = this.ensureTempOrder();
|
|
2814
2953
|
this.ensureExternalSaleNumber(tempOrder);
|
|
2815
|
-
|
|
2954
|
+
_context14.next = 4;
|
|
2816
2955
|
return this.recalculateSummary({
|
|
2817
2956
|
createIfMissing: true
|
|
2818
2957
|
});
|
|
2819
2958
|
case 4:
|
|
2820
2959
|
this.persistTempOrder();
|
|
2821
2960
|
if (!this.draftPersistEnabled) {
|
|
2822
|
-
|
|
2961
|
+
_context14.next = 8;
|
|
2823
2962
|
break;
|
|
2824
2963
|
}
|
|
2825
|
-
|
|
2964
|
+
_context14.next = 8;
|
|
2826
2965
|
return this.saveDraft();
|
|
2827
2966
|
case 8:
|
|
2828
|
-
return
|
|
2967
|
+
return _context14.abrupt("return", tempOrder);
|
|
2829
2968
|
case 9:
|
|
2830
2969
|
case "end":
|
|
2831
|
-
return
|
|
2970
|
+
return _context14.stop();
|
|
2832
2971
|
}
|
|
2833
|
-
},
|
|
2972
|
+
}, _callee12, this);
|
|
2834
2973
|
}));
|
|
2835
2974
|
function addNewOrder() {
|
|
2836
2975
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -2863,9 +3002,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2863
3002
|
}, {
|
|
2864
3003
|
key: "sanitizeTempOrderProducts",
|
|
2865
3004
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
2866
|
-
var
|
|
3005
|
+
var _this16 = this;
|
|
2867
3006
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2868
|
-
return
|
|
3007
|
+
return _this16.sanitizeOrderProductForTempOrder(_this16.normalizeVirtualSettlementProductIfEnabled(product));
|
|
2869
3008
|
});
|
|
2870
3009
|
this.syncTempOrderSettlementState(tempOrder);
|
|
2871
3010
|
ensureUniqueProductLineUids(tempOrder);
|
|
@@ -2886,8 +3025,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2886
3025
|
}, {
|
|
2887
3026
|
key: "repairDuplicateProductLineIdentities",
|
|
2888
3027
|
value: function repairDuplicateProductLineIdentities(tempOrder) {
|
|
2889
|
-
var _tempOrder$
|
|
2890
|
-
var result = repairDuplicateOrderProductLineIdentities(tempOrder.products, (_tempOrder$
|
|
3028
|
+
var _tempOrder$_extend8;
|
|
3029
|
+
var result = repairDuplicateOrderProductLineIdentities(tempOrder.products, (_tempOrder$_extend8 = tempOrder._extend) === null || _tempOrder$_extend8 === void 0 ? void 0 : _tempOrder$_extend8.productsByUid);
|
|
2891
3030
|
if (!result.repairs.length) return;
|
|
2892
3031
|
tempOrder.products = result.products;
|
|
2893
3032
|
if (result.productsByUid) {
|
|
@@ -2901,11 +3040,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2901
3040
|
}, {
|
|
2902
3041
|
key: "captureProductRuntime",
|
|
2903
3042
|
value: function captureProductRuntime(tempOrder, rawProduct, normalizedProduct, existedUid) {
|
|
2904
|
-
var _extend$productsByUid,
|
|
3043
|
+
var _extend$productsByUid, _ref48, _rawProduct$_origin;
|
|
2905
3044
|
var uid = existedUid || this.getProductUid(normalizedProduct);
|
|
2906
3045
|
var extend = this.ensureExtend(tempOrder);
|
|
2907
3046
|
var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
|
|
2908
|
-
var origin = (
|
|
3047
|
+
var origin = (_ref48 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref48 !== void 0 ? _ref48 : existed.origin;
|
|
2909
3048
|
extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
|
|
2910
3049
|
origin: origin
|
|
2911
3050
|
} : {});
|
|
@@ -2985,7 +3124,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2985
3124
|
}, {
|
|
2986
3125
|
key: "syncLinkedBookingHoldersToProducts",
|
|
2987
3126
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
2988
|
-
var
|
|
3127
|
+
var _this17 = this;
|
|
2989
3128
|
var bookings = tempOrder.bookings || [];
|
|
2990
3129
|
var products = tempOrder.products || [];
|
|
2991
3130
|
if (!bookings.length || !products.length) return;
|
|
@@ -3010,7 +3149,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3010
3149
|
var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
|
|
3011
3150
|
var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
|
|
3012
3151
|
if (linkedBooking) {
|
|
3013
|
-
|
|
3152
|
+
_this17.setProductHolderFromBooking(product, linkedBooking);
|
|
3014
3153
|
}
|
|
3015
3154
|
});
|
|
3016
3155
|
}
|
|
@@ -3048,7 +3187,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3048
3187
|
}, {
|
|
3049
3188
|
key: "buildTempOrderHolderFromBookings",
|
|
3050
3189
|
value: function buildTempOrderHolderFromBookings(tempOrder) {
|
|
3051
|
-
var _baseHolder$customer_, _baseHolder,
|
|
3190
|
+
var _baseHolder$customer_, _baseHolder, _ref49, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams2;
|
|
3052
3191
|
var holderRecords = [];
|
|
3053
3192
|
var holderNames = [];
|
|
3054
3193
|
var baseHolder = null;
|
|
@@ -3095,7 +3234,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3095
3234
|
}
|
|
3096
3235
|
var nextHolder = {
|
|
3097
3236
|
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,
|
|
3098
|
-
form_id: (
|
|
3237
|
+
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,
|
|
3099
3238
|
form_record: holderRecords
|
|
3100
3239
|
};
|
|
3101
3240
|
if (holderNames.length) {
|
|
@@ -3138,9 +3277,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3138
3277
|
}, {
|
|
3139
3278
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
3140
3279
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
3141
|
-
var
|
|
3280
|
+
var _this18 = this;
|
|
3142
3281
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
3143
|
-
return
|
|
3282
|
+
return _this18.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
3144
3283
|
});
|
|
3145
3284
|
}
|
|
3146
3285
|
}, {
|
|
@@ -3148,12 +3287,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3148
3287
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
3149
3288
|
var _product$metadata5,
|
|
3150
3289
|
_product$metadata6,
|
|
3151
|
-
|
|
3290
|
+
_this19 = this;
|
|
3152
3291
|
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);
|
|
3153
3292
|
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);
|
|
3154
3293
|
if (!productUid && !bookingUid) return;
|
|
3155
3294
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
3156
|
-
var currentBookingUid =
|
|
3295
|
+
var currentBookingUid = _this19.getBookingUniqueIdentificationNumber(booking);
|
|
3157
3296
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
3158
3297
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
3159
3298
|
return true;
|
|
@@ -3170,9 +3309,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3170
3309
|
}, {
|
|
3171
3310
|
key: "applyOrderProductsDepositSummary",
|
|
3172
3311
|
value: function applyOrderProductsDepositSummary(tempOrder, summary) {
|
|
3173
|
-
var _tempOrder$
|
|
3312
|
+
var _tempOrder$_extend9;
|
|
3174
3313
|
var depositSummary = calculateOrderProductsDeposit(tempOrder.products || [], {
|
|
3175
|
-
productsByUid: (_tempOrder$
|
|
3314
|
+
productsByUid: (_tempOrder$_extend9 = tempOrder._extend) === null || _tempOrder$_extend9 === void 0 ? void 0 : _tempOrder$_extend9.productsByUid
|
|
3176
3315
|
});
|
|
3177
3316
|
var manualDepositOverride = this.getManualDepositOverride(tempOrder);
|
|
3178
3317
|
var currentStructuralFingerprint = manualDepositOverride ? this.buildOrderProductsStructuralFingerprint(tempOrder.products) : '';
|
|
@@ -3199,18 +3338,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3199
3338
|
}, {
|
|
3200
3339
|
key: "recalculateSummary",
|
|
3201
3340
|
value: function () {
|
|
3202
|
-
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3203
|
-
var _this$otherParams3,
|
|
3341
|
+
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(options) {
|
|
3342
|
+
var _this$otherParams3, _ref50, _salesSummaryResult$e;
|
|
3204
3343
|
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;
|
|
3205
|
-
return _regeneratorRuntime().wrap(function
|
|
3206
|
-
while (1) switch (
|
|
3344
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context15) {
|
|
3345
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
3207
3346
|
case 0:
|
|
3208
3347
|
tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
|
|
3209
3348
|
if (tempOrder) {
|
|
3210
|
-
|
|
3349
|
+
_context15.next = 3;
|
|
3211
3350
|
break;
|
|
3212
3351
|
}
|
|
3213
|
-
return
|
|
3352
|
+
return _context15.abrupt("return", null);
|
|
3214
3353
|
case 3:
|
|
3215
3354
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3216
3355
|
originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
@@ -3218,10 +3357,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3218
3357
|
shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
|
|
3219
3358
|
snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
|
|
3220
3359
|
if (!snapshotSummary) {
|
|
3221
|
-
|
|
3360
|
+
_context15.next = 10;
|
|
3222
3361
|
break;
|
|
3223
3362
|
}
|
|
3224
|
-
return
|
|
3363
|
+
return _context15.abrupt("return", snapshotSummary);
|
|
3225
3364
|
case 10:
|
|
3226
3365
|
shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
|
|
3227
3366
|
summaryProducts = shouldFullRecalculateFromSnapshot ? cloneDeep(tempOrder.products || []) : tempOrder.products;
|
|
@@ -3233,7 +3372,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3233
3372
|
totalRefundAmount = existedSummary.total_refund_amount || '0.00';
|
|
3234
3373
|
paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
3235
3374
|
if (salesSummary) {
|
|
3236
|
-
|
|
3375
|
+
_context15.next = 26;
|
|
3237
3376
|
break;
|
|
3238
3377
|
}
|
|
3239
3378
|
emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
|
|
@@ -3259,9 +3398,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3259
3398
|
previousSummary: existedSummary,
|
|
3260
3399
|
summary: emptySummary
|
|
3261
3400
|
});
|
|
3262
|
-
return
|
|
3401
|
+
return _context15.abrupt("return", this.store.summary);
|
|
3263
3402
|
case 26:
|
|
3264
|
-
|
|
3403
|
+
_context15.next = 28;
|
|
3265
3404
|
return salesSummary.getSummary(_objectSpread({
|
|
3266
3405
|
products: summaryProducts,
|
|
3267
3406
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
@@ -3271,7 +3410,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3271
3410
|
channel: this.otherParams.channel
|
|
3272
3411
|
} : {}));
|
|
3273
3412
|
case 28:
|
|
3274
|
-
salesSummaryResult =
|
|
3413
|
+
salesSummaryResult = _context15.sent;
|
|
3275
3414
|
if (shouldFullRecalculateFromSnapshot) {
|
|
3276
3415
|
tempOrder.products = summaryProducts;
|
|
3277
3416
|
}
|
|
@@ -3279,7 +3418,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3279
3418
|
roundingAmount = paidPaymentSummary.roundingAmount;
|
|
3280
3419
|
payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
|
|
3281
3420
|
hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
|
|
3282
|
-
expectAmount = hasSalesSummaryAmount ? new Decimal((
|
|
3421
|
+
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;
|
|
3283
3422
|
amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
|
|
3284
3423
|
rounding_amount: roundingAmount.toFixed(2)
|
|
3285
3424
|
}, expectAmount ? {
|
|
@@ -3316,12 +3455,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3316
3455
|
previousSummary: existedSummary,
|
|
3317
3456
|
summary: summary
|
|
3318
3457
|
});
|
|
3319
|
-
return
|
|
3458
|
+
return _context15.abrupt("return", this.store.summary);
|
|
3320
3459
|
case 46:
|
|
3321
3460
|
case "end":
|
|
3322
|
-
return
|
|
3461
|
+
return _context15.stop();
|
|
3323
3462
|
}
|
|
3324
|
-
},
|
|
3463
|
+
}, _callee13, this);
|
|
3325
3464
|
}));
|
|
3326
3465
|
function recalculateSummary(_x11) {
|
|
3327
3466
|
return _recalculateSummary.apply(this, arguments);
|
|
@@ -3331,30 +3470,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3331
3470
|
}, {
|
|
3332
3471
|
key: "getOrderSummary",
|
|
3333
3472
|
value: function () {
|
|
3334
|
-
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3473
|
+
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
3335
3474
|
var summary;
|
|
3336
|
-
return _regeneratorRuntime().wrap(function
|
|
3337
|
-
while (1) switch (
|
|
3475
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context16) {
|
|
3476
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
3338
3477
|
case 0:
|
|
3339
|
-
|
|
3478
|
+
_context16.next = 2;
|
|
3340
3479
|
return this.recalculateSummary({
|
|
3341
3480
|
createIfMissing: true
|
|
3342
3481
|
});
|
|
3343
3482
|
case 2:
|
|
3344
|
-
summary =
|
|
3483
|
+
summary = _context16.sent;
|
|
3345
3484
|
if (summary) {
|
|
3346
|
-
|
|
3485
|
+
_context16.next = 5;
|
|
3347
3486
|
break;
|
|
3348
3487
|
}
|
|
3349
|
-
return
|
|
3488
|
+
return _context16.abrupt("return", createEmptySummary());
|
|
3350
3489
|
case 5:
|
|
3351
3490
|
this.persistTempOrder();
|
|
3352
|
-
return
|
|
3491
|
+
return _context16.abrupt("return", summary);
|
|
3353
3492
|
case 7:
|
|
3354
3493
|
case "end":
|
|
3355
|
-
return
|
|
3494
|
+
return _context16.stop();
|
|
3356
3495
|
}
|
|
3357
|
-
},
|
|
3496
|
+
}, _callee14, this);
|
|
3358
3497
|
}));
|
|
3359
3498
|
function getOrderSummary() {
|
|
3360
3499
|
return _getOrderSummary.apply(this, arguments);
|
|
@@ -3378,21 +3517,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3378
3517
|
}, {
|
|
3379
3518
|
key: "syncTempOrderNoteToRemote",
|
|
3380
3519
|
value: function () {
|
|
3381
|
-
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3382
|
-
return _regeneratorRuntime().wrap(function
|
|
3383
|
-
while (1) switch (
|
|
3520
|
+
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderId, note) {
|
|
3521
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
3522
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
3384
3523
|
case 0:
|
|
3385
|
-
|
|
3524
|
+
_context17.next = 2;
|
|
3386
3525
|
return this.request.put("/order/order/".concat(orderId, "/note"), {
|
|
3387
3526
|
note: note
|
|
3388
3527
|
});
|
|
3389
3528
|
case 2:
|
|
3390
|
-
return
|
|
3529
|
+
return _context17.abrupt("return", note);
|
|
3391
3530
|
case 3:
|
|
3392
3531
|
case "end":
|
|
3393
|
-
return
|
|
3532
|
+
return _context17.stop();
|
|
3394
3533
|
}
|
|
3395
|
-
},
|
|
3534
|
+
}, _callee15, this);
|
|
3396
3535
|
}));
|
|
3397
3536
|
function syncTempOrderNoteToRemote(_x12, _x13) {
|
|
3398
3537
|
return _syncTempOrderNoteToRemote.apply(this, arguments);
|
|
@@ -3402,100 +3541,398 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3402
3541
|
}, {
|
|
3403
3542
|
key: "getTempOrderNote",
|
|
3404
3543
|
value: function getTempOrderNote() {
|
|
3405
|
-
var _this$store$
|
|
3406
|
-
return ((_this$store$
|
|
3544
|
+
var _this$store$tempOrder4;
|
|
3545
|
+
return ((_this$store$tempOrder4 = this.store.tempOrder) === null || _this$store$tempOrder4 === void 0 ? void 0 : _this$store$tempOrder4.note) || '';
|
|
3407
3546
|
}
|
|
3408
3547
|
}, {
|
|
3409
|
-
key: "
|
|
3410
|
-
value: function
|
|
3411
|
-
var
|
|
3412
|
-
|
|
3413
|
-
tempOrder.
|
|
3414
|
-
|
|
3415
|
-
|
|
3548
|
+
key: "ensureSalesNotesRuntimeState",
|
|
3549
|
+
value: function ensureSalesNotesRuntimeState(tempOrder) {
|
|
3550
|
+
var hadNotesSnapshot = Array.isArray(tempOrder.notes);
|
|
3551
|
+
if (!Array.isArray(tempOrder.notes)) tempOrder.notes = [];
|
|
3552
|
+
if (!tempOrder._extend || _typeof(tempOrder._extend) !== 'object') {
|
|
3553
|
+
tempOrder._extend = {
|
|
3554
|
+
productsByUid: {}
|
|
3555
|
+
};
|
|
3556
|
+
}
|
|
3557
|
+
if (!tempOrder._extend.salesNotesState) {
|
|
3558
|
+
tempOrder._extend.salesNotesState = {
|
|
3559
|
+
loaded: hadNotesSnapshot,
|
|
3560
|
+
dirty: false
|
|
3561
|
+
};
|
|
3562
|
+
}
|
|
3563
|
+
return tempOrder._extend.salesNotesState;
|
|
3416
3564
|
}
|
|
3417
3565
|
}, {
|
|
3418
|
-
key: "
|
|
3419
|
-
value: function
|
|
3420
|
-
var
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
tempOrder: tempOrder,
|
|
3429
|
-
summary: summaryWithDeposit,
|
|
3430
|
-
orderPaidAmount: paidPaymentSummary.gapPaidAmount
|
|
3431
|
-
})
|
|
3432
|
-
});
|
|
3433
|
-
this.store.summary = summary;
|
|
3434
|
-
this.updateTempOrderPaymentStatus(tempOrder, {
|
|
3435
|
-
previousSummary: previousSummary,
|
|
3436
|
-
summary: summary
|
|
3437
|
-
});
|
|
3438
|
-
this.persistTempOrder();
|
|
3439
|
-
return summary;
|
|
3566
|
+
key: "ensureSalesNotesLoadedForMutation",
|
|
3567
|
+
value: function ensureSalesNotesLoadedForMutation(tempOrder) {
|
|
3568
|
+
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3569
|
+
if (state.loaded) return;
|
|
3570
|
+
if (tempOrder.order_id === null || tempOrder.order_id === undefined) {
|
|
3571
|
+
state.loaded = true;
|
|
3572
|
+
tempOrder.notes = [];
|
|
3573
|
+
return;
|
|
3574
|
+
}
|
|
3575
|
+
throw new Error('[Order Notes] 当前订单 Notes 尚未完整加载,禁止提交部分快照');
|
|
3440
3576
|
}
|
|
3441
3577
|
}, {
|
|
3442
|
-
key: "
|
|
3443
|
-
value: function
|
|
3444
|
-
var
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3578
|
+
key: "normalizeSalesNoteUuid",
|
|
3579
|
+
value: function normalizeSalesNoteUuid(value, field) {
|
|
3580
|
+
var uuid = String(value !== null && value !== void 0 ? value : '').trim();
|
|
3581
|
+
if (!uuid) throw new Error("[Order Notes] ".concat(field, " \u4E0D\u80FD\u4E3A\u7A7A"));
|
|
3582
|
+
if (uuid.length > 255) {
|
|
3583
|
+
throw new Error("[Order Notes] ".concat(field, " \u4E0D\u80FD\u8D85\u8FC7 255 \u4E2A\u5B57\u7B26"));
|
|
3584
|
+
}
|
|
3585
|
+
return uuid;
|
|
3448
3586
|
}
|
|
3449
3587
|
}, {
|
|
3450
|
-
key: "
|
|
3451
|
-
value: function
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
return tempOrder.contacts_info;
|
|
3588
|
+
key: "getSalesNotePrimaryRelation",
|
|
3589
|
+
value: function getSalesNotePrimaryRelation(note) {
|
|
3590
|
+
return note.note_relations.find(function (relation) {
|
|
3591
|
+
return relation.is_primary === 1;
|
|
3592
|
+
}) || null;
|
|
3456
3593
|
}
|
|
3457
3594
|
}, {
|
|
3458
|
-
key: "
|
|
3459
|
-
value: function
|
|
3460
|
-
var
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3595
|
+
key: "removeSalesNotesForMissingProductLines",
|
|
3596
|
+
value: function removeSalesNotesForMissingProductLines(tempOrder) {
|
|
3597
|
+
var _this20 = this;
|
|
3598
|
+
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3599
|
+
if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
|
|
3600
|
+
return;
|
|
3601
|
+
}
|
|
3602
|
+
var remainingProductUids = new Set((tempOrder.products || []).map(function (product) {
|
|
3603
|
+
var _product$metadata7;
|
|
3604
|
+
return ((_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number) || product.unique_identification_number;
|
|
3605
|
+
}).filter(function (uid) {
|
|
3606
|
+
return typeof uid === 'string' && uid.length > 0;
|
|
3607
|
+
}));
|
|
3608
|
+
var nextNotes = tempOrder.notes.filter(function (note) {
|
|
3609
|
+
var primary = _this20.getSalesNotePrimaryRelation(note);
|
|
3610
|
+
if (!primary || primary.target_type !== 'order_detail') return true;
|
|
3611
|
+
return remainingProductUids.has(primary.target_uuid);
|
|
3612
|
+
});
|
|
3613
|
+
if (nextNotes.length === tempOrder.notes.length) return;
|
|
3614
|
+
tempOrder.notes = nextNotes;
|
|
3615
|
+
state.dirty = true;
|
|
3616
|
+
}
|
|
3617
|
+
}, {
|
|
3618
|
+
key: "setSalesNoteOnTempOrder",
|
|
3619
|
+
value: function setSalesNoteOnTempOrder(tempOrder, input) {
|
|
3620
|
+
var _input$target,
|
|
3621
|
+
_this21 = this,
|
|
3622
|
+
_tempOrder$shop_order;
|
|
3623
|
+
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
3624
|
+
var note_type = String(input.note_type || '').trim();
|
|
3625
|
+
var policy = getSalesNotePolicy(note_type);
|
|
3626
|
+
if (!policy) {
|
|
3627
|
+
throw new Error("[Order Notes] \u5F53\u524D\u672A\u6CE8\u518C\u5907\u6CE8\u7C7B\u578B: ".concat(note_type || '(empty)'));
|
|
3628
|
+
}
|
|
3629
|
+
if (((_input$target = input.target) === null || _input$target === void 0 ? void 0 : _input$target.target_type) !== 'order_detail') {
|
|
3630
|
+
throw new Error('[Order Notes] 本期只支持 order_detail 作为主体');
|
|
3631
|
+
}
|
|
3632
|
+
var target_uuid = this.normalizeSalesNoteUuid(input.target.target_uuid, 'target_uuid');
|
|
3633
|
+
var targetProductExists = (tempOrder.products || []).some(function (product) {
|
|
3634
|
+
var _product$metadata8;
|
|
3635
|
+
var productLineUid = ((_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number) || product.unique_identification_number;
|
|
3636
|
+
return String(productLineUid !== null && productLineUid !== void 0 ? productLineUid : '') === target_uuid;
|
|
3637
|
+
});
|
|
3638
|
+
if (!targetProductExists) {
|
|
3639
|
+
throw new Error('[Order Notes] 目标商品行不存在');
|
|
3640
|
+
}
|
|
3641
|
+
var text = buildSalesNoteText(input.text);
|
|
3642
|
+
var notes = tempOrder.notes || [];
|
|
3643
|
+
// 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
|
|
3644
|
+
var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
|
|
3645
|
+
var primary = _this21.getSalesNotePrimaryRelation(note);
|
|
3646
|
+
return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
|
|
3647
|
+
}) : -1;
|
|
3648
|
+
var existing = existingIndex >= 0 ? notes[existingIndex] : null;
|
|
3649
|
+
var existingPrimary = existing === null || existing === void 0 ? void 0 : existing.note_relations.find(function (relation) {
|
|
3650
|
+
return relation.is_primary === 1 && relation.target_type === 'order_detail';
|
|
3651
|
+
});
|
|
3652
|
+
var existingOrderRelation = existing === null || existing === void 0 ? void 0 : existing.note_relations.find(function (relation) {
|
|
3653
|
+
return relation.is_primary === 0 && relation.target_type === 'order';
|
|
3473
3654
|
});
|
|
3655
|
+
var note = {
|
|
3656
|
+
uuid: (existing === null || existing === void 0 ? void 0 : existing.uuid) || createUuidV4(),
|
|
3657
|
+
note_type: policy.note_type,
|
|
3658
|
+
content: {
|
|
3659
|
+
text: text
|
|
3660
|
+
},
|
|
3661
|
+
importance: policy.importance,
|
|
3662
|
+
note_relations: [{
|
|
3663
|
+
uuid: (existingPrimary === null || existingPrimary === void 0 ? void 0 : existingPrimary.uuid) || createUuidV4(),
|
|
3664
|
+
relation_type: policy.primary_relation_type,
|
|
3665
|
+
target_type: 'order_detail',
|
|
3666
|
+
target_uuid: target_uuid,
|
|
3667
|
+
is_primary: 1
|
|
3668
|
+
}, {
|
|
3669
|
+
uuid: (existingOrderRelation === null || existingOrderRelation === void 0 ? void 0 : existingOrderRelation.uuid) || createUuidV4(),
|
|
3670
|
+
relation_type: policy.secondary_order_relation_type,
|
|
3671
|
+
target_type: 'order',
|
|
3672
|
+
target_uuid: String((_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : ''),
|
|
3673
|
+
is_primary: 0
|
|
3674
|
+
}]
|
|
3675
|
+
};
|
|
3676
|
+
var duplicateIndex = notes.findIndex(function (item, index) {
|
|
3677
|
+
return item.uuid === note.uuid && index !== existingIndex;
|
|
3678
|
+
});
|
|
3679
|
+
if (duplicateIndex >= 0) {
|
|
3680
|
+
throw new Error('[Order Notes] uuid 已被其他 Note 使用');
|
|
3681
|
+
}
|
|
3682
|
+
tempOrder.notes = existingIndex >= 0 ? notes.map(function (item, index) {
|
|
3683
|
+
return index === existingIndex ? note : item;
|
|
3684
|
+
}) : [].concat(_toConsumableArray(notes), [note]);
|
|
3685
|
+
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3686
|
+
state.loaded = true;
|
|
3687
|
+
state.dirty = true;
|
|
3688
|
+
return note;
|
|
3474
3689
|
}
|
|
3475
3690
|
}, {
|
|
3476
|
-
key: "
|
|
3477
|
-
value: function
|
|
3478
|
-
var
|
|
3479
|
-
|
|
3480
|
-
return
|
|
3691
|
+
key: "getSalesNotes",
|
|
3692
|
+
value: function getSalesNotes() {
|
|
3693
|
+
var tempOrder = this.ensureTempOrder();
|
|
3694
|
+
this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3695
|
+
return cloneDeep(tempOrder.notes || []);
|
|
3481
3696
|
}
|
|
3482
3697
|
}, {
|
|
3483
|
-
key: "
|
|
3484
|
-
value: function
|
|
3485
|
-
|
|
3698
|
+
key: "createSalesNotesMutationSnapshot",
|
|
3699
|
+
value: function createSalesNotesMutationSnapshot() {
|
|
3700
|
+
var _tempOrder$order_id2;
|
|
3701
|
+
var tempOrder = this.ensureTempOrder();
|
|
3702
|
+
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3703
|
+
return {
|
|
3704
|
+
orderIdentity: {
|
|
3705
|
+
orderId: (_tempOrder$order_id2 = tempOrder.order_id) !== null && _tempOrder$order_id2 !== void 0 ? _tempOrder$order_id2 : null,
|
|
3706
|
+
externalSaleNumber: String(tempOrder.external_sale_number || '')
|
|
3707
|
+
},
|
|
3708
|
+
notes: cloneDeep(tempOrder.notes || []),
|
|
3709
|
+
state: cloneDeep(state)
|
|
3710
|
+
};
|
|
3486
3711
|
}
|
|
3487
3712
|
}, {
|
|
3488
|
-
key: "
|
|
3489
|
-
value: function
|
|
3490
|
-
var
|
|
3491
|
-
if (((
|
|
3492
|
-
|
|
3713
|
+
key: "restoreSalesNotesMutationSnapshot",
|
|
3714
|
+
value: function restoreSalesNotesMutationSnapshot(snapshot) {
|
|
3715
|
+
var _snapshot$state, _snapshot$state2;
|
|
3716
|
+
if (!snapshot || !Array.isArray(snapshot.notes) || !snapshot.orderIdentity || typeof snapshot.orderIdentity.externalSaleNumber !== 'string' || typeof ((_snapshot$state = snapshot.state) === null || _snapshot$state === void 0 ? void 0 : _snapshot$state.loaded) !== 'boolean' || typeof ((_snapshot$state2 = snapshot.state) === null || _snapshot$state2 === void 0 ? void 0 : _snapshot$state2.dirty) !== 'boolean') {
|
|
3717
|
+
throw new Error('[Order Notes] 无效的 mutation snapshot');
|
|
3718
|
+
}
|
|
3719
|
+
var tempOrder = this.store.tempOrder;
|
|
3720
|
+
if (!tempOrder) throw new Error('[Order Notes] 当前订单不存在');
|
|
3721
|
+
var snapshotOrderId = snapshot.orderIdentity.orderId;
|
|
3722
|
+
var currentOrderId = tempOrder.order_id;
|
|
3723
|
+
var hasSnapshotOrderId = snapshotOrderId !== null && snapshotOrderId !== undefined && String(snapshotOrderId).trim().length > 0;
|
|
3724
|
+
var hasCurrentOrderId = currentOrderId !== null && currentOrderId !== undefined && String(currentOrderId).trim().length > 0;
|
|
3725
|
+
var isSameOrder = hasSnapshotOrderId && hasCurrentOrderId ? String(snapshotOrderId) === String(currentOrderId) : Boolean(snapshot.orderIdentity.externalSaleNumber) && snapshot.orderIdentity.externalSaleNumber === String(tempOrder.external_sale_number || '');
|
|
3726
|
+
if (!isSameOrder) {
|
|
3727
|
+
throw new Error('[Order Notes] 当前订单已切换,拒绝恢复旧订单快照');
|
|
3728
|
+
}
|
|
3729
|
+
this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3730
|
+
tempOrder.notes = cloneDeep(snapshot.notes);
|
|
3731
|
+
tempOrder._extend.salesNotesState = cloneDeep(snapshot.state);
|
|
3732
|
+
this.notifyTempOrderChanged();
|
|
3733
|
+
}
|
|
3734
|
+
}, {
|
|
3735
|
+
key: "setSalesNote",
|
|
3736
|
+
value: function () {
|
|
3737
|
+
var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(input) {
|
|
3738
|
+
var tempOrder, note;
|
|
3739
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
3740
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
3741
|
+
case 0:
|
|
3742
|
+
tempOrder = this.ensureTempOrder();
|
|
3743
|
+
note = this.setSalesNoteOnTempOrder(tempOrder, input);
|
|
3744
|
+
this.notifyTempOrderChanged();
|
|
3745
|
+
return _context18.abrupt("return", cloneDeep(note));
|
|
3746
|
+
case 4:
|
|
3747
|
+
case "end":
|
|
3748
|
+
return _context18.stop();
|
|
3749
|
+
}
|
|
3750
|
+
}, _callee16, this);
|
|
3751
|
+
}));
|
|
3752
|
+
function setSalesNote(_x14) {
|
|
3753
|
+
return _setSalesNote.apply(this, arguments);
|
|
3754
|
+
}
|
|
3755
|
+
return setSalesNote;
|
|
3756
|
+
}()
|
|
3757
|
+
}, {
|
|
3758
|
+
key: "removeSalesNote",
|
|
3759
|
+
value: function () {
|
|
3760
|
+
var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(uuid) {
|
|
3761
|
+
var tempOrder, normalizedUuid, notes, nextNotes, state;
|
|
3762
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3763
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
3764
|
+
case 0:
|
|
3765
|
+
tempOrder = this.ensureTempOrder();
|
|
3766
|
+
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
3767
|
+
normalizedUuid = this.normalizeSalesNoteUuid(uuid, 'uuid');
|
|
3768
|
+
notes = tempOrder.notes || [];
|
|
3769
|
+
nextNotes = notes.filter(function (note) {
|
|
3770
|
+
return note.uuid !== normalizedUuid;
|
|
3771
|
+
});
|
|
3772
|
+
if (!(nextNotes.length === notes.length)) {
|
|
3773
|
+
_context19.next = 7;
|
|
3774
|
+
break;
|
|
3775
|
+
}
|
|
3776
|
+
return _context19.abrupt("return");
|
|
3777
|
+
case 7:
|
|
3778
|
+
tempOrder.notes = nextNotes;
|
|
3779
|
+
state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3780
|
+
state.dirty = true;
|
|
3781
|
+
this.notifyTempOrderChanged();
|
|
3782
|
+
case 11:
|
|
3783
|
+
case "end":
|
|
3784
|
+
return _context19.stop();
|
|
3785
|
+
}
|
|
3786
|
+
}, _callee17, this);
|
|
3787
|
+
}));
|
|
3788
|
+
function removeSalesNote(_x15) {
|
|
3789
|
+
return _removeSalesNote.apply(this, arguments);
|
|
3790
|
+
}
|
|
3791
|
+
return removeSalesNote;
|
|
3792
|
+
}()
|
|
3793
|
+
}, {
|
|
3794
|
+
key: "clearSalesNotes",
|
|
3795
|
+
value: function () {
|
|
3796
|
+
var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
3797
|
+
var tempOrder, state;
|
|
3798
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
3799
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
3800
|
+
case 0:
|
|
3801
|
+
tempOrder = this.ensureTempOrder();
|
|
3802
|
+
tempOrder.notes = [];
|
|
3803
|
+
state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3804
|
+
state.loaded = true;
|
|
3805
|
+
state.dirty = true;
|
|
3806
|
+
this.notifyTempOrderChanged();
|
|
3807
|
+
case 6:
|
|
3808
|
+
case "end":
|
|
3809
|
+
return _context20.stop();
|
|
3810
|
+
}
|
|
3811
|
+
}, _callee18, this);
|
|
3812
|
+
}));
|
|
3813
|
+
function clearSalesNotes() {
|
|
3814
|
+
return _clearSalesNotes.apply(this, arguments);
|
|
3815
|
+
}
|
|
3816
|
+
return clearSalesNotes;
|
|
3817
|
+
}()
|
|
3818
|
+
}, {
|
|
3819
|
+
key: "updateTempOrderShopDiscount",
|
|
3820
|
+
value: function updateTempOrderShopDiscount(amount) {
|
|
3821
|
+
var tempOrder = this.ensureTempOrder();
|
|
3822
|
+
var discount = Decimal.max(new Decimal(Number(amount) || 0), 0).toDecimalPlaces(2).toFixed(2);
|
|
3823
|
+
tempOrder.shop_discount = discount;
|
|
3824
|
+
this.persistTempOrder();
|
|
3825
|
+
return tempOrder.shop_discount;
|
|
3826
|
+
}
|
|
3827
|
+
}, {
|
|
3828
|
+
key: "updateTempOrderDepositAmount",
|
|
3829
|
+
value: function updateTempOrderDepositAmount(amount) {
|
|
3830
|
+
var tempOrder = this.ensureTempOrder();
|
|
3831
|
+
var depositAmount = this.normalizeDepositAmount(amount);
|
|
3832
|
+
var previousSummary = this.store.summary || createEmptySummary();
|
|
3833
|
+
var summaryWithDeposit = this.applyDepositAmountToSummary(tempOrder, _objectSpread(_objectSpread({}, createEmptySummary()), previousSummary), depositAmount);
|
|
3834
|
+
this.setManualDepositOverride(tempOrder, depositAmount);
|
|
3835
|
+
var paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
3836
|
+
var summary = _objectSpread(_objectSpread({}, summaryWithDeposit), {}, {
|
|
3837
|
+
amount_gap: this.calculateSummaryAmountGap({
|
|
3838
|
+
tempOrder: tempOrder,
|
|
3839
|
+
summary: summaryWithDeposit,
|
|
3840
|
+
orderPaidAmount: paidPaymentSummary.gapPaidAmount
|
|
3841
|
+
})
|
|
3842
|
+
});
|
|
3843
|
+
this.store.summary = summary;
|
|
3844
|
+
this.updateTempOrderPaymentStatus(tempOrder, {
|
|
3845
|
+
previousSummary: previousSummary,
|
|
3846
|
+
summary: summary
|
|
3847
|
+
});
|
|
3848
|
+
this.persistTempOrder();
|
|
3849
|
+
return summary;
|
|
3850
|
+
}
|
|
3851
|
+
}, {
|
|
3852
|
+
key: "updateTempOrderBuzzer",
|
|
3853
|
+
value: function updateTempOrderBuzzer(buzzer) {
|
|
3854
|
+
var tempOrder = this.ensureTempOrder();
|
|
3855
|
+
tempOrder.buzzer = String(buzzer || '');
|
|
3856
|
+
this.persistTempOrder();
|
|
3857
|
+
return tempOrder.buzzer;
|
|
3858
|
+
}
|
|
3859
|
+
}, {
|
|
3860
|
+
key: "updateTempOrderShopServiceData",
|
|
3861
|
+
value: function updateTempOrderShopServiceData(patch) {
|
|
3862
|
+
var tempOrder = this.ensureTempOrder();
|
|
3863
|
+
var metadata = tempOrder.metadata && _typeof(tempOrder.metadata) === 'object' && !Array.isArray(tempOrder.metadata) ? tempOrder.metadata : {};
|
|
3864
|
+
var currentShopServiceData = metadata.shop_service_data && _typeof(metadata.shop_service_data) === 'object' && !Array.isArray(metadata.shop_service_data) ? metadata.shop_service_data : {};
|
|
3865
|
+
var shopServiceData = _objectSpread(_objectSpread({}, currentShopServiceData), patch);
|
|
3866
|
+
tempOrder.metadata = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
3867
|
+
shop_service_data: shopServiceData
|
|
3868
|
+
});
|
|
3869
|
+
this.persistTempOrder();
|
|
3870
|
+
return shopServiceData;
|
|
3871
|
+
}
|
|
3872
|
+
}, {
|
|
3873
|
+
key: "updateTempOrderPickupReferenceMode",
|
|
3874
|
+
value: function updateTempOrderPickupReferenceMode(mode) {
|
|
3875
|
+
return this.updateTempOrderShopServiceData({
|
|
3876
|
+
pickup_reference_mode: mode
|
|
3877
|
+
});
|
|
3878
|
+
}
|
|
3879
|
+
}, {
|
|
3880
|
+
key: "updateTempOrderServiceType",
|
|
3881
|
+
value: function updateTempOrderServiceType(serviceType) {
|
|
3882
|
+
return this.updateTempOrderShopServiceData({
|
|
3883
|
+
service_type: serviceType
|
|
3884
|
+
});
|
|
3885
|
+
}
|
|
3886
|
+
}, {
|
|
3887
|
+
key: "updateTempOrderContactsInfo",
|
|
3888
|
+
value: function updateTempOrderContactsInfo(contactsInfo) {
|
|
3889
|
+
var tempOrder = this.ensureTempOrder();
|
|
3890
|
+
tempOrder.contacts_info = contactsInfo && _typeof(contactsInfo) === 'object' && !Array.isArray(contactsInfo) ? contactsInfo : null;
|
|
3891
|
+
this.persistTempOrder();
|
|
3892
|
+
return tempOrder.contacts_info;
|
|
3893
|
+
}
|
|
3894
|
+
}, {
|
|
3895
|
+
key: "buildTempOrderCustomer",
|
|
3896
|
+
value: function buildTempOrderCustomer(params) {
|
|
3897
|
+
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;
|
|
3898
|
+
if (!params.customerId) return null;
|
|
3899
|
+
var source = params.source ? cloneDeep(params.source) : {};
|
|
3900
|
+
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;
|
|
3901
|
+
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;
|
|
3902
|
+
return _objectSpread(_objectSpread({}, source), {}, {
|
|
3903
|
+
id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
|
|
3904
|
+
customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
|
|
3905
|
+
name: String(name || ''),
|
|
3906
|
+
customer_name: String(customerName || ''),
|
|
3907
|
+
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),
|
|
3908
|
+
phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
|
|
3909
|
+
email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
|
|
3910
|
+
});
|
|
3911
|
+
}
|
|
3912
|
+
}, {
|
|
3913
|
+
key: "isCustomerBoundDiscount",
|
|
3914
|
+
value: function isCustomerBoundDiscount(discount) {
|
|
3915
|
+
var _discount$type5;
|
|
3916
|
+
var type = (_discount$type5 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type5 !== void 0 ? _discount$type5 : discount === null || discount === void 0 ? void 0 : discount.tag;
|
|
3917
|
+
return type === 'entitlement_pass' || type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
3918
|
+
}
|
|
3919
|
+
}, {
|
|
3920
|
+
key: "shouldKeepCustomerBoundDiscountAfterCustomerChange",
|
|
3921
|
+
value: function shouldKeepCustomerBoundDiscountAfterCustomerChange(discount) {
|
|
3922
|
+
return Boolean((discount === null || discount === void 0 ? void 0 : discount.isScan) || (discount === null || discount === void 0 ? void 0 : discount.isEditMode));
|
|
3923
|
+
}
|
|
3924
|
+
}, {
|
|
3925
|
+
key: "productHasCustomerBoundDiscount",
|
|
3926
|
+
value: function productHasCustomerBoundDiscount(product) {
|
|
3927
|
+
var _this22 = this;
|
|
3928
|
+
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
3929
|
+
return _this22.isCustomerBoundDiscount(discount);
|
|
3493
3930
|
})) {
|
|
3494
3931
|
return true;
|
|
3495
3932
|
}
|
|
3496
3933
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
3497
3934
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
3498
|
-
return
|
|
3935
|
+
return _this22.isCustomerBoundDiscount(discount);
|
|
3499
3936
|
});
|
|
3500
3937
|
});
|
|
3501
3938
|
}
|
|
@@ -3504,18 +3941,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3504
3941
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
3505
3942
|
var _this$store$discount20,
|
|
3506
3943
|
_this$store$discount21,
|
|
3507
|
-
|
|
3944
|
+
_this23 = this;
|
|
3508
3945
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
3509
3946
|
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)) || [];
|
|
3510
3947
|
if (discountList.length > 0) return false;
|
|
3511
3948
|
return !(tempOrder.products || []).some(function (product) {
|
|
3512
|
-
return
|
|
3949
|
+
return _this23.productHasCustomerBoundDiscount(product);
|
|
3513
3950
|
});
|
|
3514
3951
|
}
|
|
3515
3952
|
}, {
|
|
3516
3953
|
key: "clearCustomerBoundDiscounts",
|
|
3517
3954
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
3518
|
-
var
|
|
3955
|
+
var _this24 = this,
|
|
3519
3956
|
_discountModule$getDi,
|
|
3520
3957
|
_discountModule$getOr,
|
|
3521
3958
|
_discountModule$setDi,
|
|
@@ -3524,7 +3961,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3524
3961
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
3525
3962
|
if (!Array.isArray(discountList)) return [];
|
|
3526
3963
|
return discountList.filter(function (discount) {
|
|
3527
|
-
var shouldRemove =
|
|
3964
|
+
var shouldRemove = _this24.isCustomerBoundDiscount(discount);
|
|
3528
3965
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
3529
3966
|
return !shouldRemove;
|
|
3530
3967
|
});
|
|
@@ -3551,12 +3988,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3551
3988
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
3552
3989
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
3553
3990
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
3554
|
-
if (
|
|
3555
|
-
return !
|
|
3991
|
+
if (_this24.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3992
|
+
return !_this24.isCustomerBoundDiscount(discount);
|
|
3556
3993
|
});
|
|
3557
3994
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
3558
|
-
if (
|
|
3559
|
-
return !
|
|
3995
|
+
if (_this24.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3996
|
+
return !_this24.isCustomerBoundDiscount(discount);
|
|
3560
3997
|
});
|
|
3561
3998
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
3562
3999
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -3571,14 +4008,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3571
4008
|
}, {
|
|
3572
4009
|
key: "updateTempOrderCustomer",
|
|
3573
4010
|
value: function updateTempOrderCustomer(customer) {
|
|
3574
|
-
var _tempOrder$customer_i3,
|
|
4011
|
+
var _tempOrder$customer_i3, _ref58, _ref59, _customer$customer_id, _ref60, _ref61, _ref62, _customer$customer_na, _ref63, _customer$country_cal, _tempOrder$customer_i4;
|
|
3575
4012
|
var tempOrder = this.ensureTempOrder();
|
|
3576
4013
|
var previousCustomerId = (_tempOrder$customer_i3 = tempOrder.customer_id) !== null && _tempOrder$customer_i3 !== void 0 ? _tempOrder$customer_i3 : null;
|
|
3577
|
-
var customerId = (
|
|
3578
|
-
var customerName = (
|
|
4014
|
+
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;
|
|
4015
|
+
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 : '';
|
|
3579
4016
|
tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
|
|
3580
4017
|
tempOrder.customer_name = String(customerName || '');
|
|
3581
|
-
tempOrder.country_calling_code = String((
|
|
4018
|
+
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 : '');
|
|
3582
4019
|
tempOrder.phone = String(customer.phone || '');
|
|
3583
4020
|
tempOrder.email = String(customer.email || '');
|
|
3584
4021
|
tempOrder.customer = this.buildTempOrderCustomer({
|
|
@@ -3591,8 +4028,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3591
4028
|
});
|
|
3592
4029
|
var nextCustomerId = (_tempOrder$customer_i4 = tempOrder.customer_id) !== null && _tempOrder$customer_i4 !== void 0 ? _tempOrder$customer_i4 : null;
|
|
3593
4030
|
if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
|
|
3594
|
-
this.
|
|
3595
|
-
this.clearTempOrderPointCardSnapshot(tempOrder);
|
|
4031
|
+
this.clearCustomerWalletState(tempOrder);
|
|
3596
4032
|
}
|
|
3597
4033
|
this.persistTempOrder();
|
|
3598
4034
|
return {
|
|
@@ -3631,9 +4067,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3631
4067
|
}
|
|
3632
4068
|
var nextCustomerId = (_tempOrder$customer_i6 = tempOrder.customer_id) !== null && _tempOrder$customer_i6 !== void 0 ? _tempOrder$customer_i6 : null;
|
|
3633
4069
|
if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
|
|
3634
|
-
this.
|
|
3635
|
-
this.store.virtualCurrencyList = [];
|
|
3636
|
-
this.clearTempOrderPointCardSnapshot(tempOrder);
|
|
4070
|
+
this.clearCustomerWalletState(tempOrder);
|
|
3637
4071
|
clearTempOrderHolderAssignments(tempOrder);
|
|
3638
4072
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3639
4073
|
this.applyDiscount();
|
|
@@ -3662,8 +4096,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3662
4096
|
}, {
|
|
3663
4097
|
key: "getOrderCustomerSnapshot",
|
|
3664
4098
|
value: function getOrderCustomerSnapshot() {
|
|
3665
|
-
var _this$store$
|
|
3666
|
-
var snapshot = (_this$store$
|
|
4099
|
+
var _this$store$tempOrder5;
|
|
4100
|
+
var snapshot = (_this$store$tempOrder5 = this.store.tempOrder) === null || _this$store$tempOrder5 === void 0 || (_this$store$tempOrder5 = _this$store$tempOrder5._extend) === null || _this$store$tempOrder5 === void 0 ? void 0 : _this$store$tempOrder5.customerSnapshot;
|
|
3667
4101
|
return snapshot ? cloneDeep(snapshot) : null;
|
|
3668
4102
|
}
|
|
3669
4103
|
}, {
|
|
@@ -3678,9 +4112,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3678
4112
|
tempOrder.email = '';
|
|
3679
4113
|
tempOrder.customer = null;
|
|
3680
4114
|
if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
|
|
3681
|
-
this.
|
|
3682
|
-
this.store.virtualCurrencyList = [];
|
|
3683
|
-
this.clearTempOrderPointCardSnapshot(tempOrder);
|
|
4115
|
+
this.clearCustomerWalletState(tempOrder);
|
|
3684
4116
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3685
4117
|
this.applyDiscount();
|
|
3686
4118
|
this.persistTempOrder();
|
|
@@ -3725,10 +4157,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3725
4157
|
}, {
|
|
3726
4158
|
key: "setOrderPayments",
|
|
3727
4159
|
value: function setOrderPayments(payments) {
|
|
3728
|
-
var
|
|
4160
|
+
var _this25 = this;
|
|
3729
4161
|
var tempOrder = this.ensureTempOrder();
|
|
3730
4162
|
tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
|
|
3731
|
-
return
|
|
4163
|
+
return _this25.normalizePaymentSource(payment, {
|
|
3732
4164
|
defaultPaid: false
|
|
3733
4165
|
});
|
|
3734
4166
|
}));
|
|
@@ -3748,34 +4180,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3748
4180
|
}, {
|
|
3749
4181
|
key: "addOrderPaymentAsync",
|
|
3750
4182
|
value: (function () {
|
|
3751
|
-
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4183
|
+
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(payment) {
|
|
3752
4184
|
var hasPaymentNumber, devicePrefix;
|
|
3753
|
-
return _regeneratorRuntime().wrap(function
|
|
3754
|
-
while (1) switch (
|
|
4185
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context21) {
|
|
4186
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
3755
4187
|
case 0:
|
|
3756
4188
|
hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
|
|
3757
4189
|
if (!hasPaymentNumber) {
|
|
3758
|
-
|
|
4190
|
+
_context21.next = 5;
|
|
3759
4191
|
break;
|
|
3760
4192
|
}
|
|
3761
|
-
|
|
3762
|
-
|
|
4193
|
+
_context21.t0 = 'LOCAL';
|
|
4194
|
+
_context21.next = 8;
|
|
3763
4195
|
break;
|
|
3764
4196
|
case 5:
|
|
3765
|
-
|
|
4197
|
+
_context21.next = 7;
|
|
3766
4198
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
3767
4199
|
case 7:
|
|
3768
|
-
|
|
4200
|
+
_context21.t0 = _context21.sent;
|
|
3769
4201
|
case 8:
|
|
3770
|
-
devicePrefix =
|
|
3771
|
-
return
|
|
4202
|
+
devicePrefix = _context21.t0;
|
|
4203
|
+
return _context21.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
3772
4204
|
case 10:
|
|
3773
4205
|
case "end":
|
|
3774
|
-
return
|
|
4206
|
+
return _context21.stop();
|
|
3775
4207
|
}
|
|
3776
|
-
},
|
|
4208
|
+
}, _callee19, this);
|
|
3777
4209
|
}));
|
|
3778
|
-
function addOrderPaymentAsync(
|
|
4210
|
+
function addOrderPaymentAsync(_x16) {
|
|
3779
4211
|
return _addOrderPaymentAsync.apply(this, arguments);
|
|
3780
4212
|
}
|
|
3781
4213
|
return addOrderPaymentAsync;
|
|
@@ -3783,7 +4215,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3783
4215
|
}, {
|
|
3784
4216
|
key: "addOrderPaymentWithDevicePrefix",
|
|
3785
4217
|
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
3786
|
-
var
|
|
4218
|
+
var _this26 = this;
|
|
3787
4219
|
this.logInfo('addOrderPayment', {
|
|
3788
4220
|
payment: payment
|
|
3789
4221
|
});
|
|
@@ -3801,7 +4233,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3801
4233
|
void this.recalculateSummary({
|
|
3802
4234
|
createIfMissing: true
|
|
3803
4235
|
}).catch(function (error) {
|
|
3804
|
-
|
|
4236
|
+
_this26.logError('recalculate summary after addOrderPayment failed', {
|
|
3805
4237
|
error: error instanceof Error ? error.message : String(error)
|
|
3806
4238
|
});
|
|
3807
4239
|
});
|
|
@@ -3815,7 +4247,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3815
4247
|
}, {
|
|
3816
4248
|
key: "updateOrderPayment",
|
|
3817
4249
|
value: (function () {
|
|
3818
|
-
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4250
|
+
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(paymentIdentity, updates) {
|
|
3819
4251
|
var options,
|
|
3820
4252
|
tempOrder,
|
|
3821
4253
|
identity,
|
|
@@ -3824,17 +4256,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3824
4256
|
updatedPayment,
|
|
3825
4257
|
summary,
|
|
3826
4258
|
payments,
|
|
3827
|
-
|
|
3828
|
-
return _regeneratorRuntime().wrap(function
|
|
3829
|
-
while (1) switch (
|
|
4259
|
+
_args22 = arguments;
|
|
4260
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
4261
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
3830
4262
|
case 0:
|
|
3831
|
-
options =
|
|
4263
|
+
options = _args22.length > 2 && _args22[2] !== undefined ? _args22[2] : {};
|
|
3832
4264
|
tempOrder = this.ensureTempOrder();
|
|
3833
4265
|
identity = String(paymentIdentity);
|
|
3834
4266
|
matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
|
|
3835
4267
|
matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
|
|
3836
4268
|
if (matchedPayment) {
|
|
3837
|
-
|
|
4269
|
+
_context22.next = 7;
|
|
3838
4270
|
break;
|
|
3839
4271
|
}
|
|
3840
4272
|
throw new Error("\u672A\u627E\u5230\u652F\u4ED8\u9879: ".concat(identity));
|
|
@@ -3849,15 +4281,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3849
4281
|
return nextPayment;
|
|
3850
4282
|
});
|
|
3851
4283
|
this.persistTempOrder();
|
|
3852
|
-
|
|
4284
|
+
_context22.next = 12;
|
|
3853
4285
|
return this.recalculateSummary({
|
|
3854
4286
|
createIfMissing: true
|
|
3855
4287
|
});
|
|
3856
4288
|
case 12:
|
|
3857
|
-
summary =
|
|
4289
|
+
summary = _context22.sent;
|
|
3858
4290
|
this.persistTempOrder();
|
|
3859
4291
|
payments = tempOrder.payments;
|
|
3860
|
-
return
|
|
4292
|
+
return _context22.abrupt("return", {
|
|
3861
4293
|
updated: true,
|
|
3862
4294
|
payment: payments[matchedPayment.index] || updatedPayment,
|
|
3863
4295
|
payments: payments,
|
|
@@ -3865,11 +4297,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3865
4297
|
});
|
|
3866
4298
|
case 16:
|
|
3867
4299
|
case "end":
|
|
3868
|
-
return
|
|
4300
|
+
return _context22.stop();
|
|
3869
4301
|
}
|
|
3870
|
-
},
|
|
4302
|
+
}, _callee20, this);
|
|
3871
4303
|
}));
|
|
3872
|
-
function updateOrderPayment(
|
|
4304
|
+
function updateOrderPayment(_x17, _x18) {
|
|
3873
4305
|
return _updateOrderPayment.apply(this, arguments);
|
|
3874
4306
|
}
|
|
3875
4307
|
return updateOrderPayment;
|
|
@@ -3914,7 +4346,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3914
4346
|
}, {
|
|
3915
4347
|
key: "applyPaymentLifecycleChange",
|
|
3916
4348
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
3917
|
-
var
|
|
4349
|
+
var _this27 = this;
|
|
3918
4350
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
3919
4351
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
3920
4352
|
this.persistTempOrder();
|
|
@@ -3924,7 +4356,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3924
4356
|
void this.recalculateSummary({
|
|
3925
4357
|
createIfMissing: true
|
|
3926
4358
|
}).catch(function (error) {
|
|
3927
|
-
|
|
4359
|
+
_this27.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
3928
4360
|
error: error instanceof Error ? error.message : String(error)
|
|
3929
4361
|
});
|
|
3930
4362
|
});
|
|
@@ -3968,7 +4400,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3968
4400
|
}, {
|
|
3969
4401
|
key: "updateVoucherOrderPayments",
|
|
3970
4402
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
3971
|
-
var
|
|
4403
|
+
var _this28 = this;
|
|
3972
4404
|
var tempOrder = this.ensureTempOrder();
|
|
3973
4405
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
3974
4406
|
return value === 'normal' || value === 'deposit';
|
|
@@ -4003,7 +4435,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4003
4435
|
});
|
|
4004
4436
|
};
|
|
4005
4437
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
4006
|
-
return
|
|
4438
|
+
return _this28.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
4007
4439
|
defaultPaid: false,
|
|
4008
4440
|
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
4009
4441
|
});
|
|
@@ -4056,7 +4488,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4056
4488
|
void this.recalculateSummary({
|
|
4057
4489
|
createIfMissing: true
|
|
4058
4490
|
}).catch(function (error) {
|
|
4059
|
-
|
|
4491
|
+
_this28.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
4060
4492
|
error: error instanceof Error ? error.message : String(error)
|
|
4061
4493
|
});
|
|
4062
4494
|
});
|
|
@@ -4065,38 +4497,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4065
4497
|
}, {
|
|
4066
4498
|
key: "updateVoucherOrderPaymentsAsync",
|
|
4067
4499
|
value: function () {
|
|
4068
|
-
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4500
|
+
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(payments, options) {
|
|
4069
4501
|
var needsPaymentNumber, devicePrefix;
|
|
4070
|
-
return _regeneratorRuntime().wrap(function
|
|
4071
|
-
while (1) switch (
|
|
4502
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
4503
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
4072
4504
|
case 0:
|
|
4073
4505
|
needsPaymentNumber = (payments || []).some(function (payment) {
|
|
4074
4506
|
return String(payment.payment_number || '').trim() === '';
|
|
4075
4507
|
});
|
|
4076
4508
|
if (!needsPaymentNumber) {
|
|
4077
|
-
|
|
4509
|
+
_context23.next = 7;
|
|
4078
4510
|
break;
|
|
4079
4511
|
}
|
|
4080
|
-
|
|
4512
|
+
_context23.next = 4;
|
|
4081
4513
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
4082
4514
|
case 4:
|
|
4083
|
-
|
|
4084
|
-
|
|
4515
|
+
_context23.t0 = _context23.sent;
|
|
4516
|
+
_context23.next = 8;
|
|
4085
4517
|
break;
|
|
4086
4518
|
case 7:
|
|
4087
|
-
|
|
4519
|
+
_context23.t0 = 'LOCAL';
|
|
4088
4520
|
case 8:
|
|
4089
|
-
devicePrefix =
|
|
4090
|
-
return
|
|
4521
|
+
devicePrefix = _context23.t0;
|
|
4522
|
+
return _context23.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
|
|
4091
4523
|
devicePrefix: devicePrefix
|
|
4092
4524
|
})));
|
|
4093
4525
|
case 10:
|
|
4094
4526
|
case "end":
|
|
4095
|
-
return
|
|
4527
|
+
return _context23.stop();
|
|
4096
4528
|
}
|
|
4097
|
-
},
|
|
4529
|
+
}, _callee21, this);
|
|
4098
4530
|
}));
|
|
4099
|
-
function updateVoucherOrderPaymentsAsync(
|
|
4531
|
+
function updateVoucherOrderPaymentsAsync(_x19, _x20) {
|
|
4100
4532
|
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
4101
4533
|
}
|
|
4102
4534
|
return updateVoucherOrderPaymentsAsync;
|
|
@@ -4114,7 +4546,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4114
4546
|
key: "shouldMergeProductToOrder",
|
|
4115
4547
|
value: function shouldMergeProductToOrder(params) {
|
|
4116
4548
|
var _this$orderHooks,
|
|
4117
|
-
|
|
4549
|
+
_this29 = this;
|
|
4118
4550
|
var onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
4119
4551
|
if (!onBeforeMergeProductToOrder) return true;
|
|
4120
4552
|
var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -4122,7 +4554,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4122
4554
|
}));
|
|
4123
4555
|
if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
|
|
4124
4556
|
return Promise.resolve(result).then(function (resolved) {
|
|
4125
|
-
return
|
|
4557
|
+
return _this29.normalizeShouldMergeProductResult(resolved);
|
|
4126
4558
|
});
|
|
4127
4559
|
}
|
|
4128
4560
|
return this.normalizeShouldMergeProductResult(result);
|
|
@@ -4142,8 +4574,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4142
4574
|
}, {
|
|
4143
4575
|
key: "hasLinkedBookingUid",
|
|
4144
4576
|
value: function hasLinkedBookingUid(product) {
|
|
4145
|
-
var _product$booking_uid, _product$
|
|
4146
|
-
var bookingUid = (_product$booking_uid = product === null || product === void 0 ? void 0 : product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : product === null || product === void 0 || (_product$
|
|
4577
|
+
var _product$booking_uid, _product$metadata9;
|
|
4578
|
+
var bookingUid = (_product$booking_uid = product === null || product === void 0 ? void 0 : product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : product === null || product === void 0 || (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.booking_uid;
|
|
4147
4579
|
return bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '';
|
|
4148
4580
|
}
|
|
4149
4581
|
}, {
|
|
@@ -4171,7 +4603,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4171
4603
|
}, {
|
|
4172
4604
|
key: "assertAndLockProductSettlement",
|
|
4173
4605
|
value: function assertAndLockProductSettlement(tempOrder, product) {
|
|
4174
|
-
var
|
|
4606
|
+
var _ref64, _ref65, _product$selling_pric;
|
|
4175
4607
|
if (!this.isMultiCurrencySettlementEnabled()) return;
|
|
4176
4608
|
var currentKey = getTempOrderSettlementKey(tempOrder);
|
|
4177
4609
|
var incomingKey = getSettlementKey(getSelectedSettlementSnapshot(product)) || 'legal_currency';
|
|
@@ -4198,7 +4630,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4198
4630
|
}
|
|
4199
4631
|
applyTempOrderSettlementState(tempOrder, snapshot || {
|
|
4200
4632
|
settlement_type: 'legal_currency',
|
|
4201
|
-
price: (
|
|
4633
|
+
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,
|
|
4202
4634
|
unit_label: tempOrder.currency_code,
|
|
4203
4635
|
symbol: tempOrder.currency_symbol,
|
|
4204
4636
|
amount_format: tempOrder.currency_format
|
|
@@ -4251,45 +4683,53 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4251
4683
|
}, {
|
|
4252
4684
|
key: "finalizeProductOrderMutation",
|
|
4253
4685
|
value: function () {
|
|
4254
|
-
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4255
|
-
var isVirtualSettlement;
|
|
4256
|
-
return _regeneratorRuntime().wrap(function
|
|
4257
|
-
while (1) switch (
|
|
4686
|
+
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(tempOrder, options) {
|
|
4687
|
+
var isVirtualSettlement, promotionPayload;
|
|
4688
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
4689
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
4258
4690
|
case 0:
|
|
4259
4691
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4260
4692
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
4261
4693
|
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
4262
4694
|
if (!(!(options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) && !isVirtualSettlement)) {
|
|
4263
|
-
|
|
4695
|
+
_context24.next = 6;
|
|
4264
4696
|
break;
|
|
4265
4697
|
}
|
|
4266
|
-
|
|
4698
|
+
_context24.next = 6;
|
|
4267
4699
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
4268
4700
|
case 6:
|
|
4269
4701
|
if (!(!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement)) {
|
|
4270
|
-
|
|
4702
|
+
_context24.next = 12;
|
|
4271
4703
|
break;
|
|
4272
4704
|
}
|
|
4273
|
-
|
|
4274
|
-
return this.
|
|
4705
|
+
_context24.next = 9;
|
|
4706
|
+
return this.evaluatePromotion();
|
|
4275
4707
|
case 9:
|
|
4708
|
+
_context24.t0 = _context24.sent;
|
|
4709
|
+
_context24.next = 13;
|
|
4710
|
+
break;
|
|
4711
|
+
case 12:
|
|
4712
|
+
_context24.t0 = null;
|
|
4713
|
+
case 13:
|
|
4714
|
+
promotionPayload = _context24.t0;
|
|
4276
4715
|
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement) {
|
|
4277
4716
|
this.applyDiscount();
|
|
4278
4717
|
}
|
|
4279
4718
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4280
|
-
|
|
4719
|
+
_context24.next = 18;
|
|
4281
4720
|
return this.recalculateSummary({
|
|
4282
4721
|
createIfMissing: true
|
|
4283
4722
|
});
|
|
4284
|
-
case
|
|
4723
|
+
case 18:
|
|
4285
4724
|
this.persistTempOrder();
|
|
4286
|
-
|
|
4725
|
+
this.emitPromotionApplied(promotionPayload);
|
|
4726
|
+
case 20:
|
|
4287
4727
|
case "end":
|
|
4288
|
-
return
|
|
4728
|
+
return _context24.stop();
|
|
4289
4729
|
}
|
|
4290
|
-
},
|
|
4730
|
+
}, _callee22, this);
|
|
4291
4731
|
}));
|
|
4292
|
-
function finalizeProductOrderMutation(
|
|
4732
|
+
function finalizeProductOrderMutation(_x21, _x22) {
|
|
4293
4733
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
4294
4734
|
}
|
|
4295
4735
|
return finalizeProductOrderMutation;
|
|
@@ -4315,7 +4755,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4315
4755
|
_metadata,
|
|
4316
4756
|
_productToAdd$metadat,
|
|
4317
4757
|
_origin,
|
|
4318
|
-
|
|
4758
|
+
_this30 = this;
|
|
4319
4759
|
var linked = booking ? this.createLinkedProductAndBooking({
|
|
4320
4760
|
product: product,
|
|
4321
4761
|
booking: booking
|
|
@@ -4351,26 +4791,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4351
4791
|
var isIncomingCustomItem = ((_productToAdd$metadat = productToAdd.metadata) === null || _productToAdd$metadat === void 0 || (_productToAdd$metadat = _productToAdd$metadat.origin) === null || _productToAdd$metadat === void 0 ? void 0 : _productToAdd$metadat.isCustomItem) === true || ((_origin = productToAdd._origin) === null || _origin === void 0 ? void 0 : _origin.isCustomItem) === true;
|
|
4352
4792
|
var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
4353
4793
|
var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
4354
|
-
if (
|
|
4355
|
-
var isRuntimeEntitlementPass =
|
|
4794
|
+
if (_this30.hasGoodPassDiscount(item)) return false;
|
|
4795
|
+
var isRuntimeEntitlementPass = _this30.isRuntimeEntitlementAppend(item, tempOrder);
|
|
4356
4796
|
if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
|
|
4357
4797
|
return false;
|
|
4358
4798
|
}
|
|
4359
|
-
if (isIncomingEntitlementAppend &&
|
|
4799
|
+
if (isIncomingEntitlementAppend && _this30.isPersistedProductLine(item)) {
|
|
4360
4800
|
return false;
|
|
4361
4801
|
}
|
|
4362
|
-
var hasExistingProductNote =
|
|
4802
|
+
var hasExistingProductNote = _this30.hasOrderProductLineNote(item);
|
|
4363
4803
|
if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
|
|
4364
4804
|
return false;
|
|
4365
4805
|
}
|
|
4366
4806
|
var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
|
|
4367
|
-
if (isRuntimeEntitlementPass && !
|
|
4807
|
+
if (isRuntimeEntitlementPass && !_this30.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
|
|
4368
4808
|
return false;
|
|
4369
4809
|
}
|
|
4370
4810
|
if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
|
|
4371
4811
|
return false;
|
|
4372
4812
|
}
|
|
4373
|
-
if (
|
|
4813
|
+
if (_this30.isPersistedProductLine(item)) return false;
|
|
4374
4814
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
4375
4815
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
4376
4816
|
var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
@@ -4379,8 +4819,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4379
4819
|
var matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
4380
4820
|
var existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
4381
4821
|
var commitProductLine = function commitProductLine(shouldMerge) {
|
|
4822
|
+
var committedProduct;
|
|
4382
4823
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
4383
|
-
|
|
4824
|
+
_this30.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
4384
4825
|
if (linked) {
|
|
4385
4826
|
normalizedIncoming.booking_uid = linked.bookingUid;
|
|
4386
4827
|
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
|
|
@@ -4393,11 +4834,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4393
4834
|
} else {
|
|
4394
4835
|
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products), [normalizedIncoming]);
|
|
4395
4836
|
}
|
|
4837
|
+
committedProduct = normalizedIncoming;
|
|
4396
4838
|
} else {
|
|
4397
4839
|
var _targetProduct$metada;
|
|
4398
4840
|
var targetProduct = matchedProduct;
|
|
4399
4841
|
var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
4400
|
-
var normalizedProduct =
|
|
4842
|
+
var normalizedProduct = _this30.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
4401
4843
|
metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
|
|
4402
4844
|
unique_identification_number: targetUid
|
|
4403
4845
|
})
|
|
@@ -4420,7 +4862,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4420
4862
|
order_detail_id: targetProduct.order_detail_id,
|
|
4421
4863
|
num: nextNum
|
|
4422
4864
|
});
|
|
4423
|
-
|
|
4865
|
+
_this30.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
4866
|
+
committedProduct = tempOrder.products[matchedIndex];
|
|
4424
4867
|
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
4425
4868
|
var mergedProduct = tempOrder.products[matchedIndex];
|
|
4426
4869
|
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, matchedIndex)), _toConsumableArray(tempOrder.products.slice(matchedIndex + 1)), [mergedProduct]);
|
|
@@ -4429,10 +4872,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4429
4872
|
if (linked) {
|
|
4430
4873
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
4431
4874
|
}
|
|
4875
|
+
return committedProduct;
|
|
4432
4876
|
};
|
|
4433
4877
|
if (!matchedProduct) {
|
|
4434
|
-
commitProductLine(false);
|
|
4435
|
-
return;
|
|
4878
|
+
return commitProductLine(false);
|
|
4436
4879
|
}
|
|
4437
4880
|
var shouldMerge = this.shouldMergeProductToOrder({
|
|
4438
4881
|
incomingProduct: productToAdd,
|
|
@@ -4447,7 +4890,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4447
4890
|
if (shouldMerge && _typeof(shouldMerge) === 'object' && typeof shouldMerge.then === 'function') {
|
|
4448
4891
|
return Promise.resolve(shouldMerge).then(commitProductLine);
|
|
4449
4892
|
}
|
|
4450
|
-
commitProductLine(shouldMerge);
|
|
4893
|
+
return commitProductLine(shouldMerge);
|
|
4451
4894
|
}
|
|
4452
4895
|
|
|
4453
4896
|
/**
|
|
@@ -4457,14 +4900,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4457
4900
|
}, {
|
|
4458
4901
|
key: "createSplitBookingLine",
|
|
4459
4902
|
value: function createSplitBookingLine(product, booking, index, splitCount) {
|
|
4460
|
-
var _booking$metadata6,
|
|
4903
|
+
var _booking$metadata6, _ref66, _ref67, _bookingHolder$form_r, _booking$metadata7, _product$metadata10, _bookingHolder$name, _singleBooking$metada;
|
|
4461
4904
|
var singleLine = cloneDeep(product);
|
|
4462
4905
|
singleLine.num = 1;
|
|
4463
4906
|
delete singleLine.product_quantity;
|
|
4464
4907
|
var singleBooking = cloneDeep(booking);
|
|
4465
4908
|
var bookingHolder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
|
|
4466
4909
|
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;
|
|
4467
|
-
var rawHolderIds = (
|
|
4910
|
+
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;
|
|
4468
4911
|
var holderIds = (Array.isArray(rawHolderIds) ? rawHolderIds : [rawHolderIds]).map(function (holderId) {
|
|
4469
4912
|
return holderId && _typeof(holderId) === 'object' ? holderId.form_record_id : holderId;
|
|
4470
4913
|
}).filter(function (holderId) {
|
|
@@ -4528,12 +4971,53 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4528
4971
|
}, {
|
|
4529
4972
|
key: "addProductToOrder",
|
|
4530
4973
|
value: (function () {
|
|
4531
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4532
|
-
var
|
|
4533
|
-
|
|
4534
|
-
|
|
4974
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
|
|
4975
|
+
var _this31 = this;
|
|
4976
|
+
var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref68, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
|
|
4977
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
4978
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
4535
4979
|
case 0:
|
|
4536
4980
|
tempOrder = this.ensureTempOrder();
|
|
4981
|
+
salesNoteDrafts = ((options === null || options === void 0 ? void 0 : options.salesNotes) || []).map(function (draft) {
|
|
4982
|
+
return {
|
|
4983
|
+
note_type: String(draft.note_type || '').trim(),
|
|
4984
|
+
text: {
|
|
4985
|
+
kind: 'resolved',
|
|
4986
|
+
text: buildSalesNoteText(draft.text)
|
|
4987
|
+
}
|
|
4988
|
+
};
|
|
4989
|
+
});
|
|
4990
|
+
mutationSnapshot = salesNoteDrafts.length > 0 ? {
|
|
4991
|
+
products: cloneDeep(tempOrder.products || []),
|
|
4992
|
+
bookings: cloneDeep(tempOrder.bookings || []),
|
|
4993
|
+
notes: cloneDeep(tempOrder.notes || []),
|
|
4994
|
+
extend: cloneDeep(tempOrder._extend || {})
|
|
4995
|
+
} : null;
|
|
4996
|
+
attachSalesNoteDrafts = function attachSalesNoteDrafts(orderProduct) {
|
|
4997
|
+
var _orderProduct$metadat;
|
|
4998
|
+
if (!salesNoteDrafts.length) return;
|
|
4999
|
+
var productLineUid = ((_orderProduct$metadat = orderProduct.metadata) === null || _orderProduct$metadat === void 0 ? void 0 : _orderProduct$metadat.unique_identification_number) || orderProduct.unique_identification_number;
|
|
5000
|
+
if (!productLineUid) {
|
|
5001
|
+
throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
|
|
5002
|
+
}
|
|
5003
|
+
salesNoteDrafts.forEach(function (draft) {
|
|
5004
|
+
_this31.setSalesNoteOnTempOrder(tempOrder, {
|
|
5005
|
+
note_type: draft.note_type,
|
|
5006
|
+
target: {
|
|
5007
|
+
target_type: 'order_detail',
|
|
5008
|
+
target_uuid: String(productLineUid)
|
|
5009
|
+
},
|
|
5010
|
+
text: draft.text
|
|
5011
|
+
});
|
|
5012
|
+
});
|
|
5013
|
+
};
|
|
5014
|
+
rollbackProductAndNotesMutation = function rollbackProductAndNotesMutation() {
|
|
5015
|
+
if (!mutationSnapshot) return;
|
|
5016
|
+
tempOrder.products = mutationSnapshot.products;
|
|
5017
|
+
tempOrder.bookings = mutationSnapshot.bookings;
|
|
5018
|
+
tempOrder.notes = mutationSnapshot.notes;
|
|
5019
|
+
tempOrder._extend = mutationSnapshot.extend;
|
|
5020
|
+
};
|
|
4537
5021
|
insertAfterProductUid = options === null || options === void 0 ? void 0 : options.insertAfterProductUid;
|
|
4538
5022
|
anchorIndex = booking && insertAfterProductUid ? tempOrder.products.findIndex(function (line) {
|
|
4539
5023
|
var _line$metadata;
|
|
@@ -4541,71 +5025,99 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4541
5025
|
return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
|
|
4542
5026
|
}) : -1;
|
|
4543
5027
|
insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
5028
|
+
_context25.prev = 8;
|
|
4544
5029
|
if (!booking) {
|
|
4545
|
-
|
|
5030
|
+
_context25.next = 33;
|
|
4546
5031
|
break;
|
|
4547
5032
|
}
|
|
4548
5033
|
productRecord = product;
|
|
4549
|
-
splitCount = getSafeProductNum((
|
|
5034
|
+
splitCount = getSafeProductNum((_ref68 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref68 !== void 0 ? _ref68 : 1);
|
|
4550
5035
|
if (!(splitCount > 1)) {
|
|
4551
|
-
|
|
5036
|
+
_context25.next = 27;
|
|
4552
5037
|
break;
|
|
4553
5038
|
}
|
|
4554
5039
|
i = 0;
|
|
4555
|
-
case
|
|
5040
|
+
case 14:
|
|
4556
5041
|
if (!(i < splitCount)) {
|
|
4557
|
-
|
|
5042
|
+
_context25.next = 25;
|
|
4558
5043
|
break;
|
|
4559
5044
|
}
|
|
4560
5045
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
4561
|
-
|
|
5046
|
+
if (i > 0) {
|
|
5047
|
+
delete splitLine.product.unique_identification_number;
|
|
5048
|
+
delete splitLine.product.identity_key;
|
|
5049
|
+
if (splitLine.product.metadata) {
|
|
5050
|
+
splitLine.product.metadata = _objectSpread({}, splitLine.product.metadata);
|
|
5051
|
+
delete splitLine.product.metadata.unique_identification_number;
|
|
5052
|
+
delete splitLine.product.metadata.identity_key;
|
|
5053
|
+
}
|
|
5054
|
+
delete splitLine.booking.booking_uid;
|
|
5055
|
+
if (splitLine.booking.metadata) {
|
|
5056
|
+
splitLine.booking.metadata = _objectSpread({}, splitLine.booking.metadata);
|
|
5057
|
+
delete splitLine.booking.metadata.unique_identification_number;
|
|
5058
|
+
}
|
|
5059
|
+
}
|
|
5060
|
+
_context25.next = 19;
|
|
5061
|
+
return this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
4562
5062
|
insertAtIndex: insertAtIndex,
|
|
4563
5063
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
4564
5064
|
});
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
}
|
|
4569
|
-
_context21.next = 15;
|
|
4570
|
-
return _appendResult;
|
|
4571
|
-
case 15:
|
|
5065
|
+
case 19:
|
|
5066
|
+
committedProduct = _context25.sent;
|
|
5067
|
+
attachSalesNoteDrafts(committedProduct);
|
|
4572
5068
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
4573
|
-
case
|
|
5069
|
+
case 22:
|
|
4574
5070
|
i += 1;
|
|
4575
|
-
|
|
5071
|
+
_context25.next = 14;
|
|
4576
5072
|
break;
|
|
4577
|
-
case
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
case
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
5073
|
+
case 25:
|
|
5074
|
+
_context25.next = 31;
|
|
5075
|
+
break;
|
|
5076
|
+
case 27:
|
|
5077
|
+
_context25.next = 29;
|
|
5078
|
+
return this.appendProductLineToTempOrder(tempOrder, product, cloneDeep(booking), {
|
|
4584
5079
|
insertAtIndex: insertAtIndex,
|
|
4585
5080
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
4586
5081
|
});
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
case
|
|
4594
|
-
|
|
5082
|
+
case 29:
|
|
5083
|
+
_committedProduct = _context25.sent;
|
|
5084
|
+
attachSalesNoteDrafts(_committedProduct);
|
|
5085
|
+
case 31:
|
|
5086
|
+
_context25.next = 37;
|
|
5087
|
+
break;
|
|
5088
|
+
case 33:
|
|
5089
|
+
_context25.next = 35;
|
|
5090
|
+
return this.appendProductLineToTempOrder(tempOrder, product, undefined, {
|
|
5091
|
+
insertAtIndex: insertAtIndex,
|
|
5092
|
+
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
|
|
5093
|
+
});
|
|
5094
|
+
case 35:
|
|
5095
|
+
_committedProduct2 = _context25.sent;
|
|
5096
|
+
attachSalesNoteDrafts(_committedProduct2);
|
|
5097
|
+
case 37:
|
|
5098
|
+
_context25.next = 43;
|
|
5099
|
+
break;
|
|
5100
|
+
case 39:
|
|
5101
|
+
_context25.prev = 39;
|
|
5102
|
+
_context25.t0 = _context25["catch"](8);
|
|
5103
|
+
rollbackProductAndNotesMutation();
|
|
5104
|
+
throw _context25.t0;
|
|
5105
|
+
case 43:
|
|
5106
|
+
_context25.next = 45;
|
|
4595
5107
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
4596
|
-
case
|
|
5108
|
+
case 45:
|
|
4597
5109
|
this.logInfo('addProductToOrder success', {
|
|
4598
5110
|
product_id: product.product_id,
|
|
4599
5111
|
with_booking: !!booking
|
|
4600
5112
|
});
|
|
4601
|
-
return
|
|
4602
|
-
case
|
|
5113
|
+
return _context25.abrupt("return", tempOrder.products);
|
|
5114
|
+
case 47:
|
|
4603
5115
|
case "end":
|
|
4604
|
-
return
|
|
5116
|
+
return _context25.stop();
|
|
4605
5117
|
}
|
|
4606
|
-
},
|
|
5118
|
+
}, _callee23, this, [[8, 39]]);
|
|
4607
5119
|
}));
|
|
4608
|
-
function addProductToOrder(
|
|
5120
|
+
function addProductToOrder(_x23, _x24, _x25) {
|
|
4609
5121
|
return _addProductToOrder.apply(this, arguments);
|
|
4610
5122
|
}
|
|
4611
5123
|
return addProductToOrder;
|
|
@@ -4623,101 +5135,101 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4623
5135
|
}, {
|
|
4624
5136
|
key: "addProductsToOrder",
|
|
4625
5137
|
value: (function () {
|
|
4626
|
-
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4627
|
-
var tempOrder, _iterator20, _step20, item, product, booking,
|
|
4628
|
-
return _regeneratorRuntime().wrap(function
|
|
4629
|
-
while (1) switch (
|
|
5138
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(items, options) {
|
|
5139
|
+
var tempOrder, _iterator20, _step20, item, product, booking, _ref69, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
|
|
5140
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
5141
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
4630
5142
|
case 0:
|
|
4631
5143
|
tempOrder = this.ensureTempOrder();
|
|
4632
5144
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
4633
|
-
|
|
5145
|
+
_context26.next = 3;
|
|
4634
5146
|
break;
|
|
4635
5147
|
}
|
|
4636
|
-
return
|
|
5148
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
4637
5149
|
case 3:
|
|
4638
5150
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
4639
|
-
|
|
5151
|
+
_context26.prev = 4;
|
|
4640
5152
|
_iterator20.s();
|
|
4641
5153
|
case 6:
|
|
4642
5154
|
if ((_step20 = _iterator20.n()).done) {
|
|
4643
|
-
|
|
5155
|
+
_context26.next = 32;
|
|
4644
5156
|
break;
|
|
4645
5157
|
}
|
|
4646
5158
|
item = _step20.value;
|
|
4647
5159
|
product = item.product, booking = item.booking;
|
|
4648
5160
|
if (product) {
|
|
4649
|
-
|
|
5161
|
+
_context26.next = 11;
|
|
4650
5162
|
break;
|
|
4651
5163
|
}
|
|
4652
|
-
return
|
|
5164
|
+
return _context26.abrupt("continue", 30);
|
|
4653
5165
|
case 11:
|
|
4654
5166
|
if (!booking) {
|
|
4655
|
-
|
|
5167
|
+
_context26.next = 26;
|
|
4656
5168
|
break;
|
|
4657
5169
|
}
|
|
4658
5170
|
productRecord = product;
|
|
4659
|
-
splitCount = getSafeProductNum((
|
|
5171
|
+
splitCount = getSafeProductNum((_ref69 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref69 !== void 0 ? _ref69 : 1);
|
|
4660
5172
|
if (!(splitCount > 1)) {
|
|
4661
|
-
|
|
5173
|
+
_context26.next = 26;
|
|
4662
5174
|
break;
|
|
4663
5175
|
}
|
|
4664
5176
|
i = 0;
|
|
4665
5177
|
case 16:
|
|
4666
5178
|
if (!(i < splitCount)) {
|
|
4667
|
-
|
|
5179
|
+
_context26.next = 25;
|
|
4668
5180
|
break;
|
|
4669
5181
|
}
|
|
4670
5182
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
4671
|
-
|
|
4672
|
-
if (!
|
|
4673
|
-
|
|
5183
|
+
_appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking);
|
|
5184
|
+
if (!_appendResult) {
|
|
5185
|
+
_context26.next = 22;
|
|
4674
5186
|
break;
|
|
4675
5187
|
}
|
|
4676
|
-
|
|
4677
|
-
return
|
|
5188
|
+
_context26.next = 22;
|
|
5189
|
+
return _appendResult;
|
|
4678
5190
|
case 22:
|
|
4679
5191
|
i += 1;
|
|
4680
|
-
|
|
5192
|
+
_context26.next = 16;
|
|
4681
5193
|
break;
|
|
4682
5194
|
case 25:
|
|
4683
|
-
return
|
|
5195
|
+
return _context26.abrupt("continue", 30);
|
|
4684
5196
|
case 26:
|
|
4685
5197
|
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
4686
5198
|
if (!appendResult) {
|
|
4687
|
-
|
|
5199
|
+
_context26.next = 30;
|
|
4688
5200
|
break;
|
|
4689
5201
|
}
|
|
4690
|
-
|
|
5202
|
+
_context26.next = 30;
|
|
4691
5203
|
return appendResult;
|
|
4692
5204
|
case 30:
|
|
4693
|
-
|
|
5205
|
+
_context26.next = 6;
|
|
4694
5206
|
break;
|
|
4695
5207
|
case 32:
|
|
4696
|
-
|
|
5208
|
+
_context26.next = 37;
|
|
4697
5209
|
break;
|
|
4698
5210
|
case 34:
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
_iterator20.e(
|
|
5211
|
+
_context26.prev = 34;
|
|
5212
|
+
_context26.t0 = _context26["catch"](4);
|
|
5213
|
+
_iterator20.e(_context26.t0);
|
|
4702
5214
|
case 37:
|
|
4703
|
-
|
|
5215
|
+
_context26.prev = 37;
|
|
4704
5216
|
_iterator20.f();
|
|
4705
|
-
return
|
|
5217
|
+
return _context26.finish(37);
|
|
4706
5218
|
case 40:
|
|
4707
|
-
|
|
5219
|
+
_context26.next = 42;
|
|
4708
5220
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
4709
5221
|
case 42:
|
|
4710
5222
|
this.logInfo('addProductsToOrder success', {
|
|
4711
5223
|
itemsCount: items.length
|
|
4712
5224
|
});
|
|
4713
|
-
return
|
|
5225
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
4714
5226
|
case 44:
|
|
4715
5227
|
case "end":
|
|
4716
|
-
return
|
|
5228
|
+
return _context26.stop();
|
|
4717
5229
|
}
|
|
4718
|
-
},
|
|
5230
|
+
}, _callee24, this, [[4, 34, 37, 40]]);
|
|
4719
5231
|
}));
|
|
4720
|
-
function addProductsToOrder(
|
|
5232
|
+
function addProductsToOrder(_x26, _x27) {
|
|
4721
5233
|
return _addProductsToOrder.apply(this, arguments);
|
|
4722
5234
|
}
|
|
4723
5235
|
return addProductsToOrder;
|
|
@@ -4754,41 +5266,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4754
5266
|
}, {
|
|
4755
5267
|
key: "isPersistedProductLine",
|
|
4756
5268
|
value: function isPersistedProductLine(product) {
|
|
4757
|
-
var _product$
|
|
4758
|
-
return product.order_detail_id !== undefined && product.order_detail_id !== null && product.order_detail_id !== '' || ((_product$
|
|
5269
|
+
var _product$metadata11;
|
|
5270
|
+
return product.order_detail_id !== undefined && product.order_detail_id !== null && product.order_detail_id !== '' || ((_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.is_edit_for_runtime) === true;
|
|
4759
5271
|
}
|
|
4760
5272
|
}, {
|
|
4761
5273
|
key: "isRuntimeEntitlementAppend",
|
|
4762
5274
|
value: function isRuntimeEntitlementAppend(product, tempOrder) {
|
|
4763
|
-
var _product$metadata$uni, _product$
|
|
5275
|
+
var _product$metadata$uni, _product$metadata12, _tempOrder$_extend10, _product$_origin;
|
|
4764
5276
|
if (this.isPersistedProductLine(product)) return false;
|
|
4765
|
-
var uid = (_product$metadata$uni = (_product$
|
|
4766
|
-
var storedOrigin = uid !== undefined && uid !== null && uid !== '' ? (_tempOrder$
|
|
5277
|
+
var uid = (_product$metadata$uni = (_product$metadata12 = product.metadata) === null || _product$metadata12 === void 0 ? void 0 : _product$metadata12.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product.unique_identification_number;
|
|
5278
|
+
var storedOrigin = uid !== undefined && uid !== null && uid !== '' ? (_tempOrder$_extend10 = tempOrder._extend) === null || _tempOrder$_extend10 === void 0 || (_tempOrder$_extend10 = _tempOrder$_extend10.productsByUid) === null || _tempOrder$_extend10 === void 0 || (_tempOrder$_extend10 = _tempOrder$_extend10[String(uid)]) === null || _tempOrder$_extend10 === void 0 ? void 0 : _tempOrder$_extend10.origin : undefined;
|
|
4767
5279
|
return Boolean((product === null || product === void 0 || (_product$_origin = product._origin) === null || _product$_origin === void 0 ? void 0 : _product$_origin.__entitlementPassRuntimeAppend) === true || (storedOrigin === null || storedOrigin === void 0 ? void 0 : storedOrigin.__entitlementPassRuntimeAppend) === true);
|
|
4768
5280
|
}
|
|
4769
5281
|
}, {
|
|
4770
5282
|
key: "hasSameEntitlementMergePriceConfig",
|
|
4771
5283
|
value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
|
|
4772
|
-
var
|
|
5284
|
+
var _this32 = this;
|
|
4773
5285
|
var buildPriceConfig = function buildPriceConfig(product) {
|
|
4774
5286
|
var metadata = product.metadata || {};
|
|
4775
5287
|
var bundle = (product.product_bundle || []).map(function (item) {
|
|
4776
|
-
var
|
|
5288
|
+
var _ref70, _item$bundle_id, _ref71, _ref72, _item$bundle_product_, _ref73, _item$bundle_variant_, _ref74, _item$price_type, _ref75, _item$price_type_ext;
|
|
4777
5289
|
return {
|
|
4778
|
-
bundle_id: (
|
|
4779
|
-
bundle_product_id: (
|
|
4780
|
-
bundle_variant_id: (
|
|
4781
|
-
price_type: (
|
|
4782
|
-
price_type_ext: (
|
|
5290
|
+
bundle_id: (_ref70 = (_item$bundle_id = item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item.id) !== null && _ref70 !== void 0 ? _ref70 : null,
|
|
5291
|
+
bundle_product_id: (_ref71 = (_ref72 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref72 !== void 0 ? _ref72 : item.product_id) !== null && _ref71 !== void 0 ? _ref71 : null,
|
|
5292
|
+
bundle_variant_id: (_ref73 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.product_variant_id) !== null && _ref73 !== void 0 ? _ref73 : 0,
|
|
5293
|
+
price_type: (_ref74 = (_item$price_type = item.price_type) !== null && _item$price_type !== void 0 ? _item$price_type : item.custom_price_type) !== null && _ref74 !== void 0 ? _ref74 : '',
|
|
5294
|
+
price_type_ext: (_ref75 = (_item$price_type_ext = item.price_type_ext) !== null && _item$price_type_ext !== void 0 ? _item$price_type_ext : item.custom_price_type_ext) !== null && _ref75 !== void 0 ? _ref75 : ''
|
|
4783
5295
|
};
|
|
4784
5296
|
}).sort(function (left, right) {
|
|
4785
5297
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
4786
5298
|
});
|
|
4787
5299
|
return JSON.stringify({
|
|
4788
|
-
original_price:
|
|
4789
|
-
source_product_price:
|
|
4790
|
-
main_product_original_price:
|
|
4791
|
-
price_override:
|
|
5300
|
+
original_price: _this32.normalizeFingerprintMoney(product.original_price),
|
|
5301
|
+
source_product_price: _this32.normalizeFingerprintMoney(metadata.source_product_price),
|
|
5302
|
+
main_product_original_price: _this32.normalizeFingerprintMoney(metadata.main_product_original_price),
|
|
5303
|
+
price_override: _this32.normalizeFingerprintMoney(metadata.price_override),
|
|
4792
5304
|
is_manual_discount: Boolean(metadata.is_manual_discount),
|
|
4793
5305
|
bundle: bundle
|
|
4794
5306
|
});
|
|
@@ -4798,24 +5310,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4798
5310
|
}, {
|
|
4799
5311
|
key: "getBundleRuntimeIdentity",
|
|
4800
5312
|
value: function getBundleRuntimeIdentity(bundle) {
|
|
4801
|
-
var
|
|
5313
|
+
var _ref76, _bundle$bundle_id2, _ref77, _bundle$bundle_group_2, _ref78, _ref79, _bundle$bundle_produc3, _ref80, _bundle$bundle_varian3;
|
|
4802
5314
|
if (!bundle || _typeof(bundle) !== 'object') return '';
|
|
4803
|
-
return [(
|
|
5315
|
+
return [(_ref76 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref76 !== void 0 ? _ref76 : '', (_ref77 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref77 !== void 0 ? _ref77 : '', (_ref78 = (_ref79 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref79 !== void 0 ? _ref79 : bundle.product_id) !== null && _ref78 !== void 0 ? _ref78 : '', (_ref80 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref80 !== void 0 ? _ref80 : 0].join('|');
|
|
4804
5316
|
}
|
|
4805
5317
|
}, {
|
|
4806
5318
|
key: "preservePersistedBundlePriceFields",
|
|
4807
5319
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
4808
|
-
var
|
|
5320
|
+
var _this33 = this;
|
|
4809
5321
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
4810
5322
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
4811
5323
|
var previousByIdentity = new Map();
|
|
4812
5324
|
previousBundles.forEach(function (bundle) {
|
|
4813
|
-
var identity =
|
|
5325
|
+
var identity = _this33.getBundleRuntimeIdentity(bundle);
|
|
4814
5326
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
4815
5327
|
});
|
|
4816
5328
|
return nextBundles.map(function (bundle, index) {
|
|
4817
5329
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
4818
|
-
var previous = previousByIdentity.get(
|
|
5330
|
+
var previous = previousByIdentity.get(_this33.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
4819
5331
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
4820
5332
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
4821
5333
|
cover: previous.cover
|
|
@@ -4951,13 +5463,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4951
5463
|
delete nextProduct.metadata.main_product_original_price;
|
|
4952
5464
|
delete nextProduct.metadata.price_schema_version;
|
|
4953
5465
|
} else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4954
|
-
var
|
|
5466
|
+
var _ref81, _targetProduct$metada10, _targetProduct$metada11, _ref82, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
|
|
4955
5467
|
// 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
|
|
4956
5468
|
// 但必须让 original 与 selling 一起随新的 option 金额移动。
|
|
4957
5469
|
var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
|
|
4958
5470
|
var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
|
|
4959
|
-
var _previousMainOriginal = new Decimal(Number((
|
|
4960
|
-
var _previousMainSelling = new Decimal(Number((
|
|
5471
|
+
var _previousMainOriginal = new Decimal(Number((_ref81 = (_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 && _ref81 !== void 0 ? _ref81 : 0) || 0);
|
|
5472
|
+
var _previousMainSelling = new Decimal(Number((_ref82 = (_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 && _ref82 !== void 0 ? _ref82 : _previousMainOriginal.toNumber()) || 0);
|
|
4961
5473
|
var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
|
|
4962
5474
|
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);
|
|
4963
5475
|
var _nextMainOriginal = previousSource.plus(nextOptionSum);
|
|
@@ -5016,37 +5528,39 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5016
5528
|
}, {
|
|
5017
5529
|
key: "updateOrderProduct",
|
|
5018
5530
|
value: function () {
|
|
5019
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5020
|
-
var tempOrder, updatedProductUid;
|
|
5021
|
-
return _regeneratorRuntime().wrap(function
|
|
5022
|
-
while (1) switch (
|
|
5531
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
5532
|
+
var tempOrder, updatedProductUid, promotionPayload;
|
|
5533
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context27) {
|
|
5534
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
5023
5535
|
case 0:
|
|
5024
5536
|
tempOrder = this.ensureTempOrder();
|
|
5025
5537
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
5026
|
-
|
|
5027
|
-
return this.
|
|
5538
|
+
_context27.next = 4;
|
|
5539
|
+
return this.evaluatePromotion();
|
|
5028
5540
|
case 4:
|
|
5541
|
+
promotionPayload = _context27.sent;
|
|
5029
5542
|
this.applyDiscount({
|
|
5030
5543
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
5031
5544
|
});
|
|
5032
5545
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5033
|
-
|
|
5546
|
+
_context27.next = 9;
|
|
5034
5547
|
return this.recalculateSummary({
|
|
5035
5548
|
createIfMissing: true
|
|
5036
5549
|
});
|
|
5037
|
-
case
|
|
5550
|
+
case 9:
|
|
5038
5551
|
this.persistTempOrder();
|
|
5552
|
+
this.emitPromotionApplied(promotionPayload);
|
|
5039
5553
|
this.logInfo('updateOrderProduct success', {
|
|
5040
5554
|
params: params
|
|
5041
5555
|
});
|
|
5042
|
-
return
|
|
5043
|
-
case
|
|
5556
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
5557
|
+
case 13:
|
|
5044
5558
|
case "end":
|
|
5045
|
-
return
|
|
5559
|
+
return _context27.stop();
|
|
5046
5560
|
}
|
|
5047
|
-
},
|
|
5561
|
+
}, _callee25, this);
|
|
5048
5562
|
}));
|
|
5049
|
-
function updateOrderProduct(
|
|
5563
|
+
function updateOrderProduct(_x28) {
|
|
5050
5564
|
return _updateOrderProduct.apply(this, arguments);
|
|
5051
5565
|
}
|
|
5052
5566
|
return updateOrderProduct;
|
|
@@ -5054,28 +5568,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5054
5568
|
}, {
|
|
5055
5569
|
key: "updateOrderProducts",
|
|
5056
5570
|
value: function () {
|
|
5057
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5058
|
-
var
|
|
5571
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
|
|
5572
|
+
var _this34 = this;
|
|
5059
5573
|
var tempOrder, reapplyBookingDiscountProductUids;
|
|
5060
|
-
return _regeneratorRuntime().wrap(function
|
|
5061
|
-
while (1) switch (
|
|
5574
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
5575
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
5062
5576
|
case 0:
|
|
5063
5577
|
tempOrder = this.ensureTempOrder();
|
|
5064
5578
|
if (paramsList.length) {
|
|
5065
|
-
|
|
5579
|
+
_context28.next = 3;
|
|
5066
5580
|
break;
|
|
5067
5581
|
}
|
|
5068
|
-
return
|
|
5582
|
+
return _context28.abrupt("return", tempOrder.products);
|
|
5069
5583
|
case 3:
|
|
5070
5584
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
5071
|
-
var updatedProductUid =
|
|
5585
|
+
var updatedProductUid = _this34.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
5072
5586
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
5073
5587
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
5074
5588
|
acc.push(String(updatedProductUid));
|
|
5075
5589
|
}
|
|
5076
5590
|
return acc;
|
|
5077
5591
|
}, []);
|
|
5078
|
-
|
|
5592
|
+
_context28.next = 6;
|
|
5079
5593
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
5080
5594
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
5081
5595
|
});
|
|
@@ -5083,14 +5597,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5083
5597
|
this.logInfo('updateOrderProduct success', {
|
|
5084
5598
|
paramsList: paramsList
|
|
5085
5599
|
});
|
|
5086
|
-
return
|
|
5600
|
+
return _context28.abrupt("return", tempOrder.products);
|
|
5087
5601
|
case 8:
|
|
5088
5602
|
case "end":
|
|
5089
|
-
return
|
|
5603
|
+
return _context28.stop();
|
|
5090
5604
|
}
|
|
5091
|
-
},
|
|
5605
|
+
}, _callee26, this);
|
|
5092
5606
|
}));
|
|
5093
|
-
function updateOrderProducts(
|
|
5607
|
+
function updateOrderProducts(_x29) {
|
|
5094
5608
|
return _updateOrderProducts.apply(this, arguments);
|
|
5095
5609
|
}
|
|
5096
5610
|
return updateOrderProducts;
|
|
@@ -5098,11 +5612,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5098
5612
|
}, {
|
|
5099
5613
|
key: "updateOrderProductQuantity",
|
|
5100
5614
|
value: function () {
|
|
5101
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5615
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
5102
5616
|
var _targetProduct$metada17;
|
|
5103
|
-
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, isPersistedOrderLine, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance;
|
|
5104
|
-
return _regeneratorRuntime().wrap(function
|
|
5105
|
-
while (1) switch (
|
|
5617
|
+
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, isPersistedOrderLine, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance, isVirtualSettlement, promotionPayload;
|
|
5618
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context29) {
|
|
5619
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
5106
5620
|
case 0:
|
|
5107
5621
|
product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
|
|
5108
5622
|
tempOrder = this.ensureTempOrder();
|
|
@@ -5132,7 +5646,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5132
5646
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
5133
5647
|
}
|
|
5134
5648
|
if (!(productIndex === -1)) {
|
|
5135
|
-
|
|
5649
|
+
_context29.next = 13;
|
|
5136
5650
|
break;
|
|
5137
5651
|
}
|
|
5138
5652
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -5148,7 +5662,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5148
5662
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
5149
5663
|
settlementSnapshot = getSelectedSettlementSnapshot(normalizedProduct);
|
|
5150
5664
|
if (!(this.isMultiCurrencySettlementEnabled() && (settlementSnapshot === null || settlementSnapshot === void 0 ? void 0 : settlementSnapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1)) {
|
|
5151
|
-
|
|
5665
|
+
_context29.next = 27;
|
|
5152
5666
|
break;
|
|
5153
5667
|
}
|
|
5154
5668
|
currencyProductId = Number(settlementSnapshot.currency_product_id);
|
|
@@ -5156,7 +5670,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5156
5670
|
return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
|
|
5157
5671
|
});
|
|
5158
5672
|
if (asset) {
|
|
5159
|
-
|
|
5673
|
+
_context29.next = 23;
|
|
5160
5674
|
break;
|
|
5161
5675
|
}
|
|
5162
5676
|
throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
|
|
@@ -5168,40 +5682,50 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5168
5682
|
}, new Decimal(0));
|
|
5169
5683
|
balance = new Decimal(asset.balance || 0);
|
|
5170
5684
|
if (!balance.lt(requiredAmount)) {
|
|
5171
|
-
|
|
5685
|
+
_context29.next = 27;
|
|
5172
5686
|
break;
|
|
5173
5687
|
}
|
|
5174
5688
|
throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
5175
5689
|
case 27:
|
|
5176
5690
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
5177
5691
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
5178
|
-
|
|
5179
|
-
|
|
5692
|
+
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
5693
|
+
if (isVirtualSettlement) {
|
|
5694
|
+
_context29.next = 36;
|
|
5180
5695
|
break;
|
|
5181
5696
|
}
|
|
5182
|
-
|
|
5183
|
-
return this.
|
|
5184
|
-
case 32:
|
|
5185
|
-
this.applyDiscount();
|
|
5697
|
+
_context29.next = 33;
|
|
5698
|
+
return this.evaluatePromotion();
|
|
5186
5699
|
case 33:
|
|
5700
|
+
_context29.t0 = _context29.sent;
|
|
5701
|
+
_context29.next = 37;
|
|
5702
|
+
break;
|
|
5703
|
+
case 36:
|
|
5704
|
+
_context29.t0 = null;
|
|
5705
|
+
case 37:
|
|
5706
|
+
promotionPayload = _context29.t0;
|
|
5707
|
+
if (!isVirtualSettlement) {
|
|
5708
|
+
this.applyDiscount();
|
|
5709
|
+
}
|
|
5187
5710
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5188
|
-
|
|
5711
|
+
_context29.next = 42;
|
|
5189
5712
|
return this.recalculateSummary({
|
|
5190
5713
|
createIfMissing: true
|
|
5191
5714
|
});
|
|
5192
|
-
case
|
|
5715
|
+
case 42:
|
|
5193
5716
|
this.persistTempOrder();
|
|
5717
|
+
this.emitPromotionApplied(promotionPayload);
|
|
5194
5718
|
this.logInfo('updateOrderProductQuantity success', {
|
|
5195
5719
|
params: params
|
|
5196
5720
|
});
|
|
5197
|
-
return
|
|
5198
|
-
case
|
|
5721
|
+
return _context29.abrupt("return", tempOrder.products);
|
|
5722
|
+
case 46:
|
|
5199
5723
|
case "end":
|
|
5200
|
-
return
|
|
5724
|
+
return _context29.stop();
|
|
5201
5725
|
}
|
|
5202
|
-
},
|
|
5726
|
+
}, _callee27, this);
|
|
5203
5727
|
}));
|
|
5204
|
-
function updateOrderProductQuantity(
|
|
5728
|
+
function updateOrderProductQuantity(_x30) {
|
|
5205
5729
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
5206
5730
|
}
|
|
5207
5731
|
return updateOrderProductQuantity;
|
|
@@ -5242,31 +5766,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5242
5766
|
}, {
|
|
5243
5767
|
key: "finalizeAfterProductsMutation",
|
|
5244
5768
|
value: (function () {
|
|
5245
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5246
|
-
|
|
5247
|
-
|
|
5769
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(tempOrder, options) {
|
|
5770
|
+
var promotionPayload;
|
|
5771
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context30) {
|
|
5772
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
5248
5773
|
case 0:
|
|
5249
5774
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
5250
|
-
|
|
5251
|
-
return this.
|
|
5775
|
+
_context30.next = 3;
|
|
5776
|
+
return this.evaluatePromotion();
|
|
5252
5777
|
case 3:
|
|
5778
|
+
promotionPayload = _context30.sent;
|
|
5253
5779
|
this.applyDiscount({
|
|
5254
5780
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
5255
5781
|
});
|
|
5256
5782
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5257
|
-
|
|
5783
|
+
_context30.next = 8;
|
|
5258
5784
|
return this.recalculateSummary({
|
|
5259
5785
|
createIfMissing: true
|
|
5260
5786
|
});
|
|
5261
|
-
case 7:
|
|
5262
|
-
this.persistTempOrder();
|
|
5263
5787
|
case 8:
|
|
5788
|
+
this.persistTempOrder();
|
|
5789
|
+
this.emitPromotionApplied(promotionPayload);
|
|
5790
|
+
case 10:
|
|
5264
5791
|
case "end":
|
|
5265
|
-
return
|
|
5792
|
+
return _context30.stop();
|
|
5266
5793
|
}
|
|
5267
|
-
},
|
|
5794
|
+
}, _callee28, this);
|
|
5268
5795
|
}));
|
|
5269
|
-
function finalizeAfterProductsMutation(
|
|
5796
|
+
function finalizeAfterProductsMutation(_x31, _x32) {
|
|
5270
5797
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
5271
5798
|
}
|
|
5272
5799
|
return finalizeAfterProductsMutation;
|
|
@@ -5281,20 +5808,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5281
5808
|
}, {
|
|
5282
5809
|
key: "removeProductsFromOrder",
|
|
5283
5810
|
value: (function () {
|
|
5284
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5285
|
-
var
|
|
5811
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
|
|
5812
|
+
var _this35 = this;
|
|
5286
5813
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
5287
|
-
return _regeneratorRuntime().wrap(function
|
|
5288
|
-
while (1) switch (
|
|
5814
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
5815
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
5289
5816
|
case 0:
|
|
5290
5817
|
tempOrder = this.ensureTempOrder();
|
|
5291
|
-
this.repairDuplicateProductLineIdentities(tempOrder);
|
|
5292
5818
|
if (identities.length) {
|
|
5293
|
-
|
|
5819
|
+
_context32.next = 3;
|
|
5294
5820
|
break;
|
|
5295
5821
|
}
|
|
5296
|
-
return
|
|
5297
|
-
case
|
|
5822
|
+
return _context32.abrupt("return", tempOrder.products);
|
|
5823
|
+
case 3:
|
|
5824
|
+
// 商品删除会同步删除以商品行为主关系的 Notes;快照不完整时禁止产生孤儿 Relation。
|
|
5825
|
+
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
5826
|
+
this.repairDuplicateProductLineIdentities(tempOrder);
|
|
5298
5827
|
productsBeforeRemove = tempOrder.products || [];
|
|
5299
5828
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
5300
5829
|
preserveDisplayPosition = options === null || options === void 0 ? void 0 : options.preserveDisplayPosition;
|
|
@@ -5323,29 +5852,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5323
5852
|
}
|
|
5324
5853
|
linkedBookingUidsToRemove = new Set();
|
|
5325
5854
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
5326
|
-
|
|
5855
|
+
_context32.prev = 16;
|
|
5327
5856
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
5328
5857
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
5329
5858
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
5330
|
-
return _regeneratorRuntime().wrap(function _loop3$(
|
|
5331
|
-
while (1) switch (
|
|
5859
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context31) {
|
|
5860
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
5332
5861
|
case 0:
|
|
5333
5862
|
product = _step21.value;
|
|
5334
5863
|
productUid = (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
5335
5864
|
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata12 = product.metadata) === null || _metadata12 === void 0 ? void 0 : _metadata12.booking_uid);
|
|
5336
5865
|
isAddTimeProduct = (product === null || product === void 0 || (_metadata13 = product.metadata) === null || _metadata13 === void 0 ? void 0 : _metadata13.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata14 = product.metadata) === null || _metadata14 === void 0 ? void 0 : _metadata14.product_add_schedule_time) !== null;
|
|
5337
5866
|
if (!isAddTimeProduct) {
|
|
5338
|
-
|
|
5867
|
+
_context31.next = 6;
|
|
5339
5868
|
break;
|
|
5340
5869
|
}
|
|
5341
|
-
return
|
|
5870
|
+
return _context31.abrupt("return", 1);
|
|
5342
5871
|
case 6:
|
|
5343
5872
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
5344
5873
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
5345
5874
|
}
|
|
5346
5875
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
5347
5876
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
5348
|
-
var bookingUid =
|
|
5877
|
+
var bookingUid = _this35.getBookingUniqueIdentificationNumber(booking);
|
|
5349
5878
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
5350
5879
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
5351
5880
|
}
|
|
@@ -5353,38 +5882,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5353
5882
|
}
|
|
5354
5883
|
case 8:
|
|
5355
5884
|
case "end":
|
|
5356
|
-
return
|
|
5885
|
+
return _context31.stop();
|
|
5357
5886
|
}
|
|
5358
5887
|
}, _loop3);
|
|
5359
5888
|
});
|
|
5360
5889
|
_iterator21.s();
|
|
5361
|
-
case
|
|
5890
|
+
case 19:
|
|
5362
5891
|
if ((_step21 = _iterator21.n()).done) {
|
|
5363
|
-
|
|
5892
|
+
_context32.next = 25;
|
|
5364
5893
|
break;
|
|
5365
5894
|
}
|
|
5366
|
-
return
|
|
5367
|
-
case
|
|
5368
|
-
if (!
|
|
5369
|
-
|
|
5895
|
+
return _context32.delegateYield(_loop3(), "t0", 21);
|
|
5896
|
+
case 21:
|
|
5897
|
+
if (!_context32.t0) {
|
|
5898
|
+
_context32.next = 23;
|
|
5370
5899
|
break;
|
|
5371
5900
|
}
|
|
5372
|
-
return
|
|
5373
|
-
case
|
|
5374
|
-
|
|
5901
|
+
return _context32.abrupt("continue", 23);
|
|
5902
|
+
case 23:
|
|
5903
|
+
_context32.next = 19;
|
|
5375
5904
|
break;
|
|
5376
|
-
case
|
|
5377
|
-
|
|
5905
|
+
case 25:
|
|
5906
|
+
_context32.next = 30;
|
|
5378
5907
|
break;
|
|
5379
|
-
case
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
_iterator21.e(
|
|
5383
|
-
case
|
|
5384
|
-
|
|
5908
|
+
case 27:
|
|
5909
|
+
_context32.prev = 27;
|
|
5910
|
+
_context32.t1 = _context32["catch"](16);
|
|
5911
|
+
_iterator21.e(_context32.t1);
|
|
5912
|
+
case 30:
|
|
5913
|
+
_context32.prev = 30;
|
|
5385
5914
|
_iterator21.f();
|
|
5386
|
-
return
|
|
5387
|
-
case
|
|
5915
|
+
return _context32.finish(30);
|
|
5916
|
+
case 33:
|
|
5388
5917
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
5389
5918
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
5390
5919
|
tempOrder.products = (tempOrder.products || []).filter(function (line) {
|
|
@@ -5410,20 +5939,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5410
5939
|
tempOrder.products = nextProductIndex >= 0 ? [].concat(_toConsumableArray(productsWithoutRemaining.slice(0, nextProductIndex)), [remainingProduct], _toConsumableArray(productsWithoutRemaining.slice(nextProductIndex))) : [].concat(_toConsumableArray(productsWithoutRemaining), [remainingProduct]);
|
|
5411
5940
|
}
|
|
5412
5941
|
}
|
|
5413
|
-
|
|
5942
|
+
this.removeSalesNotesForMissingProductLines(tempOrder);
|
|
5943
|
+
_context32.next = 38;
|
|
5414
5944
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
5415
|
-
case
|
|
5945
|
+
case 38:
|
|
5416
5946
|
this.logInfo('removeProductsFromOrder success', {
|
|
5417
5947
|
identities: identities
|
|
5418
5948
|
});
|
|
5419
|
-
return
|
|
5420
|
-
case
|
|
5949
|
+
return _context32.abrupt("return", tempOrder.products);
|
|
5950
|
+
case 40:
|
|
5421
5951
|
case "end":
|
|
5422
|
-
return
|
|
5952
|
+
return _context32.stop();
|
|
5423
5953
|
}
|
|
5424
|
-
},
|
|
5954
|
+
}, _callee29, this, [[16, 27, 30, 33]]);
|
|
5425
5955
|
}));
|
|
5426
|
-
function removeProductsFromOrder(
|
|
5956
|
+
function removeProductsFromOrder(_x33, _x34) {
|
|
5427
5957
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
5428
5958
|
}
|
|
5429
5959
|
return removeProductsFromOrder;
|
|
@@ -5431,62 +5961,66 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5431
5961
|
}, {
|
|
5432
5962
|
key: "removeProductFromOrder",
|
|
5433
5963
|
value: function () {
|
|
5434
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5435
|
-
return _regeneratorRuntime().wrap(function
|
|
5436
|
-
while (1) switch (
|
|
5964
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(identity, options) {
|
|
5965
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
5966
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
5437
5967
|
case 0:
|
|
5438
|
-
return
|
|
5968
|
+
return _context33.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
5439
5969
|
case 1:
|
|
5440
5970
|
case "end":
|
|
5441
|
-
return
|
|
5971
|
+
return _context33.stop();
|
|
5442
5972
|
}
|
|
5443
|
-
},
|
|
5973
|
+
}, _callee30, this);
|
|
5444
5974
|
}));
|
|
5445
|
-
function removeProductFromOrder(
|
|
5975
|
+
function removeProductFromOrder(_x35, _x36) {
|
|
5446
5976
|
return _removeProductFromOrder.apply(this, arguments);
|
|
5447
5977
|
}
|
|
5448
5978
|
return removeProductFromOrder;
|
|
5449
5979
|
}()
|
|
5450
5980
|
/**
|
|
5451
5981
|
* 仅清空购物车行(products / bookings),不重置整单。
|
|
5452
|
-
*
|
|
5982
|
+
* 普通整单 note 保持不变;以商品行为主体的 Sales Notes 同步删除。
|
|
5453
5983
|
*/
|
|
5454
5984
|
}, {
|
|
5455
5985
|
key: "clearOrderCartLines",
|
|
5456
5986
|
value: (function () {
|
|
5457
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5458
|
-
var tempOrder;
|
|
5459
|
-
return _regeneratorRuntime().wrap(function
|
|
5460
|
-
while (1) switch (
|
|
5987
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
5988
|
+
var tempOrder, promotionPayload;
|
|
5989
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
5990
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
5461
5991
|
case 0:
|
|
5462
5992
|
tempOrder = this.ensureTempOrder();
|
|
5993
|
+
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
5463
5994
|
tempOrder.products = [];
|
|
5464
5995
|
tempOrder.bookings = [];
|
|
5465
5996
|
releaseTempOrderSettlementState(tempOrder);
|
|
5997
|
+
this.removeSalesNotesForMissingProductLines(tempOrder);
|
|
5466
5998
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
5467
5999
|
if (tempOrder._extend && _typeof(tempOrder._extend) === 'object') {
|
|
5468
6000
|
tempOrder._extend = _objectSpread(_objectSpread({}, tempOrder._extend), {}, {
|
|
5469
6001
|
productsByUid: {}
|
|
5470
6002
|
});
|
|
5471
6003
|
}
|
|
5472
|
-
|
|
5473
|
-
return this.
|
|
5474
|
-
case
|
|
6004
|
+
_context34.next = 10;
|
|
6005
|
+
return this.evaluatePromotion();
|
|
6006
|
+
case 10:
|
|
6007
|
+
promotionPayload = _context34.sent;
|
|
5475
6008
|
this.applyDiscount();
|
|
5476
6009
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5477
|
-
|
|
6010
|
+
_context34.next = 15;
|
|
5478
6011
|
return this.recalculateSummary({
|
|
5479
6012
|
createIfMissing: true
|
|
5480
6013
|
});
|
|
5481
|
-
case
|
|
6014
|
+
case 15:
|
|
5482
6015
|
this.persistTempOrder();
|
|
6016
|
+
this.emitPromotionApplied(promotionPayload);
|
|
5483
6017
|
this.logInfo('clearOrderCartLines success', {});
|
|
5484
|
-
return
|
|
5485
|
-
case
|
|
6018
|
+
return _context34.abrupt("return", tempOrder);
|
|
6019
|
+
case 19:
|
|
5486
6020
|
case "end":
|
|
5487
|
-
return
|
|
6021
|
+
return _context34.stop();
|
|
5488
6022
|
}
|
|
5489
|
-
},
|
|
6023
|
+
}, _callee31, this);
|
|
5490
6024
|
}));
|
|
5491
6025
|
function clearOrderCartLines() {
|
|
5492
6026
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -5500,15 +6034,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5500
6034
|
}, {
|
|
5501
6035
|
key: "clearOrderForSettlementSwitch",
|
|
5502
6036
|
value: (function () {
|
|
5503
|
-
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6037
|
+
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
5504
6038
|
var _this$store$discount22, _this$store$discount23;
|
|
5505
6039
|
var tempOrder;
|
|
5506
|
-
return _regeneratorRuntime().wrap(function
|
|
5507
|
-
while (1) switch (
|
|
6040
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context35) {
|
|
6041
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
5508
6042
|
case 0:
|
|
5509
6043
|
tempOrder = this.ensureTempOrder();
|
|
6044
|
+
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
5510
6045
|
tempOrder.products = [];
|
|
5511
6046
|
tempOrder.bookings = [];
|
|
6047
|
+
this.removeSalesNotesForMissingProductLines(tempOrder);
|
|
5512
6048
|
tempOrder.discount_list = [];
|
|
5513
6049
|
tempOrder.payments = [];
|
|
5514
6050
|
tempOrder.refunds = [];
|
|
@@ -5521,28 +6057,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5521
6057
|
productsByUid: {}
|
|
5522
6058
|
});
|
|
5523
6059
|
}
|
|
5524
|
-
|
|
6060
|
+
_context35.next = 15;
|
|
5525
6061
|
return (_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.setDiscountList([]);
|
|
5526
|
-
case 13:
|
|
5527
|
-
_context31.next = 15;
|
|
5528
|
-
return (_this$store$discount23 = this.store.discount) === null || _this$store$discount23 === void 0 ? void 0 : _this$store$discount23.setOriginalDiscountList([]);
|
|
5529
6062
|
case 15:
|
|
6063
|
+
_context35.next = 17;
|
|
6064
|
+
return (_this$store$discount23 = this.store.discount) === null || _this$store$discount23 === void 0 ? void 0 : _this$store$discount23.setOriginalDiscountList([]);
|
|
6065
|
+
case 17:
|
|
5530
6066
|
this.hasActiveCustomerBoundDiscount = false;
|
|
5531
6067
|
this.lastUnfulfilledPromotions = [];
|
|
5532
6068
|
this.lastGiftActions = null;
|
|
5533
|
-
|
|
6069
|
+
_context35.next = 22;
|
|
5534
6070
|
return this.recalculateSummary({
|
|
5535
6071
|
createIfMissing: true
|
|
5536
6072
|
});
|
|
5537
|
-
case
|
|
6073
|
+
case 22:
|
|
5538
6074
|
this.persistTempOrder();
|
|
5539
6075
|
this.logInfo('clearOrderForSettlementSwitch success', {});
|
|
5540
|
-
return
|
|
5541
|
-
case
|
|
6076
|
+
return _context35.abrupt("return", tempOrder);
|
|
6077
|
+
case 25:
|
|
5542
6078
|
case "end":
|
|
5543
|
-
return
|
|
6079
|
+
return _context35.stop();
|
|
5544
6080
|
}
|
|
5545
|
-
},
|
|
6081
|
+
}, _callee32, this);
|
|
5546
6082
|
}));
|
|
5547
6083
|
function clearOrderForSettlementSwitch() {
|
|
5548
6084
|
return _clearOrderForSettlementSwitch.apply(this, arguments);
|
|
@@ -5553,23 +6089,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5553
6089
|
}, {
|
|
5554
6090
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
5555
6091
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
5556
|
-
var _params$cacheId, _this$otherParams5,
|
|
6092
|
+
var _params$cacheId, _this$otherParams5, _ref83, _params$businessCode, _this$otherParams6, _this$otherParams7;
|
|
5557
6093
|
var tempOrder = this.ensureTempOrder();
|
|
5558
6094
|
this.persistTempOrder();
|
|
5559
6095
|
var payload = buildSubmitPayload({
|
|
5560
6096
|
tempOrder: tempOrder,
|
|
5561
6097
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
5562
6098
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
|
|
5563
|
-
businessCode: (
|
|
6099
|
+
businessCode: (_ref83 = (_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 && _ref83 !== void 0 ? _ref83 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
|
|
5564
6100
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5565
6101
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
5566
6102
|
summary: this.store.summary || createEmptySummary(),
|
|
5567
6103
|
enhance: function enhance(nextPayload) {
|
|
5568
|
-
var
|
|
6104
|
+
var _ref84, _tempOrder$order_numb, _ref85, _tempOrder$shop_order2, _ref86, _tempOrder$shop_full_;
|
|
5569
6105
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
5570
|
-
order_number: (
|
|
5571
|
-
shop_order_number: (
|
|
5572
|
-
shop_full_order_number: (
|
|
6106
|
+
order_number: (_ref84 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref84 !== void 0 ? _ref84 : null,
|
|
6107
|
+
shop_order_number: (_ref85 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref85 !== void 0 ? _ref85 : null,
|
|
6108
|
+
shop_full_order_number: (_ref86 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref86 !== void 0 ? _ref86 : null,
|
|
5573
6109
|
small_ticket_data_flag: 1
|
|
5574
6110
|
});
|
|
5575
6111
|
}
|
|
@@ -5580,17 +6116,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5580
6116
|
}, {
|
|
5581
6117
|
key: "applyLocalPrintOrderNumbers",
|
|
5582
6118
|
value: function () {
|
|
5583
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6119
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(order) {
|
|
5584
6120
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
5585
|
-
return _regeneratorRuntime().wrap(function
|
|
5586
|
-
while (1) switch (
|
|
6121
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
6122
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
5587
6123
|
case 0:
|
|
5588
6124
|
tempOrder = this.ensureTempOrder();
|
|
5589
6125
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
5590
|
-
|
|
6126
|
+
_context36.next = 3;
|
|
5591
6127
|
break;
|
|
5592
6128
|
}
|
|
5593
|
-
return
|
|
6129
|
+
return _context36.abrupt("return", tempOrder);
|
|
5594
6130
|
case 3:
|
|
5595
6131
|
shopOrderNumber = order.shop_order_number;
|
|
5596
6132
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -5601,17 +6137,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5601
6137
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
5602
6138
|
}
|
|
5603
6139
|
this.persistTempOrder();
|
|
5604
|
-
|
|
6140
|
+
_context36.next = 10;
|
|
5605
6141
|
return this.saveDraft();
|
|
5606
6142
|
case 10:
|
|
5607
|
-
return
|
|
6143
|
+
return _context36.abrupt("return", tempOrder);
|
|
5608
6144
|
case 11:
|
|
5609
6145
|
case "end":
|
|
5610
|
-
return
|
|
6146
|
+
return _context36.stop();
|
|
5611
6147
|
}
|
|
5612
|
-
},
|
|
6148
|
+
}, _callee33, this);
|
|
5613
6149
|
}));
|
|
5614
|
-
function applyLocalPrintOrderNumbers(
|
|
6150
|
+
function applyLocalPrintOrderNumbers(_x37) {
|
|
5615
6151
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
5616
6152
|
}
|
|
5617
6153
|
return applyLocalPrintOrderNumbers;
|
|
@@ -5619,35 +6155,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5619
6155
|
}, {
|
|
5620
6156
|
key: "saveTempOrderAsDraft",
|
|
5621
6157
|
value: function () {
|
|
5622
|
-
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6158
|
+
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
5623
6159
|
var _params$cacheId2, _this$otherParams8, _this$otherParams9, _this$otherParams10, _params$type, _this$otherParams11, _payload$products;
|
|
5624
6160
|
var tempOrder, latestSummary, payload;
|
|
5625
|
-
return _regeneratorRuntime().wrap(function
|
|
5626
|
-
while (1) switch (
|
|
6161
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
6162
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
5627
6163
|
case 0:
|
|
5628
6164
|
tempOrder = this.ensureTempOrder();
|
|
5629
6165
|
this.ensureExternalSaleNumber(tempOrder);
|
|
5630
6166
|
this.persistTempOrder();
|
|
5631
|
-
|
|
6167
|
+
_context37.next = 5;
|
|
5632
6168
|
return this.recalculateSummary({
|
|
5633
6169
|
createIfMissing: true
|
|
5634
6170
|
});
|
|
5635
6171
|
case 5:
|
|
5636
|
-
|
|
5637
|
-
if (
|
|
5638
|
-
|
|
6172
|
+
_context37.t1 = _context37.sent;
|
|
6173
|
+
if (_context37.t1) {
|
|
6174
|
+
_context37.next = 8;
|
|
5639
6175
|
break;
|
|
5640
6176
|
}
|
|
5641
|
-
|
|
6177
|
+
_context37.t1 = this.store.summary;
|
|
5642
6178
|
case 8:
|
|
5643
|
-
|
|
5644
|
-
if (
|
|
5645
|
-
|
|
6179
|
+
_context37.t0 = _context37.t1;
|
|
6180
|
+
if (_context37.t0) {
|
|
6181
|
+
_context37.next = 11;
|
|
5646
6182
|
break;
|
|
5647
6183
|
}
|
|
5648
|
-
|
|
6184
|
+
_context37.t0 = createEmptySummary();
|
|
5649
6185
|
case 11:
|
|
5650
|
-
latestSummary =
|
|
6186
|
+
latestSummary = _context37.t0;
|
|
5651
6187
|
payload = buildSubmitPayload({
|
|
5652
6188
|
tempOrder: tempOrder,
|
|
5653
6189
|
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
@@ -5668,17 +6204,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5668
6204
|
externalSaleNumber: payload.external_sale_number,
|
|
5669
6205
|
productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
|
|
5670
6206
|
});
|
|
5671
|
-
return
|
|
6207
|
+
return _context37.abrupt("return", this.request.post('/order/sales/draft', payload, {
|
|
5672
6208
|
osServer: true,
|
|
5673
6209
|
customToast: function customToast() {}
|
|
5674
6210
|
}));
|
|
5675
6211
|
case 18:
|
|
5676
6212
|
case "end":
|
|
5677
|
-
return
|
|
6213
|
+
return _context37.stop();
|
|
5678
6214
|
}
|
|
5679
|
-
},
|
|
6215
|
+
}, _callee34, this);
|
|
5680
6216
|
}));
|
|
5681
|
-
function saveTempOrderAsDraft(
|
|
6217
|
+
function saveTempOrderAsDraft(_x38) {
|
|
5682
6218
|
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
5683
6219
|
}
|
|
5684
6220
|
return saveTempOrderAsDraft;
|
|
@@ -5692,18 +6228,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5692
6228
|
}, {
|
|
5693
6229
|
key: "submitTempOrder",
|
|
5694
6230
|
value: (function () {
|
|
5695
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5696
|
-
return _regeneratorRuntime().wrap(function
|
|
5697
|
-
while (1) switch (
|
|
6231
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
6232
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context38) {
|
|
6233
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
5698
6234
|
case 0:
|
|
5699
|
-
return
|
|
6235
|
+
return _context38.abrupt("return", this.runSubmitTempOrder(params));
|
|
5700
6236
|
case 1:
|
|
5701
6237
|
case "end":
|
|
5702
|
-
return
|
|
6238
|
+
return _context38.stop();
|
|
5703
6239
|
}
|
|
5704
|
-
},
|
|
6240
|
+
}, _callee35, this);
|
|
5705
6241
|
}));
|
|
5706
|
-
function submitTempOrder(
|
|
6242
|
+
function submitTempOrder(_x39) {
|
|
5707
6243
|
return _submitTempOrder.apply(this, arguments);
|
|
5708
6244
|
}
|
|
5709
6245
|
return submitTempOrder;
|
|
@@ -5711,20 +6247,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5711
6247
|
}, {
|
|
5712
6248
|
key: "submitTempOrderAsync",
|
|
5713
6249
|
value: function () {
|
|
5714
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5715
|
-
return _regeneratorRuntime().wrap(function
|
|
5716
|
-
while (1) switch (
|
|
6250
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
6251
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context39) {
|
|
6252
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
5717
6253
|
case 0:
|
|
5718
|
-
return
|
|
6254
|
+
return _context39.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
5719
6255
|
syncMode: true
|
|
5720
6256
|
})));
|
|
5721
6257
|
case 1:
|
|
5722
6258
|
case "end":
|
|
5723
|
-
return
|
|
6259
|
+
return _context39.stop();
|
|
5724
6260
|
}
|
|
5725
|
-
},
|
|
6261
|
+
}, _callee36, this);
|
|
5726
6262
|
}));
|
|
5727
|
-
function submitTempOrderAsync(
|
|
6263
|
+
function submitTempOrderAsync(_x40) {
|
|
5728
6264
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
5729
6265
|
}
|
|
5730
6266
|
return submitTempOrderAsync;
|
|
@@ -5732,11 +6268,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5732
6268
|
}, {
|
|
5733
6269
|
key: "runSubmitTempOrder",
|
|
5734
6270
|
value: function () {
|
|
5735
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5736
|
-
var _params$cacheId3, _this$otherParams12,
|
|
5737
|
-
var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
5738
|
-
return _regeneratorRuntime().wrap(function
|
|
5739
|
-
while (1) switch (
|
|
6271
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
6272
|
+
var _params$cacheId3, _this$otherParams12, _ref87, _ref88, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
|
|
6273
|
+
var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
|
|
6274
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
6275
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
5740
6276
|
case 0:
|
|
5741
6277
|
tempOrder = this.ensureTempOrder();
|
|
5742
6278
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
@@ -5760,33 +6296,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5760
6296
|
}
|
|
5761
6297
|
}
|
|
5762
6298
|
this.persistTempOrder();
|
|
5763
|
-
|
|
6299
|
+
_context40.next = 10;
|
|
5764
6300
|
return this.recalculateSummary({
|
|
5765
6301
|
createIfMissing: true
|
|
5766
6302
|
});
|
|
5767
6303
|
case 10:
|
|
5768
|
-
|
|
5769
|
-
if (
|
|
5770
|
-
|
|
6304
|
+
_context40.t1 = _context40.sent;
|
|
6305
|
+
if (_context40.t1) {
|
|
6306
|
+
_context40.next = 13;
|
|
5771
6307
|
break;
|
|
5772
6308
|
}
|
|
5773
|
-
|
|
6309
|
+
_context40.t1 = this.store.summary;
|
|
5774
6310
|
case 13:
|
|
5775
|
-
|
|
5776
|
-
if (
|
|
5777
|
-
|
|
6311
|
+
_context40.t0 = _context40.t1;
|
|
6312
|
+
if (_context40.t0) {
|
|
6313
|
+
_context40.next = 16;
|
|
5778
6314
|
break;
|
|
5779
6315
|
}
|
|
5780
|
-
|
|
6316
|
+
_context40.t0 = createEmptySummary();
|
|
5781
6317
|
case 16:
|
|
5782
|
-
latestSummary =
|
|
6318
|
+
latestSummary = _context40.t0;
|
|
5783
6319
|
effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
|
|
5784
6320
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
6321
|
+
shouldOverridePaymentStatus = hasPaymentStatusOverride && !isOnlineStorePlatform && !shouldConfirmPendingVoucherPayments;
|
|
5785
6322
|
hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
|
|
5786
6323
|
enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
|
|
5787
6324
|
var nextPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, payload), hasPaymentOverride ? {
|
|
5788
6325
|
payments: preparedPaymentOverride || []
|
|
5789
|
-
} : {}),
|
|
6326
|
+
} : {}), shouldOverridePaymentStatus ? {
|
|
5790
6327
|
payment_status: params === null || params === void 0 ? void 0 : params.paymentStatus
|
|
5791
6328
|
} : {}), hasSmallTicketDataFlagOverride ? {
|
|
5792
6329
|
small_ticket_data_flag: params === null || params === void 0 ? void 0 : params.smallTicketDataFlag
|
|
@@ -5799,7 +6336,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5799
6336
|
tempOrder: tempOrder,
|
|
5800
6337
|
cacheId: effectiveCacheId,
|
|
5801
6338
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform),
|
|
5802
|
-
businessCode: (
|
|
6339
|
+
businessCode: (_ref87 = (_ref88 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref88 !== void 0 ? _ref88 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref87 !== void 0 ? _ref87 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
|
|
5803
6340
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5804
6341
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
5805
6342
|
summary: latestSummary,
|
|
@@ -5814,10 +6351,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5814
6351
|
if (!payload.created_at) {
|
|
5815
6352
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
5816
6353
|
}
|
|
5817
|
-
|
|
6354
|
+
_context40.next = 28;
|
|
5818
6355
|
return this.saveDraft();
|
|
5819
|
-
case
|
|
5820
|
-
|
|
6356
|
+
case 28:
|
|
6357
|
+
_context40.prev = 28;
|
|
5821
6358
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
5822
6359
|
orderId: payload.order_id,
|
|
5823
6360
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -5827,44 +6364,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5827
6364
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
5828
6365
|
syncMode: payload.sync_mode
|
|
5829
6366
|
});
|
|
5830
|
-
|
|
6367
|
+
_context40.next = 32;
|
|
5831
6368
|
return this.submitSalesOrder({
|
|
5832
6369
|
query: payload
|
|
5833
6370
|
});
|
|
5834
|
-
case
|
|
5835
|
-
result =
|
|
5836
|
-
|
|
6371
|
+
case 32:
|
|
6372
|
+
result = _context40.sent;
|
|
6373
|
+
_context40.next = 45;
|
|
5837
6374
|
break;
|
|
5838
|
-
case
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
6375
|
+
case 35:
|
|
6376
|
+
_context40.prev = 35;
|
|
6377
|
+
_context40.t2 = _context40["catch"](28);
|
|
6378
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context40.t2);
|
|
5842
6379
|
if (!backendErrorResponse) {
|
|
5843
|
-
|
|
6380
|
+
_context40.next = 42;
|
|
5844
6381
|
break;
|
|
5845
6382
|
}
|
|
5846
6383
|
this.store.syncState = 'failed';
|
|
5847
6384
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
5848
|
-
return
|
|
5849
|
-
case
|
|
6385
|
+
return _context40.abrupt("return", backendErrorResponse);
|
|
6386
|
+
case 42:
|
|
5850
6387
|
this.store.syncState = 'failed';
|
|
5851
6388
|
this.logError('submitTempOrder failed', {
|
|
5852
|
-
error:
|
|
6389
|
+
error: _context40.t2 instanceof Error ? _context40.t2.message : String(_context40.t2),
|
|
5853
6390
|
orderId: payload.order_id,
|
|
5854
6391
|
externalSaleNumber: payload.external_sale_number,
|
|
5855
6392
|
paymentStatus: payload.payment_status,
|
|
5856
6393
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
5857
6394
|
});
|
|
5858
|
-
throw
|
|
5859
|
-
case
|
|
6395
|
+
throw _context40.t2;
|
|
6396
|
+
case 45:
|
|
5860
6397
|
if (!this.isSubmitResponseRejected(result)) {
|
|
5861
|
-
|
|
6398
|
+
_context40.next = 49;
|
|
5862
6399
|
break;
|
|
5863
6400
|
}
|
|
5864
6401
|
this.store.syncState = 'failed';
|
|
5865
6402
|
this.logSubmitBackendRejected(result, payload);
|
|
5866
|
-
return
|
|
5867
|
-
case
|
|
6403
|
+
return _context40.abrupt("return", result);
|
|
6404
|
+
case 49:
|
|
6405
|
+
isLocalPendingSubmit = this.isLocalPendingSubmitResult(result); // need_sync=1 仅表示已进入本地同步队列,不能视为远端已确认 Notes。
|
|
6406
|
+
if (Object.prototype.hasOwnProperty.call(payload, 'notes') && !isLocalPendingSubmit) {
|
|
6407
|
+
salesNotesState = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
6408
|
+
salesNotesState.dirty = false;
|
|
6409
|
+
}
|
|
5868
6410
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
5869
6411
|
this.logInfo('runSubmitTempOrder: 提交成功', {
|
|
5870
6412
|
submittedOrderId: submittedOrderId,
|
|
@@ -5874,31 +6416,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5874
6416
|
})
|
|
5875
6417
|
});
|
|
5876
6418
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
5877
|
-
|
|
6419
|
+
_context40.next = 58;
|
|
5878
6420
|
break;
|
|
5879
6421
|
}
|
|
5880
6422
|
tempOrder.order_id = submittedOrderId;
|
|
5881
6423
|
resultRecord = result;
|
|
5882
|
-
|
|
6424
|
+
_context40.next = 58;
|
|
5883
6425
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
5884
|
-
case
|
|
5885
|
-
|
|
5886
|
-
break;
|
|
5887
|
-
case 57:
|
|
5888
|
-
if (this.isLocalPendingSubmitResult(result)) {
|
|
6426
|
+
case 58:
|
|
6427
|
+
if (isLocalPendingSubmit) {
|
|
5889
6428
|
this.store.syncState = 'local';
|
|
5890
|
-
} else {
|
|
6429
|
+
} else if (submittedOrderId === null || submittedOrderId === undefined) {
|
|
5891
6430
|
this.store.syncState = 'submitted';
|
|
5892
6431
|
}
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
case 59:
|
|
6432
|
+
return _context40.abrupt("return", result);
|
|
6433
|
+
case 60:
|
|
5896
6434
|
case "end":
|
|
5897
|
-
return
|
|
6435
|
+
return _context40.stop();
|
|
5898
6436
|
}
|
|
5899
|
-
},
|
|
6437
|
+
}, _callee37, this, [[28, 35]]);
|
|
5900
6438
|
}));
|
|
5901
|
-
function runSubmitTempOrder(
|
|
6439
|
+
function runSubmitTempOrder(_x41) {
|
|
5902
6440
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
5903
6441
|
}
|
|
5904
6442
|
return runSubmitTempOrder;
|
|
@@ -5906,10 +6444,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5906
6444
|
}, {
|
|
5907
6445
|
key: "markLocalOrderSynced",
|
|
5908
6446
|
value: function () {
|
|
5909
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6447
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(orderId, remoteOrder) {
|
|
5910
6448
|
var tempOrder;
|
|
5911
|
-
return _regeneratorRuntime().wrap(function
|
|
5912
|
-
while (1) switch (
|
|
6449
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context41) {
|
|
6450
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
5913
6451
|
case 0:
|
|
5914
6452
|
tempOrder = this.ensureTempOrder();
|
|
5915
6453
|
tempOrder.order_id = orderId;
|
|
@@ -5917,15 +6455,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5917
6455
|
this.store.lastOrderInfo = remoteOrder;
|
|
5918
6456
|
this.store.syncState = 'submitted';
|
|
5919
6457
|
this.persistTempOrder();
|
|
5920
|
-
|
|
6458
|
+
_context41.next = 8;
|
|
5921
6459
|
return this.saveDraft();
|
|
5922
6460
|
case 8:
|
|
5923
6461
|
case "end":
|
|
5924
|
-
return
|
|
6462
|
+
return _context41.stop();
|
|
5925
6463
|
}
|
|
5926
|
-
},
|
|
6464
|
+
}, _callee38, this);
|
|
5927
6465
|
}));
|
|
5928
|
-
function markLocalOrderSynced(
|
|
6466
|
+
function markLocalOrderSynced(_x42, _x43) {
|
|
5929
6467
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
5930
6468
|
}
|
|
5931
6469
|
return markLocalOrderSynced;
|
|
@@ -5968,10 +6506,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5968
6506
|
value: function extractSubmitErrorResponse(error) {
|
|
5969
6507
|
var _error$response,
|
|
5970
6508
|
_error$response2,
|
|
5971
|
-
|
|
6509
|
+
_this36 = this;
|
|
5972
6510
|
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];
|
|
5973
6511
|
return candidates.find(function (candidate) {
|
|
5974
|
-
return
|
|
6512
|
+
return _this36.isSubmitErrorResponse(candidate);
|
|
5975
6513
|
}) || null;
|
|
5976
6514
|
}
|
|
5977
6515
|
}, {
|
|
@@ -5998,33 +6536,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5998
6536
|
}, {
|
|
5999
6537
|
key: "syncPaymentsToOrder",
|
|
6000
6538
|
value: function () {
|
|
6001
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6002
|
-
var
|
|
6539
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
6540
|
+
var _this37 = this,
|
|
6003
6541
|
_params$confirmPendin;
|
|
6004
6542
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
6005
|
-
return _regeneratorRuntime().wrap(function
|
|
6006
|
-
while (1) switch (
|
|
6543
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
6544
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
6007
6545
|
case 0:
|
|
6008
6546
|
tempOrder = this.ensureTempOrder();
|
|
6009
6547
|
needsPaymentNumber = (params.payments || []).some(function (payment) {
|
|
6010
6548
|
return String(payment.payment_number || '').trim() === '';
|
|
6011
6549
|
});
|
|
6012
6550
|
if (!needsPaymentNumber) {
|
|
6013
|
-
|
|
6551
|
+
_context42.next = 8;
|
|
6014
6552
|
break;
|
|
6015
6553
|
}
|
|
6016
|
-
|
|
6554
|
+
_context42.next = 5;
|
|
6017
6555
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
6018
6556
|
case 5:
|
|
6019
|
-
|
|
6020
|
-
|
|
6557
|
+
_context42.t0 = _context42.sent;
|
|
6558
|
+
_context42.next = 9;
|
|
6021
6559
|
break;
|
|
6022
6560
|
case 8:
|
|
6023
|
-
|
|
6561
|
+
_context42.t0 = 'LOCAL';
|
|
6024
6562
|
case 9:
|
|
6025
|
-
devicePrefix =
|
|
6563
|
+
devicePrefix = _context42.t0;
|
|
6026
6564
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
6027
|
-
return
|
|
6565
|
+
return _this37.normalizePaymentSource(payment, {
|
|
6028
6566
|
defaultPaid: false,
|
|
6029
6567
|
devicePrefix: devicePrefix
|
|
6030
6568
|
});
|
|
@@ -6037,20 +6575,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6037
6575
|
tempOrder.payments = effectivePayments;
|
|
6038
6576
|
tempOrder.payment_status = paymentStatus;
|
|
6039
6577
|
this.persistTempOrder();
|
|
6040
|
-
|
|
6578
|
+
_context42.next = 21;
|
|
6041
6579
|
return this.saveDraft();
|
|
6042
6580
|
case 21:
|
|
6043
6581
|
if (params.submitWhenPaid) {
|
|
6044
|
-
|
|
6582
|
+
_context42.next = 23;
|
|
6045
6583
|
break;
|
|
6046
6584
|
}
|
|
6047
|
-
return
|
|
6585
|
+
return _context42.abrupt("return", completion);
|
|
6048
6586
|
case 23:
|
|
6049
6587
|
if (!(this.store.syncState === 'submitting')) {
|
|
6050
|
-
|
|
6588
|
+
_context42.next = 25;
|
|
6051
6589
|
break;
|
|
6052
6590
|
}
|
|
6053
|
-
return
|
|
6591
|
+
return _context42.abrupt("return", completion);
|
|
6054
6592
|
case 25:
|
|
6055
6593
|
this.store.syncState = 'submitting';
|
|
6056
6594
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
@@ -6070,32 +6608,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6070
6608
|
enhancePayload: enhancePayload
|
|
6071
6609
|
};
|
|
6072
6610
|
if (!(params.checkoutSyncTaskEnabled === false)) {
|
|
6073
|
-
|
|
6611
|
+
_context42.next = 35;
|
|
6074
6612
|
break;
|
|
6075
6613
|
}
|
|
6076
|
-
|
|
6614
|
+
_context42.next = 32;
|
|
6077
6615
|
return this.submitTempOrderAsync(submitParams);
|
|
6078
6616
|
case 32:
|
|
6079
|
-
|
|
6080
|
-
|
|
6617
|
+
_context42.t1 = _context42.sent;
|
|
6618
|
+
_context42.next = 38;
|
|
6081
6619
|
break;
|
|
6082
6620
|
case 35:
|
|
6083
|
-
|
|
6621
|
+
_context42.next = 37;
|
|
6084
6622
|
return this.submitTempOrder(submitParams);
|
|
6085
6623
|
case 37:
|
|
6086
|
-
|
|
6624
|
+
_context42.t1 = _context42.sent;
|
|
6087
6625
|
case 38:
|
|
6088
|
-
submitResult =
|
|
6089
|
-
return
|
|
6626
|
+
submitResult = _context42.t1;
|
|
6627
|
+
return _context42.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
6090
6628
|
submitResult: submitResult
|
|
6091
6629
|
}));
|
|
6092
6630
|
case 40:
|
|
6093
6631
|
case "end":
|
|
6094
|
-
return
|
|
6632
|
+
return _context42.stop();
|
|
6095
6633
|
}
|
|
6096
|
-
},
|
|
6634
|
+
}, _callee39, this);
|
|
6097
6635
|
}));
|
|
6098
|
-
function syncPaymentsToOrder(
|
|
6636
|
+
function syncPaymentsToOrder(_x44) {
|
|
6099
6637
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
6100
6638
|
}
|
|
6101
6639
|
return syncPaymentsToOrder;
|
|
@@ -6103,7 +6641,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6103
6641
|
}, {
|
|
6104
6642
|
key: "createOrder",
|
|
6105
6643
|
value: function createOrder(params) {
|
|
6106
|
-
var
|
|
6644
|
+
var _this38 = this;
|
|
6107
6645
|
var order = _objectSpread({
|
|
6108
6646
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
6109
6647
|
// 要从外面拿,virtual
|
|
@@ -6135,7 +6673,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6135
6673
|
|
|
6136
6674
|
// 为预约补齐 holder 信息
|
|
6137
6675
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
6138
|
-
ensureCartItemOriginHolder(item,
|
|
6676
|
+
ensureCartItemOriginHolder(item, _this38.window);
|
|
6139
6677
|
}
|
|
6140
6678
|
|
|
6141
6679
|
// 购物车是否为普通商品
|
|
@@ -6192,11 +6730,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6192
6730
|
}, {
|
|
6193
6731
|
key: "submitOrder",
|
|
6194
6732
|
value: function () {
|
|
6195
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6733
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(order) {
|
|
6196
6734
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
6197
6735
|
var url, query, fetchUrl, params;
|
|
6198
|
-
return _regeneratorRuntime().wrap(function
|
|
6199
|
-
while (1) switch (
|
|
6736
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context43) {
|
|
6737
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
6200
6738
|
case 0:
|
|
6201
6739
|
this.logInfo('submitOrder called', {
|
|
6202
6740
|
url: order.url,
|
|
@@ -6216,14 +6754,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6216
6754
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
6217
6755
|
scheduleDate: params.schedule_date
|
|
6218
6756
|
});
|
|
6219
|
-
return
|
|
6757
|
+
return _context43.abrupt("return", this.request.post(fetchUrl, params));
|
|
6220
6758
|
case 6:
|
|
6221
6759
|
case "end":
|
|
6222
|
-
return
|
|
6760
|
+
return _context43.stop();
|
|
6223
6761
|
}
|
|
6224
|
-
},
|
|
6762
|
+
}, _callee40, this);
|
|
6225
6763
|
}));
|
|
6226
|
-
function submitOrder(
|
|
6764
|
+
function submitOrder(_x45) {
|
|
6227
6765
|
return _submitOrder.apply(this, arguments);
|
|
6228
6766
|
}
|
|
6229
6767
|
return submitOrder;
|
|
@@ -6231,13 +6769,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6231
6769
|
}, {
|
|
6232
6770
|
key: "cancelOrder",
|
|
6233
6771
|
value: function () {
|
|
6234
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6772
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
6235
6773
|
var payload;
|
|
6236
|
-
return _regeneratorRuntime().wrap(function
|
|
6237
|
-
while (1) switch (
|
|
6774
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context44) {
|
|
6775
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
6238
6776
|
case 0:
|
|
6239
6777
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
6240
|
-
|
|
6778
|
+
_context44.next = 2;
|
|
6241
6779
|
break;
|
|
6242
6780
|
}
|
|
6243
6781
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -6253,16 +6791,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6253
6791
|
method: 'PUT',
|
|
6254
6792
|
orderIdsCount: params.order_ids.length
|
|
6255
6793
|
});
|
|
6256
|
-
return
|
|
6794
|
+
return _context44.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
6257
6795
|
isShopApi: true
|
|
6258
6796
|
}));
|
|
6259
6797
|
case 5:
|
|
6260
6798
|
case "end":
|
|
6261
|
-
return
|
|
6799
|
+
return _context44.stop();
|
|
6262
6800
|
}
|
|
6263
|
-
},
|
|
6801
|
+
}, _callee41, this);
|
|
6264
6802
|
}));
|
|
6265
|
-
function cancelOrder(
|
|
6803
|
+
function cancelOrder(_x46) {
|
|
6266
6804
|
return _cancelOrder.apply(this, arguments);
|
|
6267
6805
|
}
|
|
6268
6806
|
return cancelOrder;
|
|
@@ -6270,19 +6808,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6270
6808
|
}, {
|
|
6271
6809
|
key: "changeBookingStatus",
|
|
6272
6810
|
value: function () {
|
|
6273
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6811
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
|
|
6274
6812
|
var url, payload;
|
|
6275
|
-
return _regeneratorRuntime().wrap(function
|
|
6276
|
-
while (1) switch (
|
|
6813
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context45) {
|
|
6814
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
6277
6815
|
case 0:
|
|
6278
6816
|
if (params.booking_id) {
|
|
6279
|
-
|
|
6817
|
+
_context45.next = 2;
|
|
6280
6818
|
break;
|
|
6281
6819
|
}
|
|
6282
6820
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
6283
6821
|
case 2:
|
|
6284
6822
|
if (params.appointment_status) {
|
|
6285
|
-
|
|
6823
|
+
_context45.next = 4;
|
|
6286
6824
|
break;
|
|
6287
6825
|
}
|
|
6288
6826
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -6297,16 +6835,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6297
6835
|
bookingId: params.booking_id,
|
|
6298
6836
|
appointmentStatus: params.appointment_status
|
|
6299
6837
|
});
|
|
6300
|
-
return
|
|
6838
|
+
return _context45.abrupt("return", this.request.put(url, payload, {
|
|
6301
6839
|
isShopApi: true
|
|
6302
6840
|
}));
|
|
6303
6841
|
case 8:
|
|
6304
6842
|
case "end":
|
|
6305
|
-
return
|
|
6843
|
+
return _context45.stop();
|
|
6306
6844
|
}
|
|
6307
|
-
},
|
|
6845
|
+
}, _callee42, this);
|
|
6308
6846
|
}));
|
|
6309
|
-
function changeBookingStatus(
|
|
6847
|
+
function changeBookingStatus(_x47) {
|
|
6310
6848
|
return _changeBookingStatus.apply(this, arguments);
|
|
6311
6849
|
}
|
|
6312
6850
|
return changeBookingStatus;
|
|
@@ -6324,11 +6862,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6324
6862
|
}, {
|
|
6325
6863
|
key: "createOrderByCheckout",
|
|
6326
6864
|
value: (function () {
|
|
6327
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6865
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
6328
6866
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3;
|
|
6329
6867
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, orderData, response;
|
|
6330
|
-
return _regeneratorRuntime().wrap(function
|
|
6331
|
-
while (1) switch (
|
|
6868
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context46) {
|
|
6869
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
6332
6870
|
case 0:
|
|
6333
6871
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
6334
6872
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -6353,7 +6891,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6353
6891
|
return p.code;
|
|
6354
6892
|
})) || []
|
|
6355
6893
|
});
|
|
6356
|
-
|
|
6894
|
+
_context46.prev = 3;
|
|
6357
6895
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
6358
6896
|
orderData = _objectSpread({
|
|
6359
6897
|
sales_channel: 'my_pisel',
|
|
@@ -6401,32 +6939,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6401
6939
|
hasOrderId: !!orderData.order_id,
|
|
6402
6940
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
6403
6941
|
});
|
|
6404
|
-
|
|
6942
|
+
_context46.next = 10;
|
|
6405
6943
|
return this.request.post('/order/checkout', orderData, {
|
|
6406
6944
|
osServer: true,
|
|
6407
6945
|
customToast: function customToast() {}
|
|
6408
6946
|
});
|
|
6409
6947
|
case 10:
|
|
6410
|
-
response =
|
|
6948
|
+
response = _context46.sent;
|
|
6411
6949
|
this.logInfo('Order API called successfully', {
|
|
6412
6950
|
response: response
|
|
6413
6951
|
});
|
|
6414
|
-
return
|
|
6952
|
+
return _context46.abrupt("return", response);
|
|
6415
6953
|
case 15:
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
6954
|
+
_context46.prev = 15;
|
|
6955
|
+
_context46.t0 = _context46["catch"](3);
|
|
6956
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context46.t0);
|
|
6419
6957
|
this.logInfo('Order API called failed', {
|
|
6420
|
-
error:
|
|
6958
|
+
error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
|
|
6421
6959
|
});
|
|
6422
|
-
throw
|
|
6960
|
+
throw _context46.t0;
|
|
6423
6961
|
case 20:
|
|
6424
6962
|
case "end":
|
|
6425
|
-
return
|
|
6963
|
+
return _context46.stop();
|
|
6426
6964
|
}
|
|
6427
|
-
},
|
|
6965
|
+
}, _callee43, this, [[3, 15]]);
|
|
6428
6966
|
}));
|
|
6429
|
-
function createOrderByCheckout(
|
|
6967
|
+
function createOrderByCheckout(_x48) {
|
|
6430
6968
|
return _createOrderByCheckout.apply(this, arguments);
|
|
6431
6969
|
}
|
|
6432
6970
|
return createOrderByCheckout;
|
|
@@ -6434,25 +6972,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6434
6972
|
}, {
|
|
6435
6973
|
key: "submitSalesOrder",
|
|
6436
6974
|
value: function () {
|
|
6437
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6975
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
|
|
6438
6976
|
var url, query, fetchUrl, requestQuery;
|
|
6439
|
-
return _regeneratorRuntime().wrap(function
|
|
6440
|
-
while (1) switch (
|
|
6977
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context47) {
|
|
6978
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
6441
6979
|
case 0:
|
|
6442
6980
|
url = params.url, query = params.query;
|
|
6443
6981
|
fetchUrl = url || '/order/sales/checkout';
|
|
6444
6982
|
requestQuery = this.isSalesCheckoutHandledByOsServer(fetchUrl) ? query : stripOsPrivatePayloadFields(query);
|
|
6445
|
-
return
|
|
6983
|
+
return _context47.abrupt("return", this.request.post(fetchUrl, requestQuery, {
|
|
6446
6984
|
osServer: true,
|
|
6447
6985
|
customToast: function customToast() {}
|
|
6448
6986
|
}));
|
|
6449
6987
|
case 4:
|
|
6450
6988
|
case "end":
|
|
6451
|
-
return
|
|
6989
|
+
return _context47.stop();
|
|
6452
6990
|
}
|
|
6453
|
-
},
|
|
6991
|
+
}, _callee44, this);
|
|
6454
6992
|
}));
|
|
6455
|
-
function submitSalesOrder(
|
|
6993
|
+
function submitSalesOrder(_x49) {
|
|
6456
6994
|
return _submitSalesOrder.apply(this, arguments);
|
|
6457
6995
|
}
|
|
6458
6996
|
return submitSalesOrder;
|
|
@@ -6479,37 +7017,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6479
7017
|
}, {
|
|
6480
7018
|
key: "sendCustomerPayLink",
|
|
6481
7019
|
value: (function () {
|
|
6482
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7020
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
|
|
6483
7021
|
var _params$emails;
|
|
6484
7022
|
var orderIds;
|
|
6485
|
-
return _regeneratorRuntime().wrap(function
|
|
6486
|
-
while (1) switch (
|
|
7023
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context48) {
|
|
7024
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
6487
7025
|
case 0:
|
|
6488
7026
|
orderIds = params.order_ids || params.orderIds || [];
|
|
6489
7027
|
if (orderIds.length) {
|
|
6490
|
-
|
|
7028
|
+
_context48.next = 3;
|
|
6491
7029
|
break;
|
|
6492
7030
|
}
|
|
6493
7031
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
6494
7032
|
case 3:
|
|
6495
7033
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
6496
|
-
|
|
7034
|
+
_context48.next = 5;
|
|
6497
7035
|
break;
|
|
6498
7036
|
}
|
|
6499
7037
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
6500
7038
|
case 5:
|
|
6501
|
-
return
|
|
7039
|
+
return _context48.abrupt("return", this.request.post('/order/batch-email', {
|
|
6502
7040
|
order_ids: orderIds,
|
|
6503
7041
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
6504
7042
|
emails: params.emails
|
|
6505
7043
|
}));
|
|
6506
7044
|
case 6:
|
|
6507
7045
|
case "end":
|
|
6508
|
-
return
|
|
7046
|
+
return _context48.stop();
|
|
6509
7047
|
}
|
|
6510
|
-
},
|
|
7048
|
+
}, _callee45, this);
|
|
6511
7049
|
}));
|
|
6512
|
-
function sendCustomerPayLink(
|
|
7050
|
+
function sendCustomerPayLink(_x50) {
|
|
6513
7051
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
6514
7052
|
}
|
|
6515
7053
|
return sendCustomerPayLink;
|
|
@@ -6517,14 +7055,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6517
7055
|
}, {
|
|
6518
7056
|
key: "getSalesOrderByLookup",
|
|
6519
7057
|
value: function () {
|
|
6520
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7058
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
|
|
6521
7059
|
var lookup, res;
|
|
6522
|
-
return _regeneratorRuntime().wrap(function
|
|
6523
|
-
while (1) switch (
|
|
7060
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context49) {
|
|
7061
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
6524
7062
|
case 0:
|
|
6525
7063
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
6526
7064
|
if (lookup) {
|
|
6527
|
-
|
|
7065
|
+
_context49.next = 3;
|
|
6528
7066
|
break;
|
|
6529
7067
|
}
|
|
6530
7068
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -6533,27 +7071,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6533
7071
|
if (lookup.startsWith('LOCAL_')) {
|
|
6534
7072
|
params.forceRemote = false;
|
|
6535
7073
|
}
|
|
6536
|
-
|
|
7074
|
+
_context49.next = 6;
|
|
6537
7075
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
6538
|
-
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'order_meta_list', 'refunds']
|
|
7076
|
+
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'order_meta_list', 'refunds', 'notes']
|
|
6539
7077
|
}, params.forceRemote ? {
|
|
6540
7078
|
forceRemote: true
|
|
6541
7079
|
} : {}), {
|
|
6542
7080
|
osServer: true
|
|
6543
7081
|
});
|
|
6544
7082
|
case 6:
|
|
6545
|
-
res =
|
|
7083
|
+
res = _context49.sent;
|
|
6546
7084
|
if (res.code === 200) {
|
|
6547
7085
|
this.store.lastOrderInfo = res.data;
|
|
6548
7086
|
}
|
|
6549
|
-
return
|
|
7087
|
+
return _context49.abrupt("return", res);
|
|
6550
7088
|
case 9:
|
|
6551
7089
|
case "end":
|
|
6552
|
-
return
|
|
7090
|
+
return _context49.stop();
|
|
6553
7091
|
}
|
|
6554
|
-
},
|
|
7092
|
+
}, _callee46, this);
|
|
6555
7093
|
}));
|
|
6556
|
-
function getSalesOrderByLookup(
|
|
7094
|
+
function getSalesOrderByLookup(_x51) {
|
|
6557
7095
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
6558
7096
|
}
|
|
6559
7097
|
return getSalesOrderByLookup;
|
|
@@ -6567,11 +7105,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6567
7105
|
}, {
|
|
6568
7106
|
key: "hydrateTempOrderFromRecord",
|
|
6569
7107
|
value: (function () {
|
|
6570
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7108
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(record, options) {
|
|
6571
7109
|
var _sourceRaw$_extend, _this$store$discount26;
|
|
6572
7110
|
var sourceRaw, duplicateProductIdentityRepair, duplicateIdentityReadySource, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, isSessionStorageHydrate, isMergedSalesDetailHydrate, nextTempOrder, _this$store$discount24, _this$store$discount25, restoredSessionDiscounts, nextExtend, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, historicalDepositSnapshot, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount27, _this$store$discount28;
|
|
6573
|
-
return _regeneratorRuntime().wrap(function
|
|
6574
|
-
while (1) switch (
|
|
7111
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context50) {
|
|
7112
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
6575
7113
|
case 0:
|
|
6576
7114
|
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
6577
7115
|
duplicateProductIdentityRepair = repairDuplicateOrderProductLineIdentities(Array.isArray(sourceRaw.products) ? sourceRaw.products : [], (_sourceRaw$_extend = sourceRaw._extend) === null || _sourceRaw$_extend === void 0 ? void 0 : _sourceRaw$_extend.productsByUid);
|
|
@@ -6607,11 +7145,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6607
7145
|
isMergedSalesDetailHydrate = (options === null || options === void 0 ? void 0 : options.source) === 'mergedSalesDetail';
|
|
6608
7146
|
nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
|
|
6609
7147
|
// merge 前已只给远端商品补标记;这里不能把本地未提交商品一并变成 saved item。
|
|
6610
|
-
makeEditMark: !isSessionStorageHydrate && !isMergedSalesDetailHydrate
|
|
7148
|
+
makeEditMark: !isSessionStorageHydrate && !isMergedSalesDetailHydrate,
|
|
7149
|
+
allowUnresolvedSalesNotes: isSessionStorageHydrate
|
|
6611
7150
|
});
|
|
6612
7151
|
this.store.tempOrder = nextTempOrder;
|
|
7152
|
+
this.clearCustomerWalletRuntimeState();
|
|
6613
7153
|
if (!isSessionStorageHydrate) {
|
|
6614
|
-
|
|
7154
|
+
_context50.next = 31;
|
|
6615
7155
|
break;
|
|
6616
7156
|
}
|
|
6617
7157
|
// 会话快照是未提交购物车,不应获得编辑订单的 saved/edit 标记与服务端基线。
|
|
@@ -6627,24 +7167,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6627
7167
|
nextTempOrder.discount_list = restoredSessionDiscounts;
|
|
6628
7168
|
this.store.summary = createEmptySummary();
|
|
6629
7169
|
this.store.lastOrderInfo = undefined;
|
|
6630
|
-
|
|
7170
|
+
_context50.next = 24;
|
|
6631
7171
|
return (_this$store$discount24 = this.store.discount) === null || _this$store$discount24 === void 0 ? void 0 : _this$store$discount24.setOriginalDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
6632
|
-
case
|
|
6633
|
-
|
|
7172
|
+
case 24:
|
|
7173
|
+
_context50.next = 26;
|
|
6634
7174
|
return (_this$store$discount25 = this.store.discount) === null || _this$store$discount25 === void 0 ? void 0 : _this$store$discount25.setDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
6635
|
-
case
|
|
7175
|
+
case 26:
|
|
6636
7176
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
6637
|
-
|
|
7177
|
+
_context50.next = 29;
|
|
6638
7178
|
break;
|
|
6639
7179
|
}
|
|
6640
|
-
|
|
7180
|
+
_context50.next = 29;
|
|
6641
7181
|
return this.recalculateSummary({
|
|
6642
7182
|
createIfMissing: false
|
|
6643
7183
|
});
|
|
6644
|
-
case
|
|
7184
|
+
case 29:
|
|
6645
7185
|
this.persistTempOrder();
|
|
6646
|
-
return
|
|
6647
|
-
case
|
|
7186
|
+
return _context50.abrupt("return", nextTempOrder);
|
|
7187
|
+
case 31:
|
|
6648
7188
|
// Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
|
|
6649
7189
|
sourceLastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
|
|
6650
7190
|
isDraftOrder = Number(nextTempOrder.is_draft_order || 0) === 1;
|
|
@@ -6695,34 +7235,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6695
7235
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
6696
7236
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
6697
7237
|
if (shouldSkipEmptyDiscountSync) {
|
|
6698
|
-
|
|
7238
|
+
_context50.next = 55;
|
|
6699
7239
|
break;
|
|
6700
7240
|
}
|
|
6701
7241
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
6702
|
-
|
|
7242
|
+
_context50.next = 53;
|
|
6703
7243
|
return (_this$store$discount27 = this.store.discount) === null || _this$store$discount27 === void 0 ? void 0 : _this$store$discount27.setOriginalDiscountList(nextDiscounts);
|
|
6704
|
-
case
|
|
6705
|
-
|
|
7244
|
+
case 53:
|
|
7245
|
+
_context50.next = 55;
|
|
6706
7246
|
return (_this$store$discount28 = this.store.discount) === null || _this$store$discount28 === void 0 ? void 0 : _this$store$discount28.setDiscountList(nextDiscounts);
|
|
6707
|
-
case
|
|
7247
|
+
case 55:
|
|
6708
7248
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
6709
|
-
|
|
7249
|
+
_context50.next = 58;
|
|
6710
7250
|
break;
|
|
6711
7251
|
}
|
|
6712
|
-
|
|
7252
|
+
_context50.next = 58;
|
|
6713
7253
|
return this.recalculateSummary({
|
|
6714
7254
|
createIfMissing: false
|
|
6715
7255
|
});
|
|
6716
|
-
case
|
|
7256
|
+
case 58:
|
|
6717
7257
|
this.persistTempOrder();
|
|
6718
|
-
return
|
|
6719
|
-
case
|
|
7258
|
+
return _context50.abrupt("return", nextTempOrder);
|
|
7259
|
+
case 60:
|
|
6720
7260
|
case "end":
|
|
6721
|
-
return
|
|
7261
|
+
return _context50.stop();
|
|
6722
7262
|
}
|
|
6723
|
-
},
|
|
7263
|
+
}, _callee47, this);
|
|
6724
7264
|
}));
|
|
6725
|
-
function hydrateTempOrderFromRecord(
|
|
7265
|
+
function hydrateTempOrderFromRecord(_x52, _x53) {
|
|
6726
7266
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
6727
7267
|
}
|
|
6728
7268
|
return hydrateTempOrderFromRecord;
|
|
@@ -6775,10 +7315,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6775
7315
|
_step22;
|
|
6776
7316
|
try {
|
|
6777
7317
|
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
6778
|
-
var _product$
|
|
7318
|
+
var _product$metadata13;
|
|
6779
7319
|
var product = _step22.value;
|
|
6780
7320
|
var productUid = getOrderCollectionUid('product', product);
|
|
6781
|
-
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$
|
|
7321
|
+
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata13 = product.metadata) === null || _product$metadata13 === void 0 ? void 0 : _product$metadata13.booking_uid);
|
|
6782
7322
|
if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
|
|
6783
7323
|
continue;
|
|
6784
7324
|
}
|
|
@@ -6836,7 +7376,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6836
7376
|
}, {
|
|
6837
7377
|
key: "normalizeTempOrderForRuntime",
|
|
6838
7378
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
6839
|
-
var
|
|
7379
|
+
var _this39 = this,
|
|
7380
|
+
_raw$_extend;
|
|
6840
7381
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
6841
7382
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
6842
7383
|
// ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
|
|
@@ -6860,12 +7401,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6860
7401
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
6861
7402
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
6862
7403
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
6863
|
-
return
|
|
7404
|
+
return _this39.normalizeHydratedOrderProduct(p, {
|
|
6864
7405
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
6865
7406
|
});
|
|
6866
7407
|
}) : [];
|
|
6867
7408
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
6868
|
-
var booking =
|
|
7409
|
+
var booking = _this39.normalizeHydratedBookingHolder(b || {});
|
|
6869
7410
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
6870
7411
|
is_all: normalizeBookingIsAll(booking),
|
|
6871
7412
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -6874,6 +7415,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6874
7415
|
nextTempOrder.payments = Array.isArray(raw.payments) ? raw.payments.map(function (p) {
|
|
6875
7416
|
return _objectSpread({}, p || {});
|
|
6876
7417
|
}) : [];
|
|
7418
|
+
var rawHasSalesNotes = Object.prototype.hasOwnProperty.call(raw, 'notes');
|
|
7419
|
+
var restoredSalesNotesState = (_raw$_extend = raw._extend) === null || _raw$_extend === void 0 ? void 0 : _raw$_extend.salesNotesState;
|
|
7420
|
+
var allowUnresolvedSalesNotes = (options === null || options === void 0 ? void 0 : options.allowUnresolvedSalesNotes) === true || (restoredSalesNotesState === null || restoredSalesNotesState === void 0 ? void 0 : restoredSalesNotesState.dirty) === true || Number(raw.is_draft_order || 0) === 1;
|
|
7421
|
+
var decodedSalesNotes = rawHasSalesNotes ? decodeSalesNotesSnapshot(raw.notes, {
|
|
7422
|
+
allowUnresolvedOrderTarget: allowUnresolvedSalesNotes
|
|
7423
|
+
}) : {
|
|
7424
|
+
notes: [],
|
|
7425
|
+
complete: false
|
|
7426
|
+
};
|
|
7427
|
+
var hasUnresolvedSalesNoteOrderTarget = decodedSalesNotes.notes.some(function (note) {
|
|
7428
|
+
return note.note_relations.some(function (relation) {
|
|
7429
|
+
return relation.is_primary === 0 && relation.relation_type === 'related_to' && relation.target_type === 'order' && relation.target_uuid === '';
|
|
7430
|
+
});
|
|
7431
|
+
});
|
|
7432
|
+
nextTempOrder.notes = decodedSalesNotes.notes;
|
|
6877
7433
|
nextTempOrder.surcharges = Array.isArray(raw.surcharges) ? raw.surcharges.map(function (s) {
|
|
6878
7434
|
return _objectSpread({}, s || {});
|
|
6879
7435
|
}) : [];
|
|
@@ -6891,20 +7447,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6891
7447
|
productsByUid: {}
|
|
6892
7448
|
};
|
|
6893
7449
|
var tempOrderExtend = nextTempOrder._extend;
|
|
7450
|
+
tempOrderExtend.salesNotesState = {
|
|
7451
|
+
loaded: rawHasSalesNotes ? decodedSalesNotes.complete : (restoredSalesNotesState === null || restoredSalesNotesState === void 0 ? void 0 : restoredSalesNotesState.loaded) === true,
|
|
7452
|
+
dirty: decodedSalesNotes.complete && ((restoredSalesNotesState === null || restoredSalesNotesState === void 0 ? void 0 : restoredSalesNotesState.dirty) === true || allowUnresolvedSalesNotes && hasUnresolvedSalesNoteOrderTarget)
|
|
7453
|
+
};
|
|
6894
7454
|
var productsByUid = tempOrderExtend.productsByUid || {};
|
|
6895
7455
|
var _iterator24 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
|
|
6896
7456
|
_step24;
|
|
6897
7457
|
try {
|
|
6898
7458
|
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
6899
|
-
var _product$
|
|
7459
|
+
var _product$metadata14, _ref89, _ref90, _existed$origin, _rawProduct$metadata;
|
|
6900
7460
|
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
6901
7461
|
index = _step24$value[0],
|
|
6902
7462
|
product = _step24$value[1];
|
|
6903
|
-
var uid = (_product$
|
|
7463
|
+
var uid = (_product$metadata14 = product.metadata) === null || _product$metadata14 === void 0 ? void 0 : _product$metadata14.unique_identification_number;
|
|
6904
7464
|
if (!uid) continue;
|
|
6905
7465
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
6906
7466
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
6907
|
-
var origin = (
|
|
7467
|
+
var origin = (_ref89 = (_ref90 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref90 !== void 0 ? _ref90 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref89 !== void 0 ? _ref89 : rawProduct;
|
|
6908
7468
|
var originSnapshot = cloneDeep(origin);
|
|
6909
7469
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
6910
7470
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -6955,8 +7515,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6955
7515
|
var bookingUidByProductUid = new Map();
|
|
6956
7516
|
var productByUid = new Map();
|
|
6957
7517
|
(tempOrder.products || []).forEach(function (product) {
|
|
6958
|
-
var _product$
|
|
6959
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
7518
|
+
var _product$metadata15;
|
|
7519
|
+
var productUid = (product === null || product === void 0 || (_product$metadata15 = product.metadata) === null || _product$metadata15 === void 0 ? void 0 : _product$metadata15.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
6960
7520
|
if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
|
|
6961
7521
|
productByUid.set(String(productUid), product);
|
|
6962
7522
|
}
|
|
@@ -6977,8 +7537,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6977
7537
|
bookingUidByProductUid.set(String(productUid), bookingUid);
|
|
6978
7538
|
});
|
|
6979
7539
|
(tempOrder.products || []).forEach(function (product) {
|
|
6980
|
-
var _product$
|
|
6981
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
7540
|
+
var _product$metadata16;
|
|
7541
|
+
var productUid = (product === null || product === void 0 || (_product$metadata16 = product.metadata) === null || _product$metadata16 === void 0 ? void 0 : _product$metadata16.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
6982
7542
|
if (productUid === undefined || productUid === null || String(productUid) === '') return;
|
|
6983
7543
|
var bookingUid = bookingUidByProductUid.get(String(productUid));
|
|
6984
7544
|
if (!bookingUid) return;
|
|
@@ -7033,10 +7593,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7033
7593
|
}, {
|
|
7034
7594
|
key: "normalizeHydratedProductOptionItem",
|
|
7035
7595
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
7036
|
-
var
|
|
7037
|
-
var rawNum = (
|
|
7596
|
+
var _ref91, _optionItem$num, _ref92, _optionItem$add_price;
|
|
7597
|
+
var rawNum = (_ref91 = (_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 && _ref91 !== void 0 ? _ref91 : 1;
|
|
7038
7598
|
var parsedNum = Number(rawNum);
|
|
7039
|
-
var rawPrice = (
|
|
7599
|
+
var rawPrice = (_ref92 = (_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 && _ref92 !== void 0 ? _ref92 : 0;
|
|
7040
7600
|
var parsedPrice = Number(rawPrice);
|
|
7041
7601
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
7042
7602
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -7053,7 +7613,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7053
7613
|
}, {
|
|
7054
7614
|
key: "normalizeHydratedOrderProduct",
|
|
7055
7615
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
7056
|
-
var
|
|
7616
|
+
var _this40 = this;
|
|
7057
7617
|
var row = _objectSpread({}, product || {});
|
|
7058
7618
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
7059
7619
|
row.num = row.product_quantity;
|
|
@@ -7061,7 +7621,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7061
7621
|
var productSku = ensureProductSku(row);
|
|
7062
7622
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
7063
7623
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
7064
|
-
return
|
|
7624
|
+
return _this40.normalizeHydratedProductOptionItem(optionItem || {});
|
|
7065
7625
|
}))
|
|
7066
7626
|
});
|
|
7067
7627
|
delete row["product_".concat('option', "_item")];
|
|
@@ -7121,27 +7681,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7121
7681
|
}, {
|
|
7122
7682
|
key: "getOrderInfo",
|
|
7123
7683
|
value: function () {
|
|
7124
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7684
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(order_id) {
|
|
7125
7685
|
var res;
|
|
7126
|
-
return _regeneratorRuntime().wrap(function
|
|
7127
|
-
while (1) switch (
|
|
7686
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context51) {
|
|
7687
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
7128
7688
|
case 0:
|
|
7129
|
-
|
|
7689
|
+
_context51.next = 2;
|
|
7130
7690
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
7131
|
-
with: ['products', 'bookings']
|
|
7691
|
+
with: ['products', 'bookings', 'notes']
|
|
7132
7692
|
}, {
|
|
7133
7693
|
osServer: true
|
|
7134
7694
|
});
|
|
7135
7695
|
case 2:
|
|
7136
|
-
res =
|
|
7137
|
-
return
|
|
7696
|
+
res = _context51.sent;
|
|
7697
|
+
return _context51.abrupt("return", res);
|
|
7138
7698
|
case 4:
|
|
7139
7699
|
case "end":
|
|
7140
|
-
return
|
|
7700
|
+
return _context51.stop();
|
|
7141
7701
|
}
|
|
7142
|
-
},
|
|
7702
|
+
}, _callee48, this);
|
|
7143
7703
|
}));
|
|
7144
|
-
function getOrderInfo(
|
|
7704
|
+
function getOrderInfo(_x54) {
|
|
7145
7705
|
return _getOrderInfo.apply(this, arguments);
|
|
7146
7706
|
}
|
|
7147
7707
|
return getOrderInfo;
|
|
@@ -7149,8 +7709,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7149
7709
|
}, {
|
|
7150
7710
|
key: "getVouchers",
|
|
7151
7711
|
value: function getVouchers() {
|
|
7152
|
-
var _this$store$
|
|
7153
|
-
return ((_this$store$
|
|
7712
|
+
var _this$store$tempOrder6;
|
|
7713
|
+
return ((_this$store$tempOrder6 = this.store.tempOrder) === null || _this$store$tempOrder6 === void 0 ? void 0 : _this$store$tempOrder6.vouchers) || [];
|
|
7154
7714
|
}
|
|
7155
7715
|
}], [{
|
|
7156
7716
|
key: "populateSavedAmounts",
|