999精品在线视频,手机成人午夜在线视频,久久不卡国产精品无码,中日无码在线观看,成人av手机在线观看,日韩精品亚洲一区中文字幕,亚洲av无码人妻,四虎国产在线观看 ?

商品管理系統的設計與實現

2021-12-24 23:07:56唐昌華李沅倢
電腦知識與技術 2021年29期

唐昌華 李沅倢

摘要:近些年來網上商品越來越多,為了滿足日益增長的網購需求,采用JSP技術、MySql數據庫,使用MyEclipse作為開發工具實現商品管理系統,完成基本的商品信息管理,還實現了購買商品時,按照會員等級自動進行折扣功能,完成訂單時自動累積積分,當積分達到標準時自動升級會員等級的功能,為商品的網上銷售提高了效率。

關鍵詞:商品管理;JSP;JDBC

中圖分類號:TP311? 文獻標識碼:A

文章編號:1009-3044(2021)29-0076-03

Design and Implementation of Commodity Management System

TANG Chang-hua, LI Yuan-jie

(College of Humanities and information, Changchun University of Technology, Changchun 130122, China)

Abstract: In recent years, there are more and more online goods. In order to meet the growing demand of online shopping, we use JSP technology, MySQL database and MyEclipse as the development tool to realize the commodity management system, complete the basic commodity information management, and realize the automatic discount function according to the level when purchasing goods, and automatically accumulate points when completing the order, When the score reaches the standard, it can automatically upgrade the membership level, which improves the efficiency of online sales of goods.

Key words: goods management; JSP; JDBC

1背景

本系統根據網絡購物的需求,使用軟件工程的設計思想,分析設計并實現了商品管理系統,并使用面向對象的思想對代碼進行了封裝,增強了系統的魯棒性和可復用性。

2總體設計

本系統主要有管理員和會員兩個角色,管理員的功能有:管理員管理、商品分類管理、商品管理、商品入庫、商品盤庫、新聞管理、會員分類管理、會員管理、訂單管理等。會員的功能有:會員管理、商品查詢、評論管理、購物車管理、訂單管理等。

如圖1所示。

3系統開放環境

使用B/S(Browser/Server)結構完成本系統[1]。本系統采用 JSP作為開發的前臺,實現DBUtil類,對JDBC數據庫操作進行了封裝作為數據持久化層,采用MySQL作為數據庫。

4數據庫設計

本系統設計一個數據庫productdb,十一個表,分別是:管理員表、商品庫存表、商品分類表、商品表、新聞表、訂單詳單表、訂單表、購物車表、評價表、會員分類表、會員表。其中商品分類和商品是一對多關系,管理員和新聞是一對多關系,商品和商品庫存是一對一關系,商品和新聞是一對多關系,商品和訂單詳單是一對多關系,商品和購物車是一對多關系,商品和評價是一對多關系,會員分類和會員是一對多關系,會員和訂單是一對多關系,會員和購物車是一對多關系,會員和評價是一對多關系。系統ER 圖如圖2所示。

5系統實現

本系統采用Jsp的 model2[2]設計模式進行開發,為典型的 MVC架構[3]。使用JSP[4]作為視圖層,實現界面顯示,采用自定義DBUtil類作為模型層,實現對數據庫的各項操作,使用Serv? let作為控制器層。除基本的增刪改查功能外還完成了庫存自動更新,商品價格按會員等級自動折扣,會員積分按訂單自動累加,分頁顯示,多條件模糊查詢,商品圖片上傳[5]、顯示等功能。

1)DBUtil類部分實現如下:

//更新操作的封裝,包括增刪改

public static void executeUpdate(String strsql, ArrayListlstp){ try {

//獲取連接conn

Connection conn = getConnection();

//由conn使用sql命令參數創建預處理語句對象

PreparedStatementpstmt = conn.prepareStatement(strsql); //使用參數值數組lstp,循環綁定sql命令中“?”對應的值

//注意:“?”序號從1開始,數組下標開始,所以第一個參數是i+1,而不是i

for(int i =0; i<lstp.size(); i++)

pstmt.setect(i+1, lstp.get(i));

//執行更新操作

pstmt.executeUpdate();

//關閉相應對象注意:關閉順序,先建的后關,后建的先關

pstmt.close();

conn.close();

} catch (Exception e){

e.printStackTrace();

}

}

