@pisell/pisellos 2.2.91 → 2.2.93

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.
@@ -9,6 +9,7 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
9
9
  private cacheId;
10
10
  private openCache;
11
11
  private fatherModule;
12
+ private otherParams;
12
13
  constructor(name?: string, version?: string);
13
14
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
14
15
  /**
@@ -56,6 +56,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
56
56
  _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
57
57
  _defineProperty(_assertThisInitialized(_this), "openCache", false);
58
58
  _defineProperty(_assertThisInitialized(_this), "fatherModule", void 0);
59
+ _defineProperty(_assertThisInitialized(_this), "otherParams", {});
59
60
  return _this;
60
61
  }
61
62
  _createClass(CustomerModule, [{
@@ -70,6 +71,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
70
71
  this.core = core;
71
72
  this.store = options === null || options === void 0 ? void 0 : options.store;
72
73
  this.request = this.core.getPlugin('request');
74
+ this.otherParams = (options === null || options === void 0 ? void 0 : options.otherParams) || {};
73
75
 
74
76
  // 初始化状态
75
77
  if (Array.isArray(options === null || options === void 0 || (_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.customerList)) {
@@ -112,7 +114,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
112
114
  if (options !== null && options !== void 0 && (_options$otherParams2 = options.otherParams) !== null && _options$otherParams2 !== void 0 && _options$otherParams2.fatherModule) {
113
115
  this.fatherModule = options.otherParams.fatherModule;
114
116
  }
115
- case 13:
117
+ case 14:
116
118
  case "end":
117
119
  return _context.stop();
118
120
  }
@@ -132,7 +134,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
132
134
  key: "fetchCustomerListData",
133
135
  value: (function () {
134
136
  var _fetchCustomerListData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
135
- var _res$data, _res$data2;
137
+ var _this$otherParams, _res$data, _this$otherParams2, _customerList2, _res$data2;
136
138
  var params,
137
139
  url,
138
140
  _params$skip,
@@ -140,16 +142,21 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
140
142
  _params$num,
141
143
  num,
142
144
  search,
143
- otherParams,
145
+ _otherParams,
144
146
  queryParams,
145
147
  res,
148
+ _customerList,
149
+ _customerList3,
146
150
  _args2 = arguments;
147
151
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
148
152
  while (1) switch (_context2.prev = _context2.next) {
149
153
  case 0:
150
154
  params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
151
- url = '/customer/select-list';
152
- _params$skip = params.skip, skip = _params$skip === void 0 ? 1 : _params$skip, _params$num = params.num, num = _params$num === void 0 ? DEFAULT_PAGE_SIZE : _params$num, search = params.search, otherParams = _objectWithoutProperties(params, _excluded);
155
+ url = '/customer/select-list'; // 如果是加盟子店铺,则使用加盟商的客户列表接口
156
+ if ((_this$otherParams = this.otherParams) !== null && _this$otherParams !== void 0 && _this$otherParams.isFranchisee) {
157
+ url = '/franchisee/customer/select-list';
158
+ }
159
+ _params$skip = params.skip, skip = _params$skip === void 0 ? 1 : _params$skip, _params$num = params.num, num = _params$num === void 0 ? DEFAULT_PAGE_SIZE : _params$num, search = params.search, _otherParams = _objectWithoutProperties(params, _excluded);
153
160
  queryParams = _objectSpread(_objectSpread({
154
161
  skip: skip,
155
162
  num: num,
@@ -159,29 +166,38 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
159
166
  search_wallet_pass_flag: 1
160
167
  }, search && {
161
168
  search: search
162
- }), otherParams);
163
- _context2.next = 6;
169
+ }), _otherParams);
170
+ _context2.next = 7;
164
171
  return this.request.get(url, queryParams, {
165
172
  cache: {
166
173
  mode: RequestModeENUM.REMOTE_LOCAL,
167
174
  type: "memory"
168
175
  }
169
176
  });
170
- case 6:
177
+ case 7:
171
178
  res = _context2.sent;
172
179
  if (!((res === null || res === void 0 ? void 0 : res.code) !== 200)) {
173
- _context2.next = 9;
180
+ _context2.next = 10;
174
181
  break;
175
182
  }
176
183
  throw new Error(res === null || res === void 0 ? void 0 : res.message);
177
- case 9:
184
+ case 10:
185
+ // 如果是加盟子店铺,查询的接口返回的数据都是总店的客户数据,需要加上标识
186
+ _customerList = (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.list) || [];
187
+ if ((_this$otherParams2 = this.otherParams) !== null && _this$otherParams2 !== void 0 && _this$otherParams2.isFranchisee && ((_customerList2 = _customerList) === null || _customerList2 === void 0 ? void 0 : _customerList2.length) > 0) {
188
+ _customerList = (_customerList3 = _customerList) === null || _customerList3 === void 0 ? void 0 : _customerList3.map(function (item) {
189
+ return _objectSpread(_objectSpread({}, item || {}), {}, {
190
+ is_franchisor_customer: 1 // 标识是总店的客户
191
+ });
192
+ });
193
+ }
178
194
  return _context2.abrupt("return", {
179
- customerList: (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.list) || [],
195
+ customerList: _customerList,
180
196
  total: (res === null || res === void 0 || (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.count) || 0,
181
197
  page: skip,
182
198
  pageSize: num
183
199
  });
184
- case 10:
200
+ case 13:
185
201
  case "end":
186
202
  return _context2.stop();
187
203
  }
@@ -1526,7 +1526,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1526
1526
  key: "processProductSyncMessages",
1527
1527
  value: (function () {
1528
1528
  var _processProductSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1529
- var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, shouldClearPriceCache, _iterator7, _step7, msg, channelKey, _msg$relation_product, _msg$change_types, _msg$ids2, _msg$ids, ids, bodyId, _msg$relation_product2, _msg$relation_product3, uniqueDeleteIds, uniqueSSEIds, uniquePriceIds, freshProducts, allChangedIds, hasChanges;
1529
+ var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, shouldClearPriceCache, _iterator7, _step7, msg, channelKey, _msg$relation_product, _msg$change_types, _msg$ids2, _msg$ids, ids, bodyId, _bodyId, _msg$relation_product2, _msg$relation_product3, uniqueDeleteIds, uniqueSSEIds, uniquePriceIds, freshProducts, allChangedIds, hasChanges;
1530
1530
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1531
1531
  while (1) switch (_context17.prev = _context17.next) {
1532
1532
  case 0:
@@ -1551,13 +1551,13 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1551
1551
  _iterator7.s();
1552
1552
  case 13:
1553
1553
  if ((_step7 = _iterator7.n()).done) {
1554
- _context17.next = 35;
1554
+ _context17.next = 36;
1555
1555
  break;
1556
1556
  }
1557
1557
  msg = _step7.value;
1558
1558
  channelKey = msg._channelKey || msg.module || 'product';
1559
1559
  if (!(channelKey === 'product')) {
1560
- _context17.next = 32;
1560
+ _context17.next = 33;
1561
1561
  break;
1562
1562
  }
1563
1563
  if ((_msg$relation_product = msg.relation_product_ids) !== null && _msg$relation_product !== void 0 && _msg$relation_product.length) {
@@ -1569,33 +1569,37 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1569
1569
  break;
1570
1570
  }
1571
1571
  if ((_msg$ids = msg.ids) !== null && _msg$ids !== void 0 && _msg$ids.length) deleteIds.push.apply(deleteIds, _toConsumableArray(msg.ids));else if (msg.id) deleteIds.push(msg.id);
1572
- return _context17.abrupt("continue", 33);
1572
+ return _context17.abrupt("continue", 34);
1573
1573
  case 21:
1574
1574
  if (!((_msg$change_types = msg.change_types) !== null && _msg$change_types !== void 0 && _msg$change_types.includes('price'))) {
1575
- _context17.next = 25;
1575
+ _context17.next = 26;
1576
1576
  break;
1577
1577
  }
1578
1578
  ids = msg.ids || (msg.id ? [msg.id] : []);
1579
1579
  priceRefreshIds.push.apply(priceRefreshIds, _toConsumableArray(ids));
1580
- return _context17.abrupt("continue", 33);
1581
- case 25:
1580
+ if (msg.body) {
1581
+ bodyId = msg.body.id;
1582
+ if (bodyId) bodyUpdates.set(bodyId, msg.body);
1583
+ }
1584
+ return _context17.abrupt("continue", 34);
1585
+ case 26:
1582
1586
  if (!msg.body) {
1583
- _context17.next = 29;
1587
+ _context17.next = 30;
1584
1588
  break;
1585
1589
  }
1586
- bodyId = msg.body.id || msg.id;
1587
- if (bodyId) bodyUpdates.set(bodyId, msg.body);
1588
- return _context17.abrupt("continue", 33);
1589
- case 29:
1590
+ _bodyId = msg.body.id || msg.id;
1591
+ if (_bodyId) bodyUpdates.set(_bodyId, msg.body);
1592
+ return _context17.abrupt("continue", 34);
1593
+ case 30:
1590
1594
  // 4. 其他情况(有 ids 无 body 无 change_types)→ SSE 拉取
1591
1595
  if ((_msg$ids2 = msg.ids) !== null && _msg$ids2 !== void 0 && _msg$ids2.length) {
1592
1596
  sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.ids));
1593
1597
  } else if (msg.id) {
1594
1598
  sseRefreshIds.push(msg.id);
1595
1599
  }
1596
- _context17.next = 33;
1600
+ _context17.next = 34;
1597
1601
  break;
1598
- case 32:
1602
+ case 33:
1599
1603
  if (channelKey === 'product_quotation') {
1600
1604
  // 报价单变更影响范围大,标记清除全量价格缓存
1601
1605
  shouldClearPriceCache = true;
@@ -1607,61 +1611,61 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1607
1611
  sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.relation_product_ids));
1608
1612
  }
1609
1613
  }
1610
- case 33:
1614
+ case 34:
1611
1615
  _context17.next = 13;
1612
1616
  break;
1613
- case 35:
1614
- _context17.next = 40;
1617
+ case 36:
1618
+ _context17.next = 41;
1615
1619
  break;
1616
- case 37:
1617
- _context17.prev = 37;
1620
+ case 38:
1621
+ _context17.prev = 38;
1618
1622
  _context17.t0 = _context17["catch"](11);
1619
1623
  _iterator7.e(_context17.t0);
1620
- case 40:
1621
- _context17.prev = 40;
1624
+ case 41:
1625
+ _context17.prev = 41;
1622
1626
  _iterator7.f();
1623
- return _context17.finish(40);
1624
- case 43:
1627
+ return _context17.finish(41);
1628
+ case 44:
1625
1629
  uniqueDeleteIds = _toConsumableArray(new Set(deleteIds));
1626
1630
  uniqueSSEIds = _toConsumableArray(new Set(sseRefreshIds));
1627
1631
  uniquePriceIds = _toConsumableArray(new Set(priceRefreshIds)); // 1. 处理删除
1628
1632
  if (!(uniqueDeleteIds.length > 0)) {
1629
- _context17.next = 49;
1633
+ _context17.next = 50;
1630
1634
  break;
1631
1635
  }
1632
- _context17.next = 49;
1636
+ _context17.next = 50;
1633
1637
  return this.removeProductsByIds(uniqueDeleteIds);
1634
- case 49:
1638
+ case 50:
1635
1639
  if (!(bodyUpdates.size > 0)) {
1636
- _context17.next = 52;
1640
+ _context17.next = 53;
1637
1641
  break;
1638
1642
  }
1639
- _context17.next = 52;
1643
+ _context17.next = 53;
1640
1644
  return this.applyBodyUpdatesToStore(bodyUpdates);
1641
- case 52:
1645
+ case 53:
1642
1646
  if (!(uniqueSSEIds.length > 0)) {
1643
- _context17.next = 60;
1647
+ _context17.next = 61;
1644
1648
  break;
1645
1649
  }
1646
- _context17.next = 55;
1650
+ _context17.next = 56;
1647
1651
  return this.fetchProductsBySSE(uniqueSSEIds);
1648
- case 55:
1652
+ case 56:
1649
1653
  freshProducts = _context17.sent;
1650
1654
  if (!(freshProducts.length > 0)) {
1651
- _context17.next = 59;
1655
+ _context17.next = 60;
1652
1656
  break;
1653
1657
  }
1654
- _context17.next = 59;
1658
+ _context17.next = 60;
1655
1659
  return this.mergeProductsToStore(freshProducts);
1656
- case 59:
1657
- this.logInfo('processProductSyncMessages: SSE 增量更新完成', {
1660
+ case 60:
1661
+ this.logInfo('processProductSyncMessages: SSE 增量更新完成123', {
1658
1662
  requestedCount: uniqueSSEIds.length,
1659
1663
  receivedCount: freshProducts.length
1660
1664
  });
1661
- case 60:
1665
+ case 61:
1662
1666
  // 收集所有非 delete 的变更 IDs(body + SSE + price),用于增量更新价格缓存
1663
1667
  allChangedIds = _toConsumableArray(new Set([].concat(_toConsumableArray(Array.from(bodyUpdates.keys())), _toConsumableArray(uniqueSSEIds), _toConsumableArray(uniquePriceIds))));
1664
- this.logInfo('processProductSyncMessages: 处理完成', {
1668
+ this.logInfo('processProductSyncMessages: 处理完成123', {
1665
1669
  deleteCount: uniqueDeleteIds.length,
1666
1670
  bodyUpdateCount: bodyUpdates.size,
1667
1671
  sseRefreshCount: uniqueSSEIds.length,
@@ -1671,25 +1675,25 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1671
1675
  });
1672
1676
  hasChanges = uniqueDeleteIds.length > 0 || allChangedIds.length > 0 || shouldClearPriceCache;
1673
1677
  if (hasChanges) {
1674
- _context17.next = 66;
1678
+ _context17.next = 67;
1675
1679
  break;
1676
1680
  }
1677
1681
  this.logInfo('processProductSyncMessages: 没有变更,不触发 onProductsSyncCompleted');
1678
1682
  return _context17.abrupt("return");
1679
- case 66:
1683
+ case 67:
1680
1684
  // 报价单变更 → 清除全量价格缓存,后续走全量重建
1681
1685
  if (shouldClearPriceCache) {
1682
1686
  this.clearPriceCache();
1683
1687
  }
1684
- _context17.next = 69;
1688
+ _context17.next = 70;
1685
1689
  return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, {
1686
1690
  changedIds: allChangedIds
1687
1691
  });
1688
- case 69:
1692
+ case 70:
1689
1693
  case "end":
1690
1694
  return _context17.stop();
1691
1695
  }
1692
- }, _callee17, this, [[11, 37, 40, 43]]);
1696
+ }, _callee17, this, [[11, 38, 41, 44]]);
1693
1697
  }));
1694
1698
  function processProductSyncMessages() {
1695
1699
  return _processProductSyncMessages.apply(this, arguments);
@@ -131,7 +131,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
131
131
  * 获取当前的客户搜索条件
132
132
  * @returns 当前搜索条件
133
133
  */
