diff --git a/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/RemoteInvestProdService.java b/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/RemoteInvestProdService.java index f341991..f7605a7 100644 --- a/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/RemoteInvestProdService.java +++ b/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/RemoteInvestProdService.java @@ -30,6 +30,13 @@ public interface RemoteInvestProdService @RequestMapping(value = "/job/updateUnpaidInstallmentData",method = RequestMethod.POST) public R updateUnpaidInstallmentDataTask(); + /** + * 生成未出投资账单数据 + * + * @return 结果 + */ + @RequestMapping(value = "/job/generateFutureStocksBill",method = RequestMethod.POST) + public R generateFutureStocksBill(); } diff --git a/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/RemoteInvestService.java b/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/RemoteInvestService.java index cc3375f..74668fc 100644 --- a/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/RemoteInvestService.java +++ b/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/RemoteInvestService.java @@ -28,6 +28,12 @@ public interface RemoteInvestService @RequestMapping(value = "/job/updateUnpaidInstallmentData",method = RequestMethod.POST) public R updateUnpaidInstallmentDataTask(); - + /** + * 更新未出信用卡分期账单入账数据 + * + * @return 结果 + */ + @RequestMapping(value = "/job/generateFutureStocksBill",method = RequestMethod.POST) + public R generateFutureStocksBill(); } diff --git a/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/factory/RemoteInvestFallbackFactory.java b/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/factory/RemoteInvestFallbackFactory.java index ee1a5ba..06056dc 100644 --- a/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/factory/RemoteInvestFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-invest/src/main/java/com/ruoyi/api/invest/factory/RemoteInvestFallbackFactory.java @@ -34,6 +34,11 @@ public class RemoteInvestFallbackFactory implements FallbackFactory list =futureStocksMapper.selectFutureStocksList(futureStocksDto); + // 获取当前日期 + LocalDate currentDate = LocalDate.now(); + int month = currentDate.getMonthValue(); + int year = currentDate.getYear(); + int dayOfMonth = currentDate.getDayOfMonth(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月账单"); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat formatterTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + SimpleDateFormat yearFormatter = new SimpleDateFormat("yyyy"); + SimpleDateFormat monthFormatter = new SimpleDateFormat("yyyy-MM"); + Date billDate= new Date(); + //遍历数据,获取信用卡账单日及数据 + for (FutureStocksVo futureStocksVo : list) { + //如果不是正常使用的账户,不需要生成账单信息 + if(!futureStocksVo.getStatus().equals("1")){ + continue; + } + + Calendar calendarStart = Calendar.getInstance(); + calendarStart.setTime(billDate); + calendarStart.set(Calendar.DAY_OF_MONTH, 1); // 设置为当月的第一天 + + Date startDate = calendarStart.getTime(); + String periodStart = formatter.format(startDate); + + Calendar calendarEnd = Calendar.getInstance(); + calendarEnd.setTime(billDate); + int lastDay = calendarEnd.getActualMaximum(Calendar.DAY_OF_MONTH); // 当月的最后一天 + calendarEnd.set(Calendar.DAY_OF_MONTH, lastDay); + Date endDate = calendarEnd.getTime(); + String periodEnd= formatter.format(endDate); + + double billAmount=0; + AccountsDealRecordDto accountsDealRecordDto=new AccountsDealRecordDto(); + accountsDealRecordDto.setAccountId(futureStocksVo.getId()); + try { + accountsDealRecordDto.setStartDateTime(formatterTime.parse(periodStart+" 00:00:00")); + accountsDealRecordDto.setEndDateTime(formatterTime.parse(periodEnd+" 23:59:59")); + } catch (ParseException e) { + throw new RuntimeException(e); + } + + accountsDealRecordDto.setDealCategory("2"); + + //获取所有交易记录 + List accountsDealRecordVoList=accountsDealRecordMapper.selectAccountsDealRecordList(accountsDealRecordDto); + //收入转为负数 + for (AccountsDealRecordVo vo:accountsDealRecordVoList + ) { + if(vo.getDealType().equals("1")){ + vo.setAmount(vo.getAmount()*(-1)); + } + } + //如果存在交易记录,进行账单汇总,否则不进行 + if(accountsDealRecordVoList.size()>0){ + billAmount=accountsDealRecordVoList.stream().mapToDouble(AccountsDealRecordVo::getAmount).sum(); + FutureStocksBillDto futureStocksBillDto=new FutureStocksBillDto(); + futureStocksBillDto.setFutureStocksId(futureStocksVo.getId()); + String billMonth=year+"-"+String.format("%02d", month); + futureStocksBillDto.setBillMonth(billMonth); + List futureStocksBillVoList=futureStocksBillMapper.selectFutureStocksBillList(futureStocksBillDto); + if(futureStocksBillVoList.size()>0){ + FutureStocksBillVo futureStocksBillVo=futureStocksBillVoList.get(0); + FutureStocksBill futureStocksBill=new FutureStocksBill(); + futureStocksBill.setUpdateBy(SecurityUtils.getUsername()); + futureStocksBill.setUpdateTime(DateUtils.getNowDate()); + futureStocksBill.setId(futureStocksVo.getId()); + futureStocksBill.setBillAmount(billAmount); + //更新账单 + futureStocksBillMapper.updateFutureStocksBill(futureStocksBill); + }else { + //进行插入操作 + FutureStocksBill futureStocksBill=new FutureStocksBill(); + futureStocksBill.setBillDate(endDate); + futureStocksBill.setName(simpleDateFormat.format(endDate)); + futureStocksBill.setBillDatePeriod(periodStart+"~"+periodEnd); + futureStocksBill.setCreateBy(futureStocksVo.getCreateBy()); + futureStocksBill.setCreateTime(DateUtils.getNowDate()); + futureStocksBill.setId(IdWorker.getId()); + futureStocksBill.setFutureStocksId(futureStocksVo.getId()); + futureStocksBill.setBillAmount(billAmount); + futureStocksBill.setBillDatePeriod(periodStart+"~"+periodEnd); + futureStocksBill.setBillYear(yearFormatter.format(futureStocksBill.getBillDate())); + futureStocksBill.setBillMonth(monthFormatter.format(futureStocksBill.getBillDate())); + //插入未出账单 + futureStocksBillMapper.insertFutureStocksBill(futureStocksBill); + } + } + } + } + } diff --git a/ruoyi-modules/intc-invest/src/main/resources/mapper/invest/FutureStocksBillMapper.xml b/ruoyi-modules/intc-invest/src/main/resources/mapper/invest/FutureStocksBillMapper.xml index f7f7ffd..08853d6 100644 --- a/ruoyi-modules/intc-invest/src/main/resources/mapper/invest/FutureStocksBillMapper.xml +++ b/ruoyi-modules/intc-invest/src/main/resources/mapper/invest/FutureStocksBillMapper.xml @@ -59,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and a.bill_date_period = #{billDatePeriod} and a.bill_amount = #{billAmount} and a.type = #{type} + and a.bill_month = #{billMonth} and to_char(a.bill_date, 'yyyy-MM')>=#{startMonth} diff --git a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/InvestJobTask.java b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/InvestJobTask.java index f2d76fe..14deace 100644 --- a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/InvestJobTask.java +++ b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/InvestJobTask.java @@ -31,4 +31,12 @@ public class InvestJobTask } + /**未出信用卡分期账单入账数据*/ + public void generateFutureStocksBill(){ + System.out.println("================================开始生成未出投资账单数据("+ DateUtils.getTime() +")================================="); + remoteInvestService.generateFutureStocksBill(); + System.out.println("================================结束生成未出投资账单据("+ DateUtils.getTime() +")================================="); + } + + } diff --git a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/InvestProdJobTask.java b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/InvestProdJobTask.java index 6c4779d..86cc1e1 100644 --- a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/InvestProdJobTask.java +++ b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/task/InvestProdJobTask.java @@ -30,5 +30,11 @@ public class InvestProdJobTask System.out.println("================================结束更新未出信用卡分期账单入账拟数据("+ DateUtils.getTime() +")================================="); } + /**生成未出投资账单数据*/ + public void generateFutureStocksBill(){ + System.out.println("================================开始生成未出账单数据("+ DateUtils.getTime() +")================================="); + remoteInvestProdService.generateFutureStocksBill(); + System.out.println("================================结束生成未出账单据("+ DateUtils.getTime() +")================================="); + } }