Java 實戰(zhàn)項目錘煉之網(wǎng)上商城系統(tǒng)的實現(xiàn)流程_第1頁
Java 實戰(zhàn)項目錘煉之網(wǎng)上商城系統(tǒng)的實現(xiàn)流程_第2頁
Java 實戰(zhàn)項目錘煉之網(wǎng)上商城系統(tǒng)的實現(xiàn)流程_第3頁
Java 實戰(zhàn)項目錘煉之網(wǎng)上商城系統(tǒng)的實現(xiàn)流程_第4頁
Java 實戰(zhàn)項目錘煉之網(wǎng)上商城系統(tǒng)的實現(xiàn)流程_第5頁
已閱讀5頁,還剩6頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領

文檔簡介

第Java實戰(zhàn)項目錘煉之網(wǎng)上商城系統(tǒng)的實現(xiàn)流程一、項目簡述(+需求文檔+PPT)

功能:主頁顯示熱銷商品;所有商品展示,可進行商品搜索;點擊商品進入商品詳情頁,顯示庫存,具有立即購買和加入購物車功能,可增減購買商品數(shù)量亦可手動輸入(同時驗證庫存),熱銷商品展示。立即購買進入確認訂單頁面,可選擇已經(jīng)添加的地址,亦可新增地址。(同時驗證庫存),可選擇購買哪些商品,可刪除不需要的商品。點擊結(jié)算進入確認訂單頁面,確認后提交訂單,訂單重復提交給予響應,庫存不足或商品下架給予響應。后臺管理:(修改密碼等),商品管理(商品批量添加、上下架、庫存維護等),訂單管理。

二、項目運行

環(huán)境配置:Jdk1.8+Tomcat8.5+mysql+Eclispe(IntelliJIDEA,Eclispe,MyEclispe,Sts都支持)

項目技術(shù):JSP+C3P0+Servlert+html+css+JavaScript+JQuery+Ajax+Fileupload等等。

后臺管理-主頁操作代碼:

*后臺管理-主頁

@Controller

