StoreProductReply.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\v1\product;
  12. use app\adminapi\controller\AuthController;
  13. use app\services\product\product\StoreProductReplyServices;
  14. use think\facade\App;
  15. /**
  16. * 评论管理 控制器
  17. * Class StoreProductReply
  18. * @package app\admin\controller\store
  19. */
  20. class StoreProductReply extends AuthController
  21. {
  22. public function __construct(App $app, StoreProductReplyServices $service)
  23. {
  24. parent::__construct($app);
  25. $this->services = $service;
  26. }
  27. /**
  28. * 显示资源列表
  29. *
  30. * @return \think\Response
  31. */
  32. public function index()
  33. {
  34. $where = $this->request->getMore([
  35. ['is_reply', ''],
  36. ['store_name', ''],
  37. ['account', ''],
  38. ['data', ''],
  39. ['product_id', 0],
  40. ['key', ''],
  41. ['order', '']
  42. ]);
  43. $list = $this->services->sysPage($where);
  44. return app('json')->success($list);
  45. }
  46. /**
  47. * 删除评论
  48. * @param $id
  49. * @return mixed
  50. */
  51. public function delete($id)
  52. {
  53. $this->services->del($id);
  54. return app('json')->success(100002);
  55. }
  56. /**
  57. * 回复评论
  58. * @param $id
  59. * @return mixed
  60. */
  61. public function set_reply($id)
  62. {
  63. [$content] = $this->request->postMore([
  64. ['content', '']
  65. ], true);
  66. $this->services->setReply($id, $content);
  67. return app('json')->success(400169);
  68. }
  69. /**
  70. * 创建虚拟评论表单
  71. * @return mixed
  72. * @throws \FormBuilder\Exception\FormBuilderException
  73. */
  74. public function fictitious_reply()
  75. {
  76. list($product_id) = $this->request->postMore([
  77. ['product_id', 0],
  78. ], true);
  79. return app('json')->success($this->services->createForm($product_id));
  80. }
  81. /**
  82. * 保存虚拟评论
  83. * @return mixed
  84. */
  85. public function save_fictitious_reply()
  86. {
  87. $data = $this->request->postMore([
  88. ['image', ''],
  89. ['nickname', ''],
  90. ['avatar', ''],
  91. ['comment', ''],
  92. ['pics', []],
  93. ['product_score', 0],
  94. ['service_score', 0],
  95. ['product_id', 0],
  96. ['add_time', 0],
  97. ['suk', ''],
  98. ]);
  99. if (!$data['product_id']) {
  100. $data['product_id'] = $data['image']['product_id'] ?? '';
  101. }
  102. $this->validate(['product_id' => $data['product_id'], 'nickname' => $data['nickname'], 'avatar' => $data['avatar'], 'comment' => $data['comment'], 'product_score' => $data['product_score'], 'service_score' => $data['service_score']], \app\adminapi\validate\product\StoreProductReplyValidate::class, 'save');
  103. $this->services->saveReply($data);
  104. return app('json')->success(100000);
  105. }
  106. }