优惠券计算更新

This commit is contained in:
2025-10-13 11:24:11 +08:00
parent 8f7852f834
commit 6216dcbfee
4 changed files with 419 additions and 550 deletions

View File

@@ -7,6 +7,6 @@
"lodash": "^4.17.21", "lodash": "^4.17.21",
"pinia": "^2.3.1", "pinia": "^2.3.1",
"pinia-plugin-unistorage": "^0.1.2", "pinia-plugin-unistorage": "^0.1.2",
"ysk-utils": "^1.0.35" "ysk-utils": "^1.0.40"
} }
} }

View File

@@ -464,8 +464,8 @@
const maxPointDiscount = ref(0) const maxPointDiscount = ref(0)
//积分可抵扣最大金额 //积分可抵扣最大金额
const maxMoney = computed(() => { const maxMoney = computed(() => {
return cartStore.orderCostSummary.goodsRealAmount - cartStore.orderCostSummary return cartStore.orderCostSummary.finalPayAmount + cartStore.orderCostSummary
.couponDeductionAmount .pointDeductionAmount
}) })
async function getMaxPointsDiscount() { async function getMaxPointsDiscount() {
@@ -553,11 +553,8 @@
favorablelist.value = back_favorablelist.filter(v => v.name != '新客立减') favorablelist.value = back_favorablelist.filter(v => v.name != '新客立减')
return return
} }
if (!consumeDiscountRes.isUse) {
favorablelist.value = back_favorablelist.filter(v => v.name != '新客立减') if (consumeDiscountRes) {
return
}
if (consumeDiscountRes && consumeDiscountRes.isUse) {
newUserDiscount.value = consumeDiscountRes.amount newUserDiscount.value = consumeDiscountRes.amount
cartStore.newUserDiscount = consumeDiscountRes.amount || 0 cartStore.newUserDiscount = consumeDiscountRes.amount || 0
cartStore.consumeDiscount = consumeDiscountRes cartStore.consumeDiscount = consumeDiscountRes

214
pnpm-lock.yaml generated
View File

@@ -1,4 +1,4 @@
lockfileVersion: '6.0' lockfileVersion: '9.0'
settings: settings:
autoInstallPeers: true autoInstallPeers: true
@@ -30,191 +30,114 @@ importers:
specifier: ^0.1.2 specifier: ^0.1.2
version: 0.1.2 version: 0.1.2
ysk-utils: ysk-utils:
specifier: ^1.0.35 specifier: ^1.0.40
version: 1.0.35 version: 1.0.40
packages: packages:
/@babel/helper-string-parser@7.27.1: '@babel/helper-string-parser@7.27.1':
resolution: {integrity: sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==} resolution: {integrity: sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==}
engines: {node: '>=6.9.0'} engines: {node: '>=6.9.0'}
dev: false
/@babel/helper-validator-identifier@7.27.1: '@babel/helper-validator-identifier@7.27.1':
resolution: {integrity: sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==} resolution: {integrity: sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==}
engines: {node: '>=6.9.0'} engines: {node: '>=6.9.0'}
dev: false
/@babel/parser@7.28.4: '@babel/parser@7.28.4':
resolution: {integrity: sha512-yZbBqeM6TkpP9du/I2pUZnJsRMGGvOuIrhjzC1AwHwW+6he4mni6Bp/m8ijn0iOuZuPI2BfkCoSRunpyjnrQKg==} resolution: {integrity: sha512-yZbBqeM6TkpP9du/I2pUZnJsRMGGvOuIrhjzC1AwHwW+6he4mni6Bp/m8ijn0iOuZuPI2BfkCoSRunpyjnrQKg==}
engines: {node: '>=6.0.0'} engines: {node: '>=6.0.0'}
hasBin: true hasBin: true
dependencies:
'@babel/types': 7.28.4
dev: false
/@babel/types@7.28.4: '@babel/types@7.28.4':
resolution: {integrity: sha512-bkFqkLhh3pMBUQQkpVgWDWq/lqzc2678eUyDlTBhRqhCHFguYYGM0Efga7tYk4TogG/3x0EEl66/OQ+WGbWB/Q==} resolution: {integrity: sha512-bkFqkLhh3pMBUQQkpVgWDWq/lqzc2678eUyDlTBhRqhCHFguYYGM0Efga7tYk4TogG/3x0EEl66/OQ+WGbWB/Q==}
engines: {node: '>=6.9.0'} engines: {node: '>=6.9.0'}
dependencies:
'@babel/helper-string-parser': 7.27.1
'@babel/helper-validator-identifier': 7.27.1
dev: false
/@dcloudio/types@3.4.21: '@dcloudio/types@3.4.21':
resolution: {integrity: sha512-rsv3XfAaD/dtuVboPeYh+vPcULnWyozGaGKHWyN0dYRm7L1uypFUM30qNYMj9iNmbAENuBjV177S1gNEBIvdDA==} resolution: {integrity: sha512-rsv3XfAaD/dtuVboPeYh+vPcULnWyozGaGKHWyN0dYRm7L1uypFUM30qNYMj9iNmbAENuBjV177S1gNEBIvdDA==}
dev: false
/@dcloudio/uni-app@2.0.2-4070620250821001(@dcloudio/types@3.4.21)(@vue/composition-api@1.7.2): '@dcloudio/uni-app@2.0.2-4070620250821001':
resolution: {integrity: sha512-kZBLLRmFsF3HvqfgTKHh1NDb1G7L5jJXZ3rncrGnaIirc6mE4jpBoSeqQY5jFxgQXFdJVXsHvLezBi13XiqazA==} resolution: {integrity: sha512-kZBLLRmFsF3HvqfgTKHh1NDb1G7L5jJXZ3rncrGnaIirc6mE4jpBoSeqQY5jFxgQXFdJVXsHvLezBi13XiqazA==}
peerDependencies: peerDependencies:
'@dcloudio/types': ^3.0.15 '@dcloudio/types': ^3.0.15
'@vue/composition-api': ^1.7.0 '@vue/composition-api': ^1.7.0
dependencies:
'@dcloudio/types': 3.4.21
'@vue/composition-api': 1.7.2(vue@3.5.21)
dev: false
/@jridgewell/sourcemap-codec@1.5.5: '@jridgewell/sourcemap-codec@1.5.5':
resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==} resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==}
dev: false
/@vue/compiler-core@3.5.21: '@vue/compiler-core@3.5.22':
resolution: {integrity: sha512-8i+LZ0vf6ZgII5Z9XmUvrCyEzocvWT+TeR2VBUVlzIH6Tyv57E20mPZ1bCS+tbejgUgmjrEh7q/0F0bibskAmw==} resolution: {integrity: sha512-jQ0pFPmZwTEiRNSb+i9Ow/I/cHv2tXYqsnHKKyCQ08irI2kdF5qmYedmF8si8mA7zepUFmJ2hqzS8CQmNOWOkQ==}
dependencies:
'@babel/parser': 7.28.4
'@vue/shared': 3.5.21
entities: 4.5.0
estree-walker: 2.0.2
source-map-js: 1.2.1
dev: false
/@vue/compiler-dom@3.5.21: '@vue/compiler-dom@3.5.22':
resolution: {integrity: sha512-jNtbu/u97wiyEBJlJ9kmdw7tAr5Vy0Aj5CgQmo+6pxWNQhXZDPsRr1UWPN4v3Zf82s2H3kF51IbzZ4jMWAgPlQ==} resolution: {integrity: sha512-W8RknzUM1BLkypvdz10OVsGxnMAuSIZs9Wdx1vzA3mL5fNMN15rhrSCLiTm6blWeACwUwizzPVqGJgOGBEN/hA==}
dependencies:
'@vue/compiler-core': 3.5.21
'@vue/shared': 3.5.21
dev: false
/@vue/compiler-sfc@3.5.21: '@vue/compiler-sfc@3.5.22':
resolution: {integrity: sha512-SXlyk6I5eUGBd2v8Ie7tF6ADHE9kCR6mBEuPyH1nUZ0h6Xx6nZI29i12sJKQmzbDyr2tUHMhhTt51Z6blbkTTQ==} resolution: {integrity: sha512-tbTR1zKGce4Lj+JLzFXDq36K4vcSZbJ1RBu8FxcDv1IGRz//Dh2EBqksyGVypz3kXpshIfWKGOCcqpSbyGWRJQ==}
dependencies:
'@babel/parser': 7.28.4
'@vue/compiler-core': 3.5.21
'@vue/compiler-dom': 3.5.21
'@vue/compiler-ssr': 3.5.21
'@vue/shared': 3.5.21
estree-walker: 2.0.2
magic-string: 0.30.19
postcss: 8.5.6
source-map-js: 1.2.1
dev: false
/@vue/compiler-ssr@3.5.21: '@vue/compiler-ssr@3.5.22':
resolution: {integrity: sha512-vKQ5olH5edFZdf5ZrlEgSO1j1DMA4u23TVK5XR1uMhvwnYvVdDF0nHXJUblL/GvzlShQbjhZZ2uvYmDlAbgo9w==} resolution: {integrity: sha512-GdgyLvg4R+7T8Nk2Mlighx7XGxq/fJf9jaVofc3IL0EPesTE86cP/8DD1lT3h1JeZr2ySBvyqKQJgbS54IX1Ww==}
dependencies:
'@vue/compiler-dom': 3.5.21
'@vue/shared': 3.5.21
dev: false
/@vue/composition-api@1.7.2(vue@3.5.21): '@vue/composition-api@1.7.2':
resolution: {integrity: sha512-M8jm9J/laYrYT02665HkZ5l2fWTK4dcVg3BsDHm/pfz+MjDYwX+9FUaZyGwEyXEDonQYRCo0H7aLgdklcIELjw==} resolution: {integrity: sha512-M8jm9J/laYrYT02665HkZ5l2fWTK4dcVg3BsDHm/pfz+MjDYwX+9FUaZyGwEyXEDonQYRCo0H7aLgdklcIELjw==}
peerDependencies: peerDependencies:
vue: '>= 2.5 < 2.7' vue: '>= 2.5 < 2.7'
dependencies:
vue: 3.5.21
dev: false
/@vue/devtools-api@6.6.4: '@vue/devtools-api@6.6.4':
resolution: {integrity: sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==} resolution: {integrity: sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==}
dev: false
/@vue/reactivity@3.5.21: '@vue/reactivity@3.5.22':
resolution: {integrity: sha512-3ah7sa+Cwr9iiYEERt9JfZKPw4A2UlbY8RbbnH2mGCE8NwHkhmlZt2VsH0oDA3P08X3jJd29ohBDtX+TbD9AsA==} resolution: {integrity: sha512-f2Wux4v/Z2pqc9+4SmgZC1p73Z53fyD90NFWXiX9AKVnVBEvLFOWCEgJD3GdGnlxPZt01PSlfmLqbLYzY/Fw4A==}
dependencies:
'@vue/shared': 3.5.21
dev: false
/@vue/runtime-core@3.5.21: '@vue/runtime-core@3.5.22':
resolution: {integrity: sha512-+DplQlRS4MXfIf9gfD1BOJpk5RSyGgGXD/R+cumhe8jdjUcq/qlxDawQlSI8hCKupBlvM+3eS1se5xW+SuNAwA==} resolution: {integrity: sha512-EHo4W/eiYeAzRTN5PCextDUZ0dMs9I8mQ2Fy+OkzvRPUYQEyK9yAjbasrMCXbLNhF7P0OUyivLjIy0yc6VrLJQ==}
dependencies:
'@vue/reactivity': 3.5.21
'@vue/shared': 3.5.21
dev: false
/@vue/runtime-dom@3.5.21: '@vue/runtime-dom@3.5.22':
resolution: {integrity: sha512-3M2DZsOFwM5qI15wrMmNF5RJe1+ARijt2HM3TbzBbPSuBHOQpoidE+Pa+XEaVN+czbHf81ETRoG1ltztP2em8w==} resolution: {integrity: sha512-Av60jsryAkI023PlN7LsqrfPvwfxOd2yAwtReCjeuugTJTkgrksYJJstg1e12qle0NarkfhfFu1ox2D+cQotww==}
dependencies:
'@vue/reactivity': 3.5.21
'@vue/runtime-core': 3.5.21
'@vue/shared': 3.5.21
csstype: 3.1.3
dev: false
/@vue/server-renderer@3.5.21(vue@3.5.21): '@vue/server-renderer@3.5.22':
resolution: {integrity: sha512-qr8AqgD3DJPJcGvLcJKQo2tAc8OnXRcfxhOJCPF+fcfn5bBGz7VCcO7t+qETOPxpWK1mgysXvVT/j+xWaHeMWA==} resolution: {integrity: sha512-gXjo+ao0oHYTSswF+a3KRHZ1WszxIqO7u6XwNHqcqb9JfyIL/pbWrrh/xLv7jeDqla9u+LK7yfZKHih1e1RKAQ==}
peerDependencies: peerDependencies:
vue: 3.5.21 vue: 3.5.22
dependencies:
'@vue/compiler-ssr': 3.5.21
'@vue/shared': 3.5.21
vue: 3.5.21
dev: false
/@vue/shared@3.5.21: '@vue/shared@3.5.22':
resolution: {integrity: sha512-+2k1EQpnYuVuu3N7atWyG3/xoFWIVJZq4Mz8XNOdScFI0etES75fbny/oU4lKWk/577P1zmg0ioYvpGEDZ3DLw==} resolution: {integrity: sha512-F4yc6palwq3TT0u+FYf0Ns4Tfl9GRFURDN2gWG7L1ecIaS/4fCIuFOjMTnCyjsu/OK6vaDKLCrGAa+KvvH+h4w==}
dev: false
/bignumber.js@9.3.1: bignumber.js@9.3.1:
resolution: {integrity: sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==} resolution: {integrity: sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==}
dev: false
/csstype@3.1.3: csstype@3.1.3:
resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}
dev: false
/dayjs@1.11.18: dayjs@1.11.18:
resolution: {integrity: sha512-zFBQ7WFRvVRhKcWoUh+ZA1g2HVgUbsZm9sbddh8EC5iv93sui8DVVz1Npvz+r6meo9VKfa8NyLWBsQK1VvIKPA==} resolution: {integrity: sha512-zFBQ7WFRvVRhKcWoUh+ZA1g2HVgUbsZm9sbddh8EC5iv93sui8DVVz1Npvz+r6meo9VKfa8NyLWBsQK1VvIKPA==}
dev: false
/entities@4.5.0: entities@4.5.0:
resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}
engines: {node: '>=0.12'} engines: {node: '>=0.12'}
dev: false
/estree-walker@2.0.2: estree-walker@2.0.2:
resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
dev: false
/jsbarcode@3.12.1: jsbarcode@3.12.1:
resolution: {integrity: sha512-QZQSqIknC2Rr/YOUyOkCBqsoiBAOTYK+7yNN3JsqfoUtJtkazxNw1dmPpxuv7VVvqW13kA3/mKiLq+s/e3o9hQ==} resolution: {integrity: sha512-QZQSqIknC2Rr/YOUyOkCBqsoiBAOTYK+7yNN3JsqfoUtJtkazxNw1dmPpxuv7VVvqW13kA3/mKiLq+s/e3o9hQ==}
dev: false
/lodash@4.17.21: lodash@4.17.21:
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
dev: false
/magic-string@0.30.19: magic-string@0.30.19:
resolution: {integrity: sha512-2N21sPY9Ws53PZvsEpVtNuSW+ScYbQdp4b9qUaL+9QkHUrGFKo56Lg9Emg5s9V/qrtNBmiR01sYhUOwu3H+VOw==} resolution: {integrity: sha512-2N21sPY9Ws53PZvsEpVtNuSW+ScYbQdp4b9qUaL+9QkHUrGFKo56Lg9Emg5s9V/qrtNBmiR01sYhUOwu3H+VOw==}
dependencies:
'@jridgewell/sourcemap-codec': 1.5.5
dev: false
/nanoid@3.3.11: nanoid@3.3.11:
resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==} resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true hasBin: true
dev: false
/picocolors@1.1.1: picocolors@1.1.1:
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
dev: false
/pinia-plugin-unistorage@0.1.2: pinia-plugin-unistorage@0.1.2:
resolution: {integrity: sha512-WXit2cGnm5rG6CDTcLSLehNWhyJS/Yq7WEeeXAapZbCnqoPJxlszqg7rT8S+OP47az0h5nlajGo+LuyMxUQ2uw==} resolution: {integrity: sha512-WXit2cGnm5rG6CDTcLSLehNWhyJS/Yq7WEeeXAapZbCnqoPJxlszqg7rT8S+OP47az0h5nlajGo+LuyMxUQ2uw==}
dev: false
/pinia@2.3.1(@vue/composition-api@1.7.2)(vue@3.5.21): pinia@2.3.1:
resolution: {integrity: sha512-khUlZSwt9xXCaTbbxFYBKDc/bWAGWJjOgvxETwkTN7KRm66EeT1ZdZj6i2ceh9sP2Pzqsbc704r2yngBrxBVug==} resolution: {integrity: sha512-khUlZSwt9xXCaTbbxFYBKDc/bWAGWJjOgvxETwkTN7KRm66EeT1ZdZj6i2ceh9sP2Pzqsbc704r2yngBrxBVug==}
peerDependencies: peerDependencies:
typescript: '>=4.4.4' typescript: '>=4.4.4'
@@ -222,56 +145,36 @@ packages:
peerDependenciesMeta: peerDependenciesMeta:
typescript: typescript:
optional: true optional: true
dependencies:
'@vue/devtools-api': 6.6.4
vue: 3.5.21
vue-demi: 0.14.10(@vue/composition-api@1.7.2)(vue@3.5.21)
transitivePeerDependencies:
- '@vue/composition-api'
dev: false
/postcss@8.5.6: postcss@8.5.6:
resolution: {integrity: sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==} resolution: {integrity: sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==}
engines: {node: ^10 || ^12 || >=14} engines: {node: ^10 || ^12 || >=14}
dependencies:
nanoid: 3.3.11
picocolors: 1.1.1
source-map-js: 1.2.1
dev: false
/source-map-js@1.2.1: source-map-js@1.2.1:
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
engines: {node: '>=0.10.0'} engines: {node: '>=0.10.0'}
dev: false
/vue-demi@0.14.10(@vue/composition-api@1.7.2)(vue@3.5.21): vue-demi@0.14.10:
resolution: {integrity: sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==} resolution: {integrity: sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==}
engines: {node: '>=12'} engines: {node: '>=12'}
hasBin: true hasBin: true
requiresBuild: true
peerDependencies: peerDependencies:
'@vue/composition-api': ^1.0.0-rc.1 '@vue/composition-api': ^1.0.0-rc.1
vue: ^3.0.0-0 || ^2.6.0 vue: ^3.0.0-0 || ^2.6.0
peerDependenciesMeta: peerDependenciesMeta:
'@vue/composition-api': '@vue/composition-api':
optional: true optional: true
dependencies:
'@vue/composition-api': 1.7.2(vue@3.5.21)
vue: 3.5.21
dev: false
/vue@3.5.21: vue@3.5.22:
resolution: {integrity: sha512-xxf9rum9KtOdwdRkiApWL+9hZEMWE90FHh8yS1+KJAiWYh+iGWV1FquPjoO9VUHQ+VIhsCXNNyZ5Sf4++RVZBA==} resolution: {integrity: sha512-toaZjQ3a/G/mYaLSbV+QsQhIdMo9x5rrqIpYRObsJ6T/J+RyCSFwN2LHNVH9v8uIcljDNa3QzPVdv3Y6b9hAJQ==}
peerDependencies: peerDependencies:
typescript: '*' typescript: '*'
peerDependenciesMeta: peerDependenciesMeta:
typescript: typescript:
optional: true optional: true
<<<<<<< HEAD
=======
ysk-utils@1.0.35: ysk-utils@1.0.40:
resolution: {integrity: sha512-kxPtEk5zs0HjdazbH2l2x1Tm5BUpmj1MBiOnb9Xquuj2hW2NtICtq+JB6RWFO7tzAAnOC5MRw366VOKceyeK5Q==} resolution: {integrity: sha512-Hi+XI7sykGJizExMY5kVWIBhPvO3wudp2q92Vqv6zI6eDtquLz4CwxIfOLEXFfn5crYXVu/yfJQVjK3WAyNYDQ==}
snapshots: snapshots:
@@ -280,19 +183,9 @@ snapshots:
'@babel/helper-validator-identifier@7.27.1': {} '@babel/helper-validator-identifier@7.27.1': {}
'@babel/parser@7.28.4': '@babel/parser@7.28.4':
>>>>>>> a8c20960968cbcde30318c14633993aaff66a437
dependencies: dependencies:
'@vue/compiler-dom': 3.5.21 '@babel/types': 7.28.4
'@vue/compiler-sfc': 3.5.21
'@vue/runtime-dom': 3.5.21
'@vue/server-renderer': 3.5.21(vue@3.5.21)
'@vue/shared': 3.5.21
dev: false
<<<<<<< HEAD
/ysk-utils@1.0.35:
resolution: {integrity: sha512-kxPtEk5zs0HjdazbH2l2x1Tm5BUpmj1MBiOnb9Xquuj2hW2NtICtq+JB6RWFO7tzAAnOC5MRw366VOKceyeK5Q==}
=======
'@babel/types@7.28.4': '@babel/types@7.28.4':
dependencies: dependencies:
'@babel/helper-string-parser': 7.27.1 '@babel/helper-string-parser': 7.27.1
@@ -421,8 +314,7 @@ snapshots:
'@vue/server-renderer': 3.5.22(vue@3.5.22) '@vue/server-renderer': 3.5.22(vue@3.5.22)
'@vue/shared': 3.5.22 '@vue/shared': 3.5.22
ysk-utils@1.0.35: ysk-utils@1.0.40:
>>>>>>> a8c20960968cbcde30318c14633993aaff66a437
dependencies: dependencies:
bignumber.js: 9.3.1 bignumber.js: 9.3.1
dev: false lodash: 4.17.21

