@pisell/pisellos 2.2.314 → 2.2.316

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 (268) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +3 -1
  3. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  4. package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
  5. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  6. package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
  7. package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
  8. package/dist/model/strategy/adapter/itemRule/type.js +10 -0
  9. package/dist/model/strategy/adapter/promotion/evaluator.js +89 -104
  10. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
  11. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +28 -4
  12. package/dist/modules/BookingContext/utils/productExtend.d.ts +7 -0
  13. package/dist/modules/BookingContext/utils/productExtend.js +62 -18
  14. package/dist/modules/BookingContext/utils/resources.js +1 -1
  15. package/dist/modules/BusinessAvailability/index.d.ts +30 -0
  16. package/dist/modules/BusinessAvailability/index.js +204 -0
  17. package/dist/modules/Cart/index.js +4 -3
  18. package/dist/modules/Cart/types.d.ts +2 -0
  19. package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
  20. package/dist/modules/Cart/utils/cartProduct.js +59 -32
  21. package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
  22. package/dist/modules/FulfillmentTiming/index.js +407 -0
  23. package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
  24. package/dist/modules/FulfillmentTiming/types.js +1 -0
  25. package/dist/modules/Holder/utils.d.ts +2 -0
  26. package/dist/modules/Holder/utils.js +32 -2
  27. package/dist/modules/OpenData/contactInfo.d.ts +20 -0
  28. package/dist/modules/OpenData/contactInfo.js +70 -0
  29. package/dist/modules/OpenData/index.d.ts +1 -0
  30. package/dist/modules/OpenData/index.js +1 -0
  31. package/dist/modules/OpenData/types.d.ts +23 -0
  32. package/dist/modules/Order/holderRelations.d.ts +14 -0
  33. package/dist/modules/Order/holderRelations.js +154 -0
  34. package/dist/modules/Order/index.d.ts +16 -4
  35. package/dist/modules/Order/index.js +926 -511
  36. package/dist/modules/Order/localEftposState.d.ts +13 -0
  37. package/dist/modules/Order/localEftposState.js +39 -0
  38. package/dist/modules/Order/pickupTiming.d.ts +46 -0
  39. package/dist/modules/Order/pickupTiming.js +53 -0
  40. package/dist/modules/Order/types.d.ts +49 -3
  41. package/dist/modules/Order/types.js +2 -0
  42. package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
  43. package/dist/modules/Order/utils/discountProductLineIdentity.js +142 -7
  44. package/dist/modules/Order/utils/orderCollectionIdentity.js +24 -10
  45. package/dist/modules/Order/utils.d.ts +2 -1
  46. package/dist/modules/Order/utils.js +61 -17
  47. package/dist/modules/Payment/index.js +9 -10
  48. package/dist/modules/Product/types.d.ts +11 -0
  49. package/dist/modules/ProductList/index.js +1 -1
  50. package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
  51. package/dist/modules/ResourcePlanner/planner.js +332 -23
  52. package/dist/modules/ResourcePlanner/types.d.ts +29 -0
  53. package/dist/modules/Rules/index.js +62 -61
  54. package/dist/modules/Schedule/index.d.ts +8 -0
  55. package/dist/modules/Schedule/index.js +141 -39
  56. package/dist/modules/index.d.ts +1 -0
  57. package/dist/modules/index.js +1 -0
  58. package/dist/plugins/request.d.ts +7 -0
  59. package/dist/server/index.d.ts +1 -0
  60. package/dist/server/index.js +1557 -1322
  61. package/dist/server/modules/form/index.d.ts +19 -0
  62. package/dist/server/modules/form/index.js +205 -0
  63. package/dist/server/modules/form/types.d.ts +13 -0
  64. package/dist/server/modules/form/types.js +3 -0
  65. package/dist/server/modules/index.d.ts +3 -0
  66. package/dist/server/modules/index.js +4 -0
  67. package/dist/server/modules/order/index.d.ts +19 -0
  68. package/dist/server/modules/order/index.js +1071 -774
  69. package/dist/server/modules/order/types.d.ts +4 -0
  70. package/dist/server/modules/products/index.d.ts +28 -7
  71. package/dist/server/modules/products/index.js +1297 -770
  72. package/dist/server/modules/products/replication.d.ts +8 -0
  73. package/dist/server/modules/products/replication.js +69 -0
  74. package/dist/server/modules/products/types.d.ts +12 -1
  75. package/dist/server/modules/products/types.js +4 -0
  76. package/dist/server/test.json +1 -1
  77. package/dist/server/utils/small-ticket.d.ts +1 -85
  78. package/dist/server/utils/small-ticket.js +2 -2542
  79. package/dist/shared/payment/loadPaymentMethods.d.ts +9 -0
  80. package/dist/shared/payment/loadPaymentMethods.js +66 -0
  81. package/dist/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  82. package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
  83. package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
  84. package/dist/shared/receipt/loadCustomerInvoiceLayout.js +184 -0
  85. package/dist/shared/receipt/small-ticket.d.ts +96 -0
  86. package/dist/shared/receipt/small-ticket.js +2763 -0
  87. package/dist/shared/receipt/templateVisibility.d.ts +26 -0
  88. package/dist/shared/receipt/templateVisibility.js +68 -0
  89. package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  90. package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
  91. package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  92. package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
  93. package/dist/solution/BaseSales/index.d.ts +43 -16
  94. package/dist/solution/BaseSales/index.js +2028 -1247
  95. package/dist/solution/BaseSales/pickupTiming.d.ts +47 -0
  96. package/dist/solution/BaseSales/pickupTiming.js +616 -0
  97. package/dist/solution/BaseSales/types.d.ts +12 -0
  98. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
  99. package/dist/solution/BaseSales/utils/parseSalesResponse.js +10 -3
  100. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -4
  101. package/dist/solution/BookingByStep/index.d.ts +4 -2
  102. package/dist/solution/BookingByStep/index.js +8 -3
  103. package/dist/solution/BookingTicket/index.d.ts +23 -3
  104. package/dist/solution/BookingTicket/index.js +867 -507
  105. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
  106. package/dist/solution/BookingTicket/utils/addProductDecision.js +1 -1
  107. package/dist/solution/BookingTicket/utils/cartView.js +3 -1
  108. package/dist/solution/OrderInvoicePreview/index.d.ts +66 -0
  109. package/dist/solution/OrderInvoicePreview/index.js +340 -0
  110. package/dist/solution/RegisterAndLogin/config.js +54 -11
  111. package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
  112. package/dist/solution/RegisterAndLogin/index.js +1 -1
  113. package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
  114. package/dist/solution/RegisterAndLogin/utils.js +36 -16
  115. package/dist/solution/ScanOrder/index.js +65 -31
  116. package/dist/solution/ScanOrder/types.d.ts +3 -0
  117. package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  118. package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
  119. package/dist/solution/UnifiedBookingSales/index.d.ts +36 -4
  120. package/dist/solution/UnifiedBookingSales/index.js +1715 -906
  121. package/dist/solution/UnifiedBookingSales/types.d.ts +16 -2
  122. package/dist/solution/VenueBooking/index.d.ts +15 -2
  123. package/dist/solution/VenueBooking/index.js +1062 -785
  124. package/dist/solution/VenueBooking/types.d.ts +2 -1
  125. package/dist/solution/VenueBooking/types.js +1 -0
  126. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  127. package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
  128. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  129. package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
  130. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  131. package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
  132. package/dist/solution/index.d.ts +1 -0
  133. package/dist/solution/index.js +2 -1
  134. package/lib/index.d.ts +2 -0
  135. package/lib/index.js +21 -1
  136. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
  137. package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
  138. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
  139. package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
  140. package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
  141. package/lib/model/strategy/adapter/itemRule/type.js +10 -0
  142. package/lib/model/strategy/adapter/promotion/evaluator.js +9 -14
  143. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  144. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
  145. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +17 -1
  146. package/lib/modules/BookingContext/utils/productExtend.d.ts +7 -0
  147. package/lib/modules/BookingContext/utils/productExtend.js +45 -2
  148. package/lib/modules/BookingContext/utils/resources.js +1 -1
  149. package/lib/modules/BusinessAvailability/index.d.ts +30 -0
  150. package/lib/modules/BusinessAvailability/index.js +146 -0
  151. package/lib/modules/Cart/index.js +4 -2
  152. package/lib/modules/Cart/types.d.ts +2 -0
  153. package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
  154. package/lib/modules/Cart/utils/cartProduct.js +39 -20
  155. package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
  156. package/lib/modules/FulfillmentTiming/index.js +359 -0
  157. package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
  158. package/lib/modules/FulfillmentTiming/types.js +5 -0
  159. package/lib/modules/Holder/utils.d.ts +2 -0
  160. package/lib/modules/Holder/utils.js +27 -1
  161. package/lib/modules/OpenData/contactInfo.d.ts +20 -0
  162. package/lib/modules/OpenData/contactInfo.js +56 -0
  163. package/lib/modules/OpenData/index.d.ts +1 -0
  164. package/lib/modules/OpenData/index.js +12 -0
  165. package/lib/modules/OpenData/types.d.ts +23 -0
  166. package/lib/modules/Order/holderRelations.d.ts +14 -0
  167. package/lib/modules/Order/holderRelations.js +98 -0
  168. package/lib/modules/Order/index.d.ts +16 -4
  169. package/lib/modules/Order/index.js +284 -50
  170. package/lib/modules/Order/localEftposState.d.ts +13 -0
  171. package/lib/modules/Order/localEftposState.js +44 -0
  172. package/lib/modules/Order/pickupTiming.d.ts +46 -0
  173. package/lib/modules/Order/pickupTiming.js +61 -0
  174. package/lib/modules/Order/types.d.ts +49 -3
  175. package/lib/modules/Order/types.js +1 -0
  176. package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
  177. package/lib/modules/Order/utils/discountProductLineIdentity.js +51 -2
  178. package/lib/modules/Order/utils/orderCollectionIdentity.js +5 -0
  179. package/lib/modules/Order/utils.d.ts +2 -1
  180. package/lib/modules/Order/utils.js +49 -11
  181. package/lib/modules/Payment/index.js +3 -4
  182. package/lib/modules/Product/types.d.ts +11 -0
  183. package/lib/modules/ProductList/index.js +1 -1
  184. package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
  185. package/lib/modules/ResourcePlanner/planner.js +252 -8
  186. package/lib/modules/ResourcePlanner/types.d.ts +29 -0
  187. package/lib/modules/Rules/index.js +2 -1
  188. package/lib/modules/Schedule/index.d.ts +8 -0
  189. package/lib/modules/Schedule/index.js +68 -12
  190. package/lib/modules/index.d.ts +1 -0
  191. package/lib/modules/index.js +11 -0
  192. package/lib/plugins/request.d.ts +7 -0
  193. package/lib/server/index.d.ts +1 -0
  194. package/lib/server/index.js +166 -39
  195. package/lib/server/modules/form/index.d.ts +19 -0
  196. package/lib/server/modules/form/index.js +73 -0
  197. package/lib/server/modules/form/types.d.ts +13 -0
  198. package/lib/server/modules/form/types.js +9 -0
  199. package/lib/server/modules/index.d.ts +3 -0
  200. package/lib/server/modules/index.js +15 -1
  201. package/lib/server/modules/order/index.d.ts +19 -0
  202. package/lib/server/modules/order/index.js +160 -7
  203. package/lib/server/modules/order/types.d.ts +4 -0
  204. package/lib/server/modules/products/index.d.ts +28 -7
  205. package/lib/server/modules/products/index.js +226 -63
  206. package/lib/server/modules/products/replication.d.ts +8 -0
  207. package/lib/server/modules/products/replication.js +30 -0
  208. package/lib/server/modules/products/types.d.ts +12 -1
  209. package/lib/server/modules/products/types.js +3 -0
  210. package/lib/server/test.json +1 -1
  211. package/lib/server/utils/small-ticket.d.ts +1 -85
  212. package/lib/server/utils/small-ticket.js +9 -2305
  213. package/lib/shared/payment/loadPaymentMethods.d.ts +9 -0
  214. package/lib/shared/payment/loadPaymentMethods.js +40 -0
  215. package/lib/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  216. package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
  217. package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
  218. package/lib/shared/receipt/loadCustomerInvoiceLayout.js +124 -0
  219. package/lib/shared/receipt/small-ticket.d.ts +96 -0
  220. package/lib/shared/receipt/small-ticket.js +2555 -0
  221. package/lib/shared/receipt/templateVisibility.d.ts +26 -0
  222. package/lib/shared/receipt/templateVisibility.js +67 -0
  223. package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  224. package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
  225. package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
  226. package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
  227. package/lib/solution/BaseSales/index.d.ts +43 -16
  228. package/lib/solution/BaseSales/index.js +401 -33
  229. package/lib/solution/BaseSales/pickupTiming.d.ts +47 -0
  230. package/lib/solution/BaseSales/pickupTiming.js +290 -0
  231. package/lib/solution/BaseSales/types.d.ts +12 -0
  232. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
  233. package/lib/solution/BaseSales/utils/parseSalesResponse.js +7 -0
  234. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -8
  235. package/lib/solution/BookingByStep/index.d.ts +4 -2
  236. package/lib/solution/BookingByStep/index.js +7 -3
  237. package/lib/solution/BookingTicket/index.d.ts +23 -3
  238. package/lib/solution/BookingTicket/index.js +197 -9
  239. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
  240. package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -1
  241. package/lib/solution/BookingTicket/utils/cartView.js +3 -1
  242. package/lib/solution/OrderInvoicePreview/index.d.ts +66 -0
  243. package/lib/solution/OrderInvoicePreview/index.js +246 -0
  244. package/lib/solution/RegisterAndLogin/config.js +57 -11
  245. package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
  246. package/lib/solution/RegisterAndLogin/index.js +9 -1
  247. package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
  248. package/lib/solution/RegisterAndLogin/utils.js +24 -17
  249. package/lib/solution/ScanOrder/index.js +59 -20
  250. package/lib/solution/ScanOrder/types.d.ts +3 -0
  251. package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  252. package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
  253. package/lib/solution/UnifiedBookingSales/index.d.ts +36 -4
  254. package/lib/solution/UnifiedBookingSales/index.js +562 -75
  255. package/lib/solution/UnifiedBookingSales/types.d.ts +16 -2
  256. package/lib/solution/VenueBooking/index.d.ts +15 -2
  257. package/lib/solution/VenueBooking/index.js +243 -96
  258. package/lib/solution/VenueBooking/types.d.ts +2 -1
  259. package/lib/solution/VenueBooking/types.js +1 -0
  260. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  261. package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
  262. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  263. package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
  264. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  265. package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
  266. package/lib/solution/index.d.ts +1 -0
  267. package/lib/solution/index.js +11 -0
  268. package/package.json +1 -1
