CRMEB/backend/app/adminapi/controller/product/StoreProductReplyController.php
2026-09-23 15:15:02 +08:00

158 lines
4.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\product;
use app\adminapi\controller\AuthController;
use app\services\product\product\StoreProductReplyServices;
use think\facade\App;
/**
* 评论管理 控制器
* Class StoreProductReply
* @package app\admin\controller\store
*/
class StoreProductReplyController extends AuthController
{
/**
* @var StoreProductReplyServices
*/
protected $services;
/**
* 构造方法
* @param App $app
* @param StoreProductReplyServices $service
* @var StoreProductReplyServices $services
*/
public function __construct(App $app, StoreProductReplyServices $service)
{
parent::__construct($app);
$this->services = $service;
}
/**
* 显示资源列表
*
* @return \think\Response
*/
public function index()
{
$where = $this->request->getMore([
['is_reply', ''],
['store_name', ''],
['account', ''],
['data', ''],
['product_id', 0],
['key', ''],
['order', ''],
['status', ''],
]);
$list = $this->services->sysPage($where);
return app('json')->success($list);
}
/**
* 删除评论
* @param $id
* @return mixed
*/
public function delete($id)
{
$this->services->del($id);
return app('json')->success('删除成功');
}
/**
* 回复评论
* @param $id
* @return mixed
*/
public function setReply($id)
{
[$content] = $this->request->postMore([
['content', '']
], true);
$this->services->setReply($id, $content);
return app('json')->success('回复成功');
}
/**
* 创建虚拟评论表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function fictitiousReply()
{
list($product_id) = $this->request->postMore([
['product_id', 0],
], true);
return app('json')->success($this->services->createForm($product_id));
}
/**
* 保存虚拟评论
* @return mixed
*/
public function saveFictitiousReply()
{
$data = $this->request->postMore([
['image', ''],
['nickname', ''],
['avatar', ''],
['comment', ''],
['pics', []],
['product_score', 0],
['service_score', 0],
['product_id', 0],
['add_time', 0],
['suk', ''],
]);
if (!$data['product_id']) {
$data['product_id'] = $data['image']['product_id'] ?? '';
}
$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');
$this->services->saveReply($data);
return app('json')->success('保存成功');
}
/**
* 商品评论审核
* @param $id
* @param $status
* @return \think\Response
* @author wuhaotian
* @email 442384644@qq.com
* @date 2024/4/22
*/
public function setStatus($id, $status)
{
$this->services->update($id, ['status' => $status]);
return app('json')->success($status == 1 ? '审核通过' : '拒绝成功');
}
/**
* 批量商品评论审核
* @return \think\Response
* @author wuhaotian
* @email 442384644@qq.com
* @date 2025/6/18
*/
public function batchSetStatus()
{
list($ids, $status) = $this->request->postMore([
['ids', []],
['status', 0]
], true);
$this->services->batchUpdate($ids, ['status' => $status]);
return app('json')->success($status == 1 ? '审核通过' : '拒绝成功');
}
}