>php教程 >php手册 >如何把相同的订单号合并到一起?

如何把相同的订单号合并到一起?

WBOY
WBOY원래의
2016-06-07 11:39:233609검색

怎样把订单号相同的信息合并起来呢,我该怎样改变数组结构呢?类似淘宝的订单
/**********定单基本信息表******************/
drop table if exists sh_order;
create table sh_order
(
id mediumint unsigned not null auto_increment,
order_sn char(16) not null comment '定单编号',
member_id mediumint unsigned not null comment '会员id',
addtime int unsigned not null comment '下单时间',
pay_status enum("是","否") not null default '否' comment '支付状态',
post_status enum("是","否") not null default '否' comment '发货状态',
total_price decimal(10,2) not null comment '总价',
postage decimal(10,2) not null comment '邮费',
pay_time int unsigned not null default '0' comment '付款时间',
pay_method enum("支付宝") not null default '支付宝' comment '支付方式',
post_method enum("顺风","圆通") not null comment '配送方式',
shr_name varchar(30) not null comment '收货人',
shr_province varchar(30) not null comment '收货人省',
shr_city varchar(30) not null comment '收货城市',
shr_area varchar(30) not null comment '收货地区',
shr_address varchar(150) not null comment '收货地址',
shr_postcode varchar(30) not null comment '收货邮编',
shr_mobile varchar(30) not null comment '收货人手机',
primary key (id),
key member_id(member_id),
key order_sn(order_sn),
key addtime(addtime)
)engine=InnoDB default charset=utf8 comment '定单基本信息表';

/****************订单商品表**************************/
drop table if exists sh_order_goods;
create table sh_order_goods
(
id mediumint unsigned not null auto_increment,
order_id mediumint unsigned not null comment '定单id',
goods_id mediumint unsigned not null comment '商品id',
goods_name varchar(60) not null comment '商品名称',
goods_attr_id varchar(150) not null default '' comment '商品属性id',
price decimal(10,2) not null comment '购买时的价格',
goods_number int unsigned not null comment '购买的数量',
primary key (id),
key order_id(order_id),
key goods_id(goods_id)
)engine=InnoDB default charset=utf8 comment '定单商品表';

/**************商品表*******************/
drop table if exists sh_goods;
create table sh_goods
(
id mediumint unsigned not null auto_increment,
sm_logo varchar(150) not null default '' comment 'logo的缩略图路径(150*150)',
logo varchar(150) not null default '' comment 'logo的路径',
sm_show_pic varchar(150) not null default '' comment '展示图的缩略图路径(150*150)',
show_pic varchar(150) not null default '' comment '展示图的原图路径',
goods_brand_id mediumint unsigned not null comment '商品品牌id',
goods_name varchar(60) not null comment '商品名称',
market_price decimal(10,2) not null comment '市场价',
shop_price decimal(10,2) not null comment '本店价',
is_on_sale enum('是','否') not null default '是' comment '是否上架',
goods_number mediumint unsigned not null default '0' comment '库存量',
type_id mediumint unsigned not null default '0' comment '类型id',
goods_desc text comment '商品描述',
order_num tinyint unsigned not null default '100' comment '排序数字',
addtime int unsigned not null comment '添加时间',
primary key (id),
key shop_price(shop_price),
key is_on_sale(is_on_sale),
key addtime(addtime),
key order_num(order_num)
)engine=MyISAM default charset=utf8 comment '商品';

/**************商品属性表************************/
drop table if exists sh_goods_attr;
create table sh_goods_attr
(
id mediumint unsigned not null auto_increment,
goods_id mediumint unsigned not null comment '商品id',
attr_id mediumint unsigned not null comment '属性id',
attr_value varchar(150) default '' not null comment '属性的值',
primary key (id),
key goods_id(goods_id),
key attr_id(attr_id)
)engine=MyISAM default charset=utf8 comment '商品属性';





// Model模型中,根据会员ID从数据库中取出会员自己的订单,
public function getOrder($mid)
{
$orderModel = M('Order');
$orderData = $orderModel->field('a.order_sn, a.addtime, a.shr_name,
c.goods_name, c.sm_logo, b.goods_number,
b.price, d.attr_value, a.postage, a.post_status')
->alias('a')->join('LEFT JOIN sh_order_goods b ON a.id = b.order_id')->
join('LEFT JOIN sh_goods c ON b.goods_id = c.id')->
join('LEFT JOIN sh_goods_attr d ON b.goods_attr_id = d.id')
->where('a.member_id='.$mid)->select();
}

//在Controller控制器用户中心里调用
public function center()
{
if(session('id'))
{
$mid = session('id');//session('id')就是会员ID
$memberModel = D('Member/Member');
$orderData = $memberModel->getOrder($mid);
$this->assign('orderData',$orderData);
}
else
{
redirect('login');
}
$this->display();
}

HTML页面中输出:
$v):?>









取消订单


这个是显示出来的订单页面:
如何把相同的订单号合并到一起?
如何改为淘宝这样的呢?我该如何改变数组结构呢?
如何把相同的订单号合并到一起?

AD:真正免费,域名+虚机+企业邮箱=0元

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.