UserExtract.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\admin\user;
  12. use app\common\repositories\store\ExcelRepository;
  13. use crmeb\basic\BaseController;
  14. use crmeb\services\ExcelService;
  15. use think\App;
  16. use app\validate\api\UserExtractValidate as validate;
  17. use app\common\repositories\user\UserExtractRepository as repository;
  18. class UserExtract extends BaseController
  19. {
  20. /**
  21. * @var repository
  22. */
  23. public $repository;
  24. /**
  25. * UserExtract constructor.
  26. * @param App $app
  27. * @param repository $repository
  28. */
  29. public function __construct(App $app,repository $repository)
  30. {
  31. parent::__construct($app);
  32. $this->repository = $repository;
  33. }
  34. /**
  35. * TODO
  36. * @return mixed
  37. * @author Qinii
  38. * @day 2020-06-16
  39. */
  40. public function lst()
  41. {
  42. [$page,$limit] = $this->getPage();
  43. $where = $this->request->params(['status','keyword','date','extract_type']);
  44. return app('json')->success($this->repository->getList($where,$page,$limit));
  45. }
  46. /**
  47. * TODO
  48. * @param $id
  49. * @return mixed
  50. * @author Qinii
  51. * @day 2020-06-16
  52. */
  53. public function switchStatus($id)
  54. {
  55. $data = $this->request->params(['status','fail_msg','mark']);
  56. if($data['status'] == '-1' && empty($data['fail_msg']))
  57. return app('json')->fail('请填写拒绝原因');
  58. if(!$this->repository->getWhereCount($id))
  59. return app('json')->fail('数据不存在或状态错误');
  60. $data['admin_id'] = $this->request->adminId();
  61. $data['status_time'] = date('Y-m-d H:i:s',time());
  62. $this->repository->switchStatus($id,$data);
  63. return app('json')->success('审核成功');
  64. }
  65. public function export()
  66. {
  67. $where = $this->request->params(['status','keyword','date','extract_type']);
  68. [$page, $limit] = $this->getPage();
  69. $data = app()->make(ExcelService::class)->extract($where,$page,$limit);
  70. return app('json')->success($data);
  71. }
  72. }