@pisell/pisellos 2.2.171 → 2.2.172
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/index.d.ts +37 -0
- package/dist/modules/BookingContext/index.js +436 -0
- package/dist/modules/BookingContext/types.d.ts +102 -0
- package/dist/modules/BookingContext/types.js +51 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +193 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +215 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/flexible.js +56 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
- package/dist/modules/BookingContext/utils/index.d.ts +11 -0
- package/dist/modules/BookingContext/utils/index.js +11 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/noResource.js +77 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/dist/modules/BookingContext/utils/productExtend.js +339 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
- package/dist/modules/BookingContext/utils/resources.js +486 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
- package/dist/modules/Customer/index.d.ts +6 -0
- package/dist/modules/Customer/index.js +129 -83
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.d.ts +2 -4
- package/dist/modules/Discount/index.js +8 -93
- package/dist/modules/Discount/types.d.ts +1 -7
- package/dist/modules/Order/index.d.ts +47 -16
- package/dist/modules/Order/index.js +743 -334
- package/dist/modules/Order/types.d.ts +57 -17
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/manualProductDiscount.js +212 -0
- package/dist/modules/Order/utils.d.ts +23 -1
- package/dist/modules/Order/utils.js +139 -30
- package/dist/modules/Quotation/index.js +16 -5
- package/dist/modules/Rules/index.d.ts +4 -0
- package/dist/modules/Rules/index.js +26 -10
- package/dist/modules/SalesSummary/index.js +4 -2
- package/dist/modules/Schedule/index.js +6 -2
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +2 -1
- package/dist/server/index.js +10 -6
- package/dist/server/modules/order/utils/filterOrders.js +20 -6
- package/dist/server/modules/products/index.js +9 -8
- package/dist/server/modules/schedule/index.js +13 -6
- package/dist/solution/BaseSales/index.d.ts +65 -7
- package/dist/solution/BaseSales/index.js +1066 -315
- package/dist/solution/BaseSales/types.d.ts +53 -1
- package/dist/solution/BaseSales/types.js +3 -1
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +159 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +65 -15
- package/dist/solution/BaseSales/utils.js +46 -8
- package/dist/solution/BookingTicket/index.d.ts +134 -2
- package/dist/solution/BookingTicket/index.js +768 -175
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/BookingTicket/types.js +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
- package/dist/solution/ScanOrder/index.d.ts +9 -3
- package/dist/solution/ScanOrder/index.js +231 -128
- package/dist/solution/ScanOrder/utils.js +46 -8
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +18 -23
- package/dist/solution/VenueBooking/index.d.ts +5 -9
- package/dist/solution/VenueBooking/index.js +103 -55
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/lib/modules/BookingContext/index.d.ts +37 -0
- package/lib/modules/BookingContext/index.js +297 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +34 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +207 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +198 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +80 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +43 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +90 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +283 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +377 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
- package/lib/modules/Customer/index.d.ts +6 -0
- package/lib/modules/Customer/index.js +26 -11
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +2 -4
- package/lib/modules/Discount/index.js +8 -63
- package/lib/modules/Discount/types.d.ts +1 -7
- package/lib/modules/Order/index.d.ts +47 -16
- package/lib/modules/Order/index.js +389 -90
- package/lib/modules/Order/types.d.ts +57 -17
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
- package/lib/modules/Order/utils.d.ts +23 -1
- package/lib/modules/Order/utils.js +145 -21
- package/lib/modules/Quotation/index.js +17 -6
- package/lib/modules/Rules/index.d.ts +4 -0
- package/lib/modules/Rules/index.js +22 -14
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/Schedule/index.js +3 -1
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +3 -1
- package/lib/server/index.js +2 -0
- package/lib/server/modules/order/utils/filterOrders.js +12 -4
- package/lib/server/modules/products/index.js +8 -9
- package/lib/server/modules/schedule/index.js +2 -1
- package/lib/solution/BaseSales/index.d.ts +65 -7
- package/lib/solution/BaseSales/index.js +492 -20
- package/lib/solution/BaseSales/types.d.ts +53 -1
- package/lib/solution/BaseSales/types.js +3 -1
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +201 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +70 -11
- package/lib/solution/BaseSales/utils.js +46 -6
- package/lib/solution/BookingTicket/index.d.ts +134 -2
- package/lib/solution/BookingTicket/index.js +341 -8
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/BookingTicket/types.js +6 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
- package/lib/solution/ScanOrder/index.d.ts +9 -3
- package/lib/solution/ScanOrder/index.js +147 -66
- package/lib/solution/ScanOrder/utils.js +46 -6
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +2 -4
- package/lib/solution/VenueBooking/index.d.ts +5 -9
- package/lib/solution/VenueBooking/index.js +50 -14
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/package.json +2 -2
|
@@ -29,12 +29,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
// src/modules/Order/utils.ts
|
|
30
30
|
var utils_exports = {};
|
|
31
31
|
__export(utils_exports, {
|
|
32
|
+
buildManualProductDiscountItem: () => import_manualProductDiscount.buildManualProductDiscountItem,
|
|
32
33
|
buildSubmitPayload: () => buildSubmitPayload,
|
|
33
34
|
composeLinePrice: () => composeLinePrice,
|
|
34
35
|
createDefaultOrderRulesHooks: () => createDefaultOrderRulesHooks,
|
|
35
36
|
createDefaultTempOrder: () => createDefaultTempOrder,
|
|
36
37
|
createEmptySummary: () => import_utils2.createEmptySummary,
|
|
37
38
|
createUuidV4: () => createUuidV4,
|
|
39
|
+
ensureManualProductDiscountList: () => import_manualProductDiscount.ensureManualProductDiscountList,
|
|
40
|
+
findManualProductDiscountItem: () => import_manualProductDiscount.findManualProductDiscountItem,
|
|
38
41
|
formatDateTime: () => formatDateTime,
|
|
39
42
|
formatV1Product: () => formatV1Product,
|
|
40
43
|
generateDuration: () => generateDuration,
|
|
@@ -42,19 +45,31 @@ __export(utils_exports, {
|
|
|
42
45
|
isTempOrder: () => isTempOrder,
|
|
43
46
|
mapPaymentItemToOrderPayment: () => mapPaymentItemToOrderPayment,
|
|
44
47
|
mapPaymentItemsToOrderPayments: () => mapPaymentItemsToOrderPayments,
|
|
48
|
+
mergeManualProductDiscountIntoList: () => import_manualProductDiscount.mergeManualProductDiscountIntoList,
|
|
45
49
|
mergeRelationForms: () => mergeRelationForms,
|
|
46
50
|
normalizeBookingIsAll: () => normalizeBookingIsAll,
|
|
47
51
|
normalizeBookingSubType: () => normalizeBookingSubType,
|
|
52
|
+
normalizeOrderProductDiscountList: () => normalizeOrderProductDiscountList,
|
|
48
53
|
normalizeSubmitBooking: () => normalizeSubmitBooking,
|
|
49
54
|
normalizeSubmitCollectPaxValue: () => normalizeSubmitCollectPaxValue,
|
|
55
|
+
resolveManualDiscountMessage: () => import_manualProductDiscount.resolveManualDiscountMessage,
|
|
56
|
+
resolveManualDiscountOriginTotal: () => import_manualProductDiscount.resolveManualDiscountOriginTotal,
|
|
57
|
+
resolveManualDiscountReasonFromSources: () => import_manualProductDiscount.resolveManualDiscountReasonFromSources,
|
|
58
|
+
resolveManualOverrideLineOriginalPrice: () => resolveManualOverrideLineOriginalPrice,
|
|
59
|
+
resolveRulesManualDiscountFlag: () => resolveRulesManualDiscountFlag,
|
|
60
|
+
resolveSafeProductNum: () => import_manualProductDiscount.resolveSafeProductNum,
|
|
50
61
|
resolveSubmitCollectPax: () => resolveSubmitCollectPax,
|
|
51
|
-
|
|
62
|
+
shouldBuildManualProductDiscount: () => import_manualProductDiscount.shouldBuildManualProductDiscount,
|
|
63
|
+
stripManualProductDiscountItems: () => import_manualProductDiscount.stripManualProductDiscountItems,
|
|
64
|
+
sumOptionUnitPrice: () => sumOptionUnitPrice,
|
|
65
|
+
syncManualProductDiscountProductNum: () => import_manualProductDiscount.syncManualProductDiscountProductNum
|
|
52
66
|
});
|
|
53
67
|
module.exports = __toCommonJS(utils_exports);
|
|
54
68
|
var import_dayjs = __toESM(require("dayjs"));
|
|
55
69
|
var import_decimal = __toESM(require("decimal.js"));
|
|
56
70
|
var import_utils = require("../../solution/ScanOrder/utils");
|
|
57
71
|
var import_utils2 = require("../../solution/ScanOrder/utils");
|
|
72
|
+
var import_manualProductDiscount = require("./utils/manualProductDiscount");
|
|
58
73
|
function composeLinePrice(params) {
|
|
59
74
|
const { mainPrice, bundle, useOriginalBundle } = params;
|
|
60
75
|
let total = new import_decimal.default(Number(mainPrice) || 0);
|
|
@@ -80,6 +95,78 @@ function sumOptionUnitPrice(options) {
|
|
|
80
95
|
}
|
|
81
96
|
return total;
|
|
82
97
|
}
|
|
98
|
+
function resolveRulesManualDiscountFlag(metadata) {
|
|
99
|
+
if (!metadata)
|
|
100
|
+
return void 0;
|
|
101
|
+
if (metadata.is_manual_discount === true || metadata.is_manual_discount === 1) {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
const priceOverride = metadata.price_override;
|
|
105
|
+
if (priceOverride !== void 0 && priceOverride !== null && priceOverride !== "") {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
return void 0;
|
|
109
|
+
}
|
|
110
|
+
function normalizeOrderProductDiscountAmount(amount) {
|
|
111
|
+
if (amount === void 0 || amount === null)
|
|
112
|
+
return void 0;
|
|
113
|
+
return String(amount);
|
|
114
|
+
}
|
|
115
|
+
function normalizeOrderProductDiscountList(discountList) {
|
|
116
|
+
if (!Array.isArray(discountList))
|
|
117
|
+
return [];
|
|
118
|
+
return discountList.filter((item) => !!item && typeof item === "object").map((item) => {
|
|
119
|
+
const normalized = {
|
|
120
|
+
discount_id: Number.isFinite(Number(item.discount_id)) ? Number(item.discount_id) : 0
|
|
121
|
+
};
|
|
122
|
+
if (item.order_discount_id === null) {
|
|
123
|
+
normalized.order_discount_id = null;
|
|
124
|
+
} else if (item.order_discount_id !== void 0) {
|
|
125
|
+
const orderDiscountId = Number(item.order_discount_id);
|
|
126
|
+
if (Number.isFinite(orderDiscountId)) {
|
|
127
|
+
normalized.order_discount_id = orderDiscountId;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (item.type !== void 0)
|
|
131
|
+
normalized.type = item.type;
|
|
132
|
+
const amount = normalizeOrderProductDiscountAmount(item.amount);
|
|
133
|
+
if (amount !== void 0)
|
|
134
|
+
normalized.amount = amount;
|
|
135
|
+
if (item.discount && typeof item.discount === "object") {
|
|
136
|
+
normalized.discount = { ...item.discount };
|
|
137
|
+
}
|
|
138
|
+
if (item.metadata === null) {
|
|
139
|
+
normalized.metadata = null;
|
|
140
|
+
} else if (item.metadata && typeof item.metadata === "object") {
|
|
141
|
+
normalized.metadata = { ...item.metadata };
|
|
142
|
+
}
|
|
143
|
+
return normalized;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function resolveManualOverrideLineOriginalPrice(params, fallbackCompositeOriginal) {
|
|
147
|
+
var _a, _b;
|
|
148
|
+
const metadata = params.metadata || {};
|
|
149
|
+
const priceOverride = metadata.price_override;
|
|
150
|
+
if (priceOverride === void 0 || priceOverride === null || priceOverride === "") {
|
|
151
|
+
return fallbackCompositeOriginal;
|
|
152
|
+
}
|
|
153
|
+
const refTotal = (_b = (_a = metadata.origin) == null ? void 0 : _a._extend) == null ? void 0 : _b.origin_total;
|
|
154
|
+
if (refTotal !== void 0 && refTotal !== null && refTotal !== "") {
|
|
155
|
+
const parsed = Number(refTotal);
|
|
156
|
+
if (Number.isFinite(parsed)) {
|
|
157
|
+
return new import_decimal.default(parsed).toDecimalPlaces(2).toFixed(2);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const lineOriginal = params.lineOriginalPrice;
|
|
161
|
+
if (lineOriginal !== void 0 && lineOriginal !== null && lineOriginal !== "") {
|
|
162
|
+
const parsedLine = Number(lineOriginal);
|
|
163
|
+
const parsedFallback = Number(fallbackCompositeOriginal);
|
|
164
|
+
if (Number.isFinite(parsedLine) && Number.isFinite(parsedFallback) && parsedLine > parsedFallback) {
|
|
165
|
+
return new import_decimal.default(parsedLine).toDecimalPlaces(2).toFixed(2);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return fallbackCompositeOriginal;
|
|
169
|
+
}
|
|
83
170
|
function createDefaultOrderRulesHooks() {
|
|
84
171
|
const toUnitPriceString = (totalLike, num) => {
|
|
85
172
|
const effectiveNum = Number(num) > 0 ? Number(num) : 1;
|
|
@@ -87,7 +174,7 @@ function createDefaultOrderRulesHooks() {
|
|
|
87
174
|
};
|
|
88
175
|
return {
|
|
89
176
|
getProduct: (product) => {
|
|
90
|
-
var _a, _b, _c, _d, _e
|
|
177
|
+
var _a, _b, _c, _d, _e;
|
|
91
178
|
const metadataAny = product.metadata || {};
|
|
92
179
|
const optionSum = sumOptionUnitPrice(product.product_option_item);
|
|
93
180
|
let sourcePrice;
|
|
@@ -135,9 +222,11 @@ function createDefaultOrderRulesHooks() {
|
|
|
135
222
|
bundle: product.product_bundle || [],
|
|
136
223
|
booking_id: ((_b = product.metadata) == null ? void 0 : _b.booking_id) || null,
|
|
137
224
|
isClient: false,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
225
|
+
// 勿写死 false:否则 Rules 不会走 total≠origin_total 的手动价推断,
|
|
226
|
+
// 无券时会把 bundle 价还原成 original_price(手动改价套餐会从 20 回到 30)。
|
|
227
|
+
isManualDiscount: resolveRulesManualDiscountFlag(metadataAny),
|
|
228
|
+
holder_id: (_c = product.metadata) == null ? void 0 : _c.holder_id,
|
|
229
|
+
startDate: ((_d = product.metadata) == null ? void 0 : _d.start_date) || ((_e = product.metadata) == null ? void 0 : _e.startDate)
|
|
141
230
|
};
|
|
142
231
|
},
|
|
143
232
|
setProduct: (product, values) => {
|
|
@@ -160,10 +249,14 @@ function createDefaultOrderRulesHooks() {
|
|
|
160
249
|
bundle: nextBundle,
|
|
161
250
|
useOriginalBundle: true
|
|
162
251
|
});
|
|
252
|
+
const finalOriginalPrice = resolveManualOverrideLineOriginalPrice(
|
|
253
|
+
{ num: nextNum, metadata: metadataAny, lineOriginalPrice: product.original_price },
|
|
254
|
+
composedOriginalPrice
|
|
255
|
+
);
|
|
163
256
|
return {
|
|
164
257
|
...product,
|
|
165
258
|
selling_price: composedSellingPrice,
|
|
166
|
-
original_price:
|
|
259
|
+
original_price: finalOriginalPrice,
|
|
167
260
|
discount_list: values.discount_list ?? product.discount_list,
|
|
168
261
|
num: values.quantity ?? product.num,
|
|
169
262
|
product_bundle: nextBundle,
|
|
@@ -321,6 +414,11 @@ function normalizeSubmitProduct(product) {
|
|
|
321
414
|
num,
|
|
322
415
|
product_option_item: productOptionItem,
|
|
323
416
|
surcharge_fee: _productSurchargeFee,
|
|
417
|
+
discount_amount: _deprecatedDiscountAmount,
|
|
418
|
+
discount_type: _deprecatedDiscountType,
|
|
419
|
+
discountway: _deprecatedDiscountway,
|
|
420
|
+
product_discount_reason: _deprecatedProductDiscountReason,
|
|
421
|
+
discount_per: _deprecatedDiscountPer,
|
|
324
422
|
...productRest
|
|
325
423
|
} = submitProduct;
|
|
326
424
|
const rawMetadata = submitProduct.metadata || {};
|
|
@@ -365,7 +463,7 @@ function normalizeSubmitProduct(product) {
|
|
|
365
463
|
...bookingUid ? { booking_uid: bookingUid } : {},
|
|
366
464
|
product_quantity: toBundleNumber(num ?? submitProduct.product_quantity, 1),
|
|
367
465
|
product_sku: productSku,
|
|
368
|
-
discount_list: submitProduct.discount_list
|
|
466
|
+
discount_list: normalizeOrderProductDiscountList(submitProduct.discount_list),
|
|
369
467
|
product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
|
|
370
468
|
metadata: cleanMetadata,
|
|
371
469
|
// 出站兼容:后端消费 payment_price 字段,这里从 selling_price 直接派生。
|
|
@@ -425,22 +523,23 @@ function createDefaultTempOrder(params) {
|
|
|
425
523
|
return {
|
|
426
524
|
order_id: null,
|
|
427
525
|
external_sale_number: "",
|
|
428
|
-
order_number:
|
|
429
|
-
shop_order_number:
|
|
430
|
-
shop_full_order_number:
|
|
431
|
-
type: "
|
|
432
|
-
business_code:
|
|
526
|
+
order_number: null,
|
|
527
|
+
shop_order_number: null,
|
|
528
|
+
shop_full_order_number: null,
|
|
529
|
+
type: "",
|
|
530
|
+
business_code: void 0,
|
|
433
531
|
platform: "h5",
|
|
434
532
|
sales_channel: "my_pisel",
|
|
435
533
|
order_sales_channel: "online_store",
|
|
436
534
|
status: "normal",
|
|
437
535
|
payment_status: "payment_processing",
|
|
438
536
|
shipping_status: "unfulfilled",
|
|
439
|
-
customer_id:
|
|
537
|
+
customer_id: 0,
|
|
440
538
|
customer_name: "",
|
|
441
539
|
country_calling_code: "",
|
|
442
540
|
phone: "",
|
|
443
541
|
email: "",
|
|
542
|
+
customer: null,
|
|
444
543
|
is_price_include_tax: 1,
|
|
445
544
|
tax_title: "",
|
|
446
545
|
tax_country_code: "",
|
|
@@ -459,7 +558,6 @@ function createDefaultTempOrder(params) {
|
|
|
459
558
|
bookings: [],
|
|
460
559
|
payments: [],
|
|
461
560
|
surcharges: [],
|
|
462
|
-
discount_list: [],
|
|
463
561
|
relation_forms: [],
|
|
464
562
|
contacts: [],
|
|
465
563
|
contacts_info: null,
|
|
@@ -471,6 +569,7 @@ function createDefaultTempOrder(params) {
|
|
|
471
569
|
};
|
|
472
570
|
}
|
|
473
571
|
function buildSubmitPayload(params) {
|
|
572
|
+
var _a;
|
|
474
573
|
const {
|
|
475
574
|
tempOrder,
|
|
476
575
|
cacheId,
|
|
@@ -496,7 +595,7 @@ function buildSubmitPayload(params) {
|
|
|
496
595
|
shop_service_type: _shopServiceType,
|
|
497
596
|
start_time: _startTime,
|
|
498
597
|
customer: _customer,
|
|
499
|
-
|
|
598
|
+
discount_list: _discountList,
|
|
500
599
|
tax_fee: _rootTaxFee,
|
|
501
600
|
total_amount: _totalAmount,
|
|
502
601
|
total_refund_amount: _totalRefundAmount,
|
|
@@ -504,12 +603,24 @@ function buildSubmitPayload(params) {
|
|
|
504
603
|
holder_id: _holderId,
|
|
505
604
|
...tempOrderRest
|
|
506
605
|
} = tempOrder;
|
|
606
|
+
let submitType = type ?? tempOrder.type;
|
|
607
|
+
if (!submitType) {
|
|
608
|
+
if ((_a = tempOrder == null ? void 0 : tempOrder.bookings) == null ? void 0 : _a.length) {
|
|
609
|
+
submitType = "appointment_booking";
|
|
610
|
+
} else {
|
|
611
|
+
submitType = "virtual";
|
|
612
|
+
}
|
|
613
|
+
}
|
|
507
614
|
const payload = {
|
|
508
615
|
...tempOrderRest,
|
|
616
|
+
customer_id: tempOrder.customer_id ?? 0,
|
|
617
|
+
order_number: null,
|
|
618
|
+
shop_order_number: null,
|
|
619
|
+
shop_full_order_number: null,
|
|
509
620
|
platform: normalizeSubmitPlatform(platform),
|
|
510
621
|
request_unique_idempotency_token: tempOrder.request_unique_idempotency_token || `${tempOrder.external_sale_number}_${now.getTime()}`,
|
|
511
|
-
type:
|
|
512
|
-
business_code: businessCode ?? tempOrder.business_code
|
|
622
|
+
type: submitType,
|
|
623
|
+
business_code: businessCode ?? tempOrder.business_code,
|
|
513
624
|
sales_channel: tempOrder.sales_channel || "my_pisel",
|
|
514
625
|
order_sales_channel: channel ?? tempOrder.order_sales_channel ?? "online_store",
|
|
515
626
|
status: tempOrder.status || "normal",
|
|
@@ -524,12 +635,11 @@ function buildSubmitPayload(params) {
|
|
|
524
635
|
note: tempOrder.note || "",
|
|
525
636
|
delivery_type: tempOrder.delivery_type || "nil",
|
|
526
637
|
schedule_date: scheduleDate,
|
|
527
|
-
created_at: tempOrder.created_at || formatDateTime(now),
|
|
638
|
+
// created_at: tempOrder.created_at || formatDateTime(now), 和后端协定这个字段先不提交到接口
|
|
528
639
|
bookings: (tempOrder.bookings || []).filter(
|
|
529
|
-
(booking) => Number(booking.parent_id
|
|
640
|
+
(booking) => Number(booking.parent_id) !== 0
|
|
530
641
|
).map((booking) => normalizeSubmitBooking(booking)),
|
|
531
642
|
payments: tempOrder.payments || [],
|
|
532
|
-
// discount_list: tempOrder.discount_list || [],
|
|
533
643
|
relation_forms: tempOrder.relation_forms || [],
|
|
534
644
|
// contacts: tempOrder.contacts || [],
|
|
535
645
|
contacts_info: tempOrder.contacts_info && !Array.isArray(tempOrder.contacts_info) ? tempOrder.contacts_info : null,
|
|
@@ -612,12 +722,15 @@ function formatV1Product(products) {
|
|
|
612
722
|
}
|
|
613
723
|
// Annotate the CommonJS export names for ESM import in node:
|
|
614
724
|
0 && (module.exports = {
|
|
725
|
+
buildManualProductDiscountItem,
|
|
615
726
|
buildSubmitPayload,
|
|
616
727
|
composeLinePrice,
|
|
617
728
|
createDefaultOrderRulesHooks,
|
|
618
729
|
createDefaultTempOrder,
|
|
619
730
|
createEmptySummary,
|
|
620
731
|
createUuidV4,
|
|
732
|
+
ensureManualProductDiscountList,
|
|
733
|
+
findManualProductDiscountItem,
|
|
621
734
|
formatDateTime,
|
|
622
735
|
formatV1Product,
|
|
623
736
|
generateDuration,
|
|
@@ -625,11 +738,22 @@ function formatV1Product(products) {
|
|
|
625
738
|
isTempOrder,
|
|
626
739
|
mapPaymentItemToOrderPayment,
|
|
627
740
|
mapPaymentItemsToOrderPayments,
|
|
741
|
+
mergeManualProductDiscountIntoList,
|
|
628
742
|
mergeRelationForms,
|
|
629
743
|
normalizeBookingIsAll,
|
|
630
744
|
normalizeBookingSubType,
|
|
745
|
+
normalizeOrderProductDiscountList,
|
|
631
746
|
normalizeSubmitBooking,
|
|
632
747
|
normalizeSubmitCollectPaxValue,
|
|
748
|
+
resolveManualDiscountMessage,
|
|
749
|
+
resolveManualDiscountOriginTotal,
|
|
750
|
+
resolveManualDiscountReasonFromSources,
|
|
751
|
+
resolveManualOverrideLineOriginalPrice,
|
|
752
|
+
resolveRulesManualDiscountFlag,
|
|
753
|
+
resolveSafeProductNum,
|
|
633
754
|
resolveSubmitCollectPax,
|
|
634
|
-
|
|
755
|
+
shouldBuildManualProductDiscount,
|
|
756
|
+
stripManualProductDiscountItems,
|
|
757
|
+
sumOptionUnitPrice,
|
|
758
|
+
syncManualProductDiscountProductNum
|
|
635
759
|
});
|
|
@@ -74,9 +74,11 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
|
|
|
74
74
|
getPriceForProduct(params) {
|
|
75
75
|
const { productId, variantId, datetime, customer_id } = params;
|
|
76
76
|
for (const quotation of this.store.list) {
|
|
77
|
-
|
|
77
|
+
const visible = this.isQuotationVisibleForCustomer(quotation, customer_id);
|
|
78
|
+
if (!visible)
|
|
78
79
|
continue;
|
|
79
|
-
|
|
80
|
+
const active = this.isQuotationActiveAt(quotation, datetime);
|
|
81
|
+
if (!active)
|
|
80
82
|
continue;
|
|
81
83
|
const match = this.findProductData(quotation.product_data, productId, variantId);
|
|
82
84
|
if (!match)
|
|
@@ -148,18 +150,27 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
|
|
|
148
150
|
var _a;
|
|
149
151
|
if (!((_a = quotation.schedule) == null ? void 0 : _a.length))
|
|
150
152
|
return false;
|
|
151
|
-
const scheduleItems =
|
|
153
|
+
const scheduleItems = [];
|
|
154
|
+
quotation.schedule.forEach((s) => {
|
|
152
155
|
var _a2;
|
|
153
156
|
const full = (_a2 = this.scheduleResolver) == null ? void 0 : _a2.call(this, s.id);
|
|
154
|
-
if (full)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
+
if (full) {
|
|
158
|
+
scheduleItems.push(full);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (this.scheduleResolver) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const fallbackSchedule = {
|
|
157
165
|
...s,
|
|
158
166
|
repeat_type: s.repeat_type || "none",
|
|
159
167
|
repeat_rule: s.repeat_rule || null,
|
|
160
168
|
time_slot: s.time_slot || []
|
|
161
169
|
};
|
|
170
|
+
scheduleItems.push(fallbackSchedule);
|
|
162
171
|
});
|
|
172
|
+
if (!scheduleItems.length)
|
|
173
|
+
return false;
|
|
163
174
|
return (0, import_getDateIsInSchedule.getDateIsInSchedule)(datetime, scheduleItems);
|
|
164
175
|
}
|
|
165
176
|
findProductData(productData, productId, variantId) {
|
|
@@ -32,6 +32,10 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
32
32
|
unavailableReason?: UnavailableReason;
|
|
33
33
|
};
|
|
34
34
|
filterDiscountListByType(discountList: Discount[], type: string): Discount[];
|
|
35
|
+
/** 剔除指定 type/tag 的折扣项,保留手动改价(type=product) / 券等 */
|
|
36
|
+
excludeDiscountListByType(discountList: Discount[], type: string): Discount[];
|
|
37
|
+
/** 手动改价场景:去掉 promotion,保留 type=product 等行内折扣 */
|
|
38
|
+
resolveDiscountListForManualOverride(discountList: Discount[]): Discount[];
|
|
35
39
|
private getUnavailableReason;
|
|
36
40
|
calcDiscount({ discountList, productList, holders, isFormSubject, orderTotalAmount }: {
|
|
37
41
|
discountList: Discount[];
|
|
@@ -159,6 +159,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
159
159
|
filterDiscountListByType(discountList, type) {
|
|
160
160
|
return (discountList || []).filter((item) => item.type === type || item.tag === type);
|
|
161
161
|
}
|
|
162
|
+
/** 剔除指定 type/tag 的折扣项,保留手动改价(type=product) / 券等 */
|
|
163
|
+
excludeDiscountListByType(discountList, type) {
|
|
164
|
+
return (discountList || []).filter((item) => item.type !== type && item.tag !== type);
|
|
165
|
+
}
|
|
166
|
+
/** 手动改价场景:去掉 promotion,保留 type=product 等行内折扣 */
|
|
167
|
+
resolveDiscountListForManualOverride(discountList) {
|
|
168
|
+
return this.excludeDiscountListByType(discountList, "promotion");
|
|
169
|
+
}
|
|
162
170
|
// 获取券不可用的原因
|
|
163
171
|
getUnavailableReason(discountList, productList) {
|
|
164
172
|
var _a;
|
|
@@ -673,7 +681,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
673
681
|
}, 0);
|
|
674
682
|
};
|
|
675
683
|
sortedFlattenedList.forEach((flatItem, index) => {
|
|
676
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
|
|
684
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G;
|
|
677
685
|
let product, originProduct;
|
|
678
686
|
if (flatItem.type === "main") {
|
|
679
687
|
product = flatItem.product;
|
|
@@ -896,7 +904,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
896
904
|
price: product.price,
|
|
897
905
|
options: restoredOptions
|
|
898
906
|
},
|
|
899
|
-
discount_list: this.filterDiscountListByType(product.discount_list, "promotion")
|
|
907
|
+
discount_list: isManualDiscount ? this.resolveDiscountListForManualOverride(product.discount_list) : this.filterDiscountListByType(product.discount_list, "promotion")
|
|
900
908
|
})
|
|
901
909
|
]);
|
|
902
910
|
} else {
|
|
@@ -918,14 +926,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
918
926
|
main_product_selling_price,
|
|
919
927
|
options: restoredOptions
|
|
920
928
|
},
|
|
921
|
-
discount_list: this.filterDiscountListByType(product.discount_list, "promotion")
|
|
929
|
+
discount_list: isManualDiscount ? this.resolveDiscountListForManualOverride(product.discount_list) : this.filterDiscountListByType(product.discount_list, "promotion")
|
|
922
930
|
})
|
|
923
931
|
]);
|
|
924
932
|
}
|
|
925
933
|
} else {
|
|
926
934
|
processedFlatItemsMap.set(flatItem._id, [{
|
|
927
935
|
...flatItem,
|
|
928
|
-
discount_list: this.
|
|
936
|
+
discount_list: isManualDiscount ? this.resolveDiscountListForManualOverride(((_v = flatItem.bundleItem) == null ? void 0 : _v.discount_list) || []) : this.filterDiscountListByType(((_w = flatItem.bundleItem) == null ? void 0 : _w.discount_list) || [], "promotion"),
|
|
929
937
|
price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
|
|
930
938
|
processed: true
|
|
931
939
|
}]);
|
|
@@ -976,13 +984,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
976
984
|
if (this.filterDiscountListByType(product.discount_list, "promotion").length && product.origin_total) {
|
|
977
985
|
productOriginTotal = product.origin_total;
|
|
978
986
|
}
|
|
979
|
-
if (Number(((
|
|
987
|
+
if (Number(((_x = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _x.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
|
|
980
988
|
productOriginTotal = product.total;
|
|
981
989
|
}
|
|
982
990
|
const isOrderLevel = (0, import_utils3.isOrderLevelFixedAmountDiscount)(selectedDiscount2);
|
|
983
991
|
const orderLevelAllocation = isOrderLevel ? orderLevelDiscountAllocations.get(selectedDiscount2.id) : null;
|
|
984
992
|
const productAllocation = orderLevelAllocation == null ? void 0 : orderLevelAllocation.get(flatItem._id);
|
|
985
|
-
const isDeductOptionPrice = !!((
|
|
993
|
+
const isDeductOptionPrice = !!((_y = selectedDiscount2.config) == null ? void 0 : _y.deductOptionPrice);
|
|
986
994
|
let mainProductSellingPrice;
|
|
987
995
|
let amount;
|
|
988
996
|
let productDiscountDifference;
|
|
@@ -1000,7 +1008,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1000
1008
|
);
|
|
1001
1009
|
amount = new import_decimal.default(product.price).minus(new import_decimal.default(mainProductSellingPrice)).toNumber();
|
|
1002
1010
|
}
|
|
1003
|
-
if (isDeductOptionPrice && ((
|
|
1011
|
+
if (isDeductOptionPrice && ((_z = product.options) == null ? void 0 : _z.length)) {
|
|
1004
1012
|
const optionResult = applyDiscountToOptions(
|
|
1005
1013
|
product.options,
|
|
1006
1014
|
selectedDiscount2
|
|
@@ -1008,7 +1016,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1008
1016
|
discountedOptions = optionResult.discountedOptions;
|
|
1009
1017
|
optionDiscountAmount = optionResult.optionDiscountAmount;
|
|
1010
1018
|
}
|
|
1011
|
-
const optionsForLineTotal = isDeductOptionPrice && ((
|
|
1019
|
+
const optionsForLineTotal = isDeductOptionPrice && ((_A = product.options) == null ? void 0 : _A.length) ? discountedOptions : product.options;
|
|
1012
1020
|
const optionsLineTotal = getOptionTotal(optionsForLineTotal || []);
|
|
1013
1021
|
const total = new import_decimal.default(mainProductSellingPrice).plus(optionsLineTotal).toNumber();
|
|
1014
1022
|
const mainProductDiscountAmount = amount;
|
|
@@ -1019,9 +1027,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1019
1027
|
amount: lineDiscountAmount,
|
|
1020
1028
|
type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : discountType,
|
|
1021
1029
|
discount: {
|
|
1022
|
-
discount_card_type: (
|
|
1030
|
+
discount_card_type: (_B = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _B.discount_card_type,
|
|
1023
1031
|
fixed_amount: lineDiscountAmount,
|
|
1024
|
-
discount_calculation_mode: (
|
|
1032
|
+
discount_calculation_mode: (_C = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _C.discount_calculation_mode,
|
|
1025
1033
|
resource_id: selectedDiscount2.id,
|
|
1026
1034
|
title: selectedDiscount2.format_title,
|
|
1027
1035
|
original_amount: product.price,
|
|
@@ -1103,7 +1111,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1103
1111
|
type: "good_pass",
|
|
1104
1112
|
discount: {
|
|
1105
1113
|
fixed_amount: product.origin_total,
|
|
1106
|
-
discount_calculation_mode: (
|
|
1114
|
+
discount_calculation_mode: (_D = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _D.discount_calculation_mode,
|
|
1107
1115
|
resource_id: selectedDiscount2.id,
|
|
1108
1116
|
title: selectedDiscount2.format_title,
|
|
1109
1117
|
original_amount: product.origin_total,
|
|
@@ -1177,9 +1185,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1177
1185
|
amount: fixedAmountPerItem * (product.num || 1),
|
|
1178
1186
|
type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag,
|
|
1179
1187
|
discount: {
|
|
1180
|
-
discount_card_type: (
|
|
1188
|
+
discount_card_type: (_E = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _E.discount_card_type,
|
|
1181
1189
|
fixed_amount: fixedAmountPerItem,
|
|
1182
|
-
discount_calculation_mode: (
|
|
1190
|
+
discount_calculation_mode: (_F = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _F.discount_calculation_mode,
|
|
1183
1191
|
resource_id: selectedDiscount2.id,
|
|
1184
1192
|
title: selectedDiscount2.format_title,
|
|
1185
1193
|
original_amount: product.original_price,
|
|
@@ -1195,7 +1203,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1195
1203
|
...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference }
|
|
1196
1204
|
},
|
|
1197
1205
|
config: selectedDiscount2 == null ? void 0 : selectedDiscount2.config,
|
|
1198
|
-
_num: (product.num || 1) * (((
|
|
1206
|
+
_num: (product.num || 1) * (((_G = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _G.num) || 1)
|
|
1199
1207
|
};
|
|
1200
1208
|
const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
|
|
1201
1209
|
appliedProducts.push(discountDetail);
|
|
@@ -30,7 +30,8 @@ __reExport(SalesSummary_exports, require("./types"), module.exports);
|
|
|
30
30
|
var salesSummaryDataKeys = {
|
|
31
31
|
isPriceIncludeTax: "is_price_include_tax",
|
|
32
32
|
taxRate: "tax_rate",
|
|
33
|
-
taxTitle: "tax_title"
|
|
33
|
+
taxTitle: "tax_title",
|
|
34
|
+
taxCountryCode: "tax_country_code"
|
|
34
35
|
};
|
|
35
36
|
var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
36
37
|
constructor(name, version) {
|
|
@@ -84,7 +85,8 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
84
85
|
return {
|
|
85
86
|
isPriceIncludeTax: this.getAppData(salesSummaryDataKeys.isPriceIncludeTax),
|
|
86
87
|
taxRate: this.getAppData(salesSummaryDataKeys.taxRate),
|
|
87
|
-
taxTitle: this.getAppData(salesSummaryDataKeys.taxTitle)
|
|
88
|
+
taxTitle: this.getAppData(salesSummaryDataKeys.taxTitle),
|
|
89
|
+
taxCountryCode: this.getAppData(salesSummaryDataKeys.taxCountryCode)
|
|
88
90
|
};
|
|
89
91
|
}
|
|
90
92
|
async getSummary(params) {
|
|
@@ -135,7 +135,9 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
|
135
135
|
return dates;
|
|
136
136
|
}
|
|
137
137
|
getScheduleListByIds(ids) {
|
|
138
|
-
|
|
138
|
+
const idSet = new Set(ids.map((id) => String(id)));
|
|
139
|
+
const list = this.store.scheduleList.filter((n) => idSet.has(String(n.id)));
|
|
140
|
+
return list;
|
|
139
141
|
}
|
|
140
142
|
setAvailabilityScheduleDateList(list) {
|
|
141
143
|
this.store.availabilityDateList = list;
|
package/lib/modules/index.d.ts
CHANGED
package/lib/modules/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __reExport(modules_exports, require("./Schedule"), module.exports);
|
|
|
34
34
|
__reExport(modules_exports, require("./Quotation"), module.exports);
|
|
35
35
|
__reExport(modules_exports, require("./ScanOrderLogger"), module.exports);
|
|
36
36
|
__reExport(modules_exports, require("./OpenData"), module.exports);
|
|
37
|
+
__reExport(modules_exports, require("./BookingContext"), module.exports);
|
|
37
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
38
39
|
0 && (module.exports = {
|
|
39
40
|
...require("./Product"),
|
|
@@ -53,5 +54,6 @@ __reExport(modules_exports, require("./OpenData"), module.exports);
|
|
|
53
54
|
...require("./Schedule"),
|
|
54
55
|
...require("./Quotation"),
|
|
55
56
|
...require("./ScanOrderLogger"),
|
|
56
|
-
...require("./OpenData")
|
|
57
|
+
...require("./OpenData"),
|
|
58
|
+
...require("./BookingContext")
|
|
57
59
|
});
|
package/lib/server/index.js
CHANGED
|
@@ -931,6 +931,8 @@ var Server = class {
|
|
|
931
931
|
return;
|
|
932
932
|
}
|
|
933
933
|
try {
|
|
934
|
+
await this.schedule.loadAllSchedule();
|
|
935
|
+
this.products.clearPriceCache();
|
|
934
936
|
await this.products.setupQuotationPriceBridge({
|
|
935
937
|
scheduleModule: this.schedule,
|
|
936
938
|
channel: (_a = this.core.context) == null ? void 0 : _a.channel
|
|
@@ -33,6 +33,13 @@ __export(filterOrders_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(filterOrders_exports);
|
|
35
35
|
var import_dayjs = __toESM(require("dayjs"));
|
|
36
|
+
function getOrderPaymentCodes(order) {
|
|
37
|
+
const payments = order.payments;
|
|
38
|
+
if (!Array.isArray(payments) || payments.length === 0) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
return payments.map((item) => item == null ? void 0 : item.code).filter((code) => typeof code === "string" && code.length > 0);
|
|
42
|
+
}
|
|
36
43
|
function filterOrders(orders, filters) {
|
|
37
44
|
const safeFilters = filters || {};
|
|
38
45
|
if (!orders || !Array.isArray(orders)) {
|
|
@@ -133,26 +140,27 @@ function filterOrders(orders, filters) {
|
|
|
133
140
|
}
|
|
134
141
|
}
|
|
135
142
|
if (safeFilters.payment_methods && safeFilters.payment_methods.length > 0) {
|
|
136
|
-
|
|
143
|
+
const orderPaymentCodes = getOrderPaymentCodes(order);
|
|
144
|
+
if (orderPaymentCodes.length === 0) {
|
|
137
145
|
rejected.push({
|
|
138
146
|
order_id: order.order_id,
|
|
139
147
|
order_number: order.order_number,
|
|
140
148
|
reason: {
|
|
141
149
|
field: "payment_methods",
|
|
142
|
-
actual: order.
|
|
150
|
+
actual: order.payments,
|
|
143
151
|
expected: safeFilters.payment_methods
|
|
144
152
|
}
|
|
145
153
|
});
|
|
146
154
|
return false;
|
|
147
155
|
}
|
|
148
|
-
const hasMatch =
|
|
156
|
+
const hasMatch = orderPaymentCodes.some((code) => safeFilters.payment_methods.includes(code));
|
|
149
157
|
if (!hasMatch) {
|
|
150
158
|
rejected.push({
|
|
151
159
|
order_id: order.order_id,
|
|
152
160
|
order_number: order.order_number,
|
|
153
161
|
reason: {
|
|
154
162
|
field: "payment_methods",
|
|
155
|
-
actual:
|
|
163
|
+
actual: orderPaymentCodes,
|
|
156
164
|
expected: safeFilters.payment_methods
|
|
157
165
|
}
|
|
158
166
|
});
|
|
@@ -177,7 +177,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
177
177
|
* Server 层负责传入完整 schedule 模块,Products 只负责把报价单计算结果转成价格响应形状。
|
|
178
178
|
*/
|
|
179
179
|
async setupQuotationPriceBridge(params) {
|
|
180
|
-
var _a
|
|
180
|
+
var _a;
|
|
181
181
|
if (!this.core) {
|
|
182
182
|
this.logWarning("setupQuotationPriceBridge: core 尚未初始化");
|
|
183
183
|
return;
|
|
@@ -190,15 +190,14 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
190
190
|
this.quotationPriceBridge = quotation;
|
|
191
191
|
}
|
|
192
192
|
if (params.scheduleModule) {
|
|
193
|
-
const scheduleList = ((_c = (_b = params.scheduleModule).getScheduleList) == null ? void 0 : _c.call(_b)) || [];
|
|
194
|
-
const scheduleMap = new Map(
|
|
195
|
-
scheduleList.map((schedule) => [schedule.id, schedule])
|
|
196
|
-
);
|
|
197
193
|
this.quotationPriceBridge.setScheduleResolver((id) => {
|
|
198
|
-
var _a2,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const
|
|
194
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
195
|
+
const scheduleId = String(id);
|
|
196
|
+
const scheduleList = ((_b = (_a2 = params.scheduleModule).getScheduleList) == null ? void 0 : _b.call(_a2)) || [];
|
|
197
|
+
const schedule = scheduleList.find((item) => String(item.id) === scheduleId);
|
|
198
|
+
if (schedule)
|
|
199
|
+
return schedule;
|
|
200
|
+
const schedules = ((_d = (_c = params.scheduleModule).getScheduleListByIds) == null ? void 0 : _d.call(_c, [id])) || ((_f = (_e = params.scheduleModule).getScheduleByIds) == null ? void 0 : _f.call(_e, [id])) || [];
|
|
202
201
|
return schedules[0];
|
|
203
202
|
});
|
|
204
203
|
}
|
|
@@ -183,8 +183,9 @@ var ScheduleModuleEx = class extends import_BaseModule.BaseModule {
|
|
|
183
183
|
return [];
|
|
184
184
|
}
|
|
185
185
|
const result = [];
|
|
186
|
+
const scheduleList = this.store.scheduleList || [];
|
|
186
187
|
for (const id of ids) {
|
|
187
|
-
const schedule = this.store.map.get(id);
|
|
188
|
+
const schedule = this.store.map.get(id) || scheduleList.find((item) => String(item.id) === String(id));
|
|
188
189
|
if (schedule) {
|
|
189
190
|
result.push(schedule);
|
|
190
191
|
}
|