From 5cc9063aafa13e75d0fd918bd968c59f61525e2d Mon Sep 17 00:00:00 2001 From: “djh” <“3298565835@qq.com”> Date: 星期四, 23 一月 2025 14:01:59 +0800 Subject: [PATCH] 煤矿缴费 --- exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayServiceImpl.java | 97 +++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 86 insertions(+), 11 deletions(-) diff --git a/exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayServiceImpl.java b/exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayServiceImpl.java index 1f1cd8b..4043ca1 100644 --- a/exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayServiceImpl.java +++ b/exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayServiceImpl.java @@ -7,35 +7,37 @@ import com.gkhy.exam.pay.dto.req.CoalPayReq; import com.gkhy.exam.pay.dto.req.CoalPayStudentReq; import com.gkhy.exam.pay.dto.req.CoalPayTypeReq; -import com.gkhy.exam.pay.entity.CoalCategory; -import com.gkhy.exam.pay.entity.CoalPay; -import com.gkhy.exam.pay.entity.CoalPayCategory; -import com.gkhy.exam.pay.entity.CoalPayStudent; +import com.gkhy.exam.pay.entity.*; import com.gkhy.exam.pay.mapper.CoalCategoryMapper; import com.gkhy.exam.pay.mapper.CoalPayCategoryMapper; import com.gkhy.exam.pay.mapper.CoalPayMapper; import com.gkhy.exam.pay.service.CoalPayService; import com.gkhy.exam.pay.service.CoalPayStudentService; +import com.gkhy.exam.pay.utils.PayUtils; +import com.gkhy.exam.pay.utils.ResultVo; import com.ruoyi.common.constant.ResultConstants; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysDept; -import com.ruoyi.common.core.domain.entity.SysUser; -import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.exception.BusinessException; +import com.ruoyi.common.utils.RandomUtil; import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.mapper.SysDeptMapper; -import javafx.print.Collation; -import org.aspectj.weaver.loadtime.Aj; +import org.aspectj.lang.reflect.UnlockSignature; +import org.redisson.api.RLock; +import org.redisson.api.RedissonClient; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; +import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Date; import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Lock; import java.util.stream.Collectors; @Service @@ -52,6 +54,11 @@ private CoalCategoryMapper coalCategoryMapper; @Autowired private CoalPayStudentService coalPayStudentService; + + @Autowired + private RedissonClient redissonClient; + + /** @@ -168,9 +175,12 @@ //个人查询缴费 @Override - public List<CoalPayStudentRep> selectCoalPay(CoalPayStudentReq coalPayStudent) { + public List<CoalPayStudentRep> selectCoalPay(String idcard,String phone) { + CoalPayStudentReq coalPayStudentReq = new CoalPayStudentReq(); + coalPayStudentReq.setIdCard(idcard); + coalPayStudentReq.setPhone(phone); //查询个人需要缴费 - List<CoalPayStudent> coalPayStudents = coalPayStudentService.selectbyIdcard(coalPayStudent); + List<CoalPayStudent> coalPayStudents = coalPayStudentService.selectbyIdcard(coalPayStudentReq); List<CoalPayStudentRep> coalPayStudentReps = new ArrayList<>(); for (CoalPayStudent payStudent : coalPayStudents) { //封装学生基础信息 @@ -205,4 +215,69 @@ } return coalPayMapper.updateByPayId(coalPayTypeReq); } + + @Override + public String personPayMoney(Long coalPayId, Long studentId) { + CoalPayStudent coalPayStudent = coalPayStudentService.selectbyId(studentId); + CoalPay coalPay = coalPayMapper.selectById(coalPayId); + List<CoalCategory> coalCategories = coalCategoryMapper.selectByCoalPayId(coalPayId); + CoalTicket coalTicket = coalCategoryMapper.selectCoalTicket(); + + PayReqData payReqData = new PayReqData(); + payReqData.setOrderNo(RandomUtil.generateOrderNumber()); + payReqData.setMoney(coalPay.getAmount()); + payReqData.setAmount(1); + payReqData.setPayerName(coalPayStudent.getName()); + payReqData.setCertNo(coalPayStudent.getIdCard()); + payReqData.setPayerType(1); + payReqData.setInvoiceSocialCode(coalTicket.getTicketCompanyCode()); + payReqData.setHandlingPerson(coalTicket.getDrawer()); + payReqData.setChecker(coalTicket.getCheck()); + payReqData.setEnterCode(coalTicket.getCompanyCode()); + payReqData.setDesc(coalPay.getBatchName()); + + PayReqData.Feedata feedata = new PayReqData.Feedata(); + List<PayReqData.Feedata> feedatas = new ArrayList<>(); + for (CoalCategory coalCategory : coalCategories) { + feedata.setAmount(1); + feedata.setPrice(coalCategory.getAmount()); + feedata.setBusCode(coalCategory.getBusinessCode()); + feedatas.add(feedata); + } + payReqData.setFeeDatas(feedatas); + + CoalPayStudent payStudent = new CoalPayStudent(); + + RLock lock = redissonClient.getLock("SWSPKMAS_PAY_PERSON"); + try { + lock.lock(10, TimeUnit.SECONDS); + if (coalPayStudent.getGovPayStatus()!=0){ + throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"请勿重复发起支付"); + } + if (StringUtils.isEmpty(coalPayStudent.getPayCode())){ + + } + + + ResultVo resultVo = PayUtils.sendApiPost(payReqData); + if (resultVo.getRespcode().equals("BUS0000")){ + payStudent.setId(studentId); + payStudent.setOrderId(resultVo.getRespdata().getOrderNo()); + payStudent.setGovPayStatus(1); + payStudent.setPayCode(resultVo.getRespdata().getBillNo()); + coalPayStudentService.updateByCoalPayStudent(payStudent); + return resultVo.getRespdata().getBillNo(); + }else { + throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"发起支付失败,请稍后重试"); + } + }catch (BusinessException e){ + throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"请稍后重试"); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + if(lock.isLocked()){ + lock.unlock(); + } + } + } } -- Gitblit v1.9.2