選題:基于SSM框架實(shí)現(xiàn)汽車配件商城系統(tǒng)
項(xiàng)目編號(hào):BS-SC-033
前言:
?隨著互聯(lián)網(wǎng)技術(shù)逐漸的深入到生活,網(wǎng)站形式的展示窗口,已經(jīng)成為大眾迫切的需要。論文中的SSM網(wǎng)上商城購(gòu)物網(wǎng)站專門(mén)是基于B/S模式建立起來(lái)的,為用戶專門(mén)研發(fā)的一個(gè)易操作界面舒適的網(wǎng)上商城交易網(wǎng)站。
??? SSM網(wǎng)上商城交易網(wǎng)站使用JSP技術(shù)制作網(wǎng)站動(dòng)態(tài)頁(yè)面,使用IDEA為系統(tǒng)開(kāi)發(fā)工具,使用SSM框架作為系統(tǒng)的后臺(tái)開(kāi)發(fā)框架,使用BootStrap作為系統(tǒng)的前端開(kāi)發(fā)框加,系統(tǒng)數(shù)據(jù)庫(kù)則使用My SQL數(shù)據(jù)庫(kù)進(jìn)行數(shù)據(jù)存儲(chǔ),開(kāi)發(fā)一個(gè)網(wǎng)上商城交易網(wǎng)站,主要研究的功能是分為前臺(tái)與后臺(tái)兩大部分,前臺(tái)要實(shí)現(xiàn)的是用戶注冊(cè)之后登陸可以瀏覽商品的功能,還有實(shí)現(xiàn)在線商品信息查詢功能、購(gòu)物車加入功能、訂單查詢功能、用戶進(jìn)入個(gè)人中心發(fā)布商品功能、在線留言功能和已經(jīng)出售的訂單的查詢和管理等功能。后臺(tái)主要是實(shí)現(xiàn)管理員對(duì)網(wǎng)站的用戶信息管理、商品類別類別管理、網(wǎng)站新聞管理等信息管理的功能,實(shí)現(xiàn)一個(gè)基于買賣雙方的網(wǎng)上商城交易網(wǎng)站。
SSM網(wǎng)上商城交易網(wǎng)站借助于Internet互聯(lián)網(wǎng)應(yīng)用技術(shù),實(shí)現(xiàn)資源共享,借助網(wǎng)絡(luò)平臺(tái)形式的展示窗口,讓客戶更易接受此網(wǎng)上商城交易網(wǎng)站,并且打破以往購(gòu)買商品的局限性,縮短用戶找商品的時(shí)間,具有較好的交互性,從而實(shí)現(xiàn)信息化、規(guī)范化和系統(tǒng)化。
一,項(xiàng)目簡(jiǎn)介
該系統(tǒng)主要分為汽車配件商城,以汽車配件為主題的在線商城系統(tǒng),系統(tǒng)分為前后端,前臺(tái)功能主要包括用戶的登錄注冊(cè)、查詢商品、購(gòu)物車管理、用戶信息管理、收藏商品、評(píng)價(jià)、收貨地址管理以及訂單管理。后臺(tái)主要包括商品分類管理、客戶信息管理、商品管理、訂單管理、評(píng)論管理、銷售統(tǒng)計(jì)以及系統(tǒng)設(shè)置。 本系統(tǒng)所采用的技術(shù)是SSM框架,整體功能需實(shí)現(xiàn)完整,功能界面較為精美。完成了一個(gè)較為完整的商城銷售系統(tǒng)。
二,環(huán)境介紹
語(yǔ)言環(huán)境:Java:? jdk1.8
數(shù)據(jù)庫(kù):Mysql: mysql5.7
應(yīng)用服務(wù)器:Tomcat:? tomcat8.5.31
開(kāi)發(fā)工具:IDEA或eclipse
后臺(tái)開(kāi)發(fā)技術(shù):SSM
前臺(tái)開(kāi)發(fā)技術(shù):layui+jquery+echarts
三,系統(tǒng)展示
前端系統(tǒng)用戶操作功能

商品詳情

購(gòu)物車下單

個(gè)人中心

己購(gòu)買商品

我的收藏

我的評(píng)價(jià)

