@pisell/pisellos 2.3.74 → 2.3.76

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 (283) hide show
  1. package/dist/core/index.js +6 -10
  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 +1 -1
  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/plugins/request.js +1 -4
  19. package/dist/plugins/window.js +2 -6
  20. package/dist/server/index.js +97 -129
  21. package/dist/server/modules/menu/index.js +32 -41
  22. package/dist/server/modules/order/index.js +2 -4
  23. package/dist/server/modules/products/index.js +24 -42
  24. package/dist/server/modules/quotation/index.js +29 -38
  25. package/dist/server/modules/resource/index.js +3 -4
  26. package/dist/server/modules/schedule/index.js +27 -35
  27. package/dist/server/utils/product.js +0 -1
  28. package/dist/solution/BaseSales/index.js +100 -72
  29. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
  30. package/dist/solution/BaseSales/utils/cartPromotion.js +15 -6
  31. package/dist/solution/BookingByStep/index.js +7 -59
  32. package/dist/solution/BookingByStep/utils/capacity.js +1 -11
  33. package/dist/solution/BookingByStep/utils/resources.js +1 -3
  34. package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
  35. package/dist/solution/BookingTicket/index.js +0 -2
  36. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +6 -7
  37. package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
  38. package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
  39. package/dist/solution/BuyTickets/index.js +9 -12
  40. package/dist/solution/Checkout/index.js +177 -252
  41. package/dist/solution/Checkout/utils/index.js +4 -16
  42. package/dist/solution/RegisterAndLogin/index.js +30 -76
  43. package/dist/solution/ScanOrder/index.js +50 -60
  44. package/dist/solution/ShopDiscount/index.js +2 -7
  45. package/dist/solution/VenueBooking/index.js +45 -55
  46. package/dist/utils/task.js +15 -18
  47. package/dist/utils/watch.js +0 -1
  48. package/lib/apis/picoding.js +2 -0
  49. package/lib/core/index.js +134 -134
  50. package/lib/effects/index.js +46 -57
  51. package/lib/index.js +82 -49
  52. package/lib/model/index.js +14 -21
  53. package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
  54. package/lib/model/strategy/adapter/dataVariant/evaluator.js +162 -236
  55. package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
  56. package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
  57. package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
  58. package/lib/model/strategy/adapter/index.js +100 -64
  59. package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
  60. package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
  61. package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
  62. package/lib/model/strategy/adapter/itemRule/index.js +83 -57
  63. package/lib/model/strategy/adapter/itemRule/type.js +97 -36
  64. package/lib/model/strategy/adapter/promotion/adapter.js +91 -69
  65. package/lib/model/strategy/adapter/promotion/evaluator.js +444 -310
  66. package/lib/model/strategy/adapter/promotion/examples.js +222 -234
  67. package/lib/model/strategy/adapter/promotion/index.js +1 -0
  68. package/lib/model/strategy/adapter/promotion/type.js +243 -36
  69. package/lib/model/strategy/adapter/type.js +4 -16
  70. package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -150
  71. package/lib/model/strategy/adapter/walletPass/example.js +217 -190
  72. package/lib/model/strategy/adapter/walletPass/index.js +75 -51
  73. package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
  74. package/lib/model/strategy/adapter/walletPass/type.js +4 -16
  75. package/lib/model/strategy/adapter/walletPass/utils.js +588 -378
  76. package/lib/model/strategy/engine.js +270 -168
  77. package/lib/model/strategy/index.js +49 -34
  78. package/lib/model/strategy/strategy-example.js +243 -239
  79. package/lib/model/strategy/type.js +100 -40
  80. package/lib/modules/Account/index.js +39 -53
  81. package/lib/modules/Account/types.js +20 -33
  82. package/lib/modules/AccountList/index.js +116 -154
  83. package/lib/modules/AccountList/types.js +30 -31
  84. package/lib/modules/AccountList/utils.js +18 -30
  85. package/lib/modules/BaseModule.js +23 -42
  86. package/lib/modules/BookingContext/index.js +158 -136
  87. package/lib/modules/BookingContext/types.js +46 -32
  88. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +138 -146
  89. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +78 -83
  90. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +170 -150
  91. package/lib/modules/BookingContext/utils/flexible.js +38 -55
  92. package/lib/modules/BookingContext/utils/formatResourceList.js +19 -34
  93. package/lib/modules/BookingContext/utils/index.js +124 -41
  94. package/lib/modules/BookingContext/utils/noResource.js +58 -70
  95. package/lib/modules/BookingContext/utils/orderLineDisplay.js +14 -41
  96. package/lib/modules/BookingContext/utils/productExtend.js +202 -155
  97. package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
  98. package/lib/modules/BookingContext/utils/resourceSelection.js +19 -41
  99. package/lib/modules/BookingContext/utils/resources.js +209 -167
  100. package/lib/modules/BookingContext/utils/serviceTimes.js +115 -116
  101. package/lib/modules/BookingContext/utils/timeSlices.js +76 -86
  102. package/lib/modules/Cart/index.js +170 -124
  103. package/lib/modules/Cart/types.js +46 -51
  104. package/lib/modules/Cart/utils/cartAccount.js +40 -39
  105. package/lib/modules/Cart/utils/cartDate.js +56 -61
  106. package/lib/modules/Cart/utils/cartDiscount.js +28 -33
  107. package/lib/modules/Cart/utils/cartNote.js +27 -32
  108. package/lib/modules/Cart/utils/cartProduct.js +321 -251
  109. package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
  110. package/lib/modules/Cart/utils/cartResource.js +70 -78
  111. package/lib/modules/Cart/utils/changePrice.js +22 -50
  112. package/lib/modules/Cart/utils/index.js +106 -48
  113. package/lib/modules/Customer/constants.js +13 -34
  114. package/lib/modules/Customer/index.js +235 -172
  115. package/lib/modules/Customer/types.js +38 -35
  116. package/lib/modules/Date/index.js +116 -115
  117. package/lib/modules/Date/types.js +16 -28
  118. package/lib/modules/Date/utils.js +174 -123
  119. package/lib/modules/Discount/index.js +122 -127
  120. package/lib/modules/Discount/types.js +9 -31
  121. package/lib/modules/Guests/index.js +30 -56
  122. package/lib/modules/Guests/types.js +23 -33
  123. package/lib/modules/Holder/index.js +209 -189
  124. package/lib/modules/Holder/types.js +4 -16
  125. package/lib/modules/Holder/utils.js +20 -49
  126. package/lib/modules/OpenData/index.js +70 -76
  127. package/lib/modules/OpenData/types.js +4 -16
  128. package/lib/modules/OpenData/utils.js +44 -78
  129. package/lib/modules/Order/index.d.ts +1 -1
  130. package/lib/modules/Order/index.js +1733 -2121
  131. package/lib/modules/Order/payment-utils.js +77 -120
  132. package/lib/modules/Order/types.d.ts +3 -1
  133. package/lib/modules/Order/types.js +88 -35
  134. package/lib/modules/Order/utils/bundleDiscountHydration.js +41 -74
  135. package/lib/modules/Order/utils/discountProductLineIdentity.js +142 -100
  136. package/lib/modules/Order/utils/manualProductDiscount.js +124 -123
  137. package/lib/modules/Order/utils/orderCollectionIdentity.js +184 -244
  138. package/lib/modules/Order/utils.js +814 -647
  139. package/lib/modules/Payment/cash.js +20 -33
  140. package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
  141. package/lib/modules/Payment/eftpos.js +16 -30
  142. package/lib/modules/Payment/index.js +532 -399
  143. package/lib/modules/Payment/mx51.js +1 -0
  144. package/lib/modules/Payment/types.js +230 -108
  145. package/lib/modules/Payment/utils.js +52 -51
  146. package/lib/modules/Payment/walletpass.js +485 -660
  147. package/lib/modules/Product/index.js +51 -46
  148. package/lib/modules/Product/types.js +4 -16
  149. package/lib/modules/Product/utils.js +32 -33
  150. package/lib/modules/ProductList/index.js +113 -123
  151. package/lib/modules/ProductList/types.js +9 -31
  152. package/lib/modules/Quotation/index.js +81 -118
  153. package/lib/modules/Quotation/types.js +4 -16
  154. package/lib/modules/Resource/index.js +27 -59
  155. package/lib/modules/Resource/types.js +22 -32
  156. package/lib/modules/Resource/utils.js +30 -38
  157. package/lib/modules/ResourcePlanner/index.js +25 -23
  158. package/lib/modules/ResourcePlanner/localClock.js +54 -119
  159. package/lib/modules/ResourcePlanner/planner.js +589 -770
  160. package/lib/modules/ResourcePlanner/types.js +10 -29
  161. package/lib/modules/Rules/index.js +1218 -959
  162. package/lib/modules/Rules/types.js +17 -40
  163. package/lib/modules/SalesSummary/index.js +85 -90
  164. package/lib/modules/SalesSummary/types.js +4 -16
  165. package/lib/modules/SalesSummary/utils.js +355 -430
  166. package/lib/modules/ScanOrderLogger/index.js +59 -79
  167. package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
  168. package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
  169. package/lib/modules/ScanOrderLogger/types.js +4 -16
  170. package/lib/modules/Schedule/getDateIsInSchedule.js +334 -163
  171. package/lib/modules/Schedule/index.js +100 -114
  172. package/lib/modules/Schedule/type.js +4 -16
  173. package/lib/modules/Schedule/types.js +4 -16
  174. package/lib/modules/Schedule/utils.js +433 -291
  175. package/lib/modules/Step/index.js +40 -52
  176. package/lib/modules/Step/tyeps.js +4 -16
  177. package/lib/modules/Summary/index.js +66 -71
  178. package/lib/modules/Summary/types.js +4 -16
  179. package/lib/modules/Summary/utils.js +773 -418
  180. package/lib/modules/SurchargeList/index.js +46 -60
  181. package/lib/modules/SurchargeList/types.js +4 -16
  182. package/lib/modules/index.js +245 -63
  183. package/lib/plugins/app.js +4 -16
  184. package/lib/plugins/index.js +36 -25
  185. package/lib/plugins/request.js +137 -126
  186. package/lib/plugins/shopStore.js +4 -16
  187. package/lib/plugins/user.js +4 -16
  188. package/lib/plugins/window.js +171 -179
  189. package/lib/server/index.js +3050 -2665
  190. package/lib/server/modules/floor-plan/index.js +118 -134
  191. package/lib/server/modules/floor-plan/types.js +15 -30
  192. package/lib/server/modules/index.js +106 -68
  193. package/lib/server/modules/menu/index.js +142 -122
  194. package/lib/server/modules/menu/types.js +18 -31
  195. package/lib/server/modules/order/index.js +784 -1002
  196. package/lib/server/modules/order/types.js +122 -33
  197. package/lib/server/modules/order/utils/filterBookings.js +219 -194
  198. package/lib/server/modules/order/utils/filterOrders.js +118 -92
  199. package/lib/server/modules/payment/index.js +59 -83
  200. package/lib/server/modules/payment/types.js +4 -16
  201. package/lib/server/modules/products/index.js +583 -471
  202. package/lib/server/modules/products/types.js +44 -34
  203. package/lib/server/modules/quotation/index.js +137 -172
  204. package/lib/server/modules/quotation/types.js +21 -31
  205. package/lib/server/modules/resource/index.js +220 -186
  206. package/lib/server/modules/resource/types.js +42 -33
  207. package/lib/server/modules/schedule/index.js +135 -123
  208. package/lib/server/modules/schedule/types.js +14 -21
  209. package/lib/server/modules/schedule/utils.js +334 -163
  210. package/lib/server/types.js +4 -16
  211. package/lib/server/utils/index.js +25 -23
  212. package/lib/server/utils/product.js +196 -139
  213. package/lib/server/utils/schedule.js +34 -41
  214. package/lib/server/utils/small-ticket.js +479 -456
  215. package/lib/server/utils/time.js +40 -49
  216. package/lib/solution/BaseSales/index.js +1220 -1412
  217. package/lib/solution/BaseSales/types.js +42 -38
  218. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
  219. package/lib/solution/BaseSales/utils/cartPromotion.js +652 -498
  220. package/lib/solution/BaseSales/utils/parseSalesResponse.js +85 -105
  221. package/lib/solution/BaseSales/utils/quotationPrice.js +56 -114
  222. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +108 -145
  223. package/lib/solution/BaseSales/utils.js +158 -143
  224. package/lib/solution/BookingByStep/index.js +1527 -1340
  225. package/lib/solution/BookingByStep/types.js +40 -99
  226. package/lib/solution/BookingByStep/utils/capacity.js +192 -160
  227. package/lib/solution/BookingByStep/utils/products.js +42 -52
  228. package/lib/solution/BookingByStep/utils/resources.js +527 -330
  229. package/lib/solution/BookingByStep/utils/stock.js +65 -44
  230. package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
  231. package/lib/solution/BookingTicket/index.js +607 -522
  232. package/lib/solution/BookingTicket/types.js +99 -77
  233. package/lib/solution/BookingTicket/utils/addProductDecision.js +226 -189
  234. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +58 -89
  235. package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -78
  236. package/lib/solution/BookingTicket/utils/cartView.js +114 -99
  237. package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
  238. package/lib/solution/BookingTicket/utils/orderCustomer.js +18 -41
  239. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +219 -86
  240. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +168 -116
  241. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +79 -91
  242. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +54 -41
  243. package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -81
  244. package/lib/solution/BookingTicket/utils/scan/index.js +98 -104
  245. package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
  246. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +52 -64
  247. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +56 -58
  248. package/lib/solution/BookingTicket/utils/weighingProductSku.js +34 -48
  249. package/lib/solution/BuyTickets/index.js +67 -70
  250. package/lib/solution/BuyTickets/types.js +22 -38
  251. package/lib/solution/Checkout/index.js +1451 -1158
  252. package/lib/solution/Checkout/types.js +91 -61
  253. package/lib/solution/Checkout/utils/index.js +228 -156
  254. package/lib/solution/PlaceOrder/index.js +55 -0
  255. package/lib/solution/RegisterAndLogin/config.js +493 -460
  256. package/lib/solution/RegisterAndLogin/index.js +633 -630
  257. package/lib/solution/RegisterAndLogin/types.js +189 -76
  258. package/lib/solution/RegisterAndLogin/utils.js +183 -125
  259. package/lib/solution/Sales/index.js +328 -324
  260. package/lib/solution/Sales/types.js +27 -33
  261. package/lib/solution/ScanOrder/index.js +832 -864
  262. package/lib/solution/ScanOrder/types.js +33 -34
  263. package/lib/solution/ScanOrder/utils.js +409 -374
  264. package/lib/solution/ShopDiscount/index.js +226 -232
  265. package/lib/solution/ShopDiscount/types.js +15 -37
  266. package/lib/solution/ShopDiscount/utils.js +300 -172
  267. package/lib/solution/UnifiedBookingSales/index.js +1035 -1201
  268. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +99 -159
  269. package/lib/solution/UnifiedBookingSales/types.js +10 -32
  270. package/lib/solution/VenueBooking/index.js +811 -879
  271. package/lib/solution/VenueBooking/types.js +19 -39
  272. package/lib/solution/VenueBooking/utils/dateSummary.js +27 -56
  273. package/lib/solution/VenueBooking/utils/resource.js +31 -54
  274. package/lib/solution/VenueBooking/utils/slotMerge.js +94 -107
  275. package/lib/solution/VenueBooking/utils/timeSlot.js +132 -132
  276. package/lib/solution/VenueBooking/utils.js +130 -67
  277. package/lib/solution/index.js +124 -41
  278. package/lib/store/createStore.js +32 -29
  279. package/lib/types/index.js +4 -16
  280. package/lib/utils/payment-number.js +26 -46
  281. package/lib/utils/task.js +36 -36
  282. package/lib/utils/watch.js +81 -47
  283. package/package.json +2 -1
