From a50c7d1497d7f707b79597553d9db978ba7e9dd5 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期五, 13 十二月 2024 08:59:12 +0800
Subject: [PATCH] 修改

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TInformationController.java |   81 ++++++++++++++++++++++++++++++++++------
 1 files changed, 69 insertions(+), 12 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TInformationController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TInformationController.java
index 1866ba8..da277cf 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TInformationController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TInformationController.java
@@ -31,9 +31,11 @@
 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>
@@ -54,6 +56,8 @@
     private TTechnicalTitleService tTechnicalTitleService;
     @Resource
     private TTitleMajorService majorService;
+    @Resource
+    private TLevelService levelService;
     @Resource
     private TokenService tokenService;
     @Resource
@@ -95,17 +99,70 @@
     @PostMapping(value = "/list")
     public R<Page<TInformation>> list(@RequestBody InformationQuery informationQuery) {
         Long userId = tokenService.getLoginUser().getUserId();
+        Page<TInformation> page;
+        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 {
+            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()));
+            }
+        }
 
-        Page<TInformation> 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()));
         Set<Long> cacheSet = redisCache.getCacheSet("INFORMATION:" + userId);
 
         for (TInformation record : page.getRecords()) {
@@ -163,7 +220,7 @@
         record.setRegionName(byId.getProvinceName()+"-"+byId.getName());
         TTechnicalTitle byId1 = tTechnicalTitleService.getById(record.getTechnicalId());
         TTitleMajor byId2 = majorService.getById(record.getMajorId());
-        record.setTechnicalName(byId1.getTitileName()+"-"+byId2.getMajorName());
+        record.setTechnicalName(byId1.getTitileName()+"-"+byId2.getMajorName()+"-"+record.getLevel());
         if (cacheSet!=null){
             if (cacheSet.contains(record.getId())){
                 record.setIsCollect(1);
@@ -217,7 +274,7 @@
             prepayRequest.setMchid(weChatConfig.merchantId);
             prepayRequest.setOutTradeNo(byId1.getCode());
             prepayRequest.setDescription("购买资料");
-            prepayRequest.setNotifyUrl("http://www.zhipingwang.com.cn:8081/call-back/buy");
+            prepayRequest.setNotifyUrl("http://vwpmxwbhv59i.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);

--
Gitblit v1.7.1