提交 71a7c9b7 编写于 作者: G gongfuxiang

评价管理

上级 19374011
......@@ -67,7 +67,7 @@ class Goodscomments extends Common
'total' => $total,
'where' => $params,
'page' => isset($params['page']) ? intval($params['page']) : 1,
'url' => MyUrl('admin/answer/index'),
'url' => MyUrl('admin/goodscomments/index'),
);
$page = new \base\Page($page_params);
$this->assign('page_html', $page->GetPageHtml());
......@@ -82,11 +82,10 @@ class Goodscomments extends Common
$data = GoodsCommentsService::GoodsCommentsList($data_params);
$this->assign('data_list', $data['data']);
// 状态
// 静态数据
$this->assign('common_is_show_list', lang('common_is_show_list'));
// 是否
$this->assign('common_is_text_list', lang('common_is_text_list'));
$this->assign('business_type_list', GoodsCommentsService::$business_type_list);
// 参数
$this->assign('params', $params);
......@@ -184,8 +183,7 @@ class Goodscomments extends Common
// 开始处理
$params = input();
$params['user_type'] = 'admin';
return GoodsCommentsService::AnswerDelete($params);
return GoodsCommentsService::GoodsCommentsDelete($params);
}
/**
......@@ -205,7 +203,7 @@ class Goodscomments extends Common
// 开始处理
$params = input();
return GoodsCommentsService::AnswerReply($params);
return GoodsCommentsService::GoodsCommentsReply($params);
}
/**
......@@ -225,7 +223,7 @@ class Goodscomments extends Common
// 开始处理
$params = input();
return GoodsCommentsService::AnswerStatusUpdate($params);
return GoodsCommentsService::GoodsCommentsStatusUpdate($params);
}
}
?>
\ No newline at end of file
......@@ -47,6 +47,28 @@
</select>
</td>
</tr>
<tr>
<td>
<span>匿名:</span>
<select name="is_anonymous" class="chosen-select" data-placeholder="是否匿名...">
<option value="-1">是否匿名...</option>
{{foreach $common_is_text_list as $v}}
<option value="{{$v.id}}" {{if isset($params['is_anonymous']) and $params['is_anonymous'] eq $v['id']}}selected{{/if}}>{{$v.name}}</option>
{{/foreach}}
</select>
</td>
<td>
<span>类型:</span>
<select name="business_type" class="chosen-select" data-placeholder="业务类型...">
<option value="">业务类型...</option>
{{if !empty($business_type_list)}}
{{foreach $business_type_list as $k=>$v}}
<option value="{{$k}}" {{if isset($params['business_type']) and $params['business_type'] eq $k}}selected{{/if}}>{{$v}}</option>
{{/foreach}}
{{/if}}
</select>
</td>
</tr>
<tr>
<td class="time">
<span>时间:</span>
......@@ -68,24 +90,17 @@
</form>
<!-- form end -->
<!-- operation start -->
<div class="am-g m-t-15">
<a href="{{:MyUrl('admin/goodscomments/saveinfo')}}" class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-plus"> 新增</a>
</div>
<!-- operation end -->
<!-- list start -->
<table class="am-table am-table-striped am-table-hover am-text-middle m-t-10">
<thead>
<tr>
<th class="am-hide-md-down">商品信息</th>
<th class="am-hide-md-down">用户信息</th>
<th class="am-hide-sm-only">业务类型</th>
<th class="am-hide-sm-only">内容</th>
<th class="am-hide-sm-only">回复内容</th>
<th>评价内容</th>
<th class="am-hide-sm-only">是否回复</th>
<th class="am-hide-sm-only">匿名</th>
<th class="am-hide-sm-only">回复时间</th>
<th class="am-hide-sm-only">创建时间</th>
<th>是否显示</th>
<th class="am-hide-sm-only">显示</th>
<th>更多</th>
<th>操作</th>
</tr>
......@@ -94,6 +109,25 @@
{{if !empty($data_list)}}
{{foreach $data_list as $v}}
<tr id="data-list-{{$v.id}}" {{if $v['is_show'] eq 0}}class="am-active"{{/if}}>
<td class="goods-info am-hide-md-down">
{{if !empty($v['user'])}}
<div class="base">
<a href="{{$v.goods.goods_url}}" target="_blank">
<img src="{{$v.goods.images}}" alt="{{$v.goods.title}}" class="am-img-thumbnail am-radius am-align-left" />
</a>
<a class="am-text-top" href="{{$v.goods.goods_url}}" target="_blank">
{{if mb_strlen($v['goods']['title']) gt 23}}
{{:mb_substr($v['goods']['title'], 0, 23, 'utf-8')}} ...
{{else /}}
{{$v.goods.title}}
{{/if}}
</a>
</div>
<p>¥{{$v.goods.min_price}}</p>
{{else /}}
商品信息异常
{{/if}}
</td>
<td class="user-info am-hide-md-down">
{{if !empty($v['user'])}}
<img src="{{$v.user.avatar}}" alt="{{$v.user.user_name_view}}" class="am-img-thumbnail am-radius am-align-left" />
......@@ -107,25 +141,21 @@
用户信息异常
{{/if}}
</td>
<td>{{$v.business_type}}</td>
<td class="am-hide-sm-only">
<td class="am-hide-sm-only">{{$v.business_type_text}}</td>
<td>
<div class="reply-content">
{{$v.content|raw}}
{{$v.content}}
</div>
</td>
<td class="am-hide-sm-only">
{{if $v['is_reply'] eq 1 and !empty($v['reply'])}}
<div class="reply-content">
{{$v.reply|raw}}
</div>
<p>{{$v.reply_time_time}}</p>
已回复
{{else /}}
<span class="cr-ddd">未回复</span>
{{/if}}
</td>
<td class="am-hide-sm-only">{{$v.is_anonymous_text}}</td>
<td class="am-hide-sm-only">{{$v.add_time_time}}</td>
<td>
<td class="am-hide-sm-only">
<a href="javascript:;" class="am-icon-btn am-icon-check submit-state {{if $v['is_show'] eq 1}}am-success{{else /}}am-default{{/if}}" data-url="{{:MyUrl('admin/goodscomments/statusupdate')}}" data-id="{{$v.id}}" data-state="{{$v['is_show']}}" data-is-update-status="1"></a>
</td>
<td>
......@@ -139,8 +169,29 @@
</div>
<div class="am-popup-bd">
<dl class="dl-content">
<dt>商品信息</dt>
<dd class="goods-info am-hide-md-down">
{{if !empty($v['user'])}}
<div class="base">
<a href="{{$v.goods.goods_url}}" target="_blank">
<img src="{{$v.goods.images}}" alt="{{$v.goods.title}}" class="am-img-thumbnail am-radius am-align-left" />
</a>
<a class="am-text-top" href="{{$v.goods.goods_url}}" target="_blank">
{{if mb_strlen($v['goods']['title']) gt 23}}
{{:mb_substr($v['goods']['title'], 0, 23, 'utf-8')}} ...
{{else /}}
{{$v.goods.title}}
{{/if}}
</a>
</div>
<p>¥{{$v.goods.min_price}}</p>
{{else /}}
商品信息异常
{{/if}}
</dd>
<dt>用户信息</dt>
<dd>
<dd class="user-info">
{{if !empty($v['user'])}}
<img src="{{$v.user.avatar}}" alt="{{$v.user.user_name_view}}" class="am-img-thumbnail am-radius am-align-left" />
<ul class="user-base">
......@@ -155,31 +206,36 @@
</dd>
<dt>业务类型</dt>
<dd>{{$v.business_type}}</dd>
<dd>{{$v.business_type_text}}</dd>
<dt>内容</dt>
<dt>评价内容</dt>
<dd>{{$v.content|raw}}</dd>
<dt>匿名</dt>
<dt>是否匿名</dt>
<dd>{{$v.is_anonymous_text}}</dd>
<dt>是否显示</dt>
<dd>{{if empty($v['is_show_text'])}}<span class="cr-ddd">未填写</span>{{else /}}{{$v.is_show_text}}{{/if}}</dd>
<dt>是否回复</dt>
<dd>{{$v.is_reply_text}}</dd>
<dt>回复内容</dt>
<dd>
{{if $v['is_reply'] eq 1 and !empty($v['reply'])}}
<div class="reply-content">
{{$v.reply|raw}}
</div>
<p>{{$v.reply_time_time}}</p>
{{else /}}
<span class="cr-ddd">未回复</span>
{{/if}}
</dd>
<dt>匿名</dt>
<dd>{{$v.reply_time}}</dd>
<dt>回复时间</dt>
<dd>{{$v.reply_time_time}}</dd>
<dt>更新时间</dt>
<dd>{{$v.upd_time_time}}</dd>
<dt>创建时间</dt>
<dd>{{$v.add_time_time}}</dd>
......@@ -189,13 +245,11 @@
</div>
</td>
<td class="view-operation">
<a href="{{:MyUrl('admin/goodscomments/saveinfo', array_merge($params, ['id'=>$v['id']]))}}">
<button class="am-btn am-btn-secondary am-btn-xs am-radius am-icon-edit"> 编辑</button>
</a>
<a href="{{:MyUrl('admin/goodscomments/saveinfo', array_merge($params, ['id'=>$v['id']]))}}" class="am-btn am-btn-secondary am-btn-xs am-radius am-btn-block am-icon-edit"> 编辑</a>
{{if $v['is_reply'] eq 0}}
<button class="am-btn am-btn-success am-btn-xs am-radius submit-reply am-icon-gavel" data-am-modal="{target: '#my-popup-reply'}" data-json='{{:json_encode($v)}}'> 回复</button>
<button class="am-btn am-btn-success am-btn-xs am-radius am-btn-block submit-reply am-icon-gavel" data-am-modal="{target: '#my-popup-reply'}" data-json='{{:json_encode($v)}}'> 回复</button>
{{/if}}
<button class="am-btn am-btn-danger am-btn-xs am-radius am-icon-trash-o submit-delete" data-url="{{:MyUrl('admin/goodscomments/delete')}}" data-id="{{$v.id}}"> 删除</button>
<button class="am-btn am-btn-danger am-btn-xs am-radius am-btn-block am-icon-trash-o submit-delete" data-url="{{:MyUrl('admin/goodscomments/delete')}}" data-id="{{$v.id}}"> 删除</button>
</td>
</tr>
{{/foreach}}
......
......@@ -49,8 +49,8 @@ class Goods extends Common
$goods_id = input('id');
$params = [
'where' => [
'id' => $goods_id,
'is_delete_time' => 0,
'id' => $goods_id,
'is_delete_time' => 0,
],
'is_photo' => true,
'is_spec' => true,
......@@ -66,7 +66,7 @@ class Goods extends Common
$ret['data'][0]['is_favor'] = ($ret_favor['code'] == 0) ? $ret_favor['data'] : 0;
// 商品评价总数
$ret['data'][0]['comments_count'] = GoodsCommentsService::GoodsCommentsTotal(['goods_id'=>$goods_id]);
$ret['data'][0]['comments_count'] = GoodsCommentsService::GoodsCommentsTotal(['goods_id'=>$goods_id, 'is_show'=>1]);
// 商品收藏总数
$ret['data'][0]['favor_count'] = GoodsService::GoodsFavorTotal(['goods_id'=>$goods_id]);
......@@ -279,7 +279,10 @@ class Goods extends Common
$page = max(1, isset($params['page']) ? intval($params['page']) : 1);
// 条件
$where = ['goods_id'=>$params['goods_id']];
$where = [
'goods_id' => $params['goods_id'],
'is_show' => 1,
];
// 获取总数
$total = GoodsCommentsService::GoodsCommentsTotal($where);
......
......@@ -191,7 +191,7 @@ class Order extends Common
{
$params = input('post.');
$params['user'] = $this->user;
$params['business_type'] = '订单';
$params['business_type'] = 'order';
return GoodsCommentsService::Comments($params);
} else {
$this->assign('msg', '非法访问');
......
......@@ -12,6 +12,7 @@ namespace app\service;
use think\Db;
use app\service\UserService;
use app\service\GoodsService;
/**
* 商品评论服务层
......@@ -22,6 +23,11 @@ use app\service\UserService;
*/
class GoodsCommentsService
{
// 业务类型
public static $business_type_list = [
'order' => '订单',
];
/**
* 订单评价
* @author Devil
......@@ -173,7 +179,19 @@ class GoodsCommentsService
$v['user'] = $user;
}
// 获取商品信息
$goods_params = [
'where' => [
'id' => $v['goods_id'],
'is_delete_time' => 0,
],
'field' => 'id,title,images,price,min_price',
];
$ret = GoodsService::GoodsList($goods_params);
$v['goods'] = isset($ret['data'][0]) ? $ret['data'][0] : [];
// 业务类型
$v['business_type_text'] = array_key_exists($v['business_type'], self::$business_type_list) ? self::$business_type_list[$v['business_type']] : null;
$msg = null;
switch($v['business_type'])
{
......@@ -186,16 +204,22 @@ class GoodsCommentsService
// 是否
$v['is_reply_text'] = isset($common_is_text_list[$v['is_reply']]) ? $common_is_text_list[$v['is_reply']]['name'] : '';
$v['is_anonymous_text'] = isset($common_is_text_list[$v['is_anonymous']]) ? $common_is_text_list[$v['is_anonymous']]['name'] : '';
$v['is_show_text'] = isset($common_is_text_list[$v['is_show']]) ? $common_is_text_list[$v['is_show']]['name'] : '';
// 回复时间
$v['reply_time_time'] = empty($v['reply_time']) ? null : date('Y-m-d H:i:s', $v['reply_time']);
$v['reply_time_date'] = empty($v['reply_time']) ? null : date('Y-m-d', $v['reply_time']);
// 评论时间
$v['add_time_time'] = date('Y-m-d H:i:s', $v['add_time']);
$v['add_time_date'] = date('Y-m-d', $v['add_time']);
// 回复时间
$v['reply_time_time'] = empty($v['reply_time']) ? null : date('Y-m-d H:i:s', $v['reply_time']);
$v['reply_time_date'] = empty($v['reply_time']) ? null : date('Y-m-d', $v['reply_time']);
// 更新时间
$v['upd_time_time'] = empty($v['upd_time']) ? null : date('Y-m-d H:i:s', $v['upd_time']);
$v['upd_time_date'] = empty($v['upd_time']) ? null : date('Y-m-d', $v['upd_time']);
}
}
//print_r($data);
return DataReturn('处理成功', 0, $data);
}
......@@ -292,6 +316,10 @@ class GoodsCommentsService
if(isset($params['is_more']) && $params['is_more'] == 1)
{
// 等值
if(isset($params['is_show']) && $params['is_show'] > -1)
{
$where[] = ['is_show', '=', intval($params['is_show'])];
}
if(isset($params['is_anonymous']) && $params['is_anonymous'] > -1)
{
$where[] = ['is_anonymous', '=', intval($params['is_anonymous'])];
......@@ -302,7 +330,7 @@ class GoodsCommentsService
}
if(!empty($params['business_type']))
{
$where[] = ['business_type', '='. $params['business_type']];
$where[] = ['business_type', '=', $params['business_type']];
}
......@@ -318,5 +346,132 @@ class GoodsCommentsService
return $where;
}
/**
* 删除
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-30
* @desc description
* @param [array] $params [输入参数]
*/
public static function GoodsCommentsDelete($params = [])
{
// 请求参数
$p = [
[
'checked_type' => 'empty',
'key_name' => 'id',
'error_msg' => '操作id有误',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
// 开始删除
if(Db::name('GoodsComments')->where(['id'=>$comments_id])->delete())
{
return DataReturn('删除成功', 0);
}
return DataReturn('删除失败或数据不存在', -100);
}
/**
* 回复
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-12-18
* @desc description
* @param [array] $params [输入参数]
*/
public static function GoodsCommentsReply($params = [])
{
// 请求参数
$p = [
[
'checked_type' => 'empty',
'key_name' => 'id',
'error_msg' => '操作id有误',
],
[
'checked_type' => 'empty',
'key_name' => 'reply',
'error_msg' => '回复内容不能为空',
],
[
'checked_type' => 'length',
'key_name' => 'reply',
'checked_data' => '1,230',
'error_msg' => '回复内容格式 1~230 个字符',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
// 评论是否存在
$comments_id = Db::name('GoodsComments')->field('id')->find(intval($params['id']));
if(empty($comments_id))
{
return DataReturn('资源不存在或已被删除', -2);
}
// 更新问答
$data = [
'reply' => $params['reply'],
'is_reply' => 1,
'reply_time' => time(),
'upd_time' => time()
];
if(Db::name('GoodsComments')->where(['id'=>$comments_id])->update($data))
{
return DataReturn('操作成功');
}
return DataReturn('操作失败', -100);
}
/**
* 状态更新
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-06T21:31:53+0800
* @param [array] $params [输入参数]
*/
public static function GoodsCommentsStatusUpdate($params = [])
{
// 请求参数
$p = [
[
'checked_type' => 'empty',
'key_name' => 'id',
'error_msg' => '操作id有误',
],
[
'checked_type' => 'in',
'key_name' => 'state',
'checked_data' => [0,1],
'error_msg' => '状态有误',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
// 数据更新
if(Db::name('GoodsComments')->where(['id'=>intval($params['id'])])->update(['is_show'=>intval($params['state'])]))
{
return DataReturn('编辑成功');
}
return DataReturn('编辑失败或数据未改变', -100);
}
}
?>
\ No newline at end of file
此差异已折叠。
/**
* 列表
*/
.form-keyword { width: 55% !important; display: initial !important; }
.more-submit input { display: none; }
.param-where, .param-date input { display: initial !important; }
@media only screen and (max-width: 641px) {
.param-where { width: 100% !important; margin-left: 0px !important; }
.param-date input { width: 47% !important; }
.courier-health-images-list li { width: calc( 50% - 10px) !important; }
.courier-health-images-list { width: 100%; }
}
@media only screen and (min-width: 641px) {
.param-where { width: 32% !important; float: left; }
.param-date input { width: 45% !important; }
.param-where:nth-child(1) { margin-left: 0px !important; }
.courier-health-images-list { width: 75%; }
}
table.am-table .reply-content { max-width: 200px; max-height: 200px; overflow-y: scroll; overflow-x: hidden; }
@media only screen and (max-width: 321px) {
.view-operation button { margin: 2px 0px; }
}
/**
* 列表
*/
table.am-table .reply-content { max-width: 200px; max-height: 200px; overflow-y: scroll; overflow-x: hidden; }
\ No newline at end of file
.view-operation button { margin: 2px 0px; }
}
\ No newline at end of file
/**
* 用户信息
*/
.content-right table.am-table td.user-info {
width: 200px;
}
.content-right .user-info img {
max-width: 35px;
max-height: 35px;
margin: 0 5px 2px 0;
}
.content-right ul {
list-style: none;
padding: 0;
margin: 0;
}
/**
* 商品信息
*/
.content-right table.am-table td.goods-info {
width: 180px;
}
.content-right .goods-info .base {
min-height: 57px;
}
.content-right .goods-info img {
width: 55px;
height: 55px;
margin: 2px 5px 0px 0;
}
.content-right .goods-info p {
margin: 3px 0 0 0;
}
/**
* 列表
*/
.content-right table.am-table .reply-content {
max-width: 180px;
max-height: 130px;
overflow-y: scroll;
overflow-x: hidden;
}
.content-right table.am-table .reply-content p {
margin: 5px 0 0 0;
}
.content-right table.am-table .view-operation {
width: 85px;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册