134
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
134
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
135
135
  /**
136
136
  * 获取客户列表状态(包含滚动加载相关状态)
137
137
  * @returns 客户状态
@@ -9,6 +9,7 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
9
9
  private cacheId;
10
10
  private openCache;
11
11
  private fatherModule;
12
+ private otherParams;
12
13
  constructor(name?: string, version?: string);
13
14
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
14
15
  /**
@@ -46,12 +46,14 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
46
46
  searchParams: {}
47
47
  };
48
48
  this.openCache = false;
49
+ this.otherParams = {};
49
50
  }
50
51
  async initialize(core, options) {
51
52
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
52
53
  this.core = core;
53
54
  this.store = options == null ? void 0 : options.store;
54
55
  this.request = this.core.getPlugin("request");
56
+ this.otherParams = (options == null ? void 0 : options.otherParams) || {};
55
57
  if (Array.isArray((_a = options == null ? void 0 : options.initialState) == null ? void 0 : _a.customerList)) {
56
58
  const customerList = (0, import_lodash_es.cloneDeep)(options.initialState.customerList || []);
57
59
  this.store.customerList = customerList;
@@ -95,9 +97,12 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
95
97
  * @returns API响应数据
96
98
  */
97
99
  async fetchCustomerListData(params = {}) {
98
- var _a, _b;
99
- const url = "/customer/select-list";
100
- const { skip = 1, num = import_constants.DEFAULT_PAGE_SIZE, search, ...otherParams } = params;
100
+ var _a, _b, _c, _d;
101
+ let url = "/customer/select-list";
102
+ if ((_a = this.otherParams) == null ? void 0 : _a.isFranchisee) {
103
+ url = "/franchisee/customer/select-list";
104
+ }
105
+ const { skip = 1, num = import_constants.DEFAULT_PAGE_SIZE, search, ..._otherParams } = params;
101
106
  const queryParams = {
102
107
  skip,
103
108
  num,
@@ -106,7 +111,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
106
111
  search_wallet_flag: 1,
107
112
  search_wallet_pass_flag: 1,
108
113
  ...search && { search },
109
- ...otherParams
114
+ ..._otherParams
110
115
  };
111
116
  const res = await this.request.get(url, queryParams, {
112
117
  cache: {
@@ -117,9 +122,19 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
117
122
  if ((res == null ? void 0 : res.code) !== 200) {
118
123
  throw new Error(res == null ? void 0 : res.message);
119
124
  }
125
+ let _customerList = ((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.list) || [];
126
+ if (((_c = this.otherParams) == null ? void 0 : _c.isFranchisee) && (_customerList == null ? void 0 : _customerList.length) > 0) {
127
+ _customerList = _customerList == null ? void 0 : _customerList.map((item) => {
128
+ return {
129
+ ...item || {},
130
+ is_franchisor_customer: 1
131
+ // 标识是总店的客户
132
+ };
133
+ });
134
+ }
120
135
  return {
121
- customerList: ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || [],
122
- total: ((_b = res == null ? void 0 : res.data) == null ? void 0 : _b.count) || 0,
136
+ customerList: _customerList,
137
+ total: ((_d = res == null ? void 0 : res.data) == null ? void 0 : _d.count) || 0,
123
138
  page: skip,
124
139
  pageSize: num
125
140
  };
@@ -954,6 +954,11 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
954
954
  if ((_c = msg.change_types) == null ? void 0 : _c.includes("price")) {
955
955
  const ids = msg.ids || (msg.id ? [msg.id] : []);
956
956
  priceRefreshIds.push(...ids);
957
+ if (msg.body) {
958
+ const bodyId = msg.body.id;
959
+ if (bodyId)
960
+ bodyUpdates.set(bodyId, msg.body);
961
+ }
957
962
  continue;
958
963
  }
959
964
  if (msg.body) {
@@ -992,7 +997,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
992
997
  if (freshProducts.length > 0) {
993
998
  await this.mergeProductsToStore(freshProducts);
994
999
  }
995
- this.logInfo("processProductSyncMessages: SSE 增量更新完成", {
1000
+ this.logInfo("processProductSyncMessages: SSE 增量更新完成123", {
996
1001
  requestedCount: uniqueSSEIds.length,
997
1002
  receivedCount: freshProducts.length
998
1003
  });
@@ -1002,7 +1007,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
1002
1007
  ...uniqueSSEIds,
1003
1008
  ...uniquePriceIds
1004
1009
  ])];
1005
- this.logInfo("processProductSyncMessages: 处理完成", {
1010
+ this.logInfo("processProductSyncMessages: 处理完成123", {
1006
1011
  deleteCount: uniqueDeleteIds.length,
1007
1012
  bodyUpdateCount: bodyUpdates.size,
1008
1013
  sseRefreshCount: uniqueSSEIds.length,
@@ -131,7 +131,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
131
131
  * 获取当前的客户搜索条件
132
132
  * @returns 当前搜索条件
133
133
  */
134
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
134
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
135
135
  /**
136
136
  * 获取客户列表状态(包含滚动加载相关状态)
137
137
  * @returns 客户状态
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.91",
4
+ "version": "2.2.93",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",