Răsfoiți Sursa

Merge branch 'master' of http://git.izouma.com/xiongzhu/raex_back into dev-meta

sunkean 3 ani în urmă
părinte
comite
5d8d97ca63

+ 32 - 11
src/main/java/com/izouma/nineth/service/AssetService.java

@@ -927,16 +927,16 @@ public class AssetService {
             if (tags.isEmpty()) return new PageImpl<>(Collections.emptyList());
             if (tags.isEmpty()) return new PageImpl<>(Collections.emptyList());
             return assetRepo.findAll((Specification<Asset>) (root, query, criteriaBuilder) ->
             return assetRepo.findAll((Specification<Asset>) (root, query, criteriaBuilder) ->
                     query.distinct(true).where(
                     query.distinct(true).where(
-                                    // where userId=some id
-                                    criteriaBuilder.equal(root.get("userId"), userId),
-                                    // and (lockTo is null or (lockTo is not null and lockTo < now))
-                                    criteriaBuilder.or(criteriaBuilder.isNull(root.get("lockTo")),
-                                            criteriaBuilder.and(criteriaBuilder.isNotNull(root.get("lockTo")),
-                                                    criteriaBuilder.lessThan(root.get("lockTo"), LocalDateTime.now()))),
-                                    // and status = 'NORMAL'
-                                    criteriaBuilder.equal(root.get("status"), AssetStatus.NORMAL),
-                                    // and has some tagId
-                                    root.join("tags").get("id").in(tags.stream().map(Tag::getId).toArray()))
+                            // where userId=some id
+                            criteriaBuilder.equal(root.get("userId"), userId),
+                            // and (lockTo is null or (lockTo is not null and lockTo < now))
+                            criteriaBuilder.or(criteriaBuilder.isNull(root.get("lockTo")),
+                                    criteriaBuilder.and(criteriaBuilder.isNotNull(root.get("lockTo")),
+                                            criteriaBuilder.lessThan(root.get("lockTo"), LocalDateTime.now()))),
+                            // and status = 'NORMAL'
+                            criteriaBuilder.equal(root.get("status"), AssetStatus.NORMAL),
+                            // and has some tagId
+                            root.join("tags").get("id").in(tags.stream().map(Tag::getId).toArray()))
                             .getRestriction(), pageable);
                             .getRestriction(), pageable);
         } else {
         } else {
             return assetRepo.findByUserIdAndStatusAndCompanyIdAndNameLike(userId, AssetStatus.NORMAL, companyId,
             return assetRepo.findByUserIdAndStatusAndCompanyIdAndNameLike(userId, AssetStatus.NORMAL, companyId,
@@ -1093,6 +1093,25 @@ public class AssetService {
         return royalties;
         return royalties;
     }
     }
 
 
+    public double getServicecharge(double servicecharge, Long userId) {
+//        if (servicecharge == 3) {
+//            return 3;
+//        }
+        LongArrayConverter converter = new LongArrayConverter();
+//        String discountMinter = sysConfigService.getString("discount_minter");
+//        List<Long> minterIds = converter.convertToEntityAttribute(discountMinter);
+//        if (minterIds.contains(minterId)) {
+        String discountCollection = sysConfigService.getString("discount_charge");
+        List<Long> collectionIds = converter.convertToEntityAttribute(discountCollection);
+        Long assetId = assetRepo.findDiscount(userId, collectionIds);
+        if (ObjectUtils.isNotEmpty(assetId)) {
+            return 3;
+        }
+//        }
+        return servicecharge;
+    }
+
+
     @Async
     @Async
     public void hcChain() throws ExecutionException, InterruptedException {
     public void hcChain() throws ExecutionException, InterruptedException {
         new ForkJoinPool(1000).submit(() -> {
         new ForkJoinPool(1000).submit(() -> {
@@ -1190,7 +1209,9 @@ public class AssetService {
             metaPlayerRole.setType(UserHoldTypeEnum.ASSET);
             metaPlayerRole.setType(UserHoldTypeEnum.ASSET);
             metaPlayerRole.setAddress("https://www.raex.vip/9th/productSearch?search=" + metaPlayerRole
             metaPlayerRole.setAddress("https://www.raex.vip/9th/productSearch?search=" + metaPlayerRole
                     .getName() + "&source=TRANSFER");
                     .getName() + "&source=TRANSFER");
-            List<Asset> assets = assetRepo.findAllByUserIdAndStatusInAndNameLike(userId, Constants.META_NORMAL_STATUS, "%" + metaPlayerRole.getName() + "%");
+            List<Asset> assets = assetRepo
+                    .findAllByUserIdAndStatusInAndNameLike(userId, Constants.META_NORMAL_STATUS, "%" + metaPlayerRole
+                            .getName() + "%");
             metaPlayerRole.setHold(CollectionUtils.isNotEmpty(assets));
             metaPlayerRole.setHold(CollectionUtils.isNotEmpty(assets));
         });
         });
         return metaPlayerRoleList;
         return metaPlayerRoleList;

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

@@ -376,7 +376,7 @@ public class AuctionOrderService {
                         //改回资产状态
                         //改回资产状态
                         Asset asset = assetRepo.findById(auction.getAssetId())
                         Asset asset = assetRepo.findById(auction.getAssetId())
                                 .orElseThrow(new BusinessException("资产不存在"));
                                 .orElseThrow(new BusinessException("资产不存在"));
-                        asset.setStatus(AssetStatus.AUCTIONING);
+                        asset.setStatus(AssetStatus.NORMAL);
                         assetRepo.save(asset);
                         assetRepo.save(asset);
                     }
                     }
 
 

+ 11 - 6
src/main/java/com/izouma/nineth/service/OrderService.java

@@ -160,7 +160,8 @@ public class OrderService {
 
 
     public Page<Order> all(PageQuery pageQuery) {
     public Page<Order> all(PageQuery pageQuery) {
 
 
-        Page<Order> all = orderRepo.findAll(JpaUtils.toSpecification(pageQuery, Order.class), JpaUtils.toPageRequest(pageQuery));
+        Page<Order> all = orderRepo
+                .findAll(JpaUtils.toSpecification(pageQuery, Order.class), JpaUtils.toPageRequest(pageQuery));
         List<Order> content = all.getContent();
         List<Order> content = all.getContent();
         content.forEach(order -> {
         content.forEach(order -> {
             Long userId = orderRepo.selectUserId(order.getAssetId());
             Long userId = orderRepo.selectUserId(order.getAssetId());
@@ -366,8 +367,8 @@ public class OrderService {
                     .contactName(Optional.ofNullable(userAddress).map(UserAddress::getName).orElse(null))
                     .contactName(Optional.ofNullable(userAddress).map(UserAddress::getName).orElse(null))
                     .contactPhone(Optional.ofNullable(userAddress).map(UserAddress::getPhone).orElse(null))
                     .contactPhone(Optional.ofNullable(userAddress).map(UserAddress::getPhone).orElse(null))
                     .address(Optional.ofNullable(userAddress).map(u ->
                     .address(Optional.ofNullable(userAddress).map(u ->
-                                    u.getProvinceName() + " " + u.getCityName() + " " + u.getDistrictName() + " " + u
-                                            .getAddress())
+                            u.getProvinceName() + " " + u.getCityName() + " " + u.getDistrictName() + " " + u
+                                    .getAddress())
                             .orElse(null))
                             .orElse(null))
                     .status(OrderStatus.NOT_PAID)
                     .status(OrderStatus.NOT_PAID)
                     .assetId(collection.getAssetId())
                     .assetId(collection.getAssetId())
@@ -396,7 +397,9 @@ public class OrderService {
 //                collectionRepo.setOnShelf(collectionId, false);
 //                collectionRepo.setOnShelf(collectionId, false);
                 collectionRepo.setInPaying(collectionId, true);
                 collectionRepo.setInPaying(collectionId, true);
                 //拥有指定藏品降税
                 //拥有指定藏品降税
-                order.setRoyalties(assetService.getRoyalties(minter.getId(), collection.getRoyalties(), userId));
+                Long sellerId = asset.getOwnerId();
+                order.setRoyalties(assetService.getRoyalties(minter.getId(), collection.getRoyalties(), sellerId));
+                order.setServiceCharge(assetService.getServicecharge(collection.getServiceCharge(), sellerId));
             }
             }
             order = orderRepo.save(order);
             order = orderRepo.save(order);
             if (order.getTotalPrice().compareTo(BigDecimal.ZERO) == 0) {
             if (order.getTotalPrice().compareTo(BigDecimal.ZERO) == 0) {
@@ -675,7 +678,8 @@ public class OrderService {
                             userRepo.updateVipPurchase(order.getUserId(), 1);
                             userRepo.updateVipPurchase(order.getUserId(), 1);
                         }
                         }
                     }
                     }
-                    Collection winCollection = collectionRepo.findById(winItem.getCollectionId()).orElseThrow(new BusinessException("藏品不存在"));
+                    Collection winCollection = collectionRepo.findById(winItem.getCollectionId())
+                            .orElseThrow(new BusinessException("藏品不存在"));
                     assetService.createAsset(winItem, user, order.getId(), order.getPrice(), "出售",
                     assetService.createAsset(winItem, user, order.getId(), order.getPrice(), "出售",
                             winItem.getTotal() > 1 ? collectionService.getNextNumber(winItem.getCollectionId()) : null,
                             winItem.getTotal() > 1 ? collectionService.getNextNumber(winItem.getCollectionId()) : null,
                             winCollection.getHoldDays(), false);
                             winCollection.getHoldDays(), false);
@@ -1086,7 +1090,8 @@ public class OrderService {
                     .collect(Collectors.toList());
                     .collect(Collectors.toList());
             list.parallelStream().forEach(o -> {
             list.parallelStream().forEach(o -> {
                 log.info("refundGas {}", o.getId());
                 log.info("refundGas {}", o.getId());
-                userBalanceService.modifyBalance(o.getUserId(), new BigDecimal(1), BalanceType.REFUND, null, false, null);
+                userBalanceService
+                        .modifyBalance(o.getUserId(), new BigDecimal(1), BalanceType.REFUND, null, false, null);
             });
             });
         }).get();
         }).get();
     }
     }

+ 7 - 0
src/main/java/com/izouma/nineth/web/AssetController.java

@@ -235,6 +235,13 @@ public class AssetController extends BaseController {
                 .getId());
                 .getId());
     }
     }
 
 
+    @PostMapping("/getServicecharge")
+    public double getServicecharge(@RequestParam Long id) {
+        Asset asset = assetRepo.findById(id).orElseThrow(new BusinessException("无记录"));
+        return assetService.getServicecharge(asset.getServiceCharge(), SecurityUtils.getAuthenticatedUser()
+                .getId());
+    }
+
     @GetMapping("/hcChain")
     @GetMapping("/hcChain")
     public void hcChain() throws ExecutionException, InterruptedException {
     public void hcChain() throws ExecutionException, InterruptedException {
         assetService.hcChain();
         assetService.hcChain();