@pisell/pisellos 2.2.245 → 2.2.247
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/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
- package/dist/modules/Order/index.d.ts +8 -1
- package/dist/modules/Order/index.js +485 -314
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Payment/walletpass.js +1 -1
- package/dist/server/modules/order/index.js +7 -3
- package/dist/server/utils/small-ticket.d.ts +1 -0
- package/dist/server/utils/small-ticket.js +81 -41
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +5 -2
- package/lib/modules/Order/index.d.ts +8 -1
- package/lib/modules/Order/index.js +120 -10
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Payment/walletpass.js +1 -1
- package/lib/server/modules/order/index.js +7 -3
- package/lib/server/utils/small-ticket.d.ts +1 -0
- package/lib/server/utils/small-ticket.js +40 -3
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -91,6 +91,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
91
91
|
_defineProperty(_assertThisInitialized(_this), "giftSelectResolver", null);
|
|
92
92
|
/** applyPromotion 递归保护 flag(写路径同步调 applyPromotion,禁止重入) */
|
|
93
93
|
_defineProperty(_assertThisInitialized(_this), "isApplyingPromotion", false);
|
|
94
|
+
/** 商品曾应用过客户券卡,客户变更剥离后需强制跑一次 calcDiscount 复位价格 */
|
|
95
|
+
_defineProperty(_assertThisInitialized(_this), "hasActiveCustomerBoundDiscount", false);
|
|
94
96
|
/** 最近一次 applyPromotion 的未满足促销提示 */
|
|
95
97
|
_defineProperty(_assertThisInitialized(_this), "lastUnfulfilledPromotions", []);
|
|
96
98
|
/** 最近一次 applyPromotion 的赠品操作 diff(debug / SDK 读取使用) */
|
|
@@ -660,13 +662,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
660
662
|
}, {
|
|
661
663
|
key: "applyDiscount",
|
|
662
664
|
value: function applyDiscount() {
|
|
663
|
-
var _this$store$discount9,
|
|
665
|
+
var _this$store$discount9,
|
|
666
|
+
_tempOrder$holder3,
|
|
667
|
+
_tempOrder$holder4,
|
|
668
|
+
_this$store$summary2,
|
|
669
|
+
_this2 = this;
|
|
664
670
|
var tempOrder = this.store.tempOrder;
|
|
665
671
|
// 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
|
|
666
672
|
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
667
673
|
// appliedProductDetails / savedAmount 复位。
|
|
668
674
|
if (!tempOrder) return;
|
|
669
675
|
delete tempOrder.discount_list;
|
|
676
|
+
if (this.shouldSkipDiscountCalculation(tempOrder)) return;
|
|
670
677
|
var rulesModule = this.store.rules;
|
|
671
678
|
if (!rulesModule) return;
|
|
672
679
|
var discountList = ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.getDiscountList()) || [];
|
|
@@ -700,6 +707,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
700
707
|
OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
|
|
701
708
|
(_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 || _this$store$discount10.setDiscountList(result.discountList);
|
|
702
709
|
}
|
|
710
|
+
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
711
|
+
return _this2.productHasCustomerBoundDiscount(product);
|
|
712
|
+
});
|
|
703
713
|
}
|
|
704
714
|
|
|
705
715
|
// ─── 促销/赠品 ──────────────────────────────────────
|
|
@@ -758,8 +768,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
758
768
|
key: "applyPromotion",
|
|
759
769
|
value: (function () {
|
|
760
770
|
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
761
|
-
var
|
|
762
|
-
|
|
771
|
+
var _this$promotionEvalua,
|
|
772
|
+
_this$promotionEvalua2,
|
|
773
|
+
_this3 = this;
|
|
774
|
+
var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
|
|
763
775
|
return _regeneratorRuntime().wrap(function _callee6$(_context8) {
|
|
764
776
|
while (1) switch (_context8.prev = _context8.next) {
|
|
765
777
|
case 0:
|
|
@@ -782,8 +794,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
782
794
|
}
|
|
783
795
|
return _context8.abrupt("return");
|
|
784
796
|
case 7:
|
|
797
|
+
strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
|
|
798
|
+
if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
|
|
799
|
+
_context8.next = 10;
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
802
|
+
return _context8.abrupt("return");
|
|
803
|
+
case 10:
|
|
785
804
|
this.isApplyingPromotion = true;
|
|
786
|
-
_context8.prev =
|
|
805
|
+
_context8.prev = 11;
|
|
787
806
|
result = processCartPromotion(tempOrder.products, this.promotionEvaluator); // step 1: toRemove —— 直接过滤
|
|
788
807
|
if (result.giftActions.toRemove.length > 0) {
|
|
789
808
|
removeSet = new Set(result.giftActions.toRemove.map(String));
|
|
@@ -795,16 +814,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
795
814
|
|
|
796
815
|
// step 2: toReduce —— 调整数量
|
|
797
816
|
_iterator3 = _createForOfIteratorHelper(result.giftActions.toReduce);
|
|
798
|
-
_context8.prev =
|
|
817
|
+
_context8.prev = 15;
|
|
799
818
|
_iterator3.s();
|
|
800
|
-
case
|
|
819
|
+
case 17:
|
|
801
820
|
if ((_step3 = _iterator3.n()).done) {
|
|
802
|
-
_context8.next =
|
|
821
|
+
_context8.next = 37;
|
|
803
822
|
break;
|
|
804
823
|
}
|
|
805
824
|
reduce = _step3.value;
|
|
806
825
|
_iterator6 = _createForOfIteratorHelper(reduce.items);
|
|
807
|
-
_context8.prev =
|
|
826
|
+
_context8.prev = 20;
|
|
808
827
|
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
809
828
|
var item, product;
|
|
810
829
|
return _regeneratorRuntime().wrap(function _loop2$(_context7) {
|
|
@@ -824,47 +843,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
824
843
|
}, _loop2);
|
|
825
844
|
});
|
|
826
845
|
_iterator6.s();
|
|
827
|
-
case
|
|
846
|
+
case 23:
|
|
828
847
|
if ((_step6 = _iterator6.n()).done) {
|
|
829
|
-
_context8.next =
|
|
848
|
+
_context8.next = 27;
|
|
830
849
|
break;
|
|
831
850
|
}
|
|
832
|
-
return _context8.delegateYield(_loop2(), "t0",
|
|
833
|
-
case
|
|
834
|
-
_context8.next =
|
|
851
|
+
return _context8.delegateYield(_loop2(), "t0", 25);
|
|
852
|
+
case 25:
|
|
853
|
+
_context8.next = 23;
|
|
835
854
|
break;
|
|
836
|
-
case
|
|
837
|
-
_context8.next =
|
|
855
|
+
case 27:
|
|
856
|
+
_context8.next = 32;
|
|
838
857
|
break;
|
|
839
|
-
case 26:
|
|
840
|
-
_context8.prev = 26;
|
|
841
|
-
_context8.t1 = _context8["catch"](17);
|
|
842
|
-
_iterator6.e(_context8.t1);
|
|
843
858
|
case 29:
|
|
844
859
|
_context8.prev = 29;
|
|
845
|
-
|
|
846
|
-
|
|
860
|
+
_context8.t1 = _context8["catch"](20);
|
|
861
|
+
_iterator6.e(_context8.t1);
|
|
847
862
|
case 32:
|
|
848
|
-
_context8.
|
|
863
|
+
_context8.prev = 32;
|
|
864
|
+
_iterator6.f();
|
|
865
|
+
return _context8.finish(32);
|
|
866
|
+
case 35:
|
|
867
|
+
_context8.next = 17;
|
|
849
868
|
break;
|
|
850
|
-
case
|
|
851
|
-
_context8.next =
|
|
869
|
+
case 37:
|
|
870
|
+
_context8.next = 42;
|
|
852
871
|
break;
|
|
853
|
-
case 36:
|
|
854
|
-
_context8.prev = 36;
|
|
855
|
-
_context8.t2 = _context8["catch"](12);
|
|
856
|
-
_iterator3.e(_context8.t2);
|
|
857
872
|
case 39:
|
|
858
873
|
_context8.prev = 39;
|
|
859
|
-
|
|
860
|
-
|
|
874
|
+
_context8.t2 = _context8["catch"](15);
|
|
875
|
+
_iterator3.e(_context8.t2);
|
|
861
876
|
case 42:
|
|
877
|
+
_context8.prev = 42;
|
|
878
|
+
_iterator3.f();
|
|
879
|
+
return _context8.finish(42);
|
|
880
|
+
case 45:
|
|
862
881
|
if (!(result.giftActions.toAdd.length > 0)) {
|
|
863
|
-
_context8.next =
|
|
882
|
+
_context8.next = 68;
|
|
864
883
|
break;
|
|
865
884
|
}
|
|
866
885
|
if (this.giftSelectResolver) {
|
|
867
|
-
_context8.next =
|
|
886
|
+
_context8.next = 50;
|
|
868
887
|
break;
|
|
869
888
|
}
|
|
870
889
|
if (result.giftActions.toAdd.some(function (g) {
|
|
@@ -875,11 +894,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
875
894
|
} else {
|
|
876
895
|
console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
|
|
877
896
|
}
|
|
878
|
-
_context8.next =
|
|
897
|
+
_context8.next = 68;
|
|
879
898
|
break;
|
|
880
|
-
case
|
|
899
|
+
case 50:
|
|
881
900
|
_iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
|
|
882
|
-
_context8.prev =
|
|
901
|
+
_context8.prev = 51;
|
|
883
902
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
884
903
|
var addAction, _sameStrategy$metadat, sameStrategy, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
|
|
885
904
|
return _regeneratorRuntime().wrap(function _loop$(_context6) {
|
|
@@ -903,7 +922,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
903
922
|
case 6:
|
|
904
923
|
_context6.prev = 6;
|
|
905
924
|
_context6.next = 9;
|
|
906
|
-
return
|
|
925
|
+
return _this3.giftSelectResolver({
|
|
907
926
|
strategyId: addAction.strategyId,
|
|
908
927
|
strategyName: addAction.strategyName,
|
|
909
928
|
giftCount: addAction.giftCount,
|
|
@@ -938,7 +957,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
938
957
|
_context6.next = 26;
|
|
939
958
|
break;
|
|
940
959
|
}
|
|
941
|
-
linked =
|
|
960
|
+
linked = _this3.createLinkedProductAndBooking({
|
|
942
961
|
product: gp,
|
|
943
962
|
booking: booking
|
|
944
963
|
});
|
|
@@ -977,33 +996,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
977
996
|
}, _loop, null, [[6, 39], [14, 31, 34, 37]]);
|
|
978
997
|
});
|
|
979
998
|
_iterator4.s();
|
|
980
|
-
case
|
|
999
|
+
case 54:
|
|
981
1000
|
if ((_step4 = _iterator4.n()).done) {
|
|
982
|
-
_context8.next =
|
|
1001
|
+
_context8.next = 60;
|
|
983
1002
|
break;
|
|
984
1003
|
}
|
|
985
|
-
return _context8.delegateYield(_loop(), "t3",
|
|
986
|
-
case
|
|
1004
|
+
return _context8.delegateYield(_loop(), "t3", 56);
|
|
1005
|
+
case 56:
|
|
987
1006
|
if (!_context8.t3) {
|
|
988
|
-
_context8.next =
|
|
1007
|
+
_context8.next = 58;
|
|
989
1008
|
break;
|
|
990
1009
|
}
|
|
991
|
-
return _context8.abrupt("continue",
|
|
992
|
-
case
|
|
993
|
-
_context8.next =
|
|
1010
|
+
return _context8.abrupt("continue", 58);
|
|
1011
|
+
case 58:
|
|
1012
|
+
_context8.next = 54;
|
|
994
1013
|
break;
|
|
995
|
-
case
|
|
996
|
-
_context8.next =
|
|
1014
|
+
case 60:
|
|
1015
|
+
_context8.next = 65;
|
|
997
1016
|
break;
|
|
998
|
-
case 59:
|
|
999
|
-
_context8.prev = 59;
|
|
1000
|
-
_context8.t4 = _context8["catch"](48);
|
|
1001
|
-
_iterator4.e(_context8.t4);
|
|
1002
1017
|
case 62:
|
|
1003
1018
|
_context8.prev = 62;
|
|
1004
|
-
|
|
1005
|
-
|
|
1019
|
+
_context8.t4 = _context8["catch"](51);
|
|
1020
|
+
_iterator4.e(_context8.t4);
|
|
1006
1021
|
case 65:
|
|
1022
|
+
_context8.prev = 65;
|
|
1023
|
+
_iterator4.f();
|
|
1024
|
+
return _context8.finish(65);
|
|
1025
|
+
case 68:
|
|
1007
1026
|
tempOrder.products = result.products;
|
|
1008
1027
|
this.lastUnfulfilledPromotions = result.unfulfilledPromotions;
|
|
1009
1028
|
this.lastGiftActions = result.giftActions;
|
|
@@ -1021,21 +1040,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1021
1040
|
products: tempOrder.products
|
|
1022
1041
|
};
|
|
1023
1042
|
this.effectsEmit('onPromotionApplied', payload);
|
|
1024
|
-
_context8.next =
|
|
1043
|
+
_context8.next = 78;
|
|
1025
1044
|
break;
|
|
1026
|
-
case 72:
|
|
1027
|
-
_context8.prev = 72;
|
|
1028
|
-
_context8.t5 = _context8["catch"](8);
|
|
1029
|
-
console.error('[OrderModule] applyPromotion failed', _context8.t5);
|
|
1030
1045
|
case 75:
|
|
1031
1046
|
_context8.prev = 75;
|
|
1032
|
-
|
|
1033
|
-
|
|
1047
|
+
_context8.t5 = _context8["catch"](11);
|
|
1048
|
+
console.error('[OrderModule] applyPromotion failed', _context8.t5);
|
|
1034
1049
|
case 78:
|
|
1050
|
+
_context8.prev = 78;
|
|
1051
|
+
this.isApplyingPromotion = false;
|
|
1052
|
+
return _context8.finish(78);
|
|
1053
|
+
case 81:
|
|
1035
1054
|
case "end":
|
|
1036
1055
|
return _context8.stop();
|
|
1037
1056
|
}
|
|
1038
|
-
}, _callee6, this, [[
|
|
1057
|
+
}, _callee6, this, [[11, 75, 78, 81], [15, 39, 42, 45], [20, 29, 32, 35], [51, 62, 65, 68]]);
|
|
1039
1058
|
}));
|
|
1040
1059
|
function applyPromotion() {
|
|
1041
1060
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -1211,11 +1230,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1211
1230
|
}, {
|
|
1212
1231
|
key: "calculatePaymentTotal",
|
|
1213
1232
|
value: function calculatePaymentTotal(payments) {
|
|
1214
|
-
var
|
|
1233
|
+
var _this4 = this;
|
|
1215
1234
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1216
1235
|
includeVoided: false
|
|
1217
1236
|
}).reduce(function (sum, payment) {
|
|
1218
|
-
return sum.plus(
|
|
1237
|
+
return sum.plus(_this4.calculatePaymentEffectiveAmount(payment));
|
|
1219
1238
|
}, new Decimal(0));
|
|
1220
1239
|
}
|
|
1221
1240
|
}, {
|
|
@@ -1267,14 +1286,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1267
1286
|
}, {
|
|
1268
1287
|
key: "calculateDepositPaidAmount",
|
|
1269
1288
|
value: function calculateDepositPaidAmount(payments) {
|
|
1270
|
-
var
|
|
1289
|
+
var _this5 = this;
|
|
1271
1290
|
return (payments || []).reduce(function (sum, payment) {
|
|
1272
1291
|
var paymentRecord = payment;
|
|
1273
1292
|
if ((paymentRecord === null || paymentRecord === void 0 ? void 0 : paymentRecord.status) !== 'paid') return sum;
|
|
1274
1293
|
var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
|
|
1275
1294
|
if (!isDepositPayment) return sum;
|
|
1276
1295
|
if (paymentRecord.origin_amount !== undefined && paymentRecord.origin_amount !== null && paymentRecord.origin_amount !== '') {
|
|
1277
|
-
return sum.plus(
|
|
1296
|
+
return sum.plus(_this5.calculatePaymentGapAmount(paymentRecord));
|
|
1278
1297
|
}
|
|
1279
1298
|
var rounding = new Decimal(paymentRecord.rounding_amount || 0);
|
|
1280
1299
|
return sum.plus(new Decimal(paymentRecord.amount || 0).minus(rounding));
|
|
@@ -1419,16 +1438,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1419
1438
|
}, {
|
|
1420
1439
|
key: "calculatePaidPaymentSummary",
|
|
1421
1440
|
value: function calculatePaidPaymentSummary(payments) {
|
|
1422
|
-
var
|
|
1441
|
+
var _this6 = this;
|
|
1423
1442
|
return (payments || []).reduce(function (summary, payment) {
|
|
1424
1443
|
var paymentRecord = payment;
|
|
1425
1444
|
if ((paymentRecord === null || paymentRecord === void 0 ? void 0 : paymentRecord.status) !== 'paid') return summary;
|
|
1426
1445
|
return {
|
|
1427
1446
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
1428
1447
|
orderPaidAmount: summary.orderPaidAmount.plus(paymentRecord.origin_amount || 0),
|
|
1429
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
1430
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
1431
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
1448
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this6.calculatePaymentGapAmount(paymentRecord)),
|
|
1449
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this6.calculatePaymentServiceFee(paymentRecord)),
|
|
1450
|
+
roundingAmount: summary.roundingAmount.plus(_this6.calculatePaymentRoundingAmount(paymentRecord))
|
|
1432
1451
|
};
|
|
1433
1452
|
}, {
|
|
1434
1453
|
customerPaidAmount: new Decimal(0),
|
|
@@ -1613,15 +1632,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1613
1632
|
}, {
|
|
1614
1633
|
key: "normalizeFingerprintValue",
|
|
1615
1634
|
value: function normalizeFingerprintValue(value) {
|
|
1616
|
-
var
|
|
1635
|
+
var _this7 = this;
|
|
1617
1636
|
if (Array.isArray(value)) {
|
|
1618
1637
|
return value.map(function (item) {
|
|
1619
|
-
return
|
|
1638
|
+
return _this7.normalizeFingerprintValue(item);
|
|
1620
1639
|
});
|
|
1621
1640
|
}
|
|
1622
1641
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
1623
1642
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
1624
|
-
result[key] =
|
|
1643
|
+
result[key] = _this7.normalizeFingerprintValue(value[key]);
|
|
1625
1644
|
return result;
|
|
1626
1645
|
}, {});
|
|
1627
1646
|
}
|
|
@@ -1636,7 +1655,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1636
1655
|
_sku$barcode,
|
|
1637
1656
|
_ref18,
|
|
1638
1657
|
_sku$variant_id,
|
|
1639
|
-
|
|
1658
|
+
_this8 = this;
|
|
1640
1659
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1641
1660
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1642
1661
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -1670,7 +1689,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1670
1689
|
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,
|
|
1671
1690
|
option_group_item_id: (_ref20 = (_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 && _ref20 !== void 0 ? _ref20 : null,
|
|
1672
1691
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
1673
|
-
add_price:
|
|
1692
|
+
add_price: _this8.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)
|
|
1674
1693
|
};
|
|
1675
1694
|
})
|
|
1676
1695
|
}),
|
|
@@ -1680,8 +1699,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1680
1699
|
bundle_product_id: (_ref21 = (_ref22 = (_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 && _ref22 !== void 0 ? _ref22 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref21 !== void 0 ? _ref21 : null,
|
|
1681
1700
|
bundle_variant_id: (_ref23 = (_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 && _ref23 !== void 0 ? _ref23 : 0,
|
|
1682
1701
|
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),
|
|
1683
|
-
price:
|
|
1684
|
-
bundle_selling_price:
|
|
1702
|
+
price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
1703
|
+
bundle_selling_price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
1685
1704
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
1686
1705
|
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 : ''
|
|
1687
1706
|
};
|
|
@@ -1691,7 +1710,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1691
1710
|
return {
|
|
1692
1711
|
type: (_ref24 = (_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 && _ref24 !== void 0 ? _ref24 : '',
|
|
1693
1712
|
discount_id: (_ref25 = (_ref26 = (_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 && _ref26 !== void 0 ? _ref26 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref25 !== void 0 ? _ref25 : null,
|
|
1694
|
-
amount:
|
|
1713
|
+
amount: _this8.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
1695
1714
|
};
|
|
1696
1715
|
}))
|
|
1697
1716
|
};
|
|
@@ -1699,9 +1718,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1699
1718
|
}, {
|
|
1700
1719
|
key: "buildOrderProductsFingerprint",
|
|
1701
1720
|
value: function buildOrderProductsFingerprint(products) {
|
|
1702
|
-
var
|
|
1721
|
+
var _this9 = this;
|
|
1703
1722
|
var items = (products || []).map(function (product) {
|
|
1704
|
-
return
|
|
1723
|
+
return _this9.buildProductFingerprintItem(product);
|
|
1705
1724
|
});
|
|
1706
1725
|
items.sort(function (left, right) {
|
|
1707
1726
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -1723,7 +1742,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1723
1742
|
_sku$barcode2,
|
|
1724
1743
|
_ref28,
|
|
1725
1744
|
_sku$variant_id2,
|
|
1726
|
-
|
|
1745
|
+
_this10 = this;
|
|
1727
1746
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1728
1747
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1729
1748
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -1754,7 +1773,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1754
1773
|
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,
|
|
1755
1774
|
option_group_item_id: (_ref30 = (_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 && _ref30 !== void 0 ? _ref30 : null,
|
|
1756
1775
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
1757
|
-
add_price:
|
|
1776
|
+
add_price: _this10.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)
|
|
1758
1777
|
};
|
|
1759
1778
|
})
|
|
1760
1779
|
}),
|
|
@@ -1768,14 +1787,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1768
1787
|
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),
|
|
1769
1788
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
1770
1789
|
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 : '',
|
|
1771
|
-
option:
|
|
1790
|
+
option: _this10.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
1772
1791
|
var _ref36, _option$id3, _option$option_group_5, _ref37, _option$option_group_6, _option$num3, _option$add_price3;
|
|
1773
1792
|
return {
|
|
1774
1793
|
id: (_ref36 = (_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 && _ref36 !== void 0 ? _ref36 : null,
|
|
1775
1794
|
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,
|
|
1776
1795
|
option_group_item_id: (_ref37 = (_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 && _ref37 !== void 0 ? _ref37 : null,
|
|
1777
1796
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
1778
|
-
add_price:
|
|
1797
|
+
add_price: _this10.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)
|
|
1779
1798
|
};
|
|
1780
1799
|
}))
|
|
1781
1800
|
};
|
|
@@ -1785,7 +1804,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1785
1804
|
return {
|
|
1786
1805
|
type: (_ref38 = (_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 && _ref38 !== void 0 ? _ref38 : '',
|
|
1787
1806
|
discount_id: (_ref39 = (_ref40 = (_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 && _ref40 !== void 0 ? _ref40 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref39 !== void 0 ? _ref39 : null,
|
|
1788
|
-
amount:
|
|
1807
|
+
amount: _this10.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
1789
1808
|
};
|
|
1790
1809
|
}))
|
|
1791
1810
|
};
|
|
@@ -1793,20 +1812,48 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1793
1812
|
}, {
|
|
1794
1813
|
key: "buildOrderProductsStructuralFingerprint",
|
|
1795
1814
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
1796
|
-
var
|
|
1815
|
+
var _this11 = this;
|
|
1797
1816
|
var items = (products || []).map(function (product) {
|
|
1798
|
-
return
|
|
1817
|
+
return _this11.buildProductStructuralFingerprintItem(product);
|
|
1799
1818
|
});
|
|
1800
1819
|
items.sort(function (left, right) {
|
|
1801
1820
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
1802
1821
|
});
|
|
1803
1822
|
return JSON.stringify(items);
|
|
1804
1823
|
}
|
|
1824
|
+
}, {
|
|
1825
|
+
key: "getManualDepositOverride",
|
|
1826
|
+
value: function getManualDepositOverride(tempOrder) {
|
|
1827
|
+
var _tempOrder$_extend3;
|
|
1828
|
+
var override = (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.manualDepositOverride;
|
|
1829
|
+
if (!override || _typeof(override) !== 'object') return null;
|
|
1830
|
+
if (typeof override.amount !== 'string') return null;
|
|
1831
|
+
if (typeof override.productStructuralFingerprint !== 'string') return null;
|
|
1832
|
+
return override;
|
|
1833
|
+
}
|
|
1834
|
+
}, {
|
|
1835
|
+
key: "setManualDepositOverride",
|
|
1836
|
+
value: function setManualDepositOverride(tempOrder, amount) {
|
|
1837
|
+
tempOrder._extend = _objectSpread(_objectSpread({}, tempOrder._extend || {}), {}, {
|
|
1838
|
+
manualDepositOverride: {
|
|
1839
|
+
amount: amount,
|
|
1840
|
+
productStructuralFingerprint: this.buildOrderProductsStructuralFingerprint(tempOrder.products)
|
|
1841
|
+
}
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
}, {
|
|
1845
|
+
key: "clearManualDepositOverride",
|
|
1846
|
+
value: function clearManualDepositOverride(tempOrder) {
|
|
1847
|
+
var _tempOrder$_extend4;
|
|
1848
|
+
if (!((_tempOrder$_extend4 = tempOrder._extend) !== null && _tempOrder$_extend4 !== void 0 && _tempOrder$_extend4.manualDepositOverride)) return;
|
|
1849
|
+
tempOrder._extend = _objectSpread({}, tempOrder._extend);
|
|
1850
|
+
delete tempOrder._extend.manualDepositOverride;
|
|
1851
|
+
}
|
|
1805
1852
|
}, {
|
|
1806
1853
|
key: "getOriginalSalesSnapshot",
|
|
1807
1854
|
value: function getOriginalSalesSnapshot(tempOrder) {
|
|
1808
|
-
var _tempOrder$
|
|
1809
|
-
var snapshot = (_tempOrder$
|
|
1855
|
+
var _tempOrder$_extend5;
|
|
1856
|
+
var snapshot = (_tempOrder$_extend5 = tempOrder._extend) === null || _tempOrder$_extend5 === void 0 ? void 0 : _tempOrder$_extend5.originalSalesSnapshot;
|
|
1810
1857
|
if (!snapshot || _typeof(snapshot) !== 'object') return null;
|
|
1811
1858
|
if (typeof snapshot.productFingerprint !== 'string') return null;
|
|
1812
1859
|
return snapshot;
|
|
@@ -2036,13 +2083,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2036
2083
|
}, {
|
|
2037
2084
|
key: "getOrderIdentity",
|
|
2038
2085
|
value: function getOrderIdentity() {
|
|
2039
|
-
var _ref41, _ref42, _tempOrder$order_id, _tempOrder$
|
|
2086
|
+
var _ref41, _ref42, _tempOrder$order_id, _tempOrder$_extend6;
|
|
2040
2087
|
var tempOrder = this.store.tempOrder;
|
|
2041
2088
|
if (!tempOrder) return null;
|
|
2042
2089
|
var lastOrderInfo = this.store.lastOrderInfo || {};
|
|
2043
2090
|
var orderId = (_ref41 = (_ref42 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref42 !== void 0 ? _ref42 : lastOrderInfo.id) !== null && _ref41 !== void 0 ? _ref41 : null;
|
|
2044
2091
|
return {
|
|
2045
|
-
localId: this.cacheId || ((_tempOrder$
|
|
2092
|
+
localId: this.cacheId || ((_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.localId),
|
|
2046
2093
|
orderId: orderId,
|
|
2047
2094
|
externalSaleNumber: tempOrder.external_sale_number || lastOrderInfo.external_sale_number || '',
|
|
2048
2095
|
orderNumber: tempOrder.order_number || lastOrderInfo.order_number || '',
|
|
@@ -2172,9 +2219,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2172
2219
|
}, {
|
|
2173
2220
|
key: "sanitizeTempOrderProducts",
|
|
2174
2221
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
2175
|
-
var
|
|
2222
|
+
var _this12 = this;
|
|
2176
2223
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2177
|
-
return
|
|
2224
|
+
return _this12.sanitizeOrderProductForTempOrder(product);
|
|
2178
2225
|
});
|
|
2179
2226
|
}
|
|
2180
2227
|
}, {
|
|
@@ -2387,9 +2434,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2387
2434
|
}, {
|
|
2388
2435
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
2389
2436
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
2390
|
-
var
|
|
2437
|
+
var _this13 = this;
|
|
2391
2438
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
2392
|
-
return
|
|
2439
|
+
return _this13.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
2393
2440
|
});
|
|
2394
2441
|
}
|
|
2395
2442
|
}, {
|
|
@@ -2397,12 +2444,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2397
2444
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
2398
2445
|
var _product$metadata5,
|
|
2399
2446
|
_product$metadata6,
|
|
2400
|
-
|
|
2447
|
+
_this14 = this;
|
|
2401
2448
|
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);
|
|
2402
2449
|
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);
|
|
2403
2450
|
if (!productUid && !bookingUid) return;
|
|
2404
2451
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
2405
|
-
var currentBookingUid =
|
|
2452
|
+
var currentBookingUid = _this14.getBookingUniqueIdentificationNumber(booking);
|
|
2406
2453
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
2407
2454
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
2408
2455
|
return true;
|
|
@@ -2419,21 +2466,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2419
2466
|
}, {
|
|
2420
2467
|
key: "applyOrderProductsDepositSummary",
|
|
2421
2468
|
value: function applyOrderProductsDepositSummary(tempOrder, summary) {
|
|
2422
|
-
var _tempOrder$
|
|
2469
|
+
var _tempOrder$_extend7;
|
|
2423
2470
|
var depositSummary = calculateOrderProductsDeposit(tempOrder.products || [], {
|
|
2424
|
-
productsByUid: (_tempOrder$
|
|
2471
|
+
productsByUid: (_tempOrder$_extend7 = tempOrder._extend) === null || _tempOrder$_extend7 === void 0 ? void 0 : _tempOrder$_extend7.productsByUid
|
|
2425
2472
|
});
|
|
2473
|
+
var manualDepositOverride = this.getManualDepositOverride(tempOrder);
|
|
2474
|
+
var currentStructuralFingerprint = manualDepositOverride ? this.buildOrderProductsStructuralFingerprint(tempOrder.products) : '';
|
|
2475
|
+
var shouldUseManualDepositOverride = Boolean(manualDepositOverride && manualDepositOverride.productStructuralFingerprint === currentStructuralFingerprint);
|
|
2476
|
+
if (manualDepositOverride && !shouldUseManualDepositOverride) {
|
|
2477
|
+
this.clearManualDepositOverride(tempOrder);
|
|
2478
|
+
}
|
|
2479
|
+
var depositAmount = shouldUseManualDepositOverride ? manualDepositOverride.amount : depositSummary.totalText;
|
|
2480
|
+
var hasDepositAmount = new Decimal(depositAmount).gt(0);
|
|
2426
2481
|
var nextSummary = _objectSpread(_objectSpread({}, summary), {}, {
|
|
2427
|
-
deposit_amount:
|
|
2428
|
-
deposit:
|
|
2429
|
-
total:
|
|
2482
|
+
deposit_amount: depositAmount,
|
|
2483
|
+
deposit: hasDepositAmount ? {
|
|
2484
|
+
total: depositAmount,
|
|
2430
2485
|
deposit_policy_ids: depositSummary.deposit_policy_ids,
|
|
2431
2486
|
deposit_policy_data: depositSummary.protocols,
|
|
2432
2487
|
hasDeposit: true
|
|
2433
2488
|
} : undefined
|
|
2434
2489
|
});
|
|
2435
|
-
tempOrder.deposit_amount =
|
|
2436
|
-
tempOrder.is_deposit =
|
|
2490
|
+
tempOrder.deposit_amount = depositAmount;
|
|
2491
|
+
tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
|
|
2437
2492
|
return nextSummary;
|
|
2438
2493
|
}
|
|
2439
2494
|
}, {
|
|
@@ -2655,6 +2710,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2655
2710
|
var depositAmount = this.normalizeDepositAmount(amount);
|
|
2656
2711
|
var previousSummary = this.store.summary || createEmptySummary();
|
|
2657
2712
|
var summaryWithDeposit = this.applyDepositAmountToSummary(tempOrder, _objectSpread(_objectSpread({}, createEmptySummary()), previousSummary), depositAmount);
|
|
2713
|
+
this.setManualDepositOverride(tempOrder, depositAmount);
|
|
2658
2714
|
var paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
2659
2715
|
var summary = _objectSpread(_objectSpread({}, summaryWithDeposit), {}, {
|
|
2660
2716
|
amount_gap: this.calculateSummaryAmountGap({
|
|
@@ -2712,18 +2768,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2712
2768
|
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;
|
|
2713
2769
|
return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
2714
2770
|
}
|
|
2771
|
+
}, {
|
|
2772
|
+
key: "productHasCustomerBoundDiscount",
|
|
2773
|
+
value: function productHasCustomerBoundDiscount(product) {
|
|
2774
|
+
var _this15 = this;
|
|
2775
|
+
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
2776
|
+
return _this15.isCustomerBoundDiscount(discount);
|
|
2777
|
+
})) {
|
|
2778
|
+
return true;
|
|
2779
|
+
}
|
|
2780
|
+
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
2781
|
+
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
2782
|
+
return _this15.isCustomerBoundDiscount(discount);
|
|
2783
|
+
});
|
|
2784
|
+
});
|
|
2785
|
+
}
|
|
2786
|
+
}, {
|
|
2787
|
+
key: "shouldSkipDiscountCalculation",
|
|
2788
|
+
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
2789
|
+
var _this$store$discount13,
|
|
2790
|
+
_this$store$discount14,
|
|
2791
|
+
_this16 = this;
|
|
2792
|
+
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
2793
|
+
var discountList = ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 || (_this$store$discount14 = _this$store$discount13.getDiscountList) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.call(_this$store$discount13)) || [];
|
|
2794
|
+
if (discountList.length > 0) return false;
|
|
2795
|
+
return !(tempOrder.products || []).some(function (product) {
|
|
2796
|
+
return _this16.productHasCustomerBoundDiscount(product);
|
|
2797
|
+
});
|
|
2798
|
+
}
|
|
2715
2799
|
}, {
|
|
2716
2800
|
key: "clearCustomerBoundDiscounts",
|
|
2717
2801
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
2718
|
-
var
|
|
2802
|
+
var _this17 = this,
|
|
2719
2803
|
_discountModule$getDi,
|
|
2720
2804
|
_discountModule$getOr,
|
|
2721
2805
|
_discountModule$setDi,
|
|
2722
2806
|
_discountModule$setOr;
|
|
2807
|
+
var didRemoveCustomerBoundDiscount = false;
|
|
2723
2808
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
2724
2809
|
if (!Array.isArray(discountList)) return [];
|
|
2725
2810
|
return discountList.filter(function (discount) {
|
|
2726
|
-
|
|
2811
|
+
var shouldRemove = _this17.isCustomerBoundDiscount(discount);
|
|
2812
|
+
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
2813
|
+
return !shouldRemove;
|
|
2727
2814
|
});
|
|
2728
2815
|
};
|
|
2729
2816
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
@@ -2740,17 +2827,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2740
2827
|
return nextProduct;
|
|
2741
2828
|
});
|
|
2742
2829
|
delete tempOrder.discount_list;
|
|
2830
|
+
if (didRemoveCustomerBoundDiscount) {
|
|
2831
|
+
this.hasActiveCustomerBoundDiscount = true;
|
|
2832
|
+
}
|
|
2743
2833
|
var discountModule = this.store.discount;
|
|
2744
2834
|
if (!discountModule) return;
|
|
2745
2835
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
2746
2836
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
2747
2837
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
2748
2838
|
if (discount !== null && discount !== void 0 && discount.isEditMode) return true;
|
|
2749
|
-
return !
|
|
2839
|
+
return !_this17.isCustomerBoundDiscount(discount);
|
|
2750
2840
|
});
|
|
2751
2841
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
2752
2842
|
if (discount !== null && discount !== void 0 && discount.isEditMode) return true;
|
|
2753
|
-
return !
|
|
2843
|
+
return !_this17.isCustomerBoundDiscount(discount);
|
|
2754
2844
|
});
|
|
2755
2845
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
2756
2846
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -2917,7 +3007,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2917
3007
|
}, {
|
|
2918
3008
|
key: "addOrderPayment",
|
|
2919
3009
|
value: function addOrderPayment(payment) {
|
|
2920
|
-
var
|
|
3010
|
+
var _this18 = this;
|
|
2921
3011
|
this.logInfo('addOrderPayment', {
|
|
2922
3012
|
payment: payment
|
|
2923
3013
|
});
|
|
@@ -2934,7 +3024,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2934
3024
|
void this.recalculateSummary({
|
|
2935
3025
|
createIfMissing: true
|
|
2936
3026
|
}).catch(function (error) {
|
|
2937
|
-
|
|
3027
|
+
_this18.logError('recalculate summary after addOrderPayment failed', {
|
|
2938
3028
|
error: error instanceof Error ? error.message : String(error)
|
|
2939
3029
|
});
|
|
2940
3030
|
});
|
|
@@ -2999,7 +3089,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2999
3089
|
}, {
|
|
3000
3090
|
key: "updateVoucherOrderPayments",
|
|
3001
3091
|
value: function updateVoucherOrderPayments(payments) {
|
|
3002
|
-
var
|
|
3092
|
+
var _this19 = this;
|
|
3003
3093
|
var tempOrder = this.ensureTempOrder();
|
|
3004
3094
|
var isVoucherPayment = function isVoucherPayment(payment) {
|
|
3005
3095
|
return payment.voucher_id !== undefined && Number(payment.voucher_id) !== 0;
|
|
@@ -3020,7 +3110,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3020
3110
|
// return paymentRecord
|
|
3021
3111
|
// };
|
|
3022
3112
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
3023
|
-
return
|
|
3113
|
+
return _this19.normalizePaymentSource(payment, {
|
|
3024
3114
|
defaultPaid: true
|
|
3025
3115
|
});
|
|
3026
3116
|
})).filter(function (payment) {
|
|
@@ -3049,7 +3139,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3049
3139
|
void this.recalculateSummary({
|
|
3050
3140
|
createIfMissing: true
|
|
3051
3141
|
}).catch(function (error) {
|
|
3052
|
-
|
|
3142
|
+
_this19.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
3053
3143
|
error: error instanceof Error ? error.message : String(error)
|
|
3054
3144
|
});
|
|
3055
3145
|
});
|
|
@@ -3185,7 +3275,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3185
3275
|
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, product, booking) {
|
|
3186
3276
|
var _booking_uid,
|
|
3187
3277
|
_metadata,
|
|
3188
|
-
|
|
3278
|
+
_this20 = this;
|
|
3189
3279
|
var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
|
|
3190
3280
|
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
3191
3281
|
while (1) switch (_context18.prev = _context18.next) {
|
|
@@ -3210,8 +3300,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3210
3300
|
hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
3211
3301
|
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
|
|
3212
3302
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
3213
|
-
if (
|
|
3214
|
-
if (
|
|
3303
|
+
if (_this20.hasGoodPassDiscount(item)) return false;
|
|
3304
|
+
if (_this20.hasOrderProductLineNote(item)) return false;
|
|
3215
3305
|
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
3216
3306
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
3217
3307
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
@@ -3501,17 +3591,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3501
3591
|
}, {
|
|
3502
3592
|
key: "preservePersistedBundlePriceFields",
|
|
3503
3593
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
3504
|
-
var
|
|
3594
|
+
var _this21 = this;
|
|
3505
3595
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
3506
3596
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
3507
3597
|
var previousByIdentity = new Map();
|
|
3508
3598
|
previousBundles.forEach(function (bundle) {
|
|
3509
|
-
var identity =
|
|
3599
|
+
var identity = _this21.getBundleRuntimeIdentity(bundle);
|
|
3510
3600
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
3511
3601
|
});
|
|
3512
3602
|
return nextBundles.map(function (bundle, index) {
|
|
3513
3603
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
3514
|
-
var previous = previousByIdentity.get(
|
|
3604
|
+
var previous = previousByIdentity.get(_this21.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
3515
3605
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
3516
3606
|
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
3517
3607
|
price: previous.price,
|
|
@@ -3827,17 +3917,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3827
3917
|
key: "removeProductsFromOrder",
|
|
3828
3918
|
value: (function () {
|
|
3829
3919
|
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(identities) {
|
|
3830
|
-
var
|
|
3831
|
-
|
|
3832
|
-
|
|
3920
|
+
var _this22 = this;
|
|
3921
|
+
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
|
|
3922
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context25) {
|
|
3923
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
3833
3924
|
case 0:
|
|
3834
3925
|
tempOrder = this.ensureTempOrder();
|
|
3835
3926
|
if (identities.length) {
|
|
3836
|
-
|
|
3927
|
+
_context25.next = 3;
|
|
3837
3928
|
break;
|
|
3838
3929
|
}
|
|
3839
|
-
return
|
|
3930
|
+
return _context25.abrupt("return", tempOrder.products);
|
|
3840
3931
|
case 3:
|
|
3932
|
+
productsBeforeRemove = tempOrder.products || [];
|
|
3933
|
+
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
3934
|
+
matchedProducts = productsBeforeRemove.filter(function (item) {
|
|
3935
|
+
return identities.some(function (identity) {
|
|
3936
|
+
return isIdentityMatch(item, identity);
|
|
3937
|
+
});
|
|
3938
|
+
});
|
|
3841
3939
|
removedProducts = [];
|
|
3842
3940
|
tempOrder.products = tempOrder.products.filter(function (item) {
|
|
3843
3941
|
var shouldRemove = identities.some(function (identity) {
|
|
@@ -3850,15 +3948,88 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3850
3948
|
product = _removedProducts[_i2];
|
|
3851
3949
|
this.removeLinkedBookingsForProduct(tempOrder, product);
|
|
3852
3950
|
}
|
|
3853
|
-
|
|
3951
|
+
linkedBookingUidsToRemove = new Set();
|
|
3952
|
+
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
3953
|
+
_context25.prev = 11;
|
|
3954
|
+
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
3955
|
+
var _metadata8, _metadata9, _metadata10, _metadata11;
|
|
3956
|
+
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
3957
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context24) {
|
|
3958
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
3959
|
+
case 0:
|
|
3960
|
+
product = _step21.value;
|
|
3961
|
+
productUid = (product === null || product === void 0 || (_metadata8 = product.metadata) === null || _metadata8 === void 0 ? void 0 : _metadata8.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
3962
|
+
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata9 = product.metadata) === null || _metadata9 === void 0 ? void 0 : _metadata9.booking_uid);
|
|
3963
|
+
isAddTimeProduct = (product === null || product === void 0 || (_metadata10 = product.metadata) === null || _metadata10 === void 0 ? void 0 : _metadata10.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.product_add_schedule_time) !== null;
|
|
3964
|
+
if (!isAddTimeProduct) {
|
|
3965
|
+
_context24.next = 6;
|
|
3966
|
+
break;
|
|
3967
|
+
}
|
|
3968
|
+
return _context24.abrupt("return", 1);
|
|
3969
|
+
case 6:
|
|
3970
|
+
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
3971
|
+
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
3972
|
+
}
|
|
3973
|
+
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
3974
|
+
bookingsBeforeRemove.forEach(function (booking) {
|
|
3975
|
+
var bookingUid = _this22.getBookingUniqueIdentificationNumber(booking);
|
|
3976
|
+
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
3977
|
+
linkedBookingUidsToRemove.add(bookingUid);
|
|
3978
|
+
}
|
|
3979
|
+
});
|
|
3980
|
+
}
|
|
3981
|
+
case 8:
|
|
3982
|
+
case "end":
|
|
3983
|
+
return _context24.stop();
|
|
3984
|
+
}
|
|
3985
|
+
}, _loop3);
|
|
3986
|
+
});
|
|
3987
|
+
_iterator21.s();
|
|
3988
|
+
case 14:
|
|
3989
|
+
if ((_step21 = _iterator21.n()).done) {
|
|
3990
|
+
_context25.next = 20;
|
|
3991
|
+
break;
|
|
3992
|
+
}
|
|
3993
|
+
return _context25.delegateYield(_loop3(), "t0", 16);
|
|
3994
|
+
case 16:
|
|
3995
|
+
if (!_context25.t0) {
|
|
3996
|
+
_context25.next = 18;
|
|
3997
|
+
break;
|
|
3998
|
+
}
|
|
3999
|
+
return _context25.abrupt("continue", 18);
|
|
4000
|
+
case 18:
|
|
4001
|
+
_context25.next = 14;
|
|
4002
|
+
break;
|
|
4003
|
+
case 20:
|
|
4004
|
+
_context25.next = 25;
|
|
4005
|
+
break;
|
|
4006
|
+
case 22:
|
|
4007
|
+
_context25.prev = 22;
|
|
4008
|
+
_context25.t1 = _context25["catch"](11);
|
|
4009
|
+
_iterator21.e(_context25.t1);
|
|
4010
|
+
case 25:
|
|
4011
|
+
_context25.prev = 25;
|
|
4012
|
+
_iterator21.f();
|
|
4013
|
+
return _context25.finish(25);
|
|
4014
|
+
case 28:
|
|
4015
|
+
if (linkedBookingUidsToRemove.size > 0) {
|
|
4016
|
+
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
4017
|
+
tempOrder.products = (tempOrder.products || []).filter(function (line) {
|
|
4018
|
+
var _line$metadata, _line$metadata2, _line$metadata3;
|
|
4019
|
+
var lineBookingUid = (line === null || line === void 0 || (_line$metadata = line.metadata) === null || _line$metadata === void 0 ? void 0 : _line$metadata.booking_uid) || (line === null || line === void 0 ? void 0 : line.booking_uid);
|
|
4020
|
+
var isAddTimeProduct = (line === null || line === void 0 || (_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.product_add_schedule_time) !== undefined && (line === null || line === void 0 || (_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.product_add_schedule_time) !== null;
|
|
4021
|
+
return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
|
|
4022
|
+
});
|
|
4023
|
+
}
|
|
4024
|
+
_context25.next = 31;
|
|
3854
4025
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
3855
|
-
case
|
|
3856
|
-
return
|
|
3857
|
-
case
|
|
4026
|
+
case 31:
|
|
4027
|
+
return _context25.abrupt("return", tempOrder.products);
|
|
4028
|
+
case 32:
|
|
3858
4029
|
case "end":
|
|
3859
|
-
return
|
|
4030
|
+
return _context25.stop();
|
|
3860
4031
|
}
|
|
3861
|
-
}, _callee22, this);
|
|
4032
|
+
}, _callee22, this, [[11, 22, 25, 28]]);
|
|
3862
4033
|
}));
|
|
3863
4034
|
function removeProductsFromOrder(_x26) {
|
|
3864
4035
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
@@ -3869,13 +4040,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3869
4040
|
key: "removeProductFromOrder",
|
|
3870
4041
|
value: function () {
|
|
3871
4042
|
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(identity) {
|
|
3872
|
-
return _regeneratorRuntime().wrap(function _callee23$(
|
|
3873
|
-
while (1) switch (
|
|
4043
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context26) {
|
|
4044
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
3874
4045
|
case 0:
|
|
3875
|
-
return
|
|
4046
|
+
return _context26.abrupt("return", this.removeProductsFromOrder([identity]));
|
|
3876
4047
|
case 1:
|
|
3877
4048
|
case "end":
|
|
3878
|
-
return
|
|
4049
|
+
return _context26.stop();
|
|
3879
4050
|
}
|
|
3880
4051
|
}, _callee23, this);
|
|
3881
4052
|
}));
|
|
@@ -3893,8 +4064,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3893
4064
|
value: (function () {
|
|
3894
4065
|
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
3895
4066
|
var tempOrder;
|
|
3896
|
-
return _regeneratorRuntime().wrap(function _callee24$(
|
|
3897
|
-
while (1) switch (
|
|
4067
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context27) {
|
|
4068
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
3898
4069
|
case 0:
|
|
3899
4070
|
tempOrder = this.ensureTempOrder();
|
|
3900
4071
|
tempOrder.products = [];
|
|
@@ -3905,21 +4076,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3905
4076
|
productsByUid: {}
|
|
3906
4077
|
});
|
|
3907
4078
|
}
|
|
3908
|
-
|
|
4079
|
+
_context27.next = 7;
|
|
3909
4080
|
return this.applyPromotion();
|
|
3910
4081
|
case 7:
|
|
3911
4082
|
this.applyDiscount();
|
|
3912
4083
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3913
|
-
|
|
4084
|
+
_context27.next = 11;
|
|
3914
4085
|
return this.recalculateSummary({
|
|
3915
4086
|
createIfMissing: true
|
|
3916
4087
|
});
|
|
3917
4088
|
case 11:
|
|
3918
4089
|
this.persistTempOrder();
|
|
3919
|
-
return
|
|
4090
|
+
return _context27.abrupt("return", tempOrder);
|
|
3920
4091
|
case 13:
|
|
3921
4092
|
case "end":
|
|
3922
|
-
return
|
|
4093
|
+
return _context27.stop();
|
|
3923
4094
|
}
|
|
3924
4095
|
}, _callee24, this);
|
|
3925
4096
|
}));
|
|
@@ -3961,15 +4132,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3961
4132
|
value: function () {
|
|
3962
4133
|
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(order) {
|
|
3963
4134
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
3964
|
-
return _regeneratorRuntime().wrap(function _callee25$(
|
|
3965
|
-
while (1) switch (
|
|
4135
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context28) {
|
|
4136
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
3966
4137
|
case 0:
|
|
3967
4138
|
tempOrder = this.ensureTempOrder();
|
|
3968
4139
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
3969
|
-
|
|
4140
|
+
_context28.next = 3;
|
|
3970
4141
|
break;
|
|
3971
4142
|
}
|
|
3972
|
-
return
|
|
4143
|
+
return _context28.abrupt("return", tempOrder);
|
|
3973
4144
|
case 3:
|
|
3974
4145
|
shopOrderNumber = order.shop_order_number;
|
|
3975
4146
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -3980,13 +4151,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3980
4151
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
3981
4152
|
}
|
|
3982
4153
|
this.persistTempOrder();
|
|
3983
|
-
|
|
4154
|
+
_context28.next = 10;
|
|
3984
4155
|
return this.saveDraft();
|
|
3985
4156
|
case 10:
|
|
3986
|
-
return
|
|
4157
|
+
return _context28.abrupt("return", tempOrder);
|
|
3987
4158
|
case 11:
|
|
3988
4159
|
case "end":
|
|
3989
|
-
return
|
|
4160
|
+
return _context28.stop();
|
|
3990
4161
|
}
|
|
3991
4162
|
}, _callee25, this);
|
|
3992
4163
|
}));
|
|
@@ -4005,13 +4176,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4005
4176
|
key: "submitTempOrder",
|
|
4006
4177
|
value: (function () {
|
|
4007
4178
|
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
4008
|
-
return _regeneratorRuntime().wrap(function _callee26$(
|
|
4009
|
-
while (1) switch (
|
|
4179
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context29) {
|
|
4180
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
4010
4181
|
case 0:
|
|
4011
|
-
return
|
|
4182
|
+
return _context29.abrupt("return", this.runSubmitTempOrder(params));
|
|
4012
4183
|
case 1:
|
|
4013
4184
|
case "end":
|
|
4014
|
-
return
|
|
4185
|
+
return _context29.stop();
|
|
4015
4186
|
}
|
|
4016
4187
|
}, _callee26, this);
|
|
4017
4188
|
}));
|
|
@@ -4024,15 +4195,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4024
4195
|
key: "submitTempOrderAsync",
|
|
4025
4196
|
value: function () {
|
|
4026
4197
|
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
4027
|
-
return _regeneratorRuntime().wrap(function _callee27$(
|
|
4028
|
-
while (1) switch (
|
|
4198
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context30) {
|
|
4199
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
4029
4200
|
case 0:
|
|
4030
|
-
return
|
|
4201
|
+
return _context30.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
4031
4202
|
syncMode: true
|
|
4032
4203
|
})));
|
|
4033
4204
|
case 1:
|
|
4034
4205
|
case "end":
|
|
4035
|
-
return
|
|
4206
|
+
return _context30.stop();
|
|
4036
4207
|
}
|
|
4037
4208
|
}, _callee27, this);
|
|
4038
4209
|
}));
|
|
@@ -4047,31 +4218,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4047
4218
|
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
4048
4219
|
var _params$cacheId2, _this$otherParams5, _ref70, _params$businessCode2, _this$otherParams6, _this$otherParams7;
|
|
4049
4220
|
var tempOrder, latestSummary, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
4050
|
-
return _regeneratorRuntime().wrap(function _callee28$(
|
|
4051
|
-
while (1) switch (
|
|
4221
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context31) {
|
|
4222
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
4052
4223
|
case 0:
|
|
4053
4224
|
tempOrder = this.ensureTempOrder();
|
|
4054
4225
|
this.persistTempOrder();
|
|
4055
|
-
|
|
4226
|
+
_context31.next = 4;
|
|
4056
4227
|
return this.recalculateSummary({
|
|
4057
4228
|
createIfMissing: true
|
|
4058
4229
|
});
|
|
4059
4230
|
case 4:
|
|
4060
|
-
|
|
4061
|
-
if (
|
|
4062
|
-
|
|
4231
|
+
_context31.t1 = _context31.sent;
|
|
4232
|
+
if (_context31.t1) {
|
|
4233
|
+
_context31.next = 7;
|
|
4063
4234
|
break;
|
|
4064
4235
|
}
|
|
4065
|
-
|
|
4236
|
+
_context31.t1 = this.store.summary;
|
|
4066
4237
|
case 7:
|
|
4067
|
-
|
|
4068
|
-
if (
|
|
4069
|
-
|
|
4238
|
+
_context31.t0 = _context31.t1;
|
|
4239
|
+
if (_context31.t0) {
|
|
4240
|
+
_context31.next = 10;
|
|
4070
4241
|
break;
|
|
4071
4242
|
}
|
|
4072
|
-
|
|
4243
|
+
_context31.t0 = createEmptySummary();
|
|
4073
4244
|
case 10:
|
|
4074
|
-
latestSummary =
|
|
4245
|
+
latestSummary = _context31.t0;
|
|
4075
4246
|
effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
|
|
4076
4247
|
hasPaymentOverride = (params === null || params === void 0 ? void 0 : params.payments) !== undefined;
|
|
4077
4248
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
@@ -4105,10 +4276,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4105
4276
|
if (!payload.created_at) {
|
|
4106
4277
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4107
4278
|
}
|
|
4108
|
-
|
|
4279
|
+
_context31.next = 21;
|
|
4109
4280
|
return this.saveDraft();
|
|
4110
4281
|
case 21:
|
|
4111
|
-
|
|
4282
|
+
_context31.prev = 21;
|
|
4112
4283
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
4113
4284
|
orderId: payload.order_id,
|
|
4114
4285
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -4118,43 +4289,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4118
4289
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
4119
4290
|
syncMode: payload.sync_mode
|
|
4120
4291
|
});
|
|
4121
|
-
|
|
4292
|
+
_context31.next = 25;
|
|
4122
4293
|
return this.submitSalesOrder({
|
|
4123
4294
|
query: payload
|
|
4124
4295
|
});
|
|
4125
4296
|
case 25:
|
|
4126
|
-
result =
|
|
4127
|
-
|
|
4297
|
+
result = _context31.sent;
|
|
4298
|
+
_context31.next = 38;
|
|
4128
4299
|
break;
|
|
4129
4300
|
case 28:
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
4301
|
+
_context31.prev = 28;
|
|
4302
|
+
_context31.t2 = _context31["catch"](21);
|
|
4303
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context31.t2);
|
|
4133
4304
|
if (!backendErrorResponse) {
|
|
4134
|
-
|
|
4305
|
+
_context31.next = 35;
|
|
4135
4306
|
break;
|
|
4136
4307
|
}
|
|
4137
4308
|
this.store.syncState = 'failed';
|
|
4138
4309
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
4139
|
-
return
|
|
4310
|
+
return _context31.abrupt("return", backendErrorResponse);
|
|
4140
4311
|
case 35:
|
|
4141
4312
|
this.store.syncState = 'failed';
|
|
4142
4313
|
this.logError('submitTempOrder failed', {
|
|
4143
|
-
error:
|
|
4314
|
+
error: _context31.t2 instanceof Error ? _context31.t2.message : String(_context31.t2),
|
|
4144
4315
|
orderId: payload.order_id,
|
|
4145
4316
|
externalSaleNumber: payload.external_sale_number,
|
|
4146
4317
|
paymentStatus: payload.payment_status,
|
|
4147
4318
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
4148
4319
|
});
|
|
4149
|
-
throw
|
|
4320
|
+
throw _context31.t2;
|
|
4150
4321
|
case 38:
|
|
4151
4322
|
if (!this.isSubmitResponseRejected(result)) {
|
|
4152
|
-
|
|
4323
|
+
_context31.next = 42;
|
|
4153
4324
|
break;
|
|
4154
4325
|
}
|
|
4155
4326
|
this.store.syncState = 'failed';
|
|
4156
4327
|
this.logSubmitBackendRejected(result, payload);
|
|
4157
|
-
return
|
|
4328
|
+
return _context31.abrupt("return", result);
|
|
4158
4329
|
case 42:
|
|
4159
4330
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
4160
4331
|
this.logInfo('runSubmitTempOrder: 提交成功', {
|
|
@@ -4163,15 +4334,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4163
4334
|
tempOrder: tempOrder
|
|
4164
4335
|
});
|
|
4165
4336
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
4166
|
-
|
|
4337
|
+
_context31.next = 51;
|
|
4167
4338
|
break;
|
|
4168
4339
|
}
|
|
4169
4340
|
tempOrder.order_id = submittedOrderId;
|
|
4170
4341
|
resultRecord = result;
|
|
4171
|
-
|
|
4342
|
+
_context31.next = 49;
|
|
4172
4343
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
4173
4344
|
case 49:
|
|
4174
|
-
|
|
4345
|
+
_context31.next = 52;
|
|
4175
4346
|
break;
|
|
4176
4347
|
case 51:
|
|
4177
4348
|
if (this.isLocalPendingSubmitResult(result)) {
|
|
@@ -4180,10 +4351,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4180
4351
|
this.store.syncState = 'submitted';
|
|
4181
4352
|
}
|
|
4182
4353
|
case 52:
|
|
4183
|
-
return
|
|
4354
|
+
return _context31.abrupt("return", result);
|
|
4184
4355
|
case 53:
|
|
4185
4356
|
case "end":
|
|
4186
|
-
return
|
|
4357
|
+
return _context31.stop();
|
|
4187
4358
|
}
|
|
4188
4359
|
}, _callee28, this, [[21, 28]]);
|
|
4189
4360
|
}));
|
|
@@ -4197,8 +4368,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4197
4368
|
value: function () {
|
|
4198
4369
|
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(orderId, remoteOrder) {
|
|
4199
4370
|
var tempOrder;
|
|
4200
|
-
return _regeneratorRuntime().wrap(function _callee29$(
|
|
4201
|
-
while (1) switch (
|
|
4371
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
4372
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
4202
4373
|
case 0:
|
|
4203
4374
|
tempOrder = this.ensureTempOrder();
|
|
4204
4375
|
tempOrder.order_id = orderId;
|
|
@@ -4206,11 +4377,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4206
4377
|
this.store.lastOrderInfo = remoteOrder;
|
|
4207
4378
|
this.store.syncState = 'submitted';
|
|
4208
4379
|
this.persistTempOrder();
|
|
4209
|
-
|
|
4380
|
+
_context32.next = 8;
|
|
4210
4381
|
return this.saveDraft();
|
|
4211
4382
|
case 8:
|
|
4212
4383
|
case "end":
|
|
4213
|
-
return
|
|
4384
|
+
return _context32.stop();
|
|
4214
4385
|
}
|
|
4215
4386
|
}, _callee29, this);
|
|
4216
4387
|
}));
|
|
@@ -4257,10 +4428,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4257
4428
|
value: function extractSubmitErrorResponse(error) {
|
|
4258
4429
|
var _error$response,
|
|
4259
4430
|
_error$response2,
|
|
4260
|
-
|
|
4431
|
+
_this23 = this;
|
|
4261
4432
|
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];
|
|
4262
4433
|
return candidates.find(function (candidate) {
|
|
4263
|
-
return
|
|
4434
|
+
return _this23.isSubmitErrorResponse(candidate);
|
|
4264
4435
|
}) || null;
|
|
4265
4436
|
}
|
|
4266
4437
|
}, {
|
|
@@ -4289,8 +4460,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4289
4460
|
value: function () {
|
|
4290
4461
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
4291
4462
|
var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, paymentStatus, paymentSyncIdempotencyToken, submitResult;
|
|
4292
|
-
return _regeneratorRuntime().wrap(function _callee30$(
|
|
4293
|
-
while (1) switch (
|
|
4463
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
4464
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
4294
4465
|
case 0:
|
|
4295
4466
|
tempOrder = this.ensureTempOrder();
|
|
4296
4467
|
mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
|
|
@@ -4301,28 +4472,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4301
4472
|
tempOrder.payments = mappedPayments;
|
|
4302
4473
|
tempOrder.payment_status = paymentStatus;
|
|
4303
4474
|
this.persistTempOrder();
|
|
4304
|
-
|
|
4475
|
+
_context33.next = 11;
|
|
4305
4476
|
return this.saveDraft();
|
|
4306
4477
|
case 11:
|
|
4307
4478
|
if (params.submitWhenPaid) {
|
|
4308
|
-
|
|
4479
|
+
_context33.next = 13;
|
|
4309
4480
|
break;
|
|
4310
4481
|
}
|
|
4311
|
-
return
|
|
4482
|
+
return _context33.abrupt("return", {
|
|
4312
4483
|
isFullyPaid: isFullyPaid
|
|
4313
4484
|
});
|
|
4314
4485
|
case 13:
|
|
4315
4486
|
if (!(this.store.syncState === 'submitting')) {
|
|
4316
|
-
|
|
4487
|
+
_context33.next = 15;
|
|
4317
4488
|
break;
|
|
4318
4489
|
}
|
|
4319
|
-
return
|
|
4490
|
+
return _context33.abrupt("return", {
|
|
4320
4491
|
isFullyPaid: isFullyPaid
|
|
4321
4492
|
});
|
|
4322
4493
|
case 15:
|
|
4323
4494
|
this.store.syncState = 'submitting';
|
|
4324
4495
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, mappedPayments);
|
|
4325
|
-
|
|
4496
|
+
_context33.next = 19;
|
|
4326
4497
|
return this.submitTempOrder({
|
|
4327
4498
|
payments: mappedPayments,
|
|
4328
4499
|
paymentStatus: paymentStatus,
|
|
@@ -4337,14 +4508,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4337
4508
|
}
|
|
4338
4509
|
});
|
|
4339
4510
|
case 19:
|
|
4340
|
-
submitResult =
|
|
4341
|
-
return
|
|
4511
|
+
submitResult = _context33.sent;
|
|
4512
|
+
return _context33.abrupt("return", {
|
|
4342
4513
|
isFullyPaid: isFullyPaid,
|
|
4343
4514
|
submitResult: submitResult
|
|
4344
4515
|
});
|
|
4345
4516
|
case 21:
|
|
4346
4517
|
case "end":
|
|
4347
|
-
return
|
|
4518
|
+
return _context33.stop();
|
|
4348
4519
|
}
|
|
4349
4520
|
}, _callee30, this);
|
|
4350
4521
|
}));
|
|
@@ -4440,8 +4611,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4440
4611
|
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(order) {
|
|
4441
4612
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
4442
4613
|
var url, query, fetchUrl, params;
|
|
4443
|
-
return _regeneratorRuntime().wrap(function _callee31$(
|
|
4444
|
-
while (1) switch (
|
|
4614
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
4615
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
4445
4616
|
case 0:
|
|
4446
4617
|
this.logInfo('submitOrder called', {
|
|
4447
4618
|
url: order.url,
|
|
@@ -4461,10 +4632,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4461
4632
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
4462
4633
|
scheduleDate: params.schedule_date
|
|
4463
4634
|
});
|
|
4464
|
-
return
|
|
4635
|
+
return _context34.abrupt("return", this.request.post(fetchUrl, params));
|
|
4465
4636
|
case 6:
|
|
4466
4637
|
case "end":
|
|
4467
|
-
return
|
|
4638
|
+
return _context34.stop();
|
|
4468
4639
|
}
|
|
4469
4640
|
}, _callee31, this);
|
|
4470
4641
|
}));
|
|
@@ -4478,11 +4649,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4478
4649
|
value: function () {
|
|
4479
4650
|
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
4480
4651
|
var payload;
|
|
4481
|
-
return _regeneratorRuntime().wrap(function _callee32$(
|
|
4482
|
-
while (1) switch (
|
|
4652
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context35) {
|
|
4653
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
4483
4654
|
case 0:
|
|
4484
4655
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
4485
|
-
|
|
4656
|
+
_context35.next = 2;
|
|
4486
4657
|
break;
|
|
4487
4658
|
}
|
|
4488
4659
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -4498,12 +4669,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4498
4669
|
method: 'PUT',
|
|
4499
4670
|
orderIdsCount: params.order_ids.length
|
|
4500
4671
|
});
|
|
4501
|
-
return
|
|
4672
|
+
return _context35.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
4502
4673
|
isShopApi: true
|
|
4503
4674
|
}));
|
|
4504
4675
|
case 5:
|
|
4505
4676
|
case "end":
|
|
4506
|
-
return
|
|
4677
|
+
return _context35.stop();
|
|
4507
4678
|
}
|
|
4508
4679
|
}, _callee32, this);
|
|
4509
4680
|
}));
|
|
@@ -4517,17 +4688,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4517
4688
|
value: function () {
|
|
4518
4689
|
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
4519
4690
|
var url, payload;
|
|
4520
|
-
return _regeneratorRuntime().wrap(function _callee33$(
|
|
4521
|
-
while (1) switch (
|
|
4691
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
4692
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
4522
4693
|
case 0:
|
|
4523
4694
|
if (params.booking_id) {
|
|
4524
|
-
|
|
4695
|
+
_context36.next = 2;
|
|
4525
4696
|
break;
|
|
4526
4697
|
}
|
|
4527
4698
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
4528
4699
|
case 2:
|
|
4529
4700
|
if (params.appointment_status) {
|
|
4530
|
-
|
|
4701
|
+
_context36.next = 4;
|
|
4531
4702
|
break;
|
|
4532
4703
|
}
|
|
4533
4704
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -4542,12 +4713,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4542
4713
|
bookingId: params.booking_id,
|
|
4543
4714
|
appointmentStatus: params.appointment_status
|
|
4544
4715
|
});
|
|
4545
|
-
return
|
|
4716
|
+
return _context36.abrupt("return", this.request.put(url, payload, {
|
|
4546
4717
|
isShopApi: true
|
|
4547
4718
|
}));
|
|
4548
4719
|
case 8:
|
|
4549
4720
|
case "end":
|
|
4550
|
-
return
|
|
4721
|
+
return _context36.stop();
|
|
4551
4722
|
}
|
|
4552
4723
|
}, _callee33, this);
|
|
4553
4724
|
}));
|
|
@@ -4572,8 +4743,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4572
4743
|
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
4573
4744
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
4574
4745
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
|
|
4575
|
-
return _regeneratorRuntime().wrap(function _callee34$(
|
|
4576
|
-
while (1) switch (
|
|
4746
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
4747
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
4577
4748
|
case 0:
|
|
4578
4749
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
4579
4750
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -4607,7 +4778,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4607
4778
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
4608
4779
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
4609
4780
|
});
|
|
4610
|
-
|
|
4781
|
+
_context37.prev = 4;
|
|
4611
4782
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
4612
4783
|
orderData = _objectSpread({
|
|
4613
4784
|
sales_channel: 'my_pisel',
|
|
@@ -4669,13 +4840,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4669
4840
|
hasOrderId: !!orderData.order_id,
|
|
4670
4841
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
4671
4842
|
});
|
|
4672
|
-
|
|
4843
|
+
_context37.next = 12;
|
|
4673
4844
|
return this.request.post('/order/checkout', orderData, {
|
|
4674
4845
|
osServer: true,
|
|
4675
4846
|
customToast: function customToast() {}
|
|
4676
4847
|
});
|
|
4677
4848
|
case 12:
|
|
4678
|
-
response =
|
|
4849
|
+
response = _context37.sent;
|
|
4679
4850
|
this.logInfo('Order API called successfully', {
|
|
4680
4851
|
response: response
|
|
4681
4852
|
});
|
|
@@ -4683,18 +4854,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4683
4854
|
success: !!response,
|
|
4684
4855
|
hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
|
|
4685
4856
|
});
|
|
4686
|
-
return
|
|
4857
|
+
return _context37.abrupt("return", response);
|
|
4687
4858
|
case 18:
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
4859
|
+
_context37.prev = 18;
|
|
4860
|
+
_context37.t0 = _context37["catch"](4);
|
|
4861
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context37.t0);
|
|
4691
4862
|
this.logInfo('Order API called failed', {
|
|
4692
|
-
error:
|
|
4863
|
+
error: _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0)
|
|
4693
4864
|
});
|
|
4694
|
-
throw
|
|
4865
|
+
throw _context37.t0;
|
|
4695
4866
|
case 23:
|
|
4696
4867
|
case "end":
|
|
4697
|
-
return
|
|
4868
|
+
return _context37.stop();
|
|
4698
4869
|
}
|
|
4699
4870
|
}, _callee34, this, [[4, 18]]);
|
|
4700
4871
|
}));
|
|
@@ -4708,18 +4879,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4708
4879
|
value: function () {
|
|
4709
4880
|
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
4710
4881
|
var url, query, fetchUrl;
|
|
4711
|
-
return _regeneratorRuntime().wrap(function _callee35$(
|
|
4712
|
-
while (1) switch (
|
|
4882
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context38) {
|
|
4883
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
4713
4884
|
case 0:
|
|
4714
4885
|
url = params.url, query = params.query;
|
|
4715
4886
|
fetchUrl = url || '/order/sales/checkout';
|
|
4716
|
-
return
|
|
4887
|
+
return _context38.abrupt("return", this.request.post(fetchUrl, query, {
|
|
4717
4888
|
osServer: true,
|
|
4718
4889
|
customToast: function customToast() {}
|
|
4719
4890
|
}));
|
|
4720
4891
|
case 3:
|
|
4721
4892
|
case "end":
|
|
4722
|
-
return
|
|
4893
|
+
return _context38.stop();
|
|
4723
4894
|
}
|
|
4724
4895
|
}, _callee35, this);
|
|
4725
4896
|
}));
|
|
@@ -4740,30 +4911,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4740
4911
|
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
4741
4912
|
var _params$emails;
|
|
4742
4913
|
var orderIds;
|
|
4743
|
-
return _regeneratorRuntime().wrap(function _callee36$(
|
|
4744
|
-
while (1) switch (
|
|
4914
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context39) {
|
|
4915
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
4745
4916
|
case 0:
|
|
4746
4917
|
orderIds = params.order_ids || params.orderIds || [];
|
|
4747
4918
|
if (orderIds.length) {
|
|
4748
|
-
|
|
4919
|
+
_context39.next = 3;
|
|
4749
4920
|
break;
|
|
4750
4921
|
}
|
|
4751
4922
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
4752
4923
|
case 3:
|
|
4753
4924
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
4754
|
-
|
|
4925
|
+
_context39.next = 5;
|
|
4755
4926
|
break;
|
|
4756
4927
|
}
|
|
4757
4928
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
4758
4929
|
case 5:
|
|
4759
|
-
return
|
|
4930
|
+
return _context39.abrupt("return", this.request.post('/order/batch-email', {
|
|
4760
4931
|
order_ids: orderIds,
|
|
4761
4932
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
4762
4933
|
emails: params.emails
|
|
4763
4934
|
}));
|
|
4764
4935
|
case 6:
|
|
4765
4936
|
case "end":
|
|
4766
|
-
return
|
|
4937
|
+
return _context39.stop();
|
|
4767
4938
|
}
|
|
4768
4939
|
}, _callee36, this);
|
|
4769
4940
|
}));
|
|
@@ -4777,12 +4948,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4777
4948
|
value: function () {
|
|
4778
4949
|
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
4779
4950
|
var lookup, res;
|
|
4780
|
-
return _regeneratorRuntime().wrap(function _callee37$(
|
|
4781
|
-
while (1) switch (
|
|
4951
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
4952
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
4782
4953
|
case 0:
|
|
4783
4954
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
4784
4955
|
if (lookup) {
|
|
4785
|
-
|
|
4956
|
+
_context40.next = 3;
|
|
4786
4957
|
break;
|
|
4787
4958
|
}
|
|
4788
4959
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -4791,7 +4962,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4791
4962
|
if (lookup.startsWith('LOCAL_')) {
|
|
4792
4963
|
params.forceRemote = false;
|
|
4793
4964
|
}
|
|
4794
|
-
|
|
4965
|
+
_context40.next = 6;
|
|
4795
4966
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
4796
4967
|
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
4797
4968
|
}, params.forceRemote ? {
|
|
@@ -4800,14 +4971,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4800
4971
|
osServer: true
|
|
4801
4972
|
});
|
|
4802
4973
|
case 6:
|
|
4803
|
-
res =
|
|
4974
|
+
res = _context40.sent;
|
|
4804
4975
|
if (res.code === 200) {
|
|
4805
4976
|
this.store.lastOrderInfo = res.data;
|
|
4806
4977
|
}
|
|
4807
|
-
return
|
|
4978
|
+
return _context40.abrupt("return", res);
|
|
4808
4979
|
case 9:
|
|
4809
4980
|
case "end":
|
|
4810
|
-
return
|
|
4981
|
+
return _context40.stop();
|
|
4811
4982
|
}
|
|
4812
4983
|
}, _callee37, this);
|
|
4813
4984
|
}));
|
|
@@ -4826,10 +4997,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4826
4997
|
key: "hydrateTempOrderFromRecord",
|
|
4827
4998
|
value: (function () {
|
|
4828
4999
|
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(record, options) {
|
|
4829
|
-
var _this$store$
|
|
4830
|
-
var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, shouldSkipEmptyDiscountSync, _this$store$
|
|
4831
|
-
return _regeneratorRuntime().wrap(function _callee38$(
|
|
4832
|
-
while (1) switch (
|
|
5000
|
+
var _this$store$discount15;
|
|
5001
|
+
var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount16, _this$store$discount17;
|
|
5002
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context41) {
|
|
5003
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
4833
5004
|
case 0:
|
|
4834
5005
|
raw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
4835
5006
|
nextTempOrder = this.normalizeTempOrderForRuntime(raw);
|
|
@@ -4852,32 +5023,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4852
5023
|
});
|
|
4853
5024
|
this.store.lastOrderInfo = raw.lastOrderInfo || raw;
|
|
4854
5025
|
hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
4855
|
-
currentDiscounts = typeof ((_this$store$
|
|
5026
|
+
currentDiscounts = typeof ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
|
|
4856
5027
|
shouldSkipEmptyDiscountSync = hydratedEditDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
4857
5028
|
if (shouldSkipEmptyDiscountSync) {
|
|
4858
|
-
|
|
5029
|
+
_context41.next = 16;
|
|
4859
5030
|
break;
|
|
4860
5031
|
}
|
|
4861
|
-
|
|
4862
|
-
return (_this$store$
|
|
5032
|
+
_context41.next = 14;
|
|
5033
|
+
return (_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setOriginalDiscountList(hydratedEditDiscounts);
|
|
4863
5034
|
case 14:
|
|
4864
|
-
|
|
4865
|
-
return (_this$store$
|
|
5035
|
+
_context41.next = 16;
|
|
5036
|
+
return (_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 ? void 0 : _this$store$discount17.setDiscountList(hydratedEditDiscounts);
|
|
4866
5037
|
case 16:
|
|
4867
5038
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
4868
|
-
|
|
5039
|
+
_context41.next = 19;
|
|
4869
5040
|
break;
|
|
4870
5041
|
}
|
|
4871
|
-
|
|
5042
|
+
_context41.next = 19;
|
|
4872
5043
|
return this.recalculateSummary({
|
|
4873
5044
|
createIfMissing: false
|
|
4874
5045
|
});
|
|
4875
5046
|
case 19:
|
|
4876
5047
|
this.persistTempOrder();
|
|
4877
|
-
return
|
|
5048
|
+
return _context41.abrupt("return", nextTempOrder);
|
|
4878
5049
|
case 21:
|
|
4879
5050
|
case "end":
|
|
4880
|
-
return
|
|
5051
|
+
return _context41.stop();
|
|
4881
5052
|
}
|
|
4882
5053
|
}, _callee38, this);
|
|
4883
5054
|
}));
|
|
@@ -4889,7 +5060,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4889
5060
|
}, {
|
|
4890
5061
|
key: "normalizeTempOrderForRuntime",
|
|
4891
5062
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
4892
|
-
var
|
|
5063
|
+
var _this24 = this;
|
|
4893
5064
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
|
|
4894
5065
|
delete nextTempOrder.summary;
|
|
4895
5066
|
delete nextTempOrder.lastOrderInfo;
|
|
@@ -4908,7 +5079,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4908
5079
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
4909
5080
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
4910
5081
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
4911
|
-
return
|
|
5082
|
+
return _this24.normalizeHydratedOrderProduct(p);
|
|
4912
5083
|
}) : [];
|
|
4913
5084
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
4914
5085
|
return _objectSpread(_objectSpread({}, b || {}), {}, {
|
|
@@ -4936,14 +5107,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4936
5107
|
};
|
|
4937
5108
|
var tempOrderExtend = nextTempOrder._extend;
|
|
4938
5109
|
var productsByUid = tempOrderExtend.productsByUid || {};
|
|
4939
|
-
var
|
|
4940
|
-
|
|
5110
|
+
var _iterator22 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
|
|
5111
|
+
_step22;
|
|
4941
5112
|
try {
|
|
4942
|
-
for (
|
|
5113
|
+
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
4943
5114
|
var _product$metadata8, _ref71, _ref72, _existed$origin, _rawProduct$metadata;
|
|
4944
|
-
var
|
|
4945
|
-
index =
|
|
4946
|
-
product =
|
|
5115
|
+
var _step22$value = _slicedToArray(_step22.value, 2),
|
|
5116
|
+
index = _step22$value[0],
|
|
5117
|
+
product = _step22$value[1];
|
|
4947
5118
|
var uid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
|
|
4948
5119
|
if (!uid) continue;
|
|
4949
5120
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
@@ -4964,9 +5135,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4964
5135
|
});
|
|
4965
5136
|
}
|
|
4966
5137
|
} catch (err) {
|
|
4967
|
-
|
|
5138
|
+
_iterator22.e(err);
|
|
4968
5139
|
} finally {
|
|
4969
|
-
|
|
5140
|
+
_iterator22.f();
|
|
4970
5141
|
}
|
|
4971
5142
|
tempOrderExtend.productsByUid = productsByUid;
|
|
4972
5143
|
if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
|
|
@@ -4997,18 +5168,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4997
5168
|
var segments = [];
|
|
4998
5169
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
4999
5170
|
if (Array.isArray(sku.variant)) {
|
|
5000
|
-
var
|
|
5001
|
-
|
|
5171
|
+
var _iterator23 = _createForOfIteratorHelper(sku.variant),
|
|
5172
|
+
_step23;
|
|
5002
5173
|
try {
|
|
5003
|
-
for (
|
|
5004
|
-
var variant =
|
|
5174
|
+
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
5175
|
+
var variant = _step23.value;
|
|
5005
5176
|
var segment = this.formatHydratedNamePair(variant === null || variant === void 0 ? void 0 : variant.group, variant === null || variant === void 0 ? void 0 : variant.item);
|
|
5006
5177
|
if (segment) segments.push(segment);
|
|
5007
5178
|
}
|
|
5008
5179
|
} catch (err) {
|
|
5009
|
-
|
|
5180
|
+
_iterator23.e(err);
|
|
5010
5181
|
} finally {
|
|
5011
|
-
|
|
5182
|
+
_iterator23.f();
|
|
5012
5183
|
}
|
|
5013
5184
|
}
|
|
5014
5185
|
return segments.join(', ');
|
|
@@ -5036,7 +5207,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5036
5207
|
}, {
|
|
5037
5208
|
key: "normalizeHydratedOrderProduct",
|
|
5038
5209
|
value: function normalizeHydratedOrderProduct(product) {
|
|
5039
|
-
var
|
|
5210
|
+
var _this25 = this;
|
|
5040
5211
|
var row = _objectSpread({}, product || {});
|
|
5041
5212
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
5042
5213
|
row.num = row.product_quantity;
|
|
@@ -5044,7 +5215,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5044
5215
|
var productSku = ensureProductSku(row);
|
|
5045
5216
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
5046
5217
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
5047
|
-
return
|
|
5218
|
+
return _this25.normalizeHydratedProductOptionItem(optionItem || {});
|
|
5048
5219
|
}))
|
|
5049
5220
|
});
|
|
5050
5221
|
delete row["product_".concat('option', "_item")];
|
|
@@ -5077,19 +5248,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5077
5248
|
value: function () {
|
|
5078
5249
|
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(order_id) {
|
|
5079
5250
|
var res;
|
|
5080
|
-
return _regeneratorRuntime().wrap(function _callee39$(
|
|
5081
|
-
while (1) switch (
|
|
5251
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
5252
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
5082
5253
|
case 0:
|
|
5083
|
-
|
|
5254
|
+
_context42.next = 2;
|
|
5084
5255
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
5085
5256
|
with: ['products', 'bookings']
|
|
5086
5257
|
});
|
|
5087
5258
|
case 2:
|
|
5088
|
-
res =
|
|
5089
|
-
return
|
|
5259
|
+
res = _context42.sent;
|
|
5260
|
+
return _context42.abrupt("return", res);
|
|
5090
5261
|
case 4:
|
|
5091
5262
|
case "end":
|
|
5092
|
-
return
|
|
5263
|
+
return _context42.stop();
|
|
5093
5264
|
}
|
|
5094
5265
|
}, _callee39, this);
|
|
5095
5266
|
}));
|
|
@@ -5110,67 +5281,67 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5110
5281
|
var amount = new Decimal(discount.amount || 0).times(qty).plus(((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0);
|
|
5111
5282
|
savedMap.set(discountKey, (savedMap.get(discountKey) || new Decimal(0)).plus(amount));
|
|
5112
5283
|
};
|
|
5113
|
-
var
|
|
5114
|
-
|
|
5284
|
+
var _iterator24 = _createForOfIteratorHelper(productList),
|
|
5285
|
+
_step24;
|
|
5115
5286
|
try {
|
|
5116
|
-
for (
|
|
5117
|
-
var product =
|
|
5287
|
+
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
5288
|
+
var product = _step24.value;
|
|
5118
5289
|
var qty = product.num || 1;
|
|
5119
|
-
var
|
|
5120
|
-
|
|
5290
|
+
var _iterator26 = _createForOfIteratorHelper(product.discount_list || []),
|
|
5291
|
+
_step26;
|
|
5121
5292
|
try {
|
|
5122
|
-
for (
|
|
5123
|
-
var pd =
|
|
5293
|
+
for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {
|
|
5294
|
+
var pd = _step26.value;
|
|
5124
5295
|
addDiscountAmount(pd, qty);
|
|
5125
5296
|
}
|
|
5126
5297
|
} catch (err) {
|
|
5127
|
-
|
|
5298
|
+
_iterator26.e(err);
|
|
5128
5299
|
} finally {
|
|
5129
|
-
|
|
5300
|
+
_iterator26.f();
|
|
5130
5301
|
}
|
|
5131
|
-
var
|
|
5132
|
-
|
|
5302
|
+
var _iterator27 = _createForOfIteratorHelper(product.product_bundle || []),
|
|
5303
|
+
_step27;
|
|
5133
5304
|
try {
|
|
5134
|
-
for (
|
|
5305
|
+
for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
|
|
5135
5306
|
var _ref75, _bundle$num3;
|
|
5136
|
-
var bundle =
|
|
5307
|
+
var bundle = _step27.value;
|
|
5137
5308
|
var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref75 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref75 !== void 0 ? _ref75 : 1) || 1).toNumber();
|
|
5138
|
-
var
|
|
5139
|
-
|
|
5309
|
+
var _iterator28 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
5310
|
+
_step28;
|
|
5140
5311
|
try {
|
|
5141
|
-
for (
|
|
5142
|
-
var _pd =
|
|
5312
|
+
for (_iterator28.s(); !(_step28 = _iterator28.n()).done;) {
|
|
5313
|
+
var _pd = _step28.value;
|
|
5143
5314
|
addDiscountAmount(_pd, bundleQty);
|
|
5144
5315
|
}
|
|
5145
5316
|
} catch (err) {
|
|
5146
|
-
|
|
5317
|
+
_iterator28.e(err);
|
|
5147
5318
|
} finally {
|
|
5148
|
-
|
|
5319
|
+
_iterator28.f();
|
|
5149
5320
|
}
|
|
5150
5321
|
}
|
|
5151
5322
|
} catch (err) {
|
|
5152
|
-
|
|
5323
|
+
_iterator27.e(err);
|
|
5153
5324
|
} finally {
|
|
5154
|
-
|
|
5325
|
+
_iterator27.f();
|
|
5155
5326
|
}
|
|
5156
5327
|
}
|
|
5157
5328
|
} catch (err) {
|
|
5158
|
-
|
|
5329
|
+
_iterator24.e(err);
|
|
5159
5330
|
} finally {
|
|
5160
|
-
|
|
5331
|
+
_iterator24.f();
|
|
5161
5332
|
}
|
|
5162
|
-
var
|
|
5163
|
-
|
|
5333
|
+
var _iterator25 = _createForOfIteratorHelper(discountList),
|
|
5334
|
+
_step25;
|
|
5164
5335
|
try {
|
|
5165
|
-
for (
|
|
5166
|
-
var d =
|
|
5336
|
+
for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
|
|
5337
|
+
var d = _step25.value;
|
|
5167
5338
|
var key = d.id;
|
|
5168
5339
|
d.savedAmount = d.isSelected && key != null && savedMap.has(key) ? savedMap.get(key).toNumber() : 0;
|
|
5169
5340
|
}
|
|
5170
5341
|
} catch (err) {
|
|
5171
|
-
|
|
5342
|
+
_iterator25.e(err);
|
|
5172
5343
|
} finally {
|
|
5173
|
-
|
|
5344
|
+
_iterator25.f();
|
|
5174
5345
|
}
|
|
5175
5346
|
}
|
|
5176
5347
|
}]);
|