zoujiajian 2 years ago
parent
commit
6900add08a

+ 2 - 2
netflix-dao/src/main/java/com/cyksj/mapper/UserDistributeRankStatisticsRecordMapper.java

@@ -15,9 +15,9 @@ import java.util.List;
  * 创建时间:2024/7/23 16:37
  * 创建时间:2024/7/23 16:37
  */
  */
 public interface UserDistributeRankStatisticsRecordMapper extends BaseMapper<UserDistributeRankStatisticsRecord> {
 public interface UserDistributeRankStatisticsRecordMapper extends BaseMapper<UserDistributeRankStatisticsRecord> {
-	Page<DistributeUserRankView> selectDistributeRanks(@Param("type") Integer type, @Param("filed") String filed, @Param("page") Page<DistributeUserRankView> objectPage);
+	Page<DistributeUserRankView> selectDistributeRanks(@Param("type") Integer type, @Param("filed") String filed, @Param("statisticsTime") String statisticsTime, @Param("page") Page<DistributeUserRankView> objectPage);
 
 
-	DistributeUserRankView getSelfRank(@Param("type") Integer type, @Param("filed") String filed, @Param("userId") long userId);
+	DistributeUserRankView getSelfRank(@Param("type") Integer type, @Param("filed") String filed, @Param("userId") long userId, @Param("statisticsTime") String statisticsTime);
 
 
 	List<DistributeUserRankView> getPreviousWinners(@Param("type") Integer type, @Param("filed") String filed, @Param("lastTime") String lastTime);
 	List<DistributeUserRankView> getPreviousWinners(@Param("type") Integer type, @Param("filed") String filed, @Param("lastTime") String lastTime);
 }
 }

+ 2 - 0
netflix-dao/src/main/resources/mapper/UserDistributeRankStatisticsRecordMapper.xml

@@ -15,6 +15,7 @@
                  left join user u on u.id = udsr.user_id
                  left join user u on u.id = udsr.user_id
         where udsr.is_present is true
         where udsr.is_present is true
         and type = #{type}
         and type = #{type}
+        and statistics_start_time = #{statisticsTime}
     </select>
     </select>
 
 
     <select id="getSelfRank" resultType="com.cyksj.model.views.DistributeUserRankView">
     <select id="getSelfRank" resultType="com.cyksj.model.views.DistributeUserRankView">
@@ -30,6 +31,7 @@
         where udsr.user_id = #{userId}
         where udsr.user_id = #{userId}
           and type = #{type}
           and type = #{type}
           and udsr.is_present is true
           and udsr.is_present is true
+          and statistics_start_time = #{statisticsTime}
     </select>
     </select>
 
 
     <select id="getPreviousWinners" resultType="com.cyksj.model.views.DistributeUserRankView">
     <select id="getPreviousWinners" resultType="com.cyksj.model.views.DistributeUserRankView">

+ 13 - 3
netflix-web/src/main/java/com/cyksj/web/controller/distribute/DistributeRankController.java

@@ -30,6 +30,7 @@ import java.time.temporal.ChronoField;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**
+ * server/分销排行
  * 项目名: yhlxj
  * 项目名: yhlxj
  * 文件名: DistributeRankController
  * 文件名: DistributeRankController
  * 创建者: JavaZou
  * 创建者: JavaZou
@@ -75,7 +76,7 @@ public class DistributeRankController {
 	 * 个人分销排行详情  以及所属分类排行列表
 	 * 个人分销排行详情  以及所属分类排行列表
 	 */
 	 */
 	@GetMapping("/get/personal")
 	@GetMapping("/get/personal")
-	public Result<DistributeUserRankPersonalView> getPersonal(@RequestParam(defaultValue = "0") Integer type, @RequestParam(defaultValue = "1") Integer start, @RequestParam(defaultValue = "5") Integer limit) {
+	public Result<DistributeUserRankPersonalView> getPersonal(@RequestParam(defaultValue = "0") Integer type, @RequestParam(defaultValue = "week") String statisticsType, @RequestParam(defaultValue = "1") Integer start, @RequestParam(defaultValue = "5") Integer limit) {
 		long userId = StpUserUtil.getLoginIdAsLong();
 		long userId = StpUserUtil.getLoginIdAsLong();
 		DistributeUserRankPersonalView distributeUserRankPersonalView = new DistributeUserRankPersonalView();
 		DistributeUserRankPersonalView distributeUserRankPersonalView = new DistributeUserRankPersonalView();
 		String orderByField = "money";
 		String orderByField = "money";
@@ -83,12 +84,21 @@ public class DistributeRankController {
 		if (type == 1) {
 		if (type == 1) {
 			orderByField = "orders";
 			orderByField = "orders";
 		}
 		}
+		String statisticsTime;
+		if (Constant.week.equals(statisticsType)) {
+			//上周一
+			LocalDate monday = LocalDate.now().with(ChronoField.DAY_OF_WEEK, DayOfWeek.MONDAY.getValue());
+			statisticsTime = monday.toString();
+		} else {
+			LocalDate monday = LocalDate.now().with(ChronoField.DAY_OF_MONTH, DayOfWeek.MONDAY.getValue()).plusMonths(-1);
+			statisticsTime = monday.toString();
+		}
 
 
-		DistributeUserRankView self = userDistributeRankStatisticsRecordMapper.getSelfRank(type, orderByField, userId);
+		DistributeUserRankView self = userDistributeRankStatisticsRecordMapper.getSelfRank(type, orderByField, userId, statisticsTime);
 		distributeUserRankPersonalView.setSelf(self);
 		distributeUserRankPersonalView.setSelf(self);
 
 
 
 
-		Page<DistributeUserRankView> ranks = userDistributeRankStatisticsRecordMapper.selectDistributeRanks(type, orderByField, new Page<>(start, limit));
+		Page<DistributeUserRankView> ranks = userDistributeRankStatisticsRecordMapper.selectDistributeRanks(type, orderByField, statisticsTime, new Page<>(start, limit));
 		distributeUserRankPersonalView.setRanks(ranks);
 		distributeUserRankPersonalView.setRanks(ranks);
 		return GatewayResponse.SUCCESS.newBuilder().toResult(distributeUserRankPersonalView);
 		return GatewayResponse.SUCCESS.newBuilder().toResult(distributeUserRankPersonalView);
 	}
 	}