From 98a68d71ebe3d36031ccfb1a10634a69732ad209 Mon Sep 17 00:00:00 2001 From: "382696293@qq.com" <382696293@qq.com> Date: Sat, 27 Jan 2024 10:01:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=94=A8=E6=88=B7=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E4=BB=AA=E5=99=A8=EF=BC=8C=E6=8D=A2=E7=BB=91=E4=BB=AA?= =?UTF-8?q?=E5=99=A8=20=E5=93=8D=E5=BA=94=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/WxInstrumentServiceImpl.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxInstrumentServiceImpl.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxInstrumentServiceImpl.java index 7afaa3b..de0c837 100644 --- a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxInstrumentServiceImpl.java +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/service/impl/WxInstrumentServiceImpl.java @@ -128,8 +128,8 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService { WxInstrumentSerial wxInstrumentSerial = getInstrumentInfoBySerial(serial); /** - * 2、判断当前用户是否绑定了序列号对应仪器的序列号 - * 逻辑:查询‘当前用户’是否绑定了扫码序列号对应的仪器 + * 2、判断当前用户是否绑定了序列号对应仪器的仪器ID + * (每个用户只能绑定一个仪器ID,当多个序列号对应的仪器ID一样时,则进行换绑) * 绑定了: * 1、序列号一致,直接获取仪器列表 * 2、序列号不一致,询问是否对该仪器进行换绑 @@ -143,7 +143,7 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService { userBindInstrumentQuery.setInstrumentId(wxInstrumentSerial.getInstrumentId()); userBindInstrumentQuery.setStatus(Status.OK.getCode().longValue()); List wxUserInstrumentList = wxUserInstrumentMapper.selectListByUserIdAndInstrumentId(userBindInstrumentQuery); - // 2.1、当前用户绑定了序列号对应的仪器的序列号 + // 2.1、当前用户绑定过序列号对应的仪器ID if (wxUserInstrumentList != null) { if (wxUserInstrumentList.size() != 1) { logger.error("根据 用户id:{} 和 仪器id:{} 查询出来的数据为空或者数据量不止一条", wxUserMember.getId(), wxInstrumentSerial.getInstrumentId()); @@ -151,16 +151,14 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService { } WxUserInstrument wxUserInstrument = wxUserInstrumentList.get(0); /* 2.1.1、判断扫码获取的序列号和用户绑定的序列号是否一致 */ - if (StringUtils.equals(wxUserInstrument.getSerial(), serial)) { - logger.info("相同序列号,页面重新发起查询用户拥有的仪器列表"); - throw new ServiceReturnCodeException("扫码的序列号已被当前用户绑定,请查询仪器列表", 200); - } else { + if (!StringUtils.equals(wxUserInstrument.getSerial(), serial)) { /* 2.1.2、绑定过仪器,但不是同一个序列号,询问是否需要换绑 */ - logger.info("绑定过该类型仪器,但当前扫码不是以前绑定的仪器,询问是否换绑仪器"); - throw new ServiceReturnCodeException("绑定过该类型仪器,但当前扫码不是以前绑定的仪器,询问是否换绑仪器", 202); + logger.info("绑定过该类型仪器,但当前扫码的序列号与以前绑定的仪器的序列号不一致,询问用户是否换绑仪器"); + throw new ServiceReturnCodeException("绑定过该类型仪器,但当前扫码的序列号与以前绑定的仪器的序列号不一致,询问用户是否换绑仪器", 202); } + logger.info("扫码序列号与当前用户绑定的序列号一致,无需绑定,返回响应"); } - // 2.2、用户没有绑定过序列号对应的仪器 + // 2.2、用户没有绑定过序列号对应的仪器ID else { /* 2.2.1、判断序列号是否被别人绑定了 */ WxUserInstrument query = new WxUserInstrument(); @@ -276,7 +274,7 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService { List wxUserInstrumentList = wxUserInstrumentMapper.selectListByUserIdAndInstrumentId(userInstrumentQuery); if (wxUserInstrumentList == null || wxUserInstrumentList.size() != 1) { logger.error("根据 用户id:{} 和 仪器id:{} 查询出来的数据为空或者数据量不止一条", wxUserMember.getId(), newInstrumentSerial.getInstrumentId()); - throw new ServiceException("换绑失败!"); + throw new ServiceException("换绑失败"); } WxUserInstrument wxUserInstrument = wxUserInstrumentList.get(0);