|
|
@@ -0,0 +1,147 @@
|
|
|
+package org.dromara.bill.pc.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import jakarta.validation.constraints.*;
|
|
|
+import org.dromara.common.core.domain.R;
|
|
|
+import org.dromara.common.core.utils.MapstructUtils;
|
|
|
+import org.dromara.common.log.annotation.Log;
|
|
|
+import org.dromara.common.log.enums.BusinessType;
|
|
|
+import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
+import org.dromara.common.web.core.BaseController;
|
|
|
+import org.dromara.bill.domain.StatementOrder;
|
|
|
+import org.dromara.bill.domain.bo.StatementOrderBo;
|
|
|
+import org.dromara.bill.domain.vo.StatementOrderVo;
|
|
|
+import org.dromara.bill.domain.vo.StatementDetailVo;
|
|
|
+import org.dromara.bill.service.IStatementOrderService;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * PC端 - 对账单管理
|
|
|
+ * 前端访问路由地址为:/pc/enterprise/statement
|
|
|
+ *
|
|
|
+ * @author Claude
|
|
|
+ * @date 2026-01-29
|
|
|
+ */
|
|
|
+@Validated
|
|
|
+@RequiredArgsConstructor
|
|
|
+@RestController
|
|
|
+@RequestMapping("/pc/enterprise/statement")
|
|
|
+public class PcStatementOrderController extends BaseController {
|
|
|
+
|
|
|
+ private final IStatementOrderService statementOrderService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询当前企业的对账单列表
|
|
|
+ * PC端用户只能查询自己企业的对账单
|
|
|
+ * 只允许查询状态为 1(待对账)、2(已对账)、3(驳回) 的对账单
|
|
|
+ * 不允许查询状态为 0(待确认)、4(作废) 的对账单
|
|
|
+ */
|
|
|
+ @GetMapping("/list")
|
|
|
+ public TableDataInfo<StatementOrderVo> list(StatementOrderBo bo, PageQuery pageQuery) {
|
|
|
+ Long customerId = LoginHelper.getUserId();
|
|
|
+
|
|
|
+ // PC端权限控制:强制只查询状态为 1、2、3 的对账单
|
|
|
+ LambdaQueryWrapper<StatementOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(StatementOrder::getCustomerId, customerId);
|
|
|
+ wrapper.in(StatementOrder::getStatementStatus, Arrays.asList("1", "2", "3"));
|
|
|
+
|
|
|
+ // 如果用户指定了状态,且状态在允许范围内,则使用用户指定的状态
|
|
|
+ String statementStatus = bo.getStatementStatus();
|
|
|
+ if (statementStatus != null && !statementStatus.isEmpty()) {
|
|
|
+ if ("1".equals(statementStatus) || "2".equals(statementStatus) || "3".equals(statementStatus)) {
|
|
|
+ // 用户指定的状态在允许范围内,覆盖 IN 条件
|
|
|
+ wrapper.clear();
|
|
|
+ wrapper.eq(StatementOrder::getCustomerId, customerId);
|
|
|
+ wrapper.eq(StatementOrder::getStatementStatus, statementStatus);
|
|
|
+ }
|
|
|
+ // 如果用户指定了不允许的状态(0或4),保持 IN 条件,会返回空结果
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加其他查询条件
|
|
|
+ if (bo.getStatementOrderNo() != null && !bo.getStatementOrderNo().isEmpty()) {
|
|
|
+ wrapper.like(StatementOrder::getStatementOrderNo, bo.getStatementOrderNo());
|
|
|
+ }
|
|
|
+ if (bo.getIsInvoiceStatus() != null && !bo.getIsInvoiceStatus().isEmpty()) {
|
|
|
+ wrapper.eq(StatementOrder::getIsInvoiceStatus, bo.getIsInvoiceStatus());
|
|
|
+ }
|
|
|
+ if (bo.getIsPaymentStatus() != null && !bo.getIsPaymentStatus().isEmpty()) {
|
|
|
+ wrapper.eq(StatementOrder::getIsPaymentStatus, bo.getIsPaymentStatus());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 使用新添加的 PC 端专用方法
|
|
|
+ return statementOrderService.queryPageListByWrapper(wrapper, pageQuery);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取对账单详细信息
|
|
|
+ * PC端用户只能查询自己企业的对账单
|
|
|
+ */
|
|
|
+ @GetMapping("/{id}")
|
|
|
+ public R<StatementOrderVo> getInfo(@NotNull(message = "主键不能为空")
|
|
|
+ @PathVariable("id") Long id) {
|
|
|
+ StatementOrderVo vo = statementOrderService.queryById(id);
|
|
|
+ if (vo != null) {
|
|
|
+ Long customerId = LoginHelper.getUserId();
|
|
|
+ if (!customerId.equals(vo.getCustomerId())) {
|
|
|
+ return R.fail("无权访问该对账单");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.ok(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询当前企业的对账单明细列表
|
|
|
+ */
|
|
|
+ @GetMapping("/details")
|
|
|
+ public TableDataInfo<StatementDetailVo> getDetails(PageQuery pageQuery) {
|
|
|
+ Long customerId = LoginHelper.getUserId();
|
|
|
+ return statementOrderService.listDetailsByCustomerIdPage(customerId, pageQuery);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 确认对账单
|
|
|
+ */
|
|
|
+ @Log(title = "PC端-对账单确认", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping("/confirm")
|
|
|
+ public R<Void> confirm(@RequestBody StatementOrderBo bo) {
|
|
|
+ Long customerId = LoginHelper.getUserId();
|
|
|
+ StatementOrderVo existingStatement = statementOrderService.queryById(bo.getId());
|
|
|
+ if (existingStatement == null) {
|
|
|
+ return R.fail("对账单不存在");
|
|
|
+ }
|
|
|
+ if (!customerId.equals(existingStatement.getCustomerId())) {
|
|
|
+ return R.fail("无权确认该对账单");
|
|
|
+ }
|
|
|
+ bo.setCustomerId(customerId);
|
|
|
+ bo.setStatementStatus("1");
|
|
|
+ return toAjax(statementOrderService.updateStatus(bo));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 驳回对账单
|
|
|
+ */
|
|
|
+ @Log(title = "PC端-对账单驳回", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping("/reject")
|
|
|
+ public R<Void> reject(@RequestBody StatementOrderBo bo) {
|
|
|
+ Long customerId = LoginHelper.getUserId();
|
|
|
+ StatementOrderVo existingStatement = statementOrderService.queryById(bo.getId());
|
|
|
+ if (existingStatement == null) {
|
|
|
+ return R.fail("对账单不存在");
|
|
|
+ }
|
|
|
+ if (!customerId.equals(existingStatement.getCustomerId())) {
|
|
|
+ return R.fail("无权驳回该对账单");
|
|
|
+ }
|
|
|
+ bo.setCustomerId(customerId);
|
|
|
+ bo.setStatementStatus("2");
|
|
|
+ return toAjax(statementOrderService.updateStatus(bo));
|
|
|
+ }
|
|
|
+}
|