@pisell/pisellos 3.0.16 → 3.0.19

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.
@@ -16,6 +16,7 @@ export declare class AccountListModule extends BaseModule implements Module {
16
16
  * 创建账号并添加到列表中
17
17
  * @param account 账号信息
18
18
  * @param needEmit 是否需要触发事件
19
+ * @param type 添加类型
19
20
  */
20
21
  private createAccountAndAdd;
21
22
  addAccount(account: Account): Promise<AccountModule>;
@@ -30,10 +31,12 @@ export declare class AccountListModule extends BaseModule implements Module {
30
31
  storeChange(): void;
31
32
  /**
32
33
  * 批量添加holder类型账号
33
- * @param holders 账号信息列表
34
- * @param customerId 账户id
35
34
  */
36
- addHolderAccounts(holders: IHolder[], customerId: number): Promise<AccountModule[]>;
35
+ addHolderAccounts(params: {
36
+ holders: IHolder[];
37
+ customerId: number;
38
+ type?: 'unshift' | 'push';
39
+ }): Promise<AccountModule[]>;
37
40
  /**
38
41
  * 获取holder类型账户列表
39
42
  * @param params
@@ -97,42 +97,56 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
97
97
  * 创建账号并添加到列表中
98
98
  * @param account 账号信息
99
99
  * @param needEmit 是否需要触发事件
100
+ * @param type 添加类型
100
101
  */
101
102
  }, {
102
103
  key: "createAccountAndAdd",
103
104
  value: (function () {
104
105
  var _createAccountAndAdd = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(account) {
105
106
  var needEmit,
107
+ type,
106
108
  tempAccountModule,
109
+ newAccountList,
107
110
  accountModule,
108
111
  _args2 = arguments;
109
112
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
110
113
  while (1) switch (_context2.prev = _context2.next) {
111
114
  case 0:
112
115
  needEmit = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : true;
116
+ type = _args2.length > 2 ? _args2[2] : undefined;
113
117
  tempAccountModule = this.store.accounts.find(function (a) {
114
118
  return a.getId() === account.id;
115
119
  }); // 如果账号已经存在,则直接返回
116
120
  if (!tempAccountModule) {
117
- _context2.next = 4;
121
+ _context2.next = 5;
118
122
  break;
119
123
  }
120
124
  return _context2.abrupt("return", tempAccountModule);
121
- case 4:
122
- this.store.accountList.push(account);
125
+ case 5:
126
+ newAccountList = _toConsumableArray(this.store.accountList || []);
127
+ if (type === 'unshift') {
128
+ newAccountList.unshift(account);
129
+ } else {
130
+ newAccountList.push(account);
131
+ }
132
+ this.store.accountList = newAccountList;
123
133
  accountModule = new AccountModule("account_".concat(account.id));
124
134
  this.core.registerModule(accountModule);
125
135
  accountModule.setAccountInfo(account);
126
- this.store.accounts = [].concat(_toConsumableArray(this.store.accounts || []), [accountModule]);
136
+ if (type === 'unshift') {
137
+ this.store.accounts = [accountModule].concat(_toConsumableArray(this.store.accounts || []));
138
+ } else {
139
+ this.store.accounts = [].concat(_toConsumableArray(this.store.accounts || []), [accountModule]);
140
+ }
127
141
  if (!needEmit) {
128
- _context2.next = 12;
142
+ _context2.next = 15;
129
143
  break;
130
144
  }
131
- _context2.next = 12;
145
+ _context2.next = 15;
132
146
  return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
133
- case 12:
147
+ case 15:
134
148
  return _context2.abrupt("return", accountModule);
135
- case 13:
149
+ case 16:
136
150
  case "end":
137
151
  return _context2.stop();
138
152
  }
@@ -425,59 +439,62 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
425
439
 
426
440
  /**
427
441
  * 批量添加holder类型账号
428
- * @param holders 账号信息列表
429
- * @param customerId 账户id
430
442
  */
431
443
  }, {
432
444
  key: "addHolderAccounts",
433
445
  value: (function () {
434
- var _addHolderAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(holders, customerId) {
435
- var accountModules, _iterator, _step, holder, account, accountModule;
446
+ var _addHolderAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
447
+ var holders, customerId, _params$type, type, accountModules, _iterator, _step, holder, account, accountModule;
436
448
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
437
449
  while (1) switch (_context8.prev = _context8.next) {
438
450
  case 0:
451
+ holders = params.holders, customerId = params.customerId, _params$type = params.type, type = _params$type === void 0 ? 'push' : _params$type;
439
452
  accountModules = [];
440
453
  _iterator = _createForOfIteratorHelper(holders);
441
- _context8.prev = 2;
454
+ _context8.prev = 3;
442
455
  _iterator.s();
443
- case 4:
456
+ case 5:
444
457
  if ((_step = _iterator.n()).done) {
445
- _context8.next = 13;
458
+ _context8.next = 14;
446
459
  break;
447
460
  }
448
461
  holder = _step.value;
449
462
  account = createHolderAccount(holder, customerId);
450
- _context8.next = 9;
451
- return this.createAccountAndAdd(account, false);
452
- case 9:
463
+ _context8.next = 10;
464
+ return this.createAccountAndAdd(account, false, type);
465
+ case 10:
453
466
  accountModule = _context8.sent;
454
- accountModules.push(accountModule);
455
- case 11:
456
- _context8.next = 4;
467
+ if (type === 'unshift') {
468
+ accountModules.unshift(accountModule);
469
+ } else {
470
+ accountModules.push(accountModule);
471
+ }
472
+ case 12:
473
+ _context8.next = 5;
457
474
  break;
458
- case 13:
459
- _context8.next = 18;
475
+ case 14:
476
+ _context8.next = 19;
460
477
  break;
461
- case 15:
462
- _context8.prev = 15;
463
- _context8.t0 = _context8["catch"](2);
478
+ case 16:
479
+ _context8.prev = 16;
480
+ _context8.t0 = _context8["catch"](3);
464
481
  _iterator.e(_context8.t0);
465
- case 18:
466
- _context8.prev = 18;
482
+ case 19:
483
+ _context8.prev = 19;
467
484
  _iterator.f();
468
- return _context8.finish(18);
469
- case 21:
470
- _context8.next = 23;
485
+ return _context8.finish(19);
486
+ case 22:
487
+ _context8.next = 24;
471
488
  return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
472
- case 23:
473
- return _context8.abrupt("return", accountModules);
474
489
  case 24:
490
+ return _context8.abrupt("return", accountModules);
491
+ case 25:
475
492
  case "end":
476
493
  return _context8.stop();
477
494
  }
478
- }, _callee8, this, [[2, 15, 18, 21]]);
495
+ }, _callee8, this, [[3, 16, 19, 22]]);
479
496
  }));
480
- function addHolderAccounts(_x10, _x11) {
497
+ function addHolderAccounts(_x10) {
481
498
  return _addHolderAccounts.apply(this, arguments);
482
499
  }
483
500
  return addHolderAccounts;
@@ -508,26 +525,31 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
508
525
  });
