@pisell/pisellos 2.3.67 → 2.3.69
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/walletPass/evaluator.js +0 -1
- package/dist/model/strategy/adapter/walletPass/utils.js +0 -2
- package/dist/modules/BaseModule.d.ts +1 -0
- package/dist/modules/BaseModule.js +24 -28
- package/dist/modules/Customer/index.d.ts +4 -0
- package/dist/modules/Customer/index.js +91 -59
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Order/index.d.ts +22 -2
- package/dist/modules/Order/index.js +313 -142
- package/dist/modules/Order/types.d.ts +13 -1
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +75 -0
- package/dist/modules/Order/utils.js +0 -1
- package/dist/modules/Payment/index.d.ts +4 -0
- package/dist/modules/Payment/index.js +14 -4
- package/dist/modules/Payment/walletpass.js +52 -18
- package/dist/modules/Rules/index.js +46 -31
- package/dist/server/index.js +3 -6
- package/dist/server/modules/order/index.d.ts +1 -0
- package/dist/server/modules/order/index.js +252 -93
- package/dist/server/utils/small-ticket.js +2 -1
- package/dist/solution/BaseSales/index.d.ts +13 -1
- package/dist/solution/BaseSales/index.js +903 -831
- package/dist/solution/BaseSales/utils.js +31 -20
- package/dist/solution/BookingTicket/index.d.ts +7 -1
- package/dist/solution/BookingTicket/index.js +310 -224
- package/dist/solution/ScanOrder/utils.js +31 -20
- package/dist/solution/UnifiedBookingSales/index.d.ts +25 -0
- package/dist/solution/UnifiedBookingSales/index.js +640 -321
- package/dist/solution/UnifiedBookingSales/types.d.ts +7 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -1
- package/lib/model/strategy/adapter/walletPass/utils.js +0 -1
- package/lib/modules/BaseModule.d.ts +1 -0
- package/lib/modules/BaseModule.js +24 -37
- package/lib/modules/Customer/index.d.ts +4 -0
- package/lib/modules/Customer/index.js +11 -0
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Order/index.d.ts +22 -2
- package/lib/modules/Order/index.js +212 -54
- package/lib/modules/Order/types.d.ts +13 -1
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +70 -0
- package/lib/modules/Order/utils.js +0 -1
- package/lib/modules/Payment/index.d.ts +4 -0
- package/lib/modules/Payment/index.js +7 -0
- package/lib/modules/Payment/walletpass.js +27 -2
- package/lib/modules/Rules/index.js +17 -1
- package/lib/server/index.js +3 -6
- package/lib/server/modules/order/index.d.ts +1 -0
- package/lib/server/modules/order/index.js +66 -2
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +13 -1
- package/lib/solution/BaseSales/index.js +61 -18
- package/lib/solution/BaseSales/utils.js +29 -18
- package/lib/solution/BookingTicket/index.d.ts +7 -1
- package/lib/solution/BookingTicket/index.js +65 -14
- package/lib/solution/ScanOrder/utils.js +29 -18
- package/lib/solution/UnifiedBookingSales/index.d.ts +25 -0
- package/lib/solution/UnifiedBookingSales/index.js +188 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +7 -0
- package/package.json +1 -1
|
@@ -669,7 +669,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
669
669
|
}, {
|
|
670
670
|
key: "hydrateLatestLoadedSalesDetail",
|
|
671
671
|
value: function () {
|
|
672
|
-
var _hydrateLatestLoadedSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(record, loadSequence) {
|
|
672
|
+
var _hydrateLatestLoadedSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(record, loadSequence, hydrateSource) {
|
|
673
673
|
var _this4 = this;
|
|
674
674
|
var hydratedSales, skippedBeforeHydrate, hydrateTask, queuedTask;
|
|
675
675
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
@@ -697,7 +697,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
697
697
|
throw new Error('order 模块未初始化');
|
|
698
698
|
case 5:
|
|
699
699
|
_context4.next = 7;
|
|
700
|
-
return _this4.store.order.hydrateTempOrderFromRecord(record, {
|
|
700
|
+
return _this4.store.order.hydrateTempOrderFromRecord(record, hydrateSource === 'sessionStorage' ? {
|
|
701
|
+
recalcOnHydrate: true,
|
|
702
|
+
source: 'sessionStorage'
|
|
703
|
+
} : {
|
|
701
704
|
recalcOnHydrate: false
|
|
702
705
|
});
|
|
703
706
|
case 7:
|
|
@@ -748,7 +751,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
748
751
|
}
|
|
749
752
|
}, _callee5, this);
|
|
750
753
|
}));
|
|
751
|
-
function hydrateLatestLoadedSalesDetail(_x2, _x3) {
|
|
754
|
+
function hydrateLatestLoadedSalesDetail(_x2, _x3, _x4) {
|
|
752
755
|
return _hydrateLatestLoadedSalesDetail.apply(this, arguments);
|
|
753
756
|
}
|
|
754
757
|
return hydrateLatestLoadedSalesDetail;
|
|
@@ -851,7 +854,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
851
854
|
}
|
|
852
855
|
}, _callee6, this);
|
|
853
856
|
}));
|
|
854
|
-
function loadQuotationForPriceQuery(
|
|
857
|
+
function loadQuotationForPriceQuery(_x5) {
|
|
855
858
|
return _loadQuotationForPriceQuery.apply(this, arguments);
|
|
856
859
|
}
|
|
857
860
|
return loadQuotationForPriceQuery;
|
|
@@ -896,8 +899,43 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
896
899
|
if (businessCode !== undefined && businessCode !== null && String(businessCode).trim() !== '') {
|
|
897
900
|
strategyContext.business_code = String(businessCode).trim();
|
|
898
901
|
}
|
|
902
|
+
var availableWalletIds = this.getAvailableWalletIds();
|
|
903
|
+
if (availableWalletIds.length > 0 && !Array.isArray(strategyContext.available_wallet_ids)) {
|
|
904
|
+
strategyContext.available_wallet_ids = availableWalletIds;
|
|
905
|
+
}
|
|
899
906
|
return strategyContext;
|
|
900
907
|
}
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* 子类可在商品重报价前准备客户维度的策略上下文,例如等待 Wallet/优惠资产加载。
|
|
911
|
+
*/
|
|
912
|
+
}, {
|
|
913
|
+
key: "prepareProductPriceQueryContext",
|
|
914
|
+
value: (function () {
|
|
915
|
+
var _prepareProductPriceQueryContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_customerId) {
|
|
916
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
917
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
918
|
+
case 0:
|
|
919
|
+
case "end":
|
|
920
|
+
return _context7.stop();
|
|
921
|
+
}
|
|
922
|
+
}, _callee7);
|
|
923
|
+
}));
|
|
924
|
+
function prepareProductPriceQueryContext(_x6) {
|
|
925
|
+
return _prepareProductPriceQueryContext.apply(this, arguments);
|
|
926
|
+
}
|
|
927
|
+
return prepareProductPriceQueryContext;
|
|
928
|
+
}()
|
|
929
|
+
/**
|
|
930
|
+
* 默认保留 BaseSales 的 legacy quotation 行为;已由 /product/query 统一完成
|
|
931
|
+
* 智能定价与报价合并的业务可在子类中覆盖,避免二次覆盖权威价格。
|
|
932
|
+
*/
|
|
933
|
+
)
|
|
934
|
+
}, {
|
|
935
|
+
key: "preferAuthoritativeProductQueryPrice",
|
|
936
|
+
value: function preferAuthoritativeProductQueryPrice() {
|
|
937
|
+
return false;
|
|
938
|
+
}
|
|
901
939
|
}, {
|
|
902
940
|
key: "getPriceQuerySchedule",
|
|
903
941
|
value: function getPriceQuerySchedule(params) {
|
|
@@ -929,25 +967,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
929
967
|
}, {
|
|
930
968
|
key: "loadProductsForPriceQuery",
|
|
931
969
|
value: function () {
|
|
932
|
-
var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
970
|
+
var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
933
971
|
var ids, productsById, channel, strategyContext, _response$data, response, list;
|
|
934
|
-
return _regeneratorRuntime().wrap(function
|
|
935
|
-
while (1) switch (
|
|
972
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
973
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
936
974
|
case 0:
|
|
937
975
|
ids = Array.from(new Set(params.ids.filter(function (id) {
|
|
938
976
|
return Number.isFinite(id);
|
|
939
977
|
})));
|
|
940
978
|
productsById = new Map();
|
|
941
979
|
if (!(!ids.length || !this.request)) {
|
|
942
|
-
|
|
980
|
+
_context8.next = 4;
|
|
943
981
|
break;
|
|
944
982
|
}
|
|
945
|
-
return
|
|
983
|
+
return _context8.abrupt("return", productsById);
|
|
946
984
|
case 4:
|
|
947
985
|
channel = this.getPriceQueryChannel(params.channel);
|
|
948
986
|
strategyContext = this.getPriceQueryStrategyContext(channel);
|
|
949
|
-
|
|
950
|
-
|
|
987
|
+
_context8.prev = 6;
|
|
988
|
+
_context8.next = 9;
|
|
951
989
|
return this.request.post('/product/query', _objectSpread({
|
|
952
990
|
ids: ids,
|
|
953
991
|
open_quotation: 1,
|
|
@@ -966,35 +1004,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
966
1004
|
customToast: function customToast() {}
|
|
967
1005
|
});
|
|
968
1006
|
case 9:
|
|
969
|
-
response =
|
|
1007
|
+
response = _context8.sent;
|
|
970
1008
|
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) || [];
|
|
971
1009
|
if (Array.isArray(list)) {
|
|
972
|
-
|
|
1010
|
+
_context8.next = 13;
|
|
973
1011
|
break;
|
|
974
1012
|
}
|
|
975
|
-
return
|
|
1013
|
+
return _context8.abrupt("return", productsById);
|
|
976
1014
|
case 13:
|
|
977
1015
|
list.forEach(function (item) {
|
|
978
1016
|
var _item$id;
|
|
979
1017
|
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);
|
|
980
1018
|
if (Number.isFinite(productId)) productsById.set(productId, item);
|
|
981
1019
|
});
|
|
982
|
-
return
|
|
1020
|
+
return _context8.abrupt("return", productsById);
|
|
983
1021
|
case 17:
|
|
984
|
-
|
|
985
|
-
|
|
1022
|
+
_context8.prev = 17;
|
|
1023
|
+
_context8.t0 = _context8["catch"](6);
|
|
986
1024
|
this.logWarning('loadProductsForPriceQuery: 商品批量重查失败,使用入参 fallback', {
|
|
987
1025
|
ids: ids,
|
|
988
|
-
error:
|
|
1026
|
+
error: _context8.t0 instanceof Error ? _context8.t0.message : String(_context8.t0)
|
|
989
1027
|
});
|
|
990
|
-
return
|
|
1028
|
+
return _context8.abrupt("return", productsById);
|
|
991
1029
|
case 21:
|
|
992
1030
|
case "end":
|
|
993
|
-
return
|
|
1031
|
+
return _context8.stop();
|
|
994
1032
|
}
|
|
995
|
-
},
|
|
1033
|
+
}, _callee8, this, [[6, 17]]);
|
|
996
1034
|
}));
|
|
997
|
-
function loadProductsForPriceQuery(
|
|
1035
|
+
function loadProductsForPriceQuery(_x7) {
|
|
998
1036
|
return _loadProductsForPriceQuery.apply(this, arguments);
|
|
999
1037
|
}
|
|
1000
1038
|
return loadProductsForPriceQuery;
|
|
@@ -1002,21 +1040,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1002
1040
|
}, {
|
|
1003
1041
|
key: "loadProductForPriceQuery",
|
|
1004
1042
|
value: function () {
|
|
1005
|
-
var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1043
|
+
var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params, customerId) {
|
|
1006
1044
|
var product, productId, schedule, productsById;
|
|
1007
|
-
return _regeneratorRuntime().wrap(function
|
|
1008
|
-
while (1) switch (
|
|
1045
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1046
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1009
1047
|
case 0:
|
|
1010
1048
|
product = params.product || {};
|
|
1011
1049
|
productId = this.getPriceQueryProductId(product);
|
|
1012
1050
|
if (!(productId === null || !this.request)) {
|
|
1013
|
-
|
|
1051
|
+
_context9.next = 4;
|
|
1014
1052
|
break;
|
|
1015
1053
|
}
|
|
1016
|
-
return
|
|
1054
|
+
return _context9.abrupt("return", null);
|
|
1017
1055
|
case 4:
|
|
1018
1056
|
schedule = this.getPriceQuerySchedule(params);
|
|
1019
|
-
|
|
1057
|
+
_context9.next = 7;
|
|
1020
1058
|
return this.loadProductsForPriceQuery({
|
|
1021
1059
|
ids: [productId],
|
|
1022
1060
|
schedule: schedule,
|
|
@@ -1024,15 +1062,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1024
1062
|
channel: params.channel
|
|
1025
1063
|
});
|
|
1026
1064
|
case 7:
|
|
1027
|
-
productsById =
|
|
1028
|
-
return
|
|
1065
|
+
productsById = _context9.sent;
|
|
1066
|
+
return _context9.abrupt("return", productsById.get(productId) || null);
|
|
1029
1067
|
case 9:
|
|
1030
1068
|
case "end":
|
|
1031
|
-
return
|
|
1069
|
+
return _context9.stop();
|
|
1032
1070
|
}
|
|
1033
|
-
},
|
|
1071
|
+
}, _callee9, this);
|
|
1034
1072
|
}));
|
|
1035
|
-
function loadProductForPriceQuery(
|
|
1073
|
+
function loadProductForPriceQuery(_x8, _x9) {
|
|
1036
1074
|
return _loadProductForPriceQuery.apply(this, arguments);
|
|
1037
1075
|
}
|
|
1038
1076
|
return loadProductForPriceQuery;
|
|
@@ -1170,13 +1208,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1170
1208
|
* const params = this.buildSubModuleOtherParams();
|
|
1171
1209
|
* this.core.registerModule(orderModule, { otherParams: params });
|
|
1172
1210
|
*/
|
|
1211
|
+
}, {
|
|
1212
|
+
key: "isSessionStoragePersistEnabled",
|
|
1213
|
+
value: function isSessionStoragePersistEnabled() {
|
|
1214
|
+
return Boolean(this.cacheId);
|
|
1215
|
+
}
|
|
1216
|
+
}, {
|
|
1217
|
+
key: "shouldUseSessionStorageForSubModule",
|
|
1218
|
+
value: function shouldUseSessionStorageForSubModule(_moduleName) {
|
|
1219
|
+
return this.isSessionStoragePersistEnabled();
|
|
1220
|
+
}
|
|
1173
1221
|
}, {
|
|
1174
1222
|
key: "buildSubModuleOtherParams",
|
|
1175
|
-
value: function buildSubModuleOtherParams() {
|
|
1223
|
+
value: function buildSubModuleOtherParams(moduleName) {
|
|
1176
1224
|
return _objectSpread(_objectSpread({}, this.otherParams), {}, {
|
|
1177
1225
|
salesSummaryModuleName: "".concat(this.name, "_salesSummary"),
|
|
1178
1226
|
fatherModule: this.name,
|
|
1179
|
-
openCache: this.
|
|
1227
|
+
openCache: this.shouldUseSessionStorageForSubModule(moduleName),
|
|
1180
1228
|
cacheId: this.cacheId
|
|
1181
1229
|
});
|
|
1182
1230
|
}
|
|
@@ -1190,61 +1238,60 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1190
1238
|
}, {
|
|
1191
1239
|
key: "syncOtherParamsToSubModules",
|
|
1192
1240
|
value: (function () {
|
|
1193
|
-
var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1241
|
+
var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(changedParams) {
|
|
1194
1242
|
var _this6 = this;
|
|
1195
1243
|
var _ref23,
|
|
1196
1244
|
_ref23$cover,
|
|
1197
1245
|
cover,
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
1246
|
+
_args11 = arguments;
|
|
1247
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1248
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1202
1249
|
case 0:
|
|
1203
|
-
_ref23 =
|
|
1204
|
-
|
|
1205
|
-
_context10.next = 4;
|
|
1250
|
+
_ref23 = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {}, _ref23$cover = _ref23.cover, cover = _ref23$cover === void 0 ? false : _ref23$cover;
|
|
1251
|
+
_context11.next = 3;
|
|
1206
1252
|
return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
|
|
1207
|
-
var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1208
|
-
var _ref26, moduleName, subModule, targetModule;
|
|
1209
|
-
return _regeneratorRuntime().wrap(function
|
|
1210
|
-
while (1) switch (
|
|
1253
|
+
var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref24) {
|
|
1254
|
+
var _ref26, moduleName, subModule, targetModule, nextSubModuleOtherParams;
|
|
1255
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1256
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1211
1257
|
case 0:
|
|
1212
1258
|
_ref26 = _slicedToArray(_ref24, 2), moduleName = _ref26[0], subModule = _ref26[1];
|
|
1213
1259
|
if (!_this6.reusedSharedSubModuleNames.has(moduleName)) {
|
|
1214
|
-
|
|
1260
|
+
_context10.next = 3;
|
|
1215
1261
|
break;
|
|
1216
1262
|
}
|
|
1217
|
-
return
|
|
1263
|
+
return _context10.abrupt("return");
|
|
1218
1264
|
case 3:
|
|
1219
1265
|
targetModule = subModule;
|
|
1220
1266
|
if (!(!targetModule || typeof targetModule.updateOtherParams !== 'function')) {
|
|
1221
|
-
|
|
1267
|
+
_context10.next = 6;
|
|
1222
1268
|
break;
|
|
1223
1269
|
}
|
|
1224
|
-
return
|
|
1270
|
+
return _context10.abrupt("return");
|
|
1225
1271
|
case 6:
|
|
1226
|
-
|
|
1272
|
+
nextSubModuleOtherParams = _this6.buildSubModuleOtherParams(moduleName);
|
|
1273
|
+
_context10.next = 9;
|
|
1227
1274
|
return targetModule.updateOtherParams(nextSubModuleOtherParams, {
|
|
1228
1275
|
changedParams: changedParams,
|
|
1229
1276
|
cover: cover
|
|
1230
1277
|
});
|
|
1231
|
-
case
|
|
1278
|
+
case 9:
|
|
1232
1279
|
case "end":
|
|
1233
|
-
return
|
|
1280
|
+
return _context10.stop();
|
|
1234
1281
|
}
|
|
1235
|
-
},
|
|
1282
|
+
}, _callee10);
|
|
1236
1283
|
}));
|
|
1237
|
-
return function (
|
|
1284
|
+
return function (_x11) {
|
|
1238
1285
|
return _ref25.apply(this, arguments);
|
|
1239
1286
|
};
|
|
1240
1287
|
}()));
|
|
1241
|
-
case
|
|
1288
|
+
case 3:
|
|
1242
1289
|
case "end":
|
|
1243
|
-
return
|
|
1290
|
+
return _context11.stop();
|
|
1244
1291
|
}
|
|
1245
|
-
},
|
|
1292
|
+
}, _callee11, this);
|
|
1246
1293
|
}));
|
|
1247
|
-
function syncOtherParamsToSubModules(
|
|
1294
|
+
function syncOtherParamsToSubModules(_x10) {
|
|
1248
1295
|
return _syncOtherParamsToSubModules.apply(this, arguments);
|
|
1249
1296
|
}
|
|
1250
1297
|
return syncOtherParamsToSubModules;
|
|
@@ -1257,12 +1304,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1257
1304
|
}, {
|
|
1258
1305
|
key: "readSessionCacheData",
|
|
1259
1306
|
value: function readSessionCacheData() {
|
|
1260
|
-
|
|
1307
|
+
var cacheId = this.cacheId;
|
|
1308
|
+
if (!cacheId || !this.isSessionStoragePersistEnabled() || !this.window) {
|
|
1309
|
+
return {};
|
|
1310
|
+
}
|
|
1261
1311
|
try {
|
|
1262
1312
|
var sessionData = this.window.sessionStorage.getItem(this.name);
|
|
1263
1313
|
if (!sessionData) return {};
|
|
1264
1314
|
var data = JSON.parse(sessionData);
|
|
1265
|
-
return data && data[
|
|
1315
|
+
return data && data[cacheId] || {};
|
|
1266
1316
|
} catch (_unused3) {
|
|
1267
1317
|
return {};
|
|
1268
1318
|
}
|
|
@@ -1350,7 +1400,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1350
1400
|
}, {
|
|
1351
1401
|
key: "initialize",
|
|
1352
1402
|
value: function () {
|
|
1353
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1403
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(core) {
|
|
1354
1404
|
var _this$otherParams9,
|
|
1355
1405
|
_this$appPlugin2,
|
|
1356
1406
|
_this$appPlugin2$getA,
|
|
@@ -1360,11 +1410,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1360
1410
|
app,
|
|
1361
1411
|
targetCacheData,
|
|
1362
1412
|
moduleNames,
|
|
1363
|
-
|
|
1364
|
-
return _regeneratorRuntime().wrap(function
|
|
1365
|
-
while (1) switch (
|
|
1413
|
+
_args12 = arguments;
|
|
1414
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1415
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1366
1416
|
case 0:
|
|
1367
|
-
options =
|
|
1417
|
+
options = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : {};
|
|
1368
1418
|
this.core = core;
|
|
1369
1419
|
this.initializeOptions = options || {};
|
|
1370
1420
|
this.paymentNumberDevicePrefix = null;
|
|
@@ -1398,35 +1448,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1398
1448
|
var hooks = _this9.getSubModuleHooks(step);
|
|
1399
1449
|
_this9.store[step] = targetModule;
|
|
1400
1450
|
_this9.core.registerModule(targetModule, _objectSpread(_objectSpread({
|
|
1401
|
-
initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
|
|
1451
|
+
initialState: _this9.shouldUseSessionStorageForSubModule(step) ? (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {} : {}
|
|
1402
1452
|
}, hooks ? {
|
|
1403
1453
|
hooks: hooks
|
|
1404
1454
|
} : {}), {}, {
|
|
1405
|
-
otherParams: _this9.buildSubModuleOtherParams()
|
|
1455
|
+
otherParams: _this9.buildSubModuleOtherParams(step)
|
|
1406
1456
|
}));
|
|
1407
1457
|
});
|
|
1408
1458
|
if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
|
|
1409
|
-
|
|
1459
|
+
_context12.next = 19;
|
|
1410
1460
|
break;
|
|
1411
1461
|
}
|
|
1412
|
-
|
|
1462
|
+
_context12.next = 19;
|
|
1413
1463
|
return this.store.schedule.loadAllSchedule();
|
|
1414
1464
|
case 19:
|
|
1415
1465
|
if (this.store.order && typeof ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.enableTempOrderPersist) === 'boolean') {
|
|
1416
1466
|
this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
|
|
1417
1467
|
}
|
|
1418
|
-
|
|
1468
|
+
_context12.next = 22;
|
|
1419
1469
|
return this.getPaymentMethodsAsync();
|
|
1420
1470
|
case 22:
|
|
1421
1471
|
this.registerServerOrderChangeSync();
|
|
1422
1472
|
this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
1423
1473
|
case 24:
|
|
1424
1474
|
case "end":
|
|
1425
|
-
return
|
|
1475
|
+
return _context12.stop();
|
|
1426
1476
|
}
|
|
1427
|
-
},
|
|
1477
|
+
}, _callee12, this);
|
|
1428
1478
|
}));
|
|
1429
|
-
function initialize(
|
|
1479
|
+
function initialize(_x12) {
|
|
1430
1480
|
return _initialize.apply(this, arguments);
|
|
1431
1481
|
}
|
|
1432
1482
|
return initialize;
|
|
@@ -1434,11 +1484,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1434
1484
|
}, {
|
|
1435
1485
|
key: "destroy",
|
|
1436
1486
|
value: function () {
|
|
1437
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1487
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
1438
1488
|
var _this$serverOrderChan2,
|
|
1439
1489
|
_this10 = this;
|
|
1440
|
-
return _regeneratorRuntime().wrap(function
|
|
1441
|
-
while (1) switch (
|
|
1490
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1491
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1442
1492
|
case 0:
|
|
1443
1493
|
(_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
|
|
1444
1494
|
this.serverOrderChangeUnsubscribe = null;
|
|
@@ -1458,15 +1508,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1458
1508
|
this.queuedServerOrderChanges = [];
|
|
1459
1509
|
this.salesDetailLoadSequence += 1;
|
|
1460
1510
|
this.walletAssetsRefreshSequence += 1;
|
|
1461
|
-
|
|
1511
|
+
_context13.next = 10;
|
|
1462
1512
|
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
1463
1513
|
case 10:
|
|
1464
1514
|
_get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
|
|
1465
1515
|
case 11:
|
|
1466
1516
|
case "end":
|
|
1467
|
-
return
|
|
1517
|
+
return _context13.stop();
|
|
1468
1518
|
}
|
|
1469
|
-
},
|
|
1519
|
+
}, _callee13, this);
|
|
1470
1520
|
}));
|
|
1471
1521
|
function destroy() {
|
|
1472
1522
|
return _destroy.apply(this, arguments);
|
|
@@ -1483,20 +1533,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1483
1533
|
}, {
|
|
1484
1534
|
key: "loadSalesDetail",
|
|
1485
1535
|
value: (function () {
|
|
1486
|
-
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1487
|
-
var loadSequence, _ref27, _ref28, _ref29, _ref30, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, mergedRecord, record;
|
|
1488
|
-
return _regeneratorRuntime().wrap(function
|
|
1489
|
-
while (1) switch (
|
|
1536
|
+
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderIdOrParams) {
|
|
1537
|
+
var loadSequence, _ref27, _ref28, _ref29, _ref30, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, loadedSalesDetail, shouldFilterPendingPayments, remoteRecord, currentTempOrder, mergedRecord, record;
|
|
1538
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1539
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1490
1540
|
case 0:
|
|
1491
1541
|
if (this.store.order) {
|
|
1492
|
-
|
|
1542
|
+
_context14.next = 2;
|
|
1493
1543
|
break;
|
|
1494
1544
|
}
|
|
1495
1545
|
throw new Error('order 模块未初始化');
|
|
1496
1546
|
case 2:
|
|
1497
1547
|
loadSequence = ++this.salesDetailLoadSequence;
|
|
1498
1548
|
this.salesDetailLoadInFlightCount += 1;
|
|
1499
|
-
|
|
1549
|
+
_context14.prev = 4;
|
|
1500
1550
|
params = _typeof(orderIdOrParams) === 'object' ? orderIdOrParams : {
|
|
1501
1551
|
orderId: orderIdOrParams
|
|
1502
1552
|
};
|
|
@@ -1504,71 +1554,73 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1504
1554
|
preloadedSalesDetail = params.preloadedSalesDetail;
|
|
1505
1555
|
lookup = (_ref27 = (_ref28 = (_ref29 = (_ref30 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref30 !== void 0 ? _ref30 : params.orderNumber) !== null && _ref29 !== void 0 ? _ref29 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref28 !== void 0 ? _ref28 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref27 !== void 0 ? _ref27 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
|
|
1506
1556
|
if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
|
|
1507
|
-
|
|
1557
|
+
_context14.next = 11;
|
|
1508
1558
|
break;
|
|
1509
1559
|
}
|
|
1510
1560
|
throw new Error('加载销售详情需要 orderId、externalSaleNumber 或 orderNumber');
|
|
1511
1561
|
case 11:
|
|
1512
1562
|
if (!(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0)) {
|
|
1513
|
-
|
|
1563
|
+
_context14.next = 15;
|
|
1514
1564
|
break;
|
|
1515
1565
|
}
|
|
1516
|
-
|
|
1517
|
-
|
|
1566
|
+
_context14.t0 = preloadedSalesDetail;
|
|
1567
|
+
_context14.next = 18;
|
|
1518
1568
|
break;
|
|
1519
1569
|
case 15:
|
|
1520
|
-
|
|
1570
|
+
_context14.next = 17;
|
|
1521
1571
|
return this.store.order.getSalesOrderByLookup({
|
|
1522
1572
|
lookup: lookup,
|
|
1523
1573
|
forceRemote: params.forceRemote
|
|
1524
1574
|
});
|
|
1525
1575
|
case 17:
|
|
1526
|
-
|
|
1576
|
+
_context14.t0 = _context14.sent;
|
|
1527
1577
|
case 18:
|
|
1528
|
-
loadedRecord =
|
|
1578
|
+
loadedRecord = _context14.t0;
|
|
1529
1579
|
if (!(!preloadedSalesDetail && (!loadedRecord || loadedRecord.code !== 200))) {
|
|
1530
|
-
|
|
1580
|
+
_context14.next = 22;
|
|
1531
1581
|
break;
|
|
1532
1582
|
}
|
|
1533
1583
|
message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
|
|
1534
1584
|
throw new Error(message);
|
|
1535
1585
|
case 22:
|
|
1536
|
-
|
|
1586
|
+
loadedSalesDetail = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data; // payment_pending 只存在于本地;远端详情需过滤,但会话快照必须完整恢复。
|
|
1587
|
+
shouldFilterPendingPayments = params.hydrateSource !== 'sessionStorage';
|
|
1588
|
+
remoteRecord = shouldFilterPendingPayments ? filterPendingPaymentsFromLoadedSalesDetail(loadedSalesDetail) : loadedSalesDetail;
|
|
1537
1589
|
currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
1538
1590
|
mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
|
|
1539
|
-
record = filterPendingPaymentsFromLoadedSalesDetail(mergedRecord);
|
|
1540
|
-
|
|
1541
|
-
return this.hydrateLatestLoadedSalesDetail(record, loadSequence);
|
|
1542
|
-
case
|
|
1543
|
-
return
|
|
1544
|
-
case
|
|
1545
|
-
|
|
1591
|
+
record = shouldFilterPendingPayments ? filterPendingPaymentsFromLoadedSalesDetail(mergedRecord) : mergedRecord;
|
|
1592
|
+
_context14.next = 30;
|
|
1593
|
+
return this.hydrateLatestLoadedSalesDetail(record, loadSequence, params.hydrateSource);
|
|
1594
|
+
case 30:
|
|
1595
|
+
return _context14.abrupt("return", _context14.sent);
|
|
1596
|
+
case 31:
|
|
1597
|
+
_context14.prev = 31;
|
|
1546
1598
|
this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
|
|
1547
1599
|
if (!(this.salesDetailLoadInFlightCount === 0)) {
|
|
1548
|
-
|
|
1600
|
+
_context14.next = 42;
|
|
1549
1601
|
break;
|
|
1550
1602
|
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1603
|
+
_context14.prev = 34;
|
|
1604
|
+
_context14.next = 37;
|
|
1553
1605
|
return this.drainQueuedServerOrderChanges();
|
|
1554
|
-
case 35:
|
|
1555
|
-
_context13.next = 40;
|
|
1556
|
-
break;
|
|
1557
1606
|
case 37:
|
|
1558
|
-
|
|
1559
|
-
|
|
1607
|
+
_context14.next = 42;
|
|
1608
|
+
break;
|
|
1609
|
+
case 39:
|
|
1610
|
+
_context14.prev = 39;
|
|
1611
|
+
_context14.t1 = _context14["catch"](34);
|
|
1560
1612
|
this.logError('drain queued server order changes failed', {
|
|
1561
|
-
error:
|
|
1613
|
+
error: _context14.t1 instanceof Error ? _context14.t1.message : String(_context14.t1)
|
|
1562
1614
|
});
|
|
1563
|
-
case
|
|
1564
|
-
return
|
|
1565
|
-
case
|
|
1615
|
+
case 42:
|
|
1616
|
+
return _context14.finish(31);
|
|
1617
|
+
case 43:
|
|
1566
1618
|
case "end":
|
|
1567
|
-
return
|
|
1619
|
+
return _context14.stop();
|
|
1568
1620
|
}
|
|
1569
|
-
},
|
|
1621
|
+
}, _callee14, this, [[4,, 31, 43], [34, 39]]);
|
|
1570
1622
|
}));
|
|
1571
|
-
function loadSalesDetail(
|
|
1623
|
+
function loadSalesDetail(_x13) {
|
|
1572
1624
|
return _loadSalesDetail.apply(this, arguments);
|
|
1573
1625
|
}
|
|
1574
1626
|
return loadSalesDetail;
|
|
@@ -1648,34 +1700,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1648
1700
|
}, {
|
|
1649
1701
|
key: "replaceTempOrder",
|
|
1650
1702
|
value: function () {
|
|
1651
|
-
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1703
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tempOrder, options) {
|
|
1652
1704
|
var nextTempOrder;
|
|
1653
|
-
return _regeneratorRuntime().wrap(function
|
|
1654
|
-
while (1) switch (
|
|
1705
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1706
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1655
1707
|
case 0:
|
|
1656
1708
|
if (this.store.order) {
|
|
1657
|
-
|
|
1709
|
+
_context15.next = 2;
|
|
1658
1710
|
break;
|
|
1659
1711
|
}
|
|
1660
1712
|
throw new Error('order 模块未初始化');
|
|
1661
1713
|
case 2:
|
|
1662
|
-
|
|
1714
|
+
_context15.next = 4;
|
|
1663
1715
|
return this.store.order.replaceTempOrder(tempOrder, options);
|
|
1664
1716
|
case 4:
|
|
1665
|
-
nextTempOrder =
|
|
1666
|
-
|
|
1717
|
+
nextTempOrder = _context15.sent;
|
|
1718
|
+
_context15.next = 7;
|
|
1667
1719
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
1668
1720
|
tempOrder: nextTempOrder
|
|
1669
1721
|
});
|
|
1670
1722
|
case 7:
|
|
1671
|
-
return
|
|
1723
|
+
return _context15.abrupt("return", nextTempOrder);
|
|
1672
1724
|
case 8:
|
|
1673
1725
|
case "end":
|
|
1674
|
-
return
|
|
1726
|
+
return _context15.stop();
|
|
1675
1727
|
}
|
|
1676
|
-
},
|
|
1728
|
+
}, _callee15, this);
|
|
1677
1729
|
}));
|
|
1678
|
-
function replaceTempOrder(
|
|
1730
|
+
function replaceTempOrder(_x14, _x15) {
|
|
1679
1731
|
return _replaceTempOrder.apply(this, arguments);
|
|
1680
1732
|
}
|
|
1681
1733
|
return replaceTempOrder;
|
|
@@ -1773,40 +1825,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1773
1825
|
}, {
|
|
1774
1826
|
key: "addNewOrder",
|
|
1775
1827
|
value: function () {
|
|
1776
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1828
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
1777
1829
|
var tempOrder;
|
|
1778
|
-
return _regeneratorRuntime().wrap(function
|
|
1779
|
-
while (1) switch (
|
|
1830
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1831
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1780
1832
|
case 0:
|
|
1781
|
-
|
|
1833
|
+
_context16.prev = 0;
|
|
1782
1834
|
if (this.store.order) {
|
|
1783
|
-
|
|
1835
|
+
_context16.next = 3;
|
|
1784
1836
|
break;
|
|
1785
1837
|
}
|
|
1786
1838
|
throw new Error('order 模块未初始化');
|
|
1787
1839
|
case 3:
|
|
1788
|
-
|
|
1840
|
+
_context16.next = 5;
|
|
1789
1841
|
return this.store.order.addNewOrder();
|
|
1790
1842
|
case 5:
|
|
1791
|
-
tempOrder =
|
|
1843
|
+
tempOrder = _context16.sent;
|
|
1792
1844
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1793
|
-
|
|
1845
|
+
_context16.next = 10;
|
|
1794
1846
|
break;
|
|
1795
1847
|
}
|
|
1796
1848
|
this.store.order.persistTempOrder();
|
|
1797
|
-
|
|
1849
|
+
_context16.next = 10;
|
|
1798
1850
|
return this.store.order.saveDraft();
|
|
1799
1851
|
case 10:
|
|
1800
|
-
return
|
|
1852
|
+
return _context16.abrupt("return", tempOrder);
|
|
1801
1853
|
case 13:
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
throw
|
|
1854
|
+
_context16.prev = 13;
|
|
1855
|
+
_context16.t0 = _context16["catch"](0);
|
|
1856
|
+
throw _context16.t0;
|
|
1805
1857
|
case 16:
|
|
1806
1858
|
case "end":
|
|
1807
|
-
return
|
|
1859
|
+
return _context16.stop();
|
|
1808
1860
|
}
|
|
1809
|
-
},
|
|
1861
|
+
}, _callee16, this, [[0, 13]]);
|
|
1810
1862
|
}));
|
|
1811
1863
|
function addNewOrder() {
|
|
1812
1864
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -1816,22 +1868,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1816
1868
|
}, {
|
|
1817
1869
|
key: "saveDraft",
|
|
1818
1870
|
value: function () {
|
|
1819
|
-
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1820
|
-
return _regeneratorRuntime().wrap(function
|
|
1821
|
-
while (1) switch (
|
|
1871
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1872
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1873
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1822
1874
|
case 0:
|
|
1823
1875
|
if (this.store.order) {
|
|
1824
|
-
|
|
1876
|
+
_context17.next = 2;
|
|
1825
1877
|
break;
|
|
1826
1878
|
}
|
|
1827
1879
|
throw new Error('order 模块未初始化');
|
|
1828
1880
|
case 2:
|
|
1829
|
-
return
|
|
1881
|
+
return _context17.abrupt("return", this.store.order.saveDraft());
|
|
1830
1882
|
case 3:
|
|
1831
1883
|
case "end":
|
|
1832
|
-
return
|
|
1884
|
+
return _context17.stop();
|
|
1833
1885
|
}
|
|
1834
|
-
},
|
|
1886
|
+
}, _callee17, this);
|
|
1835
1887
|
}));
|
|
1836
1888
|
function saveDraft() {
|
|
1837
1889
|
return _saveDraft.apply(this, arguments);
|
|
@@ -1842,14 +1894,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1842
1894
|
}, {
|
|
1843
1895
|
key: "restoreOrder",
|
|
1844
1896
|
value: function () {
|
|
1845
|
-
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1897
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1846
1898
|
var _this$store$payment, tempOrder, wallet;
|
|
1847
|
-
return _regeneratorRuntime().wrap(function
|
|
1848
|
-
while (1) switch (
|
|
1899
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1900
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1849
1901
|
case 0:
|
|
1850
|
-
|
|
1902
|
+
_context18.prev = 0;
|
|
1851
1903
|
if (this.store.order) {
|
|
1852
|
-
|
|
1904
|
+
_context18.next = 3;
|
|
1853
1905
|
break;
|
|
1854
1906
|
}
|
|
1855
1907
|
throw new Error('scanOrder 解决方案需要 order 模块支持');
|
|
@@ -1861,37 +1913,37 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1861
1913
|
this.hasManualDiscountSelection = false;
|
|
1862
1914
|
wallet = (_this$store$payment = this.store.payment) === null || _this$store$payment === void 0 ? void 0 : _this$store$payment.wallet;
|
|
1863
1915
|
if (!wallet) {
|
|
1864
|
-
|
|
1916
|
+
_context18.next = 13;
|
|
1865
1917
|
break;
|
|
1866
1918
|
}
|
|
1867
1919
|
this.walletAssetsRefreshSequence += 1;
|
|
1868
1920
|
wallet.clearAllCache();
|
|
1869
|
-
|
|
1921
|
+
_context18.next = 13;
|
|
1870
1922
|
return this.publishWalletAssetsState(wallet.getWalletAssetsState());
|
|
1871
1923
|
case 13:
|
|
1872
|
-
|
|
1924
|
+
_context18.next = 15;
|
|
1873
1925
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
1874
1926
|
tempOrder: tempOrder
|
|
1875
1927
|
});
|
|
1876
1928
|
case 15:
|
|
1877
1929
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1878
|
-
|
|
1930
|
+
_context18.next = 19;
|
|
1879
1931
|
break;
|
|
1880
1932
|
}
|
|
1881
1933
|
this.store.order.persistTempOrder();
|
|
1882
|
-
|
|
1934
|
+
_context18.next = 19;
|
|
1883
1935
|
return this.store.order.saveDraft();
|
|
1884
1936
|
case 19:
|
|
1885
|
-
return
|
|
1937
|
+
return _context18.abrupt("return", tempOrder);
|
|
1886
1938
|
case 22:
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
throw
|
|
1939
|
+
_context18.prev = 22;
|
|
1940
|
+
_context18.t0 = _context18["catch"](0);
|
|
1941
|
+
throw _context18.t0;
|
|
1890
1942
|
case 25:
|
|
1891
1943
|
case "end":
|
|
1892
|
-
return
|
|
1944
|
+
return _context18.stop();
|
|
1893
1945
|
}
|
|
1894
|
-
},
|
|
1946
|
+
}, _callee18, this, [[0, 22]]);
|
|
1895
1947
|
}));
|
|
1896
1948
|
function restoreOrder() {
|
|
1897
1949
|
return _restoreOrder.apply(this, arguments);
|
|
@@ -1905,22 +1957,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1905
1957
|
}, {
|
|
1906
1958
|
key: "clearOrderCartLines",
|
|
1907
1959
|
value: (function () {
|
|
1908
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1960
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1909
1961
|
var tempOrder;
|
|
1910
|
-
return _regeneratorRuntime().wrap(function
|
|
1911
|
-
while (1) switch (
|
|
1962
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1963
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1912
1964
|
case 0:
|
|
1913
|
-
|
|
1965
|
+
_context19.prev = 0;
|
|
1914
1966
|
if (this.store.order) {
|
|
1915
|
-
|
|
1967
|
+
_context19.next = 3;
|
|
1916
1968
|
break;
|
|
1917
1969
|
}
|
|
1918
1970
|
throw new Error('order 模块未初始化');
|
|
1919
1971
|
case 3:
|
|
1920
|
-
|
|
1972
|
+
_context19.next = 5;
|
|
1921
1973
|
return this.store.order.clearOrderCartLines();
|
|
1922
1974
|
case 5:
|
|
1923
|
-
tempOrder =
|
|
1975
|
+
tempOrder = _context19.sent;
|
|
1924
1976
|
if (this.currentSalesDetail) {
|
|
1925
1977
|
this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
|
|
1926
1978
|
products: [],
|
|
@@ -1930,29 +1982,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1930
1982
|
discount_list: []
|
|
1931
1983
|
});
|
|
1932
1984
|
}
|
|
1933
|
-
|
|
1985
|
+
_context19.next = 9;
|
|
1934
1986
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
1935
1987
|
tempOrder: tempOrder
|
|
1936
1988
|
});
|
|
1937
1989
|
case 9:
|
|
1938
1990
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1939
|
-
|
|
1991
|
+
_context19.next = 13;
|
|
1940
1992
|
break;
|
|
1941
1993
|
}
|
|
1942
1994
|
this.store.order.persistTempOrder();
|
|
1943
|
-
|
|
1995
|
+
_context19.next = 13;
|
|
1944
1996
|
return this.store.order.saveDraft();
|
|
1945
1997
|
case 13:
|
|
1946
|
-
return
|
|
1998
|
+
return _context19.abrupt("return", tempOrder);
|
|
1947
1999
|
case 16:
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
throw
|
|
2000
|
+
_context19.prev = 16;
|
|
2001
|
+
_context19.t0 = _context19["catch"](0);
|
|
2002
|
+
throw _context19.t0;
|
|
1951
2003
|
case 19:
|
|
1952
2004
|
case "end":
|
|
1953
|
-
return
|
|
2005
|
+
return _context19.stop();
|
|
1954
2006
|
}
|
|
1955
|
-
},
|
|
2007
|
+
}, _callee19, this, [[0, 16]]);
|
|
1956
2008
|
}));
|
|
1957
2009
|
function clearOrderCartLines() {
|
|
1958
2010
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -1969,32 +2021,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1969
2021
|
}, {
|
|
1970
2022
|
key: "getSummary",
|
|
1971
2023
|
value: function () {
|
|
1972
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2024
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
1973
2025
|
var summary;
|
|
1974
|
-
return _regeneratorRuntime().wrap(function
|
|
1975
|
-
while (1) switch (
|
|
2026
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
2027
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1976
2028
|
case 0:
|
|
1977
|
-
|
|
2029
|
+
_context20.prev = 0;
|
|
1978
2030
|
if (this.store.order) {
|
|
1979
|
-
|
|
2031
|
+
_context20.next = 3;
|
|
1980
2032
|
break;
|
|
1981
2033
|
}
|
|
1982
2034
|
throw new Error('order 模块未初始化');
|
|
1983
2035
|
case 3:
|
|
1984
|
-
|
|
2036
|
+
_context20.next = 5;
|
|
1985
2037
|
return this.store.order.getOrderSummary();
|
|
1986
2038
|
case 5:
|
|
1987
|
-
summary =
|
|
1988
|
-
return
|
|
2039
|
+
summary = _context20.sent;
|
|
2040
|
+
return _context20.abrupt("return", summary);
|
|
1989
2041
|
case 9:
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
throw
|
|
2042
|
+
_context20.prev = 9;
|
|
2043
|
+
_context20.t0 = _context20["catch"](0);
|
|
2044
|
+
throw _context20.t0;
|
|
1993
2045
|
case 12:
|
|
1994
2046
|
case "end":
|
|
1995
|
-
return
|
|
2047
|
+
return _context20.stop();
|
|
1996
2048
|
}
|
|
1997
|
-
},
|
|
2049
|
+
}, _callee20, this, [[0, 9]]);
|
|
1998
2050
|
}));
|
|
1999
2051
|
function getSummary() {
|
|
2000
2052
|
return _getSummary.apply(this, arguments);
|
|
@@ -2111,14 +2163,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2111
2163
|
}, {
|
|
2112
2164
|
key: "loadDiscountConfig",
|
|
2113
2165
|
value: function () {
|
|
2114
|
-
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2166
|
+
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
|
|
2115
2167
|
var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
|
|
2116
2168
|
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _orderStore$summary, orderTotalAmount, result, _iterator2, _step2, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
|
|
2117
|
-
return _regeneratorRuntime().wrap(function
|
|
2118
|
-
while (1) switch (
|
|
2169
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2170
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
2119
2171
|
case 0:
|
|
2120
2172
|
if (this.store.order) {
|
|
2121
|
-
|
|
2173
|
+
_context21.next = 2;
|
|
2122
2174
|
break;
|
|
2123
2175
|
}
|
|
2124
2176
|
throw new Error('order 模块未初始化');
|
|
@@ -2138,18 +2190,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2138
2190
|
discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
|
|
2139
2191
|
preparedDiscountList = [];
|
|
2140
2192
|
if (!(customerId && customerId !== 1)) {
|
|
2141
|
-
|
|
2193
|
+
_context21.next = 25;
|
|
2142
2194
|
break;
|
|
2143
2195
|
}
|
|
2144
2196
|
if (!(this.discountConfigCacheKey === discountConfigCacheKey)) {
|
|
2145
|
-
|
|
2197
|
+
_context21.next = 19;
|
|
2146
2198
|
break;
|
|
2147
2199
|
}
|
|
2148
2200
|
preparedDiscountList = originalDiscountList;
|
|
2149
|
-
|
|
2201
|
+
_context21.next = 25;
|
|
2150
2202
|
break;
|
|
2151
2203
|
case 19:
|
|
2152
|
-
|
|
2204
|
+
_context21.next = 21;
|
|
2153
2205
|
return this.store.order.loadDiscountConfig({
|
|
2154
2206
|
customerId: customerId,
|
|
2155
2207
|
action: discountAction,
|
|
@@ -2157,16 +2209,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2157
2209
|
apply: false
|
|
2158
2210
|
});
|
|
2159
2211
|
case 21:
|
|
2160
|
-
preparedDiscountList =
|
|
2212
|
+
preparedDiscountList = _context21.sent;
|
|
2161
2213
|
this.discountConfigCacheKey = discountConfigCacheKey;
|
|
2162
|
-
|
|
2214
|
+
_context21.next = 25;
|
|
2163
2215
|
return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
|
|
2164
2216
|
case 25:
|
|
2165
2217
|
if (!(hasManualDiscountSelection && currentDiscountList.length)) {
|
|
2166
|
-
|
|
2218
|
+
_context21.next = 27;
|
|
2167
2219
|
break;
|
|
2168
2220
|
}
|
|
2169
|
-
return
|
|
2221
|
+
return _context21.abrupt("return", {
|
|
2170
2222
|
productList: tempOrder.products || [],
|
|
2171
2223
|
discountList: currentDiscountList,
|
|
2172
2224
|
availableWalletIds: this.getAvailableWalletIds()
|
|
@@ -2174,7 +2226,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2174
2226
|
case 27:
|
|
2175
2227
|
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 || []);
|
|
2176
2228
|
nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
|
|
2177
|
-
|
|
2229
|
+
_context21.next = 31;
|
|
2178
2230
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2179
2231
|
case 31:
|
|
2180
2232
|
shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
|
|
@@ -2184,17 +2236,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2184
2236
|
nextDiscountList: nextDiscountList
|
|
2185
2237
|
});
|
|
2186
2238
|
if (!shouldSkipAutoApplyFetchedDiscounts) {
|
|
2187
|
-
|
|
2239
|
+
_context21.next = 40;
|
|
2188
2240
|
break;
|
|
2189
2241
|
}
|
|
2190
|
-
|
|
2242
|
+
_context21.next = 35;
|
|
2191
2243
|
return this.store.order.recalculateSummary({
|
|
2192
2244
|
createIfMissing: true
|
|
2193
2245
|
});
|
|
2194
2246
|
case 35:
|
|
2195
|
-
_summary =
|
|
2247
|
+
_summary = _context21.sent;
|
|
2196
2248
|
this.store.order.persistTempOrder();
|
|
2197
|
-
|
|
2249
|
+
_context21.next = 39;
|
|
2198
2250
|
return this.effectsEmit('onDiscountApplied', {
|
|
2199
2251
|
productList: tempOrder.products || [],
|
|
2200
2252
|
discountList: nextDiscountList,
|
|
@@ -2202,14 +2254,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2202
2254
|
tempOrder: tempOrder
|
|
2203
2255
|
});
|
|
2204
2256
|
case 39:
|
|
2205
|
-
return
|
|
2257
|
+
return _context21.abrupt("return", {
|
|
2206
2258
|
productList: tempOrder.products || [],
|
|
2207
2259
|
discountList: nextDiscountList,
|
|
2208
2260
|
availableWalletIds: this.getAvailableWalletIds()
|
|
2209
2261
|
});
|
|
2210
2262
|
case 40:
|
|
2211
2263
|
if (!rulesModule) {
|
|
2212
|
-
|
|
2264
|
+
_context21.next = 77;
|
|
2213
2265
|
break;
|
|
2214
2266
|
}
|
|
2215
2267
|
orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
|
|
@@ -2230,21 +2282,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2230
2282
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2231
2283
|
}
|
|
2232
2284
|
_iterator2 = _createForOfIteratorHelper(tempOrder.products || []);
|
|
2233
|
-
|
|
2285
|
+
_context21.prev = 46;
|
|
2234
2286
|
_iterator2.s();
|
|
2235
2287
|
case 48:
|
|
2236
2288
|
if ((_step2 = _iterator2.n()).done) {
|
|
2237
|
-
|
|
2289
|
+
_context21.next = 63;
|
|
2238
2290
|
break;
|
|
2239
2291
|
}
|
|
2240
2292
|
product = _step2.value;
|
|
2241
2293
|
productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
|
|
2242
2294
|
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;
|
|
2243
2295
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
2244
|
-
|
|
2296
|
+
_context21.next = 54;
|
|
2245
2297
|
break;
|
|
2246
2298
|
}
|
|
2247
|
-
return
|
|
2299
|
+
return _context21.abrupt("continue", 61);
|
|
2248
2300
|
case 54:
|
|
2249
2301
|
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
2250
2302
|
return sum + Number(pd.amount || 0);
|
|
@@ -2262,41 +2314,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2262
2314
|
bundle: product.product_bundle
|
|
2263
2315
|
});
|
|
2264
2316
|
case 61:
|
|
2265
|
-
|
|
2317
|
+
_context21.next = 48;
|
|
2266
2318
|
break;
|
|
2267
2319
|
case 63:
|
|
2268
|
-
|
|
2320
|
+
_context21.next = 68;
|
|
2269
2321
|
break;
|
|
2270
2322
|
case 65:
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
_iterator2.e(
|
|
2323
|
+
_context21.prev = 65;
|
|
2324
|
+
_context21.t0 = _context21["catch"](46);
|
|
2325
|
+
_iterator2.e(_context21.t0);
|
|
2274
2326
|
case 68:
|
|
2275
|
-
|
|
2327
|
+
_context21.prev = 68;
|
|
2276
2328
|
_iterator2.f();
|
|
2277
|
-
return
|
|
2329
|
+
return _context21.finish(68);
|
|
2278
2330
|
case 71:
|
|
2279
2331
|
if (!result.discountList) {
|
|
2280
|
-
|
|
2332
|
+
_context21.next = 77;
|
|
2281
2333
|
break;
|
|
2282
2334
|
}
|
|
2283
2335
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
2284
2336
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2285
|
-
|
|
2337
|
+
_context21.next = 76;
|
|
2286
2338
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2287
2339
|
case 76:
|
|
2288
2340
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
2289
2341
|
return discount.isSelected;
|
|
2290
2342
|
});
|
|
2291
2343
|
case 77:
|
|
2292
|
-
|
|
2344
|
+
_context21.next = 79;
|
|
2293
2345
|
return this.store.order.recalculateSummary({
|
|
2294
2346
|
createIfMissing: true
|
|
2295
2347
|
});
|
|
2296
2348
|
case 79:
|
|
2297
|
-
summary =
|
|
2349
|
+
summary = _context21.sent;
|
|
2298
2350
|
this.store.order.persistTempOrder();
|
|
2299
|
-
|
|
2351
|
+
_context21.next = 83;
|
|
2300
2352
|
return this.effectsEmit('onDiscountApplied', {
|
|
2301
2353
|
productList: tempOrder.products || [],
|
|
2302
2354
|
discountList: nextDiscountList,
|
|
@@ -2304,18 +2356,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2304
2356
|
tempOrder: tempOrder
|
|
2305
2357
|
});
|
|
2306
2358
|
case 83:
|
|
2307
|
-
return
|
|
2359
|
+
return _context21.abrupt("return", {
|
|
2308
2360
|
productList: tempOrder.products || [],
|
|
2309
2361
|
discountList: nextDiscountList,
|
|
2310
2362
|
availableWalletIds: this.getAvailableWalletIds()
|
|
2311
2363
|
});
|
|
2312
2364
|
case 84:
|
|
2313
2365
|
case "end":
|
|
2314
|
-
return
|
|
2366
|
+
return _context21.stop();
|
|
2315
2367
|
}
|
|
2316
|
-
},
|
|
2368
|
+
}, _callee21, this, [[46, 65, 68, 71]]);
|
|
2317
2369
|
}));
|
|
2318
|
-
function loadDiscountConfig(
|
|
2370
|
+
function loadDiscountConfig(_x16) {
|
|
2319
2371
|
return _loadDiscountConfig.apply(this, arguments);
|
|
2320
2372
|
}
|
|
2321
2373
|
return loadDiscountConfig;
|
|
@@ -2330,14 +2382,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2330
2382
|
}, {
|
|
2331
2383
|
key: "bestDiscount",
|
|
2332
2384
|
value: function () {
|
|
2333
|
-
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2385
|
+
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(cb) {
|
|
2334
2386
|
var _discountModule$getOr2, _discountModule$getDi3;
|
|
2335
2387
|
var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
|
|
2336
|
-
return _regeneratorRuntime().wrap(function
|
|
2337
|
-
while (1) switch (
|
|
2388
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2389
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
2338
2390
|
case 0:
|
|
2339
2391
|
if (this.store.order) {
|
|
2340
|
-
|
|
2392
|
+
_context22.next = 2;
|
|
2341
2393
|
break;
|
|
2342
2394
|
}
|
|
2343
2395
|
throw new Error('order 模块未初始化');
|
|
@@ -2353,11 +2405,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2353
2405
|
productList: tempOrder.products || [],
|
|
2354
2406
|
discountList: nextDiscountList
|
|
2355
2407
|
};
|
|
2356
|
-
|
|
2408
|
+
_context22.next = 12;
|
|
2357
2409
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2358
2410
|
case 12:
|
|
2359
2411
|
if (!rulesModule) {
|
|
2360
|
-
|
|
2412
|
+
_context22.next = 24;
|
|
2361
2413
|
break;
|
|
2362
2414
|
}
|
|
2363
2415
|
orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
|
|
@@ -2375,12 +2427,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2375
2427
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2376
2428
|
}
|
|
2377
2429
|
if (!result.discountList) {
|
|
2378
|
-
|
|
2430
|
+
_context22.next = 24;
|
|
2379
2431
|
break;
|
|
2380
2432
|
}
|
|
2381
2433
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
2382
2434
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2383
|
-
|
|
2435
|
+
_context22.next = 22;
|
|
2384
2436
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2385
2437
|
case 22:
|
|
2386
2438
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
@@ -2391,13 +2443,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2391
2443
|
discountList: nextDiscountList
|
|
2392
2444
|
};
|
|
2393
2445
|
case 24:
|
|
2394
|
-
|
|
2446
|
+
_context22.next = 26;
|
|
2395
2447
|
return this.store.order.recalculateSummary({
|
|
2396
2448
|
createIfMissing: true
|
|
2397
2449
|
});
|
|
2398
2450
|
case 26:
|
|
2399
2451
|
this.store.order.persistTempOrder();
|
|
2400
|
-
|
|
2452
|
+
_context22.next = 29;
|
|
2401
2453
|
return this.effectsEmit('onDiscountApplied', {
|
|
2402
2454
|
productList: tempOrder.products || [],
|
|
2403
2455
|
discountList: nextDiscountList,
|
|
@@ -2406,14 +2458,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2406
2458
|
});
|
|
2407
2459
|
case 29:
|
|
2408
2460
|
cb === null || cb === void 0 || cb(result);
|
|
2409
|
-
return
|
|
2461
|
+
return _context22.abrupt("return", result);
|
|
2410
2462
|
case 31:
|
|
2411
2463
|
case "end":
|
|
2412
|
-
return
|
|
2464
|
+
return _context22.stop();
|
|
2413
2465
|
}
|
|
2414
|
-
},
|
|
2466
|
+
}, _callee22, this);
|
|
2415
2467
|
}));
|
|
2416
|
-
function bestDiscount(
|
|
2468
|
+
function bestDiscount(_x17) {
|
|
2417
2469
|
return _bestDiscount.apply(this, arguments);
|
|
2418
2470
|
}
|
|
2419
2471
|
return bestDiscount;
|
|
@@ -2442,41 +2494,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2442
2494
|
}, {
|
|
2443
2495
|
key: "replaceDiscountStoreLists",
|
|
2444
2496
|
value: (function () {
|
|
2445
|
-
var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2497
|
+
var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
2446
2498
|
var _store2;
|
|
2447
2499
|
var discountModule;
|
|
2448
|
-
return _regeneratorRuntime().wrap(function
|
|
2449
|
-
while (1) switch (
|
|
2500
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2501
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2450
2502
|
case 0:
|
|
2451
2503
|
if (this.store.order) {
|
|
2452
|
-
|
|
2504
|
+
_context23.next = 2;
|
|
2453
2505
|
break;
|
|
2454
2506
|
}
|
|
2455
2507
|
throw new Error('order 模块未初始化');
|
|
2456
2508
|
case 2:
|
|
2457
2509
|
discountModule = (_store2 = this.store.order.store) === null || _store2 === void 0 ? void 0 : _store2.discount;
|
|
2458
2510
|
if (discountModule) {
|
|
2459
|
-
|
|
2511
|
+
_context23.next = 5;
|
|
2460
2512
|
break;
|
|
2461
2513
|
}
|
|
2462
|
-
return
|
|
2514
|
+
return _context23.abrupt("return");
|
|
2463
2515
|
case 5:
|
|
2464
2516
|
if (!params.originalDiscountList) {
|
|
2465
|
-
|
|
2517
|
+
_context23.next = 8;
|
|
2466
2518
|
break;
|
|
2467
2519
|
}
|
|
2468
|
-
|
|
2520
|
+
_context23.next = 8;
|
|
2469
2521
|
return discountModule.setOriginalDiscountList(params.originalDiscountList);
|
|
2470
2522
|
case 8:
|
|
2471
|
-
|
|
2523
|
+
_context23.next = 10;
|
|
2472
2524
|
return discountModule.setDiscountList(params.discountList);
|
|
2473
2525
|
case 10:
|
|
2474
2526
|
case "end":
|
|
2475
|
-
return
|
|
2527
|
+
return _context23.stop();
|
|
2476
2528
|
}
|
|
2477
|
-
},
|
|
2529
|
+
}, _callee23, this);
|
|
2478
2530
|
}));
|
|
2479
|
-
function replaceDiscountStoreLists(
|
|
2531
|
+
function replaceDiscountStoreLists(_x18) {
|
|
2480
2532
|
return _replaceDiscountStoreLists.apply(this, arguments);
|
|
2481
2533
|
}
|
|
2482
2534
|
return replaceDiscountStoreLists;
|
|
@@ -2484,34 +2536,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2484
2536
|
}, {
|
|
2485
2537
|
key: "scanPromotionCode",
|
|
2486
2538
|
value: function () {
|
|
2487
|
-
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2539
|
+
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(code, customerId) {
|
|
2488
2540
|
var raw, tempOrder;
|
|
2489
|
-
return _regeneratorRuntime().wrap(function
|
|
2490
|
-
while (1) switch (
|
|
2541
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2542
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2491
2543
|
case 0:
|
|
2492
|
-
|
|
2544
|
+
_context24.prev = 0;
|
|
2493
2545
|
if (this.store.order) {
|
|
2494
|
-
|
|
2546
|
+
_context24.next = 3;
|
|
2495
2547
|
break;
|
|
2496
2548
|
}
|
|
2497
2549
|
throw new Error('order 模块未初始化');
|
|
2498
2550
|
case 3:
|
|
2499
|
-
|
|
2551
|
+
_context24.next = 5;
|
|
2500
2552
|
return this.store.order.scanCode(code, customerId);
|
|
2501
2553
|
case 5:
|
|
2502
|
-
raw =
|
|
2554
|
+
raw = _context24.sent;
|
|
2503
2555
|
if (!raw.isAvailable) {
|
|
2504
|
-
|
|
2556
|
+
_context24.next = 13;
|
|
2505
2557
|
break;
|
|
2506
2558
|
}
|
|
2507
|
-
|
|
2559
|
+
_context24.next = 9;
|
|
2508
2560
|
return this.store.order.recalculateSummary({
|
|
2509
2561
|
createIfMissing: true
|
|
2510
2562
|
});
|
|
2511
2563
|
case 9:
|
|
2512
2564
|
this.store.order.persistTempOrder();
|
|
2513
2565
|
tempOrder = this.store.order.ensureTempOrder();
|
|
2514
|
-
|
|
2566
|
+
_context24.next = 13;
|
|
2515
2567
|
return this.effectsEmit('onDiscountApplied', {
|
|
2516
2568
|
productList: tempOrder.products || [],
|
|
2517
2569
|
discountList: this.store.order.getDiscountList(),
|
|
@@ -2519,7 +2571,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2519
2571
|
tempOrder: tempOrder
|
|
2520
2572
|
});
|
|
2521
2573
|
case 13:
|
|
2522
|
-
return
|
|
2574
|
+
return _context24.abrupt("return", _objectSpread(_objectSpread({
|
|
2523
2575
|
isAvailable: raw.isAvailable
|
|
2524
2576
|
}, raw.isAccepted !== undefined ? {
|
|
2525
2577
|
isAccepted: raw.isAccepted
|
|
@@ -2529,16 +2581,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2529
2581
|
scannedDiscountList: raw.scannedDiscountList
|
|
2530
2582
|
}));
|
|
2531
2583
|
case 16:
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
throw
|
|
2584
|
+
_context24.prev = 16;
|
|
2585
|
+
_context24.t0 = _context24["catch"](0);
|
|
2586
|
+
throw _context24.t0;
|
|
2535
2587
|
case 19:
|
|
2536
2588
|
case "end":
|
|
2537
|
-
return
|
|
2589
|
+
return _context24.stop();
|
|
2538
2590
|
}
|
|
2539
|
-
},
|
|
2591
|
+
}, _callee24, this, [[0, 16]]);
|
|
2540
2592
|
}));
|
|
2541
|
-
function scanPromotionCode(
|
|
2593
|
+
function scanPromotionCode(_x19, _x20) {
|
|
2542
2594
|
return _scanPromotionCode.apply(this, arguments);
|
|
2543
2595
|
}
|
|
2544
2596
|
return scanPromotionCode;
|
|
@@ -2546,14 +2598,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2546
2598
|
}, {
|
|
2547
2599
|
key: "setDiscountSelected",
|
|
2548
2600
|
value: function () {
|
|
2549
|
-
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2601
|
+
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
2550
2602
|
var list, updated, tempOrder, orderStore, discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator3, _step3, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator4, _step4, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
2551
|
-
return _regeneratorRuntime().wrap(function
|
|
2552
|
-
while (1) switch (
|
|
2603
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2604
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2553
2605
|
case 0:
|
|
2554
|
-
|
|
2606
|
+
_context25.prev = 0;
|
|
2555
2607
|
if (this.store.order) {
|
|
2556
|
-
|
|
2608
|
+
_context25.next = 3;
|
|
2557
2609
|
break;
|
|
2558
2610
|
}
|
|
2559
2611
|
throw new Error('order 模块未初始化');
|
|
@@ -2571,7 +2623,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2571
2623
|
discountModule = orderStore.discount;
|
|
2572
2624
|
rulesModule = orderStore.rules;
|
|
2573
2625
|
nextDiscountList = updated;
|
|
2574
|
-
|
|
2626
|
+
_context25.next = 13;
|
|
2575
2627
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
2576
2628
|
case 13:
|
|
2577
2629
|
if (rulesModule) {
|
|
@@ -2634,21 +2686,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2634
2686
|
});
|
|
2635
2687
|
};
|
|
2636
2688
|
_iterator4 = _createForOfIteratorHelper(tempOrder.products);
|
|
2637
|
-
|
|
2689
|
+
_context25.prev = 17;
|
|
2638
2690
|
_iterator4.s();
|
|
2639
2691
|
case 19:
|
|
2640
2692
|
if ((_step4 = _iterator4.n()).done) {
|
|
2641
|
-
|
|
2693
|
+
_context25.next = 36;
|
|
2642
2694
|
break;
|
|
2643
2695
|
}
|
|
2644
2696
|
product = _step4.value;
|
|
2645
2697
|
productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
|
|
2646
2698
|
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;
|
|
2647
2699
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
2648
|
-
|
|
2700
|
+
_context25.next = 25;
|
|
2649
2701
|
break;
|
|
2650
2702
|
}
|
|
2651
|
-
return
|
|
2703
|
+
return _context25.abrupt("continue", 34);
|
|
2652
2704
|
case 25:
|
|
2653
2705
|
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
2654
2706
|
if (Array.isArray(product.product_bundle)) {
|
|
@@ -2684,28 +2736,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2684
2736
|
bundle: product.product_bundle
|
|
2685
2737
|
});
|
|
2686
2738
|
case 34:
|
|
2687
|
-
|
|
2739
|
+
_context25.next = 19;
|
|
2688
2740
|
break;
|
|
2689
2741
|
case 36:
|
|
2690
|
-
|
|
2742
|
+
_context25.next = 41;
|
|
2691
2743
|
break;
|
|
2692
2744
|
case 38:
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
_iterator4.e(
|
|
2745
|
+
_context25.prev = 38;
|
|
2746
|
+
_context25.t0 = _context25["catch"](17);
|
|
2747
|
+
_iterator4.e(_context25.t0);
|
|
2696
2748
|
case 41:
|
|
2697
|
-
|
|
2749
|
+
_context25.prev = 41;
|
|
2698
2750
|
_iterator4.f();
|
|
2699
|
-
return
|
|
2751
|
+
return _context25.finish(41);
|
|
2700
2752
|
case 44:
|
|
2701
2753
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2702
|
-
|
|
2754
|
+
_context25.next = 47;
|
|
2703
2755
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2704
2756
|
case 47:
|
|
2705
2757
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
2706
2758
|
return d.isSelected;
|
|
2707
2759
|
});
|
|
2708
|
-
|
|
2760
|
+
_context25.next = 50;
|
|
2709
2761
|
return this.store.order.recalculateSummary({
|
|
2710
2762
|
createIfMissing: true
|
|
2711
2763
|
});
|
|
@@ -2717,19 +2769,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2717
2769
|
selectedDiscountList: tempOrder.discount_list,
|
|
2718
2770
|
tempOrder: tempOrder
|
|
2719
2771
|
});
|
|
2720
|
-
|
|
2772
|
+
_context25.next = 57;
|
|
2721
2773
|
break;
|
|
2722
2774
|
case 54:
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
throw
|
|
2775
|
+
_context25.prev = 54;
|
|
2776
|
+
_context25.t1 = _context25["catch"](0);
|
|
2777
|
+
throw _context25.t1;
|
|
2726
2778
|
case 57:
|
|
2727
2779
|
case "end":
|
|
2728
|
-
return
|
|
2780
|
+
return _context25.stop();
|
|
2729
2781
|
}
|
|
2730
|
-
},
|
|
2782
|
+
}, _callee25, this, [[0, 54], [17, 38, 41, 44]]);
|
|
2731
2783
|
}));
|
|
2732
|
-
function setDiscountSelected(
|
|
2784
|
+
function setDiscountSelected(_x21) {
|
|
2733
2785
|
return _setDiscountSelected.apply(this, arguments);
|
|
2734
2786
|
}
|
|
2735
2787
|
return setDiscountSelected;
|
|
@@ -2737,23 +2789,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2737
2789
|
}, {
|
|
2738
2790
|
key: "applyDiscountCalculationResult",
|
|
2739
2791
|
value: function () {
|
|
2740
|
-
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2792
|
+
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(result) {
|
|
2741
2793
|
var tempOrder, orderStore, discountModule;
|
|
2742
|
-
return _regeneratorRuntime().wrap(function
|
|
2743
|
-
while (1) switch (
|
|
2794
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2795
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2744
2796
|
case 0:
|
|
2745
|
-
|
|
2797
|
+
_context26.prev = 0;
|
|
2746
2798
|
if (this.store.order) {
|
|
2747
|
-
|
|
2799
|
+
_context26.next = 3;
|
|
2748
2800
|
break;
|
|
2749
2801
|
}
|
|
2750
2802
|
throw new Error('order 模块未初始化');
|
|
2751
2803
|
case 3:
|
|
2752
2804
|
if (result) {
|
|
2753
|
-
|
|
2805
|
+
_context26.next = 5;
|
|
2754
2806
|
break;
|
|
2755
2807
|
}
|
|
2756
|
-
return
|
|
2808
|
+
return _context26.abrupt("return");
|
|
2757
2809
|
case 5:
|
|
2758
2810
|
tempOrder = this.store.order.ensureTempOrder();
|
|
2759
2811
|
orderStore = this.store.order.store || {};
|
|
@@ -2762,24 +2814,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2762
2814
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2763
2815
|
}
|
|
2764
2816
|
if (!result.discountList) {
|
|
2765
|
-
|
|
2817
|
+
_context26.next = 14;
|
|
2766
2818
|
break;
|
|
2767
2819
|
}
|
|
2768
2820
|
OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
|
|
2769
|
-
|
|
2821
|
+
_context26.next = 13;
|
|
2770
2822
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
|
|
2771
2823
|
case 13:
|
|
2772
2824
|
tempOrder.discount_list = result.discountList.filter(function (discount) {
|
|
2773
2825
|
return discount.isSelected;
|
|
2774
2826
|
});
|
|
2775
2827
|
case 14:
|
|
2776
|
-
|
|
2828
|
+
_context26.next = 16;
|
|
2777
2829
|
return this.store.order.recalculateSummary({
|
|
2778
2830
|
createIfMissing: true
|
|
2779
2831
|
});
|
|
2780
2832
|
case 16:
|
|
2781
2833
|
this.store.order.persistTempOrder();
|
|
2782
|
-
|
|
2834
|
+
_context26.next = 19;
|
|
2783
2835
|
return this.effectsEmit('onDiscountApplied', {
|
|
2784
2836
|
productList: tempOrder.products || [],
|
|
2785
2837
|
discountList: result.discountList || [],
|
|
@@ -2787,19 +2839,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2787
2839
|
tempOrder: tempOrder
|
|
2788
2840
|
});
|
|
2789
2841
|
case 19:
|
|
2790
|
-
|
|
2842
|
+
_context26.next = 24;
|
|
2791
2843
|
break;
|
|
2792
2844
|
case 21:
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
throw
|
|
2845
|
+
_context26.prev = 21;
|
|
2846
|
+
_context26.t0 = _context26["catch"](0);
|
|
2847
|
+
throw _context26.t0;
|
|
2796
2848
|
case 24:
|
|
2797
2849
|
case "end":
|
|
2798
|
-
return
|
|
2850
|
+
return _context26.stop();
|
|
2799
2851
|
}
|
|
2800
|
-
},
|
|
2852
|
+
}, _callee26, this, [[0, 21]]);
|
|
2801
2853
|
}));
|
|
2802
|
-
function applyDiscountCalculationResult(
|
|
2854
|
+
function applyDiscountCalculationResult(_x22) {
|
|
2803
2855
|
return _applyDiscountCalculationResult.apply(this, arguments);
|
|
2804
2856
|
}
|
|
2805
2857
|
return applyDiscountCalculationResult;
|
|
@@ -2807,18 +2859,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2807
2859
|
}, {
|
|
2808
2860
|
key: "submitScanOrder",
|
|
2809
2861
|
value: function () {
|
|
2810
|
-
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2811
|
-
return _regeneratorRuntime().wrap(function
|
|
2812
|
-
while (1) switch (
|
|
2862
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
2863
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2864
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2813
2865
|
case 0:
|
|
2814
|
-
return
|
|
2866
|
+
return _context27.abrupt("return", this.submitSalesOrder(params));
|
|
2815
2867
|
case 1:
|
|
2816
2868
|
case "end":
|
|
2817
|
-
return
|
|
2869
|
+
return _context27.stop();
|
|
2818
2870
|
}
|
|
2819
|
-
},
|
|
2871
|
+
}, _callee27, this);
|
|
2820
2872
|
}));
|
|
2821
|
-
function submitScanOrder(
|
|
2873
|
+
function submitScanOrder(_x23) {
|
|
2822
2874
|
return _submitScanOrder.apply(this, arguments);
|
|
2823
2875
|
}
|
|
2824
2876
|
return submitScanOrder;
|
|
@@ -2832,14 +2884,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2832
2884
|
}, {
|
|
2833
2885
|
key: "submitSalesOrder",
|
|
2834
2886
|
value: (function () {
|
|
2835
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2887
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
2836
2888
|
var _params$smallTicketDa, _this$otherParams11, _this$otherParams12, _this$otherParams13, _this$otherParams14;
|
|
2837
2889
|
var inferredPaymentStatus, smallTicketDataFlag, submitParams;
|
|
2838
|
-
return _regeneratorRuntime().wrap(function
|
|
2839
|
-
while (1) switch (
|
|
2890
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2891
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2840
2892
|
case 0:
|
|
2841
2893
|
if (this.store.order) {
|
|
2842
|
-
|
|
2894
|
+
_context28.next = 2;
|
|
2843
2895
|
break;
|
|
2844
2896
|
}
|
|
2845
2897
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -2865,14 +2917,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2865
2917
|
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2866
2918
|
enhancePayload: params.enhancePayload
|
|
2867
2919
|
} : {});
|
|
2868
|
-
return
|
|
2920
|
+
return _context28.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
|
|
2869
2921
|
case 6:
|
|
2870
2922
|
case "end":
|
|
2871
|
-
return
|
|
2923
|
+
return _context28.stop();
|
|
2872
2924
|
}
|
|
2873
|
-
},
|
|
2925
|
+
}, _callee28, this);
|
|
2874
2926
|
}));
|
|
2875
|
-
function submitSalesOrder(
|
|
2927
|
+
function submitSalesOrder(_x24) {
|
|
2876
2928
|
return _submitSalesOrder.apply(this, arguments);
|
|
2877
2929
|
}
|
|
2878
2930
|
return submitSalesOrder;
|
|
@@ -2880,18 +2932,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2880
2932
|
}, {
|
|
2881
2933
|
key: "saveSalesOrderDraft",
|
|
2882
2934
|
value: function () {
|
|
2883
|
-
var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2935
|
+
var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
2884
2936
|
var _params$platform, _this$otherParams15, _this$otherParams16, _this$otherParams17, _params$channel, _params$type, _this$otherParams18;
|
|
2885
|
-
return _regeneratorRuntime().wrap(function
|
|
2886
|
-
while (1) switch (
|
|
2937
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2938
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2887
2939
|
case 0:
|
|
2888
2940
|
if (this.store.order) {
|
|
2889
|
-
|
|
2941
|
+
_context29.next = 2;
|
|
2890
2942
|
break;
|
|
2891
2943
|
}
|
|
2892
2944
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
2893
2945
|
case 2:
|
|
2894
|
-
return
|
|
2946
|
+
return _context29.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
|
|
2895
2947
|
cacheId: this.cacheId,
|
|
2896
2948
|
platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.platform,
|
|
2897
2949
|
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.businessCode) || ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.business_code),
|
|
@@ -2902,11 +2954,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2902
2954
|
} : {})));
|
|
2903
2955
|
case 3:
|
|
2904
2956
|
case "end":
|
|
2905
|
-
return
|
|
2957
|
+
return _context29.stop();
|
|
2906
2958
|
}
|
|
2907
|
-
},
|
|
2959
|
+
}, _callee29, this);
|
|
2908
2960
|
}));
|
|
2909
|
-
function saveSalesOrderDraft(
|
|
2961
|
+
function saveSalesOrderDraft(_x25) {
|
|
2910
2962
|
return _saveSalesOrderDraft.apply(this, arguments);
|
|
2911
2963
|
}
|
|
2912
2964
|
return saveSalesOrderDraft;
|
|
@@ -2914,14 +2966,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2914
2966
|
}, {
|
|
2915
2967
|
key: "submitTempOrderAsync",
|
|
2916
2968
|
value: function () {
|
|
2917
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2969
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
2918
2970
|
var _params$smallTicketDa2, _this$otherParams19, _this$otherParams20, _this$otherParams21, _this$otherParams22;
|
|
2919
2971
|
var inferredPaymentStatus, smallTicketDataFlag, submitParams;
|
|
2920
|
-
return _regeneratorRuntime().wrap(function
|
|
2921
|
-
while (1) switch (
|
|
2972
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2973
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2922
2974
|
case 0:
|
|
2923
2975
|
if (this.store.order) {
|
|
2924
|
-
|
|
2976
|
+
_context30.next = 2;
|
|
2925
2977
|
break;
|
|
2926
2978
|
}
|
|
2927
2979
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -2946,14 +2998,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2946
2998
|
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2947
2999
|
enhancePayload: params.enhancePayload
|
|
2948
3000
|
} : {});
|
|
2949
|
-
return
|
|
3001
|
+
return _context30.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
|
|
2950
3002
|
case 6:
|
|
2951
3003
|
case "end":
|
|
2952
|
-
return
|
|
3004
|
+
return _context30.stop();
|
|
2953
3005
|
}
|
|
2954
|
-
},
|
|
3006
|
+
}, _callee30, this);
|
|
2955
3007
|
}));
|
|
2956
|
-
function submitTempOrderAsync(
|
|
3008
|
+
function submitTempOrderAsync(_x26) {
|
|
2957
3009
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
2958
3010
|
}
|
|
2959
3011
|
return submitTempOrderAsync;
|
|
@@ -2979,14 +3031,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2979
3031
|
}, {
|
|
2980
3032
|
key: "printLocalOrderReceipt",
|
|
2981
3033
|
value: function () {
|
|
2982
|
-
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3034
|
+
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(lookup) {
|
|
2983
3035
|
var _this$otherParams24, _this$otherParams25, _this$otherParams26, _this$otherParams27;
|
|
2984
3036
|
var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order5, _data;
|
|
2985
|
-
return _regeneratorRuntime().wrap(function
|
|
2986
|
-
while (1) switch (
|
|
3037
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
3038
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2987
3039
|
case 0:
|
|
2988
3040
|
if (this.store.order) {
|
|
2989
|
-
|
|
3041
|
+
_context31.next = 2;
|
|
2990
3042
|
break;
|
|
2991
3043
|
}
|
|
2992
3044
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -3017,28 +3069,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3017
3069
|
channel: context.channel,
|
|
3018
3070
|
type: context.type
|
|
3019
3071
|
});
|
|
3020
|
-
|
|
3072
|
+
_context31.next = 8;
|
|
3021
3073
|
return this.request.post('/local/print-order', payload, {
|
|
3022
3074
|
osServer: true,
|
|
3023
3075
|
customToast: function customToast() {}
|
|
3024
3076
|
});
|
|
3025
3077
|
case 8:
|
|
3026
|
-
response =
|
|
3078
|
+
response = _context31.sent;
|
|
3027
3079
|
if (hasLookup) {
|
|
3028
|
-
|
|
3080
|
+
_context31.next = 12;
|
|
3029
3081
|
break;
|
|
3030
3082
|
}
|
|
3031
|
-
|
|
3083
|
+
_context31.next = 12;
|
|
3032
3084
|
return (_this$store$order$app = (_this$store$order5 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order5, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
|
|
3033
3085
|
case 12:
|
|
3034
|
-
return
|
|
3086
|
+
return _context31.abrupt("return", response);
|
|
3035
3087
|
case 13:
|
|
3036
3088
|
case "end":
|
|
3037
|
-
return
|
|
3089
|
+
return _context31.stop();
|
|
3038
3090
|
}
|
|
3039
|
-
},
|
|
3091
|
+
}, _callee31, this);
|
|
3040
3092
|
}));
|
|
3041
|
-
function printLocalOrderReceipt(
|
|
3093
|
+
function printLocalOrderReceipt(_x27) {
|
|
3042
3094
|
return _printLocalOrderReceipt.apply(this, arguments);
|
|
3043
3095
|
}
|
|
3044
3096
|
return printLocalOrderReceipt;
|
|
@@ -3059,14 +3111,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3059
3111
|
}, {
|
|
3060
3112
|
key: "syncPaymentsToOrder",
|
|
3061
3113
|
value: function () {
|
|
3062
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3114
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
3063
3115
|
var _ref32, _params$businessCode, _this$otherParams28, _this$otherParams29, _params$channel2;
|
|
3064
3116
|
var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
|
|
3065
|
-
return _regeneratorRuntime().wrap(function
|
|
3066
|
-
while (1) switch (
|
|
3117
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3118
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
3067
3119
|
case 0:
|
|
3068
3120
|
if (this.store.order) {
|
|
3069
|
-
|
|
3121
|
+
_context32.next = 2;
|
|
3070
3122
|
break;
|
|
3071
3123
|
}
|
|
3072
3124
|
throw new Error('order 模块未初始化');
|
|
@@ -3082,14 +3134,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3082
3134
|
} : {});
|
|
3083
3135
|
syncState = this.store.order.getOrderSyncState();
|
|
3084
3136
|
if (!(params.submitWhenPaid && syncState === 'submitting')) {
|
|
3085
|
-
|
|
3137
|
+
_context32.next = 9;
|
|
3086
3138
|
break;
|
|
3087
3139
|
}
|
|
3088
3140
|
this.queueLatestAutoPaymentSync();
|
|
3089
|
-
return
|
|
3141
|
+
return _context32.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
|
|
3090
3142
|
case 9:
|
|
3091
3143
|
payments = params.payments || [];
|
|
3092
|
-
|
|
3144
|
+
_context32.next = 12;
|
|
3093
3145
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
|
|
3094
3146
|
payments: payments,
|
|
3095
3147
|
params: syncParams,
|
|
@@ -3097,11 +3149,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3097
3149
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
3098
3150
|
});
|
|
3099
3151
|
case 12:
|
|
3100
|
-
|
|
3101
|
-
|
|
3152
|
+
_context32.prev = 12;
|
|
3153
|
+
_context32.next = 15;
|
|
3102
3154
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
3103
3155
|
case 15:
|
|
3104
|
-
syncResult =
|
|
3156
|
+
syncResult = _context32.sent;
|
|
3105
3157
|
latestPayments = this.store.order.getOrderPayments();
|
|
3106
3158
|
amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
3107
3159
|
orderSnapshot = this.store.order.getOrderSnapshot();
|
|
@@ -3119,25 +3171,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3119
3171
|
depositAmount: syncResult.depositAmount,
|
|
3120
3172
|
orderExpectedAmount: syncResult.orderExpectedAmount
|
|
3121
3173
|
};
|
|
3122
|
-
|
|
3174
|
+
_context32.next = 22;
|
|
3123
3175
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
|
|
3124
3176
|
case 22:
|
|
3125
3177
|
if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
|
|
3126
|
-
|
|
3178
|
+
_context32.next = 25;
|
|
3127
3179
|
break;
|
|
3128
3180
|
}
|
|
3129
|
-
|
|
3181
|
+
_context32.next = 25;
|
|
3130
3182
|
return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
3131
3183
|
case 25:
|
|
3132
3184
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3133
|
-
return
|
|
3185
|
+
return _context32.abrupt("return", syncResult);
|
|
3134
3186
|
case 29:
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3187
|
+
_context32.prev = 29;
|
|
3188
|
+
_context32.t0 = _context32["catch"](12);
|
|
3189
|
+
_context32.next = 33;
|
|
3138
3190
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
3139
3191
|
ok: false,
|
|
3140
|
-
error:
|
|
3192
|
+
error: _context32.t0,
|
|
3141
3193
|
payments: this.store.order.getOrderPayments(),
|
|
3142
3194
|
params: syncParams,
|
|
3143
3195
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
@@ -3145,14 +3197,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3145
3197
|
});
|
|
3146
3198
|
case 33:
|
|
3147
3199
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3148
|
-
throw
|
|
3200
|
+
throw _context32.t0;
|
|
3149
3201
|
case 35:
|
|
3150
3202
|
case "end":
|
|
3151
|
-
return
|
|
3203
|
+
return _context32.stop();
|
|
3152
3204
|
}
|
|
3153
|
-
},
|
|
3205
|
+
}, _callee32, this, [[12, 29]]);
|
|
3154
3206
|
}));
|
|
3155
|
-
function syncPaymentsToOrder(
|
|
3207
|
+
function syncPaymentsToOrder(_x28) {
|
|
3156
3208
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
3157
3209
|
}
|
|
3158
3210
|
return syncPaymentsToOrder;
|
|
@@ -3201,46 +3253,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3201
3253
|
}, {
|
|
3202
3254
|
key: "flushQueuedAutoPaymentSync",
|
|
3203
3255
|
value: function () {
|
|
3204
|
-
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3256
|
+
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
3205
3257
|
var payments;
|
|
3206
|
-
return _regeneratorRuntime().wrap(function
|
|
3207
|
-
while (1) switch (
|
|
3258
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3259
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
3208
3260
|
case 0:
|
|
3209
3261
|
if (this.store.order) {
|
|
3210
|
-
|
|
3262
|
+
_context33.next = 2;
|
|
3211
3263
|
break;
|
|
3212
3264
|
}
|
|
3213
|
-
return
|
|
3265
|
+
return _context33.abrupt("return");
|
|
3214
3266
|
case 2:
|
|
3215
3267
|
if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
|
|
3216
|
-
|
|
3268
|
+
_context33.next = 4;
|
|
3217
3269
|
break;
|
|
3218
3270
|
}
|
|
3219
|
-
return
|
|
3271
|
+
return _context33.abrupt("return");
|
|
3220
3272
|
case 4:
|
|
3221
3273
|
if (!(this.store.order.getOrderSyncState() === 'submitting')) {
|
|
3222
|
-
|
|
3274
|
+
_context33.next = 7;
|
|
3223
3275
|
break;
|
|
3224
3276
|
}
|
|
3225
3277
|
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
3226
|
-
return
|
|
3278
|
+
return _context33.abrupt("return");
|
|
3227
3279
|
case 7:
|
|
3228
3280
|
this.autoPaymentSyncFlushing = true;
|
|
3229
|
-
|
|
3281
|
+
_context33.prev = 8;
|
|
3230
3282
|
case 9:
|
|
3231
3283
|
if (!this.queuedAutoPaymentSync) {
|
|
3232
|
-
|
|
3284
|
+
_context33.next = 18;
|
|
3233
3285
|
break;
|
|
3234
3286
|
}
|
|
3235
3287
|
this.queuedAutoPaymentSync = false;
|
|
3236
3288
|
payments = this.store.order.getOrderPayments();
|
|
3237
3289
|
if (payments.length) {
|
|
3238
|
-
|
|
3290
|
+
_context33.next = 14;
|
|
3239
3291
|
break;
|
|
3240
3292
|
}
|
|
3241
|
-
return
|
|
3293
|
+
return _context33.abrupt("continue", 9);
|
|
3242
3294
|
case 14:
|
|
3243
|
-
|
|
3295
|
+
_context33.next = 16;
|
|
3244
3296
|
return this.syncPaymentsToOrder({
|
|
3245
3297
|
payments: payments,
|
|
3246
3298
|
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
@@ -3248,29 +3300,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3248
3300
|
smallTicketDataFlag: 1
|
|
3249
3301
|
});
|
|
3250
3302
|
case 16:
|
|
3251
|
-
|
|
3303
|
+
_context33.next = 9;
|
|
3252
3304
|
break;
|
|
3253
3305
|
case 18:
|
|
3254
|
-
|
|
3306
|
+
_context33.next = 23;
|
|
3255
3307
|
break;
|
|
3256
3308
|
case 20:
|
|
3257
|
-
|
|
3258
|
-
|
|
3309
|
+
_context33.prev = 20;
|
|
3310
|
+
_context33.t0 = _context33["catch"](8);
|
|
3259
3311
|
this.logError('queued auto sync payments failed', {
|
|
3260
|
-
error:
|
|
3312
|
+
error: _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0)
|
|
3261
3313
|
});
|
|
3262
3314
|
case 23:
|
|
3263
|
-
|
|
3315
|
+
_context33.prev = 23;
|
|
3264
3316
|
this.autoPaymentSyncFlushing = false;
|
|
3265
3317
|
if (this.queuedAutoPaymentSync) {
|
|
3266
3318
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3267
3319
|
}
|
|
3268
|
-
return
|
|
3320
|
+
return _context33.finish(23);
|
|
3269
3321
|
case 27:
|
|
3270
3322
|
case "end":
|
|
3271
|
-
return
|
|
3323
|
+
return _context33.stop();
|
|
3272
3324
|
}
|
|
3273
|
-
},
|
|
3325
|
+
}, _callee33, this, [[8, 20, 23, 27]]);
|
|
3274
3326
|
}));
|
|
3275
3327
|
function flushQueuedAutoPaymentSync() {
|
|
3276
3328
|
return _flushQueuedAutoPaymentSync.apply(this, arguments);
|
|
@@ -3294,35 +3346,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3294
3346
|
}, {
|
|
3295
3347
|
key: "addOrderPaymentAsync",
|
|
3296
3348
|
value: (function () {
|
|
3297
|
-
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3349
|
+
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(payment) {
|
|
3298
3350
|
var paymentRecord, hasPaymentNumber, devicePrefix;
|
|
3299
|
-
return _regeneratorRuntime().wrap(function
|
|
3300
|
-
while (1) switch (
|
|
3351
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3352
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3301
3353
|
case 0:
|
|
3302
3354
|
paymentRecord = payment;
|
|
3303
3355
|
hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
|
|
3304
3356
|
if (!hasPaymentNumber) {
|
|
3305
|
-
|
|
3357
|
+
_context34.next = 6;
|
|
3306
3358
|
break;
|
|
3307
3359
|
}
|
|
3308
|
-
|
|
3309
|
-
|
|
3360
|
+
_context34.t0 = 'LOCAL';
|
|
3361
|
+
_context34.next = 9;
|
|
3310
3362
|
break;
|
|
3311
3363
|
case 6:
|
|
3312
|
-
|
|
3364
|
+
_context34.next = 8;
|
|
3313
3365
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
3314
3366
|
case 8:
|
|
3315
|
-
|
|
3367
|
+
_context34.t0 = _context34.sent;
|
|
3316
3368
|
case 9:
|
|
3317
|
-
devicePrefix =
|
|
3318
|
-
return
|
|
3369
|
+
devicePrefix = _context34.t0;
|
|
3370
|
+
return _context34.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
3319
3371
|
case 11:
|
|
3320
3372
|
case "end":
|
|
3321
|
-
return
|
|
3373
|
+
return _context34.stop();
|
|
3322
3374
|
}
|
|
3323
|
-
},
|
|
3375
|
+
}, _callee34, this);
|
|
3324
3376
|
}));
|
|
3325
|
-
function addOrderPaymentAsync(
|
|
3377
|
+
function addOrderPaymentAsync(_x29) {
|
|
3326
3378
|
return _addOrderPaymentAsync.apply(this, arguments);
|
|
3327
3379
|
}
|
|
3328
3380
|
return addOrderPaymentAsync;
|
|
@@ -3391,7 +3443,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3391
3443
|
}, {
|
|
3392
3444
|
key: "updateOrderPayment",
|
|
3393
3445
|
value: (function () {
|
|
3394
|
-
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3446
|
+
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(paymentIdentity, updates) {
|
|
3395
3447
|
var _result$payment, _result$payment2;
|
|
3396
3448
|
var options,
|
|
3397
3449
|
matchMode,
|
|
@@ -3408,13 +3460,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3408
3460
|
shouldSubmit,
|
|
3409
3461
|
syncResult,
|
|
3410
3462
|
_options$smallTicketD2,
|
|
3411
|
-
|
|
3412
|
-
return _regeneratorRuntime().wrap(function
|
|
3413
|
-
while (1) switch (
|
|
3463
|
+
_args35 = arguments;
|
|
3464
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3465
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3414
3466
|
case 0:
|
|
3415
|
-
options =
|
|
3467
|
+
options = _args35.length > 2 && _args35[2] !== undefined ? _args35[2] : {};
|
|
3416
3468
|
if (this.store.order) {
|
|
3417
|
-
|
|
3469
|
+
_context35.next = 3;
|
|
3418
3470
|
break;
|
|
3419
3471
|
}
|
|
3420
3472
|
throw new Error('order 模块未初始化');
|
|
@@ -3423,15 +3475,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3423
3475
|
previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
|
|
3424
3476
|
previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
|
|
3425
3477
|
if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
|
|
3426
|
-
|
|
3478
|
+
_context35.next = 13;
|
|
3427
3479
|
break;
|
|
3428
3480
|
}
|
|
3429
3481
|
currentPayments = this.store.order.getOrderPayments();
|
|
3430
3482
|
if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
|
|
3431
|
-
|
|
3483
|
+
_context35.next = 12;
|
|
3432
3484
|
break;
|
|
3433
3485
|
}
|
|
3434
|
-
|
|
3486
|
+
_context35.next = 11;
|
|
3435
3487
|
return this.syncPaymentsToOrder({
|
|
3436
3488
|
payments: currentPayments,
|
|
3437
3489
|
paymentStatus: this.getPaymentStatusForSync(currentPayments),
|
|
@@ -3439,9 +3491,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3439
3491
|
smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
|
|
3440
3492
|
});
|
|
3441
3493
|
case 11:
|
|
3442
|
-
_syncResult =
|
|
3494
|
+
_syncResult = _context35.sent;
|
|
3443
3495
|
case 12:
|
|
3444
|
-
return
|
|
3496
|
+
return _context35.abrupt("return", _objectSpread({
|
|
3445
3497
|
updated: false,
|
|
3446
3498
|
payment: previousPayment,
|
|
3447
3499
|
payments: currentPayments,
|
|
@@ -3450,44 +3502,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3450
3502
|
syncResult: _syncResult
|
|
3451
3503
|
} : {}));
|
|
3452
3504
|
case 13:
|
|
3453
|
-
|
|
3505
|
+
_context35.next = 15;
|
|
3454
3506
|
return this.store.order.updateOrderPayment(paymentIdentity, updates, {
|
|
3455
3507
|
matchBy: matchMode
|
|
3456
3508
|
});
|
|
3457
3509
|
case 15:
|
|
3458
|
-
result =
|
|
3510
|
+
result = _context35.sent;
|
|
3459
3511
|
if (!(options.persistDraft !== false)) {
|
|
3460
|
-
|
|
3512
|
+
_context35.next = 29;
|
|
3461
3513
|
break;
|
|
3462
3514
|
}
|
|
3463
|
-
|
|
3464
|
-
|
|
3515
|
+
_context35.prev = 17;
|
|
3516
|
+
_context35.next = 20;
|
|
3465
3517
|
return this.saveSalesOrderDraft();
|
|
3466
3518
|
case 20:
|
|
3467
|
-
draftResult =
|
|
3468
|
-
|
|
3519
|
+
draftResult = _context35.sent;
|
|
3520
|
+
_context35.next = 29;
|
|
3469
3521
|
break;
|
|
3470
3522
|
case 23:
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
draftError =
|
|
3523
|
+
_context35.prev = 23;
|
|
3524
|
+
_context35.t0 = _context35["catch"](17);
|
|
3525
|
+
draftError = _context35.t0;
|
|
3474
3526
|
this.logError('updateOrderPayment: 保存支付草稿失败', {
|
|
3475
3527
|
paymentIdentity: paymentIdentity,
|
|
3476
|
-
error:
|
|
3528
|
+
error: _context35.t0 instanceof Error ? _context35.t0.message : String(_context35.t0)
|
|
3477
3529
|
});
|
|
3478
3530
|
if (options.submitWhenPaid) {
|
|
3479
|
-
|
|
3531
|
+
_context35.next = 29;
|
|
3480
3532
|
break;
|
|
3481
3533
|
}
|
|
3482
|
-
throw
|
|
3534
|
+
throw _context35.t0;
|
|
3483
3535
|
case 29:
|
|
3484
3536
|
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';
|
|
3485
3537
|
shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
|
|
3486
3538
|
if (!shouldSubmit) {
|
|
3487
|
-
|
|
3539
|
+
_context35.next = 35;
|
|
3488
3540
|
break;
|
|
3489
3541
|
}
|
|
3490
|
-
|
|
3542
|
+
_context35.next = 34;
|
|
3491
3543
|
return this.syncPaymentsToOrder({
|
|
3492
3544
|
payments: result.payments,
|
|
3493
3545
|
paymentStatus: this.getPaymentStatusForSync(result.payments),
|
|
@@ -3495,9 +3547,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3495
3547
|
smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
|
|
3496
3548
|
});
|
|
3497
3549
|
case 34:
|
|
3498
|
-
syncResult =
|
|
3550
|
+
syncResult = _context35.sent;
|
|
3499
3551
|
case 35:
|
|
3500
|
-
return
|
|
3552
|
+
return _context35.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
|
|
3501
3553
|
draftResult: draftResult
|
|
3502
3554
|
} : {}), draftError !== undefined ? {
|
|
3503
3555
|
draftError: draftError
|
|
@@ -3506,11 +3558,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3506
3558
|
} : {}));
|
|
3507
3559
|
case 36:
|
|
3508
3560
|
case "end":
|
|
3509
|
-
return
|
|
3561
|
+
return _context35.stop();
|
|
3510
3562
|
}
|
|
3511
|
-
},
|
|
3563
|
+
}, _callee35, this, [[17, 23]]);
|
|
3512
3564
|
}));
|
|
3513
|
-
function updateOrderPayment(
|
|
3565
|
+
function updateOrderPayment(_x30, _x31) {
|
|
3514
3566
|
return _updateOrderPayment.apply(this, arguments);
|
|
3515
3567
|
}
|
|
3516
3568
|
return updateOrderPayment;
|
|
@@ -3532,24 +3584,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3532
3584
|
}, {
|
|
3533
3585
|
key: "updateVoucherOrderPaymentsAsync",
|
|
3534
3586
|
value: function () {
|
|
3535
|
-
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3536
|
-
return _regeneratorRuntime().wrap(function
|
|
3537
|
-
while (1) switch (
|
|
3587
|
+
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(payments, options) {
|
|
3588
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
3589
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3538
3590
|
case 0:
|
|
3539
3591
|
if (this.store.order) {
|
|
3540
|
-
|
|
3592
|
+
_context36.next = 2;
|
|
3541
3593
|
break;
|
|
3542
3594
|
}
|
|
3543
3595
|
throw new Error('order 模块未初始化');
|
|
3544
3596
|
case 2:
|
|
3545
|
-
return
|
|
3597
|
+
return _context36.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
|
|
3546
3598
|
case 3:
|
|
3547
3599
|
case "end":
|
|
3548
|
-
return
|
|
3600
|
+
return _context36.stop();
|
|
3549
3601
|
}
|
|
3550
|
-
},
|
|
3602
|
+
}, _callee36, this);
|
|
3551
3603
|
}));
|
|
3552
|
-
function updateVoucherOrderPaymentsAsync(
|
|
3604
|
+
function updateVoucherOrderPaymentsAsync(_x32, _x33) {
|
|
3553
3605
|
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
3554
3606
|
}
|
|
3555
3607
|
return updateVoucherOrderPaymentsAsync;
|
|
@@ -3660,20 +3712,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3660
3712
|
}, {
|
|
3661
3713
|
key: "initWalletData",
|
|
3662
3714
|
value: function () {
|
|
3663
|
-
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3715
|
+
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
3664
3716
|
var _snapshot$identity;
|
|
3665
3717
|
var snapshot, walletBusinessData, result;
|
|
3666
|
-
return _regeneratorRuntime().wrap(function
|
|
3667
|
-
while (1) switch (
|
|
3718
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3719
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
3668
3720
|
case 0:
|
|
3669
3721
|
if (this.store.order) {
|
|
3670
|
-
|
|
3722
|
+
_context37.next = 2;
|
|
3671
3723
|
break;
|
|
3672
3724
|
}
|
|
3673
3725
|
throw new Error('order 模块未初始化');
|
|
3674
3726
|
case 2:
|
|
3675
3727
|
if (this.store.payment) {
|
|
3676
|
-
|
|
3728
|
+
_context37.next = 4;
|
|
3677
3729
|
break;
|
|
3678
3730
|
}
|
|
3679
3731
|
throw new Error('payment 模块未初始化');
|
|
@@ -3681,10 +3733,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3681
3733
|
snapshot = this.store.order.getOrderSnapshot();
|
|
3682
3734
|
walletBusinessData = this.buildWalletInitBusinessData(params);
|
|
3683
3735
|
if (walletBusinessData) {
|
|
3684
|
-
|
|
3736
|
+
_context37.next = 8;
|
|
3685
3737
|
break;
|
|
3686
3738
|
}
|
|
3687
|
-
return
|
|
3739
|
+
return _context37.abrupt("return", {
|
|
3688
3740
|
walletRecommendList: [],
|
|
3689
3741
|
userIdentificationCodes: [],
|
|
3690
3742
|
transformList: [],
|
|
@@ -3692,11 +3744,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3692
3744
|
products: []
|
|
3693
3745
|
});
|
|
3694
3746
|
case 8:
|
|
3695
|
-
|
|
3747
|
+
_context37.next = 10;
|
|
3696
3748
|
return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
3697
3749
|
case 10:
|
|
3698
|
-
result =
|
|
3699
|
-
|
|
3750
|
+
result = _context37.sent;
|
|
3751
|
+
_context37.next = 13;
|
|
3700
3752
|
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
3701
3753
|
orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
|
|
3702
3754
|
customerId: walletBusinessData.customer_id,
|
|
@@ -3708,14 +3760,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3708
3760
|
timestamp: Date.now()
|
|
3709
3761
|
});
|
|
3710
3762
|
case 13:
|
|
3711
|
-
return
|
|
3763
|
+
return _context37.abrupt("return", result);
|
|
3712
3764
|
case 14:
|
|
3713
3765
|
case "end":
|
|
3714
|
-
return
|
|
3766
|
+
return _context37.stop();
|
|
3715
3767
|
}
|
|
3716
|
-
},
|
|
3768
|
+
}, _callee37, this);
|
|
3717
3769
|
}));
|
|
3718
|
-
function initWalletData(
|
|
3770
|
+
function initWalletData(_x34) {
|
|
3719
3771
|
return _initWalletData.apply(this, arguments);
|
|
3720
3772
|
}
|
|
3721
3773
|
return initWalletData;
|
|
@@ -3766,23 +3818,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3766
3818
|
}, {
|
|
3767
3819
|
key: "publishWalletAssetsState",
|
|
3768
3820
|
value: function () {
|
|
3769
|
-
var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3770
|
-
return _regeneratorRuntime().wrap(function
|
|
3771
|
-
while (1) switch (
|
|
3821
|
+
var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(state) {
|
|
3822
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3823
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3772
3824
|
case 0:
|
|
3773
|
-
|
|
3825
|
+
_context38.next = 2;
|
|
3774
3826
|
return this.effectsEmit(BaseSalesHookNames.onWalletAssetsStateChanged, {
|
|
3775
3827
|
state: state
|
|
3776
3828
|
});
|
|
3777
3829
|
case 2:
|
|
3778
|
-
return
|
|
3830
|
+
return _context38.abrupt("return", state);
|
|
3779
3831
|
case 3:
|
|
3780
3832
|
case "end":
|
|
3781
|
-
return
|
|
3833
|
+
return _context38.stop();
|
|
3782
3834
|
}
|
|
3783
|
-
},
|
|
3835
|
+
}, _callee38, this);
|
|
3784
3836
|
}));
|
|
3785
|
-
function publishWalletAssetsState(
|
|
3837
|
+
function publishWalletAssetsState(_x35) {
|
|
3786
3838
|
return _publishWalletAssetsState.apply(this, arguments);
|
|
3787
3839
|
}
|
|
3788
3840
|
return publishWalletAssetsState;
|
|
@@ -3790,26 +3842,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3790
3842
|
}, {
|
|
3791
3843
|
key: "syncSelectedWalletAssets",
|
|
3792
3844
|
value: function () {
|
|
3793
|
-
var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3845
|
+
var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(state) {
|
|
3794
3846
|
var paymentMethods, methodByCode, preparePayments, selectedAssetById, voucherPayments, payments;
|
|
3795
|
-
return _regeneratorRuntime().wrap(function
|
|
3796
|
-
while (1) switch (
|
|
3847
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3848
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3797
3849
|
case 0:
|
|
3798
3850
|
if (!(!this.store.order || !this.store.payment)) {
|
|
3799
|
-
|
|
3851
|
+
_context39.next = 2;
|
|
3800
3852
|
break;
|
|
3801
3853
|
}
|
|
3802
3854
|
throw new Error('订单或支付模块未初始化');
|
|
3803
3855
|
case 2:
|
|
3804
3856
|
paymentMethods = this.getPaymentMethods();
|
|
3805
3857
|
if (!(!paymentMethods.length && state.selectedItems.length)) {
|
|
3806
|
-
|
|
3858
|
+
_context39.next = 7;
|
|
3807
3859
|
break;
|
|
3808
3860
|
}
|
|
3809
|
-
|
|
3861
|
+
_context39.next = 6;
|
|
3810
3862
|
return this.getPaymentMethodsAsync();
|
|
3811
3863
|
case 6:
|
|
3812
|
-
paymentMethods =
|
|
3864
|
+
paymentMethods = _context39.sent;
|
|
3813
3865
|
case 7:
|
|
3814
3866
|
methodByCode = new Map(paymentMethods.map(function (method) {
|
|
3815
3867
|
return [String(method.code || '').toUpperCase(), method];
|
|
@@ -3851,19 +3903,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3851
3903
|
payments = this.updateVoucherOrderPayments(voucherPayments, {
|
|
3852
3904
|
status: 'payment_pending'
|
|
3853
3905
|
});
|
|
3854
|
-
|
|
3906
|
+
_context39.next = 14;
|
|
3855
3907
|
return this.store.order.recalculateSummary({
|
|
3856
3908
|
createIfMissing: true
|
|
3857
3909
|
});
|
|
3858
3910
|
case 14:
|
|
3859
|
-
return
|
|
3911
|
+
return _context39.abrupt("return", payments);
|
|
3860
3912
|
case 15:
|
|
3861
3913
|
case "end":
|
|
3862
|
-
return
|
|
3914
|
+
return _context39.stop();
|
|
3863
3915
|
}
|
|
3864
|
-
},
|
|
3916
|
+
}, _callee39, this);
|
|
3865
3917
|
}));
|
|
3866
|
-
function syncSelectedWalletAssets(
|
|
3918
|
+
function syncSelectedWalletAssets(_x36) {
|
|
3867
3919
|
return _syncSelectedWalletAssets.apply(this, arguments);
|
|
3868
3920
|
}
|
|
3869
3921
|
return syncSelectedWalletAssets;
|
|
@@ -3897,29 +3949,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3897
3949
|
}, {
|
|
3898
3950
|
key: "importWalletAssetsSnapshot",
|
|
3899
3951
|
value: (function () {
|
|
3900
|
-
var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3952
|
+
var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(snapshot) {
|
|
3901
3953
|
var state;
|
|
3902
|
-
return _regeneratorRuntime().wrap(function
|
|
3903
|
-
while (1) switch (
|
|
3954
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3955
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3904
3956
|
case 0:
|
|
3905
3957
|
if (this.store.payment) {
|
|
3906
|
-
|
|
3958
|
+
_context40.next = 2;
|
|
3907
3959
|
break;
|
|
3908
3960
|
}
|
|
3909
3961
|
throw new Error('payment 模块未初始化');
|
|
3910
3962
|
case 2:
|
|
3911
3963
|
state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
|
|
3912
|
-
|
|
3964
|
+
_context40.next = 5;
|
|
3913
3965
|
return this.syncSelectedWalletAssets(state);
|
|
3914
3966
|
case 5:
|
|
3915
|
-
return
|
|
3967
|
+
return _context40.abrupt("return", this.publishWalletAssetsState(state));
|
|
3916
3968
|
case 6:
|
|
3917
3969
|
case "end":
|
|
3918
|
-
return
|
|
3970
|
+
return _context40.stop();
|
|
3919
3971
|
}
|
|
3920
|
-
},
|
|
3972
|
+
}, _callee40, this);
|
|
3921
3973
|
}));
|
|
3922
|
-
function importWalletAssetsSnapshot(
|
|
3974
|
+
function importWalletAssetsSnapshot(_x37) {
|
|
3923
3975
|
return _importWalletAssetsSnapshot.apply(this, arguments);
|
|
3924
3976
|
}
|
|
3925
3977
|
return importWalletAssetsSnapshot;
|
|
@@ -3931,20 +3983,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3931
3983
|
}, {
|
|
3932
3984
|
key: "refreshWalletAssets",
|
|
3933
3985
|
value: (function () {
|
|
3934
|
-
var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3986
|
+
var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
3935
3987
|
var _previousState$custom, _businessData$custome;
|
|
3936
3988
|
var refreshSequence, wallet, businessData, emptyState, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, committed;
|
|
3937
|
-
return _regeneratorRuntime().wrap(function
|
|
3938
|
-
while (1) switch (
|
|
3989
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3990
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3939
3991
|
case 0:
|
|
3940
3992
|
if (this.store.order) {
|
|
3941
|
-
|
|
3993
|
+
_context41.next = 2;
|
|
3942
3994
|
break;
|
|
3943
3995
|
}
|
|
3944
3996
|
throw new Error('order 模块未初始化');
|
|
3945
3997
|
case 2:
|
|
3946
3998
|
if (this.store.payment) {
|
|
3947
|
-
|
|
3999
|
+
_context41.next = 4;
|
|
3948
4000
|
break;
|
|
3949
4001
|
}
|
|
3950
4002
|
throw new Error('payment 模块未初始化');
|
|
@@ -3953,7 +4005,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3953
4005
|
wallet = this.store.payment.wallet;
|
|
3954
4006
|
businessData = this.buildWalletInitBusinessData(params);
|
|
3955
4007
|
if (businessData) {
|
|
3956
|
-
|
|
4008
|
+
_context41.next = 12;
|
|
3957
4009
|
break;
|
|
3958
4010
|
}
|
|
3959
4011
|
wallet.clearAllCache();
|
|
@@ -3961,53 +4013,53 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3961
4013
|
this.updateVoucherOrderPayments([], {
|
|
3962
4014
|
status: 'payment_pending'
|
|
3963
4015
|
});
|
|
3964
|
-
return
|
|
4016
|
+
return _context41.abrupt("return", this.publishWalletAssetsState(emptyState));
|
|
3965
4017
|
case 12:
|
|
3966
4018
|
previousState = wallet.getWalletAssetsState();
|
|
3967
4019
|
hasPreviousWalletContext = previousState.status !== 'idle' || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== undefined;
|
|
3968
4020
|
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 : '');
|
|
3969
4021
|
if (!customerChanged) {
|
|
3970
|
-
|
|
4022
|
+
_context41.next = 20;
|
|
3971
4023
|
break;
|
|
3972
4024
|
}
|
|
3973
4025
|
clearedState = wallet.clearWalletAssetSelection();
|
|
3974
4026
|
this.updateVoucherOrderPayments([], {
|
|
3975
4027
|
status: 'payment_pending'
|
|
3976
4028
|
});
|
|
3977
|
-
|
|
4029
|
+
_context41.next = 20;
|
|
3978
4030
|
return this.publishWalletAssetsState(clearedState);
|
|
3979
4031
|
case 20:
|
|
3980
4032
|
refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
|
|
3981
4033
|
preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged
|
|
3982
4034
|
});
|
|
3983
|
-
|
|
4035
|
+
_context41.next = 23;
|
|
3984
4036
|
return this.publishWalletAssetsState(wallet.getWalletAssetsState());
|
|
3985
4037
|
case 23:
|
|
3986
|
-
|
|
4038
|
+
_context41.next = 25;
|
|
3987
4039
|
return refreshTask;
|
|
3988
4040
|
case 25:
|
|
3989
|
-
state =
|
|
4041
|
+
state = _context41.sent;
|
|
3990
4042
|
if (!(refreshSequence !== this.walletAssetsRefreshSequence)) {
|
|
3991
|
-
|
|
4043
|
+
_context41.next = 28;
|
|
3992
4044
|
break;
|
|
3993
4045
|
}
|
|
3994
|
-
return
|
|
4046
|
+
return _context41.abrupt("return", wallet.getWalletAssetsState());
|
|
3995
4047
|
case 28:
|
|
3996
4048
|
if (state.status !== 'error') {
|
|
3997
4049
|
committed = this.getCommittedWalletAssets();
|
|
3998
4050
|
state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
3999
4051
|
}
|
|
4000
|
-
|
|
4052
|
+
_context41.next = 31;
|
|
4001
4053
|
return this.syncSelectedWalletAssets(state);
|
|
4002
4054
|
case 31:
|
|
4003
|
-
return
|
|
4055
|
+
return _context41.abrupt("return", this.publishWalletAssetsState(state));
|
|
4004
4056
|
case 32:
|
|
4005
4057
|
case "end":
|
|
4006
|
-
return
|
|
4058
|
+
return _context41.stop();
|
|
4007
4059
|
}
|
|
4008
|
-
},
|
|
4060
|
+
}, _callee41, this);
|
|
4009
4061
|
}));
|
|
4010
|
-
function refreshWalletAssets(
|
|
4062
|
+
function refreshWalletAssets(_x38) {
|
|
4011
4063
|
return _refreshWalletAssets.apply(this, arguments);
|
|
4012
4064
|
}
|
|
4013
4065
|
return refreshWalletAssets;
|
|
@@ -4015,13 +4067,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4015
4067
|
}, {
|
|
4016
4068
|
key: "selectWalletAsset",
|
|
4017
4069
|
value: (function () {
|
|
4018
|
-
var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4070
|
+
var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
|
|
4019
4071
|
var state;
|
|
4020
|
-
return _regeneratorRuntime().wrap(function
|
|
4021
|
-
while (1) switch (
|
|
4072
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
4073
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
4022
4074
|
case 0:
|
|
4023
4075
|
if (this.store.payment) {
|
|
4024
|
-
|
|
4076
|
+
_context42.next = 2;
|
|
4025
4077
|
break;
|
|
4026
4078
|
}
|
|
4027
4079
|
throw new Error('payment 模块未初始化');
|
|
@@ -4030,17 +4082,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4030
4082
|
selected: params.selected,
|
|
4031
4083
|
source: params.source
|
|
4032
4084
|
});
|
|
4033
|
-
|
|
4085
|
+
_context42.next = 5;
|
|
4034
4086
|
return this.syncSelectedWalletAssets(state);
|
|
4035
4087
|
case 5:
|
|
4036
|
-
return
|
|
4088
|
+
return _context42.abrupt("return", this.publishWalletAssetsState(state));
|
|
4037
4089
|
case 6:
|
|
4038
4090
|
case "end":
|
|
4039
|
-
return
|
|
4091
|
+
return _context42.stop();
|
|
4040
4092
|
}
|
|
4041
|
-
},
|
|
4093
|
+
}, _callee42, this);
|
|
4042
4094
|
}));
|
|
4043
|
-
function selectWalletAsset(
|
|
4095
|
+
function selectWalletAsset(_x39) {
|
|
4044
4096
|
return _selectWalletAsset.apply(this, arguments);
|
|
4045
4097
|
}
|
|
4046
4098
|
return selectWalletAsset;
|
|
@@ -4048,29 +4100,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4048
4100
|
}, {
|
|
4049
4101
|
key: "updateWalletAssetAmount",
|
|
4050
4102
|
value: (function () {
|
|
4051
|
-
var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4103
|
+
var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
4052
4104
|
var state;
|
|
4053
|
-
return _regeneratorRuntime().wrap(function
|
|
4054
|
-
while (1) switch (
|
|
4105
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4106
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
4055
4107
|
case 0:
|
|
4056
4108
|
if (this.store.payment) {
|
|
4057
|
-
|
|
4109
|
+
_context43.next = 2;
|
|
4058
4110
|
break;
|
|
4059
4111
|
}
|
|
4060
4112
|
throw new Error('payment 模块未初始化');
|
|
4061
4113
|
case 2:
|
|
4062
4114
|
state = this.store.payment.wallet.updateWalletAssetAmount(params.assetId, params.amount);
|
|
4063
|
-
|
|
4115
|
+
_context43.next = 5;
|
|
4064
4116
|
return this.syncSelectedWalletAssets(state);
|
|
4065
4117
|
case 5:
|
|
4066
|
-
return
|
|
4118
|
+
return _context43.abrupt("return", this.publishWalletAssetsState(state));
|
|
4067
4119
|
case 6:
|
|
4068
4120
|
case "end":
|
|
4069
|
-
return
|
|
4121
|
+
return _context43.stop();
|
|
4070
4122
|
}
|
|
4071
|
-
},
|
|
4123
|
+
}, _callee43, this);
|
|
4072
4124
|
}));
|
|
4073
|
-
function updateWalletAssetAmount(
|
|
4125
|
+
function updateWalletAssetAmount(_x40) {
|
|
4074
4126
|
return _updateWalletAssetAmount.apply(this, arguments);
|
|
4075
4127
|
}
|
|
4076
4128
|
return updateWalletAssetAmount;
|
|
@@ -4078,13 +4130,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4078
4130
|
}, {
|
|
4079
4131
|
key: "scanWalletAsset",
|
|
4080
4132
|
value: (function () {
|
|
4081
|
-
var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4133
|
+
var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(code) {
|
|
4082
4134
|
var wallet, businessData, result;
|
|
4083
|
-
return _regeneratorRuntime().wrap(function
|
|
4084
|
-
while (1) switch (
|
|
4135
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4136
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
4085
4137
|
case 0:
|
|
4086
4138
|
if (this.store.payment) {
|
|
4087
|
-
|
|
4139
|
+
_context44.next = 2;
|
|
4088
4140
|
break;
|
|
4089
4141
|
}
|
|
4090
4142
|
throw new Error('payment 模块未初始化');
|
|
@@ -4094,28 +4146,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4094
4146
|
if (businessData) {
|
|
4095
4147
|
wallet.generateWalletParams(businessData);
|
|
4096
4148
|
}
|
|
4097
|
-
|
|
4149
|
+
_context44.next = 7;
|
|
4098
4150
|
return wallet.scanWalletAssetAsync(code);
|
|
4099
4151
|
case 7:
|
|
4100
|
-
result =
|
|
4152
|
+
result = _context44.sent;
|
|
4101
4153
|
if (!(result.type === 'normalCode')) {
|
|
4102
|
-
|
|
4154
|
+
_context44.next = 13;
|
|
4103
4155
|
break;
|
|
4104
4156
|
}
|
|
4105
|
-
|
|
4157
|
+
_context44.next = 11;
|
|
4106
4158
|
return this.syncSelectedWalletAssets(result.state);
|
|
4107
4159
|
case 11:
|
|
4108
|
-
|
|
4160
|
+
_context44.next = 13;
|
|
4109
4161
|
return this.publishWalletAssetsState(result.state);
|
|
4110
4162
|
case 13:
|
|
4111
|
-
return
|
|
4163
|
+
return _context44.abrupt("return", result);
|
|
4112
4164
|
case 14:
|
|
4113
4165
|
case "end":
|
|
4114
|
-
return
|
|
4166
|
+
return _context44.stop();
|
|
4115
4167
|
}
|
|
4116
|
-
},
|
|
4168
|
+
}, _callee44, this);
|
|
4117
4169
|
}));
|
|
4118
|
-
function scanWalletAsset(
|
|
4170
|
+
function scanWalletAsset(_x41) {
|
|
4119
4171
|
return _scanWalletAsset.apply(this, arguments);
|
|
4120
4172
|
}
|
|
4121
4173
|
return scanWalletAsset;
|
|
@@ -4123,27 +4175,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4123
4175
|
}, {
|
|
4124
4176
|
key: "clearWalletAssetSelection",
|
|
4125
4177
|
value: (function () {
|
|
4126
|
-
var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4178
|
+
var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
|
|
4127
4179
|
var state;
|
|
4128
|
-
return _regeneratorRuntime().wrap(function
|
|
4129
|
-
while (1) switch (
|
|
4180
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
4181
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4130
4182
|
case 0:
|
|
4131
4183
|
if (this.store.payment) {
|
|
4132
|
-
|
|
4184
|
+
_context45.next = 2;
|
|
4133
4185
|
break;
|
|
4134
4186
|
}
|
|
4135
4187
|
throw new Error('payment 模块未初始化');
|
|
4136
4188
|
case 2:
|
|
4137
4189
|
state = this.store.payment.wallet.clearWalletAssetSelection();
|
|
4138
|
-
|
|
4190
|
+
_context45.next = 5;
|
|
4139
4191
|
return this.syncSelectedWalletAssets(state);
|
|
4140
4192
|
case 5:
|
|
4141
|
-
return
|
|
4193
|
+
return _context45.abrupt("return", this.publishWalletAssetsState(state));
|
|
4142
4194
|
case 6:
|
|
4143
4195
|
case "end":
|
|
4144
|
-
return
|
|
4196
|
+
return _context45.stop();
|
|
4145
4197
|
}
|
|
4146
|
-
},
|
|
4198
|
+
}, _callee45, this);
|
|
4147
4199
|
}));
|
|
4148
4200
|
function clearWalletAssetSelection() {
|
|
4149
4201
|
return _clearWalletAssetSelection.apply(this, arguments);
|
|
@@ -4173,35 +4225,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4173
4225
|
}, {
|
|
4174
4226
|
key: "getPaymentMethodsAsync",
|
|
4175
4227
|
value: (function () {
|
|
4176
|
-
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4228
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
|
|
4177
4229
|
var response, paymentMethods;
|
|
4178
|
-
return _regeneratorRuntime().wrap(function
|
|
4179
|
-
while (1) switch (
|
|
4230
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
4231
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4180
4232
|
case 0:
|
|
4181
|
-
|
|
4182
|
-
|
|
4233
|
+
_context46.prev = 0;
|
|
4234
|
+
_context46.next = 3;
|
|
4183
4235
|
return this.request.get('/pay/custom-payment/all', {
|
|
4184
4236
|
filterPaymentMethods: true
|
|
4185
4237
|
}, {
|
|
4186
4238
|
osServer: true
|
|
4187
4239
|
});
|
|
4188
4240
|
case 3:
|
|
4189
|
-
response =
|
|
4241
|
+
response = _context46.sent;
|
|
4190
4242
|
paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
4191
4243
|
this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
|
|
4192
|
-
return
|
|
4244
|
+
return _context46.abrupt("return", this.getPaymentMethods());
|
|
4193
4245
|
case 9:
|
|
4194
|
-
|
|
4195
|
-
|
|
4246
|
+
_context46.prev = 9;
|
|
4247
|
+
_context46.t0 = _context46["catch"](0);
|
|
4196
4248
|
this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
|
|
4197
|
-
error:
|
|
4249
|
+
error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
|
|
4198
4250
|
});
|
|
4199
|
-
return
|
|
4251
|
+
return _context46.abrupt("return", this.getPaymentMethods());
|
|
4200
4252
|
case 13:
|
|
4201
4253
|
case "end":
|
|
4202
|
-
return
|
|
4254
|
+
return _context46.stop();
|
|
4203
4255
|
}
|
|
4204
|
-
},
|
|
4256
|
+
}, _callee46, this, [[0, 9]]);
|
|
4205
4257
|
}));
|
|
4206
4258
|
function getPaymentMethodsAsync() {
|
|
4207
4259
|
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -4244,14 +4296,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4244
4296
|
}, {
|
|
4245
4297
|
key: "getCashPaymentConfig",
|
|
4246
4298
|
value: (function () {
|
|
4247
|
-
var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4299
|
+
var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
|
|
4248
4300
|
var _this$store$order11, _this$store$order11$g, _this$store$order12, _this$store$order12$g, _this$otherParams31;
|
|
4249
4301
|
var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
|
|
4250
|
-
return _regeneratorRuntime().wrap(function
|
|
4251
|
-
while (1) switch (
|
|
4302
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
4303
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4252
4304
|
case 0:
|
|
4253
4305
|
if (this.store.payment) {
|
|
4254
|
-
|
|
4306
|
+
_context47.next = 2;
|
|
4255
4307
|
break;
|
|
4256
4308
|
}
|
|
4257
4309
|
throw new Error('payment 模块未初始化');
|
|
@@ -4259,13 +4311,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4259
4311
|
paymentMethods = this.getPaymentMethods();
|
|
4260
4312
|
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
4261
4313
|
if (paymentMethod) {
|
|
4262
|
-
|
|
4314
|
+
_context47.next = 9;
|
|
4263
4315
|
break;
|
|
4264
4316
|
}
|
|
4265
|
-
|
|
4317
|
+
_context47.next = 7;
|
|
4266
4318
|
return this.getPaymentMethodsAsync();
|
|
4267
4319
|
case 7:
|
|
4268
|
-
paymentMethods =
|
|
4320
|
+
paymentMethods = _context47.sent;
|
|
4269
4321
|
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
4270
4322
|
case 9:
|
|
4271
4323
|
amountSnapshot = (_this$store$order11 = this.store.order) === null || _this$store$order11 === void 0 || (_this$store$order11$g = _this$store$order11.getOrderAmountSnapshot) === null || _this$store$order11$g === void 0 ? void 0 : _this$store$order11$g.call(_this$store$order11);
|
|
@@ -4273,7 +4325,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4273
4325
|
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
|
|
4274
4326
|
currency = ((_this$store$order12 = this.store.order) === null || _this$store$order12 === void 0 || (_this$store$order12$g = _this$store$order12.getTempOrder) === null || _this$store$order12$g === void 0 || (_this$store$order12$g = _this$store$order12$g.call(_this$store$order12)) === null || _this$store$order12$g === void 0 ? void 0 : _this$store$order12$g.currency_code) || ((_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.currency) || 'USD';
|
|
4275
4327
|
recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
|
|
4276
|
-
return
|
|
4328
|
+
return _context47.abrupt("return", {
|
|
4277
4329
|
available: Boolean(paymentMethod && amountDue > 0),
|
|
4278
4330
|
paymentMethod: paymentMethod,
|
|
4279
4331
|
amountDue: amountDue,
|
|
@@ -4281,9 +4333,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4281
4333
|
});
|
|
4282
4334
|
case 15:
|
|
4283
4335
|
case "end":
|
|
4284
|
-
return
|
|
4336
|
+
return _context47.stop();
|
|
4285
4337
|
}
|
|
4286
|
-
},
|
|
4338
|
+
}, _callee47, this);
|
|
4287
4339
|
}));
|
|
4288
4340
|
function getCashPaymentConfig() {
|
|
4289
4341
|
return _getCashPaymentConfig.apply(this, arguments);
|
|
@@ -4300,14 +4352,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4300
4352
|
}, {
|
|
4301
4353
|
key: "confirmWalletPayment",
|
|
4302
4354
|
value: (function () {
|
|
4303
|
-
var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4355
|
+
var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
|
|
4304
4356
|
var _this$store$order$get3, _this$store$order13, _this$store$order$get4, _this$store$order$get5, _this$store$order14;
|
|
4305
4357
|
var beforePayments, pendingWalletAmount, amountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
|
|
4306
|
-
return _regeneratorRuntime().wrap(function
|
|
4307
|
-
while (1) switch (
|
|
4358
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
4359
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4308
4360
|
case 0:
|
|
4309
4361
|
if (this.store.order) {
|
|
4310
|
-
|
|
4362
|
+
_context48.next = 2;
|
|
4311
4363
|
break;
|
|
4312
4364
|
}
|
|
4313
4365
|
throw new Error('order 模块未初始化');
|
|
@@ -4315,7 +4367,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4315
4367
|
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
4316
4368
|
pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
|
|
4317
4369
|
if (!pendingWalletAmount.lte(0)) {
|
|
4318
|
-
|
|
4370
|
+
_context48.next = 6;
|
|
4319
4371
|
break;
|
|
4320
4372
|
}
|
|
4321
4373
|
throw new Error('当前订单没有待确认的 Wallet 支付');
|
|
@@ -4323,74 +4375,74 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4323
4375
|
amountSnapshot = (_this$store$order$get3 = (_this$store$order13 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order13);
|
|
4324
4376
|
effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
4325
4377
|
if (!effectiveAmountDue.gt(0.01)) {
|
|
4326
|
-
|
|
4378
|
+
_context48.next = 10;
|
|
4327
4379
|
break;
|
|
4328
4380
|
}
|
|
4329
4381
|
throw new Error('Wallet 支付尚未覆盖全部待支付金额');
|
|
4330
4382
|
case 10:
|
|
4331
4383
|
beforePaymentStatus = (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.payment_status;
|
|
4332
|
-
|
|
4333
|
-
|
|
4384
|
+
_context48.prev = 11;
|
|
4385
|
+
_context48.next = 14;
|
|
4334
4386
|
return this.submitSalesOrder({
|
|
4335
4387
|
smallTicketDataFlag: 1,
|
|
4336
4388
|
confirmPendingVoucherPayments: true
|
|
4337
4389
|
});
|
|
4338
4390
|
case 14:
|
|
4339
|
-
submitResult =
|
|
4391
|
+
submitResult = _context48.sent;
|
|
4340
4392
|
if (!isRejectedSalesSubmitResult(submitResult)) {
|
|
4341
|
-
|
|
4393
|
+
_context48.next = 17;
|
|
4342
4394
|
break;
|
|
4343
4395
|
}
|
|
4344
4396
|
throw new Error(getSalesSubmitErrorMessage(submitResult, 'Wallet 支付确认失败'));
|
|
4345
4397
|
case 17:
|
|
4346
|
-
|
|
4398
|
+
_context48.next = 27;
|
|
4347
4399
|
break;
|
|
4348
4400
|
case 19:
|
|
4349
|
-
|
|
4350
|
-
|
|
4401
|
+
_context48.prev = 19;
|
|
4402
|
+
_context48.t0 = _context48["catch"](11);
|
|
4351
4403
|
this.store.order.setOrderPayments(beforePayments);
|
|
4352
4404
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
4353
4405
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4354
4406
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4355
4407
|
this.store.order.persistTempOrder();
|
|
4356
4408
|
}
|
|
4357
|
-
|
|
4409
|
+
_context48.next = 26;
|
|
4358
4410
|
return this.store.order.recalculateSummary({
|
|
4359
4411
|
createIfMissing: true
|
|
4360
4412
|
});
|
|
4361
4413
|
case 26:
|
|
4362
|
-
throw
|
|
4414
|
+
throw _context48.t0;
|
|
4363
4415
|
case 27:
|
|
4364
4416
|
if (!this.store.payment) {
|
|
4365
|
-
|
|
4417
|
+
_context48.next = 38;
|
|
4366
4418
|
break;
|
|
4367
4419
|
}
|
|
4368
|
-
|
|
4420
|
+
_context48.prev = 28;
|
|
4369
4421
|
committed = this.getCommittedWalletAssets();
|
|
4370
4422
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4371
|
-
|
|
4423
|
+
_context48.next = 33;
|
|
4372
4424
|
return this.publishWalletAssetsState(walletState);
|
|
4373
4425
|
case 33:
|
|
4374
|
-
|
|
4426
|
+
_context48.next = 38;
|
|
4375
4427
|
break;
|
|
4376
4428
|
case 35:
|
|
4377
|
-
|
|
4378
|
-
|
|
4429
|
+
_context48.prev = 35;
|
|
4430
|
+
_context48.t1 = _context48["catch"](28);
|
|
4379
4431
|
this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
|
|
4380
|
-
error:
|
|
4432
|
+
error: _context48.t1 instanceof Error ? _context48.t1.message : String(_context48.t1)
|
|
4381
4433
|
});
|
|
4382
4434
|
case 38:
|
|
4383
4435
|
latestAmountSnapshot = (_this$store$order$get5 = (_this$store$order14 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.call(_this$store$order14);
|
|
4384
|
-
return
|
|
4436
|
+
return _context48.abrupt("return", {
|
|
4385
4437
|
submitResult: submitResult,
|
|
4386
4438
|
payments: this.store.order.getOrderPayments(),
|
|
4387
4439
|
isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
|
|
4388
4440
|
});
|
|
4389
4441
|
case 40:
|
|
4390
4442
|
case "end":
|
|
4391
|
-
return
|
|
4443
|
+
return _context48.stop();
|
|
4392
4444
|
}
|
|
4393
|
-
},
|
|
4445
|
+
}, _callee48, this, [[11, 19], [28, 35]]);
|
|
4394
4446
|
}));
|
|
4395
4447
|
function confirmWalletPayment() {
|
|
4396
4448
|
return _confirmWalletPayment.apply(this, arguments);
|
|
@@ -4405,38 +4457,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4405
4457
|
}, {
|
|
4406
4458
|
key: "payCash",
|
|
4407
4459
|
value: (function () {
|
|
4408
|
-
var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4460
|
+
var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
|
|
4409
4461
|
var _this$store$order$get6, _params$actualPaidAmo, _this$otherParams32, _this$window, _this$window$postMess;
|
|
4410
4462
|
var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
4411
|
-
return _regeneratorRuntime().wrap(function
|
|
4412
|
-
while (1) switch (
|
|
4463
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
4464
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
4413
4465
|
case 0:
|
|
4414
4466
|
if (this.store.order) {
|
|
4415
|
-
|
|
4467
|
+
_context49.next = 2;
|
|
4416
4468
|
break;
|
|
4417
4469
|
}
|
|
4418
4470
|
throw new Error('order 模块未初始化');
|
|
4419
4471
|
case 2:
|
|
4420
4472
|
amount = Number(params.amount || 0);
|
|
4421
4473
|
if (!(!Number.isFinite(amount) || amount <= 0)) {
|
|
4422
|
-
|
|
4474
|
+
_context49.next = 5;
|
|
4423
4475
|
break;
|
|
4424
4476
|
}
|
|
4425
4477
|
throw new Error('现金支付金额必须大于 0');
|
|
4426
4478
|
case 5:
|
|
4427
|
-
|
|
4479
|
+
_context49.next = 7;
|
|
4428
4480
|
return this.getCashPaymentConfig();
|
|
4429
4481
|
case 7:
|
|
4430
|
-
config =
|
|
4482
|
+
config = _context49.sent;
|
|
4431
4483
|
paymentMethod = config.paymentMethod;
|
|
4432
4484
|
if (paymentMethod) {
|
|
4433
|
-
|
|
4485
|
+
_context49.next = 11;
|
|
4434
4486
|
break;
|
|
4435
4487
|
}
|
|
4436
4488
|
throw new Error('未找到可用的 CASHMANUAL 支付方式');
|
|
4437
4489
|
case 11:
|
|
4438
4490
|
if (!(config.amountDue <= 0)) {
|
|
4439
|
-
|
|
4491
|
+
_context49.next = 13;
|
|
4440
4492
|
break;
|
|
4441
4493
|
}
|
|
4442
4494
|
throw new Error('当前订单没有待支付金额');
|
|
@@ -4444,7 +4496,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4444
4496
|
roundingAmount = Number(params.roundingAmount || 0);
|
|
4445
4497
|
effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
|
|
4446
4498
|
if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
|
|
4447
|
-
|
|
4499
|
+
_context49.next = 17;
|
|
4448
4500
|
break;
|
|
4449
4501
|
}
|
|
4450
4502
|
throw new Error('现金支付金额超过当前待支付金额');
|
|
@@ -4457,7 +4509,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4457
4509
|
changeAmount = Number(params.changeAmount || 0);
|
|
4458
4510
|
shopWalletPassId = (_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.shop_wallet_pass_id;
|
|
4459
4511
|
if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
|
|
4460
|
-
|
|
4512
|
+
_context49.next = 26;
|
|
4461
4513
|
break;
|
|
4462
4514
|
}
|
|
4463
4515
|
throw new Error('顾客实收现金不能小于支付金额');
|
|
@@ -4492,8 +4544,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4492
4544
|
var _item$metadata2;
|
|
4493
4545
|
return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
|
|
4494
4546
|
});
|
|
4495
|
-
|
|
4496
|
-
|
|
4547
|
+
_context49.prev = 29;
|
|
4548
|
+
_context49.next = 32;
|
|
4497
4549
|
return this.syncPaymentsToOrder({
|
|
4498
4550
|
payments: payments,
|
|
4499
4551
|
submitWhenPaid: true,
|
|
@@ -4501,50 +4553,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4501
4553
|
confirmPendingVoucherPayments: true
|
|
4502
4554
|
});
|
|
4503
4555
|
case 32:
|
|
4504
|
-
syncResult =
|
|
4556
|
+
syncResult = _context49.sent;
|
|
4505
4557
|
if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
|
|
4506
|
-
|
|
4558
|
+
_context49.next = 35;
|
|
4507
4559
|
break;
|
|
4508
4560
|
}
|
|
4509
4561
|
throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
|
|
4510
4562
|
case 35:
|
|
4511
4563
|
if (!this.store.payment) {
|
|
4512
|
-
|
|
4564
|
+
_context49.next = 40;
|
|
4513
4565
|
break;
|
|
4514
4566
|
}
|
|
4515
4567
|
committed = this.getCommittedWalletAssets();
|
|
4516
4568
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4517
|
-
|
|
4569
|
+
_context49.next = 40;
|
|
4518
4570
|
return this.publishWalletAssetsState(walletState);
|
|
4519
4571
|
case 40:
|
|
4520
|
-
return
|
|
4572
|
+
return _context49.abrupt("return", {
|
|
4521
4573
|
payment: payment || {},
|
|
4522
4574
|
payments: this.store.order.getOrderPayments(),
|
|
4523
4575
|
syncResult: syncResult,
|
|
4524
4576
|
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
4525
4577
|
});
|
|
4526
4578
|
case 43:
|
|
4527
|
-
|
|
4528
|
-
|
|
4579
|
+
_context49.prev = 43;
|
|
4580
|
+
_context49.t0 = _context49["catch"](29);
|
|
4529
4581
|
this.store.order.setOrderPayments(beforePayments);
|
|
4530
4582
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
4531
4583
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4532
4584
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4533
4585
|
this.store.order.persistTempOrder();
|
|
4534
4586
|
}
|
|
4535
|
-
|
|
4587
|
+
_context49.next = 50;
|
|
4536
4588
|
return this.store.order.recalculateSummary({
|
|
4537
4589
|
createIfMissing: true
|
|
4538
4590
|
});
|
|
4539
4591
|
case 50:
|
|
4540
|
-
throw
|
|
4592
|
+
throw _context49.t0;
|
|
4541
4593
|
case 51:
|
|
4542
4594
|
case "end":
|
|
4543
|
-
return
|
|
4595
|
+
return _context49.stop();
|
|
4544
4596
|
}
|
|
4545
|
-
},
|
|
4597
|
+
}, _callee49, this, [[29, 43]]);
|
|
4546
4598
|
}));
|
|
4547
|
-
function payCash(
|
|
4599
|
+
function payCash(_x42) {
|
|
4548
4600
|
return _payCash.apply(this, arguments);
|
|
4549
4601
|
}
|
|
4550
4602
|
return payCash;
|
|
@@ -4560,21 +4612,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4560
4612
|
}, {
|
|
4561
4613
|
key: "commitPaymentMethodPayment",
|
|
4562
4614
|
value: (function () {
|
|
4563
|
-
var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4615
|
+
var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
|
|
4564
4616
|
var _this$store$order$get7, _this$store$order15, _this$store$order$get8, _params$metadata, _params$originAmount;
|
|
4565
4617
|
var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
4566
|
-
return _regeneratorRuntime().wrap(function
|
|
4567
|
-
while (1) switch (
|
|
4618
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
4619
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
4568
4620
|
case 0:
|
|
4569
4621
|
if (this.store.order) {
|
|
4570
|
-
|
|
4622
|
+
_context50.next = 2;
|
|
4571
4623
|
break;
|
|
4572
4624
|
}
|
|
4573
4625
|
throw new Error('order 模块未初始化');
|
|
4574
4626
|
case 2:
|
|
4575
4627
|
amount = Number(params.amount || 0);
|
|
4576
4628
|
if (!(!Number.isFinite(amount) || amount <= 0)) {
|
|
4577
|
-
|
|
4629
|
+
_context50.next = 5;
|
|
4578
4630
|
break;
|
|
4579
4631
|
}
|
|
4580
4632
|
throw new Error('支付金额必须大于 0');
|
|
@@ -4590,17 +4642,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4590
4642
|
};
|
|
4591
4643
|
paymentMethod = findPaymentMethod();
|
|
4592
4644
|
if (paymentMethod) {
|
|
4593
|
-
|
|
4645
|
+
_context50.next = 13;
|
|
4594
4646
|
break;
|
|
4595
4647
|
}
|
|
4596
|
-
|
|
4648
|
+
_context50.next = 11;
|
|
4597
4649
|
return this.getPaymentMethodsAsync();
|
|
4598
4650
|
case 11:
|
|
4599
|
-
paymentMethods =
|
|
4651
|
+
paymentMethods = _context50.sent;
|
|
4600
4652
|
paymentMethod = findPaymentMethod();
|
|
4601
4653
|
case 13:
|
|
4602
4654
|
if (paymentMethod) {
|
|
4603
|
-
|
|
4655
|
+
_context50.next = 15;
|
|
4604
4656
|
break;
|
|
4605
4657
|
}
|
|
4606
4658
|
throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
|
|
@@ -4609,13 +4661,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4609
4661
|
pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
4610
4662
|
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
4611
4663
|
if (!amountDue.lte(0)) {
|
|
4612
|
-
|
|
4664
|
+
_context50.next = 20;
|
|
4613
4665
|
break;
|
|
4614
4666
|
}
|
|
4615
4667
|
throw new Error('当前订单没有待支付金额');
|
|
4616
4668
|
case 20:
|
|
4617
4669
|
if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
|
|
4618
|
-
|
|
4670
|
+
_context50.next = 22;
|
|
4619
4671
|
break;
|
|
4620
4672
|
}
|
|
4621
4673
|
throw new Error('支付金额超过当前待支付金额');
|
|
@@ -4654,8 +4706,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4654
4706
|
var _item$metadata3;
|
|
4655
4707
|
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;
|
|
4656
4708
|
});
|
|
4657
|
-
|
|
4658
|
-
|
|
4709
|
+
_context50.prev = 30;
|
|
4710
|
+
_context50.next = 33;
|
|
4659
4711
|
return this.syncPaymentsToOrder({
|
|
4660
4712
|
payments: payments,
|
|
4661
4713
|
submitWhenPaid: true,
|
|
@@ -4663,50 +4715,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4663
4715
|
confirmPendingVoucherPayments: true
|
|
4664
4716
|
});
|
|
4665
4717
|
case 33:
|
|
4666
|
-
syncResult =
|
|
4718
|
+
syncResult = _context50.sent;
|
|
4667
4719
|
if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
|
|
4668
|
-
|
|
4720
|
+
_context50.next = 36;
|
|
4669
4721
|
break;
|
|
4670
4722
|
}
|
|
4671
4723
|
throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
|
|
4672
4724
|
case 36:
|
|
4673
4725
|
if (!this.store.payment) {
|
|
4674
|
-
|
|
4726
|
+
_context50.next = 41;
|
|
4675
4727
|
break;
|
|
4676
4728
|
}
|
|
4677
4729
|
committed = this.getCommittedWalletAssets();
|
|
4678
4730
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4679
|
-
|
|
4731
|
+
_context50.next = 41;
|
|
4680
4732
|
return this.publishWalletAssetsState(walletState);
|
|
4681
4733
|
case 41:
|
|
4682
|
-
return
|
|
4734
|
+
return _context50.abrupt("return", {
|
|
4683
4735
|
payment: payment || {},
|
|
4684
4736
|
payments: this.store.order.getOrderPayments(),
|
|
4685
4737
|
syncResult: syncResult,
|
|
4686
4738
|
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
4687
4739
|
});
|
|
4688
4740
|
case 44:
|
|
4689
|
-
|
|
4690
|
-
|
|
4741
|
+
_context50.prev = 44;
|
|
4742
|
+
_context50.t0 = _context50["catch"](30);
|
|
4691
4743
|
this.store.order.setOrderPayments(beforePayments);
|
|
4692
4744
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
4693
4745
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4694
4746
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4695
4747
|
this.store.order.persistTempOrder();
|
|
4696
4748
|
}
|
|
4697
|
-
|
|
4749
|
+
_context50.next = 51;
|
|
4698
4750
|
return this.store.order.recalculateSummary({
|
|
4699
4751
|
createIfMissing: true
|
|
4700
4752
|
});
|
|
4701
4753
|
case 51:
|
|
4702
|
-
throw
|
|
4754
|
+
throw _context50.t0;
|
|
4703
4755
|
case 52:
|
|
4704
4756
|
case "end":
|
|
4705
|
-
return
|
|
4757
|
+
return _context50.stop();
|
|
4706
4758
|
}
|
|
4707
|
-
},
|
|
4759
|
+
}, _callee50, this, [[30, 44]]);
|
|
4708
4760
|
}));
|
|
4709
|
-
function commitPaymentMethodPayment(
|
|
4761
|
+
function commitPaymentMethodPayment(_x43) {
|
|
4710
4762
|
return _commitPaymentMethodPayment.apply(this, arguments);
|
|
4711
4763
|
}
|
|
4712
4764
|
return commitPaymentMethodPayment;
|
|
@@ -4721,40 +4773,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4721
4773
|
}, {
|
|
4722
4774
|
key: "roundAmount",
|
|
4723
4775
|
value: (function () {
|
|
4724
|
-
var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4776
|
+
var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
|
|
4725
4777
|
var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
|
|
4726
4778
|
var amount, cashManualPayment;
|
|
4727
|
-
return _regeneratorRuntime().wrap(function
|
|
4728
|
-
while (1) switch (
|
|
4779
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
4780
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
4729
4781
|
case 0:
|
|
4730
4782
|
amount = params.amount;
|
|
4731
4783
|
cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
|
|
4732
4784
|
return paymentMethod.code === 'CASHMANUAL';
|
|
4733
4785
|
});
|
|
4734
4786
|
if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
|
|
4735
|
-
|
|
4787
|
+
_context51.next = 4;
|
|
4736
4788
|
break;
|
|
4737
4789
|
}
|
|
4738
|
-
return
|
|
4790
|
+
return _context51.abrupt("return", {
|
|
4739
4791
|
originalAmount: amount.toString(),
|
|
4740
4792
|
roundedAmount: amount.toString(),
|
|
4741
4793
|
roundingDifference: '0.00'
|
|
4742
4794
|
});
|
|
4743
4795
|
case 4:
|
|
4744
4796
|
if (this.payment) {
|
|
4745
|
-
|
|
4797
|
+
_context51.next = 6;
|
|
4746
4798
|
break;
|
|
4747
4799
|
}
|
|
4748
4800
|
throw new Error('payment 模块未初始化');
|
|
4749
4801
|
case 6:
|
|
4750
|
-
return
|
|
4802
|
+
return _context51.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));
|
|
4751
4803
|
case 7:
|
|
4752
4804
|
case "end":
|
|
4753
|
-
return
|
|
4805
|
+
return _context51.stop();
|
|
4754
4806
|
}
|
|
4755
|
-
},
|
|
4807
|
+
}, _callee51, this);
|
|
4756
4808
|
}));
|
|
4757
|
-
function roundAmount(
|
|
4809
|
+
function roundAmount(_x44) {
|
|
4758
4810
|
return _roundAmount.apply(this, arguments);
|
|
4759
4811
|
}
|
|
4760
4812
|
return roundAmount;
|
|
@@ -4769,49 +4821,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4769
4821
|
}, {
|
|
4770
4822
|
key: "sendCustomerPayLink",
|
|
4771
4823
|
value: (function () {
|
|
4772
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4824
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
|
|
4773
4825
|
var orderIds, _ref37, _ref38, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
4774
|
-
return _regeneratorRuntime().wrap(function
|
|
4775
|
-
while (1) switch (
|
|
4826
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
4827
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
4776
4828
|
case 0:
|
|
4777
4829
|
if (this.store.order) {
|
|
4778
|
-
|
|
4830
|
+
_context52.next = 2;
|
|
4779
4831
|
break;
|
|
4780
4832
|
}
|
|
4781
4833
|
throw new Error('order 模块未初始化');
|
|
4782
4834
|
case 2:
|
|
4783
4835
|
orderIds = params.order_ids || params.orderIds || [];
|
|
4784
4836
|
if (!(!orderIds.length || params.submitBeforeSend)) {
|
|
4785
|
-
|
|
4837
|
+
_context52.next = 11;
|
|
4786
4838
|
break;
|
|
4787
4839
|
}
|
|
4788
|
-
|
|
4840
|
+
_context52.next = 6;
|
|
4789
4841
|
return this.submitSalesOrder({
|
|
4790
4842
|
smallTicketDataFlag: 1
|
|
4791
4843
|
});
|
|
4792
4844
|
case 6:
|
|
4793
|
-
submitResult =
|
|
4845
|
+
submitResult = _context52.sent;
|
|
4794
4846
|
orderId = (_ref37 = (_ref38 = (_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 && _ref38 !== void 0 ? _ref38 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref37 !== void 0 ? _ref37 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
4795
4847
|
if (orderId) {
|
|
4796
|
-
|
|
4848
|
+
_context52.next = 10;
|
|
4797
4849
|
break;
|
|
4798
4850
|
}
|
|
4799
4851
|
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
4800
4852
|
case 10:
|
|
4801
4853
|
orderIds = [orderId];
|
|
4802
4854
|
case 11:
|
|
4803
|
-
return
|
|
4855
|
+
return _context52.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
4804
4856
|
emails: params.emails,
|
|
4805
4857
|
notify_action: params.notify_action,
|
|
4806
4858
|
order_ids: orderIds
|
|
4807
4859
|
}));
|
|
4808
4860
|
case 12:
|
|
4809
4861
|
case "end":
|
|
4810
|
-
return
|
|
4862
|
+
return _context52.stop();
|
|
4811
4863
|
}
|
|
4812
|
-
},
|
|
4864
|
+
}, _callee52, this);
|
|
4813
4865
|
}));
|
|
4814
|
-
function sendCustomerPayLink(
|
|
4866
|
+
function sendCustomerPayLink(_x45) {
|
|
4815
4867
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
4816
4868
|
}
|
|
4817
4869
|
return sendCustomerPayLink;
|
|
@@ -4824,39 +4876,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4824
4876
|
}, {
|
|
4825
4877
|
key: "calculateProductBookingPrice",
|
|
4826
4878
|
value: function () {
|
|
4827
|
-
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4879
|
+
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
|
|
4828
4880
|
var _params$customer_id;
|
|
4829
4881
|
var quotation, customerId, authoritativeProduct, product;
|
|
4830
|
-
return _regeneratorRuntime().wrap(function
|
|
4831
|
-
while (1) switch (
|
|
4882
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
4883
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
4832
4884
|
case 0:
|
|
4833
4885
|
quotation = this.store.quotation;
|
|
4834
4886
|
customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
|
|
4835
|
-
|
|
4836
|
-
return this.
|
|
4887
|
+
_context53.next = 4;
|
|
4888
|
+
return this.prepareProductPriceQueryContext(customerId);
|
|
4837
4889
|
case 4:
|
|
4838
|
-
|
|
4890
|
+
_context53.next = 6;
|
|
4891
|
+
return this.loadProductForPriceQuery(params, customerId);
|
|
4892
|
+
case 6:
|
|
4893
|
+
authoritativeProduct = _context53.sent;
|
|
4839
4894
|
product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
4840
|
-
|
|
4895
|
+
_context53.next = 10;
|
|
4841
4896
|
return this.loadQuotationForPriceQuery({
|
|
4842
4897
|
quotation: quotation,
|
|
4843
4898
|
customer_id: customerId,
|
|
4844
4899
|
channel: params.channel
|
|
4845
4900
|
});
|
|
4846
|
-
case
|
|
4847
|
-
return
|
|
4901
|
+
case 10:
|
|
4902
|
+
return _context53.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
4848
4903
|
product: product,
|
|
4849
4904
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
4850
4905
|
customer_id: customerId,
|
|
4851
|
-
quotation: quotation
|
|
4906
|
+
quotation: authoritativeProduct && this.preferAuthoritativeProductQueryPrice() ? undefined : quotation
|
|
4852
4907
|
})));
|
|
4853
|
-
case
|
|
4908
|
+
case 11:
|
|
4854
4909
|
case "end":
|
|
4855
|
-
return
|
|
4910
|
+
return _context53.stop();
|
|
4856
4911
|
}
|
|
4857
|
-
},
|
|
4912
|
+
}, _callee53, this);
|
|
4858
4913
|
}));
|
|
4859
|
-
function calculateProductBookingPrice(
|
|
4914
|
+
function calculateProductBookingPrice(_x46) {
|
|
4860
4915
|
return _calculateProductBookingPrice.apply(this, arguments);
|
|
4861
4916
|
}
|
|
4862
4917
|
return calculateProductBookingPrice;
|
|
@@ -4900,6 +4955,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4900
4955
|
quotationScopes: quotationScopes
|
|
4901
4956
|
};
|
|
4902
4957
|
}
|
|
4958
|
+
}, {
|
|
4959
|
+
key: "hasSmartPricingStrategies",
|
|
4960
|
+
value: function hasSmartPricingStrategies() {
|
|
4961
|
+
var _this$core3;
|
|
4962
|
+
var evaluator = (_this$core3 = this.core) === null || _this$core3 === void 0 || (_this$core3 = _this$core3.context) === null || _this$core3 === void 0 ? void 0 : _this$core3.dataVariantEvaluator;
|
|
4963
|
+
if (!evaluator || typeof evaluator.getStrategyConfigs !== 'function') {
|
|
4964
|
+
return false;
|
|
4965
|
+
}
|
|
4966
|
+
var configs = evaluator.getStrategyConfigs();
|
|
4967
|
+
return Array.isArray(configs) && configs.length > 0;
|
|
4968
|
+
}
|
|
4903
4969
|
}, {
|
|
4904
4970
|
key: "shouldRecalculateProductBookingPricesForContextChange",
|
|
4905
4971
|
value: function shouldRecalculateProductBookingPricesForContextChange(params) {
|
|
@@ -4909,6 +4975,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4909
4975
|
}));
|
|
4910
4976
|
var previousCustomerId = this.normalizePriceContextCustomerId(params.previousCustomerId);
|
|
4911
4977
|
var nextCustomerId = this.normalizePriceContextCustomerId(params.nextCustomerId);
|
|
4978
|
+
if (this.hasSmartPricingStrategies()) {
|
|
4979
|
+
return previousCustomerId !== nextCustomerId;
|
|
4980
|
+
}
|
|
4912
4981
|
var previousInScope = previousCustomerId ? scopedCustomerIds.has(previousCustomerId) : false;
|
|
4913
4982
|
var nextInScope = nextCustomerId ? scopedCustomerIds.has(nextCustomerId) : false;
|
|
4914
4983
|
var shouldRecalculate = false;
|
|
@@ -4926,23 +4995,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4926
4995
|
}, {
|
|
4927
4996
|
key: "calculateProductBookingPrices",
|
|
4928
4997
|
value: function () {
|
|
4929
|
-
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4998
|
+
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(paramsList) {
|
|
4930
4999
|
var _paramsList$0$custome,
|
|
4931
5000
|
_paramsList$,
|
|
4932
5001
|
_this16 = this,
|
|
4933
5002
|
_paramsList$2;
|
|
4934
5003
|
var quotation, customerId, productMapsByGroup, groups;
|
|
4935
|
-
return _regeneratorRuntime().wrap(function
|
|
4936
|
-
while (1) switch (
|
|
5004
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5005
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
4937
5006
|
case 0:
|
|
4938
5007
|
if (paramsList.length) {
|
|
4939
|
-
|
|
5008
|
+
_context55.next = 2;
|
|
4940
5009
|
break;
|
|
4941
5010
|
}
|
|
4942
|
-
return
|
|
5011
|
+
return _context55.abrupt("return", []);
|
|
4943
5012
|
case 2:
|
|
4944
5013
|
quotation = this.store.quotation;
|
|
4945
5014
|
customerId = (_paramsList$0$custome = (_paramsList$ = paramsList[0]) === null || _paramsList$ === void 0 ? void 0 : _paramsList$.customer_id) !== null && _paramsList$0$custome !== void 0 ? _paramsList$0$custome : this.getCurrentOrderCustomerId();
|
|
5015
|
+
_context55.next = 6;
|
|
5016
|
+
return this.prepareProductPriceQueryContext(customerId);
|
|
5017
|
+
case 6:
|
|
4946
5018
|
productMapsByGroup = new Map();
|
|
4947
5019
|
groups = new Map();
|
|
4948
5020
|
paramsList.forEach(function (params) {
|
|
@@ -4961,15 +5033,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4961
5033
|
group.ids.add(productId);
|
|
4962
5034
|
groups.set(groupKey, group);
|
|
4963
5035
|
});
|
|
4964
|
-
|
|
5036
|
+
_context55.next = 11;
|
|
4965
5037
|
return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
|
|
4966
|
-
var _ref40 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5038
|
+
var _ref40 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(_ref39) {
|
|
4967
5039
|
var _ref41, groupKey, group, productsById;
|
|
4968
|
-
return _regeneratorRuntime().wrap(function
|
|
4969
|
-
while (1) switch (
|
|
5040
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5041
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
4970
5042
|
case 0:
|
|
4971
5043
|
_ref41 = _slicedToArray(_ref39, 2), groupKey = _ref41[0], group = _ref41[1];
|
|
4972
|
-
|
|
5044
|
+
_context54.next = 3;
|
|
4973
5045
|
return _this16.loadProductsForPriceQuery({
|
|
4974
5046
|
ids: Array.from(group.ids),
|
|
4975
5047
|
schedule: group.schedule,
|
|
@@ -4977,27 +5049,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4977
5049
|
channel: group.channel
|
|
4978
5050
|
});
|
|
4979
5051
|
case 3:
|
|
4980
|
-
productsById =
|
|
5052
|
+
productsById = _context54.sent;
|
|
4981
5053
|
productMapsByGroup.set(groupKey, productsById);
|
|
4982
5054
|
case 5:
|
|
4983
5055
|
case "end":
|
|
4984
|
-
return
|
|
5056
|
+
return _context54.stop();
|
|
4985
5057
|
}
|
|
4986
|
-
},
|
|
5058
|
+
}, _callee54);
|
|
4987
5059
|
}));
|
|
4988
|
-
return function (
|
|
5060
|
+
return function (_x48) {
|
|
4989
5061
|
return _ref40.apply(this, arguments);
|
|
4990
5062
|
};
|
|
4991
5063
|
}()));
|
|
4992
|
-
case
|
|
4993
|
-
|
|
5064
|
+
case 11:
|
|
5065
|
+
_context55.next = 13;
|
|
4994
5066
|
return this.loadQuotationForPriceQuery({
|
|
4995
5067
|
quotation: quotation,
|
|
4996
5068
|
customer_id: customerId,
|
|
4997
5069
|
channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
|
|
4998
5070
|
});
|
|
4999
|
-
case
|
|
5000
|
-
return
|
|
5071
|
+
case 13:
|
|
5072
|
+
return _context55.abrupt("return", paramsList.map(function (params) {
|
|
5001
5073
|
var _this16$otherParams2, _productMapsByGroup$g;
|
|
5002
5074
|
var productInput = params.product || {};
|
|
5003
5075
|
var productId = _this16.getPriceQueryProductId(productInput);
|
|
@@ -5010,16 +5082,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5010
5082
|
product: product,
|
|
5011
5083
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
5012
5084
|
customer_id: customerId,
|
|
5013
|
-
quotation: quotation
|
|
5085
|
+
quotation: authoritativeProduct && _this16.preferAuthoritativeProductQueryPrice() ? undefined : quotation
|
|
5014
5086
|
}));
|
|
5015
5087
|
}));
|
|
5016
|
-
case
|
|
5088
|
+
case 14:
|
|
5017
5089
|
case "end":
|
|
5018
|
-
return
|
|
5090
|
+
return _context55.stop();
|
|
5019
5091
|
}
|
|
5020
|
-
},
|
|
5092
|
+
}, _callee55, this);
|
|
5021
5093
|
}));
|
|
5022
|
-
function calculateProductBookingPrices(
|
|
5094
|
+
function calculateProductBookingPrices(_x47) {
|
|
5023
5095
|
return _calculateProductBookingPrices.apply(this, arguments);
|
|
5024
5096
|
}
|
|
5025
5097
|
return calculateProductBookingPrices;
|
|
@@ -5027,42 +5099,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5027
5099
|
}, {
|
|
5028
5100
|
key: "addProductToOrder",
|
|
5029
5101
|
value: function () {
|
|
5030
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5031
|
-
var products;
|
|
5032
|
-
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5033
|
-
while (1) switch (_context55.prev = _context55.next) {
|
|
5034
|
-
case 0:
|
|
5035
|
-
_context55.prev = 0;
|
|
5036
|
-
if (this.store.order) {
|
|
5037
|
-
_context55.next = 3;
|
|
5038
|
-
break;
|
|
5039
|
-
}
|
|
5040
|
-
throw new Error('order 模块未初始化');
|
|
5041
|
-
case 3:
|
|
5042
|
-
_context55.next = 5;
|
|
5043
|
-
return this.store.order.addProductToOrder(product, booking, options);
|
|
5044
|
-
case 5:
|
|
5045
|
-
products = _context55.sent;
|
|
5046
|
-
return _context55.abrupt("return", products);
|
|
5047
|
-
case 9:
|
|
5048
|
-
_context55.prev = 9;
|
|
5049
|
-
_context55.t0 = _context55["catch"](0);
|
|
5050
|
-
throw _context55.t0;
|
|
5051
|
-
case 12:
|
|
5052
|
-
case "end":
|
|
5053
|
-
return _context55.stop();
|
|
5054
|
-
}
|
|
5055
|
-
}, _callee55, this, [[0, 9]]);
|
|
5056
|
-
}));
|
|
5057
|
-
function addProductToOrder(_x47, _x48, _x49) {
|
|
5058
|
-
return _addProductToOrder.apply(this, arguments);
|
|
5059
|
-
}
|
|
5060
|
-
return addProductToOrder;
|
|
5061
|
-
}()
|
|
5062
|
-
}, {
|
|
5063
|
-
key: "updateOrderProduct",
|
|
5064
|
-
value: function () {
|
|
5065
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
|
|
5102
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(product, booking, options) {
|
|
5066
5103
|
var products;
|
|
5067
5104
|
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
5068
5105
|
while (1) switch (_context56.prev = _context56.next) {
|
|
@@ -5075,7 +5112,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5075
5112
|
throw new Error('order 模块未初始化');
|
|
5076
5113
|
case 3:
|
|
5077
5114
|
_context56.next = 5;
|
|
5078
|
-
return this.store.order.
|
|
5115
|
+
return this.store.order.addProductToOrder(product, booking, options);
|
|
5079
5116
|
case 5:
|
|
5080
5117
|
products = _context56.sent;
|
|
5081
5118
|
return _context56.abrupt("return", products);
|
|
@@ -5089,15 +5126,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5089
5126
|
}
|
|
5090
5127
|
}, _callee56, this, [[0, 9]]);
|
|
5091
5128
|
}));
|
|
5092
|
-
function
|
|
5093
|
-
return
|
|
5129
|
+
function addProductToOrder(_x49, _x50, _x51) {
|
|
5130
|
+
return _addProductToOrder.apply(this, arguments);
|
|
5094
5131
|
}
|
|
5095
|
-
return
|
|
5132
|
+
return addProductToOrder;
|
|
5096
5133
|
}()
|
|
5097
5134
|
}, {
|
|
5098
|
-
key: "
|
|
5135
|
+
key: "updateOrderProduct",
|
|
5099
5136
|
value: function () {
|
|
5100
|
-
var
|
|
5137
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
|
|
5101
5138
|
var products;
|
|
5102
5139
|
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5103
5140
|
while (1) switch (_context57.prev = _context57.next) {
|
|
@@ -5110,7 +5147,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5110
5147
|
throw new Error('order 模块未初始化');
|
|
5111
5148
|
case 3:
|
|
5112
5149
|
_context57.next = 5;
|
|
5113
|
-
return this.store.order.
|
|
5150
|
+
return this.store.order.updateOrderProduct(params);
|
|
5114
5151
|
case 5:
|
|
5115
5152
|
products = _context57.sent;
|
|
5116
5153
|
return _context57.abrupt("return", products);
|
|
@@ -5124,15 +5161,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5124
5161
|
}
|
|
5125
5162
|
}, _callee57, this, [[0, 9]]);
|
|
5126
5163
|
}));
|
|
5127
|
-
function
|
|
5128
|
-
return
|
|
5164
|
+
function updateOrderProduct(_x52) {
|
|
5165
|
+
return _updateOrderProduct.apply(this, arguments);
|
|
5129
5166
|
}
|
|
5130
|
-
return
|
|
5167
|
+
return updateOrderProduct;
|
|
5131
5168
|
}()
|
|
5132
5169
|
}, {
|
|
5133
|
-
key: "
|
|
5170
|
+
key: "updateOrderProducts",
|
|
5134
5171
|
value: function () {
|
|
5135
|
-
var
|
|
5172
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(paramsList) {
|
|
5136
5173
|
var products;
|
|
5137
5174
|
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
5138
5175
|
while (1) switch (_context58.prev = _context58.next) {
|
|
@@ -5145,7 +5182,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5145
5182
|
throw new Error('order 模块未初始化');
|
|
5146
5183
|
case 3:
|
|
5147
5184
|
_context58.next = 5;
|
|
5148
|
-
return this.store.order.
|
|
5185
|
+
return this.store.order.updateOrderProducts(paramsList);
|
|
5149
5186
|
case 5:
|
|
5150
5187
|
products = _context58.sent;
|
|
5151
5188
|
return _context58.abrupt("return", products);
|
|
@@ -5159,7 +5196,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5159
5196
|
}
|
|
5160
5197
|
}, _callee58, this, [[0, 9]]);
|
|
5161
5198
|
}));
|
|
5162
|
-
function
|
|
5199
|
+
function updateOrderProducts(_x53) {
|
|
5200
|
+
return _updateOrderProducts.apply(this, arguments);
|
|
5201
|
+
}
|
|
5202
|
+
return updateOrderProducts;
|
|
5203
|
+
}()
|
|
5204
|
+
}, {
|
|
5205
|
+
key: "updateOrderProductQuantity",
|
|
5206
|
+
value: function () {
|
|
5207
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
|
|
5208
|
+
var products;
|
|
5209
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context59) {
|
|
5210
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
5211
|
+
case 0:
|
|
5212
|
+
_context59.prev = 0;
|
|
5213
|
+
if (this.store.order) {
|
|
5214
|
+
_context59.next = 3;
|
|
5215
|
+
break;
|
|
5216
|
+
}
|
|
5217
|
+
throw new Error('order 模块未初始化');
|
|
5218
|
+
case 3:
|
|
5219
|
+
_context59.next = 5;
|
|
5220
|
+
return this.store.order.updateOrderProductQuantity(params);
|
|
5221
|
+
case 5:
|
|
5222
|
+
products = _context59.sent;
|
|
5223
|
+
return _context59.abrupt("return", products);
|
|
5224
|
+
case 9:
|
|
5225
|
+
_context59.prev = 9;
|
|
5226
|
+
_context59.t0 = _context59["catch"](0);
|
|
5227
|
+
throw _context59.t0;
|
|
5228
|
+
case 12:
|
|
5229
|
+
case "end":
|
|
5230
|
+
return _context59.stop();
|
|
5231
|
+
}
|
|
5232
|
+
}, _callee59, this, [[0, 9]]);
|
|
5233
|
+
}));
|
|
5234
|
+
function updateOrderProductQuantity(_x54) {
|
|
5163
5235
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
5164
5236
|
}
|
|
5165
5237
|
return updateOrderProductQuantity;
|
|
@@ -5182,12 +5254,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5182
5254
|
}, {
|
|
5183
5255
|
key: "setOrderProductLineNote",
|
|
5184
5256
|
value: (function () {
|
|
5185
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5257
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(identity, note) {
|
|
5186
5258
|
var params, products;
|
|
5187
|
-
return _regeneratorRuntime().wrap(function
|
|
5188
|
-
while (1) switch (
|
|
5259
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
5260
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
5189
5261
|
case 0:
|
|
5190
|
-
|
|
5262
|
+
_context60.prev = 0;
|
|
5191
5263
|
params = {
|
|
5192
5264
|
product_id: identity.product_id,
|
|
5193
5265
|
product_variant_id: identity.product_variant_id,
|
|
@@ -5202,22 +5274,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5202
5274
|
params.product_sku = identity.product_sku;
|
|
5203
5275
|
}
|
|
5204
5276
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
5205
|
-
|
|
5277
|
+
_context60.next = 7;
|
|
5206
5278
|
return this.updateOrderProduct(params);
|
|
5207
5279
|
case 7:
|
|
5208
|
-
products =
|
|
5209
|
-
return
|
|
5280
|
+
products = _context60.sent;
|
|
5281
|
+
return _context60.abrupt("return", products);
|
|
5210
5282
|
case 11:
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
throw
|
|
5283
|
+
_context60.prev = 11;
|
|
5284
|
+
_context60.t0 = _context60["catch"](0);
|
|
5285
|
+
throw _context60.t0;
|
|
5214
5286
|
case 14:
|
|
5215
5287
|
case "end":
|
|
5216
|
-
return
|
|
5288
|
+
return _context60.stop();
|
|
5217
5289
|
}
|
|
5218
|
-
},
|
|
5290
|
+
}, _callee60, this, [[0, 11]]);
|
|
5219
5291
|
}));
|
|
5220
|
-
function setOrderProductLineNote(
|
|
5292
|
+
function setOrderProductLineNote(_x55, _x56) {
|
|
5221
5293
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
5222
5294
|
}
|
|
5223
5295
|
return setOrderProductLineNote;
|
|
@@ -5232,32 +5304,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5232
5304
|
}, {
|
|
5233
5305
|
key: "removeProductsFromOrder",
|
|
5234
5306
|
value: (function () {
|
|
5235
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5236
|
-
return _regeneratorRuntime().wrap(function
|
|
5237
|
-
while (1) switch (
|
|
5307
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(identities, options) {
|
|
5308
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
5309
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
5238
5310
|
case 0:
|
|
5239
|
-
|
|
5311
|
+
_context61.prev = 0;
|
|
5240
5312
|
if (this.store.order) {
|
|
5241
|
-
|
|
5313
|
+
_context61.next = 3;
|
|
5242
5314
|
break;
|
|
5243
5315
|
}
|
|
5244
5316
|
throw new Error('order 模块未初始化');
|
|
5245
5317
|
case 3:
|
|
5246
|
-
|
|
5318
|
+
_context61.next = 5;
|
|
5247
5319
|
return this.store.order.removeProductsFromOrder(identities, options);
|
|
5248
5320
|
case 5:
|
|
5249
|
-
return
|
|
5321
|
+
return _context61.abrupt("return", _context61.sent);
|
|
5250
5322
|
case 8:
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
throw
|
|
5323
|
+
_context61.prev = 8;
|
|
5324
|
+
_context61.t0 = _context61["catch"](0);
|
|
5325
|
+
throw _context61.t0;
|
|
5254
5326
|
case 11:
|
|
5255
5327
|
case "end":
|
|
5256
|
-
return
|
|
5328
|
+
return _context61.stop();
|
|
5257
5329
|
}
|
|
5258
|
-
},
|
|
5330
|
+
}, _callee61, this, [[0, 8]]);
|
|
5259
5331
|
}));
|
|
5260
|
-
function removeProductsFromOrder(
|
|
5332
|
+
function removeProductsFromOrder(_x57, _x58) {
|
|
5261
5333
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
5262
5334
|
}
|
|
5263
5335
|
return removeProductsFromOrder;
|
|
@@ -5265,18 +5337,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5265
5337
|
}, {
|
|
5266
5338
|
key: "removeProductFromOrder",
|
|
5267
5339
|
value: function () {
|
|
5268
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5269
|
-
return _regeneratorRuntime().wrap(function
|
|
5270
|
-
while (1) switch (
|
|
5340
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(identity, options) {
|
|
5341
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
5342
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
5271
5343
|
case 0:
|
|
5272
|
-
return
|
|
5344
|
+
return _context62.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
5273
5345
|
case 1:
|
|
5274
5346
|
case "end":
|
|
5275
|
-
return
|
|
5347
|
+
return _context62.stop();
|
|
5276
5348
|
}
|
|
5277
|
-
},
|
|
5349
|
+
}, _callee62, this);
|
|
5278
5350
|
}));
|
|
5279
|
-
function removeProductFromOrder(
|
|
5351
|
+
function removeProductFromOrder(_x59, _x60) {
|
|
5280
5352
|
return _removeProductFromOrder.apply(this, arguments);
|
|
5281
5353
|
}
|
|
5282
5354
|
return removeProductFromOrder;
|
|
@@ -5326,23 +5398,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5326
5398
|
}, {
|
|
5327
5399
|
key: "applyPromotion",
|
|
5328
5400
|
value: (function () {
|
|
5329
|
-
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5330
|
-
return _regeneratorRuntime().wrap(function
|
|
5331
|
-
while (1) switch (
|
|
5401
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63() {
|
|
5402
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
5403
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
5332
5404
|
case 0:
|
|
5333
5405
|
if (this.store.order) {
|
|
5334
|
-
|
|
5406
|
+
_context63.next = 2;
|
|
5335
5407
|
break;
|
|
5336
5408
|
}
|
|
5337
5409
|
throw new Error('order 模块未初始化');
|
|
5338
5410
|
case 2:
|
|
5339
|
-
|
|
5411
|
+
_context63.next = 4;
|
|
5340
5412
|
return this.store.order.applyPromotion();
|
|
5341
5413
|
case 4:
|
|
5342
5414
|
case "end":
|
|
5343
|
-
return
|
|
5415
|
+
return _context63.stop();
|
|
5344
5416
|
}
|
|
5345
|
-
},
|
|
5417
|
+
}, _callee63, this);
|
|
5346
5418
|
}));
|
|
5347
5419
|
function applyPromotion() {
|
|
5348
5420
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -5369,18 +5441,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5369
5441
|
}, {
|
|
5370
5442
|
key: "getProductList",
|
|
5371
5443
|
value: function () {
|
|
5372
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5444
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64() {
|
|
5373
5445
|
var _this$otherParams33;
|
|
5374
5446
|
var menu_list_ids, _this$store$products, res;
|
|
5375
|
-
return _regeneratorRuntime().wrap(function
|
|
5376
|
-
while (1) switch (
|
|
5447
|
+
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
5448
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
5377
5449
|
case 0:
|
|
5378
5450
|
// 可以直接通过配置里的 menu 读取
|
|
5379
5451
|
menu_list_ids = ((_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 || (_this$otherParams33 = _this$otherParams33.dineInConfig) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33['menu.associated_menus'].map(function (n) {
|
|
5380
5452
|
return Number(n.value);
|
|
5381
5453
|
})) || [];
|
|
5382
|
-
|
|
5383
|
-
|
|
5454
|
+
_context64.prev = 1;
|
|
5455
|
+
_context64.next = 4;
|
|
5384
5456
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
5385
5457
|
menu_list_ids: menu_list_ids,
|
|
5386
5458
|
cacheId: this.cacheId,
|
|
@@ -5388,17 +5460,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5388
5460
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
5389
5461
|
});
|
|
5390
5462
|
case 4:
|
|
5391
|
-
res =
|
|
5392
|
-
return
|
|
5463
|
+
res = _context64.sent;
|
|
5464
|
+
return _context64.abrupt("return", res);
|
|
5393
5465
|
case 8:
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
throw
|
|
5466
|
+
_context64.prev = 8;
|
|
5467
|
+
_context64.t0 = _context64["catch"](1);
|
|
5468
|
+
throw _context64.t0;
|
|
5397
5469
|
case 11:
|
|
5398
5470
|
case "end":
|
|
5399
|
-
return
|
|
5471
|
+
return _context64.stop();
|
|
5400
5472
|
}
|
|
5401
|
-
},
|
|
5473
|
+
}, _callee64, this, [[1, 8]]);
|
|
5402
5474
|
}));
|
|
5403
5475
|
function getProductList() {
|
|
5404
5476
|
return _getProductList.apply(this, arguments);
|
|
@@ -5413,33 +5485,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5413
5485
|
}, {
|
|
5414
5486
|
key: "setOtherParams",
|
|
5415
5487
|
value: function () {
|
|
5416
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5488
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(params) {
|
|
5417
5489
|
var _this$otherParams34;
|
|
5418
5490
|
var _ref42,
|
|
5419
5491
|
_ref42$cover,
|
|
5420
5492
|
cover,
|
|
5421
|
-
|
|
5422
|
-
return _regeneratorRuntime().wrap(function
|
|
5423
|
-
while (1) switch (
|
|
5493
|
+
_args65 = arguments;
|
|
5494
|
+
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
5495
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
5424
5496
|
case 0:
|
|
5425
|
-
_ref42 =
|
|
5497
|
+
_ref42 = _args65.length > 1 && _args65[1] !== undefined ? _args65[1] : {}, _ref42$cover = _ref42.cover, cover = _ref42$cover === void 0 ? false : _ref42$cover;
|
|
5426
5498
|
if (cover) {
|
|
5427
5499
|
this.otherParams = _objectSpread({}, params);
|
|
5428
5500
|
} else {
|
|
5429
5501
|
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
5430
5502
|
}
|
|
5431
5503
|
this.cacheId = (_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.cacheId;
|
|
5432
|
-
|
|
5504
|
+
_context65.next = 5;
|
|
5433
5505
|
return this.syncOtherParamsToSubModules(params, {
|
|
5434
5506
|
cover: cover
|
|
5435
5507
|
});
|
|
5436
5508
|
case 5:
|
|
5437
5509
|
case "end":
|
|
5438
|
-
return
|
|
5510
|
+
return _context65.stop();
|
|
5439
5511
|
}
|
|
5440
|
-
},
|
|
5512
|
+
}, _callee65, this);
|
|
5441
5513
|
}));
|
|
5442
|
-
function setOtherParams(
|
|
5514
|
+
function setOtherParams(_x61) {
|
|
5443
5515
|
return _setOtherParams.apply(this, arguments);
|
|
5444
5516
|
}
|
|
5445
5517
|
return setOtherParams;
|