zoukankan      html  css  js  c++  java
  • 20150418--商品订单+放大镜

    一、下订单准备:

    建表:

    订单信息表:存储主要的订单信息

    订单id、登录用户的id、订单的总金额、    订单的收货人的信息

    1             123         400       梁山宋江

    订单和商品的关联表

    订单的id   商品的id  商品的属性id    购买的数量  商品的单价

    1           12         23,45           10          10

    1           24         45,67           10          20

    1           67                         20          5

    #创建一个订单信息表

    create table it_order(

             id smallint unsigned primary key auto_increment,

             user_id smallint unsigned not null comment '登录用户的id',

             order_sn varchar(32) not null comment '订单号',

             total_price  decimal(10,2) not null comment '订单的总金额',

             consignee  varchar(32) not null comment '收货人的姓名',

             address varchar(64) not null comment '收货人的地址',

             mobile  char(11)  not null comment '收货人的电话',

             pay_status tinyint not null default 0 comment '支付的状态0表示未支付,1表示已经支付',

             shipping  varchar(10) not null comment '配送方式',

             payment  varchar(10) not null comment '支付方式'

    )engine myisam charset utf8;

    #创建一个订单商品表

    create table it_order_goods(

             id smallint unsigned primary key auto_increment,

             order_id smallint unsigned not null comment '订单的id',

             goods_id smallint not null comment '商品的id',

             goods_attr_id varchar(32) not null default '' comment '商品属性id',

             goods_number tinyint unsigned not null comment '购买数量',

             goods_price  decimal(10,2) not null comment '购买商品的单价'

    )engine myisam charset utf8;

    #创建一个收货人的信息表

    create table it_address(

             id smallint unsigned primary key auto_increment,

             consignee  varchar(32) not null comment '收货人的姓名',

             tel varchar(12) not null comment '收货人的电话',

              mobile  char(11)  not null comment '收货人的移动电话',

              address varchar(64) not null comment '收货人的地址',

              post  char(6) not null comment '收货人的邮编'

    )engine myisam charset utf8;

    1、在购物车列表页面添加一个连接,进入下一步完成订单。

    wpsAD6.tmp

    2、在cart控制器添加一个order1方法,进行下订单第一步。

    该方法中:要完成验证用户是否登录,如果没有登录则跳转到登录页面,登录完成后,再跳回来。

    要完成登录用户是否填写收货人的信息,如果没有填写则跳转到填写页面。

    (1)判断用户是否登录。

    wpsAE6.tmp

    要修改UserController.class.php里面登录方法

    wpsB07.tmp

    (2)判断用户是否填写收货人的信息

    wpsB17.tmp

    在当前控制器下面新建一个writeaddress,用于填写收货人的信息。

    并拷贝对应的静态页面,并修改表单

    wpsB38.tmp

    (3)遍历取出的数据

    wpsB48.tmp

    最后控制器里面的代码:

    wpsB68.tmp

    wpsB79.tmp

    二、开始下订单

    1、给order1.html页面修改表单,添加隐藏域。

    2、开始写代码入库。

    wpsB8A.tmp

    wpsBC9.tmp

    wpsBDA.tmp

    3、需要考虑两个问题;

    一个是高并发下订单。

    库存100件

    a  购买100  可以

    b 购买100  可以

    一个是事务问题。

    要操作的表,

    要用innodb引擎,it_goods表(库存表)  it_order 表  it_order_goods表

    开启事务:

    mysql_query('START TRANSACTION');

    回滚事务:

    mysql_query('ROLLBACK');

    提交事务:

    mysql_query('COMMIT');

    wpsBEA.tmp

    wpsBFB.tmp

    wpsBFC.tmp

    三、后台订单列表,取出对应商品数据

    1、在后台创建一个order的模块,创建ordercontroller的控制器。

    wpsC1C.tmp

    wpsC3D.tmp

    2、给订单号区域添加鼠标滑过事件

    在订单列表页面添加一个隐藏div

    wpsC4D.tmp

    给订单编号区域添加事件,

    wpsC6D.tmp

    3、使用ajax取出具体订单里面的商品,

    wpsC7E.tmp

    js 代码:

    wpsCBE.tmp

    4、在order控制器定义的方法,showgoods方法。

    wpsCED.tmp

    showgoods方法,对应的模板页面遍历数据

    wpsD0E.tmp

    四、实现放大镜效果,使用一个插件

    wpsD0F.tmpwpsD1F.tmpwpsD20.tmpwpsD21.tmpwpsD22.tmpwpsD23.tmpwpsD34.tmpwpsD35.tmpwpsD36.tmpwpsD47.tmp

    五、浏览历史

    wpsD48.tmp

    思路:浏览历史是保存到cookie里面的。

    当浏览商品的详情页面时,把浏览信息添加到cookie 里面

    image

  • 相关阅读:
    故障分析 | 全局读锁一直没有释放,发生了什么?
    日常笔记
    BCC观测工具的使用
    wireshark的应用
    SQL基础之实现累加值
    SQL查询语句使用rand()的执行效率与优化
    MySQL主从复制相关问题
    LVM不停机扩容
    gtid跳过错误的方法
    IO诊断文档
  • 原文地址:https://www.cnblogs.com/lifushan/p/5472198.html
Copyright © 2011-2022 走看看