PHP交易详情有感
交易详情
一般都是按月的,
包含,交易日期,交易金额,交易状态(可有可无)
总交易额等等。
如果数据多的话,最好能够分页。
最好能够查询具体的哪一个商户。
1.模拟sql实现查询功能
SELECT a.id as user_id,a.username,b.name as store_name,c.id as order_id,c.price,c.paytime,c.sendtime,c.receivetime FROM sh_user a
LEFT JOIN sh_store b on a.id = b.user_id
LEFT JOIN sh_order c ON b.id = c.store_id
WHERE a.opener_id = 1 and a.`status` = 1 and c.status = 1 ORDER BY c.id desc; SELECT count(b.id) as count ,sum(c.price) as total_price FROM sh_user a
LEFT JOIN sh_store b on a.id = b.user_id
LEFT JOIN sh_order c ON b.id = c.store_id
WHERE a.opener_id = 1 and a.`status` = 1 and c.status = 1;
sql查询出来了,基本上就搞定了,剩下的就是用php,thinkphp实现这个查询功能,加入一些逻辑与条件。
// 商户交易
public function trade(){
if($type = $this->_request('type','trim')){
$s_year = $this->_request('s_year','trim');
$s_month = $this->_request('s_month','trim');
$s_user_id = $this->_request('s_user_id','trim,intval');
$this->assign('s_user_id',$s_user_id);
if($type == 'last'){ // 获取上一月
if($s_month==1){
$useYear = $s_year-1;
$useMonth = 12;
}else{
$useYear = $s_year;
$useMonth = $s_month-1;
}
} if($type == 'next'){ // 获取下一月
if($s_month==12){
$useYear = $s_year+1;
$useMonth = 1;
}else{
$useYear = $s_year;
$useMonth = $s_month+1;
}
} if ($type == 'selectuser'){
$useYear = $s_year;
$useMonth = $s_month;
}
}else{
// 获取当前年 月
$useYear = date('Y');
$useMonth = date('m');
}
$this->assign('s_year',$useYear);
$this->assign('s_month',$useMonth); $b_time = strtotime($useYear.'-'.$useMonth.'-'.'');
$e_time = strtotime($useYear.'-'.$useMonth.'-'.date('t',strtotime($b_time)).' 23:59:59');
if(isset($s_user_id) && $s_user_id > 0){
$where['a.id'] = $s_user_id;
}
$where['a.opener_id'] = $this->opener_id;
$where['a.status'] = 1; // 合法的用户
$where['c.status'] = 1; // 合法的订单
$where['c.paytime'] = array(array('gt',$b_time),array('lt',$e_time),'and');
$count_and_totalprice = M()->table('sh_user a')
->join('sh_store b on a.id = b.user_id')
->join('sh_order c on b.id = c.store_id')
->where($where)
->field('count(b.id) as count ,sum(c.price) as totalprice')
->find();
$count = $count_and_totalprice['count'];
$totalprice = $count_and_totalprice['totalprice'] ? $count_and_totalprice['totalprice'] : 0;
$Page = new Page($count, 10);
$list = M()->table('sh_user a')
->join('sh_store b on a.id = b.user_id')
->join('sh_order c on b.id = c.store_id')
->where($where)
->order('c.id desc')
->limit($Page->firstRow.','.$Page->listRows)
->field('a.id as user_id,a.username,b.name as store_name,c.id as order_id,c.price,c.paytime,c.sendtime,c.receivetime')
->select();
foreach ($list as $k => $v) {
if($v['sendtime'] == 0 && $v['receivetime'] == 0){
$list[$k]['progress'] = ''; // 已付款,待发货
}
if($v['sendtime'] > 0 && $v['receivetime'] == 0){
$list[$k]['progress'] = ''; // 已发货,待签收
}
if($v['sendtime'] > 0 && $v['receivetime'] > 0){
$list[$k]['progress'] = ''; // 交易完成
}
} // 获取拓展员用户
$user_list = M('User')
->where(array('opener_id'=>$this->opener_id))
->field('id,username')
->select();
$this->assign('user_list',$user_list);
$this->assign('totalprice',$totalprice);
$this->assign('page',$Page->show());
$this->assign('list', $list);
$this->display();
}
html部分
<include file="Public:head" title="交易详情" />
<style>
.top {
background-color: #eee;
height: 50px;
line-height: 50px;
font-size: 18px;
border-bottom: #ddd 1px solid;
margin-bottom: -1px;
} .list-group{
border: 1px solid #DDDDDD;
}
.list-group .list-group-item {
text-align: left;
line-height: 25px;
border: none;
background-color: #F9F9F9;
font-size: 14px;
} #select-date {
padding: 0px 10px;
} #select-date .date-txt {
font-size: 18px;
} #total {
width: 140px;
height: 140px;
background-color: #EC6C00;
margin: auto;
} #total .money-txt {
color: white;
padding-top: 10px;
} #datalist {
margin-top: 30px;
} #relief .form-control{
margin-top: 10px;
margin-bottom: 10px;
/*background-color: #FFCE42;*/
} .page{
margin-right: 10px;
margin-bottom: 20px;
} .table th {
color: #C4C4C4;
} .table tbody tr td+td+td {
color: #D3964F;
}
</style>
<script type="text/javascript">
function lastMonth(){
todo('last');
} function nextMonth(){
todo('next');
}
function selectUser(){
todo('selectuser');
}
function todo(type){
var s_year = $('#s_year').val();
var s_month = $('#s_month').val();
var s_user_id = $('#s_user_id').val();
window.location.href="{sh::U('User/trade')}&s_year="+s_year+"&s_month="+s_month+"&s_user_id="+s_user_id+"&type="+type;
}
</script> <body>
<div data-example-id="list-group-btns" class="bs-example">
<div id="select-date">
<ul class="pager">
<li class="previous"><a onclick="lastMonth();"><span aria-hidden="true">←</span> </a></li>
<span class="date-txt"><strong>{sh:$s_year}.{sh:$s_month}</strong>
<present name="paymentData"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span></present>
</span>
<input type="text" id="s_year" value="{sh:$s_year}" hidden="hidden">
<input type="text" id="s_month" value="{sh:$s_month}" hidden="hidden">
<li class="next"><a onclick="nextMonth();"><span aria-hidden="true">→</span></a></li>
</ul>
</div>
<div id="relief">
<select id="s_user_id" onchange="selectUser();" class="form-control btn-success">
<option value="">全部商户</option>
<volist name="user_list" id="vo">
<option value="{sh:$vo.id}" <eq name="vo.id" value="$s_user_id">selected="selected"</eq>>{sh:$vo.username}</option>
</volist>
</select>
</div>
<div id="total" class="img-circle">
<div class="text-center money-txt">
<h3>总交易金额</h3>
<h2>¥{sh:$totalprice}</h2>
</div>
</div>
<div id="datalist">
<table class="table table-striped">
<thead>
<tr>
<th>商户</th>
<th>日期</th>
<th>交易金额</th>
<!-- <th>状态</th> -->
</tr>
</thead>
<tbody>
<empty name="list"><tr><td class="text-center" colspan="4">暂无数据</td></tr></empty>
<volist name="list" id="vo">
<tr>
<td>{sh:$vo.username}</td>
<td>{sh:$vo.paytime|date="Y-m-d H:i",###}</td>
<td>{sh:$vo.price}</td>
<!-- <td>
<if condition="$vo.progress eq 1"><span class="text-primary">待发货</span>
<elseif condition="$vo.progress eq 2"/><span class="text-danger">待签收</span>
<elseif condition="$vo.progress eq 3"/><span class="text-success"><strong>已完成</strong></span>
</if>
</td> -->
</tr>
</volist>
</tbody>
</table>
<div class="page text-right">
{sh:$page}
</div>
</div>
</body> </html>
效果,多看看别人的设计,多学学,最重要的就是界面展示,一切的数据都是基于几面展示,所以先确定好需要什么数据,然后获取他们。

PHP交易详情有感的更多相关文章
- 从小工到专家  ——读《Java程序员职场全攻略》有感
		
从小工到专家 ——读<Java程序员职场全攻略>有感 <Java程序员职场全攻略>是以故事的形式,向读者介绍Java程序员的职场经验.作者牛开复在北京从事软件开发,已经是一 ...
 - 漫谈可视化Prefuse(三)---Prefuse API数据结构阅读有感
		
前篇回顾:上篇<漫谈可视化Prefuse(二)---一分钟学会Prefuse>主要通过一个Prefuse的具体实例了解了构建一个Prefuse application的具体步骤.一个Pre ...
 - 见证历史 -- 2013 NBA 热火夺冠之路有感
		
见证历史-- 2013 NBA 热火夺冠之路有感今年NBA季后赛从第一轮看起,到最终的热火夺冠,应该看得是最爽的一次.但一些情节和细节,回忆起来,深有感悟. 1. 做人要低调詹宁斯豪言演黑八雄鹿本赛季 ...
 - <构建之法>第十三章到十七章有感以及这个项目读后感
		
<构建之法>第十三章到十七章有感 第13章:软件测试方法有哪些? 主要讲了软件测试方法:要说有什么问题就是哪种效率最高? 第14章:质量保障 软件的质量指标是什么?怎么样能够提升软件的质量 ...
 - 段描述符表(GDT+LDT)的有感
		
[0]写在前面 要知道,在汇编中,代码的装入顺序决定了在内存中的地址位置.所有的代码或者数据都在硬盘上,当调试或者启动的时候,加载到内存:当需要对数据进行处理的时候,我们通过将数据从内存载入到regi ...
 - 驱动:中断【2】中断处理程序、中断上下文中处理延时及一些函数的调用规则(调IIC中断驱动有感)
		
中断处理程序.中断上下文中处理延时及一些函数的调用规则(调IIC中断驱动有感)http://blog.csdn.net/samantha_sun/article/details/6790492 1,中 ...
 - 第一次QQ群视频教育有感
		
标题:第一次QQ群视频教育有感 作者:丁又专, 时间:2014.08.16 教育的目的:启示学生心智,发现个人优势,激发探索欲望. 今天早上看到 中国大学MOOC<文献管理与信息 ...
 - 10.读google测试之道有感
		
(一)读google测试之道有感.
 - 重读COM技术内幕(inside com)有感
		
重读COM技术内幕(inside com)有感 面向对象设计哲学在复杂领域并不能很好地解决问题.参考(http://www.richardlord.net/blog/what-is-an-entity ...
 
随机推荐
- C++ 函数后面的const
			
一个函数 AcGePoint3dstartPoint() const; const放在后面跟前面有区别么 ==> 准确的说const是修饰this指向的对象的 譬如,我们定义了 classA{ ...
 - 2012 Multi-University Training Contest 7
			
2012 Multi-University Training Contest 7 A.As long as Binbin loves Sangsang B.Dead or alive C.Dragon ...
 - JS获取元素计算过后的样式
			
获取元素计算过后的样式 Window.getComputedStyle() 方法会在一个元素应用完有效样式且计算完所有属性的基本值之后给出所有 CSS 属性的值. 语法: let style = wi ...
 - 负载均衡之HTTP重定向
			
转载请说明出处:http://blog.csdn.net/cywosp/article/details/38014581 由于目前现有网络的各个核心部分随着业务量的提高,访问量和数据流量的快速增长,其 ...
 - CC攻击工具list
			
从论文里抠出来的工具列表如下,后面有黑产的工具以及网络上摘录的工具: 分类:(1)有僵尸网络(是否代理服务器)&没有的==>(2)单一url&混合url(多线程,压测为主,dem ...
 - LitJson使用中需要注意的一些问题(转)
			
LitJson使用中需要注意的一些问题 使用C#做Untiy开发时,有解析Json的需求,选择使用了LitJson这个库,因为之前我们是使用lua的,这个库会将Json解析后保存为JsonData,这 ...
 - 事件穿透父层 直达子层  pointer-events:none
			
之前我也做过一些canvas特效,往往在canvas全屏时,canvas下层的div就无法进行dom的事件操作,点击之类的就失灵了.之前我的做法要么就是在canvas上加入点击事件,穿透到下层,或者把 ...
 - MPLS基础一
			
多协议标签交换(MPLS) 是一种用于快速数据包交换和路由的体系,具有管理各种不同形式通信流的机制. 内容:RID / MTU / 认证 / TTL ...
 - HDU2032 杨辉三角
			
解题思路:不要小看这题水题,如果数据类型没有用long long, 当n开为35时,会出现TLE,而且会报非法内存访问,现在还 不理解为什么,若有高手,请不吝赐教. 上代码: #include< ...
 - POJ1287 Networking
			
解题思路:Kruskal模板题,重复输入的情况,本题是无向图. 见代码: #include<cstdio> #include<algorithm> #include<cs ...