|
|
@@ -27,7 +27,9 @@ import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Service
|
|
|
@@ -48,6 +50,14 @@ public class WithdrawApplyService {
|
|
|
}
|
|
|
|
|
|
public WithdrawApply withdraw(Long userId, BigDecimal money) {
|
|
|
+ BigDecimal todayWithdraw = withdrawApplyRepo
|
|
|
+ .findAllByUserIdAndStatusAndPassTimeBetween(userId, WithdrawStatus.PASS, LocalDate
|
|
|
+ .now().atStartOfDay(), LocalDate.now().atTime(LocalTime.MAX)).stream()
|
|
|
+ .map(WithdrawApply::getMoney).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
|
|
|
+ BigDecimal total = todayWithdraw.add(money);
|
|
|
+ if (total.compareTo(BigDecimal.valueOf(200)) > 0) {
|
|
|
+ throw new BusinessException("今日提现超过200元,已达今日上限.");
|
|
|
+ }
|
|
|
Store store = storeRepo.findFirstByUserId(userId);
|
|
|
MemberInfo memberInfo = memberInfoRepo.findAllByUserId(userId);
|
|
|
BigDecimal rest = memberInfo.getMoney().subtract(money);
|