Эх сурвалжийг харах

#MOD 商户的机器,解绑后,机器归父商户

谭斌 2 жил өмнө
parent
commit
616996f2b8

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

@@ -251,6 +251,7 @@ 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();
@@ -262,7 +263,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
             if (CollUtil.isEmpty(devices)) {
                 return R.ok(Boolean.TRUE);
             }
-            return R.ok(removeMerRefDevices(devices));
+            return R.ok(removeMerRefDevices(devices, parentId));
         }
         //更新商户设备授权
         List<DeviceInfo> deviceInfos = this.listByIds(deviceIds);
@@ -298,7 +299,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
             });
             if (CollUtil.isNotEmpty(removeIds)) {
                 List<DeviceInfo> removeList = this.listByIds(removeIds);
-                removeMerRefDevices(removeList);
+                removeMerRefDevices(removeList, parentId);
             }
         }
         return R.ok(Boolean.TRUE);
@@ -310,10 +311,18 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
      * @param deviceInfos
      * @return
      */
-    private Boolean removeMerRefDevices(List<DeviceInfo> deviceInfos) {
+    private Boolean removeMerRefDevices(List<DeviceInfo> deviceInfos, Long parentId) {
         deviceInfos.forEach(deviceInfo -> {
-            //-1 释放关系
-            deviceInfo.setMercId(-1L);
+            //非顶级兴元商户,解绑后,机器归父商户
+            if (parentId != 1) {
+                deviceInfo.setMercId(parentId);
+            }
+            //一级商户,解绑后,直接释放
+            if (parentId == 0) {
+                //-1 释放关系
+                deviceInfo.setMercId(-1L);
+            }
+
             deviceInfo.setMercName(StrUtil.EMPTY);
             deviceInfo.setMercCode(StrUtil.EMPTY);
         });

+ 3 - 0
device-api/src/main/java/com/xy/dto/DeviceInfoDto.java

@@ -402,6 +402,9 @@ public class DeviceInfoDto {
         @ApiModelProperty(value = "商户ID", required = true)
         private Long mercId;
 
+        @ApiModelProperty(value = "父商户ID")
+        private Long parentId;
+
         @ApiModelProperty(value = "商户名称", required = false)
         private String mercName;