@pisell/pisellos 2.2.6 → 2.2.7

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 (44) hide show
  1. package/dist/modules/Order/index.js +4 -4
  2. package/dist/modules/Order/types.d.ts +1 -0
  3. package/dist/modules/Product/index.d.ts +1 -1
  4. package/dist/modules/ProductList/index.js +11 -3
  5. package/dist/plugins/request.d.ts +1 -0
  6. package/dist/plugins/request.js +1 -1
  7. package/dist/solution/BookingByStep/index.d.ts +22 -2
  8. package/dist/solution/BookingByStep/index.js +502 -29
  9. package/dist/solution/BookingByStep/utils/capacity.d.ts +7 -2
  10. package/dist/solution/BookingByStep/utils/capacity.js +24 -8
  11. package/dist/solution/BookingTicket/index.d.ts +1 -1
  12. package/dist/solution/RegisterAndLogin/config.d.ts +87 -0
  13. package/dist/solution/RegisterAndLogin/config.js +1140 -0
  14. package/dist/solution/RegisterAndLogin/index.d.ts +189 -0
  15. package/dist/solution/RegisterAndLogin/index.js +2667 -0
  16. package/dist/solution/RegisterAndLogin/types.d.ts +445 -0
  17. package/dist/solution/RegisterAndLogin/types.js +231 -0
  18. package/dist/solution/RegisterAndLogin/utils.d.ts +95 -0
  19. package/dist/solution/RegisterAndLogin/utils.js +322 -0
  20. package/dist/solution/ShopDiscount/index.js +27 -9
  21. package/dist/solution/index.d.ts +1 -0
  22. package/dist/solution/index.js +1 -0
  23. package/lib/modules/Order/index.js +5 -2
  24. package/lib/modules/Order/types.d.ts +1 -0
  25. package/lib/modules/Product/index.d.ts +1 -1
  26. package/lib/modules/ProductList/index.js +10 -2
  27. package/lib/plugins/request.d.ts +1 -0
  28. package/lib/solution/BookingByStep/index.d.ts +22 -2
  29. package/lib/solution/BookingByStep/index.js +321 -42
  30. package/lib/solution/BookingByStep/utils/capacity.d.ts +7 -2
  31. package/lib/solution/BookingByStep/utils/capacity.js +21 -8
  32. package/lib/solution/BookingTicket/index.d.ts +1 -1
  33. package/lib/solution/RegisterAndLogin/config.d.ts +87 -0
  34. package/lib/solution/RegisterAndLogin/config.js +866 -0
  35. package/lib/solution/RegisterAndLogin/index.d.ts +189 -0
  36. package/lib/solution/RegisterAndLogin/index.js +1593 -0
  37. package/lib/solution/RegisterAndLogin/types.d.ts +445 -0
  38. package/lib/solution/RegisterAndLogin/types.js +78 -0
  39. package/lib/solution/RegisterAndLogin/utils.d.ts +95 -0
  40. package/lib/solution/RegisterAndLogin/utils.js +279 -0
  41. package/lib/solution/ShopDiscount/index.js +9 -0
  42. package/lib/solution/index.d.ts +1 -0
  43. package/lib/solution/index.js +2 -0
  44. package/package.json +1 -1
@@ -30,6 +30,7 @@ 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";
33
34
  import { getAvailableProductResources } from "./utils/products";
34
35
  import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection, isConflict } from "./utils/resources";
35
36
  import dayjs from 'dayjs';
@@ -965,7 +966,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
965
966
  }, {
966
967
  key: "submitOrder",
967
968
  value: function () {
968
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
969
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(extraData) {
969
970
  var cartItems, newCartItems, type;
970
971
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
971
972
  while (1) switch (_context19.prev = _context19.next) {
@@ -1002,7 +1003,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1002
1003
  query: {
1003
1004
  cartItems: newCartItems,
1004
1005
  type: type,
1005
- platform: this.platform
1006
+ platform: this.platform,
1007
+ extraData: extraData
1006
1008
  }
1007
1009
  }));
1008
1010
  case 6:
@@ -1011,7 +1013,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1011
1013
  }
1012
1014
  }, _callee19, this);
1013
1015
  }));
1014
- function submitOrder() {
1016
+ function submitOrder(_x17) {
1015
1017
  return _submitOrder.apply(this, arguments);
1016
1018
  }
1017
1019
  return submitOrder;
@@ -1073,7 +1075,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1073
1075
  }
1074
1076
  }, _callee22, this);
1075
1077
  }));
1076
- function setOtherParams(_x17) {
1078
+ function setOtherParams(_x18) {
1077
1079
  return _setOtherParams.apply(this, arguments);
1078
1080
  }
1079
1081
  return setOtherParams;
@@ -1194,7 +1196,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1194
1196
  this.addProductCheck({
1195
1197
  date: date
1196
1198
  });
1197
- this.store.cart.addItem(addItemParams);
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
+ }
1198
1209
  return {
1199
1210
  success: true
1200
1211
  };
