feat(myInvitation): 调整

master
yang 2025-03-07 13:19:56 +08:00
parent ff6b2cdf30
commit 535b175fab
10 changed files with 93 additions and 31 deletions

View File

@ -3,20 +3,20 @@ package com.mcwl.web.controller.myInvitation;
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.page.PageDomain;
import com.mcwl.common.core.page.TableDataInfo;
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.domain.dto.EarningsDisplayDto;
import com.mcwl.myInvitation.service.InvitationService; import com.mcwl.myInvitation.service.InvitationService;
import com.mcwl.myInvitation.domain.vo.EarningsDisplayVO; import com.mcwl.myInvitation.domain.vo.EarningsDisplayVO;
import com.mcwl.system.service.ISysUserPayAccountLogService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@ -39,6 +39,8 @@ public class InvitationController {
private final InvitationService invitationService; private final InvitationService invitationService;
private final ISysUserPayAccountLogService sysUserPayAccountLogService;
/** /**
* *
@ -103,4 +105,26 @@ public class InvitationController {
} }
/**
*
*/
@GetMapping("totalAmount")
@ApiOperation(value = "累计收入金额")
public R<Double> totalAmount() {
Long userId = SecurityUtils.getUserId();
Double totalAmount = invitationService.getTotalAmount(userId);
return R.ok(totalAmount);
}
/**
*
*/
@PostMapping("withdrawalRecord")
@ApiOperation(value = "提现记录")
public TableDataInfo withdrawalRecord(@Valid @RequestBody PageDomain pageDomain) {
return sysUserPayAccountLogService.getWithdrawalRecord(pageDomain);
}
} }

View File

@ -153,21 +153,21 @@ public class PromotionServiceImpl extends ServiceImpl<PromotionMapper, Promotion
Promotion promotion = baseMapper.selectById(promotionId); Promotion promotion = baseMapper.selectById(promotionId);
if (!Optional.ofNullable(promotion).isPresent()) { if (!Optional.ofNullable(promotion).isPresent()) {
return R.fail("活动不存在"); return R.fail(HttpStatus.WARN,"活动不存在");
} }
if (promotion.getStartTime().after(new Date())) { if (promotion.getStartTime().after(new Date())) {
return R.fail("活动未开始"); return R.fail(HttpStatus.WARN,"活动未开始");
} }
// 活动是否过期 // 活动是否过期
if (promotion.getEndTime().before(new Date())) { if (promotion.getEndTime().before(new Date())) {
return R.fail("活动已过期"); return R.fail(HttpStatus.WARN,"活动已过期");
} }
// 获取当前用户是否参与过该活动 // 获取当前用户是否参与过该活动
if (isJoinPromotion(userId, promotionId)) { if (isJoinPromotion(userId, promotionId)) {
return R.fail("您已参与过该活动"); return R.fail(HttpStatus.WARN,"您已参与过该活动");
} }
// 是否在活动期间内订阅或续订会员 // 是否在活动期间内订阅或续订会员
@ -180,7 +180,7 @@ public class PromotionServiceImpl extends ServiceImpl<PromotionMapper, Promotion
String memberLevelIds = promotion.getMemberLevelIds(); String memberLevelIds = promotion.getMemberLevelIds();
if (!memberLevelIds.contains(memberLevelId)) { if (!memberLevelIds.contains(memberLevelId)) {
return R.fail("会员等级不够,无法参与该活动,请查看活动条件"); return R.fail(HttpStatus.WARN,"会员等级不够,无法参与该活动,请查看活动条件");
} }
MemberPromotion memberPromotion = getMemberPromotion(userId, promotionId); MemberPromotion memberPromotion = getMemberPromotion(userId, promotionId);
memberPromotionService.save(memberPromotion); memberPromotionService.save(memberPromotion);

View File

@ -3,16 +3,11 @@ package com.mcwl.memberCenter.task;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mcwl.common.constant.QueueConstants; import com.mcwl.common.constant.QueueConstants;
import com.mcwl.common.core.domain.entity.SysUser; import com.mcwl.common.core.domain.entity.SysUser;
import com.mcwl.memberCenter.domain.Benefit; import com.mcwl.memberCenter.domain.*;
import com.mcwl.memberCenter.domain.Member;
import com.mcwl.memberCenter.domain.MemberBenefit;
import com.mcwl.memberCenter.domain.MemberLevel;
import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum; import com.mcwl.memberCenter.enums.MemberBenefitTypeEnum;
import com.mcwl.memberCenter.enums.MemberEnum; import com.mcwl.memberCenter.enums.MemberEnum;
import com.mcwl.memberCenter.service.BenefitService; import com.mcwl.memberCenter.enums.PromotionEnum;
import com.mcwl.memberCenter.service.MemberBenefitService; import com.mcwl.memberCenter.service.*;
import com.mcwl.memberCenter.service.MemberLevelService;
import com.mcwl.memberCenter.service.MemberService;
import com.mcwl.system.service.ISysUserService; import com.mcwl.system.service.ISysUserService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
@ -38,6 +33,10 @@ public class UserMemberTask {
private final BenefitService benefitService; private final BenefitService benefitService;
private final PromotionService promotionService;
private final MemberPromotionService memberPromotionService;
/** /**
* 0 0 9 L-5 * ? * 0 0 9 L-5 * ?
@ -134,6 +133,14 @@ public class UserMemberTask {
*/ */
public void checkPromotionExpiredTask() { public void checkPromotionExpiredTask() {
List<Long> promotionIdList = new ArrayList<>();
List<Promotion> promotionList = promotionService.lambdaQuery()
.lt(Promotion::getEndTime, new Date()) // 活动结束日期小于当前时间
.list();
for (Promotion promotion : promotionList) {
promotionIdList.add(promotion.getId());
}
} }

View File

@ -19,12 +19,9 @@ public class Commission extends BaseEntity {
@TableId @TableId
private Long id; private Long id;
// 消费者id // 用户id
private Long consumeId; private Long userId;
// 提成金额 // 提成金额
private Double amount; private Double amount;
// 支付状态
private Integer payStatus;
} }

