当前位置:网站首页>Implementation of fruit and vegetable mall management system based on SSM
Implementation of fruit and vegetable mall management system based on SSM
2022-06-28 12:52:00 【Programming compass】
Author URI : Programming compass
Author's brief introduction :Java Quality creators in the field 、CSDN Blogger 、 Nuggets guest author 、 Years of architect design experience 、 Tencent classroom resident lecturer
primary coverage :Java project 、 Graduation project 、 The resume template 、 Learning materials 、 Interview question bank 、 Technical assistance
Get the source code at the end of the article
One , Project brief introduction
The development and implementation of this project is based on SSM Box , Completed an online shopping mall sales management system which is mainly used to sell fruits and vegetables . Front end users of the system can register and log in 、 Browse products online 、 Add shopping cart online 、 Buy online 、 Full text search 、 Check out the shopping cart 、 Online collection 、 View individual orders 、 Modify personal information, etc . Background management users can manage commodity classification 、 Commodity information 、 Order information 、 User information 、 Message message 、 Announcement information and other relevant data . Complete business functions , The page is simple and generous .
Two , Introduction to the environment
Language environment :Java: jdk1.8
database :Mysql: mysql5.7
application server :Tomcat: tomcat8.5.31
development tool :IDEA or eclipse
3、 ... and , System display
home page

Product browsing

Add cart

Personal center

Merchandise collection

Add cart

Personal center

Merchandise collection

My order

Background management

Category management

User management

Commodity management

Order management

Announcement management

message management

