@pisell/pisellos 2.2.259 → 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 +1 -32
- package/dist/modules/Order/index.js +288 -615
- 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/modules/SalesSummary/index.d.ts +3 -7
- package/dist/modules/SalesSummary/index.js +39 -67
- package/dist/modules/SalesSummary/types.d.ts +0 -1
- package/dist/modules/SalesSummary/utils.js +1 -2
- package/dist/modules/SurchargeList/index.d.ts +4 -6
- package/dist/modules/SurchargeList/index.js +39 -62
- package/dist/modules/SurchargeList/types.d.ts +2 -6
- package/dist/server/index.d.ts +50 -3
- package/dist/server/index.js +1040 -1075
- package/dist/server/modules/order/index.d.ts +3 -22
- package/dist/server/modules/order/index.js +316 -398
- 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 -22
- package/dist/solution/BaseSales/index.js +701 -995
- package/dist/solution/BaseSales/types.d.ts +0 -1
- package/dist/solution/BaseSales/types.js +1 -2
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -6
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +0 -8
- package/dist/solution/BookingTicket/index.js +6 -153
- 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/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -11
- package/lib/modules/Order/index.d.ts +1 -32
- package/lib/modules/Order/index.js +64 -402
- 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/modules/SalesSummary/index.d.ts +3 -7
- package/lib/modules/SalesSummary/index.js +11 -28
- package/lib/modules/SalesSummary/types.d.ts +0 -1
- package/lib/modules/SalesSummary/utils.js +0 -2
- package/lib/modules/SurchargeList/index.d.ts +4 -6
- package/lib/modules/SurchargeList/index.js +21 -41
- package/lib/modules/SurchargeList/types.d.ts +2 -6
- package/lib/server/index.d.ts +50 -3
- package/lib/server/index.js +215 -244
- package/lib/server/modules/order/index.d.ts +3 -22
- package/lib/server/modules/order/index.js +53 -103
- 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 -22
- package/lib/solution/BaseSales/index.js +60 -246
- package/lib/solution/BaseSales/types.d.ts +0 -1
- package/lib/solution/BaseSales/types.js +1 -2
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +0 -8
- package/lib/solution/BookingTicket/index.js +0 -101
- 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
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 1 | 2 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -551,14 +551,6 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
551
551
|
setOtherParams(params: Record<string, any>, { cover }?: {
|
|
552
552
|
cover?: boolean;
|
|
553
553
|
}): Promise<void>;
|
|
554
|
-
private getDeviceTaskPlugin;
|
|
555
|
-
handlePrintWristband(params: {
|
|
556
|
-
voucher_ids: number[];
|
|
557
|
-
}): Promise<void>;
|
|
558
|
-
handleRedeem(params: {
|
|
559
|
-
voucher_ids: number[];
|
|
560
|
-
is_checkin: boolean;
|
|
561
|
-
}): Promise<any>;
|
|
562
554
|
/**
|
|
563
555
|
* 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
|
|
564
556
|
* 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
|
|
@@ -52,7 +52,6 @@ var import_buildNormalProductCacheItemFromOrderLine = require("../../modules/Boo
|
|
|
52
52
|
var import_orderLineDisplay = require("../../modules/BookingContext/utils/orderLineDisplay");
|
|
53
53
|
var import_bookingStatus = require("./utils/bookingStatus");
|
|
54
54
|
var import_resolveBestAddTimePlan = require("./utils/resolveBestAddTimePlan");
|
|
55
|
-
var import_utils = require("../../modules/Order/utils");
|
|
56
55
|
__reExport(BookingTicket_exports, require("./types"), module.exports);
|
|
57
56
|
var OPEN_DATA_SECTION_CODES = ["sale", "reservation", "fulfillment", "menu", "workflow"];
|
|
58
57
|
var OPEN_DATA_CACHE_TTL = 5 * 60 * 1e3;
|
|
@@ -1506,106 +1505,6 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1506
1505
|
await this.configureIdGeneratorFromOpenData();
|
|
1507
1506
|
}
|
|
1508
1507
|
}
|
|
1509
|
-
getDeviceTaskPlugin() {
|
|
1510
|
-
var _a;
|
|
1511
|
-
const app = this.core.getPlugin("app");
|
|
1512
|
-
return ((_a = app == null ? void 0 : app.getApp()) == null ? void 0 : _a.getPlugin("deviceTask")) || null;
|
|
1513
|
-
}
|
|
1514
|
-
// 打印手环,单个或批量都可以
|
|
1515
|
-
async handlePrintWristband(params) {
|
|
1516
|
-
var _a;
|
|
1517
|
-
const deviceTask = this.getDeviceTaskPlugin();
|
|
1518
|
-
if (!(deviceTask == null ? void 0 : deviceTask.dispatch)) {
|
|
1519
|
-
this.logger.addLog({
|
|
1520
|
-
type: "info",
|
|
1521
|
-
title: "[BookingTicket] handlePrintWristband: deviceTask.dispatch 不可用",
|
|
1522
|
-
metadata: {
|
|
1523
|
-
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
1524
|
-
}
|
|
1525
|
-
});
|
|
1526
|
-
return;
|
|
1527
|
-
}
|
|
1528
|
-
this.logger.addLog({
|
|
1529
|
-
type: "info",
|
|
1530
|
-
title: "[BookingTicket] handlePrintWristband",
|
|
1531
|
-
metadata: {
|
|
1532
|
-
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
1533
|
-
}
|
|
1534
|
-
});
|
|
1535
|
-
const deviceId = await this.getShortNumberOrDeviceId();
|
|
1536
|
-
const idempotencyKey = (0, import_utils.createUuidV4)();
|
|
1537
|
-
deviceTask.dispatch({
|
|
1538
|
-
action: "print_all",
|
|
1539
|
-
device_id: deviceId,
|
|
1540
|
-
payload: {
|
|
1541
|
-
type: "WRISTBAND",
|
|
1542
|
-
data: {
|
|
1543
|
-
order_id: (_a = this.getOrderIdentity()) == null ? void 0 : _a.orderId,
|
|
1544
|
-
voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
|
|
1545
|
-
}
|
|
1546
|
-
},
|
|
1547
|
-
idempotency_key: idempotencyKey,
|
|
1548
|
-
name: "PRINT_WRISTBAND",
|
|
1549
|
-
source: "bookingTicket",
|
|
1550
|
-
source_type: "handlePrintWristband",
|
|
1551
|
-
source_id: idempotencyKey
|
|
1552
|
-
});
|
|
1553
|
-
}
|
|
1554
|
-
// 触发核销
|
|
1555
|
-
async handleRedeem(params) {
|
|
1556
|
-
var _a, _b, _c;
|
|
1557
|
-
const voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
|
|
1558
|
-
const status = params.is_checkin ? "used" : "unused";
|
|
1559
|
-
this.logger.addLog({
|
|
1560
|
-
type: "info",
|
|
1561
|
-
title: "[BookingTicket] handleRedeem",
|
|
1562
|
-
metadata: {
|
|
1563
|
-
voucher_ids: voucherIds,
|
|
1564
|
-
status
|
|
1565
|
-
}
|
|
1566
|
-
});
|
|
1567
|
-
const voucherIdSet = new Set(voucherIds);
|
|
1568
|
-
const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
|
|
1569
|
-
const vouchers = (tempOrder == null ? void 0 : tempOrder.vouchers) || ((_c = this.store.order) == null ? void 0 : _c.getVouchers()) || [];
|
|
1570
|
-
let hasUpdatedVoucher = false;
|
|
1571
|
-
const nextVouchers = vouchers.map((voucher) => {
|
|
1572
|
-
if (!voucherIdSet.has(voucher.voucher_id))
|
|
1573
|
-
return voucher;
|
|
1574
|
-
hasUpdatedVoucher = true;
|
|
1575
|
-
return {
|
|
1576
|
-
...voucher,
|
|
1577
|
-
status
|
|
1578
|
-
};
|
|
1579
|
-
});
|
|
1580
|
-
if (tempOrder && hasUpdatedVoucher) {
|
|
1581
|
-
await this.replaceTempOrder({
|
|
1582
|
-
...tempOrder,
|
|
1583
|
-
vouchers: nextVouchers
|
|
1584
|
-
});
|
|
1585
|
-
}
|
|
1586
|
-
this.core.effects.emit(`${this.name}:onVouchersChange`, {});
|
|
1587
|
-
if (voucherIds.length === 0) {
|
|
1588
|
-
return {
|
|
1589
|
-
code: 200,
|
|
1590
|
-
status: true,
|
|
1591
|
-
message: "",
|
|
1592
|
-
data: []
|
|
1593
|
-
};
|
|
1594
|
-
}
|
|
1595
|
-
const identity = this.getOrderIdentity();
|
|
1596
|
-
const externalSaleNumber = (tempOrder == null ? void 0 : tempOrder.external_sale_number) || (identity == null ? void 0 : identity.externalSaleNumber) || void 0;
|
|
1597
|
-
const orderId = (tempOrder == null ? void 0 : tempOrder.order_id) ?? (identity == null ? void 0 : identity.orderId) ?? void 0;
|
|
1598
|
-
const orderLookup = externalSaleNumber || orderId || (identity == null ? void 0 : identity.orderNumber) || (identity == null ? void 0 : identity.shopOrderNumber) || (identity == null ? void 0 : identity.shopFullOrderNumber) || void 0;
|
|
1599
|
-
return this.request.post("/machinecode/batch", {
|
|
1600
|
-
ids: voucherIds,
|
|
1601
|
-
status,
|
|
1602
|
-
order_lookup: orderLookup,
|
|
1603
|
-
order_id: orderId,
|
|
1604
|
-
external_sale_number: externalSaleNumber
|
|
1605
|
-
}, {
|
|
1606
|
-
osServer: true
|
|
1607
|
-
});
|
|
1608
|
-
}
|
|
1609
1508
|
/**
|
|
1610
1509
|
* 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
|
|
1611
1510
|
* 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { OrderProductDiscountItem } from '../types';
|
|
2
|
-
type NormalizeDiscountList = (discountList?: unknown[] | null) => OrderProductDiscountItem[];
|
|
3
|
-
export declare function restoreHydratedBundleDiscounts<T extends Record<string, any>>(product: T, normalizeDiscountList: NormalizeDiscountList): T;
|
|
4
|
-
export declare function expandHydratedProductsForDiscountCollection(products: any[] | undefined | null): any[];
|
|
5
|
-
export {};
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
14
|
-
var BUNDLE_MAP_ID_KEY = 'custom_product_bundle_map_id';
|
|
15
|
-
function getBundleMapId(bundle) {
|
|
16
|
-
var _bundle$metadata;
|
|
17
|
-
var metadataMapId = bundle === null || bundle === void 0 || (_bundle$metadata = bundle.metadata) === null || _bundle$metadata === void 0 ? void 0 : _bundle$metadata[BUNDLE_MAP_ID_KEY];
|
|
18
|
-
if (metadataMapId !== undefined && metadataMapId !== null && metadataMapId !== '') {
|
|
19
|
-
return String(metadataMapId);
|
|
20
|
-
}
|
|
21
|
-
if ((bundle === null || bundle === void 0 ? void 0 : bundle._id) !== undefined && bundle._id !== null && bundle._id !== '') {
|
|
22
|
-
return String(bundle._id);
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
function getDiscountBundleMapId(discount) {
|
|
27
|
-
var _discount$metadata;
|
|
28
|
-
var mapId = discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata[BUNDLE_MAP_ID_KEY];
|
|
29
|
-
if (mapId === undefined || mapId === null || mapId === '') return null;
|
|
30
|
-
return String(mapId);
|
|
31
|
-
}
|
|
32
|
-
function hasSameBundleDiscount(discountList, discount) {
|
|
33
|
-
var _ref, _discount$discount$re, _discount$discount;
|
|
34
|
-
var targetOrderDiscountId = discount.order_discount_id;
|
|
35
|
-
if (targetOrderDiscountId !== undefined && targetOrderDiscountId !== null) {
|
|
36
|
-
return discountList.some(function (item) {
|
|
37
|
-
return (item === null || item === void 0 ? void 0 : item.order_discount_id) === targetOrderDiscountId;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
var targetResourceId = (_ref = (_discount$discount$re = discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _discount$discount$re !== void 0 ? _discount$discount$re : discount === null || discount === void 0 ? void 0 : discount.resource_id) !== null && _ref !== void 0 ? _ref : discount === null || discount === void 0 ? void 0 : discount.discount_id;
|
|
41
|
-
var targetMapId = getDiscountBundleMapId(discount);
|
|
42
|
-
return discountList.some(function (item) {
|
|
43
|
-
var _ref2, _item$discount$resour, _item$discount, _item$amount, _discount$amount;
|
|
44
|
-
var resourceId = (_ref2 = (_item$discount$resour = item === null || item === void 0 || (_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id) !== null && _item$discount$resour !== void 0 ? _item$discount$resour : item === null || item === void 0 ? void 0 : item.resource_id) !== null && _ref2 !== void 0 ? _ref2 : item === null || item === void 0 ? void 0 : item.discount_id;
|
|
45
|
-
return resourceId === targetResourceId && String((_item$amount = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount !== void 0 ? _item$amount : '') === String((_discount$amount = discount === null || discount === void 0 ? void 0 : discount.amount) !== null && _discount$amount !== void 0 ? _discount$amount : '') && getDiscountBundleMapId(item) === targetMapId;
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
export function restoreHydratedBundleDiscounts(product, normalizeDiscountList) {
|
|
49
|
-
if (!Array.isArray(product.product_bundle) || !Array.isArray(product.discount_list)) {
|
|
50
|
-
return product;
|
|
51
|
-
}
|
|
52
|
-
var bundleByMapId = new Map();
|
|
53
|
-
product.product_bundle.forEach(function (bundle) {
|
|
54
|
-
if (!bundle || _typeof(bundle) !== 'object') return;
|
|
55
|
-
var mapId = getBundleMapId(bundle);
|
|
56
|
-
if (mapId) bundleByMapId.set(mapId, bundle);
|
|
57
|
-
});
|
|
58
|
-
if (!bundleByMapId.size) return product;
|
|
59
|
-
var mainDiscountList = [];
|
|
60
|
-
var bundleDiscounts = [];
|
|
61
|
-
product.discount_list.forEach(function (discount) {
|
|
62
|
-
var mapId = getDiscountBundleMapId(discount);
|
|
63
|
-
if (mapId && bundleByMapId.has(mapId)) {
|
|
64
|
-
bundleDiscounts.push({
|
|
65
|
-
mapId: mapId,
|
|
66
|
-
discount: discount
|
|
67
|
-
});
|
|
68
|
-
} else {
|
|
69
|
-
mainDiscountList.push(discount);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
if (!bundleDiscounts.length) return product;
|
|
73
|
-
return _objectSpread(_objectSpread({}, product), {}, {
|
|
74
|
-
discount_list: normalizeDiscountList(mainDiscountList),
|
|
75
|
-
product_bundle: product.product_bundle.map(function (bundle) {
|
|
76
|
-
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
77
|
-
var mapId = getBundleMapId(bundle);
|
|
78
|
-
if (!mapId) return bundle;
|
|
79
|
-
var matchedDiscounts = bundleDiscounts.filter(function (item) {
|
|
80
|
-
return item.mapId === mapId;
|
|
81
|
-
}).map(function (item) {
|
|
82
|
-
return item.discount;
|
|
83
|
-
});
|
|
84
|
-
if (!matchedDiscounts.length) return bundle;
|
|
85
|
-
var currentDiscountList = Array.isArray(bundle.discount_list) ? _toConsumableArray(bundle.discount_list) : [];
|
|
86
|
-
var _iterator = _createForOfIteratorHelper(matchedDiscounts),
|
|
87
|
-
_step;
|
|
88
|
-
try {
|
|
89
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
90
|
-
var discount = _step.value;
|
|
91
|
-
if (!hasSameBundleDiscount(currentDiscountList, discount)) {
|
|
92
|
-
currentDiscountList.push(discount);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
} catch (err) {
|
|
96
|
-
_iterator.e(err);
|
|
97
|
-
} finally {
|
|
98
|
-
_iterator.f();
|
|
99
|
-
}
|
|
100
|
-
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
101
|
-
discount_list: normalizeDiscountList(currentDiscountList),
|
|
102
|
-
metadata: _objectSpread(_objectSpread({}, bundle.metadata || {}), {}, _defineProperty({}, BUNDLE_MAP_ID_KEY, mapId))
|
|
103
|
-
});
|
|
104
|
-
})
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
export function expandHydratedProductsForDiscountCollection(products) {
|
|
108
|
-
var expanded = [];
|
|
109
|
-
var _iterator2 = _createForOfIteratorHelper(products || []),
|
|
110
|
-
_step2;
|
|
111
|
-
try {
|
|
112
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
113
|
-
var product = _step2.value;
|
|
114
|
-
expanded.push(product);
|
|
115
|
-
var _iterator3 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
|
|
116
|
-
_step3;
|
|
117
|
-
try {
|
|
118
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
119
|
-
var _ref3, _ref4, _bundle$bundle_produc, _ref5, _bundle$num, _ref6, _bundle$quantity, _ref7, _bundle$original_pric, _bundle$bundle_sellin, _bundle$is_charge_tax;
|
|
120
|
-
var bundle = _step3.value;
|
|
121
|
-
if (!Array.isArray(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || bundle.discount_list.length === 0) continue;
|
|
122
|
-
expanded.push(_objectSpread(_objectSpread({}, product), {}, {
|
|
123
|
-
product_id: (_ref3 = (_ref4 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref4 !== void 0 ? _ref4 : bundle.product_id) !== null && _ref3 !== void 0 ? _ref3 : product === null || product === void 0 ? void 0 : product.product_id,
|
|
124
|
-
num: (_ref5 = (_bundle$num = bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle.quantity) !== null && _ref5 !== void 0 ? _ref5 : product === null || product === void 0 ? void 0 : product.num,
|
|
125
|
-
product_quantity: (_ref6 = (_bundle$quantity = bundle.quantity) !== null && _bundle$quantity !== void 0 ? _bundle$quantity : bundle.num) !== null && _ref6 !== void 0 ? _ref6 : product === null || product === void 0 ? void 0 : product.product_quantity,
|
|
126
|
-
original_price: (_ref7 = (_bundle$original_pric = bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle.product_price) !== null && _ref7 !== void 0 ? _ref7 : bundle.price,
|
|
127
|
-
selling_price: (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.price,
|
|
128
|
-
is_charge_tax: (_bundle$is_charge_tax = bundle.is_charge_tax) !== null && _bundle$is_charge_tax !== void 0 ? _bundle$is_charge_tax : product === null || product === void 0 ? void 0 : product.is_charge_tax,
|
|
129
|
-
discount_list: bundle.discount_list
|
|
130
|
-
}));
|
|
131
|
-
}
|
|
132
|
-
} catch (err) {
|
|
133
|
-
_iterator3.e(err);
|
|
134
|
-
} finally {
|
|
135
|
-
_iterator3.f();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
} catch (err) {
|
|
139
|
-
_iterator2.e(err);
|
|
140
|
-
} finally {
|
|
141
|
-
_iterator2.f();
|
|
142
|
-
}
|
|
143
|
-
return expanded;
|
|
144
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { OrderProductDiscountItem } from '../types';
|
|
2
|
-
type NormalizeDiscountList = (discountList?: unknown[] | null) => OrderProductDiscountItem[];
|
|
3
|
-
export declare function restoreHydratedBundleDiscounts<T extends Record<string, any>>(product: T, normalizeDiscountList: NormalizeDiscountList): T;
|
|
4
|
-
export declare function expandHydratedProductsForDiscountCollection(products: any[] | undefined | null): any[];
|
|
5
|
-
export {};
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/modules/Order/utils/bundleDiscountHydration.ts
|
|
20
|
-
var bundleDiscountHydration_exports = {};
|
|
21
|
-
__export(bundleDiscountHydration_exports, {
|
|
22
|
-
expandHydratedProductsForDiscountCollection: () => expandHydratedProductsForDiscountCollection,
|
|
23
|
-
restoreHydratedBundleDiscounts: () => restoreHydratedBundleDiscounts
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(bundleDiscountHydration_exports);
|
|
26
|
-
var BUNDLE_MAP_ID_KEY = "custom_product_bundle_map_id";
|
|
27
|
-
function getBundleMapId(bundle) {
|
|
28
|
-
var _a;
|
|
29
|
-
const metadataMapId = (_a = bundle == null ? void 0 : bundle.metadata) == null ? void 0 : _a[BUNDLE_MAP_ID_KEY];
|
|
30
|
-
if (metadataMapId !== void 0 && metadataMapId !== null && metadataMapId !== "") {
|
|
31
|
-
return String(metadataMapId);
|
|
32
|
-
}
|
|
33
|
-
if ((bundle == null ? void 0 : bundle._id) !== void 0 && bundle._id !== null && bundle._id !== "") {
|
|
34
|
-
return String(bundle._id);
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
function getDiscountBundleMapId(discount) {
|
|
39
|
-
var _a;
|
|
40
|
-
const mapId = (_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a[BUNDLE_MAP_ID_KEY];
|
|
41
|
-
if (mapId === void 0 || mapId === null || mapId === "")
|
|
42
|
-
return null;
|
|
43
|
-
return String(mapId);
|
|
44
|
-
}
|
|
45
|
-
function hasSameBundleDiscount(discountList, discount) {
|
|
46
|
-
var _a;
|
|
47
|
-
const targetOrderDiscountId = discount.order_discount_id;
|
|
48
|
-
if (targetOrderDiscountId !== void 0 && targetOrderDiscountId !== null) {
|
|
49
|
-
return discountList.some((item) => (item == null ? void 0 : item.order_discount_id) === targetOrderDiscountId);
|
|
50
|
-
}
|
|
51
|
-
const targetResourceId = ((_a = discount == null ? void 0 : discount.discount) == null ? void 0 : _a.resource_id) ?? (discount == null ? void 0 : discount.resource_id) ?? (discount == null ? void 0 : discount.discount_id);
|
|
52
|
-
const targetMapId = getDiscountBundleMapId(discount);
|
|
53
|
-
return discountList.some((item) => {
|
|
54
|
-
var _a2;
|
|
55
|
-
const resourceId = ((_a2 = item == null ? void 0 : item.discount) == null ? void 0 : _a2.resource_id) ?? (item == null ? void 0 : item.resource_id) ?? (item == null ? void 0 : item.discount_id);
|
|
56
|
-
return resourceId === targetResourceId && String((item == null ? void 0 : item.amount) ?? "") === String((discount == null ? void 0 : discount.amount) ?? "") && getDiscountBundleMapId(item) === targetMapId;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
function restoreHydratedBundleDiscounts(product, normalizeDiscountList) {
|
|
60
|
-
if (!Array.isArray(product.product_bundle) || !Array.isArray(product.discount_list)) {
|
|
61
|
-
return product;
|
|
62
|
-
}
|
|
63
|
-
const bundleByMapId = /* @__PURE__ */ new Map();
|
|
64
|
-
product.product_bundle.forEach((bundle) => {
|
|
65
|
-
if (!bundle || typeof bundle !== "object")
|
|
66
|
-
return;
|
|
67
|
-
const mapId = getBundleMapId(bundle);
|
|
68
|
-
if (mapId)
|
|
69
|
-
bundleByMapId.set(mapId, bundle);
|
|
70
|
-
});
|
|
71
|
-
if (!bundleByMapId.size)
|
|
72
|
-
return product;
|
|
73
|
-
const mainDiscountList = [];
|
|
74
|
-
const bundleDiscounts = [];
|
|
75
|
-
product.discount_list.forEach((discount) => {
|
|
76
|
-
const mapId = getDiscountBundleMapId(discount);
|
|
77
|
-
if (mapId && bundleByMapId.has(mapId)) {
|
|
78
|
-
bundleDiscounts.push({ mapId, discount });
|
|
79
|
-
} else {
|
|
80
|
-
mainDiscountList.push(discount);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
if (!bundleDiscounts.length)
|
|
84
|
-
return product;
|
|
85
|
-
return {
|
|
86
|
-
...product,
|
|
87
|
-
discount_list: normalizeDiscountList(mainDiscountList),
|
|
88
|
-
product_bundle: product.product_bundle.map((bundle) => {
|
|
89
|
-
if (!bundle || typeof bundle !== "object")
|
|
90
|
-
return bundle;
|
|
91
|
-
const mapId = getBundleMapId(bundle);
|
|
92
|
-
if (!mapId)
|
|
93
|
-
return bundle;
|
|
94
|
-
const matchedDiscounts = bundleDiscounts.filter((item) => item.mapId === mapId).map((item) => item.discount);
|
|
95
|
-
if (!matchedDiscounts.length)
|
|
96
|
-
return bundle;
|
|
97
|
-
const currentDiscountList = Array.isArray(bundle.discount_list) ? [...bundle.discount_list] : [];
|
|
98
|
-
for (const discount of matchedDiscounts) {
|
|
99
|
-
if (!hasSameBundleDiscount(currentDiscountList, discount)) {
|
|
100
|
-
currentDiscountList.push(discount);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return {
|
|
104
|
-
...bundle,
|
|
105
|
-
discount_list: normalizeDiscountList(currentDiscountList),
|
|
106
|
-
metadata: {
|
|
107
|
-
...bundle.metadata || {},
|
|
108
|
-
[BUNDLE_MAP_ID_KEY]: mapId
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
})
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
function expandHydratedProductsForDiscountCollection(products) {
|
|
115
|
-
const expanded = [];
|
|
116
|
-
for (const product of products || []) {
|
|
117
|
-
expanded.push(product);
|
|
118
|
-
for (const bundle of (product == null ? void 0 : product.product_bundle) || []) {
|
|
119
|
-
if (!Array.isArray(bundle == null ? void 0 : bundle.discount_list) || bundle.discount_list.length === 0)
|
|
120
|
-
continue;
|
|
121
|
-
expanded.push({
|
|
122
|
-
...product,
|
|
123
|
-
product_id: bundle.bundle_product_id ?? bundle._bundle_product_id ?? bundle.product_id ?? (product == null ? void 0 : product.product_id),
|
|
124
|
-
num: bundle.num ?? bundle.quantity ?? (product == null ? void 0 : product.num),
|
|
125
|
-
product_quantity: bundle.quantity ?? bundle.num ?? (product == null ? void 0 : product.product_quantity),
|
|
126
|
-
original_price: bundle.original_price ?? bundle.product_price ?? bundle.price,
|
|
127
|
-
selling_price: bundle.bundle_selling_price ?? bundle.price,
|
|
128
|
-
is_charge_tax: bundle.is_charge_tax ?? (product == null ? void 0 : product.is_charge_tax),
|
|
129
|
-
discount_list: bundle.discount_list
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return expanded;
|
|
134
|
-
}
|
|
135
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
136
|
-
0 && (module.exports = {
|
|
137
|
-
expandHydratedProductsForDiscountCollection,
|
|
138
|
-
restoreHydratedBundleDiscounts
|
|
139
|
-
});
|