feat: 增加报销系统业务bs模块。发票代码初始化提交

new
chenqp 1 year ago
parent b1f157fa55
commit d5716bec52

@ -23,6 +23,7 @@
<!-- <module>yudao-module-mall</module>-->
<!-- 示例项目 -->
<!-- <module>yudao-example</module>-->
<module>yudao-module-bs</module>
</modules>
<name>${project.artifactId}</name>

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao</artifactId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<modules>
<module>yudao-module-bs-api</module>
<module>yudao-module-bs-biz</module>
</modules>
<artifactId>yudao-module-bs</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>
报销系统业务模块
</description>
</project>

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-bs</artifactId>
<version>${revision}</version>
</parent>
<artifactId>yudao-module-bs-api</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>
bs 模块 API暴露给其它模块调用
</description>
<dependencies>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-common</artifactId>
</dependency>
<!-- 参数校验 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.bs.enums;
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
/**
*
*
* 使 1-009-000-000
*/
public interface ErrorCodeConstants {
ErrorCode INVOICE_NOT_EXISTS = new ErrorCode(200100, "我的发票不存在");
}

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-bs</artifactId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>yudao-module-bs-biz</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>
product 模块,主要实现商品相关功能
例如品牌、商品分类、spu、sku等功能。
</description>
<dependencies>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-bs-api</artifactId>
<version>${revision}</version>
</dependency>
<!-- 业务组件 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
</dependency>
<!-- Web 相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-security</artifactId>
</dependency>
<!-- DB 相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-mybatis</artifactId>
</dependency>
<!-- Test 测试相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-test</artifactId>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-excel</artifactId>
</dependency>
</dependencies>
</project>

