Merge branch 'feature/community-center' into preview

master
yang 2025-03-05 18:31:31 +08:00
commit 8ee438d3c3
20 changed files with 502 additions and 59 deletions

View File

@ -1,13 +1,13 @@
package com.mcwl.web.controller.memberCenter;
import cn.hutool.core.bean.BeanUtil;
import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.core.domain.R;
import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.memberCenter.domain.MemberConsume;
import com.mcwl.memberCenter.domain.Member;
import com.mcwl.memberCenter.domain.MemberLevel;
import com.mcwl.memberCenter.domain.MemberPromotion;
import com.mcwl.memberCenter.domain.*;
import com.mcwl.memberCenter.domain.vo.MemberConsumeVO;
import com.mcwl.memberCenter.domain.vo.RechargeRecordVO;
import com.mcwl.memberCenter.enums.PromotionEnum;
import com.mcwl.memberCenter.service.*;
import com.mcwl.memberCenter.domain.dto.RechargePointsDto;
@ -80,37 +80,35 @@ public class MemberController {
/**
*
*
*
* @return
* @return
*/
@GetMapping("getPoints")
@ApiOperation(value = "获取积分余额和历史记录")
public R<PointsVO> getPoints() {
@ApiOperation(value = "获取积分消费记录")
public R<List<MemberConsumeVO>> getPoints() {
Long userId = SecurityUtils.getUserId();
SysUser sysUser = sysUserService.selectUserById(userId);
Member member = memberService.getUseUserMemberByUserId(userId);
double points = sysUser.getFreePoints();
if (Objects.nonNull(member)) {
points = points + member.getPoints();
}
PointsVO pointsVO = new PointsVO();
// 会员消费记录
List<MemberConsume> memberConsumeList = memberConsumeService
.lambdaQuery()
.eq(MemberConsume::getUserId, userId)
.list();
pointsVO.setPoints(points);
pointsVO.setMemberConsumeList(memberConsumeList);
return R.ok(BeanUtil.copyToList(memberConsumeList, MemberConsumeVO.class));
}
return R.ok(pointsVO);
/**
*
*/
@GetMapping("getRechargePoints")
@ApiOperation(value = "获取积分记录")
public R<List<RechargeRecordVO>> getRechargePoints() {
Long userId = SecurityUtils.getUserId();
List<RechargeRecordVO> rechargeRecordList = memberService.getRechargePoints(userId);
return R.ok(rechargeRecordList);
}

View File

@ -1,31 +1,56 @@
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.entity.SysUser;
import com.mcwl.common.core.page.PageDomain;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.memberCenter.domain.Member;
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.service.*;
import com.mcwl.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Api(tags = "个人中心")
@RestController
@RequestMapping("personalCenter")
@RequiredArgsConstructor
public class PersonalCenterController {
private final ModelService modelService;
private final ModelLikeService modelLikeService;
private final ModelImageService modelImageService;
private final WorkFlowService workFlowService;
private final WorkFlowLikeService workFlowLikeService;
private final ModelImageLikeService modelImageLikeService;
private final ISysUserService sysUserService;
private final MemberService memberService;
private final OrderTradeService orderTradeService;
/**
* -
*/
@ -83,6 +108,60 @@ public class PersonalCenterController {
return modelImageLikeService.listByPage(pageDomain);
}
/**
*
*/
@ApiOperation(value = "获取积分和金币")
@PostMapping("/getPointAndWallet")
public R<Map<String, Double>> getPointAndWallet() {
Long userId = SecurityUtils.getUserId();
Map<String, Double> map = new HashMap<>();
SysUser sysUser = sysUserService.selectUserById(userId);
Member member = memberService.getUseUserMemberByUserId(userId);
double points = sysUser.getFreePoints();
if (Objects.nonNull(member)) {
points = points + member.getPoints();
}
map.put("point", points);
map.put("wallet", sysUser.getWallet());
return R.ok(map);
}
/**
*
*/
@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));
}
}

View File

@ -87,7 +87,7 @@ spring:
# 密码
password: MuYu_Cloud@Redis
# 连接超时时间
timeout: 10s
timeout: 30s
lettuce:
pool:
# 连接池中的最小空闲连接
@ -97,7 +97,64 @@ spring:
# 连接池的最大数据库连接数
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:

View File

