@pisell/pisellos 2.2.13 → 2.2.14
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.js +1 -1
- package/dist/modules/Payment/index.js +84 -82
- package/dist/modules/Payment/types.d.ts +0 -1
- package/dist/modules/Payment/walletpass.js +1 -3
- package/dist/modules/ProductList/index.js +9 -8
- package/dist/modules/Rules/index.js +34 -66
- package/dist/solution/BookingByStep/index.js +8 -29
- package/dist/solution/BookingByStep/utils/products.d.ts +0 -6
- package/dist/solution/BookingByStep/utils/products.js +0 -10
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Checkout/index.js +21 -65
- package/dist/solution/Checkout/utils/index.d.ts +2 -1
- package/dist/solution/Checkout/utils/index.js +6 -4
- package/lib/modules/Customer/index.js +1 -1
- package/lib/modules/Payment/index.js +5 -3
- package/lib/modules/Payment/types.d.ts +0 -1
- package/lib/modules/Payment/walletpass.js +1 -10
- package/lib/modules/ProductList/index.js +7 -0
- package/lib/modules/Rules/index.js +36 -46
- package/lib/solution/BookingByStep/index.js +2 -15
- package/lib/solution/BookingByStep/utils/products.d.ts +0 -6
- package/lib/solution/BookingByStep/utils/products.js +2 -8
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Checkout/index.js +20 -69
- package/lib/solution/Checkout/utils/index.d.ts +2 -1
- package/lib/solution/Checkout/utils/index.js +6 -4
- package/package.json +2 -2
|
@@ -154,7 +154,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
154
154
|
skip: skip,
|
|
155
155
|
num: num,
|
|
156
156
|
sort_by: SORT_BY,
|
|
157
|
-
with: ['latestWalletDetail.wallet'
|
|
157
|
+
with: ['latestWalletDetail.wallet'],
|
|
158
158
|
search_wallet_flag: 1,
|
|
159
159
|
search_wallet_pass_flag: 1
|
|
160
160
|
}, search && {
|
|
@@ -21,7 +21,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
21
21
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
22
22
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
23
23
|
import { BaseModule } from "../BaseModule";
|
|
24
|
-
import { PaymentStatus, PaymentMethodType, RoundingRule } from "./types";
|
|
24
|
+
import { PaymentStatus, PaymentHooks, PaymentMethodType, RoundingRule } from "./types";
|
|
25
25
|
import { getUniqueId } from "../Cart/utils";
|
|
26
26
|
import { CashPaymentImpl } from "./cash";
|
|
27
27
|
import { EftposPaymentImpl } from "./eftpos";
|
|
@@ -312,66 +312,67 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
312
312
|
return _context3.abrupt("return", cachedMethods);
|
|
313
313
|
case 16:
|
|
314
314
|
_context3.next = 18;
|
|
315
|
-
return this.request.get('/pay/custom-payment/
|
|
316
|
-
channel: 'pos'
|
|
317
|
-
});
|
|
315
|
+
return this.request.get('/pay/custom-payment/all');
|
|
318
316
|
case 18:
|
|
319
317
|
response = _context3.sent;
|
|
318
|
+
response.data = response.data.filter(function (method) {
|
|
319
|
+
return method.status === 1 && method.disable === 0;
|
|
320
|
+
});
|
|
320
321
|
payMethods = response.data || []; // 尝试缓存到 IndexDB
|
|
321
|
-
_context3.prev =
|
|
322
|
+
_context3.prev = 21;
|
|
322
323
|
_iterator = _createForOfIteratorHelper(payMethods);
|
|
323
|
-
_context3.prev =
|
|
324
|
+
_context3.prev = 23;
|
|
324
325
|
_iterator.s();
|
|
325
|
-
case
|
|
326
|
+
case 25:
|
|
326
327
|
if ((_step = _iterator.n()).done) {
|
|
327
|
-
_context3.next =
|
|
328
|
+
_context3.next = 31;
|
|
328
329
|
break;
|
|
329
330
|
}
|
|
330
331
|
method = _step.value;
|
|
331
|
-
_context3.next =
|
|
332
|
+
_context3.next = 29;
|
|
332
333
|
return this.dbManager.update('pay_method', method);
|
|
333
|
-
case
|
|
334
|
-
_context3.next =
|
|
334
|
+
case 29:
|
|
335
|
+
_context3.next = 25;
|
|
335
336
|
break;
|
|
336
|
-
case
|
|
337
|
-
_context3.next =
|
|
337
|
+
case 31:
|
|
338
|
+
_context3.next = 36;
|
|
338
339
|
break;
|
|
339
|
-
case
|
|
340
|
-
_context3.prev =
|
|
341
|
-
_context3.t1 = _context3["catch"](
|
|
340
|
+
case 33:
|
|
341
|
+
_context3.prev = 33;
|
|
342
|
+
_context3.t1 = _context3["catch"](23);
|
|
342
343
|
_iterator.e(_context3.t1);
|
|
343
|
-
case
|
|
344
|
-
_context3.prev =
|
|
344
|
+
case 36:
|
|
345
|
+
_context3.prev = 36;
|
|
345
346
|
_iterator.f();
|
|
346
|
-
return _context3.finish(
|
|
347
|
-
case
|
|
348
|
-
_context3.next =
|
|
347
|
+
return _context3.finish(36);
|
|
348
|
+
case 39:
|
|
349
|
+
_context3.next = 44;
|
|
349
350
|
break;
|
|
350
|
-
case
|
|
351
|
-
_context3.prev =
|
|
352
|
-
_context3.t2 = _context3["catch"](
|
|
351
|
+
case 41:
|
|
352
|
+
_context3.prev = 41;
|
|
353
|
+
_context3.t2 = _context3["catch"](21);
|
|
353
354
|
console.warn('[PaymentModule] 无法缓存支付方式,pay_method 表不存在');
|
|
354
|
-
case
|
|
355
|
-
_context3.next =
|
|
355
|
+
case 44:
|
|
356
|
+
_context3.next = 46;
|
|
356
357
|
return this.core.effects.emit("".concat(this.name, ":onPaymentMethodsLoaded"), payMethods);
|
|
357
|
-
case
|
|
358
|
+
case 46:
|
|
358
359
|
this.logInfo('getPayMethodListAsync completed successfully', {
|
|
359
360
|
methodCount: payMethods.length,
|
|
360
361
|
hasCache: cachedMethods.length > 0
|
|
361
362
|
});
|
|
362
363
|
return _context3.abrupt("return", payMethods);
|
|
363
|
-
case
|
|
364
|
-
_context3.prev =
|
|
364
|
+
case 50:
|
|
365
|
+
_context3.prev = 50;
|
|
365
366
|
_context3.t3 = _context3["catch"](1);
|
|
366
367
|
console.error('[PaymentModule] 获取支付方式列表失败', _context3.t3);
|
|
367
368
|
this.logError('getPayMethodListAsync failed', _context3.t3);
|
|
368
369
|
// 如果所有操作都失败,返回空数组
|
|
369
370
|
return _context3.abrupt("return", []);
|
|
370
|
-
case
|
|
371
|
+
case 55:
|
|
371
372
|
case "end":
|
|
372
373
|
return _context3.stop();
|
|
373
374
|
}
|
|
374
|
-
}, _callee3, this, [[1,
|
|
375
|
+
}, _callee3, this, [[1, 50], [3, 9], [21, 41], [23, 33, 36, 39]]);
|
|
375
376
|
}));
|
|
376
377
|
function getPayMethodListAsync() {
|
|
377
378
|
return _getPayMethodListAsync.apply(this, arguments);
|
|
@@ -398,15 +399,16 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
398
399
|
|
|
399
400
|
// 从服务器获取最新数据
|
|
400
401
|
_context4.next = 5;
|
|
401
|
-
return this.request.get('/pay/custom-payment/
|
|
402
|
-
channel: 'pos'
|
|
403
|
-
});
|
|
402
|
+
return this.request.get('/pay/custom-payment/all');
|
|
404
403
|
case 5:
|
|
405
404
|
response = _context4.sent;
|
|
405
|
+
response.data = response.data.filter(function (method) {
|
|
406
|
+
return method.status === 1 && method.disable === 0;
|
|
407
|
+
});
|
|
406
408
|
newPayMethods = response.data || []; // 检查是否有变化
|
|
407
409
|
hasChanges = this.hasPaymentMethodsChanged(cachedMethods, newPayMethods);
|
|
408
410
|
if (!hasChanges) {
|
|
409
|
-
_context4.next =
|
|
411
|
+
_context4.next = 57;
|
|
410
412
|
break;
|
|
411
413
|
}
|
|
412
414
|
console.log('[PaymentModule] 支付方式列表已更新');
|
|
@@ -416,92 +418,92 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
416
418
|
});
|
|
417
419
|
|
|
418
420
|
// 更新缓存
|
|
419
|
-
_context4.prev =
|
|
421
|
+
_context4.prev = 12;
|
|
420
422
|
// 先清除旧数据
|
|
421
423
|
_iterator2 = _createForOfIteratorHelper(cachedMethods);
|
|
422
|
-
_context4.prev =
|
|
424
|
+
_context4.prev = 14;
|
|
423
425
|
_iterator2.s();
|
|
424
|
-
case
|
|
426
|
+
case 16:
|
|
425
427
|
if ((_step2 = _iterator2.n()).done) {
|
|
426
|
-
_context4.next =
|
|
428
|
+
_context4.next = 22;
|
|
427
429
|
break;
|
|
428
430
|
}
|
|
429
431
|
method = _step2.value;
|
|
430
|
-
_context4.next =
|
|
432
|
+
_context4.next = 20;
|
|
431
433
|
return this.dbManager.delete('pay_method', method.id);
|
|
432
|
-
case
|
|
433
|
-
_context4.next =
|
|
434
|
+
case 20:
|
|
435
|
+
_context4.next = 16;
|
|
434
436
|
break;
|
|
435
|
-
case
|
|
436
|
-
_context4.next =
|
|
437
|
+
case 22:
|
|
438
|
+
_context4.next = 27;
|
|
437
439
|
break;
|
|
438
|
-
case
|
|
439
|
-
_context4.prev =
|
|
440
|
-
_context4.t0 = _context4["catch"](
|
|
440
|
+
case 24:
|
|
441
|
+
_context4.prev = 24;
|
|
442
|
+
_context4.t0 = _context4["catch"](14);
|
|
441
443
|
_iterator2.e(_context4.t0);
|
|
442
|
-
case
|
|
443
|
-
_context4.prev =
|
|
444
|
+
case 27:
|
|
445
|
+
_context4.prev = 27;
|
|
444
446
|
_iterator2.f();
|
|
445
|
-
return _context4.finish(
|
|
446
|
-
case
|
|
447
|
+
return _context4.finish(27);
|
|
448
|
+
case 30:
|
|
447
449
|
// 添加新数据
|
|
448
450
|
_iterator3 = _createForOfIteratorHelper(newPayMethods);
|
|
449
|
-
_context4.prev =
|
|
451
|
+
_context4.prev = 31;
|
|
450
452
|
_iterator3.s();
|
|
451
|
-
case
|
|
453
|
+
case 33:
|
|
452
454
|
if ((_step3 = _iterator3.n()).done) {
|
|
453
|
-
_context4.next =
|
|
455
|
+
_context4.next = 39;
|
|
454
456
|
break;
|
|
455
457
|
}
|
|
456
458
|
_method = _step3.value;
|
|
457
|
-
_context4.next =
|
|
459
|
+
_context4.next = 37;
|
|
458
460
|
return this.dbManager.update('pay_method', _method);
|
|
459
|
-
case
|
|
460
|
-
_context4.next =
|
|
461
|
+
case 37:
|
|
462
|
+
_context4.next = 33;
|
|
461
463
|
break;
|
|
462
|
-
case
|
|
463
|
-
_context4.next =
|
|
464
|
+
case 39:
|
|
465
|
+
_context4.next = 44;
|
|
464
466
|
break;
|
|
465
|
-
case
|
|
466
|
-
_context4.prev =
|
|
467
|
-
_context4.t1 = _context4["catch"](
|
|
467
|
+
case 41:
|
|
468
|
+
_context4.prev = 41;
|
|
469
|
+
_context4.t1 = _context4["catch"](31);
|
|
468
470
|
_iterator3.e(_context4.t1);
|
|
469
|
-
case
|
|
470
|
-
_context4.prev =
|
|
471
|
+
case 44:
|
|
472
|
+
_context4.prev = 44;
|
|
471
473
|
_iterator3.f();
|
|
472
|
-
return _context4.finish(
|
|
473
|
-
case
|
|
474
|
-
_context4.next =
|
|
474
|
+
return _context4.finish(44);
|
|
475
|
+
case 47:
|
|
476
|
+
_context4.next = 52;
|
|
475
477
|
break;
|
|
476
|
-
case
|
|
477
|
-
_context4.prev =
|
|
478
|
-
_context4.t2 = _context4["catch"](
|
|
478
|
+
case 49:
|
|
479
|
+
_context4.prev = 49;
|
|
480
|
+
_context4.t2 = _context4["catch"](12);
|
|
479
481
|
console.warn('[PaymentModule] 无法更新支付方式缓存', _context4.t2);
|
|
480
|
-
case
|
|
482
|
+
case 52:
|
|
481
483
|
// 通知外部支付方式已变化
|
|
482
484
|
eventData = {
|
|
483
485
|
oldMethods: cachedMethods,
|
|
484
486
|
newMethods: newPayMethods
|
|
485
487
|
};
|
|
486
|
-
_context4.next =
|
|
488
|
+
_context4.next = 55;
|
|
487
489
|
return this.core.effects.emit("".concat(this.name, ":onPaymentMethodsChanged"), eventData);
|
|
488
|
-
case
|
|
489
|
-
_context4.next =
|
|
490
|
+
case 55:
|
|
491
|
+
_context4.next = 58;
|
|
490
492
|
break;
|
|
491
|
-
case 56:
|
|
492
|
-
console.log('[PaymentModule] 支付方式列表无变化');
|
|
493
493
|
case 57:
|
|
494
|
-
|
|
494
|
+
console.log('[PaymentModule] 支付方式列表无变化');
|
|
495
|
+
case 58:
|
|
496
|
+
_context4.next = 63;
|
|
495
497
|
break;
|
|
496
|
-
case
|
|
497
|
-
_context4.prev =
|
|
498
|
+
case 60:
|
|
499
|
+
_context4.prev = 60;
|
|
498
500
|
_context4.t3 = _context4["catch"](1);
|
|
499
501
|
console.error('[PaymentModule] 后台刷新支付方式失败', _context4.t3);
|
|
500
|
-
case
|
|
502
|
+
case 63:
|
|
501
503
|
case "end":
|
|
502
504
|
return _context4.stop();
|
|
503
505
|
}
|
|
504
|
-
}, _callee4, this, [[1,
|
|
506
|
+
}, _callee4, this, [[1, 60], [12, 49], [14, 24, 27, 30], [31, 41, 44, 47]]);
|
|
505
507
|
}));
|
|
506
508
|
function refreshPaymentMethodsInBackground(_x4) {
|
|
507
509
|
return _refreshPaymentMethodsInBackground.apply(this, arguments);
|
|
@@ -1200,7 +1202,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1200
1202
|
this.logInfo('更新订单支付项完成', {
|
|
1201
1203
|
orderUuid: orderUuid
|
|
1202
1204
|
});
|
|
1203
|
-
this.core.effects.emit(
|
|
1205
|
+
this.core.effects.emit(PaymentHooks.OnPaymentAdded, {
|
|
1204
1206
|
orderUuid: orderUuid,
|
|
1205
1207
|
payment: newPaymentItem
|
|
1206
1208
|
});
|
|
@@ -64,14 +64,12 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
64
64
|
amountInfo = businessData.amountInfo,
|
|
65
65
|
products = businessData.products,
|
|
66
66
|
order_wait_pay_amount = businessData.order_wait_pay_amount,
|
|
67
|
-
payment_order_id = businessData.payment_order_id
|
|
68
|
-
is_price_include_tax = businessData.is_price_include_tax;
|
|
67
|
+
payment_order_id = businessData.payment_order_id;
|
|
69
68
|
|
|
70
69
|
// 转换金额为数字类型
|
|
71
70
|
var totalAmount = Number(amountInfo.totalAmount);
|
|
72
71
|
var subTotal = Number(amountInfo.subTotal);
|
|
73
72
|
var walletParams = {
|
|
74
|
-
is_price_include_tax: is_price_include_tax,
|
|
75
73
|
sale_channel: 'pos',
|
|
76
74
|
customer_id: customer_id || 0,
|
|
77
75
|
// 提供默认值,确保类型为 number
|
|
@@ -140,16 +140,17 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
140
140
|
productsData = _context3.sent;
|
|
141
141
|
sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
|
|
142
142
|
return Number(b.sort) - Number(a.sort);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
143
|
+
});
|
|
144
|
+
if (sortedList.length) {
|
|
145
|
+
sortedList.forEach(function (n) {
|
|
146
|
+
if (n.is_eject !== 1 && n['schedule.ids'] && n['schedule.ids'].length) {
|
|
147
|
+
n.is_eject = 1;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
150
151
|
this.addProduct(sortedList);
|
|
151
152
|
return _context3.abrupt("return", sortedList);
|
|
152
|
-
case
|
|
153
|
+
case 11:
|
|
153
154
|
case "end":
|
|
154
155
|
return _context3.stop();
|
|
155
156
|
}
|
|
@@ -24,12 +24,10 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
24
24
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
25
25
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
26
26
|
import { BaseModule } from "../BaseModule";
|
|
27
|
-
import { uniqueById, getDiscountAmount,
|
|
27
|
+
import { uniqueById, getDiscountAmount, getDiscountListAmountTotal, getDiscountListAmount, filterDiscountListByBookingTime } from "../../solution/ShopDiscount/utils";
|
|
28
28
|
import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils";
|
|
29
29
|
import Decimal from 'decimal.js';
|
|
30
|
-
import { isBoolean } from 'lodash-es';
|
|
31
30
|
import dayjs from 'dayjs';
|
|
32
|
-
|
|
33
31
|
// 临时变量
|
|
34
32
|
var flatItem;
|
|
35
33
|
export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
@@ -449,7 +447,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
449
447
|
var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
|
|
450
448
|
|
|
451
449
|
// 判断优惠券是否适用于该商品
|
|
452
|
-
if (isAvailableProduct && isLimitedProduct &&
|
|
450
|
+
if (isAvailableProduct && isLimitedProduct && isBundleAvailable && timeLimit) {
|
|
453
451
|
var _discountApplicabilit, _discount$metadata;
|
|
454
452
|
// 记录此优惠券适用的商品
|
|
455
453
|
(_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
|
|
@@ -490,7 +488,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
490
488
|
// 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
|
|
491
489
|
// 🔥 使用扁平化后的列表进行处理
|
|
492
490
|
sortedFlattenedList.forEach(function (flatItem, index) {
|
|
493
|
-
var _product5, _product$discount_lis2, _product6;
|
|
491
|
+
var _product5, _product$discount_lis2, _product6, _product$discount_lis10;
|
|
494
492
|
// 获取商品数据
|
|
495
493
|
var product, originProduct;
|
|
496
494
|
if (flatItem.type === 'main') {
|
|
@@ -539,7 +537,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
539
537
|
})) && (discount.tag || discount.type) === 'good_pass') return false;
|
|
540
538
|
|
|
541
539
|
// 折扣卡商品价格为0时不可用
|
|
542
|
-
if ((Number(product.price)
|
|
540
|
+
if ((Number(product.price) === 0 || !product.price) && !((_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.find(function (n) {
|
|
543
541
|
var _n$discount2;
|
|
544
542
|
return ((_n$discount2 = n.discount) === null || _n$discount2 === void 0 ? void 0 : _n$discount2.resource_id) === discount.id;
|
|
545
543
|
})) && (discount.tag || discount.type) !== 'good_pass') return false;
|
|
@@ -666,9 +664,18 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
666
664
|
}
|
|
667
665
|
}
|
|
668
666
|
}
|
|
667
|
+
if (options !== null && options !== void 0 && options.selectedList && (_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.some(function (item) {
|
|
668
|
+
var _options$selectedList4;
|
|
669
|
+
return options === null || options === void 0 || (_options$selectedList4 = options.selectedList) === null || _options$selectedList4 === void 0 ? void 0 : _options$selectedList4.some(function (n) {
|
|
670
|
+
var _item$discount7;
|
|
671
|
+
return n.discountId === ((_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.resource_id);
|
|
672
|
+
});
|
|
673
|
+
})) {
|
|
674
|
+
isManualDiscount = false;
|
|
675
|
+
}
|
|
669
676
|
|
|
670
677
|
// 如果没有适用的优惠券,或者手动折扣,则不适用优惠券
|
|
671
|
-
if (applicableDiscounts.length === 0 || isManualDiscount
|
|
678
|
+
if (applicableDiscounts.length === 0 || isManualDiscount) {
|
|
672
679
|
if (flatItem.type === 'main') {
|
|
673
680
|
// 主商品:保持原有逻辑
|
|
674
681
|
if (product.isClient) {
|
|
@@ -694,10 +701,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
694
701
|
discount_list: []
|
|
695
702
|
}))]);
|
|
696
703
|
} else {
|
|
697
|
-
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
|
|
698
|
-
price: product.price,
|
|
699
|
-
main_product_selling_price: product.price
|
|
700
|
-
} : {
|
|
704
|
+
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {} : {
|
|
701
705
|
_id: product._id.split('___')[0] + '___' + index,
|
|
702
706
|
total: product.origin_total || product.total,
|
|
703
707
|
price: product.price,
|
|
@@ -710,7 +714,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
710
714
|
// bundle子商品:保存到扁平化Map
|
|
711
715
|
processedFlatItemsMap.set(flatItem._id, [_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
712
716
|
discount_list: [],
|
|
713
|
-
price:
|
|
717
|
+
price: flatItem.bundleItem.original_price,
|
|
714
718
|
processed: true
|
|
715
719
|
})]);
|
|
716
720
|
}
|
|
@@ -742,7 +746,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
742
746
|
}));
|
|
743
747
|
}
|
|
744
748
|
for (var i = 0; i < splitCount; i++) {
|
|
745
|
-
var _product$
|
|
749
|
+
var _product$discount_lis11, _originProduct, _selectedDiscount$met;
|
|
746
750
|
// 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
|
|
747
751
|
var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
|
|
748
752
|
// 标记优惠券为已使用
|
|
@@ -754,7 +758,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
754
758
|
// 优先从 origin_total拿,可能会拿不到(比如用户端预约在没有配置 original_price 的情况下)
|
|
755
759
|
var productOriginTotal = product.origin_total || product.total || 0;
|
|
756
760
|
// 如果当前 product 有 discount_list,则先从 origin_total 拿
|
|
757
|
-
if ((_product$
|
|
761
|
+
if ((_product$discount_lis11 = product.discount_list) !== null && _product$discount_lis11 !== void 0 && _product$discount_lis11.length && product.origin_total) {
|
|
758
762
|
productOriginTotal = product.origin_total;
|
|
759
763
|
}
|
|
760
764
|
// 如果originProduct?._productInit?.original_price为 0,product.origin_total可能为空,此时取 product.total
|
|
@@ -1110,18 +1114,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1110
1114
|
var allDiscountAmount = getDiscountListAmountTotal(mainDiscountList);
|
|
1111
1115
|
newTotalWithDiscount = (_Decimal$minus$toNumb = new Decimal(mainProductData.price || 0).minus(allDiscountAmount).toNumber()) !== null && _Decimal$minus$toNumb !== void 0 ? _Decimal$minus$toNumb : newTotalWithDiscount;
|
|
1112
1116
|
newOriginTotalWithDiscount = (_mainProductData$orig = mainProductData.origin_total) !== null && _mainProductData$orig !== void 0 ? _mainProductData$orig : newOriginTotalWithDiscount;
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
var _item$discount_list2;
|
|
1122
|
-
var originalPrice = ((_item$discount_list2 = item.discount_list) === null || _item$discount_list2 === void 0 || (_item$discount_list2 = _item$discount_list2[0]) === null || _item$discount_list2 === void 0 || (_item$discount_list2 = _item$discount_list2.discount) === null || _item$discount_list2 === void 0 ? void 0 : _item$discount_list2.original_amount) || item.price;
|
|
1123
|
-
newOriginTotalWithDiscount += Number(originalPrice) * Number(item.num);
|
|
1124
|
-
});
|
|
1117
|
+
if (newBundleWithDiscount.length > 0) {
|
|
1118
|
+
newBundleWithDiscount.forEach(function (item) {
|
|
1119
|
+
var _item$discount_list2;
|
|
1120
|
+
newTotalWithDiscount += Number(item.price) * Number(item.num);
|
|
1121
|
+
var originalPrice = ((_item$discount_list2 = item.discount_list) === null || _item$discount_list2 === void 0 || (_item$discount_list2 = _item$discount_list2[0]) === null || _item$discount_list2 === void 0 || (_item$discount_list2 = _item$discount_list2.discount) === null || _item$discount_list2 === void 0 ? void 0 : _item$discount_list2.original_amount) || item.price;
|
|
1122
|
+
newOriginTotalWithDiscount += Number(originalPrice) * Number(item.num);
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
1125
|
}
|
|
1126
1126
|
|
|
1127
1127
|
// 累加options的价格(options不参与折扣,在最终设置total时处理)
|
|
@@ -1184,14 +1184,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1184
1184
|
var _allDiscountAmount = getDiscountListAmount(mainDiscountListOriginal);
|
|
1185
1185
|
newTotalOriginal = (_Decimal$minus$toNumb2 = new Decimal(mainProductData.price || 0).minus(_allDiscountAmount).toNumber()) !== null && _Decimal$minus$toNumb2 !== void 0 ? _Decimal$minus$toNumb2 : newTotalOriginal;
|
|
1186
1186
|
newOriginTotalOriginal = (_mainProductData$orig2 = mainProductData.origin_total) !== null && _mainProductData$orig2 !== void 0 ? _mainProductData$orig2 : newOriginTotalOriginal;
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
newOriginTotalOriginal += Number(item.price) * Number(item.num);
|
|
1194
|
-
});
|
|
1187
|
+
if (newBundleOriginal.length > 0) {
|
|
1188
|
+
newBundleOriginal.forEach(function (item) {
|
|
1189
|
+
newTotalOriginal += Number(item.price) * Number(item.num);
|
|
1190
|
+
newOriginTotalOriginal += Number(item.price) * Number(item.num);
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1195
1193
|
}
|
|
1196
1194
|
|
|
1197
1195
|
// 累加options的价格(options不参与折扣,在最终设置total时处理)
|
|
@@ -1285,13 +1283,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1285
1283
|
|
|
1286
1284
|
// 累加bundle的价格(只累加一次)
|
|
1287
1285
|
if (newBundle.length > 0) {
|
|
1288
|
-
newBundle.forEach(function (item) {
|
|
1289
|
-
newTotal += Number(item.price) * Number(item.num);
|
|
1290
|
-
});
|
|
1291
|
-
|
|
1292
|
-
// 计算原始总价(不考虑折扣)
|
|
1293
1286
|
newBundle.forEach(function (item) {
|
|
1294
1287
|
var _item$discount_list3;
|
|
1288
|
+
newTotal += Number(item.price) * Number(item.num);
|
|
1295
1289
|
var originalPrice = ((_item$discount_list3 = item.discount_list) === null || _item$discount_list3 === void 0 || (_item$discount_list3 = _item$discount_list3[0]) === null || _item$discount_list3 === void 0 || (_item$discount_list3 = _item$discount_list3.discount) === null || _item$discount_list3 === void 0 ? void 0 : _item$discount_list3.original_amount) || item.price;
|
|
1296
1290
|
newOriginTotal += Number(originalPrice) * Number(item.num);
|
|
1297
1291
|
});
|
|
@@ -1470,34 +1464,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1470
1464
|
// 套餐中购买时,判断是否为原价
|
|
1471
1465
|
var _priceType = (_flatItem$bundleItem7 = flatItem.bundleItem) === null || _flatItem$bundleItem7 === void 0 ? void 0 : _flatItem$bundleItem7.price_type;
|
|
1472
1466
|
var _priceTypeExt = (_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.price_type_ext;
|
|
1473
|
-
|
|
1474
|
-
// original_price 对应:
|
|
1475
|
-
// 1. price_type: "markup" && price_type_ext: "product_price"
|
|
1476
|
-
// markup_price 对应:
|
|
1477
|
-
// price_type: "markup" && price_type_ext: ""
|
|
1478
|
-
/** 原价 */
|
|
1479
|
-
var _isOriginalPrice = _priceType === 'markup' && _priceTypeExt === 'product_price';
|
|
1480
|
-
/** 加价 */
|
|
1481
|
-
var _isMarkupPrice = _priceType === 'markup' && (_priceTypeExt === '' || !_priceTypeExt);
|
|
1482
|
-
|
|
1483
|
-
// 检查 rules
|
|
1484
|
-
if (rules.length > 0) {
|
|
1485
|
-
// 检查原价
|
|
1486
|
-
if (_isOriginalPrice && rules.includes('original_price')) {
|
|
1487
|
-
return true;
|
|
1488
|
-
}
|
|
1489
|
-
|
|
1490
|
-
// 检查加价
|
|
1491
|
-
if (_isMarkupPrice && rules.includes('markup_price')) {
|
|
1492
|
-
return true;
|
|
1493
|
-
}
|
|
1494
|
-
|
|
1495
|
-
// 如果都不匹配,则不可用
|
|
1496
|
-
return false;
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
1467
|
// 原价包括:price_type: "markup" && price_type_ext: "product_price"
|
|
1500
|
-
return
|
|
1468
|
+
return _priceType === 'markup' && _priceTypeExt === 'product_price';
|
|
1501
1469
|
}
|
|
1502
1470
|
return false;
|
|
1503
1471
|
}
|
|
@@ -31,7 +31,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
31
31
|
import { BaseModule } from "../../modules/BaseModule";
|
|
32
32
|
import { createModule } from "./types";
|
|
33
33
|
import { formatProductToCartItem, createCartItemOrigin, getUniqueId, handleVariantProduct, formatDateToCartItem, formatAccountToCartItem } from "../../modules/Cart/utils";
|
|
34
|
-
import { getAvailableProductResources
|
|
34
|
+
import { getAvailableProductResources } from "./utils/products";
|
|
35
35
|
import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection, isConflict } from "./utils/resources";
|
|
36
36
|
import dayjs from 'dayjs';
|
|
37
37
|
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
|
@@ -238,29 +238,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
238
238
|
key: "loadProducts",
|
|
239
239
|
value: (function () {
|
|
240
240
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
241
|
-
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date
|
|
241
|
+
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date;
|
|
242
242
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
243
243
|
while (1) switch (_context2.prev = _context2.next) {
|
|
244
244
|
case 0:
|
|
245
245
|
_ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, schedule_date = _ref.schedule_date;
|
|
246
|
-
_context2.
|
|
247
|
-
return this.store.products.loadProducts({
|
|
246
|
+
return _context2.abrupt("return", this.store.products.loadProducts({
|
|
248
247
|
category_ids: category_ids,
|
|
249
248
|
product_ids: product_ids,
|
|
250
249
|
collection: collection,
|
|
251
250
|
schedule_date: schedule_date,
|
|
252
251
|
cacheId: this.cacheId
|
|
253
|
-
});
|
|
254
|
-
case
|
|
255
|
-
res = _context2.sent;
|
|
256
|
-
// 预拉取当天的资源数据
|
|
257
|
-
this.getAvailableDate({
|
|
258
|
-
startDate: schedule_date || dayjs().format('YYYY-MM-DD'),
|
|
259
|
-
endDate: schedule_date || dayjs().format('YYYY-MM-DD'),
|
|
260
|
-
products: _toConsumableArray(res)
|
|
261
|
-
});
|
|
262
|
-
return _context2.abrupt("return", res);
|
|
263
|
-
case 6:
|
|
252
|
+
}));
|
|
253
|
+
case 2:
|
|
264
254
|
case "end":
|
|
265
255
|
return _context2.stop();
|
|
266
256
|
}
|
|
@@ -292,7 +282,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
292
282
|
value: (function () {
|
|
293
283
|
var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
|
|
294
284
|
var _schedule$product_ids;
|
|
295
|
-
var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, newProductIds, schedule, otherProductsIds, allProductIds
|
|
285
|
+
var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, newProductIds, schedule, otherProductsIds, allProductIds;
|
|
296
286
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
297
287
|
while (1) switch (_context3.prev = _context3.next) {
|
|
298
288
|
case 0:
|
|
@@ -339,9 +329,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
339
329
|
schedule_date: date
|
|
340
330
|
});
|
|
341
331
|
case 10:
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
case 12:
|
|
332
|
+
return _context3.abrupt("return", _context3.sent);
|
|
333
|
+
case 11:
|
|
345
334
|
case "end":
|
|
346
335
|
return _context3.stop();
|
|
347
336
|
}
|
|
@@ -1161,16 +1150,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1161
1150
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
1162
1151
|
product_variant_id: product_variant_id
|
|
1163
1152
|
});
|
|
1164
|
-
debugger;
|
|
1165
|
-
// 保护,如果进来的是 session 商品,则必须要有 date 和时间片,否则不允许添加
|
|
1166
|
-
if (isSessionProduct(productData)) {
|
|
1167
|
-
if (!date || !date.startTime || !date.endTime) {
|
|
1168
|
-
return {
|
|
1169
|
-
success: false,
|
|
1170
|
-
errorCode: 'date_or_time_required'
|
|
1171
|
-
};
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
1153
|
|
|
1175
1154
|
// 库存检测
|
|
1176
1155
|
var currentCartItems = this.store.cart.getItems();
|
|
@@ -9,9 +9,3 @@ export declare const getAvailableProductResources: (products: ProductData[]) =>
|
|
|
9
9
|
rules: any[];
|
|
10
10
|
resourcesMap: Record<number, ProductResourceItem>;
|
|
11
11
|
};
|
|
12
|
-
/**
|
|
13
|
-
* 判断商品是否是 session 商品
|
|
14
|
-
* @param product 商品数据
|
|
15
|
-
* @returns 是否是 session 商品
|
|
16
|
-
*/
|
|
17
|
-
export declare const isSessionProduct: (product: ProductData) => boolean;
|
|
@@ -47,14 +47,4 @@ export var getAvailableProductResources = function getAvailableProductResources(
|
|
|
47
47
|
rules: rules,
|
|
48
48
|
resourcesMap: resourcesMap
|
|
49
49
|
};
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* 判断商品是否是 session 商品
|
|
54
|
-
* @param product 商品数据
|
|
55
|
-
* @returns 是否是 session 商品
|
|
56
|
-
*/
|
|
57
|
-
export var isSessionProduct = function isSessionProduct(product) {
|
|
58
|
-
var _product$scheduleIds, _product$scheduleIds2;
|
|
59
|
-
return ((_product$scheduleIds = product === null || product === void 0 || (_product$scheduleIds2 = product['schedule.ids']) === null || _product$scheduleIds2 === void 0 ? void 0 : _product$scheduleIds2.length) !== null && _product$scheduleIds !== void 0 ? _product$scheduleIds : 0) > 0;
|
|
60
50
|
};
|