From d4768db0d008477a0f7fdcac633dc9347c850098 Mon Sep 17 00:00:00 2001 From: kane Date: Wed, 16 Aug 2023 15:40:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E4=B8=BB=E6=8E=88=E6=9D=83=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AutonomousSqServiceImpl.java | 84 +++++++++++-------- .../mapper/InvoiceAllLoginResultMapper.java | 8 +- .../system/InvoiceAllLoginResultMapper.xml | 12 +++ 3 files changed, 68 insertions(+), 36 deletions(-) diff --git a/jianshui-invoice-all/src/main/java/com/jianshui/invoiceall/service/impl/AutonomousSqServiceImpl.java b/jianshui-invoice-all/src/main/java/com/jianshui/invoiceall/service/impl/AutonomousSqServiceImpl.java index 8ccd6e2..d3d5736 100644 --- a/jianshui-invoice-all/src/main/java/com/jianshui/invoiceall/service/impl/AutonomousSqServiceImpl.java +++ b/jianshui-invoice-all/src/main/java/com/jianshui/invoiceall/service/impl/AutonomousSqServiceImpl.java @@ -25,7 +25,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; -import java.util.List; /** * @author xingze @@ -55,20 +54,34 @@ public class AutonomousSqServiceImpl implements AutonomousSqService { public Object autonomousAuthorization(AutonomousAuthorizationDTO autonomousAuthorization) { log.info("自主信息授权回调接口,入参:{}", JSONUtil.toJsonStr(autonomousAuthorization)); // 存流水号 - InvoiceAllLoginResult invoiceAllLoginResult = new InvoiceAllLoginResult(); - BeanUtil.copyProperties(autonomousAuthorization, invoiceAllLoginResult); - invoiceAllLoginResult.setCreateTime(new Date()); - int count = invoiceAllLoginResultMapper.insertInvoiceAllLoginResult(invoiceAllLoginResult); - if (count > 0) { - log.info("全电登录接口,登录返回信息保存成功,信息为:{}", JSONUtil.toJsonStr(invoiceAllLoginResult)); + InvoiceAllLoginResult byQqlsh = invoiceAllLoginResultMapper.findByQqlsh(autonomousAuthorization.getTrace()); + if (byQqlsh != null) { + InvoiceAllLoginResult invoiceAllLoginResult = new InvoiceAllLoginResult(); + BeanUtil.copyProperties(autonomousAuthorization,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 { - log.error("全电登录接口,登录返回信息失败,信息为:{}", JSONUtil.toJsonStr(invoiceAllLoginResult)); + InvoiceAllLoginResult invoiceAllLoginResult = new InvoiceAllLoginResult(); + BeanUtil.copyProperties(autonomousAuthorization, invoiceAllLoginResult); + invoiceAllLoginResult.setCreateTime(new Date()); + int count = invoiceAllLoginResultMapper.insertInvoiceAllLoginResult(invoiceAllLoginResult); + if (count > 0) { + log.info("全电登录接口,登录返回信息保存成功,信息为:{}", JSONUtil.toJsonStr(invoiceAllLoginResult)); + } else { + log.error("全电登录接口,登录返回信息保存失败,信息为:{}", JSONUtil.toJsonStr(invoiceAllLoginResult)); + } } return AjaxResult.success(); } /** * 功能描述: 获取短信验证结果 + * * @param invoiceAllSubmitNoteDTO * @return : java.lang.Object */ @@ -77,17 +90,20 @@ public class AutonomousSqServiceImpl implements AutonomousSqService { log.info("获取短信验证结果入口,入参:{}", JSONUtil.toJsonStr(invoiceAllSubmitNoteDTO)); // 短信提交 ValidateUtils.validate(invoiceAllSubmitNoteDTO); - List invoiceAllLoginResultList = invoiceAllLoginResultMapper.findByQqlsh(invoiceAllSubmitNoteDTO.getTraceno()); - if (invoiceAllLoginResultList == null || invoiceAllLoginResultList.size() <= 0) { - log.info("自主授权短信提交接口,未查询到该流水号相关信息,请确认后输入"); + InvoiceAllLoginResult invoiceAllLoginResult = invoiceAllLoginResultMapper.findByQqlsh(invoiceAllSubmitNoteDTO.getTraceno()); + if (invoiceAllLoginResult == null) { + log.info("获取短信验证结果入口,未查询到该流水号相关信息,请确认后输入"); return AjaxResult.error("未查询到该流水号相关信息,请确认后输入"); } - for (InvoiceAllLoginResult invoiceAllLoginResult : invoiceAllLoginResultList) { - if ("S000".equals(invoiceAllLoginResult.getCode())){ - return AjaxResult.success(); - } + if ("SMS".equals(invoiceAllLoginResult.getCode())) { + return AjaxResult.error("10010"); + } else if ("F000".equals(invoiceAllLoginResult.getCode())) { + return AjaxResult.error("10011"); + } else if ("SOOO".equals(invoiceAllLoginResult.getCode())) { + return AjaxResult.error("10012"); + } else { + return AjaxResult.error("10013"); } - return AjaxResult.error(); } /** @@ -168,29 +184,27 @@ public class AutonomousSqServiceImpl implements AutonomousSqService { // 短信提交 ValidateUtils.validate(invoiceAllSubmitNoteDTO); // 根据流水号获取登录结果 - List invoiceAllLoginResultList = invoiceAllLoginResultMapper.findByQqlsh(invoiceAllSubmitNoteDTO.getTraceno()); - if (invoiceAllLoginResultList == null || invoiceAllLoginResultList.size() <= 0) { + InvoiceAllLoginResult invoiceAllLoginResult = invoiceAllLoginResultMapper.findByQqlsh(invoiceAllSubmitNoteDTO.getTraceno()); + if (invoiceAllLoginResult == null) { log.info("自主授权短信提交接口,未查询到该流水号相关信息,请确认后输入"); return AjaxResult.error("未查询到该流水号相关信息,请确认后输入"); } - for (InvoiceAllLoginResult invoiceAllLoginResult : invoiceAllLoginResultList) { - if ("SMS".equals(invoiceAllLoginResult.getCode())) { - try { - // 请求封装 - log.info("自主授权短信提交接口,请求上游地址:{},入参:{}", "http://221.222.184.98:8880/login/submitSms", JSONUtil.toJsonStr(invoiceAllSubmitNoteDTO)); - Thread requestThread = new Thread(() -> { - HttpUtils.sendJsonPost("http://221.222.184.98:8880/login/submitSms", invoiceAllSubmitNoteDTO); - }); - requestThread.start(); - } catch (Exception e) { - e.printStackTrace(); - log.error("【金四服务类】【金财数科】【自主授权提交短信验证码】API请求异常,外部报文返回code非S000。错误信息:{}", e.getMessage()); - return AjaxResult.error(ErrorCode.INCOME_ERROR); - } - } else { - log.error("自主授权短信提交接口,提交短信失败,失败原因:{}", "登录失败,请重新授权登录"); - return AjaxResult.error("登录失败,请重新授权登录"); + if ("SMS".equals(invoiceAllLoginResult.getCode())) { + try { + // 请求封装 + log.info("自主授权短信提交接口,请求上游地址:{},入参:{}", "http://221.222.184.98:8880/login/submitSms", JSONUtil.toJsonStr(invoiceAllSubmitNoteDTO)); + Thread requestThread = new Thread(() -> { + HttpUtils.sendJsonPost("http://221.222.184.98:8880/login/submitSms", invoiceAllSubmitNoteDTO); + }); + requestThread.start(); + } catch (Exception e) { + e.printStackTrace(); + log.error("【金四服务类】【金财数科】【自主授权提交短信验证码】API请求异常,外部报文返回code非S000。错误信息:{}", e.getMessage()); + return AjaxResult.error(ErrorCode.INCOME_ERROR); } + } else { + log.error("自主授权短信提交接口,提交短信失败,失败原因:{}", "登录失败,请重新授权登录"); + return AjaxResult.error("登录失败,请重新授权登录"); } return AjaxResult.success(); } diff --git a/jianshui-system/src/main/java/com/jianshui/system/mapper/InvoiceAllLoginResultMapper.java b/jianshui-system/src/main/java/com/jianshui/system/mapper/InvoiceAllLoginResultMapper.java index f385429..8f358a1 100644 --- a/jianshui-system/src/main/java/com/jianshui/system/mapper/InvoiceAllLoginResultMapper.java +++ b/jianshui-system/src/main/java/com/jianshui/system/mapper/InvoiceAllLoginResultMapper.java @@ -65,5 +65,11 @@ public interface InvoiceAllLoginResultMapper * @param qqlsh * @return : com.jianshui.system.domain.InvoiceAllLoginResult */ - List findByQqlsh(@Param("qqlsh") String qqlsh); + InvoiceAllLoginResult findByQqlsh(@Param("qqlsh") String qqlsh); + /** + * 功能描述: 根据流水号更新数据 + * @param invoiceAllLoginResult + * @return : int + */ + int updateInvoiceResult(InvoiceAllLoginResult invoiceAllLoginResult); } diff --git a/jianshui-system/src/main/resources/mapper/system/InvoiceAllLoginResultMapper.xml b/jianshui-system/src/main/resources/mapper/system/InvoiceAllLoginResultMapper.xml index b2d0111..da47208 100644 --- a/jianshui-system/src/main/resources/mapper/system/InvoiceAllLoginResultMapper.xml +++ b/jianshui-system/src/main/resources/mapper/system/InvoiceAllLoginResultMapper.xml @@ -73,6 +73,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} + + update invoice_all_login_result + + code = #{code}, + data = #{data}, + msg = #{msg}, + success = #{success}, + create_time = #{createTime}, + update_time = #{updateTime}, + + where trace = #{trace} + delete from invoice_all_login_result where id = #{id}