|
@@ -95,7 +95,6 @@ const STATUS_MAP = {
|
|
|
1: '已完成',
|
|
1: '已完成',
|
|
|
2: '已取消',
|
|
2: '已取消',
|
|
|
3: '已发货',
|
|
3: '已发货',
|
|
|
- 4: '已发运',
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 动态查询订单
|
|
// 动态查询订单
|
|
@@ -127,7 +126,6 @@ router.post('/query', authMiddleware, async (req, res) => {
|
|
|
WHEN 1 THEN '已完成'
|
|
WHEN 1 THEN '已完成'
|
|
|
WHEN 2 THEN '已取消'
|
|
WHEN 2 THEN '已取消'
|
|
|
WHEN 3 THEN '已发货'
|
|
WHEN 3 THEN '已发货'
|
|
|
- WHEN 4 THEN '已发运'
|
|
|
|
|
END AS "订单状态"
|
|
END AS "订单状态"
|
|
|
FROM gift_order o
|
|
FROM gift_order o
|
|
|
JOIN gift_card c ON c.id = o.card_id AND c.del_flag = '0'
|
|
JOIN gift_card c ON c.id = o.card_id AND c.del_flag = '0'
|
|
@@ -216,7 +214,6 @@ router.post('/export/excel', authMiddleware, async (req, res) => {
|
|
|
WHEN 1 THEN '已完成'
|
|
WHEN 1 THEN '已完成'
|
|
|
WHEN 2 THEN '已取消'
|
|
WHEN 2 THEN '已取消'
|
|
|
WHEN 3 THEN '已发货'
|
|
WHEN 3 THEN '已发货'
|
|
|
- WHEN 4 THEN '已发运'
|
|
|
|
|
END AS "订单状态"
|
|
END AS "订单状态"
|
|
|
FROM gift_order o
|
|
FROM gift_order o
|
|
|
JOIN gift_card c ON c.id = o.card_id AND c.del_flag = '0'
|
|
JOIN gift_card c ON c.id = o.card_id AND c.del_flag = '0'
|
|
@@ -420,7 +417,7 @@ router.post('/import/logistics', authMiddleware, upload.single('file'), async (r
|
|
|
const orderId = orderResult.rows[0].id;
|
|
const orderId = orderResult.rows[0].id;
|
|
|
const orderStatus = orderResult.rows[0].status;
|
|
const orderStatus = orderResult.rows[0].status;
|
|
|
|
|
|
|
|
- // 不允许重复发货/已完成/已发运
|
|
|
|
|
|
|
+ // 不允许重复发货/已完成
|
|
|
if (orderStatus === 3) {
|
|
if (orderStatus === 3) {
|
|
|
await pool.query('ROLLBACK');
|
|
await pool.query('ROLLBACK');
|
|
|
results.failed++;
|
|
results.failed++;
|
|
@@ -433,16 +430,10 @@ router.post('/import/logistics', authMiddleware, upload.single('file'), async (r
|
|
|
results.errors.push(`第${i + 2}行: 订单 ${orderNo} 已完成,不能导入`);
|
|
results.errors.push(`第${i + 2}行: 订单 ${orderNo} 已完成,不能导入`);
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- if (orderStatus === 4) {
|
|
|
|
|
- await pool.query('ROLLBACK');
|
|
|
|
|
- results.failed++;
|
|
|
|
|
- results.errors.push(`第${i + 2}行: 订单 ${orderNo} 已发运,不能重复导入`);
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- // 更新订单状态为已发运
|
|
|
|
|
|
|
+ // 更新订单状态为已发货
|
|
|
await pool.query(
|
|
await pool.query(
|
|
|
- `UPDATE gift_order SET status = 4, update_time = now(), update_by = $1
|
|
|
|
|
|
|
+ `UPDATE gift_order SET status = 3, update_time = now(), update_by = $1
|
|
|
WHERE id = $2 AND del_flag = '0'`,
|
|
WHERE id = $2 AND del_flag = '0'`,
|
|
|
['import', orderId]
|
|
['import', orderId]
|
|
|
);
|
|
);
|
|
@@ -530,8 +521,7 @@ router.get('/stats', async (req, res) => {
|
|
|
COUNT(*) FILTER (WHERE o.status = 0) AS pending,
|
|
COUNT(*) FILTER (WHERE o.status = 0) AS pending,
|
|
|
COUNT(*) FILTER (WHERE o.status = 1) AS completed,
|
|
COUNT(*) FILTER (WHERE o.status = 1) AS completed,
|
|
|
COUNT(*) FILTER (WHERE o.status = 2) AS cancelled,
|
|
COUNT(*) FILTER (WHERE o.status = 2) AS cancelled,
|
|
|
- COUNT(*) FILTER (WHERE o.status = 3) AS shipped,
|
|
|
|
|
- COUNT(*) FILTER (WHERE o.status = 4) AS imported
|
|
|
|
|
|
|
+ COUNT(*) FILTER (WHERE o.status = 3) AS shipped
|
|
|
FROM gift_order o
|
|
FROM gift_order o
|
|
|
WHERE o.del_flag = '0'
|
|
WHERE o.del_flag = '0'
|
|
|
`);
|
|
`);
|
|
@@ -544,7 +534,6 @@ router.get('/stats', async (req, res) => {
|
|
|
completed: parseInt(row.completed),
|
|
completed: parseInt(row.completed),
|
|
|
cancelled: parseInt(row.cancelled),
|
|
cancelled: parseInt(row.cancelled),
|
|
|
shipped: parseInt(row.shipped),
|
|
shipped: parseInt(row.shipped),
|
|
|
- imported: parseInt(row.imported),
|
|
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
} catch (err) {
|
|
} catch (err) {
|