MerchantIntention.php 4.1 KB

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