509
526
  case 5:
510
527
  res = _context9.sent;
528
+ this.store.accountList = [];
529
+ this.store.accounts = [];
511
530
  if (!(res !== null && res !== void 0 && (_res$data = res.data) !== null && _res$data !== void 0 && (_res$data = _res$data.list) !== null && _res$data !== void 0 && _res$data.length)) {
512
- _context9.next = 9;
531
+ _context9.next = 11;
513
532
  break;
514
533
  }
515
- _context9.next = 9;
516
- return this.addHolderAccounts(res.data.list, customer_id);
517
- case 9:
518
- _context9.next = 14;
519
- break;
534
+ _context9.next = 11;
535
+ return this.addHolderAccounts({
536
+ holders: res.data.list,
537
+ customerId: customer_id
538
+ });
520
539
  case 11:
521
- _context9.prev = 11;
540
+ _context9.next = 16;
541
+ break;
542
+ case 13:
543
+ _context9.prev = 13;
522
544
  _context9.t0 = _context9["catch"](2);
523
545
  console.error(_context9.t0);
524
- case 14:
546
+ case 16:
525
547
  case "end":
526
548
  return _context9.stop();
527
549
  }
528
- }, _callee9, this, [[2, 11]]);
550
+ }, _callee9, this, [[2, 13]]);
529
551
  }));
