@pisell/pisellos 0.0.475 → 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) {
@@ -1766,7 +1766,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1766
1766
  processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
1767
1767
  total: _targetProductTotal,
1768
1768
  price: new Decimal(_productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
1769
- discount_list: [_discountDetail2],
1769
+ discount_list: _this3.filterDiscountListByType(flatItem.discount_list, 'promotion').concat([_discountDetail2]),
1770
1770
  processed: true
1771
1771
  }));
1772
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 客户状态
@@ -0,0 +1,49 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/model/strategy/adapter/promotion/index.ts
30
+ var promotion_exports = {};
31
+ __export(promotion_exports, {
32
+ BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
+ PromotionAdapter: () => import_adapter.PromotionAdapter,
34
+ PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
+ X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
+ default: () => import_adapter2.default
37
+ });
38
+ module.exports = __toCommonJS(promotion_exports);
39
+ var import_evaluator = require("./evaluator");
40
+ var import_adapter = require("./adapter");
41
+ var import_adapter2 = __toESM(require("./adapter"));
42
+ var import_examples = require("./examples");
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ BUY_X_GET_Y_FREE_STRATEGY,
46
+ PromotionAdapter,
47
+ PromotionEvaluator,
48
+ X_ITEMS_FOR_Y_PRICE_STRATEGY
49
+ });
@@ -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,
@@ -1391,7 +1391,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1391
1391
  ...flatItem,
1392
1392
  total: targetProductTotal,
1393
1393
  price: new import_decimal.default(productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
1394
- discount_list: [discountDetail],
1394
+ discount_list: this.filterDiscountListByType(flatItem.discount_list, "promotion").concat([discountDetail]),
1395
1395
  processed: true
1396
1396
  });
1397
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.475",
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",