Four , Core code display
package com.javapandeng.controller;
import com.alibaba.fastjson.JSONObject;
import com.javapandeng.po.Car;
import com.javapandeng.po.Item;
import com.javapandeng.service.CarService;
import com.javapandeng.service.ItemService;
import com.javapandeng.utils.Consts;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
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.math.RoundingMode;
import java.util.List;
/**
* The shopping cart
*/
@Controller
@RequestMapping("/car")
public class CarController {
@Autowired
private CarService carService;
@Autowired
private ItemService itemService;
@RequestMapping("/exAdd")
@ResponseBody
public String exAdd(Car car, HttpServletRequest request){
JSONObject js = new JSONObject();
Object attribute = request.getSession().getAttribute(Consts.ID);
if(attribute==null){
js.put(Consts.RES,0);
return js.toJSONString();
}
// Save to shopping cart
Integer userId = Integer.valueOf(attribute.toString());
car.setUserId(userId);
Item item = itemService.load(car.getItemId());
String price = item.getPrice();
Double valueOf = Double.valueOf(price);
car.setPrice(valueOf);
if(item.getZk()!=null){
valueOf = valueOf*item.getZk()/10;
BigDecimal bg = new BigDecimal(valueOf).setScale(2, RoundingMode.UP);
car.setPrice(bg.doubleValue());
valueOf = bg.doubleValue();
}
Integer num = car.getNum();
Double t = valueOf*num;
BigDecimal bg = new BigDecimal(t).setScale(2, RoundingMode.UP);
double doubleValue = bg.doubleValue();
car.setTotal(doubleValue+"");
carService.insert(car);
js.put(Consts.RES,1);
return js.toJSONString();
}
/**
* Go to my cart page
*/
@RequestMapping("/findBySql")
public String findBySql(Model model, HttpServletRequest request){
Object attribute = request.getSession().getAttribute(Consts.ID);
if(attribute==null){
return "redirect:/login/toLogin";
}
Integer userId = Integer.valueOf(attribute.toString());
String sql = "select * from car where user_id="+userId+" order by id desc";
List<Car> list = carService.listBySqlReturnEntity(sql);
model.addAttribute("list",list);
return "car/car";
}
/**
* Delete shopping cart
*/
@RequestMapping("/delete")
@ResponseBody
public String delete(Integer id){
carService.deleteById(id);
return "success";
}
}
package com.javapandeng.controller;
import com.javapandeng.base.BaseController;
import com.javapandeng.po.Comment;
import com.javapandeng.service.CommentService;
import com.javapandeng.utils.Consts;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
/**
* Comment on
*/
@Controller
@RequestMapping("/comment")
public class CommentController extends BaseController {
@Autowired
private CommentService commentService;
/**
* Add execution
*/
@RequestMapping("/exAdd")
public String exAdd(Comment comment, HttpServletRequest request){
Object attribute = request.getSession().getAttribute(Consts.ID);
if(attribute==null){
return "redirect:/login/toLogin";
}
Integer userId = Integer.valueOf(attribute.toString());
comment.setAddTime(new Date());
comment.setUserId(userId);
commentService.insert(comment);
return "redirect:/itemOrder/myOrder.action";
}
}
package com.javapandeng.controller;
import com.javapandeng.base.BaseController;
import com.javapandeng.po.User;
import com.javapandeng.service.UserService;
import com.javapandeng.utils.Consts;
import com.javapandeng.utils.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.persistence.criteria.CriteriaBuilder;
import javax.servlet.http.HttpServletRequest;
@Controller
@RequestMapping("/user")
public class UserController extends BaseController {
@Autowired
private UserService userService;
/**
* Paging query users
* @param model
* @param user
* @return
*/
@RequestMapping("findBySql")
public String findBySql(Model model, User user){
String sql="select * from user where 1=1 ";
if(!isEmpty(user.getUserName())){
sql+=" and userName like '%"+user.getUserName()+"%' ";
}
sql+=" order by id";
Pager<User> pagers= userService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers",pagers);
model.addAttribute("obj", user);
return "user/user";
}
/**
* Delete user
* @return
*/
@RequestMapping("delete")
public String delete(Integer id){
userService.deleteById(id);
return "redirect:/user/findBySql.action";
}
/**
* Jump to the personal center page , See user information
* @return
*/
@RequestMapping("view")
public String view(Model model, HttpServletRequest request){
Object session =request.getSession().getAttribute(Consts.ID);
if(session==null){
return "redirect:/login/uLogin.action";
}
Integer userId=Integer.valueOf(session.toString());
User byId = userService.getById(userId);
model.addAttribute("obj",byId);
return "user/view";
}
/**
* Jump to the personal center page , See user information
* @return
*/
@RequestMapping("exUpdate")
public String exUpdate(User user,HttpServletRequest request){
Object session =request.getSession().getAttribute(Consts.ID);
if(session==null){
return "redirect:/login/uLogin.action";
}
user.setId(Integer.valueOf(session.toString()));
userService.updateById(user);
return "redirect:/user/view.action";
}
}
package com.javapandeng.controller;
import com.alibaba.fastjson.JSONObject;
import com.javapandeng.base.BaseController;
import com.javapandeng.po.*;
import com.javapandeng.service.*;
import com.javapandeng.utils.Consts;
import com.javapandeng.utils.Pager;
import jdk.nashorn.internal.ir.RuntimeNode;
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;
/*
View all orders in the administrator interface
*/
@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";
}
/*
User personal interface to view all orders
*/
@RequestMapping("myOrder")
public String myOrder (HttpServletRequest request, Model model){
Object attribute = request.getSession().getAttribute(Consts.ID);
if(attribute==null){
return "redirect:/login/uLogin";
}
Integer userId= Integer.valueOf(attribute.toString());
// All orders
String sql = "select * from item_order where user_id="+userId+" order by id desc";
List<ItemOrder> all = itemOrderService.listBySqlReturnEntity(sql);
// To be delivered
String sql2 = "select * from item_order where user_id="+userId+" and status=0 order by id desc";
List<ItemOrder> dfh = itemOrderService.listBySqlReturnEntity(sql2);
// Cancelled
String sql3 = "select * from item_order where user_id="+userId+" and status=1 order by id desc";
List<ItemOrder> yqx = itemOrderService.listBySqlReturnEntity(sql3);
// Shipped
String sql4 = "select * from item_order where user_id="+userId+" and status=2 order by id desc";
List<ItemOrder> dsh = itemOrderService.listBySqlReturnEntity(sql4);
// Received goods
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/myOrder";
}
/**
* Shopping cart settlement submission
*/
@RequestMapping("/exAdd")
@ResponseBody
public String exAdd(@RequestBody List<CarDto> list, HttpServletRequest request){
Object attribute = request.getSession().getAttribute(Consts.ID);
JSONObject js = new JSONObject();
if(attribute==null){
js.put(Consts.RES,0);//res=0, On the front page ajax You need to log in
return js.toJSONString();
}
Integer userId = Integer.valueOf(attribute.toString());
User byId = userService.getById(userId);
if(StringUtils.isEmpty(byId.getAddress())){
js.put(Consts.RES,2);//res=2, On the front page ajax You need an address
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);
// Order details are placed in orderDetail, Delete shopping cart
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);
// Number of modified transactions
Item load2 = itemService.load(load.getItemId());
load2.setGmNum(load2.getGmNum()+c.getNum());
itemService.updateById(load2);
// Delete shopping cart
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+"";
}
/**
* Cancellation of order
*/
@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/myOrder";
}
/**
* Back office delivery
*/
@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";
}
/**
* Customer receiving
*/
@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/myOrder";
}
/**
* User evaluation portal
*/
@RequestMapping("/pj")
public String pj(Integer id,Model model){
model.addAttribute("id",id);
return "itemOrder/pj";
}
}
package com.javapandeng.controller;
import com.javapandeng.base.BaseController;
import com.javapandeng.po.News;
import com.javapandeng.service.NewsService;
import com.javapandeng.utils.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Date;
@Controller
@RequestMapping("/news")
public class NewsController extends BaseController {
@Autowired
NewsService newsService;
@RequestMapping("findBySql")
public String findBySql(News news, Model model){
String sql="select * from news where 1=1 ";
if(!isEmpty(news.getName())){
sql+=" and name like '%"+news.getName()+"%'";
}
sql+="order by id desc";
Pager<News> pagers= newsService.findBySqlRerturnEntity(sql);
model.addAttribute("pagers",pagers);
model.addAttribute("obj", news);
return "news/news";
}
/**
* Jump to the add announcement page
*/
@RequestMapping("add")
public String add(){
return "news/add";
}
/**
* Add announcement
*/
@RequestMapping("exAdd")
public String exAdd(News news){
news.setAddTime(new Date());
newsService.insert(news);
return "redirect:/news/findBySql.antion";
}
/**
* Skip to the modify announcement page
* @return
*/
@RequestMapping("update")
public String update(Integer id,Model model){
News news=newsService.getById(id);
System.out.println(news);
model.addAttribute("obj",news);
return "news/update";
}
/**
* Modify the announcement and save
* @return
*/
@RequestMapping("exUpdate")
public String exUpdate(News news){
newsService.updateById(news);
return "redirect:/news/findBySql.action";
}
/**
* Delete announcement
* @return
*/
@RequestMapping("delete")
public String delete(Integer id){
newsService.deleteById(id);
return "redirect:/news/findBySql.action";
}
/**
* Front end announcement list
*/
@RequestMapping("/list")
public String list(Model model){
Pager<News> pagers = newsService.findByEntity(new News());
model.addAttribute("pagers",pagers);
return "news/list";
}
/**
* Announcement details page
*/
@RequestMapping("/view")
public String view(Integer id,Model model){
News obj = newsService.load(id);
model.addAttribute("obj",obj);
return "news/view";
}
}
5、 ... and , Project summary
The development and implementation of this project is based on SSM Box , Completed an online shopping mall sales management system which is mainly used to sell fruits and vegetables . Front end users of the system can register and log in 、 Browse products online 、 Add shopping cart online 、 Buy online 、 Full text search 、 Check out the shopping cart 、 Online collection 、 View individual orders 、 Modify personal information, etc . Background management users can manage commodity classification 、 Commodity information 、 Order information 、 User information 、 Message message 、 Announcement information and other relevant data . Complete business functions , The page is simple and generous .
边栏推荐
- 腾讯确认QQ大规模盗号,iPhone14无缘Type-C,第四大运营商5G正式放号,今日更多大新闻在此...
- The Research Report of Analysys' 2022 China Banking privacy computing platform supplier strength matrix analysis' was officially launched
- centos6.5 php+mysql mysql库找不到
- K3s one click installation script
- 【云原生】自助报表和BI能做这么多事?
- arcgis pro 可以实现直连postgresql,编辑图层要素吗
- 基于SSM实现水果蔬菜商城管理系统
- Jerry's wif interferes with Bluetooth [chapter]
- ASP. NET CORE Study03
- 【MySQL从入门到精通】【高级篇】(三)MySQL用户的创建_修改_删除以及密码的设置
猜你喜欢

