| | |
| | | import cc.mrbird.febs.mall.service.IMallMemberWithdrawService; |
| | | import cc.mrbird.febs.mall.service.MallMemberService; |
| | | import cc.mrbird.febs.mall.vo.CashOutSettingVo; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | cashOutSettingVo = JSONObject.parseObject(dic.getValue(), CashOutSettingVo.class); |
| | | } |
| | | |
| | | if (cashOutSettingVo.getWorkingDays() != 2) { |
| | | int i = DateUtil.dayOfWeek(new Date()); |
| | | if (i == 1 || i == 7) { |
| | | throw new FebsException("仅工作日可提现"); |
| | | } |
| | | } |
| | | |
| | | if (withdrawalDto.getAmount().compareTo(cashOutSettingVo.getMinCashOut()) < 0) { |
| | | throw new FebsException("最小提现金额为"+cashOutSettingVo.getMinCashOut().setScale(2,BigDecimal.ROUND_DOWN)); |
| | | } |
| | |
| | | throw new FebsException("请填写所属支行"); |
| | | } |
| | | |
| | | LambdaQueryWrapper<MallMemberWithdraw> query = new LambdaQueryWrapper<>(); |
| | | query.ge(MallMemberWithdraw::getCreatedTime, DateUtil.beginOfDay(new Date())) |
| | | .le(MallMemberWithdraw::getCreatedTime, DateUtil.endOfDay(new Date())) |
| | | .ne(MallMemberWithdraw::getStatus, 3) |
| | | .eq(MallMemberWithdraw::getMemberId, memberId); |
| | | List<MallMemberWithdraw> hasWithdraw = this.baseMapper.selectList(query); |
| | | if (CollUtil.isNotEmpty(hasWithdraw) && hasWithdraw.size() >= cashOutSettingVo.getDailyWithdrawlCnt()) { |
| | | throw new FebsException("达到最大提现次数"); |
| | | } |
| | | |
| | | double totalAmount = hasWithdraw.stream().mapToDouble(item -> item.getAmount().doubleValue()).sum(); |
| | | if (cashOutSettingVo.getAllCashOut().subtract(withdrawalDto.getAmount()).doubleValue() < totalAmount) { |
| | | throw new FebsException("达到当日最大提现金额"); |
| | | } |
| | | |
| | | MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); |
| | | |
| | | BigDecimal serviceFeePercent = cashOutSettingVo.getServiceFee().multiply(BigDecimal.valueOf(0.01)); |