@pisell/pisellos 2.3.51 → 2.3.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +12 -10
- package/dist/modules/Discount/index.d.ts +0 -1
- package/dist/modules/Discount/index.js +11 -40
- package/dist/modules/Discount/types.d.ts +0 -1
- package/dist/modules/OpenData/index.js +2 -2
- package/dist/modules/Order/index.d.ts +7 -9
- package/dist/modules/Order/index.js +165 -140
- package/dist/modules/Order/types.d.ts +21 -12
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Order/utils.d.ts +0 -10
- package/dist/modules/Order/utils.js +3 -35
- package/dist/modules/Product/types.d.ts +0 -1
- package/dist/modules/ProductList/index.js +14 -33
- package/dist/modules/Quotation/index.d.ts +1 -1
- package/dist/modules/Quotation/index.js +2 -2
- package/dist/modules/Rules/index.js +32 -56
- package/dist/modules/SalesSummary/index.js +13 -12
- package/dist/modules/SalesSummary/utils.js +7 -1
- package/dist/modules/ScanOrderLogger/index.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/index.js +2 -15
- package/dist/modules/ScanOrderLogger/providers/feishu.js +27 -45
- package/dist/modules/ScanOrderLogger/types.d.ts +0 -1
- package/dist/modules/Schedule/index.d.ts +1 -3
- package/dist/modules/Schedule/index.js +16 -21
- package/dist/modules/Summary/utils.js +13 -38
- package/dist/modules/index.d.ts +0 -2
- package/dist/modules/index.js +1 -3
- package/dist/plugins/window.d.ts +0 -1
- package/dist/server/index.d.ts +0 -14
- package/dist/server/index.js +793 -907
- package/dist/solution/BaseSales/index.d.ts +15 -12
- package/dist/solution/BaseSales/index.js +194 -178
- package/dist/solution/BaseSales/utils/cartPromotion.js +5 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -16
- package/dist/solution/BookingByStep/index.js +215 -294
- package/dist/solution/BookingByStep/types.d.ts +1 -2
- package/dist/solution/BookingByStep/types.js +1 -3
- package/dist/solution/BookingByStep/utils/capacity.js +1 -17
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
- package/dist/solution/BookingTicket/index.d.ts +2 -14
- package/dist/solution/BookingTicket/index.js +2 -2
- package/dist/solution/BookingTicket/types.d.ts +3 -0
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -3
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -10
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +16 -2
- package/dist/solution/ScanOrder/index.d.ts +14 -26
- package/dist/solution/ScanOrder/index.js +739 -1142
- package/dist/solution/ScanOrder/types.d.ts +1 -21
- package/dist/solution/ScanOrder/utils.d.ts +0 -8
- package/dist/solution/ScanOrder/utils.js +25 -66
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +87 -125
- package/dist/solution/VenueBooking/index.d.ts +11 -39
- package/dist/solution/VenueBooking/index.js +841 -1167
- package/dist/solution/VenueBooking/types.d.ts +0 -3
- package/dist/solution/VenueBooking/utils/resource.js +0 -1
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +5 -10
- package/dist/solution/index.d.ts +0 -1
- package/dist/solution/index.js +1 -2
- package/dist/types/index.d.ts +0 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -1
- package/lib/modules/Discount/index.d.ts +0 -1
- package/lib/modules/Discount/index.js +0 -9
- package/lib/modules/Discount/types.d.ts +0 -1
- package/lib/modules/OpenData/index.js +1 -1
- package/lib/modules/Order/index.d.ts +7 -9
- package/lib/modules/Order/index.js +89 -38
- package/lib/modules/Order/types.d.ts +21 -12
- package/lib/modules/Order/utils.d.ts +0 -10
- package/lib/modules/Order/utils.js +5 -36
- package/lib/modules/Product/types.d.ts +0 -1
- package/lib/modules/ProductList/index.js +31 -40
- package/lib/modules/Quotation/index.d.ts +1 -1
- package/lib/modules/Quotation/index.js +2 -2
- package/lib/modules/Rules/index.js +32 -44
- package/lib/modules/SalesSummary/index.js +7 -6
- package/lib/modules/SalesSummary/utils.js +5 -1
- package/lib/modules/ScanOrderLogger/index.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/index.js +1 -13
- package/lib/modules/ScanOrderLogger/providers/feishu.js +6 -15
- package/lib/modules/ScanOrderLogger/types.d.ts +0 -1
- package/lib/modules/Schedule/index.d.ts +1 -3
- package/lib/modules/Schedule/index.js +8 -10
- package/lib/modules/Summary/utils.js +1 -21
- package/lib/modules/index.d.ts +0 -2
- package/lib/modules/index.js +1 -5
- package/lib/plugins/window.d.ts +0 -1
- package/lib/server/index.d.ts +0 -14
- package/lib/server/index.js +15 -72
- package/lib/solution/BaseSales/index.d.ts +15 -12
- package/lib/solution/BaseSales/index.js +52 -35
- package/lib/solution/BaseSales/utils/cartPromotion.js +5 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -16
- package/lib/solution/BookingByStep/index.js +18 -60
- package/lib/solution/BookingByStep/types.d.ts +1 -2
- package/lib/solution/BookingByStep/types.js +0 -5
- package/lib/solution/BookingByStep/utils/capacity.js +1 -20
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
- package/lib/solution/BookingTicket/index.d.ts +2 -14
- package/lib/solution/BookingTicket/index.js +2 -10
- package/lib/solution/BookingTicket/types.d.ts +3 -0
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -3
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +15 -3
- package/lib/solution/ScanOrder/index.d.ts +14 -26
- package/lib/solution/ScanOrder/index.js +182 -449
- package/lib/solution/ScanOrder/types.d.ts +1 -21
- package/lib/solution/ScanOrder/utils.d.ts +0 -8
- package/lib/solution/ScanOrder/utils.js +0 -31
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +0 -14
- package/lib/solution/VenueBooking/index.d.ts +11 -39
- package/lib/solution/VenueBooking/index.js +110 -322
- package/lib/solution/VenueBooking/types.d.ts +0 -3
- package/lib/solution/VenueBooking/utils/resource.js +0 -1
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +4 -6
- package/lib/solution/index.d.ts +0 -1
- package/lib/solution/index.js +1 -3
- package/lib/types/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/modules/Holder/index.d.ts +0 -48
- package/dist/modules/Holder/index.js +0 -640
- package/dist/modules/Holder/types.d.ts +0 -123
- package/dist/modules/Holder/types.js +0 -1
- package/dist/modules/Holder/utils.d.ts +0 -13
- package/dist/modules/Holder/utils.js +0 -34
- package/dist/modules/ResourcePlanner/index.d.ts +0 -24
- package/dist/modules/ResourcePlanner/index.js +0 -181
- package/dist/modules/ResourcePlanner/planner.d.ts +0 -14
- package/dist/modules/ResourcePlanner/planner.js +0 -1069
- package/dist/modules/ResourcePlanner/types.d.ts +0 -227
- package/dist/modules/ResourcePlanner/types.js +0 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +0 -183
- package/dist/solution/UnifiedBookingSales/index.js +0 -1891
- package/dist/solution/UnifiedBookingSales/types.d.ts +0 -143
- package/dist/solution/UnifiedBookingSales/types.js +0 -11
- package/lib/modules/Holder/index.d.ts +0 -48
- package/lib/modules/Holder/index.js +0 -402
- package/lib/modules/Holder/types.d.ts +0 -123
- package/lib/modules/Holder/types.js +0 -17
- package/lib/modules/Holder/utils.d.ts +0 -13
- package/lib/modules/Holder/utils.js +0 -71
- package/lib/modules/ResourcePlanner/index.d.ts +0 -24
- package/lib/modules/ResourcePlanner/index.js +0 -148
- package/lib/modules/ResourcePlanner/planner.d.ts +0 -14
- package/lib/modules/ResourcePlanner/planner.js +0 -933
- package/lib/modules/ResourcePlanner/types.d.ts +0 -227
- package/lib/modules/ResourcePlanner/types.js +0 -17
- package/lib/solution/UnifiedBookingSales/index.d.ts +0 -183
- package/lib/solution/UnifiedBookingSales/index.js +0 -1084
- package/lib/solution/UnifiedBookingSales/types.d.ts +0 -143
- package/lib/solution/UnifiedBookingSales/types.js +0 -33
|
@@ -36,9 +36,8 @@ __export(utils_exports, {
|
|
|
36
36
|
composeLinePrice: () => composeLinePrice,
|
|
37
37
|
createDefaultOrderRulesHooks: () => createDefaultOrderRulesHooks,
|
|
38
38
|
createDefaultTempOrder: () => createDefaultTempOrder,
|
|
39
|
-
createEmptySummary: () =>
|
|
39
|
+
createEmptySummary: () => import_utils2.createEmptySummary,
|
|
40
40
|
createUuidV4: () => import_orderCollectionIdentity.createUuidV4,
|
|
41
|
-
ensureCartItemOriginHolder: () => ensureCartItemOriginHolder,
|
|
42
41
|
ensureManualProductDiscountList: () => import_manualProductDiscount.ensureManualProductDiscountList,
|
|
43
42
|
ensureProductSku: () => ensureProductSku,
|
|
44
43
|
findManualProductDiscountItem: () => import_manualProductDiscount.findManualProductDiscountItem,
|
|
@@ -86,10 +85,9 @@ __export(utils_exports, {
|
|
|
86
85
|
module.exports = __toCommonJS(utils_exports);
|
|
87
86
|
var import_dayjs = __toESM(require("dayjs"));
|
|
88
87
|
var import_decimal = __toESM(require("decimal.js"));
|
|
89
|
-
var import_utils = require("
|
|
90
|
-
var import_utils2 = require("../../solution/ScanOrder/utils");
|
|
88
|
+
var import_utils = require("../../solution/ScanOrder/utils");
|
|
91
89
|
var import_orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
92
|
-
var
|
|
90
|
+
var import_utils2 = require("../../solution/ScanOrder/utils");
|
|
93
91
|
var import_manualProductDiscount = require("./utils/manualProductDiscount");
|
|
94
92
|
function composeLinePrice(params) {
|
|
95
93
|
const { mainPrice, bundle, useOriginalBundle } = params;
|
|
@@ -548,7 +546,7 @@ function createDefaultOrderRulesHooks() {
|
|
|
548
546
|
// 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
|
|
549
547
|
// 不透明 identity 契约下,normalizeOrderProduct / hydrate 已保证唯一值存在;
|
|
550
548
|
// 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
|
|
551
|
-
_id: ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? `${product.product_id}_${product.product_variant_id}_${product.metadata.unique_identification_number}` : `${product.product_id}_${product.product_variant_id}_${(0,
|
|
549
|
+
_id: ((_a = product.metadata) == null ? void 0 : _a.unique_identification_number) ? `${product.product_id}_${product.product_variant_id}_${product.metadata.unique_identification_number}` : `${product.product_id}_${product.product_variant_id}_${(0, import_utils.buildProductLineFingerprint)(
|
|
552
550
|
getProductSkuOptions(product),
|
|
553
551
|
product.product_bundle
|
|
554
552
|
)}`,
|
|
@@ -640,34 +638,6 @@ var mergeRelationForms = (relationForms) => {
|
|
|
640
638
|
}, {})
|
|
641
639
|
).filter((item) => item.form_record_ids.length > 0);
|
|
642
640
|
};
|
|
643
|
-
function getCustomerIdFromStorage(window) {
|
|
644
|
-
var _a;
|
|
645
|
-
try {
|
|
646
|
-
const customer = JSON.parse(((_a = window == null ? void 0 : window.getLocalStorage) == null ? void 0 : _a.call(window, "customer")) || "{}");
|
|
647
|
-
const customerId = Number(customer == null ? void 0 : customer.id);
|
|
648
|
-
return Number.isFinite(customerId) && customerId > 0 ? customerId : void 0;
|
|
649
|
-
} catch {
|
|
650
|
-
return void 0;
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
function ensureCartItemOriginHolder(cartItem, window) {
|
|
654
|
-
var _a;
|
|
655
|
-
if ((_a = cartItem == null ? void 0 : cartItem._origin) == null ? void 0 : _a.holder) {
|
|
656
|
-
return;
|
|
657
|
-
}
|
|
658
|
-
const holderConfig = (0, import_utils.getProductHolderConfig)(
|
|
659
|
-
(cartItem == null ? void 0 : cartItem._productInit) ?? (cartItem == null ? void 0 : cartItem._productOrigin)
|
|
660
|
-
);
|
|
661
|
-
const formRecordId = cartItem == null ? void 0 : cartItem.holder_id;
|
|
662
|
-
if (!(holderConfig == null ? void 0 : holderConfig.resource_id) || formRecordId == null) {
|
|
663
|
-
return;
|
|
664
|
-
}
|
|
665
|
-
cartItem._origin.holder = {
|
|
666
|
-
customer_id: getCustomerIdFromStorage(window),
|
|
667
|
-
form_id: holderConfig.resource_id,
|
|
668
|
-
form_record: [formRecordId]
|
|
669
|
-
};
|
|
670
|
-
}
|
|
671
641
|
var getAllDiscountList = (cartItem) => {
|
|
672
642
|
var _a, _b, _c, _d;
|
|
673
643
|
let discountList = ((_b = (_a = cartItem == null ? void 0 : cartItem._origin) == null ? void 0 : _a.product) == null ? void 0 : _b.discount_list) || [];
|
|
@@ -1033,7 +1003,7 @@ function buildSubmitPayload(params) {
|
|
|
1033
1003
|
// contacts: tempOrder.contacts || [],
|
|
1034
1004
|
contacts_info: tempOrder.contacts_info && !Array.isArray(tempOrder.contacts_info) ? tempOrder.contacts_info : null,
|
|
1035
1005
|
// holder: tempOrder.holder || null,
|
|
1036
|
-
summary: summary || tempOrder.summary || (0,
|
|
1006
|
+
summary: summary || tempOrder.summary || (0, import_utils.createEmptySummary)(),
|
|
1037
1007
|
metadata: (() => {
|
|
1038
1008
|
const {
|
|
1039
1009
|
collect_pax: _collectPax,
|
|
@@ -1282,7 +1252,6 @@ function indexOrderProductsByUid(products) {
|
|
|
1282
1252
|
createDefaultTempOrder,
|
|
1283
1253
|
createEmptySummary,
|
|
1284
1254
|
createUuidV4,
|
|
1285
|
-
ensureCartItemOriginHolder,
|
|
1286
1255
|
ensureManualProductDiscountList,
|
|
1287
1256
|
ensureProductSku,
|
|
1288
1257
|
findManualProductDiscountItem,
|
|
@@ -106,48 +106,39 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
106
106
|
} catch (error) {
|
|
107
107
|
console.error(error);
|
|
108
108
|
}
|
|
109
|
-
const channelMap = {
|
|
110
|
-
online_store: "online-store",
|
|
111
|
-
scan_to_order: "online-store",
|
|
112
|
-
"scan-to-order": "online-store",
|
|
113
|
-
scan_to_order_2: "mobile_order",
|
|
114
|
-
scan_to_order_3: "scantoorder3"
|
|
115
|
-
};
|
|
116
|
-
const rawApplicationCode = (_b = this.otherParams) == null ? void 0 : _b.channel;
|
|
117
|
-
const mappedApplicationCode = typeof rawApplicationCode === "string" ? channelMap[rawApplicationCode] || rawApplicationCode : rawApplicationCode;
|
|
118
|
-
const queryPayload = {
|
|
119
|
-
open_quotation: 1,
|
|
120
|
-
open_bundle: 0,
|
|
121
|
-
exclude_extension_type: [
|
|
122
|
-
"product_party",
|
|
123
|
-
"product_event",
|
|
124
|
-
"product_series_event",
|
|
125
|
-
"product_package_ticket",
|
|
126
|
-
"ticket",
|
|
127
|
-
"event_item"
|
|
128
|
-
],
|
|
129
|
-
with: ["category", "collection", "resourceRelation"],
|
|
130
|
-
status,
|
|
131
|
-
num: 500,
|
|
132
|
-
skip: 1,
|
|
133
|
-
customer_id,
|
|
134
|
-
...Array.isArray(category_ids) && category_ids.length ? { category_ids } : {},
|
|
135
|
-
...Array.isArray(product_ids) && product_ids.length ? { ids: product_ids } : {},
|
|
136
|
-
...Array.isArray(collection) && collection.length ? { collection } : {},
|
|
137
|
-
front_end_cache_id: cacheId,
|
|
138
|
-
...Array.isArray(menu_list_ids) && menu_list_ids.length ? { menu_list_ids } : {},
|
|
139
|
-
with_count,
|
|
140
|
-
// client_schedule_ids: schedule_ids,
|
|
141
|
-
schedule_date,
|
|
142
|
-
application_code: mappedApplicationCode,
|
|
143
|
-
is_eject: 1,
|
|
144
|
-
with_schedule,
|
|
145
|
-
schedule_datetime,
|
|
146
|
-
extension_type
|
|
147
|
-
};
|
|
148
109
|
const productsData = await this.request.post(
|
|
149
110
|
`/product/query`,
|
|
150
|
-
|
|
111
|
+
{
|
|
112
|
+
open_quotation: 1,
|
|
113
|
+
open_bundle: 0,
|
|
114
|
+
exclude_extension_type: [
|
|
115
|
+
"product_party",
|
|
116
|
+
"product_event",
|
|
117
|
+
"product_series_event",
|
|
118
|
+
"product_package_ticket",
|
|
119
|
+
"ticket",
|
|
120
|
+
"event_item"
|
|
121
|
+
],
|
|
122
|
+
with: ["category", "collection", "resourceRelation"],
|
|
123
|
+
status,
|
|
124
|
+
num: 500,
|
|
125
|
+
skip: 1,
|
|
126
|
+
customer_id,
|
|
127
|
+
category_ids,
|
|
128
|
+
ids: product_ids,
|
|
129
|
+
collection,
|
|
130
|
+
front_end_cache_id: cacheId,
|
|
131
|
+
menu_list_ids,
|
|
132
|
+
with_count,
|
|
133
|
+
// client_schedule_ids: schedule_ids,
|
|
134
|
+
schedule_date,
|
|
135
|
+
application_code: (_b = this.otherParams) == null ? void 0 : _b.channel,
|
|
136
|
+
is_eject: 1,
|
|
137
|
+
with_schedule,
|
|
138
|
+
schedule_datetime,
|
|
139
|
+
extension_type,
|
|
140
|
+
strategy_context
|
|
141
|
+
},
|
|
151
142
|
{ osServer: true, callback: options == null ? void 0 : options.callback, subscriberId: options == null ? void 0 : options.subscriberId, customToast: () => {
|
|
152
143
|
} }
|
|
153
144
|
);
|
|
@@ -21,7 +21,7 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
21
21
|
* Look up the quotation price for a specific product (+ optional variant) at a given datetime.
|
|
22
22
|
* Returns the price as a string (e.g. "300.00"), or null if no quotation applies.
|
|
23
23
|
*
|
|
24
|
-
* Priority: iterates quotations already sorted by `sort`
|
|
24
|
+
* Priority: iterates quotations already sorted by `sort` ascending (lowest = highest priority).
|
|
25
25
|
* First matching quotation whose schedule covers `datetime` and whose product_data contains
|
|
26
26
|
* the requested productId wins.
|
|
27
27
|
*/
|
|
@@ -52,7 +52,7 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
|
|
|
52
52
|
{ useCache: false, osServer: true }
|
|
53
53
|
);
|
|
54
54
|
const list = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || (res == null ? void 0 : res.list) || [];
|
|
55
|
-
list.sort((a, b) =>
|
|
55
|
+
list.sort((a, b) => a.sort - b.sort);
|
|
56
56
|
this.store.list = list;
|
|
57
57
|
}
|
|
58
58
|
getQuotationList() {
|
|
@@ -96,7 +96,7 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
|
|
|
96
96
|
* Look up the quotation price for a specific product (+ optional variant) at a given datetime.
|
|
97
97
|
* Returns the price as a string (e.g. "300.00"), or null if no quotation applies.
|
|
98
98
|
*
|
|
99
|
-
* Priority: iterates quotations already sorted by `sort`
|
|
99
|
+
* Priority: iterates quotations already sorted by `sort` ascending (lowest = highest priority).
|
|
100
100
|
* First matching quotation whose schedule covers `datetime` and whose product_data contains
|
|
101
101
|
* the requested productId wins.
|
|
102
102
|
*/
|
|
@@ -243,7 +243,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
243
243
|
const discountType = selectedDiscount.tag || selectedDiscount.type;
|
|
244
244
|
return selectedDiscount.isEditMode === true && selectedDiscount.isSelected === true && ["good_pass", "discount_card", "product_discount_card"].includes(discountType);
|
|
245
245
|
};
|
|
246
|
-
const
|
|
246
|
+
const resolveReapplyBookingDiscountPercent = (originProduct, selectedDiscount) => {
|
|
247
247
|
var _a2;
|
|
248
248
|
if (!shouldReapplyBookingDiscount(originProduct, selectedDiscount))
|
|
249
249
|
return void 0;
|
|
@@ -305,8 +305,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
305
305
|
_id: product._id,
|
|
306
306
|
parentId: product._id,
|
|
307
307
|
quantity: product.quantity,
|
|
308
|
-
num: product.num
|
|
309
|
-
booking_id: product.booking_id
|
|
308
|
+
num: product.num
|
|
310
309
|
});
|
|
311
310
|
if (product.bundle && Array.isArray(product.bundle) && product.bundle.length > 0) {
|
|
312
311
|
product.bundle.forEach((bundleItem, bundleIndex) => {
|
|
@@ -318,6 +317,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
318
317
|
bundleIndex,
|
|
319
318
|
// 虚拟商品属性
|
|
320
319
|
price: Number(bundleItem.price || 0),
|
|
320
|
+
// 新增商品运行态通常带 _bundle_product_id;订单 hydrate 后只有
|
|
321
|
+
// bundle_product_id。Change time 必须兼容两种结构,否则 bundle
|
|
322
|
+
// 子项无法命中折扣卡的 limited_relation_product_data.product_ids。
|
|
321
323
|
id: bundleItem.bundle_product_id ?? bundleItem._bundle_product_id ?? bundleItem.product_id,
|
|
322
324
|
_id: `${product._id}_bundle_${bundleIndex}`,
|
|
323
325
|
parentId: product._id,
|
|
@@ -327,7 +329,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
327
329
|
origin_total: new import_decimal.default(bundleItem.price || 0).mul(bundleItem.num || 1).toNumber(),
|
|
328
330
|
original_price: bundleItem.original_price,
|
|
329
331
|
// 继承主商品属性
|
|
330
|
-
booking_id:
|
|
332
|
+
booking_id: product.booking_id,
|
|
331
333
|
discount_list: bundleItem.discount_list || []
|
|
332
334
|
});
|
|
333
335
|
});
|
|
@@ -689,8 +691,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
689
691
|
discount_product_id: discount.product_id
|
|
690
692
|
},
|
|
691
693
|
metadata: {
|
|
692
|
-
num
|
|
693
|
-
discount_rule_uncheck_flag: discount == null ? void 0 : discount.discount_rule_uncheck_flag
|
|
694
|
+
num
|
|
694
695
|
}
|
|
695
696
|
};
|
|
696
697
|
applicableProducts.push(productData);
|
|
@@ -779,13 +780,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
779
780
|
if (isPersistedProduct && hasExistingWalletDiscount) {
|
|
780
781
|
if (flatItem.type === "main") {
|
|
781
782
|
processedProductsMap.set(product._id, [originProduct]);
|
|
782
|
-
} else {
|
|
783
|
-
processedFlatItemsMap.set(flatItem._id, [
|
|
784
|
-
{
|
|
785
|
-
...flatItem,
|
|
786
|
-
processed: true
|
|
787
|
-
}
|
|
788
|
-
]);
|
|
789
783
|
}
|
|
790
784
|
return;
|
|
791
785
|
}
|
|
@@ -1091,8 +1085,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1091
1085
|
amount = productAllocation.discountAmount;
|
|
1092
1086
|
productDiscountDifference = productAllocation.difference;
|
|
1093
1087
|
mainProductSellingPrice = Math.max(new import_decimal.default(product.price).minus(amount).toNumber(), 0);
|
|
1094
|
-
} else if (
|
|
1095
|
-
const percent =
|
|
1088
|
+
} else if (resolveReapplyBookingDiscountPercent(originProduct, selectedDiscount2) !== void 0) {
|
|
1089
|
+
const percent = resolveReapplyBookingDiscountPercent(originProduct, selectedDiscount2);
|
|
1096
1090
|
reapplyDiscountPercent = new import_decimal.default(percent).toFixed(2);
|
|
1097
1091
|
mainProductSellingPrice = new import_decimal.default(product.price || 0).mul(new import_decimal.default(100).minus(percent)).div(100).toDecimalPlaces(2).toNumber();
|
|
1098
1092
|
amount = new import_decimal.default(product.price).minus(mainProductSellingPrice).toNumber();
|
|
@@ -1138,7 +1132,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1138
1132
|
config: selectedDiscount2 == null ? void 0 : selectedDiscount2.config,
|
|
1139
1133
|
metadata: {
|
|
1140
1134
|
num: 1,
|
|
1141
|
-
discount_rule_uncheck_flag: selectedDiscount2 == null ? void 0 : selectedDiscount2.discount_rule_uncheck_flag,
|
|
1142
1135
|
// 🔥 order_level 分摊差值
|
|
1143
1136
|
...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference },
|
|
1144
1137
|
/** 仅主商品上的优惠金额(不含 option) */
|
|
@@ -1219,7 +1212,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1219
1212
|
metadata: {
|
|
1220
1213
|
// 🔥 使用拆分后的唯一 _id
|
|
1221
1214
|
custom_product_bundle_map_id: uniqueId,
|
|
1222
|
-
discount_rule_uncheck_flag: selectedDiscount2 == null ? void 0 : selectedDiscount2.discount_rule_uncheck_flag,
|
|
1223
1215
|
num: 1
|
|
1224
1216
|
},
|
|
1225
1217
|
_num: 1,
|
|
@@ -1249,7 +1241,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1249
1241
|
_id: `${flatItem._id}_split_rest`,
|
|
1250
1242
|
num: normalNum,
|
|
1251
1243
|
quantity: normalNum,
|
|
1252
|
-
discount_list:
|
|
1244
|
+
discount_list: [],
|
|
1253
1245
|
processed: true
|
|
1254
1246
|
});
|
|
1255
1247
|
}
|
|
@@ -1267,10 +1259,19 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1267
1259
|
let targetProductTotal;
|
|
1268
1260
|
let fixedAmountPerItem;
|
|
1269
1261
|
let productDiscountDifference;
|
|
1262
|
+
let reapplyDiscountPercent;
|
|
1270
1263
|
if (isOrderLevel && productAllocation) {
|
|
1271
1264
|
fixedAmountPerItem = productAllocation.discountAmount;
|
|
1272
1265
|
productDiscountDifference = productAllocation.difference;
|
|
1273
1266
|
targetProductTotal = Math.max(new import_decimal.default(productOriginTotal).minus(fixedAmountPerItem).toNumber(), 0);
|
|
1267
|
+
} else if (resolveReapplyBookingDiscountPercent(originProduct, selectedDiscount2) !== void 0) {
|
|
1268
|
+
const percent = resolveReapplyBookingDiscountPercent(
|
|
1269
|
+
originProduct,
|
|
1270
|
+
selectedDiscount2
|
|
1271
|
+
);
|
|
1272
|
+
reapplyDiscountPercent = new import_decimal.default(percent).toFixed(2);
|
|
1273
|
+
targetProductTotal = new import_decimal.default(productOriginTotal).mul(new import_decimal.default(100).minus(percent)).div(100).toDecimalPlaces(2).toNumber();
|
|
1274
|
+
fixedAmountPerItem = new import_decimal.default(productOriginTotal).minus(targetProductTotal).toNumber();
|
|
1274
1275
|
} else {
|
|
1275
1276
|
targetProductTotal = (0, import_utils.getDiscountAmount)(
|
|
1276
1277
|
selectedDiscount2,
|
|
@@ -1292,13 +1293,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1292
1293
|
title: selectedDiscount2.format_title,
|
|
1293
1294
|
original_amount: product.original_price,
|
|
1294
1295
|
product_id: product.id || product.product_id,
|
|
1295
|
-
percent: selectedDiscount2.par_value,
|
|
1296
|
+
percent: reapplyDiscountPercent ?? selectedDiscount2.par_value,
|
|
1296
1297
|
discount_product_id: selectedDiscount2.product_id
|
|
1297
1298
|
},
|
|
1298
1299
|
metadata: {
|
|
1299
1300
|
// 🔥 使用唯一的 _id
|
|
1300
1301
|
custom_product_bundle_map_id: uniqueId,
|
|
1301
|
-
discount_rule_uncheck_flag: selectedDiscount2 == null ? void 0 : selectedDiscount2.discount_rule_uncheck_flag,
|
|
1302
1302
|
num: product.num || 1,
|
|
1303
1303
|
// 🔥 order_level 分摊差值
|
|
1304
1304
|
...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference }
|
|
@@ -1313,7 +1313,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1313
1313
|
...flatItem,
|
|
1314
1314
|
total: targetProductTotal,
|
|
1315
1315
|
price: new import_decimal.default(productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
|
|
1316
|
-
discount_list:
|
|
1316
|
+
discount_list: [discountDetail],
|
|
1317
1317
|
processed: true
|
|
1318
1318
|
});
|
|
1319
1319
|
}
|
|
@@ -1734,7 +1734,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1734
1734
|
* @returns 是否可用
|
|
1735
1735
|
*/
|
|
1736
1736
|
checkPackageSubItemUsageRules(discount, flatItem) {
|
|
1737
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
1737
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1738
1738
|
const limitedData = discount.limited_relation_product_data;
|
|
1739
1739
|
const usageRules = limitedData == null ? void 0 : limitedData.package_sub_item_usage_rules;
|
|
1740
1740
|
const rules = ["original_price", ...(usageRules == null ? void 0 : usageRules.rules) || []];
|
|
@@ -1746,7 +1746,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1746
1746
|
const { type: scopeType, exclude_bundle_product_ids = [], include_bundle_product_ids = [], filter = 0 } = packageScope || {};
|
|
1747
1747
|
const isMainProduct = flatItem.type === "main";
|
|
1748
1748
|
const isBundleItem = flatItem.type === "bundle";
|
|
1749
|
-
const bundleMainProductId = (_a = flatItem.product) == null ? void 0 : _a.product_id;
|
|
1750
1749
|
if (isMainProduct) {
|
|
1751
1750
|
return true;
|
|
1752
1751
|
}
|
|
@@ -1755,9 +1754,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1755
1754
|
return true;
|
|
1756
1755
|
}
|
|
1757
1756
|
if (isBundleItem) {
|
|
1758
|
-
const priceType = (
|
|
1759
|
-
const priceTypeExt = (
|
|
1760
|
-
const mainProductId = ((
|
|
1757
|
+
const priceType = (_a = flatItem.bundleItem) == null ? void 0 : _a.price_type;
|
|
1758
|
+
const priceTypeExt = (_b = flatItem.bundleItem) == null ? void 0 : _b.price_type_ext;
|
|
1759
|
+
const mainProductId = ((_d = (_c = flatItem == null ? void 0 : flatItem.originProduct) == null ? void 0 : _c._productOrigin) == null ? void 0 : _d.id) || ((_e = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _e.id) || 0;
|
|
1761
1760
|
const isOriginalPrice = priceType === "markup" && priceTypeExt === "product_price";
|
|
1762
1761
|
const isMarkupPrice = priceType === "markup" && (priceTypeExt === "" || !priceTypeExt);
|
|
1763
1762
|
if (rules.length > 0) {
|
|
@@ -1769,11 +1768,11 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1769
1768
|
if (!filter) {
|
|
1770
1769
|
isScopeValid = true;
|
|
1771
1770
|
} else {
|
|
1772
|
-
isScopeValid = !exclude_bundle_product_ids.includes(Number(
|
|
1771
|
+
isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
|
|
1773
1772
|
}
|
|
1774
1773
|
}
|
|
1775
1774
|
if (scopeType === "specific_packages" || scopeType === "products") {
|
|
1776
|
-
isScopeValid = include_bundle_product_ids.includes(Number(
|
|
1775
|
+
isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
|
|
1777
1776
|
}
|
|
1778
1777
|
if (isPriceValid && isScopeValid) {
|
|
1779
1778
|
return true;
|
|
@@ -1789,26 +1788,15 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1789
1788
|
return false;
|
|
1790
1789
|
}
|
|
1791
1790
|
if (isBundleItem) {
|
|
1792
|
-
const priceType = (
|
|
1793
|
-
const priceTypeExt = (
|
|
1791
|
+
const priceType = (_f = flatItem.bundleItem) == null ? void 0 : _f.price_type;
|
|
1792
|
+
const priceTypeExt = (_g = flatItem.bundleItem) == null ? void 0 : _g.price_type_ext;
|
|
1794
1793
|
const isOriginalPrice = priceType === "markup" && priceTypeExt === "product_price";
|
|
1795
1794
|
const isMarkupPrice = priceType === "markup" && (priceTypeExt === "" || !priceTypeExt);
|
|
1796
1795
|
if (rules.length > 0) {
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
const isPriceValid = _isOriginalPrice || _isMarkupPrice;
|
|
1800
|
-
let isScopeValid = false;
|
|
1801
|
-
if (scopeType === "all_packages" || scopeType === "product_all") {
|
|
1802
|
-
if (!filter) {
|
|
1803
|
-
isScopeValid = true;
|
|
1804
|
-
} else {
|
|
1805
|
-
isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
|
|
1806
|
-
}
|
|
1807
|
-
}
|
|
1808
|
-
if (scopeType === "specific_packages" || scopeType === "products") {
|
|
1809
|
-
isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
|
|
1796
|
+
if (isOriginalPrice && rules.includes("original_price")) {
|
|
1797
|
+
return true;
|
|
1810
1798
|
}
|
|
1811
|
-
if (
|
|
1799
|
+
if (isMarkupPrice && rules.includes("markup_price")) {
|
|
1812
1800
|
return true;
|
|
1813
1801
|
}
|
|
1814
1802
|
return false;
|
|
@@ -53,6 +53,9 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
53
53
|
this.store.surchargeList = ((_a = options.initialState) == null ? void 0 : _a.surchargeList) || [];
|
|
54
54
|
this.store.summary = ((_b = options.initialState) == null ? void 0 : _b.summary) || (0, import_utils.createEmptySalesSummary)();
|
|
55
55
|
this.surchargeListModuleName = ((_c = this.otherParams) == null ? void 0 : _c.surchargeListModuleName) || "surchargeList";
|
|
56
|
+
if (!this.appPlugin) {
|
|
57
|
+
throw new Error("SalesSummaryModule 需要 app 插件支持");
|
|
58
|
+
}
|
|
56
59
|
if (!this.request) {
|
|
57
60
|
throw new Error("SalesSummaryModule 需要 request 插件支持");
|
|
58
61
|
}
|
|
@@ -106,14 +109,12 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
getAppData(key) {
|
|
109
|
-
var _a, _b, _c, _d, _e, _f
|
|
110
|
-
const getData = (_b = (_a = this.appPlugin)
|
|
112
|
+
var _a, _b, _c, _d, _e, _f;
|
|
113
|
+
const getData = (_b = (_a = this.appPlugin).getData) == null ? void 0 : _b.call(_a);
|
|
111
114
|
if (typeof getData === "function")
|
|
112
115
|
return getData(key);
|
|
113
|
-
const app =
|
|
114
|
-
|
|
115
|
-
return void 0;
|
|
116
|
-
const coreData = (_h = (_f = (_e = app == null ? void 0 : app.models) == null ? void 0 : _e.getStore) == null ? void 0 : (_g = _f.call(_e)).getDataByModel) == null ? void 0 : _h.call(_g, "core", "core");
|
|
116
|
+
const app = this.appPlugin.getApp();
|
|
117
|
+
const coreData = (_f = (_d = (_c = app == null ? void 0 : app.models) == null ? void 0 : _c.getStore) == null ? void 0 : (_e = _d.call(_c)).getDataByModel) == null ? void 0 : _f.call(_e, "core", "core");
|
|
117
118
|
return coreData == null ? void 0 : coreData[key];
|
|
118
119
|
}
|
|
119
120
|
getTaxConfig() {
|
|
@@ -99,7 +99,11 @@ function getUnitOriginalTotal(product) {
|
|
|
99
99
|
function isGeneratedVoucherProduct(product) {
|
|
100
100
|
const record = product;
|
|
101
101
|
const metadata = (record == null ? void 0 : record.metadata) || {};
|
|
102
|
-
|
|
102
|
+
const isGeneratedChild = metadata.parent_order_detail_id !== void 0 || metadata.gift_card_type !== void 0;
|
|
103
|
+
if (isGeneratedChild)
|
|
104
|
+
return true;
|
|
105
|
+
const isPersisted = (record == null ? void 0 : record.order_detail_id) !== void 0 && (record == null ? void 0 : record.order_detail_id) !== null;
|
|
106
|
+
return (record == null ? void 0 : record.extension_type) === "product_voucher" && !isPersisted;
|
|
103
107
|
}
|
|
104
108
|
function buildSurchargeServiceItems(products) {
|
|
105
109
|
return products.map((product) => {
|
|
@@ -11,12 +11,10 @@ export declare class ScanOrderLoggerModule extends BaseModule implements Module,
|
|
|
11
11
|
protected defaultName: string;
|
|
12
12
|
protected defaultVersion: string;
|
|
13
13
|
private store;
|
|
14
|
-
private window?;
|
|
15
14
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
16
15
|
setContext(context: ScanOrderLoggerContext): void;
|
|
17
16
|
setProvider(provider: ScanOrderLoggerProviderType): void;
|
|
18
17
|
setProviderConfig(providerConfig: ScanOrderLoggerProviderConfig): void;
|
|
19
|
-
private getCurrentHost;
|
|
20
18
|
private buildRecord;
|
|
21
19
|
addLog(params: ScanOrderLogInput): Promise<void>;
|
|
22
20
|
}
|
|
@@ -60,7 +60,6 @@ var ScanOrderLoggerModule = class extends import_BaseModule.BaseModule {
|
|
|
60
60
|
var _a, _b, _c;
|
|
61
61
|
this.core = core;
|
|
62
62
|
this.store = options.store;
|
|
63
|
-
this.window = core.getPlugin("window") || void 0;
|
|
64
63
|
const provider = ((_a = options.otherParams) == null ? void 0 : _a.provider) || "feishu";
|
|
65
64
|
const providerConfig = ((_b = options.otherParams) == null ? void 0 : _b.providerConfig) || {};
|
|
66
65
|
const context = ((_c = options.otherParams) == null ? void 0 : _c.context) || {};
|
|
@@ -102,25 +101,14 @@ var ScanOrderLoggerModule = class extends import_BaseModule.BaseModule {
|
|
|
102
101
|
}
|
|
103
102
|
};
|
|
104
103
|
}
|
|
105
|
-
getCurrentHost() {
|
|
106
|
-
var _a, _b;
|
|
107
|
-
const host = (_b = (_a = this.window) == null ? void 0 : _a.location) == null ? void 0 : _b.host;
|
|
108
|
-
if (typeof host === "string" && host.length > 0)
|
|
109
|
-
return host;
|
|
110
|
-
return void 0;
|
|
111
|
-
}
|
|
112
104
|
buildRecord(params) {
|
|
113
|
-
const host = this.getCurrentHost();
|
|
114
105
|
return {
|
|
115
106
|
level: params.level || "info",
|
|
116
107
|
title: params.title,
|
|
117
108
|
timestamp: params.timestamp || (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss"),
|
|
118
109
|
payload: params.payload || {},
|
|
119
110
|
extra: params.extra || {},
|
|
120
|
-
context: {
|
|
121
|
-
...this.store.context || {},
|
|
122
|
-
...host ? { host } : {}
|
|
123
|
-
}
|
|
111
|
+
context: this.store.context || {}
|
|
124
112
|
};
|
|
125
113
|
}
|
|
126
114
|
async addLog(params) {
|
|
@@ -112,29 +112,20 @@ async function flushQueue() {
|
|
|
112
112
|
}
|
|
113
113
|
var feishuLoggerProvider = {
|
|
114
114
|
async send(payload) {
|
|
115
|
-
var _a, _b, _c, _d
|
|
115
|
+
var _a, _b, _c, _d;
|
|
116
116
|
cachedProviderConfig = payload.providerConfig;
|
|
117
117
|
const webhook = (_b = (_a = payload.providerConfig) == null ? void 0 : _a.feishu) == null ? void 0 : _b.webhook;
|
|
118
|
-
const errorHook = (_d = (_c = payload.providerConfig) == null ? void 0 : _c.feishu) == null ? void 0 : _d.errorHook;
|
|
119
|
-
if (typeof fetch !== "function") {
|
|
120
|
-
console.warn("[ScanOrderLogger] 当前环境不支持 fetch,跳过 Feishu 日志上报");
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if (payload.record.level === "error" && isWebhookUsable(errorHook)) {
|
|
124
|
-
try {
|
|
125
|
-
await postToFeishu(errorHook, buildFeishuBody([payload.record]));
|
|
126
|
-
} catch (error) {
|
|
127
|
-
console.warn("[ScanOrderLogger] Feishu errorHook 上报失败", error);
|
|
128
|
-
}
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
118
|
if (!webhook) {
|
|
132
119
|
console.warn("[ScanOrderLogger] Feishu webhook 未配置,跳过日志上报");
|
|
133
120
|
return;
|
|
134
121
|
}
|
|
135
122
|
if (!isWebhookUsable(webhook))
|
|
136
123
|
return;
|
|
137
|
-
|
|
124
|
+
if (typeof fetch !== "function") {
|
|
125
|
+
console.warn("[ScanOrderLogger] 当前环境不支持 fetch,跳过 Feishu 日志上报");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const throttleMs = ((_d = (_c = payload.providerConfig) == null ? void 0 : _c.feishu) == null ? void 0 : _d.throttleMs) ?? DEFAULT_THROTTLE_MS;
|
|
138
129
|
if (throttleMs <= 0) {
|
|
139
130
|
try {
|
|
140
131
|
await postToFeishu(webhook, buildFeishuBody([payload.record]));
|
|
@@ -2,7 +2,6 @@ export type ScanOrderLogLevel = 'info' | 'warning' | 'error' | 'debug';
|
|
|
2
2
|
export type ScanOrderLoggerProviderType = 'feishu' | 'grafana';
|
|
3
3
|
export interface ScanOrderLoggerProviderFeishuConfig {
|
|
4
4
|
webhook?: string;
|
|
5
|
-
errorHook?: string;
|
|
6
5
|
/**
|
|
7
6
|
* 节流窗口毫秒数,默认 3000ms
|
|
8
7
|
* - >0:首条日志进入队列并启动定时器,窗口结束后合并成一条 Feishu post 统一发送
|
|
@@ -24,9 +24,7 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
24
24
|
*
|
|
25
25
|
* @memberof ScheduleModule
|
|
26
26
|
*/
|
|
27
|
-
loadAllSchedule(
|
|
28
|
-
useCache?: boolean;
|
|
29
|
-
}): Promise<void>;
|
|
27
|
+
loadAllSchedule(): Promise<void>;
|
|
30
28
|
setScheduleList(list: ScheduleItem[]): void;
|
|
31
29
|
private syncScheduleMap;
|
|
32
30
|
getScheduleList(): ScheduleItem[];
|
|
@@ -95,12 +95,12 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
|
95
95
|
*
|
|
96
96
|
* @memberof ScheduleModule
|
|
97
97
|
*/
|
|
98
|
-
async loadAllSchedule(
|
|
98
|
+
async loadAllSchedule() {
|
|
99
99
|
var _a;
|
|
100
100
|
const scheduleList = await this.request.get(
|
|
101
101
|
`/schedule`,
|
|
102
102
|
{ num: 999 },
|
|
103
|
-
{ useCache:
|
|
103
|
+
{ useCache: true }
|
|
104
104
|
);
|
|
105
105
|
this.setScheduleList(((_a = scheduleList.data) == null ? void 0 : _a.list) || []);
|
|
106
106
|
}
|
|
@@ -126,6 +126,7 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
|
126
126
|
custom_page_id,
|
|
127
127
|
channel
|
|
128
128
|
}) {
|
|
129
|
+
var _a, _b, _c;
|
|
129
130
|
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day")) {
|
|
130
131
|
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
131
132
|
}
|
|
@@ -143,20 +144,17 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
|
143
144
|
channel
|
|
144
145
|
}
|
|
145
146
|
);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
this.setAvailabilityScheduleDateList(dateList);
|
|
150
|
-
this.setOtherProductsIds(otherProductIds);
|
|
151
|
-
if (!dateList.length && !otherProductIds.length || (0, import_dayjs.default)(endDate).isBefore((0, import_dayjs.default)(), "day")) {
|
|
147
|
+
this.setAvailabilityScheduleDateList(res.data.date_list);
|
|
148
|
+
this.setOtherProductsIds(res.data.other_product_ids || []);
|
|
149
|
+
if (!((_a = res.data.date_list) == null ? void 0 : _a.length) && !((_b = res.data.other_product_ids) == null ? void 0 : _b.length) || (0, import_dayjs.default)(endDate).isBefore((0, import_dayjs.default)(), "day")) {
|
|
152
150
|
return dates;
|
|
153
151
|
}
|
|
154
|
-
if (
|
|
152
|
+
if ((_c = res.data.other_product_ids) == null ? void 0 : _c.length) {
|
|
155
153
|
dates.forEach((n) => {
|
|
156
154
|
n.status = "available";
|
|
157
155
|
});
|
|
158
156
|
} else {
|
|
159
|
-
|
|
157
|
+
res.data.date_list.forEach((n) => {
|
|
160
158
|
const index = dates.findIndex((m) => m.date === n.date);
|
|
161
159
|
if (index !== -1) {
|
|
162
160
|
dates[index].status = "available";
|
|
@@ -437,31 +437,11 @@ var getBundleItemIsDiscountPrice = (item) => {
|
|
|
437
437
|
var getBundleItemIsMarkupOrDiscountPrice = (item) => {
|
|
438
438
|
return getBundleItemIsMarkupPrice(item) || getBundleItemIsDiscountPrice(item);
|
|
439
439
|
};
|
|
440
|
-
var getDiscountAmount = (discounts) => {
|
|
441
|
-
return (discounts || []).reduce((total, discount) => {
|
|
442
|
-
return total.add(new import_decimal.default(discount.amount || 0));
|
|
443
|
-
}, new import_decimal.default(0)).toNumber();
|
|
444
|
-
};
|
|
445
440
|
var getMainProductTotal = (item) => {
|
|
446
|
-
var _a, _b
|
|
441
|
+
var _a, _b;
|
|
447
442
|
let total = new import_decimal.default(
|
|
448
443
|
(item == null ? void 0 : item.main_product_selling_price) ?? ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.main_product_selling_price) ?? ((_b = item == null ? void 0 : item.metadata) == null ? void 0 : _b.main_product_original_price) ?? 0
|
|
449
444
|
);
|
|
450
|
-
const hasMainProductPrice = (item == null ? void 0 : item.main_product_selling_price) != null || ((_c = item == null ? void 0 : item.metadata) == null ? void 0 : _c.main_product_selling_price) != null || ((_d = item == null ? void 0 : item.metadata) == null ? void 0 : _d.main_product_original_price) != null;
|
|
451
|
-
if (!hasMainProductPrice) {
|
|
452
|
-
total = new import_decimal.default((item == null ? void 0 : item.main_product_selling_price) ?? ((_e = item == null ? void 0 : item.metadata) == null ? void 0 : _e.main_product_selling_price) ?? item.price ?? 0);
|
|
453
|
-
const discount = ((_g = (_f = item == null ? void 0 : item._origin) == null ? void 0 : _f.product) == null ? void 0 : _g.discount_list) || ((_j = (_i = (_h = item == null ? void 0 : item._originData) == null ? void 0 : _h.product) == null ? void 0 : _i.discount_list) == null ? void 0 : _j.filter((item2) => {
|
|
454
|
-
var _a2;
|
|
455
|
-
return !((_a2 = item2 == null ? void 0 : item2.metadata) == null ? void 0 : _a2.custom_product_bundle_map_id);
|
|
456
|
-
})) || [];
|
|
457
|
-
const mainProductDiscountAmount = getDiscountAmount(discount);
|
|
458
|
-
total = total.minus(mainProductDiscountAmount);
|
|
459
|
-
if ((item == null ? void 0 : item.option) && Array.isArray(item == null ? void 0 : item.option)) {
|
|
460
|
-
total = total.add(item == null ? void 0 : item.option.reduce((t, option) => {
|
|
461
|
-
return t.add(new import_decimal.default(option.price || 0).mul(option.num || 1));
|
|
462
|
-
}, new import_decimal.default(0)));
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
445
|
for (let bundleItem of (item == null ? void 0 : item.bundle) || []) {
|
|
466
446
|
if (getBundleItemIsMarkupOrDiscountPrice(bundleItem)) {
|
|
467
447
|
const bundleItemTotal = new import_decimal.default(bundleItem.bundle_selling_price ?? bundleItem.price ?? 0);
|