基于Springboot开发实现买卖三方二手商品交易网站

本文涉及的产品
云数据库 Redis 版,社区版 2GB
推荐场景:
搭建游戏排行榜
简介: 以SpringBoot为项目框架开发的二手交易网站,本商城系统分为三个角色,一个买家消费者,一个卖家商户,一个是平台管理员。买家登陆商城前端,可以在线分类浏览商品,添加购物车、在线购买、支付宝消箱支付扣款,维护个人信息,查看个人订单等功能。卖家登陆商城系统,可以在线发布商品,管理自己的订单等。管理员登陆商城系统,可以对买家和卖家进行管理操作,可以管理商品分类,管理商品信息,管理快递公司信息等。这种三方角色的商城系统包含买卖双方比较少见,比较适合做毕业设计系统使用。系统亮点:一是使用阿里云进行短信发送,二是基于阿里云实现云存储,三是使用支付宝沙箱实现在线支付功能,四是结合内网穿

项目编号:BS-SC-034

前言:

闲了就卖校园二手交易网使用springboot技术制作网站动态页面,使用IDEA为系统开发工具,数据存储采用现在比较流行的关系型数据库存MYSQL数据库系统来进行存储,开发一个类似于人咸鱼式的网站,实现个人闲置物品在网上进行自由交易。本论文主要研究的功能有:二手物品交易系统前台与二手物品交易系统后台,系统前台主要功能包含有:用户注册、用户登陆、浏览商品、商品在线信息查询、购物车、个人订单管理功能、个人中心、发布商品。二手物品交易系统系统的前台数据都在后台进行管理,其中主要的功能也就是有这么几个如下模块:二手物品商品类别管理、二手物品用户管理、二手物品新闻管理等相关数据模块的管理功能,实现一个基于B/S结构,由买卖双方组成的的个人闲置二手或新购物品交易网站。

定位于校园内部闲了就校园二手交易网,这个闲了就校园二手交易网主要利用互联网技术的相关技术,避免资源浪费,减少交易环节,提高交易效率,借助网络平台形式的展示窗口,让校园内的师生更习惯于接受我们所开发的个人闲置物品交易系统,并且打破传统市场购物的时间和空间局限性,大缩短校内老师和学生寻找商品和出售闲置物品的时间,同时系统的设计具有良好的人机交互性,从而实现二手闲置物品信息化、系统化和规范化。

一,项目简介

以SpringBoot为项目框架开发的二手交易网站,本商城系统分为三个角色,一个买家消费者,一个卖家商户,一个是平台管理员。

买家登陆商城前端,可以在线分类浏览商品,添加购物车、在线购买、支付宝消箱支付扣款,维护个人信息,查看个人订单等功能。

卖家登陆商城系统,可以在线发布商品,管理自己的订单等。

管理员登陆商城系统,可以对买家和卖家进行管理操作,可以管理商品分类,管理商品信息,管理快递公司信息等。

这种三方角色的商城系统包含买卖双方比较少见,比较适合做毕业设计系统使用。

系统亮点:

一是使用阿里云进行短信发送,

二是基于阿里云实现云存储,

三是使用支付宝沙箱实现在线支付功能,

四是结合内网穿透来实现支付宝支付结果的回调,

五是使用redis缓存数据库进行数据缓存处理。

系统功能完整 ,界面美观大方,是一个难得的优秀作品。

二,环境介绍

语言环境:Java:  jdk1.8

数据库:Mysql: mysql5.7+  Redis缓存数据库

应用服务器:Tomcat:  tomcat8.5.31

开发工具:IDEA或eclipse

后台开发:Springboot+mybatis

前端开发: bootstrap+jquery

三,系统展示

前端功能展示

image.gif编辑

商品详情

image.gif编辑

购物车下订单

image.gif编辑

结账支付

image.gif编辑

沙箱支付宝账户支付扣款

image.gif编辑

卖家登陆

image.gif编辑

image.gif编辑

商品管理

image.gif编辑

个人信息管理

image.gif编辑

订单管理

image.gif编辑

管理员登陆

image.gif编辑

image.gif编辑

用户管理

image.gif编辑

卖家管理

image.gif编辑

商品管理

image.gif编辑

分类管理

image.gif编辑

快递公司管理

image.gif编辑

四,核心代码展示

