@pisell/pisellos 0.0.257 → 0.0.259
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Discount/types.d.ts +3 -0
- package/dist/modules/Payment/walletpass.js +2 -3
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.js +35 -10
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Checkout/index.js +70 -40
- package/dist/solution/ShopDiscount/utils.d.ts +11 -0
- package/dist/solution/ShopDiscount/utils.js +29 -0
- package/lib/modules/Discount/types.d.ts +3 -0
- package/lib/modules/Payment/walletpass.js +1 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.js +21 -5
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Checkout/index.js +26 -3
- package/lib/solution/ShopDiscount/utils.d.ts +11 -0
- package/lib/solution/ShopDiscount/utils.js +24 -0
- package/package.json +1 -1
|
@@ -70,6 +70,9 @@ export interface Discount {
|
|
|
70
70
|
limited_relation_product_data: Limitedrelationproductdata;
|
|
71
71
|
balance: string;
|
|
72
72
|
format_title: Formattitle;
|
|
73
|
+
metadata?: {
|
|
74
|
+
discount_card_type?: 'fixed_amount' | 'percent';
|
|
75
|
+
};
|
|
73
76
|
product: Product;
|
|
74
77
|
type: "product" | 'good_pass';
|
|
75
78
|
resource_id?: number;
|
|
@@ -406,9 +406,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
406
406
|
});
|
|
407
407
|
|
|
408
408
|
// 检查识别码是否为9位且前3位为"000"
|
|
409
|
-
|
|
410
|
-
//
|
|
411
|
-
isWalletCode = code.startsWith('WL');
|
|
409
|
+
isWalletCode = code.length === 9 && code.startsWith('000'); // 测试环境先使用 WL
|
|
410
|
+
// const isWalletCode = code.startsWith('WL');
|
|
412
411
|
if (!isWalletCode) {
|
|
413
412
|
_context5.next = 14;
|
|
414
413
|
break;
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -25,7 +25,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
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
27
|
import { RulesHooks } from "./types";
|
|
28
|
-
import { uniqueById } from "../../solution/ShopDiscount/utils";
|
|
28
|
+
import { uniqueById, getDiscountAmount } from "../../solution/ShopDiscount/utils";
|
|
29
29
|
import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils";
|
|
30
30
|
import Decimal from 'decimal.js';
|
|
31
31
|
import { isBoolean } from 'lodash-es';
|
|
@@ -189,8 +189,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
189
189
|
});
|
|
190
190
|
|
|
191
191
|
// 优惠力度排序,传进来的数据里可能有商品券,也可能有优惠券
|
|
192
|
-
// 商品券(n.tag=good_pass
|
|
193
|
-
//
|
|
192
|
+
// 1. 商品券(n.tag=good_pass)视为最优惠(免费)
|
|
193
|
+
// 2. 折扣券(n.tag=product_discount_card)按照新的优先级排序:
|
|
194
|
+
// - 固定金额优先于百分比(固定金额 > 百分比)
|
|
195
|
+
// - 固定金额内部:金额越大越优先
|
|
196
|
+
// - 百分比内部:折扣越大越优先(par_value越小越优先)
|
|
197
|
+
// 3. 相同类型和金额的情况下,按照过期时间(n.expire_time)排序
|
|
194
198
|
var sortedDiscountList = _toConsumableArray(filteredDiscountList).sort(function (a, b) {
|
|
195
199
|
// 1. 商品券优先级最高
|
|
196
200
|
if (a.tag === 'good_pass' && b.tag !== 'good_pass') return -1;
|
|
@@ -201,13 +205,34 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
201
205
|
// 都是商品券,按照过期时间排序
|
|
202
206
|
return compareByExpireTime(a, b);
|
|
203
207
|
} else if (a.tag === 'product_discount_card' && b.tag === 'product_discount_card') {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
var _a$metadata, _b$metadata;
|
|
209
|
+
// 都是折扣券,按照新的优先级排序:固定金额优先于百分比
|
|
210
|
+
var typeA = ((_a$metadata = a.metadata) === null || _a$metadata === void 0 ? void 0 : _a$metadata.discount_card_type) || 'percent'; // 默认为百分比
|
|
211
|
+
var typeB = ((_b$metadata = b.metadata) === null || _b$metadata === void 0 ? void 0 : _b$metadata.discount_card_type) || 'percent'; // 默认为百分比
|
|
212
|
+
|
|
213
|
+
// 1. 固定金额优先于百分比
|
|
214
|
+
if (typeA === 'fixed_amount' && typeB === 'percent') return -1;
|
|
215
|
+
if (typeA === 'percent' && typeB === 'fixed_amount') return 1;
|
|
216
|
+
|
|
217
|
+
// 2. 都是固定金额时,金额越大越优先
|
|
218
|
+
if (typeA === 'fixed_amount' && typeB === 'fixed_amount') {
|
|
219
|
+
if (a.par_value !== b.par_value) {
|
|
220
|
+
var valueA = new Decimal(a.par_value || 0);
|
|
221
|
+
var valueB = new Decimal(b.par_value || 0);
|
|
222
|
+
return valueB.minus(valueA).toNumber(); // 金额大的在前
|
|
223
|
+
}
|
|
209
224
|
}
|
|
210
|
-
|
|
225
|
+
|
|
226
|
+
// 3. 都是百分比时,折扣越大越优先(par_value越小越优先)
|
|
227
|
+
if (typeA === 'percent' && typeB === 'percent') {
|
|
228
|
+
if (a.par_value !== b.par_value) {
|
|
229
|
+
var _valueA = new Decimal(100).minus(a.par_value || 0);
|
|
230
|
+
var _valueB = new Decimal(100).minus(b.par_value || 0);
|
|
231
|
+
return _valueB.minus(_valueA).toNumber(); // 折扣大的在前
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// 相同类型和金额的情况下,按照过期时间排序
|
|
211
236
|
return compareByExpireTime(a, b);
|
|
212
237
|
}
|
|
213
238
|
|
|
@@ -465,7 +490,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
465
490
|
}
|
|
466
491
|
|
|
467
492
|
// 计算使用折扣卡/商品券以后,单个商品的总 total
|
|
468
|
-
var targetProductTotal = _selectedDiscount
|
|
493
|
+
var targetProductTotal = getDiscountAmount(_selectedDiscount, productOriginTotal, product.price);
|
|
469
494
|
var discountType = _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : _selectedDiscount.tag;
|
|
470
495
|
var discountDetail = {
|
|
471
496
|
amount: new Decimal(productOriginTotal).minus(new Decimal(targetProductTotal)).toNumber(),
|
|
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
111
111
|
* 获取当前的客户搜索条件
|
|
112
112
|
* @returns 当前搜索条件
|
|
113
113
|
*/
|
|
114
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
114
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
115
115
|
/**
|
|
116
116
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
117
117
|
* @returns 客户状态
|
|
@@ -2673,8 +2673,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2673
2673
|
value: (function () {
|
|
2674
2674
|
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
2675
2675
|
var _this4 = this,
|
|
2676
|
-
_this$store$currentCu2,
|
|
2677
2676
|
_this$store$currentOr17,
|
|
2677
|
+
_this$store$currentCu2,
|
|
2678
2678
|
_this$store$currentOr18,
|
|
2679
2679
|
_checkoutResponse3,
|
|
2680
2680
|
_checkoutResponse4;
|
|
@@ -2684,6 +2684,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2684
2684
|
isUpdateOperation,
|
|
2685
2685
|
paymentItems,
|
|
2686
2686
|
processedPaymentItems,
|
|
2687
|
+
depositPaymentItems,
|
|
2688
|
+
calculatedDepositAmount,
|
|
2687
2689
|
orderParams,
|
|
2688
2690
|
startTime,
|
|
2689
2691
|
checkoutResponse,
|
|
@@ -2747,7 +2749,34 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2747
2749
|
shop_wallet_pass_id: ((_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.shop_wallet_pass_id) || _this4.otherParams.shop_wallet_pass_id
|
|
2748
2750
|
})
|
|
2749
2751
|
});
|
|
2750
|
-
}); //
|
|
2752
|
+
}); // 计算定金支付项的总金额(order_payment_type="deposit")
|
|
2753
|
+
depositPaymentItems = processedPaymentItems.filter(function (item) {
|
|
2754
|
+
return item.order_payment_type === 'deposit' && item.status !== 'voided';
|
|
2755
|
+
});
|
|
2756
|
+
calculatedDepositAmount = depositPaymentItems.reduce(function (sum, item) {
|
|
2757
|
+
var amount = new Decimal(item.amount || '0');
|
|
2758
|
+
var roundingAmount = new Decimal(item.rounding_amount || '0');
|
|
2759
|
+
// 包含抹零计算的有效支付金额
|
|
2760
|
+
var effectiveAmount = amount.add(roundingAmount.abs());
|
|
2761
|
+
return sum.add(effectiveAmount);
|
|
2762
|
+
}, new Decimal(0)).toFixed(2);
|
|
2763
|
+
this.logInfo('计算定金支付项总金额', {
|
|
2764
|
+
depositPaymentItemsCount: depositPaymentItems.length,
|
|
2765
|
+
depositPaymentItems: depositPaymentItems.map(function (item) {
|
|
2766
|
+
return {
|
|
2767
|
+
uuid: item.uuid,
|
|
2768
|
+
code: item.code,
|
|
2769
|
+
amount: item.amount,
|
|
2770
|
+
rounding_amount: item.rounding_amount,
|
|
2771
|
+
order_payment_type: item.order_payment_type,
|
|
2772
|
+
status: item.status
|
|
2773
|
+
};
|
|
2774
|
+
}),
|
|
2775
|
+
calculatedDepositAmount: calculatedDepositAmount,
|
|
2776
|
+
originalDepositAmount: ((_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.deposit_amount) || '0.00'
|
|
2777
|
+
});
|
|
2778
|
+
|
|
2779
|
+
// 构造订单参数,直接使用 localOrderData 中已处理好的数据
|
|
2751
2780
|
orderParams = _objectSpread(_objectSpread({}, this.store.localOrderData), {}, {
|
|
2752
2781
|
type: this.store.localOrderData.type,
|
|
2753
2782
|
platform: this.store.localOrderData.platform,
|
|
@@ -2766,8 +2795,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2766
2795
|
currency_code: this.otherParams.currency_code,
|
|
2767
2796
|
currency_symbol: this.otherParams.currency_symbol,
|
|
2768
2797
|
currency_format: this.otherParams.currency_format,
|
|
2769
|
-
is_deposit: ((_this$store$
|
|
2770
|
-
deposit_amount:
|
|
2798
|
+
is_deposit: ((_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.is_deposit) || 0,
|
|
2799
|
+
deposit_amount: calculatedDepositAmount,
|
|
2800
|
+
// 使用从支付项中计算出的定金金额
|
|
2771
2801
|
product_tax_fee: this.store.localOrderData.tax_fee,
|
|
2772
2802
|
note: this.store.localOrderData.shop_note
|
|
2773
2803
|
}); // 如果是更新操作,需要在参数中包含真实的订单ID
|
|
@@ -2782,7 +2812,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2782
2812
|
|
|
2783
2813
|
// 发送下单接口请求开始事件
|
|
2784
2814
|
startTime = Date.now();
|
|
2785
|
-
_context34.next =
|
|
2815
|
+
_context34.next = 23;
|
|
2786
2816
|
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitStart, {
|
|
2787
2817
|
orderUuid: this.store.currentOrder.uuid,
|
|
2788
2818
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -2790,9 +2820,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2790
2820
|
paymentItemCount: paymentItems.length,
|
|
2791
2821
|
timestamp: startTime
|
|
2792
2822
|
});
|
|
2793
|
-
case
|
|
2823
|
+
case 23:
|
|
2794
2824
|
submitSuccess = false;
|
|
2795
|
-
_context34.prev =
|
|
2825
|
+
_context34.prev = 24;
|
|
2796
2826
|
// 记录接口调用参数
|
|
2797
2827
|
this.logInfo('Calling backend checkout API', _objectSpread({
|
|
2798
2828
|
url: '/order/checkout',
|
|
@@ -2800,23 +2830,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2800
2830
|
}, orderParams));
|
|
2801
2831
|
|
|
2802
2832
|
// 调用 Order 模块的专用 createOrderByCheckout 方法
|
|
2803
|
-
_context34.next =
|
|
2833
|
+
_context34.next = 28;
|
|
2804
2834
|
return this.order.createOrderByCheckout(orderParams);
|
|
2805
|
-
case
|
|
2835
|
+
case 28:
|
|
2806
2836
|
checkoutResponse = _context34.sent;
|
|
2807
2837
|
submitSuccess = true;
|
|
2808
2838
|
this.logInfo('下单接口调用成功', checkoutResponse);
|
|
2809
|
-
_context34.next =
|
|
2839
|
+
_context34.next = 41;
|
|
2810
2840
|
break;
|
|
2811
|
-
case
|
|
2812
|
-
_context34.prev =
|
|
2813
|
-
_context34.t1 = _context34["catch"](
|
|
2841
|
+
case 33:
|
|
2842
|
+
_context34.prev = 33;
|
|
2843
|
+
_context34.t1 = _context34["catch"](24);
|
|
2814
2844
|
submitSuccess = false;
|
|
2815
2845
|
submitError = _context34.t1 instanceof Error ? _context34.t1.message : String(_context34.t1);
|
|
2816
2846
|
this.logError('下单接口调用失败:', submitError);
|
|
2817
2847
|
|
|
2818
2848
|
// 发送订单同步失败事件(网络错误或请求失败)
|
|
2819
|
-
_context34.next =
|
|
2849
|
+
_context34.next = 40;
|
|
2820
2850
|
return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
|
|
2821
2851
|
orderUuid: this.store.currentOrder.uuid,
|
|
2822
2852
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -2826,11 +2856,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2826
2856
|
duration: Date.now() - startTime,
|
|
2827
2857
|
timestamp: Date.now()
|
|
2828
2858
|
});
|
|
2829
|
-
case
|
|
2859
|
+
case 40:
|
|
2830
2860
|
throw _context34.t1;
|
|
2831
|
-
case
|
|
2832
|
-
_context34.prev =
|
|
2833
|
-
_context34.next =
|
|
2861
|
+
case 41:
|
|
2862
|
+
_context34.prev = 41;
|
|
2863
|
+
_context34.next = 44;
|
|
2834
2864
|
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitEnd, {
|
|
2835
2865
|
success: submitSuccess,
|
|
2836
2866
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -2841,18 +2871,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2841
2871
|
duration: Date.now() - startTime,
|
|
2842
2872
|
timestamp: Date.now()
|
|
2843
2873
|
});
|
|
2844
|
-
case
|
|
2845
|
-
return _context34.finish(
|
|
2846
|
-
case
|
|
2874
|
+
case 44:
|
|
2875
|
+
return _context34.finish(41);
|
|
2876
|
+
case 45:
|
|
2847
2877
|
// 检查响应状态是否为成功状态
|
|
2848
2878
|
responseStatus = (_checkoutResponse3 = checkoutResponse) === null || _checkoutResponse3 === void 0 ? void 0 : _checkoutResponse3.status;
|
|
2849
2879
|
isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((_checkoutResponse4 = checkoutResponse) === null || _checkoutResponse4 === void 0 ? void 0 : _checkoutResponse4.code) === 200;
|
|
2850
2880
|
if (isSuccessResponse) {
|
|
2851
|
-
_context34.next =
|
|
2881
|
+
_context34.next = 52;
|
|
2852
2882
|
break;
|
|
2853
2883
|
}
|
|
2854
2884
|
errorMessage = ((_checkoutResponse5 = checkoutResponse) === null || _checkoutResponse5 === void 0 ? void 0 : _checkoutResponse5.message) || '订单同步失败,后端返回非成功状态'; // 发送订单同步失败事件
|
|
2855
|
-
_context34.next =
|
|
2885
|
+
_context34.next = 51;
|
|
2856
2886
|
return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
|
|
2857
2887
|
orderUuid: this.store.currentOrder.uuid,
|
|
2858
2888
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -2863,18 +2893,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2863
2893
|
duration: Date.now() - startTime,
|
|
2864
2894
|
timestamp: Date.now()
|
|
2865
2895
|
});
|
|
2866
|
-
case
|
|
2896
|
+
case 51:
|
|
2867
2897
|
throw new Error(errorMessage);
|
|
2868
|
-
case
|
|
2898
|
+
case 52:
|
|
2869
2899
|
if (!isUpdateOperation) {
|
|
2870
|
-
_context34.next =
|
|
2900
|
+
_context34.next = 56;
|
|
2871
2901
|
break;
|
|
2872
2902
|
}
|
|
2873
2903
|
// 更新操作:使用现有的订单ID
|
|
2874
2904
|
realOrderId = currentOrderId;
|
|
2875
|
-
_context34.next =
|
|
2905
|
+
_context34.next = 75;
|
|
2876
2906
|
break;
|
|
2877
|
-
case
|
|
2907
|
+
case 56:
|
|
2878
2908
|
// 创建操作:从响应中提取新的订单ID
|
|
2879
2909
|
extractedOrderId = (_checkoutResponse6 = checkoutResponse) === null || _checkoutResponse6 === void 0 || (_checkoutResponse6 = _checkoutResponse6.data) === null || _checkoutResponse6 === void 0 ? void 0 : _checkoutResponse6.order_id; // 如果data.order_id不存在,尝试直接从根级获取
|
|
2880
2910
|
if (!extractedOrderId) {
|
|
@@ -2896,10 +2926,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2896
2926
|
oldOrderId: this.store.currentOrder.order_id,
|
|
2897
2927
|
newOrderId: realOrderId
|
|
2898
2928
|
});
|
|
2899
|
-
_context34.prev =
|
|
2900
|
-
_context34.next =
|
|
2929
|
+
_context34.prev = 62;
|
|
2930
|
+
_context34.next = 65;
|
|
2901
2931
|
return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, realOrderId);
|
|
2902
|
-
case
|
|
2932
|
+
case 65:
|
|
2903
2933
|
updatedOrder = _context34.sent;
|
|
2904
2934
|
this.logInfo('Payment模块替换订单ID结果:', {
|
|
2905
2935
|
wasSuccessful: !!updatedOrder,
|
|
@@ -2926,22 +2956,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2926
2956
|
目标ID: realOrderId
|
|
2927
2957
|
});
|
|
2928
2958
|
}
|
|
2929
|
-
_context34.next =
|
|
2959
|
+
_context34.next = 75;
|
|
2930
2960
|
break;
|
|
2931
|
-
case
|
|
2932
|
-
_context34.prev =
|
|
2933
|
-
_context34.t2 = _context34["catch"](
|
|
2961
|
+
case 70:
|
|
2962
|
+
_context34.prev = 70;
|
|
2963
|
+
_context34.t2 = _context34["catch"](62);
|
|
2934
2964
|
this.logError('调用Payment模块替换订单ID时发生错误:', _context34.t2);
|
|
2935
2965
|
|
|
2936
2966
|
// 发生错误时也进行手动替换
|
|
2937
2967
|
this.store.currentOrder.order_id = realOrderId;
|
|
2938
2968
|
this.logInfo('错误恢复:手动设置订单ID:', realOrderId);
|
|
2939
|
-
case
|
|
2969
|
+
case 75:
|
|
2940
2970
|
// 标记订单已同步
|
|
2941
2971
|
this.store.isOrderSynced = true;
|
|
2942
2972
|
|
|
2943
2973
|
// 触发订单同步完成事件
|
|
2944
|
-
_context34.next =
|
|
2974
|
+
_context34.next = 78;
|
|
2945
2975
|
return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
|
|
2946
2976
|
orderUuid: this.store.currentOrder.uuid,
|
|
2947
2977
|
realOrderId: realOrderId,
|
|
@@ -2950,18 +2980,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2950
2980
|
isManual: isManual,
|
|
2951
2981
|
response: checkoutResponse
|
|
2952
2982
|
});
|
|
2953
|
-
case
|
|
2983
|
+
case 78:
|
|
2954
2984
|
return _context34.abrupt("return", {
|
|
2955
2985
|
success: true,
|
|
2956
2986
|
orderId: realOrderId,
|
|
2957
2987
|
orderUuid: this.store.currentOrder.uuid,
|
|
2958
2988
|
response: checkoutResponse
|
|
2959
2989
|
});
|
|
2960
|
-
case
|
|
2990
|
+
case 79:
|
|
2961
2991
|
case "end":
|
|
2962
2992
|
return _context34.stop();
|
|
2963
2993
|
}
|
|
2964
|
-
}, _callee34, this, [[
|
|
2994
|
+
}, _callee34, this, [[24, 33, 41, 45], [62, 70]]);
|
|
2965
2995
|
}));
|
|
2966
2996
|
function syncOrderToBackendWithReturn() {
|
|
2967
2997
|
return _syncOrderToBackendWithReturn.apply(this, arguments);
|
|
@@ -1 +1,12 @@
|
|
|
1
|
+
import { Discount } from "../../modules/Discount/types";
|
|
1
2
|
export declare const uniqueById: <T>(arr: T[], key?: string) => T[];
|
|
3
|
+
/**
|
|
4
|
+
* 获取折扣金额 基于折扣卡类型计算
|
|
5
|
+
* 商品券:直接返回商品价格
|
|
6
|
+
* 折扣卡:根据折扣卡类型计算 固定金额:直接返回折扣卡金额 百分比:根据折扣卡金额计算
|
|
7
|
+
* @param discount
|
|
8
|
+
* @param total
|
|
9
|
+
* @param price
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export declare const getDiscountAmount: (discount: Discount, total: number, price: number) => number;
|
|
@@ -1,7 +1,36 @@
|
|
|
1
|
+
import Decimal from "decimal.js";
|
|
1
2
|
export var uniqueById = function uniqueById(arr) {
|
|
2
3
|
var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id';
|
|
3
4
|
var seen = new Set();
|
|
4
5
|
return arr.filter(function (item) {
|
|
5
6
|
return !seen.has(item[key]) && seen.add(item[key]);
|
|
6
7
|
});
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 获取折扣金额 基于折扣卡类型计算
|
|
12
|
+
* 商品券:直接返回商品价格
|
|
13
|
+
* 折扣卡:根据折扣卡类型计算 固定金额:直接返回折扣卡金额 百分比:根据折扣卡金额计算
|
|
14
|
+
* @param discount
|
|
15
|
+
* @param total
|
|
16
|
+
* @param price
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export var getDiscountAmount = function getDiscountAmount(discount, total, price) {
|
|
20
|
+
var _discount$metadata;
|
|
21
|
+
// 商品券
|
|
22
|
+
if (discount.tag === 'good_pass') {
|
|
23
|
+
return new Decimal(total).minus(new Decimal(price || 0)).toNumber();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 判断是否是固定金额
|
|
27
|
+
var isFixedAmount = (discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.discount_card_type) === 'fixed_amount';
|
|
28
|
+
|
|
29
|
+
// 固定金额 小于0时返回0
|
|
30
|
+
if (isFixedAmount) {
|
|
31
|
+
return Math.max(new Decimal(total).minus(new Decimal(discount.par_value || 0)).toNumber(), 0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 百分比:根据折扣卡金额计算
|
|
35
|
+
return new Decimal(100).minus(discount.par_value || 0).div(100).mul(new Decimal(total)).toNumber();
|
|
7
36
|
};
|
|
@@ -70,6 +70,9 @@ export interface Discount {
|
|
|
70
70
|
limited_relation_product_data: Limitedrelationproductdata;
|
|
71
71
|
balance: string;
|
|
72
72
|
format_title: Formattitle;
|
|
73
|
+
metadata?: {
|
|
74
|
+
discount_card_type?: 'fixed_amount' | 'percent';
|
|
75
|
+
};
|
|
73
76
|
product: Product;
|
|
74
77
|
type: "product" | 'good_pass';
|
|
75
78
|
resource_id?: number;
|
|
@@ -268,7 +268,7 @@ var WalletPassPaymentImpl = class {
|
|
|
268
268
|
code_length: code.length,
|
|
269
269
|
noCache: config.noCache || false
|
|
270
270
|
});
|
|
271
|
-
const isWalletCode = code.startsWith("
|
|
271
|
+
const isWalletCode = code.length === 9 && code.startsWith("000");
|
|
272
272
|
if (isWalletCode) {
|
|
273
273
|
const walletDetailParams = {
|
|
274
274
|
code,
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -132,6 +132,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
132
132
|
return !discount.isManualSelect;
|
|
133
133
|
});
|
|
134
134
|
const sortedDiscountList = [...filteredDiscountList].sort((a, b) => {
|
|
135
|
+
var _a, _b;
|
|
135
136
|
if (a.tag === "good_pass" && b.tag !== "good_pass")
|
|
136
137
|
return -1;
|
|
137
138
|
if (b.tag === "good_pass" && a.tag !== "good_pass")
|
|
@@ -139,10 +140,25 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
139
140
|
if (a.tag === "good_pass" && b.tag === "good_pass") {
|
|
140
141
|
return compareByExpireTime(a, b);
|
|
141
142
|
} else if (a.tag === "product_discount_card" && b.tag === "product_discount_card") {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return
|
|
143
|
+
const typeA = ((_a = a.metadata) == null ? void 0 : _a.discount_card_type) || "percent";
|
|
144
|
+
const typeB = ((_b = b.metadata) == null ? void 0 : _b.discount_card_type) || "percent";
|
|
145
|
+
if (typeA === "fixed_amount" && typeB === "percent")
|
|
146
|
+
return -1;
|
|
147
|
+
if (typeA === "percent" && typeB === "fixed_amount")
|
|
148
|
+
return 1;
|
|
149
|
+
if (typeA === "fixed_amount" && typeB === "fixed_amount") {
|
|
150
|
+
if (a.par_value !== b.par_value) {
|
|
151
|
+
const valueA = new import_decimal.default(a.par_value || 0);
|
|
152
|
+
const valueB = new import_decimal.default(b.par_value || 0);
|
|
153
|
+
return valueB.minus(valueA).toNumber();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (typeA === "percent" && typeB === "percent") {
|
|
157
|
+
if (a.par_value !== b.par_value) {
|
|
158
|
+
const valueA = new import_decimal.default(100).minus(a.par_value || 0);
|
|
159
|
+
const valueB = new import_decimal.default(100).minus(b.par_value || 0);
|
|
160
|
+
return valueB.minus(valueA).toNumber();
|
|
161
|
+
}
|
|
146
162
|
}
|
|
147
163
|
return compareByExpireTime(a, b);
|
|
148
164
|
}
|
|
@@ -322,7 +338,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
322
338
|
if (Number(((_i = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _i.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
|
|
323
339
|
productOriginTotal = product.total;
|
|
324
340
|
}
|
|
325
|
-
const targetProductTotal =
|
|
341
|
+
const targetProductTotal = (0, import_utils.getDiscountAmount)(selectedDiscount2, productOriginTotal, product.price);
|
|
326
342
|
const discountType = selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag;
|
|
327
343
|
const discountDetail = {
|
|
328
344
|
amount: new import_decimal.default(productOriginTotal).minus(new import_decimal.default(targetProductTotal)).toNumber(),
|
|
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
111
111
|
* 获取当前的客户搜索条件
|
|
112
112
|
* @returns 当前搜索条件
|
|
113
113
|
*/
|
|
114
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
114
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
115
115
|
/**
|
|
116
116
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
117
117
|
* @returns 客户状态
|
|
@@ -1636,13 +1636,35 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1636
1636
|
}
|
|
1637
1637
|
};
|
|
1638
1638
|
});
|
|
1639
|
+
const depositPaymentItems = processedPaymentItems.filter(
|
|
1640
|
+
(item) => item.order_payment_type === "deposit" && item.status !== "voided"
|
|
1641
|
+
);
|
|
1642
|
+
const calculatedDepositAmount = depositPaymentItems.reduce((sum, item) => {
|
|
1643
|
+
const amount = new import_decimal.default(item.amount || "0");
|
|
1644
|
+
const roundingAmount = new import_decimal.default(item.rounding_amount || "0");
|
|
1645
|
+
const effectiveAmount = amount.add(roundingAmount.abs());
|
|
1646
|
+
return sum.add(effectiveAmount);
|
|
1647
|
+
}, new import_decimal.default(0)).toFixed(2);
|
|
1648
|
+
this.logInfo("计算定金支付项总金额", {
|
|
1649
|
+
depositPaymentItemsCount: depositPaymentItems.length,
|
|
1650
|
+
depositPaymentItems: depositPaymentItems.map((item) => ({
|
|
1651
|
+
uuid: item.uuid,
|
|
1652
|
+
code: item.code,
|
|
1653
|
+
amount: item.amount,
|
|
1654
|
+
rounding_amount: item.rounding_amount,
|
|
1655
|
+
order_payment_type: item.order_payment_type,
|
|
1656
|
+
status: item.status
|
|
1657
|
+
})),
|
|
1658
|
+
calculatedDepositAmount,
|
|
1659
|
+
originalDepositAmount: ((_a = this.store.currentOrder) == null ? void 0 : _a.deposit_amount) || "0.00"
|
|
1660
|
+
});
|
|
1639
1661
|
const orderParams = {
|
|
1640
1662
|
...this.store.localOrderData,
|
|
1641
1663
|
type: this.store.localOrderData.type,
|
|
1642
1664
|
platform: this.store.localOrderData.platform,
|
|
1643
1665
|
payments: processedPaymentItems,
|
|
1644
1666
|
// 使用处理过的支付项数据
|
|
1645
|
-
customer_id: (
|
|
1667
|
+
customer_id: (_b = this.store.currentCustomer) == null ? void 0 : _b.customer_id,
|
|
1646
1668
|
// 添加客户ID
|
|
1647
1669
|
is_price_include_tax: this.otherParams.is_price_include_tax,
|
|
1648
1670
|
// core 有
|
|
@@ -1655,8 +1677,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1655
1677
|
currency_code: this.otherParams.currency_code,
|
|
1656
1678
|
currency_symbol: this.otherParams.currency_symbol,
|
|
1657
1679
|
currency_format: this.otherParams.currency_format,
|
|
1658
|
-
is_deposit: ((
|
|
1659
|
-
deposit_amount:
|
|
1680
|
+
is_deposit: ((_c = this.store.currentOrder) == null ? void 0 : _c.is_deposit) || 0,
|
|
1681
|
+
deposit_amount: calculatedDepositAmount,
|
|
1682
|
+
// 使用从支付项中计算出的定金金额
|
|
1660
1683
|
product_tax_fee: this.store.localOrderData.tax_fee,
|
|
1661
1684
|
note: this.store.localOrderData.shop_note
|
|
1662
1685
|
};
|
|
@@ -1 +1,12 @@
|
|
|
1
|
+
import { Discount } from "../../modules/Discount/types";
|
|
1
2
|
export declare const uniqueById: <T>(arr: T[], key?: string) => T[];
|
|
3
|
+
/**
|
|
4
|
+
* 获取折扣金额 基于折扣卡类型计算
|
|
5
|
+
* 商品券:直接返回商品价格
|
|
6
|
+
* 折扣卡:根据折扣卡类型计算 固定金额:直接返回折扣卡金额 百分比:根据折扣卡金额计算
|
|
7
|
+
* @param discount
|
|
8
|
+
* @param total
|
|
9
|
+
* @param price
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export declare const getDiscountAmount: (discount: Discount, total: number, price: number) => number;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,19 +16,41 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/solution/ShopDiscount/utils.ts
|
|
20
30
|
var utils_exports = {};
|
|
21
31
|
__export(utils_exports, {
|
|
32
|
+
getDiscountAmount: () => getDiscountAmount,
|
|
22
33
|
uniqueById: () => uniqueById
|
|
23
34
|
});
|
|
24
35
|
module.exports = __toCommonJS(utils_exports);
|
|
36
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
25
37
|
var uniqueById = (arr, key = "id") => {
|
|
26
38
|
const seen = /* @__PURE__ */ new Set();
|
|
27
39
|
return arr.filter((item) => !seen.has(item[key]) && seen.add(item[key]));
|
|
28
40
|
};
|
|
41
|
+
var getDiscountAmount = (discount, total, price) => {
|
|
42
|
+
var _a;
|
|
43
|
+
if (discount.tag === "good_pass") {
|
|
44
|
+
return new import_decimal.default(total).minus(new import_decimal.default(price || 0)).toNumber();
|
|
45
|
+
}
|
|
46
|
+
const isFixedAmount = ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.discount_card_type) === "fixed_amount";
|
|
47
|
+
if (isFixedAmount) {
|
|
48
|
+
return Math.max(new import_decimal.default(total).minus(new import_decimal.default(discount.par_value || 0)).toNumber(), 0);
|
|
49
|
+
}
|
|
50
|
+
return new import_decimal.default(100).minus(discount.par_value || 0).div(100).mul(new import_decimal.default(total)).toNumber();
|
|
51
|
+
};
|
|
29
52
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
53
|
0 && (module.exports = {
|
|
54
|
+
getDiscountAmount,
|
|
31
55
|
uniqueById
|
|
32
56
|
});
|