废话步多说,我们开工,

数据库设计如下所示:

SQL语句如下:

#创建数据库
create database shopp charset utf8;#选择数据库
use shopp;/*------------------------------------商品模块---------------------------------------*/
#创建商品类别表
create table cz_category(cat_id smallint unsigned not null auto_increment primary key comment '商品类别ID',cat_name varchar(30) not null default '' comment '商品类别名称',parent_id smallint unsigned not null default 0 comment '商品类别父ID',cat_desc varchar(255) not null default '' comment '商品类别描述',sort_order tinyint not null default 50 comment '排序依据',unit varchar(15) not null default '' comment '单位',is_show tinyint not null default 1 comment '是否显示,默认显示',index pid(parent_id)
)engine=MyISAM charset=utf8;#创建商品品牌表
create table cz_brand(brand_id smallint unsigned not null auto_increment primary key comment '商品品牌ID',brand_name varchar(30) not null default '' comment '商品品牌名称',brand_desc varchar(255) not null default '' comment '商品品牌描述',url varchar(100) not null default '' comment '商品品牌网址',logo varchar(50) not null default '' comment '品牌logo',sort_order tinyint unsigned not null default 50 comment '商品品牌排序依据',is_show tinyint not null default 1 comment '是否显示,默认显示'
)engine=MyISAM charset=utf8;#创建商品类型表
create table cz_goods_type(type_id smallint unsigned not null auto_increment primary key comment '商品类型ID',type_name varchar(50) not null default '' comment '商品类型名称'
)engine=MyISAM charset=utf8;#创建商品属性表
create table cz_attribute(attr_id smallint unsigned not null auto_increment primary key comment '商品属性ID',attr_name varchar(50) not null default '' comment '商品属性名称',type_id smallint not null default 0 comment '商品属性所属类型ID',attr_type tinyint not null default 1 comment '属性是否可选 0 为唯一,1为单选,2为多选',attr_input_type tinyint not null default 1 comment '属性录入方式 0为手工录入,1为从列表中选择,2为文本域',attr_value text comment '属性的值',sort_order tinyint not null default 50 comment '属性排序依据',index type_id(type_id)
)engine=MyISAM charset=utf8;#创建商品表
create table cz_goods(goods_id int unsigned not null auto_increment primary key comment '商品ID',goods_sn varchar(30) not null default '' comment '商品货号',goods_name varchar(100) not null default '' comment '商品名称',goods_brief varchar(255) not null default '' comment '商品简单描述',goods_desc text comment '商品详情',cat_id smallint unsigned not null default 0 comment '商品所属类别ID',brand_id smallint unsigned not null default 0 comment '商品所属品牌ID',market_price decimal(10,2) not null default 0 comment '市场价',shop_price decimal(10,2) not null default 0 comment '本店价格',promote_price decimal(10,2) not null default 0 comment '促销价格',promote_start_time int unsigned not null default 0 comment '促销起始时间',promote_end_time int unsigned not null default 0 comment '促销截止时间',goods_img varchar(50) not null default '' comment '商品图片',goods_thumb varchar(50) not null default '' comment '商品缩略图',goods_number smallint unsigned not null default 0 comment '商品库存',click_count int unsigned not null default 0 comment '点击次数',type_id smallint unsigned not null default 0 comment '商品类型ID',is_promote tinyint unsigned not null default 0 comment '是否促销,默认为0不促销',is_best tinyint unsigned not null default 0 comment '是否精品,默认为0',is_new tinyint unsigned not null default 0 comment '是否新品,默认为0',is_hot tinyint unsigned not null default 0 comment '是否热卖,默认为0',is_onsale tinyint unsigned not null default 1 comment '是否上架,默认为1',add_time int unsigned not null default 0 comment '添加时间',index cat_id(cat_id),index brand_id(brand_id),index type_id(type_id)
)engine=MyISAM charset=utf8;#创建商品属性对应表
create table cz_goods_attr(goods_attr_id int unsigned not null auto_increment primary key comment '编号ID',goods_id int unsigned not null default 0 comment '商品ID',attr_id smallint unsigned not null default 0 comment '属性ID',attr_value varchar(255) not null default '' comment '属性值',attr_price decimal(10,2) not null default 0 comment '属性价格',index goods_id(goods_id),index attr_id(attr_id)
)engine=MyISAM charset=utf8;#创建商品相册表
create table cz_galary(img_id int unsigned not null auto_increment primary key comment '图片编号',goods_id int unsigned not null default 0 comment '商品ID',img_url varchar(50) not null default '' comment '图片URL',thumb_url varchar(50) not null default '' comment '缩略图URL',img_desc varchar(50) not null default '' comment '图片描述',index goods_id(goods_id)
)engine=MyISAM charset=utf8;/*------------------------------------商品模块 end-----------------------------------*//*------------------------------------用户模块---------------------------------------*/
#创建用户表
create table cz_user(user_id int unsigned not null auto_increment primary key comment '用户编号',user_name varchar(50) not null default '' comment '用户名',email varchar(50) not null default '' comment '电子邮箱',password char(32) not null default '' comment '用户密码,md5加密',reg_time int unsigned not null default 0 comment '用户注册时间'
)engine=MyISAM charset=utf8;#创建用户收货地址表
create table cz_address(address_id int unsigned not null auto_increment primary key comment '地址编号',user_id int unsigned not null default 0 comment '地址所属用户ID',consignee varchar(60) not null default '' comment '收货人姓名',province smallint unsigned not null default 0 comment '省份,保存是ID',city smallint unsigned not null default 0 comment '市',district smallint unsigned not null default 0 comment '区',street varchar(100) not null default '' comment '街道地址',zipcode varchar(10) not null default '' comment '邮政编码',telephone varchar(20) not null default '' comment '电话',mobile varchar(20) not null default '' comment '移动电话',index user_id(user_id)
)engine=MyISAM charset=utf8;#创建地区表,包括省市区三级
create table cz_region(region_id smallint unsigned not null auto_increment primary key comment '地区ID',parent_id smallint unsigned not null default 0 comment '父ID',region_name varchar(30) not null default '' comment '地区名称',region_type tinyint unsigned not null default 1 comment '地区类型 1 省份 2 市 3 区(县)'
)engine=MyISAM charset=utf8;#创建购物车表
create table cz_cart(cart_id int unsigned not null auto_increment primary key comment '购物车ID',user_id int unsigned not null default 0 comment '用户ID',goods_id int unsigned not null default 0 comment '商品ID',goods_name varchar(100) not null default '' comment '商品名称',goods_img varchar(50) not null default '' comment '商品图片',goods_attr varchar(255) not null default '' comment '商品属性',goods_number smallint unsigned not null default 1 comment '商品数量',market_price decimal(10,2) not null default 0 comment '市场价格',goods_price decimal(10,2) not null default 0 comment '成交价格',subtotal decimal(10,2) not null default 0 comment '小计'
)engine=MyISAM charset=utf8;
/*------------------------------------用户模块 end-----------------------------------*//*------------------------------------订单模块---------------------------------------*/
#创建送货方式表
create table cz_shipping(shipping_id tinyint unsigned not null auto_increment primary key comment '编号',shipping_name varchar(30) not null default '' comment '送货方式名称',shipping_desc varchar(255) not null default '' comment '送货方式描述',shipping_fee decimal(10,2) not null default 0 comment '送货费用',enabled tinyint unsigned not null default 1 comment '是否启用,默认启用'
)engine=MyISAM charset=utf8;#创建支付方式表
create table cz_payment(pay_id tinyint unsigned not null auto_increment primary key comment '支付方式ID',pay_name varchar(30) not null default '' comment '支付方式名称',pay_desc varchar(255) not null default '' comment '支付方式描述',enabled tinyint unsigned not null default 1 comment '是否启用,默认启用'
)engine=MyISAM charset=utf8;#创建订单表
create table cz_order(order_id int unsigned not null auto_increment primary key comment '订单ID',order_sn varchar(30) not null default '' comment '订单号',user_id int unsigned not null default 0 comment '用户ID',address_id int unsigned not null default 0 comment '收货地址id',order_status tinyint unsigned not null default 0 comment '订单状态 1 待付款 2 待发货 3 已发货 4 已完成',postscripts varchar(255) not null default '' comment '订单附言',shipping_id tinyint not null default 0 comment '送货方式ID',pay_id tinyint not null default 0 comment '支付方式ID',goods_amount decimal(10,2) not null default 0 comment '商品总金额',order_amount decimal(10,2) not null default 0 comment '订单总金额',order_time int unsigned not null default 0 comment '下单时间',index user_id(user_id),index address_id(address_id),index pay_id(pay_id),index shipping_id(shipping_id)
)engine=MyISAM charset=utf8;#创建订单明细表,即商品订单关系表(多对多)
create table cz_order_goods(rec_id int unsigned not null auto_increment primary key comment '编号',order_id int unsigned not null default 0 comment '订单ID',goods_id int unsigned not null default 0 comment '商品ID',goods_name varchar(100) not null default '' comment '商品名称',goods_img varchar(50) not null default '' comment '商品图片',shop_price decimal(10,2) not null default 0 comment '商品价格',goods_price decimal(10,2) not null default 0 comment '成交价格',goods_number smallint unsigned not null default 1 comment '购买数量',goods_attr varchar(255) not null default '' comment '商品属性',subtotal decimal(10,2) not null default 0 comment '商品小计'
)engine=MyISAM charset=utf8;/*------------------------------------订单模块 end-----------------------------------*/#创建后台管理员表
create table cz_admin(admin_id smallint unsigned not null auto_increment primary key comment '管理员编号',admin_name varchar(30) not null default '' comment '管理员名称',password char(32) not null default '' comment '管理员密码',email varchar(50) not null default '' comment '管理员邮箱',add_time int unsigned not null default 0 comment '添加时间'
)engine=MyISAM charset=utf8;#插入一条记录作为管理员 用户名和密码均为admin
insert into cz_admin(admin_name,password,email) values('admin','21232f297a57a5a743894a0e4a801fc3','admin@itcast.cn');

