瀏覽代碼

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

“xubinhui 2 年之前
父節點
當前提交
267c5fc6ad

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

@@ -219,6 +219,10 @@ public interface CollectionRepo extends JpaRepository<Collection, Long>, JpaSpec
 
     List<Collection> findAllByNameLikeAndSalableAndOnShelf(String name, boolean salable, boolean onshelf);
 
+    Collection findFirstByNameAndSalableAndOnShelf(String name, boolean salable, boolean onshelf);
+
+    Collection findFirstByNameAndOnShelf(String name, boolean onshelf);
+
     @Query(nativeQuery = true, value = "update collection_info c set c.hold_days = null where c.name like ?1")
     @Modifying
     @Transactional

+ 6 - 1
src/main/java/com/izouma/nineth/repo/OrderRepo.java

@@ -3,6 +3,7 @@ package com.izouma.nineth.repo;
 import com.izouma.nineth.domain.Order;
 import com.izouma.nineth.enums.CollectionSource;
 import com.izouma.nineth.enums.OrderStatus;
+import com.izouma.nineth.enums.OrderType;
 import com.izouma.nineth.enums.PayMethod;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
@@ -51,12 +52,16 @@ public interface OrderRepo extends JpaRepository<Order, Long>, JpaSpecificationE
 
     List<Order> findAllByStatusAndCompanyId(OrderStatus status, Long companyId);
 
+    List<Order> findAllByStatusAndCompanyIdAndOrderTypeNotIn(OrderStatus status, Long companyId, Set<OrderType> orderTypes);
+
     List<Order> findAllByStatusAndMinterId(OrderStatus status, Long minterId);
 
-    List<Order> findAllByCreatedAtIsAfterAndStatusInAndCompanyId(LocalDateTime payTime, List<OrderStatus> status, Long companyId);
+    List<Order> findAllByCreatedAtIsAfterAndStatusInAndCompanyIdAndOrderTypeNot(LocalDateTime payTime, List<OrderStatus> status, Long companyId, OrderType orderType);
 
     List<Order> findAllByCreatedAtBetweenAndStatusInAndCompanyId(LocalDateTime start, LocalDateTime end, List<OrderStatus> status, Long companyId);
 
+    List<Order> findAllByCreatedAtBetweenAndStatusInAndCompanyIdAndOrderTypeNot(LocalDateTime start, LocalDateTime end, List<OrderStatus> status, Long companyId, OrderType orderType);
+
     List<Order> findAllByCreatedAtIsAfterAndMinterIdAndStatusIn(LocalDateTime payTime, Long minterId, List<OrderStatus> status);
 
     List<Order> findAllByCreatedAtBetweenAndMinterIdAndStatusIn(LocalDateTime start, LocalDateTime end, Long minterId, List<OrderStatus> status);

+ 1 - 1
src/main/java/com/izouma/nineth/repo/nftdomain/DomainAskRepo.java

@@ -26,7 +26,7 @@ public interface DomainAskRepo extends JpaRepository<DomainAsk, Long>, JpaSpecif
     @Query(nativeQuery = true, value = "select price from domain_ask where domain_order_id = ?1 and status = 'ASKING' order by price desc limit 1")
     BigDecimal findMaxPrice(Long domainOrderId);
 
-    @Query(nativeQuery = true, value = "select count(da.id) count,da.pic_url pic,da.domain_order_id domainOrderId,a.id assetId,da.`name` picName,da.end_time endTime from domain_ask da inner join asset a on a.id = da.asset_id where da.status = 'ASKING' and da.owner_id = ?1 and a.status = 'NORMAL' group by da.asset_id order by a.created_at desc ")
+    @Query(nativeQuery = true, value = "select count(da.id) count,da.pic_url pic,da.domain_order_id domainOrderId,a.id assetId,da.`name` picName,da.end_time endTime from domain_ask da inner join asset a on a.id = da.asset_id where da.status in ('REFUNDED','ASKING','FINISH') and da.owner_id = ?1 and a.status = 'NORMAL' group by da.asset_id order by a.created_at desc")
     List<Map<String, Object>> askGroup(Long userId);
 
     int countByAssetIdAndUserIdAndStatusInAndDelFalse(Long assetId, Long userId, Set<DomainAskStatus> statuses);

+ 8 - 2
src/main/java/com/izouma/nineth/service/DomainOrderService.java