@@ -2367,7 +2378,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2367
2378
  }
2368
2379
  }, _callee24, this);
2369
2380
  }));
2370
- function openProductDetail(_x18) {
2381
+ function openProductDetail(_x19) {
2371
2382
  return _openProductDetail.apply(this, arguments);
2372
2383
  }
2373
2384
  return openProductDetail;
@@ -2721,7 +2732,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2721
2732
  key: "checkMaxDurationCapacity",
2722
2733
  value: function checkMaxDurationCapacity() {
2723
2734
  var _this15 = this;
2724
- var cartItems = cloneDeep(this.store.cart.getItems());
2735
+ var cartItems = this.store.cart.getItems().filter(function (item) {
2736
+ return !isNormalProduct(item._productOrigin);
2737
+ });
2725
2738
  if (cartItems.length === 0) return {
2726
2739
  success: true,
2727
2740
  minAvailableCount: 0
@@ -3038,7 +3051,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3038
3051
  });
3039
3052
 
3040
3053
  // 按资源类型分组检查容量
3041
- if (!checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot)) {
3054
+ var _checkTimeSlotCapacit = checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, itemsInTimeSlot, allResourcesForTimeSlot),
3055
+ success = _checkTimeSlotCapacit.success,
3056
+ required = _checkTimeSlotCapacit.required,
3057
+ available = _checkTimeSlotCapacit.available;
3058
+ if (!success) {
3042
3059
  // 如果有可用数量记录,返回最小值;否则返回 0
3043
3060
  var _minAvailableCount = availableCountsByResourceType.length > 0 ? Math.min.apply(Math, availableCountsByResourceType) : 0;
3044
3061
  return {
@@ -3063,6 +3080,439 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3063
3080
  minAvailableCount: minAvailableCount
3064
3081
  };
3065
3082
  }
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
+ }
3066
3516
  }, {
3067
3517
  key: "setOtherData",
3068
3518
  value: function setOtherData(key, value) {
@@ -3118,7 +3568,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3118
3568
  }
3119
3569
  }, _callee25, this);
3120
3570
  }));
3121
- function getProductTypeById(_x19) {
3571
+ function getProductTypeById(_x20) {
3122
3572
  return _getProductTypeById.apply(this, arguments);
3123
3573
  }
3124
3574
  return getProductTypeById;
@@ -3134,7 +3584,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3134
3584
  }, {
3135
3585
  key: "getResourcesByCartItemAndCode",
3136
3586
  value: function getResourcesByCartItemAndCode(cartItemId, resourceCode) {
3137
- var _cartItem$_productOri13;
3587
+ var _cartItem$_productOri16;
3138
3588
  var dateRange = this.store.date.getDateRange();
3139
3589
  var resources = [];
3140
3590
  if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
@@ -3157,16 +3607,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3157
3607
  });
3158
3608
  if (!cartItem) return [];
3159
3609
  var selectedResources = [];
3160
- var _getCapacityInfoByCar8 = getCapacityInfoByCartItem(cartItem),
3161
- currentCapacity = _getCapacityInfoByCar8.currentCapacity,
3162
- formatCapacity = _getCapacityInfoByCar8.formatCapacity;
3610
+ var _getCapacityInfoByCar9 = getCapacityInfoByCartItem(cartItem),
3611
+ currentCapacity = _getCapacityInfoByCar9.currentCapacity,
3612
+ formatCapacity = _getCapacityInfoByCar9.formatCapacity;
3163
3613
  cartItem._origin.metadata.capacity = formatCapacity;
3164
3614
  if (cartItem.holder_id) {
3165
3615
  selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
3166
3616
  } else {
3167
3617
  selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
3168
3618
  }
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);
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);
3170
3620
  var targetResource = productResources.find(function (resource) {
3171
3621
  return resource.code === resourceCode;
3172
3622
  });
@@ -3189,7 +3639,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3189
3639
  });
3190
3640
  if (mTimes.length === 0) return false;
