@pisell/pisellos 2.1.41 → 2.2.2

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 (121) hide show
  1. package/dist/core/index.d.ts +8 -1
  2. package/dist/core/index.js +116 -42
  3. package/dist/modules/Customer/index.js +1 -1
  4. package/dist/modules/Order/index.js +4 -4
  5. package/dist/modules/Order/types.d.ts +0 -1
  6. package/dist/modules/Product/types.d.ts +19 -0
  7. package/dist/modules/ProductList/index.js +3 -11
  8. package/dist/modules/Schedule/types.d.ts +2 -0
  9. package/dist/plugins/request.d.ts +19 -1
  10. package/dist/plugins/request.js +11 -0
  11. package/dist/server/index.d.ts +152 -0
  12. package/dist/server/index.js +946 -0
  13. package/dist/server/modules/index.d.ts +16 -0
  14. package/dist/server/modules/index.js +21 -0
  15. package/dist/server/modules/menu/index.d.ts +63 -0
  16. package/dist/server/modules/menu/index.js +476 -0
  17. package/dist/server/modules/menu/types.d.ts +68 -0
  18. package/dist/server/modules/menu/types.js +16 -0
  19. package/dist/server/modules/products/index.d.ts +141 -0
  20. package/dist/server/modules/products/index.js +774 -0
  21. package/dist/server/modules/products/types.d.ts +94 -0
  22. package/dist/server/modules/products/types.js +43 -0
  23. package/dist/server/modules/quotation/index.d.ts +47 -0
  24. package/dist/server/modules/quotation/index.js +367 -0
  25. package/dist/server/modules/quotation/types.d.ts +50 -0
  26. package/dist/server/modules/quotation/types.js +20 -0
  27. package/dist/server/modules/schedule/index.d.ts +62 -0
  28. package/dist/server/modules/schedule/index.js +431 -0
  29. package/dist/server/modules/schedule/types.d.ts +1 -0
  30. package/dist/server/modules/schedule/types.js +2 -0
  31. package/dist/server/modules/schedule/utils.d.ts +32 -0
  32. package/dist/server/modules/schedule/utils.js +747 -0
  33. package/dist/server/types.d.ts +64 -0
  34. package/dist/server/types.js +1 -0
  35. package/dist/server/utils/index.d.ts +5 -0
  36. package/dist/server/utils/index.js +6 -0
  37. package/dist/server/utils/product.d.ts +18 -0
  38. package/dist/server/utils/product.js +339 -0
  39. package/dist/server/utils/schedule.d.ts +14 -0
  40. package/dist/server/utils/schedule.js +108 -0
  41. package/dist/server/utils/time.d.ts +18 -0
  42. package/dist/server/utils/time.js +53 -0
  43. package/dist/solution/BookingByStep/index.d.ts +2 -22
  44. package/dist/solution/BookingByStep/index.js +29 -502
  45. package/dist/solution/BookingByStep/utils/capacity.d.ts +2 -7
  46. package/dist/solution/BookingByStep/utils/capacity.js +8 -24
  47. package/dist/solution/BookingTicket/index.d.ts +8 -0
  48. package/dist/solution/BookingTicket/index.js +105 -71
  49. package/dist/solution/ShopDiscount/index.js +9 -27
  50. package/dist/solution/index.d.ts +0 -1
  51. package/dist/solution/index.js +0 -1
  52. package/dist/types/index.d.ts +26 -0
  53. package/lib/core/index.d.ts +8 -1
  54. package/lib/core/index.js +48 -1
  55. package/lib/modules/Customer/index.js +1 -1
  56. package/lib/modules/Order/index.js +2 -5
  57. package/lib/modules/Order/types.d.ts +0 -1
  58. package/lib/modules/Product/types.d.ts +19 -0
  59. package/lib/modules/ProductList/index.js +2 -10
  60. package/lib/modules/Schedule/types.d.ts +2 -0
  61. package/lib/plugins/request.d.ts +19 -1
  62. package/lib/plugins/request.js +11 -1
  63. package/lib/server/index.d.ts +152 -0
  64. package/lib/server/index.js +555 -0
  65. package/lib/server/modules/index.d.ts +16 -0
  66. package/lib/server/modules/index.js +47 -0
  67. package/lib/server/modules/menu/index.d.ts +63 -0
  68. package/lib/server/modules/menu/index.js +234 -0
  69. package/lib/server/modules/menu/types.d.ts +68 -0
  70. package/lib/server/modules/menu/types.js +33 -0
  71. package/lib/server/modules/products/index.d.ts +141 -0
  72. package/lib/server/modules/products/index.js +442 -0
  73. package/lib/server/modules/products/types.d.ts +94 -0
  74. package/lib/server/modules/products/types.js +35 -0
  75. package/lib/server/modules/quotation/index.d.ts +47 -0
  76. package/lib/server/modules/quotation/index.js +177 -0
  77. package/lib/server/modules/quotation/types.d.ts +50 -0
  78. package/lib/server/modules/quotation/types.js +33 -0
  79. package/lib/server/modules/schedule/index.d.ts +62 -0
  80. package/lib/server/modules/schedule/index.js +231 -0
  81. package/lib/server/modules/schedule/types.d.ts +1 -0
  82. package/lib/server/modules/schedule/types.js +23 -0
  83. package/lib/server/modules/schedule/utils.d.ts +32 -0
  84. package/lib/server/modules/schedule/utils.js +451 -0
  85. package/lib/server/types.d.ts +64 -0
  86. package/lib/server/types.js +17 -0
  87. package/lib/server/utils/index.d.ts +5 -0
  88. package/lib/server/utils/index.js +25 -0
  89. package/lib/server/utils/product.d.ts +18 -0
  90. package/lib/server/utils/product.js +262 -0
  91. package/lib/server/utils/schedule.d.ts +14 -0
  92. package/lib/server/utils/schedule.js +88 -0
  93. package/lib/server/utils/time.d.ts +18 -0
  94. package/lib/server/utils/time.js +70 -0
  95. package/lib/solution/BookingByStep/index.d.ts +2 -22
  96. package/lib/solution/BookingByStep/index.js +42 -321
  97. package/lib/solution/BookingByStep/utils/capacity.d.ts +2 -7
  98. package/lib/solution/BookingByStep/utils/capacity.js +8 -21
  99. package/lib/solution/BookingTicket/index.d.ts +8 -0
  100. package/lib/solution/BookingTicket/index.js +13 -0
  101. package/lib/solution/ShopDiscount/index.js +0 -9
  102. package/lib/solution/index.d.ts +0 -1
  103. package/lib/solution/index.js +0 -2
  104. package/lib/types/index.d.ts +26 -0
  105. package/package.json +2 -2
  106. package/dist/solution/RegisterAndLogin/config.d.ts +0 -87
  107. package/dist/solution/RegisterAndLogin/config.js +0 -792
  108. package/dist/solution/RegisterAndLogin/index.d.ts +0 -189
  109. package/dist/solution/RegisterAndLogin/index.js +0 -2667
  110. package/dist/solution/RegisterAndLogin/types.d.ts +0 -444
  111. package/dist/solution/RegisterAndLogin/types.js +0 -231
  112. package/dist/solution/RegisterAndLogin/utils.d.ts +0 -95
  113. package/dist/solution/RegisterAndLogin/utils.js +0 -322
  114. package/lib/solution/RegisterAndLogin/config.d.ts +0 -87
  115. package/lib/solution/RegisterAndLogin/config.js +0 -594
  116. package/lib/solution/RegisterAndLogin/index.d.ts +0 -189
  117. package/lib/solution/RegisterAndLogin/index.js +0 -1593
  118. package/lib/solution/RegisterAndLogin/types.d.ts +0 -444
  119. package/lib/solution/RegisterAndLogin/types.js +0 -78
  120. package/lib/solution/RegisterAndLogin/utils.d.ts +0 -95
  121. package/lib/solution/RegisterAndLogin/utils.js +0 -279
