@pisell/pisellos 2.2.243 → 2.2.244
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/model/strategy/adapter/promotion/evaluator.js +2 -3
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +4 -7
- package/dist/modules/Cart/utils/cartProduct.js +3 -24
- package/dist/modules/Cart/utils/changePrice.js +11 -11
- package/dist/modules/Customer/index.d.ts +0 -20
- package/dist/modules/Customer/index.js +83 -172
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.js +3 -4
- package/dist/modules/Discount/types.d.ts +0 -1
- package/dist/modules/OpenData/index.d.ts +0 -8
- package/dist/modules/OpenData/index.js +17 -37
- package/dist/modules/Order/index.d.ts +18 -268
- package/dist/modules/Order/index.js +757 -3306
- package/dist/modules/Order/types.d.ts +31 -279
- package/dist/modules/Order/types.js +0 -38
- package/dist/modules/Order/utils.d.ts +5 -147
- package/dist/modules/Order/utils.js +103 -746
- package/dist/modules/Payment/index.d.ts +13 -10
- package/dist/modules/Payment/index.js +837 -467
- package/dist/modules/Payment/types.d.ts +0 -2
- package/dist/modules/Payment/utils.js +1 -2
- package/dist/modules/Payment/walletpass.js +7 -14
- package/dist/modules/ProductList/index.d.ts +12 -16
- package/dist/modules/ProductList/index.js +59 -133
- package/dist/modules/ProductList/types.d.ts +0 -14
- package/dist/modules/Quotation/index.d.ts +1 -0
- package/dist/modules/Quotation/index.js +22 -25
- package/dist/modules/Rules/index.d.ts +0 -4
- package/dist/modules/Rules/index.js +69 -93
- package/dist/modules/Rules/types.d.ts +0 -1
- package/dist/modules/SalesSummary/index.d.ts +25 -8
- package/dist/modules/SalesSummary/index.js +35 -86
- package/dist/modules/SalesSummary/types.d.ts +1 -4
- package/dist/modules/SalesSummary/utils.d.ts +25 -2
- package/dist/modules/SalesSummary/utils.js +162 -794
- package/dist/modules/Schedule/index.d.ts +0 -7
- package/dist/modules/Schedule/index.js +2 -24
- package/dist/modules/Summary/index.js +3 -4
- package/dist/modules/index.d.ts +0 -2
- package/dist/modules/index.js +1 -3
- package/dist/plugins/request.d.ts +0 -1
- package/dist/server/index.d.ts +1 -204
- package/dist/server/index.js +928 -3658
- package/dist/server/modules/index.d.ts +0 -2
- package/dist/server/modules/index.js +0 -2
- package/dist/server/modules/order/index.d.ts +4 -120
- package/dist/server/modules/order/index.js +483 -1779
- package/dist/server/modules/order/types.d.ts +3 -32
- package/dist/server/modules/order/types.js +0 -8
- package/dist/server/modules/order/utils/filterBookings.js +3 -26
- package/dist/server/modules/order/utils/filterOrders.js +8 -23
- package/dist/server/modules/products/index.d.ts +7 -34
- package/dist/server/modules/products/index.js +317 -631
- package/dist/server/modules/resource/index.d.ts +0 -2
- package/dist/server/modules/resource/index.js +3 -29
- package/dist/server/modules/schedule/index.d.ts +4 -4
- package/dist/server/modules/schedule/index.js +88 -111
- package/dist/solution/BaseSales/index.d.ts +9 -131
- package/dist/solution/BaseSales/index.js +447 -1944
- package/dist/solution/BaseSales/types.d.ts +6 -76
- package/dist/solution/BaseSales/types.js +4 -5
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -105
- package/dist/solution/BaseSales/utils.d.ts +1 -1
- package/dist/solution/BaseSales/utils.js +21 -62
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +10 -270
- package/dist/solution/BookingTicket/index.js +237 -1772
- package/dist/solution/BookingTicket/types.d.ts +1 -118
- package/dist/solution/BookingTicket/types.js +2 -41
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
- package/dist/solution/BookingTicket/utils/bookingStatus.js +0 -70
- package/dist/solution/BookingTicket/utils/cartView.d.ts +1 -9
- package/dist/solution/BookingTicket/utils/cartView.js +7 -94
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -5
- package/dist/solution/BookingTicket/utils/scan/index.js +8 -20
- package/dist/solution/Checkout/appointmentDemo.json +1 -0
- package/dist/solution/Checkout/index.d.ts +0 -1
- package/dist/solution/Checkout/index.js +9 -10
- package/dist/solution/RegisterAndLogin/config.js +10 -2
- package/dist/solution/ScanOrder/index.d.ts +3 -9
- package/dist/solution/ScanOrder/index.js +134 -241
- package/dist/solution/ScanOrder/types.d.ts +5 -9
- package/dist/solution/ScanOrder/types.js +3 -2
- package/dist/solution/ScanOrder/utils.d.ts +1 -1
- package/dist/solution/ScanOrder/utils.js +22 -84
- package/dist/solution/VenueBooking/index.d.ts +2 -5
- package/dist/solution/VenueBooking/index.js +59 -110
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +2 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/dist/types/index.d.ts +0 -10
- package/lib/model/strategy/adapter/promotion/evaluator.js +1 -2
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/model/strategy/adapter/walletPass/utils.js +2 -3
- package/lib/modules/Cart/utils/cartProduct.js +3 -20
- package/lib/modules/Cart/utils/changePrice.js +20 -12
- package/lib/modules/Customer/index.d.ts +0 -20
- package/lib/modules/Customer/index.js +11 -64
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.js +1 -5
- package/lib/modules/Discount/types.d.ts +0 -1
- package/lib/modules/OpenData/index.d.ts +0 -8
- package/lib/modules/OpenData/index.js +5 -19
- package/lib/modules/Order/index.d.ts +18 -268
- package/lib/modules/Order/index.js +344 -2149
- package/lib/modules/Order/types.d.ts +31 -279
- package/lib/modules/Order/types.js +0 -1
- package/lib/modules/Order/utils.d.ts +5 -147
- package/lib/modules/Order/utils.js +46 -614
- package/lib/modules/Payment/index.d.ts +13 -10
- package/lib/modules/Payment/index.js +150 -18
- package/lib/modules/Payment/types.d.ts +0 -2
- package/lib/modules/Payment/utils.js +1 -2
- package/lib/modules/Payment/walletpass.js +3 -7
- package/lib/modules/ProductList/index.d.ts +12 -16
- package/lib/modules/ProductList/index.js +4 -41
- package/lib/modules/ProductList/types.d.ts +0 -14
- package/lib/modules/Quotation/index.d.ts +1 -0
- package/lib/modules/Quotation/index.js +16 -19
- package/lib/modules/Rules/index.d.ts +0 -4
- package/lib/modules/Rules/index.js +120 -136
- package/lib/modules/Rules/types.d.ts +0 -1
- package/lib/modules/SalesSummary/index.d.ts +25 -8
- package/lib/modules/SalesSummary/index.js +4 -30
- package/lib/modules/SalesSummary/types.d.ts +1 -4
- package/lib/modules/SalesSummary/utils.d.ts +25 -2
- package/lib/modules/SalesSummary/utils.js +91 -645
- package/lib/modules/Schedule/index.d.ts +0 -7
- package/lib/modules/Schedule/index.js +1 -17
- package/lib/modules/Summary/index.js +4 -5
- package/lib/modules/index.d.ts +0 -2
- package/lib/modules/index.js +1 -5
- package/lib/plugins/request.d.ts +0 -1
- package/lib/server/index.d.ts +1 -204
- package/lib/server/index.js +57 -1888
- package/lib/server/modules/index.d.ts +0 -2
- package/lib/server/modules/index.js +0 -3
- package/lib/server/modules/order/index.d.ts +4 -120
- package/lib/server/modules/order/index.js +142 -919
- package/lib/server/modules/order/types.d.ts +3 -32
- package/lib/server/modules/order/utils/filterBookings.js +5 -24
- package/lib/server/modules/order/utils/filterOrders.js +6 -15
- package/lib/server/modules/products/index.d.ts +7 -34
- package/lib/server/modules/products/index.js +54 -189
- package/lib/server/modules/resource/index.d.ts +0 -2
- package/lib/server/modules/resource/index.js +3 -27
- package/lib/server/modules/schedule/index.d.ts +4 -4
- package/lib/server/modules/schedule/index.js +40 -47
- package/lib/solution/BaseSales/index.d.ts +9 -131
- package/lib/solution/BaseSales/index.js +63 -1106
- package/lib/solution/BaseSales/types.d.ts +6 -76
- package/lib/solution/BaseSales/types.js +1 -3
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +18 -106
- package/lib/solution/BaseSales/utils.d.ts +1 -1
- package/lib/solution/BaseSales/utils.js +10 -54
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +10 -270
- package/lib/solution/BookingTicket/index.js +29 -922
- package/lib/solution/BookingTicket/types.d.ts +1 -118
- package/lib/solution/BookingTicket/types.js +0 -11
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
- package/lib/solution/BookingTicket/utils/bookingStatus.js +2 -44
- package/lib/solution/BookingTicket/utils/cartView.d.ts +1 -9
- package/lib/solution/BookingTicket/utils/cartView.js +6 -61
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -5
- package/lib/solution/BookingTicket/utils/scan/index.js +3 -17
- package/lib/solution/Checkout/appointmentDemo.json +1 -0
- package/lib/solution/Checkout/index.d.ts +0 -1
- package/lib/solution/Checkout/index.js +2 -1
- package/lib/solution/RegisterAndLogin/config.js +10 -2
- package/lib/solution/ScanOrder/index.d.ts +3 -9
- package/lib/solution/ScanOrder/index.js +70 -153
- package/lib/solution/ScanOrder/types.d.ts +5 -9
- package/lib/solution/ScanOrder/utils.d.ts +1 -1
- package/lib/solution/ScanOrder/utils.js +17 -83
- package/lib/solution/VenueBooking/index.d.ts +2 -5
- package/lib/solution/VenueBooking/index.js +17 -54
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +2 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/lib/types/index.d.ts +0 -10
- package/package.json +1 -1
- package/dist/modules/BookingContext/index.d.ts +0 -48
- package/dist/modules/BookingContext/index.js +0 -566
- package/dist/modules/BookingContext/types.d.ts +0 -102
- package/dist/modules/BookingContext/types.js +0 -51
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -284
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -145
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -218
- package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/dist/modules/BookingContext/utils/flexible.js +0 -56
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
- package/dist/modules/BookingContext/utils/index.d.ts +0 -11
- package/dist/modules/BookingContext/utils/index.js +0 -11
- package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/dist/modules/BookingContext/utils/noResource.js +0 -77
- package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
- package/dist/modules/BookingContext/utils/orderLineDisplay.js +0 -36
- package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/dist/modules/BookingContext/utils/productExtend.js +0 -339
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
- package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
- package/dist/modules/BookingContext/utils/resources.js +0 -486
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/dist/modules/Order/utils/manualProductDiscount.js +0 -210
- package/dist/modules/SurchargeList/index.d.ts +0 -16
- package/dist/modules/SurchargeList/index.js +0 -162
- package/dist/modules/SurchargeList/types.d.ts +0 -11
- package/dist/modules/SurchargeList/types.js +0 -1
- package/dist/server/modules/payment/index.d.ts +0 -28
- package/dist/server/modules/payment/index.js +0 -305
- package/dist/server/modules/payment/types.d.ts +0 -9
- package/dist/server/modules/payment/types.js +0 -1
- package/dist/server/test.json +0 -713
- package/dist/server/utils/small-ticket.d.ts +0 -71
- package/dist/server/utils/small-ticket.js +0 -830
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
- package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1438
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
- package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
- package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
- package/dist/solution/BookingTicket/utils/addTimeAvailability.js +0 -95
- package/dist/solution/BookingTicket/utils/exampleData.d.ts +0 -123
- package/dist/solution/BookingTicket/utils/exampleData.js +0 -183
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -438
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -399
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -56
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +0 -150
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
- package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +0 -78
- package/lib/modules/BookingContext/index.d.ts +0 -48
- package/lib/modules/BookingContext/index.js +0 -368
- package/lib/modules/BookingContext/types.d.ts +0 -102
- package/lib/modules/BookingContext/types.js +0 -34
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -276
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -151
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -201
- package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/lib/modules/BookingContext/utils/flexible.js +0 -80
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
- package/lib/modules/BookingContext/utils/index.d.ts +0 -11
- package/lib/modules/BookingContext/utils/index.js +0 -43
- package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/lib/modules/BookingContext/utils/noResource.js +0 -90
- package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +0 -56
- package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/lib/modules/BookingContext/utils/productExtend.js +0 -283
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
- package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
- package/lib/modules/BookingContext/utils/resources.js +0 -377
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/lib/modules/Order/utils/manualProductDiscount.js +0 -206
- package/lib/modules/SurchargeList/index.d.ts +0 -16
- package/lib/modules/SurchargeList/index.js +0 -89
- package/lib/modules/SurchargeList/types.d.ts +0 -11
- package/lib/modules/SurchargeList/types.js +0 -17
- package/lib/server/modules/payment/index.d.ts +0 -28
- package/lib/server/modules/payment/index.js +0 -192
- package/lib/server/modules/payment/types.d.ts +0 -9
- package/lib/server/modules/payment/types.js +0 -17
- package/lib/server/test.json +0 -713
- package/lib/server/utils/small-ticket.d.ts +0 -71
- package/lib/server/utils/small-ticket.js +0 -781
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
- package/lib/solution/BaseSales/utils/cartPromotion.js +0 -992
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
- package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
- package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +0 -125
- package/lib/solution/BookingTicket/utils/exampleData.d.ts +0 -123
- package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -254
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -168
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -51
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +0 -127
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +0 -85
|
@@ -747,10 +747,9 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
747
747
|
return b.price - a.price;
|
|
748
748
|
});
|
|
749
749
|
|
|
750
|
-
// 3.
|
|
750
|
+
// 3. 计算可以凑成多少组
|
|
751
751
|
var totalUnits = unitProducts.length;
|
|
752
|
-
var
|
|
753
|
-
var groupCount = isCumulative ? Math.floor(totalUnits / x) : totalUnits >= x ? 1 : 0;
|
|
752
|
+
var groupCount = cumulative ? Math.floor(totalUnits / x) : totalUnits >= x ? 1 : 0;
|
|
754
753
|
var promotionUnits = groupCount * x;
|
|
755
754
|
|
|
756
755
|
// 4. 分离参与促销的和不参与的商品
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 导出评估器
|
|
2
|
+
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
+
|
|
4
|
+
// 导出适配器
|
|
5
|
+
export { PromotionAdapter } from "./adapter";
|
|
6
|
+
export { default } from "./adapter";
|
|
7
|
+
|
|
8
|
+
// 导出策略配置示例常量
|
|
9
|
+
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
|
|
@@ -494,7 +494,7 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
494
494
|
// ======================================================================================
|
|
495
495
|
|
|
496
496
|
// 计算本次抵扣金额(使用同样的 usageAmount)
|
|
497
|
-
var maxDeduction = Decimal.min(new Decimal(usageAmount), new Decimal(maxDeductionAmount)
|
|
497
|
+
var maxDeduction = Decimal.min(new Decimal(usageAmount), new Decimal(maxDeductionAmount));
|
|
498
498
|
var deductionLeft = maxDeduction;
|
|
499
499
|
var deductionDetails = [];
|
|
500
500
|
if (allowCrossProduct) {
|
|
@@ -677,7 +677,6 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
677
677
|
|
|
678
678
|
// 第一步:按顺序应用已选中的券,计算实际抵扣
|
|
679
679
|
selectedVouchers.forEach(function (selectedVoucher) {
|
|
680
|
-
var _selectedVoucher$_ava;
|
|
681
680
|
var config = selectedVoucher.config,
|
|
682
681
|
id = selectedVoucher.id;
|
|
683
682
|
var maxDeductionAmount = config.maxDeductionAmount,
|
|
@@ -711,11 +710,9 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
711
710
|
return;
|
|
712
711
|
}
|
|
713
712
|
|
|
714
|
-
//
|
|
715
|
-
//
|
|
716
|
-
|
|
717
|
-
// 避免 recalculateVouchers 又回退到后端单券 recommended_usage_amount 造成超付。
|
|
718
|
-
var usageAmount = typeof selectedVoucher.edit_current_amount === 'number' ? selectedVoucher.edit_current_amount : (_selectedVoucher$_ava = selectedVoucher._available_max_amount) !== null && _selectedVoucher$_ava !== void 0 ? _selectedVoucher$_ava : getRecommendedAmount(selectedVoucher);
|
|
713
|
+
// 计算本次抵扣金额
|
|
714
|
+
// 优先使用用户手动编辑的金额,否则根据 deductTaxAndFee 配置获取推荐金额
|
|
715
|
+
var usageAmount = typeof selectedVoucher.edit_current_amount === 'number' ? selectedVoucher.edit_current_amount : getRecommendedAmount(selectedVoucher);
|
|
719
716
|
var maxDeduction = Decimal.min(new Decimal(usageAmount), new Decimal(maxDeductionAmount), remainingOrderAmount);
|
|
720
717
|
var deductionLeft = maxDeduction;
|
|
721
718
|
var deductionDetails = [];
|
|
@@ -14,7 +14,6 @@ import Decimal from 'decimal.js';
|
|
|
14
14
|
import { isNormalProduct } from "../../Product/utils";
|
|
15
15
|
import { getDiscountAmount } from "../../../solution/ShopDiscount/utils";
|
|
16
16
|
import { calcDiscountListDifference } from "../../Summary/utils";
|
|
17
|
-
import { getBundleSellingMagnitude } from "../../Order/utils";
|
|
18
17
|
|
|
19
18
|
/** 与 Rules / ShopDiscount 一致的折扣入参,用于主价与 option 单价 */
|
|
20
19
|
var toDiscountPayload = function toDiscountPayload(discountItem) {
|
|
@@ -184,9 +183,7 @@ export var formatProductToCartItemOrigin = function formatProductToCartItemOrigi
|
|
|
184
183
|
product_id: product.id,
|
|
185
184
|
product_variant_id: product_variant_id || 0,
|
|
186
185
|
product_bundle: ((_origin$product2 = origin.product) === null || _origin$product2 === void 0 ? void 0 : _origin$product2.product_bundle) || [],
|
|
187
|
-
|
|
188
|
-
option: []
|
|
189
|
-
},
|
|
186
|
+
product_option_item: ((_origin$product3 = origin.product) === null || _origin$product3 === void 0 ? void 0 : _origin$product3.product_option_item) || [],
|
|
190
187
|
metadata: {
|
|
191
188
|
product_discount_difference: product_discount_difference
|
|
192
189
|
}
|
|
@@ -199,16 +196,7 @@ export var formatProductToCartItemOrigin = function formatProductToCartItemOrigi
|
|
|
199
196
|
origin.product.product_bundle = formatBundleToOrigin(bundle);
|
|
200
197
|
}
|
|
201
198
|
if (options !== null && options !== void 0 && options.length) {
|
|
202
|
-
origin.product.
|
|
203
|
-
option: formatOptionsToOrigin(options).map(function (option) {
|
|
204
|
-
var _option$add_price;
|
|
205
|
-
var next = _objectSpread(_objectSpread({}, option), {}, {
|
|
206
|
-
add_price: (_option$add_price = option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option.price
|
|
207
|
-
});
|
|
208
|
-
delete next.price;
|
|
209
|
-
return next;
|
|
210
|
-
})
|
|
211
|
-
});
|
|
199
|
+
origin.product.product_option_item = formatOptionsToOrigin(options);
|
|
212
200
|
}
|
|
213
201
|
}
|
|
214
202
|
return origin;
|
|
@@ -375,7 +363,6 @@ export var formatBundle = function formatBundle(bundle) {
|
|
|
375
363
|
export var formatBundleToOrigin = function formatBundleToOrigin(bundle) {
|
|
376
364
|
if (!(bundle !== null && bundle !== void 0 && bundle.length)) return [];
|
|
377
365
|
return bundle.map(function (d) {
|
|
378
|
-
var _d$price, _d$price_type, _d$price_type_ext;
|
|
379
366
|
var getBundleValueByKey = function getBundleValueByKey(key) {
|
|
380
367
|
var _d$originBundleItem;
|
|
381
368
|
return (d === null || d === void 0 ? void 0 : d[key]) || (d === null || d === void 0 || (_d$originBundleItem = d.originBundleItem) === null || _d$originBundleItem === void 0 ? void 0 : _d$originBundleItem[key]);
|
|
@@ -384,14 +371,6 @@ export var formatBundleToOrigin = function formatBundleToOrigin(bundle) {
|
|
|
384
371
|
var _cur$metadata2;
|
|
385
372
|
return pre + ((cur === null || cur === void 0 || (_cur$metadata2 = cur.metadata) === null || _cur$metadata2 === void 0 ? void 0 : _cur$metadata2.product_discount_difference) || 0);
|
|
386
373
|
}, 0);
|
|
387
|
-
var normalizedBundle = _objectSpread(_objectSpread({}, d), {}, {
|
|
388
|
-
// 计算 markdown 净额时只传真实毛价;若仅有 bundle_selling_price,则由 helper 当历史净额兜底。
|
|
389
|
-
price: (_d$price = d === null || d === void 0 ? void 0 : d.price) !== null && _d$price !== void 0 ? _d$price : d === null || d === void 0 ? void 0 : d.custom_price,
|
|
390
|
-
bundle_selling_price: d === null || d === void 0 ? void 0 : d.bundle_selling_price,
|
|
391
|
-
price_type: (_d$price_type = d === null || d === void 0 ? void 0 : d.price_type) !== null && _d$price_type !== void 0 ? _d$price_type : d === null || d === void 0 ? void 0 : d.custom_price_type,
|
|
392
|
-
price_type_ext: (_d$price_type_ext = d === null || d === void 0 ? void 0 : d.price_type_ext) !== null && _d$price_type_ext !== void 0 ? _d$price_type_ext : d === null || d === void 0 ? void 0 : d.custom_price_type_ext,
|
|
393
|
-
option: getBundleValueByKey('option')
|
|
394
|
-
});
|
|
395
374
|
return {
|
|
396
375
|
bundle_group_id: getBundleValueByKey('group_id'),
|
|
397
376
|
bundle_id: d.id,
|
|
@@ -402,7 +381,7 @@ export var formatBundleToOrigin = function formatBundleToOrigin(bundle) {
|
|
|
402
381
|
extension_type: getBundleValueByKey('extension_type'),
|
|
403
382
|
option: formatOptionsToOrigin(getBundleValueByKey('option')),
|
|
404
383
|
discount_list: d.discount_list,
|
|
405
|
-
"bundle_selling_price":
|
|
384
|
+
"bundle_selling_price": d === null || d === void 0 ? void 0 : d.price,
|
|
406
385
|
"custom_price": d === null || d === void 0 ? void 0 : d.price,
|
|
407
386
|
metadata: {
|
|
408
387
|
custom_product_bundle_map_id: d._id,
|
|
@@ -10,7 +10,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
10
10
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
11
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
12
12
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
|
-
import
|
|
13
|
+
import Decimal from "decimal.js";
|
|
14
14
|
export function updateAllCartItemPrice(_x, _x2, _x3, _x4, _x5) {
|
|
15
15
|
return _updateAllCartItemPrice.apply(this, arguments);
|
|
16
16
|
}
|
|
@@ -54,18 +54,18 @@ function _updateAllCartItemPrice() {
|
|
|
54
54
|
var targetBundleItem = targetBundle.bundle_item.find(function (m) {
|
|
55
55
|
return m.id === n.id;
|
|
56
56
|
});
|
|
57
|
+
if (targetBundleItem.price_type === 'markdown') {
|
|
58
|
+
targetBundleItem.price = new Decimal(targetBundleItem.price || 0).mul(-1).toNumber();
|
|
59
|
+
}
|
|
60
|
+
// 如果有选择 option,还需要加上 option 的价格
|
|
61
|
+
if (n.option) {
|
|
62
|
+
targetBundleItem.price = new Decimal(targetBundleItem.price || 0).add(n.option.reduce(function (pre, cur) {
|
|
63
|
+
return pre + new Decimal(cur.price || 0).mul(cur.num || 1).toNumber();
|
|
64
|
+
}, 0)).toNumber();
|
|
65
|
+
}
|
|
57
66
|
if (targetBundleItem) {
|
|
58
|
-
var normalizedBundle = _objectSpread(_objectSpread({}, n), {}, {
|
|
59
|
-
price: targetBundleItem.price,
|
|
60
|
-
custom_price: targetBundleItem.price,
|
|
61
|
-
price_type: targetBundleItem.price_type,
|
|
62
|
-
price_type_ext: targetBundleItem.price_type_ext
|
|
63
|
-
});
|
|
64
|
-
var bundleSellingPrice = getBundleSellingMagnitude(normalizedBundle).toFixed(2);
|
|
65
67
|
return _objectSpread(_objectSpread({}, n), {}, {
|
|
66
|
-
|
|
67
|
-
price: targetBundleItem.price_type === 'markdown' ? bundleSellingPrice : targetBundleItem.price,
|
|
68
|
-
bundle_selling_price: bundleSellingPrice,
|
|
68
|
+
price: targetBundleItem.price,
|
|
69
69
|
base_price: targetBundleItem.base_price
|
|
70
70
|
});
|
|
71
71
|
}
|
|
@@ -7,25 +7,11 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
|
|
|
7
7
|
private store;
|
|
8
8
|
private request;
|
|
9
9
|
private cacheId;
|
|
10
|
-
/**
|
|
11
|
-
* 判断两份选中客户的核心展示字段是否一致,用于避免重复 clone / emit。
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* this.isSameSelectedCustomer(currentCustomer, nextCustomer);
|
|
15
|
-
*/
|
|
16
|
-
private isSameSelectedCustomer;
|
|
17
10
|
private openCache;
|
|
18
11
|
private fatherModule;
|
|
19
12
|
private otherParams;
|
|
20
13
|
constructor(name?: string, version?: string);
|
|
21
14
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
* 更新父级解决方案透传的运行态参数,并刷新客户模块缓存配置。
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* customerModule.updateOtherParams({ isFranchisee: true, cacheId: 'cache-2' });
|
|
27
|
-
*/
|
|
28
|
-
updateOtherParams(params: Record<string, any>): void;
|
|
29
15
|
/**
|
|
30
16
|
* 获取客户列表数据(内部方法)
|
|
31
17
|
* @param params 查询参数
|
|
@@ -38,12 +24,6 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
|
|
|
38
24
|
* @param operation 操作名称
|
|
39
25
|
*/
|
|
40
26
|
private handleCustomerListError;
|
|
41
|
-
/**
|
|
42
|
-
* 查询客户列表但不写入 customerList / pagination 状态。
|
|
43
|
-
*
|
|
44
|
-
* 用于按 ID 补齐客户等内部查询,避免把临时的 num/searchParams 污染到滚动列表。
|
|
45
|
-
*/
|
|
46
|
-
queryCustomerList(params?: ShopGetCustomerListParams): Promise<ICustomerListResponse>;
|
|
47
27
|
/**
|
|
48
28
|
* 获取客户列表
|
|
49
29
|
* @param params 查询参数
|
|
@@ -60,30 +60,6 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
60
60
|
return _this;
|
|
61
61
|
}
|
|
62
62
|
_createClass(CustomerModule, [{
|
|
63
|
-
key: "isSameSelectedCustomer",
|
|
64
|
-
value:
|
|
65
|
-
/**
|
|
66
|
-
* 判断两份选中客户的核心展示字段是否一致,用于避免重复 clone / emit。
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* this.isSameSelectedCustomer(currentCustomer, nextCustomer);
|
|
70
|
-
*/
|
|
71
|
-
function isSameSelectedCustomer(current, next) {
|
|
72
|
-
var _id, _id2;
|
|
73
|
-
var normalizedNext = !next ? DEFAULT_CUSTOMER : next;
|
|
74
|
-
var normalizedCurrent = current || null;
|
|
75
|
-
if (!normalizedCurrent) return false;
|
|
76
|
-
// Walk-In 是默认客户,展示文案 / 默认区号可能来自不同入口;同为 id=1 时视为同一客户。
|
|
77
|
-
if (String((_id = normalizedCurrent === null || normalizedCurrent === void 0 ? void 0 : normalizedCurrent.id) !== null && _id !== void 0 ? _id : '') === '1' && String((_id2 = normalizedNext === null || normalizedNext === void 0 ? void 0 : normalizedNext.id) !== null && _id2 !== void 0 ? _id2 : '') === '1') {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
var keys = ['id', 'name', 'phone', 'email', 'country_calling_code'];
|
|
81
|
-
return keys.every(function (key) {
|
|
82
|
-
var _key, _key2;
|
|
83
|
-
return String((_key = normalizedCurrent === null || normalizedCurrent === void 0 ? void 0 : normalizedCurrent[key]) !== null && _key !== void 0 ? _key : '') === String((_key2 = normalizedNext === null || normalizedNext === void 0 ? void 0 : normalizedNext[key]) !== null && _key2 !== void 0 ? _key2 : '');
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}, {
|
|
87
63
|
key: "initialize",
|
|
88
64
|
value: function () {
|
|
89
65
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
@@ -119,7 +95,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
119
95
|
} else {
|
|
120
96
|
this.store.currentPage = 1;
|
|
121
97
|
}
|
|
122
|
-
if (typeof (options === null || options === void 0 || (_options$initialState5 = options.initialState) === null || _options$initialState5 === void 0 ? void 0 : _options$initialState5.pageSize) === 'number'
|
|
98
|
+
if (typeof (options === null || options === void 0 || (_options$initialState5 = options.initialState) === null || _options$initialState5 === void 0 ? void 0 : _options$initialState5.pageSize) === 'number') {
|
|
123
99
|
this.store.pageSize = options.initialState.pageSize;
|
|
124
100
|
} else {
|
|
125
101
|
this.store.pageSize = DEFAULT_PAGE_SIZE;
|
|
@@ -149,22 +125,6 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
149
125
|
}
|
|
150
126
|
return initialize;
|
|
151
127
|
}()
|
|
152
|
-
/**
|
|
153
|
-
* 更新父级解决方案透传的运行态参数,并刷新客户模块缓存配置。
|
|
154
|
-
*
|
|
155
|
-
* @example
|
|
156
|
-
* customerModule.updateOtherParams({ isFranchisee: true, cacheId: 'cache-2' });
|
|
157
|
-
*/
|
|
158
|
-
}, {
|
|
159
|
-
key: "updateOtherParams",
|
|
160
|
-
value: function updateOtherParams(params) {
|
|
161
|
-
var _this$otherParams$ope;
|
|
162
|
-
this.otherParams = params || {};
|
|
163
|
-
this.openCache = (_this$otherParams$ope = this.otherParams.openCache) !== null && _this$otherParams$ope !== void 0 ? _this$otherParams$ope : false;
|
|
164
|
-
this.cacheId = this.otherParams.cacheId;
|
|
165
|
-
this.fatherModule = this.otherParams.fatherModule;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
128
|
/**
|
|
169
129
|
* 获取客户列表数据(内部方法)
|
|
170
130
|
* @param params 查询参数
|
|
@@ -276,52 +236,6 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
276
236
|
}
|
|
277
237
|
return handleCustomerListError;
|
|
278
238
|
}()
|
|
279
|
-
/**
|
|
280
|
-
* 查询客户列表但不写入 customerList / pagination 状态。
|
|
281
|
-
*
|
|
282
|
-
* 用于按 ID 补齐客户等内部查询,避免把临时的 num/searchParams 污染到滚动列表。
|
|
283
|
-
*/
|
|
284
|
-
)
|
|
285
|
-
}, {
|
|
286
|
-
key: "queryCustomerList",
|
|
287
|
-
value: (function () {
|
|
288
|
-
var _queryCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
289
|
-
var params,
|
|
290
|
-
_yield$this$fetchCust,
|
|
291
|
-
customerList,
|
|
292
|
-
total,
|
|
293
|
-
page,
|
|
294
|
-
pageSize,
|
|
295
|
-
_args4 = arguments;
|
|
296
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
297
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
298
|
-
case 0:
|
|
299
|
-
params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
|
|
300
|
-
_context4.next = 3;
|
|
301
|
-
return this.fetchCustomerListData(params);
|
|
302
|
-
case 3:
|
|
303
|
-
_yield$this$fetchCust = _context4.sent;
|
|
304
|
-
customerList = _yield$this$fetchCust.customerList;
|
|
305
|
-
total = _yield$this$fetchCust.total;
|
|
306
|
-
page = _yield$this$fetchCust.page;
|
|
307
|
-
pageSize = _yield$this$fetchCust.pageSize;
|
|
308
|
-
return _context4.abrupt("return", {
|
|
309
|
-
list: customerList,
|
|
310
|
-
total: total,
|
|
311
|
-
page: page,
|
|
312
|
-
pageSize: pageSize
|
|
313
|
-
});
|
|
314
|
-
case 9:
|
|
315
|
-
case "end":
|
|
316
|
-
return _context4.stop();
|
|
317
|
-
}
|
|
318
|
-
}, _callee4, this);
|
|
319
|
-
}));
|
|
320
|
-
function queryCustomerList() {
|
|
321
|
-
return _queryCustomerList.apply(this, arguments);
|
|
322
|
-
}
|
|
323
|
-
return queryCustomerList;
|
|
324
|
-
}()
|
|
325
239
|
/**
|
|
326
240
|
* 获取客户列表
|
|
327
241
|
* @param params 查询参数
|
|
@@ -331,9 +245,9 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
331
245
|
}, {
|
|
332
246
|
key: "getCustomerList",
|
|
333
247
|
value: (function () {
|
|
334
|
-
var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
248
|
+
var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
335
249
|
var params,
|
|
336
|
-
_yield$this$
|
|
250
|
+
_yield$this$fetchCust,
|
|
337
251
|
customerList,
|
|
338
252
|
total,
|
|
339
253
|
page,
|
|
@@ -342,22 +256,22 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
342
256
|
num,
|
|
343
257
|
searchParams,
|
|
344
258
|
response,
|
|
345
|
-
|
|
346
|
-
return _regeneratorRuntime().wrap(function
|
|
347
|
-
while (1) switch (
|
|
259
|
+
_args4 = arguments;
|
|
260
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
261
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
348
262
|
case 0:
|
|
349
|
-
params =
|
|
350
|
-
|
|
263
|
+
params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
|
|
264
|
+
_context4.prev = 1;
|
|
351
265
|
this.store.loading = true;
|
|
352
266
|
this.store.error = null;
|
|
353
|
-
|
|
267
|
+
_context4.next = 6;
|
|
354
268
|
return this.fetchCustomerListData(params);
|
|
355
269
|
case 6:
|
|
356
|
-
_yield$this$
|
|
357
|
-
customerList = _yield$this$
|
|
358
|
-
total = _yield$this$
|
|
359
|
-
page = _yield$this$
|
|
360
|
-
pageSize = _yield$this$
|
|
270
|
+
_yield$this$fetchCust = _context4.sent;
|
|
271
|
+
customerList = _yield$this$fetchCust.customerList;
|
|
272
|
+
total = _yield$this$fetchCust.total;
|
|
273
|
+
page = _yield$this$fetchCust.page;
|
|
274
|
+
pageSize = _yield$this$fetchCust.pageSize;
|
|
361
275
|
// 保存搜索条件(排除skip和num)
|
|
362
276
|
skip = params.skip, num = params.num, searchParams = _objectWithoutProperties(params, _excluded2);
|
|
363
277
|
this.store.searchParams = cloneDeep(searchParams);
|
|
@@ -372,7 +286,9 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
372
286
|
|
|
373
287
|
// 设置客户列表(替换模式)
|
|
374
288
|
this.store.customerList = cloneDeep(customerList);
|
|
375
|
-
|
|
289
|
+
_context4.next = 20;
|
|
290
|
+
return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
|
|
291
|
+
case 20:
|
|
376
292
|
// 触发分页变化事件
|
|
377
293
|
this.triggerPaginationChange({
|
|
378
294
|
page: page,
|
|
@@ -386,27 +302,24 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
386
302
|
page: page,
|
|
387
303
|
pageSize: pageSize
|
|
388
304
|
};
|
|
389
|
-
return
|
|
390
|
-
case
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
return this.handleCustomerListError(
|
|
395
|
-
case
|
|
396
|
-
throw
|
|
397
|
-
case
|
|
398
|
-
|
|
305
|
+
return _context4.abrupt("return", response);
|
|
306
|
+
case 25:
|
|
307
|
+
_context4.prev = 25;
|
|
308
|
+
_context4.t0 = _context4["catch"](1);
|
|
309
|
+
_context4.next = 29;
|
|
310
|
+
return this.handleCustomerListError(_context4.t0, 'fetch customer list');
|
|
311
|
+
case 29:
|
|
312
|
+
throw _context4.t0;
|
|
313
|
+
case 30:
|
|
314
|
+
_context4.prev = 30;
|
|
399
315
|
this.store.loading = false;
|
|
400
316
|
this.storeChange();
|
|
401
|
-
|
|
402
|
-
return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
|
|
403
|
-
case 33:
|
|
404
|
-
return _context5.finish(28);
|
|
317
|
+
return _context4.finish(30);
|
|
405
318
|
case 34:
|
|
406
319
|
case "end":
|
|
407
|
-
return
|
|
320
|
+
return _context4.stop();
|
|
408
321
|
}
|
|
409
|
-
},
|
|
322
|
+
}, _callee4, this, [[1, 25, 30, 34]]);
|
|
410
323
|
}));
|
|
411
324
|
function getCustomerList() {
|
|
412
325
|
return _getCustomerList.apply(this, arguments);
|
|
@@ -436,9 +349,6 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
436
349
|
}, {
|
|
437
350
|
key: "setSelectedCustomer",
|
|
438
351
|
value: function setSelectedCustomer(customer) {
|
|
439
|
-
if (this.isSameSelectedCustomer(this.store.selectedCustomer, customer)) {
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
352
|
this.store.selectedCustomer = !customer ? DEFAULT_CUSTOMER : cloneDeep(customer);
|
|
443
353
|
this.core.effects.emit("".concat(this.name, ":onCustomerSelected"), this.store.selectedCustomer);
|
|
444
354
|
this.storeChange();
|
|
@@ -583,10 +493,10 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
583
493
|
}, {
|
|
584
494
|
key: "changeCustomerPage",
|
|
585
495
|
value: (function () {
|
|
586
|
-
var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
496
|
+
var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(page, pageSize) {
|
|
587
497
|
var targetPageSize, skip, num;
|
|
588
|
-
return _regeneratorRuntime().wrap(function
|
|
589
|
-
while (1) switch (
|
|
498
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
499
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
590
500
|
case 0:
|
|
591
501
|
targetPageSize = pageSize || this.store.pageSize; // 先更新分页状态
|
|
592
502
|
this.setPaginationInfo(page, targetPageSize);
|
|
@@ -594,18 +504,18 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
594
504
|
// skip直接使用page,num使用pageSize
|
|
595
505
|
skip = page;
|
|
596
506
|
num = targetPageSize; // 自动调用获取客户列表,使用存储的搜索条件
|
|
597
|
-
|
|
507
|
+
_context5.next = 6;
|
|
598
508
|
return this.getCustomerList(_objectSpread({
|
|
599
509
|
skip: skip,
|
|
600
510
|
num: num
|
|
601
511
|
}, this.store.searchParams));
|
|
602
512
|
case 6:
|
|
603
|
-
return
|
|
513
|
+
return _context5.abrupt("return", _context5.sent);
|
|
604
514
|
case 7:
|
|
605
515
|
case "end":
|
|
606
|
-
return
|
|
516
|
+
return _context5.stop();
|
|
607
517
|
}
|
|
608
|
-
},
|
|
518
|
+
}, _callee5, this);
|
|
609
519
|
}));
|
|
610
520
|
function changeCustomerPage(_x5, _x6) {
|
|
611
521
|
return _changeCustomerPage.apply(this, arguments);
|
|
@@ -620,16 +530,16 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
620
530
|
}, {
|
|
621
531
|
key: "loadMoreCustomers",
|
|
622
532
|
value: (function () {
|
|
623
|
-
var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
624
|
-
var nextPage,
|
|
625
|
-
return _regeneratorRuntime().wrap(function
|
|
626
|
-
while (1) switch (
|
|
533
|
+
var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
534
|
+
var nextPage, _yield$this$fetchCust2, newCustomers, total, page, pageSize, updatedCustomerList, response;
|
|
535
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
536
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
627
537
|
case 0:
|
|
628
538
|
if (!(!this.store.hasMore || this.store.loadingMore)) {
|
|
629
|
-
|
|
539
|
+
_context6.next = 2;
|
|
630
540
|
break;
|
|
631
541
|
}
|
|
632
|
-
return
|
|
542
|
+
return _context6.abrupt("return", {
|
|
633
543
|
list: [],
|
|
634
544
|
total: this.store.total,
|
|
635
545
|
page: this.store.currentPage,
|
|
@@ -638,21 +548,22 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
638
548
|
case 2:
|
|
639
549
|
// 计算下一页
|
|
640
550
|
nextPage = this.store.currentPage + 1;
|
|
641
|
-
|
|
551
|
+
_context6.prev = 3;
|
|
642
552
|
this.store.loadingMore = true;
|
|
643
553
|
this.store.error = null;
|
|
644
|
-
|
|
554
|
+
|
|
555
|
+
// 使用公共方法获取数据,传入存储的搜索条件
|
|
556
|
+
_context6.next = 8;
|
|
557
|
+
return this.fetchCustomerListData(_objectSpread({
|
|
645
558
|
skip: nextPage,
|
|
646
559
|
num: this.store.pageSize
|
|
647
|
-
}, this.store.searchParams);
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
_yield$this$
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
page = _yield$this$fetchCust3.page;
|
|
655
|
-
pageSize = _yield$this$fetchCust3.pageSize;
|
|
560
|
+
}, this.store.searchParams));
|
|
561
|
+
case 8:
|
|
562
|
+
_yield$this$fetchCust2 = _context6.sent;
|
|
563
|
+
newCustomers = _yield$this$fetchCust2.customerList;
|
|
564
|
+
total = _yield$this$fetchCust2.total;
|
|
565
|
+
page = _yield$this$fetchCust2.page;
|
|
566
|
+
pageSize = _yield$this$fetchCust2.pageSize;
|
|
656
567
|
// 将新数据追加到现有列表(追加模式)
|
|
657
568
|
updatedCustomerList = [].concat(_toConsumableArray(this.store.customerList), _toConsumableArray(cloneDeep(newCustomers))); // 更新状态
|
|
658
569
|
this.store.customerList = updatedCustomerList;
|
|
@@ -661,14 +572,17 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
661
572
|
this.store.hasMore = page * pageSize < total;
|
|
662
573
|
|
|
663
574
|
// 触发滚动加载特定事件
|
|
664
|
-
|
|
575
|
+
_context6.next = 20;
|
|
665
576
|
return this.core.effects.emit("".concat(this.name, ":onScrollLoadMore"), {
|
|
666
577
|
newCustomers: newCustomers,
|
|
667
578
|
allCustomers: this.store.customerList,
|
|
668
579
|
currentPage: page,
|
|
669
580
|
hasMore: this.store.hasMore
|
|
670
581
|
});
|
|
671
|
-
case
|
|
582
|
+
case 20:
|
|
583
|
+
_context6.next = 22;
|
|
584
|
+
return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
|
|
585
|
+
case 22:
|
|
672
586
|
// 触发分页变化事件
|
|
673
587
|
this.triggerPaginationChange({
|
|
674
588
|
page: page,
|
|
@@ -683,27 +597,24 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
683
597
|
page: page,
|
|
684
598
|
pageSize: pageSize
|
|
685
599
|
};
|
|
686
|
-
return
|
|
687
|
-
case
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
return this.handleCustomerListError(
|
|
692
|
-
case 30:
|
|
693
|
-
throw _context7.t0;
|
|
600
|
+
return _context6.abrupt("return", response);
|
|
601
|
+
case 27:
|
|
602
|
+
_context6.prev = 27;
|
|
603
|
+
_context6.t0 = _context6["catch"](3);
|
|
604
|
+
_context6.next = 31;
|
|
605
|
+
return this.handleCustomerListError(_context6.t0, 'load more customers');
|
|
694
606
|
case 31:
|
|
695
|
-
|
|
607
|
+
throw _context6.t0;
|
|
608
|
+
case 32:
|
|
609
|
+
_context6.prev = 32;
|
|
696
610
|
this.store.loadingMore = false;
|
|
697
611
|
this.storeChange();
|
|
698
|
-
|
|
699
|
-
return this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), this.store);
|
|
612
|
+
return _context6.finish(32);
|
|
700
613
|
case 36:
|
|
701
|
-
return _context7.finish(31);
|
|
702
|
-
case 37:
|
|
703
614
|
case "end":
|
|
704
|
-
return
|
|
615
|
+
return _context6.stop();
|
|
705
616
|
}
|
|
706
|
-
},
|
|
617
|
+
}, _callee6, this, [[3, 27, 32, 36]]);
|
|
707
618
|
}));
|
|
708
619
|
function loadMoreCustomers() {
|
|
709
620
|
return _loadMoreCustomers.apply(this, arguments);
|
|
@@ -719,15 +630,15 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
719
630
|
}, {
|
|
720
631
|
key: "resetAndLoadCustomers",
|
|
721
632
|
value: (function () {
|
|
722
|
-
var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
633
|
+
var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
723
634
|
var params,
|
|
724
635
|
resetParams,
|
|
725
636
|
response,
|
|
726
|
-
|
|
727
|
-
return _regeneratorRuntime().wrap(function
|
|
728
|
-
while (1) switch (
|
|
637
|
+
_args7 = arguments;
|
|
638
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
639
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
729
640
|
case 0:
|
|
730
|
-
params =
|
|
641
|
+
params = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
|
|
731
642
|
// 重置状态
|
|
732
643
|
this.store.customerList = [];
|
|
733
644
|
this.store.currentPage = 1;
|
|
@@ -739,23 +650,23 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
739
650
|
skip: 1,
|
|
740
651
|
num: params.num || this.store.pageSize
|
|
741
652
|
}); // 调用普通的获取列表方法
|
|
742
|
-
|
|
653
|
+
_context7.next = 8;
|
|
743
654
|
return this.getCustomerList(resetParams);
|
|
744
655
|
case 8:
|
|
745
|
-
response =
|
|
746
|
-
|
|
656
|
+
response = _context7.sent;
|
|
657
|
+
_context7.next = 11;
|
|
747
658
|
return this.core.effects.emit("".concat(this.name, ":onScrollLoadComplete"), {
|
|
748
659
|
customers: this.store.customerList,
|
|
749
660
|
total: this.store.total,
|
|
750
661
|
hasMore: this.store.hasMore
|
|
751
662
|
});
|
|
752
663
|
case 11:
|
|
753
|
-
return
|
|
664
|
+
return _context7.abrupt("return", response);
|
|
754
665
|
case 12:
|
|
755
666
|
case "end":
|
|
756
|
-
return
|
|
667
|
+
return _context7.stop();
|
|
757
668
|
}
|
|
758
|
-
},
|
|
669
|
+
}, _callee7, this);
|
|
759
670
|
}));
|
|
760
671
|
function resetAndLoadCustomers() {
|
|
761
672
|
return _resetAndLoadCustomers.apply(this, arguments);
|
|
@@ -110,8 +110,6 @@ export interface CustomerState {
|
|
|
110
110
|
export interface CustomerModuleAPI {
|
|
111
111
|
/** 获取客户列表 */
|
|
112
112
|
getCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
|
|
113
|
-
/** 查询客户列表但不更新列表分页状态 */
|
|
114
|
-
queryCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
|
|
115
113
|
/** 设置客户列表 */
|
|
116
114
|
setCustomerList: (customers: ShopCustomer[], total?: number) => void;
|
|
117
115
|
/** 设置当前选择的客户 */
|