@ -0,0 +1,99 @@
package cn.iocoder.yudao.module.bs.controller.admin.invoice;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.bs.controller.admin.invoice.vo.*;
import cn.iocoder.yudao.module.bs.convert.invoice.InvoiceConvert;
import cn.iocoder.yudao.module.bs.dal.dataobject.invoice.InvoiceDO;
import cn.iocoder.yudao.module.bs.service.invoice.InvoiceService;
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 static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
@Tag(name = "管理后台 - 我的发票")
@RestController
@RequestMapping("/bs/invoice")
@Validated
public class InvoiceController {
@Resource
private InvoiceService invoiceService;
@PostMapping("/create")
@Operation(summary = "创建我的发票")
@PreAuthorize("@ss.hasPermission('bs:invoice:create')")
public CommonResult<Long> createInvoice(@Valid @RequestBody InvoiceCreateReqVO createReqVO) {
return success(invoiceService.createInvoice(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新我的发票")
@PreAuthorize("@ss.hasPermission('bs:invoice:update')")
public CommonResult<Boolean> updateInvoice(@Valid @RequestBody InvoiceUpdateReqVO updateReqVO) {
invoiceService.updateInvoice(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除我的发票")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('bs:invoice:delete')")
public CommonResult<Boolean> deleteInvoice(@RequestParam("id") Long id) {
invoiceService.deleteInvoice(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得我的发票")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('bs:invoice:query')")
public CommonResult<InvoiceRespVO> getInvoice(@RequestParam("id") Long id) {
InvoiceDO invoice = invoiceService.getInvoice(id);
return success(InvoiceConvert.INSTANCE.convert(invoice));
}
@GetMapping("/list")
@Operation(summary = "获得我的发票列表")
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
@PreAuthorize("@ss.hasPermission('bs:invoice:query')")
public CommonResult<List<InvoiceRespVO>> getInvoiceList(@RequestParam("ids") Collection<Long> ids) {
List<InvoiceDO> list = invoiceService.getInvoiceList(ids);
return success(InvoiceConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@Operation(summary = "获得我的发票分页")
@PreAuthorize("@ss.hasPermission('bs:invoice:query')")
public CommonResult<PageResult<InvoiceRespVO>> getInvoicePage(@Valid InvoicePageReqVO pageVO) {
PageResult<InvoiceDO> pageResult = invoiceService.getInvoicePage(pageVO);
return success(InvoiceConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@Operation(summary = "导出我的发票 Excel")
@PreAuthorize("@ss.hasPermission('bs:invoice:export')")
@OperateLog(type = EXPORT)
public void exportInvoiceExcel(@Valid InvoiceExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<InvoiceDO> list = invoiceService.getInvoiceList(exportReqVO);
// 导出 Excel
List<InvoiceExcelVO> datas = InvoiceConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "我的发票.xls", "数据", InvoiceExcelVO.class, datas);
}
}

@ -0,0 +1,58 @@
package cn.iocoder.yudao.module.bs.controller.admin.invoice.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* Base VO VO 使
* VO Swagger
*/
@Data
public class InvoiceBaseVO {
@Schema(description = "发票类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "发票类型不能为空")
private String invoiceType;
@Schema(description = "发票代码", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "发票代码不能为空")
private String invoiceCode;
@Schema(description = " 发票号码", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = " 发票号码不能为空")
private String invoiceNum;
@Schema(description = "开票日期", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "开票日期不能为空")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime invoiceDate;
@Schema(description = "销售方")
private String seller;
@Schema(description = "税额")
private BigDecimal taxAmount;
@Schema(description = "不含税金额")
private BigDecimal excludingTaxAmount;
@Schema(description = "价税合计")
private BigDecimal totalAmount;
@Schema(description = "部门ID", example = "30681")
private Long deptId;
@Schema(description = "部门名称", example = "赵六")
private String deptName;
@Schema(description = "备注", example = "随便")
private String remark;
}

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.bs.controller.admin.invoice.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@Schema(description = "管理后台 - 我的发票创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class InvoiceCreateReqVO extends InvoiceBaseVO {
}

@ -0,0 +1,68 @@
package cn.iocoder.yudao.module.bs.controller.admin.invoice.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* Excel VO
*
* @author chenqp
*/
@Data
public class InvoiceExcelVO {
@ExcelProperty("id")
private Long id;
@ExcelProperty("附件")
private String files;
@ExcelProperty("创建者")
private String createBy;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@ExcelProperty("更新者")
private String updateBy;
@ExcelProperty("更新时间")
private LocalDateTime updateTime;
@ExcelProperty("发票类型")
private String invoiceType;
@ExcelProperty("发票代码")
private String invoiceCode;
@ExcelProperty(" 发票号码")
private String invoiceNum;
@ExcelProperty("开票日期")
private LocalDateTime invoiceDate;
@ExcelProperty("销售方")
private String seller;
@ExcelProperty("税额")
private BigDecimal taxAmount;
@ExcelProperty("不含税金额")
private BigDecimal excludingTaxAmount;
@ExcelProperty("价税合计")
private BigDecimal totalAmount;
@ExcelProperty("部门ID")
private Long deptId;
@ExcelProperty("部门名称")
private String deptName;
@ExcelProperty("备注")
private String remark;
}

@ -0,0 +1,63 @@
package cn.iocoder.yudao.module.bs.controller.admin.invoice.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 我的发票 Excel 导出 Request VO参数和 InvoicePageReqVO 是一致的")
@Data
public class InvoiceExportReqVO {
@Schema(description = "附件")
private String files;
@Schema(description = "创建者")
private String createBy;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "更新者")
private String updateBy;
@Schema(description = "发票类型", example = "1")
private String invoiceType;
@Schema(description = "发票代码")
private String invoiceCode;
@Schema(description = " 发票号码")
private String invoiceNum;
@Schema(description = "开票日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] invoiceDate;
@Schema(description = "销售方")
private String seller;
@Schema(description = "税额")
private BigDecimal taxAmount;
@Schema(description = "不含税金额")
private BigDecimal excludingTaxAmount;
@Schema(description = "价税合计")
private BigDecimal totalAmount;
@Schema(description = "部门ID", example = "30681")
private Long deptId;
@Schema(description = "部门名称", example = "赵六")
private String deptName;
@Schema(description = "备注", example = "随便")
private String remark;
}

@ -0,0 +1,68 @@
package cn.iocoder.yudao.module.bs.controller.admin.invoice.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
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 InvoicePageReqVO extends PageParam {
@Schema(description = "附件")
private String files;
@Schema(description = "创建者")
private String createBy;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "更新者")
private String updateBy;
@Schema(description = "发票类型", example = "1")
private String invoiceType;
@Schema(description = "发票代码")
private String invoiceCode;
@Schema(description = " 发票号码")
private String invoiceNum;
@Schema(description = "开票日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] invoiceDate;
@Schema(description = "销售方")
private String seller;
@Schema(description = "税额")
private BigDecimal taxAmount;
@Schema(description = "不含税金额")
private BigDecimal excludingTaxAmount;
@Schema(description = "价税合计")
private BigDecimal totalAmount;
@Schema(description = "部门ID", example = "30681")
private Long deptId;
@Schema(description = "部门名称", example = "赵六")
private String deptName;
@Schema(description = "备注", example = "随便")
private String remark;
}

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.bs.controller.admin.invoice.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 我的发票 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class InvoiceRespVO extends InvoiceBaseVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "32435")
private Long id;
@Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED)
private String files;
@Schema(description = "创建者")
private String createBy;
@Schema(description = "创建时间")
private LocalDateTime createTime;
@Schema(description = "更新者")
private String updateBy;
@Schema(description = "更新时间")
private LocalDateTime updateTime;
}

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.bs.controller.admin.invoice.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
@Schema(description = "管理后台 - 我的发票更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class InvoiceUpdateReqVO extends InvoiceBaseVO {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "32435")
@NotNull(message = "id不能为空")
private Long id;
@Schema(description = "附件", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "附件不能为空")
private String files;
}

@ -0,0 +1,36 @@
package cn.iocoder.yudao.module.bs.convert.invoice;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.bs.controller.admin.invoice.vo.InvoiceCreateReqVO;
import cn.iocoder.yudao.module.bs.controller.admin.invoice.vo.InvoiceExcelVO;
import cn.iocoder.yudao.module.bs.controller.admin.invoice.vo.InvoiceRespVO;
import cn.iocoder.yudao.module.bs.controller.admin.invoice.vo.InvoiceUpdateReqVO;
import cn.iocoder.yudao.module.bs.dal.dataobject.invoice.InvoiceDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* Convert
*
* @author chenqp
*/
@Mapper
public interface InvoiceConvert {
InvoiceConvert INSTANCE = Mappers.getMapper(InvoiceConvert.class);
InvoiceDO convert(InvoiceCreateReqVO bean);
InvoiceDO convert(InvoiceUpdateReqVO bean);
InvoiceRespVO convert(InvoiceDO bean);
List<InvoiceRespVO> convertList(List<InvoiceDO> list);
PageResult<InvoiceRespVO> convertPage(PageResult<InvoiceDO> page);
List<InvoiceExcelVO> convertList02(List<InvoiceDO> list);
}

@ -0,0 +1,90 @@
package cn.iocoder.yudao.module.bs.dal.dataobject.invoice;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.*;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* DO
*
* @author chenqp
*/
@TableName("bs_invoice")
@KeySequence("bs_invoice_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class InvoiceDO extends BaseDO {
/**
* id
*/
@TableId
private Long id;
/**
*
*/
private String files;
/**
*
*/
private String createBy;
/**
*
*/
private String updateBy;
/**
*
*/
private String invoiceType;
/**
*
*/
private String invoiceCode;
/**
*
*/
private String invoiceNum;
/**
*
*/
private LocalDateTime invoiceDate;
/**
*
*/
private String seller;
/**
*
*/
private BigDecimal taxAmount;
/**
*
*/
private BigDecimal excludingTaxAmount;
/**
*
*/
private BigDecimal totalAmount;
/**
* ID
*/
private Long deptId;
/**
*
*/
private String deptName;
/**
*
*/
private String remark;
@TableField(exist = false)
private Boolean deleted;
}

@ -0,0 +1,61 @@
package cn.iocoder.yudao.module.bs.dal.mysql.invoice;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.bs.controller.admin.invoice.vo.InvoiceExportReqVO;
import cn.iocoder.yudao.module.bs.controller.admin.invoice.vo.InvoicePageReqVO;
import cn.iocoder.yudao.module.bs.dal.dataobject.invoice.InvoiceDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* Mapper
*
* @author chenqp
*/
@Mapper
public interface InvoiceMapper extends BaseMapperX<InvoiceDO> {
default PageResult<InvoiceDO> selectPage(InvoicePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<InvoiceDO>()
.eqIfPresent(InvoiceDO::getFiles, reqVO.getFiles())
.eqIfPresent(InvoiceDO::getCreateBy, reqVO.getCreateBy())
.betweenIfPresent(InvoiceDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(InvoiceDO::getUpdateBy, reqVO.getUpdateBy())
.eqIfPresent(InvoiceDO::getInvoiceType, reqVO.getInvoiceType())
.eqIfPresent(InvoiceDO::getInvoiceCode, reqVO.getInvoiceCode())
.eqIfPresent(InvoiceDO::getInvoiceNum, reqVO.getInvoiceNum())
.betweenIfPresent(InvoiceDO::getInvoiceDate, reqVO.getInvoiceDate())
.eqIfPresent(InvoiceDO::getSeller, reqVO.getSeller())
.eqIfPresent(InvoiceDO::getTaxAmount, reqVO.getTaxAmount())
.eqIfPresent(InvoiceDO::getExcludingTaxAmount, reqVO.getExcludingTaxAmount())
.eqIfPresent(InvoiceDO::getTotalAmount, reqVO.getTotalAmount())
.eqIfPresent(InvoiceDO::getDeptId, reqVO.getDeptId())
.likeIfPresent(InvoiceDO::getDeptName, reqVO.getDeptName())
.eqIfPresent(InvoiceDO::getRemark, reqVO.getRemark())
.orderByDesc(InvoiceDO::getId));
}
default List<InvoiceDO> selectList(InvoiceExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<InvoiceDO>()
.eqIfPresent(InvoiceDO::getFiles, reqVO.getFiles())
.eqIfPresent(InvoiceDO::getCreateBy, reqVO.getCreateBy())
.betweenIfPresent(InvoiceDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(InvoiceDO::getUpdateBy, reqVO.getUpdateBy())
.eqIfPresent(InvoiceDO::getInvoiceType, reqVO.getInvoiceType())
.eqIfPresent(InvoiceDO::getInvoiceCode, reqVO.getInvoiceCode())
.eqIfPresent(InvoiceDO::getInvoiceNum, reqVO.getInvoiceNum())
.betweenIfPresent(InvoiceDO::getInvoiceDate, reqVO.getInvoiceDate())
.eqIfPresent(InvoiceDO::getSeller, reqVO.getSeller())
.eqIfPresent(InvoiceDO::getTaxAmount, reqVO.getTaxAmount())
.eqIfPresent(InvoiceDO::getExcludingTaxAmount, reqVO.getExcludingTaxAmount())
.eqIfPresent(InvoiceDO::getTotalAmount, reqVO.getTotalAmount())
.eqIfPresent(InvoiceDO::getDeptId, reqVO.getDeptId())
.likeIfPresent(InvoiceDO::getDeptName, reqVO.getDeptName())
.eqIfPresent(InvoiceDO::getRemark, reqVO.getRemark())
.orderByDesc(InvoiceDO::getId));
}
}

@ -0,0 +1,75 @@
package cn.iocoder.yudao.module.bs.service.invoice;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.bs.controller.admin.invoice.vo.InvoiceCreateReqVO;
import cn.iocoder.yudao.module.bs.controller.admin.invoice.vo.InvoiceExportReqVO;
import cn.iocoder.yudao.module.bs.controller.admin.invoice.vo.InvoicePageReqVO;
import cn.iocoder.yudao.module.bs.controller.admin.invoice.vo.InvoiceUpdateReqVO;
import cn.iocoder.yudao.module.bs.dal.dataobject.invoice.InvoiceDO;
import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
/**
* Service
*
* @author chenqp
*/
public interface InvoiceService {
/**
*
*
* @param createReqVO
* @return
*/
Long createInvoice(@Valid InvoiceCreateReqVO createReqVO);
/**
*
*
* @param updateReqVO
*/
void updateInvoice(@Valid InvoiceUpdateReqVO updateReqVO);
/**
*
*
* @param id
*/
void deleteInvoice(Long id);
/**
*
*
* @param id
* @return
*/
InvoiceDO getInvoice(Long id);
/**
*
*
* @param ids
* @return
*/
List<InvoiceDO> getInvoiceList(Collection<Long> ids);
/**
*
*
* @param pageReqVO
* @return
*/
PageResult<InvoiceDO> getInvoicePage(InvoicePageReqVO pageReqVO);
/**
* , Excel
*
* @param exportReqVO
* @return
*/
List<InvoiceDO> getInvoiceList(InvoiceExportReqVO exportReqVO);
}

@ -0,0 +1,84 @@
package cn.iocoder.yudao.module.bs.service.invoice;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.bs.controller.admin.invoice.vo.InvoiceCreateReqVO;
import cn.iocoder.yudao.module.bs.controller.admin.invoice.vo.InvoiceExportReqVO;
import cn.iocoder.yudao.module.bs.controller.admin.invoice.vo.InvoicePageReqVO;
import cn.iocoder.yudao.module.bs.controller.admin.invoice.vo.InvoiceUpdateReqVO;
import cn.iocoder.yudao.module.bs.convert.invoice.InvoiceConvert;
import cn.iocoder.yudao.module.bs.dal.dataobject.invoice.InvoiceDO;
import cn.iocoder.yudao.module.bs.dal.mysql.invoice.InvoiceMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.bs.enums.ErrorCodeConstants.INVOICE_NOT_EXISTS;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
/**
* Service
*
* @author chenqp
*/
@Service
@Validated
public class InvoiceServiceImpl implements InvoiceService {
@Resource
private InvoiceMapper invoiceMapper;
@Override
public Long createInvoice(InvoiceCreateReqVO createReqVO) {
// 插入
InvoiceDO invoice = InvoiceConvert.INSTANCE.convert(createReqVO);
invoiceMapper.insert(invoice);
// 返回
return invoice.getId();
}
@Override
public void updateInvoice(InvoiceUpdateReqVO updateReqVO) {
// 校验存在
validateInvoiceExists(updateReqVO.getId());
// 更新
InvoiceDO updateObj = InvoiceConvert.INSTANCE.convert(updateReqVO);
invoiceMapper.updateById(updateObj);
}
@Override
public void deleteInvoice(Long id) {
// 校验存在
validateInvoiceExists(id);
// 删除
invoiceMapper.deleteById(id);
}
private void validateInvoiceExists(Long id) {
if (invoiceMapper.selectById(id) == null) {
throw exception(INVOICE_NOT_EXISTS);
}
}
@Override
public InvoiceDO getInvoice(Long id) {
return invoiceMapper.selectById(id);
}
@Override
public List<InvoiceDO> getInvoiceList(Collection<Long> ids) {
return invoiceMapper.selectBatchIds(ids);
}
@Override
public PageResult<InvoiceDO> getInvoicePage(InvoicePageReqVO pageReqVO) {
return invoiceMapper.selectPage(pageReqVO);
}
@Override
public List<InvoiceDO> getInvoiceList(InvoiceExportReqVO exportReqVO) {
return invoiceMapper.selectList(exportReqVO);
}
}

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.bs.web.config;
import cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* system web Configuration
*
* @author
*/
@Configuration(proxyBeanMethods = false)
public class BsConfiguration {
/**
* system API
*/
@Bean
public GroupedOpenApi bsGroupedOpenApi() {
return YudaoSwaggerAutoConfiguration.buildGroupedOpenApi("bs");
}
}

@ -0,0 +1,4 @@
/**
* system web
*/
package cn.iocoder.yudao.module.bs.web;

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.bs.dal.mysql.invoice.InvoiceMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -0,0 +1,263 @@
package cn.iocoder.yudao.module.bs.service.invoice;
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.bs.controller.admin.invoice.vo.*;
import cn.iocoder.yudao.module.bs.dal.dataobject.invoice.InvoiceDO;
import cn.iocoder.yudao.module.bs.dal.mysql.invoice.InvoiceMapper;
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.bs.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 InvoiceServiceImpl}
*
* @author chenqp
*/
@Import(InvoiceServiceImpl.class)
public class InvoiceServiceImplTest extends BaseDbUnitTest {
@Resource
private InvoiceServiceImpl invoiceService;
@Resource
private InvoiceMapper invoiceMapper;
@Test
public void testCreateInvoice_success() {
// 准备参数
InvoiceCreateReqVO reqVO = randomPojo(InvoiceCreateReqVO.class);
// 调用
Long invoiceId = invoiceService.createInvoice(reqVO);
// 断言
assertNotNull(invoiceId);
// 校验记录的属性是否正确
InvoiceDO invoice = invoiceMapper.selectById(invoiceId);
assertPojoEquals(reqVO, invoice);
}
@Test
public void testUpdateInvoice_success() {
// mock 数据
InvoiceDO dbInvoice = randomPojo(InvoiceDO.class);
invoiceMapper.insert(dbInvoice);// @Sql: 先插入出一条存在的数据
// 准备参数
InvoiceUpdateReqVO reqVO = randomPojo(InvoiceUpdateReqVO.class, o -> {
o.setId(dbInvoice.getId()); // 设置更新的 ID
});
// 调用
invoiceService.updateInvoice(reqVO);
// 校验是否更新正确
InvoiceDO invoice = invoiceMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, invoice);
}
@Test
public void testUpdateInvoice_notExists() {
// 准备参数
InvoiceUpdateReqVO reqVO = randomPojo(InvoiceUpdateReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> invoiceService.updateInvoice(reqVO), INVOICE_NOT_EXISTS);
}
@Test
public void testDeleteInvoice_success() {
// mock 数据
InvoiceDO dbInvoice = randomPojo(InvoiceDO.class);
invoiceMapper.insert(dbInvoice);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbInvoice.getId();
// 调用
invoiceService.deleteInvoice(id);
// 校验数据不存在了
assertNull(invoiceMapper.selectById(id));
}
@Test
public void testDeleteInvoice_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> invoiceService.deleteInvoice(id), INVOICE_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetInvoicePage() {
// mock 数据
InvoiceDO dbInvoice = randomPojo(InvoiceDO.class, o -> { // 等会查询到
o.setFiles(null);
o.setCreateBy(null);
o.setCreateTime(null);
o.setUpdateBy(null);
o.setInvoiceType(null);
o.setInvoiceCode(null);
o.setInvoiceNum(null);
o.setInvoiceDate(null);
o.setSeller(null);
o.setTaxAmount(null);
o.setExcludingTaxAmount(null);
o.setTotalAmount(null);
o.setDeptId(null);
o.setDeptName(null);
o.setRemark(null);
});
invoiceMapper.insert(dbInvoice);
// 测试 files 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setFiles(null)));
// 测试 createBy 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setCreateBy(null)));
// 测试 createTime 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setCreateTime(null)));
// 测试 updateBy 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setUpdateBy(null)));
// 测试 invoiceType 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceType(null)));
// 测试 invoiceCode 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceCode(null)));
// 测试 invoiceNum 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceNum(null)));
// 测试 invoiceDate 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceDate(null)));
// 测试 seller 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setSeller(null)));
// 测试 taxAmount 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setTaxAmount(null)));
// 测试 excludingTaxAmount 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setExcludingTaxAmount(null)));
// 测试 totalAmount 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setTotalAmount(null)));
// 测试 deptId 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setDeptId(null)));
// 测试 deptName 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setDeptName(null)));
// 测试 remark 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setRemark(null)));
// 准备参数
InvoicePageReqVO reqVO = new InvoicePageReqVO();
reqVO.setFiles(null);
reqVO.setCreateBy(null);
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setUpdateBy(null);
reqVO.setInvoiceType(null);
reqVO.setInvoiceCode(null);
reqVO.setInvoiceNum(null);
reqVO.setInvoiceDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setSeller(null);
reqVO.setTaxAmount(null);
reqVO.setExcludingTaxAmount(null);
reqVO.setTotalAmount(null);
reqVO.setDeptId(null);
reqVO.setDeptName(null);
reqVO.setRemark(null);
// 调用
PageResult<InvoiceDO> pageResult = invoiceService.getInvoicePage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbInvoice, pageResult.getList().get(0));
}
@Test
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
public void testGetInvoiceList() {
// mock 数据
InvoiceDO dbInvoice = randomPojo(InvoiceDO.class, o -> { // 等会查询到
o.setFiles(null);
o.setCreateBy(null);
o.setCreateTime(null);
o.setUpdateBy(null);
o.setInvoiceType(null);
o.setInvoiceCode(null);
o.setInvoiceNum(null);
o.setInvoiceDate(null);
o.setSeller(null);
o.setTaxAmount(null);
o.setExcludingTaxAmount(null);
o.setTotalAmount(null);
o.setDeptId(null);
o.setDeptName(null);
o.setRemark(null);
});
invoiceMapper.insert(dbInvoice);
// 测试 files 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setFiles(null)));
// 测试 createBy 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setCreateBy(null)));
// 测试 createTime 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setCreateTime(null)));
// 测试 updateBy 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setUpdateBy(null)));
// 测试 invoiceType 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceType(null)));
// 测试 invoiceCode 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceCode(null)));
// 测试 invoiceNum 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceNum(null)));
// 测试 invoiceDate 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setInvoiceDate(null)));
// 测试 seller 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setSeller(null)));
// 测试 taxAmount 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setTaxAmount(null)));
// 测试 excludingTaxAmount 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setExcludingTaxAmount(null)));
// 测试 totalAmount 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setTotalAmount(null)));
// 测试 deptId 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setDeptId(null)));
// 测试 deptName 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setDeptName(null)));
// 测试 remark 不匹配
invoiceMapper.insert(cloneIgnoreId(dbInvoice, o -> o.setRemark(null)));
// 准备参数
InvoiceExportReqVO reqVO = new InvoiceExportReqVO();
reqVO.setFiles(null);
reqVO.setCreateBy(null);
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setUpdateBy(null);
reqVO.setInvoiceType(null);
reqVO.setInvoiceCode(null);
reqVO.setInvoiceNum(null);
reqVO.setInvoiceDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
reqVO.setSeller(null);
reqVO.setTaxAmount(null);
reqVO.setExcludingTaxAmount(null);
reqVO.setTotalAmount(null);
reqVO.setDeptId(null);
reqVO.setDeptName(null);
reqVO.setRemark(null);
// 调用
List<InvoiceDO> list = invoiceService.getInvoiceList(reqVO);
// 断言
assertEquals(1, list.size());
assertPojoEquals(dbInvoice, list.get(0));
}
}

@ -92,7 +92,7 @@ resilience4j:
yudao:
security:
token-header: Authorization
token-secret: abcdefghijklmnopqrstuvwxyz
token-secret: sabszefopxqrstgjyuzyupz
token-timeout: 1d
session-timeout: 30m
mock-enable: true

@ -21,6 +21,12 @@
<url>https://github.com/YunaiV/ruoyi-vue-pro</url>
<dependencies>
<!-- 报销系统业务 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-bs-biz</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-member-biz</artifactId>

@ -134,6 +134,7 @@ yudao:
- cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants
- cn.iocoder.yudao.module.system.enums.ErrorCodeConstants
- cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants
- cn.iocoder.yudao.module.mp.bs.ErrorCodeConstants
tenant: # 多租户相关配置项
enable: true
ignore-urls:

Loading…
Cancel
Save