@@ -30,7 +30,6 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
30
30
  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); }
31
31
  import { BaseModule } from "../../modules/BaseModule";
32
32
  import { createModule } from "./types";
33
- import { formatProductToCartItem, createCartItemOrigin, getUniqueId, handleVariantProduct, formatDateToCartItem, formatAccountToCartItem } from "../../modules/Cart/utils";
34
33
  import { getAvailableProductResources } from "./utils/products";
35
34
  import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection, isConflict } from "./utils/resources";
36
35
  import dayjs from 'dayjs';
@@ -966,7 +965,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
966
965
  }, {
967
966
  key: "submitOrder",
968
967
  value: function () {
969
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(extraData) {
968
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
970
969
  var cartItems, newCartItems, type;
971
970
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
972
971
  while (1) switch (_context19.prev = _context19.next) {
@@ -1003,8 +1002,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1003
1002
  query: {
1004
1003
  cartItems: newCartItems,
1005
1004
  type: type,
1006
- platform: this.platform,
1007
- extraData: extraData
1005
+ platform: this.platform
1008
1006
  }
1009
1007
  }));
1010
1008
  case 6:
@@ -1013,7 +1011,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1013
1011
  }
1014
1012
  }, _callee19, this);
1015
1013
  }));
1016
- function submitOrder(_x17) {
1014
+ function submitOrder() {
1017
1015
  return _submitOrder.apply(this, arguments);
1018
1016
  }
1019
1017
  return submitOrder;
@@ -1075,7 +1073,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1075
1073
  }
1076
1074
  }, _callee22, this);
1077
1075
  }));
1078
- function setOtherParams(_x18) {
1076
+ function setOtherParams(_x17) {
1079
1077
  return _setOtherParams.apply(this, arguments);
1080
1078
  }
1081
1079
  return setOtherParams;
@@ -1196,16 +1194,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1196
1194
  this.addProductCheck({
1197
1195
  date: date
1198
1196
  });
1199
- // 如果 quantity 大于 1,且是预约商品,则进入购物车拆散成多条数据
1200
- if (addItemParams.quantity > 1 && !isNormalProduct(productData)) {
1201
- for (var i = 0; i < addItemParams.quantity; i++) {
1202
- var newAddItemParams = cloneDeep(addItemParams);
1203
- newAddItemParams.quantity = 1;
1204
- this.store.cart.addItem(newAddItemParams);
1205
- }
1206
- } else {
1207
- this.store.cart.addItem(addItemParams);
1208
- }
1197
+ this.store.cart.addItem(addItemParams);
1209
1198
  return {
1210
1199
  success: true
1211
1200
  };
@@ -2378,7 +2367,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2378
2367
  }
2379
2368
  }, _callee24, this);
