fix:未出账单定时任务修改,脚本备份。

This commit is contained in:
tianyongbao
2024-05-01 06:34:33 +08:00
parent 51e7f44fe1
commit 829ba7f996
6 changed files with 31 additions and 14 deletions

View File

@@ -56,4 +56,8 @@ public class AccountsDealRecordDto implements Serializable
private Date endDateTime; private Date endDateTime;
/** 信用卡账单 */
@ApiModelProperty(value="信用卡账单")
private String creditBill;
} }

View File

@@ -19,6 +19,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -61,22 +62,23 @@ public class InvestJobImpl implements IInvestJobService
bankCardLendDto.setType("2"); bankCardLendDto.setType("2");
List<BankCardLendVo> bankCardVoList=bankCardLendMapper.selectBankCardLendList(bankCardLendDto); List<BankCardLendVo> bankCardVoList=bankCardLendMapper.selectBankCardLendList(bankCardLendDto);
// 获取当前日期 // 获取当前日期
Date currentDate = new Date(); LocalDate currentDate = LocalDate.now();
// 创建SimpleDateFormat实例指定日期格式 int month = currentDate.getMonthValue();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); int year = currentDate.getYear();
// 格式化日期为字符串 int dayOfMonth = currentDate.getDayOfMonth();
String formattedDate = sdf.format(currentDate);
// 从格式化后的字符串中提取年份和月份
String year = formattedDate.substring(0, 4);
String month = formattedDate.substring(5);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月账单"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月账单");
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat formatterTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date billDate= new Date(); Date billDate= new Date();
//遍历数据,获取信用卡账单日及数据 //遍历数据,获取信用卡账单日及数据
for (BankCardLendVo bankCard : bankCardVoList) { for (BankCardLendVo bankCard : bankCardVoList) {
//0表示当期1表示下期 //0表示当期1表示下期
String isNextBillDate = bankCard.getIsNextBillDate(); 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 { try {
billDate=formatter.parse(billDateStr); billDate=formatter.parse(billDateStr);
} catch (ParseException e) { } catch (ParseException e) {
@@ -103,8 +105,15 @@ public class InvestJobImpl implements IInvestJobService
double billAmount=0; double billAmount=0;
AccountsDealRecordDto accountsDealRecordDto=new AccountsDealRecordDto(); AccountsDealRecordDto accountsDealRecordDto=new AccountsDealRecordDto();
accountsDealRecordDto.setAccountId(bankCard.getId()); accountsDealRecordDto.setAccountId(bankCard.getId());
accountsDealRecordDto.setStartDateTime(startDate); try {
accountsDealRecordDto.setEndDateTime(endDate); 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<AccountsDealRecordVo> accountsDealRecordVoList=accountsDealRecordMapper.selectAccountsDealRecordList(accountsDealRecordDto); List<AccountsDealRecordVo> accountsDealRecordVoList=accountsDealRecordMapper.selectAccountsDealRecordList(accountsDealRecordDto);
//收入转为负数 //收入转为负数
@@ -219,7 +228,7 @@ public class InvestJobImpl implements IInvestJobService
creditDeal.setName(creditAccount.getName()+""+ StringUtils.getLastNumberChars(4,creditAccount.getCode()+"")); creditDeal.setName(creditAccount.getName()+""+ StringUtils.getLastNumberChars(4,creditAccount.getCode()+""));
creditDeal.setRemark("分期利息"); creditDeal.setRemark("分期利息");
creditDeal.setCreateBy(SecurityUtils.getUsername()); creditDeal.setCreateBy(SecurityUtils.getUsername());
creditDeal.setCreateTime(installmentHistoryDetail.getUpdateTime()); creditDeal.setCreateTime(new Date());
accountsDealRecordMapper.insertAccountsDealRecord(creditDeal); accountsDealRecordMapper.insertAccountsDealRecord(creditDeal);
} }
@@ -241,7 +250,7 @@ public class InvestJobImpl implements IInvestJobService
creditDealPrinciple.setName(creditAccount.getName()+""+ StringUtils.getLastNumberChars(4,creditAccount.getCode()+"")); creditDealPrinciple.setName(creditAccount.getName()+""+ StringUtils.getLastNumberChars(4,creditAccount.getCode()+""));
creditDealPrinciple.setRemark("应还本金"); creditDealPrinciple.setRemark("应还本金");
creditDealPrinciple.setCreateBy(SecurityUtils.getUsername()); creditDealPrinciple.setCreateBy(SecurityUtils.getUsername());
creditDealPrinciple.setCreateTime(installmentHistoryDetail.getUpdateTime()); creditDealPrinciple.setCreateTime(new Date());
accountsDealRecordMapper.insertAccountsDealRecord(creditDealPrinciple); accountsDealRecordMapper.insertAccountsDealRecord(creditDealPrinciple);
} }

View File

@@ -56,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="accountId != null and accountId != ''"> and a.account_id = #{accountId}</if> <if test="accountId != null and accountId != ''"> and a.account_id = #{accountId}</if>
<if test="dealType != null and dealType != ''"> and a.deal_type = #{dealType}</if> <if test="dealType != null and dealType != ''"> and a.deal_type = #{dealType}</if>
<if test="dealCategory != null and dealCategory != ''"> and a.deal_category = #{dealCategory}</if> <if test="dealCategory != null and dealCategory != ''"> and a.deal_category = #{dealCategory}</if>
<if test="endTime!=null and endTime !=''"> <if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(a.create_time, 'yyyy-MM-dd') and #{endTime}>=to_char(a.create_time, 'yyyy-MM-dd')
</if> </if>
@@ -63,11 +64,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and to_char(a.create_time, 'yyyy-MM-dd')>=#{startTime} and to_char(a.create_time, 'yyyy-MM-dd')>=#{startTime}
</if> </if>
<if test="endDateTime!=null"> <if test="endDateTime!=null">
and #{endDateTime}>a.create_time and #{endDateTime}>=a.create_time
</if> </if>
<if test="startDateTime!=null"> <if test="startDateTime!=null">
and a.create_time>=#{startDateTime} and a.create_time>=#{startDateTime}
</if> </if>
<if test="creditBill!=null">
and a.deal_category!=#{creditBill}
</if>
</where> </where>
order by a.create_time desc order by a.create_time desc

Binary file not shown.

Binary file not shown.

Binary file not shown.