MerchantIntention.php 3.7 KB

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