2380
2369
  }));
2381
- function openProductDetail(_x19) {
2370
+ function openProductDetail(_x18) {
2382
2371
  return _openProductDetail.apply(this, arguments);
2383
2372
  }
2384
2373
  return openProductDetail;
@@ -2732,9 +2721,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2732
2721
  key: "checkMaxDurationCapacity",
2733
2722
  value: function checkMaxDurationCapacity() {
2734
2723
  var _this15 = this;
2735
- var cartItems = this.store.cart.getItems().filter(function (item) {
2736
- return !isNormalProduct(item._productOrigin);
2737
- });
2724
+ var cartItems = cloneDeep(this.store.cart.getItems());
2738
2725
  if (cartItems.length === 0) return {
2739
2726
  success: true,
2740
2727
  minAvailableCount: 0
@@ -3051,11 +3038,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3051
3038
  });
3052
3039
 
3053
3040
  // 按资源类型分组检查容量
3054
- var _checkTimeSlotCapacit = checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot),
3055
- success = _checkTimeSlotCapacit.success,
3056
- required = _checkTimeSlotCapacit.required,
3057
- available = _checkTimeSlotCapacit.available;
3058
- if (!success) {
3041
+ if (!checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot)) {
3059
3042
  // 如果有可用数量记录,返回最小值;否则返回 0
3060
3043
  var _minAvailableCount = availableCountsByResourceType.length > 0 ? Math.min.apply(Math, availableCountsByResourceType) : 0;
3061
3044
  return {
@@ -3080,439 +3063,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3080
3063
  minAvailableCount: minAvailableCount
3081
3064
  };
3082
3065
  }