@@ -1,105 +1,123 @@
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/solution/BookingTicket/utils/cartView.ts
20
- var cartView_exports = {};
21
- __export(cartView_exports, {
22
- buildCartView: () => buildCartView,
23
- buildCustomerView: () => buildCustomerView,
24
- indexBookingsByProductUid: () => indexBookingsByProductUid,
25
- isWalkInCustomer: () => isWalkInCustomer
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
26
5
  });
27
- module.exports = __toCommonJS(cartView_exports);
28
- var import_addTimeAvailability = require("./addTimeAvailability");
6
+ exports.buildCartView = buildCartView;
7
+ exports.buildCustomerView = buildCustomerView;
8
+ exports.indexBookingsByProductUid = indexBookingsByProductUid;
9
+ exports.isWalkInCustomer = isWalkInCustomer;
10
+ var _addTimeAvailability = require("./addTimeAvailability");
11
+ /**
12
+ * 仅按 booking.product_uid 建索引,避免发明 booking 与商品行之间的其它等价关系。
13
+ */
29
14
  function indexBookingsByProductUid(bookings) {
30
- if (!Array.isArray(bookings) || bookings.length === 0)
31
- return {};
15
+ if (!Array.isArray(bookings) || bookings.length === 0) return {};
32
16
  return bookings.reduce((acc, booking) => {
33
- const uid = booking == null ? void 0 : booking.product_uid;
34
- if (uid === void 0 || uid === null || uid === "")
35
- return acc;
17
+ const uid = booking?.product_uid;
18
+ if (uid === undefined || uid === null || uid === '') return acc;
36
19
  const key = String(uid);
37
- if (!acc[key])
38
- acc[key] = [];
20
+ if (!acc[key]) acc[key] = [];
39
21
  acc[key].push(booking);
40
22
  return acc;
41
23
  }, {});
42
24
  }
