@pisell/pisellos 2.1.53 → 2.1.58

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.
@@ -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
  }
@@ -13,24 +13,26 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
13
13
  setRulesList(rulesList: Rules[]): Promise<void>;
14
14
  getRulesList(): Rules[];
15
15
  private checkHolderMatch;
16
- isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, holders, }: {
16
+ isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, holders, isFormSubject, }: {
17
17
  oldDiscountList: Discount[];
18
18
  newDiscountList: Discount[];
19
19
  productList: any[];
20
20
  holders: {
21
21
  form_record_id: number;
22
22
  }[];
23
+ isFormSubject: boolean;
23
24
  }): {
24
25
  isAvailable: boolean;
25
26
  discountList: Discount[];
26
27
  productList: any[];
27
28
  };
28
- calcDiscount({ discountList, productList, holders, }: {
29
+ calcDiscount({ discountList, productList, holders, isFormSubject, }: {
29
30
  discountList: Discount[];
30
31
  productList: any[];
31
32
  holders: {
32
33
  form_record_id: number;
33
34
  }[];
35
+ isFormSubject: boolean;
34
36
  }, options?: {
35
37
  isSelected?: boolean;
36
38
  discountId?: number;
@@ -121,7 +121,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
121
121
  var oldDiscountList = _ref.oldDiscountList,
122
122
  newDiscountList = _ref.newDiscountList,
123
123
  productList = _ref.productList,
124
- holders = _ref.holders;
124
+ holders = _ref.holders,
125
+ isFormSubject = _ref.isFormSubject;
125
126
  // 首先检查是否有新的优惠券可应用
126
127
  if (!newDiscountList || newDiscountList.length === 0) {
127
128
  return {
@@ -152,7 +153,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
152
153
  var result = this.calcDiscount({
153
154
  discountList: mergedDiscountList,
154
155
  productList: _toConsumableArray(productList),
155
- holders: holders
156
+ holders: holders,
157
+ isFormSubject: isFormSubject
156
158
  }, {
157
159
  scan: true
158
160
  });
@@ -195,7 +197,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
195
197
  var _this3 = this;
196
198
  var discountList = _ref2.discountList,
197
199
  productList = _ref2.productList,
198
- holders = _ref2.holders;
200
+ holders = _ref2.holders,
201
+ isFormSubject = _ref2.isFormSubject;
199
202
  // 识别出来是不是在编辑的界面里又新增了商品
200
203
  // 这种情况下,如果有可用的优惠券,也会自动勾选上
201
204
  var isEditModeAddNewProduct = productList.find(function (n) {
@@ -436,7 +439,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
436
439
  // 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
437
440
  var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
438
441
  var isHolderMatch = _this3.checkHolderMatch(discount, {
439
- isNeedHolder: _tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.isNeedHolder,
442
+ isNeedHolder: isFormSubject && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
440
443
  holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
441
444
  }, holders);
442
445
  var timeLimit = true;
@@ -555,7 +558,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
555
558
  // 拿到discount配置的holder信息 product信息 product.holder 不可用return false
556
559
  var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
557
560
  var isHolderMatch = _this3.checkHolderMatch(discount, {
558
- isNeedHolder: _tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.isNeedHolder,
561
+ isNeedHolder: isFormSubject && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
559
562
  holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
560
563
  }, holders);
561
564
  // 如果 holder 不匹配,则不适用
@@ -25,6 +25,7 @@ export interface RulesModuleAPI {
25
25
  holders: {
26
26
  form_record_id: number;
27
27
  }[];
28
+ isFormSubject: boolean;
28
29
  }) => DiscountResult;
29
30
  }
30
31
  type ProductDetail = {
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
342
342
  };
343
343
  setOtherData(key: string, value: any): void;
344
344
  getOtherData(key: string): any;
345
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
345
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
346
346
  /**
347
347
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
348
348
  *
@@ -115,7 +115,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
115
115
  * 获取当前的客户搜索条件
116
116
  * @returns 当前搜索条件
117
117
  */
118
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
118
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
119
119
  /**
120
120
  * 获取客户列表状态(包含滚动加载相关状态)
121
121
  * @returns 客户状态
@@ -24,6 +24,10 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
24
24
  setHolders(holders: {
25
25
  form_record_id: number;
26
26
  }[]): void;
27
+ setBookingSubject(bookingSubject: {
28
+ type?: 'form' | 'customer';
29
+ [key: string]: any;
30
+ }): void;
27
31
  calcDiscount(productList: Record<string, any>[], options?: SetDiscountSelectedParams): {
28
32
  productList: Record<string, any>[];
29
33
  discountList: Discount[];
@@ -54,7 +54,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
54
54
  holders: [],
55
55
  originalDiscountList: [],
56
56
  currentBookingTime: "",
57
- filteredDiscountList: []
57
+ filteredDiscountList: [],
58
+ bookingSubject: undefined
58
59
  };
59
60
  return _this;
60
61
  }
@@ -292,11 +293,17 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
292
293
  value: function setHolders(holders) {
293
294
  this.store.holders = holders;
294
295
  }
296
+ }, {
297
+ key: "setBookingSubject",
298
+ value: function setBookingSubject(bookingSubject) {
299
+ this.store.bookingSubject = bookingSubject;
300
+ }
295
301
 
296
302
  // 计算优惠券
297
303
  }, {
298
304
  key: "calcDiscount",
299
305
  value: function calcDiscount(productList, options) {
306
+ var _this$store$bookingSu;
300
307
  this.store.productList = productList;
301
308
  var rulesModule = this.core.getModule("".concat(this.name, "_rules"));
302
309
  if (!rulesModule) {
@@ -308,7 +315,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
308
315
  var _ref = rulesModule.calcDiscount({
309
316
  productList: productList,
310
317
  discountList: this.getDiscountList(),
311
- holders: this.store.holders || []
318
+ holders: this.store.holders || [],
319
+ isFormSubject: ((_this$store$bookingSu = this.store.bookingSubject) === null || _this$store$bookingSu === void 0 ? void 0 : _this$store$bookingSu.type) === 'form'
312
320
  }, options) || {
313
321
  productList: productList,
314
322
  discountList: this.getDiscountList()
@@ -381,7 +389,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
381
389
  key: "scanCode",
382
390
  value: function () {
383
391
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
384
- var _this$store$discount3, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
392
+ var _this$store$discount3, _this$store$bookingSu2, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
385
393
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
386
394
  while (1) switch (_context5.prev = _context5.next) {
387
395
  case 0:
@@ -447,7 +455,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
447
455
  productList: this.store.productList || [],
448
456
  oldDiscountList: this.getDiscountList(),
449
457
  newDiscountList: withScanList,
450
- holders: this.store.holders || []
458
+ holders: this.store.holders || [],
459
+ isFormSubject: ((_this$store$bookingSu2 = this.store.bookingSubject) === null || _this$store$bookingSu2 === void 0 ? void 0 : _this$store$bookingSu2.type) === 'form'
451
460
  }) || {
452
461
  isAvailable: false,
453
462
  productList: this.store.productList || [],
@@ -31,6 +31,10 @@ export interface ShopDiscountState {
31
31
  originalDiscountList: Discount[];
32
32
  currentBookingTime: string | null;
33
33
  filteredDiscountList: Discount[];
34
+ bookingSubject?: {
35
+ type?: 'form' | 'customer';
36
+ [key: string]: any;
37
+ };
34
38
  }
35
39
  export interface SetDiscountSelectedParams {
36
40
  discountId: number;
@@ -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
  }
@@ -13,24 +13,26 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
13
13
  setRulesList(rulesList: Rules[]): Promise<void>;
14
14
  getRulesList(): Rules[];
15
15
  private checkHolderMatch;
16
- isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, holders, }: {
16
+ isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, holders, isFormSubject, }: {
17
17
  oldDiscountList: Discount[];
18
18
  newDiscountList: Discount[];
19
19
  productList: any[];
20
20
  holders: {
21
21
  form_record_id: number;
22
22
  }[];
23
+ isFormSubject: boolean;
23
24
  }): {
24
25
  isAvailable: boolean;
25
26
  discountList: Discount[];
26
27
  productList: any[];
27
28
  };
28
- calcDiscount({ discountList, productList, holders, }: {
29
+ calcDiscount({ discountList, productList, holders, isFormSubject, }: {
29
30
  discountList: Discount[];
30
31
  productList: any[];
31
32
  holders: {
32
33
  form_record_id: number;
33
34
  }[];
35
+ isFormSubject: boolean;
34
36
  }, options?: {
35
37
  isSelected?: boolean;
36
38
  discountId?: number;
@@ -75,7 +75,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
75
75
  oldDiscountList,
76
76
  newDiscountList,
77
77
  productList,
78
- holders
78
+ holders,
79
+ isFormSubject
79
80
  }) {
80
81
  if (!newDiscountList || newDiscountList.length === 0) {
81
82
  return {
@@ -103,7 +104,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
103
104
  const result = this.calcDiscount({
104
105
  discountList: mergedDiscountList,
105
106
  productList: [...productList],
106
- holders
107
+ holders,
108
+ isFormSubject
107
109
  }, {
108
110
  scan: true
109
111
  });
@@ -136,7 +138,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
136
138
  calcDiscount({
137
139
  discountList,
138
140
  productList,
139
- holders
141
+ holders,
142
+ isFormSubject
140
143
  }, options) {
141
144
  const isEditModeAddNewProduct = productList.find((n) => n.booking_id) && productList.find((n) => !n.booking_id);
142
145
  const editModeDiscount = [];
@@ -291,7 +294,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
291
294
  const isHolderMatch = this.checkHolderMatch(
292
295
  discount,
293
296
  {
294
- isNeedHolder: _tempVar == null ? void 0 : _tempVar.isNeedHolder,
297
+ isNeedHolder: isFormSubject && !(_tempVar == null ? void 0 : _tempVar.isNormalProduct),
295
298
  holder_id: (_tempVar == null ? void 0 : _tempVar.holder_id) || product.holder_id
296
299
  },
297
300
  holders
@@ -382,7 +385,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
382
385
  const isHolderMatch = this.checkHolderMatch(
383
386
  discount,
384
387
  {
385
- isNeedHolder: _tempVar == null ? void 0 : _tempVar.isNeedHolder,
388
+ isNeedHolder: isFormSubject && !(_tempVar == null ? void 0 : _tempVar.isNormalProduct),
386
389
  holder_id: (_tempVar == null ? void 0 : _tempVar.holder_id) || product.holder_id
387
390
  },
388
391
  holders
@@ -25,6 +25,7 @@ export interface RulesModuleAPI {
25
25
  holders: {
26
26
  form_record_id: number;
27
27
  }[];
28
+ isFormSubject: boolean;
28
29
  }) => DiscountResult;
29
30
  }
30
31
  type ProductDetail = {
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
342
342
  };
343
343
  setOtherData(key: string, value: any): void;
344
344
  getOtherData(key: string): any;
345
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
345
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
346
346
  /**
347
347
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
348
348
  *
@@ -115,7 +115,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
115
115
  * 获取当前的客户搜索条件
116
116
  * @returns 当前搜索条件
117
117
  */
118
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
118
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
119
119
  /**
120
120
  * 获取客户列表状态(包含滚动加载相关状态)
121
121
  * @returns 客户状态
@@ -122,6 +122,12 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
122
122
  throw error;
123
123
  }
124
124
  }
125
+ /**
126
+ * 初始化外设扫码结果监听
127
+ */
128
+ initPeripheralsListener() {
129
+ this.scan.initPeripheralsListener();
130
+ }
125
131
  /**
126
132
  * 获取商品列表(不加载到模块中)
127
133
  * @returns 商品列表
@@ -24,6 +24,10 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
24
24
  setHolders(holders: {
25
25
  form_record_id: number;
26
26
  }[]): void;
27
+ setBookingSubject(bookingSubject: {
28
+ type?: 'form' | 'customer';
29
+ [key: string]: any;
30
+ }): void;
27
31
  calcDiscount(productList: Record<string, any>[], options?: SetDiscountSelectedParams): {
28
32
  productList: Record<string, any>[];
29
33
  discountList: Discount[];
@@ -54,7 +54,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
54
54
  holders: [],
55
55
  originalDiscountList: [],
56
56
  currentBookingTime: "",
57
- filteredDiscountList: []
57
+ filteredDiscountList: [],
58
+ bookingSubject: void 0
58
59
  };
59
60
  }
60
61
  // =========== 生命周期方法 ===========
@@ -196,8 +197,12 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
196
197
  setHolders(holders) {
197
198
  this.store.holders = holders;
198
199
  }
200
+ setBookingSubject(bookingSubject) {
201
+ this.store.bookingSubject = bookingSubject;
202
+ }
199
203
  // 计算优惠券
200
204
  calcDiscount(productList, options) {
205
+ var _a;
201
206
  this.store.productList = productList;
202
207
  const rulesModule = this.core.getModule(`${this.name}_rules`);
203
208
  if (!rulesModule) {
@@ -207,7 +212,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
207
212
  {
208
213
  productList,
209
214
  discountList: this.getDiscountList(),
210
- holders: this.store.holders || []
215
+ holders: this.store.holders || [],
216
+ isFormSubject: ((_a = this.store.bookingSubject) == null ? void 0 : _a.type) === "form"
211
217
  },
212
218
  options
213
219
  ) || { productList, discountList: this.getDiscountList() };
@@ -254,7 +260,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
254
260
  }
255
261
  // 扫码输入code
256
262
  async scanCode(code, customerId) {
257
- var _a, _b;
263
+ var _a, _b, _c;
258
264
  try {
259
265
  const resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, customerId)) || [];
260
266
  const rulesModule = this.store.rules;
@@ -297,7 +303,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
297
303
  productList: this.store.productList || [],
298
304
  oldDiscountList: this.getDiscountList(),
299
305
  newDiscountList: withScanList,
300
- holders: this.store.holders || []
306
+ holders: this.store.holders || [],
307
+ isFormSubject: ((_b = this.store.bookingSubject) == null ? void 0 : _b.type) === "form"
301
308
  }) || {
302
309
  isAvailable: false,
303
310
  productList: this.store.productList || [],
@@ -307,7 +314,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
307
314
  this.setDiscountList(newDiscountList || []);
308
315
  this.store.originalDiscountList = newDiscountList || [];
309
316
  this.setProductList(newProductList || []);
310
- if (this.isWalkIn() && resultDiscountList.length && ((_b = this.options.otherParams) == null ? void 0 : _b.platform) === "shop") {
317
+ if (this.isWalkIn() && resultDiscountList.length && ((_c = this.options.otherParams) == null ? void 0 : _c.platform) === "shop") {
311
318
  await this.getCustomerWallet(
312
319
  resultDiscountList[0].customer_id
313
320
  );
@@ -31,6 +31,10 @@ export interface ShopDiscountState {
31
31
  originalDiscountList: Discount[];
32
32
  currentBookingTime: string | null;
33
33
  filteredDiscountList: Discount[];
34
+ bookingSubject?: {
35
+ type?: 'form' | 'customer';
36
+ [key: string]: any;
37
+ };
34
38
  }
35
39
  export interface SetDiscountSelectedParams {
36
40
  discountId: number;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.53",
4
+ "version": "2.1.58",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",