@pisell/pisellos 0.0.21 → 0.0.23

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.
@@ -321,10 +321,17 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
321
321
  key: "storeChange",
322
322
  value: function storeChange() {
323
323
  if (this.openCache) {
324
+ var store = cloneDeep(this.store);
325
+ // store里的 accountList 要主动基于 id 做下去重,避免重复写入
326
+ store.accountList = store.accountList.filter(function (account, index, self) {
327
+ return index === self.findIndex(function (t) {
328
+ return t.id === account.id;
329
+ });
330
+ });
324
331
  this.checkSaveCache({
325
332
  cacheId: this.cacheId,
326
333
  fatherModule: this.fatherModule,
327
- store: this.store,
334
+ store: store,
328
335
  cacheKey: ['accountList']
329
336
  });
330
337
  }
@@ -379,11 +379,18 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
379
379
  key: "storeChange",
380
380
  value: function storeChange() {
381
381
  if (this.openCache) {
382
+ var store = cloneDeep(this.store);
383
+ // store里的 list 要主动基于 id 做下去重,避免重复写入
384
+ store.list = store.list.filter(function (item, index, self) {
385
+ return index === self.findIndex(function (t) {
386
+ return t._id === item._id;
387
+ });
388
+ });
382
389
  this.checkSaveCache({
383
390
  cacheId: this.cacheId,
384
391
  fatherModule: this.fatherModule,
385
- store: this.store,
386
- cacheKey: ['list']
392
+ store: store,
393
+ cacheKey: ["list"]
387
394
  });
388
395
  }
389
396
  }
@@ -177,6 +177,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
177
177
  open_quotation: 1,
178
178
  open_bundle: 1,
179
179
  extension_type: ["product_appointment", "appointment_ticket"],
180
+ with: ["category", "collection"],
180
181
  status: "published",
181
182
  num: 500,
182
183
  skip: 1,
@@ -1022,6 +1023,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1022
1023
  }
1023
1024
  } else {
1024
1025
  var _productResources$fin;
1026
+ debugger;
1025
1027
  // 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
1026
1028
  var productResources = getResourcesByProduct(resourcesMap, item, allCartItems);
1027
1029
  // 自动选择 productResources 中对应 resources_code 的资源
@@ -1042,6 +1044,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1042
1044
  }
1043
1045
  });
1044
1046
  });
1047
+ debugger;
1045
1048
  return {
1046
1049
  errorList: errorList
1047
1050
  };
@@ -1057,15 +1060,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1057
1060
  var cartItems = this.store.cart.getItems();
1058
1061
  var resourceIds = [];
1059
1062
  cartItems.forEach(function (item) {
1060
- var _item$_productOrigin2, _item$_origin$resourc2;
1063
+ var _item$_productOrigin2;
1061
1064
  (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 || (_item$_productOrigin2 = _item$_productOrigin2.product_resource) === null || _item$_productOrigin2 === void 0 || (_item$_productOrigin2 = _item$_productOrigin2.resources) === null || _item$_productOrigin2 === void 0 || _item$_productOrigin2.forEach(function (n) {
1062
1065
  if (n.code === resources_code) {
1063
1066
  resources.push.apply(resources, _toConsumableArray(n.renderList || []));
1064
1067
  }
1065
1068
  });
1066
- (_item$_origin$resourc2 = item._origin.resources) === null || _item$_origin$resourc2 === void 0 || _item$_origin$resourc2.forEach(function (n) {
1067
- resourceIds.push(n.relation_id);
1068
- });
1069
+ // item._origin.resources?.forEach((n: any) => {
1070
+ // resourceIds.push(n.relation_id);
1071
+ // });
1072
+ if (item.resource_id) {
1073
+ resourceIds.push(item.resource_id);
1074
+ }
1069
1075
  });
1070
1076
  var resourcesMap = getResourcesMap(resources);
1071
1077
  var duration = 0;
@@ -1081,6 +1087,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1081
1087
  duration = accountDuration;
1082
1088
  }
1083
1089
  });
