Commit 7a585a64 authored by zhuxiang's avatar zhuxiang
Browse files

增加商户转个人接口

parent 70d1ca13
......@@ -2,6 +2,7 @@ package com.platform.controller;
import com.platform.model.dto.CaseDTO;
import com.platform.model.dto.ExcelDataDTO;
import com.platform.model.dto.UserDTO;
import com.platform.model.resp.Result;
import com.platform.model.vo.CaseVO;
import com.platform.page.TableDataInfo;
......@@ -91,4 +92,9 @@ public class CaseController extends BaseController {
public Result info(@RequestBody CaseDTO caseDTO) {
return Result.data(caseService.info(caseDTO));
}
@PutMapping("/updateMerchantToPerson")
public Result updateMerchantToPerson(@RequestBody UserDTO userDTO) {
return Result.data(caseService.updateMerchantToPerson(userDTO));
}
}
package com.platform.controller;
import com.platform.model.dto.GroupDetailDTO;
import com.platform.model.entity.GroupEntity;
import com.platform.model.resp.Result;
import com.platform.page.TableDataInfo;
import com.platform.service.GroupDetailService;
import com.platform.service.GroupService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
......@@ -12,6 +14,8 @@ import javax.annotation.Resource;
@RequestMapping("/group")
public class GroupController extends BaseController {
@Resource
private GroupService groupService;
@Resource
private GroupDetailService groupDetailService;
......@@ -48,4 +52,8 @@ public class GroupController extends BaseController {
return Result.data(groupDetailService.draw(groupId));
}
@PutMapping("/update/groupName")
public Result updateGroupName(@RequestBody GroupEntity groupEntity) {
return Result.data(groupService.updateGroupName(groupEntity));
}
}
......@@ -29,4 +29,7 @@ public class UserDTO extends UserEntity {
@ApiModelProperty(value = "对方id")
private String otherName;
private String oldName;
private String newName;
}
......@@ -3,9 +3,9 @@ package com.platform.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.platform.model.dto.CaseDTO;
import com.platform.model.dto.ExcelDataDTO;
import com.platform.model.dto.UserDTO;
import com.platform.model.entity.CasesEntity;
import com.platform.model.vo.CaseVO;
import com.platform.model.vo.ExcelDataVO;
import com.platform.model.vo.GraphVO;
import com.platform.model.vo.NodeVO;
......@@ -78,4 +78,6 @@ public interface CasesService extends IService<CasesEntity> {
Boolean removeBatchCase(List<String> ids);
boolean updateUserUse(ExcelDataDTO excelDataDTO);
boolean updateMerchantToPerson(UserDTO userDTO);
}
......@@ -58,4 +58,6 @@ public interface ExcelDataService extends IService<ExcelDataEntity> {
List<ExcelDataEntity> queryInfoList(CaseDTO caseDTO);
List<ExcelDataEntity> queryListByPayUserName(ExcelDataDTO excelDataDTO);
List<ExcelDataEntity> queryListByPayeeName(String oldName, String caseId);
}
......@@ -11,4 +11,6 @@ public interface GroupService extends IService<GroupEntity> {
void saveGroup(int id, List<GroupVO> groups);
List<GroupVO> queryByCaseId(Integer id);
boolean updateGroupName(GroupEntity groupEntity);
}
......@@ -30,4 +30,8 @@ public interface UserService extends IService<UserEntity> {
EveryoneVO relationPage(UserDTO userDTO);
Boolean delete(String userName);
UserEntity getByUserName(String newName);
List<String> queryListByCaseId(Integer id);
}
......@@ -5,10 +5,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.mapper.CaseMapper;
import com.platform.model.dto.CaseDTO;
import com.platform.model.dto.ExcelDataDTO;
import com.platform.model.entity.CasesEntity;
import com.platform.model.entity.ExcelDataEntity;
import com.platform.model.entity.GroupDetailEntity;
import com.platform.model.entity.UserRelationEntity;
import com.platform.model.dto.UserDTO;
import com.platform.model.entity.*;
import com.platform.model.vo.*;
import com.platform.service.*;
import com.platform.utils.StringUtils;
......@@ -23,6 +21,8 @@ import java.util.stream.Collectors;
@Service
public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implements CasesService {
@Resource
private UserService userService;
@Resource
private NodeService nodeService;
@Resource
......@@ -38,15 +38,22 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
@Override
public List<CaseVO> queryDataList(CaseDTO caseDTO) {
//查看案件关联的用户
List<String> userList = userService.queryListByCaseId(caseDTO.getId());
//查看案件所有的excelData
List<ExcelDataVO> excelDataEntityList = excelDataService.queryByCaseId(caseDTO);
excelDataEntityList.forEach(excelDataEntity -> {
if (StringUtils.isNull(excelDataEntity.getPayUserName())) {
excelDataEntity.setPayUserName("无对应人员的数据");
}
});
Map<String, List<ExcelDataVO>> groupedMap = new HashMap<>();
// 调用分组方法
Map<String, List<ExcelDataVO>> groupedMap = groupByPayUserName(excelDataEntityList);
userList.forEach(userName -> groupedMap.put(userName, Lists.newArrayList()));
groupByPayUserName(groupedMap, excelDataEntityList);
//初始化集合
List<CaseVO> caseVOList = Lists.newArrayList();
//遍历groupedMap
......@@ -382,6 +389,29 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
return excelDataService.updateBatchById(excelDataEntityList);
}
@Override
public boolean updateMerchantToPerson(UserDTO userDTO) {
List<ExcelDataEntity> excelDataEntityList = excelDataService.queryListByPayeeName(userDTO.getOldName(), userDTO.getCaseId());
if (CollUtil.isNotEmpty(excelDataEntityList)) {
excelDataEntityList.forEach(excelDataEntity -> excelDataEntity.setPayeeName(userDTO.getNewName()));
excelDataService.updateBatchById(excelDataEntityList);
}
//格局新名查看用户数据
UserEntity userEntity = userService.getByUserName(userDTO.getNewName());
if (userEntity == null) {
//新增用户
userEntity = new UserEntity();
userEntity.setUserName(userDTO.getNewName());
userEntity.setSex(userDTO.getSex());
userEntity.setIdCard(userDTO.getIdCard());
userEntity.setBasicInfo(userDTO.getBasicInfo());
userEntity.setAge(userDTO.getAge());
userEntity.setCaseId(userDTO.getCaseId());
userService.save(userEntity);
}
return false;
}
@Override
public List<NodeVO> info(CaseDTO caseDTO) {
// 使用Set去重
......@@ -483,9 +513,8 @@ public class CaseServiceImpl extends ServiceImpl<CaseMapper, CasesEntity> implem
members.contains(edge.getTarget()));
}
private Map<String, List<ExcelDataVO>> groupByPayUserName(List<ExcelDataVO> excelDataVOList) {
Map<String, List<ExcelDataVO>> groupedMap = new HashMap<>();
private Map<String, List<ExcelDataVO>> groupByPayUserName(Map<String, List<ExcelDataVO>> groupedMap,
List<ExcelDataVO> excelDataVOList) {
for (ExcelDataVO obj : excelDataVOList) {
String key = obj.getPayUserName(); // 获取A字段的值作为键
if (!groupedMap.containsKey(key)) {
......
......@@ -99,4 +99,11 @@ public class ExcelDataServiceImpl extends ServiceImpl<ExcelDataMapper, ExcelData
.eq(ExcelDataEntity::getCaseId, excelDataDTO.getCaseId())
.eq(ExcelDataEntity::getPayUserName, excelDataDTO.getPayUserName()));
}
@Override
public List<ExcelDataEntity> queryListByPayeeName(String oldName, String caseId) {
return baseMapper.selectList(new LambdaQueryWrapper<ExcelDataEntity>()
.eq(ExcelDataEntity::getCaseId, caseId)
.eq(ExcelDataEntity::getPayeeName, oldName));
}
}
......@@ -29,11 +29,11 @@ public class GroupServiceImpl extends ServiceImpl<GroupMapper, GroupEntity> impl
groupDetailService.remove(new LambdaQueryWrapper<GroupDetailEntity>()
.eq(GroupDetailEntity::getCaseId, id));
//保存新的案例团体和
groups.forEach(groupVO -> {
//初始化团体实体
for (int i = 0; i < groups.size(); i++) {
GroupVO groupVO = groups.get(i);
GroupEntity groupEntity = new GroupEntity();
groupEntity.setGroupSize(groupVO.getGroupSize());
groupEntity.setGroupName(groupVO.getGroupName());
groupEntity.setGroupName("团体" + 1);
groupEntity.setCaseId(id);
groupEntity.setTotalAmount(groupVO.getTotalAmount());
groupEntity.setTotalTransactions(groupVO.getTotalTransactions());
......@@ -49,7 +49,7 @@ public class GroupServiceImpl extends ServiceImpl<GroupMapper, GroupEntity> impl
groupDetailService.saveBatch(groupDetailList);
}
groupVO.setGroupDetailList(null);
});
}
}
@Override
......@@ -57,4 +57,15 @@ public class GroupServiceImpl extends ServiceImpl<GroupMapper, GroupEntity> impl
return DozerUtils.convertList(baseMapper.selectList(new LambdaQueryWrapper<GroupEntity>()
.eq(GroupEntity::getCaseId, id)), GroupVO.class);
}
@Override
public boolean updateGroupName(GroupEntity groupEntity) {
//查看信息
GroupEntity groupEntityNew = getById(groupEntity.getId());
if (groupEntityNew != null) {
groupEntityNew.setGroupName(groupEntity.getGroupName());
return updateById(groupEntityNew);
}
return false;
}
}
......@@ -28,10 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.*;
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> implements UserService {
......@@ -44,7 +41,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
private ExcelDataService excelDataService;
@Override
public UserVO getDetail(String userName,String caseId) {
public UserVO getDetail(String userName, String caseId) {
UserEntity userEntity = baseMapper.selectOne(new LambdaQueryWrapper<UserEntity>()
.eq(UserEntity::getUserName, userName));
UserVO userVO = DozerUtils.convertBean(userEntity, UserVO.class);
......@@ -55,41 +52,41 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
}
List<UserRelationEntity> relationShipList = userRelationService.list(new LambdaQueryWrapper<UserRelationEntity>()
.eq(UserRelationEntity::getUserName, userEntity.getUserName()).eq(UserRelationEntity::getCaseId, caseId));
if(!ObjectUtils.isEmpty(relationShipList)){
if (!ObjectUtils.isEmpty(relationShipList)) {
userVO.setRelationShipList(relationShipList);
}
//本人账号数量
HashSet<String> account = Sets.newHashSet();
//查询关联资金
List<AssociationVO> financialTransactions = excelDataService.selectFinancialTransactions(userName, caseId);
Map<String,List<AssociationVO>> detailsFunds = Maps.newHashMap();
Map<String, List<AssociationVO>> detailsFunds = Maps.newHashMap();
for (AssociationVO financialTransaction : financialTransactions) {
if(financialTransaction.getDirection().equals("出账")){
if(detailsFunds.containsKey(financialTransaction.getPayee())){
financialTransaction.setRelationDesc(detailsFunds.get(financialTransaction.getPayee()).size() + "、"+ financialTransaction.getStartTime() + "-" + financialTransaction.getEndTime()
if (financialTransaction.getDirection().equals("出账")) {
if (detailsFunds.containsKey(financialTransaction.getPayee())) {
financialTransaction.setRelationDesc(detailsFunds.get(financialTransaction.getPayee()).size() + "、" + financialTransaction.getStartTime() + "-" + financialTransaction.getEndTime()
+ financialTransaction.getPayee() + "->" + financialTransaction.getPayment() + "," + financialTransaction.getTotalAmount() + ",交易" + financialTransaction.getNum() + "次");
detailsFunds.get(financialTransaction.getPayee()).add(financialTransaction);
account.add(financialTransaction.getPayment());
}else {
} else {
List<AssociationVO> list = new ArrayList<>();
financialTransaction.setRelationDesc("1、"+ financialTransaction.getStartTime() + "-" + financialTransaction.getEndTime()
financialTransaction.setRelationDesc("1、" + financialTransaction.getStartTime() + "-" + financialTransaction.getEndTime()
+ financialTransaction.getPayee() + "->" + financialTransaction.getPayment() + "," + financialTransaction.getTotalAmount() + ",交易" + financialTransaction.getNum() + "次");
list.add(financialTransaction);
detailsFunds.put(financialTransaction.getPayee(),list);
detailsFunds.put(financialTransaction.getPayee(), list);
account.add(financialTransaction.getPayment());
}
}else if(financialTransaction.getDirection().equals("入账")){
if(detailsFunds.containsKey(financialTransaction.getPayment())){
financialTransaction.setRelationDesc(detailsFunds.get(financialTransaction.getPayment()).size() + "、"+ financialTransaction.getStartTime() + "-" + financialTransaction.getEndTime()
} else if (financialTransaction.getDirection().equals("入账")) {
if (detailsFunds.containsKey(financialTransaction.getPayment())) {
financialTransaction.setRelationDesc(detailsFunds.get(financialTransaction.getPayment()).size() + "、" + financialTransaction.getStartTime() + "-" + financialTransaction.getEndTime()
+ financialTransaction.getPayee() + "->" + financialTransaction.getPayment() + "," + financialTransaction.getTotalAmount() + ",交易" + financialTransaction.getNum() + "次");
detailsFunds.get(financialTransaction.getPayment()).add(financialTransaction);
account.add(financialTransaction.getPayee());
}else {
} else {
List<AssociationVO> list = new ArrayList<>();
financialTransaction.setRelationDesc("1、"+ financialTransaction.getStartTime() + "-" + financialTransaction.getEndTime()
financialTransaction.setRelationDesc("1、" + financialTransaction.getStartTime() + "-" + financialTransaction.getEndTime()
+ financialTransaction.getPayee() + "->" + financialTransaction.getPayment() + "," + financialTransaction.getTotalAmount() + ",交易" + financialTransaction.getNum() + "次");
list.add(financialTransaction);
detailsFunds.put(financialTransaction.getPayment(),list);
detailsFunds.put(financialTransaction.getPayment(), list);
account.add(financialTransaction.getPayee());
}
}
......@@ -112,7 +109,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
@Override
public boolean updateUser(UserDTO userDTO) {
List<UserRelationEntity> relationShipList = userDTO.getRelationShipList();
if(!ObjectUtils.isEmpty(relationShipList)){
if (!ObjectUtils.isEmpty(relationShipList)) {
userRelationService.saveOrUpdateBatch(relationShipList);
}
updateById(userDTO);
......@@ -132,7 +129,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
public Boolean add(UserDTO userDTO) {
//解析身份证号
Map<String, String> idCardInfo = IdCardUtils.parseIdCardInfo(userDTO.getIdCard());
if(MapUtil.isNotEmpty(idCardInfo)){
if (MapUtil.isNotEmpty(idCardInfo)) {
userDTO.setAge(Integer.parseInt(idCardInfo.get("age")));
userDTO.setSex(idCardInfo.get("sex"));
userDTO.setIdType("身份证");
......@@ -159,10 +156,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
public List<ExcelDataEntity> cashFlow(UserDTO userDTO) {
List<ExcelDataEntity> excelDataList = excelDataService.cashFlow(userDTO);
for (ExcelDataEntity excelDataEntity : excelDataList) {
if("出账".equals(excelDataEntity.getDirection())){
if ("出账".equals(excelDataEntity.getDirection())) {
excelDataEntity.setSelfAccount(excelDataEntity.getPayAccount());
excelDataEntity.setAssociationAccount(excelDataEntity.getPayeeAccount());
}else if("入账".equals(excelDataEntity.getDirection())){
} else if ("入账".equals(excelDataEntity.getDirection())) {
excelDataEntity.setSelfAccount(excelDataEntity.getPayeeAccount());
excelDataEntity.setAssociationAccount(excelDataEntity.getPayAccount());
}
......@@ -174,10 +171,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
public EveryoneVO relationPage(UserDTO userDTO) {
EveryoneVO everyoneVO = new EveryoneVO();
UserEntity oneself = getOne(new LambdaQueryWrapper<UserEntity>()
.eq(UserEntity::getUserName, userDTO.getUserName()).eq(UserEntity::getCaseId, userDTO.getCaseId()),false);
.eq(UserEntity::getUserName, userDTO.getUserName()).eq(UserEntity::getCaseId, userDTO.getCaseId()), false);
UserEntity other = getOne(new LambdaQueryWrapper<UserEntity>()
.eq(UserEntity::getUserName, userDTO.getOtherName()).eq(UserEntity::getCaseId, userDTO.getCaseId()),false);
if(ObjectUtils.isEmpty(oneself) || ObjectUtils.isEmpty(other)){
.eq(UserEntity::getUserName, userDTO.getOtherName()).eq(UserEntity::getCaseId, userDTO.getCaseId()), false);
if (ObjectUtils.isEmpty(oneself) || ObjectUtils.isEmpty(other)) {
throw new BusinessException("用户不存在");
}
//标题
......@@ -187,16 +184,16 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
.eq(UserRelationEntity::getUserName, userDTO.getUserName())
.eq(UserRelationEntity::getOtherName, userDTO.getOtherName()));
//指认关系
if(ObjectUtils.isEmpty(userRelation)){
if (ObjectUtils.isEmpty(userRelation)) {
everyoneVO.setRelation(userRelation);
}
//查询账户
List<String> oneselfAccountList = userAccountService.queryUserAccountList(oneself.getUserName());
List<String> otherAccountList = userAccountService.queryUserAccountList(oneself.getUserName());
PageHelper.startPage(userDTO.getPageNum(),userDTO.getPageSize());
PageHelper.startPage(userDTO.getPageNum(), userDTO.getPageSize());
List<ExcelDataEntity> details = excelDataService.relationPage(oneselfAccountList,otherAccountList);
List<ExcelDataEntity> details = excelDataService.relationPage(oneselfAccountList, otherAccountList);
everyoneVO.setDetails(details);
PageHelper.clearPage();
return everyoneVO;
......@@ -212,4 +209,19 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
userRelationService.remove(new LambdaQueryWrapper<UserRelationEntity>().eq(UserRelationEntity::getOtherName, userName));
return remove(new LambdaQueryWrapper<UserEntity>().eq(UserEntity::getUserName, userName));
}
@Override
public UserEntity getByUserName(String newName) {
return baseMapper.selectOne(new LambdaQueryWrapper<UserEntity>()
.eq(UserEntity::getUserName, newName));
}
@Override
public List<String> queryListByCaseId(Integer id) {
List<UserEntity> userEntityList = baseMapper.selectList(new LambdaQueryWrapper<UserEntity>()
.eq(UserEntity::getCaseId, id));
Set<String> userNameList = new HashSet<>();
userEntityList.forEach(userEntity -> userNameList.add(userEntity.getUserName()));
return new ArrayList<>(userNameList);
}
}
......@@ -27,6 +27,7 @@
</where>
group by
ed.file_id,ed.pay_user_name,fu.file_name,fu.path,ed.use_flag,ed.user_flag
order by ed.user_flag DESC
</select>
<select id="queryList" resultType="com.platform.model.entity.ExcelDataEntity">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment