| | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private TTechnicalTitleService tTechnicalTitleService; |
| | | @Resource |
| | | private TTitleMajorService majorService; |
| | | @Resource |
| | | private TLevelService levelService; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | |
| | | public R<Page<TInformation>> list(@RequestBody InformationQuery informationQuery) { |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Page<TInformation> page; |
| | | if (informationQuery.getSortType()==1){ |
| | | page = informationService.lambdaQuery() |
| | | .like(!StringUtils.isEmpty(informationQuery.getInformationName()), TInformation::getInformationName, informationQuery.getInformationName()) |
| | | .eq(informationQuery.getRegionId() != null, TInformation::getRegionId, informationQuery.getRegionId()) |
| | | .eq(informationQuery.getTechnicalId() != null, TInformation::getTechnicalId, informationQuery.getTechnicalId()) |
| | | .eq(informationQuery.getMajorId() != null, TInformation::getMajorId, informationQuery.getMajorId()) |
| | | .eq(informationQuery.getLevel() != null, TInformation::getLevel, informationQuery.getLevel()) |
| | | .eq(informationQuery.getFree()!=null&&informationQuery.getFree() == 1, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .ne(informationQuery.getFree()!=null&&informationQuery.getFree() == 2, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .orderByDesc(TInformation::getCreateTime) |
| | | .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize())); |
| | | if(StringUtils.isEmpty(informationQuery.getProvinceName())){ |
| | | if (informationQuery.getSortType()==1){ |
| | | page = informationService.lambdaQuery() |
| | | .like(!StringUtils.isEmpty(informationQuery.getInformationName()), TInformation::getInformationName, informationQuery.getInformationName()) |
| | | .eq(informationQuery.getRegionId() != null, TInformation::getRegionId, informationQuery.getRegionId()) |
| | | .eq(informationQuery.getTechnicalId() != null, TInformation::getTechnicalId, informationQuery.getTechnicalId()) |
| | | .eq(informationQuery.getMajorId() != null, TInformation::getMajorId, informationQuery.getMajorId()) |
| | | .eq(informationQuery.getLevel() != null, TInformation::getLevel, informationQuery.getLevel()) |
| | | .eq(informationQuery.getFree()!=null&&informationQuery.getFree() == 1, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .ne(informationQuery.getFree()!=null&&informationQuery.getFree() == 2, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .orderByDesc(TInformation::getCreateTime) |
| | | .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize())); |
| | | }else { |
| | | page = informationService.lambdaQuery() |
| | | .like(!StringUtils.isEmpty(informationQuery.getInformationName()), TInformation::getInformationName, informationQuery.getInformationName()) |
| | | .eq(informationQuery.getRegionId() != null, TInformation::getRegionId, informationQuery.getRegionId()) |
| | | .eq(informationQuery.getTechnicalId() != null, TInformation::getTechnicalId, informationQuery.getTechnicalId()) |
| | | .eq(informationQuery.getMajorId() != null, TInformation::getMajorId, informationQuery.getMajorId()) |
| | | .eq(informationQuery.getLevel() != null, TInformation::getLevel, informationQuery.getLevel()) |
| | | .eq(informationQuery.getFree()!=null&&informationQuery.getFree() == 1, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .ne(informationQuery.getFree()!=null&&informationQuery.getFree() == 2, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .orderByDesc(TInformation::getCommitteeSort) |
| | | .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize())); |
| | | } |
| | | }else { |
| | | page = informationService.lambdaQuery() |
| | | .like(!StringUtils.isEmpty(informationQuery.getInformationName()), TInformation::getInformationName, informationQuery.getInformationName()) |
| | | .eq(informationQuery.getRegionId() != null, TInformation::getRegionId, informationQuery.getRegionId()) |
| | | .eq(informationQuery.getTechnicalId() != null, TInformation::getTechnicalId, informationQuery.getTechnicalId()) |
| | | .eq(informationQuery.getMajorId() != null, TInformation::getMajorId, informationQuery.getMajorId()) |
| | | .eq(informationQuery.getLevel() != null, TInformation::getLevel, informationQuery.getLevel()) |
| | | .eq(informationQuery.getFree()!=null&&informationQuery.getFree() == 1, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .ne(informationQuery.getFree()!=null&&informationQuery.getFree() == 2, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .orderByDesc(TInformation::getCommitteeSort) |
| | | .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize())); |
| | | List<TRegion> list; |
| | | // 查询省份下的市 |
| | | if(informationQuery.getProvinceName().equals("直辖市")){ |
| | | List<String> cityList = new ArrayList<>(); |
| | | cityList.add("北京市"); |
| | | cityList.add("天津市"); |
| | | cityList.add("重庆市"); |
| | | cityList.add("上海市"); |
| | | list = regionService.lambdaQuery().in(TRegion::getProvinceName, cityList).list(); |
| | | }else { |
| | | list = regionService.lambdaQuery().eq(TRegion::getProvinceName, informationQuery.getProvinceName()).list(); |
| | | } |
| | | List<Integer> ids = list.stream().map(TRegion::getId).collect(Collectors.toList()); |
| | | if (informationQuery.getSortType()==1){ |
| | | page = informationService.lambdaQuery() |
| | | .like(!StringUtils.isEmpty(informationQuery.getInformationName()), TInformation::getInformationName, informationQuery.getInformationName()) |
| | | .in( TInformation::getRegionId, ids) |
| | | .eq(informationQuery.getTechnicalId() != null, TInformation::getTechnicalId, informationQuery.getTechnicalId()) |
| | | .eq(informationQuery.getMajorId() != null, TInformation::getMajorId, informationQuery.getMajorId()) |
| | | .eq(informationQuery.getLevel() != null, TInformation::getLevel, informationQuery.getLevel()) |
| | | .eq(informationQuery.getFree()!=null&&informationQuery.getFree() == 1, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .ne(informationQuery.getFree()!=null&&informationQuery.getFree() == 2, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .orderByDesc(TInformation::getCreateTime) |
| | | .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize())); |
| | | }else { |
| | | page = informationService.lambdaQuery() |
| | | .like(!StringUtils.isEmpty(informationQuery.getInformationName()), TInformation::getInformationName, informationQuery.getInformationName()) |
| | | .in( TInformation::getRegionId, ids) |
| | | .eq(informationQuery.getTechnicalId() != null, TInformation::getTechnicalId, informationQuery.getTechnicalId()) |
| | | .eq(informationQuery.getMajorId() != null, TInformation::getMajorId, informationQuery.getMajorId()) |
| | | .eq(informationQuery.getLevel() != null, TInformation::getLevel, informationQuery.getLevel()) |
| | | .eq(informationQuery.getFree()!=null&&informationQuery.getFree() == 1, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .ne(informationQuery.getFree()!=null&&informationQuery.getFree() == 2, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .orderByDesc(TInformation::getCommitteeSort) |
| | | .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize())); |
| | | } |
| | | } |
| | | Set<Long> cacheSet = redisCache.getCacheSet("INFORMATION:" + userId); |
| | | |
| | | Set<Long> cacheSet = redisCache.getCacheSet("INFORMATION:" + userId); |
| | | List<TRegion> regions = regionService.lambdaQuery().list(); |
| | | List<TTechnicalTitle> tTechnicalTitles = tTechnicalTitleService.lambdaQuery().list(); |
| | | List<TTitleMajor> tTitleMajors = majorService.lambdaQuery().list(); |
| | | for (TInformation record : page.getRecords()) { |
| | | TRegion byId = regionService.getById(record.getRegionId()); |
| | | record.setRegionName(byId.getProvinceName()+"-"+byId.getName()); |
| | | TTechnicalTitle byId1 = tTechnicalTitleService.getById(record.getTechnicalId()); |
| | | TTitleMajor byId2 = majorService.getById(record.getMajorId()); |
| | | record.setTechnicalName(byId1.getTitileName()+"-"+byId2.getMajorName()); |
| | | TRegion region = regions.stream().filter(e -> e.getId().equals(record.getRegionId())).findFirst().orElse(null); |
| | | TTechnicalTitle tTechnicalTitle = tTechnicalTitles.stream().filter(e -> e.getId().equals(record.getTechnicalId())).findFirst().orElse(null); |
| | | TTitleMajor tTitleMajor = tTitleMajors.stream().filter(e -> e.getId().equals(record.getMajorId())).findFirst().orElse(null); |
| | | record.setRegionName(region.getProvinceName()+"-"+region.getName()); |
| | | record.setTechnicalName(tTechnicalTitle.getTitileName()+"-"+tTitleMajor.getMajorName()); |
| | | if (cacheSet!=null){ |
| | | if (cacheSet.contains(record.getId())){ |
| | | record.setIsCollect(1); |
| | |
| | | @ApiOperation(value = "下载累计次数",tags = {"web资料查询"}) |
| | | @PostMapping(value = "/downland") |
| | | public R downland(@RequestParam Long id) { |
| | | TInformation byId = informationService.getById(id); |
| | | byId.setDownlandNum(byId.getDownlandNum()+1); |
| | | informationService.updateById(byId); |
| | | TInformation information = informationService.getById(id); |
| | | information.setDownlandNum(information.getDownlandNum()+1); |
| | | informationService.updateById(information); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | TInformation record = informationService.getById(id); |
| | | Set<Long> cacheSet = redisCache.getCacheSet("INFORMATION:" + userId); |
| | | |
| | | TRegion byId = regionService.getById(record.getRegionId()); |
| | | record.setRegionName(byId.getProvinceName()+"-"+byId.getName()); |
| | | TTechnicalTitle byId1 = tTechnicalTitleService.getById(record.getTechnicalId()); |
| | | TTitleMajor byId2 = majorService.getById(record.getMajorId()); |
| | | record.setTechnicalName(byId1.getTitileName()+"-"+byId2.getMajorName()); |
| | | TRegion region = regionService.getById(record.getRegionId()); |
| | | record.setRegionName(region.getProvinceName()+"-"+region.getName()); |
| | | TTechnicalTitle technicalTitle = tTechnicalTitleService.getById(record.getTechnicalId()); |
| | | TTitleMajor titleMajor = majorService.getById(record.getMajorId()); |
| | | record.setTechnicalName(technicalTitle.getTitileName()+"-"+titleMajor.getMajorName()+"-"+record.getLevel()); |
| | | if (cacheSet!=null){ |
| | | if (cacheSet.contains(record.getId())){ |
| | | record.setIsCollect(1); |
| | |
| | | @PostMapping(value = "/create") |
| | | public R buy( @RequestParam Long id) throws AlipayApiException { |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | TInformation byId = informationService.getById(id); |
| | | TInformation information = informationService.getById(id); |
| | | String code = "ZL" + WeChatUtil.generateTradeNumber(); |
| | | TOrder order = new TOrder(); |
| | | order.setCode(code); |
| | | order.setUserId(userId); |
| | | order.setGoodType(2); |
| | | order.setGoodId(id); |
| | | order.setOrderAmount(byId.getInformationPrice()); |
| | | order.setPaymentAmount(byId.getInformationPrice()); |
| | | order.setOrderAmount(information.getInformationPrice()); |
| | | order.setPaymentAmount(information.getInformationPrice()); |
| | | |
| | | if (byId.getInformationPrice().compareTo(new BigDecimal(0))==0){ |
| | | if (information.getInformationPrice().compareTo(new BigDecimal(0))==0){ |
| | | order.setPaymentStatus(2); |
| | | |
| | | } |
| | |
| | | @ApiOperation(value = "购买资料",tags = {"web资料查询"}) |
| | | @PostMapping(value = "/buy") |
| | | public R buy(@RequestParam Integer type, @RequestParam Long orderId) throws AlipayApiException { |
| | | TOrder byId = orderService.getById(orderId); |
| | | int i = byId.getPaymentAmount().multiply(BigDecimal.valueOf(100)).intValue(); |
| | | TOrder byId1 = orderService.getById(orderId); |
| | | TOrder order = orderService.getById(orderId); |
| | | int i = order.getPaymentAmount().multiply(BigDecimal.valueOf(100)).intValue(); |
| | | TOrder tOrder = orderService.getById(orderId); |
| | | if (type == 1) { |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | |
| | | com.wechat.pay.java.service.payments.nativepay.model.PrepayRequest prepayRequest = new com.wechat.pay.java.service.payments.nativepay.model.PrepayRequest(); |
| | | prepayRequest.setAppid(weChatConfig.appId); |
| | | prepayRequest.setMchid(weChatConfig.merchantId); |
| | | prepayRequest.setOutTradeNo(byId1.getCode()); |
| | | prepayRequest.setOutTradeNo(tOrder.getCode()); |
| | | prepayRequest.setDescription("购买资料"); |
| | | prepayRequest.setNotifyUrl("http://www.zhipingwang.com.cn:8081/call-back/buy"); |
| | | prepayRequest.setNotifyUrl("https://0ifzoxq2516g.guyubao.com/call-back/buy"); |
| | | com.wechat.pay.java.service.payments.nativepay.model.Amount amount = new com.wechat.pay.java.service.payments.nativepay.model.Amount(); |
| | | amount.setTotal(i); |
| | | prepayRequest.setAmount(amount); |
| | |
| | | } |
| | | return null; |
| | | } else { |
| | | String qrCode = AlipayTradePagePay.pay("购买资料",byId1.getCode(),byId.getPaymentAmount().toString()); |
| | | String qrCode = AlipayTradePagePay.pay("购买资料",tOrder.getCode(),order.getPaymentAmount().toString()); |
| | | |
| | | PayDto payDto = new PayDto(); |
| | | payDto.setOrderId(orderId); |
| | |
| | | while (num <= 30) { |
| | | int min = 2000; |
| | | Thread.sleep(min); |
| | | Boolean check = AlipayTradeQuery.check(byId.getCode()); |
| | | Boolean check = AlipayTradeQuery.check(order.getCode()); |
| | | if (check){ |
| | | byId.setPaymentStatus(2); |
| | | byId.setPaymentType(2); |
| | | byId.setPayTime(LocalDateTime.now()); |
| | | orderService.updateById(byId); |
| | | order.setPaymentStatus(2); |
| | | order.setPaymentType(2); |
| | | order.setPayTime(LocalDateTime.now()); |
| | | orderService.updateById(order); |
| | | }else { |
| | | num++; |
| | | } |