thinkPHP交易详情查询功能详解
发布时间:2020-12-14 14:06:46 所属栏目:大数据 来源:网络整理
导读:本文实例分析了thinkPHP交易详情查询功能。供大家参考研究具体如下: 交易详情 一般都是按月的,包含,交易日期,交易金额,交易状态(可有可无)总交易额等等。如果数据多的话,最好能够分页。最好能够查询具体的哪一个商户。 1.模拟sql实现查询功
本文实例分析了thinkPHP交易详情查询功能。分享给大家供大家参考,具体如下: 交易详情 一般都是按月的,包含,交易日期,交易金额,交易状态(可有可无) 总交易额等等。 如果数据多的话,最好能够分页。 最好能够查询具体的哪一个商户。 1.模拟sql实现查询功能 sql查询出来了,基本上就搞定了,剩下的就是用php,thinkphp实现这个查询功能,加入一些逻辑与条件。 _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.'-'.'1');
$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,c.receivetime')
->select();
foreach ($list as $k => $v) {
if($v['sendtime'] == 0 && $v['receivetime'] == 0){
$list[$k]['progress'] = '1'; // 已付款,待发货
}
if($v['sendtime'] > 0 && $v['receivetime'] == 0){
$list[$k]['progress'] = '2'; // 已发货,待签收
}
if($v['sendtime'] > 0 && $v['receivetime'] > 0){
$list[$k]['progress'] = '3'; // 交易完成
}
}
// 获取拓展员用户
$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部分 相关内容
|