ExpertController.php 4.5 KB
<?php
/**
 * Created by PhpStorm.
 * auther: sgj
 * Date: 2019/1/6
 * Time: 14:45
 */

namespace app\user\controller;


use app\user\model\InquiryModel;
use app\user\model\TransferModel;
use app\user\model\UserModel;
use cmf\controller\WeChatBaseController;
use EasyWeChat\Foundation\Application;
use think\Db;

class ExpertController extends WeChatBaseController
{

    public function inquiryAnswer(){
        $where=[];
        $userId=cmf_get_current_user_id();
        $model=new InquiryModel();
        //todo 释放专家ID
        //$where['expert_id']=$userId;

        $count0=$model->where($where)->where('status',0)->count('id');
        $count1=$model->where($where)->where(['status'=>['neq',0]])->count('id');
        $this->assign('count0',$count0);
        $this->assign('count1',$count1);

        $list0=$model->where($where)->where('status',0)->select()->toArray();
        $list1=$model->where($where)->where(['status'=>['neq',0]])->select()->toArray();

        $this->assign('list0',$list0);
        $this->assign('list1',$list1);
        return $this->fetch();
    }

    public function transferAnswer(){
        $where=[];
        $userId=cmf_get_current_user_id();
        $model=new TransferModel();
        //todo 释放专家ID
        //$where['expert_id']=$userId;

        $count0=$model->where($where)->where('status',0)->count('id');
        $count1=$model->where($where)->where(['status'=>['neq',0]])->count('id');
        $this->assign('count0',$count0);
        $this->assign('count1',$count1);

        $list0=$model->where($where)->where('status',0)->select()->toArray();
        $list1=$model->where($where)->where(['status'=>['neq',0]])->select()->toArray();

        $this->assign('list0',$list0);
        $this->assign('list1',$list1);

        return $this->fetch();
    }

    /**
     * 获取进修提交列表
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function engageAnswer(){
        $user_id=cmf_get_current_user_id();
        $map['user_id']=$user_id;
        $map['state']='0';
        /*未处理信息*/
        $undo=db('engage')->where($map)->select()->toArray();
        $map['state']=['in','1,2'];
        $redo=db('engage')->where($map)->select()->toArray();
        $this->assign('undo',$undo);
        $this->assign('redo',$redo);
        return $this->fetch();
    }

    /**
     * 提交信息细节
     */
    public function engageDetail(){
        $id=input('id');
        $info=db('engage')->where('id',$id)->find();
        if (empty($info)){
            $this->error('信息错误');
        }
        $User=new UserModel();
        $user=$User->getUser($info['user_id'])->toArray();
        $this->assign('user',$user['0']);
        $this->assign('info',$info);
        return $this->fetch();
    }


    public function inquiryDetail(){
        $config=config('wechat_config');
        $Wechat=new Application($config);
        $js = $Wechat->js;
        $api[]='startRecord';
        $api[]='stopRecord';
        $api[]='onVoiceRecordEnd';
        $api[]='playVoice';
        $api[]='pauseVoice';
        $api[]='stopVoice';
        $api[]='onVoicePlayEnd';
        $api[]='uploadVoice';
        $api[]='downloadVoice';
        $api[]='chooseImage';
        $api[]='previewImage';
        $api[]='uploadImage';
        $api[]='downloadImage';
        $api[]='translateVoice';
        $sdk=$js->config($api, true);
        $this->assign('sdk',$sdk);

        $id=$this->request->param('id',0,'intval');
        $model=new InquiryModel();
        $info=$model->getInfo($id);
        $this->assign('info',$info);
        return $this->fetch();
    }

    public function transferDetail(){
        $config=config('wechat_config');
        $Wechat=new Application($config);
        $js = $Wechat->js;
        $api[]='startRecord';
        $api[]='stopRecord';
        $api[]='onVoiceRecordEnd';
        $api[]='playVoice';
        $api[]='pauseVoice';
        $api[]='stopVoice';
        $api[]='onVoicePlayEnd';
        $api[]='uploadVoice';
        $api[]='downloadVoice';
        $api[]='chooseImage';
        $api[]='previewImage';
        $api[]='uploadImage';
        $api[]='downloadImage';
        $api[]='translateVoice';
        $sdk=$js->config($api, true);
        $this->assign('sdk',$sdk);

        $id=$this->request->param('id',0,'intval');
        $model=new TransferModel();
        $info=$model->getInfo($id);
        $this->assign('info',$info);

        return $this->fetch();
    }
}