Company.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. use think\Db;
  5. /**
  6. * 门店
  7. *
  8. * @icon fa fa-circle-o
  9. */
  10. class Company extends Backend
  11. {
  12. /**
  13. * Company模型对象
  14. * @var \app\admin\model\Company
  15. */
  16. protected $model = null;
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = new \app\admin\model\Company;
  21. $this->view->assign("statusList", $this->model->getStatusList());
  22. $this->view->assign("isOpenList", $this->model->getIsOpenList());
  23. }
  24. /**
  25. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  26. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  27. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  28. */
  29. /**
  30. * 查看
  31. */
  32. public function index()
  33. {
  34. //当前是否为关联查询
  35. $this->relationSearch = true;
  36. //设置过滤方法
  37. $this->request->filter(['strip_tags', 'trim']);
  38. if ($this->request->isAjax()) {
  39. //如果发送的来源是Selectpage,则转发到Selectpage
  40. if ($this->request->request('keyField')) {
  41. return $this->company_selectpage('id');
  42. }
  43. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  44. //只能看自己的
  45. $where_op = [];
  46. if($this->auth->company_id){
  47. $where_op['company.id'] = $this->auth->company_id;
  48. }
  49. $list = $this->model
  50. ->with(['wallet'])
  51. ->where($where)
  52. ->where($where_op)
  53. ->order($sort, $order)
  54. ->paginate($limit);
  55. foreach ($list as $row) {
  56. $row->getRelation('wallet')->visible(['money']);
  57. }
  58. $result = array("total" => $list->total(), "rows" => $list->items());
  59. return json($result);
  60. }
  61. return $this->view->fetch();
  62. }
  63. /**
  64. * 审核
  65. */
  66. public function audit(){
  67. $id = input('id');
  68. $info = Db::name('company')
  69. ->where('id',$id)
  70. ->find();
  71. if ($this->request->isPost()) {
  72. $status = input('status',0);
  73. $data = [
  74. 'status' => $status,
  75. 'updatetime' => time(),
  76. ];
  77. $rs = Db::name('company')->where('id',$id)->update($data);
  78. $this->success('审核完成');
  79. }
  80. $this->assign('row',$info);
  81. return $this->view->fetch();
  82. }
  83. }