|
|
|
|
@ -170,6 +170,7 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
|
|
|
|
|
WxUserInstrument userBindInstrumentQuery = new WxUserInstrument();
|
|
|
|
|
userBindInstrumentQuery.setUserId(wxUserMember.getId());
|
|
|
|
|
userBindInstrumentQuery.setInstrumentId(wxInstrumentSerial.getInstrumentId());
|
|
|
|
|
userBindInstrumentQuery.setBindingStatus(BindingStatusEnums.BINDED.getCode());
|
|
|
|
|
userBindInstrumentQuery.setStatus(Status.OK.getCode().longValue());
|
|
|
|
|
List<WxUserInstrument> wxUserInstrumentList = wxUserInstrumentMapper.selectListByUserIdAndInstrumentId(userBindInstrumentQuery);
|
|
|
|
|
// 2.1、当前用户绑定过序列号对应的仪器ID
|
|
|
|
|
@ -213,6 +214,8 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
|
|
|
|
|
logger.info("仪器({})被隐藏了,无法绑定", wxInstrumentSerial.getInstrumentId());
|
|
|
|
|
throw new ServiceReturnCodeException(InstrumentHttpCodeEnum.TWO_HUNDRED_AND_SIX.getInfo(), InstrumentHttpCodeEnum.TWO_HUNDRED_AND_SIX.getCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 构建 用户仪器关联对象
|
|
|
|
|
WxUserInstrument saveEntity = new WxUserInstrument();
|
|
|
|
|
saveEntity.setUserId(wxUserMember.getId());
|
|
|
|
|
saveEntity.setSerial(serial);
|
|
|
|
|
@ -226,11 +229,26 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
|
|
|
|
|
}
|
|
|
|
|
saveEntity.setBindingStatus(BindingStatusEnums.BINDED.getCode());
|
|
|
|
|
saveEntity.setStatus(Status.OK.getCode().longValue());
|
|
|
|
|
saveEntity.setCreateBy(wxUserMember.getNickname());
|
|
|
|
|
saveEntity.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
saveEntity.setUpdateBy(wxUserMember.getNickname());
|
|
|
|
|
saveEntity.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
wxUserInstrumentMapper.insertWxUserInstrument(saveEntity);
|
|
|
|
|
|
|
|
|
|
// 判断仪器是不是自己绑定过的,就是已解绑状态
|
|
|
|
|
WxUserInstrument myBindingInstrumentQuery = new WxUserInstrument();
|
|
|
|
|
myBindingInstrumentQuery.setUserId(wxUserMember.getId());
|
|
|
|
|
myBindingInstrumentQuery.setInstrumentId(wxInstrumentSerial.getInstrumentId());
|
|
|
|
|
myBindingInstrumentQuery.setBindingStatus(BindingStatusEnums.UN_BOUND.getCode());
|
|
|
|
|
myBindingInstrumentQuery.setStatus(Status.OK.getCode().longValue());
|
|
|
|
|
List<WxUserInstrument> myBindingInstrumentList = wxUserInstrumentMapper.selectListByUserIdAndInstrumentId(myBindingInstrumentQuery);
|
|
|
|
|
if (myBindingInstrumentList != null && myBindingInstrumentList.size() > 0) {
|
|
|
|
|
// 解绑状态的仪器,重新绑定
|
|
|
|
|
WxUserInstrument wxUserInstrument = myBindingInstrumentList.get(0);
|
|
|
|
|
saveEntity.setId(wxUserInstrument.getId());
|
|
|
|
|
wxUserInstrumentMapper.updateWxUserInstrument(saveEntity);
|
|
|
|
|
} else {
|
|
|
|
|
saveEntity.setCreateBy(wxUserMember.getNickname());
|
|
|
|
|
saveEntity.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
wxUserInstrumentMapper.insertWxUserInstrument(saveEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新仪器序列号绑定状态
|
|
|
|
|
WxInstrumentSerial saveSerial = new WxInstrumentSerial();
|
|
|
|
|
@ -285,7 +303,7 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* TODO: 仪器绑定获取积分
|
|
|
|
|
* TODO: 仪器绑定与数云同步积分
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|