bug修复
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user