收貨地址管理

后臺(tái)管理操作功能

配件分類

客戶管理

商品管理

訂單管理

評(píng)論管理

統(tǒng)計(jì)報(bào)表

四,核心代碼展示
package com.itlb.controller;import java.util.Date;import java.util.HashMap;import java.util.Map;import org.apache.commons.lang.StringUtils;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.ResponseBody;import org.springframework.web.servlet.ModelAndView;import com.itlb.service.AccountService;import com.itlb.util.Page;import com.itlb.entity.Account;/**
* 客戶管理控制器
* @author Administrator
*
*/public class AccountController {
private AccountService accountService; /**
* 客戶列表頁(yè)
* @param model
* @return
*/
public ModelAndView list(ModelAndView model){
model.setViewName("admin/account"); return model;
} /**
* 查詢客戶列表
* @param name
* @param page
* @return
*/
public Map<String, Object> list({
Map<String, Object> ret = String name, Integer sex, Integer status,
Page page
)new HashMap<String, Object>();
Map<String, Object> queryMap = new HashMap<String, Object>();
queryMap.put("name", name); if(sex != null){
queryMap.put("sex", sex);
} if(status != null){
queryMap.put("status", status);
}
queryMap.put("offset", page.getOffset());
queryMap.put("pageSize", page.getRows());
ret.put("rows", accountService.findList(queryMap));
ret.put("total", accountService.getTotal(queryMap)); return ret;
} /**
* 添加客戶
* @param account
* @return
*/
public Map<String, Object> add(Account account){
Map<String, Object> ret = new HashMap<String, Object>(); if(account == null){
ret.put("type", "error");
ret.put("msg", "請(qǐng)?zhí)顚?xiě)正確的客戶信息"); return ret;
} if(StringUtils.isEmpty(account.getName())){
ret.put("type", "error");
ret.put("msg", "請(qǐng)?zhí)顚?xiě)客戶名稱"); return ret;
} if(StringUtils.isEmpty(account.getPassword())){
ret.put("type", "error");
ret.put("msg", "請(qǐng)?zhí)顚?xiě)客戶登錄密碼!"); return ret;
} if(isExist(account.getName(), 0l)){
ret.put("type", "error");
ret.put("msg", "該用戶名已存在!"); return ret;
}
account.setCreateTime(new Date()); if(accountService.add(account) <= 0){
ret.put("type", "error");
ret.put("msg", "添加失敗,請(qǐng)聯(lián)系管理員!"); return ret;
}
ret.put("type", "success");
ret.put("msg", "添加成功!"); return ret;
} /**
* 編輯客戶
* @param account
* @return
*/
public Map<String, Object> edit(Account account){
Map<String, Object> ret = new HashMap<String, Object>(); if(account == null){
ret.put("type", "error");
ret.put("msg", "請(qǐng)?zhí)顚?xiě)正確的客戶信息"); return ret;
} if(StringUtils.isEmpty(account.getName())){
ret.put("type", "error");
ret.put("msg", "請(qǐng)?zhí)顚?xiě)客戶名稱"); return ret;
} if(StringUtils.isEmpty(account.getPassword())){
ret.put("type", "error");
ret.put("msg", "請(qǐng)?zhí)顚?xiě)客戶登錄密碼!"); return ret;
} if(isExist(account.getName(), account.getId())){
ret.put("type", "error");
ret.put("msg", "該用戶名已存在!"); return ret;
} if(accountService.edit(account) <= 0){
ret.put("type", "error");
ret.put("msg", "添加失敗,請(qǐng)聯(lián)系管理員!"); return ret;
}
ret.put("type", "success");
ret.put("msg", "編輯成功!"); return ret;
} /**
* 刪除客戶
* @param id
* @return
*/
public Map<String, Object> delete(Long id){
Map<String, Object> ret = new HashMap<String, Object>(); if(id == null){
ret.put("type", "error");
ret.put("msg", "請(qǐng)選擇要?jiǎng)h除的客戶"); return ret;
} try { if(accountService.delete(id) <= 0){
ret.put("type", "error");
ret.put("msg", "刪除失敗,請(qǐng)聯(lián)系管理員!"); return ret;
}
} catch (Exception e) { // TODO: handle exception
ret.put("type", "error");
ret.put("msg", "該客戶下存在訂單信息,不允許刪除!"); return ret;
}
ret.put("type", "success");
ret.put("msg", "刪除成功!"); return ret;
} /**
* 檢查用戶名是否存在
* @param name
* @param id
* @return
*/
private boolean isExist(String name,Long id){ Account account = accountService.findByName(name); if(account == null)return false; if(account.getId().longValue() == id.longValue())return false; return true;
}
}
package com.itlb.controller;import java.util.Date;import java.util.HashMap;import java.util.Map;import javax.servlet.http.HttpServletRequest;import org.apache.commons.lang.StringUtils;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.ResponseBody;import org.springframework.web.servlet.ModelAndView;import com.itlb.service.AccountService;import com.itlb.service.AddressService;import com.itlb.util.MenuUtil;import com.itlb.entity.Account;import com.itlb.entity.Address;import com.itlb.service.ProductCategoryService;import com.itlb.service.ProductService;/**
* 前臺(tái)收貨地址控制器
* @author Administrator
*
*/public class AddressController {
private AccountService accountService;
private ProductCategoryService productCategoryService;
private ProductService productService;
private AddressService addressService; /**
* 收貨地址列表頁(yè)面
* @param model
* @return
*/
public ModelAndView index(ModelAndView model,HttpServletRequest request){
model.addObject("productCategoryList", MenuUtil.getTreeCategory(productCategoryService.findList(new HashMap<String, Object>())));
model.addObject("allCategoryId","shop_hd_menu_all_category"); Account onlineAccount = (Account)request.getSession().getAttribute("account");
Map<String, Object> queryMap = new HashMap<String, Object>();
queryMap.put("userId", onlineAccount.getId());
model.addObject("addressList", addressService.findList(queryMap));
model.addObject("currentUser", "current_");
model.setViewName("home/address/list"); return model;
}
/**
* 添加收貨地址
* @param account
* @return
*/
public Map<String, String> add(Address address,HttpServletRequest request){
Map<String, String> ret = new HashMap<String, String>(); Account onlineAccount = (Account)request.getSession().getAttribute("account");
ret.put("type", "error"); if(address == null){
ret.put("msg", "請(qǐng)選擇正確的收貨信息"); return ret;
} if(StringUtils.isEmpty(address.getName())){
ret.put("msg", "請(qǐng)?zhí)顚?xiě)收貨人!"); return ret;
} if(StringUtils.isEmpty(address.getAddress())){
ret.put("msg", "請(qǐng)?zhí)顚?xiě)收貨地址!"); return ret;
} if(StringUtils.isEmpty(address.getPhone())){
ret.put("msg", "請(qǐng)?zhí)顚?xiě)手機(jī)號(hào)!"); return ret;
}
address.setUserId(onlineAccount.getId());
address.setCreateTime(new Date()); if(addressService.add(address) <= 0){
ret.put("msg", "添加失敗,請(qǐng)聯(lián)系管理員!"); return ret;
}
ret.put("type", "success"); return ret;
}
public Map<String, String> edit(Address address,HttpServletRequest request){
Map<String, String> ret = new HashMap<String, String>(); Account onlineAccount = (Account)request.getSession().getAttribute("account");
ret.put("type", "error"); if(address == null){
ret.put("msg", "請(qǐng)選擇正確的收貨信息"); return ret;
} Address existAddress = addressService.findById(address.getId()); if(existAddress == null){
ret.put("msg", "不存在該地址!"); return ret;
} if(StringUtils.isEmpty(address.getName())){
ret.put("msg", "請(qǐng)?zhí)顚?xiě)收貨人!"); return ret;
} if(StringUtils.isEmpty(address.getAddress())){
ret.put("msg", "請(qǐng)?zhí)顚?xiě)收貨地址!"); return ret;
} if(StringUtils.isEmpty(address.getPhone())){
ret.put("msg", "請(qǐng)?zhí)顚?xiě)手機(jī)號(hào)!"); return ret;
}
address.setUserId(onlineAccount.getId()); if(addressService.edit(address) <= 0){
ret.put("msg", "編輯失敗,請(qǐng)聯(lián)系管理員!"); return ret;
}
ret.put("type", "success"); return ret;
}
/**
* 刪除收貨地址
* @param favoriteId
* @return
*/
public Map<String, String> delete(Long id){
Map<String, String> ret = new HashMap<String, String>();
ret.put("type", "error"); if(id == null){
ret.put("msg", "請(qǐng)選擇要?jiǎng)h除的地址"); return ret;
} if(addressService.delete(id) <= 0){
ret.put("msg", "刪除出錯(cuò),請(qǐng)聯(lián)系管理員!"); return ret;
}
ret.put("type", "success"); return ret;
}
}
package com.itlb.controller;import java.util.Date;import java.util.HashMap;import java.util.Map;import javax.servlet.http.HttpServletRequest;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.ResponseBody;import org.springframework.web.servlet.ModelAndView;import com.itlb.service.AccountService;import com.itlb.service.AddressService;import com.itlb.util.MenuUtil;import com.itlb.entity.Account;import com.itlb.entity.Product;import com.itlb.entity.Cart;import com.itlb.service.ProductCategoryService;import com.itlb.service.ProductService;import com.itlb.service.CartService;/**
* 前臺(tái)購(gòu)物車控制器
* @author Administrator
*
*/public class CartController {
private AccountService accountService;
private ProductCategoryService productCategoryService;
private ProductService productService;
private CartService cartService;
private AddressService addressService; /**
* 購(gòu)物車列表頁(yè)面
* @param model
* @return
*/
public ModelAndView list(ModelAndView model,HttpServletRequest request){
model.addObject("productCategoryList", MenuUtil.getTreeCategory(productCategoryService.findList(new HashMap<String, Object>())));
model.addObject("allCategoryId","shop_hd_menu_all_category"); Account onlineAccount = (Account)request.getSession().getAttribute("account");
Map<String, Object> queryMap = new HashMap<String, Object>();
queryMap.put("userId", onlineAccount.getId());
model.addObject("cartList", cartService.findList(queryMap));
model.addObject("currentCart", "current_");
model.setViewName("home/cart/list"); return model;
}
/**
* 提交訂單第二步
* @param model
* @param request
* @return
*/
public ModelAndView list2(ModelAndView model,HttpServletRequest request){
model.addObject("productCategoryList", MenuUtil.getTreeCategory(productCategoryService.findList(new HashMap<String, Object>())));
model.addObject("allCategoryId","shop_hd_menu_all_category"); Account onlineAccount = (Account)request.getSession().getAttribute("account");
Map<String, Object> queryMap = new HashMap<String, Object>();
queryMap.put("userId", onlineAccount.getId());
model.addObject("cartList", cartService.findList(queryMap));
model.addObject("currentCart", "current_");
model.addObject("addressList", addressService.findList(queryMap));
model.setViewName("home/cart/list_2"); return model;
}
/**
* 添加購(gòu)物車
* @param account
* @return
*/
public Map<String, String> add(Cart cart,HttpServletRequest request){
Map<String, String> ret = new HashMap<String, String>(); Account onlineAccount = (Account)request.getSession().getAttribute("account");
ret.put("type", "error"); if(cart == null){
ret.put("msg", "請(qǐng)選擇正確的商品信息"); return ret;
} if(cart.getProductId() == null){
ret.put("msg", "請(qǐng)選擇要添加的商品!"); return ret;
} if(cart.getNum() == 0){
ret.put("msg", "請(qǐng)?zhí)顚?xiě)商品數(shù)量"); return ret;
} Product product = productService.findById(cart.getProductId()); if(product == null){
ret.put("msg", "商品不存在"); return ret;
} //根據(jù)商品和用戶去查詢?cè)撋唐肥欠褚驯惶砑拥劫?gòu)物車
Map<String, Long> queryMap = new HashMap<String, Long>();
queryMap.put("userId", onlineAccount.getId());
queryMap.put("productId", product.getId()); Cart existCart = cartService.findByIds(queryMap); if(existCart != null){ //表示這個(gè)商品已經(jīng)被添加到購(gòu)物車,只需更新數(shù)量和金額即可
existCart.setNum(existCart.getNum() + cart.getNum());
existCart.setMoney(existCart.getNum() * existCart.getPrice()); if(cartService.edit(existCart) <= 0){
ret.put("msg", "商品已被添加到購(gòu)物車,但更新數(shù)量出錯(cuò)!"); return ret;
}
ret.put("type", "success"); return ret;
}
cart.setImageUrl(product.getImageUrl());
cart.setMoney(product.getPrice() * cart.getNum());
cart.setName(product.getName());
cart.setPrice(product.getPrice());
cart.setUserId(onlineAccount.getId());
cart.setCreateTime(new Date()); if(cartService.add(cart) <= 0){
ret.put("msg", "添加失敗,請(qǐng)聯(lián)系管理員!"); return ret;
}
ret.put("type", "success"); return ret;
}
/**
* 更新購(gòu)物車商品數(shù)量
* @param cartId
* @param num
* @return
*/
public Map<String, String> updateNum(Long cartId,Integer num){
Map<String, String> ret = new HashMap<String, String>();
ret.put("type", "error"); Cart cart = cartService.findById(cartId); if(cart == null){
ret.put("msg", "請(qǐng)選擇正確的商品信息"); return ret;
} if(num == null){
ret.put("msg", "請(qǐng)?zhí)顚?xiě)商品數(shù)量"); return ret;
} Product product = productService.findById(cart.getProductId()); if(product == null){
ret.put("msg", "購(gòu)物車信息有誤!"); return ret;
} if(cart.getNum() + num.intValue() > product.getStock()){
ret.put("msg", "商品數(shù)量不能超過(guò)庫(kù)存量!"); return ret;
}
cart.setNum(cart.getNum() + num);
cart.setMoney(cart.getNum() * cart.getPrice()); if(cartService.edit(cart) <= 0){
ret.put("msg", "商品已被添加到購(gòu)物車,但更新數(shù)量出錯(cuò)!"); return ret;
}
ret.put("type", "success"); return ret;
}
/**
* 刪除購(gòu)物車商品
* @param cartId
* @return
*/
public Map<String, String> delete(Long cartId){
Map<String, String> ret = new HashMap<String, String>();
ret.put("type", "error"); if(cartId == null){
ret.put("msg", "請(qǐng)選擇要?jiǎng)h除的商品"); return ret;
} if(cartService.delete(cartId) <= 0){
ret.put("msg", "刪除出錯(cuò),請(qǐng)聯(lián)系管理員!"); return ret;
}
ret.put("type", "success"); return ret;
}
}
五,項(xiàng)目總結(jié)
?在當(dāng)前社會(huì)上,許多的各種類型的電子商務(wù)類網(wǎng)站紛紛建立,可以很大程度上的解決人們信息資源的閉塞以及地域上的限制[1]。網(wǎng)上交易成為了當(dāng)代人們業(yè)余生活的一大熱門(mén),伴隨著用戶的購(gòu)買能力的提高和新型互聯(lián)網(wǎng)技術(shù)的應(yīng)用。
??? 目前大部分的高校已經(jīng)建立自己的校園網(wǎng),而部分院校也完成了校園網(wǎng)絡(luò)工程的建設(shè),校園網(wǎng)的建成為學(xué)校的學(xué)生、老師、后勤部門(mén)等學(xué)校各方面人士提供了非常大的便利,例如學(xué)習(xí)、工作和生活上的交流便利[2]。隨著計(jì)算機(jī)網(wǎng)絡(luò)技術(shù)、通信技術(shù)和數(shù)據(jù)庫(kù)技術(shù)的迅速發(fā)展,基于網(wǎng)絡(luò)技術(shù)的電子商務(wù)也發(fā)展的非常迅速。而實(shí)現(xiàn)大學(xué)生之間的網(wǎng)上交易的主要平臺(tái)是校園論壇還有微博,校園論壇雖然用戶非常多,但是提供的功能有限,用戶不能詳細(xì)的了解商品的有關(guān)信息,更不能快速的查詢所需商品,無(wú)法讓學(xué)生實(shí)際交易的需求得到最大的滿足。