新增优惠券的选择
This commit is contained in:
@@ -1061,7 +1061,7 @@ router.post('/confirm-payment', auth, async (req, res) => {
|
||||
try {
|
||||
await connection.beginTransaction();
|
||||
|
||||
const { orderId: order_id, addressId: address_id } = req.body;
|
||||
const { orderId: order_id, addressId: address_id, couponRecordId } = req.body;
|
||||
const userId = req.user.id;
|
||||
|
||||
// 验证必填字段
|
||||
@@ -1090,7 +1090,7 @@ router.post('/confirm-payment', auth, async (req, res) => {
|
||||
|
||||
// 解析支付方式
|
||||
let allPaymentMethods = [];
|
||||
console.log(typeof order.payment_methods_list);
|
||||
// console.log(typeof order.payment_methods_list);
|
||||
|
||||
if (order.payment_methods_list) {
|
||||
try {
|
||||
@@ -1222,6 +1222,14 @@ router.post('/confirm-payment', auth, async (req, res) => {
|
||||
);
|
||||
}
|
||||
|
||||
// 更新优惠券记录
|
||||
if (couponRecordId) {
|
||||
await connection.execute(
|
||||
'UPDATE coupon_use SET use_time = NOW(), order_id = ? WHERE id = ?',
|
||||
[order_id, couponRecordId]
|
||||
);
|
||||
}
|
||||
|
||||
// 更新订单状态和收货地址
|
||||
const addressStr = JSON.stringify({
|
||||
recipient_name: address.receiver_name,
|
||||
@@ -1238,6 +1246,12 @@ router.post('/confirm-payment', auth, async (req, res) => {
|
||||
[addressStr, order_id]
|
||||
);
|
||||
|
||||
// 减组合库存
|
||||
// await connection.execute(
|
||||
// 'UPDATE product_spec_combinations SET stock = stock - 1 WHERE id = ?',
|
||||
// [order.product_combination_id]
|
||||
// );
|
||||
|
||||
await connection.commit();
|
||||
|
||||
res.json({
|
||||
|
||||
Reference in New Issue
Block a user