| | |
| | | if (coalPayTypeReq.getPayPersonType() != null && byId.getPayPersonType() == 2) { |
| | | throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "已为团体缴费,不可更改"); |
| | | } |
| | | return coalPayMapper.updateByPayId(coalPayTypeReq); |
| | | int i = coalPayMapper.updateByPayId(coalPayTypeReq); |
| | | if (i>0){ |
| | | CoalPayStudent coalPayStudent = new CoalPayStudent(); |
| | | coalPayStudent.setCoalPayId(coalPayTypeReq.getCoalPayId()); |
| | | coalPayStudent.setPayType(2); |
| | | coalPayStudentService.updateByCoalPayId(coalPayStudent); |
| | | } |
| | | return i; |
| | | } |
| | | |
| | | @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(); |
| | | CoalPayStudent payStudent = new CoalPayStudent(); |
| | | |
| | | RLock lock = redissonClient.getLock("SWSPKMAS_PAY_PERSON_" + coalPayId); |
| | | try { |
| | | lock.lock(10, TimeUnit.SECONDS); |
| | | |
| | | CoalPayStudent coalPayStudent = coalPayStudentService.selectbyId(studentId); |
| | | CoalPay coalPay = coalPayMapper.selectById(coalPayId); |
| | | List<CoalCategory> coalCategories = coalCategoryMapper.selectByCoalPayId(coalPayId); |
| | | CoalTicket coalTicket = coalCategoryMapper.selectCoalTicket(); |
| | | if (coalPayStudent==null){ |
| | | throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"缴费学员不存在"); |
| | | } |
| | | if (coalPay==null){ |
| | | throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"未找到相关缴费信息"); |
| | | } |
| | | if (coalPayStudent.getPayStatus()==1){ |
| | | throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"请勿重新缴费"); |
| | | } |
| | | |
| | | PayReqData payReqData = fillData(coalPayStudent,coalPay,coalCategories,coalTicket); |
| | | |
| | | 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().getOrderId(); |
| | | } else { |
| | | throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "发起支付失败,请稍后重试"); |
| | | } |
| | | } catch (BusinessException e) { |
| | | throw new RuntimeException(e); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } finally { |
| | | if (lock.isLocked()) { |
| | | lock.unlock(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private PayReqData fillData(CoalPayStudent coalPayStudent, CoalPay coalPay, List<CoalCategory> coalCategories, CoalTicket coalTicket) { |
| | | PayReqData payReqData = new PayReqData(); |
| | | payReqData.setOrderNo(RandomUtil.generateOrderNumber(coalPayId, "CO")); |
| | | payReqData.setOrderNo(RandomUtil.generateOrderNumber(coalPay.getId(), "CO")); |
| | | payReqData.setMoney(coalPay.getAmount()); |
| | | payReqData.setAmount(1); |
| | | payReqData.setPayerName(coalPayStudent.getName()); |
| | |
| | | feedatas.add(feedata); |
| | | } |
| | | payReqData.setFeeDatas(feedatas); |
| | | return payReqData; |
| | | |
| | | CoalPayStudent payStudent = new CoalPayStudent(); |
| | | |
| | | RLock lock = redissonClient.getLock("SWSPKMAS_PAY_PERSON_" + coalPayId); |
| | | 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(); |
| | | } |
| | | } |
| | | } |
| | | } |