@pisell/pisellos 0.0.474 → 0.0.476

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: "indexDB"
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
  }
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -31,8 +31,8 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
31
31
  productList: any[];
32
32
  unavailableReason?: UnavailableReason;
33
33
  };
34
- private getUnavailableReason;
35
34
  filterDiscountListByType(discountList: Discount[], type: string): Discount[];
35
+ private getUnavailableReason;
36
36
  calcDiscount({ discountList, productList, orderTotalAmount, holders, isFormSubject, }: {
37
37
  discountList: Discount[];
38
38
  productList: any[];
@@ -212,6 +212,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
212
212
  unavailableReason: unavailableReason
213
213
  };
214
214
  }
215
+ }, {
216
+ key: "filterDiscountListByType",
217
+ value: function filterDiscountListByType(discountList, type) {
218
+ return (discountList || []).filter(function (item) {
219
+ return item.type === type || item.tag === type;
220
+ });
221
+ }
215
222
 
216
223
  // 获取券不可用的原因
217
224
  }, {
@@ -286,13 +293,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
286
293
  }
287
294
  return UnavailableReason.Unknown;
288
295
  }
289
- }, {
290
- key: "filterDiscountListByType",
291
- value: function filterDiscountListByType(discountList, type) {
292
- return (discountList || []).filter(function (item) {
293
- return item.type === type || item.tag === type;
294
- });
295
- }
296
296
  }, {
297
297
  key: "calcDiscount",
298
298
  value: function calcDiscount(_ref2, options) {
@@ -1178,18 +1178,21 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1178
1178
  discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
1179
1179
  }))]);
