|
@@ -5,16 +5,21 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.kxs.common.security.util.SecurityUtils;
|
|
import com.kxs.common.security.util.SecurityUtils;
|
|
|
import com.kxs.user.api.model.KxsUser;
|
|
import com.kxs.user.api.model.KxsUser;
|
|
|
|
|
+import com.kxs.user.api.model.KxsUserRealLevel;
|
|
|
import com.kxs.user.api.vo.kxsapp.shareholder.ShareholderGetMyStandardsAllVO;
|
|
import com.kxs.user.api.vo.kxsapp.shareholder.ShareholderGetMyStandardsAllVO;
|
|
|
import com.kxs.user.api.vo.kxsapp.shareholder.ShareholderGetMyStandardsVO;
|
|
import com.kxs.user.api.vo.kxsapp.shareholder.ShareholderGetMyStandardsVO;
|
|
|
import com.kxs.user.api.vo.kxsapp.subGetShareholderUserList.UserScoreListVO;
|
|
import com.kxs.user.api.vo.kxsapp.subGetShareholderUserList.UserScoreListVO;
|
|
|
import com.kxs.user.biz.mapper.KxsShdScoreMapper;
|
|
import com.kxs.user.biz.mapper.KxsShdScoreMapper;
|
|
|
import com.kxs.user.api.model.KxsShdScore;
|
|
import com.kxs.user.api.model.KxsShdScore;
|
|
|
import com.kxs.user.biz.mapper.KxsUserMapper;
|
|
import com.kxs.user.biz.mapper.KxsUserMapper;
|
|
|
|
|
+import com.kxs.user.biz.mapper.KxsUserRealLevelMapper;
|
|
|
import com.kxs.user.biz.service.KxsShdScoreService;
|
|
import com.kxs.user.biz.service.KxsShdScoreService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -28,12 +33,16 @@ import java.util.List;
|
|
|
public class KxsShdScoreServiceImpl extends ServiceImpl<KxsShdScoreMapper, KxsShdScore> implements KxsShdScoreService {
|
|
public class KxsShdScoreServiceImpl extends ServiceImpl<KxsShdScoreMapper, KxsShdScore> implements KxsShdScoreService {
|
|
|
private final KxsShdScoreMapper kxsShdScoreMapper;
|
|
private final KxsShdScoreMapper kxsShdScoreMapper;
|
|
|
private final KxsUserMapper kxsUserMapper;
|
|
private final KxsUserMapper kxsUserMapper;
|
|
|
|
|
+ private final KxsUserRealLevelMapper kxsUserRealLevelMapper;
|
|
|
@Override
|
|
@Override
|
|
|
public Object getMyStandards(String month) {
|
|
public Object getMyStandards(String month) {
|
|
|
Long id = SecurityUtils.getUser().getId();
|
|
Long id = SecurityUtils.getUser().getId();
|
|
|
KxsUser kxsUser = kxsUserMapper.selectById(id);
|
|
KxsUser kxsUser = kxsUserMapper.selectById(id);
|
|
|
//获取个人积分
|
|
//获取个人积分
|
|
|
ShareholderGetMyStandardsVO shareholderGetMyStandardsVO = kxsShdScoreMapper.getMyStandards(month,kxsUser.getUserCode());
|
|
ShareholderGetMyStandardsVO shareholderGetMyStandardsVO = kxsShdScoreMapper.getMyStandards(month,kxsUser.getUserCode());
|
|
|
|
|
+ if (shareholderGetMyStandardsVO == null){
|
|
|
|
|
+ shareholderGetMyStandardsVO = new ShareholderGetMyStandardsVO();
|
|
|
|
|
+ }
|
|
|
//获取全国积分
|
|
//获取全国积分
|
|
|
ShareholderGetMyStandardsAllVO allVO = kxsShdScoreMapper.getMyStandardsAll(month);
|
|
ShareholderGetMyStandardsAllVO allVO = kxsShdScoreMapper.getMyStandardsAll(month);
|
|
|
if (allVO != null){
|
|
if (allVO != null){
|
|
@@ -61,11 +70,60 @@ public class KxsShdScoreServiceImpl extends ServiceImpl<KxsShdScoreMapper, KxsSh
|
|
|
@Override
|
|
@Override
|
|
|
public void integralStat() {
|
|
public void integralStat() {
|
|
|
//初级积分
|
|
//初级积分
|
|
|
- //获取全部用户职级 > K3
|
|
|
|
|
- //循环用户查询直属用户数量大于3
|
|
|
|
|
- Long aLong = kxsUserMapper.selectCount(Wrappers.<KxsUser>query().lambda().eq(KxsUser::getPid, 1));
|
|
|
|
|
- if (aLong > 3){
|
|
|
|
|
- List<KxsUser> kxsUsers = kxsUserMapper.selectList(Wrappers.<KxsUser>query().lambda().eq(KxsUser::getPid, 1));
|
|
|
|
|
|
|
+ //获取职级 > K3 的全部用户
|
|
|
|
|
+ List<KxsUserRealLevel> kxsUserRealLevels = kxsUserRealLevelMapper.selectList(Wrappers.<KxsUserRealLevel>query().lambda().gt(KxsUserRealLevel::getLevel, 3));
|
|
|
|
|
+ //构造月份
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
|
|
|
|
+ String month = now.format(formatter);
|
|
|
|
|
+ for (KxsUserRealLevel kxsUserRealLevel : kxsUserRealLevels) {
|
|
|
|
|
+ //查询全部直属用户
|
|
|
|
|
+ List<KxsUserRealLevel> kxsUserRealLevelList = kxsUserRealLevelMapper.selectList(Wrappers.<KxsUserRealLevel>query().lambda().eq(KxsUserRealLevel::getPid, kxsUserRealLevel.getUserId()));
|
|
|
|
|
+ //当直属用户大于3时才进行积分计算
|
|
|
|
|
+ if (kxsUserRealLevelList.size() > 3){
|
|
|
|
|
+ //初级积分基数
|
|
|
|
|
+ int firstScoreCardinal = 0;
|
|
|
|
|
+ //中级积分基数
|
|
|
|
|
+ int centerScoreCardinal = 0;
|
|
|
|
|
+ //高级积分基数
|
|
|
|
|
+ int highScoreCardinal = 0;
|
|
|
|
|
+ for (KxsUserRealLevel kxsUserRealLevelSon : kxsUserRealLevelList) {
|
|
|
|
|
+ int level = Integer.parseInt(kxsUserRealLevelSon.getLevel());
|
|
|
|
|
+ //校验用户职级
|
|
|
|
|
+ if (level > 2){
|
|
|
|
|
+ ++firstScoreCardinal;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(level > 3){
|
|
|
|
|
+ ++centerScoreCardinal;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(level > 4){
|
|
|
|
|
+ ++highScoreCardinal;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //用户实际获得积分
|
|
|
|
|
+ int firstScore = firstScoreCardinal / 3;
|
|
|
|
|
+ int centerScore = centerScoreCardinal / 3;
|
|
|
|
|
+ int highScore = highScoreCardinal / 3;
|
|
|
|
|
+ KxsShdScore kxsShdScore = kxsShdScoreMapper.selectOne(Wrappers.<KxsShdScore>query().lambda().eq(KxsShdScore::getUserId, kxsUserRealLevel.getUserId()).eq(KxsShdScore::getMonth,month));
|
|
|
|
|
+ if (kxsShdScore == null){
|
|
|
|
|
+ kxsShdScore = new KxsShdScore();
|
|
|
|
|
+ kxsShdScore.setCreateTime(now);
|
|
|
|
|
+ kxsShdScore.setDelFlag("0");
|
|
|
|
|
+ kxsShdScore.setUserId(kxsUserRealLevel.getUserId());
|
|
|
|
|
+ kxsShdScore.setFirstScore(firstScore);
|
|
|
|
|
+ kxsShdScore.setCenterScore(centerScore);
|
|
|
|
|
+ kxsShdScore.setHighScore(highScore);
|
|
|
|
|
+ kxsShdScore.setMonth(month);
|
|
|
|
|
+ kxsShdScoreMapper.insert(kxsShdScore);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ //存在记录只需修改积分
|
|
|
|
|
+ kxsShdScore.setFirstScore(firstScore);
|
|
|
|
|
+ kxsShdScore.setCenterScore(centerScore);
|
|
|
|
|
+ kxsShdScore.setHighScore(highScore);
|
|
|
|
|
+ kxsShdScore.setUpdateTime(now);
|
|
|
|
|
+ kxsShdScoreMapper.updateById(kxsShdScore);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -78,17 +136,6 @@ public class KxsShdScoreServiceImpl extends ServiceImpl<KxsShdScoreMapper, KxsSh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|