MerchantIntention.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace app\controller\admin\system\merchant;
  3. use app\common\repositories\store\ExcelRepository;
  4. use app\common\repositories\system\CacheRepository;
  5. use think\App;
  6. use ln\basic\BaseController;
  7. use app\common\repositories\system\merchant\MerchantIntentionRepository;
  8. class MerchantIntention extends BaseController
  9. {
  10. protected $repository;
  11. /**
  12. * MerchantIntention constructor.
  13. * @param App $app
  14. * @param MerchantIntentionRepository $repository
  15. */
  16. public function __construct(App $app, MerchantIntentionRepository $repository)
  17. {
  18. parent::__construct($app);
  19. $this->repository = $repository;
  20. }
  21. public function lst()
  22. {
  23. [$page, $limit] = $this->getPage();
  24. $where = $this->request->params(['mer_name', 'status', 'date', 'keyword', 'mer_intention_id', 'category_id', 'type_id']);
  25. return app('json')->success($this->repository->getList($where, $page, $limit));
  26. }
  27. public function form($id)
  28. {
  29. if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
  30. return app('json')->fail('数据不存在');
  31. return app('json')->success(formToData($this->repository->markForm($id)));
  32. }
  33. public function statusForm($id)
  34. {
  35. if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
  36. return app('json')->fail('数据不存在');
  37. return app('json')->success(formToData($this->repository->statusForm($id)));
  38. }
  39. public function mark($id)
  40. {
  41. if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
  42. return app('json')->fail('数据不存在');
  43. $data = $this->request->param('mark');
  44. $this->repository->update($id, ['mark' => $data]);
  45. return app('json')->success('修改成功');
  46. }
  47. public function switchStatus($id)
  48. {
  49. if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
  50. return app('json')->fail('数据不存在');
  51. $data = $this->request->params(['status', 'fail_msg', 'create_mer']);
  52. $data['status'] = $data['status'] == 1 ? 1 : 2;
  53. $this->repository->updateStatus($id, $data);
  54. return app('json')->success('修改成功');
  55. }
  56. public function delete($id)
  57. {
  58. if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
  59. return app('json')->fail('数据不存在');
  60. $this->repository->update($id, ['is_del' => 1]);
  61. return app('json')->success('删除成功');
  62. }
  63. /**
  64. * @Author:Qinii
  65. * @Date: 2020/9/15
  66. * @return mixed
  67. */
  68. public function saveAgree()
  69. {
  70. $agree = $this->request->param('agree');
  71. app()->make(CacheRepository::class)->save('sys_intention_agree', $agree);
  72. return app('json')->success('保存成功');
  73. }
  74. /**
  75. * @Author:Qinii
  76. * @Date: 2020/9/15
  77. * @return mixed
  78. */
  79. public function getAgree()
  80. {
  81. $make = app()->make(CacheRepository::class);
  82. return app('json')->success(['sys_intention_agree' => $make->getResult('sys_intention_agree')]);
  83. }
  84. public function excel()
  85. {
  86. $where = $this->request->params(['mer_name', 'status', 'date', 'keyword', 'mer_intention_id', 'category_id', 'type_id']);
  87. app()->make(ExcelRepository::class)->create($where, $this->request->adminId(), 'intention',0);
  88. return app('json')->success('开始导出数据');
  89. }
  90. }