账单bug修复,以及加入转单号功能

This commit is contained in:
caojia
2026-09-21 17:59:09 +08:00
parent 81bc69c268
commit 6e07d9a98b
18 changed files with 366 additions and 53 deletions
@@ -1,12 +1,17 @@
package com.ruoyi.web.controller.ar;
import java.util.List;
import java.util.Date;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.validation.annotation.Validated;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@@ -31,6 +36,7 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
@@ -49,12 +55,23 @@ public class ArBillController extends BaseController {
@Autowired
private IArBillService billService;
/**
* 查询参数中的日期必须严格按 yyyy-MM-dd 解析,禁止非法日期自动滚动到其他日期。
*/
@InitBinder
public void initDateBinder(WebDataBinder binder) {
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd");
formatter.setLenient(false);
binder.registerCustomEditor(Date.class, new CustomDateEditor(formatter, true));
}
/**
* 查询账单列表;分页参数由 BaseController.startPage 交给 MyBatis PageHelper 处理。
*/
@PreAuthorize("@ss.hasPermi('ar:bill:list')")
@GetMapping("/list")
public TableDataInfo list(ArBillQuery query) {
public TableDataInfo list(ArBillQuery query, HttpServletRequest request) {
rejectMultiValueParameter(request, "customerId");
startPage();
List<ArBill> list = billService.selectArBillList(query);
return getDataTable(list);
@@ -104,7 +121,8 @@ public class ArBillController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('ar:bill:generate')")
@GetMapping("/generate/preview")
public AjaxResult preview(ArBillGenerateQuery query) {
public AjaxResult preview(ArBillGenerateQuery query, HttpServletRequest request) {
rejectMultiValueParameter(request, "customerId");
startPage();
List<PrcOrderBill> list = billService.previewBill(query);
TableDataInfo pageData = getDataTable(list);
@@ -252,4 +270,17 @@ public class ArBillController extends BaseController {
if (StringUtils.isNotEmpty(headerRequestId)) return headerRequestId;
return IdUtils.fastSimpleUUID();
}
/**
* 禁止把 customerId 以数组参数或重复参数提交,避免参数绑定失败后悄悄退化为无客户条件查询。
*/
private void rejectMultiValueParameter(HttpServletRequest request, String parameterName) {
if (request.getParameterMap().containsKey(parameterName + "[]")) {
throw new ServiceException("查询参数[" + parameterName + "]格式不正确,请传入单个客户ID");
}
String[] values = request.getParameterValues(parameterName);
if (values != null && values.length > 1) {
throw new ServiceException("查询参数[" + parameterName + "]只能传入一个值");
}
}
}