ts-glitter 21.7.1 → 21.7.2
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/lowcode/Entry.js +1 -1
- package/lowcode/Entry.ts +1 -1
- package/lowcode/public-components/checkout/index.js +6 -7
- package/lowcode/public-components/checkout/index.ts +9 -7
- package/lowcode/public-components/modules/cart-module.js +3 -12
- package/lowcode/public-components/modules/cart-module.ts +4 -11
- package/package.json +1 -1
- package/src/api-public/services/checkout-event.js +17 -7
- package/src/api-public/services/checkout-event.js.map +1 -1
- package/src/api-public/services/shopping.js +18 -5
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +29 -5
|
@@ -2737,8 +2737,8 @@ export class Shopping {
|
|
|
2737
2737
|
voucher.bind.map(item => {
|
|
2738
2738
|
voucher.bind_subtotal += item.count * item.sale_price;
|
|
2739
2739
|
});
|
|
2740
|
-
if (
|
|
2741
|
-
voucher.bind_subtotal -= cart.discount;
|
|
2740
|
+
if (voucher.includeDiscount === 'after') {
|
|
2741
|
+
voucher.bind_subtotal -= (cart.discount ?? 0) + cart.use_rebate;
|
|
2742
2742
|
}
|
|
2743
2743
|
if (voucher.rule === 'min_price') {
|
|
2744
2744
|
cartValue = voucher.bind_subtotal;
|
|
@@ -2761,6 +2761,7 @@ export class Shopping {
|
|
|
2761
2761
|
// 回傳免運費判斷
|
|
2762
2762
|
return cart.shipment_fee > 0 && isSelectShipment() && cartValue >= ruleValue;
|
|
2763
2763
|
}
|
|
2764
|
+
|
|
2764
2765
|
if (cartValue >= ruleValue) {
|
|
2765
2766
|
if (voucher.counting === 'each') {
|
|
2766
2767
|
voucher.times = Math.floor(cartValue / ruleValue);
|
|
@@ -2776,12 +2777,24 @@ export class Shopping {
|
|
|
2776
2777
|
// 計算單位為商品的優惠觸發
|
|
2777
2778
|
if (voucher.conditionType === 'item') {
|
|
2778
2779
|
if (voucher.rule === 'min_price') {
|
|
2779
|
-
|
|
2780
|
+
// 分配使用購物金在每個商品的價值金額
|
|
2781
|
+
const proportions: number[] = [];
|
|
2782
|
+
const subtotal = voucher.bind.reduce((sum, item) => sum + item.sale_price * item.count, 0);
|
|
2783
|
+
|
|
2784
|
+
voucher.bind.map(item => {
|
|
2785
|
+
const useRebate = Math.floor(cart.use_rebate * Tool.floatAdd((item.sale_price * item.count) / subtotal, 0));
|
|
2786
|
+
proportions.push(useRebate);
|
|
2787
|
+
});
|
|
2788
|
+
|
|
2789
|
+
// 篩選優惠觸發前後與觸發次數
|
|
2790
|
+
voucher.bind = voucher.bind.filter((item, index) => {
|
|
2780
2791
|
item.times = 0;
|
|
2781
2792
|
let subtotal = item.count * item.sale_price;
|
|
2782
|
-
|
|
2783
|
-
|
|
2793
|
+
|
|
2794
|
+
if (voucher.includeDiscount === 'after') {
|
|
2795
|
+
subtotal -= (reduceDiscount[item.id] ?? 0) + proportions[index];
|
|
2784
2796
|
}
|
|
2797
|
+
|
|
2785
2798
|
if (subtotal >= ruleValue) {
|
|
2786
2799
|
if (voucher.counting === 'each') {
|
|
2787
2800
|
item.times = Math.floor(subtotal / ruleValue);
|
|
@@ -2804,6 +2817,7 @@ export class Shopping {
|
|
|
2804
2817
|
item.times = 1;
|
|
2805
2818
|
}
|
|
2806
2819
|
}
|
|
2820
|
+
|
|
2807
2821
|
return item.times > 0;
|
|
2808
2822
|
});
|
|
2809
2823
|
}
|
|
@@ -3046,6 +3060,16 @@ export class Shopping {
|
|
|
3046
3060
|
if (prevStatus !== '-1' && orderData.orderStatus === '-1') {
|
|
3047
3061
|
await this.resetStore(origin.orderData.lineItems);
|
|
3048
3062
|
|
|
3063
|
+
// 已取消過的紀錄
|
|
3064
|
+
const usedCancel = origin.orderData.editRecord.some((data: any) => data.record.includes('訂單已取消'));
|
|
3065
|
+
|
|
3066
|
+
// 扣除已售出數值
|
|
3067
|
+
if (!usedCancel) {
|
|
3068
|
+
origin.orderData.lineItems.map(async (item: any) => {
|
|
3069
|
+
await this.calcSoldOutStock(item.count * -1, item.id, item.spec);
|
|
3070
|
+
});
|
|
3071
|
+
}
|
|
3072
|
+
|
|
3049
3073
|
const emailList = new Set(
|
|
3050
3074
|
[origin.orderData.customer_info, origin.orderData.user_info].map(user => user?.email)
|
|
3051
3075
|
);
|