首先我们将thinkphp文件都解压到环境目录下的shop文件夹下

然后将里面多余的东西都干掉,留下public文件夹和thinkphp文件夹,即可,别的东西干掉,

然后我们新建一个名字叫index.php的文件,里面的配置文件可以按以下方法进行自定义:

<?php// 定义项目目录define("APP_PATH",'./Shop/');// 开启调试define("APP_DEBUG",true);// 引入ThinkPHP入口文件require "./ThinkPHP/Thinkphp.php";

我们打开shop目录下发现了Common和Home以及Runtime这三个文件夹

那么我们第一个目标是完成网站后台的首页吧,那么我们就直接将Home的文件夹复制一份出来,并且改名为Admin这样就可以分出前后台目录文件了

下一步是在shopp\shop\Common\Conf\config.php配置文件上设置下后台的配置文件和数据库的链接方式了,而且里面也可以一块开启session到时候不用那么麻烦,一个个的去打开了,如下所示:

<?php
return array(//'配置项'=>'配置值'//系统中允许访问的模块(前后台)'MODULE_ALLOW_LIST'      =>  array('Home','Admin'),//配置默认进入模块Home'DEFAULT_MODULE'         =>     'Home',//默认模块//禁止在模版中使用php代码  默认为false//'TMPL_DENY_PHP'=>false;//数据库配置'DB_TYPE'               =>  'mysql',     // 数据库类型'DB_HOST'               =>  'localhost', // 服务器地址'DB_NAME'               =>  'shopp',          // 数据库名'DB_USER'               =>  'root',      // 用户名'DB_PWD'                =>  '',          // 密码'DB_PORT'               =>  '3306',        // 端口'DB_PREFIX'             =>  'cz_',    // 数据库表前缀/*开启SESSION开关 */'SESSION_AUTO_START'    =>  true,    // 是否自动开启Session

);

