@pisell/pisellos 0.0.214 → 0.0.216
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.
- package/dist/core/index.js +2 -1
- package/dist/effects/index.d.ts +4 -3
- package/dist/effects/index.js +15 -6
- package/dist/modules/AccountList/index.d.ts +7 -1
- package/dist/modules/AccountList/index.js +81 -14
- package/dist/modules/AccountList/types.d.ts +28 -0
- package/dist/modules/AccountList/types.js +8 -0
- package/dist/modules/Customer/constants.d.ts +7 -0
- package/dist/modules/Customer/constants.js +12 -0
- package/dist/modules/Customer/index.d.ts +89 -0
- package/dist/modules/Customer/index.js +440 -0
- package/dist/modules/Customer/types.d.ts +130 -0
- package/dist/modules/Customer/types.js +39 -0
- package/dist/modules/ProductList/index.d.ts +12 -1
- package/dist/modules/ProductList/index.js +28 -4
- package/dist/modules/Rules/index.js +7 -5
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/plugins/window.d.ts +1 -0
- package/dist/solution/BookingByStep/index.js +8 -15
- package/dist/solution/BookingTicket/index.d.ts +134 -0
- package/dist/solution/BookingTicket/index.js +534 -0
- package/dist/solution/BookingTicket/types.d.ts +66 -0
- package/dist/solution/BookingTicket/types.js +41 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +159 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +19 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +182 -0
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +59 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +201 -0
- package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/dist/solution/BookingTicket/utils/scan/scanCache.js +305 -0
- package/dist/solution/ShopDiscount/index.js +4 -2
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +1 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/utils/task.d.ts +31 -0
- package/dist/utils/task.js +150 -0
- package/dist/utils/watch.d.ts +102 -0
- package/dist/utils/watch.js +294 -0
- package/lib/core/index.js +1 -1
- package/lib/effects/index.d.ts +4 -3
- package/lib/effects/index.js +4 -1
- package/lib/modules/AccountList/index.d.ts +7 -1
- package/lib/modules/AccountList/index.js +27 -0
- package/lib/modules/AccountList/types.d.ts +28 -0
- package/lib/modules/Customer/constants.d.ts +7 -0
- package/lib/modules/Customer/constants.js +39 -0
- package/lib/modules/Customer/index.d.ts +89 -0
- package/lib/modules/Customer/index.js +305 -0
- package/lib/modules/Customer/types.d.ts +130 -0
- package/lib/modules/Customer/types.js +35 -0
- package/lib/modules/ProductList/index.d.ts +12 -1
- package/lib/modules/ProductList/index.js +30 -3
- package/lib/modules/Rules/index.js +4 -3
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +2 -0
- package/lib/plugins/window.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +0 -7
- package/lib/solution/BookingTicket/index.d.ts +134 -0
- package/lib/solution/BookingTicket/index.js +331 -0
- package/lib/solution/BookingTicket/types.d.ts +66 -0
- package/lib/solution/BookingTicket/types.js +70 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +117 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +19 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +137 -0
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +59 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +149 -0
- package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +231 -0
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +2 -0
- package/lib/types/index.d.ts +3 -1
- package/lib/utils/task.d.ts +31 -0
- package/lib/utils/task.js +84 -0
- package/lib/utils/watch.d.ts +102 -0
- package/lib/utils/watch.js +217 -0
- 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
|
});
|
|
@@ -297,6 +301,26 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
297
301
|
}
|
|
298
302
|
return selectProducts;
|
|
299
303
|
}()
|
|
304
|
+
/**
|
|
305
|
+
* 根据商品编码或条码搜索商品
|
|
306
|
+
* @param code 商品编码或条码
|
|
307
|
+
* @returns 匹配的商品列表,如果没有匹配则返回空数组
|
|
308
|
+
*/
|
|
309
|
+
}, {
|
|
310
|
+
key: "findProductsByCodeOrBarcode",
|
|
311
|
+
value: function findProductsByCodeOrBarcode(code) {
|
|
312
|
+
if (!code || typeof code !== 'string') {
|
|
313
|
+
return [];
|
|
314
|
+
}
|
|
315
|
+
var trimmedCode = code.trim();
|
|
316
|
+
if (!trimmedCode) {
|
|
317
|
+
return [];
|
|
318
|
+
}
|
|
319
|
+
var matchingProducts = this.store.list.filter(function (product) {
|
|
320
|
+
return product.code && product.code.trim() === trimmedCode || product.barcode && product.barcode.trim() === trimmedCode;
|
|
321
|
+
});
|
|
322
|
+
return cloneDeep(matchingProducts);
|
|
323
|
+
}
|
|
300
324
|
}]);
|
|
301
325
|
return ProductList;
|
|
302
326
|
}(BaseModule);
|
|
@@ -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
|
-
//
|
|
334
|
-
if ((Number(product.price)
|
|
335
|
-
//
|
|
336
|
-
if ((Number(product.total)
|
|
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
|
-
|
|
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({
|
package/dist/modules/index.d.ts
CHANGED
package/dist/modules/index.js
CHANGED
package/dist/plugins/window.d.ts
CHANGED
|
@@ -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
|
-
|
|
1217
|
-
if (dateRange
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
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,134 @@
|
|
|
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 data 用户自定义数据
|
|
111
|
+
*/
|
|
112
|
+
activateCamera(data?: {
|
|
113
|
+
[key: string]: any;
|
|
114
|
+
}): void;
|
|
115
|
+
/**
|
|
116
|
+
* 设置其他参数
|
|
117
|
+
* @param params 参数
|
|
118
|
+
* @param options 选项
|
|
119
|
+
*/
|
|
120
|
+
setOtherParams(params: Record<string, any>, { cover }?: {
|
|
121
|
+
cover?: boolean;
|
|
122
|
+
}): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* 获取其他参数
|
|
125
|
+
* @returns 其他参数
|
|
126
|
+
*/
|
|
127
|
+
getOtherParams(): Promise<Record<string, any>>;
|
|
128
|
+
/**
|
|
129
|
+
* 销毁模块
|
|
130
|
+
*/
|
|
131
|
+
destroy(): void;
|
|
132
|
+
}
|
|
133
|
+
export * from './types';
|
|
134
|
+
export { BookingTicketImpl as BookingTicket };
|