@pisell/pisellos 2.2.169 → 2.2.171
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/modules/Customer/index.d.ts +0 -6
- package/dist/modules/Customer/index.js +83 -129
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.d.ts +4 -2
- package/dist/modules/Discount/index.js +93 -8
- package/dist/modules/Discount/types.d.ts +7 -1
- package/dist/modules/Order/index.d.ts +16 -28
- package/dist/modules/Order/index.js +322 -695
- package/dist/modules/Order/types.d.ts +14 -49
- package/dist/modules/Order/types.js +0 -2
- package/dist/modules/Order/utils.d.ts +0 -17
- package/dist/modules/Order/utils.js +26 -96
- package/dist/modules/Rules/index.d.ts +0 -4
- package/dist/modules/Rules/index.js +10 -26
- package/dist/modules/SalesSummary/index.js +2 -4
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +1 -2
- package/dist/server/modules/order/utils/filterOrders.js +6 -20
- package/dist/solution/BaseSales/index.d.ts +7 -46
- package/dist/solution/BaseSales/index.js +315 -1009
- package/dist/solution/BaseSales/types.d.ts +1 -53
- package/dist/solution/BaseSales/types.js +1 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +15 -65
- package/dist/solution/BaseSales/utils.js +8 -46
- package/dist/solution/BookingTicket/index.d.ts +2 -134
- package/dist/solution/BookingTicket/index.js +175 -768
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/BookingTicket/types.js +0 -3
- package/dist/solution/ScanOrder/index.d.ts +3 -9
- package/dist/solution/ScanOrder/index.js +128 -231
- package/dist/solution/ScanOrder/utils.js +8 -46
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +23 -18
- package/dist/solution/VenueBooking/index.d.ts +9 -5
- package/dist/solution/VenueBooking/index.js +55 -103
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/lib/modules/Customer/index.d.ts +0 -6
- package/lib/modules/Customer/index.js +11 -26
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.d.ts +4 -2
- package/lib/modules/Discount/index.js +63 -8
- package/lib/modules/Discount/types.d.ts +7 -1
- package/lib/modules/Order/index.d.ts +16 -28
- package/lib/modules/Order/index.js +84 -336
- package/lib/modules/Order/types.d.ts +14 -49
- package/lib/modules/Order/utils.d.ts +0 -17
- package/lib/modules/Order/utils.js +18 -104
- package/lib/modules/Rules/index.d.ts +0 -4
- package/lib/modules/Rules/index.js +14 -22
- package/lib/modules/SalesSummary/index.js +2 -4
- package/lib/modules/index.d.ts +0 -1
- package/lib/modules/index.js +1 -3
- package/lib/server/modules/order/utils/filterOrders.js +4 -12
- package/lib/solution/BaseSales/index.d.ts +7 -46
- package/lib/solution/BaseSales/index.js +20 -434
- package/lib/solution/BaseSales/types.d.ts +1 -53
- package/lib/solution/BaseSales/types.js +1 -3
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +11 -70
- package/lib/solution/BaseSales/utils.js +6 -46
- package/lib/solution/BookingTicket/index.d.ts +2 -134
- package/lib/solution/BookingTicket/index.js +8 -341
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/BookingTicket/types.js +0 -6
- package/lib/solution/ScanOrder/index.d.ts +3 -9
- package/lib/solution/ScanOrder/index.js +66 -147
- package/lib/solution/ScanOrder/utils.js +6 -46
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +4 -2
- package/lib/solution/VenueBooking/index.d.ts +9 -5
- package/lib/solution/VenueBooking/index.js +14 -50
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/package.json +2 -2
- package/dist/modules/BookingContext/index.d.ts +0 -37
- package/dist/modules/BookingContext/index.js +0 -436
- package/dist/modules/BookingContext/types.d.ts +0 -102
- package/dist/modules/BookingContext/types.js +0 -51
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
- package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/dist/modules/BookingContext/utils/flexible.js +0 -56
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
- package/dist/modules/BookingContext/utils/index.d.ts +0 -11
- package/dist/modules/BookingContext/utils/index.js +0 -11
- package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/dist/modules/BookingContext/utils/noResource.js +0 -77
- package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/dist/modules/BookingContext/utils/productExtend.js +0 -339
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
- package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
- package/dist/modules/BookingContext/utils/resources.js +0 -486
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/dist/solution/BaseSales/utils/quotationPrice.js +0 -159
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
- package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
- package/lib/modules/BookingContext/index.d.ts +0 -37
- package/lib/modules/BookingContext/index.js +0 -297
- package/lib/modules/BookingContext/types.d.ts +0 -102
- package/lib/modules/BookingContext/types.js +0 -34
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
- package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/lib/modules/BookingContext/utils/flexible.js +0 -80
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
- package/lib/modules/BookingContext/utils/index.d.ts +0 -11
- package/lib/modules/BookingContext/utils/index.js +0 -43
- package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/lib/modules/BookingContext/utils/noResource.js +0 -90
- package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/lib/modules/BookingContext/utils/productExtend.js +0 -283
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
- package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
- package/lib/modules/BookingContext/utils/resources.js +0 -377
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/lib/solution/BaseSales/utils/quotationPrice.js +0 -201
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
- package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
|
@@ -24,12 +24,6 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
|
|
|
24
24
|
* @param operation 操作名称
|
|
25
25
|
*/
|
|
26
26
|
private handleCustomerListError;
|
|
27
|
-
/**
|
|
28
|
-
* 查询客户列表但不写入 customerList / pagination 状态。
|
|
29
|
-
*
|
|
30
|
-
* 用于按 ID 补齐客户等内部查询,避免把临时的 num/searchParams 污染到滚动列表。
|
|
31
|
-
*/
|
|
32
|
-
queryCustomerList(params?: ShopGetCustomerListParams): Promise<ICustomerListResponse>;
|
|
33
27
|
/**
|
|
34
28
|
* 获取客户列表
|
|
35
29
|
* @param params 查询参数
|
|
@@ -95,7 +95,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
95
95
|
} else {
|
|
96
96
|
this.store.currentPage = 1;
|
|
97
97
|
}
|
|
98
|
-
if (typeof (options === null || options === void 0 || (_options$initialState5 = options.initialState) === null || _options$initialState5 === void 0 ? void 0 : _options$initialState5.pageSize) === 'number'
|
|
98
|
+
if (typeof (options === null || options === void 0 || (_options$initialState5 = options.initialState) === null || _options$initialState5 === void 0 ? void 0 : _options$initialState5.pageSize) === 'number') {
|
|
99
99
|
this.store.pageSize = options.initialState.pageSize;
|
|
100
100
|
} else {
|
|
101
101
|
this.store.pageSize = DEFAULT_PAGE_SIZE;
|
|
@@ -236,52 +236,6 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
236
236
|
}
|
|
237
237
|
return handleCustomerListError;
|
|
238
238
|
}()
|
|
239
|
-
/**
|
|
240
|
-
* 查询客户列表但不写入 customerList / pagination 状态。
|
|
241
|
-
*
|
|
242
|
-
* 用于按 ID 补齐客户等内部查询,避免把临时的 num/searchParams 污染到滚动列表。
|
|
243
|
-
*/
|
|
244
|
-
)
|
|
245
|
-
}, {
|
|
246
|
-
key: "queryCustomerList",
|
|
247
|
-
value: (function () {
|
|
248
|
-
var _queryCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
249
|
-
var params,
|
|
250
|
-
_yield$this$fetchCust,
|
|
251
|
-
customerList,
|
|
252
|
-
total,
|
|
253
|
-
page,
|
|
254
|
-
pageSize,
|
|
255
|
-
_args4 = arguments;
|
|
256
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
257
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
258
|
-
case 0:
|
|
259
|
-
params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
|
|
260
|
-
_context4.next = 3;
|
|
261
|
-
return this.fetchCustomerListData(params);
|
|
262
|
-
case 3:
|
|
263
|
-
_yield$this$fetchCust = _context4.sent;
|
|
264
|
-
customerList = _yield$this$fetchCust.customerList;
|
|
265
|
-
total = _yield$this$fetchCust.total;
|
|
266
|
-
page = _yield$this$fetchCust.page;
|
|
267
|
-
pageSize = _yield$this$fetchCust.pageSize;
|
|
268
|
-
return _context4.abrupt("return", {
|
|
269
|
-
list: customerList,
|
|
270
|
-
total: total,
|
|
271
|
-
page: page,
|
|
272
|
-
pageSize: pageSize
|
|
273
|
-
});
|
|
274
|
-
case 9:
|
|
275
|
-
case "end":
|
|
276
|
-
return _context4.stop();
|
|
277
|
-
}
|
|
278
|
-
}, _callee4, this);
|
|
279
|
-
}));
|
|
280
|
-
function queryCustomerList() {
|
|
281
|
-
return _queryCustomerList.apply(this, arguments);
|
|
282
|
-
}
|
|
283
|
-
return queryCustomerList;
|
|
284
|
-
}()
|
|
285
239
|
/**
|
|
286
240
|
* 获取客户列表
|
|
287
241
|
* @param params 查询参数
|
|
@@ -291,9 +245,9 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
291
245
|
}, {
|
|
292
246
|
key: "getCustomerList",
|
|
293
247
|
value: (function () {
|
|
294
|
-
var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
248
|
+
var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
295
249
|
var params,
|
|
296
|
-
_yield$this$
|
|
250
|
+
_yield$this$fetchCust,
|
|
297
251
|
customerList,
|
|
298
252
|
total,
|
|
299
253
|
page,
|
|
@@ -302,22 +256,22 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
302
256
|
num,
|
|
303
257
|
searchParams,
|
|
304
258
|
response,
|
|
305
|
-
|
|
306
|
-
return _regeneratorRuntime().wrap(function
|
|
307
|
-
while (1) switch (
|
|
259
|
+
_args4 = arguments;
|
|
260
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
261
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
308
262
|
case 0:
|
|
309
|
-
params =
|
|
310
|
-
|
|
263
|
+
params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
|
|
264
|
+
_context4.prev = 1;
|
|
311
265
|
this.store.loading = true;
|
|
312
266
|
this.store.error = null;
|
|
313
|
-
|
|
267
|
+
_context4.next = 6;
|
|
314
268
|
return this.fetchCustomerListData(params);
|
|
315
269
|
case 6:
|
|
316
|
-
_yield$this$
|
|
317
|
-
customerList = _yield$this$
|
|
318
|
-
total = _yield$this$
|
|
319
|
-
page = _yield$this$
|
|
320
|
-
pageSize = _yield$this$
|
|
270
|
+
_yield$this$fetchCust = _context4.sent;
|
|
271
|
+
customerList = _yield$this$fetchCust.customerList;
|
|
272
|
+
total = _yield$this$fetchCust.total;
|
|
273
|
+
page = _yield$this$fetchCust.page;
|
|
274
|
+
pageSize = _yield$this$fetchCust.pageSize;
|
|
321
275
|
// 保存搜索条件(排除skip和num)
|
|
322
276
|
skip = params.skip, num = params.num, searchParams = _objectWithoutProperties(params, _excluded2);
|
|
323
277
|
this.store.searchParams = cloneDeep(searchParams);
|
|
@@ -332,7 +286,9 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
332
286
|
|
|
333
287
|
// 设置客户列表(替换模式)
|
|
334
288
|
this.store.customerList = cloneDeep(customerList);
|
|
335
|
-
|
|
289
|
+
_context4.next = 20;
|
|
290
|
+
return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
|
|
291
|
+
case 20:
|
|
336
292
|
// 触发分页变化事件
|
|
337
293
|
this.triggerPaginationChange({
|
|
338
294
|
page: page,
|
|
@@ -346,27 +302,24 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
346
302
|
page: page,
|
|
347
303
|
pageSize: pageSize
|
|
348
304
|
};
|
|
349
|
-
return
|
|
350
|
-
case
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
return this.handleCustomerListError(
|
|
355
|
-
case
|
|
356
|
-
throw
|
|
357
|
-
case
|
|
358
|
-
|
|
305
|
+
return _context4.abrupt("return", response);
|
|
306
|
+
case 25:
|
|
307
|
+
_context4.prev = 25;
|
|
308
|
+
_context4.t0 = _context4["catch"](1);
|
|
309
|
+
_context4.next = 29;
|
|
310
|
+
return this.handleCustomerListError(_context4.t0, 'fetch customer list');
|
|
311
|
+
case 29:
|
|
312
|
+
throw _context4.t0;
|
|
313
|
+
case 30:
|
|
314
|
+
_context4.prev = 30;
|
|
359
315
|
this.store.loading = false;
|
|
360
316
|
this.storeChange();
|
|
361
|
-
|
|
362
|
-
return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
|
|
363
|
-
case 33:
|
|
364
|
-
return _context5.finish(28);
|
|
317
|
+
return _context4.finish(30);
|
|
365
318
|
case 34:
|
|
366
319
|
case "end":
|
|
367
|
-
return
|
|
320
|
+
return _context4.stop();
|
|
368
321
|
}
|
|
369
|
-
},
|
|
322
|
+
}, _callee4, this, [[1, 25, 30, 34]]);
|
|
370
323
|
}));
|
|
371
324
|
function getCustomerList() {
|
|
372
325
|
return _getCustomerList.apply(this, arguments);
|
|
@@ -540,10 +493,10 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
540
493
|
}, {
|
|
541
494
|
key: "changeCustomerPage",
|
|
542
495
|
value: (function () {
|
|
543
|
-
var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
496
|
+
var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(page, pageSize) {
|
|
544
497
|
var targetPageSize, skip, num;
|
|
545
|
-
return _regeneratorRuntime().wrap(function
|
|
546
|
-
while (1) switch (
|
|
498
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
499
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
547
500
|
case 0:
|
|
548
501
|
targetPageSize = pageSize || this.store.pageSize; // 先更新分页状态
|
|
549
502
|
this.setPaginationInfo(page, targetPageSize);
|
|
@@ -551,18 +504,18 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
551
504
|
// skip直接使用page,num使用pageSize
|
|
552
505
|
skip = page;
|
|
553
506
|
num = targetPageSize; // 自动调用获取客户列表,使用存储的搜索条件
|
|
554
|
-
|
|
507
|
+
_context5.next = 6;
|
|
555
508
|
return this.getCustomerList(_objectSpread({
|
|
556
509
|
skip: skip,
|
|
557
510
|
num: num
|
|
558
511
|
}, this.store.searchParams));
|
|
559
512
|
case 6:
|
|
560
|
-
return
|
|
513
|
+
return _context5.abrupt("return", _context5.sent);
|
|
561
514
|
case 7:
|
|
562
515
|
case "end":
|
|
563
|
-
return
|
|
516
|
+
return _context5.stop();
|
|
564
517
|
}
|
|
565
|
-
},
|
|
518
|
+
}, _callee5, this);
|
|
566
519
|
}));
|
|
567
520
|
function changeCustomerPage(_x5, _x6) {
|
|
568
521
|
return _changeCustomerPage.apply(this, arguments);
|
|
@@ -577,16 +530,16 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
577
530
|
}, {
|
|
578
531
|
key: "loadMoreCustomers",
|
|
579
532
|
value: (function () {
|
|
580
|
-
var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
581
|
-
var nextPage,
|
|
582
|
-
return _regeneratorRuntime().wrap(function
|
|
583
|
-
while (1) switch (
|
|
533
|
+
var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
534
|
+
var nextPage, _yield$this$fetchCust2, newCustomers, total, page, pageSize, updatedCustomerList, response;
|
|
535
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
536
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
584
537
|
case 0:
|
|
585
538
|
if (!(!this.store.hasMore || this.store.loadingMore)) {
|
|
586
|
-
|
|
539
|
+
_context6.next = 2;
|
|
587
540
|
break;
|
|
588
541
|
}
|
|
589
|
-
return
|
|
542
|
+
return _context6.abrupt("return", {
|
|
590
543
|
list: [],
|
|
591
544
|
total: this.store.total,
|
|
592
545
|
page: this.store.currentPage,
|
|
@@ -595,21 +548,22 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
595
548
|
case 2:
|
|
596
549
|
// 计算下一页
|
|
597
550
|
nextPage = this.store.currentPage + 1;
|
|
598
|
-
|
|
551
|
+
_context6.prev = 3;
|
|
599
552
|
this.store.loadingMore = true;
|
|
600
553
|
this.store.error = null;
|
|
601
|
-
|
|
554
|
+
|
|
555
|
+
// 使用公共方法获取数据,传入存储的搜索条件
|
|
556
|
+
_context6.next = 8;
|
|
557
|
+
return this.fetchCustomerListData(_objectSpread({
|
|
602
558
|
skip: nextPage,
|
|
603
559
|
num: this.store.pageSize
|
|
604
|
-
}, this.store.searchParams);
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
_yield$this$
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
page = _yield$this$fetchCust3.page;
|
|
612
|
-
pageSize = _yield$this$fetchCust3.pageSize;
|
|
560
|
+
}, this.store.searchParams));
|
|
561
|
+
case 8:
|
|
562
|
+
_yield$this$fetchCust2 = _context6.sent;
|
|
563
|
+
newCustomers = _yield$this$fetchCust2.customerList;
|
|
564
|
+
total = _yield$this$fetchCust2.total;
|
|
565
|
+
page = _yield$this$fetchCust2.page;
|
|
566
|
+
pageSize = _yield$this$fetchCust2.pageSize;
|
|
613
567
|
// 将新数据追加到现有列表(追加模式)
|
|
614
568
|
updatedCustomerList = [].concat(_toConsumableArray(this.store.customerList), _toConsumableArray(cloneDeep(newCustomers))); // 更新状态
|
|
615
569
|
this.store.customerList = updatedCustomerList;
|
|
@@ -618,14 +572,17 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
618
572
|
this.store.hasMore = page * pageSize < total;
|
|
619
573
|
|
|
620
574
|
// 触发滚动加载特定事件
|
|
621
|
-
|
|
575
|
+
_context6.next = 20;
|
|
622
576
|
return this.core.effects.emit("".concat(this.name, ":onScrollLoadMore"), {
|
|
623
577
|
newCustomers: newCustomers,
|
|
624
578
|
allCustomers: this.store.customerList,
|
|
625
579
|
currentPage: page,
|
|
626
580
|
hasMore: this.store.hasMore
|
|
627
581
|
});
|
|
628
|
-
case
|
|
582
|
+
case 20:
|
|
583
|
+
_context6.next = 22;
|
|
584
|
+
return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
|
|
585
|
+
case 22:
|
|
629
586
|
// 触发分页变化事件
|
|
630
587
|
this.triggerPaginationChange({
|
|
631
588
|
page: page,
|
|
@@ -640,27 +597,24 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
640
597
|
page: page,
|
|
641
598
|
pageSize: pageSize
|
|
642
599
|
};
|
|
643
|
-
return
|
|
644
|
-
case
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
return this.handleCustomerListError(
|
|
649
|
-
case 30:
|
|
650
|
-
throw _context7.t0;
|
|
600
|
+
return _context6.abrupt("return", response);
|
|
601
|
+
case 27:
|
|
602
|
+
_context6.prev = 27;
|
|
603
|
+
_context6.t0 = _context6["catch"](3);
|
|
604
|
+
_context6.next = 31;
|
|
605
|
+
return this.handleCustomerListError(_context6.t0, 'load more customers');
|
|
651
606
|
case 31:
|
|
652
|
-
|
|
607
|
+
throw _context6.t0;
|
|
608
|
+
case 32:
|
|
609
|
+
_context6.prev = 32;
|
|
653
610
|
this.store.loadingMore = false;
|
|
654
611
|
this.storeChange();
|
|
655
|
-
|
|
656
|
-
return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
|
|
612
|
+
return _context6.finish(32);
|
|
657
613
|
case 36:
|
|
658
|
-
return _context7.finish(31);
|
|
659
|
-
case 37:
|
|
660
614
|
case "end":
|
|
661
|
-
return
|
|
615
|
+
return _context6.stop();
|
|
662
616
|
}
|
|
663
|
-
},
|
|
617
|
+
}, _callee6, this, [[3, 27, 32, 36]]);
|
|
664
618
|
}));
|
|
665
619
|
function loadMoreCustomers() {
|
|
666
620
|
return _loadMoreCustomers.apply(this, arguments);
|
|
@@ -676,15 +630,15 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
676
630
|
}, {
|
|
677
631
|
key: "resetAndLoadCustomers",
|
|
678
632
|
value: (function () {
|
|
679
|
-
var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
633
|
+
var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
680
634
|
var params,
|
|
681
635
|
resetParams,
|
|
682
636
|
response,
|
|
683
|
-
|
|
684
|
-
return _regeneratorRuntime().wrap(function
|
|
685
|
-
while (1) switch (
|
|
637
|
+
_args7 = arguments;
|
|
638
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
639
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
686
640
|
case 0:
|
|
687
|
-
params =
|
|
641
|
+
params = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
|
|
688
642
|
// 重置状态
|
|
689
643
|
this.store.customerList = [];
|
|
690
644
|
this.store.currentPage = 1;
|
|
@@ -696,23 +650,23 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
696
650
|
skip: 1,
|
|
697
651
|
num: params.num || this.store.pageSize
|
|
698
652
|
}); // 调用普通的获取列表方法
|
|
699
|
-
|
|
653
|
+
_context7.next = 8;
|
|
700
654
|
return this.getCustomerList(resetParams);
|
|
701
655
|
case 8:
|
|
702
|
-
response =
|
|
703
|
-
|
|
656
|
+
response = _context7.sent;
|
|
657
|
+
_context7.next = 11;
|
|
704
658
|
return this.core.effects.emit("".concat(this.name, ":onScrollLoadComplete"), {
|
|
705
659
|
customers: this.store.customerList,
|
|
706
660
|
total: this.store.total,
|
|
707
661
|
hasMore: this.store.hasMore
|
|
708
662
|
});
|
|
709
663
|
case 11:
|
|
710
|
-
return
|
|
664
|
+
return _context7.abrupt("return", response);
|
|
711
665
|
case 12:
|
|
712
666
|
case "end":
|
|
713
|
-
return
|
|
667
|
+
return _context7.stop();
|
|
714
668
|
}
|
|
715
|
-
},
|
|
669
|
+
}, _callee7, this);
|
|
716
670
|
}));
|
|
717
671
|
function resetAndLoadCustomers() {
|
|
718
672
|
return _resetAndLoadCustomers.apply(this, arguments);
|
|
@@ -110,8 +110,6 @@ export interface CustomerState {
|
|
|
110
110
|
export interface CustomerModuleAPI {
|
|
111
111
|
/** 获取客户列表 */
|
|
112
112
|
getCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
|
|
113
|
-
/** 查询客户列表但不更新列表分页状态 */
|
|
114
|
-
queryCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
|
|
115
113
|
/** 设置客户列表 */
|
|
116
114
|
setCustomerList: (customers: ShopCustomer[], total?: number) => void;
|
|
117
115
|
/** 设置当前选择的客户 */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { Discount, DiscountModuleAPI } from './types';
|
|
3
|
+
import { Discount, DiscountModuleAPI, DiscountWithReason } from './types';
|
|
4
4
|
export declare class DiscountModule extends BaseModule implements Module, DiscountModuleAPI {
|
|
5
5
|
protected defaultName: string;
|
|
6
6
|
protected defaultVersion: string;
|
|
@@ -28,9 +28,11 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
28
28
|
batchSearch(code: string, options?: {
|
|
29
29
|
customerId?: number;
|
|
30
30
|
orderId?: number;
|
|
31
|
-
}): Promise<
|
|
31
|
+
}): Promise<DiscountWithReason>;
|
|
32
32
|
filterEnabledDiscountList(discountList: Discount[]): Discount[];
|
|
33
33
|
private checkUsageCreditsLimit;
|
|
34
|
+
filterEnabledDiscountListWithReason(discountList: Discount[]): DiscountWithReason;
|
|
35
|
+
private checkUsageCreditsLimitWithFailKey;
|
|
34
36
|
uniqueByProductId(discountList: Discount[]): Discount[];
|
|
35
37
|
filterDiscountListByProductIds(discountList: Discount[], productIds: number[]): Discount[];
|
|
36
38
|
calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
|
|
@@ -154,7 +154,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
154
154
|
value: function () {
|
|
155
155
|
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
156
156
|
var _prepareConfig$data, _prepareConfig$data2;
|
|
157
|
-
var prepareConfig,
|
|
157
|
+
var prepareConfig, goodPassList;
|
|
158
158
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
159
159
|
while (1) switch (_context4.prev = _context4.next) {
|
|
160
160
|
case 0:
|
|
@@ -162,10 +162,9 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
162
162
|
return this.request.post("/order/prepare/config", params);
|
|
163
163
|
case 2:
|
|
164
164
|
prepareConfig = _context4.sent;
|
|
165
|
-
|
|
166
|
-
goodPassList = this.filterEnabledDiscountList(rawDiscountList) || []; // this.setDiscountList(goodPassList);
|
|
165
|
+
goodPassList = this.filterEnabledDiscountList([].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data = prepareConfig.data) === null || _prepareConfig$data === void 0 ? void 0 : _prepareConfig$data.good_pass_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data2 = prepareConfig.data) === null || _prepareConfig$data2 === void 0 ? void 0 : _prepareConfig$data2.discount_card_list) || []))) || []; // this.setDiscountList(goodPassList);
|
|
167
166
|
return _context4.abrupt("return", goodPassList);
|
|
168
|
-
case
|
|
167
|
+
case 5:
|
|
169
168
|
case "end":
|
|
170
169
|
return _context4.stop();
|
|
171
170
|
}
|
|
@@ -180,7 +179,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
180
179
|
key: "batchSearch",
|
|
181
180
|
value: function () {
|
|
182
181
|
var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, options) {
|
|
183
|
-
var _ref, customerId, orderId, result,
|
|
182
|
+
var _ref, customerId, orderId, result, resultDiscountWithReason;
|
|
184
183
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
185
184
|
while (1) switch (_context5.prev = _context5.next) {
|
|
186
185
|
case 0:
|
|
@@ -190,7 +189,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
190
189
|
code: code,
|
|
191
190
|
translate_flag: 1,
|
|
192
191
|
tags: ['good_pass', 'product_discount_card'],
|
|
193
|
-
available: 1,
|
|
192
|
+
// available: 1,
|
|
194
193
|
relation_product: 1,
|
|
195
194
|
with: ['extensionData', 'customScheduleSnapshot', 'holder.detail'],
|
|
196
195
|
order_behavior_count: 1,
|
|
@@ -198,12 +197,13 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
198
197
|
}, orderId ? {
|
|
199
198
|
order_behavior_count_order_id: orderId
|
|
200
199
|
} : {}), {}, {
|
|
200
|
+
unified_status_info_flag: 1,
|
|
201
201
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
202
202
|
}));
|
|
203
203
|
case 3:
|
|
204
204
|
result = _context5.sent;
|
|
205
|
-
|
|
206
|
-
return _context5.abrupt("return",
|
|
205
|
+
resultDiscountWithReason = this.filterEnabledDiscountListWithReason((result === null || result === void 0 ? void 0 : result.data) || []) || [];
|
|
206
|
+
return _context5.abrupt("return", resultDiscountWithReason);
|
|
207
207
|
case 6:
|
|
208
208
|
case "end":
|
|
209
209
|
return _context5.stop();
|
|
@@ -283,6 +283,91 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
283
283
|
return true;
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
// 过滤启用且可用的优惠券,并返回校验失败原因
|
|
287
|
+
}, {
|
|
288
|
+
key: "filterEnabledDiscountListWithReason",
|
|
289
|
+
value: function filterEnabledDiscountListWithReason(discountList) {
|
|
290
|
+
var _this3 = this;
|
|
291
|
+
var lists = discountList.filter(function (discount) {
|
|
292
|
+
return discount.limit_status === 'enable';
|
|
293
|
+
}).filter(function (discount) {
|
|
294
|
+
var remaining = new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0);
|
|
295
|
+
return remaining;
|
|
296
|
+
}).map(function (discount) {
|
|
297
|
+
var limitFailKey = _this3.checkUsageCreditsLimitWithFailKey(discount);
|
|
298
|
+
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
299
|
+
usageLimitFailKey: limitFailKey
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
// 可用的列表
|
|
304
|
+
var availableLists = lists.filter(function (item) {
|
|
305
|
+
return !item.usageLimitFailKey && item.unified_available_status !== 0;
|
|
306
|
+
});
|
|
307
|
+
// 不可用数据
|
|
308
|
+
var currentFailDiscount = lists.find(function (item) {
|
|
309
|
+
return item.usageLimitFailKey;
|
|
310
|
+
});
|
|
311
|
+
return {
|
|
312
|
+
discountList: availableLists,
|
|
313
|
+
unavailableReasonKey: currentFailDiscount === null || currentFailDiscount === void 0 ? void 0 : currentFailDiscount.usageLimitFailKey
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// 检查使用次数限制,并返回校验失败原因
|
|
318
|
+
}, {
|
|
319
|
+
key: "checkUsageCreditsLimitWithFailKey",
|
|
320
|
+
value: function checkUsageCreditsLimitWithFailKey(discount) {
|
|
321
|
+
if (!discount.extension_data || discount.extension_data.length === 0) {
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
var usageCreditsData = discount.extension_data.find(function (data) {
|
|
325
|
+
return data.field_key === 'usage_credits';
|
|
326
|
+
});
|
|
327
|
+
if (!usageCreditsData) {
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
var value = usageCreditsData.value;
|
|
331
|
+
|
|
332
|
+
// 总次数限制
|
|
333
|
+
if (value.total_credits && value.total_credits > 0) {
|
|
334
|
+
if ((discount.total_order_behavior_count || 0) >= value.total_credits) {
|
|
335
|
+
return 'total_credits';
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// 单用户限制
|
|
340
|
+
if (value.per_user_limit && value.per_user_limit > 0) {
|
|
341
|
+
if ((discount.customer_order_behavior_count || 0) >= value.per_user_limit) {
|
|
342
|
+
return 'per_user_limit';
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// 单日限制
|
|
347
|
+
if (value.max_per_day && value.max_per_day > 0) {
|
|
348
|
+
if ((discount.today_order_behavior_count || 0) >= value.max_per_day) {
|
|
349
|
+
return 'max_per_day';
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// 单周限制
|
|
354
|
+
if (value.max_per_week && value.max_per_week > 0) {
|
|
355
|
+
if ((discount.week_order_behavior_count || 0) >= value.max_per_week) {
|
|
356
|
+
return 'max_per_week';
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// 单月限制
|
|
361
|
+
if (value.max_per_month && value.max_per_month > 0) {
|
|
362
|
+
if ((discount.month_order_behavior_count || 0) >= value.max_per_month) {
|
|
363
|
+
return 'max_per_month';
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// 全部通过
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
|
|
286
371
|
// 根据productIds去重
|
|
287
372
|
}, {
|
|
288
373
|
key: "uniqueByProductId",
|
|
@@ -63,6 +63,11 @@ interface UsageCreditsValue {
|
|
|
63
63
|
max_per_week: number;
|
|
64
64
|
max_per_month: number;
|
|
65
65
|
}
|
|
66
|
+
export type DiscountFilterRejectKey = 'total_credits' | 'per_user_limit' | 'max_per_day' | 'max_per_week' | 'max_per_month';
|
|
67
|
+
export interface DiscountWithReason {
|
|
68
|
+
discountList: Discount[];
|
|
69
|
+
unavailableReasonKey: DiscountFilterRejectKey | null;
|
|
70
|
+
}
|
|
66
71
|
interface ExtensionData {
|
|
67
72
|
id: number;
|
|
68
73
|
shop_id: number;
|
|
@@ -135,7 +140,6 @@ export interface Discount {
|
|
|
135
140
|
appliedProductDetails: ApplicableProductDetails[];
|
|
136
141
|
isDisabledForProductUsed?: boolean;
|
|
137
142
|
amount?: number;
|
|
138
|
-
customer_id?: number | string | null;
|
|
139
143
|
extension_data?: ExtensionData[];
|
|
140
144
|
total_order_behavior_count?: number;
|
|
141
145
|
today_order_behavior_count?: number;
|
|
@@ -148,6 +152,8 @@ export interface Discount {
|
|
|
148
152
|
num?: number;
|
|
149
153
|
start_date?: string;
|
|
150
154
|
start_time?: string;
|
|
155
|
+
usageLimitFailKey?: string | null;
|
|
156
|
+
unified_available_status?: number | undefined | null;
|
|
151
157
|
}
|
|
152
158
|
export interface DiscountState {
|
|
153
159
|
discountList: Discount[];
|