GOrderRefund.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace app\admin\controller;
  3. use think\App;
  4. use think\Db;
  5. class GOrderRefund extends Auth
  6. {
  7. public function __construct(App $app = null) {
  8. parent::__construct($app);
  9. $this->table='g_order_refund';
  10. }
  11. public function index(){
  12. if(request()->isAjax()){
  13. //分页参数
  14. $length = input('rows',10,'intval'); //每页条数
  15. $page = input('page',1,'intval'); //第几页
  16. $start = ($page - 1) * $length; //分页开始位置
  17. //排序
  18. $sortRow = input('sidx','id','trim'); //排序列
  19. $sort = input('sord','desc','trim'); //排序方式
  20. $order = $sortRow.' '.$sort;
  21. $title = input('title','','trim');
  22. if($title){
  23. $map[] = ['title','like','%'.$title.'%'];
  24. }
  25. $enable = input('enable','','trim');
  26. if($enable != ''){
  27. $map[] = ['enable','=',$enable];
  28. }
  29. $map[] = ['org_id','=',$this->orgId];
  30. $map= empty($map) ? true: $map;
  31. //数据查询
  32. $lists = db($this->table)->where($map)->limit($start,$length)->order($order)->select();
  33. foreach ($lists as $k=>$v){
  34. $lists[$k]['userName'] = Db::name('user')
  35. ->where('id',$v['user_id'])
  36. ->value('real_name');
  37. }
  38. //数据返回
  39. $totalCount = db($this->table)->where($map)->count();
  40. $totalPage = ceil($totalCount/$length);
  41. $result['page'] = $page;
  42. $result['total'] = $totalPage;
  43. $result['records'] = $totalCount;
  44. $result['rows'] = $lists;
  45. return json($result);
  46. }else{
  47. return $this->fetch();
  48. }
  49. }
  50. }