伴随着网购的盛行,大学生的消费能力和意识发生了较大的转变。超前的的消费观和落后的交易能力造成产品愈来愈多。另一方面,在校大学生对物件买卖有一定的要求。对于这一环境,搭建一个面对当代大学生的校园内、校间文章内容交易网站,可以合理处理大花园的内容问题。
本新项目根据Web,选用面向对象编程的观念,应用SSM架构,挑选Java这类十分时髦的Web应用程序开发语言表达。最先,对高校书籍資源和书籍平台交易的利用状况实现了调研分析。次之,科学研究了当今的java技术,明确提出了根据小程序的高校书籍交易平台的研发计划方案,选用Spring MyBatis架构技术性和MySQL数据库管理方法数据信息。再度,利用UML建模技术性系统对实现了需求分析、功能分析和类设计方案。最后完成了一个功能完善的高校用品平台交易。通过测试步骤,高校书籍交易平台既能防止买东西产生的新冠疫情冲击性,又能高效率利用資源,合乎当今可持续发展观的规定。
此次设计从系统需求分析、系统设计到系统编程和调试测试等过程,综合锻炼了自身对一个系统的设计与开发的能力。本文的工作为更为复杂的线上购书系统的建设打下了基础,完成了线上购书的基本流程,达到所需的功能性要求。
关键词:SSM框架;线上购书;MYSQL
【525】基于ssm校园书城系统源码和论文含代码讲解视频
Abstract
With the rise of online shopping, the consumption level and concept of contemporary college students have changed greatly. The advanced consumption concept and lagging consumption ability lead to more and more goods. On the other hand, college students have a certain demand for goods trading. In view of this background, building a goods trading website dedicated to college students in and between colleges and universities can effectively solve the problem of college campus goods.
Based on the web side, this project adopts the object-oriented idea, uses the SSM framework, and selects the very popular web application development language Java. Firstly, it investigates and analyzes the utilization of College Students' goods resources and goods trading platform; Secondly, it studies the current software development technology, and puts forward the development scheme of University goods trading platform based on wechat applet, which is developed by spring + mybatis framework technology and managed by MySQL database; Thirdly, UML modeling technology is used to analyze the requirements, function design and class design of the system; Finally, a college goods trading platform with campus division, goods search, release idle, release dynamic, idle transaction, face-to-face transaction, location selection, contact buyers and contact customer service is realized. After testing and operation, the University goods trading platform can not only avoid the epidemic impact caused by shopping, but also improve the utilization efficiency of resources, which meets the requirements of the general trend of contemporary sustainable development.
The design from system requirements analysis, system design to system programming, debugging and testing, comprehensively exercises its ability to design and develop a system. The work of this paper lays a foundation for the construction of more complex online shopping system, completes the basic process of online shopping and meets the required functional requirements.
Key words:Online goods purchasing; SSM framework; MYSQL
package com.shop.controller;
import com.alibaba.fastjson.JSONObject;
import com.shop.base.BaseController;
import com.shop.pojo.*;
import com.shop.service.*;
import com.shop.utils.Consts;
import com.shop.utils.Pager;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 订单管理
*/
@Controller
@RequestMapping("/itemOrder")
public class ItemOrderController extends BaseController {
@Autowired
private ItemOrderService itemOrderService;
@Autowired
private UserService userService;
@Autowired
private CarService carService;
@Autowired
private OrderDetailService orderDetailService;
@Autowired
private ItemService itemService;
/**
* 订单管理列表
*/
@RequestMapping("/findBySql")
public String findBySql(ItemOrder itemOrder, Model model){
//分页查询
String sql = "select * from item_order where 1=1 ";
if(!(isEmpty(itemOrder.getCode()))){
sql +=" and code like '%"+itemOrder.getCode()+"%' ";
}
sql += " order by id desc";
Pager<ItemOrder> pagers = itemOrderService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers",pagers);
//存储查询条件
model.addAttribute("obj",itemOrder);
return "itemOrder/itemOrder";
}
@RequestMapping("/delete")
public String delete(Integer id){
itemOrderService.deleteById(id);
return "redirect:/itemOrder/findBySql";
}
/**
* 我的订单
*/
@RequestMapping("/my")
public String my(Model model, HttpServletRequest request){
Object attribute = request.getSession().getAttribute(Consts.USERID);
if(attribute==null){
return "redirect:/login/uLogin";
}
Integer userId = Integer.valueOf(attribute.toString());
//全部订单
String sql = "select * from item_order where user_id="+userId+" order by id desc";
List<ItemOrder> all = itemOrderService.listBySqlReturnEntity(sql);
//待发货
String sql2 = "select * from item_order where user_id="+userId+" and status=0 order by id desc";
List<ItemOrder> dfh = itemOrderService.listBySqlReturnEntity(sql2);
//已取消
String sql3 = "select * from item_order where user_id="+userId+" and status=1 order by id desc";
List<ItemOrder> yqx = itemOrderService.listBySqlReturnEntity(sql3);
//已发货
String sql4 = "select * from item_order where user_id="+userId+" and status=2 order by id desc";
List<ItemOrder> dsh = itemOrderService.listBySqlReturnEntity(sql4);
//已收货
String sql5 = "select * from item_order where user_id="+userId+" and status=3 order by id desc";
List<ItemOrder> ysh = itemOrderService.listBySqlReturnEntity(sql5);
model.addAttribute("all",all);
model.addAttribute("dfh",dfh);
model.addAttribute("yqx",yqx);
model.addAttribute("dsh",dsh);
model.addAttribute("ysh",ysh);
return "itemOrder/my";
}
/**
* 购物车结算提交
*/
@RequestMapping("/exAdd")
@ResponseBody
public String exAdd(@RequestBody List<CarDto> list,HttpServletRequest request){
Object attribute = request.getSession().getAttribute(Consts.USERID);
JSONObject js = new JSONObject();
if(attribute==null){
js.put(Consts.RES,0);
return js.toJSONString();
}
Integer userId = Integer.valueOf(attribute.toString());
User byId = userService.getById(userId);
if(StringUtils.isEmpty(byId.getAddress())){
js.put(Consts.RES,2);
return js.toJSONString();
}
List<Integer> ids = new ArrayList<>();
BigDecimal to = new BigDecimal(0);
for(CarDto c:list){
ids.add(c.getId());
Car load = carService.load(c.getId());
to = to.add(new BigDecimal(load.getPrice()).multiply(new BigDecimal(c.getNum())));
}
ItemOrder order = new ItemOrder();
order.setStatus(0);
order.setCode(getOrderNo());
order.setIsDelete(0);
order.setTotal(to.setScale(2,BigDecimal.ROUND_HALF_UP).toString());
order.setUserId(userId);
order.setAddTime(new Date());
itemOrderService.insert(order);
//订单详情放入orderDetail,删除购物车
if(!CollectionUtils.isEmpty(ids)){
for(CarDto c:list){
Car load = carService.load(c.getId());
OrderDetail de = new OrderDetail();
de.setItemId(load.getItemId());
de.setOrderId(order.getId());
de.setStatus(0);
de.setNum(c.getNum());
de.setTotal(String.valueOf(c.getNum()*load.getPrice()));
orderDetailService.insert(de);
//修改成交数
Item load2 = itemService.load(load.getItemId());
load2.setGmNum(load2.getGmNum()+c.getNum());
itemService.updateById(load2);
//删除购物车
carService.deleteById(c.getId());
}
}
js.put(Consts.RES,1);
return js.toJSONString();
}
private static String date;
private static long orderNum = 0L;
public static synchronized String getOrderNo(){
String str = new SimpleDateFormat("yyyyMMddHHmm").format(new Date());
if(date==null||!date.equals(str)){
date = str;
orderNum = 0L;
}
orderNum++;
long orderNO = Long.parseLong(date)*10000;
orderNO += orderNum;
return orderNO+"";
}
/**
* 取消订单
*/
@RequestMapping("/qx")
public String qx(Integer id,Model model){
ItemOrder obj =itemOrderService.load(id);
obj.setStatus(1);
itemOrderService.updateById(obj);
model.addAttribute("obj",obj);
return "redirect:/itemOrder/my";
}
/**
* 后台发货
*/
@RequestMapping("/fh")
public String fh(Integer id,Model model){
ItemOrder obj =itemOrderService.load(id);
obj.setStatus(2);
itemOrderService.updateById(obj);
model.addAttribute("obj",obj);
return "redirect:/itemOrder/findBySql";
}
/**
* 用户收货
*/
@RequestMapping("/sh")
public String sh(Integer id,Model model){
ItemOrder obj =itemOrderService.load(id);
obj.setStatus(3);
itemOrderService.updateById(obj);
model.addAttribute("obj",obj);
return "redirect:/itemOrder/my";
}
/**
* 用户评价入口
*/
@RequestMapping("/pj")
public String pj(Integer id,Model model){
model.addAttribute("id",id);
return "itemOrder/pj";
}
}
package com.shop.controller;
import com.alibaba.fastjson.JSONObject;
import com.shop.base.BaseController;
import com.shop.pojo.*;
import com.shop.service.ItemCategoryService;
import com.shop.service.ItemService;
import com.shop.service.ManageService;
import com.shop.service.UserService;
import com.shop.utils.Consts;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
/**
* 登录相关的控制器
*/
@Controller
@RequestMapping("/login")
public class LoginController extends BaseController {
@Autowired
private ManageService manageService;
@Autowired
private ItemCategoryService itemCategoryService;
@Autowired
private ItemService itemService;
@Autowired
private UserService userService;
/**
* 管理员登录前
* @return
*/
@RequestMapping("login")
public String login(){
return "/login/mLogin";
}
/**
* 登录验证
* @return
*/
@RequestMapping("toLogin")
public String toLogin(Manage manage, HttpServletRequest request){
Manage byEntity = manageService.getByEntity(manage);
if(byEntity==null){
return "redirect:/login/mtuichu";
}
request.getSession().setAttribute(Consts.MANAGE,byEntity);
return "/login/mIndex";
}
/**
* 管理员退出
*/
@RequestMapping("mtuichu")
public String mtuichu(HttpServletRequest request){
request.getSession().setAttribute(Consts.MANAGE,null);
return "/login/mLogin";
}
/**
* 前端首页
*/
@RequestMapping("/uIndex")
public String uIndex(Model model, Item item,HttpServletRequest request){
String sql1 = "select * from item_category where isDelete=0 and pid is null order by name";
List<ItemCategory> fatherList = itemCategoryService.listBySqlReturnEntity(sql1);
List<CategoryDto> list = new ArrayList<>();
if(!CollectionUtils.isEmpty(fatherList)){
for(ItemCategory ic:fatherList){
CategoryDto dto = new CategoryDto();
dto.setFather(ic);
//查询二级类目
String sql2 = "select * from item_category where isDelete=0 and pid="+ic.getId();
List<ItemCategory> childrens = itemCategoryService.listBySqlReturnEntity(sql2);
dto.setChildrens(childrens);
list.add(dto);
model.addAttribute("lbs",list);
}
}
//折扣书籍
// List<Item> zks = itemService.listBySqlReturnEntity("select * from item where isDelete=0 and zk is not null order by zk desc limit 0,10");
// model.addAttribute("zks",zks);
//热销书籍
List<Item> rxs = itemService.listBySqlReturnEntity("select * from item where isDelete=0 order by gmNum desc limit 0,10");
model.addAttribute("rxs",rxs);
model.addAttribute("numtype", 1);
model.addAttribute("pricetype", 1);
model.addAttribute("zktype", 1);
return "login/uIndex";
}
/**普通用户注册*/
@RequestMapping("/res")
public String res(){
return "login/res";
}
/**执行普通用户注册*/
@RequestMapping("/toRes")
public String toRes(User u){
userService.insert(u);
return "login/uLogin";
}
/**普通用户登录入口*/
@RequestMapping("/uLogin")
public String uLogin(){
return "login/uLogin";
}
/**执行普通用户登录*/
@RequestMapping("/utoLogin")
public String utoLogin(User u,HttpServletRequest request){
User byEntity = userService.getByEntity(u);
if(byEntity==null){
return "redirect:/login/res.action";
}else {
request.getSession().setAttribute("role",2);
request.getSession().setAttribute(Consts.USERNAME,byEntity.getUserName());
request.getSession().setAttribute(Consts.USERID,byEntity.getId());
return "redirect:/login/uIndex.action";
}
}
/**前端用户退出*/
@RequestMapping("/uTui")
public String uTui(HttpServletRequest request){
HttpSession session = request.getSession();
session.invalidate();
return "redirect:/login/uIndex.action";
}
/**
* 修改密码入口
*/
@RequestMapping("/pass")
public String pass(HttpServletRequest request){
Object attribute = request.getSession().getAttribute(Consts.USERID);
if(attribute==null){
return "redirect:/login/uLogin";
}
Integer userId = Integer.valueOf(attribute.toString());
User load = userService.load(userId);
request.setAttribute("obj",load);
return "login/pass";
}
/**
* 修改密码操作
*/
@RequestMapping("/upass")
@ResponseBody
public String upass(String password,HttpServletRequest request){
Object attribute = request.getSession().getAttribute(Consts.USERID);
JSONObject js = new JSONObject();
if(attribute==null){
js.put(Consts.RES,0);
return js.toString();
}
Integer userId = Integer.valueOf(attribute.toString());
User load = userService.load(userId);
load.setPassWord(password);
userService.updateById(load);
js.put(Consts.RES,1);
return js.toString();
}
}