文件
mashangyoujiu/Application/Retail/Controller/CommentController.class.php

120 行
4.1 KiB
PHP
可执行文件

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
namespace Retail\Controller;
//[1.6.9]
/**
* Class CommentController
* @package Retail\Controller 门店评论
*/
class CommentController extends BaseController
{
public function comment()
{
$arr = array(
'deleteComment' => '/index.php/Retail/Comment/deleteComment',
'deleteComments' => '/index.php/Retail/Comment/deleteComments',
);
$authArr = checkFunction($arr);
$this->assign('authArr', $authArr);
$this->display();
}
public function commentList()
{
$addtime = I('post.add_time');
$where = array(
'storeid' => $this->store_id,
'merchantid' => $this->merchant_id,
'status' => 1,
);
if (!empty($addtime)) {
$start_time = strtotime($addtime[0]);
$end_time = strtotime($addtime[1]);
$where['addtime'] = array('between', array($start_time, $end_time));
}
//根据商户id查询出门店评价信息
$comment_count = M('retail_evalute')
->where($where)
->count();
$comments = M('retail_evalute')
->where($where)
->order('addtime desc')->page($_POST['page'], $_POST['limit'])->select();
foreach ($comments as $key => &$value) {
$value['key'] = $key + 1; //序号
//用户昵称
$value['vip_name'] = M('retail_xcxvip')->where(array('id' => $value['uid']))->getField('nickname');
//门店名称
$value['store_name'] = M('retail_store')->where(array('id' => $value['storeid']))->getField('storetag');
//转换时间戳
$value['addtime'] = date('Y-m-d H:i:s', $value['addtime']);
}
$res['code'] = 0;
$res['msg'] = '';
$res['data'] = $comments;
$res['count'] = $comment_count;
$this->ajaxReturn($res);
}
//单个删除
public function deleteComment()
{
if (IS_POST) {
$id = $_POST['id'];
// var_dump($id);
if ($id) {
$delete = M('retail_evalute')->where(array('id' => $id))->setField('status', 0);
if ($delete) {
$res['status'] = 1;
$res['msg'] = '删除成功';
//操作日志记录
$source = 0; //请求来源: 0pc系统 1小助手
$type = 4; //平台:1合伙人端 2代理商端 3商户端 4门店端
$request_data = json_encode($_POST); //请求参数 json数据
$desc = '外卖订单-评价信息单个删除'; //操作行为描述
action_log($source, $type, $request_data, $desc);
//end
} else {
$res['status'] = 0;
$res['msg'] = '删除失败';
}
} else {
$res['status'] = 0;
$res['msg'] = '删除失败';
}
$this->ajaxReturn($res);
}
}
/**
* 批量选择删除
*/
public function deleteComments()
{
if (IS_POST) {
$ids = $_POST['id'];
$new_id = explode(',', trim($ids, ','));
// var_dump($new_id);
foreach ($new_id as $key => $value) {
$delete = M('retail_evalute')->where(array('id' => $value))->setField('status', 0);
}
if ($delete) {
$res['status'] = 1;
$res['msg'] = '删除成功';
//操作日志记录
$source = 0; //请求来源: 0pc系统 1小助手
$type = 4; //平台:1合伙人端 2代理商端 3商户端 4门店端
$request_data = json_encode($_POST); //请求参数 json数据
$desc = '外卖订单-评价信息批量删除'; //操作行为描述
action_log($source, $type, $request_data, $desc);
//end
} else {
$res['status'] = 0;
$res['msg'] = '删除失败';
}
$this->ajaxReturn($res);
}
}
}