StoreProductReply.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2026 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. /**
  23. * @var StoreProductReplyServices
  24. */
  25. protected $services;
  26. /**
  27. * 构造方法
  28. * @param App $app
  29. * @param StoreProductReplyServices $service
  30. * @var StoreProductReplyServices $services
  31. */
  32. public function __construct(App $app, StoreProductReplyServices $service)
  33. {
  34. parent::__construct($app);
  35. $this->services = $service;
  36. }
  37. /**
  38. * 显示资源列表
  39. *
  40. * @return \think\Response
  41. */
  42. public function index()
  43. {
  44. $where = $this->request->getMore([
  45. ['is_reply', ''],
  46. ['store_name', ''],
  47. ['account', ''],
  48. ['data', ''],
  49. ['product_id', 0],
  50. ['key', ''],
  51. ['order', ''],
  52. ['status', ''],
  53. ]);
  54. $list = $this->services->sysPage($where);
  55. return app('json')->success($list);
  56. }
  57. /**
  58. * 删除评论
  59. * @param $id
  60. * @return mixed
  61. */
  62. public function delete($id)
  63. {
  64. $this->services->del($id);
  65. return app('json')->success('删除成功');
  66. }
  67. /**
  68. * 回复评论
  69. * @param $id
  70. * @return mixed
  71. */
  72. public function set_reply($id)
  73. {
  74. [$content] = $this->request->postMore([
  75. ['content', '']
  76. ], true);
  77. $this->services->setReply($id, $content);
  78. return app('json')->success('回复成功');
  79. }
  80. /**
  81. * 创建虚拟评论表单
  82. * @return mixed
  83. * @throws \FormBuilder\Exception\FormBuilderException
  84. */
  85. public function fictitious_reply()
  86. {
  87. list($product_id) = $this->request->postMore([
  88. ['product_id', 0],
  89. ], true);
  90. return app('json')->success($this->services->createForm($product_id));
  91. }
  92. /**
  93. * 保存虚拟评论
  94. * @return mixed
  95. */
  96. public function save_fictitious_reply()
  97. {
  98. $data = $this->request->postMore([
  99. ['image', ''],
  100. ['nickname', ''],
  101. ['avatar', ''],
  102. ['comment', ''],
  103. ['pics', []],
  104. ['product_score', 0],
  105. ['service_score', 0],
  106. ['product_id', 0],
  107. ['add_time', 0],
  108. ['suk', ''],
  109. ]);
  110. if (!$data['product_id']) {
  111. $data['product_id'] = $data['image']['product_id'] ?? '';
  112. }
  113. $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');
  114. $this->services->saveReply($data);
  115. return app('json')->success('保存成功');
  116. }
  117. /**
  118. * 商品评论审核
  119. * @param $id
  120. * @param $status
  121. * @return \think\Response
  122. * @author wuhaotian
  123. * @email 442384644@qq.com
  124. * @date 2024/4/22
  125. */
  126. public function set_status($id, $status)
  127. {
  128. $this->services->update($id, ['status' => $status]);
  129. return app('json')->success($status == 1 ? '审核通过' : '拒绝成功');
  130. }
  131. /**
  132. * 批量商品评论审核
  133. * @return \think\Response
  134. * @author wuhaotian
  135. * @email 442384644@qq.com
  136. * @date 2025/6/18
  137. */
  138. public function batch_set_status()
  139. {
  140. list($ids, $status) = $this->request->postMore([
  141. ['ids', []],
  142. ['status', 0]
  143. ], true);
  144. $this->services->batchUpdate($ids, ['status' => $status]);
  145. return app('json')->success($status == 1 ? '审核通过' : '拒绝成功');
  146. }
  147. }