欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Java女装商城系统的实现流程

程序员文章站 2022-06-26 16:08:30
一、项目简述功能javaweb 网上商城系统,前台+后台管理,用户注册,登录,上哦展示,分组展示,搜索,收货地址管理,购物车管理,添加,购买,个人信息修改。订单查询等等,后台商品管理,分类管理,库存管...

一、项目简述功能

javaweb 网上商城系统,前台+后台管理,用户注册,登录,上哦展示,分组展示,搜索,收货地址管理,购物车管理,添加,购买,个人信息修改。订单查询等等,后台商品管理,分类管理,库存管理,订单管理,用户管理,信息修改等等.

二、项目运行

环境配置: jdk1.8 + tomcats . 5 + mysql + eclispe ( intellij idea ,eclispe , myeclispe , sts 都支持)

项目技术: jsp + spring + springmvc + mybatis + html + css + javascript + jquery + ajax + layui + maven 等等。

Java女装商城系统的实现流程

Java女装商城系统的实现流程

Java女装商城系统的实现流程

Java女装商城系统的实现流程

Java女装商城系统的实现流程

后台管理平台登录代码:

/**
 * 后台管理-主页
 */
@controller
public class adminhomecontroller extends basecontroller {
    @resource(name = "adminservice")
    private adminservice adminservice;
    @resource(name = "productorderservice")
    private productorderservice productorderservice;
    @resource(name = "productservice")
    private productservice productservice;
    @resource(name = "userservice")
    private userservice userservice;
 
    /**
     * 转到后台管理-主页
     * @param session session对象
     * @param map 前台传入的map
     * @return 响应数据
     * @throws parseexception 转换异常
     */
    @requestmapping(value = "admin", method = requestmethod.get)
    public string gotopage(httpsession session, map<string, object> map) throws parseexception {
        logger.info("获取管理员信息");
        object adminid = checkadmin(session);
        if (adminid == null) {
            return "redirect:/admin/login";
        }
        admin admin = adminservice.get(null, integer.parseint(adminid.tostring()));
        map.put("admin", admin);
        logger.info("获取统计信息");
        //产品总数
        integer producttotal = productservice.gettotal(null, new byte[]{0, 2});
        //用户总数
        integer usertotal = userservice.gettotal(null);
        //订单总数
        integer ordertotal = productorderservice.gettotal(null, new byte[]{3});
        logger.info("获取图表信息");
        map.put("jsonobject", getchartdata(null,null,7));
        map.put("producttotal", producttotal);
        map.put("usertotal", usertotal);
        map.put("ordertotal", ordertotal);
 
        logger.info("转到后台管理-主页");
        return "admin/homepage";
    }
 
    /**
     * 转到后台管理-主页(ajax方式)
     * @param session session对象
     * @param map 前台传入的map
     * @return 响应数据
     * @throws parseexception 转换异常
     */
    @requestmapping(value = "admin/home", method = requestmethod.get)
    public string gotopagebyajax(httpsession session, map<string, object> map) throws parseexception {
        logger.info("获取管理员信息");
        object adminid = checkadmin(session);
        if (adminid == null) {
            return "admin/include/loginmessage";
        }
        admin admin = adminservice.get(null, integer.parseint(adminid.tostring()));
        map.put("admin", admin);
        logger.info("获取统计信息");
        integer producttotal = productservice.gettotal(null, new byte[]{0, 2});
        integer usertotal = userservice.gettotal(null);
        integer ordertotal = productorderservice.gettotal(null, new byte[]{3});
        logger.info("获取图表信息");
        map.put("jsonobject", getchartdata(null, null,7));
        logger.info("获取图表信息");
        map.put("jsonobject", getchartdata(null,null,7));
        map.put("producttotal", producttotal);
        map.put("usertotal", usertotal);
        map.put("ordertotal", ordertotal);
        logger.info("转到后台管理-主页-ajax方式");
        return "admin/homemanagepage";
    }
 
