当前位置:网站首页>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 .
边栏推荐
- 最新汇总!30省份公布2022高考分数线
- async-validator.js数据校验器
- 高考失利進哈工大,畢業卻留校要當“探索者”,丁效:科研就是厚積薄發
- Continuous integration practice of Baidu app based on pipeline as code
- June 28, 2022 Daily: Lecun's latest paper: the road to autonomous machine intelligence
- manjaro easyconnecy报错:libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory
- 结构光之相移法+多频外差的数学原理推导
- UDP RTP packet frame loss
- ASP. NET CORE Study11
- 腾讯确认QQ大规模盗号,iPhone14无缘Type-C,第四大运营商5G正式放号,今日更多大新闻在此...
猜你喜欢
![[unity Editor Extension practice] dynamically generate UI code using TXT template](/img/20/1042829c3880039c528c63d0aa472d.png)
[unity Editor Extension practice] dynamically generate UI code using TXT template
![[MySQL from introduction to mastery] [advanced part] (III) creation of MySQL users_ Modification_ Delete and password settings](/img/9c/2a0eb8f5ec03aebbe231dbdb388eca.png)
[MySQL from introduction to mastery] [advanced part] (III) creation of MySQL users_ Modification_ Delete and password settings

最新汇总!30省份公布2022高考分数线

Fastposter v2.8.4 release e-commerce poster generator

一种跳板机的实现思路

易观分析《2022年中国银行业隐私计算平台供应商实力矩阵分析》研究报告正式启动

基础软件照搬开源不可取,自力更生才是正途

在线JSON转PlainText工具

高考失利進哈工大,畢業卻留校要當“探索者”,丁效:科研就是厚積薄發

ASP. NET CORE Study04
随机推荐
ASP. NET CORE Study03
ASP.NET CORE Study09
unity发布 webgl在手机端 inputfield唤醒键盘输入
Unity load settings: application backgroundLoadingPriority
ASP. NET CORE Study02
My NVIDIA developer tour -jetson nano 2GB teaches you how to train models (complete model training routines)
. Net hybrid development solution 24 webview2's superior advantages over cefsharp
ASP. NET CORE Study08
Can ArcGIS Pro directly connect PostgreSQL and edit layer elements
UDP RTP packet frame loss
《数字经济全景白皮书》消费金融数字化篇 重磅发布
async-validator.js數據校驗器
How to install SSL certificates in Microsoft Exchange 2010
What are the common modes of financial products in 2022?
杰理之wif 干扰蓝牙【篇】
杰理之wif 干扰蓝牙【篇】
group_ Concat learning and configuration
基础软件照搬开源不可取,自力更生才是正途
哪一个证券公司最好最安全 怎么办理开户最安全
VS2012 VC新建一个空白窗口应用