@pisell/pisellos 2.1.91 → 2.1.92
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/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +40 -11
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Rules/index.js +17 -11
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +123 -85
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +9 -0
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Rules/index.js +9 -4
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +14 -0
- package/package.json +1 -1
|
@@ -25,6 +25,7 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
25
25
|
request_timezone: string;
|
|
26
26
|
}): Promise<Discount[]>;
|
|
27
27
|
batchSearch(code: string, customerId?: number): Promise<Discount[]>;
|
|
28
|
+
batchSearchByProductIds(productIds: number[]): Promise<any>;
|
|
28
29
|
filterEnabledDiscountList(discountList: Discount[]): Discount[];
|
|
29
30
|
private checkUsageCreditsLimit;
|
|
30
31
|
uniqueByProductId(discountList: Discount[]): Discount[];
|
|
@@ -208,6 +208,35 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
208
208
|
}
|
|
209
209
|
return batchSearch;
|
|
210
210
|
}()
|
|
211
|
+
}, {
|
|
212
|
+
key: "batchSearchByProductIds",
|
|
213
|
+
value: function () {
|
|
214
|
+
var _batchSearchByProductIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(productIds) {
|
|
215
|
+
var result;
|
|
216
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
217
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
218
|
+
case 0:
|
|
219
|
+
_context6.next = 2;
|
|
220
|
+
return this.request.get("/machinecode/batch-search", {
|
|
221
|
+
ids: productIds,
|
|
222
|
+
translate_flag: 1,
|
|
223
|
+
tags: ['good_pass', 'product_discount_card'],
|
|
224
|
+
relation_product: 1
|
|
225
|
+
});
|
|
226
|
+
case 2:
|
|
227
|
+
result = _context6.sent;
|
|
228
|
+
return _context6.abrupt("return", (result === null || result === void 0 ? void 0 : result.data) || []);
|
|
229
|
+
case 4:
|
|
230
|
+
case "end":
|
|
231
|
+
return _context6.stop();
|
|
232
|
+
}
|
|
233
|
+
}, _callee6, this);
|
|
234
|
+
}));
|
|
235
|
+
function batchSearchByProductIds(_x8) {
|
|
236
|
+
return _batchSearchByProductIds.apply(this, arguments);
|
|
237
|
+
}
|
|
238
|
+
return batchSearchByProductIds;
|
|
239
|
+
}()
|
|
211
240
|
}, {
|
|
212
241
|
key: "filterEnabledDiscountList",
|
|
213
242
|
value: function filterEnabledDiscountList(discountList) {
|
|
@@ -309,21 +338,21 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
309
338
|
}, {
|
|
310
339
|
key: "destroy",
|
|
311
340
|
value: function () {
|
|
312
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
313
|
-
return _regeneratorRuntime().wrap(function
|
|
314
|
-
while (1) switch (
|
|
341
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
342
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
343
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
315
344
|
case 0:
|
|
316
345
|
this.store.discountList = [];
|
|
317
346
|
this.core.effects.offByModuleDestroy(this.name);
|
|
318
|
-
|
|
347
|
+
_context7.next = 4;
|
|
319
348
|
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
320
349
|
case 4:
|
|
321
350
|
console.log('[Discount] 已销毁');
|
|
322
351
|
case 5:
|
|
323
352
|
case "end":
|
|
324
|
-
return
|
|
353
|
+
return _context7.stop();
|
|
325
354
|
}
|
|
326
|
-
},
|
|
355
|
+
}, _callee7, this);
|
|
327
356
|
}));
|
|
328
357
|
function destroy() {
|
|
329
358
|
return _destroy.apply(this, arguments);
|
|
@@ -333,18 +362,18 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
333
362
|
}, {
|
|
334
363
|
key: "clear",
|
|
335
364
|
value: function () {
|
|
336
|
-
var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
337
|
-
return _regeneratorRuntime().wrap(function
|
|
338
|
-
while (1) switch (
|
|
365
|
+
var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
366
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
367
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
339
368
|
case 0:
|
|
340
369
|
this.store.discountList = [];
|
|
341
370
|
this.store.originalDiscountList = [];
|
|
342
371
|
console.log('[Discount] clear');
|
|
343
372
|
case 3:
|
|
344
373
|
case "end":
|
|
345
|
-
return
|
|
374
|
+
return _context8.stop();
|
|
346
375
|
}
|
|
347
|
-
},
|
|
376
|
+
}, _callee8, this);
|
|
348
377
|
}));
|
|
349
378
|
function clear() {
|
|
350
379
|
return _clear.apply(this, arguments);
|
|
@@ -283,13 +283,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
283
283
|
productList = _ref2.productList,
|
|
284
284
|
holders = _ref2.holders,
|
|
285
285
|
isFormSubject = _ref2.isFormSubject;
|
|
286
|
-
// 识别出来是不是在编辑的界面里又新增了商品
|
|
287
|
-
// 这种情况下,如果有可用的优惠券,也会自动勾选上
|
|
288
|
-
var isEditModeAddNewProduct = productList.find(function (n) {
|
|
289
|
-
return n.booking_id;
|
|
290
|
-
}) && productList.find(function (n) {
|
|
291
|
-
return !n.booking_id;
|
|
292
|
-
});
|
|
293
286
|
var editModeDiscount = [];
|
|
294
287
|
var addModeDiscount = [];
|
|
295
288
|
discountList.forEach(function (discount) {
|
|
@@ -340,7 +333,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
340
333
|
_id: product._id,
|
|
341
334
|
parentId: product._id,
|
|
342
335
|
quantity: product.quantity,
|
|
343
|
-
num: product.num
|
|
336
|
+
num: product.num,
|
|
337
|
+
booking_id: product.booking_id
|
|
344
338
|
});
|
|
345
339
|
|
|
346
340
|
// 2. 展开 bundle 子商品
|
|
@@ -364,7 +358,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
364
358
|
origin_total: new Decimal(bundleItem.price || 0).mul(bundleItem.num || 1).toNumber(),
|
|
365
359
|
original_price: bundleItem.original_price,
|
|
366
360
|
// 继承主商品属性
|
|
367
|
-
booking_id:
|
|
361
|
+
booking_id: bundleItem.booking_id,
|
|
368
362
|
discount_list: bundleItem.discount_list || []
|
|
369
363
|
});
|
|
370
364
|
});
|
|
@@ -502,6 +496,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
502
496
|
// 🔥 扁平化商品列表(包含主商品和bundle子商品)
|
|
503
497
|
var flattenedList = flattenProductsWithBundle(productList);
|
|
504
498
|
|
|
499
|
+
// 识别出来是不是在编辑的界面里又新增了商品
|
|
500
|
+
// 这种情况下,如果有可用的优惠券,也会自动勾选上
|
|
501
|
+
var isEditModeAddNewProduct = flattenedList.find(function (n) {
|
|
502
|
+
return n.booking_id;
|
|
503
|
+
}) && flattenedList.find(function (n) {
|
|
504
|
+
return !n.booking_id;
|
|
505
|
+
});
|
|
506
|
+
|
|
505
507
|
// 对扁平化后的列表按价格降序排序(用于应用优惠券时优先选择高价商品)
|
|
506
508
|
var sortedFlattenedList = flattenedList.sort(function (a, b) {
|
|
507
509
|
var _ref3, _a$original_price, _ref4, _b$original_price;
|
|
@@ -829,7 +831,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
829
831
|
product_id: originProduct.id
|
|
830
832
|
},
|
|
831
833
|
metadata: {
|
|
832
|
-
num: num
|
|
834
|
+
num: num,
|
|
835
|
+
discount_rule_uncheck_flag: discount === null || discount === void 0 ? void 0 : discount.discount_rule_uncheck_flag
|
|
833
836
|
}
|
|
834
837
|
};
|
|
835
838
|
applicableProducts.push(productData);
|
|
@@ -1152,7 +1155,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1152
1155
|
// 前端使用的num数量,为了计算优惠金额
|
|
1153
1156
|
_num: isGoodPass ? 1 : product.num,
|
|
1154
1157
|
metadata: _objectSpread({
|
|
1155
|
-
num: 1
|
|
1158
|
+
num: 1,
|
|
1159
|
+
discount_rule_uncheck_flag: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.discount_rule_uncheck_flag
|
|
1156
1160
|
}, productDiscountDifference !== undefined && {
|
|
1157
1161
|
product_discount_difference: productDiscountDifference
|
|
1158
1162
|
})
|
|
@@ -1230,6 +1234,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1230
1234
|
metadata: {
|
|
1231
1235
|
// 🔥 使用拆分后的唯一 _id
|
|
1232
1236
|
custom_product_bundle_map_id: uniqueId,
|
|
1237
|
+
discount_rule_uncheck_flag: _selectedDiscount2 === null || _selectedDiscount2 === void 0 ? void 0 : _selectedDiscount2.discount_rule_uncheck_flag,
|
|
1233
1238
|
num: 1
|
|
1234
1239
|
},
|
|
1235
1240
|
_num: 1
|
|
@@ -1307,6 +1312,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1307
1312
|
metadata: _objectSpread({
|
|
1308
1313
|
// 🔥 使用唯一的 _id
|
|
1309
1314
|
custom_product_bundle_map_id: _uniqueId,
|
|
1315
|
+
discount_rule_uncheck_flag: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.discount_rule_uncheck_flag,
|
|
1310
1316
|
num: product.num || 1
|
|
1311
1317
|
}, _productDiscountDifference !== undefined && {
|
|
1312
1318
|
product_discount_difference: _productDiscountDifference
|
|
@@ -310,7 +310,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
310
310
|
date: string;
|
|
311
311
|
status: string;
|
|
312
312
|
week: string;
|
|
313
|
-
weekNum: 0 |
|
|
313
|
+
weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
314
314
|
}[]>;
|
|
315
315
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
316
316
|
private getScheduleDataByIds;
|
|
@@ -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, "
|
|
118
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
119
119
|
/**
|
|
120
120
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
121
121
|
* @returns 客户状态
|
|
@@ -38,6 +38,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
38
38
|
discountList: Discount[];
|
|
39
39
|
};
|
|
40
40
|
setProductList(productList: Record<string, any>[]): void;
|
|
41
|
+
batchSearchByProductIds(productIds: number[]): Promise<Discount[]>;
|
|
41
42
|
scanCode(code: string, customerId?: number): Promise<{
|
|
42
43
|
isAvailable: boolean;
|
|
43
44
|
productList: Record<string, any>[];
|
|
@@ -384,34 +384,72 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
384
384
|
value: function setProductList(productList) {
|
|
385
385
|
this.store.productList = productList;
|
|
386
386
|
}
|
|
387
|
-
|
|
388
|
-
// 扫码输入code
|
|
389
387
|
}, {
|
|
390
|
-
key: "
|
|
388
|
+
key: "batchSearchByProductIds",
|
|
391
389
|
value: function () {
|
|
392
|
-
var
|
|
393
|
-
var _this$store$discount3
|
|
390
|
+
var _batchSearchByProductIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(productIds) {
|
|
391
|
+
var _this$store$discount3;
|
|
392
|
+
var resultDiscountList, currentDiscountList, newDiscountList;
|
|
394
393
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
395
394
|
while (1) switch (_context5.prev = _context5.next) {
|
|
396
395
|
case 0:
|
|
397
|
-
_context5.
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
case 3:
|
|
396
|
+
_context5.next = 2;
|
|
397
|
+
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.batchSearchByProductIds(productIds);
|
|
398
|
+
case 2:
|
|
401
399
|
_context5.t0 = _context5.sent;
|
|
402
400
|
if (_context5.t0) {
|
|
403
|
-
_context5.next =
|
|
401
|
+
_context5.next = 5;
|
|
404
402
|
break;
|
|
405
403
|
}
|
|
406
404
|
_context5.t0 = [];
|
|
407
|
-
case
|
|
405
|
+
case 5:
|
|
408
406
|
resultDiscountList = _context5.t0;
|
|
407
|
+
resultDiscountList = resultDiscountList.map(function (item) {
|
|
408
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
409
|
+
discount_rule_uncheck_flag: true
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
currentDiscountList = this.getDiscountList() || [];
|
|
413
|
+
newDiscountList = [].concat(_toConsumableArray(currentDiscountList), _toConsumableArray(resultDiscountList));
|
|
414
|
+
this.setDiscountList(newDiscountList);
|
|
415
|
+
return _context5.abrupt("return", newDiscountList);
|
|
416
|
+
case 11:
|
|
417
|
+
case "end":
|
|
418
|
+
return _context5.stop();
|
|
419
|
+
}
|
|
420
|
+
}, _callee5, this);
|
|
421
|
+
}));
|
|
422
|
+
function batchSearchByProductIds(_x4) {
|
|
423
|
+
return _batchSearchByProductIds.apply(this, arguments);
|
|
424
|
+
}
|
|
425
|
+
return batchSearchByProductIds;
|
|
426
|
+
}() // 扫码输入code
|
|
427
|
+
}, {
|
|
428
|
+
key: "scanCode",
|
|
429
|
+
value: function () {
|
|
430
|
+
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
431
|
+
var _this$store$discount4, _this$store$bookingSu2, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, unavailableReason, _this$options$otherPa6;
|
|
432
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
433
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
434
|
+
case 0:
|
|
435
|
+
_context6.prev = 0;
|
|
436
|
+
_context6.next = 3;
|
|
437
|
+
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.batchSearch(code, customerId);
|
|
438
|
+
case 3:
|
|
439
|
+
_context6.t0 = _context6.sent;
|
|
440
|
+
if (_context6.t0) {
|
|
441
|
+
_context6.next = 6;
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
_context6.t0 = [];
|
|
445
|
+
case 6:
|
|
446
|
+
resultDiscountList = _context6.t0;
|
|
409
447
|
rulesModule = this.store.rules;
|
|
410
448
|
if (rulesModule) {
|
|
411
|
-
|
|
449
|
+
_context6.next = 10;
|
|
412
450
|
break;
|
|
413
451
|
}
|
|
414
|
-
return
|
|
452
|
+
return _context6.abrupt("return", {
|
|
415
453
|
type: "clientCalc",
|
|
416
454
|
isAvailable: false,
|
|
417
455
|
productList: this.store.productList || [],
|
|
@@ -420,10 +458,10 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
420
458
|
});
|
|
421
459
|
case 10:
|
|
422
460
|
if (resultDiscountList.length) {
|
|
423
|
-
|
|
461
|
+
_context6.next = 12;
|
|
424
462
|
break;
|
|
425
463
|
}
|
|
426
|
-
return
|
|
464
|
+
return _context6.abrupt("return", {
|
|
427
465
|
type: "server",
|
|
428
466
|
isAvailable: false,
|
|
429
467
|
productList: this.store.productList || [],
|
|
@@ -443,10 +481,10 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
443
481
|
return m.id === n.id;
|
|
444
482
|
});
|
|
445
483
|
}))) {
|
|
446
|
-
|
|
484
|
+
_context6.next = 16;
|
|
447
485
|
break;
|
|
448
486
|
}
|
|
449
|
-
return
|
|
487
|
+
return _context6.abrupt("return", {
|
|
450
488
|
type: "clientCalc",
|
|
451
489
|
isAvailable: true,
|
|
452
490
|
productList: this.store.productList || [],
|
|
@@ -465,20 +503,20 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
465
503
|
discountList: this.getDiscountList()
|
|
466
504
|
}, newProductList = _ref2.productList, newDiscountList = _ref2.discountList, isAvailable = _ref2.isAvailable, unavailableReason = _ref2.unavailableReason;
|
|
467
505
|
if (!isAvailable) {
|
|
468
|
-
|
|
506
|
+
_context6.next = 24;
|
|
469
507
|
break;
|
|
470
508
|
}
|
|
471
509
|
this.setDiscountList(newDiscountList || []);
|
|
472
510
|
this.store.originalDiscountList = newDiscountList || [];
|
|
473
511
|
this.setProductList(newProductList || []);
|
|
474
512
|
if (!(this.isWalkIn() && resultDiscountList.length && ((_this$options$otherPa6 = this.options.otherParams) === null || _this$options$otherPa6 === void 0 ? void 0 : _this$options$otherPa6.platform) === 'shop')) {
|
|
475
|
-
|
|
513
|
+
_context6.next = 24;
|
|
476
514
|
break;
|
|
477
515
|
}
|
|
478
|
-
|
|
516
|
+
_context6.next = 24;
|
|
479
517
|
return this.getCustomerWallet(resultDiscountList[0].customer_id);
|
|
480
518
|
case 24:
|
|
481
|
-
return
|
|
519
|
+
return _context6.abrupt("return", {
|
|
482
520
|
type: "clientCalc",
|
|
483
521
|
isAvailable: isAvailable || false,
|
|
484
522
|
productList: newProductList || this.store.productList || [],
|
|
@@ -486,10 +524,10 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
486
524
|
unavailableReason: unavailableReason
|
|
487
525
|
});
|
|
488
526
|
case 27:
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
console.error('[ShopDiscount] 扫码出错:',
|
|
492
|
-
return
|
|
527
|
+
_context6.prev = 27;
|
|
528
|
+
_context6.t1 = _context6["catch"](0);
|
|
529
|
+
console.error('[ShopDiscount] 扫码出错:', _context6.t1);
|
|
530
|
+
return _context6.abrupt("return", {
|
|
493
531
|
type: "clientCalc",
|
|
494
532
|
isAvailable: false,
|
|
495
533
|
productList: this.store.productList || [],
|
|
@@ -498,11 +536,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
498
536
|
});
|
|
499
537
|
case 31:
|
|
500
538
|
case "end":
|
|
501
|
-
return
|
|
539
|
+
return _context6.stop();
|
|
502
540
|
}
|
|
503
|
-
},
|
|
541
|
+
}, _callee6, this, [[0, 27]]);
|
|
504
542
|
}));
|
|
505
|
-
function scanCode(
|
|
543
|
+
function scanCode(_x5, _x6) {
|
|
506
544
|
return _scanCode.apply(this, arguments);
|
|
507
545
|
}
|
|
508
546
|
return scanCode;
|
|
@@ -510,8 +548,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
510
548
|
}, {
|
|
511
549
|
key: "calcDiscountApplicableProductTotalPrice",
|
|
512
550
|
value: function calcDiscountApplicableProductTotalPrice(discount) {
|
|
513
|
-
var _this$store$
|
|
514
|
-
return (_this$store$
|
|
551
|
+
var _this$store$discount5;
|
|
552
|
+
return (_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 ? void 0 : _this$store$discount5.calcDiscountApplicableProductTotalPrice(discount);
|
|
515
553
|
}
|
|
516
554
|
|
|
517
555
|
// =========== 私有辅助方法 ===========
|
|
@@ -535,19 +573,19 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
535
573
|
}, {
|
|
536
574
|
key: "emitDiscountListChange",
|
|
537
575
|
value: function () {
|
|
538
|
-
var _emitDiscountListChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
539
|
-
return _regeneratorRuntime().wrap(function
|
|
540
|
-
while (1) switch (
|
|
576
|
+
var _emitDiscountListChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(discountList) {
|
|
577
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
578
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
541
579
|
case 0:
|
|
542
|
-
|
|
580
|
+
_context7.next = 2;
|
|
543
581
|
return this.core.effects.emit("".concat(this.name, ":onDiscountListChange"), discountList);
|
|
544
582
|
case 2:
|
|
545
583
|
case "end":
|
|
546
|
-
return
|
|
584
|
+
return _context7.stop();
|
|
547
585
|
}
|
|
548
|
-
},
|
|
586
|
+
}, _callee7, this);
|
|
549
587
|
}));
|
|
550
|
-
function emitDiscountListChange(
|
|
588
|
+
function emitDiscountListChange(_x7) {
|
|
551
589
|
return _emitDiscountListChange.apply(this, arguments);
|
|
552
590
|
}
|
|
553
591
|
return emitDiscountListChange;
|
|
@@ -556,7 +594,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
556
594
|
key: "setDiscountList",
|
|
557
595
|
value: function setDiscountList(discountList) {
|
|
558
596
|
var _this3 = this,
|
|
559
|
-
_this$store$
|
|
597
|
+
_this$store$discount6;
|
|
560
598
|
var productList = this.store.productList || [];
|
|
561
599
|
var editModeDiscountList = [];
|
|
562
600
|
productList.forEach(function (item) {
|
|
@@ -639,7 +677,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
639
677
|
item.isDisabledForProductUsed = false;
|
|
640
678
|
}
|
|
641
679
|
});
|
|
642
|
-
(_this$store$
|
|
680
|
+
(_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 || _this$store$discount6.setDiscountList(newDiscountList);
|
|
643
681
|
this.emitDiscountListChange(newDiscountList);
|
|
644
682
|
return newDiscountList;
|
|
645
683
|
}
|
|
@@ -648,48 +686,48 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
648
686
|
}, {
|
|
649
687
|
key: "getDiscountList",
|
|
650
688
|
value: function getDiscountList() {
|
|
651
|
-
var _this$store$
|
|
652
|
-
return ((_this$store$
|
|
689
|
+
var _this$store$discount7;
|
|
690
|
+
return ((_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.getDiscountList()) || [];
|
|
653
691
|
}
|
|
654
692
|
|
|
655
693
|
// 获取客户钱包信息
|
|
656
694
|
}, {
|
|
657
695
|
key: "getCustomerWallet",
|
|
658
696
|
value: function () {
|
|
659
|
-
var _getCustomerWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
697
|
+
var _getCustomerWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(id) {
|
|
660
698
|
var _result, customer;
|
|
661
|
-
return _regeneratorRuntime().wrap(function
|
|
662
|
-
while (1) switch (
|
|
699
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
700
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
663
701
|
case 0:
|
|
664
|
-
|
|
665
|
-
|
|
702
|
+
_context8.prev = 0;
|
|
703
|
+
_context8.next = 3;
|
|
666
704
|
return this.request.get("/customer/info/".concat(id), {
|
|
667
705
|
with_trashed: 1
|
|
668
706
|
});
|
|
669
707
|
case 3:
|
|
670
|
-
_result =
|
|
708
|
+
_result = _context8.sent;
|
|
671
709
|
if (!(_result !== null && _result !== void 0 && _result.data)) {
|
|
672
|
-
|
|
710
|
+
_context8.next = 9;
|
|
673
711
|
break;
|
|
674
712
|
}
|
|
675
713
|
customer = Object.assign({}, (_objectDestructuringEmpty(_result.data), _result.data));
|
|
676
714
|
this.setCustomer(customer);
|
|
677
|
-
|
|
715
|
+
_context8.next = 9;
|
|
678
716
|
return this.core.effects.emit("".concat(this.name, ":onScanCustomerChange"), customer);
|
|
679
717
|
case 9:
|
|
680
|
-
|
|
718
|
+
_context8.next = 14;
|
|
681
719
|
break;
|
|
682
720
|
case 11:
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
console.error('[ShopDiscount] 获取客户钱包信息出错:',
|
|
721
|
+
_context8.prev = 11;
|
|
722
|
+
_context8.t0 = _context8["catch"](0);
|
|
723
|
+
console.error('[ShopDiscount] 获取客户钱包信息出错:', _context8.t0);
|
|
686
724
|
case 14:
|
|
687
725
|
case "end":
|
|
688
|
-
return
|
|
726
|
+
return _context8.stop();
|
|
689
727
|
}
|
|
690
|
-
},
|
|
728
|
+
}, _callee8, this, [[0, 11]]);
|
|
691
729
|
}));
|
|
692
|
-
function getCustomerWallet(
|
|
730
|
+
function getCustomerWallet(_x8) {
|
|
693
731
|
return _getCustomerWallet.apply(this, arguments);
|
|
694
732
|
}
|
|
695
733
|
return getCustomerWallet;
|
|
@@ -697,32 +735,32 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
697
735
|
}, {
|
|
698
736
|
key: "bestDiscount",
|
|
699
737
|
value: function () {
|
|
700
|
-
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
738
|
+
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(cb) {
|
|
701
739
|
var _this$store$productLi;
|
|
702
740
|
var newDiscountList, _result2;
|
|
703
|
-
return _regeneratorRuntime().wrap(function
|
|
704
|
-
while (1) switch (
|
|
741
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
742
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
705
743
|
case 0:
|
|
706
744
|
newDiscountList = this.store.originalDiscountList;
|
|
707
745
|
this.setDiscountList(newDiscountList);
|
|
708
746
|
if (!((_this$store$productLi = this.store.productList) !== null && _this$store$productLi !== void 0 && _this$store$productLi.length)) {
|
|
709
|
-
|
|
747
|
+
_context9.next = 7;
|
|
710
748
|
break;
|
|
711
749
|
}
|
|
712
750
|
_result2 = this.calcDiscount(this.store.productList);
|
|
713
751
|
cb === null || cb === void 0 || cb(_result2);
|
|
714
|
-
|
|
752
|
+
_context9.next = 7;
|
|
715
753
|
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result2);
|
|
716
754
|
case 7:
|
|
717
|
-
|
|
755
|
+
_context9.next = 9;
|
|
718
756
|
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), newDiscountList);
|
|
719
757
|
case 9:
|
|
720
758
|
case "end":
|
|
721
|
-
return
|
|
759
|
+
return _context9.stop();
|
|
722
760
|
}
|
|
723
|
-
},
|
|
761
|
+
}, _callee9, this);
|
|
724
762
|
}));
|
|
725
|
-
function bestDiscount(
|
|
763
|
+
function bestDiscount(_x9) {
|
|
726
764
|
return _bestDiscount.apply(this, arguments);
|
|
727
765
|
}
|
|
728
766
|
return bestDiscount;
|
|
@@ -730,17 +768,17 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
730
768
|
}, {
|
|
731
769
|
key: "loadPrepareConfig",
|
|
732
770
|
value: function () {
|
|
733
|
-
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
734
|
-
var _this$getCustomer2, _this$store$
|
|
735
|
-
return _regeneratorRuntime().wrap(function
|
|
736
|
-
while (1) switch (
|
|
771
|
+
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
772
|
+
var _this$getCustomer2, _this$store$discount8, _this$getDiscountList, _this$store$discount9, _this$store$productLi2, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
|
|
773
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
774
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
737
775
|
case 0:
|
|
738
|
-
|
|
776
|
+
_context10.prev = 0;
|
|
739
777
|
customerId = params.customerId || ((_this$getCustomer2 = this.getCustomer()) === null || _this$getCustomer2 === void 0 ? void 0 : _this$getCustomer2.id); // if (customerId === 1 || !customerId) {
|
|
740
778
|
// return
|
|
741
779
|
// }
|
|
742
|
-
|
|
743
|
-
return (_this$store$
|
|
780
|
+
_context10.next = 4;
|
|
781
|
+
return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.loadPrepareConfig({
|
|
744
782
|
customer_id: customerId,
|
|
745
783
|
action: 'create',
|
|
746
784
|
with_good_pass: 1,
|
|
@@ -749,7 +787,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
749
787
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
750
788
|
});
|
|
751
789
|
case 4:
|
|
752
|
-
goodPassList =
|
|
790
|
+
goodPassList = _context10.sent;
|
|
753
791
|
scanDiscount = (_this$getDiscountList = this.getDiscountList()) === null || _this$getDiscountList === void 0 ? void 0 : _this$getDiscountList.filter(function (item) {
|
|
754
792
|
return item.isScan;
|
|
755
793
|
}); // goodPassList 里可能有 scanDiscount 重合的部分,goodPassList 需要剔除
|
|
@@ -761,37 +799,37 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
761
799
|
});
|
|
762
800
|
newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || [])); // 存储原始优惠券列表
|
|
763
801
|
this.store.originalDiscountList = newDiscountList;
|
|
764
|
-
|
|
765
|
-
return (_this$store$
|
|
802
|
+
_context10.next = 12;
|
|
803
|
+
return (_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.setOriginalDiscountList(newDiscountList);
|
|
766
804
|
case 12:
|
|
767
805
|
// 根据当前预约时间过滤优惠券列表
|
|
768
806
|
filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
|
|
769
807
|
this.store.filteredDiscountList = filteredDiscountList;
|
|
770
808
|
this.setDiscountList(filteredDiscountList || []);
|
|
771
809
|
if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
|
|
772
|
-
|
|
810
|
+
_context10.next = 19;
|
|
773
811
|
break;
|
|
774
812
|
}
|
|
775
813
|
_result3 = this.calcDiscount(this.store.productList);
|
|
776
|
-
|
|
814
|
+
_context10.next = 19;
|
|
777
815
|
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
|
|
778
816
|
case 19:
|
|
779
|
-
|
|
817
|
+
_context10.next = 21;
|
|
780
818
|
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
|
|
781
819
|
case 21:
|
|
782
|
-
|
|
820
|
+
_context10.next = 26;
|
|
783
821
|
break;
|
|
784
822
|
case 23:
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
console.error('[ShopDiscount] 加载准备配置出错:',
|
|
823
|
+
_context10.prev = 23;
|
|
824
|
+
_context10.t0 = _context10["catch"](0);
|
|
825
|
+
console.error('[ShopDiscount] 加载准备配置出错:', _context10.t0);
|
|
788
826
|
case 26:
|
|
789
827
|
case "end":
|
|
790
|
-
return
|
|
828
|
+
return _context10.stop();
|
|
791
829
|
}
|
|
792
|
-
},
|
|
830
|
+
}, _callee10, this, [[0, 23]]);
|
|
793
831
|
}));
|
|
794
|
-
function loadPrepareConfig(
|
|
832
|
+
function loadPrepareConfig(_x10) {
|
|
795
833
|
return _loadPrepareConfig.apply(this, arguments);
|
|
796
834
|
}
|
|
797
835
|
return loadPrepareConfig;
|
|
@@ -25,6 +25,7 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
25
25
|
request_timezone: string;
|
|
26
26
|
}): Promise<Discount[]>;
|
|
27
27
|
batchSearch(code: string, customerId?: number): Promise<Discount[]>;
|
|
28
|
+
batchSearchByProductIds(productIds: number[]): Promise<any>;
|
|
28
29
|
filterEnabledDiscountList(discountList: Discount[]): Discount[];
|
|
29
30
|
private checkUsageCreditsLimit;
|
|
30
31
|
uniqueByProductId(discountList: Discount[]): Discount[];
|
|
@@ -117,6 +117,15 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
117
117
|
const resultDiscountList = this.filterEnabledDiscountList((result == null ? void 0 : result.data) || []) || [];
|
|
118
118
|
return resultDiscountList;
|
|
119
119
|
}
|
|
120
|
+
async batchSearchByProductIds(productIds) {
|
|
121
|
+
const result = await this.request.get(`/machinecode/batch-search`, {
|
|
122
|
+
ids: productIds,
|
|
123
|
+
translate_flag: 1,
|
|
124
|
+
tags: ["good_pass", "product_discount_card"],
|
|
125
|
+
relation_product: 1
|
|
126
|
+
});
|
|
127
|
+
return (result == null ? void 0 : result.data) || [];
|
|
128
|
+
}
|
|
120
129
|
filterEnabledDiscountList(discountList) {
|
|
121
130
|
return discountList.filter(
|
|
122
131
|
(discount) => discount.limit_status === "enable" && new import_decimal.default((discount == null ? void 0 : discount.par_value) || 0).minus(new import_decimal.default((discount == null ? void 0 : discount.used_par_value) || 0)).greaterThan(0) && this.checkUsageCreditsLimit(discount)
|
|
@@ -182,7 +182,6 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
182
182
|
holders,
|
|
183
183
|
isFormSubject
|
|
184
184
|
}, options) {
|
|
185
|
-
const isEditModeAddNewProduct = productList.find((n) => n.booking_id) && productList.find((n) => !n.booking_id);
|
|
186
185
|
const editModeDiscount = [];
|
|
187
186
|
const addModeDiscount = [];
|
|
188
187
|
discountList.forEach((discount) => {
|
|
@@ -222,7 +221,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
222
221
|
_id: product._id,
|
|
223
222
|
parentId: product._id,
|
|
224
223
|
quantity: product.quantity,
|
|
225
|
-
num: product.num
|
|
224
|
+
num: product.num,
|
|
225
|
+
booking_id: product.booking_id
|
|
226
226
|
});
|
|
227
227
|
if (product.bundle && Array.isArray(product.bundle) && product.bundle.length > 0) {
|
|
228
228
|
product.bundle.forEach((bundleItem, bundleIndex) => {
|
|
@@ -244,7 +244,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
244
244
|
origin_total: new import_decimal.default(bundleItem.price || 0).mul(bundleItem.num || 1).toNumber(),
|
|
245
245
|
original_price: bundleItem.original_price,
|
|
246
246
|
// 继承主商品属性
|
|
247
|
-
booking_id:
|
|
247
|
+
booking_id: bundleItem.booking_id,
|
|
248
248
|
discount_list: bundleItem.discount_list || []
|
|
249
249
|
});
|
|
250
250
|
});
|
|
@@ -334,6 +334,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
334
334
|
return compareByExpireTime(a, b);
|
|
335
335
|
});
|
|
336
336
|
const flattenedList = flattenProductsWithBundle(productList);
|
|
337
|
+
const isEditModeAddNewProduct = flattenedList.find((n) => n.booking_id) && flattenedList.find((n) => !n.booking_id);
|
|
337
338
|
const sortedFlattenedList = flattenedList.sort((a, b) => {
|
|
338
339
|
var _a, _b;
|
|
339
340
|
const priceA = new import_decimal.default(
|
|
@@ -555,7 +556,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
555
556
|
product_id: originProduct.id
|
|
556
557
|
},
|
|
557
558
|
metadata: {
|
|
558
|
-
num
|
|
559
|
+
num,
|
|
560
|
+
discount_rule_uncheck_flag: discount == null ? void 0 : discount.discount_rule_uncheck_flag
|
|
559
561
|
}
|
|
560
562
|
};
|
|
561
563
|
applicableProducts.push(productData);
|
|
@@ -818,6 +820,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
818
820
|
_num: isGoodPass ? 1 : product.num,
|
|
819
821
|
metadata: {
|
|
820
822
|
num: 1,
|
|
823
|
+
discount_rule_uncheck_flag: selectedDiscount2 == null ? void 0 : selectedDiscount2.discount_rule_uncheck_flag,
|
|
821
824
|
// 🔥 order_level 分摊差值
|
|
822
825
|
...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference }
|
|
823
826
|
}
|
|
@@ -885,6 +888,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
885
888
|
metadata: {
|
|
886
889
|
// 🔥 使用拆分后的唯一 _id
|
|
887
890
|
custom_product_bundle_map_id: uniqueId,
|
|
891
|
+
discount_rule_uncheck_flag: selectedDiscount2 == null ? void 0 : selectedDiscount2.discount_rule_uncheck_flag,
|
|
888
892
|
num: 1
|
|
889
893
|
},
|
|
890
894
|
_num: 1
|
|
@@ -957,6 +961,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
957
961
|
metadata: {
|
|
958
962
|
// 🔥 使用唯一的 _id
|
|
959
963
|
custom_product_bundle_map_id: uniqueId,
|
|
964
|
+
discount_rule_uncheck_flag: selectedDiscount2 == null ? void 0 : selectedDiscount2.discount_rule_uncheck_flag,
|
|
960
965
|
num: product.num || 1,
|
|
961
966
|
// 🔥 order_level 分摊差值
|
|
962
967
|
...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference }
|
|
@@ -310,7 +310,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
310
310
|
date: string;
|
|
311
311
|
status: string;
|
|
312
312
|
week: string;
|
|
313
|
-
weekNum: 0 |
|
|
313
|
+
weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
314
314
|
}[]>;
|
|
315
315
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
316
316
|
private getScheduleDataByIds;
|
|
@@ -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, "
|
|
118
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
119
119
|
/**
|
|
120
120
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
121
121
|
* @returns 客户状态
|
|
@@ -38,6 +38,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
38
38
|
discountList: Discount[];
|
|
39
39
|
};
|
|
40
40
|
setProductList(productList: Record<string, any>[]): void;
|
|
41
|
+
batchSearchByProductIds(productIds: number[]): Promise<Discount[]>;
|
|
41
42
|
scanCode(code: string, customerId?: number): Promise<{
|
|
42
43
|
isAvailable: boolean;
|
|
43
44
|
productList: Record<string, any>[];
|
|
@@ -259,6 +259,20 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
259
259
|
setProductList(productList) {
|
|
260
260
|
this.store.productList = productList;
|
|
261
261
|
}
|
|
262
|
+
async batchSearchByProductIds(productIds) {
|
|
263
|
+
var _a;
|
|
264
|
+
let resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearchByProductIds(productIds)) || [];
|
|
265
|
+
resultDiscountList = resultDiscountList.map((item) => {
|
|
266
|
+
return {
|
|
267
|
+
...item,
|
|
268
|
+
discount_rule_uncheck_flag: true
|
|
269
|
+
};
|
|
270
|
+
});
|
|
271
|
+
const currentDiscountList = this.getDiscountList() || [];
|
|
272
|
+
const newDiscountList = [...currentDiscountList, ...resultDiscountList];
|
|
273
|
+
this.setDiscountList(newDiscountList);
|
|
274
|
+
return newDiscountList;
|
|
275
|
+
}
|
|
262
276
|
// 扫码输入code
|
|
263
277
|
async scanCode(code, customerId) {
|
|
264
278
|
var _a, _b, _c;
|