package com.jzh.xx.transaction.controller;
import com.jzh.xx.transaction.domain.*;
import com.jzh.xx.transaction.service.*;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("cart")
public class CartController {
    @Resource
    private CartService cartService;
    @Resource
    private CategoryService categoryService;
    @Resource
    private CategoryTwoService categoryTwoService;
    @Resource
    private ExpressService expressService;
    /**
     * 添加一件商品
     * @param sellerId
     * @param goodsId
     * @param session
     * @return
     */
    @PostMapping("goods/add")
    @ResponseBody
    public Map<String, Object> add(Long sellerId, Long goodsId,HttpSession session) {
        Map<String, Object> result = new HashMap<>();
        // 获取用户 ID
        XxUser user = (XxUser) session.getAttribute("user");
        if (user != null){
            int exit = 1;
            // 添加商品到购物车
            List<Cart> cartGoods = cartService.add(user.getId(), sellerId,goodsId );
            // 计算购物车总金额
            Double total = 0.0;
            for (int i = 0; i < cartGoods.size(); i++) {
                total += cartGoods.get(i).getBuyCount() * cartGoods.get(i).getGoodsPrice();
            }
            result.put("cartGoods", cartGoods);
            result.put("total", total);
            result.put("exit",exit);
            return result;
        } else {
            int exit = 2;
            result.put("exit",exit);
            return result;
        }
    }
    /**
     * 删除商品
     * @param goodsId
     * @param session
     * @return
     */
    @PostMapping("goods/delete")
    @ResponseBody
    public Map<String, Object> delete(Long goodsId , HttpSession session) {
        Map<String, Object> result = new HashMap<>();
        // 获取用户 ID
        XxUser user = (XxUser) session.getAttribute("user");
        // 添加商品到购物车
        List<Cart> cartGoods = cartService.delete(user.getId(),goodsId);
        // 计算购物车总金额
        Double total = 0.0;
        for (int i = 0; i < cartGoods.size(); i++) {
            total += cartGoods.get(i).getBuyCount() * cartGoods.get(i).getGoodsPrice();
        }
        result.put("cartGoods", cartGoods);
        result.put("total", total);
        return result;
    }
    /**
     * 遍历购物车清单
     * @param model
     * @param session
     * @return
     */
    @GetMapping("detail/{id}")
    public String toCart(@PathVariable Long id, Model model, HttpSession session){
        // 获取用户 ID
        XxUser user = (XxUser) session.getAttribute("user");
        // 购物车
        List<Cart> cartGoods = new ArrayList<>();
        if (user != null){
            cartGoods = cartService.getByUserId(id);
        }
        Double total = 0.0;
        int goodsCount = cartGoods.size();
        if (cartGoods.size() >0){
            for (int i = 0; i< cartGoods.size(); i++){
                total += cartGoods.get(i).getBuyCount() * cartGoods.get(i).getGoodsPrice();
            }
        }
        // 父分类
        List<Category> categories = categoryService.categoryList();
        // 查询所有子分类
        List<CategoryTwo> categoryTwos = categoryTwoService.getAll();
        //查询所有快递
        List<Express> expresses = expressService.getAll();
        model.addAttribute("goodsCount",goodsCount);
        model.addAttribute("cartGoods",cartGoods);
        model.addAttribute("total",total);
        model.addAttribute("categories",categories);
        model.addAttribute("categoryTwos",categoryTwos);
        model.addAttribute("expresses",expresses);
        return "frontCart";
    }
}

image.gif

