From 291d00831355aafcbd775e1e2e9b07504d113f71 Mon Sep 17 00:00:00 2001 From: "382696293@qq.com" <382696293@qq.com> Date: Thu, 29 Feb 2024 14:29:43 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90ID1000533=E3=80=91=E4=BB=AA=E5=99=A8?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E8=AE=B0=E5=BD=95-=E6=8D=A2=E7=BB=91?= =?UTF-8?q?=E5=BA=8F=E5=88=97=E5=8F=B7=E8=BE=93=E5=85=A51111=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=EF=BC=9A=20=E8=AF=A5=E5=BA=8F=E5=88=97?= =?UTF-8?q?=E5=8F=B7=E5=B7=B2=E7=BB=8F=E8=A2=AB=E7=BB=91=E5=AE=9A=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=9C=89=E8=AF=AF=EF=BC=8C=E5=BA=8F=E5=88=97?= =?UTF-8?q?=E5=8F=B7=E5=88=97=E8=A1=A8=E9=83=BD=E6=B2=A1=E6=9C=89=E8=AF=A5?= =?UTF-8?q?=E5=BA=8F=E5=88=97=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/WxUserInstrumentServiceImpl.java | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxUserInstrumentServiceImpl.java b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxUserInstrumentServiceImpl.java index 8faf06d..d16d0b3 100644 --- a/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxUserInstrumentServiceImpl.java +++ b/flossom-modules/flossom-system/src/main/java/com/flossom/system/service/impl/WxUserInstrumentServiceImpl.java @@ -9,11 +9,13 @@ import com.flossom.common.core.domain.req.WxUserInstrumentExportVm; import com.flossom.common.core.enums.BindingStatusEnums; import com.flossom.common.core.mapper.*; import com.flossom.common.core.utils.DateUtils; +import com.flossom.common.security.utils.SecurityUtils; import org.apache.commons.compress.utils.Lists; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.flossom.system.service.IWxUserInstrumentService; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; /** @@ -164,14 +166,15 @@ public class WxUserInstrumentServiceImpl implements IWxUserInstrumentService } @Override + @Transactional public Map changeSerial(WxUserInstrument wxUserInstrument) { Map resultMap = Maps.newHashMap(); // 查询序列号是否有效存在 WxInstrumentSerial serial = new WxInstrumentSerial(); serial.setSerial(wxUserInstrument.getSerial()); serial.setValidStatus(1); // 有效 - List serialList = instrumentSerialMapper.selectWxInstrumentSerialList(serial); - if (CollectionUtils.isEmpty(serialList)) { + WxInstrumentSerial wxInstrumentSerial = instrumentSerialMapper.selectEntityListBySerial(serial); + if (wxInstrumentSerial == null) { resultMap.put("message","序列号无效,请确定后再绑定"); resultMap.put("code", "500"); return resultMap; @@ -179,15 +182,16 @@ public class WxUserInstrumentServiceImpl implements IWxUserInstrumentService // 查看是否已经被绑定 WxUserInstrument userInstrument = new WxUserInstrument(); userInstrument.setSerial(wxUserInstrument.getSerial()); - List wxUserInstrumentsList = wxUserInstrumentMapper.selectWxUserInstrumentList(userInstrument); - if (!CollectionUtils.isEmpty(wxUserInstrumentsList)) { + userInstrument.setBindingStatus(BindingStatusEnums.BINDED.getCode()); + Integer count = wxUserInstrumentMapper.selectUiByInstrumentId(userInstrument); + if (count != null && count > 0) { resultMap.put("message","该序列号已经被绑定"); resultMap.put("code", "500"); return resultMap; } // 开始绑定 WxUserInstrument userInstrumentRecord = wxUserInstrumentMapper.selectWxUserInstrumentById(wxUserInstrument.getId()); - + String oldSerial = userInstrumentRecord.getSerial(); // 操作变更日记 // 是否已经绑定 if (0 == userInstrumentRecord.getBindingStatus()) { @@ -208,7 +212,7 @@ public class WxUserInstrumentServiceImpl implements IWxUserInstrumentService } } // 更新信息 - WxInstrumentSerial instrumentSerialVo = serialList.get(0); + WxInstrumentSerial instrumentSerialVo = wxInstrumentSerial; userInstrumentRecord.setInstrumentId(instrumentSerialVo.getInstrumentId()); userInstrumentRecord.setSerial(instrumentSerialVo.getSerial()); // userInstrumentRecord.setSerialImage(userInstrument.getSerialImage()); @@ -216,6 +220,24 @@ public class WxUserInstrumentServiceImpl implements IWxUserInstrumentService this.saveLog(userInstrumentRecord,0); // 更新绑定数据 + WxInstrumentSerial oldUpdate = new WxInstrumentSerial(); + oldUpdate.setBindingStatus(BindingStatusEnums.UN_BOUND.getCode()); + oldUpdate.setUpdateBy(SecurityUtils.getUsername()); + oldUpdate.setUpdateTime(DateUtils.getNowDate()); + oldUpdate.setSerial(oldSerial); + instrumentSerialMapper.updateBySerial(oldUpdate); + + + WxInstrumentSerial newUpdate = new WxInstrumentSerial(); + newUpdate.setBindingStatus(BindingStatusEnums.BINDED.getCode()); + newUpdate.setUpdateBy(SecurityUtils.getUsername()); + newUpdate.setUpdateTime(DateUtils.getNowDate()); + newUpdate.setSerial(wxUserInstrument.getSerial()); + instrumentSerialMapper.updateBySerial(newUpdate); + + userInstrumentRecord.setUserId(null); + userInstrumentRecord.setInstrumentId(null); + userInstrumentRecord.setBindingStatus(BindingStatusEnums.BINDED.getCode()); wxUserInstrumentMapper.updateWxUserInstrument(userInstrumentRecord); resultMap.put("message","换绑序列号成功"); resultMap.put("code", "200");