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

作者主页:编程千纸鹤

作者简介:Java、前端、Pythone开发多年,做过高程,项目经理,架构师

主要内容:Java项目开发、毕业设计开发、面试技术整理、最新技术分享

项目编号: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

三,系统展示

前端功能展示

 

商品详情

购物车下订单

结账支付

沙箱支付宝账户支付扣款

卖家登陆

商品管理

个人信息管理

订单管理

管理员登陆

用户管理

卖家管理

商品管理

分类管理

快递公司管理

四,核心代码展示

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";
    }


}
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";
    }
}
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";
    }
}
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;
    }
}

五,项目总结

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

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

  • 6
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

编程千纸鹤

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值