148 lines
5.9 KiB
PHP
148 lines
5.9 KiB
PHP
<?php
|
|
defined('WXAPP_APP') OR exit('No direct script access allowed');
|
|
|
|
/**
|
|
* Created by Vim
|
|
* User: lcc
|
|
* Date: 2021.06.23
|
|
* Time: 14:08
|
|
*/
|
|
require_once APPPATH.'controllers/wxapp/Wxapp.php';
|
|
class User extends Wxapp{
|
|
|
|
function __construct($inputs, $app_key){
|
|
parent::__construct($inputs, $app_key);
|
|
|
|
$this->login_white = array('get_ukey');//登录白名单
|
|
$this->majia_white = array('get_ukey', 'get');//超级管理员披上马甲可操作权限
|
|
$this->check_status = array();//用户状态校验
|
|
$this->check_mobile = array();//需要手机号
|
|
$this->check_headimg =array();//授权微信信息
|
|
|
|
}
|
|
|
|
/**
|
|
* 获取ukey
|
|
* @return array
|
|
* @throws Exception
|
|
*/
|
|
protected function get_ukey(){
|
|
$code = $this->input_param('code');
|
|
$mobile = $this->input_param('mobile');
|
|
$sms_code = $this->input_param('sms_code');
|
|
|
|
if(!$code||!$mobile||!$sms_code){
|
|
throw new Exception('参数错误', API_CODE_INVILD_PARAM);
|
|
}
|
|
//判断验证码
|
|
if($mobile!='15359333655'){//测试号码
|
|
$mc = &load_cache();
|
|
$key = "licheb_login_code_".$mobile;
|
|
$cache_code = $mc->get($key);
|
|
if($sms_code!=$cache_code){
|
|
throw new Exception('验证码错误', API_CODE_FAIL);
|
|
}
|
|
}
|
|
$user = $this->app_user_model->get(['mobile'=>$mobile,'status>'=> -1]);
|
|
if(!$user){
|
|
throw new Exception('用户不存在', API_CODE_FAIL);
|
|
}
|
|
if(!$user['status']){
|
|
throw new Exception('该账号已停用', API_CODE_FAIL);
|
|
}
|
|
$session = $this->wx_session($code);
|
|
//print_r($session);
|
|
if(!$session['session_key']){
|
|
throw new Exception('登录失败', API_CODE_FAIL);
|
|
}
|
|
|
|
$uid = $user['id'];
|
|
if(!$user['openid']){ //未绑定微信
|
|
$upd = [
|
|
'openid' => $session['openid']
|
|
];
|
|
$session['unionid'] && $upd['unionid'] = $session['unionid'];
|
|
$ret = $this->app_user_model->update($upd, array('id' => $uid));
|
|
if(!$ret){
|
|
debug_log("[error]# code:{$code}; ".$this->app_user_model->db->last_query(), __FUNCTION__, $this->log_dir);
|
|
throw new Exception('授权用户信息失败', API_CODE_FAIL);
|
|
}
|
|
}
|
|
|
|
$udata = array('uid' => $uid, 'session_key' => $session['session_key']);
|
|
$ukey = $this->refresh_login($udata);
|
|
|
|
return array('ukey' => $ukey);
|
|
}
|
|
|
|
/**
|
|
* 用户信息
|
|
* @return array
|
|
*/
|
|
protected function get(){
|
|
$uid = $this->session['uid'];
|
|
|
|
$user = $this->app_user_model->get(array('id' => $uid));
|
|
//获取所属店铺字段
|
|
$this->load->model("biz/biz_model");
|
|
$biz = $this->biz_model->get(['id'=>$this->session['biz_id']],'biz_name');
|
|
$group_arr = $this->app_user_model->get_group();
|
|
|
|
$group_name = $group_arr[$user['group_id']] ? $group_arr[$user['group_id']] : '';
|
|
$data = array(
|
|
'uid' => $uid,
|
|
'uname' => $user['uname'],
|
|
'mobile' => $user['mobile'],
|
|
'group_id' => $user['group_id'],
|
|
'group_name' => $group_name,
|
|
'biz_name' => $biz['biz_name'] ? $biz['biz_name'] : ''
|
|
);
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* 统计数据
|
|
*/
|
|
protected function get_cal(){
|
|
$uid = $this->session['uid'];
|
|
$biz_id = $this->session['biz_id'];
|
|
$group_id = $this->session['group_id'];
|
|
$this->load->model('receiver/receiver_customers_model','customers_model');
|
|
$this->load->model('receiver/order/receiver_orders_model','orders_model');
|
|
$this->load->model('receiver/order/receiver_order_signs_model','order_signs_model');
|
|
$wl_count = $this->customers_model->count(["cont_time = '0000-00-00 00:00:00'"=>null,'admin_id'=>$uid,'biz_id'=>$biz_id]);
|
|
$gz_count = $this->customers_model->count(['status>'=>-1,'is_top'=>1,'admin_id'=>$uid,'biz_id'=>$biz_id]);
|
|
$sign_count = $this->orders_model->count(['status'=>0,'admin_id'=>$uid,'biz_id'=>$biz_id]);
|
|
$loan_count = $this->orders_model->count(['status'=>1,'admin_id'=>$uid,'biz_id'=>$biz_id]);
|
|
//未派单客户
|
|
$unuse_count = $this->customers_model->count(['admin_id'=>0,'biz_id'=>$biz_id]);
|
|
|
|
//为创建订单客户
|
|
$uncre_count = $this->customers_model->count(['status'=>2,'admin_id'=>$uid,'biz_id'=>$biz_id]);
|
|
$t1 = 'lc_receiver_order_signs';
|
|
$t2 = 'lc_receiver_orders';
|
|
$need_sign = $this->order_signs_model->count_order(["$t1.status"=>0,"$t2.admin_id"=>$uid]);//需要签名
|
|
$loan_count = $this->orders_model->count(['status'=>1,'admin_id'=>$uid]);//未选择分期
|
|
$bill_count = $this->orders_model->count(['status'=>3,'admin_id'=>$uid]);//开票相关
|
|
$del_count = $this->orders_model->count(['status'=>5,'admin_id'=>$uid]);//交付确认
|
|
$deallist = [
|
|
['title'=>'需登记订单','icon'=>'icon-dengji','total'=>$uncre_count,'page'=>'/pages/order/register/index'],
|
|
['title'=>'需邀请签名','icon'=>'icon-qianming1','total'=>$need_sign,'page'=>'/pages/order/filterList/index?key=0&ismy=1'],
|
|
['title'=>'未选择分期','icon'=>'icon-fenpei','total'=>$loan_count,'page'=>'/pages/order/filterList/index?key=1&ismy=1'],
|
|
['title'=>'开票相关','icon'=>'icon-kaipiao1','total'=>$bill_count,'page'=>'/pages/order/filterList/index?key=3&ismy=1'],
|
|
['title'=>'交付确认','icon'=>'icon-jiaofu','total'=>$del_count,'page'=>'/pages/order/filterList/index?key=5&ismy=1'],
|
|
];
|
|
$data = [
|
|
'wl_count' => $wl_count,
|
|
'gz_count' => $gz_count,
|
|
'sign_count' => $sign_count,
|
|
'loan_count' => $loan_count,
|
|
'unuse_count' => $unuse_count,
|
|
'deallist' => $deallist
|
|
];
|
|
return $data;
|
|
}
|
|
|
|
}
|