market_groups_1209
This commit is contained in:
@@ -14,6 +14,8 @@ class Groups extends BaseController
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('market/Market_sylive_groups_model', 'mdSyliveGroups');
|
||||
$this->load->model('market/Market_sylive_groups_user_model', 'mdSyliveGroupsUser');
|
||||
$this->load->model('market/Market_sylive_user_model', 'mdSyliveUser');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,7 +31,7 @@ class Groups extends BaseController
|
||||
$activityId && $where['activityId'] = $activityId;
|
||||
$unGroupsType && $where['groupsLevel<>'] = $unGroupsType;
|
||||
$sort_order = 'sortNumber asc,groupsId desc';
|
||||
$fileds = 'activityId,groupsId,parentId,sortNumber,userFrom,groupsName,ifBiz,statisticsType';
|
||||
$fileds = 'activityId,groupsId,parentId,sortNumber,userFrom,groupsName,ifBiz,statisticsType,originalBizId';
|
||||
$res = $this->mdSyliveGroups->select($where, $sort_order, 0, 0, $fileds);
|
||||
foreach ($res as $k => $v) {
|
||||
$res[$k]['activityId'] = intval($v['activityId']);
|
||||
@@ -39,6 +41,7 @@ class Groups extends BaseController
|
||||
$res[$k]['sortNumber'] = intval($v['sortNumber']);
|
||||
$res[$k]['ifBiz'] = intval($v['ifBiz']);
|
||||
$res[$k]['statisticsType'] = $v['statisticsType'] ? intval($v['statisticsType']) : '';
|
||||
$res[$k]['originalBizId'] = $v['originalBizId'] ? intval($v['originalBizId']) : '';
|
||||
}
|
||||
$this->return_response_list($res);
|
||||
}
|
||||
@@ -72,6 +75,7 @@ class Groups extends BaseController
|
||||
$sortNumber = intval($this->input_param('sortNumber'));
|
||||
$ifBiz = intval($this->input_param('ifBiz'));
|
||||
$statisticsType = intval($this->input_param('statisticsType'));
|
||||
$originalBizId = intval($this->input_param('originalBizId'));
|
||||
if (!$groupsName) {
|
||||
$this->return_json('请输入分组名称');
|
||||
}
|
||||
@@ -90,13 +94,31 @@ class Groups extends BaseController
|
||||
$this->return_json('请选择上级分组');
|
||||
}
|
||||
}
|
||||
$addDate = ['activityId' => $activityId, 'parentId' => $parentId, 'groupsName' => $groupsName, 'groupsLevel' => $groupsLevel,
|
||||
'statisticsType' => $statisticsType, 'userFrom' => $userFrom, 'ifBiz' => $ifBiz, 'sortNumber' => $sortNumber
|
||||
, 'createTime' => date('Y-m-d H:i:s')];
|
||||
$id = $this->mdSyliveGroups->add($addDate);
|
||||
if (!$id) {
|
||||
$originalBizId = $ifBiz ? $originalBizId : 0;
|
||||
$addDate = ['activityId' => $activityId, 'parentId' => $parentId, 'originalBizId' => $originalBizId, 'groupsName' => $groupsName
|
||||
, 'groupsLevel' => $groupsLevel, 'statisticsType' => $statisticsType, 'userFrom' => $userFrom, 'ifBiz' => $ifBiz
|
||||
, 'sortNumber' => $sortNumber, 'createTime' => date('Y-m-d H:i:s')];
|
||||
$groupsId = $this->mdSyliveGroups->add($addDate);
|
||||
if (!$groupsId) {
|
||||
$this->return_json('添加分组失败');
|
||||
}
|
||||
if ($originalBizId) {
|
||||
$levelAry = $this->getLevelAry($groupsId);
|
||||
$res = $this->mdSyliveUser->select(['bizId' => $originalBizId, 'status>=' => 0], 'userId desc', 0, 0
|
||||
, 'userId,organizationId,bizId');
|
||||
$addUser = [];
|
||||
foreach ($res as $v) {
|
||||
$re_user = $this->mdSyliveGroupsUser->get(['activityId' => $activityId, 'userId' => $v['userId'], 'status>=' => 0]);
|
||||
if (!$re_user) {
|
||||
$type = $v['bizId'] == $v['organizationId'] ? 1 : 0;
|
||||
$value = ['userId' => $v['userId'], 'type' => $type, 'activityId' => $activityId
|
||||
, 'groupsId' => $groupsId, 'userFrom' => $userFrom, 'createTime' => date('Y-m-d H:i:s')];
|
||||
$data = array_merge($value, $levelAry);
|
||||
$addUser[] = $data;
|
||||
}
|
||||
}
|
||||
$addUser && $this->mdSyliveGroupsUser->add_batch($addUser);
|
||||
}
|
||||
$this->return_response();
|
||||
}
|
||||
|
||||
@@ -107,7 +129,6 @@ class Groups extends BaseController
|
||||
*/
|
||||
public function index_put()
|
||||
{
|
||||
$activityId = intval($this->input_param('activityId'));
|
||||
$groupsId = intval($this->input_param('groupsId'));
|
||||
$parentId = intval($this->input_param('parentId'));
|
||||
$groupsName = $this->input_param('groupsName');
|
||||
@@ -115,6 +136,7 @@ class Groups extends BaseController
|
||||
$sortNumber = intval($this->input_param('sortNumber'));
|
||||
$ifBiz = intval($this->input_param('ifBiz'));
|
||||
$statisticsType = intval($this->input_param('statisticsType'));
|
||||
$originalBizId = intval($this->input_param('originalBizId'));
|
||||
if (!$groupsId) {
|
||||
$this->return_json('参数错误');
|
||||
}
|
||||
@@ -122,9 +144,9 @@ class Groups extends BaseController
|
||||
$this->return_json('请输入分组名称');
|
||||
}
|
||||
$re_gro = $this->mdSyliveGroups->get(['groupsId' => $groupsId]);
|
||||
$activityId = intval($re_gro['activityId']);
|
||||
if ($re_gro && $re_gro['parentId'] != $parentId) {
|
||||
$this->load->model('market/Market_sylive_groups_user_model', 'mdSyliveGroupsUser');
|
||||
$re_user = $this->mdSyliveGroupsUser->get(['groupsId' => $groupsId, 'activityId' => $re_gro['activityId']]);
|
||||
$re_user = $this->mdSyliveGroupsUser->get(['groupsId' => $groupsId, 'activityId' => $activityId]);
|
||||
if ($re_user) {
|
||||
$this->return_json('此分组已有用户,不能修改上级分组');
|
||||
}
|
||||
@@ -144,7 +166,8 @@ class Groups extends BaseController
|
||||
$this->return_json('请选择上级分组');
|
||||
}
|
||||
}
|
||||
$upDate = ['parentId' => $parentId, 'groupsName' => $groupsName, 'groupsLevel' => $groupsLevel,
|
||||
$originalBizId = $ifBiz ? $originalBizId : 0;
|
||||
$upDate = ['parentId' => $parentId, 'originalBizId' => $originalBizId, 'groupsName' => $groupsName, 'groupsLevel' => $groupsLevel,
|
||||
'statisticsType' => $statisticsType, 'userFrom' => $userFrom, 'ifBiz' => $ifBiz, 'sortNumber' => $sortNumber];
|
||||
$this->mdSyliveGroups->update($upDate, ['groupsId' => $groupsId]);
|
||||
$this->return_response();
|
||||
@@ -166,4 +189,33 @@ class Groups extends BaseController
|
||||
$this->return_response();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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->mdSyliveGroups->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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -108,6 +108,46 @@ class GroupsUser extends BaseController
|
||||
$this->return_response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:同步原始门店用户
|
||||
* Created on: 2022/12/9 12:21
|
||||
* Created by: dengbw
|
||||
* @param null $groupsId
|
||||
*/
|
||||
public function synchronous_get($groupsId = null)
|
||||
{
|
||||
$groupsId = intval($groupsId);
|
||||
if (!$groupsId) {
|
||||
$this->return_json('参数错误');
|
||||
}
|
||||
$re_gro = $this->mdSyliveGroups->get(['groupsId' => $groupsId]);
|
||||
if (!$re_gro) {
|
||||
$this->return_json('分组不存在');
|
||||
}
|
||||
$originalBizId = intval($re_gro['originalBizId']);
|
||||
if (!$originalBizId) {
|
||||
$this->return_json('未关连原始门店');
|
||||
}
|
||||
$activityId = intval($re_gro['activityId']);
|
||||
$userFrom = intval($re_gro['userFrom']);
|
||||
$levelAry = $this->getLevelAry($groupsId);
|
||||
$res = $this->mdSyliveUser->select(['bizId' => $originalBizId, 'status>=' => 0], 'userId desc', 0, 0
|
||||
, 'userId,organizationId,bizId');
|
||||
$addUser = [];
|
||||
foreach ($res as $v) {
|
||||
$re_user = $this->mdSyliveGroupsUser->get(['activityId' => $activityId, 'userId' => $v['userId'], 'status>=' => 0]);
|
||||
if (!$re_user) {
|
||||
$type = $v['bizId'] == $v['organizationId'] ? 1 : 0;
|
||||
$value = ['userId' => $v['userId'], 'type' => $type, 'activityId' => $activityId
|
||||
, 'groupsId' => $groupsId, 'userFrom' => $userFrom, 'createTime' => date('Y-m-d H:i:s')];
|
||||
$data = array_merge($value, $levelAry);
|
||||
$addUser[] = $data;
|
||||
}
|
||||
}
|
||||
$addUser && $this->mdSyliveGroupsUser->add_batch($addUser);
|
||||
$this->return_response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:获取分组等级ID
|
||||
* Created on: 2022/11/30 14:30
|
||||
|
||||
@@ -211,4 +211,20 @@ class Organization extends BaseController
|
||||
$this->return_response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:机构详情
|
||||
* Created on: 2022/12/09 10:37
|
||||
* Created by: dengbw
|
||||
* @param null $organizationId
|
||||
*/
|
||||
public function info_get($organizationId = null)
|
||||
{
|
||||
$organizationId = intval($organizationId);
|
||||
if (!$organizationId) {
|
||||
$this->return_json('参数错误');
|
||||
}
|
||||
$re = $this->mdSyliveOrganization->get(['organizationId' => $organizationId]);
|
||||
$this->return_response($re);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user