|
@@ -800,6 +800,41 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
return R.ok(removeMerRefDevicesToTopMerc(deviceInfos));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 商户解绑设备 --商家端
|
|
|
+ *
|
|
|
+ * @param dto
|
|
|
+ * @return {@link Boolean}
|
|
|
+ */
|
|
|
+ public Boolean unBindDeviceByMerc(DeviceInfoDto.MercDeviceUnBindDto dto) {
|
|
|
+ List<DeviceInfo> deviceInfos = this.listByIds(dto.getDeviceIds());
|
|
|
+ if (CollUtil.isNotEmpty(deviceInfos)) {
|
|
|
+ List<Long> mercIds = deviceInfos.stream().map(DeviceInfo::getMercId).collect(Collectors.toList());
|
|
|
+ mercIds.forEach(mercId -> {
|
|
|
+ if (mercId.longValue() == dto.getMercId().longValue()) {
|
|
|
+ throw new CommRuntimeException("只能选择子商户设备进行解绑,请检查是否选择了当前商户下的设备!");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return removeMerDevicesByDeviceIds(dto, deviceInfos);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Boolean removeMerDevicesByDeviceIds(DeviceInfoDto.MercDeviceUnBindDto dto, List<DeviceInfo> deviceInfos) {
|
|
|
+ if (CollUtil.isNotEmpty(deviceInfos)) {
|
|
|
+ deviceInfos.forEach(deviceInfo -> {
|
|
|
+ //回收 到当前操作商户
|
|
|
+ deviceInfo.setMercId(dto.getMercId());
|
|
|
+ deviceInfo.setMercDeviceCode(StrUtil.EMPTY);
|
|
|
+ deviceInfo.setMercName(dto.getMercName());
|
|
|
+ deviceInfo.setMercCode(dto.getMercCode());
|
|
|
+ });
|
|
|
+ //批量更新
|
|
|
+ return updateBatchById(deviceInfos);
|
|
|
+ }
|
|
|
+
|
|
|
+ return Boolean.FALSE;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 回收机器
|