    /**
     * 按日期查询图表数据(ajax方式)
     * @param begindate 开始日期
     * @param enddate 结束日期
     * @return 响应数据
     * @throws parseexception 转换异常
     */
    @responsebody
    @requestmapping(value = "admin/home/charts", method = requestmethod.get, produces = "application/json;charset=utf-8")
    public string getchartdatabydate(@requestparam(required = false) string begindate, @requestparam(required = false) string enddate) throws parseexception {
        if (begindate != null && enddate != null) {
            //转换日期格式
            simpledateformat simpledateformat = new simpledateformat("yyyy-mm-dd");
            return getchartdata(simpledateformat.parse(begindate), simpledateformat.parse(enddate),7).tojsonstring();
        } else {
            return getchartdata(null, null,7).tojsonstring();
        }
    }
 
    /**
     * 按日期获取图表数据
     * @param begindate 开始日期
     * @param enddate 结束日期
     * @param days 天数
     * @return 图表数据的json对象
     * @throws parseexception 转换异常
     */
    private jsonobject getchartdata(date begindate,date enddate,int days) throws parseexception {
        jsonobject jsonobject = new jsonobject();
        simpledateformat time = new simpledateformat("yyyy-mm-dd", locale.uk);
        simpledateformat time2 = new simpledateformat("mm/dd", locale.uk);
        simpledateformat timespecial = new simpledateformat("yyyy-mm-dd hh:mm:ss", locale.uk);
        //如果没有指定开始和结束日期
        if (begindate == null || enddate == null) {
            //指定一周前的日期为开始日期
            calendar cal = calendar.getinstance();
            cal.add(calendar.date, 1-days);
            begindate = time.parse(time.format(cal.gettime()));
            //指定当前日期为结束日期
            cal = calendar.getinstance();
            enddate = cal.gettime();
        } else {
            begindate = time.parse(time.format(begindate));
            enddate = timespecial.parse(time.format(enddate) + " 23:59:59");
        }
        logger.info("根据订单状态分类");
        //未付款订单数统计数组
        int[] orderunpaidarray = new int[7];
        //未发货订单数统计叔祖
        int[] ordernotshippedarray = new int[7];
        //未确认订单数统计数组
        int[] orderunconfirmedarray = new int[7];
        //交易成功订单数统计数组
        int[] ordersuccessarray = new int[7];
        //总交易订单数统计数组
        int[] ordertotalarray = new int[7];
        logger.info("从数据库中获取统计的订单集合数据");
        list<ordergroup> ordergrouplist = productorderservice.gettotalbydate(begindate, enddate);
        //初始化日期数组
        jsonarray datestr = new jsonarray(days);
        //按指定的天数进行循环
        for (int i = 0; i < days; i++) {
            //格式化日期串(mm/dd)并放入日期数组中
            calendar cal = calendar.getinstance();
            cal.settime(begindate);
            cal.add(calendar.date, i);
            string formatdate = time2.format(cal.gettime());
            datestr.add(formatdate);
            //该天的订单总数
            int ordercount = 0;
            //循环订单集合数据的结果集
            for(int j = 0; j < ordergrouplist.size(); j++){
                ordergroup ordergroup = ordergrouplist.get(j);
                //如果该订单日期与当前日期一致
                if(ordergroup.getproductorder_pay_date().equals(formatdate)){
                    //从结果集中移除数据
                    ordergrouplist.remove(j);
                    //根据订单状态将统计结果存入对应的订单状态数组中
                    switch (ordergroup.getproductorder_status()) {
                        case 0:
                            //未付款订单
                            orderunpaidarray[i] = ordergroup.getproductorder_count();
                            break;
                        case 1:
                            //未发货订单
                            ordernotshippedarray[i] = ordergroup.getproductorder_count();
                            break;
                        case 2:
                            //未确认订单
                            orderunconfirmedarray[i] = ordergroup.getproductorder_count();
                            break;
                        case 3:
                            //交易成功订单
                            ordersuccessarray[i] = ordergroup.getproductorder_count();
                            break;
                    }
                    //累加当前日期的订单总数
                    ordercount += ordergroup.getproductorder_count();
                }
            }
            //将统计的订单总数存入总交易订单数统计数组
            ordertotalarray[i] = ordercount;
        }
        logger.info("返回结果集map");
        jsonobject.put("ordertotalarray", ordertotalarray);
        jsonobject.put("orderunpaidarray", orderunpaidarray);
        jsonobject.put("ordernotshippedarray", ordernotshippedarray);
        jsonobject.put("orderunconfirmedarray", orderunconfirmedarray);
        jsonobject.put("ordersuccessarray", ordersuccessarray);
        jsonobject.put("datestr",datestr);
        return jsonobject;
    }
}

