提交 99bafec2 authored 作者: liuhaiquan's avatar liuhaiquan

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

Merge remote-tracking branch 'origin/v10.7_borrowing_and_repayment_20240118' into v10.7_borrowing_and_repayment_20240118
......@@ -70,7 +70,7 @@ public enum OwnerLoanRecordEnum {
}
public static String getMsgByCode(Integer code) {
return getByCode(code).map(LoanFlag::getMsg).orElse(null);
return getByCode(code).map(LoanFlag::getMsg).orElse("无需借款");
}
}
......
......@@ -65,7 +65,7 @@ public class CarrierPageSettlementDriverDetailVO {
private Integer loanFlag;
@ApiModelProperty(value = "借款标示 0:未借款 1:已借款 2:已还款")
private Integer loanFlagMsg;
private String loanFlagMsg;
@MoneyOutConvert
@ApiModelProperty(value = "结算金额")
......
......@@ -64,7 +64,7 @@ public class CarrierPageSettlementDriverVO {
private Integer loanFlag;
@ApiModelProperty(value = "借款标示 0:未借款 1:已借款 2:已还款")
private Integer loanFlagMsg;
private String loanFlagMsg;
@MoneyOutConvert
@ApiModelProperty(value = "结算金额")
......
......@@ -45,6 +45,7 @@ public class CarrierPageSettlementOwnerVO {
@MoneyOutConvert
@ApiModelProperty(value = "结算金额")
private BigDecimal settlementFreight;
@MoneyOutConvert
@ApiModelProperty(value = "借款金额")
private BigDecimal loanFreight;
@MoneyOutConvert
......
......@@ -192,7 +192,7 @@ public class OrderChildLoanComponent {
OwnerQuotationDetailVO quotationDetailVO = orderFeign.getQuotationByOrderNo(settlementDriverDetail.getOrderNo()).getData();
BigDecimal freightFreezeRate = quotationDetailVO.getFreightFreezeRate();
if (freightFreezeRate.compareTo(BigDecimal.ONE) == 0) {
if (freightFreezeRate.compareTo(new BigDecimal(100)) == 0) {
//百分百预付不需要考虑借款账户
log.info("1.1百分百预付不需要考虑借款账户");
return;
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.model.loan.OwnerLoanAccountRunningWaterRecord;
import com.clx.performance.param.pc.loan.carrier.PageOwnerLoanAccountWaterRecordOfOwnerParam;
......@@ -92,4 +93,11 @@ public class OwnerLoanAccountRunningWaterRecordDaoImpl extends BaseDaoImpl<Owner
.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())
); }
}
......@@ -57,14 +57,14 @@ public class OwnerLoanRecordDaoImpl extends BaseDaoImpl<OwnerLoanRecordMapper, O
}
/**
* 查询审批通过并且未用完的借款
* 查询审批通过和付款成功并且未用完的借款(资金+虚拟货币)
* @param userNo
* @return
*/
@Override
public List<OwnerLoanRecord> selectLoanBalance(Long userNo) {
return baseMapper.selectList(
lQrWrapper().eq(OwnerLoanRecord::getStatus, OwnerLoanRecordEnum.Status.APPROVE_PASS.getCode())
lQrWrapper().in(OwnerLoanRecord::getStatus, OwnerLoanRecordEnum.Status.APPROVE_PASS.getCode(), OwnerLoanRecordEnum.Status.PAY_SUCCESS.getCode())
.eq(OwnerLoanRecord::getOwnerUserNo , userNo)
.gt(OwnerLoanRecord::getLoanResidueBalance, 0)
.orderByAsc(OwnerLoanRecord::getId)
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.model.settle.SettlementDriver;
import com.clx.performance.param.pc.driver.PageCarrierSettlementDriverParam;
......@@ -13,6 +14,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;
import java.util.Objects;
import java.util.Set;
/**
* @Author: aiqinguo
......@@ -57,4 +59,11 @@ public class SettlementDriverDaoImpl extends BaseDaoImpl<SettlementDriverMapper,
)
.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;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.model.settle.SettlementDriverDetail;
import com.clx.performance.param.pc.driver.PageCarrierSettlementDriverDetailParam;
......@@ -15,6 +16,7 @@ import org.springframework.stereotype.Repository;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.Set;
/**
* @Author: aiqinguo
......@@ -81,4 +83,12 @@ public class SettlementDriverDetailDaoImpl extends BaseDaoImpl<SettlementDriverD
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
OwnerLoanAccountRunningWaterRecord getOneByChildNoAndStatus(String childNo, Integer type);
List<OwnerLoanAccountRunningWaterRecord> getListByOrderNoAndRunningWaterType(String childNo, Integer runningWaterType);
List<OwnerLoanAccountRunningWaterRecord> selectLoanRunningWatterRecord(Long loanNo);
}
......@@ -7,6 +7,8 @@ import com.clx.performance.param.pc.driver.PageCarrierSettlementDriverParam;
import com.msl.common.base.Optional;
import com.msl.common.dao.BaseDao;
import java.util.Set;
/**
* @Author: aiqinguo
* @Description: 车主结算单
......@@ -18,4 +20,6 @@ public interface SettlementDriverDao extends BaseDao<SettlementDriverMapper, Set
Optional<SettlementDriver> getByChildNo(String childNo);
void updateLoanFlagByChildNoList(Set<String> childNoList);
}
......@@ -9,6 +9,7 @@ import com.msl.common.dao.BaseDao;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;
/**
* @Author: aiqinguo
......@@ -31,4 +32,5 @@ public interface SettlementDriverDetailDao extends BaseDao<SettlementDriverDetai
List<SettlementDriverDetail> findByDriverSettlementIds(List<Integer> ids);
void updateLoanFlagByChildNoList(Set<String> childNoList);
}
......@@ -10,6 +10,7 @@ import com.msl.common.dao.BaseDao;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
/**
......
package com.clx.performance.event;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.json.JSONUtil;
import com.clx.performance.component.OrderChildLoanComponent;
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.settle.SettlementDriverDao;
import com.clx.performance.dao.settle.SettlementDriverDetailDao;
import com.clx.performance.dao.settle.SettlementOwnerDetailDao;
import com.clx.performance.dto.OwnerLoanMqDTO;
......@@ -12,6 +15,7 @@ import com.clx.performance.enums.loan.OwnerLoanRecordEnum;
import com.clx.performance.enums.loan.OwnerRePaymentEnum;
import com.clx.performance.model.OrderChild;
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.settle.SettlementDriverDetail;
import com.clx.performance.model.settle.SettlementOwnerDetail;
......@@ -23,6 +27,11 @@ import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@Component
@Slf4j
@AllArgsConstructor
......@@ -42,6 +51,10 @@ public class EventListenerComponent {
private final ApplicationEventPublisher applicationEventPublisher;
private final SettlementDriverDao settlementDriverDao;
private final OwnerLoanAccountRunningWaterRecordDao ownerLoanAccountRunningWaterRecordDao;
@EventListener(classes = {SettlementUpdateEvent.class})
public void listen(SettlementUpdateEvent event) {
......@@ -94,4 +107,28 @@ public class EventListenerComponent {
// 发送mq 通过开票标识
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> {
@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}" +
",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}"
+ "where id = #{account.id} and modified_time = #{account.modifiedTime}"
)
......@@ -30,7 +30,7 @@ public interface OwnerLoanAccountMapper extends BaseMapper<OwnerLoanAccount> {
@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}" +
",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}"
+ "where id = #{account.id} and modified_time = #{account.modifiedTime}"
)
......
......@@ -15,20 +15,16 @@ import com.clx.performance.config.ClxMessageConfig;
import com.clx.performance.config.loan.ClxPayeeConfig;
import com.clx.performance.config.loan.PaymentFromConfig;
import com.clx.performance.config.nbbank.NbBankConfig;
import com.clx.performance.dao.loan.BankTradeDao;
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.dao.loan.*;
import com.clx.performance.enums.PerformanceResultEnum;
import com.clx.performance.enums.loan.OwnerLoanRecordEnum;
import com.clx.performance.enums.loan.OwnerPaymentEnum;
import com.clx.performance.enums.loan.OwnerRePaymentEnum;
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.model.loan.BankTrade;
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.model.loan.*;
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.owner.ExportPaymentApplicationFormParam;
......@@ -54,9 +50,11 @@ import com.msl.user.data.UserSessionData;
import com.msl.user.utils.TokenUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
......@@ -84,6 +82,8 @@ public class OwnerRepaymentServiceImpl implements OwnerRepaymentService {
private final IdGenerateSnowFlake idGenerateSnowFlake;
private final OwnerPaymentDao ownerPaymentDao;
private final OwnerLoanRecordDao ownerLoanRecordDao;
private final ApplicationEventPublisher applicationEventPublisher;
private final OwnerLoanAccountDao ownerLoanAccountDao;
@Override
public IPage<OwnerRepaymentVO> pageOwnerRepayment(PageCarrierOwnerRepaymentParam param) {
......@@ -271,12 +271,40 @@ public class OwnerRepaymentServiceImpl implements OwnerRepaymentService {
// 查询还款信息
OwnerRepayment ownerRepayment = ownerRepaymentDao.getOneByField(OwnerRepayment::getRepaymentNo, bankTrade.getRelationNo()).get();
ownerRepayment.setStatus(OwnerRePaymentEnum.Status.PAY_SUCCESS.getCode());
// 更新款信息
// 更新款信息
ownerRepaymentDao.updateStatusById(ownerRepayment);
OwnerLoanRecord ownerLoanRecord = ownerLoanRecordDao.getOneByField(OwnerLoanRecord::getLoanNo,
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.setOwnerUserNo(ownerRepayment.getOwnerUserNo());
......@@ -297,6 +325,9 @@ public class OwnerRepaymentServiceImpl implements OwnerRepaymentService {
ownerPayment.setPayChannel(OwnerLoanRecordEnum.PayChannel.ASSET.getCode());
ownerPayment.setCreateBy("系统");
ownerPaymentDao.saveEntity(ownerPayment);
applicationEventPublisher.publishEvent(new OwnerLoanFlagEvent(this, ownerRepayment.getLoanNo()));
}
@Override
......
......@@ -13,8 +13,10 @@ import java.util.List;
@Mapper(componentModel = "spring", uses = DateStructUtil.class, imports = {DateUtils.class})
public interface SettlementDriverDetailStruct {
@Mapping(target = "loanFlagMsg", expression = "java(com.clx.performance.service.impl.settle.SettlementDriverDetailServiceImpl.formatLoanMsg(detail.getLoanFlag()))")
List<CarrierPageSettlementDriverDetailVO> covertList(List<SettlementDriverDetail> records);
@Mapping(target = "loanFlagMsg", expression = "java(com.clx.performance.enums.loan.OwnerLoanRecordEnum.LoanFlag.getMsgByCode(detail.getLoanFlag()))")
CarrierPageSettlementDriverDetailVO convert(SettlementDriverDetail detail);
OrderChildSyncTransportRecord convertRecord(SettlementDriverDetail detail);
}
......@@ -8,7 +8,6 @@ import org.mapstruct.IterableMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import java.util.List;
@Mapper(componentModel = "spring", uses = DateStructUtil.class, imports = {DateUtils.class})
......@@ -17,9 +16,9 @@ public interface SettlementDriverStruct {
@Named("toBaseVo")
@Mapping(target = "payErrorMsg", expression = "java(com.clx.performance.service.impl.settle.SettlementDriverServiceImpl.formatPayMsg(detail.getStatus(),detail.getPayErrorMsg()))")
@Mapping(target = "loanFlagMsg", expression = "java(com.clx.performance.enums.loan.OwnerLoanRecordEnum.LoanFlag.getMsgByCode(detail.getLoanFlag()))")
CarrierPageSettlementDriverVO convert(SettlementDriver detail);
@Mapping(target = "loanFlagMsg", expression = "java(com.clx.performance.service.impl.settle.SettlementDriverServiceImpl.formatLoanMsg(detail.getLoanFlag()))")
@IterableMapping(qualifiedByName = "toBaseVo")
List<CarrierPageSettlementDriverVO> covertList(List<SettlementDriver> records);
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论