|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.flossom.miniProgram.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.flossom.common.core.domain.entity.*;
|
|
|
|
|
import com.flossom.common.core.domain.ret.WxBindingInstrumentInfo;
|
|
|
|
|
import com.flossom.common.core.domain.ret.WxModeRet;
|
|
|
|
|
@ -27,10 +28,7 @@ import java.time.LocalDateTime;
|
|
|
|
|
import java.time.LocalTime;
|
|
|
|
|
import java.time.ZoneId;
|
|
|
|
|
import java.time.temporal.ChronoField;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -174,7 +172,10 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
|
|
|
|
|
userBindInstrumentQuery.setInstrumentId(wxInstrumentSerial.getInstrumentId());
|
|
|
|
|
userBindInstrumentQuery.setBindingStatus(BindingStatusEnums.BINDED.getCode());
|
|
|
|
|
userBindInstrumentQuery.setStatus(Status.OK.getCode().longValue());
|
|
|
|
|
// 用户仪器绑定记录
|
|
|
|
|
List<WxUserInstrument> wxUserInstrumentList = wxUserInstrumentMapper.selectListByUserIdAndInstrumentId(userBindInstrumentQuery);
|
|
|
|
|
// 仪器信息
|
|
|
|
|
WxInstrument wxInstrument = wxInstrumentMapper.selectWxInstrumentById(wxInstrumentSerial.getInstrumentId());
|
|
|
|
|
// 2.1、当前用户绑定过序列号对应的仪器ID
|
|
|
|
|
if (wxUserInstrumentList != null && wxUserInstrumentList.size() > 0) {
|
|
|
|
|
if (wxUserInstrumentList.size() != 1) {
|
|
|
|
|
@ -186,7 +187,10 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
|
|
|
|
|
if (!StringUtils.equals(wxUserInstrument.getSerial(), serial)) {
|
|
|
|
|
/* 2.1.2、绑定过仪器,但不是同一个序列号,询问是否需要换绑 */
|
|
|
|
|
logger.info("绑定过该类型仪器,但当前扫码的序列号与以前绑定的仪器的序列号不一致,询问用户是否换绑仪器");
|
|
|
|
|
throw new ServiceReturnCodeException(InstrumentHttpCodeEnum.TWO_HUNDRED_AND_TWO.getInfo(), InstrumentHttpCodeEnum.TWO_HUNDRED_AND_TWO.getCode());
|
|
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
resultMap.put("result", InstrumentHttpCodeEnum.TWO_HUNDRED_AND_TWO.getInfo());
|
|
|
|
|
resultMap.put("instrument", wxInstrument);
|
|
|
|
|
throw new ServiceReturnCodeException(JSON.toJSONString(resultMap), InstrumentHttpCodeEnum.TWO_HUNDRED_AND_TWO.getCode());
|
|
|
|
|
}
|
|
|
|
|
logger.info("扫码序列号与当前用户绑定的序列号一致,无需绑定,返回响应");
|
|
|
|
|
}
|
|
|
|
|
@ -195,7 +199,10 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
|
|
|
|
|
// 不立即绑定
|
|
|
|
|
if (!isImmediatelyBinding) {
|
|
|
|
|
logger.info("可以绑定,但是不立即绑定,页面需要询问用户是否绑定");
|
|
|
|
|
throw new ServiceReturnCodeException(InstrumentHttpCodeEnum.TWO_HUNDRED_AND_ONE.getInfo(), InstrumentHttpCodeEnum.TWO_HUNDRED_AND_ONE.getCode());
|
|
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
resultMap.put("result", InstrumentHttpCodeEnum.TWO_HUNDRED_AND_ONE.getInfo());
|
|
|
|
|
resultMap.put("instrument", wxInstrument);
|
|
|
|
|
throw new ServiceReturnCodeException(JSON.toJSONString(resultMap), InstrumentHttpCodeEnum.TWO_HUNDRED_AND_ONE.getCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 2.2.1、判断序列号是否被别人绑定了 */
|
|
|
|
|
@ -211,7 +218,6 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
|
|
|
|
|
}
|
|
|
|
|
/* 2.2.2、绑定仪器 */
|
|
|
|
|
else {
|
|
|
|
|
WxInstrument wxInstrument = wxInstrumentMapper.selectWxInstrumentById(wxInstrumentSerial.getInstrumentId());
|
|
|
|
|
if (wxInstrument != null && wxInstrument.getStatus().intValue() == Status.DISABLE.getCode()) {
|
|
|
|
|
logger.info("仪器({})被隐藏了,无法绑定", wxInstrumentSerial.getInstrumentId());
|
|
|
|
|
throw new ServiceReturnCodeException(InstrumentHttpCodeEnum.TWO_HUNDRED_AND_SIX.getInfo(), InstrumentHttpCodeEnum.TWO_HUNDRED_AND_SIX.getCode());
|
|
|
|
|
|