|
@@ -2,6 +2,7 @@ package com.xy.service;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.text.StrBuilder;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -265,10 +266,24 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
}
|
|
|
//更新商户设备授权
|
|
|
List<DeviceInfo> deviceInfos = this.listByIds(deviceIds);
|
|
|
- deviceInfos.forEach(deviceInfo -> {
|
|
|
+ for (DeviceInfo deviceInfo : deviceInfos) {
|
|
|
+ int refMercId = deviceInfo.getMercId().intValue();
|
|
|
+ // 只有解绑后,才能给顶级商户授权
|
|
|
+ if (refMercId != -1 && refMercId != mercId.intValue()) {
|
|
|
+ StrBuilder sb = StrBuilder.create();
|
|
|
+ String errMsg = sb.append("设备[")
|
|
|
+ .append(deviceInfo.getDeviceId())
|
|
|
+ .append("]")
|
|
|
+ .append("已被商户[")
|
|
|
+ .append(deviceInfo.getMercName())
|
|
|
+ .append("]绑定,请先进行解绑!")
|
|
|
+ .toString();
|
|
|
+ //已关联别商户
|
|
|
+ return R.fail(errMsg, Boolean.FALSE);
|
|
|
+ }
|
|
|
//绑定关系
|
|
|
deviceInfo.setMercId(mercId).setMercCode(mercCode).setAlgorithmId(algorithmId).setMercName(mercName);
|
|
|
- });
|
|
|
+ }
|
|
|
updateBatchById(deviceInfos);
|
|
|
//原来存在的设备关系,不在最终设备列表中的移除
|
|
|
if (CollUtil.isNotEmpty(devices)) {
|
|
@@ -299,9 +314,10 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
deviceInfos.forEach(deviceInfo -> {
|
|
|
//-1 释放关系
|
|
|
deviceInfo.setMercId(-1L);
|
|
|
+ deviceInfo.setMercName(StrUtil.EMPTY);
|
|
|
+ deviceInfo.setMercCode(StrUtil.EMPTY);
|
|
|
});
|
|
|
//批量更新
|
|
|
- updateBatchById(deviceInfos);
|
|
|
return updateBatchById(deviceInfos);
|
|
|
}
|
|
|
|