@pisell/pisellos 2.2.315 → 2.2.317
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/evaluator.js +89 -104
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +28 -4
- package/dist/modules/Holder/utils.d.ts +2 -0
- package/dist/modules/Holder/utils.js +32 -2
- package/dist/modules/OpenData/contactInfo.d.ts +20 -0
- package/dist/modules/OpenData/contactInfo.js +70 -0
- package/dist/modules/OpenData/index.d.ts +1 -0
- package/dist/modules/OpenData/index.js +1 -0
- package/dist/modules/OpenData/types.d.ts +9 -0
- package/dist/modules/Order/holderRelations.d.ts +14 -0
- package/dist/modules/Order/holderRelations.js +154 -0
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +791 -795
- package/dist/modules/Order/types.d.ts +21 -3
- package/dist/modules/Order/types.js +4 -2
- package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
- package/dist/modules/Order/utils/discountProductLineIdentity.js +142 -7
- package/dist/modules/Order/utils/orderCollectionIdentity.js +24 -10
- package/dist/modules/Order/utils.d.ts +2 -1
- package/dist/modules/Order/utils.js +36 -10
- package/dist/modules/Rules/index.js +62 -61
- package/dist/server/index.js +36 -28
- package/dist/server/modules/order/index.d.ts +4 -0
- package/dist/server/modules/order/index.js +255 -190
- package/dist/server/modules/order/types.d.ts +3 -0
- package/dist/server/modules/products/index.d.ts +28 -7
- package/dist/server/modules/products/index.js +1297 -770
- package/dist/server/modules/products/replication.d.ts +8 -0
- package/dist/server/modules/products/replication.js +69 -0
- package/dist/server/modules/products/types.d.ts +12 -1
- package/dist/server/modules/products/types.js +4 -0
- package/dist/shared/receipt/small-ticket.js +24 -12
- package/dist/shared/receipt/templateVisibility.d.ts +3 -0
- package/dist/shared/receipt/templateVisibility.js +6 -2
- package/dist/shared/sales/loadSalesOrderSnapshot.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +4 -0
- package/dist/solution/BaseSales/index.js +1116 -935
- package/dist/solution/BaseSales/types.d.ts +2 -1
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +7 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -4
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.d.ts +15 -1
- package/dist/solution/BookingTicket/index.js +784 -501
- package/dist/solution/ScanOrder/index.js +65 -31
- package/dist/solution/ScanOrder/types.d.ts +3 -0
- package/dist/solution/UnifiedBookingSales/index.js +1 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +9 -14
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +17 -1
- package/lib/modules/Holder/utils.d.ts +2 -0
- package/lib/modules/Holder/utils.js +27 -1
- package/lib/modules/OpenData/contactInfo.d.ts +20 -0
- package/lib/modules/OpenData/contactInfo.js +56 -0
- package/lib/modules/OpenData/index.d.ts +1 -0
- package/lib/modules/OpenData/index.js +12 -0
- package/lib/modules/OpenData/types.d.ts +9 -0
- package/lib/modules/Order/holderRelations.d.ts +14 -0
- package/lib/modules/Order/holderRelations.js +98 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +46 -20
- package/lib/modules/Order/types.d.ts +21 -3
- package/lib/modules/Order/types.js +3 -2
- package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
- package/lib/modules/Order/utils/discountProductLineIdentity.js +51 -2
- package/lib/modules/Order/utils/orderCollectionIdentity.js +5 -0
- package/lib/modules/Order/utils.d.ts +2 -1
- package/lib/modules/Order/utils.js +28 -6
- package/lib/modules/Rules/index.js +2 -1
- package/lib/server/index.js +8 -2
- package/lib/server/modules/order/index.d.ts +4 -0
- package/lib/server/modules/order/index.js +46 -4
- package/lib/server/modules/order/types.d.ts +3 -0
- package/lib/server/modules/products/index.d.ts +28 -7
- package/lib/server/modules/products/index.js +226 -63
- package/lib/server/modules/products/replication.d.ts +8 -0
- package/lib/server/modules/products/replication.js +30 -0
- package/lib/server/modules/products/types.d.ts +12 -1
- package/lib/server/modules/products/types.js +3 -0
- package/lib/shared/receipt/small-ticket.js +22 -13
- package/lib/shared/receipt/templateVisibility.d.ts +3 -0
- package/lib/shared/receipt/templateVisibility.js +6 -2
- package/lib/shared/sales/loadSalesOrderSnapshot.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +4 -0
- package/lib/solution/BaseSales/index.js +68 -2
- package/lib/solution/BaseSales/types.d.ts +2 -1
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -8
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.d.ts +15 -1
- package/lib/solution/BookingTicket/index.js +132 -3
- package/lib/solution/ScanOrder/index.js +59 -20
- package/lib/solution/ScanOrder/types.d.ts +3 -0
- package/lib/solution/UnifiedBookingSales/index.js +1 -1
- package/package.json +1 -1
|
@@ -34,8 +34,9 @@ import { loadSalesOrderSnapshot } from "../../shared/sales/loadSalesOrderSnapsho
|
|
|
34
34
|
import { PAYMENT_REFRESH_MESSAGE, requiresLocalPaymentRefresh, stripLocalEftposState } from "./localEftposState";
|
|
35
35
|
import { BaseModule } from "../BaseModule";
|
|
36
36
|
import { OrderHooks } from "./types";
|
|
37
|
-
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeOrderMetaList, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, collectPointCardSnapshotCodeCandidates, mergePointCardSnapshotCodes as _mergePointCardSnapshotCodes, buildVirtualCurrencySnapshotFromList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
|
|
37
|
+
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeOrderMetaList, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, hasAssignedHolderId, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, collectPointCardSnapshotCodeCandidates, mergePointCardSnapshotCodes as _mergePointCardSnapshotCodes, buildVirtualCurrencySnapshotFromList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
|
|
38
38
|
import { isNormalProduct } from "../Product/utils";
|
|
39
|
+
import { ensureHolderRelationUuids, getProductHolderRelations, hasProductBooking, removeProductHolderRelations, replaceProductHolderRelations, restoreLegacyHolderRelations } from "./holderRelations";
|
|
39
40
|
import { getWeighedProductPriceFingerprint, resolveWeighedSourcePrice, withOriginalBundleOptionPrices } from "./utils/weighedProduct";
|
|
40
41
|
import { buildPickupTimingBooking, isFulfillmentTimingBooking } from "./pickupTiming";
|
|
41
42
|
import dayjs from 'dayjs';
|
|
@@ -648,6 +649,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
648
649
|
return createDefaultOrderRulesHooks(function () {
|
|
649
650
|
var _this3$store$tempOrde;
|
|
650
651
|
return ((_this3$store$tempOrde = _this3.store.tempOrder) === null || _this3$store$tempOrde === void 0 ? void 0 : _this3$store$tempOrde.bookings) || [];
|
|
652
|
+
}, function () {
|
|
653
|
+
var _this3$store$tempOrde2;
|
|
654
|
+
return (_this3$store$tempOrde2 = _this3.store.tempOrder) === null || _this3$store$tempOrde2 === void 0 ? void 0 : _this3$store$tempOrde2.holder_relations;
|
|
651
655
|
});
|
|
652
656
|
}
|
|
653
657
|
|
|
@@ -1168,7 +1172,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1168
1172
|
discount_list: normalizeOrderProductDiscountList(syncManualProductDiscountProductNum(mergedProduct.discount_list, mergedProduct.num))
|
|
1169
1173
|
});
|
|
1170
1174
|
}));
|
|
1171
|
-
ensureUniqueProductLineUids(tempOrder);
|
|
1175
|
+
ensureUniqueProductLineUids(tempOrder, discountList);
|
|
1172
1176
|
consolidateDiscountFreeProductLines(tempOrder);
|
|
1173
1177
|
}
|
|
1174
1178
|
if (result !== null && result !== void 0 && result.discountList) {
|
|
@@ -1238,54 +1242,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1238
1242
|
key: "evaluatePromotion",
|
|
1239
1243
|
value: (function () {
|
|
1240
1244
|
var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(options) {
|
|
1241
|
-
var _this$promotionEvalua,
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context9) {
|
|
1246
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
1245
|
+
var _this$promotionEvalua, _this$promotionEvalua2;
|
|
1246
|
+
var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop, _iterator4, _step4, addAction, giftMutationBaseline, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked, payload;
|
|
1247
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context8) {
|
|
1248
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
1247
1249
|
case 0:
|
|
1248
1250
|
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
1249
|
-
|
|
1251
|
+
_context8.next = 2;
|
|
1250
1252
|
break;
|
|
1251
1253
|
}
|
|
1252
|
-
return
|
|
1254
|
+
return _context8.abrupt("return", null);
|
|
1253
1255
|
case 2:
|
|
1254
1256
|
if (!(this.isApplyingPromotion || this.isEmittingPromotionApplied)) {
|
|
1255
|
-
|
|
1257
|
+
_context8.next = 4;
|
|
1256
1258
|
break;
|
|
1257
1259
|
}
|
|
1258
|
-
return
|
|
1260
|
+
return _context8.abrupt("return", null);
|
|
1259
1261
|
case 4:
|
|
1260
1262
|
if (this.promotionEvaluator) {
|
|
1261
|
-
|
|
1263
|
+
_context8.next = 6;
|
|
1262
1264
|
break;
|
|
1263
1265
|
}
|
|
1264
|
-
return
|
|
1266
|
+
return _context8.abrupt("return", null);
|
|
1265
1267
|
case 6:
|
|
1266
1268
|
tempOrder = this.store.tempOrder;
|
|
1267
1269
|
if (tempOrder) {
|
|
1268
|
-
|
|
1270
|
+
_context8.next = 9;
|
|
1269
1271
|
break;
|
|
1270
1272
|
}
|
|
1271
|
-
return
|
|
1273
|
+
return _context8.abrupt("return", null);
|
|
1272
1274
|
case 9:
|
|
1273
1275
|
if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
1274
|
-
|
|
1276
|
+
_context8.next = 12;
|
|
1275
1277
|
break;
|
|
1276
1278
|
}
|
|
1277
1279
|
tempOrder.products = normalizeVirtualSettlementProducts(tempOrder.products);
|
|
1278
|
-
return
|
|
1280
|
+
return _context8.abrupt("return", null);
|
|
1279
1281
|
case 12:
|
|
1280
1282
|
strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
|
|
1281
1283
|
if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
|
|
1282
|
-
|
|
1284
|
+
_context8.next = 15;
|
|
1283
1285
|
break;
|
|
1284
1286
|
}
|
|
1285
|
-
return
|
|
1287
|
+
return _context8.abrupt("return", null);
|
|
1286
1288
|
case 15:
|
|
1287
1289
|
this.isApplyingPromotion = true;
|
|
1288
|
-
|
|
1290
|
+
_context8.prev = 16;
|
|
1289
1291
|
result = processCartPromotion(tempOrder.products, this.promotionEvaluator); // step 1: toRemove —— 直接过滤
|
|
1290
1292
|
if (result.giftActions.toRemove.length > 0) {
|
|
1291
1293
|
removeSet = new Set(result.giftActions.toRemove.map(String));
|
|
@@ -1297,20 +1299,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1297
1299
|
|
|
1298
1300
|
// step 2: toReduce —— 调整数量
|
|
1299
1301
|
_iterator3 = _createForOfIteratorHelper(result.giftActions.toReduce);
|
|
1300
|
-
|
|
1302
|
+
_context8.prev = 20;
|
|
1301
1303
|
_iterator3.s();
|
|
1302
1304
|
case 22:
|
|
1303
1305
|
if ((_step3 = _iterator3.n()).done) {
|
|
1304
|
-
|
|
1306
|
+
_context8.next = 42;
|
|
1305
1307
|
break;
|
|
1306
1308
|
}
|
|
1307
1309
|
reduce = _step3.value;
|
|
1308
1310
|
_iterator6 = _createForOfIteratorHelper(reduce.items);
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
+
_context8.prev = 25;
|
|
1312
|
+
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
1311
1313
|
var item, product;
|
|
1312
|
-
return _regeneratorRuntime().wrap(function
|
|
1313
|
-
while (1) switch (
|
|
1314
|
+
return _regeneratorRuntime().wrap(function _loop$(_context7) {
|
|
1315
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
1314
1316
|
case 0:
|
|
1315
1317
|
item = _step6.value;
|
|
1316
1318
|
product = result.products.find(function (p) {
|
|
@@ -1321,52 +1323,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1321
1323
|
}
|
|
1322
1324
|
case 3:
|
|
1323
1325
|
case "end":
|
|
1324
|
-
return
|
|
1326
|
+
return _context7.stop();
|
|
1325
1327
|
}
|
|
1326
|
-
},
|
|
1328
|
+
}, _loop);
|
|
1327
1329
|
});
|
|
1328
1330
|
_iterator6.s();
|
|
1329
1331
|
case 28:
|
|
1330
1332
|
if ((_step6 = _iterator6.n()).done) {
|
|
1331
|
-
|
|
1333
|
+
_context8.next = 32;
|
|
1332
1334
|
break;
|
|
1333
1335
|
}
|
|
1334
|
-
return
|
|
1336
|
+
return _context8.delegateYield(_loop(), "t0", 30);
|
|
1335
1337
|
case 30:
|
|
1336
|
-
|
|
1338
|
+
_context8.next = 28;
|
|
1337
1339
|
break;
|
|
1338
1340
|
case 32:
|
|
1339
|
-
|
|
1341
|
+
_context8.next = 37;
|
|
1340
1342
|
break;
|
|
1341
1343
|
case 34:
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
_iterator6.e(
|
|
1344
|
+
_context8.prev = 34;
|
|
1345
|
+
_context8.t1 = _context8["catch"](25);
|
|
1346
|
+
_iterator6.e(_context8.t1);
|
|
1345
1347
|
case 37:
|
|
1346
|
-
|
|
1348
|
+
_context8.prev = 37;
|
|
1347
1349
|
_iterator6.f();
|
|
1348
|
-
return
|
|
1350
|
+
return _context8.finish(37);
|
|
1349
1351
|
case 40:
|
|
1350
|
-
|
|
1352
|
+
_context8.next = 22;
|
|
1351
1353
|
break;
|
|
1352
1354
|
case 42:
|
|
1353
|
-
|
|
1355
|
+
_context8.next = 47;
|
|
1354
1356
|
break;
|
|
1355
1357
|
case 44:
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
_iterator3.e(
|
|
1358
|
+
_context8.prev = 44;
|
|
1359
|
+
_context8.t2 = _context8["catch"](20);
|
|
1360
|
+
_iterator3.e(_context8.t2);
|
|
1359
1361
|
case 47:
|
|
1360
|
-
|
|
1362
|
+
_context8.prev = 47;
|
|
1361
1363
|
_iterator3.f();
|
|
1362
|
-
return
|
|
1364
|
+
return _context8.finish(47);
|
|
1363
1365
|
case 50:
|
|
1364
1366
|
if (!(result.giftActions.toAdd.length > 0)) {
|
|
1365
|
-
|
|
1367
|
+
_context8.next = 115;
|
|
1366
1368
|
break;
|
|
1367
1369
|
}
|
|
1368
1370
|
if (this.giftSelectResolver) {
|
|
1369
|
-
|
|
1371
|
+
_context8.next = 55;
|
|
1370
1372
|
break;
|
|
1371
1373
|
}
|
|
1372
1374
|
if (result.giftActions.toAdd.some(function (g) {
|
|
@@ -1377,190 +1379,143 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1377
1379
|
} else {
|
|
1378
1380
|
console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
|
|
1379
1381
|
}
|
|
1380
|
-
|
|
1382
|
+
_context8.next = 115;
|
|
1381
1383
|
break;
|
|
1382
1384
|
case 55:
|
|
1383
1385
|
_iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
|
|
1384
|
-
|
|
1385
|
-
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
1386
|
-
var addAction, _sameStrategy$metadat, sameStrategy, giftMutationBaseline, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
|
|
1387
|
-
return _regeneratorRuntime().wrap(function _loop$(_context7) {
|
|
1388
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
1389
|
-
case 0:
|
|
1390
|
-
addAction = _step4.value;
|
|
1391
|
-
if (!(addAction.giftOptions.length === 1)) {
|
|
1392
|
-
_context7.next = 6;
|
|
1393
|
-
break;
|
|
1394
|
-
}
|
|
1395
|
-
sameStrategy = result.products.find(function (p) {
|
|
1396
|
-
var _p$metadata;
|
|
1397
|
-
return ((_p$metadata = p.metadata) === null || _p$metadata === void 0 || (_p$metadata = _p$metadata._giftInfo) === null || _p$metadata === void 0 ? void 0 : _p$metadata.strategyId) === addAction.strategyId;
|
|
1398
|
-
});
|
|
1399
|
-
if (!(sameStrategy && !sameStrategy.booking_uid && !((_sameStrategy$metadat = sameStrategy.metadata) !== null && _sameStrategy$metadat !== void 0 && _sameStrategy$metadat.booking_uid))) {
|
|
1400
|
-
_context7.next = 6;
|
|
1401
|
-
break;
|
|
1402
|
-
}
|
|
1403
|
-
sameStrategy.num = (Number(sameStrategy.num) || 0) + (addAction.giftCount || 1);
|
|
1404
|
-
return _context7.abrupt("return", 0);
|
|
1405
|
-
case 6:
|
|
1406
|
-
giftMutationBaseline = options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep({
|
|
1407
|
-
products: tempOrder.products,
|
|
1408
|
-
bookings: tempOrder.bookings
|
|
1409
|
-
}) : null;
|
|
1410
|
-
_context7.prev = 7;
|
|
1411
|
-
_context7.next = 10;
|
|
1412
|
-
return _this6.giftSelectResolver({
|
|
1413
|
-
strategyId: addAction.strategyId,
|
|
1414
|
-
strategyName: addAction.strategyName,
|
|
1415
|
-
giftCount: addAction.giftCount,
|
|
1416
|
-
giftOptions: addAction.giftOptions,
|
|
1417
|
-
sourceProductIds: addAction.sourceProductIds
|
|
1418
|
-
});
|
|
1419
|
-
case 10:
|
|
1420
|
-
giftResult = _context7.sent;
|
|
1421
|
-
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
1422
|
-
_context7.next = 13;
|
|
1423
|
-
break;
|
|
1424
|
-
}
|
|
1425
|
-
return _context7.abrupt("return", {
|
|
1426
|
-
v: null
|
|
1427
|
-
});
|
|
1428
|
-
case 13:
|
|
1429
|
-
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !isEqual({
|
|
1430
|
-
products: tempOrder.products,
|
|
1431
|
-
bookings: tempOrder.bookings
|
|
1432
|
-
}, giftMutationBaseline))) {
|
|
1433
|
-
_context7.next = 15;
|
|
1434
|
-
break;
|
|
1435
|
-
}
|
|
1436
|
-
return _context7.abrupt("return", {
|
|
1437
|
-
v: null
|
|
1438
|
-
});
|
|
1439
|
-
case 15:
|
|
1440
|
-
giftProducts = Array.isArray(giftResult) ? giftResult : giftResult === null || giftResult === void 0 ? void 0 : giftResult.products;
|
|
1441
|
-
giftBookings = Array.isArray(giftResult) ? [] : (giftResult === null || giftResult === void 0 ? void 0 : giftResult.bookings) || [];
|
|
1442
|
-
if (!(Array.isArray(giftProducts) && giftProducts.length > 0)) {
|
|
1443
|
-
_context7.next = 42;
|
|
1444
|
-
break;
|
|
1445
|
-
}
|
|
1446
|
-
_iterator5 = _createForOfIteratorHelper(giftProducts.entries());
|
|
1447
|
-
_context7.prev = 19;
|
|
1448
|
-
_iterator5.s();
|
|
1449
|
-
case 21:
|
|
1450
|
-
if ((_step5 = _iterator5.n()).done) {
|
|
1451
|
-
_context7.next = 34;
|
|
1452
|
-
break;
|
|
1453
|
-
}
|
|
1454
|
-
_step5$value = _slicedToArray(_step5.value, 2), index = _step5$value[0], gp = _step5$value[1];
|
|
1455
|
-
if (gp) {
|
|
1456
|
-
_context7.next = 25;
|
|
1457
|
-
break;
|
|
1458
|
-
}
|
|
1459
|
-
return _context7.abrupt("continue", 32);
|
|
1460
|
-
case 25:
|
|
1461
|
-
booking = giftBookings[index];
|
|
1462
|
-
if (!booking) {
|
|
1463
|
-
_context7.next = 31;
|
|
1464
|
-
break;
|
|
1465
|
-
}
|
|
1466
|
-
linked = _this6.createLinkedProductAndBooking({
|
|
1467
|
-
product: gp,
|
|
1468
|
-
booking: booking
|
|
1469
|
-
});
|
|
1470
|
-
result.products.push(linked.product);
|
|
1471
|
-
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
1472
|
-
return _context7.abrupt("continue", 32);
|
|
1473
|
-
case 31:
|
|
1474
|
-
// normalize 略过:调用方应保证返回完整 OrderProduct。
|
|
1475
|
-
result.products.push(gp);
|
|
1476
|
-
case 32:
|
|
1477
|
-
_context7.next = 21;
|
|
1478
|
-
break;
|
|
1479
|
-
case 34:
|
|
1480
|
-
_context7.next = 39;
|
|
1481
|
-
break;
|
|
1482
|
-
case 36:
|
|
1483
|
-
_context7.prev = 36;
|
|
1484
|
-
_context7.t0 = _context7["catch"](19);
|
|
1485
|
-
_iterator5.e(_context7.t0);
|
|
1486
|
-
case 39:
|
|
1487
|
-
_context7.prev = 39;
|
|
1488
|
-
_iterator5.f();
|
|
1489
|
-
return _context7.finish(39);
|
|
1490
|
-
case 42:
|
|
1491
|
-
_context7.next = 51;
|
|
1492
|
-
break;
|
|
1493
|
-
case 44:
|
|
1494
|
-
_context7.prev = 44;
|
|
1495
|
-
_context7.t1 = _context7["catch"](7);
|
|
1496
|
-
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
1497
|
-
_context7.next = 48;
|
|
1498
|
-
break;
|
|
1499
|
-
}
|
|
1500
|
-
return _context7.abrupt("return", {
|
|
1501
|
-
v: null
|
|
1502
|
-
});
|
|
1503
|
-
case 48:
|
|
1504
|
-
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !isEqual({
|
|
1505
|
-
products: tempOrder.products,
|
|
1506
|
-
bookings: tempOrder.bookings
|
|
1507
|
-
}, giftMutationBaseline))) {
|
|
1508
|
-
_context7.next = 50;
|
|
1509
|
-
break;
|
|
1510
|
-
}
|
|
1511
|
-
return _context7.abrupt("return", {
|
|
1512
|
-
v: null
|
|
1513
|
-
});
|
|
1514
|
-
case 50:
|
|
1515
|
-
// 用户取消 / 选择失败 → 视为放弃本次新增
|
|
1516
|
-
console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context7.t1);
|
|
1517
|
-
case 51:
|
|
1518
|
-
case "end":
|
|
1519
|
-
return _context7.stop();
|
|
1520
|
-
}
|
|
1521
|
-
}, _loop, null, [[7, 44], [19, 36, 39, 42]]);
|
|
1522
|
-
});
|
|
1386
|
+
_context8.prev = 56;
|
|
1523
1387
|
_iterator4.s();
|
|
1524
|
-
case
|
|
1388
|
+
case 58:
|
|
1525
1389
|
if ((_step4 = _iterator4.n()).done) {
|
|
1526
|
-
|
|
1390
|
+
_context8.next = 107;
|
|
1527
1391
|
break;
|
|
1528
1392
|
}
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1393
|
+
addAction = _step4.value;
|
|
1394
|
+
// 唯一候选也可能有规格/套餐。每次补赠都交给 SDK 判断,不能复用旧赠品的选择。
|
|
1395
|
+
giftMutationBaseline = options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep({
|
|
1396
|
+
products: tempOrder.products,
|
|
1397
|
+
bookings: tempOrder.bookings
|
|
1398
|
+
}) : null;
|
|
1399
|
+
_context8.prev = 61;
|
|
1400
|
+
_context8.next = 64;
|
|
1401
|
+
return this.giftSelectResolver({
|
|
1402
|
+
strategyId: addAction.strategyId,
|
|
1403
|
+
strategyName: addAction.strategyName,
|
|
1404
|
+
giftCount: addAction.giftCount,
|
|
1405
|
+
giftOptions: addAction.giftOptions,
|
|
1406
|
+
sourceProductIds: addAction.sourceProductIds
|
|
1407
|
+
});
|
|
1408
|
+
case 64:
|
|
1409
|
+
giftResult = _context8.sent;
|
|
1410
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
1411
|
+
_context8.next = 67;
|
|
1534
1412
|
break;
|
|
1535
1413
|
}
|
|
1536
|
-
return
|
|
1537
|
-
case
|
|
1538
|
-
if (!
|
|
1539
|
-
|
|
1414
|
+
return _context8.abrupt("return", null);
|
|
1415
|
+
case 67:
|
|
1416
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !isEqual({
|
|
1417
|
+
products: tempOrder.products,
|
|
1418
|
+
bookings: tempOrder.bookings
|
|
1419
|
+
}, giftMutationBaseline))) {
|
|
1420
|
+
_context8.next = 69;
|
|
1540
1421
|
break;
|
|
1541
1422
|
}
|
|
1542
|
-
return
|
|
1543
|
-
case
|
|
1544
|
-
|
|
1423
|
+
return _context8.abrupt("return", null);
|
|
1424
|
+
case 69:
|
|
1425
|
+
giftProducts = Array.isArray(giftResult) ? giftResult : giftResult === null || giftResult === void 0 ? void 0 : giftResult.products;
|
|
1426
|
+
giftBookings = Array.isArray(giftResult) ? [] : (giftResult === null || giftResult === void 0 ? void 0 : giftResult.bookings) || [];
|
|
1427
|
+
if (!(Array.isArray(giftProducts) && giftProducts.length > 0)) {
|
|
1428
|
+
_context8.next = 96;
|
|
1429
|
+
break;
|
|
1430
|
+
}
|
|
1431
|
+
_iterator5 = _createForOfIteratorHelper(giftProducts.entries());
|
|
1432
|
+
_context8.prev = 73;
|
|
1433
|
+
_iterator5.s();
|
|
1434
|
+
case 75:
|
|
1435
|
+
if ((_step5 = _iterator5.n()).done) {
|
|
1436
|
+
_context8.next = 88;
|
|
1437
|
+
break;
|
|
1438
|
+
}
|
|
1439
|
+
_step5$value = _slicedToArray(_step5.value, 2), index = _step5$value[0], gp = _step5$value[1];
|
|
1440
|
+
if (gp) {
|
|
1441
|
+
_context8.next = 79;
|
|
1442
|
+
break;
|
|
1443
|
+
}
|
|
1444
|
+
return _context8.abrupt("continue", 86);
|
|
1445
|
+
case 79:
|
|
1446
|
+
booking = giftBookings[index];
|
|
1447
|
+
if (!booking) {
|
|
1448
|
+
_context8.next = 85;
|
|
1449
|
+
break;
|
|
1450
|
+
}
|
|
1451
|
+
linked = this.createLinkedProductAndBooking({
|
|
1452
|
+
product: gp,
|
|
1453
|
+
booking: booking
|
|
1454
|
+
});
|
|
1455
|
+
result.products.push(linked.product);
|
|
1456
|
+
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
1457
|
+
return _context8.abrupt("continue", 86);
|
|
1458
|
+
case 85:
|
|
1459
|
+
// normalize 略过:调用方应保证返回完整 OrderProduct。
|
|
1460
|
+
result.products.push(gp);
|
|
1461
|
+
case 86:
|
|
1462
|
+
_context8.next = 75;
|
|
1545
1463
|
break;
|
|
1546
|
-
case
|
|
1547
|
-
|
|
1464
|
+
case 88:
|
|
1465
|
+
_context8.next = 93;
|
|
1548
1466
|
break;
|
|
1549
|
-
case
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
case
|
|
1554
|
-
|
|
1467
|
+
case 90:
|
|
1468
|
+
_context8.prev = 90;
|
|
1469
|
+
_context8.t3 = _context8["catch"](73);
|
|
1470
|
+
_iterator5.e(_context8.t3);
|
|
1471
|
+
case 93:
|
|
1472
|
+
_context8.prev = 93;
|
|
1473
|
+
_iterator5.f();
|
|
1474
|
+
return _context8.finish(93);
|
|
1475
|
+
case 96:
|
|
1476
|
+
_context8.next = 105;
|
|
1477
|
+
break;
|
|
1478
|
+
case 98:
|
|
1479
|
+
_context8.prev = 98;
|
|
1480
|
+
_context8.t4 = _context8["catch"](61);
|
|
1481
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
1482
|
+
_context8.next = 102;
|
|
1483
|
+
break;
|
|
1484
|
+
}
|
|
1485
|
+
return _context8.abrupt("return", null);
|
|
1486
|
+
case 102:
|
|
1487
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !isEqual({
|
|
1488
|
+
products: tempOrder.products,
|
|
1489
|
+
bookings: tempOrder.bookings
|
|
1490
|
+
}, giftMutationBaseline))) {
|
|
1491
|
+
_context8.next = 104;
|
|
1492
|
+
break;
|
|
1493
|
+
}
|
|
1494
|
+
return _context8.abrupt("return", null);
|
|
1495
|
+
case 104:
|
|
1496
|
+
// 用户取消 / 选择失败 → 视为放弃本次新增
|
|
1497
|
+
console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context8.t4);
|
|
1498
|
+
case 105:
|
|
1499
|
+
_context8.next = 58;
|
|
1500
|
+
break;
|
|
1501
|
+
case 107:
|
|
1502
|
+
_context8.next = 112;
|
|
1503
|
+
break;
|
|
1504
|
+
case 109:
|
|
1505
|
+
_context8.prev = 109;
|
|
1506
|
+
_context8.t5 = _context8["catch"](56);
|
|
1507
|
+
_iterator4.e(_context8.t5);
|
|
1508
|
+
case 112:
|
|
1509
|
+
_context8.prev = 112;
|
|
1555
1510
|
_iterator4.f();
|
|
1556
|
-
return
|
|
1557
|
-
case
|
|
1511
|
+
return _context8.finish(112);
|
|
1512
|
+
case 115:
|
|
1558
1513
|
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
1559
|
-
|
|
1514
|
+
_context8.next = 117;
|
|
1560
1515
|
break;
|
|
1561
1516
|
}
|
|
1562
|
-
return
|
|
1563
|
-
case
|
|
1517
|
+
return _context8.abrupt("return", null);
|
|
1518
|
+
case 117:
|
|
1564
1519
|
tempOrder.products = result.products;
|
|
1565
1520
|
this.lastUnfulfilledPromotions = result.unfulfilledPromotions;
|
|
1566
1521
|
this.lastGiftActions = result.giftActions;
|
|
@@ -1577,21 +1532,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1577
1532
|
}),
|
|
1578
1533
|
products: tempOrder.products
|
|
1579
1534
|
};
|
|
1580
|
-
return
|
|
1581
|
-
case
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
console.error('[OrderModule] applyPromotion failed',
|
|
1585
|
-
return
|
|
1586
|
-
case
|
|
1587
|
-
|
|
1535
|
+
return _context8.abrupt("return", payload);
|
|
1536
|
+
case 124:
|
|
1537
|
+
_context8.prev = 124;
|
|
1538
|
+
_context8.t6 = _context8["catch"](16);
|
|
1539
|
+
console.error('[OrderModule] applyPromotion failed', _context8.t6);
|
|
1540
|
+
return _context8.abrupt("return", null);
|
|
1541
|
+
case 128:
|
|
1542
|
+
_context8.prev = 128;
|
|
1588
1543
|
this.isApplyingPromotion = false;
|
|
1589
|
-
return
|
|
1590
|
-
case
|
|
1544
|
+
return _context8.finish(128);
|
|
1545
|
+
case 131:
|
|
1591
1546
|
case "end":
|
|
1592
|
-
return
|
|
1547
|
+
return _context8.stop();
|
|
1593
1548
|
}
|
|
1594
|
-
}, _callee7, this, [[16,
|
|
1549
|
+
}, _callee7, this, [[16, 124, 128, 131], [20, 44, 47, 50], [25, 34, 37, 40], [56, 109, 112, 115], [61, 98], [73, 90, 93, 96]]);
|
|
1595
1550
|
}));
|
|
1596
1551
|
function evaluatePromotion(_x8) {
|
|
1597
1552
|
return _evaluatePromotion.apply(this, arguments);
|
|
@@ -1621,29 +1576,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1621
1576
|
value: (function () {
|
|
1622
1577
|
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
1623
1578
|
var payload, tempOrder;
|
|
1624
|
-
return _regeneratorRuntime().wrap(function _callee8$(
|
|
1625
|
-
while (1) switch (
|
|
1579
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context9) {
|
|
1580
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1626
1581
|
case 0:
|
|
1627
|
-
|
|
1582
|
+
_context9.next = 2;
|
|
1628
1583
|
return this.evaluatePromotion();
|
|
1629
1584
|
case 2:
|
|
1630
|
-
payload =
|
|
1585
|
+
payload = _context9.sent;
|
|
1631
1586
|
if (payload) {
|
|
1632
|
-
|
|
1587
|
+
_context9.next = 5;
|
|
1633
1588
|
break;
|
|
1634
1589
|
}
|
|
1635
|
-
return
|
|
1590
|
+
return _context9.abrupt("return");
|
|
1636
1591
|
case 5:
|
|
1637
1592
|
tempOrder = this.store.tempOrder;
|
|
1638
1593
|
if (tempOrder) {
|
|
1639
|
-
|
|
1594
|
+
_context9.next = 8;
|
|
1640
1595
|
break;
|
|
1641
1596
|
}
|
|
1642
|
-
return
|
|
1597
|
+
return _context9.abrupt("return");
|
|
1643
1598
|
case 8:
|
|
1644
1599
|
this.applyDiscount();
|
|
1645
1600
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
1646
|
-
|
|
1601
|
+
_context9.next = 12;
|
|
1647
1602
|
return this.recalculateSummary({
|
|
1648
1603
|
createIfMissing: true
|
|
1649
1604
|
});
|
|
@@ -1652,7 +1607,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1652
1607
|
this.emitPromotionApplied(payload);
|
|
1653
1608
|
case 14:
|
|
1654
1609
|
case "end":
|
|
1655
|
-
return
|
|
1610
|
+
return _context9.stop();
|
|
1656
1611
|
}
|
|
1657
1612
|
}, _callee8, this);
|
|
1658
1613
|
}));
|
|
@@ -1710,7 +1665,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1710
1665
|
}, {
|
|
1711
1666
|
key: "persistTempOrder",
|
|
1712
1667
|
value: function persistTempOrder() {
|
|
1713
|
-
if (!this.
|
|
1668
|
+
if (!this.store.tempOrder) return;
|
|
1669
|
+
ensureHolderRelationUuids(this.store.tempOrder);
|
|
1670
|
+
if (!this.sessionStoragePersistEnabled) return;
|
|
1714
1671
|
this.checkSaveCache({
|
|
1715
1672
|
cacheId: this.cacheId,
|
|
1716
1673
|
fatherModule: this.fatherModule,
|
|
@@ -1825,12 +1782,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1825
1782
|
}, {
|
|
1826
1783
|
key: "rememberPointCardSnapshotCodeCandidates",
|
|
1827
1784
|
value: function rememberPointCardSnapshotCodeCandidates(value) {
|
|
1828
|
-
var
|
|
1785
|
+
var _this6 = this;
|
|
1829
1786
|
collectPointCardSnapshotCodeCandidates(value).forEach(function (_ref18) {
|
|
1830
1787
|
var id = _ref18.id,
|
|
1831
1788
|
code = _ref18.code;
|
|
1832
|
-
if (!
|
|
1833
|
-
|
|
1789
|
+
if (!_this6.pointCardSnapshotCodeCandidates.has(id)) {
|
|
1790
|
+
_this6.pointCardSnapshotCodeCandidates.set(id, code);
|
|
1834
1791
|
}
|
|
1835
1792
|
});
|
|
1836
1793
|
}
|
|
@@ -1979,11 +1936,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1979
1936
|
key: "saveDraft",
|
|
1980
1937
|
value: function () {
|
|
1981
1938
|
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
1982
|
-
return _regeneratorRuntime().wrap(function _callee9$(
|
|
1983
|
-
while (1) switch (
|
|
1939
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context10) {
|
|
1940
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1984
1941
|
case 0:
|
|
1985
1942
|
case "end":
|
|
1986
|
-
return
|
|
1943
|
+
return _context10.stop();
|
|
1987
1944
|
}
|
|
1988
1945
|
}, _callee9);
|
|
1989
1946
|
}));
|
|
@@ -2001,13 +1958,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2001
1958
|
key: "hydrateTempOrderFromLocalRecord",
|
|
2002
1959
|
value: function () {
|
|
2003
1960
|
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(record) {
|
|
2004
|
-
return _regeneratorRuntime().wrap(function _callee10$(
|
|
2005
|
-
while (1) switch (
|
|
1961
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context11) {
|
|
1962
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
2006
1963
|
case 0:
|
|
2007
|
-
return
|
|
1964
|
+
return _context11.abrupt("return", this.hydrateTempOrderFromRecord(record));
|
|
2008
1965
|
case 1:
|
|
2009
1966
|
case "end":
|
|
2010
|
-
return
|
|
1967
|
+
return _context11.stop();
|
|
2011
1968
|
}
|
|
2012
1969
|
}, _callee10, this);
|
|
2013
1970
|
}));
|
|
@@ -2037,23 +1994,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2037
1994
|
}, {
|
|
2038
1995
|
key: "calculatePaymentTotal",
|
|
2039
1996
|
value: function calculatePaymentTotal(payments) {
|
|
2040
|
-
var
|
|
1997
|
+
var _this7 = this;
|
|
2041
1998
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
2042
1999
|
includeVoided: false
|
|
2043
2000
|
}).reduce(function (sum, payment) {
|
|
2044
2001
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
2045
|
-
return sum.plus(
|
|
2002
|
+
return sum.plus(_this7.calculatePaymentEffectiveAmount(payment));
|
|
2046
2003
|
}, new Decimal(0));
|
|
2047
2004
|
}
|
|
2048
2005
|
}, {
|
|
2049
2006
|
key: "calculateOrderPaidPaymentTotal",
|
|
2050
2007
|
value: function calculateOrderPaidPaymentTotal(payments) {
|
|
2051
|
-
var
|
|
2008
|
+
var _this8 = this;
|
|
2052
2009
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
2053
2010
|
includeVoided: false
|
|
2054
2011
|
}).reduce(function (sum, payment) {
|
|
2055
2012
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
2056
|
-
return sum.plus(
|
|
2013
|
+
return sum.plus(_this8.calculatePaymentGapAmount(payment));
|
|
2057
2014
|
}, new Decimal(0));
|
|
2058
2015
|
}
|
|
2059
2016
|
}, {
|
|
@@ -2189,13 +2146,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2189
2146
|
}, {
|
|
2190
2147
|
key: "calculateDepositPaidAmount",
|
|
2191
2148
|
value: function calculateDepositPaidAmount(payments) {
|
|
2192
|
-
var
|
|
2149
|
+
var _this9 = this;
|
|
2193
2150
|
return (payments || []).reduce(function (sum, payment) {
|
|
2194
2151
|
var paymentRecord = payment;
|
|
2195
2152
|
if (!isPaidPaymentRecord(paymentRecord)) return sum;
|
|
2196
2153
|
var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
|
|
2197
2154
|
if (!isDepositPayment) return sum;
|
|
2198
|
-
return sum.plus(
|
|
2155
|
+
return sum.plus(_this9.calculatePaymentGapAmount(paymentRecord));
|
|
2199
2156
|
}, new Decimal(0));
|
|
2200
2157
|
}
|
|
2201
2158
|
}, {
|
|
@@ -2232,17 +2189,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2232
2189
|
}, {
|
|
2233
2190
|
key: "getPaymentNumberDevicePrefixSync",
|
|
2234
2191
|
value: function getPaymentNumberDevicePrefixSync() {
|
|
2235
|
-
var
|
|
2192
|
+
var _this10 = this;
|
|
2236
2193
|
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
2237
|
-
return
|
|
2194
|
+
return _this10.getPaymentNumberAppData(key);
|
|
2238
2195
|
});
|
|
2239
2196
|
}
|
|
2240
2197
|
}, {
|
|
2241
2198
|
key: "getPaymentNumberDevicePrefixAsync",
|
|
2242
2199
|
value: function getPaymentNumberDevicePrefixAsync() {
|
|
2243
|
-
var
|
|
2200
|
+
var _this11 = this;
|
|
2244
2201
|
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
2245
|
-
return
|
|
2202
|
+
return _this11.getPaymentNumberAppData(key);
|
|
2246
2203
|
});
|
|
2247
2204
|
}
|
|
2248
2205
|
}, {
|
|
@@ -2372,16 +2329,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2372
2329
|
}, {
|
|
2373
2330
|
key: "calculatePaidPaymentSummary",
|
|
2374
2331
|
value: function calculatePaidPaymentSummary(payments) {
|
|
2375
|
-
var
|
|
2332
|
+
var _this12 = this;
|
|
2376
2333
|
return (payments || []).reduce(function (summary, payment) {
|
|
2377
2334
|
var paymentRecord = payment;
|
|
2378
2335
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
2379
2336
|
return {
|
|
2380
2337
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
2381
|
-
orderPaidAmount: summary.orderPaidAmount.plus(
|
|
2382
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
2383
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
2384
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
2338
|
+
orderPaidAmount: summary.orderPaidAmount.plus(_this12.calculatePaymentOrderAmount(paymentRecord)),
|
|
2339
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this12.calculatePaymentGapAmount(paymentRecord)),
|
|
2340
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this12.calculatePaymentServiceFee(paymentRecord)),
|
|
2341
|
+
roundingAmount: summary.roundingAmount.plus(_this12.calculatePaymentRoundingAmount(paymentRecord))
|
|
2385
2342
|
};
|
|
2386
2343
|
}, {
|
|
2387
2344
|
customerPaidAmount: new Decimal(0),
|
|
@@ -2588,15 +2545,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2588
2545
|
}, {
|
|
2589
2546
|
key: "normalizeFingerprintValue",
|
|
2590
2547
|
value: function normalizeFingerprintValue(value) {
|
|
2591
|
-
var
|
|
2548
|
+
var _this13 = this;
|
|
2592
2549
|
if (Array.isArray(value)) {
|
|
2593
2550
|
return value.map(function (item) {
|
|
2594
|
-
return
|
|
2551
|
+
return _this13.normalizeFingerprintValue(item);
|
|
2595
2552
|
});
|
|
2596
2553
|
}
|
|
2597
2554
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
2598
2555
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
2599
|
-
result[key] =
|
|
2556
|
+
result[key] = _this13.normalizeFingerprintValue(value[key]);
|
|
2600
2557
|
return result;
|
|
2601
2558
|
}, {});
|
|
2602
2559
|
}
|
|
@@ -2611,7 +2568,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2611
2568
|
_sku$barcode,
|
|
2612
2569
|
_ref26,
|
|
2613
2570
|
_sku$variant_id,
|
|
2614
|
-
|
|
2571
|
+
_this14 = this;
|
|
2615
2572
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2616
2573
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2617
2574
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2630,12 +2587,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2630
2587
|
selling_price: this.normalizeFingerprintMoney(product === null || product === void 0 ? void 0 : product.selling_price),
|
|
2631
2588
|
original_price: this.normalizeFingerprintMoney(product === null || product === void 0 ? void 0 : product.original_price),
|
|
2632
2589
|
payment_price: this.normalizeFingerprintMoney((_product$payment_pric = product === null || product === void 0 ? void 0 : product.payment_price) !== null && _product$payment_pric !== void 0 ? _product$payment_pric : product === null || product === void 0 ? void 0 : product.selling_price),
|
|
2633
|
-
metadata: {
|
|
2590
|
+
metadata: _objectSpread({
|
|
2634
2591
|
source_product_price: this.normalizeFingerprintMoney(metadata.source_product_price),
|
|
2635
2592
|
main_product_selling_price: this.normalizeFingerprintMoney(metadata.main_product_selling_price),
|
|
2636
2593
|
main_product_original_price: this.normalizeFingerprintMoney(metadata.main_product_original_price),
|
|
2637
2594
|
product_discount_difference: this.normalizeFingerprintMoney(metadata.product_discount_difference)
|
|
2638
|
-
},
|
|
2595
|
+
}, !hasProductBooking(product) ? {
|
|
2596
|
+
holder_relations: this.normalizeFingerprintValue(getProductHolderRelations(this.store.tempOrder || {}, product))
|
|
2597
|
+
} : {}),
|
|
2639
2598
|
product_sku: this.normalizeFingerprintValue({
|
|
2640
2599
|
code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
|
|
2641
2600
|
barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
|
|
@@ -2648,7 +2607,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2648
2607
|
option_group_id: (_option$option_group_ = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : null,
|
|
2649
2608
|
option_group_item_id: (_ref28 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref28 !== void 0 ? _ref28 : null,
|
|
2650
2609
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
2651
|
-
add_price:
|
|
2610
|
+
add_price: _this14.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
|
|
2652
2611
|
};
|
|
2653
2612
|
})
|
|
2654
2613
|
}),
|
|
@@ -2658,8 +2617,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2658
2617
|
bundle_product_id: (_ref29 = (_ref30 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref30 !== void 0 ? _ref30 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref29 !== void 0 ? _ref29 : null,
|
|
2659
2618
|
bundle_variant_id: (_ref31 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref31 !== void 0 ? _ref31 : 0,
|
|
2660
2619
|
num: getSafeProductNum((_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
|
|
2661
|
-
price:
|
|
2662
|
-
bundle_selling_price:
|
|
2620
|
+
price: _this14.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
2621
|
+
bundle_selling_price: _this14.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
2663
2622
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
2664
2623
|
price_type_ext: (_bundle$price_type_ex = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : ''
|
|
2665
2624
|
};
|
|
@@ -2669,7 +2628,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2669
2628
|
return {
|
|
2670
2629
|
type: (_ref32 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref32 !== void 0 ? _ref32 : '',
|
|
2671
2630
|
discount_id: (_ref33 = (_ref34 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref34 !== void 0 ? _ref34 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref33 !== void 0 ? _ref33 : null,
|
|
2672
|
-
amount:
|
|
2631
|
+
amount: _this14.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2673
2632
|
};
|
|
2674
2633
|
}))
|
|
2675
2634
|
};
|
|
@@ -2677,9 +2636,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2677
2636
|
}, {
|
|
2678
2637
|
key: "buildOrderProductsFingerprint",
|
|
2679
2638
|
value: function buildOrderProductsFingerprint(products) {
|
|
2680
|
-
var
|
|
2639
|
+
var _this15 = this;
|
|
2681
2640
|
var items = (products || []).map(function (product) {
|
|
2682
|
-
return
|
|
2641
|
+
return _this15.buildProductFingerprintItem(product);
|
|
2683
2642
|
});
|
|
2684
2643
|
items.sort(function (left, right) {
|
|
2685
2644
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2701,7 +2660,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2701
2660
|
_sku$barcode2,
|
|
2702
2661
|
_ref36,
|
|
2703
2662
|
_sku$variant_id2,
|
|
2704
|
-
|
|
2663
|
+
_this16 = this;
|
|
2664
|
+
var order = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.store.tempOrder || {};
|
|
2705
2665
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2706
2666
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2707
2667
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2717,12 +2677,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2717
2677
|
product_variant_id: (_product$product_vari2 = product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : null,
|
|
2718
2678
|
extension_type: extensionType,
|
|
2719
2679
|
num: getSafeProductNum((_product$num2 = product === null || product === void 0 ? void 0 : product.num) !== null && _product$num2 !== void 0 ? _product$num2 : product === null || product === void 0 ? void 0 : product.product_quantity),
|
|
2720
|
-
metadata: {
|
|
2680
|
+
metadata: _objectSpread({
|
|
2721
2681
|
unique_identification_number: (_ref35 = (_metadata$unique_iden = metadata.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref35 !== void 0 ? _ref35 : '',
|
|
2722
2682
|
price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
|
|
2723
2683
|
is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
|
|
2724
2684
|
product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
|
|
2725
|
-
},
|
|
2685
|
+
}, !hasProductBooking(product) ? {
|
|
2686
|
+
holder_relations: this.normalizeFingerprintValue(getProductHolderRelations(order, product))
|
|
2687
|
+
} : {}),
|
|
2726
2688
|
product_sku: this.normalizeFingerprintValue({
|
|
2727
2689
|
code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
|
|
2728
2690
|
barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
|
|
@@ -2735,7 +2697,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2735
2697
|
option_group_id: (_option$option_group_3 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_3 !== void 0 ? _option$option_group_3 : null,
|
|
2736
2698
|
option_group_item_id: (_ref38 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref38 !== void 0 ? _ref38 : null,
|
|
2737
2699
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
2738
|
-
add_price:
|
|
2700
|
+
add_price: _this16.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
|
|
2739
2701
|
};
|
|
2740
2702
|
})
|
|
2741
2703
|
}),
|
|
@@ -2749,14 +2711,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2749
2711
|
num: getSafeProductNum((_bundle$num2 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num2 !== void 0 ? _bundle$num2 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
|
|
2750
2712
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
2751
2713
|
price_type_ext: (_bundle$price_type_ex2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : '',
|
|
2752
|
-
option:
|
|
2714
|
+
option: _this16.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2753
2715
|
var _ref44, _option$id3, _option$option_group_5, _ref45, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2754
2716
|
return {
|
|
2755
2717
|
id: (_ref44 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref44 !== void 0 ? _ref44 : null,
|
|
2756
2718
|
option_group_id: (_option$option_group_5 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_5 !== void 0 ? _option$option_group_5 : null,
|
|
2757
2719
|
option_group_item_id: (_ref45 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref45 !== void 0 ? _ref45 : null,
|
|
2758
2720
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
2759
|
-
add_price:
|
|
2721
|
+
add_price: _this16.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
|
|
2760
2722
|
};
|
|
2761
2723
|
}))
|
|
2762
2724
|
};
|
|
@@ -2766,7 +2728,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2766
2728
|
return {
|
|
2767
2729
|
type: (_ref46 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref46 !== void 0 ? _ref46 : '',
|
|
2768
2730
|
discount_id: (_ref47 = (_ref48 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref48 !== void 0 ? _ref48 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref47 !== void 0 ? _ref47 : null,
|
|
2769
|
-
amount:
|
|
2731
|
+
amount: _this16.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2770
2732
|
};
|
|
2771
2733
|
}))
|
|
2772
2734
|
};
|
|
@@ -2774,9 +2736,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2774
2736
|
}, {
|
|
2775
2737
|
key: "buildOrderProductsStructuralFingerprint",
|
|
2776
2738
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
2777
|
-
var
|
|
2739
|
+
var _this17 = this;
|
|
2740
|
+
var order = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.store.tempOrder || {};
|
|
2778
2741
|
var items = (products || []).map(function (product) {
|
|
2779
|
-
return
|
|
2742
|
+
return _this17.buildProductStructuralFingerprintItem(product, order);
|
|
2780
2743
|
});
|
|
2781
2744
|
items.sort(function (left, right) {
|
|
2782
2745
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2862,7 +2825,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2862
2825
|
var manualDepositOverride = this.getManualDepositOverride(tempOrder);
|
|
2863
2826
|
if (currentFingerprint !== snapshot.productFingerprint) {
|
|
2864
2827
|
var currentStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(tempOrder.products);
|
|
2865
|
-
var snapshotStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(Array.isArray(snapshot.products) ? snapshot.products : []);
|
|
2828
|
+
var snapshotStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(Array.isArray(snapshot.products) ? snapshot.products : [], snapshot);
|
|
2866
2829
|
if (currentStructuralFingerprint !== snapshotStructuralFingerprint) return null;
|
|
2867
2830
|
}
|
|
2868
2831
|
var summary = _objectSpread(_objectSpread({}, createEmptySummary()), cloneDeep(snapshot.summary || {}));
|
|
@@ -3038,11 +3001,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3038
3001
|
value: function () {
|
|
3039
3002
|
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(tempOrder, options) {
|
|
3040
3003
|
var nextTempOrder;
|
|
3041
|
-
return _regeneratorRuntime().wrap(function _callee11$(
|
|
3042
|
-
while (1) switch (
|
|
3004
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context12) {
|
|
3005
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
3043
3006
|
case 0:
|
|
3044
3007
|
if (isTempOrder(tempOrder)) {
|
|
3045
|
-
|
|
3008
|
+
_context12.next = 2;
|
|
3046
3009
|
break;
|
|
3047
3010
|
}
|
|
3048
3011
|
throw new Error('无效的 tempOrder 数据');
|
|
@@ -3054,15 +3017,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3054
3017
|
this.store.tempOrder = nextTempOrder;
|
|
3055
3018
|
this.clearCustomerWalletRuntimeState();
|
|
3056
3019
|
if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
|
|
3057
|
-
|
|
3020
|
+
_context12.next = 11;
|
|
3058
3021
|
break;
|
|
3059
3022
|
}
|
|
3060
|
-
|
|
3023
|
+
_context12.next = 9;
|
|
3061
3024
|
return this.recalculateSummary({
|
|
3062
3025
|
createIfMissing: false
|
|
3063
3026
|
});
|
|
3064
3027
|
case 9:
|
|
3065
|
-
|
|
3028
|
+
_context12.next = 12;
|
|
3066
3029
|
break;
|
|
3067
3030
|
case 11:
|
|
3068
3031
|
this.store.summary = createEmptySummary();
|
|
@@ -3071,16 +3034,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3071
3034
|
this.persistTempOrder();
|
|
3072
3035
|
}
|
|
3073
3036
|
if (!(options !== null && options !== void 0 && options.saveDraft)) {
|
|
3074
|
-
|
|
3037
|
+
_context12.next = 16;
|
|
3075
3038
|
break;
|
|
3076
3039
|
}
|
|
3077
|
-
|
|
3040
|
+
_context12.next = 16;
|
|
3078
3041
|
return this.saveDraft();
|
|
3079
3042
|
case 16:
|
|
3080
|
-
return
|
|
3043
|
+
return _context12.abrupt("return", nextTempOrder);
|
|
3081
3044
|
case 17:
|
|
3082
3045
|
case "end":
|
|
3083
|
-
return
|
|
3046
|
+
return _context12.stop();
|
|
3084
3047
|
}
|
|
3085
3048
|
}, _callee11, this);
|
|
3086
3049
|
}));
|
|
@@ -3172,28 +3135,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3172
3135
|
value: function () {
|
|
3173
3136
|
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
3174
3137
|
var tempOrder;
|
|
3175
|
-
return _regeneratorRuntime().wrap(function _callee12$(
|
|
3176
|
-
while (1) switch (
|
|
3138
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context13) {
|
|
3139
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
3177
3140
|
case 0:
|
|
3178
3141
|
tempOrder = this.ensureTempOrder();
|
|
3179
3142
|
this.ensureExternalSaleNumber(tempOrder);
|
|
3180
|
-
|
|
3143
|
+
_context13.next = 4;
|
|
3181
3144
|
return this.recalculateSummary({
|
|
3182
3145
|
createIfMissing: true
|
|
3183
3146
|
});
|
|
3184
3147
|
case 4:
|
|
3185
3148
|
this.persistTempOrder();
|
|
3186
3149
|
if (!this.draftPersistEnabled) {
|
|
3187
|
-
|
|
3150
|
+
_context13.next = 8;
|
|
3188
3151
|
break;
|
|
3189
3152
|
}
|
|
3190
|
-
|
|
3153
|
+
_context13.next = 8;
|
|
3191
3154
|
return this.saveDraft();
|
|
3192
3155
|
case 8:
|
|
3193
|
-
return
|
|
3156
|
+
return _context13.abrupt("return", tempOrder);
|
|
3194
3157
|
case 9:
|
|
3195
3158
|
case "end":
|
|
3196
|
-
return
|
|
3159
|
+
return _context13.stop();
|
|
3197
3160
|
}
|
|
3198
3161
|
}, _callee12, this);
|
|
3199
3162
|
}));
|
|
@@ -3220,17 +3183,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3220
3183
|
}, {
|
|
3221
3184
|
key: "sanitizeOrderProductForTempOrder",
|
|
3222
3185
|
value: function sanitizeOrderProductForTempOrder(product) {
|
|
3186
|
+
var _product$_extend;
|
|
3187
|
+
var deferHolderCleanup = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3223
3188
|
if (product.metadata && _typeof(product.metadata) === 'object') {
|
|
3224
3189
|
delete product.metadata.origin;
|
|
3190
|
+
if (!deferHolderCleanup && !hasProductBooking(product)) {
|
|
3191
|
+
delete product.metadata.holder;
|
|
3192
|
+
delete product.metadata.holder_id;
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
if (((_product$_extend = product._extend) === null || _product$_extend === void 0 ? void 0 : _product$_extend.holder_relations) !== undefined) {
|
|
3196
|
+
delete product._extend.holder_relations;
|
|
3225
3197
|
}
|
|
3226
3198
|
return product;
|
|
3227
3199
|
}
|
|
3228
3200
|
}, {
|
|
3229
3201
|
key: "sanitizeTempOrderProducts",
|
|
3230
3202
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
3231
|
-
var
|
|
3203
|
+
var _this18 = this;
|
|
3232
3204
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
3233
|
-
return
|
|
3205
|
+
return _this18.sanitizeOrderProductForTempOrder(_this18.normalizeVirtualSettlementProductIfEnabled(product));
|
|
3234
3206
|
});
|
|
3235
3207
|
this.syncTempOrderSettlementState(tempOrder);
|
|
3236
3208
|
ensureUniqueProductLineUids(tempOrder);
|
|
@@ -3350,7 +3322,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3350
3322
|
}, {
|
|
3351
3323
|
key: "syncLinkedBookingHoldersToProducts",
|
|
3352
3324
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
3353
|
-
var
|
|
3325
|
+
var _this19 = this;
|
|
3354
3326
|
var bookings = tempOrder.bookings || [];
|
|
3355
3327
|
var products = tempOrder.products || [];
|
|
3356
3328
|
if (!bookings.length || !products.length) return;
|
|
@@ -3376,7 +3348,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3376
3348
|
var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
|
|
3377
3349
|
var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
|
|
3378
3350
|
if (linkedBooking) {
|
|
3379
|
-
|
|
3351
|
+
_this19.setProductHolderFromBooking(product, linkedBooking);
|
|
3380
3352
|
}
|
|
3381
3353
|
});
|
|
3382
3354
|
}
|
|
@@ -3507,9 +3479,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3507
3479
|
}, {
|
|
3508
3480
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
3509
3481
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
3510
|
-
var
|
|
3482
|
+
var _this20 = this;
|
|
3511
3483
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
3512
|
-
return
|
|
3484
|
+
return _this20.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
3513
3485
|
});
|
|
3514
3486
|
}
|
|
3515
3487
|
}, {
|
|
@@ -3517,13 +3489,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3517
3489
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
3518
3490
|
var _product$metadata5,
|
|
3519
3491
|
_product$metadata6,
|
|
3520
|
-
|
|
3492
|
+
_this21 = this;
|
|
3521
3493
|
var productUid = (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
3522
3494
|
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
|
|
3523
3495
|
if (!productUid && !bookingUid) return;
|
|
3524
3496
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
3525
3497
|
if (isFulfillmentTimingBooking(booking)) return true;
|
|
3526
|
-
var currentBookingUid =
|
|
3498
|
+
var currentBookingUid = _this21.getBookingUniqueIdentificationNumber(booking);
|
|
3527
3499
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
3528
3500
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
3529
3501
|
return true;
|
|
@@ -3572,21 +3544,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3572
3544
|
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(options) {
|
|
3573
3545
|
var _this$otherParams3, _ref53, _salesSummaryResult$e;
|
|
3574
3546
|
var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, summaryMutationBaseline, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
3575
|
-
return _regeneratorRuntime().wrap(function _callee13$(
|
|
3576
|
-
while (1) switch (
|
|
3547
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context14) {
|
|
3548
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
3577
3549
|
case 0:
|
|
3578
3550
|
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
3579
|
-
|
|
3551
|
+
_context14.next = 2;
|
|
3580
3552
|
break;
|
|
3581
3553
|
}
|
|
3582
|
-
return
|
|
3554
|
+
return _context14.abrupt("return", null);
|
|
3583
3555
|
case 2:
|
|
3584
3556
|
tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
|
|
3585
3557
|
if (tempOrder) {
|
|
3586
|
-
|
|
3558
|
+
_context14.next = 5;
|
|
3587
3559
|
break;
|
|
3588
3560
|
}
|
|
3589
|
-
return
|
|
3561
|
+
return _context14.abrupt("return", null);
|
|
3590
3562
|
case 5:
|
|
3591
3563
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3592
3564
|
originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
@@ -3594,10 +3566,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3594
3566
|
shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
|
|
3595
3567
|
snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
|
|
3596
3568
|
if (!snapshotSummary) {
|
|
3597
|
-
|
|
3569
|
+
_context14.next = 12;
|
|
3598
3570
|
break;
|
|
3599
3571
|
}
|
|
3600
|
-
return
|
|
3572
|
+
return _context14.abrupt("return", snapshotSummary);
|
|
3601
3573
|
case 12:
|
|
3602
3574
|
shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
|
|
3603
3575
|
summaryProducts = shouldFullRecalculateFromSnapshot || options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep(tempOrder.products || []) : tempOrder.products;
|
|
@@ -3609,7 +3581,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3609
3581
|
totalRefundAmount = existedSummary.total_refund_amount || '0.00';
|
|
3610
3582
|
paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
3611
3583
|
if (salesSummary) {
|
|
3612
|
-
|
|
3584
|
+
_context14.next = 28;
|
|
3613
3585
|
break;
|
|
3614
3586
|
}
|
|
3615
3587
|
emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
|
|
@@ -3635,13 +3607,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3635
3607
|
previousSummary: existedSummary,
|
|
3636
3608
|
summary: emptySummary
|
|
3637
3609
|
});
|
|
3638
|
-
return
|
|
3610
|
+
return _context14.abrupt("return", this.store.summary);
|
|
3639
3611
|
case 28:
|
|
3640
3612
|
summaryMutationBaseline = options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep({
|
|
3641
3613
|
tempOrder: tempOrder,
|
|
3642
3614
|
summary: this.store.summary
|
|
3643
3615
|
}) : null;
|
|
3644
|
-
|
|
3616
|
+
_context14.next = 31;
|
|
3645
3617
|
return salesSummary.getSummary(_objectSpread({
|
|
3646
3618
|
products: summaryProducts,
|
|
3647
3619
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
@@ -3651,21 +3623,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3651
3623
|
channel: this.otherParams.channel
|
|
3652
3624
|
} : {}));
|
|
3653
3625
|
case 31:
|
|
3654
|
-
salesSummaryResult =
|
|
3626
|
+
salesSummaryResult = _context14.sent;
|
|
3655
3627
|
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
3656
|
-
|
|
3628
|
+
_context14.next = 34;
|
|
3657
3629
|
break;
|
|
3658
3630
|
}
|
|
3659
|
-
return
|
|
3631
|
+
return _context14.abrupt("return", null);
|
|
3660
3632
|
case 34:
|
|
3661
3633
|
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !isEqual({
|
|
3662
3634
|
tempOrder: tempOrder,
|
|
3663
3635
|
summary: this.store.summary
|
|
3664
3636
|
}, summaryMutationBaseline))) {
|
|
3665
|
-
|
|
3637
|
+
_context14.next = 36;
|
|
3666
3638
|
break;
|
|
3667
3639
|
}
|
|
3668
|
-
return
|
|
3640
|
+
return _context14.abrupt("return", null);
|
|
3669
3641
|
case 36:
|
|
3670
3642
|
if (shouldFullRecalculateFromSnapshot || options !== null && options !== void 0 && options.isCurrentOrder) {
|
|
3671
3643
|
tempOrder.products = summaryProducts;
|
|
@@ -3711,10 +3683,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3711
3683
|
previousSummary: existedSummary,
|
|
3712
3684
|
summary: summary
|
|
3713
3685
|
});
|
|
3714
|
-
return
|
|
3686
|
+
return _context14.abrupt("return", this.store.summary);
|
|
3715
3687
|
case 53:
|
|
3716
3688
|
case "end":
|
|
3717
|
-
return
|
|
3689
|
+
return _context14.stop();
|
|
3718
3690
|
}
|
|
3719
3691
|
}, _callee13, this);
|
|
3720
3692
|
}));
|
|
@@ -3728,26 +3700,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3728
3700
|
value: function () {
|
|
3729
3701
|
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
3730
3702
|
var summary;
|
|
3731
|
-
return _regeneratorRuntime().wrap(function _callee14$(
|
|
3732
|
-
while (1) switch (
|
|
3703
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context15) {
|
|
3704
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
3733
3705
|
case 0:
|
|
3734
|
-
|
|
3706
|
+
_context15.next = 2;
|
|
3735
3707
|
return this.recalculateSummary({
|
|
3736
3708
|
createIfMissing: true
|
|
3737
3709
|
});
|
|
3738
3710
|
case 2:
|
|
3739
|
-
summary =
|
|
3711
|
+
summary = _context15.sent;
|
|
3740
3712
|
if (summary) {
|
|
3741
|
-
|
|
3713
|
+
_context15.next = 5;
|
|
3742
3714
|
break;
|
|
3743
3715
|
}
|
|
3744
|
-
return
|
|
3716
|
+
return _context15.abrupt("return", createEmptySummary());
|
|
3745
3717
|
case 5:
|
|
3746
3718
|
this.persistTempOrder();
|
|
3747
|
-
return
|
|
3719
|
+
return _context15.abrupt("return", summary);
|
|
3748
3720
|
case 7:
|
|
3749
3721
|
case "end":
|
|
3750
|
-
return
|
|
3722
|
+
return _context15.stop();
|
|
3751
3723
|
}
|
|
3752
3724
|
}, _callee14, this);
|
|
3753
3725
|
}));
|
|
@@ -3774,18 +3746,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3774
3746
|
key: "syncTempOrderNoteToRemote",
|
|
3775
3747
|
value: function () {
|
|
3776
3748
|
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderId, note) {
|
|
3777
|
-
return _regeneratorRuntime().wrap(function _callee15$(
|
|
3778
|
-
while (1) switch (
|
|
3749
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context16) {
|
|
3750
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
3779
3751
|
case 0:
|
|
3780
|
-
|
|
3752
|
+
_context16.next = 2;
|
|
3781
3753
|
return this.request.put("/order/order/".concat(orderId, "/note"), {
|
|
3782
3754
|
note: note
|
|
3783
3755
|
});
|
|
3784
3756
|
case 2:
|
|
3785
|
-
return
|
|
3757
|
+
return _context16.abrupt("return", note);
|
|
3786
3758
|
case 3:
|
|
3787
3759
|
case "end":
|
|
3788
|
-
return
|
|
3760
|
+
return _context16.stop();
|
|
3789
3761
|
}
|
|
3790
3762
|
}, _callee15, this);
|
|
3791
3763
|
}));
|
|
@@ -3850,7 +3822,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3850
3822
|
}, {
|
|
3851
3823
|
key: "removeSalesNotesForMissingProductLines",
|
|
3852
3824
|
value: function removeSalesNotesForMissingProductLines(tempOrder) {
|
|
3853
|
-
var
|
|
3825
|
+
var _this22 = this;
|
|
3854
3826
|
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3855
3827
|
if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
|
|
3856
3828
|
return;
|
|
@@ -3862,7 +3834,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3862
3834
|
return typeof uid === 'string' && uid.length > 0;
|
|
3863
3835
|
}));
|
|
3864
3836
|
var nextNotes = tempOrder.notes.filter(function (note) {
|
|
3865
|
-
var primary =
|
|
3837
|
+
var primary = _this22.getSalesNotePrimaryRelation(note);
|
|
3866
3838
|
if (!primary || primary.target_type !== 'order_detail') return true;
|
|
3867
3839
|
return remainingProductUids.has(primary.target_uuid);
|
|
3868
3840
|
});
|
|
@@ -3874,7 +3846,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3874
3846
|
key: "setSalesNoteOnTempOrder",
|
|
3875
3847
|
value: function setSalesNoteOnTempOrder(tempOrder, input) {
|
|
3876
3848
|
var _input$target,
|
|
3877
|
-
|
|
3849
|
+
_this23 = this,
|
|
3878
3850
|
_tempOrder$shop_order;
|
|
3879
3851
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
3880
3852
|
var note_type = String(input.note_type || '').trim();
|
|
@@ -3898,7 +3870,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3898
3870
|
var notes = tempOrder.notes || [];
|
|
3899
3871
|
// 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
|
|
3900
3872
|
var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
|
|
3901
|
-
var primary =
|
|
3873
|
+
var primary = _this23.getSalesNotePrimaryRelation(note);
|
|
3902
3874
|
return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
|
|
3903
3875
|
}) : -1;
|
|
3904
3876
|
var existing = existingIndex >= 0 ? notes[existingIndex] : null;
|
|
@@ -3992,16 +3964,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3992
3964
|
value: function () {
|
|
3993
3965
|
var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(input) {
|
|
3994
3966
|
var tempOrder, note;
|
|
3995
|
-
return _regeneratorRuntime().wrap(function _callee16$(
|
|
3996
|
-
while (1) switch (
|
|
3967
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context17) {
|
|
3968
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
3997
3969
|
case 0:
|
|
3998
3970
|
tempOrder = this.ensureTempOrder();
|
|
3999
3971
|
note = this.setSalesNoteOnTempOrder(tempOrder, input);
|
|
4000
3972
|
this.notifyTempOrderChanged();
|
|
4001
|
-
return
|
|
3973
|
+
return _context17.abrupt("return", cloneDeep(note));
|
|
4002
3974
|
case 4:
|
|
4003
3975
|
case "end":
|
|
4004
|
-
return
|
|
3976
|
+
return _context17.stop();
|
|
4005
3977
|
}
|
|
4006
3978
|
}, _callee16, this);
|
|
4007
3979
|
}));
|
|
@@ -4015,8 +3987,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4015
3987
|
value: function () {
|
|
4016
3988
|
var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(uuid) {
|
|
4017
3989
|
var tempOrder, normalizedUuid, notes, nextNotes, state;
|
|
4018
|
-
return _regeneratorRuntime().wrap(function _callee17$(
|
|
4019
|
-
while (1) switch (
|
|
3990
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context18) {
|
|
3991
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
4020
3992
|
case 0:
|
|
4021
3993
|
tempOrder = this.ensureTempOrder();
|
|
4022
3994
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
@@ -4026,10 +3998,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4026
3998
|
return note.uuid !== normalizedUuid;
|
|
4027
3999
|
});
|
|
4028
4000
|
if (!(nextNotes.length === notes.length)) {
|
|
4029
|
-
|
|
4001
|
+
_context18.next = 7;
|
|
4030
4002
|
break;
|
|
4031
4003
|
}
|
|
4032
|
-
return
|
|
4004
|
+
return _context18.abrupt("return");
|
|
4033
4005
|
case 7:
|
|
4034
4006
|
tempOrder.notes = nextNotes;
|
|
4035
4007
|
state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
@@ -4037,7 +4009,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4037
4009
|
this.notifyTempOrderChanged();
|
|
4038
4010
|
case 11:
|
|
4039
4011
|
case "end":
|
|
4040
|
-
return
|
|
4012
|
+
return _context18.stop();
|
|
4041
4013
|
}
|
|
4042
4014
|
}, _callee17, this);
|
|
4043
4015
|
}));
|
|
@@ -4051,8 +4023,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4051
4023
|
value: function () {
|
|
4052
4024
|
var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
4053
4025
|
var tempOrder, state;
|
|
4054
|
-
return _regeneratorRuntime().wrap(function _callee18$(
|
|
4055
|
-
while (1) switch (
|
|
4026
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context19) {
|
|
4027
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
4056
4028
|
case 0:
|
|
4057
4029
|
tempOrder = this.ensureTempOrder();
|
|
4058
4030
|
tempOrder.notes = [];
|
|
@@ -4062,7 +4034,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4062
4034
|
this.notifyTempOrderChanged();
|
|
4063
4035
|
case 6:
|
|
4064
4036
|
case "end":
|
|
4065
|
-
return
|
|
4037
|
+
return _context19.stop();
|
|
4066
4038
|
}
|
|
4067
4039
|
}, _callee18, this);
|
|
4068
4040
|
}));
|
|
@@ -4217,15 +4189,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4217
4189
|
}, {
|
|
4218
4190
|
key: "productHasCustomerBoundDiscount",
|
|
4219
4191
|
value: function productHasCustomerBoundDiscount(product) {
|
|
4220
|
-
var
|
|
4192
|
+
var _this24 = this;
|
|
4221
4193
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
4222
|
-
return
|
|
4194
|
+
return _this24.isCustomerBoundDiscount(discount);
|
|
4223
4195
|
})) {
|
|
4224
4196
|
return true;
|
|
4225
4197
|
}
|
|
4226
4198
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
4227
4199
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
4228
|
-
return
|
|
4200
|
+
return _this24.isCustomerBoundDiscount(discount);
|
|
4229
4201
|
});
|
|
4230
4202
|
});
|
|
4231
4203
|
}
|
|
@@ -4234,18 +4206,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4234
4206
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
4235
4207
|
var _this$store$discount20,
|
|
4236
4208
|
_this$store$discount21,
|
|
4237
|
-
|
|
4209
|
+
_this25 = this;
|
|
4238
4210
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
4239
4211
|
var discountList = ((_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 || (_this$store$discount21 = _this$store$discount20.getDiscountList) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.call(_this$store$discount20)) || [];
|
|
4240
4212
|
if (discountList.length > 0) return false;
|
|
4241
4213
|
return !(tempOrder.products || []).some(function (product) {
|
|
4242
|
-
return
|
|
4214
|
+
return _this25.productHasCustomerBoundDiscount(product);
|
|
4243
4215
|
});
|
|
4244
4216
|
}
|
|
4245
4217
|
}, {
|
|
4246
4218
|
key: "clearCustomerBoundDiscounts",
|
|
4247
4219
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
4248
|
-
var
|
|
4220
|
+
var _this26 = this,
|
|
4249
4221
|
_discountModule$getDi,
|
|
4250
4222
|
_discountModule$getOr,
|
|
4251
4223
|
_discountModule$setDi,
|
|
@@ -4254,7 +4226,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4254
4226
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
4255
4227
|
if (!Array.isArray(discountList)) return [];
|
|
4256
4228
|
return discountList.filter(function (discount) {
|
|
4257
|
-
var shouldRemove =
|
|
4229
|
+
var shouldRemove = _this26.isCustomerBoundDiscount(discount);
|
|
4258
4230
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
4259
4231
|
return !shouldRemove;
|
|
4260
4232
|
});
|
|
@@ -4281,12 +4253,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4281
4253
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
4282
4254
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
4283
4255
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
4284
|
-
if (
|
|
4285
|
-
return !
|
|
4256
|
+
if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4257
|
+
return !_this26.isCustomerBoundDiscount(discount);
|
|
4286
4258
|
});
|
|
4287
4259
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
4288
|
-
if (
|
|
4289
|
-
return !
|
|
4260
|
+
if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4261
|
+
return !_this26.isCustomerBoundDiscount(discount);
|
|
4290
4262
|
});
|
|
4291
4263
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
4292
4264
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -4322,6 +4294,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4322
4294
|
var nextCustomerId = (_tempOrder$customer_i4 = tempOrder.customer_id) !== null && _tempOrder$customer_i4 !== void 0 ? _tempOrder$customer_i4 : null;
|
|
4323
4295
|
if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
|
|
4324
4296
|
this.clearCustomerWalletState(tempOrder);
|
|
4297
|
+
removeProductHolderRelations(tempOrder, tempOrder.products.filter(function (product) {
|
|
4298
|
+
return !hasProductBooking(product);
|
|
4299
|
+
}));
|
|
4325
4300
|
}
|
|
4326
4301
|
this.persistTempOrder();
|
|
4327
4302
|
return {
|
|
@@ -4450,10 +4425,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4450
4425
|
}, {
|
|
4451
4426
|
key: "setOrderPayments",
|
|
4452
4427
|
value: function setOrderPayments(payments) {
|
|
4453
|
-
var
|
|
4428
|
+
var _this27 = this;
|
|
4454
4429
|
var tempOrder = this.ensureTempOrder();
|
|
4455
4430
|
tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
|
|
4456
|
-
return
|
|
4431
|
+
return _this27.normalizePaymentSource(payment, {
|
|
4457
4432
|
defaultPaid: false
|
|
4458
4433
|
});
|
|
4459
4434
|
}));
|
|
@@ -4475,28 +4450,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4475
4450
|
value: (function () {
|
|
4476
4451
|
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(payment) {
|
|
4477
4452
|
var hasPaymentNumber, devicePrefix;
|
|
4478
|
-
return _regeneratorRuntime().wrap(function _callee19$(
|
|
4479
|
-
while (1) switch (
|
|
4453
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context20) {
|
|
4454
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
4480
4455
|
case 0:
|
|
4481
4456
|
hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
|
|
4482
4457
|
if (!hasPaymentNumber) {
|
|
4483
|
-
|
|
4458
|
+
_context20.next = 5;
|
|
4484
4459
|
break;
|
|
4485
4460
|
}
|
|
4486
|
-
|
|
4487
|
-
|
|
4461
|
+
_context20.t0 = 'LOCAL';
|
|
4462
|
+
_context20.next = 8;
|
|
4488
4463
|
break;
|
|
4489
4464
|
case 5:
|
|
4490
|
-
|
|
4465
|
+
_context20.next = 7;
|
|
4491
4466
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
4492
4467
|
case 7:
|
|
4493
|
-
|
|
4468
|
+
_context20.t0 = _context20.sent;
|
|
4494
4469
|
case 8:
|
|
4495
|
-
devicePrefix =
|
|
4496
|
-
return
|
|
4470
|
+
devicePrefix = _context20.t0;
|
|
4471
|
+
return _context20.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
4497
4472
|
case 10:
|
|
4498
4473
|
case "end":
|
|
4499
|
-
return
|
|
4474
|
+
return _context20.stop();
|
|
4500
4475
|
}
|
|
4501
4476
|
}, _callee19, this);
|
|
4502
4477
|
}));
|
|
@@ -4508,7 +4483,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4508
4483
|
}, {
|
|
4509
4484
|
key: "addOrderPaymentWithDevicePrefix",
|
|
4510
4485
|
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
4511
|
-
var
|
|
4486
|
+
var _this28 = this;
|
|
4512
4487
|
this.logInfo('addOrderPayment', {
|
|
4513
4488
|
payment: payment
|
|
4514
4489
|
});
|
|
@@ -4526,7 +4501,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4526
4501
|
void this.recalculateSummary({
|
|
4527
4502
|
createIfMissing: true
|
|
4528
4503
|
}).catch(function (error) {
|
|
4529
|
-
|
|
4504
|
+
_this28.logError('recalculate summary after addOrderPayment failed', {
|
|
4530
4505
|
error: error instanceof Error ? error.message : String(error)
|
|
4531
4506
|
});
|
|
4532
4507
|
});
|
|
@@ -4551,17 +4526,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4551
4526
|
updatedPayment,
|
|
4552
4527
|
summary,
|
|
4553
4528
|
payments,
|
|
4554
|
-
|
|
4555
|
-
return _regeneratorRuntime().wrap(function _callee20$(
|
|
4556
|
-
while (1) switch (
|
|
4529
|
+
_args21 = arguments;
|
|
4530
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context21) {
|
|
4531
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
4557
4532
|
case 0:
|
|
4558
|
-
options =
|
|
4533
|
+
options = _args21.length > 2 && _args21[2] !== undefined ? _args21[2] : {};
|
|
4559
4534
|
tempOrder = this.ensureTempOrder();
|
|
4560
4535
|
identity = String(paymentIdentity);
|
|
4561
4536
|
matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
|
|
4562
4537
|
matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
|
|
4563
4538
|
if (matchedPayment) {
|
|
4564
|
-
|
|
4539
|
+
_context21.next = 8;
|
|
4565
4540
|
break;
|
|
4566
4541
|
}
|
|
4567
4542
|
try {
|
|
@@ -4590,15 +4565,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4590
4565
|
return nextPayment;
|
|
4591
4566
|
});
|
|
4592
4567
|
this.persistTempOrder();
|
|
4593
|
-
|
|
4568
|
+
_context21.next = 13;
|
|
4594
4569
|
return this.recalculateSummary({
|
|
4595
4570
|
createIfMissing: true
|
|
4596
4571
|
});
|
|
4597
4572
|
case 13:
|
|
4598
|
-
summary =
|
|
4573
|
+
summary = _context21.sent;
|
|
4599
4574
|
this.persistTempOrder();
|
|
4600
4575
|
payments = tempOrder.payments;
|
|
4601
|
-
return
|
|
4576
|
+
return _context21.abrupt("return", {
|
|
4602
4577
|
updated: true,
|
|
4603
4578
|
payment: payments[matchedPayment.index] || updatedPayment,
|
|
4604
4579
|
payments: payments,
|
|
@@ -4606,7 +4581,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4606
4581
|
});
|
|
4607
4582
|
case 17:
|
|
4608
4583
|
case "end":
|
|
4609
|
-
return
|
|
4584
|
+
return _context21.stop();
|
|
4610
4585
|
}
|
|
4611
4586
|
}, _callee20, this);
|
|
4612
4587
|
}));
|
|
@@ -4655,7 +4630,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4655
4630
|
}, {
|
|
4656
4631
|
key: "applyPaymentLifecycleChange",
|
|
4657
4632
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
4658
|
-
var
|
|
4633
|
+
var _this29 = this;
|
|
4659
4634
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
4660
4635
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
4661
4636
|
this.persistTempOrder();
|
|
@@ -4665,7 +4640,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4665
4640
|
void this.recalculateSummary({
|
|
4666
4641
|
createIfMissing: true
|
|
4667
4642
|
}).catch(function (error) {
|
|
4668
|
-
|
|
4643
|
+
_this29.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
4669
4644
|
error: error instanceof Error ? error.message : String(error)
|
|
4670
4645
|
});
|
|
4671
4646
|
});
|
|
@@ -4709,7 +4684,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4709
4684
|
}, {
|
|
4710
4685
|
key: "updateVoucherOrderPayments",
|
|
4711
4686
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
4712
|
-
var
|
|
4687
|
+
var _this30 = this;
|
|
4713
4688
|
var tempOrder = this.ensureTempOrder();
|
|
4714
4689
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
4715
4690
|
return value === 'normal' || value === 'deposit';
|
|
@@ -4744,7 +4719,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4744
4719
|
});
|
|
4745
4720
|
};
|
|
4746
4721
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
4747
|
-
return
|
|
4722
|
+
return _this30.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
4748
4723
|
defaultPaid: false,
|
|
4749
4724
|
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
4750
4725
|
});
|
|
@@ -4797,7 +4772,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4797
4772
|
void this.recalculateSummary({
|
|
4798
4773
|
createIfMissing: true
|
|
4799
4774
|
}).catch(function (error) {
|
|
4800
|
-
|
|
4775
|
+
_this30.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
4801
4776
|
error: error instanceof Error ? error.message : String(error)
|
|
4802
4777
|
});
|
|
4803
4778
|
});
|
|
@@ -4808,32 +4783,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4808
4783
|
value: function () {
|
|
4809
4784
|
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(payments, options) {
|
|
4810
4785
|
var needsPaymentNumber, devicePrefix;
|
|
4811
|
-
return _regeneratorRuntime().wrap(function _callee21$(
|
|
4812
|
-
while (1) switch (
|
|
4786
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context22) {
|
|
4787
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
4813
4788
|
case 0:
|
|
4814
4789
|
needsPaymentNumber = (payments || []).some(function (payment) {
|
|
4815
4790
|
return String(payment.payment_number || '').trim() === '';
|
|
4816
4791
|
});
|
|
4817
4792
|
if (!needsPaymentNumber) {
|
|
4818
|
-
|
|
4793
|
+
_context22.next = 7;
|
|
4819
4794
|
break;
|
|
4820
4795
|
}
|
|
4821
|
-
|
|
4796
|
+
_context22.next = 4;
|
|
4822
4797
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
4823
4798
|
case 4:
|
|
4824
|
-
|
|
4825
|
-
|
|
4799
|
+
_context22.t0 = _context22.sent;
|
|
4800
|
+
_context22.next = 8;
|
|
4826
4801
|
break;
|
|
4827
4802
|
case 7:
|
|
4828
|
-
|
|
4803
|
+
_context22.t0 = 'LOCAL';
|
|
4829
4804
|
case 8:
|
|
4830
|
-
devicePrefix =
|
|
4831
|
-
return
|
|
4805
|
+
devicePrefix = _context22.t0;
|
|
4806
|
+
return _context22.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
|
|
4832
4807
|
devicePrefix: devicePrefix
|
|
4833
4808
|
})));
|
|
4834
4809
|
case 10:
|
|
4835
4810
|
case "end":
|
|
4836
|
-
return
|
|
4811
|
+
return _context22.stop();
|
|
4837
4812
|
}
|
|
4838
4813
|
}, _callee21, this);
|
|
4839
4814
|
}));
|
|
@@ -4855,7 +4830,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4855
4830
|
key: "shouldMergeProductToOrder",
|
|
4856
4831
|
value: function shouldMergeProductToOrder(params) {
|
|
4857
4832
|
var _this$orderHooks3,
|
|
4858
|
-
|
|
4833
|
+
_this31 = this;
|
|
4859
4834
|
var onBeforeMergeProductToOrder = (_this$orderHooks3 = this.orderHooks) === null || _this$orderHooks3 === void 0 ? void 0 : _this$orderHooks3.onBeforeMergeProductToOrder;
|
|
4860
4835
|
if (!onBeforeMergeProductToOrder) return true;
|
|
4861
4836
|
var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -4863,7 +4838,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4863
4838
|
}));
|
|
4864
4839
|
if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
|
|
4865
4840
|
return Promise.resolve(result).then(function (resolved) {
|
|
4866
|
-
return
|
|
4841
|
+
return _this31.normalizeShouldMergeProductResult(resolved);
|
|
4867
4842
|
});
|
|
4868
4843
|
}
|
|
4869
4844
|
return this.normalizeShouldMergeProductResult(result);
|
|
@@ -4994,77 +4969,77 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4994
4969
|
value: function () {
|
|
4995
4970
|
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(tempOrder, options) {
|
|
4996
4971
|
var isCurrentOrder, isVirtualSettlement, promotionPayload, summary;
|
|
4997
|
-
return _regeneratorRuntime().wrap(function _callee22$(
|
|
4998
|
-
while (1) switch (
|
|
4972
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context23) {
|
|
4973
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
4999
4974
|
case 0:
|
|
5000
4975
|
isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
|
|
5001
4976
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
5002
|
-
|
|
4977
|
+
_context23.next = 3;
|
|
5003
4978
|
break;
|
|
5004
4979
|
}
|
|
5005
|
-
return
|
|
4980
|
+
return _context23.abrupt("return");
|
|
5006
4981
|
case 3:
|
|
5007
4982
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
5008
4983
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
5009
4984
|
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
5010
4985
|
if (!(!(options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) && !isVirtualSettlement)) {
|
|
5011
|
-
|
|
4986
|
+
_context23.next = 9;
|
|
5012
4987
|
break;
|
|
5013
4988
|
}
|
|
5014
|
-
|
|
4989
|
+
_context23.next = 9;
|
|
5015
4990
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
5016
4991
|
case 9:
|
|
5017
4992
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
5018
|
-
|
|
4993
|
+
_context23.next = 11;
|
|
5019
4994
|
break;
|
|
5020
4995
|
}
|
|
5021
|
-
return
|
|
4996
|
+
return _context23.abrupt("return");
|
|
5022
4997
|
case 11:
|
|
5023
4998
|
if (!(!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement)) {
|
|
5024
|
-
|
|
4999
|
+
_context23.next = 17;
|
|
5025
5000
|
break;
|
|
5026
5001
|
}
|
|
5027
|
-
|
|
5002
|
+
_context23.next = 14;
|
|
5028
5003
|
return this.evaluatePromotion(isCurrentOrder ? {
|
|
5029
5004
|
isCurrentOrder: isCurrentOrder
|
|
5030
5005
|
} : undefined);
|
|
5031
5006
|
case 14:
|
|
5032
|
-
|
|
5033
|
-
|
|
5007
|
+
_context23.t0 = _context23.sent;
|
|
5008
|
+
_context23.next = 18;
|
|
5034
5009
|
break;
|
|
5035
5010
|
case 17:
|
|
5036
|
-
|
|
5011
|
+
_context23.t0 = null;
|
|
5037
5012
|
case 18:
|
|
5038
|
-
promotionPayload =
|
|
5013
|
+
promotionPayload = _context23.t0;
|
|
5039
5014
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
5040
|
-
|
|
5015
|
+
_context23.next = 21;
|
|
5041
5016
|
break;
|
|
5042
5017
|
}
|
|
5043
|
-
return
|
|
5018
|
+
return _context23.abrupt("return");
|
|
5044
5019
|
case 21:
|
|
5045
5020
|
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement) {
|
|
5046
5021
|
this.applyDiscount();
|
|
5047
5022
|
}
|
|
5048
5023
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5049
|
-
|
|
5024
|
+
_context23.next = 25;
|
|
5050
5025
|
return this.recalculateSummary(_objectSpread({
|
|
5051
5026
|
createIfMissing: true
|
|
5052
5027
|
}, isCurrentOrder ? {
|
|
5053
5028
|
isCurrentOrder: isCurrentOrder
|
|
5054
5029
|
} : {}));
|
|
5055
5030
|
case 25:
|
|
5056
|
-
summary =
|
|
5031
|
+
summary = _context23.sent;
|
|
5057
5032
|
if (!(isCurrentOrder && (!isCurrentOrder() || !summary))) {
|
|
5058
|
-
|
|
5033
|
+
_context23.next = 28;
|
|
5059
5034
|
break;
|
|
5060
5035
|
}
|
|
5061
|
-
return
|
|
5036
|
+
return _context23.abrupt("return");
|
|
5062
5037
|
case 28:
|
|
5063
5038
|
this.persistTempOrder();
|
|
5064
5039
|
this.emitPromotionApplied(promotionPayload);
|
|
5065
5040
|
case 30:
|
|
5066
5041
|
case "end":
|
|
5067
|
-
return
|
|
5042
|
+
return _context23.stop();
|
|
5068
5043
|
}
|
|
5069
5044
|
}, _callee22, this);
|
|
5070
5045
|
}));
|
|
@@ -5092,9 +5067,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5092
5067
|
_normalizedIncoming$p2,
|
|
5093
5068
|
_booking_uid,
|
|
5094
5069
|
_metadata,
|
|
5070
|
+
_productToAdd$_extend,
|
|
5095
5071
|
_productToAdd$metadat,
|
|
5096
5072
|
_origin,
|
|
5097
|
-
|
|
5073
|
+
_this32 = this;
|
|
5098
5074
|
var linked = booking ? this.createLinkedProductAndBooking({
|
|
5099
5075
|
product: product,
|
|
5100
5076
|
booking: booking
|
|
@@ -5126,29 +5102,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5126
5102
|
var hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
|
|
5127
5103
|
var hasIncomingManualProductDiscount = isManualProductDiscountProduct(normalizedIncoming);
|
|
5128
5104
|
var hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
5105
|
+
var holderRelationsPatch = !hasIncomingBookingUid ? (_productToAdd$_extend = productToAdd._extend) === null || _productToAdd$_extend === void 0 ? void 0 : _productToAdd$_extend.holder_relations : undefined;
|
|
5106
|
+
var hasIncomingHolder = Array.isArray(holderRelationsPatch) && holderRelationsPatch.length > 0;
|
|
5129
5107
|
var isIncomingCustomItem = ((_productToAdd$metadat = productToAdd.metadata) === null || _productToAdd$metadat === void 0 || (_productToAdd$metadat = _productToAdd$metadat.origin) === null || _productToAdd$metadat === void 0 ? void 0 : _productToAdd$metadat.isCustomItem) === true || ((_origin = productToAdd._origin) === null || _origin === void 0 ? void 0 : _origin.isCustomItem) === true;
|
|
5130
|
-
var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
5108
|
+
var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || hasIncomingHolder || isIncomingCustomItem || isWeighingProduct;
|
|
5131
5109
|
var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
5132
|
-
|
|
5133
|
-
|
|
5110
|
+
var _item$metadata4;
|
|
5111
|
+
if (_this32.hasGoodPassDiscount(item)) return false;
|
|
5112
|
+
if (getProductHolderRelations(tempOrder, item).length > 0 || hasAssignedHolderId((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.holder_id)) return false;
|
|
5113
|
+
var isRuntimeEntitlementPass = _this32.isRuntimeEntitlementAppend(item, tempOrder);
|
|
5134
5114
|
if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
|
|
5135
5115
|
return false;
|
|
5136
5116
|
}
|
|
5137
|
-
if (isIncomingEntitlementAppend &&
|
|
5117
|
+
if (isIncomingEntitlementAppend && _this32.isPersistedProductLine(item)) {
|
|
5138
5118
|
return false;
|
|
5139
5119
|
}
|
|
5140
|
-
var hasExistingProductNote =
|
|
5120
|
+
var hasExistingProductNote = _this32.hasOrderProductLineNote(item);
|
|
5141
5121
|
if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
|
|
5142
5122
|
return false;
|
|
5143
5123
|
}
|
|
5144
5124
|
var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
|
|
5145
|
-
if (isRuntimeEntitlementPass && !
|
|
5125
|
+
if (isRuntimeEntitlementPass && !_this32.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
|
|
5146
5126
|
return false;
|
|
5147
5127
|
}
|
|
5148
5128
|
if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
|
|
5149
5129
|
return false;
|
|
5150
5130
|
}
|
|
5151
|
-
if (
|
|
5131
|
+
if (_this32.isPersistedProductLine(item)) return false;
|
|
5152
5132
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
5153
5133
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
5154
5134
|
var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
@@ -5159,10 +5139,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5159
5139
|
var commitProductLine = function commitProductLine(shouldMerge) {
|
|
5160
5140
|
var _options$beforeCommit;
|
|
5161
5141
|
options === null || options === void 0 || (_options$beforeCommit = options.beforeCommit) === null || _options$beforeCommit === void 0 || _options$beforeCommit.call(options);
|
|
5162
|
-
|
|
5142
|
+
_this32.assertAndLockProductSettlement(tempOrder, productToAdd);
|
|
5163
5143
|
var committedProduct;
|
|
5164
5144
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
5165
|
-
|
|
5145
|
+
_this32.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
5166
5146
|
if (linked) {
|
|
5167
5147
|
normalizedIncoming.booking_uid = linked.bookingUid;
|
|
5168
5148
|
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
|
|
@@ -5180,7 +5160,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5180
5160
|
var _targetProduct$metada;
|
|
5181
5161
|
var targetProduct = matchedProduct;
|
|
5182
5162
|
var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
5183
|
-
var normalizedProduct =
|
|
5163
|
+
var normalizedProduct = _this32.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
5184
5164
|
metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
|
|
5185
5165
|
unique_identification_number: targetUid
|
|
5186
5166
|
})
|
|
@@ -5203,7 +5183,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5203
5183
|
order_detail_id: targetProduct.order_detail_id,
|
|
5204
5184
|
num: nextNum
|
|
5205
5185
|
});
|
|
5206
|
-
|
|
5186
|
+
_this32.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
5207
5187
|
committedProduct = tempOrder.products[matchedIndex];
|
|
5208
5188
|
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
5209
5189
|
var mergedProduct = tempOrder.products[matchedIndex];
|
|
@@ -5213,6 +5193,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5213
5193
|
if (linked) {
|
|
5214
5194
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
5215
5195
|
}
|
|
5196
|
+
replaceProductHolderRelations(tempOrder, committedProduct, holderRelationsPatch);
|
|
5216
5197
|
return committedProduct;
|
|
5217
5198
|
};
|
|
5218
5199
|
if (!matchedProduct) {
|
|
@@ -5313,10 +5294,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5313
5294
|
key: "addProductToOrder",
|
|
5314
5295
|
value: (function () {
|
|
5315
5296
|
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
|
|
5316
|
-
var
|
|
5297
|
+
var _this33 = this;
|
|
5317
5298
|
var availabilityCommitGuard, liveTempOrder, beforeCommit, tempOrder, guardedMutationFields, readGuardedMutationFields, guardedMutationBaseline, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref71, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2, committedIdentity, isCurrentOrder;
|
|
5318
|
-
return _regeneratorRuntime().wrap(function _callee23$(
|
|
5319
|
-
while (1) switch (
|
|
5299
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context24) {
|
|
5300
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
5320
5301
|
case 0:
|
|
5321
5302
|
availabilityCommitGuard = options === null || options === void 0 ? void 0 : options.availabilityCommitGuard;
|
|
5322
5303
|
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
@@ -5342,6 +5323,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5342
5323
|
});
|
|
5343
5324
|
mutationSnapshot = salesNoteDrafts.length > 0 ? {
|
|
5344
5325
|
products: cloneDeep(tempOrder.products || []),
|
|
5326
|
+
holder_relations: cloneDeep(tempOrder.holder_relations),
|
|
5345
5327
|
bookings: cloneDeep(tempOrder.bookings || []),
|
|
5346
5328
|
notes: cloneDeep(tempOrder.notes || []),
|
|
5347
5329
|
extend: cloneDeep(tempOrder._extend || {})
|
|
@@ -5354,7 +5336,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5354
5336
|
throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
|
|
5355
5337
|
}
|
|
5356
5338
|
salesNoteDrafts.forEach(function (draft) {
|
|
5357
|
-
|
|
5339
|
+
_this33.setSalesNoteOnTempOrder(tempOrder, {
|
|
5358
5340
|
note_type: draft.note_type,
|
|
5359
5341
|
target: {
|
|
5360
5342
|
target_type: 'order_detail',
|
|
@@ -5367,6 +5349,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5367
5349
|
rollbackProductAndNotesMutation = function rollbackProductAndNotesMutation() {
|
|
5368
5350
|
if (!mutationSnapshot) return;
|
|
5369
5351
|
tempOrder.products = mutationSnapshot.products;
|
|
5352
|
+
if (mutationSnapshot.holder_relations === undefined) delete tempOrder.holder_relations;else tempOrder.holder_relations = mutationSnapshot.holder_relations;
|
|
5370
5353
|
tempOrder.bookings = mutationSnapshot.bookings;
|
|
5371
5354
|
tempOrder.notes = mutationSnapshot.notes;
|
|
5372
5355
|
tempOrder._extend = mutationSnapshot.extend;
|
|
@@ -5378,21 +5361,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5378
5361
|
return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
|
|
5379
5362
|
}) : -1;
|
|
5380
5363
|
insertAtIndex = options !== null && options !== void 0 && options.insertAtStart ? 0 : anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
5381
|
-
|
|
5364
|
+
_context24.prev = 15;
|
|
5382
5365
|
if (!booking) {
|
|
5383
|
-
|
|
5366
|
+
_context24.next = 42;
|
|
5384
5367
|
break;
|
|
5385
5368
|
}
|
|
5386
5369
|
productRecord = product;
|
|
5387
5370
|
splitCount = getSafeProductNum((_ref71 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref71 !== void 0 ? _ref71 : 1);
|
|
5388
5371
|
if (!(splitCount > 1)) {
|
|
5389
|
-
|
|
5372
|
+
_context24.next = 35;
|
|
5390
5373
|
break;
|
|
5391
5374
|
}
|
|
5392
5375
|
i = 0;
|
|
5393
5376
|
case 21:
|
|
5394
5377
|
if (!(i < splitCount)) {
|
|
5395
|
-
|
|
5378
|
+
_context24.next = 33;
|
|
5396
5379
|
break;
|
|
5397
5380
|
}
|
|
5398
5381
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
@@ -5410,52 +5393,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5410
5393
|
delete splitLine.booking.metadata.unique_identification_number;
|
|
5411
5394
|
}
|
|
5412
5395
|
}
|
|
5413
|
-
|
|
5396
|
+
_context24.next = 26;
|
|
5414
5397
|
return this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
5415
5398
|
insertAtIndex: insertAtIndex,
|
|
5416
5399
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5417
5400
|
beforeCommit: beforeCommit
|
|
5418
5401
|
});
|
|
5419
5402
|
case 26:
|
|
5420
|
-
committedProduct =
|
|
5403
|
+
committedProduct = _context24.sent;
|
|
5421
5404
|
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
5422
5405
|
attachSalesNoteDrafts(committedProduct);
|
|
5423
5406
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
5424
5407
|
case 30:
|
|
5425
5408
|
i += 1;
|
|
5426
|
-
|
|
5409
|
+
_context24.next = 21;
|
|
5427
5410
|
break;
|
|
5428
5411
|
case 33:
|
|
5429
|
-
|
|
5412
|
+
_context24.next = 40;
|
|
5430
5413
|
break;
|
|
5431
5414
|
case 35:
|
|
5432
|
-
|
|
5415
|
+
_context24.next = 37;
|
|
5433
5416
|
return this.appendProductLineToTempOrder(tempOrder, product, cloneDeep(booking), {
|
|
5434
5417
|
insertAtIndex: insertAtIndex,
|
|
5435
5418
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5436
5419
|
beforeCommit: beforeCommit
|
|
5437
5420
|
});
|
|
5438
5421
|
case 37:
|
|
5439
|
-
_committedProduct =
|
|
5422
|
+
_committedProduct = _context24.sent;
|
|
5440
5423
|
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
5441
5424
|
attachSalesNoteDrafts(_committedProduct);
|
|
5442
5425
|
case 40:
|
|
5443
|
-
|
|
5426
|
+
_context24.next = 47;
|
|
5444
5427
|
break;
|
|
5445
5428
|
case 42:
|
|
5446
|
-
|
|
5429
|
+
_context24.next = 44;
|
|
5447
5430
|
return this.appendProductLineToTempOrder(tempOrder, product, undefined, {
|
|
5448
5431
|
insertAtIndex: insertAtIndex,
|
|
5449
5432
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5450
5433
|
beforeCommit: beforeCommit
|
|
5451
5434
|
});
|
|
5452
5435
|
case 44:
|
|
5453
|
-
_committedProduct2 =
|
|
5436
|
+
_committedProduct2 = _context24.sent;
|
|
5454
5437
|
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
5455
5438
|
attachSalesNoteDrafts(_committedProduct2);
|
|
5456
5439
|
case 47:
|
|
5457
5440
|
if (!availabilityCommitGuard) {
|
|
5458
|
-
|
|
5441
|
+
_context24.next = 53;
|
|
5459
5442
|
break;
|
|
5460
5443
|
}
|
|
5461
5444
|
availabilityCommitGuard();
|
|
@@ -5463,7 +5446,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5463
5446
|
// 调用方的结构 revision 可能不包括备注、价格或结算元数据。
|
|
5464
5447
|
// 本次会覆盖的字段也要保持原值,不能让草稿覆盖并发编辑。
|
|
5465
5448
|
if (isEqual(readGuardedMutationFields(liveTempOrder), guardedMutationBaseline)) {
|
|
5466
|
-
|
|
5449
|
+
_context24.next = 52;
|
|
5467
5450
|
break;
|
|
5468
5451
|
}
|
|
5469
5452
|
throw Object.assign(new Error('预约加购期间订单已变化,请重新选择'), {
|
|
@@ -5474,57 +5457,57 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5474
5457
|
// 字段;其余订单字段继续使用 live 对象,外部持有的订单引用也不变。
|
|
5475
5458
|
Object.assign(liveTempOrder, readGuardedMutationFields(tempOrder));
|
|
5476
5459
|
case 53:
|
|
5477
|
-
|
|
5460
|
+
_context24.next = 59;
|
|
5478
5461
|
break;
|
|
5479
5462
|
case 55:
|
|
5480
|
-
|
|
5481
|
-
|
|
5463
|
+
_context24.prev = 55;
|
|
5464
|
+
_context24.t0 = _context24["catch"](15);
|
|
5482
5465
|
rollbackProductAndNotesMutation();
|
|
5483
|
-
throw
|
|
5466
|
+
throw _context24.t0;
|
|
5484
5467
|
case 59:
|
|
5485
5468
|
if (!availabilityCommitGuard) {
|
|
5486
|
-
|
|
5469
|
+
_context24.next = 73;
|
|
5487
5470
|
break;
|
|
5488
5471
|
}
|
|
5489
5472
|
committedIdentity = [liveTempOrder.order_id, liveTempOrder.external_sale_number];
|
|
5490
5473
|
isCurrentOrder = function isCurrentOrder() {
|
|
5491
5474
|
var _options$availability, _options$availability2;
|
|
5492
|
-
return
|
|
5475
|
+
return _this33.store.tempOrder === liveTempOrder && liveTempOrder.order_id === committedIdentity[0] && liveTempOrder.external_sale_number === committedIdentity[1] && ((_options$availability = options === null || options === void 0 || (_options$availability2 = options.availabilityCommitTargetGuard) === null || _options$availability2 === void 0 ? void 0 : _options$availability2.call(options)) !== null && _options$availability !== void 0 ? _options$availability : true);
|
|
5493
5476
|
};
|
|
5494
|
-
|
|
5477
|
+
_context24.prev = 62;
|
|
5495
5478
|
// 新增已发布,即使后续报价/促销收尾失败,也不能向调用方报告未加购。
|
|
5496
5479
|
// 先保存已提交行;异步结果只允许写回仍属于本次提交的订单。
|
|
5497
5480
|
if (isCurrentOrder()) this.persistTempOrder();
|
|
5498
|
-
|
|
5481
|
+
_context24.next = 66;
|
|
5499
5482
|
return this.finalizeProductOrderMutation(liveTempOrder, {
|
|
5500
5483
|
isCurrentOrder: isCurrentOrder
|
|
5501
5484
|
});
|
|
5502
5485
|
case 66:
|
|
5503
|
-
|
|
5486
|
+
_context24.next = 71;
|
|
5504
5487
|
break;
|
|
5505
5488
|
case 68:
|
|
5506
|
-
|
|
5507
|
-
|
|
5489
|
+
_context24.prev = 68;
|
|
5490
|
+
_context24.t1 = _context24["catch"](62);
|
|
5508
5491
|
this.logWarning('addProductToOrder committed; finalization failed', {
|
|
5509
5492
|
product_id: product.product_id,
|
|
5510
5493
|
committed: true,
|
|
5511
|
-
error:
|
|
5494
|
+
error: _context24.t1 instanceof Error ? _context24.t1.message : String(_context24.t1)
|
|
5512
5495
|
});
|
|
5513
5496
|
case 71:
|
|
5514
|
-
|
|
5497
|
+
_context24.next = 75;
|
|
5515
5498
|
break;
|
|
5516
5499
|
case 73:
|
|
5517
|
-
|
|
5500
|
+
_context24.next = 75;
|
|
5518
5501
|
return this.finalizeProductOrderMutation(liveTempOrder);
|
|
5519
5502
|
case 75:
|
|
5520
5503
|
this.logInfo('addProductToOrder success', {
|
|
5521
5504
|
product_id: product.product_id,
|
|
5522
5505
|
with_booking: !!booking
|
|
5523
5506
|
});
|
|
5524
|
-
return
|
|
5507
|
+
return _context24.abrupt("return", liveTempOrder.products);
|
|
5525
5508
|
case 77:
|
|
5526
5509
|
case "end":
|
|
5527
|
-
return
|
|
5510
|
+
return _context24.stop();
|
|
5528
5511
|
}
|
|
5529
5512
|
}, _callee23, this, [[15, 55], [62, 68]]);
|
|
5530
5513
|
}));
|
|
@@ -5548,47 +5531,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5548
5531
|
value: (function () {
|
|
5549
5532
|
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(items, options) {
|
|
5550
5533
|
var tempOrder, beforeCommit, _iterator20, _step20, item, product, booking, _ref72, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
|
|
5551
|
-
return _regeneratorRuntime().wrap(function _callee24$(
|
|
5552
|
-
while (1) switch (
|
|
5534
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context25) {
|
|
5535
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
5553
5536
|
case 0:
|
|
5554
5537
|
tempOrder = this.ensureTempOrder();
|
|
5555
5538
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
5556
|
-
|
|
5539
|
+
_context25.next = 3;
|
|
5557
5540
|
break;
|
|
5558
5541
|
}
|
|
5559
|
-
return
|
|
5542
|
+
return _context25.abrupt("return", tempOrder.products);
|
|
5560
5543
|
case 3:
|
|
5561
5544
|
beforeCommit = this.createCartIntentCommitGuard('add_product', tempOrder);
|
|
5562
5545
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
5563
|
-
|
|
5546
|
+
_context25.prev = 5;
|
|
5564
5547
|
_iterator20.s();
|
|
5565
5548
|
case 7:
|
|
5566
5549
|
if ((_step20 = _iterator20.n()).done) {
|
|
5567
|
-
|
|
5550
|
+
_context25.next = 33;
|
|
5568
5551
|
break;
|
|
5569
5552
|
}
|
|
5570
5553
|
item = _step20.value;
|
|
5571
5554
|
product = item.product, booking = item.booking;
|
|
5572
5555
|
if (product) {
|
|
5573
|
-
|
|
5556
|
+
_context25.next = 12;
|
|
5574
5557
|
break;
|
|
5575
5558
|
}
|
|
5576
|
-
return
|
|
5559
|
+
return _context25.abrupt("continue", 31);
|
|
5577
5560
|
case 12:
|
|
5578
5561
|
if (!booking) {
|
|
5579
|
-
|
|
5562
|
+
_context25.next = 27;
|
|
5580
5563
|
break;
|
|
5581
5564
|
}
|
|
5582
5565
|
productRecord = product;
|
|
5583
5566
|
splitCount = getSafeProductNum((_ref72 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref72 !== void 0 ? _ref72 : 1);
|
|
5584
5567
|
if (!(splitCount > 1)) {
|
|
5585
|
-
|
|
5568
|
+
_context25.next = 27;
|
|
5586
5569
|
break;
|
|
5587
5570
|
}
|
|
5588
5571
|
i = 0;
|
|
5589
5572
|
case 17:
|
|
5590
5573
|
if (!(i < splitCount)) {
|
|
5591
|
-
|
|
5574
|
+
_context25.next = 26;
|
|
5592
5575
|
break;
|
|
5593
5576
|
}
|
|
5594
5577
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
@@ -5596,52 +5579,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5596
5579
|
beforeCommit: beforeCommit
|
|
5597
5580
|
});
|
|
5598
5581
|
if (!_appendResult) {
|
|
5599
|
-
|
|
5582
|
+
_context25.next = 23;
|
|
5600
5583
|
break;
|
|
5601
5584
|
}
|
|
5602
|
-
|
|
5585
|
+
_context25.next = 23;
|
|
5603
5586
|
return _appendResult;
|
|
5604
5587
|
case 23:
|
|
5605
5588
|
i += 1;
|
|
5606
|
-
|
|
5589
|
+
_context25.next = 17;
|
|
5607
5590
|
break;
|
|
5608
5591
|
case 26:
|
|
5609
|
-
return
|
|
5592
|
+
return _context25.abrupt("continue", 31);
|
|
5610
5593
|
case 27:
|
|
5611
5594
|
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
5612
5595
|
beforeCommit: beforeCommit
|
|
5613
5596
|
});
|
|
5614
5597
|
if (!appendResult) {
|
|
5615
|
-
|
|
5598
|
+
_context25.next = 31;
|
|
5616
5599
|
break;
|
|
5617
5600
|
}
|
|
5618
|
-
|
|
5601
|
+
_context25.next = 31;
|
|
5619
5602
|
return appendResult;
|
|
5620
5603
|
case 31:
|
|
5621
|
-
|
|
5604
|
+
_context25.next = 7;
|
|
5622
5605
|
break;
|
|
5623
5606
|
case 33:
|
|
5624
|
-
|
|
5607
|
+
_context25.next = 38;
|
|
5625
5608
|
break;
|
|
5626
5609
|
case 35:
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
_iterator20.e(
|
|
5610
|
+
_context25.prev = 35;
|
|
5611
|
+
_context25.t0 = _context25["catch"](5);
|
|
5612
|
+
_iterator20.e(_context25.t0);
|
|
5630
5613
|
case 38:
|
|
5631
|
-
|
|
5614
|
+
_context25.prev = 38;
|
|
5632
5615
|
_iterator20.f();
|
|
5633
|
-
return
|
|
5616
|
+
return _context25.finish(38);
|
|
5634
5617
|
case 41:
|
|
5635
|
-
|
|
5618
|
+
_context25.next = 43;
|
|
5636
5619
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
5637
5620
|
case 43:
|
|
5638
5621
|
this.logInfo('addProductsToOrder success', {
|
|
5639
5622
|
itemsCount: items.length
|
|
5640
5623
|
});
|
|
5641
|
-
return
|
|
5624
|
+
return _context25.abrupt("return", tempOrder.products);
|
|
5642
5625
|
case 45:
|
|
5643
5626
|
case "end":
|
|
5644
|
-
return
|
|
5627
|
+
return _context25.stop();
|
|
5645
5628
|
}
|
|
5646
5629
|
}, _callee24, this, [[5, 35, 38, 41]]);
|
|
5647
5630
|
}));
|
|
@@ -5653,12 +5636,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5653
5636
|
}, {
|
|
5654
5637
|
key: "getFullCoveragePassDiscounts",
|
|
5655
5638
|
value: function getFullCoveragePassDiscounts(product) {
|
|
5656
|
-
var _product$
|
|
5639
|
+
var _product$_extend2;
|
|
5657
5640
|
var discountList = _toConsumableArray(product.discount_list || []);
|
|
5658
5641
|
(product.product_bundle || []).forEach(function (item) {
|
|
5659
5642
|
discountList.push.apply(discountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
|
|
5660
5643
|
});
|
|
5661
|
-
((product === null || product === void 0 || (_product$
|
|
5644
|
+
((product === null || product === void 0 || (_product$_extend2 = product._extend) === null || _product$_extend2 === void 0 || (_product$_extend2 = _product$_extend2.other) === null || _product$_extend2 === void 0 ? void 0 : _product$_extend2.bundle) || []).forEach(function (item) {
|
|
5662
5645
|
discountList.push.apply(discountList, _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
|
|
5663
5646
|
});
|
|
5664
5647
|
return discountList.filter(function (item) {
|
|
@@ -5697,7 +5680,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5697
5680
|
}, {
|
|
5698
5681
|
key: "hasSameEntitlementMergePriceConfig",
|
|
5699
5682
|
value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
|
|
5700
|
-
var
|
|
5683
|
+
var _this34 = this;
|
|
5701
5684
|
var buildPriceConfig = function buildPriceConfig(product) {
|
|
5702
5685
|
var metadata = product.metadata || {};
|
|
5703
5686
|
var bundle = (product.product_bundle || []).map(function (item) {
|
|
@@ -5713,10 +5696,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5713
5696
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
5714
5697
|
});
|
|
5715
5698
|
return JSON.stringify({
|
|
5716
|
-
original_price:
|
|
5717
|
-
source_product_price:
|
|
5718
|
-
main_product_original_price:
|
|
5719
|
-
price_override:
|
|
5699
|
+
original_price: _this34.normalizeFingerprintMoney(product.original_price),
|
|
5700
|
+
source_product_price: _this34.normalizeFingerprintMoney(metadata.source_product_price),
|
|
5701
|
+
main_product_original_price: _this34.normalizeFingerprintMoney(metadata.main_product_original_price),
|
|
5702
|
+
price_override: _this34.normalizeFingerprintMoney(metadata.price_override),
|
|
5720
5703
|
is_manual_discount: Boolean(metadata.is_manual_discount),
|
|
5721
5704
|
bundle: bundle
|
|
5722
5705
|
});
|
|
@@ -5733,17 +5716,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5733
5716
|
}, {
|
|
5734
5717
|
key: "preservePersistedBundlePriceFields",
|
|
5735
5718
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
5736
|
-
var
|
|
5719
|
+
var _this35 = this;
|
|
5737
5720
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
5738
5721
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
5739
5722
|
var previousByIdentity = new Map();
|
|
5740
5723
|
previousBundles.forEach(function (bundle) {
|
|
5741
|
-
var identity =
|
|
5724
|
+
var identity = _this35.getBundleRuntimeIdentity(bundle);
|
|
5742
5725
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
5743
5726
|
});
|
|
5744
5727
|
return nextBundles.map(function (bundle, index) {
|
|
5745
5728
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
5746
|
-
var previous = previousByIdentity.get(
|
|
5729
|
+
var previous = previousByIdentity.get(_this35.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
5747
5730
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
5748
5731
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
5749
5732
|
cover: previous.cover
|
|
@@ -5770,15 +5753,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5770
5753
|
if (((_params$updates = params.updates) === null || _params$updates === void 0 ? void 0 : _params$updates.num) === undefined) return false;
|
|
5771
5754
|
var uid = params.unique_identification_number;
|
|
5772
5755
|
var product = uid !== undefined ? tempOrder.products.find(function (item) {
|
|
5773
|
-
var _item$
|
|
5774
|
-
return String(((_item$
|
|
5756
|
+
var _item$metadata5;
|
|
5757
|
+
return String(((_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.unique_identification_number) || item.unique_identification_number || '') === String(uid);
|
|
5775
5758
|
}) : tempOrder.products[getProductIdentityIndex(tempOrder.products, params)];
|
|
5776
5759
|
return !product || getSafeProductNum(params.updates.num) > product.num;
|
|
5777
5760
|
}
|
|
5778
5761
|
}, {
|
|
5779
5762
|
key: "applyOrderProductUpdateToTempOrder",
|
|
5780
5763
|
value: function applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids) {
|
|
5781
|
-
var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _metadata8, _metadata9, _metadata10, _nextProduct$metadata2, _targetProduct$metada20, _tempOrder$products$p, _tempOrder$products$p2;
|
|
5764
|
+
var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _metadata8, _metadata9, _metadata10, _nextProduct$metadata2, _targetProduct$metada20, _updates$_extend, _tempOrder$products$p, _tempOrder$products$p2;
|
|
5782
5765
|
var product_id = params.product_id,
|
|
5783
5766
|
product_variant_id = params.product_variant_id,
|
|
5784
5767
|
updates = params.updates,
|
|
@@ -5806,8 +5789,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5806
5789
|
if (unique_identification_number !== undefined) {
|
|
5807
5790
|
var targetUid = String(unique_identification_number);
|
|
5808
5791
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
5809
|
-
var _item$
|
|
5810
|
-
return String(((_item$
|
|
5792
|
+
var _item$metadata6;
|
|
5793
|
+
return String(((_item$metadata6 = item.metadata) === null || _item$metadata6 === void 0 ? void 0 : _item$metadata6.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
5811
5794
|
});
|
|
5812
5795
|
}
|
|
5813
5796
|
if (productIndex === -1) {
|
|
@@ -6007,6 +5990,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6007
5990
|
if (uid) reapplyWeighedDiscountProductUids === null || reapplyWeighedDiscountProductUids === void 0 || reapplyWeighedDiscountProductUids.push(String(uid));
|
|
6008
5991
|
}
|
|
6009
5992
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
5993
|
+
replaceProductHolderRelations(tempOrder, normalizedProduct, (_updates$_extend = updates._extend) === null || _updates$_extend === void 0 ? void 0 : _updates$_extend.holder_relations);
|
|
6010
5994
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
6011
5995
|
this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], (_tempOrder$products$p = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p === void 0 ? void 0 : _tempOrder$products$p.unique_identification_number);
|
|
6012
5996
|
return (_tempOrder$products$p2 = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p2 === void 0 ? void 0 : _tempOrder$products$p2.unique_identification_number;
|
|
@@ -6016,8 +6000,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6016
6000
|
value: function () {
|
|
6017
6001
|
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
6018
6002
|
var tempOrder, reapplyWeighedDiscountProductUids, updatedProductUid, promotionPayload;
|
|
6019
|
-
return _regeneratorRuntime().wrap(function _callee25$(
|
|
6020
|
-
while (1) switch (
|
|
6003
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context26) {
|
|
6004
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
6021
6005
|
case 0:
|
|
6022
6006
|
tempOrder = this.ensureTempOrder();
|
|
6023
6007
|
if (this.isRestrictedCartProductUpdate(tempOrder, params)) {
|
|
@@ -6025,16 +6009,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6025
6009
|
}
|
|
6026
6010
|
reapplyWeighedDiscountProductUids = [];
|
|
6027
6011
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
6028
|
-
|
|
6012
|
+
_context26.next = 6;
|
|
6029
6013
|
return this.evaluatePromotion();
|
|
6030
6014
|
case 6:
|
|
6031
|
-
promotionPayload =
|
|
6015
|
+
promotionPayload = _context26.sent;
|
|
6032
6016
|
this.applyDiscount({
|
|
6033
6017
|
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
6034
6018
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
6035
6019
|
});
|
|
6036
6020
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
6037
|
-
|
|
6021
|
+
_context26.next = 11;
|
|
6038
6022
|
return this.recalculateSummary({
|
|
6039
6023
|
createIfMissing: true
|
|
6040
6024
|
});
|
|
@@ -6044,10 +6028,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6044
6028
|
this.logInfo('updateOrderProduct success', {
|
|
6045
6029
|
params: params
|
|
6046
6030
|
});
|
|
6047
|
-
return
|
|
6031
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
6048
6032
|
case 15:
|
|
6049
6033
|
case "end":
|
|
6050
|
-
return
|
|
6034
|
+
return _context26.stop();
|
|
6051
6035
|
}
|
|
6052
6036
|
}, _callee25, this);
|
|
6053
6037
|
}));
|
|
@@ -6060,33 +6044,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6060
6044
|
key: "updateOrderProducts",
|
|
6061
6045
|
value: function () {
|
|
6062
6046
|
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
|
|
6063
|
-
var
|
|
6047
|
+
var _this36 = this;
|
|
6064
6048
|
var tempOrder, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids;
|
|
6065
|
-
return _regeneratorRuntime().wrap(function _callee26$(
|
|
6066
|
-
while (1) switch (
|
|
6049
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context27) {
|
|
6050
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
6067
6051
|
case 0:
|
|
6068
6052
|
tempOrder = this.ensureTempOrder();
|
|
6069
6053
|
if (paramsList.length) {
|
|
6070
|
-
|
|
6054
|
+
_context27.next = 3;
|
|
6071
6055
|
break;
|
|
6072
6056
|
}
|
|
6073
|
-
return
|
|
6057
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
6074
6058
|
case 3:
|
|
6075
6059
|
if (paramsList.some(function (params) {
|
|
6076
|
-
return
|
|
6060
|
+
return _this36.isRestrictedCartProductUpdate(tempOrder, params);
|
|
6077
6061
|
})) {
|
|
6078
6062
|
this.createCartIntentCommitGuard('update_product', tempOrder)();
|
|
6079
6063
|
}
|
|
6080
6064
|
reapplyWeighedDiscountProductUids = [];
|
|
6081
6065
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
6082
|
-
var updatedProductUid =
|
|
6066
|
+
var updatedProductUid = _this36.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
6083
6067
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
6084
6068
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
6085
6069
|
acc.push(String(updatedProductUid));
|
|
6086
6070
|
}
|
|
6087
6071
|
return acc;
|
|
6088
6072
|
}, []);
|
|
6089
|
-
|
|
6073
|
+
_context27.next = 8;
|
|
6090
6074
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
6091
6075
|
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
6092
6076
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
@@ -6095,10 +6079,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6095
6079
|
this.logInfo('updateOrderProduct success', {
|
|
6096
6080
|
paramsList: paramsList
|
|
6097
6081
|
});
|
|
6098
|
-
return
|
|
6082
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
6099
6083
|
case 10:
|
|
6100
6084
|
case "end":
|
|
6101
|
-
return
|
|
6085
|
+
return _context27.stop();
|
|
6102
6086
|
}
|
|
6103
6087
|
}, _callee26, this);
|
|
6104
6088
|
}));
|
|
@@ -6113,15 +6097,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6113
6097
|
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params, options) {
|
|
6114
6098
|
var _this$store$tempOrder9, _targetProduct$metada22;
|
|
6115
6099
|
var isCurrentOrder, product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, isPersistedOrderLine, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance, isVirtualSettlement, promotionPayload;
|
|
6116
|
-
return _regeneratorRuntime().wrap(function _callee27$(
|
|
6117
|
-
while (1) switch (
|
|
6100
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context28) {
|
|
6101
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
6118
6102
|
case 0:
|
|
6119
6103
|
isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
|
|
6120
6104
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
6121
|
-
|
|
6105
|
+
_context28.next = 3;
|
|
6122
6106
|
break;
|
|
6123
6107
|
}
|
|
6124
|
-
return
|
|
6108
|
+
return _context28.abrupt("return", ((_this$store$tempOrder9 = this.store.tempOrder) === null || _this$store$tempOrder9 === void 0 ? void 0 : _this$store$tempOrder9.products) || []);
|
|
6125
6109
|
case 3:
|
|
6126
6110
|
product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
|
|
6127
6111
|
tempOrder = this.ensureTempOrder();
|
|
@@ -6143,15 +6127,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6143
6127
|
if (unique_identification_number !== undefined) {
|
|
6144
6128
|
targetUid = String(unique_identification_number);
|
|
6145
6129
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
6146
|
-
var _item$
|
|
6147
|
-
return String(((_item$
|
|
6130
|
+
var _item$metadata7;
|
|
6131
|
+
return String(((_item$metadata7 = item.metadata) === null || _item$metadata7 === void 0 ? void 0 : _item$metadata7.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
6148
6132
|
});
|
|
6149
6133
|
}
|
|
6150
6134
|
if (productIndex === -1) {
|
|
6151
6135
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
6152
6136
|
}
|
|
6153
6137
|
if (!(productIndex === -1)) {
|
|
6154
|
-
|
|
6138
|
+
_context28.next = 16;
|
|
6155
6139
|
break;
|
|
6156
6140
|
}
|
|
6157
6141
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -6167,7 +6151,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6167
6151
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
6168
6152
|
settlementSnapshot = getSelectedSettlementSnapshot(normalizedProduct);
|
|
6169
6153
|
if (!(this.isMultiCurrencySettlementEnabled() && (settlementSnapshot === null || settlementSnapshot === void 0 ? void 0 : settlementSnapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1)) {
|
|
6170
|
-
|
|
6154
|
+
_context28.next = 30;
|
|
6171
6155
|
break;
|
|
6172
6156
|
}
|
|
6173
6157
|
currencyProductId = Number(settlementSnapshot.currency_product_id);
|
|
@@ -6175,7 +6159,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6175
6159
|
return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
|
|
6176
6160
|
});
|
|
6177
6161
|
if (asset) {
|
|
6178
|
-
|
|
6162
|
+
_context28.next = 26;
|
|
6179
6163
|
break;
|
|
6180
6164
|
}
|
|
6181
6165
|
throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
|
|
@@ -6187,7 +6171,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6187
6171
|
}, new Decimal(0));
|
|
6188
6172
|
balance = new Decimal(asset.balance || 0);
|
|
6189
6173
|
if (!balance.lt(requiredAmount)) {
|
|
6190
|
-
|
|
6174
|
+
_context28.next = 30;
|
|
6191
6175
|
break;
|
|
6192
6176
|
}
|
|
6193
6177
|
throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
@@ -6196,46 +6180,46 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6196
6180
|
this.createCartIntentCommitGuard('increase_quantity', tempOrder)();
|
|
6197
6181
|
}
|
|
6198
6182
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
6199
|
-
|
|
6183
|
+
_context28.next = 33;
|
|
6200
6184
|
break;
|
|
6201
6185
|
}
|
|
6202
|
-
return
|
|
6186
|
+
return _context28.abrupt("return", tempOrder.products);
|
|
6203
6187
|
case 33:
|
|
6204
6188
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
6205
6189
|
if (!isCurrentOrder) {
|
|
6206
|
-
|
|
6190
|
+
_context28.next = 39;
|
|
6207
6191
|
break;
|
|
6208
6192
|
}
|
|
6209
|
-
|
|
6193
|
+
_context28.next = 37;
|
|
6210
6194
|
return this.finalizeProductOrderMutation(tempOrder, {
|
|
6211
6195
|
skipEditDiscountConfigRefresh: true,
|
|
6212
6196
|
isCurrentOrder: isCurrentOrder
|
|
6213
6197
|
});
|
|
6214
6198
|
case 37:
|
|
6215
|
-
|
|
6199
|
+
_context28.next = 55;
|
|
6216
6200
|
break;
|
|
6217
6201
|
case 39:
|
|
6218
6202
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
6219
6203
|
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
6220
6204
|
if (isVirtualSettlement) {
|
|
6221
|
-
|
|
6205
|
+
_context28.next = 47;
|
|
6222
6206
|
break;
|
|
6223
6207
|
}
|
|
6224
|
-
|
|
6208
|
+
_context28.next = 44;
|
|
6225
6209
|
return this.evaluatePromotion();
|
|
6226
6210
|
case 44:
|
|
6227
|
-
|
|
6228
|
-
|
|
6211
|
+
_context28.t0 = _context28.sent;
|
|
6212
|
+
_context28.next = 48;
|
|
6229
6213
|
break;
|
|
6230
6214
|
case 47:
|
|
6231
|
-
|
|
6215
|
+
_context28.t0 = null;
|
|
6232
6216
|
case 48:
|
|
6233
|
-
promotionPayload =
|
|
6217
|
+
promotionPayload = _context28.t0;
|
|
6234
6218
|
if (!isVirtualSettlement) {
|
|
6235
6219
|
this.applyDiscount();
|
|
6236
6220
|
}
|
|
6237
6221
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
6238
|
-
|
|
6222
|
+
_context28.next = 53;
|
|
6239
6223
|
return this.recalculateSummary({
|
|
6240
6224
|
createIfMissing: true
|
|
6241
6225
|
});
|
|
@@ -6246,10 +6230,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6246
6230
|
this.logInfo('updateOrderProductQuantity success', {
|
|
6247
6231
|
params: params
|
|
6248
6232
|
});
|
|
6249
|
-
return
|
|
6233
|
+
return _context28.abrupt("return", tempOrder.products);
|
|
6250
6234
|
case 57:
|
|
6251
6235
|
case "end":
|
|
6252
|
-
return
|
|
6236
|
+
return _context28.stop();
|
|
6253
6237
|
}
|
|
6254
6238
|
}, _callee27, this);
|
|
6255
6239
|
}));
|
|
@@ -6296,20 +6280,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6296
6280
|
value: (function () {
|
|
6297
6281
|
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(tempOrder, options) {
|
|
6298
6282
|
var promotionPayload;
|
|
6299
|
-
return _regeneratorRuntime().wrap(function _callee28$(
|
|
6300
|
-
while (1) switch (
|
|
6283
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context29) {
|
|
6284
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
6301
6285
|
case 0:
|
|
6302
6286
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
6303
|
-
|
|
6287
|
+
_context29.next = 3;
|
|
6304
6288
|
return this.evaluatePromotion();
|
|
6305
6289
|
case 3:
|
|
6306
|
-
promotionPayload =
|
|
6290
|
+
promotionPayload = _context29.sent;
|
|
6307
6291
|
this.applyDiscount({
|
|
6308
6292
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids,
|
|
6309
6293
|
reapplyWeighedDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyWeighedDiscountProductUids
|
|
6310
6294
|
});
|
|
6311
6295
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
6312
|
-
|
|
6296
|
+
_context29.next = 8;
|
|
6313
6297
|
return this.recalculateSummary({
|
|
6314
6298
|
createIfMissing: true
|
|
6315
6299
|
});
|
|
@@ -6318,7 +6302,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6318
6302
|
this.emitPromotionApplied(promotionPayload);
|
|
6319
6303
|
case 10:
|
|
6320
6304
|
case "end":
|
|
6321
|
-
return
|
|
6305
|
+
return _context29.stop();
|
|
6322
6306
|
}
|
|
6323
6307
|
}, _callee28, this);
|
|
6324
6308
|
}));
|
|
@@ -6339,24 +6323,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6339
6323
|
value: (function () {
|
|
6340
6324
|
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
|
|
6341
6325
|
var _this$store$tempOrder10,
|
|
6342
|
-
|
|
6343
|
-
var isCurrentOrder, tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21,
|
|
6344
|
-
return _regeneratorRuntime().wrap(function _callee29$(
|
|
6345
|
-
while (1) switch (
|
|
6326
|
+
_this37 = this;
|
|
6327
|
+
var isCurrentOrder, tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop2, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
6328
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context31) {
|
|
6329
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
6346
6330
|
case 0:
|
|
6347
6331
|
isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
|
|
6348
6332
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
6349
|
-
|
|
6333
|
+
_context31.next = 3;
|
|
6350
6334
|
break;
|
|
6351
6335
|
}
|
|
6352
|
-
return
|
|
6336
|
+
return _context31.abrupt("return", ((_this$store$tempOrder10 = this.store.tempOrder) === null || _this$store$tempOrder10 === void 0 ? void 0 : _this$store$tempOrder10.products) || []);
|
|
6353
6337
|
case 3:
|
|
6354
6338
|
tempOrder = this.ensureTempOrder();
|
|
6355
6339
|
if (identities.length) {
|
|
6356
|
-
|
|
6340
|
+
_context31.next = 6;
|
|
6357
6341
|
break;
|
|
6358
6342
|
}
|
|
6359
|
-
return
|
|
6343
|
+
return _context31.abrupt("return", tempOrder.products);
|
|
6360
6344
|
case 6:
|
|
6361
6345
|
// 商品删除会同步删除以商品行为主关系的 Notes;快照不完整时禁止产生孤儿 Relation。
|
|
6362
6346
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
@@ -6365,8 +6349,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6365
6349
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
6366
6350
|
preserveDisplayPosition = options === null || options === void 0 ? void 0 : options.preserveDisplayPosition;
|
|
6367
6351
|
anchorIndex = preserveDisplayPosition ? productsBeforeRemove.findIndex(function (item) {
|
|
6368
|
-
var _item$
|
|
6369
|
-
var uid = ((_item$
|
|
6352
|
+
var _item$metadata8;
|
|
6353
|
+
var uid = ((_item$metadata8 = item.metadata) === null || _item$metadata8 === void 0 ? void 0 : _item$metadata8.unique_identification_number) || item.unique_identification_number;
|
|
6370
6354
|
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.anchorProductUid);
|
|
6371
6355
|
}) : -1;
|
|
6372
6356
|
productsAfterAnchor = anchorIndex >= 0 ? productsBeforeRemove.slice(anchorIndex + 1) : [];
|
|
@@ -6389,29 +6373,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6389
6373
|
}
|
|
6390
6374
|
linkedBookingUidsToRemove = new Set();
|
|
6391
6375
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
6392
|
-
|
|
6393
|
-
|
|
6376
|
+
_context31.prev = 19;
|
|
6377
|
+
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
6394
6378
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
6395
6379
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
6396
|
-
return _regeneratorRuntime().wrap(function
|
|
6397
|
-
while (1) switch (
|
|
6380
|
+
return _regeneratorRuntime().wrap(function _loop2$(_context30) {
|
|
6381
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
6398
6382
|
case 0:
|
|
6399
6383
|
product = _step21.value;
|
|
6400
6384
|
productUid = (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
6401
6385
|
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata12 = product.metadata) === null || _metadata12 === void 0 ? void 0 : _metadata12.booking_uid);
|
|
6402
6386
|
isAddTimeProduct = (product === null || product === void 0 || (_metadata13 = product.metadata) === null || _metadata13 === void 0 ? void 0 : _metadata13.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata14 = product.metadata) === null || _metadata14 === void 0 ? void 0 : _metadata14.product_add_schedule_time) !== null;
|
|
6403
6387
|
if (!isAddTimeProduct) {
|
|
6404
|
-
|
|
6388
|
+
_context30.next = 6;
|
|
6405
6389
|
break;
|
|
6406
6390
|
}
|
|
6407
|
-
return
|
|
6391
|
+
return _context30.abrupt("return", 1);
|
|
6408
6392
|
case 6:
|
|
6409
6393
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
6410
6394
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
6411
6395
|
}
|
|
6412
6396
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
6413
6397
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
6414
|
-
var bookingUid =
|
|
6398
|
+
var bookingUid = _this37.getBookingUniqueIdentificationNumber(booking);
|
|
6415
6399
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
6416
6400
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
6417
6401
|
}
|
|
@@ -6419,37 +6403,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6419
6403
|
}
|
|
6420
6404
|
case 8:
|
|
6421
6405
|
case "end":
|
|
6422
|
-
return
|
|
6406
|
+
return _context30.stop();
|
|
6423
6407
|
}
|
|
6424
|
-
},
|
|
6408
|
+
}, _loop2);
|
|
6425
6409
|
});
|
|
6426
6410
|
_iterator21.s();
|
|
6427
6411
|
case 22:
|
|
6428
6412
|
if ((_step21 = _iterator21.n()).done) {
|
|
6429
|
-
|
|
6413
|
+
_context31.next = 28;
|
|
6430
6414
|
break;
|
|
6431
6415
|
}
|
|
6432
|
-
return
|
|
6416
|
+
return _context31.delegateYield(_loop2(), "t0", 24);
|
|
6433
6417
|
case 24:
|
|
6434
|
-
if (!
|
|
6435
|
-
|
|
6418
|
+
if (!_context31.t0) {
|
|
6419
|
+
_context31.next = 26;
|
|
6436
6420
|
break;
|
|
6437
6421
|
}
|
|
6438
|
-
return
|
|
6422
|
+
return _context31.abrupt("continue", 26);
|
|
6439
6423
|
case 26:
|
|
6440
|
-
|
|
6424
|
+
_context31.next = 22;
|
|
6441
6425
|
break;
|
|
6442
6426
|
case 28:
|
|
6443
|
-
|
|
6427
|
+
_context31.next = 33;
|
|
6444
6428
|
break;
|
|
6445
6429
|
case 30:
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
_iterator21.e(
|
|
6430
|
+
_context31.prev = 30;
|
|
6431
|
+
_context31.t1 = _context31["catch"](19);
|
|
6432
|
+
_iterator21.e(_context31.t1);
|
|
6449
6433
|
case 33:
|
|
6450
|
-
|
|
6434
|
+
_context31.prev = 33;
|
|
6451
6435
|
_iterator21.f();
|
|
6452
|
-
return
|
|
6436
|
+
return _context31.finish(33);
|
|
6453
6437
|
case 36:
|
|
6454
6438
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
6455
6439
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
@@ -6462,8 +6446,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6462
6446
|
}
|
|
6463
6447
|
if (preserveDisplayPosition && anchorIndex >= 0) {
|
|
6464
6448
|
remainingProductIndex = tempOrder.products.findIndex(function (item) {
|
|
6465
|
-
var _item$
|
|
6466
|
-
var uid = ((_item$
|
|
6449
|
+
var _item$metadata9;
|
|
6450
|
+
var uid = ((_item$metadata9 = item.metadata) === null || _item$metadata9 === void 0 ? void 0 : _item$metadata9.unique_identification_number) || item.unique_identification_number;
|
|
6467
6451
|
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.remainingProductUid);
|
|
6468
6452
|
});
|
|
6469
6453
|
if (remainingProductIndex >= 0) {
|
|
@@ -6476,30 +6460,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6476
6460
|
tempOrder.products = nextProductIndex >= 0 ? [].concat(_toConsumableArray(productsWithoutRemaining.slice(0, nextProductIndex)), [remainingProduct], _toConsumableArray(productsWithoutRemaining.slice(nextProductIndex))) : [].concat(_toConsumableArray(productsWithoutRemaining), [remainingProduct]);
|
|
6477
6461
|
}
|
|
6478
6462
|
}
|
|
6463
|
+
removeProductHolderRelations(tempOrder, productsBeforeRemove.filter(function (product) {
|
|
6464
|
+
return !tempOrder.products.includes(product);
|
|
6465
|
+
}));
|
|
6479
6466
|
this.removeSalesNotesForMissingProductLines(tempOrder);
|
|
6480
6467
|
if (!isCurrentOrder) {
|
|
6481
|
-
|
|
6468
|
+
_context31.next = 45;
|
|
6482
6469
|
break;
|
|
6483
6470
|
}
|
|
6484
|
-
|
|
6471
|
+
_context31.next = 43;
|
|
6485
6472
|
return this.finalizeProductOrderMutation(tempOrder, {
|
|
6486
6473
|
skipEditDiscountConfigRefresh: true,
|
|
6487
6474
|
isCurrentOrder: isCurrentOrder
|
|
6488
6475
|
});
|
|
6489
|
-
case
|
|
6490
|
-
|
|
6476
|
+
case 43:
|
|
6477
|
+
_context31.next = 47;
|
|
6491
6478
|
break;
|
|
6492
|
-
case
|
|
6493
|
-
|
|
6479
|
+
case 45:
|
|
6480
|
+
_context31.next = 47;
|
|
6494
6481
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
6495
|
-
case
|
|
6482
|
+
case 47:
|
|
6496
6483
|
this.logInfo('removeProductsFromOrder success', {
|
|
6497
6484
|
identities: identities
|
|
6498
6485
|
});
|
|
6499
|
-
return
|
|
6500
|
-
case
|
|
6486
|
+
return _context31.abrupt("return", tempOrder.products);
|
|
6487
|
+
case 49:
|
|
6501
6488
|
case "end":
|
|
6502
|
-
return
|
|
6489
|
+
return _context31.stop();
|
|
6503
6490
|
}
|
|
6504
6491
|
}, _callee29, this, [[19, 30, 33, 36]]);
|
|
6505
6492
|
}));
|
|
@@ -6512,13 +6499,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6512
6499
|
key: "removeProductFromOrder",
|
|
6513
6500
|
value: function () {
|
|
6514
6501
|
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(identity, options) {
|
|
6515
|
-
return _regeneratorRuntime().wrap(function _callee30$(
|
|
6516
|
-
while (1) switch (
|
|
6502
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context32) {
|
|
6503
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
6517
6504
|
case 0:
|
|
6518
|
-
return
|
|
6505
|
+
return _context32.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
6519
6506
|
case 1:
|
|
6520
6507
|
case "end":
|
|
6521
|
-
return
|
|
6508
|
+
return _context32.stop();
|
|
6522
6509
|
}
|
|
6523
6510
|
}, _callee30, this);
|
|
6524
6511
|
}));
|
|
@@ -6536,11 +6523,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6536
6523
|
value: (function () {
|
|
6537
6524
|
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
6538
6525
|
var tempOrder, promotionPayload;
|
|
6539
|
-
return _regeneratorRuntime().wrap(function _callee31$(
|
|
6540
|
-
while (1) switch (
|
|
6526
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context33) {
|
|
6527
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
6541
6528
|
case 0:
|
|
6542
6529
|
tempOrder = this.ensureTempOrder();
|
|
6543
6530
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
6531
|
+
removeProductHolderRelations(tempOrder, tempOrder.products);
|
|
6544
6532
|
tempOrder.products = [];
|
|
6545
6533
|
tempOrder.bookings = [];
|
|
6546
6534
|
releaseTempOrderSettlementState(tempOrder);
|
|
@@ -6551,24 +6539,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6551
6539
|
productsByUid: {}
|
|
6552
6540
|
});
|
|
6553
6541
|
}
|
|
6554
|
-
|
|
6542
|
+
_context33.next = 11;
|
|
6555
6543
|
return this.evaluatePromotion();
|
|
6556
|
-
case
|
|
6557
|
-
promotionPayload =
|
|
6544
|
+
case 11:
|
|
6545
|
+
promotionPayload = _context33.sent;
|
|
6558
6546
|
this.applyDiscount();
|
|
6559
6547
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
6560
|
-
|
|
6548
|
+
_context33.next = 16;
|
|
6561
6549
|
return this.recalculateSummary({
|
|
6562
6550
|
createIfMissing: true
|
|
6563
6551
|
});
|
|
6564
|
-
case
|
|
6552
|
+
case 16:
|
|
6565
6553
|
this.persistTempOrder();
|
|
6566
6554
|
this.emitPromotionApplied(promotionPayload);
|
|
6567
6555
|
this.logInfo('clearOrderCartLines success', {});
|
|
6568
|
-
return
|
|
6569
|
-
case
|
|
6556
|
+
return _context33.abrupt("return", tempOrder);
|
|
6557
|
+
case 20:
|
|
6570
6558
|
case "end":
|
|
6571
|
-
return
|
|
6559
|
+
return _context33.stop();
|
|
6572
6560
|
}
|
|
6573
6561
|
}, _callee31, this);
|
|
6574
6562
|
}));
|
|
@@ -6587,11 +6575,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6587
6575
|
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
|
|
6588
6576
|
var _this$store$discount22, _this$store$discount23;
|
|
6589
6577
|
var tempOrder;
|
|
6590
|
-
return _regeneratorRuntime().wrap(function _callee32$(
|
|
6591
|
-
while (1) switch (
|
|
6578
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context34) {
|
|
6579
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
6592
6580
|
case 0:
|
|
6593
6581
|
tempOrder = this.ensureTempOrder();
|
|
6594
6582
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
6583
|
+
removeProductHolderRelations(tempOrder, tempOrder.products);
|
|
6595
6584
|
tempOrder.products = [];
|
|
6596
6585
|
tempOrder.bookings = [];
|
|
6597
6586
|
this.removeSalesNotesForMissingProductLines(tempOrder);
|
|
@@ -6607,26 +6596,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6607
6596
|
productsByUid: {}
|
|
6608
6597
|
});
|
|
6609
6598
|
}
|
|
6610
|
-
|
|
6599
|
+
_context34.next = 16;
|
|
6611
6600
|
return (_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.setDiscountList([]);
|
|
6612
|
-
case
|
|
6613
|
-
|
|
6601
|
+
case 16:
|
|
6602
|
+
_context34.next = 18;
|
|
6614
6603
|
return (_this$store$discount23 = this.store.discount) === null || _this$store$discount23 === void 0 ? void 0 : _this$store$discount23.setOriginalDiscountList([]);
|
|
6615
|
-
case
|
|
6604
|
+
case 18:
|
|
6616
6605
|
this.hasActiveCustomerBoundDiscount = false;
|
|
6617
6606
|
this.lastUnfulfilledPromotions = [];
|
|
6618
6607
|
this.lastGiftActions = null;
|
|
6619
|
-
|
|
6608
|
+
_context34.next = 23;
|
|
6620
6609
|
return this.recalculateSummary({
|
|
6621
6610
|
createIfMissing: true
|
|
6622
6611
|
});
|
|
6623
|
-
case
|
|
6612
|
+
case 23:
|
|
6624
6613
|
this.persistTempOrder();
|
|
6625
6614
|
this.logInfo('clearOrderForSettlementSwitch success', {});
|
|
6626
|
-
return
|
|
6627
|
-
case
|
|
6615
|
+
return _context34.abrupt("return", tempOrder);
|
|
6616
|
+
case 26:
|
|
6628
6617
|
case "end":
|
|
6629
|
-
return
|
|
6618
|
+
return _context34.stop();
|
|
6630
6619
|
}
|
|
6631
6620
|
}, _callee32, this);
|
|
6632
6621
|
}));
|
|
@@ -6668,15 +6657,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6668
6657
|
value: function () {
|
|
6669
6658
|
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(order) {
|
|
6670
6659
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
6671
|
-
return _regeneratorRuntime().wrap(function _callee33$(
|
|
6672
|
-
while (1) switch (
|
|
6660
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context35) {
|
|
6661
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
6673
6662
|
case 0:
|
|
6674
6663
|
tempOrder = this.ensureTempOrder();
|
|
6675
6664
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
6676
|
-
|
|
6665
|
+
_context35.next = 3;
|
|
6677
6666
|
break;
|
|
6678
6667
|
}
|
|
6679
|
-
return
|
|
6668
|
+
return _context35.abrupt("return", tempOrder);
|
|
6680
6669
|
case 3:
|
|
6681
6670
|
shopOrderNumber = order.shop_order_number;
|
|
6682
6671
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -6687,13 +6676,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6687
6676
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
6688
6677
|
}
|
|
6689
6678
|
this.persistTempOrder();
|
|
6690
|
-
|
|
6679
|
+
_context35.next = 10;
|
|
6691
6680
|
return this.saveDraft();
|
|
6692
6681
|
case 10:
|
|
6693
|
-
return
|
|
6682
|
+
return _context35.abrupt("return", tempOrder);
|
|
6694
6683
|
case 11:
|
|
6695
6684
|
case "end":
|
|
6696
|
-
return
|
|
6685
|
+
return _context35.stop();
|
|
6697
6686
|
}
|
|
6698
6687
|
}, _callee33, this);
|
|
6699
6688
|
}));
|
|
@@ -6708,32 +6697,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6708
6697
|
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
6709
6698
|
var _params$cacheId2, _this$otherParams8, _this$otherParams9, _this$otherParams10, _params$type, _this$otherParams11, _payload$products;
|
|
6710
6699
|
var tempOrder, latestSummary, payload;
|
|
6711
|
-
return _regeneratorRuntime().wrap(function _callee34$(
|
|
6712
|
-
while (1) switch (
|
|
6700
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context36) {
|
|
6701
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
6713
6702
|
case 0:
|
|
6714
6703
|
tempOrder = this.ensureTempOrder();
|
|
6715
6704
|
this.ensureExternalSaleNumber(tempOrder);
|
|
6716
6705
|
this.persistTempOrder();
|
|
6717
|
-
|
|
6706
|
+
_context36.next = 5;
|
|
6718
6707
|
return this.recalculateSummary({
|
|
6719
6708
|
createIfMissing: true
|
|
6720
6709
|
});
|
|
6721
6710
|
case 5:
|
|
6722
|
-
|
|
6723
|
-
if (
|
|
6724
|
-
|
|
6711
|
+
_context36.t1 = _context36.sent;
|
|
6712
|
+
if (_context36.t1) {
|
|
6713
|
+
_context36.next = 8;
|
|
6725
6714
|
break;
|
|
6726
6715
|
}
|
|
6727
|
-
|
|
6716
|
+
_context36.t1 = this.store.summary;
|
|
6728
6717
|
case 8:
|
|
6729
|
-
|
|
6730
|
-
if (
|
|
6731
|
-
|
|
6718
|
+
_context36.t0 = _context36.t1;
|
|
6719
|
+
if (_context36.t0) {
|
|
6720
|
+
_context36.next = 11;
|
|
6732
6721
|
break;
|
|
6733
6722
|
}
|
|
6734
|
-
|
|
6723
|
+
_context36.t0 = createEmptySummary();
|
|
6735
6724
|
case 11:
|
|
6736
|
-
latestSummary =
|
|
6725
|
+
latestSummary = _context36.t0;
|
|
6737
6726
|
payload = buildSubmitPayload({
|
|
6738
6727
|
tempOrder: tempOrder,
|
|
6739
6728
|
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
@@ -6754,13 +6743,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6754
6743
|
externalSaleNumber: payload.external_sale_number,
|
|
6755
6744
|
productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
|
|
6756
6745
|
});
|
|
6757
|
-
return
|
|
6746
|
+
return _context36.abrupt("return", this.request.post('/order/sales/draft', payload, {
|
|
6758
6747
|
osServer: true,
|
|
6759
6748
|
customToast: function customToast() {}
|
|
6760
6749
|
}));
|
|
6761
6750
|
case 18:
|
|
6762
6751
|
case "end":
|
|
6763
|
-
return
|
|
6752
|
+
return _context36.stop();
|
|
6764
6753
|
}
|
|
6765
6754
|
}, _callee34, this);
|
|
6766
6755
|
}));
|
|
@@ -6779,13 +6768,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6779
6768
|
key: "submitTempOrder",
|
|
6780
6769
|
value: (function () {
|
|
6781
6770
|
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
6782
|
-
return _regeneratorRuntime().wrap(function _callee35$(
|
|
6783
|
-
while (1) switch (
|
|
6771
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context37) {
|
|
6772
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
6784
6773
|
case 0:
|
|
6785
|
-
return
|
|
6774
|
+
return _context37.abrupt("return", this.runSubmitTempOrder(params));
|
|
6786
6775
|
case 1:
|
|
6787
6776
|
case "end":
|
|
6788
|
-
return
|
|
6777
|
+
return _context37.stop();
|
|
6789
6778
|
}
|
|
6790
6779
|
}, _callee35, this);
|
|
6791
6780
|
}));
|
|
@@ -6798,15 +6787,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6798
6787
|
key: "submitTempOrderAsync",
|
|
6799
6788
|
value: function () {
|
|
6800
6789
|
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
6801
|
-
return _regeneratorRuntime().wrap(function _callee36$(
|
|
6802
|
-
while (1) switch (
|
|
6790
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context38) {
|
|
6791
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
6803
6792
|
case 0:
|
|
6804
|
-
return
|
|
6793
|
+
return _context38.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
6805
6794
|
syncMode: true
|
|
6806
6795
|
})));
|
|
6807
6796
|
case 1:
|
|
6808
6797
|
case "end":
|
|
6809
|
-
return
|
|
6798
|
+
return _context38.stop();
|
|
6810
6799
|
}
|
|
6811
6800
|
}, _callee36, this);
|
|
6812
6801
|
}));
|
|
@@ -6821,12 +6810,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6821
6810
|
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
6822
6811
|
var _params$cacheId3, _this$otherParams12, _ref92, _ref93, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
|
|
6823
6812
|
var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
|
|
6824
|
-
return _regeneratorRuntime().wrap(function _callee37$(
|
|
6825
|
-
while (1) switch (
|
|
6813
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context39) {
|
|
6814
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
6826
6815
|
case 0:
|
|
6827
6816
|
tempOrder = this.ensureTempOrder();
|
|
6828
6817
|
if (!requiresLocalPaymentRefresh(tempOrder)) {
|
|
6829
|
-
|
|
6818
|
+
_context39.next = 3;
|
|
6830
6819
|
break;
|
|
6831
6820
|
}
|
|
6832
6821
|
throw new Error(PAYMENT_REFRESH_MESSAGE);
|
|
@@ -6852,26 +6841,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6852
6841
|
}
|
|
6853
6842
|
}
|
|
6854
6843
|
this.persistTempOrder();
|
|
6855
|
-
|
|
6844
|
+
_context39.next = 12;
|
|
6856
6845
|
return this.recalculateSummary({
|
|
6857
6846
|
createIfMissing: true
|
|
6858
6847
|
});
|
|
6859
6848
|
case 12:
|
|
6860
|
-
|
|
6861
|
-
if (
|
|
6862
|
-
|
|
6849
|
+
_context39.t1 = _context39.sent;
|
|
6850
|
+
if (_context39.t1) {
|
|
6851
|
+
_context39.next = 15;
|
|
6863
6852
|
break;
|
|
6864
6853
|
}
|
|
6865
|
-
|
|
6854
|
+
_context39.t1 = this.store.summary;
|
|
6866
6855
|
case 15:
|
|
6867
|
-
|
|
6868
|
-
if (
|
|
6869
|
-
|
|
6856
|
+
_context39.t0 = _context39.t1;
|
|
6857
|
+
if (_context39.t0) {
|
|
6858
|
+
_context39.next = 18;
|
|
6870
6859
|
break;
|
|
6871
6860
|
}
|
|
6872
|
-
|
|
6861
|
+
_context39.t0 = createEmptySummary();
|
|
6873
6862
|
case 18:
|
|
6874
|
-
latestSummary =
|
|
6863
|
+
latestSummary = _context39.t0;
|
|
6875
6864
|
effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
|
|
6876
6865
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
6877
6866
|
shouldOverridePaymentStatus = hasPaymentStatusOverride && !isOnlineStorePlatform && !shouldConfirmPendingVoucherPayments;
|
|
@@ -6907,10 +6896,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6907
6896
|
if (!payload.created_at) {
|
|
6908
6897
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
6909
6898
|
}
|
|
6910
|
-
|
|
6899
|
+
_context39.next = 30;
|
|
6911
6900
|
return this.saveDraft();
|
|
6912
6901
|
case 30:
|
|
6913
|
-
|
|
6902
|
+
_context39.prev = 30;
|
|
6914
6903
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
6915
6904
|
orderId: payload.order_id,
|
|
6916
6905
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -6920,43 +6909,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6920
6909
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
6921
6910
|
syncMode: payload.sync_mode
|
|
6922
6911
|
});
|
|
6923
|
-
|
|
6912
|
+
_context39.next = 34;
|
|
6924
6913
|
return this.submitSalesOrder({
|
|
6925
6914
|
query: payload
|
|
6926
6915
|
});
|
|
6927
6916
|
case 34:
|
|
6928
|
-
result =
|
|
6929
|
-
|
|
6917
|
+
result = _context39.sent;
|
|
6918
|
+
_context39.next = 47;
|
|
6930
6919
|
break;
|
|
6931
6920
|
case 37:
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
6921
|
+
_context39.prev = 37;
|
|
6922
|
+
_context39.t2 = _context39["catch"](30);
|
|
6923
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context39.t2);
|
|
6935
6924
|
if (!backendErrorResponse) {
|
|
6936
|
-
|
|
6925
|
+
_context39.next = 44;
|
|
6937
6926
|
break;
|
|
6938
6927
|
}
|
|
6939
6928
|
this.store.syncState = 'failed';
|
|
6940
6929
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
6941
|
-
return
|
|
6930
|
+
return _context39.abrupt("return", backendErrorResponse);
|
|
6942
6931
|
case 44:
|
|
6943
6932
|
this.store.syncState = 'failed';
|
|
6944
6933
|
this.logError('submitTempOrder failed', {
|
|
6945
|
-
error:
|
|
6934
|
+
error: _context39.t2 instanceof Error ? _context39.t2.message : String(_context39.t2),
|
|
6946
6935
|
orderId: payload.order_id,
|
|
6947
6936
|
externalSaleNumber: payload.external_sale_number,
|
|
6948
6937
|
paymentStatus: payload.payment_status,
|
|
6949
6938
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
6950
6939
|
});
|
|
6951
|
-
throw
|
|
6940
|
+
throw _context39.t2;
|
|
6952
6941
|
case 47:
|
|
6953
6942
|
if (!this.isSubmitResponseRejected(result)) {
|
|
6954
|
-
|
|
6943
|
+
_context39.next = 51;
|
|
6955
6944
|
break;
|
|
6956
6945
|
}
|
|
6957
6946
|
this.store.syncState = 'failed';
|
|
6958
6947
|
this.logSubmitBackendRejected(result, payload);
|
|
6959
|
-
return
|
|
6948
|
+
return _context39.abrupt("return", result);
|
|
6960
6949
|
case 51:
|
|
6961
6950
|
isLocalPendingSubmit = this.isLocalPendingSubmitResult(result); // need_sync=1 仅表示已进入本地同步队列,不能视为远端已确认 Notes。
|
|
6962
6951
|
if (Object.prototype.hasOwnProperty.call(payload, 'notes') && !isLocalPendingSubmit) {
|
|
@@ -6972,12 +6961,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6972
6961
|
})
|
|
6973
6962
|
});
|
|
6974
6963
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
6975
|
-
|
|
6964
|
+
_context39.next = 60;
|
|
6976
6965
|
break;
|
|
6977
6966
|
}
|
|
6978
6967
|
tempOrder.order_id = submittedOrderId;
|
|
6979
6968
|
resultRecord = result;
|
|
6980
|
-
|
|
6969
|
+
_context39.next = 60;
|
|
6981
6970
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
6982
6971
|
case 60:
|
|
6983
6972
|
if (isLocalPendingSubmit) {
|
|
@@ -6985,10 +6974,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6985
6974
|
} else if (submittedOrderId === null || submittedOrderId === undefined) {
|
|
6986
6975
|
this.store.syncState = 'submitted';
|
|
6987
6976
|
}
|
|
6988
|
-
return
|
|
6977
|
+
return _context39.abrupt("return", result);
|
|
6989
6978
|
case 62:
|
|
6990
6979
|
case "end":
|
|
6991
|
-
return
|
|
6980
|
+
return _context39.stop();
|
|
6992
6981
|
}
|
|
6993
6982
|
}, _callee37, this, [[30, 37]]);
|
|
6994
6983
|
}));
|
|
@@ -7002,8 +6991,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7002
6991
|
value: function () {
|
|
7003
6992
|
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(orderId, remoteOrder) {
|
|
7004
6993
|
var tempOrder;
|
|
7005
|
-
return _regeneratorRuntime().wrap(function _callee38$(
|
|
7006
|
-
while (1) switch (
|
|
6994
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context40) {
|
|
6995
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
7007
6996
|
case 0:
|
|
7008
6997
|
tempOrder = this.ensureTempOrder();
|
|
7009
6998
|
tempOrder.order_id = orderId;
|
|
@@ -7011,11 +7000,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7011
7000
|
this.store.lastOrderInfo = remoteOrder;
|
|
7012
7001
|
this.store.syncState = 'submitted';
|
|
7013
7002
|
this.persistTempOrder();
|
|
7014
|
-
|
|
7003
|
+
_context40.next = 8;
|
|
7015
7004
|
return this.saveDraft();
|
|
7016
7005
|
case 8:
|
|
7017
7006
|
case "end":
|
|
7018
|
-
return
|
|
7007
|
+
return _context40.stop();
|
|
7019
7008
|
}
|
|
7020
7009
|
}, _callee38, this);
|
|
7021
7010
|
}));
|
|
@@ -7062,10 +7051,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7062
7051
|
value: function extractSubmitErrorResponse(error) {
|
|
7063
7052
|
var _error$response,
|
|
7064
7053
|
_error$response2,
|
|
7065
|
-
|
|
7054
|
+
_this38 = this;
|
|
7066
7055
|
var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
|
|
7067
7056
|
return candidates.find(function (candidate) {
|
|
7068
|
-
return
|
|
7057
|
+
return _this38.isSubmitErrorResponse(candidate);
|
|
7069
7058
|
}) || null;
|
|
7070
7059
|
}
|
|
7071
7060
|
}, {
|
|
@@ -7093,32 +7082,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7093
7082
|
key: "syncPaymentsToOrder",
|
|
7094
7083
|
value: function () {
|
|
7095
7084
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
7096
|
-
var
|
|
7085
|
+
var _this39 = this,
|
|
7097
7086
|
_params$confirmPendin;
|
|
7098
7087
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
7099
|
-
return _regeneratorRuntime().wrap(function _callee39$(
|
|
7100
|
-
while (1) switch (
|
|
7088
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context41) {
|
|
7089
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
7101
7090
|
case 0:
|
|
7102
7091
|
tempOrder = this.ensureTempOrder();
|
|
7103
7092
|
needsPaymentNumber = (params.payments || []).some(function (payment) {
|
|
7104
7093
|
return String(payment.payment_number || '').trim() === '';
|
|
7105
7094
|
});
|
|
7106
7095
|
if (!needsPaymentNumber) {
|
|
7107
|
-
|
|
7096
|
+
_context41.next = 8;
|
|
7108
7097
|
break;
|
|
7109
7098
|
}
|
|
7110
|
-
|
|
7099
|
+
_context41.next = 5;
|
|
7111
7100
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
7112
7101
|
case 5:
|
|
7113
|
-
|
|
7114
|
-
|
|
7102
|
+
_context41.t0 = _context41.sent;
|
|
7103
|
+
_context41.next = 9;
|
|
7115
7104
|
break;
|
|
7116
7105
|
case 8:
|
|
7117
|
-
|
|
7106
|
+
_context41.t0 = 'LOCAL';
|
|
7118
7107
|
case 9:
|
|
7119
|
-
devicePrefix =
|
|
7108
|
+
devicePrefix = _context41.t0;
|
|
7120
7109
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
7121
|
-
return
|
|
7110
|
+
return _this39.normalizePaymentSource(payment, {
|
|
7122
7111
|
defaultPaid: false,
|
|
7123
7112
|
devicePrefix: devicePrefix
|
|
7124
7113
|
});
|
|
@@ -7131,20 +7120,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7131
7120
|
tempOrder.payments = effectivePayments;
|
|
7132
7121
|
tempOrder.payment_status = paymentStatus;
|
|
7133
7122
|
this.persistTempOrder();
|
|
7134
|
-
|
|
7123
|
+
_context41.next = 21;
|
|
7135
7124
|
return this.saveDraft();
|
|
7136
7125
|
case 21:
|
|
7137
7126
|
if (params.submitWhenPaid) {
|
|
7138
|
-
|
|
7127
|
+
_context41.next = 23;
|
|
7139
7128
|
break;
|
|
7140
7129
|
}
|
|
7141
|
-
return
|
|
7130
|
+
return _context41.abrupt("return", completion);
|
|
7142
7131
|
case 23:
|
|
7143
7132
|
if (!(this.store.syncState === 'submitting')) {
|
|
7144
|
-
|
|
7133
|
+
_context41.next = 25;
|
|
7145
7134
|
break;
|
|
7146
7135
|
}
|
|
7147
|
-
return
|
|
7136
|
+
return _context41.abrupt("return", completion);
|
|
7148
7137
|
case 25:
|
|
7149
7138
|
this.store.syncState = 'submitting';
|
|
7150
7139
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
@@ -7164,28 +7153,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7164
7153
|
enhancePayload: enhancePayload
|
|
7165
7154
|
};
|
|
7166
7155
|
if (!(params.checkoutSyncTaskEnabled === false)) {
|
|
7167
|
-
|
|
7156
|
+
_context41.next = 35;
|
|
7168
7157
|
break;
|
|
7169
7158
|
}
|
|
7170
|
-
|
|
7159
|
+
_context41.next = 32;
|
|
7171
7160
|
return this.submitTempOrderAsync(submitParams);
|
|
7172
7161
|
case 32:
|
|
7173
|
-
|
|
7174
|
-
|
|
7162
|
+
_context41.t1 = _context41.sent;
|
|
7163
|
+
_context41.next = 38;
|
|
7175
7164
|
break;
|
|
7176
7165
|
case 35:
|
|
7177
|
-
|
|
7166
|
+
_context41.next = 37;
|
|
7178
7167
|
return this.submitTempOrder(submitParams);
|
|
7179
7168
|
case 37:
|
|
7180
|
-
|
|
7169
|
+
_context41.t1 = _context41.sent;
|
|
7181
7170
|
case 38:
|
|
7182
|
-
submitResult =
|
|
7183
|
-
return
|
|
7171
|
+
submitResult = _context41.t1;
|
|
7172
|
+
return _context41.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
7184
7173
|
submitResult: submitResult
|
|
7185
7174
|
}));
|
|
7186
7175
|
case 40:
|
|
7187
7176
|
case "end":
|
|
7188
|
-
return
|
|
7177
|
+
return _context41.stop();
|
|
7189
7178
|
}
|
|
7190
7179
|
}, _callee39, this);
|
|
7191
7180
|
}));
|
|
@@ -7197,7 +7186,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7197
7186
|
}, {
|
|
7198
7187
|
key: "createOrder",
|
|
7199
7188
|
value: function createOrder(params) {
|
|
7200
|
-
var
|
|
7189
|
+
var _this40 = this;
|
|
7201
7190
|
var order = _objectSpread({
|
|
7202
7191
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
7203
7192
|
// 要从外面拿,virtual
|
|
@@ -7229,7 +7218,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7229
7218
|
|
|
7230
7219
|
// 为预约补齐 holder 信息
|
|
7231
7220
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
7232
|
-
ensureCartItemOriginHolder(item,
|
|
7221
|
+
ensureCartItemOriginHolder(item, _this40.window);
|
|
7233
7222
|
}
|
|
7234
7223
|
|
|
7235
7224
|
// 购物车是否为普通商品
|
|
@@ -7289,8 +7278,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7289
7278
|
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(order) {
|
|
7290
7279
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
7291
7280
|
var url, query, fetchUrl, params;
|
|
7292
|
-
return _regeneratorRuntime().wrap(function _callee40$(
|
|
7293
|
-
while (1) switch (
|
|
7281
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context42) {
|
|
7282
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
7294
7283
|
case 0:
|
|
7295
7284
|
this.logInfo('submitOrder called', {
|
|
7296
7285
|
url: order.url,
|
|
@@ -7310,10 +7299,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7310
7299
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
7311
7300
|
scheduleDate: params.schedule_date
|
|
7312
7301
|
});
|
|
7313
|
-
return
|
|
7302
|
+
return _context42.abrupt("return", this.request.post(fetchUrl, params));
|
|
7314
7303
|
case 6:
|
|
7315
7304
|
case "end":
|
|
7316
|
-
return
|
|
7305
|
+
return _context42.stop();
|
|
7317
7306
|
}
|
|
7318
7307
|
}, _callee40, this);
|
|
7319
7308
|
}));
|
|
@@ -7327,11 +7316,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7327
7316
|
value: function () {
|
|
7328
7317
|
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
7329
7318
|
var payload;
|
|
7330
|
-
return _regeneratorRuntime().wrap(function _callee41$(
|
|
7331
|
-
while (1) switch (
|
|
7319
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context43) {
|
|
7320
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
7332
7321
|
case 0:
|
|
7333
7322
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
7334
|
-
|
|
7323
|
+
_context43.next = 2;
|
|
7335
7324
|
break;
|
|
7336
7325
|
}
|
|
7337
7326
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -7347,12 +7336,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7347
7336
|
method: 'PUT',
|
|
7348
7337
|
orderIdsCount: params.order_ids.length
|
|
7349
7338
|
});
|
|
7350
|
-
return
|
|
7339
|
+
return _context43.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
7351
7340
|
isShopApi: true
|
|
7352
7341
|
}));
|
|
7353
7342
|
case 5:
|
|
7354
7343
|
case "end":
|
|
7355
|
-
return
|
|
7344
|
+
return _context43.stop();
|
|
7356
7345
|
}
|
|
7357
7346
|
}, _callee41, this);
|
|
7358
7347
|
}));
|
|
@@ -7366,17 +7355,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7366
7355
|
value: function () {
|
|
7367
7356
|
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
|
|
7368
7357
|
var url, payload;
|
|
7369
|
-
return _regeneratorRuntime().wrap(function _callee42$(
|
|
7370
|
-
while (1) switch (
|
|
7358
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context44) {
|
|
7359
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
7371
7360
|
case 0:
|
|
7372
7361
|
if (params.booking_id) {
|
|
7373
|
-
|
|
7362
|
+
_context44.next = 2;
|
|
7374
7363
|
break;
|
|
7375
7364
|
}
|
|
7376
7365
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
7377
7366
|
case 2:
|
|
7378
7367
|
if (params.appointment_status) {
|
|
7379
|
-
|
|
7368
|
+
_context44.next = 4;
|
|
7380
7369
|
break;
|
|
7381
7370
|
}
|
|
7382
7371
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -7391,12 +7380,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7391
7380
|
bookingId: params.booking_id,
|
|
7392
7381
|
appointmentStatus: params.appointment_status
|
|
7393
7382
|
});
|
|
7394
|
-
return
|
|
7383
|
+
return _context44.abrupt("return", this.request.put(url, payload, {
|
|
7395
7384
|
isShopApi: true
|
|
7396
7385
|
}));
|
|
7397
7386
|
case 8:
|
|
7398
7387
|
case "end":
|
|
7399
|
-
return
|
|
7388
|
+
return _context44.stop();
|
|
7400
7389
|
}
|
|
7401
7390
|
}, _callee42, this);
|
|
7402
7391
|
}));
|
|
@@ -7421,8 +7410,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7421
7410
|
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
7422
7411
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3;
|
|
7423
7412
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, orderData, response;
|
|
7424
|
-
return _regeneratorRuntime().wrap(function _callee43$(
|
|
7425
|
-
while (1) switch (
|
|
7413
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context45) {
|
|
7414
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
7426
7415
|
case 0:
|
|
7427
7416
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
7428
7417
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -7447,7 +7436,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7447
7436
|
return p.code;
|
|
7448
7437
|
})) || []
|
|
7449
7438
|
});
|
|
7450
|
-
|
|
7439
|
+
_context45.prev = 3;
|
|
7451
7440
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
7452
7441
|
orderData = _objectSpread({
|
|
7453
7442
|
sales_channel: 'my_pisel',
|
|
@@ -7495,28 +7484,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7495
7484
|
hasOrderId: !!orderData.order_id,
|
|
7496
7485
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
7497
7486
|
});
|
|
7498
|
-
|
|
7487
|
+
_context45.next = 10;
|
|
7499
7488
|
return this.request.post('/order/checkout', orderData, {
|
|
7500
7489
|
osServer: true,
|
|
7501
7490
|
customToast: function customToast() {}
|
|
7502
7491
|
});
|
|
7503
7492
|
case 10:
|
|
7504
|
-
response =
|
|
7493
|
+
response = _context45.sent;
|
|
7505
7494
|
this.logInfo('Order API called successfully', {
|
|
7506
7495
|
response: response
|
|
7507
7496
|
});
|
|
7508
|
-
return
|
|
7497
|
+
return _context45.abrupt("return", response);
|
|
7509
7498
|
case 15:
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
7499
|
+
_context45.prev = 15;
|
|
7500
|
+
_context45.t0 = _context45["catch"](3);
|
|
7501
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context45.t0);
|
|
7513
7502
|
this.logInfo('Order API called failed', {
|
|
7514
|
-
error:
|
|
7503
|
+
error: _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0)
|
|
7515
7504
|
});
|
|
7516
|
-
throw
|
|
7505
|
+
throw _context45.t0;
|
|
7517
7506
|
case 20:
|
|
7518
7507
|
case "end":
|
|
7519
|
-
return
|
|
7508
|
+
return _context45.stop();
|
|
7520
7509
|
}
|
|
7521
7510
|
}, _callee43, this, [[3, 15]]);
|
|
7522
7511
|
}));
|
|
@@ -7530,19 +7519,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7530
7519
|
value: function () {
|
|
7531
7520
|
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
|
|
7532
7521
|
var url, query, fetchUrl, requestQuery;
|
|
7533
|
-
return _regeneratorRuntime().wrap(function _callee44$(
|
|
7534
|
-
while (1) switch (
|
|
7522
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context46) {
|
|
7523
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
7535
7524
|
case 0:
|
|
7536
7525
|
url = params.url, query = params.query;
|
|
7537
7526
|
fetchUrl = url || '/order/sales/checkout';
|
|
7538
7527
|
requestQuery = this.isSalesCheckoutHandledByOsServer(fetchUrl) ? query : stripLocalEftposState(stripOsPrivatePayloadFields(query));
|
|
7539
|
-
return
|
|
7528
|
+
return _context46.abrupt("return", this.request.post(fetchUrl, requestQuery, {
|
|
7540
7529
|
osServer: true,
|
|
7541
7530
|
customToast: function customToast() {}
|
|
7542
7531
|
}));
|
|
7543
7532
|
case 4:
|
|
7544
7533
|
case "end":
|
|
7545
|
-
return
|
|
7534
|
+
return _context46.stop();
|
|
7546
7535
|
}
|
|
7547
7536
|
}, _callee44, this);
|
|
7548
7537
|
}));
|
|
@@ -7576,30 +7565,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7576
7565
|
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
|
|
7577
7566
|
var _params$emails;
|
|
7578
7567
|
var orderIds;
|
|
7579
|
-
return _regeneratorRuntime().wrap(function _callee45$(
|
|
7580
|
-
while (1) switch (
|
|
7568
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context47) {
|
|
7569
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
7581
7570
|
case 0:
|
|
7582
7571
|
orderIds = params.order_ids || params.orderIds || [];
|
|
7583
7572
|
if (orderIds.length) {
|
|
7584
|
-
|
|
7573
|
+
_context47.next = 3;
|
|
7585
7574
|
break;
|
|
7586
7575
|
}
|
|
7587
7576
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
7588
7577
|
case 3:
|
|
7589
7578
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
7590
|
-
|
|
7579
|
+
_context47.next = 5;
|
|
7591
7580
|
break;
|
|
7592
7581
|
}
|
|
7593
7582
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
7594
7583
|
case 5:
|
|
7595
|
-
return
|
|
7584
|
+
return _context47.abrupt("return", this.request.post('/order/batch-email', {
|
|
7596
7585
|
order_ids: orderIds,
|
|
7597
7586
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
7598
7587
|
emails: params.emails
|
|
7599
7588
|
}));
|
|
7600
7589
|
case 6:
|
|
7601
7590
|
case "end":
|
|
7602
|
-
return
|
|
7591
|
+
return _context47.stop();
|
|
7603
7592
|
}
|
|
7604
7593
|
}, _callee45, this);
|
|
7605
7594
|
}));
|
|
@@ -7613,12 +7602,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7613
7602
|
value: function () {
|
|
7614
7603
|
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
|
|
7615
7604
|
var lookup, res;
|
|
7616
|
-
return _regeneratorRuntime().wrap(function _callee46$(
|
|
7617
|
-
while (1) switch (
|
|
7605
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context48) {
|
|
7606
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
7618
7607
|
case 0:
|
|
7619
7608
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
7620
7609
|
if (lookup) {
|
|
7621
|
-
|
|
7610
|
+
_context48.next = 3;
|
|
7622
7611
|
break;
|
|
7623
7612
|
}
|
|
7624
7613
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -7627,21 +7616,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7627
7616
|
if (lookup.startsWith('LOCAL_')) {
|
|
7628
7617
|
params.forceRemote = false;
|
|
7629
7618
|
}
|
|
7630
|
-
|
|
7619
|
+
_context48.next = 6;
|
|
7631
7620
|
return loadSalesOrderSnapshot(this.request, {
|
|
7632
7621
|
lookup: lookup,
|
|
7633
7622
|
transport: 'os-server',
|
|
7634
7623
|
forceRemote: params.forceRemote
|
|
7635
7624
|
});
|
|
7636
7625
|
case 6:
|
|
7637
|
-
res =
|
|
7626
|
+
res = _context48.sent;
|
|
7638
7627
|
if (res.code === 200) {
|
|
7639
7628
|
this.store.lastOrderInfo = res.data;
|
|
7640
7629
|
}
|
|
7641
|
-
return
|
|
7630
|
+
return _context48.abrupt("return", res);
|
|
7642
7631
|
case 9:
|
|
7643
7632
|
case "end":
|
|
7644
|
-
return
|
|
7633
|
+
return _context48.stop();
|
|
7645
7634
|
}
|
|
7646
7635
|
}, _callee46, this);
|
|
7647
7636
|
}));
|
|
@@ -7662,8 +7651,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7662
7651
|
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(record, options) {
|
|
7663
7652
|
var _sourceRaw$_extend, _this$store$discount26;
|
|
7664
7653
|
var sourceRaw, duplicateProductIdentityRepair, duplicateIdentityReadySource, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, isSessionStorageHydrate, isMergedSalesDetailHydrate, nextTempOrder, _this$store$discount24, _this$store$discount25, restoredSessionDiscounts, nextExtend, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, historicalDepositSnapshot, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount27, _this$store$discount28;
|
|
7665
|
-
return _regeneratorRuntime().wrap(function _callee47$(
|
|
7666
|
-
while (1) switch (
|
|
7654
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context49) {
|
|
7655
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
7667
7656
|
case 0:
|
|
7668
7657
|
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
7669
7658
|
duplicateProductIdentityRepair = repairDuplicateOrderProductLineIdentities(Array.isArray(sourceRaw.products) ? sourceRaw.products : [], (_sourceRaw$_extend = sourceRaw._extend) === null || _sourceRaw$_extend === void 0 ? void 0 : _sourceRaw$_extend.productsByUid);
|
|
@@ -7705,7 +7694,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7705
7694
|
this.store.tempOrder = nextTempOrder;
|
|
7706
7695
|
this.clearCustomerWalletRuntimeState();
|
|
7707
7696
|
if (!isSessionStorageHydrate) {
|
|
7708
|
-
|
|
7697
|
+
_context49.next = 31;
|
|
7709
7698
|
break;
|
|
7710
7699
|
}
|
|
7711
7700
|
// 会话快照是未提交购物车,不应获得编辑订单的 saved/edit 标记与服务端基线。
|
|
@@ -7721,23 +7710,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7721
7710
|
nextTempOrder.discount_list = restoredSessionDiscounts;
|
|
7722
7711
|
this.store.summary = createEmptySummary();
|
|
7723
7712
|
this.store.lastOrderInfo = undefined;
|
|
7724
|
-
|
|
7713
|
+
_context49.next = 24;
|
|
7725
7714
|
return (_this$store$discount24 = this.store.discount) === null || _this$store$discount24 === void 0 ? void 0 : _this$store$discount24.setOriginalDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
7726
7715
|
case 24:
|
|
7727
|
-
|
|
7716
|
+
_context49.next = 26;
|
|
7728
7717
|
return (_this$store$discount25 = this.store.discount) === null || _this$store$discount25 === void 0 ? void 0 : _this$store$discount25.setDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
7729
7718
|
case 26:
|
|
7730
7719
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
7731
|
-
|
|
7720
|
+
_context49.next = 29;
|
|
7732
7721
|
break;
|
|
7733
7722
|
}
|
|
7734
|
-
|
|
7723
|
+
_context49.next = 29;
|
|
7735
7724
|
return this.recalculateSummary({
|
|
7736
7725
|
createIfMissing: false
|
|
7737
7726
|
});
|
|
7738
7727
|
case 29:
|
|
7739
7728
|
this.persistTempOrder();
|
|
7740
|
-
return
|
|
7729
|
+
return _context49.abrupt("return", nextTempOrder);
|
|
7741
7730
|
case 31:
|
|
7742
7731
|
// Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
|
|
7743
7732
|
sourceLastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
|
|
@@ -7758,6 +7747,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7758
7747
|
originalSalesSnapshot: _objectSpread(_objectSpread({
|
|
7759
7748
|
summary: cloneDeep(this.store.summary),
|
|
7760
7749
|
products: cloneDeep(nextTempOrder.products || []),
|
|
7750
|
+
holder_relations: cloneDeep(nextTempOrder.holder_relations),
|
|
7761
7751
|
bookings: cloneDeep(nextTempOrder.bookings || []),
|
|
7762
7752
|
payments: cloneDeep(nextTempOrder.payments || []),
|
|
7763
7753
|
surcharges: cloneDeep(nextTempOrder.surcharges || []),
|
|
@@ -7789,30 +7779,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7789
7779
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
7790
7780
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
7791
7781
|
if (shouldSkipEmptyDiscountSync) {
|
|
7792
|
-
|
|
7782
|
+
_context49.next = 55;
|
|
7793
7783
|
break;
|
|
7794
7784
|
}
|
|
7795
7785
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
7796
|
-
|
|
7786
|
+
_context49.next = 53;
|
|
7797
7787
|
return (_this$store$discount27 = this.store.discount) === null || _this$store$discount27 === void 0 ? void 0 : _this$store$discount27.setOriginalDiscountList(nextDiscounts);
|
|
7798
7788
|
case 53:
|
|
7799
|
-
|
|
7789
|
+
_context49.next = 55;
|
|
7800
7790
|
return (_this$store$discount28 = this.store.discount) === null || _this$store$discount28 === void 0 ? void 0 : _this$store$discount28.setDiscountList(nextDiscounts);
|
|
7801
7791
|
case 55:
|
|
7802
7792
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
7803
|
-
|
|
7793
|
+
_context49.next = 58;
|
|
7804
7794
|
break;
|
|
7805
7795
|
}
|
|
7806
|
-
|
|
7796
|
+
_context49.next = 58;
|
|
7807
7797
|
return this.recalculateSummary({
|
|
7808
7798
|
createIfMissing: false
|
|
7809
7799
|
});
|
|
7810
7800
|
case 58:
|
|
7811
7801
|
this.persistTempOrder();
|
|
7812
|
-
return
|
|
7802
|
+
return _context49.abrupt("return", nextTempOrder);
|
|
7813
7803
|
case 60:
|
|
7814
7804
|
case "end":
|
|
7815
|
-
return
|
|
7805
|
+
return _context49.stop();
|
|
7816
7806
|
}
|
|
7817
7807
|
}, _callee47, this);
|
|
7818
7808
|
}));
|
|
@@ -7930,7 +7920,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7930
7920
|
}, {
|
|
7931
7921
|
key: "normalizeTempOrderForRuntime",
|
|
7932
7922
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
7933
|
-
var
|
|
7923
|
+
var _this41 = this,
|
|
7934
7924
|
_raw$_extend;
|
|
7935
7925
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
7936
7926
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
@@ -7952,15 +7942,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7952
7942
|
delete nextTempOrder.total_refund_amount;
|
|
7953
7943
|
delete nextTempOrder.holder_id;
|
|
7954
7944
|
nextTempOrder.metadata = raw.metadata && _typeof(raw.metadata) === 'object' ? _objectSpread({}, raw.metadata) : {};
|
|
7945
|
+
var holderRelations = restoreLegacyHolderRelations(raw);
|
|
7946
|
+
if (holderRelations === undefined) delete nextTempOrder.holder_relations;else nextTempOrder.holder_relations = cloneDeep(holderRelations);
|
|
7947
|
+
ensureHolderRelationUuids(nextTempOrder);
|
|
7955
7948
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
7956
7949
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
7957
7950
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
7958
|
-
return
|
|
7951
|
+
return _this41.normalizeHydratedOrderProduct(p, {
|
|
7959
7952
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
7960
7953
|
});
|
|
7961
7954
|
}) : [];
|
|
7962
7955
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
7963
|
-
var booking =
|
|
7956
|
+
var booking = _this41.normalizeHydratedBookingHolder(b || {});
|
|
7964
7957
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
7965
7958
|
is_all: normalizeBookingIsAll(booking),
|
|
7966
7959
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -8040,6 +8033,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8040
8033
|
}
|
|
8041
8034
|
tempOrderExtend.productsByUid = productsByUid;
|
|
8042
8035
|
this.hydrateLinkedBookingIdentity(nextTempOrder);
|
|
8036
|
+
nextTempOrder.products.forEach(function (product) {
|
|
8037
|
+
return _this41.sanitizeOrderProductForTempOrder(product);
|
|
8038
|
+
});
|
|
8043
8039
|
if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
|
|
8044
8040
|
this.ensureExternalSaleNumber(nextTempOrder);
|
|
8045
8041
|
}
|
|
@@ -8167,7 +8163,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8167
8163
|
}, {
|
|
8168
8164
|
key: "normalizeHydratedOrderProduct",
|
|
8169
8165
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
8170
|
-
var
|
|
8166
|
+
var _this42 = this;
|
|
8171
8167
|
var row = _objectSpread({}, product || {});
|
|
8172
8168
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
8173
8169
|
row.num = row.product_quantity;
|
|
@@ -8175,7 +8171,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8175
8171
|
var productSku = ensureProductSku(row);
|
|
8176
8172
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
8177
8173
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
8178
|
-
return
|
|
8174
|
+
return _this42.normalizeHydratedProductOptionItem(optionItem || {});
|
|
8179
8175
|
}))
|
|
8180
8176
|
});
|
|
8181
8177
|
delete row["product_".concat('option', "_item")];
|
|
@@ -8224,7 +8220,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8224
8220
|
});
|
|
8225
8221
|
if (result.metadata) delete result.metadata.price_schema_version;
|
|
8226
8222
|
var restored = restoreHydratedBundleDiscounts(result, normalizeOrderProductDiscountList);
|
|
8227
|
-
return this.sanitizeOrderProductForTempOrder(this.normalizeVirtualSettlementProductIfEnabled(restored));
|
|
8223
|
+
return this.sanitizeOrderProductForTempOrder(this.normalizeVirtualSettlementProductIfEnabled(restored), true);
|
|
8228
8224
|
}
|
|
8229
8225
|
}, {
|
|
8230
8226
|
key: "getLastOrderInfo",
|
|
@@ -8237,21 +8233,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8237
8233
|
value: function () {
|
|
8238
8234
|
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(order_id) {
|
|
8239
8235
|
var res;
|
|
8240
|
-
return _regeneratorRuntime().wrap(function _callee48$(
|
|
8241
|
-
while (1) switch (
|
|
8236
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context50) {
|
|
8237
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
8242
8238
|
case 0:
|
|
8243
|
-
|
|
8239
|
+
_context50.next = 2;
|
|
8244
8240
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
8245
8241
|
with: ['products', 'bookings', 'notes']
|
|
8246
8242
|
}, {
|
|
8247
8243
|
osServer: true
|
|
8248
8244
|
});
|
|
8249
8245
|
case 2:
|
|
8250
|
-
res =
|
|
8251
|
-
return
|
|
8246
|
+
res = _context50.sent;
|
|
8247
|
+
return _context50.abrupt("return", res);
|
|
8252
8248
|
case 4:
|
|
8253
8249
|
case "end":
|
|
8254
|
-
return
|
|
8250
|
+
return _context50.stop();
|
|
8255
8251
|
}
|
|
8256
8252
|
}, _callee48, this);
|
|
8257
8253
|
}));
|