//帶參數的查詢的封裝

public static ArrayList<ArrayList>executeQuery(String strsql, ArrayListlstp){

ArrayList<ArrayList>lstres = new ArrayList<ArrayList>(); try {

int i =0;

Connection conn = getConnection();

PreparedStatementpstmt= conn.prepareStatement(strsql);? //使用參數值數組lstp,循環綁定sql命令中“?”對應的值

//注意:“?”序號從1開始,數組下標開始,所以第一個參數是i+1,而不是i

if(lstp != null){

for(i =0; i<lstp.size(); i++){

pstmt.setect(i+1, lstp.get(i));

}

}

ResultSetrs = pstmt.executeQuery();

ResultSetMetaDatarsmd = rs.getMetaData();

int cc = rsmd.getColumnCount();

while(rs.next()){

ArrayListlstline = new ArrayList();

for(i =0; i< cc; i++)

lstline.add(rs.getect(i+1));

lstres.add(lstline);

}

rs.close();

pstmt.close();

conn.close();

} catch (Exception e){

e.printStackTrace();

}

return lstres;

}

2)添加訂單實現:

添加訂單時,自動計算折扣價,累加積分,更新庫存。

public void doPost(HttpServletRequest request, HttpServle?tResponse response)

throws ServletException, IOException {

String[] strscids = request.getParameterValues("chksc");

if(strscids != null){

float money =0;

String strsql ="";

ArrayListlstm = new ArrayList();

ArrayList<ArrayList>lstres = new ArrayList<ArrayList>(); for(String strscid : strscids){

int scid = Integer.parseInt(strscid);

strsql ="select * from shoppingcart as sc, product as p, pro?ductbase as pb "

+" where sc.id =? and sc.pid = p.id and p.id = pb.pid and sc.num<= pb.num ";

lstm = DbUtil.findline(strsql, scid);

if(lstm.isEmpty()){

response. sendRedirect("ShoppingcartFindAll? prompt=" + scid);

return ;

}

strsql ="select p.price * sc.num * cc.discount from shopping? cart as sc, product as p, customer as c, customercategory as cc "

+" where sc.id =? and sc.pid = p.id and sc.cid = c.id and cc.id = c.ccid ";

lstm = DbUtil.findline(strsql, scid);

money += Float.parseFloat(lstm.get(0).toString());}

strsql ="select max(id) from book";

lstres = DbUtil.executeQuery(strsql);

int maxid;

if(lstres == null || lstres.get(0)== null || lstres.get(0).get(0)= = null)

maxid =1;

else

maxid = Integer.parseInt(lstres.get(0).get(0).toString())+ 1;

ArrayListlstcustomer =(ArrayList)request. getSession(). ge?tAttribute("customer");

ArrayListlstp = new ArrayList();

lstp.add(maxid);

lstp.add(lstcustomer.get(0));

lstp.add(lstcustomer.get(3));

lstp.add(money);

strsql ="insert into book(id, cid, mailaddress, money) val?ues(?,?,?,?)";

DbUtil.executeUpdate(strsql, lstp);

strsql ="update customer c, customercategory cc set c.to?talscore = c.totalscore + floor(?/100)*cc.score "

+" where c.id =? and c.ccid = cc.id";

lstp.clear();

lstp.add(money);

lstp.add(lstcustomer.get(0));

DbUtil.executeUpdate(strsql, lstp);

for(String strscid : strscids){

strsql ="insert into bookitem(bid,pid,num) select ?,pid,num

from shoppingcart where id =?";

int scid = Integer.parseInt(strscid);

lstp.clear();

lstp.add(maxid);

lstp.add(scid);

DbUtil.executeUpdate(strsql, lstp);

strsql ="update productbase pb, shoppingcartsc set pb. num = pb.num - sc.num where sc.id =? and pb.pid = sc.pid ";

DbUtil.executeUpdate(strsql, scid);

}

response.sendRedirect("BookFindAll");

}

else{

response.setCharacterEncoding("gbk");

PrintWriter out = response.getWriter();

out.println("<script>alert('請選擇要購買的商品!');win?dow.location='ShoppingcartFindAll';</script>");

}

}

