提交 1863731c authored 作者: huyufan's avatar huyufan

Merge remote-tracking branch 'origin/v10.7_borrowing_and_repayment_20240118' into test

...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.clx.performance.dao.loan.OwnerLoanAccountRunningWaterRecordDao; import com.clx.performance.dao.loan.OwnerLoanAccountRunningWaterRecordDao;
import com.clx.performance.enums.loan.OwnerLoanAccountRunningWaterRecordEnum;
import com.clx.performance.mapper.loan.OwnerLoanAccountRunningWaterRecordMapper; import com.clx.performance.mapper.loan.OwnerLoanAccountRunningWaterRecordMapper;
import com.clx.performance.model.loan.OwnerLoanAccountRunningWaterRecord; import com.clx.performance.model.loan.OwnerLoanAccountRunningWaterRecord;
import com.clx.performance.param.pc.loan.carrier.PageOwnerLoanAccountWaterRecordOfOwnerParam; import com.clx.performance.param.pc.loan.carrier.PageOwnerLoanAccountWaterRecordOfOwnerParam;
...@@ -92,4 +93,11 @@ public class OwnerLoanAccountRunningWaterRecordDaoImpl extends BaseDaoImpl<Owner ...@@ -92,4 +93,11 @@ public class OwnerLoanAccountRunningWaterRecordDaoImpl extends BaseDaoImpl<Owner
.orderByAsc(OwnerLoanAccountRunningWaterRecord::getId) .orderByAsc(OwnerLoanAccountRunningWaterRecord::getId)
); );
} }
@Override
public List<OwnerLoanAccountRunningWaterRecord> selectLoanRunningWatterRecord(Long loanNo) {
return baseMapper.selectList(lQrWrapper().eq(OwnerLoanAccountRunningWaterRecord::getLoanNo, loanNo)
.eq(OwnerLoanAccountRunningWaterRecord::getRunningWaterType,
OwnerLoanAccountRunningWaterRecordEnum.RunWaterType.APPROVE_FROZEN.getCode())
); }
} }
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.clx.performance.dao.settle.SettlementDriverDao; import com.clx.performance.dao.settle.SettlementDriverDao;
import com.clx.performance.enums.loan.OwnerLoanRecordEnum;
import com.clx.performance.mapper.settle.SettlementDriverMapper; import com.clx.performance.mapper.settle.SettlementDriverMapper;
import com.clx.performance.model.settle.SettlementDriver; import com.clx.performance.model.settle.SettlementDriver;
import com.clx.performance.param.pc.driver.PageCarrierSettlementDriverParam; import com.clx.performance.param.pc.driver.PageCarrierSettlementDriverParam;
...@@ -13,6 +14,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -13,6 +14,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
/** /**
* @Author: aiqinguo * @Author: aiqinguo
...@@ -57,4 +59,11 @@ public class SettlementDriverDaoImpl extends BaseDaoImpl<SettlementDriverMapper, ...@@ -57,4 +59,11 @@ public class SettlementDriverDaoImpl extends BaseDaoImpl<SettlementDriverMapper,
) )
.map(super::getOne); .map(super::getOne);
} }
@Override
public void updateLoanFlagByChildNoList(Set<String> childNoList) {
update(lUdWrapper().in(SettlementDriver::getChildNo, childNoList)
.set(SettlementDriver::getLoanFlag, OwnerLoanRecordEnum.LoanFlag.RE_PAY.getCode())
);
}
} }
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.clx.performance.dao.settle.SettlementDriverDetailDao; import com.clx.performance.dao.settle.SettlementDriverDetailDao;
import com.clx.performance.enums.loan.OwnerLoanRecordEnum;
import com.clx.performance.mapper.settle.SettlementDriverDetailMapper; import com.clx.performance.mapper.settle.SettlementDriverDetailMapper;
import com.clx.performance.model.settle.SettlementDriverDetail; import com.clx.performance.model.settle.SettlementDriverDetail;
import com.clx.performance.param.pc.driver.PageCarrierSettlementDriverDetailParam; import com.clx.performance.param.pc.driver.PageCarrierSettlementDriverDetailParam;
...@@ -15,6 +16,7 @@ import org.springframework.stereotype.Repository; ...@@ -15,6 +16,7 @@ import org.springframework.stereotype.Repository;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
/** /**
* @Author: aiqinguo * @Author: aiqinguo
...@@ -81,4 +83,12 @@ public class SettlementDriverDetailDaoImpl extends BaseDaoImpl<SettlementDriverD ...@@ -81,4 +83,12 @@ public class SettlementDriverDetailDaoImpl extends BaseDaoImpl<SettlementDriverD
return baseMapper.findByDriverSettlementIds(ids); return baseMapper.findByDriverSettlementIds(ids);
} }
@Override
public void updateLoanFlagByChildNoList(Set<String> childNoList) {
update(lUdWrapper()
.in(SettlementDriverDetail::getChildNo, childNoList)
.set(SettlementDriverDetail::getLoanFlag, OwnerLoanRecordEnum.LoanFlag.RE_PAY.getCode())
);
}
} }
...@@ -26,4 +26,6 @@ public interface OwnerLoanAccountRunningWaterRecordDao extends BaseDao<OwnerLoan ...@@ -26,4 +26,6 @@ public interface OwnerLoanAccountRunningWaterRecordDao extends BaseDao<OwnerLoan
OwnerLoanAccountRunningWaterRecord getOneByChildNoAndStatus(String childNo, Integer type); OwnerLoanAccountRunningWaterRecord getOneByChildNoAndStatus(String childNo, Integer type);
List<OwnerLoanAccountRunningWaterRecord> getListByOrderNoAndRunningWaterType(String childNo, Integer runningWaterType); List<OwnerLoanAccountRunningWaterRecord> getListByOrderNoAndRunningWaterType(String childNo, Integer runningWaterType);
List<OwnerLoanAccountRunningWaterRecord> selectLoanRunningWatterRecord(Long loanNo);
} }
...@@ -7,6 +7,8 @@ import com.clx.performance.param.pc.driver.PageCarrierSettlementDriverParam; ...@@ -7,6 +7,8 @@ import com.clx.performance.param.pc.driver.PageCarrierSettlementDriverParam;
import com.msl.common.base.Optional; import com.msl.common.base.Optional;
import com.msl.common.dao.BaseDao; import com.msl.common.dao.BaseDao;
import java.util.Set;
/** /**
* @Author: aiqinguo * @Author: aiqinguo
* @Description: 车主结算单 * @Description: 车主结算单
...@@ -18,4 +20,6 @@ public interface SettlementDriverDao extends BaseDao<SettlementDriverMapper, Set ...@@ -18,4 +20,6 @@ public interface SettlementDriverDao extends BaseDao<SettlementDriverMapper, Set
Optional<SettlementDriver> getByChildNo(String childNo); Optional<SettlementDriver> getByChildNo(String childNo);
void updateLoanFlagByChildNoList(Set<String> childNoList);
} }
...@@ -9,6 +9,7 @@ import com.msl.common.dao.BaseDao; ...@@ -9,6 +9,7 @@ import com.msl.common.dao.BaseDao;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* @Author: aiqinguo * @Author: aiqinguo
...@@ -31,4 +32,5 @@ public interface SettlementDriverDetailDao extends BaseDao<SettlementDriverDetai ...@@ -31,4 +32,5 @@ public interface SettlementDriverDetailDao extends BaseDao<SettlementDriverDetai
List<SettlementDriverDetail> findByDriverSettlementIds(List<Integer> ids); List<SettlementDriverDetail> findByDriverSettlementIds(List<Integer> ids);
void updateLoanFlagByChildNoList(Set<String> childNoList);
} }
...@@ -10,6 +10,7 @@ import com.msl.common.dao.BaseDao; ...@@ -10,6 +10,7 @@ import com.msl.common.dao.BaseDao;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
......
package com.clx.performance.event; package com.clx.performance.event;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.clx.performance.component.OrderChildLoanComponent; import com.clx.performance.component.OrderChildLoanComponent;
import com.clx.performance.dao.loan.OrderChildLoanRetryRecordDao; import com.clx.performance.dao.loan.OrderChildLoanRetryRecordDao;
import com.clx.performance.dao.loan.OwnerLoanAccountRunningWaterRecordDao;
import com.clx.performance.dao.loan.OwnerRepaymentDao; import com.clx.performance.dao.loan.OwnerRepaymentDao;
import com.clx.performance.dao.settle.SettlementDriverDao;
import com.clx.performance.dao.settle.SettlementDriverDetailDao; import com.clx.performance.dao.settle.SettlementDriverDetailDao;
import com.clx.performance.dao.settle.SettlementOwnerDetailDao; import com.clx.performance.dao.settle.SettlementOwnerDetailDao;
import com.clx.performance.dto.OwnerLoanMqDTO; import com.clx.performance.dto.OwnerLoanMqDTO;
...@@ -12,6 +15,7 @@ import com.clx.performance.enums.loan.OwnerLoanRecordEnum; ...@@ -12,6 +15,7 @@ import com.clx.performance.enums.loan.OwnerLoanRecordEnum;
import com.clx.performance.enums.loan.OwnerRePaymentEnum; import com.clx.performance.enums.loan.OwnerRePaymentEnum;
import com.clx.performance.model.OrderChild; import com.clx.performance.model.OrderChild;
import com.clx.performance.model.loan.OrderChildLoanRetryRecord; import com.clx.performance.model.loan.OrderChildLoanRetryRecord;
import com.clx.performance.model.loan.OwnerLoanAccountRunningWaterRecord;
import com.clx.performance.model.loan.OwnerRepayment; import com.clx.performance.model.loan.OwnerRepayment;
import com.clx.performance.model.settle.SettlementDriverDetail; import com.clx.performance.model.settle.SettlementDriverDetail;
import com.clx.performance.model.settle.SettlementOwnerDetail; import com.clx.performance.model.settle.SettlementOwnerDetail;
...@@ -23,6 +27,11 @@ import org.springframework.context.event.EventListener; ...@@ -23,6 +27,11 @@ import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.PlatformTransactionManager;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@Component @Component
@Slf4j @Slf4j
@AllArgsConstructor @AllArgsConstructor
...@@ -42,6 +51,10 @@ public class EventListenerComponent { ...@@ -42,6 +51,10 @@ public class EventListenerComponent {
private final ApplicationEventPublisher applicationEventPublisher; private final ApplicationEventPublisher applicationEventPublisher;
private final SettlementDriverDao settlementDriverDao;
private final OwnerLoanAccountRunningWaterRecordDao ownerLoanAccountRunningWaterRecordDao;
@EventListener(classes = {SettlementUpdateEvent.class}) @EventListener(classes = {SettlementUpdateEvent.class})
public void listen(SettlementUpdateEvent event) { public void listen(SettlementUpdateEvent event) {
...@@ -94,4 +107,28 @@ public class EventListenerComponent { ...@@ -94,4 +107,28 @@ public class EventListenerComponent {
// 发送mq 通过开票标识 // 发送mq 通过开票标识
settlementMqService.invoiceTypeSync(settlementDriverDetail.getChildNo(), settlementDriverDetail.getInvoiceType()); settlementMqService.invoiceTypeSync(settlementDriverDetail.getChildNo(), settlementDriverDetail.getInvoiceType());
} }
@EventListener(classes = {OwnerLoanFlagEvent.class})
public void listen(OwnerLoanFlagEvent event) {
log.info("OwnerLoanFlagEvent事件执行");
Long loanNo = event.getLoanNo();
List<OwnerLoanAccountRunningWaterRecord> records = ownerLoanAccountRunningWaterRecordDao.selectLoanRunningWatterRecord(loanNo);
if (CollectionUtil.isEmpty(records)) {
return;
}
Map<String, List<OwnerLoanAccountRunningWaterRecord>> listMap = records.stream().collect(Collectors.groupingBy(OwnerLoanAccountRunningWaterRecord::getChildNo));
for (Map.Entry<String, List<OwnerLoanAccountRunningWaterRecord>> entry : listMap.entrySet()) {
if (entry.getValue().size() > 1) {
log.info("当前运单{}存在多条流水,不更新还款标志", entry.getKey());
listMap.remove(entry.getKey());
}
}
log.info("当前需要更新的运单数量:{}", listMap.size());
settlementDriverDetailDao.updateLoanFlagByChildNoList(listMap.keySet());
settlementDriverDao.updateLoanFlagByChildNoList(listMap.keySet());
}
} }
package com.clx.performance.event;
import lombok.Getter;
import lombok.Setter;
import org.springframework.context.ApplicationEvent;
@Getter
@Setter
public class OwnerLoanFlagEvent extends ApplicationEvent {
private Long loanNo;
/**
* Create a new {@code ApplicationEvent}.
*
* @param source the object on which the event initially occurred or with
* which the event is associated (never {@code null})
*/
public OwnerLoanFlagEvent(Object source) {
super(source);
}
public OwnerLoanFlagEvent(Object source, Long loanNo) {
super(source);
this.loanNo = loanNo;
}
}
...@@ -21,7 +21,7 @@ public interface OwnerLoanAccountMapper extends BaseMapper<OwnerLoanAccount> { ...@@ -21,7 +21,7 @@ public interface OwnerLoanAccountMapper extends BaseMapper<OwnerLoanAccount> {
@Update("update owner_loan_account set funding_account_balance = funding_account_balance + #{account.fundingAccountBalance}" + @Update("update owner_loan_account set funding_account_balance = funding_account_balance + #{account.fundingAccountBalance}" +
",funding_usable_balance = funding_usable_balance + #{account.fundingUsableBalance},funding_frozen_balance = funding_frozen_balance + #{account.fundingFrozenBalance}" + ",funding_usable_balance = funding_usable_balance + #{account.fundingUsableBalance},funding_frozen_balance = funding_frozen_balance + #{account.fundingFrozenBalance}" +
",virtually_account_balance = virtually_account_balance + #{account.virtuallyAccountBalance},virtually_usable_balance = virtually_usable_balance + #{account.virtuallyUsableBalance}" + ",virtually_account_balance = virtually_account_balance + #{account.virtuallyAccountBalance},virtually_usable_balance = virtually_usable_balance + #{account.virtuallyUsableBalance}" +
",virtually_frozen_balance = virtually_frozen_balance + #{account.virtuallyFrozenBalance}" + ",virtually_frozen_balance = virtually_frozen_balance + #{account.virtuallyFrozenBalance},funding_arrears = funding_arrears + #{account.fundingArrears},virtually_arrears = virtually_arrears + #{account.virtuallyArrears}" +
",modified_time=#{now}" ",modified_time=#{now}"
+ "where id = #{account.id} and modified_time = #{account.modifiedTime}" + "where id = #{account.id} and modified_time = #{account.modifiedTime}"
) )
...@@ -30,7 +30,7 @@ public interface OwnerLoanAccountMapper extends BaseMapper<OwnerLoanAccount> { ...@@ -30,7 +30,7 @@ public interface OwnerLoanAccountMapper extends BaseMapper<OwnerLoanAccount> {
@Update("update owner_loan_account set funding_account_balance = funding_account_balance - #{account.fundingAccountBalance}" + @Update("update owner_loan_account set funding_account_balance = funding_account_balance - #{account.fundingAccountBalance}" +
",funding_usable_balance = funding_usable_balance - #{account.fundingUsableBalance},funding_frozen_balance = funding_frozen_balance + #{account.fundingFrozenBalance}" + ",funding_usable_balance = funding_usable_balance - #{account.fundingUsableBalance},funding_frozen_balance = funding_frozen_balance + #{account.fundingFrozenBalance}" +
",virtually_account_balance = virtually_account_balance - #{account.virtuallyAccountBalance},virtually_usable_balance = virtually_usable_balance - #{account.virtuallyUsableBalance}" + ",virtually_account_balance = virtually_account_balance - #{account.virtuallyAccountBalance},virtually_usable_balance = virtually_usable_balance - #{account.virtuallyUsableBalance}" +
",virtually_frozen_balance = virtually_frozen_balance + #{account.virtuallyFrozenBalance}" + ",virtually_frozen_balance = virtually_frozen_balance + #{account.virtuallyFrozenBalance},funding_arrears = funding_arrears - #{account.fundingArrears},virtually_arrears = virtually_arrears - #{account.virtuallyArrears}" +
",modified_time=#{now}" ",modified_time=#{now}"
+ "where id = #{account.id} and modified_time = #{account.modifiedTime}" + "where id = #{account.id} and modified_time = #{account.modifiedTime}"
) )
......
...@@ -223,6 +223,9 @@ public class OwnerLoanRecordServiceImpl implements OwnerLoanRecordService { ...@@ -223,6 +223,9 @@ public class OwnerLoanRecordServiceImpl implements OwnerLoanRecordService {
entity.setVirtuallyFrozenBalance(BigDecimal.ZERO); entity.setVirtuallyFrozenBalance(BigDecimal.ZERO);
entity.setVirtuallyUsableBalance(ownerLoanRecord.getLoanBalance()); entity.setVirtuallyUsableBalance(ownerLoanRecord.getLoanBalance());
entity.setModifiedTime(ownerLoanAccount.getModifiedTime()); entity.setModifiedTime(ownerLoanAccount.getModifiedTime());
entity.setFundingArrears(BigDecimal.ZERO);
entity.setVirtuallyArrears(ownerLoanRecord.getLoanBalance());
Integer flag = ownerLoanAccountDao.updateAccountCAS(entity, LocalDateTime.now(), true); Integer flag = ownerLoanAccountDao.updateAccountCAS(entity, LocalDateTime.now(), true);
if (flag == 1) { if (flag == 1) {
//生成借款流水 //生成借款流水
...@@ -605,13 +608,17 @@ public class OwnerLoanRecordServiceImpl implements OwnerLoanRecordService { ...@@ -605,13 +608,17 @@ public class OwnerLoanRecordServiceImpl implements OwnerLoanRecordService {
ownerLoanRecord.getOwnerUserNo()).get(); ownerLoanRecord.getOwnerUserNo()).get();
OwnerLoanAccount entity = new OwnerLoanAccount(); OwnerLoanAccount entity = new OwnerLoanAccount();
entity.setId(ownerLoanAccount.getId()); entity.setId(ownerLoanAccount.getId());
entity.setFundingAccountBalance(BigDecimal.ZERO); entity.setVirtuallyAccountBalance(BigDecimal.ZERO);
entity.setFundingFrozenBalance(BigDecimal.ZERO);
entity.setFundingUsableBalance(BigDecimal.ZERO);
entity.setVirtuallyAccountBalance(ownerLoanRecord.getLoanBalance());
entity.setVirtuallyFrozenBalance(BigDecimal.ZERO); entity.setVirtuallyFrozenBalance(BigDecimal.ZERO);
entity.setVirtuallyUsableBalance(ownerLoanRecord.getLoanBalance()); entity.setVirtuallyUsableBalance(BigDecimal.ZERO);
entity.setFundingAccountBalance(ownerLoanRecord.getLoanBalance());
entity.setFundingFrozenBalance(BigDecimal.ZERO);
entity.setFundingUsableBalance(ownerLoanRecord.getLoanBalance());
entity.setFundingArrears(ownerLoanRecord.getLoanBalance());
entity.setVirtuallyArrears(BigDecimal.ZERO);
entity.setModifiedTime(ownerLoanAccount.getModifiedTime()); entity.setModifiedTime(ownerLoanAccount.getModifiedTime());
Integer flag = ownerLoanAccountDao.updateAccountCAS(entity, LocalDateTime.now(), true); Integer flag = ownerLoanAccountDao.updateAccountCAS(entity, LocalDateTime.now(), true);
if (flag == 1) { if (flag == 1) {
//生成借款流水 //生成借款流水
...@@ -747,6 +754,8 @@ public class OwnerLoanRecordServiceImpl implements OwnerLoanRecordService { ...@@ -747,6 +754,8 @@ public class OwnerLoanRecordServiceImpl implements OwnerLoanRecordService {
update.setFundingAccountBalance(BigDecimal.ZERO); update.setFundingAccountBalance(BigDecimal.ZERO);
update.setFundingFrozenBalance(BigDecimal.ZERO); update.setFundingFrozenBalance(BigDecimal.ZERO);
update.setFundingUsableBalance(BigDecimal.ZERO); update.setFundingUsableBalance(BigDecimal.ZERO);
update.setFundingArrears(BigDecimal.ZERO);
update.setVirtuallyArrears(BigDecimal.ZERO);
} else { } else {
log.info("进行资金信息赋值"); log.info("进行资金信息赋值");
update.setId(account.getId()); update.setId(account.getId());
...@@ -758,6 +767,8 @@ public class OwnerLoanRecordServiceImpl implements OwnerLoanRecordService { ...@@ -758,6 +767,8 @@ public class OwnerLoanRecordServiceImpl implements OwnerLoanRecordService {
update.setVirtuallyFrozenBalance(BigDecimal.ZERO); update.setVirtuallyFrozenBalance(BigDecimal.ZERO);
update.setVirtuallyUsableBalance(BigDecimal.ZERO); update.setVirtuallyUsableBalance(BigDecimal.ZERO);
update.setVirtuallyAccountBalance(BigDecimal.ZERO); update.setVirtuallyAccountBalance(BigDecimal.ZERO);
update.setFundingArrears(BigDecimal.ZERO);
update.setVirtuallyArrears(BigDecimal.ZERO);
} }
} }
......
...@@ -15,20 +15,16 @@ import com.clx.performance.config.ClxMessageConfig; ...@@ -15,20 +15,16 @@ import com.clx.performance.config.ClxMessageConfig;
import com.clx.performance.config.loan.ClxPayeeConfig; import com.clx.performance.config.loan.ClxPayeeConfig;
import com.clx.performance.config.loan.PaymentFromConfig; import com.clx.performance.config.loan.PaymentFromConfig;
import com.clx.performance.config.nbbank.NbBankConfig; import com.clx.performance.config.nbbank.NbBankConfig;
import com.clx.performance.dao.loan.BankTradeDao; import com.clx.performance.dao.loan.*;
import com.clx.performance.dao.loan.OwnerLoanRecordDao;
import com.clx.performance.dao.loan.OwnerPaymentDao;
import com.clx.performance.dao.loan.OwnerRepaymentDao;
import com.clx.performance.enums.PerformanceResultEnum; import com.clx.performance.enums.PerformanceResultEnum;
import com.clx.performance.enums.loan.OwnerLoanRecordEnum; import com.clx.performance.enums.loan.OwnerLoanRecordEnum;
import com.clx.performance.enums.loan.OwnerPaymentEnum; import com.clx.performance.enums.loan.OwnerPaymentEnum;
import com.clx.performance.enums.loan.OwnerRePaymentEnum; import com.clx.performance.enums.loan.OwnerRePaymentEnum;
import com.clx.performance.enums.nbbank.NbBankStatusEnum; import com.clx.performance.enums.nbbank.NbBankStatusEnum;
import com.clx.performance.event.OwnerLoanFlagEvent;
import com.clx.performance.event.OwnerRepaymentUpdateEvent;
import com.clx.performance.extranal.user.impl.OwnerInfoServiceImpl; import com.clx.performance.extranal.user.impl.OwnerInfoServiceImpl;
import com.clx.performance.model.loan.BankTrade; import com.clx.performance.model.loan.*;
import com.clx.performance.model.loan.OwnerLoanRecord;
import com.clx.performance.model.loan.OwnerPayment;
import com.clx.performance.model.loan.OwnerRepayment;
import com.clx.performance.param.pc.loan.carrier.PageCarrierOwnerRepaymentParam; import com.clx.performance.param.pc.loan.carrier.PageCarrierOwnerRepaymentParam;
import com.clx.performance.param.pc.loan.carrier.PageOwnerRepaymentOfOwner; import com.clx.performance.param.pc.loan.carrier.PageOwnerRepaymentOfOwner;
import com.clx.performance.param.pc.loan.owner.ExportPaymentApplicationFormParam; import com.clx.performance.param.pc.loan.owner.ExportPaymentApplicationFormParam;
...@@ -54,9 +50,11 @@ import com.msl.user.data.UserSessionData; ...@@ -54,9 +50,11 @@ import com.msl.user.data.UserSessionData;
import com.msl.user.utils.TokenUtil; import com.msl.user.utils.TokenUtil;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
...@@ -84,6 +82,8 @@ public class OwnerRepaymentServiceImpl implements OwnerRepaymentService { ...@@ -84,6 +82,8 @@ public class OwnerRepaymentServiceImpl implements OwnerRepaymentService {
private final IdGenerateSnowFlake idGenerateSnowFlake; private final IdGenerateSnowFlake idGenerateSnowFlake;
private final OwnerPaymentDao ownerPaymentDao; private final OwnerPaymentDao ownerPaymentDao;
private final OwnerLoanRecordDao ownerLoanRecordDao; private final OwnerLoanRecordDao ownerLoanRecordDao;
private final ApplicationEventPublisher applicationEventPublisher;
private final OwnerLoanAccountDao ownerLoanAccountDao;
@Override @Override
public IPage<OwnerRepaymentVO> pageOwnerRepayment(PageCarrierOwnerRepaymentParam param) { public IPage<OwnerRepaymentVO> pageOwnerRepayment(PageCarrierOwnerRepaymentParam param) {
...@@ -271,12 +271,40 @@ public class OwnerRepaymentServiceImpl implements OwnerRepaymentService { ...@@ -271,12 +271,40 @@ public class OwnerRepaymentServiceImpl implements OwnerRepaymentService {
// 查询还款信息 // 查询还款信息
OwnerRepayment ownerRepayment = ownerRepaymentDao.getOneByField(OwnerRepayment::getRepaymentNo, bankTrade.getRelationNo()).get(); OwnerRepayment ownerRepayment = ownerRepaymentDao.getOneByField(OwnerRepayment::getRepaymentNo, bankTrade.getRelationNo()).get();
ownerRepayment.setStatus(OwnerRePaymentEnum.Status.PAY_SUCCESS.getCode()); ownerRepayment.setStatus(OwnerRePaymentEnum.Status.PAY_SUCCESS.getCode());
// 更新款信息 // 更新款信息
ownerRepaymentDao.updateStatusById(ownerRepayment); ownerRepaymentDao.updateStatusById(ownerRepayment);
OwnerLoanRecord ownerLoanRecord = ownerLoanRecordDao.getOneByField(OwnerLoanRecord::getLoanNo, OwnerLoanRecord ownerLoanRecord = ownerLoanRecordDao.getOneByField(OwnerLoanRecord::getLoanNo,
ownerRepayment.getLoanNo()).orElseThrow(PerformanceResultEnum.DATA_NOT_FIND); ownerRepayment.getLoanNo()).orElseThrow(PerformanceResultEnum.DATA_NOT_FIND);
while (true) {
OwnerLoanAccount ownerLoanAccount = ownerLoanAccountDao.getOneByField(OwnerLoanAccount::getOwnerUserNo,
ownerLoanRecord.getOwnerUserNo()).get();
OwnerLoanAccount entity = new OwnerLoanAccount();
if (OwnerLoanRecordEnum.LoanType.FUND.getCode().equals(ownerLoanRecord.getLoanType())) {
entity.setFundingArrears(ownerLoanRecord.getLoanBalance());
entity.setVirtuallyArrears(BigDecimal.ZERO);
} else {
entity.setFundingArrears(BigDecimal.ZERO);
entity.setVirtuallyArrears(ownerLoanRecord.getLoanBalance());
}
entity.setFundingFrozenBalance(BigDecimal.ZERO);
entity.setFundingUsableBalance(BigDecimal.ZERO);
entity.setFundingAccountBalance(BigDecimal.ZERO);
entity.setVirtuallyFrozenBalance(BigDecimal.ZERO);
entity.setVirtuallyUsableBalance(BigDecimal.ZERO);
entity.setVirtuallyAccountBalance(BigDecimal.ZERO);
entity.setId(ownerLoanAccount.getId());
entity.setModifiedTime(ownerLoanAccount.getModifiedTime());
Integer flag = ownerLoanAccountDao.updateAccountCAS(entity, LocalDateTime.now(), false);
if (flag > 0) {
break;
}
}
//生成付款记录 //生成付款记录
OwnerPayment ownerPayment = new OwnerPayment(); OwnerPayment ownerPayment = new OwnerPayment();
ownerPayment.setOwnerUserNo(ownerRepayment.getOwnerUserNo()); ownerPayment.setOwnerUserNo(ownerRepayment.getOwnerUserNo());
...@@ -297,6 +325,9 @@ public class OwnerRepaymentServiceImpl implements OwnerRepaymentService { ...@@ -297,6 +325,9 @@ public class OwnerRepaymentServiceImpl implements OwnerRepaymentService {
ownerPayment.setPayChannel(OwnerLoanRecordEnum.PayChannel.ASSET.getCode()); ownerPayment.setPayChannel(OwnerLoanRecordEnum.PayChannel.ASSET.getCode());
ownerPayment.setCreateBy("系统"); ownerPayment.setCreateBy("系统");
ownerPaymentDao.saveEntity(ownerPayment); ownerPaymentDao.saveEntity(ownerPayment);
applicationEventPublisher.publishEvent(new OwnerLoanFlagEvent(this, ownerRepayment.getLoanNo()));
} }
@Override @Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论