| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.constant.DictConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.DictUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.dto.TBillDto; |
| | | import com.ruoyi.system.dto.TInvoiceDTO; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.TBillQuery; |
| | | import com.ruoyi.system.service.TBillDetailService; |
| | | import com.ruoyi.system.service.TBillService; |
| | | import com.ruoyi.system.service.TInvoiceService; |
| | | import com.ruoyi.system.service.TInvoiceToBillService; |
| | | import com.ruoyi.system.vo.TBillVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | 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.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author xiaochen |
| | | * @since 2025-01-17 |
| | | */ |
| | | @Api(tags = "缴费账单") |
| | | @RestController |
| | | @RequestMapping("/t-bill") |
| | | public class TBillController { |
| | | |
| | | @Autowired |
| | | TBillService tBillService; |
| | | @Autowired |
| | | TBillDetailService billDetailService; |
| | | @Autowired |
| | | TInvoiceService invoiceService; |
| | | @Autowired |
| | | TInvoiceToBillService invoiceToBillService; |
| | | |
| | | @ApiOperation(value = "缴费账单查询分页列表") |
| | | @PostMapping("list") |
| | | public R<PageInfo<TBillDto>> list(@RequestBody TBillQuery query){ |
| | | if (StringUtils.isEmpty(query.getUserId())){ |
| | |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | @ApiOperation(value = "查看缴费账单详情") |
| | | @GetMapping(value = "/getDetailById") |
| | | public R<TBillVO> getDetailById(@RequestParam String id) { |
| | | TBill bill = tBillService.getById(id); |
| | | TBillVO billVO = new TBillVO(); |
| | | BeanUtils.copyProperties(bill, billVO); |
| | | // 查询水电费列表 |
| | | if("3".equals(bill.getBillType())){ |
| | | List<TBillDetail> list = billDetailService.list(Wrappers.lambdaQuery(TBillDetail.class) |
| | | .eq(TBillDetail::getBillId, id)); |
| | | billVO.setBillDetailList(list); |
| | | } |
| | | billVO.setBillType(DictUtils.getDictLabel(DictConstants.DICT_TYPE_BILL_TYPE,billVO.getBillType())); |
| | | billVO.setPayFeesStatus(DictUtils.getDictLabel(DictConstants.DICT_TYPE_PAY_FEES_STATUS,billVO.getPayFeesStatus())); |
| | | return R.ok(billVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "缴费账单开票") |
| | | @PostMapping(value = "/invoice") |
| | | public R<String> invoice(@RequestBody TInvoiceDTO dto) { |
| | | // 添加开票信息 |
| | | invoiceService.save(dto); |
| | | |
| | | // 添加开票信息中间表信息 |
| | | List<String> billIds = dto.getBillIds(); |
| | | List<TInvoiceToBill> sysInvoiceToBills = new ArrayList<>(); |
| | | for (String billId : billIds) { |
| | | TInvoiceToBill tInvoiceToBill = new TInvoiceToBill(); |
| | | tInvoiceToBill.setInvoiceId(dto.getId()); |
| | | tInvoiceToBill.setBillId(billId); |
| | | sysInvoiceToBills.add(tInvoiceToBill); |
| | | } |
| | | invoiceToBillService.saveBatch(sysInvoiceToBills); |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | | |