@pisell/pisellos 2.2.258 → 2.2.260
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +152 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +755 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +282 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +146 -0
- package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
- package/dist/model/strategy/adapter/index.d.ts +4 -0
- package/dist/model/strategy/adapter/index.js +5 -1
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +13 -17
- package/dist/modules/Order/index.d.ts +2 -30
- package/dist/modules/Order/index.js +241 -508
- package/dist/modules/Order/types.d.ts +2 -20
- package/dist/modules/Order/utils.d.ts +0 -4
- package/dist/modules/Order/utils.js +28 -114
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/types.d.ts +22 -0
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -2
- package/dist/modules/ProductList/types.d.ts +2 -0
- package/dist/modules/Rules/index.d.ts +3 -3
- package/dist/modules/Rules/index.js +3 -8
- package/dist/modules/Rules/types.d.ts +1 -2
- package/dist/server/index.d.ts +50 -3
- package/dist/server/index.js +958 -1000
- package/dist/server/modules/order/index.d.ts +3 -22
- package/dist/server/modules/order/index.js +314 -397
- package/dist/server/modules/products/index.d.ts +26 -7
- package/dist/server/modules/products/index.js +166 -76
- package/dist/server/modules/products/types.d.ts +14 -0
- package/dist/solution/BaseSales/index.d.ts +2 -16
- package/dist/solution/BaseSales/index.js +314 -484
- package/dist/solution/BaseSales/types.d.ts +0 -1
- package/dist/solution/BaseSales/types.js +1 -2
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -4
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -9
- package/dist/solution/BookingTicket/index.js +6 -162
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +49 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +139 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +87 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +564 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/examples.js +295 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +146 -0
- package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
- package/lib/model/strategy/adapter/index.d.ts +4 -0
- package/lib/model/strategy/adapter/index.js +13 -2
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -11
- package/lib/modules/Order/index.d.ts +2 -30
- package/lib/modules/Order/index.js +57 -340
- package/lib/modules/Order/types.d.ts +2 -20
- package/lib/modules/Order/utils.d.ts +0 -4
- package/lib/modules/Order/utils.js +2 -84
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +22 -0
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +4 -2
- package/lib/modules/ProductList/types.d.ts +2 -0
- package/lib/modules/Rules/index.d.ts +3 -3
- package/lib/modules/Rules/index.js +3 -4
- package/lib/modules/Rules/types.d.ts +1 -2
- package/lib/server/index.d.ts +50 -3
- package/lib/server/index.js +215 -230
- package/lib/server/modules/order/index.d.ts +3 -22
- package/lib/server/modules/order/index.js +51 -102
- package/lib/server/modules/products/index.d.ts +26 -7
- package/lib/server/modules/products/index.js +113 -35
- package/lib/server/modules/products/types.d.ts +14 -0
- package/lib/solution/BaseSales/index.d.ts +2 -16
- package/lib/solution/BaseSales/index.js +31 -143
- package/lib/solution/BaseSales/types.d.ts +0 -1
- package/lib/solution/BaseSales/types.js +1 -2
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +5 -4
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -9
- package/lib/solution/BookingTicket/index.js +0 -112
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/package.json +1 -1
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
- package/dist/modules/Order/utils/bundleDiscountHydration.js +0 -144
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +0 -5
- package/lib/modules/Order/utils/bundleDiscountHydration.js +0 -139
|
@@ -36,7 +36,7 @@ import { OrderModule } from "../../modules/Order";
|
|
|
36
36
|
import Decimal from 'decimal.js';
|
|
37
37
|
import { cloneDeep, mergeWith } from 'lodash-es';
|
|
38
38
|
import { createModule } from "../BookingByStep/types";
|
|
39
|
-
import { composeLinePrice, createUuidV4, ensureProductSku, getProductSkuOptions,
|
|
39
|
+
import { composeLinePrice, createUuidV4, ensureProductSku, getProductSkuOptions, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
40
40
|
import dayjs from 'dayjs';
|
|
41
41
|
export * from "./types";
|
|
42
42
|
import { QuotationModule } from "../../modules/Quotation";
|
|
@@ -153,9 +153,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
153
153
|
_defineProperty(_assertThisInitialized(_this), "hasManualDiscountSelection", false);
|
|
154
154
|
_defineProperty(_assertThisInitialized(_this), "reusedSharedSubModuleNames", new Set());
|
|
155
155
|
_defineProperty(_assertThisInitialized(_this), "paymentMethodsCache", []);
|
|
156
|
-
_defineProperty(_assertThisInitialized(_this), "queuedAutoPaymentSync", false);
|
|
157
|
-
_defineProperty(_assertThisInitialized(_this), "autoPaymentSyncFlushing", false);
|
|
158
|
-
_defineProperty(_assertThisInitialized(_this), "autoPaymentSyncTimer", null);
|
|
159
156
|
return _this;
|
|
160
157
|
}
|
|
161
158
|
|
|
@@ -171,9 +168,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
171
168
|
}, {
|
|
172
169
|
key: "getReusableSharedSubModule",
|
|
173
170
|
value: function getReusableSharedSubModule(moduleName) {
|
|
174
|
-
var _this$core
|
|
171
|
+
var _this$core;
|
|
175
172
|
if (moduleName !== 'schedule' && moduleName !== 'quotation') return null;
|
|
176
|
-
return ((_this$core = this.core) === null || _this$core === void 0
|
|
173
|
+
return ((_this$core = this.core) === null || _this$core === void 0 ? void 0 : _this$core.getModule(moduleName)) || null;
|
|
177
174
|
}
|
|
178
175
|
}, {
|
|
179
176
|
key: "isScheduleListLoaded",
|
|
@@ -1492,7 +1489,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1492
1489
|
value: function () {
|
|
1493
1490
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
1494
1491
|
var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
|
|
1495
|
-
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _tempOrder$holder, _orderStore$summary, holders,
|
|
1492
|
+
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _tempOrder$holder, _tempOrder$holder2, _orderStore$summary, holders, result, _iterator, _step, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
|
|
1496
1493
|
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1497
1494
|
while (1) switch (_context15.prev = _context15.next) {
|
|
1498
1495
|
case 0:
|
|
@@ -1586,20 +1583,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1586
1583
|
});
|
|
1587
1584
|
case 40:
|
|
1588
1585
|
if (!rulesModule) {
|
|
1589
|
-
_context15.next =
|
|
1586
|
+
_context15.next = 76;
|
|
1590
1587
|
break;
|
|
1591
1588
|
}
|
|
1592
|
-
holders = (
|
|
1593
|
-
|
|
1594
|
-
|
|
1589
|
+
holders = (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
|
|
1590
|
+
form_record_id: tempOrder.holder.form_record_id
|
|
1591
|
+
}] : [];
|
|
1595
1592
|
result = rulesModule.calcDiscount({
|
|
1596
1593
|
productList: tempOrder.products,
|
|
1597
1594
|
discountList: nextDiscountList,
|
|
1598
1595
|
holders: holders,
|
|
1599
|
-
isFormSubject:
|
|
1600
|
-
|
|
1601
|
-
},
|
|
1602
|
-
orderTotalAmount: orderTotalAmount
|
|
1596
|
+
isFormSubject: !!((_tempOrder$holder2 = tempOrder.holder) !== null && _tempOrder$holder2 !== void 0 && _tempOrder$holder2.type) && tempOrder.holder.type === 'form',
|
|
1597
|
+
orderTotalAmount: Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0)
|
|
1603
1598
|
}) || {
|
|
1604
1599
|
productList: tempOrder.products,
|
|
1605
1600
|
discountList: nextDiscountList
|
|
@@ -1608,22 +1603,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1608
1603
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
1609
1604
|
}
|
|
1610
1605
|
_iterator = _createForOfIteratorHelper(tempOrder.products || []);
|
|
1611
|
-
_context15.prev =
|
|
1606
|
+
_context15.prev = 45;
|
|
1612
1607
|
_iterator.s();
|
|
1613
|
-
case
|
|
1608
|
+
case 47:
|
|
1614
1609
|
if ((_step = _iterator.n()).done) {
|
|
1615
|
-
_context15.next =
|
|
1610
|
+
_context15.next = 62;
|
|
1616
1611
|
break;
|
|
1617
1612
|
}
|
|
1618
1613
|
product = _step.value;
|
|
1619
1614
|
productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
|
|
1620
1615
|
runtimeOrigin = productUid ? (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[productUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin : undefined;
|
|
1621
1616
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
1622
|
-
_context15.next =
|
|
1617
|
+
_context15.next = 53;
|
|
1623
1618
|
break;
|
|
1624
1619
|
}
|
|
1625
|
-
return _context15.abrupt("continue",
|
|
1626
|
-
case
|
|
1620
|
+
return _context15.abrupt("continue", 60);
|
|
1621
|
+
case 53:
|
|
1627
1622
|
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
1628
1623
|
return sum + Number(pd.amount || 0);
|
|
1629
1624
|
}, 0);
|
|
@@ -1639,58 +1634,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1639
1634
|
mainPrice: newMainSellingPrice,
|
|
1640
1635
|
bundle: product.product_bundle
|
|
1641
1636
|
});
|
|
1637
|
+
case 60:
|
|
1638
|
+
_context15.next = 47;
|
|
1639
|
+
break;
|
|
1642
1640
|
case 62:
|
|
1643
|
-
_context15.next =
|
|
1641
|
+
_context15.next = 67;
|
|
1644
1642
|
break;
|
|
1645
1643
|
case 64:
|
|
1646
|
-
_context15.
|
|
1647
|
-
|
|
1648
|
-
case 66:
|
|
1649
|
-
_context15.prev = 66;
|
|
1650
|
-
_context15.t0 = _context15["catch"](47);
|
|
1644
|
+
_context15.prev = 64;
|
|
1645
|
+
_context15.t0 = _context15["catch"](45);
|
|
1651
1646
|
_iterator.e(_context15.t0);
|
|
1652
|
-
case
|
|
1653
|
-
_context15.prev =
|
|
1647
|
+
case 67:
|
|
1648
|
+
_context15.prev = 67;
|
|
1654
1649
|
_iterator.f();
|
|
1655
|
-
return _context15.finish(
|
|
1656
|
-
case
|
|
1650
|
+
return _context15.finish(67);
|
|
1651
|
+
case 70:
|
|
1657
1652
|
if (!result.discountList) {
|
|
1658
|
-
_context15.next =
|
|
1653
|
+
_context15.next = 76;
|
|
1659
1654
|
break;
|
|
1660
1655
|
}
|
|
1661
1656
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
1662
1657
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1663
|
-
_context15.next =
|
|
1658
|
+
_context15.next = 75;
|
|
1664
1659
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1665
|
-
case
|
|
1660
|
+
case 75:
|
|
1666
1661
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
1667
1662
|
return discount.isSelected;
|
|
1668
1663
|
});
|
|
1669
|
-
case
|
|
1670
|
-
_context15.next =
|
|
1664
|
+
case 76:
|
|
1665
|
+
_context15.next = 78;
|
|
1671
1666
|
return this.store.order.recalculateSummary({
|
|
1672
1667
|
createIfMissing: true
|
|
1673
1668
|
});
|
|
1674
|
-
case
|
|
1669
|
+
case 78:
|
|
1675
1670
|
summary = _context15.sent;
|
|
1676
1671
|
this.store.order.persistTempOrder();
|
|
1677
|
-
_context15.next =
|
|
1672
|
+
_context15.next = 82;
|
|
1678
1673
|
return this.effectsEmit('onDiscountApplied', {
|
|
1679
1674
|
productList: tempOrder.products || [],
|
|
1680
1675
|
discountList: nextDiscountList,
|
|
1681
1676
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
1682
1677
|
tempOrder: tempOrder
|
|
1683
1678
|
});
|
|
1684
|
-
case
|
|
1679
|
+
case 82:
|
|
1685
1680
|
return _context15.abrupt("return", {
|
|
1686
1681
|
productList: tempOrder.products || [],
|
|
1687
1682
|
discountList: nextDiscountList
|
|
1688
1683
|
});
|
|
1689
|
-
case
|
|
1684
|
+
case 83:
|
|
1690
1685
|
case "end":
|
|
1691
1686
|
return _context15.stop();
|
|
1692
1687
|
}
|
|
1693
|
-
}, _callee15, this, [[
|
|
1688
|
+
}, _callee15, this, [[45, 64, 67, 70]]);
|
|
1694
1689
|
}));
|
|
1695
1690
|
function loadDiscountConfig(_x10) {
|
|
1696
1691
|
return _loadDiscountConfig.apply(this, arguments);
|
|
@@ -1702,7 +1697,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1702
1697
|
value: function () {
|
|
1703
1698
|
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(cb) {
|
|
1704
1699
|
var _discountModule$getOr2, _discountModule$getDi3;
|
|
1705
|
-
var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _tempOrder$
|
|
1700
|
+
var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _tempOrder$holder3, _tempOrder$holder4, _orderStore$summary2, holders;
|
|
1706
1701
|
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1707
1702
|
while (1) switch (_context16.prev = _context16.next) {
|
|
1708
1703
|
case 0:
|
|
@@ -1727,33 +1722,31 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1727
1722
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1728
1723
|
case 12:
|
|
1729
1724
|
if (!rulesModule) {
|
|
1730
|
-
_context16.next =
|
|
1725
|
+
_context16.next = 23;
|
|
1731
1726
|
break;
|
|
1732
1727
|
}
|
|
1733
|
-
holders = (
|
|
1734
|
-
|
|
1735
|
-
|
|
1728
|
+
holders = (_tempOrder$holder3 = tempOrder.holder) !== null && _tempOrder$holder3 !== void 0 && _tempOrder$holder3.form_record_id ? [{
|
|
1729
|
+
form_record_id: tempOrder.holder.form_record_id
|
|
1730
|
+
}] : [];
|
|
1736
1731
|
result = rulesModule.calcDiscount({
|
|
1737
1732
|
productList: tempOrder.products,
|
|
1738
1733
|
discountList: nextDiscountList,
|
|
1739
1734
|
holders: holders,
|
|
1740
|
-
isFormSubject:
|
|
1741
|
-
|
|
1742
|
-
},
|
|
1743
|
-
orderTotalAmount: orderTotalAmount
|
|
1735
|
+
isFormSubject: !!((_tempOrder$holder4 = tempOrder.holder) !== null && _tempOrder$holder4 !== void 0 && _tempOrder$holder4.type) && tempOrder.holder.type === 'form',
|
|
1736
|
+
orderTotalAmount: Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0)
|
|
1744
1737
|
}) || result;
|
|
1745
1738
|
if (result.productList) {
|
|
1746
1739
|
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
1747
1740
|
}
|
|
1748
1741
|
if (!result.discountList) {
|
|
1749
|
-
_context16.next =
|
|
1742
|
+
_context16.next = 23;
|
|
1750
1743
|
break;
|
|
1751
1744
|
}
|
|
1752
1745
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
1753
1746
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1754
|
-
_context16.next =
|
|
1747
|
+
_context16.next = 21;
|
|
1755
1748
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1756
|
-
case
|
|
1749
|
+
case 21:
|
|
1757
1750
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
1758
1751
|
return discount.isSelected;
|
|
1759
1752
|
});
|
|
@@ -1761,16 +1754,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1761
1754
|
productList: tempOrder.products,
|
|
1762
1755
|
discountList: nextDiscountList
|
|
1763
1756
|
};
|
|
1764
|
-
case
|
|
1765
|
-
_context16.next =
|
|
1757
|
+
case 23:
|
|
1758
|
+
_context16.next = 25;
|
|
1766
1759
|
return this.store.order.recalculateSummary({
|
|
1767
1760
|
createIfMissing: true
|
|
1768
1761
|
});
|
|
1769
|
-
case
|
|
1762
|
+
case 25:
|
|
1770
1763
|
this.store.order.persistTempOrder();
|
|
1771
1764
|
cb === null || cb === void 0 || cb(result);
|
|
1772
1765
|
return _context16.abrupt("return", result);
|
|
1773
|
-
case
|
|
1766
|
+
case 28:
|
|
1774
1767
|
case "end":
|
|
1775
1768
|
return _context16.stop();
|
|
1776
1769
|
}
|
|
@@ -1841,7 +1834,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1841
1834
|
key: "setDiscountSelected",
|
|
1842
1835
|
value: function () {
|
|
1843
1836
|
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
|
|
1844
|
-
var _tempOrder$
|
|
1837
|
+
var _tempOrder$holder5, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder6, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, _iterator3, _step3, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
1845
1838
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1846
1839
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1847
1840
|
case 0:
|
|
@@ -1864,22 +1857,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1864
1857
|
orderStore = this.store.order.store || {};
|
|
1865
1858
|
discountModule = orderStore.discount;
|
|
1866
1859
|
rulesModule = orderStore.rules;
|
|
1867
|
-
holders = (
|
|
1860
|
+
holders = (_tempOrder$holder5 = tempOrder.holder) !== null && _tempOrder$holder5 !== void 0 && _tempOrder$holder5.form_record_id ? [{
|
|
1861
|
+
form_record_id: tempOrder.holder.form_record_id
|
|
1862
|
+
}] : [];
|
|
1868
1863
|
nextDiscountList = updated;
|
|
1869
1864
|
_context18.next = 14;
|
|
1870
1865
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
1871
1866
|
case 14:
|
|
1872
1867
|
if (rulesModule) {
|
|
1873
|
-
orderTotalAmount = Number(((_orderStore$summary3 = orderStore.summary) === null || _orderStore$summary3 === void 0 ? void 0 : _orderStore$summary3.total_amount) || 0);
|
|
1874
|
-
console.log('[BaseSales.setDiscountSelected.calcDiscount]');
|
|
1875
1868
|
result = rulesModule.calcDiscount({
|
|
1876
1869
|
productList: tempOrder.products,
|
|
1877
1870
|
discountList: updated,
|
|
1878
1871
|
holders: holders,
|
|
1879
|
-
isFormSubject:
|
|
1880
|
-
return resolveIsFormSubject(tempOrder, product);
|
|
1881
|
-
},
|
|
1882
|
-
orderTotalAmount: orderTotalAmount
|
|
1872
|
+
isFormSubject: !!((_tempOrder$holder6 = tempOrder.holder) !== null && _tempOrder$holder6 !== void 0 && _tempOrder$holder6.type) && tempOrder.holder.type === 'form'
|
|
1883
1873
|
}, {
|
|
1884
1874
|
discountId: params.discountId,
|
|
1885
1875
|
isSelected: params.isSelected
|
|
@@ -1905,7 +1895,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1905
1895
|
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
1906
1896
|
d.isSelected = false;
|
|
1907
1897
|
d.isManualSelect = true;
|
|
1908
|
-
d.appliedProductDetails = [];
|
|
1909
1898
|
}
|
|
1910
1899
|
}
|
|
1911
1900
|
} catch (err) {
|
|
@@ -1921,45 +1910,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1921
1910
|
}).map(function (d) {
|
|
1922
1911
|
return d.id;
|
|
1923
1912
|
}));
|
|
1924
|
-
filterSelectedDiscountDetails = function filterSelectedDiscountDetails(discountList) {
|
|
1925
|
-
return (discountList || []).filter(function (pd) {
|
|
1926
|
-
var _pd$discount$resource, _pd$discount;
|
|
1927
|
-
var rid = (_pd$discount$resource = (_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) !== null && _pd$discount$resource !== void 0 ? _pd$discount$resource : pd.id;
|
|
1928
|
-
return rid != null && selectedResourceIds.has(rid);
|
|
1929
|
-
});
|
|
1930
|
-
};
|
|
1931
1913
|
_iterator3 = _createForOfIteratorHelper(tempOrder.products);
|
|
1932
|
-
_context18.prev =
|
|
1914
|
+
_context18.prev = 17;
|
|
1933
1915
|
_iterator3.s();
|
|
1934
|
-
case
|
|
1916
|
+
case 19:
|
|
1935
1917
|
if ((_step3 = _iterator3.n()).done) {
|
|
1936
|
-
_context18.next =
|
|
1918
|
+
_context18.next = 35;
|
|
1937
1919
|
break;
|
|
1938
1920
|
}
|
|
1939
1921
|
product = _step3.value;
|
|
1940
1922
|
productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
|
|
1941
1923
|
runtimeOrigin = productUid ? (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[productUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin : undefined;
|
|
1942
1924
|
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
|
|
1943
|
-
_context18.next =
|
|
1925
|
+
_context18.next = 25;
|
|
1944
1926
|
break;
|
|
1945
1927
|
}
|
|
1946
|
-
return _context18.abrupt("continue",
|
|
1947
|
-
case
|
|
1948
|
-
product.discount_list =
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
1954
|
-
var restoredBundlePrice = (_ref18 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref18 !== void 0 ? _ref18 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
1955
|
-
return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
|
|
1956
|
-
price: restoredBundlePrice,
|
|
1957
|
-
bundle_selling_price: restoredBundlePrice
|
|
1958
|
-
} : {}), {}, {
|
|
1959
|
-
discount_list: nextBundleDiscountList
|
|
1960
|
-
});
|
|
1961
|
-
});
|
|
1962
|
-
}
|
|
1928
|
+
return _context18.abrupt("continue", 33);
|
|
1929
|
+
case 25:
|
|
1930
|
+
product.discount_list = (product.discount_list || []).filter(function (pd) {
|
|
1931
|
+
var _pd$discount$resource, _pd$discount;
|
|
1932
|
+
var rid = (_pd$discount$resource = (_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) !== null && _pd$discount$resource !== void 0 ? _pd$discount$resource : pd.id;
|
|
1933
|
+
return rid != null && selectedResourceIds.has(rid);
|
|
1934
|
+
});
|
|
1963
1935
|
|
|
1964
1936
|
// 券作用于 source(不含 option、不含 bundle);算出新 source 折后价后补回 options
|
|
1965
1937
|
// 写入含 option 的 main_product_selling_price,再合成 composite 回写 selling_price。
|
|
@@ -1978,33 +1950,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1978
1950
|
mainPrice: newMainSellingPrice,
|
|
1979
1951
|
bundle: product.product_bundle
|
|
1980
1952
|
});
|
|
1953
|
+
case 33:
|
|
1954
|
+
_context18.next = 19;
|
|
1955
|
+
break;
|
|
1981
1956
|
case 35:
|
|
1982
|
-
_context18.next =
|
|
1957
|
+
_context18.next = 40;
|
|
1983
1958
|
break;
|
|
1984
1959
|
case 37:
|
|
1985
|
-
_context18.
|
|
1986
|
-
|
|
1987
|
-
case 39:
|
|
1988
|
-
_context18.prev = 39;
|
|
1989
|
-
_context18.t0 = _context18["catch"](18);
|
|
1960
|
+
_context18.prev = 37;
|
|
1961
|
+
_context18.t0 = _context18["catch"](17);
|
|
1990
1962
|
_iterator3.e(_context18.t0);
|
|
1991
|
-
case
|
|
1992
|
-
_context18.prev =
|
|
1963
|
+
case 40:
|
|
1964
|
+
_context18.prev = 40;
|
|
1993
1965
|
_iterator3.f();
|
|
1994
|
-
return _context18.finish(
|
|
1995
|
-
case
|
|
1966
|
+
return _context18.finish(40);
|
|
1967
|
+
case 43:
|
|
1996
1968
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1997
|
-
_context18.next =
|
|
1969
|
+
_context18.next = 46;
|
|
1998
1970
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1999
|
-
case
|
|
1971
|
+
case 46:
|
|
2000
1972
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
2001
1973
|
return d.isSelected;
|
|
2002
1974
|
});
|
|
2003
|
-
_context18.next =
|
|
1975
|
+
_context18.next = 49;
|
|
2004
1976
|
return this.store.order.recalculateSummary({
|
|
2005
1977
|
createIfMissing: true
|
|
2006
1978
|
});
|
|
2007
|
-
case
|
|
1979
|
+
case 49:
|
|
2008
1980
|
this.store.order.persistTempOrder();
|
|
2009
1981
|
this.effectsEmit('onDiscountApplied', {
|
|
2010
1982
|
productList: tempOrder.products,
|
|
@@ -2012,17 +1984,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2012
1984
|
selectedDiscountList: tempOrder.discount_list,
|
|
2013
1985
|
tempOrder: tempOrder
|
|
2014
1986
|
});
|
|
2015
|
-
_context18.next =
|
|
1987
|
+
_context18.next = 56;
|
|
2016
1988
|
break;
|
|
2017
|
-
case
|
|
2018
|
-
_context18.prev =
|
|
1989
|
+
case 53:
|
|
1990
|
+
_context18.prev = 53;
|
|
2019
1991
|
_context18.t1 = _context18["catch"](0);
|
|
2020
1992
|
throw _context18.t1;
|
|
2021
|
-
case
|
|
1993
|
+
case 56:
|
|
2022
1994
|
case "end":
|
|
2023
1995
|
return _context18.stop();
|
|
2024
1996
|
}
|
|
2025
|
-
}, _callee18, this, [[0,
|
|
1997
|
+
}, _callee18, this, [[0, 53], [17, 37, 40, 43]]);
|
|
2026
1998
|
}));
|
|
2027
1999
|
function setDiscountSelected(_x14) {
|
|
2028
2000
|
return _setDiscountSelected.apply(this, arguments);
|
|
@@ -2133,7 +2105,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2133
2105
|
case 2:
|
|
2134
2106
|
// this.store.order.persistTempOrder();
|
|
2135
2107
|
inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
|
|
2136
|
-
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(
|
|
2108
|
+
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
2137
2109
|
cacheId: this.cacheId,
|
|
2138
2110
|
platform: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform,
|
|
2139
2111
|
businessCode: ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) || ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code),
|
|
@@ -2146,8 +2118,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2146
2118
|
paymentStatus: inferredPaymentStatus
|
|
2147
2119
|
} : {}), (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined ? {
|
|
2148
2120
|
smallTicketDataFlag: params.smallTicketDataFlag
|
|
2149
|
-
} : {}), (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
|
|
2150
|
-
confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
|
|
2151
2121
|
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2152
2122
|
enhancePayload: params.enhancePayload
|
|
2153
2123
|
} : {});
|
|
@@ -2179,7 +2149,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2179
2149
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
2180
2150
|
case 2:
|
|
2181
2151
|
inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
|
|
2182
|
-
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(
|
|
2152
|
+
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
2183
2153
|
cacheId: this.cacheId,
|
|
2184
2154
|
platform: (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform,
|
|
2185
2155
|
businessCode: ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code),
|
|
@@ -2191,8 +2161,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2191
2161
|
paymentStatus: inferredPaymentStatus
|
|
2192
2162
|
} : {}), (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined ? {
|
|
2193
2163
|
smallTicketDataFlag: params.smallTicketDataFlag
|
|
2194
|
-
} : {}), (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== undefined ? {
|
|
2195
|
-
confirmPendingVoucherPayments: params.confirmPendingVoucherPayments
|
|
2196
2164
|
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2197
2165
|
enhancePayload: params.enhancePayload
|
|
2198
2166
|
} : {});
|
|
@@ -2292,8 +2260,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2292
2260
|
key: "syncPaymentsToOrder",
|
|
2293
2261
|
value: function () {
|
|
2294
2262
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
2295
|
-
var
|
|
2296
|
-
var businessCode, channel, syncParams, syncState, payments, syncResult
|
|
2263
|
+
var _ref18, _params$businessCode, _this$otherParams18, _this$otherParams19, _params$channel;
|
|
2264
|
+
var businessCode, channel, syncParams, syncState, payments, syncResult;
|
|
2297
2265
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2298
2266
|
while (1) switch (_context24.prev = _context24.next) {
|
|
2299
2267
|
case 0:
|
|
@@ -2303,7 +2271,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2303
2271
|
}
|
|
2304
2272
|
throw new Error('order 模块未初始化');
|
|
2305
2273
|
case 2:
|
|
2306
|
-
businessCode = (
|
|
2274
|
+
businessCode = (_ref18 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode) !== null && _ref18 !== void 0 ? _ref18 : (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.business_code;
|
|
2307
2275
|
channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
|
|
2308
2276
|
syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
|
|
2309
2277
|
businessCode: businessCode
|
|
@@ -2312,59 +2280,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2312
2280
|
} : {});
|
|
2313
2281
|
syncState = this.store.order.getOrderSyncState();
|
|
2314
2282
|
if (!(params.submitWhenPaid && syncState === 'submitting')) {
|
|
2315
|
-
_context24.next =
|
|
2283
|
+
_context24.next = 8;
|
|
2316
2284
|
break;
|
|
2317
2285
|
}
|
|
2318
|
-
this.queueLatestAutoPaymentSync();
|
|
2319
2286
|
return _context24.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
|
|
2320
|
-
case
|
|
2287
|
+
case 8:
|
|
2321
2288
|
payments = params.payments || [];
|
|
2322
|
-
_context24.next =
|
|
2289
|
+
_context24.next = 11;
|
|
2323
2290
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
|
|
2324
2291
|
payments: payments,
|
|
2325
2292
|
params: syncParams,
|
|
2326
2293
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
2327
2294
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
2328
2295
|
});
|
|
2329
|
-
case
|
|
2330
|
-
_context24.prev =
|
|
2331
|
-
_context24.next =
|
|
2296
|
+
case 11:
|
|
2297
|
+
_context24.prev = 11;
|
|
2298
|
+
_context24.next = 14;
|
|
2332
2299
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
2333
|
-
case
|
|
2300
|
+
case 14:
|
|
2334
2301
|
syncResult = _context24.sent;
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
orderSnapshot = this.store.order.getOrderSnapshot();
|
|
2338
|
-
syncPayload = {
|
|
2302
|
+
_context24.next = 17;
|
|
2303
|
+
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
2339
2304
|
ok: true,
|
|
2340
2305
|
syncResult: syncResult,
|
|
2341
|
-
payments:
|
|
2306
|
+
payments: this.store.order.getOrderPayments(),
|
|
2342
2307
|
params: syncParams,
|
|
2343
|
-
amountSnapshot:
|
|
2344
|
-
orderSnapshot:
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
isDepositFullyPaid: syncResult.isDepositFullyPaid,
|
|
2348
|
-
paymentStage: syncResult.paymentStage,
|
|
2349
|
-
depositAmount: syncResult.depositAmount,
|
|
2350
|
-
orderExpectedAmount: syncResult.orderExpectedAmount
|
|
2351
|
-
};
|
|
2352
|
-
_context24.next = 22;
|
|
2353
|
-
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
|
|
2354
|
-
case 22:
|
|
2355
|
-
if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
|
|
2356
|
-
_context24.next = 25;
|
|
2357
|
-
break;
|
|
2358
|
-
}
|
|
2359
|
-
_context24.next = 25;
|
|
2360
|
-
return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
2361
|
-
case 25:
|
|
2362
|
-
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
2308
|
+
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
2309
|
+
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
2310
|
+
});
|
|
2311
|
+
case 17:
|
|
2363
2312
|
return _context24.abrupt("return", syncResult);
|
|
2364
|
-
case
|
|
2365
|
-
_context24.prev =
|
|
2366
|
-
_context24.t0 = _context24["catch"](
|
|
2367
|
-
_context24.next =
|
|
2313
|
+
case 20:
|
|
2314
|
+
_context24.prev = 20;
|
|
2315
|
+
_context24.t0 = _context24["catch"](11);
|
|
2316
|
+
_context24.next = 24;
|
|
2368
2317
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
2369
2318
|
ok: false,
|
|
2370
2319
|
error: _context24.t0,
|
|
@@ -2373,14 +2322,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2373
2322
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
2374
2323
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
2375
2324
|
});
|
|
2376
|
-
case
|
|
2377
|
-
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
2325
|
+
case 24:
|
|
2378
2326
|
throw _context24.t0;
|
|
2379
|
-
case
|
|
2327
|
+
case 25:
|
|
2380
2328
|
case "end":
|
|
2381
2329
|
return _context24.stop();
|
|
2382
2330
|
}
|
|
2383
|
-
}, _callee24, this, [[
|
|
2331
|
+
}, _callee24, this, [[11, 20]]);
|
|
2384
2332
|
}));
|
|
2385
2333
|
function syncPaymentsToOrder(_x20) {
|
|
2386
2334
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
@@ -2402,120 +2350,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2402
2350
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2403
2351
|
return this.store.order.setOrderPayments(payments);
|
|
2404
2352
|
}
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
value: function getPaymentStatusForSync(payments) {
|
|
2408
|
-
var order = this.store.order;
|
|
2409
|
-
if (!order) throw new Error('order 模块未初始化');
|
|
2410
|
-
var completion = order.getPaymentCompletion(payments);
|
|
2411
|
-
return completion.isOrderFullyPaid ? 'paid' : 'partially_paid';
|
|
2412
|
-
}
|
|
2413
|
-
}, {
|
|
2414
|
-
key: "queueLatestAutoPaymentSync",
|
|
2415
|
-
value: function queueLatestAutoPaymentSync() {
|
|
2416
|
-
this.queuedAutoPaymentSync = true;
|
|
2417
|
-
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
2418
|
-
}
|
|
2419
|
-
}, {
|
|
2420
|
-
key: "scheduleQueuedAutoPaymentSyncFlush",
|
|
2421
|
-
value: function scheduleQueuedAutoPaymentSyncFlush() {
|
|
2422
|
-
var _this8 = this;
|
|
2423
|
-
var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
|
|
2424
|
-
if (!this.queuedAutoPaymentSync) return;
|
|
2425
|
-
if (this.autoPaymentSyncTimer) return;
|
|
2426
|
-
this.autoPaymentSyncTimer = setTimeout(function () {
|
|
2427
|
-
_this8.autoPaymentSyncTimer = null;
|
|
2428
|
-
void _this8.flushQueuedAutoPaymentSync();
|
|
2429
|
-
}, delay);
|
|
2430
|
-
}
|
|
2431
|
-
}, {
|
|
2432
|
-
key: "flushQueuedAutoPaymentSync",
|
|
2433
|
-
value: function () {
|
|
2434
|
-
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
2435
|
-
var payments;
|
|
2436
|
-
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2437
|
-
while (1) switch (_context25.prev = _context25.next) {
|
|
2438
|
-
case 0:
|
|
2439
|
-
if (this.store.order) {
|
|
2440
|
-
_context25.next = 2;
|
|
2441
|
-
break;
|
|
2442
|
-
}
|
|
2443
|
-
return _context25.abrupt("return");
|
|
2444
|
-
case 2:
|
|
2445
|
-
if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
|
|
2446
|
-
_context25.next = 4;
|
|
2447
|
-
break;
|
|
2448
|
-
}
|
|
2449
|
-
return _context25.abrupt("return");
|
|
2450
|
-
case 4:
|
|
2451
|
-
if (!(this.store.order.getOrderSyncState() === 'submitting')) {
|
|
2452
|
-
_context25.next = 7;
|
|
2453
|
-
break;
|
|
2454
|
-
}
|
|
2455
|
-
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
2456
|
-
return _context25.abrupt("return");
|
|
2457
|
-
case 7:
|
|
2458
|
-
this.autoPaymentSyncFlushing = true;
|
|
2459
|
-
_context25.prev = 8;
|
|
2460
|
-
case 9:
|
|
2461
|
-
if (!this.queuedAutoPaymentSync) {
|
|
2462
|
-
_context25.next = 18;
|
|
2463
|
-
break;
|
|
2464
|
-
}
|
|
2465
|
-
this.queuedAutoPaymentSync = false;
|
|
2466
|
-
payments = this.store.order.getOrderPayments();
|
|
2467
|
-
if (payments.length) {
|
|
2468
|
-
_context25.next = 14;
|
|
2469
|
-
break;
|
|
2470
|
-
}
|
|
2471
|
-
return _context25.abrupt("continue", 9);
|
|
2472
|
-
case 14:
|
|
2473
|
-
_context25.next = 16;
|
|
2474
|
-
return this.syncPaymentsToOrder({
|
|
2475
|
-
payments: payments,
|
|
2476
|
-
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
2477
|
-
submitWhenPaid: true,
|
|
2478
|
-
smallTicketDataFlag: 1
|
|
2479
|
-
});
|
|
2480
|
-
case 16:
|
|
2481
|
-
_context25.next = 9;
|
|
2482
|
-
break;
|
|
2483
|
-
case 18:
|
|
2484
|
-
_context25.next = 23;
|
|
2485
|
-
break;
|
|
2486
|
-
case 20:
|
|
2487
|
-
_context25.prev = 20;
|
|
2488
|
-
_context25.t0 = _context25["catch"](8);
|
|
2489
|
-
this.logError('queued auto sync payments failed', {
|
|
2490
|
-
error: _context25.t0 instanceof Error ? _context25.t0.message : String(_context25.t0)
|
|
2491
|
-
});
|
|
2492
|
-
case 23:
|
|
2493
|
-
_context25.prev = 23;
|
|
2494
|
-
this.autoPaymentSyncFlushing = false;
|
|
2495
|
-
if (this.queuedAutoPaymentSync) {
|
|
2496
|
-
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
2497
|
-
}
|
|
2498
|
-
return _context25.finish(23);
|
|
2499
|
-
case 27:
|
|
2500
|
-
case "end":
|
|
2501
|
-
return _context25.stop();
|
|
2502
|
-
}
|
|
2503
|
-
}, _callee25, this, [[8, 20, 23, 27]]);
|
|
2504
|
-
}));
|
|
2505
|
-
function flushQueuedAutoPaymentSync() {
|
|
2506
|
-
return _flushQueuedAutoPaymentSync.apply(this, arguments);
|
|
2507
|
-
}
|
|
2508
|
-
return flushQueuedAutoPaymentSync;
|
|
2509
|
-
}() /** 追加单个支付项到当前订单。 */
|
|
2353
|
+
|
|
2354
|
+
/** 追加单个支付项到当前订单。 */
|
|
2510
2355
|
}, {
|
|
2511
2356
|
key: "addOrderPayment",
|
|
2512
2357
|
value: function addOrderPayment(payment) {
|
|
2513
2358
|
var _this$otherParams20,
|
|
2514
2359
|
_paymentRecord$paymen,
|
|
2515
2360
|
_paymentRecord$create,
|
|
2516
|
-
|
|
2361
|
+
_ref19,
|
|
2517
2362
|
_paymentRecord$origin,
|
|
2518
|
-
|
|
2363
|
+
_this8 = this;
|
|
2519
2364
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2520
2365
|
var paymentRecord = payment;
|
|
2521
2366
|
var paymentAmount = new Decimal(paymentRecord.amount || 0);
|
|
@@ -2537,7 +2382,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2537
2382
|
var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
|
|
2538
2383
|
var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
|
|
2539
2384
|
var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
|
|
2540
|
-
var calculatedServiceFee = serviceCharge ? new Decimal((
|
|
2385
|
+
var calculatedServiceFee = serviceCharge ? new Decimal((_ref19 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref19 !== void 0 ? _ref19 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
2541
2386
|
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, paymentRecord), calculatedServiceFee !== undefined ? {
|
|
2542
2387
|
service_fee: calculatedServiceFee
|
|
2543
2388
|
} : {}), {}, {
|
|
@@ -2547,22 +2392,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2547
2392
|
}));
|
|
2548
2393
|
var amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
2549
2394
|
var syncState = this.store.order.getOrderSyncState();
|
|
2550
|
-
if (amountSnapshot) {
|
|
2551
|
-
|
|
2552
|
-
this.queueLatestAutoPaymentSync();
|
|
2553
|
-
return payments;
|
|
2554
|
-
}
|
|
2395
|
+
if (amountSnapshot && syncState !== 'submitting') {
|
|
2396
|
+
var paymentStatus = Number(amountSnapshot.amountGap || 0) <= 0 ? 'paid' : 'partially_paid';
|
|
2555
2397
|
void this.syncPaymentsToOrder({
|
|
2556
2398
|
payments: payments,
|
|
2557
|
-
paymentStatus:
|
|
2399
|
+
paymentStatus: paymentStatus,
|
|
2558
2400
|
submitWhenPaid: true,
|
|
2559
2401
|
smallTicketDataFlag: 1
|
|
2560
2402
|
}).catch(function (error) {
|
|
2561
|
-
|
|
2403
|
+
_this8.logError('auto sync payments failed', {
|
|
2562
2404
|
error: error instanceof Error ? error.message : String(error)
|
|
2563
2405
|
});
|
|
2564
2406
|
});
|
|
2565
|
-
}
|
|
2407
|
+
} else {}
|
|
2566
2408
|
return payments;
|
|
2567
2409
|
}
|
|
2568
2410
|
|
|
@@ -2585,21 +2427,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2585
2427
|
/** 覆盖 wallet pass 支付项,同时保留普通支付项。 */
|
|
2586
2428
|
}, {
|
|
2587
2429
|
key: "updateVoucherOrderPayments",
|
|
2588
|
-
value: function updateVoucherOrderPayments(payments
|
|
2589
|
-
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2590
|
-
return this.store.order.updateVoucherOrderPayments(payments, options);
|
|
2591
|
-
}
|
|
2592
|
-
}, {
|
|
2593
|
-
key: "confirmPendingVoucherPayments",
|
|
2594
|
-
value: function confirmPendingVoucherPayments() {
|
|
2430
|
+
value: function updateVoucherOrderPayments(payments) {
|
|
2595
2431
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2596
|
-
return this.store.order.
|
|
2597
|
-
}
|
|
2598
|
-
}, {
|
|
2599
|
-
key: "discardPendingVoucherPayments",
|
|
2600
|
-
value: function discardPendingVoucherPayments() {
|
|
2601
|
-
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2602
|
-
return this.store.order.discardPendingVoucherPayments();
|
|
2432
|
+
return this.store.order.updateVoucherOrderPayments(payments);
|
|
2603
2433
|
}
|
|
2604
2434
|
}, {
|
|
2605
2435
|
key: "getWalletProductList",
|
|
@@ -2662,20 +2492,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2662
2492
|
}, {
|
|
2663
2493
|
key: "initWalletData",
|
|
2664
2494
|
value: function () {
|
|
2665
|
-
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2666
|
-
var _params$order_wait_pa,
|
|
2495
|
+
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
2496
|
+
var _params$order_wait_pa, _ref20, _tempOrder$is_price_i;
|
|
2667
2497
|
var snapshot, tempOrder, amount, walletBusinessData, result;
|
|
2668
|
-
return _regeneratorRuntime().wrap(function
|
|
2669
|
-
while (1) switch (
|
|
2498
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2499
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2670
2500
|
case 0:
|
|
2671
2501
|
if (this.store.order) {
|
|
2672
|
-
|
|
2502
|
+
_context25.next = 2;
|
|
2673
2503
|
break;
|
|
2674
2504
|
}
|
|
2675
2505
|
throw new Error('order 模块未初始化');
|
|
2676
2506
|
case 2:
|
|
2677
2507
|
if (this.store.payment) {
|
|
2678
|
-
|
|
2508
|
+
_context25.next = 4;
|
|
2679
2509
|
break;
|
|
2680
2510
|
}
|
|
2681
2511
|
throw new Error('payment 模块未初始化');
|
|
@@ -2684,10 +2514,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2684
2514
|
tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
|
|
2685
2515
|
amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
|
|
2686
2516
|
if (!(!tempOrder || !amount)) {
|
|
2687
|
-
|
|
2517
|
+
_context25.next = 9;
|
|
2688
2518
|
break;
|
|
2689
2519
|
}
|
|
2690
|
-
return
|
|
2520
|
+
return _context25.abrupt("return", {
|
|
2691
2521
|
walletRecommendList: [],
|
|
2692
2522
|
userIdentificationCodes: [],
|
|
2693
2523
|
transformList: [],
|
|
@@ -2706,15 +2536,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2706
2536
|
},
|
|
2707
2537
|
products: this.getWalletProductList(),
|
|
2708
2538
|
order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
|
|
2709
|
-
is_price_include_tax: (
|
|
2539
|
+
is_price_include_tax: (_ref20 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref20 !== void 0 ? _ref20 : 1
|
|
2710
2540
|
}, snapshot.identity.orderId ? {
|
|
2711
2541
|
payment_order_id: String(snapshot.identity.orderId)
|
|
2712
2542
|
} : {});
|
|
2713
|
-
|
|
2543
|
+
_context25.next = 12;
|
|
2714
2544
|
return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
2715
2545
|
case 12:
|
|
2716
|
-
result =
|
|
2717
|
-
|
|
2546
|
+
result = _context25.sent;
|
|
2547
|
+
_context25.next = 15;
|
|
2718
2548
|
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
2719
2549
|
orderId: snapshot.identity.orderId,
|
|
2720
2550
|
customerId: walletBusinessData.customer_id,
|
|
@@ -2726,12 +2556,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2726
2556
|
timestamp: Date.now()
|
|
2727
2557
|
});
|
|
2728
2558
|
case 15:
|
|
2729
|
-
return
|
|
2559
|
+
return _context25.abrupt("return", result);
|
|
2730
2560
|
case 16:
|
|
2731
2561
|
case "end":
|
|
2732
|
-
return
|
|
2562
|
+
return _context25.stop();
|
|
2733
2563
|
}
|
|
2734
|
-
},
|
|
2564
|
+
}, _callee25, this);
|
|
2735
2565
|
}));
|
|
2736
2566
|
function initWalletData(_x21) {
|
|
2737
2567
|
return _initWalletData.apply(this, arguments);
|
|
@@ -2760,35 +2590,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2760
2590
|
}, {
|
|
2761
2591
|
key: "getPaymentMethodsAsync",
|
|
2762
2592
|
value: (function () {
|
|
2763
|
-
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2593
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
2764
2594
|
var response, paymentMethods;
|
|
2765
|
-
return _regeneratorRuntime().wrap(function
|
|
2766
|
-
while (1) switch (
|
|
2595
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2596
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2767
2597
|
case 0:
|
|
2768
|
-
|
|
2769
|
-
|
|
2598
|
+
_context26.prev = 0;
|
|
2599
|
+
_context26.next = 3;
|
|
2770
2600
|
return this.request.get('/pay/custom-payment/all', {
|
|
2771
2601
|
filterPaymentMethods: true
|
|
2772
2602
|
}, {
|
|
2773
2603
|
osServer: true
|
|
2774
2604
|
});
|
|
2775
2605
|
case 3:
|
|
2776
|
-
response =
|
|
2606
|
+
response = _context26.sent;
|
|
2777
2607
|
paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
2778
2608
|
this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
|
|
2779
|
-
return
|
|
2609
|
+
return _context26.abrupt("return", this.getPaymentMethods());
|
|
2780
2610
|
case 9:
|
|
2781
|
-
|
|
2782
|
-
|
|
2611
|
+
_context26.prev = 9;
|
|
2612
|
+
_context26.t0 = _context26["catch"](0);
|
|
2783
2613
|
this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
|
|
2784
|
-
error:
|
|
2614
|
+
error: _context26.t0 instanceof Error ? _context26.t0.message : String(_context26.t0)
|
|
2785
2615
|
});
|
|
2786
|
-
return
|
|
2616
|
+
return _context26.abrupt("return", this.getPaymentMethods());
|
|
2787
2617
|
case 13:
|
|
2788
2618
|
case "end":
|
|
2789
|
-
return
|
|
2619
|
+
return _context26.stop();
|
|
2790
2620
|
}
|
|
2791
|
-
},
|
|
2621
|
+
}, _callee26, this, [[0, 9]]);
|
|
2792
2622
|
}));
|
|
2793
2623
|
function getPaymentMethodsAsync() {
|
|
2794
2624
|
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -2836,47 +2666,47 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2836
2666
|
}, {
|
|
2837
2667
|
key: "sendCustomerPayLink",
|
|
2838
2668
|
value: (function () {
|
|
2839
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2840
|
-
var orderIds,
|
|
2841
|
-
return _regeneratorRuntime().wrap(function
|
|
2842
|
-
while (1) switch (
|
|
2669
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
2670
|
+
var orderIds, _ref21, _ref22, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
2671
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2672
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2843
2673
|
case 0:
|
|
2844
2674
|
if (this.store.order) {
|
|
2845
|
-
|
|
2675
|
+
_context27.next = 2;
|
|
2846
2676
|
break;
|
|
2847
2677
|
}
|
|
2848
2678
|
throw new Error('order 模块未初始化');
|
|
2849
2679
|
case 2:
|
|
2850
2680
|
orderIds = params.order_ids || params.orderIds || [];
|
|
2851
2681
|
if (!(!orderIds.length || params.submitBeforeSend)) {
|
|
2852
|
-
|
|
2682
|
+
_context27.next = 11;
|
|
2853
2683
|
break;
|
|
2854
2684
|
}
|
|
2855
|
-
|
|
2685
|
+
_context27.next = 6;
|
|
2856
2686
|
return this.submitSalesOrder({
|
|
2857
2687
|
smallTicketDataFlag: 1
|
|
2858
2688
|
});
|
|
2859
2689
|
case 6:
|
|
2860
|
-
submitResult =
|
|
2861
|
-
orderId = (
|
|
2690
|
+
submitResult = _context27.sent;
|
|
2691
|
+
orderId = (_ref21 = (_ref22 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref22 !== void 0 ? _ref22 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref21 !== void 0 ? _ref21 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
2862
2692
|
if (orderId) {
|
|
2863
|
-
|
|
2693
|
+
_context27.next = 10;
|
|
2864
2694
|
break;
|
|
2865
2695
|
}
|
|
2866
2696
|
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
2867
2697
|
case 10:
|
|
2868
2698
|
orderIds = [orderId];
|
|
2869
2699
|
case 11:
|
|
2870
|
-
return
|
|
2700
|
+
return _context27.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
2871
2701
|
emails: params.emails,
|
|
2872
2702
|
notify_action: params.notify_action,
|
|
2873
2703
|
order_ids: orderIds
|
|
2874
2704
|
}));
|
|
2875
2705
|
case 12:
|
|
2876
2706
|
case "end":
|
|
2877
|
-
return
|
|
2707
|
+
return _context27.stop();
|
|
2878
2708
|
}
|
|
2879
|
-
},
|
|
2709
|
+
}, _callee27, this);
|
|
2880
2710
|
}));
|
|
2881
2711
|
function sendCustomerPayLink(_x22) {
|
|
2882
2712
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
@@ -2891,27 +2721,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2891
2721
|
}, {
|
|
2892
2722
|
key: "calculateProductBookingPrice",
|
|
2893
2723
|
value: function () {
|
|
2894
|
-
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2724
|
+
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
2895
2725
|
var _params$customer_id;
|
|
2896
2726
|
var quotation, customerId, authoritativeProduct, product;
|
|
2897
|
-
return _regeneratorRuntime().wrap(function
|
|
2898
|
-
while (1) switch (
|
|
2727
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2728
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2899
2729
|
case 0:
|
|
2900
2730
|
quotation = this.store.quotation;
|
|
2901
2731
|
customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
|
|
2902
|
-
|
|
2732
|
+
_context28.next = 4;
|
|
2903
2733
|
return this.loadProductForPriceQuery(params, customerId);
|
|
2904
2734
|
case 4:
|
|
2905
|
-
authoritativeProduct =
|
|
2735
|
+
authoritativeProduct = _context28.sent;
|
|
2906
2736
|
product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
2907
|
-
|
|
2737
|
+
_context28.next = 8;
|
|
2908
2738
|
return this.loadQuotationForPriceQuery({
|
|
2909
2739
|
quotation: quotation,
|
|
2910
2740
|
customer_id: customerId,
|
|
2911
2741
|
channel: params.channel
|
|
2912
2742
|
});
|
|
2913
2743
|
case 8:
|
|
2914
|
-
return
|
|
2744
|
+
return _context28.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
2915
2745
|
product: product,
|
|
2916
2746
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
2917
2747
|
customer_id: customerId,
|
|
@@ -2919,9 +2749,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2919
2749
|
})));
|
|
2920
2750
|
case 9:
|
|
2921
2751
|
case "end":
|
|
2922
|
-
return
|
|
2752
|
+
return _context28.stop();
|
|
2923
2753
|
}
|
|
2924
|
-
},
|
|
2754
|
+
}, _callee28, this);
|
|
2925
2755
|
}));
|
|
2926
2756
|
function calculateProductBookingPrice(_x23) {
|
|
2927
2757
|
return _calculateProductBookingPrice.apply(this, arguments);
|
|
@@ -2931,7 +2761,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2931
2761
|
}, {
|
|
2932
2762
|
key: "getQuotationCustomerScopeInfo",
|
|
2933
2763
|
value: function getQuotationCustomerScopeInfo() {
|
|
2934
|
-
var
|
|
2764
|
+
var _this9 = this;
|
|
2935
2765
|
var quotation = this.store.quotation;
|
|
2936
2766
|
if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
|
|
2937
2767
|
return quotation.getQuotationCustomerScopeInfo();
|
|
@@ -2943,7 +2773,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2943
2773
|
}).map(function (item) {
|
|
2944
2774
|
var localSeen = new Set();
|
|
2945
2775
|
var customers = item.customer.filter(function (customer) {
|
|
2946
|
-
var customerId =
|
|
2776
|
+
var customerId = _this9.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
|
|
2947
2777
|
if (!customerId || localSeen.has(customerId)) return false;
|
|
2948
2778
|
localSeen.add(customerId);
|
|
2949
2779
|
if (!customerById.has(customerId)) customerById.set(customerId, customer);
|
|
@@ -2993,32 +2823,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2993
2823
|
}, {
|
|
2994
2824
|
key: "calculateProductBookingPrices",
|
|
2995
2825
|
value: function () {
|
|
2996
|
-
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2826
|
+
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(paramsList) {
|
|
2997
2827
|
var _paramsList$0$custome,
|
|
2998
2828
|
_paramsList$,
|
|
2999
|
-
|
|
2829
|
+
_this10 = this,
|
|
3000
2830
|
_paramsList$2;
|
|
3001
2831
|
var quotation, customerId, productMapsByGroup, groups;
|
|
3002
|
-
return _regeneratorRuntime().wrap(function
|
|
3003
|
-
while (1) switch (
|
|
2832
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2833
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
3004
2834
|
case 0:
|
|
3005
2835
|
if (paramsList.length) {
|
|
3006
|
-
|
|
2836
|
+
_context30.next = 2;
|
|
3007
2837
|
break;
|
|
3008
2838
|
}
|
|
3009
|
-
return
|
|
2839
|
+
return _context30.abrupt("return", []);
|
|
3010
2840
|
case 2:
|
|
3011
2841
|
quotation = this.store.quotation;
|
|
3012
2842
|
customerId = (_paramsList$0$custome = (_paramsList$ = paramsList[0]) === null || _paramsList$ === void 0 ? void 0 : _paramsList$.customer_id) !== null && _paramsList$0$custome !== void 0 ? _paramsList$0$custome : this.getCurrentOrderCustomerId();
|
|
3013
2843
|
productMapsByGroup = new Map();
|
|
3014
2844
|
groups = new Map();
|
|
3015
2845
|
paramsList.forEach(function (params) {
|
|
3016
|
-
var
|
|
2846
|
+
var _this10$otherParams;
|
|
3017
2847
|
var product = params.product || {};
|
|
3018
|
-
var productId =
|
|
2848
|
+
var productId = _this10.getPriceQueryProductId(product);
|
|
3019
2849
|
if (productId === null) return;
|
|
3020
|
-
var schedule =
|
|
3021
|
-
var channel = params.channel || ((
|
|
2850
|
+
var schedule = _this10.getPriceQuerySchedule(params);
|
|
2851
|
+
var channel = params.channel || ((_this10$otherParams = _this10.otherParams) === null || _this10$otherParams === void 0 ? void 0 : _this10$otherParams.channel);
|
|
3022
2852
|
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
|
|
3023
2853
|
var group = groups.get(groupKey) || {
|
|
3024
2854
|
ids: new Set(),
|
|
@@ -3028,51 +2858,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3028
2858
|
group.ids.add(productId);
|
|
3029
2859
|
groups.set(groupKey, group);
|
|
3030
2860
|
});
|
|
3031
|
-
|
|
2861
|
+
_context30.next = 9;
|
|
3032
2862
|
return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
|
|
3033
|
-
var
|
|
3034
|
-
var
|
|
3035
|
-
return _regeneratorRuntime().wrap(function
|
|
3036
|
-
while (1) switch (
|
|
2863
|
+
var _ref24 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(_ref23) {
|
|
2864
|
+
var _ref25, groupKey, group, productsById;
|
|
2865
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2866
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
3037
2867
|
case 0:
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
return
|
|
2868
|
+
_ref25 = _slicedToArray(_ref23, 2), groupKey = _ref25[0], group = _ref25[1];
|
|
2869
|
+
_context29.next = 3;
|
|
2870
|
+
return _this10.loadProductsForPriceQuery({
|
|
3041
2871
|
ids: Array.from(group.ids),
|
|
3042
2872
|
schedule: group.schedule,
|
|
3043
2873
|
customerId: customerId,
|
|
3044
2874
|
channel: group.channel
|
|
3045
2875
|
});
|
|
3046
2876
|
case 3:
|
|
3047
|
-
productsById =
|
|
2877
|
+
productsById = _context29.sent;
|
|
3048
2878
|
productMapsByGroup.set(groupKey, productsById);
|
|
3049
2879
|
case 5:
|
|
3050
2880
|
case "end":
|
|
3051
|
-
return
|
|
2881
|
+
return _context29.stop();
|
|
3052
2882
|
}
|
|
3053
|
-
},
|
|
2883
|
+
}, _callee29);
|
|
3054
2884
|
}));
|
|
3055
2885
|
return function (_x25) {
|
|
3056
|
-
return
|
|
2886
|
+
return _ref24.apply(this, arguments);
|
|
3057
2887
|
};
|
|
3058
2888
|
}()));
|
|
3059
2889
|
case 9:
|
|
3060
|
-
|
|
2890
|
+
_context30.next = 11;
|
|
3061
2891
|
return this.loadQuotationForPriceQuery({
|
|
3062
2892
|
quotation: quotation,
|
|
3063
2893
|
customer_id: customerId,
|
|
3064
2894
|
channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
|
|
3065
2895
|
});
|
|
3066
2896
|
case 11:
|
|
3067
|
-
return
|
|
3068
|
-
var
|
|
2897
|
+
return _context30.abrupt("return", paramsList.map(function (params) {
|
|
2898
|
+
var _this10$otherParams2, _productMapsByGroup$g;
|
|
3069
2899
|
var productInput = params.product || {};
|
|
3070
|
-
var productId =
|
|
3071
|
-
var schedule =
|
|
3072
|
-
var channel = params.channel || ((
|
|
2900
|
+
var productId = _this10.getPriceQueryProductId(productInput);
|
|
2901
|
+
var schedule = _this10.getPriceQuerySchedule(params);
|
|
2902
|
+
var channel = params.channel || ((_this10$otherParams2 = _this10.otherParams) === null || _this10$otherParams2 === void 0 ? void 0 : _this10$otherParams2.channel);
|
|
3073
2903
|
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
|
|
3074
2904
|
var authoritativeProduct = productId === null ? null : ((_productMapsByGroup$g = productMapsByGroup.get(groupKey)) === null || _productMapsByGroup$g === void 0 ? void 0 : _productMapsByGroup$g.get(productId)) || null;
|
|
3075
|
-
var product =
|
|
2905
|
+
var product = _this10.mergeProductForPriceQuery(productInput, authoritativeProduct);
|
|
3076
2906
|
return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
3077
2907
|
product: product,
|
|
3078
2908
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
@@ -3082,9 +2912,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3082
2912
|
}));
|
|
3083
2913
|
case 12:
|
|
3084
2914
|
case "end":
|
|
3085
|
-
return
|
|
2915
|
+
return _context30.stop();
|
|
3086
2916
|
}
|
|
3087
|
-
},
|
|
2917
|
+
}, _callee30, this);
|
|
3088
2918
|
}));
|
|
3089
2919
|
function calculateProductBookingPrices(_x24) {
|
|
3090
2920
|
return _calculateProductBookingPrices.apply(this, arguments);
|
|
@@ -3094,7 +2924,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3094
2924
|
}, {
|
|
3095
2925
|
key: "addProductToOrder",
|
|
3096
2926
|
value: function () {
|
|
3097
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2927
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(product, booking) {
|
|
2928
|
+
var products;
|
|
2929
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2930
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2931
|
+
case 0:
|
|
2932
|
+
_context31.prev = 0;
|
|
2933
|
+
if (this.store.order) {
|
|
2934
|
+
_context31.next = 3;
|
|
2935
|
+
break;
|
|
2936
|
+
}
|
|
2937
|
+
throw new Error('order 模块未初始化');
|
|
2938
|
+
case 3:
|
|
2939
|
+
_context31.next = 5;
|
|
2940
|
+
return this.store.order.addProductToOrder(product, booking);
|
|
2941
|
+
case 5:
|
|
2942
|
+
products = _context31.sent;
|
|
2943
|
+
return _context31.abrupt("return", products);
|
|
2944
|
+
case 9:
|
|
2945
|
+
_context31.prev = 9;
|
|
2946
|
+
_context31.t0 = _context31["catch"](0);
|
|
2947
|
+
throw _context31.t0;
|
|
2948
|
+
case 12:
|
|
2949
|
+
case "end":
|
|
2950
|
+
return _context31.stop();
|
|
2951
|
+
}
|
|
2952
|
+
}, _callee31, this, [[0, 9]]);
|
|
2953
|
+
}));
|
|
2954
|
+
function addProductToOrder(_x26, _x27) {
|
|
2955
|
+
return _addProductToOrder.apply(this, arguments);
|
|
2956
|
+
}
|
|
2957
|
+
return addProductToOrder;
|
|
2958
|
+
}()
|
|
2959
|
+
}, {
|
|
2960
|
+
key: "updateOrderProduct",
|
|
2961
|
+
value: function () {
|
|
2962
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
3098
2963
|
var products;
|
|
3099
2964
|
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3100
2965
|
while (1) switch (_context32.prev = _context32.next) {
|
|
@@ -3107,7 +2972,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3107
2972
|
throw new Error('order 模块未初始化');
|
|
3108
2973
|
case 3:
|
|
3109
2974
|
_context32.next = 5;
|
|
3110
|
-
return this.store.order.
|
|
2975
|
+
return this.store.order.updateOrderProduct(params);
|
|
3111
2976
|
case 5:
|
|
3112
2977
|
products = _context32.sent;
|
|
3113
2978
|
return _context32.abrupt("return", products);
|
|
@@ -3121,15 +2986,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3121
2986
|
}
|
|
3122
2987
|
}, _callee32, this, [[0, 9]]);
|
|
3123
2988
|
}));
|
|
3124
|
-
function
|
|
3125
|
-
return
|
|
2989
|
+
function updateOrderProduct(_x28) {
|
|
2990
|
+
return _updateOrderProduct.apply(this, arguments);
|
|
3126
2991
|
}
|
|
3127
|
-
return
|
|
2992
|
+
return updateOrderProduct;
|
|
3128
2993
|
}()
|
|
3129
2994
|
}, {
|
|
3130
|
-
key: "
|
|
2995
|
+
key: "updateOrderProducts",
|
|
3131
2996
|
value: function () {
|
|
3132
|
-
var
|
|
2997
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(paramsList) {
|
|
3133
2998
|
var products;
|
|
3134
2999
|
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3135
3000
|
while (1) switch (_context33.prev = _context33.next) {
|
|
@@ -3142,7 +3007,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3142
3007
|
throw new Error('order 模块未初始化');
|
|
3143
3008
|
case 3:
|
|
3144
3009
|
_context33.next = 5;
|
|
3145
|
-
return this.store.order.
|
|
3010
|
+
return this.store.order.updateOrderProducts(paramsList);
|
|
3146
3011
|
case 5:
|
|
3147
3012
|
products = _context33.sent;
|
|
3148
3013
|
return _context33.abrupt("return", products);
|
|
@@ -3156,15 +3021,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3156
3021
|
}
|
|
3157
3022
|
}, _callee33, this, [[0, 9]]);
|
|
3158
3023
|
}));
|
|
3159
|
-
function
|
|
3160
|
-
return
|
|
3024
|
+
function updateOrderProducts(_x29) {
|
|
3025
|
+
return _updateOrderProducts.apply(this, arguments);
|
|
3161
3026
|
}
|
|
3162
|
-
return
|
|
3027
|
+
return updateOrderProducts;
|
|
3163
3028
|
}()
|
|
3164
3029
|
}, {
|
|
3165
|
-
key: "
|
|
3030
|
+
key: "updateOrderProductQuantity",
|
|
3166
3031
|
value: function () {
|
|
3167
|
-
var
|
|
3032
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
3168
3033
|
var products;
|
|
3169
3034
|
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3170
3035
|
while (1) switch (_context34.prev = _context34.next) {
|
|
@@ -3177,7 +3042,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3177
3042
|
throw new Error('order 模块未初始化');
|
|
3178
3043
|
case 3:
|
|
3179
3044
|
_context34.next = 5;
|
|
3180
|
-
return this.store.order.
|
|
3045
|
+
return this.store.order.updateOrderProductQuantity(params);
|
|
3181
3046
|
case 5:
|
|
3182
3047
|
products = _context34.sent;
|
|
3183
3048
|
return _context34.abrupt("return", products);
|
|
@@ -3191,41 +3056,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3191
3056
|
}
|
|
3192
3057
|
}, _callee34, this, [[0, 9]]);
|
|
3193
3058
|
}));
|
|
3194
|
-
function updateOrderProducts(_x29) {
|
|
3195
|
-
return _updateOrderProducts.apply(this, arguments);
|
|
3196
|
-
}
|
|
3197
|
-
return updateOrderProducts;
|
|
3198
|
-
}()
|
|
3199
|
-
}, {
|
|
3200
|
-
key: "updateOrderProductQuantity",
|
|
3201
|
-
value: function () {
|
|
3202
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
3203
|
-
var products;
|
|
3204
|
-
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3205
|
-
while (1) switch (_context35.prev = _context35.next) {
|
|
3206
|
-
case 0:
|
|
3207
|
-
_context35.prev = 0;
|
|
3208
|
-
if (this.store.order) {
|
|
3209
|
-
_context35.next = 3;
|
|
3210
|
-
break;
|
|
3211
|
-
}
|
|
3212
|
-
throw new Error('order 模块未初始化');
|
|
3213
|
-
case 3:
|
|
3214
|
-
_context35.next = 5;
|
|
3215
|
-
return this.store.order.updateOrderProductQuantity(params);
|
|
3216
|
-
case 5:
|
|
3217
|
-
products = _context35.sent;
|
|
3218
|
-
return _context35.abrupt("return", products);
|
|
3219
|
-
case 9:
|
|
3220
|
-
_context35.prev = 9;
|
|
3221
|
-
_context35.t0 = _context35["catch"](0);
|
|
3222
|
-
throw _context35.t0;
|
|
3223
|
-
case 12:
|
|
3224
|
-
case "end":
|
|
3225
|
-
return _context35.stop();
|
|
3226
|
-
}
|
|
3227
|
-
}, _callee35, this, [[0, 9]]);
|
|
3228
|
-
}));
|
|
3229
3059
|
function updateOrderProductQuantity(_x30) {
|
|
3230
3060
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
3231
3061
|
}
|
|
@@ -3249,12 +3079,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3249
3079
|
}, {
|
|
3250
3080
|
key: "setOrderProductLineNote",
|
|
3251
3081
|
value: (function () {
|
|
3252
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3082
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(identity, note) {
|
|
3253
3083
|
var params, products;
|
|
3254
|
-
return _regeneratorRuntime().wrap(function
|
|
3255
|
-
while (1) switch (
|
|
3084
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3085
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3256
3086
|
case 0:
|
|
3257
|
-
|
|
3087
|
+
_context35.prev = 0;
|
|
3258
3088
|
params = {
|
|
3259
3089
|
product_id: identity.product_id,
|
|
3260
3090
|
product_variant_id: identity.product_variant_id,
|
|
@@ -3269,20 +3099,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3269
3099
|
params.product_sku = identity.product_sku;
|
|
3270
3100
|
}
|
|
3271
3101
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
3272
|
-
|
|
3102
|
+
_context35.next = 7;
|
|
3273
3103
|
return this.updateOrderProduct(params);
|
|
3274
3104
|
case 7:
|
|
3275
|
-
products =
|
|
3276
|
-
return
|
|
3105
|
+
products = _context35.sent;
|
|
3106
|
+
return _context35.abrupt("return", products);
|
|
3277
3107
|
case 11:
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
throw
|
|
3108
|
+
_context35.prev = 11;
|
|
3109
|
+
_context35.t0 = _context35["catch"](0);
|
|
3110
|
+
throw _context35.t0;
|
|
3281
3111
|
case 14:
|
|
3282
3112
|
case "end":
|
|
3283
|
-
return
|
|
3113
|
+
return _context35.stop();
|
|
3284
3114
|
}
|
|
3285
|
-
},
|
|
3115
|
+
}, _callee35, this, [[0, 11]]);
|
|
3286
3116
|
}));
|
|
3287
3117
|
function setOrderProductLineNote(_x31, _x32) {
|
|
3288
3118
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
@@ -3299,30 +3129,30 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3299
3129
|
}, {
|
|
3300
3130
|
key: "removeProductsFromOrder",
|
|
3301
3131
|
value: (function () {
|
|
3302
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3303
|
-
return _regeneratorRuntime().wrap(function
|
|
3304
|
-
while (1) switch (
|
|
3132
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(identities) {
|
|
3133
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
3134
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3305
3135
|
case 0:
|
|
3306
|
-
|
|
3136
|
+
_context36.prev = 0;
|
|
3307
3137
|
if (this.store.order) {
|
|
3308
|
-
|
|
3138
|
+
_context36.next = 3;
|
|
3309
3139
|
break;
|
|
3310
3140
|
}
|
|
3311
3141
|
throw new Error('order 模块未初始化');
|
|
3312
3142
|
case 3:
|
|
3313
|
-
|
|
3143
|
+
_context36.next = 5;
|
|
3314
3144
|
return this.store.order.removeProductsFromOrder(identities);
|
|
3315
3145
|
case 5:
|
|
3316
|
-
return
|
|
3146
|
+
return _context36.abrupt("return", _context36.sent);
|
|
3317
3147
|
case 8:
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
throw
|
|
3148
|
+
_context36.prev = 8;
|
|
3149
|
+
_context36.t0 = _context36["catch"](0);
|
|
3150
|
+
throw _context36.t0;
|
|
3321
3151
|
case 11:
|
|
3322
3152
|
case "end":
|
|
3323
|
-
return
|
|
3153
|
+
return _context36.stop();
|
|
3324
3154
|
}
|
|
3325
|
-
},
|
|
3155
|
+
}, _callee36, this, [[0, 8]]);
|
|
3326
3156
|
}));
|
|
3327
3157
|
function removeProductsFromOrder(_x33) {
|
|
3328
3158
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
@@ -3332,16 +3162,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3332
3162
|
}, {
|
|
3333
3163
|
key: "removeProductFromOrder",
|
|
3334
3164
|
value: function () {
|
|
3335
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3336
|
-
return _regeneratorRuntime().wrap(function
|
|
3337
|
-
while (1) switch (
|
|
3165
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(identity) {
|
|
3166
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3167
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
3338
3168
|
case 0:
|
|
3339
|
-
return
|
|
3169
|
+
return _context37.abrupt("return", this.removeProductsFromOrder([identity]));
|
|
3340
3170
|
case 1:
|
|
3341
3171
|
case "end":
|
|
3342
|
-
return
|
|
3172
|
+
return _context37.stop();
|
|
3343
3173
|
}
|
|
3344
|
-
},
|
|
3174
|
+
}, _callee37, this);
|
|
3345
3175
|
}));
|
|
3346
3176
|
function removeProductFromOrder(_x34) {
|
|
3347
3177
|
return _removeProductFromOrder.apply(this, arguments);
|
|
@@ -3393,23 +3223,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3393
3223
|
}, {
|
|
3394
3224
|
key: "applyPromotion",
|
|
3395
3225
|
value: (function () {
|
|
3396
|
-
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3397
|
-
return _regeneratorRuntime().wrap(function
|
|
3398
|
-
while (1) switch (
|
|
3226
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
|
|
3227
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3228
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3399
3229
|
case 0:
|
|
3400
3230
|
if (this.store.order) {
|
|
3401
|
-
|
|
3231
|
+
_context38.next = 2;
|
|
3402
3232
|
break;
|
|
3403
3233
|
}
|
|
3404
3234
|
throw new Error('order 模块未初始化');
|
|
3405
3235
|
case 2:
|
|
3406
|
-
|
|
3236
|
+
_context38.next = 4;
|
|
3407
3237
|
return this.store.order.applyPromotion();
|
|
3408
3238
|
case 4:
|
|
3409
3239
|
case "end":
|
|
3410
|
-
return
|
|
3240
|
+
return _context38.stop();
|
|
3411
3241
|
}
|
|
3412
|
-
},
|
|
3242
|
+
}, _callee38, this);
|
|
3413
3243
|
}));
|
|
3414
3244
|
function applyPromotion() {
|
|
3415
3245
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -3436,18 +3266,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3436
3266
|
}, {
|
|
3437
3267
|
key: "getProductList",
|
|
3438
3268
|
value: function () {
|
|
3439
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3269
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
|
|
3440
3270
|
var _this$otherParams21;
|
|
3441
3271
|
var menu_list_ids, _this$store$products, res;
|
|
3442
|
-
return _regeneratorRuntime().wrap(function
|
|
3443
|
-
while (1) switch (
|
|
3272
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3273
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3444
3274
|
case 0:
|
|
3445
3275
|
// 可以直接通过配置里的 menu 读取
|
|
3446
3276
|
menu_list_ids = ((_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 || (_this$otherParams21 = _this$otherParams21.dineInConfig) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21['menu.associated_menus'].map(function (n) {
|
|
3447
3277
|
return Number(n.value);
|
|
3448
3278
|
})) || [];
|
|
3449
|
-
|
|
3450
|
-
|
|
3279
|
+
_context39.prev = 1;
|
|
3280
|
+
_context39.next = 4;
|
|
3451
3281
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
3452
3282
|
menu_list_ids: menu_list_ids,
|
|
3453
3283
|
cacheId: this.cacheId,
|
|
@@ -3455,17 +3285,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3455
3285
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
3456
3286
|
});
|
|
3457
3287
|
case 4:
|
|
3458
|
-
res =
|
|
3459
|
-
return
|
|
3288
|
+
res = _context39.sent;
|
|
3289
|
+
return _context39.abrupt("return", res);
|
|
3460
3290
|
case 8:
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
throw
|
|
3291
|
+
_context39.prev = 8;
|
|
3292
|
+
_context39.t0 = _context39["catch"](1);
|
|
3293
|
+
throw _context39.t0;
|
|
3464
3294
|
case 11:
|
|
3465
3295
|
case "end":
|
|
3466
|
-
return
|
|
3296
|
+
return _context39.stop();
|
|
3467
3297
|
}
|
|
3468
|
-
},
|
|
3298
|
+
}, _callee39, this, [[1, 8]]);
|
|
3469
3299
|
}));
|
|
3470
3300
|
function getProductList() {
|
|
3471
3301
|
return _getProductList.apply(this, arguments);
|
|
@@ -3480,31 +3310,31 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3480
3310
|
}, {
|
|
3481
3311
|
key: "setOtherParams",
|
|
3482
3312
|
value: function () {
|
|
3483
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3313
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
3484
3314
|
var _this$otherParams22;
|
|
3485
|
-
var
|
|
3486
|
-
|
|
3315
|
+
var _ref26,
|
|
3316
|
+
_ref26$cover,
|
|
3487
3317
|
cover,
|
|
3488
|
-
|
|
3489
|
-
return _regeneratorRuntime().wrap(function
|
|
3490
|
-
while (1) switch (
|
|
3318
|
+
_args40 = arguments;
|
|
3319
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3320
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3491
3321
|
case 0:
|
|
3492
|
-
|
|
3322
|
+
_ref26 = _args40.length > 1 && _args40[1] !== undefined ? _args40[1] : {}, _ref26$cover = _ref26.cover, cover = _ref26$cover === void 0 ? false : _ref26$cover;
|
|
3493
3323
|
if (cover) {
|
|
3494
3324
|
this.otherParams = _objectSpread({}, params);
|
|
3495
3325
|
} else {
|
|
3496
3326
|
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
3497
3327
|
}
|
|
3498
3328
|
this.cacheId = (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.cacheId;
|
|
3499
|
-
|
|
3329
|
+
_context40.next = 5;
|
|
3500
3330
|
return this.syncOtherParamsToSubModules(params, {
|
|
3501
3331
|
cover: cover
|
|
3502
3332
|
});
|
|
3503
3333
|
case 5:
|
|
3504
3334
|
case "end":
|
|
3505
|
-
return
|
|
3335
|
+
return _context40.stop();
|
|
3506
3336
|
}
|
|
3507
|
-
},
|
|
3337
|
+
}, _callee40, this);
|
|
3508
3338
|
}));
|
|
3509
3339
|
function setOtherParams(_x35) {
|
|
3510
3340
|
return _setOtherParams.apply(this, arguments);
|