TodoCons.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\model\MateGoodsLog;
  4. use think\App;
  5. use think\Db;
  6. use think\Exception;
  7. class TodoCons extends Auth
  8. {
  9. public function index(){
  10. if(request()->isAjax()){
  11. //分页参数
  12. $length = input('rows',10,'intval'); //每页条数
  13. $page = input('page',1,'intval'); //第几页
  14. $start = ($page - 1) * $length; //分页开始位置
  15. //排序
  16. $sortRow = input('sidx','sort','trim'); //排序列
  17. $sort = input('sord','asc','trim'); //排序方式
  18. $order = $sortRow.' '.$sort.' ,id desc';
  19. $title = input('title','','trim');
  20. if($title){
  21. $map[] = ['order_id','like','%'.$title.'%'];
  22. }
  23. $enable = input('enable','','trim');
  24. if($enable != ''){
  25. $map[] = ['enable','=',$enable];
  26. }
  27. $map[] = ['org_id','=',$this->orgId];
  28. $map= empty($map) ? true: $map;
  29. //数据查询
  30. $lists =db('todo_mate')
  31. ->where($map)->limit($start,$length)
  32. ->order($order)->select();
  33. foreach ($lists as $k=>$v){
  34. $lists[$k]['userName'] = db('user')
  35. ->where('id',$v['user_id'])
  36. ->value('real_name');
  37. }
  38. //数据返回
  39. $totalCount = db('todo_mate')->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. $this->assign('meta_title','订单消耗记录');
  48. return $this->fetch();
  49. }
  50. }
  51. //调拨详情
  52. public function info($id){
  53. $info = Db::name('todo_mate')
  54. ->where('id',$id)
  55. ->find();
  56. $goods = [];
  57. $cons = Db::name('todo_mate_item')
  58. ->where('todo_mate_id','=',$id)
  59. ->select();
  60. foreach ($cons as $k1=>$v1){
  61. // $rr = Db::name('mate_sub_goods')
  62. // ->where('id',$v1['items_id'])
  63. // ->find();
  64. $pInfo =Db::name('mate_goods')
  65. ->where('id',$v1['items_id'])
  66. ->find();
  67. $goods[] = [
  68. 'title' =>$pInfo['title'],
  69. 'total' =>$v1['total'],
  70. 'money' =>$v1['money'],
  71. 'total_money' =>$v1['total_money'],
  72. 'realName' =>$this->getTableField('user',['id'=>$v1['user_id']],'real_name'),
  73. ];
  74. }
  75. $info['userName'] = Db::name('user')
  76. ->where('id',$info['user_id'])
  77. ->value('real_name');
  78. $info['goods'] = $goods;
  79. $this->assign('info',$info);
  80. return $this->fetch();
  81. }
  82. }