|
|
@ -1,9 +1,12 @@
|
|
|
|
package com.ibeetl.jlw.flow.bankacceptancebill.service;
|
|
|
|
package com.ibeetl.jlw.flow.bankacceptancebill.service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
import com.ibeetl.admin.core.service.CoreBaseService;
|
|
|
|
import com.ibeetl.admin.core.service.CoreBaseService;
|
|
|
|
import com.ibeetl.admin.core.util.NoUtil;
|
|
|
|
import com.ibeetl.admin.core.util.NoUtil;
|
|
|
|
import com.ibeetl.jlw.flow.bankacceptancebill.dao.BankAcceptanceBillDao;
|
|
|
|
import com.ibeetl.jlw.flow.bankacceptancebill.dao.BankAcceptanceBillDao;
|
|
|
|
import com.ibeetl.jlw.flow.bankacceptancebill.entity.BankAcceptanceBill;
|
|
|
|
import com.ibeetl.jlw.flow.bankacceptancebill.entity.BankAcceptanceBill;
|
|
|
|
|
|
|
|
import com.ibeetl.jlw.flow.financings.entity.Financings;
|
|
|
|
|
|
|
|
import com.ibeetl.jlw.flow.financings.service.FinancingsService;
|
|
|
|
import com.ibeetl.jlw.service.ExaminationFinancialsService;
|
|
|
|
import com.ibeetl.jlw.service.ExaminationFinancialsService;
|
|
|
|
import com.ibeetl.jlw.service.ExaminationInstancesService;
|
|
|
|
import com.ibeetl.jlw.service.ExaminationInstancesService;
|
|
|
|
import org.beetl.sql.core.engine.PageQuery;
|
|
|
|
import org.beetl.sql.core.engine.PageQuery;
|
|
|
@ -11,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
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.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
@ -27,6 +31,9 @@ public class BankAcceptanceBillService extends CoreBaseService<BankAcceptanceBil
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ExaminationFinancialsService examinationFinancialsService;
|
|
|
|
private ExaminationFinancialsService examinationFinancialsService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private FinancingsService financingsService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 分页查询
|
|
|
|
* 分页查询
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -51,6 +58,7 @@ public class BankAcceptanceBillService extends CoreBaseService<BankAcceptanceBil
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 银行承兑汇票开具之后,银行收取手续费,导致买方企业资金减少
|
|
|
|
* 银行承兑汇票开具之后,银行收取手续费,导致买方企业资金减少
|
|
|
|
|
|
|
|
* 同时买方企业支付合同金额与汇票金额之间的差额部分货款给卖方企业,此时买方企业可用资金减少。
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|
public void addNew(BankAcceptanceBill dto) {
|
|
|
|
public void addNew(BankAcceptanceBill dto) {
|
|
|
@ -58,10 +66,18 @@ public class BankAcceptanceBillService extends CoreBaseService<BankAcceptanceBil
|
|
|
|
dto.setCreatedAt(new Date());
|
|
|
|
dto.setCreatedAt(new Date());
|
|
|
|
this.insert(dto);
|
|
|
|
this.insert(dto);
|
|
|
|
|
|
|
|
|
|
|
|
if (dto.getInvoiceFee() != null) {
|
|
|
|
if (dto.getInvoiceFee() != null && dto.getInvoiceFee().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
|
examinationFinancialsService.decrementBalance(dto.getExaminationId(), dto.getInstanceId(), "1", dto.getInvoiceFee()); // 买方资金减少
|
|
|
|
examinationFinancialsService.decrementBalance(dto.getExaminationId(), dto.getInstanceId(), "1", dto.getInvoiceFee()); // 买方资金减少
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 保兑仓 买方企业 把购销合同金额和融资申请金额的差额,发给卖方企业
|
|
|
|
|
|
|
|
final Financings financings = financingsService.queryById(dto.getFinancingId());
|
|
|
|
|
|
|
|
Assert.notNull(financings, "为查询到承兑汇票相关融资申请 " + dto.getFinancingId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final BigDecimal sub2 = financings.getContractAmount().subtract(financings.getApplyAmount());
|
|
|
|
|
|
|
|
examinationFinancialsService.decrementBalance(financings.getExaminationId(), financings.getInstanceId(), "1", sub2); // 买方资金减少
|
|
|
|
|
|
|
|
examinationFinancialsService.incrementBalance(financings.getExaminationId(), financings.getInstanceId(), "2", sub2); // 卖方资金增加
|
|
|
|
|
|
|
|
|
|
|
|
if (dto.getStep() != null) {
|
|
|
|
if (dto.getStep() != null) {
|
|
|
|
examinationInstancesService.finishStep(dto.getInstanceId(), dto.getStep());
|
|
|
|
examinationInstancesService.finishStep(dto.getInstanceId(), dto.getStep());
|
|
|
|
}
|
|
|
|
}
|
|
|
|