1090
+ debugger;
1084
1091
  var timeSlots = getTimeSlicesByResources({
1085
1092
  resourceIds: resourceIds,
1086
1093
  resourcesMap: resourcesMap,
@@ -517,44 +517,40 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
517
517
  while (1) switch (_context9.prev = _context9.next) {
518
518
  case 0:
519
519
  _context9.prev = 0;
520
- customerId = params.customerId || ((_this$getCustomer2 = this.getCustomer()) === null || _this$getCustomer2 === void 0 ? void 0 : _this$getCustomer2.id);
521
- if (!(customerId === 1 || !customerId)) {
522
- _context9.next = 4;
523
- break;
524
- }
525
- return _context9.abrupt("return");
526
- case 4:
527
- _context9.next = 6;
520
+ customerId = params.customerId || ((_this$getCustomer2 = this.getCustomer()) === null || _this$getCustomer2 === void 0 ? void 0 : _this$getCustomer2.id); // if (customerId === 1 || !customerId) {
521
+ // return
522
+ // }
523
+ _context9.next = 4;
528
524
  return (_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.loadPrepareConfig({
529
525
  customer_id: customerId,
530
526
  action: "create",
531
527
  with_good_pass: 1
532
528
  });
533
- case 6:
529
+ case 4:
534
530
  goodPassList = _context9.sent;
535
531
  this.setDiscountList(goodPassList || []);
536
532
  if (!((_this$store$productLi = this.store.productList) !== null && _this$store$productLi !== void 0 && _this$store$productLi.length)) {
537
- _context9.next = 12;
533
+ _context9.next = 10;
538
534
  break;
539
535
  }
540
536
  result = this.calcDiscount(this.store.productList);
541
- _context9.next = 12;
537
+ _context9.next = 10;
542
538
  return this.core.effects.emit(ShopDiscountHooks.onLoadPrepareCalcResult, result);
543
- case 12:
544
- _context9.next = 14;
539
+ case 10:
540
+ _context9.next = 12;
545
541
  return this.core.effects.emit(ShopDiscountHooks.onLoadDiscountList, goodPassList);
546
- case 14:
547
- _context9.next = 19;
542
+ case 12:
543
+ _context9.next = 17;
548
544
  break;
549
- case 16:
550
- _context9.prev = 16;
545
+ case 14:
546
+ _context9.prev = 14;
551
547
  _context9.t0 = _context9["catch"](0);
552
548
  console.error("[ShopDiscount] 加载准备配置出错:", _context9.t0);
553
- case 19:
549
+ case 17:
554
550
  case "end":
555
551
  return _context9.stop();
556
552
  }
557
- }, _callee9, this, [[0, 16]]);
553
+ }, _callee9, this, [[0, 14]]);
558
554
  }));
559
555
  function loadPrepareConfig(_x8) {
560
556
  return _loadPrepareConfig.apply(this, arguments);
@@ -164,7 +164,11 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
164
164
  }
165
165
  storeChange() {
166
166
  if (this.openCache) {
167
- this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["accountList"] });
167
+ const store = (0, import_lodash_es.cloneDeep)(this.store);
168
+ store.accountList = store.accountList.filter(
169
+ (account, index, self) => index === self.findIndex((t) => t.id === account.id)
170
+ );
171
+ this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store, cacheKey: ["accountList"] });
168
172
  }
169
173
  }
170
174
  };
@@ -76,7 +76,12 @@ var CartModule = class extends import_BaseModule.BaseModule {
76
76
  };
77
77
  if (product) {
78
78
  cartItem._productOrigin = (0, import_lodash_es.cloneDeep)(product);
79
- cartItem = (0, import_utils.formatProductToCartItem)({ cartItem, product, bundle, options });
79
+ cartItem = (0, import_utils.formatProductToCartItem)({
80
+ cartItem,
81
+ product,
82
+ bundle,
83
+ options
84
+ });
80
85
  }