@@ -317,7 +317,11 @@ public class DomainOrderService {
                 if (asset != null) {
                     if (asset.isConsignment()) {
                         sold.put("canAsk", false);
+                        sold.put("collectionId", asset.getPublicCollectionId());
                     } else {
+                        if (asset.isPublicShow()) {
+                            sold.put("collectionId", asset.getPublicCollectionId());
+                        }
                         sold.put("canAsk", true);
                     }
                     sold.put("id", domainOrder.getId());
@@ -632,8 +636,10 @@ public class DomainOrderService {
 
     public void addHyperLink(Long collectionId, boolean openHyperLink, HyperLinkType hyperLinkType, String address) {
         // Collection collection = collectionRepo.findById(collectionId).orElseThrow(new BusinessException("没找到记录"));
-        Asset asset = assetRepo.findByIdAndStatus(collectionId, AssetStatus.NORMAL).orElseThrow(new BusinessException("没找到记录"));
-        DomainOrder domainOrder = domainOrderRepo.findById(asset.getCollectionId()).orElseThrow(new BusinessException("没找到记录"));
+        Asset asset = assetRepo.findByIdAndStatus(collectionId, AssetStatus.NORMAL)
+                               .orElseThrow(new BusinessException("没找到记录"));
+        DomainOrder domainOrder = domainOrderRepo.findById(asset.getCollectionId())
+                                                 .orElseThrow(new BusinessException("没找到记录"));
         domainOrder.setOpenHyperLink(openHyperLink);
         domainOrder.setHyperLinkType(hyperLinkType);
         domainOrder.setAddress(address);

+ 53 - 43
src/main/java/com/izouma/nineth/service/StatisticService.java

@@ -12,6 +12,7 @@ import com.izouma.nineth.domain.User;
 import com.izouma.nineth.enums.BalanceType;
 import com.izouma.nineth.enums.CollectionSource;
 import com.izouma.nineth.enums.OrderStatus;
+import com.izouma.nineth.enums.OrderType;
 import com.izouma.nineth.exception.BusinessException;
 import com.izouma.nineth.repo.*;
 import com.izouma.nineth.utils.netease.CheckSumBuilder;
@@ -47,7 +48,9 @@ public class StatisticService {
         if (user1.isAdmin()) {
             long user = userRepo.countAllByDelFalse();
             total.put("userNum", user);
-            orders = orderRepo.findAllByStatusAndCompanyId(OrderStatus.FINISH, companyId);
+            Set<OrderType> orderTypes = new HashSet<>();
+            orderTypes.add(OrderType.MIX);
+            orders = orderRepo.findAllByStatusAndCompanyIdAndOrderTypeNotIn(OrderStatus.FINISH, companyId, orderTypes);
             BigDecimal allRecharged = balanceRecordRepo.sumRechargeAll();
             total.put("rechargePrice", allRecharged);
         } else {
@@ -56,19 +59,19 @@ public class StatisticService {
 
         Map<CollectionSource, List<Order>> orderMap = orders.stream().collect(Collectors.groupingBy(Order::getSource));
         List<Order> officialOrders = Optional.ofNullable(orderMap.get(CollectionSource.OFFICIAL))
-                .orElse(Collections.emptyList());
+                                             .orElse(Collections.emptyList());
         List<Order> transferOrders = Optional.ofNullable(orderMap.get(CollectionSource.TRANSFER))
-                .orElse(Collections.emptyList());
+                                             .orElse(Collections.emptyList());
 
         total.put("officialNum", officialOrders.size());
         total.put("transferNum", transferOrders.size());
 
         BigDecimal officialPrice = officialOrders.stream()
-                .map(Order::getTotalPrice)
-                .reduce(BigDecimal.ZERO, BigDecimal::add);
+                                                 .map(Order::getTotalPrice)
+                                                 .reduce(BigDecimal.ZERO, BigDecimal::add);
         BigDecimal transferPrice = transferOrders.stream()
-                .map(Order::getTotalPrice)
-                .reduce(BigDecimal.ZERO, BigDecimal::add);
+                                                 .map(Order::getTotalPrice)
+                                                 .reduce(BigDecimal.ZERO, BigDecimal::add);
         total.put("officialPrice", officialPrice);
         total.put("transferPrice", transferPrice);
 
@@ -107,8 +110,8 @@ public class StatisticService {
         User user = userRepo.findByIdAndDelFalse(userId).orElseThrow(new BusinessException("无用户"));
         List<Order> orders;
         if (user.isAdmin()) {
-            orders = orderRepo.findAllByCreatedAtIsAfterAndStatusInAndCompanyId(start,
-                    Arrays.asList(OrderStatus.PROCESSING, OrderStatus.FINISH), companyId);
+            orders = orderRepo.findAllByCreatedAtIsAfterAndStatusInAndCompanyIdAndOrderTypeNot(start,
+                    Arrays.asList(OrderStatus.PROCESSING, OrderStatus.FINISH), companyId, OrderType.MIX);
         } else {
             orders = orderRepo.findAllByCreatedAtIsAfterAndMinterIdAndStatusIn(start, userId,
                     Arrays.asList(OrderStatus.PROCESSING, OrderStatus.FINISH));
@@ -121,14 +124,14 @@ public class StatisticService {
         if (CollUtil.isNotEmpty(orderMap.get(CollectionSource.OFFICIAL))) {
             official = orderMap.get(CollectionSource.OFFICIAL).stream().collect(Collectors.groupingBy(
                     item -> DateTimeFormatter.ofPattern("yyyy-MM-dd")
-                            .format(item.getCreatedAt()), Collectors.counting()));
+                                             .format(item.getCreatedAt()), Collectors.counting()));
         }
 
         Map<String, Long> transfer = null;
         if (CollUtil.isNotEmpty(orderMap.get(CollectionSource.TRANSFER))) {
             transfer = orderMap.get(CollectionSource.TRANSFER).stream().collect(Collectors.groupingBy(
                     item -> DateTimeFormatter.ofPattern("yyyy-MM-dd")
-                            .format(item.getCreatedAt()), Collectors.counting()));
+                                             .format(item.getCreatedAt()), Collectors.counting()));
         }
 
         Map<String, Map<String, Long>> trend = new HashMap<>();
@@ -145,16 +148,20 @@ public class StatisticService {
         List<Order> orders;
         Map<String, Map<String, BigDecimal>> trend = new HashMap<>();
         if (user.isAdmin()) {
-            orders = orderRepo.findAllByCreatedAtIsAfterAndStatusInAndCompanyId(start,
-                    Arrays.asList(OrderStatus.PROCESSING, OrderStatus.FINISH), companyId);
+            orders = orderRepo.findAllByCreatedAtIsAfterAndStatusInAndCompanyIdAndOrderTypeNot(start,
+                    Arrays.asList(OrderStatus.PROCESSING, OrderStatus.FINISH), companyId, OrderType.MIX);
             List<BalanceRecord> balanceRecords = balanceRecordRepo
                     .findByTypeAndCreatedAtBetween(BalanceType.RECHARGE, start, LocalDateTime.now());
             Map<String, BigDecimal> recharged = null;
             if (balanceRecords.size() > 0) {
                 recharged = balanceRecords.stream()
-                        .collect(Collectors.groupingBy(item -> DateTimeFormatter.ofPattern("yyyy-MM-dd")
-                                .format(item.getCreatedAt()), Collectors.mapping(BalanceRecord::getAmount,
-                                Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
+                                          .collect(Collectors
+                                                  .groupingBy(item -> DateTimeFormatter.ofPattern("yyyy-MM-dd")
+                                                                                       .format(item
+                                                                                               .getCreatedAt()), Collectors
+                                                          .mapping(BalanceRecord::getAmount,
+                                                                  Collectors
+                                                                          .reducing(BigDecimal.ZERO, BigDecimal::add))));
             }
             trend.put("recharged", recharged);
         } else {
@@ -166,21 +173,23 @@ public class StatisticService {
         Map<String, BigDecimal> official = null;
         if (CollUtil.isNotEmpty(orderMap.get(CollectionSource.OFFICIAL))) {
             official = orderMap.get(CollectionSource.OFFICIAL)
-                    .stream()
-                    .collect(Collectors.groupingBy(
-                            item -> DateTimeFormatter.ofPattern("yyyy-MM-dd")
-                                    .format(item.getCreatedAt()), Collectors.mapping(Order::getTotalPrice,
-                                    Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
+                               .stream()
+                               .collect(Collectors.groupingBy(
+                                       item -> DateTimeFormatter.ofPattern("yyyy-MM-dd")
+                                                                .format(item.getCreatedAt()), Collectors
+                                               .mapping(Order::getTotalPrice,
+                                                       Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
         }
 
         Map<String, BigDecimal> transfer = null;
         if (CollUtil.isNotEmpty(orderMap.get(CollectionSource.TRANSFER))) {
             transfer = orderMap.get(CollectionSource.TRANSFER)
-                    .stream()
-                    .collect(Collectors.groupingBy(
-                            item -> DateTimeFormatter.ofPattern("yyyy-MM-dd")
-                                    .format(item.getCreatedAt()), Collectors.mapping(Order::getTotalPrice,
-                                    Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
+                               .stream()
+                               .collect(Collectors.groupingBy(
+                                       item -> DateTimeFormatter.ofPattern("yyyy-MM-dd")
+                                                                .format(item.getCreatedAt()), Collectors
+                                               .mapping(Order::getTotalPrice,
+                                                       Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
         }
 
         trend.put("official", official);
@@ -202,8 +211,8 @@ public class StatisticService {
         List<Order> orders;
         Map<String, BigDecimal> map = new HashMap<>();
         if (user.isAdmin()) {
-            orders = orderRepo.findAllByCreatedAtBetweenAndStatusInAndCompanyId(start, end,
-                    Arrays.asList(OrderStatus.PROCESSING, OrderStatus.FINISH), companyId);
+            orders = orderRepo.findAllByCreatedAtBetweenAndStatusInAndCompanyIdAndOrderTypeNot(start, end,
+                    Arrays.asList(OrderStatus.PROCESSING, OrderStatus.FINISH), companyId, OrderType.MIX);
             BigDecimal allRecharged = balanceRecordRepo.sumRechargeToday(start, end);
             map.put("recharged", allRecharged);
         } else {
@@ -211,9 +220,9 @@ public class StatisticService {
                     Arrays.asList(OrderStatus.PROCESSING, OrderStatus.FINISH));
         }
         map.put("official", orders.stream().filter(order -> order.getSource().equals(CollectionSource.OFFICIAL))
-                .map(Order::getPrice).reduce(BigDecimal::add).orElse(BigDecimal.ZERO));
+                                  .map(Order::getPrice).reduce(BigDecimal::add).orElse(BigDecimal.ZERO));
         map.put("transfer", orders.stream().filter(order -> order.getSource().equals(CollectionSource.TRANSFER))
-                .map(Order::getPrice).reduce(BigDecimal::add).orElse(BigDecimal.ZERO));
+                                  .map(Order::getPrice).reduce(BigDecimal::add).orElse(BigDecimal.ZERO));
         return map;
     }
 
@@ -374,10 +383,10 @@ public class StatisticService {
         headers.put("Content-Type", "application/json; charset=UTF-8");
         headers.put("Accept", "application/json, text/plain, */*");
         return HttpRequest.post(url)
-                .contentType(HttpRequest.CONTENT_TYPE_JSON)
-                .headers(headers)
-                .send(JSON.toJSONString(params))
-                .body();
+                          .contentType(HttpRequest.CONTENT_TYPE_JSON)
+                          .headers(headers)
+                          .send(JSON.toJSONString(params))
+                          .body();
     }
 
     public String getToken(String username, String password, String url) {
@@ -386,10 +395,10 @@ public class StatisticService {
         params.put("username", username);
         params.put("password", password);
         return HttpRequest.post(url)
-                .contentType("application/x-www-form-urlencoded")
-                .headers(headers)
-                .form(params)
-                .body();
+                          .contentType("application/x-www-form-urlencoded")
+                          .headers(headers)
+                          .form(params)
+                          .body();
     }
 
     public Map<String, Map<String, Object>> statisticDetail() {
@@ -414,17 +423,18 @@ public class StatisticService {
         Map<String, Object> today = new HashMap<>();
         //充值
         BigDecimal rcToday = Optional.ofNullable(balanceRecordRepo.sumRechargeToday(todayStart, todayEnd))
-                .orElse(BigDecimal.ZERO);
+                                     .orElse(BigDecimal.ZERO);
         today.put("recharge", rcToday);
         //提现
         BigDecimal wdToday = Optional.ofNullable(balanceRecordRepo.sumWithdrawToday(todayStart, todayEnd))
-                .orElse(BigDecimal.ZERO);
+                                     .orElse(BigDecimal.ZERO);
         today.put("withdraw", wdToday);
         //星图
         BigDecimal paToday = Optional.ofNullable(photoAssetRepo.sumPaid(todayStart, todayEnd)).orElse(BigDecimal.ZERO);
         today.put("photoAsset", paToday);
-        List<Order> orders = orderRepo.findAllByCreatedAtBetweenAndStatusInAndCompanyId(todayStart, todayEnd,
-                Arrays.asList(OrderStatus.PROCESSING, OrderStatus.FINISH), 1L);
+        List<Order> orders = orderRepo
+                .findAllByCreatedAtBetweenAndStatusInAndCompanyIdAndOrderTypeNot(todayStart, todayEnd,
+                        Arrays.asList(OrderStatus.PROCESSING, OrderStatus.FINISH), 1L, OrderType.MIX);
         ///手续费
         List<BigDecimal> ros = new ArrayList<>();
         List<BigDecimal> scs = new ArrayList<>();
@@ -439,7 +449,7 @@ public class StatisticService {
             scs.add(orderSc);
         }
         BigDecimal todayRo = Optional.of(ros.stream().reduce(BigDecimal::add).orElse(BigDecimal.ZERO))
-                .orElse(BigDecimal.ZERO);
+                                     .orElse(BigDecimal.ZERO);
         today.put("royalties", todayRo);
         //版权费
         BigDecimal todaySc = scs.stream().reduce(BigDecimal::add).orElse(BigDecimal.ZERO);

+ 8 - 7
src/main/java/com/izouma/nineth/service/nftdomain/DomainAskService.java

@@ -109,7 +109,8 @@ public class DomainAskService {
             domainAsk.setStatus(DomainAskStatus.CANCELLED);
         }
         if (domainAsk.getStatus() == DomainAskStatus.ASKING) {
-            if (!SecurityUtils.getAuthenticatedUser().getId().equals(domainAsk.getUserId())) {
+            if (!SecurityUtils.getAuthenticatedUser().getId().equals(domainAsk.getUserId()) & !SecurityUtils
+                    .getAuthenticatedUser().getId().equals(domainAsk.getOwnerId())) {
                 throw new BusinessException("该叫价用户id不匹配,不能取消");
             }
             domainAsk.setStatus(DomainAskStatus.REFUNDED);
@@ -139,12 +140,12 @@ public class DomainAskService {
                         .getOwnerId(), domainAskStatuses) > 0) {
             throw new BusinessException("已有通过报价,请勿重复通过!");
         }
-        BigDecimal amount = domainAsk.getPrice()
-//                                 .subtract(BigDecimal.valueOf(1))
-                                     .multiply(BigDecimal
-                                             .valueOf(100 - domainAsk.getRoyalties() - domainAsk.getServiceCharge()))
-                                     .divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP);
-        assetService.transfer(asset, amount,
+//        BigDecimal amount = domainAsk.getPrice()
+////                                 .subtract(BigDecimal.valueOf(1))
+//                                     .multiply(BigDecimal
+//                                             .valueOf(100 - domainAsk.getRoyalties() - domainAsk.getServiceCharge()))
+//                                     .divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP);
+        assetService.transfer(asset, domainAsk.getPrice(),
                 userRepo.findById(domainAsk.getUserId())
                         .orElseThrow(new BusinessException("未找到用户")), TransferReason.ASK, domainAsk
                         .getId());

+ 5 - 5
src/main/java/com/izouma/nineth/web/SmsController.java

@@ -22,11 +22,11 @@ public class SmsController {
 
     @GetMapping("/sendVerify")
     public String sendVerify(@RequestParam String phone) {
-//        throw new BusinessException("此接口已停用,请重启APP或刷新网页");
-        if (!Pattern.matches(Constants.Regex.PHONE, phone)) {
-            throw new BusinessException("请输入正确的手机号");
-        }
-        return smsService.sendVerify(phone);
+        throw new BusinessException("此接口已停用,请重启APP或刷新网页");
+//        if (!Pattern.matches(Constants.Regex.PHONE, phone)) {
+//            throw new BusinessException("请输入正确的手机号");
+//        }
+//        return smsService.sendVerify(phone);
     }
 
     @GetMapping("/sendSecureVerify")