3083
-
3084
- /**
3085
- * 将 ProductData 转换为 CartItem,但不添加到购物车
3086
- * 参考 addProductToCart 方法的实现
3087
- */
3088
- }, {
3089
- key: "convertProductToCartItem",
3090
- value: function convertProductToCartItem(_ref11) {
3091
- var product = _ref11.product,
3092
- date = _ref11.date,
3093
- account = _ref11.account;
3094
- var _ref12 = product || {},
3095
- bundle = _ref12.bundle,
3096
- options = _ref12.options,
3097
- origin = _ref12.origin,
3098
- product_variant_id = _ref12.product_variant_id,
3099
- _ref12$quantity = _ref12.quantity,
3100
- quantity = _ref12$quantity === void 0 ? 1 : _ref12$quantity;
3101
-
3102
- // 处理商品数据,类似 addProductToCart 中的逻辑
3103
- var productData = _objectSpread(_objectSpread({}, origin), {}, {
3104
- product_variant_id: product_variant_id
3105
- });
3106
-
3107
- // 处理组合商品
3108
- var processedProduct = handleVariantProduct(productData);
3109
-
3110
- // 如果没有传入账户,获取当前活跃账户
3111
- if (!account) {
3112
- var activeAccount = this.getActiveAccount();
3113
- if (activeAccount) {
3114
- account = activeAccount;
3115
- }
3116
- }
3117
-
3118
- // 创建基础的 CartItem
3119
- var cartItem = {
3120
- _id: getUniqueId('temp_'),
3121
- _origin: createCartItemOrigin(),
3122
- _productOrigin: processedProduct,
3123
- _productInit: product
3124
- };
3125
-
3126
- // 使用格式化函数填充 CartItem 数据
3127
- formatProductToCartItem({
3128
- cartItem: cartItem,
3129
- product: processedProduct,
3130
- bundle: bundle,
3131
- options: options,
3132
- product_variant_id: product_variant_id,
3133
- quantity: quantity
3134
- });
3135
-
3136
- // 如果有日期信息,格式化日期到购物车
3137
- if (date) {
3138
- formatDateToCartItem({
3139
- cartItem: cartItem,
3140
- date: date
3141
- });
3142
- }
3143
-
3144
- // 如果有账户信息,格式化账户到购物车
3145
- if (account) {
3146
- formatAccountToCartItem({
3147
- cartItem: cartItem,
3148
- account: account
3149
- });
3150
- }
3151
- return cartItem;
3152
- }
3153
- }, {
3154
- key: "checkMaxDurationCapacityForDetailNums",
3155
- value: function checkMaxDurationCapacityForDetailNums(_ref13) {
3156
- var _this16 = this;
3157
- var product = _ref13.product,
3158
- date = _ref13.date,
3159
- account = _ref13.account;
3160
- var cartItems = this.store.cart.getItems().filter(function (item) {
3161
- return !isNormalProduct(item._productOrigin);
3162
- });
3163
-
3164
- // 将 ProductData 转换为 CartItem 但不真正添加到购物车
3165
- var currentCartItem = this.convertProductToCartItem({
3166
- product: product,
3167
- date: date,
3168
- account: account
3169
- });
3170
- cartItems.push(currentCartItem);
3171
- if (cartItems.length === 0) return {
3172
- success: true,
3173
- minAvailableCount: 0
3174
- };
3175
-
3176
- // 将购物车商品分为有时间的和没有时间的
3177
- var itemsWithTime = [];
3178
- var itemsWithoutTime = [];
3179
- // 记录每种资源类型的可用数量
3180
- var availableCountsByResourceType = [];
3181
- cartItems.forEach(function (cartItem) {
3182
- if (cartItem.start_time && cartItem.end_time && cartItem.start_date) {
3183
- itemsWithTime.push(cartItem);
3184
- } else {
3185
- itemsWithoutTime.push(cartItem);
3186
- }
3187
- });
3188
-
3189
- // 处理没有时间的商品,为它们分配公共可用时间的第一个时间片
3190
- var processedItemsWithoutTime = [];
3191
- if (itemsWithoutTime.length > 0) {
3192
- // 按资源类型分组处理没有时间的商品
3193
- var itemsByResourceType = {};
3194
- itemsWithoutTime.forEach(function (cartItem) {
3195
- var _cartItem$_productOri13;
3196
- if (!cartItem._productOrigin) return;
3197
- var resourceTypes = ((_cartItem$_productOri13 = cartItem._productOrigin.product_resource) === null || _cartItem$_productOri13 === void 0 ? void 0 : _cartItem$_productOri13.resources) || [];
3198
- resourceTypes.forEach(function (resourceType) {
3199
- if (resourceType.status === 1) {
3200
- var _resourceType$id2;
3201
- var resourceCode = resourceType.code || ((_resourceType$id2 = resourceType.id) === null || _resourceType$id2 === void 0 ? void 0 : _resourceType$id2.toString());
3202
- if (!itemsByResourceType[resourceCode]) {
3203
- itemsByResourceType[resourceCode] = [];
3204
- }
3205
- // 避免重复添加同一个商品
3206
- if (!itemsByResourceType[resourceCode].find(function (item) {
3207
- return item._id === cartItem._id;
3208
- })) {
3209
- itemsByResourceType[resourceCode].push(cartItem);
3210
- }
3211
- }
3212
- });
3213
- });
3214
-
3215
- // 为每种资源类型检查容量
3216
- var dateRange = this.store.date.getDateRange();
3217
- if (!dateRange || dateRange.length === 0) return {
3218
- success: false,
3219
- minAvailableCount: 0
3220
- };
3221
- var resourcesDates = this.store.date.getDateList();
3222
- var targetResourceDate = resourcesDates.find(function (n) {
3223
- return n.date === dateRange[0].date;
3224
- });
3225
- if (!targetResourceDate) return {
3226
- success: false,
3227
- minAvailableCount: 0
3228
- };
3229
- var resourcesMap = getResourcesMap(targetResourceDate.resource || []);
3230
-
3231
- // 从购物车商品中获取资源类型配置,建立 resourceCode 到 form_id 的映射关系
3232
- var resourceCodeToFormIdMap = {};
3233
-
3234
- // 遍历购物车中的商品,收集所有资源类型配置
3235
- Object.values(itemsByResourceType).flat().forEach(function (cartItem) {
3236
- var _cartItem$_productOri14;
3237
- if ((_cartItem$_productOri14 = cartItem._productOrigin) !== null && _cartItem$_productOri14 !== void 0 && (_cartItem$_productOri14 = _cartItem$_productOri14.product_resource) !== null && _cartItem$_productOri14 !== void 0 && _cartItem$_productOri14.resources) {
3238
- cartItem._productOrigin.product_resource.resources.forEach(function (resourceConfig) {
3239
- // 只处理启用的资源类型 (status === 1)
3240
- if (resourceConfig.status === 1 && resourceConfig.code) {
3241
- var _resourceConfig$id2, _resourceConfig$resou2;
3242
- var formId = ((_resourceConfig$id2 = resourceConfig.id) === null || _resourceConfig$id2 === void 0 ? void 0 : _resourceConfig$id2.toString()) || ((_resourceConfig$resou2 = resourceConfig.resource_type_id) === null || _resourceConfig$resou2 === void 0 ? void 0 : _resourceConfig$resou2.toString());
3243
- if (formId) {
3244
- resourceCodeToFormIdMap[resourceConfig.code] = formId;
3245
- }
3246
- }
3247
- });
3248
- }
3249
- });
3250
- var hasCapacityIssue = false;
3251
- var resourceCapacityInfo = [];
3252
-
3253
- // 用于跟踪已处理的商品,避免重复添加
3254
- var processedCartItemIds = new Set();
3255
-
3256
- // 先检查所有资源类型,收集可用数量信息
3257
- var _loop5 = function _loop5() {
3258
- var _resourceTypeConfig2;
3259
- var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
3260
- resourceCode = _Object$entries3$_i[0],
3261
- items = _Object$entries3$_i[1];
3262
- // 获取该资源类型对应的 form_id
3263
- var targetFormId = resourceCodeToFormIdMap[resourceCode];
3264
- if (!targetFormId) {
3265
- console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u627E\u4E0D\u5230\u5BF9\u5E94\u7684 form_id"));
3266
- return {
3267
- v: {
3268
- success: false,
3269
- minAvailableCount: 0
3270
- }
3271
- };
3272
- }
3273
-
3274
- // 获取该资源类型的所有资源
3275
- var resourcesOfThisType = [];
3276
- items.forEach(function (cartItem) {
3277
- var productResourceIds = getResourcesIdsByProduct(cartItem._productOrigin);
3278
- productResourceIds.forEach(function (resourceId) {
3279
- var _resource$form_id2;
3280
- var resource = resourcesMap[resourceId];
3281
- if (resource && ((_resource$form_id2 = resource.form_id) === null || _resource$form_id2 === void 0 ? void 0 : _resource$form_id2.toString()) === targetFormId) {
3282
- // 避免重复添加同一个资源
3283
- if (!resourcesOfThisType.find(function (r) {
3284
- return r.id === resource.id;
3285
- })) {
3286
- resourcesOfThisType.push(resource);
3287
- }
3288
- }
3289
- });
3290
- });
3291
- if (resourcesOfThisType.length === 0) {
3292
- console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u6CA1\u6709\u627E\u5230\u53EF\u7528\u8D44\u6E90"));
3293
- return {
3294
- v: {
3295
- success: false,
3296
- minAvailableCount: 0
3297
- }
3298
- };
3299
- }
3300
-
3301
- // 检查资源类型(单个预约 vs 多个预约)
3302
- // 从商品配置中获取资源类型信息
3303
- var resourceTypeConfig = null;
3304
- var _iterator4 = _createForOfIteratorHelper(items),
3305
- _step4;
3306
- try {
3307
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
3308
- var _cartItem$_productOri15;
3309
- var cartItem = _step4.value;
3310
- if ((_cartItem$_productOri15 = cartItem._productOrigin) !== null && _cartItem$_productOri15 !== void 0 && (_cartItem$_productOri15 = _cartItem$_productOri15.product_resource) !== null && _cartItem$_productOri15 !== void 0 && _cartItem$_productOri15.resources) {
3311
- resourceTypeConfig = cartItem._productOrigin.product_resource.resources.find(function (r) {
3312
- return r.code === resourceCode && r.status === 1;
3313
- });
3314
- if (resourceTypeConfig) break;
3315
- }
3316
- }
3317
- } catch (err) {
3318
- _iterator4.e(err);
3319
- } finally {
3320
- _iterator4.f();
3321
- }
3322
- var isMultipleBooking = ((_resourceTypeConfig2 = resourceTypeConfig) === null || _resourceTypeConfig2 === void 0 ? void 0 : _resourceTypeConfig2.type) === 'multiple';
3323
- var totalAvailable;
3324
- var requiredAmount;
3325
- var availableAmount;
3326
- if (isMultipleBooking) {
3327
- // 多个预约:计算容量
3328
- totalAvailable = resourcesOfThisType.reduce(function (sum, resource) {
3329
- return sum + (resource.capacity || 0);
3330
- }, 0);
3331
- requiredAmount = items.reduce(function (sum, cartItem) {
3332
- var _getCapacityInfoByCar8 = getCapacityInfoByCartItem(cartItem),
3333
- currentCapacity = _getCapacityInfoByCar8.currentCapacity;
3334
- return sum + currentCapacity;
3335
- }, 0);
3336
- availableAmount = Math.max(0, totalAvailable - requiredAmount);
3337
- } else {
3338
- // 单个预约:计算资源个数
3339
- totalAvailable = resourcesOfThisType.length;
3340
- requiredAmount = items.reduce(function (sum, cartItem) {
3341
- return sum + (cartItem.num || 1);
3342
- }, 0);
3343
- availableAmount = Math.max(0, totalAvailable - requiredAmount);
3344
- }
3345
-
3346
- // 记录资源容量信息
3347
- resourceCapacityInfo.push({
3348
- code: resourceCode,
3349
- available: availableAmount,
3350
- total: totalAvailable,
3351
- required: requiredAmount,
3352
- isMultiple: isMultipleBooking
3353
- });
3354
- availableCountsByResourceType.push(availableAmount);
3355
-
3356
- // 检查是否有容量问题
3357
- if (requiredAmount > totalAvailable) {
3358
- hasCapacityIssue = true;
3359
- console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " ").concat(isMultipleBooking ? '容量' : '资源数量', "\u4E0D\u8DB3: \u9700\u8981 ").concat(requiredAmount, ", \u603B\u5171 ").concat(totalAvailable));
3360
- }
3361
-
3362
- // 为通过检测的商品分配一个公共可用时间段
3363
- console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u7684\u8D44\u6E90\u65F6\u95F4\u4FE1\u606F:"), resourcesOfThisType.map(function (r) {
3364
- return {
3365
- id: r.id,
3366
- times: r.times.map(function (t) {
3367
- return "".concat(t.start_at, " - ").concat(t.end_at);
3368
- })
3369
- };
3370
- }));
3371
-
3372
- // 找到所有资源都可用的时间段
3373
- var commonTimeSlots = _this16.findCommonAvailableTimeSlots(resourcesOfThisType);
3374
- console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u7684\u516C\u5171\u65F6\u95F4\u6BB5:"), commonTimeSlots);
3375
- if (commonTimeSlots.length === 0) {
3376
- console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5"));
3377
- return {
3378
- v: {
3379
- success: false,
3380
- minAvailableCount: 0
3381
- }
3382
- };
3383
- }
3384
-
3385
- // 使用第一个公共可用时间段,但只处理未处理过的商品
3386
- var firstCommonSlot = commonTimeSlots[0];
3387
- console.log("\u4F7F\u7528\u516C\u5171\u65F6\u95F4\u6BB5: ".concat(firstCommonSlot.startTime, " - ").concat(firstCommonSlot.endTime));
3388
- items.forEach(function (cartItem) {
3389
- // 只处理未处理过的商品,避免重复添加
3390
- if (!processedCartItemIds.has(cartItem._id)) {
3391
- processedCartItemIds.add(cartItem._id);
3392
- var processedItem = _objectSpread(_objectSpread({}, cartItem), {}, {
3393
- start_date: dateRange[0].date,
3394
- start_time: firstCommonSlot.startTime,
3395
- end_time: firstCommonSlot.endTime,
3396
- end_date: dateRange[0].date
3397
- });
3398
- processedItemsWithoutTime.push(processedItem);
3399
- }
3400
- });
3401
- },
3402
- _ret4;
3403
- for (var _i3 = 0, _Object$entries3 = Object.entries(itemsByResourceType); _i3 < _Object$entries3.length; _i3++) {
3404
- _ret4 = _loop5();
3405
- if (_ret4) return _ret4.v;
3406
- }
3407
-
3408
- // 如果有容量问题,找出限制最严格的资源类型,返回其总容量
3409
- if (hasCapacityIssue) {
3410
- // 找出超出容量的资源类型中,总容量最少的那个
3411
- var overCapacityResources = resourceCapacityInfo.filter(function (info) {
3412
- return info.required > info.total;
3413
- });
3414
- if (overCapacityResources.length > 0) {
3415
- var _minTotalCapacity2 = Math.min.apply(Math, _toConsumableArray(overCapacityResources.map(function (info) {
3416
- return info.total;
3417
- })));
3418
- return {
3419
- success: false,
3420
- minAvailableCount: _minTotalCapacity2
3421
- };
3422
- }
3423
- // 如果没有超出容量的(理论上不应该发生),返回总容量最少的
3424
- var minTotalCapacity = Math.min.apply(Math, _toConsumableArray(resourceCapacityInfo.map(function (info) {
3425
- return info.total;
3426
- })));
3427
- return {
3428
- success: false,
3429
- minAvailableCount: minTotalCapacity
3430
- };
3431
- }
3432
- }
3433
-
3434
- // 合并所有商品(有时间的 + 处理后的没有时间的)
3435
- var allProcessedItems = [].concat(itemsWithTime, processedItemsWithoutTime);
3436
-
3437
- // 按时间段分组检查
3438
- var cartItemsByTimeSlot = {};
3439
- allProcessedItems.forEach(function (cartItem) {
3440
- if (!cartItem.start_time || !cartItem.end_time || !cartItem.start_date) return;
3441
- var timeSlotKey = "".concat(cartItem.start_date, "_").concat(cartItem.start_time, "_").concat(cartItem.end_date || cartItem.start_date, "_").concat(cartItem.end_time);
3442
- if (!cartItemsByTimeSlot[timeSlotKey]) {
3443
- cartItemsByTimeSlot[timeSlotKey] = [];
3444
- }
3445
- cartItemsByTimeSlot[timeSlotKey].push(cartItem);
3446
- });
3447
- // 检查每个时间段是否有足够的资源容量
3448
- var _loop6 = function _loop6() {
3449
- var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2),
3450
- timeSlotKey = _Object$entries4$_i[0],
3451
- itemsInTimeSlot = _Object$entries4$_i[1];
3452
- var _timeSlotKey$split3 = timeSlotKey.split('_'),
3453
- _timeSlotKey$split4 = _slicedToArray(_timeSlotKey$split3, 4),
3454
- startDate = _timeSlotKey$split4[0],
3455
- startTime = _timeSlotKey$split4[1],
3456
- endDate = _timeSlotKey$split4[2],
3457
- endTime = _timeSlotKey$split4[3];
3458
- var timeSlotStart = "".concat(startDate, " ").concat(startTime);
3459
- var timeSlotEnd = "".concat(endDate, " ").concat(endTime);
3460
-
3461
- // 获取这个时间段所有商品涉及的资源
3462
- var allResourcesForTimeSlot = [];
3463
- var resourcesIdSet = new Set();
3464
-
3465
- // 获取资源数据
3466
- // const dateRange = this.store.date.getDateRange();
3467
- var resourcesDates = _this16.store.date.getDateList();
3468
- var targetResourceDate = resourcesDates.find(function (n) {
3469
- return n.date === startDate;
3470
- });
3471
- if (!targetResourceDate) return 0; // continue
3472
- var resourcesMap = getResourcesMap(targetResourceDate.resource || []);
3473
- itemsInTimeSlot.forEach(function (cartItem) {
3474
- if (!cartItem._productOrigin) return;
3475
-
3476
- // 获取商品的资源配置
3477
- var productResourceIds = getResourcesIdsByProduct(cartItem._productOrigin);
3478
- productResourceIds.forEach(function (resourceId) {
3479
- if (resourcesMap[resourceId] && !resourcesIdSet.has(resourceId)) {
3480
- resourcesIdSet.add(resourceId);
3481
- allResourcesForTimeSlot.push(resourcesMap[resourceId]);
3482
- }
3483
- });
3484
- });
3485
-
3486
- // 按资源类型分组检查容量
3487
- var _checkTimeSlotCapacit2 = checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot),
3488
- success = _checkTimeSlotCapacit2.success,
3489
- required = _checkTimeSlotCapacit2.required,
3490
- available = _checkTimeSlotCapacit2.available;
3491
- if (!success) {
3492
- // 如果有可用数量记录,返回最小值;否则返回 0
3493
- // const minAvailableCount = availableCountsByResourceType.length > 0 ? Math.min(...availableCountsByResourceType) : 0;
3494
- return {
3495
- v: {
3496
- success: false,
3497
- minAvailableCount: available
3498
- }
3499
- };
3500
- }
3501
- },
3502
- _ret5;
3503
- for (var _i4 = 0, _Object$entries4 = Object.entries(cartItemsByTimeSlot); _i4 < _Object$entries4.length; _i4++) {
3504
- _ret5 = _loop6();
3505
- if (_ret5 === 0) continue;
3506
- if (_ret5) return _ret5.v;
3507
- }
3508
-
3509
- // 全部通过检测,返回成功和最小可用数量
3510
- var minAvailableCount = availableCountsByResourceType.length > 0 ? Math.min.apply(Math, availableCountsByResourceType) : 0;
3511
- return {
3512
- success: true,
3513
- minAvailableCount: minAvailableCount
3514
- };
3515
- }
3516
3066
  }, {
3517
3067
  key: "setOtherData",
3518
3068
  value: function setOtherData(key, value) {
@@ -3568,7 +3118,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3568
3118
  }
3569
3119
  }, _callee25, this);
