From b4d62c78529fb673c12ad0bcaf1e16b119c58051 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期五, 28 二月 2025 16:15:03 +0800
Subject: [PATCH] Merge branch 'xizang-changyun' of https://gitee.com/xiaochen991015/xizang
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java | 20 +++
ruoyi-admin/pom.xml | 10 +-
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBankFlowController.java | 14 ++
ruoyi-common/src/main/resources/META-INF/spring.factories | 2
ruoyi-system/src/main/java/com/ruoyi/system/dto/CachPayDto.java | 33 ++++++
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBankFlowServiceImpl.java | 9 +
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java | 138 +++++++++++++++++++++------
ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java | 7
ruoyi-system/src/main/java/com/ruoyi/system/dto/OfflinePayCheckDto.java | 15 ++
ruoyi-system/src/main/java/com/ruoyi/system/dto/OfflinePayDto.java | 3
ruoyi-system/src/main/java/com/ruoyi/system/dto/TBillDto.java | 5 +
11 files changed, 202 insertions(+), 54 deletions(-)
diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml
index 96e7388..5741488 100644
--- a/ruoyi-admin/pom.xml
+++ b/ruoyi-admin/pom.xml
@@ -32,11 +32,11 @@
<version>31.1-jre</version> <!-- 请根据需要选择合适的版本 -->
</dependency>
<!-- spring-boot-devtools -->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-devtools</artifactId>
- <optional>true</optional> <!-- 表示依赖不会传递 -->
- </dependency>
+<!-- <dependency>-->
+<!-- <groupId>org.springframework.boot</groupId>-->
+<!-- <artifactId>spring-boot-devtools</artifactId>-->
+<!-- <optional>true</optional> <!– 表示依赖不会传递 –>-->
+<!-- </dependency>-->
<!-- swagger3-->
<dependency>
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBankFlowController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBankFlowController.java
index 465eebc..cc91e8f 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBankFlowController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBankFlowController.java
@@ -6,6 +6,7 @@
import com.alibaba.excel.event.AnalysisEventListener;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.WebUtils;
import com.ruoyi.system.importExcel.TBankFlowImportExcel;
import com.ruoyi.system.model.TBankFlow;
@@ -15,10 +16,7 @@
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
-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 org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
@@ -111,6 +109,14 @@
System.err.println("银行流水返回结果导出失败");
}
}
+
+ @GetMapping("getByBankSerialNumber")
+ public R<List<TBankFlow>> searchByBankSerialNumber(@RequestParam String bankSerialNumber){
+ List<TBankFlow> tBankFlows = flowService.searchByBankSerialNumber(bankSerialNumber);
+ return R.ok(tBankFlows);
+ }
+
+
}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java
index 4893b54..be019f9 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java
@@ -4,10 +4,13 @@
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.dto.*;
import com.ruoyi.system.model.TBill;
+import com.ruoyi.system.model.TBillConfirm;
import com.ruoyi.system.model.TBillDetail;
import com.ruoyi.system.query.TBillQuery;
+import com.ruoyi.system.service.TBillConfirmService;
import com.ruoyi.system.service.TBillDetailService;
import com.ruoyi.system.service.TBillService;
import io.swagger.annotations.Api;
@@ -39,6 +42,8 @@
@Autowired
TBillDetailService tBillDetailService;
+ @Autowired
+ TBillConfirmService tBillConfirmService;
@PreAuthorize("@ss.hasPermi('bill:list')")
@PostMapping("list")
@@ -58,7 +63,10 @@
@ApiOperation("通过ID查找详情")
@GetMapping("getDetailById")
- public R<TBillDto> getDetailById(@Validated @NotEmpty String id){
+ 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);
@@ -66,6 +74,10 @@
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);
}
@@ -96,10 +108,14 @@
return R.ok(failNum);
}
+
+
+
@PreAuthorize("@ss.hasPermi('bill:list:receipt')")
@ApiOperation("收款")
@PostMapping("cashPay")
- public R cashPay(@RequestBody OfflinePayDto offlinePayDto){
+ public R cashPay(@RequestBody CachPayDto cachPayDto){
+ tBillService.cashPay(cachPayDto);
return null;
}
diff --git a/ruoyi-common/src/main/resources/META-INF/spring.factories b/ruoyi-common/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000..dc976e7
--- /dev/null
+++ b/ruoyi-common/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,2 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+com.ruoyi.common.config.SmsConfig
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/dto/CachPayDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/dto/CachPayDto.java
new file mode 100644
index 0000000..fbc237e
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/dto/CachPayDto.java
@@ -0,0 +1,33 @@
+package com.ruoyi.system.dto;
+
+import com.ruoyi.system.model.TBankFlow;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 收款对象
+ */
+@Data
+public class CachPayDto implements Serializable {
+
+ @ApiModelProperty(value = "支付类型:1.银行、2.现金")
+ private Integer payType;
+
+ @ApiModelProperty(value = "账单ID")
+ private String billId;
+
+ @ApiModelProperty(value = "金额")
+ private BigDecimal amount;
+
+ @ApiModelProperty(value = "付款人姓名")
+ private String payer;
+
+ @ApiModelProperty(value = "银行支付的付款凭证")
+ private String voucher;
+
+ @ApiModelProperty("银行支付的银行流水")
+ private TBankFlow tBankFlow;
+}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/dto/OfflinePayCheckDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/dto/OfflinePayCheckDto.java
index 8e088b9..97d1159 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/dto/OfflinePayCheckDto.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/dto/OfflinePayCheckDto.java
@@ -1,6 +1,7 @@
package com.ruoyi.system.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.system.model.TBankFlow;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -19,6 +20,11 @@
@ApiModelProperty("账单ID列表,管理员处理后的")
@NotEmpty(message = "账单列表不能为空")
private List<String> billIds;
+
+ @ApiModelProperty(value = "账单ID")
+ @NotEmpty(message = "账单ID不能为空")
+ private String billId;
+
@ApiModelProperty("实际支付金额")
@NotNull(message = "实际支付金额不能为空")
private BigDecimal amount;
@@ -27,14 +33,15 @@
@NotNull(message = "确认单ID不能为空")
private String confirmId;
- @ApiModelProperty("银行流水号,用于生成流水")
- @NotEmpty(message = "银行流水号不能为空")
- private String bankSerilNum;
-
@ApiModelProperty("支付人")
private String payer;
@ApiModelProperty("支付时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime payTime;
+ @ApiModelProperty("支付凭证")
+ private String voucher;
+
+ @ApiModelProperty("银行流水")
+ private TBankFlow tBankFlow;
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/dto/OfflinePayDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/dto/OfflinePayDto.java
index fdaf862..9af180e 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/dto/OfflinePayDto.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/dto/OfflinePayDto.java
@@ -27,6 +27,7 @@
@ApiModelProperty(value = "账单列表")
@NotEmpty(message = "账单ID不能为空")
private List<String> billIds;
+
/**
* 凭证文件ID
*/
@@ -39,4 +40,6 @@
private Date payTime;
+
+
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/dto/TBillDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/dto/TBillDto.java
index 6619889..1babbce 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/dto/TBillDto.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/dto/TBillDto.java
@@ -1,6 +1,7 @@
package com.ruoyi.system.dto;
import com.ruoyi.system.model.TBill;
+import com.ruoyi.system.model.TBillConfirm;
import com.ruoyi.system.model.TBillDetail;
import lombok.Data;
@@ -40,5 +41,9 @@
* 电费
*/
private TBillDetail elect;
+ /**
+ * 线下打款确认单
+ */
+ private TBillConfirm confirm;
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java
index 1fd2b07..090fed4 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java
@@ -2,10 +2,7 @@
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.basic.PageInfo;
-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.dto.*;
import com.ruoyi.system.model.TBill;
import com.ruoyi.system.query.TBillQuery;
import com.taxi591.bankapi.dto.ChargeBillRequest;
@@ -84,4 +81,6 @@
Integer sendMailBatchByBillIds(SmsByBillDto dto);
TBillDto getDetailByBillId(@NotEmpty String id);
+
+ Boolean cashPay(CachPayDto offlinePayDto);
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBankFlowServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBankFlowServiceImpl.java
index 317ec8a..147a3ea 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBankFlowServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBankFlowServiceImpl.java
@@ -7,6 +7,7 @@
import com.ruoyi.system.importExcel.TBankFlowImportExcel;
import com.ruoyi.system.mapper.TBankFlowMapper;
import com.ruoyi.system.model.TBankFlow;
+import com.ruoyi.system.model.TBill;
import com.ruoyi.system.model.TFlowManagement;
import com.ruoyi.system.query.TBankFlowQuery;
import com.ruoyi.system.query.TFlowManagementQuery;
@@ -62,8 +63,12 @@
@Override
public List<TBankFlow> searchByBankSerialNumber(String bankSerialNumber) {
LambdaQueryWrapper<TBankFlow> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.like(StringUtils.isNotEmpty(bankSerialNumber),TBankFlow::getBankSerialNumber,bankSerialNumber);
- return this.baseMapper.selectList(queryWrapper);
+ queryWrapper.like(StringUtils.isNotEmpty(bankSerialNumber),TBankFlow::getBankSerialNumber,bankSerialNumber)
+ .orderByDesc(TBankFlow::getPayTime);
+
+ PageInfo<TBankFlow> pageInfo = new PageInfo<>(1, 20);
+ pageInfo = this.baseMapper.selectPage(pageInfo, queryWrapper);
+ return pageInfo.getRecords();
}
@Override
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 3e5b73b..dd43535 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
@@ -12,10 +12,7 @@
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.TencentMailUtil;
import com.ruoyi.common.utils.uuid.UUID;
-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.dto.*;
import com.ruoyi.system.mapper.TBillMapper;
import com.ruoyi.system.model.*;
import com.ruoyi.system.query.TBillQuery;
@@ -244,32 +241,50 @@
}
@Override
+ @Transactional(rollbackFor = Exception.class)
public boolean checkOfflinePay(OfflinePayCheckDto dto) {
- List<TBill> tBills = listByIds(dto.getBillIds());
- TBillConfirm confirm = tBillConfirmService.getById(dto.getConfirmId());
- lockAndUpdateByAmountBatch(tBills,dto.getAmount(),(bill)->{
- TFlowManagement save = new TFlowManagement();
- save.setPayType(3);
- save.setPayer(dto.getPayer());
- save.setPayTime(dto.getPayTime()==null?DateUtils.dateToLocalDateTime(confirm.getPayTime()):dto.getPayTime());
- save.setBankSerialNumber(dto.getBankSerilNum());
- save.setFlowType(2);
- save.setPaymentBillId(bill.getId());
- save.setDeductionMoney(bill.getDeductionMoney());
- save.setFlowMoney(dto.getAmount());
- save.setRemainingMoney(bill.getOutstandingMoney());
- save.setPreOutstand(bill.getPreOutstand());
- tFlowManagementService.save(save);
- });
- TBankFlow bankFlow = new TBankFlow();
- bankFlow.setPayType(3);
- bankFlow.setPayer(dto.getPayer());
- bankFlow.setPayTime(dto.getPayTime()==null?DateUtils.dateToLocalDateTime(confirm.getPayTime()):dto.getPayTime());
- bankFlow.setBankSerialNumber(dto.getBankSerilNum());
- bankFlow.setFlowMoney(dto.getAmount());
- bankFlow.setFlowStatus(1);
- tBankFlowService.save(bankFlow);
- return false;
+ TBankFlow bankflow = tBankFlowService.getById(dto.getTBankFlow().getId());
+ TBillDto bill = getDetailByBillId(dto.getBillId());
+ if (bankflow.getRemainingMoney().compareTo(BigDecimal.ZERO)<=0){
+ throw new ServiceException("该流水已无可抵扣剩余金额");
+ }
+ if (bankflow.getRemainingMoney().compareTo(dto.getAmount())<0){
+ throw new ServiceException("实付金额不能高于于流水可抵扣剩余金额");
+ }
+ //如果实付金额大于欠费金额
+ if (dto.getAmount().compareTo(bill.getOutstandingMoney())>=0){
+ throw new ServiceException("实付金额不能高于该账单欠费金额");
+ }
+
+ TBill billSave = new TBill();
+ billSave.setId(bill.getId());
+ billSave.setPayFeesMoney(dto.getAmount());
+ billSave.setBankSerialNumber(dto.getTBankFlow().getBankSerialNumber());
+ billSave.setPayFeesTime(dto.getTBankFlow().getPayTime());
+ billSave.setVoucher(dto.getVoucher());
+ billSave.setPayFeesType(2);
+ TBill back = lockAndUpdateInfo(billSave, 2);
+
+ //更新银行流水的已抵扣金额和剩余可抵扣金额
+ TBankFlow saveBankFlow = new TBankFlow();
+ saveBankFlow.setId(bankflow.getId());
+ saveBankFlow.setDeductionMoney(bankflow.getDeductionMoney().add(dto.getAmount()));
+ saveBankFlow.setRemainingMoney(bankflow.getRemainingMoney().subtract(dto.getAmount()));
+ tBankFlowService.updateById(saveBankFlow);
+ //存流水
+ TFlowManagement save = new TFlowManagement();
+ save.setPayType(3);
+ save.setPayer(dto.getPayer());
+ save.setPayTime(dto.getTBankFlow().getPayTime());
+ save.setBankSerialNumber(dto.getTBankFlow().getBankSerialNumber());
+ save.setFlowType(2);
+ save.setPaymentBillId(back.getId());
+ save.setDeductionMoney(back.getDeductionMoney());
+ save.setFlowMoney(dto.getAmount());
+ save.setRemainingMoney(back.getOutstandingMoney());
+ save.setPreOutstand(back.getPreOutstand());
+ tFlowManagementService.save(save);
+ return true;
}
@Override
@@ -380,7 +395,7 @@
TBill save = new TBill();
save.setId(bill.getId());
try {
- smsUtil.sendSms(bill.getPhone(), "", new String[]{""});
+ smsUtil.sendSms(bill.getPhone(), "2365726", new String[]{bill.getPartyTwoName()});
save.setSmsStatus(1);
}catch (ServiceException e){
failNum++;
@@ -398,9 +413,9 @@
int failNum = 0;
for (String billId : dto.getBillIds()) {
TBillDto bill = getDetailByBillId(billId);
- if (bill.getSmsLastTime()!=null
- && (System.currentTimeMillis()-bill.getSmsLastTime().getTime()<mailUtil.getPro().getBillMailDelayPeriod()*60*1000L)){
- throw new ServiceException("有账单最近一次发送的时间是:"+DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,bill.getSmsLastTime()));
+ if (bill.getMailLastTime()!=null
+ && (System.currentTimeMillis()-bill.getMailLastTime().getTime()<mailUtil.getPro().getBillMailDelayPeriod()*60*1000L)){
+ throw new ServiceException("有账单最近一次发送的时间是:"+DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,bill.getMailLastTime()));
}
if (StringUtils.isEmpty(bill.getEmail())){
failNum++;
@@ -426,5 +441,62 @@
return getBaseMapper().selectDetailByBillId(billId);
}
+ /**
+ * 收款、类型可能是现金、银行
+ * @param dto
+ * @return
+ */
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public Boolean cashPay(CachPayDto dto) {
+ TBill back = null;
+ TBankFlow bankflow = null;
+ if (dto.getPayType()==1){
+ bankflow = tBankFlowService.getById(dto.getTBankFlow().getId());
+ TBillDto bill = getDetailByBillId(dto.getBillId());
+ if (bankflow.getRemainingMoney().compareTo(BigDecimal.ZERO)<=0){
+ throw new ServiceException("该流水已无可抵扣剩余金额");
+ }
+ if (bankflow.getRemainingMoney().compareTo(dto.getAmount())<0){
+ throw new ServiceException("实付金额不能高于于流水可抵扣剩余金额");
+ }
+ //如果实付金额大于欠费金额
+ if (dto.getAmount().compareTo(bill.getOutstandingMoney())>=0){
+ throw new ServiceException("实付金额不能高于该账单欠费金额");
+ }
+ }
+ TBillDto bill = getDetailByBillId(dto.getBillId());
+ TBill billSave = new TBill();
+ billSave.setId(bill.getId());
+ billSave.setPayFeesMoney(dto.getAmount());
+ billSave.setBankSerialNumber(dto.getTBankFlow().getBankSerialNumber());
+ billSave.setPayFeesTime(dto.getTBankFlow().getPayTime());
+ billSave.setVoucher(dto.getVoucher());
+ billSave.setPayFeesType(2);
+ back = lockAndUpdateInfo(billSave, 2);
+ if (dto.getPayType()==1){
+ //更新银行流水的已抵扣金额和剩余可抵扣金额
+ TBankFlow saveBankFlow = new TBankFlow();
+ saveBankFlow.setId(bankflow.getId());
+ saveBankFlow.setDeductionMoney(bankflow.getDeductionMoney().add(dto.getAmount()));
+ saveBankFlow.setRemainingMoney(bankflow.getRemainingMoney().subtract(dto.getAmount()));
+ tBankFlowService.updateById(saveBankFlow);
+ }
+ //存流水
+ TFlowManagement save = new TFlowManagement();
+ save.setPayType(3);
+ save.setPayer(dto.getPayer());
+ save.setPayTime(dto.getTBankFlow().getPayTime());
+ save.setBankSerialNumber(dto.getTBankFlow().getBankSerialNumber());
+ save.setFlowType(dto.getPayType()==1?2:1);
+ save.setPaymentBillId(back.getId());
+ save.setDeductionMoney(back.getDeductionMoney());
+ save.setFlowMoney(dto.getAmount());
+ save.setRemainingMoney(back.getOutstandingMoney());
+ save.setPreOutstand(back.getPreOutstand());
+ tFlowManagementService.save(save);
+ return true;
+ }
+
}
--
Gitblit v1.7.1