|
|
|
@ -9,9 +9,12 @@ import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|
|
|
|
import com.dxhy.common.enums.FplxEnum; |
|
|
|
|
import com.dxhy.erp.entity.*; |
|
|
|
|
import com.dxhy.erp.model.*; |
|
|
|
|
import com.dxhy.erp.service.TDxInvoiceReimburseService; |
|
|
|
|
import com.dxhy.erp.utils.JsonUtils; |
|
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
@ -28,10 +31,6 @@ import com.dxhy.erp.dao.AuthRecordDao; |
|
|
|
|
import com.dxhy.erp.dao.RecordInvoiceDao; |
|
|
|
|
import com.dxhy.erp.dao.SysDeptDao; |
|
|
|
|
import com.dxhy.erp.dao.TdxRecordInvoiceDao; |
|
|
|
|
import com.dxhy.erp.entity.AuthRecord; |
|
|
|
|
import com.dxhy.erp.entity.RecordInvoice; |
|
|
|
|
import com.dxhy.erp.entity.SysDeptEntity; |
|
|
|
|
import com.dxhy.erp.entity.TdxRecordInvoice; |
|
|
|
|
import com.dxhy.erp.model.auth.InterfaceCode; |
|
|
|
|
import com.dxhy.erp.service.InvoiceAuthService; |
|
|
|
|
import com.dxhy.erp.utils.CheckUtils; |
|
|
|
@ -53,6 +52,8 @@ public class InvoiceAuthServiceImpl extends MpBaseServiceImpl<RecordInvoiceDao, |
|
|
|
|
SysDeptDao sysDeptDao; |
|
|
|
|
@Resource |
|
|
|
|
TdxRecordInvoiceDao tDxrecordInvoiceDao; |
|
|
|
|
@Resource |
|
|
|
|
TDxInvoiceReimburseService tDxInvoiceReimburseService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String applyInvoiceAuth(GlobalInfo globalInfo, Map<String, String> map, HttpServletRequest request, |
|
|
|
@ -334,12 +335,35 @@ public class InvoiceAuthServiceImpl extends MpBaseServiceImpl<RecordInvoiceDao, |
|
|
|
|
authDateReq.setApplyRzlx("1"); |
|
|
|
|
StringBuilder errorMsg = new StringBuilder(); |
|
|
|
|
DynamicContextHolder.push("business"+DbConstant.BUSINESS_READ); |
|
|
|
|
List<String> fplxList = new ArrayList<>(); |
|
|
|
|
fplxList.add("01"); |
|
|
|
|
fplxList.add("03"); |
|
|
|
|
fplxList.add("04"); |
|
|
|
|
fplxList.add("08"); |
|
|
|
|
fplxList.add("10"); |
|
|
|
|
fplxList.add("11"); |
|
|
|
|
fplxList.add("14"); |
|
|
|
|
fplxList.add("31"); |
|
|
|
|
fplxList.add("32"); |
|
|
|
|
for(ZDATA zdata1:zdata){ |
|
|
|
|
String uuid = zdata1.getZFPDM()+zdata1.getZFPHM(); |
|
|
|
|
TdxRecordInvoice recordInvoiceByUuid = tDxrecordInvoiceDao.getRecordInvoiceByUuid(uuid); |
|
|
|
|
if(recordInvoiceByUuid==null){ |
|
|
|
|
errorMsg.append("发票号码:"+zdata1.getZFPHM()); |
|
|
|
|
zdata1.setZFPLX(convertFpzldm(zdata1.getZFPLX())); |
|
|
|
|
|
|
|
|
|
if(fplxList.contains(zdata1.getZFPLX())){ |
|
|
|
|
TdxRecordInvoice recordInvoiceByUuid = tDxrecordInvoiceDao.getRecordInvoiceByUuid(uuid); |
|
|
|
|
if(recordInvoiceByUuid==null){ |
|
|
|
|
errorMsg.append("发票号码:"+zdata1.getZFPHM()); |
|
|
|
|
} |
|
|
|
|
}else { |
|
|
|
|
//查询票池
|
|
|
|
|
QueryWrapper<TDxInvoiceReimburse> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq("uuid",uuid); |
|
|
|
|
TDxInvoiceReimburse tDxInvoiceReimburse = tDxInvoiceReimburseService.getBaseMapper().selectOne(queryWrapper); |
|
|
|
|
if(tDxInvoiceReimburseService==null){ |
|
|
|
|
errorMsg.append("发票号码"+zdata1.getZFPHM()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if(errorMsg.length()>1){ |
|
|
|
|
es.setZMESSAGE(errorMsg.toString()+"不存在"); |
|
|
|
@ -352,8 +376,42 @@ public class InvoiceAuthServiceImpl extends MpBaseServiceImpl<RecordInvoiceDao, |
|
|
|
|
boolean flag = false; |
|
|
|
|
String uuid = zdata1.getZFPDM()+zdata1.getZFPHM(); |
|
|
|
|
DynamicContextHolder.push("business"+DbConstant.BUSINESS_READ); |
|
|
|
|
TdxRecordInvoice recordInvoiceByUuid = tDxrecordInvoiceDao.getRecordInvoiceByUuid(uuid); |
|
|
|
|
if(recordInvoiceByUuid!=null){ |
|
|
|
|
if(fplxList.contains(zdata1.getZFPLX())){ |
|
|
|
|
TdxRecordInvoice recordInvoiceByUuid = tDxrecordInvoiceDao.getRecordInvoiceByUuid(uuid); |
|
|
|
|
if(recordInvoiceByUuid!=null){ |
|
|
|
|
UpdateWrapper updateWrapper = new UpdateWrapper(); |
|
|
|
|
updateWrapper.eq("uuid",uuid); |
|
|
|
|
//会计凭证号
|
|
|
|
|
updateWrapper.set("snvoucher_number",zdata1.getBELNR()); |
|
|
|
|
//凭证过账日期
|
|
|
|
|
updateWrapper.set("posting_time",zdata1.getBUDAT()); |
|
|
|
|
//账期
|
|
|
|
|
updateWrapper.set("account_period",zdata1.getBUDAT()); |
|
|
|
|
updateWrapper.set("bzdh",zdata1.getZBZDH()); |
|
|
|
|
DynamicContextHolder.push("business"+DbConstant.BUSINESS_WRITE); |
|
|
|
|
int update = tDxrecordInvoiceDao.update(null, updateWrapper); |
|
|
|
|
if(update>0){ |
|
|
|
|
DynamicContextHolder.push(DbConstant.BASICS_READ); |
|
|
|
|
SysDeptEntity org = sysDeptDao.getOrg(recordInvoiceByUuid.getGfTaxNo()); |
|
|
|
|
zdata1.setZFPLX(convertFpzldm(zdata1.getZFPLX())); |
|
|
|
|
//如果设置的自动认证走申请认证逻辑
|
|
|
|
|
if(org!=null && "1".equals(org.getAutoRz()) && ("01".equals(zdata1.getZFPLX()) || "03".equals(zdata1.getZFPLX()) |
|
|
|
|
|| "08".equals(zdata1.getZFPLX()) || "14".equals(zdata1.getZFPLX()) |
|
|
|
|
|| "31".equals(zdata1.getZFPLX())) && StringUtils.isNotBlank(zdata1.getBUDAT())){ |
|
|
|
|
if(!"4".equals(recordInvoiceByUuid.getAuthStatus()) && !"3".equals(recordInvoiceByUuid.getAuthStatus()) |
|
|
|
|
&& !"2".equals(recordInvoiceByUuid.getAuthStatus())){ |
|
|
|
|
Map<String,Object> authState = new HashMap<>(); |
|
|
|
|
authState.put("rz_user",zdata1.getZJBRT()); |
|
|
|
|
authState.put("applyTaxPeriod",zdata1.getBUDAT().substring(0,7).replace("-","")); |
|
|
|
|
DynamicContextHolder.push("business"+DbConstant.BUSINESS_WRITE); |
|
|
|
|
tDxrecordInvoiceDao.updateRz(authState,"1","1",recordInvoiceByUuid.getUuid()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else { |
|
|
|
|
flag=true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else { |
|
|
|
|
UpdateWrapper updateWrapper = new UpdateWrapper(); |
|
|
|
|
updateWrapper.eq("uuid",uuid); |
|
|
|
|
//会计凭证号
|
|
|
|
@ -362,29 +420,11 @@ public class InvoiceAuthServiceImpl extends MpBaseServiceImpl<RecordInvoiceDao, |
|
|
|
|
updateWrapper.set("posting_time",zdata1.getBUDAT()); |
|
|
|
|
//账期
|
|
|
|
|
updateWrapper.set("account_period",zdata1.getBUDAT()); |
|
|
|
|
updateWrapper.set("bzdh",zdata1.getZBZDH()); |
|
|
|
|
DynamicContextHolder.push("business"+DbConstant.BUSINESS_WRITE); |
|
|
|
|
int update = tDxrecordInvoiceDao.update(null, updateWrapper); |
|
|
|
|
if(update>0){ |
|
|
|
|
DynamicContextHolder.push(DbConstant.BASICS_READ); |
|
|
|
|
SysDeptEntity org = sysDeptDao.getOrg(recordInvoiceByUuid.getGfTaxNo()); |
|
|
|
|
zdata1.setZFPLX(convertFpzldm(zdata1.getZFPLX())); |
|
|
|
|
//如果设置的自动认证走申请认证逻辑
|
|
|
|
|
if(org!=null && "1".equals(org.getAutoRz()) && ("01".equals(zdata1.getZFPLX()) || "03".equals(zdata1.getZFPLX()) |
|
|
|
|
|| "08".equals(zdata1.getZFPLX()) || "14".equals(zdata1.getZFPLX()) |
|
|
|
|
|| "31".equals(zdata1.getZFPLX())) && StringUtils.isNotBlank(zdata1.getBUDAT())){ |
|
|
|
|
if(!"4".equals(recordInvoiceByUuid.getAuthStatus()) && !"3".equals(recordInvoiceByUuid.getAuthStatus()) |
|
|
|
|
&& !"2".equals(recordInvoiceByUuid.getAuthStatus())){ |
|
|
|
|
Map<String,Object> authState = new HashMap<>(); |
|
|
|
|
authState.put("rz_user",zdata1.getZJBRT()); |
|
|
|
|
authState.put("applyTaxPeriod",zdata1.getBUDAT().substring(0,7).replace("-","")); |
|
|
|
|
DynamicContextHolder.push("business"+DbConstant.BUSINESS_WRITE); |
|
|
|
|
tDxrecordInvoiceDao.updateRz(authState,"1","1",recordInvoiceByUuid.getUuid()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else { |
|
|
|
|
flag=true; |
|
|
|
|
} |
|
|
|
|
tDxInvoiceReimburseService.getBaseMapper().update(null,updateWrapper); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(!flag){ |
|
|
|
|
promsg.append("票据号码:"+zdata1.getZFPHM()+"绑定成功! "); |
|
|
|
|
} |
|
|
|
|