bug修复

This commit is contained in:
dzl
2025-10-22 17:26:50 +08:00
parent 27a3f564ed
commit be8b182e82
2 changed files with 86 additions and 78 deletions

View File

@@ -496,20 +496,23 @@ router.post('/create-from-cart', auth, async (req, res) => {
totalAmount += finalPrice * item.quantity;
// 根据支付方式计算积分和融豆需求
const hasPoints = productPaymentMethods.includes('points') || productPaymentMethods.includes('points_rongdou');
const hasRongdou = productPaymentMethods.includes('rongdou') || productPaymentMethods.includes('points_rongdou');
// const hasPoints = productPaymentMethods.includes('points') || productPaymentMethods.includes('points_rongdou');
// const hasRongdou = productPaymentMethods.includes('rongdou') || productPaymentMethods.includes('points_rongdou');
if (hasPoints && !hasRongdou) {
// 仅积分支付按10000积分=1融豆计算
totalPoints += finalRongdouPrice * item.quantity * 10000;
totalRongdou += finalRongdouPrice * item.quantity;
} else if (!hasPoints && hasRongdou) {
// 仅融豆支付
totalRongdou += finalRongdouPrice * item.quantity;
} else {
// 组合支付或默认:记录融豆价格,前端可选择支付方式
totalRongdou += finalRongdouPrice * item.quantity;
}
// if (hasPoints && !hasRongdou) {
// // 仅积分支付按10000积分=1融豆计算
// totalPoints += finalRongdouPrice * item.quantity * 10000;
// totalRongdou += finalRongdouPrice * item.quantity;
// } else if (!hasPoints && hasRongdou) {
// // 仅融豆支付
// totalRongdou += finalRongdouPrice * item.quantity;
// } else {
// // 组合支付或默认:记录融豆价格,前端可选择支付方式
// totalRongdou += finalRongdouPrice * item.quantity;
// }
totalPoints += item.points_price * item.quantity;
totalRongdou += item.rongdou_price * item.quantity;
// console.log(1111,item)
}
// 去重支付方式
@@ -1176,6 +1179,8 @@ router.post('/confirm-payment', auth, async (req, res) => {
}
user.balance = Math.abs(user.balance);
console.log(123456,paymentMethod)
// 开始扣钱
switch (paymentMethod) {
case 'points':
@@ -1184,6 +1189,7 @@ router.post('/confirm-payment', auth, async (req, res) => {
await connection.rollback();
return res.status(400).json({ success: false, message: '积分不足' });
}
console.log(1234567,paymentMethod,userId,order.total_points)
await connection.execute(
'UPDATE users SET points = points - ? WHERE id = ?',
[order.total_points, userId]