@ -5,10 +5,16 @@ import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
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.script.DefaultRedisScript;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import java.time.Duration;
/**
* redis
*
@ -66,4 +72,22 @@ public class RedisConfig extends CachingConfigurerSupport
"end\n" +
"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);
// }
}

View File

@ -9,6 +9,7 @@ import com.mcwl.common.exception.ServiceException;
import com.mcwl.common.utils.StringUtils;
import com.mcwl.common.utils.html.EscapeUtil;
import io.lettuce.core.RedisCommandTimeoutException;
import io.lettuce.core.RedisException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.AccessDeniedException;
@ -45,13 +46,13 @@ public class GlobalExceptionHandler {
}
/**
*
* redis
*/
@ExceptionHandler(RedisCommandTimeoutException.class)
public AjaxResult commandTimeoutException(AccessDeniedException e, HttpServletRequest request) {
@ExceptionHandler(RedisException.class)
public AjaxResult commandTimeoutException(RedisException e, HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("连接超时{},{}", requestURI, e.getMessage());
return AjaxResult.error(HttpStatus.ERROR, "连接超时");
log.error("redis异常{},{}", requestURI, e.getMessage());
return AjaxResult.error(HttpStatus.ERROR, e.getMessage());
}

View File

@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletRequest;
import com.mcwl.common.exception.ServiceException;
import io.lettuce.core.RedisCommandTimeoutException;
import io.lettuce.core.RedisException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -77,6 +78,12 @@ public class TokenService
LoginUser user = redisCache.getCacheObject(userKey);
return user;
}
catch (RedisException e) {
if (e.getCause() instanceof io.lettuce.core.RedisCommandTimeoutException) {
throw new RedisCommandTimeoutException("连接超时");
}
throw e;
}
catch (Exception e)
{
log.error("获取用户信息异常'{}'", e.getMessage());

View File

@ -41,7 +41,7 @@ public class EmptyPointsRemindConsumer {
sysAdvice.setReceiverId(member.getUserId());
sysAdvice.setType(AdviceEnum.SYSTEM_NOTICE);
sysAdvice.setTitle("积分清零提醒");
sysAdvice.setContent("您的积分将清零,请及时消费");
sysAdvice.setContent("您的积分月底前两天将清零,请及时消费");
sysAdvice.setCreateBy(sysUser.getUserName());
sysAdvice.setUpdateBy(sysUser.getUserName());
sysAdvice.setUpdateTime(new Date());

View File

@ -2,6 +2,7 @@ package com.mcwl.memberCenter.domain;
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 lombok.Data;
import lombok.EqualsAndHashCode;
@ -9,7 +10,7 @@ import lombok.EqualsAndHashCode;
import java.util.Date;
/**
*
*
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ -29,6 +30,7 @@ public class MemberConsume extends BaseEntity {
private Double remainingPoints;
// 消费时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date consumeTime;

View File

@ -3,9 +3,15 @@ package com.mcwl.memberCenter.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.mcwl.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
*
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("mem_recharge_record")
@ -19,6 +25,11 @@ public class RechargeRecord extends BaseEntity {
*/
private Long userId;
/**
*
*/
private String getSource;
/**
*
*/
@ -34,4 +45,14 @@ public class RechargeRecord extends BaseEntity {
*/
private Double points;
/**
*
*/
private Date effectStartTime;
/**
*
*/
private Date effectEndTime;
}

View File

@ -0,0 +1,35 @@
package com.mcwl.memberCenter.domain.vo;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mcwl.memberCenter.domain.MemberConsume;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
*
*/
@Data
@ApiModel(description = "积分消费")
public class MemberConsumeVO {
private Long id;
// 用户id
@ApiModelProperty(value = "用户id")
private Long userId;
// 消费积分
@ApiModelProperty(value = "消费积分")
private Double consumePoints;
// 消费时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date consumeTime;
}

View File

@ -1,6 +1,8 @@
package com.mcwl.memberCenter.domain.vo;
import com.mcwl.memberCenter.domain.MemberConsume;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
@ -10,11 +12,11 @@ import java.util.List;
*
*/
@Data
@ApiModel(description = "积分历史记录")
public class PointsVO {
// 积分余额
private Double points;
// 积分消费记录
private List<MemberConsume> memberConsumeList = new ArrayList<>();
@ApiModelProperty(value = "积分消费记录")
private List<MemberConsumeVO> memberConsumeList = new ArrayList<>();
}

View File

@ -0,0 +1,70 @@
package com.mcwl.memberCenter.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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
*
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(description = "积分获取记录")
public class RechargeRecordVO {
private Long id;
/**
* ID
*/
@ApiModelProperty(value = "用户ID")
private Long userId;
/**
*
*/
private String getSource;
/**
*
*/
@ApiModelProperty(value = "充值金额")
private Double amount;
/**
*
*/
@ApiModelProperty(value = "获取到的积分")
private Double points;
/**
*
*/
@ApiModelProperty(value = "有效期开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date effectStartTime;
/**
*
*/
@ApiModelProperty(value = "有效期结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date effectEndTime;
/**
*
*/
@ApiModelProperty(value = "积分获取时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date rechargeTime;
}

View File

@ -2,6 +2,7 @@ package com.mcwl.memberCenter.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mcwl.memberCenter.domain.Member;
import com.mcwl.memberCenter.domain.vo.RechargeRecordVO;
import javax.validation.constraints.NotNull;
import java.util.List;
@ -25,6 +26,7 @@ public interface MemberService extends IService<Member> {
*/
List<Member> getUseUserMember();
/**
/**
* id使
* @param userId id
@ -44,4 +46,6 @@ public interface MemberService extends IService<Member> {
void consumePoints(Double consumePoints);
Double calculatePayment(Double unitPrice, Long promotionId);
List<RechargeRecordVO> getRechargePoints(Long userId);
}

View File

@ -1,5 +1,6 @@
package com.mcwl.memberCenter.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -8,6 +9,7 @@ import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.common.exception.ServiceException;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.memberCenter.domain.*;
import com.mcwl.memberCenter.domain.vo.RechargeRecordVO;
import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum;
import com.mcwl.memberCenter.enums.MemberEnum;
import com.mcwl.memberCenter.enums.MemberPeriodicEnum;
@ -39,6 +41,8 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
private final BenefitService benefitService;
private final RechargeRecordService rechargeRecordService;
@Override
public Member createUserMember(Long userId, Long memberLevelId, String paymentMethod, Long promotionId) {
if (userId == null) {
@ -110,12 +114,6 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
member.setLastPaymentDate(new Date());
// 设置支付方式
member.setPaymentMethod(paymentMethod);
// 设置创建者
SysUser sysUser = sysUserService.selectUserById(userId);
member.setCreateBy(sysUser.getUserName());
member.setCreateTime(new Date());
member.setUpdateBy(sysUser.getUserName());
member.setUpdateTime(new Date());
baseMapper.insert(member);
@ -283,4 +281,24 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
return calendar.getTime();
}
@Override
public List<RechargeRecordVO> getRechargePoints(Long userId) {
if (Objects.isNull(userId)) {
return Collections.emptyList();
}
List<RechargeRecord> rechargeRecordList = rechargeRecordService.lambdaQuery()
.eq(RechargeRecord::getUserId, userId)
.list();
List<RechargeRecordVO> rechargeRecordVOList = new ArrayList<>();
for (RechargeRecord rechargeRecord : rechargeRecordList) {
RechargeRecordVO rechargeRecordVO = BeanUtil.copyProperties(rechargeRecord, RechargeRecordVO.class);
rechargeRecordVO.setRechargeTime(rechargeRecord.getCreateTime());
rechargeRecordVOList.add(rechargeRecordVO);
}
return rechargeRecordVOList;
}
}

View File

@ -3,8 +3,15 @@ package com.mcwl.memberCenter.task;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mcwl.common.constant.QueueConstants;
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.MemberBenefit;
import com.mcwl.memberCenter.domain.MemberLevel;
import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum;
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.system.service.ISysUserService;
import lombok.RequiredArgsConstructor;
@ -27,6 +34,10 @@ public class UserMemberTask {
private final RabbitTemplate rabbitTemplate;
private final MemberBenefitService memberBenefitService;
private final BenefitService benefitService;
/**
* 0 0 9 L-5 * ?
@ -45,7 +56,7 @@ public class UserMemberTask {
/**
* 0 0 9 L-2 * ?
* 0 0 0 L-2 * ?
*/
@Transactional
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;
}
}

View File

@ -44,7 +44,7 @@ public class OrderTrade extends BaseEntity {
/**
* ID
*/
private Integer productId;
private Long productId;
/**
*
*/
@ -64,8 +64,8 @@ public class OrderTrade extends BaseEntity {
/**
*
*/
@JsonFormat(pattern = "yyyy-mm-dd")
@DateTimeFormat(pattern = "yyyy-mm-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date orderTime;
/**
* 1: 2: 3 4

View File

@ -15,7 +15,7 @@ public class OrderTradeDto {
* ID
*/
@ApiModelProperty(value = "商品ID 如果订单类型是points 或者 wallet可以不传")
private Integer productId;
private Long productId;
/**
*

View File

@ -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;
}

View File

@ -167,7 +167,7 @@ public class AliPayServiceImpl implements AliPayService {
public PayVo memberPay(OrderTradeDto orderTradeDto) throws Exception {
// 会员等级id
Integer productId = orderTradeDto.getProductId();
Long productId = orderTradeDto.getProductId();
if (!Optional.ofNullable(productId).isPresent()) {
throw new ServiceException("memberLevelId不能为空");
@ -225,7 +225,7 @@ public class AliPayServiceImpl implements AliPayService {
OrderTrade tradeEntity = new OrderTrade();
tradeEntity.setCode(UUID.randomUUID().toString(true).substring(0, 30) + "_points");
tradeEntity.setUserId(SecurityUtils.getUserId());
tradeEntity.setProductId(-1);
tradeEntity.setProductId(-1L);
tradeEntity.setProductName("积分充值");
tradeEntity.setUserName(SecurityUtils.getUsername());
tradeEntity.setTotalAmount(paymentAmount);
@ -263,7 +263,7 @@ public class AliPayServiceImpl implements AliPayService {
OrderTrade tradeEntity = new OrderTrade();
tradeEntity.setCode(UUID.randomUUID().toString(true).substring(0, 30) + "_wallet");
tradeEntity.setUserId(SecurityUtils.getUserId());
tradeEntity.setProductId(-1);
tradeEntity.setProductId(-1L);
tradeEntity.setProductName("金币充值");
tradeEntity.setUserName(SecurityUtils.getUsername());
tradeEntity.setTotalAmount(paymentAmount);

View File

@ -1,5 +1,6 @@
package com.mcwl.pay.service.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mcwl.common.core.domain.entity.SysUser;
@ -8,7 +9,10 @@ import com.mcwl.common.domain.IdsParam;
import com.mcwl.common.utils.DateUtils;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils;
import com.mcwl.memberCenter.domain.Member;
import com.mcwl.memberCenter.domain.MemberLevel;
import com.mcwl.memberCenter.domain.RechargeRecord;
import com.mcwl.memberCenter.service.MemberLevelService;
import com.mcwl.memberCenter.service.MemberService;
import com.mcwl.memberCenter.service.RechargeRecordService;
import com.mcwl.myInvitation.domain.Commission;
@ -31,12 +35,16 @@ import com.mcwl.resource.service.ModelService;
import com.mcwl.resource.service.WorkFlowService;
import com.mcwl.system.service.ISysUserService;
import com.mcwl.system.service.impl.SysUserServiceImpl;
import org.joda.time.LocalDateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalTime;
import java.time.YearMonth;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
/**
@ -53,7 +61,7 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
@Autowired
private OrderTradeMapper orderTradeMapper;
@Autowired
private SysUserServiceImpl userExtensionService;
private MemberLevelService memberLevelService;
@Autowired
private OrderTradeService orderTradeService;
@ -235,12 +243,12 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
// 添加充值记录
RechargeRecord rechargeRecord = new RechargeRecord();
rechargeRecord.setUserId(userId);
rechargeRecord.setGetSource("积分充值");
rechargeRecord.setCode(orderTrade.getCode());
rechargeRecord.setAmount(Double.parseDouble(amount));
rechargeRecord.setPoints(points);
rechargeRecord.setCreateBy(user.getUserName());
rechargeRecord.setUpdateBy(user.getUserName());
rechargeRecord.setUpdateTime(new Date());
rechargeRecord.setEffectStartTime(new Date());
rechargeRecord.setEffectEndTime(DateUtil.endOfMonth(new Date()));
rechargeRecordService.save(rechargeRecord);
@ -279,10 +287,24 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
private void memberHandler(OrderTrade orderTrade, Long promotionId) {
Long userId = orderTrade.getUserId();
Integer memberLevelId = orderTrade.getProductId();
Long memberLevelId = orderTrade.getProductId();
String paymentMethod = "aliPay";
memberService.createUserMember(userId, memberLevelId.longValue(), paymentMethod, promotionId);
Member userMember = memberService.createUserMember(userId, memberLevelId, paymentMethod, promotionId);
MemberLevel memberLevel = memberLevelService.getById(memberLevelId);
// 添加充值记录
RechargeRecord rechargeRecord = new RechargeRecord();
rechargeRecord.setUserId(userId);
rechargeRecord.setGetSource(memberLevel.getMemberName());
rechargeRecord.setCode(orderTrade.getCode());
rechargeRecord.setAmount(orderTrade.getPaymentAmount().doubleValue());
rechargeRecord.setPoints(userMember.getPoints());
rechargeRecord.setEffectStartTime(new Date());
rechargeRecord.setEffectEndTime(DateUtil.endOfMonth(new Date()));
rechargeRecordService.save(rechargeRecord);
}