@@ -1,4 +1,3 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
1
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
2
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
3
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -10,6 +9,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
10
9
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
10
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
11
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
12
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
13
13
  import dayjs from 'dayjs';
14
14
  import { formatResources, getResourceByIds, getSumCapacity, getUsableTime, setDefaultCapacitys, setDefaultResource } from "./resources";
15
15
  import { hasActualResourceSelection, productNeedsResourceExtend } from "./resourceSelection";
@@ -24,6 +24,46 @@ import { flexibleObj, getDurationValue, isProductFlexibleDuration } from "./flex
24
24
  * 让 OS 这层完全可在 Node 单测下运行(dayjs 在 Node 也是纯函数)。
25
25
  */
26
26
 
27
+ /** Rebuild only the derived booking fields; SKU, quantity, notes and Holder stay intact. */
28
+ function seedRememberedBookingStart(cacheItem, ctx) {
29
+ var _cacheItem$cartDetail, _cacheItem$_extend;
30
+ var remembered = ctx.rememberedTime;
31
+ var invalid = function invalid() {
32
+ return Object.assign(new Error('Remembered time requires a valid POS duration start.'), {
33
+ code: 'INVALID_REMEMBERED_TIME'
34
+ });
35
+ };
36
+ var duration = cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.duration;
37
+ var durationType = _typeof(duration) === 'object' && duration ? String(duration.type || '').toLowerCase() : '';
38
+ var durationValue = _typeof(duration) === 'object' && duration ? duration.value : duration;
39
+ var isDuration = isProductFlexibleDuration(duration) || ['', 'fixed', 'minute', 'minutes', 'hour', 'hours'].includes(durationType) && Number.isFinite(Number(durationValue)) && Number(durationValue) > 0;
40
+ var isCalendarDate = function isCalendarDate(value) {
41
+ if (typeof value !== 'string' || !/^\d{4}-\d{2}-\d{2}$/.test(value)) return false;
42
+ var date = new Date("".concat(value, "T00:00:00.000Z"));
43
+ return Number.isFinite(date.getTime()) && date.toISOString().slice(0, 10) === value;
44
+ };
45
+ var parts = typeof (remembered === null || remembered === void 0 ? void 0 : remembered.startAt) === 'string' ? /^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,3})?)?(?:Z|[+-](\d{2}):(\d{2}))?$/.exec(remembered.startAt) : null;
46
+ if (String(ctx.channel || '').trim().toLowerCase() !== 'pos' || !isDuration || isMultiDayProduct(cacheItem) || isSessionProduct(cacheItem) || cacheItem !== null && cacheItem !== void 0 && (_cacheItem$cartDetail = cacheItem.cartDetailValue) !== null && _cacheItem$cartDetail !== void 0 && _cacheItem$cartDetail.session || cacheItem !== null && cacheItem !== void 0 && (_cacheItem$_extend = cacheItem._extend) !== null && _cacheItem$_extend !== void 0 && (_cacheItem$_extend = _cacheItem$_extend.other) !== null && _cacheItem$_extend !== void 0 && _cacheItem$_extend.session || !isCalendarDate(remembered === null || remembered === void 0 ? void 0 : remembered.businessDate) || !parts || !isCalendarDate(parts[1]) || Number(parts[2]) > 23 || Number(parts[3]) > 59 || Number(parts[4] || 0) > 59 || Number(parts[5] || 0) > 23 || Number(parts[6] || 0) > 59) throw invalid();
47
+ // Parse the actual instant with the same runtime clock used by the legacy booking helpers.
48
+ // The business-day label must not replace the calendar date of an overnight start.
49
+ var start = dayjs(remembered.startAt);
50
+ if (!start.isValid()) throw invalid();
51
+ var extend = _objectSpread({}, (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem._extend) || {});
52
+ for (var _i = 0, _arr = ['start_date', 'startDate', 'start_time', 'end_date', 'endDate', 'end_time', 'duration', 'resource', 'resources', 'capacity', 'booking', 'availabilitySelection']; _i < _arr.length; _i++) {
53
+ var key = _arr[_i];
54
+ delete extend[key];
55
+ }
56
+ return _objectSpread(_objectSpread({}, cacheItem), {}, {
57
+ new: 1,
58
+ autoClose: false,
59
+ _data: {},
60
+ _extend: _objectSpread(_objectSpread({}, extend), {}, {
61
+ start_date: start.format('YYYY-MM-DD'),
62
+ start_time: start.format(start.millisecond() ? 'HH:mm:ss.SSS' : start.second() ? 'HH:mm:ss' : 'HH:mm')
63
+ })
64
+ });
65
+ }
66
+
27
67
  /** 从 BookingContext.date 提取 HH:mm(仅当日期带有效时分时)。 */
