@pisell/pisellos 0.0.213 → 0.0.215

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.
Files changed (80) hide show
  1. package/dist/core/index.js +2 -1
  2. package/dist/effects/index.d.ts +4 -3
  3. package/dist/effects/index.js +15 -6
  4. package/dist/modules/AccountList/index.d.ts +7 -1
  5. package/dist/modules/AccountList/index.js +81 -14
  6. package/dist/modules/AccountList/types.d.ts +28 -0
  7. package/dist/modules/AccountList/types.js +8 -0
  8. package/dist/modules/Customer/constants.d.ts +7 -0
  9. package/dist/modules/Customer/constants.js +12 -0
  10. package/dist/modules/Customer/index.d.ts +89 -0
  11. package/dist/modules/Customer/index.js +439 -0
  12. package/dist/modules/Customer/types.d.ts +130 -0
  13. package/dist/modules/Customer/types.js +39 -0
  14. package/dist/modules/ProductList/index.d.ts +6 -1
  15. package/dist/modules/ProductList/index.js +8 -4
  16. package/dist/modules/Rules/index.js +7 -5
  17. package/dist/modules/Rules/types.d.ts +1 -0
  18. package/dist/modules/Schedule/utils.js +7 -1
  19. package/dist/modules/index.d.ts +1 -0
  20. package/dist/modules/index.js +1 -0
  21. package/dist/plugins/window.d.ts +1 -0
  22. package/dist/solution/BookingByStep/index.js +8 -15
  23. package/dist/solution/BookingTicket/index.d.ts +127 -0
  24. package/dist/solution/BookingTicket/index.js +494 -0
  25. package/dist/solution/BookingTicket/types.d.ts +66 -0
  26. package/dist/solution/BookingTicket/types.js +41 -0
  27. package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
  28. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +147 -0
  29. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +19 -0
  30. package/dist/solution/BookingTicket/utils/scan/handleScan.js +138 -0
  31. package/dist/solution/BookingTicket/utils/scan/index.d.ts +51 -0
  32. package/dist/solution/BookingTicket/utils/scan/index.js +189 -0
  33. package/dist/solution/ShopDiscount/index.js +4 -2
  34. package/dist/solution/index.d.ts +1 -0
  35. package/dist/solution/index.js +1 -0
  36. package/dist/types/index.d.ts +3 -1
  37. package/dist/utils/task.d.ts +31 -0
  38. package/dist/utils/task.js +150 -0
  39. package/dist/utils/watch.d.ts +102 -0
  40. package/dist/utils/watch.js +294 -0
  41. package/lib/core/index.js +1 -1
  42. package/lib/effects/index.d.ts +4 -3
  43. package/lib/effects/index.js +4 -1
  44. package/lib/modules/AccountList/index.d.ts +7 -1
  45. package/lib/modules/AccountList/index.js +27 -0
  46. package/lib/modules/AccountList/types.d.ts +28 -0
  47. package/lib/modules/Customer/constants.d.ts +7 -0
  48. package/lib/modules/Customer/constants.js +39 -0
  49. package/lib/modules/Customer/index.d.ts +89 -0
  50. package/lib/modules/Customer/index.js +304 -0
  51. package/lib/modules/Customer/types.d.ts +130 -0
  52. package/lib/modules/Customer/types.js +35 -0
  53. package/lib/modules/ProductList/index.d.ts +6 -1
  54. package/lib/modules/ProductList/index.js +12 -3
  55. package/lib/modules/Rules/index.js +4 -3
  56. package/lib/modules/Rules/types.d.ts +1 -0
  57. package/lib/modules/Schedule/utils.js +8 -3
  58. package/lib/modules/index.d.ts +1 -0
  59. package/lib/modules/index.js +2 -0
  60. package/lib/plugins/window.d.ts +1 -0
  61. package/lib/solution/BookingByStep/index.js +0 -7
  62. package/lib/solution/BookingTicket/index.d.ts +127 -0
  63. package/lib/solution/BookingTicket/index.js +291 -0
  64. package/lib/solution/BookingTicket/types.d.ts +66 -0
  65. package/lib/solution/BookingTicket/types.js +70 -0
  66. package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
  67. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +97 -0
  68. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +19 -0
  69. package/lib/solution/BookingTicket/utils/scan/handleScan.js +95 -0
  70. package/lib/solution/BookingTicket/utils/scan/index.d.ts +51 -0
  71. package/lib/solution/BookingTicket/utils/scan/index.js +153 -0
  72. package/lib/solution/ShopDiscount/index.js +2 -1
  73. package/lib/solution/index.d.ts +1 -0
  74. package/lib/solution/index.js +2 -0
  75. package/lib/types/index.d.ts +3 -1
  76. package/lib/utils/task.d.ts +31 -0
  77. package/lib/utils/task.js +84 -0
  78. package/lib/utils/watch.d.ts +102 -0
  79. package/lib/utils/watch.js +217 -0
  80. package/package.json +1 -1
