StoreProductReply.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. ['status', ''],
  43. ]);
  44. $list = $this->services->sysPage($where);
  45. return app('json')->success($list);
  46. }
  47. /**
  48. * 删除评论
  49. * @param $id
  50. * @return mixed
  51. */
  52. public function delete($id)
  53. {
  54. $this->services->del($id);
  55. return app('json')->success(100002);
  56. }
  57. /**
  58. * 回复评论
  59. * @param $id
  60. * @return mixed
  61. */
  62. public function set_reply($id)
  63. {
  64. [$content] = $this->request->postMore([
  65. ['content', '']
  66. ], true);
  67. $this->services->setReply($id, $content);
  68. return app('json')->success(400169);
  69. }
  70. /**
  71. * 创建虚拟评论表单
  72. * @return mixed
  73. * @throws \FormBuilder\Exception\FormBuilderException
  74. */
  75. public function fictitious_reply()
  76. {
  77. list($product_id) = $this->request->postMore([
  78. ['product_id', 0],
  79. ], true);
  80. return app('json')->success($this->services->createForm($product_id));
  81. }
  82. /**
  83. * 保存虚拟评论
  84. * @return mixed
  85. */
  86. public function save_fictitious_reply()
  87. {
  88. $data = $this->request->postMore([
  89. ['image', ''],
  90. ['nickname', ''],
  91. ['avatar', ''],
  92. ['comment', ''],
  93. ['pics', []],
  94. ['product_score', 0],
  95. ['service_score', 0],
  96. ['product_id', 0],
  97. ['add_time', 0],
  98. ['suk', ''],
  99. ]);
  100. if (!$data['product_id']) {
  101. $data['product_id'] = $data['image']['product_id'] ?? '';
  102. }
  103. $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');
  104. $this->services->saveReply($data);
  105. return app('json')->success(100000);
  106. }
  107. /**
  108. * 商品评论审核
  109. * @param $id
  110. * @param $status
  111. * @return \think\Response
  112. * @author wuhaotian
  113. * @email 442384644@qq.com
  114. * @date 2024/4/22
  115. */
  116. public function set_status($id, $status)
  117. {
  118. $this->services->update($id, ['status' => $status]);
  119. return app('json')->success($status == 1 ? '审核通过' : '拒绝成功');
  120. }
  121. }