28
68
  export function derivePresetStartTimeFromDate(date) {
29
69
  if (date == null) return undefined;
@@ -46,12 +86,12 @@ function getAppointmentTimingPreference(ctx) {
46
86
  * 灵活时长选项(cacheItem.duration.type === 'flexible' 时)。
47
87
  */
48
88
  function getFlexibleOption(params) {
49
- var _cacheItem$_extend, _cacheItem$_extend2, _usable$_extend, _params$ctx;
89
+ var _cacheItem$_extend2, _cacheItem$_extend3, _usable$_extend, _params$ctx;
50
90
  var cacheItem = params.cacheItem,
51
91
  useStartTime = params.useStartTime;
52
92
  var duration = getDurationValue(cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.duration);
53
93
  if (duration !== 'flexible') return null;
54
- var startDate = dayjs("".concat(dayjs(cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.start_date).format('YYYY-MM-DD'), " ").concat(useStartTime || (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.start_time) || '00:00'));
94
+ var startDate = dayjs("".concat(dayjs(cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.start_date).format('YYYY-MM-DD'), " ").concat(useStartTime || (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend3 = cacheItem._extend) === null || _cacheItem$_extend3 === void 0 ? void 0 : _cacheItem$_extend3.start_time) || '00:00'));
55
95
  var usable = getUsableTime(cacheItem);
56
96
  var usableEndAt = usable !== null && usable !== void 0 && (_usable$_extend = usable._extend) !== null && _usable$_extend !== void 0 && (_usable$_extend = _usable$_extend.usableTime) !== null && _usable$_extend !== void 0 && _usable$_extend.end_at ? dayjs(usable._extend.usableTime.end_at) : null;
57
97
  var endDate = getEndDate(startDate, 'flexible', usableEndAt, (_params$ctx = params.ctx) === null || _params$ctx === void 0 ? void 0 : _params$ctx.shopOpeningHours);
@@ -105,7 +145,7 @@ export function getTimeObj(params) {
105
145
  * - cacheItem.isCustomItem → 直接返回 `{ duration: null }`。
106
146
  */
107
147
  export function getServiceStartTimeAndEndTime(params) {
108
- var _cacheItem$_extend3;
148
+ var _cacheItem$_extend4;
109
149
  var cacheItem = params.cacheItem,
110
150
  timeObj = params.timeObj,
111
151
  ctx = params.ctx;
@@ -163,7 +203,7 @@ export function getServiceStartTimeAndEndTime(params) {
163
203
  _extend.start_date = (_extend$start_date = _extend.start_date) !== null && _extend$start_date !== void 0 ? _extend$start_date : startDate;
164
204
  _extend.end_date = (_extend$end_date = _extend.end_date) !== null && _extend$end_date !== void 0 ? _extend$end_date : endDate;
165
205
  }
166
- var session = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend3 = cacheItem._extend) === null || _cacheItem$_extend3 === void 0 || (_cacheItem$_extend3 = _cacheItem$_extend3.other) === null || _cacheItem$_extend3 === void 0 ? void 0 : _cacheItem$_extend3.session;
206
+ var session = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend4 = cacheItem._extend) === null || _cacheItem$_extend4 === void 0 || (_cacheItem$_extend4 = _cacheItem$_extend4.other) === null || _cacheItem$_extend4 === void 0 ? void 0 : _cacheItem$_extend4.session;
167
207
  if (isSessionProduct(cacheItem) && session) {
168
208
  var baseDate = ctx.date ? dayjs(ctx.date) : dayjs();
169
209
  var startAt = dayjs("".concat(baseDate.format('YYYY-MM-DD'), " ").concat(dayjs(session.start_at).format('HH:mm:ss')));
@@ -188,18 +228,22 @@ export function getServiceStartTimeAndEndTime(params) {
188
228
  * 入参 ctx 必须至少给:bookingConfig / resourcesOriginMap / resourcesOrigin / date。
189
229
  */
190
230
  export function getProductExtend(params) {
191
- var _cacheItem$_extend4;
192
- var cacheItem = params.cacheItem,
193
- ctx = params.ctx,
194
- isDisabledTime = params.isDisabledTime;
195
- var isNew = cacheItem.new || !((_cacheItem$_extend4 = cacheItem._extend) !== null && _cacheItem$_extend4 !== void 0 && _cacheItem$_extend4.endDate);
231
+ var _cacheItem$_extend5;
232
+ var isDisabledTime = params.isDisabledTime;
233
+ var hasRememberedTime = params.ctx.rememberedTime !== undefined;
234
+ var cacheItem = hasRememberedTime ? seedRememberedBookingStart(params.cacheItem, params.ctx) : params.cacheItem;
235
+ var ctx = hasRememberedTime ? _objectSpread(_objectSpread({}, params.ctx), {}, {
236
+ previousService: undefined,
237
+ presetStartTime: undefined
238
+ }) : params.ctx;
239
+ var isNew = cacheItem.new || !((_cacheItem$_extend5 = cacheItem._extend) !== null && _cacheItem$_extend5 !== void 0 && _cacheItem$_extend5.endDate);
196
240
  var _cacheItem = _objectSpread({}, cacheItem);
197
241
  var resourcesOriginMap = ctx.resourcesOriginMap || {};
198
242
  _cacheItem._data = {};
199
243
  if (isMultiDayProduct(cacheItem)) {
200
- var _cacheItem$_extend5;
244
+ var _cacheItem$_extend6;
201
245
  _cacheItem._extend = _cacheItem._extend || {};
202
- _cacheItem._extend.holder_id = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend5 = cacheItem._extend) === null || _cacheItem$_extend5 === void 0 ? void 0 : _cacheItem$_extend5.holder_id) || [];
246
+ _cacheItem._extend.holder_id = (cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend6 = cacheItem._extend) === null || _cacheItem$_extend6 === void 0 ? void 0 : _cacheItem$_extend6.holder_id) || [];
203
247
  _cacheItem._extend.sub_type = 'days';
204
248
  }
205
249
  if (isNew) {
@@ -260,14 +304,14 @@ export function getProductExtend(params) {
260
304
  _cacheItem._time = new Date().getTime();
261
305
  }
262
306
  } else {
263
- var _cacheItem$_extend7;
307
+ var _cacheItem$_extend8;
264
308
  if (!_cacheItem._data.capacitys) {
265
309
  _cacheItem._data.capacitys = cacheItem.capacity;
266
310
  }
267
311
  if (!_cacheItem._data.resourcesOrigin) {
268
- var _cacheItem$_extend6, _ctx$bookingConfig4;
312
+ var _cacheItem$_extend7, _ctx$bookingConfig4;
269
313
  var extraResources = [];
270
- if (Array.isArray((_cacheItem$_extend6 = _cacheItem._extend) === null || _cacheItem$_extend6 === void 0 ? void 0 : _cacheItem$_extend6.event_resources)) {
314
+ if (Array.isArray((_cacheItem$_extend7 = _cacheItem._extend) === null || _cacheItem$_extend7 === void 0 ? void 0 : _cacheItem$_extend7.event_resources)) {
271
315
  _cacheItem._extend.event_resources.forEach(function (er) {
272
316
  extraResources.push({
273
317
  form_id: er.form_id,
@@ -293,7 +337,7 @@ export function getProductExtend(params) {
293
337
  }
294
338
  _cacheItem._data.timeObj = getTimeObj({
295
339
  cacheItem: _cacheItem,
296
- useStartTime: (_cacheItem$_extend7 = _cacheItem._extend) === null || _cacheItem$_extend7 === void 0 ? void 0 : _cacheItem$_extend7.start_time,
340
+ useStartTime: (_cacheItem$_extend8 = _cacheItem._extend) === null || _cacheItem$_extend8 === void 0 ? void 0 : _cacheItem$_extend8.start_time,
297
341
  ctx: ctx
298
342
  });
299
343
  }
@@ -306,7 +350,7 @@ export function getProductExtend(params) {
306
350
  * `getAutoAllocationStorage` 抽象为入参 `isAutoAllocationOn(formId)`。
307
351
  */
308
352
  export function getIsAutoClose(cacheItem, isAutoAllocationOn) {
309
- var _cacheItem$_data, _cacheItem$_extend8;
353
+ var _cacheItem$_data, _cacheItem$_extend9;
310
354
  if (productNeedsResourceExtend(cacheItem) && !hasActualResourceSelection(cacheItem)) {
311
355
  return false;
312
356
  }
@@ -321,7 +365,7 @@ export function getIsAutoClose(cacheItem, isAutoAllocationOn) {
321
365
  }
322
366
  }
323
367
  }
324
- var entries = Object.entries(((_cacheItem$_extend8 = cacheItem._extend) === null || _cacheItem$_extend8 === void 0 ? void 0 : _cacheItem$_extend8.resource) || {});
368
+ var entries = Object.entries(((_cacheItem$_extend9 = cacheItem._extend) === null || _cacheItem$_extend9 === void 0 ? void 0 : _cacheItem$_extend9.resource) || {});
325
369
  if (entries.length === 0) {
326
370
  return !productNeedsResourceExtend(cacheItem);
327
371
  }
@@ -260,7 +260,7 @@ function getResourceMaxFreeTime(resource, isAutoAllocationOn) {
260
260
  return d.usable && d.id !== 0;
261
261
  });
262
262
  var defaultResource = [];
263
- var maxFreeTime = 0;
263
+ var maxFreeTime = -1;
264
264
  usableList.forEach(function (d) {
265
265
  var _d$times = d.times,
266
266
  times = _d$times === void 0 ? [] : _d$times;
@@ -0,0 +1,30 @@
1
+ import type { MultiLangObject } from '../OpenData/types';
2
+ import type { ScheduleItem } from '../Schedule/types';
3
+ export type BusinessClosedBehavior = 'show_menu_disabled' | 'hide_all';
4
+ export interface BusinessAvailability {
5
+ status: 'open' | 'paused' | 'closed' | 'error';
6
+ behavior: BusinessClosedBehavior | null;
7
+ message: string | MultiLangObject | null;
8
+ /** Epoch milliseconds. Re-evaluate the cached configuration at this time. */
9
+ nextChangeAt: number;
10
+ requirePaymentOnSubmit: boolean;
11
+ error?: string;
12
+ }
13
+ export interface BusinessAvailabilityConfig {
14
+ paused: boolean;
15
+ pauseBehavior: BusinessClosedBehavior;
16
+ closedBehavior: BusinessClosedBehavior;
17
+ pauseMessage: BusinessAvailability['message'];
18
+ closedMessage: BusinessAvailability['message'];
19
+ scheduleIds: number[];
20
+ invalidScheduleIds: boolean;
21
+ requirePaymentOnSubmit: boolean;
22
+ }
23
+ export declare function normalizeBusinessAvailabilityConfig(data: Record<string, unknown>): BusinessAvailabilityConfig;
24
+ /** Business ordering is independent of reservation switches and Pickup slot availability. */
25
+ export declare function computeBusinessAvailability(input: {
26
+ config: BusinessAvailabilityConfig;
27
+ schedules: ScheduleItem[];
28
+ timezone: string;
29
+ now: Date;
30
+ }): BusinessAvailability;
@@ -0,0 +1,204 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
4
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
5
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
6
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
11
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
15
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
17
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
18
+ import dayjs from 'dayjs';
19
+ import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
20
+ import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
21
+ import { getScheduleStartEndTimePoints } from "../Schedule/getDateIsInSchedule";
22
+ dayjs.extend(isSameOrAfter);
23
+ dayjs.extend(isSameOrBefore);
24
+ var DAY = 86400000;
25
+ var behavior = function behavior(value) {
26
+ return value === 'show_menu_disabled' ? value : 'hide_all';
27
+ };
28
+ var message = function message(value) {
29
+ return typeof value === 'string' || value !== null && _typeof(value) === 'object' && !Array.isArray(value) ? value : null;
30
+ };
31
+ export function normalizeBusinessAvailabilityConfig(data) {
32
+ var rawIds = data['availability.operating_hours'];
33
+ var ids = Array.isArray(rawIds) ? rawIds.map(function (id) {
34
+ return typeof id === 'number' || typeof id === 'string' ? Number(id) : NaN;
35
+ }) : [];
36
+ var validIds = ids.filter(function (id) {
37
+ return Number.isInteger(id) && id > 0;
38
+ });
39
+ var paused = data['availability.paused'];
40
+ return {
41
+ paused: paused === true || paused === 1 || paused === 'true' || paused === '1',
42
+ pauseBehavior: behavior(data['availability.pause_behavior']),
43
+ closedBehavior: behavior(data['availability.closed_behavior']),
44
+ pauseMessage: message(data['availability.pause_message']),
45
+ closedMessage: message(data['availability.closed_message']),
46
+ scheduleIds: _toConsumableArray(new Set(validIds)),
47
+ invalidScheduleIds: rawIds != null && (!Array.isArray(rawIds) || validIds.length !== ids.length),
48
+ // Only an explicitly disabled setting changes the existing payment flow.
49
+ requirePaymentOnSubmit: data['sale.require_payment_on_submit'] !== false
50
+ };
51
+ }
52
+ function createClock(timezone) {
53
+ if (!timezone) throw new Error('Store timezone is unavailable.');
54
+ var formatter = new Intl.DateTimeFormat('en-GB', {
55
+ timeZone: timezone,
56
+ year: 'numeric',
57
+ month: '2-digit',
58
+ day: '2-digit',
59
+ hour: '2-digit',
60
+ minute: '2-digit',
61
+ second: '2-digit',
62
+ hourCycle: 'h23'
63
+ });
64
+ var local = function local(timestamp) {
65
+ var parts = {};
66
+ formatter.formatToParts(timestamp).forEach(function (part) {
67
+ parts[part.type] = part.value;
68
+ });
69
+ var date = "".concat(parts.year, "-").concat(parts.month, "-").concat(parts.day);
70
+ return {
71
+ date: date,
72
+ scalar: Date.parse("".concat(date, "T").concat(parts.hour, ":").concat(parts.minute, ":").concat(parts.second, "Z"))
73
+ };
74
+ };
75
+ var offsets = new Set();
76
+ var instants = function instants(scalar) {
77
+ offsets.clear();
78
+ for (var hours = -36; hours <= 36; hours += 6) {
79
+ var sample = scalar + hours * 3600000;
80
+ offsets.add(local(sample).scalar - sample);
81
+ }
82
+ return _toConsumableArray(offsets).map(function (offset) {
83
+ return scalar - offset;
84
+ }).filter(function (instant) {
85
+ return local(instant).scalar === scalar;
86
+ }).sort(function (a, b) {
87
+ return a - b;
88
+ });
89
+ };
90
+ return {
91
+ local: local,
92
+ instants: instants
93
+ };
94
+ }
95
+
96
+ /** Business ordering is independent of reservation switches and Pickup slot availability. */
97
+ export function computeBusinessAvailability(input) {
98
+ var config = input.config,
99
+ schedules = input.schedules,
100
+ timezone = input.timezone,
101
+ now = input.now;
102
+ var nowAt = now.getTime();
103
+ var base = {
104
+ requirePaymentOnSubmit: config.requirePaymentOnSubmit,
105
+ nextChangeAt: nowAt + DAY
106
+ };
107
+ if (config.paused) {
108
+ return _objectSpread(_objectSpread({}, base), {}, {
109
+ status: 'paused',
110
+ behavior: config.pauseBehavior,
111
+ message: config.pauseMessage
112
+ });
113
+ }
114
+ if (config.invalidScheduleIds) throw new Error('Business operating-hours configuration is invalid.');
115
+ if (!config.scheduleIds.length) return _objectSpread(_objectSpread({}, base), {}, {
116
+ status: 'open',
117
+ behavior: null,
118
+ message: null
119
+ });
120
+ var selected = schedules.filter(function (schedule) {
121
+ return config.scheduleIds.includes(Number(schedule.id));
122
+ });
123
+ if (config.scheduleIds.some(function (id) {
124
+ return !selected.some(function (schedule) {
125
+ return Number(schedule.id) === id;
126
+ });
127
+ })) {
128
+ throw new Error('A configured business operating-hours schedule is unavailable.');
129
+ }
130
+ var clock = createClock(timezone);
131
+ var current = clock.local(nowAt);
132
+ var today = Date.parse("".concat(current.date, "T00:00:00Z"));
133
+ var nextMidnight = clock.instants(today + DAY).find(function (instant) {
134
+ return instant > nowAt;
135
+ });
136
+ var nextChangeAt = nextMidnight !== null && nextMidnight !== void 0 ? nextMidnight : nowAt + 60000;
137
+ var open = false;
138
+ // Yesterday contributes the tail of overnight windows; today supplies the next boundary.
139
+ for (var _i = 0, _arr = [today - DAY, today]; _i < _arr.length; _i++) {
140
+ var dateAt = _arr[_i];
141
+ var date = new Date(dateAt).toISOString().slice(0, 10);
142
+ // Schedule's resolver merges by time-of-day, so resolve each schedule independently.
143
+ var _iterator = _createForOfIteratorHelper(selected),
144
+ _step;
145
+ try {
146
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
147
+ var schedule = _step.value;
148
+ var _iterator2 = _createForOfIteratorHelper(getScheduleStartEndTimePoints(date, [schedule])),
149
+ _step2;
150
+ try {
151
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
152
+ var window = _step2.value;
153
+ var toMinutes = function toMinutes(value) {
154
+ if (!/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(value) && value !== '24:00') {
155
+ throw new Error('Business operating-hours schedule contains an invalid time.');
156
+ }
157
+ var _value$split$map = value.split(':').map(Number),
158
+ _value$split$map2 = _slicedToArray(_value$split$map, 2),
159
+ hours = _value$split$map2[0],
160
+ minutes = _value$split$map2[1];
161
+ return hours * 60 + minutes;
162
+ };
163
+ var start = dateAt + toMinutes(window.start_time) * 60000;
164
+ var end = dateAt + toMinutes(window.end_time) * 60000;
165
+ if (end <= start) end += DAY;
166
+ if (current.scalar >= start && current.scalar < end) open = true;
167
+ for (var _i2 = 0, _arr2 = [start, end]; _i2 < _arr2.length; _i2++) {
168
+ var boundary = _arr2[_i2];
169
+ var _iterator3 = _createForOfIteratorHelper(clock.instants(boundary)),
170
+ _step3;
171
+ try {
172
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
173
+ var instant = _step3.value;
174
+ if (instant > nowAt) nextChangeAt = Math.min(nextChangeAt, instant);
175
+ }
176
+ } catch (err) {
177
+ _iterator3.e(err);
178
+ } finally {
179
+ _iterator3.f();
180
+ }
181
+ }
182
+ }
183
+ } catch (err) {
184
+ _iterator2.e(err);
185
+ } finally {
186
+ _iterator2.f();
187
+ }
188
+ }
189
+ } catch (err) {
190
+ _iterator.e(err);
191
+ } finally {
192
+ _iterator.f();
193
+ }
194
+ }
195
+ // A timezone offset change can repeat/skip a wall-clock boundary. A local-only safety
196
+ // check also covers throttled timers; it does not fetch either configuration source.
197
+ nextChangeAt = Math.min(nextChangeAt, nowAt + 60000);
198
+ return _objectSpread(_objectSpread({}, base), {}, {
199
+ nextChangeAt: nextChangeAt,
200
+ status: open ? 'open' : 'closed',
201
+ behavior: open ? null : config.closedBehavior,
202
+ message: open ? null : config.closedMessage
203
+ });
204
+ }
@@ -113,11 +113,11 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
113
113
  key: "addItem",
114
114
  value: (function () {
115
115
  var _addItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
116
- var account, product, bundle, options, date, _params$quantity, quantity, cartItem, newProduct, items;
116
+ var account, product, bundle, options, date, _params$quantity, quantity, isLegacyOrder, cartItem, newProduct, items;
117
117
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
118
118
  while (1) switch (_context2.prev = _context2.next) {
119
119
  case 0:
120
- account = params.account, product = params.product, bundle = params.bundle, options = params.options, date = params.date, _params$quantity = params.quantity, quantity = _params$quantity === void 0 ? 1 : _params$quantity; // 生成一个唯一的 ID
120
+ account = params.account, product = params.product, bundle = params.bundle, options = params.options, date = params.date, _params$quantity = params.quantity, quantity = _params$quantity === void 0 ? 1 : _params$quantity, isLegacyOrder = params.isLegacyOrder; // 生成一个唯一的 ID
121
121
  cartItem = {
122
122
  _id: getUniqueId(),
123
123
  _origin: createCartItemOrigin()
@@ -134,7 +134,8 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
134
134
  bundle: bundle,
135
135
  options: options,
136
136
  product_variant_id: newProduct.product_variant_id,
137
- quantity: quantity
137
+ quantity: quantity,
138
+ isLegacyOrder: isLegacyOrder
138
139
  });
139
140
  }
140
141
  if (account) {
@@ -180,6 +180,8 @@ export interface IAddItemParams {
180
180
  };
181
181
  /** 商品组合规格ID */
182
182
  product_variant_id?: number;
183
+ /** 是否由旧版下单流程加入购物车 */
184
+ isLegacyOrder?: boolean;
183
185
  }
184
186
  /**
185
187
  * 更新购物车信息参数
@@ -21,6 +21,7 @@ export declare const formatProductToCartItem: (params: {
21
21
  product_variant_id?: number;
22
22
  quantity?: number;
23
23
  discounts?: any[];
24
+ isLegacyOrder?: boolean;
24
25
  }) => CartItem;
25
26
  export declare const formatProductToCartItemOrigin: (params: {
26
27
  cartItem: CartItem;
@@ -29,6 +30,7 @@ export declare const formatProductToCartItemOrigin: (params: {
29
30
  options?: any;
30
31
  product_variant_id?: number;
31
32
  quantity?: number;
33
+ isLegacyOrder?: boolean;
32
34
  }) => any;
33
35
  /**
34
36
  * 获取商品总价
@@ -61,7 +63,7 @@ export declare const getProductOriginTotalPrice: (params: {
61
63
  * @param options 套餐规格信息
62
64
  * @returns 格式化后的套餐规格信息
63
65
  */
64
- export declare const formatOptions: (options: any) => any;
66
+ export declare const formatOptions: (options: any, product?: ProductData) => any;
65
67
  export declare const formatOptionsToOrigin: (options: any) => any;
66
68
  /**
67
69
  * 格式化商品套餐信息