@@ -100,11 +100,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
100
100
  key: "loadProducts",
101
101
  value: function () {
102
102
  var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref) {
103
- var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date, cacheId, userPlugin, customer_id, _userPlugin$get, productsData;
103
+ var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$menu_list_ids, menu_list_ids, paramsCustomerId, _ref$with_count, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, userPlugin, customer_id, _userPlugin$get, productsData;
104
104
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
105
105
  while (1) switch (_context3.prev = _context3.next) {
106
106
  case 0:
107
- _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, schedule_date = _ref.schedule_date, cacheId = _ref.cacheId;
107
+ _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$menu_list_ids = _ref.menu_list_ids, menu_list_ids = _ref$menu_list_ids === void 0 ? [] : _ref$menu_list_ids, paramsCustomerId = _ref.customer_id, _ref$with_count = _ref.with_count, with_count = _ref$with_count === void 0 ? [] : _ref$with_count, schedule_datetime = _ref.schedule_datetime, schedule_date = _ref.schedule_date, cacheId = _ref.cacheId, with_schedule = _ref.with_schedule;
108
108
  // // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
109
109
  // if (!schedule_ids?.length) {
110
110
  // const schedule_ids_data = this.store.schedule
@@ -120,7 +120,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
120
120
  userPlugin = this.core.getPlugin('user');
121
121
  customer_id = undefined;
122
122
  try {
123
- customer_id = userPlugin === null || userPlugin === void 0 || (_userPlugin$get = userPlugin.get()) === null || _userPlugin$get === void 0 ? void 0 : _userPlugin$get.id;
123
+ customer_id = paramsCustomerId || (userPlugin === null || userPlugin === void 0 || (_userPlugin$get = userPlugin.get()) === null || _userPlugin$get === void 0 ? void 0 : _userPlugin$get.id);
124
124
  } catch (error) {
125
125
  console.error(error);
126
126
  }
@@ -139,8 +139,12 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
139
139
  ids: product_ids,
140
140
  collection: collection,
141
141
  front_end_cache_id: cacheId,
142
+ menu_list_ids: menu_list_ids,
143
+ with_count: with_count,
142
144
  // client_schedule_ids: schedule_ids,
143
- schedule_date: schedule_date
145
+ schedule_date: schedule_date,
146
+ with_schedule: with_schedule,
147
+ schedule_datetime: schedule_datetime
144
148
  }, {
145
149
  useCache: true
146
150
  });
@@ -28,6 +28,7 @@ import { RulesHooks } from "./types";
28
28
  import { uniqueById } from "../../solution/ShopDiscount/utils";
29
29
  import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils";
30
30
  import Decimal from 'decimal.js';
