From 8d0009c7b03ea915955bf6b84a548699a32f23e5 Mon Sep 17 00:00:00 2001 From: yupeng <roc__yu@163.com> Date: 星期三, 26 三月 2025 17:59:56 +0800 Subject: [PATCH] feat: 账单及查询、新增、添加营运部门ID --- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java | 166 +++++++++++++++++++++++++++++++++---------------------- 1 files changed, 99 insertions(+), 67 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java index 0376220..a596a85 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java @@ -1,21 +1,42 @@ package com.ruoyi.system.service.impl; -import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.basic.PageInfo; -import com.ruoyi.common.config.SmsProperties; import com.ruoyi.common.constant.AmountConstant; import com.ruoyi.common.constant.CacheConstants; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.exception.ServiceException; -import com.ruoyi.common.utils.*; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.OrderNos; +import com.ruoyi.common.utils.SmsUtil; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.TencentMailUtil; import com.ruoyi.common.utils.uuid.UUID; -import com.ruoyi.system.dto.*; +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.mapper.TBillMapper; -import com.ruoyi.system.model.*; +import com.ruoyi.system.model.TBankFlow; +import com.ruoyi.system.model.TBill; +import com.ruoyi.system.model.TBillDetail; +import com.ruoyi.system.model.TFlowManagement; +import com.ruoyi.system.model.TInvoiceToBill; +import com.ruoyi.system.model.TOrderBill; +import com.ruoyi.system.model.TPayOrder; import com.ruoyi.system.query.TBillQuery; import com.ruoyi.system.query.TInvoiceToBillQuery; -import com.ruoyi.system.service.*; +import com.ruoyi.system.service.TBankFlowService; +import com.ruoyi.system.service.TBillConfirmService; +import com.ruoyi.system.service.TBillDetailService; +import com.ruoyi.system.service.TBillService; +import com.ruoyi.system.service.TFlowManagementService; +import com.ruoyi.system.service.TInvoiceToBillService; +import com.ruoyi.system.service.TOrderBillService; +import com.ruoyi.system.service.TPayOrderService; +import com.ruoyi.system.vo.ScreenRentRankVO; import com.taxi591.bankapi.dto.ChargeBillRequest; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; @@ -28,7 +49,6 @@ import javax.validation.constraints.NotEmpty; import java.math.BigDecimal; import java.text.ParseException; -import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Comparator; import java.util.Date; @@ -124,6 +144,7 @@ if (isok){ try { TBill save = new TBill(); + save.setId(tBill.getId()); TBill presist = getById(tBill.getId()); //如果账单是已缴费状态,本方法不再进行更新账单 if (presist.getPayFeesStatus().equals("3")){ @@ -323,62 +344,66 @@ String uuid = UUID.fastUUID().toString(); boolean lock = redisCache.trylockLoop(CacheConstants.COMPLETE_PAY_LOCK_KEY + orderNo, uuid, 60); if (lock){ - TPayOrder order = tPayOrderService.getById(orderNo); - if (order==null){ - throw new ServiceException("订单不存在"); - } - if (StringUtils.isNotEmpty(order.getPayNo())){ - log.info("订单号已处理:{}",orderNo); - return; - } - /** - * 更新订单状态 - */ - TPayOrder save = new TPayOrder(); - save.setId(order.getId()); - save.setStatus(1); - save.setPayNo(billRequest.getMessage().getInfo().getTraceNo()); - save.setPayType(billRequest.getMessage().getHead().getChannel()); try { - save.setPayTime(DateUtils.parseDate(billRequest.getMessage().getHead().getTimeStamp(),"yyyyMMddHHmmssSSS")); - } catch (ParseException e) { - throw new ServiceException("日期格式化错误"); + TPayOrder order = tPayOrderService.getById(orderNo); + if (order==null){ + throw new ServiceException("订单不存在"); + } + if (StringUtils.isNotEmpty(order.getPayNo())){ + log.info("订单号已处理:{}",orderNo); + return; + } + /** + * 更新订单状态 + */ + TPayOrder save = new TPayOrder(); + save.setId(order.getId()); + save.setStatus(1); + save.setPayNo(billRequest.getMessage().getInfo().getTraceNo()); + save.setPayType(billRequest.getMessage().getHead().getChannel()); + try { + save.setPayTime(DateUtils.parseDate(billRequest.getMessage().getHead().getTimeStamp(),"yyyyMMddHHmmssSSS")); + } catch (ParseException e) { + throw new ServiceException("日期格式化错误"); + } + save.setCallbackTime(new Date()); + BigDecimal payAmount = new BigDecimal(billRequest.getMessage().getInfo().getPayBillAmt()); + save.setActPayAmount(payAmount + .multiply(AmountConstant.b100).longValue()); + save.setStatus(1); + save.setPayInfo(billRequest.getMessage().toString()); + tPayOrderService.updateById(save); + /** + * 更新账单状态 + */ + List<TOrderBill> orderBills = orderBillService.getByOrderNo(order.getId()); + List<TBill> bills = orderBills.stream().map(ob -> getById(ob.getBillId())).collect(Collectors.toList()); + lockAndUpdateByAmountBatch(bills,payAmount,(bill)->{ + TFlowManagement saveFlow = new TFlowManagement(); + saveFlow.setPayType(1); + saveFlow.setPayer(order.getUserId()); + saveFlow.setPayTime(DateUtils.dateToLocalDateTime(save.getPayTime())); + saveFlow.setSysSerialNumber(OrderNos.getDid(30)); + saveFlow.setBankSerialNumber(save.getPayNo()); + saveFlow.setFlowType(2); + saveFlow.setPaymentBillId(bill.getId()); + saveFlow.setDeductionMoney(bill.getDeductionMoney()); + saveFlow.setFlowMoney(payAmount); + saveFlow.setRemainingMoney(bill.getOutstandingMoney()); + saveFlow.setPreOutstand(bill.getPreOutstand()); + tFlowManagementService.save(saveFlow); + }); +// TBankFlow bankFlow = new TBankFlow(); +// bankFlow.setPayType(1); +// bankFlow.setPayer(order.getUserId()); +// bankFlow.setPayTime(DateUtils.dateToLocalDateTime(save.getPayTime())); +// bankFlow.setBankSerialNumber(save.getPayNo()); +// bankFlow.setFlowMoney(payAmount); +// bankFlow.setFlowStatus(1); +// tBankFlowService.save(bankFlow); + }finally { + redisCache.unlock(CacheConstants.COMPLETE_PAY_LOCK_KEY + orderNo,uuid); } - save.setCallbackTime(new Date()); - BigDecimal payAmount = new BigDecimal(billRequest.getMessage().getInfo().getPayBillAmt()); - save.setActPayAmount(payAmount - .multiply(AmountConstant.b100).longValue()); - save.setStatus(1); - save.setPayInfo(billRequest.getMessage().toString()); - tPayOrderService.updateById(save); - /** - * 更新账单状态 - */ - List<TOrderBill> orderBills = orderBillService.getByOrderNo(order.getId()); - List<TBill> bills = orderBills.stream().map(ob -> getById(ob.getBillId())).collect(Collectors.toList()); - lockAndUpdateByAmountBatch(bills,payAmount,(bill)->{ - TFlowManagement saveFlow = new TFlowManagement(); - saveFlow.setPayType(1); - saveFlow.setPayer(order.getUserId()); - saveFlow.setPayTime(DateUtils.dateToLocalDateTime(save.getPayTime())); - saveFlow.setSysSerialNumber(OrderNos.getDid(30)); - saveFlow.setBankSerialNumber(save.getPayNo()); - saveFlow.setFlowType(2); - saveFlow.setPaymentBillId(bill.getId()); - saveFlow.setDeductionMoney(bill.getDeductionMoney()); - saveFlow.setFlowMoney(payAmount); - saveFlow.setRemainingMoney(bill.getOutstandingMoney()); - saveFlow.setPreOutstand(bill.getPreOutstand()); - tFlowManagementService.save(saveFlow); - }); - TBankFlow bankFlow = new TBankFlow(); - bankFlow.setPayType(1); - bankFlow.setPayer(order.getUserId()); - bankFlow.setPayTime(DateUtils.dateToLocalDateTime(save.getPayTime())); - bankFlow.setBankSerialNumber(save.getPayNo()); - bankFlow.setFlowMoney(payAmount); - bankFlow.setFlowStatus(1); - tBankFlowService.save(bankFlow); } @@ -538,12 +563,12 @@ } @Override - public BillStatisticsDto statistics() { + public BillStatisticsDto statistics(String busDeptId) { BillStatisticsDto dto = new BillStatisticsDto(); - dto.setRent(getBaseMapper().statisticsAllRent()); - dto.setNopay(getBaseMapper().statisticsNoPay()); - dto.setPayed(getBaseMapper().statisticsPayed()); - dto.setOverdue(getBaseMapper().statisticsOverdue()); + dto.setRent(getBaseMapper().statisticsAllRent(busDeptId)); + dto.setNopay(getBaseMapper().statisticsNoPay(busDeptId)); + dto.setPayed(getBaseMapper().statisticsPayed(busDeptId)); + dto.setOverdue(getBaseMapper().statisticsOverdue(busDeptId)); return dto; } @@ -552,5 +577,12 @@ return this.baseMapper.batchBillCount(userId,billIds); } - + /** + * 街道租金排行 + * @return + */ + @Override + public List<ScreenRentRankVO> getStreetRentRank() { + return baseMapper.getStreetRentRank(); + } } -- Gitblit v1.7.1