侯体宗的博客
  • 首页
  • Hyperf版
  • beego仿版
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

thinkPHP交易详情查询功能详解

ThinkPHP  /  管理员 发布于 8年前   201

本文实例分析了thinkPHP交易详情查询功能。分享给大家供大家参考,具体如下:

交易详情

一般都是按月的,包含,交易日期,交易金额,交易状态(可有可无)
总交易额等等。
如果数据多的话,最好能够分页。
最好能够查询具体的哪一个商户。

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.'-'.'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,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'] = '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部分

  
  • ←
  • {sh:$s_year}.{sh:$s_month}
  • →

总交易金额

¥{sh:$totalprice}

商户 日期 交易金额
暂无数据
{sh:$vo.username} {sh:$vo.paytime|date="Y-m-d H:i",###} {sh:$vo.price}
{sh:$page}

效果,多看看别人的设计,多学学,最重要的就是界面展示,一切的数据都是基于几面展示,所以先确定好需要什么数据,然后获取他们。

更多关于thinkPHP相关内容感兴趣的读者可查看本站专题:《ThinkPHP入门教程》、《thinkPHP模板操作技巧总结》、《ThinkPHP常用方法总结》、《codeigniter入门教程》、《CI(CodeIgniter)框架进阶教程》、《Zend FrameWork框架入门教程》、《smarty模板入门基础教程》及《PHP模板技术总结》。

希望本文所述对大家基于ThinkPHP框架的PHP程序设计有所帮助。

您可能感兴趣的文章:

  • php+mysql+jquery实现日历签到功能
  • ThinkPHP+jquery实现“加载更多”功能代码
  • Thinkphp整合微信支付功能
  • thinkphp实现分页显示功能
  • thinkPHP统计排行与分页显示功能示例
  • thinkPHP商城公告功能开发问题分析
  • thinkPHP订单数字提醒功能的实现方法
  • Thinkphp实现短信验证注册功能
  • thinkphp框架实现数据添加和显示功能
  • ThinkPHP3.2.2实现持久登录(记住我)功能的方法
  • thinkPHP实现MemCache分布式缓存功能
  • thinkphp实现图片上传功能
  • thinkPHP实现签到功能的方法


  • 上一条:
    thinkPHP统计排行与分页显示功能示例
    下一条:
    thinkPHP实现多字段模糊匹配查询的方法
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • thinkphp + mongodb项目中数据加载慢问题分析及解决(0个评论)
    • thinkphp6框架中封装redis操作类(0个评论)
    • thinkphp6框架中实现定时任务功能流程步骤(0个评论)
    • Thinkphp5.1框架中实现Session+Redis会话共享流程步骤(0个评论)
    • TP5框架版本5.0.10安全漏洞根据官方补丁修复,也是本站安全漏洞修复(0个评论)
    • 近期文章
    • 在go中实现一个常用的先进先出的缓存淘汰算法示例代码(0个评论)
    • 在go+gin中使用"github.com/skip2/go-qrcode"实现url转二维码功能(0个评论)
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(0个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 欧盟关于强迫劳动的规定的官方举报渠道及官方举报网站(0个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf文件功能(0个评论)
    • Laravel从Accel获得5700万美元A轮融资(0个评论)
    • 在go + gin中gorm实现指定搜索/区间搜索分页列表功能接口实例(0个评论)
    • 在go语言中实现IP/CIDR的ip和netmask互转及IP段形式互转及ip是否存在IP/CIDR(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2016-10
    • 2017-07
    • 2017-08
    • 2017-09
    • 2017-10
    • 2017-12
    • 2018-01
    • 2018-02
    • 2020-03
    • 2021-07
    • 2021-12
    • 2022-05
    • 2022-06
    • 2022-09
    • 2023-01
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客