【新增】回款管理 功能
parent
439edcd1be
commit
73f4fc8ceb
@ -0,0 +1,19 @@
|
||||
|
||||
INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (184, '回款管理审批状态', 'crm_receivable_check_status', 0, '回款管理审批状态(0 未审核 1 审核通过 2 审核拒绝 3 审核中 4 已撤回)', '1', '2023-10-18 21:44:24', '1', '2023-10-18 21:44:24', b'0', '1970-01-01 00:00:00');
|
||||
INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (185, '回款管理-回款方式', 'crm_return_type', 0, '回款管理-回款方式', '1', '2023-10-18 21:54:10', '1', '2023-10-18 21:54:10', b'0', '1970-01-01 00:00:00');
|
||||
|
||||
|
||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1389, 0, '未审核', '0', 'crm_receivable_check_status', 0, 'default', '', '0 未审核 ', '1', '2023-10-18 21:46:00', '1', '2023-10-18 21:47:16', b'0');
|
||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1390, 1, '审核通过', '1', 'crm_receivable_check_status', 0, 'default', '', '1 审核通过', '1', '2023-10-18 21:46:18', '1', '2023-10-18 21:47:08', b'0');
|
||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1391, 2, '审核拒绝', '2', 'crm_receivable_check_status', 0, 'default', '', ' 2 审核拒绝', '1', '2023-10-18 21:46:58', '1', '2023-10-18 21:47:21', b'0');
|
||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1392, 3, '审核中', '3', 'crm_receivable_check_status', 0, 'default', '', ' 3 审核中', '1', '2023-10-18 21:47:35', '1', '2023-10-18 21:47:35', b'0');
|
||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1393, 4, '已撤回', '4', 'crm_receivable_check_status', 0, 'default', '', ' 4 已撤回', '1', '2023-10-18 21:47:46', '1', '2023-10-18 21:47:46', b'0');
|
||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1394, 1, '支票', '1', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:54:29', '1', '2023-10-18 21:54:29', b'0');
|
||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1395, 2, '现金', '2', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:54:41', '1', '2023-10-18 21:54:41', b'0');
|
||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1396, 3, '邮政汇款', '3', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:54:53', '1', '2023-10-18 21:54:53', b'0');
|
||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1397, 4, '电汇', '4', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:07', '1', '2023-10-18 21:55:07', b'0');
|
||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1398, 5, '网上转账', '5', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:24', '1', '2023-10-18 21:55:24', b'0');
|
||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1399, 6, '支付宝', '6', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:38', '1', '2023-10-18 21:55:38', b'0');
|
||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1400, 7, '微信支付', '7', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:53', '1', '2023-10-18 21:55:53', b'0');
|
||||
INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1401, 8, '其他', '8', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:56:06', '1', '2023-10-18 21:56:06', b'0');
|
||||
|
||||
@ -0,0 +1,101 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.receivable;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO;
|
||||
import cn.iocoder.yudao.module.crm.service.receivable.ReceivableService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
/**
|
||||
* @author 赤焰
|
||||
*/
|
||||
@Tag(name = "管理后台 - 回款管理")
|
||||
@RestController
|
||||
@RequestMapping("/crm/receivable")
|
||||
@Validated
|
||||
public class ReceivableController {
|
||||
|
||||
@Resource
|
||||
private ReceivableService receivableService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建回款管理")
|
||||
@PreAuthorize("@ss.hasPermission('crm:receivable:create')")
|
||||
public CommonResult<Long> createReceivable(@Valid @RequestBody ReceivableCreateReqVO createReqVO) {
|
||||
return success(receivableService.createReceivable(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新回款管理")
|
||||
@PreAuthorize("@ss.hasPermission('crm:receivable:update')")
|
||||
public CommonResult<Boolean> updateReceivable(@Valid @RequestBody ReceivableUpdateReqVO updateReqVO) {
|
||||
receivableService.updateReceivable(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除回款管理")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('crm:receivable:delete')")
|
||||
public CommonResult<Boolean> deleteReceivable(@RequestParam("id") Long id) {
|
||||
receivableService.deleteReceivable(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得回款管理")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('crm:receivable:query')")
|
||||
public CommonResult<ReceivableRespVO> getReceivable(@RequestParam("id") Long id) {
|
||||
ReceivableDO receivable = receivableService.getReceivable(id);
|
||||
return success(ReceivableConvert.INSTANCE.convert(receivable));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得回款管理列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||
@PreAuthorize("@ss.hasPermission('crm:receivable:query')")
|
||||
public CommonResult<List<ReceivableRespVO>> getReceivableList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<ReceivableDO> list = receivableService.getReceivableList(ids);
|
||||
return success(ReceivableConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得回款管理分页")
|
||||
@PreAuthorize("@ss.hasPermission('crm:receivable:query')")
|
||||
public CommonResult<PageResult<ReceivableRespVO>> getReceivablePage(@Valid ReceivablePageReqVO pageVO) {
|
||||
PageResult<ReceivableDO> pageResult = receivableService.getReceivablePage(pageVO);
|
||||
return success(ReceivableConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出回款管理 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('crm:receivable:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportReceivableExcel(@Valid ReceivableExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<ReceivableDO> list = receivableService.getReceivableList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<ReceivableExcelVO> datas = ReceivableConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "回款管理.xls", "数据", ReceivableExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 回款管理创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ReceivableCreateReqVO extends ReceivableBaseVO {
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 回款管理 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ReceivableRespVO extends ReceivableBaseVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25787")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 回款管理更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ReceivableUpdateReqVO extends ReceivableBaseVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25787")
|
||||
@NotNull(message = "ID不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.crm.convert.receivable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO;
|
||||
|
||||
/**
|
||||
* 回款管理 Convert
|
||||
*
|
||||
* @author 赤焰
|
||||
*/
|
||||
@Mapper
|
||||
public interface ReceivableConvert {
|
||||
|
||||
ReceivableConvert INSTANCE = Mappers.getMapper(ReceivableConvert.class);
|
||||
|
||||
ReceivableDO convert(ReceivableCreateReqVO bean);
|
||||
|
||||
ReceivableDO convert(ReceivableUpdateReqVO bean);
|
||||
|
||||
ReceivableRespVO convert(ReceivableDO bean);
|
||||
|
||||
List<ReceivableRespVO> convertList(List<ReceivableDO> list);
|
||||
|
||||
PageResult<ReceivableRespVO> convertPage(PageResult<ReceivableDO> page);
|
||||
|
||||
List<ReceivableExcelVO> convertList02(List<ReceivableDO> list);
|
||||
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package cn.iocoder.yudao.module.crm.dal.mysql.receivable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*;
|
||||
|
||||
/**
|
||||
* 回款管理 Mapper
|
||||
*
|
||||
* @author 赤焰
|
||||
*/
|
||||
@Mapper
|
||||
public interface ReceivableMapper extends BaseMapperX<ReceivableDO> {
|
||||
|
||||
default PageResult<ReceivableDO> selectPage(ReceivablePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ReceivableDO>()
|
||||
.eqIfPresent(ReceivableDO::getNo, reqVO.getNo())
|
||||
.eqIfPresent(ReceivableDO::getPlanId, reqVO.getPlanId())
|
||||
.eqIfPresent(ReceivableDO::getCustomerId, reqVO.getCustomerId())
|
||||
.eqIfPresent(ReceivableDO::getContractId, reqVO.getContractId())
|
||||
.eqIfPresent(ReceivableDO::getCheckStatus, reqVO.getCheckStatus())
|
||||
.eqIfPresent(ReceivableDO::getProcessInstanceId, reqVO.getProcessInstanceId())
|
||||
.betweenIfPresent(ReceivableDO::getReturnTime, reqVO.getReturnTime())
|
||||
.eqIfPresent(ReceivableDO::getReturnType, reqVO.getReturnType())
|
||||
.eqIfPresent(ReceivableDO::getPrice, reqVO.getPrice())
|
||||
.eqIfPresent(ReceivableDO::getOwnerUserId, reqVO.getOwnerUserId())
|
||||
.eqIfPresent(ReceivableDO::getBatchId, reqVO.getBatchId())
|
||||
.eqIfPresent(ReceivableDO::getSort, reqVO.getSort())
|
||||
.eqIfPresent(ReceivableDO::getDataScope, reqVO.getDataScope())
|
||||
.eqIfPresent(ReceivableDO::getDataScopeDeptIds, reqVO.getDataScopeDeptIds())
|
||||
.eqIfPresent(ReceivableDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(ReceivableDO::getRemark, reqVO.getRemark())
|
||||
.betweenIfPresent(ReceivableDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ReceivableDO::getId));
|
||||
}
|
||||
|
||||
default List<ReceivableDO> selectList(ReceivableExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<ReceivableDO>()
|
||||
.eqIfPresent(ReceivableDO::getNo, reqVO.getNo())
|
||||
.eqIfPresent(ReceivableDO::getPlanId, reqVO.getPlanId())
|
||||
.eqIfPresent(ReceivableDO::getCustomerId, reqVO.getCustomerId())
|
||||
.eqIfPresent(ReceivableDO::getContractId, reqVO.getContractId())
|
||||
.eqIfPresent(ReceivableDO::getCheckStatus, reqVO.getCheckStatus())
|
||||
.eqIfPresent(ReceivableDO::getProcessInstanceId, reqVO.getProcessInstanceId())
|
||||
.betweenIfPresent(ReceivableDO::getReturnTime, reqVO.getReturnTime())
|
||||
.eqIfPresent(ReceivableDO::getReturnType, reqVO.getReturnType())
|
||||
.eqIfPresent(ReceivableDO::getPrice, reqVO.getPrice())
|
||||
.eqIfPresent(ReceivableDO::getOwnerUserId, reqVO.getOwnerUserId())
|
||||
.eqIfPresent(ReceivableDO::getBatchId, reqVO.getBatchId())
|
||||
.eqIfPresent(ReceivableDO::getSort, reqVO.getSort())
|
||||
.eqIfPresent(ReceivableDO::getDataScope, reqVO.getDataScope())
|
||||
.eqIfPresent(ReceivableDO::getDataScopeDeptIds, reqVO.getDataScopeDeptIds())
|
||||
.eqIfPresent(ReceivableDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(ReceivableDO::getRemark, reqVO.getRemark())
|
||||
.betweenIfPresent(ReceivableDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ReceivableDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
package cn.iocoder.yudao.module.crm.service.receivable;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 回款管理 Service 接口
|
||||
*
|
||||
* @author 赤焰
|
||||
*/
|
||||
public interface ReceivableService {
|
||||
|
||||
/**
|
||||
* 创建回款管理
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createReceivable(@Valid ReceivableCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新回款管理
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateReceivable(@Valid ReceivableUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除回款管理
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteReceivable(Long id);
|
||||
|
||||
/**
|
||||
* 获得回款管理
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 回款管理
|
||||
*/
|
||||
ReceivableDO getReceivable(Long id);
|
||||
|
||||
/**
|
||||
* 获得回款管理列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 回款管理列表
|
||||
*/
|
||||
List<ReceivableDO> getReceivableList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得回款管理分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 回款管理分页
|
||||
*/
|
||||
PageResult<ReceivableDO> getReceivablePage(ReceivablePageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得回款管理列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 回款管理列表
|
||||
*/
|
||||
List<ReceivableDO> getReceivableList(ReceivableExportReqVO exportReqVO);
|
||||
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
package cn.iocoder.yudao.module.crm.service.receivable;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
|
||||
/**
|
||||
* 回款管理 Service 实现类
|
||||
*
|
||||
* @author 赤焰
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ReceivableServiceImpl implements ReceivableService {
|
||||
|
||||
@Resource
|
||||
private ReceivableMapper receivableMapper;
|
||||
|
||||
@Override
|
||||
public Long createReceivable(ReceivableCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
ReceivableDO receivable = ReceivableConvert.INSTANCE.convert(createReqVO);
|
||||
receivableMapper.insert(receivable);
|
||||
// 返回
|
||||
return receivable.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateReceivable(ReceivableUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateReceivableExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ReceivableDO updateObj = ReceivableConvert.INSTANCE.convert(updateReqVO);
|
||||
receivableMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteReceivable(Long id) {
|
||||
// 校验存在
|
||||
validateReceivableExists(id);
|
||||
// 删除
|
||||
receivableMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateReceivableExists(Long id) {
|
||||
if (receivableMapper.selectById(id) == null) {
|
||||
throw exception(RECEIVABLE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReceivableDO getReceivable(Long id) {
|
||||
return receivableMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReceivableDO> getReceivableList(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return ListUtil.empty();
|
||||
}
|
||||
return receivableMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ReceivableDO> getReceivablePage(ReceivablePageReqVO pageReqVO) {
|
||||
return receivableMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReceivableDO> getReceivableList(ReceivableExportReqVO exportReqVO) {
|
||||
return receivableMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,279 @@
|
||||
package cn.iocoder.yudao.module.crm.service.receivable;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.*;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* {@link ReceivableServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author 赤焰
|
||||
*/
|
||||
@Import(ReceivableServiceImpl.class)
|
||||
public class ReceivableServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private ReceivableServiceImpl receivableService;
|
||||
|
||||
@Resource
|
||||
private ReceivableMapper receivableMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateReceivable_success() {
|
||||
// 准备参数
|
||||
ReceivableCreateReqVO reqVO = randomPojo(ReceivableCreateReqVO.class);
|
||||
|
||||
// 调用
|
||||
Long receivableId = receivableService.createReceivable(reqVO);
|
||||
// 断言
|
||||
assertNotNull(receivableId);
|
||||
// 校验记录的属性是否正确
|
||||
ReceivableDO receivable = receivableMapper.selectById(receivableId);
|
||||
assertPojoEquals(reqVO, receivable);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateReceivable_success() {
|
||||
// mock 数据
|
||||
ReceivableDO dbReceivable = randomPojo(ReceivableDO.class);
|
||||
receivableMapper.insert(dbReceivable);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
ReceivableUpdateReqVO reqVO = randomPojo(ReceivableUpdateReqVO.class, o -> {
|
||||
o.setId(dbReceivable.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
receivableService.updateReceivable(reqVO);
|
||||
// 校验是否更新正确
|
||||
ReceivableDO receivable = receivableMapper.selectById(reqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(reqVO, receivable);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateReceivable_notExists() {
|
||||
// 准备参数
|
||||
ReceivableUpdateReqVO reqVO = randomPojo(ReceivableUpdateReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> receivableService.updateReceivable(reqVO), RECEIVABLE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteReceivable_success() {
|
||||
// mock 数据
|
||||
ReceivableDO dbReceivable = randomPojo(ReceivableDO.class);
|
||||
receivableMapper.insert(dbReceivable);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbReceivable.getId();
|
||||
|
||||
// 调用
|
||||
receivableService.deleteReceivable(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(receivableMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteReceivable_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> receivableService.deleteReceivable(id), RECEIVABLE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetReceivablePage() {
|
||||
// mock 数据
|
||||
ReceivableDO dbReceivable = randomPojo(ReceivableDO.class, o -> { // 等会查询到
|
||||
o.setNo(null);
|
||||
o.setPlanId(null);
|
||||
o.setCustomerId(null);
|
||||
o.setContractId(null);
|
||||
o.setCheckStatus(null);
|
||||
o.setProcessInstanceId(null);
|
||||
o.setReturnTime(null);
|
||||
o.setReturnType(null);
|
||||
o.setPrice(null);
|
||||
o.setOwnerUserId(null);
|
||||
o.setBatchId(null);
|
||||
o.setSort(null);
|
||||
o.setDataScope(null);
|
||||
o.setDataScopeDeptIds(null);
|
||||
o.setStatus(null);
|
||||
o.setRemark(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
receivableMapper.insert(dbReceivable);
|
||||
// 测试 no 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setNo(null)));
|
||||
// 测试 planId 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPlanId(null)));
|
||||
// 测试 customerId 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCustomerId(null)));
|
||||
// 测试 contractId 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setContractId(null)));
|
||||
// 测试 checkStatus 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCheckStatus(null)));
|
||||
// 测试 processInstanceId 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setProcessInstanceId(null)));
|
||||
// 测试 returnTime 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnTime(null)));
|
||||
// 测试 returnType 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnType(null)));
|
||||
// 测试 price 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPrice(null)));
|
||||
// 测试 ownerUserId 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setOwnerUserId(null)));
|
||||
// 测试 batchId 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setBatchId(null)));
|
||||
// 测试 sort 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setSort(null)));
|
||||
// 测试 dataScope 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScope(null)));
|
||||
// 测试 dataScopeDeptIds 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScopeDeptIds(null)));
|
||||
// 测试 status 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setStatus(null)));
|
||||
// 测试 remark 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setRemark(null)));
|
||||
// 测试 createTime 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
ReceivablePageReqVO reqVO = new ReceivablePageReqVO();
|
||||
reqVO.setNo(null);
|
||||
reqVO.setPlanId(null);
|
||||
reqVO.setCustomerId(null);
|
||||
reqVO.setContractId(null);
|
||||
reqVO.setCheckStatus(null);
|
||||
reqVO.setProcessInstanceId(null);
|
||||
reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setReturnType(null);
|
||||
reqVO.setPrice(null);
|
||||
reqVO.setOwnerUserId(null);
|
||||
reqVO.setBatchId(null);
|
||||
reqVO.setSort(null);
|
||||
reqVO.setDataScope(null);
|
||||
reqVO.setDataScopeDeptIds(null);
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setRemark(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
PageResult<ReceivableDO> pageResult = receivableService.getReceivablePage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbReceivable, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetReceivableList() {
|
||||
// mock 数据
|
||||
ReceivableDO dbReceivable = randomPojo(ReceivableDO.class, o -> { // 等会查询到
|
||||
o.setNo(null);
|
||||
o.setPlanId(null);
|
||||
o.setCustomerId(null);
|
||||
o.setContractId(null);
|
||||
o.setCheckStatus(null);
|
||||
o.setProcessInstanceId(null);
|
||||
o.setReturnTime(null);
|
||||
o.setReturnType(null);
|
||||
o.setPrice(null);
|
||||
o.setOwnerUserId(null);
|
||||
o.setBatchId(null);
|
||||
o.setSort(null);
|
||||
o.setDataScope(null);
|
||||
o.setDataScopeDeptIds(null);
|
||||
o.setStatus(null);
|
||||
o.setRemark(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
receivableMapper.insert(dbReceivable);
|
||||
// 测试 no 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setNo(null)));
|
||||
// 测试 planId 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPlanId(null)));
|
||||
// 测试 customerId 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCustomerId(null)));
|
||||
// 测试 contractId 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setContractId(null)));
|
||||
// 测试 checkStatus 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCheckStatus(null)));
|
||||
// 测试 processInstanceId 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setProcessInstanceId(null)));
|
||||
// 测试 returnTime 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnTime(null)));
|
||||
// 测试 returnType 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnType(null)));
|
||||
// 测试 price 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPrice(null)));
|
||||
// 测试 ownerUserId 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setOwnerUserId(null)));
|
||||
// 测试 batchId 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setBatchId(null)));
|
||||
// 测试 sort 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setSort(null)));
|
||||
// 测试 dataScope 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScope(null)));
|
||||
// 测试 dataScopeDeptIds 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScopeDeptIds(null)));
|
||||
// 测试 status 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setStatus(null)));
|
||||
// 测试 remark 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setRemark(null)));
|
||||
// 测试 createTime 不匹配
|
||||
receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
ReceivableExportReqVO reqVO = new ReceivableExportReqVO();
|
||||
reqVO.setNo(null);
|
||||
reqVO.setPlanId(null);
|
||||
reqVO.setCustomerId(null);
|
||||
reqVO.setContractId(null);
|
||||
reqVO.setCheckStatus(null);
|
||||
reqVO.setProcessInstanceId(null);
|
||||
reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
reqVO.setReturnType(null);
|
||||
reqVO.setPrice(null);
|
||||
reqVO.setOwnerUserId(null);
|
||||
reqVO.setBatchId(null);
|
||||
reqVO.setSort(null);
|
||||
reqVO.setDataScope(null);
|
||||
reqVO.setDataScopeDeptIds(null);
|
||||
reqVO.setStatus(null);
|
||||
reqVO.setRemark(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
List<ReceivableDO> list = receivableService.getReceivableList(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, list.size());
|
||||
assertPojoEquals(dbReceivable, list.get(0));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,3 +1,5 @@
|
||||
DELETE FROM "crm_contract";
|
||||
|
||||
DELETE FROM "crm_clue";
|
||||
DELETE FROM "crm_clue";
|
||||
|
||||
DELETE FROM "crm_receivable";
|
||||
|
||||
Loading…
Reference in New Issue