| | |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.mapper.SysDeptMapper; |
| | | import org.aspectj.lang.reflect.UnlockSignature; |
| | | import org.redisson.api.RLock; |
| | | import org.redisson.api.RedissonClient; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | 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 |
| | |
| | | @Autowired |
| | | private RedissonClient redissonClient; |
| | | |
| | | |
| | | @Autowired |
| | | private PayUtils payUtils; |
| | | |
| | | |
| | | /** |
| | | * 缴费管理列表 |
| | | * |
| | | * @param coalPay |
| | | * @return |
| | | */ |
| | |
| | | List<CoalPay> coalPays = coalPayMapper.selectCoalPayList(coalPay); |
| | | for (CoalPay pay : coalPays) { |
| | | CoalPayRepDto coalPayRepDto = new CoalPayRepDto(); |
| | | BeanUtils.copyProperties(pay,coalPayRepDto); |
| | | BeanUtils.copyProperties(pay, coalPayRepDto); |
| | | //部门数据 |
| | | SysDept sysDept = sysDeptMapper.selectDeptById(pay.getDeptId()); |
| | | coalPayRepDto.setDeptName(sysDept.getDeptName()); |
| | |
| | | |
| | | //基本数据 |
| | | CoalPay coalPay = coalPayMapper.selectById(id); |
| | | BeanUtils.copyProperties(coalPay,coalPayRepDto); |
| | | BeanUtils.copyProperties(coalPay, coalPayRepDto); |
| | | //考点名称 |
| | | SysDept sysDept = sysDeptMapper.selectDeptById(coalPay.getDeptId()); |
| | | coalPayRepDto.setDeptName(sysDept.getDeptName()); |
| | |
| | | @Override |
| | | public int insertCoalPay(CoalPayDto coalPayDto) { |
| | | CoalPay coalPay = new CoalPay(); |
| | | BeanUtils.copyProperties(coalPayDto,coalPay); |
| | | BeanUtils.copyProperties(coalPayDto, coalPay); |
| | | coalPay.setCreateBy(SecurityUtils.getUsername()); |
| | | coalPay.setCreateTime(new Date()); |
| | | int insert = coalPayMapper.insertBath(coalPay); |
| | | if (CollectionUtils.isEmpty(coalPayDto.getCoalPayCategoryies())){ |
| | | throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"工种类别不能为空"); |
| | | if (CollectionUtils.isEmpty(coalPayDto.getCoalPayCategoryies())) { |
| | | throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "工种类别不能为空"); |
| | | } |
| | | List<CoalPayCategory> coalPayCategories = coalPayDto.getCoalPayCategoryies(); |
| | | for (CoalPayCategory coalPayCategory : coalPayCategories) { |
| | |
| | | |
| | | /** |
| | | * 修改缴费信息 |
| | | * |
| | | * @param coalPayDto |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int updateCoalPay(CoalPayDto coalPayDto) { |
| | | CoalPay coalPay = new CoalPay(); |
| | | BeanUtils.copyProperties(coalPayDto,coalPay); |
| | | BeanUtils.copyProperties(coalPayDto, coalPay); |
| | | coalPay.setUpdateBy(SecurityUtils.getUsername()); |
| | | coalPay.setUpdateTime(new Date()); |
| | | int i = coalPayMapper.updateCoalPayById(coalPay); |
| | | int update = coalPayCategoryMapper.deleteByCoalPayId(coalPayDto.getId()); |
| | | if (update>0){ |
| | | if (update > 0) { |
| | | List<CoalPayCategory> coalPayCategories = coalPayDto.getCoalPayCategoryies(); |
| | | for (CoalPayCategory coalPayCategory : coalPayCategories) { |
| | | coalPayCategory.setCoalPayId(coalPay.getId()); |
| | |
| | | @Override |
| | | public AjaxResult deleteCoalPayByIds(Long[] ids) { |
| | | for (Long id : ids) { |
| | | List<CoalPayStudent> coalPayStudents = coalPayStudentService.selectByCoalPayIdAndPayStatus(id,1); |
| | | if (!CollectionUtils.isEmpty(coalPayStudents)){ |
| | | throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR,"已有学员完成缴费,请勿删除"); |
| | | List<CoalPayStudent> coalPayStudents = coalPayStudentService.selectByCoalPayIdAndPayStatus(id, 1); |
| | | if (!CollectionUtils.isEmpty(coalPayStudents)) { |
| | | throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "已有学员完成缴费,请勿删除"); |
| | | } |
| | | } |
| | | int i = coalPayMapper.updateByIds(ids); |
| | | if (i>0){ |
| | | if (i > 0) { |
| | | return AjaxResult.success(); |
| | | } |
| | | return AjaxResult.error(); |
| | |
| | | |
| | | //个人查询缴费 |
| | | @Override |
| | | public List<CoalPayStudentRep> selectCoalPay(String idcard,String phone) { |
| | | public List<CoalPayStudentRep> selectCoalPay(String idcard, String phone) { |
| | | CoalPayStudentReq coalPayStudentReq = new CoalPayStudentReq(); |
| | | coalPayStudentReq.setIdCard(idcard); |
| | | coalPayStudentReq.setPhone(phone); |
| | |
| | | //查询对应批次以及批次包含工种类别 |
| | | CoalPay coalPay = coalPayMapper.selectById(payStudent.getCoalPayId()); |
| | | CoalPayRepDto coalPayRepDto = new CoalPayRepDto(); |
| | | BeanUtils.copyProperties(coalPay,coalPayRepDto); |
| | | BeanUtils.copyProperties(coalPay, coalPayRepDto); |
| | | //考点名称 |
| | | SysDept sysDept = sysDeptMapper.selectDeptById(coalPay.getDeptId()); |
| | | coalPayRepDto.setDeptName(sysDept.getDeptName()); |
| | |
| | | @Override |
| | | public int updateCoalPayType(CoalPayTypeReq coalPayTypeReq) { |
| | | CoalPay byId = coalPayMapper.selectById(coalPayTypeReq.getCoalPayId()); |
| | | if (coalPayTypeReq.getPayPersonType() != null && byId.getPayPersonType() == 2){ |
| | | throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"已为团体缴费,不可更改"); |
| | | if (coalPayTypeReq.getPayPersonType() != null && byId.getPayPersonType() == 2) { |
| | | throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "已为团体缴费,不可更改"); |
| | | } |
| | | return coalPayMapper.updateByPayId(coalPayTypeReq); |
| | | } |
| | |
| | | CoalTicket coalTicket = coalCategoryMapper.selectCoalTicket(); |
| | | |
| | | PayReqData payReqData = new PayReqData(); |
| | | payReqData.setOrderNo(RandomUtil.generateOrderNumber()); |
| | | payReqData.setOrderNo(RandomUtil.generateOrderNumber(coalPayId, "CO")); |
| | | payReqData.setMoney(coalPay.getAmount()); |
| | | payReqData.setAmount(1); |
| | | payReqData.setPayerName(coalPayStudent.getName()); |
| | |
| | | |
| | | CoalPayStudent payStudent = new CoalPayStudent(); |
| | | |
| | | RLock lock = redissonClient.getLock("SWSPKMAS_PAY_PERSON"); |
| | | 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 (coalPayStudent.getGovPayStatus() != 0) { |
| | | throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "请勿重复发起支付"); |
| | | } |
| | | if (StringUtils.isEmpty(coalPayStudent.getPayCode())){ |
| | | if (StringUtils.isEmpty(coalPayStudent.getPayCode())) { |
| | | |
| | | } |
| | | |
| | | |
| | | ResultVo resultVo = PayUtils.sendApiPost(payReqData); |
| | | if (resultVo.getRespcode().equals("BUS0000")){ |
| | | 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,"发起支付失败,请稍后重试"); |
| | | } else { |
| | | throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "发起支付失败,请稍后重试"); |
| | | } |
| | | }catch (BusinessException e){ |
| | | 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()){ |
| | | if (lock.isLocked()) { |
| | | lock.unlock(); |
| | | } |
| | | } |