增加微信支付,商城逻辑,公告

This commit is contained in:
2025-09-05 16:48:53 +08:00
parent e5ace37c68
commit 8530e97ab6
38 changed files with 6430 additions and 1688 deletions

View File

@@ -114,9 +114,11 @@ router.get('/', auth, async (req, res) => {
}
// 处理地址信息
console.log(order.address,'order.address');
if (order.address) {
try {
order.address = JSON.parse(order.address);
order.address = order.address;
} catch (e) {
order.address = null;
}
@@ -138,76 +140,7 @@ router.get('/', auth, async (req, res) => {
}
});
/**
* @swagger
* /api/orders/confirm:
* post:
* summary: 确认下单
* tags: [Orders]
* security:
* - bearerAuth: []
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - pre_order_id
* - address
* properties:
* pre_order_id:
* type: integer
* description: 预订单ID
* address:
* type: object
* properties:
* recipient_name:
* type: string
* description: 收货人姓名
* phone:
* type: string
* description: 收货人电话
* province:
* type: string
* description: 省份
* city:
* type: string
* description: 城市
* district:
* type: string
* description: 区县
* detail_address:
* type: string
* description: 详细地址
* responses:
* 200:
* description: 确认下单成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* message:
* type: string
* data:
* type: object
* properties:
* order_id:
* type: integer
* order_no:
* type: string
* 400:
* description: 请求参数错误
* 401:
* description: 未授权
* 404:
* description: 预订单不存在
* 500:
* description: 服务器错误
*/
router.post('/confirm', auth, async (req, res) => {
const connection = await getDB().getConnection();
@@ -331,76 +264,7 @@ router.get('/', auth, async (req, res) => {
}
});
/**
* @swagger
* /api/orders/pre-order/{id}:
* get:
* summary: 获取预订单详情
* tags: [Orders]
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: id
* required: true
* schema:
* type: integer
* description: 预订单ID
* responses:
* 200:
* description: 获取预订单详情成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* data:
* type: object
* properties:
* id:
* type: integer
* order_no:
* type: string
* total_amount:
* type: integer
* total_points:
* type: integer
* total_rongdou:
* type: integer
* status:
* type: string
* created_at:
* type: string
* items:
* type: array
* items:
* type: object
* properties:
* id:
* type: integer
* product_id:
* type: integer
* product_name:
* type: string
* quantity:
* type: integer
* price:
* type: integer
* points_price:
* type: integer
* rongdou_price:
* type: integer
* spec_info:
* type: object
* 401:
* description: 未授权
* 404:
* description: 预订单不存在
* 500:
* description: 服务器错误
*/
router.get('/pre-order/:id', auth, async (req, res) => {
try {
const preOrderId = req.params.id;
@@ -462,43 +326,7 @@ router.get('/', auth, async (req, res) => {
}
});
/**
* @swagger
* /api/orders/{id}:
* get:
* summary: 获取单个订单详情
* tags: [Orders]
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: id
* required: true
* schema:
* type: integer
* description: 订单ID
* responses:
* 200:
* description: 成功获取订单详情
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* data:
* type: object
* properties:
* order:
* $ref: '#/components/schemas/Order'
* 401:
* description: 未授权
* 404:
* description: 订单不存在
* 500:
* description: 服务器错误
*/
router.get('/:id', auth, async (req, res) => {
try {
const { id } = req.params;
@@ -557,9 +385,11 @@ router.get('/:id', auth, async (req, res) => {
}
// 处理地址信息
console.log(order.address,'order.address');
if (order.address) {
try {
order.address = JSON.parse(order.address);
order.address = order.address;
} catch (e) {
order.address = null;
}
@@ -1340,7 +1170,7 @@ router.post('/confirm-payment', auth, async (req, res) => {
}
pointsToDeduct = 0;
rongdouToDeduct = totalRongdouNeeded;
} else if (isComboPayment) {
} else if (hasPoints && hasRongdou) {
// 组合支付:先扣积分,不足部分用融豆
const availablePointsInRongdou = Math.floor(user.points / 10000); // 积分可转换的融豆数