25
+
26
+ /**
27
+ * 商品行按 unique_identification_number 建 1:1 索引(同 uid 多行时保留首行)。
28
+ */
43
29
  function indexProductsByUid(lines) {
44
30
  return lines.reduce((acc, line) => {
45
- var _a;
46
- const uid = (_a = line.metadata) == null ? void 0 : _a.unique_identification_number;
47
- if (uid === void 0 || uid === null || uid === "")
48
- return acc;
31
+ const uid = line.metadata?.unique_identification_number;
32
+ if (uid === undefined || uid === null || uid === '') return acc;
49
33
  const key = String(uid);
50
- if (!acc[key])
51
- acc[key] = line;
34
+ if (!acc[key]) acc[key] = line;
52
35
  return acc;
53
36
  }, {});
54
37
  }
38
+
39
+ /**
40
+ * 读取 booking 的协议唯一值。
41
+ *
42
+ * @example
43
+ * const uid = getBookingUid(booking);
44
+ */
55
45
  function getBookingUid(booking) {
56
- var _a;
57
- const uid = (_a = booking == null ? void 0 : booking.metadata) == null ? void 0 : _a.unique_identification_number;
58
- return uid === void 0 || uid === null ? "" : String(uid);
46
+ const uid = booking?.metadata?.unique_identification_number;
47
+ return uid === undefined || uid === null ? '' : String(uid);
59
48
  }