商品信息控制层:

/**
 * @author yy
 */
@controller
@requestmapping("/admin")
public class newbeemallgoodscontroller {
 
    @resource
    private newbeemallgoodsservice newbeemallgoodsservice;
    @resource
    private newbeemallcategoryservice newbeemallcategoryservice;
 
    @getmapping("/goods")
    public string goodspage(httpservletrequest request) {
        request.setattribute("path", "newbee_mall_goods");
        return "admin/newbee_mall_goods";
    }
 
    @getmapping("/goods/edit")
    public string edit(httpservletrequest request) {
        request.setattribute("path", "edit");
        //查询所有的一级分类
        list<goodscategory> firstlevelcategories = newbeemallcategoryservice.selectbylevelandparentidsandnumber(collections.singletonlist(0l), newbeemallcategorylevelenum.level_one.getlevel());
        if (!collectionutils.isempty(firstlevelcategories)) {
            //查询一级分类列表中第一个实体的所有二级分类
            list<goodscategory> secondlevelcategories = newbeemallcategoryservice.selectbylevelandparentidsandnumber(collections.singletonlist(firstlevelcategories.get(0).getcategoryid()), newbeemallcategorylevelenum.level_two.getlevel());
            if (!collectionutils.isempty(secondlevelcategories)) {
                //查询二级分类列表中第一个实体的所有三级分类
                list<goodscategory> thirdlevelcategories = newbeemallcategoryservice.selectbylevelandparentidsandnumber(collections.singletonlist(secondlevelcategories.get(0).getcategoryid()), newbeemallcategorylevelenum.level_three.getlevel());
                request.setattribute("firstlevelcategories", firstlevelcategories);
                request.setattribute("secondlevelcategories", secondlevelcategories);
                request.setattribute("thirdlevelcategories", thirdlevelcategories);
                request.setattribute("path", "goods-edit");
                return "admin/newbee_mall_goods_edit";
            }
        }
        return "error/error_5xx";
    }
 