然后在Admin目录下找到IndexController的控制器,将里面的

namespace Home\Controller;

改成namespace Admin\Controller;

然后用浏览器进行访问下http://localhost/shopp/index.php/admin,看下是否能正常见到笑脸,如果能正常看到,那么恭喜您,您成成功配置成功Thinkphp的环境了

下一步我们就是在Admin---View---目录下创建Index的文件夹,然后将网站模版放进去,

按正常来说,我们访问http://localhost/shopp/index.php/admin应该可以看到一些东西才是对的,但是我打开发现报了一大堆的错,不过没关系,这都是小问题,还没全部加载进来,因为我们框架是由分针技术实现的,而且框架上的路径还没成功引入,那么我们就打开index.html让他们进行引入

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>myshop管理中心</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><frameset rows="51,*" framespacing="0" border="0"><frame src="__MODULE__/Index/top" id="header-frame" name="header-frame" frameborder="no" scrolling="no"><frameset cols="180, 10, *" framespacing="0" border="0" id="frame-body"><frame src="__MODULE__/Index/menu" id="menu-frame" name="menu-frame" frameborder="no" scrolling="yes"><frame src="__MODULE__/Index/drag" id="drag-frame" name="drag-frame" frameborder="no" scrolling="no"><frame src="__MODULE__/Index/main" id="main-frame" name="main-frame" frameborder="no" scrolling="yes"></frameset>
</frameset><frameset rows="0, 0" framespacing="0" border="0"><frame src="http://api.ecshop.com/record.php?mod=login&url={$shop_url}" id="hidd-frame" name="hidd-frame" frameborder="no" scrolling="no"></frameset>
</head>
</html>

