libo 4 years ago
parent
commit
1771a18f71
1 changed files with 25 additions and 20 deletions
  1. 25 20
      src/main/java/com/tdba/cxb/ares/api/service/UserService.java

+ 25 - 20
src/main/java/com/tdba/cxb/ares/api/service/UserService.java

@@ -78,14 +78,17 @@ public class UserService {
78 78
                                 .build());
79 79
                     }
80 80
                 }
81
+            }
81 82
 
82
-                //-- 追溯之前的数据
83
-                if((null != row.getSpread_uid()) && (0 < row.getSpread_uid())){
84
-                    relateList.add(UserRelate.UserRelateBuilder.anUserRelate()
85
-                            .withUid(row.getUid())
86
-                            .withPid(row.getSpread_uid())
87
-                            .withDate(localDate)
88
-                            .build());
83
+            //-- 追溯之前的数据
84
+            if((null != row.getSpread_uid()) && (0 < row.getSpread_uid())){
85
+                relateList.add(UserRelate.UserRelateBuilder.anUserRelate()
86
+                        .withUid(row.getUid())
87
+                        .withPid(row.getSpread_uid())
88
+                        .withDate(localDate)
89
+                        .build());
90
+
91
+                if(0 < num) {
89 92
                     //推荐人
90 93
                     resultList.add(UserCount.UserCountBuilder.anUserCount()
91 94
                             .withCreate_time(currentTime)
@@ -94,9 +97,11 @@ public class UserService {
94 97
                             .withUid(row.getSpread_uid())
95 98
                             .withDate(localDate)
96 99
                             .build());
100
+                }
97 101
 
98
-                    //往前追溯的推荐人
99
-                    userRelateMapper.selectByUid(row.getSpread_uid()).stream().forEach(innerRow -> {
102
+                //往前追溯的推荐人
103
+                userRelateMapper.selectByUid(row.getSpread_uid()).stream().forEach(innerRow -> {
104
+                    if(0 < num) {
100 105
                         resultList.add(UserCount.UserCountBuilder.anUserCount()
101 106
                                 .withCreate_time(currentTime)
102 107
                                 .withNum(num)
@@ -104,19 +109,19 @@ public class UserService {
104 109
                                 .withUid(innerRow.getPid())
105 110
                                 .withDate(localDate)
106 111
                                 .build());
112
+                    }
107 113
 
108
-                        relateList.add(UserRelate.UserRelateBuilder.anUserRelate()
109
-                                .withUid(row.getUid())
110
-                                .withPid(innerRow.getPid())
111
-                                .withDate(localDate)
112
-                                .build());
113
-                    });
114
-                }
115
-                if(!relateList.isEmpty()){
116
-                    userRelateMapper.insertSelectiveForeach(relateList);
117
-                }
118
-                relateList.clear();
114
+                    relateList.add(UserRelate.UserRelateBuilder.anUserRelate()
115
+                            .withUid(row.getUid())
116
+                            .withPid(innerRow.getPid())
117
+                            .withDate(localDate)
118
+                            .build());
119
+                });
120
+            }
121
+            if(!relateList.isEmpty()){
122
+                userRelateMapper.insertSelectiveForeach(relateList);
119 123
             }
124
+            relateList.clear();
120 125
         });
121 126
         if(!resultList.isEmpty()){
122 127
             userCountMapper.insertSelectiveForeach(resultList);