李盛蘭+吳慶祥
摘要:隨著網(wǎng)絡(luò)的高速發(fā)展,互聯(lián)網(wǎng)進(jìn)入各行各業(yè)并逐漸成為提供收集信息的最優(yōu)方式。人們通過互聯(lián)網(wǎng)進(jìn)行購物、交友、閱讀等等。網(wǎng)上購物已經(jīng)成為了一種非常流行的購物方式。對于學(xué)生和熱愛書籍的人來說,能通過網(wǎng)絡(luò)方便地購買書籍也變成十分必要。于是本人通過調(diào)查了解開發(fā)了本書城系統(tǒng)。本系統(tǒng)基于PHP開發(fā),運(yùn)用MySQL作為后臺數(shù)據(jù)庫,使用易交互的界面使用戶能獲得更好的體驗(yàn),滿足用戶在網(wǎng)上購物時(shí)的基本需求。本系統(tǒng)由前臺與后臺兩部分組成。前臺實(shí)現(xiàn)了注冊登錄、商品展示、購買商品等功能,后臺實(shí)現(xiàn)了用戶管理、訂單管理、商品管理等功能,顧客可以在本網(wǎng)站中查找購買書籍,商家也可以簡單方便的更新及管理商品。
關(guān)鍵詞:PHP;書城系統(tǒng);MySQL
中圖分類號:TP393 文獻(xiàn)標(biāo)識碼:A 文章編號:1009-3044(2017)06-0271-03
Abstract:With the rapid development of the network, and all walks of life into the Internet is becoming the best way to provide the information collected. People make purchases via the Internet, making friends, reading and so on. The online shopping has now become a popular way to shop. For students and people who love books, through the network to easily purchase books has become very necessary. So we developed this investigation by Bookstore system. The system is based PHP developers using MySQL as the backend database, easy to use interactive interface that enables users to get a better experience to meet the basic needs of users on the Internet when shopping. The system consists of two parts front and back. Reception implements registration log browse product information, purchase goods and other functions, the background to achieve user management, order management, merchandise management and other functions, customers can look to buy books on this site, businesses can also be easy to update and manage merchandise.
Key words:PHP; Online Bookstore; MySQL
1 概述
隨著電子商務(wù)的迅猛發(fā)展,人們越來越傾向于在網(wǎng)絡(luò)上購物。網(wǎng)上書店與實(shí)體書店相比有不少優(yōu)點(diǎn)。第一、網(wǎng)上書店不需要實(shí)體店鋪,為賣家節(jié)約了不少成本。第二、商家能夠通過管理系統(tǒng)很方便地了解到庫存、熱銷書籍等信息,可以及時(shí)調(diào)整營銷策略。第三、顧客通過網(wǎng)上書店可以快速地搜索到自己想購買的書籍,節(jié)省了時(shí)間。對于消費(fèi)者和商家來說網(wǎng)上書店是互利雙贏的,具有廣闊的發(fā)展前景。
2 系統(tǒng)具體設(shè)計(jì)
2.1 系統(tǒng)流程
本系統(tǒng)主要包括購買流程和管理流程。其中購買流程包括顧客進(jìn)入網(wǎng)站瀏覽商品,加入購物車時(shí)判斷用戶是否登錄,當(dāng)用戶尚未登錄時(shí)提醒用戶登錄,顧客選購好商品后可下達(dá)訂單。
2.2 功能模塊
本網(wǎng)上書城共分為兩個(gè)模塊:其中前臺模塊包括:會員模塊,商品展示模塊,購物車模塊,訂單模塊,后臺模塊包括權(quán)限管理、用戶管理、分類管理、商品管理等模塊,本系統(tǒng)功能明確,層次清晰。網(wǎng)站的功能圖如圖1所示:
3 系統(tǒng)的具體實(shí)現(xiàn)
用戶進(jìn)入本網(wǎng)站后,首先展示的是主頁面。用戶可進(jìn)行瀏覽商品及注冊登錄等操作,只有當(dāng)用戶登錄后才可以進(jìn)行將商品加入購物車及下訂單等操作。對于后臺界面,首先展示的是登錄界面,只有已管理員身份登錄成功后才可以進(jìn)入后臺管理界面。登錄成功后管理員可以對商品、訂單等進(jìn)行操作。
4 商品展示模塊
用戶進(jìn)入網(wǎng)站后可以通過瀏覽商品分類中的某一類書籍來尋找自己喜歡的圖書,也可以通過搜索欄直接輸入自己想要購買的商品。商品分類及商品展示如圖2,圖3所示,商品搜索如圖4所示:
點(diǎn)擊商品分類時(shí)展示對應(yīng)商品的邏輯:當(dāng)點(diǎn)擊對應(yīng)分類時(shí)把分類id傳到后臺,控制器接收后通過在模型在數(shù)據(jù)庫商品表中查找其分類id等于接收到的分類id的書籍并把數(shù)據(jù)返回給控制器??刂破髂玫綌?shù)據(jù)后把數(shù)據(jù)傳到前臺,前臺渲染展示數(shù)據(jù)。而通過搜索展示商品則是把用戶輸入的關(guān)鍵字傳到后臺,在商品表中查找含有該關(guān)鍵字的商品返回給前臺展示。實(shí)現(xiàn)商品展示功能的部分代碼如下:
GoodslistAction.class.php:
//獲取書籍列表并輸出到前臺
function index(){
Load('extend');
$data = $this->goodslistModel->getGoodslistIndexData($id);
$this->assign('data', $data);
$this->display();
}
GoodslistModel.class.php:
//獲取書籍列表
public function getGoodslistIndexData($id)
{
import('@.ORG.Page');
$condition['brand'] = array('eq', $id); //查找分類相關(guān)的書籍
$condition['putaway'] = array('eq', 1); //查找上架的書籍
$condition['_logic'] = 'and';
$count = $this->tableGoods()->where($condition)->field('id')->count();
$page = new Page($count, 10); // 實(shí)例化分頁類 傳入總記錄數(shù)和每頁顯示的記錄數(shù)
$page->setConfig('header', '個(gè)商品');
$page->setConfig('theme', '共%totalRow%%header% 當(dāng)前%nowPage%?;/?;%totalPage% 頁 %first% %upPage% %linkPage% %downPage% %end%');
$result['goods_list'] = $this->tableGoods()->where($condition)->field('id, title, title_info, inventory, sell_price, pic_one, path')->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
$result['show'] = $page->show(); // 分頁顯示輸出
$result = array_merge($this->thisGoodsSort, $result);
return $result;
}
SearchAction.class.php
function index(){
Load('extend');
$condition['title'] = array('like', '%'.$_GET['keyword'].'%');
$condition['title_info'] = array('like', '%'.$_GET['keyword'].'%');
$condition['item_No'] = array('like', '%'.$_GET['keyword'].'%');
$condition['sell_price'] = array('like', '%'.$_GET['keyword'].'%');
$condition['_logic'] = 'or';
$conditionMap['_complex'] = $condition;
$conditionMap['putaway'] = array('eq', 1);
$data = $this->searchModel->getSearchData($conditionMap); //獲取所有含有該關(guān)鍵詞的數(shù)據(jù)
$this->assign('data', $data);
$this->display(); //展示數(shù)據(jù)
}
用戶可以點(diǎn)擊書籍對應(yīng)的鏈接進(jìn)入商品詳情頁查看書籍的詳細(xì)信息。書籍詳情界面如圖5所示:
商品詳情頁邏輯:用戶點(diǎn)擊商品展示頁的商品時(shí)把對應(yīng)的商品id傳到后臺,后臺通過在數(shù)據(jù)庫商品表中查詢對應(yīng)的id活得商品數(shù)據(jù)并輸出到前臺。當(dāng)用戶添加商品時(shí)首先判斷是否已經(jīng)登錄,若用戶尚未登錄,則提示用戶先登錄才可以進(jìn)行購物。若用戶已登錄,則把商品添加進(jìn)入購物車。添加商品時(shí)先在前臺判斷用戶想要購買的商品數(shù)量,若商品庫存比用戶添加的商品數(shù)量小,則提示用戶商品庫存不夠。
5 結(jié)束語
本模塊的最大特點(diǎn)是其結(jié)構(gòu)清晰,易于實(shí)現(xiàn)。在本模塊的設(shè)計(jì)過程中,某些功能的考慮得還不夠周全,有待在使用體驗(yàn)中去完善。
參考文獻(xiàn):
[1] 方程,任一波,陳明.電子商務(wù)概論[M].北京:電子工業(yè)出版社,2008:19-20.
[2] 徐建波,周新蓮. Web設(shè)計(jì)原理于編程技術(shù)[M].長沙:中南大學(xué)出版社,2005:255-306.
[3] 白志強(qiáng),白志剛.21天學(xué)通PHP[M].北京:電子工業(yè)出版社,2010:23-25.
[4] 姜承堯.MySQL技術(shù)內(nèi)幕:SQL編程[M].北京:機(jī)械工業(yè)出版社,2012:46-67.
[5] 張端金,高曙,楊蘋.計(jì)算機(jī)專業(yè)英語[M]. 武漢理工大學(xué)出版社,2003:6-19.