diff --git a/README.md b/README.md index 159beb91c11390922b1b401e86fc5c80611996d9..ff42b6c14d466b9e30b26c5ed313aa59ab6e6e2b 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ - + ``` @@ -46,8 +46,8 @@ ```html - - + + ``` @@ -128,7 +128,7 @@ ### 关于引用路径 - jQuery、less文件都从public文件夹下 -- bootstrap文件前期请引用 ./frame/custom-bootstrap/custom-bootstrap.css +- bootstrap文件前期请引用 ./frame/bootstrap/css/bootstrap.min.css - 除bootstrap自带的字体图标外,还可以引用 ./frame/font-awesome-4.7.0/css/font-awesome.css 文件,API网址 http://fontawesome.dashgame.com/ - 图片路径 表格录入为 ./images/ diff --git a/project/app.js b/project/app.js index c67c7b0a11ccebb411ca77abc7ba6d41f1824208..0fcff54715d154e0db2571f761c587b7230d6781 100644 --- a/project/app.js +++ b/project/app.js @@ -22,6 +22,7 @@ app.use('/back*', (req,res,next)=> { const formroutes = require("./routes/formroutes");//登录路由 const CommodityRouting = require("./routes/CommodityRouting");//商品页路由 const shopping_router = require('./routes/shopping_router');//购买流程路由 +const comment_router = require('./routes/show_comments_router');//评论路由 const stylist_route = require('./routes/stylist_route');//设计师路由 const order = require('./routes/order');//订单系统路由 const personCenter_router = require('./routes/personCenter_router');//个人中心路由 @@ -37,9 +38,10 @@ const backRefundRouter = require('./routes/backRefundRouter'); // 交易管理 const backCommodityManagement = require('./routes/backCommodityManagement_route');//后台商品管理路由 const backDesignerRouter = require('./routes/backDesignerRouter');//后台设计师管理路由 const backGetorderlist=require('./routes/backGetorderlist');//后台订单路由 +const backAnalysisRouter = require('./routes/backAnalysisRouter');// 后台数据分析路由 // 引用路由 结束 -app.use(logger("dev"));//开发log配置 +// app.use(logger("dev"));//开发log配置 app.use(favicon(__dirname + "/public/images/favicon.ico"));//项目图标配置 //配置POST bodyParser 开始 @@ -64,13 +66,11 @@ app.use(session({ })); //缓存配置结束 - - //不需登录路由配置开始 app.use(formroutes); -// app.use(index_route); app.use(CommodityRouting); app.use(stylist_route); +app.use(comment_router); app.use(test); app.use(back_package_route); app.use(backStageLoginRouter); @@ -83,31 +83,21 @@ app.use(backCommodityManagement); app.use(backUserManageRouter); app.use(backGetorderlist); app.use(backDesignerRouter); +app.use(backAnalysisRouter); //不需登录路由配置结束 +//可直接访问静态资源配置 开始 +app.use(express.static(__dirname + "/public")); + // 配置通用拦截,防止未登录情况下进入其他网页 开始 app.use("/", (req, resp, next) => { req.headers.referer = req.headers.referer || ""; - if ( - req.session.username ||//若存在用户登陆信息 - req.path === "/login.html" //若访问的市登陆界面 - || req.path ==="/images/lgbj.png" - || req.path === "css/nav-footer/nav.css.map" - || req.path === "/pages/LJC/login2.html" - || req.path === "/pages/LJC/pwd.html" - || req.path === "/frame/bootstrap/css/bootstrap.min.css" - || req.path === "frame/bootstrap/css/bootstrap-theme.min.css" - || req.path === "/pages/LJC/reg.html" - || req.path === "/bootstrap-3.3.7-dist/css/bootstrap.css" - || req.headers.referer.match(/login.html$/)//若是在向服务器提交登录数据 + if (req.path === '/') { + resp.redirect("/home") + } else if ( + req.session.username//若存在用户登陆信息 || req.headers.referer.match(/productList$/) || req.headers.referer.match(/stylist$/) - || req.headers.referer.match(/login2.html$/) - || req.headers.referer.match(/pwd.html$/) - || req.headers.referer.match(/reg.html$/) - || req.headers.referer.match(/bootstrap.min.css$/) - || req.headers.referer.match(/bootstrap-theme.min.css$/) - || req.headers.referer.match(/nav.css.map$/) ) { next();//进入后续路由 @@ -117,12 +107,6 @@ app.use("/", (req, resp, next) => { }); // 配置通用拦截,防止未登录情况下进入其他网页 结束 -//可直接访问静态资源配置 开始 -app.use(express.static(__dirname + "/public")); -// app.use(express.static(__dirname + "/public/pages/LJC")); -// app.use(express.static(__dirname + "/public/pages/FYK")); - - //需登录路由配置 开始 app.use(order); app.use(shopping_router); @@ -131,7 +115,7 @@ app.use(personCenter_router); //跳转404页面 开始 app.use((req, resp) => { - resp.redirect("404.html"); + resp.redirect("./404.html"); resp.status(404); }); //跳转404页面 结束 @@ -139,5 +123,4 @@ app.use((req, resp) => { app.set("port", 8989); app.listen(8989, () => { console.log("服务启动" + app.get("port")); - }); diff --git a/project/controller/CommodityController.js b/project/controller/CommodityController.js index 002e876a691e7c2d9719e24799cc5bb3e1d6982c..64c900043c7ea313c4468874800f701c073b5a6b 100644 --- a/project/controller/CommodityController.js +++ b/project/controller/CommodityController.js @@ -2,7 +2,7 @@ const CommodityModel=require("../dao/CommodityDao"); const CommodityController= { commodityDetails (req, resp) { let SPU_code=req.query.SPU_code; - console.log("SPU_code="+SPU_code); + // console.log("SPU_code="+SPU_code); CommodityModel.getcommodityDetails([SPU_code]) .then((data)=>{ // console.log(data); @@ -10,16 +10,30 @@ const CommodityController= { }); }, productList (req, resp) { - CommodityModel.getAllGoods([]) + // console.log(req.query); + let code={ + main_type_code:``, + sub_type_id:`` + }; + if(req.query.main_type_code){ + if(req.query.main_type_code.length>1){ + code.main_type_code=req.query.main_type_code.split(`?`)[0]; + code.sub_type_id=req.query.main_type_code.split("=")[1]; + }else { + code.main_type_code=req.query.main_type_code; + } + } + // console.log(code); + CommodityModel.getAllGoods(code) .then((data)=>{ - console.log(data); + // console.log(data); resp.render('XY/productList', {mydata:data}) }); }, detailGoods(req,resp){ let detailColor=req.body.detailColor; let detailStyle=req.body.detailStyle; - console.log(detailColor,detailStyle); + // console.log(req.body); CommodityModel.detailGoods([detailColor,detailStyle]) .then((data)=>{ // console.log("------这里是控制层-------"); @@ -30,7 +44,7 @@ const CommodityController= { datailColor(req,resp){ let detailColor=req.body.detailColor; let SPUcode=req.body.SPUcode; - console.log("这里是颜色控制"+detailColor+SPUcode); + // console.log("这里是颜色控制"+detailColor+SPUcode); CommodityModel.detailColor([SPUcode,detailColor]) .then((data)=>{ // console.log("------这里是控制层-------"); @@ -42,8 +56,8 @@ const CommodityController= { let SKUcode=req.body.SKUcode; let goodsNum=req.body.goodsNum; let userID=req.session.username; - console.log("-------------------------------"); - console.log(userID); + // console.log("-------------------------------"); + // console.log(userID); CommodityModel.joinShoppingCar([SKUcode,goodsNum,userID,]) .then((data)=>{ resp.send("添加成功"); @@ -51,4 +65,4 @@ const CommodityController= { } }; -module.exports=CommodityController; \ No newline at end of file +module.exports=CommodityController; diff --git a/project/controller/backAnalysisCtrl.js b/project/controller/backAnalysisCtrl.js new file mode 100644 index 0000000000000000000000000000000000000000..edba67e3c7832a0b31595443e242b5823756710f --- /dev/null +++ b/project/controller/backAnalysisCtrl.js @@ -0,0 +1,22 @@ +const dao = require('../dao/backAnalysisDao'); + +const controller = { + getCollectionData (req, resp) { + let params = []; + dao.getCollectionData(params) + .then(response => resp.send(response)) + .catch(error => console.error(error.message)) + }, + getShoppingCartData (req, resp) { + 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)) + } +}; + +module.exports = controller; diff --git a/project/controller/backCommodityManagementController.js b/project/controller/backCommodityManagementController.js index b814463799e4d2e1fd0780f89375a9bc515bbf84..7abea042c14591e19261f4a7fe15fecb0f733e2a 100644 --- a/project/controller/backCommodityManagementController.js +++ b/project/controller/backCommodityManagementController.js @@ -23,13 +23,70 @@ const CommodityManagemen = { }) }, SKUEditRight(req,resp){ - console.log("------------------------------------控制层-------------------------------------"); - console.log(req.body.code); - console.log(req.body.SKU); - console.log(req.body.SKUattr); + // console.log("------------------------------------控制层-------------------------------------"); + // console.log(req.body.code); + // console.log(req.body.SKU); + // console.log(req.body.SKUattr); CommodityManagementModule.SKUEditRightDao([req.body.code,req.body.SKU,req.body.SKUattr]) .then((data)=>{ - console.log(data) + resp.send(data); + }) + }, + AddSKURingt(req,resp){ + console.log(req.body.form); + let SKUdata=[]; + for (let i in req.body.form){ + SKUdata.push(req.body.form[i]); + } + let SKUcolor=SKUdata.splice(9,2); + console.log(SKUdata); + console.log(SKUcolor); + CommodityManagementModule.AddSKURingtDao([SKUdata,SKUcolor]) + .then((data)=>{ + resp.send(data) + }) + }, + backSKUTypeToggle(req,resp){ + // console.log(req.body.arr); + // console.log(req.body.method); + CommodityManagementModule.backSKUTypeToggleDao([req.body.arr,req.body.method]) + .then((data)=>{ + console.log(data); + resp.send(data) + }) + }, + backSelectSKU(req,resp){ + console.log(req.body.from); + CommodityManagementModule.backSelectSKUDao(req.body.from) + .then(data=>{ + resp.send(data); + }) + }, + backSPUEditRight(req,resp){ + CommodityManagementModule.backSPUEditRightDao(req.body.code,req.body.arr) + .then(data=>{ + console.log(data); + resp.send(data); + }) + }, + backSPUTypeToggle(req,resp){ + CommodityManagementModule.backSPUTypeToggleDao([req.body.arr,req.body.method]) + .then((data)=>{ + console.log(data); + resp.send(data) + }) + }, + backAddSPURingt(req,resp){ + CommodityManagementModule.backAddSPURingtDao([req.body.arr]) + .then(data=>{ + resp.send(data); + }) + }, + backSelectSPU(req,resp){ + + CommodityManagementModule.backSelectSPUDao(req.body.from) + .then(data=>{ + resp.send(data); }) } diff --git a/project/controller/backGetorderlist.js b/project/controller/backGetorderlist.js index fbb6acfb0d58370f3e2f3f12457809d50ec443eb..f7971d8691ba24f371f6b157a5eb01f35f2f8619 100644 --- a/project/controller/backGetorderlist.js +++ b/project/controller/backGetorderlist.js @@ -2,9 +2,7 @@ const dbpool=require("../config/dbpoolconfig"); const controller={ getOrderlist(req,resp){ -console.log('111'); dbpool.connect(`SELECT -user_profile_table.user_nickname, order_table.order_id, order_table.user_id, order_table.addr_id, @@ -19,11 +17,21 @@ order_table.order_deliver_code, order_table.order_remarks, order_table.order_point, order_table.order_state, -user_profile_table.user_id +order_table.Logistics_mode, +user_profile_table.user_id, +user_profile_table.user_nickname, +user_profile_table.user_tel_num, +order_sku_table.order_SKU_id, +order_sku_table.SKU_code, +order_sku_table.order_id, +order_sku_table.order_SKU_num, +sku_table.SKU_name, +sku_table.SKU_code FROM order_table INNER JOIN user_profile_table ON order_table.user_id = user_profile_table.user_id - +INNER JOIN order_sku_table ON order_sku_table.order_id = order_table.order_id +INNER JOIN sku_table ON order_sku_table.SKU_code = sku_table.SKU_code `,[null],function (err,data) { resp.send(data); @@ -51,7 +59,50 @@ INNER JOIN user_profile_table ON order_table.user_id = user_profile_table.user_i } }) - } + }, +// backOrderdetails(req,resp){ +// console.log('233333'); +// let detailsID=req.query.detailsID; +// +// dbpool.connect(`SELECT +// order_table.order_id, +// order_table.user_id, +// order_table.addr_id, +// DATE_FORMAT(order_table.order_place_time, '%Y-%m-%d% %H:%i:%S')AS 'order_place_time', +// DATE_FORMAT(order_table.order_pay_time, '%Y-%m-%d% %H:%i:%S')AS 'order_pay_time', +// DATE_FORMAT(order_table.order_deliver_time, '%Y-%m-%d% %H:%i:%S')AS 'order_deliver_time', +// DATE_FORMAT(order_table.order_receive_time, '%Y-%m-%d% %H:%i:%S')AS 'order_receive_time', +// order_table.order_cut_down, +// order_table.order_amount, +// order_table.order_pay_method, +// order_table.order_deliver_code, +// order_table.order_remarks, +// order_table.order_point, +// order_table.order_state, +// order_table.Logistics_mode, +// user_profile_table.user_id, +// user_profile_table.user_nickname, +// user_profile_table.user_tel_num, +// order_sku_table.order_SKU_id, +// order_sku_table.SKU_code, +// order_sku_table.order_id, +// order_sku_table.order_SKU_num, +// sku_table.SKU_name, +// sku_table.SKU_code +// FROM +// order_table +// INNER JOIN user_profile_table ON order_table.user_id = user_profile_table.user_id +// INNER JOIN order_sku_table ON order_sku_table.order_id = order_table.order_id +// INNER JOIN sku_table ON order_sku_table.SKU_code = sku_table.SKU_code +// WHERE +// order_table.order_id = ? +// +// `,[detailsID],(err,data)=>{ +// resp.send(data); +// console.log(data) +// }) +// +// } }; diff --git a/project/controller/backLoginforCtrl.js b/project/controller/backLoginforCtrl.js index 46baf71e1fa32df5f9650c2f0ef17e3da9f0a871..e6eef3f250430e5351ba23d791c648a8a4e227ca 100644 --- a/project/controller/backLoginforCtrl.js +++ b/project/controller/backLoginforCtrl.js @@ -51,7 +51,6 @@ const backLogCtrl = { let value1=req.query.value1; let value2=req.query.value2; let params = [value1,value2]; - console.log(params); inforModel.displayinfoop4(params) .then((data)=>{ // console.log('查到了'); @@ -60,6 +59,17 @@ const backLogCtrl = { .catch((error) => { console.log(error.message) }) + }, + lognum(req, resp) { + let params = []; + inforModel.lognumdao(params) + .then((data)=>{ + // console.log('查到了'); + resp.send(data) + }) + .catch((error) => { + console.log(error.message) + }) } } diff --git a/project/controller/backRefundCtrl.js b/project/controller/backRefundCtrl.js index 00dc54b0f3e467668198140beb858ee502129444..50c2e21a00593cdf176669bb98270a59bb58b8ea 100644 --- a/project/controller/backRefundCtrl.js +++ b/project/controller/backRefundCtrl.js @@ -9,18 +9,19 @@ const controller = { // console.log(data); }) }, - editRefund(req, resp){ + editRefund(req, resp) { // console.log('222'); // console.log(req.query.name); - let params=[req.query.region,req.query.money,req.query.desc,req.query.date1,req.query.name]; + let params = [req.query.region, req.query.money, req.query.desc, req.query.date1, req.query.logistic, req.query.name]; console.log(params); dbpool.connect(`UPDATE refund_table SET handle_method = ?, refund_money = ?, handle_note = ?, - handle_time = ? + handle_time = ? , + express_code = ? WHERE refund_id = ? - `,params,(error,data)=>{ + `, params, (error, data) => { console.log(error); console.log(data); }) diff --git a/project/controller/back_admin_Controller.js b/project/controller/back_admin_Controller.js index ab61ef2b0c71c370c6c97318af999241e4479e9d..7ac1b43a4bd59494b469c6142e6fc33bdfce0562 100644 --- a/project/controller/back_admin_Controller.js +++ b/project/controller/back_admin_Controller.js @@ -1,22 +1,109 @@ const dbpool = require("../config/dbpoolconfig"); -const adminList={ - adminList(request,response){ +const adminList = { + //获取所有数据 + adminList(request, response) { // console.log(211) dbpool.connect(`SELECT employee_table.employee_id, -employee_table.employee_name, employee_table.employee_password, +employee_table.employee_name, +employee_table.employee_age, +employee_table.employee_sex, employee_table.employee_tel, +employee_table.employee_email, employee_table.employee_level, -employee_table.employee_describe, -employee_table.employee_reg_date +employee_table.employee_status, +DATE_FORMAT(reg_time, '%Y-%m-%d% %H:%i:%S') AS reg_time FROM employee_table -`,[null],(error,data)=>{ - console.log(data); + + +`, [null], (error, data) => { + // console.log(data); response.send(data) + }); + }, + //添加数据 + addList(request, response) { + // console.log(22211); + // console.log(request.query.position); + let params = [null, request.query.pass, request.query.name, request.query.age, + request.query.sex, request.query.phone, request.query.email, request.query.position, + null, request.query.status, null + ]; + // console.log(params); + dbpool.connect(`insert into employee_table values(?,?,?,?,?,?,?,?,?,?,?)` + , params, (error, data) => { + console.log(data); + console.log(error) + if (!error) { + response.send('success') + } else { + response.send(error.message) + } + }) + }, + //编辑数据 + editAdmin(request, response) { + // console.log(22222); + // console.log(request.query.status) + let params = [request.query.pass, request.query.name, request.query.age, + request.query.sex, request.query.phone, request.query.email, request.query.position, + null, request.query.status, request.query.loginName + ]; + // console.log(params) + dbpool.connect(`UPDATE employee_table +SET employee_password = ?, +employee_name = ?, +employee_age = ?, +employee_sex = ?, +employee_tel = ?, +employee_email = ?, +employee_level = ?, +employee_describe= ? , +employee_status= ? +WHERE + employee_id = ?`, params, (error, data) => { + // console.log(error); + // console.log(data); + if (!error) { + response.send('success') + } else { + response.send(error.message) + } }) - } + }, + //状态改变 + changeStatus(request, response) { + // console.log(3333); + // console.log(request.query.id); + // console.log(request.query.status); + let params = []; + if (request.query.status === "启用") { + params = ["停用", request.query.id] + } else { + params = ["启用", request.query.id] + } + dbpool.connect(`UPDATE employee_table + SET employee_status= ? +WHERE employee_id = ?`, params, (error, data) => { + // console.log(error) + // console.log(data) + response.send('success') + }) + + }, + //删除数据 + // deleteData(request, response) { + // // console.log(request.query.id) + // dbpool.connect(`DELETE FROM employee_table WHERE employee_id=?`, request.query.id + // , (error, data) => { + // // console.log(error) + // // console.log(data) + // response.send('success') + // }) + // }, + }; -module.exports=adminList; +module.exports = adminList; diff --git a/project/controller/back_limitController.js b/project/controller/back_limitController.js index 11a5af3eb87e3efa6f146d4dae6c9c77462a414d..3f39cf490b10bfdfd815f462c59c0b41887aa691 100644 --- a/project/controller/back_limitController.js +++ b/project/controller/back_limitController.js @@ -4,10 +4,6 @@ const employeeList = { // console.log(222) dbpool.connect(`SELECT Count(employee_table.employee_level) AS num, -employee_table.employee_id, -employee_table.employee_name, -employee_table.employee_password, -employee_table.employee_tel, employee_table.employee_describe, employee_table.employee_level FROM diff --git a/project/controller/homepageController.js b/project/controller/homepageController.js index f3982313eb9e3d36871feba66a32ddb76255554a..760c4a44411ae4191d5f42d8339fdf4c083ecfca 100644 --- a/project/controller/homepageController.js +++ b/project/controller/homepageController.js @@ -306,7 +306,7 @@ designer_table.designer_name `, [null], (err10, data10) => { obj.decorate = data10; - console.log(obj); + // console.log(obj); response.render('index', obj); }) }) @@ -322,4 +322,4 @@ designer_table.designer_name }; -module.exports = homepageController; \ No newline at end of file +module.exports = homepageController; diff --git a/project/controller/shopping_controller.js b/project/controller/shopping_controller.js index 9df4b6421596d621f8deed87781d1a43252f520a..1dbacaa7321717657828c8b3e8423ec827262801 100644 --- a/project/controller/shopping_controller.js +++ b/project/controller/shopping_controller.js @@ -83,6 +83,20 @@ const controller = { .catch((data)=>{ resp.send(); }) + }, + add_addr (req, resp) { + let params = [ + req.session.username, + req.body.province, + req.body.city, + req.body.district, + req.body.detail, + req.body.name, + req.body.tel + ]; + dao.add_addr(params) + .then(data => resp.send(data)) + .catch(error => resp.send(error.message)) } }; diff --git a/project/controller/show_comment_ctrl.js b/project/controller/show_comment_ctrl.js new file mode 100644 index 0000000000000000000000000000000000000000..366541d1bcf36cd48ae9f698c362f6abdc86fbfb --- /dev/null +++ b/project/controller/show_comment_ctrl.js @@ -0,0 +1,11 @@ +const dao = require('../dao/show_comment_dao'); + +const showCommentCrtl = { + showComment (req, resp) { + dao.showComment() + .then(response => resp.render('TYH/show_comments',{commentList: response})) + .catch(error => console.error(error.message)) + } +}; + +module.exports = showCommentCrtl; diff --git a/project/dao/CommodityDao.js b/project/dao/CommodityDao.js index 866b9847b89eaebcadd71a43147797c404f5baa7..2d90a17bb9c12123863f0d5598d990b14bb015d8 100644 --- a/project/dao/CommodityDao.js +++ b/project/dao/CommodityDao.js @@ -1,21 +1,30 @@ const dbpool = require("../config/dbpoolconfig"); const CommodityDao = { getAllGoods(params) { + let sql=`SELECT + * + FROM + sku_spu_view + WHERE + 1=1`; + let arr=[]; + if(params.main_type_code!==``){ + sql += ` and main_type_code = ? `; + arr.push(params.main_type_code); + } + if(params.sub_type_id!==``){ + sql += ` and sub_type_id = ? `; + arr.push(params.sub_type_id); + } + sql += ` GROUP BY + sku_spu_view.SPU_code`; + + // console.log(params); + // console.log(sql); return new Promise((resolve, reject) => { - dbpool.connect("SELECT\n" + - "spu_table.SPU_code,\n" + - "spu_table.SPU_name,\n" + - "spu_table.SPU_describe,\n" + - "spu_table.SPU_head_img_path,\n" + - "sku_table.SKU_code,\n" + - "sku_table.sell_price\n" + - "FROM\n" + - "spu_table\n" + - "INNER JOIN sku_table ON sku_table.SPU_code = spu_table.SPU_code\n" + - "GROUP BY\n" + - "spu_table.SPU_code\n", params, (err, data) => { - console.log("Dao:"); - console.log(data); + dbpool.connect(sql, arr, (err, data) => { + // console.log("Dao:"); + // console.log(data); resolve(data); }) }) @@ -124,15 +133,15 @@ const CommodityDao = { sendObj.SKUsize=SKUsize; sendObj.mainData=data; if (err) { - console.log("这里是DAO错误-------"); - console.log(err); + // console.log("这里是DAO错误-------"); + console.error(err.message); } else { - console.log("这里是DAO正确-------"); - console.log(sendObj.SKUsize); + // console.log("这里是DAO正确-------"); + // console.log(sendObj.SKUsize); dbpool.connect(designer,params,(err,data)=>{ if (err) { - console.log("这里是DAO错误-------"); - console.log(err); + // console.log("这里是DAO错误-------"); + console.error(err.message); } else { // console.log("这里是DAO正确-------"); // console.log(data); @@ -159,7 +168,8 @@ const CommodityDao = { sku_info.spec_option_value_color, sku_info.spec_option_value_style, sku_info.SKU_pic_path, - sku_info.sell_price + sku_info.sell_price, + sku_info.SPU_code FROM sku_info WHERE @@ -168,15 +178,15 @@ const CommodityDao = { `; dbpool.connect(sql, params, (err, data) => { if (err) { - console.log("这里是商品DAO错误-------"); - console.log(err); + console.error("这里是商品DAO错误-------"); + console.error(err.message); } else { - console.log("这里是商品DAO正确-------"); - console.log(data); + // console.log("这里是商品DAO正确-------"); + // console.log(data); } resolve(data); - console.log(params); + // console.log(params); }) }) @@ -197,11 +207,11 @@ const CommodityDao = { `; dbpool.connect(sql,params,(err,data)=>{ if (err) { - console.log("这里是颜色DAO错误-------"); - console.log(err); + console.error("这里是颜色DAO错误-------"); + console.error(err.message); } else { - console.log("这里是颜色DAO正确-------"); - console.log(data); + // console.log("这里是颜色DAO正确-------"); + // console.log(data); } resolve(data); }) @@ -214,15 +224,15 @@ const CommodityDao = { VALUES (null,?,?,?,null)`; dbpool.connect(sql,params,(err,data)=>{ if (err) { - console.log("这里是加入购物车DAO错误-------"); - console.log(err); + console.error("这里是加入购物车DAO错误-------"); + console.error(err.message); } else { - console.log("这里是加入购物车DAO正确-------"); - console.log(data); + // console.log("这里是加入购物车DAO正确-------"); + // console.log(data); } }) }) } }; -module.exports = CommodityDao; \ No newline at end of file +module.exports = CommodityDao; diff --git a/project/dao/backAnalysisDao.js b/project/dao/backAnalysisDao.js new file mode 100644 index 0000000000000000000000000000000000000000..b44a43cd0ddbc387fc7a86fee30c815fd543cf74 --- /dev/null +++ b/project/dao/backAnalysisDao.js @@ -0,0 +1,99 @@ +const dbpool = require('../config/dbpoolconfig'); +const dao = { + getCollectionData (params) { + return new Promise((resolve, reject) => { + let sql = ` + SELECT + collection_table.SKU_code, + Count(collection_table.SKU_code) AS collectNum, + sku_info.SKU_name, + sku_info.spec_option_value_style, + sku_info.spec_option_value_color, + sku_info.SPU_name, + sku_info.sub_type_name, + sku_info.main_type_name, + sku_info.sell_price, + sku_info.stock + FROM + collection_table + INNER JOIN sku_info ON collection_table.SKU_code = sku_info.SKU_code + GROUP BY + sku_info.SKU_name, + sku_info.spec_option_value_style, + sku_info.spec_option_value_color, + sku_info.SPU_name, + sku_info.sub_type_name, + sku_info.main_type_name, + sku_info.sell_price, + sku_info.stock + ORDER BY + collectNum DESC + LIMIT 0, 10 + `; + dbpool.connect(sql, params, (error, data) => { + if (error) { + reject(error) + } else { + resolve(data) + } + }) + }) + }, + getShoppingCartData (params) { + return new Promise((resolve, reject) => { + let sql = ` + SELECT + shopping_car_item_table.SKU_code, + Sum(shopping_car_item_table.shopping_car_SKU_num) AS addNum, + sku_info.SKU_name, + sku_info.spec_option_value_color, + sku_info.spec_option_value_style, + sku_info.sell_price, + sku_info.stock + FROM + shopping_car_item_table + INNER JOIN sku_info ON shopping_car_item_table.SKU_code = sku_info.SKU_code + GROUP BY + shopping_car_item_table.SKU_code + ORDER BY + addNum DESC + `; + dbpool.connect(sql, params, (error, data) => { + if (error) { + reject(error) + } else { + resolve(data) + } + }) + }) + }, + 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) + } + }) + }) + } +}; + +module.exports = dao; diff --git a/project/dao/backCommodityManagementDao.js b/project/dao/backCommodityManagementDao.js index 9b7f7827370fd4609320db425c8b84f02a396d2d..74c69a2d328bb2d63a6eac5d640b229172ee1b9f 100644 --- a/project/dao/backCommodityManagementDao.js +++ b/project/dao/backCommodityManagementDao.js @@ -3,28 +3,115 @@ const backCommodityManagementDao = { getbackSKUManageDao(params){ return new Promise((resolve) =>{ let sql = `SELECT * FROM \`sku_info\``; + let spu = `SELECT * FROM \`spu_view\``; + let style = `SELECT + spec_option_table.spec_option_id, + spec_option_table.spec_id, + spec_option_table.spec_option_value + FROM + spec_option_table + WHERE + spec_option_table.spec_id = 1`; + let color = `SELECT + spec_option_table.spec_option_id, + spec_option_table.spec_id, + spec_option_table.spec_option_value + FROM + spec_option_table + WHERE + spec_option_table.spec_id = 2 + `; + let SKU={ + list:null, + SUPelect:null, + style:null, + color:null + }; dbpool.connect(sql,params,(err,data)=>{ // console.log("Dao:"); // console.log(data); - resolve(data); + SKU.list=data; + /*对象去重*/ + let obj = {}; + // SKU.SUPelect = data.reduce(function(item, next) { + // obj[next.SPU_code] ? '' : obj[next.SPU_code] = true && item.push(next); + // return item; + // }, []); + obj={}; + SKU.style= data.reduce(function(item, next) { + obj[next.spec_option_id_style] ? '' : obj[next.spec_option_id_style] = true && item.push(next); + return item; + }, []); + obj={}; + SKU.color= data.reduce(function(item, next) { + obj[next.spec_option_id_color] ? '' : obj[next.spec_option_id_color] = true && item.push(next); + return item; + }, []); + /*/对象去重*/ + dbpool.connect(spu,params,(err,data)=>{ + SKU.SUPelect=data; + dbpool.connect(style,params,(err,data)=>{ + SKU.style=data; + dbpool.connect(color,params,(err,data)=>{ + SKU.color=data ; + resolve(SKU); + }); + }); + // console.log(SKU.style); + }); }) } ) }, getbackSPUManageDao(params){ return new Promise((resolve) =>{ - let sql = `SELECT - * + let myData={ + list:null, + designer:null, + main_type:null, + sub_type:null, + series:null + }; + let sql = ` + SELECT * FROM spu_view + `; + let designer_table=`SELECT + designer_table.designer_id, + designer_table.designer_name + FROM + designer_table`; + let main_type=`SELECT + main_type_table.main_type_code, + main_type_table.main_type_name FROM - sku_spu_view - GROUP BY - sku_spu_view.SPU_code + main_type_table `; + let sub_type=`SELECT + sub_type_table.sub_type_id, + sub_type_table.main_type_code, + sub_type_table.sub_type_name + FROM + sub_type_table`; + let series=`SELECT + product_series_table.product_series_id, + product_series_table.product_series_name + FROM product_series_table`; dbpool.connect(sql,params,(err,data)=>{ - console.log("Dao:"); - console.log(data); - resolve(data); + myData.list=data; + dbpool.connect(designer_table,params,(err,data)=>{ + myData.designer=data; + dbpool.connect(main_type,params,(err,data)=>{ + myData.main_type=data; + dbpool.connect(sub_type,params,(err,data)=>{ + myData.sub_type=data; + dbpool.connect(series,params,(err,data)=>{ + myData.series=data; + resolve(myData); + }); + }) + }) + }) }) - } ) + }) }, SKUEditDao(params){ return new Promise((resolve => { @@ -104,17 +191,6 @@ const backCommodityManagementDao = { // UPDATE sku_table SET SKU_name="大先生沙发转角大三人座新版米黄" and sell_price=8599 and purchase_price= 5400 AND stock=111 WHERE SKU_code= 80000001 let SKUup = `UPDATE sku_table SET SKU_name=?,sell_price=?,purchase_price= ?,stock=? WHERE SKU_code= ?`; // let SKUup = `UPDATE sku_table SET SKU_name="?",sell_price=?,purchase_price= ?,stock=? WHERE SKU_code= ?`; - let SKUslect= `SELECT - spec_option_table.spec_option_value, - sku_spec_table.spec_col_id, - sku_spec_table.spec_option_id, - sku_spec_table.SKU_code - FROM - spec_option_table - INNER JOIN sku_spec_table ON sku_spec_table.spec_option_id = spec_option_table.spec_option_id - WHERE - spec_id = ? AND - sku_spec_table.SKU_code = ?`; let SKUsetarrt=`UPDATE sku_spec_table set spec_option_id = ? WHERE spec_col_id = ? and SKU_code = ?`; dbpool.connect(SKUup,SKU,(err,data)=>{ console.log("SKUup成功"); @@ -125,12 +201,208 @@ const backCommodityManagementDao = { console.log(data); dbpool.connect(SKUsetarrt,[params[2][2],params[2][3],params[0]],(err,data)=>{ console.log("狗日的颜色改成功了:"); - console.log(data) + console.log(data); + resolve("修改成功了"); }); }); }) })) + }, + AddSKURingtDao(params){ + return new Promise((resolve) => { + let AddSKU=`INSERT INTO \`interesting_ph3\`.\`sku_table\` ( \`SPU_code\`, \`SKU_name\`, \`purchase_price\`, \`sell_price\`, \`stock\`, \`produce_date\`, \`SKU_pic_path\`, \`SKU_size_pic_path\`, \`SKU_type_state\` ) + VALUES + \t( ?,?,?,?,?,?,?,?,?)`; + let selectSKU=`SELECT + \tsku_table.SKU_code + FROM + \tsku_table + WHERE + \tsku_table.SPU_code = ? + \tAND sku_table.SKU_name = ? + \tAND sku_table.purchase_price = ? + \tAND sku_table.sell_price = ? + \tAND sku_table.stock = ? + \tAND sku_table.produce_date = ? + \tAND sku_table.SKU_pic_path = ? + \tAND sku_table.SKU_size_pic_path = ? + \tAND sku_table.SKU_type_state = ?`; + let SKUattr=`INSERT INTO \`interesting_ph3\`.\`sku_spec_table\`(\`spec_option_id\`, \`SKU_code\`) VALUES (?, ?)`; + let SKUcode=null; + dbpool.connect(AddSKU,params[0],(err,data)=>{ + dbpool.connect(selectSKU,params[0],(err,data)=>{ + SKUcode=data[0].SKU_code; + dbpool.connect(SKUattr,[params[1][0],SKUcode],(err,data)=>{ + dbpool.connect(SKUattr,[params[1][1],SKUcode],(err,data)=>{ + console.log("数据添加成功"); + resolve("数据添加成功"); + }); + }); + }); + }) + }) + }, + backSKUTypeToggleDao(params){ + let q=''; + params[0].forEach((val, index, arr) => { + if (arr.length === 1) { + q = '= ?'; + } else { + if (index !== arr.length-1) { + q+= '?,' + } else { + q+= '?' + q = `IN (${q})` + } + } + }); + let alterState = `UPDATE sku_table SET SKU_type_state = '${params[1]}' WHERE SKU_code ${q}`; + console.log(alterState); + + return new Promise((resolve) => { + dbpool.connect(alterState,params[0],(err,data)=>{ + resolve("数据修改成功"); + }) + }) + }, + backSelectSKUDao(params){ + let sql=`SELECT * FROM sku_info WHERE 1=1`; + let arr = []; + let SPU_name=params.name; + let SPU_code=params.code; + let spec_option_id_color = params.color; + let spec_option_id_style = params.style; + let SKU_type_state = params.state; + if(SPU_name !== ''){ + SPU_name = `%${SPU_name}%`; + sql += ` and SPU_name like ?`; + arr.push(SPU_name); + } + if(SPU_code !== ''){ + SPU_code = `%${SPU_code}%`; + sql += ` and SPU_code like ?`; + arr.push(SPU_code); + + } + if(spec_option_id_color !== ''){ + spec_option_id_color = `%${spec_option_id_color}%`; + sql += ` and spec_option_id_color like ?`; + arr.push(spec_option_id_color); + + } + if(spec_option_id_style !== ''){ + spec_option_id_style = `%${spec_option_id_style}%`; + sql += ` and spec_option_id_style like ?`; + arr.push(spec_option_id_style); + } + if(SKU_type_state !== ''){ + SKU_type_state = `%${SKU_type_state}%`; + sql += ` and SKU_type_state like ?`; + arr.push(SKU_type_state); + } + console.log(arr); + console.log(sql); + + return new Promise(resolve => { + dbpool.connect(sql,arr,(err,data)=>{ + resolve(data); + }) + }) + }, + backSPUEditRightDao(code,params){ + let sql=`UPDATE interesting_ph3.spu_table + SET designer_id = ?, + sub_type_id = ?, + SPU_name = ?, + SPU_describe = ?, + SPU_head_img_path = ? + WHERE + SPU_code = ${code}`; + return new Promise(resolve => { + dbpool.connect(sql,params,(err,data)=>{ + resolve(data) + }) + }) + }, + backSPUTypeToggleDao(params){ + let q=''; + params[0].forEach((val, index, arr) => { + if (arr.length === 1) { + q = '= ?'; + } else { + if (index !== arr.length-1) { + q+= '?,' + } else { + q+= '?' + q = `IN (${q})` + } + } + }); + let alterState = `UPDATE spu_table SET SPU_state = '${params[1]}' WHERE SPU_code ${q}`; + console.log(alterState); + + return new Promise((resolve) => { + dbpool.connect(alterState,params[0],(err,data)=>{ + console.log(data); + resolve("数据修改成功"); + }) + }) + }, + backAddSPURingtDao(params){ + let sql=`INSERT INTO interesting_ph3.spu_table ( designer_id, sub_type_id, SPU_name, SPU_describe, SPU_head_img_path, SPU_state ) + VALUES + ( ?, ?, ?, ?, ?, ? )`; + return new Promise(resolve => { + console.log(params); + dbpool.connect(sql,params[0],(err,data)=>{ + console.log(err); + resolve("数据添加成功"); + }) + }) + }, + backSelectSPUDao(params){ + console.log(params); + let sql=`SELECT * FROM sku_spu_view WHERE 1=1`; + let arr = []; + let SPU_name=params.name; + let main_type_name=params.main_Value; + let sub_type_name = params.sub_type; + let SPU_state = params.state; + if(SPU_name !== ''){ + SPU_name = `%${SPU_name}%`; + sql += ` and SPU_name like ?`; + arr.push(SPU_name); + } + if(main_type_name !== ''){ + main_type_name = `%${main_type_name}%`; + sql += ` and main_type_code like ?`; + arr.push(main_type_name); + + } + if(sub_type_name !== ''){ + sub_type_name = `%${sub_type_name}%`; + sql += ` and sub_type_id like ?`; + arr.push(sub_type_name); + } + if(SPU_state !== ''){ + SPU_state = `%${SPU_state}%`; + sql += ` and SPU_state like ?`; + arr.push(SPU_state); + } + sql += ` GROUP BY SPU_code`; + + console.log(arr); + console.log(sql); + + return new Promise(resolve => { + dbpool.connect(sql,arr,(err,data)=>{ + console.log(data) + resolve(data); + }) + }) + } + }; diff --git a/project/dao/inforDao.js b/project/dao/inforDao.js index 342f815b9f0ed822de78dc03fca39791eb44d003..04d54ba94a93fd04f78900966117c599e0cff420 100644 --- a/project/dao/inforDao.js +++ b/project/dao/inforDao.js @@ -56,7 +56,27 @@ const inforModel={ }) }) }, + lognumdao(params){ + return new Promise((resolve,reject)=>{ + dbpool.connect(` + SELECT + (SELECT COUNT(login_time) FROM login_log_table WHERE DATE_FORMAT(login_time,'%Y-%m-%d')= DATE_FORMAT(NOW(),'%Y-%m-%d'))AS t, + (SELECT COUNT(login_time) FROM login_log_table WHERE DATE_FORMAT(login_time,'%Y-%m-%d')= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 DAY),'%Y-%m-%d'))AS t1, + (SELECT COUNT(login_time) FROM login_log_table WHERE DATE_FORMAT(login_time,'%Y-%m-%d')= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 2 DAY),'%Y-%m-%d'))AS t2, + (SELECT COUNT(login_time) FROM login_log_table WHERE DATE_FORMAT(login_time,'%Y-%m-%d')= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 3 DAY),'%Y-%m-%d')) AS t3, + (SELECT COUNT(login_time) FROM login_log_table WHERE DATE_FORMAT(login_time,'%Y-%m-%d')= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 4 DAY),'%Y-%m-%d') )AS t4, + (SELECT COUNT(login_time) FROM login_log_table WHERE DATE_FORMAT(login_time,'%Y-%m-%d')= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 5 DAY),'%Y-%m-%d'))AS t5, + (SELECT COUNT(login_time) FROM login_log_table WHERE DATE_FORMAT(login_time,'%Y-%m-%d')= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 6 DAY),'%Y-%m-%d'))AS t6 + `,params, (error, data ) => { + if(error){ + reject(error) + }else { + resolve(data) + } + }) + }) + }, }; -module.exports = inforModel; \ No newline at end of file +module.exports = inforModel; diff --git a/project/dao/shopping_dao.js b/project/dao/shopping_dao.js index a15d4a1d2efd618295122ddbf42ee1ac5206bbf5..d793e60f9e5b13bae68b8303ba5556ac4e6d3eb4 100644 --- a/project/dao/shopping_dao.js +++ b/project/dao/shopping_dao.js @@ -243,8 +243,44 @@ const dao = { resolve('success'); }) }) + }, + add_addr (params) { + return new Promise((resolve, reject) => { + let sql =` + INSERT INTO user_addr_table + ( user_id, addr_province, addr_city, addr_district, addr_detail, addressee_name, addressee_tel ) + VALUES + ( ?, ?, ?, ?, ?, ?, ? ) + `; + dbpool.connect(sql, params, (error, data) => { + if (error) { + reject(error) + } else { + dbpool.connect(` + SELECT + user_addr_table.addr_id + FROM + user_addr_table + WHERE + user_addr_table.user_id = ? AND + user_addr_table.addr_province = ? AND + user_addr_table.addr_city = ? AND + user_addr_table.addr_district = ? AND + user_addr_table.addr_detail = ? AND + user_addr_table.addressee_name = ? AND + user_addr_table.addressee_name = ? + `, params, (error2, data2) => { + if (error2) { + reject(error2) + }else { + resolve(data2) + } + }) + } + }) + }) } }; -module.exports = dao; \ No newline at end of file +module.exports = dao; diff --git a/project/dao/show_comment_dao.js b/project/dao/show_comment_dao.js new file mode 100644 index 0000000000000000000000000000000000000000..6f5923626ff3bc16bb01bb983d6c0d015aae5a12 --- /dev/null +++ b/project/dao/show_comment_dao.js @@ -0,0 +1,36 @@ +const dbpool = require('../config/dbpoolconfig'); + +const showCommentDao = { + showComment () { + return new Promise((resolve, reject) => { + let sql = ` + SELECT + comment_table.comment_id, + comment_table.comment_star, + comment_table.comment_content, + user_profile_table.user_nickname, + user_addr_table.addr_province, + user_addr_table.addr_city, + comment_pic_table.comment_pic_url, + comment_pic_table.comment_pic_id, + user_profile_table.user_icon_path + FROM + comment_table + INNER JOIN user_profile_table ON comment_table.user_id = user_profile_table.user_id + INNER JOIN user_addr_table ON user_addr_table.user_id = user_profile_table.user_id + INNER JOIN comment_pic_table ON comment_pic_table.comment_id = comment_table.comment_id + GROUP BY + comment_table.comment_id + `; + dbpool.connect(sql, [], (error,data) => { + if (error) { + reject(error) + } else { + resolve(data) + } + }) + }) + } +}; + +module.exports = showCommentDao; diff --git a/project/public/pages/LJC/404.html b/project/public/404.html similarity index 60% rename from project/public/pages/LJC/404.html rename to project/public/404.html index cbee847f02760c8a3cf92c07d1bafcb7b476e05e..da1db95d3f02d62f35a189ddbe9762ccdbaa6532 100644 --- a/project/public/pages/LJC/404.html +++ b/project/public/404.html @@ -3,23 +3,23 @@