123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?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\user\controller;
- use app\common\model\RegionalAgency;
- use app\common\model\User;
- use app\common\model\UserPartner;
- use library\Controller;
- use think\Db;
- /**
- * 区域代理管理
- * Class Member
- * @package app\Member\controller
- */
- class Agency extends Controller
- {
- /**
- * 申请列表
- * @var string
- */
- protected $table = 'RegionalAgency';
- /**
- * 列表
- * @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->search_url = strtolower($this->request->controller()).'/index_search';
- $this->title = '申请记录';
- $sel_where = [];
- $sel_where[] = ['w.is_deleted','=',0];
- if($name = $this->request->get('name')) $sel_where[] =['w.true_name','=',$name];
- if($phone = $this->request->get('phone')) $sel_where[] =['w.phone','=',$phone];
- $query = $this->_query($this->table)
- ->alias('w')
- ->where($sel_where)
- ->field('w.*,m.headimg,m.openid,m.name as m_name')
- ->join('store_member m','m.id = w.user_id');
- $query->dateBetween('w.create_at')->order('w.id desc')->page();
- }
- /**
- * 数据列表处理
- * @auth true
- * @menu true
- * @param array $data
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- protected function _index_page_filter(&$data)
- {
- }
- /**
- * 审核
- * @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 edit()
- {
- $this->title = '审核';
- $this->_form($this->table, 'form');
- }
- protected function _form_filter(&$data)
- {
- if($data['status'] > 0) $data['check_time'] = date('Y-m-d H:i:s');
- }
- protected function _form_result($id)
- {
- $apply_info = RegionalAgency::where('id',$id)->find()->toArray();
- switch ($apply_info['status']){
- case 1:
- $user_info = User::field('is_agency,partner_lev,is_partner')->where('id',$apply_info['user_id'])->find() ;
- if($user_info->is_agency == 0) {
- if($user_info->partner_lev == 0) $user_info->partner_lev = 1;
- $user_info->is_agency = 1;
- $user_info->is_partner = 1;
- $user_info->save();
- }
- break;
- case 2:
- $user_info = User::field('is_agency,partner_lev,is_partner')->where('id',$apply_info['user_id'])->find() ;
- if($user_info->is_agency > 0) {
- $user_info->is_agency = 0;
- $user_info->save();
- }
- break;
- }
- }
- }
|