修复分类筛选,新增个人信息修改接口,区分不同客户端
This commit is contained in:
@@ -10,7 +10,7 @@ const router = express.Router();
|
||||
// 获取订单列表
|
||||
router.get('/', async (req, res) => {
|
||||
try {
|
||||
const { page = 1, limit = 10, search = '', orderNumber = '', username = '', status = '', startDate = '', endDate = '' } = req.query;
|
||||
const { page = 1, limit = 10, search = '', orderNumber = '', username = '', status = '', startDate = '', endDate = '', shop_name = '' } = req.query;
|
||||
|
||||
|
||||
|
||||
@@ -59,11 +59,24 @@ router.get('/', async (req, res) => {
|
||||
params.push(endDate);
|
||||
}
|
||||
|
||||
if (shop_name) {
|
||||
whereClause += ' AND p.shop_name = ?';
|
||||
params.push(shop_name);
|
||||
}
|
||||
|
||||
// 获取总数
|
||||
// const countQuery = `
|
||||
// SELECT COUNT(*) as total
|
||||
// FROM orders as o
|
||||
// LEFT JOIN users u ON o.user_id = u.id
|
||||
// ${whereClause}
|
||||
// `;
|
||||
const countQuery = `
|
||||
SELECT COUNT(*) as total
|
||||
SELECT COUNT(DISTINCT o.id) as total
|
||||
FROM orders as o
|
||||
LEFT JOIN users u ON o.user_id = u.id
|
||||
LEFT JOIN users u ON o.user_id = u.id
|
||||
LEFT JOIN order_items oi ON o.id = oi.order_id
|
||||
LEFT JOIN products p ON oi.product_id = p.id
|
||||
${whereClause}
|
||||
`;
|
||||
console.log(countQuery, params);
|
||||
@@ -73,13 +86,26 @@ router.get('/', async (req, res) => {
|
||||
console.log(total, '数量');
|
||||
|
||||
// 获取订单列表
|
||||
// const query = `
|
||||
// SELECT
|
||||
// o.id, o.order_no, o.user_id, o.total_amount, o.total_points,
|
||||
// o.status, o.address, o.created_at, o.updated_at,o.total_rongdou,
|
||||
// u.username, o.salesperson_id, o.delivery_code, o.logistics_company
|
||||
// FROM orders o
|
||||
// LEFT JOIN users u ON o.user_id = u.id
|
||||
// ${whereClause}
|
||||
// ORDER BY o.created_at DESC
|
||||
// LIMIT ${limitNum} OFFSET ${offset}
|
||||
// `;
|
||||
const query = `
|
||||
SELECT
|
||||
SELECT DISTINCT
|
||||
o.id, o.order_no, o.user_id, o.total_amount, o.total_points,
|
||||
o.status, o.address, o.created_at, o.updated_at,o.total_rongdou,
|
||||
o.status, o.address, o.created_at, o.updated_at, o.total_rongdou,
|
||||
u.username, o.salesperson_id, o.delivery_code, o.logistics_company
|
||||
FROM orders o
|
||||
LEFT JOIN users u ON o.user_id = u.id
|
||||
LEFT JOIN order_items oi ON o.id = oi.order_id
|
||||
LEFT JOIN products p ON oi.product_id = p.id
|
||||
${whereClause}
|
||||
ORDER BY o.created_at DESC
|
||||
LIMIT ${limitNum} OFFSET ${offset}
|
||||
@@ -114,7 +140,7 @@ router.get('/', async (req, res) => {
|
||||
}
|
||||
|
||||
// 处理地址信息
|
||||
console.log(order.address,'order.address');
|
||||
// console.log(order.address,'order.address');
|
||||
|
||||
if (order.address) {
|
||||
try {
|
||||
@@ -127,9 +153,27 @@ router.get('/', async (req, res) => {
|
||||
order.items = orderItems;
|
||||
}
|
||||
|
||||
// let shopNames = [];
|
||||
|
||||
// for (const order of orders) {
|
||||
// const orderItems = order.items;
|
||||
// // console.log(111,orderItems[0].product_id);
|
||||
|
||||
// const query = `
|
||||
// SELECT shop_name as shopName
|
||||
// FROM order_items oi
|
||||
// LEFT JOIN products p ON oi.product_id = p.id
|
||||
// LEFT JOIN product_spec_combinations psc ON oi.spec_combination_id = psc.id
|
||||
// WHERE oi.order_id = ? AND oi.product_id = ?
|
||||
// `;
|
||||
// const [result] = await getDB().execute(query, [order.id, orderItems[0].product_id]);
|
||||
// order.shop_name = result[0].shopName;
|
||||
// }
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
data: {
|
||||
// orders: orders.filter(order => order.shop_name === shop_name.toString()),
|
||||
orders,
|
||||
pagination: {
|
||||
page: pageNum,
|
||||
|
||||
Reference in New Issue
Block a user