@pisell/pisellos 0.10.8 → 0.10.9
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/core/index.js +0 -1
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/dist/model/strategy/adapter/walletPass/type.d.ts +5 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +57 -26
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +7 -3
- package/dist/modules/BookingContext/utils/productExtend.js +5 -9
- package/dist/modules/BookingContext/utils/timeSlices.js +24 -3
- 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/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +38 -5
- package/dist/modules/Discount/types.d.ts +11 -0
- package/dist/modules/Order/index.d.ts +20 -1
- package/dist/modules/Order/index.js +976 -730
- package/dist/modules/Order/types.d.ts +6 -1
- package/dist/modules/Order/utils/virtualSettlement.d.ts +56 -0
- package/dist/modules/Order/utils/virtualSettlement.js +271 -0
- package/dist/modules/Order/utils.js +89 -48
- package/dist/modules/Payment/types.d.ts +2 -0
- package/dist/modules/Payment/utils.js +4 -1
- package/dist/modules/Payment/walletpass.d.ts +11 -0
- package/dist/modules/Payment/walletpass.js +235 -60
- package/dist/modules/Product/types.d.ts +23 -0
- package/dist/modules/ProductList/index.d.ts +15 -2
- package/dist/modules/ProductList/index.js +92 -13
- package/dist/modules/SalesSummary/index.d.ts +1 -0
- package/dist/modules/SalesSummary/index.js +4 -3
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +21 -1
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +90 -58
- package/dist/server/modules/order/index.d.ts +1 -0
- package/dist/server/modules/order/index.js +252 -94
- package/dist/server/utils/small-ticket.js +2 -1
- package/dist/solution/BaseSales/index.d.ts +26 -2
- package/dist/solution/BaseSales/index.js +1310 -931
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +78 -12
- package/dist/solution/BookingByStep/index.d.ts +3 -3
- package/dist/solution/BookingTicket/index.d.ts +5 -1
- package/dist/solution/BookingTicket/index.js +221 -159
- package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/dist/solution/ScanOrder/index.js +25 -64
- package/lib/core/index.js +0 -1
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +170 -7
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/lib/model/strategy/adapter/walletPass/type.d.ts +5 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +62 -11
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -0
- package/lib/modules/BookingContext/utils/productExtend.js +4 -3
- package/lib/modules/BookingContext/utils/timeSlices.js +18 -3
- 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/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +37 -3
- package/lib/modules/Discount/types.d.ts +11 -0
- package/lib/modules/Order/index.d.ts +20 -1
- package/lib/modules/Order/index.js +393 -128
- package/lib/modules/Order/types.d.ts +6 -1
- package/lib/modules/Order/utils/virtualSettlement.d.ts +56 -0
- package/lib/modules/Order/utils/virtualSettlement.js +300 -0
- package/lib/modules/Order/utils.js +65 -21
- package/lib/modules/Payment/types.d.ts +2 -0
- package/lib/modules/Payment/utils.js +5 -1
- package/lib/modules/Payment/walletpass.d.ts +11 -0
- package/lib/modules/Payment/walletpass.js +198 -17
- package/lib/modules/Product/types.d.ts +23 -0
- package/lib/modules/ProductList/index.d.ts +15 -2
- package/lib/modules/ProductList/index.js +85 -3
- package/lib/modules/SalesSummary/index.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +10 -2
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +25 -1
- package/lib/server/index.d.ts +9 -0
- package/lib/server/index.js +54 -14
- 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 +26 -2
- package/lib/solution/BaseSales/index.js +261 -23
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +61 -11
- package/lib/solution/BookingByStep/index.d.ts +3 -3
- package/lib/solution/BookingTicket/index.d.ts +5 -1
- package/lib/solution/BookingTicket/index.js +30 -2
- package/lib/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/lib/solution/ScanOrder/index.js +17 -54
- package/package.json +1 -1
|
@@ -37,6 +37,7 @@ import Decimal from 'decimal.js';
|
|
|
37
37
|
import { cloneDeep, mergeWith } from 'lodash-es';
|
|
38
38
|
import { createModule } from "../BookingByStep/types";
|
|
39
39
|
import { composeLinePrice, createUuidV4, ensureProductSku, getProductSkuOptions, resolveIsFormSubject, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
40
|
+
import { getTempOrderSettlementSnapshot, isVirtualSettlementOrder } from "../../modules/Order/utils/virtualSettlement";
|
|
40
41
|
import { ensureOrderPaymentNumber, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity, resolveOrderPaymentIdentity } from "../../modules/Order/payment-utils";
|
|
41
42
|
import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
|
|
42
43
|
import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
|
|
@@ -899,8 +900,43 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
899
900
|
if (businessCode !== undefined && businessCode !== null && String(businessCode).trim() !== '') {
|
|
900
901
|
strategyContext.business_code = String(businessCode).trim();
|
|
901
902
|
}
|
|
903
|
+
var availableWalletIds = this.getAvailableWalletIds();
|
|
904
|
+
if (availableWalletIds.length > 0 && !Array.isArray(strategyContext.available_wallet_ids)) {
|
|
905
|
+
strategyContext.available_wallet_ids = availableWalletIds;
|
|
906
|
+
}
|
|
902
907
|
return strategyContext;
|
|
903
908
|
}
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* 子类可在商品重报价前准备客户维度的策略上下文,例如等待 Wallet/优惠资产加载。
|
|
912
|
+
*/
|
|
913
|
+
}, {
|
|
914
|
+
key: "prepareProductPriceQueryContext",
|
|
915
|
+
value: (function () {
|
|
916
|
+
var _prepareProductPriceQueryContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_customerId) {
|
|
917
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
918
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
919
|
+
case 0:
|
|
920
|
+
case "end":
|
|
921
|
+
return _context7.stop();
|
|
922
|
+
}
|
|
923
|
+
}, _callee7);
|
|
924
|
+
}));
|
|
925
|
+
function prepareProductPriceQueryContext(_x6) {
|
|
926
|
+
return _prepareProductPriceQueryContext.apply(this, arguments);
|
|
927
|
+
}
|
|
928
|
+
return prepareProductPriceQueryContext;
|
|
929
|
+
}()
|
|
930
|
+
/**
|
|
931
|
+
* 默认保留 BaseSales 的 legacy quotation 行为;已由 /product/query 统一完成
|
|
932
|
+
* 智能定价与报价合并的业务可在子类中覆盖,避免二次覆盖权威价格。
|
|
933
|
+
*/
|
|
934
|
+
)
|
|
935
|
+
}, {
|
|
936
|
+
key: "preferAuthoritativeProductQueryPrice",
|
|
937
|
+
value: function preferAuthoritativeProductQueryPrice() {
|
|
938
|
+
return false;
|
|
939
|
+
}
|
|
904
940
|
}, {
|
|
905
941
|
key: "getPriceQuerySchedule",
|
|
906
942
|
value: function getPriceQuerySchedule(params) {
|
|
@@ -932,25 +968,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
932
968
|
}, {
|
|
933
969
|
key: "loadProductsForPriceQuery",
|
|
934
970
|
value: function () {
|
|
935
|
-
var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
971
|
+
var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
936
972
|
var ids, productsById, channel, strategyContext, _response$data, response, list;
|
|
937
|
-
return _regeneratorRuntime().wrap(function
|
|
938
|
-
while (1) switch (
|
|
973
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
974
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
939
975
|
case 0:
|
|
940
976
|
ids = Array.from(new Set(params.ids.filter(function (id) {
|
|
941
977
|
return Number.isFinite(id);
|
|
942
978
|
})));
|
|
943
979
|
productsById = new Map();
|
|
944
980
|
if (!(!ids.length || !this.request)) {
|
|
945
|
-
|
|
981
|
+
_context8.next = 4;
|
|
946
982
|
break;
|
|
947
983
|
}
|
|
948
|
-
return
|
|
984
|
+
return _context8.abrupt("return", productsById);
|
|
949
985
|
case 4:
|
|
950
986
|
channel = this.getPriceQueryChannel(params.channel);
|
|
951
987
|
strategyContext = this.getPriceQueryStrategyContext(channel);
|
|
952
|
-
|
|
953
|
-
|
|
988
|
+
_context8.prev = 6;
|
|
989
|
+
_context8.next = 9;
|
|
954
990
|
return this.request.post('/product/query', _objectSpread({
|
|
955
991
|
ids: ids,
|
|
956
992
|
open_quotation: 1,
|
|
@@ -969,35 +1005,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
969
1005
|
customToast: function customToast() {}
|
|
970
1006
|
});
|
|
971
1007
|
case 9:
|
|
972
|
-
response =
|
|
1008
|
+
response = _context8.sent;
|
|
973
1009
|
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) || [];
|
|
974
1010
|
if (Array.isArray(list)) {
|
|
975
|
-
|
|
1011
|
+
_context8.next = 13;
|
|
976
1012
|
break;
|
|
977
1013
|
}
|
|
978
|
-
return
|
|
1014
|
+
return _context8.abrupt("return", productsById);
|
|
979
1015
|
case 13:
|
|
980
1016
|
list.forEach(function (item) {
|
|
981
1017
|
var _item$id;
|
|
982
1018
|
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);
|
|
983
1019
|
if (Number.isFinite(productId)) productsById.set(productId, item);
|
|
984
1020
|
});
|
|
985
|
-
return
|
|
1021
|
+
return _context8.abrupt("return", productsById);
|
|
986
1022
|
case 17:
|
|
987
|
-
|
|
988
|
-
|
|
1023
|
+
_context8.prev = 17;
|
|
1024
|
+
_context8.t0 = _context8["catch"](6);
|
|
989
1025
|
this.logWarning('loadProductsForPriceQuery: 商品批量重查失败,使用入参 fallback', {
|
|
990
1026
|
ids: ids,
|
|
991
|
-
error:
|
|
1027
|
+
error: _context8.t0 instanceof Error ? _context8.t0.message : String(_context8.t0)
|
|
992
1028
|
});
|
|
993
|
-
return
|
|
1029
|
+
return _context8.abrupt("return", productsById);
|
|
994
1030
|
case 21:
|
|
995
1031
|
case "end":
|
|
996
|
-
return
|
|
1032
|
+
return _context8.stop();
|
|
997
1033
|
}
|
|
998
|
-
},
|
|
1034
|
+
}, _callee8, this, [[6, 17]]);
|
|
999
1035
|
}));
|
|
1000
|
-
function loadProductsForPriceQuery(
|
|
1036
|
+
function loadProductsForPriceQuery(_x7) {
|
|
1001
1037
|
return _loadProductsForPriceQuery.apply(this, arguments);
|
|
1002
1038
|
}
|
|
1003
1039
|
return loadProductsForPriceQuery;
|
|
@@ -1005,21 +1041,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1005
1041
|
}, {
|
|
1006
1042
|
key: "loadProductForPriceQuery",
|
|
1007
1043
|
value: function () {
|
|
1008
|
-
var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1044
|
+
var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params, customerId) {
|
|
1009
1045
|
var product, productId, schedule, productsById;
|
|
1010
|
-
return _regeneratorRuntime().wrap(function
|
|
1011
|
-
while (1) switch (
|
|
1046
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1047
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1012
1048
|
case 0:
|
|
1013
1049
|
product = params.product || {};
|
|
1014
1050
|
productId = this.getPriceQueryProductId(product);
|
|
1015
1051
|
if (!(productId === null || !this.request)) {
|
|
1016
|
-
|
|
1052
|
+
_context9.next = 4;
|
|
1017
1053
|
break;
|
|
1018
1054
|
}
|
|
1019
|
-
return
|
|
1055
|
+
return _context9.abrupt("return", null);
|
|
1020
1056
|
case 4:
|
|
1021
1057
|
schedule = this.getPriceQuerySchedule(params);
|
|
1022
|
-
|
|
1058
|
+
_context9.next = 7;
|
|
1023
1059
|
return this.loadProductsForPriceQuery({
|
|
1024
1060
|
ids: [productId],
|
|
1025
1061
|
schedule: schedule,
|
|
@@ -1027,15 +1063,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1027
1063
|
channel: params.channel
|
|
1028
1064
|
});
|
|
1029
1065
|
case 7:
|
|
1030
|
-
productsById =
|
|
1031
|
-
return
|
|
1066
|
+
productsById = _context9.sent;
|
|
1067
|
+
return _context9.abrupt("return", productsById.get(productId) || null);
|
|
1032
1068
|
case 9:
|
|
1033
1069
|
case "end":
|
|
1034
|
-
return
|
|
1070
|
+
return _context9.stop();
|
|
1035
1071
|
}
|
|
1036
|
-
},
|
|
1072
|
+
}, _callee9, this);
|
|
1037
1073
|
}));
|
|
1038
|
-
function loadProductForPriceQuery(
|
|
1074
|
+
function loadProductForPriceQuery(_x8, _x9) {
|
|
1039
1075
|
return _loadProductForPriceQuery.apply(this, arguments);
|
|
1040
1076
|
}
|
|
1041
1077
|
return loadProductForPriceQuery;
|
|
@@ -1203,60 +1239,60 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1203
1239
|
}, {
|
|
1204
1240
|
key: "syncOtherParamsToSubModules",
|
|
1205
1241
|
value: (function () {
|
|
1206
|
-
var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1242
|
+
var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(changedParams) {
|
|
1207
1243
|
var _this6 = this;
|
|
1208
1244
|
var _ref23,
|
|
1209
1245
|
_ref23$cover,
|
|
1210
1246
|
cover,
|
|
1211
|
-
|
|
1212
|
-
return _regeneratorRuntime().wrap(function
|
|
1213
|
-
while (1) switch (
|
|
1247
|
+
_args11 = arguments;
|
|
1248
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1249
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1214
1250
|
case 0:
|
|
1215
|
-
_ref23 =
|
|
1216
|
-
|
|
1251
|
+
_ref23 = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {}, _ref23$cover = _ref23.cover, cover = _ref23$cover === void 0 ? false : _ref23$cover;
|
|
1252
|
+
_context11.next = 3;
|
|
1217
1253
|
return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
|
|
1218
|
-
var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1254
|
+
var _ref25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref24) {
|
|
1219
1255
|
var _ref26, moduleName, subModule, targetModule, nextSubModuleOtherParams;
|
|
1220
|
-
return _regeneratorRuntime().wrap(function
|
|
1221
|
-
while (1) switch (
|
|
1256
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1257
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1222
1258
|
case 0:
|
|
1223
1259
|
_ref26 = _slicedToArray(_ref24, 2), moduleName = _ref26[0], subModule = _ref26[1];
|
|
1224
1260
|
if (!_this6.reusedSharedSubModuleNames.has(moduleName)) {
|
|
1225
|
-
|
|
1261
|
+
_context10.next = 3;
|
|
1226
1262
|
break;
|
|
1227
1263
|
}
|
|
1228
|
-
return
|
|
1264
|
+
return _context10.abrupt("return");
|
|
1229
1265
|
case 3:
|
|
1230
1266
|
targetModule = subModule;
|
|
1231
1267
|
if (!(!targetModule || typeof targetModule.updateOtherParams !== 'function')) {
|
|
1232
|
-
|
|
1268
|
+
_context10.next = 6;
|
|
1233
1269
|
break;
|
|
1234
1270
|
}
|
|
1235
|
-
return
|
|
1271
|
+
return _context10.abrupt("return");
|
|
1236
1272
|
case 6:
|
|
1237
1273
|
nextSubModuleOtherParams = _this6.buildSubModuleOtherParams(moduleName);
|
|
1238
|
-
|
|
1274
|
+
_context10.next = 9;
|
|
1239
1275
|
return targetModule.updateOtherParams(nextSubModuleOtherParams, {
|
|
1240
1276
|
changedParams: changedParams,
|
|
1241
1277
|
cover: cover
|
|
1242
1278
|
});
|
|
1243
1279
|
case 9:
|
|
1244
1280
|
case "end":
|
|
1245
|
-
return
|
|
1281
|
+
return _context10.stop();
|
|
1246
1282
|
}
|
|
1247
|
-
},
|
|
1283
|
+
}, _callee10);
|
|
1248
1284
|
}));
|
|
1249
|
-
return function (
|
|
1285
|
+
return function (_x11) {
|
|
1250
1286
|
return _ref25.apply(this, arguments);
|
|
1251
1287
|
};
|
|
1252
1288
|
}()));
|
|
1253
1289
|
case 3:
|
|
1254
1290
|
case "end":
|
|
1255
|
-
return
|
|
1291
|
+
return _context11.stop();
|
|
1256
1292
|
}
|
|
1257
|
-
},
|
|
1293
|
+
}, _callee11, this);
|
|
1258
1294
|
}));
|
|
1259
|
-
function syncOtherParamsToSubModules(
|
|
1295
|
+
function syncOtherParamsToSubModules(_x10) {
|
|
1260
1296
|
return _syncOtherParamsToSubModules.apply(this, arguments);
|
|
1261
1297
|
}
|
|
1262
1298
|
return syncOtherParamsToSubModules;
|
|
@@ -1324,6 +1360,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1324
1360
|
return _this8.getAppData(key);
|
|
1325
1361
|
});
|
|
1326
1362
|
}
|
|
1363
|
+
}, {
|
|
1364
|
+
key: "isMultiCurrencySettlementEnabled",
|
|
1365
|
+
value: function isMultiCurrencySettlementEnabled() {
|
|
1366
|
+
var _this$otherParams9;
|
|
1367
|
+
return ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.enableMultiCurrencySettlement) === true;
|
|
1368
|
+
}
|
|
1369
|
+
}, {
|
|
1370
|
+
key: "isActiveVirtualSettlementOrder",
|
|
1371
|
+
value: function isActiveVirtualSettlementOrder(tempOrder) {
|
|
1372
|
+
return this.isMultiCurrencySettlementEnabled() && isVirtualSettlementOrder(tempOrder);
|
|
1373
|
+
}
|
|
1374
|
+
}, {
|
|
1375
|
+
key: "isHistoricalVirtualSettlementOrder",
|
|
1376
|
+
value: function isHistoricalVirtualSettlementOrder(tempOrder) {
|
|
1377
|
+
var _tempOrder$metadata;
|
|
1378
|
+
return (tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 || (_tempOrder$metadata = _tempOrder$metadata.currency_settlement_config) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.settlement_type) === 'virtual_currency';
|
|
1379
|
+
}
|
|
1327
1380
|
}, {
|
|
1328
1381
|
key: "syncAppDataToTempOrder",
|
|
1329
1382
|
value: function syncAppDataToTempOrder(tempOrder) {
|
|
@@ -1331,6 +1384,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1331
1384
|
var taxCountryCode = this.getAppData('tax_country_code');
|
|
1332
1385
|
var currencyCode = this.getAppData('shop_currency_code');
|
|
1333
1386
|
var currencySymbol = this.getAppData('shop_symbol');
|
|
1387
|
+
// 历史虚拟币订单不依赖交易开关;普通 POS 不从商品行残留快照推断订单币种。
|
|
1388
|
+
var isHistoricalVirtualSettlement = this.isHistoricalVirtualSettlementOrder(tempOrder);
|
|
1389
|
+
var isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder) || isHistoricalVirtualSettlement;
|
|
1390
|
+
var shouldManageLegalCurrencySnapshot = this.isMultiCurrencySettlementEnabled() || isHistoricalVirtualSettlement;
|
|
1334
1391
|
var isChanged = false;
|
|
1335
1392
|
if (isPriceIncludeTax !== undefined) {
|
|
1336
1393
|
var nextIsPriceIncludeTax = Number(isPriceIncludeTax);
|
|
@@ -1346,14 +1403,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1346
1403
|
isChanged = true;
|
|
1347
1404
|
}
|
|
1348
1405
|
}
|
|
1349
|
-
|
|
1406
|
+
tempOrder.metadata = tempOrder.metadata || {};
|
|
1407
|
+
if (shouldManageLegalCurrencySnapshot) {
|
|
1408
|
+
var _ref27, _ref28, _tempOrder$metadata$l, _ref29, _ref30, _tempOrder$metadata$l2, _tempOrder$metadata$l3;
|
|
1409
|
+
var legalCurrencySnapshot = {
|
|
1410
|
+
currency_code: String((_ref27 = (_ref28 = currencyCode !== null && currencyCode !== void 0 ? currencyCode : (_tempOrder$metadata$l = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l === void 0 ? void 0 : _tempOrder$metadata$l.currency_code) !== null && _ref28 !== void 0 ? _ref28 : tempOrder.currency_code) !== null && _ref27 !== void 0 ? _ref27 : ''),
|
|
1411
|
+
currency_symbol: String((_ref29 = (_ref30 = currencySymbol !== null && currencySymbol !== void 0 ? currencySymbol : (_tempOrder$metadata$l2 = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l2 === void 0 ? void 0 : _tempOrder$metadata$l2.currency_symbol) !== null && _ref30 !== void 0 ? _ref30 : tempOrder.currency_symbol) !== null && _ref29 !== void 0 ? _ref29 : ''),
|
|
1412
|
+
currency_format: String(((_tempOrder$metadata$l3 = tempOrder.metadata.legal_currency_snapshot) === null || _tempOrder$metadata$l3 === void 0 ? void 0 : _tempOrder$metadata$l3.currency_format) || (isVirtualSettlement ? 'symbol_first' : tempOrder.currency_format) || 'symbol_first')
|
|
1413
|
+
};
|
|
1414
|
+
if (JSON.stringify(tempOrder.metadata.legal_currency_snapshot || {}) !== JSON.stringify(legalCurrencySnapshot)) {
|
|
1415
|
+
tempOrder.metadata.legal_currency_snapshot = legalCurrencySnapshot;
|
|
1416
|
+
isChanged = true;
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
if (!isVirtualSettlement && currencyCode !== undefined) {
|
|
1350
1420
|
var nextCurrencyCode = String(currencyCode || '');
|
|
1351
1421
|
if (tempOrder.currency_code !== nextCurrencyCode) {
|
|
1352
1422
|
tempOrder.currency_code = nextCurrencyCode;
|
|
1353
1423
|
isChanged = true;
|
|
1354
1424
|
}
|
|
1355
1425
|
}
|
|
1356
|
-
if (currencySymbol !== undefined) {
|
|
1426
|
+
if (!isVirtualSettlement && currencySymbol !== undefined) {
|
|
1357
1427
|
var nextCurrencySymbol = String(currencySymbol || '');
|
|
1358
1428
|
if (tempOrder.currency_symbol !== nextCurrencySymbol) {
|
|
1359
1429
|
tempOrder.currency_symbol = nextCurrencySymbol;
|
|
@@ -1365,27 +1435,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1365
1435
|
}, {
|
|
1366
1436
|
key: "initialize",
|
|
1367
1437
|
value: function () {
|
|
1368
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1369
|
-
var _this$
|
|
1438
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(core) {
|
|
1439
|
+
var _this$otherParams10,
|
|
1370
1440
|
_this$appPlugin2,
|
|
1371
1441
|
_this$appPlugin2$getA,
|
|
1372
1442
|
_this9 = this,
|
|
1373
|
-
_this$
|
|
1443
|
+
_this$otherParams11;
|
|
1374
1444
|
var options,
|
|
1375
1445
|
app,
|
|
1376
1446
|
targetCacheData,
|
|
1377
1447
|
moduleNames,
|
|
1378
|
-
|
|
1379
|
-
return _regeneratorRuntime().wrap(function
|
|
1380
|
-
while (1) switch (
|
|
1448
|
+
_args12 = arguments;
|
|
1449
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1450
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1381
1451
|
case 0:
|
|
1382
|
-
options =
|
|
1452
|
+
options = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : {};
|
|
1383
1453
|
this.core = core;
|
|
1384
1454
|
this.initializeOptions = options || {};
|
|
1385
1455
|
this.paymentNumberDevicePrefix = null;
|
|
1386
1456
|
// this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
|
|
1387
1457
|
this.otherParams = options.otherParams || {};
|
|
1388
|
-
this.cacheId = (_this$
|
|
1458
|
+
this.cacheId = (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.cacheId;
|
|
1389
1459
|
this.reusedSharedSubModuleNames.clear();
|
|
1390
1460
|
this.window = core.getPlugin('window');
|
|
1391
1461
|
this.request = core.getPlugin('request');
|
|
@@ -1421,27 +1491,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1421
1491
|
}));
|
|
1422
1492
|
});
|
|
1423
1493
|
if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
|
|
1424
|
-
|
|
1494
|
+
_context12.next = 19;
|
|
1425
1495
|
break;
|
|
1426
1496
|
}
|
|
1427
|
-
|
|
1497
|
+
_context12.next = 19;
|
|
1428
1498
|
return this.store.schedule.loadAllSchedule();
|
|
1429
1499
|
case 19:
|
|
1430
|
-
if (this.store.order && typeof ((_this$
|
|
1500
|
+
if (this.store.order && typeof ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.enableTempOrderPersist) === 'boolean') {
|
|
1431
1501
|
this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
|
|
1432
1502
|
}
|
|
1433
|
-
|
|
1503
|
+
_context12.next = 22;
|
|
1434
1504
|
return this.getPaymentMethodsAsync();
|
|
1435
1505
|
case 22:
|
|
1436
1506
|
this.registerServerOrderChangeSync();
|
|
1437
1507
|
this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
1438
1508
|
case 24:
|
|
1439
1509
|
case "end":
|
|
1440
|
-
return
|
|
1510
|
+
return _context12.stop();
|
|
1441
1511
|
}
|
|
1442
|
-
},
|
|
1512
|
+
}, _callee12, this);
|
|
1443
1513
|
}));
|
|
1444
|
-
function initialize(
|
|
1514
|
+
function initialize(_x12) {
|
|
1445
1515
|
return _initialize.apply(this, arguments);
|
|
1446
1516
|
}
|
|
1447
1517
|
return initialize;
|
|
@@ -1449,11 +1519,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1449
1519
|
}, {
|
|
1450
1520
|
key: "destroy",
|
|
1451
1521
|
value: function () {
|
|
1452
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1522
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
1453
1523
|
var _this$serverOrderChan2,
|
|
1454
1524
|
_this10 = this;
|
|
1455
|
-
return _regeneratorRuntime().wrap(function
|
|
1456
|
-
while (1) switch (
|
|
1525
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1526
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1457
1527
|
case 0:
|
|
1458
1528
|
(_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
|
|
1459
1529
|
this.serverOrderChangeUnsubscribe = null;
|
|
@@ -1473,15 +1543,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1473
1543
|
this.queuedServerOrderChanges = [];
|
|
1474
1544
|
this.salesDetailLoadSequence += 1;
|
|
1475
1545
|
this.walletAssetsRefreshSequence += 1;
|
|
1476
|
-
|
|
1546
|
+
_context13.next = 10;
|
|
1477
1547
|
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
1478
1548
|
case 10:
|
|
1479
1549
|
_get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
|
|
1480
1550
|
case 11:
|
|
1481
1551
|
case "end":
|
|
1482
|
-
return
|
|
1552
|
+
return _context13.stop();
|
|
1483
1553
|
}
|
|
1484
|
-
},
|
|
1554
|
+
}, _callee13, this);
|
|
1485
1555
|
}));
|
|
1486
1556
|
function destroy() {
|
|
1487
1557
|
return _destroy.apply(this, arguments);
|
|
@@ -1498,51 +1568,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1498
1568
|
}, {
|
|
1499
1569
|
key: "loadSalesDetail",
|
|
1500
1570
|
value: (function () {
|
|
1501
|
-
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1502
|
-
var loadSequence,
|
|
1503
|
-
return _regeneratorRuntime().wrap(function
|
|
1504
|
-
while (1) switch (
|
|
1571
|
+
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderIdOrParams) {
|
|
1572
|
+
var loadSequence, _ref31, _ref32, _ref33, _ref34, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, loadedSalesDetail, shouldFilterPendingPayments, remoteRecord, currentTempOrder, mergedRecord, record;
|
|
1573
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1574
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1505
1575
|
case 0:
|
|
1506
1576
|
if (this.store.order) {
|
|
1507
|
-
|
|
1577
|
+
_context14.next = 2;
|
|
1508
1578
|
break;
|
|
1509
1579
|
}
|
|
1510
1580
|
throw new Error('order 模块未初始化');
|
|
1511
1581
|
case 2:
|
|
1512
1582
|
loadSequence = ++this.salesDetailLoadSequence;
|
|
1513
1583
|
this.salesDetailLoadInFlightCount += 1;
|
|
1514
|
-
|
|
1584
|
+
_context14.prev = 4;
|
|
1515
1585
|
params = _typeof(orderIdOrParams) === 'object' ? orderIdOrParams : {
|
|
1516
1586
|
orderId: orderIdOrParams
|
|
1517
1587
|
};
|
|
1518
1588
|
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
1519
1589
|
preloadedSalesDetail = params.preloadedSalesDetail;
|
|
1520
|
-
lookup = (
|
|
1590
|
+
lookup = (_ref31 = (_ref32 = (_ref33 = (_ref34 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref34 !== void 0 ? _ref34 : params.orderNumber) !== null && _ref33 !== void 0 ? _ref33 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref32 !== void 0 ? _ref32 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref31 !== void 0 ? _ref31 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
|
|
1521
1591
|
if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
|
|
1522
|
-
|
|
1592
|
+
_context14.next = 11;
|
|
1523
1593
|
break;
|
|
1524
1594
|
}
|
|
1525
1595
|
throw new Error('加载销售详情需要 orderId、externalSaleNumber 或 orderNumber');
|
|
1526
1596
|
case 11:
|
|
1527
1597
|
if (!(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0)) {
|
|
1528
|
-
|
|
1598
|
+
_context14.next = 15;
|
|
1529
1599
|
break;
|
|
1530
1600
|
}
|
|
1531
|
-
|
|
1532
|
-
|
|
1601
|
+
_context14.t0 = preloadedSalesDetail;
|
|
1602
|
+
_context14.next = 18;
|
|
1533
1603
|
break;
|
|
1534
1604
|
case 15:
|
|
1535
|
-
|
|
1605
|
+
_context14.next = 17;
|
|
1536
1606
|
return this.store.order.getSalesOrderByLookup({
|
|
1537
1607
|
lookup: lookup,
|
|
1538
1608
|
forceRemote: params.forceRemote
|
|
1539
1609
|
});
|
|
1540
1610
|
case 17:
|
|
1541
|
-
|
|
1611
|
+
_context14.t0 = _context14.sent;
|
|
1542
1612
|
case 18:
|
|
1543
|
-
loadedRecord =
|
|
1613
|
+
loadedRecord = _context14.t0;
|
|
1544
1614
|
if (!(!preloadedSalesDetail && (!loadedRecord || loadedRecord.code !== 200))) {
|
|
1545
|
-
|
|
1615
|
+
_context14.next = 22;
|
|
1546
1616
|
break;
|
|
1547
1617
|
}
|
|
1548
1618
|
message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
|
|
@@ -1554,38 +1624,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1554
1624
|
currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
1555
1625
|
mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
|
|
1556
1626
|
record = shouldFilterPendingPayments ? filterPendingPaymentsFromLoadedSalesDetail(mergedRecord) : mergedRecord;
|
|
1557
|
-
|
|
1627
|
+
_context14.next = 30;
|
|
1558
1628
|
return this.hydrateLatestLoadedSalesDetail(record, loadSequence, params.hydrateSource);
|
|
1559
1629
|
case 30:
|
|
1560
|
-
return
|
|
1630
|
+
return _context14.abrupt("return", _context14.sent);
|
|
1561
1631
|
case 31:
|
|
1562
|
-
|
|
1632
|
+
_context14.prev = 31;
|
|
1563
1633
|
this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
|
|
1564
1634
|
if (!(this.salesDetailLoadInFlightCount === 0)) {
|
|
1565
|
-
|
|
1635
|
+
_context14.next = 42;
|
|
1566
1636
|
break;
|
|
1567
1637
|
}
|
|
1568
|
-
|
|
1569
|
-
|
|
1638
|
+
_context14.prev = 34;
|
|
1639
|
+
_context14.next = 37;
|
|
1570
1640
|
return this.drainQueuedServerOrderChanges();
|
|
1571
1641
|
case 37:
|
|
1572
|
-
|
|
1642
|
+
_context14.next = 42;
|
|
1573
1643
|
break;
|
|
1574
1644
|
case 39:
|
|
1575
|
-
|
|
1576
|
-
|
|
1645
|
+
_context14.prev = 39;
|
|
1646
|
+
_context14.t1 = _context14["catch"](34);
|
|
1577
1647
|
this.logError('drain queued server order changes failed', {
|
|
1578
|
-
error:
|
|
1648
|
+
error: _context14.t1 instanceof Error ? _context14.t1.message : String(_context14.t1)
|
|
1579
1649
|
});
|
|
1580
1650
|
case 42:
|
|
1581
|
-
return
|
|
1651
|
+
return _context14.finish(31);
|
|
1582
1652
|
case 43:
|
|
1583
1653
|
case "end":
|
|
1584
|
-
return
|
|
1654
|
+
return _context14.stop();
|
|
1585
1655
|
}
|
|
1586
|
-
},
|
|
1656
|
+
}, _callee14, this, [[4,, 31, 43], [34, 39]]);
|
|
1587
1657
|
}));
|
|
1588
|
-
function loadSalesDetail(
|
|
1658
|
+
function loadSalesDetail(_x13) {
|
|
1589
1659
|
return _loadSalesDetail.apply(this, arguments);
|
|
1590
1660
|
}
|
|
1591
1661
|
return loadSalesDetail;
|
|
@@ -1665,34 +1735,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1665
1735
|
}, {
|
|
1666
1736
|
key: "replaceTempOrder",
|
|
1667
1737
|
value: function () {
|
|
1668
|
-
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1738
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tempOrder, options) {
|
|
1669
1739
|
var nextTempOrder;
|
|
1670
|
-
return _regeneratorRuntime().wrap(function
|
|
1671
|
-
while (1) switch (
|
|
1740
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1741
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1672
1742
|
case 0:
|
|
1673
1743
|
if (this.store.order) {
|
|
1674
|
-
|
|
1744
|
+
_context15.next = 2;
|
|
1675
1745
|
break;
|
|
1676
1746
|
}
|
|
1677
1747
|
throw new Error('order 模块未初始化');
|
|
1678
1748
|
case 2:
|
|
1679
|
-
|
|
1749
|
+
_context15.next = 4;
|
|
1680
1750
|
return this.store.order.replaceTempOrder(tempOrder, options);
|
|
1681
1751
|
case 4:
|
|
1682
|
-
nextTempOrder =
|
|
1683
|
-
|
|
1752
|
+
nextTempOrder = _context15.sent;
|
|
1753
|
+
_context15.next = 7;
|
|
1684
1754
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
1685
1755
|
tempOrder: nextTempOrder
|
|
1686
1756
|
});
|
|
1687
1757
|
case 7:
|
|
1688
|
-
return
|
|
1758
|
+
return _context15.abrupt("return", nextTempOrder);
|
|
1689
1759
|
case 8:
|
|
1690
1760
|
case "end":
|
|
1691
|
-
return
|
|
1761
|
+
return _context15.stop();
|
|
1692
1762
|
}
|
|
1693
|
-
},
|
|
1763
|
+
}, _callee15, this);
|
|
1694
1764
|
}));
|
|
1695
|
-
function replaceTempOrder(
|
|
1765
|
+
function replaceTempOrder(_x14, _x15) {
|
|
1696
1766
|
return _replaceTempOrder.apply(this, arguments);
|
|
1697
1767
|
}
|
|
1698
1768
|
return replaceTempOrder;
|
|
@@ -1790,40 +1860,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1790
1860
|
}, {
|
|
1791
1861
|
key: "addNewOrder",
|
|
1792
1862
|
value: function () {
|
|
1793
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1863
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
1794
1864
|
var tempOrder;
|
|
1795
|
-
return _regeneratorRuntime().wrap(function
|
|
1796
|
-
while (1) switch (
|
|
1865
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1866
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1797
1867
|
case 0:
|
|
1798
|
-
|
|
1868
|
+
_context16.prev = 0;
|
|
1799
1869
|
if (this.store.order) {
|
|
1800
|
-
|
|
1870
|
+
_context16.next = 3;
|
|
1801
1871
|
break;
|
|
1802
1872
|
}
|
|
1803
1873
|
throw new Error('order 模块未初始化');
|
|
1804
1874
|
case 3:
|
|
1805
|
-
|
|
1875
|
+
_context16.next = 5;
|
|
1806
1876
|
return this.store.order.addNewOrder();
|
|
1807
1877
|
case 5:
|
|
1808
|
-
tempOrder =
|
|
1878
|
+
tempOrder = _context16.sent;
|
|
1809
1879
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1810
|
-
|
|
1880
|
+
_context16.next = 10;
|
|
1811
1881
|
break;
|
|
1812
1882
|
}
|
|
1813
1883
|
this.store.order.persistTempOrder();
|
|
1814
|
-
|
|
1884
|
+
_context16.next = 10;
|
|
1815
1885
|
return this.store.order.saveDraft();
|
|
1816
1886
|
case 10:
|
|
1817
|
-
return
|
|
1887
|
+
return _context16.abrupt("return", tempOrder);
|
|
1818
1888
|
case 13:
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
throw
|
|
1889
|
+
_context16.prev = 13;
|
|
1890
|
+
_context16.t0 = _context16["catch"](0);
|
|
1891
|
+
throw _context16.t0;
|
|
1822
1892
|
case 16:
|
|
1823
1893
|
case "end":
|
|
1824
|
-
return
|
|
1894
|
+
return _context16.stop();
|
|
1825
1895
|
}
|
|
1826
|
-
},
|
|
1896
|
+
}, _callee16, this, [[0, 13]]);
|
|
1827
1897
|
}));
|
|
1828
1898
|
function addNewOrder() {
|
|
1829
1899
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -1833,22 +1903,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1833
1903
|
}, {
|
|
1834
1904
|
key: "saveDraft",
|
|
1835
1905
|
value: function () {
|
|
1836
|
-
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1837
|
-
return _regeneratorRuntime().wrap(function
|
|
1838
|
-
while (1) switch (
|
|
1906
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1907
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1908
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1839
1909
|
case 0:
|
|
1840
1910
|
if (this.store.order) {
|
|
1841
|
-
|
|
1911
|
+
_context17.next = 2;
|
|
1842
1912
|
break;
|
|
1843
1913
|
}
|
|
1844
1914
|
throw new Error('order 模块未初始化');
|
|
1845
1915
|
case 2:
|
|
1846
|
-
return
|
|
1916
|
+
return _context17.abrupt("return", this.store.order.saveDraft());
|
|
1847
1917
|
case 3:
|
|
1848
1918
|
case "end":
|
|
1849
|
-
return
|
|
1919
|
+
return _context17.stop();
|
|
1850
1920
|
}
|
|
1851
|
-
},
|
|
1921
|
+
}, _callee17, this);
|
|
1852
1922
|
}));
|
|
1853
1923
|
function saveDraft() {
|
|
1854
1924
|
return _saveDraft.apply(this, arguments);
|
|
@@ -1859,14 +1929,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1859
1929
|
}, {
|
|
1860
1930
|
key: "restoreOrder",
|
|
1861
1931
|
value: function () {
|
|
1862
|
-
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1932
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1863
1933
|
var _this$store$payment, tempOrder, wallet;
|
|
1864
|
-
return _regeneratorRuntime().wrap(function
|
|
1865
|
-
while (1) switch (
|
|
1934
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1935
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1866
1936
|
case 0:
|
|
1867
|
-
|
|
1937
|
+
_context18.prev = 0;
|
|
1868
1938
|
if (this.store.order) {
|
|
1869
|
-
|
|
1939
|
+
_context18.next = 3;
|
|
1870
1940
|
break;
|
|
1871
1941
|
}
|
|
1872
1942
|
throw new Error('scanOrder 解决方案需要 order 模块支持');
|
|
@@ -1878,37 +1948,37 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1878
1948
|
this.hasManualDiscountSelection = false;
|
|
1879
1949
|
wallet = (_this$store$payment = this.store.payment) === null || _this$store$payment === void 0 ? void 0 : _this$store$payment.wallet;
|
|
1880
1950
|
if (!wallet) {
|
|
1881
|
-
|
|
1951
|
+
_context18.next = 13;
|
|
1882
1952
|
break;
|
|
1883
1953
|
}
|
|
1884
1954
|
this.walletAssetsRefreshSequence += 1;
|
|
1885
1955
|
wallet.clearAllCache();
|
|
1886
|
-
|
|
1956
|
+
_context18.next = 13;
|
|
1887
1957
|
return this.publishWalletAssetsState(wallet.getWalletAssetsState());
|
|
1888
1958
|
case 13:
|
|
1889
|
-
|
|
1959
|
+
_context18.next = 15;
|
|
1890
1960
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
1891
1961
|
tempOrder: tempOrder
|
|
1892
1962
|
});
|
|
1893
1963
|
case 15:
|
|
1894
1964
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1895
|
-
|
|
1965
|
+
_context18.next = 19;
|
|
1896
1966
|
break;
|
|
1897
1967
|
}
|
|
1898
1968
|
this.store.order.persistTempOrder();
|
|
1899
|
-
|
|
1969
|
+
_context18.next = 19;
|
|
1900
1970
|
return this.store.order.saveDraft();
|
|
1901
1971
|
case 19:
|
|
1902
|
-
return
|
|
1972
|
+
return _context18.abrupt("return", tempOrder);
|
|
1903
1973
|
case 22:
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
throw
|
|
1974
|
+
_context18.prev = 22;
|
|
1975
|
+
_context18.t0 = _context18["catch"](0);
|
|
1976
|
+
throw _context18.t0;
|
|
1907
1977
|
case 25:
|
|
1908
1978
|
case "end":
|
|
1909
|
-
return
|
|
1979
|
+
return _context18.stop();
|
|
1910
1980
|
}
|
|
1911
|
-
},
|
|
1981
|
+
}, _callee18, this, [[0, 22]]);
|
|
1912
1982
|
}));
|
|
1913
1983
|
function restoreOrder() {
|
|
1914
1984
|
return _restoreOrder.apply(this, arguments);
|
|
@@ -1922,22 +1992,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1922
1992
|
}, {
|
|
1923
1993
|
key: "clearOrderCartLines",
|
|
1924
1994
|
value: (function () {
|
|
1925
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1995
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1926
1996
|
var tempOrder;
|
|
1927
|
-
return _regeneratorRuntime().wrap(function
|
|
1928
|
-
while (1) switch (
|
|
1997
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1998
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1929
1999
|
case 0:
|
|
1930
|
-
|
|
2000
|
+
_context19.prev = 0;
|
|
1931
2001
|
if (this.store.order) {
|
|
1932
|
-
|
|
2002
|
+
_context19.next = 3;
|
|
1933
2003
|
break;
|
|
1934
2004
|
}
|
|
1935
2005
|
throw new Error('order 模块未初始化');
|
|
1936
2006
|
case 3:
|
|
1937
|
-
|
|
2007
|
+
_context19.next = 5;
|
|
1938
2008
|
return this.store.order.clearOrderCartLines();
|
|
1939
2009
|
case 5:
|
|
1940
|
-
tempOrder =
|
|
2010
|
+
tempOrder = _context19.sent;
|
|
1941
2011
|
if (this.currentSalesDetail) {
|
|
1942
2012
|
this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
|
|
1943
2013
|
products: [],
|
|
@@ -1947,34 +2017,74 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1947
2017
|
discount_list: []
|
|
1948
2018
|
});
|
|
1949
2019
|
}
|
|
1950
|
-
|
|
2020
|
+
_context19.next = 9;
|
|
1951
2021
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
1952
2022
|
tempOrder: tempOrder
|
|
1953
2023
|
});
|
|
1954
2024
|
case 9:
|
|
1955
2025
|
if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
|
|
1956
|
-
|
|
2026
|
+
_context19.next = 13;
|
|
1957
2027
|
break;
|
|
1958
2028
|
}
|
|
1959
2029
|
this.store.order.persistTempOrder();
|
|
1960
|
-
|
|
2030
|
+
_context19.next = 13;
|
|
1961
2031
|
return this.store.order.saveDraft();
|
|
1962
2032
|
case 13:
|
|
1963
|
-
return
|
|
2033
|
+
return _context19.abrupt("return", tempOrder);
|
|
1964
2034
|
case 16:
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
throw
|
|
2035
|
+
_context19.prev = 16;
|
|
2036
|
+
_context19.t0 = _context19["catch"](0);
|
|
2037
|
+
throw _context19.t0;
|
|
1968
2038
|
case 19:
|
|
1969
2039
|
case "end":
|
|
1970
|
-
return
|
|
2040
|
+
return _context19.stop();
|
|
1971
2041
|
}
|
|
1972
|
-
},
|
|
2042
|
+
}, _callee19, this, [[0, 16]]);
|
|
1973
2043
|
}));
|
|
1974
2044
|
function clearOrderCartLines() {
|
|
1975
2045
|
return _clearOrderCartLines.apply(this, arguments);
|
|
1976
2046
|
}
|
|
1977
2047
|
return clearOrderCartLines;
|
|
2048
|
+
}() /** 切换法币 / WalletPass 单位时清空商品、折扣与支付状态,保留客户。 */)
|
|
2049
|
+
}, {
|
|
2050
|
+
key: "clearOrderForSettlementSwitch",
|
|
2051
|
+
value: (function () {
|
|
2052
|
+
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
2053
|
+
var tempOrder;
|
|
2054
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
2055
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
2056
|
+
case 0:
|
|
2057
|
+
if (this.store.order) {
|
|
2058
|
+
_context20.next = 2;
|
|
2059
|
+
break;
|
|
2060
|
+
}
|
|
2061
|
+
throw new Error('order 模块未初始化');
|
|
2062
|
+
case 2:
|
|
2063
|
+
_context20.next = 4;
|
|
2064
|
+
return this.store.order.clearOrderForSettlementSwitch();
|
|
2065
|
+
case 4:
|
|
2066
|
+
tempOrder = _context20.sent;
|
|
2067
|
+
if (this.currentSalesDetail) {
|
|
2068
|
+
this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
|
|
2069
|
+
products: [],
|
|
2070
|
+
bookings: [],
|
|
2071
|
+
rootBooking: null,
|
|
2072
|
+
bookingsByProductUid: {},
|
|
2073
|
+
discount_list: [],
|
|
2074
|
+
payments: []
|
|
2075
|
+
});
|
|
2076
|
+
}
|
|
2077
|
+
return _context20.abrupt("return", tempOrder);
|
|
2078
|
+
case 7:
|
|
2079
|
+
case "end":
|
|
2080
|
+
return _context20.stop();
|
|
2081
|
+
}
|
|
2082
|
+
}, _callee20, this);
|
|
2083
|
+
}));
|
|
2084
|
+
function clearOrderForSettlementSwitch() {
|
|
2085
|
+
return _clearOrderForSettlementSwitch.apply(this, arguments);
|
|
2086
|
+
}
|
|
2087
|
+
return clearOrderForSettlementSwitch;
|
|
1978
2088
|
}())
|
|
1979
2089
|
}, {
|
|
1980
2090
|
key: "getOrderProducts",
|
|
@@ -1986,32 +2096,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1986
2096
|
}, {
|
|
1987
2097
|
key: "getSummary",
|
|
1988
2098
|
value: function () {
|
|
1989
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2099
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
1990
2100
|
var summary;
|
|
1991
|
-
return _regeneratorRuntime().wrap(function
|
|
1992
|
-
while (1) switch (
|
|
2101
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2102
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1993
2103
|
case 0:
|
|
1994
|
-
|
|
2104
|
+
_context21.prev = 0;
|
|
1995
2105
|
if (this.store.order) {
|
|
1996
|
-
|
|
2106
|
+
_context21.next = 3;
|
|
1997
2107
|
break;
|
|
1998
2108
|
}
|
|
1999
2109
|
throw new Error('order 模块未初始化');
|
|
2000
2110
|
case 3:
|
|
2001
|
-
|
|
2111
|
+
_context21.next = 5;
|
|
2002
2112
|
return this.store.order.getOrderSummary();
|
|
2003
2113
|
case 5:
|
|
2004
|
-
summary =
|
|
2005
|
-
return
|
|
2114
|
+
summary = _context21.sent;
|
|
2115
|
+
return _context21.abrupt("return", summary);
|
|
2006
2116
|
case 9:
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
throw
|
|
2117
|
+
_context21.prev = 9;
|
|
2118
|
+
_context21.t0 = _context21["catch"](0);
|
|
2119
|
+
throw _context21.t0;
|
|
2010
2120
|
case 12:
|
|
2011
2121
|
case "end":
|
|
2012
|
-
return
|
|
2122
|
+
return _context21.stop();
|
|
2013
2123
|
}
|
|
2014
|
-
},
|
|
2124
|
+
}, _callee21, this, [[0, 9]]);
|
|
2015
2125
|
}));
|
|
2016
2126
|
function getSummary() {
|
|
2017
2127
|
return _getSummary.apply(this, arguments);
|
|
@@ -2128,14 +2238,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2128
2238
|
}, {
|
|
2129
2239
|
key: "loadDiscountConfig",
|
|
2130
2240
|
value: function () {
|
|
2131
|
-
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2241
|
+
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
2132
2242
|
var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
|
|
2133
|
-
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;
|
|
2134
|
-
return _regeneratorRuntime().wrap(function
|
|
2135
|
-
while (1) switch (
|
|
2243
|
+
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, _discountModule$setOr2, _discountModule$setDi, 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;
|
|
2244
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2245
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
2136
2246
|
case 0:
|
|
2137
2247
|
if (this.store.order) {
|
|
2138
|
-
|
|
2248
|
+
_context22.next = 2;
|
|
2139
2249
|
break;
|
|
2140
2250
|
}
|
|
2141
2251
|
throw new Error('order 模块未初始化');
|
|
@@ -2155,18 +2265,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2155
2265
|
discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
|
|
2156
2266
|
preparedDiscountList = [];
|
|
2157
2267
|
if (!(customerId && customerId !== 1)) {
|
|
2158
|
-
|
|
2268
|
+
_context22.next = 25;
|
|
2159
2269
|
break;
|
|
2160
2270
|
}
|
|
2161
|
-
if (!(this.discountConfigCacheKey === discountConfigCacheKey)) {
|
|
2162
|
-
|
|
2271
|
+
if (!(!(params !== null && params !== void 0 && params.force) && this.discountConfigCacheKey === discountConfigCacheKey)) {
|
|
2272
|
+
_context22.next = 19;
|
|
2163
2273
|
break;
|
|
2164
2274
|
}
|
|
2165
2275
|
preparedDiscountList = originalDiscountList;
|
|
2166
|
-
|
|
2276
|
+
_context22.next = 25;
|
|
2167
2277
|
break;
|
|
2168
2278
|
case 19:
|
|
2169
|
-
|
|
2279
|
+
_context22.next = 21;
|
|
2170
2280
|
return this.store.order.loadDiscountConfig({
|
|
2171
2281
|
customerId: customerId,
|
|
2172
2282
|
action: discountAction,
|
|
@@ -2174,26 +2284,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2174
2284
|
apply: false
|
|
2175
2285
|
});
|
|
2176
2286
|
case 21:
|
|
2177
|
-
preparedDiscountList =
|
|
2287
|
+
preparedDiscountList = _context22.sent;
|
|
2178
2288
|
this.discountConfigCacheKey = discountConfigCacheKey;
|
|
2179
|
-
|
|
2289
|
+
_context22.next = 25;
|
|
2180
2290
|
return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
|
|
2181
2291
|
case 25:
|
|
2292
|
+
if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
2293
|
+
_context22.next = 33;
|
|
2294
|
+
break;
|
|
2295
|
+
}
|
|
2296
|
+
_context22.next = 28;
|
|
2297
|
+
return discountModule === null || discountModule === void 0 || (_discountModule$setOr2 = discountModule.setOriginalDiscountList) === null || _discountModule$setOr2 === void 0 ? void 0 : _discountModule$setOr2.call(discountModule, []);
|
|
2298
|
+
case 28:
|
|
2299
|
+
_context22.next = 30;
|
|
2300
|
+
return discountModule === null || discountModule === void 0 || (_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, []);
|
|
2301
|
+
case 30:
|
|
2302
|
+
tempOrder.discount_list = [];
|
|
2303
|
+
tempOrder.shop_discount = '0.00';
|
|
2304
|
+
return _context22.abrupt("return", {
|
|
2305
|
+
productList: tempOrder.products || [],
|
|
2306
|
+
discountList: [],
|
|
2307
|
+
availableWalletIds: this.getAvailableWalletIds(),
|
|
2308
|
+
virtualCurrencyList: this.store.order.getVirtualCurrencyList()
|
|
2309
|
+
});
|
|
2310
|
+
case 33:
|
|
2182
2311
|
if (!(hasManualDiscountSelection && currentDiscountList.length)) {
|
|
2183
|
-
|
|
2312
|
+
_context22.next = 35;
|
|
2184
2313
|
break;
|
|
2185
2314
|
}
|
|
2186
|
-
return
|
|
2315
|
+
return _context22.abrupt("return", {
|
|
2187
2316
|
productList: tempOrder.products || [],
|
|
2188
2317
|
discountList: currentDiscountList,
|
|
2189
|
-
availableWalletIds: this.getAvailableWalletIds()
|
|
2318
|
+
availableWalletIds: this.getAvailableWalletIds(),
|
|
2319
|
+
virtualCurrencyList: this.store.order.getVirtualCurrencyList()
|
|
2190
2320
|
});
|
|
2191
|
-
case
|
|
2321
|
+
case 35:
|
|
2192
2322
|
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 || []);
|
|
2193
2323
|
nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
|
|
2194
|
-
|
|
2324
|
+
_context22.next = 39;
|
|
2195
2325
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2196
|
-
case
|
|
2326
|
+
case 39:
|
|
2197
2327
|
shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
|
|
2198
2328
|
discountAction: discountAction,
|
|
2199
2329
|
products: tempOrder.products || [],
|
|
@@ -2201,32 +2331,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2201
2331
|
nextDiscountList: nextDiscountList
|
|
2202
2332
|
});
|
|
2203
2333
|
if (!shouldSkipAutoApplyFetchedDiscounts) {
|
|
2204
|
-
|
|
2334
|
+
_context22.next = 48;
|
|
2205
2335
|
break;
|
|
2206
2336
|
}
|
|
2207
|
-
|
|
2337
|
+
_context22.next = 43;
|
|
2208
2338
|
return this.store.order.recalculateSummary({
|
|
2209
2339
|
createIfMissing: true
|
|
2210
2340
|
});
|
|
2211
|
-
case
|
|
2212
|
-
_summary =
|
|
2341
|
+
case 43:
|
|
2342
|
+
_summary = _context22.sent;
|
|
2213
2343
|
this.store.order.persistTempOrder();
|
|
2214
|
-
|
|
2344
|
+
_context22.next = 47;
|
|
2215
2345
|
return this.effectsEmit('onDiscountApplied', {
|
|
2216
2346
|
productList: tempOrder.products || [],
|
|
2217
2347
|
discountList: nextDiscountList,
|
|
2218
2348
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
2219
2349
|
tempOrder: tempOrder
|
|
2220
2350
|
});
|
|
2221
|
-
case
|
|
2222
|
-
return
|
|
2351
|
+
case 47:
|
|
2352
|
+
return _context22.abrupt("return", {
|
|
2223
2353
|
productList: tempOrder.products || [],
|
|
2224
2354
|
discountList: nextDiscountList,
|
|
2225
|
-
availableWalletIds: this.getAvailableWalletIds()
|
|
2355
|
+
availableWalletIds: this.getAvailableWalletIds(),
|
|
2356
|
+
virtualCurrencyList: this.store.order.getVirtualCurrencyList()
|
|
2226
2357
|
});
|
|
2227
|
-
case
|
|
2358
|
+
case 48:
|
|
2228
2359
|
if (!rulesModule) {
|
|
2229
|
-
|
|
2360
|
+
_context22.next = 85;
|
|
2230
2361
|
break;
|
|
2231
2362
|
}
|
|
2232
2363
|
orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
|
|
@@ -2247,22 +2378,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2247
2378
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2248
2379
|
}
|
|
2249
2380
|
_iterator2 = _createForOfIteratorHelper(tempOrder.products || []);
|
|
2250
|
-
|
|
2381
|
+
_context22.prev = 54;
|
|
2251
2382
|
_iterator2.s();
|
|
2252
|
-
case
|
|
2383
|
+
case 56:
|
|
2253
2384
|
if ((_step2 = _iterator2.n()).done) {
|
|
2254
|
-
|
|
2385
|
+
_context22.next = 71;
|
|
2255
2386
|
break;
|
|
2256
2387
|
}
|
|
2257
2388
|
product = _step2.value;
|
|
2258
2389
|
productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
|
|
2259
2390
|
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;
|
|
2260
2391
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
2261
|
-
|
|
2392
|
+
_context22.next = 62;
|
|
2262
2393
|
break;
|
|
2263
2394
|
}
|
|
2264
|
-
return
|
|
2265
|
-
case
|
|
2395
|
+
return _context22.abrupt("continue", 69);
|
|
2396
|
+
case 62:
|
|
2266
2397
|
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
2267
2398
|
return sum + Number(pd.amount || 0);
|
|
2268
2399
|
}, 0);
|
|
@@ -2278,61 +2409,62 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2278
2409
|
mainPrice: newMainSellingPrice,
|
|
2279
2410
|
bundle: product.product_bundle
|
|
2280
2411
|
});
|
|
2281
|
-
case
|
|
2282
|
-
|
|
2412
|
+
case 69:
|
|
2413
|
+
_context22.next = 56;
|
|
2283
2414
|
break;
|
|
2284
|
-
case
|
|
2285
|
-
|
|
2415
|
+
case 71:
|
|
2416
|
+
_context22.next = 76;
|
|
2286
2417
|
break;
|
|
2287
|
-
case
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
_iterator2.e(
|
|
2291
|
-
case
|
|
2292
|
-
|
|
2418
|
+
case 73:
|
|
2419
|
+
_context22.prev = 73;
|
|
2420
|
+
_context22.t0 = _context22["catch"](54);
|
|
2421
|
+
_iterator2.e(_context22.t0);
|
|
2422
|
+
case 76:
|
|
2423
|
+
_context22.prev = 76;
|
|
2293
2424
|
_iterator2.f();
|
|
2294
|
-
return
|
|
2295
|
-
case
|
|
2425
|
+
return _context22.finish(76);
|
|
2426
|
+
case 79:
|
|
2296
2427
|
if (!result.discountList) {
|
|
2297
|
-
|
|
2428
|
+
_context22.next = 85;
|
|
2298
2429
|
break;
|
|
2299
2430
|
}
|
|
2300
2431
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
2301
2432
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2302
|
-
|
|
2433
|
+
_context22.next = 84;
|
|
2303
2434
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2304
|
-
case
|
|
2435
|
+
case 84:
|
|
2305
2436
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
2306
2437
|
return discount.isSelected;
|
|
2307
2438
|
});
|
|
2308
|
-
case
|
|
2309
|
-
|
|
2439
|
+
case 85:
|
|
2440
|
+
_context22.next = 87;
|
|
2310
2441
|
return this.store.order.recalculateSummary({
|
|
2311
2442
|
createIfMissing: true
|
|
2312
2443
|
});
|
|
2313
|
-
case
|
|
2314
|
-
summary =
|
|
2444
|
+
case 87:
|
|
2445
|
+
summary = _context22.sent;
|
|
2315
2446
|
this.store.order.persistTempOrder();
|
|
2316
|
-
|
|
2447
|
+
_context22.next = 91;
|
|
2317
2448
|
return this.effectsEmit('onDiscountApplied', {
|
|
2318
2449
|
productList: tempOrder.products || [],
|
|
2319
2450
|
discountList: nextDiscountList,
|
|
2320
2451
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
2321
2452
|
tempOrder: tempOrder
|
|
2322
2453
|
});
|
|
2323
|
-
case
|
|
2324
|
-
return
|
|
2454
|
+
case 91:
|
|
2455
|
+
return _context22.abrupt("return", {
|
|
2325
2456
|
productList: tempOrder.products || [],
|
|
2326
2457
|
discountList: nextDiscountList,
|
|
2327
|
-
availableWalletIds: this.getAvailableWalletIds()
|
|
2458
|
+
availableWalletIds: this.getAvailableWalletIds(),
|
|
2459
|
+
virtualCurrencyList: this.store.order.getVirtualCurrencyList()
|
|
2328
2460
|
});
|
|
2329
|
-
case
|
|
2461
|
+
case 92:
|
|
2330
2462
|
case "end":
|
|
2331
|
-
return
|
|
2463
|
+
return _context22.stop();
|
|
2332
2464
|
}
|
|
2333
|
-
},
|
|
2465
|
+
}, _callee22, this, [[54, 73, 76, 79]]);
|
|
2334
2466
|
}));
|
|
2335
|
-
function loadDiscountConfig(
|
|
2467
|
+
function loadDiscountConfig(_x16) {
|
|
2336
2468
|
return _loadDiscountConfig.apply(this, arguments);
|
|
2337
2469
|
}
|
|
2338
2470
|
return loadDiscountConfig;
|
|
@@ -2344,22 +2476,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2344
2476
|
if (!((_this$store$order4 = this.store.order) !== null && _this$store$order4 !== void 0 && _this$store$order4.getAvailableWalletIds)) return [];
|
|
2345
2477
|
return this.store.order.getAvailableWalletIds();
|
|
2346
2478
|
}
|
|
2479
|
+
}, {
|
|
2480
|
+
key: "getVirtualCurrencyList",
|
|
2481
|
+
value: function getVirtualCurrencyList() {
|
|
2482
|
+
var _this$store$order5;
|
|
2483
|
+
if (!((_this$store$order5 = this.store.order) !== null && _this$store$order5 !== void 0 && _this$store$order5.getVirtualCurrencyList)) return [];
|
|
2484
|
+
return this.store.order.getVirtualCurrencyList();
|
|
2485
|
+
}
|
|
2347
2486
|
}, {
|
|
2348
2487
|
key: "bestDiscount",
|
|
2349
2488
|
value: function () {
|
|
2350
|
-
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2489
|
+
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(cb) {
|
|
2351
2490
|
var _discountModule$getOr2, _discountModule$getDi3;
|
|
2352
|
-
var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
|
|
2353
|
-
return _regeneratorRuntime().wrap(function
|
|
2354
|
-
while (1) switch (
|
|
2491
|
+
var tempOrder, _result2, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
|
|
2492
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2493
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2355
2494
|
case 0:
|
|
2356
2495
|
if (this.store.order) {
|
|
2357
|
-
|
|
2496
|
+
_context23.next = 2;
|
|
2358
2497
|
break;
|
|
2359
2498
|
}
|
|
2360
2499
|
throw new Error('order 模块未初始化');
|
|
2361
2500
|
case 2:
|
|
2362
2501
|
tempOrder = this.store.order.ensureTempOrder();
|
|
2502
|
+
if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
2503
|
+
_context23.next = 7;
|
|
2504
|
+
break;
|
|
2505
|
+
}
|
|
2506
|
+
_result2 = {
|
|
2507
|
+
productList: tempOrder.products || [],
|
|
2508
|
+
discountList: []
|
|
2509
|
+
};
|
|
2510
|
+
cb === null || cb === void 0 || cb(_result2);
|
|
2511
|
+
return _context23.abrupt("return", _result2);
|
|
2512
|
+
case 7:
|
|
2363
2513
|
orderStore = this.store.order.store || {};
|
|
2364
2514
|
discountModule = orderStore.discount;
|
|
2365
2515
|
rulesModule = orderStore.rules;
|
|
@@ -2370,11 +2520,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2370
2520
|
productList: tempOrder.products || [],
|
|
2371
2521
|
discountList: nextDiscountList
|
|
2372
2522
|
};
|
|
2373
|
-
|
|
2523
|
+
_context23.next = 16;
|
|
2374
2524
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2375
|
-
case
|
|
2525
|
+
case 16:
|
|
2376
2526
|
if (!rulesModule) {
|
|
2377
|
-
|
|
2527
|
+
_context23.next = 28;
|
|
2378
2528
|
break;
|
|
2379
2529
|
}
|
|
2380
2530
|
orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
|
|
@@ -2392,14 +2542,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2392
2542
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2393
2543
|
}
|
|
2394
2544
|
if (!result.discountList) {
|
|
2395
|
-
|
|
2545
|
+
_context23.next = 28;
|
|
2396
2546
|
break;
|
|
2397
2547
|
}
|
|
2398
2548
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
2399
2549
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2400
|
-
|
|
2550
|
+
_context23.next = 26;
|
|
2401
2551
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2402
|
-
case
|
|
2552
|
+
case 26:
|
|
2403
2553
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
2404
2554
|
return discount.isSelected;
|
|
2405
2555
|
});
|
|
@@ -2407,30 +2557,30 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2407
2557
|
productList: tempOrder.products,
|
|
2408
2558
|
discountList: nextDiscountList
|
|
2409
2559
|
};
|
|
2410
|
-
case
|
|
2411
|
-
|
|
2560
|
+
case 28:
|
|
2561
|
+
_context23.next = 30;
|
|
2412
2562
|
return this.store.order.recalculateSummary({
|
|
2413
2563
|
createIfMissing: true
|
|
2414
2564
|
});
|
|
2415
|
-
case
|
|
2565
|
+
case 30:
|
|
2416
2566
|
this.store.order.persistTempOrder();
|
|
2417
|
-
|
|
2567
|
+
_context23.next = 33;
|
|
2418
2568
|
return this.effectsEmit('onDiscountApplied', {
|
|
2419
2569
|
productList: tempOrder.products || [],
|
|
2420
2570
|
discountList: nextDiscountList,
|
|
2421
2571
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
2422
2572
|
tempOrder: tempOrder
|
|
2423
2573
|
});
|
|
2424
|
-
case
|
|
2574
|
+
case 33:
|
|
2425
2575
|
cb === null || cb === void 0 || cb(result);
|
|
2426
|
-
return
|
|
2427
|
-
case
|
|
2576
|
+
return _context23.abrupt("return", result);
|
|
2577
|
+
case 35:
|
|
2428
2578
|
case "end":
|
|
2429
|
-
return
|
|
2579
|
+
return _context23.stop();
|
|
2430
2580
|
}
|
|
2431
|
-
},
|
|
2581
|
+
}, _callee23, this);
|
|
2432
2582
|
}));
|
|
2433
|
-
function bestDiscount(
|
|
2583
|
+
function bestDiscount(_x17) {
|
|
2434
2584
|
return _bestDiscount.apply(this, arguments);
|
|
2435
2585
|
}
|
|
2436
2586
|
return bestDiscount;
|
|
@@ -2459,41 +2609,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2459
2609
|
}, {
|
|
2460
2610
|
key: "replaceDiscountStoreLists",
|
|
2461
2611
|
value: (function () {
|
|
2462
|
-
var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2612
|
+
var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
2463
2613
|
var _store2;
|
|
2464
2614
|
var discountModule;
|
|
2465
|
-
return _regeneratorRuntime().wrap(function
|
|
2466
|
-
while (1) switch (
|
|
2615
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2616
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2467
2617
|
case 0:
|
|
2468
2618
|
if (this.store.order) {
|
|
2469
|
-
|
|
2619
|
+
_context24.next = 2;
|
|
2470
2620
|
break;
|
|
2471
2621
|
}
|
|
2472
2622
|
throw new Error('order 模块未初始化');
|
|
2473
2623
|
case 2:
|
|
2474
2624
|
discountModule = (_store2 = this.store.order.store) === null || _store2 === void 0 ? void 0 : _store2.discount;
|
|
2475
2625
|
if (discountModule) {
|
|
2476
|
-
|
|
2626
|
+
_context24.next = 5;
|
|
2477
2627
|
break;
|
|
2478
2628
|
}
|
|
2479
|
-
return
|
|
2629
|
+
return _context24.abrupt("return");
|
|
2480
2630
|
case 5:
|
|
2481
2631
|
if (!params.originalDiscountList) {
|
|
2482
|
-
|
|
2632
|
+
_context24.next = 8;
|
|
2483
2633
|
break;
|
|
2484
2634
|
}
|
|
2485
|
-
|
|
2635
|
+
_context24.next = 8;
|
|
2486
2636
|
return discountModule.setOriginalDiscountList(params.originalDiscountList);
|
|
2487
2637
|
case 8:
|
|
2488
|
-
|
|
2638
|
+
_context24.next = 10;
|
|
2489
2639
|
return discountModule.setDiscountList(params.discountList);
|
|
2490
2640
|
case 10:
|
|
2491
2641
|
case "end":
|
|
2492
|
-
return
|
|
2642
|
+
return _context24.stop();
|
|
2493
2643
|
}
|
|
2494
|
-
},
|
|
2644
|
+
}, _callee24, this);
|
|
2495
2645
|
}));
|
|
2496
|
-
function replaceDiscountStoreLists(
|
|
2646
|
+
function replaceDiscountStoreLists(_x18) {
|
|
2497
2647
|
return _replaceDiscountStoreLists.apply(this, arguments);
|
|
2498
2648
|
}
|
|
2499
2649
|
return replaceDiscountStoreLists;
|
|
@@ -2501,34 +2651,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2501
2651
|
}, {
|
|
2502
2652
|
key: "scanPromotionCode",
|
|
2503
2653
|
value: function () {
|
|
2504
|
-
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2654
|
+
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(code, customerId) {
|
|
2505
2655
|
var raw, tempOrder;
|
|
2506
|
-
return _regeneratorRuntime().wrap(function
|
|
2507
|
-
while (1) switch (
|
|
2656
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2657
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2508
2658
|
case 0:
|
|
2509
|
-
|
|
2659
|
+
_context25.prev = 0;
|
|
2510
2660
|
if (this.store.order) {
|
|
2511
|
-
|
|
2661
|
+
_context25.next = 3;
|
|
2512
2662
|
break;
|
|
2513
2663
|
}
|
|
2514
2664
|
throw new Error('order 模块未初始化');
|
|
2515
2665
|
case 3:
|
|
2516
|
-
|
|
2666
|
+
_context25.next = 5;
|
|
2517
2667
|
return this.store.order.scanCode(code, customerId);
|
|
2518
2668
|
case 5:
|
|
2519
|
-
raw =
|
|
2669
|
+
raw = _context25.sent;
|
|
2520
2670
|
if (!raw.isAvailable) {
|
|
2521
|
-
|
|
2671
|
+
_context25.next = 13;
|
|
2522
2672
|
break;
|
|
2523
2673
|
}
|
|
2524
|
-
|
|
2674
|
+
_context25.next = 9;
|
|
2525
2675
|
return this.store.order.recalculateSummary({
|
|
2526
2676
|
createIfMissing: true
|
|
2527
2677
|
});
|
|
2528
2678
|
case 9:
|
|
2529
2679
|
this.store.order.persistTempOrder();
|
|
2530
2680
|
tempOrder = this.store.order.ensureTempOrder();
|
|
2531
|
-
|
|
2681
|
+
_context25.next = 13;
|
|
2532
2682
|
return this.effectsEmit('onDiscountApplied', {
|
|
2533
2683
|
productList: tempOrder.products || [],
|
|
2534
2684
|
discountList: this.store.order.getDiscountList(),
|
|
@@ -2536,7 +2686,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2536
2686
|
tempOrder: tempOrder
|
|
2537
2687
|
});
|
|
2538
2688
|
case 13:
|
|
2539
|
-
return
|
|
2689
|
+
return _context25.abrupt("return", _objectSpread(_objectSpread({
|
|
2540
2690
|
isAvailable: raw.isAvailable
|
|
2541
2691
|
}, raw.isAccepted !== undefined ? {
|
|
2542
2692
|
isAccepted: raw.isAccepted
|
|
@@ -2546,16 +2696,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2546
2696
|
scannedDiscountList: raw.scannedDiscountList
|
|
2547
2697
|
}));
|
|
2548
2698
|
case 16:
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
throw
|
|
2699
|
+
_context25.prev = 16;
|
|
2700
|
+
_context25.t0 = _context25["catch"](0);
|
|
2701
|
+
throw _context25.t0;
|
|
2552
2702
|
case 19:
|
|
2553
2703
|
case "end":
|
|
2554
|
-
return
|
|
2704
|
+
return _context25.stop();
|
|
2555
2705
|
}
|
|
2556
|
-
},
|
|
2706
|
+
}, _callee25, this, [[0, 16]]);
|
|
2557
2707
|
}));
|
|
2558
|
-
function scanPromotionCode(
|
|
2708
|
+
function scanPromotionCode(_x19, _x20) {
|
|
2559
2709
|
return _scanPromotionCode.apply(this, arguments);
|
|
2560
2710
|
}
|
|
2561
2711
|
return scanPromotionCode;
|
|
@@ -2563,18 +2713,36 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2563
2713
|
}, {
|
|
2564
2714
|
key: "setDiscountSelected",
|
|
2565
2715
|
value: function () {
|
|
2566
|
-
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2567
|
-
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;
|
|
2568
|
-
return _regeneratorRuntime().wrap(function
|
|
2569
|
-
while (1) switch (
|
|
2716
|
+
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
2717
|
+
var currentOrder, _store3, _store3$setDiscountLi, 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;
|
|
2718
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2719
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2570
2720
|
case 0:
|
|
2571
|
-
|
|
2721
|
+
_context26.prev = 0;
|
|
2572
2722
|
if (this.store.order) {
|
|
2573
|
-
|
|
2723
|
+
_context26.next = 3;
|
|
2574
2724
|
break;
|
|
2575
2725
|
}
|
|
2576
2726
|
throw new Error('order 模块未初始化');
|
|
2577
2727
|
case 3:
|
|
2728
|
+
currentOrder = this.store.order.ensureTempOrder();
|
|
2729
|
+
if (!this.isActiveVirtualSettlementOrder(currentOrder)) {
|
|
2730
|
+
_context26.next = 13;
|
|
2731
|
+
break;
|
|
2732
|
+
}
|
|
2733
|
+
currentOrder.discount_list = [];
|
|
2734
|
+
currentOrder.shop_discount = '0.00';
|
|
2735
|
+
_context26.next = 9;
|
|
2736
|
+
return (_store3 = this.store.order.store) === null || _store3 === void 0 || (_store3 = _store3.discount) === null || _store3 === void 0 || (_store3$setDiscountLi = _store3.setDiscountList) === null || _store3$setDiscountLi === void 0 ? void 0 : _store3$setDiscountLi.call(_store3, []);
|
|
2737
|
+
case 9:
|
|
2738
|
+
_context26.next = 11;
|
|
2739
|
+
return this.store.order.recalculateSummary({
|
|
2740
|
+
createIfMissing: true
|
|
2741
|
+
});
|
|
2742
|
+
case 11:
|
|
2743
|
+
this.store.order.persistTempOrder();
|
|
2744
|
+
return _context26.abrupt("return");
|
|
2745
|
+
case 13:
|
|
2578
2746
|
list = this.store.order.getDiscountList();
|
|
2579
2747
|
updated = list.map(function (d) {
|
|
2580
2748
|
return d.id === params.discountId && !isBaseSalesHistoricalDiscountEntry(d) ? _objectSpread(_objectSpread({}, d), {}, {
|
|
@@ -2588,9 +2756,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2588
2756
|
discountModule = orderStore.discount;
|
|
2589
2757
|
rulesModule = orderStore.rules;
|
|
2590
2758
|
nextDiscountList = updated;
|
|
2591
|
-
|
|
2759
|
+
_context26.next = 23;
|
|
2592
2760
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
2593
|
-
case
|
|
2761
|
+
case 23:
|
|
2594
2762
|
if (rulesModule) {
|
|
2595
2763
|
orderTotalAmount = Number(((_orderStore$summary3 = orderStore.summary) === null || _orderStore$summary3 === void 0 ? void 0 : _orderStore$summary3.total_amount) || 0);
|
|
2596
2764
|
console.log('[BaseSales.setDiscountSelected.calcDiscount]');
|
|
@@ -2651,29 +2819,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2651
2819
|
});
|
|
2652
2820
|
};
|
|
2653
2821
|
_iterator4 = _createForOfIteratorHelper(tempOrder.products);
|
|
2654
|
-
|
|
2822
|
+
_context26.prev = 27;
|
|
2655
2823
|
_iterator4.s();
|
|
2656
|
-
case
|
|
2824
|
+
case 29:
|
|
2657
2825
|
if ((_step4 = _iterator4.n()).done) {
|
|
2658
|
-
|
|
2826
|
+
_context26.next = 46;
|
|
2659
2827
|
break;
|
|
2660
2828
|
}
|
|
2661
2829
|
product = _step4.value;
|
|
2662
2830
|
productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
|
|
2663
2831
|
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;
|
|
2664
2832
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
2665
|
-
|
|
2833
|
+
_context26.next = 35;
|
|
2666
2834
|
break;
|
|
2667
2835
|
}
|
|
2668
|
-
return
|
|
2669
|
-
case
|
|
2836
|
+
return _context26.abrupt("continue", 44);
|
|
2837
|
+
case 35:
|
|
2670
2838
|
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
2671
2839
|
if (Array.isArray(product.product_bundle)) {
|
|
2672
2840
|
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
2673
|
-
var
|
|
2841
|
+
var _ref35, _bundle$original_pric;
|
|
2674
2842
|
var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
|
|
2675
2843
|
var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
2676
|
-
var restoredBundlePrice = (
|
|
2844
|
+
var restoredBundlePrice = (_ref35 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref35 !== void 0 ? _ref35 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
2677
2845
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
|
|
2678
2846
|
price: restoredBundlePrice,
|
|
2679
2847
|
bundle_selling_price: restoredBundlePrice
|
|
@@ -2700,33 +2868,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2700
2868
|
mainPrice: newMainSellingPrice,
|
|
2701
2869
|
bundle: product.product_bundle
|
|
2702
2870
|
});
|
|
2703
|
-
case
|
|
2704
|
-
|
|
2871
|
+
case 44:
|
|
2872
|
+
_context26.next = 29;
|
|
2705
2873
|
break;
|
|
2706
|
-
case
|
|
2707
|
-
|
|
2874
|
+
case 46:
|
|
2875
|
+
_context26.next = 51;
|
|
2708
2876
|
break;
|
|
2709
|
-
case
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
_iterator4.e(
|
|
2713
|
-
case
|
|
2714
|
-
|
|
2877
|
+
case 48:
|
|
2878
|
+
_context26.prev = 48;
|
|
2879
|
+
_context26.t0 = _context26["catch"](27);
|
|
2880
|
+
_iterator4.e(_context26.t0);
|
|
2881
|
+
case 51:
|
|
2882
|
+
_context26.prev = 51;
|
|
2715
2883
|
_iterator4.f();
|
|
2716
|
-
return
|
|
2717
|
-
case
|
|
2884
|
+
return _context26.finish(51);
|
|
2885
|
+
case 54:
|
|
2718
2886
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2719
|
-
|
|
2887
|
+
_context26.next = 57;
|
|
2720
2888
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2721
|
-
case
|
|
2889
|
+
case 57:
|
|
2722
2890
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
2723
2891
|
return d.isSelected;
|
|
2724
2892
|
});
|
|
2725
|
-
|
|
2893
|
+
_context26.next = 60;
|
|
2726
2894
|
return this.store.order.recalculateSummary({
|
|
2727
2895
|
createIfMissing: true
|
|
2728
2896
|
});
|
|
2729
|
-
case
|
|
2897
|
+
case 60:
|
|
2730
2898
|
this.store.order.persistTempOrder();
|
|
2731
2899
|
this.effectsEmit('onDiscountApplied', {
|
|
2732
2900
|
productList: tempOrder.products,
|
|
@@ -2734,19 +2902,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2734
2902
|
selectedDiscountList: tempOrder.discount_list,
|
|
2735
2903
|
tempOrder: tempOrder
|
|
2736
2904
|
});
|
|
2737
|
-
|
|
2905
|
+
_context26.next = 67;
|
|
2738
2906
|
break;
|
|
2739
|
-
case
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
throw
|
|
2743
|
-
case
|
|
2907
|
+
case 64:
|
|
2908
|
+
_context26.prev = 64;
|
|
2909
|
+
_context26.t1 = _context26["catch"](0);
|
|
2910
|
+
throw _context26.t1;
|
|
2911
|
+
case 67:
|
|
2744
2912
|
case "end":
|
|
2745
|
-
return
|
|
2913
|
+
return _context26.stop();
|
|
2746
2914
|
}
|
|
2747
|
-
},
|
|
2915
|
+
}, _callee26, this, [[0, 64], [27, 48, 51, 54]]);
|
|
2748
2916
|
}));
|
|
2749
|
-
function setDiscountSelected(
|
|
2917
|
+
function setDiscountSelected(_x21) {
|
|
2750
2918
|
return _setDiscountSelected.apply(this, arguments);
|
|
2751
2919
|
}
|
|
2752
2920
|
return setDiscountSelected;
|
|
@@ -2754,23 +2922,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2754
2922
|
}, {
|
|
2755
2923
|
key: "applyDiscountCalculationResult",
|
|
2756
2924
|
value: function () {
|
|
2757
|
-
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2925
|
+
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(result) {
|
|
2758
2926
|
var tempOrder, orderStore, discountModule;
|
|
2759
|
-
return _regeneratorRuntime().wrap(function
|
|
2760
|
-
while (1) switch (
|
|
2927
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2928
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2761
2929
|
case 0:
|
|
2762
|
-
|
|
2930
|
+
_context27.prev = 0;
|
|
2763
2931
|
if (this.store.order) {
|
|
2764
|
-
|
|
2932
|
+
_context27.next = 3;
|
|
2765
2933
|
break;
|
|
2766
2934
|
}
|
|
2767
2935
|
throw new Error('order 模块未初始化');
|
|
2768
2936
|
case 3:
|
|
2769
2937
|
if (result) {
|
|
2770
|
-
|
|
2938
|
+
_context27.next = 5;
|
|
2771
2939
|
break;
|
|
2772
2940
|
}
|
|
2773
|
-
return
|
|
2941
|
+
return _context27.abrupt("return");
|
|
2774
2942
|
case 5:
|
|
2775
2943
|
tempOrder = this.store.order.ensureTempOrder();
|
|
2776
2944
|
orderStore = this.store.order.store || {};
|
|
@@ -2779,24 +2947,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2779
2947
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2780
2948
|
}
|
|
2781
2949
|
if (!result.discountList) {
|
|
2782
|
-
|
|
2950
|
+
_context27.next = 14;
|
|
2783
2951
|
break;
|
|
2784
2952
|
}
|
|
2785
2953
|
OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
|
|
2786
|
-
|
|
2954
|
+
_context27.next = 13;
|
|
2787
2955
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
|
|
2788
2956
|
case 13:
|
|
2789
2957
|
tempOrder.discount_list = result.discountList.filter(function (discount) {
|
|
2790
2958
|
return discount.isSelected;
|
|
2791
2959
|
});
|
|
2792
2960
|
case 14:
|
|
2793
|
-
|
|
2961
|
+
_context27.next = 16;
|
|
2794
2962
|
return this.store.order.recalculateSummary({
|
|
2795
2963
|
createIfMissing: true
|
|
2796
2964
|
});
|
|
2797
2965
|
case 16:
|
|
2798
2966
|
this.store.order.persistTempOrder();
|
|
2799
|
-
|
|
2967
|
+
_context27.next = 19;
|
|
2800
2968
|
return this.effectsEmit('onDiscountApplied', {
|
|
2801
2969
|
productList: tempOrder.products || [],
|
|
2802
2970
|
discountList: result.discountList || [],
|
|
@@ -2804,19 +2972,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2804
2972
|
tempOrder: tempOrder
|
|
2805
2973
|
});
|
|
2806
2974
|
case 19:
|
|
2807
|
-
|
|
2975
|
+
_context27.next = 24;
|
|
2808
2976
|
break;
|
|
2809
2977
|
case 21:
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
throw
|
|
2978
|
+
_context27.prev = 21;
|
|
2979
|
+
_context27.t0 = _context27["catch"](0);
|
|
2980
|
+
throw _context27.t0;
|
|
2813
2981
|
case 24:
|
|
2814
2982
|
case "end":
|
|
2815
|
-
return
|
|
2983
|
+
return _context27.stop();
|
|
2816
2984
|
}
|
|
2817
|
-
},
|
|
2985
|
+
}, _callee27, this, [[0, 21]]);
|
|
2818
2986
|
}));
|
|
2819
|
-
function applyDiscountCalculationResult(
|
|
2987
|
+
function applyDiscountCalculationResult(_x22) {
|
|
2820
2988
|
return _applyDiscountCalculationResult.apply(this, arguments);
|
|
2821
2989
|
}
|
|
2822
2990
|
return applyDiscountCalculationResult;
|
|
@@ -2824,22 +2992,155 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2824
2992
|
}, {
|
|
2825
2993
|
key: "submitScanOrder",
|
|
2826
2994
|
value: function () {
|
|
2827
|
-
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2828
|
-
return _regeneratorRuntime().wrap(function
|
|
2829
|
-
while (1) switch (
|
|
2995
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
2996
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2997
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2830
2998
|
case 0:
|
|
2831
|
-
return
|
|
2999
|
+
return _context28.abrupt("return", this.submitSalesOrder(params));
|
|
2832
3000
|
case 1:
|
|
2833
3001
|
case "end":
|
|
2834
|
-
return
|
|
3002
|
+
return _context28.stop();
|
|
2835
3003
|
}
|
|
2836
|
-
},
|
|
3004
|
+
}, _callee28, this);
|
|
2837
3005
|
}));
|
|
2838
|
-
function submitScanOrder(
|
|
3006
|
+
function submitScanOrder(_x23) {
|
|
2839
3007
|
return _submitScanOrder.apply(this, arguments);
|
|
2840
3008
|
}
|
|
2841
3009
|
return submitScanOrder;
|
|
2842
3010
|
}()
|
|
3011
|
+
}, {
|
|
3012
|
+
key: "buildVirtualSettlementSubmitData",
|
|
3013
|
+
value: function () {
|
|
3014
|
+
var _buildVirtualSettlementSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
3015
|
+
var _tempOrder$metadata$c, _tempOrder$metadata2, _paymentMethod$custom;
|
|
3016
|
+
var tempOrder, snapshot, currencyProductId, summary, amount, customerId, asset, currencyCode, currencySymbol, currencyFormat, balance, paymentMethods, paymentMethod, amountText, payment;
|
|
3017
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
3018
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
3019
|
+
case 0:
|
|
3020
|
+
if (this.store.order) {
|
|
3021
|
+
_context29.next = 2;
|
|
3022
|
+
break;
|
|
3023
|
+
}
|
|
3024
|
+
return _context29.abrupt("return", null);
|
|
3025
|
+
case 2:
|
|
3026
|
+
tempOrder = this.store.order.getTempOrder();
|
|
3027
|
+
if (this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
3028
|
+
_context29.next = 5;
|
|
3029
|
+
break;
|
|
3030
|
+
}
|
|
3031
|
+
return _context29.abrupt("return", null);
|
|
3032
|
+
case 5:
|
|
3033
|
+
snapshot = getTempOrderSettlementSnapshot(tempOrder);
|
|
3034
|
+
currencyProductId = Number((_tempOrder$metadata$c = tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.currency_settlement_config) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.settlement_ids) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2[0]) !== null && _tempOrder$metadata$c !== void 0 ? _tempOrder$metadata$c : snapshot === null || snapshot === void 0 ? void 0 : snapshot.currency_product_id);
|
|
3035
|
+
if (!(!snapshot || !Number.isFinite(currencyProductId) || currencyProductId <= 0)) {
|
|
3036
|
+
_context29.next = 9;
|
|
3037
|
+
break;
|
|
3038
|
+
}
|
|
3039
|
+
throw new Error('Virtual currency settlement configuration is invalid.');
|
|
3040
|
+
case 9:
|
|
3041
|
+
_context29.next = 11;
|
|
3042
|
+
return this.store.order.recalculateSummary({
|
|
3043
|
+
createIfMissing: true
|
|
3044
|
+
});
|
|
3045
|
+
case 11:
|
|
3046
|
+
summary = _context29.sent;
|
|
3047
|
+
amount = new Decimal((summary === null || summary === void 0 ? void 0 : summary.total_amount) || 0).toDecimalPlaces(2);
|
|
3048
|
+
customerId = Number((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id) || 0);
|
|
3049
|
+
if (!(amount.gt(0) && customerId > 0 && customerId !== 1)) {
|
|
3050
|
+
_context29.next = 17;
|
|
3051
|
+
break;
|
|
3052
|
+
}
|
|
3053
|
+
_context29.next = 17;
|
|
3054
|
+
return this.store.order.loadDiscountConfig({
|
|
3055
|
+
customerId: customerId,
|
|
3056
|
+
action: tempOrder !== null && tempOrder !== void 0 && tempOrder.order_id ? 'edit' : 'create',
|
|
3057
|
+
orderId: Number(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) || undefined,
|
|
3058
|
+
apply: false
|
|
3059
|
+
});
|
|
3060
|
+
case 17:
|
|
3061
|
+
asset = this.store.order.getVirtualCurrencyList().find(function (item) {
|
|
3062
|
+
return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
|
|
3063
|
+
});
|
|
3064
|
+
currencyCode = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_code) || '');
|
|
3065
|
+
currencySymbol = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_symbol) || '');
|
|
3066
|
+
currencyFormat = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_format) || 'symbol_first');
|
|
3067
|
+
if (!amount.lte(0)) {
|
|
3068
|
+
_context29.next = 23;
|
|
3069
|
+
break;
|
|
3070
|
+
}
|
|
3071
|
+
return _context29.abrupt("return", {
|
|
3072
|
+
payments: [],
|
|
3073
|
+
snapshot: snapshot,
|
|
3074
|
+
currencyProductId: currencyProductId,
|
|
3075
|
+
currencyCode: currencyCode,
|
|
3076
|
+
currencySymbol: currencySymbol,
|
|
3077
|
+
currencyFormat: currencyFormat
|
|
3078
|
+
});
|
|
3079
|
+
case 23:
|
|
3080
|
+
if (asset) {
|
|
3081
|
+
_context29.next = 25;
|
|
3082
|
+
break;
|
|
3083
|
+
}
|
|
3084
|
+
throw new Error('No matching virtual currency card is available.');
|
|
3085
|
+
case 25:
|
|
3086
|
+
balance = new Decimal(asset.balance || 0);
|
|
3087
|
+
if (!balance.lt(amount)) {
|
|
3088
|
+
_context29.next = 28;
|
|
3089
|
+
break;
|
|
3090
|
+
}
|
|
3091
|
+
throw new Error('Insufficient virtual currency balance.');
|
|
3092
|
+
case 28:
|
|
3093
|
+
_context29.next = 30;
|
|
3094
|
+
return this.getPaymentMethodsAsync();
|
|
3095
|
+
case 30:
|
|
3096
|
+
paymentMethods = _context29.sent;
|
|
3097
|
+
paymentMethod = paymentMethods.find(function (method) {
|
|
3098
|
+
return String(method.code || '').toUpperCase() === 'PRODUCTVOUCHER';
|
|
3099
|
+
});
|
|
3100
|
+
if (paymentMethod) {
|
|
3101
|
+
_context29.next = 34;
|
|
3102
|
+
break;
|
|
3103
|
+
}
|
|
3104
|
+
throw new Error('PRODUCTVOUCHER payment method is unavailable.');
|
|
3105
|
+
case 34:
|
|
3106
|
+
amountText = amount.toFixed(2);
|
|
3107
|
+
payment = {
|
|
3108
|
+
payment_number: "LOCAL_".concat(createUuidV4()),
|
|
3109
|
+
amount: amountText,
|
|
3110
|
+
origin_amount: amountText,
|
|
3111
|
+
code: paymentMethod.code,
|
|
3112
|
+
custom_payment_id: paymentMethod.id,
|
|
3113
|
+
custom_payment_type: (_paymentMethod$custom = paymentMethod.custom_payment_type) !== null && _paymentMethod$custom !== void 0 ? _paymentMethod$custom : paymentMethod.type,
|
|
3114
|
+
name: paymentMethod.name,
|
|
3115
|
+
type: 'normal',
|
|
3116
|
+
voucher_id: asset.id,
|
|
3117
|
+
order_payment_type: 'normal',
|
|
3118
|
+
wallet_pass_usage_unit: {
|
|
3119
|
+
price: 1,
|
|
3120
|
+
points: 1
|
|
3121
|
+
},
|
|
3122
|
+
wallet_pass_use_value: amountText,
|
|
3123
|
+
metadata: {}
|
|
3124
|
+
};
|
|
3125
|
+
return _context29.abrupt("return", {
|
|
3126
|
+
payments: [payment],
|
|
3127
|
+
snapshot: snapshot,
|
|
3128
|
+
currencyProductId: currencyProductId,
|
|
3129
|
+
currencyCode: currencyCode,
|
|
3130
|
+
currencySymbol: currencySymbol,
|
|
3131
|
+
currencyFormat: currencyFormat
|
|
3132
|
+
});
|
|
3133
|
+
case 37:
|
|
3134
|
+
case "end":
|
|
3135
|
+
return _context29.stop();
|
|
3136
|
+
}
|
|
3137
|
+
}, _callee29, this);
|
|
3138
|
+
}));
|
|
3139
|
+
function buildVirtualSettlementSubmitData() {
|
|
3140
|
+
return _buildVirtualSettlementSubmitData.apply(this, arguments);
|
|
3141
|
+
}
|
|
3142
|
+
return buildVirtualSettlementSubmitData;
|
|
3143
|
+
}()
|
|
2843
3144
|
/**
|
|
2844
3145
|
* 提交当前 Sales 订单。
|
|
2845
3146
|
*
|
|
@@ -2849,47 +3150,70 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2849
3150
|
}, {
|
|
2850
3151
|
key: "submitSalesOrder",
|
|
2851
3152
|
value: (function () {
|
|
2852
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2853
|
-
var _params$smallTicketDa, _this$
|
|
2854
|
-
var inferredPaymentStatus, smallTicketDataFlag, submitParams;
|
|
2855
|
-
return _regeneratorRuntime().wrap(function
|
|
2856
|
-
while (1) switch (
|
|
3153
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
3154
|
+
var _params$smallTicketDa, _this$otherParams12, _this$otherParams13, _this$otherParams14, _this$otherParams15;
|
|
3155
|
+
var virtualSettlement, inferredPaymentStatus, smallTicketDataFlag, submitParams;
|
|
3156
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
3157
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2857
3158
|
case 0:
|
|
2858
3159
|
if (this.store.order) {
|
|
2859
|
-
|
|
3160
|
+
_context30.next = 2;
|
|
2860
3161
|
break;
|
|
2861
3162
|
}
|
|
2862
3163
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
2863
3164
|
case 2:
|
|
3165
|
+
_context30.next = 4;
|
|
3166
|
+
return this.buildVirtualSettlementSubmitData();
|
|
3167
|
+
case 4:
|
|
3168
|
+
virtualSettlement = _context30.sent;
|
|
2864
3169
|
// this.store.order.persistTempOrder();
|
|
2865
3170
|
inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
|
|
2866
3171
|
smallTicketDataFlag = (_params$smallTicketDa = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa !== void 0 ? _params$smallTicketDa : this.getDefaultCheckoutSmallTicketDataFlag();
|
|
2867
3172
|
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
2868
3173
|
cacheId: this.cacheId,
|
|
2869
|
-
platform: (_this$
|
|
2870
|
-
businessCode: ((_this$
|
|
3174
|
+
platform: (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform,
|
|
3175
|
+
businessCode: ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) || ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code),
|
|
2871
3176
|
channel: this.getSubmitOrderSalesChannel(),
|
|
2872
|
-
type: (_this$
|
|
3177
|
+
type: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.type,
|
|
2873
3178
|
request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
|
|
2874
|
-
},
|
|
3179
|
+
}, virtualSettlement ? {
|
|
3180
|
+
payments: virtualSettlement.payments
|
|
3181
|
+
} : (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
|
|
2875
3182
|
payments: params.payments
|
|
2876
3183
|
} : {}), inferredPaymentStatus !== undefined ? {
|
|
2877
3184
|
paymentStatus: inferredPaymentStatus
|
|
2878
3185
|
} : {}), smallTicketDataFlag !== undefined ? {
|
|
2879
3186
|
smallTicketDataFlag: smallTicketDataFlag
|
|
2880
|
-
} : {}),
|
|
3187
|
+
} : {}), virtualSettlement ? {
|
|
3188
|
+
confirmPendingVoucherPayments: false
|
|
3189
|
+
} : (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
|
|
2881
3190
|
confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
|
|
2882
|
-
} : {}),
|
|
3191
|
+
} : {}), virtualSettlement ? {
|
|
3192
|
+
enhancePayload: function enhancePayload(payload, ctx) {
|
|
3193
|
+
var callerPayload = params !== null && params !== void 0 && params.enhancePayload ? params.enhancePayload(payload, ctx) : payload;
|
|
3194
|
+
return _objectSpread(_objectSpread({}, callerPayload), {}, {
|
|
3195
|
+
metadata: _objectSpread(_objectSpread({}, callerPayload.metadata || {}), {}, {
|
|
3196
|
+
currency_settlement_config: {
|
|
3197
|
+
settlement_type: 'virtual_currency',
|
|
3198
|
+
settlement_ids: [virtualSettlement.currencyProductId]
|
|
3199
|
+
}
|
|
3200
|
+
}),
|
|
3201
|
+
currency_code: virtualSettlement.currencyCode,
|
|
3202
|
+
currency_symbol: virtualSettlement.currencySymbol,
|
|
3203
|
+
currency_format: virtualSettlement.currencyFormat
|
|
3204
|
+
});
|
|
3205
|
+
}
|
|
3206
|
+
} : (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2883
3207
|
enhancePayload: params.enhancePayload
|
|
2884
3208
|
} : {});
|
|
2885
|
-
return
|
|
2886
|
-
case
|
|
3209
|
+
return _context30.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
|
|
3210
|
+
case 9:
|
|
2887
3211
|
case "end":
|
|
2888
|
-
return
|
|
3212
|
+
return _context30.stop();
|
|
2889
3213
|
}
|
|
2890
|
-
},
|
|
3214
|
+
}, _callee30, this);
|
|
2891
3215
|
}));
|
|
2892
|
-
function submitSalesOrder(
|
|
3216
|
+
function submitSalesOrder(_x24) {
|
|
2893
3217
|
return _submitSalesOrder.apply(this, arguments);
|
|
2894
3218
|
}
|
|
2895
3219
|
return submitSalesOrder;
|
|
@@ -2897,33 +3221,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2897
3221
|
}, {
|
|
2898
3222
|
key: "saveSalesOrderDraft",
|
|
2899
3223
|
value: function () {
|
|
2900
|
-
var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2901
|
-
var _params$platform, _this$
|
|
2902
|
-
return _regeneratorRuntime().wrap(function
|
|
2903
|
-
while (1) switch (
|
|
3224
|
+
var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
3225
|
+
var _params$platform, _this$otherParams16, _this$otherParams17, _this$otherParams18, _params$channel, _params$type, _this$otherParams19;
|
|
3226
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
3227
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2904
3228
|
case 0:
|
|
2905
3229
|
if (this.store.order) {
|
|
2906
|
-
|
|
3230
|
+
_context31.next = 2;
|
|
2907
3231
|
break;
|
|
2908
3232
|
}
|
|
2909
3233
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
2910
3234
|
case 2:
|
|
2911
|
-
return
|
|
3235
|
+
return _context31.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
|
|
2912
3236
|
cacheId: this.cacheId,
|
|
2913
|
-
platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$
|
|
2914
|
-
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$
|
|
3237
|
+
platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.platform,
|
|
3238
|
+
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.businessCode) || ((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.business_code),
|
|
2915
3239
|
channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
|
|
2916
|
-
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$
|
|
3240
|
+
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.type
|
|
2917
3241
|
}, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2918
3242
|
enhancePayload: params.enhancePayload
|
|
2919
3243
|
} : {})));
|
|
2920
3244
|
case 3:
|
|
2921
3245
|
case "end":
|
|
2922
|
-
return
|
|
3246
|
+
return _context31.stop();
|
|
2923
3247
|
}
|
|
2924
|
-
},
|
|
3248
|
+
}, _callee31, this);
|
|
2925
3249
|
}));
|
|
2926
|
-
function saveSalesOrderDraft(
|
|
3250
|
+
function saveSalesOrderDraft(_x25) {
|
|
2927
3251
|
return _saveSalesOrderDraft.apply(this, arguments);
|
|
2928
3252
|
}
|
|
2929
3253
|
return saveSalesOrderDraft;
|
|
@@ -2931,14 +3255,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2931
3255
|
}, {
|
|
2932
3256
|
key: "submitTempOrderAsync",
|
|
2933
3257
|
value: function () {
|
|
2934
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2935
|
-
var _params$smallTicketDa2, _this$
|
|
3258
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
3259
|
+
var _params$smallTicketDa2, _this$otherParams20, _this$otherParams21, _this$otherParams22, _this$otherParams23;
|
|
2936
3260
|
var inferredPaymentStatus, smallTicketDataFlag, submitParams;
|
|
2937
|
-
return _regeneratorRuntime().wrap(function
|
|
2938
|
-
while (1) switch (
|
|
3261
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3262
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2939
3263
|
case 0:
|
|
2940
3264
|
if (this.store.order) {
|
|
2941
|
-
|
|
3265
|
+
_context32.next = 2;
|
|
2942
3266
|
break;
|
|
2943
3267
|
}
|
|
2944
3268
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -2947,10 +3271,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2947
3271
|
smallTicketDataFlag = (_params$smallTicketDa2 = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa2 !== void 0 ? _params$smallTicketDa2 : this.getDefaultCheckoutSmallTicketDataFlag();
|
|
2948
3272
|
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
2949
3273
|
cacheId: this.cacheId,
|
|
2950
|
-
platform: (_this$
|
|
2951
|
-
businessCode: ((_this$
|
|
3274
|
+
platform: (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.platform,
|
|
3275
|
+
businessCode: ((_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.businessCode) || ((_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.business_code),
|
|
2952
3276
|
channel: this.getSubmitOrderSalesChannel(),
|
|
2953
|
-
type: (_this$
|
|
3277
|
+
type: (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.type,
|
|
2954
3278
|
request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
|
|
2955
3279
|
}, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
|
|
2956
3280
|
payments: params.payments
|
|
@@ -2963,14 +3287,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2963
3287
|
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2964
3288
|
enhancePayload: params.enhancePayload
|
|
2965
3289
|
} : {});
|
|
2966
|
-
return
|
|
3290
|
+
return _context32.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
|
|
2967
3291
|
case 6:
|
|
2968
3292
|
case "end":
|
|
2969
|
-
return
|
|
3293
|
+
return _context32.stop();
|
|
2970
3294
|
}
|
|
2971
|
-
},
|
|
3295
|
+
}, _callee32, this);
|
|
2972
3296
|
}));
|
|
2973
|
-
function submitTempOrderAsync(
|
|
3297
|
+
function submitTempOrderAsync(_x26) {
|
|
2974
3298
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
2975
3299
|
}
|
|
2976
3300
|
return submitTempOrderAsync;
|
|
@@ -2982,8 +3306,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2982
3306
|
}, {
|
|
2983
3307
|
key: "shouldUseCheckoutSyncTask",
|
|
2984
3308
|
value: function shouldUseCheckoutSyncTask() {
|
|
2985
|
-
var _this$
|
|
2986
|
-
var configured = (_this$
|
|
3309
|
+
var _this$otherParams24;
|
|
3310
|
+
var configured = (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.checkoutSyncTaskEnabled;
|
|
2987
3311
|
return typeof configured === 'boolean' ? configured : true;
|
|
2988
3312
|
}
|
|
2989
3313
|
|
|
@@ -2996,14 +3320,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2996
3320
|
}, {
|
|
2997
3321
|
key: "printLocalOrderReceipt",
|
|
2998
3322
|
value: function () {
|
|
2999
|
-
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3000
|
-
var _this$
|
|
3001
|
-
var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$
|
|
3002
|
-
return _regeneratorRuntime().wrap(function
|
|
3003
|
-
while (1) switch (
|
|
3323
|
+
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(lookup) {
|
|
3324
|
+
var _this$otherParams25, _this$otherParams26, _this$otherParams27, _this$otherParams28;
|
|
3325
|
+
var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order6, _data;
|
|
3326
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3327
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
3004
3328
|
case 0:
|
|
3005
3329
|
if (this.store.order) {
|
|
3006
|
-
|
|
3330
|
+
_context33.next = 2;
|
|
3007
3331
|
break;
|
|
3008
3332
|
}
|
|
3009
3333
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -3015,10 +3339,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3015
3339
|
external_sale_number: lookup
|
|
3016
3340
|
};
|
|
3017
3341
|
context = {
|
|
3018
|
-
platform: (_this$
|
|
3019
|
-
businessCode: ((_this$
|
|
3342
|
+
platform: (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.platform,
|
|
3343
|
+
businessCode: ((_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.businessCode) || ((_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.business_code),
|
|
3020
3344
|
channel: this.getSubmitOrderSalesChannel(),
|
|
3021
|
-
type: (_this$
|
|
3345
|
+
type: (_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.type
|
|
3022
3346
|
};
|
|
3023
3347
|
payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
|
|
3024
3348
|
lookup_order_from_db: 1,
|
|
@@ -3034,28 +3358,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3034
3358
|
channel: context.channel,
|
|
3035
3359
|
type: context.type
|
|
3036
3360
|
});
|
|
3037
|
-
|
|
3361
|
+
_context33.next = 8;
|
|
3038
3362
|
return this.request.post('/local/print-order', payload, {
|
|
3039
3363
|
osServer: true,
|
|
3040
3364
|
customToast: function customToast() {}
|
|
3041
3365
|
});
|
|
3042
3366
|
case 8:
|
|
3043
|
-
response =
|
|
3367
|
+
response = _context33.sent;
|
|
3044
3368
|
if (hasLookup) {
|
|
3045
|
-
|
|
3369
|
+
_context33.next = 12;
|
|
3046
3370
|
break;
|
|
3047
3371
|
}
|
|
3048
|
-
|
|
3049
|
-
return (_this$store$order$app = (_this$store$
|
|
3372
|
+
_context33.next = 12;
|
|
3373
|
+
return (_this$store$order$app = (_this$store$order6 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order6, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
|
|
3050
3374
|
case 12:
|
|
3051
|
-
return
|
|
3375
|
+
return _context33.abrupt("return", response);
|
|
3052
3376
|
case 13:
|
|
3053
3377
|
case "end":
|
|
3054
|
-
return
|
|
3378
|
+
return _context33.stop();
|
|
3055
3379
|
}
|
|
3056
|
-
},
|
|
3380
|
+
}, _callee33, this);
|
|
3057
3381
|
}));
|
|
3058
|
-
function printLocalOrderReceipt(
|
|
3382
|
+
function printLocalOrderReceipt(_x27) {
|
|
3059
3383
|
return _printLocalOrderReceipt.apply(this, arguments);
|
|
3060
3384
|
}
|
|
3061
3385
|
return printLocalOrderReceipt;
|
|
@@ -3063,9 +3387,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3063
3387
|
}, {
|
|
3064
3388
|
key: "getSubmitPaymentStatus",
|
|
3065
3389
|
value: function getSubmitPaymentStatus(paymentStatus) {
|
|
3066
|
-
var _this$store$
|
|
3390
|
+
var _this$store$order7, _this$store$order7$ge;
|
|
3067
3391
|
if (paymentStatus !== undefined) return paymentStatus;
|
|
3068
|
-
var amountSnapshot = (_this$store$
|
|
3392
|
+
var amountSnapshot = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 || (_this$store$order7$ge = _this$store$order7.getOrderAmountSnapshot) === null || _this$store$order7$ge === void 0 ? void 0 : _this$store$order7$ge.call(_this$store$order7);
|
|
3069
3393
|
if (!amountSnapshot) return undefined;
|
|
3070
3394
|
try {
|
|
3071
3395
|
return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
|
|
@@ -3076,19 +3400,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3076
3400
|
}, {
|
|
3077
3401
|
key: "syncPaymentsToOrder",
|
|
3078
3402
|
value: function () {
|
|
3079
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3080
|
-
var
|
|
3403
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
3404
|
+
var _ref36, _params$businessCode, _this$otherParams29, _this$otherParams30, _params$channel2;
|
|
3081
3405
|
var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
|
|
3082
|
-
return _regeneratorRuntime().wrap(function
|
|
3083
|
-
while (1) switch (
|
|
3406
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3407
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3084
3408
|
case 0:
|
|
3085
3409
|
if (this.store.order) {
|
|
3086
|
-
|
|
3410
|
+
_context34.next = 2;
|
|
3087
3411
|
break;
|
|
3088
3412
|
}
|
|
3089
3413
|
throw new Error('order 模块未初始化');
|
|
3090
3414
|
case 2:
|
|
3091
|
-
businessCode = (
|
|
3415
|
+
businessCode = (_ref36 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.businessCode) !== null && _ref36 !== void 0 ? _ref36 : (_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.business_code;
|
|
3092
3416
|
channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
|
|
3093
3417
|
syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), {}, {
|
|
3094
3418
|
checkoutSyncTaskEnabled: this.shouldUseCheckoutSyncTask()
|
|
@@ -3099,14 +3423,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3099
3423
|
} : {});
|
|
3100
3424
|
syncState = this.store.order.getOrderSyncState();
|
|
3101
3425
|
if (!(params.submitWhenPaid && syncState === 'submitting')) {
|
|
3102
|
-
|
|
3426
|
+
_context34.next = 9;
|
|
3103
3427
|
break;
|
|
3104
3428
|
}
|
|
3105
3429
|
this.queueLatestAutoPaymentSync();
|
|
3106
|
-
return
|
|
3430
|
+
return _context34.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
|
|
3107
3431
|
case 9:
|
|
3108
3432
|
payments = params.payments || [];
|
|
3109
|
-
|
|
3433
|
+
_context34.next = 12;
|
|
3110
3434
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
|
|
3111
3435
|
payments: payments,
|
|
3112
3436
|
params: syncParams,
|
|
@@ -3114,11 +3438,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3114
3438
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
3115
3439
|
});
|
|
3116
3440
|
case 12:
|
|
3117
|
-
|
|
3118
|
-
|
|
3441
|
+
_context34.prev = 12;
|
|
3442
|
+
_context34.next = 15;
|
|
3119
3443
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
3120
3444
|
case 15:
|
|
3121
|
-
syncResult =
|
|
3445
|
+
syncResult = _context34.sent;
|
|
3122
3446
|
latestPayments = this.store.order.getOrderPayments();
|
|
3123
3447
|
amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
3124
3448
|
orderSnapshot = this.store.order.getOrderSnapshot();
|
|
@@ -3136,25 +3460,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3136
3460
|
depositAmount: syncResult.depositAmount,
|
|
3137
3461
|
orderExpectedAmount: syncResult.orderExpectedAmount
|
|
3138
3462
|
};
|
|
3139
|
-
|
|
3463
|
+
_context34.next = 22;
|
|
3140
3464
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
|
|
3141
3465
|
case 22:
|
|
3142
3466
|
if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
|
|
3143
|
-
|
|
3467
|
+
_context34.next = 25;
|
|
3144
3468
|
break;
|
|
3145
3469
|
}
|
|
3146
|
-
|
|
3470
|
+
_context34.next = 25;
|
|
3147
3471
|
return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
3148
3472
|
case 25:
|
|
3149
3473
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3150
|
-
return
|
|
3474
|
+
return _context34.abrupt("return", syncResult);
|
|
3151
3475
|
case 29:
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3476
|
+
_context34.prev = 29;
|
|
3477
|
+
_context34.t0 = _context34["catch"](12);
|
|
3478
|
+
_context34.next = 33;
|
|
3155
3479
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
3156
3480
|
ok: false,
|
|
3157
|
-
error:
|
|
3481
|
+
error: _context34.t0,
|
|
3158
3482
|
payments: this.store.order.getOrderPayments(),
|
|
3159
3483
|
params: syncParams,
|
|
3160
3484
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
@@ -3162,14 +3486,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3162
3486
|
});
|
|
3163
3487
|
case 33:
|
|
3164
3488
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3165
|
-
throw
|
|
3489
|
+
throw _context34.t0;
|
|
3166
3490
|
case 35:
|
|
3167
3491
|
case "end":
|
|
3168
|
-
return
|
|
3492
|
+
return _context34.stop();
|
|
3169
3493
|
}
|
|
3170
|
-
},
|
|
3494
|
+
}, _callee34, this, [[12, 29]]);
|
|
3171
3495
|
}));
|
|
3172
|
-
function syncPaymentsToOrder(
|
|
3496
|
+
function syncPaymentsToOrder(_x28) {
|
|
3173
3497
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
3174
3498
|
}
|
|
3175
3499
|
return syncPaymentsToOrder;
|
|
@@ -3218,46 +3542,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3218
3542
|
}, {
|
|
3219
3543
|
key: "flushQueuedAutoPaymentSync",
|
|
3220
3544
|
value: function () {
|
|
3221
|
-
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3545
|
+
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
|
|
3222
3546
|
var payments;
|
|
3223
|
-
return _regeneratorRuntime().wrap(function
|
|
3224
|
-
while (1) switch (
|
|
3547
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3548
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3225
3549
|
case 0:
|
|
3226
3550
|
if (this.store.order) {
|
|
3227
|
-
|
|
3551
|
+
_context35.next = 2;
|
|
3228
3552
|
break;
|
|
3229
3553
|
}
|
|
3230
|
-
return
|
|
3554
|
+
return _context35.abrupt("return");
|
|
3231
3555
|
case 2:
|
|
3232
3556
|
if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
|
|
3233
|
-
|
|
3557
|
+
_context35.next = 4;
|
|
3234
3558
|
break;
|
|
3235
3559
|
}
|
|
3236
|
-
return
|
|
3560
|
+
return _context35.abrupt("return");
|
|
3237
3561
|
case 4:
|
|
3238
3562
|
if (!(this.store.order.getOrderSyncState() === 'submitting')) {
|
|
3239
|
-
|
|
3563
|
+
_context35.next = 7;
|
|
3240
3564
|
break;
|
|
3241
3565
|
}
|
|
3242
3566
|
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
3243
|
-
return
|
|
3567
|
+
return _context35.abrupt("return");
|
|
3244
3568
|
case 7:
|
|
3245
3569
|
this.autoPaymentSyncFlushing = true;
|
|
3246
|
-
|
|
3570
|
+
_context35.prev = 8;
|
|
3247
3571
|
case 9:
|
|
3248
3572
|
if (!this.queuedAutoPaymentSync) {
|
|
3249
|
-
|
|
3573
|
+
_context35.next = 18;
|
|
3250
3574
|
break;
|
|
3251
3575
|
}
|
|
3252
3576
|
this.queuedAutoPaymentSync = false;
|
|
3253
3577
|
payments = this.store.order.getOrderPayments();
|
|
3254
3578
|
if (payments.length) {
|
|
3255
|
-
|
|
3579
|
+
_context35.next = 14;
|
|
3256
3580
|
break;
|
|
3257
3581
|
}
|
|
3258
|
-
return
|
|
3582
|
+
return _context35.abrupt("continue", 9);
|
|
3259
3583
|
case 14:
|
|
3260
|
-
|
|
3584
|
+
_context35.next = 16;
|
|
3261
3585
|
return this.syncPaymentsToOrder({
|
|
3262
3586
|
payments: payments,
|
|
3263
3587
|
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
@@ -3265,29 +3589,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3265
3589
|
smallTicketDataFlag: 1
|
|
3266
3590
|
});
|
|
3267
3591
|
case 16:
|
|
3268
|
-
|
|
3592
|
+
_context35.next = 9;
|
|
3269
3593
|
break;
|
|
3270
3594
|
case 18:
|
|
3271
|
-
|
|
3595
|
+
_context35.next = 23;
|
|
3272
3596
|
break;
|
|
3273
3597
|
case 20:
|
|
3274
|
-
|
|
3275
|
-
|
|
3598
|
+
_context35.prev = 20;
|
|
3599
|
+
_context35.t0 = _context35["catch"](8);
|
|
3276
3600
|
this.logError('queued auto sync payments failed', {
|
|
3277
|
-
error:
|
|
3601
|
+
error: _context35.t0 instanceof Error ? _context35.t0.message : String(_context35.t0)
|
|
3278
3602
|
});
|
|
3279
3603
|
case 23:
|
|
3280
|
-
|
|
3604
|
+
_context35.prev = 23;
|
|
3281
3605
|
this.autoPaymentSyncFlushing = false;
|
|
3282
3606
|
if (this.queuedAutoPaymentSync) {
|
|
3283
3607
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3284
3608
|
}
|
|
3285
|
-
return
|
|
3609
|
+
return _context35.finish(23);
|
|
3286
3610
|
case 27:
|
|
3287
3611
|
case "end":
|
|
3288
|
-
return
|
|
3612
|
+
return _context35.stop();
|
|
3289
3613
|
}
|
|
3290
|
-
},
|
|
3614
|
+
}, _callee35, this, [[8, 20, 23, 27]]);
|
|
3291
3615
|
}));
|
|
3292
3616
|
function flushQueuedAutoPaymentSync() {
|
|
3293
3617
|
return _flushQueuedAutoPaymentSync.apply(this, arguments);
|
|
@@ -3311,35 +3635,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3311
3635
|
}, {
|
|
3312
3636
|
key: "addOrderPaymentAsync",
|
|
3313
3637
|
value: (function () {
|
|
3314
|
-
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3638
|
+
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(payment) {
|
|
3315
3639
|
var paymentRecord, hasPaymentNumber, devicePrefix;
|
|
3316
|
-
return _regeneratorRuntime().wrap(function
|
|
3317
|
-
while (1) switch (
|
|
3640
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
3641
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3318
3642
|
case 0:
|
|
3319
3643
|
paymentRecord = payment;
|
|
3320
3644
|
hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
|
|
3321
3645
|
if (!hasPaymentNumber) {
|
|
3322
|
-
|
|
3646
|
+
_context36.next = 6;
|
|
3323
3647
|
break;
|
|
3324
3648
|
}
|
|
3325
|
-
|
|
3326
|
-
|
|
3649
|
+
_context36.t0 = 'LOCAL';
|
|
3650
|
+
_context36.next = 9;
|
|
3327
3651
|
break;
|
|
3328
3652
|
case 6:
|
|
3329
|
-
|
|
3653
|
+
_context36.next = 8;
|
|
3330
3654
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
3331
3655
|
case 8:
|
|
3332
|
-
|
|
3656
|
+
_context36.t0 = _context36.sent;
|
|
3333
3657
|
case 9:
|
|
3334
|
-
devicePrefix =
|
|
3335
|
-
return
|
|
3658
|
+
devicePrefix = _context36.t0;
|
|
3659
|
+
return _context36.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
3336
3660
|
case 11:
|
|
3337
3661
|
case "end":
|
|
3338
|
-
return
|
|
3662
|
+
return _context36.stop();
|
|
3339
3663
|
}
|
|
3340
|
-
},
|
|
3664
|
+
}, _callee36, this);
|
|
3341
3665
|
}));
|
|
3342
|
-
function addOrderPaymentAsync(
|
|
3666
|
+
function addOrderPaymentAsync(_x29) {
|
|
3343
3667
|
return _addOrderPaymentAsync.apply(this, arguments);
|
|
3344
3668
|
}
|
|
3345
3669
|
return addOrderPaymentAsync;
|
|
@@ -3347,10 +3671,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3347
3671
|
}, {
|
|
3348
3672
|
key: "addOrderPaymentWithDevicePrefix",
|
|
3349
3673
|
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
3350
|
-
var _this$
|
|
3674
|
+
var _this$otherParams31,
|
|
3351
3675
|
_paymentRecord$paymen,
|
|
3352
3676
|
_paymentRecord$create,
|
|
3353
|
-
|
|
3677
|
+
_ref37,
|
|
3354
3678
|
_paymentRecord$origin,
|
|
3355
3679
|
_this14 = this;
|
|
3356
3680
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
@@ -3363,7 +3687,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3363
3687
|
return this.store.order.getOrderPayments();
|
|
3364
3688
|
}
|
|
3365
3689
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
3366
|
-
var shopWalletPassId = (_this$
|
|
3690
|
+
var shopWalletPassId = (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.shop_wallet_pass_id;
|
|
3367
3691
|
if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
|
|
3368
3692
|
metadata.shop_wallet_pass_id = shopWalletPassId;
|
|
3369
3693
|
}
|
|
@@ -3372,7 +3696,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3372
3696
|
var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
|
|
3373
3697
|
var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
|
|
3374
3698
|
var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
|
|
3375
|
-
var calculatedServiceFee = serviceCharge ? new Decimal((
|
|
3699
|
+
var calculatedServiceFee = serviceCharge ? new Decimal((_ref37 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref37 !== void 0 ? _ref37 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
3376
3700
|
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
|
|
3377
3701
|
service_fee: calculatedServiceFee
|
|
3378
3702
|
} : {}), {}, {
|
|
@@ -3408,7 +3732,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3408
3732
|
}, {
|
|
3409
3733
|
key: "updateOrderPayment",
|
|
3410
3734
|
value: (function () {
|
|
3411
|
-
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3735
|
+
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(paymentIdentity, updates) {
|
|
3412
3736
|
var _result$payment, _result$payment2;
|
|
3413
3737
|
var options,
|
|
3414
3738
|
matchMode,
|
|
@@ -3425,13 +3749,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3425
3749
|
shouldSubmit,
|
|
3426
3750
|
syncResult,
|
|
3427
3751
|
_options$smallTicketD2,
|
|
3428
|
-
|
|
3429
|
-
return _regeneratorRuntime().wrap(function
|
|
3430
|
-
while (1) switch (
|
|
3752
|
+
_args37 = arguments;
|
|
3753
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3754
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
3431
3755
|
case 0:
|
|
3432
|
-
options =
|
|
3756
|
+
options = _args37.length > 2 && _args37[2] !== undefined ? _args37[2] : {};
|
|
3433
3757
|
if (this.store.order) {
|
|
3434
|
-
|
|
3758
|
+
_context37.next = 3;
|
|
3435
3759
|
break;
|
|
3436
3760
|
}
|
|
3437
3761
|
throw new Error('order 模块未初始化');
|
|
@@ -3440,15 +3764,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3440
3764
|
previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
|
|
3441
3765
|
previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
|
|
3442
3766
|
if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
|
|
3443
|
-
|
|
3767
|
+
_context37.next = 13;
|
|
3444
3768
|
break;
|
|
3445
3769
|
}
|
|
3446
3770
|
currentPayments = this.store.order.getOrderPayments();
|
|
3447
3771
|
if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
|
|
3448
|
-
|
|
3772
|
+
_context37.next = 12;
|
|
3449
3773
|
break;
|
|
3450
3774
|
}
|
|
3451
|
-
|
|
3775
|
+
_context37.next = 11;
|
|
3452
3776
|
return this.syncPaymentsToOrder({
|
|
3453
3777
|
payments: currentPayments,
|
|
3454
3778
|
paymentStatus: this.getPaymentStatusForSync(currentPayments),
|
|
@@ -3456,9 +3780,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3456
3780
|
smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
|
|
3457
3781
|
});
|
|
3458
3782
|
case 11:
|
|
3459
|
-
_syncResult =
|
|
3783
|
+
_syncResult = _context37.sent;
|
|
3460
3784
|
case 12:
|
|
3461
|
-
return
|
|
3785
|
+
return _context37.abrupt("return", _objectSpread({
|
|
3462
3786
|
updated: false,
|
|
3463
3787
|
payment: previousPayment,
|
|
3464
3788
|
payments: currentPayments,
|
|
@@ -3467,44 +3791,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3467
3791
|
syncResult: _syncResult
|
|
3468
3792
|
} : {}));
|
|
3469
3793
|
case 13:
|
|
3470
|
-
|
|
3794
|
+
_context37.next = 15;
|
|
3471
3795
|
return this.store.order.updateOrderPayment(paymentIdentity, updates, {
|
|
3472
3796
|
matchBy: matchMode
|
|
3473
3797
|
});
|
|
3474
3798
|
case 15:
|
|
3475
|
-
result =
|
|
3799
|
+
result = _context37.sent;
|
|
3476
3800
|
if (!(options.persistDraft !== false)) {
|
|
3477
|
-
|
|
3801
|
+
_context37.next = 29;
|
|
3478
3802
|
break;
|
|
3479
3803
|
}
|
|
3480
|
-
|
|
3481
|
-
|
|
3804
|
+
_context37.prev = 17;
|
|
3805
|
+
_context37.next = 20;
|
|
3482
3806
|
return this.saveSalesOrderDraft();
|
|
3483
3807
|
case 20:
|
|
3484
|
-
draftResult =
|
|
3485
|
-
|
|
3808
|
+
draftResult = _context37.sent;
|
|
3809
|
+
_context37.next = 29;
|
|
3486
3810
|
break;
|
|
3487
3811
|
case 23:
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
draftError =
|
|
3812
|
+
_context37.prev = 23;
|
|
3813
|
+
_context37.t0 = _context37["catch"](17);
|
|
3814
|
+
draftError = _context37.t0;
|
|
3491
3815
|
this.logError('updateOrderPayment: 保存支付草稿失败', {
|
|
3492
3816
|
paymentIdentity: paymentIdentity,
|
|
3493
|
-
error:
|
|
3817
|
+
error: _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0)
|
|
3494
3818
|
});
|
|
3495
3819
|
if (options.submitWhenPaid) {
|
|
3496
|
-
|
|
3820
|
+
_context37.next = 29;
|
|
3497
3821
|
break;
|
|
3498
3822
|
}
|
|
3499
|
-
throw
|
|
3823
|
+
throw _context37.t0;
|
|
3500
3824
|
case 29:
|
|
3501
3825
|
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';
|
|
3502
3826
|
shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
|
|
3503
3827
|
if (!shouldSubmit) {
|
|
3504
|
-
|
|
3828
|
+
_context37.next = 35;
|
|
3505
3829
|
break;
|
|
3506
3830
|
}
|
|
3507
|
-
|
|
3831
|
+
_context37.next = 34;
|
|
3508
3832
|
return this.syncPaymentsToOrder({
|
|
3509
3833
|
payments: result.payments,
|
|
3510
3834
|
paymentStatus: this.getPaymentStatusForSync(result.payments),
|
|
@@ -3512,9 +3836,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3512
3836
|
smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
|
|
3513
3837
|
});
|
|
3514
3838
|
case 34:
|
|
3515
|
-
syncResult =
|
|
3839
|
+
syncResult = _context37.sent;
|
|
3516
3840
|
case 35:
|
|
3517
|
-
return
|
|
3841
|
+
return _context37.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
|
|
3518
3842
|
draftResult: draftResult
|
|
3519
3843
|
} : {}), draftError !== undefined ? {
|
|
3520
3844
|
draftError: draftError
|
|
@@ -3523,11 +3847,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3523
3847
|
} : {}));
|
|
3524
3848
|
case 36:
|
|
3525
3849
|
case "end":
|
|
3526
|
-
return
|
|
3850
|
+
return _context37.stop();
|
|
3527
3851
|
}
|
|
3528
|
-
},
|
|
3852
|
+
}, _callee37, this, [[17, 23]]);
|
|
3529
3853
|
}));
|
|
3530
|
-
function updateOrderPayment(
|
|
3854
|
+
function updateOrderPayment(_x30, _x31) {
|
|
3531
3855
|
return _updateOrderPayment.apply(this, arguments);
|
|
3532
3856
|
}
|
|
3533
3857
|
return updateOrderPayment;
|
|
@@ -3549,24 +3873,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3549
3873
|
}, {
|
|
3550
3874
|
key: "updateVoucherOrderPaymentsAsync",
|
|
3551
3875
|
value: function () {
|
|
3552
|
-
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3553
|
-
return _regeneratorRuntime().wrap(function
|
|
3554
|
-
while (1) switch (
|
|
3876
|
+
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(payments, options) {
|
|
3877
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3878
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3555
3879
|
case 0:
|
|
3556
3880
|
if (this.store.order) {
|
|
3557
|
-
|
|
3881
|
+
_context38.next = 2;
|
|
3558
3882
|
break;
|
|
3559
3883
|
}
|
|
3560
3884
|
throw new Error('order 模块未初始化');
|
|
3561
3885
|
case 2:
|
|
3562
|
-
return
|
|
3886
|
+
return _context38.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
|
|
3563
3887
|
case 3:
|
|
3564
3888
|
case "end":
|
|
3565
|
-
return
|
|
3889
|
+
return _context38.stop();
|
|
3566
3890
|
}
|
|
3567
|
-
},
|
|
3891
|
+
}, _callee38, this);
|
|
3568
3892
|
}));
|
|
3569
|
-
function updateVoucherOrderPaymentsAsync(
|
|
3893
|
+
function updateVoucherOrderPaymentsAsync(_x32, _x33) {
|
|
3570
3894
|
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
3571
3895
|
}
|
|
3572
3896
|
return updateVoucherOrderPaymentsAsync;
|
|
@@ -3592,8 +3916,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3592
3916
|
}, {
|
|
3593
3917
|
key: "getWalletProductList",
|
|
3594
3918
|
value: function getWalletProductList() {
|
|
3595
|
-
var _this$store$
|
|
3596
|
-
var tempOrder = (_this$store$
|
|
3919
|
+
var _this$store$order8, _tempOrder$products;
|
|
3920
|
+
var tempOrder = (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getTempOrder();
|
|
3597
3921
|
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
|
|
3598
3922
|
// 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
|
|
3599
3923
|
// debugger
|
|
@@ -3653,8 +3977,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3653
3977
|
}, {
|
|
3654
3978
|
key: "buildWalletInitBusinessData",
|
|
3655
3979
|
value: function buildWalletInitBusinessData(params) {
|
|
3656
|
-
var _this$store$
|
|
3657
|
-
var snapshot = (_this$store$
|
|
3980
|
+
var _this$store$order9, _params$order_wait_pa, _ref38, _tempOrder$is_price_i;
|
|
3981
|
+
var snapshot = (_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 ? void 0 : _this$store$order9.getOrderSnapshot();
|
|
3658
3982
|
var tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
|
|
3659
3983
|
var amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
|
|
3660
3984
|
if (!tempOrder || !amount) return null;
|
|
@@ -3669,7 +3993,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3669
3993
|
},
|
|
3670
3994
|
products: this.getWalletProductList(),
|
|
3671
3995
|
order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
|
|
3672
|
-
is_price_include_tax: (
|
|
3996
|
+
is_price_include_tax: (_ref38 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref38 !== void 0 ? _ref38 : 1
|
|
3673
3997
|
}, snapshot.identity.orderId ? {
|
|
3674
3998
|
payment_order_id: String(snapshot.identity.orderId)
|
|
3675
3999
|
} : {});
|
|
@@ -3677,20 +4001,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3677
4001
|
}, {
|
|
3678
4002
|
key: "initWalletData",
|
|
3679
4003
|
value: function () {
|
|
3680
|
-
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4004
|
+
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
3681
4005
|
var _snapshot$identity;
|
|
3682
4006
|
var snapshot, walletBusinessData, result;
|
|
3683
|
-
return _regeneratorRuntime().wrap(function
|
|
3684
|
-
while (1) switch (
|
|
4007
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
4008
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3685
4009
|
case 0:
|
|
3686
4010
|
if (this.store.order) {
|
|
3687
|
-
|
|
4011
|
+
_context39.next = 2;
|
|
3688
4012
|
break;
|
|
3689
4013
|
}
|
|
3690
4014
|
throw new Error('order 模块未初始化');
|
|
3691
4015
|
case 2:
|
|
3692
4016
|
if (this.store.payment) {
|
|
3693
|
-
|
|
4017
|
+
_context39.next = 4;
|
|
3694
4018
|
break;
|
|
3695
4019
|
}
|
|
3696
4020
|
throw new Error('payment 模块未初始化');
|
|
@@ -3698,10 +4022,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3698
4022
|
snapshot = this.store.order.getOrderSnapshot();
|
|
3699
4023
|
walletBusinessData = this.buildWalletInitBusinessData(params);
|
|
3700
4024
|
if (walletBusinessData) {
|
|
3701
|
-
|
|
4025
|
+
_context39.next = 8;
|
|
3702
4026
|
break;
|
|
3703
4027
|
}
|
|
3704
|
-
return
|
|
4028
|
+
return _context39.abrupt("return", {
|
|
3705
4029
|
walletRecommendList: [],
|
|
3706
4030
|
userIdentificationCodes: [],
|
|
3707
4031
|
transformList: [],
|
|
@@ -3709,11 +4033,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3709
4033
|
products: []
|
|
3710
4034
|
});
|
|
3711
4035
|
case 8:
|
|
3712
|
-
|
|
4036
|
+
_context39.next = 10;
|
|
3713
4037
|
return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
3714
4038
|
case 10:
|
|
3715
|
-
result =
|
|
3716
|
-
|
|
4039
|
+
result = _context39.sent;
|
|
4040
|
+
_context39.next = 13;
|
|
3717
4041
|
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
3718
4042
|
orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
|
|
3719
4043
|
customerId: walletBusinessData.customer_id,
|
|
@@ -3725,14 +4049,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3725
4049
|
timestamp: Date.now()
|
|
3726
4050
|
});
|
|
3727
4051
|
case 13:
|
|
3728
|
-
return
|
|
4052
|
+
return _context39.abrupt("return", result);
|
|
3729
4053
|
case 14:
|
|
3730
4054
|
case "end":
|
|
3731
|
-
return
|
|
4055
|
+
return _context39.stop();
|
|
3732
4056
|
}
|
|
3733
|
-
},
|
|
4057
|
+
}, _callee39, this);
|
|
3734
4058
|
}));
|
|
3735
|
-
function initWalletData(
|
|
4059
|
+
function initWalletData(_x34) {
|
|
3736
4060
|
return _initWalletData.apply(this, arguments);
|
|
3737
4061
|
}
|
|
3738
4062
|
return initWalletData;
|
|
@@ -3740,8 +4064,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3740
4064
|
}, {
|
|
3741
4065
|
key: "getCommittedWalletAssets",
|
|
3742
4066
|
value: function getCommittedWalletAssets() {
|
|
3743
|
-
var _this$store$
|
|
3744
|
-
var payments = ((_this$store$
|
|
4067
|
+
var _this$store$order10, _this$store$order10$g;
|
|
4068
|
+
var payments = ((_this$store$order10 = this.store.order) === null || _this$store$order10 === void 0 || (_this$store$order10$g = _this$store$order10.getOrderPayments) === null || _this$store$order10$g === void 0 ? void 0 : _this$store$order10$g.call(_this$store$order10)) || [];
|
|
3745
4069
|
var committed = payments.filter(function (payment) {
|
|
3746
4070
|
var voucherId = payment === null || payment === void 0 ? void 0 : payment.voucher_id;
|
|
3747
4071
|
if (voucherId === undefined || voucherId === null || voucherId === 0) {
|
|
@@ -3759,9 +4083,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3759
4083
|
var walletPassName = fundRecord.wallet_pass_name;
|
|
3760
4084
|
var title = walletPassName && _typeof(walletPassName) === 'object' ? walletPassName.default || Object.values(walletPassName)[0] : walletPassName;
|
|
3761
4085
|
var code = String((payment === null || payment === void 0 ? void 0 : payment.code) || '').toUpperCase();
|
|
3762
|
-
var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (
|
|
3763
|
-
var
|
|
3764
|
-
paymentCode =
|
|
4086
|
+
var tag = ((_Object$entries$find = Object.entries(WALLET_PAYMENT_CODE_BY_TAG).find(function (_ref39) {
|
|
4087
|
+
var _ref40 = _slicedToArray(_ref39, 2),
|
|
4088
|
+
paymentCode = _ref40[1];
|
|
3765
4089
|
return paymentCode === code;
|
|
3766
4090
|
})) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0]) || fundRecord.tag;
|
|
3767
4091
|
return {
|
|
@@ -3783,23 +4107,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3783
4107
|
}, {
|
|
3784
4108
|
key: "publishWalletAssetsState",
|
|
3785
4109
|
value: function () {
|
|
3786
|
-
var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3787
|
-
return _regeneratorRuntime().wrap(function
|
|
3788
|
-
while (1) switch (
|
|
4110
|
+
var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(state) {
|
|
4111
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
4112
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3789
4113
|
case 0:
|
|
3790
|
-
|
|
4114
|
+
_context40.next = 2;
|
|
3791
4115
|
return this.effectsEmit(BaseSalesHookNames.onWalletAssetsStateChanged, {
|
|
3792
4116
|
state: state
|
|
3793
4117
|
});
|
|
3794
4118
|
case 2:
|
|
3795
|
-
return
|
|
4119
|
+
return _context40.abrupt("return", state);
|
|
3796
4120
|
case 3:
|
|
3797
4121
|
case "end":
|
|
3798
|
-
return
|
|
4122
|
+
return _context40.stop();
|
|
3799
4123
|
}
|
|
3800
|
-
},
|
|
4124
|
+
}, _callee40, this);
|
|
3801
4125
|
}));
|
|
3802
|
-
function publishWalletAssetsState(
|
|
4126
|
+
function publishWalletAssetsState(_x35) {
|
|
3803
4127
|
return _publishWalletAssetsState.apply(this, arguments);
|
|
3804
4128
|
}
|
|
3805
4129
|
return publishWalletAssetsState;
|
|
@@ -3807,26 +4131,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3807
4131
|
}, {
|
|
3808
4132
|
key: "syncSelectedWalletAssets",
|
|
3809
4133
|
value: function () {
|
|
3810
|
-
var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4134
|
+
var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(state) {
|
|
3811
4135
|
var paymentMethods, methodByCode, preparePayments, selectedAssetById, voucherPayments, payments;
|
|
3812
|
-
return _regeneratorRuntime().wrap(function
|
|
3813
|
-
while (1) switch (
|
|
4136
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
4137
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3814
4138
|
case 0:
|
|
3815
4139
|
if (!(!this.store.order || !this.store.payment)) {
|
|
3816
|
-
|
|
4140
|
+
_context41.next = 2;
|
|
3817
4141
|
break;
|
|
3818
4142
|
}
|
|
3819
4143
|
throw new Error('订单或支付模块未初始化');
|
|
3820
4144
|
case 2:
|
|
3821
4145
|
paymentMethods = this.getPaymentMethods();
|
|
3822
4146
|
if (!(!paymentMethods.length && state.selectedItems.length)) {
|
|
3823
|
-
|
|
4147
|
+
_context41.next = 7;
|
|
3824
4148
|
break;
|
|
3825
4149
|
}
|
|
3826
|
-
|
|
4150
|
+
_context41.next = 6;
|
|
3827
4151
|
return this.getPaymentMethodsAsync();
|
|
3828
4152
|
case 6:
|
|
3829
|
-
paymentMethods =
|
|
4153
|
+
paymentMethods = _context41.sent;
|
|
3830
4154
|
case 7:
|
|
3831
4155
|
methodByCode = new Map(paymentMethods.map(function (method) {
|
|
3832
4156
|
return [String(method.code || '').toUpperCase(), method];
|
|
@@ -3868,19 +4192,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3868
4192
|
payments = this.updateVoucherOrderPayments(voucherPayments, {
|
|
3869
4193
|
status: 'payment_pending'
|
|
3870
4194
|
});
|
|
3871
|
-
|
|
4195
|
+
_context41.next = 14;
|
|
3872
4196
|
return this.store.order.recalculateSummary({
|
|
3873
4197
|
createIfMissing: true
|
|
3874
4198
|
});
|
|
3875
4199
|
case 14:
|
|
3876
|
-
return
|
|
4200
|
+
return _context41.abrupt("return", payments);
|
|
3877
4201
|
case 15:
|
|
3878
4202
|
case "end":
|
|
3879
|
-
return
|
|
4203
|
+
return _context41.stop();
|
|
3880
4204
|
}
|
|
3881
|
-
},
|
|
4205
|
+
}, _callee41, this);
|
|
3882
4206
|
}));
|
|
3883
|
-
function syncSelectedWalletAssets(
|
|
4207
|
+
function syncSelectedWalletAssets(_x36) {
|
|
3884
4208
|
return _syncSelectedWalletAssets.apply(this, arguments);
|
|
3885
4209
|
}
|
|
3886
4210
|
return syncSelectedWalletAssets;
|
|
@@ -3914,29 +4238,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3914
4238
|
}, {
|
|
3915
4239
|
key: "importWalletAssetsSnapshot",
|
|
3916
4240
|
value: (function () {
|
|
3917
|
-
var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4241
|
+
var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(snapshot) {
|
|
3918
4242
|
var state;
|
|
3919
|
-
return _regeneratorRuntime().wrap(function
|
|
3920
|
-
while (1) switch (
|
|
4243
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
4244
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
3921
4245
|
case 0:
|
|
3922
4246
|
if (this.store.payment) {
|
|
3923
|
-
|
|
4247
|
+
_context42.next = 2;
|
|
3924
4248
|
break;
|
|
3925
4249
|
}
|
|
3926
4250
|
throw new Error('payment 模块未初始化');
|
|
3927
4251
|
case 2:
|
|
3928
4252
|
state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
|
|
3929
|
-
|
|
4253
|
+
_context42.next = 5;
|
|
3930
4254
|
return this.syncSelectedWalletAssets(state);
|
|
3931
4255
|
case 5:
|
|
3932
|
-
return
|
|
4256
|
+
return _context42.abrupt("return", this.publishWalletAssetsState(state));
|
|
3933
4257
|
case 6:
|
|
3934
4258
|
case "end":
|
|
3935
|
-
return
|
|
4259
|
+
return _context42.stop();
|
|
3936
4260
|
}
|
|
3937
|
-
},
|
|
4261
|
+
}, _callee42, this);
|
|
3938
4262
|
}));
|
|
3939
|
-
function importWalletAssetsSnapshot(
|
|
4263
|
+
function importWalletAssetsSnapshot(_x37) {
|
|
3940
4264
|
return _importWalletAssetsSnapshot.apply(this, arguments);
|
|
3941
4265
|
}
|
|
3942
4266
|
return importWalletAssetsSnapshot;
|
|
@@ -3948,20 +4272,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3948
4272
|
}, {
|
|
3949
4273
|
key: "refreshWalletAssets",
|
|
3950
4274
|
value: (function () {
|
|
3951
|
-
var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4275
|
+
var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
3952
4276
|
var _previousState$custom, _businessData$custome;
|
|
3953
4277
|
var refreshSequence, wallet, businessData, emptyState, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, committed;
|
|
3954
|
-
return _regeneratorRuntime().wrap(function
|
|
3955
|
-
while (1) switch (
|
|
4278
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4279
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
3956
4280
|
case 0:
|
|
3957
4281
|
if (this.store.order) {
|
|
3958
|
-
|
|
4282
|
+
_context43.next = 2;
|
|
3959
4283
|
break;
|
|
3960
4284
|
}
|
|
3961
4285
|
throw new Error('order 模块未初始化');
|
|
3962
4286
|
case 2:
|
|
3963
4287
|
if (this.store.payment) {
|
|
3964
|
-
|
|
4288
|
+
_context43.next = 4;
|
|
3965
4289
|
break;
|
|
3966
4290
|
}
|
|
3967
4291
|
throw new Error('payment 模块未初始化');
|
|
@@ -3970,7 +4294,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3970
4294
|
wallet = this.store.payment.wallet;
|
|
3971
4295
|
businessData = this.buildWalletInitBusinessData(params);
|
|
3972
4296
|
if (businessData) {
|
|
3973
|
-
|
|
4297
|
+
_context43.next = 12;
|
|
3974
4298
|
break;
|
|
3975
4299
|
}
|
|
3976
4300
|
wallet.clearAllCache();
|
|
@@ -3978,53 +4302,53 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3978
4302
|
this.updateVoucherOrderPayments([], {
|
|
3979
4303
|
status: 'payment_pending'
|
|
3980
4304
|
});
|
|
3981
|
-
return
|
|
4305
|
+
return _context43.abrupt("return", this.publishWalletAssetsState(emptyState));
|
|
3982
4306
|
case 12:
|
|
3983
4307
|
previousState = wallet.getWalletAssetsState();
|
|
3984
4308
|
hasPreviousWalletContext = previousState.status !== 'idle' || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== undefined;
|
|
3985
4309
|
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 : '');
|
|
3986
4310
|
if (!customerChanged) {
|
|
3987
|
-
|
|
4311
|
+
_context43.next = 20;
|
|
3988
4312
|
break;
|
|
3989
4313
|
}
|
|
3990
4314
|
clearedState = wallet.clearWalletAssetSelection();
|
|
3991
4315
|
this.updateVoucherOrderPayments([], {
|
|
3992
4316
|
status: 'payment_pending'
|
|
3993
4317
|
});
|
|
3994
|
-
|
|
4318
|
+
_context43.next = 20;
|
|
3995
4319
|
return this.publishWalletAssetsState(clearedState);
|
|
3996
4320
|
case 20:
|
|
3997
4321
|
refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
|
|
3998
4322
|
preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged
|
|
3999
4323
|
});
|
|
4000
|
-
|
|
4324
|
+
_context43.next = 23;
|
|
4001
4325
|
return this.publishWalletAssetsState(wallet.getWalletAssetsState());
|
|
4002
4326
|
case 23:
|
|
4003
|
-
|
|
4327
|
+
_context43.next = 25;
|
|
4004
4328
|
return refreshTask;
|
|
4005
4329
|
case 25:
|
|
4006
|
-
state =
|
|
4330
|
+
state = _context43.sent;
|
|
4007
4331
|
if (!(refreshSequence !== this.walletAssetsRefreshSequence)) {
|
|
4008
|
-
|
|
4332
|
+
_context43.next = 28;
|
|
4009
4333
|
break;
|
|
4010
4334
|
}
|
|
4011
|
-
return
|
|
4335
|
+
return _context43.abrupt("return", wallet.getWalletAssetsState());
|
|
4012
4336
|
case 28:
|
|
4013
4337
|
if (state.status !== 'error') {
|
|
4014
4338
|
committed = this.getCommittedWalletAssets();
|
|
4015
4339
|
state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4016
4340
|
}
|
|
4017
|
-
|
|
4341
|
+
_context43.next = 31;
|
|
4018
4342
|
return this.syncSelectedWalletAssets(state);
|
|
4019
4343
|
case 31:
|
|
4020
|
-
return
|
|
4344
|
+
return _context43.abrupt("return", this.publishWalletAssetsState(state));
|
|
4021
4345
|
case 32:
|
|
4022
4346
|
case "end":
|
|
4023
|
-
return
|
|
4347
|
+
return _context43.stop();
|
|
4024
4348
|
}
|
|
4025
|
-
},
|
|
4349
|
+
}, _callee43, this);
|
|
4026
4350
|
}));
|
|
4027
|
-
function refreshWalletAssets(
|
|
4351
|
+
function refreshWalletAssets(_x38) {
|
|
4028
4352
|
return _refreshWalletAssets.apply(this, arguments);
|
|
4029
4353
|
}
|
|
4030
4354
|
return refreshWalletAssets;
|
|
@@ -4032,13 +4356,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4032
4356
|
}, {
|
|
4033
4357
|
key: "selectWalletAsset",
|
|
4034
4358
|
value: (function () {
|
|
4035
|
-
var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4359
|
+
var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
|
|
4036
4360
|
var state;
|
|
4037
|
-
return _regeneratorRuntime().wrap(function
|
|
4038
|
-
while (1) switch (
|
|
4361
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4362
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
4039
4363
|
case 0:
|
|
4040
4364
|
if (this.store.payment) {
|
|
4041
|
-
|
|
4365
|
+
_context44.next = 2;
|
|
4042
4366
|
break;
|
|
4043
4367
|
}
|
|
4044
4368
|
throw new Error('payment 模块未初始化');
|
|
@@ -4047,57 +4371,92 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4047
4371
|
selected: params.selected,
|
|
4048
4372
|
source: params.source
|
|
4049
4373
|
});
|
|
4050
|
-
|
|
4374
|
+
_context44.next = 5;
|
|
4051
4375
|
return this.syncSelectedWalletAssets(state);
|
|
4052
4376
|
case 5:
|
|
4053
|
-
return
|
|
4377
|
+
return _context44.abrupt("return", this.publishWalletAssetsState(state));
|
|
4054
4378
|
case 6:
|
|
4055
4379
|
case "end":
|
|
4056
|
-
return
|
|
4380
|
+
return _context44.stop();
|
|
4057
4381
|
}
|
|
4058
|
-
},
|
|
4382
|
+
}, _callee44, this);
|
|
4059
4383
|
}));
|
|
4060
|
-
function selectWalletAsset(
|
|
4384
|
+
function selectWalletAsset(_x39) {
|
|
4061
4385
|
return _selectWalletAsset.apply(this, arguments);
|
|
4062
4386
|
}
|
|
4063
4387
|
return selectWalletAsset;
|
|
4388
|
+
}() /** 更新已选钱包资产的手动使用金额,并同步 pending payment。 */)
|
|
4389
|
+
}, {
|
|
4390
|
+
key: "updateWalletAssetAmount",
|
|
4391
|
+
value: (function () {
|
|
4392
|
+
var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
|
|
4393
|
+
var state;
|
|
4394
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
4395
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4396
|
+
case 0:
|
|
4397
|
+
if (this.store.payment) {
|
|
4398
|
+
_context45.next = 2;
|
|
4399
|
+
break;
|
|
4400
|
+
}
|
|
4401
|
+
throw new Error('payment 模块未初始化');
|
|
4402
|
+
case 2:
|
|
4403
|
+
state = this.store.payment.wallet.updateWalletAssetAmount(params.assetId, params.amount);
|
|
4404
|
+
_context45.next = 5;
|
|
4405
|
+
return this.syncSelectedWalletAssets(state);
|
|
4406
|
+
case 5:
|
|
4407
|
+
return _context45.abrupt("return", this.publishWalletAssetsState(state));
|
|
4408
|
+
case 6:
|
|
4409
|
+
case "end":
|
|
4410
|
+
return _context45.stop();
|
|
4411
|
+
}
|
|
4412
|
+
}, _callee45, this);
|
|
4413
|
+
}));
|
|
4414
|
+
function updateWalletAssetAmount(_x40) {
|
|
4415
|
+
return _updateWalletAssetAmount.apply(this, arguments);
|
|
4416
|
+
}
|
|
4417
|
+
return updateWalletAssetAmount;
|
|
4064
4418
|
}() /** 扫码精确查券;仅可用资产会被自动选中。 */)
|
|
4065
4419
|
}, {
|
|
4066
4420
|
key: "scanWalletAsset",
|
|
4067
4421
|
value: (function () {
|
|
4068
|
-
var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4069
|
-
var result;
|
|
4070
|
-
return _regeneratorRuntime().wrap(function
|
|
4071
|
-
while (1) switch (
|
|
4422
|
+
var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(code) {
|
|
4423
|
+
var wallet, businessData, result;
|
|
4424
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
4425
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4072
4426
|
case 0:
|
|
4073
4427
|
if (this.store.payment) {
|
|
4074
|
-
|
|
4428
|
+
_context46.next = 2;
|
|
4075
4429
|
break;
|
|
4076
4430
|
}
|
|
4077
4431
|
throw new Error('payment 模块未初始化');
|
|
4078
4432
|
case 2:
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4433
|
+
wallet = this.store.payment.wallet; // 扫码可能早于后台 Wallet 刷新,搜索参数必须以当前订单为准。
|
|
4434
|
+
businessData = this.buildWalletInitBusinessData();
|
|
4435
|
+
if (businessData) {
|
|
4436
|
+
wallet.generateWalletParams(businessData);
|
|
4437
|
+
}
|
|
4438
|
+
_context46.next = 7;
|
|
4439
|
+
return wallet.scanWalletAssetAsync(code);
|
|
4440
|
+
case 7:
|
|
4441
|
+
result = _context46.sent;
|
|
4083
4442
|
if (!(result.type === 'normalCode')) {
|
|
4084
|
-
|
|
4443
|
+
_context46.next = 13;
|
|
4085
4444
|
break;
|
|
4086
4445
|
}
|
|
4087
|
-
|
|
4446
|
+
_context46.next = 11;
|
|
4088
4447
|
return this.syncSelectedWalletAssets(result.state);
|
|
4089
|
-
case 8:
|
|
4090
|
-
_context42.next = 10;
|
|
4091
|
-
return this.publishWalletAssetsState(result.state);
|
|
4092
|
-
case 10:
|
|
4093
|
-
return _context42.abrupt("return", result);
|
|
4094
4448
|
case 11:
|
|
4449
|
+
_context46.next = 13;
|
|
4450
|
+
return this.publishWalletAssetsState(result.state);
|
|
4451
|
+
case 13:
|
|
4452
|
+
return _context46.abrupt("return", result);
|
|
4453
|
+
case 14:
|
|
4095
4454
|
case "end":
|
|
4096
|
-
return
|
|
4455
|
+
return _context46.stop();
|
|
4097
4456
|
}
|
|
4098
|
-
},
|
|
4457
|
+
}, _callee46, this);
|
|
4099
4458
|
}));
|
|
4100
|
-
function scanWalletAsset(
|
|
4459
|
+
function scanWalletAsset(_x41) {
|
|
4101
4460
|
return _scanWalletAsset.apply(this, arguments);
|
|
4102
4461
|
}
|
|
4103
4462
|
return scanWalletAsset;
|
|
@@ -4105,27 +4464,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4105
4464
|
}, {
|
|
4106
4465
|
key: "clearWalletAssetSelection",
|
|
4107
4466
|
value: (function () {
|
|
4108
|
-
var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4467
|
+
var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
|
|
4109
4468
|
var state;
|
|
4110
|
-
return _regeneratorRuntime().wrap(function
|
|
4111
|
-
while (1) switch (
|
|
4469
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
4470
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4112
4471
|
case 0:
|
|
4113
4472
|
if (this.store.payment) {
|
|
4114
|
-
|
|
4473
|
+
_context47.next = 2;
|
|
4115
4474
|
break;
|
|
4116
4475
|
}
|
|
4117
4476
|
throw new Error('payment 模块未初始化');
|
|
4118
4477
|
case 2:
|
|
4119
4478
|
state = this.store.payment.wallet.clearWalletAssetSelection();
|
|
4120
|
-
|
|
4479
|
+
_context47.next = 5;
|
|
4121
4480
|
return this.syncSelectedWalletAssets(state);
|
|
4122
4481
|
case 5:
|
|
4123
|
-
return
|
|
4482
|
+
return _context47.abrupt("return", this.publishWalletAssetsState(state));
|
|
4124
4483
|
case 6:
|
|
4125
4484
|
case "end":
|
|
4126
|
-
return
|
|
4485
|
+
return _context47.stop();
|
|
4127
4486
|
}
|
|
4128
|
-
},
|
|
4487
|
+
}, _callee47, this);
|
|
4129
4488
|
}));
|
|
4130
4489
|
function clearWalletAssetSelection() {
|
|
4131
4490
|
return _clearWalletAssetSelection.apply(this, arguments);
|
|
@@ -4155,35 +4514,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4155
4514
|
}, {
|
|
4156
4515
|
key: "getPaymentMethodsAsync",
|
|
4157
4516
|
value: (function () {
|
|
4158
|
-
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4517
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
|
|
4159
4518
|
var response, paymentMethods;
|
|
4160
|
-
return _regeneratorRuntime().wrap(function
|
|
4161
|
-
while (1) switch (
|
|
4519
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
4520
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4162
4521
|
case 0:
|
|
4163
|
-
|
|
4164
|
-
|
|
4522
|
+
_context48.prev = 0;
|
|
4523
|
+
_context48.next = 3;
|
|
4165
4524
|
return this.request.get('/pay/custom-payment/all', {
|
|
4166
4525
|
filterPaymentMethods: true
|
|
4167
4526
|
}, {
|
|
4168
4527
|
osServer: true
|
|
4169
4528
|
});
|
|
4170
4529
|
case 3:
|
|
4171
|
-
response =
|
|
4530
|
+
response = _context48.sent;
|
|
4172
4531
|
paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
4173
4532
|
this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
|
|
4174
|
-
return
|
|
4533
|
+
return _context48.abrupt("return", this.getPaymentMethods());
|
|
4175
4534
|
case 9:
|
|
4176
|
-
|
|
4177
|
-
|
|
4535
|
+
_context48.prev = 9;
|
|
4536
|
+
_context48.t0 = _context48["catch"](0);
|
|
4178
4537
|
this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
|
|
4179
|
-
error:
|
|
4538
|
+
error: _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0)
|
|
4180
4539
|
});
|
|
4181
|
-
return
|
|
4540
|
+
return _context48.abrupt("return", this.getPaymentMethods());
|
|
4182
4541
|
case 13:
|
|
4183
4542
|
case "end":
|
|
4184
|
-
return
|
|
4543
|
+
return _context48.stop();
|
|
4185
4544
|
}
|
|
4186
|
-
},
|
|
4545
|
+
}, _callee48, this, [[0, 9]]);
|
|
4187
4546
|
}));
|
|
4188
4547
|
function getPaymentMethodsAsync() {
|
|
4189
4548
|
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -4208,8 +4567,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4208
4567
|
}, {
|
|
4209
4568
|
key: "getPendingWalletPaymentAmount",
|
|
4210
4569
|
value: function getPendingWalletPaymentAmount() {
|
|
4211
|
-
var _this$store$
|
|
4212
|
-
var payments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ((_this$store$
|
|
4570
|
+
var _this$store$order11, _this$store$order11$g;
|
|
4571
|
+
var payments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ((_this$store$order11 = this.store.order) === null || _this$store$order11 === void 0 || (_this$store$order11$g = _this$store$order11.getOrderPayments) === null || _this$store$order11$g === void 0 ? void 0 : _this$store$order11$g.call(_this$store$order11)) || [];
|
|
4213
4572
|
return payments.reduce(function (total, payment) {
|
|
4214
4573
|
if ((payment === null || payment === void 0 ? void 0 : payment.status) !== 'payment_pending' || (payment === null || payment === void 0 ? void 0 : payment.voucher_id) === undefined || Number(payment.voucher_id) === 0) {
|
|
4215
4574
|
return total;
|
|
@@ -4226,14 +4585,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4226
4585
|
}, {
|
|
4227
4586
|
key: "getCashPaymentConfig",
|
|
4228
4587
|
value: (function () {
|
|
4229
|
-
var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4230
|
-
var _this$store$
|
|
4588
|
+
var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
|
|
4589
|
+
var _this$store$order12, _this$store$order12$g, _this$store$order13, _this$store$order13$g, _this$otherParams32;
|
|
4231
4590
|
var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
|
|
4232
|
-
return _regeneratorRuntime().wrap(function
|
|
4233
|
-
while (1) switch (
|
|
4591
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
4592
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
4234
4593
|
case 0:
|
|
4235
4594
|
if (this.store.payment) {
|
|
4236
|
-
|
|
4595
|
+
_context49.next = 2;
|
|
4237
4596
|
break;
|
|
4238
4597
|
}
|
|
4239
4598
|
throw new Error('payment 模块未初始化');
|
|
@@ -4241,21 +4600,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4241
4600
|
paymentMethods = this.getPaymentMethods();
|
|
4242
4601
|
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
4243
4602
|
if (paymentMethod) {
|
|
4244
|
-
|
|
4603
|
+
_context49.next = 9;
|
|
4245
4604
|
break;
|
|
4246
4605
|
}
|
|
4247
|
-
|
|
4606
|
+
_context49.next = 7;
|
|
4248
4607
|
return this.getPaymentMethodsAsync();
|
|
4249
4608
|
case 7:
|
|
4250
|
-
paymentMethods =
|
|
4609
|
+
paymentMethods = _context49.sent;
|
|
4251
4610
|
paymentMethod = this.findCashPaymentMethod(paymentMethods);
|
|
4252
4611
|
case 9:
|
|
4253
|
-
amountSnapshot = (_this$store$
|
|
4612
|
+
amountSnapshot = (_this$store$order12 = this.store.order) === null || _this$store$order12 === void 0 || (_this$store$order12$g = _this$store$order12.getOrderAmountSnapshot) === null || _this$store$order12$g === void 0 ? void 0 : _this$store$order12$g.call(_this$store$order12);
|
|
4254
4613
|
pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
4255
4614
|
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
|
|
4256
|
-
currency = ((_this$store$
|
|
4615
|
+
currency = ((_this$store$order13 = this.store.order) === null || _this$store$order13 === void 0 || (_this$store$order13$g = _this$store$order13.getTempOrder) === null || _this$store$order13$g === void 0 || (_this$store$order13$g = _this$store$order13$g.call(_this$store$order13)) === null || _this$store$order13$g === void 0 ? void 0 : _this$store$order13$g.currency_code) || ((_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.currency) || 'USD';
|
|
4257
4616
|
recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
|
|
4258
|
-
return
|
|
4617
|
+
return _context49.abrupt("return", {
|
|
4259
4618
|
available: Boolean(paymentMethod && amountDue > 0),
|
|
4260
4619
|
paymentMethod: paymentMethod,
|
|
4261
4620
|
amountDue: amountDue,
|
|
@@ -4263,9 +4622,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4263
4622
|
});
|
|
4264
4623
|
case 15:
|
|
4265
4624
|
case "end":
|
|
4266
|
-
return
|
|
4625
|
+
return _context49.stop();
|
|
4267
4626
|
}
|
|
4268
|
-
},
|
|
4627
|
+
}, _callee49, this);
|
|
4269
4628
|
}));
|
|
4270
4629
|
function getCashPaymentConfig() {
|
|
4271
4630
|
return _getCashPaymentConfig.apply(this, arguments);
|
|
@@ -4282,14 +4641,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4282
4641
|
}, {
|
|
4283
4642
|
key: "confirmWalletPayment",
|
|
4284
4643
|
value: (function () {
|
|
4285
|
-
var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4286
|
-
var _this$store$order$get3, _this$store$
|
|
4644
|
+
var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
|
|
4645
|
+
var _this$store$order$get3, _this$store$order14, _this$store$order$get4, _this$store$order$get5, _this$store$order15;
|
|
4287
4646
|
var beforePayments, pendingWalletAmount, amountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
|
|
4288
|
-
return _regeneratorRuntime().wrap(function
|
|
4289
|
-
while (1) switch (
|
|
4647
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
4648
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
4290
4649
|
case 0:
|
|
4291
4650
|
if (this.store.order) {
|
|
4292
|
-
|
|
4651
|
+
_context50.next = 2;
|
|
4293
4652
|
break;
|
|
4294
4653
|
}
|
|
4295
4654
|
throw new Error('order 模块未初始化');
|
|
@@ -4297,82 +4656,82 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4297
4656
|
beforePayments = cloneDeep(this.store.order.getOrderPayments());
|
|
4298
4657
|
pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
|
|
4299
4658
|
if (!pendingWalletAmount.lte(0)) {
|
|
4300
|
-
|
|
4659
|
+
_context50.next = 6;
|
|
4301
4660
|
break;
|
|
4302
4661
|
}
|
|
4303
4662
|
throw new Error('当前订单没有待确认的 Wallet 支付');
|
|
4304
4663
|
case 6:
|
|
4305
|
-
amountSnapshot = (_this$store$order$get3 = (_this$store$
|
|
4664
|
+
amountSnapshot = (_this$store$order$get3 = (_this$store$order14 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order14);
|
|
4306
4665
|
effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
4307
4666
|
if (!effectiveAmountDue.gt(0.01)) {
|
|
4308
|
-
|
|
4667
|
+
_context50.next = 10;
|
|
4309
4668
|
break;
|
|
4310
4669
|
}
|
|
4311
4670
|
throw new Error('Wallet 支付尚未覆盖全部待支付金额');
|
|
4312
4671
|
case 10:
|
|
4313
4672
|
beforePaymentStatus = (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.payment_status;
|
|
4314
|
-
|
|
4315
|
-
|
|
4673
|
+
_context50.prev = 11;
|
|
4674
|
+
_context50.next = 14;
|
|
4316
4675
|
return this.submitSalesOrder({
|
|
4317
4676
|
smallTicketDataFlag: 1,
|
|
4318
4677
|
confirmPendingVoucherPayments: true
|
|
4319
4678
|
});
|
|
4320
4679
|
case 14:
|
|
4321
|
-
submitResult =
|
|
4680
|
+
submitResult = _context50.sent;
|
|
4322
4681
|
if (!isRejectedSalesSubmitResult(submitResult)) {
|
|
4323
|
-
|
|
4682
|
+
_context50.next = 17;
|
|
4324
4683
|
break;
|
|
4325
4684
|
}
|
|
4326
4685
|
throw new Error(getSalesSubmitErrorMessage(submitResult, 'Wallet 支付确认失败'));
|
|
4327
4686
|
case 17:
|
|
4328
|
-
|
|
4687
|
+
_context50.next = 27;
|
|
4329
4688
|
break;
|
|
4330
4689
|
case 19:
|
|
4331
|
-
|
|
4332
|
-
|
|
4690
|
+
_context50.prev = 19;
|
|
4691
|
+
_context50.t0 = _context50["catch"](11);
|
|
4333
4692
|
this.store.order.setOrderPayments(beforePayments);
|
|
4334
4693
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
4335
4694
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4336
4695
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4337
4696
|
this.store.order.persistTempOrder();
|
|
4338
4697
|
}
|
|
4339
|
-
|
|
4698
|
+
_context50.next = 26;
|
|
4340
4699
|
return this.store.order.recalculateSummary({
|
|
4341
4700
|
createIfMissing: true
|
|
4342
4701
|
});
|
|
4343
4702
|
case 26:
|
|
4344
|
-
throw
|
|
4703
|
+
throw _context50.t0;
|
|
4345
4704
|
case 27:
|
|
4346
4705
|
if (!this.store.payment) {
|
|
4347
|
-
|
|
4706
|
+
_context50.next = 38;
|
|
4348
4707
|
break;
|
|
4349
4708
|
}
|
|
4350
|
-
|
|
4709
|
+
_context50.prev = 28;
|
|
4351
4710
|
committed = this.getCommittedWalletAssets();
|
|
4352
4711
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4353
|
-
|
|
4712
|
+
_context50.next = 33;
|
|
4354
4713
|
return this.publishWalletAssetsState(walletState);
|
|
4355
4714
|
case 33:
|
|
4356
|
-
|
|
4715
|
+
_context50.next = 38;
|
|
4357
4716
|
break;
|
|
4358
4717
|
case 35:
|
|
4359
|
-
|
|
4360
|
-
|
|
4718
|
+
_context50.prev = 35;
|
|
4719
|
+
_context50.t1 = _context50["catch"](28);
|
|
4361
4720
|
this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
|
|
4362
|
-
error:
|
|
4721
|
+
error: _context50.t1 instanceof Error ? _context50.t1.message : String(_context50.t1)
|
|
4363
4722
|
});
|
|
4364
4723
|
case 38:
|
|
4365
|
-
latestAmountSnapshot = (_this$store$order$get5 = (_this$store$
|
|
4366
|
-
return
|
|
4724
|
+
latestAmountSnapshot = (_this$store$order$get5 = (_this$store$order15 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.call(_this$store$order15);
|
|
4725
|
+
return _context50.abrupt("return", {
|
|
4367
4726
|
submitResult: submitResult,
|
|
4368
4727
|
payments: this.store.order.getOrderPayments(),
|
|
4369
4728
|
isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
|
|
4370
4729
|
});
|
|
4371
4730
|
case 40:
|
|
4372
4731
|
case "end":
|
|
4373
|
-
return
|
|
4732
|
+
return _context50.stop();
|
|
4374
4733
|
}
|
|
4375
|
-
},
|
|
4734
|
+
}, _callee50, this, [[11, 19], [28, 35]]);
|
|
4376
4735
|
}));
|
|
4377
4736
|
function confirmWalletPayment() {
|
|
4378
4737
|
return _confirmWalletPayment.apply(this, arguments);
|
|
@@ -4387,38 +4746,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4387
4746
|
}, {
|
|
4388
4747
|
key: "payCash",
|
|
4389
4748
|
value: (function () {
|
|
4390
|
-
var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4391
|
-
var _this$store$order$get6, _params$actualPaidAmo, _this$
|
|
4749
|
+
var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
|
|
4750
|
+
var _this$store$order$get6, _params$actualPaidAmo, _this$otherParams33, _this$window, _this$window$postMess;
|
|
4392
4751
|
var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
4393
|
-
return _regeneratorRuntime().wrap(function
|
|
4394
|
-
while (1) switch (
|
|
4752
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
4753
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
4395
4754
|
case 0:
|
|
4396
4755
|
if (this.store.order) {
|
|
4397
|
-
|
|
4756
|
+
_context51.next = 2;
|
|
4398
4757
|
break;
|
|
4399
4758
|
}
|
|
4400
4759
|
throw new Error('order 模块未初始化');
|
|
4401
4760
|
case 2:
|
|
4402
4761
|
amount = Number(params.amount || 0);
|
|
4403
4762
|
if (!(!Number.isFinite(amount) || amount <= 0)) {
|
|
4404
|
-
|
|
4763
|
+
_context51.next = 5;
|
|
4405
4764
|
break;
|
|
4406
4765
|
}
|
|
4407
4766
|
throw new Error('现金支付金额必须大于 0');
|
|
4408
4767
|
case 5:
|
|
4409
|
-
|
|
4768
|
+
_context51.next = 7;
|
|
4410
4769
|
return this.getCashPaymentConfig();
|
|
4411
4770
|
case 7:
|
|
4412
|
-
config =
|
|
4771
|
+
config = _context51.sent;
|
|
4413
4772
|
paymentMethod = config.paymentMethod;
|
|
4414
4773
|
if (paymentMethod) {
|
|
4415
|
-
|
|
4774
|
+
_context51.next = 11;
|
|
4416
4775
|
break;
|
|
4417
4776
|
}
|
|
4418
4777
|
throw new Error('未找到可用的 CASHMANUAL 支付方式');
|
|
4419
4778
|
case 11:
|
|
4420
4779
|
if (!(config.amountDue <= 0)) {
|
|
4421
|
-
|
|
4780
|
+
_context51.next = 13;
|
|
4422
4781
|
break;
|
|
4423
4782
|
}
|
|
4424
4783
|
throw new Error('当前订单没有待支付金额');
|
|
@@ -4426,7 +4785,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4426
4785
|
roundingAmount = Number(params.roundingAmount || 0);
|
|
4427
4786
|
effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
|
|
4428
4787
|
if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
|
|
4429
|
-
|
|
4788
|
+
_context51.next = 17;
|
|
4430
4789
|
break;
|
|
4431
4790
|
}
|
|
4432
4791
|
throw new Error('现金支付金额超过当前待支付金额');
|
|
@@ -4437,9 +4796,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4437
4796
|
paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4438
4797
|
actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
|
|
4439
4798
|
changeAmount = Number(params.changeAmount || 0);
|
|
4440
|
-
shopWalletPassId = (_this$
|
|
4799
|
+
shopWalletPassId = (_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33.shop_wallet_pass_id;
|
|
4441
4800
|
if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
|
|
4442
|
-
|
|
4801
|
+
_context51.next = 26;
|
|
4443
4802
|
break;
|
|
4444
4803
|
}
|
|
4445
4804
|
throw new Error('顾客实收现金不能小于支付金额');
|
|
@@ -4474,8 +4833,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4474
4833
|
var _item$metadata2;
|
|
4475
4834
|
return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
|
|
4476
4835
|
});
|
|
4477
|
-
|
|
4478
|
-
|
|
4836
|
+
_context51.prev = 29;
|
|
4837
|
+
_context51.next = 32;
|
|
4479
4838
|
return this.syncPaymentsToOrder({
|
|
4480
4839
|
payments: payments,
|
|
4481
4840
|
submitWhenPaid: true,
|
|
@@ -4483,50 +4842,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4483
4842
|
confirmPendingVoucherPayments: true
|
|
4484
4843
|
});
|
|
4485
4844
|
case 32:
|
|
4486
|
-
syncResult =
|
|
4845
|
+
syncResult = _context51.sent;
|
|
4487
4846
|
if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
|
|
4488
|
-
|
|
4847
|
+
_context51.next = 35;
|
|
4489
4848
|
break;
|
|
4490
4849
|
}
|
|
4491
4850
|
throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
|
|
4492
4851
|
case 35:
|
|
4493
4852
|
if (!this.store.payment) {
|
|
4494
|
-
|
|
4853
|
+
_context51.next = 40;
|
|
4495
4854
|
break;
|
|
4496
4855
|
}
|
|
4497
4856
|
committed = this.getCommittedWalletAssets();
|
|
4498
4857
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4499
|
-
|
|
4858
|
+
_context51.next = 40;
|
|
4500
4859
|
return this.publishWalletAssetsState(walletState);
|
|
4501
4860
|
case 40:
|
|
4502
|
-
return
|
|
4861
|
+
return _context51.abrupt("return", {
|
|
4503
4862
|
payment: payment || {},
|
|
4504
4863
|
payments: this.store.order.getOrderPayments(),
|
|
4505
4864
|
syncResult: syncResult,
|
|
4506
4865
|
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
4507
4866
|
});
|
|
4508
4867
|
case 43:
|
|
4509
|
-
|
|
4510
|
-
|
|
4868
|
+
_context51.prev = 43;
|
|
4869
|
+
_context51.t0 = _context51["catch"](29);
|
|
4511
4870
|
this.store.order.setOrderPayments(beforePayments);
|
|
4512
4871
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
4513
4872
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4514
4873
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4515
4874
|
this.store.order.persistTempOrder();
|
|
4516
4875
|
}
|
|
4517
|
-
|
|
4876
|
+
_context51.next = 50;
|
|
4518
4877
|
return this.store.order.recalculateSummary({
|
|
4519
4878
|
createIfMissing: true
|
|
4520
4879
|
});
|
|
4521
4880
|
case 50:
|
|
4522
|
-
throw
|
|
4881
|
+
throw _context51.t0;
|
|
4523
4882
|
case 51:
|
|
4524
4883
|
case "end":
|
|
4525
|
-
return
|
|
4884
|
+
return _context51.stop();
|
|
4526
4885
|
}
|
|
4527
|
-
},
|
|
4886
|
+
}, _callee51, this, [[29, 43]]);
|
|
4528
4887
|
}));
|
|
4529
|
-
function payCash(
|
|
4888
|
+
function payCash(_x42) {
|
|
4530
4889
|
return _payCash.apply(this, arguments);
|
|
4531
4890
|
}
|
|
4532
4891
|
return payCash;
|
|
@@ -4542,21 +4901,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4542
4901
|
}, {
|
|
4543
4902
|
key: "commitPaymentMethodPayment",
|
|
4544
4903
|
value: (function () {
|
|
4545
|
-
var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4546
|
-
var _this$store$order$get7, _this$store$
|
|
4904
|
+
var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
|
|
4905
|
+
var _this$store$order$get7, _this$store$order16, _this$store$order$get8, _params$metadata, _params$originAmount;
|
|
4547
4906
|
var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
|
|
4548
|
-
return _regeneratorRuntime().wrap(function
|
|
4549
|
-
while (1) switch (
|
|
4907
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
4908
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
4550
4909
|
case 0:
|
|
4551
4910
|
if (this.store.order) {
|
|
4552
|
-
|
|
4911
|
+
_context52.next = 2;
|
|
4553
4912
|
break;
|
|
4554
4913
|
}
|
|
4555
4914
|
throw new Error('order 模块未初始化');
|
|
4556
4915
|
case 2:
|
|
4557
4916
|
amount = Number(params.amount || 0);
|
|
4558
4917
|
if (!(!Number.isFinite(amount) || amount <= 0)) {
|
|
4559
|
-
|
|
4918
|
+
_context52.next = 5;
|
|
4560
4919
|
break;
|
|
4561
4920
|
}
|
|
4562
4921
|
throw new Error('支付金额必须大于 0');
|
|
@@ -4572,32 +4931,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4572
4931
|
};
|
|
4573
4932
|
paymentMethod = findPaymentMethod();
|
|
4574
4933
|
if (paymentMethod) {
|
|
4575
|
-
|
|
4934
|
+
_context52.next = 13;
|
|
4576
4935
|
break;
|
|
4577
4936
|
}
|
|
4578
|
-
|
|
4937
|
+
_context52.next = 11;
|
|
4579
4938
|
return this.getPaymentMethodsAsync();
|
|
4580
4939
|
case 11:
|
|
4581
|
-
paymentMethods =
|
|
4940
|
+
paymentMethods = _context52.sent;
|
|
4582
4941
|
paymentMethod = findPaymentMethod();
|
|
4583
4942
|
case 13:
|
|
4584
4943
|
if (paymentMethod) {
|
|
4585
|
-
|
|
4944
|
+
_context52.next = 15;
|
|
4586
4945
|
break;
|
|
4587
4946
|
}
|
|
4588
4947
|
throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
|
|
4589
4948
|
case 15:
|
|
4590
|
-
amountSnapshot = (_this$store$order$get7 = (_this$store$
|
|
4949
|
+
amountSnapshot = (_this$store$order$get7 = (_this$store$order16 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.call(_this$store$order16);
|
|
4591
4950
|
pendingWalletAmount = this.getPendingWalletPaymentAmount();
|
|
4592
4951
|
amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
|
|
4593
4952
|
if (!amountDue.lte(0)) {
|
|
4594
|
-
|
|
4953
|
+
_context52.next = 20;
|
|
4595
4954
|
break;
|
|
4596
4955
|
}
|
|
4597
4956
|
throw new Error('当前订单没有待支付金额');
|
|
4598
4957
|
case 20:
|
|
4599
4958
|
if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
|
|
4600
|
-
|
|
4959
|
+
_context52.next = 22;
|
|
4601
4960
|
break;
|
|
4602
4961
|
}
|
|
4603
4962
|
throw new Error('支付金额超过当前待支付金额');
|
|
@@ -4636,8 +4995,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4636
4995
|
var _item$metadata3;
|
|
4637
4996
|
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;
|
|
4638
4997
|
});
|
|
4639
|
-
|
|
4640
|
-
|
|
4998
|
+
_context52.prev = 30;
|
|
4999
|
+
_context52.next = 33;
|
|
4641
5000
|
return this.syncPaymentsToOrder({
|
|
4642
5001
|
payments: payments,
|
|
4643
5002
|
submitWhenPaid: true,
|
|
@@ -4645,50 +5004,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4645
5004
|
confirmPendingVoucherPayments: true
|
|
4646
5005
|
});
|
|
4647
5006
|
case 33:
|
|
4648
|
-
syncResult =
|
|
5007
|
+
syncResult = _context52.sent;
|
|
4649
5008
|
if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
|
|
4650
|
-
|
|
5009
|
+
_context52.next = 36;
|
|
4651
5010
|
break;
|
|
4652
5011
|
}
|
|
4653
5012
|
throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
|
|
4654
5013
|
case 36:
|
|
4655
5014
|
if (!this.store.payment) {
|
|
4656
|
-
|
|
5015
|
+
_context52.next = 41;
|
|
4657
5016
|
break;
|
|
4658
5017
|
}
|
|
4659
5018
|
committed = this.getCommittedWalletAssets();
|
|
4660
5019
|
walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
|
|
4661
|
-
|
|
5020
|
+
_context52.next = 41;
|
|
4662
5021
|
return this.publishWalletAssetsState(walletState);
|
|
4663
5022
|
case 41:
|
|
4664
|
-
return
|
|
5023
|
+
return _context52.abrupt("return", {
|
|
4665
5024
|
payment: payment || {},
|
|
4666
5025
|
payments: this.store.order.getOrderPayments(),
|
|
4667
5026
|
syncResult: syncResult,
|
|
4668
5027
|
isOrderFullyPaid: syncResult.isOrderFullyPaid
|
|
4669
5028
|
});
|
|
4670
5029
|
case 44:
|
|
4671
|
-
|
|
4672
|
-
|
|
5030
|
+
_context52.prev = 44;
|
|
5031
|
+
_context52.t0 = _context52["catch"](30);
|
|
4673
5032
|
this.store.order.setOrderPayments(beforePayments);
|
|
4674
5033
|
restoredTempOrder = this.store.order.getTempOrder();
|
|
4675
5034
|
if (restoredTempOrder && beforePaymentStatus !== undefined) {
|
|
4676
5035
|
restoredTempOrder.payment_status = beforePaymentStatus;
|
|
4677
5036
|
this.store.order.persistTempOrder();
|
|
4678
5037
|
}
|
|
4679
|
-
|
|
5038
|
+
_context52.next = 51;
|
|
4680
5039
|
return this.store.order.recalculateSummary({
|
|
4681
5040
|
createIfMissing: true
|
|
4682
5041
|
});
|
|
4683
5042
|
case 51:
|
|
4684
|
-
throw
|
|
5043
|
+
throw _context52.t0;
|
|
4685
5044
|
case 52:
|
|
4686
5045
|
case "end":
|
|
4687
|
-
return
|
|
5046
|
+
return _context52.stop();
|
|
4688
5047
|
}
|
|
4689
|
-
},
|
|
5048
|
+
}, _callee52, this, [[30, 44]]);
|
|
4690
5049
|
}));
|
|
4691
|
-
function commitPaymentMethodPayment(
|
|
5050
|
+
function commitPaymentMethodPayment(_x43) {
|
|
4692
5051
|
return _commitPaymentMethodPayment.apply(this, arguments);
|
|
4693
5052
|
}
|
|
4694
5053
|
return commitPaymentMethodPayment;
|
|
@@ -4703,40 +5062,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4703
5062
|
}, {
|
|
4704
5063
|
key: "roundAmount",
|
|
4705
5064
|
value: (function () {
|
|
4706
|
-
var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5065
|
+
var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
|
|
4707
5066
|
var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
|
|
4708
5067
|
var amount, cashManualPayment;
|
|
4709
|
-
return _regeneratorRuntime().wrap(function
|
|
4710
|
-
while (1) switch (
|
|
5068
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
5069
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
4711
5070
|
case 0:
|
|
4712
5071
|
amount = params.amount;
|
|
4713
5072
|
cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
|
|
4714
5073
|
return paymentMethod.code === 'CASHMANUAL';
|
|
4715
5074
|
});
|
|
4716
5075
|
if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
|
|
4717
|
-
|
|
5076
|
+
_context53.next = 4;
|
|
4718
5077
|
break;
|
|
4719
5078
|
}
|
|
4720
|
-
return
|
|
5079
|
+
return _context53.abrupt("return", {
|
|
4721
5080
|
originalAmount: amount.toString(),
|
|
4722
5081
|
roundedAmount: amount.toString(),
|
|
4723
5082
|
roundingDifference: '0.00'
|
|
4724
5083
|
});
|
|
4725
5084
|
case 4:
|
|
4726
5085
|
if (this.payment) {
|
|
4727
|
-
|
|
5086
|
+
_context53.next = 6;
|
|
4728
5087
|
break;
|
|
4729
5088
|
}
|
|
4730
5089
|
throw new Error('payment 模块未初始化');
|
|
4731
5090
|
case 6:
|
|
4732
|
-
return
|
|
5091
|
+
return _context53.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));
|
|
4733
5092
|
case 7:
|
|
4734
5093
|
case "end":
|
|
4735
|
-
return
|
|
5094
|
+
return _context53.stop();
|
|
4736
5095
|
}
|
|
4737
|
-
},
|
|
5096
|
+
}, _callee53, this);
|
|
4738
5097
|
}));
|
|
4739
|
-
function roundAmount(
|
|
5098
|
+
function roundAmount(_x44) {
|
|
4740
5099
|
return _roundAmount.apply(this, arguments);
|
|
4741
5100
|
}
|
|
4742
5101
|
return roundAmount;
|
|
@@ -4751,49 +5110,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4751
5110
|
}, {
|
|
4752
5111
|
key: "sendCustomerPayLink",
|
|
4753
5112
|
value: (function () {
|
|
4754
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4755
|
-
var orderIds,
|
|
4756
|
-
return _regeneratorRuntime().wrap(function
|
|
4757
|
-
while (1) switch (
|
|
5113
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
|
|
5114
|
+
var orderIds, _ref41, _ref42, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
5115
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5116
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
4758
5117
|
case 0:
|
|
4759
5118
|
if (this.store.order) {
|
|
4760
|
-
|
|
5119
|
+
_context54.next = 2;
|
|
4761
5120
|
break;
|
|
4762
5121
|
}
|
|
4763
5122
|
throw new Error('order 模块未初始化');
|
|
4764
5123
|
case 2:
|
|
4765
5124
|
orderIds = params.order_ids || params.orderIds || [];
|
|
4766
5125
|
if (!(!orderIds.length || params.submitBeforeSend)) {
|
|
4767
|
-
|
|
5126
|
+
_context54.next = 11;
|
|
4768
5127
|
break;
|
|
4769
5128
|
}
|
|
4770
|
-
|
|
5129
|
+
_context54.next = 6;
|
|
4771
5130
|
return this.submitSalesOrder({
|
|
4772
5131
|
smallTicketDataFlag: 1
|
|
4773
5132
|
});
|
|
4774
5133
|
case 6:
|
|
4775
|
-
submitResult =
|
|
4776
|
-
orderId = (
|
|
5134
|
+
submitResult = _context54.sent;
|
|
5135
|
+
orderId = (_ref41 = (_ref42 = (_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 && _ref42 !== void 0 ? _ref42 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref41 !== void 0 ? _ref41 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
4777
5136
|
if (orderId) {
|
|
4778
|
-
|
|
5137
|
+
_context54.next = 10;
|
|
4779
5138
|
break;
|
|
4780
5139
|
}
|
|
4781
5140
|
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
4782
5141
|
case 10:
|
|
4783
5142
|
orderIds = [orderId];
|
|
4784
5143
|
case 11:
|
|
4785
|
-
return
|
|
5144
|
+
return _context54.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
4786
5145
|
emails: params.emails,
|
|
4787
5146
|
notify_action: params.notify_action,
|
|
4788
5147
|
order_ids: orderIds
|
|
4789
5148
|
}));
|
|
4790
5149
|
case 12:
|
|
4791
5150
|
case "end":
|
|
4792
|
-
return
|
|
5151
|
+
return _context54.stop();
|
|
4793
5152
|
}
|
|
4794
|
-
},
|
|
5153
|
+
}, _callee54, this);
|
|
4795
5154
|
}));
|
|
4796
|
-
function sendCustomerPayLink(
|
|
5155
|
+
function sendCustomerPayLink(_x45) {
|
|
4797
5156
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
4798
5157
|
}
|
|
4799
5158
|
return sendCustomerPayLink;
|
|
@@ -4806,39 +5165,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4806
5165
|
}, {
|
|
4807
5166
|
key: "calculateProductBookingPrice",
|
|
4808
5167
|
value: function () {
|
|
4809
|
-
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5168
|
+
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
|
|
4810
5169
|
var _params$customer_id;
|
|
4811
5170
|
var quotation, customerId, authoritativeProduct, product;
|
|
4812
|
-
return _regeneratorRuntime().wrap(function
|
|
4813
|
-
while (1) switch (
|
|
5171
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5172
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
4814
5173
|
case 0:
|
|
4815
5174
|
quotation = this.store.quotation;
|
|
4816
5175
|
customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
|
|
4817
|
-
|
|
4818
|
-
return this.
|
|
5176
|
+
_context55.next = 4;
|
|
5177
|
+
return this.prepareProductPriceQueryContext(customerId);
|
|
4819
5178
|
case 4:
|
|
4820
|
-
|
|
5179
|
+
_context55.next = 6;
|
|
5180
|
+
return this.loadProductForPriceQuery(params, customerId);
|
|
5181
|
+
case 6:
|
|
5182
|
+
authoritativeProduct = _context55.sent;
|
|
4821
5183
|
product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
4822
|
-
|
|
5184
|
+
_context55.next = 10;
|
|
4823
5185
|
return this.loadQuotationForPriceQuery({
|
|
4824
5186
|
quotation: quotation,
|
|
4825
5187
|
customer_id: customerId,
|
|
4826
5188
|
channel: params.channel
|
|
4827
5189
|
});
|
|
4828
|
-
case
|
|
4829
|
-
return
|
|
5190
|
+
case 10:
|
|
5191
|
+
return _context55.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
4830
5192
|
product: product,
|
|
4831
5193
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
4832
5194
|
customer_id: customerId,
|
|
4833
|
-
quotation: quotation
|
|
5195
|
+
quotation: authoritativeProduct && this.preferAuthoritativeProductQueryPrice() ? undefined : quotation
|
|
4834
5196
|
})));
|
|
4835
|
-
case
|
|
5197
|
+
case 11:
|
|
4836
5198
|
case "end":
|
|
4837
|
-
return
|
|
5199
|
+
return _context55.stop();
|
|
4838
5200
|
}
|
|
4839
|
-
},
|
|
5201
|
+
}, _callee55, this);
|
|
4840
5202
|
}));
|
|
4841
|
-
function calculateProductBookingPrice(
|
|
5203
|
+
function calculateProductBookingPrice(_x46) {
|
|
4842
5204
|
return _calculateProductBookingPrice.apply(this, arguments);
|
|
4843
5205
|
}
|
|
4844
5206
|
return calculateProductBookingPrice;
|
|
@@ -4882,6 +5244,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4882
5244
|
quotationScopes: quotationScopes
|
|
4883
5245
|
};
|
|
4884
5246
|
}
|
|
5247
|
+
}, {
|
|
5248
|
+
key: "hasSmartPricingStrategies",
|
|
5249
|
+
value: function hasSmartPricingStrategies() {
|
|
5250
|
+
var _this$core3;
|
|
5251
|
+
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;
|
|
5252
|
+
if (!evaluator || typeof evaluator.getStrategyConfigs !== 'function') {
|
|
5253
|
+
return false;
|
|
5254
|
+
}
|
|
5255
|
+
var configs = evaluator.getStrategyConfigs();
|
|
5256
|
+
return Array.isArray(configs) && configs.length > 0;
|
|
5257
|
+
}
|
|
4885
5258
|
}, {
|
|
4886
5259
|
key: "shouldRecalculateProductBookingPricesForContextChange",
|
|
4887
5260
|
value: function shouldRecalculateProductBookingPricesForContextChange(params) {
|
|
@@ -4891,6 +5264,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4891
5264
|
}));
|
|
4892
5265
|
var previousCustomerId = this.normalizePriceContextCustomerId(params.previousCustomerId);
|
|
4893
5266
|
var nextCustomerId = this.normalizePriceContextCustomerId(params.nextCustomerId);
|
|
5267
|
+
if (this.hasSmartPricingStrategies()) {
|
|
5268
|
+
return previousCustomerId !== nextCustomerId;
|
|
5269
|
+
}
|
|
4894
5270
|
var previousInScope = previousCustomerId ? scopedCustomerIds.has(previousCustomerId) : false;
|
|
4895
5271
|
var nextInScope = nextCustomerId ? scopedCustomerIds.has(nextCustomerId) : false;
|
|
4896
5272
|
var shouldRecalculate = false;
|
|
@@ -4908,23 +5284,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4908
5284
|
}, {
|
|
4909
5285
|
key: "calculateProductBookingPrices",
|
|
4910
5286
|
value: function () {
|
|
4911
|
-
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5287
|
+
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(paramsList) {
|
|
4912
5288
|
var _paramsList$0$custome,
|
|
4913
5289
|
_paramsList$,
|
|
4914
5290
|
_this16 = this,
|
|
4915
5291
|
_paramsList$2;
|
|
4916
5292
|
var quotation, customerId, productMapsByGroup, groups;
|
|
4917
|
-
return _regeneratorRuntime().wrap(function
|
|
4918
|
-
while (1) switch (
|
|
5293
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5294
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
4919
5295
|
case 0:
|
|
4920
5296
|
if (paramsList.length) {
|
|
4921
|
-
|
|
5297
|
+
_context57.next = 2;
|
|
4922
5298
|
break;
|
|
4923
5299
|
}
|
|
4924
|
-
return
|
|
5300
|
+
return _context57.abrupt("return", []);
|
|
4925
5301
|
case 2:
|
|
4926
5302
|
quotation = this.store.quotation;
|
|
4927
5303
|
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();
|
|
5304
|
+
_context57.next = 6;
|
|
5305
|
+
return this.prepareProductPriceQueryContext(customerId);
|
|
5306
|
+
case 6:
|
|
4928
5307
|
productMapsByGroup = new Map();
|
|
4929
5308
|
groups = new Map();
|
|
4930
5309
|
paramsList.forEach(function (params) {
|
|
@@ -4943,15 +5322,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4943
5322
|
group.ids.add(productId);
|
|
4944
5323
|
groups.set(groupKey, group);
|
|
4945
5324
|
});
|
|
4946
|
-
|
|
5325
|
+
_context57.next = 11;
|
|
4947
5326
|
return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
|
|
4948
|
-
var
|
|
4949
|
-
var
|
|
4950
|
-
return _regeneratorRuntime().wrap(function
|
|
4951
|
-
while (1) switch (
|
|
5327
|
+
var _ref44 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(_ref43) {
|
|
5328
|
+
var _ref45, groupKey, group, productsById;
|
|
5329
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
5330
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
4952
5331
|
case 0:
|
|
4953
|
-
|
|
4954
|
-
|
|
5332
|
+
_ref45 = _slicedToArray(_ref43, 2), groupKey = _ref45[0], group = _ref45[1];
|
|
5333
|
+
_context56.next = 3;
|
|
4955
5334
|
return _this16.loadProductsForPriceQuery({
|
|
4956
5335
|
ids: Array.from(group.ids),
|
|
4957
5336
|
schedule: group.schedule,
|
|
@@ -4959,27 +5338,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4959
5338
|
channel: group.channel
|
|
4960
5339
|
});
|
|
4961
5340
|
case 3:
|
|
4962
|
-
productsById =
|
|
5341
|
+
productsById = _context56.sent;
|
|
4963
5342
|
productMapsByGroup.set(groupKey, productsById);
|
|
4964
5343
|
case 5:
|
|
4965
5344
|
case "end":
|
|
4966
|
-
return
|
|
5345
|
+
return _context56.stop();
|
|
4967
5346
|
}
|
|
4968
|
-
},
|
|
5347
|
+
}, _callee56);
|
|
4969
5348
|
}));
|
|
4970
|
-
return function (
|
|
4971
|
-
return
|
|
5349
|
+
return function (_x48) {
|
|
5350
|
+
return _ref44.apply(this, arguments);
|
|
4972
5351
|
};
|
|
4973
5352
|
}()));
|
|
4974
|
-
case
|
|
4975
|
-
|
|
5353
|
+
case 11:
|
|
5354
|
+
_context57.next = 13;
|
|
4976
5355
|
return this.loadQuotationForPriceQuery({
|
|
4977
5356
|
quotation: quotation,
|
|
4978
5357
|
customer_id: customerId,
|
|
4979
5358
|
channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
|
|
4980
5359
|
});
|
|
4981
|
-
case
|
|
4982
|
-
return
|
|
5360
|
+
case 13:
|
|
5361
|
+
return _context57.abrupt("return", paramsList.map(function (params) {
|
|
4983
5362
|
var _this16$otherParams2, _productMapsByGroup$g;
|
|
4984
5363
|
var productInput = params.product || {};
|
|
4985
5364
|
var productId = _this16.getPriceQueryProductId(productInput);
|
|
@@ -4992,16 +5371,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4992
5371
|
product: product,
|
|
4993
5372
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
4994
5373
|
customer_id: customerId,
|
|
4995
|
-
quotation: quotation
|
|
5374
|
+
quotation: authoritativeProduct && _this16.preferAuthoritativeProductQueryPrice() ? undefined : quotation
|
|
4996
5375
|
}));
|
|
4997
5376
|
}));
|
|
4998
|
-
case
|
|
5377
|
+
case 14:
|
|
4999
5378
|
case "end":
|
|
5000
|
-
return
|
|
5379
|
+
return _context57.stop();
|
|
5001
5380
|
}
|
|
5002
|
-
},
|
|
5381
|
+
}, _callee57, this);
|
|
5003
5382
|
}));
|
|
5004
|
-
function calculateProductBookingPrices(
|
|
5383
|
+
function calculateProductBookingPrices(_x47) {
|
|
5005
5384
|
return _calculateProductBookingPrices.apply(this, arguments);
|
|
5006
5385
|
}
|
|
5007
5386
|
return calculateProductBookingPrices;
|
|
@@ -5009,34 +5388,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5009
5388
|
}, {
|
|
5010
5389
|
key: "addProductToOrder",
|
|
5011
5390
|
value: function () {
|
|
5012
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5391
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(product, booking, options) {
|
|
5013
5392
|
var products;
|
|
5014
|
-
return _regeneratorRuntime().wrap(function
|
|
5015
|
-
while (1) switch (
|
|
5393
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
5394
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
5016
5395
|
case 0:
|
|
5017
|
-
|
|
5396
|
+
_context58.prev = 0;
|
|
5018
5397
|
if (this.store.order) {
|
|
5019
|
-
|
|
5398
|
+
_context58.next = 3;
|
|
5020
5399
|
break;
|
|
5021
5400
|
}
|
|
5022
5401
|
throw new Error('order 模块未初始化');
|
|
5023
5402
|
case 3:
|
|
5024
|
-
|
|
5403
|
+
_context58.next = 5;
|
|
5025
5404
|
return this.store.order.addProductToOrder(product, booking, options);
|
|
5026
5405
|
case 5:
|
|
5027
|
-
products =
|
|
5028
|
-
return
|
|
5406
|
+
products = _context58.sent;
|
|
5407
|
+
return _context58.abrupt("return", products);
|
|
5029
5408
|
case 9:
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
throw
|
|
5409
|
+
_context58.prev = 9;
|
|
5410
|
+
_context58.t0 = _context58["catch"](0);
|
|
5411
|
+
throw _context58.t0;
|
|
5033
5412
|
case 12:
|
|
5034
5413
|
case "end":
|
|
5035
|
-
return
|
|
5414
|
+
return _context58.stop();
|
|
5036
5415
|
}
|
|
5037
|
-
},
|
|
5416
|
+
}, _callee58, this, [[0, 9]]);
|
|
5038
5417
|
}));
|
|
5039
|
-
function addProductToOrder(
|
|
5418
|
+
function addProductToOrder(_x49, _x50, _x51) {
|
|
5040
5419
|
return _addProductToOrder.apply(this, arguments);
|
|
5041
5420
|
}
|
|
5042
5421
|
return addProductToOrder;
|
|
@@ -5044,34 +5423,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5044
5423
|
}, {
|
|
5045
5424
|
key: "updateOrderProduct",
|
|
5046
5425
|
value: function () {
|
|
5047
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5426
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
|
|
5048
5427
|
var products;
|
|
5049
|
-
return _regeneratorRuntime().wrap(function
|
|
5050
|
-
while (1) switch (
|
|
5428
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context59) {
|
|
5429
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
5051
5430
|
case 0:
|
|
5052
|
-
|
|
5431
|
+
_context59.prev = 0;
|
|
5053
5432
|
if (this.store.order) {
|
|
5054
|
-
|
|
5433
|
+
_context59.next = 3;
|
|
5055
5434
|
break;
|
|
5056
5435
|
}
|
|
5057
5436
|
throw new Error('order 模块未初始化');
|
|
5058
5437
|
case 3:
|
|
5059
|
-
|
|
5438
|
+
_context59.next = 5;
|
|
5060
5439
|
return this.store.order.updateOrderProduct(params);
|
|
5061
5440
|
case 5:
|
|
5062
|
-
products =
|
|
5063
|
-
return
|
|
5441
|
+
products = _context59.sent;
|
|
5442
|
+
return _context59.abrupt("return", products);
|
|
5064
5443
|
case 9:
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
throw
|
|
5444
|
+
_context59.prev = 9;
|
|
5445
|
+
_context59.t0 = _context59["catch"](0);
|
|
5446
|
+
throw _context59.t0;
|
|
5068
5447
|
case 12:
|
|
5069
5448
|
case "end":
|
|
5070
|
-
return
|
|
5449
|
+
return _context59.stop();
|
|
5071
5450
|
}
|
|
5072
|
-
},
|
|
5451
|
+
}, _callee59, this, [[0, 9]]);
|
|
5073
5452
|
}));
|
|
5074
|
-
function updateOrderProduct(
|
|
5453
|
+
function updateOrderProduct(_x52) {
|
|
5075
5454
|
return _updateOrderProduct.apply(this, arguments);
|
|
5076
5455
|
}
|
|
5077
5456
|
return updateOrderProduct;
|
|
@@ -5079,34 +5458,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5079
5458
|
}, {
|
|
5080
5459
|
key: "updateOrderProducts",
|
|
5081
5460
|
value: function () {
|
|
5082
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5461
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(paramsList) {
|
|
5083
5462
|
var products;
|
|
5084
|
-
return _regeneratorRuntime().wrap(function
|
|
5085
|
-
while (1) switch (
|
|
5463
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
5464
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
5086
5465
|
case 0:
|
|
5087
|
-
|
|
5466
|
+
_context60.prev = 0;
|
|
5088
5467
|
if (this.store.order) {
|
|
5089
|
-
|
|
5468
|
+
_context60.next = 3;
|
|
5090
5469
|
break;
|
|
5091
5470
|
}
|
|
5092
5471
|
throw new Error('order 模块未初始化');
|
|
5093
5472
|
case 3:
|
|
5094
|
-
|
|
5473
|
+
_context60.next = 5;
|
|
5095
5474
|
return this.store.order.updateOrderProducts(paramsList);
|
|
5096
5475
|
case 5:
|
|
5097
|
-
products =
|
|
5098
|
-
return
|
|
5476
|
+
products = _context60.sent;
|
|
5477
|
+
return _context60.abrupt("return", products);
|
|
5099
5478
|
case 9:
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
throw
|
|
5479
|
+
_context60.prev = 9;
|
|
5480
|
+
_context60.t0 = _context60["catch"](0);
|
|
5481
|
+
throw _context60.t0;
|
|
5103
5482
|
case 12:
|
|
5104
5483
|
case "end":
|
|
5105
|
-
return
|
|
5484
|
+
return _context60.stop();
|
|
5106
5485
|
}
|
|
5107
|
-
},
|
|
5486
|
+
}, _callee60, this, [[0, 9]]);
|
|
5108
5487
|
}));
|
|
5109
|
-
function updateOrderProducts(
|
|
5488
|
+
function updateOrderProducts(_x53) {
|
|
5110
5489
|
return _updateOrderProducts.apply(this, arguments);
|
|
5111
5490
|
}
|
|
5112
5491
|
return updateOrderProducts;
|
|
@@ -5114,34 +5493,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5114
5493
|
}, {
|
|
5115
5494
|
key: "updateOrderProductQuantity",
|
|
5116
5495
|
value: function () {
|
|
5117
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5496
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
|
|
5118
5497
|
var products;
|
|
5119
|
-
return _regeneratorRuntime().wrap(function
|
|
5120
|
-
while (1) switch (
|
|
5498
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
5499
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
5121
5500
|
case 0:
|
|
5122
|
-
|
|
5501
|
+
_context61.prev = 0;
|
|
5123
5502
|
if (this.store.order) {
|
|
5124
|
-
|
|
5503
|
+
_context61.next = 3;
|
|
5125
5504
|
break;
|
|
5126
5505
|
}
|
|
5127
5506
|
throw new Error('order 模块未初始化');
|
|
5128
5507
|
case 3:
|
|
5129
|
-
|
|
5508
|
+
_context61.next = 5;
|
|
5130
5509
|
return this.store.order.updateOrderProductQuantity(params);
|
|
5131
5510
|
case 5:
|
|
5132
|
-
products =
|
|
5133
|
-
return
|
|
5511
|
+
products = _context61.sent;
|
|
5512
|
+
return _context61.abrupt("return", products);
|
|
5134
5513
|
case 9:
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
throw
|
|
5514
|
+
_context61.prev = 9;
|
|
5515
|
+
_context61.t0 = _context61["catch"](0);
|
|
5516
|
+
throw _context61.t0;
|
|
5138
5517
|
case 12:
|
|
5139
5518
|
case "end":
|
|
5140
|
-
return
|
|
5519
|
+
return _context61.stop();
|
|
5141
5520
|
}
|
|
5142
|
-
},
|
|
5521
|
+
}, _callee61, this, [[0, 9]]);
|
|
5143
5522
|
}));
|
|
5144
|
-
function updateOrderProductQuantity(
|
|
5523
|
+
function updateOrderProductQuantity(_x54) {
|
|
5145
5524
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
5146
5525
|
}
|
|
5147
5526
|
return updateOrderProductQuantity;
|
|
@@ -5164,12 +5543,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5164
5543
|
}, {
|
|
5165
5544
|
key: "setOrderProductLineNote",
|
|
5166
5545
|
value: (function () {
|
|
5167
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5546
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(identity, note) {
|
|
5168
5547
|
var params, products;
|
|
5169
|
-
return _regeneratorRuntime().wrap(function
|
|
5170
|
-
while (1) switch (
|
|
5548
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
5549
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
5171
5550
|
case 0:
|
|
5172
|
-
|
|
5551
|
+
_context62.prev = 0;
|
|
5173
5552
|
params = {
|
|
5174
5553
|
product_id: identity.product_id,
|
|
5175
5554
|
product_variant_id: identity.product_variant_id,
|
|
@@ -5184,22 +5563,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5184
5563
|
params.product_sku = identity.product_sku;
|
|
5185
5564
|
}
|
|
5186
5565
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
5187
|
-
|
|
5566
|
+
_context62.next = 7;
|
|
5188
5567
|
return this.updateOrderProduct(params);
|
|
5189
5568
|
case 7:
|
|
5190
|
-
products =
|
|
5191
|
-
return
|
|
5569
|
+
products = _context62.sent;
|
|
5570
|
+
return _context62.abrupt("return", products);
|
|
5192
5571
|
case 11:
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
throw
|
|
5572
|
+
_context62.prev = 11;
|
|
5573
|
+
_context62.t0 = _context62["catch"](0);
|
|
5574
|
+
throw _context62.t0;
|
|
5196
5575
|
case 14:
|
|
5197
5576
|
case "end":
|
|
5198
|
-
return
|
|
5577
|
+
return _context62.stop();
|
|
5199
5578
|
}
|
|
5200
|
-
},
|
|
5579
|
+
}, _callee62, this, [[0, 11]]);
|
|
5201
5580
|
}));
|
|
5202
|
-
function setOrderProductLineNote(
|
|
5581
|
+
function setOrderProductLineNote(_x55, _x56) {
|
|
5203
5582
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
5204
5583
|
}
|
|
5205
5584
|
return setOrderProductLineNote;
|
|
@@ -5214,32 +5593,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5214
5593
|
}, {
|
|
5215
5594
|
key: "removeProductsFromOrder",
|
|
5216
5595
|
value: (function () {
|
|
5217
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5218
|
-
return _regeneratorRuntime().wrap(function
|
|
5219
|
-
while (1) switch (
|
|
5596
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(identities, options) {
|
|
5597
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
5598
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
5220
5599
|
case 0:
|
|
5221
|
-
|
|
5600
|
+
_context63.prev = 0;
|
|
5222
5601
|
if (this.store.order) {
|
|
5223
|
-
|
|
5602
|
+
_context63.next = 3;
|
|
5224
5603
|
break;
|
|
5225
5604
|
}
|
|
5226
5605
|
throw new Error('order 模块未初始化');
|
|
5227
5606
|
case 3:
|
|
5228
|
-
|
|
5607
|
+
_context63.next = 5;
|
|
5229
5608
|
return this.store.order.removeProductsFromOrder(identities, options);
|
|
5230
5609
|
case 5:
|
|
5231
|
-
return
|
|
5610
|
+
return _context63.abrupt("return", _context63.sent);
|
|
5232
5611
|
case 8:
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
throw
|
|
5612
|
+
_context63.prev = 8;
|
|
5613
|
+
_context63.t0 = _context63["catch"](0);
|
|
5614
|
+
throw _context63.t0;
|
|
5236
5615
|
case 11:
|
|
5237
5616
|
case "end":
|
|
5238
|
-
return
|
|
5617
|
+
return _context63.stop();
|
|
5239
5618
|
}
|
|
5240
|
-
},
|
|
5619
|
+
}, _callee63, this, [[0, 8]]);
|
|
5241
5620
|
}));
|
|
5242
|
-
function removeProductsFromOrder(
|
|
5621
|
+
function removeProductsFromOrder(_x57, _x58) {
|
|
5243
5622
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
5244
5623
|
}
|
|
5245
5624
|
return removeProductsFromOrder;
|
|
@@ -5247,18 +5626,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5247
5626
|
}, {
|
|
5248
5627
|
key: "removeProductFromOrder",
|
|
5249
5628
|
value: function () {
|
|
5250
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5251
|
-
return _regeneratorRuntime().wrap(function
|
|
5252
|
-
while (1) switch (
|
|
5629
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(identity, options) {
|
|
5630
|
+
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
5631
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
5253
5632
|
case 0:
|
|
5254
|
-
return
|
|
5633
|
+
return _context64.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
5255
5634
|
case 1:
|
|
5256
5635
|
case "end":
|
|
5257
|
-
return
|
|
5636
|
+
return _context64.stop();
|
|
5258
5637
|
}
|
|
5259
|
-
},
|
|
5638
|
+
}, _callee64, this);
|
|
5260
5639
|
}));
|
|
5261
|
-
function removeProductFromOrder(
|
|
5640
|
+
function removeProductFromOrder(_x59, _x60) {
|
|
5262
5641
|
return _removeProductFromOrder.apply(this, arguments);
|
|
5263
5642
|
}
|
|
5264
5643
|
return removeProductFromOrder;
|
|
@@ -5308,23 +5687,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5308
5687
|
}, {
|
|
5309
5688
|
key: "applyPromotion",
|
|
5310
5689
|
value: (function () {
|
|
5311
|
-
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5312
|
-
return _regeneratorRuntime().wrap(function
|
|
5313
|
-
while (1) switch (
|
|
5690
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65() {
|
|
5691
|
+
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
5692
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
5314
5693
|
case 0:
|
|
5315
5694
|
if (this.store.order) {
|
|
5316
|
-
|
|
5695
|
+
_context65.next = 2;
|
|
5317
5696
|
break;
|
|
5318
5697
|
}
|
|
5319
5698
|
throw new Error('order 模块未初始化');
|
|
5320
5699
|
case 2:
|
|
5321
|
-
|
|
5700
|
+
_context65.next = 4;
|
|
5322
5701
|
return this.store.order.applyPromotion();
|
|
5323
5702
|
case 4:
|
|
5324
5703
|
case "end":
|
|
5325
|
-
return
|
|
5704
|
+
return _context65.stop();
|
|
5326
5705
|
}
|
|
5327
|
-
},
|
|
5706
|
+
}, _callee65, this);
|
|
5328
5707
|
}));
|
|
5329
5708
|
function applyPromotion() {
|
|
5330
5709
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -5334,16 +5713,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5334
5713
|
}, {
|
|
5335
5714
|
key: "getUnfulfilledPromotions",
|
|
5336
5715
|
value: function getUnfulfilledPromotions() {
|
|
5337
|
-
var _this$store$
|
|
5338
|
-
return ((_this$store$
|
|
5716
|
+
var _this$store$order17;
|
|
5717
|
+
return ((_this$store$order17 = this.store.order) === null || _this$store$order17 === void 0 ? void 0 : _this$store$order17.getUnfulfilledPromotions()) || [];
|
|
5339
5718
|
}
|
|
5340
5719
|
|
|
5341
5720
|
/** 最近一次促销计算输出的赠品操作 diff。 */
|
|
5342
5721
|
}, {
|
|
5343
5722
|
key: "getLastGiftActions",
|
|
5344
5723
|
value: function getLastGiftActions() {
|
|
5345
|
-
var _this$store$
|
|
5346
|
-
return ((_this$store$
|
|
5724
|
+
var _this$store$order18;
|
|
5725
|
+
return ((_this$store$order18 = this.store.order) === null || _this$store$order18 === void 0 ? void 0 : _this$store$order18.getLastGiftActions()) || null;
|
|
5347
5726
|
}
|
|
5348
5727
|
|
|
5349
5728
|
// 获取商品列表
|
|
@@ -5351,18 +5730,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5351
5730
|
}, {
|
|
5352
5731
|
key: "getProductList",
|
|
5353
5732
|
value: function () {
|
|
5354
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5355
|
-
var _this$
|
|
5733
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66() {
|
|
5734
|
+
var _this$otherParams34;
|
|
5356
5735
|
var menu_list_ids, _this$store$products, res;
|
|
5357
|
-
return _regeneratorRuntime().wrap(function
|
|
5358
|
-
while (1) switch (
|
|
5736
|
+
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
5737
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
5359
5738
|
case 0:
|
|
5360
5739
|
// 可以直接通过配置里的 menu 读取
|
|
5361
|
-
menu_list_ids = ((_this$
|
|
5740
|
+
menu_list_ids = ((_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 || (_this$otherParams34 = _this$otherParams34.dineInConfig) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34['menu.associated_menus'].map(function (n) {
|
|
5362
5741
|
return Number(n.value);
|
|
5363
5742
|
})) || [];
|
|
5364
|
-
|
|
5365
|
-
|
|
5743
|
+
_context66.prev = 1;
|
|
5744
|
+
_context66.next = 4;
|
|
5366
5745
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
5367
5746
|
menu_list_ids: menu_list_ids,
|
|
5368
5747
|
cacheId: this.cacheId,
|
|
@@ -5370,17 +5749,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5370
5749
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
5371
5750
|
});
|
|
5372
5751
|
case 4:
|
|
5373
|
-
res =
|
|
5374
|
-
return
|
|
5752
|
+
res = _context66.sent;
|
|
5753
|
+
return _context66.abrupt("return", res);
|
|
5375
5754
|
case 8:
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
throw
|
|
5755
|
+
_context66.prev = 8;
|
|
5756
|
+
_context66.t0 = _context66["catch"](1);
|
|
5757
|
+
throw _context66.t0;
|
|
5379
5758
|
case 11:
|
|
5380
5759
|
case "end":
|
|
5381
|
-
return
|
|
5760
|
+
return _context66.stop();
|
|
5382
5761
|
}
|
|
5383
|
-
},
|
|
5762
|
+
}, _callee66, this, [[1, 8]]);
|
|
5384
5763
|
}));
|
|
5385
5764
|
function getProductList() {
|
|
5386
5765
|
return _getProductList.apply(this, arguments);
|
|
@@ -5395,33 +5774,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5395
5774
|
}, {
|
|
5396
5775
|
key: "setOtherParams",
|
|
5397
5776
|
value: function () {
|
|
5398
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5399
|
-
var _this$
|
|
5400
|
-
var
|
|
5401
|
-
|
|
5777
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(params) {
|
|
5778
|
+
var _this$otherParams35;
|
|
5779
|
+
var _ref46,
|
|
5780
|
+
_ref46$cover,
|
|
5402
5781
|
cover,
|
|
5403
|
-
|
|
5404
|
-
return _regeneratorRuntime().wrap(function
|
|
5405
|
-
while (1) switch (
|
|
5782
|
+
_args67 = arguments;
|
|
5783
|
+
return _regeneratorRuntime().wrap(function _callee67$(_context67) {
|
|
5784
|
+
while (1) switch (_context67.prev = _context67.next) {
|
|
5406
5785
|
case 0:
|
|
5407
|
-
|
|
5786
|
+
_ref46 = _args67.length > 1 && _args67[1] !== undefined ? _args67[1] : {}, _ref46$cover = _ref46.cover, cover = _ref46$cover === void 0 ? false : _ref46$cover;
|
|
5408
5787
|
if (cover) {
|
|
5409
5788
|
this.otherParams = _objectSpread({}, params);
|
|
5410
5789
|
} else {
|
|
5411
5790
|
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
5412
5791
|
}
|
|
5413
|
-
this.cacheId = (_this$
|
|
5414
|
-
|
|
5792
|
+
this.cacheId = (_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35.cacheId;
|
|
5793
|
+
_context67.next = 5;
|
|
5415
5794
|
return this.syncOtherParamsToSubModules(params, {
|
|
5416
5795
|
cover: cover
|
|
5417
5796
|
});
|
|
5418
5797
|
case 5:
|
|
5419
5798
|
case "end":
|
|
5420
|
-
return
|
|
5799
|
+
return _context67.stop();
|
|
5421
5800
|
}
|
|
5422
|
-
},
|
|
5801
|
+
}, _callee67, this);
|
|
5423
5802
|
}));
|
|
5424
|
-
function setOtherParams(
|
|
5803
|
+
function setOtherParams(_x61) {
|
|
5425
5804
|
return _setOtherParams.apply(this, arguments);
|
|
5426
5805
|
}
|
|
5427
5806
|
return setOtherParams;
|