diff --git a/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/domain/dto/AccountsDealRecordDto.java b/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/domain/dto/AccountsDealRecordDto.java index ec73011..b74fa2b 100644 --- a/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/domain/dto/AccountsDealRecordDto.java +++ b/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/invest/domain/dto/AccountsDealRecordDto.java @@ -56,4 +56,8 @@ public class AccountsDealRecordDto implements Serializable private Date endDateTime; + /** 信用卡账单 */ + @ApiModelProperty(value="信用卡账单") + private String creditBill; + } diff --git a/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/job/service/impl/InvestJobImpl.java b/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/job/service/impl/InvestJobImpl.java index 039ec2f..c32a33c 100644 --- a/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/job/service/impl/InvestJobImpl.java +++ b/ruoyi-modules/intc-invest/src/main/java/com/ruoyi/job/service/impl/InvestJobImpl.java @@ -19,6 +19,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.LocalDate; import java.util.Calendar; import java.util.Date; import java.util.List; @@ -61,22 +62,23 @@ public class InvestJobImpl implements IInvestJobService bankCardLendDto.setType("2"); List bankCardVoList=bankCardLendMapper.selectBankCardLendList(bankCardLendDto); // 获取当前日期 - Date currentDate = new Date(); - // 创建SimpleDateFormat实例,指定日期格式 - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); - // 格式化日期为字符串 - String formattedDate = sdf.format(currentDate); - // 从格式化后的字符串中提取年份和月份 - String year = formattedDate.substring(0, 4); - String month = formattedDate.substring(5); + 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"); Date billDate= new Date(); //遍历数据,获取信用卡账单日及数据 for (BankCardLendVo bankCard : bankCardVoList) { //0表示当期,1表示下期 String isNextBillDate = bankCard.getIsNextBillDate(); - String billDateStr=year+"-"+month+"-"+String.format("%02d", bankCard.getBillDate()); + String billDateStr=year+"-"+String.format("%02d", month)+"-"+String.format("%02d", bankCard.getBillDate()); + //如果当前日期大于账单日,进入下个账单周期 + if(dayOfMonth>bankCard.getBillDate()){ + billDateStr=year+"-"+String.format("%02d", month+1)+"-"+String.format("%02d", bankCard.getBillDate()); + } try { billDate=formatter.parse(billDateStr); } catch (ParseException e) { @@ -103,8 +105,15 @@ public class InvestJobImpl implements IInvestJobService double billAmount=0; AccountsDealRecordDto accountsDealRecordDto=new AccountsDealRecordDto(); accountsDealRecordDto.setAccountId(bankCard.getId()); - accountsDealRecordDto.setStartDateTime(startDate); - accountsDealRecordDto.setEndDateTime(endDate); + 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.setCreditBill("6"); + //获取所有交易记录 List accountsDealRecordVoList=accountsDealRecordMapper.selectAccountsDealRecordList(accountsDealRecordDto); //收入转为负数 @@ -219,7 +228,7 @@ public class InvestJobImpl implements IInvestJobService creditDeal.setName(creditAccount.getName()+"("+ StringUtils.getLastNumberChars(4,creditAccount.getCode()+")")); creditDeal.setRemark("分期利息"); creditDeal.setCreateBy(SecurityUtils.getUsername()); - creditDeal.setCreateTime(installmentHistoryDetail.getUpdateTime()); + creditDeal.setCreateTime(new Date()); accountsDealRecordMapper.insertAccountsDealRecord(creditDeal); } @@ -241,7 +250,7 @@ public class InvestJobImpl implements IInvestJobService creditDealPrinciple.setName(creditAccount.getName()+"("+ StringUtils.getLastNumberChars(4,creditAccount.getCode()+")")); creditDealPrinciple.setRemark("应还本金"); creditDealPrinciple.setCreateBy(SecurityUtils.getUsername()); - creditDealPrinciple.setCreateTime(installmentHistoryDetail.getUpdateTime()); + creditDealPrinciple.setCreateTime(new Date()); accountsDealRecordMapper.insertAccountsDealRecord(creditDealPrinciple); } diff --git a/ruoyi-modules/intc-invest/src/main/resources/mapper/invest/AccountsDealRecordMapper.xml b/ruoyi-modules/intc-invest/src/main/resources/mapper/invest/AccountsDealRecordMapper.xml index 53dc414..b62d109 100644 --- a/ruoyi-modules/intc-invest/src/main/resources/mapper/invest/AccountsDealRecordMapper.xml +++ b/ruoyi-modules/intc-invest/src/main/resources/mapper/invest/AccountsDealRecordMapper.xml @@ -56,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and a.account_id = #{accountId} and a.deal_type = #{dealType} and a.deal_category = #{dealCategory} + and #{endTime}>=to_char(a.create_time, 'yyyy-MM-dd') @@ -63,11 +64,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and to_char(a.create_time, 'yyyy-MM-dd')>=#{startTime} - and #{endDateTime}>a.create_time + and #{endDateTime}>=a.create_time and a.create_time>=#{startDateTime} + + and a.deal_category!=#{creditBill} + order by a.create_time desc diff --git a/sql/20240430-sql/dump-intc_invest_dev-202404302304 b/sql/20240430-sql/dump-intc_invest_dev-202404302304 new file mode 100644 index 0000000..05975ed Binary files /dev/null and b/sql/20240430-sql/dump-intc_invest_dev-202404302304 differ diff --git a/sql/20240430-sql/dump-intc_invest_test-202404302304 b/sql/20240430-sql/dump-intc_invest_test-202404302304 new file mode 100644 index 0000000..b003bb6 Binary files /dev/null and b/sql/20240430-sql/dump-intc_invest_test-202404302304 differ diff --git a/sql/20240430-sql/dump-intc_system-202404302305 b/sql/20240430-sql/dump-intc_system-202404302305 new file mode 100644 index 0000000..789450e Binary files /dev/null and b/sql/20240430-sql/dump-intc_system-202404302305 differ