    @getmapping("/goods/edit/{goodsid}")
    public string edit(httpservletrequest request, @pathvariable("goodsid") long goodsid) {
        request.setattribute("path", "edit");
        newbeemallgoods newbeemallgoods = newbeemallgoodsservice.getnewbeemallgoodsbyid(goodsid);
        if (newbeemallgoods == null) {
            return "error/error_400";
        }
        if (newbeemallgoods.getgoodscategoryid() > 0) {
            if (newbeemallgoods.getgoodscategoryid() != null || newbeemallgoods.getgoodscategoryid() > 0) {
                //有分类字段则查询相关分类数据返回给前端以供分类的三级联动显示
                goodscategory currentgoodscategory = newbeemallcategoryservice.getgoodscategorybyid(newbeemallgoods.getgoodscategoryid());
                //商品表中存储的分类id字段为三级分类的id,不为三级分类则是错误数据
                if (currentgoodscategory != null && currentgoodscategory.getcategorylevel() == newbeemallcategorylevelenum.level_three.getlevel()) {
                    //查询所有的一级分类
                    list<goodscategory> firstlevelcategories = newbeemallcategoryservice.selectbylevelandparentidsandnumber(collections.singletonlist(0l), newbeemallcategorylevelenum.level_one.getlevel());
                    //根据parentid查询当前parentid下所有的三级分类
                    list<goodscategory> thirdlevelcategories = newbeemallcategoryservice.selectbylevelandparentidsandnumber(collections.singletonlist(currentgoodscategory.getparentid()), newbeemallcategorylevelenum.level_three.getlevel());
                    //查询当前三级分类的父级二级分类
                    goodscategory secondcategory = newbeemallcategoryservice.getgoodscategorybyid(currentgoodscategory.getparentid());
                    if (secondcategory != null) {
                        //根据parentid查询当前parentid下所有的二级分类
                        list<goodscategory> secondlevelcategories = newbeemallcategoryservice.selectbylevelandparentidsandnumber(collections.singletonlist(secondcategory.getparentid()), newbeemallcategorylevelenum.level_two.getlevel());
                        //查询当前二级分类的父级一级分类
                        goodscategory firestcategory = newbeemallcategoryservice.getgoodscategorybyid(secondcategory.getparentid());
                        if (firestcategory != null) {
                            //所有分类数据都得到之后放到request对象*前端读取
                            request.setattribute("firstlevelcategories", firstlevelcategories);
                            request.setattribute("secondlevelcategories", secondlevelcategories);
                            request.setattribute("thirdlevelcategories", thirdlevelcategories);
                            request.setattribute("firstlevelcategoryid", firestcategory.getcategoryid());
                            request.setattribute("secondlevelcategoryid", secondcategory.getcategoryid());
                            request.setattribute("thirdlevelcategoryid", currentgoodscategory.getcategoryid());
                        }
                    }
                }
            }
        }
        if (newbeemallgoods.getgoodscategoryid() == 0) {
            //查询所有的一级分类
            list<goodscategory> firstlevelcategories = newbeemallcategoryservice.selectbylevelandparentidsandnumber(collections.singletonlist(0l), newbeemallcategorylevelenum.level_one.getlevel());
            if (!collectionutils.isempty(firstlevelcategories)) {
                //查询一级分类列表中第一个实体的所有二级分类
                list<goodscategory> secondlevelcategories = newbeemallcategoryservice.selectbylevelandparentidsandnumber(collections.singletonlist(firstlevelcategories.get(0).getcategoryid()), newbeemallcategorylevelenum.level_two.getlevel());
                if (!collectionutils.isempty(secondlevelcategories)) {
                    //查询二级分类列表中第一个实体的所有三级分类
                    list<goodscategory> thirdlevelcategories = newbeemallcategoryservice.selectbylevelandparentidsandnumber(collections.singletonlist(secondlevelcategories.get(0).getcategoryid()), newbeemallcategorylevelenum.level_three.getlevel());
                    request.setattribute("firstlevelcategories", firstlevelcategories);
                    request.setattribute("secondlevelcategories", secondlevelcategories);
                    request.setattribute("thirdlevelcategories", thirdlevelcategories);
                }
            }
        }
        request.setattribute("goods", newbeemallgoods);
        request.setattribute("path", "goods-edit");
        return "admin/newbee_mall_goods_edit";
    }
 
    /**
     * 列表
     */
    @requestmapping(value = "/goods/list", method = requestmethod.get)
    @responsebody
    public result list(@requestparam map<string, object> params) {
        if (stringutils.isempty(params.get("page")) || stringutils.isempty(params.get("limit"))) {
            return resultgenerator.genfailresult("参数异常!");
        }
        pagequeryutil pageutil = new pagequeryutil(params);
        return resultgenerator.gensuccessresult(newbeemallgoodsservice.getnewbeemallgoodspage(pageutil));
    }
 
    /**
     * 添加
     */
    @requestmapping(value = "/goods/save", method = requestmethod.post)
    @responsebody
    public result save(@requestbody newbeemallgoods newbeemallgoods) {
        if (stringutils.isempty(newbeemallgoods.getgoodsname())
                || stringutils.isempty(newbeemallgoods.getgoodsintro())
                || stringutils.isempty(newbeemallgoods.gettag())
                || objects.isnull(newbeemallgoods.getoriginalprice())
                || objects.isnull(newbeemallgoods.getgoodscategoryid())
                || objects.isnull(newbeemallgoods.getsellingprice())
                || objects.isnull(newbeemallgoods.getstocknum())
                || objects.isnull(newbeemallgoods.getgoodssellstatus())
                || stringutils.isempty(newbeemallgoods.getgoodscoverimg())
                || stringutils.isempty(newbeemallgoods.getgoodsdetailcontent())) {
            return resultgenerator.genfailresult("参数异常!");
        }
        string result = newbeemallgoodsservice.savenewbeemallgoods(newbeemallgoods);
        if (serviceresultenum.success.getresult().equals(result)) {
            return resultgenerator.gensuccessresult();
        } else {
            return resultgenerator.genfailresult(result);
        }
    }
 
 
    /**
     * 修改
     */
    @requestmapping(value = "/goods/update", method = requestmethod.post)
    @responsebody
    public result update(@requestbody newbeemallgoods newbeemallgoods) {
        if (objects.isnull(newbeemallgoods.getgoodsid())
                || stringutils.isempty(newbeemallgoods.getgoodsname())
                || stringutils.isempty(newbeemallgoods.getgoodsintro())
                || stringutils.isempty(newbeemallgoods.gettag())
                || objects.isnull(newbeemallgoods.getoriginalprice())
                || objects.isnull(newbeemallgoods.getsellingprice())
                || objects.isnull(newbeemallgoods.getgoodscategoryid())
                || objects.isnull(newbeemallgoods.getstocknum())
                || objects.isnull(newbeemallgoods.getgoodssellstatus())
                || stringutils.isempty(newbeemallgoods.getgoodscoverimg())
                || stringutils.isempty(newbeemallgoods.getgoodsdetailcontent())) {
            return resultgenerator.genfailresult("参数异常!");
        }
        string result = newbeemallgoodsservice.updatenewbeemallgoods(newbeemallgoods);
        if (serviceresultenum.success.getresult().equals(result)) {
            return resultgenerator.gensuccessresult();
        } else {
            return resultgenerator.genfailresult(result);
        }
    }
 
