Răsfoiți Sursa

提现手续费

xiongzhu 3 ani în urmă
părinte
comite
433fd74eaa

+ 9 - 16
src/main/java/com/izouma/nineth/service/OrderService.java

@@ -265,27 +265,20 @@ public class OrderService {
                 throw new BusinessException("该藏品当前不可购买");
             }
 
-
-            AtomicInteger userMax = new AtomicInteger();
-            userPropertyRepo.findById(userId).ifPresent(userProperty -> userMax.set(userProperty.getMaxCount()));
-
             if (collection.getMaxCount() > 0) {
+                int userMax = userPropertyRepo.findById(userId)
+                        .map(UserProperty::getMaxCount)
+                        .orElse(collection.getMaxCount());
                 int count;
                 if (StringUtils.isNotBlank(collection.getCountId())) {
-                    count = orderRepo.countByUserIdAndCountIdAndStatusIn(userId, collection.getCountId(), Arrays
-                            .asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
+                    count = orderRepo.countByUserIdAndCountIdAndStatusIn(userId, collection.getCountId(),
+                            Arrays.asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
                 } else {
-                    count = orderRepo.countByUserIdAndCollectionIdAndStatusIn(userId, collectionId, Arrays
-                            .asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
+                    count = orderRepo.countByUserIdAndCollectionIdAndStatusIn(userId, collectionId,
+                            Arrays.asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
                 }
-                if (userMax.get() > 0) {
-                    if (count >= userMax.get()) {
-                        throw new BusinessException("限购" + userMax.get() + "件");
-                    }
-                } else {
-                    if (count >= collection.getMaxCount()) {
-                        throw new BusinessException("限购" + collection.getMaxCount() + "件");
-                    }
+                if (count >= userMax) {
+                    throw new BusinessException("限购" + userMax + "件");
                 }
 
             }

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

@@ -26,6 +26,7 @@ import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
@@ -98,7 +99,8 @@ public class WithdrawApplyService {
                 String withdrawCharge = sysConfigService.getString("withdraw_charge");
                 if (StringUtils.isNotEmpty(withdrawCharge) && Pattern.matches("^(\\d+|\\d+.\\d+),\\d+$", withdrawCharge)) {
                     String[] arr = withdrawCharge.split(",");
-                    chargeAmount = apply.getAmount().multiply(new BigDecimal(arr[0]));
+                    chargeAmount = apply.getAmount().multiply(new BigDecimal(arr[0]))
+                            .divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP);
                     BigDecimal minChargeAmount = new BigDecimal(arr[1]);
                     if (chargeAmount.compareTo(minChargeAmount) < 0) {
                         chargeAmount = minChargeAmount;

+ 1 - 1
src/main/java/com/izouma/nineth/web/TestClassController.java

@@ -71,7 +71,7 @@ public class TestClassController extends BaseController {
     @GetMapping("/test")
     public String test() {
         Bucket bucket = buckets.builder().build("test1", () -> (BucketConfiguration.builder()
-                .addLimit(Bandwidth.classic(10, Refill.intervally(10, Duration.ofSeconds(10))))
+                .addLimit(Bandwidth.classic(300, Refill.intervally(300, Duration.ofSeconds(30))))
                 .build()));
         if (bucket.tryConsume(1)) {
             return "ok";