49
+
50
+ /**
51
+ * 读取商品行绑定的 booking 唯一值。
52
+ *
53
+ * @example
54
+ * const bookingUid = getProductBookingUid(product);
55
+ */
60
56
  function getProductBookingUid(line) {
61
- var _a;
62
- const uid = (line == null ? void 0 : line.booking_uid) ?? ((_a = line == null ? void 0 : line.metadata) == null ? void 0 : _a.booking_uid);
63
- return uid === void 0 || uid === null ? "" : String(uid);
57
+ const uid = line?.booking_uid ?? line?.metadata?.booking_uid;
58
+ return uid === undefined || uid === null ? '' : String(uid);
64
59
  }
60
+
61
+ /**
62
+ * 判断商品行是否为加时商品行。
63
+ *
64
+ * @example
65
+ * isAddTimeProductLine({ metadata: { product_add_schedule_time: 30 } } as any);
66
+ */
65
67
  function isAddTimeProductLine(line) {
66
- var _a, _b;
67
- return ((_a = line == null ? void 0 : line.metadata) == null ? void 0 : _a.product_add_schedule_time) !== void 0 && ((_b = line == null ? void 0 : line.metadata) == null ? void 0 : _b.product_add_schedule_time) !== null;
68
+ return line?.metadata?.product_add_schedule_time !== undefined && line?.metadata?.product_add_schedule_time !== null;
68
69
  }
