MerchantIntention.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 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. /**
  19. * 商户入驻申请
  20. */
  21. class MerchantIntention extends BaseController
  22. {
  23. protected $repository;
  24. /**
  25. * MerchantIntention constructor.
  26. * @param App $app
  27. * @param MerchantIntentionRepository $repository
  28. */
  29. public function __construct(App $app, MerchantIntentionRepository $repository)
  30. {
  31. parent::__construct($app);
  32. $this->repository = $repository;
  33. }
  34. /**
  35. * 列表
  36. * @return \think\response\Json
  37. * @author Qinii
  38. */
  39. public function lst()
  40. {
  41. [$page, $limit] = $this->getPage();
  42. $where = $this->request->params(['mer_name', 'status', 'date', 'keyword', 'mer_intention_id', 'category_id', 'type_id']);
  43. return app('json')->success($this->repository->getList($where, $page, $limit));
  44. }
  45. /**
  46. * 备注表单
  47. * @param $id
  48. * @return \think\response\Json
  49. * @author Qinii
  50. */
  51. public function form($id)
  52. {
  53. if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
  54. return app('json')->fail('数据不存在');
  55. return app('json')->success(formToData($this->repository->markForm($id)));
  56. }
  57. /**
  58. * 审核表单
  59. * @param $id
  60. * @return \think\response\Json
  61. * @author Qinii
  62. */
  63. public function statusForm($id)
  64. {
  65. if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
  66. return app('json')->fail('数据不存在');
  67. return app('json')->success(formToData($this->repository->statusForm($id)));
  68. }
  69. /**
  70. * 修改备注
  71. * @param $id
  72. * @return \think\response\Json
  73. * @author Qinii
  74. */
  75. public function mark($id)
  76. {
  77. if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
  78. return app('json')->fail('数据不存在');
  79. $data = $this->request->param('mark');
  80. $this->repository->update($id, ['mark' => $data]);
  81. return app('json')->success('修改成功');
  82. }
  83. /**
  84. * 修改审核状态
  85. * @param $id
  86. * @return \think\response\Json
  87. * @author Qinii
  88. */
  89. public function switchStatus($id)
  90. {
  91. if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
  92. return app('json')->fail('数据不存在');
  93. $data = $this->request->params(['status', 'fail_msg', 'create_mer']);
  94. $data['status'] = $data['status'] == 1 ? 1 : 2;
  95. $this->repository->updateStatus($id, $data);
  96. return app('json')->success('修改成功');
  97. }
  98. /**
  99. * 删除
  100. * @param $id
  101. * @return \think\response\Json
  102. * @author Qinii
  103. */
  104. public function delete($id)
  105. {
  106. if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0]))
  107. return app('json')->fail('数据不存在');
  108. $this->repository->update($id, ['is_del' => 1]);
  109. return app('json')->success('删除成功');
  110. }
  111. /**
  112. * 保存入驻协议
  113. * @Author:Qinii
  114. * @Date: 2020/9/15
  115. * @return mixed
  116. */
  117. public function saveAgree()
  118. {
  119. $agree = $this->request->param('agree');
  120. app()->make(CacheRepository::class)->save('sys_intention_agree', $agree);
  121. return app('json')->success('保存成功');
  122. }
  123. /**
  124. * 获取入驻协议
  125. * @Author:Qinii
  126. * @Date: 2020/9/15
  127. * @return mixed
  128. */
  129. public function getAgree()
  130. {
  131. $make = app()->make(CacheRepository::class);
  132. return app('json')->success(['sys_intention_agree' => $make->getResult('sys_intention_agree')]);
  133. }
  134. /**
  135. * 导出
  136. * @return \think\response\Json
  137. * @author Qinii
  138. */
  139. public function excel()
  140. {
  141. $where = $this->request->params(['mer_name', 'status', 'date', 'keyword', 'mer_intention_id', 'category_id', 'type_id']);
  142. [$page, $limit] = $this->getPage();
  143. $data = app()->make(ExcelService::class)->intention($where, $page, $limit);
  144. return app('json')->success($data);
  145. }
  146. }