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