package com.by4cloud.platformx.business.controller;
|
|
import cn.hutool.core.util.StrUtil;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.by4cloud.platformx.business.dto.GenInvoiceInfoDTO;
|
import com.by4cloud.platformx.business.entity.Contract;
|
import com.by4cloud.platformx.business.service.ContractInvoiceService;
|
import com.by4cloud.platformx.business.service.ContractService;
|
import com.by4cloud.platformx.common.core.util.R;
|
import com.by4cloud.platformx.common.data.mybatis.BaseModel;
|
import com.by4cloud.platformx.common.security.annotation.Inner;
|
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import lombok.RequiredArgsConstructor;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springdoc.core.annotations.ParameterObject;
|
import org.springframework.http.HttpHeaders;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.web.bind.annotation.*;
|
|
/**
|
* 合同开票
|
*
|
* @author syt
|
* @date 2026年6月5日 08:13:55
|
*/
|
@RestController
|
@RequiredArgsConstructor
|
@RequestMapping("/contractInvoice" )
|
@Tag(description = "contract" , name = "合同开票" )
|
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
public class ContractInvoiceController {
|
|
private final ContractService contractService;
|
private final ContractInvoiceService contractInvoiceService;
|
|
/**
|
* 分页查询
|
* @param page 分页对象
|
* @param contract 合同管理
|
* @return
|
*/
|
@Operation(summary = "分页查询" , description = "分页查询" )
|
@GetMapping("/page" )
|
public R getContractPage(@ParameterObject Page page, @ParameterObject Contract contract) {
|
LambdaQueryWrapper<Contract> wrapper = Wrappers.lambdaQuery();
|
wrapper.like(StringUtils.isNotBlank(contract.getContractName()),Contract::getContractName,contract.getContractName());
|
wrapper.like(StringUtils.isNotBlank(contract.getPartyA()),Contract::getPartyA,contract.getPartyA());
|
wrapper.eq(Contract::getBillingStatus,contract.getBillingStatus());
|
if (StrUtil.equals(contract.getBillingStatus(),"1")){
|
wrapper.orderByDesc(BaseModel::getCreateTime);
|
}else {
|
wrapper.orderByAsc(BaseModel::getCreateTime);
|
}
|
|
return R.ok(contractService.pageByScope(page, wrapper));
|
}
|
|
/**
|
* 获取合同出库信息
|
* @return
|
*/
|
@GetMapping("/getContractOutBound/{contractId}" )
|
public R getContractOutBound(@PathVariable("contractId")Long contractId) {
|
return contractInvoiceService.getContractOutBound(contractId);
|
}
|
|
/**
|
* 生成开票预览信息
|
* @return
|
*/
|
@PostMapping("/genInvoiceInfo" )
|
public R genInvoiceInfo(@RequestBody GenInvoiceInfoDTO genInvoiceInfoDTO) {
|
return contractInvoiceService.genInvoiceInfo(genInvoiceInfoDTO);
|
}
|
|
/**
|
* 开蓝票
|
* @return
|
*/
|
@PostMapping("/toInvoice" )
|
public R toInvoice(@RequestBody GenInvoiceInfoDTO genInvoiceInfoDTO) {
|
return contractInvoiceService.toInvoice(genInvoiceInfoDTO);
|
}
|
|
/**
|
* 获取已开发票
|
* @return
|
*/
|
@GetMapping("/getContractInvoiceList/{contractId}" )
|
public R getContractInvoiceList(@PathVariable("contractId")Long contractId) {
|
return contractInvoiceService.getContractInvoiceList(contractId);
|
}
|
|
/**
|
* 蓝票查询
|
* @return
|
*/
|
@Inner(value = false)
|
@GetMapping("/queryBlueInvoice")
|
public R queryBlueInvoice() {
|
return contractInvoiceService.queryBlueInvoice();
|
}
|
|
/**
|
* 开红票
|
* @return
|
*/
|
@GetMapping("/toRedInvoice/{invoiceId}")
|
public R toRedInvoice(@PathVariable("invoiceId")Long invoiceId) {
|
return contractInvoiceService.toRedInvoice(invoiceId);
|
}
|
|
/**
|
* 红票查询
|
* @return
|
*/
|
@Inner(value = false)
|
@GetMapping("/queryRedInvoice")
|
public R queryRedInvoice() {
|
return contractInvoiceService.queryRedInvoice();
|
}
|
}
|