View File

@@ -1,10 +1,6 @@
import { import { BigNumber } from "bignumber.js";
BigNumber
} from "bignumber.js";
import _ from "lodash"; import _ from "lodash";
/** /**
* 返回商品单价 * 返回商品单价
* @param goods 商品 * @param goods 商品
@@ -13,7 +9,7 @@ import _ from "lodash";
*/ */
export function returnGoodsPrice(goods, user, shopInfo) { export function returnGoodsPrice(goods, user, shopInfo) {
if (!goods) { if (!goods) {
return 0 return 0;
} }
if (goods.discount_sale_amount * 1 > 0) { if (goods.discount_sale_amount * 1 > 0) {
return goods.discount_sale_amount; return goods.discount_sale_amount;
@@ -74,9 +70,9 @@ export function returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user) {
.filter((v) => types.includes(v.type)) .filter((v) => types.includes(v.type))
.reduce((prev, cur) => { .reduce((prev, cur) => {
// 给每个抵扣商品添加所属优惠券类型 // 给每个抵扣商品添加所属优惠券类型
const goodsWithType = cur.discount.hasDiscountGoodsArr.map(goods => ({ const goodsWithType = cur.discount.hasDiscountGoodsArr.map((goods) => ({
...goods, ...goods,
couponType: cur.type // 记录该商品是被哪种类型的优惠券抵扣的 couponType: cur.type, // 记录该商品是被哪种类型的优惠券抵扣的
})); }));
prev.push(...goodsWithType); prev.push(...goodsWithType);
return prev; return prev;
@@ -118,19 +114,12 @@ export function returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user) {
* @returns {Object} - { canUse: boolean, reason: string } 可用状态及不可用原因 * @returns {Object} - { canUse: boolean, reason: string } 可用状态及不可用原因
*/ */
export function returnCouponCanUse(args) { export function returnCouponCanUse(args) {
let { let { canDikouGoodsArr, coupon, goodsOrderPrice, user, selCoupon, shopInfo } = args;
canDikouGoodsArr,
coupon,
goodsOrderPrice,
user,
selCoupon,
shopInfo
} = args;
// 优惠券未启用 // 优惠券未启用
if (!coupon.use) { if (!coupon.use) {
return { return {
canUse: false, canUse: false,
reason:coupon.noUseRestrictions|| "不在可用时间段内" reason: coupon.noUseRestrictions || "不在可用时间段内",
}; };
} }
@@ -138,7 +127,7 @@ export function returnCouponCanUse(args) {
let fullAmount = goodsOrderPrice; let fullAmount = goodsOrderPrice;
canDikouGoodsArr = returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user, shopInfo); canDikouGoodsArr = returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user, shopInfo);
//优惠券指定门槛商品列表 //优惠券指定门槛商品列表
let canCalcGoodsArr = [...canDikouGoodsArr] let canCalcGoodsArr = [...canDikouGoodsArr];
//部分商品参与门槛计算 //部分商品参与门槛计算
if (coupon.thresholdFoods.length) { if (coupon.thresholdFoods.length) {
canCalcGoodsArr = canDikouGoodsArr.filter((v) => { canCalcGoodsArr = canDikouGoodsArr.filter((v) => {
@@ -149,8 +138,6 @@ export function returnCouponCanUse(args) {
}, 0); }, 0);
} }
// 是否全部商品可用 // 是否全部商品可用
const isDikouAll = coupon.useFoods.length === 0; const isDikouAll = coupon.useFoods.length === 0;
// 订单可用商品列表 // 订单可用商品列表
@@ -163,19 +150,19 @@ export function returnCouponCanUse(args) {
if (user.isVip && !coupon.vipPriceShare) { if (user.isVip && !coupon.vipPriceShare) {
return { return {
canUse: false, canUse: false,
reason: "非会员可用" reason: "非会员可用",
}; };
} }
if (selCoupon.length > 0 && !selCoupon[0].otherCouponShare) { if (selCoupon.length > 0 && !selCoupon[0].otherCouponShare) {
return { return {
canUse: false, canUse: false,
reason: "当前选中的券不可与其他券同享" reason: "当前选中的券不可与其他券同享",
}; };
} }
if (selCoupon.length > 0 && !coupon.otherCouponShare) { if (selCoupon.length > 0 && !coupon.otherCouponShare) {
return { return {
canUse: false, canUse: false,
reason: "当前选中的券不可与其他券同享" reason: "当前选中的券不可与其他券同享",
}; };
} }
// 满减券和折扣券计算门槛金额是否满足 // 满减券和折扣券计算门槛金额是否满足
@@ -183,30 +170,39 @@ export function returnCouponCanUse(args) {
if (canCalcGoodsArr.length <= 0) { if (canCalcGoodsArr.length <= 0) {
return { return {
canUse: false, canUse: false,
reason: "没有可参与计算门槛的商品" reason: "没有可参与计算门槛的商品",
}; };
} }
// 不满足门槛金额 // 不满足门槛金额
if (fullAmount < coupon.fullAmount) { if (fullAmount < coupon.fullAmount) {
return { return {
canUse: false, canUse: false,
reason: `${coupon.fullAmount}元可用,当前可参与金额${fullAmount}` reason: `${coupon.fullAmount}元可用,当前可参与金额${fullAmount}`,
}; };
} }
} }
// 商品兑换券,第二件半价和买一送一判断是否有可用商品 // 商品兑换券,第二件半价和买一送一判断是否有可用商品
if ([2, 4, 5].includes(coupon.type)) { if ([2, 4, 5].includes(coupon.type)) {
console.log("商品兑换券", fullAmount, coupon.fullAmount);
if (coupon.type == 2 && fullAmount < coupon.fullAmount) {
console.log("商品兑换券", coupon);
return {
canUse: false,
reason: `${coupon.fullAmount}元可用,当前可参与金额${fullAmount}`,
};
}
// 没有符合条件的商品 // 没有符合条件的商品
if (isDikouAll && canDikouGoodsArr.length === 0) { if (isDikouAll && canDikouGoodsArr.length === 0) {
return { return {
canUse: false, canUse: false,
reason: "没有符合条件的商品" reason: "没有符合条件的商品",
}; };
} }
if (!isDikouAll && canUseGoodsArr.length === 0) { if (!isDikouAll && canUseGoodsArr.length === 0) {
return { return {
canUse: false, canUse: false,
reason: "没有符合条件的商品" reason: "没有符合条件的商品",
}; };
} }
} }
@@ -214,7 +210,7 @@ export function returnCouponCanUse(args) {
if (coupon.type == 2 && goodsOrderPrice < coupon.fullAmount) { if (coupon.type == 2 && goodsOrderPrice < coupon.fullAmount) {
return { return {
canUse: false, canUse: false,
reason: `${coupon.fullAmount}元可用,当前可参与金额${fullAmount}` reason: `${coupon.fullAmount}元可用,当前可参与金额${fullAmount}`,
}; };
} }
@@ -230,7 +226,7 @@ export function returnCouponCanUse(args) {
if (!canUse) { if (!canUse) {
return { return {
canUse: false, canUse: false,
reason: "需要购买至少2件相同的商品才能使用" reason: "需要购买至少2件相同的商品才能使用",
}; };
} }
} }
@@ -247,7 +243,7 @@ export function returnCouponCanUse(args) {
if (!canUse) { if (!canUse) {
return { return {
canUse: false, canUse: false,
reason: "需要购买至少2件相同的商品才能使用" reason: "需要购买至少2件相同的商品才能使用",
}; };
} }
} }
@@ -255,11 +251,10 @@ export function returnCouponCanUse(args) {
// 所有条件都满足 // 所有条件都满足
return { return {
canUse: true, canUse: true,
reason: "" reason: "",
}; };
} }
/** /**
* 计算抵扣商品金额 * 计算抵扣商品金额
* @param discountGoodsArr 可抵扣商品列表 * @param discountGoodsArr 可抵扣商品列表
@@ -279,15 +274,17 @@ export function calcDiscountGoodsArrPrice(discountGoodsArr, discountNum, user, s
const shengyuNum = discountNum - hasCountNum; const shengyuNum = discountNum - hasCountNum;
const num = Math.min(goods.num, shengyuNum); const num = Math.min(goods.num, shengyuNum);
discountPrice += returnGoodsPrice(goods, user, shopInfo) * num; discountPrice += returnGoodsPrice(goods, user, shopInfo) * num;
hasCountNum += num; hasCountNum += num;
hasDiscountGoodsArr.push({ hasDiscountGoodsArr.push({
...goods, ...goods,
num num,
}); });
} }
return { return {
discountPrice, discountPrice,
hasDiscountGoodsArr hasDiscountGoodsArr,
}; };
} }
@@ -307,7 +304,7 @@ export function returnCouponDiscount(arr, coupon, user, goodsOrderPrice, selCoup
} }
if (coupon.type == 6) { if (coupon.type == 6) {
const result = returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user, shopInfo); const result = returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user, shopInfo);
return result return result;
} }
if (coupon.type == 4) { if (coupon.type == 4) {
return returnSecoendDiscount(canDikouGoodsArr, coupon, user, shopInfo); return returnSecoendDiscount(canDikouGoodsArr, coupon, user, shopInfo);
@@ -333,10 +330,7 @@ export function returnCouponZhekouDiscount(
goodsOrderPrice, goodsOrderPrice,
selCoupon selCoupon
) { ) {
const { const { discountRate, maxDiscountAmount } = coupon;
discountRate,
maxDiscountAmount
} = coupon;
// 计算商品优惠券折扣总和使用BigNumber避免精度问题 // 计算商品优惠券折扣总和使用BigNumber避免精度问题
const goodsCouponDiscount = selCoupon const goodsCouponDiscount = selCoupon
@@ -347,13 +341,13 @@ export function returnCouponZhekouDiscount(
// 将商品订单价格转换为BigNumber并减去优惠券折扣 // 将商品订单价格转换为BigNumber并减去优惠券折扣
const adjustedGoodsOrderPrice = new BigNumber(goodsOrderPrice).minus(goodsCouponDiscount); const adjustedGoodsOrderPrice = new BigNumber(goodsOrderPrice).minus(goodsCouponDiscount);
console.log('adjustedGoodsOrderPrice', adjustedGoodsOrderPrice.toNumber());
// 计算优惠比例:(100 - 折扣率) / 100 // 计算优惠比例:(100 - 折扣率) / 100
const discountAmountRatio = new BigNumber(100).minus(discountRate).dividedBy(100); const discountAmountRatio = new BigNumber(100).minus(discountRate).dividedBy(100);
// 计算折扣金额:调整后的商品订单金额 × 优惠比例 // 计算折扣金额:调整后的商品订单金额 × 优惠比例
let discountPrice = adjustedGoodsOrderPrice.times(discountAmountRatio) let discountPrice = adjustedGoodsOrderPrice
.times(discountAmountRatio)
.decimalPlaces(2, BigNumber.ROUND_FLOOR) .decimalPlaces(2, BigNumber.ROUND_FLOOR)
.toNumber(); .toNumber();
@@ -376,19 +370,13 @@ export function returnCouponZhekouDiscount(
* @param shopInfo 店铺信息 * @param shopInfo 店铺信息
*/ */
export function returnCouponProductDiscount(canDikouGoodsArr, coupon, user, shopInfo) { export function returnCouponProductDiscount(canDikouGoodsArr, coupon, user, shopInfo) {
const { const { useFoods, discountNum, useRule } = coupon;
useFoods,
discountNum,
useRule
} = coupon;
//抵扣商品数组 //抵扣商品数组
let discountGoodsArr = []; let discountGoodsArr = [];
//抵扣全部商品 //抵扣全部商品
if (useFoods.length === 0) { if (useFoods.length === 0) {
if (useRule == "price_asc") { if (useRule == "price_asc") {
discountGoodsArr = canDikouGoodsArr discountGoodsArr = canDikouGoodsArr.slice(discountNum * -1).reverse();
.slice(canDikouGoodsArr.length - discountNum, canDikouGoodsArr.length)
.reverse();
} else { } else {
discountGoodsArr = canDikouGoodsArr.slice(0, discountNum); discountGoodsArr = canDikouGoodsArr.slice(0, discountNum);
} }
@@ -398,9 +386,7 @@ export function returnCouponProductDiscount(canDikouGoodsArr, coupon, user, shop
useFoods.find((food) => food.id == v.productId) useFoods.find((food) => food.id == v.productId)
); );
if (useRule == "price_asc") { if (useRule == "price_asc") {
discountGoodsArr = discountSelGoodsArr discountGoodsArr = discountSelGoodsArr.slice(discountNum * -1).reverse();
.slice(discountSelGoodsArr.length - discountNum, discountSelGoodsArr.length)
.reverse();
} else { } else {
discountGoodsArr = discountSelGoodsArr.slice(0, discountNum); discountGoodsArr = discountSelGoodsArr.slice(0, discountNum);
} }
@@ -417,10 +403,7 @@ export function returnCouponProductDiscount(canDikouGoodsArr, coupon, user, shop
* @param shopInfo 店铺信息 * @param shopInfo 店铺信息
*/ */
function returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user, shopInfo) { function returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user, shopInfo) {
const { const { useFoods, useRule } = coupon;
useFoods,
useRule
} = coupon;
//抵扣商品 //抵扣商品
let discountGoods = undefined; let discountGoods = undefined;
//符合买一送一条件的商品 //符合买一送一条件的商品
@@ -428,7 +411,7 @@ function returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user, shopI
//抵扣全部商品 //抵扣全部商品
if (useFoods.length === 0) { if (useFoods.length === 0) {
if (useRule == "price_asc") { if (useRule == "price_asc") {
discountGoods = canUseGoods[canUseGoods.length - 1] discountGoods = canUseGoods[canUseGoods.length - 1];
} else { } else {
discountGoods = canUseGoods[0]; discountGoods = canUseGoods[0];
} }
@@ -436,21 +419,21 @@ function returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user, shopI
//符合抵扣条件的商品 //符合抵扣条件的商品
const canUseGoods1 = canUseGoods.filter((v) => useFoods.find((food) => food.id == v.productId)); const canUseGoods1 = canUseGoods.filter((v) => useFoods.find((food) => food.id == v.productId));
if (useRule == "price_asc") { if (useRule == "price_asc") {
discountGoods = canUseGoods1[canUseGoods1.length - 1] discountGoods = canUseGoods1[canUseGoods1.length - 1];
} else { } else {
discountGoods = canUseGoods1[0] discountGoods = canUseGoods1[0];
} }
} }
let discountPrice = 0; let discountPrice = 0;
let hasDiscountGoodsArr = [] let hasDiscountGoodsArr = [];
console.log('returnCouponBuyOneGiveOneDiscount:discountGoods',discountGoods); console.log("returnCouponBuyOneGiveOneDiscount:discountGoods", discountGoods);
if (discountGoods) { if (discountGoods) {
discountPrice = returnGoodsPrice(discountGoods, user, shopInfo); discountPrice = returnGoodsPrice(discountGoods, user, shopInfo);
hasDiscountGoodsArr = [discountGoods]; hasDiscountGoodsArr = [discountGoods];
} }
return { return {
discountPrice: discountPrice <= 0 ? 0 : discountPrice, discountPrice: discountPrice <= 0 ? 0 : discountPrice,
hasDiscountGoodsArr hasDiscountGoodsArr,
}; };
} }
@@ -462,10 +445,7 @@ function returnCouponBuyOneGiveOneDiscount(canDikouGoodsArr, coupon, user, shopI
* @param shopInfo 店铺信息 * @param shopInfo 店铺信息
*/ */
function returnSecoendDiscount(canDikouGoodsArr, coupon, user, shopInfo) { function returnSecoendDiscount(canDikouGoodsArr, coupon, user, shopInfo) {
const { const { useFoods, useRule } = coupon;
useFoods,
useRule
} = coupon;
//抵扣商品 //抵扣商品
let discountGoods = undefined; let discountGoods = undefined;
//符合条件的商品 //符合条件的商品
@@ -473,21 +453,21 @@ function returnSecoendDiscount(canDikouGoodsArr, coupon, user, shopInfo) {
//抵扣全部商品 //抵扣全部商品
if (useFoods.length === 0) { if (useFoods.length === 0) {
if (useRule == "price_asc") { if (useRule == "price_asc") {
discountGoods = canUseGoods[canUseGoods.length - 1] discountGoods = canUseGoods[canUseGoods.length - 1];
} else { } else {
discountGoods = canUseGoods[0] discountGoods = canUseGoods[0];
} }
} else { } else {
//符合抵扣条件的商品 //符合抵扣条件的商品
const canUseGoods1 = canUseGoods.filter((v) => useFoods.find((food) => food.id == v.productId)); const canUseGoods1 = canUseGoods.filter((v) => useFoods.find((food) => food.id == v.productId));
if (useRule == "price_asc") { if (useRule == "price_asc") {
discountGoods = canUseGoods1[canUseGoods1.length - 1] discountGoods = canUseGoods1[canUseGoods1.length - 1];
} else { } else {
discountGoods = canUseGoods1[0] discountGoods = canUseGoods1[0];
} }
} }
let discountPrice = 0; let discountPrice = 0;
let hasDiscountGoodsArr = [] let hasDiscountGoodsArr = [];
if (discountGoods) { if (discountGoods) {
discountPrice = returnGoodsPrice(discountGoods, user, shopInfo); discountPrice = returnGoodsPrice(discountGoods, user, shopInfo);
hasDiscountGoodsArr = [discountGoods]; hasDiscountGoodsArr = [discountGoods];