luodangjia
2024-12-12 d7b3c61e01aadf99ce6a1d8ebf18c4e6dd81cc2b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.ruoyi.other.service.impl;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.account.api.feignClient.AppUserClient;
import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.other.mapper.VipSettingMapper;
import com.ruoyi.other.api.domain.VipSetting;
import com.ruoyi.other.service.VipSettingService;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.List;
 
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author luodangjia
 * @since 2024-11-20
 */
@Service
public class VipSettingServiceImpl extends ServiceImpl<VipSettingMapper, VipSetting> implements VipSettingService {
    @Resource
    private AppUserClient appUserClient;
 
    @Override
    public VipSetting getVipSettingByUserId(Long userId) {
        AppUser appUser = appUserClient.getAppUserById(userId);
        if(null == appUser){
            throw new ServiceException("用户不存在");
        }
        return this.getById(appUser.getVipId());
    }
 
    @Override
    public void downUsers() {
        //查出可能需要降级的人员
        R<List<AppUser>> topUsers = appUserClient.getTopUsers();
        //循环判断是否要展示
        if (topUsers.getData()!=null && topUsers.getData().size()>0){
            for (AppUser appUser : topUsers.getData()){
                if (appUser.getVipId()==5){
                    VipSetting vipSetting = this.baseMapper.selectById(5);
                    if (vipSetting.getKeepBuyPoint()!=null){
                        //如果消费不为空,查找对应天数的消费积分
 
                        //如果消费积分小于保级积分,设置用户降级标志并将降级信息
                    }
 
                }
            }
        }
 
        //然后设置降级提示
 
    }
}