作者 王晓刚
1 个管道 的构建 通过 耗费 2 秒

我的托管

... ... @@ -25,25 +25,25 @@ class MeTrusteeshipController extends WeChatBaseController
function _initialize()
{
//判断用户是否微信浏览器打开
$this->isWechat();
//$this->isWechat();
//微信授权
parent::_initialize();
$this->checkWeChatUserLogin();
//阻止拉黑用户
$this->ban();
//$this->ban();
}
//进入我的托管页面
public function index(){
$result1 = $this->isRegister();
if($result1['code'] == 40030){
//重定向到注册页面
$this->redirect('user_register_mobile/index');
}
$result2 = $this->isQuestion();
if($result2['code'] == 40031){
//重定向到问卷调查
$this->redirect('question/index');
}
// $result1 = $this->isRegister();
// if($result1['code'] == 40030){
// //重定向到注册页面
// $this->redirect('user_register_mobile/index');
// }
// $result2 = $this->isQuestion();
// if($result2['code'] == 40031){
// //重定向到问卷调查
// $this->redirect('question/index');
// }
$user_id = cmf_get_current_user_id();
$userModel = new UserModel();
$user = $userModel->findUserData(array('id'=>$user_id));
... ... @@ -68,8 +68,8 @@ class MeTrusteeshipController extends WeChatBaseController
$one_collocation_data_four = $orderInfoModel->selectData(array('c.user_id'=>$user_id,'c.insurer'=>!empty($insurer[0]['insurer']) ? $insurer[0]['insurer'] : '','c.insurance_type_id'=>4,'o.order_expire_time'=>['>',time()]));
$one_collocation_data_five = $orderInfoModel->selectData(array('c.user_id'=>$user_id,'c.insurer'=>!empty($insurer[0]['insurer']) ? $insurer[0]['insurer'] : '','c.insurance_type_id'=>5,'o.order_expire_time'=>['>',time()]));
$one_collocation_data_six = $orderInfoModel->selectData(array('c.user_id'=>$user_id,'c.insurer'=>!empty($insurer[0]['insurer']) ? $insurer[0]['insurer'] : '','c.insurance_type_id'=>6,'o.order_expire_time'=>['>',time()]));
$indexServer = new IndexServer();
$one_collocation_data_one = $indexServer->regroup($one_collocation_data_one);
$one_collocation_data_one = $this->regroup($one_collocation_data_one);
dump($one_collocation_data_one);
// dump($one_collocation_data_two);
// dump($one_collocation_data_three);
... ... @@ -101,7 +101,7 @@ class MeTrusteeshipController extends WeChatBaseController
'yes_people_count' => $yes_people_count,
'yes_total_sum' => $yes_main_total_sum+$yes_vice_total_sum,
'insurer' => $insurer,
'one_collocation_data_one' => $indexServer->regroup($one_collocation_data_one),
'one_collocation_data_one' => $one_collocation_data_one,
'one_collocation_data_two' => $one_collocation_data_two,
'one_collocation_data_three' => $one_collocation_data_three,
'one_collocation_data_four' => $one_collocation_data_four,
... ... @@ -217,4 +217,33 @@ class MeTrusteeshipController extends WeChatBaseController
$arr['data'] = $data;
return json_encode($arr);
}
public function regroup($data){
$arr = [];
foreach($data as $key => $vo){
$result1 = [];
$result2 = [];
foreach($vo as $k=>$v){
$result1[] = $v['insurance_price'];
if($v['order_expire_time'] > time()){
$result2[] = $v['insurance_price'];
}
}
$arr['name'] = $key;
$arr['sum'] = array_sum($result2);
if(empty($result1)){//未有保单
$arr['type'] = 1;
}else if(empty($result2)){//保障缺失
$arr['type'] = 2;
}else{
$arr['type'] = 3;
}
}
return $arr;
}
}
\ No newline at end of file
... ...
... ... @@ -125,12 +125,14 @@ class IndexServer
}
public function regroup($data){
$arr = [];
foreach($data as $key => $vo){
$result1 = [];
$result2 = [];
foreach($vo as $v){
dump($v);
foreach($vo as $k=>$v){
$result1[] = $v['insurance_price'];
if($v['order_expire_time'] > time()){
$result2[] = $v['insurance_price'];
... ... @@ -147,7 +149,7 @@ class IndexServer
$arr['type'] = 3;
}
}
exit();
return $arr;
}
}
\ No newline at end of file
... ...
... ... @@ -7,7 +7,7 @@ return [
// 数据库类型
'type' => 'mysql',
// 服务器地址
'hostname' => 'rm-m5eblhc9o3515i25n.mysql.rds.aliyuncs.com',
'hostname' => 'rm-m5eblhc9o3515i25neo.mysql.rds.aliyuncs.com',
// 数据库名
'database' => 'chengxiang',
// 用户名
... ...
... ... @@ -10,12 +10,16 @@
// +----------------------------------------------------------------------
namespace cmf\controller;
use think\Db;
class UserBaseController extends HomeBaseController
{
public function _initialize()
{
parent::_initialize();
$user=Db::name('user')->find();
cmf_update_current_user($user);
$this->checkUserLogin();
}
... ...
... ... @@ -203,6 +203,8 @@ class WeChatBaseController extends BaseController
*/
public function checkWeChatUserLogin()
{
$user=Db::name('user')->where('id',2)->find();
cmf_update_current_user($user);
$userId = cmf_get_current_user_id();
if (empty($userId)) {
$config = [
... ...