package com.jzh.xx.transaction.controller;
import com.jzh.xx.transaction.domain.*;
import com.jzh.xx.transaction.dto.PageResult;
import com.jzh.xx.transaction.service.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
@Controller
@RequestMapping("frontCategory")
public class FrontCateController {
    @Resource
    private GoodsService goodsService;
    @Resource
    private CategoryService categoryService;
    @Resource
    private CategoryTwoService categoryTwoService;
    @Resource
    private CartService cartService;
    @Resource
    private FrontCateService frontCateService;
    @GetMapping
    public String toCategory(){
        return "cate_list";
    }
    /**
     * 商品分类信息页
     * @param id
     * @param model
     * @param pageNum
     * @param session
     * @return
     */
    @GetMapping("list/{id}")
    public String categoryList(@PathVariable Long id, Model model, @RequestParam(defaultValue = "1") int pageNum, HttpSession session){
        // 获取用户 ID
        XxUser user = (XxUser) session.getAttribute("user");
        // 购物车
        List<Cart> cartGoods = new ArrayList<>();
        if (user != null){
            cartGoods = cartService.getByUserId(user.getId());
        }
        Double total = 0.0;
        int goodsCount = cartGoods.size();
        if (cartGoods.size() >0){
            for (int i = 0; i< cartGoods.size(); i++){
                total += cartGoods.get(i).getBuyCount() * cartGoods.get(i).getGoodsPrice();
            }
        }
        // 父分类
        List<Category> categories = categoryService.categoryList();
        //该父分类
        Category category = categoryService.getById(id);
        //子分类名称
        List<CategoryTwo> categoryTwos = categoryTwoService.getAll();
        //分类商品
        PageResult<Goods> goodsPageResult = frontCateService.goodsPage(pageNum,id);
        model.addAttribute("goodsCount",goodsCount);
        model.addAttribute("cartGoods",cartGoods);
        model.addAttribute("total",total);
        model.addAttribute("categories",categories);
        model.addAttribute("category",category);
        model.addAttribute("categoryTwos",categoryTwos);
        model.addAttribute("goodsList",goodsPageResult);
        return "cate_list";
    }
    /**
     * 主页小标题商品信息页
     * @param jb_status
     * @param model
     * @param session
     * @return
     */
    @GetMapping("subheading/{jb_status}")
    public String subheading(@PathVariable Long jb_status, Model model, HttpSession session){
        // 获取用户 ID
        XxUser user = (XxUser) session.getAttribute("user");
        // 购物车
        List<Cart> cartGoods = new ArrayList<>();
        if (user != null){
            cartGoods = cartService.getByUserId(user.getId());
        }
        Double total = 0.0;
        int goodsCount = cartGoods.size();
        if (cartGoods.size() >0){
            for (int i = 0; i< cartGoods.size(); i++){
                total += cartGoods.get(i).getBuyCount() * cartGoods.get(i).getGoodsPrice();
            }
        }
        // 父分类
        List<Category> categories = categoryService.categoryList();
        // 查询所有子分类
        List<CategoryTwo> categoryTwos = categoryTwoService.getAll();
        //小标题商品
        List<Goods> subGoods = null;
        int subStatus = 0;
        int subsize = 0;
        if (jb_status == 2){
            subStatus = 2;
            subGoods = goodsService.showCheaper();
            subsize = subGoods.size();
        }else if (jb_status == 1){
            subStatus = 1;
            subGoods = goodsService.showChosen();
            subsize = subGoods.size();
        }
        model.addAttribute("goodsCount",goodsCount);
        model.addAttribute("cartGoods",cartGoods);
        model.addAttribute("total",total);
        model.addAttribute("categories",categories);
        model.addAttribute("categoryTwos",categoryTwos);
        model.addAttribute("subGoods",subGoods);
        model.addAttribute("subStatus",subStatus);
        model.addAttribute("subsize",subsize);
        return "subheading";
    }
}

image.gif

package com.jzh.xx.transaction.controller;
import com.jzh.xx.transaction.domain.*;
import com.jzh.xx.transaction.service.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;
@Controller
@RequestMapping("goods")
public class GoodsController {
    @Resource
    private GoodsService goodsService;
    @Resource
    private CategoryService categoryService;
    @Resource
    private SellerService sellerService;
    @Resource
    private CartService cartService;
    @Resource
    private CategoryTwoService categoryTwoService;
    /**
     * 商品详情
     * @param id
     * @param model
     * @return
     */
    @GetMapping("detail/{id}")
    public String toDetail(@PathVariable Long id, Model model, HttpSession session){
        // 获取用户 ID
        XxUser user = (XxUser) session.getAttribute("user");
        // 购物车
        List<Cart> cartGoods = new ArrayList<>();
        if (user != null){
            cartGoods = cartService.getByUserId(user.getId());
        }
        Double total = 0.0;
        int goodsCount = cartGoods.size();
        if (cartGoods.size() >0){
            for (int i = 0; i< cartGoods.size(); i++){
                total += cartGoods.get(i).getBuyCount() * cartGoods.get(i).getGoodsPrice();
            }
        }
        // 父分类
        List<Category> categories = categoryService.categoryList();
        // 查询所有子分类
        List<CategoryTwo> categoryTwos = categoryTwoService.getAll();
        //商品详情
        Goods goods = goodsService.detail(id);
        Long categoryId = goods.getCategoryId();
        Long sellerId = goods.getSellerId();
        Category category = categoryService.showCategory(categoryId);
        Seller seller = sellerService.seller(sellerId);
        model.addAttribute("goodsId",id);
        model.addAttribute("goodsCount",goodsCount);
        model.addAttribute("cartGoods",cartGoods);
        model.addAttribute("total",total);
        model.addAttribute("categories",categories);
        model.addAttribute("categoryTwos",categoryTwos);
        model.addAttribute("goods",goods);
        model.addAttribute("category",category);
        model.addAttribute("seller",seller);
        return "shop_single";
    }
}

image.gif

package com.jzh.xx.transaction.controller;
import com.jzh.xx.transaction.domain.XxUser;
import com.jzh.xx.transaction.service.OrderService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
@Controller
@RequestMapping("order")
public class OrderController {
    @Resource
    private OrderService orderService;
    /**
     * 生成订单
     */
    @PostMapping("create")
    @ResponseBody
    public Long create(Long expressId, HttpSession session) {
        // 从 session 中获取会员信息
        XxUser user = (XxUser) session.getAttribute("user");
        // 创建订单
        Long orderId = orderService.create(user.getId(), expressId);
        return orderId;
    }
}

