@pisell/pisellos 2.3.112 → 2.3.114
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/index.js +4 -4
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Payment/index.d.ts +0 -5
- package/dist/modules/Payment/index.js +35 -85
- package/dist/modules/ResourcePlanner/planner.js +9 -5
- package/dist/modules/ResourcePlanner/types.d.ts +2 -1
- package/dist/server/index.js +4 -0
- package/dist/server/modules/payment/index.d.ts +25 -6
- package/dist/server/modules/payment/index.js +660 -133
- package/dist/solution/BaseSales/index.d.ts +2 -0
- package/dist/solution/BaseSales/index.js +1081 -1042
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +2 -2
- package/dist/solution/UnifiedBookingSales/index.js +3 -3
- package/lib/modules/BookingContext/index.js +3 -3
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Payment/index.d.ts +0 -5
- package/lib/modules/Payment/index.js +3 -28
- package/lib/modules/ResourcePlanner/planner.js +9 -5
- package/lib/modules/ResourcePlanner/types.d.ts +2 -1
- package/lib/server/index.js +4 -0
- package/lib/server/modules/payment/index.d.ts +25 -6
- package/lib/server/modules/payment/index.js +350 -78
- package/lib/solution/BaseSales/index.d.ts +2 -0
- package/lib/solution/BaseSales/index.js +14 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +2 -2
- package/lib/solution/UnifiedBookingSales/index.js +3 -3
- package/package.json +1 -1
|
@@ -49,6 +49,7 @@ import { QuotationModule } from "../../modules/Quotation";
|
|
|
49
49
|
import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
|
|
50
50
|
import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
|
|
51
51
|
var SERVER_ORDER_CHANGED_EVENT = 'order:onOrdersChanged';
|
|
52
|
+
var PAYMENT_METHODS_CHANGED_EVENT = 'payment:onPaymentMethodsChanged';
|
|
52
53
|
var OS_FULFILLMENT_REF_MODE_FIELD = '_os_fulfillment_ref_mode';
|
|
53
54
|
var OS_INVOICE_LAYOUT_CONFIG_FIELD = '_os_invoice_layout_config';
|
|
54
55
|
var OS_INVOICE_TEMPLATE_SETTINGS_FIELD = '_os_invoice_template_settings';
|
|
@@ -542,6 +543,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
542
543
|
_defineProperty(_assertThisInitialized(_this), "walletAssetsRefreshSequence", 0);
|
|
543
544
|
_defineProperty(_assertThisInitialized(_this), "salesDetailHydrateQueue", Promise.resolve());
|
|
544
545
|
_defineProperty(_assertThisInitialized(_this), "serverOrderChangeUnsubscribe", null);
|
|
546
|
+
_defineProperty(_assertThisInitialized(_this), "paymentMethodsChangedUnsubscribe", null);
|
|
545
547
|
_defineProperty(_assertThisInitialized(_this), "serverOrderChangeHydrateInFlight", null);
|
|
546
548
|
_defineProperty(_assertThisInitialized(_this), "queuedServerOrderChanges", []);
|
|
547
549
|
_defineProperty(_assertThisInitialized(_this), "serverOrderChangeSyncEnabled", false);
|
|
@@ -794,32 +796,65 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
794
796
|
});
|
|
795
797
|
});
|
|
796
798
|
}
|
|
799
|
+
}, {
|
|
800
|
+
key: "registerPaymentMethodsChangeSync",
|
|
801
|
+
value: function registerPaymentMethodsChangeSync() {
|
|
802
|
+
var _this$paymentMethodsC,
|
|
803
|
+
_this$core3,
|
|
804
|
+
_this4 = this;
|
|
805
|
+
(_this$paymentMethodsC = this.paymentMethodsChangedUnsubscribe) === null || _this$paymentMethodsC === void 0 || _this$paymentMethodsC.call(this);
|
|
806
|
+
var effects = (_this$core3 = this.core) === null || _this$core3 === void 0 ? void 0 : _this$core3.effects;
|
|
807
|
+
if (!effects || typeof effects.on !== 'function') return;
|
|
808
|
+
this.paymentMethodsChangedUnsubscribe = effects.on(PAYMENT_METHODS_CHANGED_EVENT, /*#__PURE__*/function () {
|
|
809
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(payload) {
|
|
810
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
811
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
812
|
+
case 0:
|
|
813
|
+
if (Array.isArray(payload === null || payload === void 0 ? void 0 : payload.newMethods)) {
|
|
814
|
+
_context4.next = 2;
|
|
815
|
+
break;
|
|
816
|
+
}
|
|
817
|
+
return _context4.abrupt("return");
|
|
818
|
+
case 2:
|
|
819
|
+
_context4.next = 4;
|
|
820
|
+
return _this4.getPaymentMethodsAsync();
|
|
821
|
+
case 4:
|
|
822
|
+
case "end":
|
|
823
|
+
return _context4.stop();
|
|
824
|
+
}
|
|
825
|
+
}, _callee4);
|
|
826
|
+
}));
|
|
827
|
+
return function (_x2) {
|
|
828
|
+
return _ref10.apply(this, arguments);
|
|
829
|
+
};
|
|
830
|
+
}());
|
|
831
|
+
}
|
|
797
832
|
}, {
|
|
798
833
|
key: "hydrateLatestLoadedSalesDetail",
|
|
799
834
|
value: function () {
|
|
800
|
-
var _hydrateLatestLoadedSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
801
|
-
var
|
|
835
|
+
var _hydrateLatestLoadedSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(record, loadSequence, options) {
|
|
836
|
+
var _this5 = this;
|
|
802
837
|
var hydratedSales, skippedBeforeHydrate, hydrateTask, queuedTask;
|
|
803
|
-
return _regeneratorRuntime().wrap(function
|
|
804
|
-
while (1) switch (
|
|
838
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
839
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
805
840
|
case 0:
|
|
806
841
|
hydratedSales = null;
|
|
807
842
|
skippedBeforeHydrate = false;
|
|
808
843
|
hydrateTask = /*#__PURE__*/function () {
|
|
809
|
-
var
|
|
844
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
810
845
|
var hydrateOptions, sales;
|
|
811
|
-
return _regeneratorRuntime().wrap(function
|
|
812
|
-
while (1) switch (
|
|
846
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
847
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
813
848
|
case 0:
|
|
814
|
-
if (!(loadSequence !==
|
|
815
|
-
|
|
849
|
+
if (!(loadSequence !== _this5.salesDetailLoadSequence)) {
|
|
850
|
+
_context5.next = 3;
|
|
816
851
|
break;
|
|
817
852
|
}
|
|
818
853
|
skippedBeforeHydrate = true;
|
|
819
|
-
return
|
|
854
|
+
return _context5.abrupt("return");
|
|
820
855
|
case 3:
|
|
821
|
-
if (
|
|
822
|
-
|
|
856
|
+
if (_this5.store.order) {
|
|
857
|
+
_context5.next = 5;
|
|
823
858
|
break;
|
|
824
859
|
}
|
|
825
860
|
throw new Error('order 模块未初始化');
|
|
@@ -838,32 +873,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
838
873
|
source: 'mergedSalesDetail'
|
|
839
874
|
};
|
|
840
875
|
}
|
|
841
|
-
|
|
842
|
-
return
|
|
876
|
+
_context5.next = 9;
|
|
877
|
+
return _this5.store.order.hydrateTempOrderFromRecord(record, hydrateOptions);
|
|
843
878
|
case 9:
|
|
844
|
-
sales =
|
|
879
|
+
sales = _context5.sent;
|
|
845
880
|
hydratedSales = sales;
|
|
846
881
|
|
|
847
882
|
// hydrate 期间可能又发起了更新请求;后续任务已串行排队,将负责最终状态。
|
|
848
|
-
if (!(loadSequence !==
|
|
849
|
-
|
|
883
|
+
if (!(loadSequence !== _this5.salesDetailLoadSequence)) {
|
|
884
|
+
_context5.next = 13;
|
|
850
885
|
break;
|
|
851
886
|
}
|
|
852
|
-
return
|
|
887
|
+
return _context5.abrupt("return");
|
|
853
888
|
case 13:
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
return
|
|
889
|
+
_this5.currentSalesDetail = sales;
|
|
890
|
+
_context5.next = 16;
|
|
891
|
+
return _this5.core.effects.emit("".concat(_this5.name, ":onSalesOrderLoaded"), {
|
|
857
892
|
sales: sales
|
|
858
893
|
});
|
|
859
894
|
case 16:
|
|
860
895
|
case "end":
|
|
861
|
-
return
|
|
896
|
+
return _context5.stop();
|
|
862
897
|
}
|
|
863
|
-
},
|
|
898
|
+
}, _callee5);
|
|
864
899
|
}));
|
|
865
900
|
return function hydrateTask() {
|
|
866
|
-
return
|
|
901
|
+
return _ref11.apply(this, arguments);
|
|
867
902
|
};
|
|
868
903
|
}();
|
|
869
904
|
queuedTask = this.salesDetailHydrateQueue.then(hydrateTask, hydrateTask);
|
|
@@ -872,23 +907,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
872
907
|
}, function () {
|
|
873
908
|
return undefined;
|
|
874
909
|
});
|
|
875
|
-
|
|
910
|
+
_context6.next = 7;
|
|
876
911
|
return queuedTask;
|
|
877
912
|
case 7:
|
|
878
913
|
if (!skippedBeforeHydrate) {
|
|
879
|
-
|
|
914
|
+
_context6.next = 9;
|
|
880
915
|
break;
|
|
881
916
|
}
|
|
882
|
-
return
|
|
917
|
+
return _context6.abrupt("return", record);
|
|
883
918
|
case 9:
|
|
884
|
-
return
|
|
919
|
+
return _context6.abrupt("return", hydratedSales || this.currentSalesDetail || record);
|
|
885
920
|
case 10:
|
|
886
921
|
case "end":
|
|
887
|
-
return
|
|
922
|
+
return _context6.stop();
|
|
888
923
|
}
|
|
889
|
-
},
|
|
924
|
+
}, _callee6, this);
|
|
890
925
|
}));
|
|
891
|
-
function hydrateLatestLoadedSalesDetail(
|
|
926
|
+
function hydrateLatestLoadedSalesDetail(_x3, _x4, _x5) {
|
|
892
927
|
return _hydrateLatestLoadedSalesDetail.apply(this, arguments);
|
|
893
928
|
}
|
|
894
929
|
return hydrateLatestLoadedSalesDetail;
|
|
@@ -957,10 +992,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
957
992
|
});
|
|
958
993
|
}
|
|
959
994
|
quotation.setScheduleResolver(function (id) {
|
|
960
|
-
var _scheduleModule$getSc, _getScheduleByIds,
|
|
995
|
+
var _scheduleModule$getSc, _getScheduleByIds, _ref12;
|
|
961
996
|
var scheduleId = String(id);
|
|
962
997
|
if (scheduleById.has(scheduleId)) return scheduleById.get(scheduleId);
|
|
963
|
-
var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (
|
|
998
|
+
var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (_ref12 = scheduleModule).getScheduleByIds) === null || _getScheduleByIds === void 0 ? void 0 : _getScheduleByIds.call(_ref12, [id])) || [];
|
|
964
999
|
if (schedules[0]) scheduleById.set(scheduleId, schedules[0]);
|
|
965
1000
|
return schedules[0];
|
|
966
1001
|
});
|
|
@@ -968,32 +1003,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
968
1003
|
}, {
|
|
969
1004
|
key: "loadQuotationForPriceQuery",
|
|
970
1005
|
value: function () {
|
|
971
|
-
var _loadQuotationForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1006
|
+
var _loadQuotationForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
|
|
972
1007
|
var quotation, load;
|
|
973
|
-
return _regeneratorRuntime().wrap(function
|
|
974
|
-
while (1) switch (
|
|
1008
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
1009
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
975
1010
|
case 0:
|
|
976
1011
|
if (params.quotation) {
|
|
977
|
-
|
|
1012
|
+
_context7.next = 2;
|
|
978
1013
|
break;
|
|
979
1014
|
}
|
|
980
|
-
return
|
|
1015
|
+
return _context7.abrupt("return");
|
|
981
1016
|
case 2:
|
|
982
1017
|
this.applyQuotationScheduleResolver(params.quotation);
|
|
983
1018
|
quotation = params.quotation;
|
|
984
1019
|
load = typeof quotation.ensureQuotations === 'function' ? quotation.ensureQuotations.bind(quotation) : quotation.loadQuotations.bind(quotation);
|
|
985
|
-
|
|
1020
|
+
_context7.next = 7;
|
|
986
1021
|
return load({
|
|
987
1022
|
channel: this.getPriceQueryChannel(params.channel),
|
|
988
1023
|
customer_id: params.customer_id
|
|
989
1024
|
});
|
|
990
1025
|
case 7:
|
|
991
1026
|
case "end":
|
|
992
|
-
return
|
|
1027
|
+
return _context7.stop();
|
|
993
1028
|
}
|
|
994
|
-
},
|
|
1029
|
+
}, _callee7, this);
|
|
995
1030
|
}));
|
|
996
|
-
function loadQuotationForPriceQuery(
|
|
1031
|
+
function loadQuotationForPriceQuery(_x6) {
|
|
997
1032
|
return _loadQuotationForPriceQuery.apply(this, arguments);
|
|
998
1033
|
}
|
|
999
1034
|
return loadQuotationForPriceQuery;
|
|
@@ -1014,9 +1049,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1014
1049
|
}, {
|
|
1015
1050
|
key: "getPriceQueryChannel",
|
|
1016
1051
|
value: function getPriceQueryChannel(channel) {
|
|
1017
|
-
var _this$otherParams,
|
|
1052
|
+
var _this$otherParams, _ref13, _ref14, _this$otherParams2, _this$otherParams3;
|
|
1018
1053
|
var strategyContext = (_this$otherParams = this.otherParams) !== null && _this$otherParams !== void 0 && _this$otherParams.strategy_context && _typeof(this.otherParams.strategy_context) === 'object' ? this.otherParams.strategy_context : {};
|
|
1019
|
-
var value = (
|
|
1054
|
+
var value = (_ref13 = (_ref14 = channel !== null && channel !== void 0 ? channel : strategyContext.channel) !== null && _ref14 !== void 0 ? _ref14 : (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.channel) !== null && _ref13 !== void 0 ? _ref13 : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform;
|
|
1020
1055
|
if (value === undefined || value === null || String(value).trim() === '') {
|
|
1021
1056
|
return undefined;
|
|
1022
1057
|
}
|
|
@@ -1029,11 +1064,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1029
1064
|
}, {
|
|
1030
1065
|
key: "getPriceQueryStrategyContext",
|
|
1031
1066
|
value: function getPriceQueryStrategyContext(channel) {
|
|
1032
|
-
var _this$otherParams4,
|
|
1067
|
+
var _this$otherParams4, _ref15, _strategyContext$busi, _this$otherParams5, _this$otherParams6;
|
|
1033
1068
|
var inherited = (_this$otherParams4 = this.otherParams) !== null && _this$otherParams4 !== void 0 && _this$otherParams4.strategy_context && _typeof(this.otherParams.strategy_context) === 'object' ? this.otherParams.strategy_context : {};
|
|
1034
1069
|
var strategyContext = _objectSpread({}, inherited);
|
|
1035
1070
|
var resolvedChannel = this.getPriceQueryChannel(channel);
|
|
1036
|
-
var businessCode = (
|
|
1071
|
+
var businessCode = (_ref15 = (_strategyContext$busi = strategyContext.business_code) !== null && _strategyContext$busi !== void 0 ? _strategyContext$busi : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.businessCode) !== null && _ref15 !== void 0 ? _ref15 : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.business_code;
|
|
1037
1072
|
if (resolvedChannel) strategyContext.channel = resolvedChannel;
|
|
1038
1073
|
if (businessCode !== undefined && businessCode !== null && String(businessCode).trim() !== '') {
|
|
1039
1074
|
strategyContext.business_code = String(businessCode).trim();
|
|
@@ -1051,16 +1086,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1051
1086
|
}, {
|
|
1052
1087
|
key: "prepareProductPriceQueryContext",
|
|
1053
1088
|
value: (function () {
|
|
1054
|
-
var _prepareProductPriceQueryContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1055
|
-
return _regeneratorRuntime().wrap(function
|
|
1056
|
-
while (1) switch (
|
|
1089
|
+
var _prepareProductPriceQueryContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_customerId) {
|
|
1090
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
1091
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1057
1092
|
case 0:
|
|
1058
1093
|
case "end":
|
|
1059
|
-
return
|
|
1094
|
+
return _context8.stop();
|
|
1060
1095
|
}
|
|
1061
|
-
},
|
|
1096
|
+
}, _callee8);
|
|
1062
1097
|
}));
|
|
1063
|
-
function prepareProductPriceQueryContext(
|
|
1098
|
+
function prepareProductPriceQueryContext(_x7) {
|
|
1064
1099
|
return _prepareProductPriceQueryContext.apply(this, arguments);
|
|
1065
1100
|
}
|
|
1066
1101
|
return prepareProductPriceQueryContext;
|
|
@@ -1112,12 +1147,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1112
1147
|
}, {
|
|
1113
1148
|
key: "getPriceQueryScheduleList",
|
|
1114
1149
|
value: function getPriceQueryScheduleList() {
|
|
1115
|
-
var _this$store$schedule, _this$store$schedule$, _this$
|
|
1150
|
+
var _this$store$schedule, _this$store$schedule$, _this$core4;
|
|
1116
1151
|
var storeScheduleList = (_this$store$schedule = this.store.schedule) === null || _this$store$schedule === void 0 || (_this$store$schedule$ = _this$store$schedule.getScheduleList) === null || _this$store$schedule$ === void 0 ? void 0 : _this$store$schedule$.call(_this$store$schedule);
|
|
1117
1152
|
if (Array.isArray(storeScheduleList) && storeScheduleList.length > 0) {
|
|
1118
1153
|
return storeScheduleList;
|
|
1119
1154
|
}
|
|
1120
|
-
var contextScheduleList = (_this$
|
|
1155
|
+
var contextScheduleList = (_this$core4 = this.core) === null || _this$core4 === void 0 || (_this$core4 = _this$core4.context) === null || _this$core4 === void 0 ? void 0 : _this$core4.scheduleList;
|
|
1121
1156
|
return Array.isArray(contextScheduleList) && contextScheduleList.length > 0 ? contextScheduleList : undefined;
|
|
1122
1157
|
}
|
|
1123
1158
|
}, {
|
|
@@ -1177,8 +1212,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1177
1212
|
}, {
|
|
1178
1213
|
key: "getSelectedProductVariantId",
|
|
1179
1214
|
value: function getSelectedProductVariantId(product) {
|
|
1180
|
-
var
|
|
1181
|
-
var variantId = Number((
|
|
1215
|
+
var _ref16, _product$product_vari;
|
|
1216
|
+
var variantId = Number((_ref16 = (_product$product_vari = product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : product === null || product === void 0 ? void 0 : product.variant_id) !== null && _ref16 !== void 0 ? _ref16 : 0);
|
|
1182
1217
|
return Number.isFinite(variantId) && variantId > 0 ? variantId : 0;
|
|
1183
1218
|
}
|
|
1184
1219
|
|
|
@@ -1193,7 +1228,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1193
1228
|
key: "prepareRawProductForPriceQuery",
|
|
1194
1229
|
value: function prepareRawProductForPriceQuery(rawProduct, selectedProduct) {
|
|
1195
1230
|
var _product$product_id2,
|
|
1196
|
-
|
|
1231
|
+
_this6 = this;
|
|
1197
1232
|
var product = cloneDeep(rawProduct);
|
|
1198
1233
|
var rawProductId = this.getPriceQueryProductId(product);
|
|
1199
1234
|
var selectedProductId = this.getPriceQueryProductId(selectedProduct);
|
|
@@ -1205,13 +1240,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1205
1240
|
product.product_variant_id = selectedVariantId;
|
|
1206
1241
|
product.variant_id = selectedVariantId;
|
|
1207
1242
|
if (selectedVariantId > 0) {
|
|
1208
|
-
var
|
|
1243
|
+
var _ref17, _selectedVariant$pric, _selectedVariant$sell, _selectedVariant$base;
|
|
1209
1244
|
var variants = Array.isArray(product.variant) ? product.variant : [];
|
|
1210
1245
|
var selectedVariant = variants.find(function (variant) {
|
|
1211
1246
|
return Number(variant === null || variant === void 0 ? void 0 : variant.id) === selectedVariantId;
|
|
1212
1247
|
});
|
|
1213
1248
|
if (!selectedVariant) return null;
|
|
1214
|
-
var variantPrice = (
|
|
1249
|
+
var variantPrice = (_ref17 = (_selectedVariant$pric = selectedVariant.price) !== null && _selectedVariant$pric !== void 0 ? _selectedVariant$pric : selectedVariant.selling_price) !== null && _ref17 !== void 0 ? _ref17 : selectedVariant.base_price;
|
|
1215
1250
|
if (variantPrice === undefined || variantPrice === null || variantPrice === '') {
|
|
1216
1251
|
return null;
|
|
1217
1252
|
}
|
|
@@ -1223,11 +1258,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1223
1258
|
if (selectedBundles.length > 0) {
|
|
1224
1259
|
var rawBundleItems = this.getAuthoritativeBundleItems(product);
|
|
1225
1260
|
var allSelectedBundlesExist = selectedBundles.every(function (bundle) {
|
|
1226
|
-
var
|
|
1227
|
-
var authoritativeBundle =
|
|
1261
|
+
var _ref18, _bundle$bundle_varian, _ref19, _authoritativeBundle$;
|
|
1262
|
+
var authoritativeBundle = _this6.findAuthoritativeBundleItem(bundle, rawBundleItems);
|
|
1228
1263
|
if (!authoritativeBundle) return false;
|
|
1229
|
-
var selectedBundleVariantId = Number((
|
|
1230
|
-
var authoritativeBundleVariantId = Number((
|
|
1264
|
+
var selectedBundleVariantId = Number((_ref18 = (_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.variant_id) !== null && _ref18 !== void 0 ? _ref18 : 0);
|
|
1265
|
+
var authoritativeBundleVariantId = Number((_ref19 = (_authoritativeBundle$ = authoritativeBundle === null || authoritativeBundle === void 0 ? void 0 : authoritativeBundle.bundle_variant_id) !== null && _authoritativeBundle$ !== void 0 ? _authoritativeBundle$ : authoritativeBundle === null || authoritativeBundle === void 0 ? void 0 : authoritativeBundle.variant_id) !== null && _ref19 !== void 0 ? _ref19 : 0);
|
|
1231
1266
|
if ((Number.isFinite(selectedBundleVariantId) ? selectedBundleVariantId : 0) !== (Number.isFinite(authoritativeBundleVariantId) ? authoritativeBundleVariantId : 0)) {
|
|
1232
1267
|
return false;
|
|
1233
1268
|
}
|
|
@@ -1262,42 +1297,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1262
1297
|
}, {
|
|
1263
1298
|
key: "loadProductsForPriceQuery",
|
|
1264
1299
|
value: function () {
|
|
1265
|
-
var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1300
|
+
var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
1266
1301
|
var ids, productsById, handledByOsServer, _response$data, queryPayload, response, list, scheduleList, resolvedList;
|
|
1267
|
-
return _regeneratorRuntime().wrap(function
|
|
1268
|
-
while (1) switch (
|
|
1302
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1303
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1269
1304
|
case 0:
|
|
1270
1305
|
ids = Array.from(new Set(params.ids.filter(function (id) {
|
|
1271
1306
|
return Number.isFinite(id);
|
|
1272
1307
|
})));
|
|
1273
1308
|
productsById = new Map();
|
|
1274
1309
|
if (!(!ids.length || !this.request)) {
|
|
1275
|
-
|
|
1310
|
+
_context9.next = 4;
|
|
1276
1311
|
break;
|
|
1277
1312
|
}
|
|
1278
|
-
return
|
|
1313
|
+
return _context9.abrupt("return", productsById);
|
|
1279
1314
|
case 4:
|
|
1280
1315
|
handledByOsServer = isProductQueryHandledByOsServer(this.core, this.request);
|
|
1281
|
-
|
|
1316
|
+
_context9.prev = 5;
|
|
1282
1317
|
queryPayload = this.buildPriceQueryPayload(_objectSpread(_objectSpread({}, params), {}, {
|
|
1283
1318
|
ids: ids
|
|
1284
1319
|
}));
|
|
1285
|
-
|
|
1320
|
+
_context9.next = 9;
|
|
1286
1321
|
return this.request.post('/product/query', queryPayload, {
|
|
1287
1322
|
osServer: true,
|
|
1288
1323
|
customToast: function customToast() {}
|
|
1289
1324
|
});
|
|
1290
1325
|
case 9:
|
|
1291
|
-
response =
|
|
1326
|
+
response = _context9.sent;
|
|
1292
1327
|
list = (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) || (response === null || response === void 0 ? void 0 : response.list) || [];
|
|
1293
1328
|
if (Array.isArray(list)) {
|
|
1294
|
-
|
|
1329
|
+
_context9.next = 13;
|
|
1295
1330
|
break;
|
|
1296
1331
|
}
|
|
1297
|
-
return
|
|
1332
|
+
return _context9.abrupt("return", productsById);
|
|
1298
1333
|
case 13:
|
|
1299
1334
|
if (!(this.isCustomerUserPriceQuery() && !handledByOsServer)) {
|
|
1300
|
-
|
|
1335
|
+
_context9.next = 17;
|
|
1301
1336
|
break;
|
|
1302
1337
|
}
|
|
1303
1338
|
this.rememberRawProductPriceSources(list);
|
|
@@ -1306,7 +1341,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1306
1341
|
var productId = Number((_item$id = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id !== void 0 ? _item$id : item === null || item === void 0 ? void 0 : item.product_id);
|
|
1307
1342
|
if (Number.isFinite(productId)) productsById.set(productId, item);
|
|
1308
1343
|
});
|
|
1309
|
-
return
|
|
1344
|
+
return _context9.abrupt("return", productsById);
|
|
1310
1345
|
case 17:
|
|
1311
1346
|
scheduleList = this.getPriceQueryScheduleList();
|
|
1312
1347
|
resolvedList = resolveClientDataVariants(_objectSpread({
|
|
@@ -1323,22 +1358,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1323
1358
|
var productId = Number((_item$id2 = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id2 !== void 0 ? _item$id2 : item === null || item === void 0 ? void 0 : item.product_id);
|
|
1324
1359
|
if (Number.isFinite(productId)) productsById.set(productId, item);
|
|
1325
1360
|
});
|
|
1326
|
-
return
|
|
1361
|
+
return _context9.abrupt("return", productsById);
|
|
1327
1362
|
case 23:
|
|
1328
|
-
|
|
1329
|
-
|
|
1363
|
+
_context9.prev = 23;
|
|
1364
|
+
_context9.t0 = _context9["catch"](5);
|
|
1330
1365
|
this.logWarning('loadProductsForPriceQuery: 商品批量重查失败,使用入参 fallback', {
|
|
1331
1366
|
ids: ids,
|
|
1332
|
-
error:
|
|
1367
|
+
error: _context9.t0 instanceof Error ? _context9.t0.message : String(_context9.t0)
|
|
1333
1368
|
});
|
|
1334
|
-
return
|
|
1369
|
+
return _context9.abrupt("return", productsById);
|
|
1335
1370
|
case 27:
|
|
1336
1371
|
case "end":
|
|
1337
|
-
return
|
|
1372
|
+
return _context9.stop();
|
|
1338
1373
|
}
|
|
1339
|
-
},
|
|
1374
|
+
}, _callee9, this, [[5, 23]]);
|
|
1340
1375
|
}));
|
|
1341
|
-
function loadProductsForPriceQuery(
|
|
1376
|
+
function loadProductsForPriceQuery(_x8) {
|
|
1342
1377
|
return _loadProductsForPriceQuery.apply(this, arguments);
|
|
1343
1378
|
}
|
|
1344
1379
|
return loadProductsForPriceQuery;
|
|
@@ -1346,44 +1381,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1346
1381
|
}, {
|
|
1347
1382
|
key: "resolveProductsForPriceQuery",
|
|
1348
1383
|
value: function () {
|
|
1349
|
-
var _resolveProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1350
|
-
var
|
|
1384
|
+
var _resolveProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
1385
|
+
var _this7 = this;
|
|
1351
1386
|
var selectedProducts, productIds, ids, handledByOsServer, canUseLocalFastPath, productsById, queryPayload, cachedRawProducts, authoritativeProducts, missingIds, remoteRawProducts;
|
|
1352
|
-
return _regeneratorRuntime().wrap(function
|
|
1353
|
-
while (1) switch (
|
|
1387
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1388
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1354
1389
|
case 0:
|
|
1355
1390
|
selectedProducts = params.priceQueries.map(function (item) {
|
|
1356
1391
|
return item.product || {};
|
|
1357
1392
|
});
|
|
1358
1393
|
productIds = selectedProducts.map(function (product) {
|
|
1359
|
-
return
|
|
1394
|
+
return _this7.getPriceQueryProductId(product);
|
|
1360
1395
|
});
|
|
1361
1396
|
ids = Array.from(new Set(productIds.filter(function (id) {
|
|
1362
1397
|
return id !== null;
|
|
1363
1398
|
})));
|
|
1364
1399
|
if (ids.length) {
|
|
1365
|
-
|
|
1400
|
+
_context10.next = 5;
|
|
1366
1401
|
break;
|
|
1367
1402
|
}
|
|
1368
|
-
return
|
|
1403
|
+
return _context10.abrupt("return", selectedProducts.map(function () {
|
|
1369
1404
|
return null;
|
|
1370
1405
|
}));
|
|
1371
1406
|
case 5:
|
|
1372
1407
|
handledByOsServer = this.request ? isProductQueryHandledByOsServer(this.core, this.request) : false;
|
|
1373
1408
|
canUseLocalFastPath = this.isCustomerUserPriceQuery() && !handledByOsServer;
|
|
1374
1409
|
if (canUseLocalFastPath) {
|
|
1375
|
-
|
|
1410
|
+
_context10.next = 14;
|
|
1376
1411
|
break;
|
|
1377
1412
|
}
|
|
1378
1413
|
if (this.request) {
|
|
1379
|
-
|
|
1414
|
+
_context10.next = 10;
|
|
1380
1415
|
break;
|
|
1381
1416
|
}
|
|
1382
|
-
return
|
|
1417
|
+
return _context10.abrupt("return", selectedProducts.map(function () {
|
|
1383
1418
|
return null;
|
|
1384
1419
|
}));
|
|
1385
1420
|
case 10:
|
|
1386
|
-
|
|
1421
|
+
_context10.next = 12;
|
|
1387
1422
|
return this.loadProductsForPriceQuery({
|
|
1388
1423
|
ids: ids,
|
|
1389
1424
|
schedule: params.schedule,
|
|
@@ -1391,8 +1426,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1391
1426
|
channel: params.channel
|
|
1392
1427
|
});
|
|
1393
1428
|
case 12:
|
|
1394
|
-
productsById =
|
|
1395
|
-
return
|
|
1429
|
+
productsById = _context10.sent;
|
|
1430
|
+
return _context10.abrupt("return", productIds.map(function (productId) {
|
|
1396
1431
|
return productId === null ? null : productsById.get(productId) || null;
|
|
1397
1432
|
}));
|
|
1398
1433
|
case 14:
|
|
@@ -1405,7 +1440,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1405
1440
|
cachedRawProducts = this.getRawProductPriceSources(ids);
|
|
1406
1441
|
authoritativeProducts = selectedProducts.map(function (selectedProduct, index) {
|
|
1407
1442
|
var productId = productIds[index];
|
|
1408
|
-
return productId === null ? null :
|
|
1443
|
+
return productId === null ? null : _this7.resolveLocalProductForPriceQuery({
|
|
1409
1444
|
selectedProduct: selectedProduct,
|
|
1410
1445
|
rawProduct: cachedRawProducts.get(productId),
|
|
1411
1446
|
queryPayload: queryPayload
|
|
@@ -1415,18 +1450,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1415
1450
|
return productId !== null && !authoritativeProducts[index];
|
|
1416
1451
|
})));
|
|
1417
1452
|
if (missingIds.length) {
|
|
1418
|
-
|
|
1453
|
+
_context10.next = 20;
|
|
1419
1454
|
break;
|
|
1420
1455
|
}
|
|
1421
|
-
return
|
|
1456
|
+
return _context10.abrupt("return", authoritativeProducts);
|
|
1422
1457
|
case 20:
|
|
1423
1458
|
if (this.request) {
|
|
1424
|
-
|
|
1459
|
+
_context10.next = 22;
|
|
1425
1460
|
break;
|
|
1426
1461
|
}
|
|
1427
|
-
return
|
|
1462
|
+
return _context10.abrupt("return", authoritativeProducts);
|
|
1428
1463
|
case 22:
|
|
1429
|
-
|
|
1464
|
+
_context10.next = 24;
|
|
1430
1465
|
return this.loadProductsForPriceQuery({
|
|
1431
1466
|
ids: missingIds,
|
|
1432
1467
|
schedule: params.schedule,
|
|
@@ -1434,13 +1469,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1434
1469
|
channel: params.channel
|
|
1435
1470
|
});
|
|
1436
1471
|
case 24:
|
|
1437
|
-
remoteRawProducts =
|
|
1472
|
+
remoteRawProducts = _context10.sent;
|
|
1438
1473
|
authoritativeProducts.forEach(function (authoritativeProduct, index) {
|
|
1439
1474
|
if (authoritativeProduct) return;
|
|
1440
1475
|
var productId = productIds[index];
|
|
1441
1476
|
if (productId === null) return;
|
|
1442
1477
|
var rawProduct = remoteRawProducts.get(productId);
|
|
1443
|
-
var locallyResolved =
|
|
1478
|
+
var locallyResolved = _this7.resolveLocalProductForPriceQuery({
|
|
1444
1479
|
selectedProduct: selectedProducts[index],
|
|
1445
1480
|
rawProduct: rawProduct,
|
|
1446
1481
|
queryPayload: queryPayload
|
|
@@ -1452,16 +1487,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1452
1487
|
|
|
1453
1488
|
// 严格客户端能力仍不可用时,真实请求已经是最后的权威降级。
|
|
1454
1489
|
// 尽量应用所选 SKU 基线;关系不完整时保持旧的远端商品语义。
|
|
1455
|
-
authoritativeProducts[index] = rawProduct ?
|
|
1490
|
+
authoritativeProducts[index] = rawProduct ? _this7.prepareRawProductForPriceQuery(rawProduct, selectedProducts[index]) || rawProduct : null;
|
|
1456
1491
|
});
|
|
1457
|
-
return
|
|
1492
|
+
return _context10.abrupt("return", authoritativeProducts);
|
|
1458
1493
|
case 27:
|
|
1459
1494
|
case "end":
|
|
1460
|
-
return
|
|
1495
|
+
return _context10.stop();
|
|
1461
1496
|
}
|
|
1462
|
-
},
|
|
1497
|
+
}, _callee10, this);
|
|
1463
1498
|
}));
|
|
1464
|
-
function resolveProductsForPriceQuery(
|
|
1499
|
+
function resolveProductsForPriceQuery(_x9) {
|
|
1465
1500
|
return _resolveProductsForPriceQuery.apply(this, arguments);
|
|
1466
1501
|
}
|
|
1467
1502
|
return resolveProductsForPriceQuery;
|
|
@@ -1474,10 +1509,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1474
1509
|
return groups.flatMap(function (group) {
|
|
1475
1510
|
var items = Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : Array.isArray(group === null || group === void 0 ? void 0 : group.bundleItem) ? group.bundleItem : [];
|
|
1476
1511
|
return items.map(function (item) {
|
|
1477
|
-
var _item$group_id,
|
|
1512
|
+
var _item$group_id, _ref20, _item$bundle_group_id;
|
|
1478
1513
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
1479
1514
|
group_id: (_item$group_id = item === null || item === void 0 ? void 0 : item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : group === null || group === void 0 ? void 0 : group.id,
|
|
1480
|
-
bundle_group_id: (
|
|
1515
|
+
bundle_group_id: (_ref20 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref20 !== void 0 ? _ref20 : group === null || group === void 0 ? void 0 : group.id
|
|
1481
1516
|
});
|
|
1482
1517
|
});
|
|
1483
1518
|
});
|
|
@@ -1508,21 +1543,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1508
1543
|
}, {
|
|
1509
1544
|
key: "getAuthoritativeBundleUnitPrice",
|
|
1510
1545
|
value: function getAuthoritativeBundleUnitPrice(bundle) {
|
|
1511
|
-
var
|
|
1512
|
-
return (
|
|
1546
|
+
var _ref21, _ref22, _ref23, _bundle$price;
|
|
1547
|
+
return (_ref21 = (_ref22 = (_ref23 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref23 !== void 0 ? _ref23 : bundle.custom_price) !== null && _ref22 !== void 0 ? _ref22 : bundle.product_price) !== null && _ref21 !== void 0 ? _ref21 : bundle.base_price;
|
|
1513
1548
|
}
|
|
1514
1549
|
}, {
|
|
1515
1550
|
key: "mergeProductForPriceQuery",
|
|
1516
1551
|
value: function mergeProductForPriceQuery(product, authoritativeProduct) {
|
|
1517
|
-
var
|
|
1552
|
+
var _this8 = this,
|
|
1518
1553
|
_product$id,
|
|
1519
|
-
_ref23,
|
|
1520
|
-
_product$product_id3,
|
|
1521
1554
|
_ref24,
|
|
1522
|
-
_product$
|
|
1555
|
+
_product$product_id3,
|
|
1523
1556
|
_ref25,
|
|
1524
|
-
_product$
|
|
1557
|
+
_product$product_vari2,
|
|
1525
1558
|
_ref26,
|
|
1559
|
+
_product$num,
|
|
1560
|
+
_ref27,
|
|
1526
1561
|
_product$quantity,
|
|
1527
1562
|
_product$metadata4;
|
|
1528
1563
|
if (!authoritativeProduct) return product;
|
|
@@ -1530,8 +1565,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1530
1565
|
var authoritativeBundles = this.getAuthoritativeBundleItems(authoritativeProduct);
|
|
1531
1566
|
var productBundle = selectedBundles.map(function (bundle) {
|
|
1532
1567
|
var _authoritativeBundle$2, _authoritativeBundle$3;
|
|
1533
|
-
var authoritativeBundle =
|
|
1534
|
-
var unitPrice = authoritativeBundle ?
|
|
1568
|
+
var authoritativeBundle = _this8.findAuthoritativeBundleItem(bundle, authoritativeBundles);
|
|
1569
|
+
var unitPrice = authoritativeBundle ? _this8.getAuthoritativeBundleUnitPrice(authoritativeBundle) : undefined;
|
|
1535
1570
|
if (unitPrice === undefined || unitPrice === null || unitPrice === '') return bundle;
|
|
1536
1571
|
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
1537
1572
|
price: unitPrice,
|
|
@@ -1542,10 +1577,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1542
1577
|
});
|
|
1543
1578
|
return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
|
|
1544
1579
|
id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
|
|
1545
|
-
product_id: (
|
|
1546
|
-
product_variant_id: (
|
|
1547
|
-
num: (
|
|
1548
|
-
quantity: (
|
|
1580
|
+
product_id: (_ref24 = (_product$product_id3 = product.product_id) !== null && _product$product_id3 !== void 0 ? _product$product_id3 : authoritativeProduct.product_id) !== null && _ref24 !== void 0 ? _ref24 : authoritativeProduct.id,
|
|
1581
|
+
product_variant_id: (_ref25 = (_product$product_vari2 = product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : authoritativeProduct.product_variant_id) !== null && _ref25 !== void 0 ? _ref25 : 0,
|
|
1582
|
+
num: (_ref26 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref26 !== void 0 ? _ref26 : authoritativeProduct.num,
|
|
1583
|
+
quantity: (_ref27 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref27 !== void 0 ? _ref27 : authoritativeProduct.quantity,
|
|
1549
1584
|
product_sku: function () {
|
|
1550
1585
|
var authoritativeSku = ensureProductSku(authoritativeProduct);
|
|
1551
1586
|
var productSku = ensureProductSku(product);
|
|
@@ -1711,60 +1746,60 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1711
1746
|
}, {
|
|
1712
1747
|
key: "syncOtherParamsToSubModules",
|
|
1713
1748
|
value: (function () {
|
|
1714
|
-
var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1715
|
-
var
|
|
1716
|
-
var
|
|
1717
|
-
|
|
1749
|
+
var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(changedParams) {
|
|
1750
|
+
var _this9 = this;
|
|
1751
|
+
var _ref31,
|
|
1752
|
+
_ref31$cover,
|
|
1718
1753
|
cover,
|
|
1719
|
-
|
|
1720
|
-
return _regeneratorRuntime().wrap(function
|
|
1721
|
-
while (1) switch (
|
|
1754
|
+
_args12 = arguments;
|
|
1755
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1756
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1722
1757
|
case 0:
|
|
1723
|
-
|
|
1724
|
-
|
|
1758
|
+
_ref31 = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : {}, _ref31$cover = _ref31.cover, cover = _ref31$cover === void 0 ? false : _ref31$cover;
|
|
1759
|
+
_context12.next = 3;
|
|
1725
1760
|
return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
|
|
1726
|
-
var
|
|
1727
|
-
var
|
|
1728
|
-
return _regeneratorRuntime().wrap(function
|
|
1729
|
-
while (1) switch (
|
|
1761
|
+
var _ref33 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(_ref32) {
|
|
1762
|
+
var _ref34, moduleName, subModule, targetModule, nextSubModuleOtherParams;
|
|
1763
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1764
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1730
1765
|
case 0:
|
|
1731
|
-
|
|
1732
|
-
if (!
|
|
1733
|
-
|
|
1766
|
+
_ref34 = _slicedToArray(_ref32, 2), moduleName = _ref34[0], subModule = _ref34[1];
|
|
1767
|
+
if (!_this9.reusedSharedSubModuleNames.has(moduleName)) {
|
|
1768
|
+
_context11.next = 3;
|
|
1734
1769
|
break;
|
|
1735
1770
|
}
|
|
1736
|
-
return
|
|
1771
|
+
return _context11.abrupt("return");
|
|
1737
1772
|
case 3:
|
|
1738
1773
|
targetModule = subModule;
|
|
1739
1774
|
if (!(!targetModule || typeof targetModule.updateOtherParams !== 'function')) {
|
|
1740
|
-
|
|
1775
|
+
_context11.next = 6;
|
|
1741
1776
|
break;
|
|
1742
1777
|
}
|
|
1743
|
-
return
|
|
1778
|
+
return _context11.abrupt("return");
|
|
1744
1779
|
case 6:
|
|
1745
|
-
nextSubModuleOtherParams =
|
|
1746
|
-
|
|
1780
|
+
nextSubModuleOtherParams = _this9.buildSubModuleOtherParams(moduleName);
|
|
1781
|
+
_context11.next = 9;
|
|
1747
1782
|
return targetModule.updateOtherParams(nextSubModuleOtherParams, {
|
|
1748
1783
|
changedParams: changedParams,
|
|
1749
1784
|
cover: cover
|
|
1750
1785
|
});
|
|
1751
1786
|
case 9:
|
|
1752
1787
|
case "end":
|
|
1753
|
-
return
|
|
1788
|
+
return _context11.stop();
|
|
1754
1789
|
}
|
|
1755
|
-
},
|
|
1790
|
+
}, _callee11);
|
|
1756
1791
|
}));
|
|
1757
|
-
return function (
|
|
1758
|
-
return
|
|
1792
|
+
return function (_x11) {
|
|
1793
|
+
return _ref33.apply(this, arguments);
|
|
1759
1794
|
};
|
|
1760
1795
|
}()));
|
|
1761
1796
|
case 3:
|
|
1762
1797
|
case "end":
|
|
1763
|
-
return
|
|
1798
|
+
return _context12.stop();
|
|
1764
1799
|
}
|
|
1765
|
-
},
|
|
1800
|
+
}, _callee12, this);
|
|
1766
1801
|
}));
|
|
1767
|
-
function syncOtherParamsToSubModules(
|
|
1802
|
+
function syncOtherParamsToSubModules(_x10) {
|
|
1768
1803
|
return _syncOtherParamsToSubModules.apply(this, arguments);
|
|
1769
1804
|
}
|
|
1770
1805
|
return syncOtherParamsToSubModules;
|
|
@@ -1814,22 +1849,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1814
1849
|
}, {
|
|
1815
1850
|
key: "getPaymentNumberDevicePrefixSync",
|
|
1816
1851
|
value: function getPaymentNumberDevicePrefixSync() {
|
|
1817
|
-
var
|
|
1852
|
+
var _this10 = this;
|
|
1818
1853
|
if (!this.appPlugin) return 'LOCAL';
|
|
1819
1854
|
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
1820
|
-
return
|
|
1855
|
+
return _this10.getAppData(key);
|
|
1821
1856
|
});
|
|
1822
1857
|
}
|
|
1823
1858
|
}, {
|
|
1824
1859
|
key: "getPaymentNumberDevicePrefixAsync",
|
|
1825
1860
|
value: function getPaymentNumberDevicePrefixAsync() {
|
|
1826
|
-
var
|
|
1861
|
+
var _this11 = this;
|
|
1827
1862
|
if (!this.appPlugin) return Promise.resolve('LOCAL');
|
|
1828
1863
|
if (this.paymentNumberDevicePrefix) {
|
|
1829
1864
|
return Promise.resolve(this.paymentNumberDevicePrefix);
|
|
1830
1865
|
}
|
|
1831
1866
|
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
1832
|
-
return
|
|
1867
|
+
return _this11.getAppData(key);
|
|
1833
1868
|
});
|
|
1834
1869
|
}
|
|
1835
1870
|
}, {
|
|
@@ -1877,10 +1912,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1877
1912
|
}
|
|
1878
1913
|
tempOrder.metadata = tempOrder.metadata || {};
|
|
1879
1914
|
if (shouldManageLegalCurrencySnapshot) {
|
|
1880
|
-
var
|
|
1915
|
+
var _ref35, _ref36, _tempOrder$metadata$l, _ref37, _ref38, _tempOrder$metadata$l2, _tempOrder$metadata$l3;
|
|
1881
1916
|
var legalCurrencySnapshot = {
|
|
1882
|
-
currency_code: String((
|
|
1883
|
-
currency_symbol: String((
|
|
1917
|
+
currency_code: String((_ref35 = (_ref36 = currencyCode !== null && currencyCode !== void 0 ? currencyCode : (_tempOrder$metadata$l = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l === void 0 ? void 0 : _tempOrder$metadata$l.currency_code) !== null && _ref36 !== void 0 ? _ref36 : tempOrder.currency_code) !== null && _ref35 !== void 0 ? _ref35 : ''),
|
|
1918
|
+
currency_symbol: String((_ref37 = (_ref38 = currencySymbol !== null && currencySymbol !== void 0 ? currencySymbol : (_tempOrder$metadata$l2 = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l2 === void 0 ? void 0 : _tempOrder$metadata$l2.currency_symbol) !== null && _ref38 !== void 0 ? _ref38 : tempOrder.currency_symbol) !== null && _ref37 !== void 0 ? _ref37 : ''),
|
|
1884
1919
|
currency_format: String(((_tempOrder$metadata$l3 = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l3 === void 0 ? void 0 : _tempOrder$metadata$l3.currency_format) || (isVirtualSettlement ? 'symbol_first' : tempOrder.currency_format) || 'symbol_first')
|
|
1885
1920
|
};
|
|
1886
1921
|
if (JSON.stringify(tempOrder.metadata.legal_currency_snapshot || {}) !== JSON.stringify(legalCurrencySnapshot)) {
|
|
@@ -1907,21 +1942,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1907
1942
|
}, {
|
|
1908
1943
|
key: "initialize",
|
|
1909
1944
|
value: function () {
|
|
1910
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1945
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(core) {
|
|
1911
1946
|
var _this$otherParams12,
|
|
1912
1947
|
_this$appPlugin2,
|
|
1913
1948
|
_this$appPlugin2$getA,
|
|
1914
|
-
|
|
1949
|
+
_this12 = this,
|
|
1915
1950
|
_this$otherParams13;
|
|
1916
1951
|
var options,
|
|
1917
1952
|
app,
|
|
1918
1953
|
targetCacheData,
|
|
1919
1954
|
moduleNames,
|
|
1920
|
-
|
|
1921
|
-
return _regeneratorRuntime().wrap(function
|
|
1922
|
-
while (1) switch (
|
|
1955
|
+
_args13 = arguments;
|
|
1956
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1957
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1923
1958
|
case 0:
|
|
1924
|
-
options =
|
|
1959
|
+
options = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : {};
|
|
1925
1960
|
this.core = core;
|
|
1926
1961
|
this.initializeOptions = options || {};
|
|
1927
1962
|
this.paymentNumberDevicePrefix = null;
|
|
@@ -1942,48 +1977,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1942
1977
|
targetCacheData = this.readSessionCacheData();
|
|
1943
1978
|
moduleNames = this.getRegisteredModuleNames();
|
|
1944
1979
|
moduleNames.forEach(function (step) {
|
|
1945
|
-
var reusedModule =
|
|
1980
|
+
var reusedModule = _this12.getReusableSharedSubModule(step);
|
|
1946
1981
|
if (reusedModule) {
|
|
1947
|
-
|
|
1948
|
-
|
|
1982
|
+
_this12.store[step] = reusedModule;
|
|
1983
|
+
_this12.reusedSharedSubModuleNames.add(step);
|
|
1949
1984
|
return;
|
|
1950
1985
|
}
|
|
1951
|
-
var targetModule =
|
|
1986
|
+
var targetModule = _this12.createSubModule(step);
|
|
1952
1987
|
if (!targetModule) {
|
|
1953
1988
|
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
1954
1989
|
}
|
|
1955
|
-
var hooks =
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
initialState:
|
|
1990
|
+
var hooks = _this12.getSubModuleHooks(step);
|
|
1991
|
+
_this12.store[step] = targetModule;
|
|
1992
|
+
_this12.core.registerModule(targetModule, _objectSpread(_objectSpread({
|
|
1993
|
+
initialState: _this12.shouldUseSessionStorageForSubModule(step) ? (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {} : {}
|
|
1959
1994
|
}, hooks ? {
|
|
1960
1995
|
hooks: hooks
|
|
1961
1996
|
} : {}), {}, {
|
|
1962
|
-
otherParams:
|
|
1997
|
+
otherParams: _this12.buildSubModuleOtherParams(step)
|
|
1963
1998
|
}));
|
|
1964
1999
|
});
|
|
1965
2000
|
if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
|
|
1966
|
-
|
|
2001
|
+
_context13.next = 19;
|
|
1967
2002
|
break;
|
|
1968
2003
|
}
|
|
1969
|
-
|
|
2004
|
+
_context13.next = 19;
|
|
1970
2005
|
return this.store.schedule.loadAllSchedule();
|
|
1971
2006
|
case 19:
|
|
1972
2007
|
if (this.store.order && typeof ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.enableTempOrderPersist) === 'boolean') {
|
|
1973
2008
|
this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
|
|
1974
2009
|
}
|
|
1975
|
-
|
|
2010
|
+
_context13.next = 22;
|
|
1976
2011
|
return this.getPaymentMethodsAsync();
|
|
1977
2012
|
case 22:
|
|
2013
|
+
this.registerPaymentMethodsChangeSync();
|
|
1978
2014
|
this.registerServerOrderChangeSync();
|
|
1979
2015
|
this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
1980
|
-
case
|
|
2016
|
+
case 25:
|
|
1981
2017
|
case "end":
|
|
1982
|
-
return
|
|
2018
|
+
return _context13.stop();
|
|
1983
2019
|
}
|
|
1984
|
-
},
|
|
2020
|
+
}, _callee13, this);
|
|
1985
2021
|
}));
|
|
1986
|
-
function initialize(
|
|
2022
|
+
function initialize(_x12) {
|
|
1987
2023
|
return _initialize.apply(this, arguments);
|
|
1988
2024
|
}
|
|
1989
2025
|
return initialize;
|
|
@@ -1991,17 +2027,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1991
2027
|
}, {
|
|
1992
2028
|
key: "destroy",
|
|
1993
2029
|
value: function () {
|
|
1994
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2030
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
1995
2031
|
var _this$serverOrderChan2,
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
2032
|
+
_this$paymentMethodsC2,
|
|
2033
|
+
_this13 = this;
|
|
2034
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
2035
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1999
2036
|
case 0:
|
|
2000
2037
|
(_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
|
|
2001
2038
|
this.serverOrderChangeUnsubscribe = null;
|
|
2039
|
+
(_this$paymentMethodsC2 = this.paymentMethodsChangedUnsubscribe) === null || _this$paymentMethodsC2 === void 0 || _this$paymentMethodsC2.call(this);
|
|
2040
|
+
this.paymentMethodsChangedUnsubscribe = null;
|
|
2002
2041
|
Object.keys(this.store).forEach(function (key) {
|
|
2003
|
-
if (
|
|
2004
|
-
var sub =
|
|
2042
|
+
if (_this13.reusedSharedSubModuleNames.has(key)) return;
|
|
2043
|
+
var sub = _this13.store[key];
|
|
2005
2044
|
if (sub && typeof sub.destroy === 'function') {
|
|
2006
2045
|
try {
|
|
2007
2046
|
sub.destroy();
|
|
@@ -2015,15 +2054,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2015
2054
|
this.queuedServerOrderChanges = [];
|
|
2016
2055
|
this.salesDetailLoadSequence += 1;
|
|
2017
2056
|
this.walletAssetsRefreshSequence += 1;
|
|
2018
|
-
|
|
2057
|
+
_context14.next = 12;
|
|
2019
2058
|
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
2020
|
-
case
|
|
2059
|
+
case 12:
|
|
2021
2060
|
_get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
|
|
2022
|
-
case
|
|
2061
|
+
case 13:
|
|
2023
2062
|
case "end":
|
|
2024
|
-
return
|
|
2063
|
+
return _context14.stop();
|
|
2025
2064
|
}
|
|
2026
|
-
},
|
|
2065
|
+
}, _callee14, this);
|
|
2027
2066
|
}));
|
|
2028
2067
|
function destroy() {
|
|
2029
2068
|
return _destroy.apply(this, arguments);
|
|
@@ -2040,51 +2079,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2040
2079
|
}, {
|
|
2041
2080
|
key: "loadSalesDetail",
|
|
2042
2081
|
value: (function () {
|
|
2043
|
-
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2044
|
-
var loadSequence,
|
|
2045
|
-
return _regeneratorRuntime().wrap(function
|
|
2046
|
-
while (1) switch (
|
|
2082
|
+
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderIdOrParams) {
|
|
2083
|
+
var loadSequence, _ref39, _ref40, _ref41, _ref42, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, loadedSalesDetail, shouldFilterPendingPayments, remoteRecord, mergeSourceRecord, currentTempOrder, mergedRecord, record;
|
|
2084
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
2085
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
2047
2086
|
case 0:
|
|
2048
2087
|
if (this.store.order) {
|
|
2049
|
-
|
|
2088
|
+
_context15.next = 2;
|
|
2050
2089
|
break;
|
|
2051
2090
|
}
|
|
2052
2091
|
throw new Error('order 模块未初始化');
|
|
2053
2092
|
case 2:
|
|
2054
2093
|
loadSequence = ++this.salesDetailLoadSequence;
|
|
2055
2094
|
this.salesDetailLoadInFlightCount += 1;
|
|
2056
|
-
|
|
2095
|
+
_context15.prev = 4;
|
|
2057
2096
|
params = _typeof(orderIdOrParams) === 'object' ? orderIdOrParams : {
|
|
2058
2097
|
orderId: orderIdOrParams
|
|
2059
2098
|
};
|
|
2060
2099
|
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
2061
2100
|
preloadedSalesDetail = params.preloadedSalesDetail;
|
|
2062
|
-
lookup = (
|
|
2101
|
+
lookup = (_ref39 = (_ref40 = (_ref41 = (_ref42 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref42 !== void 0 ? _ref42 : params.orderNumber) !== null && _ref41 !== void 0 ? _ref41 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref40 !== void 0 ? _ref40 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref39 !== void 0 ? _ref39 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
|
|
2063
2102
|
if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
|
|
2064
|
-
|
|
2103
|
+
_context15.next = 11;
|
|
2065
2104
|
break;
|
|
2066
2105
|
}
|
|
2067
2106
|
throw new Error('加载销售详情需要 orderId、externalSaleNumber 或 orderNumber');
|
|
2068
2107
|
case 11:
|
|
2069
2108
|
if (!(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0)) {
|
|
2070
|
-
|
|
2109
|
+
_context15.next = 15;
|
|
2071
2110
|
break;
|
|
2072
2111
|
}
|
|
2073
|
-
|
|
2074
|
-
|
|
2112
|
+
_context15.t0 = preloadedSalesDetail;
|
|
2113
|
+
_context15.next = 18;
|
|
2075
2114
|
break;
|
|
2076
2115
|
case 15:
|
|
2077
|
-
|
|
2116
|
+
_context15.next = 17;
|
|
2078
2117
|
return this.store.order.getSalesOrderByLookup({
|
|
2079
2118
|
lookup: lookup,
|
|
2080
2119
|
forceRemote: params.forceRemote
|
|
2081
2120
|
});
|
|
2082
2121
|
case 17:
|
|
2083
|
-
|
|
2122
|
+
_context15.t0 = _context15.sent;
|
|
2084
2123
|
case 18:
|
|
2085
|
-
loadedRecord =
|
|
2124
|
+
loadedRecord = _context15.t0;
|
|
2086
2125
|
if (!(!preloadedSalesDetail && (!loadedRecord || loadedRecord.code !== 200))) {
|
|
2087
|
-
|
|
2126
|
+
_context15.next = 22;
|
|
2088
2127
|
break;
|
|
2089
2128
|
}
|
|
2090
2129
|
message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
|
|
@@ -2097,41 +2136,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2097
2136
|
currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
2098
2137
|
mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, mergeSourceRecord, 'preserve-local') : mergeSourceRecord;
|
|
2099
2138
|
record = shouldFilterPendingPayments ? filterPendingPaymentsFromLoadedSalesDetail(mergedRecord) : mergedRecord;
|
|
2100
|
-
|
|
2139
|
+
_context15.next = 31;
|
|
2101
2140
|
return this.hydrateLatestLoadedSalesDetail(record, loadSequence, {
|
|
2102
2141
|
hydrateSource: params.hydrateSource,
|
|
2103
2142
|
merge: params.merge
|
|
2104
2143
|
});
|
|
2105
2144
|
case 31:
|
|
2106
|
-
return
|
|
2145
|
+
return _context15.abrupt("return", _context15.sent);
|
|
2107
2146
|
case 32:
|
|
2108
|
-
|
|
2147
|
+
_context15.prev = 32;
|
|
2109
2148
|
this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
|
|
2110
2149
|
if (!(this.salesDetailLoadInFlightCount === 0)) {
|
|
2111
|
-
|
|
2150
|
+
_context15.next = 43;
|
|
2112
2151
|
break;
|
|
2113
2152
|
}
|
|
2114
|
-
|
|
2115
|
-
|
|
2153
|
+
_context15.prev = 35;
|
|
2154
|
+
_context15.next = 38;
|
|
2116
2155
|
return this.drainQueuedServerOrderChanges();
|
|
2117
2156
|
case 38:
|
|
2118
|
-
|
|
2157
|
+
_context15.next = 43;
|
|
2119
2158
|
break;
|
|
2120
2159
|
case 40:
|
|
2121
|
-
|
|
2122
|
-
|
|
2160
|
+
_context15.prev = 40;
|
|
2161
|
+
_context15.t1 = _context15["catch"](35);
|
|
2123
2162
|
this.logError('drain queued server order changes failed', {
|
|
2124
|
-
error:
|
|
2163
|
+
error: _context15.t1 instanceof Error ? _context15.t1.message : String(_context15.t1)
|
|
2125
2164
|
});
|
|
2126
2165
|
case 43:
|
|
2127
|
-
return
|
|
2166
|
+
return _context15.finish(32);
|
|
2128
2167
|
case 44:
|
|
2129
2168
|
case "end":
|
|
2130
|
-
return
|
|
2169
|
+
return _context15.stop();
|
|
2131
2170
|
}
|
|
2132
|
-
},
|
|
2171
|
+
}, _callee15, this, [[4,, 32, 44], [35, 40]]);
|
|
2133
2172
|
}));
|
|
2134
|
-
function loadSalesDetail(
|
|
2173
|
+
function loadSalesDetail(_x13) {
|
|
2135
2174
|
return _loadSalesDetail.apply(this, arguments);
|
|
2136
2175
|
}
|
|
2137
2176
|
return loadSalesDetail;
|
|
@@ -2211,34 +2250,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2211
2250
|
}, {
|
|
2212
2251
|
key: "replaceTempOrder",
|
|
2213
2252
|
value: function () {
|
|
2214
|
-
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2253
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, options) {
|
|
2215
2254
|
var nextTempOrder;
|
|
2216
|
-
return _regeneratorRuntime().wrap(function
|
|
2217
|
-
while (1) switch (
|
|
2255
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
2256
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
2218
2257
|
case 0:
|
|
2219
2258
|
if (this.store.order) {
|
|
2220
|
-
|
|
2259
|
+
_context16.next = 2;
|
|
2221
2260
|
break;
|
|
2222
2261
|
}
|
|
2223
2262
|
throw new Error('order 模块未初始化');
|
|
2224
2263
|
case 2:
|
|
2225
|
-
|
|
2264
|
+
_context16.next = 4;
|
|
2226
2265
|
return this.store.order.replaceTempOrder(tempOrder, options);
|
|
2227
2266
|
case 4:
|
|
2228
|
-
nextTempOrder =
|
|
2229
|
-
|
|
2267
|
+
nextTempOrder = _context16.sent;
|
|
2268
|
+
_context16.next = 7;
|
|
2230
2269
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
2231
2270
|
tempOrder: nextTempOrder
|
|
2232
2271
|
});
|
|
2233
2272
|
case 7:
|
|
2234
|
-
return
|
|
2273
|
+
return _context16.abrupt("return", nextTempOrder);
|
|
2235
2274
|
case 8:
|
|
2236
2275
|
case "end":
|
|
2237
|
-
return
|
|
2276
|
+
return _context16.stop();
|
|
2238
2277
|
}
|
|
2239
|
-
},
|
|
2278
|
+
}, _callee16, this);
|
|
2240
2279
|
}));
|
|
2241
|
-
function replaceTempOrder(
|
|
2280
|
+
function replaceTempOrder(_x14, _x15) {
|
|
2242
2281
|
return _replaceTempOrder.apply(this, arguments);
|
|
2243
2282
|
}
|
|
2244
2283
|
return replaceTempOrder;
|
|
@@ -2294,24 +2333,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2294
2333
|
}, {
|
|
2295
2334
|
key: "setSalesNote",
|
|
2296
2335
|
value: function () {
|
|
2297
|
-
var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2298
|
-
return _regeneratorRuntime().wrap(function
|
|
2299
|
-
while (1) switch (
|
|
2336
|
+
var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(input) {
|
|
2337
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
2338
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
2300
2339
|
case 0:
|
|
2301
2340
|
if (this.store.order) {
|
|
2302
|
-
|
|
2341
|
+
_context17.next = 2;
|
|
2303
2342
|
break;
|
|
2304
2343
|
}
|
|
2305
2344
|
throw new Error('order 模块未初始化');
|
|
2306
2345
|
case 2:
|
|
2307
|
-
return
|
|
2346
|
+
return _context17.abrupt("return", this.store.order.setSalesNote(input));
|
|
2308
2347
|
case 3:
|
|
2309
2348
|
case "end":
|
|
2310
|
-
return
|
|
2349
|
+
return _context17.stop();
|
|
2311
2350
|
}
|
|
2312
|
-
},
|
|
2351
|
+
}, _callee17, this);
|
|
2313
2352
|
}));
|
|
2314
|
-
function setSalesNote(
|
|
2353
|
+
function setSalesNote(_x16) {
|
|
2315
2354
|
return _setSalesNote.apply(this, arguments);
|
|
2316
2355
|
}
|
|
2317
2356
|
return setSalesNote;
|
|
@@ -2319,25 +2358,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2319
2358
|
}, {
|
|
2320
2359
|
key: "removeSalesNote",
|
|
2321
2360
|
value: function () {
|
|
2322
|
-
var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2323
|
-
return _regeneratorRuntime().wrap(function
|
|
2324
|
-
while (1) switch (
|
|
2361
|
+
var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(uuid) {
|
|
2362
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
2363
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
2325
2364
|
case 0:
|
|
2326
2365
|
if (this.store.order) {
|
|
2327
|
-
|
|
2366
|
+
_context18.next = 2;
|
|
2328
2367
|
break;
|
|
2329
2368
|
}
|
|
2330
2369
|
throw new Error('order 模块未初始化');
|
|
2331
2370
|
case 2:
|
|
2332
|
-
|
|
2371
|
+
_context18.next = 4;
|
|
2333
2372
|
return this.store.order.removeSalesNote(uuid);
|
|
2334
2373
|
case 4:
|
|
2335
2374
|
case "end":
|
|
2336
|
-
return
|
|
2375
|
+
return _context18.stop();
|
|
2337
2376
|
}
|
|
2338
|
-
},
|
|
2377
|
+
}, _callee18, this);
|
|
2339
2378
|
}));
|
|
2340
|
-
function removeSalesNote(
|
|
2379
|
+
function removeSalesNote(_x17) {
|
|
2341
2380
|
return _removeSalesNote.apply(this, arguments);
|
|
2342
2381
|
}
|
|
2343
2382
|
return removeSalesNote;
|
|
@@ -2345,23 +2384,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2345
2384
|
}, {
|
|
2346
2385
|
key: "clearSalesNotes",
|
|
2347
2386
|
value: function () {
|
|
2348
|
-
var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2349
|
-
return _regeneratorRuntime().wrap(function
|
|
2350
|
-
while (1) switch (
|
|
2387
|
+
var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
2388
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
2389
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
2351
2390
|
case 0:
|
|
2352
2391
|
if (this.store.order) {
|
|
2353
|
-
|
|
2392
|
+
_context19.next = 2;
|
|
2354
2393
|
break;
|
|
2355
2394
|
}
|
|
2356
2395
|
throw new Error('order 模块未初始化');
|
|
2357
2396
|
case 2:
|
|
2358
|
-
|
|
2397
|
+
_context19.next = 4;
|
|
2359
2398
|
return this.store.order.clearSalesNotes();
|
|
2360
2399
|
case 4:
|
|
2361
2400
|
case "end":
|
|
2362
|
-
return
|
|
2401
|
+
return _context19.stop();
|
|
2363
2402
|
}
|
|
2364
|
-
},
|
|
2403
|
+
}, _callee19, this);
|
|
2365
2404
|
}));
|
|
2366
2405
|
function clearSalesNotes() {
|
|
2367
2406
|
return _clearSalesNotes.apply(this, arguments);
|
|
@@ -2451,40 +2490,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2451
2490
|
}, {
|
|
2452
2491
|
key: "addNewOrder",
|
|
2453
2492
|
value: function () {
|
|
2454
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2493
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
2455
2494
|
var tempOrder;
|
|
2456
|
-
return _regeneratorRuntime().wrap(function
|
|
2457
|
-
while (1) switch (
|
|
2495
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
2496
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
2458
2497
|
case 0:
|
|
2459
|
-
|
|
2498
|
+
_context20.prev = 0;
|
|
2460
2499
|
if (this.store.order) {
|
|
2461
|
-
|
|
2500
|
+
_context20.next = 3;
|
|
2462
2501
|
break;
|
|
2463
2502
|
}
|
|
2464
2503
|
throw new Error('order 模块未初始化');
|
|
2465
2504
|
case 3:
|
|
2466
|
-
|
|
2505
|
+
_context20.next = 5;
|
|
2467
2506
|
return this.store.order.addNewOrder();
|
|
2468
2507
|
case 5:
|
|
2469
|
-
tempOrder =
|
|
2508
|
+
tempOrder = _context20.sent;
|
|
2470
2509
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
2471
|
-
|
|
2510
|
+
_context20.next = 10;
|
|
2472
2511
|
break;
|
|
2473
2512
|
}
|
|
2474
2513
|
this.store.order.persistTempOrder();
|
|
2475
|
-
|
|
2514
|
+
_context20.next = 10;
|
|
2476
2515
|
return this.store.order.saveDraft();
|
|
2477
2516
|
case 10:
|
|
2478
|
-
return
|
|
2517
|
+
return _context20.abrupt("return", tempOrder);
|
|
2479
2518
|
case 13:
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
throw
|
|
2519
|
+
_context20.prev = 13;
|
|
2520
|
+
_context20.t0 = _context20["catch"](0);
|
|
2521
|
+
throw _context20.t0;
|
|
2483
2522
|
case 16:
|
|
2484
2523
|
case "end":
|
|
2485
|
-
return
|
|
2524
|
+
return _context20.stop();
|
|
2486
2525
|
}
|
|
2487
|
-
},
|
|
2526
|
+
}, _callee20, this, [[0, 13]]);
|
|
2488
2527
|
}));
|
|
2489
2528
|
function addNewOrder() {
|
|
2490
2529
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -2494,22 +2533,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2494
2533
|
}, {
|
|
2495
2534
|
key: "saveDraft",
|
|
2496
2535
|
value: function () {
|
|
2497
|
-
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2498
|
-
return _regeneratorRuntime().wrap(function
|
|
2499
|
-
while (1) switch (
|
|
2536
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
2537
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2538
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
2500
2539
|
case 0:
|
|
2501
2540
|
if (this.store.order) {
|
|
2502
|
-
|
|
2541
|
+
_context21.next = 2;
|
|
2503
2542
|
break;
|
|
2504
2543
|
}
|
|
2505
2544
|
throw new Error('order 模块未初始化');
|
|
2506
2545
|
case 2:
|
|
2507
|
-
return
|
|
2546
|
+
return _context21.abrupt("return", this.store.order.saveDraft());
|
|
2508
2547
|
case 3:
|
|
2509
2548
|
case "end":
|
|
2510
|
-
return
|
|
2549
|
+
return _context21.stop();
|
|
2511
2550
|
}
|
|
2512
|
-
},
|
|
2551
|
+
}, _callee21, this);
|
|
2513
2552
|
}));
|
|
2514
2553
|
function saveDraft() {
|
|
2515
2554
|
return _saveDraft.apply(this, arguments);
|
|
@@ -2520,14 +2559,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2520
2559
|
}, {
|
|
2521
2560
|
key: "restoreOrder",
|
|
2522
2561
|
value: function () {
|
|
2523
|
-
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2562
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
2524
2563
|
var _this$store$payment, tempOrder, appDataChanged, wallet;
|
|
2525
|
-
return _regeneratorRuntime().wrap(function
|
|
2526
|
-
while (1) switch (
|
|
2564
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2565
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
2527
2566
|
case 0:
|
|
2528
|
-
|
|
2567
|
+
_context22.prev = 0;
|
|
2529
2568
|
if (this.store.order) {
|
|
2530
|
-
|
|
2569
|
+
_context22.next = 3;
|
|
2531
2570
|
break;
|
|
2532
2571
|
}
|
|
2533
2572
|
throw new Error('scanOrder 解决方案需要 order 模块支持');
|
|
@@ -2540,37 +2579,37 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2540
2579
|
this.hasManualDiscountSelection = false;
|
|
2541
2580
|
wallet = (_this$store$payment = this.store.payment) === null || _this$store$payment === void 0 ? void 0 : _this$store$payment.wallet;
|
|
2542
2581
|
if (!wallet) {
|
|
2543
|
-
|
|
2582
|
+
_context22.next = 14;
|
|
2544
2583
|
break;
|
|
2545
2584
|
}
|
|
2546
2585
|
this.walletAssetsRefreshSequence += 1;
|
|
2547
2586
|
wallet.clearAllCache();
|
|
2548
|
-
|
|
2587
|
+
_context22.next = 14;
|
|
2549
2588
|
return this.publishWalletAssetsState(wallet.getWalletAssetsState());
|
|
2550
2589
|
case 14:
|
|
2551
|
-
|
|
2590
|
+
_context22.next = 16;
|
|
2552
2591
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
2553
2592
|
tempOrder: tempOrder
|
|
2554
2593
|
});
|
|
2555
2594
|
case 16:
|
|
2556
2595
|
if (!(appDataChanged && this.isTempOrderPersistEnabled())) {
|
|
2557
|
-
|
|
2596
|
+
_context22.next = 20;
|
|
2558
2597
|
break;
|
|
2559
2598
|
}
|
|
2560
2599
|
this.store.order.persistTempOrder();
|
|
2561
|
-
|
|
2600
|
+
_context22.next = 20;
|
|
2562
2601
|
return this.store.order.saveDraft();
|
|
2563
2602
|
case 20:
|
|
2564
|
-
return
|
|
2603
|
+
return _context22.abrupt("return", tempOrder);
|
|
2565
2604
|
case 23:
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
throw
|
|
2605
|
+
_context22.prev = 23;
|
|
2606
|
+
_context22.t0 = _context22["catch"](0);
|
|
2607
|
+
throw _context22.t0;
|
|
2569
2608
|
case 26:
|
|
2570
2609
|
case "end":
|
|
2571
|
-
return
|
|
2610
|
+
return _context22.stop();
|
|
2572
2611
|
}
|
|
2573
|
-
},
|
|
2612
|
+
}, _callee22, this, [[0, 23]]);
|
|
2574
2613
|
}));
|
|
2575
2614
|
function restoreOrder() {
|
|
2576
2615
|
return _restoreOrder.apply(this, arguments);
|
|
@@ -2584,22 +2623,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2584
2623
|
}, {
|
|
2585
2624
|
key: "clearOrderCartLines",
|
|
2586
2625
|
value: (function () {
|
|
2587
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2626
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
2588
2627
|
var tempOrder;
|
|
2589
|
-
return _regeneratorRuntime().wrap(function
|
|
2590
|
-
while (1) switch (
|
|
2628
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2629
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2591
2630
|
case 0:
|
|
2592
|
-
|
|
2631
|
+
_context23.prev = 0;
|
|
2593
2632
|
if (this.store.order) {
|
|
2594
|
-
|
|
2633
|
+
_context23.next = 3;
|
|
2595
2634
|
break;
|
|
2596
2635
|
}
|
|
2597
2636
|
throw new Error('order 模块未初始化');
|
|
2598
2637
|
case 3:
|
|
2599
|
-
|
|
2638
|
+
_context23.next = 5;
|
|
2600
2639
|
return this.store.order.clearOrderCartLines();
|
|
2601
2640
|
case 5:
|
|
2602
|
-
tempOrder =
|
|
2641
|
+
tempOrder = _context23.sent;
|
|
2603
2642
|
if (this.currentSalesDetail) {
|
|
2604
2643
|
this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
|
|
2605
2644
|
products: [],
|
|
@@ -2609,29 +2648,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2609
2648
|
discount_list: []
|
|
2610
2649
|
});
|
|
2611
2650
|
}
|
|
2612
|
-
|
|
2651
|
+
_context23.next = 9;
|
|
2613
2652
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
2614
2653
|
tempOrder: tempOrder
|
|
2615
2654
|
});
|
|
2616
2655
|
case 9:
|
|
2617
2656
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
2618
|
-
|
|
2657
|
+
_context23.next = 13;
|
|
2619
2658
|
break;
|
|
2620
2659
|
}
|
|
2621
2660
|
this.store.order.persistTempOrder();
|
|
2622
|
-
|
|
2661
|
+
_context23.next = 13;
|
|
2623
2662
|
return this.store.order.saveDraft();
|
|
2624
2663
|
case 13:
|
|
2625
|
-
return
|
|
2664
|
+
return _context23.abrupt("return", tempOrder);
|
|
2626
2665
|
case 16:
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
throw
|
|
2666
|
+
_context23.prev = 16;
|
|
2667
|
+
_context23.t0 = _context23["catch"](0);
|
|
2668
|
+
throw _context23.t0;
|
|
2630
2669
|
case 19:
|
|
2631
2670
|
case "end":
|
|
2632
|
-
return
|
|
2671
|
+
return _context23.stop();
|
|
2633
2672
|
}
|
|
2634
|
-
},
|
|
2673
|
+
}, _callee23, this, [[0, 16]]);
|
|
2635
2674
|
}));
|
|
2636
2675
|
function clearOrderCartLines() {
|
|
2637
2676
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -2641,21 +2680,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2641
2680
|
}, {
|
|
2642
2681
|
key: "clearOrderForSettlementSwitch",
|
|
2643
2682
|
value: (function () {
|
|
2644
|
-
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2683
|
+
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
2645
2684
|
var tempOrder;
|
|
2646
|
-
return _regeneratorRuntime().wrap(function
|
|
2647
|
-
while (1) switch (
|
|
2685
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2686
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2648
2687
|
case 0:
|
|
2649
2688
|
if (this.store.order) {
|
|
2650
|
-
|
|
2689
|
+
_context24.next = 2;
|
|
2651
2690
|
break;
|
|
2652
2691
|
}
|
|
2653
2692
|
throw new Error('order 模块未初始化');
|
|
2654
2693
|
case 2:
|
|
2655
|
-
|
|
2694
|
+
_context24.next = 4;
|
|
2656
2695
|
return this.store.order.clearOrderForSettlementSwitch();
|
|
2657
2696
|
case 4:
|
|
2658
|
-
tempOrder =
|
|
2697
|
+
tempOrder = _context24.sent;
|
|
2659
2698
|
if (this.currentSalesDetail) {
|
|
2660
2699
|
this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
|
|
2661
2700
|
products: [],
|
|
@@ -2666,12 +2705,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2666
2705
|
payments: []
|
|
2667
2706
|
});
|
|
2668
2707
|
}
|
|
2669
|
-
return
|
|
2708
|
+
return _context24.abrupt("return", tempOrder);
|
|
2670
2709
|
case 7:
|
|
2671
2710
|
case "end":
|
|
2672
|
-
return
|
|
2711
|
+
return _context24.stop();
|
|
2673
2712
|
}
|
|
2674
|
-
},
|
|
2713
|
+
}, _callee24, this);
|
|
2675
2714
|
}));
|
|
2676
2715
|
function clearOrderForSettlementSwitch() {
|
|
2677
2716
|
return _clearOrderForSettlementSwitch.apply(this, arguments);
|
|
@@ -2688,32 +2727,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2688
2727
|
}, {
|
|
2689
2728
|
key: "getSummary",
|
|
2690
2729
|
value: function () {
|
|
2691
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2730
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
2692
2731
|
var summary;
|
|
2693
|
-
return _regeneratorRuntime().wrap(function
|
|
2694
|
-
while (1) switch (
|
|
2732
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2733
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2695
2734
|
case 0:
|
|
2696
|
-
|
|
2735
|
+
_context25.prev = 0;
|
|
2697
2736
|
if (this.store.order) {
|
|
2698
|
-
|
|
2737
|
+
_context25.next = 3;
|
|
2699
2738
|
break;
|
|
2700
2739
|
}
|
|
2701
2740
|
throw new Error('order 模块未初始化');
|
|
2702
2741
|
case 3:
|
|
2703
|
-
|
|
2742
|
+
_context25.next = 5;
|
|
2704
2743
|
return this.store.order.getOrderSummary();
|
|
2705
2744
|
case 5:
|
|
2706
|
-
summary =
|
|
2707
|
-
return
|
|
2745
|
+
summary = _context25.sent;
|
|
2746
|
+
return _context25.abrupt("return", summary);
|
|
2708
2747
|
case 9:
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
throw
|
|
2748
|
+
_context25.prev = 9;
|
|
2749
|
+
_context25.t0 = _context25["catch"](0);
|
|
2750
|
+
throw _context25.t0;
|
|
2712
2751
|
case 12:
|
|
2713
2752
|
case "end":
|
|
2714
|
-
return
|
|
2753
|
+
return _context25.stop();
|
|
2715
2754
|
}
|
|
2716
|
-
},
|
|
2755
|
+
}, _callee25, this, [[0, 9]]);
|
|
2717
2756
|
}));
|
|
2718
2757
|
function getSummary() {
|
|
2719
2758
|
return _getSummary.apply(this, arguments);
|
|
@@ -2723,10 +2762,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2723
2762
|
}, {
|
|
2724
2763
|
key: "getHistoricalProductDiscountList",
|
|
2725
2764
|
value: function getHistoricalProductDiscountList(products) {
|
|
2726
|
-
var
|
|
2765
|
+
var _this14 = this;
|
|
2727
2766
|
var historyDiscountList = [];
|
|
2728
2767
|
products.forEach(function (item) {
|
|
2729
|
-
if (!
|
|
2768
|
+
if (!_this14.isPersistedOrderProduct(item)) return;
|
|
2730
2769
|
(item.discount_list || []).forEach(function (discount) {
|
|
2731
2770
|
var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
|
|
2732
2771
|
var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
|
|
@@ -2786,11 +2825,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2786
2825
|
}, {
|
|
2787
2826
|
key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
|
|
2788
2827
|
value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
|
|
2789
|
-
var
|
|
2828
|
+
var _this15 = this;
|
|
2790
2829
|
if (params.discountAction !== 'edit') return false;
|
|
2791
2830
|
if (!params.products.length) return false;
|
|
2792
2831
|
var hasDraftProduct = params.products.some(function (product) {
|
|
2793
|
-
return !
|
|
2832
|
+
return !_this15.isPersistedOrderProduct(product);
|
|
2794
2833
|
});
|
|
2795
2834
|
if (hasDraftProduct) return false;
|
|
2796
2835
|
|
|
@@ -2841,14 +2880,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2841
2880
|
}, {
|
|
2842
2881
|
key: "loadDiscountConfig",
|
|
2843
2882
|
value: function () {
|
|
2844
|
-
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2883
|
+
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
2845
2884
|
var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
|
|
2846
2885
|
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, searchedDiscountList, searchedDiscountIds, preparedDiscountList, _discountModule$setOr, _discountModule$setOr2, _discountModule$setDi, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _orderStore$summary, orderTotalAmount, result, _iterator3, _step3, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
|
|
2847
|
-
return _regeneratorRuntime().wrap(function
|
|
2848
|
-
while (1) switch (
|
|
2886
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2887
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2849
2888
|
case 0:
|
|
2850
2889
|
if (this.store.order) {
|
|
2851
|
-
|
|
2890
|
+
_context26.next = 2;
|
|
2852
2891
|
break;
|
|
2853
2892
|
}
|
|
2854
2893
|
throw new Error('order 模块未初始化');
|
|
@@ -2877,18 +2916,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2877
2916
|
return !searchedDiscountIds.has(String(discount.id));
|
|
2878
2917
|
})));
|
|
2879
2918
|
if (!(customerId && customerId !== 1)) {
|
|
2880
|
-
|
|
2919
|
+
_context26.next = 27;
|
|
2881
2920
|
break;
|
|
2882
2921
|
}
|
|
2883
2922
|
if (!(!(params !== null && params !== void 0 && params.force) && this.discountConfigCacheKey === discountConfigCacheKey)) {
|
|
2884
|
-
|
|
2923
|
+
_context26.next = 21;
|
|
2885
2924
|
break;
|
|
2886
2925
|
}
|
|
2887
2926
|
preparedDiscountList = originalDiscountList;
|
|
2888
|
-
|
|
2927
|
+
_context26.next = 27;
|
|
2889
2928
|
break;
|
|
2890
2929
|
case 21:
|
|
2891
|
-
|
|
2930
|
+
_context26.next = 23;
|
|
2892
2931
|
return this.store.order.loadDiscountConfig({
|
|
2893
2932
|
customerId: customerId,
|
|
2894
2933
|
action: discountAction,
|
|
@@ -2896,24 +2935,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2896
2935
|
apply: false
|
|
2897
2936
|
});
|
|
2898
2937
|
case 23:
|
|
2899
|
-
preparedDiscountList =
|
|
2938
|
+
preparedDiscountList = _context26.sent;
|
|
2900
2939
|
this.discountConfigCacheKey = discountConfigCacheKey;
|
|
2901
|
-
|
|
2940
|
+
_context26.next = 27;
|
|
2902
2941
|
return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
|
|
2903
2942
|
case 27:
|
|
2904
2943
|
if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
2905
|
-
|
|
2944
|
+
_context26.next = 35;
|
|
2906
2945
|
break;
|
|
2907
2946
|
}
|
|
2908
|
-
|
|
2947
|
+
_context26.next = 30;
|
|
2909
2948
|
return discountModule === null || discountModule === void 0 || (_discountModule$setOr2 = discountModule.setOriginalDiscountList) === null || _discountModule$setOr2 === void 0 ? void 0 : _discountModule$setOr2.call(discountModule, []);
|
|
2910
2949
|
case 30:
|
|
2911
|
-
|
|
2950
|
+
_context26.next = 32;
|
|
2912
2951
|
return discountModule === null || discountModule === void 0 || (_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, []);
|
|
2913
2952
|
case 32:
|
|
2914
2953
|
tempOrder.discount_list = [];
|
|
2915
2954
|
tempOrder.shop_discount = '0.00';
|
|
2916
|
-
return
|
|
2955
|
+
return _context26.abrupt("return", {
|
|
2917
2956
|
productList: tempOrder.products || [],
|
|
2918
2957
|
discountList: [],
|
|
2919
2958
|
availableWalletIds: this.getAvailableWalletIds(),
|
|
@@ -2921,10 +2960,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2921
2960
|
});
|
|
2922
2961
|
case 35:
|
|
2923
2962
|
if (!(hasManualDiscountSelection && currentDiscountList.length)) {
|
|
2924
|
-
|
|
2963
|
+
_context26.next = 37;
|
|
2925
2964
|
break;
|
|
2926
2965
|
}
|
|
2927
|
-
return
|
|
2966
|
+
return _context26.abrupt("return", {
|
|
2928
2967
|
productList: tempOrder.products || [],
|
|
2929
2968
|
discountList: currentDiscountList,
|
|
2930
2969
|
availableWalletIds: this.getAvailableWalletIds(),
|
|
@@ -2933,7 +2972,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2933
2972
|
case 37:
|
|
2934
2973
|
nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$getDi2 = discountModule.getDiscountList) === null || _discountModule$getDi2 === void 0 ? void 0 : _discountModule$getDi2.call(discountModule)) || [], tempOrder.products || []);
|
|
2935
2974
|
nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
|
|
2936
|
-
|
|
2975
|
+
_context26.next = 41;
|
|
2937
2976
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2938
2977
|
case 41:
|
|
2939
2978
|
shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
|
|
@@ -2943,17 +2982,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2943
2982
|
nextDiscountList: nextDiscountList
|
|
2944
2983
|
});
|
|
2945
2984
|
if (!shouldSkipAutoApplyFetchedDiscounts) {
|
|
2946
|
-
|
|
2985
|
+
_context26.next = 50;
|
|
2947
2986
|
break;
|
|
2948
2987
|
}
|
|
2949
|
-
|
|
2988
|
+
_context26.next = 45;
|
|
2950
2989
|
return this.store.order.recalculateSummary({
|
|
2951
2990
|
createIfMissing: true
|
|
2952
2991
|
});
|
|
2953
2992
|
case 45:
|
|
2954
|
-
_summary =
|
|
2993
|
+
_summary = _context26.sent;
|
|
2955
2994
|
this.store.order.persistTempOrder();
|
|
2956
|
-
|
|
2995
|
+
_context26.next = 49;
|
|
2957
2996
|
return this.effectsEmit('onDiscountApplied', {
|
|
2958
2997
|
productList: tempOrder.products || [],
|
|
2959
2998
|
discountList: nextDiscountList,
|
|
@@ -2961,7 +3000,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2961
3000
|
tempOrder: tempOrder
|
|
2962
3001
|
});
|
|
2963
3002
|
case 49:
|
|
2964
|
-
return
|
|
3003
|
+
return _context26.abrupt("return", {
|
|
2965
3004
|
productList: tempOrder.products || [],
|
|
2966
3005
|
discountList: nextDiscountList,
|
|
2967
3006
|
availableWalletIds: this.getAvailableWalletIds(),
|
|
@@ -2969,7 +3008,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2969
3008
|
});
|
|
2970
3009
|
case 50:
|
|
2971
3010
|
if (!rulesModule) {
|
|
2972
|
-
|
|
3011
|
+
_context26.next = 86;
|
|
2973
3012
|
break;
|
|
2974
3013
|
}
|
|
2975
3014
|
orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
|
|
@@ -2989,21 +3028,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2989
3028
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2990
3029
|
}
|
|
2991
3030
|
_iterator3 = _createForOfIteratorHelper(tempOrder.products || []);
|
|
2992
|
-
|
|
3031
|
+
_context26.prev = 55;
|
|
2993
3032
|
_iterator3.s();
|
|
2994
3033
|
case 57:
|
|
2995
3034
|
if ((_step3 = _iterator3.n()).done) {
|
|
2996
|
-
|
|
3035
|
+
_context26.next = 72;
|
|
2997
3036
|
break;
|
|
2998
3037
|
}
|
|
2999
3038
|
product = _step3.value;
|
|
3000
3039
|
productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
|
|
3001
3040
|
runtimeOrigin = productUid ? (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[productUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin : undefined;
|
|
3002
3041
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
3003
|
-
|
|
3042
|
+
_context26.next = 63;
|
|
3004
3043
|
break;
|
|
3005
3044
|
}
|
|
3006
|
-
return
|
|
3045
|
+
return _context26.abrupt("continue", 70);
|
|
3007
3046
|
case 63:
|
|
3008
3047
|
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
3009
3048
|
return sum + Number(pd.amount || 0);
|
|
@@ -3021,41 +3060,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3021
3060
|
bundle: product.product_bundle
|
|
3022
3061
|
});
|
|
3023
3062
|
case 70:
|
|
3024
|
-
|
|
3063
|
+
_context26.next = 57;
|
|
3025
3064
|
break;
|
|
3026
3065
|
case 72:
|
|
3027
|
-
|
|
3066
|
+
_context26.next = 77;
|
|
3028
3067
|
break;
|
|
3029
3068
|
case 74:
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
_iterator3.e(
|
|
3069
|
+
_context26.prev = 74;
|
|
3070
|
+
_context26.t0 = _context26["catch"](55);
|
|
3071
|
+
_iterator3.e(_context26.t0);
|
|
3033
3072
|
case 77:
|
|
3034
|
-
|
|
3073
|
+
_context26.prev = 77;
|
|
3035
3074
|
_iterator3.f();
|
|
3036
|
-
return
|
|
3075
|
+
return _context26.finish(77);
|
|
3037
3076
|
case 80:
|
|
3038
3077
|
if (!result.discountList) {
|
|
3039
|
-
|
|
3078
|
+
_context26.next = 86;
|
|
3040
3079
|
break;
|
|
3041
3080
|
}
|
|
3042
3081
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
3043
3082
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
3044
|
-
|
|
3083
|
+
_context26.next = 85;
|
|
3045
3084
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
3046
3085
|
case 85:
|
|
3047
3086
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
3048
3087
|
return discount.isSelected;
|
|
3049
3088
|
});
|
|
3050
3089
|
case 86:
|
|
3051
|
-
|
|
3090
|
+
_context26.next = 88;
|
|
3052
3091
|
return this.store.order.recalculateSummary({
|
|
3053
3092
|
createIfMissing: true
|
|
3054
3093
|
});
|
|
3055
3094
|
case 88:
|
|
3056
|
-
summary =
|
|
3095
|
+
summary = _context26.sent;
|
|
3057
3096
|
this.store.order.persistTempOrder();
|
|
3058
|
-
|
|
3097
|
+
_context26.next = 92;
|
|
3059
3098
|
return this.effectsEmit('onDiscountApplied', {
|
|
3060
3099
|
productList: tempOrder.products || [],
|
|
3061
3100
|
discountList: nextDiscountList,
|
|
@@ -3063,7 +3102,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3063
3102
|
tempOrder: tempOrder
|
|
3064
3103
|
});
|
|
3065
3104
|
case 92:
|
|
3066
|
-
return
|
|
3105
|
+
return _context26.abrupt("return", {
|
|
3067
3106
|
productList: tempOrder.products || [],
|
|
3068
3107
|
discountList: nextDiscountList,
|
|
3069
3108
|
availableWalletIds: this.getAvailableWalletIds(),
|
|
@@ -3071,11 +3110,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3071
3110
|
});
|
|
3072
3111
|
case 93:
|
|
3073
3112
|
case "end":
|
|
3074
|
-
return
|
|
3113
|
+
return _context26.stop();
|
|
3075
3114
|
}
|
|
3076
|
-
},
|
|
3115
|
+
}, _callee26, this, [[55, 74, 77, 80]]);
|
|
3077
3116
|
}));
|
|
3078
|
-
function loadDiscountConfig(
|
|
3117
|
+
function loadDiscountConfig(_x18) {
|
|
3079
3118
|
return _loadDiscountConfig.apply(this, arguments);
|
|
3080
3119
|
}
|
|
3081
3120
|
return loadDiscountConfig;
|
|
@@ -3097,21 +3136,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3097
3136
|
}, {
|
|
3098
3137
|
key: "bestDiscount",
|
|
3099
3138
|
value: function () {
|
|
3100
|
-
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3139
|
+
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(cb) {
|
|
3101
3140
|
var _discountModule$getOr2, _discountModule$getDi3;
|
|
3102
3141
|
var tempOrder, _result2, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
|
|
3103
|
-
return _regeneratorRuntime().wrap(function
|
|
3104
|
-
while (1) switch (
|
|
3142
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
3143
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
3105
3144
|
case 0:
|
|
3106
3145
|
if (this.store.order) {
|
|
3107
|
-
|
|
3146
|
+
_context27.next = 2;
|
|
3108
3147
|
break;
|
|
3109
3148
|
}
|
|
3110
3149
|
throw new Error('order 模块未初始化');
|
|
3111
3150
|
case 2:
|
|
3112
3151
|
tempOrder = this.store.order.ensureTempOrder();
|
|
3113
3152
|
if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
3114
|
-
|
|
3153
|
+
_context27.next = 7;
|
|
3115
3154
|
break;
|
|
3116
3155
|
}
|
|
3117
3156
|
_result2 = {
|
|
@@ -3119,7 +3158,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3119
3158
|
discountList: []
|
|
3120
3159
|
};
|
|
3121
3160
|
cb === null || cb === void 0 || cb(_result2);
|
|
3122
|
-
return
|
|
3161
|
+
return _context27.abrupt("return", _result2);
|
|
3123
3162
|
case 7:
|
|
3124
3163
|
orderStore = this.store.order.store || {};
|
|
3125
3164
|
discountModule = orderStore.discount;
|
|
@@ -3131,11 +3170,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3131
3170
|
productList: tempOrder.products || [],
|
|
3132
3171
|
discountList: nextDiscountList
|
|
3133
3172
|
};
|
|
3134
|
-
|
|
3173
|
+
_context27.next = 16;
|
|
3135
3174
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
3136
3175
|
case 16:
|
|
3137
3176
|
if (!rulesModule) {
|
|
3138
|
-
|
|
3177
|
+
_context27.next = 27;
|
|
3139
3178
|
break;
|
|
3140
3179
|
}
|
|
3141
3180
|
orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
|
|
@@ -3152,12 +3191,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3152
3191
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
3153
3192
|
}
|
|
3154
3193
|
if (!result.discountList) {
|
|
3155
|
-
|
|
3194
|
+
_context27.next = 27;
|
|
3156
3195
|
break;
|
|
3157
3196
|
}
|
|
3158
3197
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
3159
3198
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
3160
|
-
|
|
3199
|
+
_context27.next = 25;
|
|
3161
3200
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
3162
3201
|
case 25:
|
|
3163
3202
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
@@ -3168,13 +3207,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3168
3207
|
discountList: nextDiscountList
|
|
3169
3208
|
};
|
|
3170
3209
|
case 27:
|
|
3171
|
-
|
|
3210
|
+
_context27.next = 29;
|
|
3172
3211
|
return this.store.order.recalculateSummary({
|
|
3173
3212
|
createIfMissing: true
|
|
3174
3213
|
});
|
|
3175
3214
|
case 29:
|
|
3176
3215
|
this.store.order.persistTempOrder();
|
|
3177
|
-
|
|
3216
|
+
_context27.next = 32;
|
|
3178
3217
|
return this.effectsEmit('onDiscountApplied', {
|
|
3179
3218
|
productList: tempOrder.products || [],
|
|
3180
3219
|
discountList: nextDiscountList,
|
|
@@ -3183,14 +3222,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3183
3222
|
});
|
|
3184
3223
|
case 32:
|
|
3185
3224
|
cb === null || cb === void 0 || cb(result);
|
|
3186
|
-
return
|
|
3225
|
+
return _context27.abrupt("return", result);
|
|
3187
3226
|
case 34:
|
|
3188
3227
|
case "end":
|
|
3189
|
-
return
|
|
3228
|
+
return _context27.stop();
|
|
3190
3229
|
}
|
|
3191
|
-
},
|
|
3230
|
+
}, _callee27, this);
|
|
3192
3231
|
}));
|
|
3193
|
-
function bestDiscount(
|
|
3232
|
+
function bestDiscount(_x19) {
|
|
3194
3233
|
return _bestDiscount.apply(this, arguments);
|
|
3195
3234
|
}
|
|
3196
3235
|
return bestDiscount;
|
|
@@ -3219,41 +3258,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3219
3258
|
}, {
|
|
3220
3259
|
key: "replaceDiscountStoreLists",
|
|
3221
3260
|
value: (function () {
|
|
3222
|
-
var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3261
|
+
var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
3223
3262
|
var _store2;
|
|
3224
3263
|
var discountModule;
|
|
3225
|
-
return _regeneratorRuntime().wrap(function
|
|
3226
|
-
while (1) switch (
|
|
3264
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
3265
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
3227
3266
|
case 0:
|
|
3228
3267
|
if (this.store.order) {
|
|
3229
|
-
|
|
3268
|
+
_context28.next = 2;
|
|
3230
3269
|
break;
|
|
3231
3270
|
}
|
|
3232
3271
|
throw new Error('order 模块未初始化');
|
|
3233
3272
|
case 2:
|
|
3234
3273
|
discountModule = (_store2 = this.store.order.store) === null || _store2 === void 0 ? void 0 : _store2.discount;
|
|
3235
3274
|
if (discountModule) {
|
|
3236
|
-
|
|
3275
|
+
_context28.next = 5;
|
|
3237
3276
|
break;
|
|
3238
3277
|
}
|
|
3239
|
-
return
|
|
3278
|
+
return _context28.abrupt("return");
|
|
3240
3279
|
case 5:
|
|
3241
3280
|
if (!params.originalDiscountList) {
|
|
3242
|
-
|
|
3281
|
+
_context28.next = 8;
|
|
3243
3282
|
break;
|
|
3244
3283
|
}
|
|
3245
|
-
|
|
3284
|
+
_context28.next = 8;
|
|
3246
3285
|
return discountModule.setOriginalDiscountList(params.originalDiscountList);
|
|
3247
3286
|
case 8:
|
|
3248
|
-
|
|
3287
|
+
_context28.next = 10;
|
|
3249
3288
|
return discountModule.setDiscountList(params.discountList);
|
|
3250
3289
|
case 10:
|
|
3251
3290
|
case "end":
|
|
3252
|
-
return
|
|
3291
|
+
return _context28.stop();
|
|
3253
3292
|
}
|
|
3254
|
-
},
|
|
3293
|
+
}, _callee28, this);
|
|
3255
3294
|
}));
|
|
3256
|
-
function replaceDiscountStoreLists(
|
|
3295
|
+
function replaceDiscountStoreLists(_x20) {
|
|
3257
3296
|
return _replaceDiscountStoreLists.apply(this, arguments);
|
|
3258
3297
|
}
|
|
3259
3298
|
return replaceDiscountStoreLists;
|
|
@@ -3261,34 +3300,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3261
3300
|
}, {
|
|
3262
3301
|
key: "scanPromotionCode",
|
|
3263
3302
|
value: function () {
|
|
3264
|
-
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3303
|
+
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(code, customerId) {
|
|
3265
3304
|
var raw, tempOrder;
|
|
3266
|
-
return _regeneratorRuntime().wrap(function
|
|
3267
|
-
while (1) switch (
|
|
3305
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
3306
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
3268
3307
|
case 0:
|
|
3269
|
-
|
|
3308
|
+
_context29.prev = 0;
|
|
3270
3309
|
if (this.store.order) {
|
|
3271
|
-
|
|
3310
|
+
_context29.next = 3;
|
|
3272
3311
|
break;
|
|
3273
3312
|
}
|
|
3274
3313
|
throw new Error('order 模块未初始化');
|
|
3275
3314
|
case 3:
|
|
3276
|
-
|
|
3315
|
+
_context29.next = 5;
|
|
3277
3316
|
return this.store.order.scanCode(code, customerId);
|
|
3278
3317
|
case 5:
|
|
3279
|
-
raw =
|
|
3318
|
+
raw = _context29.sent;
|
|
3280
3319
|
if (!raw.isAvailable) {
|
|
3281
|
-
|
|
3320
|
+
_context29.next = 13;
|
|
3282
3321
|
break;
|
|
3283
3322
|
}
|
|
3284
|
-
|
|
3323
|
+
_context29.next = 9;
|
|
3285
3324
|
return this.store.order.recalculateSummary({
|
|
3286
3325
|
createIfMissing: true
|
|
3287
3326
|
});
|
|
3288
3327
|
case 9:
|
|
3289
3328
|
this.store.order.persistTempOrder();
|
|
3290
3329
|
tempOrder = this.store.order.ensureTempOrder();
|
|
3291
|
-
|
|
3330
|
+
_context29.next = 13;
|
|
3292
3331
|
return this.effectsEmit('onDiscountApplied', {
|
|
3293
3332
|
productList: tempOrder.products || [],
|
|
3294
3333
|
discountList: this.store.order.getDiscountList(),
|
|
@@ -3296,7 +3335,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3296
3335
|
tempOrder: tempOrder
|
|
3297
3336
|
});
|
|
3298
3337
|
case 13:
|
|
3299
|
-
return
|
|
3338
|
+
return _context29.abrupt("return", _objectSpread(_objectSpread({
|
|
3300
3339
|
isAvailable: raw.isAvailable
|
|
3301
3340
|
}, raw.isAccepted !== undefined ? {
|
|
3302
3341
|
isAccepted: raw.isAccepted
|
|
@@ -3306,16 +3345,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3306
3345
|
scannedDiscountList: raw.scannedDiscountList
|
|
3307
3346
|
}));
|
|
3308
3347
|
case 16:
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
throw
|
|
3348
|
+
_context29.prev = 16;
|
|
3349
|
+
_context29.t0 = _context29["catch"](0);
|
|
3350
|
+
throw _context29.t0;
|
|
3312
3351
|
case 19:
|
|
3313
3352
|
case "end":
|
|
3314
|
-
return
|
|
3353
|
+
return _context29.stop();
|
|
3315
3354
|
}
|
|
3316
|
-
},
|
|
3355
|
+
}, _callee29, this, [[0, 16]]);
|
|
3317
3356
|
}));
|
|
3318
|
-
function scanPromotionCode(
|
|
3357
|
+
function scanPromotionCode(_x21, _x22) {
|
|
3319
3358
|
return _scanPromotionCode.apply(this, arguments);
|
|
3320
3359
|
}
|
|
3321
3360
|
return scanPromotionCode;
|
|
@@ -3323,35 +3362,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3323
3362
|
}, {
|
|
3324
3363
|
key: "setDiscountSelected",
|
|
3325
3364
|
value: function () {
|
|
3326
|
-
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3365
|
+
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
3327
3366
|
var currentOrder, _store3, _store3$setDiscountLi, list, updated, tempOrder, orderStore, discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator4, _step4, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator5, _step5, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
3328
|
-
return _regeneratorRuntime().wrap(function
|
|
3329
|
-
while (1) switch (
|
|
3367
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
3368
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
3330
3369
|
case 0:
|
|
3331
|
-
|
|
3370
|
+
_context30.prev = 0;
|
|
3332
3371
|
if (this.store.order) {
|
|
3333
|
-
|
|
3372
|
+
_context30.next = 3;
|
|
3334
3373
|
break;
|
|
3335
3374
|
}
|
|
3336
3375
|
throw new Error('order 模块未初始化');
|
|
3337
3376
|
case 3:
|
|
3338
3377
|
currentOrder = this.store.order.ensureTempOrder();
|
|
3339
3378
|
if (!this.isActiveVirtualSettlementOrder(currentOrder)) {
|
|
3340
|
-
|
|
3379
|
+
_context30.next = 13;
|
|
3341
3380
|
break;
|
|
3342
3381
|
}
|
|
3343
3382
|
currentOrder.discount_list = [];
|
|
3344
3383
|
currentOrder.shop_discount = '0.00';
|
|
3345
|
-
|
|
3384
|
+
_context30.next = 9;
|
|
3346
3385
|
return (_store3 = this.store.order.store) === null || _store3 === void 0 || (_store3 = _store3.discount) === null || _store3 === void 0 || (_store3$setDiscountLi = _store3.setDiscountList) === null || _store3$setDiscountLi === void 0 ? void 0 : _store3$setDiscountLi.call(_store3, []);
|
|
3347
3386
|
case 9:
|
|
3348
|
-
|
|
3387
|
+
_context30.next = 11;
|
|
3349
3388
|
return this.store.order.recalculateSummary({
|
|
3350
3389
|
createIfMissing: true
|
|
3351
3390
|
});
|
|
3352
3391
|
case 11:
|
|
3353
3392
|
this.store.order.persistTempOrder();
|
|
3354
|
-
return
|
|
3393
|
+
return _context30.abrupt("return");
|
|
3355
3394
|
case 13:
|
|
3356
3395
|
list = this.store.order.getDiscountList();
|
|
3357
3396
|
updated = list.map(function (d) {
|
|
@@ -3366,7 +3405,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3366
3405
|
discountModule = orderStore.discount;
|
|
3367
3406
|
rulesModule = orderStore.rules;
|
|
3368
3407
|
nextDiscountList = updated;
|
|
3369
|
-
|
|
3408
|
+
_context30.next = 23;
|
|
3370
3409
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
3371
3410
|
case 23:
|
|
3372
3411
|
if (rulesModule) {
|
|
@@ -3428,29 +3467,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3428
3467
|
});
|
|
3429
3468
|
};
|
|
3430
3469
|
_iterator5 = _createForOfIteratorHelper(tempOrder.products);
|
|
3431
|
-
|
|
3470
|
+
_context30.prev = 27;
|
|
3432
3471
|
_iterator5.s();
|
|
3433
3472
|
case 29:
|
|
3434
3473
|
if ((_step5 = _iterator5.n()).done) {
|
|
3435
|
-
|
|
3474
|
+
_context30.next = 46;
|
|
3436
3475
|
break;
|
|
3437
3476
|
}
|
|
3438
3477
|
product = _step5.value;
|
|
3439
3478
|
productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
|
|
3440
3479
|
runtimeOrigin = productUid ? (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[productUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin : undefined;
|
|
3441
3480
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
3442
|
-
|
|
3481
|
+
_context30.next = 35;
|
|
3443
3482
|
break;
|
|
3444
3483
|
}
|
|
3445
|
-
return
|
|
3484
|
+
return _context30.abrupt("continue", 44);
|
|
3446
3485
|
case 35:
|
|
3447
3486
|
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
3448
3487
|
if (Array.isArray(product.product_bundle)) {
|
|
3449
3488
|
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
3450
|
-
var
|
|
3489
|
+
var _ref43, _bundle$original_pric;
|
|
3451
3490
|
var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
|
|
3452
3491
|
var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
3453
|
-
var restoredBundlePrice = (
|
|
3492
|
+
var restoredBundlePrice = (_ref43 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref43 !== void 0 ? _ref43 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
3454
3493
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
|
|
3455
3494
|
price: restoredBundlePrice,
|
|
3456
3495
|
bundle_selling_price: restoredBundlePrice
|
|
@@ -3478,28 +3517,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3478
3517
|
bundle: product.product_bundle
|
|
3479
3518
|
});
|
|
3480
3519
|
case 44:
|
|
3481
|
-
|
|
3520
|
+
_context30.next = 29;
|
|
3482
3521
|
break;
|
|
3483
3522
|
case 46:
|
|
3484
|
-
|
|
3523
|
+
_context30.next = 51;
|
|
3485
3524
|
break;
|
|
3486
3525
|
case 48:
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
_iterator5.e(
|
|
3526
|
+
_context30.prev = 48;
|
|
3527
|
+
_context30.t0 = _context30["catch"](27);
|
|
3528
|
+
_iterator5.e(_context30.t0);
|
|
3490
3529
|
case 51:
|
|
3491
|
-
|
|
3530
|
+
_context30.prev = 51;
|
|
3492
3531
|
_iterator5.f();
|
|
3493
|
-
return
|
|
3532
|
+
return _context30.finish(51);
|
|
3494
3533
|
case 54:
|
|
3495
3534
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
3496
|
-
|
|
3535
|
+
_context30.next = 57;
|
|
3497
3536
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
3498
3537
|
case 57:
|
|
3499
3538
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
3500
3539
|
return d.isSelected;
|
|
3501
3540
|
});
|
|
3502
|
-
|
|
3541
|
+
_context30.next = 60;
|
|
3503
3542
|
return this.store.order.recalculateSummary({
|
|
3504
3543
|
createIfMissing: true
|
|
3505
3544
|
});
|
|
@@ -3511,19 +3550,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3511
3550
|
selectedDiscountList: tempOrder.discount_list,
|
|
3512
3551
|
tempOrder: tempOrder
|
|
3513
3552
|
});
|
|
3514
|
-
|
|
3553
|
+
_context30.next = 67;
|
|
3515
3554
|
break;
|
|
3516
3555
|
case 64:
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
throw
|
|
3556
|
+
_context30.prev = 64;
|
|
3557
|
+
_context30.t1 = _context30["catch"](0);
|
|
3558
|
+
throw _context30.t1;
|
|
3520
3559
|
case 67:
|
|
3521
3560
|
case "end":
|
|
3522
|
-
return
|
|
3561
|
+
return _context30.stop();
|
|
3523
3562
|
}
|
|
3524
|
-
},
|
|
3563
|
+
}, _callee30, this, [[0, 64], [27, 48, 51, 54]]);
|
|
3525
3564
|
}));
|
|
3526
|
-
function setDiscountSelected(
|
|
3565
|
+
function setDiscountSelected(_x23) {
|
|
3527
3566
|
return _setDiscountSelected.apply(this, arguments);
|
|
3528
3567
|
}
|
|
3529
3568
|
return setDiscountSelected;
|
|
@@ -3531,23 +3570,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3531
3570
|
}, {
|
|
3532
3571
|
key: "applyDiscountCalculationResult",
|
|
3533
3572
|
value: function () {
|
|
3534
|
-
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3573
|
+
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(result) {
|
|
3535
3574
|
var tempOrder, orderStore, discountModule;
|
|
3536
|
-
return _regeneratorRuntime().wrap(function
|
|
3537
|
-
while (1) switch (
|
|
3575
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
3576
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
3538
3577
|
case 0:
|
|
3539
|
-
|
|
3578
|
+
_context31.prev = 0;
|
|
3540
3579
|
if (this.store.order) {
|
|
3541
|
-
|
|
3580
|
+
_context31.next = 3;
|
|
3542
3581
|
break;
|
|
3543
3582
|
}
|
|
3544
3583
|
throw new Error('order 模块未初始化');
|
|
3545
3584
|
case 3:
|
|
3546
3585
|
if (result) {
|
|
3547
|
-
|
|
3586
|
+
_context31.next = 5;
|
|
3548
3587
|
break;
|
|
3549
3588
|
}
|
|
3550
|
-
return
|
|
3589
|
+
return _context31.abrupt("return");
|
|
3551
3590
|
case 5:
|
|
3552
3591
|
tempOrder = this.store.order.ensureTempOrder();
|
|
3553
3592
|
orderStore = this.store.order.store || {};
|
|
@@ -3556,24 +3595,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3556
3595
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
3557
3596
|
}
|
|
3558
3597
|
if (!result.discountList) {
|
|
3559
|
-
|
|
3598
|
+
_context31.next = 14;
|
|
3560
3599
|
break;
|
|
3561
3600
|
}
|
|
3562
3601
|
OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
|
|
3563
|
-
|
|
3602
|
+
_context31.next = 13;
|
|
3564
3603
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
|
|
3565
3604
|
case 13:
|
|
3566
3605
|
tempOrder.discount_list = result.discountList.filter(function (discount) {
|
|
3567
3606
|
return discount.isSelected;
|
|
3568
3607
|
});
|
|
3569
3608
|
case 14:
|
|
3570
|
-
|
|
3609
|
+
_context31.next = 16;
|
|
3571
3610
|
return this.store.order.recalculateSummary({
|
|
3572
3611
|
createIfMissing: true
|
|
3573
3612
|
});
|
|
3574
3613
|
case 16:
|
|
3575
3614
|
this.store.order.persistTempOrder();
|
|
3576
|
-
|
|
3615
|
+
_context31.next = 19;
|
|
3577
3616
|
return this.effectsEmit('onDiscountApplied', {
|
|
3578
3617
|
productList: tempOrder.products || [],
|
|
3579
3618
|
discountList: result.discountList || [],
|
|
@@ -3581,19 +3620,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3581
3620
|
tempOrder: tempOrder
|
|
3582
3621
|
});
|
|
3583
3622
|
case 19:
|
|
3584
|
-
|
|
3623
|
+
_context31.next = 24;
|
|
3585
3624
|
break;
|
|
3586
3625
|
case 21:
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
throw
|
|
3626
|
+
_context31.prev = 21;
|
|
3627
|
+
_context31.t0 = _context31["catch"](0);
|
|
3628
|
+
throw _context31.t0;
|
|
3590
3629
|
case 24:
|
|
3591
3630
|
case "end":
|
|
3592
|
-
return
|
|
3631
|
+
return _context31.stop();
|
|
3593
3632
|
}
|
|
3594
|
-
},
|
|
3633
|
+
}, _callee31, this, [[0, 21]]);
|
|
3595
3634
|
}));
|
|
3596
|
-
function applyDiscountCalculationResult(
|
|
3635
|
+
function applyDiscountCalculationResult(_x24) {
|
|
3597
3636
|
return _applyDiscountCalculationResult.apply(this, arguments);
|
|
3598
3637
|
}
|
|
3599
3638
|
return applyDiscountCalculationResult;
|
|
@@ -3601,18 +3640,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3601
3640
|
}, {
|
|
3602
3641
|
key: "submitScanOrder",
|
|
3603
3642
|
value: function () {
|
|
3604
|
-
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3605
|
-
return _regeneratorRuntime().wrap(function
|
|
3606
|
-
while (1) switch (
|
|
3643
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
3644
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3645
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
3607
3646
|
case 0:
|
|
3608
|
-
return
|
|
3647
|
+
return _context32.abrupt("return", this.submitSalesOrder(params));
|
|
3609
3648
|
case 1:
|
|
3610
3649
|
case "end":
|
|
3611
|
-
return
|
|
3650
|
+
return _context32.stop();
|
|
3612
3651
|
}
|
|
3613
|
-
},
|
|
3652
|
+
}, _callee32, this);
|
|
3614
3653
|
}));
|
|
3615
|
-
function submitScanOrder(
|
|
3654
|
+
function submitScanOrder(_x25) {
|
|
3616
3655
|
return _submitScanOrder.apply(this, arguments);
|
|
3617
3656
|
}
|
|
3618
3657
|
return submitScanOrder;
|
|
@@ -3620,46 +3659,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3620
3659
|
}, {
|
|
3621
3660
|
key: "buildVirtualSettlementSubmitData",
|
|
3622
3661
|
value: function () {
|
|
3623
|
-
var _buildVirtualSettlementSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3662
|
+
var _buildVirtualSettlementSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
3624
3663
|
var _tempOrder$metadata$c, _tempOrder$metadata2;
|
|
3625
3664
|
var tempOrder, snapshot, currencyProductId, summary, amount, customerId, asset, currencyCode, currencySymbol, currencyFormat, balance, amountText, paymentNumber, payment, _paymentMethod$custom, paymentMethods, paymentMethod;
|
|
3626
|
-
return _regeneratorRuntime().wrap(function
|
|
3627
|
-
while (1) switch (
|
|
3665
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3666
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
3628
3667
|
case 0:
|
|
3629
3668
|
if (this.store.order) {
|
|
3630
|
-
|
|
3669
|
+
_context33.next = 2;
|
|
3631
3670
|
break;
|
|
3632
3671
|
}
|
|
3633
|
-
return
|
|
3672
|
+
return _context33.abrupt("return", null);
|
|
3634
3673
|
case 2:
|
|
3635
3674
|
tempOrder = this.store.order.getTempOrder();
|
|
3636
3675
|
if (this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
3637
|
-
|
|
3676
|
+
_context33.next = 5;
|
|
3638
3677
|
break;
|
|
3639
3678
|
}
|
|
3640
|
-
return
|
|
3679
|
+
return _context33.abrupt("return", null);
|
|
3641
3680
|
case 5:
|
|
3642
3681
|
snapshot = getTempOrderSettlementSnapshot(tempOrder);
|
|
3643
3682
|
currencyProductId = Number((_tempOrder$metadata$c = tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.currency_settlement_config) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.settlement_ids) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2[0]) !== null && _tempOrder$metadata$c !== void 0 ? _tempOrder$metadata$c : snapshot === null || snapshot === void 0 ? void 0 : snapshot.currency_product_id);
|
|
3644
3683
|
if (!(!snapshot || !Number.isFinite(currencyProductId) || currencyProductId <= 0)) {
|
|
3645
|
-
|
|
3684
|
+
_context33.next = 9;
|
|
3646
3685
|
break;
|
|
3647
3686
|
}
|
|
3648
3687
|
throw new Error('Virtual currency settlement configuration is invalid.');
|
|
3649
3688
|
case 9:
|
|
3650
|
-
|
|
3689
|
+
_context33.next = 11;
|
|
3651
3690
|
return this.store.order.recalculateSummary({
|
|
3652
3691
|
createIfMissing: true
|
|
3653
3692
|
});
|
|
3654
3693
|
case 11:
|
|
3655
|
-
summary =
|
|
3694
|
+
summary = _context33.sent;
|
|
3656
3695
|
amount = new Decimal((summary === null || summary === void 0 ? void 0 : summary.total_amount) || 0).toDecimalPlaces(2);
|
|
3657
3696
|
customerId = Number((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id) || 0);
|
|
3658
3697
|
if (!(amount.gt(0) && customerId > 0 && customerId !== 1)) {
|
|
3659
|
-
|
|
3698
|
+
_context33.next = 17;
|
|
3660
3699
|
break;
|
|
3661
3700
|
}
|
|
3662
|
-
|
|
3701
|
+
_context33.next = 17;
|
|
3663
3702
|
return this.store.order.loadDiscountConfig({
|
|
3664
3703
|
customerId: customerId,
|
|
3665
3704
|
action: tempOrder !== null && tempOrder !== void 0 && tempOrder.order_id ? 'edit' : 'create',
|
|
@@ -3674,10 +3713,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3674
3713
|
currencySymbol = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_symbol) || '');
|
|
3675
3714
|
currencyFormat = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_format) || 'symbol_first');
|
|
3676
3715
|
if (!amount.lte(0)) {
|
|
3677
|
-
|
|
3716
|
+
_context33.next = 23;
|
|
3678
3717
|
break;
|
|
3679
3718
|
}
|
|
3680
|
-
return
|
|
3719
|
+
return _context33.abrupt("return", {
|
|
3681
3720
|
payments: [],
|
|
3682
3721
|
snapshot: snapshot,
|
|
3683
3722
|
currencyProductId: currencyProductId,
|
|
@@ -3687,14 +3726,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3687
3726
|
});
|
|
3688
3727
|
case 23:
|
|
3689
3728
|
if (asset) {
|
|
3690
|
-
|
|
3729
|
+
_context33.next = 25;
|
|
3691
3730
|
break;
|
|
3692
3731
|
}
|
|
3693
3732
|
throw new Error('No matching virtual currency card is available.');
|
|
3694
3733
|
case 25:
|
|
3695
3734
|
balance = new Decimal(asset.balance || 0);
|
|
3696
3735
|
if (!balance.lt(amount)) {
|
|
3697
|
-
|
|
3736
|
+
_context33.next = 28;
|
|
3698
3737
|
break;
|
|
3699
3738
|
}
|
|
3700
3739
|
throw new Error('Insufficient virtual currency balance.');
|
|
@@ -3702,7 +3741,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3702
3741
|
amountText = amount.toFixed(2);
|
|
3703
3742
|
paymentNumber = "LOCAL_".concat(createUuidV4());
|
|
3704
3743
|
if (!this.store.order.isOnlineStorePlatform()) {
|
|
3705
|
-
|
|
3744
|
+
_context33.next = 34;
|
|
3706
3745
|
break;
|
|
3707
3746
|
}
|
|
3708
3747
|
payment = {
|
|
@@ -3719,18 +3758,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3719
3758
|
},
|
|
3720
3759
|
wallet_pass_use_value: amountText
|
|
3721
3760
|
};
|
|
3722
|
-
|
|
3761
|
+
_context33.next = 41;
|
|
3723
3762
|
break;
|
|
3724
3763
|
case 34:
|
|
3725
|
-
|
|
3764
|
+
_context33.next = 36;
|
|
3726
3765
|
return this.getPaymentMethodsAsync();
|
|
3727
3766
|
case 36:
|
|
3728
|
-
paymentMethods =
|
|
3767
|
+
paymentMethods = _context33.sent;
|
|
3729
3768
|
paymentMethod = paymentMethods.find(function (method) {
|
|
3730
3769
|
return String(method.code || '').toUpperCase() === 'PRODUCTVOUCHER';
|
|
3731
3770
|
});
|
|
3732
3771
|
if (paymentMethod) {
|
|
3733
|
-
|
|
3772
|
+
_context33.next = 40;
|
|
3734
3773
|
break;
|
|
3735
3774
|
}
|
|
3736
3775
|
throw new Error('PRODUCTVOUCHER payment method is unavailable.');
|
|
@@ -3754,7 +3793,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3754
3793
|
metadata: {}
|
|
3755
3794
|
};
|
|
3756
3795
|
case 41:
|
|
3757
|
-
return
|
|
3796
|
+
return _context33.abrupt("return", {
|
|
3758
3797
|
payments: [payment],
|
|
3759
3798
|
snapshot: snapshot,
|
|
3760
3799
|
currencyProductId: currencyProductId,
|
|
@@ -3764,9 +3803,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3764
3803
|
});
|
|
3765
3804
|
case 42:
|
|
3766
3805
|
case "end":
|
|
3767
|
-
return
|
|
3806
|
+
return _context33.stop();
|
|
3768
3807
|
}
|
|
3769
|
-
},
|
|
3808
|
+
}, _callee33, this);
|
|
3770
3809
|
}));
|
|
3771
3810
|
function buildVirtualSettlementSubmitData() {
|
|
3772
3811
|
return _buildVirtualSettlementSubmitData.apply(this, arguments);
|
|
@@ -3782,22 +3821,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3782
3821
|
}, {
|
|
3783
3822
|
key: "submitSalesOrder",
|
|
3784
3823
|
value: (function () {
|
|
3785
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3824
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
3786
3825
|
var _params$smallTicketDa, _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
|
|
3787
3826
|
var virtualSettlement, inferredPaymentStatus, smallTicketDataFlag, _enhancePayload, submitParams;
|
|
3788
|
-
return _regeneratorRuntime().wrap(function
|
|
3789
|
-
while (1) switch (
|
|
3827
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3828
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3790
3829
|
case 0:
|
|
3791
3830
|
if (this.store.order) {
|
|
3792
|
-
|
|
3831
|
+
_context34.next = 2;
|
|
3793
3832
|
break;
|
|
3794
3833
|
}
|
|
3795
3834
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
3796
3835
|
case 2:
|
|
3797
|
-
|
|
3836
|
+
_context34.next = 4;
|
|
3798
3837
|
return this.buildVirtualSettlementSubmitData();
|
|
3799
3838
|
case 4:
|
|
3800
|
-
virtualSettlement =
|
|
3839
|
+
virtualSettlement = _context34.sent;
|
|
3801
3840
|
// this.store.order.persistTempOrder();
|
|
3802
3841
|
inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
|
|
3803
3842
|
smallTicketDataFlag = (_params$smallTicketDa = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa !== void 0 ? _params$smallTicketDa : this.getDefaultCheckoutSmallTicketDataFlag();
|
|
@@ -3842,14 +3881,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3842
3881
|
} : _enhancePayload !== undefined ? {
|
|
3843
3882
|
enhancePayload: _enhancePayload
|
|
3844
3883
|
} : {});
|
|
3845
|
-
return
|
|
3884
|
+
return _context34.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
|
|
3846
3885
|
case 10:
|
|
3847
3886
|
case "end":
|
|
3848
|
-
return
|
|
3887
|
+
return _context34.stop();
|
|
3849
3888
|
}
|
|
3850
|
-
},
|
|
3889
|
+
}, _callee34, this);
|
|
3851
3890
|
}));
|
|
3852
|
-
function submitSalesOrder(
|
|
3891
|
+
function submitSalesOrder(_x26) {
|
|
3853
3892
|
return _submitSalesOrder.apply(this, arguments);
|
|
3854
3893
|
}
|
|
3855
3894
|
return submitSalesOrder;
|
|
@@ -3857,18 +3896,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3857
3896
|
}, {
|
|
3858
3897
|
key: "saveSalesOrderDraft",
|
|
3859
3898
|
value: function () {
|
|
3860
|
-
var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3899
|
+
var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
3861
3900
|
var _params$platform, _this$otherParams18, _this$otherParams19, _this$otherParams20, _params$channel, _params$type, _this$otherParams21;
|
|
3862
|
-
return _regeneratorRuntime().wrap(function
|
|
3863
|
-
while (1) switch (
|
|
3901
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3902
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3864
3903
|
case 0:
|
|
3865
3904
|
if (this.store.order) {
|
|
3866
|
-
|
|
3905
|
+
_context35.next = 2;
|
|
3867
3906
|
break;
|
|
3868
3907
|
}
|
|
3869
3908
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
3870
3909
|
case 2:
|
|
3871
|
-
return
|
|
3910
|
+
return _context35.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
|
|
3872
3911
|
cacheId: this.cacheId,
|
|
3873
3912
|
platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform,
|
|
3874
3913
|
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.businessCode) || ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.business_code),
|
|
@@ -3879,11 +3918,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3879
3918
|
} : {})));
|
|
3880
3919
|
case 3:
|
|
3881
3920
|
case "end":
|
|
3882
|
-
return
|
|
3921
|
+
return _context35.stop();
|
|
3883
3922
|
}
|
|
3884
|
-
},
|
|
3923
|
+
}, _callee35, this);
|
|
3885
3924
|
}));
|
|
3886
|
-
function saveSalesOrderDraft(
|
|
3925
|
+
function saveSalesOrderDraft(_x27) {
|
|
3887
3926
|
return _saveSalesOrderDraft.apply(this, arguments);
|
|
3888
3927
|
}
|
|
3889
3928
|
return saveSalesOrderDraft;
|
|
@@ -3891,14 +3930,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3891
3930
|
}, {
|
|
3892
3931
|
key: "submitTempOrderAsync",
|
|
3893
3932
|
value: function () {
|
|
3894
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3933
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
3895
3934
|
var _params$smallTicketDa2, _this$otherParams22, _this$otherParams23, _this$otherParams24, _this$otherParams25;
|
|
3896
3935
|
var inferredPaymentStatus, smallTicketDataFlag, enhancePayload, submitParams;
|
|
3897
|
-
return _regeneratorRuntime().wrap(function
|
|
3898
|
-
while (1) switch (
|
|
3936
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
3937
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3899
3938
|
case 0:
|
|
3900
3939
|
if (this.store.order) {
|
|
3901
|
-
|
|
3940
|
+
_context36.next = 2;
|
|
3902
3941
|
break;
|
|
3903
3942
|
}
|
|
3904
3943
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -3924,14 +3963,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3924
3963
|
} : {}), enhancePayload !== undefined ? {
|
|
3925
3964
|
enhancePayload: enhancePayload
|
|
3926
3965
|
} : {});
|
|
3927
|
-
return
|
|
3966
|
+
return _context36.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
|
|
3928
3967
|
case 7:
|
|
3929
3968
|
case "end":
|
|
3930
|
-
return
|
|
3969
|
+
return _context36.stop();
|
|
3931
3970
|
}
|
|
3932
|
-
},
|
|
3971
|
+
}, _callee36, this);
|
|
3933
3972
|
}));
|
|
3934
|
-
function submitTempOrderAsync(
|
|
3973
|
+
function submitTempOrderAsync(_x28) {
|
|
3935
3974
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
3936
3975
|
}
|
|
3937
3976
|
return submitTempOrderAsync;
|
|
@@ -3957,14 +3996,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3957
3996
|
}, {
|
|
3958
3997
|
key: "printLocalOrderReceipt",
|
|
3959
3998
|
value: function () {
|
|
3960
|
-
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3999
|
+
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(lookup) {
|
|
3961
4000
|
var _this$otherParams27, _this$otherParams28, _this$otherParams29, _this$otherParams30;
|
|
3962
4001
|
var hasLookup, lookupPayload, context, payload, invoiceLayoutConfig, invoiceTemplateSettings, printPayload, response, _this$store$order$app, _this$store$order6, _data;
|
|
3963
|
-
return _regeneratorRuntime().wrap(function
|
|
3964
|
-
while (1) switch (
|
|
4002
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
4003
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
3965
4004
|
case 0:
|
|
3966
4005
|
if (this.store.order) {
|
|
3967
|
-
|
|
4006
|
+
_context37.next = 2;
|
|
3968
4007
|
break;
|
|
3969
4008
|
}
|
|
3970
4009
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -4002,28 +4041,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4002
4041
|
} : {}), invoiceTemplateSettings ? {
|
|
4003
4042
|
template_settings: cloneDeep(invoiceTemplateSettings)
|
|
4004
4043
|
} : {});
|
|
4005
|
-
|
|
4044
|
+
_context37.next = 11;
|
|
4006
4045
|
return this.request.post('/local/print-order', printPayload, {
|
|
4007
4046
|
osServer: true,
|
|
4008
4047
|
customToast: function customToast() {}
|
|
4009
4048
|
});
|
|
4010
4049
|
case 11:
|
|
4011
|
-
response =
|
|
4050
|
+
response = _context37.sent;
|
|
4012
4051
|
if (hasLookup) {
|
|
4013
|
-
|
|
4052
|
+
_context37.next = 15;
|
|
4014
4053
|
break;
|
|
4015
4054
|
}
|
|
4016
|
-
|
|
4055
|
+
_context37.next = 15;
|
|
4017
4056
|
return (_this$store$order$app = (_this$store$order6 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order6, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
|
|
4018
4057
|
case 15:
|
|
4019
|
-
return
|
|
4058
|
+
return _context37.abrupt("return", response);
|
|
4020
4059
|
case 16:
|
|
4021
4060
|
case "end":
|
|
4022
|
-
return
|
|
4061
|
+
return _context37.stop();
|
|
4023
4062
|
}
|
|
4024
|
-
},
|
|
4063
|
+
}, _callee37, this);
|
|
4025
4064
|
}));
|
|
4026
|
-
function printLocalOrderReceipt(
|
|
4065
|
+
function printLocalOrderReceipt(_x29) {
|
|
4027
4066
|
return _printLocalOrderReceipt.apply(this, arguments);
|
|
4028
4067
|
}
|
|
4029
4068
|
return printLocalOrderReceipt;
|
|
@@ -4044,19 +4083,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4044
4083
|
}, {
|
|
4045
4084
|
key: "syncPaymentsToOrder",
|
|
4046
4085
|
value: function () {
|
|
4047
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4048
|
-
var
|
|
4086
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
|
|
4087
|
+
var _ref44, _params$businessCode, _this$otherParams31, _this$otherParams32, _params$channel2;
|
|
4049
4088
|
var businessCode, channel, enhancePayload, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
|
|
4050
|
-
return _regeneratorRuntime().wrap(function
|
|
4051
|
-
while (1) switch (
|
|
4089
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
4090
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
4052
4091
|
case 0:
|
|
4053
4092
|
if (this.store.order) {
|
|
4054
|
-
|
|
4093
|
+
_context38.next = 2;
|
|
4055
4094
|
break;
|
|
4056
4095
|
}
|
|
4057
4096
|
throw new Error('order 模块未初始化');
|
|
4058
4097
|
case 2:
|
|
4059
|
-
businessCode = (
|
|
4098
|
+
businessCode = (_ref44 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.businessCode) !== null && _ref44 !== void 0 ? _ref44 : (_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.business_code;
|
|
4060
4099
|
channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
|
|
4061
4100
|
enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(params.enhancePayload);
|
|
4062
4101
|
syncParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -4070,14 +4109,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4070
4109
|
} : {});
|
|
4071
4110
|
syncState = this.store.order.getOrderSyncState();
|
|
4072
4111
|
if (!(params.submitWhenPaid && syncState === 'submitting')) {
|
|
4073
|
-
|
|
4112
|
+
_context38.next = 10;
|
|
4074
4113
|
break;
|
|
4075
4114
|
}
|
|
4076
4115
|
this.queueLatestAutoPaymentSync();
|
|
4077
|
-
return
|
|
4116
|
+
return _context38.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
|
|
4078
4117
|
case 10:
|
|
4079
4118
|
payments = params.payments || [];
|
|
4080
|
-
|
|
4119
|
+
_context38.next = 13;
|
|
4081
4120
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
|
|
4082
4121
|
payments: payments,
|
|
4083
4122
|
params: syncParams,
|
|
@@ -4085,11 +4124,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4085
4124
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
4086
4125
|
});
|
|
4087
4126
|
case 13:
|
|
4088
|
-
|
|
4089
|
-
|
|
4127
|
+
_context38.prev = 13;
|
|
4128
|
+
_context38.next = 16;
|
|
4090
4129
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
4091
4130
|
case 16:
|
|
4092
|
-
syncResult =
|
|
4131
|
+
syncResult = _context38.sent;
|
|
4093
4132
|
latestPayments = this.store.order.getOrderPayments();
|
|
4094
4133
|
amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
4095
4134
|
orderSnapshot = this.store.order.getOrderSnapshot();
|
|
@@ -4107,25 +4146,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4107
4146
|
depositAmount: syncResult.depositAmount,
|
|
4108
4147
|
orderExpectedAmount: syncResult.orderExpectedAmount
|
|
4109
4148
|
};
|
|
4110
|
-
|
|
4149
|
+
_context38.next = 23;
|
|
4111
4150
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
|
|
4112
4151
|
case 23:
|
|
4113
4152
|
if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
|
|
4114
|
-
|
|
4153
|
+
_context38.next = 26;
|
|
4115
4154
|
break;
|
|
4116
4155
|
}
|
|
4117
|
-
|
|
4156
|
+
_context38.next = 26;
|
|
4118
4157
|
return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
4119
4158
|
case 26:
|
|
4120
4159
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
4121
|
-
return
|
|
4160
|
+
return _context38.abrupt("return", syncResult);
|
|
4122
4161
|
case 30:
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4162
|
+
_context38.prev = 30;
|
|
4163
|
+
_context38.t0 = _context38["catch"](13);
|
|
4164
|
+
_context38.next = 34;
|
|
4126
4165
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
4127
4166
|
ok: false,
|
|
4128
|
-
error:
|
|
4167
|
+
error: _context38.t0,
|
|
4129
4168
|
payments: this.store.order.getOrderPayments(),
|
|
4130
4169
|
params: syncParams,
|
|
4131
4170
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
@@ -4133,14 +4172,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4133
4172
|
});
|
|
4134
4173
|
case 34:
|
|
4135
4174
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
4136
|
-
throw
|
|
4175
|
+
throw _context38.t0;
|
|
4137
4176
|
case 36:
|
|
4138
4177
|
case "end":
|
|
4139
|
-
return
|
|
4178
|
+
return _context38.stop();
|
|
4140
4179
|
}
|
|
4141
|
-
},
|
|
4180
|
+
}, _callee38, this, [[13, 30]]);
|
|
4142
4181
|
}));
|
|
4143
|
-
function syncPaymentsToOrder(
|
|
4182
|
+
function syncPaymentsToOrder(_x30) {
|
|
4144
4183
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
4145
4184
|
}
|
|
4146
4185
|
return syncPaymentsToOrder;
|
|
@@ -4177,58 +4216,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4177
4216
|
}, {
|
|
4178
4217
|
key: "scheduleQueuedAutoPaymentSyncFlush",
|
|
4179
4218
|
value: function scheduleQueuedAutoPaymentSyncFlush() {
|
|
4180
|
-
var
|
|
4219
|
+
var _this16 = this;
|
|
4181
4220
|
var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
|
|
4182
4221
|
if (!this.queuedAutoPaymentSync) return;
|
|
4183
4222
|
if (this.autoPaymentSyncTimer) return;
|
|
4184
4223
|
this.autoPaymentSyncTimer = setTimeout(function () {
|
|
4185
|
-
|
|
4186
|
-
void
|
|
4224
|
+
_this16.autoPaymentSyncTimer = null;
|
|
4225
|
+
void _this16.flushQueuedAutoPaymentSync();
|
|
4187
4226
|
}, delay);
|
|
4188
4227
|
}
|
|
4189
4228
|
}, {
|
|
4190
4229
|
key: "flushQueuedAutoPaymentSync",
|
|
4191
4230
|
value: function () {
|
|
4192
|
-
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4231
|
+
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
|
|
4193
4232
|
var payments;
|
|
4194
|
-
return _regeneratorRuntime().wrap(function
|
|
4195
|
-
while (1) switch (
|
|
4233
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
4234
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
4196
4235
|
case 0:
|
|
4197
4236
|
if (this.store.order) {
|
|
4198
|
-
|
|
4237
|
+
_context39.next = 2;
|
|
4199
4238
|
break;
|
|
4200
4239
|
}
|
|
4201
|
-
return
|
|
4240
|
+
return _context39.abrupt("return");
|
|
4202
4241
|
case 2:
|
|
4203
4242
|
if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
|
|
4204
|
-
|
|
4243
|
+
_context39.next = 4;
|
|
4205
4244
|
break;
|
|
4206
4245
|
}
|
|
4207
|
-
return
|
|
4246
|
+
return _context39.abrupt("return");
|
|
4208
4247
|
case 4:
|
|
4209
4248
|
if (!(this.store.order.getOrderSyncState() === 'submitting')) {
|
|
4210
|
-
|
|
4249
|
+
_context39.next = 7;
|
|
4211
4250
|
break;
|
|
4212
4251
|
}
|
|
4213
4252
|
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
4214
|
-
return
|
|
4253
|
+
return _context39.abrupt("return");
|
|
4215
4254
|
case 7:
|
|
4216
4255
|
this.autoPaymentSyncFlushing = true;
|
|
4217
|
-
|
|
4256
|
+
_context39.prev = 8;
|
|
4218
4257
|
case 9:
|
|
4219
4258
|
if (!this.queuedAutoPaymentSync) {
|
|
4220
|
-
|
|
4259
|
+
_context39.next = 18;
|
|
4221
4260
|
break;
|
|
4222
4261
|
}
|
|
4223
4262
|
this.queuedAutoPaymentSync = false;
|
|
4224
4263
|
payments = this.store.order.getOrderPayments();
|
|
4225
4264
|
if (payments.length) {
|
|
4226
|
-
|
|
4265
|
+
_context39.next = 14;
|
|
4227
4266
|
break;
|
|
4228
4267
|
}
|
|
4229
|
-
return
|
|
4268
|
+
return _context39.abrupt("continue", 9);
|
|
4230
4269
|
case 14:
|
|
4231
|
-
|
|
4270
|
+
_context39.next = 16;
|
|
4232
4271
|
return this.syncPaymentsToOrder({
|
|
4233
4272
|
payments: payments,
|
|
4234
4273
|
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
@@ -4236,29 +4275,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4236
4275
|
smallTicketDataFlag: 1
|
|
4237
4276
|
});
|
|
4238
4277
|
case 16:
|
|
4239
|
-
|
|
4278
|
+
_context39.next = 9;
|
|
4240
4279
|
break;
|
|
4241
4280
|
case 18:
|
|
4242
|
-
|
|
4281
|
+
_context39.next = 23;
|
|
4243
4282
|
break;
|
|
4244
4283
|
case 20:
|
|
4245
|
-
|
|
4246
|
-
|
|
4284
|
+
_context39.prev = 20;
|
|
4285
|
+
_context39.t0 = _context39["catch"](8);
|
|
4247
4286
|
this.logError('queued auto sync payments failed', {
|
|
4248
|
-
error:
|
|
4287
|
+
error: _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0)
|
|
4249
4288
|
});
|
|
4250
4289
|
case 23:
|
|
4251
|
-
|
|
4290
|
+
_context39.prev = 23;
|
|
4252
4291
|
this.autoPaymentSyncFlushing = false;
|
|
4253
4292
|
if (this.queuedAutoPaymentSync) {
|
|
4254
4293
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
4255
4294
|
}
|
|
4256
|
-
return
|
|
4295
|
+
return _context39.finish(23);
|
|
4257
4296
|
case 27:
|
|
4258
4297
|
case "end":
|
|
4259
|
-
return
|
|
4298
|
+
return _context39.stop();
|
|
4260
4299
|
}
|
|
4261
|
-
},
|
|
4300
|
+
}, _callee39, this, [[8, 20, 23, 27]]);
|
|
4262
4301
|
}));
|
|
4263
4302
|
function flushQueuedAutoPaymentSync() {
|
|
4264
4303
|
return _flushQueuedAutoPaymentSync.apply(this, arguments);
|
|
@@ -4282,35 +4321,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4282
4321
|
}, {
|
|
4283
4322
|
key: "addOrderPaymentAsync",
|
|
4284
4323
|
value: (function () {
|
|
4285
|
-
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4324
|
+
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(payment) {
|
|
4286
4325
|
var paymentRecord, hasPaymentNumber, devicePrefix;
|
|
4287
|
-
return _regeneratorRuntime().wrap(function
|
|
4288
|
-
while (1) switch (
|
|
4326
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
4327
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
4289
4328
|
case 0:
|
|
4290
4329
|
paymentRecord = payment;
|
|
4291
4330
|
hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
|
|
4292
4331
|
if (!hasPaymentNumber) {
|
|
4293
|
-
|
|
4332
|
+
_context40.next = 6;
|
|
4294
4333
|
break;
|
|
4295
4334
|
}
|
|
4296
|
-
|
|
4297
|
-
|
|
4335
|
+
_context40.t0 = 'LOCAL';
|
|
4336
|
+
_context40.next = 9;
|
|
4298
4337
|
break;
|
|
4299
4338
|
case 6:
|
|
4300
|
-
|
|
4339
|
+
_context40.next = 8;
|
|
4301
4340
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
4302
4341
|
case 8:
|
|
4303
|
-
|
|
4342
|
+
_context40.t0 = _context40.sent;
|
|
4304
4343
|
case 9:
|
|
4305
|
-
devicePrefix =
|
|
4306
|
-
return
|
|
4344
|
+
devicePrefix = _context40.t0;
|
|
4345
|
+
return _context40.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
4307
4346
|
case 11:
|
|
4308
4347
|
case "end":
|
|
4309
|
-
return
|
|
4348
|
+
return _context40.stop();
|
|
4310
4349
|
}
|
|
4311
|
-
},
|
|
4350
|
+
}, _callee40, this);
|
|
4312
4351
|
}));
|
|
4313
|
-
function addOrderPaymentAsync(
|
|
4352
|
+
function addOrderPaymentAsync(_x31) {
|
|
4314
4353
|
return _addOrderPaymentAsync.apply(this, arguments);
|
|
4315
4354
|
}
|
|
4316
4355
|
return addOrderPaymentAsync;
|
|
@@ -4321,9 +4360,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4321
4360
|
var _this$otherParams33,
|
|
4322
4361
|
_paymentRecord$paymen,
|
|
4323
4362
|
_paymentRecord$create,
|
|
4324
|
-
|
|
4363
|
+
_ref45,
|
|
4325
4364
|
_paymentRecord$origin,
|
|
4326
|
-
|
|
4365
|
+
_this17 = this;
|
|
4327
4366
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
4328
4367
|
var paymentRecord = payment;
|
|
4329
4368
|
var paymentAmount = new Decimal(paymentRecord.amount || 0);
|
|
@@ -4343,7 +4382,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4343
4382
|
var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
|
|
4344
4383
|
var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
|
|
4345
4384
|
var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
|
|
4346
|
-
var calculatedServiceFee = serviceCharge ? new Decimal((
|
|
4385
|
+
var calculatedServiceFee = serviceCharge ? new Decimal((_ref45 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref45 !== void 0 ? _ref45 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
4347
4386
|
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
|
|
4348
4387
|
service_fee: calculatedServiceFee
|
|
4349
4388
|
} : {}), {}, {
|
|
@@ -4367,7 +4406,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4367
4406
|
submitWhenPaid: true,
|
|
4368
4407
|
smallTicketDataFlag: 1
|
|
4369
4408
|
}).catch(function (error) {
|
|
4370
|
-
|
|
4409
|
+
_this17.logError('auto sync payments failed', {
|
|
4371
4410
|
error: error instanceof Error ? error.message : String(error)
|
|
4372
4411
|
});
|
|
4373
4412
|
});
|
|
@@ -4379,7 +4418,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4379
4418
|
}, {
|
|
4380
4419
|
key: "updateOrderPayment",
|
|
4381
4420
|
value: (function () {
|
|
4382
|
-
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4421
|
+
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(paymentIdentity, updates) {
|
|
4383
4422
|
var _result$payment, _result$payment2;
|
|
4384
4423
|
var options,
|
|
4385
4424
|
matchMode,
|
|
@@ -4396,13 +4435,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4396
4435
|
shouldSubmit,
|
|
4397
4436
|
syncResult,
|
|
4398
4437
|
_options$smallTicketD2,
|
|
4399
|
-
|
|
4400
|
-
return _regeneratorRuntime().wrap(function
|
|
4401
|
-
while (1) switch (
|
|
4438
|
+
_args41 = arguments;
|
|
4439
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
4440
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
4402
4441
|
case 0:
|
|
4403
|
-
options =
|
|
4442
|
+
options = _args41.length > 2 && _args41[2] !== undefined ? _args41[2] : {};
|
|
4404
4443
|
if (this.store.order) {
|
|
4405
|
-
|
|
4444
|
+
_context41.next = 3;
|
|
4406
4445
|
break;
|
|
4407
4446
|
}
|
|
4408
4447
|
throw new Error('order 模块未初始化');
|
|
@@ -4411,15 +4450,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4411
4450
|
previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
|
|
4412
4451
|
previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
|
|
4413
4452
|
if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
|
|
4414
|
-
|
|
4453
|
+
_context41.next = 13;
|
|
4415
4454
|
break;
|
|
4416
4455
|
}
|
|
4417
4456
|
currentPayments = this.store.order.getOrderPayments();
|
|
4418
4457
|
if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
|
|
4419
|
-
|
|
4458
|
+
_context41.next = 12;
|
|
4420
4459
|
break;
|
|
4421
4460
|
}
|
|
4422
|
-
|
|
4461
|
+
_context41.next = 11;
|
|
4423
4462
|
return this.syncPaymentsToOrder({
|
|
4424
4463
|
payments: currentPayments,
|
|
4425
4464
|
paymentStatus: this.getPaymentStatusForSync(currentPayments),
|
|
@@ -4427,9 +4466,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4427
4466
|
smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
|
|
4428
4467
|
});
|
|
4429
4468
|
case 11:
|
|
4430
|
-
_syncResult =
|
|
4469
|
+
_syncResult = _context41.sent;
|
|
4431
4470
|
case 12:
|
|
4432
|
-
return
|
|
4471
|
+
return _context41.abrupt("return", _objectSpread({
|
|
4433
4472
|
updated: false,
|
|
4434
4473
|
payment: previousPayment,
|
|
4435
4474
|
payments: currentPayments,
|
|
@@ -4438,44 +4477,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4438
4477
|
syncResult: _syncResult
|
|
4439
4478
|
} : {}));
|
|
4440
4479
|
case 13:
|
|
4441
|
-
|
|
4480
|
+
_context41.next = 15;
|
|
4442
4481
|
return this.store.order.updateOrderPayment(paymentIdentity, updates, {
|
|
4443
4482
|
matchBy: matchMode
|
|
4444
4483
|
});
|
|
4445
4484
|
case 15:
|
|
4446
|
-
result =
|
|
4485
|
+
result = _context41.sent;
|
|
4447
4486
|
if (!(options.persistDraft !== false)) {
|
|
4448
|
-
|
|
4487
|
+
_context41.next = 29;
|
|
4449
4488
|
break;
|
|
4450
4489
|
}
|
|
4451
|
-
|
|
4452
|
-
|
|
4490
|
+
_context41.prev = 17;
|
|
4491
|
+
_context41.next = 20;
|
|
4453
4492
|
return this.saveSalesOrderDraft();
|
|
4454
4493
|
case 20:
|
|
4455
|
-
draftResult =
|
|
4456
|
-
|
|
4494
|
+
draftResult = _context41.sent;
|
|
4495
|
+
_context41.next = 29;
|
|
4457
4496
|
break;
|
|
4458
4497
|
case 23:
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
draftError =
|
|
4498
|
+
_context41.prev = 23;
|
|
4499
|
+
_context41.t0 = _context41["catch"](17);
|
|
4500
|
+
draftError = _context41.t0;
|
|
4462
4501
|
this.logError('updateOrderPayment: 保存支付草稿失败', {
|
|
4463
4502
|
paymentIdentity: paymentIdentity,
|
|
4464
|
-
error:
|
|
4503
|
+
error: _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0)
|
|
4465
4504
|
});
|
|
4466
4505
|
if (options.submitWhenPaid) {
|
|
4467
|
-
|
|
4506
|
+
_context41.next = 29;
|
|
4468
4507
|
break;
|
|
4469
4508
|
}
|
|
4470
|
-
throw
|
|
4509
|
+
throw _context41.t0;
|
|
4471
4510
|
case 29:
|
|
4472
4511
|
becamePaid = (previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) !== 'paid' && ((_result$payment = result.payment) === null || _result$payment === void 0 ? void 0 : _result$payment.status) === 'paid';
|
|
4473
4512
|
shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
|
|
4474
4513
|
if (!shouldSubmit) {
|
|
4475
|
-
|
|
4514
|
+
_context41.next = 35;
|
|
4476
4515
|
break;
|
|
4477
4516
|
}
|
|
4478
|
-
|
|
4517
|
+
_context41.next = 34;
|
|
4479
4518
|
return this.syncPaymentsToOrder({
|
|
4480
4519
|
payments: result.payments,
|
|
4481
4520
|
paymentStatus: this.getPaymentStatusForSync(result.payments),
|
|
@@ -4483,9 +4522,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4483
4522
|
smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
|
|
4484
4523
|
});
|
|
4485
4524
|
case 34:
|
|
4486
|
-
syncResult =
|
|
4525
|
+
syncResult = _context41.sent;
|
|
4487
4526
|
case 35:
|
|
4488
|
-
return
|
|
4527
|
+
return _context41.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
|
|
4489
4528
|
draftResult: draftResult
|
|
4490
4529
|
} : {}), draftError !== undefined ? {
|
|
4491
4530
|
draftError: draftError
|
|
@@ -4494,11 +4533,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4494
4533
|
} : {}));
|
|
4495
4534
|
case 36:
|
|
4496
4535
|
case "end":
|
|
4497
|
-
return
|
|
4536
|
+
return _context41.stop();
|
|
4498
4537
|
}
|
|
4499
|
-
},
|
|
4538
|
+
}, _callee41, this, [[17, 23]]);
|
|
4500
4539
|
}));
|
|
4501
|
-
function updateOrderPayment(
|
|
4540
|
+
function updateOrderPayment(_x32, _x33) {
|
|
4502
4541
|
return _updateOrderPayment.apply(this, arguments);
|
|
4503
4542
|
}
|
|
4504
4543
|
return updateOrderPayment;
|
|
@@ -4520,24 +4559,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4520
4559
|
}, {
|
|
4521
4560
|
key: "updateVoucherOrderPaymentsAsync",
|
|
4522
4561
|
value: function () {
|
|
4523
|
-
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4524
|
-
return _regeneratorRuntime().wrap(function
|
|
4525
|
-
while (1) switch (
|
|
4562
|
+
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(payments, options) {
|
|
4563
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
4564
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
4526
4565
|
case 0:
|
|
4527
4566
|
if (this.store.order) {
|
|
4528
|
-
|
|
4567
|
+
_context42.next = 2;
|
|
4529
4568
|
break;
|
|
4530
4569
|
}
|
|
4531
4570
|
throw new Error('order 模块未初始化');
|
|
4532
4571
|
case 2:
|
|
4533
|
-
return
|
|
4572
|
+
return _context42.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
|
|
4534
4573
|
case 3:
|
|
4535
4574
|
case "end":
|
|
4536
|
-
return
|
|
4575
|
+
return _context42.stop();
|
|
4537
4576
|
}
|
|
4538
|
-
},
|
|
4577
|
+
}, _callee42, this);
|
|
4539
4578
|
}));
|
|
4540
|
-
function updateVoucherOrderPaymentsAsync(
|
|
4579
|
+
function updateVoucherOrderPaymentsAsync(_x34, _x35) {
|
|
4541
4580
|
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
4542
4581
|
}
|
|
4543
4582
|
return updateVoucherOrderPaymentsAsync;
|
|
@@ -4624,7 +4663,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4624
4663
|
}, {
|
|
4625
4664
|
key: "buildWalletInitBusinessData",
|
|
4626
4665
|
value: function buildWalletInitBusinessData(params) {
|
|
4627
|
-
var _this$store$order9, _params$order_wait_pa,
|
|
4666
|
+
var _this$store$order9, _params$order_wait_pa, _ref46, _tempOrder$is_price_i;
|
|
4628
4667
|
var snapshot = (_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 ? void 0 : _this$store$order9.getOrderSnapshot();
|
|
4629
4668
|
var tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
|
|
4630
4669
|
var amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
|
|
@@ -4640,7 +4679,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4640
4679
|
},
|
|
4641
4680
|
products: this.getWalletProductList(),
|
|
4642
4681
|
order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
|
|
4643
|
-
is_price_include_tax: (
|
|
4682
|
+
is_price_include_tax: (_ref46 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref46 !== void 0 ? _ref46 : 1
|
|
4644
4683
|
}, snapshot.identity.orderId ? {
|
|
4645
4684
|
payment_order_id: String(snapshot.identity.orderId)
|
|
4646
4685
|
} : {});
|
|
@@ -4648,20 +4687,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4648
4687
|
}, {
|
|
4649
4688
|
key: "initWalletData",
|
|
4650
4689
|
value: function () {
|
|
4651
|
-
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4690
|
+
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
4652
4691
|
var _snapshot$identity;
|
|
4653
4692
|
var snapshot, walletBusinessData, result;
|
|
4654
|
-
return _regeneratorRuntime().wrap(function
|
|
4655
|
-
while (1) switch (
|
|
4693
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4694
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
4656
4695
|
case 0:
|
|
4657
4696
|
if (this.store.order) {
|
|
4658
|
-
|
|
4697
|
+
_context43.next = 2;
|
|
4659
4698
|
break;
|
|
4660
4699
|
}
|
|
4661
4700
|
throw new Error('order 模块未初始化');
|
|
4662
4701
|
case 2:
|
|
4663
4702
|
if (this.store.payment) {
|
|
4664
|
-
|
|
4703
|
+
_context43.next = 4;
|
|
4665
4704
|
break;
|
|
4666
4705
|
}
|
|
4667
4706
|
throw new Error('payment 模块未初始化');
|
|
@@ -4669,10 +4708,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4669
4708
|
snapshot = this.store.order.getOrderSnapshot();
|
|
4670
4709
|
walletBusinessData = this.buildWalletInitBusinessData(params);
|
|
4671
4710
|
if (walletBusinessData) {
|
|
4672
|
-
|
|
4711
|
+
_context43.next = 8;
|
|
4673
4712
|
break;
|
|
4674
4713
|
}
|
|
4675
|
-
return
|
|
4714
|
+
return _context43.abrupt("return", {
|
|
4676
4715
|
walletRecommendList: [],
|
|
4677
4716
|
userIdentificationCodes: [],
|
|
4678
4717
|
transformList: [],
|
|
@@ -4680,11 +4719,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4680
4719
|
products: []
|
|
4681
4720
|
});
|
|
4682
4721
|
case 8:
|
|
4683
|
-
|
|
4722
|
+
_context43.next = 10;
|
|
4684
4723
|
return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
4685
4724
|
case 10:
|
|
4686
|
-
result =
|
|
4687
|
-
|
|
4725
|
+
result = _context43.sent;
|
|
4726
|
+
_context43.next = 13;
|
|
4688
4727
|
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
4689
4728
|
orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
|
|
4690
4729
|
customerId: walletBusinessData.customer_id,
|
|
@@ -4696,14 +4735,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4696
4735
|
timestamp: Date.now()
|
|
4697
4736
|
});
|
|
4698
4737
|
case 13:
|
|
4699
|
-
return
|
|
4738
|
+
return _context43.abrupt("return", result);
|
|
4700
4739
|
case 14:
|
|
4701
4740
|
case "end":
|
|
4702
|
-
return
|
|
4741
|
+
return _context43.stop();
|
|
4703
4742
|
}
|
|
4704
|
-
},
|
|
4743
|
+
}, _callee43, this);
|
|
4705
4744
|
}));
|
|
4706
|
-
function initWalletData(
|
|
4745
|
+
function initWalletData(_x36) {
|
|
4707
4746
|
return _initWalletData.apply(this, arguments);
|
|
4708
4747
|
}
|
|
4709
4748
|
return initWalletData;
|
|
@@ -4730,9 +4769,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4730
4769
|
var walletPassName = fundRecord.wallet_pass_name;
|
|
4731
4770
|
var title = walletPassName && _typeof(walletPassName) === 'object' ? walletPassName.default || Object.values(walletPassName)[0] : walletPassName;
|
|
4732
4771
|
var code = String((payment === null || payment === void 0 ? void 0 : payment.code) || '').toUpperCase();
|
|
4733
|
-
var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (
|
|
4734
|
-
var
|
|
4735
|
-
paymentCode =
|
|
4772
|
+
var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (_ref47) {
|
|
4773
|
+
var _ref48 = _slicedToArray(_ref47, 2),
|
|
4774
|
+
paymentCode = _ref48[1];
|
|
4736
4775
|
return paymentCode === code;
|
|
4737
4776
|
})) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0]) || fundRecord.tag;
|
|
4738
4777
|
return {
|
|
@@ -4754,27 +4793,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4754
4793
|
}, {
|
|
4755
4794
|
key: "publishWalletAssetsState",
|
|
4756
4795
|
value: function () {
|
|
4757
|
-
var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4796
|
+
var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(state) {
|
|
4758
4797
|
var changeSource,
|
|
4759
|
-
|
|
4760
|
-
return _regeneratorRuntime().wrap(function
|
|
4761
|
-
while (1) switch (
|
|
4798
|
+
_args44 = arguments;
|
|
4799
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4800
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
4762
4801
|
case 0:
|
|
4763
|
-
changeSource =
|
|
4764
|
-
|
|
4802
|
+
changeSource = _args44.length > 1 && _args44[1] !== undefined ? _args44[1] : 'derived';
|
|
4803
|
+
_context44.next = 3;
|
|
4765
4804
|
return this.effectsEmit(BaseSalesHookNames.onWalletAssetsStateChanged, {
|
|
4766
4805
|
state: state,
|
|
4767
4806
|
changeSource: changeSource
|
|
4768
4807
|
});
|
|
4769
4808
|
case 3:
|
|
4770
|
-
return
|
|
4809
|
+
return _context44.abrupt("return", state);
|
|
4771
4810
|
case 4:
|
|
4772
4811
|
case "end":
|
|
4773
|
-
return
|
|
4812
|
+
return _context44.stop();
|
|
4774
4813
|
}
|
|
4775
|
-
},
|
|
4814
|
+
}, _callee44, this);
|
|
4776
4815
|
}));
|
|
4777
|
-
function publishWalletAssetsState(
|
|
4816
|
+
function publishWalletAssetsState(_x37) {
|
|
4778
4817
|
return _publishWalletAssetsState.apply(this, arguments);
|
|
4779
4818
|
}
|
|
4780
4819
|
return publishWalletAssetsState;
|
|
@@ -4782,26 +4821,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4782
4821
|
}, {
|
|
4783
4822
|
key: "syncSelectedWalletAssets",
|
|
4784
4823
|
value: function () {
|
|
4785
|
-
var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4824
|
+
var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(state) {
|
|
4786
4825
|
var paymentMethods, methodByCode, preparePayments, selectedAssetById, voucherPayments, payments;
|
|
4787
|
-
return _regeneratorRuntime().wrap(function
|
|
4788
|
-
while (1) switch (
|
|
4826
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
4827
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4789
4828
|
case 0:
|
|
4790
4829
|
if (!(!this.store.order || !this.store.payment)) {
|
|
4791
|
-
|
|
4830
|
+
_context45.next = 2;
|
|
4792
4831
|
break;
|
|
4793
4832
|
}
|
|
4794
4833
|
throw new Error('订单或支付模块未初始化');
|
|
4795
4834
|
case 2:
|
|
4796
4835
|
paymentMethods = this.getPaymentMethods();
|
|
4797
4836
|
if (!(!paymentMethods.length && state.selectedItems.length)) {
|
|
4798
|
-
|
|
4837
|
+
_context45.next = 7;
|
|
4799
4838
|
break;
|
|
4800
4839
|
}
|
|
4801
|
-
|
|
4840
|
+
_context45.next = 6;
|
|
4802
4841
|
return this.getPaymentMethodsAsync();
|
|
4803
4842
|
case 6:
|
|
4804
|
-
paymentMethods =
|
|
4843
|
+
paymentMethods = _context45.sent;
|
|
4805
4844
|
case 7:
|
|
4806
4845
|
methodByCode = new Map(paymentMethods.map(function (method) {
|
|
4807
4846
|
return [String(method.code || '').toUpperCase(), method];
|
|
@@ -4843,19 +4882,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4843
4882
|
payments = this.updateVoucherOrderPayments(voucherPayments, {
|
|
4844
4883
|
status: 'payment_pending'
|
|
4845
4884
|
});
|
|
4846
|
-
|
|
4885
|
+
_context45.next = 14;
|
|
4847
4886
|
return this.store.order.recalculateSummary({
|
|
4848
4887
|
createIfMissing: true
|
|
4849
4888
|
});
|
|
4850
4889
|
case 14:
|
|
4851
|
-
return
|
|
4890
|
+
return _context45.abrupt("return", payments);
|
|
4852
4891
|
case 15:
|
|
4853
4892
|
case "end":
|
|
4854
|
-
return
|
|
4893
|
+
return _context45.stop();
|
|
4855
4894
|
}
|
|
4856
|
-
},
|
|
4895
|
+
}, _callee45, this);
|
|
4857
4896
|
}));
|
|
4858
|
-
function syncSelectedWalletAssets(
|
|
4897
|
+
function syncSelectedWalletAssets(_x38) {
|
|
4859
4898
|
return _syncSelectedWalletAssets.apply(this, arguments);
|
|
4860
4899
|
}
|
|
4861
4900
|
return syncSelectedWalletAssets;
|
|
@@ -4889,29 +4928,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4889
4928
|
}, {
|
|
4890
4929
|
key: "importWalletAssetsSnapshot",
|
|
4891
4930
|
value: (function () {
|
|
4892
|
-
var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4931
|
+
var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(snapshot) {
|
|
4893
4932
|
var state;
|
|
4894
|
-
return _regeneratorRuntime().wrap(function
|
|
4895
|
-
while (1) switch (
|
|
4933
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
4934
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4896
4935
|
case 0:
|
|
4897
4936
|
if (this.store.payment) {
|
|
4898
|
-
|
|
4937
|
+
_context46.next = 2;
|
|
4899
4938
|
break;
|
|
4900
4939
|
}
|
|
4901
4940
|
throw new Error('payment 模块未初始化');
|
|
4902
4941
|
case 2:
|
|
4903
4942
|
state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
|
|
4904
|
-
|
|
4943
|
+
_context46.next = 5;
|
|
4905
4944
|
return this.syncSelectedWalletAssets(state);
|
|
4906
4945
|
case 5:
|
|
4907
|
-
return
|
|
4946
|
+
return _context46.abrupt("return", this.publishWalletAssetsState(state));
|
|
4908
4947
|
case 6:
|
|
4909
4948
|
case "end":
|
|
4910
|
-
return
|
|
4949
|
+
return _context46.stop();
|
|
4911
4950
|
}
|
|
4912
|
-
},
|
|
4951
|
+
}, _callee46, this);
|
|
4913
4952
|
}));
|
|
4914
|
-
function importWalletAssetsSnapshot(
|
|
4953
|
+
function importWalletAssetsSnapshot(_x39) {
|
|
4915
4954
|
return _importWalletAssetsSnapshot.apply(this, arguments);
|
|
4916
4955
|
}
|
|
4917
4956
|
return importWalletAssetsSnapshot;
|
|
@@ -4923,20 +4962,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4923
4962
|
}, {
|
|
4924
4963
|
key: "refreshWalletAssets",
|
|
4925
4964
|
value: (function () {
|
|
4926
|
-
var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4965
|
+
var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
|
|
4927
4966
|
var _previousState$custom, _businessData$custome;
|
|
4928
4967
|
var refreshSequence, wallet, businessData, emptyState, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, committed;
|
|
4929
|
-
return _regeneratorRuntime().wrap(function
|
|
4930
|
-
while (1) switch (
|
|
4968
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
4969
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4931
4970
|
case 0:
|
|
4932
4971
|
if (this.store.order) {
|
|
4933
|
-
|
|
4972
|
+
_context47.next = 2;
|
|
4934
4973
|
break;
|
|
4935
4974
|
}
|
|
4936
4975
|
throw new Error('order 模块未初始化');
|
|
4937
4976
|
case 2:
|
|
4938
4977
|
if (this.store.payment) {
|
|
4939
|
-
|
|
4978
|
+
_context47.next = 4;
|
|
4940
4979
|
break;
|
|
4941
4980
|
}
|
|
4942
4981
|
throw new Error('payment 模块未初始化');
|
|
@@ -4945,7 +4984,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4945
4984
|
wallet = this.store.payment.wallet;
|
|
4946
4985
|
businessData = this.buildWalletInitBusinessData(params);
|
|
4947
4986
|
if (businessData) {
|
|
4948
|
-
|
|
4987
|
+
_context47.next = 12;
|
|
4949
4988
|
break;
|
|
4950
4989
|
}
|
|
4951
4990
|
wallet.clearAllCache();
|
|
@@ -4953,53 +4992,53 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4953
4992
|
this.updateVoucherOrderPayments([], {
|
|
4954
4993
|
status: 'payment_pending'
|
|
4955
4994
|
});
|
|
4956
|
-
return
|
|
4995
|
+
return _context47.abrupt("return", this.publishWalletAssetsState(emptyState));
|
|
4957
4996
|
case 12:
|
|
4958
4997
|
previousState = wallet.getWalletAssetsState();
|
|
4959
4998
|
hasPreviousWalletContext = previousState.status !== 'idle' || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== undefined;
|
|
4960
4999
|
customerChanged = hasPreviousWalletContext && String((_previousState$custom = previousState.customerId) !== null && _previousState$custom !== void 0 ? _previousState$custom : '') !== String((_businessData$custome = businessData.customer_id) !== null && _businessData$custome !== void 0 ? _businessData$custome : '');
|
|
4961
5000
|
if (!customerChanged) {
|
|
4962
|
-
|
|
5001
|
+
_context47.next = 20;
|
|
4963
5002
|
break;
|
|
4964
5003
|
}
|
|
4965
5004
|
clearedState = wallet.clearWalletAssetSelection();
|
|
4966
5005
|
this.updateVoucherOrderPayments([], {
|
|
4967
5006
|
status: 'payment_pending'
|
|
4968
5007
|
});
|
|
4969
|
-
|
|
5008
|
+
_context47.next = 20;
|
|
4970
5009
|
return this.publishWalletAssetsState(clearedState);
|
|
4971
5010
|
case 20:
|
|
4972
5011
|
refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
|
|
4973
5012
|
preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged
|
|
4974
5013
|
});
|
|
4975
|
-
|
|
5014
|
+
_context47.next = 23;
|
|
4976
5015
|
return this.publishWalletAssetsState(wallet.getWalletAssetsState());
|
|
4977
5016
|
case 23:
|
|
4978
|
-
|
|
5017
|
+
_context47.next = 25;
|
|
4979
5018
|
return refreshTask;
|
|
4980
5019
|
case 25:
|
|
4981
|
-
state =
|
|
5020
|
+
state = _context47.sent;
|
|
4982
5021
|
if (!(refreshSequence !== this.walletAssetsRefreshSequence)) {
|
|
4983
|
-
|
|
5022
|
+
_context47.next = 28;
|
|
4984
5023
|
break;
|
|
4985
5024
|
}
|
|
4986
|
-
return
|
|
5025
|
+
return _context47.abrupt("return", wallet.getWalletAssetsState());
|
|
4987
5026
|
case 28:
|
|
4988
5027
|
if (state.status !== 'error') {
|
|
4989
5028
|
committed = this.getCommittedWalletAssets();
|
|
4990
5029
|
state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4991
5030
|
}
|
|
4992
|
-
|
|
5031
|
+
_context47.next = 31;
|
|
4993
5032
|
return this.syncSelectedWalletAssets(state);
|
|
4994
5033
|
case 31:
|
|
4995
|
-
return
|
|
5034
|
+
return _context47.abrupt("return", this.publishWalletAssetsState(state));
|
|
4996
5035
|
case 32:
|
|
4997
5036
|
case "end":
|
|
4998
|
-
return
|
|
5037
|
+
return _context47.stop();
|
|
4999
5038
|
}
|
|
5000
|
-
},
|
|
5039
|
+
}, _callee47, this);
|
|
5001
5040
|
}));
|
|
5002
|
-
function refreshWalletAssets(
|
|
5041
|
+
function refreshWalletAssets(_x40) {
|
|
5003
5042
|
return _refreshWalletAssets.apply(this, arguments);
|
|
5004
5043
|
}
|
|
5005
5044
|
return refreshWalletAssets;
|
|
@@ -5007,13 +5046,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5007
5046
|
}, {
|
|
5008
5047
|
key: "selectWalletAsset",
|
|
5009
5048
|
value: (function () {
|
|
5010
|
-
var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5049
|
+
var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
|
|
5011
5050
|
var state;
|
|
5012
|
-
return _regeneratorRuntime().wrap(function
|
|
5013
|
-
while (1) switch (
|
|
5051
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
5052
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
5014
5053
|
case 0:
|
|
5015
5054
|
if (this.store.payment) {
|
|
5016
|
-
|
|
5055
|
+
_context48.next = 2;
|
|
5017
5056
|
break;
|
|
5018
5057
|
}
|
|
5019
5058
|
throw new Error('payment 模块未初始化');
|
|
@@ -5022,17 +5061,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5022
5061
|
selected: params.selected,
|
|
5023
5062
|
source: params.source
|
|
5024
5063
|
});
|
|
5025
|
-
|
|
5064
|
+
_context48.next = 5;
|
|
5026
5065
|
return this.syncSelectedWalletAssets(state);
|
|
5027
5066
|
case 5:
|
|
5028
|
-
return
|
|
5067
|
+
return _context48.abrupt("return", this.publishWalletAssetsState(state, 'local'));
|
|
5029
5068
|
case 6:
|
|
5030
5069
|
case "end":
|
|
5031
|
-
return
|
|
5070
|
+
return _context48.stop();
|
|
5032
5071
|
}
|
|
5033
|
-
},
|
|
5072
|
+
}, _callee48, this);
|
|
5034
5073
|
}));
|
|
5035
|
-
function selectWalletAsset(
|
|
5074
|
+
function selectWalletAsset(_x41) {
|
|
5036
5075
|
return _selectWalletAsset.apply(this, arguments);
|
|
5037
5076
|
}
|
|
5038
5077
|
return selectWalletAsset;
|
|
@@ -5040,29 +5079,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5040
5079
|
}, {
|
|
5041
5080
|
key: "updateWalletAssetAmount",
|
|
5042
5081
|
value: (function () {
|
|
5043
|
-
var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5082
|
+
var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
|
|
5044
5083
|
var state;
|
|
5045
|
-
return _regeneratorRuntime().wrap(function
|
|
5046
|
-
while (1) switch (
|
|
5084
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
5085
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
5047
5086
|
case 0:
|
|
5048
5087
|
if (this.store.payment) {
|
|
5049
|
-
|
|
5088
|
+
_context49.next = 2;
|
|
5050
5089
|
break;
|
|
5051
5090
|
}
|
|
5052
5091
|
throw new Error('payment 模块未初始化');
|
|
5053
5092
|
case 2:
|
|
5054
5093
|
state = this.store.payment.wallet.updateWalletAssetAmount(params.assetId, params.amount);
|
|
5055
|
-
|
|
5094
|
+
_context49.next = 5;
|
|
5056
5095
|
return this.syncSelectedWalletAssets(state);
|
|
5057
5096
|
case 5:
|
|
5058
|
-
return
|
|
5097
|
+
return _context49.abrupt("return", this.publishWalletAssetsState(state, 'local'));
|
|
5059
5098
|
case 6:
|
|
5060
5099
|
case "end":
|
|
5061
|
-
return
|
|
5100
|
+
return _context49.stop();
|
|
5062
5101
|
}
|
|
5063
|
-
},
|
|
5102
|
+
}, _callee49, this);
|
|
5064
5103
|
}));
|
|
5065
|
-
function updateWalletAssetAmount(
|
|
5104
|
+
function updateWalletAssetAmount(_x42) {
|
|
5066
5105
|
return _updateWalletAssetAmount.apply(this, arguments);
|
|
5067
5106
|
}
|
|
5068
5107
|
return updateWalletAssetAmount;
|
|
@@ -5070,13 +5109,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5070
5109
|
}, {
|
|
5071
5110
|
key: "scanWalletAsset",
|
|
5072
5111
|
value: (function () {
|
|
5073
|
-
var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5112
|
+
var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(code) {
|
|
5074
5113
|
var wallet, businessData, result;
|
|
5075
|
-
return _regeneratorRuntime().wrap(function
|
|
5076
|
-
while (1) switch (
|
|
5114
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
5115
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
5077
5116
|
case 0:
|
|
5078
5117
|
if (this.store.payment) {
|
|
5079
|
-
|
|
5118
|
+
_context50.next = 2;
|
|
5080
5119
|
break;
|
|
5081
5120
|
}
|
|
5082
5121
|
throw new Error('payment 模块未初始化');
|
|
@@ -5086,28 +5125,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5086
5125
|
if (businessData) {
|
|
5087
5126
|
wallet.generateWalletParams(businessData);
|
|
5088
5127
|
}
|
|
5089
|
-
|
|
5128
|
+
_context50.next = 7;
|
|
5090
5129
|
return wallet.scanWalletAssetAsync(code);
|
|
5091
5130
|
case 7:
|
|
5092
|
-
result =
|
|
5131
|
+
result = _context50.sent;
|
|
5093
5132
|
if (!(result.type === 'normalCode')) {
|
|
5094
|
-
|
|
5133
|
+
_context50.next = 13;
|
|
5095
5134
|
break;
|
|
5096
5135
|
}
|
|
5097
|
-
|
|
5136
|
+
_context50.next = 11;
|
|
5098
5137
|
return this.syncSelectedWalletAssets(result.state);
|
|
5099
5138
|
case 11:
|
|
5100
|
-
|
|
5139
|
+
_context50.next = 13;
|
|
5101
5140
|
return this.publishWalletAssetsState(result.state, 'local');
|
|
5102
5141
|
case 13:
|
|
5103
|
-
return
|
|
5142
|
+
return _context50.abrupt("return", result);
|
|
5104
5143
|
case 14:
|
|
5105
5144
|
case "end":
|
|
5106
|
-
return
|
|
5145
|
+
return _context50.stop();
|
|
5107
5146
|
}
|
|
5108
|
-
},
|
|
5147
|
+
}, _callee50, this);
|
|
5109
5148
|
}));
|
|
5110
|
-
function scanWalletAsset(
|
|
5149
|
+
function scanWalletAsset(_x43) {
|
|
5111
5150
|
return _scanWalletAsset.apply(this, arguments);
|
|
5112
5151
|
}
|
|
5113
5152
|
return scanWalletAsset;
|
|
@@ -5115,27 +5154,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5115
5154
|
}, {
|
|
5116
5155
|
key: "clearWalletAssetSelection",
|
|
5117
5156
|
value: (function () {
|
|
5118
|
-
var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5157
|
+
var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51() {
|
|
5119
5158
|
var state;
|
|
5120
|
-
return _regeneratorRuntime().wrap(function
|
|
5121
|
-
while (1) switch (
|
|
5159
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
5160
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
5122
5161
|
case 0:
|
|
5123
5162
|
if (this.store.payment) {
|
|
5124
|
-
|
|
5163
|
+
_context51.next = 2;
|
|
5125
5164
|
break;
|
|
5126
5165
|
}
|
|
5127
5166
|
throw new Error('payment 模块未初始化');
|
|
5128
5167
|
case 2:
|
|
5129
5168
|
state = this.store.payment.wallet.clearWalletAssetSelection();
|
|
5130
|
-
|
|
5169
|
+
_context51.next = 5;
|
|
5131
5170
|
return this.syncSelectedWalletAssets(state);
|
|
5132
5171
|
case 5:
|
|
5133
|
-
return
|
|
5172
|
+
return _context51.abrupt("return", this.publishWalletAssetsState(state, 'local'));
|
|
5134
5173
|
case 6:
|
|
5135
5174
|
case "end":
|
|
5136
|
-
return
|
|
5175
|
+
return _context51.stop();
|
|
5137
5176
|
}
|
|
5138
|
-
},
|
|
5177
|
+
}, _callee51, this);
|
|
5139
5178
|
}));
|
|
5140
5179
|
function clearWalletAssetSelection() {
|
|
5141
5180
|
return _clearWalletAssetSelection.apply(this, arguments);
|
|
@@ -5165,35 +5204,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5165
5204
|
}, {
|
|
5166
5205
|
key: "getPaymentMethodsAsync",
|
|
5167
5206
|
value: (function () {
|
|
5168
|
-
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5207
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52() {
|
|
5169
5208
|
var response, paymentMethods;
|
|
5170
|
-
return _regeneratorRuntime().wrap(function
|
|
5171
|
-
while (1) switch (
|
|
5209
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
5210
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
5172
5211
|
case 0:
|
|
5173
|
-
|
|
5174
|
-
|
|
5212
|
+
_context52.prev = 0;
|
|
5213
|
+
_context52.next = 3;
|
|
5175
5214
|
return this.request.get('/pay/custom-payment/all', {
|
|
5176
5215
|
filterPaymentMethods: true
|
|
5177
5216
|
}, {
|
|
5178
5217
|
osServer: true
|
|
5179
5218
|
});
|
|
5180
5219
|
case 3:
|
|
5181
|
-
response =
|
|
5220
|
+
response = _context52.sent;
|
|
5182
5221
|
paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
5183
5222
|
this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
|
|
5184
|
-
return
|
|
5223
|
+
return _context52.abrupt("return", this.getPaymentMethods());
|
|
5185
5224
|
case 9:
|
|
5186
|
-
|
|
5187
|
-
|
|
5225
|
+
_context52.prev = 9;
|
|
5226
|
+
_context52.t0 = _context52["catch"](0);
|
|
5188
5227
|
this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
|
|
5189
|
-
error:
|
|
5228
|
+
error: _context52.t0 instanceof Error ? _context52.t0.message : String(_context52.t0)
|
|
5190
5229
|
});
|
|
5191
|
-
return
|
|
5230
|
+
return _context52.abrupt("return", this.getPaymentMethods());
|
|
5192
5231
|
case 13:
|
|
5193
5232
|
case "end":
|
|
5194
|
-
return
|
|
5233
|
+
return _context52.stop();
|
|
5195
5234
|
}
|
|
5196
|
-
},
|
|
5235
|
+
}, _callee52, this, [[0, 9]]);
|
|
5197
5236
|
}));
|
|
5198
5237
|
function getPaymentMethodsAsync() {
|
|
5199
5238
|
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -5236,14 +5275,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5236
5275
|
}, {
|
|
5237
5276
|
key: "getCashPaymentConfig",
|
|
5238
5277
|
value: (function () {
|
|
5239
|
-
var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5278
|
+
var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
|
|
5240
5279
|
var _this$store$order12, _this$store$order12$g, _this$store$order13, _this$store$order13$g, _this$otherParams34;
|
|
5241
5280
|
var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
|
|
5242
|
-
return _regeneratorRuntime().wrap(function
|
|
5243
|
-
while (1) switch (
|
|
5281
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
5282
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
5244
5283
|
case 0:
|
|
5245
5284
|
if (this.store.payment) {
|
|
5246
|
-
|
|
5285
|
+
_context53.next = 2;
|
|
5247
5286
|
break;
|
|
5248
5287
|
}
|
|
5249
5288
|
throw new Error('payment 模块未初始化');
|
|
@@ -5251,13 +5290,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5251
5290
|
paymentMethods = this.getPaymentMethods();
|
|
5252
5291
|
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
5253
5292
|
if (paymentMethod) {
|
|
5254
|
-
|
|
5293
|
+
_context53.next = 9;
|
|
5255
5294
|
break;
|
|
5256
5295
|
}
|
|
5257
|
-
|
|
5296
|
+
_context53.next = 7;
|
|
5258
5297
|
return this.getPaymentMethodsAsync();
|
|
5259
5298
|
case 7:
|
|
5260
|
-
paymentMethods =
|
|
5299
|
+
paymentMethods = _context53.sent;
|
|
5261
5300
|
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
5262
5301
|
case 9:
|
|
5263
5302
|
amountSnapshot = (_this$store$order12 = this.store.order) === null || _this$store$order12 === void 0 || (_this$store$order12$g = _this$store$order12.getOrderAmountSnapshot) === null || _this$store$order12$g === void 0 ? void 0 : _this$store$order12$g.call(_this$store$order12);
|
|
@@ -5265,7 +5304,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5265
5304
|
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
|
|
5266
5305
|
currency = ((_this$store$order13 = this.store.order) === null || _this$store$order13 === void 0 || (_this$store$order13$g = _this$store$order13.getTempOrder) === null || _this$store$order13$g === void 0 || (_this$store$order13$g = _this$store$order13$g.call(_this$store$order13)) === null || _this$store$order13$g === void 0 ? void 0 : _this$store$order13$g.currency_code) || ((_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.currency) || 'USD';
|
|
5267
5306
|
recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
|
|
5268
|
-
return
|
|
5307
|
+
return _context53.abrupt("return", {
|
|
5269
5308
|
available: Boolean(paymentMethod && amountDue > 0),
|
|
5270
5309
|
paymentMethod: paymentMethod,
|
|
5271
5310
|
amountDue: amountDue,
|
|
@@ -5273,9 +5312,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5273
5312
|
});
|
|
5274
5313
|
case 15:
|
|
5275
5314
|
case "end":
|
|
5276
|
-
return
|
|
5315
|
+
return _context53.stop();
|
|
5277
5316
|
}
|
|
5278
|
-
},
|
|
5317
|
+
}, _callee53, this);
|
|
5279
5318
|
}));
|
|
5280
5319
|
function getCashPaymentConfig() {
|
|
5281
5320
|
return _getCashPaymentConfig.apply(this, arguments);
|
|
@@ -5292,14 +5331,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5292
5331
|
}, {
|
|
5293
5332
|
key: "confirmWalletPayment",
|
|
5294
5333
|
value: (function () {
|
|
5295
|
-
var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5334
|
+
var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
|
|
5296
5335
|
var _this$store$order$get3, _this$store$order14, _this$store$order$get5, _this$store$order$get6, _this$store$order16;
|
|
5297
5336
|
var beforePayments, pendingWalletAmount, amountSnapshot, _this$store$order$get4, _this$store$order15, _submitResult, _latestAmountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
|
|
5298
|
-
return _regeneratorRuntime().wrap(function
|
|
5299
|
-
while (1) switch (
|
|
5337
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5338
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
5300
5339
|
case 0:
|
|
5301
5340
|
if (this.store.order) {
|
|
5302
|
-
|
|
5341
|
+
_context54.next = 2;
|
|
5303
5342
|
break;
|
|
5304
5343
|
}
|
|
5305
5344
|
throw new Error('order 模块未初始化');
|
|
@@ -5308,26 +5347,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5308
5347
|
pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
|
|
5309
5348
|
amountSnapshot = (_this$store$order$get3 = (_this$store$order14 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order14);
|
|
5310
5349
|
if (!pendingWalletAmount.lte(0)) {
|
|
5311
|
-
|
|
5350
|
+
_context54.next = 14;
|
|
5312
5351
|
break;
|
|
5313
5352
|
}
|
|
5314
5353
|
this.logWarning('confirmWalletPayment: 未发现待确认 Wallet 支付,跳过 Wallet 确认并按普通订单提交', {
|
|
5315
5354
|
amountGap: amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap
|
|
5316
5355
|
});
|
|
5317
|
-
|
|
5356
|
+
_context54.next = 9;
|
|
5318
5357
|
return this.submitSalesOrder({
|
|
5319
5358
|
smallTicketDataFlag: 1
|
|
5320
5359
|
});
|
|
5321
5360
|
case 9:
|
|
5322
|
-
_submitResult =
|
|
5361
|
+
_submitResult = _context54.sent;
|
|
5323
5362
|
if (!isRejectedSalesSubmitResult(_submitResult)) {
|
|
5324
|
-
|
|
5363
|
+
_context54.next = 12;
|
|
5325
5364
|
break;
|
|
5326
5365
|
}
|
|
5327
5366
|
throw new Error(getSalesSubmitErrorMessage(_submitResult, '订单提交失败'));
|
|
5328
5367
|
case 12:
|
|
5329
5368
|
_latestAmountSnapshot = (_this$store$order$get4 = (_this$store$order15 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.call(_this$store$order15);
|
|
5330
|
-
return
|
|
5369
|
+
return _context54.abrupt("return", {
|
|
5331
5370
|
submitResult: _submitResult,
|
|
5332
5371
|
payments: this.store.order.getOrderPayments(),
|
|
5333
5372
|
isOrderFullyPaid: new Decimal((_latestAmountSnapshot === null || _latestAmountSnapshot === void 0 ? void 0 : _latestAmountSnapshot.amountGap) || 0).lte(0)
|
|
@@ -5335,74 +5374,74 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5335
5374
|
case 14:
|
|
5336
5375
|
effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
5337
5376
|
if (!effectiveAmountDue.gt(0.01)) {
|
|
5338
|
-
|
|
5377
|
+
_context54.next = 17;
|
|
5339
5378
|
break;
|
|
5340
5379
|
}
|
|
5341
5380
|
throw new Error('Wallet 支付尚未覆盖全部待支付金额');
|
|
5342
5381
|
case 17:
|
|
5343
5382
|
beforePaymentStatus = (_this$store$order$get5 = this.store.order.getTempOrder()) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.payment_status;
|
|
5344
|
-
|
|
5345
|
-
|
|
5383
|
+
_context54.prev = 18;
|
|
5384
|
+
_context54.next = 21;
|
|
5346
5385
|
return this.submitSalesOrder({
|
|
5347
5386
|
smallTicketDataFlag: 1,
|
|
5348
5387
|
confirmPendingVoucherPayments: true
|
|
5349
5388
|
});
|
|
5350
5389
|
case 21:
|
|
5351
|
-
submitResult =
|
|
5390
|
+
submitResult = _context54.sent;
|
|
5352
5391
|
if (!isRejectedSalesSubmitResult(submitResult)) {
|
|
5353
|
-
|
|
5392
|
+
_context54.next = 24;
|
|
5354
5393
|
break;
|
|
5355
5394
|
}
|
|
5356
5395
|
throw new Error(getSalesSubmitErrorMessage(submitResult, 'Wallet 支付确认失败'));
|
|
5357
5396
|
case 24:
|
|
5358
|
-
|
|
5397
|
+
_context54.next = 34;
|
|
5359
5398
|
break;
|
|
5360
5399
|
case 26:
|
|
5361
|
-
|
|
5362
|
-
|
|
5400
|
+
_context54.prev = 26;
|
|
5401
|
+
_context54.t0 = _context54["catch"](18);
|
|
5363
5402
|
this.store.order.setOrderPayments(beforePayments);
|
|
5364
5403
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
5365
5404
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
5366
5405
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
5367
5406
|
this.store.order.persistTempOrder();
|
|
5368
5407
|
}
|
|
5369
|
-
|
|
5408
|
+
_context54.next = 33;
|
|
5370
5409
|
return this.store.order.recalculateSummary({
|
|
5371
5410
|
createIfMissing: true
|
|
5372
5411
|
});
|
|
5373
5412
|
case 33:
|
|
5374
|
-
throw
|
|
5413
|
+
throw _context54.t0;
|
|
5375
5414
|
case 34:
|
|
5376
5415
|
if (!this.store.payment) {
|
|
5377
|
-
|
|
5416
|
+
_context54.next = 45;
|
|
5378
5417
|
break;
|
|
5379
5418
|
}
|
|
5380
|
-
|
|
5419
|
+
_context54.prev = 35;
|
|
5381
5420
|
committed = this.getCommittedWalletAssets();
|
|
5382
5421
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
5383
|
-
|
|
5422
|
+
_context54.next = 40;
|
|
5384
5423
|
return this.publishWalletAssetsState(walletState, 'local');
|
|
5385
5424
|
case 40:
|
|
5386
|
-
|
|
5425
|
+
_context54.next = 45;
|
|
5387
5426
|
break;
|
|
5388
5427
|
case 42:
|
|
5389
|
-
|
|
5390
|
-
|
|
5428
|
+
_context54.prev = 42;
|
|
5429
|
+
_context54.t1 = _context54["catch"](35);
|
|
5391
5430
|
this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
|
|
5392
|
-
error:
|
|
5431
|
+
error: _context54.t1 instanceof Error ? _context54.t1.message : String(_context54.t1)
|
|
5393
5432
|
});
|
|
5394
5433
|
case 45:
|
|
5395
5434
|
latestAmountSnapshot = (_this$store$order$get6 = (_this$store$order16 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get6 === void 0 ? void 0 : _this$store$order$get6.call(_this$store$order16);
|
|
5396
|
-
return
|
|
5435
|
+
return _context54.abrupt("return", {
|
|
5397
5436
|
submitResult: submitResult,
|
|
5398
5437
|
payments: this.store.order.getOrderPayments(),
|
|
5399
5438
|
isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
|
|
5400
5439
|
});
|
|
5401
5440
|
case 47:
|
|
5402
5441
|
case "end":
|
|
5403
|
-
return
|
|
5442
|
+
return _context54.stop();
|
|
5404
5443
|
}
|
|
5405
|
-
},
|
|
5444
|
+
}, _callee54, this, [[18, 26], [35, 42]]);
|
|
5406
5445
|
}));
|
|
5407
5446
|
function confirmWalletPayment() {
|
|
5408
5447
|
return _confirmWalletPayment.apply(this, arguments);
|
|
@@ -5417,38 +5456,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5417
5456
|
}, {
|
|
5418
5457
|
key: "payCash",
|
|
5419
5458
|
value: (function () {
|
|
5420
|
-
var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5459
|
+
var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
|
|
5421
5460
|
var _this$store$order$get7, _params$actualPaidAmo, _this$otherParams35, _this$window, _this$window$postMess;
|
|
5422
5461
|
var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
5423
|
-
return _regeneratorRuntime().wrap(function
|
|
5424
|
-
while (1) switch (
|
|
5462
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5463
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
5425
5464
|
case 0:
|
|
5426
5465
|
if (this.store.order) {
|
|
5427
|
-
|
|
5466
|
+
_context55.next = 2;
|
|
5428
5467
|
break;
|
|
5429
5468
|
}
|
|
5430
5469
|
throw new Error('order 模块未初始化');
|
|
5431
5470
|
case 2:
|
|
5432
5471
|
amount = Number(params.amount || 0);
|
|
5433
5472
|
if (!(!Number.isFinite(amount) || amount <= 0)) {
|
|
5434
|
-
|
|
5473
|
+
_context55.next = 5;
|
|
5435
5474
|
break;
|
|
5436
5475
|
}
|
|
5437
5476
|
throw new Error('现金支付金额必须大于 0');
|
|
5438
5477
|
case 5:
|
|
5439
|
-
|
|
5478
|
+
_context55.next = 7;
|
|
5440
5479
|
return this.getCashPaymentConfig();
|
|
5441
5480
|
case 7:
|
|
5442
|
-
config =
|
|
5481
|
+
config = _context55.sent;
|
|
5443
5482
|
paymentMethod = config.paymentMethod;
|
|
5444
5483
|
if (paymentMethod) {
|
|
5445
|
-
|
|
5484
|
+
_context55.next = 11;
|
|
5446
5485
|
break;
|
|
5447
5486
|
}
|
|
5448
5487
|
throw new Error('未找到可用的 CASHMANUAL 支付方式');
|
|
5449
5488
|
case 11:
|
|
5450
5489
|
if (!(config.amountDue <= 0)) {
|
|
5451
|
-
|
|
5490
|
+
_context55.next = 13;
|
|
5452
5491
|
break;
|
|
5453
5492
|
}
|
|
5454
5493
|
throw new Error('当前订单没有待支付金额');
|
|
@@ -5456,7 +5495,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5456
5495
|
roundingAmount = Number(params.roundingAmount || 0);
|
|
5457
5496
|
effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
|
|
5458
5497
|
if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
|
|
5459
|
-
|
|
5498
|
+
_context55.next = 17;
|
|
5460
5499
|
break;
|
|
5461
5500
|
}
|
|
5462
5501
|
throw new Error('现金支付金额超过当前待支付金额');
|
|
@@ -5469,7 +5508,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5469
5508
|
changeAmount = Number(params.changeAmount || 0);
|
|
5470
5509
|
shopWalletPassId = (_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35.shop_wallet_pass_id;
|
|
5471
5510
|
if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
|
|
5472
|
-
|
|
5511
|
+
_context55.next = 26;
|
|
5473
5512
|
break;
|
|
5474
5513
|
}
|
|
5475
5514
|
throw new Error('顾客实收现金不能小于支付金额');
|
|
@@ -5504,8 +5543,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5504
5543
|
var _item$metadata2;
|
|
5505
5544
|
return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
|
|
5506
5545
|
});
|
|
5507
|
-
|
|
5508
|
-
|
|
5546
|
+
_context55.prev = 29;
|
|
5547
|
+
_context55.next = 32;
|
|
5509
5548
|
return this.syncPaymentsToOrder({
|
|
5510
5549
|
payments: payments,
|
|
5511
5550
|
submitWhenPaid: true,
|
|
@@ -5513,50 +5552,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5513
5552
|
confirmPendingVoucherPayments: true
|
|
5514
5553
|
});
|
|
5515
5554
|
case 32:
|
|
5516
|
-
syncResult =
|
|
5555
|
+
syncResult = _context55.sent;
|
|
5517
5556
|
if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
|
|
5518
|
-
|
|
5557
|
+
_context55.next = 35;
|
|
5519
5558
|
break;
|
|
5520
5559
|
}
|
|
5521
5560
|
throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
|
|
5522
5561
|
case 35:
|
|
5523
5562
|
if (!this.store.payment) {
|
|
5524
|
-
|
|
5563
|
+
_context55.next = 40;
|
|
5525
5564
|
break;
|
|
5526
5565
|
}
|
|
5527
5566
|
committed = this.getCommittedWalletAssets();
|
|
5528
5567
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
5529
|
-
|
|
5568
|
+
_context55.next = 40;
|
|
5530
5569
|
return this.publishWalletAssetsState(walletState, 'local');
|
|
5531
5570
|
case 40:
|
|
5532
|
-
return
|
|
5571
|
+
return _context55.abrupt("return", {
|
|
5533
5572
|
payment: payment || {},
|
|
5534
5573
|
payments: this.store.order.getOrderPayments(),
|
|
5535
5574
|
syncResult: syncResult,
|
|
5536
5575
|
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
5537
5576
|
});
|
|
5538
5577
|
case 43:
|
|
5539
|
-
|
|
5540
|
-
|
|
5578
|
+
_context55.prev = 43;
|
|
5579
|
+
_context55.t0 = _context55["catch"](29);
|
|
5541
5580
|
this.store.order.setOrderPayments(beforePayments);
|
|
5542
5581
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
5543
5582
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
5544
5583
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
5545
5584
|
this.store.order.persistTempOrder();
|
|
5546
5585
|
}
|
|
5547
|
-
|
|
5586
|
+
_context55.next = 50;
|
|
5548
5587
|
return this.store.order.recalculateSummary({
|
|
5549
5588
|
createIfMissing: true
|
|
5550
5589
|
});
|
|
5551
5590
|
case 50:
|
|
5552
|
-
throw
|
|
5591
|
+
throw _context55.t0;
|
|
5553
5592
|
case 51:
|
|
5554
5593
|
case "end":
|
|
5555
|
-
return
|
|
5594
|
+
return _context55.stop();
|
|
5556
5595
|
}
|
|
5557
|
-
},
|
|
5596
|
+
}, _callee55, this, [[29, 43]]);
|
|
5558
5597
|
}));
|
|
5559
|
-
function payCash(
|
|
5598
|
+
function payCash(_x44) {
|
|
5560
5599
|
return _payCash.apply(this, arguments);
|
|
5561
5600
|
}
|
|
5562
5601
|
return payCash;
|
|
@@ -5572,21 +5611,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5572
5611
|
}, {
|
|
5573
5612
|
key: "commitPaymentMethodPayment",
|
|
5574
5613
|
value: (function () {
|
|
5575
|
-
var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5614
|
+
var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
|
|
5576
5615
|
var _this$store$order$get8, _this$store$order17, _this$store$order$get9, _params$metadata, _params$originAmount;
|
|
5577
5616
|
var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
5578
|
-
return _regeneratorRuntime().wrap(function
|
|
5579
|
-
while (1) switch (
|
|
5617
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
5618
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
5580
5619
|
case 0:
|
|
5581
5620
|
if (this.store.order) {
|
|
5582
|
-
|
|
5621
|
+
_context56.next = 2;
|
|
5583
5622
|
break;
|
|
5584
5623
|
}
|
|
5585
5624
|
throw new Error('order 模块未初始化');
|
|
5586
5625
|
case 2:
|
|
5587
5626
|
amount = Number(params.amount || 0);
|
|
5588
5627
|
if (!(!Number.isFinite(amount) || amount <= 0)) {
|
|
5589
|
-
|
|
5628
|
+
_context56.next = 5;
|
|
5590
5629
|
break;
|
|
5591
5630
|
}
|
|
5592
5631
|
throw new Error('支付金额必须大于 0');
|
|
@@ -5602,17 +5641,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5602
5641
|
};
|
|
5603
5642
|
paymentMethod = findPaymentMethod();
|
|
5604
5643
|
if (paymentMethod) {
|
|
5605
|
-
|
|
5644
|
+
_context56.next = 13;
|
|
5606
5645
|
break;
|
|
5607
5646
|
}
|
|
5608
|
-
|
|
5647
|
+
_context56.next = 11;
|
|
5609
5648
|
return this.getPaymentMethodsAsync();
|
|
5610
5649
|
case 11:
|
|
5611
|
-
paymentMethods =
|
|
5650
|
+
paymentMethods = _context56.sent;
|
|
5612
5651
|
paymentMethod = findPaymentMethod();
|
|
5613
5652
|
case 13:
|
|
5614
5653
|
if (paymentMethod) {
|
|
5615
|
-
|
|
5654
|
+
_context56.next = 15;
|
|
5616
5655
|
break;
|
|
5617
5656
|
}
|
|
5618
5657
|
throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
|
|
@@ -5621,13 +5660,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5621
5660
|
pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
5622
5661
|
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
5623
5662
|
if (!amountDue.lte(0)) {
|
|
5624
|
-
|
|
5663
|
+
_context56.next = 20;
|
|
5625
5664
|
break;
|
|
5626
5665
|
}
|
|
5627
5666
|
throw new Error('当前订单没有待支付金额');
|
|
5628
5667
|
case 20:
|
|
5629
5668
|
if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
|
|
5630
|
-
|
|
5669
|
+
_context56.next = 22;
|
|
5631
5670
|
break;
|
|
5632
5671
|
}
|
|
5633
5672
|
throw new Error('支付金额超过当前待支付金额');
|
|
@@ -5666,8 +5705,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5666
5705
|
var _item$metadata3;
|
|
5667
5706
|
return (item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.unique_payment_number) === metadata.unique_payment_number;
|
|
5668
5707
|
});
|
|
5669
|
-
|
|
5670
|
-
|
|
5708
|
+
_context56.prev = 30;
|
|
5709
|
+
_context56.next = 33;
|
|
5671
5710
|
return this.syncPaymentsToOrder({
|
|
5672
5711
|
payments: payments,
|
|
5673
5712
|
submitWhenPaid: true,
|
|
@@ -5675,50 +5714,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5675
5714
|
confirmPendingVoucherPayments: true
|
|
5676
5715
|
});
|
|
5677
5716
|
case 33:
|
|
5678
|
-
syncResult =
|
|
5717
|
+
syncResult = _context56.sent;
|
|
5679
5718
|
if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
|
|
5680
|
-
|
|
5719
|
+
_context56.next = 36;
|
|
5681
5720
|
break;
|
|
5682
5721
|
}
|
|
5683
5722
|
throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
|
|
5684
5723
|
case 36:
|
|
5685
5724
|
if (!this.store.payment) {
|
|
5686
|
-
|
|
5725
|
+
_context56.next = 41;
|
|
5687
5726
|
break;
|
|
5688
5727
|
}
|
|
5689
5728
|
committed = this.getCommittedWalletAssets();
|
|
5690
5729
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
5691
|
-
|
|
5730
|
+
_context56.next = 41;
|
|
5692
5731
|
return this.publishWalletAssetsState(walletState, 'local');
|
|
5693
5732
|
case 41:
|
|
5694
|
-
return
|
|
5733
|
+
return _context56.abrupt("return", {
|
|
5695
5734
|
payment: payment || {},
|
|
5696
5735
|
payments: this.store.order.getOrderPayments(),
|
|
5697
5736
|
syncResult: syncResult,
|
|
5698
5737
|
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
5699
5738
|
});
|
|
5700
5739
|
case 44:
|
|
5701
|
-
|
|
5702
|
-
|
|
5740
|
+
_context56.prev = 44;
|
|
5741
|
+
_context56.t0 = _context56["catch"](30);
|
|
5703
5742
|
this.store.order.setOrderPayments(beforePayments);
|
|
5704
5743
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
5705
5744
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
5706
5745
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
5707
5746
|
this.store.order.persistTempOrder();
|
|
5708
5747
|
}
|
|
5709
|
-
|
|
5748
|
+
_context56.next = 51;
|
|
5710
5749
|
return this.store.order.recalculateSummary({
|
|
5711
5750
|
createIfMissing: true
|
|
5712
5751
|
});
|
|
5713
5752
|
case 51:
|
|
5714
|
-
throw
|
|
5753
|
+
throw _context56.t0;
|
|
5715
5754
|
case 52:
|
|
5716
5755
|
case "end":
|
|
5717
|
-
return
|
|
5756
|
+
return _context56.stop();
|
|
5718
5757
|
}
|
|
5719
|
-
},
|
|
5758
|
+
}, _callee56, this, [[30, 44]]);
|
|
5720
5759
|
}));
|
|
5721
|
-
function commitPaymentMethodPayment(
|
|
5760
|
+
function commitPaymentMethodPayment(_x45) {
|
|
5722
5761
|
return _commitPaymentMethodPayment.apply(this, arguments);
|
|
5723
5762
|
}
|
|
5724
5763
|
return commitPaymentMethodPayment;
|
|
@@ -5733,40 +5772,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5733
5772
|
}, {
|
|
5734
5773
|
key: "roundAmount",
|
|
5735
5774
|
value: (function () {
|
|
5736
|
-
var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5775
|
+
var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
|
|
5737
5776
|
var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
|
|
5738
5777
|
var amount, cashManualPayment;
|
|
5739
|
-
return _regeneratorRuntime().wrap(function
|
|
5740
|
-
while (1) switch (
|
|
5778
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5779
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
5741
5780
|
case 0:
|
|
5742
5781
|
amount = params.amount;
|
|
5743
5782
|
cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
|
|
5744
5783
|
return paymentMethod.code === 'CASHMANUAL';
|
|
5745
5784
|
});
|
|
5746
5785
|
if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
|
|
5747
|
-
|
|
5786
|
+
_context57.next = 4;
|
|
5748
5787
|
break;
|
|
5749
5788
|
}
|
|
5750
|
-
return
|
|
5789
|
+
return _context57.abrupt("return", {
|
|
5751
5790
|
originalAmount: amount.toString(),
|
|
5752
5791
|
roundedAmount: amount.toString(),
|
|
5753
5792
|
roundingDifference: '0.00'
|
|
5754
5793
|
});
|
|
5755
5794
|
case 4:
|
|
5756
5795
|
if (this.payment) {
|
|
5757
|
-
|
|
5796
|
+
_context57.next = 6;
|
|
5758
5797
|
break;
|
|
5759
5798
|
}
|
|
5760
5799
|
throw new Error('payment 模块未初始化');
|
|
5761
5800
|
case 6:
|
|
5762
|
-
return
|
|
5801
|
+
return _context57.abrupt("return", this.payment.roundAmountAsync(amount, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.interval, (_this$otherParams$ord3 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord3 === void 0 ? void 0 : _this$otherParams$ord3.type));
|
|
5763
5802
|
case 7:
|
|
5764
5803
|
case "end":
|
|
5765
|
-
return
|
|
5804
|
+
return _context57.stop();
|
|
5766
5805
|
}
|
|
5767
|
-
},
|
|
5806
|
+
}, _callee57, this);
|
|
5768
5807
|
}));
|
|
5769
|
-
function roundAmount(
|
|
5808
|
+
function roundAmount(_x46) {
|
|
5770
5809
|
return _roundAmount.apply(this, arguments);
|
|
5771
5810
|
}
|
|
5772
5811
|
return roundAmount;
|
|
@@ -5781,49 +5820,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5781
5820
|
}, {
|
|
5782
5821
|
key: "sendCustomerPayLink",
|
|
5783
5822
|
value: (function () {
|
|
5784
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5785
|
-
var orderIds,
|
|
5786
|
-
return _regeneratorRuntime().wrap(function
|
|
5787
|
-
while (1) switch (
|
|
5823
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
|
|
5824
|
+
var orderIds, _ref49, _ref50, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
5825
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
5826
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
5788
5827
|
case 0:
|
|
5789
5828
|
if (this.store.order) {
|
|
5790
|
-
|
|
5829
|
+
_context58.next = 2;
|
|
5791
5830
|
break;
|
|
5792
5831
|
}
|
|
5793
5832
|
throw new Error('order 模块未初始化');
|
|
5794
5833
|
case 2:
|
|
5795
5834
|
orderIds = params.order_ids || params.orderIds || [];
|
|
5796
5835
|
if (!(!orderIds.length || params.submitBeforeSend)) {
|
|
5797
|
-
|
|
5836
|
+
_context58.next = 11;
|
|
5798
5837
|
break;
|
|
5799
5838
|
}
|
|
5800
|
-
|
|
5839
|
+
_context58.next = 6;
|
|
5801
5840
|
return this.submitSalesOrder({
|
|
5802
5841
|
smallTicketDataFlag: 1
|
|
5803
5842
|
});
|
|
5804
5843
|
case 6:
|
|
5805
|
-
submitResult =
|
|
5806
|
-
orderId = (
|
|
5844
|
+
submitResult = _context58.sent;
|
|
5845
|
+
orderId = (_ref49 = (_ref50 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref50 !== void 0 ? _ref50 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref49 !== void 0 ? _ref49 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
5807
5846
|
if (orderId) {
|
|
5808
|
-
|
|
5847
|
+
_context58.next = 10;
|
|
5809
5848
|
break;
|
|
5810
5849
|
}
|
|
5811
5850
|
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
5812
5851
|
case 10:
|
|
5813
5852
|
orderIds = [orderId];
|
|
5814
5853
|
case 11:
|
|
5815
|
-
return
|
|
5854
|
+
return _context58.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
5816
5855
|
emails: params.emails,
|
|
5817
5856
|
notify_action: params.notify_action,
|
|
5818
5857
|
order_ids: orderIds
|
|
5819
5858
|
}));
|
|
5820
5859
|
case 12:
|
|
5821
5860
|
case "end":
|
|
5822
|
-
return
|
|
5861
|
+
return _context58.stop();
|
|
5823
5862
|
}
|
|
5824
|
-
},
|
|
5863
|
+
}, _callee58, this);
|
|
5825
5864
|
}));
|
|
5826
|
-
function sendCustomerPayLink(
|
|
5865
|
+
function sendCustomerPayLink(_x47) {
|
|
5827
5866
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
5828
5867
|
}
|
|
5829
5868
|
return sendCustomerPayLink;
|
|
@@ -5836,20 +5875,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5836
5875
|
}, {
|
|
5837
5876
|
key: "calculateProductBookingPrice",
|
|
5838
5877
|
value: function () {
|
|
5839
|
-
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5878
|
+
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
|
|
5840
5879
|
var _params$customer_id;
|
|
5841
5880
|
var useCustomerUserPricing, quotation, customerId, channel, _yield$this$resolvePr, _yield$this$resolvePr2, authoritativeProduct, product;
|
|
5842
|
-
return _regeneratorRuntime().wrap(function
|
|
5843
|
-
while (1) switch (
|
|
5881
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context59) {
|
|
5882
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
5844
5883
|
case 0:
|
|
5845
5884
|
useCustomerUserPricing = this.isCustomerUserPriceQuery();
|
|
5846
5885
|
quotation = useCustomerUserPricing ? undefined : this.store.quotation;
|
|
5847
5886
|
customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
|
|
5848
|
-
|
|
5887
|
+
_context59.next = 5;
|
|
5849
5888
|
return this.prepareProductPriceQueryContext(customerId);
|
|
5850
5889
|
case 5:
|
|
5851
5890
|
channel = this.getPriceQueryChannel(params.channel);
|
|
5852
|
-
|
|
5891
|
+
_context59.next = 8;
|
|
5853
5892
|
return this.resolveProductsForPriceQuery({
|
|
5854
5893
|
priceQueries: [params],
|
|
5855
5894
|
schedule: this.getPriceQuerySchedule(params),
|
|
@@ -5857,22 +5896,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5857
5896
|
channel: channel
|
|
5858
5897
|
});
|
|
5859
5898
|
case 8:
|
|
5860
|
-
_yield$this$resolvePr =
|
|
5899
|
+
_yield$this$resolvePr = _context59.sent;
|
|
5861
5900
|
_yield$this$resolvePr2 = _slicedToArray(_yield$this$resolvePr, 1);
|
|
5862
5901
|
authoritativeProduct = _yield$this$resolvePr2[0];
|
|
5863
5902
|
product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
5864
5903
|
if (useCustomerUserPricing) {
|
|
5865
|
-
|
|
5904
|
+
_context59.next = 15;
|
|
5866
5905
|
break;
|
|
5867
5906
|
}
|
|
5868
|
-
|
|
5907
|
+
_context59.next = 15;
|
|
5869
5908
|
return this.loadQuotationForPriceQuery({
|
|
5870
5909
|
quotation: quotation,
|
|
5871
5910
|
customer_id: customerId,
|
|
5872
5911
|
channel: channel
|
|
5873
5912
|
});
|
|
5874
5913
|
case 15:
|
|
5875
|
-
return
|
|
5914
|
+
return _context59.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
5876
5915
|
channel: channel,
|
|
5877
5916
|
product: product,
|
|
5878
5917
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
@@ -5881,11 +5920,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5881
5920
|
})));
|
|
5882
5921
|
case 16:
|
|
5883
5922
|
case "end":
|
|
5884
|
-
return
|
|
5923
|
+
return _context59.stop();
|
|
5885
5924
|
}
|
|
5886
|
-
},
|
|
5925
|
+
}, _callee59, this);
|
|
5887
5926
|
}));
|
|
5888
|
-
function calculateProductBookingPrice(
|
|
5927
|
+
function calculateProductBookingPrice(_x48) {
|
|
5889
5928
|
return _calculateProductBookingPrice.apply(this, arguments);
|
|
5890
5929
|
}
|
|
5891
5930
|
return calculateProductBookingPrice;
|
|
@@ -5893,7 +5932,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5893
5932
|
}, {
|
|
5894
5933
|
key: "getQuotationCustomerScopeInfo",
|
|
5895
5934
|
value: function getQuotationCustomerScopeInfo() {
|
|
5896
|
-
var
|
|
5935
|
+
var _this18 = this;
|
|
5897
5936
|
var quotation = this.store.quotation;
|
|
5898
5937
|
if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
|
|
5899
5938
|
return quotation.getQuotationCustomerScopeInfo();
|
|
@@ -5905,7 +5944,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5905
5944
|
}).map(function (item) {
|
|
5906
5945
|
var localSeen = new Set();
|
|
5907
5946
|
var customers = item.customer.filter(function (customer) {
|
|
5908
|
-
var customerId =
|
|
5947
|
+
var customerId = _this18.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
|
|
5909
5948
|
if (!customerId || localSeen.has(customerId)) return false;
|
|
5910
5949
|
localSeen.add(customerId);
|
|
5911
5950
|
if (!customerById.has(customerId)) customerById.set(customerId, customer);
|
|
@@ -5932,8 +5971,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5932
5971
|
}, {
|
|
5933
5972
|
key: "hasSmartPricingStrategies",
|
|
5934
5973
|
value: function hasSmartPricingStrategies() {
|
|
5935
|
-
var _this$
|
|
5936
|
-
var evaluator = (_this$
|
|
5974
|
+
var _this$core5;
|
|
5975
|
+
var evaluator = (_this$core5 = this.core) === null || _this$core5 === void 0 || (_this$core5 = _this$core5.context) === null || _this$core5 === void 0 ? void 0 : _this$core5.dataVariantEvaluator;
|
|
5937
5976
|
if (!evaluator || typeof evaluator.getStrategyConfigs !== 'function') {
|
|
5938
5977
|
return false;
|
|
5939
5978
|
}
|
|
@@ -5969,23 +6008,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5969
6008
|
}, {
|
|
5970
6009
|
key: "calculateProductBookingPrices",
|
|
5971
6010
|
value: function () {
|
|
5972
|
-
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5973
|
-
var
|
|
6011
|
+
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(paramsList) {
|
|
6012
|
+
var _this19 = this;
|
|
5974
6013
|
var useCustomerUserPricing, quotation, currentOrderCustomerId, resolvedChannels, authoritativeProducts, groups, quotationContexts;
|
|
5975
|
-
return _regeneratorRuntime().wrap(function
|
|
5976
|
-
while (1) switch (
|
|
6014
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
6015
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
5977
6016
|
case 0:
|
|
5978
6017
|
if (paramsList.length) {
|
|
5979
|
-
|
|
6018
|
+
_context61.next = 2;
|
|
5980
6019
|
break;
|
|
5981
6020
|
}
|
|
5982
|
-
return
|
|
6021
|
+
return _context61.abrupt("return", []);
|
|
5983
6022
|
case 2:
|
|
5984
6023
|
useCustomerUserPricing = this.isCustomerUserPriceQuery();
|
|
5985
6024
|
quotation = useCustomerUserPricing ? undefined : this.store.quotation;
|
|
5986
6025
|
currentOrderCustomerId = this.getCurrentOrderCustomerId();
|
|
5987
6026
|
resolvedChannels = paramsList.map(function (params) {
|
|
5988
|
-
return
|
|
6027
|
+
return _this19.getPriceQueryChannel(params.channel);
|
|
5989
6028
|
});
|
|
5990
6029
|
authoritativeProducts = paramsList.map(function () {
|
|
5991
6030
|
return null;
|
|
@@ -5993,10 +6032,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5993
6032
|
groups = new Map();
|
|
5994
6033
|
paramsList.forEach(function (params, index) {
|
|
5995
6034
|
var _params$customer_id2;
|
|
5996
|
-
var schedule =
|
|
6035
|
+
var schedule = _this19.getPriceQuerySchedule(params);
|
|
5997
6036
|
var channel = resolvedChannels[index];
|
|
5998
6037
|
var customerId = (_params$customer_id2 = params.customer_id) !== null && _params$customer_id2 !== void 0 ? _params$customer_id2 : currentOrderCustomerId;
|
|
5999
|
-
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || '',
|
|
6038
|
+
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || '', _this19.normalizePriceContextCustomerId(customerId) || ''].join('|');
|
|
6000
6039
|
var group = groups.get(groupKey) || {
|
|
6001
6040
|
indices: [],
|
|
6002
6041
|
schedule: schedule,
|
|
@@ -6006,44 +6045,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6006
6045
|
group.indices.push(index);
|
|
6007
6046
|
groups.set(groupKey, group);
|
|
6008
6047
|
});
|
|
6009
|
-
|
|
6048
|
+
_context61.next = 11;
|
|
6010
6049
|
return Promise.all(Array.from(groups.values()).map( /*#__PURE__*/function () {
|
|
6011
|
-
var
|
|
6050
|
+
var _ref51 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(group) {
|
|
6012
6051
|
var priceQueries, resolvedProducts;
|
|
6013
|
-
return _regeneratorRuntime().wrap(function
|
|
6014
|
-
while (1) switch (
|
|
6052
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
6053
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
6015
6054
|
case 0:
|
|
6016
|
-
|
|
6017
|
-
return
|
|
6055
|
+
_context60.next = 2;
|
|
6056
|
+
return _this19.prepareProductPriceQueryContext(group.customerId);
|
|
6018
6057
|
case 2:
|
|
6019
6058
|
priceQueries = group.indices.map(function (index) {
|
|
6020
6059
|
return paramsList[index];
|
|
6021
6060
|
});
|
|
6022
|
-
|
|
6023
|
-
return
|
|
6061
|
+
_context60.next = 5;
|
|
6062
|
+
return _this19.resolveProductsForPriceQuery({
|
|
6024
6063
|
priceQueries: priceQueries,
|
|
6025
6064
|
schedule: group.schedule,
|
|
6026
6065
|
customerId: group.customerId,
|
|
6027
6066
|
channel: group.channel
|
|
6028
6067
|
});
|
|
6029
6068
|
case 5:
|
|
6030
|
-
resolvedProducts =
|
|
6069
|
+
resolvedProducts = _context60.sent;
|
|
6031
6070
|
group.indices.forEach(function (originalIndex, groupIndex) {
|
|
6032
6071
|
authoritativeProducts[originalIndex] = resolvedProducts[groupIndex] || null;
|
|
6033
6072
|
});
|
|
6034
6073
|
case 7:
|
|
6035
6074
|
case "end":
|
|
6036
|
-
return
|
|
6075
|
+
return _context60.stop();
|
|
6037
6076
|
}
|
|
6038
|
-
},
|
|
6077
|
+
}, _callee60);
|
|
6039
6078
|
}));
|
|
6040
|
-
return function (
|
|
6041
|
-
return
|
|
6079
|
+
return function (_x50) {
|
|
6080
|
+
return _ref51.apply(this, arguments);
|
|
6042
6081
|
};
|
|
6043
6082
|
}()));
|
|
6044
6083
|
case 11:
|
|
6045
6084
|
if (useCustomerUserPricing) {
|
|
6046
|
-
|
|
6085
|
+
_context61.next = 16;
|
|
6047
6086
|
break;
|
|
6048
6087
|
}
|
|
6049
6088
|
quotationContexts = new Map();
|
|
@@ -6057,18 +6096,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6057
6096
|
customer_id: (_params$customer_id3 = params.customer_id) !== null && _params$customer_id3 !== void 0 ? _params$customer_id3 : currentOrderCustomerId
|
|
6058
6097
|
});
|
|
6059
6098
|
});
|
|
6060
|
-
|
|
6099
|
+
_context61.next = 16;
|
|
6061
6100
|
return Promise.all(Array.from(quotationContexts.values()).map(function (context) {
|
|
6062
|
-
return
|
|
6101
|
+
return _this19.loadQuotationForPriceQuery(_objectSpread({
|
|
6063
6102
|
quotation: quotation
|
|
6064
6103
|
}, context));
|
|
6065
6104
|
}));
|
|
6066
6105
|
case 16:
|
|
6067
|
-
return
|
|
6106
|
+
return _context61.abrupt("return", paramsList.map(function (params, index) {
|
|
6068
6107
|
var _params$customer_id4;
|
|
6069
6108
|
var productInput = params.product || {};
|
|
6070
6109
|
var authoritativeProduct = authoritativeProducts[index];
|
|
6071
|
-
var product =
|
|
6110
|
+
var product = _this19.mergeProductForPriceQuery(productInput, authoritativeProduct);
|
|
6072
6111
|
var customerId = (_params$customer_id4 = params.customer_id) !== null && _params$customer_id4 !== void 0 ? _params$customer_id4 : currentOrderCustomerId;
|
|
6073
6112
|
var channel = resolvedChannels[index];
|
|
6074
6113
|
return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -6076,16 +6115,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6076
6115
|
product: product,
|
|
6077
6116
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
6078
6117
|
customer_id: customerId,
|
|
6079
|
-
quotation: authoritativeProduct &&
|
|
6118
|
+
quotation: authoritativeProduct && _this19.preferAuthoritativeProductQueryPrice() ? undefined : quotation
|
|
6080
6119
|
}));
|
|
6081
6120
|
}));
|
|
6082
6121
|
case 17:
|
|
6083
6122
|
case "end":
|
|
6084
|
-
return
|
|
6123
|
+
return _context61.stop();
|
|
6085
6124
|
}
|
|
6086
|
-
},
|
|
6125
|
+
}, _callee61, this);
|
|
6087
6126
|
}));
|
|
6088
|
-
function calculateProductBookingPrices(
|
|
6127
|
+
function calculateProductBookingPrices(_x49) {
|
|
6089
6128
|
return _calculateProductBookingPrices.apply(this, arguments);
|
|
6090
6129
|
}
|
|
6091
6130
|
return calculateProductBookingPrices;
|
|
@@ -6093,42 +6132,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6093
6132
|
}, {
|
|
6094
6133
|
key: "addProductToOrder",
|
|
6095
6134
|
value: function () {
|
|
6096
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6097
|
-
var products;
|
|
6098
|
-
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
6099
|
-
while (1) switch (_context61.prev = _context61.next) {
|
|
6100
|
-
case 0:
|
|
6101
|
-
_context61.prev = 0;
|
|
6102
|
-
if (this.store.order) {
|
|
6103
|
-
_context61.next = 3;
|
|
6104
|
-
break;
|
|
6105
|
-
}
|
|
6106
|
-
throw new Error('order 模块未初始化');
|
|
6107
|
-
case 3:
|
|
6108
|
-
_context61.next = 5;
|
|
6109
|
-
return this.store.order.addProductToOrder(product, booking, options);
|
|
6110
|
-
case 5:
|
|
6111
|
-
products = _context61.sent;
|
|
6112
|
-
return _context61.abrupt("return", products);
|
|
6113
|
-
case 9:
|
|
6114
|
-
_context61.prev = 9;
|
|
6115
|
-
_context61.t0 = _context61["catch"](0);
|
|
6116
|
-
throw _context61.t0;
|
|
6117
|
-
case 12:
|
|
6118
|
-
case "end":
|
|
6119
|
-
return _context61.stop();
|
|
6120
|
-
}
|
|
6121
|
-
}, _callee61, this, [[0, 9]]);
|
|
6122
|
-
}));
|
|
6123
|
-
function addProductToOrder(_x50, _x51, _x52) {
|
|
6124
|
-
return _addProductToOrder.apply(this, arguments);
|
|
6125
|
-
}
|
|
6126
|
-
return addProductToOrder;
|
|
6127
|
-
}()
|
|
6128
|
-
}, {
|
|
6129
|
-
key: "updateOrderProduct",
|
|
6130
|
-
value: function () {
|
|
6131
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
|
|
6135
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(product, booking, options) {
|
|
6132
6136
|
var products;
|
|
6133
6137
|
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
6134
6138
|
while (1) switch (_context62.prev = _context62.next) {
|
|
@@ -6141,7 +6145,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6141
6145
|
throw new Error('order 模块未初始化');
|
|
6142
6146
|
case 3:
|
|
6143
6147
|
_context62.next = 5;
|
|
6144
|
-
return this.store.order.
|
|
6148
|
+
return this.store.order.addProductToOrder(product, booking, options);
|
|
6145
6149
|
case 5:
|
|
6146
6150
|
products = _context62.sent;
|
|
6147
6151
|
return _context62.abrupt("return", products);
|
|
@@ -6155,15 +6159,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6155
6159
|
}
|
|
6156
6160
|
}, _callee62, this, [[0, 9]]);
|
|
6157
6161
|
}));
|
|
6158
|
-
function
|
|
6159
|
-
return
|
|
6162
|
+
function addProductToOrder(_x51, _x52, _x53) {
|
|
6163
|
+
return _addProductToOrder.apply(this, arguments);
|
|
6160
6164
|
}
|
|
6161
|
-
return
|
|
6165
|
+
return addProductToOrder;
|
|
6162
6166
|
}()
|
|
6163
6167
|
}, {
|
|
6164
|
-
key: "
|
|
6168
|
+
key: "updateOrderProduct",
|
|
6165
6169
|
value: function () {
|
|
6166
|
-
var
|
|
6170
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
|
|
6167
6171
|
var products;
|
|
6168
6172
|
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
6169
6173
|
while (1) switch (_context63.prev = _context63.next) {
|
|
@@ -6176,7 +6180,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6176
6180
|
throw new Error('order 模块未初始化');
|
|
6177
6181
|
case 3:
|
|
6178
6182
|
_context63.next = 5;
|
|
6179
|
-
return this.store.order.
|
|
6183
|
+
return this.store.order.updateOrderProduct(params);
|
|
6180
6184
|
case 5:
|
|
6181
6185
|
products = _context63.sent;
|
|
6182
6186
|
return _context63.abrupt("return", products);
|
|
@@ -6190,15 +6194,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6190
6194
|
}
|
|
6191
6195
|
}, _callee63, this, [[0, 9]]);
|
|
6192
6196
|
}));
|
|
6193
|
-
function
|
|
6194
|
-
return
|
|
6197
|
+
function updateOrderProduct(_x54) {
|
|
6198
|
+
return _updateOrderProduct.apply(this, arguments);
|
|
6195
6199
|
}
|
|
6196
|
-
return
|
|
6200
|
+
return updateOrderProduct;
|
|
6197
6201
|
}()
|
|
6198
6202
|
}, {
|
|
6199
|
-
key: "
|
|
6203
|
+
key: "updateOrderProducts",
|
|
6200
6204
|
value: function () {
|
|
6201
|
-
var
|
|
6205
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(paramsList) {
|
|
6202
6206
|
var products;
|
|
6203
6207
|
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
6204
6208
|
while (1) switch (_context64.prev = _context64.next) {
|
|
@@ -6211,7 +6215,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6211
6215
|
throw new Error('order 模块未初始化');
|
|
6212
6216
|
case 3:
|
|
6213
6217
|
_context64.next = 5;
|
|
6214
|
-
return this.store.order.
|
|
6218
|
+
return this.store.order.updateOrderProducts(paramsList);
|
|
6215
6219
|
case 5:
|
|
6216
6220
|
products = _context64.sent;
|
|
6217
6221
|
return _context64.abrupt("return", products);
|
|
@@ -6225,7 +6229,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6225
6229
|
}
|
|
6226
6230
|
}, _callee64, this, [[0, 9]]);
|
|
6227
6231
|
}));
|
|
6228
|
-
function
|
|
6232
|
+
function updateOrderProducts(_x55) {
|
|
6233
|
+
return _updateOrderProducts.apply(this, arguments);
|
|
6234
|
+
}
|
|
6235
|
+
return updateOrderProducts;
|
|
6236
|
+
}()
|
|
6237
|
+
}, {
|
|
6238
|
+
key: "updateOrderProductQuantity",
|
|
6239
|
+
value: function () {
|
|
6240
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(params) {
|
|
6241
|
+
var products;
|
|
6242
|
+
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
6243
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
6244
|
+
case 0:
|
|
6245
|
+
_context65.prev = 0;
|
|
6246
|
+
if (this.store.order) {
|
|
6247
|
+
_context65.next = 3;
|
|
6248
|
+
break;
|
|
6249
|
+
}
|
|
6250
|
+
throw new Error('order 模块未初始化');
|
|
6251
|
+
case 3:
|
|
6252
|
+
_context65.next = 5;
|
|
6253
|
+
return this.store.order.updateOrderProductQuantity(params);
|
|
6254
|
+
case 5:
|
|
6255
|
+
products = _context65.sent;
|
|
6256
|
+
return _context65.abrupt("return", products);
|
|
6257
|
+
case 9:
|
|
6258
|
+
_context65.prev = 9;
|
|
6259
|
+
_context65.t0 = _context65["catch"](0);
|
|
6260
|
+
throw _context65.t0;
|
|
6261
|
+
case 12:
|
|
6262
|
+
case "end":
|
|
6263
|
+
return _context65.stop();
|
|
6264
|
+
}
|
|
6265
|
+
}, _callee65, this, [[0, 9]]);
|
|
6266
|
+
}));
|
|
6267
|
+
function updateOrderProductQuantity(_x56) {
|
|
6229
6268
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
6230
6269
|
}
|
|
6231
6270
|
return updateOrderProductQuantity;
|
|
@@ -6248,12 +6287,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6248
6287
|
}, {
|
|
6249
6288
|
key: "setOrderProductLineNote",
|
|
6250
6289
|
value: (function () {
|
|
6251
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6290
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(identity, note) {
|
|
6252
6291
|
var params, products;
|
|
6253
|
-
return _regeneratorRuntime().wrap(function
|
|
6254
|
-
while (1) switch (
|
|
6292
|
+
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
6293
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
6255
6294
|
case 0:
|
|
6256
|
-
|
|
6295
|
+
_context66.prev = 0;
|
|
6257
6296
|
params = {
|
|
6258
6297
|
product_id: identity.product_id,
|
|
6259
6298
|
product_variant_id: identity.product_variant_id,
|
|
@@ -6268,22 +6307,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6268
6307
|
params.product_sku = identity.product_sku;
|
|
6269
6308
|
}
|
|
6270
6309
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
6271
|
-
|
|
6310
|
+
_context66.next = 7;
|
|
6272
6311
|
return this.updateOrderProduct(params);
|
|
6273
6312
|
case 7:
|
|
6274
|
-
products =
|
|
6275
|
-
return
|
|
6313
|
+
products = _context66.sent;
|
|
6314
|
+
return _context66.abrupt("return", products);
|
|
6276
6315
|
case 11:
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
throw
|
|
6316
|
+
_context66.prev = 11;
|
|
6317
|
+
_context66.t0 = _context66["catch"](0);
|
|
6318
|
+
throw _context66.t0;
|
|
6280
6319
|
case 14:
|
|
6281
6320
|
case "end":
|
|
6282
|
-
return
|
|
6321
|
+
return _context66.stop();
|
|
6283
6322
|
}
|
|
6284
|
-
},
|
|
6323
|
+
}, _callee66, this, [[0, 11]]);
|
|
6285
6324
|
}));
|
|
6286
|
-
function setOrderProductLineNote(
|
|
6325
|
+
function setOrderProductLineNote(_x57, _x58) {
|
|
6287
6326
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
6288
6327
|
}
|
|
6289
6328
|
return setOrderProductLineNote;
|
|
@@ -6298,32 +6337,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6298
6337
|
}, {
|
|
6299
6338
|
key: "removeProductsFromOrder",
|
|
6300
6339
|
value: (function () {
|
|
6301
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6302
|
-
return _regeneratorRuntime().wrap(function
|
|
6303
|
-
while (1) switch (
|
|
6340
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(identities, options) {
|
|
6341
|
+
return _regeneratorRuntime().wrap(function _callee67$(_context67) {
|
|
6342
|
+
while (1) switch (_context67.prev = _context67.next) {
|
|
6304
6343
|
case 0:
|
|
6305
|
-
|
|
6344
|
+
_context67.prev = 0;
|
|
6306
6345
|
if (this.store.order) {
|
|
6307
|
-
|
|
6346
|
+
_context67.next = 3;
|
|
6308
6347
|
break;
|
|
6309
6348
|
}
|
|
6310
6349
|
throw new Error('order 模块未初始化');
|
|
6311
6350
|
case 3:
|
|
6312
|
-
|
|
6351
|
+
_context67.next = 5;
|
|
6313
6352
|
return this.store.order.removeProductsFromOrder(identities, options);
|
|
6314
6353
|
case 5:
|
|
6315
|
-
return
|
|
6354
|
+
return _context67.abrupt("return", _context67.sent);
|
|
6316
6355
|
case 8:
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
throw
|
|
6356
|
+
_context67.prev = 8;
|
|
6357
|
+
_context67.t0 = _context67["catch"](0);
|
|
6358
|
+
throw _context67.t0;
|
|
6320
6359
|
case 11:
|
|
6321
6360
|
case "end":
|
|
6322
|
-
return
|
|
6361
|
+
return _context67.stop();
|
|
6323
6362
|
}
|
|
6324
|
-
},
|
|
6363
|
+
}, _callee67, this, [[0, 8]]);
|
|
6325
6364
|
}));
|
|
6326
|
-
function removeProductsFromOrder(
|
|
6365
|
+
function removeProductsFromOrder(_x59, _x60) {
|
|
6327
6366
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
6328
6367
|
}
|
|
6329
6368
|
return removeProductsFromOrder;
|
|
@@ -6331,18 +6370,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6331
6370
|
}, {
|
|
6332
6371
|
key: "removeProductFromOrder",
|
|
6333
6372
|
value: function () {
|
|
6334
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6335
|
-
return _regeneratorRuntime().wrap(function
|
|
6336
|
-
while (1) switch (
|
|
6373
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(identity, options) {
|
|
6374
|
+
return _regeneratorRuntime().wrap(function _callee68$(_context68) {
|
|
6375
|
+
while (1) switch (_context68.prev = _context68.next) {
|
|
6337
6376
|
case 0:
|
|
6338
|
-
return
|
|
6377
|
+
return _context68.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
6339
6378
|
case 1:
|
|
6340
6379
|
case "end":
|
|
6341
|
-
return
|
|
6380
|
+
return _context68.stop();
|
|
6342
6381
|
}
|
|
6343
|
-
},
|
|
6382
|
+
}, _callee68, this);
|
|
6344
6383
|
}));
|
|
6345
|
-
function removeProductFromOrder(
|
|
6384
|
+
function removeProductFromOrder(_x61, _x62) {
|
|
6346
6385
|
return _removeProductFromOrder.apply(this, arguments);
|
|
6347
6386
|
}
|
|
6348
6387
|
return removeProductFromOrder;
|
|
@@ -6392,23 +6431,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6392
6431
|
}, {
|
|
6393
6432
|
key: "applyPromotion",
|
|
6394
6433
|
value: (function () {
|
|
6395
|
-
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6396
|
-
return _regeneratorRuntime().wrap(function
|
|
6397
|
-
while (1) switch (
|
|
6434
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69() {
|
|
6435
|
+
return _regeneratorRuntime().wrap(function _callee69$(_context69) {
|
|
6436
|
+
while (1) switch (_context69.prev = _context69.next) {
|
|
6398
6437
|
case 0:
|
|
6399
6438
|
if (this.store.order) {
|
|
6400
|
-
|
|
6439
|
+
_context69.next = 2;
|
|
6401
6440
|
break;
|
|
6402
6441
|
}
|
|
6403
6442
|
throw new Error('order 模块未初始化');
|
|
6404
6443
|
case 2:
|
|
6405
|
-
|
|
6444
|
+
_context69.next = 4;
|
|
6406
6445
|
return this.store.order.applyPromotion();
|
|
6407
6446
|
case 4:
|
|
6408
6447
|
case "end":
|
|
6409
|
-
return
|
|
6448
|
+
return _context69.stop();
|
|
6410
6449
|
}
|
|
6411
|
-
},
|
|
6450
|
+
}, _callee69, this);
|
|
6412
6451
|
}));
|
|
6413
6452
|
function applyPromotion() {
|
|
6414
6453
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -6435,18 +6474,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6435
6474
|
}, {
|
|
6436
6475
|
key: "getProductList",
|
|
6437
6476
|
value: function () {
|
|
6438
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6477
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70() {
|
|
6439
6478
|
var _this$otherParams36;
|
|
6440
6479
|
var menu_list_ids, _this$store$products, res;
|
|
6441
|
-
return _regeneratorRuntime().wrap(function
|
|
6442
|
-
while (1) switch (
|
|
6480
|
+
return _regeneratorRuntime().wrap(function _callee70$(_context70) {
|
|
6481
|
+
while (1) switch (_context70.prev = _context70.next) {
|
|
6443
6482
|
case 0:
|
|
6444
6483
|
// 可以直接通过配置里的 menu 读取
|
|
6445
6484
|
menu_list_ids = ((_this$otherParams36 = this.otherParams) === null || _this$otherParams36 === void 0 || (_this$otherParams36 = _this$otherParams36.dineInConfig) === null || _this$otherParams36 === void 0 ? void 0 : _this$otherParams36['menu.associated_menus'].map(function (n) {
|
|
6446
6485
|
return Number(n.value);
|
|
6447
6486
|
})) || [];
|
|
6448
|
-
|
|
6449
|
-
|
|
6487
|
+
_context70.prev = 1;
|
|
6488
|
+
_context70.next = 4;
|
|
6450
6489
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
6451
6490
|
menu_list_ids: menu_list_ids,
|
|
6452
6491
|
cacheId: this.cacheId,
|
|
@@ -6454,17 +6493,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6454
6493
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
6455
6494
|
});
|
|
6456
6495
|
case 4:
|
|
6457
|
-
res =
|
|
6458
|
-
return
|
|
6496
|
+
res = _context70.sent;
|
|
6497
|
+
return _context70.abrupt("return", res);
|
|
6459
6498
|
case 8:
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
throw
|
|
6499
|
+
_context70.prev = 8;
|
|
6500
|
+
_context70.t0 = _context70["catch"](1);
|
|
6501
|
+
throw _context70.t0;
|
|
6463
6502
|
case 11:
|
|
6464
6503
|
case "end":
|
|
6465
|
-
return
|
|
6504
|
+
return _context70.stop();
|
|
6466
6505
|
}
|
|
6467
|
-
},
|
|
6506
|
+
}, _callee70, this, [[1, 8]]);
|
|
6468
6507
|
}));
|
|
6469
6508
|
function getProductList() {
|
|
6470
6509
|
return _getProductList.apply(this, arguments);
|
|
@@ -6479,33 +6518,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6479
6518
|
}, {
|
|
6480
6519
|
key: "setOtherParams",
|
|
6481
6520
|
value: function () {
|
|
6482
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6521
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(params) {
|
|
6483
6522
|
var _this$otherParams37;
|
|
6484
|
-
var
|
|
6485
|
-
|
|
6523
|
+
var _ref52,
|
|
6524
|
+
_ref52$cover,
|
|
6486
6525
|
cover,
|
|
6487
|
-
|
|
6488
|
-
return _regeneratorRuntime().wrap(function
|
|
6489
|
-
while (1) switch (
|
|
6526
|
+
_args71 = arguments;
|
|
6527
|
+
return _regeneratorRuntime().wrap(function _callee71$(_context71) {
|
|
6528
|
+
while (1) switch (_context71.prev = _context71.next) {
|
|
6490
6529
|
case 0:
|
|
6491
|
-
|
|
6530
|
+
_ref52 = _args71.length > 1 && _args71[1] !== undefined ? _args71[1] : {}, _ref52$cover = _ref52.cover, cover = _ref52$cover === void 0 ? false : _ref52$cover;
|
|
6492
6531
|
if (cover) {
|
|
6493
6532
|
this.otherParams = _objectSpread({}, params);
|
|
6494
6533
|
} else {
|
|
6495
6534
|
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
6496
6535
|
}
|
|
6497
6536
|
this.cacheId = (_this$otherParams37 = this.otherParams) === null || _this$otherParams37 === void 0 ? void 0 : _this$otherParams37.cacheId;
|
|
6498
|
-
|
|
6537
|
+
_context71.next = 5;
|
|
6499
6538
|
return this.syncOtherParamsToSubModules(params, {
|
|
6500
6539
|
cover: cover
|
|
6501
6540
|
});
|
|
6502
6541
|
case 5:
|
|
6503
6542
|
case "end":
|
|
6504
|
-
return
|
|
6543
|
+
return _context71.stop();
|
|
6505
6544
|
}
|
|
6506
|
-
},
|
|
6545
|
+
}, _callee71, this);
|
|
6507
6546
|
}));
|
|
6508
|
-
function setOtherParams(
|
|
6547
|
+
function setOtherParams(_x63) {
|
|
6509
6548
|
return _setOtherParams.apply(this, arguments);
|
|
6510
6549
|
}
|
|
6511
6550
|
return setOtherParams;
|