From 431dde90aa20f7652092fc0bfa9e6a1a28b06b9f Mon Sep 17 00:00:00 2001 From: jiangqs <343695869@qq.com> Date: 星期日, 06 八月 2023 12:41:23 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/HongRuiTang --- ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 113 insertions(+), 1 deletions(-) diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java index 5bb8b99..03acb69 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java @@ -1,15 +1,21 @@ package com.ruoyi.system.service.impl.staff; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.uuid.IdUtils; +import com.ruoyi.common.redis.service.RedisService; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.system.api.constant.AppErrorConstant; +import com.ruoyi.system.api.constant.SecurityConstant; +import com.ruoyi.system.api.domain.dto.MerEditUserDto; import com.ruoyi.system.api.domain.dto.MgtBaseGetDto; +import com.ruoyi.system.api.domain.dto.MgtShopStaffEditDto; import com.ruoyi.system.api.domain.poji.sys.SysUser; +import com.ruoyi.system.api.service.RemoteShopService; import com.ruoyi.system.domain.dto.MgtStaffEditDto; import com.ruoyi.system.domain.dto.MgtStaffPageDto; import com.ruoyi.system.domain.pojo.staff.SysStaff; @@ -18,10 +24,12 @@ import com.ruoyi.system.mapper.staff.SysStaffMapper; import com.ruoyi.system.service.staff.SysStaffService; import com.ruoyi.system.service.sys.ISysUserService; +import com.ruoyi.system.util.QiYeUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; +import java.util.concurrent.TimeUnit; /** * <p> @@ -39,6 +47,13 @@ @Resource private ISysUserService sysUserService; + + @Resource + private RedisService redisService; + + @Resource + private RemoteShopService remoteShopService; + /** * @description 获取部门员工列表 @@ -149,6 +164,12 @@ sysStaff.setStaffAvatar(mgtStaffEditDto.getStaffAvatar()); sysStaff.setHeadFlag(mgtStaffEditDto.getHeadFlag()); this.saveOrUpdate(sysStaff); + MgtShopStaffEditDto mgtShopStaffEditDto = new MgtShopStaffEditDto(); + mgtShopStaffEditDto.setUserId(sysStaff.getUserId()); + mgtShopStaffEditDto.setStaffName(sysStaff.getStaffName()); + mgtShopStaffEditDto.setStaffMobile(sysStaff.getStaffMobile()); + mgtShopStaffEditDto.setStaffAvatar(sysStaff.getStaffAvatar()); + remoteShopService.editMgtShopStaff(mgtShopStaffEditDto); } /** @@ -163,8 +184,9 @@ Long userId = Long.valueOf(mgtBaseGetDto.getId()); SysStaff sysStaff = this.getByUserId(userId); sysStaff.setDelFlag(1); + sysStaff.setStaffMobile(sysStaff.getStaffMobile()+":已删除"); this.saveOrUpdate(sysStaff); - sysUserService.deleteUserById(mgtBaseGetDto.getUserId()); + sysUserService.deleteUserById(userId); } /** @@ -179,4 +201,94 @@ public List<MgtStaffPageVo> pageMgtStaff(Page page, MgtStaffPageDto mgtStaffPageDto){ return sysStaffMapper.pageMgtStaff(page, mgtStaffPageDto); } + + /** + * @description + * @author jqs + * @date 2023/7/14 9:52 + * @param mobile + * @return SysStaff + */ + @Override + public SysStaff getByMobile(String mobile){ + LambdaQueryWrapper<SysStaff> queryWrapper = new LambdaQueryWrapper(); + queryWrapper.eq(SysStaff::getDelFlag,0); + queryWrapper.eq(SysStaff::getStaffMobile,mobile); + return this.getOne(queryWrapper,false); + } + + + /** + * @description 同步组织架构 + * @author jqs + * @date 2023/7/18 19:06 + * @param + * @return void + */ + @Override + public void synchronizeOrganizationalStructure(){ + String accessToken = getQYToken(); + + + } + + + /** + * @description 获取企业微信token + * @author jqs + * @date 2023/7/18 19:35 + * @param + * @return String + */ + private String getQYToken(){ + String accessToken = redisService.getCacheObject(SecurityConstant.QY_TOKEN); + if(StringUtils.isBlank(accessToken)){ + try { + accessToken = QiYeUtils.getAccessTokenByQY(); + JSONObject jsonAccessToken = JSONObject.parseObject(accessToken); + String errcode = jsonAccessToken.getString("errcode"); + String errmsg = jsonAccessToken.getString("errmsg"); + if(errcode.equals("0")){ + accessToken = jsonAccessToken.getString("access_token"); + Long expiresIn = jsonAccessToken.getLong("expires_in"); + expiresIn = expiresIn -100; + redisService.setCacheObject(SecurityConstant.QY_TOKEN,accessToken,expiresIn, TimeUnit.SECONDS); + }else{ + throw new ServiceException(errmsg); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + return accessToken; + } + + + /** + * @description 编辑商户员工 + * @author jqs + * @date 2023/7/19 19:42 + * @param merEditUserDto + * @return void + */ + @Override + public void editSysStaffInfo(MerEditUserDto merEditUserDto){ + SysStaff sysStaff = this.getByUserId(merEditUserDto.getUserId()); + Integer editType = merEditUserDto.getEditType(); + switch (editType){ + case 1: + sysStaff.setStaffName(merEditUserDto.getEditValue()); + break; + case 2: + sysStaff.setStaffAvatar(merEditUserDto.getEditValue()); + break; + case 3: + break; + case 4: + break; + default: + break; + } + this.saveOrUpdate(sysStaff); + } } -- Gitblit v1.7.1