完善首付款管理模块

This commit is contained in:
2026-08-27 23:51:55 +08:00
parent cce9ac0f3d
commit 1be1a18ea8
15 changed files with 611 additions and 69 deletions
@@ -0,0 +1,90 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments from this software for such purposes. Copyright of this software remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.pojo.entity.InvoiceItem;
import org.springblade.system.pojo.vo.InvoiceItemVO;
import org.springblade.system.service.IInvoiceItemService;
import org.springblade.system.wrapper.InvoiceItemWrapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 开票项目控制器
*
* @author Chill
*/
@NonDS
@RestController
@AllArgsConstructor
@PreAuth(menu = "invoice_item")
@RequestMapping("/invoice-item")
@Tag(name = "开票项目", description = "开票项目")
public class InvoiceItemController extends BladeController {
private final IInvoiceItemService invoiceItemService;
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入invoiceItem")
public R<InvoiceItemVO> detail(InvoiceItem invoiceItem) {
InvoiceItem detail = invoiceItemService.getOne(Condition.getQueryWrapper(invoiceItem));
return R.data(InvoiceItemWrapper.build().entityVO(detail));
}
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@Operation(summary = "分页", description = "传入invoiceItem")
public R<IPage<InvoiceItemVO>> list(InvoiceItemVO invoiceItem, Query query) {
return R.data(invoiceItemService.selectInvoiceItemPage(Condition.getPage(query), invoiceItem));
}
@PostMapping("/submit")
@ApiOperationSupport(order = 3)
@Operation(summary = "新增或修改", description = "传入invoiceItem")
public R submit(@Valid @RequestBody InvoiceItem invoiceItem) {
return R.status(invoiceItemService.submit(invoiceItem));
}
@PostMapping("/remove")
@ApiOperationSupport(order = 4)
@Operation(summary = "逻辑删除", description = "传入ids")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(invoiceItemService.deleteLogic(Func.toLongList(ids)));
}
}
@@ -0,0 +1,39 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments from this software for such purposes. Copyright of this software remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.system.pojo.entity.InvoiceItem;
import org.springblade.system.pojo.vo.InvoiceItemVO;
import java.util.List;
/**
* 开票项目 Mapper 接口
*
* @author Chill
*/
public interface InvoiceItemMapper extends BaseMapper<InvoiceItem> {
List<InvoiceItemVO> selectInvoiceItemPage(IPage<InvoiceItemVO> page,
@Param("invoiceItem") InvoiceItemVO invoiceItem);
}
@@ -0,0 +1,40 @@
<?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="org.springblade.system.mapper.InvoiceItemMapper">
<resultMap id="invoiceItemResultMap" type="org.springblade.system.pojo.vo.InvoiceItemVO">
<result column="id" property="id"/>
<result column="create_user" property="createUser"/>
<result column="create_dept" property="createDept"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="create_dept_name" property="createDeptName"/>
<result column="update_user_name" property="updateUserName"/>
<result column="short_name" property="shortName"/>
<result column="tax_classification_code" property="taxClassificationCode"/>
<result column="category_name" property="categoryName"/>
<result column="default_tax_rate" property="defaultTaxRate"/>
</resultMap>
<select id="selectInvoiceItemPage" resultMap="invoiceItemResultMap">
SELECT bii.*, bd.dept_name AS create_dept_name, bu.real_name AS update_user_name
FROM blade_invoice_item bii
LEFT JOIN blade_dept bd ON bd.id = bii.create_dept
LEFT JOIN blade_user bu ON bu.id = bii.update_user
WHERE bii.is_deleted = 0
<if test="invoiceItem.shortName != null and invoiceItem.shortName != ''">
<bind name="shortNameLike" value="'%' + invoiceItem.shortName + '%'"/>
AND bii.short_name LIKE #{shortNameLike}
</if>
<if test="invoiceItem.categoryName != null and invoiceItem.categoryName != ''">
<bind name="categoryNameLike" value="'%' + invoiceItem.categoryName + '%'"/>
AND bii.category_name LIKE #{categoryNameLike}
</if>
<if test="invoiceItem.taxClassificationCode != null and invoiceItem.taxClassificationCode != ''">
<bind name="taxCodeLike" value="'%' + invoiceItem.taxClassificationCode + '%'"/>
AND bii.tax_classification_code LIKE #{taxCodeLike}
</if>
ORDER BY bii.create_time DESC
</select>
</mapper>
@@ -0,0 +1,37 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments from this software for such purposes. Copyright of this software remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.system.pojo.entity.InvoiceItem;
import org.springblade.system.pojo.vo.InvoiceItemVO;
/**
* 开票项目服务类
*
* @author Chill
*/
public interface IInvoiceItemService extends BaseService<InvoiceItem> {
IPage<InvoiceItemVO> selectInvoiceItemPage(IPage<InvoiceItemVO> page, InvoiceItemVO invoiceItem);
boolean submit(InvoiceItem invoiceItem);
}
@@ -0,0 +1,92 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments from this software for such purposes. Copyright of this software remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.mapper.InvoiceItemMapper;
import org.springblade.system.pojo.entity.InvoiceItem;
import org.springblade.system.pojo.vo.InvoiceItemVO;
import org.springblade.system.service.IInvoiceItemService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
/**
* 开票项目服务实现类
*
* @author Chill
*/
@Service
public class InvoiceItemServiceImpl extends BaseServiceImpl<InvoiceItemMapper, InvoiceItem>
implements IInvoiceItemService {
private static final int SHORT_NAME_MAX_LENGTH = 100;
private static final int TAX_CODE_MAX_LENGTH = 30;
private static final int CATEGORY_NAME_MAX_LENGTH = 200;
@Override
public IPage<InvoiceItemVO> selectInvoiceItemPage(IPage<InvoiceItemVO> page, InvoiceItemVO invoiceItem) {
return page.setRecords(baseMapper.selectInvoiceItemPage(page, invoiceItem));
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean submit(InvoiceItem invoiceItem) {
prepare(invoiceItem);
validate(invoiceItem);
return saveOrUpdate(invoiceItem);
}
private void prepare(InvoiceItem invoiceItem) {
invoiceItem.setShortName(trim(invoiceItem.getShortName()));
invoiceItem.setTaxClassificationCode(trim(invoiceItem.getTaxClassificationCode()));
invoiceItem.setCategoryName(trim(invoiceItem.getCategoryName()));
if (Func.isEmpty(invoiceItem.getStatus())) {
invoiceItem.setStatus(1);
}
}
private void validate(InvoiceItem invoiceItem) {
if (Func.isEmpty(invoiceItem.getShortName())) throw new ServiceException("货物或服务简称不能为空");
if (invoiceItem.getShortName().length() > SHORT_NAME_MAX_LENGTH) throw new ServiceException("货物或服务简称不能超过100字");
if (Func.isEmpty(invoiceItem.getTaxClassificationCode())) throw new ServiceException("税收分类编码不能为空");
if (invoiceItem.getTaxClassificationCode().length() > TAX_CODE_MAX_LENGTH) throw new ServiceException("税收分类编码不能超过30字");
if (Func.isEmpty(invoiceItem.getCategoryName())) throw new ServiceException("商品和服务分类名称不能为空");
if (invoiceItem.getCategoryName().length() > CATEGORY_NAME_MAX_LENGTH) throw new ServiceException("商品和服务分类名称不能超过200字");
BigDecimal taxRate = invoiceItem.getDefaultTaxRate();
if (taxRate == null) throw new ServiceException("默认税率不能为空");
if (taxRate.compareTo(BigDecimal.ZERO) < 0 || taxRate.compareTo(new BigDecimal("100")) > 0) throw new ServiceException("默认税率必须在0到100之间");
boolean duplicate = count(Wrappers.<InvoiceItem>lambdaQuery()
.eq(InvoiceItem::getTaxClassificationCode, invoiceItem.getTaxClassificationCode())
.eq(InvoiceItem::getShortName, invoiceItem.getShortName())
.eq(InvoiceItem::getIsDeleted, 0)
.ne(Func.isNotEmpty(invoiceItem.getId()), InvoiceItem::getId, invoiceItem.getId())) > 0;
if (duplicate) throw new ServiceException("该开票项目已存在");
}
private String trim(String value) {
return value == null ? "" : value.trim();
}
}
@@ -0,0 +1,50 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments from this software for such purposes. Copyright of this software remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.system.wrapper;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.cache.SysCache;
import org.springblade.system.cache.UserCache;
import org.springblade.system.pojo.entity.InvoiceItem;
import org.springblade.system.pojo.vo.InvoiceItemVO;
import java.util.Objects;
/**
* 开票项目包装类
*
* @author Chill
*/
public class InvoiceItemWrapper extends BaseEntityWrapper<InvoiceItem, InvoiceItemVO> {
public static InvoiceItemWrapper build() {
return new InvoiceItemWrapper();
}
@Override
public InvoiceItemVO entityVO(InvoiceItem invoiceItem) {
InvoiceItemVO vo = Objects.requireNonNull(BeanUtil.copyProperties(invoiceItem, InvoiceItemVO.class));
vo.setCreateDeptName(Func.isEmpty(invoiceItem.getCreateDept()) ? "" : SysCache.getDeptName(invoiceItem.getCreateDept()));
vo.setUpdateUserName(UserCache.getUserRealName(invoiceItem.getUpdateUser()));
return vo;
}
}