StoreServiceFeedbackServices.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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\services\message\service;
  12. use app\dao\service\StoreServiceFeedbackDao;
  13. use app\services\BaseServices;
  14. use crmeb\services\FormBuilder;
  15. use crmeb\traits\ServicesTrait;
  16. use think\exception\ValidateException;
  17. /**
  18. * 客服反馈
  19. * Class StoreServiceFeedbackServices
  20. * @package app\services\message\service
  21. */
  22. class StoreServiceFeedbackServices extends BaseServices
  23. {
  24. use ServicesTrait;
  25. /**
  26. * StoreServiceFeedbackServices constructor.
  27. * @param StoreServiceFeedbackDao $dao
  28. */
  29. public function __construct(StoreServiceFeedbackDao $dao)
  30. {
  31. $this->dao = $dao;
  32. }
  33. /**
  34. * 获取反馈列表
  35. * @param array $where
  36. * @return array
  37. * @throws \think\db\exception\DataNotFoundException
  38. * @throws \think\db\exception\DbException
  39. * @throws \think\db\exception\ModelNotFoundException
  40. */
  41. public function getFeedbackList(array $where)
  42. {
  43. [$page, $limit] = $this->getPageValue();
  44. $data = $this->dao->getFeedback($where, $page, $limit);
  45. $count = $this->dao->count($where);
  46. return compact('data', 'count');
  47. }
  48. /**
  49. *
  50. * @param int $id
  51. * @return array
  52. * @throws \FormBuilder\Exception\FormBuilderException
  53. * @throws \think\db\exception\DataNotFoundException
  54. * @throws \think\db\exception\DbException
  55. * @throws \think\db\exception\ModelNotFoundException
  56. */
  57. public function editForm(int $id)
  58. {
  59. $feedInfo = $this->dao->get($id);
  60. if (!$feedInfo) {
  61. throw new ValidateException('反馈内容没有查到');
  62. }
  63. $feedInfo = $feedInfo->toArray();
  64. $field = [
  65. FormBuilder::textarea('make', '备注', $feedInfo['make'])->col(22),
  66. ];
  67. if (!$feedInfo['status']) {
  68. $field[] = FormBuilder::radio('status', '状态', 0)->setOptions([
  69. ['label' => '已处理', 'value' => 1],
  70. ['label' => '未处理', 'value' => 0]
  71. ]);
  72. }
  73. return create_form($feedInfo['status'] ? '备注' : '处理', $field, $this->url('/app/feedback/' . $id), 'PUT');
  74. }
  75. }