| | |
| | | import com.yami.trading.bean.model.User; |
| | | import com.yami.trading.bean.model.Wallet; |
| | | import com.yami.trading.common.constants.Constants; |
| | | import com.yami.trading.common.domain.Result; |
| | | import com.yami.trading.common.exception.BusinessException; |
| | | import com.yami.trading.dao.loan.LoanParamMapper; |
| | | import com.yami.trading.service.MoneyLogService; |
| | | import com.yami.trading.service.WalletService; |
| | | import com.yami.trading.service.user.UserService; |
| | | import lombok.Getter; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | * @author JORGE |
| | | * @description 借贷服务接口实现类 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | @Transactional |
| | | public class LoanServiceImpl implements LoanService { |
| | |
| | | |
| | | @Autowired |
| | | MoneyLogService moneyLogService; |
| | | |
| | | @Autowired |
| | | LoanParamMapper loanParamMapper; |
| | | |
| | | @Getter |
| | | HashMap<String,Object> paramMap = new HashMap<>(); |
| | |
| | | transferMap.put("lendingInstitution", new Object[] {led,order.getLendingName()}); |
| | | |
| | | |
| | | Long starTimel = order.getCreateTime().getTime(); |
| | | /*Long starTimel = order.getCreateTime().getTime(); |
| | | Long num = endTimel - starTimel; |
| | | Long remainQuota = num/24/60/60/1000; |
| | | Long remainQuota = num/24/60/60/1000;*/ |
| | | order.setTotalInterest(BigDecimal.ZERO); |
| | | order.setRemainQuota(0); |
| | | if(order.getState().intValue()==2||order.getState().intValue()==4) { |
| | | /*if(order.getState().intValue()==2||order.getState().intValue()==4) { |
| | | BigDecimal totalInterest = order.getDailyRate().multiply(new BigDecimal(remainQuota)).multiply(order.getQuota()); |
| | | order.setTotalInterest(totalInterest); |
| | | order.setRemainQuota(order.getTerm() - remainQuota.intValue()); |
| | | transferMap.put("totalInterest", totalInterest); |
| | | } |
| | | } */ |
| | | |
| | | return transferMap; |
| | | }).collect(Collectors.toList()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public boolean updateLoanOrderState(String orderId, String status,String reason) { |
| | | if(null==orderId || (orderId=orderId.trim()).isEmpty()) { |
| | | throw new BusinessException("申请单ID不能为空!"); |
| | |
| | | } |
| | | //到账金额 |
| | | double amt = loanOrder.getQuota().doubleValue(); |
| | | |
| | | User user = userService.getById(loanOrder.getPartyId()); |
| | | double remainLoanLimit = user.getLoanLimit() - amt; |
| | | user.setLoanLimit(remainLoanLimit < 0 ? 0 : remainLoanLimit); |
| | | userService.updateById(user); |
| | | |
| | | //通过 |
| | | Wallet wallet = this.walletService.saveWalletByPartyId(loanOrder.getPartyId()); |
| | | double amountBefore = wallet.getMoney().doubleValue(); |
| | |
| | | SimpleLoanOrder loanOrder=loanOrders.get(0); |
| | | String houseImgs=(String)loanOrder.getHouseImgs(); |
| | | loanOrder.setHouseImgs(null==houseImgs?new String[0]:commaPattern.split(houseImgs)); |
| | | Date endDay = new Date(); |
| | | /*Date endDay = new Date(); |
| | | Long endTimel = endDay.getTime(); |
| | | Long starTimel = loanOrder.getCreateTime().getTime(); |
| | | Long num = endTimel - starTimel; |
| | | Long remainQuota = num/24/60/60/1000; |
| | | Long remainQuota = num/24/60/60/1000;*/ |
| | | loanOrder.setTotalInterest(BigDecimal.ZERO); |
| | | loanOrder.setRemainQuota(0); |
| | | if(loanOrder.getState().intValue()==2||loanOrder.getState().intValue()==4) { |
| | | /*if(loanOrder.getState().intValue()==2||loanOrder.getState().intValue()==4) { |
| | | BigDecimal totalInterest = loanOrder.getDailyRate().multiply(new BigDecimal(remainQuota)).multiply(loanOrder.getQuota()); |
| | | loanOrder.setTotalInterest(totalInterest); |
| | | loanOrder.setRemainQuota(loanOrder.getTerm() - remainQuota.intValue()); |
| | | } |
| | | }*/ |
| | | return loanOrder; |
| | | } |
| | | |
| | |
| | | List<SimpleLoanOrder> simpleLoanOrderList = jdbcTemplate.query(whereStatement.toString(), rowMapper); |
| | | //DateFormat dft = new SimpleDateFormat("yyyy-MM-dd"); |
| | | |
| | | Date endDay = new Date(); |
| | | /*Date endDay = new Date(); |
| | | Long endTimel = endDay.getTime(); |
| | | for(SimpleLoanOrder simpleLoanOrder : simpleLoanOrderList) { |
| | | Long starTimel = simpleLoanOrder.getCreateTime().getTime(); |
| | |
| | | simpleLoanOrder.setTotalInterest(totalInterest); |
| | | simpleLoanOrder.setRemainQuota(simpleLoanOrder.getTerm() - remainQuota.intValue()); |
| | | } |
| | | } |
| | | }*/ |
| | | return simpleLoanOrderList; |
| | | } |
| | | |
| | |
| | | this.paramMap = params; |
| | | } |
| | | |
| | | @Override |
| | | public Result getLoanParamList(int pageNum, int pageSize) { |
| | | try { |
| | | Page page = new Page(pageNum, pageSize); |
| | | page = loanParamMapper.getLoanParamList(page); |
| | | return Result.succeed(page); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | } |
| | | return Result.failed("获取失败"); |
| | | } |
| | | |
| | | @Override |
| | | public Result saveLoanParam(LoanParam model) { |
| | | try { |
| | | if (model.getLending_institution() == null || model.getLending_institution().isEmpty()) { |
| | | model.setLending_institution("1"); |
| | | } |
| | | if (model.getUuid() != 0) { |
| | | System.out.println(model); |
| | | if (loanParamMapper.updateById(model) > 0) { |
| | | return Result.succeed("修改成功"); |
| | | } |
| | | } else { |
| | | if (loanParamMapper.insert(model) > 0) { |
| | | return Result.succeed("添加成功"); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | } |
| | | return Result.failed("操作失败"); |
| | | } |
| | | |
| | | @Override |
| | | public Result delLoanParam(String id) { |
| | | try { |
| | | if (loanParamMapper.deleteById(id) > 0) { |
| | | return Result.succeed("删除成功"); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | } |
| | | return Result.failed("操作失败"); |
| | | } |
| | | |
| | | } |