This commit is contained in:
linfso 2025-06-18 15:04:33 +08:00
parent 58e904c23a
commit 3b35c592bf

View File

@ -209,6 +209,8 @@ public class EmisWaybillAjustApplyServiceImpl extends EmisBaseService implements
throw new EmisBizError(EmisBizErrorType.FAIL,"已审核!"); throw new EmisBizError(EmisBizErrorType.FAIL,"已审核!");
} }
emisWaybillAjustApply.setBlDestConfirmed("1"); emisWaybillAjustApply.setBlDestConfirmed("1");
emisWaybillAjustApply.setDestConfirmManCode(getCurrentUser().getEmpCode()); emisWaybillAjustApply.setDestConfirmManCode(getCurrentUser().getEmpCode());
@ -242,6 +244,8 @@ public class EmisWaybillAjustApplyServiceImpl extends EmisBaseService implements
@Override @Override
public int auditCenterPass(EmisWaybillAjustApply emisWaybillAjustApply) throws EmisBizError { public int auditCenterPass(EmisWaybillAjustApply emisWaybillAjustApply) throws EmisBizError {
boolean isDZZS=false;
// 重新从数据库取信息 // 重新从数据库取信息
emisWaybillAjustApply = emisWaybillAjustApplyMapper.selectEmisWaybillAjustApplyById(emisWaybillAjustApply.getId()); emisWaybillAjustApply = emisWaybillAjustApplyMapper.selectEmisWaybillAjustApplyById(emisWaybillAjustApply.getId());
@ -252,56 +256,72 @@ public class EmisWaybillAjustApplyServiceImpl extends EmisBaseService implements
emisWaybillAjustApply.setBlCenterConfirmed("1"); emisWaybillAjustApply.setBlCenterConfirmed("1");
emisWaybillAjustApply.setCenterConfirmManCode(getCurrentUser().getEmpCode()); emisWaybillAjustApply.setCenterConfirmManCode(getCurrentUser().getEmpCode());
// 判断申请人是否是[单证专属]岗位
SysUser opUser = getEmisStaffByCode(emisWaybillAjustApply.getApplyManCode());
// 获取账单状态,若账单处于非未确认状态,不允许审核 if (opUser != null) {
List<EmisSettleSubBill> emisSettleSubBillList=getSettleSubBillListByBillCode(emisWaybillAjustApply.getBillCode()); // 判断申请人是否是单证专属
if(!CollectionUtils.isEmpty(emisSettleSubBillList)){ List<Long> postIds = postMapper.selectPostListByUserId(opUser.getUserId());
if (!CollectionUtils.isEmpty(postIds)) {
if(emisSettleSubBillList.size()>1){ for (Long poId : postIds) {
throw new EmisBizError(EmisBizErrorType.FAIL,"已拆子账单,不允许修改!"); if (poId == 18) {
isDZZS = true;
break;
}
}
} }
}
for (EmisSettleSubBill emisSettleSubBill:emisSettleSubBillList) { // 非单证专属则判断
if("1".equals(emisSettleSubBill.getBlConfirmCenter())){ if(!isDZZS) {
throw new EmisBizError(EmisBizErrorType.FAIL,"财务已确认账单,不允许审核,请先取消财务确认!"); // 获取账单状态,若账单处于非未确认状态,不允许审核
List<EmisSettleSubBill> emisSettleSubBillList = getSettleSubBillListByBillCode(emisWaybillAjustApply.getBillCode());
if (!CollectionUtils.isEmpty(emisSettleSubBillList)) {
if (emisSettleSubBillList.size() > 1) {
throw new EmisBizError(EmisBizErrorType.FAIL, "已拆子账单,不允许修改!");
} }
// 如果已定制账单,并且新的销售联系人、回款联系人不一致,必须从定制账单中移除 for (EmisSettleSubBill emisSettleSubBill : emisSettleSubBillList) {
if("1".equals(emisSettleSubBill.getBlMerge())){ if ("1".equals(emisSettleSubBill.getBlConfirmCenter())) {
// 判断是否调整销售联系人或回款联系人,如调整,需要先从账单里移除 throw new EmisBizError(EmisBizErrorType.FAIL, "财务已确认账单,不允许审核,请先取消财务确认!");
String newDataStr=emisWaybillAjustApply.getJsonData();
JSONObject jObj = JSONObject.parseObject(newDataStr);
JSONObject jobjOldValue=jObj.getJSONObject("oldValue");
JSONObject jobjNewValue=jObj.getJSONObject("newValue");
String oldPaymentType = jobjOldValue.getString("paymentType");
String oldCustNo = jobjOldValue.getString("custNo");
String oldPayee=emisSettleSubBill.getPayee();
String oldSalesmen=emisSettleSubBill.getSalesmen();
String newPaymentType = jobjNewValue.getString("paymentType");
String newCustNo = jobjNewValue.getString("custNo");
String newPayee=jobjNewValue.getString("payee");
String newSalesmen=jobjNewValue.getString("salesmen");
if( !oldPayee.equals(newPayee) || !oldSalesmen.equals(newSalesmen) ){
throw new EmisBizError(EmisBizErrorType.FAIL,"已定制账单,销售联系/回款联系人发生改变,请从原账单移除,单号:"+emisSettleSubBill.getBillNo());
} }
// bug: 1412 支付方式发生改变,需要从账单中移除 // 如果已定制账单,并且新的销售联系人、回款联系人不一致,必须从定制账单中移除
if( !oldPaymentType.equals(newPaymentType)){ if ("1".equals(emisSettleSubBill.getBlMerge())) {
throw new EmisBizError(EmisBizErrorType.FAIL,"已定制账单,支付方式发生改变,请从原账单移除,单号:"+emisSettleSubBill.getBillNo()); // 判断是否调整销售联系人或回款联系人,如调整,需要先从账单里移除
}
// bug: 1412 月结客户发生改变,都需要从账单中移除 String newDataStr = emisWaybillAjustApply.getJsonData();
if(!StringUtils.isEmpty(newCustNo)){ JSONObject jObj = JSONObject.parseObject(newDataStr);
if( !newCustNo.equals(oldCustNo)){ JSONObject jobjOldValue = jObj.getJSONObject("oldValue");
throw new EmisBizError(EmisBizErrorType.FAIL,"已定制账单,月结客户发生改变,请从原账单移除,单号:"+emisSettleSubBill.getBillNo()); JSONObject jobjNewValue = jObj.getJSONObject("newValue");
String oldPaymentType = jobjOldValue.getString("paymentType");
String oldCustNo = jobjOldValue.getString("custNo");
String oldPayee = emisSettleSubBill.getPayee();
String oldSalesmen = emisSettleSubBill.getSalesmen();
String newPaymentType = jobjNewValue.getString("paymentType");
String newCustNo = jobjNewValue.getString("custNo");
String newPayee = jobjNewValue.getString("payee");
String newSalesmen = jobjNewValue.getString("salesmen");
if (!oldPayee.equals(newPayee) || !oldSalesmen.equals(newSalesmen)) {
throw new EmisBizError(EmisBizErrorType.FAIL, "已定制账单,销售联系/回款联系人发生改变,请从原账单移除,单号:" + emisSettleSubBill.getBillNo());
} }
}
// bug: 1412 支付方式发生改变,需要从账单中移除
if (!oldPaymentType.equals(newPaymentType)) {
throw new EmisBizError(EmisBizErrorType.FAIL, "已定制账单,支付方式发生改变,请从原账单移除,单号:" + emisSettleSubBill.getBillNo());
}
// bug: 1412 月结客户发生改变,都需要从账单中移除
if (!StringUtils.isEmpty(newCustNo)) {
if (!newCustNo.equals(oldCustNo)) {
throw new EmisBizError(EmisBizErrorType.FAIL, "已定制账单,月结客户发生改变,请从原账单移除,单号:" + emisSettleSubBill.getBillNo());
}
}
}
} }
} }
} }
@ -342,77 +362,59 @@ public class EmisWaybillAjustApplyServiceImpl extends EmisBaseService implements
// 审核通过 // 审核通过
emisWaybillAjustApplyMapper.auditCenterPass(emisWaybillAjustApply); emisWaybillAjustApplyMapper.auditCenterPass(emisWaybillAjustApply);
// 财务中心费用审核:数据部人员通过岗位登记的费用申请:修改项目“运费调整”,财务审批通过后数据直接修改不用再进行层层审核; //bug:1610 财务中心费用审核:数据部人员通过岗位登记的费用申请:修改项目“运费调整”,财务审批通过后数据直接修改不用再进行层层审核;
// 运费调整类型 // 运费调整类型
if("9".equals(emisWaybillAjustApply.getApplyType())){ if("9".equals(emisWaybillAjustApply.getApplyType())){
// 若是单证专属则自动确认账单
if(isDZZS) {
// 自动确认账单
EmisSettleSubBill oldSubBill = emisBaseService.getSettleSubBillBySubBillNo(emisWaybillAjustApply.getBillCode());
if (oldSubBill != null) {
// 触发业务自动确认
EmisSettleSubBill updSubBillBySite = new EmisSettleSubBill();
updSubBillBySite.setId(oldSubBill.getId());
updSubBillBySite.setConfirmSiteManCode(emisWaybillAjustApply.getApplyManCode());
updSubBillBySite.setConfirmSiteCode(emisWaybillAjustApply.getApplySiteCode());
updSubBillBySite.setConfirmSiteNote("[单证专属]申请调整费用-自动确认");
emisBaseService.confirmBillBySite(updSubBillBySite);
SysUser opUser=getEmisStaffByCode(emisWaybillAjustApply.getApplyManCode()); // 触发财务自动确认
if(opUser!=null){ EmisSettleSubBill updSubBillByCenter = new EmisSettleSubBill();
// 判断申请人是否是单证专属 updSubBillByCenter.setConfirmCenterManCode(getCurrentUser().getEmpCode());
boolean isDZZS=false; updSubBillByCenter.setConfirmCenterCode(getCurrentUser().getOwnerSiteCode());
List<Long> postIds=postMapper.selectPostListByUserId(opUser.getUserId()); updSubBillByCenter.setConfirmCenterNote("[单证专属]申请调整费用-自动确认");
if(!CollectionUtils.isEmpty(postIds)){ updSubBillByCenter.setId(oldSubBill.getId());
for(Long poId:postIds){
if(poId==18){
isDZZS=true;
break;
}
}
}
// 若是单证专属则自动确认账单 emisBaseService.confirmBillByCenter(updSubBillByCenter);
if(isDZZS) {
// 自动确认账单
EmisSettleSubBill oldSubBill = emisBaseService.getSettleSubBillBySubBillNo(emisWaybillAjustApply.getBillCode());
if (oldSubBill != null) {
// 触发业务自动确认
EmisSettleSubBill updSubBillBySite = new EmisSettleSubBill();
updSubBillBySite.setId(oldSubBill.getId());
updSubBillBySite.setConfirmSiteManCode(emisWaybillAjustApply.getApplyManCode());
updSubBillBySite.setConfirmSiteCode(emisWaybillAjustApply.getApplySiteCode());
updSubBillBySite.setConfirmSiteNote("[单证专属]申请调整费用-自动确认");
emisBaseService.confirmBillBySite(updSubBillBySite);
// 触发财务自动确认 // 判断账单是否已经被合并,若被合并则需要重新计算费用
EmisSettleSubBill updSubBillByCenter = new EmisSettleSubBill(); // 重新计算总账单费用
updSubBillByCenter.setConfirmCenterManCode(getCurrentUser().getEmpCode()); // 获取账单是否已经被合并,若合并则更新账单费用
updSubBillByCenter.setConfirmCenterCode(getCurrentUser().getOwnerSiteCode()); if (!StringUtils.isEmpty(oldSubBill.getSettleBillNo())) {
updSubBillByCenter.setConfirmCenterNote("[单证专属]申请调整费用-自动确认"); EmisSettleBill oldSettleBill = emisSettleBillService.selectEmisSettleBillBySettleBillNo(oldSubBill.getSettleBillNo());
updSubBillByCenter.setId(oldSubBill.getId()); if (oldSettleBill != null) {
// 触发业务账单自动确认
EmisSettleBill emisSettleBill = new EmisSettleBill();
emisSettleBill.setConfirmSiteManCode(emisWaybillAjustApply.getApplyManCode());
emisSettleBill.setConfirmSiteCode(emisWaybillAjustApply.getApplySiteCode());
emisSettleBill.setBlConfirmSite("1");
emisSettleBill.setConfirmSiteDate(new Date());
emisSettleBill.setId(oldSettleBill.getId());
emisSettleBill.setConfirmSiteNote("[单证专属]申请调整费用-自动确认");
emisSettleBillService.updateEmisSettleBill(emisSettleBill);
emisBaseService.confirmBillByCenter(updSubBillByCenter); // 重新计算账单费用,计算开票状态,计算收款状态
emisSettleBillService.reCalcSettleBillFee(oldSettleBill);
// 判断账单是否已经被合并,若被合并则需要重新计算费用 emisSettleBillService.reCalcSettleBillInvoiceStatus(oldSubBill.getSettleBillNo());
// 重新计算总账单费用
// 获取账单是否已经被合并,若合并则更新账单费用
if (!StringUtils.isEmpty(oldSubBill.getSettleBillNo())) {
EmisSettleBill oldSettleBill = emisSettleBillService.selectEmisSettleBillBySettleBillNo(oldSubBill.getSettleBillNo());
if (oldSettleBill != null) {
// 触发业务账单自动确认
EmisSettleBill emisSettleBill = new EmisSettleBill();
emisSettleBill.setConfirmSiteManCode(emisWaybillAjustApply.getApplyManCode());
emisSettleBill.setConfirmSiteCode(emisWaybillAjustApply.getApplySiteCode());
emisSettleBill.setBlConfirmSite("1");
emisSettleBill.setConfirmSiteDate(new Date());
emisSettleBill.setId(oldSettleBill.getId());
emisSettleBill.setConfirmSiteNote("[单证专属]申请调整费用-自动确认");
emisSettleBillService.updateEmisSettleBill(emisSettleBill);
// 重新计算账单费用,计算开票状态,计算收款状态 emisSettleBillService.reCalcSettleBillPayStatus(oldSubBill.getSettleBillNo());
emisSettleBillService.reCalcSettleBillFee(oldSettleBill);
emisSettleBillService.reCalcSettleBillInvoiceStatus(oldSubBill.getSettleBillNo());
emisSettleBillService.reCalcSettleBillPayStatus(oldSubBill.getSettleBillNo());
}
} }
} }
} }
} }
} }
return 1; return 1;
} }