@pisell/pisellos 2.1.91 → 2.1.93
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +3 -0
- package/dist/model/strategy/adapter/index.js +4 -0
- package/dist/model/strategy/adapter/type.d.ts +28 -0
- package/dist/model/strategy/adapter/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +497 -0
- package/dist/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/dist/model/strategy/adapter/walletPass/example.js +258 -0
- package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/dist/model/strategy/adapter/walletPass/index.js +182 -0
- package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/dist/model/strategy/adapter/walletPass/locales.js +23 -0
- package/dist/model/strategy/adapter/walletPass/type.d.ts +165 -0
- package/dist/model/strategy/adapter/walletPass/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +965 -0
- package/dist/model/strategy/index.d.ts +94 -0
- package/dist/model/strategy/index.js +551 -0
- package/dist/model/strategy/strategy-example.d.ts +5 -0
- package/dist/model/strategy/strategy-example.js +331 -0
- package/dist/model/strategy/type.d.ts +228 -0
- package/dist/model/strategy/type.js +94 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +11 -0
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +40 -11
- package/dist/modules/Discount/types.d.ts +17 -0
- package/dist/modules/Payment/index.d.ts +2 -1
- package/dist/modules/Payment/index.js +10 -7
- package/dist/modules/Payment/utils.js +3 -0
- package/dist/modules/Payment/walletpass.d.ts +23 -0
- package/dist/modules/Payment/walletpass.js +191 -95
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.d.ts +9 -5
- package/dist/modules/Rules/index.js +538 -118
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/modules/Summary/types.d.ts +2 -0
- package/dist/modules/Summary/utils.d.ts +6 -0
- package/dist/modules/Summary/utils.js +21 -0
- package/dist/plugins/window.d.ts +2 -0
- package/dist/solution/BookingByStep/index.d.ts +2 -1
- package/dist/solution/Checkout/index.js +2 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +146 -92
- package/dist/solution/ShopDiscount/types.d.ts +1 -0
- package/dist/solution/ShopDiscount/types.js +2 -1
- package/dist/solution/ShopDiscount/utils.js +26 -12
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/model/index.d.ts +1 -0
- package/lib/model/index.js +23 -0
- package/lib/model/strategy/adapter/index.d.ts +3 -0
- package/lib/model/strategy/adapter/index.js +45 -0
- package/lib/model/strategy/adapter/type.d.ts +28 -0
- package/lib/model/strategy/adapter/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +421 -0
- package/lib/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/lib/model/strategy/adapter/walletPass/example.js +207 -0
- package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/lib/model/strategy/adapter/walletPass/index.js +142 -0
- package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/lib/model/strategy/adapter/walletPass/locales.js +51 -0
- package/lib/model/strategy/adapter/walletPass/type.d.ts +165 -0
- package/lib/model/strategy/adapter/walletPass/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +660 -0
- package/lib/model/strategy/index.d.ts +94 -0
- package/lib/model/strategy/index.js +413 -0
- package/lib/model/strategy/strategy-example.d.ts +5 -0
- package/lib/model/strategy/strategy-example.js +318 -0
- package/lib/model/strategy/type.d.ts +228 -0
- package/lib/model/strategy/type.js +44 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +9 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +9 -0
- package/lib/modules/Discount/types.d.ts +17 -0
- package/lib/modules/Payment/index.d.ts +2 -1
- package/lib/modules/Payment/index.js +1 -0
- package/lib/modules/Payment/utils.js +3 -0
- package/lib/modules/Payment/walletpass.d.ts +23 -0
- package/lib/modules/Payment/walletpass.js +94 -17
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.d.ts +9 -5
- package/lib/modules/Rules/index.js +669 -258
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/modules/Summary/types.d.ts +2 -0
- package/lib/modules/Summary/utils.d.ts +6 -0
- package/lib/modules/Summary/utils.js +15 -0
- package/lib/plugins/window.d.ts +2 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -1
- package/lib/solution/Checkout/index.js +2 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +36 -8
- package/lib/solution/ShopDiscount/types.d.ts +1 -0
- package/lib/solution/ShopDiscount/utils.js +10 -6
- package/package.json +1 -1
|
@@ -58,6 +58,12 @@ export declare const getTax: ({ service, addons, bookingDetail, bookingId }: {
|
|
|
58
58
|
* @returns 商品总价字符串,保留2位小数
|
|
59
59
|
*/
|
|
60
60
|
export declare const calculateSubtotal: (items: CartItem[]) => string;
|
|
61
|
+
/**
|
|
62
|
+
* 计算商品小计(不含其他费用 不包含折扣卡商品券抵扣金额)
|
|
63
|
+
* @param items - 购物车商品数组
|
|
64
|
+
* @returns 商品总价字符串,保留2位小数
|
|
65
|
+
*/
|
|
66
|
+
export declare const calculateOriginSubtotal: (items: CartItem[]) => string;
|
|
61
67
|
/**
|
|
62
68
|
* @title: 单个商品的税费
|
|
63
69
|
* @description:
|
|
@@ -20,6 +20,7 @@ import { isNormalProduct } from "../Product/utils";
|
|
|
20
20
|
import dayjs from 'dayjs';
|
|
21
21
|
export var calculatePriceDetails = function calculatePriceDetails(shopInfo, items, isInScheduleByDate, surchargeList, scheduleById) {
|
|
22
22
|
var subtotal = new Decimal(calculateSubtotal(items));
|
|
23
|
+
var subOriginTotal = new Decimal(calculateOriginSubtotal(items));
|
|
23
24
|
var totalTaxFee = new Decimal(calculateTaxFee(shopInfo, items));
|
|
24
25
|
// 订单附加费列表
|
|
25
26
|
var surcharge = getSurcharge({
|
|
@@ -58,11 +59,15 @@ export var calculatePriceDetails = function calculatePriceDetails(shopInfo, item
|
|
|
58
59
|
originTax = _getTax.originTax;
|
|
59
60
|
var total = shopInfo !== null && shopInfo !== void 0 && shopInfo.is_price_include_tax ? subtotal.plus(surchargeAmount) : subtotal.plus(tax).plus(surchargeAmount);
|
|
60
61
|
|
|
62
|
+
// 计算总价 不包含折扣卡商品券折扣信息价格
|
|
63
|
+
var originTotal = shopInfo !== null && shopInfo !== void 0 && shopInfo.is_price_include_tax ? subOriginTotal : subOriginTotal.plus(totalTaxFee);
|
|
64
|
+
|
|
61
65
|
// 计算定金
|
|
62
66
|
var deposit = calculateDeposit(items);
|
|
63
67
|
return {
|
|
64
68
|
subtotal: subtotal.toFixed(2),
|
|
65
69
|
total: total.toFixed(2),
|
|
70
|
+
originTotal: originTotal.toFixed(2),
|
|
66
71
|
taxTitle: shopInfo === null || shopInfo === void 0 ? void 0 : shopInfo.tax_title,
|
|
67
72
|
taxRate: shopInfo === null || shopInfo === void 0 ? void 0 : shopInfo.tax_rate,
|
|
68
73
|
totalTaxFee: tax,
|
|
@@ -572,6 +577,22 @@ export var calculateSubtotal = function calculateSubtotal(items) {
|
|
|
572
577
|
return subtotal.toFixed(2);
|
|
573
578
|
};
|
|
574
579
|
|
|
580
|
+
/**
|
|
581
|
+
* 计算商品小计(不含其他费用 不包含折扣卡商品券抵扣金额)
|
|
582
|
+
* @param items - 购物车商品数组
|
|
583
|
+
* @returns 商品总价字符串,保留2位小数
|
|
584
|
+
*/
|
|
585
|
+
export var calculateOriginSubtotal = function calculateOriginSubtotal(items) {
|
|
586
|
+
if (!(items !== null && items !== void 0 && items.length)) {
|
|
587
|
+
return '0.00';
|
|
588
|
+
}
|
|
589
|
+
var subtotal = items.reduce(function (sum, item) {
|
|
590
|
+
var cartItemTotalPrice = new Decimal(item.summaryOriginTotal || 0);
|
|
591
|
+
return sum.plus(cartItemTotalPrice);
|
|
592
|
+
}, new Decimal(0));
|
|
593
|
+
return subtotal.toFixed(2);
|
|
594
|
+
};
|
|
595
|
+
|
|
575
596
|
/**
|
|
576
597
|
* @title: 单个商品的税费
|
|
577
598
|
* @description:
|
package/dist/plugins/window.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WalletPassEvaluator } from '../model';
|
|
1
2
|
import { Plugin } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* WindowPlugin 接口定义
|
|
@@ -14,6 +15,7 @@ export interface WindowPlugin extends Plugin {
|
|
|
14
15
|
document: Partial<Document>;
|
|
15
16
|
history: History;
|
|
16
17
|
interaction?: any;
|
|
18
|
+
getWalletPassEvaluator?: () => WalletPassEvaluator;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* 简单的 Storage 接口实现
|
|
@@ -144,6 +144,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
144
144
|
getSummary(): Promise<{
|
|
145
145
|
subtotal: string | number;
|
|
146
146
|
total: string | number;
|
|
147
|
+
originTotal: string | number;
|
|
147
148
|
taxTitle?: string | undefined;
|
|
148
149
|
totalTaxFee?: string | number | undefined;
|
|
149
150
|
isPriceIncludeTax?: 0 | 1 | undefined;
|
|
@@ -310,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
310
311
|
date: string;
|
|
311
312
|
status: string;
|
|
312
313
|
week: string;
|
|
313
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
314
315
|
}[]>;
|
|
315
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
316
317
|
private getScheduleDataByIds;
|
|
@@ -403,6 +403,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
403
403
|
product_id: item.product_id,
|
|
404
404
|
product_variant_id: item.product_variant_id,
|
|
405
405
|
quantity: item.num,
|
|
406
|
+
is_price_include_tax: item.is_price_include_tax,
|
|
406
407
|
// 商品是否含税:1;0
|
|
407
408
|
is_charge_tax: (_item$is_charge_tax = item.is_charge_tax) !== null && _item$is_charge_tax !== void 0 ? _item$is_charge_tax : 0,
|
|
408
409
|
// 若商品不含税,计算得到的税费,单位(元)
|
|
@@ -427,6 +428,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
427
428
|
},
|
|
428
429
|
product_bundle: item.product_bundle.map(function (bundle) {
|
|
429
430
|
return {
|
|
431
|
+
is_price_include_tax: item.is_price_include_tax,
|
|
430
432
|
bundle_id: bundle.bundle_id,
|
|
431
433
|
bundle_product_id: bundle.bundle_product_id,
|
|
432
434
|
bundle_variant_id: bundle.bundle_variant_id,
|
|
@@ -22,6 +22,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
22
22
|
getCurrentBookingTime(): string | null;
|
|
23
23
|
private filterDiscountListByBookingTime;
|
|
24
24
|
setCustomer(customer: Customer): Promise<void>;
|
|
25
|
+
setOriginTotalAmount(amount: number): void;
|
|
25
26
|
setHolders(holders: {
|
|
26
27
|
form_record_id: number;
|
|
27
28
|
}[]): void;
|
|
@@ -38,6 +39,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
38
39
|
discountList: Discount[];
|
|
39
40
|
};
|
|
40
41
|
setProductList(productList: Record<string, any>[]): void;
|
|
42
|
+
batchSearchByProductIds(productIds: number[]): Promise<Discount[]>;
|
|
41
43
|
scanCode(code: string, customerId?: number): Promise<{
|
|
42
44
|
isAvailable: boolean;
|
|
43
45
|
productList: Record<string, any>[];
|
|
@@ -56,7 +56,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
56
56
|
originalDiscountList: [],
|
|
57
57
|
currentBookingTime: "",
|
|
58
58
|
filteredDiscountList: [],
|
|
59
|
-
bookingSubject: undefined
|
|
59
|
+
bookingSubject: undefined,
|
|
60
|
+
orderTotalAmount: 0
|
|
60
61
|
};
|
|
61
62
|
return _this;
|
|
62
63
|
}
|
|
@@ -288,7 +289,14 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
288
289
|
return _setCustomer.apply(this, arguments);
|
|
289
290
|
}
|
|
290
291
|
return setCustomer;
|
|
291
|
-
}()
|
|
292
|
+
}()
|
|
293
|
+
}, {
|
|
294
|
+
key: "setOriginTotalAmount",
|
|
295
|
+
value: function setOriginTotalAmount(amount) {
|
|
296
|
+
this.store.orderTotalAmount = amount;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// 设置holders
|
|
292
300
|
}, {
|
|
293
301
|
key: "setHolders",
|
|
294
302
|
value: function setHolders(holders) {
|
|
@@ -316,6 +324,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
316
324
|
var _ref = rulesModule.calcDiscount({
|
|
317
325
|
productList: productList,
|
|
318
326
|
discountList: this.getDiscountList(),
|
|
327
|
+
orderTotalAmount: this.store.orderTotalAmount || 0,
|
|
319
328
|
holders: this.store.holders || [],
|
|
320
329
|
isFormSubject: ((_this$store$bookingSu = this.store.bookingSubject) === null || _this$store$bookingSu === void 0 ? void 0 : _this$store$bookingSu.type) === 'form'
|
|
321
330
|
}, options) || {
|
|
@@ -384,34 +393,72 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
384
393
|
value: function setProductList(productList) {
|
|
385
394
|
this.store.productList = productList;
|
|
386
395
|
}
|
|
387
|
-
|
|
388
|
-
// 扫码输入code
|
|
389
396
|
}, {
|
|
390
|
-
key: "
|
|
397
|
+
key: "batchSearchByProductIds",
|
|
391
398
|
value: function () {
|
|
392
|
-
var
|
|
393
|
-
var _this$store$discount3
|
|
399
|
+
var _batchSearchByProductIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(productIds) {
|
|
400
|
+
var _this$store$discount3;
|
|
401
|
+
var resultDiscountList, currentDiscountList, newDiscountList;
|
|
394
402
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
395
403
|
while (1) switch (_context5.prev = _context5.next) {
|
|
396
404
|
case 0:
|
|
397
|
-
_context5.
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
case 3:
|
|
405
|
+
_context5.next = 2;
|
|
406
|
+
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.batchSearchByProductIds(productIds);
|
|
407
|
+
case 2:
|
|
401
408
|
_context5.t0 = _context5.sent;
|
|
402
409
|
if (_context5.t0) {
|
|
403
|
-
_context5.next =
|
|
410
|
+
_context5.next = 5;
|
|
404
411
|
break;
|
|
405
412
|
}
|
|
406
413
|
_context5.t0 = [];
|
|
407
|
-
case
|
|
414
|
+
case 5:
|
|
408
415
|
resultDiscountList = _context5.t0;
|
|
416
|
+
resultDiscountList = resultDiscountList.map(function (item) {
|
|
417
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
418
|
+
discount_rule_uncheck_flag: true
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
currentDiscountList = this.getDiscountList() || [];
|
|
422
|
+
newDiscountList = [].concat(_toConsumableArray(currentDiscountList), _toConsumableArray(resultDiscountList));
|
|
423
|
+
this.setDiscountList(newDiscountList);
|
|
424
|
+
return _context5.abrupt("return", newDiscountList);
|
|
425
|
+
case 11:
|
|
426
|
+
case "end":
|
|
427
|
+
return _context5.stop();
|
|
428
|
+
}
|
|
429
|
+
}, _callee5, this);
|
|
430
|
+
}));
|
|
431
|
+
function batchSearchByProductIds(_x4) {
|
|
432
|
+
return _batchSearchByProductIds.apply(this, arguments);
|
|
433
|
+
}
|
|
434
|
+
return batchSearchByProductIds;
|
|
435
|
+
}() // 扫码输入code
|
|
436
|
+
}, {
|
|
437
|
+
key: "scanCode",
|
|
438
|
+
value: function () {
|
|
439
|
+
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
440
|
+
var _this$store$discount4, _this$store$bookingSu2, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, unavailableReason, _this$options$otherPa6;
|
|
441
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
442
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
443
|
+
case 0:
|
|
444
|
+
_context6.prev = 0;
|
|
445
|
+
_context6.next = 3;
|
|
446
|
+
return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.batchSearch(code, customerId);
|
|
447
|
+
case 3:
|
|
448
|
+
_context6.t0 = _context6.sent;
|
|
449
|
+
if (_context6.t0) {
|
|
450
|
+
_context6.next = 6;
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
453
|
+
_context6.t0 = [];
|
|
454
|
+
case 6:
|
|
455
|
+
resultDiscountList = _context6.t0;
|
|
409
456
|
rulesModule = this.store.rules;
|
|
410
457
|
if (rulesModule) {
|
|
411
|
-
|
|
458
|
+
_context6.next = 10;
|
|
412
459
|
break;
|
|
413
460
|
}
|
|
414
|
-
return
|
|
461
|
+
return _context6.abrupt("return", {
|
|
415
462
|
type: "clientCalc",
|
|
416
463
|
isAvailable: false,
|
|
417
464
|
productList: this.store.productList || [],
|
|
@@ -420,10 +467,10 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
420
467
|
});
|
|
421
468
|
case 10:
|
|
422
469
|
if (resultDiscountList.length) {
|
|
423
|
-
|
|
470
|
+
_context6.next = 12;
|
|
424
471
|
break;
|
|
425
472
|
}
|
|
426
|
-
return
|
|
473
|
+
return _context6.abrupt("return", {
|
|
427
474
|
type: "server",
|
|
428
475
|
isAvailable: false,
|
|
429
476
|
productList: this.store.productList || [],
|
|
@@ -443,10 +490,10 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
443
490
|
return m.id === n.id;
|
|
444
491
|
});
|
|
445
492
|
}))) {
|
|
446
|
-
|
|
493
|
+
_context6.next = 16;
|
|
447
494
|
break;
|
|
448
495
|
}
|
|
449
|
-
return
|
|
496
|
+
return _context6.abrupt("return", {
|
|
450
497
|
type: "clientCalc",
|
|
451
498
|
isAvailable: true,
|
|
452
499
|
productList: this.store.productList || [],
|
|
@@ -457,6 +504,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
457
504
|
productList: this.store.productList || [],
|
|
458
505
|
oldDiscountList: this.getDiscountList(),
|
|
459
506
|
newDiscountList: withScanList,
|
|
507
|
+
orderTotalAmount: this.store.orderTotalAmount || 0,
|
|
460
508
|
holders: this.store.holders || [],
|
|
461
509
|
isFormSubject: ((_this$store$bookingSu2 = this.store.bookingSubject) === null || _this$store$bookingSu2 === void 0 ? void 0 : _this$store$bookingSu2.type) === 'form'
|
|
462
510
|
}) || {
|
|
@@ -465,20 +513,20 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
465
513
|
discountList: this.getDiscountList()
|
|
466
514
|
}, newProductList = _ref2.productList, newDiscountList = _ref2.discountList, isAvailable = _ref2.isAvailable, unavailableReason = _ref2.unavailableReason;
|
|
467
515
|
if (!isAvailable) {
|
|
468
|
-
|
|
516
|
+
_context6.next = 24;
|
|
469
517
|
break;
|
|
470
518
|
}
|
|
471
519
|
this.setDiscountList(newDiscountList || []);
|
|
472
520
|
this.store.originalDiscountList = newDiscountList || [];
|
|
473
521
|
this.setProductList(newProductList || []);
|
|
474
522
|
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
|
-
|
|
523
|
+
_context6.next = 24;
|
|
476
524
|
break;
|
|
477
525
|
}
|
|
478
|
-
|
|
526
|
+
_context6.next = 24;
|
|
479
527
|
return this.getCustomerWallet(resultDiscountList[0].customer_id);
|
|
480
528
|
case 24:
|
|
481
|
-
return
|
|
529
|
+
return _context6.abrupt("return", {
|
|
482
530
|
type: "clientCalc",
|
|
483
531
|
isAvailable: isAvailable || false,
|
|
484
532
|
productList: newProductList || this.store.productList || [],
|
|
@@ -486,10 +534,10 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
486
534
|
unavailableReason: unavailableReason
|
|
487
535
|
});
|
|
488
536
|
case 27:
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
console.error('[ShopDiscount] 扫码出错:',
|
|
492
|
-
return
|
|
537
|
+
_context6.prev = 27;
|
|
538
|
+
_context6.t1 = _context6["catch"](0);
|
|
539
|
+
console.error('[ShopDiscount] 扫码出错:', _context6.t1);
|
|
540
|
+
return _context6.abrupt("return", {
|
|
493
541
|
type: "clientCalc",
|
|
494
542
|
isAvailable: false,
|
|
495
543
|
productList: this.store.productList || [],
|
|
@@ -498,11 +546,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
498
546
|
});
|
|
499
547
|
case 31:
|
|
500
548
|
case "end":
|
|
501
|
-
return
|
|
549
|
+
return _context6.stop();
|
|
502
550
|
}
|
|
503
|
-
},
|
|
551
|
+
}, _callee6, this, [[0, 27]]);
|
|
504
552
|
}));
|
|
505
|
-
function scanCode(
|
|
553
|
+
function scanCode(_x5, _x6) {
|
|
506
554
|
return _scanCode.apply(this, arguments);
|
|
507
555
|
}
|
|
508
556
|
return scanCode;
|
|
@@ -510,8 +558,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
510
558
|
}, {
|
|
511
559
|
key: "calcDiscountApplicableProductTotalPrice",
|
|
512
560
|
value: function calcDiscountApplicableProductTotalPrice(discount) {
|
|
513
|
-
var _this$store$
|
|
514
|
-
return (_this$store$
|
|
561
|
+
var _this$store$discount5;
|
|
562
|
+
return (_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 ? void 0 : _this$store$discount5.calcDiscountApplicableProductTotalPrice(discount);
|
|
515
563
|
}
|
|
516
564
|
|
|
517
565
|
// =========== 私有辅助方法 ===========
|
|
@@ -535,19 +583,19 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
535
583
|
}, {
|
|
536
584
|
key: "emitDiscountListChange",
|
|
537
585
|
value: function () {
|
|
538
|
-
var _emitDiscountListChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
539
|
-
return _regeneratorRuntime().wrap(function
|
|
540
|
-
while (1) switch (
|
|
586
|
+
var _emitDiscountListChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(discountList) {
|
|
587
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
588
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
541
589
|
case 0:
|
|
542
|
-
|
|
590
|
+
_context7.next = 2;
|
|
543
591
|
return this.core.effects.emit("".concat(this.name, ":onDiscountListChange"), discountList);
|
|
544
592
|
case 2:
|
|
545
593
|
case "end":
|
|
546
|
-
return
|
|
594
|
+
return _context7.stop();
|
|
547
595
|
}
|
|
548
|
-
},
|
|
596
|
+
}, _callee7, this);
|
|
549
597
|
}));
|
|
550
|
-
function emitDiscountListChange(
|
|
598
|
+
function emitDiscountListChange(_x7) {
|
|
551
599
|
return _emitDiscountListChange.apply(this, arguments);
|
|
552
600
|
}
|
|
553
601
|
return emitDiscountListChange;
|
|
@@ -556,7 +604,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
556
604
|
key: "setDiscountList",
|
|
557
605
|
value: function setDiscountList(discountList) {
|
|
558
606
|
var _this3 = this,
|
|
559
|
-
_this$store$
|
|
607
|
+
_this$store$discount6;
|
|
560
608
|
var productList = this.store.productList || [];
|
|
561
609
|
var editModeDiscountList = [];
|
|
562
610
|
productList.forEach(function (item) {
|
|
@@ -570,21 +618,27 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
570
618
|
return n.id === (((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id);
|
|
571
619
|
});
|
|
572
620
|
if (index !== -1) {
|
|
573
|
-
var _discount$metadata;
|
|
621
|
+
var _editModeDiscountList, _discount$metadata, _discount$metadata2;
|
|
574
622
|
editModeDiscountList[index] = _objectSpread(_objectSpread({}, editModeDiscountList[index]), {}, {
|
|
623
|
+
metadata: _objectSpread(_objectSpread({}, discount.metadata || {}), {}, {
|
|
624
|
+
num: ((editModeDiscountList === null || editModeDiscountList === void 0 || (_editModeDiscountList = editModeDiscountList[index]) === null || _editModeDiscountList === void 0 || (_editModeDiscountList = _editModeDiscountList.metadata) === null || _editModeDiscountList === void 0 ? void 0 : _editModeDiscountList.num) || 1) + (((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.num) || 1)
|
|
625
|
+
}),
|
|
575
626
|
amount: new Decimal(discount.amount || 0).plus(new Decimal(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
576
|
-
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$
|
|
627
|
+
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.product_discount_difference) || 0).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
577
628
|
});
|
|
578
629
|
} else {
|
|
579
|
-
var _discount$
|
|
630
|
+
var _discount$metadata3, _discount$metadata4, _discount$discount2, _discount$discount3, _discount$discount4;
|
|
580
631
|
if (discount.type && !discount.tag) {
|
|
581
632
|
discount.tag = discount.type;
|
|
582
633
|
}
|
|
583
634
|
editModeDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
|
|
635
|
+
metadata: _objectSpread(_objectSpread({}, discount.metadata || {}), {}, {
|
|
636
|
+
num: ((_discount$metadata3 = discount.metadata) === null || _discount$metadata3 === void 0 ? void 0 : _discount$metadata3.num) || 1
|
|
637
|
+
}),
|
|
584
638
|
name: discount.name || discount.discount.title.auto,
|
|
585
639
|
isEditMode: true,
|
|
586
640
|
limited_relation_product_data: {},
|
|
587
|
-
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$
|
|
641
|
+
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata4 = discount.metadata) === null || _discount$metadata4 === void 0 ? void 0 : _discount$metadata4.product_discount_difference) || 0).toNumber(),
|
|
588
642
|
isAvailable: true,
|
|
589
643
|
id: ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) || discount.id,
|
|
590
644
|
format_title: ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.title) || discount.format_title,
|
|
@@ -639,7 +693,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
639
693
|
item.isDisabledForProductUsed = false;
|
|
640
694
|
}
|
|
641
695
|
});
|
|
642
|
-
(_this$store$
|
|
696
|
+
(_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 || _this$store$discount6.setDiscountList(newDiscountList);
|
|
643
697
|
this.emitDiscountListChange(newDiscountList);
|
|
644
698
|
return newDiscountList;
|
|
645
699
|
}
|
|
@@ -648,48 +702,48 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
648
702
|
}, {
|
|
649
703
|
key: "getDiscountList",
|
|
650
704
|
value: function getDiscountList() {
|
|
651
|
-
var _this$store$
|
|
652
|
-
return ((_this$store$
|
|
705
|
+
var _this$store$discount7;
|
|
706
|
+
return ((_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.getDiscountList()) || [];
|
|
653
707
|
}
|
|
654
708
|
|
|
655
709
|
// 获取客户钱包信息
|
|
656
710
|
}, {
|
|
657
711
|
key: "getCustomerWallet",
|
|
658
712
|
value: function () {
|
|
659
|
-
var _getCustomerWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
713
|
+
var _getCustomerWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(id) {
|
|
660
714
|
var _result, customer;
|
|
661
|
-
return _regeneratorRuntime().wrap(function
|
|
662
|
-
while (1) switch (
|
|
715
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
716
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
663
717
|
case 0:
|
|
664
|
-
|
|
665
|
-
|
|
718
|
+
_context8.prev = 0;
|
|
719
|
+
_context8.next = 3;
|
|
666
720
|
return this.request.get("/customer/info/".concat(id), {
|
|
667
721
|
with_trashed: 1
|
|
668
722
|
});
|
|
669
723
|
case 3:
|
|
670
|
-
_result =
|
|
724
|
+
_result = _context8.sent;
|
|
671
725
|
if (!(_result !== null && _result !== void 0 && _result.data)) {
|
|
672
|
-
|
|
726
|
+
_context8.next = 9;
|
|
673
727
|
break;
|
|
674
728
|
}
|
|
675
729
|
customer = Object.assign({}, (_objectDestructuringEmpty(_result.data), _result.data));
|
|
676
730
|
this.setCustomer(customer);
|
|
677
|
-
|
|
731
|
+
_context8.next = 9;
|
|
678
732
|
return this.core.effects.emit("".concat(this.name, ":onScanCustomerChange"), customer);
|
|
679
733
|
case 9:
|
|
680
|
-
|
|
734
|
+
_context8.next = 14;
|
|
681
735
|
break;
|
|
682
736
|
case 11:
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
console.error('[ShopDiscount] 获取客户钱包信息出错:',
|
|
737
|
+
_context8.prev = 11;
|
|
738
|
+
_context8.t0 = _context8["catch"](0);
|
|
739
|
+
console.error('[ShopDiscount] 获取客户钱包信息出错:', _context8.t0);
|
|
686
740
|
case 14:
|
|
687
741
|
case "end":
|
|
688
|
-
return
|
|
742
|
+
return _context8.stop();
|
|
689
743
|
}
|
|
690
|
-
},
|
|
744
|
+
}, _callee8, this, [[0, 11]]);
|
|
691
745
|
}));
|
|
692
|
-
function getCustomerWallet(
|
|
746
|
+
function getCustomerWallet(_x8) {
|
|
693
747
|
return _getCustomerWallet.apply(this, arguments);
|
|
694
748
|
}
|
|
695
749
|
return getCustomerWallet;
|
|
@@ -697,32 +751,32 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
697
751
|
}, {
|
|
698
752
|
key: "bestDiscount",
|
|
699
753
|
value: function () {
|
|
700
|
-
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
754
|
+
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(cb) {
|
|
701
755
|
var _this$store$productLi;
|
|
702
756
|
var newDiscountList, _result2;
|
|
703
|
-
return _regeneratorRuntime().wrap(function
|
|
704
|
-
while (1) switch (
|
|
757
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
758
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
705
759
|
case 0:
|
|
706
760
|
newDiscountList = this.store.originalDiscountList;
|
|
707
761
|
this.setDiscountList(newDiscountList);
|
|
708
762
|
if (!((_this$store$productLi = this.store.productList) !== null && _this$store$productLi !== void 0 && _this$store$productLi.length)) {
|
|
709
|
-
|
|
763
|
+
_context9.next = 7;
|
|
710
764
|
break;
|
|
711
765
|
}
|
|
712
766
|
_result2 = this.calcDiscount(this.store.productList);
|
|
713
767
|
cb === null || cb === void 0 || cb(_result2);
|
|
714
|
-
|
|
768
|
+
_context9.next = 7;
|
|
715
769
|
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result2);
|
|
716
770
|
case 7:
|
|
717
|
-
|
|
771
|
+
_context9.next = 9;
|
|
718
772
|
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), newDiscountList);
|
|
719
773
|
case 9:
|
|
720
774
|
case "end":
|
|
721
|
-
return
|
|
775
|
+
return _context9.stop();
|
|
722
776
|
}
|
|
723
|
-
},
|
|
777
|
+
}, _callee9, this);
|
|
724
778
|
}));
|
|
725
|
-
function bestDiscount(
|
|
779
|
+
function bestDiscount(_x9) {
|
|
726
780
|
return _bestDiscount.apply(this, arguments);
|
|
727
781
|
}
|
|
728
782
|
return bestDiscount;
|
|
@@ -730,17 +784,17 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
730
784
|
}, {
|
|
731
785
|
key: "loadPrepareConfig",
|
|
732
786
|
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 (
|
|
787
|
+
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
788
|
+
var _this$getCustomer2, _this$store$discount8, _this$getDiscountList, _this$store$discount9, _this$store$productLi2, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
|
|
789
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
790
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
737
791
|
case 0:
|
|
738
|
-
|
|
792
|
+
_context10.prev = 0;
|
|
739
793
|
customerId = params.customerId || ((_this$getCustomer2 = this.getCustomer()) === null || _this$getCustomer2 === void 0 ? void 0 : _this$getCustomer2.id); // if (customerId === 1 || !customerId) {
|
|
740
794
|
// return
|
|
741
795
|
// }
|
|
742
|
-
|
|
743
|
-
return (_this$store$
|
|
796
|
+
_context10.next = 4;
|
|
797
|
+
return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.loadPrepareConfig({
|
|
744
798
|
customer_id: customerId,
|
|
745
799
|
action: 'create',
|
|
746
800
|
with_good_pass: 1,
|
|
@@ -749,7 +803,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
749
803
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
750
804
|
});
|
|
751
805
|
case 4:
|
|
752
|
-
goodPassList =
|
|
806
|
+
goodPassList = _context10.sent;
|
|
753
807
|
scanDiscount = (_this$getDiscountList = this.getDiscountList()) === null || _this$getDiscountList === void 0 ? void 0 : _this$getDiscountList.filter(function (item) {
|
|
754
808
|
return item.isScan;
|
|
755
809
|
}); // goodPassList 里可能有 scanDiscount 重合的部分,goodPassList 需要剔除
|
|
@@ -761,37 +815,37 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
761
815
|
});
|
|
762
816
|
newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || [])); // 存储原始优惠券列表
|
|
763
817
|
this.store.originalDiscountList = newDiscountList;
|
|
764
|
-
|
|
765
|
-
return (_this$store$
|
|
818
|
+
_context10.next = 12;
|
|
819
|
+
return (_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.setOriginalDiscountList(newDiscountList);
|
|
766
820
|
case 12:
|
|
767
821
|
// 根据当前预约时间过滤优惠券列表
|
|
768
822
|
filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
|
|
769
823
|
this.store.filteredDiscountList = filteredDiscountList;
|
|
770
824
|
this.setDiscountList(filteredDiscountList || []);
|
|
771
825
|
if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
|
|
772
|
-
|
|
826
|
+
_context10.next = 19;
|
|
773
827
|
break;
|
|
774
828
|
}
|
|
775
829
|
_result3 = this.calcDiscount(this.store.productList);
|
|
776
|
-
|
|
830
|
+
_context10.next = 19;
|
|
777
831
|
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
|
|
778
832
|
case 19:
|
|
779
|
-
|
|
780
|
-
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"),
|
|
833
|
+
_context10.next = 21;
|
|
834
|
+
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), newDiscountList);
|
|
781
835
|
case 21:
|
|
782
|
-
|
|
836
|
+
_context10.next = 26;
|
|
783
837
|
break;
|
|
784
838
|
case 23:
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
console.error('[ShopDiscount] 加载准备配置出错:',
|
|
839
|
+
_context10.prev = 23;
|
|
840
|
+
_context10.t0 = _context10["catch"](0);
|
|
841
|
+
console.error('[ShopDiscount] 加载准备配置出错:', _context10.t0);
|
|
788
842
|
case 26:
|
|
789
843
|
case "end":
|
|
790
|
-
return
|
|
844
|
+
return _context10.stop();
|
|
791
845
|
}
|
|
792
|
-
},
|
|
846
|
+
}, _callee10, this, [[0, 23]]);
|
|
793
847
|
}));
|
|
794
|
-
function loadPrepareConfig(
|
|
848
|
+
function loadPrepareConfig(_x10) {
|
|
795
849
|
return _loadPrepareConfig.apply(this, arguments);
|
|
796
850
|
}
|
|
797
851
|
return loadPrepareConfig;
|
|
@@ -8,4 +8,5 @@ export var ShopDiscountHooks = /*#__PURE__*/function (ShopDiscountHooks) {
|
|
|
8
8
|
ShopDiscountHooks["onRulesListChange"] = "shopDiscount:onRulesListChange";
|
|
9
9
|
ShopDiscountHooks["onLoadPrepareCalcResult"] = "shopDiscount:onLoadPrepareCalcResult";
|
|
10
10
|
return ShopDiscountHooks;
|
|
11
|
-
}({});
|
|
11
|
+
}({});
|
|
12
|
+
;
|