@pisell/pisellos 2.3.73 → 2.3.75
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/core/index.d.ts +7 -0
- package/dist/core/index.js +111 -71
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/example.js +3 -26
- package/dist/model/strategy/strategy-example.js +5 -19
- package/dist/modules/Cart/index.js +0 -3
- package/dist/modules/Cart/utils/cartProduct.js +0 -1
- package/dist/modules/Date/index.js +1 -5
- package/dist/modules/Discount/index.js +2 -4
- package/dist/modules/OpenData/index.js +0 -2
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +36 -64
- package/dist/modules/Payment/index.js +97 -162
- package/dist/modules/Quotation/index.d.ts +6 -0
- package/dist/modules/Quotation/index.js +75 -19
- package/dist/modules/Rules/index.js +1 -4
- package/dist/modules/Schedule/index.js +0 -1
- package/dist/modules/Schedule/utils.js +0 -1
- package/dist/modules/Step/index.js +0 -1
- package/dist/plugins/request.d.ts +1 -0
- package/dist/plugins/request.js +1 -4
- package/dist/plugins/window.js +2 -6
- package/dist/server/index.d.ts +8 -2
- package/dist/server/index.js +303 -269
- package/dist/server/modules/floor-plan/index.d.ts +4 -0
- package/dist/server/modules/floor-plan/index.js +240 -98
- package/dist/server/modules/menu/index.js +75 -59
- package/dist/server/modules/order/index.d.ts +17 -7
- package/dist/server/modules/order/index.js +421 -211
- package/dist/server/modules/products/index.d.ts +8 -2
- package/dist/server/modules/products/index.js +191 -117
- package/dist/server/modules/quotation/index.js +29 -38
- package/dist/server/modules/resource/index.js +24 -17
- package/dist/server/modules/schedule/index.js +27 -35
- package/dist/server/utils/product.js +0 -1
- package/dist/solution/BaseSales/index.js +38 -41
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +7 -59
- package/dist/solution/BookingByStep/utils/capacity.js +1 -11
- package/dist/solution/BookingByStep/utils/resources.js +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
- package/dist/solution/BookingTicket/index.js +0 -2
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +6 -7
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
- package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
- package/dist/solution/BuyTickets/index.js +9 -12
- package/dist/solution/Checkout/index.js +177 -252
- package/dist/solution/Checkout/utils/index.js +4 -16
- package/dist/solution/RegisterAndLogin/index.js +30 -76
- package/dist/solution/ScanOrder/index.js +50 -60
- package/dist/solution/ShopDiscount/index.js +2 -7
- package/dist/solution/VenueBooking/index.js +45 -55
- package/dist/utils/task.js +15 -18
- package/dist/utils/watch.js +0 -1
- package/lib/apis/picoding.js +2 -0
- package/lib/core/index.d.ts +7 -0
- package/lib/core/index.js +149 -131
- package/lib/effects/index.js +46 -57
- package/lib/index.js +82 -49
- package/lib/model/index.js +14 -21
- package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +162 -236
- package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
- package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
- package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
- package/lib/model/strategy/adapter/index.js +100 -64
- package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
- package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
- package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
- package/lib/model/strategy/adapter/itemRule/index.js +83 -57
- package/lib/model/strategy/adapter/itemRule/type.js +97 -36
- package/lib/model/strategy/adapter/promotion/adapter.js +91 -69
- package/lib/model/strategy/adapter/promotion/evaluator.js +444 -310
- package/lib/model/strategy/adapter/promotion/examples.js +222 -234
- package/lib/model/strategy/adapter/promotion/index.js +1 -0
- package/lib/model/strategy/adapter/promotion/type.js +243 -36
- package/lib/model/strategy/adapter/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -150
- package/lib/model/strategy/adapter/walletPass/example.js +217 -190
- package/lib/model/strategy/adapter/walletPass/index.js +75 -51
- package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
- package/lib/model/strategy/adapter/walletPass/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/utils.js +588 -378
- package/lib/model/strategy/engine.js +270 -168
- package/lib/model/strategy/index.js +49 -34
- package/lib/model/strategy/strategy-example.js +243 -239
- package/lib/model/strategy/type.js +100 -40
- package/lib/modules/Account/index.js +39 -53
- package/lib/modules/Account/types.js +20 -33
- package/lib/modules/AccountList/index.js +116 -154
- package/lib/modules/AccountList/types.js +30 -31
- package/lib/modules/AccountList/utils.js +18 -30
- package/lib/modules/BaseModule.js +23 -42
- package/lib/modules/BookingContext/index.js +158 -136
- package/lib/modules/BookingContext/types.js +46 -32
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +138 -146
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +78 -83
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +170 -150
- package/lib/modules/BookingContext/utils/flexible.js +38 -55
- package/lib/modules/BookingContext/utils/formatResourceList.js +19 -34
- package/lib/modules/BookingContext/utils/index.js +124 -41
- package/lib/modules/BookingContext/utils/noResource.js +58 -70
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +14 -41
- package/lib/modules/BookingContext/utils/productExtend.js +202 -155
- package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
- package/lib/modules/BookingContext/utils/resourceSelection.js +19 -41
- package/lib/modules/BookingContext/utils/resources.js +209 -167
- package/lib/modules/BookingContext/utils/serviceTimes.js +115 -116
- package/lib/modules/BookingContext/utils/timeSlices.js +76 -86
- package/lib/modules/Cart/index.js +170 -124
- package/lib/modules/Cart/types.js +46 -51
- package/lib/modules/Cart/utils/cartAccount.js +40 -39
- package/lib/modules/Cart/utils/cartDate.js +56 -61
- package/lib/modules/Cart/utils/cartDiscount.js +28 -33
- package/lib/modules/Cart/utils/cartNote.js +27 -32
- package/lib/modules/Cart/utils/cartProduct.js +321 -251
- package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
- package/lib/modules/Cart/utils/cartResource.js +70 -78
- package/lib/modules/Cart/utils/changePrice.js +22 -50
- package/lib/modules/Cart/utils/index.js +106 -48
- package/lib/modules/Customer/constants.js +13 -34
- package/lib/modules/Customer/index.js +235 -172
- package/lib/modules/Customer/types.js +38 -35
- package/lib/modules/Date/index.js +116 -115
- package/lib/modules/Date/types.js +16 -28
- package/lib/modules/Date/utils.js +174 -123
- package/lib/modules/Discount/index.js +122 -127
- package/lib/modules/Discount/types.js +9 -31
- package/lib/modules/Guests/index.js +30 -56
- package/lib/modules/Guests/types.js +23 -33
- package/lib/modules/Holder/index.js +209 -189
- package/lib/modules/Holder/types.js +4 -16
- package/lib/modules/Holder/utils.js +20 -49
- package/lib/modules/OpenData/index.js +70 -76
- package/lib/modules/OpenData/types.js +4 -16
- package/lib/modules/OpenData/utils.js +44 -78
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +1713 -2118
- package/lib/modules/Order/payment-utils.js +77 -120
- package/lib/modules/Order/types.js +88 -35
- package/lib/modules/Order/utils/bundleDiscountHydration.js +41 -74
- package/lib/modules/Order/utils/discountProductLineIdentity.js +142 -100
- package/lib/modules/Order/utils/manualProductDiscount.js +124 -123
- package/lib/modules/Order/utils/orderCollectionIdentity.js +184 -244
- package/lib/modules/Order/utils.js +814 -647
- package/lib/modules/Payment/cash.js +20 -33
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
- package/lib/modules/Payment/eftpos.js +16 -30
- package/lib/modules/Payment/index.js +532 -399
- package/lib/modules/Payment/mx51.js +1 -0
- package/lib/modules/Payment/types.js +230 -108
- package/lib/modules/Payment/utils.js +52 -51
- package/lib/modules/Payment/walletpass.js +485 -660
- package/lib/modules/Product/index.js +51 -46
- package/lib/modules/Product/types.js +4 -16
- package/lib/modules/Product/utils.js +32 -33
- package/lib/modules/ProductList/index.js +113 -123
- package/lib/modules/ProductList/types.js +9 -31
- package/lib/modules/Quotation/index.d.ts +6 -0
- package/lib/modules/Quotation/index.js +110 -103
- package/lib/modules/Quotation/types.js +4 -16
- package/lib/modules/Resource/index.js +27 -59
- package/lib/modules/Resource/types.js +22 -32
- package/lib/modules/Resource/utils.js +30 -38
- package/lib/modules/ResourcePlanner/index.js +25 -23
- package/lib/modules/ResourcePlanner/localClock.js +54 -119
- package/lib/modules/ResourcePlanner/planner.js +589 -770
- package/lib/modules/ResourcePlanner/types.js +10 -29
- package/lib/modules/Rules/index.js +1218 -959
- package/lib/modules/Rules/types.js +17 -40
- package/lib/modules/SalesSummary/index.js +85 -90
- package/lib/modules/SalesSummary/types.js +4 -16
- package/lib/modules/SalesSummary/utils.js +355 -430
- package/lib/modules/ScanOrderLogger/index.js +59 -79
- package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
- package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
- package/lib/modules/ScanOrderLogger/types.js +4 -16
- package/lib/modules/Schedule/getDateIsInSchedule.js +334 -163
- package/lib/modules/Schedule/index.js +100 -114
- package/lib/modules/Schedule/type.js +4 -16
- package/lib/modules/Schedule/types.js +4 -16
- package/lib/modules/Schedule/utils.js +433 -291
- package/lib/modules/Step/index.js +40 -52
- package/lib/modules/Step/tyeps.js +4 -16
- package/lib/modules/Summary/index.js +66 -71
- package/lib/modules/Summary/types.js +4 -16
- package/lib/modules/Summary/utils.js +773 -418
- package/lib/modules/SurchargeList/index.js +46 -60
- package/lib/modules/SurchargeList/types.js +4 -16
- package/lib/modules/index.js +245 -63
- package/lib/plugins/app.js +4 -16
- package/lib/plugins/index.js +36 -25
- package/lib/plugins/request.d.ts +1 -0
- package/lib/plugins/request.js +137 -126
- package/lib/plugins/shopStore.js +4 -16
- package/lib/plugins/user.js +4 -16
- package/lib/plugins/window.js +171 -179
- package/lib/server/index.d.ts +8 -2
- package/lib/server/index.js +3083 -2663
- package/lib/server/modules/floor-plan/index.d.ts +4 -0
- package/lib/server/modules/floor-plan/index.js +159 -127
- package/lib/server/modules/floor-plan/types.js +15 -30
- package/lib/server/modules/index.js +106 -68
- package/lib/server/modules/menu/index.js +170 -124
- package/lib/server/modules/menu/types.js +18 -31
- package/lib/server/modules/order/index.d.ts +17 -7
- package/lib/server/modules/order/index.js +916 -977
- package/lib/server/modules/order/types.js +122 -33
- package/lib/server/modules/order/utils/filterBookings.js +219 -194
- package/lib/server/modules/order/utils/filterOrders.js +118 -92
- package/lib/server/modules/payment/index.js +59 -83
- package/lib/server/modules/payment/types.js +4 -16
- package/lib/server/modules/products/index.d.ts +8 -2
- package/lib/server/modules/products/index.js +656 -471
- package/lib/server/modules/products/types.js +44 -34
- package/lib/server/modules/quotation/index.js +137 -172
- package/lib/server/modules/quotation/types.js +21 -31
- package/lib/server/modules/resource/index.js +225 -186
- package/lib/server/modules/resource/types.js +42 -33
- package/lib/server/modules/schedule/index.js +135 -123
- package/lib/server/modules/schedule/types.js +14 -21
- package/lib/server/modules/schedule/utils.js +334 -163
- package/lib/server/types.js +4 -16
- package/lib/server/utils/index.js +25 -23
- package/lib/server/utils/product.js +196 -139
- package/lib/server/utils/schedule.js +34 -41
- package/lib/server/utils/small-ticket.js +479 -456
- package/lib/server/utils/time.js +40 -49
- package/lib/solution/BaseSales/index.js +1186 -1410
- package/lib/solution/BaseSales/types.js +42 -38
- package/lib/solution/BaseSales/utils/cartPromotion.js +642 -498
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +85 -105
- package/lib/solution/BaseSales/utils/quotationPrice.js +56 -114
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +108 -145
- package/lib/solution/BaseSales/utils.js +158 -143
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1527 -1340
- package/lib/solution/BookingByStep/types.js +40 -99
- package/lib/solution/BookingByStep/utils/capacity.js +192 -160
- package/lib/solution/BookingByStep/utils/products.js +42 -52
- package/lib/solution/BookingByStep/utils/resources.js +527 -330
- package/lib/solution/BookingByStep/utils/stock.js +65 -44
- package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
- package/lib/solution/BookingTicket/index.js +607 -522
- package/lib/solution/BookingTicket/types.js +99 -77
- package/lib/solution/BookingTicket/utils/addProductDecision.js +226 -189
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +58 -89
- package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -78
- package/lib/solution/BookingTicket/utils/cartView.js +114 -99
- package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +18 -41
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +219 -86
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +168 -116
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +79 -91
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +54 -41
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -81
- package/lib/solution/BookingTicket/utils/scan/index.js +98 -104
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +52 -64
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +56 -58
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +34 -48
- package/lib/solution/BuyTickets/index.js +67 -70
- package/lib/solution/BuyTickets/types.js +22 -38
- package/lib/solution/Checkout/index.js +1451 -1158
- package/lib/solution/Checkout/types.js +91 -61
- package/lib/solution/Checkout/utils/index.js +228 -156
- package/lib/solution/PlaceOrder/index.js +55 -0
- package/lib/solution/RegisterAndLogin/config.js +493 -460
- package/lib/solution/RegisterAndLogin/index.js +633 -630
- package/lib/solution/RegisterAndLogin/types.js +189 -76
- package/lib/solution/RegisterAndLogin/utils.js +183 -125
- package/lib/solution/Sales/index.js +328 -324
- package/lib/solution/Sales/types.js +27 -33
- package/lib/solution/ScanOrder/index.js +832 -864
- package/lib/solution/ScanOrder/types.js +33 -34
- package/lib/solution/ScanOrder/utils.js +409 -374
- package/lib/solution/ShopDiscount/index.js +226 -232
- package/lib/solution/ShopDiscount/types.js +15 -37
- package/lib/solution/ShopDiscount/utils.js +300 -172
- package/lib/solution/UnifiedBookingSales/index.js +1035 -1201
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +99 -159
- package/lib/solution/UnifiedBookingSales/types.js +10 -32
- package/lib/solution/VenueBooking/index.js +811 -879
- package/lib/solution/VenueBooking/types.js +19 -39
- package/lib/solution/VenueBooking/utils/dateSummary.js +27 -56
- package/lib/solution/VenueBooking/utils/resource.js +31 -54
- package/lib/solution/VenueBooking/utils/slotMerge.js +94 -107
- package/lib/solution/VenueBooking/utils/timeSlot.js +132 -132
- package/lib/solution/VenueBooking/utils.js +130 -67
- package/lib/solution/index.js +124 -41
- package/lib/store/createStore.js +32 -29
- package/lib/types/index.js +4 -16
- package/lib/utils/payment-number.js +26 -46
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +81 -47
- package/package.json +2 -1
|
@@ -1,102 +1,93 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__export(buildNormalProductCacheItemFromOrderLine_exports, {
|
|
22
|
-
buildNormalProductCacheItemFromOrderLine: () => buildNormalProductCacheItemFromOrderLine
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
23
5
|
});
|
|
24
|
-
|
|
25
|
-
var
|
|
26
|
-
var
|
|
6
|
+
exports.buildNormalProductCacheItemFromOrderLine = buildNormalProductCacheItemFromOrderLine;
|
|
7
|
+
var _utils = require("../../Order/utils");
|
|
8
|
+
var _orderLineDisplay = require("./orderLineDisplay");
|
|
9
|
+
/**
|
|
10
|
+
* 从已加车的普通商品 order line 反查 SkuDetailModal edit 所需的 cacheItem。
|
|
11
|
+
*
|
|
12
|
+
* 与 `buildCacheItemFromOrderLine`(预约行 + booking)并列;不含 resource / duration / holder 等预约字段。
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* 解析 v2 主商品 source 价(不含 option、不含 bundle),供 SkuDetailModal / transform 使用。
|
|
16
|
+
*/
|
|
27
17
|
function resolveSourceProductPrice(product, sourceProduct) {
|
|
28
|
-
var _a, _b, _c;
|
|
29
18
|
const metadata = product.metadata || {};
|
|
30
|
-
if (metadata.source_product_price !==
|
|
19
|
+
if (metadata.source_product_price !== undefined && metadata.source_product_price !== null) {
|
|
31
20
|
const parsed = Number(metadata.source_product_price);
|
|
32
|
-
if (Number.isFinite(parsed))
|
|
33
|
-
return parsed;
|
|
21
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
34
22
|
}
|
|
35
23
|
const variantId = Number(product.product_variant_id || 0);
|
|
36
24
|
if (variantId > 0) {
|
|
37
|
-
const variantList =
|
|
25
|
+
const variantList = metadata.origin?.variant ?? sourceProduct?.variant;
|
|
38
26
|
if (Array.isArray(variantList)) {
|
|
39
|
-
const matched = variantList.find(
|
|
40
|
-
const variantPrice =
|
|
41
|
-
if (variantPrice !==
|
|
27
|
+
const matched = variantList.find(v => Number(v?.id) === variantId);
|
|
28
|
+
const variantPrice = matched?.price ?? matched?.base_price;
|
|
29
|
+
if (variantPrice !== undefined && variantPrice !== null) {
|
|
42
30
|
const parsed = Number(variantPrice);
|
|
43
|
-
if (Number.isFinite(parsed))
|
|
44
|
-
return parsed;
|
|
31
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
45
32
|
}
|
|
46
33
|
}
|
|
47
34
|
}
|
|
48
|
-
const catalogPrice =
|
|
49
|
-
if (catalogPrice !==
|
|
35
|
+
const catalogPrice = sourceProduct?.price ?? sourceProduct?.base_price;
|
|
36
|
+
if (catalogPrice !== undefined && catalogPrice !== null) {
|
|
50
37
|
const parsed = Number(catalogPrice);
|
|
51
|
-
if (Number.isFinite(parsed))
|
|
52
|
-
return parsed;
|
|
38
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
53
39
|
}
|
|
54
|
-
const originPrice =
|
|
55
|
-
if (originPrice !==
|
|
40
|
+
const originPrice = metadata.origin?.price ?? metadata.origin?.base_price;
|
|
41
|
+
if (originPrice !== undefined && originPrice !== null) {
|
|
56
42
|
const parsed = Number(originPrice);
|
|
57
|
-
if (Number.isFinite(parsed))
|
|
58
|
-
return parsed;
|
|
43
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
59
44
|
}
|
|
60
45
|
return Number(product.selling_price ?? 0);
|
|
61
46
|
}
|
|
47
|
+
|
|
48
|
+
/** 订单行 bundle → booking other.bundle(保留 original_price 供 setProductPrice 按比例分摊) */
|
|
62
49
|
function mapOrderBundleToOtherBundle(bundle) {
|
|
63
|
-
return bundle.map(
|
|
50
|
+
return bundle.map(item => {
|
|
64
51
|
const catalogOriginal = item.original_price ?? item.product_price ?? item.price ?? item.bundle_selling_price;
|
|
65
52
|
const selling = item.bundle_selling_price ?? item.price ?? catalogOriginal;
|
|
66
|
-
const {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
53
|
+
const {
|
|
54
|
+
bundle_selling_price: _omitBundleSelling,
|
|
55
|
+
...rest
|
|
56
|
+
} = item;
|
|
57
|
+
const isMarkupOrMarkdown = (item.price_type === 'markdown' || item.price_type === 'markup') && (item.price_type_ext === '' || item.price_type_ext === undefined || item.price_type_ext === null);
|
|
58
|
+
if (isMarkupOrMarkdown) delete rest.original_total;
|
|
70
59
|
return {
|
|
71
60
|
...rest,
|
|
72
61
|
price: selling,
|
|
73
62
|
original_price: catalogOriginal,
|
|
74
|
-
...isMarkupOrMarkdown ? {} : {
|
|
63
|
+
...(isMarkupOrMarkdown ? {} : {
|
|
64
|
+
original_total: item.original_total ?? catalogOriginal
|
|
65
|
+
}),
|
|
75
66
|
num: item.num ?? item.quantity ?? 1,
|
|
76
67
|
quantity: item.quantity ?? item.num ?? 1
|
|
77
68
|
};
|
|
78
69
|
});
|
|
79
70
|
}
|
|
80
71
|
function buildNormalProductCacheItemFromOrderLine(input) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
72
|
+
const {
|
|
73
|
+
product,
|
|
74
|
+
sourceProduct
|
|
75
|
+
} = input;
|
|
76
|
+
const resolvedId = product.product_id ?? sourceProduct?.id;
|
|
84
77
|
const sourcePrice = resolveSourceProductPrice(product, sourceProduct);
|
|
85
78
|
const selling = Number(product.selling_price ?? 0);
|
|
86
79
|
const original = Number(product.original_price ?? selling);
|
|
87
|
-
const uid =
|
|
88
|
-
const option = (0,
|
|
89
|
-
const bundle = mapOrderBundleToOtherBundle(
|
|
90
|
-
|
|
91
|
-
);
|
|
92
|
-
const originExtend = (_c = (_b = product.metadata) == null ? void 0 : _b.origin) == null ? void 0 : _c._extend;
|
|
93
|
-
const productOptionString = (0, import_orderLineDisplay.buildProductOptionStringFromOrderLine)(product);
|
|
80
|
+
const uid = product.metadata?.unique_identification_number;
|
|
81
|
+
const option = (0, _utils.getProductSkuOptions)(product);
|
|
82
|
+
const bundle = mapOrderBundleToOtherBundle(Array.isArray(product.product_bundle) ? product.product_bundle : []);
|
|
83
|
+
const originExtend = product.metadata?.origin?._extend;
|
|
84
|
+
const productOptionString = (0, _orderLineDisplay.buildProductOptionStringFromOrderLine)(product);
|
|
94
85
|
const discountList = product.discount_list || [];
|
|
95
86
|
const other = {
|
|
96
87
|
product_id: resolvedId,
|
|
97
88
|
product_variant_id: product.product_variant_id ?? 0,
|
|
98
89
|
option,
|
|
99
|
-
bundle:
|
|
90
|
+
bundle: originExtend?.other?.bundle ? JSON.parse(JSON.stringify(originExtend.other.bundle)) : bundle,
|
|
100
91
|
quantity: product.num ?? 1
|
|
101
92
|
};
|
|
102
93
|
const skuValue = {
|
|
@@ -107,50 +98,54 @@ function buildNormalProductCacheItemFromOrderLine(input) {
|
|
|
107
98
|
};
|
|
108
99
|
const extend = {
|
|
109
100
|
quantity: product.num ?? 1,
|
|
110
|
-
product_name:
|
|
111
|
-
note: product.note ??
|
|
101
|
+
product_name: sourceProduct?.title ?? '',
|
|
102
|
+
note: product.note ?? '',
|
|
112
103
|
// v2:_extend.price 为主商品 source 价;行 composite 用 total / origin_total 展示
|
|
113
|
-
price:
|
|
114
|
-
total:
|
|
115
|
-
origin_total:
|
|
104
|
+
price: originExtend?.price ?? sourcePrice,
|
|
105
|
+
total: originExtend?.total ?? selling,
|
|
106
|
+
origin_total: originExtend?.origin_total ?? original,
|
|
116
107
|
other,
|
|
117
108
|
skuValue: JSON.parse(JSON.stringify(skuValue)),
|
|
118
109
|
_skuValue: JSON.parse(JSON.stringify(skuValue)),
|
|
119
110
|
isNormalProduct: true,
|
|
120
111
|
metadata: {
|
|
121
|
-
product_add_schedule_time:
|
|
112
|
+
product_add_schedule_time: product.metadata?.product_add_schedule_time
|
|
122
113
|
},
|
|
123
|
-
...productOptionString ? {
|
|
124
|
-
|
|
125
|
-
|
|
114
|
+
...(productOptionString ? {
|
|
115
|
+
product_option_string: productOptionString
|
|
116
|
+
} : {}),
|
|
117
|
+
...(originExtend?.priceOverride !== undefined ? {
|
|
118
|
+
priceOverride: originExtend.priceOverride
|
|
119
|
+
} : {}),
|
|
120
|
+
...(originExtend?.bundle_edit !== undefined ? {
|
|
121
|
+
bundle_edit: originExtend.bundle_edit
|
|
122
|
+
} : {})
|
|
126
123
|
};
|
|
127
|
-
if (
|
|
128
|
-
extend.skuValue = JSON.parse(
|
|
129
|
-
JSON.stringify(originExtend.skuValue || originExtend._skuValue)
|
|
130
|
-
);
|
|
124
|
+
if (originExtend?.skuValue || originExtend?._skuValue) {
|
|
125
|
+
extend.skuValue = JSON.parse(JSON.stringify(originExtend.skuValue || originExtend._skuValue));
|
|
131
126
|
extend._skuValue = JSON.parse(JSON.stringify(extend.skuValue));
|
|
132
127
|
}
|
|
133
128
|
return {
|
|
134
|
-
...sourceProduct || {},
|
|
129
|
+
...(sourceProduct || {}),
|
|
135
130
|
id: resolvedId,
|
|
136
131
|
product_id: resolvedId,
|
|
137
132
|
_id: uid,
|
|
138
|
-
title:
|
|
139
|
-
cover:
|
|
140
|
-
price:
|
|
133
|
+
title: sourceProduct?.title ?? product.product_title ?? '',
|
|
134
|
+
cover: sourceProduct?.cover ?? product.product_cover ?? '',
|
|
135
|
+
price: sourceProduct?.price ?? sourcePrice,
|
|
141
136
|
selling_price: product.selling_price,
|
|
142
137
|
original_price: product.original_price,
|
|
143
|
-
...productOptionString ? {
|
|
138
|
+
...(productOptionString ? {
|
|
139
|
+
product_option_string: productOptionString
|
|
140
|
+
} : {}),
|
|
144
141
|
note: product.note,
|
|
145
142
|
order_detail_id: product.order_detail_id ?? null,
|
|
146
143
|
discount_list: discountList,
|
|
147
|
-
...Number(
|
|
144
|
+
...(Number(product.product_sku?.open_sold_weight || 0) === 1 ? {
|
|
145
|
+
product_sku: JSON.parse(JSON.stringify(product.product_sku))
|
|
146
|
+
} : {}),
|
|
148
147
|
new: 0,
|
|
149
148
|
autoClose: true,
|
|
150
149
|
_extend: extend
|
|
151
150
|
};
|
|
152
|
-
}
|
|
153
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
154
|
-
0 && (module.exports = {
|
|
155
|
-
buildNormalProductCacheItemFromOrderLine
|
|
156
|
-
});
|
|
151
|
+
}
|
|
@@ -1,222 +1,242 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
28
2
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
__export(cacheItemToBookingInput_exports, {
|
|
32
|
-
cacheItemToBookingInput: () => cacheItemToBookingInput
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
33
5
|
});
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
var
|
|
6
|
+
exports.cacheItemToBookingInput = cacheItemToBookingInput;
|
|
7
|
+
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
8
|
+
var _serviceTimes = require("./serviceTimes");
|
|
9
|
+
var _resources = require("./resources");
|
|
10
|
+
var _flexible = require("./flexible");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
/**
|
|
13
|
+
* 把 info2 `cacheItem` 转换为 OS `addProductToOrder(product, booking)` 所需的 booking 入参。
|
|
14
|
+
*
|
|
15
|
+
* 协议严格对齐 `pisell_os/src/modules/Order/TEMP_ORDER_FIELDS_SUMMARY.md` 的 Bookings 章节:
|
|
16
|
+
* - 顶层只允许出现:schedule_event_id / appointment_status / start_date / start_time / end_date /
|
|
17
|
+
* end_time / select_date / duration / sub_type / like_status / number / resources / relation_forms /
|
|
18
|
+
* holder / metadata / is_all / schedule_id / relation_id / form_id / relation_type / product_uid
|
|
19
|
+
* - bookings[] 不允许出现 `_extend`
|
|
20
|
+
* - bookings[].metadata 走白名单:unique_identification_number / collect_pax / capacity / holder_id / resource_select_type
|
|
21
|
+
* - bookings[].resources[] 只接受协议白名单:form_id / relation_type / relation_id / capacity / like_status / metadata / children
|
|
22
|
+
*
|
|
23
|
+
* `product_uid` / `metadata.unique_identification_number` 不在这里生成:
|
|
24
|
+
* OS `addProductToOrder` 内的 `createLinkedProductAndBooking` 会在最终一步统一改写,
|
|
25
|
+
* 保证商品行 uid 与 booking root 唯一值始终对齐。
|
|
26
|
+
*
|
|
27
|
+
* 复杂 multi-day 展开(createBookingItemsByGroup / concatBookings)首版**不支持**,
|
|
28
|
+
* 由 UI 在 `cart.confirmDetail` 之外通过辅助 API 处理。
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/** custom / package 人数维度快照,与 info2 `_extend.capacity` / `metadata.capacity` 对齐。 */
|
|
32
|
+
|
|
33
|
+
/** 将 UI `_extend.capacity[]` 规范化为 booking.metadata.capacity。 */
|
|
39
34
|
function normalizeExtendCapacityForMetadata(capacity) {
|
|
40
|
-
if (!Array.isArray(capacity) || capacity.length === 0)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (
|
|
44
|
-
return null;
|
|
45
|
-
if (item.id === void 0 || item.id === null)
|
|
46
|
-
return null;
|
|
35
|
+
if (!Array.isArray(capacity) || capacity.length === 0) return undefined;
|
|
36
|
+
const normalized = capacity.map(item => {
|
|
37
|
+
if (!item || typeof item !== 'object') return null;
|
|
38
|
+
if (item.id === undefined || item.id === null) return null;
|
|
47
39
|
const row = {
|
|
48
40
|
id: item.id,
|
|
49
41
|
value: Number(item.value ?? 0)
|
|
50
42
|
};
|
|
51
|
-
if (item.name !==
|
|
52
|
-
row.name = item.name;
|
|
43
|
+
if (item.name !== undefined) row.name = item.name;
|
|
53
44
|
return row;
|
|
54
|
-
}).filter(
|
|
55
|
-
return normalized.length > 0 ? normalized :
|
|
45
|
+
}).filter(item => item != null);
|
|
46
|
+
return normalized.length > 0 ? normalized : undefined;
|
|
56
47
|
}
|
|
57
48
|
function safeFormat(value, fmt) {
|
|
58
|
-
if (value ===
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (!d.isValid())
|
|
62
|
-
return void 0;
|
|
49
|
+
if (value === undefined || value === null) return undefined;
|
|
50
|
+
const d = (0, _dayjs.default)(value);
|
|
51
|
+
if (!d.isValid()) return undefined;
|
|
63
52
|
return d.format(fmt);
|
|
64
53
|
}
|
|
54
|
+
|
|
55
|
+
/** booking 协议 start_time / end_time:统一 HH:mm(不带秒)。 */
|
|
65
56
|
function normalizeTimeString(value) {
|
|
66
|
-
if (value ===
|
|
67
|
-
|
|
68
|
-
if (typeof value === "string") {
|
|
57
|
+
if (value === undefined || value === null) return undefined;
|
|
58
|
+
if (typeof value === 'string') {
|
|
69
59
|
const t = value.trim();
|
|
70
60
|
const hhmmFromHhmmss = t.match(/^(\d{1,2}:\d{2}):\d{2}$/);
|
|
71
|
-
if (hhmmFromHhmmss)
|
|
72
|
-
|
|
73
|
-
if (/^\d{1,2}:\d{2}$/.test(t))
|
|
74
|
-
return t;
|
|
61
|
+
if (hhmmFromHhmmss) return hhmmFromHhmmss[1];
|
|
62
|
+
if (/^\d{1,2}:\d{2}$/.test(t)) return t;
|
|
75
63
|
}
|
|
76
|
-
const d = (0,
|
|
77
|
-
if (d.isValid())
|
|
78
|
-
|
|
79
|
-
return void 0;
|
|
64
|
+
const d = (0, _dayjs.default)(value);
|
|
65
|
+
if (d.isValid()) return d.format('HH:mm');
|
|
66
|
+
return undefined;
|
|
80
67
|
}
|
|
81
68
|
function resolveDurationMinutes(value) {
|
|
82
|
-
if (typeof value ===
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
return void 0;
|
|
86
|
-
if (import_flexible.flexibleObj.isFlexible(value))
|
|
87
|
-
return import_flexible.flexibleObj.getValue(value);
|
|
69
|
+
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
|
70
|
+
if (typeof value !== 'string') return undefined;
|
|
71
|
+
if (_flexible.flexibleObj.isFlexible(value)) return _flexible.flexibleObj.getValue(value);
|
|
88
72
|
const n = Number(value);
|
|
89
|
-
return Number.isNaN(n) ?
|
|
73
|
+
return Number.isNaN(n) ? undefined : n;
|
|
90
74
|
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 将组合资源子项收敛为 checkout resources 协议。
|
|
78
|
+
*
|
|
79
|
+
* resourcesOriginMap 中的子资源是 UI 运行态结构,通常只有 id / main_field / form_id,
|
|
80
|
+
* 不保证携带后端必填的 relation_type。这里不能原样透传,否则会触发
|
|
81
|
+
* `bookings.*.resources.*.children.*.relation_type` 校验错误。
|
|
82
|
+
*/
|
|
91
83
|
function normalizeChildResource(child, parentFormId) {
|
|
92
84
|
const item = {
|
|
93
|
-
form_id:
|
|
94
|
-
relation_type:
|
|
95
|
-
relation_id:
|
|
96
|
-
capacity: child
|
|
97
|
-
like_status:
|
|
85
|
+
form_id: child?.form_id ?? parentFormId,
|
|
86
|
+
relation_type: child?.relation_type || 'form',
|
|
87
|
+
relation_id: child?.relation_id ?? child?.id,
|
|
88
|
+
capacity: child?.capacity,
|
|
89
|
+
like_status: child?.like_status || 'common'
|
|
98
90
|
};
|
|
99
|
-
if (
|
|
100
|
-
item.metadata = {
|
|
91
|
+
if (child?.metadata !== undefined) {
|
|
92
|
+
item.metadata = {
|
|
93
|
+
...child.metadata
|
|
94
|
+
};
|
|
101
95
|
}
|
|
102
|
-
if (Array.isArray(child
|
|
103
|
-
item.children = child.children.map(
|
|
104
|
-
(nestedChild) => normalizeChildResource(nestedChild, item.form_id)
|
|
105
|
-
);
|
|
96
|
+
if (Array.isArray(child?.children)) {
|
|
97
|
+
item.children = child.children.map(nestedChild => normalizeChildResource(nestedChild, item.form_id));
|
|
106
98
|
}
|
|
107
99
|
return item;
|
|
108
100
|
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* cacheItem._extend.resource 形如 `{ [form_id]: [{ relation_id, form_id, like_status, metadata, children }] }`。
|
|
104
|
+
* 这里扁平化为符合协议的 resources[] 数组;id=0 的「无资源」占位行**保留**(与 info2 业务等价;协议 `relation_id=0` 合法)。
|
|
105
|
+
*
|
|
106
|
+
* 顶层 resources[].capacity 与 info2 `checkResourcesFormat` 一致:Σ capacity[].value(不含 quantity)。
|
|
107
|
+
*/
|
|
109
108
|
function flattenResources(cacheItem) {
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
const topLevelCapacity = (0, import_resources.getSumCapacity)(cacheItem, false);
|
|
109
|
+
const resourceMap = cacheItem?._extend?.resource || {};
|
|
110
|
+
const topLevelCapacity = (0, _resources.getSumCapacity)(cacheItem, false);
|
|
113
111
|
const result = [];
|
|
114
|
-
Object.values(resourceMap).forEach(
|
|
115
|
-
if (!Array.isArray(arr))
|
|
116
|
-
|
|
117
|
-
arr.forEach((r) => {
|
|
112
|
+
Object.values(resourceMap).forEach(arr => {
|
|
113
|
+
if (!Array.isArray(arr)) return;
|
|
114
|
+
arr.forEach(r => {
|
|
118
115
|
const item = {
|
|
119
|
-
form_id: r
|
|
120
|
-
relation_type:
|
|
121
|
-
relation_id: r
|
|
116
|
+
form_id: r?.form_id,
|
|
117
|
+
relation_type: r?.relation_type || 'form',
|
|
118
|
+
relation_id: r?.relation_id,
|
|
122
119
|
capacity: topLevelCapacity
|
|
123
120
|
};
|
|
124
|
-
item.like_status =
|
|
125
|
-
if (
|
|
126
|
-
|
|
121
|
+
item.like_status = r?.like_status || 'common';
|
|
122
|
+
if (r?.metadata !== undefined) {
|
|
123
|
+
// 协议允许 metadata 自由透传;为了与 info2 行为等价,把 form_name / resource_name / combined_resource 一并保留。
|
|
124
|
+
item.metadata = {
|
|
125
|
+
...r.metadata
|
|
126
|
+
};
|
|
127
127
|
}
|
|
128
|
-
if (Array.isArray(r
|
|
129
|
-
item.children = r.children.map(
|
|
130
|
-
(child) => normalizeChildResource(child, item.form_id)
|
|
131
|
-
);
|
|
128
|
+
if (Array.isArray(r?.children)) {
|
|
129
|
+
item.children = r.children.map(child => normalizeChildResource(child, item.form_id));
|
|
132
130
|
}
|
|
133
131
|
result.push(item);
|
|
134
132
|
});
|
|
135
133
|
});
|
|
136
134
|
return result;
|
|
137
135
|
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 从 cacheItem 中派生 metadata.resource_select_type;优先级:
|
|
139
|
+
* 1. cacheItem._data.resources[0].select_type.type
|
|
140
|
+
* 2. cacheItem.product_resource.resources[0].select_type.type
|
|
141
|
+
* 3. 默认 undefined(由 OS / 后端兜底)。
|
|
142
|
+
*/
|
|
138
143
|
function deriveResourceSelectType(cacheItem) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (productFirst)
|
|
145
|
-
return productFirst;
|
|
146
|
-
return void 0;
|
|
144
|
+
const localFirst = cacheItem?._data?.resources?.[0]?.select_type?.type;
|
|
145
|
+
if (localFirst) return localFirst;
|
|
146
|
+
const productFirst = cacheItem?.product_resource?.resources?.[0]?.select_type?.type;
|
|
147
|
+
if (productFirst) return productFirst;
|
|
148
|
+
return undefined;
|
|
147
149
|
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* 主入口。
|
|
153
|
+
*/
|
|
148
154
|
function cacheItemToBookingInput(cacheItem, options) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
155
|
+
if (!cacheItem) return {
|
|
156
|
+
metadata: {
|
|
157
|
+
holder_id: null
|
|
158
|
+
}
|
|
159
|
+
};
|
|
152
160
|
const ext = cacheItem._extend || {};
|
|
153
|
-
const isMultiDay = (0,
|
|
154
|
-
const isSession = (0,
|
|
161
|
+
const isMultiDay = (0, _serviceTimes.isMultiDayProduct)(cacheItem) || ext.is_all === 1 || ext.sub_type === 'days';
|
|
162
|
+
const isSession = (0, _serviceTimes.isSessionProduct)(cacheItem);
|
|
155
163
|
const result = {};
|
|
156
|
-
|
|
164
|
+
|
|
165
|
+
// ──── 日期 / 时间 ───────────────────────────────────────────────
|
|
166
|
+
if (isSession && ext?.other?.session) {
|
|
157
167
|
const session = ext.other.session;
|
|
158
|
-
|
|
159
|
-
result.
|
|
160
|
-
result.
|
|
161
|
-
result.
|
|
168
|
+
// 优先 _extend 上已按顶部 date 对齐过的起止(catalog cartDetailValue.session → applySessionTimesToExtend)
|
|
169
|
+
result.start_date = safeFormat(ext.start_date || ext.startDate || session.start_at, 'YYYY-MM-DD');
|
|
170
|
+
result.start_time = normalizeTimeString(ext.start_time) || normalizeTimeString(session.start_time) || safeFormat(session.start_at, 'HH:mm');
|
|
171
|
+
result.end_date = safeFormat(ext.end_date || ext.endDate || session.end_at, 'YYYY-MM-DD');
|
|
172
|
+
result.end_time = normalizeTimeString(ext.end_time) || normalizeTimeString(session.end_time) || safeFormat(session.end_at, 'HH:mm');
|
|
162
173
|
} else {
|
|
163
|
-
result.start_date = safeFormat(ext.start_date || ext.startDate,
|
|
164
|
-
result.start_time = normalizeTimeString(ext.start_time) || safeFormat(ext.startDate,
|
|
165
|
-
result.end_date = safeFormat(ext.end_date || ext.endDate,
|
|
166
|
-
result.end_time = normalizeTimeString(ext.end_time) || safeFormat(ext.endDate,
|
|
174
|
+
result.start_date = safeFormat(ext.start_date || ext.startDate, 'YYYY-MM-DD');
|
|
175
|
+
result.start_time = normalizeTimeString(ext.start_time) || safeFormat(ext.startDate, 'HH:mm');
|
|
176
|
+
result.end_date = safeFormat(ext.end_date || ext.endDate, 'YYYY-MM-DD');
|
|
177
|
+
result.end_time = normalizeTimeString(ext.end_time) || safeFormat(ext.endDate, 'HH:mm');
|
|
167
178
|
}
|
|
179
|
+
|
|
180
|
+
// ──── duration / sub_type / is_all ──────────────────────────────
|
|
168
181
|
if (isMultiDay) {
|
|
169
182
|
result.is_all = 1;
|
|
170
|
-
result.sub_type =
|
|
171
|
-
result.duration = Number(ext.duration) || (0,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
183
|
+
result.sub_type = 'days';
|
|
184
|
+
result.duration = Number(ext.duration) || (0, _serviceTimes.getDays)(cacheItem, 'days');
|
|
185
|
+
// 全天选择日期 = 起始日
|
|
186
|
+
if (result.start_date) result.select_date = result.start_date;
|
|
187
|
+
// 跨日结束时刻与开始一致(如 11:24),避免 endDate 仅日期落为 00:00
|
|
188
|
+
if (result.start_time && (!result.end_time || result.end_time === '00:00')) {
|
|
175
189
|
result.end_time = result.start_time;
|
|
176
190
|
}
|
|
177
191
|
} else {
|
|
178
192
|
result.is_all = 0;
|
|
179
|
-
result.sub_type = ext.sub_type ||
|
|
193
|
+
result.sub_type = ext.sub_type || 'minutes';
|
|
180
194
|
const duration = resolveDurationMinutes(ext.duration);
|
|
181
|
-
if (duration !==
|
|
182
|
-
result.duration = duration;
|
|
195
|
+
if (duration !== undefined) result.duration = duration;
|
|
183
196
|
}
|
|
184
|
-
|
|
197
|
+
|
|
198
|
+
// ──── number(人数/容量占用) ───────────────────────────────────
|
|
199
|
+
result.number = (0, _resources.getSumCapacity)(cacheItem, true);
|
|
200
|
+
|
|
201
|
+
// ──── resources ─────────────────────────────────────────────────
|
|
185
202
|
result.resources = flattenResources(cacheItem);
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
203
|
+
|
|
204
|
+
// ──── holder / relation_forms / like_status / schedule_event_id ──
|
|
205
|
+
if (ext.holder !== undefined) result.holder = ext.holder;
|
|
206
|
+
if (Array.isArray(ext.relation_forms)) result.relation_forms = ext.relation_forms;
|
|
207
|
+
// 与 info2 booking/components/footer/utils formatBooking 一致:默认 common
|
|
208
|
+
result.like_status = ext.like_status || 'common';
|
|
209
|
+
if (cacheItem.schedule_event_id !== undefined) {
|
|
192
210
|
result.schedule_event_id = cacheItem.schedule_event_id;
|
|
193
211
|
}
|
|
194
|
-
|
|
195
|
-
|
|
212
|
+
|
|
213
|
+
// ──── metadata(严格白名单) ────────────────────────────────────
|
|
214
|
+
const metadata = {
|
|
215
|
+
holder_id: null
|
|
216
|
+
};
|
|
217
|
+
if (ext.holder_id !== undefined && ext.holder_id !== null) {
|
|
196
218
|
metadata.holder_id = ext.holder_id;
|
|
197
219
|
}
|
|
198
|
-
if (ext.holder !==
|
|
220
|
+
if (ext.holder !== undefined) {
|
|
199
221
|
metadata.holder = ext.holder;
|
|
200
222
|
}
|
|
201
|
-
if (ext.collect_pax !==
|
|
202
|
-
|
|
223
|
+
if (ext.collect_pax !== undefined) metadata.collect_pax = ext.collect_pax;
|
|
224
|
+
// 与 info2 formatMetaData 一致:优先写入完整人数维度数组,供编辑回显 / 详情回灌。
|
|
203
225
|
const extendCapacity = normalizeExtendCapacityForMetadata(ext.capacity);
|
|
204
226
|
if (extendCapacity) {
|
|
205
227
|
metadata.capacity = extendCapacity;
|
|
206
|
-
} else if (ext.capacity_snapshot !==
|
|
228
|
+
} else if (ext.capacity_snapshot !== undefined) {
|
|
207
229
|
metadata.capacity = ext.capacity_snapshot;
|
|
208
230
|
}
|
|
209
|
-
const selectType = deriveResourceSelectType(cacheItem) ||
|
|
210
|
-
if (selectType)
|
|
211
|
-
|
|
231
|
+
const selectType = deriveResourceSelectType(cacheItem) || options?.bookingConfig?.resource_select_type;
|
|
232
|
+
if (selectType) metadata.resource_select_type = selectType;
|
|
233
|
+
// unique_identification_number 不在这里生成(由 OS createLinkedProductAndBooking 统一写)。
|
|
212
234
|
result.metadata = metadata;
|
|
235
|
+
|
|
236
|
+
// ──── booking root 占位字段(与 TEMP_ORDER_FIELDS_SUMMARY 一致) ──
|
|
213
237
|
result.schedule_id = 0;
|
|
214
238
|
result.relation_id = 0;
|
|
215
239
|
result.form_id = 0;
|
|
216
|
-
result.relation_type =
|
|
240
|
+
result.relation_type = '';
|
|
217
241
|
return result;
|
|
218
|
-
}
|
|
219
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
220
|
-
0 && (module.exports = {
|
|
221
|
-
cacheItemToBookingInput
|
|
222
|
-
});
|
|
242
|
+
}
|