商城-如何把相同的订单号合并到一起?
商城php订单模块
/**********定单基本信息表******************/
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):?>
取消订单

怎样把订单号相同的合并起来呢,我该怎样改变数组结构呢?类似淘宝的订单


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

In this article, we're going to explore the notification system in the Laravel web framework. The notification system in Laravel allows you to send notifications to users over different channels. Today, we'll discuss how you can send notifications ov

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot
