@pisell/pisellos 0.0.496 → 0.0.498
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.
|
@@ -47,6 +47,7 @@ import { mergeConsecutiveSlots, expandMergedSlotToIndividual, buildVenueIdentity
|
|
|
47
47
|
import { createUuidV4 } from "../../modules/Order/utils";
|
|
48
48
|
import { OrderModule } from "../../modules/Order";
|
|
49
49
|
import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
|
|
50
|
+
import Decimal from 'decimal.js';
|
|
50
51
|
export * from "./types";
|
|
51
52
|
var OPEN_DATA_SECTION_CODES = ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow', 'checkout'];
|
|
52
53
|
function cloneCustomDepositData(customDepositData) {
|
|
@@ -1672,7 +1673,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1672
1673
|
key: "setDiscountSelected",
|
|
1673
1674
|
value: (function () {
|
|
1674
1675
|
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
1675
|
-
var _tempOrder$holder, _this$store$order$get, _this$store$order$get2, list, beforeTarget, updated, updatedTarget, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator7, _step7, d, afterApplyTarget, finalSummary, finalProduct, finalTarget;
|
|
1676
|
+
var _tempOrder$holder, _this$store$order$get, _this$store$order$get2, list, beforeTarget, updated, updatedTarget, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator7, _step7, d, selectedResourceIds, _iterator8, _step8, _product$discount_lis, product, before, totalDiscountAmount, newPaymentPrice, paymentStr, afterApplyTarget, finalSummary, finalProduct, finalTarget;
|
|
1676
1677
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1677
1678
|
while (1) switch (_context20.prev = _context20.next) {
|
|
1678
1679
|
case 0:
|
|
@@ -1748,21 +1749,73 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1748
1749
|
}
|
|
1749
1750
|
}
|
|
1750
1751
|
}
|
|
1752
|
+
selectedResourceIds = new Set(nextDiscountList.filter(function (d) {
|
|
1753
|
+
return d.isSelected;
|
|
1754
|
+
}).map(function (d) {
|
|
1755
|
+
return d.id;
|
|
1756
|
+
}));
|
|
1757
|
+
_iterator8 = _createForOfIteratorHelper(tempOrder.products);
|
|
1758
|
+
_context20.prev = 19;
|
|
1759
|
+
_iterator8.s();
|
|
1760
|
+
case 21:
|
|
1761
|
+
if ((_step8 = _iterator8.n()).done) {
|
|
1762
|
+
_context20.next = 30;
|
|
1763
|
+
break;
|
|
1764
|
+
}
|
|
1765
|
+
product = _step8.value;
|
|
1766
|
+
if ((_product$discount_lis = product.discount_list) !== null && _product$discount_lis !== void 0 && _product$discount_lis.length) {
|
|
1767
|
+
_context20.next = 25;
|
|
1768
|
+
break;
|
|
1769
|
+
}
|
|
1770
|
+
return _context20.abrupt("continue", 28);
|
|
1771
|
+
case 25:
|
|
1772
|
+
before = product.discount_list.length;
|
|
1773
|
+
product.discount_list = product.discount_list.filter(function (pd) {
|
|
1774
|
+
var _pd$discount$resource, _pd$discount;
|
|
1775
|
+
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;
|
|
1776
|
+
return rid != null && selectedResourceIds.has(rid);
|
|
1777
|
+
});
|
|
1778
|
+
if (product.discount_list.length < before) {
|
|
1779
|
+
totalDiscountAmount = product.discount_list.reduce(function (sum, pd) {
|
|
1780
|
+
return sum + (pd.amount || 0);
|
|
1781
|
+
}, 0);
|
|
1782
|
+
newPaymentPrice = new Decimal(product.selling_price || 0).minus(totalDiscountAmount).toNumber();
|
|
1783
|
+
paymentStr = toPriceString(newPaymentPrice);
|
|
1784
|
+
product.payment_price = paymentStr;
|
|
1785
|
+
if (product.metadata) {
|
|
1786
|
+
product.metadata.main_product_selling_price = paymentStr;
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
case 28:
|
|
1790
|
+
_context20.next = 21;
|
|
1791
|
+
break;
|
|
1792
|
+
case 30:
|
|
1793
|
+
_context20.next = 35;
|
|
1794
|
+
break;
|
|
1795
|
+
case 32:
|
|
1796
|
+
_context20.prev = 32;
|
|
1797
|
+
_context20.t0 = _context20["catch"](19);
|
|
1798
|
+
_iterator8.e(_context20.t0);
|
|
1799
|
+
case 35:
|
|
1800
|
+
_context20.prev = 35;
|
|
1801
|
+
_iterator8.f();
|
|
1802
|
+
return _context20.finish(35);
|
|
1803
|
+
case 38:
|
|
1751
1804
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1752
|
-
_context20.next =
|
|
1805
|
+
_context20.next = 41;
|
|
1753
1806
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1754
|
-
case
|
|
1807
|
+
case 41:
|
|
1755
1808
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
1756
1809
|
return d.isSelected;
|
|
1757
1810
|
});
|
|
1758
1811
|
afterApplyTarget = this.store.order.getDiscountList().find(function (d) {
|
|
1759
1812
|
return d.id === params.discountId;
|
|
1760
1813
|
}) || null;
|
|
1761
|
-
_context20.next =
|
|
1814
|
+
_context20.next = 45;
|
|
1762
1815
|
return this.store.order.recalculateSummary({
|
|
1763
1816
|
createIfMissing: true
|
|
1764
1817
|
});
|
|
1765
|
-
case
|
|
1818
|
+
case 45:
|
|
1766
1819
|
this.store.order.persistTempOrder();
|
|
1767
1820
|
finalSummary = ((_this$store$order$get = this.store.order.getTempOrder()) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.summary) || null;
|
|
1768
1821
|
finalProduct = ((_this$store$order$get2 = this.store.order.getTempOrder()) === null || _this$store$order$get2 === void 0 || (_this$store$order$get2 = _this$store$order$get2.products) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2[0]) || null;
|
|
@@ -1771,16 +1824,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1771
1824
|
return d.id === params.discountId;
|
|
1772
1825
|
}) || null;
|
|
1773
1826
|
return _context20.abrupt("return", this.store.order.getDiscountList());
|
|
1774
|
-
case
|
|
1775
|
-
_context20.prev =
|
|
1776
|
-
_context20.
|
|
1777
|
-
this.logMethodError('setDiscountSelected', _context20.
|
|
1778
|
-
throw _context20.
|
|
1779
|
-
case
|
|
1827
|
+
case 53:
|
|
1828
|
+
_context20.prev = 53;
|
|
1829
|
+
_context20.t1 = _context20["catch"](1);
|
|
1830
|
+
this.logMethodError('setDiscountSelected', _context20.t1);
|
|
1831
|
+
throw _context20.t1;
|
|
1832
|
+
case 57:
|
|
1780
1833
|
case "end":
|
|
1781
1834
|
return _context20.stop();
|
|
1782
1835
|
}
|
|
1783
|
-
}, _callee20, this, [[1, 32]]);
|
|
1836
|
+
}, _callee20, this, [[1, 53], [19, 32, 35, 38]]);
|
|
1784
1837
|
}));
|
|
1785
1838
|
function setDiscountSelected(_x14) {
|
|
1786
1839
|
return _setDiscountSelected.apply(this, arguments);
|
|
@@ -2254,17 +2307,17 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2254
2307
|
if (visited.has(value)) return;
|
|
2255
2308
|
visited.add(value);
|
|
2256
2309
|
if (Array.isArray(value)) {
|
|
2257
|
-
var
|
|
2258
|
-
|
|
2310
|
+
var _iterator9 = _createForOfIteratorHelper(value),
|
|
2311
|
+
_step9;
|
|
2259
2312
|
try {
|
|
2260
|
-
for (
|
|
2261
|
-
var item =
|
|
2313
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
2314
|
+
var item = _step9.value;
|
|
2262
2315
|
collectFromValue(item);
|
|
2263
2316
|
}
|
|
2264
2317
|
} catch (err) {
|
|
2265
|
-
|
|
2318
|
+
_iterator9.e(err);
|
|
2266
2319
|
} finally {
|
|
2267
|
-
|
|
2320
|
+
_iterator9.f();
|
|
2268
2321
|
}
|
|
2269
2322
|
return;
|
|
2270
2323
|
}
|
|
@@ -2419,7 +2472,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2419
2472
|
key: "applyPrefillByItemRule",
|
|
2420
2473
|
value: function () {
|
|
2421
2474
|
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
|
|
2422
|
-
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges,
|
|
2475
|
+
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator10, _step10, _prefillItem$product_, _targetProduct$_origi, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, _ref5, _sourceItem$original_, _ref6, _sourceItem$payment_p, sellingPrice, originalPrice, paymentPrice, targetProduct, existedQuantity, delta, nextProduct;
|
|
2423
2476
|
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2424
2477
|
while (1) switch (_context35.prev = _context35.next) {
|
|
2425
2478
|
case 0:
|
|
@@ -2464,15 +2517,15 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2464
2517
|
productSourceMap = _context35.sent;
|
|
2465
2518
|
tempOrder = this.ensureTempOrder();
|
|
2466
2519
|
hasChanges = false;
|
|
2467
|
-
|
|
2520
|
+
_iterator10 = _createForOfIteratorHelper(prefillItems);
|
|
2468
2521
|
_context35.prev = 20;
|
|
2469
|
-
|
|
2522
|
+
_iterator10.s();
|
|
2470
2523
|
case 22:
|
|
2471
|
-
if ((
|
|
2524
|
+
if ((_step10 = _iterator10.n()).done) {
|
|
2472
2525
|
_context35.next = 47;
|
|
2473
2526
|
break;
|
|
2474
2527
|
}
|
|
2475
|
-
prefillItem =
|
|
2528
|
+
prefillItem = _step10.value;
|
|
2476
2529
|
productId = Number(prefillItem.product_id);
|
|
2477
2530
|
productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
|
|
2478
2531
|
targetQuantity = toNonNegativeInt(prefillItem.quantity);
|
|
@@ -2544,10 +2597,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2544
2597
|
case 49:
|
|
2545
2598
|
_context35.prev = 49;
|
|
2546
2599
|
_context35.t0 = _context35["catch"](20);
|
|
2547
|
-
|
|
2600
|
+
_iterator10.e(_context35.t0);
|
|
2548
2601
|
case 52:
|
|
2549
2602
|
_context35.prev = 52;
|
|
2550
|
-
|
|
2603
|
+
_iterator10.f();
|
|
2551
2604
|
return _context35.finish(52);
|
|
2552
2605
|
case 55:
|
|
2553
2606
|
if (!hasChanges) {
|
|
@@ -226,7 +226,7 @@ export function buildTimeSlotGrid(params) {
|
|
|
226
226
|
resources.push({
|
|
227
227
|
resourceId: resource.resourceId,
|
|
228
228
|
resourceFormId: resource.formId,
|
|
229
|
-
resourceName: mapping.resourceName,
|
|
229
|
+
resourceName: resource.main_field || mapping.resourceName,
|
|
230
230
|
productId: mapping.productId,
|
|
231
231
|
productTitle: mapping.productTitle,
|
|
232
232
|
slots: slots
|
|
@@ -52,6 +52,7 @@ var import_slotMerge = require("./utils/slotMerge");
|
|
|
52
52
|
var import_utils2 = require("../../modules/Order/utils");
|
|
53
53
|
var import_Order = require("../../modules/Order");
|
|
54
54
|
var import_types4 = require("../RegisterAndLogin/types");
|
|
55
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
55
56
|
__reExport(VenueBooking_exports, require("./types"), module.exports);
|
|
56
57
|
var OPEN_DATA_SECTION_CODES = [
|
|
57
58
|
"basic",
|
|
@@ -1015,7 +1016,7 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1015
1016
|
}
|
|
1016
1017
|
/** 勾选/取消勾选某张折扣券,重新计算折扣并持久化 */
|
|
1017
1018
|
async setDiscountSelected(params) {
|
|
1018
|
-
var _a, _b, _c, _d, _e;
|
|
1019
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1019
1020
|
this.logMethodStart("setDiscountSelected", params);
|
|
1020
1021
|
try {
|
|
1021
1022
|
if (!this.store.order)
|
|
@@ -1067,14 +1068,39 @@ var VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1067
1068
|
}
|
|
1068
1069
|
}
|
|
1069
1070
|
}
|
|
1071
|
+
const selectedResourceIds = new Set(
|
|
1072
|
+
nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
|
|
1073
|
+
);
|
|
1074
|
+
for (const product of tempOrder.products) {
|
|
1075
|
+
if (!((_c = product.discount_list) == null ? void 0 : _c.length))
|
|
1076
|
+
continue;
|
|
1077
|
+
const before = product.discount_list.length;
|
|
1078
|
+
product.discount_list = product.discount_list.filter((pd) => {
|
|
1079
|
+
var _a2;
|
|
1080
|
+
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
1081
|
+
return rid != null && selectedResourceIds.has(rid);
|
|
1082
|
+
});
|
|
1083
|
+
if (product.discount_list.length < before) {
|
|
1084
|
+
const totalDiscountAmount = product.discount_list.reduce(
|
|
1085
|
+
(sum, pd) => sum + (pd.amount || 0),
|
|
1086
|
+
0
|
|
1087
|
+
);
|
|
1088
|
+
const newPaymentPrice = new import_decimal.default(product.selling_price || 0).minus(totalDiscountAmount).toNumber();
|
|
1089
|
+
const paymentStr = (0, import_utils.toPriceString)(newPaymentPrice);
|
|
1090
|
+
product.payment_price = paymentStr;
|
|
1091
|
+
if (product.metadata) {
|
|
1092
|
+
product.metadata.main_product_selling_price = paymentStr;
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1070
1096
|
import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1071
1097
|
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
1072
1098
|
tempOrder.discount_list = (nextDiscountList || []).filter((d) => d.isSelected);
|
|
1073
1099
|
const afterApplyTarget = this.store.order.getDiscountList().find((d) => d.id === params.discountId) || null;
|
|
1074
1100
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1075
1101
|
this.store.order.persistTempOrder();
|
|
1076
|
-
const finalSummary = ((
|
|
1077
|
-
const finalProduct = ((
|
|
1102
|
+
const finalSummary = ((_d = this.store.order.getTempOrder()) == null ? void 0 : _d.summary) || null;
|
|
1103
|
+
const finalProduct = ((_f = (_e = this.store.order.getTempOrder()) == null ? void 0 : _e.products) == null ? void 0 : _f[0]) || null;
|
|
1078
1104
|
this.logMethodSuccess("setDiscountSelected", params);
|
|
1079
1105
|
const finalTarget = this.store.order.getDiscountList().find((d) => d.id === params.discountId) || null;
|
|
1080
1106
|
return this.store.order.getDiscountList();
|
|
@@ -175,7 +175,7 @@ function buildTimeSlotGrid(params) {
|
|
|
175
175
|
resources.push({
|
|
176
176
|
resourceId: resource.resourceId,
|
|
177
177
|
resourceFormId: resource.formId,
|
|
178
|
-
resourceName: mapping.resourceName,
|
|
178
|
+
resourceName: resource.main_field || mapping.resourceName,
|
|
179
179
|
productId: mapping.productId,
|
|
180
180
|
productTitle: mapping.productTitle,
|
|
181
181
|
slots
|