81
86
  if (account) {
82
87
  cartItem = (0, import_utils.formatAccountToCartItem)({ cartItem, account });
@@ -117,16 +122,28 @@ var CartModule = class extends import_BaseModule.BaseModule {
117
122
  }
118
123
  if (product) {
119
124
  tempCartItem._productOrigin = (0, import_lodash_es.cloneDeep)(product);
120
- tempCartItem = (0, import_utils.formatProductToCartItem)({ cartItem: tempCartItem, product });
125
+ tempCartItem = (0, import_utils.formatProductToCartItem)({
126
+ cartItem: tempCartItem,
127
+ product
128
+ });
121
129
  }
122
130
  if (discounts) {
123
- tempCartItem = (0, import_utils.formatDiscountToCartItem)({ cartItem: tempCartItem, discounts });
131
+ tempCartItem = (0, import_utils.formatDiscountToCartItem)({
132
+ cartItem: tempCartItem,
133
+ discounts
134
+ });
124
135
  }
125
136
  if (account) {
126
- tempCartItem = (0, import_utils.formatAccountToCartItem)({ cartItem: tempCartItem, account });
137
+ tempCartItem = (0, import_utils.formatAccountToCartItem)({
138
+ cartItem: tempCartItem,
139
+ account
140
+ });
127
141
  }
128
142
  if (resources) {
129
- tempCartItem = (0, import_utils.formatResourceToCartItem)({ cartItem: tempCartItem, resources });
143
+ tempCartItem = (0, import_utils.formatResourceToCartItem)({
144
+ cartItem: tempCartItem,
145
+ resources
146
+ });
130
147
  }
131
148
  if (note) {
132
149
  tempCartItem = (0, import_utils.formatNoteToCartItem)({ cartItem: tempCartItem, note });
@@ -155,7 +172,9 @@ var CartModule = class extends import_BaseModule.BaseModule {
155
172
  * 根据账户ID获取购物车
156
173
  */
157
174
  getCartByAccount(account_id) {
158
- return this.store.list.filter((item) => item.holder_id === account_id);
175
+ return this.store.list.filter(
176
+ (item) => item.holder_id === account_id
177
+ );
159
178
  }
160
179
  /**
161
180
  * 移除购物车商品
@@ -169,7 +188,9 @@ var CartModule = class extends import_BaseModule.BaseModule {
169
188
  * 根据账户ID清除购物车
170
189
  */
171
190
  clearCartByAccount(account_id) {
172
- const items = this.store.list.filter((item) => item.holder_id !== account_id);
191
+ const items = this.store.list.filter(
192
+ (item) => item.holder_id !== account_id
193
+ );
173
194
  this.store.list = [...items || []];
174
195
  }
175
196
  /**
@@ -194,7 +215,16 @@ var CartModule = class extends import_BaseModule.BaseModule {
194
215
  }
195
216
  storeChange() {
196
217
  if (this.openCache) {
197
- this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["list"] });
218
+ const store = (0, import_lodash_es.cloneDeep)(this.store);
219
+ store.list = store.list.filter(
220
+ (item, index, self) => index === self.findIndex((t) => t._id === item._id)
221
+ );
222
+ this.checkSaveCache({
223
+ cacheId: this.cacheId,
224
+ fatherModule: this.fatherModule,
225
+ store,
226
+ cacheKey: ["list"]
227
+ });
198
228
  }
199
229
  }
200
230
  };
@@ -134,6 +134,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
134
134
  open_quotation: 1,
135
135
  open_bundle: 1,
136
136
  extension_type: ["product_appointment", "appointment_ticket"],
137
+ with: ["category", "collection"],
137
138
  status: "published",
138
139
  num: 500,
139
140
  skip: 1,
@@ -571,6 +572,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
571
572
  errorList.push(item._id);
572
573
  }
573
574
  } else {
575
+ debugger;
574
576
  const productResources = (0, import_resources.getResourcesByProduct)(resourcesMap, item, allCartItems);
575
577
  const targetRenderList = (_a = productResources.find((n) => n.code === resources_code)) == null ? void 0 : _a.renderList;
576
578
  if (targetRenderList && targetRenderList.length > 0) {
@@ -589,6 +591,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
589
591
  }
590
592
  });
591
593
  });
594
+ debugger;
592
595
  return { errorList };
593
596
  }
594
597
  // 从购物车中获取已经分配好第一步资源的所有时间片
@@ -598,15 +601,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
598
601
  const cartItems = this.store.cart.getItems();
599
602
  const resourceIds = [];
600
603
  cartItems.forEach((item) => {
601
- var _a, _b, _c, _d;
604
+ var _a, _b, _c;
602
605
  (_c = (_b = (_a = item._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) == null ? void 0 : _c.forEach((n) => {
603
606
  if (n.code === resources_code) {
604
607
  resources.push(...n.renderList || []);
605
608
  }
606
609
  });
607
- (_d = item._origin.resources) == null ? void 0 : _d.forEach((n) => {
608
- resourceIds.push(n.relation_id);
609
- });
610
+ if (item.resource_id) {
611
+ resourceIds.push(item.resource_id);
612
+ }
610
613
  });
611
614
  const resourcesMap = (0, import_utils.getResourcesMap)(resources);
612
615
  let duration = 0;
@@ -621,6 +624,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
621
624
  duration = accountDuration;
622
625
  }
623
626
  });
627
+ debugger;
624
628
  const timeSlots = (0, import_resources.getTimeSlicesByResources)({
625
629
  resourceIds,
626
630
  resourcesMap,
@@ -307,9 +307,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
307
307
  var _a, _b, _c;
308
308
  try {
309
309
  const customerId = params.customerId || ((_a = this.getCustomer()) == null ? void 0 : _a.id);
310
- if (customerId === 1 || !customerId) {
311
- return;
312
- }
313
310
  const goodPassList = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
314
311
  customer_id: customerId,
315
312
  action: "create",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.21",
4
+ "version": "0.0.23",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",