| | |
| | | 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; |
| | |
| | | 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> |
| | |
| | | |
| | | @Resource |
| | | private ISysUserService sysUserService; |
| | | |
| | | @Resource |
| | | private RedisService redisService; |
| | | |
| | | @Resource |
| | | private RemoteShopService remoteShopService; |
| | | |
| | | |
| | | /** |
| | | * @description 获取部门员工列表 |
| | |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | |
| | | 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); |
| | | } |
| | | } |