diff --git a/home/controllers/h5/market/sylive2/Act.php b/home/controllers/h5/market/sylive2/Act.php index 27d5abf2..af4fec76 100644 --- a/home/controllers/h5/market/sylive2/Act.php +++ b/home/controllers/h5/market/sylive2/Act.php @@ -34,6 +34,26 @@ class Act extends Wx { if(!$row){ throw new Hd_exception('参数错误',400); } + $jsondata = json_decode($row['jsondata'],true); + $bottoms = []; + if($jsondata['bottoms']){ + foreach ($jsondata['bottoms'] as $key=>$val) { + $temp = [ + 'title' => $val['title'], + 'icon' => build_qiniu_image_url($val['icon']) + ]; + if($val['urlType']=='miniProgram'){ + $temp['type'] = 1; + $temp['wechat_ghid'] = $val['miniProgramId']; + $temp['wechat_path'] = $val['url']; + }else{ + $temp['type'] = 2; + $temp['url'] = $val['url']; + } + $bottoms[] = $temp; + } + } + $info['menu'] = $bottoms; $user = $this->user_model->get(['userId'=>$this->uid],'unionid,nickname,headimg'); $timeStart = strtotime($row['timeStart']); $info['s_time'] = time() < $timeStart ? $timeStart-time() : 0; diff --git a/home/controllers/h5/market/sylive2/Biz.php b/home/controllers/h5/market/sylive2/Biz.php index 3264055d..bd6bfa56 100644 --- a/home/controllers/h5/market/sylive2/Biz.php +++ b/home/controllers/h5/market/sylive2/Biz.php @@ -9,7 +9,9 @@ class Biz extends Admin{ } //活动列表 public function index(){ + $user = $this->user_model->get(['userId'=>$this->session['userId']]); $this->data['multi_org'] = $_SESSION[self::SESSION_KEY]['multi_org'] ? 1 : 0; + $this->data['isBiz'] = $user['bizId'] ? 1 : 0; $this->show_view('h5/market/sylive2/biz/index'); } @@ -21,6 +23,7 @@ class Biz extends Admin{ $where = [ 'userId' => $this->uid, 'status' => 0, + 'activityId in (select activityId from lc_market_sylive_activity where status=0)' => null ]; $total = $this->groups_user_model->count($where); $rows = $this->groups_user_model->select($where,'activityId desc',$page,$size); diff --git a/home/controllers/h5/market/sylive2/Common.php b/home/controllers/h5/market/sylive2/Common.php index 11a503e9..9fa96c2d 100644 --- a/home/controllers/h5/market/sylive2/Common.php +++ b/home/controllers/h5/market/sylive2/Common.php @@ -188,6 +188,8 @@ class Admin extends Common{ $_SESSION[self::WX_SESSION] = $ret; header('Location:/h5/market/sylive2/login');exit; } + //更新未绑定用户openid + $row_wechat['mobile'] && $this->user_model->update(['openid'=>$openid],['mobile'=>$row_wechat['mobile'],'status'=>0]); $_SESSION[self::SESSION_KEY]['mobile'] = $row_wechat['mobile']; $org_url = http_host_com('home')."/h5/market/sylive2"; redirect($org_url); diff --git a/home/controllers/h5/market/sylive2/User.php b/home/controllers/h5/market/sylive2/User.php index 4170b669..8f639b16 100644 --- a/home/controllers/h5/market/sylive2/User.php +++ b/home/controllers/h5/market/sylive2/User.php @@ -10,16 +10,17 @@ class User extends Admin parent::__construct(); $this->load->model('market/Market_sylive_organization_model', 'mdSyliveOrganization'); $this->load->library('market/sylive_entity'); - $this->biz_id = 0; - $this->session['org_id']; + $this->user = $this->user_model->get(['userId'=>$this->uid],'bizId,topOrgId'); + $this->biz_id = $this->user['bizId']; } public function index() { - $row = $this->market_sylive_organization_model->get(['organizationId' => $this->biz_id]); + $row = $this->market_sylive_organization_model->get(['organizationId' => $this->user['topOrgId']]); + $biz_row = $this->market_sylive_organization_model->get(['organizationId' => $this->biz_id]); $headimg = $row['logo'] ? build_qiniu_image_url($row['logo']) : Sylive_entity::HD_IMG; $this->data['headimg'] = $headimg; - $this->data['biz_name'] = $row['organizationName']; + $this->data['biz_name'] = $biz_row['organizationName']; $this->data['biz_id'] = $this->biz_id; //微信分享 $wx_info = $this->share_info(); @@ -76,27 +77,39 @@ class User extends Admin $this->show_json('', 400, '门店未添加顾问类型,请联系管理员'); } $organizationId = $re_org['organizationId']; - $topOrgId = $this->getTopOrgId($organizationId); + $topOrgId = $this->user['topOrgId']; $re = $this->user_model->get(['mobile' => $mobile, 'topOrgId' => $topOrgId]); if ($re && $re['status'] != -1) { - if ($re['teamId'] || $re['organizationId']) { - $this->show_json('', 400, '手机号已存在'); - } + $this->show_json('', 400, '手机号已存在'); } - $addDate = ['topOrgId' => $topOrgId, 'organizationId' => $organizationId, 'biz_id' => $this->biz_id, + $addDate = ['topOrgId' => $topOrgId, 'organizationId' => $organizationId, 'bizId' => $this->biz_id, 'uname' => $uname, 'status' => 0, 'teamId' => 0]; - if ($re['userId']) { - $this->user_model->update($addDate, ['userId' => $re['userId']]); - $this->show_json('', 200, '绑定用户成功'); - } else { - $addDate['mobile'] = $mobile; - $addDate['createTime'] = date('Y-m-d H:i:s'); - $id = $this->user_model->add($addDate); - if (!$id) { - $this->show_json('', 400, '添加用户失败'); - } - $this->show_json('', 200, '操作成功'); + $addDate['mobile'] = $mobile; + $addDate['createTime'] = date('Y-m-d H:i:s'); + $id = $this->user_model->add($addDate); + if (!$id) { + $this->show_json('', 400, '添加用户失败'); } + //所有分组添加顾问 + $filed = 'activityId,groupsId,bizId,levelId1,levelId2,levelId3,userFrom'; + $admin_lists = $this->groups_user_model->select(['userId'=>$this->uid],'groupsUserId desc',0,0,$filed); + if($admin_lists){ + foreach ($admin_lists as $key => $val) { + $add_data[] = [ + 'activityId' => $val['activityId'], + 'groupsId' => $val['groupsId'], + 'bizId' => $val['bizId'], + 'levelId1' => $val['levelId1'], + 'levelId2' => $val['levelId2'], + 'levelId3' => $val['levelId3'], + 'userFrom' => $val['userFrom'], + 'userId' => $id, + 'createTime' => time() + ]; + } + $this->groups_user_model->add_batch($add_data); + } + $this->show_json('', 200, '操作成功'); } public function edit() @@ -142,28 +155,4 @@ class User extends Admin $this->user_model->update(['status' => $status], ['userId' => $userId]); $this->show_json('', 200, '操作成功'); } - - /** - * Notes:获取顶级机构id - * Created on: 2022/12/8 14:39 - * Created by: dengbw - * @param $organizationId - * @param $topOrgId - * @return mixed - */ - private function getTopOrgId($organizationId, $topOrgId = 0) - { - $re = $this->mdSyliveOrganization->get(['organizationId' => $organizationId], 'organizationId,parentId'); - if (!$re) { - return $topOrgId; - } else { - $topOrgId = $re['organizationId']; - if ($re['parentId']) { - return $this->getTopOrgId($re['parentId'], $topOrgId); - } else { - return $topOrgId; - } - } - } - } \ No newline at end of file diff --git a/home/views/h5/market/sylive2/act/index.php b/home/views/h5/market/sylive2/act/index.php index 7bba1c18..07b15e21 100644 --- a/home/views/h5/market/sylive2/act/index.php +++ b/home/views/h5/market/sylive2/act/index.php @@ -1,8 +1,9 @@