<?php
/**
 * 客户服务控制器
 * @Copyright (C) 2016 汉潮 All rights reserved.
 * @License http://www.hanchao9999.com
 * @Author lss <lss@qq.com>
 */
namespace Admin\Controller;
class CustomerServiceController extends BaseController{
    /**
     * 投诉列表管理
     */
    public function complaint(){
        $name="Service";
        $map['type']=1;
        $list = $this->lists($name, $map);
        $this->assign('list', $list);
        $this->display();
    }
    /**
     * 回复投诉
     */
    public function edit(){
        $admin_info=session('admin_info');
        $id = I('get.id');
        $info = '';
        if (!$id) $this->error(L('PARAM_ERR'));
        $info = M('Service')->field(true)->find($id);
        $this->assign($info);
        $this->assign('adminid',$admin_info['id']);
        $this->display();
    }
    public function update(){
        $postdata=I('post.');
        $map['id']=$postdata['id'];
        $savedata['pid']=$postdata['pid'];
        $savedata['p_content']=$postdata['p_content'];
        $savedata['updatetime']=$postdata['updatetime'];
        $savedata['status']=1;
        $result=M('Service')->where($map)->save($savedata);
        if($result){
            if($postdata['type']==1){
                $this->success('回复成功',U('CustomerService/complaint'));
            }else{
                $this->success('回复成功',U('CustomerService/platformservice'));
            }
        }else{
            $this->error('回复失败',U('CustomerService/complaint'));
        }
    }
    /**
     * 投诉列表管理
     */
    public function platformservice(){
        $name="Service";
        $map['type']=array('neq',1);
        $list = $this->lists($name, $map);
        $this->assign('list', $list);
        $this->display();
    }
    public function delete(){exit();
        $postdate=I('param.');
        $map['id']=array('in',$postdate['id']);
        $deletes = M('Service')->where($map)->delete();
        if($deletes){
            $this->success('删除成功！');
        } else {
            $this->error('删除失败！');
        }
    }
}