demand: TMS系统 - 客户账单管理 - 现金账单核销/月结账单核销 - 登记收款时:理赔金额有填写,保存成功后 账单对应的理赔金额和收款状态未更新 TMS系统 - 客户账单管理 - 现金账单核销/月结账单核销 - 收款/退款后同步更新账单对应发票的收款状态、已收金额。 TMS系统 - 客户账单管理 - 业务开票申请 - 生成发票时根据发票关联的账单自动计算生成发票的收款状态、已收金额。
committer: heyu
This commit is contained in:
parent
1f3bf7cfd9
commit
08f1f2e0c8
@ -1,10 +1,10 @@
|
||||
/**
|
||||
/**
|
||||
* @Project: emis
|
||||
* @Title: EmisSettleBillServiceImpl.java
|
||||
* @author linfso
|
||||
* @date 2024-07-03 18:54:51
|
||||
* @Copyright: ShangHai Duta 2022 All rights reserved.
|
||||
* @version v1.0
|
||||
* @version v1.0
|
||||
* @Description: <p> 结算总账单 实体类 </p>
|
||||
*/
|
||||
|
||||
@ -58,7 +58,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 结算总账单Service业务层处理
|
||||
*
|
||||
*
|
||||
* @author linfso
|
||||
* @date 2024-07-03 18:54:51
|
||||
*/
|
||||
@ -73,6 +73,9 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
@Autowired
|
||||
private EmisSettleSubBillMapper emisSettleSubBillMapper;
|
||||
|
||||
@Autowired
|
||||
private EmisSettleInvoiceRecordMapper emisSettleInvoiceRecordMapper;
|
||||
|
||||
@Autowired
|
||||
private EmisSettleInvoiceRelMapper emisSettleInvoiceRelMapper;
|
||||
|
||||
@ -103,7 +106,7 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
|
||||
/**
|
||||
* 查询结算总账单
|
||||
*
|
||||
*
|
||||
* @param id 结算总账单主键
|
||||
* @return 结算总账单
|
||||
*/
|
||||
@ -158,7 +161,7 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
|
||||
/**
|
||||
* 查询结算总账单列表
|
||||
*
|
||||
*
|
||||
* @param emisSettleBill 结算总账单
|
||||
* @return 结算总账单
|
||||
*/
|
||||
@ -170,8 +173,8 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
|
||||
/**
|
||||
* 检查是否重复
|
||||
*
|
||||
* @param emisSettleBill
|
||||
*
|
||||
* @param emisSettleBill
|
||||
* @return 数量
|
||||
*/
|
||||
@Override
|
||||
@ -238,7 +241,7 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
|
||||
/**
|
||||
* 新增结算总账单
|
||||
*
|
||||
*
|
||||
* @param emisSettleBill 结算总账单
|
||||
* @return 结果
|
||||
*/
|
||||
@ -836,55 +839,59 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
|
||||
/**
|
||||
* 重算账单收款状态
|
||||
*
|
||||
* @param settleBillNo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int reCalcSettleBillPayStatus(String settleBillNo){
|
||||
public int reCalcSettleBillPayStatus(String settleBillNo) {
|
||||
|
||||
EmisSettleBill oldBill = getSettleBillBySettleBillNo(settleBillNo);
|
||||
// 获取收款记录
|
||||
List<EmisSettlePayRecord> payRecordList=emisSettlePayRecordMapper.selectSettlePayRecordListBySettleBillNo(settleBillNo);
|
||||
List<EmisSettlePayRecord> payRecordList = emisSettlePayRecordMapper
|
||||
.selectSettlePayRecordListBySettleBillNo(settleBillNo);
|
||||
|
||||
// 计算已收款金额
|
||||
BigDecimal totalHasPayMoney = BigDecimal.ZERO;
|
||||
|
||||
// 抵扣金额
|
||||
// 理赔金额
|
||||
BigDecimal satisfyMoney = BigDecimal.ZERO;
|
||||
/* allowance_money */
|
||||
/* 折让 */
|
||||
BigDecimal allowanceMoney = BigDecimal.ZERO;
|
||||
/* deduction_money */
|
||||
/* 折扣 */
|
||||
BigDecimal deductionMoney = BigDecimal.ZERO;
|
||||
/* other_money */
|
||||
/* 其他 */
|
||||
BigDecimal otherMoney = BigDecimal.ZERO;
|
||||
// refund_money
|
||||
BigDecimal refundMoney = BigDecimal.ZERO;
|
||||
|
||||
log.debug("reCalcSettleBillPayStatus===>应收:{}",oldBill.getRecMoney());
|
||||
log.debug("reCalcSettleBillPayStatus===>应收:{}", oldBill.getRecMoney());
|
||||
|
||||
for(EmisSettlePayRecord item:payRecordList){
|
||||
for (EmisSettlePayRecord item : payRecordList) {
|
||||
totalHasPayMoney = totalHasPayMoney.add(item.getPayMoney());
|
||||
satisfyMoney = satisfyMoney.add(item.getSatisfyMoney() == null ? BigDecimal.ZERO : item.getSatisfyMoney());
|
||||
allowanceMoney = allowanceMoney.add(item.getAllowanceMoney() == null ? BigDecimal.ZERO : item.getAllowanceMoney());
|
||||
deductionMoney = deductionMoney.add(item.getDeductionMoney() == null ? BigDecimal.ZERO : item.getDeductionMoney());
|
||||
allowanceMoney = allowanceMoney
|
||||
.add(item.getAllowanceMoney() == null ? BigDecimal.ZERO : item.getAllowanceMoney());
|
||||
deductionMoney = deductionMoney
|
||||
.add(item.getDeductionMoney() == null ? BigDecimal.ZERO : item.getDeductionMoney());
|
||||
otherMoney = otherMoney.add(item.getOtherMoney() == null ? BigDecimal.ZERO : item.getOtherMoney());
|
||||
|
||||
if("2".equals(item.getRecType())) {
|
||||
if ("2".equals(item.getRecType())) {
|
||||
refundMoney = refundMoney.add(item.getRefundMoney() == null ? BigDecimal.ZERO : item.getRefundMoney());
|
||||
}
|
||||
}
|
||||
|
||||
// 更新运单的收款状态
|
||||
if(totalHasPayMoney.compareTo(BigDecimal.ZERO) > 0){
|
||||
if (totalHasPayMoney.compareTo(BigDecimal.ZERO) > 0) {
|
||||
BigDecimal totalMoney = BigDecimal.ZERO;
|
||||
// 更新运单收款记录
|
||||
List<Map> listRel=emisSettlePayRelMapper.selectHasPayMapList(settleBillNo);
|
||||
if(!CollectionUtils.isEmpty(listRel)) {
|
||||
List<Map> listRel = emisSettlePayRelMapper.selectHasPayMapList(settleBillNo);
|
||||
if (!CollectionUtils.isEmpty(listRel)) {
|
||||
|
||||
for(Map item:listRel){
|
||||
for (Map item : listRel) {
|
||||
|
||||
String billNo= MapUtils.getString(item,"billNo",null);
|
||||
if(StringUtils.isEmpty(billNo)){
|
||||
String billNo = MapUtils.getString(item, "billNo", null);
|
||||
if (StringUtils.isEmpty(billNo)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -895,24 +902,24 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
EmisWaybill emisWaybill = new EmisWaybill();
|
||||
emisWaybill.setBillCode(subBill.getBillCode());
|
||||
|
||||
String paymentStatusDesc="";
|
||||
String paymentStatusDesc = "";
|
||||
|
||||
if( sumMoney.compareTo(BigDecimal.ZERO) == 0 ){
|
||||
if (sumMoney.compareTo(BigDecimal.ZERO) == 0) {
|
||||
emisWaybill.setPaymentStatus("0");
|
||||
paymentStatusDesc="未付款";
|
||||
}else{
|
||||
paymentStatusDesc = "未付款";
|
||||
} else {
|
||||
if (sumMoney.compareTo(subBill.getBillFee()) >= 0) {
|
||||
paymentStatusDesc="已付款";
|
||||
paymentStatusDesc = "已付款";
|
||||
emisWaybill.setPaymentStatus("1");
|
||||
} else {
|
||||
paymentStatusDesc="部分付款";
|
||||
paymentStatusDesc = "部分付款";
|
||||
emisWaybill.setPaymentStatus("2");
|
||||
}
|
||||
}
|
||||
|
||||
emisWaybillMapper.updatePayedStatus(emisWaybill);
|
||||
|
||||
EmisSettleSubBill updEmisSettleSubBill=new EmisSettleSubBill();
|
||||
EmisSettleSubBill updEmisSettleSubBill = new EmisSettleSubBill();
|
||||
updEmisSettleSubBill.setPaymentStatus(emisWaybill.getPaymentStatus());
|
||||
updEmisSettleSubBill.setRecedMoney(sumMoney);
|
||||
updEmisSettleSubBill.setBillCode(subBill.getBillCode());
|
||||
@ -924,22 +931,21 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
WaybillOperLogType.SITE_PAYMENT_STATUS_CHANGE,
|
||||
null,
|
||||
null,
|
||||
"收款状态变更["+paymentStatusDesc+"]"
|
||||
);
|
||||
"收款状态变更[" + paymentStatusDesc + "]");
|
||||
// 计算占用
|
||||
// try {
|
||||
// EmisWaybill oldBillA = getWaybillByBillCode(subBill.getBillCode());
|
||||
// reCalcUseQuotaCredit(oldBillA,null);
|
||||
// } catch (EmisBizError emisBizError) {
|
||||
// emisBizError.printStackTrace();
|
||||
// }
|
||||
// try {
|
||||
// EmisWaybill oldBillA = getWaybillByBillCode(subBill.getBillCode());
|
||||
// reCalcUseQuotaCredit(oldBillA,null);
|
||||
// } catch (EmisBizError emisBizError) {
|
||||
// emisBizError.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
// 全部收款金额
|
||||
BigDecimal totalAllPayMoney = BigDecimal.ZERO;
|
||||
|
||||
// 收款金额
|
||||
totalAllPayMoney=totalMoney
|
||||
totalAllPayMoney = totalMoney
|
||||
.add(satisfyMoney)
|
||||
.add(allowanceMoney)
|
||||
.add(deductionMoney)
|
||||
@ -956,19 +962,18 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
newBill.setRefundMoney(refundMoney);
|
||||
|
||||
// 更新账单收款状态 收款金额
|
||||
log.debug("reCalcSettleBillPayStatus===>收款金额:{},应收:{}",totalMoney,oldBill.getRecMoney());
|
||||
log.debug("reCalcSettleBillPayStatus===>收款金额:{},应收:{}", totalMoney, oldBill.getRecMoney());
|
||||
|
||||
if( totalAllPayMoney.compareTo(BigDecimal.ZERO) == 0 ){
|
||||
if (totalAllPayMoney.compareTo(BigDecimal.ZERO) == 0) {
|
||||
newBill.setPaymentStatus("0");
|
||||
emisSettleBillMapper.updateEmisSettleBill(newBill);
|
||||
}else{
|
||||
int rstDif=totalAllPayMoney.compareTo(oldBill.getRecMoney());
|
||||
if( rstDif >= 0 ){
|
||||
} else {
|
||||
int rstDif = totalAllPayMoney.compareTo(oldBill.getRecMoney());
|
||||
if (rstDif >= 0) {
|
||||
// 已收款
|
||||
newBill.setPaymentStatus("1");
|
||||
emisSettleBillMapper.updateEmisSettleBill(newBill);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
// 部分收款
|
||||
newBill.setPaymentStatus("2");
|
||||
emisSettleBillMapper.updateEmisSettleBill(newBill);
|
||||
@ -977,18 +982,18 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
|
||||
}
|
||||
// 如果没有收款记录则设置账单为未收款
|
||||
else{
|
||||
else {
|
||||
|
||||
// 全部收款金额
|
||||
BigDecimal totalAllPayMoney = BigDecimal.ZERO;
|
||||
// 收款金额-退款金额
|
||||
totalAllPayMoney=totalMoney
|
||||
totalAllPayMoney = totalMoney
|
||||
.add(satisfyMoney)
|
||||
.add(allowanceMoney)
|
||||
.add(deductionMoney)
|
||||
.add(otherMoney);
|
||||
|
||||
// .subtract(refundMoney);
|
||||
// .subtract(refundMoney);
|
||||
|
||||
EmisSettleBill newBill = new EmisSettleBill();
|
||||
newBill.setId(oldBill.getId());
|
||||
@ -1001,18 +1006,17 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
newBill.setRefundMoney(refundMoney);
|
||||
|
||||
// 更新账单收款状态 收款金额
|
||||
log.debug("reCalcSettleBillPayStatus===>收款金额:{},应收:{}",totalMoney,oldBill.getRecMoney());
|
||||
if( totalAllPayMoney.compareTo(BigDecimal.ZERO) == 0 ){
|
||||
log.debug("reCalcSettleBillPayStatus===>收款金额:{},应收:{}", totalMoney, oldBill.getRecMoney());
|
||||
if (totalAllPayMoney.compareTo(BigDecimal.ZERO) == 0) {
|
||||
newBill.setPaymentStatus("0");
|
||||
emisSettleBillMapper.updateEmisSettleBill(newBill);
|
||||
}else{
|
||||
int rstDif=totalAllPayMoney.compareTo(oldBill.getRecMoney());
|
||||
if( rstDif >= 0 ){
|
||||
} else {
|
||||
int rstDif = totalAllPayMoney.compareTo(oldBill.getRecMoney());
|
||||
if (rstDif >= 0) {
|
||||
// 已收款
|
||||
newBill.setPaymentStatus("1");
|
||||
emisSettleBillMapper.updateEmisSettleBill(newBill);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
// 部分收款
|
||||
newBill.setPaymentStatus("2");
|
||||
emisSettleBillMapper.updateEmisSettleBill(newBill);
|
||||
@ -1022,9 +1026,9 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
// 未收款则更新运单状态未收款状态
|
||||
List<EmisSettleSubBill> list = emisBaseService.selectSubBillListBySettleBillNo(settleBillNo);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
for (EmisSettleSubBill subBill:list) {
|
||||
for (EmisSettleSubBill subBill : list) {
|
||||
// 已收款
|
||||
if("1".equals(newBill.getPaymentStatus())) {
|
||||
if ("1".equals(newBill.getPaymentStatus())) {
|
||||
// 更新子账单收款状态
|
||||
EmisSettleSubBill updEmisSettleSubBill = new EmisSettleSubBill();
|
||||
updEmisSettleSubBill.setPaymentStatus("1");
|
||||
@ -1039,7 +1043,7 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
emisWaybillMapper.updatePayedStatus(emisWaybill);
|
||||
}
|
||||
// 未收款
|
||||
else{
|
||||
else {
|
||||
// 更新子账单收款状态
|
||||
EmisSettleSubBill updEmisSettleSubBill = new EmisSettleSubBill();
|
||||
updEmisSettleSubBill.setPaymentStatus("0");
|
||||
@ -1058,20 +1062,19 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
|
||||
// 全部收款金额
|
||||
BigDecimal totalAllPayMoney = BigDecimal.ZERO;
|
||||
BigDecimal totalMoney = BigDecimal.ZERO;
|
||||
// 收款金额
|
||||
totalAllPayMoney=totalMoney
|
||||
totalAllPayMoney = totalMoney
|
||||
.add(satisfyMoney)
|
||||
.add(allowanceMoney)
|
||||
.add(deductionMoney)
|
||||
.add(otherMoney);
|
||||
|
||||
// .subtract(refundMoney);
|
||||
// .subtract(refundMoney);
|
||||
|
||||
EmisSettleBill newBill = new EmisSettleBill();
|
||||
newBill.setId(oldBill.getId());
|
||||
@ -1084,32 +1087,30 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
newBill.setRefundMoney(refundMoney);
|
||||
|
||||
// 更新账单收款状态 收款金额
|
||||
log.debug("reCalcSettleBillPayStatus===>收款金额:{},应收:{}",totalMoney,oldBill.getRecMoney());
|
||||
if( totalAllPayMoney.compareTo(BigDecimal.ZERO) == 0 ){
|
||||
log.debug("reCalcSettleBillPayStatus===>收款金额:{},应收:{}", totalMoney, oldBill.getRecMoney());
|
||||
if (totalAllPayMoney.compareTo(BigDecimal.ZERO) == 0) {
|
||||
newBill.setPaymentStatus("0");
|
||||
emisSettleBillMapper.updateEmisSettleBill(newBill);
|
||||
}else{
|
||||
int rstDif=totalAllPayMoney.compareTo(oldBill.getRecMoney());
|
||||
if( rstDif >= 0 ){
|
||||
} else {
|
||||
int rstDif = totalAllPayMoney.compareTo(oldBill.getRecMoney());
|
||||
if (rstDif >= 0) {
|
||||
// 已收款
|
||||
newBill.setPaymentStatus("1");
|
||||
emisSettleBillMapper.updateEmisSettleBill(newBill);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
// 部分收款
|
||||
newBill.setPaymentStatus("2");
|
||||
emisSettleBillMapper.updateEmisSettleBill(newBill);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 未收款则更新运单状态未收款状态
|
||||
List<EmisSettleSubBill> list = emisBaseService.selectSubBillListBySettleBillNo(settleBillNo);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
for (EmisSettleSubBill subBill:list) {
|
||||
for (EmisSettleSubBill subBill : list) {
|
||||
|
||||
// 已收款
|
||||
if("1".equals(newBill.getPaymentStatus())) {
|
||||
if ("1".equals(newBill.getPaymentStatus())) {
|
||||
// 更新子账单收款状态
|
||||
EmisSettleSubBill updEmisSettleSubBill = new EmisSettleSubBill();
|
||||
updEmisSettleSubBill.setPaymentStatus("1");
|
||||
@ -1124,7 +1125,7 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
emisWaybillMapper.updatePayedStatus(emisWaybill);
|
||||
}
|
||||
// 未收款
|
||||
else{
|
||||
else {
|
||||
// 更新子账单收款状态
|
||||
EmisSettleSubBill updEmisSettleSubBill = new EmisSettleSubBill();
|
||||
updEmisSettleSubBill.setPaymentStatus("0");
|
||||
@ -1143,7 +1144,81 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
// 更新发票收款状态
|
||||
updateInvoicePaymentStatus(settleBillNo);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新发票收款状态(发票不考虑理赔金额等)
|
||||
*
|
||||
* @param settleBillNo 账单号
|
||||
*/
|
||||
private void updateInvoicePaymentStatus(String settleBillNo) {
|
||||
try {
|
||||
// 获取所有包含当前账单号的发票记录(发票可能对应多个账单号,用逗号分隔)
|
||||
List<EmisSettleInvoiceRecord> invoiceRecordList = emisSettleInvoiceRecordMapper
|
||||
.selectInvoiceRecordListBySettleBillNo(settleBillNo);
|
||||
if (CollectionUtils.isEmpty(invoiceRecordList)) {
|
||||
log.debug("updateInvoicePaymentStatus===>账单{}没有发票记录", settleBillNo);
|
||||
return;
|
||||
}
|
||||
|
||||
// 遍历每个发票记录,更新其收款状态
|
||||
for (EmisSettleInvoiceRecord invoiceRecord : invoiceRecordList) {
|
||||
String invoiceSettleBillNo = invoiceRecord.getSettleBillNo();
|
||||
if (StringUtils.isEmpty(invoiceSettleBillNo)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 解析发票对应的所有账单号(可能用逗号分隔)
|
||||
String[] billNoArray = invoiceSettleBillNo.split(",");
|
||||
BigDecimal totalRecedMoney = BigDecimal.ZERO;
|
||||
|
||||
// 遍历发票对应的每个账单号,计算每个账单的实际收款金额并累加
|
||||
for (String billNo : billNoArray) {
|
||||
billNo = billNo.trim();
|
||||
if (StringUtils.isEmpty(billNo)) {
|
||||
continue;
|
||||
}
|
||||
// 通过账单号查询emis_settle_bill获取reced_money作为已收金额
|
||||
EmisSettleBill bill = selectEmisSettleBillBySettleBillNo(billNo);
|
||||
BigDecimal billTotalHasPayMoney = (bill != null && bill.getRecedMoney() != null)
|
||||
? bill.getRecedMoney()
|
||||
: BigDecimal.ZERO;
|
||||
totalRecedMoney = totalRecedMoney.add(billTotalHasPayMoney);
|
||||
}
|
||||
|
||||
// 获取发票申请金额
|
||||
BigDecimal applyMoney = invoiceRecord.getApplyMoney() != null ? invoiceRecord.getApplyMoney()
|
||||
: BigDecimal.ZERO;
|
||||
|
||||
// 计算收款状态
|
||||
String paymentStatus;
|
||||
if (totalRecedMoney.compareTo(BigDecimal.ZERO) == 0) {
|
||||
paymentStatus = "0"; // 未付款
|
||||
} else if (totalRecedMoney.compareTo(applyMoney) >= 0) {
|
||||
paymentStatus = "1"; // 已付款
|
||||
} else {
|
||||
paymentStatus = "2"; // 部分付款
|
||||
}
|
||||
|
||||
// 更新发票记录收款状态
|
||||
EmisSettleInvoiceRecord updateInvoiceRecord = new EmisSettleInvoiceRecord();
|
||||
updateInvoiceRecord.setId(invoiceRecord.getId());
|
||||
updateInvoiceRecord.setPaymentStatus(paymentStatus);
|
||||
updateInvoiceRecord.setRecedMoney(totalRecedMoney);
|
||||
emisSettleInvoiceRecordMapper.updateEmisSettleInvoiceRecord(updateInvoiceRecord);
|
||||
|
||||
log.debug("updateInvoicePaymentStatus===>发票申请序号:{}, 收款状态:{}, 已收金额:{}, 申请金额:{}, 对应账单号:{}",
|
||||
invoiceRecord.getApplySeqNo(), paymentStatus, totalRecedMoney, applyMoney, invoiceSettleBillNo);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("updateInvoicePaymentStatus===>更新发票收款状态失败,账单号: {}", settleBillNo, e);
|
||||
// 不抛出异常,避免影响主流程
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void exportSeaWayBill(HttpServletResponse response, EmisSettleBill emisSettleBill) {
|
||||
@ -1414,7 +1489,7 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
|
||||
/**
|
||||
* 修改结算总账单
|
||||
*
|
||||
*
|
||||
* @param emisSettleBill 结算总账单
|
||||
* @return 结果
|
||||
*/
|
||||
@ -1426,7 +1501,7 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
|
||||
/**
|
||||
* 批量删除结算总账单
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的结算总账单主键
|
||||
* @return 结果
|
||||
*/
|
||||
@ -1446,7 +1521,7 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
|
||||
/**
|
||||
* 删除结算总账单信息
|
||||
*
|
||||
*
|
||||
* @param id 结算总账单主键
|
||||
* @return 结果
|
||||
*/
|
||||
|
||||
@ -33,6 +33,7 @@ import org.springframework.stereotype.Service;
|
||||
import com.xdadan.erp.emis.mapper.EmisSettleInvoiceRecordMapper;
|
||||
import com.xdadan.erp.emis.service.IEmisSettleInvoiceRecordService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.xdadan.erp.emis.mapper.EmisSettlePayRecordMapper;
|
||||
|
||||
/**
|
||||
* 开票记录表Service业务层处理
|
||||
@ -62,6 +63,9 @@ public class EmisSettleInvoiceRecordServiceImpl extends EmisBaseService implemen
|
||||
@Autowired
|
||||
private EmisCustomerInvoiceInfoMapper emisCustomerInvoiceInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private EmisSettlePayRecordMapper emisSettlePayRecordMapper;
|
||||
|
||||
/**
|
||||
* 查询开票记录表
|
||||
*
|
||||
@ -192,6 +196,29 @@ public class EmisSettleInvoiceRecordServiceImpl extends EmisBaseService implemen
|
||||
emisSettleInvoiceRecord.setApplyManCode(getCurrentUser().getEmpCode());
|
||||
emisSettleInvoiceRecord.setApplySiteCode(getCurrentUser().getOwnerSiteCode());
|
||||
emisSettleInvoiceRecord.setApplyDate(new Date());
|
||||
// 计算发票已收金额与收款状态
|
||||
BigDecimal totalRecedMoney = BigDecimal.ZERO;
|
||||
for (String billNoItem : settBillNoArr) {
|
||||
String billNoTrim = billNoItem == null ? null : billNoItem.trim();
|
||||
if (StringUtils.isEmpty(billNoTrim)) {
|
||||
continue;
|
||||
}
|
||||
// 通过账单号查询emis_settle_bill获取reced_money作为已收金额
|
||||
EmisSettleBill bill = getSettleBillBySettleBillNo(billNoTrim);
|
||||
BigDecimal billRecedMoney = (bill != null && bill.getRecedMoney() != null) ? bill.getRecedMoney()
|
||||
: BigDecimal.ZERO;
|
||||
totalRecedMoney = totalRecedMoney.add(billRecedMoney);
|
||||
}
|
||||
emisSettleInvoiceRecord.setRecedMoney(totalRecedMoney);
|
||||
String paymentStatus;
|
||||
if (totalRecedMoney.compareTo(BigDecimal.ZERO) == 0) {
|
||||
paymentStatus = "0"; // 未付款
|
||||
} else if (totalRecedMoney.compareTo(emisSettleInvoiceRecord.getApplyMoney()) >= 0) {
|
||||
paymentStatus = "1"; // 已付款
|
||||
} else {
|
||||
paymentStatus = "2"; // 部分付款
|
||||
}
|
||||
emisSettleInvoiceRecord.setPaymentStatus(paymentStatus);
|
||||
// 插入开票记录
|
||||
emisSettleInvoiceRecordMapper.insertEmisSettleInvoiceRecord(emisSettleInvoiceRecord);
|
||||
|
||||
@ -248,7 +275,7 @@ public class EmisSettleInvoiceRecordServiceImpl extends EmisBaseService implemen
|
||||
|
||||
/**
|
||||
* 中心驳回
|
||||
*
|
||||
*
|
||||
* @param inputObj
|
||||
* @return
|
||||
* @throws EmisBizError
|
||||
@ -289,7 +316,7 @@ public class EmisSettleInvoiceRecordServiceImpl extends EmisBaseService implemen
|
||||
|
||||
/**
|
||||
* 审核通过
|
||||
*
|
||||
*
|
||||
* @param inputObj
|
||||
* @return
|
||||
* @throws EmisBizError
|
||||
@ -338,7 +365,7 @@ public class EmisSettleInvoiceRecordServiceImpl extends EmisBaseService implemen
|
||||
|
||||
/**
|
||||
* 根据运单号列表查询开票记录
|
||||
*
|
||||
*
|
||||
* @param billCodes 运单号列表
|
||||
* @return 开票记录列表
|
||||
*/
|
||||
|
||||
@ -497,8 +497,8 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
for (EmisSettlePayInvoiceRel itemSettlePayInvoiceRel : emisSettlePayRecord.getPayInvoiceRelList()) {
|
||||
itemSettlePayInvoiceRel.setPayId(payId);
|
||||
emisSettlePayInvoiceRelMapper.insertEmisSettlePayInvoiceRel(itemSettlePayInvoiceRel);
|
||||
// 更新收款状态
|
||||
emisSettleInvoiceRecordMapper.updateHasPayByApplySeqNo(itemSettlePayInvoiceRel.getApplySeqNo());
|
||||
// // 更新收款状态
|
||||
// emisSettleInvoiceRecordMapper.updateHasPayByApplySeqNo(itemSettlePayInvoiceRel.getApplySeqNo());
|
||||
}
|
||||
}
|
||||
|
||||
@ -520,16 +520,16 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
// 插入数据
|
||||
emisSettlePayRecordMapper.insertEmisSettlePayRecord(emisSettlePayRecord);
|
||||
|
||||
// // 重新计算账单收款信息
|
||||
// for (int i = 0; i < settleBillNoArr.size(); i++) {
|
||||
// String settleBillNo = settleBillNoArr.get(i);
|
||||
// if (!StringUtils.isEmpty(settleBillNo)) {
|
||||
// emisSettleBillService.reCalcSettleBillPayStatus(settleBillNo);
|
||||
// }
|
||||
// }
|
||||
// 重新计算账单收款信息
|
||||
for (int i = 0; i < settleBillNoArr.size(); i++) {
|
||||
String settleBillNo = settleBillNoArr.get(i);
|
||||
if (!StringUtils.isEmpty(settleBillNo)) {
|
||||
emisSettleBillService.reCalcSettleBillPayStatus(settleBillNo);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理部分收款逻辑 - 更新各个维度的收款状态
|
||||
updatePartialPaymentStatus(emisSettlePayRecord, settleBillNoArr);
|
||||
// // 处理部分收款逻辑 - 更新各个维度的收款状态
|
||||
// updatePartialPaymentStatus(emisSettlePayRecord, settleBillNoArr);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -374,6 +374,8 @@
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="createSite != null and createSite != ''">create_site,</if>
|
||||
<if test="updateSite != null and updateSite != ''">update_site,</if>
|
||||
<if test="paymentStatus != null and paymentStatus != ''">payment_status,</if>
|
||||
<if test="recedMoney != null">reced_money,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="applySeqNo != null and applySeqNo != ''">#{applySeqNo},</if>
|
||||
@ -428,6 +430,8 @@
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="createSite != null and createSite != ''">#{createSite},</if>
|
||||
<if test="updateSite != null and updateSite != ''">#{updateSite},</if>
|
||||
<if test="paymentStatus != null and paymentStatus != ''">#{paymentStatus},</if>
|
||||
<if test="recedMoney != null">#{recedMoney},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user