3570
3120
  }));
3571
- function getProductTypeById(_x20) {
3121
+ function getProductTypeById(_x19) {
3572
3122
  return _getProductTypeById.apply(this, arguments);
3573
3123
  }
3574
3124
  return getProductTypeById;
@@ -3584,7 +3134,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3584
3134
  }, {
3585
3135
  key: "getResourcesByCartItemAndCode",
3586
3136
  value: function getResourcesByCartItemAndCode(cartItemId, resourceCode) {
3587
- var _cartItem$_productOri16;
3137
+ var _cartItem$_productOri13;
3588
3138
  var dateRange = this.store.date.getDateRange();
3589
3139
  var resources = [];
3590
3140
  if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
@@ -3607,16 +3157,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3607
3157
  });
3608
3158
  if (!cartItem) return [];
3609
3159
  var selectedResources = [];
3610
- var _getCapacityInfoByCar9 = getCapacityInfoByCartItem(cartItem),
3611
- currentCapacity = _getCapacityInfoByCar9.currentCapacity,
3612
- formatCapacity = _getCapacityInfoByCar9.formatCapacity;
3160
+ var _getCapacityInfoByCar8 = getCapacityInfoByCartItem(cartItem),
3161
+ currentCapacity = _getCapacityInfoByCar8.currentCapacity,
3162
+ formatCapacity = _getCapacityInfoByCar8.formatCapacity;
3613
3163
  cartItem._origin.metadata.capacity = formatCapacity;