31
+ import { isBoolean } from 'lodash-es';
31
32
  export var RulesModule = /*#__PURE__*/function (_BaseModule) {
32
33
  _inherits(RulesModule, _BaseModule);
33
34
  var _super = _createSuper(RulesModule);
@@ -330,10 +331,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
330
331
  var applicableDiscounts = sortedDiscountList.filter(function (discount) {
331
332
  var _product$discount_lis6;
332
333
  // 如果商品价格为 0,其实不需要使用任何优惠券,直接 return true
333
- // 商品券时主商品价格为0不可用
334
- if ((Number(product.price) === 0 || !product.price) && (discount.tag || discount.type) === 'good_pass') return false;
335
- // 折扣卡时总价为0时不可用
336
- if ((Number(product.total) === 0 || !product.total) && !((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.find(function (n) {
334
+ // 商品券时主商品价格小于等于0不可用
335
+ if ((Number(product.price) <= 0 || !product.price) && (discount.tag || discount.type) === 'good_pass') return false;
336
+ // 折扣卡时总价小于等于0时不可用
337
+ if ((Number(product.total) <= 0 || !product.total) && !((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.find(function (n) {
337
338
  var _n$discount;
338
339
  return ((_n$discount = n.discount) === null || _n$discount === void 0 ? void 0 : _n$discount.resource_id) === discount.id;
339
340
  })) && (discount.tag || discount.type) !== 'good_pass') return false;
@@ -373,7 +374,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
373
374
  }
374
375
 
375
376
  // 如果没有适用的优惠券,或者手动折扣,则不适用优惠券
376
- if (applicableDiscounts.length === 0 || isManualDiscount) {
377
+ // 自定义商品:如果未开启适用折扣卡(product.vouchersApplicable),则不适用优惠券
378
+ if (applicableDiscounts.length === 0 || isManualDiscount || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
377
379
  if (product.isClient) {
378
380
  processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {} : {
379
381
  origin_total: getProductOriginTotalPrice({
@@ -39,6 +39,7 @@ type ProductDetail = {
39
39
  original_price?: number | string;
40
40
  num?: number;
41
41
  quantity: number;
42
+ vouchersApplicable?: boolean;
42
43
  };
43
44
  export interface RulesParamsHooks {
44
45
  getProduct: (product: Record<string, any>) => ProductDetail;
@@ -140,6 +140,12 @@ var getDaysByRepeatWeek = function getDaysByRepeatWeek(params, isGetRange) {
140
140
  for (var i = 0; i < frequency_date.length; i++) {
141
141
  var item = frequency_date[i];
142
142
  var _start = startTmp.day(item);
143
+
144
+ // 如果计算出的日期早于startTmp,则跳到下一周的相同星期几
145
+ if (_start.isBefore(startTmp, 'day')) {
146
+ _start = _start.add(1, 'week');
147
+ }
148
+
143
149
  // 如果周结束的那一天还超过了deadline,则需要把_end置为deadline
144
150
  var _end = _start.add(scheduleDiff, 'second');
145
151
  if (_end.isAfter(deadline, 'day')) {
@@ -161,7 +167,7 @@ var getDaysByRepeatWeek = function getDaysByRepeatWeek(params, isGetRange) {
161
167
  daysArr.push.apply(daysArr, _toConsumableArray(getDaysByStartEnd(_start, _end)));
162
168
  }
163
169
  }
164
- startTmp = startTmp.day(1).add(frequency, 'week');
170
+ startTmp = startTmp.add(frequency, 'week');
165
171
  }
166
172
  return Array.from(new Set(daysArr));
167
173
  };
@@ -3,6 +3,7 @@ export * from './ProductList';
3
3
  export * from './Cart';
4
4
  export * from './Account';
5
5
  export * from './AccountList';
6
+ export * from './Customer';
6
7
  export * from './Date';
7
8
  export * from './Guests';
8
9
  export * from './Order';
@@ -3,6 +3,7 @@ export * from "./ProductList";
3
3
  export * from "./Cart";
4
4
  export * from "./Account";
5
5
  export * from "./AccountList";
6
+ export * from "./Customer";
6
7
  export * from "./Date";
7
8
  export * from "./Guests";
8
9
  export * from "./Order";
@@ -13,6 +13,7 @@ export interface WindowPlugin extends Plugin {
13
13
  navigator: Partial<Navigator>;
14
14
  document: Partial<Document>;
15
15
  history: History;
16
+ interaction?: any;
16
17
  }
17
18
  /**
18
19
  * 简单的 Storage 接口实现
@@ -1212,21 +1212,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1212
1212
  _this6.store.cart.removeItem(n._id);
1213
1213
  });
1214
1214
  }
1215
- // 如果 date.startTime 和 dateRange 里的 startTime 不一样,需要修正 dateRange
1216
- var dateRange = this.store.date.getDateRange();
1217
- if (dateRange !== null && dateRange !== void 0 && dateRange[0] && !dayjs(dateRange[0].date).isSame(dayjs(date.startTime), 'day')) {
1218
- this.setDateRange([{
1219
- date: dayjs(date.startTime).format('YYYY-MM-DD'),
1220
- status: 'available',
1221
- week: '',
1222
- weekNum: 0
1223
- }, {
1224
- date: dayjs(date.endTime).format('YYYY-MM-DD'),
1225
- status: 'available',
1226
- week: '',
1227
- weekNum: 0
1228
- }]);
1229
- }
1215
+ // // 如果 date.startTime 和 dateRange 里的 startTime 不一样,需要修正 dateRange
1216
+ // const dateRange = this.store.date.getDateRange()
1217
+ // if (dateRange?.[0] && !dayjs(dateRange[0].date).isSame(dayjs(date.startTime), 'day')) {
1218
+ // this.setDateRange([
1219
+ // { date: dayjs(date.startTime).format('YYYY-MM-DD'), status: 'available', week: '', weekNum: 0 },
1220
+ // { date: dayjs(date.endTime).format('YYYY-MM-DD'), status: 'available', week: '', weekNum: 0 },
1221
+ // ]);
1222
+ // }
1230
1223
  }
1231
1224
  }
1232
1225
  }, {
@@ -0,0 +1,127 @@
1
+ import { Module, PisellCore } from '../../types';
2
+ import { BaseModule } from '../../modules/BaseModule';
3
+ import { RequestPlugin, WindowPlugin } from '../../plugins';
4
+ import { IGetCustomerListParams, ICustomer, ILoadProductsParams, IScanResult } from './types';
5
+ import { ProductData } from '../../modules';
6
+ export declare class BookingTicketImpl extends BaseModule implements Module {
7
+ protected defaultName: string;
8
+ protected defaultVersion: string;
9
+ isSolution: boolean;
10
+ request: RequestPlugin;
11
+ window: WindowPlugin;
12
+ private shopStore;
13
+ private store;
14
+ private otherParams;
15
+ private cacheId;
16
+ private platform;
17
+ private scan;
18
+ initialize(core: PisellCore, options: any): Promise<void>;
19
+ /**
20
+ * 获取商品列表
21
+ * @param params 包含 schedule_date 的参数
22
+ * @returns 商品列表
23
+ */
24
+ loadProducts(params?: ILoadProductsParams): Promise<any>;
25
+ /**
26
+ * 获取商品列表(不加载到模块中)
27
+ * @returns 商品列表
28
+ */
29
+ getProducts(): Promise<ProductData[]>;
30
+ /**
31
+ * 获取客户列表
32
+ * @param params 查询参数
33
+ * @returns 客户列表响应
34
+ */
35
+ getCustomerList(params?: IGetCustomerListParams): Promise<import("../../modules").ICustomerListResponse>;
36
+ /**
37
+ * 设置活跃客户
38
+ * @param customer 客户信息
39
+ */
40
+ setActiveCustomer(customer: ICustomer): void;
41
+ /**
42
+ * 获取当前活跃客户
43
+ * @returns 当前活跃客户
44
+ */
45
+ getActiveCustomer(): ICustomer | null;
46
+ /**
47
+ * 根据ID设置选中的客户
48
+ * @param customerId 客户ID
49
+ */
50
+ setSelectedCustomerById(customerId: string | number): void;
51
+ /**
52
+ * 获取所有客户
53
+ * @returns 客户列表
54
+ */
55
+ getCustomers(): ICustomer[];
56
+ /**
57
+ * 根据ID获取客户
58
+ * @param customerId 客户ID
59
+ * @returns 客户信息
60
+ */
61
+ getCustomerById(customerId: string | number): ICustomer | null;
62
+ /**
63
+ * 清空客户列表
64
+ */
65
+ clearCustomers(): void;
66
+ /**
67
+ * 添加客户到列表第一位
68
+ * @param customer 要添加的客户信息
69
+ */
70
+ addCustomerToFirst(customer: ICustomer): void;
71
+ /**
72
+ * 获取客户分页信息
73
+ * @returns 分页信息
74
+ */
75
+ getCustomerPaginationInfo(): import("../../modules").IPaginationInfo;
76
+ /**
77
+ * 获取客户列表总数
78
+ * @returns 总数
79
+ */
80
+ getCustomerTotal(): number;
81
+ /**
82
+ * 设置客户分页信息
83
+ * @param page 页码
84
+ * @param pageSize 每页数量
85
+ */
86
+ setCustomerPaginationInfo(page: number, pageSize: number): void;
87
+ /**
88
+ * 便捷方法:切换客户分页并自动获取数据
89
+ * @param page 页码
90
+ * @param pageSize 每页数量(可选)
91
+ * @returns 客户列表响应
92
+ */
93
+ changeCustomerPage(page: number, pageSize?: number): Promise<import("../../modules").ICustomerListResponse>;
94
+ /**
95
+ * 全局扫描监听
96
+ * @param callback 回调
97
+ */
98
+ scanGlobalListener(callback: (data: IScanResult) => void): {
99
+ remove: () => void;
100
+ };
101
+ /**
102
+ * 客户扫描监听
103
+ * @param callback 回调
104
+ */
105
+ scanCustomerListener(callback: (data: IScanResult) => void): {
106
+ remove: () => void;
107
+ };
108
+ /**
109
+ * 设置其他参数
110
+ * @param params 参数
111
+ * @param options 选项
112
+ */
113
+ setOtherParams(params: Record<string, any>, { cover }?: {
114
+ cover?: boolean;
115
+ }): Promise<void>;
116
+ /**
117
+ * 获取其他参数
118
+ * @returns 其他参数
119
+ */
120
+ getOtherParams(): Promise<Record<string, any>>;
121
+ /**
122
+ * 销毁模块
123
+ */
124
+ destroy(): void;
125
+ }
126
+ export * from './types';
127
+ export { BookingTicketImpl as BookingTicket };