主界面實現如下:

6結束語

本系統實現了商品管理,使得會員能夠在網上瀏覽商品、購買商品、評價商品,管理員能夠管理商品、庫存等,方便了商品在網上的銷售,提高了工作效率。

參考文獻:

[1]唐昌華,時兵,時慶濤.基于Struts 和Hibernate畢業設計管理系統的設計與實現[J].數字技術與應用,2012(11):167.

[2]劉艷春,洪曉慧.Struts2框架核心配置文件的研究與應用[J].計算機技術與發展,2013,23(2):77-81.

[3]孫衛琴.精通Struts基于MVC 的Java Web設計與實現[M].北京:電子工業出版社,2004.

[4]李興華,王月清. 名師講壇:Java Web 開發實戰經典基礎篇(JSP, Servlet, Struts, Ajax)[M].北京:清華大學出版社,2010.

[5]蔣治學.JSP技術及其在動態網頁開發中的應用分析[J].浙江水利水電學院學報,2020,32(2):75-77.

【通聯編輯:謝媛媛】

主站蜘蛛池模板: 亚洲经典在线中文字幕| 色九九视频| 手机看片1024久久精品你懂的| 久久www视频| YW尤物AV无码国产在线观看| 国产精品亚洲综合久久小说| 国内黄色精品| 色综合激情网| 免费国产高清精品一区在线| 精品国产美女福到在线直播| 有专无码视频| 欧美有码在线观看| 91久草视频| 久久久国产精品无码专区| 亚洲欧美在线综合一区二区三区| 欧美精品二区| 国产麻豆aⅴ精品无码| 亚洲成综合人影院在院播放| 先锋资源久久| 免费Aⅴ片在线观看蜜芽Tⅴ| 狠狠综合久久| 亚洲无码四虎黄色网站| 国产jizz| 四虎永久免费在线| 97在线碰| 97精品伊人久久大香线蕉| 本亚洲精品网站| 成人午夜久久| 伊人成人在线| 成人日韩视频| 亚洲美女久久| 老司机午夜精品网站在线观看| 亚洲制服丝袜第一页| 欧美精品成人一区二区视频一| 国产原创演绎剧情有字幕的| 国产乱人伦偷精品视频AAA| 四虎免费视频网站| 精品国产女同疯狂摩擦2| 无码人妻免费| 国产午夜精品一区二区三| 亚洲视频免| 一区二区日韩国产精久久| 国产自产视频一区二区三区| 国产激情在线视频| 精品一区国产精品| 免费精品一区二区h| 国产成人精品午夜视频'| 毛片大全免费观看| 久久99精品久久久久久不卡| 欧洲熟妇精品视频| 亚洲成人在线免费观看| 久久99国产乱子伦精品免| 久草视频精品| 国产精品专区第1页| 亚洲精品亚洲人成在线| 免费三A级毛片视频| 992tv国产人成在线观看| 日韩精品高清自在线| 亚洲青涩在线| 永久免费AⅤ无码网站在线观看| 国产av一码二码三码无码| 日韩一区二区三免费高清| 国产精品网址你懂的| 久久不卡国产精品无码| 免费观看国产小粉嫩喷水| 国产日韩精品欧美一区灰| 在线观看欧美国产| 成人日韩精品| 四虎免费视频网站| 国产欧美日韩在线在线不卡视频| 伊人久久青草青青综合| 色吊丝av中文字幕| 午夜丁香婷婷| 99re在线观看视频| 国产资源免费观看| 中文字幕在线一区二区在线| 99在线视频免费| 精品国产黑色丝袜高跟鞋| 亚洲高清无码久久久| 午夜日韩久久影院| 三上悠亚一区二区| 91无码网站|