Merge remote-tracking branch 'origin/preview' into preview
commit
a98d3bea72
|
@ -2,21 +2,25 @@ package com.mcwl.web.controller.memberCenter;
|
||||||
|
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
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.memberCenter.domain.MemberConsume;
|
import com.mcwl.memberCenter.domain.MemberConsume;
|
||||||
import com.mcwl.memberCenter.domain.Member;
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
import com.mcwl.memberCenter.domain.MemberLevel;
|
import com.mcwl.memberCenter.domain.MemberLevel;
|
||||||
import com.mcwl.memberCenter.service.MemberBenefitService;
|
import com.mcwl.memberCenter.service.MemberBenefitService;
|
||||||
import com.mcwl.memberCenter.service.MemberLevelService;
|
import com.mcwl.memberCenter.domain.dto.RechargePointsDto;
|
||||||
import com.mcwl.web.controller.memberCenter.pojo.dto.RechargePointsDto;
|
import com.mcwl.memberCenter.domain.dto.UserMemberDto;
|
||||||
import com.mcwl.web.controller.memberCenter.pojo.dto.UserMemberDto;
|
|
||||||
import com.mcwl.memberCenter.service.MemberConsumeService;
|
import com.mcwl.memberCenter.service.MemberConsumeService;
|
||||||
|
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 com.mcwl.web.controller.memberCenter.pojo.vo.PointsVO;
|
import com.mcwl.memberCenter.domain.vo.PointsVO;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("member")
|
@RequestMapping("member")
|
||||||
|
@ -31,6 +35,7 @@ public class MemberController {
|
||||||
|
|
||||||
private final MemberBenefitService memberBenefitService;
|
private final MemberBenefitService memberBenefitService;
|
||||||
|
|
||||||
|
private final MemberLevelService memberLevelService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建用户会员
|
* 创建用户会员
|
||||||
|
@ -39,45 +44,42 @@ public class MemberController {
|
||||||
* @return 用户会员
|
* @return 用户会员
|
||||||
*/
|
*/
|
||||||
@PostMapping("createMember")
|
@PostMapping("createMember")
|
||||||
public AjaxResult createMemberCenter(@RequestBody UserMemberDto userMemberDto) {
|
public AjaxResult createMemberCenter(@RequestBody @Valid UserMemberDto userMemberDto) {
|
||||||
Long userId = userMemberDto.getUserId();
|
Long userId = userMemberDto.getUserId();
|
||||||
if (userId == null) {
|
|
||||||
return AjaxResult.warn("用户未登录");
|
|
||||||
}
|
|
||||||
Long memberLevelId = userMemberDto.getMemberLevelId();
|
Long memberLevelId = userMemberDto.getMemberLevelId();
|
||||||
if (memberLevelId == null) {
|
|
||||||
return AjaxResult.warn("会员等级未选择");
|
|
||||||
}
|
|
||||||
String paymentMethod = userMemberDto.getPaymentMethod();
|
String paymentMethod = userMemberDto.getPaymentMethod();
|
||||||
if (paymentMethod == null) {
|
Long promotionId = userMemberDto.getPromotionId();
|
||||||
return AjaxResult.warn("支付方式错误,请重新支付");
|
|
||||||
|
SysUser sysUser = sysUserService.selectUserById(userId);
|
||||||
|
if (!Optional.ofNullable(sysUser).isPresent()) {
|
||||||
|
return AjaxResult.warn("用户不存在");
|
||||||
}
|
}
|
||||||
Member member = memberService.createUserMember(userId, memberLevelId, paymentMethod);
|
|
||||||
if (member == null) {
|
MemberLevel memberLevel = memberLevelService.getById(memberLevelId);
|
||||||
|
if (!Optional.ofNullable(memberLevel).isPresent()) {
|
||||||
|
return AjaxResult.warn("会员等级不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
Member member = memberService.createUserMember(userId, memberLevelId, paymentMethod, promotionId);
|
||||||
|
if (!Optional.ofNullable(member).isPresent()) {
|
||||||
return AjaxResult.warn("创建会员失败");
|
return AjaxResult.warn("创建会员失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
return AjaxResult.success(member);
|
return AjaxResult.success(member);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取积分余额和历史记录
|
* 获取积分余额和历史记录
|
||||||
* @param userId 用户id
|
*
|
||||||
* @return 积分余额和历史记录
|
* @return 积分余额和历史记录
|
||||||
*/
|
*/
|
||||||
@GetMapping("getPoints/{id}")
|
@GetMapping("getPoints")
|
||||||
public AjaxResult getPoints(@PathVariable("id") Long userId) {
|
public AjaxResult getPoints() {
|
||||||
if (userId == null) {
|
Long userId = SecurityUtils.getUserId();
|
||||||
return AjaxResult.warn("用户未登录");
|
|
||||||
}
|
|
||||||
|
|
||||||
SysUser sysUser = sysUserService.selectUserById(userId);
|
|
||||||
if (sysUser == null) {
|
|
||||||
return AjaxResult.warn("用户不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
Member member = memberService.getUseUserMemberByUserId(userId);
|
Member member = memberService.getUseUserMemberByUserId(userId);
|
||||||
if (member == null) {
|
if (!Optional.ofNullable(member).isPresent()) {
|
||||||
return AjaxResult.warn("用户未开通会员");
|
return AjaxResult.warn("用户未开通会员");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,31 +102,19 @@ public class MemberController {
|
||||||
* 会员积分充值
|
* 会员积分充值
|
||||||
*/
|
*/
|
||||||
@PostMapping("rechargePoints")
|
@PostMapping("rechargePoints")
|
||||||
public AjaxResult rechargePoints(@RequestBody RechargePointsDto rechargePointsDto) {
|
public AjaxResult rechargePoints(@RequestBody @Valid RechargePointsDto rechargePointsDto) {
|
||||||
Long userId = rechargePointsDto.getUserId();
|
Long userId = rechargePointsDto.getUserId();
|
||||||
Double points = rechargePointsDto.getPoints();
|
Double amount = rechargePointsDto.getAmount();
|
||||||
|
|
||||||
if (userId == null) {
|
|
||||||
return AjaxResult.warn("用户未登录");
|
|
||||||
}
|
|
||||||
|
|
||||||
SysUser sysUser = sysUserService.selectUserById(userId);
|
SysUser sysUser = sysUserService.selectUserById(userId);
|
||||||
if (sysUser == null) {
|
if (!Optional.ofNullable(sysUser).isPresent()) {
|
||||||
return AjaxResult.warn("用户不存在");
|
return AjaxResult.warn("用户不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (points == null) {
|
Member member = memberService.rechargePoints(userId, amount * 10);
|
||||||
return AjaxResult.warn("充值积分为空");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (points <= 0) {
|
|
||||||
return AjaxResult.warn("充值积分必须大于0");
|
|
||||||
}
|
|
||||||
|
|
||||||
Member member = memberService.rechargePoints(userId, points);
|
|
||||||
|
|
||||||
// 返回充值积分
|
// 返回充值积分
|
||||||
if (member == null) {
|
if (!Optional.ofNullable(member).isPresent()) {
|
||||||
return AjaxResult.warn("充值积分失败");
|
return AjaxResult.warn("充值积分失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import com.mcwl.memberCenter.domain.MemberBenefit;
|
||||||
import com.mcwl.memberCenter.domain.MemberLevel;
|
import com.mcwl.memberCenter.domain.MemberLevel;
|
||||||
import com.mcwl.memberCenter.service.MemberBenefitService;
|
import com.mcwl.memberCenter.service.MemberBenefitService;
|
||||||
import com.mcwl.memberCenter.service.MemberLevelService;
|
import com.mcwl.memberCenter.service.MemberLevelService;
|
||||||
import com.mcwl.web.controller.memberCenter.pojo.vo.MemberBenefitVO;
|
import com.mcwl.memberCenter.domain.vo.MemberBenefitVO;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
|
@ -0,0 +1,170 @@
|
||||||
|
package com.mcwl.web.controller.memberCenter;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
|
import com.mcwl.memberCenter.domain.MemberPromotion;
|
||||||
|
import com.mcwl.memberCenter.domain.Promotion;
|
||||||
|
import com.mcwl.memberCenter.domain.dto.JoinPromotionDto;
|
||||||
|
import com.mcwl.memberCenter.domain.dto.PromotionDto;
|
||||||
|
import com.mcwl.memberCenter.enums.MemberEnum;
|
||||||
|
import com.mcwl.memberCenter.enums.PromotionEnum;
|
||||||
|
import com.mcwl.memberCenter.service.MemberPromotionService;
|
||||||
|
import com.mcwl.memberCenter.service.MemberService;
|
||||||
|
import com.mcwl.memberCenter.service.PromotionService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 促销活动
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("promotion")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PromotionController {
|
||||||
|
|
||||||
|
private final PromotionService promotionService;
|
||||||
|
|
||||||
|
private final MemberPromotionService memberPromotionService;
|
||||||
|
|
||||||
|
private final MemberService memberService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建活动
|
||||||
|
*/
|
||||||
|
@PostMapping("createPromotion")
|
||||||
|
public AjaxResult createPromotion(@RequestBody @Valid PromotionDto promotionDto) {
|
||||||
|
|
||||||
|
Date startTime = promotionDto.getStartTime();
|
||||||
|
Date endTime = promotionDto.getEndTime();
|
||||||
|
if (startTime.after(endTime)) {
|
||||||
|
return AjaxResult.warn("活动开始时间不能大于结束时间");
|
||||||
|
}
|
||||||
|
Promotion promotion = new Promotion();
|
||||||
|
|
||||||
|
BeanUtil.copyProperties(promotionDto, promotion);
|
||||||
|
|
||||||
|
promotionService.save(promotion);
|
||||||
|
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动列表
|
||||||
|
*/
|
||||||
|
@GetMapping("promotionList")
|
||||||
|
public AjaxResult promotionList() {
|
||||||
|
List<Promotion> promotionList = promotionService.lambdaQuery()
|
||||||
|
.gt(Promotion::getEndTime, new Date())
|
||||||
|
.list();
|
||||||
|
return AjaxResult.success(promotionList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前用户参与的活动
|
||||||
|
*/
|
||||||
|
@GetMapping("myPromotionList")
|
||||||
|
public AjaxResult myPromotionList() {
|
||||||
|
// 获取当前用户
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
List<MemberPromotion> memberPromotionList = memberPromotionService.lambdaQuery()
|
||||||
|
.eq(MemberPromotion::getUserId, userId)
|
||||||
|
.list();
|
||||||
|
return AjaxResult.success(memberPromotionList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参与活动
|
||||||
|
*/
|
||||||
|
@PostMapping("joinPromotion")
|
||||||
|
public AjaxResult joinPromotion(@RequestBody @Valid JoinPromotionDto joinPromotionDto) {
|
||||||
|
// 用户id
|
||||||
|
Long userId = joinPromotionDto.getUserId();
|
||||||
|
// 活动id
|
||||||
|
Long promotionId = joinPromotionDto.getPromotionId();
|
||||||
|
// 按活动id查询活动信息
|
||||||
|
Promotion promotion = promotionService.getById(promotionId);
|
||||||
|
|
||||||
|
if (!Optional.ofNullable(promotion).isPresent()) {
|
||||||
|
return AjaxResult.warn("活动不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (promotion.getStartTime().after(new Date())) {
|
||||||
|
return AjaxResult.warn("活动未开始");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 活动是否过期
|
||||||
|
if (promotion.getEndTime().before(new Date())) {
|
||||||
|
return AjaxResult.warn("活动已过期");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前用户是否参与过该活动
|
||||||
|
if (isJoinPromotion(userId, promotionId)) {
|
||||||
|
return AjaxResult.warn("您已参与过该活动");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 是否在活动期间内订阅或续订会员
|
||||||
|
// if (!isSubscribe(userId, promotion)) {
|
||||||
|
// return AjaxResult.warn("请在活动期间内订阅或续期会员后参加该活动");
|
||||||
|
// }
|
||||||
|
|
||||||
|
Member member = memberService.getUseUserMemberByUserId(userId);
|
||||||
|
|
||||||
|
String memberLevelIds = promotion.getMemberLevelIds();
|
||||||
|
if (!memberLevelIds.contains(member.getMemberLevelId().toString())) {
|
||||||
|
return AjaxResult.warn("无法参与该活动,请查看活动条件");
|
||||||
|
}
|
||||||
|
MemberPromotion memberPromotion = getMemberPromotion(userId, promotionId);
|
||||||
|
memberPromotionService.save(memberPromotion);
|
||||||
|
|
||||||
|
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
// private boolean isSubscribe(Long userId, Promotion promotion) {
|
||||||
|
// if (promotion.getActivityType() == PromotionEnum.SUBSCRIBE) {
|
||||||
|
// // 获取当前用户最新的订阅或续订
|
||||||
|
// Member member = memberService.latestSubscription(userId);
|
||||||
|
// if (!Optional.ofNullable(member).isPresent()) {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// Date createTime = member.getCreateTime();
|
||||||
|
// // 会员创建时间在活动开始时间之前,说明用户不符合“活动期间内订阅或续订会员”的条件
|
||||||
|
// return !createTime.before(promotion.getStartTime());
|
||||||
|
// }
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
private boolean isJoinPromotion(Long userId, Long promotionId) {
|
||||||
|
MemberPromotion memberPromotion = memberPromotionService.lambdaQuery()
|
||||||
|
.eq(MemberPromotion::getUserId, userId)
|
||||||
|
.eq(MemberPromotion::getPromotionId, promotionId)
|
||||||
|
.one();
|
||||||
|
return memberPromotion != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MemberPromotion getMemberPromotion(Long userId, Long promotionId) {
|
||||||
|
MemberPromotion memberPromotion = new MemberPromotion();
|
||||||
|
memberPromotion.setUserId(userId);
|
||||||
|
memberPromotion.setPromotionId(promotionId);
|
||||||
|
memberPromotion.setStatus(PromotionEnum.PARTICIPATE);
|
||||||
|
memberPromotion.setParticipationTime(new Date());
|
||||||
|
memberPromotion.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
memberPromotion.setCreateTime(new Date());
|
||||||
|
memberPromotion.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
memberPromotion.setUpdateTime(new Date());
|
||||||
|
return memberPromotion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,14 +0,0 @@
|
||||||
package com.mcwl.web.controller.memberCenter.pojo.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class RechargePointsDto {
|
|
||||||
|
|
||||||
// 用户ID
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
// 充值积分
|
|
||||||
private Double points;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package com.mcwl.web.controller.memberCenter.pojo.dto;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class UserMemberDto {
|
|
||||||
|
|
||||||
// 用户ID
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
// 会员ID
|
|
||||||
private Long memberLevelId;
|
|
||||||
|
|
||||||
// 支付方式
|
|
||||||
private String paymentMethod;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,22 +1,30 @@
|
||||||
package com.mcwl.web.controller.myInvitation;
|
package com.mcwl.web.controller.myInvitation;
|
||||||
|
|
||||||
|
|
||||||
import com.mcwl.common.annotation.Anonymous;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.mcwl.common.domain.IdsParam;
|
import com.mcwl.myInvitation.domain.Consume;
|
||||||
|
import com.mcwl.myInvitation.service.ConsumeService;
|
||||||
|
import com.mcwl.myInvitation.domain.dto.ConsumeDto;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消费记录
|
||||||
|
*/
|
||||||
@RestController()
|
@RestController()
|
||||||
|
@RequiredArgsConstructor
|
||||||
@RequestMapping("/consume")
|
@RequestMapping("/consume")
|
||||||
public class ConsumeController {
|
public class ConsumeController {
|
||||||
|
|
||||||
@PostMapping()
|
private final ConsumeService consumeService;
|
||||||
@Anonymous
|
|
||||||
public void removeByIds(@RequestBody IdsParam ids){
|
|
||||||
System.out.println(ids);
|
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public void consume(@RequestBody ConsumeDto consumeDto) {
|
||||||
|
|
||||||
|
Consume consume = new Consume();
|
||||||
|
BeanUtil.copyProperties(consumeDto, consume);
|
||||||
|
consumeService.saveConsume(consume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,28 @@
|
||||||
package com.mcwl.web.controller.myInvitation;
|
package com.mcwl.web.controller.myInvitation;
|
||||||
|
|
||||||
|
|
||||||
import com.mcwl.common.annotation.Anonymous;
|
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.myInvitation.domain.Invitation;
|
import com.mcwl.myInvitation.domain.Invitation;
|
||||||
|
import com.mcwl.myInvitation.domain.dto.EarningsDisplayDto;
|
||||||
import com.mcwl.myInvitation.service.InvitationService;
|
import com.mcwl.myInvitation.service.InvitationService;
|
||||||
|
import com.mcwl.myInvitation.domain.vo.EarningsDisplayVO;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
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.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import static com.mcwl.common.core.domain.AjaxResult.success;
|
import static com.mcwl.common.core.domain.AjaxResult.success;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邀请管理
|
||||||
|
*/
|
||||||
@RestController()
|
@RestController()
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RequestMapping("/invitation")
|
@RequestMapping("/invitation")
|
||||||
|
@ -23,27 +31,60 @@ public class InvitationController {
|
||||||
private final InvitationService invitationService;
|
private final InvitationService invitationService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取邀请码
|
||||||
|
* @return 邀请码
|
||||||
|
*/
|
||||||
@GetMapping("/getInvitationCode")
|
@GetMapping("/getInvitationCode")
|
||||||
public AjaxResult getInvitationCode() {
|
public AjaxResult getInvitationCode() {
|
||||||
// 获取当前用户
|
// 获取当前用户
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
if (userId == null) {
|
|
||||||
return AjaxResult.warn("用户未登录");
|
|
||||||
}
|
|
||||||
String invitationCode = invitationService.getInvitationCode(userId);
|
String invitationCode = invitationService.getInvitationCode(userId);
|
||||||
|
if (StringUtils.isEmpty(invitationCode)) {
|
||||||
|
return AjaxResult.warn("获取邀请码失败");
|
||||||
|
}
|
||||||
return success("操作成功", invitationCode);
|
return success("操作成功", invitationCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/list")
|
|
||||||
public AjaxResult list() {
|
/**
|
||||||
List<Invitation> list = invitationService.list();
|
* 获取邀请列表
|
||||||
|
* @param userId 用户id
|
||||||
|
* @return 邀请列表
|
||||||
|
*/
|
||||||
|
|
||||||
|
@GetMapping("/list/{userId}")
|
||||||
|
public AjaxResult list(@PathVariable Long userId) {
|
||||||
|
List<Invitation> list = invitationService.lambdaQuery()
|
||||||
|
.eq(Invitation::getUserId, userId)
|
||||||
|
.list();
|
||||||
return success(list);
|
return success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getById")
|
|
||||||
public AjaxResult getById(Long id) {
|
/**
|
||||||
Invitation invitation = invitationService.getById(id);
|
* 邀请人收益展示
|
||||||
return success(invitation);
|
*/
|
||||||
|
@GetMapping("earningsDisplay")
|
||||||
|
public AjaxResult earningsDisplay() {
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
|
||||||
|
EarningsDisplayVO earningsDisplayVO = new EarningsDisplayVO();
|
||||||
|
|
||||||
|
// 获取邀请人收益
|
||||||
|
Double totalAmount = invitationService.getTotalAmount(userId);
|
||||||
|
|
||||||
|
// 获取我的团员
|
||||||
|
List<EarningsDisplayDto> earningsDisplay = invitationService.getEarningsDisplay(userId);
|
||||||
|
if (earningsDisplay == null || earningsDisplay.isEmpty()) {
|
||||||
|
return AjaxResult.warn("暂无收益");
|
||||||
|
}
|
||||||
|
|
||||||
|
earningsDisplayVO.setTotalAmount(totalAmount);
|
||||||
|
earningsDisplayVO.setEarningsDisplayList(earningsDisplay);
|
||||||
|
|
||||||
|
return success(earningsDisplayVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,58 +1,71 @@
|
||||||
//package com.mcwl.memberCenter;
|
package com.mcwl.memberCenter;
|
||||||
//
|
|
||||||
//import com.mcwl.McWlApplication;
|
import com.mcwl.McWlApplication;
|
||||||
//import com.mcwl.common.utils.ShareCodeUtils;
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
//import com.mcwl.memberCenter.consumer.EmptyPointsRemindConsumer;
|
import com.mcwl.memberCenter.consumer.EmptyPointsRemindConsumer;
|
||||||
//import com.mcwl.memberCenter.domain.UserMember;
|
import com.mcwl.memberCenter.service.MemberLevelService;
|
||||||
//import com.mcwl.memberCenter.service.MemberService;
|
import com.mcwl.memberCenter.service.MemberService;
|
||||||
//import com.mcwl.memberCenter.service.UserMemberService;
|
import com.mcwl.memberCenter.task.UserMemberTask;
|
||||||
//import com.mcwl.memberCenter.task.UserMemberTask;
|
import com.mcwl.web.controller.memberCenter.MemberController;
|
||||||
//import org.junit.Test;
|
import com.mcwl.web.controller.memberCenter.MemberLevelController;
|
||||||
//import org.junit.runner.RunWith;
|
import org.junit.Test;
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
import org.junit.runner.RunWith;
|
||||||
//import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
//import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
//
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
//@RunWith(SpringRunner.class)
|
|
||||||
//@SpringBootTest(classes = McWlApplication.class)
|
@RunWith(SpringRunner.class)
|
||||||
//public class MemberTest {
|
@SpringBootTest(classes = McWlApplication.class)
|
||||||
//
|
public class MemberCenterTest {
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private MemberService memberService;
|
@Autowired
|
||||||
//
|
private MemberLevelService memberLevelService;
|
||||||
// @Autowired
|
|
||||||
// private UserMemberService userMemberService;
|
@Autowired
|
||||||
//
|
private MemberController memberController;
|
||||||
// @Autowired
|
|
||||||
// private UserMemberTask userMemberTask;
|
@Autowired
|
||||||
//
|
private MemberService memberService;
|
||||||
// @Autowired
|
|
||||||
// private EmptyPointsRemindConsumer emptyPointsRemindConsumer;
|
@Autowired
|
||||||
// @Test
|
private UserMemberTask userMemberTask;
|
||||||
// public void createUserMember() {
|
|
||||||
// System.out.println(userMemberService.createUserMember(1L, 1013L, "wechat"));
|
@Autowired
|
||||||
// }
|
private MemberLevelController memberLevelController;
|
||||||
//
|
|
||||||
// @Test
|
@Autowired
|
||||||
// public void emptyPointsTaskTest() {
|
private EmptyPointsRemindConsumer emptyPointsRemindConsumer;
|
||||||
// userMemberTask.emptyPointsTsk();
|
@Test
|
||||||
// }
|
public void createUserMember() {
|
||||||
//
|
System.out.println(memberService.createUserMember(1L, 1013L, "wechat",1L));
|
||||||
// @Test
|
}
|
||||||
// public void updateSubscriptionStatusTaskTest() {
|
|
||||||
// userMemberTask.updateSubscriptionStatusTask();
|
@Test
|
||||||
// }
|
public void emptyPointsTaskTest() {
|
||||||
//
|
userMemberTask.emptyPointsTsk();
|
||||||
// @Test
|
}
|
||||||
// public void emptyPointsRemindTaskTst() {
|
|
||||||
//
|
@Test
|
||||||
// userMemberTask.emptyPointsRemindTask();
|
public void updateSubscriptionStatusTaskTest() {
|
||||||
// }
|
userMemberTask.updateSubscriptionStatusTask();
|
||||||
//
|
}
|
||||||
// @Test
|
|
||||||
// public void memberServiceTest() {
|
|
||||||
// System.out.println(memberService.list());
|
@Test
|
||||||
// }
|
public void memberServiceTest() {
|
||||||
//
|
System.out.println(memberLevelService.list());
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getPointsTest() {
|
||||||
|
AjaxResult points = memberController.getPoints();
|
||||||
|
System.out.println("points = " + points);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMemberLevelListTest() {
|
||||||
|
System.out.println("memberLevelController.getMemberBenefitList() = " + memberLevelController.getMemberBenefitList());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: Jwt工具类
|
* Jwt工具类
|
||||||
* @author DongZl
|
* @author DongZl
|
||||||
*/
|
*/
|
||||||
public class JwtUtils {
|
public class JwtUtils {
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
<version>3.8.8</version>
|
<version>3.8.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
memberCenter会员中心
|
||||||
|
</description>
|
||||||
|
|
||||||
<artifactId>mcwl-memberCenter</artifactId>
|
<artifactId>mcwl-memberCenter</artifactId>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -12,7 +12,9 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 积分消费者
|
||||||
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@ -20,6 +22,9 @@ public class EmptyPointsRemindConsumer {
|
||||||
|
|
||||||
private final MemberService memberService;
|
private final MemberService memberService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 积分清零提醒
|
||||||
|
*/
|
||||||
@RabbitListener(queues = QueueConstants.EMPTY_POINTS_REMIND_QUEUE, ackMode = "MANUAL")
|
@RabbitListener(queues = QueueConstants.EMPTY_POINTS_REMIND_QUEUE, ackMode = "MANUAL")
|
||||||
public void emptyPointsRemind(Member Member, Channel channel, Message message) {
|
public void emptyPointsRemind(Member Member, Channel channel, Message message) {
|
||||||
try {
|
try {
|
||||||
|
@ -37,20 +42,4 @@ public class EmptyPointsRemindConsumer {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RabbitListener(queues = QueueConstants.MEMBER_BILLING_QUEUE, ackMode = "MANUAL")
|
|
||||||
public void memberBillingQueue(Member member, Channel channel, Message message) {
|
|
||||||
try {
|
|
||||||
// TODO 发送短信提醒用户会员账单,如果支付成功,更新last_payment_date,并重新计算end_date(start_date + 1个月)
|
|
||||||
log.info("获取到会员账单的数据:{}", member);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("处理会员账单消息时出错: {}", e.getMessage(), e);
|
|
||||||
try {
|
|
||||||
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
log.error("消息确认失败: {}", ex.getMessage(), ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.mcwl.memberCenter.consumer;
|
||||||
|
|
||||||
|
import com.mcwl.common.constant.QueueConstants;
|
||||||
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
|
import com.rabbitmq.client.Channel;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.amqp.core.Message;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员账单消费者
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class MemberBillingConsumer {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员账单
|
||||||
|
*/
|
||||||
|
@RabbitListener(queues = QueueConstants.MEMBER_BILLING_QUEUE, ackMode = "MANUAL")
|
||||||
|
public void memberBillingQueue(Member member, Channel channel, Message message) {
|
||||||
|
try {
|
||||||
|
// TODO 发送短信提醒用户会员账单,如果支付成功,更新last_payment_date,并重新计算end_date(start_date + 1个月)
|
||||||
|
log.info("获取到会员账单的数据:{}", member);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("处理会员账单消息时出错: {}", e.getMessage(), e);
|
||||||
|
try {
|
||||||
|
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
log.error("消息确认失败: {}", ex.getMessage(), ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,6 +10,9 @@ import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员表
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@TableName("mem_member")
|
@TableName("mem_member")
|
||||||
|
|
|
@ -7,6 +7,9 @@ import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员权益表
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@TableName("mem_member_benefit")
|
@TableName("mem_member_benefit")
|
||||||
|
|
|
@ -8,6 +8,9 @@ import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员消费表
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@TableName("mem_member_consume")
|
@TableName("mem_member_consume")
|
||||||
|
|
|
@ -7,6 +7,9 @@ import com.mcwl.memberCenter.enums.MemberPeriodicEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员等级表
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@TableName("mem_member_level")
|
@TableName("mem_member_level")
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
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 com.mcwl.memberCenter.enums.PromotionEnum;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员优惠活动关联表
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("mem_member_promotion")
|
||||||
|
public class MemberPromotion extends BaseEntity {
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优惠活动ID
|
||||||
|
*/
|
||||||
|
private Long promotionId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参与时间
|
||||||
|
*/
|
||||||
|
private Date participationTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态 “已参与”“已过期”
|
||||||
|
*/
|
||||||
|
private PromotionEnum status;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
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 com.mcwl.memberCenter.enums.PromotionEnum;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 促销活动表
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("mem_promotion")
|
||||||
|
public class Promotion extends BaseEntity {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动名称
|
||||||
|
*/
|
||||||
|
private String activityName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动开始时间
|
||||||
|
*/
|
||||||
|
private Date startTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动结束时间
|
||||||
|
*/
|
||||||
|
private Date endTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动类型,如“限时折扣”、“积分奖励”
|
||||||
|
*/
|
||||||
|
private PromotionEnum activityType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 折扣/积分奖励 根据活动类型,这里可以是折扣率(如0.8代表8折)
|
||||||
|
*/
|
||||||
|
private Double activityValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动的详细描述
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 适用会员等级 可选字段,用于指定哪些会员等级可以享受此活动(用逗号分隔的会员等级ID)
|
||||||
|
*/
|
||||||
|
private String memberLevelIds;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.mcwl.memberCenter.domain.dto;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参与活动请求参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class JoinPromotionDto {
|
||||||
|
|
||||||
|
@NotNull(message = "用户id不能为空")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@NotNull(message = "活动id不能为空")
|
||||||
|
private Long promotionId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.mcwl.memberCenter.domain.dto;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
import com.mcwl.memberCenter.enums.PromotionEnum;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 促销活动请求参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PromotionDto {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动名称
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "活动名称不能为空")
|
||||||
|
private String activityName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动开始时间 校验时间格式
|
||||||
|
*/
|
||||||
|
@NotNull(message = "活动开始时间不能为空")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date startTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动结束时间
|
||||||
|
*/
|
||||||
|
@NotNull(message = "活动结束时间不能为空")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date endTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动类型,如“限时折扣”、“额外积分”
|
||||||
|
*/
|
||||||
|
@NotNull()
|
||||||
|
private PromotionEnum activityType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 折扣/积分奖励 根据活动类型,这里可以是折扣率(如0.8代表8折)
|
||||||
|
*/
|
||||||
|
@NotNull(message = "折扣/积分奖励不能为空")
|
||||||
|
@Min(value = 0, message = "折扣/积分奖励不能小于0")
|
||||||
|
private Double activityValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动的详细描述
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 适用会员等级 可选字段,用于指定哪些会员等级可以享受此活动(可以用逗号分隔的会员等级ID)
|
||||||
|
*/
|
||||||
|
private String memberLevelIds;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.mcwl.memberCenter.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 积分充值请求参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RechargePointsDto {
|
||||||
|
|
||||||
|
// 用户ID
|
||||||
|
@NotNull(message = "用户ID不能为空")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
// 充值积分
|
||||||
|
@NotNull(message = "充值积分不能为空")
|
||||||
|
@Min(value = 5, message = "充值积分不能小于5")
|
||||||
|
private Double amount;
|
||||||
|
|
||||||
|
// 剩余积分
|
||||||
|
private Double points;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.mcwl.memberCenter.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建会员请求参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserMemberDto {
|
||||||
|
|
||||||
|
// 用户ID
|
||||||
|
@NotNull(message = "用户ID不能为空")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
// 会员等级ID
|
||||||
|
@NotNull(message = "会员等级ID不能为空")
|
||||||
|
private Long memberLevelId;
|
||||||
|
|
||||||
|
// 支付方式
|
||||||
|
@NotBlank(message = "支付方式不能为空")
|
||||||
|
private String paymentMethod;
|
||||||
|
|
||||||
|
// 活动ID
|
||||||
|
private Long promotionId;
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.mcwl.web.controller.memberCenter.pojo.vo;
|
package com.mcwl.memberCenter.domain.vo;
|
||||||
|
|
||||||
import com.mcwl.memberCenter.domain.MemberBenefit;
|
import com.mcwl.memberCenter.domain.MemberBenefit;
|
||||||
import com.mcwl.memberCenter.domain.MemberLevel;
|
import com.mcwl.memberCenter.domain.MemberLevel;
|
||||||
|
@ -7,6 +7,9 @@ import lombok.Data;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员权益VO
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class MemberBenefitVO {
|
public class MemberBenefitVO {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.mcwl.web.controller.memberCenter.pojo.vo;
|
package com.mcwl.memberCenter.domain.vo;
|
||||||
|
|
||||||
import com.mcwl.memberCenter.domain.MemberConsume;
|
import com.mcwl.memberCenter.domain.MemberConsume;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
|
@ -5,6 +5,9 @@ import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员权益类型枚举
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum MemberBenefitTypeEnum {
|
public enum MemberBenefitTypeEnum {
|
||||||
|
|
|
@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员状态枚举
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum MemberEnum {
|
public enum MemberEnum {
|
||||||
|
|
|
@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员周期枚举
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum MemberPeriodicEnum {
|
public enum MemberPeriodicEnum {
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.mcwl.memberCenter.enums;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员参与活动状态
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum PromotionEnum {
|
||||||
|
/**
|
||||||
|
* 参与
|
||||||
|
*/
|
||||||
|
PARTICIPATE("participate", "参与"),
|
||||||
|
/**
|
||||||
|
* 过期
|
||||||
|
*/
|
||||||
|
EXPIRED("expired", "过期"),
|
||||||
|
// /**
|
||||||
|
// * 订阅/续订会员
|
||||||
|
// */
|
||||||
|
// SUBSCRIBE("subscribe", "订阅/续订会员"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限时折扣
|
||||||
|
*/
|
||||||
|
DISCOUNT("discount", "限时折扣"),
|
||||||
|
/**
|
||||||
|
* 积分奖励
|
||||||
|
*/
|
||||||
|
POINTS("points", "积分奖励");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
@EnumValue
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
}
|
|
@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.mcwl.memberCenter.domain.MemberBenefit;
|
import com.mcwl.memberCenter.domain.MemberBenefit;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员权益 Mapper
|
||||||
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface MemberBenefitMapper extends BaseMapper<MemberBenefit> {
|
public interface MemberBenefitMapper extends BaseMapper<MemberBenefit> {
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.mcwl.memberCenter.domain.MemberConsume;
|
import com.mcwl.memberCenter.domain.MemberConsume;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员消费记录 Mapper
|
||||||
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface MemberConsumeMapper extends BaseMapper<MemberConsume> {
|
public interface MemberConsumeMapper extends BaseMapper<MemberConsume> {
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.mcwl.memberCenter.domain.MemberLevel;
|
import com.mcwl.memberCenter.domain.MemberLevel;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员等级表 Mapper
|
||||||
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface MemberLevelMapper extends BaseMapper<MemberLevel> {
|
public interface MemberLevelMapper extends BaseMapper<MemberLevel> {
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.mcwl.memberCenter.domain.Member;
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员 Mapper
|
||||||
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface MemberMapper extends BaseMapper<Member> {
|
public interface MemberMapper extends BaseMapper<Member> {
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.mcwl.memberCenter.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.memberCenter.domain.MemberBenefit;
|
||||||
|
import com.mcwl.memberCenter.domain.MemberPromotion;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员优惠活动关联 Mapper
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface MemberPromotionMapper extends BaseMapper<MemberPromotion> {
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.mcwl.memberCenter.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.memberCenter.domain.MemberPromotion;
|
||||||
|
import com.mcwl.memberCenter.domain.Promotion;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 促销活动 Mapper
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface PromotionMapper extends BaseMapper<Promotion> {
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.mcwl.memberCenter.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
|
import com.mcwl.memberCenter.domain.MemberPromotion;
|
||||||
|
|
||||||
|
public interface MemberPromotionService extends IService<MemberPromotion> {
|
||||||
|
}
|
|
@ -12,9 +12,11 @@ public interface MemberService extends IService<Member> {
|
||||||
*
|
*
|
||||||
* @param userId 用户id
|
* @param userId 用户id
|
||||||
* @param memberLevelId 会员等级id
|
* @param memberLevelId 会员等级id
|
||||||
|
* @param paymentMethod 支付方式
|
||||||
|
* @param promotionId 活动id
|
||||||
* @return 用户会员
|
* @return 用户会员
|
||||||
*/
|
*/
|
||||||
Member createUserMember(Long userId, Long memberLevelId, String paymentMethod);
|
Member createUserMember(Long userId, Long memberLevelId, String paymentMethod, Long promotionId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -31,4 +33,6 @@ public interface MemberService extends IService<Member> {
|
||||||
|
|
||||||
|
|
||||||
Member rechargePoints(Long userId, Double points);
|
Member rechargePoints(Long userId, Double points);
|
||||||
|
|
||||||
|
Member latestSubscription(Long userId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.mcwl.memberCenter.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.memberCenter.domain.MemberPromotion;
|
||||||
|
import com.mcwl.memberCenter.domain.Promotion;
|
||||||
|
|
||||||
|
public interface PromotionService extends IService<Promotion> {
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.mcwl.memberCenter.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
|
import com.mcwl.memberCenter.domain.MemberBenefit;
|
||||||
|
import com.mcwl.memberCenter.domain.MemberLevel;
|
||||||
|
import com.mcwl.memberCenter.domain.MemberPromotion;
|
||||||
|
import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum;
|
||||||
|
import com.mcwl.memberCenter.enums.MemberEnum;
|
||||||
|
import com.mcwl.memberCenter.enums.MemberPeriodicEnum;
|
||||||
|
import com.mcwl.memberCenter.mapper.MemberMapper;
|
||||||
|
import com.mcwl.memberCenter.mapper.MemberPromotionMapper;
|
||||||
|
import com.mcwl.memberCenter.service.MemberBenefitService;
|
||||||
|
import com.mcwl.memberCenter.service.MemberLevelService;
|
||||||
|
import com.mcwl.memberCenter.service.MemberPromotionService;
|
||||||
|
import com.mcwl.memberCenter.service.MemberService;
|
||||||
|
import com.mcwl.system.service.ISysUserService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class MemberPromotionServiceImpl extends ServiceImpl<MemberPromotionMapper, MemberPromotion> implements MemberPromotionService {
|
||||||
|
|
||||||
|
}
|
|
@ -7,13 +7,17 @@ import com.mcwl.common.exception.ServiceException;
|
||||||
import com.mcwl.memberCenter.domain.MemberBenefit;
|
import com.mcwl.memberCenter.domain.MemberBenefit;
|
||||||
import com.mcwl.memberCenter.domain.MemberLevel;
|
import com.mcwl.memberCenter.domain.MemberLevel;
|
||||||
import com.mcwl.memberCenter.domain.Member;
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
|
import com.mcwl.memberCenter.domain.Promotion;
|
||||||
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;
|
||||||
|
import com.mcwl.memberCenter.enums.PromotionEnum;
|
||||||
import com.mcwl.memberCenter.mapper.MemberMapper;
|
import com.mcwl.memberCenter.mapper.MemberMapper;
|
||||||
|
import com.mcwl.memberCenter.mapper.PromotionMapper;
|
||||||
import com.mcwl.memberCenter.service.MemberBenefitService;
|
import com.mcwl.memberCenter.service.MemberBenefitService;
|
||||||
import com.mcwl.memberCenter.service.MemberLevelService;
|
import com.mcwl.memberCenter.service.MemberLevelService;
|
||||||
import com.mcwl.memberCenter.service.MemberService;
|
import com.mcwl.memberCenter.service.MemberService;
|
||||||
|
import com.mcwl.memberCenter.service.PromotionService;
|
||||||
import com.mcwl.system.service.ISysUserService;
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -31,8 +35,10 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||||
|
|
||||||
private final MemberBenefitService memberBenefitService;
|
private final MemberBenefitService memberBenefitService;
|
||||||
|
|
||||||
|
private final PromotionMapper promotionMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Member createUserMember(Long userId, Long memberLevelId, String paymentMethod) {
|
public Member createUserMember(Long userId, Long memberLevelId, String paymentMethod, Long promotionId) {
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +85,15 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||||
.eq(MemberBenefit::getBenefitType, MemberBenefitTypeEnum.POINTS)
|
.eq(MemberBenefit::getBenefitType, MemberBenefitTypeEnum.POINTS)
|
||||||
.one();
|
.one();
|
||||||
if (memberBenefit != null) {
|
if (memberBenefit != null) {
|
||||||
member.setPoints(memberBenefit.getBenefitDiscount());
|
Double points = memberBenefit.getBenefitDiscount();
|
||||||
|
// 根据活动id查询活动类型,如果为积分,则积分加成
|
||||||
|
if (promotionId != null) {
|
||||||
|
Promotion promotion = promotionMapper.selectById(promotionId);
|
||||||
|
if (promotion.getActivityType() == PromotionEnum.POINTS) {
|
||||||
|
points = points + promotion.getActivityValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
member.setPoints(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置订阅状态
|
// 设置订阅状态
|
||||||
|
@ -143,6 +157,21 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Member latestSubscription(Long userId) {
|
||||||
|
// 根据userId 查询会员,按创建时间降序,获取最新的会员
|
||||||
|
LambdaQueryWrapper<Member> qw = new LambdaQueryWrapper<>();
|
||||||
|
qw.eq(Member::getUserId, userId)
|
||||||
|
.ne(Member::getSubscriptionStatus, MemberEnum.MEMBER_CENTER_EXPIRED)
|
||||||
|
.ne(Member::getSubscriptionStatus, MemberEnum.MEMBER_CENTER_PENDING)
|
||||||
|
.orderByDesc(Member::getCreateTime);
|
||||||
|
List<Member> memberList = baseMapper.selectList(qw);
|
||||||
|
if (memberList != null && !memberList.isEmpty()) {
|
||||||
|
return memberList.get(0);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private List<Member> getUseUserMember(Long userId) {
|
private List<Member> getUseUserMember(Long userId) {
|
||||||
// startDate 小于等于当前时间、endDate 大于等于当前时间
|
// startDate 小于等于当前时间、endDate 大于等于当前时间
|
||||||
// subscriptionStatus 不为 "过期" 或 "待支付"
|
// subscriptionStatus 不为 "过期" 或 "待支付"
|
||||||
|
@ -160,6 +189,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据订阅周期和开始时间 计算结束时间
|
* 根据订阅周期和开始时间 计算结束时间
|
||||||
|
*
|
||||||
* @param subscriptionPeriod 订阅周期
|
* @param subscriptionPeriod 订阅周期
|
||||||
* @param calendar 结束时间(日历)
|
* @param calendar 结束时间(日历)
|
||||||
* @return 结束时间
|
* @return 结束时间
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.mcwl.memberCenter.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.memberCenter.domain.MemberPromotion;
|
||||||
|
import com.mcwl.memberCenter.domain.Promotion;
|
||||||
|
import com.mcwl.memberCenter.mapper.MemberPromotionMapper;
|
||||||
|
import com.mcwl.memberCenter.mapper.PromotionMapper;
|
||||||
|
import com.mcwl.memberCenter.service.MemberPromotionService;
|
||||||
|
import com.mcwl.memberCenter.service.PromotionService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PromotionServiceImpl extends ServiceImpl<PromotionMapper, Promotion> implements PromotionService {
|
||||||
|
|
||||||
|
}
|
|
@ -9,6 +9,10 @@
|
||||||
<version>3.8.8</version>
|
<version>3.8.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
myInvitation我的邀请
|
||||||
|
</description>
|
||||||
|
|
||||||
<artifactId>mcwl-myInvitation</artifactId>
|
<artifactId>mcwl-myInvitation</artifactId>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -32,6 +36,11 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mcwl</groupId>
|
||||||
|
<artifactId>mcwl-system</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
|
|
@ -4,21 +4,22 @@ 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 lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
// 提成表
|
/**
|
||||||
|
* 提成表
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@TableName("commissions")
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("inv_commission")
|
||||||
public class Commission extends BaseEntity {
|
public class Commission extends BaseEntity {
|
||||||
|
|
||||||
@TableId
|
@TableId
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
// 用户id
|
// 消费者id
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
// 消费id
|
|
||||||
private Long consumeId;
|
private Long consumeId;
|
||||||
|
|
||||||
// 提成金额
|
// 提成金额
|
||||||
|
@ -26,16 +27,4 @@ public class Commission extends BaseEntity {
|
||||||
|
|
||||||
// 支付状态
|
// 支付状态
|
||||||
private Integer payStatus;
|
private Integer payStatus;
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
Commission that = (Commission) o;
|
|
||||||
return Objects.equals(id, that.id) && Objects.equals(userId, that.userId) && Objects.equals(consumeId, that.consumeId) && Objects.equals(amount, that.amount) && Objects.equals(payStatus, that.payStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id, userId, consumeId, amount, payStatus);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,17 @@ 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 lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
// 消费表
|
/**
|
||||||
|
* 消费表
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@TableName("consumes")
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("inv_consume")
|
||||||
public class Consume extends BaseEntity {
|
public class Consume extends BaseEntity {
|
||||||
|
|
||||||
@TableId
|
@TableId
|
||||||
|
@ -24,16 +28,4 @@ public class Consume extends BaseEntity {
|
||||||
|
|
||||||
// 消费时间
|
// 消费时间
|
||||||
private Date consumeDate;
|
private Date consumeDate;
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
Consume consume = (Consume) o;
|
|
||||||
return Objects.equals(id, consume.id) && Objects.equals(userId, consume.userId) && Objects.equals(amount, consume.amount) && Objects.equals(consumeDate, consume.consumeDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id, userId, amount, consumeDate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,12 @@ import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
// 邀请表
|
/**
|
||||||
|
* 邀请表
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@TableName("invitations")
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("inv_invitation")
|
||||||
public class Invitation extends BaseEntity {
|
public class Invitation extends BaseEntity {
|
||||||
|
|
||||||
@TableId
|
@TableId
|
||||||
|
@ -24,17 +27,4 @@ public class Invitation extends BaseEntity {
|
||||||
|
|
||||||
// 邀请码
|
// 邀请码
|
||||||
private String invitationCode;
|
private String invitationCode;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
Invitation that = (Invitation) o;
|
|
||||||
return Objects.equals(id, that.id) && Objects.equals(userId, that.userId) && Objects.equals(userInviteId, that.userInviteId) && Objects.equals(invitationCode, that.invitationCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(id, userId, userInviteId, invitationCode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.mcwl.myInvitation.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消费记录Dto
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ConsumeDto {
|
||||||
|
private Long userId;
|
||||||
|
private Double amount;
|
||||||
|
private Date consumeDate;
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.mcwl.myInvitation.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class EarningsDisplay {
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
private Integer count;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.mcwl.myInvitation.domain.dto;
|
||||||
|
|
||||||
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class EarningsDisplayDto {
|
||||||
|
|
||||||
|
private SysUser user;
|
||||||
|
|
||||||
|
private Integer count;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.mcwl.myInvitation.domain.vo;
|
||||||
|
|
||||||
|
import com.mcwl.myInvitation.domain.dto.EarningsDisplay;
|
||||||
|
import com.mcwl.myInvitation.domain.dto.EarningsDisplayDto;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class EarningsDisplayVO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总金额
|
||||||
|
*/
|
||||||
|
private Double totalAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提成列表
|
||||||
|
*/
|
||||||
|
private List<EarningsDisplayDto> earningsDisplayList;
|
||||||
|
}
|
|
@ -1,11 +1,16 @@
|
||||||
package com.mcwl.myInvitation.mapper;
|
package com.mcwl.myInvitation.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.mcwl.myInvitation.domain.Commission;
|
|
||||||
import com.mcwl.myInvitation.domain.Invitation;
|
import com.mcwl.myInvitation.domain.Invitation;
|
||||||
|
import com.mcwl.myInvitation.domain.dto.EarningsDisplay;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface InvitationMapper extends BaseMapper<Invitation> {
|
public interface InvitationMapper extends BaseMapper<Invitation> {
|
||||||
|
|
||||||
|
Double getTotalAmount(Long userId);
|
||||||
|
|
||||||
|
List<EarningsDisplay> getEarningsDisplay(Long userId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,4 +5,5 @@ import com.mcwl.myInvitation.domain.Consume;
|
||||||
|
|
||||||
public interface ConsumeService extends IService<Consume> {
|
public interface ConsumeService extends IService<Consume> {
|
||||||
|
|
||||||
|
void saveConsume(Consume consume);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,10 @@ package com.mcwl.myInvitation.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.mcwl.myInvitation.domain.Invitation;
|
import com.mcwl.myInvitation.domain.Invitation;
|
||||||
|
import com.mcwl.myInvitation.domain.dto.EarningsDisplay;
|
||||||
|
import com.mcwl.myInvitation.domain.dto.EarningsDisplayDto;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface InvitationService extends IService<Invitation> {
|
public interface InvitationService extends IService<Invitation> {
|
||||||
|
|
||||||
|
@ -11,4 +15,8 @@ public interface InvitationService extends IService<Invitation> {
|
||||||
* @return 邀请码
|
* @return 邀请码
|
||||||
*/
|
*/
|
||||||
String getInvitationCode(Long userId);
|
String getInvitationCode(Long userId);
|
||||||
|
|
||||||
|
List<EarningsDisplayDto> getEarningsDisplay(Long userId);
|
||||||
|
|
||||||
|
Double getTotalAmount(Long userId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,47 @@
|
||||||
package com.mcwl.myInvitation.service.impl;
|
package com.mcwl.myInvitation.service.impl;
|
||||||
|
|
||||||
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.myInvitation.domain.Commission;
|
||||||
import com.mcwl.myInvitation.domain.Consume;
|
import com.mcwl.myInvitation.domain.Consume;
|
||||||
import com.mcwl.myInvitation.mapper.ConsumeMapper;
|
import com.mcwl.myInvitation.mapper.ConsumeMapper;
|
||||||
|
import com.mcwl.myInvitation.service.CommissionService;
|
||||||
import com.mcwl.myInvitation.service.ConsumeService;
|
import com.mcwl.myInvitation.service.ConsumeService;
|
||||||
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class ConsumeServiceImpl extends ServiceImpl<ConsumeMapper, Consume> implements ConsumeService {
|
public class ConsumeServiceImpl extends ServiceImpl<ConsumeMapper, Consume> implements ConsumeService {
|
||||||
|
|
||||||
|
private final ConsumeMapper consumeMapper;
|
||||||
|
|
||||||
|
private final CommissionService commissionService;
|
||||||
|
|
||||||
|
private final ISysUserService sysUserService;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void saveConsume(Consume consume) {
|
||||||
|
consumeMapper.insert(consume);
|
||||||
|
|
||||||
|
Commission commission = new Commission();
|
||||||
|
SysUser sysUser = sysUserService.selectUserById(consume.getUserId());
|
||||||
|
// TODO 设置用户id
|
||||||
|
// commission.setUserId(sysUser.getParentId());
|
||||||
|
|
||||||
|
// 设置消费者id
|
||||||
|
commission.setConsumeId(consume.getUserId());
|
||||||
|
|
||||||
|
// TODO 设置佣金,目前固定2.0
|
||||||
|
commission.setAmount(2.0);
|
||||||
|
commission.setPayStatus(0);
|
||||||
|
|
||||||
|
commissionService.save(commission);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,60 @@
|
||||||
package com.mcwl.myInvitation.service.impl;
|
package com.mcwl.myInvitation.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.mcwl.common.constant.JwtConstants;
|
|
||||||
import com.mcwl.common.utils.JwtUtils;
|
|
||||||
import com.mcwl.common.utils.ShareCodeUtils;
|
import com.mcwl.common.utils.ShareCodeUtils;
|
||||||
import com.mcwl.myInvitation.domain.Invitation;
|
import com.mcwl.myInvitation.domain.Invitation;
|
||||||
|
import com.mcwl.myInvitation.domain.dto.EarningsDisplay;
|
||||||
|
import com.mcwl.myInvitation.domain.dto.EarningsDisplayDto;
|
||||||
import com.mcwl.myInvitation.mapper.InvitationMapper;
|
import com.mcwl.myInvitation.mapper.InvitationMapper;
|
||||||
|
import com.mcwl.myInvitation.service.ConsumeService;
|
||||||
import com.mcwl.myInvitation.service.InvitationService;
|
import com.mcwl.myInvitation.service.InvitationService;
|
||||||
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class InvitationServiceImpl extends ServiceImpl<InvitationMapper, Invitation> implements InvitationService {
|
public class InvitationServiceImpl extends ServiceImpl<InvitationMapper, Invitation> implements InvitationService {
|
||||||
|
|
||||||
|
|
||||||
|
private final ConsumeService consumeService;
|
||||||
|
|
||||||
|
private final ISysUserService sysUserService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getInvitationCode(Long userId) {
|
public String getInvitationCode(Long userId) {
|
||||||
|
if (userId == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
// 生成邀请码
|
// 生成邀请码
|
||||||
String invitationCode = ShareCodeUtils.idToCode(userId);
|
return ShareCodeUtils.idToCode(userId);
|
||||||
return invitationCode;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<EarningsDisplayDto> getEarningsDisplay(Long userId) {
|
||||||
|
List<EarningsDisplay> earningsDisplay = baseMapper.getEarningsDisplay(userId);
|
||||||
|
if (earningsDisplay == null || earningsDisplay.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<EarningsDisplayDto> list = new ArrayList<>();
|
||||||
|
earningsDisplay.forEach(item -> {
|
||||||
|
EarningsDisplayDto edd = new EarningsDisplayDto();
|
||||||
|
edd.setUser(sysUserService.selectUserById(item.getUserId()));
|
||||||
|
edd.setCount(item.getCount());
|
||||||
|
list.add(edd);
|
||||||
|
});
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Double getTotalAmount(Long userId) {
|
||||||
|
return baseMapper.getTotalAmount(userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,5 +5,23 @@
|
||||||
<mapper namespace="com.mcwl.myInvitation.mapper.InvitationMapper">
|
<mapper namespace="com.mcwl.myInvitation.mapper.InvitationMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<select id="getTotalAmount" resultType="java.lang.Double">
|
||||||
|
select sum(com.amount)
|
||||||
|
from inv_invitation inv
|
||||||
|
join inv_consume con
|
||||||
|
on inv.user_invite_id = con.user_id
|
||||||
|
join inv_commission com on com.consume_id = con.id
|
||||||
|
where inv.user_id = #{userId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getEarningsDisplay" resultType="com.mcwl.myInvitation.domain.dto.EarningsDisplay">
|
||||||
|
select inv.user_invite_id as userId, count(con.id) as count
|
||||||
|
from inv_invitation inv
|
||||||
|
left join inv_consume con
|
||||||
|
on inv.user_invite_id = con.user_id
|
||||||
|
where inv.user_id = #{userId}
|
||||||
|
group by inv.user_invite_id
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue