@pisell/pisellos 2.3.232 → 2.3.233
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Customer/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +9 -0
- package/dist/modules/Order/index.js +1350 -1133
- package/dist/modules/Order/types.d.ts +3 -0
- package/dist/modules/Order/utils/bookingUuid.d.ts +4 -0
- package/dist/modules/Order/utils/bookingUuid.js +24 -0
- package/dist/modules/Order/utils/virtualSettlement.d.ts +4 -0
- package/dist/modules/Order/utils/virtualSettlement.js +13 -0
- package/dist/modules/Order/utils.js +11 -6
- package/dist/shared/payment/loadPaymentMethods.d.ts +4 -1
- package/dist/shared/payment/loadPaymentMethods.js +35 -2
- package/dist/solution/BaseSales/index.d.ts +1 -0
- package/dist/solution/BaseSales/index.js +516 -423
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +1 -0
- package/dist/solution/Checkout/index.js +104 -69
- package/dist/solution/Checkout/types.d.ts +1 -0
- package/dist/solution/ScanOrder/index.js +10 -2
- package/dist/solution/VenueBooking/index.js +522 -490
- package/dist/utils/platform.d.ts +1 -0
- package/dist/utils/platform.js +4 -0
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/Customer/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +9 -0
- package/lib/modules/Order/index.js +141 -20
- package/lib/modules/Order/types.d.ts +3 -0
- package/lib/modules/Order/utils/bookingUuid.d.ts +4 -0
- package/lib/modules/Order/utils/bookingUuid.js +25 -0
- package/lib/modules/Order/utils/virtualSettlement.d.ts +4 -0
- package/lib/modules/Order/utils/virtualSettlement.js +9 -1
- package/lib/modules/Order/utils.js +13 -5
- package/lib/shared/payment/loadPaymentMethods.d.ts +4 -1
- package/lib/shared/payment/loadPaymentMethods.js +13 -0
- package/lib/solution/BaseSales/index.d.ts +1 -0
- package/lib/solution/BaseSales/index.js +49 -10
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +1 -0
- package/lib/solution/Checkout/index.js +21 -0
- package/lib/solution/Checkout/types.d.ts +1 -0
- package/lib/solution/ScanOrder/index.js +6 -0
- package/lib/solution/VenueBooking/index.js +6 -1
- package/lib/utils/platform.d.ts +1 -0
- package/lib/utils/platform.js +5 -0
- package/package.json +1 -1
|
@@ -31,6 +31,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
31
31
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
32
32
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
33
33
|
import { loadSalesOrderSnapshot } from "../../shared/sales/loadSalesOrderSnapshot";
|
|
34
|
+
import { assignBookingUuid, ensureBookingUuid } from "./utils/bookingUuid";
|
|
34
35
|
import { PAYMENT_REFRESH_MESSAGE, requiresLocalPaymentRefresh, stripLocalEftposState } from "./localEftposState";
|
|
35
36
|
import { BaseModule } from "../BaseModule";
|
|
36
37
|
import { OrderHooks } from "./types";
|
|
@@ -53,13 +54,28 @@ import { hasManualProductDiscountFlag, syncManualProductDiscountProductNum, buil
|
|
|
53
54
|
import { expandHydratedProductsForDiscountCollection, restoreHydratedBundleDiscounts } from "./utils/bundleDiscountHydration";
|
|
54
55
|
import { getOrderCollectionPersistentId, getOrderCollectionUid, normalizeOrderCollections, repairDuplicateProductLineIdentities as repairDuplicateOrderProductLineIdentities, setOrderCollectionUid } from "./utils/orderCollectionIdentity";
|
|
55
56
|
import { consolidateDiscountFreeProductLines, ensureUniqueProductLineUids } from "./utils/discountProductLineIdentity";
|
|
56
|
-
import { applyTempOrderSettlementState, getSelectedSettlementSnapshot, getSettlementKey, getTempOrderSettlementKey, getTempOrderSettlementSnapshot, isVirtualSettlementOrder, normalizeVirtualSettlementOrderProduct, normalizeVirtualSettlementProducts, OrderSettlementConflictError, releaseTempOrderSettlementState, VirtualCurrencyAssetNotFoundError, VirtualCurrencyBalanceError } from "./utils/virtualSettlement";
|
|
57
|
+
import { applyTempOrderSettlementState, getSelectedSettlementSnapshot, getSettlementKey, getTempOrderSettlementKey, getTempOrderSettlementSnapshot, isVirtualSettlementOrder, isVirtualSettlementProduct, normalizeVirtualSettlementOrderProduct, normalizeVirtualSettlementProducts, OrderSettlementConflictError, releaseTempOrderSettlementState, VirtualCurrencyAssetNotFoundError, VirtualCurrencyBalanceError } from "./utils/virtualSettlement";
|
|
58
|
+
import { loadPaymentMethods, requirePosVirtualCurrencyPaymentMethod } from "../../shared/payment/loadPaymentMethods";
|
|
59
|
+
import { isPosTerminalPlatform } from "../../utils/platform";
|
|
57
60
|
import { DiscountModule } from "../Discount";
|
|
58
61
|
import { RulesModule } from "../Rules";
|
|
59
62
|
import { isEntitlementPass, isFullCoveragePass } from "../Discount/entitlementPass";
|
|
60
63
|
import { UnavailableReason } from "../Rules/types";
|
|
61
64
|
import Decimal from 'decimal.js';
|
|
62
|
-
import { cloneDeep, isEqual } from 'lodash-es';
|
|
65
|
+
import { cloneDeep, isEqual, omit } from 'lodash-es';
|
|
66
|
+
var SUMMARY_LINE_FIELDS = ['tax_fee', 'original_tax_fee', 'tax_fee_rounding_remainder', 'original_tax_fee_rounding_remainder', 'surcharge_fee', 'surcharge_rounding_remainder', 'relation_surcharge_ids'];
|
|
67
|
+
var SUMMARY_LINE_METADATA_FIELDS = ['tax_fee_rounding_remainder', 'surcharge_rounding_remainder', 'relation_surcharge_ids'];
|
|
68
|
+
function getFixedGiftProductSnapshot(product) {
|
|
69
|
+
// 赠品预约等待期间,recalculateSummary 可以更新金额字段。赠品写回后会重新计算这些金额。
|
|
70
|
+
return _objectSpread(_objectSpread({}, omit(product, [].concat(SUMMARY_LINE_FIELDS, ['main_product_attached_bundle_tax_fee', 'main_product_attached_bundle_surcharge_fee', 'payment_price', 'deposit']))), {}, {
|
|
71
|
+
metadata: omit(product.metadata, [].concat(SUMMARY_LINE_METADATA_FIELDS, ['main_product_attached_bundle_tax_fee', 'main_product_attached_bundle_surcharge_fee', 'main_product_attached_bundle_selling_price', 'main_product_attached_bundle_payment_price', 'average_discount_amount_rate'])),
|
|
72
|
+
product_bundle: Array.isArray(product.product_bundle) ? product.product_bundle.map(function (bundle) {
|
|
73
|
+
return _objectSpread(_objectSpread({}, omit(bundle, [].concat(SUMMARY_LINE_FIELDS, ['bundle_payment_price']))), {}, {
|
|
74
|
+
metadata: omit(bundle === null || bundle === void 0 ? void 0 : bundle.metadata, [].concat(SUMMARY_LINE_METADATA_FIELDS, ['surcharge_fee']))
|
|
75
|
+
});
|
|
76
|
+
}) : product.product_bundle
|
|
77
|
+
});
|
|
78
|
+
}
|
|
63
79
|
function normalizeDiscountListSignature(discountList) {
|
|
64
80
|
return (discountList || []).map(function (item) {
|
|
65
81
|
var _item$type, _item$discount_id, _item$order_discount_;
|
|
@@ -188,6 +204,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
188
204
|
_defineProperty(_assertThisInitialized(_this), "moduleHooksOverride", void 0);
|
|
189
205
|
_defineProperty(_assertThisInitialized(_this), "orderHooks", void 0);
|
|
190
206
|
_defineProperty(_assertThisInitialized(_this), "cartCommandQueue", Promise.resolve());
|
|
207
|
+
_defineProperty(_assertThisInitialized(_this), "posVirtualPaymentRevision", 0);
|
|
208
|
+
_defineProperty(_assertThisInitialized(_this), "posVirtualPaymentSnapshot", void 0);
|
|
191
209
|
_defineProperty(_assertThisInitialized(_this), "otherParams", void 0);
|
|
192
210
|
// ─── 促销/赠品 ────────────────────────────────────
|
|
193
211
|
/** 评估器引用;由 SalesSdkProvider 注入,未注入时 applyPromotion 静默跳过 */
|
|
@@ -1481,56 +1499,56 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1481
1499
|
_tempOrder$_extend4,
|
|
1482
1500
|
_this$promotionEvalua,
|
|
1483
1501
|
_this$promotionEvalua2;
|
|
1484
|
-
var tempOrder, isCurrentOrder, previousFixedGiftQuotas, strategyConfigs, _nextOrder$bookings, _tempOrder$bookings, _tempOrder$_extend5, result, nextOrder, publishGiftChanges, removeSet, removed, _iterator5, _step5, product, removedBookings, _iterator6, _step6, reduce, _iterator10, _step10,
|
|
1485
|
-
return _regeneratorRuntime().wrap(function _callee10$(
|
|
1486
|
-
while (1) switch (
|
|
1502
|
+
var tempOrder, isCurrentOrder, previousFixedGiftQuotas, strategyConfigs, _nextOrder$bookings, _tempOrder$bookings, _tempOrder$_extend5, result, nextOrder, publishGiftChanges, removeSet, removed, _iterator5, _step5, product, removedBookings, _iterator6, _step6, reduce, _iterator10, _step10, _loop3, giftSelectResolver, _iterator7, _step7, _loop, _ret, fixedGiftQuotas, payload;
|
|
1503
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context13) {
|
|
1504
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1487
1505
|
case 0:
|
|
1488
1506
|
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
1489
|
-
|
|
1507
|
+
_context13.next = 2;
|
|
1490
1508
|
break;
|
|
1491
1509
|
}
|
|
1492
|
-
return
|
|
1510
|
+
return _context13.abrupt("return", null);
|
|
1493
1511
|
case 2:
|
|
1494
1512
|
if (!(this.isApplyingPromotion || this.isEmittingPromotionApplied)) {
|
|
1495
|
-
|
|
1513
|
+
_context13.next = 4;
|
|
1496
1514
|
break;
|
|
1497
1515
|
}
|
|
1498
|
-
return
|
|
1516
|
+
return _context13.abrupt("return", null);
|
|
1499
1517
|
case 4:
|
|
1500
1518
|
if (this.promotionEvaluator) {
|
|
1501
|
-
|
|
1519
|
+
_context13.next = 6;
|
|
1502
1520
|
break;
|
|
1503
1521
|
}
|
|
1504
|
-
return
|
|
1522
|
+
return _context13.abrupt("return", null);
|
|
1505
1523
|
case 6:
|
|
1506
1524
|
tempOrder = this.store.tempOrder;
|
|
1507
1525
|
if (tempOrder) {
|
|
1508
|
-
|
|
1526
|
+
_context13.next = 9;
|
|
1509
1527
|
break;
|
|
1510
1528
|
}
|
|
1511
|
-
return
|
|
1529
|
+
return _context13.abrupt("return", null);
|
|
1512
1530
|
case 9:
|
|
1513
1531
|
isCurrentOrder = function isCurrentOrder() {
|
|
1514
1532
|
var _options$isCurrentOrd, _options$isCurrentOrd2;
|
|
1515
1533
|
return _this9.store.tempOrder === tempOrder && ((_options$isCurrentOrd = options === null || options === void 0 || (_options$isCurrentOrd2 = options.isCurrentOrder) === null || _options$isCurrentOrd2 === void 0 ? void 0 : _options$isCurrentOrd2.call(options)) !== null && _options$isCurrentOrd !== void 0 ? _options$isCurrentOrd : true);
|
|
1516
1534
|
};
|
|
1517
1535
|
if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
|
|
1518
|
-
|
|
1536
|
+
_context13.next = 13;
|
|
1519
1537
|
break;
|
|
1520
1538
|
}
|
|
1521
1539
|
tempOrder.products = normalizeVirtualSettlementProducts(tempOrder.products);
|
|
1522
|
-
return
|
|
1540
|
+
return _context13.abrupt("return", null);
|
|
1523
1541
|
case 13:
|
|
1524
1542
|
previousFixedGiftQuotas = ((_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.fixedGiftQuotas) || [];
|
|
1525
1543
|
strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
|
|
1526
1544
|
if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0 && !previousFixedGiftQuotas.length)) {
|
|
1527
|
-
|
|
1545
|
+
_context13.next = 17;
|
|
1528
1546
|
break;
|
|
1529
1547
|
}
|
|
1530
|
-
return
|
|
1548
|
+
return _context13.abrupt("return", null);
|
|
1531
1549
|
case 17:
|
|
1532
1550
|
this.isApplyingPromotion = true;
|
|
1533
|
-
|
|
1551
|
+
_context13.prev = 18;
|
|
1534
1552
|
result = processCartPromotion(tempOrder.products, this.promotionEvaluator, {
|
|
1535
1553
|
previousFixedGiftQuotas: previousFixedGiftQuotas
|
|
1536
1554
|
});
|
|
@@ -1567,20 +1585,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1567
1585
|
}
|
|
1568
1586
|
removedBookings = ((_nextOrder$bookings = nextOrder.bookings) === null || _nextOrder$bookings === void 0 ? void 0 : _nextOrder$bookings.length) !== ((_tempOrder$bookings = tempOrder.bookings) === null || _tempOrder$bookings === void 0 ? void 0 : _tempOrder$bookings.length); // step 2: toReduce —— 调整数量
|
|
1569
1587
|
_iterator6 = _createForOfIteratorHelper(result.giftActions.toReduce);
|
|
1570
|
-
|
|
1588
|
+
_context13.prev = 25;
|
|
1571
1589
|
_iterator6.s();
|
|
1572
1590
|
case 27:
|
|
1573
1591
|
if ((_step6 = _iterator6.n()).done) {
|
|
1574
|
-
|
|
1592
|
+
_context13.next = 47;
|
|
1575
1593
|
break;
|
|
1576
1594
|
}
|
|
1577
1595
|
reduce = _step6.value;
|
|
1578
1596
|
_iterator10 = _createForOfIteratorHelper(reduce.items);
|
|
1579
|
-
|
|
1580
|
-
|
|
1597
|
+
_context13.prev = 30;
|
|
1598
|
+
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
1581
1599
|
var item, productIndex;
|
|
1582
|
-
return _regeneratorRuntime().wrap(function
|
|
1583
|
-
while (1) switch (
|
|
1600
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context12) {
|
|
1601
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1584
1602
|
case 0:
|
|
1585
1603
|
item = _step10.value;
|
|
1586
1604
|
productIndex = nextOrder.products.findIndex(function (p) {
|
|
@@ -1593,54 +1611,54 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1593
1611
|
}
|
|
1594
1612
|
case 3:
|
|
1595
1613
|
case "end":
|
|
1596
|
-
return
|
|
1614
|
+
return _context12.stop();
|
|
1597
1615
|
}
|
|
1598
|
-
},
|
|
1616
|
+
}, _loop3);
|
|
1599
1617
|
});
|
|
1600
1618
|
_iterator10.s();
|
|
1601
1619
|
case 33:
|
|
1602
1620
|
if ((_step10 = _iterator10.n()).done) {
|
|
1603
|
-
|
|
1621
|
+
_context13.next = 37;
|
|
1604
1622
|
break;
|
|
1605
1623
|
}
|
|
1606
|
-
return
|
|
1624
|
+
return _context13.delegateYield(_loop3(), "t0", 35);
|
|
1607
1625
|
case 35:
|
|
1608
|
-
|
|
1626
|
+
_context13.next = 33;
|
|
1609
1627
|
break;
|
|
1610
1628
|
case 37:
|
|
1611
|
-
|
|
1629
|
+
_context13.next = 42;
|
|
1612
1630
|
break;
|
|
1613
1631
|
case 39:
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
_iterator10.e(
|
|
1632
|
+
_context13.prev = 39;
|
|
1633
|
+
_context13.t1 = _context13["catch"](30);
|
|
1634
|
+
_iterator10.e(_context13.t1);
|
|
1617
1635
|
case 42:
|
|
1618
|
-
|
|
1636
|
+
_context13.prev = 42;
|
|
1619
1637
|
_iterator10.f();
|
|
1620
|
-
return
|
|
1638
|
+
return _context13.finish(42);
|
|
1621
1639
|
case 45:
|
|
1622
|
-
|
|
1640
|
+
_context13.next = 27;
|
|
1623
1641
|
break;
|
|
1624
1642
|
case 47:
|
|
1625
|
-
|
|
1643
|
+
_context13.next = 52;
|
|
1626
1644
|
break;
|
|
1627
1645
|
case 49:
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
_iterator6.e(
|
|
1646
|
+
_context13.prev = 49;
|
|
1647
|
+
_context13.t2 = _context13["catch"](25);
|
|
1648
|
+
_iterator6.e(_context13.t2);
|
|
1631
1649
|
case 52:
|
|
1632
|
-
|
|
1650
|
+
_context13.prev = 52;
|
|
1633
1651
|
_iterator6.f();
|
|
1634
|
-
return
|
|
1652
|
+
return _context13.finish(52);
|
|
1635
1653
|
case 55:
|
|
1636
1654
|
// step 3: toAdd —— 补赠品
|
|
1637
1655
|
giftSelectResolver = this.giftSelectResolver;
|
|
1638
1656
|
if (!(result.giftActions.toAdd.length > 0)) {
|
|
1639
|
-
|
|
1657
|
+
_context13.next = 81;
|
|
1640
1658
|
break;
|
|
1641
1659
|
}
|
|
1642
1660
|
if (giftSelectResolver) {
|
|
1643
|
-
|
|
1661
|
+
_context13.next = 61;
|
|
1644
1662
|
break;
|
|
1645
1663
|
}
|
|
1646
1664
|
if (result.giftActions.toAdd.some(function (g) {
|
|
@@ -1651,231 +1669,245 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1651
1669
|
} else {
|
|
1652
1670
|
console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
|
|
1653
1671
|
}
|
|
1654
|
-
|
|
1672
|
+
_context13.next = 81;
|
|
1655
1673
|
break;
|
|
1656
1674
|
case 61:
|
|
1657
1675
|
if (result.giftActions.toRemove.length || result.giftActions.toReduce.length) {
|
|
1658
1676
|
publishGiftChanges();
|
|
1659
1677
|
}
|
|
1660
1678
|
_iterator7 = _createForOfIteratorHelper(result.giftActions.toAdd);
|
|
1661
|
-
|
|
1662
|
-
_iterator7.s();
|
|
1663
|
-
case 65:
|
|
1664
|
-
if ((_step7 = _iterator7.n()).done) {
|
|
1665
|
-
_context12.next = 146;
|
|
1666
|
-
break;
|
|
1667
|
-
}
|
|
1668
|
-
addAction = _step7.value;
|
|
1669
|
-
// 唯一候选也可能有规格/套餐。每次补赠都交给 SDK 判断,不能复用旧赠品的选择。
|
|
1670
|
-
_fixedGiftQuotas = addAction.giftQuotas;
|
|
1671
|
-
giftMutationBaseline = options !== null && options !== void 0 && options.isCurrentOrder || _fixedGiftQuotas ? cloneDeep({
|
|
1672
|
-
products: tempOrder.products,
|
|
1673
|
-
bookings: tempOrder.bookings
|
|
1674
|
-
}) : null;
|
|
1675
|
-
_context12.prev = 69;
|
|
1676
|
-
inventoryProducts = _fixedGiftQuotas ? nextOrder.products : tempOrder.products;
|
|
1677
|
-
_context12.next = 73;
|
|
1678
|
-
return giftSelectResolver(_objectSpread(_objectSpread({}, addAction), {}, {
|
|
1679
|
-
inventoryReserved: inventoryProducts.map(function (line) {
|
|
1680
|
-
return {
|
|
1681
|
-
product_id: Number(line.product_id),
|
|
1682
|
-
product_variant_id: Number(line.product_variant_id || 0),
|
|
1683
|
-
quantity: Number(line.num) || 0
|
|
1684
|
-
};
|
|
1685
|
-
})
|
|
1686
|
-
}));
|
|
1687
|
-
case 73:
|
|
1688
|
-
giftResult = _context12.sent;
|
|
1689
|
-
if (isCurrentOrder()) {
|
|
1690
|
-
_context12.next = 76;
|
|
1691
|
-
break;
|
|
1692
|
-
}
|
|
1693
|
-
return _context12.abrupt("return", null);
|
|
1694
|
-
case 76:
|
|
1695
|
-
if (!(giftMutationBaseline && !isEqual({
|
|
1696
|
-
products: tempOrder.products,
|
|
1697
|
-
bookings: tempOrder.bookings
|
|
1698
|
-
}, giftMutationBaseline))) {
|
|
1699
|
-
_context12.next = 78;
|
|
1700
|
-
break;
|
|
1701
|
-
}
|
|
1702
|
-
return _context12.abrupt("return", null);
|
|
1703
|
-
case 78:
|
|
1704
|
-
giftProducts = Array.isArray(giftResult) ? giftResult : giftResult === null || giftResult === void 0 ? void 0 : giftResult.products;
|
|
1705
|
-
giftBookings = Array.isArray(giftResult) ? [] : (giftResult === null || giftResult === void 0 ? void 0 : giftResult.bookings) || [];
|
|
1706
|
-
if (!(Array.isArray(giftProducts) && giftProducts.length > 0)) {
|
|
1707
|
-
_context12.next = 135;
|
|
1708
|
-
break;
|
|
1709
|
-
}
|
|
1710
|
-
if (!_fixedGiftQuotas) {
|
|
1711
|
-
_context12.next = 99;
|
|
1712
|
-
break;
|
|
1713
|
-
}
|
|
1714
|
-
selectedCounts = new Map();
|
|
1715
|
-
_iterator8 = _createForOfIteratorHelper(giftProducts);
|
|
1716
|
-
_context12.prev = 84;
|
|
1679
|
+
_context13.prev = 63;
|
|
1717
1680
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
1718
|
-
var
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
1681
|
+
var addAction, fixedGiftQuotas, getGiftMutationState, giftMutationBaseline, isGiftDraftCurrent, inventoryProducts, giftResult, giftProducts, giftBookings, selectedCounts, _iterator8, _step8, _loop2, fixedBookingsByProduct, products, bookings, _iterator9, _step9, _gp$metadata, _step9$value, index, gp, productUid, booking, linked;
|
|
1682
|
+
return _regeneratorRuntime().wrap(function _loop$(_context11) {
|
|
1683
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1722
1684
|
case 0:
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1685
|
+
addAction = _step7.value;
|
|
1686
|
+
// 唯一候选也可能有规格/套餐。每次补赠都交给 SDK 判断,不能复用旧赠品的选择。
|
|
1687
|
+
fixedGiftQuotas = addAction.giftQuotas;
|
|
1688
|
+
getGiftMutationState = function getGiftMutationState() {
|
|
1689
|
+
return _objectSpread({
|
|
1690
|
+
products: fixedGiftQuotas ? tempOrder.products.map(getFixedGiftProductSnapshot) : tempOrder.products,
|
|
1691
|
+
bookings: tempOrder.bookings
|
|
1692
|
+
}, fixedGiftQuotas && {
|
|
1693
|
+
holderRelations: tempOrder.holder_relations,
|
|
1694
|
+
shopDiscount: tempOrder.shop_discount
|
|
1695
|
+
});
|
|
1696
|
+
};
|
|
1697
|
+
giftMutationBaseline = options !== null && options !== void 0 && options.isCurrentOrder || fixedGiftQuotas ? cloneDeep(getGiftMutationState()) : null;
|
|
1698
|
+
isGiftDraftCurrent = function isGiftDraftCurrent() {
|
|
1699
|
+
return isCurrentOrder() && (!giftMutationBaseline || isEqual(getGiftMutationState(), giftMutationBaseline));
|
|
1700
|
+
};
|
|
1701
|
+
_context11.prev = 5;
|
|
1702
|
+
inventoryProducts = fixedGiftQuotas ? nextOrder.products : tempOrder.products;
|
|
1703
|
+
_context11.next = 9;
|
|
1704
|
+
return giftSelectResolver(_objectSpread(_objectSpread({}, addAction), {}, {
|
|
1705
|
+
inventoryReserved: inventoryProducts.map(function (line) {
|
|
1706
|
+
return {
|
|
1707
|
+
product_id: Number(line.product_id),
|
|
1708
|
+
product_variant_id: Number(line.product_variant_id || 0),
|
|
1709
|
+
quantity: Number(line.num) || 0
|
|
1710
|
+
};
|
|
1711
|
+
})
|
|
1712
|
+
}));
|
|
1713
|
+
case 9:
|
|
1714
|
+
giftResult = _context11.sent;
|
|
1715
|
+
if (isGiftDraftCurrent()) {
|
|
1716
|
+
_context11.next = 12;
|
|
1717
|
+
break;
|
|
1718
|
+
}
|
|
1719
|
+
return _context11.abrupt("return", {
|
|
1720
|
+
v: null
|
|
1727
1721
|
});
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1722
|
+
case 12:
|
|
1723
|
+
giftProducts = Array.isArray(giftResult) ? giftResult : giftResult === null || giftResult === void 0 ? void 0 : giftResult.products;
|
|
1724
|
+
giftBookings = Array.isArray(giftResult) ? [] : (giftResult === null || giftResult === void 0 ? void 0 : giftResult.bookings) || [];
|
|
1725
|
+
if (!(Array.isArray(giftProducts) && giftProducts.length > 0)) {
|
|
1726
|
+
_context11.next = 69;
|
|
1732
1727
|
break;
|
|
1733
1728
|
}
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1729
|
+
if (!fixedGiftQuotas) {
|
|
1730
|
+
_context11.next = 33;
|
|
1731
|
+
break;
|
|
1732
|
+
}
|
|
1733
|
+
selectedCounts = new Map();
|
|
1734
|
+
_iterator8 = _createForOfIteratorHelper(giftProducts);
|
|
1735
|
+
_context11.prev = 18;
|
|
1736
|
+
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
1737
|
+
var _selectedCounts$get, _product$metadata3;
|
|
1738
|
+
var product, productId, quota, quantity, count;
|
|
1739
|
+
return _regeneratorRuntime().wrap(function _loop2$(_context10) {
|
|
1740
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1741
|
+
case 0:
|
|
1742
|
+
product = _step8.value;
|
|
1743
|
+
productId = Number(product === null || product === void 0 ? void 0 : product.product_id);
|
|
1744
|
+
quota = fixedGiftQuotas.find(function (item) {
|
|
1745
|
+
return item.product_id === productId;
|
|
1746
|
+
});
|
|
1747
|
+
quantity = Number(product === null || product === void 0 ? void 0 : product.num);
|
|
1748
|
+
count = ((_selectedCounts$get = selectedCounts.get(productId)) !== null && _selectedCounts$get !== void 0 ? _selectedCounts$get : 0) + quantity;
|
|
1749
|
+
if (!(!quota || quota.product_variant_id !== 0 && Number(product === null || product === void 0 ? void 0 : product.product_variant_id) !== quota.product_variant_id || !Number.isSafeInteger(quantity) || quantity <= 0 || count > quota.quantity || (product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 || (_product$metadata3 = _product$metadata3._giftInfo) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.strategyId) !== addAction.strategyId)) {
|
|
1750
|
+
_context10.next = 7;
|
|
1751
|
+
break;
|
|
1752
|
+
}
|
|
1753
|
+
throw new Error('Gift selection does not match the fixed gift allowance');
|
|
1754
|
+
case 7:
|
|
1755
|
+
selectedCounts.set(productId, count);
|
|
1756
|
+
case 8:
|
|
1757
|
+
case "end":
|
|
1758
|
+
return _context10.stop();
|
|
1759
|
+
}
|
|
1760
|
+
}, _loop2);
|
|
1761
|
+
});
|
|
1762
|
+
_iterator8.s();
|
|
1763
|
+
case 21:
|
|
1764
|
+
if ((_step8 = _iterator8.n()).done) {
|
|
1765
|
+
_context11.next = 25;
|
|
1766
|
+
break;
|
|
1767
|
+
}
|
|
1768
|
+
return _context11.delegateYield(_loop2(), "t0", 23);
|
|
1769
|
+
case 23:
|
|
1770
|
+
_context11.next = 21;
|
|
1771
|
+
break;
|
|
1772
|
+
case 25:
|
|
1773
|
+
_context11.next = 30;
|
|
1774
|
+
break;
|
|
1775
|
+
case 27:
|
|
1776
|
+
_context11.prev = 27;
|
|
1777
|
+
_context11.t1 = _context11["catch"](18);
|
|
1778
|
+
_iterator8.e(_context11.t1);
|
|
1779
|
+
case 30:
|
|
1780
|
+
_context11.prev = 30;
|
|
1781
|
+
_iterator8.f();
|
|
1782
|
+
return _context11.finish(30);
|
|
1783
|
+
case 33:
|
|
1784
|
+
fixedBookingsByProduct = fixedGiftQuotas ? new Map(giftBookings.filter(function (booking) {
|
|
1785
|
+
return booking === null || booking === void 0 ? void 0 : booking.product_uid;
|
|
1786
|
+
}).map(function (booking) {
|
|
1787
|
+
return [String(booking.product_uid), booking];
|
|
1788
|
+
})) : null;
|
|
1789
|
+
products = [];
|
|
1790
|
+
bookings = [];
|
|
1791
|
+
_iterator9 = _createForOfIteratorHelper(giftProducts.entries());
|
|
1792
|
+
_context11.prev = 37;
|
|
1793
|
+
_iterator9.s();
|
|
1794
|
+
case 39:
|
|
1795
|
+
if ((_step9 = _iterator9.n()).done) {
|
|
1796
|
+
_context11.next = 56;
|
|
1797
|
+
break;
|
|
1798
|
+
}
|
|
1799
|
+
_step9$value = _slicedToArray(_step9.value, 2), index = _step9$value[0], gp = _step9$value[1];
|
|
1800
|
+
if (gp) {
|
|
1801
|
+
_context11.next = 43;
|
|
1802
|
+
break;
|
|
1803
|
+
}
|
|
1804
|
+
return _context11.abrupt("continue", 54);
|
|
1805
|
+
case 43:
|
|
1806
|
+
productUid = getPromotionUid(gp);
|
|
1807
|
+
booking = fixedBookingsByProduct ? fixedBookingsByProduct.get(productUid) : giftBookings[index];
|
|
1808
|
+
if (!booking) {
|
|
1809
|
+
_context11.next = 51;
|
|
1810
|
+
break;
|
|
1811
|
+
}
|
|
1812
|
+
fixedBookingsByProduct === null || fixedBookingsByProduct === void 0 || fixedBookingsByProduct.delete(productUid);
|
|
1813
|
+
linked = _this9.createLinkedProductAndBooking({
|
|
1814
|
+
product: gp,
|
|
1815
|
+
booking: booking
|
|
1816
|
+
});
|
|
1817
|
+
products.push(linked.product);
|
|
1818
|
+
bookings.push(linked.booking);
|
|
1819
|
+
return _context11.abrupt("continue", 54);
|
|
1820
|
+
case 51:
|
|
1821
|
+
if (!(fixedBookingsByProduct && (_gp$metadata = gp.metadata) !== null && _gp$metadata !== void 0 && _gp$metadata.booking_uid)) {
|
|
1822
|
+
_context11.next = 53;
|
|
1823
|
+
break;
|
|
1824
|
+
}
|
|
1825
|
+
throw new Error('Gift booking does not match its selected product');
|
|
1826
|
+
case 53:
|
|
1827
|
+
// normalize 略过:调用方应保证返回完整 OrderProduct。
|
|
1828
|
+
products.push(gp);
|
|
1829
|
+
case 54:
|
|
1830
|
+
_context11.next = 39;
|
|
1831
|
+
break;
|
|
1832
|
+
case 56:
|
|
1833
|
+
_context11.next = 61;
|
|
1834
|
+
break;
|
|
1835
|
+
case 58:
|
|
1836
|
+
_context11.prev = 58;
|
|
1837
|
+
_context11.t2 = _context11["catch"](37);
|
|
1838
|
+
_iterator9.e(_context11.t2);
|
|
1839
|
+
case 61:
|
|
1840
|
+
_context11.prev = 61;
|
|
1841
|
+
_iterator9.f();
|
|
1842
|
+
return _context11.finish(61);
|
|
1843
|
+
case 64:
|
|
1844
|
+
if (!(fixedBookingsByProduct && bookings.length !== giftBookings.length)) {
|
|
1845
|
+
_context11.next = 66;
|
|
1846
|
+
break;
|
|
1847
|
+
}
|
|
1848
|
+
throw new Error('Gift bookings do not match the selected products');
|
|
1849
|
+
case 66:
|
|
1850
|
+
nextOrder.products = [].concat(_toConsumableArray(nextOrder.products), products);
|
|
1851
|
+
if (bookings.length) nextOrder.bookings = [].concat(_toConsumableArray(nextOrder.bookings || []), bookings);
|
|
1852
|
+
// 下一场活动的赠品校验读取已更新的草稿。
|
|
1853
|
+
publishGiftChanges();
|
|
1854
|
+
case 69:
|
|
1855
|
+
_context11.next = 76;
|
|
1856
|
+
break;
|
|
1857
|
+
case 71:
|
|
1858
|
+
_context11.prev = 71;
|
|
1859
|
+
_context11.t3 = _context11["catch"](5);
|
|
1860
|
+
if (isGiftDraftCurrent()) {
|
|
1861
|
+
_context11.next = 75;
|
|
1862
|
+
break;
|
|
1863
|
+
}
|
|
1864
|
+
return _context11.abrupt("return", {
|
|
1865
|
+
v: null
|
|
1866
|
+
});
|
|
1867
|
+
case 75:
|
|
1868
|
+
// 用户取消 / 选择失败 → 视为放弃本次新增
|
|
1869
|
+
console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context11.t3);
|
|
1870
|
+
case 76:
|
|
1738
1871
|
case "end":
|
|
1739
|
-
return
|
|
1872
|
+
return _context11.stop();
|
|
1740
1873
|
}
|
|
1741
|
-
}, _loop);
|
|
1742
|
-
});
|
|
1743
|
-
_iterator8.s();
|
|
1744
|
-
case 87:
|
|
1745
|
-
if ((_step8 = _iterator8.n()).done) {
|
|
1746
|
-
_context12.next = 91;
|
|
1747
|
-
break;
|
|
1748
|
-
}
|
|
1749
|
-
return _context12.delegateYield(_loop(), "t3", 89);
|
|
1750
|
-
case 89:
|
|
1751
|
-
_context12.next = 87;
|
|
1752
|
-
break;
|
|
1753
|
-
case 91:
|
|
1754
|
-
_context12.next = 96;
|
|
1755
|
-
break;
|
|
1756
|
-
case 93:
|
|
1757
|
-
_context12.prev = 93;
|
|
1758
|
-
_context12.t4 = _context12["catch"](84);
|
|
1759
|
-
_iterator8.e(_context12.t4);
|
|
1760
|
-
case 96:
|
|
1761
|
-
_context12.prev = 96;
|
|
1762
|
-
_iterator8.f();
|
|
1763
|
-
return _context12.finish(96);
|
|
1764
|
-
case 99:
|
|
1765
|
-
fixedBookingsByProduct = _fixedGiftQuotas ? new Map(giftBookings.filter(function (booking) {
|
|
1766
|
-
return booking === null || booking === void 0 ? void 0 : booking.product_uid;
|
|
1767
|
-
}).map(function (booking) {
|
|
1768
|
-
return [String(booking.product_uid), booking];
|
|
1769
|
-
})) : null;
|
|
1770
|
-
products = [];
|
|
1771
|
-
bookings = [];
|
|
1772
|
-
_iterator9 = _createForOfIteratorHelper(giftProducts.entries());
|
|
1773
|
-
_context12.prev = 103;
|
|
1774
|
-
_iterator9.s();
|
|
1775
|
-
case 105:
|
|
1776
|
-
if ((_step9 = _iterator9.n()).done) {
|
|
1777
|
-
_context12.next = 122;
|
|
1778
|
-
break;
|
|
1779
|
-
}
|
|
1780
|
-
_step9$value = _slicedToArray(_step9.value, 2), index = _step9$value[0], gp = _step9$value[1];
|
|
1781
|
-
if (gp) {
|
|
1782
|
-
_context12.next = 109;
|
|
1783
|
-
break;
|
|
1784
|
-
}
|
|
1785
|
-
return _context12.abrupt("continue", 120);
|
|
1786
|
-
case 109:
|
|
1787
|
-
productUid = getPromotionUid(gp);
|
|
1788
|
-
booking = fixedBookingsByProduct ? fixedBookingsByProduct.get(productUid) : giftBookings[index];
|
|
1789
|
-
if (!booking) {
|
|
1790
|
-
_context12.next = 117;
|
|
1791
|
-
break;
|
|
1792
|
-
}
|
|
1793
|
-
fixedBookingsByProduct === null || fixedBookingsByProduct === void 0 || fixedBookingsByProduct.delete(productUid);
|
|
1794
|
-
linked = this.createLinkedProductAndBooking({
|
|
1795
|
-
product: gp,
|
|
1796
|
-
booking: booking
|
|
1874
|
+
}, _loop, null, [[5, 71], [18, 27, 30, 33], [37, 58, 61, 64]]);
|
|
1797
1875
|
});
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
if (!(fixedBookingsByProduct && (_gp$metadata = gp.metadata) !== null && _gp$metadata !== void 0 && _gp$metadata.booking_uid)) {
|
|
1803
|
-
_context12.next = 119;
|
|
1804
|
-
break;
|
|
1805
|
-
}
|
|
1806
|
-
throw new Error('Gift booking does not match its selected product');
|
|
1807
|
-
case 119:
|
|
1808
|
-
// normalize 略过:调用方应保证返回完整 OrderProduct。
|
|
1809
|
-
products.push(gp);
|
|
1810
|
-
case 120:
|
|
1811
|
-
_context12.next = 105;
|
|
1812
|
-
break;
|
|
1813
|
-
case 122:
|
|
1814
|
-
_context12.next = 127;
|
|
1815
|
-
break;
|
|
1816
|
-
case 124:
|
|
1817
|
-
_context12.prev = 124;
|
|
1818
|
-
_context12.t5 = _context12["catch"](103);
|
|
1819
|
-
_iterator9.e(_context12.t5);
|
|
1820
|
-
case 127:
|
|
1821
|
-
_context12.prev = 127;
|
|
1822
|
-
_iterator9.f();
|
|
1823
|
-
return _context12.finish(127);
|
|
1824
|
-
case 130:
|
|
1825
|
-
if (!(fixedBookingsByProduct && bookings.length !== giftBookings.length)) {
|
|
1826
|
-
_context12.next = 132;
|
|
1827
|
-
break;
|
|
1828
|
-
}
|
|
1829
|
-
throw new Error('Gift bookings do not match the selected products');
|
|
1830
|
-
case 132:
|
|
1831
|
-
nextOrder.products = [].concat(_toConsumableArray(nextOrder.products), products);
|
|
1832
|
-
if (bookings.length) nextOrder.bookings = [].concat(_toConsumableArray(nextOrder.bookings || []), bookings);
|
|
1833
|
-
// 下一场活动的赠品校验读取已更新的草稿。
|
|
1834
|
-
publishGiftChanges();
|
|
1835
|
-
case 135:
|
|
1836
|
-
_context12.next = 144;
|
|
1837
|
-
break;
|
|
1838
|
-
case 137:
|
|
1839
|
-
_context12.prev = 137;
|
|
1840
|
-
_context12.t6 = _context12["catch"](69);
|
|
1841
|
-
if (isCurrentOrder()) {
|
|
1842
|
-
_context12.next = 141;
|
|
1876
|
+
_iterator7.s();
|
|
1877
|
+
case 66:
|
|
1878
|
+
if ((_step7 = _iterator7.n()).done) {
|
|
1879
|
+
_context13.next = 73;
|
|
1843
1880
|
break;
|
|
1844
1881
|
}
|
|
1845
|
-
return
|
|
1846
|
-
case
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
}, giftMutationBaseline))) {
|
|
1851
|
-
_context12.next = 143;
|
|
1882
|
+
return _context13.delegateYield(_loop(), "t3", 68);
|
|
1883
|
+
case 68:
|
|
1884
|
+
_ret = _context13.t3;
|
|
1885
|
+
if (!_ret) {
|
|
1886
|
+
_context13.next = 71;
|
|
1852
1887
|
break;
|
|
1853
1888
|
}
|
|
1854
|
-
return
|
|
1855
|
-
case
|
|
1856
|
-
|
|
1857
|
-
console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context12.t6);
|
|
1858
|
-
case 144:
|
|
1859
|
-
_context12.next = 65;
|
|
1889
|
+
return _context13.abrupt("return", _ret.v);
|
|
1890
|
+
case 71:
|
|
1891
|
+
_context13.next = 66;
|
|
1860
1892
|
break;
|
|
1861
|
-
case
|
|
1862
|
-
|
|
1893
|
+
case 73:
|
|
1894
|
+
_context13.next = 78;
|
|
1863
1895
|
break;
|
|
1864
|
-
case
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
_iterator7.e(
|
|
1868
|
-
case
|
|
1869
|
-
|
|
1896
|
+
case 75:
|
|
1897
|
+
_context13.prev = 75;
|
|
1898
|
+
_context13.t4 = _context13["catch"](63);
|
|
1899
|
+
_iterator7.e(_context13.t4);
|
|
1900
|
+
case 78:
|
|
1901
|
+
_context13.prev = 78;
|
|
1870
1902
|
_iterator7.f();
|
|
1871
|
-
return
|
|
1872
|
-
case
|
|
1903
|
+
return _context13.finish(78);
|
|
1904
|
+
case 81:
|
|
1873
1905
|
if (isCurrentOrder()) {
|
|
1874
|
-
|
|
1906
|
+
_context13.next = 83;
|
|
1875
1907
|
break;
|
|
1876
1908
|
}
|
|
1877
|
-
return
|
|
1878
|
-
case
|
|
1909
|
+
return _context13.abrupt("return", null);
|
|
1910
|
+
case 83:
|
|
1879
1911
|
publishGiftChanges();
|
|
1880
1912
|
fixedGiftQuotas = result.gifts.flatMap(function (_ref19) {
|
|
1881
1913
|
var strategyId = _ref19.strategyId,
|
|
@@ -1914,21 +1946,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1914
1946
|
}),
|
|
1915
1947
|
products: tempOrder.products
|
|
1916
1948
|
};
|
|
1917
|
-
return
|
|
1918
|
-
case
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
console.error('[OrderModule] applyPromotion failed',
|
|
1922
|
-
return
|
|
1923
|
-
case
|
|
1924
|
-
|
|
1949
|
+
return _context13.abrupt("return", payload);
|
|
1950
|
+
case 94:
|
|
1951
|
+
_context13.prev = 94;
|
|
1952
|
+
_context13.t5 = _context13["catch"](18);
|
|
1953
|
+
console.error('[OrderModule] applyPromotion failed', _context13.t5);
|
|
1954
|
+
return _context13.abrupt("return", null);
|
|
1955
|
+
case 98:
|
|
1956
|
+
_context13.prev = 98;
|
|
1925
1957
|
this.isApplyingPromotion = false;
|
|
1926
|
-
return
|
|
1927
|
-
case
|
|
1958
|
+
return _context13.finish(98);
|
|
1959
|
+
case 101:
|
|
1928
1960
|
case "end":
|
|
1929
|
-
return
|
|
1961
|
+
return _context13.stop();
|
|
1930
1962
|
}
|
|
1931
|
-
}, _callee10, this, [[18,
|
|
1963
|
+
}, _callee10, this, [[18, 94, 98, 101], [25, 49, 52, 55], [30, 39, 42, 45], [63, 75, 78, 81]]);
|
|
1932
1964
|
}));
|
|
1933
1965
|
function evaluatePromotion(_x11) {
|
|
1934
1966
|
return _evaluatePromotion.apply(this, arguments);
|
|
@@ -1958,29 +1990,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1958
1990
|
value: (function () {
|
|
1959
1991
|
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
1960
1992
|
var payload, tempOrder;
|
|
1961
|
-
return _regeneratorRuntime().wrap(function _callee11$(
|
|
1962
|
-
while (1) switch (
|
|
1993
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context14) {
|
|
1994
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1963
1995
|
case 0:
|
|
1964
|
-
|
|
1996
|
+
_context14.next = 2;
|
|
1965
1997
|
return this.evaluatePromotion();
|
|
1966
1998
|
case 2:
|
|
1967
|
-
payload =
|
|
1999
|
+
payload = _context14.sent;
|
|
1968
2000
|
if (payload) {
|
|
1969
|
-
|
|
2001
|
+
_context14.next = 5;
|
|
1970
2002
|
break;
|
|
1971
2003
|
}
|
|
1972
|
-
return
|
|
2004
|
+
return _context14.abrupt("return");
|
|
1973
2005
|
case 5:
|
|
1974
2006
|
tempOrder = this.store.tempOrder;
|
|
1975
2007
|
if (tempOrder) {
|
|
1976
|
-
|
|
2008
|
+
_context14.next = 8;
|
|
1977
2009
|
break;
|
|
1978
2010
|
}
|
|
1979
|
-
return
|
|
2011
|
+
return _context14.abrupt("return");
|
|
1980
2012
|
case 8:
|
|
1981
2013
|
this.applyDiscount();
|
|
1982
2014
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
1983
|
-
|
|
2015
|
+
_context14.next = 12;
|
|
1984
2016
|
return this.recalculateSummary({
|
|
1985
2017
|
createIfMissing: true
|
|
1986
2018
|
});
|
|
@@ -1989,7 +2021,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1989
2021
|
this.emitPromotionApplied(payload);
|
|
1990
2022
|
case 14:
|
|
1991
2023
|
case "end":
|
|
1992
|
-
return
|
|
2024
|
+
return _context14.stop();
|
|
1993
2025
|
}
|
|
1994
2026
|
}, _callee11, this);
|
|
1995
2027
|
}));
|
|
@@ -2254,24 +2286,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2254
2286
|
value: function () {
|
|
2255
2287
|
var _rollbackOrderReplacement = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(replacement) {
|
|
2256
2288
|
var discount, restore;
|
|
2257
|
-
return _regeneratorRuntime().wrap(function _callee12$(
|
|
2258
|
-
while (1) switch (
|
|
2289
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context15) {
|
|
2290
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
2259
2291
|
case 0:
|
|
2260
2292
|
if (!(this.orderReplacement !== replacement)) {
|
|
2261
|
-
|
|
2293
|
+
_context15.next = 2;
|
|
2262
2294
|
break;
|
|
2263
2295
|
}
|
|
2264
|
-
return
|
|
2296
|
+
return _context15.abrupt("return");
|
|
2265
2297
|
case 2:
|
|
2266
2298
|
Object.assign(this.store, replacement.state);
|
|
2267
2299
|
this.customerWalletPrepareConfigEpoch = replacement.walletEpoch;
|
|
2268
2300
|
this.pointCardSnapshotCodeCandidates = replacement.pointCardCandidates;
|
|
2269
2301
|
this.sessionStorageRestoreRecord = replacement.sessionStorageRestoreRecord;
|
|
2270
2302
|
discount = this.store.discount;
|
|
2271
|
-
|
|
2303
|
+
_context15.next = 9;
|
|
2272
2304
|
return Promise.allSettled([discount === null || discount === void 0 ? void 0 : discount.setOriginalDiscountList(replacement.originalDiscounts), discount === null || discount === void 0 ? void 0 : discount.setDiscountList(replacement.discounts)]);
|
|
2273
2305
|
case 9:
|
|
2274
|
-
restore =
|
|
2306
|
+
restore = _context15.sent;
|
|
2275
2307
|
if (restore.some(function (result) {
|
|
2276
2308
|
return result.status === 'rejected';
|
|
2277
2309
|
})) {
|
|
@@ -2280,7 +2312,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2280
2312
|
if (this.orderReplacement === replacement) this.orderReplacement = null;
|
|
2281
2313
|
case 12:
|
|
2282
2314
|
case "end":
|
|
2283
|
-
return
|
|
2315
|
+
return _context15.stop();
|
|
2284
2316
|
}
|
|
2285
2317
|
}, _callee12, this);
|
|
2286
2318
|
}));
|
|
@@ -2481,11 +2513,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2481
2513
|
key: "saveDraft",
|
|
2482
2514
|
value: function () {
|
|
2483
2515
|
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
2484
|
-
return _regeneratorRuntime().wrap(function _callee13$(
|
|
2485
|
-
while (1) switch (
|
|
2516
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context16) {
|
|
2517
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
2486
2518
|
case 0:
|
|
2487
2519
|
case "end":
|
|
2488
|
-
return
|
|
2520
|
+
return _context16.stop();
|
|
2489
2521
|
}
|
|
2490
2522
|
}, _callee13);
|
|
2491
2523
|
}));
|
|
@@ -2503,13 +2535,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2503
2535
|
key: "hydrateTempOrderFromLocalRecord",
|
|
2504
2536
|
value: function () {
|
|
2505
2537
|
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(record) {
|
|
2506
|
-
return _regeneratorRuntime().wrap(function _callee14$(
|
|
2507
|
-
while (1) switch (
|
|
2538
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context17) {
|
|
2539
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
2508
2540
|
case 0:
|
|
2509
|
-
return
|
|
2541
|
+
return _context17.abrupt("return", this.hydrateTempOrderFromRecord(record));
|
|
2510
2542
|
case 1:
|
|
2511
2543
|
case "end":
|
|
2512
|
-
return
|
|
2544
|
+
return _context17.stop();
|
|
2513
2545
|
}
|
|
2514
2546
|
}, _callee14, this);
|
|
2515
2547
|
}));
|
|
@@ -3610,11 +3642,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3610
3642
|
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tempOrder, options) {
|
|
3611
3643
|
var _this23 = this;
|
|
3612
3644
|
var nextTempOrder, replacement;
|
|
3613
|
-
return _regeneratorRuntime().wrap(function _callee15$(
|
|
3614
|
-
while (1) switch (
|
|
3645
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context18) {
|
|
3646
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
3615
3647
|
case 0:
|
|
3616
3648
|
if (isTempOrder(tempOrder)) {
|
|
3617
|
-
|
|
3649
|
+
_context18.next = 2;
|
|
3618
3650
|
break;
|
|
3619
3651
|
}
|
|
3620
3652
|
throw new Error('无效的 tempOrder 数据');
|
|
@@ -3623,15 +3655,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3623
3655
|
ensureIdentity: false
|
|
3624
3656
|
});
|
|
3625
3657
|
replacement = this.beginOrderReplacement(options === null || options === void 0 ? void 0 : options.preserveOrderSessionId);
|
|
3626
|
-
|
|
3658
|
+
_context18.prev = 4;
|
|
3627
3659
|
this.sessionStorageRestoreRecord = null;
|
|
3628
3660
|
this.store.tempOrder = nextTempOrder;
|
|
3629
3661
|
this.clearCustomerWalletRuntimeState();
|
|
3630
3662
|
if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
|
|
3631
|
-
|
|
3663
|
+
_context18.next = 13;
|
|
3632
3664
|
break;
|
|
3633
3665
|
}
|
|
3634
|
-
|
|
3666
|
+
_context18.next = 11;
|
|
3635
3667
|
return this.recalculateSummary({
|
|
3636
3668
|
createIfMissing: false,
|
|
3637
3669
|
isCurrentOrder: function isCurrentOrder() {
|
|
@@ -3639,34 +3671,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3639
3671
|
}
|
|
3640
3672
|
});
|
|
3641
3673
|
case 11:
|
|
3642
|
-
|
|
3674
|
+
_context18.next = 14;
|
|
3643
3675
|
break;
|
|
3644
3676
|
case 13:
|
|
3645
3677
|
this.store.summary = createEmptySummary();
|
|
3646
3678
|
case 14:
|
|
3647
3679
|
this.assertOrderReplacementCurrent(replacement);
|
|
3648
3680
|
if (!(options !== null && options !== void 0 && options.saveDraft)) {
|
|
3649
|
-
|
|
3681
|
+
_context18.next = 19;
|
|
3650
3682
|
break;
|
|
3651
3683
|
}
|
|
3652
|
-
|
|
3684
|
+
_context18.next = 18;
|
|
3653
3685
|
return this.saveDraft();
|
|
3654
3686
|
case 18:
|
|
3655
3687
|
this.assertOrderReplacementCurrent(replacement);
|
|
3656
3688
|
case 19:
|
|
3657
3689
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) this.persistTempOrder();
|
|
3658
3690
|
this.completeOrderReplacement(replacement, nextTempOrder, options === null || options === void 0 ? void 0 : options.preserveOrderSessionId);
|
|
3659
|
-
return
|
|
3691
|
+
return _context18.abrupt("return", nextTempOrder);
|
|
3660
3692
|
case 24:
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3693
|
+
_context18.prev = 24;
|
|
3694
|
+
_context18.t0 = _context18["catch"](4);
|
|
3695
|
+
_context18.next = 28;
|
|
3664
3696
|
return this.rollbackOrderReplacement(replacement);
|
|
3665
3697
|
case 28:
|
|
3666
|
-
throw
|
|
3698
|
+
throw _context18.t0;
|
|
3667
3699
|
case 29:
|
|
3668
3700
|
case "end":
|
|
3669
|
-
return
|
|
3701
|
+
return _context18.stop();
|
|
3670
3702
|
}
|
|
3671
3703
|
}, _callee15, this, [[4, 24]]);
|
|
3672
3704
|
}));
|
|
@@ -3759,28 +3791,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3759
3791
|
value: function () {
|
|
3760
3792
|
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
3761
3793
|
var tempOrder;
|
|
3762
|
-
return _regeneratorRuntime().wrap(function _callee16$(
|
|
3763
|
-
while (1) switch (
|
|
3794
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context19) {
|
|
3795
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
3764
3796
|
case 0:
|
|
3765
3797
|
tempOrder = this.ensureTempOrder();
|
|
3766
3798
|
this.ensureExternalSaleNumber(tempOrder);
|
|
3767
|
-
|
|
3799
|
+
_context19.next = 4;
|
|
3768
3800
|
return this.recalculateSummary({
|
|
3769
3801
|
createIfMissing: true
|
|
3770
3802
|
});
|
|
3771
3803
|
case 4:
|
|
3772
3804
|
this.persistTempOrder();
|
|
3773
3805
|
if (!this.draftPersistEnabled) {
|
|
3774
|
-
|
|
3806
|
+
_context19.next = 8;
|
|
3775
3807
|
break;
|
|
3776
3808
|
}
|
|
3777
|
-
|
|
3809
|
+
_context19.next = 8;
|
|
3778
3810
|
return this.saveDraft();
|
|
3779
3811
|
case 8:
|
|
3780
|
-
return
|
|
3812
|
+
return _context19.abrupt("return", tempOrder);
|
|
3781
3813
|
case 9:
|
|
3782
3814
|
case "end":
|
|
3783
|
-
return
|
|
3815
|
+
return _context19.stop();
|
|
3784
3816
|
}
|
|
3785
3817
|
}, _callee16, this);
|
|
3786
3818
|
}));
|
|
@@ -3896,7 +3928,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3896
3928
|
}),
|
|
3897
3929
|
booking_uid: bookingUid
|
|
3898
3930
|
}),
|
|
3899
|
-
booking: _objectSpread(_objectSpread({}, params.booking), {}, {
|
|
3931
|
+
booking: _objectSpread(_objectSpread({}, ensureBookingUuid(params.booking)), {}, {
|
|
3900
3932
|
is_all: normalizeBookingIsAll(params.booking),
|
|
3901
3933
|
product_uid: productUid,
|
|
3902
3934
|
sub_type: normalizeBookingSubType(params.booking),
|
|
@@ -4176,21 +4208,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4176
4208
|
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(options) {
|
|
4177
4209
|
var _this$otherParams3, _ref55, _salesSummaryResult$e;
|
|
4178
4210
|
var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, summaryMutationBaseline, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
4179
|
-
return _regeneratorRuntime().wrap(function _callee17$(
|
|
4180
|
-
while (1) switch (
|
|
4211
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context20) {
|
|
4212
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
4181
4213
|
case 0:
|
|
4182
4214
|
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
4183
|
-
|
|
4215
|
+
_context20.next = 2;
|
|
4184
4216
|
break;
|
|
4185
4217
|
}
|
|
4186
|
-
return
|
|
4218
|
+
return _context20.abrupt("return", null);
|
|
4187
4219
|
case 2:
|
|
4188
4220
|
tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
|
|
4189
4221
|
if (tempOrder) {
|
|
4190
|
-
|
|
4222
|
+
_context20.next = 5;
|
|
4191
4223
|
break;
|
|
4192
4224
|
}
|
|
4193
|
-
return
|
|
4225
|
+
return _context20.abrupt("return", null);
|
|
4194
4226
|
case 5:
|
|
4195
4227
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4196
4228
|
originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
@@ -4198,10 +4230,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4198
4230
|
shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
|
|
4199
4231
|
snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
|
|
4200
4232
|
if (!snapshotSummary) {
|
|
4201
|
-
|
|
4233
|
+
_context20.next = 12;
|
|
4202
4234
|
break;
|
|
4203
4235
|
}
|
|
4204
|
-
return
|
|
4236
|
+
return _context20.abrupt("return", snapshotSummary);
|
|
4205
4237
|
case 12:
|
|
4206
4238
|
shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
|
|
4207
4239
|
summaryProducts = shouldFullRecalculateFromSnapshot || options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep(tempOrder.products || []) : tempOrder.products;
|
|
@@ -4213,7 +4245,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4213
4245
|
totalRefundAmount = existedSummary.total_refund_amount || '0.00';
|
|
4214
4246
|
paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
4215
4247
|
if (salesSummary) {
|
|
4216
|
-
|
|
4248
|
+
_context20.next = 28;
|
|
4217
4249
|
break;
|
|
4218
4250
|
}
|
|
4219
4251
|
emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
|
|
@@ -4239,13 +4271,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4239
4271
|
previousSummary: existedSummary,
|
|
4240
4272
|
summary: emptySummary
|
|
4241
4273
|
});
|
|
4242
|
-
return
|
|
4274
|
+
return _context20.abrupt("return", this.store.summary);
|
|
4243
4275
|
case 28:
|
|
4244
4276
|
summaryMutationBaseline = options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep({
|
|
4245
4277
|
tempOrder: tempOrder,
|
|
4246
4278
|
summary: this.store.summary
|
|
4247
4279
|
}) : null;
|
|
4248
|
-
|
|
4280
|
+
_context20.next = 31;
|
|
4249
4281
|
return salesSummary.getSummary(_objectSpread({
|
|
4250
4282
|
products: summaryProducts,
|
|
4251
4283
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
@@ -4255,21 +4287,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4255
4287
|
channel: this.otherParams.channel
|
|
4256
4288
|
} : {}));
|
|
4257
4289
|
case 31:
|
|
4258
|
-
salesSummaryResult =
|
|
4290
|
+
salesSummaryResult = _context20.sent;
|
|
4259
4291
|
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
4260
|
-
|
|
4292
|
+
_context20.next = 34;
|
|
4261
4293
|
break;
|
|
4262
4294
|
}
|
|
4263
|
-
return
|
|
4295
|
+
return _context20.abrupt("return", null);
|
|
4264
4296
|
case 34:
|
|
4265
4297
|
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !isEqual({
|
|
4266
4298
|
tempOrder: tempOrder,
|
|
4267
4299
|
summary: this.store.summary
|
|
4268
4300
|
}, summaryMutationBaseline))) {
|
|
4269
|
-
|
|
4301
|
+
_context20.next = 36;
|
|
4270
4302
|
break;
|
|
4271
4303
|
}
|
|
4272
|
-
return
|
|
4304
|
+
return _context20.abrupt("return", null);
|
|
4273
4305
|
case 36:
|
|
4274
4306
|
if (shouldFullRecalculateFromSnapshot || options !== null && options !== void 0 && options.isCurrentOrder) {
|
|
4275
4307
|
tempOrder.products = summaryProducts;
|
|
@@ -4315,10 +4347,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4315
4347
|
previousSummary: existedSummary,
|
|
4316
4348
|
summary: summary
|
|
4317
4349
|
});
|
|
4318
|
-
return
|
|
4350
|
+
return _context20.abrupt("return", this.store.summary);
|
|
4319
4351
|
case 53:
|
|
4320
4352
|
case "end":
|
|
4321
|
-
return
|
|
4353
|
+
return _context20.stop();
|
|
4322
4354
|
}
|
|
4323
4355
|
}, _callee17, this);
|
|
4324
4356
|
}));
|
|
@@ -4332,26 +4364,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4332
4364
|
value: function () {
|
|
4333
4365
|
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
4334
4366
|
var summary;
|
|
4335
|
-
return _regeneratorRuntime().wrap(function _callee18$(
|
|
4336
|
-
while (1) switch (
|
|
4367
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context21) {
|
|
4368
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
4337
4369
|
case 0:
|
|
4338
|
-
|
|
4370
|
+
_context21.next = 2;
|
|
4339
4371
|
return this.recalculateSummary({
|
|
4340
4372
|
createIfMissing: true
|
|
4341
4373
|
});
|
|
4342
4374
|
case 2:
|
|
4343
|
-
summary =
|
|
4375
|
+
summary = _context21.sent;
|
|
4344
4376
|
if (summary) {
|
|
4345
|
-
|
|
4377
|
+
_context21.next = 5;
|
|
4346
4378
|
break;
|
|
4347
4379
|
}
|
|
4348
|
-
return
|
|
4380
|
+
return _context21.abrupt("return", createEmptySummary());
|
|
4349
4381
|
case 5:
|
|
4350
4382
|
this.persistTempOrder();
|
|
4351
|
-
return
|
|
4383
|
+
return _context21.abrupt("return", summary);
|
|
4352
4384
|
case 7:
|
|
4353
4385
|
case "end":
|
|
4354
|
-
return
|
|
4386
|
+
return _context21.stop();
|
|
4355
4387
|
}
|
|
4356
4388
|
}, _callee18, this);
|
|
4357
4389
|
}));
|
|
@@ -4378,18 +4410,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4378
4410
|
key: "syncTempOrderNoteToRemote",
|
|
4379
4411
|
value: function () {
|
|
4380
4412
|
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(orderId, note) {
|
|
4381
|
-
return _regeneratorRuntime().wrap(function _callee19$(
|
|
4382
|
-
while (1) switch (
|
|
4413
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context22) {
|
|
4414
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
4383
4415
|
case 0:
|
|
4384
|
-
|
|
4416
|
+
_context22.next = 2;
|
|
4385
4417
|
return this.request.put("/order/order/".concat(orderId, "/note"), {
|
|
4386
4418
|
note: note
|
|
4387
4419
|
});
|
|
4388
4420
|
case 2:
|
|
4389
|
-
return
|
|
4421
|
+
return _context22.abrupt("return", note);
|
|
4390
4422
|
case 3:
|
|
4391
4423
|
case "end":
|
|
4392
|
-
return
|
|
4424
|
+
return _context22.stop();
|
|
4393
4425
|
}
|
|
4394
4426
|
}, _callee19, this);
|
|
4395
4427
|
}));
|
|
@@ -4596,16 +4628,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4596
4628
|
value: function () {
|
|
4597
4629
|
var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(input) {
|
|
4598
4630
|
var tempOrder, note;
|
|
4599
|
-
return _regeneratorRuntime().wrap(function _callee20$(
|
|
4600
|
-
while (1) switch (
|
|
4631
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context23) {
|
|
4632
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
4601
4633
|
case 0:
|
|
4602
4634
|
tempOrder = this.ensureTempOrder();
|
|
4603
4635
|
note = this.setSalesNoteOnTempOrder(tempOrder, input);
|
|
4604
4636
|
this.notifyTempOrderChanged();
|
|
4605
|
-
return
|
|
4637
|
+
return _context23.abrupt("return", cloneDeep(note));
|
|
4606
4638
|
case 4:
|
|
4607
4639
|
case "end":
|
|
4608
|
-
return
|
|
4640
|
+
return _context23.stop();
|
|
4609
4641
|
}
|
|
4610
4642
|
}, _callee20, this);
|
|
4611
4643
|
}));
|
|
@@ -4619,8 +4651,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4619
4651
|
value: function () {
|
|
4620
4652
|
var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(uuid) {
|
|
4621
4653
|
var tempOrder, normalizedUuid, notes, nextNotes, state;
|
|
4622
|
-
return _regeneratorRuntime().wrap(function _callee21$(
|
|
4623
|
-
while (1) switch (
|
|
4654
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context24) {
|
|
4655
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
4624
4656
|
case 0:
|
|
4625
4657
|
tempOrder = this.ensureTempOrder();
|
|
4626
4658
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
@@ -4630,10 +4662,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4630
4662
|
return note.uuid !== normalizedUuid;
|
|
4631
4663
|
});
|
|
4632
4664
|
if (!(nextNotes.length === notes.length)) {
|
|
4633
|
-
|
|
4665
|
+
_context24.next = 7;
|
|
4634
4666
|
break;
|
|
4635
4667
|
}
|
|
4636
|
-
return
|
|
4668
|
+
return _context24.abrupt("return");
|
|
4637
4669
|
case 7:
|
|
4638
4670
|
tempOrder.notes = nextNotes;
|
|
4639
4671
|
state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
@@ -4641,7 +4673,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4641
4673
|
this.notifyTempOrderChanged();
|
|
4642
4674
|
case 11:
|
|
4643
4675
|
case "end":
|
|
4644
|
-
return
|
|
4676
|
+
return _context24.stop();
|
|
4645
4677
|
}
|
|
4646
4678
|
}, _callee21, this);
|
|
4647
4679
|
}));
|
|
@@ -4655,8 +4687,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4655
4687
|
value: function () {
|
|
4656
4688
|
var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
4657
4689
|
var tempOrder, state;
|
|
4658
|
-
return _regeneratorRuntime().wrap(function _callee22$(
|
|
4659
|
-
while (1) switch (
|
|
4690
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context25) {
|
|
4691
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
4660
4692
|
case 0:
|
|
4661
4693
|
tempOrder = this.ensureTempOrder();
|
|
4662
4694
|
tempOrder.notes = [];
|
|
@@ -4666,7 +4698,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4666
4698
|
this.notifyTempOrderChanged();
|
|
4667
4699
|
case 6:
|
|
4668
4700
|
case "end":
|
|
4669
|
-
return
|
|
4701
|
+
return _context25.stop();
|
|
4670
4702
|
}
|
|
4671
4703
|
}, _callee22, this);
|
|
4672
4704
|
}));
|
|
@@ -4764,7 +4796,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4764
4796
|
var tempOrder = this.ensureTempOrder();
|
|
4765
4797
|
var bookings = tempOrder.bookings || [];
|
|
4766
4798
|
var firstIndex = bookings.findIndex(isFulfillmentTimingBooking);
|
|
4767
|
-
var nextBooking = buildPickupTimingBooking(input, bookings[firstIndex]);
|
|
4799
|
+
var nextBooking = ensureBookingUuid(buildPickupTimingBooking(input, bookings[firstIndex]));
|
|
4768
4800
|
// Keep the first row's identity and position; repair duplicate marked rows only.
|
|
4769
4801
|
tempOrder.bookings = firstIndex === -1 ? [].concat(_toConsumableArray(bookings), [nextBooking]) : bookings.flatMap(function (booking, index) {
|
|
4770
4802
|
return index === firstIndex ? [nextBooking] : isFulfillmentTimingBooking(booking) ? [] : [booking];
|
|
@@ -5085,28 +5117,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5085
5117
|
value: (function () {
|
|
5086
5118
|
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(payment) {
|
|
5087
5119
|
var hasPaymentNumber, devicePrefix;
|
|
5088
|
-
return _regeneratorRuntime().wrap(function _callee23$(
|
|
5089
|
-
while (1) switch (
|
|
5120
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context26) {
|
|
5121
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
5090
5122
|
case 0:
|
|
5091
5123
|
hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
|
|
5092
5124
|
if (!hasPaymentNumber) {
|
|
5093
|
-
|
|
5125
|
+
_context26.next = 5;
|
|
5094
5126
|
break;
|
|
5095
5127
|
}
|
|
5096
|
-
|
|
5097
|
-
|
|
5128
|
+
_context26.t0 = 'LOCAL';
|
|
5129
|
+
_context26.next = 8;
|
|
5098
5130
|
break;
|
|
5099
5131
|
case 5:
|
|
5100
|
-
|
|
5132
|
+
_context26.next = 7;
|
|
5101
5133
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
5102
5134
|
case 7:
|
|
5103
|
-
|
|
5135
|
+
_context26.t0 = _context26.sent;
|
|
5104
5136
|
case 8:
|
|
5105
|
-
devicePrefix =
|
|
5106
|
-
return
|
|
5137
|
+
devicePrefix = _context26.t0;
|
|
5138
|
+
return _context26.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
5107
5139
|
case 10:
|
|
5108
5140
|
case "end":
|
|
5109
|
-
return
|
|
5141
|
+
return _context26.stop();
|
|
5110
5142
|
}
|
|
5111
5143
|
}, _callee23, this);
|
|
5112
5144
|
}));
|
|
@@ -5161,17 +5193,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5161
5193
|
updatedPayment,
|
|
5162
5194
|
summary,
|
|
5163
5195
|
payments,
|
|
5164
|
-
|
|
5165
|
-
return _regeneratorRuntime().wrap(function _callee24$(
|
|
5166
|
-
while (1) switch (
|
|
5196
|
+
_args27 = arguments;
|
|
5197
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context27) {
|
|
5198
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
5167
5199
|
case 0:
|
|
5168
|
-
options =
|
|
5200
|
+
options = _args27.length > 2 && _args27[2] !== undefined ? _args27[2] : {};
|
|
5169
5201
|
tempOrder = this.ensureTempOrder();
|
|
5170
5202
|
identity = String(paymentIdentity);
|
|
5171
5203
|
matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
|
|
5172
5204
|
matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
|
|
5173
5205
|
if (matchedPayment) {
|
|
5174
|
-
|
|
5206
|
+
_context27.next = 8;
|
|
5175
5207
|
break;
|
|
5176
5208
|
}
|
|
5177
5209
|
try {
|
|
@@ -5200,15 +5232,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5200
5232
|
return nextPayment;
|
|
5201
5233
|
});
|
|
5202
5234
|
this.persistTempOrder();
|
|
5203
|
-
|
|
5235
|
+
_context27.next = 13;
|
|
5204
5236
|
return this.recalculateSummary({
|
|
5205
5237
|
createIfMissing: true
|
|
5206
5238
|
});
|
|
5207
5239
|
case 13:
|
|
5208
|
-
summary =
|
|
5240
|
+
summary = _context27.sent;
|
|
5209
5241
|
this.persistTempOrder();
|
|
5210
5242
|
payments = tempOrder.payments;
|
|
5211
|
-
return
|
|
5243
|
+
return _context27.abrupt("return", {
|
|
5212
5244
|
updated: true,
|
|
5213
5245
|
payment: payments[matchedPayment.index] || updatedPayment,
|
|
5214
5246
|
payments: payments,
|
|
@@ -5216,7 +5248,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5216
5248
|
});
|
|
5217
5249
|
case 17:
|
|
5218
5250
|
case "end":
|
|
5219
|
-
return
|
|
5251
|
+
return _context27.stop();
|
|
5220
5252
|
}
|
|
5221
5253
|
}, _callee24, this);
|
|
5222
5254
|
}));
|
|
@@ -5418,32 +5450,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5418
5450
|
value: function () {
|
|
5419
5451
|
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(payments, options) {
|
|
5420
5452
|
var needsPaymentNumber, devicePrefix;
|
|
5421
|
-
return _regeneratorRuntime().wrap(function _callee25$(
|
|
5422
|
-
while (1) switch (
|
|
5453
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context28) {
|
|
5454
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
5423
5455
|
case 0:
|
|
5424
5456
|
needsPaymentNumber = (payments || []).some(function (payment) {
|
|
5425
5457
|
return String(payment.payment_number || '').trim() === '';
|
|
5426
5458
|
});
|
|
5427
5459
|
if (!needsPaymentNumber) {
|
|
5428
|
-
|
|
5460
|
+
_context28.next = 7;
|
|
5429
5461
|
break;
|
|
5430
5462
|
}
|
|
5431
|
-
|
|
5463
|
+
_context28.next = 4;
|
|
5432
5464
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
5433
5465
|
case 4:
|
|
5434
|
-
|
|
5435
|
-
|
|
5466
|
+
_context28.t0 = _context28.sent;
|
|
5467
|
+
_context28.next = 8;
|
|
5436
5468
|
break;
|
|
5437
5469
|
case 7:
|
|
5438
|
-
|
|
5470
|
+
_context28.t0 = 'LOCAL';
|
|
5439
5471
|
case 8:
|
|
5440
|
-
devicePrefix =
|
|
5441
|
-
return
|
|
5472
|
+
devicePrefix = _context28.t0;
|
|
5473
|
+
return _context28.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
|
|
5442
5474
|
devicePrefix: devicePrefix
|
|
5443
5475
|
})));
|
|
5444
5476
|
case 10:
|
|
5445
5477
|
case "end":
|
|
5446
|
-
return
|
|
5478
|
+
return _context28.stop();
|
|
5447
5479
|
}
|
|
5448
5480
|
}, _callee25, this);
|
|
5449
5481
|
}));
|
|
@@ -5503,6 +5535,110 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5503
5535
|
var _this$otherParams4;
|
|
5504
5536
|
return ((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.enableMultiCurrencySettlement) === true;
|
|
5505
5537
|
}
|
|
5538
|
+
}, {
|
|
5539
|
+
key: "requiresPosVirtualCurrencyPayment",
|
|
5540
|
+
value: function requiresPosVirtualCurrencyPayment(product) {
|
|
5541
|
+
var _this$otherParams5;
|
|
5542
|
+
return this.isMultiCurrencySettlementEnabled() && isPosTerminalPlatform((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform) && isVirtualSettlementProduct(product);
|
|
5543
|
+
}
|
|
5544
|
+
}, {
|
|
5545
|
+
key: "getPosVirtualPaymentShopId",
|
|
5546
|
+
value: function getPosVirtualPaymentShopId() {
|
|
5547
|
+
var _this$core$context$ge, _this$core3, _this$core3$getData;
|
|
5548
|
+
return String((_this$core$context$ge = (_this$core3 = this.core) === null || _this$core3 === void 0 || (_this$core3 = _this$core3.context) === null || _this$core3 === void 0 || (_this$core3$getData = _this$core3.getData) === null || _this$core3$getData === void 0 ? void 0 : _this$core3$getData.call(_this$core3, 'shop_id')) !== null && _this$core$context$ge !== void 0 ? _this$core$context$ge : '');
|
|
5549
|
+
}
|
|
5550
|
+
}, {
|
|
5551
|
+
key: "syncPosVirtualCurrencyPaymentMethods",
|
|
5552
|
+
value: function syncPosVirtualCurrencyPaymentMethods(methods) {
|
|
5553
|
+
var _methods$find;
|
|
5554
|
+
var shopId = this.getPosVirtualPaymentShopId();
|
|
5555
|
+
var sourceShopId = (_methods$find = methods.find(function (method) {
|
|
5556
|
+
return Number(method === null || method === void 0 ? void 0 : method.shop_id) > 0;
|
|
5557
|
+
})) === null || _methods$find === void 0 ? void 0 : _methods$find.shop_id;
|
|
5558
|
+
if (shopId && sourceShopId != null && String(sourceShopId) !== shopId) return;
|
|
5559
|
+
this.posVirtualPaymentSnapshot = {
|
|
5560
|
+
shopId: shopId,
|
|
5561
|
+
methods: methods,
|
|
5562
|
+
revision: ++this.posVirtualPaymentRevision
|
|
5563
|
+
};
|
|
5564
|
+
}
|
|
5565
|
+
}, {
|
|
5566
|
+
key: "getPosVirtualCurrencyPaymentMethod",
|
|
5567
|
+
value: function getPosVirtualCurrencyPaymentMethod() {
|
|
5568
|
+
var initialMethods = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
5569
|
+
var shopId = this.getPosVirtualPaymentShopId();
|
|
5570
|
+
var snapshot = this.posVirtualPaymentSnapshot;
|
|
5571
|
+
return requirePosVirtualCurrencyPaymentMethod((snapshot === null || snapshot === void 0 ? void 0 : snapshot.shopId) === shopId ? snapshot.methods : initialMethods, shopId);
|
|
5572
|
+
}
|
|
5573
|
+
}, {
|
|
5574
|
+
key: "refreshPosVirtualCurrencyPaymentMethod",
|
|
5575
|
+
value: function () {
|
|
5576
|
+
var _refreshPosVirtualCurrencyPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
5577
|
+
var shopId, revision, methods, snapshot;
|
|
5578
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context29) {
|
|
5579
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
5580
|
+
case 0:
|
|
5581
|
+
shopId = this.getPosVirtualPaymentShopId();
|
|
5582
|
+
revision = ++this.posVirtualPaymentRevision;
|
|
5583
|
+
_context29.next = 4;
|
|
5584
|
+
return loadPaymentMethods(this.request, {
|
|
5585
|
+
transport: 'remote',
|
|
5586
|
+
filterPaymentMethods: false
|
|
5587
|
+
});
|
|
5588
|
+
case 4:
|
|
5589
|
+
methods = _context29.sent;
|
|
5590
|
+
if (!(shopId !== this.getPosVirtualPaymentShopId())) {
|
|
5591
|
+
_context29.next = 7;
|
|
5592
|
+
break;
|
|
5593
|
+
}
|
|
5594
|
+
throw new Error('[Order] Payment methods belong to a previous shop');
|
|
5595
|
+
case 7:
|
|
5596
|
+
snapshot = this.posVirtualPaymentSnapshot; // Slow reads must not overwrite a newer lookup or a payment methods sync event.
|
|
5597
|
+
if ((snapshot === null || snapshot === void 0 ? void 0 : snapshot.shopId) !== shopId || snapshot.revision < revision) {
|
|
5598
|
+
this.posVirtualPaymentSnapshot = {
|
|
5599
|
+
shopId: shopId,
|
|
5600
|
+
methods: methods,
|
|
5601
|
+
revision: revision
|
|
5602
|
+
};
|
|
5603
|
+
}
|
|
5604
|
+
return _context29.abrupt("return", this.getPosVirtualCurrencyPaymentMethod());
|
|
5605
|
+
case 10:
|
|
5606
|
+
case "end":
|
|
5607
|
+
return _context29.stop();
|
|
5608
|
+
}
|
|
5609
|
+
}, _callee26, this);
|
|
5610
|
+
}));
|
|
5611
|
+
function refreshPosVirtualCurrencyPaymentMethod() {
|
|
5612
|
+
return _refreshPosVirtualCurrencyPaymentMethod.apply(this, arguments);
|
|
5613
|
+
}
|
|
5614
|
+
return refreshPosVirtualCurrencyPaymentMethod;
|
|
5615
|
+
}()
|
|
5616
|
+
}, {
|
|
5617
|
+
key: "validatePosVirtualCurrencyCart",
|
|
5618
|
+
value: function () {
|
|
5619
|
+
var _validatePosVirtualCurrencyCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(order) {
|
|
5620
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context30) {
|
|
5621
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
5622
|
+
case 0:
|
|
5623
|
+
_context30.next = 2;
|
|
5624
|
+
return this.refreshPosVirtualCurrencyPaymentMethod();
|
|
5625
|
+
case 2:
|
|
5626
|
+
if (!(this.getTempOrder() !== order)) {
|
|
5627
|
+
_context30.next = 4;
|
|
5628
|
+
break;
|
|
5629
|
+
}
|
|
5630
|
+
throw new Error('[Order] Cart intent belongs to a previous order or business');
|
|
5631
|
+
case 4:
|
|
5632
|
+
case "end":
|
|
5633
|
+
return _context30.stop();
|
|
5634
|
+
}
|
|
5635
|
+
}, _callee27, this);
|
|
5636
|
+
}));
|
|
5637
|
+
function validatePosVirtualCurrencyCart(_x26) {
|
|
5638
|
+
return _validatePosVirtualCurrencyCart.apply(this, arguments);
|
|
5639
|
+
}
|
|
5640
|
+
return validatePosVirtualCurrencyCart;
|
|
5641
|
+
}()
|
|
5506
5642
|
}, {
|
|
5507
5643
|
key: "isActiveVirtualSettlementOrder",
|
|
5508
5644
|
value: function isActiveVirtualSettlementOrder(tempOrder) {
|
|
@@ -5602,83 +5738,83 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5602
5738
|
}, {
|
|
5603
5739
|
key: "finalizeProductOrderMutation",
|
|
5604
5740
|
value: function () {
|
|
5605
|
-
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5741
|
+
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(tempOrder, options) {
|
|
5606
5742
|
var isCurrentOrder, isVirtualSettlement, promotionPayload, summary;
|
|
5607
|
-
return _regeneratorRuntime().wrap(function
|
|
5608
|
-
while (1) switch (
|
|
5743
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context31) {
|
|
5744
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
5609
5745
|
case 0:
|
|
5610
5746
|
isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
|
|
5611
5747
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
5612
|
-
|
|
5748
|
+
_context31.next = 3;
|
|
5613
5749
|
break;
|
|
5614
5750
|
}
|
|
5615
|
-
return
|
|
5751
|
+
return _context31.abrupt("return");
|
|
5616
5752
|
case 3:
|
|
5617
5753
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
5618
5754
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
5619
5755
|
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
5620
5756
|
if (!(!(options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) && !isVirtualSettlement)) {
|
|
5621
|
-
|
|
5757
|
+
_context31.next = 9;
|
|
5622
5758
|
break;
|
|
5623
5759
|
}
|
|
5624
|
-
|
|
5760
|
+
_context31.next = 9;
|
|
5625
5761
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
5626
5762
|
case 9:
|
|
5627
5763
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
5628
|
-
|
|
5764
|
+
_context31.next = 11;
|
|
5629
5765
|
break;
|
|
5630
5766
|
}
|
|
5631
|
-
return
|
|
5767
|
+
return _context31.abrupt("return");
|
|
5632
5768
|
case 11:
|
|
5633
5769
|
if (!(!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement)) {
|
|
5634
|
-
|
|
5770
|
+
_context31.next = 17;
|
|
5635
5771
|
break;
|
|
5636
5772
|
}
|
|
5637
|
-
|
|
5773
|
+
_context31.next = 14;
|
|
5638
5774
|
return this.evaluatePromotion(isCurrentOrder ? {
|
|
5639
5775
|
isCurrentOrder: isCurrentOrder
|
|
5640
5776
|
} : undefined);
|
|
5641
5777
|
case 14:
|
|
5642
|
-
|
|
5643
|
-
|
|
5778
|
+
_context31.t0 = _context31.sent;
|
|
5779
|
+
_context31.next = 18;
|
|
5644
5780
|
break;
|
|
5645
5781
|
case 17:
|
|
5646
|
-
|
|
5782
|
+
_context31.t0 = null;
|
|
5647
5783
|
case 18:
|
|
5648
|
-
promotionPayload =
|
|
5784
|
+
promotionPayload = _context31.t0;
|
|
5649
5785
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
5650
|
-
|
|
5786
|
+
_context31.next = 21;
|
|
5651
5787
|
break;
|
|
5652
5788
|
}
|
|
5653
|
-
return
|
|
5789
|
+
return _context31.abrupt("return");
|
|
5654
5790
|
case 21:
|
|
5655
5791
|
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement) {
|
|
5656
5792
|
this.applyDiscount();
|
|
5657
5793
|
}
|
|
5658
5794
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5659
|
-
|
|
5795
|
+
_context31.next = 25;
|
|
5660
5796
|
return this.recalculateSummary(_objectSpread({
|
|
5661
5797
|
createIfMissing: true
|
|
5662
5798
|
}, isCurrentOrder ? {
|
|
5663
5799
|
isCurrentOrder: isCurrentOrder
|
|
5664
5800
|
} : {}));
|
|
5665
5801
|
case 25:
|
|
5666
|
-
summary =
|
|
5802
|
+
summary = _context31.sent;
|
|
5667
5803
|
if (!(isCurrentOrder && (!isCurrentOrder() || !summary))) {
|
|
5668
|
-
|
|
5804
|
+
_context31.next = 28;
|
|
5669
5805
|
break;
|
|
5670
5806
|
}
|
|
5671
|
-
return
|
|
5807
|
+
return _context31.abrupt("return");
|
|
5672
5808
|
case 28:
|
|
5673
5809
|
this.persistTempOrder();
|
|
5674
5810
|
this.emitPromotionApplied(promotionPayload);
|
|
5675
5811
|
case 30:
|
|
5676
5812
|
case "end":
|
|
5677
|
-
return
|
|
5813
|
+
return _context31.stop();
|
|
5678
5814
|
}
|
|
5679
|
-
},
|
|
5815
|
+
}, _callee28, this);
|
|
5680
5816
|
}));
|
|
5681
|
-
function finalizeProductOrderMutation(
|
|
5817
|
+
function finalizeProductOrderMutation(_x27, _x28) {
|
|
5682
5818
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
5683
5819
|
}
|
|
5684
5820
|
return finalizeProductOrderMutation;
|
|
@@ -5698,7 +5834,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5698
5834
|
}, {
|
|
5699
5835
|
key: "appendProductLineToTempOrder",
|
|
5700
5836
|
value: function appendProductLineToTempOrder(tempOrder, product, booking, options) {
|
|
5701
|
-
var
|
|
5837
|
+
var _booking,
|
|
5838
|
+
_tempOrder$bookings3,
|
|
5839
|
+
_normalizedIncoming$p,
|
|
5702
5840
|
_normalizedIncoming$p2,
|
|
5703
5841
|
_booking_uid,
|
|
5704
5842
|
_metadata,
|
|
@@ -5706,6 +5844,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5706
5844
|
_productToAdd$metadat,
|
|
5707
5845
|
_origin,
|
|
5708
5846
|
_this38 = this;
|
|
5847
|
+
var incomingBookingUuid = (_booking = booking) === null || _booking === void 0 ? void 0 : _booking.uuid;
|
|
5848
|
+
if (booking && incomingBookingUuid && (_tempOrder$bookings3 = tempOrder.bookings) !== null && _tempOrder$bookings3 !== void 0 && _tempOrder$bookings3.some(function (item) {
|
|
5849
|
+
return item.uuid === incomingBookingUuid;
|
|
5850
|
+
})) {
|
|
5851
|
+
// Appending a copy creates a different booking; editing uses the update path below.
|
|
5852
|
+
booking = _objectSpread(_objectSpread({}, booking), {}, {
|
|
5853
|
+
uuid: createUuidV4(),
|
|
5854
|
+
id: undefined,
|
|
5855
|
+
schedule_event_id: undefined
|
|
5856
|
+
});
|
|
5857
|
+
}
|
|
5709
5858
|
var linked = booking ? this.createLinkedProductAndBooking({
|
|
5710
5859
|
product: product,
|
|
5711
5860
|
booking: booking
|
|
@@ -5863,6 +6012,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5863
6012
|
singleLine.num = 1;
|
|
5864
6013
|
delete singleLine.product_quantity;
|
|
5865
6014
|
var singleBooking = cloneDeep(booking);
|
|
6015
|
+
if (index > 0) {
|
|
6016
|
+
// Both single-add and batch-add quantity splits create separate appointments.
|
|
6017
|
+
delete singleBooking.uuid;
|
|
6018
|
+
delete singleBooking.schedule_event_id;
|
|
6019
|
+
delete singleBooking.id;
|
|
6020
|
+
}
|
|
5866
6021
|
var bookingHolder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
|
|
5867
6022
|
var metadataHolder = booking !== null && booking !== void 0 && (_booking$metadata6 = booking.metadata) !== null && _booking$metadata6 !== void 0 && _booking$metadata6.holder && _typeof(booking.metadata.holder) === 'object' ? booking.metadata.holder : null;
|
|
5868
6023
|
var rawHolderIds = (_ref71 = (_ref72 = (_bookingHolder$form_r = bookingHolder === null || bookingHolder === void 0 ? void 0 : bookingHolder.form_record) !== null && _bookingHolder$form_r !== void 0 ? _bookingHolder$form_r : booking === null || booking === void 0 || (_booking$metadata7 = booking.metadata) === null || _booking$metadata7 === void 0 ? void 0 : _booking$metadata7.holder_id) !== null && _ref72 !== void 0 ? _ref72 : metadataHolder === null || metadataHolder === void 0 ? void 0 : metadataHolder.form_record) !== null && _ref71 !== void 0 ? _ref71 : product === null || product === void 0 || (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.holder_id;
|
|
@@ -5929,21 +6084,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5929
6084
|
}, {
|
|
5930
6085
|
key: "addProductToOrder",
|
|
5931
6086
|
value: (function () {
|
|
5932
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6087
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(product, booking, options) {
|
|
5933
6088
|
var _this39 = this;
|
|
5934
|
-
return _regeneratorRuntime().wrap(function
|
|
5935
|
-
while (1) switch (
|
|
6089
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
6090
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
5936
6091
|
case 0:
|
|
5937
|
-
return
|
|
6092
|
+
return _context32.abrupt("return", this.queueCartCommand(function () {
|
|
5938
6093
|
return _this39.addProductToOrderDraft(product, booking, options);
|
|
5939
6094
|
}));
|
|
5940
6095
|
case 1:
|
|
5941
6096
|
case "end":
|
|
5942
|
-
return
|
|
6097
|
+
return _context32.stop();
|
|
5943
6098
|
}
|
|
5944
|
-
},
|
|
6099
|
+
}, _callee29, this);
|
|
5945
6100
|
}));
|
|
5946
|
-
function addProductToOrder(
|
|
6101
|
+
function addProductToOrder(_x29, _x30, _x31) {
|
|
5947
6102
|
return _addProductToOrder.apply(this, arguments);
|
|
5948
6103
|
}
|
|
5949
6104
|
return addProductToOrder;
|
|
@@ -5951,17 +6106,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5951
6106
|
}, {
|
|
5952
6107
|
key: "addProductToOrderDraft",
|
|
5953
6108
|
value: function () {
|
|
5954
|
-
var _addProductToOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6109
|
+
var _addProductToOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(product, booking, options) {
|
|
5955
6110
|
var _product$_extend2,
|
|
5956
6111
|
_this40 = this;
|
|
5957
6112
|
var availabilityCommitGuard, liveTempOrder, beforeCommit, mutation, tempOrder, beforeAppend, guardedMutationFields, readGuardedMutationFields, guardedMutationBaseline, beforePublish, _tempOrder$_extend13, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref73, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2, committedIdentity, isCurrentOrder;
|
|
5958
|
-
return _regeneratorRuntime().wrap(function
|
|
5959
|
-
while (1) switch (
|
|
6113
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
6114
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
5960
6115
|
case 0:
|
|
5961
6116
|
availabilityCommitGuard = options === null || options === void 0 ? void 0 : options.availabilityCommitGuard;
|
|
5962
6117
|
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
5963
6118
|
liveTempOrder = this.ensureTempOrder();
|
|
5964
6119
|
beforeCommit = this.createCartIntentCommitGuard('add_product', liveTempOrder);
|
|
6120
|
+
if (!this.requiresPosVirtualCurrencyPayment(product)) {
|
|
6121
|
+
_context33.next = 8;
|
|
6122
|
+
break;
|
|
6123
|
+
}
|
|
6124
|
+
_context33.next = 7;
|
|
6125
|
+
return this.validatePosVirtualCurrencyCart(liveTempOrder);
|
|
6126
|
+
case 7:
|
|
6127
|
+
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
6128
|
+
case 8:
|
|
5965
6129
|
mutation = this.beginCartMutation(); // 库存/商品券校验与自动预约共用草稿,全部门禁通过后才发布完整批次。
|
|
5966
6130
|
tempOrder = availabilityCommitGuard && !mutation.commit ? cloneDeep(liveTempOrder) : mutation.draft;
|
|
5967
6131
|
beforeAppend = mutation.commit ? undefined : beforeCommit;
|
|
@@ -5983,21 +6147,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5983
6147
|
}
|
|
5984
6148
|
};
|
|
5985
6149
|
if (!(options !== null && options !== void 0 && options.productVoucherGroupKey)) {
|
|
5986
|
-
|
|
6150
|
+
_context33.next = 19;
|
|
5987
6151
|
break;
|
|
5988
6152
|
}
|
|
5989
6153
|
if ((_tempOrder$_extend13 = tempOrder._extend) !== null && _tempOrder$_extend13 !== void 0 && (_tempOrder$_extend13 = _tempOrder$_extend13.productVoucherGroups) !== null && _tempOrder$_extend13 !== void 0 && _tempOrder$_extend13.some(function (group) {
|
|
5990
6154
|
return group.key === options.productVoucherGroupKey;
|
|
5991
6155
|
})) {
|
|
5992
|
-
|
|
6156
|
+
_context33.next = 18;
|
|
5993
6157
|
break;
|
|
5994
6158
|
}
|
|
5995
6159
|
throw voucherGroupError();
|
|
5996
|
-
case
|
|
6160
|
+
case 18:
|
|
5997
6161
|
product = _objectSpread(_objectSpread({}, product), {}, {
|
|
5998
6162
|
_productVoucherGroupKey: options.productVoucherGroupKey
|
|
5999
6163
|
});
|
|
6000
|
-
case
|
|
6164
|
+
case 19:
|
|
6001
6165
|
salesNoteDrafts = ((options === null || options === void 0 ? void 0 : options.salesNotes) || []).map(function (draft) {
|
|
6002
6166
|
return {
|
|
6003
6167
|
note_type: String(draft.note_type || '').trim(),
|
|
@@ -6047,21 +6211,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6047
6211
|
return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
|
|
6048
6212
|
}) : -1;
|
|
6049
6213
|
insertAtIndex = options !== null && options !== void 0 && options.insertAtStart ? 0 : anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
6050
|
-
|
|
6214
|
+
_context33.prev = 26;
|
|
6051
6215
|
if (!booking) {
|
|
6052
|
-
|
|
6216
|
+
_context33.next = 53;
|
|
6053
6217
|
break;
|
|
6054
6218
|
}
|
|
6055
6219
|
productRecord = product;
|
|
6056
6220
|
splitCount = getSafeProductNum((_ref73 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref73 !== void 0 ? _ref73 : 1);
|
|
6057
6221
|
if (!(splitCount > 1)) {
|
|
6058
|
-
|
|
6222
|
+
_context33.next = 46;
|
|
6059
6223
|
break;
|
|
6060
6224
|
}
|
|
6061
6225
|
i = 0;
|
|
6062
|
-
case
|
|
6226
|
+
case 32:
|
|
6063
6227
|
if (!(i < splitCount)) {
|
|
6064
|
-
|
|
6228
|
+
_context33.next = 44;
|
|
6065
6229
|
break;
|
|
6066
6230
|
}
|
|
6067
6231
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
@@ -6079,79 +6243,79 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6079
6243
|
delete splitLine.booking.metadata.unique_identification_number;
|
|
6080
6244
|
}
|
|
6081
6245
|
}
|
|
6082
|
-
|
|
6246
|
+
_context33.next = 37;
|
|
6083
6247
|
return this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
6084
6248
|
insertAtIndex: insertAtIndex,
|
|
6085
6249
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
6086
6250
|
beforeCommit: beforeAppend
|
|
6087
6251
|
});
|
|
6088
|
-
case
|
|
6089
|
-
committedProduct =
|
|
6252
|
+
case 37:
|
|
6253
|
+
committedProduct = _context33.sent;
|
|
6090
6254
|
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
6091
6255
|
attachSalesNoteDrafts(committedProduct);
|
|
6092
6256
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
6093
|
-
case
|
|
6257
|
+
case 41:
|
|
6094
6258
|
i += 1;
|
|
6095
|
-
|
|
6259
|
+
_context33.next = 32;
|
|
6096
6260
|
break;
|
|
6097
|
-
case
|
|
6098
|
-
|
|
6261
|
+
case 44:
|
|
6262
|
+
_context33.next = 51;
|
|
6099
6263
|
break;
|
|
6100
|
-
case
|
|
6101
|
-
|
|
6264
|
+
case 46:
|
|
6265
|
+
_context33.next = 48;
|
|
6102
6266
|
return this.appendProductLineToTempOrder(tempOrder, product, cloneDeep(booking), {
|
|
6103
6267
|
insertAtIndex: insertAtIndex,
|
|
6104
6268
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
6105
6269
|
beforeCommit: beforeAppend
|
|
6106
6270
|
});
|
|
6107
|
-
case
|
|
6108
|
-
_committedProduct =
|
|
6271
|
+
case 48:
|
|
6272
|
+
_committedProduct = _context33.sent;
|
|
6109
6273
|
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
6110
6274
|
attachSalesNoteDrafts(_committedProduct);
|
|
6111
|
-
case
|
|
6112
|
-
|
|
6275
|
+
case 51:
|
|
6276
|
+
_context33.next = 58;
|
|
6113
6277
|
break;
|
|
6114
|
-
case
|
|
6115
|
-
|
|
6278
|
+
case 53:
|
|
6279
|
+
_context33.next = 55;
|
|
6116
6280
|
return this.appendProductLineToTempOrder(tempOrder, product, undefined, {
|
|
6117
6281
|
insertAtIndex: insertAtIndex,
|
|
6118
6282
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
6119
6283
|
beforeCommit: beforeAppend
|
|
6120
6284
|
});
|
|
6121
|
-
case
|
|
6122
|
-
_committedProduct2 =
|
|
6285
|
+
case 55:
|
|
6286
|
+
_committedProduct2 = _context33.sent;
|
|
6123
6287
|
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
6124
6288
|
attachSalesNoteDrafts(_committedProduct2);
|
|
6125
|
-
case
|
|
6289
|
+
case 58:
|
|
6126
6290
|
if (!mutation.commit) {
|
|
6127
|
-
|
|
6291
|
+
_context33.next = 63;
|
|
6128
6292
|
break;
|
|
6129
6293
|
}
|
|
6130
|
-
|
|
6294
|
+
_context33.next = 61;
|
|
6131
6295
|
return mutation.commit({
|
|
6132
6296
|
beforeCommit: beforePublish
|
|
6133
6297
|
});
|
|
6134
|
-
case
|
|
6135
|
-
|
|
6298
|
+
case 61:
|
|
6299
|
+
_context33.next = 64;
|
|
6136
6300
|
break;
|
|
6137
|
-
case
|
|
6301
|
+
case 63:
|
|
6138
6302
|
if (availabilityCommitGuard) {
|
|
6139
6303
|
beforePublish();
|
|
6140
6304
|
// 从最后一次门禁到真正新增之间不再 await。只发布本次新增会改写的
|
|
6141
6305
|
// 字段;其余订单字段继续使用 live 对象,外部持有的订单引用也不变。
|
|
6142
6306
|
Object.assign(liveTempOrder, readGuardedMutationFields(tempOrder));
|
|
6143
6307
|
}
|
|
6144
|
-
case
|
|
6145
|
-
|
|
6308
|
+
case 64:
|
|
6309
|
+
_context33.next = 70;
|
|
6146
6310
|
break;
|
|
6147
|
-
case 62:
|
|
6148
|
-
_context30.prev = 62;
|
|
6149
|
-
_context30.t0 = _context30["catch"](22);
|
|
6150
|
-
rollbackProductAndNotesMutation();
|
|
6151
|
-
throw _context30.t0;
|
|
6152
6311
|
case 66:
|
|
6312
|
+
_context33.prev = 66;
|
|
6313
|
+
_context33.t0 = _context33["catch"](26);
|
|
6314
|
+
rollbackProductAndNotesMutation();
|
|
6315
|
+
throw _context33.t0;
|
|
6316
|
+
case 70:
|
|
6153
6317
|
if (!availabilityCommitGuard) {
|
|
6154
|
-
|
|
6318
|
+
_context33.next = 84;
|
|
6155
6319
|
break;
|
|
6156
6320
|
}
|
|
6157
6321
|
committedIdentity = [liveTempOrder.order_id, liveTempOrder.external_sale_number];
|
|
@@ -6159,44 +6323,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6159
6323
|
var _options$availability, _options$availability2;
|
|
6160
6324
|
return _this40.store.tempOrder === liveTempOrder && liveTempOrder.order_id === committedIdentity[0] && liveTempOrder.external_sale_number === committedIdentity[1] && ((_options$availability = options === null || options === void 0 || (_options$availability2 = options.availabilityCommitTargetGuard) === null || _options$availability2 === void 0 ? void 0 : _options$availability2.call(options)) !== null && _options$availability !== void 0 ? _options$availability : true);
|
|
6161
6325
|
};
|
|
6162
|
-
|
|
6326
|
+
_context33.prev = 73;
|
|
6163
6327
|
// 新增已发布,即使后续报价/促销收尾失败,也不能向调用方报告未加购。
|
|
6164
6328
|
// 先保存已提交行;异步结果只允许写回仍属于本次提交的订单。
|
|
6165
6329
|
if (isCurrentOrder()) this.persistTempOrder();
|
|
6166
|
-
|
|
6330
|
+
_context33.next = 77;
|
|
6167
6331
|
return this.finalizeProductOrderMutation(liveTempOrder, {
|
|
6168
6332
|
isCurrentOrder: isCurrentOrder
|
|
6169
6333
|
});
|
|
6170
|
-
case
|
|
6171
|
-
|
|
6334
|
+
case 77:
|
|
6335
|
+
_context33.next = 82;
|
|
6172
6336
|
break;
|
|
6173
|
-
case
|
|
6174
|
-
|
|
6175
|
-
|
|
6337
|
+
case 79:
|
|
6338
|
+
_context33.prev = 79;
|
|
6339
|
+
_context33.t1 = _context33["catch"](73);
|
|
6176
6340
|
this.logWarning('addProductToOrder committed; finalization failed', {
|
|
6177
6341
|
product_id: product.product_id,
|
|
6178
6342
|
committed: true,
|
|
6179
|
-
error:
|
|
6343
|
+
error: _context33.t1 instanceof Error ? _context33.t1.message : String(_context33.t1)
|
|
6180
6344
|
});
|
|
6181
|
-
case 78:
|
|
6182
|
-
_context30.next = 82;
|
|
6183
|
-
break;
|
|
6184
|
-
case 80:
|
|
6185
|
-
_context30.next = 82;
|
|
6186
|
-
return this.finalizeProductOrderMutation(liveTempOrder);
|
|
6187
6345
|
case 82:
|
|
6346
|
+
_context33.next = 86;
|
|
6347
|
+
break;
|
|
6348
|
+
case 84:
|
|
6349
|
+
_context33.next = 86;
|
|
6350
|
+
return this.finalizeProductOrderMutation(liveTempOrder);
|
|
6351
|
+
case 86:
|
|
6188
6352
|
this.logInfo('addProductToOrder success', {
|
|
6189
6353
|
product_id: product.product_id,
|
|
6190
6354
|
with_booking: !!booking
|
|
6191
6355
|
});
|
|
6192
|
-
return
|
|
6193
|
-
case
|
|
6356
|
+
return _context33.abrupt("return", liveTempOrder.products);
|
|
6357
|
+
case 88:
|
|
6194
6358
|
case "end":
|
|
6195
|
-
return
|
|
6359
|
+
return _context33.stop();
|
|
6196
6360
|
}
|
|
6197
|
-
},
|
|
6361
|
+
}, _callee30, this, [[26, 66], [73, 79]]);
|
|
6198
6362
|
}));
|
|
6199
|
-
function addProductToOrderDraft(
|
|
6363
|
+
function addProductToOrderDraft(_x32, _x33, _x34) {
|
|
6200
6364
|
return _addProductToOrderDraft.apply(this, arguments);
|
|
6201
6365
|
}
|
|
6202
6366
|
return addProductToOrderDraft;
|
|
@@ -6209,21 +6373,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6209
6373
|
}, {
|
|
6210
6374
|
key: "replaceBookingProductWithRelatedRetail",
|
|
6211
6375
|
value: (function () {
|
|
6212
|
-
var _replaceBookingProductWithRelatedRetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6376
|
+
var _replaceBookingProductWithRelatedRetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
6213
6377
|
var _this41 = this;
|
|
6214
|
-
return _regeneratorRuntime().wrap(function
|
|
6215
|
-
while (1) switch (
|
|
6378
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
6379
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
6216
6380
|
case 0:
|
|
6217
|
-
return
|
|
6381
|
+
return _context34.abrupt("return", this.queueCartCommand(function () {
|
|
6218
6382
|
return _this41.replaceBookingProductWithRelatedRetailDraft(params);
|
|
6219
6383
|
}));
|
|
6220
6384
|
case 1:
|
|
6221
6385
|
case "end":
|
|
6222
|
-
return
|
|
6386
|
+
return _context34.stop();
|
|
6223
6387
|
}
|
|
6224
|
-
},
|
|
6388
|
+
}, _callee31, this);
|
|
6225
6389
|
}));
|
|
6226
|
-
function replaceBookingProductWithRelatedRetail(
|
|
6390
|
+
function replaceBookingProductWithRelatedRetail(_x35) {
|
|
6227
6391
|
return _replaceBookingProductWithRelatedRetail.apply(this, arguments);
|
|
6228
6392
|
}
|
|
6229
6393
|
return replaceBookingProductWithRelatedRetail;
|
|
@@ -6231,18 +6395,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6231
6395
|
}, {
|
|
6232
6396
|
key: "replaceBookingProductWithRelatedRetailDraft",
|
|
6233
6397
|
value: function () {
|
|
6234
|
-
var _replaceBookingProductWithRelatedRetailDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6398
|
+
var _replaceBookingProductWithRelatedRetailDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
6235
6399
|
var _target$metadata,
|
|
6236
6400
|
_target$metadata2,
|
|
6401
|
+
_this42 = this,
|
|
6237
6402
|
_params$product$num,
|
|
6238
6403
|
_target$metadata3,
|
|
6239
6404
|
_params$product$metad,
|
|
6240
6405
|
_params$product$metad2,
|
|
6241
|
-
_params$booking$metad
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
while (1) switch (_context33.prev = _context33.next) {
|
|
6406
|
+
_params$booking$metad;
|
|
6407
|
+
var live, mutation, beforeCommit, uid, getUid, targetIndex, target, scopeKey, targetBookingUid, targetBookings, children, start, serviceDatetime, ownedUids, nextUids, retainedChildUids, nextChildren, _iterator25, _step25, _loop4, publishedFields, guardedFields, readFields, baseline, identity, isCurrentOrder, draft, removed, _iterator26, _step26, line, _iterator27, _step27, _draft$_extend, _line, replacement, replacementBooking, _iterator28, _step28, _step28$value, index, child, beforePublish;
|
|
6408
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context36) {
|
|
6409
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
6246
6410
|
case 0:
|
|
6247
6411
|
params.availabilityCommitGuard();
|
|
6248
6412
|
live = this.ensureTempOrder();
|
|
@@ -6259,17 +6423,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6259
6423
|
target = live.products[targetIndex];
|
|
6260
6424
|
scopeKey = String((target === null || target === void 0 || (_target$metadata = target.metadata) === null || _target$metadata === void 0 ? void 0 : _target$metadata.venue_booking_scope_key) || '');
|
|
6261
6425
|
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) || '');
|
|
6262
|
-
|
|
6263
|
-
return _this42.getBookingUniqueIdentificationNumber(
|
|
6264
|
-
})
|
|
6426
|
+
targetBookings = (live.bookings || []).filter(function (row) {
|
|
6427
|
+
return _this42.getBookingUniqueIdentificationNumber(row) === targetBookingUid;
|
|
6428
|
+
});
|
|
6429
|
+
if (!(!uid || !target || !scopeKey || live.order_id || 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 || targetBookings.length !== 1 || live.products.filter(function (line) {
|
|
6265
6430
|
var _line$metadata3, _line$metadata4;
|
|
6266
6431
|
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;
|
|
6267
6432
|
}).length !== 1)) {
|
|
6268
|
-
|
|
6433
|
+
_context36.next = 13;
|
|
6269
6434
|
break;
|
|
6270
6435
|
}
|
|
6271
6436
|
throw new Error('[Order] Party replacement requires one unsubmitted, unpaid main booking in the same scope');
|
|
6272
|
-
case
|
|
6437
|
+
case 13:
|
|
6273
6438
|
children = live.products.filter(function (line) {
|
|
6274
6439
|
var _line$metadata5, _line$metadata6;
|
|
6275
6440
|
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;
|
|
@@ -6278,30 +6443,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6278
6443
|
var _line$metadata7;
|
|
6279
6444
|
return !getUid(line) || ((_line$metadata7 = line.metadata) === null || _line$metadata7 === void 0 ? void 0 : _line$metadata7.venue_booking_scope_key) !== scopeKey || line.order_detail_id != null || _this42.hasLinkedBookingUid(line);
|
|
6280
6445
|
})) {
|
|
6281
|
-
|
|
6446
|
+
_context36.next = 16;
|
|
6282
6447
|
break;
|
|
6283
6448
|
}
|
|
6284
6449
|
throw new Error('[Order] Related retail line does not belong to this local Party scope');
|
|
6285
|
-
case
|
|
6450
|
+
case 16:
|
|
6286
6451
|
start = params.booking.start_at || "".concat(params.booking.start_date || '', " ").concat(params.booking.start_time || '').trim();
|
|
6287
6452
|
if (!(!start || !dayjs(start).isValid())) {
|
|
6288
|
-
|
|
6453
|
+
_context36.next = 19;
|
|
6289
6454
|
break;
|
|
6290
6455
|
}
|
|
6291
6456
|
throw new Error('[Order] Party service datetime is required');
|
|
6292
|
-
case
|
|
6457
|
+
case 19:
|
|
6293
6458
|
serviceDatetime = dayjs(start).format('YYYY-MM-DD HH:mm:ss');
|
|
6294
6459
|
ownedUids = new Set(children.map(getUid));
|
|
6295
6460
|
nextUids = new Set();
|
|
6296
6461
|
retainedChildUids = new Set();
|
|
6297
6462
|
nextChildren = cloneDeep(params.relatedRetailProducts);
|
|
6298
6463
|
_iterator25 = _createForOfIteratorHelper(nextChildren);
|
|
6299
|
-
|
|
6300
|
-
|
|
6464
|
+
_context36.prev = 25;
|
|
6465
|
+
_loop4 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop4() {
|
|
6301
6466
|
var _child$metadata, _child$metadata2, _child$metadata3, _child$metadata4, _child$num;
|
|
6302
6467
|
var child, childUid, purchaseDatetime, normalizedPurchaseDatetime, previous, _live$_extend, _rawChild$_origin, previousForms, rawChild;
|
|
6303
|
-
return _regeneratorRuntime().wrap(function
|
|
6304
|
-
while (1) switch (
|
|
6468
|
+
return _regeneratorRuntime().wrap(function _loop4$(_context35) {
|
|
6469
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
6305
6470
|
case 0:
|
|
6306
6471
|
child = _step25.value;
|
|
6307
6472
|
childUid = getUid(child);
|
|
@@ -6310,7 +6475,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6310
6475
|
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 || !/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?$/.test(purchaseDatetime) || !dayjs(purchaseDatetime).isValid() || dayjs(purchaseDatetime).format('YYYY-MM-DD HH:mm:ss') !== normalizedPurchaseDatetime || _this42.hasLinkedBookingUid(child) || child.order_detail_id != null || childUid && (nextUids.has(childUid) || live.products.some(function (line) {
|
|
6311
6476
|
return getUid(line) === childUid && !ownedUids.has(childUid);
|
|
6312
6477
|
})))) {
|
|
6313
|
-
|
|
6478
|
+
_context35.next = 6;
|
|
6314
6479
|
break;
|
|
6315
6480
|
}
|
|
6316
6481
|
throw new Error('[Order] Invalid Party extra ownership, identity, or purchase quote datetime');
|
|
@@ -6332,32 +6497,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6332
6497
|
}
|
|
6333
6498
|
case 9:
|
|
6334
6499
|
case "end":
|
|
6335
|
-
return
|
|
6500
|
+
return _context35.stop();
|
|
6336
6501
|
}
|
|
6337
|
-
},
|
|
6502
|
+
}, _loop4);
|
|
6338
6503
|
});
|
|
6339
6504
|
_iterator25.s();
|
|
6340
|
-
case
|
|
6505
|
+
case 28:
|
|
6341
6506
|
if ((_step25 = _iterator25.n()).done) {
|
|
6342
|
-
|
|
6507
|
+
_context36.next = 32;
|
|
6343
6508
|
break;
|
|
6344
6509
|
}
|
|
6345
|
-
return
|
|
6346
|
-
case
|
|
6347
|
-
|
|
6510
|
+
return _context36.delegateYield(_loop4(), "t0", 30);
|
|
6511
|
+
case 30:
|
|
6512
|
+
_context36.next = 28;
|
|
6348
6513
|
break;
|
|
6349
|
-
case
|
|
6350
|
-
|
|
6514
|
+
case 32:
|
|
6515
|
+
_context36.next = 37;
|
|
6351
6516
|
break;
|
|
6352
|
-
case
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
_iterator25.e(
|
|
6356
|
-
case
|
|
6357
|
-
|
|
6517
|
+
case 34:
|
|
6518
|
+
_context36.prev = 34;
|
|
6519
|
+
_context36.t1 = _context36["catch"](25);
|
|
6520
|
+
_iterator25.e(_context36.t1);
|
|
6521
|
+
case 37:
|
|
6522
|
+
_context36.prev = 37;
|
|
6358
6523
|
_iterator25.f();
|
|
6359
|
-
return
|
|
6360
|
-
case
|
|
6524
|
+
return _context36.finish(37);
|
|
6525
|
+
case 40:
|
|
6361
6526
|
publishedFields = ['products', 'bookings', 'notes', '_extend', 'metadata', 'holder', 'holder_relations', 'currency_code', 'currency_symbol', 'currency_format'];
|
|
6362
6527
|
guardedFields = [].concat(publishedFields, ['customer_id', 'discount_list', 'shop_discount', 'payments']);
|
|
6363
6528
|
readFields = function readFields(order, fields) {
|
|
@@ -6412,43 +6577,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6412
6577
|
venue_booking_service_datetime: serviceDatetime
|
|
6413
6578
|
});
|
|
6414
6579
|
replacement.unique_identification_number = uid;
|
|
6415
|
-
|
|
6416
|
-
|
|
6580
|
+
replacementBooking = cloneDeep(params.booking);
|
|
6581
|
+
replacementBooking.uuid = targetBookings[0].uuid || replacementBooking.uuid;
|
|
6582
|
+
_context36.next = 62;
|
|
6583
|
+
return this.appendProductLineToTempOrder(draft, replacement, replacementBooking, {
|
|
6417
6584
|
insertAtIndex: targetIndex,
|
|
6418
6585
|
disableMerge: true,
|
|
6419
6586
|
beforeCommit: beforeCommit
|
|
6420
6587
|
});
|
|
6421
|
-
case
|
|
6588
|
+
case 62:
|
|
6422
6589
|
_iterator28 = _createForOfIteratorHelper(nextChildren.entries());
|
|
6423
|
-
|
|
6590
|
+
_context36.prev = 63;
|
|
6424
6591
|
_iterator28.s();
|
|
6425
|
-
case
|
|
6592
|
+
case 65:
|
|
6426
6593
|
if ((_step28 = _iterator28.n()).done) {
|
|
6427
|
-
|
|
6594
|
+
_context36.next = 71;
|
|
6428
6595
|
break;
|
|
6429
6596
|
}
|
|
6430
6597
|
_step28$value = _slicedToArray(_step28.value, 2), index = _step28$value[0], child = _step28$value[1];
|
|
6431
|
-
|
|
6598
|
+
_context36.next = 69;
|
|
6432
6599
|
return this.appendProductLineToTempOrder(draft, child, undefined, {
|
|
6433
6600
|
insertAtIndex: targetIndex + index + 1,
|
|
6434
6601
|
disableMerge: true,
|
|
6435
6602
|
beforeCommit: beforeCommit
|
|
6436
6603
|
});
|
|
6437
|
-
case
|
|
6438
|
-
|
|
6604
|
+
case 69:
|
|
6605
|
+
_context36.next = 65;
|
|
6439
6606
|
break;
|
|
6440
|
-
case
|
|
6441
|
-
|
|
6607
|
+
case 71:
|
|
6608
|
+
_context36.next = 76;
|
|
6442
6609
|
break;
|
|
6443
|
-
case 70:
|
|
6444
|
-
_context33.prev = 70;
|
|
6445
|
-
_context33.t2 = _context33["catch"](60);
|
|
6446
|
-
_iterator28.e(_context33.t2);
|
|
6447
6610
|
case 73:
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6611
|
+
_context36.prev = 73;
|
|
6612
|
+
_context36.t2 = _context36["catch"](63);
|
|
6613
|
+
_iterator28.e(_context36.t2);
|
|
6451
6614
|
case 76:
|
|
6615
|
+
_context36.prev = 76;
|
|
6616
|
+
_iterator28.f();
|
|
6617
|
+
return _context36.finish(76);
|
|
6618
|
+
case 79:
|
|
6452
6619
|
this.removeSalesNotesForMissingProductLines(draft);
|
|
6453
6620
|
this.syncTempOrderHolderFromBookings(draft);
|
|
6454
6621
|
beforePublish = function beforePublish() {
|
|
@@ -6462,47 +6629,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6462
6629
|
};
|
|
6463
6630
|
beforePublish();
|
|
6464
6631
|
if (!mutation.commit) {
|
|
6465
|
-
|
|
6632
|
+
_context36.next = 88;
|
|
6466
6633
|
break;
|
|
6467
6634
|
}
|
|
6468
|
-
|
|
6635
|
+
_context36.next = 86;
|
|
6469
6636
|
return mutation.commit({
|
|
6470
6637
|
beforeCommit: beforePublish
|
|
6471
6638
|
});
|
|
6472
|
-
case
|
|
6473
|
-
|
|
6639
|
+
case 86:
|
|
6640
|
+
_context36.next = 89;
|
|
6474
6641
|
break;
|
|
6475
|
-
case
|
|
6642
|
+
case 88:
|
|
6476
6643
|
// No await between the final CAS and publication; preserve every unrelated live field.
|
|
6477
6644
|
Object.assign(live, readFields(draft, publishedFields));
|
|
6478
|
-
case
|
|
6479
|
-
|
|
6645
|
+
case 89:
|
|
6646
|
+
_context36.prev = 89;
|
|
6480
6647
|
if (isCurrentOrder()) this.persistTempOrder();
|
|
6481
|
-
|
|
6648
|
+
_context36.next = 93;
|
|
6482
6649
|
return this.finalizeProductOrderMutation(live, {
|
|
6483
6650
|
isCurrentOrder: isCurrentOrder
|
|
6484
6651
|
});
|
|
6485
|
-
case
|
|
6486
|
-
|
|
6652
|
+
case 93:
|
|
6653
|
+
_context36.next = 98;
|
|
6487
6654
|
break;
|
|
6488
|
-
case
|
|
6489
|
-
|
|
6490
|
-
|
|
6655
|
+
case 95:
|
|
6656
|
+
_context36.prev = 95;
|
|
6657
|
+
_context36.t3 = _context36["catch"](89);
|
|
6491
6658
|
// Already committed. Do not invite a second replacement or restore a stale snapshot.
|
|
6492
6659
|
this.logWarning('Party replacement committed; finalization failed', {
|
|
6493
6660
|
productLineUid: uid,
|
|
6494
6661
|
committed: true,
|
|
6495
|
-
error:
|
|
6662
|
+
error: _context36.t3 instanceof Error ? _context36.t3.message : String(_context36.t3)
|
|
6496
6663
|
});
|
|
6497
|
-
case
|
|
6498
|
-
return
|
|
6499
|
-
case
|
|
6664
|
+
case 98:
|
|
6665
|
+
return _context36.abrupt("return", live.products);
|
|
6666
|
+
case 99:
|
|
6500
6667
|
case "end":
|
|
6501
|
-
return
|
|
6668
|
+
return _context36.stop();
|
|
6502
6669
|
}
|
|
6503
|
-
},
|
|
6670
|
+
}, _callee32, this, [[25, 34, 37, 40], [63, 73, 76, 79], [89, 95]]);
|
|
6504
6671
|
}));
|
|
6505
|
-
function replaceBookingProductWithRelatedRetailDraft(
|
|
6672
|
+
function replaceBookingProductWithRelatedRetailDraft(_x36) {
|
|
6506
6673
|
return _replaceBookingProductWithRelatedRetailDraft.apply(this, arguments);
|
|
6507
6674
|
}
|
|
6508
6675
|
return replaceBookingProductWithRelatedRetailDraft;
|
|
@@ -6519,21 +6686,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6519
6686
|
}, {
|
|
6520
6687
|
key: "addProductsToOrder",
|
|
6521
6688
|
value: (function () {
|
|
6522
|
-
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6689
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(items, options) {
|
|
6523
6690
|
var _this43 = this;
|
|
6524
|
-
return _regeneratorRuntime().wrap(function
|
|
6525
|
-
while (1) switch (
|
|
6691
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context37) {
|
|
6692
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
6526
6693
|
case 0:
|
|
6527
|
-
return
|
|
6694
|
+
return _context37.abrupt("return", this.queueCartCommand(function () {
|
|
6528
6695
|
return _this43.addProductsToOrderDraft(items, options);
|
|
6529
6696
|
}));
|
|
6530
6697
|
case 1:
|
|
6531
6698
|
case "end":
|
|
6532
|
-
return
|
|
6699
|
+
return _context37.stop();
|
|
6533
6700
|
}
|
|
6534
|
-
},
|
|
6701
|
+
}, _callee33, this);
|
|
6535
6702
|
}));
|
|
6536
|
-
function addProductsToOrder(
|
|
6703
|
+
function addProductsToOrder(_x37, _x38) {
|
|
6537
6704
|
return _addProductsToOrder.apply(this, arguments);
|
|
6538
6705
|
}
|
|
6539
6706
|
return addProductsToOrder;
|
|
@@ -6541,51 +6708,62 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6541
6708
|
}, {
|
|
6542
6709
|
key: "addProductsToOrderDraft",
|
|
6543
6710
|
value: function () {
|
|
6544
|
-
var _addProductsToOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6545
|
-
var
|
|
6546
|
-
|
|
6547
|
-
|
|
6711
|
+
var _addProductsToOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(items, options) {
|
|
6712
|
+
var _this44 = this;
|
|
6713
|
+
var mutation, tempOrder, beforeCommit, beforeAppend, _iterator29, _step29, item, product, booking, _ref75, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
|
|
6714
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context38) {
|
|
6715
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
6548
6716
|
case 0:
|
|
6549
6717
|
mutation = this.beginCartMutation();
|
|
6550
6718
|
tempOrder = mutation.draft;
|
|
6551
6719
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
6552
|
-
|
|
6720
|
+
_context38.next = 4;
|
|
6553
6721
|
break;
|
|
6554
6722
|
}
|
|
6555
|
-
return
|
|
6723
|
+
return _context38.abrupt("return", tempOrder.products);
|
|
6556
6724
|
case 4:
|
|
6557
6725
|
beforeCommit = this.createCartIntentCommitGuard('add_product');
|
|
6558
6726
|
beforeAppend = mutation.commit ? undefined : beforeCommit;
|
|
6727
|
+
if (!items.some(function (_ref74) {
|
|
6728
|
+
var product = _ref74.product;
|
|
6729
|
+
return product && _this44.requiresPosVirtualCurrencyPayment(product);
|
|
6730
|
+
})) {
|
|
6731
|
+
_context38.next = 9;
|
|
6732
|
+
break;
|
|
6733
|
+
}
|
|
6734
|
+
_context38.next = 9;
|
|
6735
|
+
return this.validatePosVirtualCurrencyCart(this.ensureTempOrder());
|
|
6736
|
+
case 9:
|
|
6559
6737
|
_iterator29 = _createForOfIteratorHelper(items || []);
|
|
6560
|
-
|
|
6738
|
+
_context38.prev = 10;
|
|
6561
6739
|
_iterator29.s();
|
|
6562
|
-
case
|
|
6740
|
+
case 12:
|
|
6563
6741
|
if ((_step29 = _iterator29.n()).done) {
|
|
6564
|
-
|
|
6742
|
+
_context38.next = 38;
|
|
6565
6743
|
break;
|
|
6566
6744
|
}
|
|
6567
6745
|
item = _step29.value;
|
|
6568
6746
|
product = item.product, booking = item.booking;
|
|
6569
6747
|
if (product) {
|
|
6570
|
-
|
|
6748
|
+
_context38.next = 17;
|
|
6571
6749
|
break;
|
|
6572
6750
|
}
|
|
6573
|
-
return
|
|
6574
|
-
case
|
|
6751
|
+
return _context38.abrupt("continue", 36);
|
|
6752
|
+
case 17:
|
|
6575
6753
|
if (!booking) {
|
|
6576
|
-
|
|
6754
|
+
_context38.next = 32;
|
|
6577
6755
|
break;
|
|
6578
6756
|
}
|
|
6579
6757
|
productRecord = product;
|
|
6580
|
-
splitCount = getSafeProductNum((
|
|
6758
|
+
splitCount = getSafeProductNum((_ref75 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref75 !== void 0 ? _ref75 : 1);
|
|
6581
6759
|
if (!(splitCount > 1)) {
|
|
6582
|
-
|
|
6760
|
+
_context38.next = 32;
|
|
6583
6761
|
break;
|
|
6584
6762
|
}
|
|
6585
6763
|
i = 0;
|
|
6586
|
-
case
|
|
6764
|
+
case 22:
|
|
6587
6765
|
if (!(i < splitCount)) {
|
|
6588
|
-
|
|
6766
|
+
_context38.next = 31;
|
|
6589
6767
|
break;
|
|
6590
6768
|
}
|
|
6591
6769
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
@@ -6593,67 +6771,67 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6593
6771
|
beforeCommit: beforeAppend
|
|
6594
6772
|
});
|
|
6595
6773
|
if (!_appendResult) {
|
|
6596
|
-
|
|
6774
|
+
_context38.next = 28;
|
|
6597
6775
|
break;
|
|
6598
6776
|
}
|
|
6599
|
-
|
|
6777
|
+
_context38.next = 28;
|
|
6600
6778
|
return _appendResult;
|
|
6601
|
-
case
|
|
6779
|
+
case 28:
|
|
6602
6780
|
i += 1;
|
|
6603
|
-
|
|
6781
|
+
_context38.next = 22;
|
|
6604
6782
|
break;
|
|
6605
|
-
case
|
|
6606
|
-
return
|
|
6607
|
-
case
|
|
6783
|
+
case 31:
|
|
6784
|
+
return _context38.abrupt("continue", 36);
|
|
6785
|
+
case 32:
|
|
6608
6786
|
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
6609
6787
|
beforeCommit: beforeAppend
|
|
6610
6788
|
});
|
|
6611
6789
|
if (!appendResult) {
|
|
6612
|
-
|
|
6790
|
+
_context38.next = 36;
|
|
6613
6791
|
break;
|
|
6614
6792
|
}
|
|
6615
|
-
|
|
6793
|
+
_context38.next = 36;
|
|
6616
6794
|
return appendResult;
|
|
6617
|
-
case
|
|
6618
|
-
|
|
6795
|
+
case 36:
|
|
6796
|
+
_context38.next = 12;
|
|
6619
6797
|
break;
|
|
6620
|
-
case
|
|
6621
|
-
|
|
6798
|
+
case 38:
|
|
6799
|
+
_context38.next = 43;
|
|
6622
6800
|
break;
|
|
6623
|
-
case 37:
|
|
6624
|
-
_context35.prev = 37;
|
|
6625
|
-
_context35.t0 = _context35["catch"](7);
|
|
6626
|
-
_iterator29.e(_context35.t0);
|
|
6627
6801
|
case 40:
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6802
|
+
_context38.prev = 40;
|
|
6803
|
+
_context38.t0 = _context38["catch"](10);
|
|
6804
|
+
_iterator29.e(_context38.t0);
|
|
6631
6805
|
case 43:
|
|
6806
|
+
_context38.prev = 43;
|
|
6807
|
+
_iterator29.f();
|
|
6808
|
+
return _context38.finish(43);
|
|
6809
|
+
case 46:
|
|
6632
6810
|
if (!mutation.commit) {
|
|
6633
|
-
|
|
6811
|
+
_context38.next = 50;
|
|
6634
6812
|
break;
|
|
6635
6813
|
}
|
|
6636
|
-
|
|
6814
|
+
_context38.next = 49;
|
|
6637
6815
|
return mutation.commit({
|
|
6638
6816
|
beforeCommit: beforeCommit
|
|
6639
6817
|
});
|
|
6640
|
-
case 46:
|
|
6641
|
-
tempOrder = _context35.sent;
|
|
6642
|
-
case 47:
|
|
6643
|
-
_context35.next = 49;
|
|
6644
|
-
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
6645
6818
|
case 49:
|
|
6819
|
+
tempOrder = _context38.sent;
|
|
6820
|
+
case 50:
|
|
6821
|
+
_context38.next = 52;
|
|
6822
|
+
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
6823
|
+
case 52:
|
|
6646
6824
|
this.logInfo('addProductsToOrder success', {
|
|
6647
6825
|
itemsCount: items.length
|
|
6648
6826
|
});
|
|
6649
|
-
return
|
|
6650
|
-
case
|
|
6827
|
+
return _context38.abrupt("return", tempOrder.products);
|
|
6828
|
+
case 54:
|
|
6651
6829
|
case "end":
|
|
6652
|
-
return
|
|
6830
|
+
return _context38.stop();
|
|
6653
6831
|
}
|
|
6654
|
-
},
|
|
6832
|
+
}, _callee34, this, [[10, 40, 43, 46]]);
|
|
6655
6833
|
}));
|
|
6656
|
-
function addProductsToOrderDraft(
|
|
6834
|
+
function addProductsToOrderDraft(_x39, _x40) {
|
|
6657
6835
|
return _addProductsToOrderDraft.apply(this, arguments);
|
|
6658
6836
|
}
|
|
6659
6837
|
return addProductsToOrderDraft;
|
|
@@ -6705,26 +6883,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6705
6883
|
}, {
|
|
6706
6884
|
key: "hasSameEntitlementMergePriceConfig",
|
|
6707
6885
|
value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
|
|
6708
|
-
var
|
|
6886
|
+
var _this45 = this;
|
|
6709
6887
|
var buildPriceConfig = function buildPriceConfig(product) {
|
|
6710
6888
|
var metadata = product.metadata || {};
|
|
6711
6889
|
var bundle = (product.product_bundle || []).map(function (item) {
|
|
6712
|
-
var
|
|
6890
|
+
var _ref76, _item$bundle_id, _ref77, _ref78, _item$bundle_product_, _ref79, _item$bundle_variant_, _ref80, _item$price_type, _ref81, _item$price_type_ext;
|
|
6713
6891
|
return {
|
|
6714
|
-
bundle_id: (
|
|
6715
|
-
bundle_product_id: (
|
|
6716
|
-
bundle_variant_id: (
|
|
6717
|
-
price_type: (
|
|
6718
|
-
price_type_ext: (
|
|
6892
|
+
bundle_id: (_ref76 = (_item$bundle_id = item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item.id) !== null && _ref76 !== void 0 ? _ref76 : null,
|
|
6893
|
+
bundle_product_id: (_ref77 = (_ref78 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref78 !== void 0 ? _ref78 : item.product_id) !== null && _ref77 !== void 0 ? _ref77 : null,
|
|
6894
|
+
bundle_variant_id: (_ref79 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.product_variant_id) !== null && _ref79 !== void 0 ? _ref79 : 0,
|
|
6895
|
+
price_type: (_ref80 = (_item$price_type = item.price_type) !== null && _item$price_type !== void 0 ? _item$price_type : item.custom_price_type) !== null && _ref80 !== void 0 ? _ref80 : '',
|
|
6896
|
+
price_type_ext: (_ref81 = (_item$price_type_ext = item.price_type_ext) !== null && _item$price_type_ext !== void 0 ? _item$price_type_ext : item.custom_price_type_ext) !== null && _ref81 !== void 0 ? _ref81 : ''
|
|
6719
6897
|
};
|
|
6720
6898
|
}).sort(function (left, right) {
|
|
6721
6899
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
6722
6900
|
});
|
|
6723
6901
|
return JSON.stringify({
|
|
6724
|
-
original_price:
|
|
6725
|
-
source_product_price:
|
|
6726
|
-
main_product_original_price:
|
|
6727
|
-
price_override:
|
|
6902
|
+
original_price: _this45.normalizeFingerprintMoney(product.original_price),
|
|
6903
|
+
source_product_price: _this45.normalizeFingerprintMoney(metadata.source_product_price),
|
|
6904
|
+
main_product_original_price: _this45.normalizeFingerprintMoney(metadata.main_product_original_price),
|
|
6905
|
+
price_override: _this45.normalizeFingerprintMoney(metadata.price_override),
|
|
6728
6906
|
is_manual_discount: Boolean(metadata.is_manual_discount),
|
|
6729
6907
|
bundle: bundle
|
|
6730
6908
|
});
|
|
@@ -6734,24 +6912,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6734
6912
|
}, {
|
|
6735
6913
|
key: "getBundleRuntimeIdentity",
|
|
6736
6914
|
value: function getBundleRuntimeIdentity(bundle) {
|
|
6737
|
-
var
|
|
6915
|
+
var _ref82, _bundle$bundle_id2, _ref83, _bundle$bundle_group_2, _ref84, _ref85, _bundle$bundle_produc3, _ref86, _bundle$bundle_varian3;
|
|
6738
6916
|
if (!bundle || _typeof(bundle) !== 'object') return '';
|
|
6739
|
-
return [(
|
|
6917
|
+
return [(_ref82 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref82 !== void 0 ? _ref82 : '', (_ref83 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref83 !== void 0 ? _ref83 : '', (_ref84 = (_ref85 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref85 !== void 0 ? _ref85 : bundle.product_id) !== null && _ref84 !== void 0 ? _ref84 : '', (_ref86 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref86 !== void 0 ? _ref86 : 0].join('|');
|
|
6740
6918
|
}
|
|
6741
6919
|
}, {
|
|
6742
6920
|
key: "preservePersistedBundlePriceFields",
|
|
6743
6921
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
6744
|
-
var
|
|
6922
|
+
var _this46 = this;
|
|
6745
6923
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
6746
6924
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
6747
6925
|
var previousByIdentity = new Map();
|
|
6748
6926
|
previousBundles.forEach(function (bundle) {
|
|
6749
|
-
var identity =
|
|
6927
|
+
var identity = _this46.getBundleRuntimeIdentity(bundle);
|
|
6750
6928
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
6751
6929
|
});
|
|
6752
6930
|
return nextBundles.map(function (bundle, index) {
|
|
6753
6931
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
6754
|
-
var previous = previousByIdentity.get(
|
|
6932
|
+
var previous = previousByIdentity.get(_this46.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
6755
6933
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
6756
6934
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
6757
6935
|
cover: previous.cover
|
|
@@ -6872,10 +7050,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6872
7050
|
var weighedSourcePrice = callerChangesWeighing ? resolveWeighedSourcePrice(nextProduct.product_sku) : undefined;
|
|
6873
7051
|
var hasResolvedWeighedPrice = weighedSourcePrice !== undefined;
|
|
6874
7052
|
if (hasResolvedWeighedPrice && !callerUpdatesSourcePrice) {
|
|
6875
|
-
var
|
|
7053
|
+
var _ref87, _targetProduct$metada3, _targetProduct$metada4, _ref88, _targetProduct$metada5, _targetProduct$metada6;
|
|
6876
7054
|
var nextMainOriginal = new Decimal(weighedSourcePrice).plus(sumOptionUnitPrice(getProductSkuOptions(nextProduct)));
|
|
6877
|
-
var previousMainOriginal = new Decimal((
|
|
6878
|
-
var previousMainSelling = new Decimal((
|
|
7055
|
+
var previousMainOriginal = new Decimal((_ref87 = (_targetProduct$metada3 = (_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.main_product_original_price) !== null && _targetProduct$metada3 !== void 0 ? _targetProduct$metada3 : targetProduct.original_price) !== null && _ref87 !== void 0 ? _ref87 : 0);
|
|
7056
|
+
var previousMainSelling = new Decimal((_ref88 = (_targetProduct$metada5 = (_targetProduct$metada6 = targetProduct.metadata) === null || _targetProduct$metada6 === void 0 ? void 0 : _targetProduct$metada6.main_product_selling_price) !== null && _targetProduct$metada5 !== void 0 ? _targetProduct$metada5 : targetProduct.selling_price) !== null && _ref88 !== void 0 ? _ref88 : 0);
|
|
6879
7057
|
// A manual final price remains fixed; other legacy discounts keep their amount
|
|
6880
7058
|
// until Rules reapplies the currently selected wallet discount below.
|
|
6881
7059
|
var nextMainSelling = isManualProductDiscountProduct(nextProduct) ? previousMainSelling : nextMainOriginal.minus(previousMainOriginal.minus(previousMainSelling));
|
|
@@ -6923,13 +7101,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6923
7101
|
delete nextProduct.metadata.main_product_original_price;
|
|
6924
7102
|
delete nextProduct.metadata.price_schema_version;
|
|
6925
7103
|
} else if (callerChangesLineConfiguration && !hasResolvedWeighedPrice && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
6926
|
-
var
|
|
7104
|
+
var _ref89, _targetProduct$metada15, _targetProduct$metada16, _ref90, _targetProduct$metada17, _targetProduct$metada18, _targetProduct$metada19;
|
|
6927
7105
|
// 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
|
|
6928
7106
|
// 但必须让 original 与 selling 一起随新的 option 金额移动。
|
|
6929
7107
|
var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
|
|
6930
7108
|
var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
|
|
6931
|
-
var _previousMainOriginal2 = new Decimal(Number((
|
|
6932
|
-
var _previousMainSelling2 = new Decimal(Number((
|
|
7109
|
+
var _previousMainOriginal2 = new Decimal(Number((_ref89 = (_targetProduct$metada15 = (_targetProduct$metada16 = targetProduct.metadata) === null || _targetProduct$metada16 === void 0 ? void 0 : _targetProduct$metada16.main_product_original_price) !== null && _targetProduct$metada15 !== void 0 ? _targetProduct$metada15 : targetProduct.original_price) !== null && _ref89 !== void 0 ? _ref89 : 0) || 0);
|
|
7110
|
+
var _previousMainSelling2 = new Decimal(Number((_ref90 = (_targetProduct$metada17 = (_targetProduct$metada18 = targetProduct.metadata) === null || _targetProduct$metada18 === void 0 ? void 0 : _targetProduct$metada18.main_product_selling_price) !== null && _targetProduct$metada17 !== void 0 ? _targetProduct$metada17 : targetProduct.selling_price) !== null && _ref90 !== void 0 ? _ref90 : _previousMainOriginal2.toNumber()) || 0);
|
|
6933
7111
|
var _preservedDiscount = _previousMainOriginal2.minus(_previousMainSelling2);
|
|
6934
7112
|
var previousSource = ((_targetProduct$metada19 = targetProduct.metadata) === null || _targetProduct$metada19 === void 0 ? void 0 : _targetProduct$metada19.source_product_price) != null ? new Decimal(Number(targetProduct.metadata.source_product_price) || 0) : _previousMainOriginal2.minus(previousOptionSum);
|
|
6935
7113
|
var _nextMainOriginal2 = previousSource.plus(nextOptionSum);
|
|
@@ -6988,16 +7166,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6988
7166
|
});
|
|
6989
7167
|
}
|
|
6990
7168
|
if (booking) {
|
|
6991
|
-
var _normalizedProduct$me, _targetProduct$metada21;
|
|
7169
|
+
var _normalizedProduct$me, _targetProduct$metada21, _targetProduct$metada22, _bookings$find;
|
|
6992
7170
|
var productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada21 = targetProduct.metadata) === null || _targetProduct$metada21 === void 0 ? void 0 : _targetProduct$metada21.unique_identification_number) || unique_identification_number || createUuidV4());
|
|
6993
7171
|
normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
6994
7172
|
unique_identification_number: productUid
|
|
6995
7173
|
});
|
|
7174
|
+
var originalBookingUid = targetProduct.booking_uid || ((_targetProduct$metada22 = targetProduct.metadata) === null || _targetProduct$metada22 === void 0 ? void 0 : _targetProduct$metada22.booking_uid) || preservedBookingUid;
|
|
7175
|
+
var bookings = tempOrder.bookings || [];
|
|
7176
|
+
var eventId = booking.schedule_event_id;
|
|
7177
|
+
var originalBooking = (_bookings$find = bookings.find(function (row) {
|
|
7178
|
+
return Number(eventId) > 0 && String(row.schedule_event_id) === String(eventId);
|
|
7179
|
+
})) !== null && _bookings$find !== void 0 ? _bookings$find : bookings.find(function (row) {
|
|
7180
|
+
var _row$metadata;
|
|
7181
|
+
return originalBookingUid && ((_row$metadata = row.metadata) === null || _row$metadata === void 0 ? void 0 : _row$metadata.unique_identification_number) === originalBookingUid;
|
|
7182
|
+
});
|
|
7183
|
+
var _booking$uuid = booking.uuid,
|
|
7184
|
+
incomingUuid = _booking$uuid === void 0 ? originalBooking === null || originalBooking === void 0 ? void 0 : originalBooking.uuid : _booking$uuid;
|
|
6996
7185
|
var linked = this.createLinkedProductAndBooking({
|
|
6997
7186
|
product: _objectSpread(_objectSpread({}, normalizedProduct), {}, {
|
|
6998
7187
|
unique_identification_number: productUid
|
|
6999
7188
|
}),
|
|
7000
|
-
booking: booking
|
|
7189
|
+
booking: _objectSpread(_objectSpread({}, booking), {}, {
|
|
7190
|
+
uuid: (originalBooking === null || originalBooking === void 0 ? void 0 : originalBooking.uuid) || incomingUuid
|
|
7191
|
+
})
|
|
7001
7192
|
});
|
|
7002
7193
|
this.removeLinkedBookingsForProduct(tempOrder, targetProduct);
|
|
7003
7194
|
normalizedProduct = _objectSpread(_objectSpread({}, normalizedProduct), {}, {
|
|
@@ -7023,21 +7214,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7023
7214
|
}, {
|
|
7024
7215
|
key: "updateOrderProduct",
|
|
7025
7216
|
value: function () {
|
|
7026
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7027
|
-
var
|
|
7028
|
-
return _regeneratorRuntime().wrap(function
|
|
7029
|
-
while (1) switch (
|
|
7217
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
7218
|
+
var _this47 = this;
|
|
7219
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context39) {
|
|
7220
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
7030
7221
|
case 0:
|
|
7031
|
-
return
|
|
7032
|
-
return
|
|
7222
|
+
return _context39.abrupt("return", this.queueCartCommand(function () {
|
|
7223
|
+
return _this47.updateOrderProductDraft(params);
|
|
7033
7224
|
}));
|
|
7034
7225
|
case 1:
|
|
7035
7226
|
case "end":
|
|
7036
|
-
return
|
|
7227
|
+
return _context39.stop();
|
|
7037
7228
|
}
|
|
7038
|
-
},
|
|
7229
|
+
}, _callee35, this);
|
|
7039
7230
|
}));
|
|
7040
|
-
function updateOrderProduct(
|
|
7231
|
+
function updateOrderProduct(_x41) {
|
|
7041
7232
|
return _updateOrderProduct.apply(this, arguments);
|
|
7042
7233
|
}
|
|
7043
7234
|
return updateOrderProduct;
|
|
@@ -7045,10 +7236,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7045
7236
|
}, {
|
|
7046
7237
|
key: "updateOrderProductDraft",
|
|
7047
7238
|
value: function () {
|
|
7048
|
-
var _updateOrderProductDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7239
|
+
var _updateOrderProductDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
7049
7240
|
var mutation, tempOrder, beforeCommit, reapplyWeighedDiscountProductUids, updatedProductUid, promotionPayload;
|
|
7050
|
-
return _regeneratorRuntime().wrap(function
|
|
7051
|
-
while (1) switch (
|
|
7241
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context40) {
|
|
7242
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
7052
7243
|
case 0:
|
|
7053
7244
|
mutation = this.beginCartMutation();
|
|
7054
7245
|
tempOrder = mutation.draft;
|
|
@@ -7057,26 +7248,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7057
7248
|
reapplyWeighedDiscountProductUids = [];
|
|
7058
7249
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
7059
7250
|
if (!mutation.commit) {
|
|
7060
|
-
|
|
7251
|
+
_context40.next = 10;
|
|
7061
7252
|
break;
|
|
7062
7253
|
}
|
|
7063
|
-
|
|
7254
|
+
_context40.next = 9;
|
|
7064
7255
|
return mutation.commit({
|
|
7065
7256
|
beforeCommit: beforeCommit
|
|
7066
7257
|
});
|
|
7067
7258
|
case 9:
|
|
7068
|
-
tempOrder =
|
|
7259
|
+
tempOrder = _context40.sent;
|
|
7069
7260
|
case 10:
|
|
7070
|
-
|
|
7261
|
+
_context40.next = 12;
|
|
7071
7262
|
return this.evaluatePromotion();
|
|
7072
7263
|
case 12:
|
|
7073
|
-
promotionPayload =
|
|
7264
|
+
promotionPayload = _context40.sent;
|
|
7074
7265
|
this.applyDiscount({
|
|
7075
7266
|
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
7076
7267
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
7077
7268
|
});
|
|
7078
7269
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
7079
|
-
|
|
7270
|
+
_context40.next = 17;
|
|
7080
7271
|
return this.recalculateSummary({
|
|
7081
7272
|
createIfMissing: true
|
|
7082
7273
|
});
|
|
@@ -7086,14 +7277,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7086
7277
|
this.logInfo('updateOrderProduct success', {
|
|
7087
7278
|
params: params
|
|
7088
7279
|
});
|
|
7089
|
-
return
|
|
7280
|
+
return _context40.abrupt("return", tempOrder.products);
|
|
7090
7281
|
case 21:
|
|
7091
7282
|
case "end":
|
|
7092
|
-
return
|
|
7283
|
+
return _context40.stop();
|
|
7093
7284
|
}
|
|
7094
|
-
},
|
|
7285
|
+
}, _callee36, this);
|
|
7095
7286
|
}));
|
|
7096
|
-
function updateOrderProductDraft(
|
|
7287
|
+
function updateOrderProductDraft(_x42) {
|
|
7097
7288
|
return _updateOrderProductDraft.apply(this, arguments);
|
|
7098
7289
|
}
|
|
7099
7290
|
return updateOrderProductDraft;
|
|
@@ -7101,21 +7292,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7101
7292
|
}, {
|
|
7102
7293
|
key: "updateOrderProducts",
|
|
7103
7294
|
value: function () {
|
|
7104
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7105
|
-
var
|
|
7106
|
-
return _regeneratorRuntime().wrap(function
|
|
7107
|
-
while (1) switch (
|
|
7295
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(paramsList, options) {
|
|
7296
|
+
var _this48 = this;
|
|
7297
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context41) {
|
|
7298
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
7108
7299
|
case 0:
|
|
7109
|
-
return
|
|
7110
|
-
return
|
|
7300
|
+
return _context41.abrupt("return", this.queueCartCommand(function () {
|
|
7301
|
+
return _this48.updateOrderProductsDraft(paramsList, options);
|
|
7111
7302
|
}));
|
|
7112
7303
|
case 1:
|
|
7113
7304
|
case "end":
|
|
7114
|
-
return
|
|
7305
|
+
return _context41.stop();
|
|
7115
7306
|
}
|
|
7116
|
-
},
|
|
7307
|
+
}, _callee37, this);
|
|
7117
7308
|
}));
|
|
7118
|
-
function updateOrderProducts(
|
|
7309
|
+
function updateOrderProducts(_x43, _x44) {
|
|
7119
7310
|
return _updateOrderProducts.apply(this, arguments);
|
|
7120
7311
|
}
|
|
7121
7312
|
return updateOrderProducts;
|
|
@@ -7123,33 +7314,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7123
7314
|
}, {
|
|
7124
7315
|
key: "updateOrderProductsDraft",
|
|
7125
7316
|
value: function () {
|
|
7126
|
-
var _updateOrderProductsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7127
|
-
var
|
|
7317
|
+
var _updateOrderProductsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(paramsList, options) {
|
|
7318
|
+
var _this49 = this;
|
|
7128
7319
|
var mutation, tempOrder, beforeCommit, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids;
|
|
7129
|
-
return _regeneratorRuntime().wrap(function
|
|
7130
|
-
while (1) switch (
|
|
7320
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context42) {
|
|
7321
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
7131
7322
|
case 0:
|
|
7132
7323
|
if (!options) {
|
|
7133
|
-
|
|
7324
|
+
_context42.next = 2;
|
|
7134
7325
|
break;
|
|
7135
7326
|
}
|
|
7136
|
-
return
|
|
7327
|
+
return _context42.abrupt("return", this.updateOrderProductsGuarded(paramsList, options));
|
|
7137
7328
|
case 2:
|
|
7138
7329
|
mutation = this.beginCartMutation();
|
|
7139
7330
|
tempOrder = mutation.draft;
|
|
7140
7331
|
if (paramsList.length) {
|
|
7141
|
-
|
|
7332
|
+
_context42.next = 6;
|
|
7142
7333
|
break;
|
|
7143
7334
|
}
|
|
7144
|
-
return
|
|
7335
|
+
return _context42.abrupt("return", tempOrder.products);
|
|
7145
7336
|
case 6:
|
|
7146
7337
|
beforeCommit = paramsList.some(function (params) {
|
|
7147
|
-
return
|
|
7338
|
+
return _this49.isRestrictedCartProductUpdate(tempOrder, params);
|
|
7148
7339
|
}) ? this.createCartIntentCommitGuard('update_product') : undefined;
|
|
7149
7340
|
if (!mutation.commit) beforeCommit === null || beforeCommit === void 0 || beforeCommit();
|
|
7150
7341
|
reapplyWeighedDiscountProductUids = [];
|
|
7151
7342
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
7152
|
-
var updatedProductUid =
|
|
7343
|
+
var updatedProductUid = _this49.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
7153
7344
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
7154
7345
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
7155
7346
|
acc.push(String(updatedProductUid));
|
|
@@ -7157,17 +7348,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7157
7348
|
return acc;
|
|
7158
7349
|
}, []);
|
|
7159
7350
|
if (!mutation.commit) {
|
|
7160
|
-
|
|
7351
|
+
_context42.next = 14;
|
|
7161
7352
|
break;
|
|
7162
7353
|
}
|
|
7163
|
-
|
|
7354
|
+
_context42.next = 13;
|
|
7164
7355
|
return mutation.commit({
|
|
7165
7356
|
beforeCommit: beforeCommit
|
|
7166
7357
|
});
|
|
7167
7358
|
case 13:
|
|
7168
|
-
tempOrder =
|
|
7359
|
+
tempOrder = _context42.sent;
|
|
7169
7360
|
case 14:
|
|
7170
|
-
|
|
7361
|
+
_context42.next = 16;
|
|
7171
7362
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
7172
7363
|
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
7173
7364
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
@@ -7176,14 +7367,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7176
7367
|
this.logInfo('updateOrderProduct success', {
|
|
7177
7368
|
paramsList: paramsList
|
|
7178
7369
|
});
|
|
7179
|
-
return
|
|
7370
|
+
return _context42.abrupt("return", tempOrder.products);
|
|
7180
7371
|
case 18:
|
|
7181
7372
|
case "end":
|
|
7182
|
-
return
|
|
7373
|
+
return _context42.stop();
|
|
7183
7374
|
}
|
|
7184
|
-
},
|
|
7375
|
+
}, _callee38, this);
|
|
7185
7376
|
}));
|
|
7186
|
-
function updateOrderProductsDraft(
|
|
7377
|
+
function updateOrderProductsDraft(_x45, _x46) {
|
|
7187
7378
|
return _updateOrderProductsDraft.apply(this, arguments);
|
|
7188
7379
|
}
|
|
7189
7380
|
return updateOrderProductsDraft;
|
|
@@ -7191,12 +7382,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7191
7382
|
}, {
|
|
7192
7383
|
key: "updateOrderProductsGuarded",
|
|
7193
7384
|
value: function () {
|
|
7194
|
-
var _updateOrderProductsGuarded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7385
|
+
var _updateOrderProductsGuarded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(paramsList, options) {
|
|
7195
7386
|
var _options$beforeApply,
|
|
7196
|
-
|
|
7197
|
-
var stale, live, mutation, identity, isCurrentOrder, beforeCommit, publishedFields, guardedFields, readFields, baseline, draft, seen, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids, _iterator30, _step30,
|
|
7198
|
-
return _regeneratorRuntime().wrap(function
|
|
7199
|
-
while (1) switch (
|
|
7387
|
+
_this50 = this;
|
|
7388
|
+
var stale, live, mutation, identity, isCurrentOrder, beforeCommit, publishedFields, guardedFields, readFields, baseline, draft, seen, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids, _iterator30, _step30, _loop5, beforePublish;
|
|
7389
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context44) {
|
|
7390
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
7200
7391
|
case 0:
|
|
7201
7392
|
stale = function stale() {
|
|
7202
7393
|
return Object.assign(new Error('Order product update interrupted by an order change'), {
|
|
@@ -7205,23 +7396,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7205
7396
|
};
|
|
7206
7397
|
(_options$beforeApply = options.beforeApply) === null || _options$beforeApply === void 0 || _options$beforeApply.call(options);
|
|
7207
7398
|
if (!(options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
7208
|
-
|
|
7399
|
+
_context44.next = 4;
|
|
7209
7400
|
break;
|
|
7210
7401
|
}
|
|
7211
7402
|
throw stale();
|
|
7212
7403
|
case 4:
|
|
7213
7404
|
live = this.ensureTempOrder();
|
|
7214
7405
|
if (paramsList.length) {
|
|
7215
|
-
|
|
7406
|
+
_context44.next = 7;
|
|
7216
7407
|
break;
|
|
7217
7408
|
}
|
|
7218
|
-
return
|
|
7409
|
+
return _context44.abrupt("return", live.products);
|
|
7219
7410
|
case 7:
|
|
7220
7411
|
mutation = this.beginCartMutation();
|
|
7221
7412
|
identity = [live.order_id, live.external_sale_number];
|
|
7222
7413
|
isCurrentOrder = function isCurrentOrder() {
|
|
7223
7414
|
var _options$isCurrentOrd3, _options$isCurrentOrd4;
|
|
7224
|
-
return
|
|
7415
|
+
return _this50.store.tempOrder === live && live.order_id === identity[0] && live.external_sale_number === identity[1] && ((_options$isCurrentOrd3 = (_options$isCurrentOrd4 = options.isCurrentOrder) === null || _options$isCurrentOrd4 === void 0 ? void 0 : _options$isCurrentOrd4.call(options)) !== null && _options$isCurrentOrd3 !== void 0 ? _options$isCurrentOrd3 : true);
|
|
7225
7416
|
};
|
|
7226
7417
|
beforeCommit = this.createCartIntentCommitGuard('update_product', live);
|
|
7227
7418
|
publishedFields = ['products', 'bookings', 'notes', '_extend', 'metadata', 'holder', 'holder_relations'];
|
|
@@ -7237,11 +7428,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7237
7428
|
reapplyWeighedDiscountProductUids = [];
|
|
7238
7429
|
reapplyBookingDiscountProductUids = [];
|
|
7239
7430
|
_iterator30 = _createForOfIteratorHelper(paramsList);
|
|
7240
|
-
|
|
7241
|
-
|
|
7431
|
+
_context44.prev = 20;
|
|
7432
|
+
_loop5 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop5() {
|
|
7242
7433
|
var params, uid, matches, target, updatedUid;
|
|
7243
|
-
return _regeneratorRuntime().wrap(function
|
|
7244
|
-
while (1) switch (
|
|
7434
|
+
return _regeneratorRuntime().wrap(function _loop5$(_context43) {
|
|
7435
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
7245
7436
|
case 0:
|
|
7246
7437
|
params = _step30.value;
|
|
7247
7438
|
uid = String(params.unique_identification_number || '');
|
|
@@ -7251,41 +7442,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7251
7442
|
});
|
|
7252
7443
|
target = matches[0]; // Guarded re-quotation must identify the exact row; never fall back to another same-SKU line.
|
|
7253
7444
|
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))) {
|
|
7254
|
-
|
|
7445
|
+
_context43.next = 6;
|
|
7255
7446
|
break;
|
|
7256
7447
|
}
|
|
7257
7448
|
throw stale();
|
|
7258
7449
|
case 6:
|
|
7259
7450
|
seen.add(uid);
|
|
7260
|
-
updatedUid =
|
|
7451
|
+
updatedUid = _this50.applyOrderProductUpdateToTempOrder(draft, cloneDeep(params), reapplyWeighedDiscountProductUids);
|
|
7261
7452
|
if (params.allow_booking_discount_reapply && updatedUid) reapplyBookingDiscountProductUids.push(updatedUid);
|
|
7262
7453
|
case 9:
|
|
7263
7454
|
case "end":
|
|
7264
|
-
return
|
|
7455
|
+
return _context43.stop();
|
|
7265
7456
|
}
|
|
7266
|
-
},
|
|
7457
|
+
}, _loop5);
|
|
7267
7458
|
});
|
|
7268
7459
|
_iterator30.s();
|
|
7269
7460
|
case 23:
|
|
7270
7461
|
if ((_step30 = _iterator30.n()).done) {
|
|
7271
|
-
|
|
7462
|
+
_context44.next = 27;
|
|
7272
7463
|
break;
|
|
7273
7464
|
}
|
|
7274
|
-
return
|
|
7465
|
+
return _context44.delegateYield(_loop5(), "t0", 25);
|
|
7275
7466
|
case 25:
|
|
7276
|
-
|
|
7467
|
+
_context44.next = 23;
|
|
7277
7468
|
break;
|
|
7278
7469
|
case 27:
|
|
7279
|
-
|
|
7470
|
+
_context44.next = 32;
|
|
7280
7471
|
break;
|
|
7281
7472
|
case 29:
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
_iterator30.e(
|
|
7473
|
+
_context44.prev = 29;
|
|
7474
|
+
_context44.t1 = _context44["catch"](20);
|
|
7475
|
+
_iterator30.e(_context44.t1);
|
|
7285
7476
|
case 32:
|
|
7286
|
-
|
|
7477
|
+
_context44.prev = 32;
|
|
7287
7478
|
_iterator30.f();
|
|
7288
|
-
return
|
|
7479
|
+
return _context44.finish(32);
|
|
7289
7480
|
case 35:
|
|
7290
7481
|
beforePublish = function beforePublish() {
|
|
7291
7482
|
var _options$beforeApply2;
|
|
@@ -7295,46 +7486,46 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7295
7486
|
};
|
|
7296
7487
|
beforePublish();
|
|
7297
7488
|
if (!mutation.commit) {
|
|
7298
|
-
|
|
7489
|
+
_context44.next = 42;
|
|
7299
7490
|
break;
|
|
7300
7491
|
}
|
|
7301
|
-
|
|
7492
|
+
_context44.next = 40;
|
|
7302
7493
|
return mutation.commit({
|
|
7303
7494
|
beforeCommit: beforePublish
|
|
7304
7495
|
});
|
|
7305
7496
|
case 40:
|
|
7306
|
-
|
|
7497
|
+
_context44.next = 43;
|
|
7307
7498
|
break;
|
|
7308
7499
|
case 42:
|
|
7309
7500
|
Object.assign(live, readFields(draft, publishedFields));
|
|
7310
7501
|
case 43:
|
|
7311
|
-
|
|
7502
|
+
_context44.prev = 43;
|
|
7312
7503
|
if (isCurrentOrder()) this.persistTempOrder();
|
|
7313
|
-
|
|
7504
|
+
_context44.next = 47;
|
|
7314
7505
|
return this.finalizeAfterProductsMutation(live, {
|
|
7315
7506
|
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
7316
7507
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids,
|
|
7317
7508
|
isCurrentOrder: isCurrentOrder
|
|
7318
7509
|
});
|
|
7319
7510
|
case 47:
|
|
7320
|
-
|
|
7511
|
+
_context44.next = 52;
|
|
7321
7512
|
break;
|
|
7322
7513
|
case 49:
|
|
7323
|
-
|
|
7324
|
-
|
|
7514
|
+
_context44.prev = 49;
|
|
7515
|
+
_context44.t2 = _context44["catch"](43);
|
|
7325
7516
|
this.logWarning('Order product update committed; finalization failed', {
|
|
7326
7517
|
committed: true,
|
|
7327
|
-
error:
|
|
7518
|
+
error: _context44.t2 instanceof Error ? _context44.t2.message : String(_context44.t2)
|
|
7328
7519
|
});
|
|
7329
7520
|
case 52:
|
|
7330
|
-
return
|
|
7521
|
+
return _context44.abrupt("return", live.products);
|
|
7331
7522
|
case 53:
|
|
7332
7523
|
case "end":
|
|
7333
|
-
return
|
|
7524
|
+
return _context44.stop();
|
|
7334
7525
|
}
|
|
7335
|
-
},
|
|
7526
|
+
}, _callee39, this, [[20, 29, 32, 35], [43, 49]]);
|
|
7336
7527
|
}));
|
|
7337
|
-
function updateOrderProductsGuarded(
|
|
7528
|
+
function updateOrderProductsGuarded(_x47, _x48) {
|
|
7338
7529
|
return _updateOrderProductsGuarded.apply(this, arguments);
|
|
7339
7530
|
}
|
|
7340
7531
|
return updateOrderProductsGuarded;
|
|
@@ -7342,21 +7533,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7342
7533
|
}, {
|
|
7343
7534
|
key: "updateOrderProductQuantity",
|
|
7344
7535
|
value: function () {
|
|
7345
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7346
|
-
var
|
|
7347
|
-
return _regeneratorRuntime().wrap(function
|
|
7348
|
-
while (1) switch (
|
|
7536
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params, options) {
|
|
7537
|
+
var _this51 = this;
|
|
7538
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context45) {
|
|
7539
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
7349
7540
|
case 0:
|
|
7350
|
-
return
|
|
7351
|
-
return
|
|
7541
|
+
return _context45.abrupt("return", this.queueCartCommand(function () {
|
|
7542
|
+
return _this51.updateOrderProductQuantityDraft(params, options);
|
|
7352
7543
|
}));
|
|
7353
7544
|
case 1:
|
|
7354
7545
|
case "end":
|
|
7355
|
-
return
|
|
7546
|
+
return _context45.stop();
|
|
7356
7547
|
}
|
|
7357
|
-
},
|
|
7548
|
+
}, _callee40, this);
|
|
7358
7549
|
}));
|
|
7359
|
-
function updateOrderProductQuantity(
|
|
7550
|
+
function updateOrderProductQuantity(_x49, _x50) {
|
|
7360
7551
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
7361
7552
|
}
|
|
7362
7553
|
return updateOrderProductQuantity;
|
|
@@ -7364,18 +7555,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7364
7555
|
}, {
|
|
7365
7556
|
key: "updateOrderProductQuantityDraft",
|
|
7366
7557
|
value: function () {
|
|
7367
|
-
var _updateOrderProductQuantityDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7368
|
-
var _this$store$tempOrder10, _targetProduct$
|
|
7369
|
-
var isCurrentOrder, 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;
|
|
7370
|
-
return _regeneratorRuntime().wrap(function
|
|
7371
|
-
while (1) switch (
|
|
7558
|
+
var _updateOrderProductQuantityDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params, options) {
|
|
7559
|
+
var _this$store$tempOrder10, _targetProduct$metada23;
|
|
7560
|
+
var isCurrentOrder, 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, liveOrder, products, customerId, isVirtualSettlement, promotionPayload;
|
|
7561
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context46) {
|
|
7562
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
7372
7563
|
case 0:
|
|
7373
7564
|
isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
|
|
7374
7565
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
7375
|
-
|
|
7566
|
+
_context46.next = 3;
|
|
7376
7567
|
break;
|
|
7377
7568
|
}
|
|
7378
|
-
return
|
|
7569
|
+
return _context46.abrupt("return", ((_this$store$tempOrder10 = this.store.tempOrder) === null || _this$store$tempOrder10 === void 0 ? void 0 : _this$store$tempOrder10.products) || []);
|
|
7379
7570
|
case 3:
|
|
7380
7571
|
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;
|
|
7381
7572
|
mutation = this.beginCartMutation();
|
|
@@ -7406,7 +7597,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7406
7597
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
7407
7598
|
}
|
|
7408
7599
|
if (!(productIndex === -1)) {
|
|
7409
|
-
|
|
7600
|
+
_context46.next = 17;
|
|
7410
7601
|
break;
|
|
7411
7602
|
}
|
|
7412
7603
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -7416,13 +7607,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7416
7607
|
normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
7417
7608
|
num: getSafeProductNum(num),
|
|
7418
7609
|
metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
|
|
7419
|
-
unique_identification_number: ((_targetProduct$
|
|
7610
|
+
unique_identification_number: ((_targetProduct$metada23 = targetProduct.metadata) === null || _targetProduct$metada23 === void 0 ? void 0 : _targetProduct$metada23.unique_identification_number) || unique_identification_number
|
|
7420
7611
|
})
|
|
7421
7612
|
})));
|
|
7422
7613
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
7423
7614
|
settlementSnapshot = getSelectedSettlementSnapshot(normalizedProduct);
|
|
7424
7615
|
if (!(this.isMultiCurrencySettlementEnabled() && (settlementSnapshot === null || settlementSnapshot === void 0 ? void 0 : settlementSnapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1)) {
|
|
7425
|
-
|
|
7616
|
+
_context46.next = 31;
|
|
7426
7617
|
break;
|
|
7427
7618
|
}
|
|
7428
7619
|
currencyProductId = Number(settlementSnapshot.currency_product_id);
|
|
@@ -7430,7 +7621,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7430
7621
|
return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
|
|
7431
7622
|
});
|
|
7432
7623
|
if (asset) {
|
|
7433
|
-
|
|
7624
|
+
_context46.next = 27;
|
|
7434
7625
|
break;
|
|
7435
7626
|
}
|
|
7436
7627
|
throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
|
|
@@ -7442,84 +7633,102 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7442
7633
|
}, new Decimal(0));
|
|
7443
7634
|
balance = new Decimal(asset.balance || 0);
|
|
7444
7635
|
if (!balance.lt(requiredAmount)) {
|
|
7445
|
-
|
|
7636
|
+
_context46.next = 31;
|
|
7446
7637
|
break;
|
|
7447
7638
|
}
|
|
7448
7639
|
throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
7449
7640
|
case 31:
|
|
7450
7641
|
beforeCommit = normalizedProduct.num > targetProduct.num ? this.createCartIntentCommitGuard('increase_quantity') : undefined;
|
|
7642
|
+
if (!(beforeCommit && this.requiresPosVirtualCurrencyPayment(normalizedProduct))) {
|
|
7643
|
+
_context46.next = 40;
|
|
7644
|
+
break;
|
|
7645
|
+
}
|
|
7646
|
+
liveOrder = this.ensureTempOrder();
|
|
7647
|
+
products = cloneDeep(liveOrder.products);
|
|
7648
|
+
customerId = liveOrder.customer_id;
|
|
7649
|
+
_context46.next = 38;
|
|
7650
|
+
return this.validatePosVirtualCurrencyCart(liveOrder);
|
|
7651
|
+
case 38:
|
|
7652
|
+
if (!(liveOrder.customer_id !== customerId || !isEqual(liveOrder.products, products))) {
|
|
7653
|
+
_context46.next = 40;
|
|
7654
|
+
break;
|
|
7655
|
+
}
|
|
7656
|
+
throw Object.assign(new Error('The cart changed. Please try again.'), {
|
|
7657
|
+
code: 'SALES_GUARD_REJECTED'
|
|
7658
|
+
});
|
|
7659
|
+
case 40:
|
|
7451
7660
|
if (!mutation.commit) beforeCommit === null || beforeCommit === void 0 || beforeCommit();
|
|
7452
7661
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
7453
|
-
|
|
7662
|
+
_context46.next = 43;
|
|
7454
7663
|
break;
|
|
7455
7664
|
}
|
|
7456
|
-
return
|
|
7457
|
-
case
|
|
7665
|
+
return _context46.abrupt("return", tempOrder.products);
|
|
7666
|
+
case 43:
|
|
7458
7667
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
7459
7668
|
if (!mutation.commit) {
|
|
7460
|
-
|
|
7669
|
+
_context46.next = 48;
|
|
7461
7670
|
break;
|
|
7462
7671
|
}
|
|
7463
|
-
|
|
7672
|
+
_context46.next = 47;
|
|
7464
7673
|
return mutation.commit({
|
|
7465
7674
|
beforeCommit: beforeCommit,
|
|
7466
7675
|
isCurrentOrder: isCurrentOrder
|
|
7467
7676
|
});
|
|
7468
|
-
case
|
|
7469
|
-
tempOrder =
|
|
7470
|
-
case
|
|
7677
|
+
case 47:
|
|
7678
|
+
tempOrder = _context46.sent;
|
|
7679
|
+
case 48:
|
|
7471
7680
|
if (!isCurrentOrder) {
|
|
7472
|
-
|
|
7681
|
+
_context46.next = 53;
|
|
7473
7682
|
break;
|
|
7474
7683
|
}
|
|
7475
|
-
|
|
7684
|
+
_context46.next = 51;
|
|
7476
7685
|
return this.finalizeProductOrderMutation(tempOrder, {
|
|
7477
7686
|
skipEditDiscountConfigRefresh: true,
|
|
7478
7687
|
isCurrentOrder: isCurrentOrder
|
|
7479
7688
|
});
|
|
7480
|
-
case
|
|
7481
|
-
|
|
7689
|
+
case 51:
|
|
7690
|
+
_context46.next = 69;
|
|
7482
7691
|
break;
|
|
7483
|
-
case
|
|
7692
|
+
case 53:
|
|
7484
7693
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
7485
7694
|
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
7486
7695
|
if (isVirtualSettlement) {
|
|
7487
|
-
|
|
7696
|
+
_context46.next = 61;
|
|
7488
7697
|
break;
|
|
7489
7698
|
}
|
|
7490
|
-
|
|
7699
|
+
_context46.next = 58;
|
|
7491
7700
|
return this.evaluatePromotion();
|
|
7492
|
-
case
|
|
7493
|
-
|
|
7494
|
-
|
|
7701
|
+
case 58:
|
|
7702
|
+
_context46.t0 = _context46.sent;
|
|
7703
|
+
_context46.next = 62;
|
|
7495
7704
|
break;
|
|
7496
|
-
case
|
|
7497
|
-
|
|
7498
|
-
case
|
|
7499
|
-
promotionPayload =
|
|
7705
|
+
case 61:
|
|
7706
|
+
_context46.t0 = null;
|
|
7707
|
+
case 62:
|
|
7708
|
+
promotionPayload = _context46.t0;
|
|
7500
7709
|
if (!isVirtualSettlement) {
|
|
7501
7710
|
this.applyDiscount();
|
|
7502
7711
|
}
|
|
7503
7712
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
7504
|
-
|
|
7713
|
+
_context46.next = 67;
|
|
7505
7714
|
return this.recalculateSummary({
|
|
7506
7715
|
createIfMissing: true
|
|
7507
7716
|
});
|
|
7508
|
-
case
|
|
7717
|
+
case 67:
|
|
7509
7718
|
this.persistTempOrder();
|
|
7510
7719
|
this.emitPromotionApplied(promotionPayload);
|
|
7511
|
-
case
|
|
7720
|
+
case 69:
|
|
7512
7721
|
this.logInfo('updateOrderProductQuantity success', {
|
|
7513
7722
|
params: params
|
|
7514
7723
|
});
|
|
7515
|
-
return
|
|
7516
|
-
case
|
|
7724
|
+
return _context46.abrupt("return", tempOrder.products);
|
|
7725
|
+
case 71:
|
|
7517
7726
|
case "end":
|
|
7518
|
-
return
|
|
7727
|
+
return _context46.stop();
|
|
7519
7728
|
}
|
|
7520
|
-
},
|
|
7729
|
+
}, _callee41, this);
|
|
7521
7730
|
}));
|
|
7522
|
-
function updateOrderProductQuantityDraft(
|
|
7731
|
+
function updateOrderProductQuantityDraft(_x51, _x52) {
|
|
7523
7732
|
return _updateOrderProductQuantityDraft.apply(this, arguments);
|
|
7524
7733
|
}
|
|
7525
7734
|
return updateOrderProductQuantityDraft;
|
|
@@ -7537,13 +7746,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7537
7746
|
throw new Error('[Order] 目标 booking 不存在,无法更新');
|
|
7538
7747
|
}
|
|
7539
7748
|
var targetBooking = tempOrder.bookings[bookingIndex] || {};
|
|
7749
|
+
var _updates$uuid = updates.uuid,
|
|
7750
|
+
incomingUuid = _updates$uuid === void 0 ? targetBooking.uuid : _updates$uuid;
|
|
7540
7751
|
var nextBooking = _objectSpread(_objectSpread(_objectSpread({}, targetBooking), updates), {}, {
|
|
7752
|
+
uuid: targetBooking.uuid || incomingUuid,
|
|
7541
7753
|
metadata: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, targetBooking.metadata || {}), updates.metadata || {}), Number((_targetBooking$metada = targetBooking.metadata) === null || _targetBooking$metada === void 0 ? void 0 : _targetBooking$metada.is_change_by_redeem) === 1 ? {
|
|
7542
7754
|
is_change_by_redeem: 1
|
|
7543
7755
|
} : {}), {}, {
|
|
7544
7756
|
unique_identification_number: bookingUid
|
|
7545
7757
|
})
|
|
7546
7758
|
});
|
|
7759
|
+
assignBookingUuid(nextBooking);
|
|
7547
7760
|
this.syncBookingMetadataHolder(nextBooking, nextBooking.metadata);
|
|
7548
7761
|
nextBooking.is_all = normalizeBookingIsAll(nextBooking);
|
|
7549
7762
|
nextBooking.sub_type = normalizeBookingSubType(nextBooking);
|
|
@@ -7563,59 +7776,59 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7563
7776
|
}, {
|
|
7564
7777
|
key: "finalizeAfterProductsMutation",
|
|
7565
7778
|
value: (function () {
|
|
7566
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7779
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(tempOrder, options) {
|
|
7567
7780
|
var isCurrentOrder, promotionPayload, summary;
|
|
7568
|
-
return _regeneratorRuntime().wrap(function
|
|
7569
|
-
while (1) switch (
|
|
7781
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context47) {
|
|
7782
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
7570
7783
|
case 0:
|
|
7571
7784
|
isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
|
|
7572
7785
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
7573
|
-
|
|
7786
|
+
_context47.next = 3;
|
|
7574
7787
|
break;
|
|
7575
7788
|
}
|
|
7576
|
-
return
|
|
7789
|
+
return _context47.abrupt("return");
|
|
7577
7790
|
case 3:
|
|
7578
7791
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
7579
|
-
|
|
7792
|
+
_context47.next = 6;
|
|
7580
7793
|
return this.evaluatePromotion(isCurrentOrder ? {
|
|
7581
7794
|
isCurrentOrder: isCurrentOrder
|
|
7582
7795
|
} : undefined);
|
|
7583
7796
|
case 6:
|
|
7584
|
-
promotionPayload =
|
|
7797
|
+
promotionPayload = _context47.sent;
|
|
7585
7798
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
7586
|
-
|
|
7799
|
+
_context47.next = 9;
|
|
7587
7800
|
break;
|
|
7588
7801
|
}
|
|
7589
|
-
return
|
|
7802
|
+
return _context47.abrupt("return");
|
|
7590
7803
|
case 9:
|
|
7591
7804
|
this.applyDiscount({
|
|
7592
7805
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids,
|
|
7593
7806
|
reapplyWeighedDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyWeighedDiscountProductUids
|
|
7594
7807
|
});
|
|
7595
7808
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
7596
|
-
|
|
7809
|
+
_context47.next = 13;
|
|
7597
7810
|
return this.recalculateSummary(_objectSpread({
|
|
7598
7811
|
createIfMissing: true
|
|
7599
7812
|
}, isCurrentOrder ? {
|
|
7600
7813
|
isCurrentOrder: isCurrentOrder
|
|
7601
7814
|
} : {}));
|
|
7602
7815
|
case 13:
|
|
7603
|
-
summary =
|
|
7816
|
+
summary = _context47.sent;
|
|
7604
7817
|
if (!(isCurrentOrder && (!isCurrentOrder() || !summary))) {
|
|
7605
|
-
|
|
7818
|
+
_context47.next = 16;
|
|
7606
7819
|
break;
|
|
7607
7820
|
}
|
|
7608
|
-
return
|
|
7821
|
+
return _context47.abrupt("return");
|
|
7609
7822
|
case 16:
|
|
7610
7823
|
this.persistTempOrder();
|
|
7611
7824
|
this.emitPromotionApplied(promotionPayload);
|
|
7612
7825
|
case 18:
|
|
7613
7826
|
case "end":
|
|
7614
|
-
return
|
|
7827
|
+
return _context47.stop();
|
|
7615
7828
|
}
|
|
7616
|
-
},
|
|
7829
|
+
}, _callee42, this);
|
|
7617
7830
|
}));
|
|
7618
|
-
function finalizeAfterProductsMutation(
|
|
7831
|
+
function finalizeAfterProductsMutation(_x53, _x54) {
|
|
7619
7832
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
7620
7833
|
}
|
|
7621
7834
|
return finalizeAfterProductsMutation;
|
|
@@ -7630,21 +7843,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7630
7843
|
}, {
|
|
7631
7844
|
key: "removeProductsFromOrder",
|
|
7632
7845
|
value: (function () {
|
|
7633
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7634
|
-
var
|
|
7635
|
-
return _regeneratorRuntime().wrap(function
|
|
7636
|
-
while (1) switch (
|
|
7846
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(identities, options) {
|
|
7847
|
+
var _this52 = this;
|
|
7848
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context48) {
|
|
7849
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
7637
7850
|
case 0:
|
|
7638
|
-
return
|
|
7639
|
-
return
|
|
7851
|
+
return _context48.abrupt("return", this.queueCartCommand(function () {
|
|
7852
|
+
return _this52.removeProductsFromOrderDraft(identities, options);
|
|
7640
7853
|
}));
|
|
7641
7854
|
case 1:
|
|
7642
7855
|
case "end":
|
|
7643
|
-
return
|
|
7856
|
+
return _context48.stop();
|
|
7644
7857
|
}
|
|
7645
|
-
},
|
|
7858
|
+
}, _callee43, this);
|
|
7646
7859
|
}));
|
|
7647
|
-
function removeProductsFromOrder(
|
|
7860
|
+
function removeProductsFromOrder(_x55, _x56) {
|
|
7648
7861
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
7649
7862
|
}
|
|
7650
7863
|
return removeProductsFromOrder;
|
|
@@ -7652,38 +7865,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7652
7865
|
}, {
|
|
7653
7866
|
key: "removeProductsFromOrderDraft",
|
|
7654
7867
|
value: function () {
|
|
7655
|
-
var _removeProductsFromOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7868
|
+
var _removeProductsFromOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(identities, options) {
|
|
7656
7869
|
var _this$store$tempOrder11,
|
|
7657
7870
|
_options$beforeApply3,
|
|
7658
7871
|
_this$store$tempOrder12,
|
|
7659
|
-
|
|
7660
|
-
var isCurrentOrder, mutation, tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator31, _step31,
|
|
7661
|
-
return _regeneratorRuntime().wrap(function
|
|
7662
|
-
while (1) switch (
|
|
7872
|
+
_this53 = this;
|
|
7873
|
+
var isCurrentOrder, mutation, tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator31, _step31, _loop6, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
7874
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context50) {
|
|
7875
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
7663
7876
|
case 0:
|
|
7664
7877
|
isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
|
|
7665
7878
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
7666
|
-
|
|
7879
|
+
_context50.next = 3;
|
|
7667
7880
|
break;
|
|
7668
7881
|
}
|
|
7669
|
-
return
|
|
7882
|
+
return _context50.abrupt("return", ((_this$store$tempOrder11 = this.store.tempOrder) === null || _this$store$tempOrder11 === void 0 ? void 0 : _this$store$tempOrder11.products) || []);
|
|
7670
7883
|
case 3:
|
|
7671
7884
|
// Keep the pre-removal snapshot guard separate from the ownership guard:
|
|
7672
7885
|
// deleting these rows must not make the async finalization reject its own mutation.
|
|
7673
7886
|
if (identities.length) options === null || options === void 0 || (_options$beforeApply3 = options.beforeApply) === null || _options$beforeApply3 === void 0 || _options$beforeApply3.call(options);
|
|
7674
7887
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
7675
|
-
|
|
7888
|
+
_context50.next = 6;
|
|
7676
7889
|
break;
|
|
7677
7890
|
}
|
|
7678
|
-
return
|
|
7891
|
+
return _context50.abrupt("return", ((_this$store$tempOrder12 = this.store.tempOrder) === null || _this$store$tempOrder12 === void 0 ? void 0 : _this$store$tempOrder12.products) || []);
|
|
7679
7892
|
case 6:
|
|
7680
7893
|
mutation = this.beginCartMutation();
|
|
7681
7894
|
tempOrder = mutation.draft;
|
|
7682
7895
|
if (identities.length) {
|
|
7683
|
-
|
|
7896
|
+
_context50.next = 10;
|
|
7684
7897
|
break;
|
|
7685
7898
|
}
|
|
7686
|
-
return
|
|
7899
|
+
return _context50.abrupt("return", tempOrder.products);
|
|
7687
7900
|
case 10:
|
|
7688
7901
|
// 商品删除会同步删除以商品行为主关系的 Notes;快照不完整时禁止产生孤儿 Relation。
|
|
7689
7902
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
@@ -7716,29 +7929,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7716
7929
|
}
|
|
7717
7930
|
linkedBookingUidsToRemove = new Set();
|
|
7718
7931
|
_iterator31 = _createForOfIteratorHelper(matchedProducts);
|
|
7719
|
-
|
|
7720
|
-
|
|
7932
|
+
_context50.prev = 23;
|
|
7933
|
+
_loop6 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop6() {
|
|
7721
7934
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
7722
7935
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
7723
|
-
return _regeneratorRuntime().wrap(function
|
|
7724
|
-
while (1) switch (
|
|
7936
|
+
return _regeneratorRuntime().wrap(function _loop6$(_context49) {
|
|
7937
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
7725
7938
|
case 0:
|
|
7726
7939
|
product = _step31.value;
|
|
7727
7940
|
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);
|
|
7728
7941
|
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);
|
|
7729
7942
|
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;
|
|
7730
7943
|
if (!isAddTimeProduct) {
|
|
7731
|
-
|
|
7944
|
+
_context49.next = 6;
|
|
7732
7945
|
break;
|
|
7733
7946
|
}
|
|
7734
|
-
return
|
|
7947
|
+
return _context49.abrupt("return", 1);
|
|
7735
7948
|
case 6:
|
|
7736
7949
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
7737
7950
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
7738
7951
|
}
|
|
7739
7952
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
7740
7953
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
7741
|
-
var bookingUid =
|
|
7954
|
+
var bookingUid = _this53.getBookingUniqueIdentificationNumber(booking);
|
|
7742
7955
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
7743
7956
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
7744
7957
|
}
|
|
@@ -7746,37 +7959,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7746
7959
|
}
|
|
7747
7960
|
case 8:
|
|
7748
7961
|
case "end":
|
|
7749
|
-
return
|
|
7962
|
+
return _context49.stop();
|
|
7750
7963
|
}
|
|
7751
|
-
},
|
|
7964
|
+
}, _loop6);
|
|
7752
7965
|
});
|
|
7753
7966
|
_iterator31.s();
|
|
7754
7967
|
case 26:
|
|
7755
7968
|
if ((_step31 = _iterator31.n()).done) {
|
|
7756
|
-
|
|
7969
|
+
_context50.next = 32;
|
|
7757
7970
|
break;
|
|
7758
7971
|
}
|
|
7759
|
-
return
|
|
7972
|
+
return _context50.delegateYield(_loop6(), "t0", 28);
|
|
7760
7973
|
case 28:
|
|
7761
|
-
if (!
|
|
7762
|
-
|
|
7974
|
+
if (!_context50.t0) {
|
|
7975
|
+
_context50.next = 30;
|
|
7763
7976
|
break;
|
|
7764
7977
|
}
|
|
7765
|
-
return
|
|
7978
|
+
return _context50.abrupt("continue", 30);
|
|
7766
7979
|
case 30:
|
|
7767
|
-
|
|
7980
|
+
_context50.next = 26;
|
|
7768
7981
|
break;
|
|
7769
7982
|
case 32:
|
|
7770
|
-
|
|
7983
|
+
_context50.next = 37;
|
|
7771
7984
|
break;
|
|
7772
7985
|
case 34:
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
_iterator31.e(
|
|
7986
|
+
_context50.prev = 34;
|
|
7987
|
+
_context50.t1 = _context50["catch"](23);
|
|
7988
|
+
_iterator31.e(_context50.t1);
|
|
7776
7989
|
case 37:
|
|
7777
|
-
|
|
7990
|
+
_context50.prev = 37;
|
|
7778
7991
|
_iterator31.f();
|
|
7779
|
-
return
|
|
7992
|
+
return _context50.finish(37);
|
|
7780
7993
|
case 40:
|
|
7781
7994
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
7782
7995
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
@@ -7812,44 +8025,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7812
8025
|
tempOrder.shop_discount = '0.00';
|
|
7813
8026
|
}
|
|
7814
8027
|
if (!mutation.commit) {
|
|
7815
|
-
|
|
8028
|
+
_context50.next = 49;
|
|
7816
8029
|
break;
|
|
7817
8030
|
}
|
|
7818
|
-
|
|
8031
|
+
_context50.next = 48;
|
|
7819
8032
|
return mutation.commit({
|
|
7820
8033
|
isCurrentOrder: isCurrentOrder,
|
|
7821
8034
|
beforeCommit: options === null || options === void 0 ? void 0 : options.beforeApply
|
|
7822
8035
|
});
|
|
7823
8036
|
case 48:
|
|
7824
|
-
tempOrder =
|
|
8037
|
+
tempOrder = _context50.sent;
|
|
7825
8038
|
case 49:
|
|
7826
8039
|
if (!isCurrentOrder) {
|
|
7827
|
-
|
|
8040
|
+
_context50.next = 54;
|
|
7828
8041
|
break;
|
|
7829
8042
|
}
|
|
7830
|
-
|
|
8043
|
+
_context50.next = 52;
|
|
7831
8044
|
return this.finalizeProductOrderMutation(tempOrder, {
|
|
7832
8045
|
skipEditDiscountConfigRefresh: true,
|
|
7833
8046
|
isCurrentOrder: isCurrentOrder
|
|
7834
8047
|
});
|
|
7835
8048
|
case 52:
|
|
7836
|
-
|
|
8049
|
+
_context50.next = 56;
|
|
7837
8050
|
break;
|
|
7838
8051
|
case 54:
|
|
7839
|
-
|
|
8052
|
+
_context50.next = 56;
|
|
7840
8053
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
7841
8054
|
case 56:
|
|
7842
8055
|
this.logInfo('removeProductsFromOrder success', {
|
|
7843
8056
|
identities: identities
|
|
7844
8057
|
});
|
|
7845
|
-
return
|
|
8058
|
+
return _context50.abrupt("return", tempOrder.products);
|
|
7846
8059
|
case 58:
|
|
7847
8060
|
case "end":
|
|
7848
|
-
return
|
|
8061
|
+
return _context50.stop();
|
|
7849
8062
|
}
|
|
7850
|
-
},
|
|
8063
|
+
}, _callee44, this, [[23, 34, 37, 40]]);
|
|
7851
8064
|
}));
|
|
7852
|
-
function removeProductsFromOrderDraft(
|
|
8065
|
+
function removeProductsFromOrderDraft(_x57, _x58) {
|
|
7853
8066
|
return _removeProductsFromOrderDraft.apply(this, arguments);
|
|
7854
8067
|
}
|
|
7855
8068
|
return removeProductsFromOrderDraft;
|
|
@@ -7857,18 +8070,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7857
8070
|
}, {
|
|
7858
8071
|
key: "removeProductFromOrder",
|
|
7859
8072
|
value: function () {
|
|
7860
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7861
|
-
return _regeneratorRuntime().wrap(function
|
|
7862
|
-
while (1) switch (
|
|
8073
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(identity, options) {
|
|
8074
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context51) {
|
|
8075
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
7863
8076
|
case 0:
|
|
7864
|
-
return
|
|
8077
|
+
return _context51.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
7865
8078
|
case 1:
|
|
7866
8079
|
case "end":
|
|
7867
|
-
return
|
|
8080
|
+
return _context51.stop();
|
|
7868
8081
|
}
|
|
7869
|
-
},
|
|
8082
|
+
}, _callee45, this);
|
|
7870
8083
|
}));
|
|
7871
|
-
function removeProductFromOrder(
|
|
8084
|
+
function removeProductFromOrder(_x59, _x60) {
|
|
7872
8085
|
return _removeProductFromOrder.apply(this, arguments);
|
|
7873
8086
|
}
|
|
7874
8087
|
return removeProductFromOrder;
|
|
@@ -7880,19 +8093,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7880
8093
|
}, {
|
|
7881
8094
|
key: "clearOrderCartLines",
|
|
7882
8095
|
value: (function () {
|
|
7883
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7884
|
-
var
|
|
7885
|
-
return _regeneratorRuntime().wrap(function
|
|
7886
|
-
while (1) switch (
|
|
8096
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
|
|
8097
|
+
var _this54 = this;
|
|
8098
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context52) {
|
|
8099
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
7887
8100
|
case 0:
|
|
7888
|
-
return
|
|
7889
|
-
return
|
|
8101
|
+
return _context52.abrupt("return", this.queueCartCommand(function () {
|
|
8102
|
+
return _this54.clearOrderCartLinesDraft();
|
|
7890
8103
|
}));
|
|
7891
8104
|
case 1:
|
|
7892
8105
|
case "end":
|
|
7893
|
-
return
|
|
8106
|
+
return _context52.stop();
|
|
7894
8107
|
}
|
|
7895
|
-
},
|
|
8108
|
+
}, _callee46, this);
|
|
7896
8109
|
}));
|
|
7897
8110
|
function clearOrderCartLines() {
|
|
7898
8111
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -7902,10 +8115,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7902
8115
|
}, {
|
|
7903
8116
|
key: "clearOrderCartLinesDraft",
|
|
7904
8117
|
value: function () {
|
|
7905
|
-
var _clearOrderCartLinesDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8118
|
+
var _clearOrderCartLinesDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
|
|
7906
8119
|
var mutation, tempOrder, promotionPayload;
|
|
7907
|
-
return _regeneratorRuntime().wrap(function
|
|
7908
|
-
while (1) switch (
|
|
8120
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context53) {
|
|
8121
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
7909
8122
|
case 0:
|
|
7910
8123
|
mutation = this.beginCartMutation();
|
|
7911
8124
|
tempOrder = mutation.draft;
|
|
@@ -7924,21 +8137,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7924
8137
|
delete tempOrder._extend.fixedGiftQuotas;
|
|
7925
8138
|
}
|
|
7926
8139
|
if (!mutation.commit) {
|
|
7927
|
-
|
|
8140
|
+
_context53.next = 15;
|
|
7928
8141
|
break;
|
|
7929
8142
|
}
|
|
7930
|
-
|
|
8143
|
+
_context53.next = 14;
|
|
7931
8144
|
return mutation.commit();
|
|
7932
8145
|
case 14:
|
|
7933
|
-
tempOrder =
|
|
8146
|
+
tempOrder = _context53.sent;
|
|
7934
8147
|
case 15:
|
|
7935
|
-
|
|
8148
|
+
_context53.next = 17;
|
|
7936
8149
|
return this.evaluatePromotion();
|
|
7937
8150
|
case 17:
|
|
7938
|
-
promotionPayload =
|
|
8151
|
+
promotionPayload = _context53.sent;
|
|
7939
8152
|
this.applyDiscount();
|
|
7940
8153
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
7941
|
-
|
|
8154
|
+
_context53.next = 22;
|
|
7942
8155
|
return this.recalculateSummary({
|
|
7943
8156
|
createIfMissing: true
|
|
7944
8157
|
});
|
|
@@ -7946,12 +8159,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7946
8159
|
this.persistTempOrder();
|
|
7947
8160
|
this.emitPromotionApplied(promotionPayload);
|
|
7948
8161
|
this.logInfo('clearOrderCartLines success', {});
|
|
7949
|
-
return
|
|
8162
|
+
return _context53.abrupt("return", tempOrder);
|
|
7950
8163
|
case 26:
|
|
7951
8164
|
case "end":
|
|
7952
|
-
return
|
|
8165
|
+
return _context53.stop();
|
|
7953
8166
|
}
|
|
7954
|
-
},
|
|
8167
|
+
}, _callee47, this);
|
|
7955
8168
|
}));
|
|
7956
8169
|
function clearOrderCartLinesDraft() {
|
|
7957
8170
|
return _clearOrderCartLinesDraft.apply(this, arguments);
|
|
@@ -7964,11 +8177,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7964
8177
|
}, {
|
|
7965
8178
|
key: "clearOrderForSettlementSwitch",
|
|
7966
8179
|
value: (function () {
|
|
7967
|
-
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8180
|
+
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
|
|
7968
8181
|
var _this$store$discount22, _this$store$discount23;
|
|
7969
8182
|
var tempOrder;
|
|
7970
|
-
return _regeneratorRuntime().wrap(function
|
|
7971
|
-
while (1) switch (
|
|
8183
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context54) {
|
|
8184
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
7972
8185
|
case 0:
|
|
7973
8186
|
tempOrder = this.ensureTempOrder();
|
|
7974
8187
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
@@ -7988,28 +8201,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7988
8201
|
productsByUid: {}
|
|
7989
8202
|
});
|
|
7990
8203
|
}
|
|
7991
|
-
|
|
8204
|
+
_context54.next = 16;
|
|
7992
8205
|
return (_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.setDiscountList([]);
|
|
7993
8206
|
case 16:
|
|
7994
|
-
|
|
8207
|
+
_context54.next = 18;
|
|
7995
8208
|
return (_this$store$discount23 = this.store.discount) === null || _this$store$discount23 === void 0 ? void 0 : _this$store$discount23.setOriginalDiscountList([]);
|
|
7996
8209
|
case 18:
|
|
7997
8210
|
this.hasActiveCustomerBoundDiscount = false;
|
|
7998
8211
|
this.lastUnfulfilledPromotions = [];
|
|
7999
8212
|
this.lastGiftActions = null;
|
|
8000
|
-
|
|
8213
|
+
_context54.next = 23;
|
|
8001
8214
|
return this.recalculateSummary({
|
|
8002
8215
|
createIfMissing: true
|
|
8003
8216
|
});
|
|
8004
8217
|
case 23:
|
|
8005
8218
|
this.persistTempOrder();
|
|
8006
8219
|
this.logInfo('clearOrderForSettlementSwitch success', {});
|
|
8007
|
-
return
|
|
8220
|
+
return _context54.abrupt("return", tempOrder);
|
|
8008
8221
|
case 26:
|
|
8009
8222
|
case "end":
|
|
8010
|
-
return
|
|
8223
|
+
return _context54.stop();
|
|
8011
8224
|
}
|
|
8012
|
-
},
|
|
8225
|
+
}, _callee48, this);
|
|
8013
8226
|
}));
|
|
8014
8227
|
function clearOrderForSettlementSwitch() {
|
|
8015
8228
|
return _clearOrderForSettlementSwitch.apply(this, arguments);
|
|
@@ -8020,23 +8233,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8020
8233
|
}, {
|
|
8021
8234
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
8022
8235
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
8023
|
-
var _params$cacheId, _this$
|
|
8236
|
+
var _params$cacheId, _this$otherParams6, _ref91, _params$businessCode, _this$otherParams7, _this$otherParams8;
|
|
8024
8237
|
var tempOrder = this.ensureTempOrder();
|
|
8025
8238
|
this.persistTempOrder();
|
|
8026
8239
|
var payload = buildSubmitPayload({
|
|
8027
8240
|
tempOrder: tempOrder,
|
|
8028
8241
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
8029
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
8030
|
-
businessCode: (
|
|
8242
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
|
|
8243
|
+
businessCode: (_ref91 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref91 !== void 0 ? _ref91 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
|
|
8031
8244
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
8032
8245
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
8033
8246
|
summary: this.store.summary || createEmptySummary(),
|
|
8034
8247
|
enhance: function enhance(nextPayload) {
|
|
8035
|
-
var
|
|
8248
|
+
var _ref92, _tempOrder$order_numb, _ref93, _tempOrder$shop_order2, _ref94, _tempOrder$shop_full_;
|
|
8036
8249
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
8037
|
-
order_number: (
|
|
8038
|
-
shop_order_number: (
|
|
8039
|
-
shop_full_order_number: (
|
|
8250
|
+
order_number: (_ref92 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref92 !== void 0 ? _ref92 : null,
|
|
8251
|
+
shop_order_number: (_ref93 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref93 !== void 0 ? _ref93 : null,
|
|
8252
|
+
shop_full_order_number: (_ref94 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref94 !== void 0 ? _ref94 : null,
|
|
8040
8253
|
small_ticket_data_flag: 1
|
|
8041
8254
|
});
|
|
8042
8255
|
}
|
|
@@ -8047,17 +8260,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8047
8260
|
}, {
|
|
8048
8261
|
key: "applyLocalPrintOrderNumbers",
|
|
8049
8262
|
value: function () {
|
|
8050
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8263
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(order) {
|
|
8051
8264
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
8052
|
-
return _regeneratorRuntime().wrap(function
|
|
8053
|
-
while (1) switch (
|
|
8265
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context55) {
|
|
8266
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
8054
8267
|
case 0:
|
|
8055
8268
|
tempOrder = this.ensureTempOrder();
|
|
8056
8269
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
8057
|
-
|
|
8270
|
+
_context55.next = 3;
|
|
8058
8271
|
break;
|
|
8059
8272
|
}
|
|
8060
|
-
return
|
|
8273
|
+
return _context55.abrupt("return", tempOrder);
|
|
8061
8274
|
case 3:
|
|
8062
8275
|
shopOrderNumber = order.shop_order_number;
|
|
8063
8276
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -8068,17 +8281,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8068
8281
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
8069
8282
|
}
|
|
8070
8283
|
this.persistTempOrder();
|
|
8071
|
-
|
|
8284
|
+
_context55.next = 10;
|
|
8072
8285
|
return this.saveDraft();
|
|
8073
8286
|
case 10:
|
|
8074
|
-
return
|
|
8287
|
+
return _context55.abrupt("return", tempOrder);
|
|
8075
8288
|
case 11:
|
|
8076
8289
|
case "end":
|
|
8077
|
-
return
|
|
8290
|
+
return _context55.stop();
|
|
8078
8291
|
}
|
|
8079
|
-
},
|
|
8292
|
+
}, _callee49, this);
|
|
8080
8293
|
}));
|
|
8081
|
-
function applyLocalPrintOrderNumbers(
|
|
8294
|
+
function applyLocalPrintOrderNumbers(_x61) {
|
|
8082
8295
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
8083
8296
|
}
|
|
8084
8297
|
return applyLocalPrintOrderNumbers;
|
|
@@ -8086,42 +8299,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8086
8299
|
}, {
|
|
8087
8300
|
key: "saveTempOrderAsDraft",
|
|
8088
8301
|
value: function () {
|
|
8089
|
-
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8090
|
-
var _params$cacheId2, _this$
|
|
8302
|
+
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
|
|
8303
|
+
var _params$cacheId2, _this$otherParams9, _this$otherParams10, _this$otherParams11, _params$type, _this$otherParams12, _payload$products;
|
|
8091
8304
|
var tempOrder, latestSummary, payload;
|
|
8092
|
-
return _regeneratorRuntime().wrap(function
|
|
8093
|
-
while (1) switch (
|
|
8305
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context56) {
|
|
8306
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
8094
8307
|
case 0:
|
|
8095
8308
|
tempOrder = this.ensureTempOrder();
|
|
8096
8309
|
this.ensureExternalSaleNumber(tempOrder);
|
|
8097
8310
|
this.persistTempOrder();
|
|
8098
|
-
|
|
8311
|
+
_context56.next = 5;
|
|
8099
8312
|
return this.recalculateSummary({
|
|
8100
8313
|
createIfMissing: true
|
|
8101
8314
|
});
|
|
8102
8315
|
case 5:
|
|
8103
|
-
|
|
8104
|
-
if (
|
|
8105
|
-
|
|
8316
|
+
_context56.t1 = _context56.sent;
|
|
8317
|
+
if (_context56.t1) {
|
|
8318
|
+
_context56.next = 8;
|
|
8106
8319
|
break;
|
|
8107
8320
|
}
|
|
8108
|
-
|
|
8321
|
+
_context56.t1 = this.store.summary;
|
|
8109
8322
|
case 8:
|
|
8110
|
-
|
|
8111
|
-
if (
|
|
8112
|
-
|
|
8323
|
+
_context56.t0 = _context56.t1;
|
|
8324
|
+
if (_context56.t0) {
|
|
8325
|
+
_context56.next = 11;
|
|
8113
8326
|
break;
|
|
8114
8327
|
}
|
|
8115
|
-
|
|
8328
|
+
_context56.t0 = createEmptySummary();
|
|
8116
8329
|
case 11:
|
|
8117
|
-
latestSummary =
|
|
8330
|
+
latestSummary = _context56.t0;
|
|
8118
8331
|
payload = buildSubmitPayload({
|
|
8119
8332
|
tempOrder: tempOrder,
|
|
8120
8333
|
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
8121
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
8122
|
-
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$
|
|
8334
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.platform),
|
|
8335
|
+
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.businessCode) || ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.business_code) || tempOrder.business_code,
|
|
8123
8336
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
8124
|
-
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$
|
|
8337
|
+
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.type,
|
|
8125
8338
|
summary: latestSummary,
|
|
8126
8339
|
enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
|
|
8127
8340
|
});
|
|
@@ -8135,17 +8348,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8135
8348
|
externalSaleNumber: payload.external_sale_number,
|
|
8136
8349
|
productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
|
|
8137
8350
|
});
|
|
8138
|
-
return
|
|
8351
|
+
return _context56.abrupt("return", this.request.post('/order/sales/draft', payload, {
|
|
8139
8352
|
osServer: true,
|
|
8140
8353
|
customToast: function customToast() {}
|
|
8141
8354
|
}));
|
|
8142
8355
|
case 18:
|
|
8143
8356
|
case "end":
|
|
8144
|
-
return
|
|
8357
|
+
return _context56.stop();
|
|
8145
8358
|
}
|
|
8146
|
-
},
|
|
8359
|
+
}, _callee50, this);
|
|
8147
8360
|
}));
|
|
8148
|
-
function saveTempOrderAsDraft(
|
|
8361
|
+
function saveTempOrderAsDraft(_x62) {
|
|
8149
8362
|
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
8150
8363
|
}
|
|
8151
8364
|
return saveTempOrderAsDraft;
|
|
@@ -8159,18 +8372,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8159
8372
|
}, {
|
|
8160
8373
|
key: "submitTempOrder",
|
|
8161
8374
|
value: (function () {
|
|
8162
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8163
|
-
return _regeneratorRuntime().wrap(function
|
|
8164
|
-
while (1) switch (
|
|
8375
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
|
|
8376
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context57) {
|
|
8377
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
8165
8378
|
case 0:
|
|
8166
|
-
return
|
|
8379
|
+
return _context57.abrupt("return", this.runSubmitTempOrder(params));
|
|
8167
8380
|
case 1:
|
|
8168
8381
|
case "end":
|
|
8169
|
-
return
|
|
8382
|
+
return _context57.stop();
|
|
8170
8383
|
}
|
|
8171
|
-
},
|
|
8384
|
+
}, _callee51, this);
|
|
8172
8385
|
}));
|
|
8173
|
-
function submitTempOrder(
|
|
8386
|
+
function submitTempOrder(_x63) {
|
|
8174
8387
|
return _submitTempOrder.apply(this, arguments);
|
|
8175
8388
|
}
|
|
8176
8389
|
return submitTempOrder;
|
|
@@ -8178,20 +8391,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8178
8391
|
}, {
|
|
8179
8392
|
key: "submitTempOrderAsync",
|
|
8180
8393
|
value: function () {
|
|
8181
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8182
|
-
return _regeneratorRuntime().wrap(function
|
|
8183
|
-
while (1) switch (
|
|
8394
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
|
|
8395
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context58) {
|
|
8396
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
8184
8397
|
case 0:
|
|
8185
|
-
return
|
|
8398
|
+
return _context58.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
8186
8399
|
syncMode: true
|
|
8187
8400
|
})));
|
|
8188
8401
|
case 1:
|
|
8189
8402
|
case "end":
|
|
8190
|
-
return
|
|
8403
|
+
return _context58.stop();
|
|
8191
8404
|
}
|
|
8192
|
-
},
|
|
8405
|
+
}, _callee52, this);
|
|
8193
8406
|
}));
|
|
8194
|
-
function submitTempOrderAsync(
|
|
8407
|
+
function submitTempOrderAsync(_x64) {
|
|
8195
8408
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
8196
8409
|
}
|
|
8197
8410
|
return submitTempOrderAsync;
|
|
@@ -8199,15 +8412,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8199
8412
|
}, {
|
|
8200
8413
|
key: "runSubmitTempOrder",
|
|
8201
8414
|
value: function () {
|
|
8202
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8203
|
-
var _params$cacheId3, _this$
|
|
8415
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
|
|
8416
|
+
var _params$cacheId3, _this$otherParams13, _ref95, _ref96, _submitSnapshot$busin, _this$otherParams14, _this$otherParams15, _submitSnapshot$type;
|
|
8204
8417
|
var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
|
|
8205
|
-
return _regeneratorRuntime().wrap(function
|
|
8206
|
-
while (1) switch (
|
|
8418
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context59) {
|
|
8419
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
8207
8420
|
case 0:
|
|
8208
8421
|
tempOrder = this.ensureTempOrder();
|
|
8209
8422
|
if (!requiresLocalPaymentRefresh(tempOrder)) {
|
|
8210
|
-
|
|
8423
|
+
_context59.next = 3;
|
|
8211
8424
|
break;
|
|
8212
8425
|
}
|
|
8213
8426
|
throw new Error(PAYMENT_REFRESH_MESSAGE);
|
|
@@ -8234,26 +8447,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8234
8447
|
}
|
|
8235
8448
|
}
|
|
8236
8449
|
this.persistTempOrder();
|
|
8237
|
-
|
|
8450
|
+
_context59.next = 13;
|
|
8238
8451
|
return this.recalculateSummary({
|
|
8239
8452
|
createIfMissing: true
|
|
8240
8453
|
});
|
|
8241
8454
|
case 13:
|
|
8242
|
-
|
|
8243
|
-
if (
|
|
8244
|
-
|
|
8455
|
+
_context59.t1 = _context59.sent;
|
|
8456
|
+
if (_context59.t1) {
|
|
8457
|
+
_context59.next = 16;
|
|
8245
8458
|
break;
|
|
8246
8459
|
}
|
|
8247
|
-
|
|
8460
|
+
_context59.t1 = this.store.summary;
|
|
8248
8461
|
case 16:
|
|
8249
|
-
|
|
8250
|
-
if (
|
|
8251
|
-
|
|
8462
|
+
_context59.t0 = _context59.t1;
|
|
8463
|
+
if (_context59.t0) {
|
|
8464
|
+
_context59.next = 19;
|
|
8252
8465
|
break;
|
|
8253
8466
|
}
|
|
8254
|
-
|
|
8467
|
+
_context59.t0 = createEmptySummary();
|
|
8255
8468
|
case 19:
|
|
8256
|
-
latestSummary =
|
|
8469
|
+
latestSummary = _context59.t0;
|
|
8257
8470
|
effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
|
|
8258
8471
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
8259
8472
|
shouldOverridePaymentStatus = hasPaymentStatusOverride && !isOnlineStorePlatform && !shouldConfirmPendingVoucherPayments;
|
|
@@ -8273,8 +8486,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8273
8486
|
payload = buildSubmitPayload({
|
|
8274
8487
|
tempOrder: tempOrder,
|
|
8275
8488
|
cacheId: effectiveCacheId,
|
|
8276
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
8277
|
-
businessCode: (
|
|
8489
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.platform),
|
|
8490
|
+
businessCode: (_ref95 = (_ref96 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref96 !== void 0 ? _ref96 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.businessCode) !== null && _ref95 !== void 0 ? _ref95 : (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.business_code,
|
|
8278
8491
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
8279
8492
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
8280
8493
|
summary: latestSummary,
|
|
@@ -8289,10 +8502,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8289
8502
|
if (!payload.created_at) {
|
|
8290
8503
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
8291
8504
|
}
|
|
8292
|
-
|
|
8505
|
+
_context59.next = 31;
|
|
8293
8506
|
return this.saveDraft();
|
|
8294
8507
|
case 31:
|
|
8295
|
-
|
|
8508
|
+
_context59.prev = 31;
|
|
8296
8509
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
8297
8510
|
orderId: payload.order_id,
|
|
8298
8511
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -8302,43 +8515,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8302
8515
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
8303
8516
|
syncMode: payload.sync_mode
|
|
8304
8517
|
});
|
|
8305
|
-
|
|
8518
|
+
_context59.next = 35;
|
|
8306
8519
|
return this.submitSalesOrder({
|
|
8307
8520
|
query: payload
|
|
8308
8521
|
});
|
|
8309
8522
|
case 35:
|
|
8310
|
-
result =
|
|
8311
|
-
|
|
8523
|
+
result = _context59.sent;
|
|
8524
|
+
_context59.next = 48;
|
|
8312
8525
|
break;
|
|
8313
8526
|
case 38:
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
8527
|
+
_context59.prev = 38;
|
|
8528
|
+
_context59.t2 = _context59["catch"](31);
|
|
8529
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context59.t2);
|
|
8317
8530
|
if (!backendErrorResponse) {
|
|
8318
|
-
|
|
8531
|
+
_context59.next = 45;
|
|
8319
8532
|
break;
|
|
8320
8533
|
}
|
|
8321
8534
|
this.store.syncState = 'failed';
|
|
8322
8535
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
8323
|
-
return
|
|
8536
|
+
return _context59.abrupt("return", backendErrorResponse);
|
|
8324
8537
|
case 45:
|
|
8325
8538
|
this.store.syncState = 'failed';
|
|
8326
8539
|
this.logError('submitTempOrder failed', {
|
|
8327
|
-
error:
|
|
8540
|
+
error: _context59.t2 instanceof Error ? _context59.t2.message : String(_context59.t2),
|
|
8328
8541
|
orderId: payload.order_id,
|
|
8329
8542
|
externalSaleNumber: payload.external_sale_number,
|
|
8330
8543
|
paymentStatus: payload.payment_status,
|
|
8331
8544
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
8332
8545
|
});
|
|
8333
|
-
throw
|
|
8546
|
+
throw _context59.t2;
|
|
8334
8547
|
case 48:
|
|
8335
8548
|
if (!this.isSubmitResponseRejected(result)) {
|
|
8336
|
-
|
|
8549
|
+
_context59.next = 52;
|
|
8337
8550
|
break;
|
|
8338
8551
|
}
|
|
8339
8552
|
this.store.syncState = 'failed';
|
|
8340
8553
|
this.logSubmitBackendRejected(result, payload);
|
|
8341
|
-
return
|
|
8554
|
+
return _context59.abrupt("return", result);
|
|
8342
8555
|
case 52:
|
|
8343
8556
|
isLocalPendingSubmit = this.isLocalPendingSubmitResult(result); // need_sync=1 仅表示已进入本地同步队列,不能视为远端已确认 Notes。
|
|
8344
8557
|
if (Object.prototype.hasOwnProperty.call(payload, 'notes') && !isLocalPendingSubmit) {
|
|
@@ -8354,12 +8567,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8354
8567
|
})
|
|
8355
8568
|
});
|
|
8356
8569
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
8357
|
-
|
|
8570
|
+
_context59.next = 61;
|
|
8358
8571
|
break;
|
|
8359
8572
|
}
|
|
8360
8573
|
tempOrder.order_id = submittedOrderId;
|
|
8361
8574
|
resultRecord = result;
|
|
8362
|
-
|
|
8575
|
+
_context59.next = 61;
|
|
8363
8576
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
8364
8577
|
case 61:
|
|
8365
8578
|
if (isLocalPendingSubmit) {
|
|
@@ -8367,14 +8580,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8367
8580
|
} else if (submittedOrderId === null || submittedOrderId === undefined) {
|
|
8368
8581
|
this.store.syncState = 'submitted';
|
|
8369
8582
|
}
|
|
8370
|
-
return
|
|
8583
|
+
return _context59.abrupt("return", result);
|
|
8371
8584
|
case 63:
|
|
8372
8585
|
case "end":
|
|
8373
|
-
return
|
|
8586
|
+
return _context59.stop();
|
|
8374
8587
|
}
|
|
8375
|
-
},
|
|
8588
|
+
}, _callee53, this, [[31, 38]]);
|
|
8376
8589
|
}));
|
|
8377
|
-
function runSubmitTempOrder(
|
|
8590
|
+
function runSubmitTempOrder(_x65) {
|
|
8378
8591
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
8379
8592
|
}
|
|
8380
8593
|
return runSubmitTempOrder;
|
|
@@ -8382,10 +8595,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8382
8595
|
}, {
|
|
8383
8596
|
key: "markLocalOrderSynced",
|
|
8384
8597
|
value: function () {
|
|
8385
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8598
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(orderId, remoteOrder) {
|
|
8386
8599
|
var tempOrder;
|
|
8387
|
-
return _regeneratorRuntime().wrap(function
|
|
8388
|
-
while (1) switch (
|
|
8600
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context60) {
|
|
8601
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
8389
8602
|
case 0:
|
|
8390
8603
|
tempOrder = this.ensureTempOrder();
|
|
8391
8604
|
tempOrder.order_id = orderId;
|
|
@@ -8393,15 +8606,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8393
8606
|
this.store.lastOrderInfo = remoteOrder;
|
|
8394
8607
|
this.store.syncState = 'submitted';
|
|
8395
8608
|
this.persistTempOrder();
|
|
8396
|
-
|
|
8609
|
+
_context60.next = 8;
|
|
8397
8610
|
return this.saveDraft();
|
|
8398
8611
|
case 8:
|
|
8399
8612
|
case "end":
|
|
8400
|
-
return
|
|
8613
|
+
return _context60.stop();
|
|
8401
8614
|
}
|
|
8402
|
-
},
|
|
8615
|
+
}, _callee54, this);
|
|
8403
8616
|
}));
|
|
8404
|
-
function markLocalOrderSynced(
|
|
8617
|
+
function markLocalOrderSynced(_x66, _x67) {
|
|
8405
8618
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
8406
8619
|
}
|
|
8407
8620
|
return markLocalOrderSynced;
|
|
@@ -8444,10 +8657,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8444
8657
|
value: function extractSubmitErrorResponse(error) {
|
|
8445
8658
|
var _error$response,
|
|
8446
8659
|
_error$response2,
|
|
8447
|
-
|
|
8660
|
+
_this55 = this;
|
|
8448
8661
|
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];
|
|
8449
8662
|
return candidates.find(function (candidate) {
|
|
8450
|
-
return
|
|
8663
|
+
return _this55.isSubmitErrorResponse(candidate);
|
|
8451
8664
|
}) || null;
|
|
8452
8665
|
}
|
|
8453
8666
|
}, {
|
|
@@ -8474,33 +8687,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8474
8687
|
}, {
|
|
8475
8688
|
key: "syncPaymentsToOrder",
|
|
8476
8689
|
value: function () {
|
|
8477
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8478
|
-
var
|
|
8690
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
|
|
8691
|
+
var _this56 = this,
|
|
8479
8692
|
_params$confirmPendin;
|
|
8480
8693
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
8481
|
-
return _regeneratorRuntime().wrap(function
|
|
8482
|
-
while (1) switch (
|
|
8694
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context61) {
|
|
8695
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
8483
8696
|
case 0:
|
|
8484
8697
|
tempOrder = this.ensureTempOrder();
|
|
8485
8698
|
needsPaymentNumber = (params.payments || []).some(function (payment) {
|
|
8486
8699
|
return String(payment.payment_number || '').trim() === '';
|
|
8487
8700
|
});
|
|
8488
8701
|
if (!needsPaymentNumber) {
|
|
8489
|
-
|
|
8702
|
+
_context61.next = 8;
|
|
8490
8703
|
break;
|
|
8491
8704
|
}
|
|
8492
|
-
|
|
8705
|
+
_context61.next = 5;
|
|
8493
8706
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
8494
8707
|
case 5:
|
|
8495
|
-
|
|
8496
|
-
|
|
8708
|
+
_context61.t0 = _context61.sent;
|
|
8709
|
+
_context61.next = 9;
|
|
8497
8710
|
break;
|
|
8498
8711
|
case 8:
|
|
8499
|
-
|
|
8712
|
+
_context61.t0 = 'LOCAL';
|
|
8500
8713
|
case 9:
|
|
8501
|
-
devicePrefix =
|
|
8714
|
+
devicePrefix = _context61.t0;
|
|
8502
8715
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
8503
|
-
return
|
|
8716
|
+
return _this56.normalizePaymentSource(payment, {
|
|
8504
8717
|
defaultPaid: false,
|
|
8505
8718
|
devicePrefix: devicePrefix
|
|
8506
8719
|
});
|
|
@@ -8513,20 +8726,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8513
8726
|
tempOrder.payments = effectivePayments;
|
|
8514
8727
|
tempOrder.payment_status = paymentStatus;
|
|
8515
8728
|
this.persistTempOrder();
|
|
8516
|
-
|
|
8729
|
+
_context61.next = 21;
|
|
8517
8730
|
return this.saveDraft();
|
|
8518
8731
|
case 21:
|
|
8519
8732
|
if (params.submitWhenPaid) {
|
|
8520
|
-
|
|
8733
|
+
_context61.next = 23;
|
|
8521
8734
|
break;
|
|
8522
8735
|
}
|
|
8523
|
-
return
|
|
8736
|
+
return _context61.abrupt("return", completion);
|
|
8524
8737
|
case 23:
|
|
8525
8738
|
if (!(this.store.syncState === 'submitting')) {
|
|
8526
|
-
|
|
8739
|
+
_context61.next = 25;
|
|
8527
8740
|
break;
|
|
8528
8741
|
}
|
|
8529
|
-
return
|
|
8742
|
+
return _context61.abrupt("return", completion);
|
|
8530
8743
|
case 25:
|
|
8531
8744
|
this.store.syncState = 'submitting';
|
|
8532
8745
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
@@ -8546,32 +8759,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8546
8759
|
enhancePayload: enhancePayload
|
|
8547
8760
|
};
|
|
8548
8761
|
if (!(params.checkoutSyncTaskEnabled === false)) {
|
|
8549
|
-
|
|
8762
|
+
_context61.next = 35;
|
|
8550
8763
|
break;
|
|
8551
8764
|
}
|
|
8552
|
-
|
|
8765
|
+
_context61.next = 32;
|
|
8553
8766
|
return this.submitTempOrderAsync(submitParams);
|
|
8554
8767
|
case 32:
|
|
8555
|
-
|
|
8556
|
-
|
|
8768
|
+
_context61.t1 = _context61.sent;
|
|
8769
|
+
_context61.next = 38;
|
|
8557
8770
|
break;
|
|
8558
8771
|
case 35:
|
|
8559
|
-
|
|
8772
|
+
_context61.next = 37;
|
|
8560
8773
|
return this.submitTempOrder(submitParams);
|
|
8561
8774
|
case 37:
|
|
8562
|
-
|
|
8775
|
+
_context61.t1 = _context61.sent;
|
|
8563
8776
|
case 38:
|
|
8564
|
-
submitResult =
|
|
8565
|
-
return
|
|
8777
|
+
submitResult = _context61.t1;
|
|
8778
|
+
return _context61.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
8566
8779
|
submitResult: submitResult
|
|
8567
8780
|
}));
|
|
8568
8781
|
case 40:
|
|
8569
8782
|
case "end":
|
|
8570
|
-
return
|
|
8783
|
+
return _context61.stop();
|
|
8571
8784
|
}
|
|
8572
|
-
},
|
|
8785
|
+
}, _callee55, this);
|
|
8573
8786
|
}));
|
|
8574
|
-
function syncPaymentsToOrder(
|
|
8787
|
+
function syncPaymentsToOrder(_x68) {
|
|
8575
8788
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
8576
8789
|
}
|
|
8577
8790
|
return syncPaymentsToOrder;
|
|
@@ -8579,7 +8792,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8579
8792
|
}, {
|
|
8580
8793
|
key: "createOrder",
|
|
8581
8794
|
value: function createOrder(params) {
|
|
8582
|
-
var
|
|
8795
|
+
var _this57 = this;
|
|
8583
8796
|
var order = _objectSpread({
|
|
8584
8797
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
8585
8798
|
// 要从外面拿,virtual
|
|
@@ -8611,7 +8824,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8611
8824
|
|
|
8612
8825
|
// 为预约补齐 holder 信息
|
|
8613
8826
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
8614
|
-
ensureCartItemOriginHolder(item,
|
|
8827
|
+
ensureCartItemOriginHolder(item, _this57.window);
|
|
8615
8828
|
}
|
|
8616
8829
|
|
|
8617
8830
|
// 购物车是否为普通商品
|
|
@@ -8668,11 +8881,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8668
8881
|
}, {
|
|
8669
8882
|
key: "submitOrder",
|
|
8670
8883
|
value: function () {
|
|
8671
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8884
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(order) {
|
|
8672
8885
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
8673
8886
|
var url, query, fetchUrl, params;
|
|
8674
|
-
return _regeneratorRuntime().wrap(function
|
|
8675
|
-
while (1) switch (
|
|
8887
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context62) {
|
|
8888
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
8676
8889
|
case 0:
|
|
8677
8890
|
this.logInfo('submitOrder called', {
|
|
8678
8891
|
url: order.url,
|
|
@@ -8692,14 +8905,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8692
8905
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
8693
8906
|
scheduleDate: params.schedule_date
|
|
8694
8907
|
});
|
|
8695
|
-
return
|
|
8908
|
+
return _context62.abrupt("return", this.request.post(fetchUrl, params));
|
|
8696
8909
|
case 6:
|
|
8697
8910
|
case "end":
|
|
8698
|
-
return
|
|
8911
|
+
return _context62.stop();
|
|
8699
8912
|
}
|
|
8700
|
-
},
|
|
8913
|
+
}, _callee56, this);
|
|
8701
8914
|
}));
|
|
8702
|
-
function submitOrder(
|
|
8915
|
+
function submitOrder(_x69) {
|
|
8703
8916
|
return _submitOrder.apply(this, arguments);
|
|
8704
8917
|
}
|
|
8705
8918
|
return submitOrder;
|
|
@@ -8707,13 +8920,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8707
8920
|
}, {
|
|
8708
8921
|
key: "cancelOrder",
|
|
8709
8922
|
value: function () {
|
|
8710
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8923
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
|
|
8711
8924
|
var payload;
|
|
8712
|
-
return _regeneratorRuntime().wrap(function
|
|
8713
|
-
while (1) switch (
|
|
8925
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context63) {
|
|
8926
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
8714
8927
|
case 0:
|
|
8715
8928
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
8716
|
-
|
|
8929
|
+
_context63.next = 2;
|
|
8717
8930
|
break;
|
|
8718
8931
|
}
|
|
8719
8932
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -8729,16 +8942,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8729
8942
|
method: 'PUT',
|
|
8730
8943
|
orderIdsCount: params.order_ids.length
|
|
8731
8944
|
});
|
|
8732
|
-
return
|
|
8945
|
+
return _context63.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
8733
8946
|
isShopApi: true
|
|
8734
8947
|
}));
|
|
8735
8948
|
case 5:
|
|
8736
8949
|
case "end":
|
|
8737
|
-
return
|
|
8950
|
+
return _context63.stop();
|
|
8738
8951
|
}
|
|
8739
|
-
},
|
|
8952
|
+
}, _callee57, this);
|
|
8740
8953
|
}));
|
|
8741
|
-
function cancelOrder(
|
|
8954
|
+
function cancelOrder(_x70) {
|
|
8742
8955
|
return _cancelOrder.apply(this, arguments);
|
|
8743
8956
|
}
|
|
8744
8957
|
return cancelOrder;
|
|
@@ -8746,19 +8959,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8746
8959
|
}, {
|
|
8747
8960
|
key: "changeBookingStatus",
|
|
8748
8961
|
value: function () {
|
|
8749
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8962
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
|
|
8750
8963
|
var url, payload;
|
|
8751
|
-
return _regeneratorRuntime().wrap(function
|
|
8752
|
-
while (1) switch (
|
|
8964
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context64) {
|
|
8965
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
8753
8966
|
case 0:
|
|
8754
8967
|
if (params.booking_id) {
|
|
8755
|
-
|
|
8968
|
+
_context64.next = 2;
|
|
8756
8969
|
break;
|
|
8757
8970
|
}
|
|
8758
8971
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
8759
8972
|
case 2:
|
|
8760
8973
|
if (params.appointment_status) {
|
|
8761
|
-
|
|
8974
|
+
_context64.next = 4;
|
|
8762
8975
|
break;
|
|
8763
8976
|
}
|
|
8764
8977
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -8773,16 +8986,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8773
8986
|
bookingId: params.booking_id,
|
|
8774
8987
|
appointmentStatus: params.appointment_status
|
|
8775
8988
|
});
|
|
8776
|
-
return
|
|
8989
|
+
return _context64.abrupt("return", this.request.put(url, payload, {
|
|
8777
8990
|
isShopApi: true
|
|
8778
8991
|
}));
|
|
8779
8992
|
case 8:
|
|
8780
8993
|
case "end":
|
|
8781
|
-
return
|
|
8994
|
+
return _context64.stop();
|
|
8782
8995
|
}
|
|
8783
|
-
},
|
|
8996
|
+
}, _callee58, this);
|
|
8784
8997
|
}));
|
|
8785
|
-
function changeBookingStatus(
|
|
8998
|
+
function changeBookingStatus(_x71) {
|
|
8786
8999
|
return _changeBookingStatus.apply(this, arguments);
|
|
8787
9000
|
}
|
|
8788
9001
|
return changeBookingStatus;
|
|
@@ -8800,12 +9013,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8800
9013
|
}, {
|
|
8801
9014
|
key: "createOrderByCheckout",
|
|
8802
9015
|
value: (function () {
|
|
8803
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8804
|
-
var _params$payments, _params$
|
|
9016
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
|
|
9017
|
+
var _params$bookings2, _params$payments, _params$bookings3, _params$relation_prod2, _params$payments2, _params$payments3;
|
|
8805
9018
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, orderData, response;
|
|
8806
|
-
return _regeneratorRuntime().wrap(function
|
|
8807
|
-
while (1) switch (
|
|
9019
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context65) {
|
|
9020
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
8808
9021
|
case 0:
|
|
9022
|
+
(_params$bookings2 = params.bookings) === null || _params$bookings2 === void 0 || _params$bookings2.forEach(assignBookingUuid);
|
|
8809
9023
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
8810
9024
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
8811
9025
|
params.payments = (_params$payments = params.payments) === null || _params$payments === void 0 ? void 0 : _params$payments.filter(function (p) {
|
|
@@ -8816,7 +9030,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8816
9030
|
platform: params.platform,
|
|
8817
9031
|
is_deposit: params.is_deposit,
|
|
8818
9032
|
customer_id: params.customer_id,
|
|
8819
|
-
bookingsCount: ((_params$
|
|
9033
|
+
bookingsCount: ((_params$bookings3 = params.bookings) === null || _params$bookings3 === void 0 ? void 0 : _params$bookings3.length) || 0,
|
|
8820
9034
|
relationProductsCount: ((_params$relation_prod2 = params.relation_products) === null || _params$relation_prod2 === void 0 ? void 0 : _params$relation_prod2.length) || 0,
|
|
8821
9035
|
paymentsCount: ((_params$payments2 = params.payments) === null || _params$payments2 === void 0 ? void 0 : _params$payments2.length) || 0,
|
|
8822
9036
|
depositAmount: params.deposit_amount,
|
|
@@ -8829,7 +9043,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8829
9043
|
return p.code;
|
|
8830
9044
|
})) || []
|
|
8831
9045
|
});
|
|
8832
|
-
|
|
9046
|
+
_context65.prev = 4;
|
|
8833
9047
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
8834
9048
|
orderData = _objectSpread({
|
|
8835
9049
|
sales_channel: 'my_pisel',
|
|
@@ -8877,32 +9091,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8877
9091
|
hasOrderId: !!orderData.order_id,
|
|
8878
9092
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
8879
9093
|
});
|
|
8880
|
-
|
|
9094
|
+
_context65.next = 11;
|
|
8881
9095
|
return this.request.post('/order/checkout', orderData, {
|
|
8882
9096
|
osServer: true,
|
|
8883
9097
|
customToast: function customToast() {}
|
|
8884
9098
|
});
|
|
8885
|
-
case
|
|
8886
|
-
response =
|
|
9099
|
+
case 11:
|
|
9100
|
+
response = _context65.sent;
|
|
8887
9101
|
this.logInfo('Order API called successfully', {
|
|
8888
9102
|
response: response
|
|
8889
9103
|
});
|
|
8890
|
-
return
|
|
8891
|
-
case
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
9104
|
+
return _context65.abrupt("return", response);
|
|
9105
|
+
case 16:
|
|
9106
|
+
_context65.prev = 16;
|
|
9107
|
+
_context65.t0 = _context65["catch"](4);
|
|
9108
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context65.t0);
|
|
8895
9109
|
this.logInfo('Order API called failed', {
|
|
8896
|
-
error:
|
|
9110
|
+
error: _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0)
|
|
8897
9111
|
});
|
|
8898
|
-
throw
|
|
8899
|
-
case
|
|
9112
|
+
throw _context65.t0;
|
|
9113
|
+
case 21:
|
|
8900
9114
|
case "end":
|
|
8901
|
-
return
|
|
9115
|
+
return _context65.stop();
|
|
8902
9116
|
}
|
|
8903
|
-
},
|
|
9117
|
+
}, _callee59, this, [[4, 16]]);
|
|
8904
9118
|
}));
|
|
8905
|
-
function createOrderByCheckout(
|
|
9119
|
+
function createOrderByCheckout(_x72) {
|
|
8906
9120
|
return _createOrderByCheckout.apply(this, arguments);
|
|
8907
9121
|
}
|
|
8908
9122
|
return createOrderByCheckout;
|
|
@@ -8910,29 +9124,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8910
9124
|
}, {
|
|
8911
9125
|
key: "submitSalesOrder",
|
|
8912
9126
|
value: function () {
|
|
8913
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9127
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
|
|
9128
|
+
var _query$bookings;
|
|
8914
9129
|
var url, query, fetchUrl, handledByOsServer, requestQuery;
|
|
8915
|
-
return _regeneratorRuntime().wrap(function
|
|
8916
|
-
while (1) switch (
|
|
9130
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context66) {
|
|
9131
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
8917
9132
|
case 0:
|
|
8918
9133
|
url = params.url, query = params.query;
|
|
9134
|
+
(_query$bookings = query.bookings) === null || _query$bookings === void 0 || _query$bookings.forEach(assignBookingUuid);
|
|
8919
9135
|
fetchUrl = url || '/order/sales/checkout';
|
|
8920
9136
|
handledByOsServer = this.isSalesCheckoutHandledByOsServer(fetchUrl);
|
|
8921
9137
|
requestQuery = handledByOsServer ? query : stripLocalEftposState(stripOsPrivatePayloadFields(query));
|
|
8922
9138
|
if (!handledByOsServer && String((query === null || query === void 0 ? void 0 : query._os_fulfillment_ref_mode) || '').trim() === 'resource_identifier') {
|
|
8923
9139
|
requestQuery.buzzer = buildResourceIdentifierBuzzer(requestQuery.bookings);
|
|
8924
9140
|
}
|
|
8925
|
-
return
|
|
9141
|
+
return _context66.abrupt("return", this.request.post(fetchUrl, requestQuery, {
|
|
8926
9142
|
osServer: true,
|
|
8927
9143
|
customToast: function customToast() {}
|
|
8928
9144
|
}));
|
|
8929
|
-
case
|
|
9145
|
+
case 7:
|
|
8930
9146
|
case "end":
|
|
8931
|
-
return
|
|
9147
|
+
return _context66.stop();
|
|
8932
9148
|
}
|
|
8933
|
-
},
|
|
9149
|
+
}, _callee60, this);
|
|
8934
9150
|
}));
|
|
8935
|
-
function submitSalesOrder(
|
|
9151
|
+
function submitSalesOrder(_x73) {
|
|
8936
9152
|
return _submitSalesOrder.apply(this, arguments);
|
|
8937
9153
|
}
|
|
8938
9154
|
return submitSalesOrder;
|
|
@@ -8940,8 +9156,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8940
9156
|
}, {
|
|
8941
9157
|
key: "isSalesCheckoutHandledByOsServer",
|
|
8942
9158
|
value: function isSalesCheckoutHandledByOsServer(fetchUrl) {
|
|
8943
|
-
var _this$
|
|
8944
|
-
var server = (_this$
|
|
9159
|
+
var _this$core4, _this$request;
|
|
9160
|
+
var server = (_this$core4 = this.core) === null || _this$core4 === void 0 ? void 0 : _this$core4.server;
|
|
8945
9161
|
if (!server || typeof server.hasRoute !== 'function') return false;
|
|
8946
9162
|
var requestBaseUrl = String(((_this$request = this.request) === null || _this$request === void 0 ? void 0 : _this$request.baseUrl) || '/shop').replace(/\/+$/, '');
|
|
8947
9163
|
if (!requestBaseUrl.startsWith('/')) return false;
|
|
@@ -8959,37 +9175,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8959
9175
|
}, {
|
|
8960
9176
|
key: "sendCustomerPayLink",
|
|
8961
9177
|
value: (function () {
|
|
8962
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9178
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
|
|
8963
9179
|
var _params$emails;
|
|
8964
9180
|
var orderIds;
|
|
8965
|
-
return _regeneratorRuntime().wrap(function
|
|
8966
|
-
while (1) switch (
|
|
9181
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context67) {
|
|
9182
|
+
while (1) switch (_context67.prev = _context67.next) {
|
|
8967
9183
|
case 0:
|
|
8968
9184
|
orderIds = params.order_ids || params.orderIds || [];
|
|
8969
9185
|
if (orderIds.length) {
|
|
8970
|
-
|
|
9186
|
+
_context67.next = 3;
|
|
8971
9187
|
break;
|
|
8972
9188
|
}
|
|
8973
9189
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
8974
9190
|
case 3:
|
|
8975
9191
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
8976
|
-
|
|
9192
|
+
_context67.next = 5;
|
|
8977
9193
|
break;
|
|
8978
9194
|
}
|
|
8979
9195
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
8980
9196
|
case 5:
|
|
8981
|
-
return
|
|
9197
|
+
return _context67.abrupt("return", this.request.post('/order/batch-email', {
|
|
8982
9198
|
order_ids: orderIds,
|
|
8983
9199
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
8984
9200
|
emails: params.emails
|
|
8985
9201
|
}));
|
|
8986
9202
|
case 6:
|
|
8987
9203
|
case "end":
|
|
8988
|
-
return
|
|
9204
|
+
return _context67.stop();
|
|
8989
9205
|
}
|
|
8990
|
-
},
|
|
9206
|
+
}, _callee61, this);
|
|
8991
9207
|
}));
|
|
8992
|
-
function sendCustomerPayLink(
|
|
9208
|
+
function sendCustomerPayLink(_x74) {
|
|
8993
9209
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
8994
9210
|
}
|
|
8995
9211
|
return sendCustomerPayLink;
|
|
@@ -8997,14 +9213,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8997
9213
|
}, {
|
|
8998
9214
|
key: "getSalesOrderByLookup",
|
|
8999
9215
|
value: function () {
|
|
9000
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9216
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
|
|
9001
9217
|
var lookup, res;
|
|
9002
|
-
return _regeneratorRuntime().wrap(function
|
|
9003
|
-
while (1) switch (
|
|
9218
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context68) {
|
|
9219
|
+
while (1) switch (_context68.prev = _context68.next) {
|
|
9004
9220
|
case 0:
|
|
9005
9221
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
9006
9222
|
if (lookup) {
|
|
9007
|
-
|
|
9223
|
+
_context68.next = 3;
|
|
9008
9224
|
break;
|
|
9009
9225
|
}
|
|
9010
9226
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -9013,25 +9229,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
9013
9229
|
if (lookup.startsWith('LOCAL_')) {
|
|
9014
9230
|
params.forceRemote = false;
|
|
9015
9231
|
}
|
|
9016
|
-
|
|
9232
|
+
_context68.next = 6;
|
|
9017
9233
|
return loadSalesOrderSnapshot(this.request, {
|
|
9018
9234
|
lookup: lookup,
|
|
9019
9235
|
transport: 'os-server',
|
|
9020
9236
|
forceRemote: params.forceRemote
|
|
9021
9237
|
});
|
|
9022
9238
|
case 6:
|
|
9023
|
-
res =
|
|
9239
|
+
res = _context68.sent;
|
|
9024
9240
|
if (res.code === 200) {
|
|
9025
9241
|
this.store.lastOrderInfo = res.data;
|
|
9026
9242
|
}
|
|
9027
|
-
return
|
|
9243
|
+
return _context68.abrupt("return", res);
|
|
9028
9244
|
case 9:
|
|
9029
9245
|
case "end":
|
|
9030
|
-
return
|
|
9246
|
+
return _context68.stop();
|
|
9031
9247
|
}
|
|
9032
|
-
},
|
|
9248
|
+
}, _callee62, this);
|
|
9033
9249
|
}));
|
|
9034
|
-
function getSalesOrderByLookup(
|
|
9250
|
+
function getSalesOrderByLookup(_x75) {
|
|
9035
9251
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
9036
9252
|
}
|
|
9037
9253
|
return getSalesOrderByLookup;
|
|
@@ -9045,35 +9261,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
9045
9261
|
}, {
|
|
9046
9262
|
key: "hydrateTempOrderFromRecord",
|
|
9047
9263
|
value: (function () {
|
|
9048
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9264
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(record, options) {
|
|
9049
9265
|
var replacement, nextTempOrder;
|
|
9050
|
-
return _regeneratorRuntime().wrap(function
|
|
9051
|
-
while (1) switch (
|
|
9266
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context69) {
|
|
9267
|
+
while (1) switch (_context69.prev = _context69.next) {
|
|
9052
9268
|
case 0:
|
|
9053
9269
|
replacement = this.beginOrderReplacement(options === null || options === void 0 ? void 0 : options.preserveOrderSessionId);
|
|
9054
|
-
|
|
9055
|
-
|
|
9270
|
+
_context69.prev = 1;
|
|
9271
|
+
_context69.next = 4;
|
|
9056
9272
|
return this.prepareHydratedTempOrder(record, options, replacement);
|
|
9057
9273
|
case 4:
|
|
9058
|
-
nextTempOrder =
|
|
9274
|
+
nextTempOrder = _context69.sent;
|
|
9059
9275
|
this.assertOrderReplacementCurrent(replacement);
|
|
9060
9276
|
this.persistTempOrder();
|
|
9061
9277
|
this.completeOrderReplacement(replacement, nextTempOrder, options === null || options === void 0 ? void 0 : options.preserveOrderSessionId);
|
|
9062
|
-
return
|
|
9278
|
+
return _context69.abrupt("return", nextTempOrder);
|
|
9063
9279
|
case 11:
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9280
|
+
_context69.prev = 11;
|
|
9281
|
+
_context69.t0 = _context69["catch"](1);
|
|
9282
|
+
_context69.next = 15;
|
|
9067
9283
|
return this.rollbackOrderReplacement(replacement);
|
|
9068
9284
|
case 15:
|
|
9069
|
-
throw
|
|
9285
|
+
throw _context69.t0;
|
|
9070
9286
|
case 16:
|
|
9071
9287
|
case "end":
|
|
9072
|
-
return
|
|
9288
|
+
return _context69.stop();
|
|
9073
9289
|
}
|
|
9074
|
-
},
|
|
9290
|
+
}, _callee63, this, [[1, 11]]);
|
|
9075
9291
|
}));
|
|
9076
|
-
function hydrateTempOrderFromRecord(
|
|
9292
|
+
function hydrateTempOrderFromRecord(_x76, _x77) {
|
|
9077
9293
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
9078
9294
|
}
|
|
9079
9295
|
return hydrateTempOrderFromRecord;
|
|
@@ -9081,13 +9297,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
9081
9297
|
}, {
|
|
9082
9298
|
key: "prepareHydratedTempOrder",
|
|
9083
9299
|
value: function () {
|
|
9084
|
-
var _prepareHydratedTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9300
|
+
var _prepareHydratedTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(record, options, replacement) {
|
|
9085
9301
|
var _sourceRaw$_extend,
|
|
9086
|
-
|
|
9302
|
+
_this58 = this,
|
|
9087
9303
|
_this$store$discount26;
|
|
9088
9304
|
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, previousSummary, summary;
|
|
9089
|
-
return _regeneratorRuntime().wrap(function
|
|
9090
|
-
while (1) switch (
|
|
9305
|
+
return _regeneratorRuntime().wrap(function _callee64$(_context70) {
|
|
9306
|
+
while (1) switch (_context70.prev = _context70.next) {
|
|
9091
9307
|
case 0:
|
|
9092
9308
|
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
9093
9309
|
duplicateProductIdentityRepair = repairDuplicateOrderProductLineIdentities(Array.isArray(sourceRaw.products) ? sourceRaw.products : [], (_sourceRaw$_extend = sourceRaw._extend) === null || _sourceRaw$_extend === void 0 ? void 0 : _sourceRaw$_extend.productsByUid);
|
|
@@ -9129,7 +9345,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
9129
9345
|
this.store.tempOrder = nextTempOrder;
|
|
9130
9346
|
this.clearCustomerWalletRuntimeState();
|
|
9131
9347
|
if (!isSessionStorageHydrate) {
|
|
9132
|
-
|
|
9348
|
+
_context70.next = 32;
|
|
9133
9349
|
break;
|
|
9134
9350
|
}
|
|
9135
9351
|
// 会话快照是未提交购物车,不应获得编辑订单的 saved/edit 标记与服务端基线。
|
|
@@ -9145,27 +9361,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
9145
9361
|
nextTempOrder.discount_list = restoredSessionDiscounts;
|
|
9146
9362
|
this.store.summary = createEmptySummary();
|
|
9147
9363
|
this.store.lastOrderInfo = undefined;
|
|
9148
|
-
|
|
9364
|
+
_context70.next = 24;
|
|
9149
9365
|
return (_this$store$discount24 = this.store.discount) === null || _this$store$discount24 === void 0 ? void 0 : _this$store$discount24.setOriginalDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
9150
9366
|
case 24:
|
|
9151
9367
|
this.assertOrderReplacementCurrent(replacement);
|
|
9152
|
-
|
|
9368
|
+
_context70.next = 27;
|
|
9153
9369
|
return (_this$store$discount25 = this.store.discount) === null || _this$store$discount25 === void 0 ? void 0 : _this$store$discount25.setDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
9154
9370
|
case 27:
|
|
9155
9371
|
this.assertOrderReplacementCurrent(replacement);
|
|
9156
9372
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
9157
|
-
|
|
9373
|
+
_context70.next = 31;
|
|
9158
9374
|
break;
|
|
9159
9375
|
}
|
|
9160
|
-
|
|
9376
|
+
_context70.next = 31;
|
|
9161
9377
|
return this.recalculateSummary({
|
|
9162
9378
|
createIfMissing: false,
|
|
9163
9379
|
isCurrentOrder: function isCurrentOrder() {
|
|
9164
|
-
return
|
|
9380
|
+
return _this58.orderReplacement === replacement;
|
|
9165
9381
|
}
|
|
9166
9382
|
});
|
|
9167
9383
|
case 31:
|
|
9168
|
-
return
|
|
9384
|
+
return _context70.abrupt("return", nextTempOrder);
|
|
9169
9385
|
case 32:
|
|
9170
9386
|
// Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
|
|
9171
9387
|
sourceLastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
|
|
@@ -9221,32 +9437,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
9221
9437
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
9222
9438
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
9223
9439
|
if (shouldSkipEmptyDiscountSync) {
|
|
9224
|
-
|
|
9440
|
+
_context70.next = 59;
|
|
9225
9441
|
break;
|
|
9226
9442
|
}
|
|
9227
9443
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
9228
|
-
|
|
9444
|
+
_context70.next = 55;
|
|
9229
9445
|
return (_this$store$discount27 = this.store.discount) === null || _this$store$discount27 === void 0 ? void 0 : _this$store$discount27.setOriginalDiscountList(nextDiscounts);
|
|
9230
9446
|
case 55:
|
|
9231
9447
|
this.assertOrderReplacementCurrent(replacement);
|
|
9232
|
-
|
|
9448
|
+
_context70.next = 58;
|
|
9233
9449
|
return (_this$store$discount28 = this.store.discount) === null || _this$store$discount28 === void 0 ? void 0 : _this$store$discount28.setDiscountList(nextDiscounts);
|
|
9234
9450
|
case 58:
|
|
9235
9451
|
this.assertOrderReplacementCurrent(replacement);
|
|
9236
9452
|
case 59:
|
|
9237
9453
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
9238
|
-
|
|
9454
|
+
_context70.next = 64;
|
|
9239
9455
|
break;
|
|
9240
9456
|
}
|
|
9241
|
-
|
|
9457
|
+
_context70.next = 62;
|
|
9242
9458
|
return this.recalculateSummary({
|
|
9243
9459
|
createIfMissing: false,
|
|
9244
9460
|
isCurrentOrder: function isCurrentOrder() {
|
|
9245
|
-
return
|
|
9461
|
+
return _this58.orderReplacement === replacement;
|
|
9246
9462
|
}
|
|
9247
9463
|
});
|
|
9248
9464
|
case 62:
|
|
9249
|
-
|
|
9465
|
+
_context70.next = 65;
|
|
9250
9466
|
break;
|
|
9251
9467
|
case 64:
|
|
9252
9468
|
if (!isMergedSalesDetailHydrate && [rawSummary.expect_amount, rawSummary.total_amount].some(function (amount) {
|
|
@@ -9267,14 +9483,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
9267
9483
|
});
|
|
9268
9484
|
}
|
|
9269
9485
|
case 65:
|
|
9270
|
-
return
|
|
9486
|
+
return _context70.abrupt("return", nextTempOrder);
|
|
9271
9487
|
case 66:
|
|
9272
9488
|
case "end":
|
|
9273
|
-
return
|
|
9489
|
+
return _context70.stop();
|
|
9274
9490
|
}
|
|
9275
|
-
},
|
|
9491
|
+
}, _callee64, this);
|
|
9276
9492
|
}));
|
|
9277
|
-
function prepareHydratedTempOrder(
|
|
9493
|
+
function prepareHydratedTempOrder(_x78, _x79, _x80) {
|
|
9278
9494
|
return _prepareHydratedTempOrder.apply(this, arguments);
|
|
9279
9495
|
}
|
|
9280
9496
|
return prepareHydratedTempOrder;
|
|
@@ -9387,7 +9603,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
9387
9603
|
}, {
|
|
9388
9604
|
key: "normalizeTempOrderForRuntime",
|
|
9389
9605
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
9390
|
-
var
|
|
9606
|
+
var _this59 = this,
|
|
9391
9607
|
_raw$_extend;
|
|
9392
9608
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
9393
9609
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
@@ -9415,13 +9631,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
9415
9631
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
9416
9632
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
9417
9633
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
9418
|
-
return
|
|
9634
|
+
return _this59.normalizeHydratedOrderProduct(p, {
|
|
9419
9635
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
9420
9636
|
});
|
|
9421
9637
|
}) : [];
|
|
9422
9638
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
9423
|
-
var booking =
|
|
9424
|
-
|
|
9639
|
+
var booking = _this59.normalizeHydratedBookingHolder(b || {});
|
|
9640
|
+
var submitted = isFulfillmentTimingBooking(booking) || Number(booking.parent_id) !== 0;
|
|
9641
|
+
return _objectSpread(_objectSpread({}, submitted ? ensureBookingUuid(booking) : booking), {}, {
|
|
9425
9642
|
is_all: normalizeBookingIsAll(booking),
|
|
9426
9643
|
sub_type: normalizeBookingSubType(booking)
|
|
9427
9644
|
});
|
|
@@ -9470,7 +9687,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
9470
9687
|
_step34;
|
|
9471
9688
|
try {
|
|
9472
9689
|
for (_iterator34.s(); !(_step34 = _iterator34.n()).done;) {
|
|
9473
|
-
var _product$metadata15,
|
|
9690
|
+
var _product$metadata15, _ref97, _ref98, _existed$origin, _rawProduct$metadata;
|
|
9474
9691
|
var _step34$value = _slicedToArray(_step34.value, 2),
|
|
9475
9692
|
index = _step34$value[0],
|
|
9476
9693
|
product = _step34$value[1];
|
|
@@ -9478,7 +9695,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
9478
9695
|
if (!uid) continue;
|
|
9479
9696
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
9480
9697
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
9481
|
-
var origin = (
|
|
9698
|
+
var origin = (_ref97 = (_ref98 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref98 !== void 0 ? _ref98 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref97 !== void 0 ? _ref97 : rawProduct;
|
|
9482
9699
|
var originSnapshot = cloneDeep(origin);
|
|
9483
9700
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
9484
9701
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -9501,7 +9718,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
9501
9718
|
tempOrderExtend.productsByUid = productsByUid;
|
|
9502
9719
|
this.hydrateLinkedBookingIdentity(nextTempOrder);
|
|
9503
9720
|
nextTempOrder.products.forEach(function (product) {
|
|
9504
|
-
return
|
|
9721
|
+
return _this59.sanitizeOrderProductForTempOrder(product);
|
|
9505
9722
|
});
|
|
9506
9723
|
if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
|
|
9507
9724
|
this.ensureExternalSaleNumber(nextTempOrder);
|
|
@@ -9610,10 +9827,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
9610
9827
|
}, {
|
|
9611
9828
|
key: "normalizeHydratedProductOptionItem",
|
|
9612
9829
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
9613
|
-
var
|
|
9614
|
-
var rawNum = (
|
|
9830
|
+
var _ref99, _optionItem$num, _ref100, _optionItem$add_price;
|
|
9831
|
+
var rawNum = (_ref99 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref99 !== void 0 ? _ref99 : 1;
|
|
9615
9832
|
var parsedNum = Number(rawNum);
|
|
9616
|
-
var rawPrice = (
|
|
9833
|
+
var rawPrice = (_ref100 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref100 !== void 0 ? _ref100 : 0;
|
|
9617
9834
|
var parsedPrice = Number(rawPrice);
|
|
9618
9835
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
9619
9836
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -9630,7 +9847,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
9630
9847
|
}, {
|
|
9631
9848
|
key: "normalizeHydratedOrderProduct",
|
|
9632
9849
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
9633
|
-
var
|
|
9850
|
+
var _this60 = this;
|
|
9634
9851
|
var row = _objectSpread({}, product || {});
|
|
9635
9852
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
9636
9853
|
row.num = row.product_quantity;
|
|
@@ -9638,7 +9855,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
9638
9855
|
var productSku = ensureProductSku(row);
|
|
9639
9856
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
9640
9857
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
9641
|
-
return
|
|
9858
|
+
return _this60.normalizeHydratedProductOptionItem(optionItem || {});
|
|
9642
9859
|
}))
|
|
9643
9860
|
});
|
|
9644
9861
|
delete row["product_".concat('option', "_item")];
|
|
@@ -9698,27 +9915,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
9698
9915
|
}, {
|
|
9699
9916
|
key: "getOrderInfo",
|
|
9700
9917
|
value: function () {
|
|
9701
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9918
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(order_id) {
|
|
9702
9919
|
var res;
|
|
9703
|
-
return _regeneratorRuntime().wrap(function
|
|
9704
|
-
while (1) switch (
|
|
9920
|
+
return _regeneratorRuntime().wrap(function _callee65$(_context71) {
|
|
9921
|
+
while (1) switch (_context71.prev = _context71.next) {
|
|
9705
9922
|
case 0:
|
|
9706
|
-
|
|
9923
|
+
_context71.next = 2;
|
|
9707
9924
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
9708
9925
|
with: ['products', 'bookings', 'notes']
|
|
9709
9926
|
}, {
|
|
9710
9927
|
osServer: true
|
|
9711
9928
|
});
|
|
9712
9929
|
case 2:
|
|
9713
|
-
res =
|
|
9714
|
-
return
|
|
9930
|
+
res = _context71.sent;
|
|
9931
|
+
return _context71.abrupt("return", res);
|
|
9715
9932
|
case 4:
|
|
9716
9933
|
case "end":
|
|
9717
|
-
return
|
|
9934
|
+
return _context71.stop();
|
|
9718
9935
|
}
|
|
9719
|
-
},
|
|
9936
|
+
}, _callee65, this);
|
|
9720
9937
|
}));
|
|
9721
|
-
function getOrderInfo(
|
|
9938
|
+
function getOrderInfo(_x81) {
|
|
9722
9939
|
return _getOrderInfo.apply(this, arguments);
|
|
9723
9940
|
}
|
|
9724
9941
|
return getOrderInfo;
|