70
+
71
+ /**
72
+ * 将加时商品按 booking_uid 建索引。
73
+ *
74
+ * @example
75
+ * const map = indexAddTimeProductsByBookingUid(products);
76
+ */
69
77
  function indexAddTimeProductsByBookingUid(lines) {
70
78
  return lines.reduce((acc, line) => {
71
- if (!isAddTimeProductLine(line))
72
- return acc;
79
+ if (!isAddTimeProductLine(line)) return acc;
73
80
  const bookingUid = getProductBookingUid(line);
74
- if (!bookingUid)
75
- return acc;
76
- if (!acc[bookingUid])
77
- acc[bookingUid] = [];
81
+ if (!bookingUid) return acc;
82
+ if (!acc[bookingUid]) acc[bookingUid] = [];
78
83
  acc[bookingUid].push(line);
79
84
  return acc;
80
85
  }, {});
81
86
  }
87
+
88
+ /**
89
+ * 判断商品行是否是促销赠品行。
90
+ *
91
+ * @example
92
+ * isGiftProductLine({ metadata: { _giftInfo: {} } } as any); // true
93
+ */
82
94
  function isGiftProductLine(line) {
83
- var _a;
84
- return Boolean((_a = line == null ? void 0 : line.metadata) == null ? void 0 : _a._giftInfo);
95
+ return Boolean(line?.metadata?._giftInfo);
85
96
  }
