作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
本项目分为前后台,前台普通用户登录,后台管理员登录;
管理员角色包含以下功能:
管理员登录,修改个人信息,人员管理,图片管理,订单管理,图表管理,农资管理等功能。
用户角色包含以下功能:
按分类查看农资产品,用户登录,查看商品详情,加入购物车,提交订单,修改个人信息,查看订单等功能。
由于本程序规模不大,可供课程设计,毕业设计学习演示之
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:MySql 5.7版本;
6.是否Maven项目:是;
技术栈
1. 后端:Spring+SpringMVC+Mybatis
2. 前端:JSP+CSS+JavaScript+jQuery
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,前台地址:http://localhost:8080/snack/shop/index 注:tomcat中配置的路径必须为snack
用户账号/密码:wangzixiao/123456
后台地址:http://localhost:8080/snack/admin/login/adminLogin
管理员账号/密码:admin/123456
运行截图
前台界面
后台界面
代码相关
订单管理控制器
@Controller
@RequestMapping("/admin/order/")
public class AdminOrderControll {
@Autowired
private adminOrderService adminOrderService;
@Autowired
private userService userService;
@RequestMapping("mainToAdminOrder")
public String mainToAdminOrder(){
return "admin/order/adminOrder";
}
//订单
@RequestMapping("adminOrderLimit")
@ResponseBody
public DataTables adminOrderLimit(int start,int length,
String oId,String oTimeStart,String oTimeEnd,String adUserName){
Map<Object,Object> map=new HashMap<Object, Object>();
map.put("pageStart",start);
map.put("pageSize",length);
map.put("oId",oId);
map.put("oTimeStart",oTimeStart);
map.put("oTimeEnd",oTimeEnd);
map.put("adUserName",adUserName);
PageHelp<DoAdminOrder> pageHelp= adminOrderService.selectAdminOrderLimit(map);
DataTables datatable=new DataTables();
datatable.setData(pageHelp.getList());
datatable.setRecordsFiltered(pageHelp.getRecord());
datatable.setRecordsTotal(pageHelp.getRecord());
return datatable;
}
//删除订单
@RequestMapping("deleteAdminOrder")
@ResponseBody
public String deleteAdminOrder(String oId){
return ResponseUtil.successToClient(adminOrderService.deleteAdminOrder(oId));
}
//update加载订单
@RequestMapping("updateSelectAdminOrder")
@ResponseBody
public String updateSelectAdminOrder(int rId){
return ResponseUtil.successToClient(adminOrderService.updateSelectAdminOrder(rId));
}
//update订单
@RequestMapping("updateAdminOrder")
@ResponseBody
public String updateAdminOrder(Receiptinfo receiptinfo){
return ResponseUtil.successToClient(adminOrderService.updateAdminOrder(receiptinfo));
}
//updateOrderDetial加载订单
@RequestMapping("updateSelectAdminOrderDetial")
@ResponseBody
public String updateSelectAdminOrderDetial(int dId){
return ResponseUtil.successToClient(adminOrderService.updateSelectAdminOrderDetial(dId));
}
//updateOrderDetial订单
@RequestMapping("updateOrderdetail")
@ResponseBody
public String updateOrderdetail(Orderdetail orderdetail){
return ResponseUtil.successToClient(adminOrderService.updateOrderdetail(orderdetail));
}
//删除OrderDetial
@RequestMapping("deleteOrderdetail")
@ResponseBody
public String deleteOrderdetail(int dId,String oId){
List<Orderdetail> orderdetailList = adminOrderService.selectOrderdetailByoId(oId);
if(orderdetailList.size()>=2){
adminOrderService.deleteOrderdetailBydId(dId);
return ResponseUtil.successToClient(1);
}else{
adminOrderService.deleteAdminOrder(oId);
return ResponseUtil.successToClient(2);
}
}
//导出订单详情
@RequestMapping("outExcelOrder")
@ResponseBody
public void outExcelOrder(HttpServletResponse response,String oId){
SXSSFWorkbook workbook = new SXSSFWorkbook();
reportSheet(workbook,oId);
outputExcel(response, workbook, "订单详情");
}
private void reportSheet(SXSSFWorkbook workbook,String oId) {
List<DoExcelOrder> outExcelOrderDetail = adminOrderService.outExcelOrderDetail(oId);
for (int i = 0; i < outExcelOrderDetail.size(); i++) {
if(i!=0){
outExcelOrderDetail.get(i).setOId("");
outExcelOrderDetail.get(i).setOName("");
outExcelOrderDetail.get(i).setOPhone("");
outExcelOrderDetail.get(i).setOAddress("");
}
outExcelOrderDetail.get(i).setMoney(outExcelOrderDetail.get(i).getMoney()+"元");
}
ExcelUtil2 excelUtil=new ExcelUtil2();
List<JSONObject> columns = new ArrayList<>();
columns.add(excelUtil.defaultGetColumn("订单号", "oId", 15 * 256, false, false));
columns.add(excelUtil.defaultGetColumn("收货人", "oName", 15 * 256, false, false));
columns.add(excelUtil.defaultGetColumn("电话", "oPhone", 15 * 256, false, false));
columns.add(excelUtil.defaultGetColumn("地址", "oAddress", 26 * 256, false, false));
columns.add(excelUtil.defaultGetColumn("商品名", "sName", 15 * 256, false, false));
columns.add(excelUtil.defaultGetColumn("数量", "num", 12 * 256, false, false));
columns.add(excelUtil.defaultGetColumn("单价", "money", 12 * 256, false, false));
excelUtil.createSheet(workbook, outExcelOrderDetail, columns, "订单详情");
}
private void outputExcel(HttpServletResponse response, SXSSFWorkbook workbook, String excelName) {
response.setContentType("application/vnd.ms-excel");
try {
// 进行转码,使其支持中文文件名
response.setHeader("content-disposition", "attachment;filename=" + new String(excelName.getBytes("GB2312"), "ISO-8859-1") + ".xlsx");
workbook.write(response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
}
//请确认收货
@RequestMapping("userOrderConfirm")
@ResponseBody
public String userOrderConfirm(HttpServletRequest request,int id,int typeNum){
int eId;
if(typeNum==0){
eId = (int)request.getSession().getAttribute("adminId");
}else{
eId=0;
}
return ResponseUtil.successToClient(userService.upDateByorderConfirm(id,typeNum,eId));
}
}
如果也想学习本系统,下面领取。回复:199ssm