上面的__MODULE__他目前的指向是当前admin文件夹下,Index是控制器,top之类的是方法,那么我们就打开IndexController.class.php控制器设置以下方法让他进行输出

<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends Controller {public function index(){$this -> display();}public function top(){$this -> display();}public function menu(){$this -> display();}public function drag(){$this -> display();}public function main(){$this -> display();}
}

这样设置好了,但是打开http://localhost/shopp/index.php/admin/  后还是发现不能正常显示,原因也很简单,就是因为他的css和js之类的没引入进来,那么我们的解决方法是在项目的更目录下新建一个Public的目录然后在public里面建立一个叫Admin的目录,如下图所示:

然后在shopp\Shop\Common\Conf\config.php里面进行自定义目录,目的是为了更加的方便引入各种样式和图片,代码如下所示:

<?php
return array(//'配置项'=>'配置值'//系统中允许访问的模块(前后台)'MODULE_ALLOW_LIST'      =>  array('Home','Admin'),//配置默认进入模块Home'DEFAULT_MODULE'         =>     'Home',//默认模块//数据库配置'DB_TYPE'               =>  'mysql',     // 数据库类型'DB_HOST'               =>  'localhost', // 服务器地址'DB_NAME'               =>  'shopp',          // 数据库名'DB_USER'               =>  'root',      // 用户名'DB_PWD'                =>  '',          // 密码'DB_PORT'               =>  '3306',        // 端口        'DB_PREFIX'             =>  'cz_',    // 数据库表前缀/*开启SESSION开关 */'SESSION_AUTO_START'    =>  true,    // 是否自动开启Session//自定义目录,方便样式的引入'TMPL_PARSE_STRING'         =>  array(//后台的'__ADMIN__'=>'/Public/Admin',    ),);

路径测试了,那么下一步就是来对wamp进行一个配置,

打开后进入里面拉到最低下加上

Include "D:/wamp/alias/*"
<VirtualHost *:80>DocumentRoot "D:\wamp\www\shopp"ServerName www.shop.com
</VirtualHost>

这段代码,因为我的wamp是放在D盘下的,所以我的DocumentRoot路径就指向那,大家可以看情况而定,

然后修改下host文件C:\Windows\System32\drivers\etc\hosts文件夹拉到最底部加上

127.0.0.1        www.shop.com

这段代码即可模拟出服务器端的环境了

对了别忘了从其apache噢,嘻嘻

然后对这下面的几个文件涉及到图片和样式的都该下即可,

如:

<link href="__ADMIN__/styles/general.css" rel="stylesheet" type="text/css" /><img src="__ADMIN__/images/ecshop_logo.gif" alt="ECSHOP - power for e-commerce" /><script type="text/javascript" src="__ADMIN__/js/transport.js"></script>

改成这样即可。

替换成功后首页即会变成这样

看上去没那么磕碜啦,嘻嘻..

不过我们在实际的情况下都是用到批量替换的噢,别手动一个个去换,有写模版太多图片之类的了,会改到发晕的噢..

转载于:https://www.cnblogs.com/leigood/p/4943311.html

夺命雷公狗ThinkPHP项目之----商城6数据库设计和完成后台首页相关推荐

  1. 夺命雷公狗ThinkPHP项目之----商城1项目整体架构

    夺命雷公狗项目之---商城 本人准备更新套基于tp下开发的商城的项目,为啥呢?原因和简单,本人没使用过框架开发商城,准备用一些时间来开发套B2C的商城系统.. 项目规划: 1:项目整体架构 用户部分 ...

  2. 夺命雷公狗ThinkPHP项目之----商城10商品属性管理

    我们一般做项目前就要分析业务逻辑先,这次也不例外. attr_type:是指属性的类型,有唯一,单选和多选之分 唯一属性,是指用户在购买商品时,可以看到的扩展属性如下图所示: 单选属性,是指用户在购买 ...

  3. 夺命雷公狗ThinkPHP项目之----商城9商品后台无限极分类

    无限极分类,几乎在每个网站上都会用到的,因此而重要. 先来对数据表进行分析 parent_id:表示当前分类的父id,他是实现无限级分类的关键 无限级分类,主要从两个方面进行考虑的. 1.数据库的设计 ...

  4. 夺命雷公狗TP3.2.3商城2-----后台模版引入和后台控制器的创建

    首先我们来到D:\phpStudy\WWW\shop\WEB  目录下,将Home目录进行复制一份,并且改名为Admin,如下所示: 然后将我们准备好的后台首页模版放入   D:\phpStudy\W ...

  5. 夺命雷公狗ThinkPHP项目之----企业网站2之数据库的快速设计

    我们在一个项目的时候,花费最多事件的估计还是数据库的时间了,我们的数据库暂时就这样设计好了: 暂时我们的数据库就这样设计好了用下先,建好后如下所示: 转载于:https://www.cnblogs.c ...

  6. 夺命雷公狗ThinkPHP项目之----企业网站13之文章列表页的实现(主要是分页的实现)...

    列表页这个其实是比较简单的一个,直接遍历除数据即可: public function lists(){//$mod = M("Article")->select();//$t ...

  7. 夺命雷公狗ThinkPHP项目之----企业网站25之网站前台面包屑导航URL的完善

    如果想取出面包屑导航的url那么就必须在model层里面进行多取一个了: <?phpnamespace Home\Model;use Think\Model;class CategoryMode ...

  8. 夺命雷公狗TP3.2.3商城的搭建开篇1

    这里是最后次是最后一次写TP323框架的项目类教程了,大家请见谅,毕竟tp5都出来这么长时间了,我看是时候去研究一下了, 首先我们还是老规矩先在index.php里面进行修改一下: <?php/ ...

  9. 夺命雷公狗TP3.2.3商城5-----管理员的列表页和分页

    列表也其实也很简单,说白了直接在数据库取出数据,然后直接遍历到模版即可,首先来修改Admin控制器的add方法: 然后到add模板页里使用volist进行遍历: 然后测试下看看数据是否成功被取出: 然 ...

最新文章

  1. python怎么输入代码-如何编写python代码
  2. before和after怎么区分_如何区分before和after~有时候觉得两者可以通用
  3. 动态分辨率是什么意思_b站么么直播最新动态里都有啥 b站什么意思
  4. 容器学习 之 共享数据(十六)
  5. linux 安装监控系统,CentOS7安装性能监控系统
  6. PHP直播源码js判断浏览器版本
  7. 一步步用python制作游戏外挂【转】
  8. 【转】傅里叶分析之掐死教程(完整版)
  9. 深度学习之编程语言Python(Ⅰ)
  10. [图像处理-1]:颜色中英文对照表 颜色名字 色彩名称
  11. Linux一句话将文件夹的用户用户组设置为wps:wps
  12. 深搜回溯与不回溯的区别
  13. win8.1系统在线安装VS2017出现Internet连接问题的解决办法
  14. 视觉培训2 机器学习基础知识学习
  15. Git Tortoisegit的基础安装与登录
  16. 云服务器的登陆密码忘记了怎么办?
  17. 微信小程序---实现tab选项卡
  18. 经典PID控制器的缺陷
  19. 你是我今生最美的相遇
  20. java中感叹号啥意思_感叹号暗示什么意思

热门文章

  1. Brightcove推出新的季度视频指数报告,对构成OTT增长根源的消费者行为进行深入分析
  2. 客户关系管理挑战:如何保持客户满意度并提高业绩?
  3. 【C#通过共享内存MemoryMappedFile解码和播放WavPack等PCM音频】
  4. 批量下载sra文件linux,NCBI下载SRA数据的4种方法
  5. Java写一个黄金矿工小游戏
  6. ASP.NETMVC - 山东省职称申报评审系统
  7. Ubuntu 复制文件夹到移动硬盘的笔记
  8. keepalived实现vip的原理简析
  9. 用计算机弹心做的乐谱,抖音计算器音乐乐谱大全_抖音计算器音乐乐谱汇总_游戏吧...
  10. 口才训练,简单、易行、见效的训练方法大全!