feat: 债务还款计划完成;修复部分bug

This commit is contained in:
Bunny 2024-11-17 00:47:09 +08:00
parent 38eb0afd92
commit 31ff32fe34
11 changed files with 259 additions and 11 deletions

View File

@ -1,6 +1,6 @@
package cn.bunny.dao.vo.financial.user;
import cn.bunny.dao.common.vo.BaseUserVo;
import cn.bunny.dao.common.vo.BaseVo;
import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@ -20,7 +20,7 @@ import java.time.LocalDateTime;
@NoArgsConstructor
@Builder
@Schema(name = "BudgetCategoryVo对象", title = "预算分类查询返回对象", description = "预算分类查询返回对象")
public class BudgetCategoryUserVo extends BaseUserVo {
public class BudgetCategoryUserVo extends BaseVo {
@Schema(name = "parentId", title = "父级id")
@JsonFormat(shape = JsonFormat.Shape.STRING)

View File

@ -0,0 +1,41 @@
package cn.bunny.dao.vo.financial.user;
import cn.bunny.dao.common.vo.BaseVo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "DebtRepaymentPlanVo对象", title = "债务还款计划返回对象", description = "债务还款计划返回对象")
public class DebtRepaymentPlanUserVo extends BaseVo {
@Schema(name = "installmentNumber", title = "债务金额")
private BigDecimal installmentNumber;
@Schema(name = "installmentAmount", title = "每期应还金额")
private BigDecimal installmentAmount;
@Schema(name = "dueDate", title = "还款截止日期")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
private LocalDateTime dueDate;
@Schema(name = "paidAmount", title = "已还金额")
private BigDecimal paidAmount;
@Schema(name = "paymentStatus", title = "还款状态")
private String paymentStatus;
}

View File

@ -1,6 +1,6 @@
package cn.bunny.dao.vo.financial.user;
import cn.bunny.dao.common.vo.BaseUserVo;
import cn.bunny.dao.common.vo.BaseVo;
import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@ -20,7 +20,7 @@ import java.time.LocalDateTime;
@NoArgsConstructor
@Builder
@Schema(name = "DebtTrackingVo对象", title = "债务追踪返回内容", description = "债务追踪返回内容")
public class DebtTrackingUserVo extends BaseUserVo {
public class DebtTrackingUserVo extends BaseVo {
@Schema(name = "userId", title = "绑定的用户")
@JsonFormat(shape = JsonFormat.Shape.STRING)

View File

@ -0,0 +1,44 @@
package cn.bunny.dao.vo.financial.user;
import cn.bunny.dao.common.vo.BaseVo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Schema(name = "SavingGoalVo对象", title = "用户储值返回内容", description = "用户储值返回内容")
public class SavingGoalUserVo extends BaseVo {
@Schema(name = "statusType", title = "完成状态")
private String statusType;
@Schema(name = "savingGoalName", title = "储值目标名称")
private String savingGoalName;
@Schema(name = "amount", title = "目标金额")
private BigDecimal amount;
@Schema(name = "startDuration", title = "开始目标时长")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
private LocalDateTime startDuration;
@Schema(name = "endDuration", title = "结束目标时长")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
private LocalDateTime endDuration;
}

View File

@ -3,11 +3,14 @@ package cn.bunny.services.controller.financial;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.DebtRepaymentPlanDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanAddDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanUpdateDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanAddUserDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanUpdateUserDto;
import cn.bunny.dao.entity.financial.DebtRepaymentPlan;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.Result;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
import cn.bunny.dao.vo.financial.admin.DebtRepaymentPlanVo;
import cn.bunny.dao.vo.financial.user.DebtRepaymentPlanUserVo;
import cn.bunny.services.service.financial.DebtRepaymentPlanService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
@ -49,6 +52,19 @@ public class DebtRepaymentPlanController {
return Mono.just(Result.success(pageResult));
}
@Operation(summary = "用户分页查询债务还款计划表", description = "用户分页查询债务还款计划表")
@GetMapping("noManage/getUserDebtRepaymentPlanList/{page}/{limit}")
public Mono<Result<PageResult<DebtRepaymentPlanUserVo>>> getUserDebtRepaymentPlanList(
@Parameter(name = "page", description = "当前页", required = true)
@PathVariable("page") Integer page,
@Parameter(name = "limit", description = "每页记录数", required = true)
@PathVariable("limit") Integer limit,
DebtRepaymentPlanDto dto) {
Page<DebtRepaymentPlan> pageParams = new Page<>(page, limit);
PageResult<DebtRepaymentPlanUserVo> pageResult = debtRepaymentPlanService.getUserDebtRepaymentPlanList(pageParams, dto);
return Mono.just(Result.success(pageResult));
}
@Operation(summary = "添加债务还款计划表", description = "添加债务还款计划表")
@PostMapping("addDebtRepaymentPlan")
public Mono<Result<String>> addDebtRepaymentPlan(@Valid @RequestBody DebtRepaymentPlanAddDto dto) {
@ -56,6 +72,13 @@ public class DebtRepaymentPlanController {
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
}
@Operation(summary = "用户添加债务还款计划表", description = "用户添加债务还款计划表")
@PostMapping("noManage/addUserDebtRepaymentPlan")
public Mono<Result<String>> addUserDebtRepaymentPlan(@Valid @RequestBody DebtRepaymentPlanAddUserDto dto) {
debtRepaymentPlanService.addUserDebtRepaymentPlan(dto);
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
}
@Operation(summary = "更新债务还款计划表", description = "更新债务还款计划表")
@PutMapping("updateDebtRepaymentPlan")
public Mono<Result<String>> updateDebtRepaymentPlan(@Valid @RequestBody DebtRepaymentPlanUpdateDto dto) {
@ -63,10 +86,25 @@ public class DebtRepaymentPlanController {
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
}
@Operation(summary = "用户更新债务还款计划表", description = "用户更新债务还款计划表")
@PutMapping("noManage/updateUserDebtRepaymentPlan")
public Mono<Result<String>> updateUserDebtRepaymentPlan(@Valid @RequestBody DebtRepaymentPlanUpdateUserDto dto) {
debtRepaymentPlanService.updateUserDebtRepaymentPlan(dto);
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
}
@Operation(summary = "删除债务还款计划表", description = "删除债务还款计划表")
@DeleteMapping("deleteDebtRepaymentPlan")
public Mono<Result<String>> deleteDebtRepaymentPlan(@RequestBody List<Long> ids) {
debtRepaymentPlanService.deleteDebtRepaymentPlan(ids);
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
}
@Operation(summary = "用户删除债务还款计划表", description = "用户删除债务还款计划表")
@DeleteMapping("noManage/deleteUserDebtRepaymentPlan")
public Mono<Result<String>> deleteUserDebtRepaymentPlan(@RequestBody List<Long> ids) {
debtRepaymentPlanService.deleteUserDebtRepaymentPlan(ids);
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
}
}

View File

@ -9,6 +9,7 @@ import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.Result;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
import cn.bunny.dao.vo.financial.admin.SavingGoalVo;
import cn.bunny.dao.vo.financial.user.SavingGoalUserVo;
import cn.bunny.services.service.financial.SavingGoalService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
@ -52,14 +53,14 @@ public class SavingGoalController {
@Operation(summary = "用户分页查询用户储值", description = "用户分页查询用户储值")
@GetMapping("noManage/getUserSavingGoalList/{page}/{limit}")
public Mono<Result<PageResult<SavingGoalVo>>> getUserSavingGoalList(
public Mono<Result<PageResult<SavingGoalUserVo>>> getUserSavingGoalList(
@Parameter(name = "page", description = "当前页", required = true)
@PathVariable("page") Integer page,
@Parameter(name = "limit", description = "每页记录数", required = true)
@PathVariable("limit") Integer limit,
SavingGoalDto dto) {
Page<SavingGoal> pageParams = new Page<>(page, limit);
PageResult<SavingGoalVo> pageResult = savingGoalService.getUserSavingGoalList(pageParams, dto);
PageResult<SavingGoalUserVo> pageResult = savingGoalService.getUserSavingGoalList(pageParams, dto);
return Mono.just(Result.success(pageResult));
}

View File

@ -3,9 +3,12 @@ package cn.bunny.services.service.financial;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.DebtRepaymentPlanDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanAddDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanUpdateDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanAddUserDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanUpdateUserDto;
import cn.bunny.dao.entity.financial.DebtRepaymentPlan;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.financial.admin.DebtRepaymentPlanVo;
import cn.bunny.dao.vo.financial.user.DebtRepaymentPlanUserVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import jakarta.validation.Valid;
@ -49,4 +52,34 @@ public interface DebtRepaymentPlanService extends IService<DebtRepaymentPlan> {
* @param ids 删除id列表
*/
void deleteDebtRepaymentPlan(List<Long> ids);
/**
* 用户分页查询债务还款计划表
*
* @param pageParams 分页参数
* @param dto 查询表单
* @return 分页返回结果
*/
PageResult<DebtRepaymentPlanUserVo> getUserDebtRepaymentPlanList(Page<DebtRepaymentPlan> pageParams, DebtRepaymentPlanDto dto);
/**
* 用户添加债务还款计划表
*
* @param dto 添加表单
*/
void addUserDebtRepaymentPlan(@Valid DebtRepaymentPlanAddUserDto dto);
/**
* 用户更新债务还款计划表
*
* @param dto 更新表单
*/
void updateUserDebtRepaymentPlan(@Valid DebtRepaymentPlanUpdateUserDto dto);
/**
* 用户删除债务还款计划表
*
* @param ids 删除id列表
*/
void deleteUserDebtRepaymentPlan(List<Long> ids);
}

View File

@ -7,6 +7,7 @@ import cn.bunny.dao.dto.financial.savingGoal.user.SavingGoalAddUserDto;
import cn.bunny.dao.entity.financial.SavingGoal;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.vo.financial.admin.SavingGoalVo;
import cn.bunny.dao.vo.financial.user.SavingGoalUserVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import jakarta.validation.Valid;
@ -58,7 +59,7 @@ public interface SavingGoalService extends IService<SavingGoal> {
* @param dto 分页查询表单
* @return 分页返回结果
*/
PageResult<SavingGoalVo> getUserSavingGoalList(Page<SavingGoal> pageParams, SavingGoalDto dto);
PageResult<SavingGoalUserVo> getUserSavingGoalList(Page<SavingGoal> pageParams, SavingGoalDto dto);
/**
* 用户添加储值

View File

@ -1,14 +1,21 @@
package cn.bunny.services.service.financial.impl;
import cn.bunny.common.service.context.BaseContext;
import cn.bunny.common.service.exception.BunnyException;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.DebtRepaymentPlanDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanAddDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.admin.DebtRepaymentPlanUpdateDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanAddUserDto;
import cn.bunny.dao.dto.financial.debtRepaymentPlan.user.DebtRepaymentPlanUpdateUserDto;
import cn.bunny.dao.entity.financial.DebtRepaymentPlan;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
import cn.bunny.dao.vo.financial.admin.DebtRepaymentPlanVo;
import cn.bunny.dao.vo.financial.user.DebtRepaymentPlanUserVo;
import cn.bunny.services.mapper.financial.DebtRepaymentPlanMapper;
import cn.bunny.services.service.financial.DebtRepaymentPlanService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.validation.Valid;
@ -82,4 +89,77 @@ public class DebtRepaymentPlanServiceImpl extends ServiceImpl<DebtRepaymentPlanM
public void deleteDebtRepaymentPlan(List<Long> ids) {
baseMapper.deleteBatchIdsWithPhysics(ids);
}
/**
* 用户分页查询债务还款计划表
*
* @param pageParams 分页参数
* @param dto 查询表单
* @return 分页返回结果
*/
@Override
public PageResult<DebtRepaymentPlanUserVo> getUserDebtRepaymentPlanList(Page<DebtRepaymentPlan> pageParams, DebtRepaymentPlanDto dto) {
dto.setUserId(BaseContext.getUserId());
IPage<DebtRepaymentPlanVo> page = baseMapper.selectListByPage(pageParams, dto);
List<DebtRepaymentPlanUserVo> planUserVoList = page.getRecords().stream().map(debtRepaymentPlanVo -> {
DebtRepaymentPlanUserVo debtRepaymentPlanUserVo = new DebtRepaymentPlanUserVo();
BeanUtils.copyProperties(debtRepaymentPlanVo, debtRepaymentPlanUserVo);
return debtRepaymentPlanUserVo;
}).toList();
return PageResult.<DebtRepaymentPlanUserVo>builder()
.list(planUserVoList)
.pageNo(page.getCurrent())
.pageSize(page.getSize())
.total(page.getTotal())
.build();
}
/**
* 用户添加债务还款计划表
*
* @param dto 添加表单
*/
@Override
public void addUserDebtRepaymentPlan(@Valid DebtRepaymentPlanAddUserDto dto) {
// 保存数据
DebtRepaymentPlan debtRepaymentPlan = new DebtRepaymentPlan();
BeanUtils.copyProperties(dto, debtRepaymentPlan);
debtRepaymentPlan.setUserId(BaseContext.getUserId());
save(debtRepaymentPlan);
}
/**
* 用户更新债务还款计划表
*
* @param dto 更新表单
*/
@Override
public void updateUserDebtRepaymentPlan(@Valid DebtRepaymentPlanUpdateUserDto dto) {
// 更新内容
DebtRepaymentPlan debtRepaymentPlan = new DebtRepaymentPlan();
BeanUtils.copyProperties(dto, debtRepaymentPlan);
debtRepaymentPlan.setUserId(BaseContext.getUserId());
updateById(debtRepaymentPlan);
}
/**
* 用户删除债务还款计划表
*
* @param ids 删除id列表
*/
@Override
public void deleteUserDebtRepaymentPlan(List<Long> ids) {
// 判断删除的是否是自己的账单
List<DebtRepaymentPlan> billList = list(Wrappers.<DebtRepaymentPlan>lambdaQuery().in(DebtRepaymentPlan::getId, ids))
.stream().filter(bill -> !bill.getUserId().equals(BaseContext.getUserId())).toList();
if (!billList.isEmpty()) {
throw new BunnyException(ResultCodeEnum.ILLEGAL_DATA_REQUEST);
}
baseMapper.deleteBatchIdsWithPhysics(ids);
}
}

View File

@ -10,6 +10,7 @@ import cn.bunny.dao.entity.financial.SavingGoal;
import cn.bunny.dao.pojo.result.PageResult;
import cn.bunny.dao.pojo.result.ResultCodeEnum;
import cn.bunny.dao.vo.financial.admin.SavingGoalVo;
import cn.bunny.dao.vo.financial.user.SavingGoalUserVo;
import cn.bunny.services.mapper.financial.SavingGoalMapper;
import cn.bunny.services.service.financial.SavingGoalService;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -96,12 +97,18 @@ public class SavingGoalServiceImpl extends ServiceImpl<SavingGoalMapper, SavingG
* @return 分页返回结果
*/
@Override
public PageResult<SavingGoalVo> getUserSavingGoalList(Page<SavingGoal> pageParams, SavingGoalDto dto) {
public PageResult<SavingGoalUserVo> getUserSavingGoalList(Page<SavingGoal> pageParams, SavingGoalDto dto) {
dto.setUserId(BaseContext.getUserId());
IPage<SavingGoalVo> page = baseMapper.selectListByPage(pageParams, dto);
return PageResult.<SavingGoalVo>builder()
.list(page.getRecords())
IPage<SavingGoalVo> page = baseMapper.selectListByPage(pageParams, dto);
List<SavingGoalUserVo> goalUserVoList = page.getRecords().stream().map(savingGoalVo -> {
SavingGoalUserVo savingGoalUserVo = new SavingGoalUserVo();
BeanUtils.copyProperties(savingGoalVo, savingGoalUserVo);
return savingGoalUserVo;
}).toList();
return PageResult.<SavingGoalUserVo>builder()
.list(goalUserVoList)
.pageNo(page.getCurrent())
.pageSize(page.getSize())
.total(page.getTotal())

View File

@ -36,6 +36,9 @@
left join sys_user update_user on update_user.id = base.update_user
<where>
base.is_deleted = 0
<if test="dto.userId != null">
and base.user_id = #{dto.userId}
</if>
<if test="dto.installmentNumber != null and dto.installmentNumber != ''">
and base.installment_number like CONCAT('%',#{dto.installmentNumber},'%')
</if>