@pisell/pisellos 2.2.282 → 2.2.284

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.
Files changed (285) hide show
  1. package/dist/core/index.js +6 -9
  2. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  3. package/dist/model/strategy/adapter/walletPass/example.js +3 -26
  4. package/dist/model/strategy/strategy-example.js +5 -19
  5. package/dist/modules/Cart/index.js +0 -3
  6. package/dist/modules/Cart/utils/cartProduct.js +0 -1
  7. package/dist/modules/Date/index.js +1 -5
  8. package/dist/modules/Discount/index.js +2 -4
  9. package/dist/modules/OpenData/index.js +0 -2
  10. package/dist/modules/Order/index.d.ts +2 -2
  11. package/dist/modules/Order/index.js +75 -91
  12. package/dist/modules/Order/types.d.ts +3 -1
  13. package/dist/modules/Payment/index.js +97 -162
  14. package/dist/modules/Rules/index.js +1 -4
  15. package/dist/modules/Schedule/index.js +0 -1
  16. package/dist/modules/Schedule/utils.js +0 -1
  17. package/dist/modules/Step/index.js +0 -1
  18. package/dist/modules/Summary/utils.d.ts +1 -1
  19. package/dist/plugins/request.js +1 -4
  20. package/dist/plugins/window.js +2 -6
  21. package/dist/server/index.js +97 -129
  22. package/dist/server/modules/menu/index.js +32 -41
  23. package/dist/server/modules/order/index.js +2 -4
  24. package/dist/server/modules/products/index.js +24 -42
  25. package/dist/server/modules/quotation/index.js +29 -38
  26. package/dist/server/modules/resource/index.js +3 -4
  27. package/dist/server/modules/schedule/index.js +27 -35
  28. package/dist/server/utils/product.js +0 -1
  29. package/dist/solution/BaseSales/index.js +100 -72
  30. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
  31. package/dist/solution/BaseSales/utils/cartPromotion.js +15 -6
  32. package/dist/solution/BookingByStep/index.d.ts +1 -1
  33. package/dist/solution/BookingByStep/index.js +7 -59
  34. package/dist/solution/BookingByStep/utils/capacity.js +1 -11
  35. package/dist/solution/BookingByStep/utils/resources.js +1 -3
  36. package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
  37. package/dist/solution/BookingTicket/index.js +8 -4
  38. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +6 -7
  39. package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
  40. package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
  41. package/dist/solution/BuyTickets/index.js +9 -12
  42. package/dist/solution/Checkout/index.js +177 -252
  43. package/dist/solution/Checkout/utils/index.js +4 -16
  44. package/dist/solution/RegisterAndLogin/index.js +30 -76
  45. package/dist/solution/ScanOrder/index.js +50 -60
  46. package/dist/solution/ShopDiscount/index.js +2 -7
  47. package/dist/solution/VenueBooking/index.js +45 -55
  48. package/dist/utils/task.js +15 -18
  49. package/dist/utils/watch.js +0 -1
  50. package/lib/apis/picoding.js +2 -0
  51. package/lib/core/index.js +131 -131
  52. package/lib/effects/index.js +46 -57
  53. package/lib/index.js +82 -49
  54. package/lib/model/index.js +14 -21
  55. package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
  56. package/lib/model/strategy/adapter/dataVariant/evaluator.js +162 -236
  57. package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
  58. package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
  59. package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
  60. package/lib/model/strategy/adapter/index.js +100 -64
  61. package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
  62. package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
  63. package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
  64. package/lib/model/strategy/adapter/itemRule/index.js +83 -57
  65. package/lib/model/strategy/adapter/itemRule/type.js +97 -36
  66. package/lib/model/strategy/adapter/promotion/adapter.js +91 -69
  67. package/lib/model/strategy/adapter/promotion/evaluator.js +444 -310
  68. package/lib/model/strategy/adapter/promotion/examples.js +222 -234
  69. package/lib/model/strategy/adapter/promotion/index.js +1 -51
  70. package/lib/model/strategy/adapter/promotion/type.js +243 -36
  71. package/lib/model/strategy/adapter/type.js +4 -16
  72. package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -150
  73. package/lib/model/strategy/adapter/walletPass/example.js +217 -190
  74. package/lib/model/strategy/adapter/walletPass/index.js +75 -51
  75. package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
  76. package/lib/model/strategy/adapter/walletPass/type.js +4 -16
  77. package/lib/model/strategy/adapter/walletPass/utils.js +588 -378
  78. package/lib/model/strategy/engine.js +270 -168
  79. package/lib/model/strategy/index.js +49 -34
  80. package/lib/model/strategy/strategy-example.js +243 -239
  81. package/lib/model/strategy/type.js +100 -40
  82. package/lib/modules/Account/index.js +39 -53
  83. package/lib/modules/Account/types.js +20 -33
  84. package/lib/modules/AccountList/index.js +116 -154
  85. package/lib/modules/AccountList/types.js +30 -31
  86. package/lib/modules/AccountList/utils.js +18 -30
  87. package/lib/modules/BaseModule.js +23 -42
  88. package/lib/modules/BookingContext/index.js +158 -136
  89. package/lib/modules/BookingContext/types.js +46 -32
  90. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +138 -146
  91. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +78 -83
  92. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +170 -150
  93. package/lib/modules/BookingContext/utils/flexible.js +38 -55
  94. package/lib/modules/BookingContext/utils/formatResourceList.js +19 -34
  95. package/lib/modules/BookingContext/utils/index.js +124 -41
  96. package/lib/modules/BookingContext/utils/noResource.js +58 -70
  97. package/lib/modules/BookingContext/utils/orderLineDisplay.js +14 -41
  98. package/lib/modules/BookingContext/utils/productExtend.js +202 -155
  99. package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
  100. package/lib/modules/BookingContext/utils/resourceSelection.js +19 -41
  101. package/lib/modules/BookingContext/utils/resources.js +209 -167
  102. package/lib/modules/BookingContext/utils/serviceTimes.js +115 -116
  103. package/lib/modules/BookingContext/utils/timeSlices.js +76 -86
  104. package/lib/modules/Cart/index.js +170 -124
  105. package/lib/modules/Cart/types.js +46 -51
  106. package/lib/modules/Cart/utils/cartAccount.js +40 -39
  107. package/lib/modules/Cart/utils/cartDate.js +56 -61
  108. package/lib/modules/Cart/utils/cartDiscount.js +28 -33
  109. package/lib/modules/Cart/utils/cartNote.js +27 -32
  110. package/lib/modules/Cart/utils/cartProduct.js +321 -251
  111. package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
  112. package/lib/modules/Cart/utils/cartResource.js +70 -78
  113. package/lib/modules/Cart/utils/changePrice.js +22 -50
  114. package/lib/modules/Cart/utils/index.js +106 -48
  115. package/lib/modules/Customer/constants.js +13 -34
  116. package/lib/modules/Customer/index.js +235 -172
  117. package/lib/modules/Customer/types.js +38 -35
  118. package/lib/modules/Date/index.js +116 -115
  119. package/lib/modules/Date/types.js +16 -28
  120. package/lib/modules/Date/utils.js +174 -123
  121. package/lib/modules/Discount/index.js +122 -127
  122. package/lib/modules/Discount/types.js +9 -31
  123. package/lib/modules/Guests/index.js +30 -56
  124. package/lib/modules/Guests/types.js +23 -33
  125. package/lib/modules/Holder/index.js +209 -189
  126. package/lib/modules/Holder/types.js +4 -16
  127. package/lib/modules/Holder/utils.js +20 -49
  128. package/lib/modules/OpenData/index.js +70 -76
  129. package/lib/modules/OpenData/types.js +4 -16
  130. package/lib/modules/OpenData/utils.js +44 -78
  131. package/lib/modules/Order/index.d.ts +2 -2
  132. package/lib/modules/Order/index.js +1733 -2121
  133. package/lib/modules/Order/payment-utils.js +77 -120
  134. package/lib/modules/Order/types.d.ts +3 -1
  135. package/lib/modules/Order/types.js +87 -35
  136. package/lib/modules/Order/utils/bundleDiscountHydration.js +41 -74
  137. package/lib/modules/Order/utils/discountProductLineIdentity.js +142 -100
  138. package/lib/modules/Order/utils/manualProductDiscount.js +124 -123
  139. package/lib/modules/Order/utils/orderCollectionIdentity.js +184 -244
  140. package/lib/modules/Order/utils.js +814 -647
  141. package/lib/modules/Payment/cash.js +20 -33
  142. package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
  143. package/lib/modules/Payment/eftpos.js +16 -30
  144. package/lib/modules/Payment/index.js +532 -399
  145. package/lib/modules/Payment/mx51.js +1 -0
  146. package/lib/modules/Payment/types.js +230 -108
  147. package/lib/modules/Payment/utils.js +52 -51
  148. package/lib/modules/Payment/walletpass.js +485 -660
  149. package/lib/modules/Product/index.js +51 -46
  150. package/lib/modules/Product/types.js +4 -16
  151. package/lib/modules/Product/utils.js +32 -33
  152. package/lib/modules/ProductList/index.js +113 -123
  153. package/lib/modules/ProductList/types.js +9 -31
  154. package/lib/modules/Quotation/index.js +66 -100
  155. package/lib/modules/Quotation/types.js +4 -16
  156. package/lib/modules/Resource/index.js +27 -59
  157. package/lib/modules/Resource/types.js +22 -32
  158. package/lib/modules/Resource/utils.js +30 -38
  159. package/lib/modules/ResourcePlanner/index.js +60 -61
  160. package/lib/modules/ResourcePlanner/planner.js +346 -384
  161. package/lib/modules/ResourcePlanner/types.js +4 -16
  162. package/lib/modules/Rules/index.js +1218 -959
  163. package/lib/modules/Rules/types.js +17 -40
  164. package/lib/modules/SalesSummary/index.js +85 -90
  165. package/lib/modules/SalesSummary/types.js +4 -16
  166. package/lib/modules/SalesSummary/utils.js +355 -430
  167. package/lib/modules/ScanOrderLogger/index.js +59 -79
  168. package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
  169. package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
  170. package/lib/modules/ScanOrderLogger/types.js +4 -16
  171. package/lib/modules/Schedule/getDateIsInSchedule.js +334 -163
  172. package/lib/modules/Schedule/index.js +100 -114
  173. package/lib/modules/Schedule/type.js +4 -16
  174. package/lib/modules/Schedule/types.js +4 -16
  175. package/lib/modules/Schedule/utils.js +433 -291
  176. package/lib/modules/Step/index.js +40 -52
  177. package/lib/modules/Step/tyeps.js +4 -16
  178. package/lib/modules/Summary/index.js +66 -71
  179. package/lib/modules/Summary/types.js +4 -16
  180. package/lib/modules/Summary/utils.d.ts +1 -1
  181. package/lib/modules/Summary/utils.js +773 -418
  182. package/lib/modules/SurchargeList/index.js +46 -60
  183. package/lib/modules/SurchargeList/types.js +4 -16
  184. package/lib/modules/index.js +245 -63
  185. package/lib/plugins/app.js +4 -16
  186. package/lib/plugins/index.js +36 -25
  187. package/lib/plugins/request.js +137 -126
  188. package/lib/plugins/shopStore.js +4 -16
  189. package/lib/plugins/user.js +4 -16
  190. package/lib/plugins/window.js +171 -179
  191. package/lib/server/index.js +3027 -2655
  192. package/lib/server/modules/floor-plan/index.js +102 -123
  193. package/lib/server/modules/floor-plan/types.js +15 -30
  194. package/lib/server/modules/index.js +106 -68
  195. package/lib/server/modules/menu/index.js +146 -122
  196. package/lib/server/modules/menu/types.js +18 -31
  197. package/lib/server/modules/order/index.js +758 -956
  198. package/lib/server/modules/order/types.js +122 -33
  199. package/lib/server/modules/order/utils/filterBookings.js +219 -194
  200. package/lib/server/modules/order/utils/filterOrders.js +118 -92
  201. package/lib/server/modules/payment/index.js +59 -83
  202. package/lib/server/modules/payment/types.js +4 -16
  203. package/lib/server/modules/products/index.js +575 -459
  204. package/lib/server/modules/products/types.js +44 -34
  205. package/lib/server/modules/quotation/index.js +137 -172
  206. package/lib/server/modules/quotation/types.js +21 -31
  207. package/lib/server/modules/resource/index.js +213 -184
  208. package/lib/server/modules/resource/types.js +42 -33
  209. package/lib/server/modules/schedule/index.js +135 -123
  210. package/lib/server/modules/schedule/types.js +14 -21
  211. package/lib/server/modules/schedule/utils.js +334 -163
  212. package/lib/server/types.js +4 -16
  213. package/lib/server/utils/index.js +25 -23
  214. package/lib/server/utils/product.js +196 -139
  215. package/lib/server/utils/schedule.js +34 -41
  216. package/lib/server/utils/small-ticket.js +479 -456
  217. package/lib/server/utils/time.js +40 -49
  218. package/lib/solution/BaseSales/index.js +1209 -1412
  219. package/lib/solution/BaseSales/types.js +42 -38
  220. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
  221. package/lib/solution/BaseSales/utils/cartPromotion.js +652 -498
  222. package/lib/solution/BaseSales/utils/parseSalesResponse.js +85 -105
  223. package/lib/solution/BaseSales/utils/quotationPrice.js +56 -114
  224. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +108 -145
  225. package/lib/solution/BaseSales/utils.js +158 -143
  226. package/lib/solution/BookingByStep/index.d.ts +1 -1
  227. package/lib/solution/BookingByStep/index.js +1527 -1340
  228. package/lib/solution/BookingByStep/types.js +40 -99
  229. package/lib/solution/BookingByStep/utils/capacity.js +192 -160
  230. package/lib/solution/BookingByStep/utils/products.js +42 -52
  231. package/lib/solution/BookingByStep/utils/resources.js +527 -330
  232. package/lib/solution/BookingByStep/utils/stock.js +65 -44
  233. package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
  234. package/lib/solution/BookingTicket/index.js +598 -514
  235. package/lib/solution/BookingTicket/types.js +99 -77
  236. package/lib/solution/BookingTicket/utils/addProductDecision.js +225 -187
  237. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +58 -89
  238. package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -78
  239. package/lib/solution/BookingTicket/utils/cartView.js +114 -99
  240. package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
  241. package/lib/solution/BookingTicket/utils/orderCustomer.js +18 -41
  242. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +219 -86
  243. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +168 -116
  244. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +79 -91
  245. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +54 -41
  246. package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -81
  247. package/lib/solution/BookingTicket/utils/scan/index.js +98 -104
  248. package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
  249. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +52 -64
  250. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +56 -58
  251. package/lib/solution/BookingTicket/utils/weighingProductSku.js +34 -48
  252. package/lib/solution/BuyTickets/index.js +67 -70
  253. package/lib/solution/BuyTickets/types.js +22 -38
  254. package/lib/solution/Checkout/index.js +1451 -1158
  255. package/lib/solution/Checkout/types.js +91 -61
  256. package/lib/solution/Checkout/utils/index.js +228 -156
  257. package/lib/solution/PlaceOrder/index.js +55 -0
  258. package/lib/solution/RegisterAndLogin/config.js +493 -460
  259. package/lib/solution/RegisterAndLogin/index.js +633 -630
  260. package/lib/solution/RegisterAndLogin/types.js +189 -76
  261. package/lib/solution/RegisterAndLogin/utils.js +183 -125
  262. package/lib/solution/Sales/index.js +328 -324
  263. package/lib/solution/Sales/types.js +27 -33
  264. package/lib/solution/ScanOrder/index.js +832 -864
  265. package/lib/solution/ScanOrder/types.js +33 -34
  266. package/lib/solution/ScanOrder/utils.js +409 -374
  267. package/lib/solution/ShopDiscount/index.js +226 -232
  268. package/lib/solution/ShopDiscount/types.js +15 -37
  269. package/lib/solution/ShopDiscount/utils.js +300 -172
  270. package/lib/solution/UnifiedBookingSales/index.js +437 -487
  271. package/lib/solution/UnifiedBookingSales/types.js +12 -31
  272. package/lib/solution/VenueBooking/index.js +811 -879
  273. package/lib/solution/VenueBooking/types.js +19 -39
  274. package/lib/solution/VenueBooking/utils/dateSummary.js +27 -56
  275. package/lib/solution/VenueBooking/utils/resource.js +31 -54
  276. package/lib/solution/VenueBooking/utils/slotMerge.js +94 -107
  277. package/lib/solution/VenueBooking/utils/timeSlot.js +132 -132
  278. package/lib/solution/VenueBooking/utils.js +130 -67
  279. package/lib/solution/index.js +124 -41
  280. package/lib/store/createStore.js +32 -29
  281. package/lib/types/index.js +4 -16
  282. package/lib/utils/payment-number.js +26 -46
  283. package/lib/utils/task.js +36 -36
  284. package/lib/utils/watch.js +81 -47
  285. package/package.json +2 -1