3191
3641
  var canUseArr = mTimes.map(function (item) {
3192
- var _cartItem$_productOri14;
3642
+ var _cartItem$_productOri17;
3193
3643
  var res = getIsUsableByTimeItem({
3194
3644
  timeSlice: {
3195
3645
  start_time: startTime.format('HH:mm'),
@@ -3201,7 +3651,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3201
3651
  resource: m,
3202
3652
  currentCount: currentCapacity || 0,
3203
3653
  resourcesUseableMap: resourcesUseableMap,
3204
- cut_off_time: (_cartItem$_productOri14 = cartItem._productOrigin) === null || _cartItem$_productOri14 === void 0 ? void 0 : _cartItem$_productOri14.cut_off_time
3654
+ cut_off_time: (_cartItem$_productOri17 = cartItem._productOrigin) === null || _cartItem$_productOri17 === void 0 ? void 0 : _cartItem$_productOri17.cut_off_time
3205
3655
  });
3206
3656
  if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
3207
3657
  resourcesUseableMap[m.id] = res.usable;
@@ -3215,12 +3665,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3215
3665
  });
3216
3666
  } else {
3217
3667
  targetResource.renderList = targetResource.renderList.filter(function (n) {
3218
- var _cartItem$_productOri15;
3668
+ var _cartItem$_productOri18;
3219
3669
  var recordCount = n.capacity || 0;
3220
3670
  if (n.onlyComputed) return false;
3221
3671
  var timeSlots = getTimeSlicesByResource({
3222
3672
  resource: n,
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,
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,
3224
3674
  split: 10,
3225
3675
  currentDate: dateRange[0].date
3226
3676
  });
@@ -3238,12 +3688,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3238
3688
  }, {
3239
3689
  key: "getTimeslotsScheduleByDateRange",
3240
3690
  value: (function () {
3241
- var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(_ref11) {
3242
- var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i3, _dates, date;
3691
+ var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(_ref14) {
3692
+ var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i5, _dates, date;
3243
3693
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3244
3694
  while (1) switch (_context26.prev = _context26.next) {
3245
3695
  case 0:
3246
- startDate = _ref11.startDate, endDate = _ref11.endDate, scheduleIds = _ref11.scheduleIds, resources = _ref11.resources;
3696
+ startDate = _ref14.startDate, endDate = _ref14.endDate, scheduleIds = _ref14.scheduleIds, resources = _ref14.resources;
3247
3697
  console.log('appoimentBooking-session-date-getTimeslotsScheduleByDateRange', {
3248
3698
  startDate: startDate,
3249
3699
  endDate: endDate,
@@ -3260,8 +3710,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3260
3710
  }
3261
3711
  // 如果不支持 Web Worker,使用同步方式处理
3262
3712
  results = {};
3263
- for (_i3 = 0, _dates = dates; _i3 < _dates.length; _i3++) {
3264
- date = _dates[_i3];
3713
+ for (_i5 = 0, _dates = dates; _i5 < _dates.length; _i5++) {
3714
+ date = _dates[_i5];
3265
3715
  results[date] = this.getTimeslotBySchedule({
3266
3716
  date: date,
3267
3717
  scheduleIds: scheduleIds,
@@ -3275,7 +3725,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3275
3725
  }
3276
3726
  }, _callee26, this);
3277
3727
  }));
3278
- function getTimeslotsScheduleByDateRange(_x20) {
3728
+ function getTimeslotsScheduleByDateRange(_x21) {
3279
3729
  return _getTimeslotsScheduleByDateRange.apply(this, arguments);
3280
3730
  }
3281
3731
  return getTimeslotsScheduleByDateRange;
@@ -3302,7 +3752,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3302
3752
  openResources,
3303
3753
  allProductResources,
3304
3754
  targetSchedules,
3305
- _loop5,
3755
+ _loop7,
3306
3756
  _args28 = arguments;
3307
3757
  return _regeneratorRuntime().wrap(function _callee27$(_context28) {
3308
3758
  while (1) switch (_context28.prev = _context28.next) {
@@ -3379,9 +3829,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3379
3829
  }
3380
3830
  });
3381
3831
  targetSchedules = this.store.schedule.getScheduleListByIds(tempProducts['schedule.ids']);
3382
- _loop5 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop5() {
3832
+ _loop7 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop7() {
3383
3833
  var currentDateStr, status, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse;
3384
- return _regeneratorRuntime().wrap(function _loop5$(_context27) {
3834
+ return _regeneratorRuntime().wrap(function _loop7$(_context27) {
3385
3835
  while (1) switch (_context27.prev = _context27.next) {
3386
3836
  case 0:
3387
3837
  currentDateStr = currentDate.format('YYYY-MM-DD');
@@ -3484,14 +3934,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3484
3934
  case "end":
3485
3935
  return _context27.stop();
3486
3936
  }
3487
- }, _loop5);
3937
+ }, _loop7);
3488
3938
  });
3489
3939
  case 28:
3490
3940
  if (!(dayjs(currentDate).isBefore(dayjs(endDate), 'day') || dayjs(currentDate).isSame(dayjs(endDate), 'day'))) {
3491
3941
  _context28.next = 34;
3492
3942
  break;
3493
3943
  }
3494
- return _context28.delegateYield(_loop5(), "t0", 30);
3944
+ return _context28.delegateYield(_loop7(), "t0", 30);
3495
3945
  case 30:
3496
3946
  if (!_context28.t0) {
3497
3947
  _context28.next = 32;
@@ -3562,6 +4012,29 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3562
4012
  });
3563
4013
  return cartItem && isNormalProduct(cartItem._productOrigin);
3564
4014
  }
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
+ }())
3565
4038
  }]);
3566
4039
  return BookingByStepImpl;
3567
4040
  }(BaseModule);