客户结算信息
This commit is contained in:
parent
2462b89750
commit
3932fc9030
@ -285,4 +285,7 @@ public interface ErrorCodeConstants {
|
|||||||
|
|
||||||
// ========== 项目管理相关 1-014-001-001 ==========
|
// ========== 项目管理相关 1-014-001-001 ==========
|
||||||
ErrorCode PROJECT_NOT_EXISTS = new ErrorCode(1_014_001_001, "项目不存在!");
|
ErrorCode PROJECT_NOT_EXISTS = new ErrorCode(1_014_001_001, "项目不存在!");
|
||||||
|
|
||||||
|
// ========== 客户结算信息 1-015-001-001 ==========
|
||||||
|
ErrorCode CUSTOMER_SETTLEMENT_NOT_EXISTS = new ErrorCode(1-015-001-001, "客户结算信息不存在");
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,94 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.controller.admin.customersettlement;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||||
|
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.CustomerSettlementDO;
|
||||||
|
import cn.iocoder.yudao.module.system.service.customersettlement.CustomerSettlementService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 客户结算信息")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/customer-settlement")
|
||||||
|
@Validated
|
||||||
|
public class CustomerSettlementController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CustomerSettlementService customerSettlementService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建客户结算信息")
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:customer-settlement:create')")
|
||||||
|
public CommonResult<Long> createCustomerSettlement(@Valid @RequestBody CustomerSettlementSaveReqVO createReqVO) {
|
||||||
|
return success(customerSettlementService.createCustomerSettlement(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新客户结算信息")
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:customer-settlement:update')")
|
||||||
|
public CommonResult<Boolean> updateCustomerSettlement(@Valid @RequestBody CustomerSettlementSaveReqVO updateReqVO) {
|
||||||
|
customerSettlementService.updateCustomerSettlement(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除客户结算信息")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:customer-settlement:delete')")
|
||||||
|
public CommonResult<Boolean> deleteCustomerSettlement(@RequestParam("id") Long id) {
|
||||||
|
customerSettlementService.deleteCustomerSettlement(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得客户结算信息")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:customer-settlement:query')")
|
||||||
|
public CommonResult<CustomerSettlementRespVO> getCustomerSettlement(@RequestParam("id") Long id) {
|
||||||
|
CustomerSettlementDO customerSettlement = customerSettlementService.getCustomerSettlement(id);
|
||||||
|
return success(BeanUtils.toBean(customerSettlement, CustomerSettlementRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得客户结算信息分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:customer-settlement:query')")
|
||||||
|
public CommonResult<PageResult<CustomerSettlementRespVO>> getCustomerSettlementPage(@Valid CustomerSettlementPageReqVO pageReqVO) {
|
||||||
|
PageResult<CustomerSettlementDO> pageResult = customerSettlementService.getCustomerSettlementPage(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, CustomerSettlementRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出客户结算信息 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:customer-settlement:export')")
|
||||||
|
@OperateLog(type = EXPORT)
|
||||||
|
public void exportCustomerSettlementExcel(@Valid CustomerSettlementPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<CustomerSettlementDO> list = customerSettlementService.getCustomerSettlementPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "客户结算信息.xls", "数据", CustomerSettlementRespVO.class,
|
||||||
|
BeanUtils.toBean(list, CustomerSettlementRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 客户结算信息分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class CustomerSettlementPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "客户id", example = "11477")
|
||||||
|
private Long customerId;
|
||||||
|
|
||||||
|
@Schema(description = "业务类型(1:物流辅助服务、2:设备销售、 3:设备维护、4:系统集成、5:叉车改造)", example = "1")
|
||||||
|
private Integer businessType;
|
||||||
|
|
||||||
|
@Schema(description = "结算月份")
|
||||||
|
private String settlementMonth;
|
||||||
|
|
||||||
|
@Schema(description = "预结算金额")
|
||||||
|
private BigDecimal preSettlementAmount;
|
||||||
|
|
||||||
|
@Schema(description = "扣款金额")
|
||||||
|
private BigDecimal deductionAmount;
|
||||||
|
|
||||||
|
@Schema(description = "结算金额")
|
||||||
|
private BigDecimal settlementAmount;
|
||||||
|
|
||||||
|
@Schema(description = "结算公司id", example = "3044")
|
||||||
|
private Long companyId;
|
||||||
|
|
||||||
|
@Schema(description = "上传附件", example = "https://www.iocoder.cn")
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.alibaba.excel.annotation.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 客户结算信息 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class CustomerSettlementRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "16752")
|
||||||
|
@ExcelProperty("主键ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "客户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "11477")
|
||||||
|
@ExcelProperty("客户id")
|
||||||
|
private Long customerId;
|
||||||
|
|
||||||
|
@Schema(description = "业务类型(1:物流辅助服务、2:设备销售、 3:设备维护、4:系统集成、5:叉车改造)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
@ExcelProperty("业务类型(1:物流辅助服务、2:设备销售、 3:设备维护、4:系统集成、5:叉车改造)")
|
||||||
|
private Integer businessType;
|
||||||
|
|
||||||
|
@Schema(description = "结算月份", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("结算月份")
|
||||||
|
private String settlementMonth;
|
||||||
|
|
||||||
|
@Schema(description = "预结算金额")
|
||||||
|
@ExcelProperty("预结算金额")
|
||||||
|
private BigDecimal preSettlementAmount;
|
||||||
|
|
||||||
|
@Schema(description = "扣款金额")
|
||||||
|
@ExcelProperty("扣款金额")
|
||||||
|
private BigDecimal deductionAmount;
|
||||||
|
|
||||||
|
@Schema(description = "结算金额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("结算金额")
|
||||||
|
private BigDecimal settlementAmount;
|
||||||
|
|
||||||
|
@Schema(description = "结算公司id", requiredMode = Schema.RequiredMode.REQUIRED, example = "3044")
|
||||||
|
@ExcelProperty("结算公司id")
|
||||||
|
private Long companyId;
|
||||||
|
|
||||||
|
@Schema(description = "上传附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
|
||||||
|
@ExcelProperty("上传附件")
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 客户结算信息新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class CustomerSettlementSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "16752")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "客户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "11477")
|
||||||
|
@NotNull(message = "客户id不能为空")
|
||||||
|
private Long customerId;
|
||||||
|
|
||||||
|
@Schema(description = "业务类型(1:物流辅助服务、2:设备销售、 3:设备维护、4:系统集成、5:叉车改造)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
@NotNull(message = "业务类型(1:物流辅助服务、2:设备销售、 3:设备维护、4:系统集成、5:叉车改造)不能为空")
|
||||||
|
private Integer businessType;
|
||||||
|
|
||||||
|
@Schema(description = "结算月份", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "结算月份不能为空")
|
||||||
|
private String settlementMonth;
|
||||||
|
|
||||||
|
@Schema(description = "预结算金额")
|
||||||
|
private BigDecimal preSettlementAmount;
|
||||||
|
|
||||||
|
@Schema(description = "扣款金额")
|
||||||
|
private BigDecimal deductionAmount;
|
||||||
|
|
||||||
|
@Schema(description = "结算金额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "结算金额不能为空")
|
||||||
|
private BigDecimal settlementAmount;
|
||||||
|
|
||||||
|
@Schema(description = "结算公司id", requiredMode = Schema.RequiredMode.REQUIRED, example = "3044")
|
||||||
|
@NotNull(message = "结算公司id不能为空")
|
||||||
|
private Long companyId;
|
||||||
|
|
||||||
|
@Schema(description = "上传附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
|
||||||
|
@NotEmpty(message = "上传附件不能为空")
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.dal.dataobject.customersettlement;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户结算信息 DO
|
||||||
|
*
|
||||||
|
* @author 陈宾顺
|
||||||
|
*/
|
||||||
|
@TableName("system_customer_settlement")
|
||||||
|
@KeySequence("system_customer_settlement_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CustomerSettlementDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 客户id
|
||||||
|
*/
|
||||||
|
private Long customerId;
|
||||||
|
/**
|
||||||
|
* 业务类型(1:物流辅助服务、2:设备销售、 3:设备维护、4:系统集成、5:叉车改造)
|
||||||
|
*/
|
||||||
|
private Integer businessType;
|
||||||
|
/**
|
||||||
|
* 结算月份
|
||||||
|
*/
|
||||||
|
private String settlementMonth;
|
||||||
|
/**
|
||||||
|
* 预结算金额
|
||||||
|
*/
|
||||||
|
private BigDecimal preSettlementAmount;
|
||||||
|
/**
|
||||||
|
* 扣款金额
|
||||||
|
*/
|
||||||
|
private BigDecimal deductionAmount;
|
||||||
|
/**
|
||||||
|
* 结算金额
|
||||||
|
*/
|
||||||
|
private BigDecimal settlementAmount;
|
||||||
|
/**
|
||||||
|
* 结算公司id
|
||||||
|
*/
|
||||||
|
private Long companyId;
|
||||||
|
/**
|
||||||
|
* 上传附件
|
||||||
|
*/
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.dal.mysql.customersettlement;
|
||||||
|
|
||||||
|
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.system.dal.dataobject.customersettlement.CustomerSettlementDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户结算信息 Mapper
|
||||||
|
*
|
||||||
|
* @author 陈宾顺
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface CustomerSettlementMapper extends BaseMapperX<CustomerSettlementDO> {
|
||||||
|
|
||||||
|
default PageResult<CustomerSettlementDO> selectPage(CustomerSettlementPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<CustomerSettlementDO>()
|
||||||
|
.eqIfPresent(CustomerSettlementDO::getCustomerId, reqVO.getCustomerId())
|
||||||
|
.eqIfPresent(CustomerSettlementDO::getBusinessType, reqVO.getBusinessType())
|
||||||
|
.eqIfPresent(CustomerSettlementDO::getSettlementMonth, reqVO.getSettlementMonth())
|
||||||
|
.eqIfPresent(CustomerSettlementDO::getPreSettlementAmount, reqVO.getPreSettlementAmount())
|
||||||
|
.eqIfPresent(CustomerSettlementDO::getDeductionAmount, reqVO.getDeductionAmount())
|
||||||
|
.eqIfPresent(CustomerSettlementDO::getSettlementAmount, reqVO.getSettlementAmount())
|
||||||
|
.eqIfPresent(CustomerSettlementDO::getCompanyId, reqVO.getCompanyId())
|
||||||
|
.eqIfPresent(CustomerSettlementDO::getUrl, reqVO.getUrl())
|
||||||
|
.betweenIfPresent(CustomerSettlementDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(CustomerSettlementDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.service.customersettlement;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.CustomerSettlementDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户结算信息 Service 接口
|
||||||
|
*
|
||||||
|
* @author 陈宾顺
|
||||||
|
*/
|
||||||
|
public interface CustomerSettlementService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建客户结算信息
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createCustomerSettlement(@Valid CustomerSettlementSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新客户结算信息
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateCustomerSettlement(@Valid CustomerSettlementSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除客户结算信息
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteCustomerSettlement(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得客户结算信息
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 客户结算信息
|
||||||
|
*/
|
||||||
|
CustomerSettlementDO getCustomerSettlement(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得客户结算信息分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 客户结算信息分页
|
||||||
|
*/
|
||||||
|
PageResult<CustomerSettlementDO> getCustomerSettlementPage(CustomerSettlementPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.service.customersettlement;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.CustomerSettlementDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.system.dal.mysql.customersettlement.CustomerSettlementMapper;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户结算信息 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 陈宾顺
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class CustomerSettlementServiceImpl implements CustomerSettlementService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CustomerSettlementMapper customerSettlementMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createCustomerSettlement(CustomerSettlementSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
CustomerSettlementDO customerSettlement = BeanUtils.toBean(createReqVO, CustomerSettlementDO.class);
|
||||||
|
customerSettlementMapper.insert(customerSettlement);
|
||||||
|
// 返回
|
||||||
|
return customerSettlement.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateCustomerSettlement(CustomerSettlementSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateCustomerSettlementExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
CustomerSettlementDO updateObj = BeanUtils.toBean(updateReqVO, CustomerSettlementDO.class);
|
||||||
|
customerSettlementMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteCustomerSettlement(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateCustomerSettlementExists(id);
|
||||||
|
// 删除
|
||||||
|
customerSettlementMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateCustomerSettlementExists(Long id) {
|
||||||
|
if (customerSettlementMapper.selectById(id) == null) {
|
||||||
|
throw exception(CUSTOMER_SETTLEMENT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CustomerSettlementDO getCustomerSettlement(Long id) {
|
||||||
|
return customerSettlementMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<CustomerSettlementDO> getCustomerSettlementPage(CustomerSettlementPageReqVO pageReqVO) {
|
||||||
|
return customerSettlementMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,162 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.service.customersettlement;
|
||||||
|
|
||||||
|
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.system.controller.admin.customersettlement.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.CustomerSettlementDO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.mysql.customersettlement.CustomerSettlementMapper;
|
||||||
|
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.system.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 CustomerSettlementServiceImpl} 的单元测试类
|
||||||
|
*
|
||||||
|
* @author 陈宾顺
|
||||||
|
*/
|
||||||
|
@Import(CustomerSettlementServiceImpl.class)
|
||||||
|
public class CustomerSettlementServiceImplTest extends BaseDbUnitTest {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CustomerSettlementServiceImpl customerSettlementService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CustomerSettlementMapper customerSettlementMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateCustomerSettlement_success() {
|
||||||
|
// 准备参数
|
||||||
|
CustomerSettlementSaveReqVO createReqVO = randomPojo(CustomerSettlementSaveReqVO.class).setId(null);
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
Long customerSettlementId = customerSettlementService.createCustomerSettlement(createReqVO);
|
||||||
|
// 断言
|
||||||
|
assertNotNull(customerSettlementId);
|
||||||
|
// 校验记录的属性是否正确
|
||||||
|
CustomerSettlementDO customerSettlement = customerSettlementMapper.selectById(customerSettlementId);
|
||||||
|
assertPojoEquals(createReqVO, customerSettlement, "id");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateCustomerSettlement_success() {
|
||||||
|
// mock 数据
|
||||||
|
CustomerSettlementDO dbCustomerSettlement = randomPojo(CustomerSettlementDO.class);
|
||||||
|
customerSettlementMapper.insert(dbCustomerSettlement);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
CustomerSettlementSaveReqVO updateReqVO = randomPojo(CustomerSettlementSaveReqVO.class, o -> {
|
||||||
|
o.setId(dbCustomerSettlement.getId()); // 设置更新的 ID
|
||||||
|
});
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
customerSettlementService.updateCustomerSettlement(updateReqVO);
|
||||||
|
// 校验是否更新正确
|
||||||
|
CustomerSettlementDO customerSettlement = customerSettlementMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||||
|
assertPojoEquals(updateReqVO, customerSettlement);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateCustomerSettlement_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
CustomerSettlementSaveReqVO updateReqVO = randomPojo(CustomerSettlementSaveReqVO.class);
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> customerSettlementService.updateCustomerSettlement(updateReqVO), CUSTOMER_SETTLEMENT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteCustomerSettlement_success() {
|
||||||
|
// mock 数据
|
||||||
|
CustomerSettlementDO dbCustomerSettlement = randomPojo(CustomerSettlementDO.class);
|
||||||
|
customerSettlementMapper.insert(dbCustomerSettlement);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
Long id = dbCustomerSettlement.getId();
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
customerSettlementService.deleteCustomerSettlement(id);
|
||||||
|
// 校验数据不存在了
|
||||||
|
assertNull(customerSettlementMapper.selectById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteCustomerSettlement_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
Long id = randomLongId();
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> customerSettlementService.deleteCustomerSettlement(id), CUSTOMER_SETTLEMENT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||||
|
public void testGetCustomerSettlementPage() {
|
||||||
|
// mock 数据
|
||||||
|
CustomerSettlementDO dbCustomerSettlement = randomPojo(CustomerSettlementDO.class, o -> { // 等会查询到
|
||||||
|
o.setCustomerId(null);
|
||||||
|
o.setBusinessType(null);
|
||||||
|
o.setSettlementMonth(null);
|
||||||
|
o.setPreSettlementAmount(null);
|
||||||
|
o.setDeductionAmount(null);
|
||||||
|
o.setSettlementAmount(null);
|
||||||
|
o.setCompanyId(null);
|
||||||
|
o.setUrl(null);
|
||||||
|
o.setCreateTime(null);
|
||||||
|
});
|
||||||
|
customerSettlementMapper.insert(dbCustomerSettlement);
|
||||||
|
// 测试 customerId 不匹配
|
||||||
|
customerSettlementMapper.insert(cloneIgnoreId(dbCustomerSettlement, o -> o.setCustomerId(null)));
|
||||||
|
// 测试 businessType 不匹配
|
||||||
|
customerSettlementMapper.insert(cloneIgnoreId(dbCustomerSettlement, o -> o.setBusinessType(null)));
|
||||||
|
// 测试 settlementMonth 不匹配
|
||||||
|
customerSettlementMapper.insert(cloneIgnoreId(dbCustomerSettlement, o -> o.setSettlementMonth(null)));
|
||||||
|
// 测试 preSettlementAmount 不匹配
|
||||||
|
customerSettlementMapper.insert(cloneIgnoreId(dbCustomerSettlement, o -> o.setPreSettlementAmount(null)));
|
||||||
|
// 测试 deductionAmount 不匹配
|
||||||
|
customerSettlementMapper.insert(cloneIgnoreId(dbCustomerSettlement, o -> o.setDeductionAmount(null)));
|
||||||
|
// 测试 settlementAmount 不匹配
|
||||||
|
customerSettlementMapper.insert(cloneIgnoreId(dbCustomerSettlement, o -> o.setSettlementAmount(null)));
|
||||||
|
// 测试 companyId 不匹配
|
||||||
|
customerSettlementMapper.insert(cloneIgnoreId(dbCustomerSettlement, o -> o.setCompanyId(null)));
|
||||||
|
// 测试 url 不匹配
|
||||||
|
customerSettlementMapper.insert(cloneIgnoreId(dbCustomerSettlement, o -> o.setUrl(null)));
|
||||||
|
// 测试 createTime 不匹配
|
||||||
|
customerSettlementMapper.insert(cloneIgnoreId(dbCustomerSettlement, o -> o.setCreateTime(null)));
|
||||||
|
// 准备参数
|
||||||
|
CustomerSettlementPageReqVO reqVO = new CustomerSettlementPageReqVO();
|
||||||
|
reqVO.setCustomerId(null);
|
||||||
|
reqVO.setBusinessType(null);
|
||||||
|
reqVO.setSettlementMonth(null);
|
||||||
|
reqVO.setPreSettlementAmount(null);
|
||||||
|
reqVO.setDeductionAmount(null);
|
||||||
|
reqVO.setSettlementAmount(null);
|
||||||
|
reqVO.setCompanyId(null);
|
||||||
|
reqVO.setUrl(null);
|
||||||
|
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
PageResult<CustomerSettlementDO> pageResult = customerSettlementService.getCustomerSettlementPage(reqVO);
|
||||||
|
// 断言
|
||||||
|
assertEquals(1, pageResult.getTotal());
|
||||||
|
assertEquals(1, pageResult.getList().size());
|
||||||
|
assertPojoEquals(dbCustomerSettlement, pageResult.getList().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user