StoreServiceFeedbackServices.php 2.8 KB

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