|
|
@ -2,6 +2,7 @@ package com.jianshui.invoiceall.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.bean.copier.CopyOptions; |
|
|
|
import cn.hutool.core.bean.copier.CopyOptions; |
|
|
|
|
|
|
|
import cn.hutool.http.HttpUtil; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.jianshui.common.config.JianshuiConfig; |
|
|
|
import com.jianshui.common.config.JianshuiConfig; |
|
|
@ -12,6 +13,8 @@ import com.jianshui.common.enums.ErrorCode; |
|
|
|
import com.jianshui.common.utils.StringUtils; |
|
|
|
import com.jianshui.common.utils.StringUtils; |
|
|
|
import com.jianshui.common.utils.ValidateUtils; |
|
|
|
import com.jianshui.common.utils.ValidateUtils; |
|
|
|
import com.jianshui.common.utils.http.HttpUtils; |
|
|
|
import com.jianshui.common.utils.http.HttpUtils; |
|
|
|
|
|
|
|
import com.jianshui.invoiceall.domain.AsyncLoginResultEntity; |
|
|
|
|
|
|
|
import com.jianshui.invoiceall.domain.dto.AsyncInvoiceAllSubmitNoteDTO; |
|
|
|
import com.jianshui.invoiceall.domain.dto.InoviceAllQdLoginDTO; |
|
|
|
import com.jianshui.invoiceall.domain.dto.InoviceAllQdLoginDTO; |
|
|
|
import com.jianshui.invoiceall.domain.dto.jcsk.AutonomousAuthorizationDTO; |
|
|
|
import com.jianshui.invoiceall.domain.dto.jcsk.AutonomousAuthorizationDTO; |
|
|
|
import com.jianshui.invoiceall.domain.dto.jcsk.InvoiceAllSubmitNoteDTO; |
|
|
|
import com.jianshui.invoiceall.domain.dto.jcsk.InvoiceAllSubmitNoteDTO; |
|
|
@ -200,6 +203,134 @@ public class AutonomousSqServiceImpl implements AutonomousSqService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 异步全电登录 |
|
|
|
|
|
|
|
* @param inoviceAllQdLoginDTO |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Object asyncqdLogin(InoviceAllQdLoginDTO inoviceAllQdLoginDTO) { |
|
|
|
|
|
|
|
// 全电登录
|
|
|
|
|
|
|
|
log.info("异步全电登录接口,入参:{}", JSONUtil.toJsonStr(inoviceAllQdLoginDTO)); |
|
|
|
|
|
|
|
ValidateUtils.validate(inoviceAllQdLoginDTO); |
|
|
|
|
|
|
|
Companyservice companyservice = companyserviceMapper.selectCompanyserviceByTaxcode(inoviceAllQdLoginDTO.getNsrsbh()); |
|
|
|
|
|
|
|
if (companyservice == null){ |
|
|
|
|
|
|
|
log.error("异步全电登录接口,获取企业信息为空"); |
|
|
|
|
|
|
|
return AjaxResult.error("未获取到该税号企业信息!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (BeanUtil.isEmpty(inoviceAllQdLoginDTO.getNsrInfo())) { |
|
|
|
|
|
|
|
log.error("异步全电登录接口,传入报文错误,请检查,纳税人信息为空!"); |
|
|
|
|
|
|
|
return AjaxResult.error("传入报文错误,请检查,纳税人信息为空!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ValidateUtils.validate(inoviceAllQdLoginDTO.getNsrInfo()); |
|
|
|
|
|
|
|
// 流水号(唯一)
|
|
|
|
|
|
|
|
String qqlsh = inoviceAllQdLoginDTO.getNsrsbh() + inoviceAllQdLoginDTO.getNsrInfo().getGsnsyhm() + System.currentTimeMillis(); |
|
|
|
|
|
|
|
inoviceAllQdLoginDTO.setTraceno(qqlsh); |
|
|
|
|
|
|
|
AsyncLoginResultEntity asyncLoginResultEntity = null; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// 回调地址
|
|
|
|
|
|
|
|
inoviceAllQdLoginDTO.setLoginType("1"); |
|
|
|
|
|
|
|
log.info("异步全电登录接口,请求上游,地址:{},参数:{}", Constants.QD_LOGIN, JSONUtil.toJsonStr(inoviceAllQdLoginDTO)); |
|
|
|
|
|
|
|
String reslut = HttpUtil.post(Constants.ASYNC_QD_LOGIN, JSONUtil.toJsonStr(inoviceAllQdLoginDTO)); |
|
|
|
|
|
|
|
log.info("异步全电登录接口,返回结果信息:{}",reslut); |
|
|
|
|
|
|
|
asyncLoginResultEntity = JSONUtil.toBean(reslut, AsyncLoginResultEntity.class); |
|
|
|
|
|
|
|
// 存流水号
|
|
|
|
|
|
|
|
InvoiceAllLoginResult byQqlsh = invoiceAllLoginResultMapper.findByQqlsh(qqlsh); |
|
|
|
|
|
|
|
if (byQqlsh != null) { |
|
|
|
|
|
|
|
InvoiceAllLoginResult invoiceAllLoginResult = new InvoiceAllLoginResult(); |
|
|
|
|
|
|
|
BeanUtil.copyProperties(asyncLoginResultEntity,invoiceAllLoginResult); |
|
|
|
|
|
|
|
invoiceAllLoginResult.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
int count = invoiceAllLoginResultMapper.updateInvoiceResult(invoiceAllLoginResult); |
|
|
|
|
|
|
|
if (count > 0) { |
|
|
|
|
|
|
|
log.info("全电登录接口,登录返回信息更新成功,信息为:{}", JSONUtil.toJsonStr(invoiceAllLoginResult)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
log.error("全电登录接口,登录返回信息更新失败,信息为:{}", JSONUtil.toJsonStr(invoiceAllLoginResult)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
InvoiceAllLoginResult invoiceAllLoginResult = new InvoiceAllLoginResult(); |
|
|
|
|
|
|
|
BeanUtil.copyProperties(asyncLoginResultEntity, invoiceAllLoginResult); |
|
|
|
|
|
|
|
invoiceAllLoginResult.setCreateTime(new Date()); |
|
|
|
|
|
|
|
int count = invoiceAllLoginResultMapper.insertInvoiceAllLoginResult(invoiceAllLoginResult); |
|
|
|
|
|
|
|
if (count > 0) { |
|
|
|
|
|
|
|
log.info("全电登录接口,登录返回信息保存成功,信息为:{}", JSONUtil.toJsonStr(invoiceAllLoginResult)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
log.error("全电登录接口,登录返回信息保存失败,信息为:{}", JSONUtil.toJsonStr(invoiceAllLoginResult)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 用户信息封装
|
|
|
|
|
|
|
|
InvoiceAllYhdj yhdj = BeanUtil.copyProperties(inoviceAllQdLoginDTO, InvoiceAllYhdj.class); |
|
|
|
|
|
|
|
yhdj.setDlsfmm(inoviceAllQdLoginDTO.getNsrInfo().getGsnsmm()); |
|
|
|
|
|
|
|
yhdj.setBsrysfzjhm(inoviceAllQdLoginDTO.getNsrInfo().getSfzjhm()); |
|
|
|
|
|
|
|
yhdj.setDlzh(inoviceAllQdLoginDTO.getNsrInfo().getGsnsyhm()); |
|
|
|
|
|
|
|
yhdj.setBsryxm(inoviceAllQdLoginDTO.getNsrInfo().getBsryxz()); |
|
|
|
|
|
|
|
QueryWrapper<InvoiceAllYhdj> yhdjQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
|
|
|
yhdjQueryWrapper.eq("nsrsbh", yhdj.getNsrsbh()); |
|
|
|
|
|
|
|
yhdjQueryWrapper.eq("identity", companyservice.getIdentity()); |
|
|
|
|
|
|
|
InvoiceAllYhdj yhdjTemp = yhdjMapper.selectOne(yhdjQueryWrapper); |
|
|
|
|
|
|
|
// 日志信息
|
|
|
|
|
|
|
|
InvoiceAllApiLog invoiceAllApiLog = new InvoiceAllApiLog(); |
|
|
|
|
|
|
|
invoiceAllApiLog.setCreateTime(new Date()); |
|
|
|
|
|
|
|
invoiceAllApiLog.setCompany(companyservice.getSellertax()); |
|
|
|
|
|
|
|
invoiceAllApiLog.setIdentityId(companyservice.getIdentity()); |
|
|
|
|
|
|
|
invoiceAllApiLog.setUrl(Constants.QD_LOGIN); |
|
|
|
|
|
|
|
invoiceAllApiLog.setSendMsg(JSONUtil.toJsonStr(inoviceAllQdLoginDTO)); |
|
|
|
|
|
|
|
invoiceAllApiLog.setRequestId(qqlsh); |
|
|
|
|
|
|
|
invoiceAllApiLog.setResultMsg(JSONUtil.toJsonStr(asyncLoginResultEntity)); |
|
|
|
|
|
|
|
allApiLogMapper.insert(invoiceAllApiLog); |
|
|
|
|
|
|
|
// 更新记录表
|
|
|
|
|
|
|
|
if (BeanUtil.isNotEmpty(yhdjTemp)) { |
|
|
|
|
|
|
|
BeanUtil.copyProperties(yhdj, yhdjTemp, CopyOptions.create().setIgnoreNullValue(true)); |
|
|
|
|
|
|
|
yhdjTemp.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
yhdjMapper.updateInvoiceAllYhdj(yhdjTemp); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
yhdj.setCreateTime(new Date()); |
|
|
|
|
|
|
|
yhdj.setIdentity(companyservice.getIdentity()); |
|
|
|
|
|
|
|
yhdjMapper.insertInvoiceAllYhdj(yhdj); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (asyncLoginResultEntity != null){ |
|
|
|
|
|
|
|
if (!"S000".equals(asyncLoginResultEntity.getCode())){ |
|
|
|
|
|
|
|
return AjaxResult.error(asyncLoginResultEntity.getMsg()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
log.error("【金四服务类】【金财数科】【异步全电登录】API请求异常,错误信息:{}", e.getMessage()); |
|
|
|
|
|
|
|
return AjaxResult.error(ErrorCode.INCOME_ERROR); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success().put("nsrsbh",inoviceAllQdLoginDTO.getNsrsbh()).put("traceno",qqlsh); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 异步提交短信验证码 |
|
|
|
|
|
|
|
* @param asyncInvoiceAllSubmitNoteDTO |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Object asyncsubmitNote(AsyncInvoiceAllSubmitNoteDTO asyncInvoiceAllSubmitNoteDTO) { |
|
|
|
|
|
|
|
log.info("自主授权短信异步提交接口,入参:{}", JSONUtil.toJsonStr(asyncInvoiceAllSubmitNoteDTO)); |
|
|
|
|
|
|
|
// 短信提交
|
|
|
|
|
|
|
|
ValidateUtils.validate(asyncInvoiceAllSubmitNoteDTO); |
|
|
|
|
|
|
|
AsyncLoginResultEntity asyncLoginResultEntity = null; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
log.info("自主授权短信异步提交接口,调用地址:{},入参:{}",Constants.ASYNC_SUBMIT_SMS,JSONUtil.toJsonStr(asyncInvoiceAllSubmitNoteDTO)); |
|
|
|
|
|
|
|
String result = HttpUtil.post(Constants.ASYNC_SUBMIT_SMS, JSONUtil.toJsonStr(asyncInvoiceAllSubmitNoteDTO)); |
|
|
|
|
|
|
|
log.info("自主授权短信异步提交接口,调用结果:{}",result); |
|
|
|
|
|
|
|
asyncLoginResultEntity = JSONUtil.toBean(result, AsyncLoginResultEntity.class); |
|
|
|
|
|
|
|
if (asyncLoginResultEntity == null){ |
|
|
|
|
|
|
|
return AjaxResult.error("调用失败,获取结果为空"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}catch (Exception e){ |
|
|
|
|
|
|
|
log.info("自主授权短信异步提交接口,调用异常,异常信息:{}",e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!"SMS".equals(asyncLoginResultEntity.getCode())){ |
|
|
|
|
|
|
|
return AjaxResult.error(asyncLoginResultEntity.getData()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return AjaxResult.success(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 功能描述: 全电登录 |
|
|
|
* 功能描述: 全电登录 |
|
|
|
* |
|
|
|
* |
|
|
|