|
|
@@ -1,6 +1,7 @@
|
|
|
package com.cyksj.web.controller.distribute;
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.cyksj.common.constant.Constant;
|
|
|
@@ -25,6 +26,7 @@ import java.time.DayOfWeek;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.temporal.ChronoField;
|
|
|
import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* server/分销排行
|
|
|
@@ -88,18 +90,20 @@ public class DistributeRankController {
|
|
|
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();
|
|
|
+ DateTime beginOfMonth = DateUtil.beginOfMonth(DateTime.now());
|
|
|
+ statisticsTime = beginOfMonth.toDateStr();
|
|
|
}
|
|
|
|
|
|
- DistributeUserRankView self = userDistributeRankStatisticsRecordMapper.getSelfRank(orderByField, userId, statisticsTime);
|
|
|
+ DistributeUserRankView self = Optional.ofNullable(userDistributeRankStatisticsRecordMapper.getSelfRank(orderByField, userId, statisticsTime)).orElse(new DistributeUserRankView());
|
|
|
distributeUserRankPersonalView.setSelf(self);
|
|
|
|
|
|
- DistributeUserRankView more = userDistributeRankStatisticsRecordMapper.getMoreSelfRank(self.getRankId());
|
|
|
- if (type == 1) {
|
|
|
- self.setGapOrders(more.getOrders() - self.getOrders());
|
|
|
- } else {
|
|
|
- self.setGapMoney(more.getMoney().subtract(self.getMoney()));
|
|
|
+ DistributeUserRankView more = userDistributeRankStatisticsRecordMapper.getMoreSelfRank(self.getRankId(), orderByField, statisticsTime);
|
|
|
+ if (more != null) {
|
|
|
+ if (type == 1) {
|
|
|
+ self.setGapOrders(more.getOrders() - self.getOrders());
|
|
|
+ } else {
|
|
|
+ self.setGapMoney(more.getMoney().subtract(self.getMoney()));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
Page<DistributeUserRankView> ranks = userDistributeRankStatisticsRecordMapper.selectDistributeRanks(orderByField, statisticsTime, new Page<>(start, limit));
|
|
|
@@ -118,8 +122,8 @@ public class DistributeRankController {
|
|
|
LocalDate monday = LocalDate.now().with(ChronoField.DAY_OF_WEEK, DayOfWeek.MONDAY.getValue()).plusWeeks(-1);
|
|
|
lastTime = monday.toString();
|
|
|
} else {
|
|
|
- LocalDate monday = LocalDate.now().with(ChronoField.DAY_OF_MONTH, DayOfWeek.MONDAY.getValue()).plusMonths(-1);
|
|
|
- lastTime = monday.toString();
|
|
|
+ DateTime lastBeginOfMonth = DateUtil.offsetMonth(DateUtil.beginOfMonth(DateTime.now()), -1);
|
|
|
+ lastTime = lastBeginOfMonth.toDateStr();
|
|
|
}
|
|
|
String orderByField = "money";
|
|
|
if (type == 1) {
|