|
|
@@ -101,7 +101,7 @@ const STATUS_MAP = {
|
|
|
// 动态查询订单
|
|
|
router.post('/query', authMiddleware, async (req, res) => {
|
|
|
try {
|
|
|
- const { batch_no, card_no, order_no, start_date, end_date, status } = req.body;
|
|
|
+ const { receiver_name, receiver_phone, order_no, start_date, end_date, status } = req.body;
|
|
|
|
|
|
let sql = `
|
|
|
SELECT
|
|
|
@@ -145,15 +145,15 @@ router.post('/query', authMiddleware, async (req, res) => {
|
|
|
paramIndex++;
|
|
|
}
|
|
|
|
|
|
- if (batch_no) {
|
|
|
- sql += ` AND c.batch_no = $${paramIndex}`;
|
|
|
- params.push(batch_no);
|
|
|
+ if (receiver_name) {
|
|
|
+ sql += ` AND o.receiver_name LIKE $${paramIndex}`;
|
|
|
+ params.push(`%${receiver_name}%`);
|
|
|
paramIndex++;
|
|
|
}
|
|
|
|
|
|
- if (card_no) {
|
|
|
- sql += ` AND o.card_no = $${paramIndex}`;
|
|
|
- params.push(card_no);
|
|
|
+ if (receiver_phone) {
|
|
|
+ sql += ` AND o.receiver_phone LIKE $${paramIndex}`;
|
|
|
+ params.push(`%${receiver_phone}%`);
|
|
|
paramIndex++;
|
|
|
}
|
|
|
|
|
|
@@ -179,7 +179,7 @@ router.post('/query', authMiddleware, async (req, res) => {
|
|
|
|
|
|
const result = await pool.query(sql, params);
|
|
|
// 记录查询日志
|
|
|
- await logOperation(req.user.username, req.user.role, '查询订单', `条件: 状态=${status||'全部'}, 批次=${batch_no||'-'}, 卡号=${card_no||'-'}, 订单号=${order_no||'-'}, 日期=${start_date||'-'}~${end_date||'-'}`, req.ip);
|
|
|
+ await logOperation(req.user.username, req.user.role, '查询订单', `条件: 状态=${status||'全部'}, 收货人=${receiver_name||'-'}, 手机号=${receiver_phone||'-'}, 订单号=${order_no||'-'}, 日期=${start_date||'-'}~${end_date||'-'}`, req.ip);
|
|
|
res.json({ success: true, data: result.rows, total: result.rows.length });
|
|
|
} catch (err) {
|
|
|
console.error('查询订单失败:', err);
|