|
@@ -57,23 +57,9 @@ import java.util.Map;
|
|
@Service
|
|
@Service
|
|
public class BizCustomerServiceImpl extends ServiceImpl<BizCustomerMapper, BizCustomer> implements BizCustomerService {
|
|
public class BizCustomerServiceImpl extends ServiceImpl<BizCustomerMapper, BizCustomer> implements BizCustomerService {
|
|
|
|
|
|
- private static final String SNOWY_SYS_DEFAULT_PASSWORD_KEY = "SNOWY_SYS_DEFAULT_PASSWORD";
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- private DevConfigApi devConfigApi;
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- private BizUserMapper bizUserMapper;
|
|
|
|
-
|
|
|
|
- @Resource
|
|
|
|
- private SysUserApi sysUserApi;
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public Page<BizCustomer> page(BizCustomerPageParam bizCustomerPageParam) {
|
|
public Page<BizCustomer> page(BizCustomerPageParam bizCustomerPageParam) {
|
|
QueryWrapper<BizCustomer> queryWrapper = new QueryWrapper<BizCustomer>().checkSqlInjection();
|
|
QueryWrapper<BizCustomer> queryWrapper = new QueryWrapper<BizCustomer>().checkSqlInjection();
|
|
- if(ObjectUtil.isNotEmpty(bizCustomerPageParam.getLoginAccount())) {
|
|
|
|
- queryWrapper.lambda().like(BizCustomer::getLoginAccount, bizCustomerPageParam.getLoginAccount());
|
|
|
|
- }
|
|
|
|
if(ObjectUtil.isNotEmpty(bizCustomerPageParam.getName())) {
|
|
if(ObjectUtil.isNotEmpty(bizCustomerPageParam.getName())) {
|
|
queryWrapper.lambda().like(BizCustomer::getName, bizCustomerPageParam.getName());
|
|
queryWrapper.lambda().like(BizCustomer::getName, bizCustomerPageParam.getName());
|
|
}
|
|
}
|
|
@@ -94,9 +80,6 @@ public class BizCustomerServiceImpl extends ServiceImpl<BizCustomerMapper, BizCu
|
|
@Override
|
|
@Override
|
|
public List<BizCustomer> getList(BizCustomerPageParam bizCustomerPageParam) {
|
|
public List<BizCustomer> getList(BizCustomerPageParam bizCustomerPageParam) {
|
|
QueryWrapper<BizCustomer> queryWrapper = new QueryWrapper<BizCustomer>().checkSqlInjection();
|
|
QueryWrapper<BizCustomer> queryWrapper = new QueryWrapper<BizCustomer>().checkSqlInjection();
|
|
- if(ObjectUtil.isNotEmpty(bizCustomerPageParam.getLoginAccount())) {
|
|
|
|
- queryWrapper.lambda().like(BizCustomer::getLoginAccount, bizCustomerPageParam.getLoginAccount());
|
|
|
|
- }
|
|
|
|
if(ObjectUtil.isNotEmpty(bizCustomerPageParam.getName())) {
|
|
if(ObjectUtil.isNotEmpty(bizCustomerPageParam.getName())) {
|
|
queryWrapper.lambda().like(BizCustomer::getName, bizCustomerPageParam.getName());
|
|
queryWrapper.lambda().like(BizCustomer::getName, bizCustomerPageParam.getName());
|
|
}
|
|
}
|
|
@@ -122,11 +105,6 @@ public class BizCustomerServiceImpl extends ServiceImpl<BizCustomerMapper, BizCu
|
|
if(countYong>0){
|
|
if(countYong>0){
|
|
throw new CommonException("客户关联的用友平台ID已存在!");
|
|
throw new CommonException("客户关联的用友平台ID已存在!");
|
|
}
|
|
}
|
|
- //查询客户账号是否添加过
|
|
|
|
- long countLogin = this.count(new QueryWrapper<BizCustomer>().lambda().eq(BizCustomer::getLoginAccount, bizCustomerAddParam.getLoginAccount()));
|
|
|
|
- if(countLogin>0){
|
|
|
|
- throw new CommonException("客户账号已存在!");
|
|
|
|
- }
|
|
|
|
//查询客户名称是否添加过
|
|
//查询客户名称是否添加过
|
|
long countName = this.count(new QueryWrapper<BizCustomer>().lambda().eq(BizCustomer::getName, bizCustomerAddParam.getName()));
|
|
long countName = this.count(new QueryWrapper<BizCustomer>().lambda().eq(BizCustomer::getName, bizCustomerAddParam.getName()));
|
|
if(countName>0){
|
|
if(countName>0){
|
|
@@ -134,22 +112,6 @@ public class BizCustomerServiceImpl extends ServiceImpl<BizCustomerMapper, BizCu
|
|
}
|
|
}
|
|
BizCustomer bizCustomer = BeanUtil.toBean(bizCustomerAddParam, BizCustomer.class);
|
|
BizCustomer bizCustomer = BeanUtil.toBean(bizCustomerAddParam, BizCustomer.class);
|
|
this.save(bizCustomer);
|
|
this.save(bizCustomer);
|
|
-
|
|
|
|
- // 添加客户登录账号
|
|
|
|
- BizUser bizUser = new BizUser();
|
|
|
|
- bizUser.setCustomerId(bizCustomer.getId());
|
|
|
|
- bizUser.setAccount(bizCustomer.getLoginAccount());
|
|
|
|
- bizUser.setName(bizCustomer.getName());
|
|
|
|
- bizUser.setPhone(bizCustomer.getPhone());
|
|
|
|
- bizUser.setUserType("1");
|
|
|
|
- // 设置密码
|
|
|
|
- bizUser.setPassword(CommonCryptogramUtil.doHashValue(devConfigApi.getValueByKey(SNOWY_SYS_DEFAULT_PASSWORD_KEY)));
|
|
|
|
- // 设置状态
|
|
|
|
- bizUser.setUserStatus(BizUserStatusEnum.ENABLE.getValue());
|
|
|
|
- this.bizUserMapper.insert(bizUser);
|
|
|
|
-
|
|
|
|
- // 添加客户角色
|
|
|
|
- this.sysUserApi.grantRoleType(bizUser.getId(), "客户");
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -169,13 +131,6 @@ public class BizCustomerServiceImpl extends ServiceImpl<BizCustomerMapper, BizCu
|
|
throw new CommonException("客户关联的用友平台ID已存在!");
|
|
throw new CommonException("客户关联的用友平台ID已存在!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(!StringUtils.equals(bizCustomer.getLoginAccount(),bizCustomerEditParam.getLoginAccount())){
|
|
|
|
- //查询客户账号是否添加过
|
|
|
|
- long countLogin = this.count(new QueryWrapper<BizCustomer>().lambda().eq(BizCustomer::getLoginAccount, bizCustomerEditParam.getLoginAccount()));
|
|
|
|
- if(countLogin>0){
|
|
|
|
- throw new CommonException("客户账号已存在!");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
if(!StringUtils.equals(bizCustomer.getName(),bizCustomerEditParam.getName())){
|
|
if(!StringUtils.equals(bizCustomer.getName(),bizCustomerEditParam.getName())){
|
|
//查询客户名称是否添加过
|
|
//查询客户名称是否添加过
|
|
long count = this.count(new QueryWrapper<BizCustomer>().lambda().eq(BizCustomer::getName, bizCustomerEditParam.getName()));
|
|
long count = this.count(new QueryWrapper<BizCustomer>().lambda().eq(BizCustomer::getName, bizCustomerEditParam.getName()));
|
|
@@ -185,25 +140,6 @@ public class BizCustomerServiceImpl extends ServiceImpl<BizCustomerMapper, BizCu
|
|
}
|
|
}
|
|
BeanUtil.copyProperties(bizCustomerEditParam, bizCustomer);
|
|
BeanUtil.copyProperties(bizCustomerEditParam, bizCustomer);
|
|
this.updateById(bizCustomer);
|
|
this.updateById(bizCustomer);
|
|
-
|
|
|
|
- // 检查是否存在账号
|
|
|
|
- long count = this.bizUserMapper.selectCount(new QueryWrapper<BizUser>().lambda().eq(BizUser::getCustomerId, bizCustomer.getId()));
|
|
|
|
- if(count == 0){
|
|
|
|
- BizUser bizUser = new BizUser();
|
|
|
|
- bizUser.setCustomerId(bizCustomer.getId());
|
|
|
|
- bizUser.setAccount(bizCustomer.getLoginAccount());
|
|
|
|
- bizUser.setName(bizCustomer.getName());
|
|
|
|
- bizUser.setPhone(bizCustomer.getPhone());
|
|
|
|
- bizUser.setUserType("1");
|
|
|
|
- // 设置密码
|
|
|
|
- bizUser.setPassword(CommonCryptogramUtil.doHashValue(devConfigApi.getValueByKey(SNOWY_SYS_DEFAULT_PASSWORD_KEY)));
|
|
|
|
- // 设置状态
|
|
|
|
- bizUser.setUserStatus(BizUserStatusEnum.ENABLE.getValue());
|
|
|
|
- this.bizUserMapper.insert(bizUser);
|
|
|
|
-
|
|
|
|
- // 添加客户角色
|
|
|
|
- this.sysUserApi.grantRoleType(bizUser.getId(), "客户");
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -218,13 +154,6 @@ public class BizCustomerServiceImpl extends ServiceImpl<BizCustomerMapper, BizCu
|
|
return this.queryEntity(bizCustomerIdParam.getId());
|
|
return this.queryEntity(bizCustomerIdParam.getId());
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public void resetPassword(BizCustomerIdParam bizCustomerIdParam) {
|
|
|
|
- this.bizUserMapper.update(new LambdaUpdateWrapper<BizUser>().eq(BizUser::getCustomerId,
|
|
|
|
- bizCustomerIdParam.getId()).set(BizUser::getPassword,
|
|
|
|
- CommonCryptogramUtil.doHashValue(devConfigApi.getValueByKey(SNOWY_SYS_DEFAULT_PASSWORD_KEY))));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public BizCustomer queryEntity(String id) {
|
|
public BizCustomer queryEntity(String id) {
|
|
BizCustomer bizCustomer = this.getById(id);
|
|
BizCustomer bizCustomer = this.getById(id);
|