Parcourir la source

Merge remote-tracking branch 'origin/master'

李进 il y a 2 ans
Parent
commit
c848652ed5

+ 26 - 5
device-api-service/src/main/java/com/xy/service/DeviceInfoServiceImpl.java

@@ -303,7 +303,6 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
     @Transactional(rollbackFor = Exception.class)
     public R<Boolean> mercDeviceAuth(DeviceInfoDto.MercDeviceAuthDto auth) {
         Long mercId = auth.getMercId();
-        Long parentId = auth.getParentId();
         String mercCode = auth.getMercCode();
         Long algorithmId = auth.getAlgorithmId();
         String mercName = auth.getMercName();
@@ -315,7 +314,6 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
             if (CollUtil.isEmpty(devices)) {
                 return R.ok(Boolean.TRUE);
             }
-            return R.ok(removeMerRefDevices(devices, parentId));
         }
         //更新商户设备授权
         List<DeviceInfo> deviceInfos = this.listByIds(deviceIds);
@@ -358,16 +356,39 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
     }
 
     /**
-     * 解绑机器
+     * 解绑机器 回收
      *
      * @param dto
      * @return
      */
     @Override
     public R<Boolean> unBindMercDevice(DeviceInfoDto.MercDeviceUnBindDto dto) {
-        Long parentId = dto.getParentId();
         List<DeviceInfo> deviceInfos = this.listByIds(dto.getDeviceIds());
-        return R.ok(removeMerRefDevices(deviceInfos, parentId));
+        return R.ok(removeMerRefDevicesToTopMerc(deviceInfos));
+    }
+
+
+    /**
+     * 回收机器
+     *
+     * @param deviceInfos
+     * @return
+     */
+    private Boolean removeMerRefDevicesToTopMerc(List<DeviceInfo> deviceInfos) {
+        if (CollUtil.isNotEmpty(deviceInfos)) {
+            deviceInfos.forEach(deviceInfo -> {
+                //回收
+                deviceInfo.setMercId(-1L);
+                deviceInfo.setMercDeviceCode(StrUtil.EMPTY);
+                deviceInfo.setMercName(StrUtil.EMPTY);
+                deviceInfo.setMercCode(StrUtil.EMPTY);
+            });
+            //批量更新
+            return updateBatchById(deviceInfos);
+        }
+
+        return Boolean.FALSE;
+
     }
 
     /**

+ 1 - 7
device-api/src/main/java/com/xy/dto/DeviceInfoDto.java

@@ -507,15 +507,9 @@ public class DeviceInfoDto {
     @Data
     @Accessors(chain = true)
     public static class MercDeviceUnBindDto {
-        @ApiModelProperty(value = "对应商户的全量设备ID(传空则取消商户所有机器)", required = false)
+        @ApiModelProperty(value = "设备ID", required = false)
         private List<Long> deviceIds;
 
-        @ApiModelProperty(value = "商户ID", required = true)
-        private Long mercId;
-
-        @ApiModelProperty(value = "父商户ID", hidden = true)
-        private Long parentId;
-
     }