Goodscomments.php 6.3 KB
Newer Older
D
devil_gong 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\admin\controller;

use app\service\GoodsCommentsService;

/**
D
devil_gong 已提交
16
 * 商品评论管理
D
devil_gong 已提交
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
 * @author   Devil
 * @blog     http://gong.gg/
 * @version  0.0.1
 * @datetime 2016-12-01T21:51:08+0800
 */
class Goodscomments extends Common
{
    /**
     * 构造方法
     * @author   Devil
     * @blog     http://gong.gg/
     * @version  0.0.1
     * @datetime 2016-12-03T12:39:08+0800
     */
    public function __construct()
    {
        // 调用父类前置方法
        parent::__construct();

        // 登录校验
        $this->IsLogin();

        // 权限校验
        $this->IsPower();
    }

    /**
     * 问答列表
     * @author   Devil
     * @blog     http://gong.gg/
     * @version  0.0.1
     * @datetime 2016-12-06T21:31:53+0800
     */
    public function Index()
    {
D
devil 已提交
52 53
        // 总数
        $total = GoodsCommentsService::GoodsCommentsTotal($this->form_where);
D
devil_gong 已提交
54 55

        // 分页
D
devil 已提交
56 57 58 59 60 61 62
        $page_params = [
            'number'    =>  $this->page_size,
            'total'     =>  $total,
            'where'     =>  $this->data_request,
            'page'      =>  $this->page,
            'url'       =>  MyUrl('admin/goodscomments/index'),
        ];
D
devil_gong 已提交
63 64 65
        $page = new \base\Page($page_params);

        // 获取列表
D
devil 已提交
66 67 68 69
        $data_params = [
            'where'         => $this->form_where,
            'm'             => $page->GetPageStarNumber(),
            'n'             => $this->page_size,
D
devil 已提交
70
            'order_by'      => $this->form_order_by['data'],
D
devil 已提交
71 72 73 74
            'is_public'     => 0,
        ];
        $ret = GoodsCommentsService::GoodsCommentsList($data_params);

D
devil 已提交
75
        // 基础参数赋值
D
devil 已提交
76 77 78 79 80
        $this->assign('params', $this->data_request);
        $this->assign('page_html', $page->GetPageHtml());
        $this->assign('data_list', $ret['data']);
        return $this->fetch();
    }
D
devil_gong 已提交
81

D
devil 已提交
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
    /**
     * 详情
     * @author   Devil
     * @blog     http://gong.gg/
     * @version  1.0.0
     * @datetime 2019-08-05T08:21:54+0800
     */
    public function Detail()
    {
        if(!empty($this->data_request['id']))
        {
            // 条件
            $where = [
                ['id', '=', intval($this->data_request['id'])],
            ];
D
devil_gong 已提交
97

D
devil 已提交
98 99 100 101 102 103 104 105 106 107 108 109
            // 获取列表
            $data_params = [
                'm'             => 0,
                'n'             => 1,
                'where'         => $where,
            ];
            $ret = GoodsCommentsService::GoodsCommentsList($data_params);
            $data = (empty($ret['data']) || empty($ret['data'][0])) ? [] : $ret['data'][0];
            $this->assign('data', $data);

            $this->assign('common_goods_comments_rating_list', lang('common_goods_comments_rating_list'));
        }
D
devil_gong 已提交
110 111 112 113 114 115 116 117 118 119 120 121 122
        return $this->fetch();
    }

    /**
     * [SaveInfo 添加/编辑页面]
     * @author   Devil
     * @blog     http://gong.gg/
     * @version  0.0.1
     * @datetime 2016-12-14T21:37:02+0800
     */
    public function SaveInfo()
    {
        // 参数
D
devil 已提交
123
        $params = $this->data_request;
D
devil_gong 已提交
124 125 126 127 128 129 130

        // 数据
        $data = [];
        if(!empty($params['id']))
        {
            // 获取列表
            $data_params = array(
D
devil_gong 已提交
131 132 133 134
                'm'         => 0,
                'n'         => 1,
                'where'     => ['id'=>intval($params['id'])],
                'is_public' => 0,
D
devil_gong 已提交
135
            );
D
devil_gong 已提交
136
            $ret = GoodsCommentsService::GoodsCommentsList($data_params);
D
devil_gong 已提交
137 138 139 140
            $data = empty($ret['data'][0]) ? [] : $ret['data'][0];
        }
        $this->assign('data', $data);

D
devil_gong 已提交
141
        // 静态数据
D
devil_gong 已提交
142 143
        $this->assign('common_is_show_list', lang('common_is_show_list'));
        $this->assign('common_is_text_list', lang('common_is_text_list'));
D
devil_gong 已提交
144
        $this->assign('common_goods_comments_rating_list', lang('common_goods_comments_rating_list'));
D
devil 已提交
145
        $this->assign('common_goods_comments_business_type_list', lang('common_goods_comments_business_type_list'));
D
devil_gong 已提交
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169

        // 参数
        unset($params['id']);
        $this->assign('params', $params);

        return $this->fetch();
    }

    /**
     * [Save 保存]
     * @author   Devil
     * @blog     http://gong.gg/
     * @version  0.0.1
     * @datetime 2016-12-25T22:36:12+0800
     */
    public function Save()
    {
        // 是否ajax请求
        if(!IS_AJAX)
        {
            return $this->error('非法访问');
        }

        // 开始处理
D
devil 已提交
170
        $params = $this->data_request;
D
devil_gong 已提交
171
        return GoodsCommentsService::GoodsCommentsSave($params);
D
devil_gong 已提交
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
    }

    /**
     * 问答删除
     * @author   Devil
     * @blog     http://gong.gg/
     * @version  0.0.1
     * @datetime 2016-12-15T11:03:30+0800
     */
    public function Delete()
    {
        // 是否ajax请求
        if(!IS_AJAX)
        {
            return $this->error('非法访问');
        }

        // 开始处理
D
devil 已提交
190
        $params = $this->data_request;
G
gongfuxiang 已提交
191
        return GoodsCommentsService::GoodsCommentsDelete($params);
D
devil_gong 已提交
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
    }

    /**
     * 问答回复处理
     * @author   Devil
     * @blog     http://gong.gg/
     * @version  1.0.0
     * @datetime 2018-03-28T15:07:17+0800
     */
    public function Reply()
    {
        // 是否ajax请求
        if(!IS_AJAX)
        {
            return $this->error('非法访问');
        }

        // 开始处理
D
devil 已提交
210
        $params = $this->data_request;
G
gongfuxiang 已提交
211
        return GoodsCommentsService::GoodsCommentsReply($params);
D
devil_gong 已提交
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
    }

    /**
     * 状态更新
     * @author   Devil
     * @blog     http://gong.gg/
     * @version  0.0.1
     * @datetime 2017-01-12T22:23:06+0800
     */
    public function StatusUpdate()
    {
        // 是否ajax请求
        if(!IS_AJAX)
        {
            return $this->error('非法访问');
        }

        // 开始处理
D
devil 已提交
230
        $params = $this->data_request;
G
gongfuxiang 已提交
231
        return GoodsCommentsService::GoodsCommentsStatusUpdate($params);
D
devil_gong 已提交
232 233 234
    }
}
?>