3614
3164
  if (cartItem.holder_id) {
3615
3165
  selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
3616
3166
  } else {
3617
3167
  selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
3618
3168
  }
3619
- var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri16 = cartItem._productOrigin) === null || _cartItem$_productOri16 === void 0 || (_cartItem$_productOri16 = _cartItem$_productOri16.product_resource) === null || _cartItem$_productOri16 === void 0 ? void 0 : _cartItem$_productOri16.resources) || [], selectedResources, currentCapacity);
3169
+ var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri13 = cartItem._productOrigin) === null || _cartItem$_productOri13 === void 0 || (_cartItem$_productOri13 = _cartItem$_productOri13.product_resource) === null || _cartItem$_productOri13 === void 0 ? void 0 : _cartItem$_productOri13.resources) || [], selectedResources, currentCapacity);
3620
3170
  var targetResource = productResources.find(function (resource) {
3621
3171
  return resource.code === resourceCode;
3622
3172
  });
@@ -3639,7 +3189,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3639
3189
  });
3640
3190
  if (mTimes.length === 0) return false;
3641
3191
  var canUseArr = mTimes.map(function (item) {
3642
- var _cartItem$_productOri17;
3192
+ var _cartItem$_productOri14;
3643
3193
  var res = getIsUsableByTimeItem({
3644
3194
  timeSlice: {
3645
3195
  start_time: startTime.format('HH:mm'),
@@ -3651,7 +3201,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3651
3201
  resource: m,
3652
3202
  currentCount: currentCapacity || 0,
3653
3203
  resourcesUseableMap: resourcesUseableMap,
3654
- cut_off_time: (_cartItem$_productOri17 = cartItem._productOrigin) === null || _cartItem$_productOri17 === void 0 ? void 0 : _cartItem$_productOri17.cut_off_time
3204
+ cut_off_time: (_cartItem$_productOri14 = cartItem._productOrigin) === null || _cartItem$_productOri14 === void 0 ? void 0 : _cartItem$_productOri14.cut_off_time
3655
3205
  });
3656
3206
  if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
3657
3207
  resourcesUseableMap[m.id] = res.usable;
@@ -3665,12 +3215,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3665
3215
  });
3666
3216
  } else {
3667
3217
  targetResource.renderList = targetResource.renderList.filter(function (n) {
3668
- var _cartItem$_productOri18;
3218
+ var _cartItem$_productOri15;
3669
3219
  var recordCount = n.capacity || 0;
3670
3220
  if (n.onlyComputed) return false;
3671
3221
  var timeSlots = getTimeSlicesByResource({
3672
3222
  resource: n,
3673
- duration: ((_cartItem$_productOri18 = cartItem._productOrigin) === null || _cartItem$_productOri18 === void 0 || (_cartItem$_productOri18 = _cartItem$_productOri18.duration) === null || _cartItem$_productOri18 === void 0 ? void 0 : _cartItem$_productOri18.value) || 10,
3223
+ duration: ((_cartItem$_productOri15 = cartItem._productOrigin) === null || _cartItem$_productOri15 === void 0 || (_cartItem$_productOri15 = _cartItem$_productOri15.duration) === null || _cartItem$_productOri15 === void 0 ? void 0 : _cartItem$_productOri15.value) || 10,
3674
3224
  split: 10,
3675
3225
  currentDate: dateRange[0].date
3676
3226
  });
@@ -3688,12 +3238,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3688
3238
  }, {
3689
3239
  key: "getTimeslotsScheduleByDateRange",
3690
3240
  value: (function () {
3691
- var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(_ref14) {
3692
- var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i5, _dates, date;
3241
+ var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(_ref11) {
3242
+ var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i3, _dates, date;
3693
3243
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3694
3244
  while (1) switch (_context26.prev = _context26.next) {
3695
3245
  case 0:
3696
- startDate = _ref14.startDate, endDate = _ref14.endDate, scheduleIds = _ref14.scheduleIds, resources = _ref14.resources;
3246
+ startDate = _ref11.startDate, endDate = _ref11.endDate, scheduleIds = _ref11.scheduleIds, resources = _ref11.resources;
3697
3247
  console.log('appoimentBooking-session-date-getTimeslotsScheduleByDateRange', {
3698
3248
  startDate: startDate,
3699
3249
  endDate: endDate,
@@ -3710,8 +3260,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3710
3260
  }
3711
3261
  // 如果不支持 Web Worker,使用同步方式处理
3712
3262
  results = {};
3713
- for (_i5 = 0, _dates = dates; _i5 < _dates.length; _i5++) {
3714
- date = _dates[_i5];
3263
+ for (_i3 = 0, _dates = dates; _i3 < _dates.length; _i3++) {
3264
+ date = _dates[_i3];
3715
3265
  results[date] = this.getTimeslotBySchedule({
3716
3266
  date: date,
3717
3267
  scheduleIds: scheduleIds,
@@ -3725,7 +3275,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3725
3275
  }
3726
3276
  }, _callee26, this);
3727
3277
  }));
3728
- function getTimeslotsScheduleByDateRange(_x21) {
3278
+ function getTimeslotsScheduleByDateRange(_x20) {
3729
3279
  return _getTimeslotsScheduleByDateRange.apply(this, arguments);
3730
3280
  }
3731
3281
  return getTimeslotsScheduleByDateRange;
@@ -3752,7 +3302,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3752
3302
  openResources,
3753
3303
  allProductResources,
3754
3304
  targetSchedules,
3755
- _loop7,
3305
+ _loop5,
3756
3306
  _args28 = arguments;
3757
3307
  return _regeneratorRuntime().wrap(function _callee27$(_context28) {
3758
3308
  while (1) switch (_context28.prev = _context28.next) {
@@ -3829,9 +3379,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3829
3379
  }
3830
3380
  });
3831
3381
  targetSchedules = this.store.schedule.getScheduleListByIds(tempProducts['schedule.ids']);
3832
- _loop7 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop7() {
3382
+ _loop5 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop5() {
3833
3383
  var currentDateStr, status, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse;
3834
- return _regeneratorRuntime().wrap(function _loop7$(_context27) {
3384
+ return _regeneratorRuntime().wrap(function _loop5$(_context27) {
3835
3385
  while (1) switch (_context27.prev = _context27.next) {
3836
3386
  case 0:
3837
3387
  currentDateStr = currentDate.format('YYYY-MM-DD');
@@ -3934,14 +3484,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3934
3484
  case "end":
3935
3485
  return _context27.stop();
3936
3486
  }
3937
- }, _loop7);
3487
+ }, _loop5);
3938
3488
  });
3939
3489
  case 28:
3940
3490
  if (!(dayjs(currentDate).isBefore(dayjs(endDate), 'day') || dayjs(currentDate).isSame(dayjs(endDate), 'day'))) {
3941
3491
  _context28.next = 34;
3942
3492
  break;
3943
3493
  }
3944
- return _context28.delegateYield(_loop7(), "t0", 30);
3494
+ return _context28.delegateYield(_loop5(), "t0", 30);
3945
3495
  case 30:
3946
3496
  if (!_context28.t0) {
3947
3497
  _context28.next = 32;
@@ -4012,29 +3562,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
4012
3562
  });
4013
3563
  return cartItem && isNormalProduct(cartItem._productOrigin);
4014
3564
  }
4015
-
4016
- /**
4017
- * 获取联系信息
4018
- */
4019
- }, {
4020
- key: "getContactInfo",
4021
- value: (function () {
4022
- var _getContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4023
- return _regeneratorRuntime().wrap(function _callee28$(_context29) {
4024
- while (1) switch (_context29.prev = _context29.next) {
4025
- case 0:
4026
- return _context29.abrupt("return", this.request.get('/customer/metadata', params));
4027
- case 1:
4028
- case "end":
4029
- return _context29.stop();
4030
- }
4031
- }, _callee28, this);
4032
- }));
4033
- function getContactInfo(_x22) {
4034
- return _getContactInfo.apply(this, arguments);
4035
- }
4036
- return getContactInfo;
4037
- }())
4038
3565
  }]);
4039
3566
  return BookingByStepImpl;
4040
3567
  }(BaseModule);