Compare commits
No commits in common. "eaab153631d4e58e8b1bcf5ca306f2cf413bb1ea" and "22b0abad0b470f995d78b6636fd4338b7e80c0d3" have entirely different histories.
eaab153631
...
22b0abad0b
@ -6,10 +6,8 @@ import cn.iocoder.yudao.module.member.controller.app.type.vo.AppMemberCardTypeRe
|
|||||||
import cn.iocoder.yudao.module.member.convert.type.MemberCardTypeConvert;
|
import cn.iocoder.yudao.module.member.convert.type.MemberCardTypeConvert;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.membercardtype.PaidMemberCardTypeDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.membercardtype.PaidMemberCardTypeDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.PaidMemberUserDO;
|
|
||||||
import cn.iocoder.yudao.module.member.service.membercardtype.PaidMemberCardTypeService;
|
import cn.iocoder.yudao.module.member.service.membercardtype.PaidMemberCardTypeService;
|
||||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||||
import cn.iocoder.yudao.module.member.service.user.PaidMemberUserService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -17,7 +15,6 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.lang.reflect.Member;
|
import java.lang.reflect.Member;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
@ -35,9 +32,6 @@ public class AppMemberCardTypeController {
|
|||||||
@Resource
|
@Resource
|
||||||
private MemberUserService userService;
|
private MemberUserService userService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private PaidMemberUserService paidMemberUserService;
|
|
||||||
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@Operation(summary = "获得会员卡类型列表")
|
@Operation(summary = "获得会员卡类型列表")
|
||||||
public CommonResult<List<AppMemberCardTypeRespVO>> list() {
|
public CommonResult<List<AppMemberCardTypeRespVO>> list() {
|
||||||
@ -45,13 +39,7 @@ public class AppMemberCardTypeController {
|
|||||||
MemberUserDO memberUserDO = userService.getUser(getLoginUserId());
|
MemberUserDO memberUserDO = userService.getUser(getLoginUserId());
|
||||||
/** 根据用户查询是否有试用会员的类型列表 */
|
/** 根据用户查询是否有试用会员的类型列表 */
|
||||||
List<PaidMemberCardTypeDO> list = cardService.getCardTypeList(memberUserDO.getActivate());
|
List<PaidMemberCardTypeDO> list = cardService.getCardTypeList(memberUserDO.getActivate());
|
||||||
List<AppMemberCardTypeRespVO> cardTypes = MemberCardTypeConvert.INSTANCE.convertList(list);
|
return success(MemberCardTypeConvert.INSTANCE.convertList(list));
|
||||||
//设置过期时间
|
|
||||||
cardTypes.forEach(card ->{
|
|
||||||
LocalDateTime expireTime = paidMemberUserService.getDeadLineDay(card.getName(), getLoginUserId());
|
|
||||||
card.setCardExpirationTime(expireTime);
|
|
||||||
});
|
|
||||||
return success(cardTypes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,13 +6,8 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
|||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
|
|
||||||
|
|
||||||
@Schema(description = "用户 App - 会员卡类型 Response VO")
|
@Schema(description = "用户 App - 会员卡类型 Response VO")
|
||||||
@Data
|
@Data
|
||||||
public class AppMemberCardTypeRespVO {
|
public class AppMemberCardTypeRespVO {
|
||||||
@ -27,8 +22,4 @@ public class AppMemberCardTypeRespVO {
|
|||||||
|
|
||||||
@Schema(description = "会员卡优惠价", example = "12301")
|
@Schema(description = "会员卡优惠价", example = "12301")
|
||||||
private BigDecimal specialPrice;
|
private BigDecimal specialPrice;
|
||||||
|
|
||||||
@Schema(description = "过期时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
|
||||||
private LocalDateTime cardExpirationTime;
|
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,6 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.user.vo.*;
|
import cn.iocoder.yudao.module.member.controller.admin.user.vo.*;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.PaidMemberUserDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.PaidMemberUserDO;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
@ -158,11 +156,17 @@ public class PaidMemberUserServiceImpl implements PaidMemberUserService {
|
|||||||
public LocalDateTime getDay(String cardName,LocalDateTime dateTime) {
|
public LocalDateTime getDay(String cardName,LocalDateTime dateTime) {
|
||||||
LocalDateTime deadlineDay;
|
LocalDateTime deadlineDay;
|
||||||
PaidMemberCardTypeDO paidMemberCardTypeDO = memberCardTypeService.selectByName(cardName);
|
PaidMemberCardTypeDO paidMemberCardTypeDO = memberCardTypeService.selectByName(cardName);
|
||||||
if (cardName.equals("永久")){
|
if (cardName.equals("试用")){
|
||||||
|
deadlineDay = dateTime.plus(Long.parseLong(paidMemberCardTypeDO.getVid()), ChronoUnit.DAYS);
|
||||||
|
} else if (cardName.equals("月卡")) {
|
||||||
|
deadlineDay = dateTime.plus(1,ChronoUnit.MONTHS);
|
||||||
|
} else if (cardName.equals("季卡")) {
|
||||||
|
deadlineDay = dateTime.plus(3,ChronoUnit.MONTHS);
|
||||||
|
} else if (cardName.equals("年卡")) {
|
||||||
|
deadlineDay = dateTime.plus(1,ChronoUnit.YEARS);
|
||||||
|
} else {
|
||||||
//永久设置为一个非常远的的日期
|
//永久设置为一个非常远的的日期
|
||||||
deadlineDay = LocalDateTime.of(9999,12,31,23,59,59);
|
deadlineDay = LocalDateTime.of(9999,12,31,23,59,59);
|
||||||
} else {
|
|
||||||
deadlineDay = dateTime.plus(Long.parseLong(paidMemberCardTypeDO.getVid()), ChronoUnit.DAYS);
|
|
||||||
}
|
}
|
||||||
return deadlineDay;
|
return deadlineDay;
|
||||||
}
|
}
|
||||||
@ -197,17 +201,13 @@ public class PaidMemberUserServiceImpl implements PaidMemberUserService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PaidMemberUserDO getPaidMemberUserByUid(Long uid) {
|
public PaidMemberUserDO getPaidMemberUserByUid(Long uid) {
|
||||||
List<PaidMemberUserDO> list = paidMemberUserMapper.selectLatestPaidMemberUsers();
|
List<PaidMemberUserDO> list = paidMemberUserMapper.selectList(
|
||||||
|
new LambdaQueryWrapperX<PaidMemberUserDO>().eq(PaidMemberUserDO::getUid,uid)
|
||||||
|
.orderByDesc(PaidMemberUserDO::getId));
|
||||||
if(list.isEmpty()){
|
if(list.isEmpty()){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<PaidMemberUserDO> filters = list.stream()
|
PaidMemberUserDO paidMemberUserDO = list.get(0);
|
||||||
.filter(user -> user.getUid().equals(uid))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
PaidMemberUserDO paidMemberUserDO = filters.get(0);
|
|
||||||
if (paidMemberUserDO.getCardExpirationTime().isBefore(LocalDateTime.now())){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return paidMemberUserDO;
|
return paidMemberUserDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user