| | |
| | | |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.system.model.TBill; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.dto.BillStatisticsDto; |
| | | import com.ruoyi.system.dto.CachPayDto; |
| | | import com.ruoyi.system.dto.OfflinePayCheckDto; |
| | | import com.ruoyi.system.dto.SmsByBillDto; |
| | | import com.ruoyi.system.dto.TBillDto; |
| | | import com.ruoyi.system.dto.TbillSaveDto; |
| | | import com.ruoyi.system.model.TBillConfirm; |
| | | import com.ruoyi.system.model.TBillDetail; |
| | | import com.ruoyi.system.model.TContract; |
| | | import com.ruoyi.system.query.TBillQuery; |
| | | import com.ruoyi.system.query.TContractQuery; |
| | | import com.ruoyi.system.service.TBillConfirmService; |
| | | import com.ruoyi.system.service.TBillDetailService; |
| | | import com.ruoyi.system.service.TBillService; |
| | | import com.ruoyi.system.service.TContractService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | 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; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author xiaochen |
| | | * @since 2025-01-17 |
| | | */ |
| | | @Api(tags = "账单管理") |
| | | @RestController |
| | | @RequestMapping("/t-bill") |
| | | public class TBillController { |
| | |
| | | @Autowired |
| | | TBillService tBillService; |
| | | |
| | | @Autowired |
| | | TBillDetailService tBillDetailService; |
| | | |
| | | @Autowired |
| | | TBillConfirmService tBillConfirmService; |
| | | |
| | | @Autowired |
| | | TContractService contractService; |
| | | |
| | | @PreAuthorize("@ss.hasPermi('bill:list')") |
| | | @PostMapping("list") |
| | | public R<PageInfo<TBill>> list(@RequestBody TBillQuery query){ |
| | | PageInfo<TBill> pageInfo = tBillService.queryPage(query); |
| | | @ApiOperation("分页查询账单列表") |
| | | public R<PageInfo<TBillDto>> list(@RequestBody TBillQuery query){ |
| | | query.setBusinessDeptId(SecurityUtils.getBusinessDeptId()); |
| | | PageInfo<TBillDto> pageInfo = tBillService.queryPage(query); |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | @ApiOperation("统计") |
| | | @PostMapping("statistics") |
| | | public R<BillStatisticsDto> statistics(@RequestBody TBillQuery query){ |
| | | query.setBusinessDeptId(SecurityUtils.getBusinessDeptId()); |
| | | BillStatisticsDto dto = tBillService.statistics(query); |
| | | return R.ok(dto); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "获取合同分页列表") |
| | | @PostMapping(value = "/contractList") |
| | | public R<PageInfo<TContract>> contractList(@RequestBody TContractQuery query) { |
| | | query.setBusinessDeptId(SecurityUtils.getBusinessDeptId()); |
| | | return R.ok(contractService.queryPage(query)); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('bill:list:addRent')") |
| | | @PostMapping("add") |
| | | @ApiOperation("新增账单") |
| | | public R<PageInfo<TBillDto>> add(@Validated @RequestBody TbillSaveDto bill){ |
| | | String businessDeptId = SecurityUtils.getBusinessDeptId(); |
| | | if (SecurityUtils.getBusinessDeptId().equals("0")) { |
| | | TContract contract = contractService.getById(bill.getContractId()); |
| | | if (Objects.nonNull(contract)) { |
| | | businessDeptId = contract.getBusinessDeptId(); |
| | | } |
| | | } |
| | | bill.setBusinessDeptId(businessDeptId); |
| | | tBillService.saveBill(bill); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @PreAuthorize("@ss.hasPermi('bill:list:editAmount')") |
| | | @PostMapping("editAmount") |
| | | @ApiOperation("修改账单金额") |
| | | public R editAmount(@Validated @RequestBody TbillSaveDto bill){ |
| | | if (StringUtils.isEmpty(bill.getId())){ |
| | | return R.fail("参数错误"); |
| | | } |
| | | if (bill.getEditAmount().compareTo(BigDecimal.ZERO)==0){ |
| | | return R.fail("调整金额不能为0"); |
| | | } |
| | | |
| | | tBillService.editAmount(bill); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation("通过ID查找详情") |
| | | @GetMapping("getDetailById") |
| | | public R<TBillDto> getDetailById(@RequestParam String id){ |
| | | if (StringUtils.isEmpty(id)){ |
| | | return R.fail(); |
| | | } |
| | | TBillDto dto = tBillService.getDetailByBillId(id); |
| | | if (dto.getBillType().equals("3")){ |
| | | List<TBillDetail> details = tBillDetailService.getByBillId(id); |
| | | for (TBillDetail detail : details) { |
| | | if (detail.getLiveType()==1)dto.setWater(detail); //水费 |
| | | else dto.setElect(detail); //电费 |
| | | } |
| | | } |
| | | if (StringUtils.isNotEmpty(dto.getConfirmId())){ |
| | | TBillConfirm confirm = tBillConfirmService.getById(dto.getConfirmId()); |
| | | dto.setConfirm(confirm); |
| | | } |
| | | return R.ok(dto); |
| | | } |
| | | |
| | | |
| | | @PreAuthorize("@ss.hasPermi('bill:list:paid')") |
| | | @ApiOperation("确认线下缴费") |
| | | @PostMapping("checkOfflinePay") |
| | | public R checkOfflinePay(@Validated @RequestBody OfflinePayCheckDto dto){ |
| | | tBillService.checkOfflinePay(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('bill:list:sendMsg')") |
| | | @ApiOperation("账单批量发送短信通知") |
| | | @PostMapping("sendSmsByBillIds") |
| | | public R sendSmsByBillIds(@Validated @RequestBody SmsByBillDto dto){ |
| | | Integer failNum = tBillService.sendSmsByBillIds(dto); |
| | | return R.ok(failNum); |
| | | } |
| | | |
| | | |
| | | @PreAuthorize("@ss.hasPermi('bill:list:sendMail')") |
| | | @ApiOperation("账单批量发送邮箱通知") |
| | | @PostMapping("sendMailBatchByBillIds") |
| | | public R sendMailBatchByBillIds(@Validated @RequestBody SmsByBillDto dto){ |
| | | Integer failNum = tBillService.sendMailBatchByBillIds(dto); |
| | | return R.ok(failNum); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @PreAuthorize("@ss.hasPermi('bill:list:receipt')") |
| | | @ApiOperation("收款") |
| | | @PostMapping("cashPay") |
| | | public R cashPay(@RequestBody CachPayDto cachPayDto){ |
| | | tBillService.cashPay(cachPayDto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |