小程序-仪器响应优化

master
382696293@qq.com 2 years ago
parent 086bd1c44e
commit c6a2bd5781

@ -0,0 +1,30 @@
package com.flossom.common.core.enums;
public enum InstrumentHttpCodeEnum {
TWO_HUNDRED_AND_ONE(201, "可以绑定,但是不立即绑定,页面需要询问用户是否绑定"),
TWO_HUNDRED_AND_TWO(202, "绑定过该类型仪器,但当前扫码的序列号与以前绑定的仪器的序列号不一致,询问用户是否换绑仪器"),
TWO_HUNDRED_AND_THREE(203, "当前序列码被别人绑定了,联系客服"),
TWO_HUNDRED_AND_FOUR(204, "用户选择的仪器与序列号对应的仪器不一致"),
TWO_HUNDRED_AND_FIVE(205, "序列号不存在,联系客服"),
TWO_HUNDRED_AND_SIX(206, "绑定失败,不存在该仪器,请联系客服"),
;
private final Integer code;
private final String info;
InstrumentHttpCodeEnum(Integer code, String info) {
this.code = code;
this.info = info;
}
public Integer getCode() {
return code;
}
public String getInfo() {
return info;
}
}

@ -80,16 +80,15 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
@Override @Override
public List<WxInstrument> bindingInstrumentList() { public List<WxInstrument> bindingInstrumentList() {
// TODO: 仪器隐藏???? /* 绑定了的仪器 不受 "可见小程序标签/可见外部标签" 影响, 去除仪器隐藏的 */
/* 绑定了的仪器 不受 "可见小程序标签/可见外部标签" 影响 */
return wxInstrumentMapper.selectBindingInstrumentListByUserId(SecurityUtils.getLoginUser().getWxUserMember().getId()); return wxInstrumentMapper.selectBindingInstrumentListByUserId(SecurityUtils.getLoginUser().getWxUserMember().getId());
} }
@Override @Override
public List<WxInstrument> unbindingInstrumentInfoList() { public List<WxInstrument> unbindingInstrumentInfoList() {
List<WxInstrument> returnList = new ArrayList<>(); List<WxInstrument> returnList = new ArrayList<>();
/* 去除仪器隐藏的 */
List<WxInstrument> wxInstrumentList = wxInstrumentMapper.selectUnbindingInstrumentListByUserId(SecurityUtils.getLoginUser().getWxUserMember().getId()); List<WxInstrument> wxInstrumentList = wxInstrumentMapper.selectUnbindingInstrumentListByUserId(SecurityUtils.getLoginUser().getWxUserMember().getId());
// TODO: 仪器隐藏????
/* 未绑定的仪器 受 "可见小程序标签/可见外部标签" 影响,需要用户拥有全部对应的标签才可见 */ /* 未绑定的仪器 受 "可见小程序标签/可见外部标签" 影响,需要用户拥有全部对应的标签才可见 */
if (wxInstrumentList != null && wxInstrumentList.size() > 0) { if (wxInstrumentList != null && wxInstrumentList.size() > 0) {
// 用户拥有的标签 // 用户拥有的标签
@ -128,8 +127,8 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
WxInstrumentSerial wxInstrumentSerial = wxInstrumentSerialMapper.selectEntityListBySerial(query); WxInstrumentSerial wxInstrumentSerial = wxInstrumentSerialMapper.selectEntityListBySerial(query);
// 序列号唯一 // 序列号唯一
if (wxInstrumentSerial == null) { if (wxInstrumentSerial == null) {
logger.info("serial:{}, 没有对应的数据", serial); logger.info("serial:{}, 序列号不存在", serial);
throw new ServiceReturnCodeException("没有对应的序列号,跳转联系客服", 203); throw new ServiceReturnCodeException(InstrumentHttpCodeEnum.TWO_HUNDRED_AND_FIVE.getInfo(), InstrumentHttpCodeEnum.TWO_HUNDRED_AND_FIVE.getCode());
} }
return wxInstrumentSerial; return wxInstrumentSerial;
} }
@ -175,7 +174,7 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
if (!StringUtils.equals(wxUserInstrument.getSerial(), serial)) { if (!StringUtils.equals(wxUserInstrument.getSerial(), serial)) {
/* 2.1.2、绑定过仪器,但不是同一个序列号,询问是否需要换绑 */ /* 2.1.2、绑定过仪器,但不是同一个序列号,询问是否需要换绑 */
logger.info("绑定过该类型仪器,但当前扫码的序列号与以前绑定的仪器的序列号不一致,询问用户是否换绑仪器"); logger.info("绑定过该类型仪器,但当前扫码的序列号与以前绑定的仪器的序列号不一致,询问用户是否换绑仪器");
throw new ServiceReturnCodeException("绑定过该类型仪器,但当前扫码的序列号与以前绑定的仪器的序列号不一致,询问用户是否换绑仪器", 202); throw new ServiceReturnCodeException(InstrumentHttpCodeEnum.TWO_HUNDRED_AND_TWO.getInfo(), InstrumentHttpCodeEnum.TWO_HUNDRED_AND_TWO.getCode());
} }
logger.info("扫码序列号与当前用户绑定的序列号一致,无需绑定,返回响应"); logger.info("扫码序列号与当前用户绑定的序列号一致,无需绑定,返回响应");
} }
@ -184,7 +183,7 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
// 不立即绑定 // 不立即绑定
if (!isImmediatelyBinding) { if (!isImmediatelyBinding) {
logger.info("可以绑定,但是不立即绑定,页面需要询问用户是否绑定"); logger.info("可以绑定,但是不立即绑定,页面需要询问用户是否绑定");
throw new ServiceReturnCodeException("可以绑定,但是不立即绑定,页面需要询问用户是否绑定", 201); throw new ServiceReturnCodeException(InstrumentHttpCodeEnum.TWO_HUNDRED_AND_ONE.getInfo(), InstrumentHttpCodeEnum.TWO_HUNDRED_AND_ONE.getCode());
} }
/* 2.2.1、判断序列号是否被别人绑定了 */ /* 2.2.1、判断序列号是否被别人绑定了 */
@ -196,11 +195,15 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
Integer num = wxUserInstrumentMapper.selectUiByInstrumentId(query); Integer num = wxUserInstrumentMapper.selectUiByInstrumentId(query);
if (num != null && num > 0) { if (num != null && num > 0) {
logger.info("被别人绑定了,页面跳转联系客服"); logger.info("被别人绑定了,页面跳转联系客服");
throw new ServiceReturnCodeException("当前序列码被别人绑定了,页面跳转联系客服", 203); throw new ServiceReturnCodeException(InstrumentHttpCodeEnum.TWO_HUNDRED_AND_THREE.getInfo(), InstrumentHttpCodeEnum.TWO_HUNDRED_AND_THREE.getCode());
} }
/* 2.2.2、绑定仪器 */ /* 2.2.2、绑定仪器 */
else { else {
WxInstrument wxInstrument = wxInstrumentMapper.selectWxInstrumentById(wxInstrumentSerial.getInstrumentId()); 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());
}
WxUserInstrument saveEntity = new WxUserInstrument(); WxUserInstrument saveEntity = new WxUserInstrument();
saveEntity.setUserId(wxUserMember.getId()); saveEntity.setUserId(wxUserMember.getId());
saveEntity.setSerial(serial); saveEntity.setSerial(serial);
@ -293,7 +296,12 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
Integer num = wxUserInstrumentMapper.selectUiByInstrumentId(query); Integer num = wxUserInstrumentMapper.selectUiByInstrumentId(query);
if (num != null && num > 0) { if (num != null && num > 0) {
logger.info("被别人绑定了,页面跳转联系客服"); logger.info("被别人绑定了,页面跳转联系客服");
throw new ServiceReturnCodeException("当前序列码被别人绑定了,页面跳转联系客服", 203); throw new ServiceReturnCodeException(InstrumentHttpCodeEnum.TWO_HUNDRED_AND_THREE.getInfo(), InstrumentHttpCodeEnum.TWO_HUNDRED_AND_THREE.getCode());
}
WxInstrument wxInstrument = wxInstrumentMapper.selectWxInstrumentById(newInstrumentSerial.getInstrumentId());
if (wxInstrument != null && wxInstrument.getStatus().intValue() == Status.DISABLE.getCode()) {
logger.info("仪器({})被隐藏了,无法绑定", newInstrumentSerial.getInstrumentId());
throw new ServiceReturnCodeException(InstrumentHttpCodeEnum.TWO_HUNDRED_AND_SIX.getInfo(), InstrumentHttpCodeEnum.TWO_HUNDRED_AND_SIX.getCode());
} }
/* 3、换绑 */ /* 3、换绑 */
@ -425,7 +433,12 @@ public class WxInstrumentServiceImpl implements IWxInstrumentService {
WxInstrumentSerial wxInstrumentSerial = getInstrumentInfoBySerial(serial); WxInstrumentSerial wxInstrumentSerial = getInstrumentInfoBySerial(serial);
if (wxInstrumentSerial.getInstrumentId() != instrumentId) { if (wxInstrumentSerial.getInstrumentId() != instrumentId) {
logger.info("用户选择的仪器与序列号对应的仪器不一致,序列号:{} 仪器ID{}", serial, instrumentId); logger.info("用户选择的仪器与序列号对应的仪器不一致,序列号:{} 仪器ID{}", serial, instrumentId);
throw new ServiceReturnCodeException("用户选择的仪器与序列号对应的仪器不一致", 204); throw new ServiceReturnCodeException(InstrumentHttpCodeEnum.TWO_HUNDRED_AND_FOUR.getInfo(), InstrumentHttpCodeEnum.TWO_HUNDRED_AND_FOUR.getCode());
}
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());
} }
return wxInstrumentSerial; return wxInstrumentSerial;
} }

Loading…
Cancel
Save