530
- function fetchHolderAccounts(_x12) {
552
+ function fetchHolderAccounts(_x11) {
531
553
  return _fetchHolderAccounts.apply(this, arguments);
532
554
  }
533
555
  return fetchHolderAccounts;
@@ -542,14 +542,19 @@ export var getProductDeposit = function getProductDeposit(params) {
542
542
 
543
543
  // 判定商品是否有定金规则
544
544
  if ((product === null || product === void 0 || (_product$custom_depos2 = product.custom_deposit_data) === null || _product$custom_depos2 === void 0 ? void 0 : _product$custom_depos2.has_deposit) == 1) {
545
- var protocols = [];
546
545
  var total = new Decimal(0);
547
546
  var _ref2 = (product === null || product === void 0 ? void 0 : product.custom_deposit_data) || {},
548
547
  deposit_fixed = _ref2.deposit_fixed,
549
548
  deposit_percentage = _ref2.deposit_percentage,
550
- deposit_policy_data = _ref2.deposit_policy_data;
551
- // 协议数据
552
- protocols.push.apply(protocols, _toConsumableArray(deposit_policy_data || []));
549
+ deposit_policy_data = _ref2.deposit_policy_data,
550
+ self_deposit_policy_ids = _ref2.self_deposit_policy_ids;
551
+ // 所有协议数据
552
+ var allProtocols = deposit_policy_data || [];
553
+ // 是否存在定金,主商品has_deposit为1,但是自身没有定金设置,需要判定子商品是否存在定金,如果不存在最终判定也是不存在定金
554
+ var productHasDeposit = false;
555
+ // 关联的定金协议id
556
+ var protocolIds = [];
557
+
553
558
  // 判断主商品是否有定金规则
554
559
  if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
555
560
  var _handleProductDeposit = handleProductDeposit({
@@ -561,28 +566,40 @@ export var getProductDeposit = function getProductDeposit(params) {
561
566
  result = _handleProductDeposit.result;
562
567
  if (result) {
563
568
  total = depositTotal;
569
+ protocolIds.push.apply(protocolIds, _toConsumableArray(self_deposit_policy_ids || []));
570
+ productHasDeposit = true;
564
571
  }
565
572
  } else {
566
573
  if (bundle !== null && bundle !== void 0 && bundle.length) {
567
- total = bundle.reduce(function (accumulator, currentBundleProduct) {
574
+ total = bundle.reduce(function (accumulator, currBundleProduct) {
575
+ var depositData = currBundleProduct === null || currBundleProduct === void 0 ? void 0 : currBundleProduct.custom_deposit_data;
568
576
  var _handleProductDeposit2 = handleProductDeposit({
569
- depositData: currentBundleProduct === null || currentBundleProduct === void 0 ? void 0 : currentBundleProduct.custom_deposit_data,
570
- total: currentBundleProduct.price,
571
- num: currentBundleProduct.num
577
+ depositData: depositData,
578
+ total: currBundleProduct === null || currBundleProduct === void 0 ? void 0 : currBundleProduct.price,
579
+ num: (currBundleProduct === null || currBundleProduct === void 0 ? void 0 : currBundleProduct.num) || 1
572
580
  }),
573
581
  depositTotal = _handleProductDeposit2.depositTotal,
574
582
  result = _handleProductDeposit2.result;
575
583
  if (result) {
584
+ protocolIds.push.apply(protocolIds, _toConsumableArray((depositData === null || depositData === void 0 ? void 0 : depositData.self_deposit_policy_ids) || []));
585
+ productHasDeposit = true;
576
586
  return accumulator.plus(depositTotal);
577
587
  }
578
588
  return accumulator;
579
589
  }, new Decimal(0));
580
590
  }
581
591
  }
582
- return {
583
- total: total.toNumber(),
584
- protocols: protocols
585
- };
592
+ if (productHasDeposit) {
593
+ var ids = new Set(protocolIds);
594
+ var protocols = allProtocols.filter(function (item) {
595
+ return ids.has(item.id);
596
+ });
597
+ return {
598
+ total: total.toNumber(),
599
+ protocols: protocols
600
+ };
601
+ }
602
+ return null;
586
603
  }
587
604
  return null;
588
605
  };
@@ -44,6 +44,7 @@ export interface Discount {
44
44
  balance: string;
45
45
  format_title: Formattitle;
46
46
  product: Product;
47
+ type: "product" | 'good_pass';
47
48
  resource_id?: number;
48
49
  savedAmount?: number;
49
50
  isEditMode?: boolean;
@@ -168,6 +168,8 @@ export interface ProductData {
168
168
  deposit_fixed?: string;
169
169
  /** 定金百分比 */
170
170
  deposit_percentage?: string;
171
+ /** 关联的定金协议id */
172
+ self_deposit_policy_ids?: number[];
171
173
  /** 定金协议数据 */
172
174
  deposit_policy_data?: Array<{
173
175
  /** 定金协议id */
@@ -457,4 +459,6 @@ export interface ProductResourceItem {
457
459
  updated_at: string;
458
460
  /** 可用资源列表 */
459
461
  renderList?: any[];
462
+ /** 资源类型 */
463
+ type: 'single' | 'multiple' | 'capacity';
460
464
  }
@@ -25,7 +25,8 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
25
25
  productList: any[];
26
26
  }, options?: {
27
27
  isSelected?: boolean;
28
- discountId: number;
28
+ discountId?: number;
29
+ scan?: boolean;
29
30
  }): DiscountResult;
30
31
  destroy(): Promise<void>;
31
32
  clear(): Promise<void>;
@@ -111,6 +111,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
111
111
  var result = this.calcDiscount({
112
112
  discountList: mergedDiscountList,
113
113
  productList: _toConsumableArray(productList)
114
+ }, {
115
+ scan: true
114
116
  });
115
117
 
116
118
  // 检查是否有产品使用了新折扣
@@ -214,7 +216,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
214
216
 
215
217
  // 编辑的商品 使用了优惠券不可用
216
218
  var isAvailableProduct = !(product !== null && product !== void 0 && product.booking_id && product !== null && product !== void 0 && (_product$discount_lis = product.discount_list) !== null && _product$discount_lis !== void 0 && _product$discount_lis.length && product !== null && product !== void 0 && (_product$discount_lis2 = product.discount_list) !== null && _product$discount_lis2 !== void 0 && _product$discount_lis2.every(function (discount) {
217
- return discount.id;
219
+ return discount.id && discount.type === 'good_pass';
218
220
  }));
219
221
 
220
222
  // 判断优惠券是否适用于该商品
@@ -244,7 +246,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
244
246
  var _product$discount_lis3, _product$discount_lis4, _product$discount_lis5;
245
247
  var product = _this3.hooks.getProduct(originProduct);
246
248
  if (product !== null && product !== void 0 && product.booking_id && (_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.length && product !== null && product !== void 0 && (_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.every(function (discount) {
247
- return discount.id;
249
+ return discount.id && discount.type === 'good_pass';
248
250
  })) {
249
251
  processedProductsMap.set(product._id, originProduct);
250
252
  return;
@@ -308,7 +310,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
308
310
  }
309
311
  return;
310
312
  }
311
- if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined') {
313
+ if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined' && !(options !== null && options !== void 0 && options.scan)) {
312
314
  return;
313
315
  }
314
316
 
@@ -366,7 +368,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
366
368
  var product = _this3.hooks.getProduct(originProduct);
367
369
  var getDefaultProduct = function getDefaultProduct() {
368
370
  if (product.isClient) {
369
- _this3.hooks.setProduct(originProduct, {
371
+ return _this3.hooks.setProduct(originProduct, {
370
372
  discount_list: [],
371
373
  price: product.price,
372
374
  origin_total: getProductOriginTotalPrice({
@@ -385,7 +387,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
385
387
  })
386
388
  });
387
389
  } else {
388
- _this3.hooks.setProduct(originProduct, {
390
+ return _this3.hooks.setProduct(originProduct, {
389
391
  discount_list: [],
390
392
  total: product.total,
391
393
  origin_total: product.origin_total,
@@ -147,6 +147,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
147
147
  checkCartItems(type: ECartItemCheckType): string[];
148
148
  destroy(): void;
149
149
  getResourcesList(): any[];
150
+ checkResourceListForDate(): boolean;
150
151
  getResourcesListByCartItem(id: string | number): {
151
152
  id: number | undefined;
152
153
  _id: string;