123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkAdmin
- // +----------------------------------------------------------------------
- // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
- // +----------------------------------------------------------------------
- // | 官方网站: http://demo.thinkadmin.top
- // +----------------------------------------------------------------------
- // | 开源协议 ( https://mit-license.org )
- // +----------------------------------------------------------------------
- // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
- // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
- // +----------------------------------------------------------------------
- namespace app\store\controller;
- use library\Controller;
- use think\Db;
- /**
- * 工程师管理
- * Class GoodsCate
- * @package app\store\controller
- */
- class Engineer extends Controller
- {
- /**
- * 绑定数据表
- * @var string
- */
- protected $table = 'store_engineer';
- /**
- * 工程师管理
- * @auth true
- * @menu true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function index()
- {
- $this->title = '工程师列表';
- $query = $this->_query($this->table)->where('is_deleted',0)->like('name,phone');
- $query->dateBetween('create_at')->order('id desc')->page();
- }
- /**
- * 数据列表处理
- * @param array $data
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- protected function _index_page_filter(&$data)
- {
- foreach ($data as $k=>&$v){
- }
- }
- /**
- * 表单数据处理
- * @param array $data
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- protected function _form_filter(&$data)
- {
- if ($this->request->isGet()) {
- }elseif ($this->request->isPost()){
- if(!preg_match("/^1[23456789]\d{9}$/", $data['phone'])){
- $this->error('手机号格式不正确');
- }
- if(empty($data['headimg'])){
- $this->error('请上传头像');
- }
- //查看手机号是否已有账号
- $engineer_id = Db::name('store_engineer')->where('phone',$data['phone'])->value('id');
- if($engineer_id){
- $this->error('该手机号已有账号');
- }
- }
- }
- /**
- * 表单结果处理
- * @param boolean $result
- */
- protected function _form_result($result)
- {
- $phone = Db::name('store_engineer')->where('id',$result)->value('phone');
- $system_user_data = array(
- 'username' => $phone,
- 'authorize'=> 1,
- 'password' => md5( substr($phone,-6)),
- 'engineer_id' => $result
- );
- Db::name('system_user')->insert($system_user_data);
- }
- /**
- * 添加工程师
- * @auth true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function add()
- {
- $this->title = '添加工程师';
- $this->_form($this->table, 'form');
- }
- /**
- * 编辑工程师
- * @auth true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function edit()
- {
- $this->title = '编辑工程师';
- $this->_form($this->table, 'form');
- }
- /**
- * 删除工程师
- * @auth true
- * @throws \think\Exception
- * @throws \think\exception\PDOException
- */
- public function remove()
- {
- $id_arr = explode(',',$_POST['id']);
- //删除系统用户
- foreach ($id_arr as $value){
- Db::name('system_user')->where('engineer_id',$value)->update(array('is_deleted'=>1));
- }
- $this->_save($this->table, ['is_deleted' => '1']);
- }
- }
|