    /**
     * 详情
     */
    @getmapping("/goods/info/{id}")
    @responsebody
    public result info(@pathvariable("id") long id) {
        newbeemallgoods goods = newbeemallgoodsservice.getnewbeemallgoodsbyid(id);
        if (goods == null) {
            return resultgenerator.genfailresult(serviceresultenum.data_not_exist.getresult());
        }
        return resultgenerator.gensuccessresult(goods);
    }
 
    /**
     * 批量修改销售状态
     */
    @requestmapping(value = "/goods/status/{sellstatus}", method = requestmethod.put)
    @responsebody
    public result delete(@requestbody long[] ids, @pathvariable("sellstatus") int sellstatus) {
        if (ids.length < 1) {
            return resultgenerator.genfailresult("参数异常!");
        }
        if (sellstatus != constants.sell_status_up && sellstatus != constants.sell_status_down) {
            return resultgenerator.genfailresult("状态异常!");
        }
        if (newbeemallgoodsservice.batchupdatesellstatus(ids, sellstatus)) {
            return resultgenerator.gensuccessresult();
        } else {
            return resultgenerator.genfailresult("修改失败");
        }
    }
 
}

商品分类控制器:

/**
 * @author yy
 */
@controller
@requestmapping("/admin")
public class newbeemallgoodscategorycontroller {
 
    @resource
    private newbeemallcategoryservice newbeemallcategoryservice;
 
    @getmapping("/categories")
    public string categoriespage(httpservletrequest request, @requestparam("categorylevel") byte categorylevel, @requestparam("parentid") long parentid, @requestparam("backparentid") long backparentid) {
        if (categorylevel == null || categorylevel < 1 || categorylevel > 3) {
            return "error/error_5xx";
        }
        request.setattribute("path", "newbee_mall_category");
        request.setattribute("parentid", parentid);
        request.setattribute("backparentid", backparentid);
        request.setattribute("categorylevel", categorylevel);
        return "admin/newbee_mall_category";
    }
 
    /**
     * 列表
     */
    @requestmapping(value = "/categories/list", method = requestmethod.get)
    @responsebody
    public result list(@requestparam map<string, object> params) {
        if (stringutils.isempty(params.get("page")) || stringutils.isempty(params.get("limit"))) {
            return resultgenerator.genfailresult("参数异常!");
        }
        pagequeryutil pageutil = new pagequeryutil(params);
        return resultgenerator.gensuccessresult(newbeemallcategoryservice.getcategorispage(pageutil));
    }
 
