diff --git a/home/controllers/h5/market/sylive2/Common.php b/home/controllers/h5/market/sylive2/Common.php index 60261f05..d7dd329e 100644 --- a/home/controllers/h5/market/sylive2/Common.php +++ b/home/controllers/h5/market/sylive2/Common.php @@ -174,6 +174,7 @@ class Admin extends Common{ const WX_SESSION = "market_wx_info"; public function __construct(){ parent::__construct(); + //print_r($this->session); } public function _remap($method){ diff --git a/home/controllers/h5/market/sylive2/Stic.php b/home/controllers/h5/market/sylive2/Stic.php index 7154d6c5..083eef99 100644 --- a/home/controllers/h5/market/sylive2/Stic.php +++ b/home/controllers/h5/market/sylive2/Stic.php @@ -54,14 +54,17 @@ class Stic extends Admin $info['group_name'] = implode(' ', array_column($group_lists, 'groupsName')); $groups = $this->groups_model->get(['groupsId' => $groupsId]); $info['biz_id'] = $groups['ifBiz'] ? $groups['groupsId'] : 0; + $info['organizationId'] = $groups['originalBizId']; } $info['groupsId'] = $groupsId ? $groupsId : $group_user['groupsId']; + $info['tab'] = 1; if (time() >= strtotime($row['timeStart']) && $this->a_id != 11) { $info['tab'] = 2; } $info['aId'] = $this->a_id; $this->data['info'] = $info; + //微信分享 $wx_info = $this->share_info($row); $this->data['sign_package'] = $wx_info['sign_package']; diff --git a/home/controllers/h5/market/sylive2/User.php b/home/controllers/h5/market/sylive2/User.php index 1e3cbfe3..f7f0a45d 100644 --- a/home/controllers/h5/market/sylive2/User.php +++ b/home/controllers/h5/market/sylive2/User.php @@ -16,12 +16,15 @@ class User extends Admin public function index() { + !$this->biz_id && $this->biz_id = intval($this->input->get('organizationId')); $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'] = $biz_row['organizationName']; $this->data['biz_id'] = $this->biz_id; + $this->data['is_manager'] = (!$this->user['bizId'] && $this->user['topOrgId']) ? 1 : 0; + //微信分享 $wx_info = $this->share_info(); $this->data['sign_package'] = $wx_info['sign_package']; @@ -31,19 +34,21 @@ class User extends Admin public function lists() { $keyWord = $this->input->get('keyWord'); + $biz_id = intval($this->input->get('biz_id')); $page = intval($this->input->get('page')); $size = intval($this->input->get('size')); !$page && $page = 1; !$size && $size = 10; + $where = [ 'status<>' => -1, - "organizationId in (select organizationId from lc_market_sylive_organization where parentId={$this->biz_id})" => null + 'bizId' => $biz_id ]; $keyWord && $where["uname like '%{$keyWord}%'"] = null; $total = $this->user_model->count($where); $lists = []; if ($total) { - $res = $this->user_model->select($where, 'userId desc', $page, $size, 'userId,mobile,uname,nickname,headimg,status'); + $res = $this->user_model->select($where, 'userId desc', $page, $size, 'userId,mobile,uname,nickname,headimg,organizationId,bizId,status'); foreach ($res as $val) { $temp = [ 'userId' => $val['userId'], @@ -51,7 +56,8 @@ class User extends Admin 'uname' => $val['uname'], 'mobile' => $val['mobile'], 'wxuname' => $val['nickname'], - 'wxheadimg' => $val['headimg'] + 'wxheadimg' => $val['headimg'], + 'shop_manager' => $val['organizationId'] == $val['bizId'] ? 1 : 0 ]; $lists[] = $temp; } @@ -63,59 +69,63 @@ class User extends Admin public function add() { + $biz_id = $this->input->post('biz_id'); $uname = $this->input->post('uname'); $mobile = $this->input->post('mobile'); + $type = $this->input->post('type'); + if (!$uname) { $this->show_json('', 400, '请输入顾问姓名'); } if (!mobile_valid($mobile)) { $this->show_json('', 400, '请输入正确手机号'); } - $re_org = $this->market_sylive_organization_model->get(['parentId' => $this->biz_id, 'organizationType' => 4 - , 'status' => 0]); - if (!$re_org) { - $this->show_json('', 400, '门店未添加顾问类型,请联系管理员'); + + if($type == 1) { + $re_org = $this->market_sylive_organization_model->get(['parentId' => $biz_id, 'organizationType' => 3, 'status' => 0]); + if (!$re_org) { + $this->show_json('', 400, '门店未添加店长类型,请联系管理员'); + } } + else{ + $type = 0; + $re_org = $this->market_sylive_organization_model->get(['parentId' => $biz_id, 'organizationType' => 4, 'status' => 0]); + if (!$re_org) { + $this->show_json('', 400, '门店未添加顾问类型,请联系管理员'); + } + } + $organizationId = $re_org['organizationId']; $topOrgId = $this->user['topOrgId']; $re = $this->user_model->get(['mobile' => $mobile, 'topOrgId' => $topOrgId]); if ($re && $re['status'] != -1) { $this->show_json('', 400, '手机号已存在'); } - $addDate = ['topOrgId' => $topOrgId, 'organizationId' => $organizationId, 'bizId' => $this->biz_id, - 'uname' => $uname, 'status' => 0, 'teamId' => 0]; - $addDate['mobile'] = $mobile; - $addDate['createTime'] = date('Y-m-d H:i:s'); - $id = $this->user_model->add($addDate); + $addData = ['topOrgId' => $topOrgId, 'organizationId' => $organizationId, 'bizId' => $biz_id, 'uname' => $uname, 'status' => 0, 'teamId' => 0]; + $addData['mobile'] = $mobile; + $addData['createTime'] = date('Y-m-d H:i:s'); + $id = $this->user_model->add($addData); if (!$id) { $this->show_json('', 400, '添加用户失败'); } + //所有分组添加顾问 - $filed = 'activityId,groupsId,bizId,levelId1,levelId2,levelId3,userFrom'; $day = date('Y-m-d H:i:s'); $where = [ - 'userId' => $this->uid, - 'status > -1' => null, - 'type' => 1, + 'originalBizId' => $biz_id, + 'status >' => -1, "activityId in (select activityId from lc_market_sylive_activity where timeEnd>'{$day}' and status > -1)" => null ]; - $admin_lists = $this->groups_user_model->select($where,'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' => date('Y-m-d H:i:s') - ]; - } - $this->groups_user_model->add_batch($add_data); + + $group = $this->groups_model->get($where); + if($group) + { + $levelAry = $this->getLevelAry($group['groupsId']); + $value = ['userId' => $id, 'activityId' => $group['activityId'], 'groupsId' => $group['groupsId'], 'type' => $type, 'createTime' => date('Y-m-d H:i:s')]; + $data = array_merge($value, $levelAry); + $this->groups_user_model->add($data); } + $this->show_json('', 200, '操作成功'); } @@ -175,4 +185,33 @@ class User extends Admin } $this->show_json('', 200, '操作成功'); } + + /** + * Notes:获取分组等级ID + * Created on: 2022/11/30 14:30 + * Created by: dengbw + * @param $groupsId + * @param array $data + * @return array + */ + private function getLevelAry($groupsId, $data = []) + { + $re = $this->groups_model->get(['groupsId' => $groupsId], 'groupsId,parentId,groupsLevel,ifBiz'); + if (!$re) { + return $data; + } else { + if ($re['groupsLevel']) {//分类id + $levelId = "levelId" . $re['groupsLevel']; + $data[$levelId] = $re['groupsId']; + } + if ($re['ifBiz']) {//门店id + $data['bizId'] = $re['groupsId']; + } + if ($re['parentId']) { + return $this->getLevelAry($re['parentId'], $data); + } else { + return $data; + } + } + } } \ No newline at end of file diff --git a/home/views/h5/market/sylive2/stic/index.php b/home/views/h5/market/sylive2/stic/index.php index 877f7e65..7201ae46 100644 --- a/home/views/h5/market/sylive2/stic/index.php +++ b/home/views/h5/market/sylive2/stic/index.php @@ -6,6 +6,16 @@