|
@ -143,7 +143,7 @@ public class BaseExpenseConfirmAmountServiceImpl implements IBaseExpenseConfirmA |
|
|
return rows; |
|
|
return rows; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 修改关联订单子表打款状态;
|
|
|
// 更新关联订单子表打款状态;
|
|
|
private int changeRelatedOrderStatus(String expenseCode,BaseExpenseConfirmAmount baseExpenseConfirmAmount){ |
|
|
private int changeRelatedOrderStatus(String expenseCode,BaseExpenseConfirmAmount baseExpenseConfirmAmount){ |
|
|
List<BaseExpenseAccountChild> expenseChildren = expenseAccountChildMapper.selectBaseExpenseAccountChildByExpenseCode(expenseCode); |
|
|
List<BaseExpenseAccountChild> expenseChildren = expenseAccountChildMapper.selectBaseExpenseAccountChildByExpenseCode(expenseCode); |
|
|
BaseExpenseAccount baseExpenseAccount = expenseAccountMapper.selectBaseExpenseAccountByCode(expenseCode); |
|
|
BaseExpenseAccount baseExpenseAccount = expenseAccountMapper.selectBaseExpenseAccountByCode(expenseCode); |
|
@ -156,26 +156,24 @@ public class BaseExpenseConfirmAmountServiceImpl implements IBaseExpenseConfirmA |
|
|
if(rows<= 0){ |
|
|
if(rows<= 0){ |
|
|
throw new BusinessException("更新应付账款记录失败!"); |
|
|
throw new BusinessException("更新应付账款记录失败!"); |
|
|
} |
|
|
} |
|
|
int updateResult = 0; |
|
|
String purchaseOrderCode = child.getPurchaseCode(); |
|
|
PurchaseOrderChild tempChild = new PurchaseOrderChild(); |
|
|
PurchaseOrder purchaseOrder = purchaseOrderMapper.selectPurchaseOrderByOrderCode(purchaseOrderCode); |
|
|
tempChild.setPurchaseOrderCode(child.getPurchaseCode()); |
|
|
if(purchaseOrder == null){ |
|
|
//tempChild.setSupplierCode(supplierCode);
|
|
|
throw new BusinessException("关联采购订单"+purchaseOrderCode+"不存在!"); |
|
|
List<PurchaseOrderChild> purchaseChildren = purchaseChildMapper.selectChildListBySupplierCodeAndOrderCode(tempChild); |
|
|
|
|
|
if(CollectionUtils.isNotEmpty(purchaseChildren)){ |
|
|
|
|
|
for (PurchaseOrderChild purchaseChild: purchaseChildren) { |
|
|
|
|
|
//purchaseChild.setPaymentStatus("2");
|
|
|
|
|
|
purchaseChildMapper.updatePurchaseOrderChild(purchaseChild); |
|
|
|
|
|
updateResult ++; |
|
|
|
|
|
} |
|
|
|
|
|
if(updateResult <= 0){ |
|
|
|
|
|
throw new BusinessException("采购订单详情记录更新失败!"); |
|
|
|
|
|
} |
|
|
|
|
|
int updatePurchaseOrder = updatePurchaseOrderPayableStatus(child.getPurchaseCode()); |
|
|
|
|
|
if(updatePurchaseOrder <= 0){ |
|
|
|
|
|
throw new BusinessException("采购订单打款状态更新失败!"); |
|
|
|
|
|
} |
|
|
|
|
|
influRows ++; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
BigDecimal paidPrice = child.getAmounts(); |
|
|
|
|
|
if(paidPrice.compareTo(purchaseOrder.getRmbSum()) == 0){ |
|
|
|
|
|
purchaseOrder.setPaymentStatus("4");//已结案
|
|
|
|
|
|
}else if(paidPrice.compareTo(purchaseOrder.getRmbSum()) < 0){ |
|
|
|
|
|
purchaseOrder.setPaymentStatus("1");//部分打款(需要手动结案)
|
|
|
|
|
|
} |
|
|
|
|
|
purchaseOrder.setUpdateBy(ShiroUtils.getLoginName()); |
|
|
|
|
|
purchaseOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
|
|
int updateResult = purchaseOrderMapper.updatePurchaseOrder(purchaseOrder); |
|
|
|
|
|
if(updateResult <= 0 ){ |
|
|
|
|
|
throw new BusinessException("关联采购订单更新失败"); |
|
|
|
|
|
} |
|
|
|
|
|
influRows ++; |
|
|
} |
|
|
} |
|
|
else if(child.getOutsourceCode()!=null&&!child.getOutsourceCode().isEmpty()){ |
|
|
else if(child.getOutsourceCode()!=null&&!child.getOutsourceCode().isEmpty()){ |
|
|
// 更新应付账款打款相关信息
|
|
|
// 更新应付账款打款相关信息
|
|
@ -208,42 +206,6 @@ public class BaseExpenseConfirmAmountServiceImpl implements IBaseExpenseConfirmA |
|
|
} |
|
|
} |
|
|
return influRows; |
|
|
return influRows; |
|
|
} |
|
|
} |
|
|
// 更新采购订单打款状态
|
|
|
|
|
|
public int updatePurchaseOrderPayableStatus(String purchaseOrderCode){ |
|
|
|
|
|
PurchaseOrder purchaseOrder = purchaseOrderMapper.selectPurchaseOrderByOrderCode(purchaseOrderCode); |
|
|
|
|
|
List<PurchaseOrderChild> purchaseOrderChildren = purchaseChildMapper.selectPurchaseOrderChildByOrderCode(purchaseOrderCode); |
|
|
|
|
|
// if(CollectionUtils.isEmpty(purchaseOrderChildren)){
|
|
|
|
|
|
// throw new BusinessException("采购订单详情记录为空!");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// String isAllPaid = "3";
|
|
|
|
|
|
// // 获取所有 paymentStatus 的集合
|
|
|
|
|
|
// Set<String> statuses = purchaseOrderChildren.stream()
|
|
|
|
|
|
// .map(PurchaseOrderChild::getPaymentStatus)
|
|
|
|
|
|
// .collect(Collectors.toSet());
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 判断状态
|
|
|
|
|
|
// if (statuses.size() == 1) {
|
|
|
|
|
|
// String singleStatus = statuses.iterator().next();
|
|
|
|
|
|
// if (singleStatus.equals("0")) {
|
|
|
|
|
|
// isAllPaid = "0";
|
|
|
|
|
|
// } else if (singleStatus.equals("2")) {
|
|
|
|
|
|
// isAllPaid = "1";
|
|
|
|
|
|
// }
|
|
|
|
|
|
// } else if (statuses.size() == 2 && statuses.contains("0") && statuses.contains("2")) {
|
|
|
|
|
|
// isAllPaid = "2";
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if(isAllPaid.equals("1")){
|
|
|
|
|
|
//// 订单内供应商全部打款
|
|
|
|
|
|
// purchaseOrder.setPaymentStatus("2");
|
|
|
|
|
|
// }else if(isAllPaid.equals("0")){
|
|
|
|
|
|
//// 订单内供应商全未打款
|
|
|
|
|
|
// purchaseOrder.setPaymentStatus("0");
|
|
|
|
|
|
// }else if(isAllPaid.equals("2")){
|
|
|
|
|
|
// purchaseOrder.setPaymentStatus("1");
|
|
|
|
|
|
// }
|
|
|
|
|
|
purchaseOrder.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
|
|
return purchaseOrderMapper.updatePurchaseOrder(purchaseOrder); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 更新委外订单打款状态
|
|
|
// 更新委外订单打款状态
|
|
|
public int updateOutsourceOrderPayableStatus(String outsourceOrderCode){ |
|
|
public int updateOutsourceOrderPayableStatus(String outsourceOrderCode){ |
|
@ -300,12 +262,18 @@ public class BaseExpenseConfirmAmountServiceImpl implements IBaseExpenseConfirmA |
|
|
if(insertResult <= 0){ |
|
|
if(insertResult <= 0){ |
|
|
throw new BusinessException("插入应付账款付款记录失败!"); |
|
|
throw new BusinessException("插入应付账款付款记录失败!"); |
|
|
} |
|
|
} |
|
|
accountsPayable.setAccountsPayableStatus("2"); |
|
|
|
|
|
accountsPayable.setPaidPrice(paidPrice); |
|
|
accountsPayable.setPaidPrice(paidPrice); |
|
|
accountsPayable.setActualPaidPrice(paidPrice); |
|
|
accountsPayable.setActualPaidPrice(paidPrice); |
|
|
BigDecimal shoudPay = accountsPayable.getPriceIncludesTax(); |
|
|
BigDecimal shoudPay = accountsPayable.getPriceIncludesTax(); |
|
|
accountsPayable.setUnpaidPrice(shoudPay.subtract(paidPrice)); |
|
|
accountsPayable.setUnpaidPrice(shoudPay.subtract(paidPrice)); |
|
|
|
|
|
if(paidPrice.compareTo(shoudPay) == 0 ){ |
|
|
|
|
|
accountsPayable.setAccountsPayableStatus("2");//已结案
|
|
|
|
|
|
}else if(paidPrice.compareTo(shoudPay) < 0){ |
|
|
|
|
|
accountsPayable.setAccountsPayableStatus("1");//部分打款(需要手动结案)
|
|
|
|
|
|
} |
|
|
accountsPayable.setOperatorPeople(ShiroUtils.getLoginName()); |
|
|
accountsPayable.setOperatorPeople(ShiroUtils.getLoginName()); |
|
|
|
|
|
accountsPayable.setUpdateBy(ShiroUtils.getLoginName()); |
|
|
|
|
|
accountsPayable.setUpdateTime(DateUtils.getNowDate()); |
|
|
int rows = accountsPayableMapper.updateFinancialAccountsPayable(accountsPayable); |
|
|
int rows = accountsPayableMapper.updateFinancialAccountsPayable(accountsPayable); |
|
|
return rows; |
|
|
return rows; |
|
|
} |
|
|
} |
|
|