mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2024-12-03 04:19:37 +08:00
订单评价
This commit is contained in:
parent
c485e2eafa
commit
a9b43af8e3
@ -54,6 +54,9 @@ class GoodsController extends CommonController
|
||||
$ret_favor = GoodsService::IsUserGoodsFavor(['goods_id'=>$id, 'user'=>$this->user]);
|
||||
$goods[0]['is_favor'] = ($ret_favor['code'] == 0) ? $ret_favor['data'] : 0;
|
||||
|
||||
// 商品评价总数
|
||||
$goods[0]['comments_count'] = GoodsService::GoodsCommentsTotal($id);
|
||||
|
||||
$this->assign('goods', $goods[0]);
|
||||
$this->assign('home_seo_site_title', $goods[0]['title']);
|
||||
|
||||
|
@ -137,7 +137,7 @@ class OrderController extends CommonController
|
||||
* @date 2018-10-08
|
||||
* @desc description
|
||||
*/
|
||||
public function CommentsInfo()
|
||||
public function Comments()
|
||||
{
|
||||
// 参数
|
||||
$params = array_merge($_POST, $_GET);
|
||||
@ -155,14 +155,37 @@ class OrderController extends CommonController
|
||||
$data = OrderService::OrderList($data_params);
|
||||
if(!empty($data['data'][0]))
|
||||
{
|
||||
$this->assign('referer_url', empty($_SERVER['HTTP_REFERER']) ? U('Home/Order/Index') : $_SERVER['HTTP_REFERER']);
|
||||
$this->assign('data', $data['data'][0]);
|
||||
$this->display('CommentsInfo');
|
||||
$this->display('Comments');
|
||||
} else {
|
||||
$this->assign('msg', L('common_not_data_tips'));
|
||||
$this->display('/Public/TipsError');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 评价保存
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-10-09
|
||||
* @desc description
|
||||
*/
|
||||
public function CommentsSave()
|
||||
{
|
||||
if(IS_POST)
|
||||
{
|
||||
$params = $_POST;
|
||||
$params['user'] = $this->user;
|
||||
$ret = OrderService::Comments($params);
|
||||
$this->ajaxReturn($ret['msg'], $ret['code'], $ret['data']);
|
||||
} else {
|
||||
$this->assign('msg', L('common_unauthorized_access'));
|
||||
$this->display('/Public/TipsError');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单支付
|
||||
* @author Devil
|
||||
|
@ -90,7 +90,7 @@
|
||||
<div class="tm-indcon"><span class="tm-label">浏览次数</span><span class="tm-count">{{$goods.access_count}}</span></div>
|
||||
</li>
|
||||
<li class="tm-ind-item tm-ind-reviewCount canClick tm-line3">
|
||||
<div class="tm-indcon"><span class="tm-label">累计评价</span><span class="tm-count">640</span></div>
|
||||
<div class="tm-indcon"><span class="tm-label">累计评价</span><span class="tm-count">{{$goods.comments_count}}</span></div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
104
service/Application/Home/View/Default/Order/Comments.html
Normal file
104
service/Application/Home/View/Default/Order/Comments.html
Normal file
@ -0,0 +1,104 @@
|
||||
<include file="Public/Header" />
|
||||
|
||||
<!-- header top nav -->
|
||||
<include file="Public/HeaderTopNav" />
|
||||
|
||||
<!-- search -->
|
||||
<include file="Public/NavSearch" />
|
||||
|
||||
<!-- header nav -->
|
||||
<include file="Public/HeaderNav" />
|
||||
|
||||
<!-- goods category -->
|
||||
<include file="Public/GoodsCategory" />
|
||||
|
||||
<!-- content -->
|
||||
<div class="am-container user-main">
|
||||
|
||||
<!-- user menu start -->
|
||||
<include file="Public/UserMenu" />
|
||||
<!-- user menu end -->
|
||||
|
||||
<!-- content start -->
|
||||
<div class="user-content">
|
||||
<div class="user-content-body">
|
||||
<if condition="$data['user_is_comments'] eq 0">
|
||||
<form class="am-form form-validation" method="post" action="{{:U('Home/Order/CommentsSave')}}" request-type="ajax-url" request-value="{{$referer_url}}">
|
||||
<!-- 商品列表 -->
|
||||
<notempty name="data.items">
|
||||
<div class="order-goods">
|
||||
<table class="am-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>商品信息</th>
|
||||
<th class="am-hide-sm-only">单价</th>
|
||||
<th>评价内容</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<foreach name="data.items" item="goods">
|
||||
<tr id="data-list-{{$goods.id}}" data-id="{{$goods.id}}" data-goods-id="{{$goods.goods_id}}">
|
||||
<td class="base">
|
||||
<div class="goods-detail">
|
||||
<a href="{{$goods.goods_url}}" target="_blank">
|
||||
<img src="{{$goods.images}}">
|
||||
</a>
|
||||
<div class="goods-base">
|
||||
<a href="{{$goods.goods_url}}" target="_blank" class="goods-title">{{$goods.title}}</a>
|
||||
<notempty name="goods.attribute">
|
||||
<ul class="goods-attr">
|
||||
<foreach name="goods.attribute" item="attr">
|
||||
<li>{{$attr.attr_type_name}}:{{$attr.attr_name}}</li>
|
||||
</foreach>
|
||||
</ul>
|
||||
</notempty>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wap-base am-show-sm-only">
|
||||
<if condition="$goods['original_price'] gt 0">
|
||||
<span class="original-price">¥{{$goods.original_price}}</span>
|
||||
</if>
|
||||
<strong class="total-price-content">¥{{$goods.price}}</strong>
|
||||
<span class="wap-number">x{{$goods.buy_number}}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="price am-hide-sm-only">
|
||||
<if condition="$goods['original_price'] gt 0">
|
||||
<p class="original-price">¥{{$goods.original_price}}</p>
|
||||
</if>
|
||||
<p class="line-price">¥{{$goods.price}} x {{$goods.buy_number}}</p>
|
||||
</td>
|
||||
<td>
|
||||
<ul class="rating">
|
||||
<li><i class="am-icon-star-o am-icon-md"></i></li>
|
||||
<li><i class="am-icon-star-o am-icon-md"></i></li>
|
||||
<li><i class="am-icon-star-o am-icon-md"></i></li>
|
||||
<li><i class="am-icon-star-o am-icon-md"></i></li>
|
||||
<li><i class="am-icon-star-o am-icon-md"></i></li>
|
||||
</ul>
|
||||
<input type="hidden" name="goods_id[]" value="{{$goods.goods_id}}" />
|
||||
<input type="hidden" name="rating[]" value="0" class="input-rating" />
|
||||
<textarea name="content[]" class="am-radius" rows="4" maxlength="200" data-validation-message="最多200个字符"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</foreach>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</notempty>
|
||||
<div class="am-form-group">
|
||||
<input type="hidden" name="id" value="{{$data.id}}" />
|
||||
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm" data-am-loading="{loadingText:'{{:L('common_form_loading_tips')}}'}">{{:L('common_operation_submit')}}</button>
|
||||
</div>
|
||||
</form>
|
||||
<else />
|
||||
<div class="table-no"><i class="am-icon-warning"></i> 你已进行过评价</div>
|
||||
</if>
|
||||
</div>
|
||||
</div>
|
||||
<!-- content end -->
|
||||
</div>
|
||||
|
||||
<!-- footer start -->
|
||||
<include file="Public/Footer" />
|
||||
<!-- footer end -->
|
@ -1,33 +0,0 @@
|
||||
<include file="Public/Header" />
|
||||
|
||||
<!-- header top nav -->
|
||||
<include file="Public/HeaderTopNav" />
|
||||
|
||||
<!-- search -->
|
||||
<include file="Public/NavSearch" />
|
||||
|
||||
<!-- header nav -->
|
||||
<include file="Public/HeaderNav" />
|
||||
|
||||
<!-- goods category -->
|
||||
<include file="Public/GoodsCategory" />
|
||||
|
||||
<!-- content -->
|
||||
<div class="am-container user-main">
|
||||
|
||||
<!-- user menu start -->
|
||||
<include file="Public/UserMenu" />
|
||||
<!-- user menu end -->
|
||||
|
||||
<!-- content start -->
|
||||
<div class="user-content">
|
||||
<div class="user-content-body">
|
||||
hello
|
||||
</div>
|
||||
</div>
|
||||
<!-- content end -->
|
||||
</div>
|
||||
|
||||
<!-- footer start -->
|
||||
<include file="Public/Footer" />
|
||||
<!-- footer end -->
|
@ -170,7 +170,7 @@
|
||||
<button type="button" class="am-btn am-btn-secondary am-btn-xs am-radius submit-ajax submit-confirm" data-url="{{:U('Home/Order/Collect')}}" data-id="{{$data.id}}" data-view="reload" data-msg="请仔细确认已收到货物、确认继续吗?">收货</button>
|
||||
</if>
|
||||
<if condition="in_array($data['status'], [4]) and $data['user_is_comments'] eq 0">
|
||||
<a href="{{:U('Home/Order/CommentsInfo', ['id'=>$data['id']])}}" target="_blank" class="am-btn am-btn-primary am-btn-xs am-radius">评价</a>
|
||||
<a href="{{:U('Home/Order/Comments', ['id'=>$data['id']])}}" target="_blank" class="am-btn am-btn-primary am-btn-xs am-radius">评价</a>
|
||||
</if>
|
||||
<if condition="in_array($data['status'], [4,5,6])">
|
||||
<button type="button" class="am-btn am-btn-danger am-btn-xs am-radius submit-delete" data-url="{{:U('Home/Order/Delete')}}" data-id="{{$data.id}}" data-view="jump" data-jump="{{:U('Home/Order/Index')}}">删除</button>
|
||||
|
@ -186,7 +186,7 @@
|
||||
<button type="button" class="am-btn am-btn-secondary am-btn-xs am-radius am-btn-block submit-ajax submit-confirm" data-url="{{:U('Home/Order/Collect')}}" data-id="{{$order.id}}" data-view="reload" data-msg="请仔细确认已收到货物、确认继续吗?">收货</button>
|
||||
</if>
|
||||
<if condition="in_array($order['status'], [4]) and $order['user_is_comments'] eq 0">
|
||||
<a href="{{:U('Home/Order/CommentsInfo', ['id'=>$order['id']])}}" target="_blank" class="am-btn am-btn-primary am-btn-xs am-radius am-btn-block">评价</a>
|
||||
<a href="{{:U('Home/Order/Comments', ['id'=>$order['id']])}}" target="_blank" class="am-btn am-btn-primary am-btn-xs am-radius am-btn-block">评价</a>
|
||||
</if>
|
||||
<if condition="in_array($order['status'], [4,5,6])">
|
||||
<button type="button" class="am-btn am-btn-danger am-btn-xs am-radius am-btn-block submit-delete" data-url="{{:U('Home/Order/Delete')}}" data-id="{{$order.id}}" data-view="reload">删除</button>
|
||||
|
@ -390,5 +390,19 @@ class GoodsService
|
||||
$temp = $m->where($data)->find();
|
||||
return DataReturn(L('common_operation_success'), 0, empty($temp) ? 0 : 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品评论总数
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-09-29
|
||||
* @desc description
|
||||
* @param [array] $where [条件]
|
||||
*/
|
||||
public static function GoodsCommentsTotal($goods_id)
|
||||
{
|
||||
return (int) M('OrderComments')->where(['goods_id'=>intval($goods_id)])->count();
|
||||
}
|
||||
}
|
||||
?>
|
@ -875,5 +875,116 @@ class OrderService
|
||||
return DataReturn(L('common_operation_delete_error'), -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单评价
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @date 2018-10-09
|
||||
* @desc description
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function Comments($params = [])
|
||||
{
|
||||
// 请求参数
|
||||
$p = [
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'id',
|
||||
'error_msg' => '订单id有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'isset',
|
||||
'key_name' => 'goods_id',
|
||||
'error_msg' => '商品id有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'is_array',
|
||||
'key_name' => 'goods_id',
|
||||
'error_msg' => '商品数据格式有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'isset',
|
||||
'key_name' => 'rating',
|
||||
'error_msg' => '评级有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'is_array',
|
||||
'key_name' => 'rating',
|
||||
'error_msg' => '评级数据格式有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'isset',
|
||||
'key_name' => 'content',
|
||||
'error_msg' => '评价内容有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'is_array',
|
||||
'key_name' => 'content',
|
||||
'error_msg' => '评价内容数据格式有误',
|
||||
],
|
||||
[
|
||||
'checked_type' => 'empty',
|
||||
'key_name' => 'user',
|
||||
'error_msg' => '用户信息有误',
|
||||
],
|
||||
];
|
||||
$ret = params_checked($params, $p);
|
||||
if($ret !== true)
|
||||
{
|
||||
return DataReturn($ret, -1);
|
||||
}
|
||||
|
||||
// 获取订单信息
|
||||
$order_id = intval($params['id']);
|
||||
$order_m = M('Order');
|
||||
$where = ['id'=>$order_id, 'user_id'=>$params['user']['id'], 'is_delete_time'=>0, 'user_is_delete_time'=>0];
|
||||
$order = $order_m->where($where)->field('id,status,shop_id,user_is_comments')->find();
|
||||
if(empty($order))
|
||||
{
|
||||
return DataReturn(L('common_data_no_exist_error'), -1);
|
||||
}
|
||||
if($order['status'] != 4)
|
||||
{
|
||||
$status_text = L('common_order_user_status')[$order['status']]['name'];
|
||||
return DataReturn('状态不可操作['.$status_text.']', -1);
|
||||
}
|
||||
if($order['user_is_comments'] != 0)
|
||||
{
|
||||
return DataReturn('该订单你已进行过评价', -10);
|
||||
}
|
||||
|
||||
// 处理数据
|
||||
$comments_m = M('OrderComments');
|
||||
$comments_m->startTrans();
|
||||
foreach($params['goods_id'] as $k=>$goods_id)
|
||||
{
|
||||
$data = [
|
||||
'user_id' => $params['user']['id'],
|
||||
'shop_id' => $order['shop_id'],
|
||||
'order_id' => $order_id,
|
||||
'goods_id' => $goods_id,
|
||||
'content' => isset($params['content'][$k]) ? htmlspecialchars(trim($params['content'][$k])) : '',
|
||||
'rating' => isset($params['rating'][$k]) ? intval($params['rating'][$k]) : 0,
|
||||
'add_time' => time(),
|
||||
];
|
||||
if($comments_m->add($data) <= 0)
|
||||
{
|
||||
$comments_m->rollback();
|
||||
return DataReturn('评价内容添加失败', -100);
|
||||
}
|
||||
}
|
||||
|
||||
// 订单评价状态更新
|
||||
if(!$order_m->where($where)->save(['user_is_comments'=>time(), 'upd_time'=>time()]))
|
||||
{
|
||||
$comments_m->rollback();
|
||||
return DataReturn('订单更新失败', -101);
|
||||
}
|
||||
|
||||
$comments_m->commit();
|
||||
return DataReturn(L('common_operation_comments_success'), 0);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
43
service/Public/Home/Default/Css/Order.Comments.css
Normal file
43
service/Public/Home/Default/Css/Order.Comments.css
Normal file
@ -0,0 +1,43 @@
|
||||
ul.rating {
|
||||
overflow: hidden;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
ul.rating li {
|
||||
float: left;
|
||||
margin-right: 10px;
|
||||
}
|
||||
ul.rating li i.am-icon-star-o {
|
||||
color: #888;
|
||||
}
|
||||
ul.rating li i.am-icon-star {
|
||||
color: #d13b49;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
.order-goods { margin-top: 20px; }
|
||||
.goods-detail img { width: 80px; height: 80px; }
|
||||
.goods-detail { position: relative; }
|
||||
.goods-title { display: block; max-height: 36px; overflow: hidden; text-overflow: ellipsis; }
|
||||
.goods-title:hover { text-decoration: underline; }
|
||||
.goods-base { position: absolute; top: 0; left: 85px; }
|
||||
.goods-attr { margin-top: 5px; }
|
||||
.goods-attr li { color: #888; line-height: 16px; }
|
||||
.original-price, .line-price { font-family: Verdana,Tahoma,arial; }
|
||||
.original-price { color: #9c9c9c; text-decoration: line-through; }
|
||||
.line-price { color: #3c3c3c; }
|
||||
.line-price, strong.total-price-content { font-weight: 700; }
|
||||
strong.total-price-content { color: #d2364c; font-size: 16px; }
|
||||
.am-table { margin-bottom: 10px; }
|
||||
.am-table > tbody > tr > td { border-top: 1px solid #F5F5F5; }
|
||||
.am-table > thead > tr > th { border-bottom: 1px solid #f7f7f7; }
|
||||
|
||||
@media only screen and (min-width:640px) {
|
||||
.cart-content table tr .base { width: 40%; }
|
||||
.cart-content table tr .price { width: 20%; }
|
||||
.cart-content table tr .number { width: 20%; }
|
||||
.cart-content table tr .total-price { width: 20%; }
|
||||
.cart-content { margin-top: 20px; }
|
||||
}
|
@ -67,4 +67,19 @@ $(function()
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* 评价打分
|
||||
*/
|
||||
$('ul.rating li').on('click', function()
|
||||
{
|
||||
$(this).parent().find('li i').removeClass('am-icon-star').addClass('am-icon-star-o');
|
||||
var index = $(this).index();
|
||||
for(var i=0; i<=index; i++)
|
||||
{
|
||||
$(this).parent().find('li').eq(i).find('i').removeClass('am-icon-star-o').addClass('am-icon-star');
|
||||
}
|
||||
$(this).parents('td').find('input.input-rating').val(index+1);
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user