97
+
98
+ /**
99
+ * 构建购物车 UI 视图:bookings 平铺附带关联商品;items 仅含未关联 booking 的商品行。
100
+ *
101
+ * 商品行直接透传 tempOrder.products,不做 enrichment。
102
+ * 关联规则(1:1):booking.product_uid ↔ line.metadata.unique_identification_number;
103
+ * 同一 uid 已被更早的 booking 占用时,后续 booking 的 product 为 null。
104
+ */
86
105
  function buildCartView(lines, bookings, options = {}) {
87
106
  const productLines = Array.isArray(lines) ? lines : [];
88
107
  const bookingList = Array.isArray(bookings) ? bookings : [];
89
- const childBookings = bookingList.filter((booking) => booking.parent_id !== 0);
108
+ const childBookings = bookingList.filter(booking => booking.parent_id !== 0);
90
109
  const bookingsByProductUid = indexBookingsByProductUid(childBookings);
91
110
  const linesByUid = indexProductsByUid(productLines);
92
111
  const addTimeLinesByBookingUid = indexAddTimeProductsByBookingUid(productLines);
93
- const claimedAddTimeLines = /* @__PURE__ */ new Set();
94
- childBookings.forEach((booking) => {
112
+ const claimedAddTimeLines = new Set();
113
+ childBookings.forEach(booking => {
95
114
  const bookingUid = getBookingUid(booking);
96
- if (!bookingUid)
97
- return;
98
- (addTimeLinesByBookingUid[bookingUid] || []).forEach((line) => {
115
+ if (!bookingUid) return;
116
+ (addTimeLinesByBookingUid[bookingUid] || []).forEach(line => {
99
117
  claimedAddTimeLines.add(line);
100
118
  });
101
119
  });
102
- const claimedBookings = /* @__PURE__ */ new Set();
120
+ const claimedBookings = new Set();
103
121
  const cartBookings = [];
104
122
  const items = [];
105
123
  const orderedLines = [];
@@ -111,7 +129,7 @@ function buildCartView(lines, bookings, options = {}) {
111
129
  _extend: {
112
130
  product,
113
131
  addTimeProduct,
114
- canAddTime: (0, import_addTimeAvailability.resolveBookingCanAddTime)({
132
+ canAddTime: (0, _addTimeAvailability.resolveBookingCanAddTime)({
115
133
  booking,
116
134
  product,
117
135
  addTimeProducts: options.addTimeProducts,
@@ -122,14 +140,11 @@ function buildCartView(lines, bookings, options = {}) {
122
140
  }
123
141
  };
124
142
  };
125
- productLines.forEach((line) => {
126
- var _a;
127
- if (isGiftProductLine(line) || claimedAddTimeLines.has(line))
128
- return;
129
- const uid = (_a = line.metadata) == null ? void 0 : _a.unique_identification_number;
130
- const matchedBooking = uid === void 0 || uid === null || uid === "" ? void 0 : (bookingsByProductUid[String(uid)] || []).find(
131
- (booking) => !claimedBookings.has(booking)
132
- );
143
+ productLines.forEach(line => {
144
+ // 赠品由主商品 Gift 行展示;加时商品挂在 booking._extend.addTimeProduct。
145
+ if (isGiftProductLine(line) || claimedAddTimeLines.has(line)) return;
146
+ const uid = line.metadata?.unique_identification_number;
147
+ const matchedBooking = uid === undefined || uid === null || uid === '' ? undefined : (bookingsByProductUid[String(uid)] || []).find(booking => !claimedBookings.has(booking));
133
148
  if (matchedBooking) {
134
149
  claimedBookings.add(matchedBooking);
135
150
  const bookingView = buildBookingView(matchedBooking, line);
@@ -140,33 +155,38 @@ function buildCartView(lines, bookings, options = {}) {
140
155
  items.push(line);
141
156
  orderedLines.push(line);
142
157
  });
143
- childBookings.forEach((booking) => {
144
- if (claimedBookings.has(booking))
145
- return;
146
- const uid = booking == null ? void 0 : booking.product_uid;
147
- const linkedProduct = uid === void 0 || uid === null || uid === "" ? null : linesByUid[String(uid)] || null;
148
- if (isGiftProductLine(linkedProduct))
149
- return;
158
+ childBookings.forEach(booking => {
159
+ if (claimedBookings.has(booking)) return;
160
+ const uid = booking?.product_uid;
161
+ const linkedProduct = uid === undefined || uid === null || uid === '' ? null : linesByUid[String(uid)] || null;
162
+ // 赠品预约只作为提交数据保留,不在购物车预约卡片区展示。
163
+ if (isGiftProductLine(linkedProduct)) return;
150
164
  cartBookings.push(buildBookingView(booking, null));
151
165
  });
152
- return { bookings: cartBookings, items, lines: orderedLines };
166
+ return {
167
+ bookings: cartBookings,
168
+ items,
169
+ lines: orderedLines
170
+ };
153
171
  }
154
172
  function isWalkInCustomer(customer) {
155
- if (!customer)
156
- return true;
173
+ if (!customer) return true;
157
174
  const id = customer.id;
158
- if (id === void 0 || id === null)
159
- return true;
160
- if (typeof id === "string") {
161
- return ["", "0", "1"].includes(id);
175
+ if (id === undefined || id === null) return true;
176
+ if (typeof id === 'string') {
177
+ return ['', '0', '1'].includes(id);
162
178
  }
163
179
  return [0, 1].includes(id);
164
180
  }
181
+
182
+ /**
183
+ * selected 优先,缺失时回退 tempOrder.customer_*,统一输出 UI 客户视图。
184
+ */
165
185
  function buildCustomerView(selected, tempOrder) {
166
- if (selected && selected.id !== void 0 && selected.id !== null && selected.id !== "" && selected.id !== 0) {
186
+ if (selected && selected.id !== undefined && selected.id !== null && selected.id !== '' && selected.id !== 0) {
167
187
  return {
168
188
  id: selected.id,
169
- name: selected.name ?? "",
189
+ name: selected.name ?? '',
170
190
  phone: selected.phone,
171
191
  email: selected.email,
172
192
  country_calling_code: selected.country_calling_code,
@@ -175,23 +195,18 @@ function buildCustomerView(selected, tempOrder) {
175
195
  };
176
196
  }
177
197
  if (tempOrder && (tempOrder.customer_id != null || tempOrder.customer_name)) {
178
- const id = tempOrder.customer_id ?? "";
198
+ const id = tempOrder.customer_id ?? '';
179
199
  return {
180
200
  id,
181
- name: tempOrder.customer_name ?? "",
201
+ name: tempOrder.customer_name ?? '',
182
202
  phone: tempOrder.phone,
183
203
  email: tempOrder.email,
184
204
  country_calling_code: tempOrder.country_calling_code,
185
- cover: void 0,
186
- isWalkIn: isWalkInCustomer({ id })
205
+ cover: undefined,
206
+ isWalkIn: isWalkInCustomer({
207
+ id
208
+ })
187
209
  };
188
210
  }
189
211
  return null;
190
- }
191
- // Annotate the CommonJS export names for ESM import in node:
192
- 0 && (module.exports = {
193
- buildCartView,
194
- buildCustomerView,
195
- indexBookingsByProductUid,
196
- isWalkInCustomer
197
- });
212
+ }
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+
3
+ let data = [{
4
+ "id": 58299,
5
+ "title": "玄-加时商品-与数量无关-不指定商品",
6
+ "price": 1,
7
+ "minMinutes": 30,
8
+ "maxMinutes": 30,
9
+ "unitMinutes": 30,
10
+ "unlimited": false,
11
+ "_originalProduct": {
12
+ "id": 58299,
13
+ "extension_id": 384,
14
+ "extension_type": "product_add_time",
15
+ "shop_id": 9,
16
+ "title": "玄-加时商品-与数量无关-不指定商品",
17
+ "slug": "玄-加时商品-与数量无关-指定商品",
18
+ "status": "published",
19
+ "stock_quantity": -119,
20
+ "sales_quantity": 113,
21
+ "sum_stock": -119,
22
+ "price": "1.00",
23
+ "original_price": "4.00",
24
+ "cost_price": "0.00",
25
+ "cover": "",
26
+ "channel_application": ["online-store", "pos", "bbc-module:mebook"],
27
+ "is_track": 0,
28
+ "over_sold": 0,
29
+ "is_gst": 1,
30
+ "code": "",
31
+ "barcode": "",
32
+ "is_delivery": 0,
33
+ "weight_unit": "KILOGRAMS",
34
+ "weight_value": "0.00",
35
+ "type": "physical",
36
+ "unit": "",
37
+ "sort": 9999999,
38
+ "subtitle": "",
39
+ "minimum_markup_price": "0.00",
40
+ "is_bundle": 0,
41
+ "description": "",
42
+ "open_sold_weight": 0,
43
+ "unit_value": 0,
44
+ "is_variant": 0,
45
+ "variant_count": 0,
46
+ "add_time": {
47
+ "unit_duration": 30,
48
+ "min_add_time": 30,
49
+ "max_add_time": 30,
50
+ "calculate_type": "not_related_to_quantity",
51
+ "relation_product": {
52
+ "type": "product_all",
53
+ "products": []
54
+ }
55
+ },
56
+ "shelf_product_datas": [],
57
+ "step_value": 1,
58
+ "min_num_unit": 1,
59
+ "is_charge_tax": 1,
60
+ "base_price": "1.00",
61
+ "variant": []
62
+ }
63
+ }, {
64
+ "id": 58279,
65
+ "title": "加时商品2",
66
+ "price": 10,
67
+ "minMinutes": 30,
68
+ "maxMinutes": 120,
69
+ "unitMinutes": 10,
70
+ "unlimited": false,
71
+ "_originalProduct": {
72
+ "id": 58279,
73
+ "extension_id": 384,
74
+ "extension_type": "product_add_time",
75
+ "shop_id": 9,
76
+ "title": "加时商品2",
77
+ "slug": "加时商品2",
78
+ "status": "published",
79
+ "stock_quantity": -275,
80
+ "sales_quantity": 261,
81
+ "sum_stock": -275,
82
+ "price": "10.00",
83
+ "original_price": "10.00",
84
+ "cost_price": "0.00",
85
+ "cover": "",
86
+ "channel_application": ["online-store", "pos", "bbc-module:mebook"],
87
+ "is_track": 0,
88
+ "over_sold": 0,
89
+ "is_gst": 1,
90
+ "code": "",
91
+ "barcode": "",
92
+ "is_delivery": 0,
93
+ "weight_unit": "KILOGRAMS",
94
+ "weight_value": "0.00",
95
+ "type": "physical",
96
+ "unit": "",
97
+ "sort": 9999999,
98
+ "subtitle": "",
99
+ "minimum_markup_price": "0.00",
100
+ "is_bundle": 0,
101
+ "description": "",
102
+ "open_sold_weight": 0,
103
+ "unit_value": 0,
104
+ "is_variant": 0,
105
+ "variant_count": 0,
106
+ "add_time": {
107
+ "additional_time_options": "explicit_durations",
108
+ "unit_duration": 10,
109
+ "min_add_time": 30,
110
+ "max_add_time": 120,
111
+ "calculate_type": "not_related_to_quantity",
112
+ "relation_product": {
113
+ "type": "product_all",
114
+ "products": []
115
+ }
116
+ },
117
+ "shelf_product_datas": [],
118
+ "step_value": 1,
119
+ "min_num_unit": 1,
120
+ "is_charge_tax": 1,
121
+ "base_price": "10.00",
122
+ "variant": []
123
+ }
124
+ }, {
125
+ "id": 58277,
126
+ "title": "测试加时商品",
127
+ "price": 2,
128
+ "minMinutes": 30,
129
+ "maxMinutes": 780,
130
+ "unitMinutes": 30,
131
+ "unlimited": true,
132
+ "_originalProduct": {
133
+ "id": 58277,
134
+ "extension_id": 384,
135
+ "extension_type": "product_add_time",
136
+ "shop_id": 9,
137
+ "title": "测试加时商品",
138
+ "slug": "测试加时商品",
139
+ "status": "published",
140
+ "stock_quantity": -7,
141
+ "sales_quantity": 8,
142
+ "sum_stock": -7,
143
+ "price": "2.00",
144
+ "original_price": "0.00",
145
+ "cost_price": "0.00",
146
+ "cover": "",
147
+ "channel_application": ["online-store", "pos", "bbc-module:mebook"],
148
+ "is_track": 0,
149
+ "over_sold": 0,
150
+ "is_gst": 1,
151
+ "code": "",
152
+ "barcode": "",
153
+ "is_delivery": 0,
154
+ "weight_unit": "KILOGRAMS",
155
+ "weight_value": "0.00",
156
+ "type": "physical",
157
+ "unit": "",
158
+ "sort": 9999999,
159
+ "subtitle": "",
160
+ "minimum_markup_price": "0.00",
161
+ "is_bundle": 0,
162
+ "description": "",
163
+ "open_sold_weight": 0,
164
+ "unit_value": 0,
165
+ "is_variant": 0,
166
+ "variant_count": 0,
167
+ "add_time": {
168
+ "additional_time_options": "unlimited",
169
+ "unit_duration": 30,
170
+ "min_add_time": 30,
171
+ "max_add_time": 780,
172
+ "calculate_type": "select_quantity",
173
+ "relation_product": {
174
+ "type": "product_all",
175
+ "products": []
176
+ }
177
+ },
178
+ "shelf_product_datas": [],
179
+ "step_value": 1,
180
+ "min_num_unit": 1,
181
+ "is_charge_tax": 1,
182
+ "base_price": "2.00",
183
+ "variant": []
184
+ }
185
+ }];
@@ -1,58 +1,35 @@
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/solution/BookingTicket/utils/orderCustomer.ts
20
- var orderCustomer_exports = {};
21
- __export(orderCustomer_exports, {
22
- formatOrderCustomerPatch: () => formatOrderCustomerPatch
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
23
5
  });
24
- module.exports = __toCommonJS(orderCustomer_exports);
6
+ exports.formatOrderCustomerPatch = formatOrderCustomerPatch;
7
+ /** 从 ICustomer 富字段解析展示名(与 SalesSdk getClientName 语义对齐)。 */
25
8
  function resolveCustomerDisplayName(customer) {
26
9
  const c = customer;
27
10
  const displayName = c.display_name;
28
- if (typeof displayName === "string" && displayName)
29
- return displayName;
11
+ if (typeof displayName === 'string' && displayName) return displayName;
30
12
  const nickname = c.nickname;
31
- if (typeof nickname === "string" && nickname)
32
- return nickname;
13
+ if (typeof nickname === 'string' && nickname) return nickname;
33
14
  const firstName = c.first_name;
34
15
  const lastName = c.last_name;
35
- if (typeof firstName === "string" && firstName || typeof lastName === "string" && lastName) {
36
- return `${typeof firstName === "string" ? firstName : ""} ${typeof lastName === "string" ? lastName : ""}`.trim();
16
+ if (typeof firstName === 'string' && firstName || typeof lastName === 'string' && lastName) {
17
+ return `${typeof firstName === 'string' ? firstName : ''} ${typeof lastName === 'string' ? lastName : ''}`.trim();
37
18
  }
38
19
  const customerName = c.customer_name;
39
- if (typeof customerName === "string" && customerName)
40
- return customerName;
41
- return customer.name ?? "";
20
+ if (typeof customerName === 'string' && customerName) return customerName;
21
+ return customer.name ?? '';
42
22
  }
23
+
24
+ /** 将 ICustomer 格式化为写入 tempOrder 的协议字段。 */
43
25
  function formatOrderCustomerPatch(customer) {
44
- var _a;
45
26
  const rawId = customer.id;
46
- const numericId = typeof rawId === "number" ? rawId : rawId !== void 0 && rawId !== null && rawId !== "" ? Number(rawId) : null;
27
+ const numericId = typeof rawId === 'number' ? rawId : rawId !== undefined && rawId !== null && rawId !== '' ? Number(rawId) : null;
47
28
  return {
48
29
  customer_id: Number.isFinite(numericId) ? numericId : null,
49
30
  customer_name: resolveCustomerDisplayName(customer),
50
- phone: customer.phone ?? "",
51
- email: customer.email ?? "",
52
- country_calling_code: ((_a = customer.country_calling_code) == null ? void 0 : _a.toString()) ?? ""
31
+ phone: customer.phone ?? '',
32
+ email: customer.email ?? '',
33
+ country_calling_code: customer.country_calling_code?.toString() ?? ''
53
34
  };
54
- }
55
- // Annotate the CommonJS export names for ESM import in node:
56
- 0 && (module.exports = {
57
- formatOrderCustomerPatch
58
- });
35
+ }