@pisell/pisellos 2.0.6 → 2.0.8

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.
@@ -1,6 +1,6 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { Rules, RulesModuleAPI, DiscountResult } from "./types";
3
+ import { Rules, RulesModuleAPI, DiscountResult } from './types';
4
4
  import { Discount } from "../Discount/types";
5
5
  export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
6
6
  protected defaultName: string;
@@ -1182,17 +1182,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1182
1182
  if (cartItem._origin.start_time) {
1183
1183
  var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
1184
1184
  var endTime = dayjs("".concat(cartItem._origin.end_date, " ").concat(cartItem._origin.end_time));
1185
- // 资源排下序,把单个资源靠前,组合资源排在后面
1186
- productResources.sort(function (a, b) {
1187
- var _a$metadata, _b$metadata;
1188
- var aIsCombined = ((_a$metadata = a.metadata) === null || _a$metadata === void 0 || (_a$metadata = _a$metadata.combined_resource) === null || _a$metadata === void 0 ? void 0 : _a$metadata.status) === 1;
1189
- var bIsCombined = ((_b$metadata = b.metadata) === null || _b$metadata === void 0 || (_b$metadata = _b$metadata.combined_resource) === null || _b$metadata === void 0 ? void 0 : _b$metadata.status) === 1;
1190
- if (aIsCombined && !bIsCombined) return 1;
1191
- if (!aIsCombined && bIsCombined) return -1;
1192
- return 0;
1193
- });
1194
1185
  var resourcesUseableMap = {};
1195
1186
  productResources.forEach(function (n) {
1187
+ // 资源排下序,把单个资源靠前,组合资源排在后面
1188
+ n.renderList = n.renderList.sort(function (a, b) {
1189
+ var _a$metadata, _b$metadata;
1190
+ var aIsCombined = ((_a$metadata = a.metadata) === null || _a$metadata === void 0 || (_a$metadata = _a$metadata.combined_resource) === null || _a$metadata === void 0 ? void 0 : _a$metadata.status) === 1;
1191
+ var bIsCombined = ((_b$metadata = b.metadata) === null || _b$metadata === void 0 || (_b$metadata = _b$metadata.combined_resource) === null || _b$metadata === void 0 ? void 0 : _b$metadata.status) === 1;
1192
+ if (aIsCombined && !bIsCombined) return 1;
1193
+ if (!aIsCombined && bIsCombined) return -1;
1194
+ return 0;
1195
+ });
1196
1196
  n.renderList = n.renderList.filter(function (m) {
1197
1197
  var recordCount = capacityMap[m.id] || 0;
1198
1198
  var canUseTime = m.times.find(function (item) {
@@ -1505,12 +1505,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1505
1505
  var allCartItems = cloneDeep(_this8.store.cart.getItems());
1506
1506
  // 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
1507
1507
  var selectedResources = [];
1508
+ var _resources = cloneDeep(((_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.product_resource) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.resources) || []);
1509
+ var currentResourcesRenderList = [];
1510
+ _resources.forEach(function (n) {
1511
+ var _n$renderList;
1512
+ if ((_n$renderList = n.renderList) !== null && _n$renderList !== void 0 && _n$renderList.length) {
1513
+ currentResourcesRenderList.push.apply(currentResourcesRenderList, _toConsumableArray(n.renderList || []));
1514
+ }
1515
+ });
1516
+ var _resourcesMap = getResourcesMap(currentResourcesRenderList);
1508
1517
  if (item.holder_id) {
1509
- selectedResources = getOthersSelectedResources(allCartItems, item.holder_id, resourcesMap);
1518
+ selectedResources = getOthersSelectedResources(allCartItems, item.holder_id, _resourcesMap);
1510
1519
  } else {
1511
- selectedResources = getOthersCartSelectedResources(allCartItems, item._id, resourcesMap);
1520
+ selectedResources = getOthersCartSelectedResources(allCartItems, item._id, _resourcesMap);
1512
1521
  }
1513
- var productResources = getResourcesByProduct(resourcesMap, ((_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.product_resource) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.resources) || [], selectedResources, currentCapacity);
1522
+ var productResources = getResourcesByProduct(_resourcesMap, cloneDeep(_resources), selectedResources, currentCapacity);
1514
1523
  // 自动选择 productResources 中对应 resources_code 的资源
1515
1524
  var targetRenderList = (_productResources$fin = productResources.find(function (n) {
1516
1525
  return n.code === resources_code;
@@ -1,6 +1,6 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { Rules, RulesModuleAPI, DiscountResult } from "./types";
3
+ import { Rules, RulesModuleAPI, DiscountResult } from './types';
4
4
  import { Discount } from "../Discount/types";
5
5
  export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
6
6
  protected defaultName: string;
@@ -632,18 +632,18 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
632
632
  const endTime = (0, import_dayjs.default)(
633
633
  `${cartItem._origin.end_date} ${cartItem._origin.end_time}`
634
634
  );
635
- productResources.sort((a, b) => {
636
- var _a2, _b2, _c2, _d;
637
- const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
638
- const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
639
- if (aIsCombined && !bIsCombined)
640
- return 1;
641
- if (!aIsCombined && bIsCombined)
642
- return -1;
643
- return 0;
644
- });
645
635
  const resourcesUseableMap = {};
646
636
  productResources.forEach((n) => {
637
+ n.renderList = n.renderList.sort((a, b) => {
638
+ var _a2, _b2, _c2, _d;
639
+ const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
640
+ const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
641
+ if (aIsCombined && !bIsCombined)
642
+ return 1;
643
+ if (!aIsCombined && bIsCombined)
644
+ return -1;
645
+ return 0;
646
+ });
647
647
  n.renderList = n.renderList.filter((m) => {
648
648
  const recordCount = capacityMap[m.id] || 0;
649
649
  const canUseTime = m.times.find((item) => {
@@ -913,22 +913,31 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
913
913
  } else {
914
914
  const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
915
915
  let selectedResources = [];
916
+ const resources2 = (0, import_lodash_es.cloneDeep)(((_k = (_j = item._productOrigin) == null ? void 0 : _j.product_resource) == null ? void 0 : _k.resources) || []);
917
+ const currentResourcesRenderList = [];
918
+ resources2.forEach((n) => {
919
+ var _a3;
920
+ if ((_a3 = n.renderList) == null ? void 0 : _a3.length) {
921
+ currentResourcesRenderList.push(...n.renderList || []);
922
+ }
923
+ });
924
+ const resourcesMap2 = (0, import_utils.getResourcesMap)(currentResourcesRenderList);
916
925
  if (item.holder_id) {
917
926
  selectedResources = (0, import_resources.getOthersSelectedResources)(
918
927
  allCartItems,
919
928
  item.holder_id,
920
- resourcesMap
929
+ resourcesMap2
921
930
  );
922
931
  } else {
923
932
  selectedResources = (0, import_resources.getOthersCartSelectedResources)(
924
933
  allCartItems,
925
934
  item._id,
926
- resourcesMap
935
+ resourcesMap2
927
936
  );
928
937
  }
929
938
  const productResources = (0, import_resources.getResourcesByProduct)(
930
- resourcesMap,
931
- ((_k = (_j = item._productOrigin) == null ? void 0 : _j.product_resource) == null ? void 0 : _k.resources) || [],
939
+ resourcesMap2,
940
+ (0, import_lodash_es.cloneDeep)(resources2),
932
941
  selectedResources,
933
942
  currentCapacity
934
943
  );
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.0.6",
4
+ "version": "2.0.8",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",