|
@@ -11,18 +11,20 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import io.netty.util.internal.StringUtil;
|
|
import io.netty.util.internal.StringUtil;
|
|
|
|
+import me.zhyd.oauth.utils.UuidUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.shiro.SecurityUtils;
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.config.TenantContext;
|
|
import org.jeecg.common.config.TenantContext;
|
|
import org.jeecg.common.constant.CommonConstant;
|
|
import org.jeecg.common.constant.CommonConstant;
|
|
import org.jeecg.common.constant.FillRuleConstant;
|
|
import org.jeecg.common.constant.FillRuleConstant;
|
|
import org.jeecg.common.constant.SymbolConstant;
|
|
import org.jeecg.common.constant.SymbolConstant;
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
-import org.jeecg.common.util.FillRuleUtil;
|
|
|
|
-import org.jeecg.common.util.ImportExcelUtil;
|
|
|
|
-import org.jeecg.common.util.YouBianCodeUtil;
|
|
|
|
-import org.jeecg.common.util.oConvertUtils;
|
|
|
|
|
|
+import org.jeecg.common.util.*;
|
|
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
|
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
|
|
|
+import org.jeecg.modules.system.app.dto.merchant.AddMerchantRequestDTO;
|
|
|
|
+import org.jeecg.modules.system.app.dto.merchant.FindByMerchantIdResponseDTO;
|
|
|
|
+import org.jeecg.modules.system.app.dto.merchant.FindMerchantResponseDTO;
|
|
import org.jeecg.modules.system.entity.*;
|
|
import org.jeecg.modules.system.entity.*;
|
|
import org.jeecg.modules.system.mapper.*;
|
|
import org.jeecg.modules.system.mapper.*;
|
|
import org.jeecg.modules.system.model.DepartIdModel;
|
|
import org.jeecg.modules.system.model.DepartIdModel;
|
|
@@ -50,6 +52,7 @@ import java.util.stream.Collectors;
|
|
@Service
|
|
@Service
|
|
public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart> implements ISysDepartService {
|
|
public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart> implements ISysDepartService {
|
|
|
|
|
|
|
|
+ private String passwordPrefix="qlyd";//创建商户的密码前缀
|
|
@Autowired
|
|
@Autowired
|
|
private SysUserDepartMapper userDepartMapper;
|
|
private SysUserDepartMapper userDepartMapper;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -1346,6 +1349,122 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public IPage<FindMerchantResponseDTO> findMerchantPage(Integer pageNo, Integer pageSize, String merchantName, String orgCode) {
|
|
|
|
+ Page<FindMerchantResponseDTO> page = new Page<FindMerchantResponseDTO>(pageNo, pageSize);
|
|
|
|
+ IPage<FindMerchantResponseDTO> findEvaluateResponseDTOIPage= departMapper.findMerchantPage(page, merchantName,orgCode);
|
|
|
|
+ if (findEvaluateResponseDTOIPage!=null&&findEvaluateResponseDTOIPage.getRecords()!=null){
|
|
|
|
+ for (FindMerchantResponseDTO record : findEvaluateResponseDTOIPage.getRecords()) {
|
|
|
|
+ Integer countNum = departMapper.findByParentIdCount(record.getId());
|
|
|
|
+ record.setStoreNum(countNum);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return findEvaluateResponseDTOIPage;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 添加商户
|
|
|
|
+ * @param addMerchantRequestDTO
|
|
|
|
+ * @param loginUser
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional
|
|
|
|
+ public Result<String> addMerchnt(AddMerchantRequestDTO addMerchantRequestDTO, LoginUser loginUser) {
|
|
|
|
+ SysUser userByPhone = sysUserMapper.getUserByPhone(addMerchantRequestDTO.getPhone());
|
|
|
|
+ if (userByPhone!=null){
|
|
|
|
+ return Result.error("添加商户信息失败,用户手机号已存在");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SysUser sysUser = new SysUser();
|
|
|
|
+ sysUser.setCreateTime(new Date());//设置创建时间
|
|
|
|
+ sysUser.setId(UuidUtils.getUUID());
|
|
|
|
+ String salt = oConvertUtils.randomGen(8);
|
|
|
|
+ sysUser.setSalt(salt);
|
|
|
|
+ String password = passwordPrefix+addMerchantRequestDTO.getPhone().substring(7, 11);
|
|
|
|
+ String passwordEncode = PasswordUtil.encrypt(addMerchantRequestDTO.getPhone(),password , salt);
|
|
|
|
+ sysUser.setPassword(passwordEncode);
|
|
|
|
+ sysUser.setPhone(addMerchantRequestDTO.getPhone());
|
|
|
|
+ sysUser.setStatus(1);
|
|
|
|
+ sysUser.setUsername(addMerchantRequestDTO.getPhone());
|
|
|
|
+ sysUser.setRealname(addMerchantRequestDTO.getRealName());
|
|
|
|
+ sysUser.setWorkNo(addMerchantRequestDTO.getPhone());
|
|
|
|
+ sysUser.setUserIdentity(CommonConstant.USER_IDENTITY_2);
|
|
|
|
+ sysUser.setDelFlag(CommonConstant.DEL_FLAG_0);
|
|
|
|
+ if (sysUserMapper.insert(sysUser)<1){
|
|
|
|
+ return Result.error("添加商户信息失败");
|
|
|
|
+ }
|
|
|
|
+ SysDepart sysDepart = new SysDepart();
|
|
|
|
+ String deptId = departMapper.queryDepartIdByOrgCode(loginUser.getOrgCode());
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNotEmpty(deptId)){
|
|
|
|
+ sysDepart.setParentId(deptId);
|
|
|
|
+ }
|
|
|
|
+ sysDepart.setDirectorUserIds(sysUser.getId());
|
|
|
|
+ sysDepart.setDepartName(addMerchantRequestDTO.getMerchantName());
|
|
|
|
+ sysDepart.setOrgCategory("1");//创建商户类型
|
|
|
|
+ this.saveDepartData(sysDepart,addMerchantRequestDTO.getPhone());
|
|
|
|
+ sysUser.setOrgCode(sysDepart.getOrgCode());
|
|
|
|
+ if (sysUserMapper.updateById(sysUser)<1){
|
|
|
|
+ return Result.error("添加商户信息失败");
|
|
|
|
+ }
|
|
|
|
+ return Result.ok("添加商户成功");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result<FindByMerchantIdResponseDTO> findByMerchntId(String id) {
|
|
|
|
+ return Result.OK(departMapper.findByMerchntId(id));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional
|
|
|
|
+ public Result<String> updateMerchntId(AddMerchantRequestDTO addMerchantRequestDTO) {
|
|
|
|
+ if (StringUtils.isEmpty(addMerchantRequestDTO.getId())){
|
|
|
|
+ return Result.error("修改商户信息失败");
|
|
|
|
+ }
|
|
|
|
+ SysDepart sysDepart = departMapper.getDepartById(addMerchantRequestDTO.getId());
|
|
|
|
+ if (sysDepart==null){
|
|
|
|
+ return Result.error("修改商户信息失败,未查询到商户信息");
|
|
|
|
+ }
|
|
|
|
+ sysDepart.setDepartName(addMerchantRequestDTO.getMerchantName());
|
|
|
|
+ if (departMapper.updateById(sysDepart)<1){
|
|
|
|
+ return Result.error("修改商户信息失败,请联系管理员");
|
|
|
|
+ }
|
|
|
|
+ SysUser sysUser =sysUserMapper.findByDepartIds(addMerchantRequestDTO.getId());
|
|
|
|
+ if (sysUser==null){
|
|
|
|
+ return Result.error("修改商户信息失败,未查询到商户管理员信息");
|
|
|
|
+ }
|
|
|
|
+ sysUser.setRealname(addMerchantRequestDTO.getRealName());
|
|
|
|
+ sysUser.setPhone(addMerchantRequestDTO.getPhone());
|
|
|
|
+ sysUser.setUsername(addMerchantRequestDTO.getPhone());
|
|
|
|
+ if (sysUserMapper.updateById(sysUser)<1){
|
|
|
|
+ return Result.error("修改商户信息失败,请联系管理员");
|
|
|
|
+ }
|
|
|
|
+ return Result.ok("修改商户成功");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result<String> resetPassword(String id) {
|
|
|
|
+ if (StringUtils.isEmpty(id)){
|
|
|
|
+ return Result.error("重置密码失败,请选择商户");
|
|
|
|
+ }
|
|
|
|
+ SysDepart sysDepart = departMapper.getDepartById(id);
|
|
|
|
+ if (sysDepart==null){
|
|
|
|
+ return Result.error("重置密码失败,未查询到商户信息");
|
|
|
|
+ }
|
|
|
|
+ SysUser sysUser =sysUserMapper.findByDepartIds(id);
|
|
|
|
+ if (sysUser==null){
|
|
|
|
+ return Result.error("重置密码失败,未查询到商户管理员信息");
|
|
|
|
+ }
|
|
|
|
+ String password = passwordPrefix+sysUser.getPhone().substring(7, 11);
|
|
|
|
+ String passwordEncode = PasswordUtil.encrypt(sysUser.getPhone(),password , sysUser.getSalt());
|
|
|
|
+ sysUser.setPassword(passwordEncode);
|
|
|
|
+ if (sysUserMapper.updateById(sysUser)<1){
|
|
|
|
+ return Result.error("重置密码失败,请联系管理员");
|
|
|
|
+ }
|
|
|
|
+ return Result.ok("重置密码成功");
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 寻找部门路径
|
|
* 寻找部门路径
|
|
*
|
|
*
|