    /**
     * 列表
     */
    @requestmapping(value = "/categories/listforselect", method = requestmethod.get)
    @responsebody
    public result listforselect(@requestparam("categoryid") long categoryid) {
        if (categoryid == null || categoryid < 1) {
            return resultgenerator.genfailresult("缺少参数!");
        }
        goodscategory category = newbeemallcategoryservice.getgoodscategorybyid(categoryid);
        //既不是一级分类也不是二级分类则为不返回数据
        if (category == null || category.getcategorylevel() == newbeemallcategorylevelenum.level_three.getlevel()) {
            return resultgenerator.genfailresult("参数异常!");
        }
        map categoryresult = new hashmap(2);
        if (category.getcategorylevel() == newbeemallcategorylevelenum.level_one.getlevel()) {
            //如果是一级分类则返回当前一级分类下的所有二级分类,以及二级分类列表中第一条数据下的所有三级分类列表
            //查询一级分类列表中第一个实体的所有二级分类
            list<goodscategory> secondlevelcategories = newbeemallcategoryservice.selectbylevelandparentidsandnumber(collections.singletonlist(categoryid), newbeemallcategorylevelenum.level_two.getlevel());
            if (!collectionutils.isempty(secondlevelcategories)) {
                //查询二级分类列表中第一个实体的所有三级分类
                list<goodscategory> thirdlevelcategories = newbeemallcategoryservice.selectbylevelandparentidsandnumber(collections.singletonlist(secondlevelcategories.get(0).getcategoryid()), newbeemallcategorylevelenum.level_three.getlevel());
                categoryresult.put("secondlevelcategories", secondlevelcategories);
                categoryresult.put("thirdlevelcategories", thirdlevelcategories);
            }
        }
        if (category.getcategorylevel() == newbeemallcategorylevelenum.level_two.getlevel()) {
            //如果是二级分类则返回当前分类下的所有三级分类列表
            list<goodscategory> thirdlevelcategories = newbeemallcategoryservice.selectbylevelandparentidsandnumber(collections.singletonlist(categoryid), newbeemallcategorylevelenum.level_three.getlevel());
            categoryresult.put("thirdlevelcategories", thirdlevelcategories);
        }
        return resultgenerator.gensuccessresult(categoryresult);
    }
 
    /**
     * 添加
     */
    @requestmapping(value = "/categories/save", method = requestmethod.post)
    @responsebody
    public result save(@requestbody goodscategory goodscategory) {
        if (objects.isnull(goodscategory.getcategorylevel())
                || stringutils.isempty(goodscategory.getcategoryname())
                || objects.isnull(goodscategory.getparentid())
                || objects.isnull(goodscategory.getcategoryrank())) {
            return resultgenerator.genfailresult("参数异常!");
        }
        string result = newbeemallcategoryservice.savecategory(goodscategory);
        if (serviceresultenum.success.getresult().equals(result)) {
            return resultgenerator.gensuccessresult();
        } else {
            return resultgenerator.genfailresult(result);
        }
    }
 
 
    /**
     * 修改
     */
    @requestmapping(value = "/categories/update", method = requestmethod.post)
    @responsebody
    public result update(@requestbody goodscategory goodscategory) {
        if (objects.isnull(goodscategory.getcategoryid())
                || objects.isnull(goodscategory.getcategorylevel())
                || stringutils.isempty(goodscategory.getcategoryname())
                || objects.isnull(goodscategory.getparentid())
                || objects.isnull(goodscategory.getcategoryrank())) {
            return resultgenerator.genfailresult("参数异常!");
        }
        string result = newbeemallcategoryservice.updategoodscategory(goodscategory);
        if (serviceresultenum.success.getresult().equals(result)) {
            return resultgenerator.gensuccessresult();
        } else {
            return resultgenerator.genfailresult(result);
        }
    }
 
    /**
     * 详情
     */
    @getmapping("/categories/info/{id}")
    @responsebody
    public result info(@pathvariable("id") long id) {
        goodscategory goodscategory = newbeemallcategoryservice.getgoodscategorybyid(id);
        if (goodscategory == null) {
            return resultgenerator.genfailresult("未查询到数据");
        }
        return resultgenerator.gensuccessresult(goodscategory);
    }
 
    /**
     * 分类删除
     */
    @requestmapping(value = "/categories/delete", method = requestmethod.post)
    @responsebody
    public result delete(@requestbody integer[] ids) {
        if (ids.length < 1) {
            return resultgenerator.genfailresult("参数异常!");
        }
        if (newbeemallcategoryservice.deletebatch(ids)) {
            return resultgenerator.gensuccessresult();
        } else {
            return resultgenerator.genfailresult("删除失败");
        }
    }
 
 
}

到此这篇关于java女装商城系统的实现流程的文章就介绍到这了,更多相关java 女装商城系统内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!