feat(memberCenter): 积分调整

master
yang 2025-03-05 17:03:26 +08:00
parent 7d3c43a1e8
commit 1350eb52f5
14 changed files with 269 additions and 44 deletions

View File

@ -1,13 +1,13 @@
package com.mcwl.web.controller.memberCenter; 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.AjaxResult;
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.utils.SecurityUtils; import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.memberCenter.domain.MemberConsume; import com.mcwl.memberCenter.domain.*;
import com.mcwl.memberCenter.domain.Member; import com.mcwl.memberCenter.domain.vo.MemberConsumeVO;
import com.mcwl.memberCenter.domain.MemberLevel; import com.mcwl.memberCenter.domain.vo.RechargeRecordVO;
import com.mcwl.memberCenter.domain.MemberPromotion;
import com.mcwl.memberCenter.enums.PromotionEnum; import com.mcwl.memberCenter.enums.PromotionEnum;
import com.mcwl.memberCenter.service.*; import com.mcwl.memberCenter.service.*;
import com.mcwl.memberCenter.domain.dto.RechargePointsDto; import com.mcwl.memberCenter.domain.dto.RechargePointsDto;
@ -80,37 +80,35 @@ public class MemberController {
/** /**
* *
* *
* @return * @return
*/ */
@GetMapping("getPoints") @GetMapping("getPoints")
@ApiOperation(value = "获取积分余额和历史记录") @ApiOperation(value = "获取积分消费记录")
public R<PointsVO> getPoints() { public R<List<MemberConsumeVO>> getPoints() {
Long userId = SecurityUtils.getUserId(); 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 List<MemberConsume> memberConsumeList = memberConsumeService
.lambdaQuery() .lambdaQuery()
.eq(MemberConsume::getUserId, userId) .eq(MemberConsume::getUserId, userId)
.list(); .list();
pointsVO.setPoints(points); return R.ok(BeanUtil.copyToList(memberConsumeList, MemberConsumeVO.class));
pointsVO.setMemberConsumeList(memberConsumeList); }
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,10 +1,16 @@
package com.mcwl.web.controller.personalCenter; package com.mcwl.web.controller.personalCenter;
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.PageDomain;
import com.mcwl.common.core.page.TableDataInfo; 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.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 io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -14,18 +20,33 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@Api(tags = "个人中心") @Api(tags = "个人中心")
@RestController @RestController
@RequestMapping("personalCenter") @RequestMapping("personalCenter")
@RequiredArgsConstructor @RequiredArgsConstructor
public class PersonalCenterController { public class PersonalCenterController {
private final ModelService modelService; private final ModelService modelService;
private final ModelLikeService modelLikeService; private final ModelLikeService modelLikeService;
private final ModelImageService modelImageService; private final ModelImageService modelImageService;
private final WorkFlowService workFlowService; private final WorkFlowService workFlowService;
private final WorkFlowLikeService workFlowLikeService; private final WorkFlowLikeService workFlowLikeService;
private final ModelImageLikeService modelImageLikeService; private final ModelImageLikeService modelImageLikeService;
private final ISysUserService sysUserService;
private final MemberService memberService;
/** /**
* - * -
*/ */
@ -83,6 +104,34 @@ public class PersonalCenterController {
return modelImageLikeService.listByPage(pageDomain); 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);
}
} }

View File

@ -77,6 +77,10 @@ public class TokenService
LoginUser user = redisCache.getCacheObject(userKey); LoginUser user = redisCache.getCacheObject(userKey);
return user; return user;
} }
catch (RedisCommandTimeoutException e)
{
throw new RedisCommandTimeoutException();
}
catch (Exception e) catch (Exception e)
{ {
log.error("获取用户信息异常'{}'", e.getMessage()); log.error("获取用户信息异常'{}'", e.getMessage());

View File

@ -2,6 +2,7 @@ package com.mcwl.memberCenter.domain;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mcwl.common.core.domain.BaseEntity; import com.mcwl.common.core.domain.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -9,7 +10,7 @@ import lombok.EqualsAndHashCode;
import java.util.Date; import java.util.Date;
/** /**
* *
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@ -29,6 +30,7 @@ public class MemberConsume extends BaseEntity {
private Double remainingPoints; private Double remainingPoints;
// 消费时间 // 消费时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date consumeTime; 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.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.mcwl.common.core.domain.BaseEntity; import com.mcwl.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.util.Date;
/**
*
*/
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@TableName("mem_recharge_record") @TableName("mem_recharge_record")
@ -19,6 +25,11 @@ public class RechargeRecord extends BaseEntity {
*/ */
private Long userId; private Long userId;
/**
*
*/
private String getSource;
/** /**
* *
*/ */
@ -34,4 +45,14 @@ public class RechargeRecord extends BaseEntity {
*/ */
private Double points; 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; package com.mcwl.memberCenter.domain.vo;
import com.mcwl.memberCenter.domain.MemberConsume; import com.mcwl.memberCenter.domain.MemberConsume;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.ArrayList; import java.util.ArrayList;
@ -10,11 +12,11 @@ import java.util.List;
* *
*/ */
@Data @Data
@ApiModel(description = "积分历史记录")
public class PointsVO { 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.baomidou.mybatisplus.extension.service.IService;
import com.mcwl.memberCenter.domain.Member; import com.mcwl.memberCenter.domain.Member;
import com.mcwl.memberCenter.domain.vo.RechargeRecordVO;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
@ -25,6 +26,7 @@ public interface MemberService extends IService<Member> {
*/ */
List<Member> getUseUserMember(); List<Member> getUseUserMember();
/**
/** /**
* id使 * id使
* @param userId id * @param userId id
@ -44,4 +46,6 @@ public interface MemberService extends IService<Member> {
void consumePoints(Double consumePoints); void consumePoints(Double consumePoints);
Double calculatePayment(Double unitPrice, Long promotionId); Double calculatePayment(Double unitPrice, Long promotionId);
List<RechargeRecordVO> getRechargePoints(Long userId);
} }

View File

@ -1,5 +1,6 @@
package com.mcwl.memberCenter.service.impl; package com.mcwl.memberCenter.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.exception.ServiceException;
import com.mcwl.common.utils.SecurityUtils; import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.memberCenter.domain.*; import com.mcwl.memberCenter.domain.*;
import com.mcwl.memberCenter.domain.vo.RechargeRecordVO;
import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum; import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum;
import com.mcwl.memberCenter.enums.MemberEnum; import com.mcwl.memberCenter.enums.MemberEnum;
import com.mcwl.memberCenter.enums.MemberPeriodicEnum; import com.mcwl.memberCenter.enums.MemberPeriodicEnum;
@ -39,6 +41,8 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
private final BenefitService benefitService; private final BenefitService benefitService;
private final RechargeRecordService rechargeRecordService;
@Override @Override
public Member createUserMember(Long userId, Long memberLevelId, String paymentMethod, Long promotionId) { public Member createUserMember(Long userId, Long memberLevelId, String paymentMethod, Long promotionId) {
if (userId == null) { if (userId == null) {
@ -110,12 +114,6 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
member.setLastPaymentDate(new Date()); member.setLastPaymentDate(new Date());
// 设置支付方式 // 设置支付方式
member.setPaymentMethod(paymentMethod); 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); baseMapper.insert(member);
@ -283,4 +281,24 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
return calendar.getTime(); 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

@ -44,7 +44,7 @@ public class OrderTrade extends BaseEntity {
/** /**
* ID * ID
*/ */
private Integer productId; private Long productId;
/** /**
* *
*/ */

View File

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

View File

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

View File

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