image.gif

五,项目总结

IT和互联网技术的普及应用让很多电子商务网站系统向雨后春笋般快速发展起来,它打破了时间和空间上的限制,让人们原来仅仅局限一隅的购物方式发生了很的变化[1]。二手闲置物品的交易是现在各高校中校园文化的另一种体现,将自己不用的物品放在平台上进行交易,或了置换自己所需要的其它商品,即避免了资源的浪费,又提升了物品本身的价值应用空间。目前校内的二手闲置物品交易主要以线下和线上两种模块,线下就是常见的地摊经济,但占用个人的时间精力很大,很多人可能也没有时间去摆摊卖自己的二手物品,而且地域限制性极强。另外一种就是线上模式,目前主要以校内论坛为主的体现形式,这些平台的局限性非常大,并不能很好的促进闲置物品的交易和满足学生的交流需求,而基于网站的闲置物品信息交流的形式刚好能满足学生的要求。有了我们这个交易系统,二手物品的拥有者可以很方便的在平台上发布自己所拥有的物品信息,也可以在网上很方便的浏览别人的发布的闲置二手物品信息,并且可以在平台上对各种闲置二手物品进行相应的信息比较,选择自己中意的。

目前国内大部分的大学校园大都有自己的校园内网网站的信息化建,而大部分的高校也同时完成了自己网络工程的搭建,校园网的建成为学校的学生、老师、后勤部门等学校各方面人士提供了很多方便。现在随着普遍的相关的计算机的技术中的网络相关技术的应用,以及当代通信技术、DB技术的无法估计的发展,电子商务的也发展的非常迅速。而现在校园中大学生之间的网上交易的主要平台是校园论坛还有微博。论坛的主要功能是交流使用,它虽然使用的人很多,但是功能被限制在了交流使用,用户无法像其它的电子商务网站一样了解商品的更加详细的信息,比如图片、价格、相关的功能展示等等,更不能向电子商务网站一样快速的查询客户自己所需的相关商品,无法满足学生之间的快速交易的即时需要。

相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore &nbsp; &nbsp; ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库&nbsp;ECS 实例和一台目标数据库&nbsp;RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&amp;RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
相关文章
|
3月前
|
前端开发 JavaScript 算法
springboot+vue+mybatis-plus+axios实现商品的CRUD
springboot+vue+mybatis-plus+axios实现商品的CRUD
36 0
|
4月前
|
前端开发 JavaScript Java
SpringBoot+Vue(一)商品管理系统 模式介绍 、项目改造
SpringBoot+Vue(一)商品管理系统 模式介绍 、项目改造
69 0
|
9月前
|
安全 Java 数据安全/隐私保护
【Java项目】基于SpringBoot+Vue的校园二手商品交易平台(一)
【Java项目】基于SpringBoot+Vue的校园二手商品交易平台
87 0
|
4月前
|
缓存 Java 应用服务中间件
基于Springboot实现商品进销存管理系统
基于Springboot实现商品进销存管理系统
|
9月前
|
Java 数据库连接 数据安全/隐私保护
【Java项目】基于SpringBoot+Vue的校园二手商品交易平台(二)
【Java项目】基于SpringBoot+Vue的校园二手商品交易平台
78 0
|
9月前
|
搜索推荐 定位技术 vr&ar
Vue+SpringBoot打造超市商品管理系统(附源码文档)(二)
Vue+SpringBoot打造超市商品管理系统(附源码文档)
141 0
|
9月前
|
供应链 监控 JavaScript
Vue+SpringBoot打造超市商品管理系统(附源码文档)(一)
Vue+SpringBoot打造超市商品管理系统(附源码文档)
198 0
|
网络协议 前端开发 Java
SpringBoot+Netty开发IM即时通讯系列(一)
简单来讲,Netty是一个提供了易于使用的API的客户端/服务端框架。Netty并发非常高,一个非阻塞的IO,Netty传输速度也非常快,因为他是0拷贝,什么是零拷贝?NIO中的特性之一就是零拷贝,在Java中,内存分为堆和栈以及字符串常量值等等,如果有一些数据从IO中读取并且放到堆里面,中间会经过一些缓冲区。
939 0
SpringBoot+Netty开发IM即时通讯系列(一)
|
11月前
|
NoSQL 安全 Java
springboot 整合redis | 乐观锁实现商品秒杀
这是redis整合springboot在单人单机的场景下进行模拟的秒杀业务,通过乐观锁的方式实现. 供大家参考学习
110 0
|
缓存 NoSQL 前端开发
基于Springboot实现商品进销存管理系统
基于Springboot实现商品进销存管理系统
219 0
基于Springboot实现商品进销存管理系统