Explorar el Código

修复好友关联关系导出

leon hace 4 años
padre
commit
a6e761e6da

+ 5 - 1
src/main/java/com/mokamrp/privates/controller/pangu/FosterwxCashOasBoxController.java

@@ -225,7 +225,11 @@ public class FosterwxCashOasBoxController extends BaseController<FosterwxCashOas
         }
         return AjaxResult.success(HttpMsg.importSuccess);
     }
-
+    @GetMapping("/test")
+    public Object test(){
+        FosterwxCashOasBox fosterwxCashOasBox = fosterwxCashOasBoxService.getRandBox(10, 1);
+        return AjaxResult.success(fosterwxCashOasBox);
+    }
 
 
 }

+ 7 - 5
src/main/java/com/mokamrp/privates/mapper/pangu/FosterwxMobileWxfriendMapper.xml

@@ -61,9 +61,11 @@
     </select>
 
     <select id="export" resultType="com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend">
-        SELECT
+        SELECT T.* FROM  (SELECT
         A.friend_id,
         A.mobile_id,
+        B.wx_name,
+        B.wx_username,
         C.mobile_code,
         D.id as station_id,
         D.station_name
@@ -71,11 +73,11 @@
         left join pan_fosterwx_wxfriend as B on A.friend_id = B.id
         left join pan_fosterwx_mobile as C on A.mobile_id = C.id
         left join pan_fosterwx_station as D on C.station_id = D.id
+        GROUP BY A.mobile_id,B.wx_name,B.wx_username,C.mobile_code,D.id,D.station_name,A.friend_id) as T
         <where>
-            <if test="params.stationId">and D.id = #{params.stationId}</if>
-            <if test="params.mobileCode">and C.mobile_code = #{params.mobileCode}</if>
-            <if test="params.name">and B.wx_name like CONCAT('%',#{params.name},'%') or B.wx_username like CONCAT('%',#{params.name},'%')</if>
+            <if test="params.stationId">and T.station_id = #{params.stationId}</if>
+            <if test="params.mobileCode">and T.mobile_code = #{params.mobileCode}</if>
+            <if test="params.name">and T.wx_name like CONCAT('%',#{params.name},'%') or T.wx_username like CONCAT('%',#{params.name},'%')</if>
         </where>
-        GROUP BY A.mobile_id,C.mobile_code,D.id,D.station_name,A.friend_id
     </select>
 </mapper>

+ 4 - 10
src/main/java/com/mokamrp/privates/service/pangu/impl/FosterwxCashOasBoxServiceImpl.java

@@ -102,14 +102,11 @@ public class FosterwxCashOasBoxServiceImpl extends ServiceImpl<FosterwxCashOasBo
         if (list == null || list.size() <= 0) {
             return null;
         }
+        Random rand =  new Random();
         if (list.size() == 1){
             return list.get(0);
         }
-        int max = list.size() - 1;
-        int min = 0;
-        Random random = new Random();
-        int i = random.nextInt(max) % (max - min + 1) + min;
-        return list.get(i);
+        return list.get(rand.nextInt(list.size()));
     }
 
     /**
@@ -132,11 +129,8 @@ public class FosterwxCashOasBoxServiceImpl extends ServiceImpl<FosterwxCashOasBo
         if (list.size() == 1){
             return list.get(0);
         }
-        int max = list.size() - 1;
-        int min = 0;
-        Random random = new Random();
-        int i = random.nextInt(max) % (max - min + 1) + min;
-        return list.get(i);
+        Random rand =  new Random();
+        return list.get(rand.nextInt(list.size()));
     }
 
     /**