diff --git a/project/controller/backAnalysisCtrl.js b/project/controller/backAnalysisCtrl.js index c4d91ba7b5673681c04f6405e6f2b91ec30ff509..edba67e3c7832a0b31595443e242b5823756710f 100644 --- a/project/controller/backAnalysisCtrl.js +++ b/project/controller/backAnalysisCtrl.js @@ -11,6 +11,11 @@ const controller = { dao.getShoppingCartData([]) .then(response => resp.send(response)) .catch(error => console.error(error.message)) + }, + getOrderData (req, resp) { + dao.getOrderData() + .then(data => resp.send(data)) + .catch(error => console.log(error)) } }; diff --git a/project/dao/backAnalysisDao.js b/project/dao/backAnalysisDao.js index fd24bb053aae56ebbe286ac257b1bac694e2e73e..b44a43cd0ddbc387fc7a86fee30c815fd543cf74 100644 --- a/project/dao/backAnalysisDao.js +++ b/project/dao/backAnalysisDao.js @@ -66,6 +66,33 @@ const dao = { } }) }) + }, + getOrderData () { + return new Promise((resolve, reject) => { + let sql = ` + SELECT + order_sku_table.SKU_code, + Sum(order_sku_table.order_SKU_num) AS buyNum, + sku_info.SKU_name, + sku_info.sell_price, + sku_info.stock + FROM + order_table + INNER JOIN order_sku_table ON order_sku_table.order_id = order_table.order_id + INNER JOIN sku_info ON order_sku_table.SKU_code = sku_info.SKU_code + GROUP BY + order_sku_table.SKU_code + ORDER BY + buyNum DESC + `; + dbpool.connect(sql, [], (error, data) => { + if (error) { + reject(error) + } else { + resolve(data) + } + }) + }) } }; diff --git a/project/routes/backAnalysisRouter.js b/project/routes/backAnalysisRouter.js index af35edddb9c2a959c609e63a393118a8443adfbc..e07187a920a26d3f7e39f8f9e12b9979561bd7de 100644 --- a/project/routes/backAnalysisRouter.js +++ b/project/routes/backAnalysisRouter.js @@ -4,5 +4,6 @@ const router = express.Router(); router.get('/getCollectionData',controller.getCollectionData); router.get('/getShoppingCartData',controller.getShoppingCartData); +router.get('/getOrderData',controller.getOrderData); module.exports = router; diff --git "a/\351\241\271\347\233\256\351\203\250\347\275\262/logo.psd" "b/\351\241\271\347\233\256\351\203\250\347\275\262/logo.psd" index 31cc1759efa114a7915b160ae8e2e9f1f27f1c32..b6b775288d85f900716982deaab0f5c5c2a5bc4c 100644 Binary files "a/\351\241\271\347\233\256\351\203\250\347\275\262/logo.psd" and "b/\351\241\271\347\233\256\351\203\250\347\275\262/logo.psd" differ