init
This commit is contained in:
@@ -11,4 +11,5 @@ import com.ruoyi.xq.domain.AgreementSetting;
|
||||
*/
|
||||
public interface AgreementSettingService extends IService<AgreementSetting> {
|
||||
|
||||
AgreementSetting getAgreementSetting();
|
||||
}
|
||||
|
||||
@@ -11,4 +11,9 @@ import com.ruoyi.xq.domain.UserVip;
|
||||
*/
|
||||
public interface UserVipService extends IService<UserVip> {
|
||||
|
||||
UserVip getUserVip(Long userId, Integer vipType);
|
||||
|
||||
UserVip getUserVipNormal(Long userId, Integer vipType);
|
||||
|
||||
UserVip getByUserVipMaster(Long userId);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.ruoyi.xq.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.xq.domain.VipPrice;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员价格设置Service接口
|
||||
*
|
||||
@@ -10,4 +12,5 @@ import com.ruoyi.xq.domain.VipPrice;
|
||||
* @date 2024-03-04
|
||||
*/
|
||||
public interface VipPriceService extends IService<VipPrice> {
|
||||
List<VipPrice> listByVipType(Integer vipType);
|
||||
}
|
||||
|
||||
@@ -16,5 +16,8 @@ import org.springframework.stereotype.Service;
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class AgreementSettingServiceImpl extends ServiceImpl<AgreementSettingMapper,AgreementSetting> implements AgreementSettingService {
|
||||
|
||||
@Override
|
||||
public AgreementSetting getAgreementSetting() {
|
||||
return this.getById(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
package com.ruoyi.xq.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.xq.domain.UserVip;
|
||||
import com.ruoyi.xq.enums.vip.VipStatusEnum;
|
||||
import com.ruoyi.xq.mapper.UserVipMapper;
|
||||
import com.ruoyi.xq.service.UserVipService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* VIP用户Service业务层处理
|
||||
*
|
||||
@@ -17,4 +23,32 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class UserVipServiceImpl extends ServiceImpl<UserVipMapper,UserVip> implements UserVipService {
|
||||
|
||||
|
||||
@Override
|
||||
public UserVip getUserVip(Long userId, Integer vipType){
|
||||
return this.getOne(Wrappers.lambdaQuery(UserVip.class)
|
||||
.eq(UserVip::getUserId, userId)
|
||||
.eq(UserVip::getVipType, vipType)
|
||||
.last("limit 1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVip getUserVipNormal(Long userId, Integer vipType){
|
||||
return this.getOne(Wrappers.lambdaQuery(UserVip.class)
|
||||
.eq(UserVip::getUserId, userId)
|
||||
.eq(UserVip::getVipType, vipType)
|
||||
.eq(UserVip::getVipStatus, VipStatusEnum.NORMAL.getCode())
|
||||
.ge(UserVip::getVipTimeout, LocalDateTime.now())
|
||||
.last("limit 1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVip getByUserVipMaster(Long userId){
|
||||
List<UserVip> userVipList = this.list(Wrappers.lambdaQuery(UserVip.class)
|
||||
.eq(UserVip::getUserId, userId)
|
||||
.eq(UserVip::getVipStatus, VipStatusEnum.NORMAL.getCode())
|
||||
.ge(UserVip::getVipTimeout, LocalDateTime.now()));
|
||||
return userVipList.stream().max(Comparator.comparing(UserVip::getVipType)).orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.xq.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.xq.domain.VipPrice;
|
||||
import com.ruoyi.xq.mapper.VipPriceMapper;
|
||||
@@ -7,6 +8,8 @@ import com.ruoyi.xq.service.VipPriceService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员价格设置Service业务层处理
|
||||
*
|
||||
@@ -17,4 +20,9 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class VipPriceServiceImpl extends ServiceImpl<VipPriceMapper,VipPrice> implements VipPriceService {
|
||||
|
||||
@Override
|
||||
public List<VipPrice> listByVipType(Integer vipType) {
|
||||
return this.list(Wrappers.lambdaQuery(VipPrice.class).eq(VipPrice::getVipType,vipType)
|
||||
.orderByAsc(VipPrice::getVipTime));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user