Ver Fonte

Merge remote-tracking branch 'origin/dev' into dev

ouyang há 3 anos atrás
pai
commit
e5040630ed

+ 1 - 4
src/main/java/com/izouma/nineth/repo/CollectionRepo.java

@@ -166,10 +166,7 @@ public interface CollectionRepo extends JpaRepository<Collection, Long>, JpaSpec
             "and c.stock > 0 order by c.price limit 5) t", nativeQuery = true)
     String lowestPrice(String search);
 
-    @Query(value = "select c.original_price from collection_info c where c.name like ?1 " +
-            "and c.source = 'OFFICIAL' " +
-            "and c.original_price != null " +
-            "and c.stock > 0 order by c.original_price limit 1", nativeQuery = true)
+    @Query(value = "SELECT c.original_price FROM collection_info c WHERE c.NAME LIKE ?1 AND c.original_price != 'null' ORDER BY c.original_price LIMIT 1", nativeQuery = true)
     String lowestOriginPrice(String search);
 
     @Query(value = "select min(t.price) from (select c.price from collection_info c where c.name like ?1 " +

+ 4 - 0
src/main/java/com/izouma/nineth/service/CacheService.java

@@ -109,6 +109,10 @@ public class CacheService {
     public void clearPriceList() {
     }
 
+    @CacheEvict(value = "priceListVo", allEntries = true)
+    public void clearPriceListVo() {
+    }
+
     @CacheEvict(value = "news", key = "#id")
     public void clearNews(Long id) {
     }

+ 1 - 0
src/main/java/com/izouma/nineth/service/PriceListService.java

@@ -30,6 +30,7 @@ public class PriceListService {
     @RedisLock(value = "priceList", expire = 1, unit = TimeUnit.MINUTES)
     public void schedule() {
         cacheService.clearPriceList();
+        cacheService.clearPriceListVo();
         for (PriceList priceList : priceListRepo.findAll()) {
             priceList.setPrice(collectionRepo.lowestPrice(priceList.getSearch()));
             List<Long> ids = priceListRepo.lowest20(priceList.getSearch());

+ 10 - 4
src/main/java/com/izouma/nineth/web/PriceListController.java

@@ -91,17 +91,23 @@ public class PriceListController extends BaseController {
         }).collect(Collectors.toList());
     }
     @GetMapping("/priceListVo")
-    @Cacheable("priceList")
+    @Cacheable("priceListVo")
     public Result<PriceListVo> priceList() {
         ArrayList<PriceListVo> list = new ArrayList<>();
         List<PriceList> priceLists = priceListRepo.findAll();
         for (PriceList priceList : priceLists) {
-            list.add(new PriceListVo().builder()
+            PriceListVo priceListVo = new PriceListVo().builder()
                     .name(priceList.getName())
                     .img(priceList.getPic())
-                    .price(collectionRepo.lowestPrices(priceList.getSearch()))
+                    .price(priceList.getPrice())
                     .origin_price(collectionRepo.lowestOriginPrice(priceList.getSearch()))
-                    .build());
+                    .build();
+            if (StringUtils.isNotEmpty(priceList.getColumnA())) {
+                if (Double.parseDouble(priceList.getColumnA()) != 0) {
+                    priceListVo.setPrice(priceList.getColumnA());
+                }
+            }
+            list.add(priceListVo);
         }
          return Result.OK().success(list);
     }