feat(memberCenter): 调整积分
parent
1350eb52f5
commit
63fcfc941d
|
@ -1,6 +1,7 @@
|
||||||
package com.mcwl.web.controller.personalCenter;
|
package com.mcwl.web.controller.personalCenter;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.mcwl.common.core.domain.R;
|
import com.mcwl.common.core.domain.R;
|
||||||
import com.mcwl.common.core.domain.entity.SysUser;
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
import com.mcwl.common.core.page.PageDomain;
|
import com.mcwl.common.core.page.PageDomain;
|
||||||
|
@ -8,6 +9,9 @@ import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.memberCenter.domain.Member;
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
import com.mcwl.memberCenter.service.MemberService;
|
import com.mcwl.memberCenter.service.MemberService;
|
||||||
|
import com.mcwl.pay.domain.OrderTrade;
|
||||||
|
import com.mcwl.pay.domain.vo.OrderTradeVo;
|
||||||
|
import com.mcwl.pay.service.OrderTradeService;
|
||||||
import com.mcwl.resource.domain.dto.ModelImagePageRes;
|
import com.mcwl.resource.domain.dto.ModelImagePageRes;
|
||||||
import com.mcwl.resource.service.*;
|
import com.mcwl.resource.service.*;
|
||||||
import com.mcwl.system.service.ISysUserService;
|
import com.mcwl.system.service.ISysUserService;
|
||||||
|
@ -15,12 +19,10 @@ import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -46,6 +48,8 @@ public class PersonalCenterController {
|
||||||
|
|
||||||
private final MemberService memberService;
|
private final MemberService memberService;
|
||||||
|
|
||||||
|
private final OrderTradeService orderTradeService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 我的发布-模型列表
|
* 我的发布-模型列表
|
||||||
|
@ -133,5 +137,31 @@ public class PersonalCenterController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取金币消费记录
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "获取金币消费记录")
|
||||||
|
@GetMapping("/getWallet")
|
||||||
|
public TableDataInfo getWallet() {
|
||||||
|
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
|
||||||
|
// return memberService.getRechargePoints(userId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取金币充值记录
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "获取金币充值记录")
|
||||||
|
@GetMapping("/getRechargePoints")
|
||||||
|
public R<List<OrderTradeVo>> getRechargePoints() {
|
||||||
|
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
List<OrderTrade> orderTradeList = orderTradeService.lambdaQuery()
|
||||||
|
.eq(OrderTrade::getUserId, userId)
|
||||||
|
.list();
|
||||||
|
return R.ok(BeanUtil.copyToList(orderTradeList, OrderTradeVo.class));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ spring:
|
||||||
# 密码
|
# 密码
|
||||||
password: MuYu_Cloud@Redis
|
password: MuYu_Cloud@Redis
|
||||||
# 连接超时时间
|
# 连接超时时间
|
||||||
timeout: 10s
|
timeout: 30s
|
||||||
lettuce:
|
lettuce:
|
||||||
pool:
|
pool:
|
||||||
# 连接池中的最小空闲连接
|
# 连接池中的最小空闲连接
|
||||||
|
@ -97,7 +97,64 @@ spring:
|
||||||
# 连接池的最大数据库连接数
|
# 连接池的最大数据库连接数
|
||||||
max-active: 8
|
max-active: 8
|
||||||
# #连接池最大阻塞等待时间(使用负值表示没有限制)
|
# #连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||||
max-wait: -1ms
|
max-wait: -1ms # 默认使用的数据库索引
|
||||||
|
|
||||||
|
# 连接超时配置
|
||||||
|
connect-timeout: 5000ms # 连接建立超时时间
|
||||||
|
timeout: 10000ms # 命令执行超时时间
|
||||||
|
|
||||||
|
# SSL配置(如果需要)
|
||||||
|
ssl:
|
||||||
|
enabled: false # 是否启用SSL连接
|
||||||
|
# bundle-certs: true # 使用自定义证书
|
||||||
|
# keystore-password: secret # 证书密码
|
||||||
|
|
||||||
|
# Lettuce客户端配置(推荐使用Lettuce而非Jedis)
|
||||||
|
lettuce:
|
||||||
|
shutdown-timeout: 5000ms # 关闭超时时间
|
||||||
|
|
||||||
|
# 客户端配置选项
|
||||||
|
client-options:
|
||||||
|
auto-reconnect: true # 自动重连
|
||||||
|
disconnect-timeout: 5000ms # 断开连接超时
|
||||||
|
cancel-timeout: 3000ms # 取消命令超时
|
||||||
|
keep-alive: true # 开启TCP Keep-Alive
|
||||||
|
publish-on-scheduler: true # 在调度器上发布(提高性能)
|
||||||
|
|
||||||
|
# TCP连接选项
|
||||||
|
client-resources:
|
||||||
|
io-thread-pool-size: 8 # IO线程池大小
|
||||||
|
computation-thread-pool-size: 8 # 计算线程池大小
|
||||||
|
|
||||||
|
# 集群配置(如果使用Redis集群)
|
||||||
|
# cluster:
|
||||||
|
# refresh:
|
||||||
|
# period: 20s # 拓扑刷新周期
|
||||||
|
# adaptive: true # 自适应刷新
|
||||||
|
|
||||||
|
# 连接池配置
|
||||||
|
pool:
|
||||||
|
max-active: 32 # 最大活跃连接数(根据并发需求调整)
|
||||||
|
max-idle: 16 # 最大空闲连接数
|
||||||
|
min-idle: 8 # 最小空闲连接数
|
||||||
|
max-wait: 3000ms # 最大等待时间
|
||||||
|
time-between-eviction-runs: 120000ms # 空闲连接检查周期
|
||||||
|
test-while-idle: true # 在空闲时检测连接是否有效
|
||||||
|
test-on-borrow: true # 在借用连接时检测连接是否有效
|
||||||
|
test-on-return: false # 在归还连接时检测连接是否有效
|
||||||
|
|
||||||
|
# 哨兵配置(如果使用Redis Sentinel)
|
||||||
|
sentinel:
|
||||||
|
enabled: false # 是否启用哨兵模式
|
||||||
|
# master: mymaster # 主节点名称
|
||||||
|
# nodes: host1:26379,host2:26379 # 哨兵节点列表
|
||||||
|
|
||||||
|
# 集群配置(如果使用Redis Cluster)
|
||||||
|
# cluster:
|
||||||
|
# enabled: false # 是否启用集群模式
|
||||||
|
# # nodes: host1:6379,host2:6379 # 集群节点列表
|
||||||
|
# max-redirects: 3 # 最大重定向次数
|
||||||
|
|
||||||
|
|
||||||
#ai配置
|
#ai配置
|
||||||
ai:
|
ai:
|
||||||
|
|
|
@ -5,10 +5,16 @@ import org.springframework.cache.annotation.EnableCaching;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.connection.RedisPassword;
|
||||||
|
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||||
|
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;
|
||||||
|
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.core.script.DefaultRedisScript;
|
import org.springframework.data.redis.core.script.DefaultRedisScript;
|
||||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* redis配置
|
* redis配置
|
||||||
*
|
*
|
||||||
|
@ -66,4 +72,22 @@ public class RedisConfig extends CachingConfigurerSupport
|
||||||
"end\n" +
|
"end\n" +
|
||||||
"return tonumber(current);";
|
"return tonumber(current);";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @Bean
|
||||||
|
// public RedisConnectionFactory redisConnectionFactory() {
|
||||||
|
// RedisStandaloneConfiguration standaloneConfig = new RedisStandaloneConfiguration("localhost", 6370);
|
||||||
|
// standaloneConfig.setPassword(RedisPassword.of("password"));
|
||||||
|
//
|
||||||
|
// LettuceClientConfiguration lettuceClientConfig = LettuceClientConfiguration.builder()
|
||||||
|
// .commandTimeout(Duration.ofSeconds(2))
|
||||||
|
// .shutdownTimeout(Duration.ZERO)
|
||||||
|
// .build();
|
||||||
|
//
|
||||||
|
// standaloneConfig.setClientConfiguration(lettuceClientConfig);
|
||||||
|
//
|
||||||
|
// return new LettuceConnectionFactory(standaloneConfig);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import com.mcwl.common.exception.ServiceException;
|
||||||
import com.mcwl.common.utils.StringUtils;
|
import com.mcwl.common.utils.StringUtils;
|
||||||
import com.mcwl.common.utils.html.EscapeUtil;
|
import com.mcwl.common.utils.html.EscapeUtil;
|
||||||
import io.lettuce.core.RedisCommandTimeoutException;
|
import io.lettuce.core.RedisCommandTimeoutException;
|
||||||
|
import io.lettuce.core.RedisException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.security.access.AccessDeniedException;
|
import org.springframework.security.access.AccessDeniedException;
|
||||||
|
@ -45,13 +46,13 @@ public class GlobalExceptionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权限校验异常
|
* redis异常
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(RedisCommandTimeoutException.class)
|
@ExceptionHandler(RedisException.class)
|
||||||
public AjaxResult commandTimeoutException(AccessDeniedException e, HttpServletRequest request) {
|
public AjaxResult commandTimeoutException(RedisException e, HttpServletRequest request) {
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
log.error("连接超时{},{}", requestURI, e.getMessage());
|
log.error("redis异常{},{}", requestURI, e.getMessage());
|
||||||
return AjaxResult.error(HttpStatus.ERROR, "连接超时");
|
return AjaxResult.error(HttpStatus.ERROR, e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import com.mcwl.common.exception.ServiceException;
|
import com.mcwl.common.exception.ServiceException;
|
||||||
import io.lettuce.core.RedisCommandTimeoutException;
|
import io.lettuce.core.RedisCommandTimeoutException;
|
||||||
|
import io.lettuce.core.RedisException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -77,9 +78,11 @@ public class TokenService
|
||||||
LoginUser user = redisCache.getCacheObject(userKey);
|
LoginUser user = redisCache.getCacheObject(userKey);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
catch (RedisCommandTimeoutException e)
|
catch (RedisException e) {
|
||||||
{
|
if (e.getCause() instanceof io.lettuce.core.RedisCommandTimeoutException) {
|
||||||
throw new RedisCommandTimeoutException();
|
throw new RedisCommandTimeoutException("连接超时");
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class EmptyPointsRemindConsumer {
|
||||||
sysAdvice.setReceiverId(member.getUserId());
|
sysAdvice.setReceiverId(member.getUserId());
|
||||||
sysAdvice.setType(AdviceEnum.SYSTEM_NOTICE);
|
sysAdvice.setType(AdviceEnum.SYSTEM_NOTICE);
|
||||||
sysAdvice.setTitle("积分清零提醒");
|
sysAdvice.setTitle("积分清零提醒");
|
||||||
sysAdvice.setContent("您的积分即将清零,请及时消费");
|
sysAdvice.setContent("您的积分月底前两天将清零,请及时消费");
|
||||||
sysAdvice.setCreateBy(sysUser.getUserName());
|
sysAdvice.setCreateBy(sysUser.getUserName());
|
||||||
sysAdvice.setUpdateBy(sysUser.getUserName());
|
sysAdvice.setUpdateBy(sysUser.getUserName());
|
||||||
sysAdvice.setUpdateTime(new Date());
|
sysAdvice.setUpdateTime(new Date());
|
||||||
|
|
|
@ -3,8 +3,15 @@ package com.mcwl.memberCenter.task;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.mcwl.common.constant.QueueConstants;
|
import com.mcwl.common.constant.QueueConstants;
|
||||||
import com.mcwl.common.core.domain.entity.SysUser;
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
|
import com.mcwl.memberCenter.domain.Benefit;
|
||||||
import com.mcwl.memberCenter.domain.Member;
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
|
import com.mcwl.memberCenter.domain.MemberBenefit;
|
||||||
|
import com.mcwl.memberCenter.domain.MemberLevel;
|
||||||
|
import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum;
|
||||||
import com.mcwl.memberCenter.enums.MemberEnum;
|
import com.mcwl.memberCenter.enums.MemberEnum;
|
||||||
|
import com.mcwl.memberCenter.service.BenefitService;
|
||||||
|
import com.mcwl.memberCenter.service.MemberBenefitService;
|
||||||
|
import com.mcwl.memberCenter.service.MemberLevelService;
|
||||||
import com.mcwl.memberCenter.service.MemberService;
|
import com.mcwl.memberCenter.service.MemberService;
|
||||||
import com.mcwl.system.service.ISysUserService;
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
@ -27,6 +34,10 @@ public class UserMemberTask {
|
||||||
|
|
||||||
private final RabbitTemplate rabbitTemplate;
|
private final RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
private final MemberBenefitService memberBenefitService;
|
||||||
|
|
||||||
|
private final BenefitService benefitService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 积分清零提醒 月底前五天 0 0 9 L-5 * ?
|
* 积分清零提醒 月底前五天 0 0 9 L-5 * ?
|
||||||
|
@ -45,7 +56,7 @@ public class UserMemberTask {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清空积分 每月月底前两天 0 0 9 L-2 * ?
|
* 清空积分 每月月底前两天 0 0 0 L-2 * ?
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
public void emptyPointsTsk() {
|
public void emptyPointsTsk() {
|
||||||
|
@ -104,4 +115,47 @@ public class UserMemberTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员积分赠送 每月1号 0 0 0 1 * ?
|
||||||
|
*/
|
||||||
|
public void givePointsTask() {
|
||||||
|
List<Member> memberList = memberService.getUseUserMember();
|
||||||
|
for (Member member : memberList) {
|
||||||
|
Long memberLevelId = member.getMemberLevelId();
|
||||||
|
Double points = this.getPointsByMemberLevelId(memberLevelId);
|
||||||
|
member.setPoints(points);
|
||||||
|
}
|
||||||
|
memberService.updateBatchById(memberList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据会员等级获取积分
|
||||||
|
*/
|
||||||
|
public Double getPointsByMemberLevelId(Long memberLevelId) {
|
||||||
|
|
||||||
|
// 根据会员等级id获取会员权益
|
||||||
|
List<MemberBenefit> memberBenefitList = memberBenefitService.lambdaQuery()
|
||||||
|
.eq(MemberBenefit::getMemberLevelId, memberLevelId)
|
||||||
|
.list();
|
||||||
|
|
||||||
|
// 根据会员权益id获取权益
|
||||||
|
List<Long> benefitIdList = new ArrayList<>();
|
||||||
|
for (MemberBenefit memberBenefit : memberBenefitList) {
|
||||||
|
benefitIdList.add(memberBenefit.getBenefitId());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Benefit> benefitList = benefitService.lambdaQuery()
|
||||||
|
.in(Benefit::getId, benefitIdList)
|
||||||
|
.list();
|
||||||
|
for (Benefit benefit : benefitList) {
|
||||||
|
if (benefit.getBenefitType().equals(MemberBenefitTypeEnum.POINTS.getValue())) {
|
||||||
|
return benefit.getBenefitDiscount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,8 +64,8 @@ public class OrderTrade extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 下单时间
|
* 下单时间
|
||||||
*/
|
*/
|
||||||
@JsonFormat(pattern = "yyyy-mm-dd")
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
@DateTimeFormat(pattern = "yyyy-mm-dd")
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
private Date orderTime;
|
private Date orderTime;
|
||||||
/**
|
/**
|
||||||
* 订单状态 1:下单 2:支付 3:完成 4:取消
|
* 订单状态 1:下单 2:支付 3:完成 4:取消
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.mcwl.pay.domain.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
import com.mcwl.common.interfaces.MaxMoney;
|
||||||
|
import com.mcwl.common.interfaces.MinMoney;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "金币充值记录")
|
||||||
|
public class OrderTradeVo {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 订单编码
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "订单编码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品名称
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "商品名称")
|
||||||
|
private String productName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下单时间
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "下单时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date orderTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 付款金额
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "付款金额")
|
||||||
|
private Integer paymentAmount;
|
||||||
|
}
|
Loading…
Reference in New Issue