|
|
|
|
@ -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<String,String> changeSerial(WxUserInstrument wxUserInstrument) {
|
|
|
|
|
Map<String,String> resultMap = Maps.newHashMap();
|
|
|
|
|
// 查询序列号是否有效存在
|
|
|
|
|
WxInstrumentSerial serial = new WxInstrumentSerial();
|
|
|
|
|
serial.setSerial(wxUserInstrument.getSerial());
|
|
|
|
|
serial.setValidStatus(1); // 有效
|
|
|
|
|
List<WxInstrumentSerial> 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<WxUserInstrument> 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");
|
|
|
|
|
|