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.

【通聯編輯:謝媛媛】

主站蜘蛛池模板: 五月天福利视频| 无码aⅴ精品一区二区三区| 狠狠色狠狠综合久久| 亚洲成人播放| 亚洲男女在线| 国产H片无码不卡在线视频| 呦女亚洲一区精品| av一区二区三区高清久久| 成人字幕网视频在线观看| 国产91精品调教在线播放| 亚洲无码免费黄色网址| 农村乱人伦一区二区| 国产激情在线视频| 毛片免费试看| 亚洲成a人片| 久久一级电影| 免费高清a毛片| 久久亚洲综合伊人| 欧美v在线| 亚洲成人网在线观看| 天堂成人在线视频| 日韩欧美在线观看| 日本日韩欧美| 在线人成精品免费视频| 亚洲人在线| 国产又大又粗又猛又爽的视频| 极品av一区二区| 5555国产在线观看| 91人人妻人人做人人爽男同| 波多野结衣一二三| 五月天天天色| 呦系列视频一区二区三区| 制服丝袜无码每日更新| 亚洲欧美国产视频| 手机在线免费毛片| 久久五月视频| 精品乱码久久久久久久| 国产又色又爽又黄| 欧美国产另类| P尤物久久99国产综合精品| 毛片网站在线播放| 91精品国产自产91精品资源| 亚洲男女在线| 456亚洲人成高清在线| 亚洲欧美自拍一区| 国产经典在线观看一区| 欧美中出一区二区| 国产农村1级毛片| 久久精品国产一区二区小说| 亚洲男人的天堂视频| www.精品视频| 91久久性奴调教国产免费| 天天综合色天天综合网| 中文字幕有乳无码| 人妻91无码色偷偷色噜噜噜| 99在线小视频| 亚洲第一黄片大全| 香蕉久久永久视频| 日本精品影院| 亚洲国产欧美国产综合久久| 人妻夜夜爽天天爽| 91人妻日韩人妻无码专区精品| 午夜在线不卡| 国产黄色片在线看| 91精品福利自产拍在线观看| 中字无码av在线电影| 亚洲日本一本dvd高清| 香港一级毛片免费看| 成人免费视频一区| 天堂岛国av无码免费无禁网站| 久久精品日日躁夜夜躁欧美| 女人18一级毛片免费观看| 国产成人综合久久精品下载| 国产亚洲视频中文字幕视频| jizz在线观看| 国产成人亚洲欧美激情| 亚洲一区毛片| 日本免费新一区视频| 国产原创演绎剧情有字幕的| 欧美a级完整在线观看| 成人va亚洲va欧美天堂| 欧美日韩中文国产|