// +---------------------------------------------------------------------- namespace app\home\controller; use think\Db; use think\Validate; use think\Request; use think\captcha\Captcha; class Feedback extends Base { public function submit(){ $rule = [ 'name'=>'require', 'tel'=>'require', 'platform'=>'require', 'account'=>'require', 'org'=>'require', 'target'=>'require', 'target_relation'=>'require', 'information'=>'require', 'economy_problem'=>'require', 'intro'=>'require', 'attach'=>'require', '__feedback__' =>'require|token:__feedback__' ]; $message = [ 'name'=>'姓名不能为空', 'tel'=>'手机号不能为空', 'platform'=>'参与平台不能为空', 'account'=>'客户账号不能为空', 'org'=>'所属机构不能为空', 'target'=>'客户投诉主体不能为空', 'target_relation'=>'与投诉主体的关系不能为空', 'information'=>'基本情况反馈不能为空', 'economy_problem'=>'经济问题反馈不能为空', 'intro'=>'相关协议及签署文件情况介绍不能为空', 'attach'=>'对应证明附件不能为空', '__feedback__.require'=>'令牌缺失' ]; $recharge=input('post.is_recharge', 0); $money=input('post.recharge_money', 0); $validate=new Validate($rule,$message); $result=$validate->check(input()); $error=''; if($recharge != 0 && $recharge != 1)$error='账号是否入金'; if($recharge == 1) { if(empty($money))$error='入金金额不能为空'; } if(!$result)$error=$validate->getError(); if(!empty($error)){ request()->token(); echo json_encode(['code' => 500, 'msg' => '失败', 'data' => $error,'token'=>request()->token('__feedback__')], JSON_UNESCAPED_UNICODE); return; } $data = array(); $data['name'] = input('post.name',''); $data['tel'] = input('post.tel',''); $data['platform'] = input('post.platform',''); $data['account'] = input('post.account',''); $data['is_recharge'] =$recharge; $data['recharge_money'] =$money; $data['org'] = input('post.org',''); $data['target'] = input('post.target',''); $data['target_relation'] = input('post.target_relation',''); $data['information'] = input('post.information',''); $data['economy_problem'] = input('post.economy_problem',''); $data['intro'] = input('post.intro',''); $data['attach'] = htmlspecialchars_decode(input('post.attach')); $data['create_time'] = time(); $query=Db::name('feedback')->insert($data); if($query){ $tels=config('complaint'); if(count($tels)){ foreach ($tels as $tel){ $weeks=[1=>'周一','周二','周三','周四','周五','周六','周日']; $week=date("N"); $cur=$weeks[$week]; $msg='【深圳文化产权交易所】'.date("Y年m月d日").$cur.date("H:i").'系统官网后台收到一条客户投诉消息,请及时查看处理!'; send_sms($tel,$msg); } } } echo json_encode(['code' => 200, 'msg' => '成功', 'data' => ''], JSON_UNESCAPED_UNICODE); } public function review(){ $token=input('token'); $id=input('id'); if(md5('szwjs_'.$id)!=$token){ $this->error('无权限操作'); } $doc = Db::name('feedback')->where(['id'=>$id])->find(); if(request()->isAjax()){ if($doc['score']){ $this->error("已经提交过反馈"); } $score=input('score','','intval'); $query=Db::name('feedback')->where(['id'=>$id])->update(['score'=>$score]); if($query){ $this->success("提交成功"); }else{ $this->error("提交失败"); } } $this->assign('doc',$doc); $this->assign('token',$token); return $this->view->fetch(':fbreview'); } public function uploadimage(){ $file = request()->file('image'); if ($file) { $path = '/data' . DS . 'upload' . DS . date('Y-m-d'); $validate = config('upload_validate'); $info = $file->validate($validate)->rule('md5')->move(ROOT_PATH . $path); if ($info) { $img_url = request()->domain() . $path . DS . $info->getFilename(); return json(['code' => 200, 'msg' => '成功', 'data' =>$img_url]); } else { echo json_encode(['code' => 500, 'msg' => '失败', 'data' => "上传文件失败"]); return; } } else { echo json_encode(['code' => 500, 'msg' => '失败', 'data' => "上传文件失败"]); return; } } }