View File

@ -45,11 +45,10 @@ public class ConsumeServiceImpl extends ServiceImpl<ConsumeMapper, Consume> impl
// commission.setUserId(sysUser.getParentId()); // commission.setUserId(sysUser.getParentId());
// 设置消费者id // 设置消费者id
commission.setConsumeId(consume.getUserId()); commission.setUserId(consume.getUserId());
// TODO 设置佣金,目前固定2.0 // TODO 设置佣金,目前固定2.0
commission.setAmount(2.0); commission.setAmount(2.0);
commission.setPayStatus(0);
commissionService.save(commission); commissionService.save(commission);

View File

@ -6,12 +6,9 @@
<select id="getTotalAmount" resultType="java.lang.Double"> <select id="getTotalAmount" resultType="java.lang.Double">
select sum(com.amount) select sum(amount)
from inv_invitation inv from inv_commission
join inv_consume con where user_id = #{userId}
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>
<select id="getEarningsDisplay" resultType="com.mcwl.myInvitation.domain.dto.EarningsDisplay"> <select id="getEarningsDisplay" resultType="com.mcwl.myInvitation.domain.dto.EarningsDisplay">

View File

@ -355,6 +355,7 @@ public class AliPayServiceImpl implements AliPayService {
System.out.println(response.getBody()); System.out.println(response.getBody());
if (response.isSuccess()) { if (response.isSuccess()) {
return R.ok("提现成功"); return R.ok("提现成功");
} }

View File

@ -144,7 +144,7 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
// 保存提成表 // 保存提成表
Commission commission = new Commission(); Commission commission = new Commission();
commission.setConsumeId(inviterUserId); commission.setUserId(inviterUserId);
commission.setAmount(amount); commission.setAmount(amount);
commissionService.save(commission); commissionService.save(commission);

View File

@ -1,9 +1,13 @@
package com.mcwl.system.service; package com.mcwl.system.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.mcwl.common.core.page.PageDomain;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.system.domain.SysUserPayAccount; import com.mcwl.system.domain.SysUserPayAccount;
import com.mcwl.system.domain.SysUserPayAccountLog; import com.mcwl.system.domain.SysUserPayAccountLog;
import javax.validation.Valid;
/** /**
* *
* *
@ -12,4 +16,10 @@ import com.mcwl.system.domain.SysUserPayAccountLog;
public interface ISysUserPayAccountLogService extends IService<SysUserPayAccountLog> { public interface ISysUserPayAccountLogService extends IService<SysUserPayAccountLog> {
/**
*
* @param pageDomain
* @return TableDataInfo
*/
TableDataInfo getWithdrawalRecord(PageDomain pageDomain);
} }

View File

@ -1,12 +1,20 @@
package com.mcwl.system.service.impl; package com.mcwl.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.core.page.PageDomain;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.system.domain.SysUserPayAccount; import com.mcwl.system.domain.SysUserPayAccount;
import com.mcwl.system.domain.SysUserPayAccountLog; import com.mcwl.system.domain.SysUserPayAccountLog;
import com.mcwl.system.mapper.SysUserPayAccountLogMapper; import com.mcwl.system.mapper.SysUserPayAccountLogMapper;
import com.mcwl.system.mapper.SysUserPayAccountMapper; import com.mcwl.system.mapper.SysUserPayAccountMapper;
import com.mcwl.system.service.ISysUserPayAccountLogService; import com.mcwl.system.service.ISysUserPayAccountLogService;
import com.mcwl.system.service.ISysUserPayAccountService; import com.mcwl.system.service.ISysUserPayAccountService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
@ -15,5 +23,24 @@ import org.springframework.stereotype.Service;
@Service @Service
public class SysUserPayAccountLogServiceImpl extends ServiceImpl<SysUserPayAccountLogMapper, SysUserPayAccountLog> implements ISysUserPayAccountLogService { public class SysUserPayAccountLogServiceImpl extends ServiceImpl<SysUserPayAccountLogMapper, SysUserPayAccountLog> implements ISysUserPayAccountLogService {
/**
*
* @param pageDomain
* @return TableDataInfo
*/
@Override
public TableDataInfo getWithdrawalRecord(PageDomain pageDomain) {
Page<SysUserPayAccountLog> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
baseMapper.selectPage(page, new LambdaQueryWrapper<SysUserPayAccountLog>()
.select(SysUserPayAccountLog::getAmount, SysUserPayAccountLog::getAccount, SysUserPayAccountLog::getCreateTime)
.eq(SysUserPayAccountLog::getUserId, SecurityUtils.getUserId()));
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS);
rspData.setMsg("查询成功");
rspData.setRows(page.getRecords());
rspData.setTotal(page.getTotal());
return rspData;
}
} }