publicclassAdminHomeControllerextendsBaseController{

@Resource(name="adminService")

privateAdminServiceadminService;

@Resource(name="productOrderService")

privateProductOrderServiceproductOrderService;

@Resource(name="productService")

privateProductServiceproductService;

@Resource(name="userService")

privateUserServiceuserService;

*轉(zhuǎn)到后臺管理-主頁

*@paramsessionsession對象

*@parammap前臺傳入的Map

*@return響應數(shù)據(jù)

*@throwsParseException轉(zhuǎn)換異常

@RequestMapping(value="admin",method=RequestMethod.GET)

publicStringgoToPage(HttpSessionsession,MapString,Objectmap)throwsParseException{

("獲取管理員信息");

ObjectadminId=checkAdmin(session);

if(adminId==null){

return"redirect:/admin/login";

Adminadmin=adminService.get(null,Integer.parseInt(adminId.toString()));

map.put("admin",admin);

("獲取統(tǒng)計信息");

//產(chǎn)品總數(shù)

IntegerproductTotal=productService.getTotal(null,newByte[]{0,2});

//用戶總數(shù)

IntegeruserTotal=userService.getTotal(null);

//訂單總數(shù)

IntegerorderTotal=productOrderService.getTotal(null,newByte[]{3});

("獲取圖表信息");

map.put("jsonObject",getChartData(null,null,7));

map.put("productTotal",productTotal);

map.put("userTotal",userTotal);

map.put("orderTotal",orderTotal);

("轉(zhuǎn)到后臺管理-主頁");

return"admin/homePage";

*轉(zhuǎn)到后臺管理-主頁(ajax方式)

*@paramsessionsession對象

*@parammap前臺傳入的Map

*@return響應數(shù)據(jù)

*@throwsParseException轉(zhuǎn)換異常

@RequestMapping(value="admin/home",method=RequestMethod.GET)

publicStringgoToPageByAjax(HttpSessionsession,MapString,Objectmap)throwsParseException{

("獲取管理員信息");

ObjectadminId=checkAdmin(session);

if(adminId==null){

return"admin/include/loginMessage";

Adminadmin=adminService.get(null,Integer.parseInt(adminId.toString()));

map.put("admin",admin);

("獲取統(tǒng)計信息");

IntegerproductTotal=productService.getTotal(null,newByte[]{0,2});

IntegeruserTotal=userService.getTotal(null);

IntegerorderTotal=productOrderService.getTotal(null,newByte[]{3});

("獲取圖表信息");

map.put("jsonObject",getChartData(null,null,7));

("獲取圖表信息");

map.put("jsonObject",getChartData(null,null,7));

map.put("productTotal",productTotal);

map.put("userTotal",userTotal);

map.put("orderTotal",orderTotal);

("轉(zhuǎn)到后臺管理-主頁-ajax方式");

return"admin/homeManagePage";

*按日期查詢圖表數(shù)據(jù)(ajax方式)

*@parambeginDate開始日期

*@paramendDate結(jié)束日期

*@return響應數(shù)據(jù)

*@throwsParseException轉(zhuǎn)換異常

@ResponseBody

@RequestMapping(value="admin/home/charts",method=RequestMethod.GET,produces="application/json;charset=utf-8")

publicStringgetChartDataByDate(@RequestParam(required=false)StringbeginDate,@RequestParam(required=false)StringendDate)throwsParseException{

if(beginDate!=nullendDate!=null){

//轉(zhuǎn)換日期格式

SimpleDateFormatsimpleDateFormat=newSimpleDateFormat("yyyy-MM-dd");

returngetChartData(simpleDateFormat.parse(beginDate),simpleDateFormat.parse(endDate),7).toJSONString();

}else{

returngetChartData(null,null,7).toJSONString();

*按日期獲取圖表數(shù)據(jù)

*@parambeginDate開始日期

*@paramendDate結(jié)束日期

*@paramdays天數(shù)

*@return圖表數(shù)據(jù)的JSON對象

*@throwsParseException轉(zhuǎn)換異常

privateJSONObjectgetChartData(DatebeginDate,DateendDate,intdays)throwsParseException{

JSONObjectjsonObject=newJSONObject();

SimpleDateFormattime=newSimpleDateFormat("yyyy-MM-dd",Locale.UK);

SimpleDateFormattime2=newSimpleDateFormat("MM/dd",Locale.UK);

SimpleDateFormattimeSpecial=newSimpleDateFormat("yyyy-MM-ddHH:mm:ss",Locale.UK);

//如果沒有指定開始和結(jié)束日期

if(beginDate==null||endDate==null){

//指定一周前的日期為開始日期

Calendarcal=Calendar.getInstance();

cal.add(Calendar.DATE,1-days);

beginDate=time.parse(time.format(cal.getTime()));

//指定當前日期為結(jié)束日期

cal=Calendar.getInstance();

endDate=cal.getTime();

}else{

beginDate=time.parse(time.format(beginDate));

endDate=timeSpecial.parse(time.format(endDate)+"23:59:59");

("根據(jù)訂單狀態(tài)分類");

//未付款訂單數(shù)統(tǒng)計數(shù)組

int[]orderUnpaidArray=newint[7];

//未發(fā)貨訂單數(shù)統(tǒng)計叔祖

int[]orderNotShippedArray=newint[7];

//未確認訂單數(shù)統(tǒng)計數(shù)組

int[]orderUnconfirmedArray=newint[7];

//交易成功訂單數(shù)統(tǒng)計數(shù)組

int[]orderSuccessArray=newint[7];

//總交易訂單數(shù)統(tǒng)計數(shù)組

int[]orderTotalArray=newint[7];

("從數(shù)據(jù)庫中獲取統(tǒng)計的訂單集合數(shù)據(jù)");

ListOrderGrouporderGroupList=productOrderService.getTotalByDate(beginDate,endDate);

//初始化日期數(shù)組

JSONArraydateStr=newJSONArray(days);

//按指定的天數(shù)進行循環(huán)

for(inti=0;idays;i++){

//格式化日期串(MM/dd)并放入日期數(shù)組中

Calendarcal=Calendar.getInstance();

cal.setTime(beginDate);

cal.add(Calendar.DATE,i);

StringformatDate=time2.format(cal.getTime());

dateStr.add(formatDate);

//該天的訂單總數(shù)

intorderCount=0;

//循環(huán)訂單集合數(shù)據(jù)的結(jié)果集

for(intj=0;jorderGroupList.size();j++){

OrderGrouporderGroup=orderGroupList.get(j);

//如果該訂單日期與當前日期一致

if(orderGroup.getProductOrder_pay_date().equals(formatDate)){

//從結(jié)果集中移除數(shù)據(jù)

orderGroupList.remove(j);

//根據(jù)訂單狀態(tài)將統(tǒng)計結(jié)果存入對應的訂單狀態(tài)數(shù)組中

switch(orderGroup.getProductOrder_status()){

case0:

//未付款訂單

orderUnpaidArray[i]=orderGroup.getProductOrder_count();

break;

case1:

//未發(fā)貨訂單

orderNotShippedArray[i]=orderGroup.getProductOrder_count();

break;

case2:

//未確認訂單

orderUnconfirmedArray[i]=orderGroup.getProductOrder_count();

break;

case3:

//交易成功訂單

orderSuccessArray[i]=orderGroup.getProductOrder_count();

break;

//累加當前日期的訂單總數(shù)

orderCount+=orderGroup.getProductOrder_count();

//將統(tǒng)計的訂單總數(shù)存入總交易訂單數(shù)統(tǒng)計數(shù)組

orderTotalArray[i]=orderCount;

("返回結(jié)果集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);

returnjsonObject;

}

前臺主頁代碼:

*主頁

@Controller

publicclassForeHomeControllerextendsBaseController{

@Resource(name="userService")

privateUserServiceuserService;

@Resource(name="categoryService")

privateCategoryServicecategoryService;

@Resource(name="productService")

privateProductServiceproductService;

@Resource(name="productImageService")

privateProductImageServiceproductImageService;

//轉(zhuǎn)到前臺天貓-主頁

@RequestMapping(value="/",method=RequestMethod.GET)

publicStringgoToPage(HttpSessionsession,MapString,Objectmap){

("檢查用戶是否登錄");

ObjectuserId=checkUser(session);

if(userId!=null){

("獲取用戶信息");

Useruser=userService.get(Integer.parseInt(userId.toString()));

map.put("user",user);

("獲取產(chǎn)品分類列表");

ListCategorycategoryList=categoryService.getList(null,null);

("獲取每個分類下的產(chǎn)品列表");

for(Categorycategory:categoryList){

ListProductproductList=productService.getList(

newProduct().setProduct_category(category),

newByte[]{0,2},

newOrderUtil("product_sale_count",true),newPageUtil(0,8)

if(productList!=null){

for(Productproduct:productList){

Integerproduct_id=product.getProduct_id();

product.setSingleProductImageList(

productImageService.getList(

product_id,(byte)0,newPageUtil(0,1)

category.setProductList(productList);

map.put("categoryList",categoryList);

("獲取促銷產(chǎn)品列表");

ListProductspecialProductList=productService.getList(

null,newByte[]{2},null,newPageUtil(0,6)

map.put("specialProductList",specialProductList);

("轉(zhuǎn)到前臺主頁");

return"fore/homePage";

//轉(zhuǎn)到前臺天貓-錯誤頁

@RequestMapping(value="error",method=RequestMethod.GET)

publicStringgoToErrorPage(){

return"fore/errorPage";

//獲取主頁分類下產(chǎn)品信息-ajax

@ResponseBody

@RequestMapping(value="product/nav/{category_id}",method=RequestMethod.GET,produces="application/json;charset=utf-8")

publicStringgetProductByNav(@PathVariable("category_id")Integercategory_id){

JSONObject

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論