批量缴费接口开发

This commit is contained in:
hejinbo
2023-11-21 14:53:07 +08:00
parent b979d8a4eb
commit 0b94672e58
7 changed files with 124 additions and 14 deletions
@@ -6,7 +6,6 @@ import com.ruoyi.wisdomarbitrate.domain.dto.CaseConfirmPayDTO;
import com.ruoyi.wisdomarbitrate.service.ICasePaymentService;
import com.ruoyi.wisdomarbitrate.domain.dto.CasePayDTO;
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.*;
@@ -52,4 +51,13 @@ public class CasePaymentController {
public AjaxResult confirmPayment(@Validated @RequestBody CaseApplication caseApplication) {
return paymentService.confirmPayment(caseApplication);
}
/**
* 缴费列表查询
* @param casePayDTO
* @return
*/
@GetMapping("/list")
public AjaxResult casePayList(CasePayDTO casePayDTO) {
return paymentService.casePayList(casePayDTO);
}
}
@@ -0,0 +1,23 @@
package com.ruoyi.wisdomarbitrate.domain;
import com.ruoyi.common.annotation.Excel;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class CaseApplicationPay {
/** 案件编号 */
private String caseNum;
/** 案件标的 */
private BigDecimal caseSubjectAmount;
/** 仲裁应缴费用 */
private BigDecimal feePayable;
/** 案件状态 */
private Integer caseStatus;
/**申请人 */
private String caseAppName;
/**被申请人 */
private String caseResName;
}
@@ -13,7 +13,7 @@ public class CasePayDTO {
/**
* 案件id
*/
private Long caseId;
private List<Long> caseIds;
/**
* 订单金额 单位:分
@@ -0,0 +1,25 @@
package com.ruoyi.wisdomarbitrate.domain.vo;
import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
import com.ruoyi.wisdomarbitrate.domain.CaseApplicationPay;
import lombok.Data;
import java.util.List;
@Data
public class CasePayListVO {
/**
* 订单总金额 单位:分
*/
private int totalFee;
/**
* 案件总条数
*/
private int CaseTotal;
/**
* 案件订单列表
*/
private List<CaseApplicationPay> caseApplicationList;
}
@@ -20,4 +20,8 @@ public interface ICasePaymentService {
* @return
*/
AjaxResult confirmPay(CaseConfirmPayDTO payDTO);
AjaxResult casePayList(CasePayDTO casePayDTO);
}
@@ -11,7 +11,9 @@ import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.wisdomarbitrate.domain.*;
import com.ruoyi.wisdomarbitrate.domain.dto.CaseConfirmPayDTO;
import com.ruoyi.wisdomarbitrate.domain.vo.CasePayListVO;
import com.ruoyi.wisdomarbitrate.mapper.*;
import com.ruoyi.wisdomarbitrate.service.ICaseApplicationService;
import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
import com.ruoyi.common.utils.SmsUtils;
import com.ruoyi.dto.PayRequest;
@@ -22,6 +24,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -42,12 +46,15 @@ public class CasePaymentServiceImpl implements ICasePaymentService {
public CasePaymentServiceImpl(ElegentPay elegentPay
, CaseApplicationMapper caseApplicationMapper
, CasePaymentRecordMapper casePaymentRecordMapper
, CaseAffiliateMapper caseAffiliateMapper) {
, CaseAffiliateMapper caseAffiliateMapper
) {
this.elegentPay = elegentPay;
this.caseApplicationMapper = caseApplicationMapper;
this.casePaymentRecordMapper = casePaymentRecordMapper;
this.caseAffiliateMapper = caseAffiliateMapper;
}
@Autowired
private ICaseApplicationService caseApplicationService;
@Override
@Transactional
@@ -60,16 +67,22 @@ public class CasePaymentServiceImpl implements ICasePaymentService {
if (response.getCode_url() == null) {
return AjaxResult.error();
}
//缴费记录表里新增数据
CasePaymentRecord casePaymentRecord = new CasePaymentRecord();
casePaymentRecord.setCaseId(casePayDTO.getCaseId());
casePaymentRecord.setOrderNumber(payRequest.getOrderSn());
casePaymentRecord.setPaymentStatus(0);
casePaymentRecord.setCreateTime(new Date());
int count = casePaymentRecordMapper.saveRecord(casePaymentRecord);
if (count < 1) {
List<Long> caseIds = casePayDTO.getCaseIds();
if (CollectionUtil.isEmpty(caseIds)) {
return AjaxResult.error("请检查参数是否有误");
}
for (Long caseId : caseIds) {
//缴费记录表里新增数据
CasePaymentRecord casePaymentRecord = new CasePaymentRecord();
casePaymentRecord.setCaseId(caseId);
casePaymentRecord.setOrderNumber(payRequest.getOrderSn());
casePaymentRecord.setPaymentStatus(0);
casePaymentRecord.setCreateTime(new Date());
int count = casePaymentRecordMapper.saveRecord(casePaymentRecord);
if (count < 1) {
return AjaxResult.error("请检查参数是否有误");
}
}
return AjaxResult.success(response);
}
@@ -151,9 +164,9 @@ public class CasePaymentServiceImpl implements ICasePaymentService {
String content = "尊敬的" + name + "用户,您的" + caseName + "案件" + caseNum + "已成功受理,请点击链接:https://miniapp-3gpama6l759911ef-1321289474.tcloudbaseapp.com/jump-mp.html 选择是否应诉。如非本人操作,请忽略本短信";
smsSendRecord.setSendContent(content);
smsSendRecord.setCreateBy(getUsername());
if (aBoolean){
if (aBoolean) {
smsSendRecord.setSendStatus(1);
}else {
} else {
smsSendRecord.setSendStatus(0);
}
smsRecordMapper.saveSmsSendRecord(smsSendRecord);
@@ -211,5 +224,42 @@ public class CasePaymentServiceImpl implements ICasePaymentService {
return AjaxResult.success("确认缴费失败");
}
@Override
public AjaxResult casePayList(CasePayDTO casePayDTO) {
//参数校验
List<Long> caseIds = casePayDTO.getCaseIds();
if (caseIds == null || caseIds.size() == 0) {
return null;
}
BigDecimal totalCost = new BigDecimal(0);
BigDecimal sum =totalCost;
CasePayListVO listVO = new CasePayListVO();
listVO.setCaseTotal(caseIds.size());
List<CaseApplicationPay> caseApplicationList =new ArrayList<>();
for (Long caseId : caseIds) {
CaseApplication caseApplication = new CaseApplication();
CaseApplicationPay caseApplicationPay = new CaseApplicationPay();
caseApplication.setId(caseId);
CaseApplication caseApplication1 = caseApplicationService.selectCaseApplication(caseApplication);
BigDecimal feePayable = caseApplication1.getFeePayable();
feePayable = feePayable.multiply(new BigDecimal(100));
sum = sum.add(feePayable);
listVO.setTotalFee(sum.intValue());
caseApplicationPay.setCaseAppName(caseApplication1.getApplicantName());
caseApplicationPay.setCaseResName(caseApplication1.getRespondentName());
caseApplicationPay.setCaseNum(caseApplication1.getCaseNum());
caseApplicationPay.setCaseStatus(caseApplication1.getCaseStatus());
caseApplicationPay.setCaseSubjectAmount(caseApplication1.getCaseSubjectAmount());
caseApplicationPay.setFeePayable(caseApplication1.getFeePayable());
caseApplicationList.add(caseApplicationPay);
listVO.setCaseApplicationList(caseApplicationList);
}
if (sum.compareTo(BigDecimal.ZERO) == 0) {
return AjaxResult.error("没有可支付的费用");
}
return AjaxResult.success(listVO);
}
}
@@ -419,7 +419,7 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
String prefix = "/profile";
int startIndex = fileName.indexOf(prefix);
startIndex += prefix.length();
String annexPath = "home/ruoyi/uploadPath" + fileName.substring(startIndex);
String annexPath = "uploadPath" + fileName.substring(startIndex);
templateManage.setTemOrigPath(annexPath);
String format = getFileExtension(fileName);
templateManage.setTemFormat(format);