Watermaker of the Flink core

分页样式 flex设置成在尾部显示(即使页数加长 也不会因为在末尾而换行)

Online JSON to plaintext tool

Login interface accesses and clears the token

Flink流处理API大合集:掌握所有flink流处理技术,看这一篇就够了

Ipetronik data acquisition equipment and softing q-vision software are committed to ADAS test scheme

From simplekv to redis

ASP.NET CORE Study09

ASP.NET CORE Study05

go template with...end遍历用法
随机推荐
The paging style flex is set to be displayed at the end (even if the number of pages is longer, there will be no line breaks at the end)
一文搞懂leveldb写操作
ASP. NET CORE Study03
Understand leveldb write operation
Ipetronik data acquisition equipment and softing q-vision software are committed to ADAS test scheme
【历史上的今天】6 月 28 日:马斯克诞生;微软推出 Office 365;蔡氏电路的发明者出生
Which securities company is the best and safest? How to open an account is the safest
After importing resources, unity also manually modifies the properties of resources? This code can save you a lot of time: assetpostprocessor
Continuous integration practice of Baidu app based on pipeline as code
Jerry's wif interferes with Bluetooth [chapter]
My NVIDIA developer tour -jetson nano 2GB teaches you how to train models (complete model training routines)
JS class 并不只是简单的语法糖!
Ugui force refresh of layout components
K3s one click installation script
2022-06-28日报:LeCun最新论文:通往自主机器智能的道路
数字孪生能源系统,打造低碳时代“透视”眼
Flink stream processing API collection: master all Flink stream processing technologies. Just read this article
From jsonpath and XPath to spl
Tips for using ugui (V) using scroll rect component
杰理之wif 干扰蓝牙【篇】