This commit is contained in:
cun-nan 2024-03-18 16:30:21 +08:00
parent 613995dd4e
commit c4dda44f15
3 changed files with 44 additions and 7 deletions

View File

@ -234,9 +234,7 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
String staffId = param.get("staffId") == null ? "0" : param.get("staffId").toString(); String staffId = param.get("staffId") == null ? "0" : param.get("staffId").toString();
String deptId = param.get("deptId") == null ? "0" : param.get("deptId").toString(); String deptId = param.get("deptId") == null ? "0" : param.get("deptId").toString();
ChainStoreInfo chainStoreInfo = chainStoreInfoService.selectChainStoreByDeptId(Long.valueOf(deptId));
if (ObjectUtil.isNotEmpty(chainStoreInfo) && ObjectUtil.isNotEmpty(chainStoreInfo.getId()))
merchantId = String.valueOf(chainStoreInfo.getId());
// 获取角色code // 获取角色code
String code = param.get("code") == null ? "0" : param.get("code").toString(); String code = param.get("code") == null ? "0" : param.get("code").toString();
@ -257,6 +255,12 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
mtStore = mtStoreMapper.selectOne(lambdaQueryWrapper); mtStore = mtStoreMapper.selectOne(lambdaQueryWrapper);
} }
if ("2".equals(deptType)) {
// 查出storeId
ChainStoreInfo chainStoreInfo = chainStoreInfoService.selectChainStoreByDeptId(Long.valueOf(deptId));
if (ObjectUtil.isNotEmpty(chainStoreInfo) && ObjectUtil.isNotEmpty(chainStoreInfo.getId()))
merchantId = String.valueOf(chainStoreInfo.getId());
}
AccountInfo accountInfo = getAccountByName(accountName); AccountInfo accountInfo = getAccountByName(accountName);
if (accountInfo != null) { if (accountInfo != null) {
@ -283,6 +287,7 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
tAccount.setLocked(0); tAccount.setLocked(0);
if (ObjectUtil.isEmpty(mtStore)) mtStore.setId(0); if (ObjectUtil.isEmpty(mtStore)) mtStore.setId(0);
tAccount.setStoreId(mtStore.getId()); tAccount.setStoreId(mtStore.getId());
merchantId = ObjectUtil.isNotEmpty(mtStore) ? String.valueOf(mtStore.getChainStoreId()) : merchantId;
tAccount.setMerchantId(Integer.parseInt(merchantId)); tAccount.setMerchantId(Integer.parseInt(merchantId));
tAccount.setStaffId(Integer.parseInt(staffId)); tAccount.setStaffId(Integer.parseInt(staffId));
tAccount.setDeptId(Long.parseLong(deptId)); tAccount.setDeptId(Long.parseLong(deptId));
@ -373,9 +378,15 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
tAccount.setStaffId(Integer.parseInt(staffId)); tAccount.setStaffId(Integer.parseInt(staffId));
} }
ChainStoreInfo chainStoreInfo = chainStoreInfoService.selectChainStoreByDeptId(tAccount.getDeptId()); if (param.get("deptType").equals("3")) {
if (ObjectUtil.isNotEmpty(chainStoreInfo) && ObjectUtil.isNotEmpty(chainStoreInfo.getId())) MtStore store = mtStoreMapper.selectById(Integer.valueOf(param.get("storeId").toString()));
merchantId = String.valueOf(chainStoreInfo.getId()); if (ObjectUtil.isNotEmpty(store)) merchantId = String.valueOf(store.getChainStoreId());
}
if (param.get("deptType").equals("2")){
ChainStoreInfo chainStoreInfo = chainStoreInfoService.selectChainStoreByDeptId(tAccount.getDeptId());
if (ObjectUtil.isNotEmpty(chainStoreInfo) && ObjectUtil.isNotEmpty(chainStoreInfo.getId()))
merchantId = String.valueOf(chainStoreInfo.getId());
}
if (StringUtil.isNotEmpty(merchantId)) { if (StringUtil.isNotEmpty(merchantId)) {
tAccount.setMerchantId(Integer.parseInt(merchantId)); tAccount.setMerchantId(Integer.parseInt(merchantId));

View File

@ -4,7 +4,11 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fuint.common.dto.AccountInfo;
import com.fuint.common.enums.StatusEnum; import com.fuint.common.enums.StatusEnum;
import com.fuint.common.service.AccountService;
import com.fuint.common.util.TokenUtil;
import com.fuint.repository.model.TAccount;
import com.fuint.system.role.service.DutyService; import com.fuint.system.role.service.DutyService;
import com.fuint.framework.annoation.OperationServiceLog; import com.fuint.framework.annoation.OperationServiceLog;
import com.fuint.framework.exception.BusinessCheckException; import com.fuint.framework.exception.BusinessCheckException;
@ -23,6 +27,7 @@ import com.fuint.utils.StringUtil;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -47,6 +52,10 @@ public class DutyServiceImpl extends ServiceImpl<TDutyMapper, TDuty> implements
@Resource @Resource
private TDutySourceMapper tDutySourceMapper; private TDutySourceMapper tDutySourceMapper;
@Resource
@Lazy
private AccountService accountService;
@Override @Override
public List<TDuty> getAvailableRoles(Integer merchantId) { public List<TDuty> getAvailableRoles(Integer merchantId) {
List<TDuty> result = tDutyMapper.findByStatus(merchantId, StatusEnum.ENABLED.getKey()); List<TDuty> result = tDutyMapper.findByStatus(merchantId, StatusEnum.ENABLED.getKey());
@ -145,12 +154,18 @@ public class DutyServiceImpl extends ServiceImpl<TDutyMapper, TDuty> implements
existsDuty.setDutyName(tduty.getDutyName()); existsDuty.setDutyName(tduty.getDutyName());
existsDuty.setStatus(tduty.getStatus()); existsDuty.setStatus(tduty.getStatus());
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
TAccount byId = accountService.getById(nowAccountInfo.getId());
Integer chainStoreId = null;
if (ObjectUtil.isNotEmpty(byId)) chainStoreId = byId.getMerchantId();
if (sources != null && sources.size() > 0) { if (sources != null && sources.size() > 0) {
tDutySourceMapper.deleteSourcesByDutyId(tduty.getDutyId()); tDutySourceMapper.deleteSourcesByDutyId(tduty.getDutyId());
for (TSource tSource : sources) { for (TSource tSource : sources) {
TDutySource dutySource = new TDutySource(); TDutySource dutySource = new TDutySource();
dutySource.setDutyId(tduty.getDutyId()); dutySource.setDutyId(tduty.getDutyId());
dutySource.setSourceId(tSource.getSourceId()); dutySource.setSourceId(tSource.getSourceId());
dutySource.setChainStoreId(chainStoreId);
tDutySourceMapper.insert(dutySource); tDutySourceMapper.insert(dutySource);
} }
} }
@ -195,11 +210,16 @@ public class DutyServiceImpl extends ServiceImpl<TDutyMapper, TDuty> implements
throw new BusinessCheckException("角色名称已经存在."); throw new BusinessCheckException("角色名称已经存在.");
} }
this.tDutyMapper.insert(duty); this.tDutyMapper.insert(duty);
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
TAccount byId = accountService.getById(nowAccountInfo.getId());
Integer chainStoreId = null;
if (ObjectUtil.isNotEmpty(byId)) chainStoreId = byId.getMerchantId();
if (sources != null && sources.size() > 0) { if (sources != null && sources.size() > 0) {
for (TSource tSource : sources) { for (TSource tSource : sources) {
TDutySource dutySource = new TDutySource(); TDutySource dutySource = new TDutySource();
dutySource.setDutyId(duty.getDutyId()); dutySource.setDutyId(duty.getDutyId());
dutySource.setSourceId(tSource.getSourceId()); dutySource.setSourceId(tSource.getSourceId());
dutySource.setChainStoreId(chainStoreId);
tDutySourceMapper.insert(dutySource); tDutySourceMapper.insert(dutySource);
} }
} }

View File

@ -34,8 +34,14 @@
left join t_duty td ON ta.role_ids = td.duty_id left join t_duty td ON ta.role_ids = td.duty_id
where account_status != -1 where account_status != -1
<if test="accountInfo.accountName != null and accountInfo.accountName != ''">
AND ta.account_name like concat('%',#{accountInfo.accountName},'%')
</if>
<if test="accountInfo.accountStatus != null">
AND ta.account_status = #{accountInfo.accountStatus}
</if>
<if test="accountInfo.realName != null and accountInfo.realName != ''"> <if test="accountInfo.realName != null and accountInfo.realName != ''">
AND ta.real_name = like concat('%',#{accountInfo.realName},'%') AND ta.real_name like concat('%',#{accountInfo.realName},'%')
</if> </if>
<if test="accountInfo.deptId != null"> <if test="accountInfo.deptId != null">
AND (ta.dept_id = #{accountInfo.deptId} or FIND_IN_SET(#{accountInfo.deptId}, sd.ancestors)) AND (ta.dept_id = #{accountInfo.deptId} or FIND_IN_SET(#{accountInfo.deptId}, sd.ancestors))