StoreServiceFeedback.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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\v1\message\service;
  12. use app\controller\admin\AuthController;
  13. use app\services\message\service\StoreServiceFeedbackServices;
  14. use think\facade\App;
  15. /**
  16. * 客服用户留言反馈
  17. * Class StoreServiceFeedback
  18. * @package app\controller\admin\v1\application\wechat
  19. */
  20. class StoreServiceFeedback extends AuthController
  21. {
  22. /**
  23. * StoreServiceFeedback constructor.
  24. * @param App $app
  25. * @param StoreServiceFeedbackServices $services
  26. */
  27. public function __construct(App $app, StoreServiceFeedbackServices $services)
  28. {
  29. parent::__construct($app);
  30. $this->services = $services;
  31. }
  32. /**
  33. * 获取留言列表
  34. * @return mixed
  35. * @throws \think\db\exception\DataNotFoundException
  36. * @throws \think\db\exception\DbException
  37. * @throws \think\db\exception\ModelNotFoundException
  38. */
  39. public function index()
  40. {
  41. $where = $this->request->getMore([
  42. ['title', ''],
  43. ['time', '']
  44. ]);
  45. return $this->success($this->services->getFeedbackList($where));
  46. }
  47. /**
  48. * 获取修改表单
  49. * @param $id
  50. * @return mixed
  51. * @throws \FormBuilder\Exception\FormBuilderException
  52. * @throws \think\db\exception\DataNotFoundException
  53. * @throws \think\db\exception\DbException
  54. * @throws \think\db\exception\ModelNotFoundException
  55. */
  56. public function edit($id)
  57. {
  58. if (!$id) {
  59. return $this->fail('缺少参数');
  60. }
  61. return $this->success($this->services->editForm((int)$id));
  62. }
  63. /**
  64. * 修改
  65. * @param $id
  66. * @return mixed
  67. */
  68. public function update($id)
  69. {
  70. $data = $this->request->postMore([
  71. ['make', ''],
  72. ['status', 0],
  73. ]);
  74. if (!$id || !($feedInfo = $this->services->get($id))) {
  75. return $this->fail('反馈内容不存在');
  76. }
  77. $feedInfo->make = $data['make'];
  78. if ($data['status']) {
  79. $feedInfo->status = $data['status'];
  80. }
  81. $feedInfo->save();
  82. return $this->success('修改成功');
  83. }
  84. /**
  85. * 删除反馈
  86. * @param $id
  87. * @return mixed
  88. * @throws \Exception
  89. */
  90. public function delete($id)
  91. {
  92. if (!$id) {
  93. return $this->fail('缺少参数');
  94. }
  95. if ($this->services->delete($id)) {
  96. return $this->success('删除成功');
  97. } else {
  98. return $this->fail('删除失败');
  99. }
  100. }
  101. }