1180
1180
  } else {
1181
- var _product$price2, _ref8, _product$_promotion$f, _product13;
1181
+ var _ref8, _product$_promotion$f, _product13, _product$origin_total, _product$price2;
1182
+ var total = product.inPromotion ? (_ref8 = (_product$_promotion$f = (_product13 = product) === null || _product13 === void 0 || (_product13 = _product13._promotion) === null || _product13 === void 0 ? void 0 : _product13.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref8 !== void 0 ? _ref8 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
1182
1183
  var main_product_selling_price = (_product$price2 = product.price) !== null && _product$price2 !== void 0 ? _product$price2 : product.main_product_selling_price;
1183
- if (product.booking_id) {
1184
- var _product$main_product;
1185
- main_product_selling_price = (_product$main_product = product.main_product_selling_price) !== null && _product$main_product !== void 0 ? _product$main_product : product.price;
1184
+ if ((product.discount_list || []).some(function (item) {
1185
+ return item.type === 'promotion';
1186
+ }) || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
1187
+ var _product$total, _product$main_product;
1188
+ total = (_product$total = product.total) !== null && _product$total !== void 0 ? _product$total : product.origin_total;
1189
+ main_product_selling_price = (_product$main_product = product.main_product_selling_price) !== null && _product$main_product !== void 0 ? _product$main_product : main_product_selling_price;
1186
1190
  }
1187
1191
  processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
1188
- price: product.price,
1189
- main_product_selling_price: main_product_selling_price
1192
+ price: product.price
1190
1193
  } : {
1191
1194
  _id: product._id.split('___')[0] + '___' + index,
1192
- total: product.inPromotion ? (_ref8 = (_product$_promotion$f = (_product13 = product) === null || _product13 === void 0 || (_product13 = _product13._promotion) === null || _product13 === void 0 ? void 0 : _product13.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref8 !== void 0 ? _ref8 : product.total : product.origin_total || product.total,
1195
+ total: total,
1193
1196
  price: product.price,
1194
1197
  main_product_selling_price: main_product_selling_price
1195
1198
  }), {}, {
@@ -1339,13 +1342,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1339
1342
  };
1340
1343
  appliedProducts.push(discountDetail);
1341
1344
  appliedDiscountProducts.set(currentSelectedDiscount.id, appliedProducts);
1342
- var total = targetProductTotal;
1345
+ var _total = targetProductTotal;
1343
1346
  if (product.options) {
1344
- total = product.options.reduce(function (accumulator, currentValue) {
1347
+ _total = product.options.reduce(function (accumulator, currentValue) {
1345
1348
  var currentPrice = new Decimal(currentValue.price || 0);
1346
1349
  var currentNum = new Decimal(currentValue.num || 0);
1347
1350
  return accumulator.add(currentPrice.mul(currentNum));
1348
- }, new Decimal(total)).toNumber();
1351
+ }, new Decimal(_total)).toNumber();
1349
1352
  }
1350
1353
 
1351
1354
  // 记录应用了优惠券的商品
@@ -1763,7 +1766,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1763
1766
  processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
1764
1767
  total: _targetProductTotal,
1765
1768
  price: new Decimal(_productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
1766
- discount_list: [_discountDetail2],
1769
+ discount_list: _this3.filterDiscountListByType(flatItem.discount_list, 'promotion').concat([_discountDetail2]),
1767
1770
  processed: true
1768
1771
  }));
1769
1772
  }
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
314
+ weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
123
123
  * 获取当前的客户搜索条件
124
124
  * @returns 当前搜索条件
125
125
  */
126
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
126
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
127
127
  /**
128
128
  * 获取客户列表状态(包含滚动加载相关状态)
129
129
  * @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
  };
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -31,8 +31,8 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
31
31
  productList: any[];
32
32
  unavailableReason?: UnavailableReason;
33
33
  };
34
- private getUnavailableReason;
35
34
  filterDiscountListByType(discountList: Discount[], type: string): Discount[];
35
+ private getUnavailableReason;
36
36
  calcDiscount({ discountList, productList, orderTotalAmount, holders, isFormSubject, }: {
37
37
  discountList: Discount[];
38
38
  productList: any[];
@@ -154,6 +154,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
154
154
  unavailableReason
155
155
  };
156
156
  }
157
+ filterDiscountListByType(discountList, type) {
158
+ return (discountList || []).filter((item) => item.type === type || item.tag === type);
159
+ }
157
160
  // 获取券不可用的原因
158
161
  getUnavailableReason(discountList, productList) {
159
162
  var _a;
@@ -186,9 +189,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
186
189
  }
187
190
  return import_types.UnavailableReason.Unknown;
188
191
  }
189
- filterDiscountListByType(discountList, type) {
190
- return (discountList || []).filter((item) => item.type === type || item.tag === type);
191
- }
192
192
  calcDiscount({
193
193
  discountList,
194
194
  productList,
@@ -869,18 +869,19 @@ var RulesModule = class extends import_BaseModule.BaseModule {
869
869
  })
870
870
  ]);
871
871
  } else {
872
+ let total = product.inPromotion ? ((_u = product == null ? void 0 : product._promotion) == null ? void 0 : _u.finalPrice) ?? product.origin_total ?? product.total : product.origin_total ?? product.total;
872
873
  let main_product_selling_price = product.price ?? product.main_product_selling_price;
873
- if (product.booking_id) {
874
- main_product_selling_price = product.main_product_selling_price ?? product.price;
874
+ if ((product.discount_list || []).some((item) => item.type === "promotion") || (0, import_lodash_es.isBoolean)(product.vouchersApplicable) && !product.vouchersApplicable) {
875
+ total = product.total ?? product.origin_total;
876
+ main_product_selling_price = product.main_product_selling_price ?? main_product_selling_price;
875
877
  }
876
878
  processedProductsMap.set(product._id, [
877
879
  this.hooks.setProduct(originProduct, {
878
880
  ...isManualDiscount ? {
879
- price: product.price,
880
- main_product_selling_price
881
+ price: product.price
881
882
  } : {
882
883
  _id: product._id.split("___")[0] + "___" + index,
883
- total: product.inPromotion ? ((_u = product == null ? void 0 : product._promotion) == null ? void 0 : _u.finalPrice) ?? product.origin_total ?? product.total : product.origin_total || product.total,
884
+ total,
884
885
  price: product.price,
885
886
  main_product_selling_price
886
887
  },
@@ -1390,7 +1391,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1390
1391
  ...flatItem,
1391
1392
  total: targetProductTotal,
1392
1393
  price: new import_decimal.default(productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
1393
- discount_list: [discountDetail],
1394
+ discount_list: this.filterDiscountListByType(flatItem.discount_list, "promotion").concat([discountDetail]),
1394
1395
  processed: true
1395
1396
  });
1396
1397
  }
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
314
+ weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
123
123
  * 获取当前的客户搜索条件
124
124
  * @returns 当前搜索条件
125
125
  */
126
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
126
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
127
127
  /**
128
128
  * 获取客户列表状态(包含滚动加载相关状态)
129
129
  * @returns 客户状态
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.474",
4
+ "version": "0.0.476",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -23,7 +23,8 @@
23
23
  "docs": "typedoc --out docs src/index.ts",
24
24
  "sync": "node sync.js",
25
25
  "prepublishOnly": "npm run build",
26
- "deploy": "npm run build && npm run changeset && npm run version && npm run release"
26
+ "deploy": "npm run build && npm run changeset && npm run version && npm run release",
27
+ "deploy:ci": "npm run build && npm run version && changeset publish --registry=https://registry.npmjs.com/ && npm run sync"
27
28
  },
28
29
  "repository": {
29
30
  "type": "git",