@@ -1,102 +1,93 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";
18
2
 
19
- // src/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.ts
20
- var buildNormalProductCacheItemFromOrderLine_exports = {};
21
- __export(buildNormalProductCacheItemFromOrderLine_exports, {
22
- buildNormalProductCacheItemFromOrderLine: () => buildNormalProductCacheItemFromOrderLine
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
23
5
  });
24
- module.exports = __toCommonJS(buildNormalProductCacheItemFromOrderLine_exports);
25
- var import_utils = require("../../Order/utils");
26
- var import_orderLineDisplay = require("./orderLineDisplay");
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 !== void 0 && metadata.source_product_price !== null) {
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 = ((_a = metadata.origin) == null ? void 0 : _a.variant) ?? (sourceProduct == null ? void 0 : sourceProduct.variant);
25
+ const variantList = metadata.origin?.variant ?? sourceProduct?.variant;
38
26
  if (Array.isArray(variantList)) {
39
- const matched = variantList.find((v) => Number(v == null ? void 0 : v.id) === variantId);
40
- const variantPrice = (matched == null ? void 0 : matched.price) ?? (matched == null ? void 0 : matched.base_price);
41
- if (variantPrice !== void 0 && variantPrice !== null) {
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 = (sourceProduct == null ? void 0 : sourceProduct.price) ?? (sourceProduct == null ? void 0 : sourceProduct.base_price);
49
- if (catalogPrice !== void 0 && catalogPrice !== null) {
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 = ((_b = metadata.origin) == null ? void 0 : _b.price) ?? ((_c = metadata.origin) == null ? void 0 : _c.base_price);
55
- if (originPrice !== void 0 && originPrice !== null) {
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((item) => {
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 { bundle_selling_price: _omitBundleSelling, ...rest } = item;
67
- const isMarkupOrMarkdown = (item.price_type === "markdown" || item.price_type === "markup") && (item.price_type_ext === "" || item.price_type_ext === void 0 || item.price_type_ext === null);
68
- if (isMarkupOrMarkdown)
69
- delete rest.original_total;
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 ? {} : { original_total: item.original_total ?? catalogOriginal },
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
- var _a, _b, _c, _d, _e, _f;
82
- const { product, sourceProduct } = input;
83
- const resolvedId = product.product_id ?? (sourceProduct == null ? void 0 : sourceProduct.id);
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 = (_a = product.metadata) == null ? void 0 : _a.unique_identification_number;
88
- const option = (0, import_utils.getProductSkuOptions)(product);
89
- const bundle = mapOrderBundleToOtherBundle(
90
- Array.isArray(product.product_bundle) ? product.product_bundle : []
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: ((_d = originExtend == null ? void 0 : originExtend.other) == null ? void 0 : _d.bundle) ? JSON.parse(JSON.stringify(originExtend.other.bundle)) : 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: (sourceProduct == null ? void 0 : sourceProduct.title) ?? "",
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: (originExtend == null ? void 0 : originExtend.price) ?? sourcePrice,
114
- total: (originExtend == null ? void 0 : originExtend.total) ?? selling,
115
- origin_total: (originExtend == null ? void 0 : originExtend.origin_total) ?? original,
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: (_e = product.metadata) == null ? void 0 : _e.product_add_schedule_time
112
+ product_add_schedule_time: product.metadata?.product_add_schedule_time
122
113
  },
123
- ...productOptionString ? { product_option_string: productOptionString } : {},
124
- ...(originExtend == null ? void 0 : originExtend.priceOverride) !== void 0 ? { priceOverride: originExtend.priceOverride } : {},
125
- ...(originExtend == null ? void 0 : originExtend.bundle_edit) !== void 0 ? { bundle_edit: originExtend.bundle_edit } : {}
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 ((originExtend == null ? void 0 : originExtend.skuValue) || (originExtend == null ? void 0 : originExtend._skuValue)) {
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: (sourceProduct == null ? void 0 : sourceProduct.title) ?? product.product_title ?? "",
139
- cover: (sourceProduct == null ? void 0 : sourceProduct.cover) ?? product.product_cover ?? "",
140
- price: (sourceProduct == null ? void 0 : sourceProduct.price) ?? sourcePrice,
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 ? { product_option_string: 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(((_f = product.product_sku) == null ? void 0 : _f.open_sold_weight) || 0) === 1 ? { product_sku: JSON.parse(JSON.stringify(product.product_sku)) } : {},
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
- var __create = Object.create;
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
- // src/modules/BookingContext/utils/cacheItemToBookingInput.ts
30
- var cacheItemToBookingInput_exports = {};
31
- __export(cacheItemToBookingInput_exports, {
32
- cacheItemToBookingInput: () => cacheItemToBookingInput
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
33
5
  });
34
- module.exports = __toCommonJS(cacheItemToBookingInput_exports);
35
- var import_dayjs = __toESM(require("dayjs"));
36
- var import_serviceTimes = require("./serviceTimes");
37
- var import_resources = require("./resources");
38
- var import_flexible = require("./flexible");
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
- return void 0;
42
- const normalized = capacity.map((item) => {
43
- if (!item || typeof item !== "object")
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 !== void 0)
52
- row.name = item.name;
43
+ if (item.name !== undefined) row.name = item.name;
53
44
  return row;
54
- }).filter((item) => item != null);
55
- return normalized.length > 0 ? normalized : void 0;
45
+ }).filter(item => item != null);
46
+ return normalized.length > 0 ? normalized : undefined;
56
47
  }
57
48
  function safeFormat(value, fmt) {
58
- if (value === void 0 || value === null)
59
- return void 0;
60
- const d = (0, import_dayjs.default)(value);
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 === void 0 || value === null)
67
- return void 0;
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
- return hhmmFromHhmmss[1];
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, import_dayjs.default)(value);
77
- if (d.isValid())
78
- return d.format("HH:mm");
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 === "number" && Number.isFinite(value))
83
- return value;
84
- if (typeof value !== "string")
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) ? void 0 : 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: (child == null ? void 0 : child.form_id) ?? parentFormId,
94
- relation_type: (child == null ? void 0 : child.relation_type) || "form",
95
- relation_id: (child == null ? void 0 : child.relation_id) ?? (child == null ? void 0 : child.id),
96
- capacity: child == null ? void 0 : child.capacity,
97
- like_status: (child == null ? void 0 : child.like_status) || "common"
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 ((child == null ? void 0 : child.metadata) !== void 0) {
100
- item.metadata = { ...child.metadata };
91
+ if (child?.metadata !== undefined) {
92
+ item.metadata = {
93
+ ...child.metadata
94
+ };
101
95
  }
102
- if (Array.isArray(child == null ? void 0 : child.children)) {
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
- var _a;
111
- const resourceMap = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.resource) || {};
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((arr) => {
115
- if (!Array.isArray(arr))
116
- return;
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 == null ? void 0 : r.form_id,
120
- relation_type: (r == null ? void 0 : r.relation_type) || "form",
121
- relation_id: r == null ? void 0 : r.relation_id,
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 = (r == null ? void 0 : r.like_status) || "common";
125
- if ((r == null ? void 0 : r.metadata) !== void 0) {
126
- item.metadata = { ...r.metadata };
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 == null ? void 0 : r.children)) {
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
- var _a, _b, _c, _d, _e, _f, _g, _h;
140
- const localFirst = (_d = (_c = (_b = (_a = cacheItem == null ? void 0 : cacheItem._data) == null ? void 0 : _a.resources) == null ? void 0 : _b[0]) == null ? void 0 : _c.select_type) == null ? void 0 : _d.type;
141
- if (localFirst)
142
- return localFirst;
143
- const productFirst = (_h = (_g = (_f = (_e = cacheItem == null ? void 0 : cacheItem.product_resource) == null ? void 0 : _e.resources) == null ? void 0 : _f[0]) == null ? void 0 : _g.select_type) == null ? void 0 : _h.type;
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
- var _a, _b;
150
- if (!cacheItem)
151
- return { metadata: { holder_id: null } };
155
+ if (!cacheItem) return {
156
+ metadata: {
157
+ holder_id: null
158
+ }
159
+ };
152
160
  const ext = cacheItem._extend || {};
153
- const isMultiDay = (0, import_serviceTimes.isMultiDayProduct)(cacheItem) || ext.is_all === 1 || ext.sub_type === "days";
154
- const isSession = (0, import_serviceTimes.isSessionProduct)(cacheItem);
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
- if (isSession && ((_a = ext == null ? void 0 : ext.other) == null ? void 0 : _a.session)) {
164
+
165
+ // ──── 日期 / 时间 ───────────────────────────────────────────────
166
+ if (isSession && ext?.other?.session) {
157
167
  const session = ext.other.session;
158
- result.start_date = safeFormat(ext.start_date || ext.startDate || session.start_at, "YYYY-MM-DD");
159
- result.start_time = normalizeTimeString(ext.start_time) || normalizeTimeString(session.start_time) || safeFormat(session.start_at, "HH:mm");
160
- result.end_date = safeFormat(ext.end_date || ext.endDate || session.end_at, "YYYY-MM-DD");
161
- result.end_time = normalizeTimeString(ext.end_time) || normalizeTimeString(session.end_time) || safeFormat(session.end_at, "HH:mm");
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, "YYYY-MM-DD");
164
- result.start_time = normalizeTimeString(ext.start_time) || safeFormat(ext.startDate, "HH:mm");
165
- result.end_date = safeFormat(ext.end_date || ext.endDate, "YYYY-MM-DD");
166
- result.end_time = normalizeTimeString(ext.end_time) || safeFormat(ext.endDate, "HH:mm");
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 = "days";
171
- result.duration = Number(ext.duration) || (0, import_serviceTimes.getDays)(cacheItem, "days");
172
- if (result.start_date)
173
- result.select_date = result.start_date;
174
- if (result.start_time && (!result.end_time || result.end_time === "00:00")) {
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 || "minutes";
193
+ result.sub_type = ext.sub_type || 'minutes';
180
194
  const duration = resolveDurationMinutes(ext.duration);
181
- if (duration !== void 0)
182
- result.duration = duration;
195
+ if (duration !== undefined) result.duration = duration;
183
196
  }
184
- result.number = (0, import_resources.getSumCapacity)(cacheItem, true);
197
+
198
+ // ──── number(人数/容量占用) ───────────────────────────────────
199
+ result.number = (0, _resources.getSumCapacity)(cacheItem, true);
200
+
201
+ // ──── resources ─────────────────────────────────────────────────
185
202
  result.resources = flattenResources(cacheItem);
186
- if (ext.holder !== void 0)
187
- result.holder = ext.holder;
188
- if (Array.isArray(ext.relation_forms))
189
- result.relation_forms = ext.relation_forms;
190
- result.like_status = ext.like_status || "common";
191
- if (cacheItem.schedule_event_id !== void 0) {
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
- const metadata = { holder_id: null };
195
- if (ext.holder_id !== void 0 && ext.holder_id !== null) {
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 !== void 0) {
220
+ if (ext.holder !== undefined) {
199
221
  metadata.holder = ext.holder;
200
222
  }
201
- if (ext.collect_pax !== void 0)
202
- metadata.collect_pax = ext.collect_pax;
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 !== void 0) {
228
+ } else if (ext.capacity_snapshot !== undefined) {
207
229
  metadata.capacity = ext.capacity_snapshot;
208
230
  }
209
- const selectType = deriveResourceSelectType(cacheItem) || ((_b = options == null ? void 0 : options.bookingConfig) == null ? void 0 : _b.resource_select_type);
210
- if (selectType)
211
- metadata.resource_select_type = selectType;
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
+ }