@pisell/pisellos 3.0.15 → 3.0.18

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;
@@ -550,6 +550,9 @@ export var getProductDeposit = function getProductDeposit(params) {
550
550
  deposit_policy_data = _ref2.deposit_policy_data;
551
551
  // 协议数据
552
552
  protocols.push.apply(protocols, _toConsumableArray(deposit_policy_data || []));
553
+ // 是否存在定金,主商品has_deposit为1,但是自身没有定金设置,需要判定子商品是否存在定金,如果不存在最终判定也是不存在定金
554
+ var productHasDeposit = false;
555
+
553
556
  // 判断主商品是否有定金规则
554
557
  if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
555
558
  var _handleProductDeposit = handleProductDeposit({
@@ -561,6 +564,7 @@ export var getProductDeposit = function getProductDeposit(params) {
561
564
  result = _handleProductDeposit.result;
562
565
  if (result) {
563
566
  total = depositTotal;
567
+ productHasDeposit = true;
564
568
  }
565
569
  } else {
566
570
  if (bundle !== null && bundle !== void 0 && bundle.length) {
@@ -573,16 +577,20 @@ export var getProductDeposit = function getProductDeposit(params) {
573
577
  depositTotal = _handleProductDeposit2.depositTotal,
574
578
  result = _handleProductDeposit2.result;
575
579
  if (result) {
580
+ productHasDeposit = true;
576
581
  return accumulator.plus(depositTotal);
577
582
  }
578
583
  return accumulator;
579
584
  }, new Decimal(0));
580
585
  }
581
586
  }
582
- return {
583
- total: total.toNumber(),
584
- protocols: protocols
585
- };
587
+ if (productHasDeposit) {
588
+ return {
589
+ total: total.toNumber(),
590
+ protocols: protocols
591
+ };
592
+ }
593
+ return null;
586
594
  }
587
595
  return null;
588
596
  };
@@ -457,4 +457,6 @@ export interface ProductResourceItem {
457
457
  updated_at: string;
458
458
  /** 可用资源列表 */
459
459
  renderList?: any[];
460
+ /** 资源类型 */
461
+ type: 'single' | 'multiple' | 'capacity';
460
462
  }
@@ -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;