@pisell/pisellos 0.10.71 → 0.10.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/BookingContext/index.d.ts +2 -2
- package/dist/modules/BookingContext/index.js +55 -25
- package/dist/modules/BookingContext/types.d.ts +2 -0
- package/dist/modules/Order/index.d.ts +13 -4
- package/dist/modules/Order/index.js +1401 -764
- package/dist/modules/Order/types.d.ts +24 -1
- package/dist/modules/Order/types.js +4 -0
- package/dist/server/index.js +5 -2
- package/dist/solution/BaseSales/index.d.ts +2 -2
- package/dist/solution/BaseSales/index.js +8 -8
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +15 -0
- package/dist/solution/UnifiedBookingSales/index.js +1082 -596
- package/dist/solution/UnifiedBookingSales/types.d.ts +17 -1
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/BookingContext/index.d.ts +2 -2
- package/lib/modules/BookingContext/index.js +42 -10
- package/lib/modules/BookingContext/types.d.ts +2 -0
- package/lib/modules/Order/index.d.ts +13 -4
- package/lib/modules/Order/index.js +284 -24
- package/lib/modules/Order/types.d.ts +24 -1
- package/lib/modules/Order/types.js +2 -0
- package/lib/server/index.js +5 -1
- package/lib/solution/BaseSales/index.d.ts +2 -2
- package/lib/solution/BaseSales/index.js +2 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +15 -0
- package/lib/solution/UnifiedBookingSales/index.js +343 -44
- package/lib/solution/UnifiedBookingSales/types.d.ts +17 -1
- package/package.json +1 -1
|
@@ -209,7 +209,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
209
209
|
key: "queueCartCommand",
|
|
210
210
|
value: function queueCartCommand(run) {
|
|
211
211
|
var _this$orderHooks, _this$store$tempOrder;
|
|
212
|
-
|
|
212
|
+
var forceQueue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
213
|
+
if (!forceQueue && !((_this$orderHooks = this.orderHooks) !== null && _this$orderHooks !== void 0 && _this$orderHooks.onBeforeCartCommit) && !((_this$store$tempOrder = this.store.tempOrder) !== null && _this$store$tempOrder !== void 0 && (_this$store$tempOrder = _this$store$tempOrder._extend) !== null && _this$store$tempOrder !== void 0 && (_this$store$tempOrder = _this$store$tempOrder.productVoucherGroups) !== null && _this$store$tempOrder !== void 0 && _this$store$tempOrder.length)) return run();
|
|
213
214
|
var pending = this.cartCommandQueue.then(run, run);
|
|
214
215
|
this.cartCommandQueue = pending.catch(function () {
|
|
215
216
|
return undefined;
|
|
@@ -220,13 +221,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
220
221
|
/** Use the exact Order normalizers/merge rules on a private draft, not a second projection. */
|
|
221
222
|
}, {
|
|
222
223
|
key: "beginCartMutation",
|
|
223
|
-
value: function beginCartMutation() {
|
|
224
|
+
value: function beginCartMutation(options) {
|
|
224
225
|
var _this$orderHooks2,
|
|
225
226
|
_current$_extend,
|
|
226
227
|
_this2 = this;
|
|
227
228
|
var current = this.ensureTempOrder();
|
|
228
229
|
var guard = (_this$orderHooks2 = this.orderHooks) === null || _this$orderHooks2 === void 0 ? void 0 : _this$orderHooks2.onBeforeCartCommit;
|
|
229
|
-
if (!guard && !((_current$_extend = current._extend) !== null && _current$_extend !== void 0 && (_current$_extend = _current$_extend.productVoucherGroups) !== null && _current$_extend !== void 0 && _current$_extend.length)) return {
|
|
230
|
+
if (!(options !== null && options !== void 0 && options.forceDraft) && !guard && !((_current$_extend = current._extend) !== null && _current$_extend !== void 0 && (_current$_extend = _current$_extend.productVoucherGroups) !== null && _current$_extend !== void 0 && _current$_extend.length)) return {
|
|
230
231
|
current: current,
|
|
231
232
|
draft: current,
|
|
232
233
|
commit: undefined
|
|
@@ -259,9 +260,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
259
260
|
case 5:
|
|
260
261
|
// Recheck the accepted intent's scope after asynchronous inventory validation.
|
|
261
262
|
beforeCommit === null || beforeCommit === void 0 || beforeCommit();
|
|
263
|
+
// Opt-in booking guards may inspect or reject the source snapshot here.
|
|
264
|
+
// Never publish over a mutation made by that last synchronous callback.
|
|
265
|
+
if (!(options !== null && options !== void 0 && options.forceDraft && (_this2.store.tempOrder !== current || !isEqual(current, before)))) {
|
|
266
|
+
_context.next = 8;
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
throw Object.assign(new Error('The cart changed. Please try again.'), {
|
|
270
|
+
code: 'SALES_GUARD_REJECTED'
|
|
271
|
+
});
|
|
272
|
+
case 8:
|
|
262
273
|
Object.assign(current, draft);
|
|
263
274
|
return _context.abrupt("return", current);
|
|
264
|
-
case
|
|
275
|
+
case 10:
|
|
265
276
|
case "end":
|
|
266
277
|
return _context.stop();
|
|
267
278
|
}
|
|
@@ -1437,49 +1448,55 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1437
1448
|
}, {
|
|
1438
1449
|
key: "evaluatePromotion",
|
|
1439
1450
|
value: (function () {
|
|
1440
|
-
var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
1451
|
+
var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(options) {
|
|
1441
1452
|
var _this$promotionEvalua,
|
|
1442
1453
|
_this$promotionEvalua2,
|
|
1443
1454
|
_this9 = this;
|
|
1444
|
-
var tempOrder, strategyConfigs, result, removeSet, _iterator5, _step5, reduce, _iterator8, _step8, _loop2, _iterator6, _step6, _loop, payload;
|
|
1455
|
+
var tempOrder, strategyConfigs, result, removeSet, _iterator5, _step5, reduce, _iterator8, _step8, _loop2, _iterator6, _step6, _loop, _ret, payload;
|
|
1445
1456
|
return _regeneratorRuntime().wrap(function _callee10$(_context12) {
|
|
1446
1457
|
while (1) switch (_context12.prev = _context12.next) {
|
|
1447
1458
|
case 0:
|
|
1448
|
-
if (!(
|
|
1459
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
1449
1460
|
_context12.next = 2;
|
|
1450
1461
|
break;
|
|
1451
1462
|
}
|
|
1452
1463
|
return _context12.abrupt("return", null);
|
|
1453
1464
|
case 2:
|
|
1454
|
-
if (this.
|
|
1465
|
+
if (!(this.isApplyingPromotion || this.isEmittingPromotionApplied)) {
|
|
1455
1466
|
_context12.next = 4;
|
|
1456
1467
|
break;
|
|
1457
1468
|
}
|
|
1458
1469
|
return _context12.abrupt("return", null);
|
|
1459
1470
|
case 4:
|
|
1471
|
+
if (this.promotionEvaluator) {
|
|
1472
|
+
_context12.next = 6;
|
|
1473
|
+
break;
|
|
1474
|
+
}
|
|
1475
|
+
return _context12.abrupt("return", null);
|
|
1476
|
+
case 6:
|
|
1460
1477
|
tempOrder = this.store.tempOrder;
|
|
1461
1478
|
if (tempOrder) {
|
|
1462
|
-
_context12.next =
|
|
1479
|
+
_context12.next = 9;
|
|
1463
1480
|
break;
|
|
1464
1481
|
}
|
|
1465
1482
|
return _context12.abrupt("return", null);
|
|
1466
|
-
case
|
|
1483
|
+
case 9:
|
|
1467
1484
|
if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
1468
|
-
_context12.next =
|
|
1485
|
+
_context12.next = 12;
|
|
1469
1486
|
break;
|
|
1470
1487
|
}
|
|
1471
1488
|
tempOrder.products = normalizeVirtualSettlementProducts(tempOrder.products);
|
|
1472
1489
|
return _context12.abrupt("return", null);
|
|
1473
|
-
case
|
|
1490
|
+
case 12:
|
|
1474
1491
|
strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
|
|
1475
1492
|
if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
|
|
1476
|
-
_context12.next =
|
|
1493
|
+
_context12.next = 15;
|
|
1477
1494
|
break;
|
|
1478
1495
|
}
|
|
1479
1496
|
return _context12.abrupt("return", null);
|
|
1480
|
-
case
|
|
1497
|
+
case 15:
|
|
1481
1498
|
this.isApplyingPromotion = true;
|
|
1482
|
-
_context12.prev =
|
|
1499
|
+
_context12.prev = 16;
|
|
1483
1500
|
result = processCartPromotion(tempOrder.products, this.promotionEvaluator); // step 1: toRemove —— 直接过滤
|
|
1484
1501
|
if (result.giftActions.toRemove.length > 0) {
|
|
1485
1502
|
removeSet = new Set(result.giftActions.toRemove.map(String));
|
|
@@ -1491,16 +1508,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1491
1508
|
|
|
1492
1509
|
// step 2: toReduce —— 调整数量
|
|
1493
1510
|
_iterator5 = _createForOfIteratorHelper(result.giftActions.toReduce);
|
|
1494
|
-
_context12.prev =
|
|
1511
|
+
_context12.prev = 20;
|
|
1495
1512
|
_iterator5.s();
|
|
1496
|
-
case
|
|
1513
|
+
case 22:
|
|
1497
1514
|
if ((_step5 = _iterator5.n()).done) {
|
|
1498
|
-
_context12.next =
|
|
1515
|
+
_context12.next = 42;
|
|
1499
1516
|
break;
|
|
1500
1517
|
}
|
|
1501
1518
|
reduce = _step5.value;
|
|
1502
1519
|
_iterator8 = _createForOfIteratorHelper(reduce.items);
|
|
1503
|
-
_context12.prev =
|
|
1520
|
+
_context12.prev = 25;
|
|
1504
1521
|
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
1505
1522
|
var item, product;
|
|
1506
1523
|
return _regeneratorRuntime().wrap(function _loop2$(_context11) {
|
|
@@ -1520,47 +1537,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1520
1537
|
}, _loop2);
|
|
1521
1538
|
});
|
|
1522
1539
|
_iterator8.s();
|
|
1523
|
-
case
|
|
1540
|
+
case 28:
|
|
1524
1541
|
if ((_step8 = _iterator8.n()).done) {
|
|
1525
|
-
_context12.next =
|
|
1542
|
+
_context12.next = 32;
|
|
1526
1543
|
break;
|
|
1527
1544
|
}
|
|
1528
|
-
return _context12.delegateYield(_loop2(), "t0",
|
|
1529
|
-
case 28:
|
|
1530
|
-
_context12.next = 26;
|
|
1531
|
-
break;
|
|
1545
|
+
return _context12.delegateYield(_loop2(), "t0", 30);
|
|
1532
1546
|
case 30:
|
|
1533
|
-
_context12.next =
|
|
1547
|
+
_context12.next = 28;
|
|
1534
1548
|
break;
|
|
1535
1549
|
case 32:
|
|
1536
|
-
_context12.
|
|
1537
|
-
|
|
1550
|
+
_context12.next = 37;
|
|
1551
|
+
break;
|
|
1552
|
+
case 34:
|
|
1553
|
+
_context12.prev = 34;
|
|
1554
|
+
_context12.t1 = _context12["catch"](25);
|
|
1538
1555
|
_iterator8.e(_context12.t1);
|
|
1539
|
-
case
|
|
1540
|
-
_context12.prev =
|
|
1556
|
+
case 37:
|
|
1557
|
+
_context12.prev = 37;
|
|
1541
1558
|
_iterator8.f();
|
|
1542
|
-
return _context12.finish(
|
|
1543
|
-
case 38:
|
|
1544
|
-
_context12.next = 20;
|
|
1545
|
-
break;
|
|
1559
|
+
return _context12.finish(37);
|
|
1546
1560
|
case 40:
|
|
1547
|
-
_context12.next =
|
|
1561
|
+
_context12.next = 22;
|
|
1548
1562
|
break;
|
|
1549
1563
|
case 42:
|
|
1550
|
-
_context12.
|
|
1551
|
-
|
|
1564
|
+
_context12.next = 47;
|
|
1565
|
+
break;
|
|
1566
|
+
case 44:
|
|
1567
|
+
_context12.prev = 44;
|
|
1568
|
+
_context12.t2 = _context12["catch"](20);
|
|
1552
1569
|
_iterator5.e(_context12.t2);
|
|
1553
|
-
case
|
|
1554
|
-
_context12.prev =
|
|
1570
|
+
case 47:
|
|
1571
|
+
_context12.prev = 47;
|
|
1555
1572
|
_iterator5.f();
|
|
1556
|
-
return _context12.finish(
|
|
1557
|
-
case
|
|
1573
|
+
return _context12.finish(47);
|
|
1574
|
+
case 50:
|
|
1558
1575
|
if (!(result.giftActions.toAdd.length > 0)) {
|
|
1559
|
-
_context12.next =
|
|
1576
|
+
_context12.next = 76;
|
|
1560
1577
|
break;
|
|
1561
1578
|
}
|
|
1562
1579
|
if (this.giftSelectResolver) {
|
|
1563
|
-
_context12.next =
|
|
1580
|
+
_context12.next = 55;
|
|
1564
1581
|
break;
|
|
1565
1582
|
}
|
|
1566
1583
|
if (result.giftActions.toAdd.some(function (g) {
|
|
@@ -1571,13 +1588,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1571
1588
|
} else {
|
|
1572
1589
|
console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
|
|
1573
1590
|
}
|
|
1574
|
-
_context12.next =
|
|
1591
|
+
_context12.next = 76;
|
|
1575
1592
|
break;
|
|
1576
|
-
case
|
|
1593
|
+
case 55:
|
|
1577
1594
|
_iterator6 = _createForOfIteratorHelper(result.giftActions.toAdd);
|
|
1578
|
-
_context12.prev =
|
|
1595
|
+
_context12.prev = 56;
|
|
1579
1596
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
1580
|
-
var addAction, _sameStrategy$metadat, sameStrategy, giftResult, giftProducts, giftBookings, _iterator7, _step7, _step7$value, index, gp, booking, linked;
|
|
1597
|
+
var addAction, _sameStrategy$metadat, sameStrategy, giftBaseline, isGiftResultCurrent, giftResult, giftProducts, giftBookings, _iterator7, _step7, _step7$value, index, gp, booking, linked;
|
|
1581
1598
|
return _regeneratorRuntime().wrap(function _loop$(_context10) {
|
|
1582
1599
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1583
1600
|
case 0:
|
|
@@ -1595,10 +1612,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1595
1612
|
break;
|
|
1596
1613
|
}
|
|
1597
1614
|
sameStrategy.num = (Number(sameStrategy.num) || 0) + (addAction.giftCount || 1);
|
|
1598
|
-
return _context10.abrupt("return",
|
|
1615
|
+
return _context10.abrupt("return", 0);
|
|
1599
1616
|
case 6:
|
|
1600
|
-
|
|
1601
|
-
|
|
1617
|
+
giftBaseline = options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep({
|
|
1618
|
+
products: tempOrder.products,
|
|
1619
|
+
bookings: tempOrder.bookings
|
|
1620
|
+
}) : null;
|
|
1621
|
+
isGiftResultCurrent = function isGiftResultCurrent() {
|
|
1622
|
+
return !(options !== null && options !== void 0 && options.isCurrentOrder) || options.isCurrentOrder() && isEqual(giftBaseline, {
|
|
1623
|
+
products: tempOrder.products,
|
|
1624
|
+
bookings: tempOrder.bookings
|
|
1625
|
+
});
|
|
1626
|
+
};
|
|
1627
|
+
_context10.prev = 8;
|
|
1628
|
+
_context10.next = 11;
|
|
1602
1629
|
return _this9.giftSelectResolver({
|
|
1603
1630
|
strategyId: addAction.strategyId,
|
|
1604
1631
|
strategyName: addAction.strategyName,
|
|
@@ -1606,32 +1633,40 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1606
1633
|
giftOptions: addAction.giftOptions,
|
|
1607
1634
|
sourceProductIds: addAction.sourceProductIds
|
|
1608
1635
|
});
|
|
1609
|
-
case
|
|
1636
|
+
case 11:
|
|
1610
1637
|
giftResult = _context10.sent;
|
|
1638
|
+
if (isGiftResultCurrent()) {
|
|
1639
|
+
_context10.next = 14;
|
|
1640
|
+
break;
|
|
1641
|
+
}
|
|
1642
|
+
return _context10.abrupt("return", {
|
|
1643
|
+
v: null
|
|
1644
|
+
});
|
|
1645
|
+
case 14:
|
|
1611
1646
|
giftProducts = Array.isArray(giftResult) ? giftResult : giftResult === null || giftResult === void 0 ? void 0 : giftResult.products;
|
|
1612
1647
|
giftBookings = Array.isArray(giftResult) ? [] : (giftResult === null || giftResult === void 0 ? void 0 : giftResult.bookings) || [];
|
|
1613
1648
|
if (!(Array.isArray(giftProducts) && giftProducts.length > 0)) {
|
|
1614
|
-
_context10.next =
|
|
1649
|
+
_context10.next = 41;
|
|
1615
1650
|
break;
|
|
1616
1651
|
}
|
|
1617
1652
|
_iterator7 = _createForOfIteratorHelper(giftProducts.entries());
|
|
1618
|
-
_context10.prev =
|
|
1653
|
+
_context10.prev = 18;
|
|
1619
1654
|
_iterator7.s();
|
|
1620
|
-
case
|
|
1655
|
+
case 20:
|
|
1621
1656
|
if ((_step7 = _iterator7.n()).done) {
|
|
1622
|
-
_context10.next =
|
|
1657
|
+
_context10.next = 33;
|
|
1623
1658
|
break;
|
|
1624
1659
|
}
|
|
1625
1660
|
_step7$value = _slicedToArray(_step7.value, 2), index = _step7$value[0], gp = _step7$value[1];
|
|
1626
1661
|
if (gp) {
|
|
1627
|
-
_context10.next =
|
|
1662
|
+
_context10.next = 24;
|
|
1628
1663
|
break;
|
|
1629
1664
|
}
|
|
1630
|
-
return _context10.abrupt("continue",
|
|
1631
|
-
case
|
|
1665
|
+
return _context10.abrupt("continue", 31);
|
|
1666
|
+
case 24:
|
|
1632
1667
|
booking = giftBookings[index];
|
|
1633
1668
|
if (!booking) {
|
|
1634
|
-
_context10.next =
|
|
1669
|
+
_context10.next = 30;
|
|
1635
1670
|
break;
|
|
1636
1671
|
}
|
|
1637
1672
|
linked = _this9.createLinkedProductAndBooking({
|
|
@@ -1640,66 +1675,87 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1640
1675
|
});
|
|
1641
1676
|
result.products.push(linked.product);
|
|
1642
1677
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
1643
|
-
return _context10.abrupt("continue",
|
|
1644
|
-
case
|
|
1678
|
+
return _context10.abrupt("continue", 31);
|
|
1679
|
+
case 30:
|
|
1645
1680
|
// normalize 略过:调用方应保证返回完整 OrderProduct。
|
|
1646
1681
|
result.products.push(gp);
|
|
1647
|
-
case
|
|
1648
|
-
_context10.next =
|
|
1682
|
+
case 31:
|
|
1683
|
+
_context10.next = 20;
|
|
1649
1684
|
break;
|
|
1650
|
-
case
|
|
1651
|
-
_context10.next =
|
|
1685
|
+
case 33:
|
|
1686
|
+
_context10.next = 38;
|
|
1652
1687
|
break;
|
|
1653
|
-
case
|
|
1654
|
-
_context10.prev =
|
|
1655
|
-
_context10.t0 = _context10["catch"](
|
|
1688
|
+
case 35:
|
|
1689
|
+
_context10.prev = 35;
|
|
1690
|
+
_context10.t0 = _context10["catch"](18);
|
|
1656
1691
|
_iterator7.e(_context10.t0);
|
|
1657
|
-
case
|
|
1658
|
-
_context10.prev =
|
|
1692
|
+
case 38:
|
|
1693
|
+
_context10.prev = 38;
|
|
1659
1694
|
_iterator7.f();
|
|
1660
|
-
return _context10.finish(
|
|
1661
|
-
case
|
|
1662
|
-
_context10.next =
|
|
1695
|
+
return _context10.finish(38);
|
|
1696
|
+
case 41:
|
|
1697
|
+
_context10.next = 48;
|
|
1663
1698
|
break;
|
|
1664
|
-
case
|
|
1665
|
-
_context10.prev =
|
|
1666
|
-
_context10.t1 = _context10["catch"](
|
|
1699
|
+
case 43:
|
|
1700
|
+
_context10.prev = 43;
|
|
1701
|
+
_context10.t1 = _context10["catch"](8);
|
|
1702
|
+
if (isGiftResultCurrent()) {
|
|
1703
|
+
_context10.next = 47;
|
|
1704
|
+
break;
|
|
1705
|
+
}
|
|
1706
|
+
return _context10.abrupt("return", {
|
|
1707
|
+
v: null
|
|
1708
|
+
});
|
|
1709
|
+
case 47:
|
|
1667
1710
|
// 用户取消 / 选择失败 → 视为放弃本次新增
|
|
1668
1711
|
console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context10.t1);
|
|
1669
|
-
case
|
|
1712
|
+
case 48:
|
|
1670
1713
|
case "end":
|
|
1671
1714
|
return _context10.stop();
|
|
1672
1715
|
}
|
|
1673
|
-
}, _loop, null, [[
|
|
1716
|
+
}, _loop, null, [[8, 43], [18, 35, 38, 41]]);
|
|
1674
1717
|
});
|
|
1675
1718
|
_iterator6.s();
|
|
1676
|
-
case
|
|
1719
|
+
case 59:
|
|
1677
1720
|
if ((_step6 = _iterator6.n()).done) {
|
|
1678
|
-
_context12.next =
|
|
1721
|
+
_context12.next = 68;
|
|
1679
1722
|
break;
|
|
1680
1723
|
}
|
|
1681
|
-
return _context12.delegateYield(_loop(), "t3",
|
|
1682
|
-
case
|
|
1683
|
-
|
|
1684
|
-
|
|
1724
|
+
return _context12.delegateYield(_loop(), "t3", 61);
|
|
1725
|
+
case 61:
|
|
1726
|
+
_ret = _context12.t3;
|
|
1727
|
+
if (!(_ret === 0)) {
|
|
1728
|
+
_context12.next = 64;
|
|
1685
1729
|
break;
|
|
1686
1730
|
}
|
|
1687
|
-
return _context12.abrupt("continue",
|
|
1688
|
-
case
|
|
1689
|
-
|
|
1731
|
+
return _context12.abrupt("continue", 66);
|
|
1732
|
+
case 64:
|
|
1733
|
+
if (!_ret) {
|
|
1734
|
+
_context12.next = 66;
|
|
1735
|
+
break;
|
|
1736
|
+
}
|
|
1737
|
+
return _context12.abrupt("return", _ret.v);
|
|
1738
|
+
case 66:
|
|
1739
|
+
_context12.next = 59;
|
|
1690
1740
|
break;
|
|
1691
|
-
case
|
|
1692
|
-
_context12.next =
|
|
1741
|
+
case 68:
|
|
1742
|
+
_context12.next = 73;
|
|
1693
1743
|
break;
|
|
1694
|
-
case
|
|
1695
|
-
_context12.prev =
|
|
1696
|
-
_context12.t4 = _context12["catch"](
|
|
1744
|
+
case 70:
|
|
1745
|
+
_context12.prev = 70;
|
|
1746
|
+
_context12.t4 = _context12["catch"](56);
|
|
1697
1747
|
_iterator6.e(_context12.t4);
|
|
1698
|
-
case
|
|
1699
|
-
_context12.prev =
|
|
1748
|
+
case 73:
|
|
1749
|
+
_context12.prev = 73;
|
|
1700
1750
|
_iterator6.f();
|
|
1701
|
-
return _context12.finish(
|
|
1702
|
-
case
|
|
1751
|
+
return _context12.finish(73);
|
|
1752
|
+
case 76:
|
|
1753
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
1754
|
+
_context12.next = 78;
|
|
1755
|
+
break;
|
|
1756
|
+
}
|
|
1757
|
+
return _context12.abrupt("return", null);
|
|
1758
|
+
case 78:
|
|
1703
1759
|
tempOrder.products = result.products;
|
|
1704
1760
|
this.lastUnfulfilledPromotions = result.unfulfilledPromotions;
|
|
1705
1761
|
this.lastGiftActions = result.giftActions;
|
|
@@ -1717,22 +1773,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1717
1773
|
products: tempOrder.products
|
|
1718
1774
|
};
|
|
1719
1775
|
return _context12.abrupt("return", payload);
|
|
1720
|
-
case
|
|
1721
|
-
_context12.prev =
|
|
1722
|
-
_context12.t5 = _context12["catch"](
|
|
1776
|
+
case 85:
|
|
1777
|
+
_context12.prev = 85;
|
|
1778
|
+
_context12.t5 = _context12["catch"](16);
|
|
1723
1779
|
console.error('[OrderModule] applyPromotion failed', _context12.t5);
|
|
1724
1780
|
return _context12.abrupt("return", null);
|
|
1725
|
-
case
|
|
1726
|
-
_context12.prev =
|
|
1781
|
+
case 89:
|
|
1782
|
+
_context12.prev = 89;
|
|
1727
1783
|
this.isApplyingPromotion = false;
|
|
1728
|
-
return _context12.finish(
|
|
1729
|
-
case
|
|
1784
|
+
return _context12.finish(89);
|
|
1785
|
+
case 92:
|
|
1730
1786
|
case "end":
|
|
1731
1787
|
return _context12.stop();
|
|
1732
1788
|
}
|
|
1733
|
-
}, _callee10, this, [[
|
|
1789
|
+
}, _callee10, this, [[16, 85, 89, 92], [20, 44, 47, 50], [25, 34, 37, 40], [56, 70, 73, 76]]);
|
|
1734
1790
|
}));
|
|
1735
|
-
function evaluatePromotion() {
|
|
1791
|
+
function evaluatePromotion(_x11) {
|
|
1736
1792
|
return _evaluatePromotion.apply(this, arguments);
|
|
1737
1793
|
}
|
|
1738
1794
|
return evaluatePromotion;
|
|
@@ -2152,7 +2208,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2152
2208
|
}
|
|
2153
2209
|
}, _callee13, this);
|
|
2154
2210
|
}));
|
|
2155
|
-
function hydrateTempOrderFromLocalRecord(
|
|
2211
|
+
function hydrateTempOrderFromLocalRecord(_x12) {
|
|
2156
2212
|
return _hydrateTempOrderFromLocalRecord.apply(this, arguments);
|
|
2157
2213
|
}
|
|
2158
2214
|
return hydrateTempOrderFromLocalRecord;
|
|
@@ -3231,7 +3287,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3231
3287
|
}
|
|
3232
3288
|
}, _callee14, this);
|
|
3233
3289
|
}));
|
|
3234
|
-
function replaceTempOrder(
|
|
3290
|
+
function replaceTempOrder(_x13, _x14) {
|
|
3235
3291
|
return _replaceTempOrder.apply(this, arguments);
|
|
3236
3292
|
}
|
|
3237
3293
|
return replaceTempOrder;
|
|
@@ -3730,30 +3786,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3730
3786
|
value: function () {
|
|
3731
3787
|
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(options) {
|
|
3732
3788
|
var _this$otherParams3, _ref54, _salesSummaryResult$e;
|
|
3733
|
-
var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
3789
|
+
var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, summaryBaseline, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
3734
3790
|
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
3735
3791
|
while (1) switch (_context18.prev = _context18.next) {
|
|
3736
3792
|
case 0:
|
|
3793
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
3794
|
+
_context18.next = 2;
|
|
3795
|
+
break;
|
|
3796
|
+
}
|
|
3797
|
+
return _context18.abrupt("return", null);
|
|
3798
|
+
case 2:
|
|
3737
3799
|
tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
|
|
3738
3800
|
if (tempOrder) {
|
|
3739
|
-
_context18.next =
|
|
3801
|
+
_context18.next = 5;
|
|
3740
3802
|
break;
|
|
3741
3803
|
}
|
|
3742
3804
|
return _context18.abrupt("return", null);
|
|
3743
|
-
case
|
|
3805
|
+
case 5:
|
|
3744
3806
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3745
3807
|
originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
3746
3808
|
hasShopDiscountChanged = originalSnapshot ? this.hasShopDiscountChangedFromSnapshot(tempOrder, originalSnapshot) : false;
|
|
3747
3809
|
shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
|
|
3748
3810
|
snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
|
|
3749
3811
|
if (!snapshotSummary) {
|
|
3750
|
-
_context18.next =
|
|
3812
|
+
_context18.next = 12;
|
|
3751
3813
|
break;
|
|
3752
3814
|
}
|
|
3753
3815
|
return _context18.abrupt("return", snapshotSummary);
|
|
3754
|
-
case
|
|
3816
|
+
case 12:
|
|
3755
3817
|
shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
|
|
3756
|
-
summaryProducts = shouldFullRecalculateFromSnapshot ? cloneDeep(tempOrder.products || []) : tempOrder.products;
|
|
3818
|
+
summaryProducts = shouldFullRecalculateFromSnapshot || options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep(tempOrder.products || []) : tempOrder.products;
|
|
3757
3819
|
if (shouldFullRecalculateFromSnapshot) {
|
|
3758
3820
|
this.clearPersistedAmountFieldsForFullRecalc(summaryProducts || []);
|
|
3759
3821
|
}
|
|
@@ -3762,7 +3824,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3762
3824
|
totalRefundAmount = existedSummary.total_refund_amount || '0.00';
|
|
3763
3825
|
paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
3764
3826
|
if (salesSummary) {
|
|
3765
|
-
_context18.next =
|
|
3827
|
+
_context18.next = 28;
|
|
3766
3828
|
break;
|
|
3767
3829
|
}
|
|
3768
3830
|
emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
|
|
@@ -3789,8 +3851,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3789
3851
|
summary: emptySummary
|
|
3790
3852
|
});
|
|
3791
3853
|
return _context18.abrupt("return", this.store.summary);
|
|
3792
|
-
case
|
|
3793
|
-
|
|
3854
|
+
case 28:
|
|
3855
|
+
summaryBaseline = options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep({
|
|
3856
|
+
tempOrder: tempOrder,
|
|
3857
|
+
summary: this.store.summary
|
|
3858
|
+
}) : null;
|
|
3859
|
+
_context18.next = 31;
|
|
3794
3860
|
return salesSummary.getSummary(_objectSpread({
|
|
3795
3861
|
products: summaryProducts,
|
|
3796
3862
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
@@ -3799,9 +3865,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3799
3865
|
}, (_this$otherParams3 = this.otherParams) !== null && _this$otherParams3 !== void 0 && _this$otherParams3.channel ? {
|
|
3800
3866
|
channel: this.otherParams.channel
|
|
3801
3867
|
} : {}));
|
|
3802
|
-
case
|
|
3868
|
+
case 31:
|
|
3803
3869
|
salesSummaryResult = _context18.sent;
|
|
3804
|
-
if (
|
|
3870
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && (!options.isCurrentOrder() || !isEqual(summaryBaseline, {
|
|
3871
|
+
tempOrder: tempOrder,
|
|
3872
|
+
summary: this.store.summary
|
|
3873
|
+
})))) {
|
|
3874
|
+
_context18.next = 34;
|
|
3875
|
+
break;
|
|
3876
|
+
}
|
|
3877
|
+
return _context18.abrupt("return", null);
|
|
3878
|
+
case 34:
|
|
3879
|
+
if (shouldFullRecalculateFromSnapshot || options !== null && options !== void 0 && options.isCurrentOrder) {
|
|
3805
3880
|
tempOrder.products = summaryProducts;
|
|
3806
3881
|
}
|
|
3807
3882
|
this.syncSummaryProductMetadata(tempOrder.products || []);
|
|
@@ -3846,13 +3921,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3846
3921
|
summary: summary
|
|
3847
3922
|
});
|
|
3848
3923
|
return _context18.abrupt("return", this.store.summary);
|
|
3849
|
-
case
|
|
3924
|
+
case 51:
|
|
3850
3925
|
case "end":
|
|
3851
3926
|
return _context18.stop();
|
|
3852
3927
|
}
|
|
3853
3928
|
}, _callee16, this);
|
|
3854
3929
|
}));
|
|
3855
|
-
function recalculateSummary(
|
|
3930
|
+
function recalculateSummary(_x15) {
|
|
3856
3931
|
return _recalculateSummary.apply(this, arguments);
|
|
3857
3932
|
}
|
|
3858
3933
|
return recalculateSummary;
|
|
@@ -3923,7 +3998,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3923
3998
|
}
|
|
3924
3999
|
}, _callee18, this);
|
|
3925
4000
|
}));
|
|
3926
|
-
function syncTempOrderNoteToRemote(
|
|
4001
|
+
function syncTempOrderNoteToRemote(_x16, _x17) {
|
|
3927
4002
|
return _syncTempOrderNoteToRemote.apply(this, arguments);
|
|
3928
4003
|
}
|
|
3929
4004
|
return syncTempOrderNoteToRemote;
|
|
@@ -4139,7 +4214,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4139
4214
|
}
|
|
4140
4215
|
}, _callee19, this);
|
|
4141
4216
|
}));
|
|
4142
|
-
function setSalesNote(
|
|
4217
|
+
function setSalesNote(_x18) {
|
|
4143
4218
|
return _setSalesNote.apply(this, arguments);
|
|
4144
4219
|
}
|
|
4145
4220
|
return setSalesNote;
|
|
@@ -4175,7 +4250,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4175
4250
|
}
|
|
4176
4251
|
}, _callee20, this);
|
|
4177
4252
|
}));
|
|
4178
|
-
function removeSalesNote(
|
|
4253
|
+
function removeSalesNote(_x19) {
|
|
4179
4254
|
return _removeSalesNote.apply(this, arguments);
|
|
4180
4255
|
}
|
|
4181
4256
|
return removeSalesNote;
|
|
@@ -4637,7 +4712,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4637
4712
|
}
|
|
4638
4713
|
}, _callee22, this);
|
|
4639
4714
|
}));
|
|
4640
|
-
function addOrderPaymentAsync(
|
|
4715
|
+
function addOrderPaymentAsync(_x20) {
|
|
4641
4716
|
return _addOrderPaymentAsync.apply(this, arguments);
|
|
4642
4717
|
}
|
|
4643
4718
|
return addOrderPaymentAsync;
|
|
@@ -4731,7 +4806,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4731
4806
|
}
|
|
4732
4807
|
}, _callee23, this);
|
|
4733
4808
|
}));
|
|
4734
|
-
function updateOrderPayment(
|
|
4809
|
+
function updateOrderPayment(_x21, _x22) {
|
|
4735
4810
|
return _updateOrderPayment.apply(this, arguments);
|
|
4736
4811
|
}
|
|
4737
4812
|
return updateOrderPayment;
|
|
@@ -4958,7 +5033,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4958
5033
|
}
|
|
4959
5034
|
}, _callee24, this);
|
|
4960
5035
|
}));
|
|
4961
|
-
function updateVoucherOrderPaymentsAsync(
|
|
5036
|
+
function updateVoucherOrderPaymentsAsync(_x23, _x24) {
|
|
4962
5037
|
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
4963
5038
|
}
|
|
4964
5039
|
return updateVoucherOrderPaymentsAsync;
|
|
@@ -5114,52 +5189,80 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5114
5189
|
key: "finalizeProductOrderMutation",
|
|
5115
5190
|
value: function () {
|
|
5116
5191
|
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(tempOrder, options) {
|
|
5117
|
-
var isVirtualSettlement, promotionPayload;
|
|
5192
|
+
var isVirtualSettlement, promotionPayload, summary;
|
|
5118
5193
|
return _regeneratorRuntime().wrap(function _callee25$(_context27) {
|
|
5119
5194
|
while (1) switch (_context27.prev = _context27.next) {
|
|
5120
5195
|
case 0:
|
|
5196
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
5197
|
+
_context27.next = 2;
|
|
5198
|
+
break;
|
|
5199
|
+
}
|
|
5200
|
+
return _context27.abrupt("return");
|
|
5201
|
+
case 2:
|
|
5121
5202
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
5122
5203
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
5123
5204
|
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
5124
5205
|
if (!(!(options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) && !isVirtualSettlement)) {
|
|
5125
|
-
_context27.next =
|
|
5206
|
+
_context27.next = 8;
|
|
5126
5207
|
break;
|
|
5127
5208
|
}
|
|
5128
|
-
_context27.next =
|
|
5209
|
+
_context27.next = 8;
|
|
5129
5210
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
5130
|
-
case
|
|
5211
|
+
case 8:
|
|
5212
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
5213
|
+
_context27.next = 10;
|
|
5214
|
+
break;
|
|
5215
|
+
}
|
|
5216
|
+
return _context27.abrupt("return");
|
|
5217
|
+
case 10:
|
|
5131
5218
|
if (!(!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement)) {
|
|
5132
|
-
_context27.next =
|
|
5219
|
+
_context27.next = 16;
|
|
5133
5220
|
break;
|
|
5134
5221
|
}
|
|
5135
|
-
_context27.next = 9;
|
|
5136
|
-
return this.evaluatePromotion();
|
|
5137
|
-
case 9:
|
|
5138
|
-
_context27.t0 = _context27.sent;
|
|
5139
5222
|
_context27.next = 13;
|
|
5223
|
+
return this.evaluatePromotion({
|
|
5224
|
+
isCurrentOrder: options === null || options === void 0 ? void 0 : options.isCurrentOrder
|
|
5225
|
+
});
|
|
5226
|
+
case 13:
|
|
5227
|
+
_context27.t0 = _context27.sent;
|
|
5228
|
+
_context27.next = 17;
|
|
5140
5229
|
break;
|
|
5141
|
-
case
|
|
5230
|
+
case 16:
|
|
5142
5231
|
_context27.t0 = null;
|
|
5143
|
-
case
|
|
5232
|
+
case 17:
|
|
5144
5233
|
promotionPayload = _context27.t0;
|
|
5234
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
5235
|
+
_context27.next = 20;
|
|
5236
|
+
break;
|
|
5237
|
+
}
|
|
5238
|
+
return _context27.abrupt("return");
|
|
5239
|
+
case 20:
|
|
5145
5240
|
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement) {
|
|
5146
5241
|
this.applyDiscount();
|
|
5147
5242
|
}
|
|
5148
5243
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5149
|
-
_context27.next =
|
|
5244
|
+
_context27.next = 24;
|
|
5150
5245
|
return this.recalculateSummary({
|
|
5151
|
-
createIfMissing: true
|
|
5246
|
+
createIfMissing: true,
|
|
5247
|
+
isCurrentOrder: options === null || options === void 0 ? void 0 : options.isCurrentOrder
|
|
5152
5248
|
});
|
|
5153
|
-
case
|
|
5249
|
+
case 24:
|
|
5250
|
+
summary = _context27.sent;
|
|
5251
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && (!options.isCurrentOrder() || !summary))) {
|
|
5252
|
+
_context27.next = 27;
|
|
5253
|
+
break;
|
|
5254
|
+
}
|
|
5255
|
+
return _context27.abrupt("return");
|
|
5256
|
+
case 27:
|
|
5154
5257
|
this.persistTempOrder();
|
|
5155
5258
|
this.emitPromotionApplied(promotionPayload);
|
|
5156
|
-
case
|
|
5259
|
+
case 29:
|
|
5157
5260
|
case "end":
|
|
5158
5261
|
return _context27.stop();
|
|
5159
5262
|
}
|
|
5160
5263
|
}, _callee25, this);
|
|
5161
5264
|
}));
|
|
5162
|
-
function finalizeProductOrderMutation(
|
|
5265
|
+
function finalizeProductOrderMutation(_x25, _x26) {
|
|
5163
5266
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
5164
5267
|
}
|
|
5165
5268
|
return finalizeProductOrderMutation;
|
|
@@ -5417,14 +5520,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5417
5520
|
case 0:
|
|
5418
5521
|
return _context28.abrupt("return", this.queueCartCommand(function () {
|
|
5419
5522
|
return _this37.addProductToOrderDraft(product, booking, options);
|
|
5420
|
-
}));
|
|
5523
|
+
}, Boolean((options === null || options === void 0 ? void 0 : options.availabilityCommitGuard) || (options === null || options === void 0 ? void 0 : options.availabilityCommitTargetGuard))));
|
|
5421
5524
|
case 1:
|
|
5422
5525
|
case "end":
|
|
5423
5526
|
return _context28.stop();
|
|
5424
5527
|
}
|
|
5425
5528
|
}, _callee26, this);
|
|
5426
5529
|
}));
|
|
5427
|
-
function addProductToOrder(
|
|
5530
|
+
function addProductToOrder(_x27, _x28, _x29) {
|
|
5428
5531
|
return _addProductToOrder.apply(this, arguments);
|
|
5429
5532
|
}
|
|
5430
5533
|
return addProductToOrder;
|
|
@@ -5433,30 +5536,48 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5433
5536
|
key: "addProductToOrderDraft",
|
|
5434
5537
|
value: function () {
|
|
5435
5538
|
var _addProductToOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(product, booking, options) {
|
|
5436
|
-
var
|
|
5437
|
-
|
|
5539
|
+
var _options$availability,
|
|
5540
|
+
_this38 = this;
|
|
5541
|
+
var guarded, mutation, tempOrder, intentCommitGuard, identity, isCurrentOrder, beforeCommit, _tempOrder$_extend10, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref72, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
|
|
5438
5542
|
return _regeneratorRuntime().wrap(function _callee27$(_context29) {
|
|
5439
5543
|
while (1) switch (_context29.prev = _context29.next) {
|
|
5440
5544
|
case 0:
|
|
5441
|
-
|
|
5545
|
+
guarded = Boolean((options === null || options === void 0 ? void 0 : options.availabilityCommitGuard) || (options === null || options === void 0 ? void 0 : options.availabilityCommitTargetGuard));
|
|
5546
|
+
options === null || options === void 0 || (_options$availability = options.availabilityCommitGuard) === null || _options$availability === void 0 || _options$availability.call(options);
|
|
5547
|
+
mutation = this.beginCartMutation({
|
|
5548
|
+
forceDraft: guarded
|
|
5549
|
+
});
|
|
5442
5550
|
tempOrder = mutation.draft;
|
|
5443
|
-
|
|
5551
|
+
intentCommitGuard = this.createCartIntentCommitGuard('add_product', mutation.current);
|
|
5552
|
+
identity = [mutation.current.order_id, mutation.current.external_sale_number];
|
|
5553
|
+
isCurrentOrder = function isCurrentOrder() {
|
|
5554
|
+
var _options$availability2, _options$availability3;
|
|
5555
|
+
return _this38.store.tempOrder === mutation.current && mutation.current.order_id === identity[0] && mutation.current.external_sale_number === identity[1] && ((_options$availability2 = options === null || options === void 0 || (_options$availability3 = options.availabilityCommitTargetGuard) === null || _options$availability3 === void 0 ? void 0 : _options$availability3.call(options)) !== null && _options$availability2 !== void 0 ? _options$availability2 : true);
|
|
5556
|
+
};
|
|
5557
|
+
beforeCommit = function beforeCommit() {
|
|
5558
|
+
var _options$availability4;
|
|
5559
|
+
options === null || options === void 0 || (_options$availability4 = options.availabilityCommitGuard) === null || _options$availability4 === void 0 || _options$availability4.call(options);
|
|
5560
|
+
if (guarded && !isCurrentOrder()) throw Object.assign(new Error('Booking add belongs to a previous order'), {
|
|
5561
|
+
code: 'AVAILABILITY_SELECTION_STALE'
|
|
5562
|
+
});
|
|
5563
|
+
intentCommitGuard();
|
|
5564
|
+
};
|
|
5444
5565
|
if (!(options !== null && options !== void 0 && options.productVoucherGroupKey)) {
|
|
5445
|
-
_context29.next =
|
|
5566
|
+
_context29.next = 12;
|
|
5446
5567
|
break;
|
|
5447
5568
|
}
|
|
5448
5569
|
if ((_tempOrder$_extend10 = tempOrder._extend) !== null && _tempOrder$_extend10 !== void 0 && (_tempOrder$_extend10 = _tempOrder$_extend10.productVoucherGroups) !== null && _tempOrder$_extend10 !== void 0 && _tempOrder$_extend10.some(function (group) {
|
|
5449
5570
|
return group.key === options.productVoucherGroupKey;
|
|
5450
5571
|
})) {
|
|
5451
|
-
_context29.next =
|
|
5572
|
+
_context29.next = 11;
|
|
5452
5573
|
break;
|
|
5453
5574
|
}
|
|
5454
5575
|
throw voucherGroupError();
|
|
5455
|
-
case
|
|
5576
|
+
case 11:
|
|
5456
5577
|
product = _objectSpread(_objectSpread({}, product), {}, {
|
|
5457
5578
|
_productVoucherGroupKey: options.productVoucherGroupKey
|
|
5458
5579
|
});
|
|
5459
|
-
case
|
|
5580
|
+
case 12:
|
|
5460
5581
|
salesNoteDrafts = ((options === null || options === void 0 ? void 0 : options.salesNotes) || []).map(function (draft) {
|
|
5461
5582
|
return {
|
|
5462
5583
|
note_type: String(draft.note_type || '').trim(),
|
|
@@ -5506,21 +5627,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5506
5627
|
return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
|
|
5507
5628
|
}) : -1;
|
|
5508
5629
|
insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
5509
|
-
_context29.prev =
|
|
5630
|
+
_context29.prev = 19;
|
|
5510
5631
|
if (!booking) {
|
|
5511
|
-
_context29.next =
|
|
5632
|
+
_context29.next = 44;
|
|
5512
5633
|
break;
|
|
5513
5634
|
}
|
|
5514
5635
|
productRecord = product;
|
|
5515
5636
|
splitCount = getSafeProductNum((_ref72 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref72 !== void 0 ? _ref72 : 1);
|
|
5516
5637
|
if (!(splitCount > 1)) {
|
|
5517
|
-
_context29.next =
|
|
5638
|
+
_context29.next = 38;
|
|
5518
5639
|
break;
|
|
5519
5640
|
}
|
|
5520
5641
|
i = 0;
|
|
5521
|
-
case
|
|
5642
|
+
case 25:
|
|
5522
5643
|
if (!(i < splitCount)) {
|
|
5523
|
-
_context29.next =
|
|
5644
|
+
_context29.next = 36;
|
|
5524
5645
|
break;
|
|
5525
5646
|
}
|
|
5526
5647
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
@@ -5538,227 +5659,552 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5538
5659
|
delete splitLine.booking.metadata.unique_identification_number;
|
|
5539
5660
|
}
|
|
5540
5661
|
}
|
|
5541
|
-
_context29.next =
|
|
5662
|
+
_context29.next = 30;
|
|
5542
5663
|
return this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
5543
5664
|
insertAtIndex: insertAtIndex,
|
|
5544
5665
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5545
5666
|
beforeCommit: beforeCommit
|
|
5546
5667
|
});
|
|
5547
|
-
case
|
|
5668
|
+
case 30:
|
|
5548
5669
|
committedProduct = _context29.sent;
|
|
5549
5670
|
attachSalesNoteDrafts(committedProduct);
|
|
5550
5671
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
5551
|
-
case
|
|
5672
|
+
case 33:
|
|
5552
5673
|
i += 1;
|
|
5553
|
-
_context29.next =
|
|
5674
|
+
_context29.next = 25;
|
|
5554
5675
|
break;
|
|
5555
|
-
case
|
|
5556
|
-
_context29.next =
|
|
5676
|
+
case 36:
|
|
5677
|
+
_context29.next = 42;
|
|
5557
5678
|
break;
|
|
5558
|
-
case
|
|
5559
|
-
_context29.next =
|
|
5679
|
+
case 38:
|
|
5680
|
+
_context29.next = 40;
|
|
5560
5681
|
return this.appendProductLineToTempOrder(tempOrder, product, cloneDeep(booking), {
|
|
5561
5682
|
insertAtIndex: insertAtIndex,
|
|
5562
5683
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5563
5684
|
beforeCommit: beforeCommit
|
|
5564
5685
|
});
|
|
5565
|
-
case
|
|
5686
|
+
case 40:
|
|
5566
5687
|
_committedProduct = _context29.sent;
|
|
5567
5688
|
attachSalesNoteDrafts(_committedProduct);
|
|
5568
|
-
case
|
|
5569
|
-
_context29.next =
|
|
5689
|
+
case 42:
|
|
5690
|
+
_context29.next = 48;
|
|
5570
5691
|
break;
|
|
5571
|
-
case
|
|
5572
|
-
_context29.next =
|
|
5692
|
+
case 44:
|
|
5693
|
+
_context29.next = 46;
|
|
5573
5694
|
return this.appendProductLineToTempOrder(tempOrder, product, undefined, {
|
|
5574
5695
|
insertAtIndex: insertAtIndex,
|
|
5575
5696
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5576
5697
|
beforeCommit: beforeCommit
|
|
5577
5698
|
});
|
|
5578
|
-
case
|
|
5699
|
+
case 46:
|
|
5579
5700
|
_committedProduct2 = _context29.sent;
|
|
5580
5701
|
attachSalesNoteDrafts(_committedProduct2);
|
|
5581
|
-
case
|
|
5582
|
-
_context29.next =
|
|
5702
|
+
case 48:
|
|
5703
|
+
_context29.next = 54;
|
|
5583
5704
|
break;
|
|
5584
|
-
case
|
|
5585
|
-
_context29.prev =
|
|
5586
|
-
_context29.t0 = _context29["catch"](
|
|
5705
|
+
case 50:
|
|
5706
|
+
_context29.prev = 50;
|
|
5707
|
+
_context29.t0 = _context29["catch"](19);
|
|
5587
5708
|
rollbackProductAndNotesMutation();
|
|
5588
5709
|
throw _context29.t0;
|
|
5589
|
-
case
|
|
5710
|
+
case 54:
|
|
5590
5711
|
if (!mutation.commit) {
|
|
5591
|
-
_context29.next =
|
|
5712
|
+
_context29.next = 58;
|
|
5592
5713
|
break;
|
|
5593
5714
|
}
|
|
5594
|
-
_context29.next =
|
|
5715
|
+
_context29.next = 57;
|
|
5595
5716
|
return mutation.commit(beforeCommit);
|
|
5596
|
-
case
|
|
5717
|
+
case 57:
|
|
5597
5718
|
tempOrder = _context29.sent;
|
|
5598
|
-
case
|
|
5599
|
-
|
|
5719
|
+
case 58:
|
|
5720
|
+
if (!guarded) {
|
|
5721
|
+
_context29.next = 70;
|
|
5722
|
+
break;
|
|
5723
|
+
}
|
|
5724
|
+
_context29.prev = 59;
|
|
5725
|
+
if (isCurrentOrder()) this.persistTempOrder();
|
|
5726
|
+
_context29.next = 63;
|
|
5727
|
+
return this.finalizeProductOrderMutation(tempOrder, {
|
|
5728
|
+
isCurrentOrder: isCurrentOrder
|
|
5729
|
+
});
|
|
5730
|
+
case 63:
|
|
5731
|
+
_context29.next = 68;
|
|
5732
|
+
break;
|
|
5733
|
+
case 65:
|
|
5734
|
+
_context29.prev = 65;
|
|
5735
|
+
_context29.t1 = _context29["catch"](59);
|
|
5736
|
+
this.logWarning('addProductToOrder committed; finalization failed', {
|
|
5737
|
+
product_id: product.product_id,
|
|
5738
|
+
committed: true,
|
|
5739
|
+
error: _context29.t1 instanceof Error ? _context29.t1.message : String(_context29.t1)
|
|
5740
|
+
});
|
|
5741
|
+
case 68:
|
|
5742
|
+
_context29.next = 72;
|
|
5743
|
+
break;
|
|
5744
|
+
case 70:
|
|
5745
|
+
_context29.next = 72;
|
|
5600
5746
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
5601
|
-
case
|
|
5747
|
+
case 72:
|
|
5602
5748
|
this.logInfo('addProductToOrder success', {
|
|
5603
5749
|
product_id: product.product_id,
|
|
5604
5750
|
with_booking: !!booking
|
|
5605
5751
|
});
|
|
5606
5752
|
return _context29.abrupt("return", tempOrder.products);
|
|
5607
|
-
case
|
|
5753
|
+
case 74:
|
|
5608
5754
|
case "end":
|
|
5609
5755
|
return _context29.stop();
|
|
5610
5756
|
}
|
|
5611
|
-
}, _callee27, this, [[
|
|
5757
|
+
}, _callee27, this, [[19, 50], [59, 65]]);
|
|
5612
5758
|
}));
|
|
5613
|
-
function addProductToOrderDraft(
|
|
5759
|
+
function addProductToOrderDraft(_x30, _x31, _x32) {
|
|
5614
5760
|
return _addProductToOrderDraft.apply(this, arguments);
|
|
5615
5761
|
}
|
|
5616
5762
|
return addProductToOrderDraft;
|
|
5617
5763
|
}()
|
|
5618
5764
|
/**
|
|
5619
|
-
*
|
|
5620
|
-
*
|
|
5621
|
-
*
|
|
5622
|
-
* await order.addProductsToOrder([
|
|
5623
|
-
* { product: { product_id: 1, product_variant_id: 0, num: 1 } },
|
|
5624
|
-
* { product: { product_id: 2, product_variant_id: 0, num: 1 } },
|
|
5625
|
-
* ]);
|
|
5765
|
+
* Replaces one local Party booking and its confirmed children on a detached draft.
|
|
5766
|
+
* All fallible preparation precedes a guarded synchronous publication; never rolls
|
|
5767
|
+
* an old whole-order snapshot over concurrent edits or a newly selected order.
|
|
5626
5768
|
*/
|
|
5627
5769
|
}, {
|
|
5628
|
-
key: "
|
|
5770
|
+
key: "replaceBookingProductWithRelatedRetail",
|
|
5629
5771
|
value: (function () {
|
|
5630
|
-
var
|
|
5772
|
+
var _replaceBookingProductWithRelatedRetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
5631
5773
|
var _this39 = this;
|
|
5632
5774
|
return _regeneratorRuntime().wrap(function _callee28$(_context30) {
|
|
5633
5775
|
while (1) switch (_context30.prev = _context30.next) {
|
|
5634
5776
|
case 0:
|
|
5635
5777
|
return _context30.abrupt("return", this.queueCartCommand(function () {
|
|
5636
|
-
return _this39.
|
|
5637
|
-
}));
|
|
5778
|
+
return _this39.replaceBookingProductWithRelatedRetailDraft(params);
|
|
5779
|
+
}, true));
|
|
5638
5780
|
case 1:
|
|
5639
5781
|
case "end":
|
|
5640
5782
|
return _context30.stop();
|
|
5641
5783
|
}
|
|
5642
5784
|
}, _callee28, this);
|
|
5643
5785
|
}));
|
|
5644
|
-
function
|
|
5645
|
-
return
|
|
5786
|
+
function replaceBookingProductWithRelatedRetail(_x33) {
|
|
5787
|
+
return _replaceBookingProductWithRelatedRetail.apply(this, arguments);
|
|
5646
5788
|
}
|
|
5647
|
-
return
|
|
5789
|
+
return replaceBookingProductWithRelatedRetail;
|
|
5648
5790
|
}())
|
|
5649
5791
|
}, {
|
|
5650
|
-
key: "
|
|
5792
|
+
key: "replaceBookingProductWithRelatedRetailDraft",
|
|
5651
5793
|
value: function () {
|
|
5652
|
-
var
|
|
5653
|
-
var
|
|
5654
|
-
|
|
5655
|
-
|
|
5794
|
+
var _replaceBookingProductWithRelatedRetailDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
5795
|
+
var _target$metadata,
|
|
5796
|
+
_target$metadata2,
|
|
5797
|
+
_params$product$num,
|
|
5798
|
+
_target$metadata3,
|
|
5799
|
+
_params$product$metad,
|
|
5800
|
+
_params$product$metad2,
|
|
5801
|
+
_params$booking$metad,
|
|
5802
|
+
_this40 = this,
|
|
5803
|
+
_mutation$commit;
|
|
5804
|
+
var mutation, live, beforeCommit, uid, getUid, targetIndex, target, scopeKey, targetBookingUid, children, start, serviceDatetime, ownedUids, nextUids, retainedChildUids, nextChildren, _iterator22, _step22, _loop3, publishedFields, guardedFields, readFields, baseline, identity, isCurrentOrder, draft, removed, _iterator23, _step23, line, _iterator24, _step24, _draft$_extend, _line, replacement, _iterator25, _step25, _step25$value, index, child;
|
|
5805
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
5806
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
5656
5807
|
case 0:
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5808
|
+
params.availabilityCommitGuard();
|
|
5809
|
+
mutation = this.beginCartMutation({
|
|
5810
|
+
forceDraft: true
|
|
5811
|
+
});
|
|
5812
|
+
live = mutation.current;
|
|
5813
|
+
beforeCommit = this.createCartIntentCommitGuard('update_product', live);
|
|
5814
|
+
uid = String(params.productLineUid || '');
|
|
5815
|
+
getUid = function getUid(line) {
|
|
5816
|
+
var _line$metadata2;
|
|
5817
|
+
return String(((_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.unique_identification_number) || line.unique_identification_number || '');
|
|
5818
|
+
};
|
|
5819
|
+
targetIndex = live.products.findIndex(function (line) {
|
|
5820
|
+
return getUid(line) === uid;
|
|
5821
|
+
});
|
|
5822
|
+
target = live.products[targetIndex];
|
|
5823
|
+
scopeKey = String((target === null || target === void 0 || (_target$metadata = target.metadata) === null || _target$metadata === void 0 ? void 0 : _target$metadata.venue_booking_scope_key) || '');
|
|
5824
|
+
targetBookingUid = String((target === null || target === void 0 ? void 0 : target.booking_uid) || (target === null || target === void 0 || (_target$metadata2 = target.metadata) === null || _target$metadata2 === void 0 ? void 0 : _target$metadata2.booking_uid) || '');
|
|
5825
|
+
if (!(!uid || !target || !scopeKey || live.order_id || live.products.filter(function (line) {
|
|
5826
|
+
return getUid(line) === uid;
|
|
5827
|
+
}).length !== 1 || target.order_detail_id != null || Number(target.num) !== 1 || Number((_params$product$num = params.product.num) !== null && _params$product$num !== void 0 ? _params$product$num : 1) !== 1 || ((_target$metadata3 = target.metadata) === null || _target$metadata3 === void 0 ? void 0 : _target$metadata3.venue_booking_role) !== 'party_main' || ((_params$product$metad = params.product.metadata) === null || _params$product$metad === void 0 ? void 0 : _params$product$metad.venue_booking_role) !== 'party_main' || ((_params$product$metad2 = params.product.metadata) === null || _params$product$metad2 === void 0 ? void 0 : _params$product$metad2.venue_booking_scope_key) !== scopeKey || !Array.isArray(params.relatedRetailProducts) || (live.payments || []).length > 0 || !targetBookingUid || String(((_params$booking$metad = params.booking.metadata) === null || _params$booking$metad === void 0 ? void 0 : _params$booking$metad.unique_identification_number) || '') !== targetBookingUid || (live.bookings || []).filter(function (booking) {
|
|
5828
|
+
return _this40.getBookingUniqueIdentificationNumber(booking) === targetBookingUid;
|
|
5829
|
+
}).length !== 1 || live.products.filter(function (line) {
|
|
5830
|
+
var _line$metadata3, _line$metadata4;
|
|
5831
|
+
return ((_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.venue_booking_role) === 'party_main' && ((_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.venue_booking_scope_key) === scopeKey;
|
|
5832
|
+
}).length !== 1)) {
|
|
5833
|
+
_context32.next = 12;
|
|
5678
5834
|
break;
|
|
5679
5835
|
}
|
|
5680
|
-
|
|
5681
|
-
case
|
|
5682
|
-
|
|
5683
|
-
|
|
5836
|
+
throw new Error('[Order] Party replacement requires one unsubmitted, unpaid main booking in the same scope');
|
|
5837
|
+
case 12:
|
|
5838
|
+
children = live.products.filter(function (line) {
|
|
5839
|
+
var _line$metadata5, _line$metadata6;
|
|
5840
|
+
return ((_line$metadata5 = line.metadata) === null || _line$metadata5 === void 0 ? void 0 : _line$metadata5.venue_booking_role) === 'party_extra' && String(((_line$metadata6 = line.metadata) === null || _line$metadata6 === void 0 ? void 0 : _line$metadata6.venue_booking_parent_uid) || '') === uid;
|
|
5841
|
+
});
|
|
5842
|
+
if (!children.some(function (line) {
|
|
5843
|
+
var _line$metadata7;
|
|
5844
|
+
return !getUid(line) || live.products.filter(function (candidate) {
|
|
5845
|
+
return getUid(candidate) === getUid(line);
|
|
5846
|
+
}).length !== 1 || ((_line$metadata7 = line.metadata) === null || _line$metadata7 === void 0 ? void 0 : _line$metadata7.venue_booking_scope_key) !== scopeKey || line.order_detail_id != null || _this40.hasLinkedBookingUid(line);
|
|
5847
|
+
})) {
|
|
5848
|
+
_context32.next = 15;
|
|
5684
5849
|
break;
|
|
5685
5850
|
}
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5851
|
+
throw new Error('[Order] Related retail line does not belong to this local Party scope');
|
|
5852
|
+
case 15:
|
|
5853
|
+
start = params.booking.start_at || "".concat(params.booking.start_date || '', " ").concat(params.booking.start_time || '').trim();
|
|
5854
|
+
if (!(!start || !dayjs(start).isValid())) {
|
|
5855
|
+
_context32.next = 18;
|
|
5690
5856
|
break;
|
|
5691
5857
|
}
|
|
5692
|
-
|
|
5858
|
+
throw new Error('[Order] Party service datetime is required');
|
|
5693
5859
|
case 18:
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
|
|
5860
|
+
serviceDatetime = dayjs(start).format('YYYY-MM-DD HH:mm:ss');
|
|
5861
|
+
ownedUids = new Set(children.map(getUid));
|
|
5862
|
+
nextUids = new Set();
|
|
5863
|
+
retainedChildUids = new Set();
|
|
5864
|
+
nextChildren = cloneDeep(params.relatedRetailProducts);
|
|
5865
|
+
_iterator22 = _createForOfIteratorHelper(nextChildren);
|
|
5866
|
+
_context32.prev = 24;
|
|
5867
|
+
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
5868
|
+
var _child$metadata, _child$metadata2, _child$metadata3, _child$metadata4, _child$num;
|
|
5869
|
+
var child, childUid, service, previous, _live$_extend, _rawChild$_origin, previousForms, rawChild;
|
|
5870
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context31) {
|
|
5871
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
5872
|
+
case 0:
|
|
5873
|
+
child = _step22.value;
|
|
5874
|
+
childUid = getUid(child);
|
|
5875
|
+
service = String(((_child$metadata = child.metadata) === null || _child$metadata === void 0 ? void 0 : _child$metadata.venue_booking_service_datetime) || '');
|
|
5876
|
+
if (!(((_child$metadata2 = child.metadata) === null || _child$metadata2 === void 0 ? void 0 : _child$metadata2.venue_booking_role) !== 'party_extra' || String(((_child$metadata3 = child.metadata) === null || _child$metadata3 === void 0 ? void 0 : _child$metadata3.venue_booking_parent_uid) || '') !== uid || ((_child$metadata4 = child.metadata) === null || _child$metadata4 === void 0 ? void 0 : _child$metadata4.venue_booking_scope_key) !== scopeKey || !service || !dayjs(service).isValid() || dayjs(service).format('YYYY-MM-DD HH:mm:ss') !== serviceDatetime || _this40.hasLinkedBookingUid(child) || child.order_detail_id != null || childUid && (nextUids.has(childUid) || live.products.some(function (line) {
|
|
5877
|
+
return getUid(line) === childUid && !ownedUids.has(childUid);
|
|
5878
|
+
})))) {
|
|
5879
|
+
_context31.next = 5;
|
|
5880
|
+
break;
|
|
5881
|
+
}
|
|
5882
|
+
throw new Error('[Order] Invalid Party extra ownership, identity, or service datetime');
|
|
5883
|
+
case 5:
|
|
5884
|
+
if (childUid) nextUids.add(childUid);
|
|
5885
|
+
previous = children.find(function (line) {
|
|
5886
|
+
return getUid(line) === childUid;
|
|
5887
|
+
});
|
|
5888
|
+
if (previous && previous.product_id === child.product_id && Number(previous.product_variant_id || 0) === Number(child.product_variant_id || 0) && Number(previous.num) === Number((_child$num = child.num) !== null && _child$num !== void 0 ? _child$num : 1) && buildProductLineFingerprint(getProductSkuOptions(previous), previous.product_bundle) === buildProductLineFingerprint(getProductSkuOptions(child), child.product_bundle)) {
|
|
5889
|
+
retainedChildUids.add(childUid);
|
|
5890
|
+
// The same configured extra keeps completed product forms unless explicitly replaced.
|
|
5891
|
+
previousForms = (_live$_extend = live._extend) === null || _live$_extend === void 0 || (_live$_extend = _live$_extend.productsByUid) === null || _live$_extend === void 0 || (_live$_extend = _live$_extend[childUid]) === null || _live$_extend === void 0 || (_live$_extend = _live$_extend.origin) === null || _live$_extend === void 0 ? void 0 : _live$_extend.relation_forms;
|
|
5892
|
+
rawChild = child;
|
|
5893
|
+
if (previousForms !== undefined && ((_rawChild$_origin = rawChild._origin) === null || _rawChild$_origin === void 0 ? void 0 : _rawChild$_origin.relation_forms) === undefined) {
|
|
5894
|
+
rawChild._origin = _objectSpread(_objectSpread({}, rawChild._origin || {}), {}, {
|
|
5895
|
+
relation_forms: cloneDeep(previousForms)
|
|
5896
|
+
});
|
|
5897
|
+
}
|
|
5898
|
+
}
|
|
5899
|
+
case 8:
|
|
5900
|
+
case "end":
|
|
5901
|
+
return _context31.stop();
|
|
5902
|
+
}
|
|
5903
|
+
}, _loop3);
|
|
5701
5904
|
});
|
|
5702
|
-
|
|
5703
|
-
_context31.next = 24;
|
|
5704
|
-
break;
|
|
5705
|
-
}
|
|
5706
|
-
_context31.next = 24;
|
|
5707
|
-
return _appendResult;
|
|
5708
|
-
case 24:
|
|
5709
|
-
i += 1;
|
|
5710
|
-
_context31.next = 18;
|
|
5711
|
-
break;
|
|
5905
|
+
_iterator22.s();
|
|
5712
5906
|
case 27:
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
5716
|
-
beforeCommit: beforeCommit
|
|
5717
|
-
});
|
|
5718
|
-
if (!appendResult) {
|
|
5719
|
-
_context31.next = 32;
|
|
5907
|
+
if ((_step22 = _iterator22.n()).done) {
|
|
5908
|
+
_context32.next = 31;
|
|
5720
5909
|
break;
|
|
5721
5910
|
}
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
_context31.next = 8;
|
|
5911
|
+
return _context32.delegateYield(_loop3(), "t0", 29);
|
|
5912
|
+
case 29:
|
|
5913
|
+
_context32.next = 27;
|
|
5726
5914
|
break;
|
|
5727
|
-
case
|
|
5728
|
-
|
|
5915
|
+
case 31:
|
|
5916
|
+
_context32.next = 36;
|
|
5729
5917
|
break;
|
|
5918
|
+
case 33:
|
|
5919
|
+
_context32.prev = 33;
|
|
5920
|
+
_context32.t1 = _context32["catch"](24);
|
|
5921
|
+
_iterator22.e(_context32.t1);
|
|
5730
5922
|
case 36:
|
|
5731
|
-
|
|
5732
|
-
_context31.t0 = _context31["catch"](6);
|
|
5733
|
-
_iterator22.e(_context31.t0);
|
|
5734
|
-
case 39:
|
|
5735
|
-
_context31.prev = 39;
|
|
5923
|
+
_context32.prev = 36;
|
|
5736
5924
|
_iterator22.f();
|
|
5737
|
-
return
|
|
5738
|
-
case
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5925
|
+
return _context32.finish(36);
|
|
5926
|
+
case 39:
|
|
5927
|
+
publishedFields = ['products', 'bookings', 'notes', '_extend', 'metadata', 'holder', 'holder_relations', 'currency_code', 'currency_symbol', 'currency_format'];
|
|
5928
|
+
guardedFields = [].concat(publishedFields, ['customer_id', 'discount_list', 'shop_discount', 'payments']);
|
|
5929
|
+
readFields = function readFields(order, fields) {
|
|
5930
|
+
return Object.fromEntries(fields.map(function (key) {
|
|
5931
|
+
return [key, order[key]];
|
|
5932
|
+
}));
|
|
5933
|
+
};
|
|
5934
|
+
baseline = cloneDeep(readFields(live, guardedFields));
|
|
5935
|
+
identity = [live.order_id, live.external_sale_number];
|
|
5936
|
+
isCurrentOrder = function isCurrentOrder() {
|
|
5937
|
+
var _params$availabilityC, _params$availabilityC2;
|
|
5938
|
+
return _this40.store.tempOrder === live && live.order_id === identity[0] && live.external_sale_number === identity[1] && ((_params$availabilityC = (_params$availabilityC2 = params.availabilityCommitTargetGuard) === null || _params$availabilityC2 === void 0 ? void 0 : _params$availabilityC2.call(params)) !== null && _params$availabilityC !== void 0 ? _params$availabilityC : true);
|
|
5939
|
+
};
|
|
5940
|
+
draft = mutation.draft;
|
|
5941
|
+
this.ensureSalesNotesLoadedForMutation(draft);
|
|
5942
|
+
removed = draft.products.filter(function (line) {
|
|
5943
|
+
return getUid(line) === uid || ownedUids.has(getUid(line));
|
|
5944
|
+
});
|
|
5945
|
+
draft.products = draft.products.filter(function (line) {
|
|
5946
|
+
return getUid(line) !== uid && !ownedUids.has(getUid(line));
|
|
5947
|
+
});
|
|
5948
|
+
_iterator23 = _createForOfIteratorHelper(removed);
|
|
5949
|
+
try {
|
|
5950
|
+
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
5951
|
+
line = _step23.value;
|
|
5952
|
+
this.removeLinkedBookingsForProduct(draft, line);
|
|
5953
|
+
}
|
|
5954
|
+
} catch (err) {
|
|
5955
|
+
_iterator23.e(err);
|
|
5956
|
+
} finally {
|
|
5957
|
+
_iterator23.f();
|
|
5958
|
+
}
|
|
5959
|
+
removeProductHolderRelations(draft, removed.filter(function (line) {
|
|
5960
|
+
return !retainedChildUids.has(getUid(line));
|
|
5961
|
+
}));
|
|
5962
|
+
_iterator24 = _createForOfIteratorHelper(removed);
|
|
5963
|
+
try {
|
|
5964
|
+
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
5965
|
+
_line = _step24.value;
|
|
5966
|
+
if ((_draft$_extend = draft._extend) !== null && _draft$_extend !== void 0 && _draft$_extend.productsByUid && !retainedChildUids.has(getUid(_line))) {
|
|
5967
|
+
delete draft._extend.productsByUid[getUid(_line)];
|
|
5968
|
+
}
|
|
5969
|
+
}
|
|
5970
|
+
} catch (err) {
|
|
5971
|
+
_iterator24.e(err);
|
|
5972
|
+
} finally {
|
|
5973
|
+
_iterator24.f();
|
|
5974
|
+
}
|
|
5975
|
+
replacement = cloneDeep(params.product);
|
|
5976
|
+
replacement.metadata = _objectSpread(_objectSpread({}, replacement.metadata || {}), {}, {
|
|
5977
|
+
unique_identification_number: uid,
|
|
5978
|
+
venue_booking_service_datetime: serviceDatetime
|
|
5979
|
+
});
|
|
5980
|
+
replacement.unique_identification_number = uid;
|
|
5981
|
+
_context32.next = 59;
|
|
5982
|
+
return this.appendProductLineToTempOrder(draft, replacement, cloneDeep(params.booking), {
|
|
5983
|
+
insertAtIndex: targetIndex,
|
|
5984
|
+
disableMerge: true,
|
|
5985
|
+
beforeCommit: beforeCommit
|
|
5986
|
+
});
|
|
5987
|
+
case 59:
|
|
5988
|
+
_iterator25 = _createForOfIteratorHelper(nextChildren.entries());
|
|
5989
|
+
_context32.prev = 60;
|
|
5990
|
+
_iterator25.s();
|
|
5991
|
+
case 62:
|
|
5992
|
+
if ((_step25 = _iterator25.n()).done) {
|
|
5993
|
+
_context32.next = 68;
|
|
5994
|
+
break;
|
|
5995
|
+
}
|
|
5996
|
+
_step25$value = _slicedToArray(_step25.value, 2), index = _step25$value[0], child = _step25$value[1];
|
|
5997
|
+
_context32.next = 66;
|
|
5998
|
+
return this.appendProductLineToTempOrder(draft, child, undefined, {
|
|
5999
|
+
insertAtIndex: targetIndex + index + 1,
|
|
6000
|
+
disableMerge: true,
|
|
6001
|
+
beforeCommit: beforeCommit
|
|
6002
|
+
});
|
|
6003
|
+
case 66:
|
|
6004
|
+
_context32.next = 62;
|
|
6005
|
+
break;
|
|
6006
|
+
case 68:
|
|
6007
|
+
_context32.next = 73;
|
|
6008
|
+
break;
|
|
6009
|
+
case 70:
|
|
6010
|
+
_context32.prev = 70;
|
|
6011
|
+
_context32.t2 = _context32["catch"](60);
|
|
6012
|
+
_iterator25.e(_context32.t2);
|
|
6013
|
+
case 73:
|
|
6014
|
+
_context32.prev = 73;
|
|
6015
|
+
_iterator25.f();
|
|
6016
|
+
return _context32.finish(73);
|
|
6017
|
+
case 76:
|
|
6018
|
+
this.removeSalesNotesForMissingProductLines(draft);
|
|
6019
|
+
this.syncTempOrderHolderFromBookings(draft);
|
|
6020
|
+
// Develop owns inventory/voucher validation and the whole-draft CAS. Recheck
|
|
6021
|
+
// the availability intent after that await, immediately before its publication.
|
|
6022
|
+
_context32.next = 80;
|
|
6023
|
+
return (_mutation$commit = mutation.commit) === null || _mutation$commit === void 0 ? void 0 : _mutation$commit.call(mutation, function () {
|
|
6024
|
+
params.availabilityCommitGuard();
|
|
6025
|
+
beforeCommit();
|
|
6026
|
+
if (!isCurrentOrder() || !isEqual(readFields(live, guardedFields), baseline)) {
|
|
6027
|
+
throw Object.assign(new Error('Party replacement interrupted by an order change'), {
|
|
6028
|
+
code: 'AVAILABILITY_SELECTION_STALE'
|
|
6029
|
+
});
|
|
6030
|
+
}
|
|
6031
|
+
});
|
|
6032
|
+
case 80:
|
|
6033
|
+
_context32.prev = 80;
|
|
6034
|
+
if (isCurrentOrder()) this.persistTempOrder();
|
|
6035
|
+
_context32.next = 84;
|
|
6036
|
+
return this.finalizeProductOrderMutation(live, {
|
|
6037
|
+
isCurrentOrder: isCurrentOrder
|
|
6038
|
+
});
|
|
6039
|
+
case 84:
|
|
6040
|
+
_context32.next = 89;
|
|
6041
|
+
break;
|
|
6042
|
+
case 86:
|
|
6043
|
+
_context32.prev = 86;
|
|
6044
|
+
_context32.t3 = _context32["catch"](80);
|
|
6045
|
+
// Already committed. Do not invite a second replacement or restore a stale snapshot.
|
|
6046
|
+
this.logWarning('Party replacement committed; finalization failed', {
|
|
6047
|
+
productLineUid: uid,
|
|
6048
|
+
committed: true,
|
|
6049
|
+
error: _context32.t3 instanceof Error ? _context32.t3.message : String(_context32.t3)
|
|
6050
|
+
});
|
|
6051
|
+
case 89:
|
|
6052
|
+
return _context32.abrupt("return", live.products);
|
|
6053
|
+
case 90:
|
|
6054
|
+
case "end":
|
|
6055
|
+
return _context32.stop();
|
|
6056
|
+
}
|
|
6057
|
+
}, _callee29, this, [[24, 33, 36, 39], [60, 70, 73, 76], [80, 86]]);
|
|
6058
|
+
}));
|
|
6059
|
+
function replaceBookingProductWithRelatedRetailDraft(_x34) {
|
|
6060
|
+
return _replaceBookingProductWithRelatedRetailDraft.apply(this, arguments);
|
|
6061
|
+
}
|
|
6062
|
+
return replaceBookingProductWithRelatedRetailDraft;
|
|
6063
|
+
}()
|
|
6064
|
+
/**
|
|
6065
|
+
* 批量添加商品行,所有行追加完成后只触发一次促销、折扣、summary 重算与持久化。
|
|
6066
|
+
*
|
|
6067
|
+
* @example
|
|
6068
|
+
* await order.addProductsToOrder([
|
|
6069
|
+
* { product: { product_id: 1, product_variant_id: 0, num: 1 } },
|
|
6070
|
+
* { product: { product_id: 2, product_variant_id: 0, num: 1 } },
|
|
6071
|
+
* ]);
|
|
6072
|
+
*/
|
|
6073
|
+
}, {
|
|
6074
|
+
key: "addProductsToOrder",
|
|
6075
|
+
value: (function () {
|
|
6076
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(items, options) {
|
|
6077
|
+
var _this41 = this;
|
|
6078
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
6079
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
6080
|
+
case 0:
|
|
6081
|
+
return _context33.abrupt("return", this.queueCartCommand(function () {
|
|
6082
|
+
return _this41.addProductsToOrderDraft(items, options);
|
|
6083
|
+
}));
|
|
6084
|
+
case 1:
|
|
6085
|
+
case "end":
|
|
6086
|
+
return _context33.stop();
|
|
6087
|
+
}
|
|
6088
|
+
}, _callee30, this);
|
|
6089
|
+
}));
|
|
6090
|
+
function addProductsToOrder(_x35, _x36) {
|
|
6091
|
+
return _addProductsToOrder.apply(this, arguments);
|
|
6092
|
+
}
|
|
6093
|
+
return addProductsToOrder;
|
|
6094
|
+
}())
|
|
6095
|
+
}, {
|
|
6096
|
+
key: "addProductsToOrderDraft",
|
|
6097
|
+
value: function () {
|
|
6098
|
+
var _addProductsToOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(items, options) {
|
|
6099
|
+
var mutation, tempOrder, beforeCommit, _iterator26, _step26, item, product, booking, _ref73, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
|
|
6100
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
6101
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
6102
|
+
case 0:
|
|
6103
|
+
mutation = this.beginCartMutation();
|
|
6104
|
+
tempOrder = mutation.draft;
|
|
6105
|
+
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
6106
|
+
_context34.next = 4;
|
|
6107
|
+
break;
|
|
6108
|
+
}
|
|
6109
|
+
return _context34.abrupt("return", tempOrder.products);
|
|
6110
|
+
case 4:
|
|
6111
|
+
beforeCommit = this.createCartIntentCommitGuard('add_product', mutation.current);
|
|
6112
|
+
_iterator26 = _createForOfIteratorHelper(items || []);
|
|
6113
|
+
_context34.prev = 6;
|
|
6114
|
+
_iterator26.s();
|
|
6115
|
+
case 8:
|
|
6116
|
+
if ((_step26 = _iterator26.n()).done) {
|
|
6117
|
+
_context34.next = 34;
|
|
6118
|
+
break;
|
|
6119
|
+
}
|
|
6120
|
+
item = _step26.value;
|
|
6121
|
+
product = item.product, booking = item.booking;
|
|
6122
|
+
if (product) {
|
|
6123
|
+
_context34.next = 13;
|
|
6124
|
+
break;
|
|
6125
|
+
}
|
|
6126
|
+
return _context34.abrupt("continue", 32);
|
|
6127
|
+
case 13:
|
|
6128
|
+
if (!booking) {
|
|
6129
|
+
_context34.next = 28;
|
|
6130
|
+
break;
|
|
6131
|
+
}
|
|
6132
|
+
productRecord = product;
|
|
6133
|
+
splitCount = getSafeProductNum((_ref73 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref73 !== void 0 ? _ref73 : 1);
|
|
6134
|
+
if (!(splitCount > 1)) {
|
|
6135
|
+
_context34.next = 28;
|
|
6136
|
+
break;
|
|
6137
|
+
}
|
|
6138
|
+
i = 0;
|
|
6139
|
+
case 18:
|
|
6140
|
+
if (!(i < splitCount)) {
|
|
6141
|
+
_context34.next = 27;
|
|
6142
|
+
break;
|
|
6143
|
+
}
|
|
6144
|
+
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
6145
|
+
_appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
6146
|
+
beforeCommit: beforeCommit
|
|
6147
|
+
});
|
|
6148
|
+
if (!_appendResult) {
|
|
6149
|
+
_context34.next = 24;
|
|
6150
|
+
break;
|
|
6151
|
+
}
|
|
6152
|
+
_context34.next = 24;
|
|
6153
|
+
return _appendResult;
|
|
6154
|
+
case 24:
|
|
6155
|
+
i += 1;
|
|
6156
|
+
_context34.next = 18;
|
|
6157
|
+
break;
|
|
6158
|
+
case 27:
|
|
6159
|
+
return _context34.abrupt("continue", 32);
|
|
6160
|
+
case 28:
|
|
6161
|
+
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
6162
|
+
beforeCommit: beforeCommit
|
|
6163
|
+
});
|
|
6164
|
+
if (!appendResult) {
|
|
6165
|
+
_context34.next = 32;
|
|
6166
|
+
break;
|
|
6167
|
+
}
|
|
6168
|
+
_context34.next = 32;
|
|
6169
|
+
return appendResult;
|
|
6170
|
+
case 32:
|
|
6171
|
+
_context34.next = 8;
|
|
6172
|
+
break;
|
|
6173
|
+
case 34:
|
|
6174
|
+
_context34.next = 39;
|
|
6175
|
+
break;
|
|
6176
|
+
case 36:
|
|
6177
|
+
_context34.prev = 36;
|
|
6178
|
+
_context34.t0 = _context34["catch"](6);
|
|
6179
|
+
_iterator26.e(_context34.t0);
|
|
6180
|
+
case 39:
|
|
6181
|
+
_context34.prev = 39;
|
|
6182
|
+
_iterator26.f();
|
|
6183
|
+
return _context34.finish(39);
|
|
6184
|
+
case 42:
|
|
6185
|
+
if (!mutation.commit) {
|
|
6186
|
+
_context34.next = 46;
|
|
6187
|
+
break;
|
|
6188
|
+
}
|
|
6189
|
+
_context34.next = 45;
|
|
6190
|
+
return mutation.commit(beforeCommit);
|
|
5745
6191
|
case 45:
|
|
5746
|
-
tempOrder =
|
|
6192
|
+
tempOrder = _context34.sent;
|
|
5747
6193
|
case 46:
|
|
5748
|
-
|
|
6194
|
+
_context34.next = 48;
|
|
5749
6195
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
5750
6196
|
case 48:
|
|
5751
6197
|
this.logInfo('addProductsToOrder success', {
|
|
5752
6198
|
itemsCount: items.length
|
|
5753
6199
|
});
|
|
5754
|
-
return
|
|
6200
|
+
return _context34.abrupt("return", tempOrder.products);
|
|
5755
6201
|
case 50:
|
|
5756
6202
|
case "end":
|
|
5757
|
-
return
|
|
6203
|
+
return _context34.stop();
|
|
5758
6204
|
}
|
|
5759
|
-
},
|
|
6205
|
+
}, _callee31, this, [[6, 36, 39, 42]]);
|
|
5760
6206
|
}));
|
|
5761
|
-
function addProductsToOrderDraft(
|
|
6207
|
+
function addProductsToOrderDraft(_x37, _x38) {
|
|
5762
6208
|
return _addProductsToOrderDraft.apply(this, arguments);
|
|
5763
6209
|
}
|
|
5764
6210
|
return addProductsToOrderDraft;
|
|
@@ -5810,7 +6256,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5810
6256
|
}, {
|
|
5811
6257
|
key: "hasSameEntitlementMergePriceConfig",
|
|
5812
6258
|
value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
|
|
5813
|
-
var
|
|
6259
|
+
var _this42 = this;
|
|
5814
6260
|
var buildPriceConfig = function buildPriceConfig(product) {
|
|
5815
6261
|
var metadata = product.metadata || {};
|
|
5816
6262
|
var bundle = (product.product_bundle || []).map(function (item) {
|
|
@@ -5826,10 +6272,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5826
6272
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
5827
6273
|
});
|
|
5828
6274
|
return JSON.stringify({
|
|
5829
|
-
original_price:
|
|
5830
|
-
source_product_price:
|
|
5831
|
-
main_product_original_price:
|
|
5832
|
-
price_override:
|
|
6275
|
+
original_price: _this42.normalizeFingerprintMoney(product.original_price),
|
|
6276
|
+
source_product_price: _this42.normalizeFingerprintMoney(metadata.source_product_price),
|
|
6277
|
+
main_product_original_price: _this42.normalizeFingerprintMoney(metadata.main_product_original_price),
|
|
6278
|
+
price_override: _this42.normalizeFingerprintMoney(metadata.price_override),
|
|
5833
6279
|
is_manual_discount: Boolean(metadata.is_manual_discount),
|
|
5834
6280
|
bundle: bundle
|
|
5835
6281
|
});
|
|
@@ -5846,17 +6292,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5846
6292
|
}, {
|
|
5847
6293
|
key: "preservePersistedBundlePriceFields",
|
|
5848
6294
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
5849
|
-
var
|
|
6295
|
+
var _this43 = this;
|
|
5850
6296
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
5851
6297
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
5852
6298
|
var previousByIdentity = new Map();
|
|
5853
6299
|
previousBundles.forEach(function (bundle) {
|
|
5854
|
-
var identity =
|
|
6300
|
+
var identity = _this43.getBundleRuntimeIdentity(bundle);
|
|
5855
6301
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
5856
6302
|
});
|
|
5857
6303
|
return nextBundles.map(function (bundle, index) {
|
|
5858
6304
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
5859
|
-
var previous = previousByIdentity.get(
|
|
6305
|
+
var previous = previousByIdentity.get(_this43.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
5860
6306
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
5861
6307
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
5862
6308
|
cover: previous.cover
|
|
@@ -6128,21 +6574,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6128
6574
|
}, {
|
|
6129
6575
|
key: "updateOrderProduct",
|
|
6130
6576
|
value: function () {
|
|
6131
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6132
|
-
var
|
|
6133
|
-
return _regeneratorRuntime().wrap(function
|
|
6134
|
-
while (1) switch (
|
|
6577
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
6578
|
+
var _this44 = this;
|
|
6579
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context35) {
|
|
6580
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
6135
6581
|
case 0:
|
|
6136
|
-
return
|
|
6137
|
-
return
|
|
6582
|
+
return _context35.abrupt("return", this.queueCartCommand(function () {
|
|
6583
|
+
return _this44.updateOrderProductDraft(params);
|
|
6138
6584
|
}));
|
|
6139
6585
|
case 1:
|
|
6140
6586
|
case "end":
|
|
6141
|
-
return
|
|
6587
|
+
return _context35.stop();
|
|
6142
6588
|
}
|
|
6143
|
-
},
|
|
6589
|
+
}, _callee32, this);
|
|
6144
6590
|
}));
|
|
6145
|
-
function updateOrderProduct(
|
|
6591
|
+
function updateOrderProduct(_x39) {
|
|
6146
6592
|
return _updateOrderProduct.apply(this, arguments);
|
|
6147
6593
|
}
|
|
6148
6594
|
return updateOrderProduct;
|
|
@@ -6150,10 +6596,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6150
6596
|
}, {
|
|
6151
6597
|
key: "updateOrderProductDraft",
|
|
6152
6598
|
value: function () {
|
|
6153
|
-
var _updateOrderProductDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6599
|
+
var _updateOrderProductDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
6154
6600
|
var mutation, tempOrder, beforeCommit, reapplyWeighedDiscountProductUids, updatedProductUid, promotionPayload;
|
|
6155
|
-
return _regeneratorRuntime().wrap(function
|
|
6156
|
-
while (1) switch (
|
|
6601
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
6602
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
6157
6603
|
case 0:
|
|
6158
6604
|
mutation = this.beginCartMutation();
|
|
6159
6605
|
tempOrder = mutation.draft;
|
|
@@ -6162,24 +6608,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6162
6608
|
reapplyWeighedDiscountProductUids = [];
|
|
6163
6609
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
6164
6610
|
if (!mutation.commit) {
|
|
6165
|
-
|
|
6611
|
+
_context36.next = 10;
|
|
6166
6612
|
break;
|
|
6167
6613
|
}
|
|
6168
|
-
|
|
6614
|
+
_context36.next = 9;
|
|
6169
6615
|
return mutation.commit(beforeCommit);
|
|
6170
6616
|
case 9:
|
|
6171
|
-
tempOrder =
|
|
6617
|
+
tempOrder = _context36.sent;
|
|
6172
6618
|
case 10:
|
|
6173
|
-
|
|
6619
|
+
_context36.next = 12;
|
|
6174
6620
|
return this.evaluatePromotion();
|
|
6175
6621
|
case 12:
|
|
6176
|
-
promotionPayload =
|
|
6622
|
+
promotionPayload = _context36.sent;
|
|
6177
6623
|
this.applyDiscount({
|
|
6178
6624
|
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
6179
6625
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
6180
6626
|
});
|
|
6181
6627
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
6182
|
-
|
|
6628
|
+
_context36.next = 17;
|
|
6183
6629
|
return this.recalculateSummary({
|
|
6184
6630
|
createIfMissing: true
|
|
6185
6631
|
});
|
|
@@ -6189,14 +6635,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6189
6635
|
this.logInfo('updateOrderProduct success', {
|
|
6190
6636
|
params: params
|
|
6191
6637
|
});
|
|
6192
|
-
return
|
|
6638
|
+
return _context36.abrupt("return", tempOrder.products);
|
|
6193
6639
|
case 21:
|
|
6194
6640
|
case "end":
|
|
6195
|
-
return
|
|
6641
|
+
return _context36.stop();
|
|
6196
6642
|
}
|
|
6197
|
-
},
|
|
6643
|
+
}, _callee33, this);
|
|
6198
6644
|
}));
|
|
6199
|
-
function updateOrderProductDraft(
|
|
6645
|
+
function updateOrderProductDraft(_x40) {
|
|
6200
6646
|
return _updateOrderProductDraft.apply(this, arguments);
|
|
6201
6647
|
}
|
|
6202
6648
|
return updateOrderProductDraft;
|
|
@@ -6204,21 +6650,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6204
6650
|
}, {
|
|
6205
6651
|
key: "updateOrderProducts",
|
|
6206
6652
|
value: function () {
|
|
6207
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6208
|
-
var
|
|
6209
|
-
return _regeneratorRuntime().wrap(function
|
|
6210
|
-
while (1) switch (
|
|
6653
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(paramsList, options) {
|
|
6654
|
+
var _this45 = this;
|
|
6655
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
6656
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
6211
6657
|
case 0:
|
|
6212
|
-
return
|
|
6213
|
-
return
|
|
6214
|
-
}));
|
|
6658
|
+
return _context37.abrupt("return", this.queueCartCommand(function () {
|
|
6659
|
+
return _this45.updateOrderProductsDraft(paramsList, options);
|
|
6660
|
+
}, Boolean(options)));
|
|
6215
6661
|
case 1:
|
|
6216
6662
|
case "end":
|
|
6217
|
-
return
|
|
6663
|
+
return _context37.stop();
|
|
6218
6664
|
}
|
|
6219
|
-
},
|
|
6665
|
+
}, _callee34, this);
|
|
6220
6666
|
}));
|
|
6221
|
-
function updateOrderProducts(
|
|
6667
|
+
function updateOrderProducts(_x41, _x42) {
|
|
6222
6668
|
return _updateOrderProducts.apply(this, arguments);
|
|
6223
6669
|
}
|
|
6224
6670
|
return updateOrderProducts;
|
|
@@ -6226,27 +6672,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6226
6672
|
}, {
|
|
6227
6673
|
key: "updateOrderProductsDraft",
|
|
6228
6674
|
value: function () {
|
|
6229
|
-
var _updateOrderProductsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6230
|
-
var
|
|
6675
|
+
var _updateOrderProductsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(paramsList, options) {
|
|
6676
|
+
var _this46 = this;
|
|
6231
6677
|
var mutation, tempOrder, beforeCommit, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids;
|
|
6232
|
-
return _regeneratorRuntime().wrap(function
|
|
6233
|
-
while (1) switch (
|
|
6678
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context38) {
|
|
6679
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
6234
6680
|
case 0:
|
|
6681
|
+
if (!options) {
|
|
6682
|
+
_context38.next = 2;
|
|
6683
|
+
break;
|
|
6684
|
+
}
|
|
6685
|
+
return _context38.abrupt("return", this.updateOrderProductsGuarded(paramsList, options));
|
|
6686
|
+
case 2:
|
|
6235
6687
|
mutation = this.beginCartMutation();
|
|
6236
6688
|
tempOrder = mutation.draft;
|
|
6237
6689
|
if (paramsList.length) {
|
|
6238
|
-
|
|
6690
|
+
_context38.next = 6;
|
|
6239
6691
|
break;
|
|
6240
6692
|
}
|
|
6241
|
-
return
|
|
6242
|
-
case
|
|
6693
|
+
return _context38.abrupt("return", tempOrder.products);
|
|
6694
|
+
case 6:
|
|
6243
6695
|
beforeCommit = paramsList.some(function (params) {
|
|
6244
|
-
return
|
|
6696
|
+
return _this46.isRestrictedCartProductUpdate(tempOrder, params);
|
|
6245
6697
|
}) ? this.createCartIntentCommitGuard('update_product', mutation.current) : undefined;
|
|
6246
6698
|
beforeCommit === null || beforeCommit === void 0 || beforeCommit();
|
|
6247
6699
|
reapplyWeighedDiscountProductUids = [];
|
|
6248
6700
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
6249
|
-
var updatedProductUid =
|
|
6701
|
+
var updatedProductUid = _this46.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
6250
6702
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
6251
6703
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
6252
6704
|
acc.push(String(updatedProductUid));
|
|
@@ -6254,53 +6706,194 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6254
6706
|
return acc;
|
|
6255
6707
|
}, []);
|
|
6256
6708
|
if (!mutation.commit) {
|
|
6257
|
-
|
|
6709
|
+
_context38.next = 14;
|
|
6258
6710
|
break;
|
|
6259
6711
|
}
|
|
6260
|
-
|
|
6712
|
+
_context38.next = 13;
|
|
6261
6713
|
return mutation.commit(beforeCommit);
|
|
6262
|
-
case
|
|
6263
|
-
tempOrder =
|
|
6264
|
-
case
|
|
6265
|
-
|
|
6714
|
+
case 13:
|
|
6715
|
+
tempOrder = _context38.sent;
|
|
6716
|
+
case 14:
|
|
6717
|
+
_context38.next = 16;
|
|
6266
6718
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
6267
6719
|
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
6268
6720
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
6269
6721
|
});
|
|
6270
|
-
case
|
|
6722
|
+
case 16:
|
|
6271
6723
|
this.logInfo('updateOrderProduct success', {
|
|
6272
6724
|
paramsList: paramsList
|
|
6273
6725
|
});
|
|
6274
|
-
return
|
|
6275
|
-
case
|
|
6726
|
+
return _context38.abrupt("return", tempOrder.products);
|
|
6727
|
+
case 18:
|
|
6276
6728
|
case "end":
|
|
6277
|
-
return
|
|
6729
|
+
return _context38.stop();
|
|
6278
6730
|
}
|
|
6279
|
-
},
|
|
6731
|
+
}, _callee35, this);
|
|
6280
6732
|
}));
|
|
6281
|
-
function updateOrderProductsDraft(
|
|
6733
|
+
function updateOrderProductsDraft(_x43, _x44) {
|
|
6282
6734
|
return _updateOrderProductsDraft.apply(this, arguments);
|
|
6283
6735
|
}
|
|
6284
6736
|
return updateOrderProductsDraft;
|
|
6285
6737
|
}()
|
|
6738
|
+
}, {
|
|
6739
|
+
key: "updateOrderProductsGuarded",
|
|
6740
|
+
value: function () {
|
|
6741
|
+
var _updateOrderProductsGuarded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(paramsList, options) {
|
|
6742
|
+
var _options$beforeApply,
|
|
6743
|
+
_this47 = this,
|
|
6744
|
+
_mutation$commit2;
|
|
6745
|
+
var stale, mutation, live, identity, isCurrentOrder, beforeCommit, publishedFields, guardedFields, readFields, baseline, draft, seen, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids, _iterator27, _step27, _loop4;
|
|
6746
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context40) {
|
|
6747
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
6748
|
+
case 0:
|
|
6749
|
+
stale = function stale() {
|
|
6750
|
+
return Object.assign(new Error('Order product update interrupted by an order change'), {
|
|
6751
|
+
code: 'AVAILABILITY_SELECTION_STALE'
|
|
6752
|
+
});
|
|
6753
|
+
};
|
|
6754
|
+
(_options$beforeApply = options.beforeApply) === null || _options$beforeApply === void 0 || _options$beforeApply.call(options);
|
|
6755
|
+
if (!(options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
6756
|
+
_context40.next = 4;
|
|
6757
|
+
break;
|
|
6758
|
+
}
|
|
6759
|
+
throw stale();
|
|
6760
|
+
case 4:
|
|
6761
|
+
mutation = this.beginCartMutation({
|
|
6762
|
+
forceDraft: true
|
|
6763
|
+
});
|
|
6764
|
+
live = mutation.current;
|
|
6765
|
+
if (paramsList.length) {
|
|
6766
|
+
_context40.next = 8;
|
|
6767
|
+
break;
|
|
6768
|
+
}
|
|
6769
|
+
return _context40.abrupt("return", live.products);
|
|
6770
|
+
case 8:
|
|
6771
|
+
identity = [live.order_id, live.external_sale_number];
|
|
6772
|
+
isCurrentOrder = function isCurrentOrder() {
|
|
6773
|
+
var _options$isCurrentOrd, _options$isCurrentOrd2;
|
|
6774
|
+
return _this47.store.tempOrder === live && live.order_id === identity[0] && live.external_sale_number === identity[1] && ((_options$isCurrentOrd = (_options$isCurrentOrd2 = options.isCurrentOrder) === null || _options$isCurrentOrd2 === void 0 ? void 0 : _options$isCurrentOrd2.call(options)) !== null && _options$isCurrentOrd !== void 0 ? _options$isCurrentOrd : true);
|
|
6775
|
+
};
|
|
6776
|
+
beforeCommit = this.createCartIntentCommitGuard('update_product', live);
|
|
6777
|
+
publishedFields = ['products', 'bookings', 'notes', '_extend', 'metadata', 'holder', 'holder_relations'];
|
|
6778
|
+
guardedFields = [].concat(publishedFields, ['customer_id', 'discount_list', 'shop_discount', 'payments']);
|
|
6779
|
+
readFields = function readFields(order, fields) {
|
|
6780
|
+
return Object.fromEntries(fields.map(function (key) {
|
|
6781
|
+
return [key, order[key]];
|
|
6782
|
+
}));
|
|
6783
|
+
};
|
|
6784
|
+
baseline = cloneDeep(readFields(live, guardedFields));
|
|
6785
|
+
draft = mutation.draft;
|
|
6786
|
+
seen = new Set();
|
|
6787
|
+
reapplyWeighedDiscountProductUids = [];
|
|
6788
|
+
reapplyBookingDiscountProductUids = [];
|
|
6789
|
+
_iterator27 = _createForOfIteratorHelper(paramsList);
|
|
6790
|
+
_context40.prev = 20;
|
|
6791
|
+
_loop4 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop4() {
|
|
6792
|
+
var params, uid, matches, target, updatedUid;
|
|
6793
|
+
return _regeneratorRuntime().wrap(function _loop4$(_context39) {
|
|
6794
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
6795
|
+
case 0:
|
|
6796
|
+
params = _step27.value;
|
|
6797
|
+
uid = String(params.unique_identification_number || '');
|
|
6798
|
+
matches = draft.products.filter(function (line) {
|
|
6799
|
+
var _line$metadata8;
|
|
6800
|
+
return String(((_line$metadata8 = line.metadata) === null || _line$metadata8 === void 0 ? void 0 : _line$metadata8.unique_identification_number) || line.unique_identification_number || '') === uid;
|
|
6801
|
+
});
|
|
6802
|
+
target = matches[0]; // Guarded re-quotation must identify the exact row; never fall back to another same-SKU line.
|
|
6803
|
+
if (!(!uid || seen.has(uid) || matches.length !== 1 || !target || target.product_id !== params.product_id || Number(target.product_variant_id || 0) !== Number(params.product_variant_id || 0))) {
|
|
6804
|
+
_context39.next = 6;
|
|
6805
|
+
break;
|
|
6806
|
+
}
|
|
6807
|
+
throw stale();
|
|
6808
|
+
case 6:
|
|
6809
|
+
seen.add(uid);
|
|
6810
|
+
updatedUid = _this47.applyOrderProductUpdateToTempOrder(draft, cloneDeep(params), reapplyWeighedDiscountProductUids);
|
|
6811
|
+
if (params.allow_booking_discount_reapply && updatedUid) reapplyBookingDiscountProductUids.push(updatedUid);
|
|
6812
|
+
case 9:
|
|
6813
|
+
case "end":
|
|
6814
|
+
return _context39.stop();
|
|
6815
|
+
}
|
|
6816
|
+
}, _loop4);
|
|
6817
|
+
});
|
|
6818
|
+
_iterator27.s();
|
|
6819
|
+
case 23:
|
|
6820
|
+
if ((_step27 = _iterator27.n()).done) {
|
|
6821
|
+
_context40.next = 27;
|
|
6822
|
+
break;
|
|
6823
|
+
}
|
|
6824
|
+
return _context40.delegateYield(_loop4(), "t0", 25);
|
|
6825
|
+
case 25:
|
|
6826
|
+
_context40.next = 23;
|
|
6827
|
+
break;
|
|
6828
|
+
case 27:
|
|
6829
|
+
_context40.next = 32;
|
|
6830
|
+
break;
|
|
6831
|
+
case 29:
|
|
6832
|
+
_context40.prev = 29;
|
|
6833
|
+
_context40.t1 = _context40["catch"](20);
|
|
6834
|
+
_iterator27.e(_context40.t1);
|
|
6835
|
+
case 32:
|
|
6836
|
+
_context40.prev = 32;
|
|
6837
|
+
_iterator27.f();
|
|
6838
|
+
return _context40.finish(32);
|
|
6839
|
+
case 35:
|
|
6840
|
+
_context40.next = 37;
|
|
6841
|
+
return (_mutation$commit2 = mutation.commit) === null || _mutation$commit2 === void 0 ? void 0 : _mutation$commit2.call(mutation, function () {
|
|
6842
|
+
var _options$beforeApply2;
|
|
6843
|
+
(_options$beforeApply2 = options.beforeApply) === null || _options$beforeApply2 === void 0 || _options$beforeApply2.call(options);
|
|
6844
|
+
beforeCommit();
|
|
6845
|
+
if (!isCurrentOrder() || !isEqual(readFields(live, guardedFields), baseline)) throw stale();
|
|
6846
|
+
});
|
|
6847
|
+
case 37:
|
|
6848
|
+
_context40.prev = 37;
|
|
6849
|
+
if (isCurrentOrder()) this.persistTempOrder();
|
|
6850
|
+
_context40.next = 41;
|
|
6851
|
+
return this.finalizeAfterProductsMutation(live, {
|
|
6852
|
+
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
6853
|
+
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids,
|
|
6854
|
+
isCurrentOrder: isCurrentOrder
|
|
6855
|
+
});
|
|
6856
|
+
case 41:
|
|
6857
|
+
_context40.next = 46;
|
|
6858
|
+
break;
|
|
6859
|
+
case 43:
|
|
6860
|
+
_context40.prev = 43;
|
|
6861
|
+
_context40.t2 = _context40["catch"](37);
|
|
6862
|
+
this.logWarning('Order product update committed; finalization failed', {
|
|
6863
|
+
committed: true,
|
|
6864
|
+
error: _context40.t2 instanceof Error ? _context40.t2.message : String(_context40.t2)
|
|
6865
|
+
});
|
|
6866
|
+
case 46:
|
|
6867
|
+
return _context40.abrupt("return", live.products);
|
|
6868
|
+
case 47:
|
|
6869
|
+
case "end":
|
|
6870
|
+
return _context40.stop();
|
|
6871
|
+
}
|
|
6872
|
+
}, _callee36, this, [[20, 29, 32, 35], [37, 43]]);
|
|
6873
|
+
}));
|
|
6874
|
+
function updateOrderProductsGuarded(_x45, _x46) {
|
|
6875
|
+
return _updateOrderProductsGuarded.apply(this, arguments);
|
|
6876
|
+
}
|
|
6877
|
+
return updateOrderProductsGuarded;
|
|
6878
|
+
}()
|
|
6286
6879
|
}, {
|
|
6287
6880
|
key: "updateOrderProductQuantity",
|
|
6288
6881
|
value: function () {
|
|
6289
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6290
|
-
var
|
|
6291
|
-
return _regeneratorRuntime().wrap(function
|
|
6292
|
-
while (1) switch (
|
|
6882
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
6883
|
+
var _this48 = this;
|
|
6884
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context41) {
|
|
6885
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
6293
6886
|
case 0:
|
|
6294
|
-
return
|
|
6295
|
-
return
|
|
6887
|
+
return _context41.abrupt("return", this.queueCartCommand(function () {
|
|
6888
|
+
return _this48.updateOrderProductQuantityDraft(params);
|
|
6296
6889
|
}));
|
|
6297
6890
|
case 1:
|
|
6298
6891
|
case "end":
|
|
6299
|
-
return
|
|
6892
|
+
return _context41.stop();
|
|
6300
6893
|
}
|
|
6301
|
-
},
|
|
6894
|
+
}, _callee37, this);
|
|
6302
6895
|
}));
|
|
6303
|
-
function updateOrderProductQuantity(
|
|
6896
|
+
function updateOrderProductQuantity(_x47) {
|
|
6304
6897
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
6305
6898
|
}
|
|
6306
6899
|
return updateOrderProductQuantity;
|
|
@@ -6308,11 +6901,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6308
6901
|
}, {
|
|
6309
6902
|
key: "updateOrderProductQuantityDraft",
|
|
6310
6903
|
value: function () {
|
|
6311
|
-
var _updateOrderProductQuantityDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6904
|
+
var _updateOrderProductQuantityDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
|
|
6312
6905
|
var _targetProduct$metada22;
|
|
6313
6906
|
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, mutation, tempOrder, identityLookup, productIndex, targetUid, targetProduct, isPersistedOrderLine, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance, beforeCommit, isVirtualSettlement, promotionPayload;
|
|
6314
|
-
return _regeneratorRuntime().wrap(function
|
|
6315
|
-
while (1) switch (
|
|
6907
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context42) {
|
|
6908
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
6316
6909
|
case 0:
|
|
6317
6910
|
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;
|
|
6318
6911
|
mutation = this.beginCartMutation();
|
|
@@ -6343,7 +6936,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6343
6936
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
6344
6937
|
}
|
|
6345
6938
|
if (!(productIndex === -1)) {
|
|
6346
|
-
|
|
6939
|
+
_context42.next = 14;
|
|
6347
6940
|
break;
|
|
6348
6941
|
}
|
|
6349
6942
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -6359,7 +6952,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6359
6952
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
6360
6953
|
settlementSnapshot = getSelectedSettlementSnapshot(normalizedProduct);
|
|
6361
6954
|
if (!(this.isMultiCurrencySettlementEnabled() && (settlementSnapshot === null || settlementSnapshot === void 0 ? void 0 : settlementSnapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1)) {
|
|
6362
|
-
|
|
6955
|
+
_context42.next = 28;
|
|
6363
6956
|
break;
|
|
6364
6957
|
}
|
|
6365
6958
|
currencyProductId = Number(settlementSnapshot.currency_product_id);
|
|
@@ -6367,7 +6960,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6367
6960
|
return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
|
|
6368
6961
|
});
|
|
6369
6962
|
if (asset) {
|
|
6370
|
-
|
|
6963
|
+
_context42.next = 24;
|
|
6371
6964
|
break;
|
|
6372
6965
|
}
|
|
6373
6966
|
throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
|
|
@@ -6379,7 +6972,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6379
6972
|
}, new Decimal(0));
|
|
6380
6973
|
balance = new Decimal(asset.balance || 0);
|
|
6381
6974
|
if (!balance.lt(requiredAmount)) {
|
|
6382
|
-
|
|
6975
|
+
_context42.next = 28;
|
|
6383
6976
|
break;
|
|
6384
6977
|
}
|
|
6385
6978
|
throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
@@ -6388,35 +6981,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6388
6981
|
beforeCommit === null || beforeCommit === void 0 || beforeCommit();
|
|
6389
6982
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
6390
6983
|
if (!mutation.commit) {
|
|
6391
|
-
|
|
6984
|
+
_context42.next = 35;
|
|
6392
6985
|
break;
|
|
6393
6986
|
}
|
|
6394
|
-
|
|
6987
|
+
_context42.next = 34;
|
|
6395
6988
|
return mutation.commit(beforeCommit);
|
|
6396
6989
|
case 34:
|
|
6397
|
-
tempOrder =
|
|
6990
|
+
tempOrder = _context42.sent;
|
|
6398
6991
|
case 35:
|
|
6399
6992
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
6400
6993
|
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
6401
6994
|
if (isVirtualSettlement) {
|
|
6402
|
-
|
|
6995
|
+
_context42.next = 43;
|
|
6403
6996
|
break;
|
|
6404
6997
|
}
|
|
6405
|
-
|
|
6998
|
+
_context42.next = 40;
|
|
6406
6999
|
return this.evaluatePromotion();
|
|
6407
7000
|
case 40:
|
|
6408
|
-
|
|
6409
|
-
|
|
7001
|
+
_context42.t0 = _context42.sent;
|
|
7002
|
+
_context42.next = 44;
|
|
6410
7003
|
break;
|
|
6411
7004
|
case 43:
|
|
6412
|
-
|
|
7005
|
+
_context42.t0 = null;
|
|
6413
7006
|
case 44:
|
|
6414
|
-
promotionPayload =
|
|
7007
|
+
promotionPayload = _context42.t0;
|
|
6415
7008
|
if (!isVirtualSettlement) {
|
|
6416
7009
|
this.applyDiscount();
|
|
6417
7010
|
}
|
|
6418
7011
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
6419
|
-
|
|
7012
|
+
_context42.next = 49;
|
|
6420
7013
|
return this.recalculateSummary({
|
|
6421
7014
|
createIfMissing: true
|
|
6422
7015
|
});
|
|
@@ -6426,14 +7019,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6426
7019
|
this.logInfo('updateOrderProductQuantity success', {
|
|
6427
7020
|
params: params
|
|
6428
7021
|
});
|
|
6429
|
-
return
|
|
7022
|
+
return _context42.abrupt("return", tempOrder.products);
|
|
6430
7023
|
case 53:
|
|
6431
7024
|
case "end":
|
|
6432
|
-
return
|
|
7025
|
+
return _context42.stop();
|
|
6433
7026
|
}
|
|
6434
|
-
},
|
|
7027
|
+
}, _callee38, this);
|
|
6435
7028
|
}));
|
|
6436
|
-
function updateOrderProductQuantityDraft(
|
|
7029
|
+
function updateOrderProductQuantityDraft(_x48) {
|
|
6437
7030
|
return _updateOrderProductQuantityDraft.apply(this, arguments);
|
|
6438
7031
|
}
|
|
6439
7032
|
return updateOrderProductQuantityDraft;
|
|
@@ -6474,35 +7067,59 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6474
7067
|
}, {
|
|
6475
7068
|
key: "finalizeAfterProductsMutation",
|
|
6476
7069
|
value: (function () {
|
|
6477
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6478
|
-
var promotionPayload;
|
|
6479
|
-
return _regeneratorRuntime().wrap(function
|
|
6480
|
-
while (1) switch (
|
|
7070
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(tempOrder, options) {
|
|
7071
|
+
var isCurrentOrder, promotionPayload, summary;
|
|
7072
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context43) {
|
|
7073
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
6481
7074
|
case 0:
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
7075
|
+
isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
|
|
7076
|
+
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
7077
|
+
_context43.next = 3;
|
|
7078
|
+
break;
|
|
7079
|
+
}
|
|
7080
|
+
return _context43.abrupt("return");
|
|
6485
7081
|
case 3:
|
|
6486
|
-
|
|
7082
|
+
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
7083
|
+
_context43.next = 6;
|
|
7084
|
+
return this.evaluatePromotion(isCurrentOrder ? {
|
|
7085
|
+
isCurrentOrder: isCurrentOrder
|
|
7086
|
+
} : undefined);
|
|
7087
|
+
case 6:
|
|
7088
|
+
promotionPayload = _context43.sent;
|
|
7089
|
+
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
7090
|
+
_context43.next = 9;
|
|
7091
|
+
break;
|
|
7092
|
+
}
|
|
7093
|
+
return _context43.abrupt("return");
|
|
7094
|
+
case 9:
|
|
6487
7095
|
this.applyDiscount({
|
|
6488
7096
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids,
|
|
6489
7097
|
reapplyWeighedDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyWeighedDiscountProductUids
|
|
6490
7098
|
});
|
|
6491
7099
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
6492
|
-
|
|
6493
|
-
return this.recalculateSummary({
|
|
7100
|
+
_context43.next = 13;
|
|
7101
|
+
return this.recalculateSummary(_objectSpread({
|
|
6494
7102
|
createIfMissing: true
|
|
6495
|
-
}
|
|
6496
|
-
|
|
7103
|
+
}, isCurrentOrder ? {
|
|
7104
|
+
isCurrentOrder: isCurrentOrder
|
|
7105
|
+
} : {}));
|
|
7106
|
+
case 13:
|
|
7107
|
+
summary = _context43.sent;
|
|
7108
|
+
if (!(isCurrentOrder && (!isCurrentOrder() || !summary))) {
|
|
7109
|
+
_context43.next = 16;
|
|
7110
|
+
break;
|
|
7111
|
+
}
|
|
7112
|
+
return _context43.abrupt("return");
|
|
7113
|
+
case 16:
|
|
6497
7114
|
this.persistTempOrder();
|
|
6498
7115
|
this.emitPromotionApplied(promotionPayload);
|
|
6499
|
-
case
|
|
7116
|
+
case 18:
|
|
6500
7117
|
case "end":
|
|
6501
|
-
return
|
|
7118
|
+
return _context43.stop();
|
|
6502
7119
|
}
|
|
6503
|
-
},
|
|
7120
|
+
}, _callee39, this);
|
|
6504
7121
|
}));
|
|
6505
|
-
function finalizeAfterProductsMutation(
|
|
7122
|
+
function finalizeAfterProductsMutation(_x49, _x50) {
|
|
6506
7123
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
6507
7124
|
}
|
|
6508
7125
|
return finalizeAfterProductsMutation;
|
|
@@ -6517,21 +7134,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6517
7134
|
}, {
|
|
6518
7135
|
key: "removeProductsFromOrder",
|
|
6519
7136
|
value: (function () {
|
|
6520
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6521
|
-
var
|
|
6522
|
-
return _regeneratorRuntime().wrap(function
|
|
6523
|
-
while (1) switch (
|
|
7137
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(identities, options) {
|
|
7138
|
+
var _this49 = this;
|
|
7139
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context44) {
|
|
7140
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
6524
7141
|
case 0:
|
|
6525
|
-
return
|
|
6526
|
-
return
|
|
6527
|
-
}));
|
|
7142
|
+
return _context44.abrupt("return", this.queueCartCommand(function () {
|
|
7143
|
+
return _this49.removeProductsFromOrderDraft(identities, options);
|
|
7144
|
+
}, Boolean(options === null || options === void 0 ? void 0 : options.isCurrentOrder)));
|
|
6528
7145
|
case 1:
|
|
6529
7146
|
case "end":
|
|
6530
|
-
return
|
|
7147
|
+
return _context44.stop();
|
|
6531
7148
|
}
|
|
6532
|
-
},
|
|
7149
|
+
}, _callee40, this);
|
|
6533
7150
|
}));
|
|
6534
|
-
function removeProductsFromOrder(
|
|
7151
|
+
function removeProductsFromOrder(_x51, _x52) {
|
|
6535
7152
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
6536
7153
|
}
|
|
6537
7154
|
return removeProductsFromOrder;
|
|
@@ -6539,20 +7156,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6539
7156
|
}, {
|
|
6540
7157
|
key: "removeProductsFromOrderDraft",
|
|
6541
7158
|
value: function () {
|
|
6542
|
-
var _removeProductsFromOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6543
|
-
var
|
|
6544
|
-
var mutation, tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove,
|
|
6545
|
-
return _regeneratorRuntime().wrap(function
|
|
6546
|
-
while (1) switch (
|
|
7159
|
+
var _removeProductsFromOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(identities, options) {
|
|
7160
|
+
var _this50 = this;
|
|
7161
|
+
var _this$store$tempOrder10, mutation, tempOrder, identity, isCurrentOrder, beforeCommit, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator28, _step28, _loop5, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
7162
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context46) {
|
|
7163
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
6547
7164
|
case 0:
|
|
6548
|
-
|
|
7165
|
+
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
7166
|
+
_context46.next = 2;
|
|
7167
|
+
break;
|
|
7168
|
+
}
|
|
7169
|
+
return _context46.abrupt("return", ((_this$store$tempOrder10 = this.store.tempOrder) === null || _this$store$tempOrder10 === void 0 ? void 0 : _this$store$tempOrder10.products) || []);
|
|
7170
|
+
case 2:
|
|
7171
|
+
mutation = this.beginCartMutation({
|
|
7172
|
+
forceDraft: Boolean(options === null || options === void 0 ? void 0 : options.isCurrentOrder)
|
|
7173
|
+
});
|
|
6549
7174
|
tempOrder = mutation.draft;
|
|
7175
|
+
identity = [mutation.current.order_id, mutation.current.external_sale_number];
|
|
7176
|
+
isCurrentOrder = function isCurrentOrder() {
|
|
7177
|
+
var _options$isCurrentOrd3, _options$isCurrentOrd4;
|
|
7178
|
+
return _this50.store.tempOrder === mutation.current && mutation.current.order_id === identity[0] && mutation.current.external_sale_number === identity[1] && ((_options$isCurrentOrd3 = options === null || options === void 0 || (_options$isCurrentOrd4 = options.isCurrentOrder) === null || _options$isCurrentOrd4 === void 0 ? void 0 : _options$isCurrentOrd4.call(options)) !== null && _options$isCurrentOrd3 !== void 0 ? _options$isCurrentOrd3 : true);
|
|
7179
|
+
};
|
|
7180
|
+
beforeCommit = options !== null && options !== void 0 && options.isCurrentOrder ? function () {
|
|
7181
|
+
if (!isCurrentOrder()) throw Object.assign(new Error('Order product removal interrupted by an order change'), {
|
|
7182
|
+
code: 'AVAILABILITY_SELECTION_STALE'
|
|
7183
|
+
});
|
|
7184
|
+
} : undefined;
|
|
6550
7185
|
if (identities.length) {
|
|
6551
|
-
|
|
7186
|
+
_context46.next = 9;
|
|
6552
7187
|
break;
|
|
6553
7188
|
}
|
|
6554
|
-
return
|
|
6555
|
-
case
|
|
7189
|
+
return _context46.abrupt("return", tempOrder.products);
|
|
7190
|
+
case 9:
|
|
6556
7191
|
// 商品删除会同步删除以商品行为主关系的 Notes;快照不完整时禁止产生孤儿 Relation。
|
|
6557
7192
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
6558
7193
|
this.repairDuplicateProductLineIdentities(tempOrder);
|
|
@@ -6583,30 +7218,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6583
7218
|
this.removeLinkedBookingsForProduct(tempOrder, product);
|
|
6584
7219
|
}
|
|
6585
7220
|
linkedBookingUidsToRemove = new Set();
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
7221
|
+
_iterator28 = _createForOfIteratorHelper(matchedProducts);
|
|
7222
|
+
_context46.prev = 22;
|
|
7223
|
+
_loop5 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop5() {
|
|
6589
7224
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
6590
7225
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
6591
|
-
return _regeneratorRuntime().wrap(function
|
|
6592
|
-
while (1) switch (
|
|
7226
|
+
return _regeneratorRuntime().wrap(function _loop5$(_context45) {
|
|
7227
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
6593
7228
|
case 0:
|
|
6594
|
-
product =
|
|
7229
|
+
product = _step28.value;
|
|
6595
7230
|
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);
|
|
6596
7231
|
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);
|
|
6597
7232
|
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;
|
|
6598
7233
|
if (!isAddTimeProduct) {
|
|
6599
|
-
|
|
7234
|
+
_context45.next = 6;
|
|
6600
7235
|
break;
|
|
6601
7236
|
}
|
|
6602
|
-
return
|
|
7237
|
+
return _context45.abrupt("return", 1);
|
|
6603
7238
|
case 6:
|
|
6604
7239
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
6605
7240
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
6606
7241
|
}
|
|
6607
7242
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
6608
7243
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
6609
|
-
var bookingUid =
|
|
7244
|
+
var bookingUid = _this50.getBookingUniqueIdentificationNumber(booking);
|
|
6610
7245
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
6611
7246
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
6612
7247
|
}
|
|
@@ -6614,44 +7249,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6614
7249
|
}
|
|
6615
7250
|
case 8:
|
|
6616
7251
|
case "end":
|
|
6617
|
-
return
|
|
7252
|
+
return _context45.stop();
|
|
6618
7253
|
}
|
|
6619
|
-
},
|
|
7254
|
+
}, _loop5);
|
|
6620
7255
|
});
|
|
6621
|
-
|
|
6622
|
-
case
|
|
6623
|
-
if ((
|
|
6624
|
-
|
|
7256
|
+
_iterator28.s();
|
|
7257
|
+
case 25:
|
|
7258
|
+
if ((_step28 = _iterator28.n()).done) {
|
|
7259
|
+
_context46.next = 31;
|
|
6625
7260
|
break;
|
|
6626
7261
|
}
|
|
6627
|
-
return
|
|
6628
|
-
case
|
|
6629
|
-
if (!
|
|
6630
|
-
|
|
7262
|
+
return _context46.delegateYield(_loop5(), "t0", 27);
|
|
7263
|
+
case 27:
|
|
7264
|
+
if (!_context46.t0) {
|
|
7265
|
+
_context46.next = 29;
|
|
6631
7266
|
break;
|
|
6632
7267
|
}
|
|
6633
|
-
return
|
|
6634
|
-
case
|
|
6635
|
-
|
|
6636
|
-
break;
|
|
6637
|
-
case 26:
|
|
6638
|
-
_context41.next = 31;
|
|
7268
|
+
return _context46.abrupt("continue", 29);
|
|
7269
|
+
case 29:
|
|
7270
|
+
_context46.next = 25;
|
|
6639
7271
|
break;
|
|
6640
|
-
case 28:
|
|
6641
|
-
_context41.prev = 28;
|
|
6642
|
-
_context41.t1 = _context41["catch"](17);
|
|
6643
|
-
_iterator23.e(_context41.t1);
|
|
6644
7272
|
case 31:
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
7273
|
+
_context46.next = 36;
|
|
7274
|
+
break;
|
|
7275
|
+
case 33:
|
|
7276
|
+
_context46.prev = 33;
|
|
7277
|
+
_context46.t1 = _context46["catch"](22);
|
|
7278
|
+
_iterator28.e(_context46.t1);
|
|
7279
|
+
case 36:
|
|
7280
|
+
_context46.prev = 36;
|
|
7281
|
+
_iterator28.f();
|
|
7282
|
+
return _context46.finish(36);
|
|
7283
|
+
case 39:
|
|
6649
7284
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
6650
7285
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
6651
7286
|
tempOrder.products = (tempOrder.products || []).filter(function (line) {
|
|
6652
|
-
var _line$
|
|
6653
|
-
var lineBookingUid = (line === null || line === void 0 || (_line$
|
|
6654
|
-
var isAddTimeProduct = (line === null || line === void 0 || (_line$
|
|
7287
|
+
var _line$metadata9, _line$metadata10, _line$metadata11;
|
|
7288
|
+
var lineBookingUid = (line === null || line === void 0 || (_line$metadata9 = line.metadata) === null || _line$metadata9 === void 0 ? void 0 : _line$metadata9.booking_uid) || (line === null || line === void 0 ? void 0 : line.booking_uid);
|
|
7289
|
+
var isAddTimeProduct = (line === null || line === void 0 || (_line$metadata10 = line.metadata) === null || _line$metadata10 === void 0 ? void 0 : _line$metadata10.product_add_schedule_time) !== undefined && (line === null || line === void 0 || (_line$metadata11 = line.metadata) === null || _line$metadata11 === void 0 ? void 0 : _line$metadata11.product_add_schedule_time) !== null;
|
|
6655
7290
|
return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
|
|
6656
7291
|
});
|
|
6657
7292
|
}
|
|
@@ -6676,28 +7311,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6676
7311
|
}));
|
|
6677
7312
|
this.removeSalesNotesForMissingProductLines(tempOrder);
|
|
6678
7313
|
if (!mutation.commit) {
|
|
6679
|
-
|
|
7314
|
+
_context46.next = 47;
|
|
6680
7315
|
break;
|
|
6681
7316
|
}
|
|
6682
|
-
|
|
6683
|
-
return mutation.commit();
|
|
6684
|
-
case
|
|
6685
|
-
tempOrder =
|
|
6686
|
-
case
|
|
6687
|
-
|
|
6688
|
-
return this.finalizeAfterProductsMutation(tempOrder
|
|
6689
|
-
|
|
7317
|
+
_context46.next = 46;
|
|
7318
|
+
return mutation.commit(beforeCommit);
|
|
7319
|
+
case 46:
|
|
7320
|
+
tempOrder = _context46.sent;
|
|
7321
|
+
case 47:
|
|
7322
|
+
_context46.next = 49;
|
|
7323
|
+
return this.finalizeAfterProductsMutation(tempOrder, options !== null && options !== void 0 && options.isCurrentOrder ? {
|
|
7324
|
+
isCurrentOrder: isCurrentOrder
|
|
7325
|
+
} : undefined);
|
|
7326
|
+
case 49:
|
|
6690
7327
|
this.logInfo('removeProductsFromOrder success', {
|
|
6691
7328
|
identities: identities
|
|
6692
7329
|
});
|
|
6693
|
-
return
|
|
6694
|
-
case
|
|
7330
|
+
return _context46.abrupt("return", tempOrder.products);
|
|
7331
|
+
case 51:
|
|
6695
7332
|
case "end":
|
|
6696
|
-
return
|
|
7333
|
+
return _context46.stop();
|
|
6697
7334
|
}
|
|
6698
|
-
},
|
|
7335
|
+
}, _callee41, this, [[22, 33, 36, 39]]);
|
|
6699
7336
|
}));
|
|
6700
|
-
function removeProductsFromOrderDraft(
|
|
7337
|
+
function removeProductsFromOrderDraft(_x53, _x54) {
|
|
6701
7338
|
return _removeProductsFromOrderDraft.apply(this, arguments);
|
|
6702
7339
|
}
|
|
6703
7340
|
return removeProductsFromOrderDraft;
|
|
@@ -6705,18 +7342,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6705
7342
|
}, {
|
|
6706
7343
|
key: "removeProductFromOrder",
|
|
6707
7344
|
value: function () {
|
|
6708
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6709
|
-
return _regeneratorRuntime().wrap(function
|
|
6710
|
-
while (1) switch (
|
|
7345
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(identity, options) {
|
|
7346
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context47) {
|
|
7347
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
6711
7348
|
case 0:
|
|
6712
|
-
return
|
|
7349
|
+
return _context47.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
6713
7350
|
case 1:
|
|
6714
7351
|
case "end":
|
|
6715
|
-
return
|
|
7352
|
+
return _context47.stop();
|
|
6716
7353
|
}
|
|
6717
|
-
},
|
|
7354
|
+
}, _callee42, this);
|
|
6718
7355
|
}));
|
|
6719
|
-
function removeProductFromOrder(
|
|
7356
|
+
function removeProductFromOrder(_x55, _x56) {
|
|
6720
7357
|
return _removeProductFromOrder.apply(this, arguments);
|
|
6721
7358
|
}
|
|
6722
7359
|
return removeProductFromOrder;
|
|
@@ -6728,19 +7365,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6728
7365
|
}, {
|
|
6729
7366
|
key: "clearOrderCartLines",
|
|
6730
7367
|
value: (function () {
|
|
6731
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6732
|
-
var
|
|
6733
|
-
return _regeneratorRuntime().wrap(function
|
|
6734
|
-
while (1) switch (
|
|
7368
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
|
|
7369
|
+
var _this51 = this;
|
|
7370
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context48) {
|
|
7371
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
6735
7372
|
case 0:
|
|
6736
|
-
return
|
|
6737
|
-
return
|
|
7373
|
+
return _context48.abrupt("return", this.queueCartCommand(function () {
|
|
7374
|
+
return _this51.clearOrderCartLinesDraft();
|
|
6738
7375
|
}));
|
|
6739
7376
|
case 1:
|
|
6740
7377
|
case "end":
|
|
6741
|
-
return
|
|
7378
|
+
return _context48.stop();
|
|
6742
7379
|
}
|
|
6743
|
-
},
|
|
7380
|
+
}, _callee43, this);
|
|
6744
7381
|
}));
|
|
6745
7382
|
function clearOrderCartLines() {
|
|
6746
7383
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -6750,10 +7387,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6750
7387
|
}, {
|
|
6751
7388
|
key: "clearOrderCartLinesDraft",
|
|
6752
7389
|
value: function () {
|
|
6753
|
-
var _clearOrderCartLinesDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7390
|
+
var _clearOrderCartLinesDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
|
|
6754
7391
|
var mutation, tempOrder, promotionPayload;
|
|
6755
|
-
return _regeneratorRuntime().wrap(function
|
|
6756
|
-
while (1) switch (
|
|
7392
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context49) {
|
|
7393
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
6757
7394
|
case 0:
|
|
6758
7395
|
mutation = this.beginCartMutation();
|
|
6759
7396
|
tempOrder = mutation.draft;
|
|
@@ -6770,21 +7407,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6770
7407
|
});
|
|
6771
7408
|
}
|
|
6772
7409
|
if (!mutation.commit) {
|
|
6773
|
-
|
|
7410
|
+
_context49.next = 14;
|
|
6774
7411
|
break;
|
|
6775
7412
|
}
|
|
6776
|
-
|
|
7413
|
+
_context49.next = 13;
|
|
6777
7414
|
return mutation.commit();
|
|
6778
7415
|
case 13:
|
|
6779
|
-
tempOrder =
|
|
7416
|
+
tempOrder = _context49.sent;
|
|
6780
7417
|
case 14:
|
|
6781
|
-
|
|
7418
|
+
_context49.next = 16;
|
|
6782
7419
|
return this.evaluatePromotion();
|
|
6783
7420
|
case 16:
|
|
6784
|
-
promotionPayload =
|
|
7421
|
+
promotionPayload = _context49.sent;
|
|
6785
7422
|
this.applyDiscount();
|
|
6786
7423
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
6787
|
-
|
|
7424
|
+
_context49.next = 21;
|
|
6788
7425
|
return this.recalculateSummary({
|
|
6789
7426
|
createIfMissing: true
|
|
6790
7427
|
});
|
|
@@ -6792,12 +7429,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6792
7429
|
this.persistTempOrder();
|
|
6793
7430
|
this.emitPromotionApplied(promotionPayload);
|
|
6794
7431
|
this.logInfo('clearOrderCartLines success', {});
|
|
6795
|
-
return
|
|
7432
|
+
return _context49.abrupt("return", tempOrder);
|
|
6796
7433
|
case 25:
|
|
6797
7434
|
case "end":
|
|
6798
|
-
return
|
|
7435
|
+
return _context49.stop();
|
|
6799
7436
|
}
|
|
6800
|
-
},
|
|
7437
|
+
}, _callee44, this);
|
|
6801
7438
|
}));
|
|
6802
7439
|
function clearOrderCartLinesDraft() {
|
|
6803
7440
|
return _clearOrderCartLinesDraft.apply(this, arguments);
|
|
@@ -6810,11 +7447,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6810
7447
|
}, {
|
|
6811
7448
|
key: "clearOrderForSettlementSwitch",
|
|
6812
7449
|
value: (function () {
|
|
6813
|
-
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7450
|
+
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
|
|
6814
7451
|
var _this$store$discount22, _this$store$discount23;
|
|
6815
7452
|
var tempOrder;
|
|
6816
|
-
return _regeneratorRuntime().wrap(function
|
|
6817
|
-
while (1) switch (
|
|
7453
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context50) {
|
|
7454
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
6818
7455
|
case 0:
|
|
6819
7456
|
tempOrder = this.ensureTempOrder();
|
|
6820
7457
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
@@ -6834,28 +7471,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6834
7471
|
productsByUid: {}
|
|
6835
7472
|
});
|
|
6836
7473
|
}
|
|
6837
|
-
|
|
7474
|
+
_context50.next = 16;
|
|
6838
7475
|
return (_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.setDiscountList([]);
|
|
6839
7476
|
case 16:
|
|
6840
|
-
|
|
7477
|
+
_context50.next = 18;
|
|
6841
7478
|
return (_this$store$discount23 = this.store.discount) === null || _this$store$discount23 === void 0 ? void 0 : _this$store$discount23.setOriginalDiscountList([]);
|
|
6842
7479
|
case 18:
|
|
6843
7480
|
this.hasActiveCustomerBoundDiscount = false;
|
|
6844
7481
|
this.lastUnfulfilledPromotions = [];
|
|
6845
7482
|
this.lastGiftActions = null;
|
|
6846
|
-
|
|
7483
|
+
_context50.next = 23;
|
|
6847
7484
|
return this.recalculateSummary({
|
|
6848
7485
|
createIfMissing: true
|
|
6849
7486
|
});
|
|
6850
7487
|
case 23:
|
|
6851
7488
|
this.persistTempOrder();
|
|
6852
7489
|
this.logInfo('clearOrderForSettlementSwitch success', {});
|
|
6853
|
-
return
|
|
7490
|
+
return _context50.abrupt("return", tempOrder);
|
|
6854
7491
|
case 26:
|
|
6855
7492
|
case "end":
|
|
6856
|
-
return
|
|
7493
|
+
return _context50.stop();
|
|
6857
7494
|
}
|
|
6858
|
-
},
|
|
7495
|
+
}, _callee45, this);
|
|
6859
7496
|
}));
|
|
6860
7497
|
function clearOrderForSettlementSwitch() {
|
|
6861
7498
|
return _clearOrderForSettlementSwitch.apply(this, arguments);
|
|
@@ -6893,17 +7530,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6893
7530
|
}, {
|
|
6894
7531
|
key: "applyLocalPrintOrderNumbers",
|
|
6895
7532
|
value: function () {
|
|
6896
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7533
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(order) {
|
|
6897
7534
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
6898
|
-
return _regeneratorRuntime().wrap(function
|
|
6899
|
-
while (1) switch (
|
|
7535
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context51) {
|
|
7536
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
6900
7537
|
case 0:
|
|
6901
7538
|
tempOrder = this.ensureTempOrder();
|
|
6902
7539
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
6903
|
-
|
|
7540
|
+
_context51.next = 3;
|
|
6904
7541
|
break;
|
|
6905
7542
|
}
|
|
6906
|
-
return
|
|
7543
|
+
return _context51.abrupt("return", tempOrder);
|
|
6907
7544
|
case 3:
|
|
6908
7545
|
shopOrderNumber = order.shop_order_number;
|
|
6909
7546
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -6914,17 +7551,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6914
7551
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
6915
7552
|
}
|
|
6916
7553
|
this.persistTempOrder();
|
|
6917
|
-
|
|
7554
|
+
_context51.next = 10;
|
|
6918
7555
|
return this.saveDraft();
|
|
6919
7556
|
case 10:
|
|
6920
|
-
return
|
|
7557
|
+
return _context51.abrupt("return", tempOrder);
|
|
6921
7558
|
case 11:
|
|
6922
7559
|
case "end":
|
|
6923
|
-
return
|
|
7560
|
+
return _context51.stop();
|
|
6924
7561
|
}
|
|
6925
|
-
},
|
|
7562
|
+
}, _callee46, this);
|
|
6926
7563
|
}));
|
|
6927
|
-
function applyLocalPrintOrderNumbers(
|
|
7564
|
+
function applyLocalPrintOrderNumbers(_x57) {
|
|
6928
7565
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
6929
7566
|
}
|
|
6930
7567
|
return applyLocalPrintOrderNumbers;
|
|
@@ -6932,35 +7569,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6932
7569
|
}, {
|
|
6933
7570
|
key: "saveTempOrderAsDraft",
|
|
6934
7571
|
value: function () {
|
|
6935
|
-
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7572
|
+
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
|
|
6936
7573
|
var _params$cacheId2, _this$otherParams8, _this$otherParams9, _this$otherParams10, _params$type, _this$otherParams11, _payload$products;
|
|
6937
7574
|
var tempOrder, latestSummary, payload;
|
|
6938
|
-
return _regeneratorRuntime().wrap(function
|
|
6939
|
-
while (1) switch (
|
|
7575
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context52) {
|
|
7576
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
6940
7577
|
case 0:
|
|
6941
7578
|
tempOrder = this.ensureTempOrder();
|
|
6942
7579
|
this.ensureExternalSaleNumber(tempOrder);
|
|
6943
7580
|
this.persistTempOrder();
|
|
6944
|
-
|
|
7581
|
+
_context52.next = 5;
|
|
6945
7582
|
return this.recalculateSummary({
|
|
6946
7583
|
createIfMissing: true
|
|
6947
7584
|
});
|
|
6948
7585
|
case 5:
|
|
6949
|
-
|
|
6950
|
-
if (
|
|
6951
|
-
|
|
7586
|
+
_context52.t1 = _context52.sent;
|
|
7587
|
+
if (_context52.t1) {
|
|
7588
|
+
_context52.next = 8;
|
|
6952
7589
|
break;
|
|
6953
7590
|
}
|
|
6954
|
-
|
|
7591
|
+
_context52.t1 = this.store.summary;
|
|
6955
7592
|
case 8:
|
|
6956
|
-
|
|
6957
|
-
if (
|
|
6958
|
-
|
|
7593
|
+
_context52.t0 = _context52.t1;
|
|
7594
|
+
if (_context52.t0) {
|
|
7595
|
+
_context52.next = 11;
|
|
6959
7596
|
break;
|
|
6960
7597
|
}
|
|
6961
|
-
|
|
7598
|
+
_context52.t0 = createEmptySummary();
|
|
6962
7599
|
case 11:
|
|
6963
|
-
latestSummary =
|
|
7600
|
+
latestSummary = _context52.t0;
|
|
6964
7601
|
payload = buildSubmitPayload({
|
|
6965
7602
|
tempOrder: tempOrder,
|
|
6966
7603
|
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
@@ -6981,17 +7618,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6981
7618
|
externalSaleNumber: payload.external_sale_number,
|
|
6982
7619
|
productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
|
|
6983
7620
|
});
|
|
6984
|
-
return
|
|
7621
|
+
return _context52.abrupt("return", this.request.post('/order/sales/draft', payload, {
|
|
6985
7622
|
osServer: true,
|
|
6986
7623
|
customToast: function customToast() {}
|
|
6987
7624
|
}));
|
|
6988
7625
|
case 18:
|
|
6989
7626
|
case "end":
|
|
6990
|
-
return
|
|
7627
|
+
return _context52.stop();
|
|
6991
7628
|
}
|
|
6992
|
-
},
|
|
7629
|
+
}, _callee47, this);
|
|
6993
7630
|
}));
|
|
6994
|
-
function saveTempOrderAsDraft(
|
|
7631
|
+
function saveTempOrderAsDraft(_x58) {
|
|
6995
7632
|
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
6996
7633
|
}
|
|
6997
7634
|
return saveTempOrderAsDraft;
|
|
@@ -7005,18 +7642,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7005
7642
|
}, {
|
|
7006
7643
|
key: "submitTempOrder",
|
|
7007
7644
|
value: (function () {
|
|
7008
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7009
|
-
return _regeneratorRuntime().wrap(function
|
|
7010
|
-
while (1) switch (
|
|
7645
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
|
|
7646
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context53) {
|
|
7647
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
7011
7648
|
case 0:
|
|
7012
|
-
return
|
|
7649
|
+
return _context53.abrupt("return", this.runSubmitTempOrder(params));
|
|
7013
7650
|
case 1:
|
|
7014
7651
|
case "end":
|
|
7015
|
-
return
|
|
7652
|
+
return _context53.stop();
|
|
7016
7653
|
}
|
|
7017
|
-
},
|
|
7654
|
+
}, _callee48, this);
|
|
7018
7655
|
}));
|
|
7019
|
-
function submitTempOrder(
|
|
7656
|
+
function submitTempOrder(_x59) {
|
|
7020
7657
|
return _submitTempOrder.apply(this, arguments);
|
|
7021
7658
|
}
|
|
7022
7659
|
return submitTempOrder;
|
|
@@ -7024,20 +7661,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7024
7661
|
}, {
|
|
7025
7662
|
key: "submitTempOrderAsync",
|
|
7026
7663
|
value: function () {
|
|
7027
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7028
|
-
return _regeneratorRuntime().wrap(function
|
|
7029
|
-
while (1) switch (
|
|
7664
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
|
|
7665
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context54) {
|
|
7666
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
7030
7667
|
case 0:
|
|
7031
|
-
return
|
|
7668
|
+
return _context54.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
7032
7669
|
syncMode: true
|
|
7033
7670
|
})));
|
|
7034
7671
|
case 1:
|
|
7035
7672
|
case "end":
|
|
7036
|
-
return
|
|
7673
|
+
return _context54.stop();
|
|
7037
7674
|
}
|
|
7038
|
-
},
|
|
7675
|
+
}, _callee49, this);
|
|
7039
7676
|
}));
|
|
7040
|
-
function submitTempOrderAsync(
|
|
7677
|
+
function submitTempOrderAsync(_x60) {
|
|
7041
7678
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
7042
7679
|
}
|
|
7043
7680
|
return submitTempOrderAsync;
|
|
@@ -7045,11 +7682,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7045
7682
|
}, {
|
|
7046
7683
|
key: "runSubmitTempOrder",
|
|
7047
7684
|
value: function () {
|
|
7048
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7685
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
|
|
7049
7686
|
var _params$cacheId3, _this$otherParams12, _ref93, _ref94, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
|
|
7050
7687
|
var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
|
|
7051
|
-
return _regeneratorRuntime().wrap(function
|
|
7052
|
-
while (1) switch (
|
|
7688
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context55) {
|
|
7689
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
7053
7690
|
case 0:
|
|
7054
7691
|
tempOrder = this.ensureTempOrder();
|
|
7055
7692
|
validateProductVoucherGroups(tempOrder, this.getDiscountList(), undefined, true);
|
|
@@ -7074,26 +7711,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7074
7711
|
}
|
|
7075
7712
|
}
|
|
7076
7713
|
this.persistTempOrder();
|
|
7077
|
-
|
|
7714
|
+
_context55.next = 11;
|
|
7078
7715
|
return this.recalculateSummary({
|
|
7079
7716
|
createIfMissing: true
|
|
7080
7717
|
});
|
|
7081
7718
|
case 11:
|
|
7082
|
-
|
|
7083
|
-
if (
|
|
7084
|
-
|
|
7719
|
+
_context55.t1 = _context55.sent;
|
|
7720
|
+
if (_context55.t1) {
|
|
7721
|
+
_context55.next = 14;
|
|
7085
7722
|
break;
|
|
7086
7723
|
}
|
|
7087
|
-
|
|
7724
|
+
_context55.t1 = this.store.summary;
|
|
7088
7725
|
case 14:
|
|
7089
|
-
|
|
7090
|
-
if (
|
|
7091
|
-
|
|
7726
|
+
_context55.t0 = _context55.t1;
|
|
7727
|
+
if (_context55.t0) {
|
|
7728
|
+
_context55.next = 17;
|
|
7092
7729
|
break;
|
|
7093
7730
|
}
|
|
7094
|
-
|
|
7731
|
+
_context55.t0 = createEmptySummary();
|
|
7095
7732
|
case 17:
|
|
7096
|
-
latestSummary =
|
|
7733
|
+
latestSummary = _context55.t0;
|
|
7097
7734
|
effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
|
|
7098
7735
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
7099
7736
|
shouldOverridePaymentStatus = hasPaymentStatusOverride && !isOnlineStorePlatform && !shouldConfirmPendingVoucherPayments;
|
|
@@ -7129,10 +7766,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7129
7766
|
if (!payload.created_at) {
|
|
7130
7767
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
7131
7768
|
}
|
|
7132
|
-
|
|
7769
|
+
_context55.next = 29;
|
|
7133
7770
|
return this.saveDraft();
|
|
7134
7771
|
case 29:
|
|
7135
|
-
|
|
7772
|
+
_context55.prev = 29;
|
|
7136
7773
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
7137
7774
|
orderId: payload.order_id,
|
|
7138
7775
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -7142,43 +7779,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7142
7779
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
7143
7780
|
syncMode: payload.sync_mode
|
|
7144
7781
|
});
|
|
7145
|
-
|
|
7782
|
+
_context55.next = 33;
|
|
7146
7783
|
return this.submitSalesOrder({
|
|
7147
7784
|
query: payload
|
|
7148
7785
|
});
|
|
7149
7786
|
case 33:
|
|
7150
|
-
result =
|
|
7151
|
-
|
|
7787
|
+
result = _context55.sent;
|
|
7788
|
+
_context55.next = 46;
|
|
7152
7789
|
break;
|
|
7153
7790
|
case 36:
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
7791
|
+
_context55.prev = 36;
|
|
7792
|
+
_context55.t2 = _context55["catch"](29);
|
|
7793
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context55.t2);
|
|
7157
7794
|
if (!backendErrorResponse) {
|
|
7158
|
-
|
|
7795
|
+
_context55.next = 43;
|
|
7159
7796
|
break;
|
|
7160
7797
|
}
|
|
7161
7798
|
this.store.syncState = 'failed';
|
|
7162
7799
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
7163
|
-
return
|
|
7800
|
+
return _context55.abrupt("return", backendErrorResponse);
|
|
7164
7801
|
case 43:
|
|
7165
7802
|
this.store.syncState = 'failed';
|
|
7166
7803
|
this.logError('submitTempOrder failed', {
|
|
7167
|
-
error:
|
|
7804
|
+
error: _context55.t2 instanceof Error ? _context55.t2.message : String(_context55.t2),
|
|
7168
7805
|
orderId: payload.order_id,
|
|
7169
7806
|
externalSaleNumber: payload.external_sale_number,
|
|
7170
7807
|
paymentStatus: payload.payment_status,
|
|
7171
7808
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
7172
7809
|
});
|
|
7173
|
-
throw
|
|
7810
|
+
throw _context55.t2;
|
|
7174
7811
|
case 46:
|
|
7175
7812
|
if (!this.isSubmitResponseRejected(result)) {
|
|
7176
|
-
|
|
7813
|
+
_context55.next = 50;
|
|
7177
7814
|
break;
|
|
7178
7815
|
}
|
|
7179
7816
|
this.store.syncState = 'failed';
|
|
7180
7817
|
this.logSubmitBackendRejected(result, payload);
|
|
7181
|
-
return
|
|
7818
|
+
return _context55.abrupt("return", result);
|
|
7182
7819
|
case 50:
|
|
7183
7820
|
isLocalPendingSubmit = this.isLocalPendingSubmitResult(result); // need_sync=1 仅表示已进入本地同步队列,不能视为远端已确认 Notes。
|
|
7184
7821
|
if (Object.prototype.hasOwnProperty.call(payload, 'notes') && !isLocalPendingSubmit) {
|
|
@@ -7194,12 +7831,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7194
7831
|
})
|
|
7195
7832
|
});
|
|
7196
7833
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
7197
|
-
|
|
7834
|
+
_context55.next = 59;
|
|
7198
7835
|
break;
|
|
7199
7836
|
}
|
|
7200
7837
|
tempOrder.order_id = submittedOrderId;
|
|
7201
7838
|
resultRecord = result;
|
|
7202
|
-
|
|
7839
|
+
_context55.next = 59;
|
|
7203
7840
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
7204
7841
|
case 59:
|
|
7205
7842
|
if (isLocalPendingSubmit) {
|
|
@@ -7207,14 +7844,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7207
7844
|
} else if (submittedOrderId === null || submittedOrderId === undefined) {
|
|
7208
7845
|
this.store.syncState = 'submitted';
|
|
7209
7846
|
}
|
|
7210
|
-
return
|
|
7847
|
+
return _context55.abrupt("return", result);
|
|
7211
7848
|
case 61:
|
|
7212
7849
|
case "end":
|
|
7213
|
-
return
|
|
7850
|
+
return _context55.stop();
|
|
7214
7851
|
}
|
|
7215
|
-
},
|
|
7852
|
+
}, _callee50, this, [[29, 36]]);
|
|
7216
7853
|
}));
|
|
7217
|
-
function runSubmitTempOrder(
|
|
7854
|
+
function runSubmitTempOrder(_x61) {
|
|
7218
7855
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
7219
7856
|
}
|
|
7220
7857
|
return runSubmitTempOrder;
|
|
@@ -7222,10 +7859,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7222
7859
|
}, {
|
|
7223
7860
|
key: "markLocalOrderSynced",
|
|
7224
7861
|
value: function () {
|
|
7225
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7862
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(orderId, remoteOrder) {
|
|
7226
7863
|
var tempOrder;
|
|
7227
|
-
return _regeneratorRuntime().wrap(function
|
|
7228
|
-
while (1) switch (
|
|
7864
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context56) {
|
|
7865
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
7229
7866
|
case 0:
|
|
7230
7867
|
tempOrder = this.ensureTempOrder();
|
|
7231
7868
|
tempOrder.order_id = orderId;
|
|
@@ -7233,15 +7870,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7233
7870
|
this.store.lastOrderInfo = remoteOrder;
|
|
7234
7871
|
this.store.syncState = 'submitted';
|
|
7235
7872
|
this.persistTempOrder();
|
|
7236
|
-
|
|
7873
|
+
_context56.next = 8;
|
|
7237
7874
|
return this.saveDraft();
|
|
7238
7875
|
case 8:
|
|
7239
7876
|
case "end":
|
|
7240
|
-
return
|
|
7877
|
+
return _context56.stop();
|
|
7241
7878
|
}
|
|
7242
|
-
},
|
|
7879
|
+
}, _callee51, this);
|
|
7243
7880
|
}));
|
|
7244
|
-
function markLocalOrderSynced(
|
|
7881
|
+
function markLocalOrderSynced(_x62, _x63) {
|
|
7245
7882
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
7246
7883
|
}
|
|
7247
7884
|
return markLocalOrderSynced;
|
|
@@ -7284,10 +7921,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7284
7921
|
value: function extractSubmitErrorResponse(error) {
|
|
7285
7922
|
var _error$response,
|
|
7286
7923
|
_error$response2,
|
|
7287
|
-
|
|
7924
|
+
_this52 = this;
|
|
7288
7925
|
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];
|
|
7289
7926
|
return candidates.find(function (candidate) {
|
|
7290
|
-
return
|
|
7927
|
+
return _this52.isSubmitErrorResponse(candidate);
|
|
7291
7928
|
}) || null;
|
|
7292
7929
|
}
|
|
7293
7930
|
}, {
|
|
@@ -7314,33 +7951,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7314
7951
|
}, {
|
|
7315
7952
|
key: "syncPaymentsToOrder",
|
|
7316
7953
|
value: function () {
|
|
7317
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7318
|
-
var
|
|
7954
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
|
|
7955
|
+
var _this53 = this,
|
|
7319
7956
|
_params$confirmPendin;
|
|
7320
7957
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
7321
|
-
return _regeneratorRuntime().wrap(function
|
|
7322
|
-
while (1) switch (
|
|
7958
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context57) {
|
|
7959
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
7323
7960
|
case 0:
|
|
7324
7961
|
tempOrder = this.ensureTempOrder();
|
|
7325
7962
|
needsPaymentNumber = (params.payments || []).some(function (payment) {
|
|
7326
7963
|
return String(payment.payment_number || '').trim() === '';
|
|
7327
7964
|
});
|
|
7328
7965
|
if (!needsPaymentNumber) {
|
|
7329
|
-
|
|
7966
|
+
_context57.next = 8;
|
|
7330
7967
|
break;
|
|
7331
7968
|
}
|
|
7332
|
-
|
|
7969
|
+
_context57.next = 5;
|
|
7333
7970
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
7334
7971
|
case 5:
|
|
7335
|
-
|
|
7336
|
-
|
|
7972
|
+
_context57.t0 = _context57.sent;
|
|
7973
|
+
_context57.next = 9;
|
|
7337
7974
|
break;
|
|
7338
7975
|
case 8:
|
|
7339
|
-
|
|
7976
|
+
_context57.t0 = 'LOCAL';
|
|
7340
7977
|
case 9:
|
|
7341
|
-
devicePrefix =
|
|
7978
|
+
devicePrefix = _context57.t0;
|
|
7342
7979
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
7343
|
-
return
|
|
7980
|
+
return _this53.normalizePaymentSource(payment, {
|
|
7344
7981
|
defaultPaid: false,
|
|
7345
7982
|
devicePrefix: devicePrefix
|
|
7346
7983
|
});
|
|
@@ -7353,20 +7990,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7353
7990
|
tempOrder.payments = effectivePayments;
|
|
7354
7991
|
tempOrder.payment_status = paymentStatus;
|
|
7355
7992
|
this.persistTempOrder();
|
|
7356
|
-
|
|
7993
|
+
_context57.next = 21;
|
|
7357
7994
|
return this.saveDraft();
|
|
7358
7995
|
case 21:
|
|
7359
7996
|
if (params.submitWhenPaid) {
|
|
7360
|
-
|
|
7997
|
+
_context57.next = 23;
|
|
7361
7998
|
break;
|
|
7362
7999
|
}
|
|
7363
|
-
return
|
|
8000
|
+
return _context57.abrupt("return", completion);
|
|
7364
8001
|
case 23:
|
|
7365
8002
|
if (!(this.store.syncState === 'submitting')) {
|
|
7366
|
-
|
|
8003
|
+
_context57.next = 25;
|
|
7367
8004
|
break;
|
|
7368
8005
|
}
|
|
7369
|
-
return
|
|
8006
|
+
return _context57.abrupt("return", completion);
|
|
7370
8007
|
case 25:
|
|
7371
8008
|
this.store.syncState = 'submitting';
|
|
7372
8009
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
@@ -7386,32 +8023,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7386
8023
|
enhancePayload: enhancePayload
|
|
7387
8024
|
};
|
|
7388
8025
|
if (!(params.checkoutSyncTaskEnabled === false)) {
|
|
7389
|
-
|
|
8026
|
+
_context57.next = 35;
|
|
7390
8027
|
break;
|
|
7391
8028
|
}
|
|
7392
|
-
|
|
8029
|
+
_context57.next = 32;
|
|
7393
8030
|
return this.submitTempOrderAsync(submitParams);
|
|
7394
8031
|
case 32:
|
|
7395
|
-
|
|
7396
|
-
|
|
8032
|
+
_context57.t1 = _context57.sent;
|
|
8033
|
+
_context57.next = 38;
|
|
7397
8034
|
break;
|
|
7398
8035
|
case 35:
|
|
7399
|
-
|
|
8036
|
+
_context57.next = 37;
|
|
7400
8037
|
return this.submitTempOrder(submitParams);
|
|
7401
8038
|
case 37:
|
|
7402
|
-
|
|
8039
|
+
_context57.t1 = _context57.sent;
|
|
7403
8040
|
case 38:
|
|
7404
|
-
submitResult =
|
|
7405
|
-
return
|
|
8041
|
+
submitResult = _context57.t1;
|
|
8042
|
+
return _context57.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
7406
8043
|
submitResult: submitResult
|
|
7407
8044
|
}));
|
|
7408
8045
|
case 40:
|
|
7409
8046
|
case "end":
|
|
7410
|
-
return
|
|
8047
|
+
return _context57.stop();
|
|
7411
8048
|
}
|
|
7412
|
-
},
|
|
8049
|
+
}, _callee52, this);
|
|
7413
8050
|
}));
|
|
7414
|
-
function syncPaymentsToOrder(
|
|
8051
|
+
function syncPaymentsToOrder(_x64) {
|
|
7415
8052
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
7416
8053
|
}
|
|
7417
8054
|
return syncPaymentsToOrder;
|
|
@@ -7419,7 +8056,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7419
8056
|
}, {
|
|
7420
8057
|
key: "createOrder",
|
|
7421
8058
|
value: function createOrder(params) {
|
|
7422
|
-
var
|
|
8059
|
+
var _this54 = this;
|
|
7423
8060
|
var order = _objectSpread({
|
|
7424
8061
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
7425
8062
|
// 要从外面拿,virtual
|
|
@@ -7451,7 +8088,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7451
8088
|
|
|
7452
8089
|
// 为预约补齐 holder 信息
|
|
7453
8090
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
7454
|
-
ensureCartItemOriginHolder(item,
|
|
8091
|
+
ensureCartItemOriginHolder(item, _this54.window);
|
|
7455
8092
|
}
|
|
7456
8093
|
|
|
7457
8094
|
// 购物车是否为普通商品
|
|
@@ -7508,11 +8145,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7508
8145
|
}, {
|
|
7509
8146
|
key: "submitOrder",
|
|
7510
8147
|
value: function () {
|
|
7511
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8148
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(order) {
|
|
7512
8149
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
7513
8150
|
var url, query, fetchUrl, params;
|
|
7514
|
-
return _regeneratorRuntime().wrap(function
|
|
7515
|
-
while (1) switch (
|
|
8151
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context58) {
|
|
8152
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
7516
8153
|
case 0:
|
|
7517
8154
|
this.logInfo('submitOrder called', {
|
|
7518
8155
|
url: order.url,
|
|
@@ -7532,14 +8169,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7532
8169
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
7533
8170
|
scheduleDate: params.schedule_date
|
|
7534
8171
|
});
|
|
7535
|
-
return
|
|
8172
|
+
return _context58.abrupt("return", this.request.post(fetchUrl, params));
|
|
7536
8173
|
case 6:
|
|
7537
8174
|
case "end":
|
|
7538
|
-
return
|
|
8175
|
+
return _context58.stop();
|
|
7539
8176
|
}
|
|
7540
|
-
},
|
|
8177
|
+
}, _callee53, this);
|
|
7541
8178
|
}));
|
|
7542
|
-
function submitOrder(
|
|
8179
|
+
function submitOrder(_x65) {
|
|
7543
8180
|
return _submitOrder.apply(this, arguments);
|
|
7544
8181
|
}
|
|
7545
8182
|
return submitOrder;
|
|
@@ -7547,13 +8184,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7547
8184
|
}, {
|
|
7548
8185
|
key: "cancelOrder",
|
|
7549
8186
|
value: function () {
|
|
7550
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8187
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
|
|
7551
8188
|
var payload;
|
|
7552
|
-
return _regeneratorRuntime().wrap(function
|
|
7553
|
-
while (1) switch (
|
|
8189
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context59) {
|
|
8190
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
7554
8191
|
case 0:
|
|
7555
8192
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
7556
|
-
|
|
8193
|
+
_context59.next = 2;
|
|
7557
8194
|
break;
|
|
7558
8195
|
}
|
|
7559
8196
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -7569,16 +8206,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7569
8206
|
method: 'PUT',
|
|
7570
8207
|
orderIdsCount: params.order_ids.length
|
|
7571
8208
|
});
|
|
7572
|
-
return
|
|
8209
|
+
return _context59.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
7573
8210
|
isShopApi: true
|
|
7574
8211
|
}));
|
|
7575
8212
|
case 5:
|
|
7576
8213
|
case "end":
|
|
7577
|
-
return
|
|
8214
|
+
return _context59.stop();
|
|
7578
8215
|
}
|
|
7579
|
-
},
|
|
8216
|
+
}, _callee54, this);
|
|
7580
8217
|
}));
|
|
7581
|
-
function cancelOrder(
|
|
8218
|
+
function cancelOrder(_x66) {
|
|
7582
8219
|
return _cancelOrder.apply(this, arguments);
|
|
7583
8220
|
}
|
|
7584
8221
|
return cancelOrder;
|
|
@@ -7586,19 +8223,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7586
8223
|
}, {
|
|
7587
8224
|
key: "changeBookingStatus",
|
|
7588
8225
|
value: function () {
|
|
7589
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8226
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
|
|
7590
8227
|
var url, payload;
|
|
7591
|
-
return _regeneratorRuntime().wrap(function
|
|
7592
|
-
while (1) switch (
|
|
8228
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context60) {
|
|
8229
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
7593
8230
|
case 0:
|
|
7594
8231
|
if (params.booking_id) {
|
|
7595
|
-
|
|
8232
|
+
_context60.next = 2;
|
|
7596
8233
|
break;
|
|
7597
8234
|
}
|
|
7598
8235
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
7599
8236
|
case 2:
|
|
7600
8237
|
if (params.appointment_status) {
|
|
7601
|
-
|
|
8238
|
+
_context60.next = 4;
|
|
7602
8239
|
break;
|
|
7603
8240
|
}
|
|
7604
8241
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -7613,16 +8250,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7613
8250
|
bookingId: params.booking_id,
|
|
7614
8251
|
appointmentStatus: params.appointment_status
|
|
7615
8252
|
});
|
|
7616
|
-
return
|
|
8253
|
+
return _context60.abrupt("return", this.request.put(url, payload, {
|
|
7617
8254
|
isShopApi: true
|
|
7618
8255
|
}));
|
|
7619
8256
|
case 8:
|
|
7620
8257
|
case "end":
|
|
7621
|
-
return
|
|
8258
|
+
return _context60.stop();
|
|
7622
8259
|
}
|
|
7623
|
-
},
|
|
8260
|
+
}, _callee55, this);
|
|
7624
8261
|
}));
|
|
7625
|
-
function changeBookingStatus(
|
|
8262
|
+
function changeBookingStatus(_x67) {
|
|
7626
8263
|
return _changeBookingStatus.apply(this, arguments);
|
|
7627
8264
|
}
|
|
7628
8265
|
return changeBookingStatus;
|
|
@@ -7640,11 +8277,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7640
8277
|
}, {
|
|
7641
8278
|
key: "createOrderByCheckout",
|
|
7642
8279
|
value: (function () {
|
|
7643
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8280
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
|
|
7644
8281
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3;
|
|
7645
8282
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, orderData, response;
|
|
7646
|
-
return _regeneratorRuntime().wrap(function
|
|
7647
|
-
while (1) switch (
|
|
8283
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context61) {
|
|
8284
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
7648
8285
|
case 0:
|
|
7649
8286
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
7650
8287
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -7669,7 +8306,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7669
8306
|
return p.code;
|
|
7670
8307
|
})) || []
|
|
7671
8308
|
});
|
|
7672
|
-
|
|
8309
|
+
_context61.prev = 3;
|
|
7673
8310
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
7674
8311
|
orderData = _objectSpread({
|
|
7675
8312
|
sales_channel: 'my_pisel',
|
|
@@ -7717,32 +8354,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7717
8354
|
hasOrderId: !!orderData.order_id,
|
|
7718
8355
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
7719
8356
|
});
|
|
7720
|
-
|
|
8357
|
+
_context61.next = 10;
|
|
7721
8358
|
return this.request.post('/order/checkout', orderData, {
|
|
7722
8359
|
osServer: true,
|
|
7723
8360
|
customToast: function customToast() {}
|
|
7724
8361
|
});
|
|
7725
8362
|
case 10:
|
|
7726
|
-
response =
|
|
8363
|
+
response = _context61.sent;
|
|
7727
8364
|
this.logInfo('Order API called successfully', {
|
|
7728
8365
|
response: response
|
|
7729
8366
|
});
|
|
7730
|
-
return
|
|
8367
|
+
return _context61.abrupt("return", response);
|
|
7731
8368
|
case 15:
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
8369
|
+
_context61.prev = 15;
|
|
8370
|
+
_context61.t0 = _context61["catch"](3);
|
|
8371
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context61.t0);
|
|
7735
8372
|
this.logInfo('Order API called failed', {
|
|
7736
|
-
error:
|
|
8373
|
+
error: _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0)
|
|
7737
8374
|
});
|
|
7738
|
-
throw
|
|
8375
|
+
throw _context61.t0;
|
|
7739
8376
|
case 20:
|
|
7740
8377
|
case "end":
|
|
7741
|
-
return
|
|
8378
|
+
return _context61.stop();
|
|
7742
8379
|
}
|
|
7743
|
-
},
|
|
8380
|
+
}, _callee56, this, [[3, 15]]);
|
|
7744
8381
|
}));
|
|
7745
|
-
function createOrderByCheckout(
|
|
8382
|
+
function createOrderByCheckout(_x68) {
|
|
7746
8383
|
return _createOrderByCheckout.apply(this, arguments);
|
|
7747
8384
|
}
|
|
7748
8385
|
return createOrderByCheckout;
|
|
@@ -7750,25 +8387,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7750
8387
|
}, {
|
|
7751
8388
|
key: "submitSalesOrder",
|
|
7752
8389
|
value: function () {
|
|
7753
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8390
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
|
|
7754
8391
|
var url, query, fetchUrl, requestQuery;
|
|
7755
|
-
return _regeneratorRuntime().wrap(function
|
|
7756
|
-
while (1) switch (
|
|
8392
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context62) {
|
|
8393
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
7757
8394
|
case 0:
|
|
7758
8395
|
url = params.url, query = params.query;
|
|
7759
8396
|
fetchUrl = url || '/order/sales/checkout';
|
|
7760
8397
|
requestQuery = this.isSalesCheckoutHandledByOsServer(fetchUrl) ? query : stripOsPrivatePayloadFields(query);
|
|
7761
|
-
return
|
|
8398
|
+
return _context62.abrupt("return", this.request.post(fetchUrl, requestQuery, {
|
|
7762
8399
|
osServer: true,
|
|
7763
8400
|
customToast: function customToast() {}
|
|
7764
8401
|
}));
|
|
7765
8402
|
case 4:
|
|
7766
8403
|
case "end":
|
|
7767
|
-
return
|
|
8404
|
+
return _context62.stop();
|
|
7768
8405
|
}
|
|
7769
|
-
},
|
|
8406
|
+
}, _callee57, this);
|
|
7770
8407
|
}));
|
|
7771
|
-
function submitSalesOrder(
|
|
8408
|
+
function submitSalesOrder(_x69) {
|
|
7772
8409
|
return _submitSalesOrder.apply(this, arguments);
|
|
7773
8410
|
}
|
|
7774
8411
|
return submitSalesOrder;
|
|
@@ -7795,37 +8432,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7795
8432
|
}, {
|
|
7796
8433
|
key: "sendCustomerPayLink",
|
|
7797
8434
|
value: (function () {
|
|
7798
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8435
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
|
|
7799
8436
|
var _params$emails;
|
|
7800
8437
|
var orderIds;
|
|
7801
|
-
return _regeneratorRuntime().wrap(function
|
|
7802
|
-
while (1) switch (
|
|
8438
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context63) {
|
|
8439
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
7803
8440
|
case 0:
|
|
7804
8441
|
orderIds = params.order_ids || params.orderIds || [];
|
|
7805
8442
|
if (orderIds.length) {
|
|
7806
|
-
|
|
8443
|
+
_context63.next = 3;
|
|
7807
8444
|
break;
|
|
7808
8445
|
}
|
|
7809
8446
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
7810
8447
|
case 3:
|
|
7811
8448
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
7812
|
-
|
|
8449
|
+
_context63.next = 5;
|
|
7813
8450
|
break;
|
|
7814
8451
|
}
|
|
7815
8452
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
7816
8453
|
case 5:
|
|
7817
|
-
return
|
|
8454
|
+
return _context63.abrupt("return", this.request.post('/order/batch-email', {
|
|
7818
8455
|
order_ids: orderIds,
|
|
7819
8456
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
7820
8457
|
emails: params.emails
|
|
7821
8458
|
}));
|
|
7822
8459
|
case 6:
|
|
7823
8460
|
case "end":
|
|
7824
|
-
return
|
|
8461
|
+
return _context63.stop();
|
|
7825
8462
|
}
|
|
7826
|
-
},
|
|
8463
|
+
}, _callee58, this);
|
|
7827
8464
|
}));
|
|
7828
|
-
function sendCustomerPayLink(
|
|
8465
|
+
function sendCustomerPayLink(_x70) {
|
|
7829
8466
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
7830
8467
|
}
|
|
7831
8468
|
return sendCustomerPayLink;
|
|
@@ -7833,14 +8470,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7833
8470
|
}, {
|
|
7834
8471
|
key: "getSalesOrderByLookup",
|
|
7835
8472
|
value: function () {
|
|
7836
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8473
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
|
|
7837
8474
|
var lookup, res;
|
|
7838
|
-
return _regeneratorRuntime().wrap(function
|
|
7839
|
-
while (1) switch (
|
|
8475
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context64) {
|
|
8476
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
7840
8477
|
case 0:
|
|
7841
8478
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
7842
8479
|
if (lookup) {
|
|
7843
|
-
|
|
8480
|
+
_context64.next = 3;
|
|
7844
8481
|
break;
|
|
7845
8482
|
}
|
|
7846
8483
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -7849,25 +8486,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7849
8486
|
if (lookup.startsWith('LOCAL_')) {
|
|
7850
8487
|
params.forceRemote = false;
|
|
7851
8488
|
}
|
|
7852
|
-
|
|
8489
|
+
_context64.next = 6;
|
|
7853
8490
|
return loadSalesOrderSnapshot(this.request, {
|
|
7854
8491
|
lookup: lookup,
|
|
7855
8492
|
transport: 'os-server',
|
|
7856
8493
|
forceRemote: params.forceRemote
|
|
7857
8494
|
});
|
|
7858
8495
|
case 6:
|
|
7859
|
-
res =
|
|
8496
|
+
res = _context64.sent;
|
|
7860
8497
|
if (res.code === 200) {
|
|
7861
8498
|
this.store.lastOrderInfo = res.data;
|
|
7862
8499
|
}
|
|
7863
|
-
return
|
|
8500
|
+
return _context64.abrupt("return", res);
|
|
7864
8501
|
case 9:
|
|
7865
8502
|
case "end":
|
|
7866
|
-
return
|
|
8503
|
+
return _context64.stop();
|
|
7867
8504
|
}
|
|
7868
|
-
},
|
|
8505
|
+
}, _callee59, this);
|
|
7869
8506
|
}));
|
|
7870
|
-
function getSalesOrderByLookup(
|
|
8507
|
+
function getSalesOrderByLookup(_x71) {
|
|
7871
8508
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
7872
8509
|
}
|
|
7873
8510
|
return getSalesOrderByLookup;
|
|
@@ -7881,11 +8518,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7881
8518
|
}, {
|
|
7882
8519
|
key: "hydrateTempOrderFromRecord",
|
|
7883
8520
|
value: (function () {
|
|
7884
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8521
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(record, options) {
|
|
7885
8522
|
var _sourceRaw$_extend, _this$store$discount26;
|
|
7886
8523
|
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;
|
|
7887
|
-
return _regeneratorRuntime().wrap(function
|
|
7888
|
-
while (1) switch (
|
|
8524
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context65) {
|
|
8525
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
7889
8526
|
case 0:
|
|
7890
8527
|
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
7891
8528
|
duplicateProductIdentityRepair = repairDuplicateOrderProductLineIdentities(Array.isArray(sourceRaw.products) ? sourceRaw.products : [], (_sourceRaw$_extend = sourceRaw._extend) === null || _sourceRaw$_extend === void 0 ? void 0 : _sourceRaw$_extend.productsByUid);
|
|
@@ -7927,7 +8564,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7927
8564
|
this.store.tempOrder = nextTempOrder;
|
|
7928
8565
|
this.clearCustomerWalletRuntimeState();
|
|
7929
8566
|
if (!isSessionStorageHydrate) {
|
|
7930
|
-
|
|
8567
|
+
_context65.next = 31;
|
|
7931
8568
|
break;
|
|
7932
8569
|
}
|
|
7933
8570
|
// 会话快照是未提交购物车,不应获得编辑订单的 saved/edit 标记与服务端基线。
|
|
@@ -7943,23 +8580,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7943
8580
|
nextTempOrder.discount_list = restoredSessionDiscounts;
|
|
7944
8581
|
this.store.summary = createEmptySummary();
|
|
7945
8582
|
this.store.lastOrderInfo = undefined;
|
|
7946
|
-
|
|
8583
|
+
_context65.next = 24;
|
|
7947
8584
|
return (_this$store$discount24 = this.store.discount) === null || _this$store$discount24 === void 0 ? void 0 : _this$store$discount24.setOriginalDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
7948
8585
|
case 24:
|
|
7949
|
-
|
|
8586
|
+
_context65.next = 26;
|
|
7950
8587
|
return (_this$store$discount25 = this.store.discount) === null || _this$store$discount25 === void 0 ? void 0 : _this$store$discount25.setDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
7951
8588
|
case 26:
|
|
7952
8589
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
7953
|
-
|
|
8590
|
+
_context65.next = 29;
|
|
7954
8591
|
break;
|
|
7955
8592
|
}
|
|
7956
|
-
|
|
8593
|
+
_context65.next = 29;
|
|
7957
8594
|
return this.recalculateSummary({
|
|
7958
8595
|
createIfMissing: false
|
|
7959
8596
|
});
|
|
7960
8597
|
case 29:
|
|
7961
8598
|
this.persistTempOrder();
|
|
7962
|
-
return
|
|
8599
|
+
return _context65.abrupt("return", nextTempOrder);
|
|
7963
8600
|
case 31:
|
|
7964
8601
|
// Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
|
|
7965
8602
|
sourceLastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
|
|
@@ -8012,34 +8649,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8012
8649
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
8013
8650
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
8014
8651
|
if (shouldSkipEmptyDiscountSync) {
|
|
8015
|
-
|
|
8652
|
+
_context65.next = 55;
|
|
8016
8653
|
break;
|
|
8017
8654
|
}
|
|
8018
8655
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
8019
|
-
|
|
8656
|
+
_context65.next = 53;
|
|
8020
8657
|
return (_this$store$discount27 = this.store.discount) === null || _this$store$discount27 === void 0 ? void 0 : _this$store$discount27.setOriginalDiscountList(nextDiscounts);
|
|
8021
8658
|
case 53:
|
|
8022
|
-
|
|
8659
|
+
_context65.next = 55;
|
|
8023
8660
|
return (_this$store$discount28 = this.store.discount) === null || _this$store$discount28 === void 0 ? void 0 : _this$store$discount28.setDiscountList(nextDiscounts);
|
|
8024
8661
|
case 55:
|
|
8025
8662
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
8026
|
-
|
|
8663
|
+
_context65.next = 58;
|
|
8027
8664
|
break;
|
|
8028
8665
|
}
|
|
8029
|
-
|
|
8666
|
+
_context65.next = 58;
|
|
8030
8667
|
return this.recalculateSummary({
|
|
8031
8668
|
createIfMissing: false
|
|
8032
8669
|
});
|
|
8033
8670
|
case 58:
|
|
8034
8671
|
this.persistTempOrder();
|
|
8035
|
-
return
|
|
8672
|
+
return _context65.abrupt("return", nextTempOrder);
|
|
8036
8673
|
case 60:
|
|
8037
8674
|
case "end":
|
|
8038
|
-
return
|
|
8675
|
+
return _context65.stop();
|
|
8039
8676
|
}
|
|
8040
|
-
},
|
|
8677
|
+
}, _callee60, this);
|
|
8041
8678
|
}));
|
|
8042
|
-
function hydrateTempOrderFromRecord(
|
|
8679
|
+
function hydrateTempOrderFromRecord(_x72, _x73) {
|
|
8043
8680
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
8044
8681
|
}
|
|
8045
8682
|
return hydrateTempOrderFromRecord;
|
|
@@ -8088,12 +8725,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8088
8725
|
if (!raw || _typeof(raw) !== 'object') return {};
|
|
8089
8726
|
if (!Array.isArray(raw.bookings) || !Array.isArray(raw.products)) return raw;
|
|
8090
8727
|
var bookingUidsByProductUid = new Map();
|
|
8091
|
-
var
|
|
8092
|
-
|
|
8728
|
+
var _iterator29 = _createForOfIteratorHelper(raw.products),
|
|
8729
|
+
_step29;
|
|
8093
8730
|
try {
|
|
8094
|
-
for (
|
|
8731
|
+
for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
|
|
8095
8732
|
var _product$metadata13;
|
|
8096
|
-
var product =
|
|
8733
|
+
var product = _step29.value;
|
|
8097
8734
|
var productUid = getOrderCollectionUid('product', product);
|
|
8098
8735
|
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata13 = product.metadata) === null || _product$metadata13 === void 0 ? void 0 : _product$metadata13.booking_uid);
|
|
8099
8736
|
if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
|
|
@@ -8104,18 +8741,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8104
8741
|
bookingUidsByProductUid.set(productUid, candidates);
|
|
8105
8742
|
}
|
|
8106
8743
|
} catch (err) {
|
|
8107
|
-
|
|
8744
|
+
_iterator29.e(err);
|
|
8108
8745
|
} finally {
|
|
8109
|
-
|
|
8746
|
+
_iterator29.f();
|
|
8110
8747
|
}
|
|
8111
8748
|
if (bookingUidsByProductUid.size === 0) return raw;
|
|
8112
8749
|
var anonymousBookingCountByProductUid = new Map();
|
|
8113
|
-
var
|
|
8114
|
-
|
|
8750
|
+
var _iterator30 = _createForOfIteratorHelper(raw.bookings),
|
|
8751
|
+
_step30;
|
|
8115
8752
|
try {
|
|
8116
|
-
for (
|
|
8753
|
+
for (_iterator30.s(); !(_step30 = _iterator30.n()).done;) {
|
|
8117
8754
|
var _booking$metadata9;
|
|
8118
|
-
var booking =
|
|
8755
|
+
var booking = _step30.value;
|
|
8119
8756
|
if (getOrderCollectionPersistentId('booking', booking) || getOrderCollectionUid('booking', booking)) {
|
|
8120
8757
|
continue;
|
|
8121
8758
|
}
|
|
@@ -8125,9 +8762,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8125
8762
|
anonymousBookingCountByProductUid.set(key, (anonymousBookingCountByProductUid.get(key) || 0) + 1);
|
|
8126
8763
|
}
|
|
8127
8764
|
} catch (err) {
|
|
8128
|
-
|
|
8765
|
+
_iterator30.e(err);
|
|
8129
8766
|
} finally {
|
|
8130
|
-
|
|
8767
|
+
_iterator30.f();
|
|
8131
8768
|
}
|
|
8132
8769
|
return _objectSpread(_objectSpread({}, raw), {}, {
|
|
8133
8770
|
bookings: raw.bookings.map(function (booking) {
|
|
@@ -8153,7 +8790,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8153
8790
|
}, {
|
|
8154
8791
|
key: "normalizeTempOrderForRuntime",
|
|
8155
8792
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
8156
|
-
var
|
|
8793
|
+
var _this55 = this,
|
|
8157
8794
|
_raw$_extend;
|
|
8158
8795
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
8159
8796
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
@@ -8181,12 +8818,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8181
8818
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
8182
8819
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
8183
8820
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
8184
|
-
return
|
|
8821
|
+
return _this55.normalizeHydratedOrderProduct(p, {
|
|
8185
8822
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
8186
8823
|
});
|
|
8187
8824
|
}) : [];
|
|
8188
8825
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
8189
|
-
var booking =
|
|
8826
|
+
var booking = _this55.normalizeHydratedBookingHolder(b || {});
|
|
8190
8827
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
8191
8828
|
is_all: normalizeBookingIsAll(booking),
|
|
8192
8829
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -8232,14 +8869,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8232
8869
|
dirty: decodedSalesNotes.complete && ((restoredSalesNotesState === null || restoredSalesNotesState === void 0 ? void 0 : restoredSalesNotesState.dirty) === true || allowUnresolvedSalesNotes && hasUnresolvedSalesNoteOrderTarget)
|
|
8233
8870
|
};
|
|
8234
8871
|
var productsByUid = tempOrderExtend.productsByUid || {};
|
|
8235
|
-
var
|
|
8236
|
-
|
|
8872
|
+
var _iterator31 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
|
|
8873
|
+
_step31;
|
|
8237
8874
|
try {
|
|
8238
|
-
for (
|
|
8875
|
+
for (_iterator31.s(); !(_step31 = _iterator31.n()).done;) {
|
|
8239
8876
|
var _product$metadata14, _ref95, _ref96, _existed$origin, _rawProduct$metadata;
|
|
8240
|
-
var
|
|
8241
|
-
index =
|
|
8242
|
-
product =
|
|
8877
|
+
var _step31$value = _slicedToArray(_step31.value, 2),
|
|
8878
|
+
index = _step31$value[0],
|
|
8879
|
+
product = _step31$value[1];
|
|
8243
8880
|
var uid = (_product$metadata14 = product.metadata) === null || _product$metadata14 === void 0 ? void 0 : _product$metadata14.unique_identification_number;
|
|
8244
8881
|
if (!uid) continue;
|
|
8245
8882
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
@@ -8260,14 +8897,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8260
8897
|
});
|
|
8261
8898
|
}
|
|
8262
8899
|
} catch (err) {
|
|
8263
|
-
|
|
8900
|
+
_iterator31.e(err);
|
|
8264
8901
|
} finally {
|
|
8265
|
-
|
|
8902
|
+
_iterator31.f();
|
|
8266
8903
|
}
|
|
8267
8904
|
tempOrderExtend.productsByUid = productsByUid;
|
|
8268
8905
|
this.hydrateLinkedBookingIdentity(nextTempOrder);
|
|
8269
8906
|
nextTempOrder.products.forEach(function (product) {
|
|
8270
|
-
return
|
|
8907
|
+
return _this55.sanitizeOrderProductForTempOrder(product);
|
|
8271
8908
|
});
|
|
8272
8909
|
if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
|
|
8273
8910
|
this.ensureExternalSaleNumber(nextTempOrder);
|
|
@@ -8357,18 +8994,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8357
8994
|
var segments = [];
|
|
8358
8995
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
8359
8996
|
if (Array.isArray(sku.variant)) {
|
|
8360
|
-
var
|
|
8361
|
-
|
|
8997
|
+
var _iterator32 = _createForOfIteratorHelper(sku.variant),
|
|
8998
|
+
_step32;
|
|
8362
8999
|
try {
|
|
8363
|
-
for (
|
|
8364
|
-
var variant =
|
|
9000
|
+
for (_iterator32.s(); !(_step32 = _iterator32.n()).done;) {
|
|
9001
|
+
var variant = _step32.value;
|
|
8365
9002
|
var segment = this.formatHydratedNamePair(variant === null || variant === void 0 ? void 0 : variant.group, variant === null || variant === void 0 ? void 0 : variant.item);
|
|
8366
9003
|
if (segment) segments.push(segment);
|
|
8367
9004
|
}
|
|
8368
9005
|
} catch (err) {
|
|
8369
|
-
|
|
9006
|
+
_iterator32.e(err);
|
|
8370
9007
|
} finally {
|
|
8371
|
-
|
|
9008
|
+
_iterator32.f();
|
|
8372
9009
|
}
|
|
8373
9010
|
}
|
|
8374
9011
|
return segments.join(', ');
|
|
@@ -8396,7 +9033,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8396
9033
|
}, {
|
|
8397
9034
|
key: "normalizeHydratedOrderProduct",
|
|
8398
9035
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
8399
|
-
var
|
|
9036
|
+
var _this56 = this;
|
|
8400
9037
|
var row = _objectSpread({}, product || {});
|
|
8401
9038
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
8402
9039
|
row.num = row.product_quantity;
|
|
@@ -8404,7 +9041,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8404
9041
|
var productSku = ensureProductSku(row);
|
|
8405
9042
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
8406
9043
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
8407
|
-
return
|
|
9044
|
+
return _this56.normalizeHydratedProductOptionItem(optionItem || {});
|
|
8408
9045
|
}))
|
|
8409
9046
|
});
|
|
8410
9047
|
delete row["product_".concat('option', "_item")];
|
|
@@ -8464,27 +9101,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8464
9101
|
}, {
|
|
8465
9102
|
key: "getOrderInfo",
|
|
8466
9103
|
value: function () {
|
|
8467
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9104
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(order_id) {
|
|
8468
9105
|
var res;
|
|
8469
|
-
return _regeneratorRuntime().wrap(function
|
|
8470
|
-
while (1) switch (
|
|
9106
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context66) {
|
|
9107
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
8471
9108
|
case 0:
|
|
8472
|
-
|
|
9109
|
+
_context66.next = 2;
|
|
8473
9110
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
8474
9111
|
with: ['products', 'bookings', 'notes']
|
|
8475
9112
|
}, {
|
|
8476
9113
|
osServer: true
|
|
8477
9114
|
});
|
|
8478
9115
|
case 2:
|
|
8479
|
-
res =
|
|
8480
|
-
return
|
|
9116
|
+
res = _context66.sent;
|
|
9117
|
+
return _context66.abrupt("return", res);
|
|
8481
9118
|
case 4:
|
|
8482
9119
|
case "end":
|
|
8483
|
-
return
|
|
9120
|
+
return _context66.stop();
|
|
8484
9121
|
}
|
|
8485
|
-
},
|
|
9122
|
+
}, _callee61, this);
|
|
8486
9123
|
}));
|
|
8487
|
-
function getOrderInfo(
|
|
9124
|
+
function getOrderInfo(_x74) {
|
|
8488
9125
|
return _getOrderInfo.apply(this, arguments);
|
|
8489
9126
|
}
|
|
8490
9127
|
return getOrderInfo;
|
|
@@ -8492,8 +9129,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8492
9129
|
}, {
|
|
8493
9130
|
key: "getVouchers",
|
|
8494
9131
|
value: function getVouchers() {
|
|
8495
|
-
var _this$store$
|
|
8496
|
-
return ((_this$store$
|
|
9132
|
+
var _this$store$tempOrder11;
|
|
9133
|
+
return ((_this$store$tempOrder11 = this.store.tempOrder) === null || _this$store$tempOrder11 === void 0 ? void 0 : _this$store$tempOrder11.vouchers) || [];
|
|
8497
9134
|
}
|
|
8498
9135
|
}], [{
|
|
8499
9136
|
key: "populateSavedAmounts",
|
|
@@ -8520,69 +9157,69 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8520
9157
|
addDiscountAmount(savedMap, discountKey, amount);
|
|
8521
9158
|
addDiscountAmount(isPersistedProduct || discount.order_discount_id != null ? editModeSavedMap : runtimeSavedMap, discountKey, amount);
|
|
8522
9159
|
};
|
|
8523
|
-
var
|
|
8524
|
-
|
|
9160
|
+
var _iterator33 = _createForOfIteratorHelper(productList),
|
|
9161
|
+
_step33;
|
|
8525
9162
|
try {
|
|
8526
|
-
for (
|
|
8527
|
-
var product =
|
|
9163
|
+
for (_iterator33.s(); !(_step33 = _iterator33.n()).done;) {
|
|
9164
|
+
var product = _step33.value;
|
|
8528
9165
|
var qty = product.num || 1;
|
|
8529
9166
|
var isPersistedProduct = Boolean(product.order_detail_id || product.orderDetailId || product.booking_id);
|
|
8530
|
-
var
|
|
8531
|
-
|
|
9167
|
+
var _iterator35 = _createForOfIteratorHelper(product.discount_list || []),
|
|
9168
|
+
_step35;
|
|
8532
9169
|
try {
|
|
8533
|
-
for (
|
|
8534
|
-
var pd =
|
|
9170
|
+
for (_iterator35.s(); !(_step35 = _iterator35.n()).done;) {
|
|
9171
|
+
var pd = _step35.value;
|
|
8535
9172
|
addProductDiscountAmount(pd, qty, isPersistedProduct);
|
|
8536
9173
|
}
|
|
8537
9174
|
} catch (err) {
|
|
8538
|
-
|
|
9175
|
+
_iterator35.e(err);
|
|
8539
9176
|
} finally {
|
|
8540
|
-
|
|
9177
|
+
_iterator35.f();
|
|
8541
9178
|
}
|
|
8542
|
-
var
|
|
8543
|
-
|
|
9179
|
+
var _iterator36 = _createForOfIteratorHelper(product.product_bundle || []),
|
|
9180
|
+
_step36;
|
|
8544
9181
|
try {
|
|
8545
|
-
for (
|
|
8546
|
-
var bundle =
|
|
9182
|
+
for (_iterator36.s(); !(_step36 = _iterator36.n()).done;) {
|
|
9183
|
+
var bundle = _step36.value;
|
|
8547
9184
|
var isPersistedBundleProduct = isPersistedProduct || Boolean((bundle === null || bundle === void 0 ? void 0 : bundle.order_detail_id) || (bundle === null || bundle === void 0 ? void 0 : bundle.orderDetailId) || (bundle === null || bundle === void 0 ? void 0 : bundle.booking_id));
|
|
8548
9185
|
var bundleQty = Number(qty) || 1;
|
|
8549
|
-
var
|
|
8550
|
-
|
|
9186
|
+
var _iterator37 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
9187
|
+
_step37;
|
|
8551
9188
|
try {
|
|
8552
|
-
for (
|
|
8553
|
-
var _pd =
|
|
9189
|
+
for (_iterator37.s(); !(_step37 = _iterator37.n()).done;) {
|
|
9190
|
+
var _pd = _step37.value;
|
|
8554
9191
|
addProductDiscountAmount(_pd, bundleQty, isPersistedBundleProduct);
|
|
8555
9192
|
}
|
|
8556
9193
|
} catch (err) {
|
|
8557
|
-
|
|
9194
|
+
_iterator37.e(err);
|
|
8558
9195
|
} finally {
|
|
8559
|
-
|
|
9196
|
+
_iterator37.f();
|
|
8560
9197
|
}
|
|
8561
9198
|
}
|
|
8562
9199
|
} catch (err) {
|
|
8563
|
-
|
|
9200
|
+
_iterator36.e(err);
|
|
8564
9201
|
} finally {
|
|
8565
|
-
|
|
9202
|
+
_iterator36.f();
|
|
8566
9203
|
}
|
|
8567
9204
|
}
|
|
8568
9205
|
} catch (err) {
|
|
8569
|
-
|
|
9206
|
+
_iterator33.e(err);
|
|
8570
9207
|
} finally {
|
|
8571
|
-
|
|
9208
|
+
_iterator33.f();
|
|
8572
9209
|
}
|
|
8573
|
-
var
|
|
8574
|
-
|
|
9210
|
+
var _iterator34 = _createForOfIteratorHelper(discountList),
|
|
9211
|
+
_step34;
|
|
8575
9212
|
try {
|
|
8576
|
-
for (
|
|
8577
|
-
var d =
|
|
9213
|
+
for (_iterator34.s(); !(_step34 = _iterator34.n()).done;) {
|
|
9214
|
+
var d = _step34.value;
|
|
8578
9215
|
var key = d.id;
|
|
8579
9216
|
var sourceMap = d.isEditMode ? editModeSavedMap : editModeDiscountKeys.has(key) ? runtimeSavedMap : savedMap;
|
|
8580
9217
|
d.savedAmount = d.isSelected && key != null && sourceMap.has(key) ? sourceMap.get(key).toNumber() : 0;
|
|
8581
9218
|
}
|
|
8582
9219
|
} catch (err) {
|
|
8583
|
-
|
|
9220
|
+
_iterator34.e(err);
|
|
8584
9221
|
} finally {
|
|
8585
|
-
|
|
9222
|
+
_iterator34.f();
|
|
8586
9223
|
}
|
|
8587
9224
|
}
|
|
8588
9225
|
}]);
|