diff --git a/common/models/market/Market_sylive_groups_model.php b/common/models/market/Market_sylive_groups_model.php new file mode 100644 index 00000000..6c289d01 --- /dev/null +++ b/common/models/market/Market_sylive_groups_model.php @@ -0,0 +1,17 @@ +table_name, 'default'); + } +} \ No newline at end of file diff --git a/common/models/market/Market_sylive_groups_user_model.php b/common/models/market/Market_sylive_groups_user_model.php new file mode 100644 index 00000000..cf740325 --- /dev/null +++ b/common/models/market/Market_sylive_groups_user_model.php @@ -0,0 +1,17 @@ +table_name, 'default'); + } +} \ No newline at end of file diff --git a/common/models/market/Market_sylive_order_model.php b/common/models/market/Market_sylive_order_model.php index 3c26c343..dcd2b742 100644 --- a/common/models/market/Market_sylive_order_model.php +++ b/common/models/market/Market_sylive_order_model.php @@ -77,9 +77,9 @@ class Market_sylive_order_model extends HD_Model public function winTypeAry($activityId = 0, $type = 0) { $winType = []; + $img = 'https://qs.haodian.cn/web/images/project/H5-ShiYu-draw'; if ($activityId == 4) {//纳米BOX双11纳享嗨购日 - $img = 'https://qs.haodian.cn/web/images/project/H5-ShiYu-draw'; - $winType = [ 0 => ['title' => '请选择抽奖类型'] + $winType = [0 => ['title' => '请选择抽奖类型'] , 6 => ['title' => '150元京东卡', 'tag' => '六等奖', 'img' => $img . '/prize-jd-150.png', 'price' => 0.99] , 5 => ['title' => '200元京东卡', 'tag' => '五等奖', 'img' => $img . '/prize-jd-200.png', 'price' => 0.99] , 4 => ['title' => '300元京东卡', 'tag' => '四等奖', 'img' => $img . '/prize-jd-300.png', 'price' => 0.99] @@ -90,6 +90,13 @@ class Market_sylive_order_model extends HD_Model , 8 => ['title' => '500元京东卡', 'tag' => '199独享', 'img' => $img . '/prize-jd-500.png', 'price' => 199] , 9 => ['title' => '1000元京东卡', 'tag' => '199独享', 'img' => $img . '/prize-jd-1000.png', 'price' => 199] ]; + } else if ($activityId == 5) {//哪吒汽车宁德时代员工私享内购会 + $winType = [0 => ['title' => '请选择抽奖类型'] + , 1 => ['title' => '哪吒V车模', 'tag' => '车模', 'img' => $img . '/nz-prize-chemo.png', 'price' => 0.99] + , 2 => ['title' => '车载吸尘器', 'tag' => '吸尘器', 'img' => $img . '/nz-prize-xihenqi.png', 'price' => 0.99] + , 3 => ['title' => '免费保养券', 'tag' => '保养券', 'img' => $img . '/nz-prize-baoyangquan.png', 'price' => 0.99] + , 4 => ['title' => '65寸液晶电视', 'tag' => '电视机', 'img' => $img . '/nz-prize-dianshi.png', 'price' => 99] + ]; } if ($type) { $winType = $winType[$type]; @@ -107,7 +114,7 @@ class Market_sylive_order_model extends HD_Model public function winNumAry($activityId = 0) { $winNumAry = []; - if ($activityId == 4) {//纳米BOX双11纳享嗨购日 + if ($activityId == 4 ||$activityId == 5 ) {//纳米BOX双11纳享嗨购日 $winNumAry = [['title' => '请选择中奖人数', 'value' => 0], ['title' => '1人', 'value' => 1], ['title' => '2人', 'value' => 2], ['title' => '5人', 'value' => 5], ['title' => '50人', 'value' => 50]]; diff --git a/market/controllers/api/sylive/Groups.php b/market/controllers/api/sylive/Groups.php new file mode 100644 index 00000000..c4cfc746 --- /dev/null +++ b/market/controllers/api/sylive/Groups.php @@ -0,0 +1,153 @@ +load->model('market/Market_sylive_groups_model', 'mdSyliveGroups'); + } + + /** + * Notes:获取分组 + * Created on: 2022/9/16 11:11 + * Created by: dengbw + */ + public function index_get() + { + $activityId = intval($this->input_param('activityId')); + $unGroupsType = $this->input_param('unGroupsType'); + $where['status>='] = 0; + $activityId && $where['activityId'] = $activityId; + $unGroupsType && $where['groupsType<>'] = $unGroupsType; + $sort_order = 'sortNumber asc,groupsId desc'; + $fileds = 'activityId,groupsId,parentId,sortNumber,userFrom,groupsName,groupsType'; + $res = $this->mdSyliveGroups->select($where, $sort_order, 0, 0, $fileds); + foreach ($res as $k => $v) { + $res[$k]['activityId'] = intval($v['activityId']); + $res[$k]['groupsId'] = intval($v['groupsId']); + $res[$k]['parentId'] = intval($v['parentId']); + $res[$k]['sortNumber'] = intval($v['sortNumber']); + $res[$k]['userFrom'] = intval($v['userFrom']); + } + $this->return_response_list($res); + } + + /** + * Notes:查找上级分组 + * Created on: 2022/10/24 15:24 + * Created by: dengbw + */ + public function parent_get() + { + $parentId = intval($this->input_param('parentId')); + $sort_order = 'sortNumber asc,groupsId desc'; + $where['status>='] = 0; + $where['parentId'] = $parentId; + $res = $this->mdSyliveGroups->select($where, $sort_order, 0, 0, 'groupsId,groupsName'); + $this->return_response_list($res); + } + + /** + * Notes:添加分组 + * Created on: 2022/9/19 16:43 + * Created by: dengbw + */ + public function index_post() + { + $activityId = intval($this->input_param('activityId')); + $parentId = intval($this->input_param('parentId')); + $groupsName = $this->input_param('groupsName'); + $groupsType = $this->input_param('groupsType'); + $userFrom = intval($this->input_param('userFrom')); + $sortNumber = intval($this->input_param('sortNumber')); + if (!$groupsName) { + $this->return_json('请输入分组名称'); + } + if (!$groupsType) { + $this->return_json('请选择分组类型'); + } + if ($parentId) {//判断上级分组是不是门店类型 + $re_org = $this->mdSyliveGroups->get(['groupsId' => $parentId]); + if ($re_org['groupsType'] == 4) { + $this->return_json('选择的上级分组不能保存,请重新选择'); + } + } else { + $re_org = $this->mdSyliveGroups->get(['parentId' => $parentId]); + if ($re_org) { + $this->return_json('请选择上级分组'); + } + } + $addDate = ['activityId' => $activityId, 'parentId' => $parentId, 'groupsName' => $groupsName, 'groupsType' => $groupsType, 'userFrom' => $userFrom, + 'sortNumber' => $sortNumber, 'createTime' => date('Y-m-d H:i:s')]; + $id = $this->mdSyliveGroups->add($addDate); + if (!$id) { + $this->return_json('添加分组失败'); + } + $this->return_response(); + } + + /** + * Notes:修改分组 + * Created on: 2022/9/19 17:29 + * Created by: dengbw + */ + public function index_put() + { + $groupsId = intval($this->input_param('groupsId')); + $parentId = intval($this->input_param('parentId')); + $groupsName = $this->input_param('groupsName'); + $groupsType = $this->input_param('groupsType'); + $userFrom = $this->input_param('userFrom'); + $sortNumber = intval($this->input_param('sortNumber')); + if (!$groupsId) { + $this->return_json('参数错误'); + } + if (!$groupsName) { + $this->return_json('请输入分组名称'); + } + if (!$groupsType) { + $this->return_json('请选择分组类型'); + } + if ($parentId) {//判断上级分组是不是门店类型 + $re_org = $this->mdSyliveGroups->get(['groupsId' => $parentId]); + if ($re_org['groupsType'] == 4) { + $this->return_json('选择的上级分组不能保存,请重新选择'); + } + } else { + $re_org = $this->mdSyliveGroups->get(['parentId' => $parentId]); + if ($re_org && $groupsId != $re_org['groupsId']) { + $this->return_json('请选择上级分组'); + } + } + $upDate = ['parentId' => $parentId, 'groupsName' => $groupsName, 'groupsType' => $groupsType, + 'userFrom' => $userFrom, 'sortNumber' => $sortNumber]; + $this->mdSyliveGroups->update($upDate, ['groupsId' => $groupsId]); + $this->return_response(); + } + + /** + * Notes:删除分组 + * Created on: 2022/9/19 11:08 + * Created by: dengbw + * @param null $groupsId + */ + public function index_delete($groupsId = null) + { + $groupsId = intval($groupsId); + if (!$groupsId) { + $this->return_json('参数错误'); + } + $this->mdSyliveGroups->update(['status' => -1], ['groupsId' => $groupsId]); + $this->return_response(); + } + +} \ No newline at end of file diff --git a/market/controllers/api/sylive/GroupsUser.php b/market/controllers/api/sylive/GroupsUser.php new file mode 100644 index 00000000..882cbd0e --- /dev/null +++ b/market/controllers/api/sylive/GroupsUser.php @@ -0,0 +1,180 @@ +load->model('market/Market_sylive_groups_user_model', 'mdSyliveGroupsUser'); + } + + /** + * Notes:用户管理列表 + * Created on: 2022/9/20 14:48 + * Created by: dengbw + */ + public function page_get() + { + $page = $this->input_param('page'); + $limit = $this->input_param('limit'); + $uname = $this->input_param('uname'); + $nickname = $this->input_param('nickname'); + $sort = $this->input_param('sort'); + $order = $this->input_param('order'); + $teamId = intval($this->input_param('teamId')); + !$page && $page = 1; + !$limit && $limit = 10; + $sort_order = 'userId desc'; + if ($sort && $order) { + $sort_order = $sort . ' ' . $order; + } + $list = []; + $where['status>='] = 0; + $teamId && $where['teamId'] = $teamId; + $uname && $where['uname'] = $uname; + $nickname && $where['nickname'] = $nickname; + $count = $this->mdSyliveGroupsUser->count($where); + if ($count) { + $res = $this->mdSyliveGroupsUser->select($where, $sort_order, $page, $limit); + foreach ($res as $v) { + $status = intval($v['status']); + $createTime = $v['createTime'] != '0000-00-00 00:00:00' ? $v['createTime'] : ''; + $list[] = [ + 'userId' => $v['userId'], 'uname' => $v['uname'], 'nickname' => $v['nickname'], 'mobile' => $v['mobile'] + , 'teamId' => $teamId, 'status' => $status, 'createTime' => $createTime]; + } + } + $date = ['list' => $list, 'count' => $count]; + $this->return_response_list($date); + } + + /** + * Notes:添加用户 + * Created on: 2022/9/21 16:46 + * Created by: dengbw + */ + public function index_post() + { + $mobile = $this->input_param('mobile'); + $teamId = intval($this->input_param('teamId')); + $uname = $this->input_param('uname'); + if (!$mobile) { + $this->return_json('请输入手机号'); + } + if (!$teamId) { + $this->return_json('请选择所属团队'); + } + if (!$uname) { + $this->return_json('请输入姓名'); + } + $re = $this->mdSyliveGroupsUser->get(['mobile' => $mobile]); + if ($re && $re['status'] != -1) { + if ($re['teamId'] || $re['organizationId']) { + $this->return_json('手机号已存在'); + } + } + $addDate = ['teamId' => $teamId, 'uname' => $uname, 'status' => 0, 'organizationId' => 0]; + if ($re['userId']) { + $this->mdSyliveGroupsUser->update($addDate, ['userId' => $re['userId']]); + $this->return_response([], '绑定用户成功'); + } else { + $addDate['mobile'] = $mobile; + $addDate['createTime'] = date('Y-m-d H:i:s'); + $id = $this->mdSyliveGroupsUser->add($addDate); + if (!$id) { + $this->return_json('添加用户失败'); + } + $this->return_response(); + } + } + + /** + * Notes:修改用户 + * Created on: 2022/9/21 14:48 + * Created by: dengbw + */ + public function index_put() + { + $userId = intval($this->input_param('userId')); + $teamId = intval($this->input_param('teamId')); + $uname = $this->input_param('uname'); + if (!$userId) { + $this->return_json('参数错误'); + } + if (!$teamId) { + $this->return_json('请选择所属团队'); + } + if (!$uname) { + $this->return_json('请输入姓名'); + } + $upDate = ['teamId' => $teamId, 'uname' => $uname]; + $this->mdSyliveGroupsUser->update($upDate, ['userId' => $userId]); + $this->return_response(); + } + + /** + * Notes:修改状态 + * Created on: 2022/9/21 16:10 + * Created by: dengbw + */ + public function status_put() + { + $userId = $this->input_param('userId'); + $status = $this->input_param('status'); + if (!$userId) { + $this->return_json('参数错误'); + } + $this->mdSyliveGroupsUser->update(['status' => $status], ['userId' => $userId]); + $this->return_response(); + } + + /** + * Notes:删除用户 + * Created on: 2022/9/21 16:10 + * Created by: dengbw + * @param null $userId + */ + public function index_delete($userId = null) + { + if (!$userId) { + $this->return_json('参数错误'); + } + $this->mdSyliveGroupsUser->update(['status' => -1], ['userId' => $userId]); + $this->return_response(); + } + + /** + * Notes:栓验字段 + * Created on: 2022/9/21 15:52 + * Created by: dengbw + */ + public function existence_get() + { + $field = $this->input_param('field'); + $value = $this->input_param('value'); + $id = $this->input_param('id'); + if (!$id) { + $where = [$field => $value, 'status<>' => -1]; + $re = $this->mdSyliveGroupsUser->get($where); + if ($re) { + if ($field == 'mobile') { + if ($re['teamId'] || $re['organizationId']) { + $this->return_json('已存在', 0); + } + } else { + $this->return_json('已存在', 0); + } + } + } + $this->return_json('不存在', 1); + } + +} \ No newline at end of file diff --git a/market/hooks/ApiAuthHook.php b/market/hooks/ApiAuthHook.php index 62a08843..a432955f 100644 --- a/market/hooks/ApiAuthHook.php +++ b/market/hooks/ApiAuthHook.php @@ -90,6 +90,8 @@ class ApiAuthHook $authority = 'sylive:organization:' . $authority_set; } else if (strstr($route, '/sylive/teamUser')) {//团队用户权限 $authority = 'sylive:team:' . $authority_set; + } else if (strstr($route, '/sylive/groupsUser')) {//分组用户权限 + $authority = 'sylive:groups:' . $authority_set; } $this->CI->load->model('market/Market_sys_menu_model'); $re_menu = $this->CI->Market_sys_menu_model->get(["menuId in({$menuIds})" => null, 'status' => 0